@restatedev/restate-sdk-cloudflare-workers 1.6.0 → 1.7.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/dist/esm/src/common_api.d.ts +7 -3
- package/dist/esm/src/common_api.d.ts.map +1 -1
- package/dist/esm/src/common_api.js +5 -1
- package/dist/esm/src/common_api.js.map +1 -1
- package/dist/esm/src/context.d.ts +32 -32
- 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 +8 -6
- package/dist/esm/src/context_impl.d.ts.map +1 -1
- package/dist/esm/src/context_impl.js +161 -80
- package/dist/esm/src/context_impl.js.map +1 -1
- package/dist/esm/src/endpoint/endpoint_builder.d.ts.map +1 -1
- package/dist/esm/src/endpoint/endpoint_builder.js +3 -3
- package/dist/esm/src/endpoint/endpoint_builder.js.map +1 -1
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts +1 -1
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/fetch_endpoint.js +1 -4
- package/dist/esm/src/endpoint/fetch_endpoint.js.map +1 -1
- package/dist/esm/src/endpoint/handlers/generic.d.ts.map +1 -1
- package/dist/esm/src/endpoint/handlers/generic.js +168 -118
- 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 +26 -2
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.js +66 -4
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm +0 -0
- package/dist/esm/src/endpoint/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm.d.ts +5 -2
- package/dist/esm/src/endpoint/lambda_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/lambda_endpoint.js +1 -2
- package/dist/esm/src/endpoint/lambda_endpoint.js.map +1 -1
- package/dist/esm/src/endpoint/node_endpoint.d.ts.map +1 -1
- package/dist/esm/src/endpoint/node_endpoint.js +12 -6
- package/dist/esm/src/endpoint/node_endpoint.js.map +1 -1
- package/dist/esm/src/fetch.d.ts.map +1 -1
- 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/promises.d.ts +2 -1
- package/dist/esm/src/promises.d.ts.map +1 -1
- package/dist/esm/src/promises.js +8 -8
- package/dist/esm/src/promises.js.map +1 -1
- package/dist/esm/src/types/components.d.ts +8 -5
- package/dist/esm/src/types/components.d.ts.map +1 -1
- package/dist/esm/src/types/components.js +70 -30
- package/dist/esm/src/types/components.js.map +1 -1
- package/dist/esm/src/types/discovery.d.ts +128 -36
- package/dist/esm/src/types/discovery.d.ts.map +1 -1
- package/dist/esm/src/types/discovery.js +6 -26
- package/dist/esm/src/types/discovery.js.map +1 -1
- package/dist/esm/src/types/errors.d.ts +2 -0
- package/dist/esm/src/types/errors.d.ts.map +1 -1
- package/dist/esm/src/types/errors.js +17 -0
- package/dist/esm/src/types/errors.js.map +1 -1
- package/dist/esm/src/types/rpc.d.ts +173 -56
- package/dist/esm/src/types/rpc.d.ts.map +1 -1
- package/dist/esm/src/types/rpc.js +19 -2
- package/dist/esm/src/types/rpc.js.map +1 -1
- package/dist/esm/src/user_agent.d.ts +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,46 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
+
*/
|
|
6
|
+
export type ProtocolMode = "BIDI_STREAM" | "REQUEST_RESPONSE";
|
|
7
|
+
export type ServiceType = "VIRTUAL_OBJECT" | "SERVICE" | "WORKFLOW";
|
|
8
|
+
/**
|
|
9
|
+
* If unspecified, defaults to EXCLUSIVE for Virtual Object or WORKFLOW for Workflows. This should be unset for Services.
|
|
10
|
+
*/
|
|
11
|
+
export type HandlerType = "WORKFLOW" | "EXCLUSIVE" | "SHARED";
|
|
12
|
+
/**
|
|
13
|
+
* Restate endpoint manifest v3
|
|
14
|
+
*/
|
|
15
|
+
export interface Endpoint {
|
|
16
|
+
protocolMode?: ProtocolMode;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum supported protocol version
|
|
19
|
+
*/
|
|
20
|
+
minProtocolVersion: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum supported protocol version
|
|
23
|
+
*/
|
|
24
|
+
maxProtocolVersion: number;
|
|
25
|
+
services: Service[];
|
|
9
26
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
export interface Service {
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Documentation for this service definition. No format is enforced, but generally Markdown is assumed.
|
|
31
|
+
*/
|
|
32
|
+
documentation?: string;
|
|
33
|
+
ty: ServiceType;
|
|
34
|
+
handlers: Handler[];
|
|
35
|
+
/**
|
|
36
|
+
* Inactivity timeout duration, expressed in milliseconds.
|
|
37
|
+
*/
|
|
38
|
+
inactivityTimeout?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Abort timeout duration, expressed in milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
abortTimeout?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Journal retention duration, expressed in milliseconds.
|
|
45
|
+
*/
|
|
46
|
+
journalRetention?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Idempotency retention duration, expressed in milliseconds. When ServiceType == WORKFLOW, this option will be applied only to the shared handlers. See workflowCompletionRetention for more details.
|
|
49
|
+
*/
|
|
50
|
+
idempotencyRetention?: number;
|
|
51
|
+
/**
|
|
52
|
+
* If true, lazy state is enabled.
|
|
53
|
+
*/
|
|
54
|
+
enableLazyState?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If true, the service cannot be invoked from the HTTP nor Kafka ingress.
|
|
57
|
+
*/
|
|
58
|
+
ingressPrivate?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Custom metadata of this service definition. This metadata is shown on the Admin API when querying the service definition.
|
|
61
|
+
*/
|
|
62
|
+
metadata?: {
|
|
63
|
+
[k: string]: string;
|
|
64
|
+
};
|
|
14
65
|
}
|
|
15
|
-
export type InputPayload = {
|
|
16
|
-
required?: boolean;
|
|
17
|
-
contentType?: string;
|
|
18
|
-
jsonSchema?: any;
|
|
19
|
-
};
|
|
20
|
-
export type OutputPayload = {
|
|
21
|
-
contentType?: string;
|
|
22
|
-
setContentTypeIfEmpty: boolean;
|
|
23
|
-
jsonSchema?: any;
|
|
24
|
-
};
|
|
25
66
|
export interface Handler {
|
|
26
67
|
name: string;
|
|
27
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Documentation for this handler definition. No format is enforced, but generally Markdown is assumed.
|
|
70
|
+
*/
|
|
71
|
+
documentation?: string;
|
|
72
|
+
ty?: HandlerType;
|
|
28
73
|
input?: InputPayload;
|
|
29
74
|
output?: OutputPayload;
|
|
30
|
-
|
|
31
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Inactivity timeout duration, expressed in milliseconds.
|
|
77
|
+
*/
|
|
78
|
+
inactivityTimeout?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Abort timeout duration, expressed in milliseconds.
|
|
81
|
+
*/
|
|
82
|
+
abortTimeout?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Journal retention duration, expressed in milliseconds.
|
|
85
|
+
*/
|
|
86
|
+
journalRetention?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Idempotency retention duration, expressed in milliseconds. This is NOT VALID when HandlerType == WORKFLOW
|
|
89
|
+
*/
|
|
90
|
+
idempotencyRetention?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Workflow completion retention duration, expressed in milliseconds. This is valid ONLY when HandlerType == WORKFLOW
|
|
93
|
+
*/
|
|
94
|
+
workflowCompletionRetention?: number;
|
|
95
|
+
/**
|
|
96
|
+
* If true, lazy state is enabled.
|
|
97
|
+
*/
|
|
98
|
+
enableLazyState?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If true, the service cannot be invoked from the HTTP nor Kafka ingress.
|
|
101
|
+
*/
|
|
102
|
+
ingressPrivate?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Custom metadata of this handler definition. This metadata is shown on the Admin API when querying the service/handler definition.
|
|
105
|
+
*/
|
|
106
|
+
metadata?: {
|
|
107
|
+
[k: string]: string;
|
|
108
|
+
};
|
|
32
109
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Description of an input payload. This will be used by Restate to validate incoming requests.
|
|
112
|
+
*/
|
|
113
|
+
export interface InputPayload {
|
|
114
|
+
/**
|
|
115
|
+
* If true, a body MUST be sent with a content-type, even if the body length is zero.
|
|
116
|
+
*/
|
|
117
|
+
required?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Content type of the input. It can accept wildcards, in the same format as the 'Accept' header. When this field is unset, it implies emptiness, meaning no content-type/body is expected.
|
|
120
|
+
*/
|
|
121
|
+
contentType?: string;
|
|
122
|
+
jsonSchema?: unknown;
|
|
39
123
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Description of an output payload.
|
|
126
|
+
*/
|
|
127
|
+
export interface OutputPayload {
|
|
128
|
+
/**
|
|
129
|
+
* Content type set on output. This will be used by Restate to set the output content type at the ingress.
|
|
130
|
+
*/
|
|
131
|
+
contentType?: string;
|
|
132
|
+
/**
|
|
133
|
+
* If true, the specified content-type is set even if the output is empty.
|
|
134
|
+
*/
|
|
135
|
+
setContentTypeIfEmpty?: boolean;
|
|
136
|
+
jsonSchema?: unknown;
|
|
45
137
|
}
|
|
46
138
|
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../../src/types/discovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../../src/types/discovery.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,GAAG,UAAU,CAAC;AACpE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AACD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,WAAW,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAA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
6
|
-
*
|
|
7
|
-
* You can find a copy of the license in file LICENSE in the root
|
|
8
|
-
* directory of this repository or package, or at
|
|
9
|
-
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
10
6
|
*/
|
|
11
|
-
export
|
|
12
|
-
(function (ProtocolMode) {
|
|
13
|
-
ProtocolMode["BIDI_STREAM"] = "BIDI_STREAM";
|
|
14
|
-
ProtocolMode["REQUEST_RESPONSE"] = "REQUEST_RESPONSE";
|
|
15
|
-
})(ProtocolMode || (ProtocolMode = {}));
|
|
16
|
-
export var ServiceType;
|
|
17
|
-
(function (ServiceType) {
|
|
18
|
-
ServiceType["VIRTUAL_OBJECT"] = "VIRTUAL_OBJECT";
|
|
19
|
-
ServiceType["SERVICE"] = "SERVICE";
|
|
20
|
-
ServiceType["WORKFLOW"] = "WORKFLOW";
|
|
21
|
-
})(ServiceType || (ServiceType = {}));
|
|
22
|
-
export var ServiceHandlerType;
|
|
23
|
-
(function (ServiceHandlerType) {
|
|
24
|
-
ServiceHandlerType["WORKFLOW"] = "WORKFLOW";
|
|
25
|
-
ServiceHandlerType["EXCLUSIVE"] = "EXCLUSIVE";
|
|
26
|
-
ServiceHandlerType["SHARED"] = "SHARED";
|
|
27
|
-
})(ServiceHandlerType || (ServiceHandlerType = {}));
|
|
7
|
+
export {};
|
|
28
8
|
//# sourceMappingURL=discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../../src/types/discovery.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../../src/types/discovery.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;GAIG"}
|
|
@@ -2,8 +2,10 @@ export declare const INTERNAL_ERROR_CODE = 500;
|
|
|
2
2
|
export declare const TIMEOUT_ERROR_CODE = 408;
|
|
3
3
|
export declare const CANCEL_ERROR_CODE = 409;
|
|
4
4
|
export declare const UNKNOWN_ERROR_CODE = 500;
|
|
5
|
+
export declare const CLOSED_ERROR_CODE = 598;
|
|
5
6
|
export declare const SUSPENDED_ERROR_CODE = 599;
|
|
6
7
|
export declare function ensureError(e: unknown): Error;
|
|
8
|
+
export declare function logError(log: Console, e: unknown): void;
|
|
7
9
|
export declare class RestateError extends Error {
|
|
8
10
|
readonly code: number;
|
|
9
11
|
name: string;
|
|
@@ -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,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAmB7C;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;AAID,qBAAa,aAAc,SAAQ,YAAY;IACtC,IAAI,SAAmB;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE;CAG3E;AAED,qBAAa,YAAa,SAAQ,aAAa;IACtC,IAAI,SAAkB;;CAK9B;AAED,qBAAa,cAAe,SAAQ,aAAa;IACxC,IAAI,SAAoB;;CAKhC"}
|
|
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,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAmB7C;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;AAID,qBAAa,aAAc,SAAQ,YAAY;IACtC,IAAI,SAAmB;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE;CAG3E;AAED,qBAAa,YAAa,SAAQ,aAAa;IACtC,IAAI,SAAkB;;CAK9B;AAED,qBAAa,cAAe,SAAQ,aAAa;IACxC,IAAI,SAAoB;;CAKhC"}
|
|
@@ -14,6 +14,7 @@ export const TIMEOUT_ERROR_CODE = 408;
|
|
|
14
14
|
export const CANCEL_ERROR_CODE = 409;
|
|
15
15
|
export const UNKNOWN_ERROR_CODE = 500;
|
|
16
16
|
// From shared core!
|
|
17
|
+
export const CLOSED_ERROR_CODE = 598;
|
|
17
18
|
export const SUSPENDED_ERROR_CODE = 599;
|
|
18
19
|
export function ensureError(e) {
|
|
19
20
|
if (e instanceof Error) {
|
|
@@ -34,6 +35,22 @@ export function ensureError(e) {
|
|
|
34
35
|
}
|
|
35
36
|
return new Error("Non-Error value: " + msg);
|
|
36
37
|
}
|
|
38
|
+
export function logError(log, e) {
|
|
39
|
+
if (e instanceof RestateError) {
|
|
40
|
+
if (e.code === SUSPENDED_ERROR_CODE) {
|
|
41
|
+
log.info("Invocation suspended");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
else if (e.code === CLOSED_ERROR_CODE) {
|
|
45
|
+
log.error("DANGER! The invocation is closed, but some related operation is still running. \n" +
|
|
46
|
+
"This might indicate that a RestatePromise is being awaited on an asynchronous task, outside the handler, or you're awaiting a RestatePromise inside a ctx.run.\n" +
|
|
47
|
+
"This is dangerous, and can lead the service to deadlock. Please fix the issue.\n" +
|
|
48
|
+
"Diagnostic: ", e);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
log.warn("Error when processing a Restate context operation.\n", e);
|
|
53
|
+
}
|
|
37
54
|
export class RestateError extends Error {
|
|
38
55
|
code;
|
|
39
56
|
name = "RestateError";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uDAAuD;AAEvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,oBAAoB;AACpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,CA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W,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context, GenericCall, GenericSend, InvocationHandle, InvocationPromise, ObjectContext, ObjectSharedContext, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "../context.js";
|
|
2
|
-
import { type ServiceHandler, type ServiceDefinition, type ObjectHandler, type VirtualObjectDefinition, type WorkflowHandler, type WorkflowDefinition, type WorkflowSharedHandler, type Serde } from "@restatedev/restate-sdk-core";
|
|
2
|
+
import { type ServiceHandler, type ServiceDefinition, type ObjectHandler, type VirtualObjectDefinition, type WorkflowHandler, type WorkflowDefinition, type WorkflowSharedHandler, type Serde, type Duration } from "@restatedev/restate-sdk-core";
|
|
3
3
|
export type ClientCallOptions<I, O> = {
|
|
4
4
|
input?: Serde<I>;
|
|
5
5
|
output?: Serde<O>;
|
|
@@ -19,7 +19,32 @@ export declare class Opts<I, O> {
|
|
|
19
19
|
}
|
|
20
20
|
export type ClientSendOptions<I> = {
|
|
21
21
|
input?: Serde<I>;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Makes a type-safe one-way RPC to the specified target service, after a delay specified by the
|
|
24
|
+
* milliseconds' argument.
|
|
25
|
+
* This method is like setting up a fault-tolerant cron job that enqueues the message in a
|
|
26
|
+
* message queue.
|
|
27
|
+
* The handler calling this function does not have to stay active for the delay time.
|
|
28
|
+
*
|
|
29
|
+
* Both the delay timer and the message are durably stored in Restate and guaranteed to be reliably
|
|
30
|
+
* delivered. The delivery happens no earlier than specified through the delay, but may happen
|
|
31
|
+
* later, if the target service is down, or backpressuring the system.
|
|
32
|
+
*
|
|
33
|
+
* The delay message is journaled for durable execution and will thus not be duplicated when the
|
|
34
|
+
* handler is re-invoked for retries or after suspending.
|
|
35
|
+
*
|
|
36
|
+
* This call will return immediately; the message sending happens asynchronously in the background.
|
|
37
|
+
* Despite that, the message is guaranteed to be sent, because the completion of the invocation that
|
|
38
|
+
* triggers the send (calls this function) happens logically after the sending. That means that any
|
|
39
|
+
* failure where the message does not reach Restate also cannot complete this invocation, and will
|
|
40
|
+
* hence recover this handler and (through the durable execution) recover the message to be sent.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* ctx.serviceSendClient(Service).anotherAction(1337, { delay: { seconds: 60 } });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
delay?: Duration | number;
|
|
23
48
|
headers?: Record<string, string>;
|
|
24
49
|
idempotencyKey?: string;
|
|
25
50
|
};
|
|
@@ -51,8 +76,10 @@ export declare enum HandlerKind {
|
|
|
51
76
|
}
|
|
52
77
|
export type ServiceHandlerOpts<I, O> = {
|
|
53
78
|
/**
|
|
54
|
-
* Define the acceptable content-type
|
|
55
|
-
*
|
|
79
|
+
* Define the acceptable content-type for this handler when a request is received at the ingress.
|
|
80
|
+
* Wildcards can be used, e.g. `application/*` or `* / *`.
|
|
81
|
+
*
|
|
82
|
+
* If not provided, the `input.contentType` will be used instead as default.
|
|
56
83
|
*
|
|
57
84
|
* Setting this value has no effect on the input serde.
|
|
58
85
|
* If you want to customize how to deserialize the input, you still need to provide an `input` serde.
|
|
@@ -84,78 +111,75 @@ export type ServiceHandlerOpts<I, O> = {
|
|
|
84
111
|
* Additional metadata for the handler.
|
|
85
112
|
*/
|
|
86
113
|
metadata?: Record<string, string>;
|
|
87
|
-
};
|
|
88
|
-
export type ObjectHandlerOpts<I, O> = {
|
|
89
114
|
/**
|
|
90
|
-
*
|
|
91
|
-
* If not provided, the `input.contentType` will be used instead.
|
|
115
|
+
* The retention duration of idempotent requests to this handler.
|
|
92
116
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
117
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
118
|
+
* otherwise the service discovery will fail.
|
|
95
119
|
*/
|
|
96
|
-
|
|
120
|
+
idempotencyRetention?: Duration | number;
|
|
97
121
|
/**
|
|
98
|
-
* The
|
|
99
|
-
* defaults to: restate.serde.json
|
|
122
|
+
* The journal retention for invocations to this handler.
|
|
100
123
|
*
|
|
101
|
-
*
|
|
102
|
-
* restate.serde.binary the skip serialization/deserialization altogether.
|
|
103
|
-
* in that case, the input parameter is a Uint8Array.
|
|
104
|
-
*/
|
|
105
|
-
input?: Serde<I>;
|
|
106
|
-
/**
|
|
107
|
-
* The Serde to use for serializing the output.
|
|
108
|
-
* defaults to: restate.serde.json
|
|
124
|
+
* In case the request has an idempotency key, the `idempotencyRetention` caps the journal retention time.
|
|
109
125
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* in that case, the output parameter is a Uint8Array.
|
|
126
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
127
|
+
* otherwise the service discovery will fail.
|
|
113
128
|
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* An additional description for the handler, for documentation purposes.
|
|
117
|
-
*/
|
|
118
|
-
description?: string;
|
|
119
|
-
/**
|
|
120
|
-
* Additional metadata for the handler.
|
|
121
|
-
*/
|
|
122
|
-
metadata?: Record<string, string>;
|
|
123
|
-
};
|
|
124
|
-
export type WorkflowHandlerOpts<I, O> = {
|
|
129
|
+
journalRetention?: Duration | number;
|
|
125
130
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
131
|
+
* This timer guards against stalled invocations. Once it expires, Restate triggers a graceful
|
|
132
|
+
* termination by asking the invocation to suspend (which preserves intermediate progress).
|
|
128
133
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
134
|
+
* The `abortTimeout` is used to abort the invocation, in case it doesn't react to the request to
|
|
135
|
+
* suspend.
|
|
136
|
+
*
|
|
137
|
+
* This overrides the inactivity timeout set for the service and the default set in restate-server.
|
|
138
|
+
*
|
|
139
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
140
|
+
* otherwise the service discovery will fail.
|
|
131
141
|
*/
|
|
132
|
-
|
|
142
|
+
inactivityTimeout?: Duration | number;
|
|
133
143
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
144
|
+
* This timer guards against stalled invocations that are supposed to terminate. The abort timeout
|
|
145
|
+
* is started after the [inactivityTimeout] has expired and the invocation has been asked to
|
|
146
|
+
* gracefully terminate. Once the timer expires, it will abort the invocation.
|
|
136
147
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
148
|
+
* This timer potentially *interrupts* user code. If the user code needs longer to gracefully
|
|
149
|
+
* terminate, then this value needs to be set accordingly.
|
|
150
|
+
*
|
|
151
|
+
* This overrides the abort timeout set for the service and the default set in restate-server.
|
|
152
|
+
*
|
|
153
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
154
|
+
* otherwise the service discovery will fail.
|
|
140
155
|
*/
|
|
141
|
-
|
|
156
|
+
abortTimeout?: Duration | number;
|
|
142
157
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
158
|
+
* When set to `true` this handler cannot be invoked from the restate-server HTTP and Kafka ingress,
|
|
159
|
+
* but only from other services.
|
|
145
160
|
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* in that case, the output parameter is a Uint8Array.
|
|
161
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
162
|
+
* otherwise the service discovery will fail.
|
|
149
163
|
*/
|
|
150
|
-
|
|
164
|
+
ingressPrivate?: boolean;
|
|
165
|
+
};
|
|
166
|
+
export type ObjectHandlerOpts<I, O> = ServiceHandlerOpts<I, O> & {
|
|
151
167
|
/**
|
|
152
|
-
*
|
|
168
|
+
* When set to `true`, lazy state will be enabled for all invocations to this handler.
|
|
169
|
+
*
|
|
170
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
171
|
+
* otherwise the service discovery will fail.
|
|
153
172
|
*/
|
|
154
|
-
|
|
173
|
+
enableLazyState?: boolean;
|
|
174
|
+
};
|
|
175
|
+
export type WorkflowHandlerOpts<I, O> = ServiceHandlerOpts<I, O> & {
|
|
155
176
|
/**
|
|
156
|
-
*
|
|
177
|
+
* When set to `true`, lazy state will be enabled for all invocations to this handler.
|
|
178
|
+
*
|
|
179
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
180
|
+
* otherwise the service discovery will fail.
|
|
157
181
|
*/
|
|
158
|
-
|
|
182
|
+
enableLazyState?: boolean;
|
|
159
183
|
};
|
|
160
184
|
export declare class HandlerWrapper {
|
|
161
185
|
readonly kind: HandlerKind;
|
|
@@ -164,6 +188,12 @@ export declare class HandlerWrapper {
|
|
|
164
188
|
readonly outputSerde: Serde<unknown>;
|
|
165
189
|
readonly description?: string | undefined;
|
|
166
190
|
readonly metadata?: Record<string, string> | undefined;
|
|
191
|
+
readonly idempotencyRetention?: (Duration | number) | undefined;
|
|
192
|
+
readonly journalRetention?: (Duration | number) | undefined;
|
|
193
|
+
readonly inactivityTimeout?: (Duration | number) | undefined;
|
|
194
|
+
readonly abortTimeout?: (Duration | number) | undefined;
|
|
195
|
+
readonly ingressPrivate?: boolean | undefined;
|
|
196
|
+
readonly enableLazyState?: boolean | undefined;
|
|
167
197
|
static from(kind: HandlerKind, handler: Function, opts?: ServiceHandlerOpts<unknown, unknown> | ObjectHandlerOpts<unknown, unknown> | WorkflowHandlerOpts<unknown, unknown>): HandlerWrapper;
|
|
168
198
|
static fromHandler(handler: any): HandlerWrapper | undefined;
|
|
169
199
|
readonly accept?: string;
|
|
@@ -265,6 +295,65 @@ export declare namespace handlers {
|
|
|
265
295
|
export type ServiceOpts<U> = {
|
|
266
296
|
[K in keyof U]: U[K] extends ServiceHandler<U[K], Context> ? U[K] : ServiceHandler<U[K], Context>;
|
|
267
297
|
};
|
|
298
|
+
export type ServiceOptions = {
|
|
299
|
+
/**
|
|
300
|
+
* The retention duration of idempotent requests to this service.
|
|
301
|
+
*
|
|
302
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
303
|
+
* otherwise the service discovery will fail.
|
|
304
|
+
*/
|
|
305
|
+
idempotencyRetention?: Duration | number;
|
|
306
|
+
/**
|
|
307
|
+
* The journal retention. When set, this applies to all requests to all handlers of this service.
|
|
308
|
+
*
|
|
309
|
+
* In case the request has an idempotency key, the `idempotencyRetention` caps the journal retention
|
|
310
|
+
* time.
|
|
311
|
+
*
|
|
312
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
313
|
+
* otherwise the service discovery will fail.
|
|
314
|
+
*
|
|
315
|
+
* @return this
|
|
316
|
+
*/
|
|
317
|
+
journalRetention?: Duration | number;
|
|
318
|
+
/**
|
|
319
|
+
* This timer guards against stalled invocations. Once it expires, Restate triggers a graceful
|
|
320
|
+
* termination by asking the invocation to suspend (which preserves intermediate progress).
|
|
321
|
+
*
|
|
322
|
+
* The `abortTimeout` is used to abort the invocation, in case it doesn't react to the request to
|
|
323
|
+
* suspend.
|
|
324
|
+
*
|
|
325
|
+
* This overrides the default inactivity timeout configured in the restate-server for all
|
|
326
|
+
* invocations to this service.
|
|
327
|
+
*
|
|
328
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
329
|
+
* otherwise the service discovery will fail.
|
|
330
|
+
*/
|
|
331
|
+
inactivityTimeout?: Duration | number;
|
|
332
|
+
/**
|
|
333
|
+
* This timer guards against stalled service/handler invocations that are supposed to terminate. The
|
|
334
|
+
* abort timeout is started after the `inactivityTimeout` has expired and the service/handler
|
|
335
|
+
* invocation has been asked to gracefully terminate. Once the timer expires, it will abort the
|
|
336
|
+
* service/handler invocation.
|
|
337
|
+
*
|
|
338
|
+
* This timer potentially *interrupts* user code. If the user code needs longer to gracefully
|
|
339
|
+
* terminate, then this value needs to be set accordingly.
|
|
340
|
+
*
|
|
341
|
+
* This overrides the default abort timeout configured in the restate-server for all invocations to
|
|
342
|
+
* this service.
|
|
343
|
+
*
|
|
344
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
345
|
+
* otherwise the service discovery will fail.
|
|
346
|
+
*/
|
|
347
|
+
abortTimeout?: Duration | number;
|
|
348
|
+
/**
|
|
349
|
+
* When set to `true` this service, with all its handlers, cannot be invoked from the restate-server
|
|
350
|
+
* HTTP and Kafka ingress, but only from other services.
|
|
351
|
+
*
|
|
352
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
353
|
+
* otherwise the service discovery will fail.
|
|
354
|
+
*/
|
|
355
|
+
ingressPrivate?: boolean;
|
|
356
|
+
};
|
|
268
357
|
/**
|
|
269
358
|
* Define a Restate service.
|
|
270
359
|
*
|
|
@@ -317,10 +406,20 @@ export declare const service: <P extends string, M>(service: {
|
|
|
317
406
|
handlers: ServiceOpts<M> & ThisType<M>;
|
|
318
407
|
description?: string;
|
|
319
408
|
metadata?: Record<string, string>;
|
|
409
|
+
options?: ServiceOptions;
|
|
320
410
|
}) => ServiceDefinition<P, M>;
|
|
321
411
|
export type ObjectOpts<U> = {
|
|
322
412
|
[K in keyof U]: U[K] extends ObjectHandler<U[K], ObjectContext<any>> ? U[K] : U[K] extends ObjectHandler<U[K], ObjectSharedContext<any>> ? U[K] : ObjectHandler<U[K], ObjectContext<any>> | ObjectHandler<U[K], ObjectSharedContext<any>>;
|
|
323
413
|
};
|
|
414
|
+
export type ObjectOptions = ServiceOptions & {
|
|
415
|
+
/**
|
|
416
|
+
* When set to `true`, lazy state will be enabled for all invocations to this service.
|
|
417
|
+
*
|
|
418
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
419
|
+
* otherwise the service discovery will fail.
|
|
420
|
+
*/
|
|
421
|
+
enableLazyState?: boolean;
|
|
422
|
+
};
|
|
324
423
|
/**
|
|
325
424
|
* Define a Restate virtual object.
|
|
326
425
|
*
|
|
@@ -380,6 +479,7 @@ export declare const object: <P extends string, M>(object: {
|
|
|
380
479
|
handlers: ObjectOpts<M> & ThisType<M>;
|
|
381
480
|
description?: string;
|
|
382
481
|
metadata?: Record<string, string>;
|
|
482
|
+
options?: ObjectOptions;
|
|
383
483
|
}) => VirtualObjectDefinition<P, M>;
|
|
384
484
|
/**
|
|
385
485
|
* A workflow handlers is a type that describes the handlers for a workflow.
|
|
@@ -393,6 +493,22 @@ export type WorkflowOpts<U> = {
|
|
|
393
493
|
} & {
|
|
394
494
|
[K in keyof U]: K extends "workflowSubmit" | "workflowAttach" | "workflowOutput" ? `${K} is a reserved keyword` : K extends "run" ? U[K] extends WorkflowHandler<U[K], WorkflowContext<any>> ? U[K] : "An handler named 'run' must take as a first argument a WorkflowContext, and must return a Promise" : U[K] extends WorkflowSharedHandler<U[K], WorkflowSharedContext<any>> ? U[K] : "An handler other then 'run' must accept as a first argument a WorkflowSharedContext";
|
|
395
495
|
};
|
|
496
|
+
export type WorkflowOptions = ServiceOptions & {
|
|
497
|
+
/**
|
|
498
|
+
* The retention duration for this workflow.
|
|
499
|
+
*
|
|
500
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
501
|
+
* otherwise the service discovery will fail.
|
|
502
|
+
*/
|
|
503
|
+
workflowRetention?: Duration | number;
|
|
504
|
+
/**
|
|
505
|
+
* When set to `true`, lazy state will be enabled for all invocations to this service.
|
|
506
|
+
*
|
|
507
|
+
* *NOTE:* You can set this field only if you register this endpoint against restate-server >= 1.4,
|
|
508
|
+
* otherwise the service discovery will fail.
|
|
509
|
+
*/
|
|
510
|
+
enableLazyState?: boolean;
|
|
511
|
+
};
|
|
396
512
|
/**
|
|
397
513
|
* Define a Restate workflow.
|
|
398
514
|
*
|
|
@@ -438,5 +554,6 @@ export declare const workflow: <P extends string, M>(workflow: {
|
|
|
438
554
|
handlers: WorkflowOpts<M> & ThisType<M>;
|
|
439
555
|
description?: string;
|
|
440
556
|
metadata?: Record<string, string>;
|
|
557
|
+
options?: WorkflowOptions;
|
|
441
558
|
}) => WorkflowDefinition<P, M>;
|
|
442
559
|
//# sourceMappingURL=rpc.d.ts.map
|