@restatedev/restate-sdk 0.6.0 → 0.7.1-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 (113) hide show
  1. package/README.md +12 -2
  2. package/dist/cloudflare_bundle.js +27387 -0
  3. package/dist/connection/buffered_connection.d.ts +14 -0
  4. package/dist/connection/buffered_connection.d.ts.map +1 -0
  5. package/dist/connection/embedded_connection.d.ts +2 -4
  6. package/dist/connection/embedded_connection.d.ts.map +1 -1
  7. package/dist/connection/http_connection.d.ts +1 -1
  8. package/dist/connection/http_connection.d.ts.map +1 -1
  9. package/dist/generated/proto/protocol.d.ts +52 -16
  10. package/dist/generated/proto/protocol.d.ts.map +1 -1
  11. package/dist/invocation.d.ts +12 -2
  12. package/dist/invocation.d.ts.map +1 -1
  13. package/dist/io/encoder.d.ts +2 -1
  14. package/dist/io/encoder.d.ts.map +1 -1
  15. package/dist/journal.d.ts +2 -1
  16. package/dist/journal.d.ts.map +1 -1
  17. package/dist/restate_context_impl.d.ts.map +1 -1
  18. package/dist/server/base_restate_server.d.ts +1 -1
  19. package/dist/server/base_restate_server.d.ts.map +1 -1
  20. package/dist/server/restate_server.d.ts +45 -39
  21. package/dist/server/restate_server.d.ts.map +1 -1
  22. package/dist/state_machine.d.ts +1 -1
  23. package/dist/state_machine.d.ts.map +1 -1
  24. package/dist/types/errors.d.ts +1 -1
  25. package/dist/types/errors.d.ts.map +1 -1
  26. package/dist/types/protocol.d.ts +5 -3
  27. package/dist/types/protocol.d.ts.map +1 -1
  28. package/dist/types/types.d.ts.map +1 -1
  29. package/dist/utils/utils.d.ts +1 -0
  30. package/dist/utils/utils.d.ts.map +1 -1
  31. package/package.json +7 -3
  32. package/dist/connection/connection.js +0 -13
  33. package/dist/connection/connection.js.map +0 -1
  34. package/dist/connection/embedded_connection.js +0 -78
  35. package/dist/connection/embedded_connection.js.map +0 -1
  36. package/dist/connection/http_connection.js +0 -203
  37. package/dist/connection/http_connection.js.map +0 -1
  38. package/dist/connection/lambda_connection.js +0 -58
  39. package/dist/connection/lambda_connection.js.map +0 -1
  40. package/dist/embedded/api.js +0 -35
  41. package/dist/embedded/api.js.map +0 -1
  42. package/dist/embedded/handler.js +0 -28
  43. package/dist/embedded/handler.js.map +0 -1
  44. package/dist/embedded/http2_remote.js +0 -91
  45. package/dist/embedded/http2_remote.js.map +0 -1
  46. package/dist/embedded/invocation.js +0 -94
  47. package/dist/embedded/invocation.js.map +0 -1
  48. package/dist/generated/dev/restate/events.js +0 -371
  49. package/dist/generated/dev/restate/events.js.map +0 -1
  50. package/dist/generated/dev/restate/ext.js +0 -215
  51. package/dist/generated/dev/restate/ext.js.map +0 -1
  52. package/dist/generated/google/protobuf/descriptor.js +0 -6676
  53. package/dist/generated/google/protobuf/descriptor.js.map +0 -1
  54. package/dist/generated/google/protobuf/empty.js +0 -107
  55. package/dist/generated/google/protobuf/empty.js.map +0 -1
  56. package/dist/generated/google/protobuf/struct.js +0 -754
  57. package/dist/generated/google/protobuf/struct.js.map +0 -1
  58. package/dist/generated/proto/discovery.js +0 -364
  59. package/dist/generated/proto/discovery.js.map +0 -1
  60. package/dist/generated/proto/dynrpc.js +0 -668
  61. package/dist/generated/proto/dynrpc.js.map +0 -1
  62. package/dist/generated/proto/javascript.js +0 -297
  63. package/dist/generated/proto/javascript.js.map +0 -1
  64. package/dist/generated/proto/protocol.js +0 -2179
  65. package/dist/generated/proto/protocol.js.map +0 -1
  66. package/dist/generated/proto/services.js +0 -1535
  67. package/dist/generated/proto/services.js.map +0 -1
  68. package/dist/generated/proto/test.js +0 -321
  69. package/dist/generated/proto/test.js.map +0 -1
  70. package/dist/invocation.js +0 -138
  71. package/dist/invocation.js.map +0 -1
  72. package/dist/io/decoder.js +0 -133
  73. package/dist/io/decoder.js.map +0 -1
  74. package/dist/io/encoder.js +0 -57
  75. package/dist/io/encoder.js.map +0 -1
  76. package/dist/journal.js +0 -368
  77. package/dist/journal.js.map +0 -1
  78. package/dist/local_state_store.js +0 -72
  79. package/dist/local_state_store.js.map +0 -1
  80. package/dist/public_api.js +0 -59
  81. package/dist/public_api.js.map +0 -1
  82. package/dist/restate_context.js +0 -46
  83. package/dist/restate_context.js.map +0 -1
  84. package/dist/restate_context_impl.js +0 -375
  85. package/dist/restate_context_impl.js.map +0 -1
  86. package/dist/server/base_restate_server.js +0 -361
  87. package/dist/server/base_restate_server.js.map +0 -1
  88. package/dist/server/restate_lambda_handler.js +0 -247
  89. package/dist/server/restate_lambda_handler.js.map +0 -1
  90. package/dist/server/restate_server.js +0 -230
  91. package/dist/server/restate_server.js.map +0 -1
  92. package/dist/state_machine.js +0 -385
  93. package/dist/state_machine.js.map +0 -1
  94. package/dist/types/errors.js +0 -261
  95. package/dist/types/errors.js.map +0 -1
  96. package/dist/types/grpc.js +0 -68
  97. package/dist/types/grpc.js.map +0 -1
  98. package/dist/types/protocol.js +0 -115
  99. package/dist/types/protocol.js.map +0 -1
  100. package/dist/types/router.js +0 -36
  101. package/dist/types/router.js.map +0 -1
  102. package/dist/types/types.js +0 -125
  103. package/dist/types/types.js.map +0 -1
  104. package/dist/utils/assumpsions.js +0 -101
  105. package/dist/utils/assumpsions.js.map +0 -1
  106. package/dist/utils/logger.js +0 -102
  107. package/dist/utils/logger.js.map +0 -1
  108. package/dist/utils/public_utils.js +0 -49
  109. package/dist/utils/public_utils.js.map +0 -1
  110. package/dist/utils/rand.js +0 -114
  111. package/dist/utils/rand.js.map +0 -1
  112. package/dist/utils/utils.js +0 -119
  113. package/dist/utils/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.1-worker",
