@restatedev/restate-sdk 0.7.0 → 0.7.2-worker

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/cloudflare_bundle.js +26133 -0
  2. package/dist/io/encoder.d.ts +2 -1
  3. package/dist/io/encoder.d.ts.map +1 -1
  4. package/package.json +6 -3
  5. package/dist/connection/buffered_connection.js +0 -44
  6. package/dist/connection/buffered_connection.js.map +0 -1
  7. package/dist/connection/connection.js +0 -13
  8. package/dist/connection/connection.js.map +0 -1
  9. package/dist/connection/embedded_connection.js +0 -59
  10. package/dist/connection/embedded_connection.js.map +0 -1
  11. package/dist/connection/http_connection.js +0 -203
  12. package/dist/connection/http_connection.js.map +0 -1
  13. package/dist/connection/lambda_connection.js +0 -58
  14. package/dist/connection/lambda_connection.js.map +0 -1
  15. package/dist/embedded/api.js +0 -35
  16. package/dist/embedded/api.js.map +0 -1
  17. package/dist/embedded/handler.js +0 -28
  18. package/dist/embedded/handler.js.map +0 -1
  19. package/dist/embedded/http2_remote.js +0 -91
  20. package/dist/embedded/http2_remote.js.map +0 -1
  21. package/dist/embedded/invocation.js +0 -94
  22. package/dist/embedded/invocation.js.map +0 -1
  23. package/dist/generated/dev/restate/events.js +0 -371
  24. package/dist/generated/dev/restate/events.js.map +0 -1
  25. package/dist/generated/dev/restate/ext.js +0 -215
  26. package/dist/generated/dev/restate/ext.js.map +0 -1
  27. package/dist/generated/google/protobuf/descriptor.js +0 -6676
  28. package/dist/generated/google/protobuf/descriptor.js.map +0 -1
  29. package/dist/generated/google/protobuf/empty.js +0 -107
  30. package/dist/generated/google/protobuf/empty.js.map +0 -1
  31. package/dist/generated/google/protobuf/struct.js +0 -754
  32. package/dist/generated/google/protobuf/struct.js.map +0 -1
  33. package/dist/generated/proto/discovery.js +0 -364
  34. package/dist/generated/proto/discovery.js.map +0 -1
  35. package/dist/generated/proto/dynrpc.js +0 -668
  36. package/dist/generated/proto/dynrpc.js.map +0 -1
  37. package/dist/generated/proto/javascript.js +0 -297
  38. package/dist/generated/proto/javascript.js.map +0 -1
  39. package/dist/generated/proto/protocol.js +0 -2398
  40. package/dist/generated/proto/protocol.js.map +0 -1
  41. package/dist/generated/proto/services.js +0 -1535
  42. package/dist/generated/proto/services.js.map +0 -1
  43. package/dist/generated/proto/test.js +0 -321
  44. package/dist/generated/proto/test.js.map +0 -1
  45. package/dist/invocation.js +0 -154
  46. package/dist/invocation.js.map +0 -1
  47. package/dist/io/decoder.js +0 -133
  48. package/dist/io/decoder.js.map +0 -1
  49. package/dist/io/encoder.js +0 -68
  50. package/dist/io/encoder.js.map +0 -1
  51. package/dist/journal.js +0 -372
  52. package/dist/journal.js.map +0 -1
  53. package/dist/local_state_store.js +0 -72
  54. package/dist/local_state_store.js.map +0 -1
  55. package/dist/public_api.js +0 -58
  56. package/dist/public_api.js.map +0 -1
  57. package/dist/restate_context.js +0 -46
  58. package/dist/restate_context.js.map +0 -1
  59. package/dist/restate_context_impl.js +0 -375
  60. package/dist/restate_context_impl.js.map +0 -1
  61. package/dist/server/base_restate_server.js +0 -364
  62. package/dist/server/base_restate_server.js.map +0 -1
  63. package/dist/server/restate_lambda_handler.js +0 -247
  64. package/dist/server/restate_lambda_handler.js.map +0 -1
  65. package/dist/server/restate_server.js +0 -186
  66. package/dist/server/restate_server.js.map +0 -1
  67. package/dist/state_machine.js +0 -403
  68. package/dist/state_machine.js.map +0 -1
  69. package/dist/types/errors.js +0 -267
  70. package/dist/types/errors.js.map +0 -1
  71. package/dist/types/grpc.js +0 -68
  72. package/dist/types/grpc.js.map +0 -1
  73. package/dist/types/protocol.js +0 -125
  74. package/dist/types/protocol.js.map +0 -1
  75. package/dist/types/router.js +0 -36
  76. package/dist/types/router.js.map +0 -1
  77. package/dist/types/types.js +0 -126
  78. package/dist/types/types.js.map +0 -1
  79. package/dist/utils/assumpsions.js +0 -101
  80. package/dist/utils/assumpsions.js.map +0 -1
  81. package/dist/utils/logger.js +0 -102
  82. package/dist/utils/logger.js.map +0 -1
  83. package/dist/utils/public_utils.js +0 -49
  84. package/dist/utils/public_utils.js.map +0 -1
  85. package/dist/utils/rand.js +0 -114
  86. package/dist/utils/rand.js.map +0 -1
  87. package/dist/utils/utils.js +0 -144
  88. package/dist/utils/utils.js.map +0 -1
