@restatedev/restate-sdk 1.7.3 → 1.8.0
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.
- package/README.md +4 -3
- package/dist/cjs/src/common_api.d.ts +3 -2
- package/dist/cjs/src/common_api.d.ts.map +1 -1
- package/dist/cjs/src/common_api.js +2 -1
- package/dist/cjs/src/common_api.js.map +1 -1
- package/dist/cjs/src/context.d.ts +66 -47
- package/dist/cjs/src/context.d.ts.map +1 -1
- package/dist/cjs/src/context.js.map +1 -1
- package/dist/cjs/src/context_impl.d.ts.map +1 -1
- package/dist/cjs/src/context_impl.js +8 -0
- package/dist/cjs/src/context_impl.js.map +1 -1
- package/dist/cjs/src/{types → endpoint}/components.d.ts +2 -2
- package/dist/cjs/src/endpoint/components.d.ts.map +1 -0
- package/dist/cjs/src/{types → endpoint}/components.js +1 -1
- package/dist/cjs/src/endpoint/components.js.map +1 -0
- package/dist/cjs/src/endpoint/discovery.d.ts.map +1 -0
- package/dist/cjs/src/endpoint/discovery.js.map +1 -0
- package/dist/cjs/src/endpoint/endpoint.d.ts +33 -0
- package/dist/cjs/src/endpoint/endpoint.d.ts.map +1 -0
- package/dist/cjs/src/endpoint/endpoint.js +152 -0
- package/dist/cjs/src/endpoint/endpoint.js.map +1 -0
- package/dist/cjs/src/endpoint/fetch_endpoint.d.ts +3 -6
- package/dist/cjs/src/endpoint/fetch_endpoint.d.ts.map +1 -1
- package/dist/cjs/src/endpoint/fetch_endpoint.js +8 -13
- package/dist/cjs/src/endpoint/fetch_endpoint.js.map +1 -1
- package/dist/cjs/src/endpoint/handlers/generic.d.ts +4 -4
- package/dist/cjs/src/endpoint/handlers/generic.d.ts.map +1 -1
- package/dist/cjs/src/endpoint/handlers/generic.js +12 -3
- package/dist/cjs/src/endpoint/handlers/generic.js.map +1 -1
- package/dist/cjs/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +16 -0
- package/dist/cjs/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts.map +1 -1
- package/dist/cjs/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js +40 -1
- package/dist/cjs/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js.map +1 -1
- package/dist/cjs/src/endpoint/lambda_endpoint.d.ts +2 -5
- package/dist/cjs/src/endpoint/lambda_endpoint.d.ts.map +1 -1
- package/dist/cjs/src/endpoint/lambda_endpoint.js +8 -13
- package/dist/cjs/src/endpoint/lambda_endpoint.js.map +1 -1
- package/dist/cjs/src/endpoint/node_endpoint.d.ts +2 -5
- package/dist/cjs/src/endpoint/node_endpoint.d.ts.map +1 -1
- package/dist/cjs/src/endpoint/node_endpoint.js +55 -63
- package/dist/cjs/src/endpoint/node_endpoint.js.map +1 -1
- package/dist/cjs/src/endpoint/types.d.ts +48 -0
- package/dist/cjs/src/endpoint/types.d.ts.map +1 -0
- package/dist/cjs/src/endpoint/types.js +3 -0
- package/dist/cjs/src/endpoint/types.js.map +1 -0
- package/dist/cjs/src/endpoint/withOptions.d.ts +4 -0
- package/dist/cjs/src/endpoint/withOptions.d.ts.map +1 -0
- package/dist/cjs/src/endpoint/withOptions.js +19 -0
- package/dist/cjs/src/endpoint/withOptions.js.map +1 -0
- package/dist/cjs/src/endpoint.d.ts +23 -22
- package/dist/cjs/src/endpoint.d.ts.map +1 -1
- package/dist/cjs/src/fetch.d.ts +34 -0
- package/dist/cjs/src/fetch.d.ts.map +1 -1
- package/dist/cjs/src/fetch.js +26 -0
- package/dist/cjs/src/fetch.js.map +1 -1
- package/dist/cjs/src/generated/version.d.ts +1 -1
- package/dist/cjs/src/generated/version.js +1 -1
- package/dist/cjs/src/lambda.d.ts +16 -1
- package/dist/cjs/src/lambda.d.ts.map +1 -1
- package/dist/cjs/src/lambda.js +19 -1
- package/dist/cjs/src/lambda.js.map +1 -1
- package/dist/cjs/src/node.d.ts +38 -0
- package/dist/cjs/src/node.d.ts.map +1 -0
- package/dist/cjs/src/node.js +70 -0
- package/dist/cjs/src/node.js.map +1 -0
- package/dist/cjs/src/public_api.d.ts +1 -6
- package/dist/cjs/src/public_api.d.ts.map +1 -1
- package/dist/cjs/src/public_api.js +1 -9
- package/dist/cjs/src/public_api.js.map +1 -1
- package/dist/cjs/src/types/errors.d.ts +25 -0
- package/dist/cjs/src/types/errors.d.ts.map +1 -1
- package/dist/cjs/src/types/errors.js +31 -2
- package/dist/cjs/src/types/errors.js.map +1 -1
- package/dist/cjs/src/types/rpc.d.ts +19 -19
- package/dist/cjs/src/types/rpc.js +19 -19
- package/dist/cjs/src/user_agent.d.ts +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/common_api.d.ts +3 -2
- package/dist/esm/src/common_api.d.ts.map +1 -1
- package/dist/esm/src/common_api.js +1 -1
- package/dist/esm/src/common_api.js.map +1 -1
- package/dist/esm/src/context.d.ts +66 -47
- package/dist/esm/src/context.d.ts.map +1 -1
- package/dist/esm/src/context.js.map +1 -1
- package/dist/esm/src/context_impl.d.ts.map +1 -1
- package/dist/esm/src/context_impl.js +9 -1
- package/dist/esm/src/context_impl.js.map +1 -1
- package/dist/esm/src/{types → endpoint}/components.d.ts +2 -2
- package/dist/esm/src/endpoint/components.d.ts.map +1 -0
- package/dist/esm/src/{types → endpoint}/components.js +1 -1
- package/dist/esm/src/endpoint/components.js.map +1 -0
- package/dist/esm/src/endpoint/discovery.d.ts.map +1 -0
- package/dist/esm/src/endpoint/discovery.js.map +1 -0
- package/dist/esm/src/endpoint/endpoint.d.ts +33 -0
- package/dist/esm/src/endpoint/endpoint.d.ts.map +1 -0
- package/dist/esm/src/endpoint/endpoint.js +148 -0
- package/dist/esm/src/endpoint/endpoint.js.map +1 -0
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts +3 -6
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/fetch_endpoint.js +7 -12
- package/dist/esm/src/endpoint/fetch_endpoint.js.map +1 -1
- package/dist/esm/src/endpoint/handlers/generic.d.ts +4 -4
- package/dist/esm/src/endpoint/handlers/generic.d.ts.map +1 -1
- package/dist/esm/src/endpoint/handlers/generic.js +13 -4
- package/dist/esm/src/endpoint/handlers/generic.js.map +1 -1
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +16 -0
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.d.ts.map +1 -1
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js +40 -1
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js.map +1 -1
- package/dist/esm/src/endpoint/lambda_endpoint.d.ts +2 -5
- package/dist/esm/src/endpoint/lambda_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/lambda_endpoint.js +7 -12
- package/dist/esm/src/endpoint/lambda_endpoint.js.map +1 -1
- package/dist/esm/src/endpoint/node_endpoint.d.ts +2 -5
- package/dist/esm/src/endpoint/node_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/node_endpoint.js +54 -62
- package/dist/esm/src/endpoint/node_endpoint.js.map +1 -1
- package/dist/esm/src/endpoint/types.d.ts +48 -0
- package/dist/esm/src/endpoint/types.d.ts.map +1 -0
- package/dist/esm/src/endpoint/types.js +2 -0
- package/dist/esm/src/endpoint/types.js.map +1 -0
- package/dist/esm/src/endpoint/withOptions.d.ts +4 -0
- package/dist/esm/src/endpoint/withOptions.d.ts.map +1 -0
- package/dist/esm/src/endpoint/withOptions.js +16 -0
- package/dist/esm/src/endpoint/withOptions.js.map +1 -0
- package/dist/esm/src/endpoint.d.ts +23 -22
- package/dist/esm/src/endpoint.d.ts.map +1 -1
- package/dist/esm/src/fetch.d.ts +34 -0
- package/dist/esm/src/fetch.d.ts.map +1 -1
- package/dist/esm/src/fetch.js +25 -0
- package/dist/esm/src/fetch.js.map +1 -1
- package/dist/esm/src/generated/version.d.ts +1 -1
- package/dist/esm/src/generated/version.js +1 -1
- package/dist/esm/src/lambda.d.ts +16 -1
- package/dist/esm/src/lambda.d.ts.map +1 -1
- package/dist/esm/src/lambda.js +18 -1
- package/dist/esm/src/lambda.js.map +1 -1
- package/dist/esm/src/node.d.ts +38 -0
- package/dist/esm/src/node.d.ts.map +1 -0
- package/dist/esm/src/node.js +51 -0
- package/dist/esm/src/node.js.map +1 -0
- package/dist/esm/src/public_api.d.ts +1 -6
- package/dist/esm/src/public_api.d.ts.map +1 -1
- package/dist/esm/src/public_api.js +1 -8
- package/dist/esm/src/public_api.js.map +1 -1
- package/dist/esm/src/types/errors.d.ts +25 -0
- package/dist/esm/src/types/errors.d.ts.map +1 -1
- package/dist/esm/src/types/errors.js +29 -1
- package/dist/esm/src/types/errors.js.map +1 -1
- package/dist/esm/src/types/rpc.d.ts +19 -19
- package/dist/esm/src/types/rpc.js +19 -19
- package/dist/esm/src/user_agent.d.ts +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -2
- package/dist/cjs/src/endpoint/endpoint_builder.d.ts +0 -26
- package/dist/cjs/src/endpoint/endpoint_builder.d.ts.map +0 -1
- package/dist/cjs/src/endpoint/endpoint_builder.js +0 -143
- package/dist/cjs/src/endpoint/endpoint_builder.js.map +0 -1
- package/dist/cjs/src/types/components.d.ts.map +0 -1
- package/dist/cjs/src/types/components.js.map +0 -1
- package/dist/cjs/src/types/discovery.d.ts.map +0 -1
- package/dist/cjs/src/types/discovery.js.map +0 -1
- package/dist/esm/src/endpoint/endpoint_builder.d.ts +0 -26
- package/dist/esm/src/endpoint/endpoint_builder.d.ts.map +0 -1
- package/dist/esm/src/endpoint/endpoint_builder.js +0 -139
- package/dist/esm/src/endpoint/endpoint_builder.js.map +0 -1
- package/dist/esm/src/types/components.d.ts.map +0 -1
- package/dist/esm/src/types/components.js.map +0 -1
- package/dist/esm/src/types/discovery.d.ts.map +0 -1
- package/dist/esm/src/types/discovery.js.map +0 -1
- /package/dist/cjs/src/{types → endpoint}/discovery.d.ts +0 -0
- /package/dist/cjs/src/{types → endpoint}/discovery.js +0 -0
- /package/dist/esm/src/{types → endpoint}/discovery.d.ts +0 -0
- /package/dist/esm/src/{types → endpoint}/discovery.js +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withOptions = withOptions;
|
|
4
|
+
function withOptions(endpoint, { identityKeys, defaultServiceOptions, logger, services }) {
|
|
5
|
+
let endpointWithOptions = endpoint;
|
|
6
|
+
if (identityKeys && identityKeys.length > 0) {
|
|
7
|
+
endpointWithOptions = endpointWithOptions.withIdentityV1(...identityKeys);
|
|
8
|
+
}
|
|
9
|
+
if (defaultServiceOptions) {
|
|
10
|
+
endpointWithOptions = endpointWithOptions.defaultServiceOptions(defaultServiceOptions);
|
|
11
|
+
}
|
|
12
|
+
if (logger) {
|
|
13
|
+
endpointWithOptions = endpointWithOptions.setLogger(logger);
|
|
14
|
+
}
|
|
15
|
+
return services.reduce((results, service) => {
|
|
16
|
+
return results.bind(service);
|
|
17
|
+
}, endpointWithOptions);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=withOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withOptions.js","sourceRoot":"","sources":["../../../../src/endpoint/withOptions.ts"],"names":[],"mappings":";;AAGA,kCAoBC;AApBD,SAAgB,WAAW,CACzB,QAAW,EACX,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,EAAmB;IAE1E,IAAI,mBAAmB,GAAG,QAAQ,CAAC;IACnC,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,mBAAmB,GAAG,mBAAmB,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,qBAAqB,EAAE,CAAC;QAC1B,mBAAmB,GAAG,mBAAmB,CAAC,qBAAqB,CAC7D,qBAAqB,CACtB,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,mBAAmB,GAAG,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Http2ServerRequest, Http2ServerResponse } from "http2";
|
|
2
2
|
import type { VirtualObjectDefinition, ServiceDefinition, WorkflowDefinition } from "@restatedev/restate-sdk-core";
|
|
3
3
|
import type { LoggerTransport } from "./logging/logger_transport.js";
|
|
4
|
+
import type { ObjectOptions, ServiceOptions, WorkflowOptions } from "./types/rpc.js";
|
|
5
|
+
export type DefaultServiceOptions = ServiceOptions & ObjectOptions & WorkflowOptions;
|
|
4
6
|
export interface RestateEndpointBase<E> {
|
|
5
7
|
/**
|
|
6
8
|
* Binds a new durable service / virtual object / workflow.
|
|
@@ -18,34 +20,43 @@ export interface RestateEndpointBase<E> {
|
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
20
22
|
withIdentityV1(...keys: string[]): E;
|
|
23
|
+
/**
|
|
24
|
+
* Set default service options that will be used by all services bind to this endpoint.
|
|
25
|
+
*
|
|
26
|
+
* Options can be overridden on each service/handler.
|
|
27
|
+
*
|
|
28
|
+
* @param options
|
|
29
|
+
*/
|
|
30
|
+
defaultServiceOptions(options: DefaultServiceOptions): E;
|
|
21
31
|
/**
|
|
22
32
|
* Replace the default console-based {@link LoggerTransport}
|
|
23
33
|
* @param logger
|
|
24
34
|
* @example
|
|
25
35
|
* Using console:
|
|
26
36
|
* ```ts
|
|
27
|
-
*
|
|
28
|
-
*
|
|
37
|
+
* restate.setLogger((meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)})
|
|
38
|
+
* ```
|
|
29
39
|
* @example
|
|
30
40
|
* Using winston:
|
|
31
41
|
* ```ts
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
42
|
+
* const logger = createLogger({ ... })
|
|
43
|
+
* restate.setLogger((meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
44
|
+
* ```
|
|
35
45
|
* @example
|
|
36
46
|
* Using pino:
|
|
37
47
|
* ```ts
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
48
|
+
* const logger = pino()
|
|
49
|
+
* restate.setLogger((meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
50
|
+
* ```
|
|
41
51
|
*/
|
|
42
52
|
setLogger(logger: LoggerTransport): E;
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
55
|
* RestateEndpoint encapsulates all the Restate services served by this endpoint.
|
|
46
56
|
*
|
|
47
|
-
* A RestateEndpoint can either be served
|
|
48
|
-
*
|
|
57
|
+
* A RestateEndpoint can either be served as HTTP2 server, using the methods {@link RestateEndpoint.listen} or {@link RestateEndpoint.http2Handler}.
|
|
58
|
+
*
|
|
59
|
+
* For Lambda, check {@link LambdaEndpoint}
|
|
49
60
|
*
|
|
50
61
|
* @example
|
|
51
62
|
* A typical endpoint served as HTTP server would look like this:
|
|
@@ -57,16 +68,6 @@ export interface RestateEndpointBase<E> {
|
|
|
57
68
|
* .bind(myService)
|
|
58
69
|
* .listen(8000);
|
|
59
70
|
* ```
|
|
60
|
-
* @example
|
|
61
|
-
* A typical endpoint served as AWS Lambda would look like this:
|
|
62
|
-
* ```
|
|
63
|
-
* import * as restate from "@restatedev/restate-sdk/lambda";
|
|
64
|
-
*
|
|
65
|
-
* export const handler = restate
|
|
66
|
-
* .endpoint()
|
|
67
|
-
* .bind(myService)
|
|
68
|
-
* .handler();
|
|
69
|
-
* ```
|
|
70
71
|
*/
|
|
71
72
|
export interface RestateEndpoint extends RestateEndpointBase<RestateEndpoint> {
|
|
72
73
|
/**
|
|
@@ -86,14 +87,14 @@ export interface RestateEndpoint extends RestateEndpointBase<RestateEndpoint> {
|
|
|
86
87
|
* httpServer.listen(port);
|
|
87
88
|
* ```
|
|
88
89
|
*
|
|
89
|
-
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link http2Handler}.
|
|
90
|
+
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link RestateEndpoint.http2Handler}.
|
|
90
91
|
*
|
|
91
92
|
* @param port The port to listen at. May be undefined (see above).
|
|
92
93
|
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
|
|
93
94
|
*/
|
|
94
95
|
listen(port?: number): Promise<number>;
|
|
95
96
|
/**
|
|
96
|
-
* Returns an http2 server handler. See {@link listen} for more details.
|
|
97
|
+
* Returns an http2 server handler. See {@link RestateEndpoint.listen} for more details.
|
|
97
98
|
*/
|
|
98
99
|
http2Handler(): (request: Http2ServerRequest, response: Http2ServerResponse) => void;
|
|
99
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/endpoint.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/endpoint.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAChD,aAAa,GACb,eAAe,CAAC;AAElB,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC;;;;QAII;IACJ,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACtB,OAAO,EACH,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3B,CAAC,CAAC;IAEL;;;;;;;;OAQG;IACH,cAAc,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAErC;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,CAAC,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB,CAAC,eAAe,CAAC;IAC3E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,YAAY,IAAI,CACd,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,mBAAmB,KAC1B,IAAI,CAAC;CACX"}
|
package/dist/cjs/src/fetch.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
export * from "./common_api.js";
|
|
2
2
|
import { type FetchEndpoint } from "./endpoint/fetch_endpoint.js";
|
|
3
|
+
import type { EndpointOptions } from "./endpoint/types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Create a new {@link RestateEndpoint} in request response protocol mode.
|
|
5
6
|
* Bidirectional mode (must be served over http2) can be enabled with .enableHttp2()
|
|
6
7
|
*/
|
|
7
8
|
export declare function endpoint(): FetchEndpoint;
|
|
9
|
+
interface FetchEndpointOptions extends EndpointOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Enables bidirectional communication for the handler.
|
|
12
|
+
*
|
|
13
|
+
* When set to `true`, the handler supports bidirectional streaming (e.g., via HTTP/2 or compatible HTTP/1.1 servers).
|
|
14
|
+
* When `false`, the handler operates in request-response mode only.
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
bidirectional?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Fetch handler that encapsulates all the Restate services served by this endpoint.
|
|
22
|
+
*
|
|
23
|
+
* @param {FetchEndpointOptions} options - Configuration options for the endpoint handler.
|
|
24
|
+
* @returns A fetch handler function.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* A typical request-response handler would look like this:
|
|
28
|
+
* ```
|
|
29
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
30
|
+
*
|
|
31
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* A typical bidirectional handler (works with http2 and some http1.1 servers) would look like this:
|
|
35
|
+
* ```
|
|
36
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
37
|
+
*
|
|
38
|
+
* export const handler = createEndpointHandler({ services: [myService], bidirectional: true })
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
export declare function createEndpointHandler(options: FetchEndpointOptions): (request: Request, ...extraArgs: unknown[]) => Promise<Response>;
|
|
8
42
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/fetch.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/fetch.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,aAAa,CAExC;AAED,UAAU,oBAAqB,SAAQ,eAAe;IACpD;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,oEAOlE"}
|
package/dist/cjs/src/fetch.js
CHANGED
|
@@ -25,8 +25,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.endpoint = endpoint;
|
|
28
|
+
exports.createEndpointHandler = createEndpointHandler;
|
|
28
29
|
__exportStar(require("./common_api.js"), exports);
|
|
29
30
|
const fetch_endpoint_js_1 = require("./endpoint/fetch_endpoint.js");
|
|
31
|
+
const withOptions_js_1 = require("./endpoint/withOptions.js");
|
|
30
32
|
/**
|
|
31
33
|
* Create a new {@link RestateEndpoint} in request response protocol mode.
|
|
32
34
|
* Bidirectional mode (must be served over http2) can be enabled with .enableHttp2()
|
|
@@ -34,4 +36,28 @@ const fetch_endpoint_js_1 = require("./endpoint/fetch_endpoint.js");
|
|
|
34
36
|
function endpoint() {
|
|
35
37
|
return new fetch_endpoint_js_1.FetchEndpointImpl("REQUEST_RESPONSE");
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Fetch handler that encapsulates all the Restate services served by this endpoint.
|
|
41
|
+
*
|
|
42
|
+
* @param {FetchEndpointOptions} options - Configuration options for the endpoint handler.
|
|
43
|
+
* @returns A fetch handler function.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* A typical request-response handler would look like this:
|
|
47
|
+
* ```
|
|
48
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
49
|
+
*
|
|
50
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* A typical bidirectional handler (works with http2 and some http1.1 servers) would look like this:
|
|
54
|
+
* ```
|
|
55
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
56
|
+
*
|
|
57
|
+
* export const handler = createEndpointHandler({ services: [myService], bidirectional: true })
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
function createEndpointHandler(options) {
|
|
61
|
+
return (0, withOptions_js_1.withOptions)(new fetch_endpoint_js_1.FetchEndpointImpl(options.bidirectional ? "BIDI_STREAM" : "REQUEST_RESPONSE"), options).handler().fetch;
|
|
62
|
+
}
|
|
37
63
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/fetch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/fetch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;AAeH,4BAEC;AAmCD,sDAOC;AAzDD,kDAAgC;AAEhC,oEAGsC;AAEtC,8DAAwD;AAExD;;;GAGG;AACH,SAAgB,QAAQ;IACtB,OAAO,IAAI,qCAAiB,CAAC,kBAAkB,CAAC,CAAC;AACnD,CAAC;AAcD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,qBAAqB,CAAC,OAA6B;IACjE,OAAO,IAAA,4BAAW,EAChB,IAAI,qCAAiB,CACnB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAC3D,EACD,OAAO,CACR,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;AACpB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
1
|
+
export declare const SDK_VERSION = "1.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cjs/src/lambda.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
export * from "./common_api.js";
|
|
2
2
|
import { type LambdaEndpoint } from "./endpoint/lambda_endpoint.js";
|
|
3
|
+
import type { EndpointOptions } from "./endpoint/types.js";
|
|
3
4
|
/**
|
|
4
|
-
* Create a new {@link
|
|
5
|
+
* Create a new {@link LambdaEndpoint}.
|
|
5
6
|
*/
|
|
6
7
|
export declare function endpoint(): LambdaEndpoint;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Lambda handler that encapsulates all the Restate services served by this endpoint.
|
|
10
|
+
*
|
|
11
|
+
* @param {EndpointOptions} options - Configuration options for the endpoint handler.
|
|
12
|
+
* @returns A Lambda handler function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* A typical endpoint served as Lambda would look like this:
|
|
16
|
+
* ```
|
|
17
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/lambda";
|
|
18
|
+
*
|
|
19
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
20
|
+
*/
|
|
21
|
+
export declare function createEndpointHandler(options: EndpointOptions): (event: any, ctx: any) => Promise<any>;
|
|
7
22
|
//# sourceMappingURL=lambda.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../../../src/lambda.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../../../src/lambda.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CAEzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,0CAK7D"}
|
package/dist/cjs/src/lambda.js
CHANGED
|
@@ -25,12 +25,30 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.endpoint = endpoint;
|
|
28
|
+
exports.createEndpointHandler = createEndpointHandler;
|
|
28
29
|
__exportStar(require("./common_api.js"), exports);
|
|
29
30
|
const lambda_endpoint_js_1 = require("./endpoint/lambda_endpoint.js");
|
|
31
|
+
const withOptions_js_1 = require("./endpoint/withOptions.js");
|
|
30
32
|
/**
|
|
31
|
-
* Create a new {@link
|
|
33
|
+
* Create a new {@link LambdaEndpoint}.
|
|
32
34
|
*/
|
|
33
35
|
function endpoint() {
|
|
34
36
|
return new lambda_endpoint_js_1.LambdaEndpointImpl();
|
|
35
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Lambda handler that encapsulates all the Restate services served by this endpoint.
|
|
40
|
+
*
|
|
41
|
+
* @param {EndpointOptions} options - Configuration options for the endpoint handler.
|
|
42
|
+
* @returns A Lambda handler function.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* A typical endpoint served as Lambda would look like this:
|
|
46
|
+
* ```
|
|
47
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/lambda";
|
|
48
|
+
*
|
|
49
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
50
|
+
*/
|
|
51
|
+
function createEndpointHandler(options) {
|
|
52
|
+
return (0, withOptions_js_1.withOptions)(new lambda_endpoint_js_1.LambdaEndpointImpl(), options).handler();
|
|
53
|
+
}
|
|
36
54
|
//# sourceMappingURL=lambda.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../../src/lambda.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../../src/lambda.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;AAcH,4BAEC;AAeD,sDAKC;AAlCD,kDAAgC;AAEhC,sEAGuC;AAEvC,8DAAwD;AAExD;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,IAAI,uCAAkB,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,qBAAqB,CAAC,OAAwB;IAC5D,OAAO,IAAA,4BAAW,EAChB,IAAI,uCAAkB,EAAE,EACxB,OAAO,CACR,CAAC,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from "./common_api.js";
|
|
2
|
+
import type { RestateEndpoint } from "./endpoint.js";
|
|
3
|
+
import type { EndpointOptions } from "./endpoint/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create a new {@link RestateEndpoint}.
|
|
6
|
+
*/
|
|
7
|
+
export declare function endpoint(): RestateEndpoint;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an HTTP/2 request handler for the provided services.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
|
|
14
|
+
* httpServer.listen(port);
|
|
15
|
+
* ```
|
|
16
|
+
* @param {EndpointOptions} options - Configuration options for the endpoint handler.
|
|
17
|
+
* @returns An HTTP/2 request handler function.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createEndpointHandler(options: EndpointOptions): (request: import("http2").Http2ServerRequest, response: import("http2").Http2ServerResponse) => void;
|
|
20
|
+
export interface ServeOptions extends EndpointOptions {
|
|
21
|
+
port?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serves this Restate services as HTTP2 server, listening to the given port.
|
|
25
|
+
*
|
|
26
|
+
* If the port is undefined, this method will use the port set in the `PORT`
|
|
27
|
+
* environment variable. If that variable is undefined as well, the method will
|
|
28
|
+
* default to port 9080.
|
|
29
|
+
*
|
|
30
|
+
* The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
|
|
31
|
+
*
|
|
32
|
+
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link createEndpointHandler}.
|
|
33
|
+
*
|
|
34
|
+
* @param {ServeOptions} options - Configuration options for the endpoint handler.
|
|
35
|
+
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare function serve({ port, ...options }: ServeOptions): Promise<number>;
|
|
38
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,QAAQ,IAAI,eAAe,CAE1C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,wGAK7D;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,YAAY,mBAEvD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2024 - 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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
24
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.endpoint = endpoint;
|
|
28
|
+
exports.createEndpointHandler = createEndpointHandler;
|
|
29
|
+
exports.serve = serve;
|
|
30
|
+
__exportStar(require("./common_api.js"), exports);
|
|
31
|
+
const node_endpoint_js_1 = require("./endpoint/node_endpoint.js");
|
|
32
|
+
const withOptions_js_1 = require("./endpoint/withOptions.js");
|
|
33
|
+
/**
|
|
34
|
+
* Create a new {@link RestateEndpoint}.
|
|
35
|
+
*/
|
|
36
|
+
function endpoint() {
|
|
37
|
+
return new node_endpoint_js_1.NodeEndpoint();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an HTTP/2 request handler for the provided services.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```
|
|
44
|
+
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
|
|
45
|
+
* httpServer.listen(port);
|
|
46
|
+
* ```
|
|
47
|
+
* @param {EndpointOptions} options - Configuration options for the endpoint handler.
|
|
48
|
+
* @returns An HTTP/2 request handler function.
|
|
49
|
+
*/
|
|
50
|
+
function createEndpointHandler(options) {
|
|
51
|
+
return (0, withOptions_js_1.withOptions)(new node_endpoint_js_1.NodeEndpoint(), options).http2Handler();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Serves this Restate services as HTTP2 server, listening to the given port.
|
|
55
|
+
*
|
|
56
|
+
* If the port is undefined, this method will use the port set in the `PORT`
|
|
57
|
+
* environment variable. If that variable is undefined as well, the method will
|
|
58
|
+
* default to port 9080.
|
|
59
|
+
*
|
|
60
|
+
* The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
|
|
61
|
+
*
|
|
62
|
+
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link createEndpointHandler}.
|
|
63
|
+
*
|
|
64
|
+
* @param {ServeOptions} options - Configuration options for the endpoint handler.
|
|
65
|
+
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
|
|
66
|
+
*/
|
|
67
|
+
function serve({ port, ...options }) {
|
|
68
|
+
return (0, withOptions_js_1.withOptions)(new node_endpoint_js_1.NodeEndpoint(), options).listen(port);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;AAWH,4BAEC;AAaD,sDAKC;AAoBD,sBAEC;AAnDD,kDAAgC;AAEhC,kEAA2D;AAE3D,8DAAwD;AAExD;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,IAAI,+BAAY,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,qBAAqB,CAAC,OAAwB;IAC5D,OAAO,IAAA,4BAAW,EAChB,IAAI,+BAAY,EAAE,EAClB,OAAO,CACR,CAAC,YAAY,EAAE,CAAC;AACnB,CAAC;AAMD;;;;;;;;;;;;;GAaG;AACH,SAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAgB;IACtD,OAAO,IAAA,4BAAW,EAAkB,IAAI,+BAAY,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
import type { RestateEndpoint } from "./endpoint.js";
|
|
3
|
-
/**
|
|
4
|
-
* Create a new {@link RestateEndpoint}.
|
|
5
|
-
*/
|
|
6
|
-
export declare function endpoint(): RestateEndpoint;
|
|
1
|
+
export * from "./node.js";
|
|
7
2
|
//# sourceMappingURL=public_api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../../../src/public_api.ts"],"names":[],"mappings":"AAWA,cAAc,
|
|
1
|
+
{"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../../../src/public_api.ts"],"names":[],"mappings":"AAWA,cAAc,WAAW,CAAC"}
|
|
@@ -24,13 +24,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
24
24
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
|
|
28
|
-
__exportStar(require("./common_api.js"), exports);
|
|
29
|
-
const node_endpoint_js_1 = require("./endpoint/node_endpoint.js");
|
|
30
|
-
/**
|
|
31
|
-
* Create a new {@link RestateEndpoint}.
|
|
32
|
-
*/
|
|
33
|
-
function endpoint() {
|
|
34
|
-
return new node_endpoint_js_1.NodeEndpoint();
|
|
35
|
-
}
|
|
27
|
+
__exportStar(require("./node.js"), exports);
|
|
36
28
|
//# sourceMappingURL=public_api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../../src/public_api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../../src/public_api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;AAEH,4CAA0B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Duration } from "@restatedev/restate-sdk-core";
|
|
1
2
|
export declare const INTERNAL_ERROR_CODE = 500;
|
|
2
3
|
export declare const TIMEOUT_ERROR_CODE = 408;
|
|
3
4
|
export declare const CANCEL_ERROR_CODE = 409;
|
|
@@ -46,4 +47,28 @@ export declare class CancelledError extends TerminalError {
|
|
|
46
47
|
name: string;
|
|
47
48
|
constructor();
|
|
48
49
|
}
|
|
50
|
+
export interface RetryableErrorOptions {
|
|
51
|
+
/**
|
|
52
|
+
* In how long it should retry.
|
|
53
|
+
*/
|
|
54
|
+
retryAfter?: Duration | number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Error that Restate will retry. By using this error type within a `ctx.run` closure,
|
|
58
|
+
* you can dynamically provide the retry delay specified in {@link RetryableErrorOptions}.
|
|
59
|
+
*
|
|
60
|
+
* You can wrap another error using {@link from}.
|
|
61
|
+
*/
|
|
62
|
+
export declare class RetryableError extends RestateError {
|
|
63
|
+
name: string;
|
|
64
|
+
readonly retryAfter?: Duration | number;
|
|
65
|
+
constructor(message: string, options?: RetryableErrorOptions & {
|
|
66
|
+
errorCode?: number;
|
|
67
|
+
cause?: any;
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Create a `RetryableError` from the given cause.
|
|
71
|
+
*/
|
|
72
|
+
static from(cause: any, options?: RetryableErrorOptions): RetryableError;
|
|
73
|
+
}
|
|
49
74
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/types/errors.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAGtC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,CACzB,CAAC,EAAE,OAAO,EACV,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,aAAa,GAAG,SAAS,GAC1D,KAAK,CA6BP;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,QAiBhD;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,SAAkB;gBAEjB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE;CAI3E;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,YAAY;IACtC,IAAI,SAAmB;gBAG5B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR;;WAEG;QACH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AC,EAAE,GAAG,CAAC;KACb;CAIJ;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;IACtC,IAAI,SAAkB;;CAK9B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;IACxC,IAAI,SAAoB;;CAKhC;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,YAAY;IACvC,IAAI,SAAoB;IAE/B,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;gBAGtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAAG;QAChC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,GAAG,CAAC;KACb;IAUH;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,cAAc;CAQzE"}
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.CancelledError = exports.TimeoutError = exports.TerminalError = exports.RestateError = exports.SUSPENDED_ERROR_CODE = exports.CLOSED_ERROR_CODE = exports.UNKNOWN_ERROR_CODE = exports.CANCEL_ERROR_CODE = exports.TIMEOUT_ERROR_CODE = exports.INTERNAL_ERROR_CODE = void 0;
|
|
13
|
+
exports.RetryableError = exports.CancelledError = exports.TimeoutError = exports.TerminalError = exports.RestateError = exports.SUSPENDED_ERROR_CODE = exports.CLOSED_ERROR_CODE = exports.UNKNOWN_ERROR_CODE = exports.CANCEL_ERROR_CODE = exports.TIMEOUT_ERROR_CODE = exports.INTERNAL_ERROR_CODE = void 0;
|
|
14
14
|
exports.ensureError = ensureError;
|
|
15
15
|
exports.logError = logError;
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
16
|
exports.INTERNAL_ERROR_CODE = 500;
|
|
18
17
|
exports.TIMEOUT_ERROR_CODE = 408;
|
|
19
18
|
exports.CANCEL_ERROR_CODE = 409;
|
|
@@ -106,4 +105,34 @@ class CancelledError extends TerminalError {
|
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
exports.CancelledError = CancelledError;
|
|
108
|
+
/**
|
|
109
|
+
* Error that Restate will retry. By using this error type within a `ctx.run` closure,
|
|
110
|
+
* you can dynamically provide the retry delay specified in {@link RetryableErrorOptions}.
|
|
111
|
+
*
|
|
112
|
+
* You can wrap another error using {@link from}.
|
|
113
|
+
*/
|
|
114
|
+
class RetryableError extends RestateError {
|
|
115
|
+
name = "RetryableError";
|
|
116
|
+
retryAfter;
|
|
117
|
+
constructor(message, options) {
|
|
118
|
+
super(message, {
|
|
119
|
+
errorCode: options?.errorCode,
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
121
|
+
cause: options?.cause,
|
|
122
|
+
});
|
|
123
|
+
this.retryAfter = options?.retryAfter;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a `RetryableError` from the given cause.
|
|
127
|
+
*/
|
|
128
|
+
static from(cause, options) {
|
|
129
|
+
const error = ensureError(cause);
|
|
130
|
+
return new RetryableError(error.message, {
|
|
131
|
+
errorCode: error["errorCode"],
|
|
132
|
+
cause: cause,
|
|
133
|
+
...options,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.RetryableError = RetryableError;
|
|
109
138
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/types/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../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,CAAC;IAE/B;QACE,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,yBAAiB,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAND,wCAMC;AASD;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,YAAY;IACvC,IAAI,GAAG,gBAAgB,CAAC;IAEtB,UAAU,CAAqB;IAExC,YACE,OAAe,EACf,OAGC;QAED,KAAK,CAAC,OAAO,EAAE;YACb,SAAS,EAAE,OAAO,EAAE,SAAS;YAC7B,mEAAmE;YACnE,KAAK,EAAE,OAAO,EAAE,KAAK;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,KAAU,EAAE,OAA+B;QACrD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE;YACvC,SAAS,EAAE,KAAK,CAAC,WAAiC,CAAW;YAC7D,KAAK,EAAE,KAAK;YACZ,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AA/BD,wCA+BC"}
|
|
@@ -398,13 +398,13 @@ export type ServiceOptions = {
|
|
|
398
398
|
* @example Here is an example of how to define a service:
|
|
399
399
|
*
|
|
400
400
|
* ```ts
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
401
|
+
* const greeter = service({
|
|
402
|
+
* name: "greeter",
|
|
403
|
+
* handlers: {
|
|
404
|
+
* greet: async (ctx: Context, name: string) => {
|
|
405
|
+
* return `Hello ${name}`;
|
|
406
|
+
* }
|
|
407
|
+
* }
|
|
408
408
|
* });
|
|
409
409
|
* ```
|
|
410
410
|
*
|
|
@@ -425,11 +425,11 @@ export type ServiceOptions = {
|
|
|
425
425
|
*
|
|
426
426
|
* @example Alternatively to avoid repeating the service name, you can:
|
|
427
427
|
* ```
|
|
428
|
-
*
|
|
429
|
-
*
|
|
428
|
+
* import type {Greeter} from "./greeter";
|
|
429
|
+
* const Greeter: Greeter = { name : "greeter"};
|
|
430
430
|
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
431
|
+
* // now you can reference the service like this:
|
|
432
|
+
* const client = ctx.serviceClient(Greeter);
|
|
433
433
|
* ```
|
|
434
434
|
*
|
|
435
435
|
* @param name the service name
|
|
@@ -553,14 +553,14 @@ export type WorkflowOptions = ServiceOptions & {
|
|
|
553
553
|
*
|
|
554
554
|
* @example Here is an example of how to define a workflow:
|
|
555
555
|
* ```ts
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
556
|
+
* const mywf = workflow({
|
|
557
|
+
* name: "mywf",
|
|
558
|
+
* handlers: {
|
|
559
|
+
* run: async (ctx: WorkflowContext, argument: any) => {
|
|
560
|
+
* return "Hello World";
|
|
561
|
+
* }
|
|
562
|
+
* }
|
|
563
|
+
* });
|
|
564
564
|
* ```
|
|
565
565
|
*
|
|
566
566
|
* ### Note:
|