4
4
  "description": "Typescript SDK for Restate",
5
5
  "engines": {
6
6
  "node": ">= 10"
@@ -24,7 +24,7 @@
24
24
  "@restatedev:registry": "https://registry.npmjs.org"
25
25
  },
26
26
  "type": "commonjs",
27
- "main": "dist/public_api.js",
27
+ "main": "dist/cloudflare_bundle.js",
28
28
  "types": "dist/public_api.d.ts",
29
29
  "author": "Restate Developers",
30
30
  "license": "MIT",
@@ -32,6 +32,7 @@
32
32
  "scripts": {
33
33
  "proto": "npx buf mod update && npx buf generate",
34
34
  "build": "tsc --noEmitOnError",
35
+ "build-worker": "tsc --emitDeclarationOnly --noEmitOnError && node build-worker.mjs",
35
36
  "test": "jest --silent --maxWorkers=1",
36
37
  "lint": "eslint --ignore-path .eslintignore --ext .ts .",
37
38
  "format": "prettier --ignore-path .eslintignore --write \"**/*.+(js|ts|json)\"",
@@ -62,7 +63,10 @@
62
63
  "ts-jest": "^29.0.5",
63
64
  "ts-node-dev": "^2.0.0",
64
65
  "typescript": "^4.9.5",
65
- "express": "*"
66
+ "express": "*",
67
+ "esbuild": "^0.20.1",
68
+ "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
69
+ "@esbuild-plugins/node-modules-polyfill": "^0.2.2"
66
70
  },