@@ -1,267 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.errorToErrorMessage = exports.failureToError = exports.failureToTerminalError = exports.errorToFailureWithTerminal = exports.errorToFailure = exports.RetryableError = exports.TerminalError = exports.RestateError = exports.ensureError = exports.RestateErrorCodes = exports.ErrorCodes = void 0;
14
- /* eslint-disable @typescript-eslint/no-explicit-any */
15
- const protocol_1 = require("../generated/proto/protocol");
16
- const utils_1 = require("../utils/utils");
17
- const javascript_1 = require("../generated/proto/javascript");
18
- var ErrorCodes;
19
- (function (ErrorCodes) {
20
- /**
21
- * Not an error; returned on success.
22
- * HTTP 200
23
- */
24
- ErrorCodes[ErrorCodes["OK"] = 0] = "OK";
25
- /**
26
- * The operation was cancelled, typically by the caller.
27
- * HTTP 408
28
- */
29
- ErrorCodes[ErrorCodes["CANCELLED"] = 1] = "CANCELLED";
30
- /**
31
- * Unknown error. For example, this error may be returned when a
32
- * Status value received from another address space belongs to an error
33
- * space that is not known in this address space. Also errors raised by APIs
34
- * that do not return enough error information may be converted to this
35
- * error.
36
- * HTTP 500
37
- */
38
- ErrorCodes[ErrorCodes["UNKNOWN"] = 2] = "UNKNOWN";
39
- /**
40
- * The client specified an invalid argument. Note that
41
- * this differs from FAILED_PRECONDITION. INVALID_ARGUMENT indicates
42
- * arguments that are problematic regardless of the state of the system
43
- * (e.g., a malformed file name).
44
- * HTTP 400
45
- */
46
- ErrorCodes[ErrorCodes["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
47
- /**
48
- * The deadline expired before the operation could
49
- * complete. For operations that change the state of the system, this error
50
- * may be returned even if the operation has completed successfully. For
51
- * example, a successful response from a server could have been delayed
52
- * long.
53
- * HTTP 408
54
- */
55
- ErrorCodes[ErrorCodes["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
56
- /**
57
- * Some requested entity (e.g., file or directory) was not
58
- * found. Note to server developers: if a request is denied for an entire
59
- * class of users, such as gradual feature rollout or undocumented
60
- * allowlist, NOT_FOUND may be used. If a request is denied for some users
61
- * within a class of users, such as user-based access control,
62
- * PERMISSION_DENIED must be used.
63
- * HTTP 404
64
- */
65
- ErrorCodes[ErrorCodes["NOT_FOUND"] = 5] = "NOT_FOUND";
66
- /**
67
- * The entity that a client attempted to create (e.g., file
68
- * or directory) already exists.
69
- * HTTP 409
70
- */
71
- ErrorCodes[ErrorCodes["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
72
- /**
73
- * The caller does not have permission to execute the
74
- * specified operation. PERMISSION_DENIED must not be used for rejections
75
- * caused by exhausting some resource (use RESOURCE_EXHAUSTED instead for
76
- * those errors). PERMISSION_DENIED must not be used if the caller can not
77
- * be identified (use UNAUTHENTICATED instead for those errors). This error
78
- * code does not imply the request is valid or the requested entity exists
79
- * or satisfies other pre-conditions.
80
- * HTTP 403
81
- */
82
- ErrorCodes[ErrorCodes["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
83
- /**
84
- * Some resource has been exhausted, perhaps a per-user
85
- * quota, or perhaps the entire file system is out of space.
86
- * HTTP 413
87
- */
88
- ErrorCodes[ErrorCodes["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
89
- /**
90
- * The operation was rejected because the system is
91
- * not in a state required for the operation's execution. For example, the
92
- * directory to be deleted is non-empty, an rmdir operation is applied to a
93
- * non-directory, etc. Service implementors can use the following guidelines
94
- * to decide between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: (a) Use
95
- * UNAVAILABLE if the client can retry just the failing call. (b) Use
96
- * ABORTED if the client should retry at a higher level (e.g., when a
97
- * client-specified test-and-set fails, indicating the client should restart
98
- * a read-modify-write sequence). (c) Use FAILED_PRECONDITION if the client
99
- * should not retry until the system state has been explicitly fixed. E.g.,
100
- * if an "rmdir" fails because the directory is non-empty,
101
- * FAILED_PRECONDITION should be returned since the client should not retry
102
- * unless the files are deleted from the directory.
103
- * HTTP 412
104
- */
105
- ErrorCodes[ErrorCodes["FAILED_PRECONDITION"] = 9] = "FAILED_PRECONDITION";
106
- /**
107
- * The operation was aborted, typically due to a concurrency issue
108
- * such as a sequencer check failure or transaction abort. See the
109
- * guidelines above for deciding between FAILED_PRECONDITION, ABORTED, and
110
- * UNAVAILABLE.
111
- * HTTP 409
112
- */
113
- ErrorCodes[ErrorCodes["ABORTED"] = 10] = "ABORTED";
114
- /**
115
- * The operation was attempted past the valid range. E.g.,
116
- * seeking or reading past end-of-file. Unlike INVALID_ARGUMENT, this error
117
- * indicates a problem that may be fixed if the system state changes. For
118
- * example, a 32-bit file system will generate INVALID_ARGUMENT if asked to
119
- * read at an offset that is not in the range [0,2^32-1], but it will
120
- * generate OUT_OF_RANGE if asked to read from an offset past the current
121
- * file size. There is a fair bit of overlap between FAILED_PRECONDITION and
122
- * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error)
123
- * when it applies so that callers who are iterating through a space can
124
- * easily look for an OUT_OF_RANGE error to detect when they are done.
125
- * HTTP 400
126
- */
127
- ErrorCodes[ErrorCodes["OUT_OF_RANGE"] = 11] = "OUT_OF_RANGE";
128
- /**
129
- * The operation is not implemented or is not
130
- * supported/enabled in this service.
131
- * HTTP 501
132
- */
133
- ErrorCodes[ErrorCodes["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
134
- /**
135
- * Internal errors. This means that some invariants expected by
136
- * the underlying system have been broken. This error code is reserved for
137
- * serious errors.
138
- * HTTP 500
139
- */
140
- ErrorCodes[ErrorCodes["INTERNAL"] = 13] = "INTERNAL";
141
- /**
142
- * The service is currently unavailable. This is most likely a
143
- * transient condition, which can be corrected by retrying with a backoff.
144
- * Note that it is not always safe to retry non-idempotent operations.
145
- * HTTP 503
146
- */
147
- ErrorCodes[ErrorCodes["UNAVAILABLE"] = 14] = "UNAVAILABLE";
148
- /**
149
- * Unrecoverable data loss or corruption.
150
- * HTTP 500
151
- */
152
- ErrorCodes[ErrorCodes["DATA_LOSS"] = 15] = "DATA_LOSS";
153
- /**
154
- * The request does not have valid authentication
155
- * credentials for the operation.
156
- * HTTP 401
157
- */
158
- ErrorCodes[ErrorCodes["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
159
- })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
160
- var RestateErrorCodes;
161
- (function (RestateErrorCodes) {
162
- RestateErrorCodes[RestateErrorCodes["JOURNAL_MISMATCH"] = 32] = "JOURNAL_MISMATCH";
163
- RestateErrorCodes[RestateErrorCodes["PROTOCOL_VIOLATION"] = 33] = "PROTOCOL_VIOLATION";
164
- })(RestateErrorCodes = exports.RestateErrorCodes || (exports.RestateErrorCodes = {}));
165
- function ensureError(e) {
166
- if (e instanceof Error) {
167
- return e;
168
- }
169
- let msg;
170
- try {
171
- msg = JSON.stringify(e);
172
- }
173
- catch (x) {
174
- msg = "(no JSON representation)";
175
- }
176
- return new Error("Non-Error value: " + msg);
177
- }
178
- exports.ensureError = ensureError;
179
- class RestateError extends Error {
180
- code;
181
- constructor(message, options) {
182
- super(message, { cause: options?.cause });
183
- this.code = options?.errorCode ?? ErrorCodes.INTERNAL;
184
- }
185
- toFailure() {
186
- return protocol_1.Failure.create({
187
- code: this.code,
188
- message: this.message,
189
- });
190
- }
191
- }
192
- exports.RestateError = RestateError;
193
- // Does not lead to Restate retries
194
- // Leads to an output message with a failure defined
195
- class TerminalError extends RestateError {
196
- constructor(message, options) {
197
- super(message, options);
198
- }
199
- }
200
- exports.TerminalError = TerminalError;
201
- // Leads to Restate retries
202
- class RetryableError extends RestateError {
203
- constructor(message, options) {
204
- super(message, options);
205
- }
206
- static internal(message) {
207
- return new RetryableError(message);
208
- }
209
- static journalMismatch(journalIndex, replayMessage, journalEntry) {
210
- const msg = `Journal mismatch: Replayed journal entries did not correspond to the user code. The user code has to be deterministic!
211
- The journal entry at position ${journalIndex} was:
212
- - In the user code: type: ${journalEntry.messageType}, message:${(0, utils_1.printMessageAsJson)(journalEntry.message)}
213
- - In the replayed messages: type: ${replayMessage.messageType}, message: ${(0, utils_1.printMessageAsJson)(replayMessage.message)}`;
214
- return new RetryableError(msg, {
215
- errorCode: RestateErrorCodes.JOURNAL_MISMATCH,
216
- });
217
- }
218
- static protocolViolation(message) {
219
- return new RetryableError(message, {
220
- errorCode: RestateErrorCodes.PROTOCOL_VIOLATION,
221
- });
222
- }
223
- static apiViolation(message) {
224
- return new RetryableError(`API violation: ${message}`, {
225
- errorCode: ErrorCodes.INTERNAL,
226
- });
227
- }
228
- }
229
- exports.RetryableError = RetryableError;
230
- function errorToFailure(err) {
231
- return err instanceof RestateError
232
- ? err.toFailure()
233
- : protocol_1.Failure.create({
234
- code: ErrorCodes.INTERNAL,
235
- message: err.message,
236
- });
237
- }
238
- exports.errorToFailure = errorToFailure;
239
- function errorToFailureWithTerminal(err) {
240
- const failure = errorToFailure(err);
241
- return javascript_1.FailureWithTerminal.create({
242
- failure,
243
- terminal: err instanceof TerminalError,
244
- });
245
- }
246
- exports.errorToFailureWithTerminal = errorToFailureWithTerminal;
247
- function failureToTerminalError(failure) {
248
- return failureToError(failure, true);
249
- }
250
- exports.failureToTerminalError = failureToTerminalError;
251
- function failureToError(failure, terminalError) {
252
- const errorMessage = failure.message ?? "(missing error message)";
253
- const errorCode = failure.code ?? ErrorCodes.INTERNAL;
254
- return terminalError
255
- ? new TerminalError(errorMessage, { errorCode })
256
- : new RestateError(errorMessage, { errorCode });
257
- }
258
- exports.failureToError = failureToError;
259
- function errorToErrorMessage(err) {
260
- const code = err instanceof RestateError ? err.code : ErrorCodes.INTERNAL;
261
- return protocol_1.ErrorMessage.create({
262
- code: code,
263
- message: err.message,
264
- });
265
- }
266
- exports.errorToErrorMessage = errorToErrorMessage;
267
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,uDAAuD;AAEvD,0DAAoE;AACpE,0CAAoD;AAGpD,8DAAoE;AAEpE,IAAY,UA4IX;AA5ID,WAAY,UAAU;IACpB;;;OAGG;IACH,uCAAM,CAAA;IACN;;;OAGG;IACH,qDAAa,CAAA;IACb;;;;;;;OAOG;IACH,iDAAW,CAAA;IACX;;;;;;OAMG;IACH,mEAAoB,CAAA;IACpB;;;;;;;OAOG;IACH,qEAAqB,CAAA;IACrB;;;;;;;;OAQG;IACH,qDAAa,CAAA;IACb;;;;OAIG;IACH,+DAAkB,CAAA;IAClB;;;;;;;;;OASG;IACH,qEAAqB,CAAA;IACrB;;;;OAIG;IACH,uEAAsB,CAAA;IACtB;;;;;;;;;;;;;;;OAeG;IACH,yEAAuB,CAAA;IACvB;;;;;;OAMG;IACH,kDAAY,CAAA;IACZ;;;;;;;;;;;;OAYG;IACH,4DAAiB,CAAA;IACjB;;;;OAIG;IACH,8DAAkB,CAAA;IAClB;;;;;OAKG;IACH,oDAAa,CAAA;IACb;;;;;OAKG;IACH,0DAAgB,CAAA;IAChB;;;OAGG;IACH,sDAAc,CAAA;IACd;;;;OAIG;IACH,kEAAoB,CAAA;AACtB,CAAC,EA5IW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QA4IrB;AACD,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,kFAAqB,CAAA;IACrB,sFAAuB,CAAA;AACzB,CAAC,EAHW,iBAAiB,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AO,EAAE,IAAI,CAAkB,CAAC;AACxD,CAAC;AAFD,wDAEC;AAED,SAAgB,cAAc,CAC5B,OAAgB,EAChB,aAAsB;IAEtB,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,IAAI,yBAAyB,CAAC;IAClE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC;IAEtD,OAAO,aAAa;QAClB,CAAC,CAAC,IAAI,aAAa,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC;QAChD,CAAC,CAAC,IAAI,YAAY,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;AACpD,CAAC;AAVD,wCAUC;AAED,SAAgB,mBAAmB,CAAC,GAAU;IAC5C,MAAM,IAAI,GAAG,GAAG,YAAY,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;IAE1E,OAAO,uBAAY,CAAC,MAAM,CAAC;QACzB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAC;AACL,CAAC;AAPD,kDAOC"}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.HostedGrpcServiceMethod = exports.GrpcService = exports.GrpcServiceMethod = void 0;
14
- const restate_context_1 = require("../restate_context");
15
- class GrpcServiceMethod {
16
- name;
17
- localName;
18
- localFn;
19
- inputDecoder;
20
- outputEncoder;
21
- constructor(name, // the gRPC name as defined in the .proto file
22
- localName, // the method name as defined in the class.
23
- localFn, // the actual function
24
- inputDecoder, // the protobuf decoder
25
- outputEncoder // protobuf encoder
26
- ) {
27
- this.name = name;
28
- this.localName = localName;
29
- this.localFn = localFn;
30
- this.inputDecoder = inputDecoder;
31
- this.outputEncoder = outputEncoder;
32
- }
33
- }
34
- exports.GrpcServiceMethod = GrpcServiceMethod;
35
- class GrpcService {
36
- name;
37
- packge;
38
- impl;
39
- methods;
40
- constructor(name, packge, impl, methods) {
41
- this.name = name;
42
- this.packge = packge;
43
- this.impl = impl;
44
- this.methods = methods;
45
- }
46
- }
47
- exports.GrpcService = GrpcService;
48
- class HostedGrpcServiceMethod {
49
- instance;
50
- packge;
51
- service;
52
- method;
53
- constructor(instance, packge, service, method) {
54
- this.instance = instance;
55
- this.packge = packge;
56
- this.service = service;
57
- this.method = method;
58
- }
59
- // The end of an invoke is either a response (Uint8Array) or a SuspensionMessage
60
- async invoke(context, inBytes) {
61
- const instanceWithContext = (0, restate_context_1.setContext)(this.instance, context);
62
- const input = this.method.inputDecoder(inBytes);
63
- const result = await this.method.localFn(instanceWithContext, input);
64
- return this.method.outputEncoder(result);
65
- }
66
- }
67
- exports.HostedGrpcServiceMethod = HostedGrpcServiceMethod;
68
- //# sourceMappingURL=grpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../src/types/grpc.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,wDAAgE;AAGhE,MAAa,iBAAiB;IAEjB;IACA;IACA;IACA;IACA;IALX,YACW,IAAY,EAAE,8CAA8C;IAC5D,SAAiB,EAAE,2CAA2C;IAC9D,OAAoD,EAAE,sBAAsB;IAC5E,YAAoC,EAAE,uBAAuB;IAC7D,aAAwC,CAAC,mBAAmB;;QAJ5D,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAQ;QACjB,YAAO,GAAP,OAAO,CAA6C;QACpD,iBAAY,GAAZ,YAAY,CAAwB;QACpC,kBAAa,GAAb,aAAa,CAA2B;IAChD,CAAC;CACL;AARD,8CAQC;AAED,MAAa,WAAW;IAEX;IACA;IACA;IACA;IAJX,YACW,IAAY,EACZ,MAAc,EACd,IAAY,EACZ,OAAmD;QAHnD,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAA4C;IAC3D,CAAC;CACL;AAPD,kCAOC;AAED,MAAa,uBAAuB;IAEvB;IACA;IACA;IACA;IAJX,YACW,QAAiB,EACjB,MAAc,EACd,OAAe,EACf,MAA+B;QAH/B,aAAQ,GAAR,QAAQ,CAAS;QACjB,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAyB;IACvC,CAAC;IAEJ,gFAAgF;IAChF,KAAK,CAAC,MAAM,CACV,OAAuB,EACvB,OAAmB;QAEnB,MAAM,mBAAmB,GAAG,IAAA,4BAAU,EAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAM,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF;AAlBD,0DAkBC"}
@@ -1,125 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.SUSPENSION_TRIGGERS = exports.PROTOBUF_MESSAGE_BY_TYPE = exports.PROTOBUF_MESSAGE_NAME_BY_TYPE = exports.KNOWN_MESSAGE_TYPES = exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE = exports.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE = exports.AWAKEABLE_ENTRY_MESSAGE_TYPE = exports.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE = exports.INVOKE_ENTRY_MESSAGE_TYPE = exports.SLEEP_ENTRY_MESSAGE_TYPE = exports.CLEAR_STATE_ENTRY_MESSAGE_TYPE = exports.SET_STATE_ENTRY_MESSAGE_TYPE = exports.GET_STATE_ENTRY_MESSAGE_TYPE = exports.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE = exports.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE = exports.END_MESSAGE_TYPE = exports.ENTRY_ACK_MESSAGE_TYPE = exports.ERROR_MESSAGE_TYPE = exports.SUSPENSION_MESSAGE_TYPE = exports.COMPLETION_MESSAGE_TYPE = exports.START_MESSAGE_TYPE = exports.EntryAckMessage = exports.SuspensionMessage = exports.StartMessage = exports.SleepEntryMessage = exports.SetStateEntryMessage = exports.PollInputStreamEntryMessage = exports.OutputStreamEntryMessage = exports.InvokeEntryMessage = exports.GetStateEntryMessage = exports.EndMessage = exports.ErrorMessage = exports.CompletionMessage = exports.CompleteAwakeableEntryMessage = exports.ClearStateEntryMessage = exports.BackgroundInvokeEntryMessage = exports.AwakeableEntryMessage = void 0;
14
- const javascript_1 = require("../generated/proto/javascript");
15
- const protocol_1 = require("../generated/proto/protocol");
16
- // Re-export the protobuf messages.
17
- var protocol_2 = require("../generated/proto/protocol");
18
- Object.defineProperty(exports, "AwakeableEntryMessage", { enumerable: true, get: function () { return protocol_2.AwakeableEntryMessage; } });
19
- Object.defineProperty(exports, "BackgroundInvokeEntryMessage", { enumerable: true, get: function () { return protocol_2.BackgroundInvokeEntryMessage; } });
20
- Object.defineProperty(exports, "ClearStateEntryMessage", { enumerable: true, get: function () { return protocol_2.ClearStateEntryMessage; } });
21
- Object.defineProperty(exports, "CompleteAwakeableEntryMessage", { enumerable: true, get: function () { return protocol_2.CompleteAwakeableEntryMessage; } });
22
- Object.defineProperty(exports, "CompletionMessage", { enumerable: true, get: function () { return protocol_2.CompletionMessage; } });
23
- Object.defineProperty(exports, "ErrorMessage", { enumerable: true, get: function () { return protocol_2.ErrorMessage; } });
24
- Object.defineProperty(exports, "EndMessage", { enumerable: true, get: function () { return protocol_2.EndMessage; } });
25
- Object.defineProperty(exports, "GetStateEntryMessage", { enumerable: true, get: function () { return protocol_2.GetStateEntryMessage; } });
26
- Object.defineProperty(exports, "InvokeEntryMessage", { enumerable: true, get: function () { return protocol_2.InvokeEntryMessage; } });
27
- Object.defineProperty(exports, "OutputStreamEntryMessage", { enumerable: true, get: function () { return protocol_2.OutputStreamEntryMessage; } });
28
- Object.defineProperty(exports, "PollInputStreamEntryMessage", { enumerable: true, get: function () { return protocol_2.PollInputStreamEntryMessage; } });
29
- Object.defineProperty(exports, "SetStateEntryMessage", { enumerable: true, get: function () { return protocol_2.SetStateEntryMessage; } });
30
- Object.defineProperty(exports, "SleepEntryMessage", { enumerable: true, get: function () { return protocol_2.SleepEntryMessage; } });
31
- Object.defineProperty(exports, "StartMessage", { enumerable: true, get: function () { return protocol_2.StartMessage; } });
32
- Object.defineProperty(exports, "SuspensionMessage", { enumerable: true, get: function () { return protocol_2.SuspensionMessage; } });
33
- Object.defineProperty(exports, "EntryAckMessage", { enumerable: true, get: function () { return protocol_2.EntryAckMessage; } });
34
- // Export the protocol message types as defined by the restate protocol.
35
- exports.START_MESSAGE_TYPE = 0x0000n;
36
- exports.COMPLETION_MESSAGE_TYPE = 0x0001n;
37
- exports.SUSPENSION_MESSAGE_TYPE = 0x0002n;
38
- exports.ERROR_MESSAGE_TYPE = 0x0003n;
39
- exports.ENTRY_ACK_MESSAGE_TYPE = 0x0004n;
40
- exports.END_MESSAGE_TYPE = 0x0005n;
41
- exports.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE = 0x0400n;
42
- exports.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE = 0x0401n;
43
- exports.GET_STATE_ENTRY_MESSAGE_TYPE = 0x0800n;
44
- exports.SET_STATE_ENTRY_MESSAGE_TYPE = 0x0801n;
45
- exports.CLEAR_STATE_ENTRY_MESSAGE_TYPE = 0x0802n;
46
- exports.SLEEP_ENTRY_MESSAGE_TYPE = 0x0c00n;
47
- exports.INVOKE_ENTRY_MESSAGE_TYPE = 0x0c01n;
48
- exports.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE = 0x0c02n;
49
- exports.AWAKEABLE_ENTRY_MESSAGE_TYPE = 0x0c03n;
50
- exports.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE = 0x0c04n;
51
- // Export the custom message types
52
- // Side effects are custom messages because the runtime does not need to inspect them
53
- exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE = 0xfc01n;
54
- // Restate DuplexStream
55
- // Message types in the protocol.
56
- // Custom message types (per SDK) such as side effect entry message should not be included here.
57
- exports.KNOWN_MESSAGE_TYPES = new Set([
58
- exports.START_MESSAGE_TYPE,
59
- exports.COMPLETION_MESSAGE_TYPE,
60
- exports.SUSPENSION_MESSAGE_TYPE,
61
- exports.ERROR_MESSAGE_TYPE,
62
- exports.ENTRY_ACK_MESSAGE_TYPE,
63
- exports.END_MESSAGE_TYPE,
64
- exports.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE,
65
- exports.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE,
66
- exports.GET_STATE_ENTRY_MESSAGE_TYPE,
67
- exports.SET_STATE_ENTRY_MESSAGE_TYPE,
68
- exports.CLEAR_STATE_ENTRY_MESSAGE_TYPE,
69
- exports.SLEEP_ENTRY_MESSAGE_TYPE,
70
- exports.INVOKE_ENTRY_MESSAGE_TYPE,
71
- exports.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE,
72
- exports.AWAKEABLE_ENTRY_MESSAGE_TYPE,
73
- exports.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE,
74
- exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE,
75
- ]);
76
- exports.PROTOBUF_MESSAGE_NAME_BY_TYPE = new Map([
77
- [exports.START_MESSAGE_TYPE, "StartMessage"],
78
- [exports.COMPLETION_MESSAGE_TYPE, "CompletionMessage"],
79
- [exports.SUSPENSION_MESSAGE_TYPE, "SuspensionMessage"],
80
- [exports.ERROR_MESSAGE_TYPE, "ErrorMessage"],
81
- [exports.ENTRY_ACK_MESSAGE_TYPE, "EntryAckMessage"],
82
- [exports.END_MESSAGE_TYPE, "EndMessage"],
83
- [exports.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE, "PollInputStreamEntryMessage"],
84
- [exports.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE, "OutputStreamEntryMessage"],
85
- [exports.GET_STATE_ENTRY_MESSAGE_TYPE, "GetStateEntryMessage"],
86
- [exports.SET_STATE_ENTRY_MESSAGE_TYPE, "SetStateEntryMessage"],
87
- [exports.CLEAR_STATE_ENTRY_MESSAGE_TYPE, "ClearStateEntryMessage"],
88
- [exports.SLEEP_ENTRY_MESSAGE_TYPE, "SleepEntryMessage"],
89
- [exports.INVOKE_ENTRY_MESSAGE_TYPE, "InvokeEntryMessage"],
90
- [exports.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE, "BackgroundInvokeEntryMessage"],
91
- [exports.AWAKEABLE_ENTRY_MESSAGE_TYPE, "AwakeableEntryMessage"],
92
- [exports.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE, "CompleteAwakeableEntryMessage"],
93
- [exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, "SideEffectEntryMessage"],
94
- ]);
95
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
- const PROTOBUF_MESSAGES = [
97
- [exports.START_MESSAGE_TYPE, protocol_1.StartMessage],
98
- [exports.COMPLETION_MESSAGE_TYPE, protocol_1.CompletionMessage],
99
- [exports.SUSPENSION_MESSAGE_TYPE, protocol_1.SuspensionMessage],
100
- [exports.ERROR_MESSAGE_TYPE, protocol_1.ErrorMessage],
101
- [exports.ENTRY_ACK_MESSAGE_TYPE, protocol_1.EntryAckMessage],
102
- [exports.END_MESSAGE_TYPE, protocol_1.EndMessage],
103
- [exports.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE, protocol_1.PollInputStreamEntryMessage],
104
- [exports.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE, protocol_1.OutputStreamEntryMessage],
105
- [exports.GET_STATE_ENTRY_MESSAGE_TYPE, protocol_1.GetStateEntryMessage],
106
- [exports.SET_STATE_ENTRY_MESSAGE_TYPE, protocol_1.SetStateEntryMessage],
107
- [exports.CLEAR_STATE_ENTRY_MESSAGE_TYPE, protocol_1.ClearStateEntryMessage],
108
- [exports.SLEEP_ENTRY_MESSAGE_TYPE, protocol_1.SleepEntryMessage],
109
- [exports.INVOKE_ENTRY_MESSAGE_TYPE, protocol_1.InvokeEntryMessage],
110
- [exports.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE, protocol_1.BackgroundInvokeEntryMessage],
111
- [exports.AWAKEABLE_ENTRY_MESSAGE_TYPE, protocol_1.AwakeableEntryMessage],
112
- [exports.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE, protocol_1.CompleteAwakeableEntryMessage],
113
- [exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, javascript_1.SideEffectEntryMessage],
114
- ];
115
- exports.PROTOBUF_MESSAGE_BY_TYPE = new Map(PROTOBUF_MESSAGES);
116
- // These message types will trigger sending a suspension message from the runtime
117
- // for each of the protocol modes
118
- exports.SUSPENSION_TRIGGERS = [
119
- exports.INVOKE_ENTRY_MESSAGE_TYPE,
120
- exports.GET_STATE_ENTRY_MESSAGE_TYPE,
121
- exports.SIDE_EFFECT_ENTRY_MESSAGE_TYPE,
122
- exports.AWAKEABLE_ENTRY_MESSAGE_TYPE,
123
- exports.SLEEP_ENTRY_MESSAGE_TYPE,
124
- ];
125
- //# sourceMappingURL=protocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,8DAAuE;AACvE,0DAiBqC;AAErC,mCAAmC;AACnC,wDAiBqC;AAhBnC,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAC5B,kHAAA,sBAAsB,OAAA;AACtB,yHAAA,6BAA6B,OAAA;AAC7B,6GAAA,iBAAiB,OAAA;AACjB,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,gHAAA,oBAAoB,OAAA;AACpB,8GAAA,kBAAkB,OAAA;AAClB,oHAAA,wBAAwB,OAAA;AACxB,uHAAA,2BAA2B,OAAA;AAC3B,gHAAA,oBAAoB,OAAA;AACpB,6GAAA,iBAAiB,OAAA;AACjB,wGAAA,YAAY,OAAA;AACZ,6GAAA,iBAAiB,OAAA;AACjB,2GAAA,eAAe,OAAA;AAGjB,wEAAwE;AAC3D,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAClC,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAClC,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,sBAAsB,GAAG,OAAO,CAAC;AACjC,QAAA,gBAAgB,GAAG,OAAO,CAAC;AAC3B,QAAA,oCAAoC,GAAG,OAAO,CAAC;AAC/C,QAAA,gCAAgC,GAAG,OAAO,CAAC;AAC3C,QAAA,4BAA4B,GAAG,OAAO,CAAC;AACvC,QAAA,4BAA4B,GAAG,OAAO,CAAC;AACvC,QAAA,8BAA8B,GAAG,OAAO,CAAC;AACzC,QAAA,wBAAwB,GAAG,OAAO,CAAC;AACnC,QAAA,yBAAyB,GAAG,OAAO,CAAC;AACpC,QAA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AC;IACxE,CAAC,sCAA8B,EAAE,wBAAwB,CAAC;CAC3D,CAAC,CAAC;AAEH,8DAA8D;AAC9D,MAAM,iBAAiB,GAAyB;IAC9C,CAAC,0BAAkB,EAAE,uBAAY,CAAC;IAClC,CAAC,+BAAuB,EAAE,4BAAiB,CAAC;IAC5C,CAAC,+BAAuB,EAAE,4BAAiB,CAAC;IAC5C,CAAC,0BAAkB,EAAE,uBAAY,CAAC;IAClC,CAAC,8BAAsB,EAAE,0BAAe,CAAC;IACzC,CAAC,wBAAgB,EAAE,qBAAU,CAAC;IAC9B,CAAC,4CAAoC,EAAE,sCAA2B,CAAC;IACnE,CAAC,wCAAgC,EAAE,mCAAwB,CAAC;IAC5D,CAAC,oCAA4B,EAAE,+BAAoB,CAAC;IACpD,CAAC,oCAA4B,EAAE,+BAAoB,CAAC;IACpD,CAAC,sCAA8B,EAAE,iCAAsB,CAAC;IACxD,CAAC,gCAAwB,EAAE,4BAAiB,CAAC;IAC7C,CAAC,iCAAyB,EAAE,6BAAkB,CAAC;IAC/C,CAAC,4CAAoC,EAAE,uCAA4B,CAAC;IACpE,CAAC,oCAA4B,EAAE,gCAAqB,CAAC;IACrD,CAAC,6CAAqC,EAAE,wCAA6B,CAAC;IACtE,CAAC,sCAA8B,EAAE,mCAAsB,CAAC;CACzD,CAAC;AAEW,QAAA,wBAAwB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAqBnE,iFAAiF;AACjF,iCAAiC;AACpB,QAAA,mBAAmB,GAAa;IAC3C,iCAAyB;IACzB,oCAA4B;IAC5B,sCAA8B;IAC9B,oCAA4B;IAC5B,gCAAwB;CACzB,CAAC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.isEventHandler = exports.keyedEventHandler = exports.keyedRouter = exports.router = void 0;
14
- const router = (opts) => {
15
- if (opts === undefined || opts === null) {
16
- throw new Error("router must be defined");
17
- }
18
- return opts;
19
- };
20
- exports.router = router;
21
- const keyedRouter = (opts) => {
22
- if (opts === undefined || opts === null) {
23
- throw new Error("router must be defined");
24
- }
25
- return opts;
26
- };
27
- exports.keyedRouter = keyedRouter;
28
- const keyedEventHandler = (handler) => {
29
- return { eventHandler: true, handler: handler };
30
- };
31
- exports.keyedEventHandler = keyedEventHandler;
32
- const isEventHandler = (handler) => {
33
- return typeof handler === "object" && handler["eventHandler"];
34
- };
35
- exports.isEventHandler = isEventHandler;
36
- //# sourceMappingURL=router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/types/router.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAgDI,MAAM,MAAM,GAAG,CAAI,IAA0B,EAAoB,EAAE;IACxE,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;IACD,OAAO,IAAwB,CAAC;AAClC,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB;AAwBK,MAAM,WAAW,GAAG,CAAI,IAAwB,EAAkB,EAAE;IACzE,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;IACD,OAAO,IAAsB,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,WAAW,eAKtB;AAYK,MAAM,iBAAiB,GAAG,CAAI,OAA6B,EAAK,EAAE;IACvE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAO,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,cAAc,GAAG,CAC5B,OAAY,EAGZ,EAAE;IACF,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;AAChE,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB"}
@@ -1,126 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Event = exports.Header = exports.Message = void 0;
14
- const protocol_1 = require("./protocol");
15
- class Message {
16
- messageType;
17
- message;
18
- completed;
19
- protocolVersion;
20
- requiresAck;
21
- constructor(messageType, message, completed, protocolVersion, requiresAck) {
22
- this.messageType = messageType;
23
- this.message = message;
24
- this.completed = completed;
25
- this.protocolVersion = protocolVersion;
26
- this.requiresAck = requiresAck;
27
- }
28
- }
29
- exports.Message = Message;
30
- class MessageType {
31
- static assertValid(messageTypeId) {
32
- if (protocol_1.KNOWN_MESSAGE_TYPES.has(messageTypeId)) {
33
- return;
34
- }
35
- if ((messageTypeId & CUSTOM_MESSAGE_MASK) !== 0n) {
36
- return;
37
- }
38
- throw new Error(`Unknown message type ${messageTypeId}`);
39
- }
40
- static hasCompletedFlag(messageType) {
41
- return (messageType === protocol_1.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE ||
42
- messageType === protocol_1.GET_STATE_ENTRY_MESSAGE_TYPE ||
43
- messageType === protocol_1.SLEEP_ENTRY_MESSAGE_TYPE ||
44
- messageType === protocol_1.AWAKEABLE_ENTRY_MESSAGE_TYPE);
45
- }
46
- static hasProtocolVersion(messageType) {
47
- return messageType == protocol_1.START_MESSAGE_TYPE;
48
- }
49
- static hasRequiresAckFlag(messageType) {
50
- return (messageType !== protocol_1.START_MESSAGE_TYPE &&
51
- messageType !== protocol_1.ERROR_MESSAGE_TYPE &&
52
- messageType !== protocol_1.SUSPENSION_MESSAGE_TYPE &&
53
- messageType !== protocol_1.ENTRY_ACK_MESSAGE_TYPE &&
54
- messageType !== protocol_1.COMPLETION_MESSAGE_TYPE);
55
- }
56
- }
57
- const CUSTOM_MESSAGE_MASK = BigInt(0xfc00);
58
- const COMPLETED_MASK = BigInt(0x0001_0000_0000);
59
- const VERSION_MASK = BigInt(0x03ff_0000_0000);
60
- const REQUIRES_ACK_MASK = BigInt(0x8000_0000_0000);
61
- // The header is exported but only for tests.
62
- class Header {
63
- messageType;
64
- frameLength;
65
- completedFlag;
66
- protocolVersion;
67
- requiresAckFlag;
68
- partialStateFlag;
69
- constructor(messageType, frameLength, completedFlag, protocolVersion, requiresAckFlag, partialStateFlag) {
70
- this.messageType = messageType;
71
- this.frameLength = frameLength;
72
- this.completedFlag = completedFlag;
73
- this.protocolVersion = protocolVersion;
74
- this.requiresAckFlag = requiresAckFlag;
75
- this.partialStateFlag = partialStateFlag;
76
- }
77
- static fromU64be(value) {
78
- const messageType = (value >> 48n) & 0xffffn;
79
- MessageType.assertValid(messageType);
80
- const completedFlag = MessageType.hasCompletedFlag(messageType) &&
81
- (value & COMPLETED_MASK) !== 0n
82
- ? true
83
- : undefined;
84
- const protocolVersion = MessageType.hasProtocolVersion(messageType)
85
- ? Number(((value & VERSION_MASK) >> 32n) & 0xffffn)
86
- : undefined;
87
- const requiresAckFlag = MessageType.hasRequiresAckFlag(messageType) &&
88
- (value & REQUIRES_ACK_MASK) !== 0n
89
- ? true
90
- : undefined;
91
- const frameLength = Number(value & 0xffffffffn);
92
- return new Header(messageType, frameLength, completedFlag, protocolVersion, requiresAckFlag);
93
- }
94
- toU64be() {
95
- let res = (this.messageType << 48n) | BigInt(this.frameLength);
96
- if (this.completedFlag) {
97
- res = res | COMPLETED_MASK;
98
- }
99
- if (this.protocolVersion !== undefined) {
100
- res = res | (BigInt(this.protocolVersion) << 32n);
101
- }
102
- if (this.requiresAckFlag) {
103
- res = res | REQUIRES_ACK_MASK;
104
- }
105
- return res;
106
- }
107
- }
108
- exports.Header = Header;
109
- class Event {
110
- key;
111
- payload;
112
- attributes;
113
- constructor(key, payload, attributes) {
114
- this.key = key;
115
- this.payload = payload;
116
- this.attributes = attributes;
117
- }
118
- json() {
119
- return JSON.parse(this.payload.toString("utf-8"));
120
- }
121
- body() {
122
- return this.payload;
123
- }
124
- }
125
- exports.Event = Event;
126
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,yCAmBoB;AAEpB,MAAa,OAAO;IAEP;IACA;IACA;IACA;IACA;IALX,YACW,WAAmB,EACnB,OAAwB,EACxB,SAAmB,EACnB,eAAwB,EACxB,WAAqB;QAJrB,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAiB;QACxB,cAAS,GAAT,SAAS,CAAU;QACnB,oBAAe,GAAf,eAAe,CAAS;QACxB,gBAAW,GAAX,WAAW,CAAU;IAC7B,CAAC;CACL;AARD,0BAQC;AAED,MAAM,WAAW;IACf,MAAM,CAAC,WAAW,CAAC,aAAqB;QACtC,IAAI,8BAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YAC1C,OAAO;SACR;QACD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,KAAK,EAAE,EAAE;YAChD,OAAO;SACR;QACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,aAAa,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,WAAmB;QACzC,OAAO,CACL,WAAW,KAAK,+CAAoC;YACpD,WAAW,KAAK,uCAA4B;YAC5C,WAAW,KAAK,mCAAwB;YACxC,WAAW,KAAK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