@restatedev/restate-sdk 0.0.0-SNAPSHOT-20231025205407

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/dist/connection/connection.d.ts +19 -0
  4. package/dist/connection/connection.d.ts.map +1 -0
  5. package/dist/connection/connection.js +13 -0
  6. package/dist/connection/connection.js.map +1 -0
  7. package/dist/connection/embedded_connection.d.ts +22 -0
  8. package/dist/connection/embedded_connection.d.ts.map +1 -0
  9. package/dist/connection/embedded_connection.js +78 -0
  10. package/dist/connection/embedded_connection.js.map +1 -0
  11. package/dist/connection/http_connection.d.ts +73 -0
  12. package/dist/connection/http_connection.d.ts.map +1 -0
  13. package/dist/connection/http_connection.js +203 -0
  14. package/dist/connection/http_connection.js.map +1 -0
  15. package/dist/connection/lambda_connection.d.ts +14 -0
  16. package/dist/connection/lambda_connection.d.ts.map +1 -0
  17. package/dist/connection/lambda_connection.js +56 -0
  18. package/dist/connection/lambda_connection.js.map +1 -0
  19. package/dist/embedded/api.d.ts +18 -0
  20. package/dist/embedded/api.d.ts.map +1 -0
  21. package/dist/embedded/api.js +37 -0
  22. package/dist/embedded/api.js.map +1 -0
  23. package/dist/embedded/handler.d.ts +4 -0
  24. package/dist/embedded/handler.d.ts.map +1 -0
  25. package/dist/embedded/handler.js +28 -0
  26. package/dist/embedded/handler.js.map +1 -0
  27. package/dist/embedded/http2_remote.d.ts +10 -0
  28. package/dist/embedded/http2_remote.d.ts.map +1 -0
  29. package/dist/embedded/http2_remote.js +85 -0
  30. package/dist/embedded/http2_remote.js.map +1 -0
  31. package/dist/embedded/invocation.d.ts +4 -0
  32. package/dist/embedded/invocation.d.ts.map +1 -0
  33. package/dist/embedded/invocation.js +90 -0
  34. package/dist/embedded/invocation.js.map +1 -0
  35. package/dist/generated/dev/restate/events.d.ts +96 -0
  36. package/dist/generated/dev/restate/events.d.ts.map +1 -0
  37. package/dist/generated/dev/restate/events.js +371 -0
  38. package/dist/generated/dev/restate/events.js.map +1 -0
  39. package/dist/generated/dev/restate/ext.d.ts +88 -0
  40. package/dist/generated/dev/restate/ext.d.ts.map +1 -0
  41. package/dist/generated/dev/restate/ext.js +212 -0
  42. package/dist/generated/dev/restate/ext.js.map +1 -0
  43. package/dist/generated/google/protobuf/descriptor.d.ts +1204 -0
  44. package/dist/generated/google/protobuf/descriptor.d.ts.map +1 -0
  45. package/dist/generated/google/protobuf/descriptor.js +6676 -0
  46. package/dist/generated/google/protobuf/descriptor.js.map +1 -0
  47. package/dist/generated/google/protobuf/empty.d.ts +86 -0
  48. package/dist/generated/google/protobuf/empty.d.ts.map +1 -0
  49. package/dist/generated/google/protobuf/empty.js +107 -0
  50. package/dist/generated/google/protobuf/empty.js.map +1 -0
  51. package/dist/generated/google/protobuf/struct.d.ts +175 -0
  52. package/dist/generated/google/protobuf/struct.d.ts.map +1 -0
  53. package/dist/generated/google/protobuf/struct.js +754 -0
  54. package/dist/generated/google/protobuf/struct.js.map +1 -0
  55. package/dist/generated/proto/discovery.d.ts +105 -0
  56. package/dist/generated/proto/discovery.d.ts.map +1 -0
  57. package/dist/generated/proto/discovery.js +364 -0
  58. package/dist/generated/proto/discovery.js.map +1 -0
  59. package/dist/generated/proto/dynrpc.d.ts +150 -0
  60. package/dist/generated/proto/dynrpc.d.ts.map +1 -0
  61. package/dist/generated/proto/dynrpc.js +668 -0
  62. package/dist/generated/proto/dynrpc.js.map +1 -0
  63. package/dist/generated/proto/javascript.d.ts +97 -0
  64. package/dist/generated/proto/javascript.d.ts.map +1 -0
  65. package/dist/generated/proto/javascript.js +297 -0
  66. package/dist/generated/proto/javascript.js.map +1 -0
  67. package/dist/generated/proto/protocol.d.ts +371 -0
  68. package/dist/generated/proto/protocol.d.ts.map +1 -0
  69. package/dist/generated/proto/protocol.js +2179 -0
  70. package/dist/generated/proto/protocol.js.map +1 -0
  71. package/dist/generated/proto/services.d.ts +307 -0
  72. package/dist/generated/proto/services.d.ts.map +1 -0
  73. package/dist/generated/proto/services.js +1535 -0
  74. package/dist/generated/proto/services.js.map +1 -0
  75. package/dist/generated/proto/test.d.ts +116 -0
  76. package/dist/generated/proto/test.d.ts.map +1 -0
  77. package/dist/generated/proto/test.js +321 -0
  78. package/dist/generated/proto/test.js.map +1 -0
  79. package/dist/invocation.d.ts +39 -0
  80. package/dist/invocation.d.ts.map +1 -0
  81. package/dist/invocation.js +138 -0
  82. package/dist/invocation.js.map +1 -0
  83. package/dist/io/decoder.d.ts +8 -0
  84. package/dist/io/decoder.d.ts.map +1 -0
  85. package/dist/io/decoder.js +133 -0
  86. package/dist/io/decoder.js.map +1 -0
  87. package/dist/io/encoder.d.ts +7 -0
  88. package/dist/io/encoder.d.ts.map +1 -0
  89. package/dist/io/encoder.js +57 -0
  90. package/dist/io/encoder.js.map +1 -0
  91. package/dist/journal.d.ts +42 -0
  92. package/dist/journal.d.ts.map +1 -0
  93. package/dist/journal.js +368 -0
  94. package/dist/journal.js.map +1 -0
  95. package/dist/local_state_store.d.ts +13 -0
  96. package/dist/local_state_store.d.ts.map +1 -0
  97. package/dist/local_state_store.js +72 -0
  98. package/dist/local_state_store.js.map +1 -0
  99. package/dist/public_api.d.ts +10 -0
  100. package/dist/public_api.d.ts.map +1 -0
  101. package/dist/public_api.js +59 -0
  102. package/dist/public_api.js.map +1 -0
  103. package/dist/restate_context.d.ts +405 -0
  104. package/dist/restate_context.d.ts.map +1 -0
  105. package/dist/restate_context.js +46 -0
  106. package/dist/restate_context.js.map +1 -0
  107. package/dist/restate_context_impl.d.ts +54 -0
  108. package/dist/restate_context_impl.d.ts.map +1 -0
  109. package/dist/restate_context_impl.js +364 -0
  110. package/dist/restate_context_impl.js.map +1 -0
  111. package/dist/server/base_restate_server.d.ts +30 -0
  112. package/dist/server/base_restate_server.d.ts.map +1 -0
  113. package/dist/server/base_restate_server.js +360 -0
  114. package/dist/server/base_restate_server.js.map +1 -0
  115. package/dist/server/restate_lambda_handler.d.ts +104 -0
  116. package/dist/server/restate_lambda_handler.d.ts.map +1 -0
  117. package/dist/server/restate_lambda_handler.js +245 -0
  118. package/dist/server/restate_lambda_handler.js.map +1 -0
  119. package/dist/server/restate_server.d.ts +91 -0
  120. package/dist/server/restate_server.d.ts.map +1 -0
  121. package/dist/server/restate_server.js +230 -0
  122. package/dist/server/restate_server.js.map +1 -0
  123. package/dist/state_machine.d.ts +75 -0
  124. package/dist/state_machine.d.ts.map +1 -0
  125. package/dist/state_machine.js +380 -0
  126. package/dist/state_machine.js.map +1 -0
  127. package/dist/types/errors.d.ts +40 -0
  128. package/dist/types/errors.d.ts.map +1 -0
  129. package/dist/types/errors.js +121 -0
  130. package/dist/types/errors.js.map +1 -0
  131. package/dist/types/grpc.d.ts +88 -0
  132. package/dist/types/grpc.d.ts.map +1 -0
  133. package/dist/types/grpc.js +68 -0
  134. package/dist/types/grpc.js.map +1 -0
  135. package/dist/types/protocol.d.ts +24 -0
  136. package/dist/types/protocol.d.ts.map +1 -0
  137. package/dist/types/protocol.js +115 -0
  138. package/dist/types/protocol.js.map +1 -0
  139. package/dist/types/router.d.ts +33 -0
  140. package/dist/types/router.d.ts.map +1 -0
  141. package/dist/types/router.js +36 -0
  142. package/dist/types/router.js.map +1 -0
  143. package/dist/types/types.d.ts +30 -0
  144. package/dist/types/types.d.ts.map +1 -0
  145. package/dist/types/types.js +125 -0
  146. package/dist/types/types.js.map +1 -0
  147. package/dist/utils/assumpsions.d.ts +8 -0
  148. package/dist/utils/assumpsions.d.ts.map +1 -0
  149. package/dist/utils/assumpsions.js +101 -0
  150. package/dist/utils/assumpsions.js.map +1 -0
  151. package/dist/utils/logger.d.ts +60 -0
  152. package/dist/utils/logger.d.ts.map +1 -0
  153. package/dist/utils/logger.js +102 -0
  154. package/dist/utils/logger.js.map +1 -0
  155. package/dist/utils/public_utils.d.ts +58 -0
  156. package/dist/utils/public_utils.d.ts.map +1 -0
  157. package/dist/utils/public_utils.js +49 -0
  158. package/dist/utils/public_utils.js.map +1 -0
  159. package/dist/utils/utils.d.ts +14 -0
  160. package/dist/utils/utils.d.ts.map +1 -0
  161. package/dist/utils/utils.js +119 -0
  162. package/dist/utils/utils.js.map +1 -0
  163. package/package.json +75 -0
