Repository navigation
fix(typescript): type a resource's 64-bit values as Long #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
moetemp
wants to merge
1
commit into
moe/up/python-proto-modules
from
moe/up/ts-long-resource-params
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
advanced/samples/invalid/resources/typescript-64-bit-map-key/expected.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| languages = ["typescript"] | ||
|
|
||
| [error] | ||
| kind = "invalid-resource-method" | ||
| contains = [ | ||
| "CounterService.Counter.add", | ||
| "parameter `totals` has a 64-bit map key", | ||
| ] |
12 changes: 12 additions & 0 deletions
12
advanced/samples/invalid/resources/typescript-64-bit-map-key/input.wit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package temporal:counters@1.0.0; | ||
|
|
||
| world system { export counter-service; } | ||
|
|
||
| /// @nexus.endpoint "__counter_service" | ||
| interface counter-service { | ||
| resource counter { | ||
| constructor(counter-id: string); | ||
|
|
||
| add: func(totals: map<s64, string>); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
advanced/samples/invalid/resources/typescript-64-bit-plain-request-field/expected.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| languages = ["typescript"] | ||
|
|
||
| [error] | ||
| kind = "invalid-resource-method" | ||
| contains = [ | ||
| "CounterService.Counter.add", | ||
| "field `total` goes into record `counter-service.add-request`", | ||
| ] |
19 changes: 19 additions & 0 deletions
19
advanced/samples/invalid/resources/typescript-64-bit-plain-request-field/input.wit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package temporal:counters@1.0.0; | ||
|
|
||
| world system { export counter-service; } | ||
|
|
||
| /// @nexus.endpoint "__counter_service" | ||
| interface counter-service { | ||
| resource counter { | ||
| constructor(counter-id: string, total: s64); | ||
|
|
||
| add: func(); | ||
| } | ||
|
|
||
| record add-request { | ||
| counter-id: string, | ||
| total: s64, | ||
| } | ||
|
|
||
| add: func(request: add-request); | ||
| } |
9 changes: 9 additions & 0 deletions
9
...nced/samples/invalid/resources/typescript-64-bit-plain-request-proto-member/expected.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| languages = ["typescript"] | ||
| descriptors = "temporal" | ||
|
|
||
| [error] | ||
| kind = "invalid-resource-method" | ||
| contains = [ | ||
| "CounterService.Counter.touch", | ||
| "parameter `seconds` goes into record `counter-service.touch-request`", | ||
| ] |
25 changes: 25 additions & 0 deletions
25
advanced/samples/invalid/resources/typescript-64-bit-plain-request-proto-member/input.wit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package temporal:counters@1.0.0; | ||
|
|
||
| world system { export counter-service; } | ||
|
|
||
| /// @nexus.endpoint "__counter_service" | ||
| interface counter-service { | ||
| /// @nexus.proto "google.protobuf.Timestamp" | ||
| record timestamp { | ||
| seconds: option<s64>, | ||
| nanos: option<s32>, | ||
| } | ||
|
|
||
| resource counter { | ||
| constructor(counter-id: string); | ||
|
|
||
| touch: func(seconds: option<s64>); | ||
| } | ||
|
|
||
| record touch-request { | ||
| counter-id: string, | ||
| at: option<timestamp>, | ||
| } | ||
|
|
||
| touch: func(request: touch-request); | ||
| } |
10 changes: 10 additions & 0 deletions
10
advanced/samples/invalid/resources/typescript-64-bit-plain-request/expected.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| languages = ["typescript"] | ||
|
|
||
| [error] | ||
| kind = "invalid-resource-method" | ||
| contains = [ | ||
| "CounterService.Counter.add", | ||
| "parameter `amount` goes into record `counter-service.add-request`", | ||
| "has no `@nexus.proto`", | ||
| "A TypeScript resource holds it as a `Long`", | ||
| ] |
19 changes: 19 additions & 0 deletions
19
advanced/samples/invalid/resources/typescript-64-bit-plain-request/input.wit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package temporal:counters@1.0.0; | ||
|
|
||
| world system { export counter-service; } | ||
|
|
||
| /// @nexus.endpoint "__counter_service" | ||
| interface counter-service { | ||
| resource counter { | ||
| constructor(counter-id: string); | ||
|
|
||
| add: func(amount: s64); | ||
| } | ||
|
|
||
| record add-request { | ||
| counter-id: string, | ||
| amount: s64, | ||
| } | ||
|
|
||
| add: func(request: add-request); | ||
| } |
9 changes: 9 additions & 0 deletions
9
advanced/samples/invalid/resources/typescript-64-bit-plain-result/expected.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| languages = ["typescript"] | ||
|
|
||
| [error] | ||
| kind = "invalid-resource" | ||
| contains = [ | ||
| "CounterService.Counter", | ||
| "operation `GetCounter` returns it with no proto wire message", | ||
| "64-bit field `total` goes over JSON as a `number`", | ||
| ] |
18 changes: 18 additions & 0 deletions
18
advanced/samples/invalid/resources/typescript-64-bit-plain-result/input.wit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package temporal:counters@1.0.0; | ||
|
|
||
| world system { export counter-service; } | ||
|
|
||
| /// @nexus.endpoint "__counter_service" | ||
| interface counter-service { | ||
| resource counter { | ||
| constructor(counter-id: string, total: s64); | ||
| } | ||
|
|
||
| type counter-result = own<counter>; | ||
|
|
||
| record get-counter-request { | ||
| counter-id: string, | ||
| } | ||
|
|
||
| get-counter: func(request: get-counter-request) -> counter-result; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,5 @@ | |
| "support/**/*.ts", | ||
| "tests/**/*.ts", | ||
| "proto/**/*.d.ts" | ||
| ], | ||
| "exclude": ["wit/stream-service/**"] | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| A TypeScript resource holds a 64-bit integer as a `Long`, which keeps every digit of a Stream offset. nexgen refuses such a value where it would go into a record without `@nexus.proto`, which holds it as a `number`, and a 64-bit map key in any TypeScript resource, since a `Long` can't key a `Record`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ where | |
| RequestPlan::Construct { | ||
| message_name, | ||
| fields, | ||
| .. | ||
| } => { | ||
| let rendered_fields = fields | ||
| .iter() | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the confusion between number and Long is likely a mistake, and not one we should compound with additional caveats and edge cases. If the overall goal is make these sepecific fields show up as longs, we could potentially just explicitly alias them in the wit.