67
71
  "bugs": {
68
72
  "url": "https://github.com/restatedev/sdk-typescript/issues"
@@ -1,13 +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
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
@@ -1,78 +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.EmbeddedConnection = exports.InvocationAlreadyCompletedError = exports.FencedOffError = void 0;
14
- const encoder_1 = require("../io/encoder");
15
- class FencedOffError extends Error {
16
- constructor() {
17
- super("FencedOff");
18
- }
19
- }
20
- exports.FencedOffError = FencedOffError;
21
- class InvocationAlreadyCompletedError extends Error {
22
- constructor() {
23
- super("Completed");
24
- }
25
- }
26
- exports.InvocationAlreadyCompletedError = InvocationAlreadyCompletedError;
27
- class EmbeddedConnection {
28
- operationId;
29
- streamId;
30
- remote;
31
- queue = [];
32
- flushing = Promise.resolve();
33
- constructor(operationId, streamId, remote) {
34
- this.operationId = operationId;
35
- this.streamId = streamId;
36
- this.remote = remote;
37
- }
38
- send(msg) {
39
- const len = this.queue.push(msg);
40
- if (len === 1) {
41
- // we are the first in line, therefore we schedule a flush,
42
- // BUT we must wait for the previous flush to end.
43
- this.flushing = this.flushing.then(() => this.scheduleFlush());
44
- }
45
- // tag along to the previously scheduled flush.
46
- return this.flushing;
47
- }
48
- end() {
49
- this.flushing = this.flushing.then(() => this.flush());
50
- return this.flushing;
51
- }
52
- scheduleFlush() {
53
- // schedule a flush at the end of the current event loop iteration.
54
- return new Promise((resolve, reject) => setImmediate(() => {
55
- this.flush().then(resolve).catch(reject);
56
- }));
57
- }
58
- async flush() {
59
- if (this.queue.length === 0) {
60
- return Promise.resolve();
61
- }
62
- const buffer = (0, encoder_1.encodeMessages)(this.queue);
63
- this.queue = [];
64
- const res = await this.remote.send({
65
- operationId: this.operationId,
66
- streamId: this.streamId,
67
- messages: buffer,
68
- });
69
- if (res.invalidStream !== undefined) {
70
- throw new FencedOffError();
71
- }
72
- if (res.invocationCompleted !== undefined) {
73
- throw new InvocationAlreadyCompletedError();
74
- }
75
- }
76
- }
77
- exports.EmbeddedConnection = EmbeddedConnection;
78
- //# sourceMappingURL=embedded_connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embedded_connection.js","sourceRoot":"","sources":["../../src/connection/embedded_connection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,2CAA+C;AAI/C,MAAa,cAAe,SAAQ,KAAK;IACvC;QACE,KAAK,CAAC,WAAW,CAAC,CAAC;IACrB,CAAC;CACF;AAJD,wCAIC;AAED,MAAa,+BAAgC,SAAQ,KAAK;IACxD;QACE,KAAK,CAAC,WAAW,CAAC,CAAC;IACrB,CAAC;CACF;AAJD,0EAIC;AAED,MAAa,kBAAkB;IAKV;IACA;IACA;IANX,KAAK,GAAc,EAAE,CAAC;IACtB,QAAQ,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEpD,YACmB,WAAmB,EACnB,QAAgB,EAChB,MAAqB;QAFrB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAe;IACrC,CAAC;IAEJ,IAAI,CAAC,GAAY;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,GAAG,KAAK,CAAC,EAAE;YACb,2DAA2D;YAC3D,kDAAkD;YAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;SAChE;QACD,+CAA+C;QAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,GAAG;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEO,aAAa;QACnB,mEAAmE;QACnE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CACrC,YAAY,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QACD,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,IAAI,CAAC,KAAK,CAAW,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAEhB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,cAAc,EAAE,CAAC;SAC5B;QACD,IAAI,GAAG,CAAC,mBAAmB,KAAK,SAAS,EAAE;YACzC,MAAM,IAAI,+BAA+B,EAAE,CAAC;SAC7C;IACH,CAAC;CACF;AAvDD,gDAuDC"}
@@ -1,203 +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.RestateHttp2Connection = void 0;
14
- const encoder_1 = require("../io/encoder");
15
- const decoder_1 = require("../io/decoder");
16
- const logger_1 = require("../utils/logger");
17
- const promises_1 = require("stream/promises");
18
- // utility promise, for cases where we want to save allocation of an extra promise
19
- const RESOLVED = Promise.resolve();
20
- /**
21
- * A duplex stream with Restate Messages over HTTP2.
22
- *
23
- * This stream handles the following concerns:
24
- *
25
- * (1) encoding and decoding of messages from and from raw bytes
26
- *
27
- * (2) buffering the outgoing messages, because the call sites that produce (potentially) large
28
- * messages might not await their transfer. Aside from the fact that we achieve better pipelining
29
- * that way, we also simply cannot guarantee that users of the Restate SDK actually await the
30
- * relevant async API methods.
31
- *
32
- * This stream essentially buffers messages and, upon flush, sends them asynchronously, as the
33
- * stream has availability. Flush requests queue up, if new data gets flushed while the previous
34
- * data is still being sent.
35
- *
36
- * (3) Input messages can be pipelined to a sequence of consumers. For example, first to a journal,
37
- * and afterwards to the state machine.
38
- *
39
- * (4) Handling the relevant stream events for errors and consolidating them to one error handler, plus
40
- * notifications for cleanly closed input (to trigger suspension).
41
- */
42
- class RestateHttp2Connection {
43
- rawStream;
44
- /**
45
- * create a RestateDuplex stream from an http2 (duplex) stream.
46
- */
47
- static from(http2stream) {
48
- return new RestateHttp2Connection(http2stream);
49
- }
50
- // --------------------------------------------------------------------------
51
- // input as decoded messages
52
- sdkInput;
53
- // output as encoded bytes. we convert manually, not as transforms,
54
- // to skip a layer of stream indirection
55
- sdkOutput;
56
- // consumer handling
57
- currentConsumer = null;
58
- inputBuffer = [];
59
- consumerError;
60
- consumerInputClosed = false;
61
- constructor(rawStream) {
62
- this.rawStream = rawStream;
63
- this.sdkInput = rawStream.pipe((0, decoder_1.streamDecoder)());
64
- this.sdkOutput = rawStream;
65
- // remember and forward messages
66
- this.sdkInput.on("data", (m) => {
67
- // deliver message, if we have a consumer. otherwise buffer the message.
68
- if (this.currentConsumer) {
69
- if (this.currentConsumer.handleMessage(m)) {
70
- this.removeCurrentConsumer();
71
- }
72
- }
73
- else {
74
- this.inputBuffer.push(m);
75
- }
76
- });
77
- // remember and forward close events
78
- this.sdkInput.on("end", () => {
79
- this.consumerInputClosed = true;
80
- if (this.currentConsumer) {
81
- this.currentConsumer.handleInputClosed();
82
- }
83
- });
84
- // --------- error handling --------
85
- // - a.k.a. node event wrangling...
86
- // the error handler for all sorts of errors coming from streams
87
- const errorHandler = (e) => {
88
- // make sure we don't overwrite the initial error
89
- if (this.consumerError !== undefined) {
90
- return;
91
- }
92
- this.consumerError = e;
93
- if (this.currentConsumer) {
94
- this.currentConsumer.handleStreamError(e);
95
- }
96
- };
97
- // those two event types should cover all types of connection losses
98
- rawStream.on("aborted", () => {
99
- logger_1.rlog.error("Connection to Restate was lost");
100
- errorHandler(new Error("Connection to Restate was lost"));
101
- });
102
- // this is both the raw http2 stream and the output SDK->Restate
103
- rawStream.on("error", (e) => {
104
- logger_1.rlog.error("Error in http2 stream to Restate: " + (e.stack ?? e.message));
105
- errorHandler(e);
106
- });
107
- // these events notify of errors in the decoding pipeline
108
- this.sdkInput.on("error", (e) => {
109
- logger_1.rlog.error("Error in input stream (Restate to Service): " + (e.stack ?? e.message));
110
- errorHandler(e);
111
- });
112
- // see if streams get torn down before they end cleanly
113
- this.sdkInput.on("close", () => {
114
- if (!this.consumerInputClosed) {
115
- errorHandler(new Error("stream was destroyed before end"));
116
- }
117
- });
118
- }
119
- // --------------------------------------------------------------------------
120
- // input stream handling
121
- // --------------------------------------------------------------------------
122
- /**
123
- * Pipes the messages from this connection to the given consumer. The consumer
124
- * will also receive error and stream closing notifications.
125
- *
126
- * Once the 'handleMessage()' method returns 'true', the consumer is immediately removed.
127
- * That way, consumers can consume a bounded amount of messages (like just the initial journal).
128
- *
129
- * There can only be one consumer at a time.
130
- */
131
- pipeToConsumer(consumer) {
132
- if (this.currentConsumer !== null) {
133
- throw new Error("Already piping to a consumer");
134
- }
135
- this.currentConsumer = consumer;
136
- // propagate pre-existing information
137
- if (this.consumerError) {
138
- consumer.handleStreamError(this.consumerError);
139
- }
140
- if (this.consumerInputClosed) {
141
- consumer.handleInputClosed();
142
- }
143
- // pipe the buffered input messages, if we buffered some before the consumer was registered
144
- const input = this.inputBuffer;
145
- if (input.length > 0) {
146
- let i = 0;
147
- while (i < input.length) {
148
- const done = consumer.handleMessage(input[i]);
149
- i++;
150
- if (done) {
151
- this.removeCurrentConsumer();
152
- break;
153
- }
154
- }
155
- this.inputBuffer = i === input.length ? [] : this.inputBuffer.slice(i);
156
- }
157
- }
158
- /**
159
- * Removes the current consumer, if there is one.
160
- */
161
- removeCurrentConsumer() {
162
- this.currentConsumer = null;
163
- }
164
- // --------------------------------------------------------------------------
165
- // output stream handling
166
- // --------------------------------------------------------------------------
167
- /**
168
- * Adds a message to the output stream.
169
- *
170
- * This always puts the message into the node stream, but will return a promise that is resolved once
171
- * further messages can be written.
172
- *
173
- * The reasoning is that some, but not all Restate operations return promises and are typically
174
- * awaited. For example, rpc, sleep, side-effect have promises and are awaited, while one-way-sends and
175
- * state updates don't return promises.
176
- *
177
- * As a pragmatic solution, we always accept messages, but return a promise for when the output has
178
- * capacity again, so that at least the operations that await results will respect backpressure.
179
- */
180
- send(msg) {
181
- const encodedMessage = (0, encoder_1.encodeMessage)(msg);
182
- const hasMoreCapacity = this.sdkOutput.write(encodedMessage);
183
- if (hasMoreCapacity) {
184
- return RESOLVED;
185
- }
186
- return new Promise((resolve) => {
187
- this.sdkOutput.once("drain", resolve);
188
- });
189
- }
190
- /**
191
- * Ends the stream, awaiting pending writes.
192
- */
193
- async end() {
194
- this.sdkOutput.end();
195
- const options = {
196
- error: true,
197
- cleanup: true,
198
- };
199
- await (0, promises_1.finished)(this.rawStream, options);
200
- }
201
- }
202
- exports.RestateHttp2Connection = RestateHttp2Connection;
203
- //# sourceMappingURL=http_connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http_connection.js","sourceRoot":"","sources":["../../src/connection/http_connection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,2CAA8C;AAC9C,2CAA8C;AAG9C,4CAAuC;AACvC,8CAA2C;AAE3C,kFAAkF;AAClF,MAAM,QAAQ,GAAkB,OAAO,CAAC,OAAO,EAAE,CAA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M,cAAc,GAAe,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QAEtD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC7D,IAAI,eAAe,EAAE;YACnB,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG;QACd,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAErB,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;SACd,CAAC;QAEF,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AAxLD,wDAwLC"}
@@ -1,58 +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.LambdaConnection = void 0;
14
- const encoder_1 = require("../io/encoder");
15
- const protocol_1 = require("../types/protocol");
16
- const logger_1 = require("../utils/logger");
17
- const RESOLVED = Promise.resolve();
18
- class LambdaConnection {
19
- suspendedOrCompleted;
20
- // Empty buffer to store journal output messages
21
- outputBuffer = Buffer.alloc(0);
22
- // Callback to resolve the invocation promise of the Lambda handler when the response is ready
23
- completionPromise;
24
- resolveOnCompleted;
25
- constructor(suspendedOrCompleted = false) {
26
- this.suspendedOrCompleted = suspendedOrCompleted;
27
- // Promise that signals when the invocation is over, to then flush the messages
28
- this.completionPromise = new Promise((resolve) => {
29
- this.resolveOnCompleted = resolve;
30
- });
31
- }
32
- // Send a message back to the runtime
33
- send(msg) {
34
- // Add the header and the body to buffer and add to the output buffer
35
- const msgBuffer = (0, encoder_1.encodeMessage)(msg);
36
- this.outputBuffer = Buffer.concat([this.outputBuffer, msgBuffer]);
37
- // An output message, suspension message or error message is the end of a Lambda invocation
38
- if (msg.messageType === protocol_1.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE ||
39
- msg.messageType === protocol_1.SUSPENSION_MESSAGE_TYPE ||
40
- msg.messageType === protocol_1.ERROR_MESSAGE_TYPE) {
41
- this.suspendedOrCompleted = true;
42
- }
43
- return RESOLVED;
44
- }
45
- getResult() {
46
- return this.completionPromise;
47
- }
48
- end() {
49
- if (this.suspendedOrCompleted) {
50
- logger_1.rlog.debug("Flushing output buffer...");
51
- this.resolveOnCompleted(this.outputBuffer);
52
- }
53
- this.outputBuffer = Buffer.alloc(0);
54
- return RESOLVED;
55
- }
56
- }
57
- exports.LambdaConnection = LambdaConnection;
58
- //# sourceMappingURL=lambda_connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda_connection.js","sourceRoot":"","sources":["../../src/connection/lambda_connection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,2CAA8C;AAC9C,gDAI2B;AAE3B,4CAAuC;AAEvC,MAAM,QAAQ,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;AAElD,MAAa,gBAAgB;IAQP;IAPpB,gDAAgD;IACxC,YAAY,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/C,8FAA8F;IAC7E,iBAAiB,CAAkB;IAC5C,kBAAkB,CAAiD;IAE3E,YAAoB,uBAAuB,KAAK;QAA5B,yBAAoB,GAApB,oBAAoB,CAAQ;QAC9C,+EAA+E;QAC/E,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;YACvD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,qCAAqC;IACrC,IAAI,CAAC,GAAY;QACf,qEAAqE;QACrE,MAAM,SAAS,GAAG,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;QAElE,2FAA2F;QAC3F,IACE,GAAG,CAAC,WAAW,KAAK,2CAAgC;YACpD,GAAG,CAAC,WAAW,KAAK,kCAAuB;YAC3C,GAAG,CAAC,WAAW,KAAK,6BAAkB,EACtC;YACA,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SAClC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,GAAG;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC7B,aAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC5C;QACD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA7CD,4CA6CC"}
@@ -1,35 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.RestateConnection = exports.connection = void 0;
17
- const invocation_1 = require("./invocation");
18
- const handler_1 = require("./handler");
19
- const crypto_1 = __importDefault(require("crypto"));
20
- const http2_remote_1 = require("./http2_remote");
21
- const connection = (address, opt) => new RestateConnection((0, http2_remote_1.bufConnectRemoteContext)(address, opt));
22
- exports.connection = connection;
23
- class RestateConnection {
24
- remote;
25
- constructor(remote) {
26
- this.remote = remote;
27
- }
28
- invoke(id, input, handler, opt) {
29
- const method = (0, handler_1.wrapHandler)(handler);
30
- const streamId = crypto_1.default.randomUUID();
31
- return (0, invocation_1.doInvoke)(this.remote, id, streamId, input, method, opt);
32
- }
33
- }
34
- exports.RestateConnection = RestateConnection;
35
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/embedded/api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAGH,6CAAwC;AACxC,uCAAwC;AACxC,oDAA4B;AAE5B,iDAAyD;AAqBlD,MAAM,UAAU,GAAG,CACxB,OAAe,EACf,GAA8B,EACX,EAAE,CACrB,IAAI,iBAAiB,CAAC,IAAA,sCAAuB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AAJlD,QAAA,UAAU,cAIwC;AAE/D,MAAa,iBAAiB;IACC;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE/C,MAAM,CACX,EAAU,EACV,KAAQ,EACR,OAAkD,EAClD,GAA8B;QAE9B,MAAM,MAAM,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,gBAAM,CAAC,UAAU,EAAE,CAAC;QACrC,OAAO,IAAA,qBAAQ,EAAO,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACvE,CAAC;CACF;AAbD,8CAaC"}
@@ -1,28 +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.wrapHandler = void 0;
14
- const restate_context_1 = require("../restate_context");
15
- const restate_context_impl_1 = require("../restate_context_impl");
16
- const grpc_1 = require("../types/grpc");
17
- function wrapHandler(handler) {
18
- const localMethod = (instance, input) => {
19
- const ctx = new restate_context_impl_1.RpcContextImpl((0, restate_context_1.useContext)(instance));
20
- return handler(ctx, input);
21
- };
22
- const encoder = (output) => Buffer.from(JSON.stringify(output));
23
- const decoder = (buf) => JSON.parse(buf.toString());
24
- const method = new grpc_1.GrpcServiceMethod("", "", localMethod, decoder, encoder);
25
- return new grpc_1.HostedGrpcServiceMethod({}, "", "", method);
26
- }
27
- exports.wrapHandler = wrapHandler;
28
- //# sourceMappingURL=handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/embedded/handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,wDAA4D;AAC5D,kEAAyD;AACzD,wCAA2E;AAE3E,SAAgB,WAAW,CACzB,OAAkD;IAElD,MAAM,WAAW,GAAG,CAAC,QAAiB,EAAE,KAAQ,EAAc,EAAE;QAC9D,MAAM,GAAG,GAAG,IAAI,qCAAc,CAAC,IAAA,4BAAU,EAAC,QAAQ,CAAC,CAAC,CAAC;QACrD,OAAO,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,MAAS,EAAc,EAAE,CACxC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,CAAC,GAAe,EAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEnE,MAAM,MAAM,GAAG,IAAI,wBAAiB,CAClC,EAAE,EACF,EAAE,EACF,WAAW,EACX,OAAO,EACP,OAAO,CACR,CAAC;IAEF,OAAO,IAAI,8BAAuB,CAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AArBD,kCAqBC"}
@@ -1,91 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.bufConnectRemoteContext = exports.RequestError = void 0;
17
- const node_http2_1 = __importDefault(require("node:http2"));
18
- const events_1 = require("events");
19
- const services_1 = require("../generated/proto/services");
20
- class RequestError extends Error {
21
- url;
22
- status;
23
- statusText;
24
- constructor(url, status, statusText) {
25
- super(`${status} ${statusText ?? ""}`);
26
- this.url = url;
27
- this.status = status;
28
- this.statusText = statusText;
29
- }
30
- precondtionFailed() {
31
- return this.status === node_http2_1.default.constants.HTTP_STATUS_PRECONDITION_FAILED;
32
- }
33
- }
34
- exports.RequestError = RequestError;
35
- const bufConnectRemoteContext = (url, opt) => {
36
- const httpClient = new ProtobufHttp2Client(url, opt);
37
- return new services_1.RemoteContextClientImpl({
38
- request: (service, method, data) => httpClient.post(`/${service}/${method}`, data),
39
- });
40
- };
41
- exports.bufConnectRemoteContext = bufConnectRemoteContext;
42
- class ProtobufHttp2Client {
43
- ingress;
44
- session;
45
- additionalHeaders;
46
- constructor(ingress, opt) {
47
- this.ingress = ingress;
48
- this.additionalHeaders = opt?.headers == undefined ? {} : opt?.headers;
49
- }
50
- async client() {
51
- if (this.session !== undefined) {
52
- return this.session;
53
- }
54
- const client = node_http2_1.default.connect(this.ingress);
55
- client.unref();
56
- client.once("goaway", () => {
57
- this.session = undefined;
58
- });
59
- client.once("close", () => {
60
- this.session = undefined;
61
- });
62
- this.session = client;
63
- return client;
64
- }
65
- async post(path, body) {
66
- const client = await this.client();
67
- const req = client.request({
68
- ...{
69
- [node_http2_1.default.constants.HTTP2_HEADER_SCHEME]: "http",
70
- [node_http2_1.default.constants.HTTP2_HEADER_METHOD]: node_http2_1.default.constants.HTTP2_METHOD_POST,
71
- [node_http2_1.default.constants.HTTP2_HEADER_PATH]: path,
72
- [node_http2_1.default.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/proto",
73
- [node_http2_1.default.constants.HTTP2_HEADER_ACCEPT]: "application/proto",
74
- [node_http2_1.default.constants.HTTP2_HEADER_CONTENT_LENGTH]: body.length,
75
- },
76
- ...this.additionalHeaders,
77
- });
78
- req.end(body);
79
- const [headers] = await (0, events_1.once)(req, "response");
80
- const status = headers[node_http2_1.default.constants.HTTP2_HEADER_STATUS] ?? 0;
81
- if (status !== 200) {
82
- throw new RequestError(path, status);
83
- }
84
- const chunks = [];
85
- for await (const chunk of req) {
86
- chunks.push(chunk);
87
- }
88
- return Buffer.concat(chunks);
89
- }
90
- }
91
- //# sourceMappingURL=http2_remote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http2_remote.js","sourceRoot":"","sources":["../../src/embedded/http2_remote.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,4DAA+B;AAC/B,mCAA8B;AAC9B,0DAGqC;AAIrC,MAAa,YAAa,SAAQ,KAAK;IAEnB;IACA;IACA;IAHlB,YACkB,GAAW,EACX,MAAc,EAC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