@@ -0,0 +1,360 @@
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.parseService = exports.BaseRestateServer = void 0;
14
+ /* eslint-disable @typescript-eslint/ban-types */
15
+ const logger_1 = require("../utils/logger");
16
+ const grpc_1 = require("../types/grpc");
17
+ const types_1 = require("../types/types");
18
+ const descriptor_1 = require("../generated/google/protobuf/descriptor");
19
+ const empty_1 = require("../generated/google/protobuf/empty");
20
+ const ext_1 = require("../generated/dev/restate/ext");
21
+ const dynrpc_1 = require("../generated/proto/dynrpc");
22
+ const restate_context_1 = require("../restate_context");
23
+ const restate_context_impl_1 = require("../restate_context_impl");
24
+ const assumpsions_1 = require("../utils/assumpsions");
25
+ const public_api_1 = require("../public_api");
26
+ const router_1 = require("../types/router");
27
+ class BaseRestateServer {
28
+ methods = {};
29
+ discovery;
30
+ constructor(protocolMode) {
31
+ this.discovery = {
32
+ files: { file: [] },
33
+ services: [],
34
+ minProtocolVersion: 0,
35
+ maxProtocolVersion: 0,
36
+ protocolMode: protocolMode,
37
+ };
38
+ }
39
+ addDescriptor(descriptor) {
40
+ const desc = descriptor_1.FileDescriptorProto.fromPartial(descriptor.fileDescriptor);
41
+ // extract out service options and put into the fileDescriptor
42
+ for (const name in descriptor.options?.services) {
43
+ if (descriptor.options?.services[name]?.options?.service_type !== undefined) {
44
+ desc.service
45
+ .find((desc) => desc.name === name)
46
+ ?.options?.uninterpretedOption.push(descriptor_1.UninterpretedOption.fromPartial({
47
+ name: [
48
+ { namePart: "dev.restate.ext.service_type", isExtension: true },
49
+ ],
50
+ identifierValue: (0, ext_1.serviceTypeToJSON)(descriptor.options?.services[name]?.options?.service_type),
51
+ }));
52
+ }
53
+ }
54
+ // extract out field options and put into the fileDescriptor
55
+ for (const messageName in descriptor.options?.messages) {
56
+ for (const fieldName in descriptor.options?.messages[messageName]
57
+ ?.fields) {
58
+ const fields = descriptor.options?.messages[messageName]?.fields || {};
59
+ if (fields[fieldName]["field"] !== undefined) {
60
+ desc.messageType
61
+ .find((desc) => desc.name === messageName)
62
+ ?.field?.find((desc) => desc.name === fieldName)
63
+ ?.options?.uninterpretedOption.push(descriptor_1.UninterpretedOption.fromPartial({
64
+ name: [
65
+ { namePart: "dev.restate.ext.field", isExtension: true },
66
+ ],
67
+ identifierValue: (0, ext_1.fieldTypeToJSON)(fields[fieldName]["field"]),
68
+ }));
69
+ }
70
+ }
71
+ }
72
+ if (this.discovery.files?.file.filter((haveDesc) => desc.name === haveDesc.name).length === 0) {
73
+ this.discovery.files?.file.push(desc);
74
+ }
75
+ descriptor.dependencies?.forEach((dep) => {
76
+ this.addDescriptor(dep);
77
+ });
78
+ }
79
+ bindService({ descriptor, service, instance }) {
80
+ const spec = parseService(descriptor, service, instance);
81
+ this.addDescriptor(descriptor);
82
+ const qname = spec.packge === "" ? spec.name : `${spec.packge}.${spec.name}`;
83
+ this.discovery.services.push(qname);
84
+ for (const method of spec.methods) {
85
+ const url = `/invoke/${qname}/${method.name}`;
86
+ this.methods[url] = new grpc_1.HostedGrpcServiceMethod(instance, spec.packge, service, method);
87
+ // note that this log will not print all the keys.
88
+ logger_1.rlog.info(`Registering: ${url} -> ${JSON.stringify(method, null, "\t")}`);
89
+ }
90
+ }
91
+ rpcHandler(keyed, route, handler) {
92
+ const descriptor = createRpcMethodDescriptor(route);
93
+ const localMethod = (instance, input) => {
94
+ const ctx = (0, restate_context_1.useContext)(instance);
95
+ if (keyed) {
96
+ return dispatchKeyedRpcHandler(ctx, input, handler);
97
+ }
98
+ else {
99
+ return dispatchUnkeyedRpcHandler(ctx, input, handler);
100
+ }
101
+ };
102
+ const decoder = dynrpc_1.RpcRequest.decode;
103
+ const encoder = (message) => dynrpc_1.RpcResponse.encode(message).finish();
104
+ const method = new grpc_1.GrpcServiceMethod(route, route, localMethod, decoder, encoder);
105
+ return {
106
+ descriptor: descriptor,
107
+ method: method,
108
+ };
109
+ }
110
+ stringKeyedEventHandler(keyed, route, handler) {
111
+ if (!keyed) {
112
+ // TODO: support unkeyed rpc event handler
113
+ throw new public_api_1.TerminalError("Unkeyed Event handlers are not yet supported.");
114
+ }
115
+ const descriptor = createStringKeyedMethodDescriptor(route);
116
+ const localMethod = (instance, input) => {
117
+ const ctx = (0, restate_context_1.useContext)(instance);
118
+ return dispatchKeyedEventHandler(ctx, input, handler);
119
+ };
120
+ const decoder = dynrpc_1.KeyedEvent.decode;
121
+ const encoder = (message) => empty_1.Empty.encode(message).finish();
122
+ const method = new grpc_1.GrpcServiceMethod(route, route, localMethod, decoder, encoder);
123
+ return {
124
+ descriptor,
125
+ method: method,
126
+ };
127
+ }
128
+ bindRpcService(name, router, keyed) {
129
+ const lastDot = name.indexOf(".");
130
+ const serviceName = lastDot === -1 ? name : name.substring(lastDot + 1);
131
+ const servicePackage = name.substring(0, name.length - serviceName.length - 1);
132
+ const desc = dynrpcDescriptor;
133
+ const serviceGrpcSpec = keyed
134
+ ? pushKeyedService(desc, name)
135
+ : pushUnKeyedService(desc, name);
136
+ for (const [route, handler] of Object.entries(router)) {
137
+ let registration;
138
+ if ((0, router_1.isEventHandler)(handler)) {
139
+ const theHandler = handler.handler;
140
+ registration = this.stringKeyedEventHandler(keyed, route, theHandler);
141
+ }
142
+ else {
143
+ registration = this.rpcHandler(keyed, route, handler);
144
+ }
145
+ serviceGrpcSpec.method.push(registration.descriptor);
146
+ const url = `/invoke/${name}/${route}`;
147
+ this.methods[url] = new grpc_1.HostedGrpcServiceMethod({}, // we don't actually execute on any class instance
148
+ servicePackage, serviceName, registration.method);
149
+ logger_1.rlog.info(`Registering: ${url} -> ${JSON.stringify(registration.method, null, "\t")}`);
150
+ }
151
+ // since we modified this descriptor, we need to remove it in case it was added before,
152
+ // so that the modified version is processed and added again
153
+ const filteredFiles = this.discovery.files?.file.filter((haveDesc) => desc.fileDescriptor.name !== haveDesc.name);
154
+ if (this.discovery.files !== undefined && filteredFiles !== undefined) {
155
+ this.discovery.files.file = filteredFiles;
156
+ }
157
+ this.addDescriptor(desc);
158
+ this.discovery.services.push(name);
159
+ }
160
+ methodByUrl(url) {
161
+ if (url == undefined || url === null) {
162
+ return undefined;
163
+ }
164
+ return this.methods[url];
165
+ }
166
+ }
167
+ exports.BaseRestateServer = BaseRestateServer;
168
+ /* eslint-disable @typescript-eslint/no-explicit-any */
169
+ function indexProperties(instance) {
170
+ const names = new Map();
171
+ while (instance !== null &&
172
+ instance !== undefined &&
173
+ instance !== Object.prototype) {
174
+ for (const property of Object.getOwnPropertyNames(instance)) {
175
+ names.set(property.toLowerCase(), property);
176
+ }
177
+ instance = Object.getPrototypeOf(instance);
178
+ }
179
+ return names;
180
+ }
181
+ // Given:
182
+ // * an instance of a class that implements a gRPC TypeScript interface,
183
+ // as generated by our protoc plugin, this method
184
+ // * The ProtobufFileDescriptor as generated by the protobuf plugin
185
+ // * and the gRPC service name
186
+ //
187
+ // Return a GrpcService definition, as defined above.
188
+ //
189
+ // For example (see first: example.proto and example.ts):
190
+ //
191
+ // > parse(example.protoMetaData, "Greeter", new GreeterService())
192
+ //
193
+ // produces ~
194
+ //
195
+ // serviceName: 'Greeter',
196
+ // instance: GreeterService {},
197
+ // methods: {
198
+ // multiword: {
199
+ // localName: 'multiWord',
200
+ // fn: [Function: multiWord],
201
+ // inputType: [Object],
202
+ // outputType: [Object]
203
+ // },
204
+ // greet: {
205
+ // localName: 'greet',
206
+ // fn: [Function: greet],
207
+ // inputType: [Object],
208
+ // outputType: [Object]
209
+ // }
210
+ // }
211
+ //}
212
+ //
213
+ /* eslint-disable @typescript-eslint/no-explicit-any */
214
+ function parseService(meta, serviceName, instance) {
215
+ const svcMethods = [];
216
+ // index all the existing properties that `instance` has.
217
+ // we index them by the lower case represention.
218
+ const names = indexProperties(instance);
219
+ for (const serviceDescriptor of meta.fileDescriptor.service) {
220
+ if (serviceName !== serviceDescriptor.name) {
221
+ continue;
222
+ }
223
+ for (const methodDescriptor of serviceDescriptor.method) {
224
+ const lowercaseName = methodDescriptor.name.toLowerCase();
225
+ const localName = names.get(lowercaseName);
226
+ if (localName === undefined || localName === null) {
227
+ throw new Error(`unimplemented method ${methodDescriptor.name}`);
228
+ }
229
+ const fn = instance[localName];
230
+ if (typeof fn !== "function") {
231
+ throw new Error(`A property ${localName} exists, which coresponds to a gRPC service named ${methodDescriptor.name}, but that property is not a function.`);
232
+ }
233
+ const localMethod = async (instance, input) => {
234
+ return await fn.call(instance, input);
235
+ };
236
+ let inputMessage = meta.references[methodDescriptor.inputType];
237
+ // If the input message type is not defined by the proto files of the service but by a dependency (e.g. BoolValue, Empty, etc)
238
+ // then we need to look for the encoders and decoders in the dependencies.
239
+ if (inputMessage === undefined) {
240
+ meta.dependencies?.forEach((dep) => {
241
+ if (dep.references[methodDescriptor.inputType] !== undefined) {
242
+ inputMessage = dep.references[methodDescriptor.inputType];
243
+ }
244
+ });
245
+ }
246
+ let outputMessage = meta.references[methodDescriptor.outputType];
247
+ // If the output message type is not defined by use but by the proto files of the service (e.g. BoolValue, Empty, etc)
248
+ // then we need to look for the encoders and decoders in the dependencies.
249
+ if (outputMessage === undefined) {
250
+ meta.dependencies?.forEach((dep) => {
251
+ if (dep.references[methodDescriptor.outputType] !== undefined) {
252
+ outputMessage = dep.references[methodDescriptor.outputType];
253
+ }
254
+ });
255
+ }
256
+ const decoder = (buffer) => inputMessage.decode(buffer);
257
+ const encoder = (message) => outputMessage.encode(message).finish();
258
+ svcMethods.push(new grpc_1.GrpcServiceMethod(methodDescriptor.name, localName, localMethod, decoder, encoder));
259
+ }
260
+ return new grpc_1.GrpcService(serviceName, meta.fileDescriptor.package, instance, svcMethods);
261
+ }
262
+ throw new Error(`Unable to find a service ${serviceName}.`);
263
+ }
264
+ exports.parseService = parseService;
265
+ async function dispatchKeyedRpcHandler(origCtx, req, handler) {
266
+ const { key, request } = (0, assumpsions_1.verifyAssumptions)(true, req);
267
+ const ctx = new restate_context_impl_1.RpcContextImpl(origCtx);
268
+ if (typeof key !== "string" || key.length === 0) {
269
+ // we throw a terminal error here, because this cannot be patched by updating code:
270
+ // if the request is wrong (missing a key), the request can never make it
271
+ throw new public_api_1.TerminalError("Keyed handlers must recieve a non null or empty string key");
272
+ }
273
+ const jsResult = (await handler(ctx, key, request));
274
+ return dynrpc_1.RpcResponse.create({ response: jsResult });
275
+ }
276
+ async function dispatchUnkeyedRpcHandler(origCtx, req, handler) {
277
+ const { request } = (0, assumpsions_1.verifyAssumptions)(false, req);
278
+ const ctx = new restate_context_impl_1.RpcContextImpl(origCtx);
279
+ const result = await handler(ctx, request);
280
+ return dynrpc_1.RpcResponse.create({ response: result });
281
+ }
282
+ async function dispatchKeyedEventHandler(origCtx, req, handler) {
283
+ const ctx = new restate_context_impl_1.RpcContextImpl(origCtx);
284
+ const key = req.key;
285
+ if (key === null || key === undefined || key.length === 0) {
286
+ // we throw a terminal error here, because this cannot be patched by updating code:
287
+ // if the request is wrong (missing a key), the request can never make it
288
+ throw new public_api_1.TerminalError("Keyed handlers must receive a non null or empty string key");
289
+ }
290
+ const jsEvent = new types_1.Event(key, req.payload, req.attributes);
291
+ await handler(ctx, jsEvent);
292
+ return empty_1.Empty.create({});
293
+ }
294
+ function copyProtoMetadata(original) {
295
+ // duplicate the file descriptor. shallow, because we only need to
296
+ // change one top-level field: service[]
297
+ const fileDescriptorCopy = {
298
+ ...original.fileDescriptor,
299
+ };
300
+ fileDescriptorCopy.service = [];
301
+ let options = original.options;
302
+ if (options !== undefined) {
303
+ options = {
304
+ ...original.options,
305
+ };
306
+ options.services = {};
307
+ }
308
+ return {
309
+ fileDescriptor: fileDescriptorCopy,
310
+ references: original.references,
311
+ dependencies: original.dependencies,
312
+ options: options,
313
+ };
314
+ }
315
+ function pushKeyedService(desc, newName) {
316
+ const service = {
317
+ ...dynrpc_1.protoMetadata.fileDescriptor.service[0],
318
+ };
319
+ service.name = newName;
320
+ service.method = [];
321
+ desc.fileDescriptor.service.push(service);
322
+ const serviceOptions = dynrpc_1.protoMetadata.options?.services?.["RpcEndpoint"];
323
+ if (serviceOptions === undefined) {
324
+ throw new Error("Missing service options in original RpcEndpoint proto descriptor");
325
+ }
326
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
327
+ desc.options.services[newName] = serviceOptions;
328
+ return service;
329
+ }
330
+ function pushUnKeyedService(desc, newName) {
331
+ const service = {
332
+ ...dynrpc_1.protoMetadata.fileDescriptor.service[1],
333
+ };
334
+ service.name = newName;
335
+ service.method = [];
336
+ desc.fileDescriptor.service.push(service);
337
+ const serviceOptions = dynrpc_1.protoMetadata.options?.services?.["UnkeyedRpcEndpoint"];
338
+ if (serviceOptions === undefined) {
339
+ throw new Error("Missing service options in original UnkeyedRpcEndpoint proto descriptor");
340
+ }
341
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
342
+ desc.options.services[newName] = serviceOptions;
343
+ return service;
344
+ }
345
+ function createRpcMethodDescriptor(methodName) {
346
+ const desc = {
347
+ ...dynrpc_1.protoMetadata.fileDescriptor.service[0].method[0],
348
+ };
349
+ desc.name = methodName;
350
+ return desc;
351
+ }
352
+ function createStringKeyedMethodDescriptor(methodName) {
353
+ const desc = {
354
+ ...dynrpc_1.protoMetadata.fileDescriptor.service[0].method[1],
355
+ };
356
+ desc.name = methodName;
357
+ return desc;
358
+ }
359
+ const dynrpcDescriptor = copyProtoMetadata(dynrpc_1.protoMetadata);
360
+ //# sourceMappingURL=base_restate_server.js.map
@@ -0,0 +1 @@
1
+ {"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,CAC1E,CAAC;KACH;IACD,oEAAoE;IACpE,IAAI,CAAC,OAAQ,CAAC,QAAS,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC;IAElD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,yBAAyB,CAAC,UAAkB;IACnD,MAAM,IAAI,GAAG;QACX,GAAG,sBAAuB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KACrC,CAAC;IAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACvB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iCAAiC,CACxC,UAAkB;IAElB,MAAM,IAAI,GAAG;QACX,GAAG,sBAAuB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KACrC,CAAC;IAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACvB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,sBAAuB,CAAC,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { BaseRestateServer, ServiceOpts } from "./base_restate_server";
2
+ import { KeyedRouter, UnKeyedRouter } from "../public_api";
3
+ /**
4
+ * Creates an Restate entrypoint for services deployed on AWS Lambda and invoked
5
+ * through API Gateway.
6
+ *
7
+ * Register services on this entrypoint via {@link LambdaRestateServer.bindService } and
8
+ * then create the Lambda invocation handler via {@link LambdaRestateServer.handle }.
9
+ *
10
+ * @example
11
+ * A typical AWS Lambda entry point would look like this
12
+ * ```
13
+ * import * as restate from "@restatedev/restate-sdk";
14
+ *
15
+ * export const handler = restate
16
+ * .createLambdaApiGatewayHandler()
17
+ * .bindService({
18
+ * service: "MyService",
19
+ * instance: new myService.MyServiceImpl(),
20
+ * descriptor: myService.protoMetadata,
21
+ * })
22
+ * .handle();
23
+ * ```
24
+ */
25
+ export declare function createLambdaApiGatewayHandler(): LambdaRestateServer;
26
+ /**
27
+ * Restate entrypoint implementation for services deployed on AWS Lambda.
28
+ * This one decodes the requests, create the log event sequence that
29
+ * drives the durable execution of the service invocations.
30
+ */
31
+ export declare class LambdaRestateServer extends BaseRestateServer {
32
+ constructor();
33
+ /**
34
+ * Adds a gRPC service to be served from this endpoint.
35
+ *
36
+ * The {@link ServiceOpts} passed here need to describe the following properties:
37
+ *
38
+ * - The 'service' name: the name of the gRPC service (as in the service definition proto file).
39
+ * - The service 'instance': the implementation of the service logic (must implement the generated
40
+ * gRPC service interface).
41
+ * - The gRPC/protobuf 'descriptor': The protoMetadata descriptor that describes the service, methods,
42
+ * and parameter types. It is usually found as the value 'protoMetadata' in the generated
43
+ * file '(service-name).ts'
44
+ *
45
+ * The descriptor is generated by the protobuf compiler and needed by Restate to reflectively discover
46
+ * the service details, understand payload serialization, perform HTTP/JSON-to-gRPC transcoding, or
47
+ * to proxy the service.
48
+ *
49
+ * If you define multiple services in the same '.proto' file, you may have only one descriptor that
50
+ * describes all services together. You can pass the same descriptor to multiple calls of '.bindService()'.
51
+ *
52
+ * If you don't find the gRPC/protobuf descriptor, make your you generated the gRPC/ProtoBuf code with
53
+ * the option to generate the descriptor. For example, using the 'ts-proto' plugin, make sure you pass
54
+ * the 'outputSchema=true' option. If you are using Restate's project templates, this should all be
55
+ * pre-configured for you.
56
+ *
57
+ * @example
58
+ * ```
59
+ * endpoint.bindService({
60
+ * service: "MyService",
61
+ * instance: new myService.MyServiceImpl(),
62
+ * descriptor: myService.protoMetadata
63
+ * })
64
+ * ```
65
+ *
66
+ * @param serviceOpts The options describing the service to be bound. See above for a detailed description.
67
+ * @returns An instance of this LambdaRestateServer
68
+ */
69
+ bindService(serviceOpts: ServiceOpts): LambdaRestateServer;
70
+ bindRouter<M>(path: string, router: UnKeyedRouter<M>): LambdaRestateServer;
71
+ bindKeyedRouter<M>(path: string, router: KeyedRouter<M>): LambdaRestateServer;
72
+ /**
73
+ * Creates the invocation handler function to be called by AWS Lambda.
74
+ *
75
+ * The returned type of this function is `(event: APIGatewayProxyEvent | APIGatewayProxyEventV2) => Promise<APIGatewayProxyResult | APIGatewayProxyResultV2>`.
76
+ * We use `any` types here to avoid a dependency on the `@types/aws-lambda` dependency for consumers of this API.
77
+ *
78
+ * @example
79
+ * A typical AWS Lambda entry point would use this method the follwing way:
80
+ * ```
81
+ * import * as restate from "@restatedev/restate-sdk";
82
+ *
83
+ * export const handler = restate
84
+ * .createLambdaApiGatewayHandler()
85
+ * .bindService({
86
+ * service: "MyService",
87
+ * instance: new myService.MyServiceImpl(),
88
+ * descriptor: myService.protoMetadata,
89
+ * })
90
+ * .handle();
91
+ * ```
92
+ *
93
+ * @returns The invocation handler function for to be called by AWS Lambda.
94
+ */
95
+ handle(): (event: any) => Promise<any>;
96
+ /**
97
+ * This is the main request handling method, effectively a typed variant of `create()`.
98
+ */
99
+ private handleRequest;
100
+ private handleInvoke;
101
+ private handleDiscovery;
102
+ private toErrorResponse;
103
+ }
104
+ //# sourceMappingURL=restate_lambda_handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restate_lambda_handler.d.ts","sourceRoot":"","sources":["../../src/server/restate_lambda_handler.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOvE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,6BAA6B,IAAI,mBAAmB,CAEnE;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,iBAAiB;;IAKxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACI,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;IAO1D,UAAU,CAAC,CAAC,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,mBAAmB;IAKf,eAAe,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,mBAAmB;IAKtB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IAEI,MAAM,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;IAO7C;;OAEG;YACW,aAAa;YAuCb,YAAY;IAsD1B,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,eAAe;CAUxB"}