@restatedev/restate-sdk-cloudflare-workers 1.9.0 → 1.10.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/LICENSE +21 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/common_api.cjs +25 -0
- package/dist/common_api.d.cts +30 -0
- package/dist/common_api.d.cts.map +1 -0
- package/dist/common_api.d.ts +30 -0
- package/dist/common_api.d.ts.map +1 -0
- package/dist/common_api.js +19 -0
- package/dist/common_api.js.map +1 -0
- package/dist/context.cjs +29 -0
- package/dist/context.d.cts +699 -0
- package/dist/context.d.cts.map +1 -0
- package/dist/context.d.ts +699 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +29 -0
- package/dist/context.js.map +1 -0
- package/dist/context_impl.cjs +441 -0
- package/dist/context_impl.js +440 -0
- package/dist/context_impl.js.map +1 -0
- package/dist/endpoint/components.cjs +257 -0
- package/dist/endpoint/components.js +253 -0
- package/dist/endpoint/components.js.map +1 -0
- package/dist/endpoint/endpoint.cjs +117 -0
- package/dist/endpoint/endpoint.js +118 -0
- package/dist/endpoint/endpoint.js.map +1 -0
- package/dist/endpoint/fetch_endpoint.cjs +41 -0
- package/dist/endpoint/fetch_endpoint.d.cts +39 -0
- package/dist/endpoint/fetch_endpoint.d.cts.map +1 -0
- package/dist/endpoint/fetch_endpoint.d.ts +39 -0
- package/dist/endpoint/fetch_endpoint.d.ts.map +1 -0
- package/dist/endpoint/fetch_endpoint.js +42 -0
- package/dist/endpoint/fetch_endpoint.js.map +1 -0
- package/dist/endpoint/handlers/fetch.cjs +21 -0
- package/dist/endpoint/handlers/fetch.js +21 -0
- package/dist/endpoint/handlers/fetch.js.map +1 -0
- package/dist/endpoint/handlers/generic.cjs +328 -0
- package/dist/endpoint/handlers/generic.js +324 -0
- package/dist/endpoint/handlers/generic.js.map +1 -0
- package/dist/endpoint/handlers/lambda.cjs +93 -0
- package/dist/endpoint/handlers/lambda.js +89 -0
- package/dist/endpoint/handlers/lambda.js.map +1 -0
- package/dist/endpoint/lambda_endpoint.cjs +36 -0
- package/dist/endpoint/lambda_endpoint.d.cts +26 -0
- package/dist/endpoint/lambda_endpoint.d.cts.map +1 -0
- package/dist/endpoint/lambda_endpoint.d.ts +26 -0
- package/dist/endpoint/lambda_endpoint.d.ts.map +1 -0
- package/dist/endpoint/lambda_endpoint.js +37 -0
- package/dist/endpoint/lambda_endpoint.js.map +1 -0
- package/dist/endpoint/node_endpoint.cjs +101 -0
- package/dist/endpoint/node_endpoint.js +99 -0
- package/dist/endpoint/node_endpoint.js.map +1 -0
- package/dist/endpoint/types.d.cts +61 -0
- package/dist/endpoint/types.d.cts.map +1 -0
- package/dist/endpoint/types.d.ts +61 -0
- package/dist/endpoint/types.d.ts.map +1 -0
- package/dist/endpoint/withOptions.cjs +15 -0
- package/dist/endpoint/withOptions.js +15 -0
- package/dist/endpoint/withOptions.js.map +1 -0
- package/dist/endpoint.d.cts +112 -0
- package/dist/endpoint.d.cts.map +1 -0
- package/dist/endpoint.d.ts +112 -0
- package/dist/endpoint.d.ts.map +1 -0
- package/dist/fetch.cjs +83 -0
- package/dist/fetch.d.cts +52 -0
- package/dist/fetch.d.cts.map +1 -0
- package/dist/fetch.d.ts +52 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/{esm/src/fetch.js → fetch.js} +15 -18
- package/dist/fetch.js.map +1 -0
- package/dist/index.cjs +48 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/io.cjs +48 -0
- package/dist/io.js +48 -0
- package/dist/io.js.map +1 -0
- package/dist/lambda.cjs +74 -0
- package/dist/lambda.d.cts +32 -0
- package/dist/lambda.d.cts.map +1 -0
- package/dist/lambda.d.ts +32 -0
- package/dist/lambda.d.ts.map +1 -0
- package/dist/lambda.js +35 -0
- package/dist/lambda.js.map +1 -0
- package/dist/logging/console_logger_transport.cjs +54 -0
- package/dist/logging/console_logger_transport.js +54 -0
- package/dist/logging/console_logger_transport.js.map +1 -0
- package/dist/logging/logger.cjs +43 -0
- package/dist/logging/logger.js +44 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/logging/logger_transport.cjs +42 -0
- package/dist/logging/logger_transport.d.cts +57 -0
- package/dist/logging/logger_transport.d.cts.map +1 -0
- package/dist/logging/logger_transport.d.ts +57 -0
- package/dist/logging/logger_transport.d.ts.map +1 -0
- package/dist/logging/logger_transport.js +40 -0
- package/dist/logging/logger_transport.js.map +1 -0
- package/dist/node.cjs +90 -0
- package/dist/node.d.cts +51 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.ts +51 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +50 -0
- package/dist/node.js.map +1 -0
- package/dist/package.cjs +11 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/promises.cjs +234 -0
- package/dist/promises.js +226 -0
- package/dist/promises.js.map +1 -0
- package/dist/types/errors.cjs +110 -0
- package/dist/types/errors.d.cts +71 -0
- package/dist/types/errors.d.cts.map +1 -0
- package/dist/types/errors.d.ts +71 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +102 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/rpc.cjs +425 -0
- package/dist/types/rpc.d.cts +580 -0
- package/dist/types/rpc.d.cts.map +1 -0
- package/dist/types/rpc.d.ts +580 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/rpc.js +406 -0
- package/dist/types/rpc.js.map +1 -0
- package/dist/user_agent.cjs +7 -0
- package/dist/user_agent.js +8 -0
- package/dist/user_agent.js.map +1 -0
- package/dist/utils/completable_promise.cjs +22 -0
- package/dist/utils/completable_promise.js +22 -0
- package/dist/utils/completable_promise.js.map +1 -0
- package/dist/utils/rand.cjs +72 -0
- package/dist/utils/rand.js +71 -0
- package/dist/utils/rand.js.map +1 -0
- package/dist/utils/streams.cjs +14 -0
- package/dist/utils/streams.js +13 -0
- package/dist/utils/streams.js.map +1 -0
- package/package.json +30 -52
- package/dist/esm/src/common_api.d.ts +0 -37
- package/dist/esm/src/common_api.d.ts.map +0 -1
- package/dist/esm/src/common_api.js +0 -32
- package/dist/esm/src/common_api.js.map +0 -1
- package/dist/esm/src/context.d.ts +0 -695
- package/dist/esm/src/context.d.ts.map +0 -1
- package/dist/esm/src/context.js +0 -87
- package/dist/esm/src/context.js.map +0 -1
- package/dist/esm/src/context_impl.d.ts +0 -69
- package/dist/esm/src/context_impl.d.ts.map +0 -1
- package/dist/esm/src/context_impl.js +0 -592
- package/dist/esm/src/context_impl.js.map +0 -1
- package/dist/esm/src/endpoint/components.d.ts +0 -97
- package/dist/esm/src/endpoint/components.d.ts.map +0 -1
- package/dist/esm/src/endpoint/components.js +0 -343
- package/dist/esm/src/endpoint/components.js.map +0 -1
- package/dist/esm/src/endpoint/discovery.d.ts +0 -184
- package/dist/esm/src/endpoint/discovery.d.ts.map +0 -1
- package/dist/esm/src/endpoint/discovery.js +0 -8
- package/dist/esm/src/endpoint/discovery.js.map +0 -1
- package/dist/esm/src/endpoint/endpoint.d.ts +0 -39
- package/dist/esm/src/endpoint/endpoint.d.ts.map +0 -1
- package/dist/esm/src/endpoint/endpoint.js +0 -155
- package/dist/esm/src/endpoint/endpoint.js.map +0 -1
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts +0 -49
- package/dist/esm/src/endpoint/fetch_endpoint.d.ts.map +0 -1
- package/dist/esm/src/endpoint/fetch_endpoint.js +0 -49
- package/dist/esm/src/endpoint/fetch_endpoint.js.map +0 -1
- package/dist/esm/src/endpoint/handlers/fetch.d.ts +0 -5
- package/dist/esm/src/endpoint/handlers/fetch.d.ts.map +0 -1
- package/dist/esm/src/endpoint/handlers/fetch.js +0 -31
- package/dist/esm/src/endpoint/handlers/fetch.js.map +0 -1
- package/dist/esm/src/endpoint/handlers/generic.d.ts +0 -56
- package/dist/esm/src/endpoint/handlers/generic.d.ts.map +0 -1
- package/dist/esm/src/endpoint/handlers/generic.js +0 -447
- package/dist/esm/src/endpoint/handlers/generic.js.map +0 -1
- package/dist/esm/src/endpoint/handlers/lambda.d.ts +0 -10
- package/dist/esm/src/endpoint/handlers/lambda.d.ts.map +0 -1
- package/dist/esm/src/endpoint/handlers/lambda.js +0 -142
- package/dist/esm/src/endpoint/handlers/lambda.js.map +0 -1
- package/dist/esm/src/endpoint/lambda_endpoint.d.ts +0 -30
- package/dist/esm/src/endpoint/lambda_endpoint.d.ts.map +0 -1
- package/dist/esm/src/endpoint/lambda_endpoint.js +0 -48
- package/dist/esm/src/endpoint/lambda_endpoint.js.map +0 -1
- package/dist/esm/src/endpoint/node_endpoint.d.ts +0 -16
- package/dist/esm/src/endpoint/node_endpoint.d.ts.map +0 -1
- package/dist/esm/src/endpoint/node_endpoint.js +0 -111
- package/dist/esm/src/endpoint/node_endpoint.js.map +0 -1
- package/dist/esm/src/endpoint/types.d.ts +0 -55
- package/dist/esm/src/endpoint/types.d.ts.map +0 -1
- package/dist/esm/src/endpoint/types.js +0 -2
- package/dist/esm/src/endpoint/types.js.map +0 -1
- package/dist/esm/src/endpoint/withOptions.d.ts +0 -4
- package/dist/esm/src/endpoint/withOptions.d.ts.map +0 -1
- package/dist/esm/src/endpoint/withOptions.js +0 -19
- package/dist/esm/src/endpoint/withOptions.js.map +0 -1
- package/dist/esm/src/endpoint.d.ts +0 -108
- package/dist/esm/src/endpoint.d.ts.map +0 -1
- package/dist/esm/src/endpoint.js +0 -12
- package/dist/esm/src/endpoint.js.map +0 -1
- package/dist/esm/src/fetch.d.ts +0 -43
- package/dist/esm/src/fetch.d.ts.map +0 -1
- package/dist/esm/src/fetch.js.map +0 -1
- package/dist/esm/src/generated/version.d.ts +0 -2
- package/dist/esm/src/generated/version.d.ts.map +0 -1
- package/dist/esm/src/generated/version.js +0 -2
- package/dist/esm/src/generated/version.js.map +0 -1
- package/dist/esm/src/io.d.ts +0 -24
- package/dist/esm/src/io.d.ts.map +0 -1
- package/dist/esm/src/io.js +0 -73
- package/dist/esm/src/io.js.map +0 -1
- package/dist/esm/src/lambda.d.ts +0 -23
- package/dist/esm/src/lambda.d.ts.map +0 -1
- package/dist/esm/src/lambda.js +0 -37
- package/dist/esm/src/lambda.js.map +0 -1
- package/dist/esm/src/logging/console_logger_transport.d.ts +0 -5
- package/dist/esm/src/logging/console_logger_transport.d.ts.map +0 -1
- package/dist/esm/src/logging/console_logger_transport.js +0 -94
- package/dist/esm/src/logging/console_logger_transport.js.map +0 -1
- package/dist/esm/src/logging/logger.d.ts +0 -10
- package/dist/esm/src/logging/logger.d.ts.map +0 -1
- package/dist/esm/src/logging/logger.js +0 -57
- package/dist/esm/src/logging/logger.js.map +0 -1
- package/dist/esm/src/logging/logger_transport.d.ts +0 -52
- package/dist/esm/src/logging/logger_transport.d.ts.map +0 -1
- package/dist/esm/src/logging/logger_transport.js +0 -55
- package/dist/esm/src/logging/logger_transport.js.map +0 -1
- package/dist/esm/src/node.d.ts +0 -39
- package/dist/esm/src/node.d.ts.map +0 -1
- package/dist/esm/src/node.js +0 -52
- package/dist/esm/src/node.js.map +0 -1
- package/dist/esm/src/promises.d.ts +0 -111
- package/dist/esm/src/promises.d.ts.map +0 -1
- package/dist/esm/src/promises.js +0 -314
- package/dist/esm/src/promises.js.map +0 -1
- package/dist/esm/src/public_api.d.ts +0 -2
- package/dist/esm/src/public_api.d.ts.map +0 -1
- package/dist/esm/src/public_api.js +0 -12
- package/dist/esm/src/public_api.js.map +0 -1
- package/dist/esm/src/types/errors.d.ts +0 -74
- package/dist/esm/src/types/errors.d.ts.map +0 -1
- package/dist/esm/src/types/errors.js +0 -128
- package/dist/esm/src/types/errors.js.map +0 -1
- package/dist/esm/src/types/rpc.d.ts +0 -620
- package/dist/esm/src/types/rpc.d.ts.map +0 -1
- package/dist/esm/src/types/rpc.js +0 -577
- package/dist/esm/src/types/rpc.js.map +0 -1
- package/dist/esm/src/user_agent.d.ts +0 -2
- package/dist/esm/src/user_agent.d.ts.map +0 -1
- package/dist/esm/src/user_agent.js +0 -13
- package/dist/esm/src/user_agent.js.map +0 -1
- package/dist/esm/src/utils/completable_promise.d.ts +0 -9
- package/dist/esm/src/utils/completable_promise.d.ts.map +0 -1
- package/dist/esm/src/utils/completable_promise.js +0 -30
- package/dist/esm/src/utils/completable_promise.js.map +0 -1
- package/dist/esm/src/utils/rand.d.ts +0 -13
- package/dist/esm/src/utils/rand.d.ts.map +0 -1
- package/dist/esm/src/utils/rand.js +0 -109
- package/dist/esm/src/utils/rand.js.map +0 -1
- package/dist/esm/src/utils/streams.d.ts +0 -3
- package/dist/esm/src/utils/streams.d.ts.map +0 -1
- package/dist/esm/src/utils/streams.js +0 -20
- package/dist/esm/src/utils/streams.js.map +0 -1
- package/dist/esm/tsconfig.tsbuildinfo +0 -1
- /package/dist/{esm/src/endpoint → endpoint}/handlers/vm/sdk_shared_core_wasm_bindings.d.ts +0 -0
- /package/dist/{esm/src/endpoint → endpoint}/handlers/vm/sdk_shared_core_wasm_bindings.js +0 -0
- /package/dist/{esm/src/endpoint → endpoint}/handlers/vm/sdk_shared_core_wasm_bindings_bg.js +0 -0
- /package/dist/{esm/src/endpoint → endpoint}/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm +0 -0
- /package/dist/{esm/src/endpoint → endpoint}/handlers/vm/sdk_shared_core_wasm_bindings_bg.wasm.d.ts +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LoggerTransport } from "../logging/logger_transport.cjs";
|
|
2
|
+
import { DefaultServiceOptions } from "../endpoint.cjs";
|
|
3
|
+
import { JournalValueCodec, ServiceDefinition, VirtualObjectDefinition, WorkflowDefinition } from "../common_api.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/endpoint/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating an endpoint handler for Node.js HTTP/2 servers.
|
|
8
|
+
*/
|
|
9
|
+
interface EndpointOptions {
|
|
10
|
+
/**
|
|
11
|
+
* A list of Restate services, virtual objects, or workflows that will be exposed via the endpoint.
|
|
12
|
+
*/
|
|
13
|
+
services: Array<ServiceDefinition<string, unknown> | VirtualObjectDefinition<string, unknown> | WorkflowDefinition<string, unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* Provide a list of v1 request identity public keys eg `publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9` to validate
|
|
16
|
+
* incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is
|
|
17
|
+
* logged by the Restate process at startup if a request identity private key is provided.
|
|
18
|
+
*
|
|
19
|
+
* If this function is called, all incoming requests irrelevant of endpoint type will be expected to have
|
|
20
|
+
* `x-restate-signature-scheme: v1` and `x-restate-jwt-v1: <valid jwt signed with one of these keys>`. If not called,
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
identityKeys?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Default service options that will be used by all services bind to this endpoint.
|
|
26
|
+
*
|
|
27
|
+
* Options can be overridden on each service/handler.
|
|
28
|
+
*/
|
|
29
|
+
defaultServiceOptions?: DefaultServiceOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Replace the default console-based {@link LoggerTransport}
|
|
32
|
+
* @example
|
|
33
|
+
* Using console:
|
|
34
|
+
* ```ts
|
|
35
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)}})
|
|
36
|
+
* ```
|
|
37
|
+
* @example
|
|
38
|
+
* Using winston:
|
|
39
|
+
* ```ts
|
|
40
|
+
* const logger = createLogger({ ... })
|
|
41
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))} })
|
|
42
|
+
* ```
|
|
43
|
+
* @example
|
|
44
|
+
* Using pino:
|
|
45
|
+
* ```ts
|
|
46
|
+
* const logger = pino()
|
|
47
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))}} )
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
logger?: LoggerTransport;
|
|
51
|
+
/**
|
|
52
|
+
* Provider for the codec to use for journal values. One codec will be instantiated globally for this endpoint.
|
|
53
|
+
* Check {@link JournalValueCodec} for more details
|
|
54
|
+
*
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
journalValueCodecProvider?: () => Promise<JournalValueCodec>;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { EndpointOptions };
|
|
61
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/endpoint/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,eAAA;EAAA;;;EAOX,QAAA,EAHM,KAGN,CAFA,iBAEA,CAAA,MAAA,EAAA,OAAA,CAAA,GADA,uBACA,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,kBAAA,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAHM;;;;;;;;;;;;;;;0BAoBc;;;;;;;;;;;;;;;;;;;;;WAqBf;;;;;;;oCAQyB,QAAQ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LoggerTransport } from "../logging/logger_transport.js";
|
|
2
|
+
import { DefaultServiceOptions } from "../endpoint.js";
|
|
3
|
+
import { JournalValueCodec, ServiceDefinition, VirtualObjectDefinition, WorkflowDefinition } from "../common_api.js";
|
|
4
|
+
|
|
5
|
+
//#region src/endpoint/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating an endpoint handler for Node.js HTTP/2 servers.
|
|
8
|
+
*/
|
|
9
|
+
interface EndpointOptions {
|
|
10
|
+
/**
|
|
11
|
+
* A list of Restate services, virtual objects, or workflows that will be exposed via the endpoint.
|
|
12
|
+
*/
|
|
13
|
+
services: Array<ServiceDefinition<string, unknown> | VirtualObjectDefinition<string, unknown> | WorkflowDefinition<string, unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* Provide a list of v1 request identity public keys eg `publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9` to validate
|
|
16
|
+
* incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is
|
|
17
|
+
* logged by the Restate process at startup if a request identity private key is provided.
|
|
18
|
+
*
|
|
19
|
+
* If this function is called, all incoming requests irrelevant of endpoint type will be expected to have
|
|
20
|
+
* `x-restate-signature-scheme: v1` and `x-restate-jwt-v1: <valid jwt signed with one of these keys>`. If not called,
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
identityKeys?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Default service options that will be used by all services bind to this endpoint.
|
|
26
|
+
*
|
|
27
|
+
* Options can be overridden on each service/handler.
|
|
28
|
+
*/
|
|
29
|
+
defaultServiceOptions?: DefaultServiceOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Replace the default console-based {@link LoggerTransport}
|
|
32
|
+
* @example
|
|
33
|
+
* Using console:
|
|
34
|
+
* ```ts
|
|
35
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)}})
|
|
36
|
+
* ```
|
|
37
|
+
* @example
|
|
38
|
+
* Using winston:
|
|
39
|
+
* ```ts
|
|
40
|
+
* const logger = createLogger({ ... })
|
|
41
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))} })
|
|
42
|
+
* ```
|
|
43
|
+
* @example
|
|
44
|
+
* Using pino:
|
|
45
|
+
* ```ts
|
|
46
|
+
* const logger = pino()
|
|
47
|
+
* createEndpointHandler({ logger: (meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))}} )
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
logger?: LoggerTransport;
|
|
51
|
+
/**
|
|
52
|
+
* Provider for the codec to use for journal values. One codec will be instantiated globally for this endpoint.
|
|
53
|
+
* Check {@link JournalValueCodec} for more details
|
|
54
|
+
*
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
journalValueCodecProvider?: () => Promise<JournalValueCodec>;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { EndpointOptions };
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/endpoint/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,eAAA;EAAA;;;EAOX,QAAA,EAHM,KAGN,CAFA,iBAEA,CAAA,MAAA,EAAA,OAAA,CAAA,GADA,uBACA,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,kBAAA,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAHM;;;;;;;;;;;;;;;0BAoBc;;;;;;;;;;;;;;;;;;;;;WAqBf;;;;;;;oCAQyB,QAAQ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/endpoint/withOptions.ts
|
|
3
|
+
function withOptions(endpoint, { identityKeys, defaultServiceOptions, logger, services, journalValueCodecProvider }) {
|
|
4
|
+
let endpointWithOptions = endpoint;
|
|
5
|
+
if (identityKeys && identityKeys.length > 0) endpointWithOptions = endpointWithOptions.withIdentityV1(...identityKeys);
|
|
6
|
+
if (defaultServiceOptions) endpointWithOptions = endpointWithOptions.defaultServiceOptions(defaultServiceOptions);
|
|
7
|
+
if (journalValueCodecProvider) endpointWithOptions = endpointWithOptions.journalValueCodecProvider(journalValueCodecProvider);
|
|
8
|
+
if (logger) endpointWithOptions = endpointWithOptions.setLogger(logger);
|
|
9
|
+
return services.reduce((results, service) => {
|
|
10
|
+
return results.bind(service);
|
|
11
|
+
}, endpointWithOptions);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.withOptions = withOptions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/endpoint/withOptions.ts
|
|
2
|
+
function withOptions(endpoint, { identityKeys, defaultServiceOptions, logger, services, journalValueCodecProvider }) {
|
|
3
|
+
let endpointWithOptions = endpoint;
|
|
4
|
+
if (identityKeys && identityKeys.length > 0) endpointWithOptions = endpointWithOptions.withIdentityV1(...identityKeys);
|
|
5
|
+
if (defaultServiceOptions) endpointWithOptions = endpointWithOptions.defaultServiceOptions(defaultServiceOptions);
|
|
6
|
+
if (journalValueCodecProvider) endpointWithOptions = endpointWithOptions.journalValueCodecProvider(journalValueCodecProvider);
|
|
7
|
+
if (logger) endpointWithOptions = endpointWithOptions.setLogger(logger);
|
|
8
|
+
return services.reduce((results, service) => {
|
|
9
|
+
return results.bind(service);
|
|
10
|
+
}, endpointWithOptions);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { withOptions };
|
|
15
|
+
//# sourceMappingURL=withOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withOptions.js","names":[],"sources":["../../src/endpoint/withOptions.ts"],"sourcesContent":["import type { RestateEndpointBase } from \"../endpoint.js\";\nimport type { EndpointOptions } from \"./types.js\";\n\nexport function withOptions<E extends RestateEndpointBase<E>>(\n endpoint: E,\n {\n identityKeys,\n defaultServiceOptions,\n logger,\n services,\n journalValueCodecProvider,\n }: EndpointOptions\n): E {\n let endpointWithOptions = endpoint;\n if (identityKeys && identityKeys.length > 0) {\n endpointWithOptions = endpointWithOptions.withIdentityV1(...identityKeys);\n }\n if (defaultServiceOptions) {\n endpointWithOptions = endpointWithOptions.defaultServiceOptions(\n defaultServiceOptions\n );\n }\n if (journalValueCodecProvider) {\n endpointWithOptions = endpointWithOptions.journalValueCodecProvider(\n journalValueCodecProvider\n );\n }\n if (logger) {\n endpointWithOptions = endpointWithOptions.setLogger(logger);\n }\n\n return services.reduce((results, service) => {\n return results.bind(service);\n }, endpointWithOptions);\n}\n"],"mappings":";AAGA,SAAgB,YACd,UACA,EACE,cACA,uBACA,QACA,UACA,6BAEC;CACH,IAAI,sBAAsB;AAC1B,KAAI,gBAAgB,aAAa,SAAS,EACxC,uBAAsB,oBAAoB,eAAe,GAAG,aAAa;AAE3E,KAAI,sBACF,uBAAsB,oBAAoB,sBACxC,sBACD;AAEH,KAAI,0BACF,uBAAsB,oBAAoB,0BACxC,0BACD;AAEH,KAAI,OACF,uBAAsB,oBAAoB,UAAU,OAAO;AAG7D,QAAO,SAAS,QAAQ,SAAS,YAAY;AAC3C,SAAO,QAAQ,KAAK,QAAQ;IAC3B,oBAAoB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ObjectOptions, ServiceOptions, WorkflowOptions } from "./types/rpc.cjs";
|
|
2
|
+
import { LoggerTransport } from "./logging/logger_transport.cjs";
|
|
3
|
+
import { JournalValueCodec, ServiceDefinition, VirtualObjectDefinition, WorkflowDefinition } from "@restatedev/restate-sdk-core";
|
|
4
|
+
import { Http2ServerRequest, Http2ServerResponse } from "http2";
|
|
5
|
+
|
|
6
|
+
//#region src/endpoint.d.ts
|
|
7
|
+
type DefaultServiceOptions = ServiceOptions & ObjectOptions & WorkflowOptions;
|
|
8
|
+
interface RestateEndpointBase<E> {
|
|
9
|
+
/**
|
|
10
|
+
* Binds a new durable service / virtual object / workflow.
|
|
11
|
+
*
|
|
12
|
+
* see restate.service, restate.object, and restate.workflow for more details.
|
|
13
|
+
**/
|
|
14
|
+
bind<P extends string, M>(service: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M> | WorkflowDefinition<P, M>): E;
|
|
15
|
+
/**
|
|
16
|
+
* Provide a list of v1 request identity public keys eg `publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9` to validate
|
|
17
|
+
* incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is
|
|
18
|
+
* logged by the Restate process at startup if a request identity private key is provided.
|
|
19
|
+
*
|
|
20
|
+
* If this function is called, all incoming requests irrelevant of endpoint type will be expected to have
|
|
21
|
+
* `x-restate-signature-scheme: v1` and `x-restate-jwt-v1: <valid jwt signed with one of these keys>`. If not called,
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
withIdentityV1(...keys: string[]): E;
|
|
25
|
+
/**
|
|
26
|
+
* Set default service options that will be used by all services bind to this endpoint.
|
|
27
|
+
*
|
|
28
|
+
* Options can be overridden on each service/handler.
|
|
29
|
+
*
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
defaultServiceOptions(options: DefaultServiceOptions): E;
|
|
33
|
+
/**
|
|
34
|
+
* Replace the default console-based {@link LoggerTransport}
|
|
35
|
+
* @param logger
|
|
36
|
+
* @example
|
|
37
|
+
* Using console:
|
|
38
|
+
* ```ts
|
|
39
|
+
* restate.setLogger((meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)})
|
|
40
|
+
* ```
|
|
41
|
+
* @example
|
|
42
|
+
* Using winston:
|
|
43
|
+
* ```ts
|
|
44
|
+
* const logger = createLogger({ ... })
|
|
45
|
+
* restate.setLogger((meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
46
|
+
* ```
|
|
47
|
+
* @example
|
|
48
|
+
* Using pino:
|
|
49
|
+
* ```ts
|
|
50
|
+
* const logger = pino()
|
|
51
|
+
* restate.setLogger((meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
setLogger(logger: LoggerTransport): E;
|
|
55
|
+
/**
|
|
56
|
+
* Provider for the codec to use for journal values. One codec will be instantiated globally for this endpoint.
|
|
57
|
+
* Check {@link JournalValueCodec} for more details
|
|
58
|
+
*
|
|
59
|
+
* @experimental
|
|
60
|
+
*/
|
|
61
|
+
journalValueCodecProvider(codecProvider: () => Promise<JournalValueCodec>): E;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* RestateEndpoint encapsulates all the Restate services served by this endpoint.
|
|
65
|
+
*
|
|
66
|
+
* A RestateEndpoint can either be served as HTTP2 server, using the methods {@link RestateEndpoint.listen} or {@link RestateEndpoint.http2Handler}.
|
|
67
|
+
*
|
|
68
|
+
* For Lambda, check {@link LambdaEndpoint}
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* A typical endpoint served as HTTP server would look like this:
|
|
72
|
+
* ```
|
|
73
|
+
* import * as restate from "@restatedev/restate-sdk";
|
|
74
|
+
*
|
|
75
|
+
* restate
|
|
76
|
+
* .endpoint()
|
|
77
|
+
* .bind(myService)
|
|
78
|
+
* .listen(8000);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
interface RestateEndpoint extends RestateEndpointBase<RestateEndpoint> {
|
|
82
|
+
/**
|
|
83
|
+
* Serve this Restate Endpoint as HTTP2 server, listening to the given port.
|
|
84
|
+
*
|
|
85
|
+
* If the port is undefined, this method will use the port set in the `PORT`
|
|
86
|
+
* environment variable. If that variable is undefined as well, the method will
|
|
87
|
+
* default to port 9080.
|
|
88
|
+
*
|
|
89
|
+
* The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
|
|
90
|
+
*
|
|
91
|
+
* This method is a shorthand for:
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```
|
|
95
|
+
* const httpServer = http2.createServer(endpoint.http2Handler());
|
|
96
|
+
* httpServer.listen(port);
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link RestateEndpoint.http2Handler}.
|
|
100
|
+
*
|
|
101
|
+
* @param port The port to listen at. May be undefined (see above).
|
|
102
|
+
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
|
|
103
|
+
*/
|
|
104
|
+
listen(port?: number): Promise<number>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns an http2 server handler. See {@link RestateEndpoint.listen} for more details.
|
|
107
|
+
*/
|
|
108
|
+
http2Handler(): (request: Http2ServerRequest, response: Http2ServerResponse) => void;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase };
|
|
112
|
+
//# sourceMappingURL=endpoint.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.d.cts","names":[],"sources":["../src/endpoint.ts"],"sourcesContent":[],"mappings":";;;;;;KAyBY,qBAAA,GAAwB,iBAClC,gBACA;UAEe;EAJL;;;;;EAIK,IAAA,CAAA,UAAA,MAAA,EAAmB,CAAA,CAAA,CAAA,OAAA,EAQ5B,iBAR4B,CAQV,CARU,EAQP,CARO,CAAA,GAS5B,uBAT4B,CASJ,CATI,EASD,CATC,CAAA,GAU5B,kBAV4B,CAUT,CAVS,EAUN,CAVM,CAAA,CAAA,EAW/B,CAX+B;EAQV;;;;;;;;;EAGrB,cAAA,CAAA,GAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAWgC,CAXhC;EAWgC;;;;;;;EAwCyC,qBAAA,CAAA,OAAA,EA/B7C,qBA+B6C,CAAA,EA/BrB,CA+BqB;EAAC;AAqB/E;;;;;;;;;;;;;;;;;;;;oBA7BoB,kBAAkB;;;;;;;iDAQW,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;;UAqB7D,eAAA,SAAwB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;yBAuBpC;;;;4BAMZ,8BACC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ObjectOptions, ServiceOptions, WorkflowOptions } from "./types/rpc.js";
|
|
2
|
+
import { LoggerTransport } from "./logging/logger_transport.js";
|
|
3
|
+
import { JournalValueCodec, ServiceDefinition, VirtualObjectDefinition, WorkflowDefinition } from "@restatedev/restate-sdk-core";
|
|
4
|
+
import { Http2ServerRequest, Http2ServerResponse } from "http2";
|
|
5
|
+
|
|
6
|
+
//#region src/endpoint.d.ts
|
|
7
|
+
type DefaultServiceOptions = ServiceOptions & ObjectOptions & WorkflowOptions;
|
|
8
|
+
interface RestateEndpointBase<E> {
|
|
9
|
+
/**
|
|
10
|
+
* Binds a new durable service / virtual object / workflow.
|
|
11
|
+
*
|
|
12
|
+
* see restate.service, restate.object, and restate.workflow for more details.
|
|
13
|
+
**/
|
|
14
|
+
bind<P extends string, M>(service: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M> | WorkflowDefinition<P, M>): E;
|
|
15
|
+
/**
|
|
16
|
+
* Provide a list of v1 request identity public keys eg `publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9` to validate
|
|
17
|
+
* incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is
|
|
18
|
+
* logged by the Restate process at startup if a request identity private key is provided.
|
|
19
|
+
*
|
|
20
|
+
* If this function is called, all incoming requests irrelevant of endpoint type will be expected to have
|
|
21
|
+
* `x-restate-signature-scheme: v1` and `x-restate-jwt-v1: <valid jwt signed with one of these keys>`. If not called,
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
withIdentityV1(...keys: string[]): E;
|
|
25
|
+
/**
|
|
26
|
+
* Set default service options that will be used by all services bind to this endpoint.
|
|
27
|
+
*
|
|
28
|
+
* Options can be overridden on each service/handler.
|
|
29
|
+
*
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
defaultServiceOptions(options: DefaultServiceOptions): E;
|
|
33
|
+
/**
|
|
34
|
+
* Replace the default console-based {@link LoggerTransport}
|
|
35
|
+
* @param logger
|
|
36
|
+
* @example
|
|
37
|
+
* Using console:
|
|
38
|
+
* ```ts
|
|
39
|
+
* restate.setLogger((meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)})
|
|
40
|
+
* ```
|
|
41
|
+
* @example
|
|
42
|
+
* Using winston:
|
|
43
|
+
* ```ts
|
|
44
|
+
* const logger = createLogger({ ... })
|
|
45
|
+
* restate.setLogger((meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
46
|
+
* ```
|
|
47
|
+
* @example
|
|
48
|
+
* Using pino:
|
|
49
|
+
* ```ts
|
|
50
|
+
* const logger = pino()
|
|
51
|
+
* restate.setLogger((meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))})
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
setLogger(logger: LoggerTransport): E;
|
|
55
|
+
/**
|
|
56
|
+
* Provider for the codec to use for journal values. One codec will be instantiated globally for this endpoint.
|
|
57
|
+
* Check {@link JournalValueCodec} for more details
|
|
58
|
+
*
|
|
59
|
+
* @experimental
|
|
60
|
+
*/
|
|
61
|
+
journalValueCodecProvider(codecProvider: () => Promise<JournalValueCodec>): E;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* RestateEndpoint encapsulates all the Restate services served by this endpoint.
|
|
65
|
+
*
|
|
66
|
+
* A RestateEndpoint can either be served as HTTP2 server, using the methods {@link RestateEndpoint.listen} or {@link RestateEndpoint.http2Handler}.
|
|
67
|
+
*
|
|
68
|
+
* For Lambda, check {@link LambdaEndpoint}
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* A typical endpoint served as HTTP server would look like this:
|
|
72
|
+
* ```
|
|
73
|
+
* import * as restate from "@restatedev/restate-sdk";
|
|
74
|
+
*
|
|
75
|
+
* restate
|
|
76
|
+
* .endpoint()
|
|
77
|
+
* .bind(myService)
|
|
78
|
+
* .listen(8000);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
interface RestateEndpoint extends RestateEndpointBase<RestateEndpoint> {
|
|
82
|
+
/**
|
|
83
|
+
* Serve this Restate Endpoint as HTTP2 server, listening to the given port.
|
|
84
|
+
*
|
|
85
|
+
* If the port is undefined, this method will use the port set in the `PORT`
|
|
86
|
+
* environment variable. If that variable is undefined as well, the method will
|
|
87
|
+
* default to port 9080.
|
|
88
|
+
*
|
|
89
|
+
* The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
|
|
90
|
+
*
|
|
91
|
+
* This method is a shorthand for:
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```
|
|
95
|
+
* const httpServer = http2.createServer(endpoint.http2Handler());
|
|
96
|
+
* httpServer.listen(port);
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link RestateEndpoint.http2Handler}.
|
|
100
|
+
*
|
|
101
|
+
* @param port The port to listen at. May be undefined (see above).
|
|
102
|
+
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
|
|
103
|
+
*/
|
|
104
|
+
listen(port?: number): Promise<number>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns an http2 server handler. See {@link RestateEndpoint.listen} for more details.
|
|
107
|
+
*/
|
|
108
|
+
http2Handler(): (request: Http2ServerRequest, response: Http2ServerResponse) => void;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase };
|
|
112
|
+
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","names":[],"sources":["../src/endpoint.ts"],"sourcesContent":[],"mappings":";;;;;;KAyBY,qBAAA,GAAwB,iBAClC,gBACA;UAEe;EAJL;;;;;EAIK,IAAA,CAAA,UAAA,MAAA,EAAmB,CAAA,CAAA,CAAA,OAAA,EAQ5B,iBAR4B,CAQV,CARU,EAQP,CARO,CAAA,GAS5B,uBAT4B,CASJ,CATI,EASD,CATC,CAAA,GAU5B,kBAV4B,CAUT,CAVS,EAUN,CAVM,CAAA,CAAA,EAW/B,CAX+B;EAQV;;;;;;;;;EAGrB,cAAA,CAAA,GAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAWgC,CAXhC;EAWgC;;;;;;;EAwCyC,qBAAA,CAAA,OAAA,EA/B7C,qBA+B6C,CAAA,EA/BrB,CA+BqB;EAAC;AAqB/E;;;;;;;;;;;;;;;;;;;;oBA7BoB,kBAAkB;;;;;;;iDAQW,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;;UAqB7D,eAAA,SAAwB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;yBAuBpC;;;;4BAMZ,8BACC"}
|
package/dist/fetch.cjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_errors = require('./types/errors.cjs');
|
|
3
|
+
const require_rpc = require('./types/rpc.cjs');
|
|
4
|
+
const require_context = require('./context.cjs');
|
|
5
|
+
const require_common_api = require('./common_api.cjs');
|
|
6
|
+
const require_fetch_endpoint = require('./endpoint/fetch_endpoint.cjs');
|
|
7
|
+
const require_withOptions = require('./endpoint/withOptions.cjs');
|
|
8
|
+
let __restatedev_restate_sdk_core = require("@restatedev/restate-sdk-core");
|
|
9
|
+
__restatedev_restate_sdk_core = require_rolldown_runtime.__toESM(__restatedev_restate_sdk_core);
|
|
10
|
+
|
|
11
|
+
//#region src/fetch.ts
|
|
12
|
+
/**
|
|
13
|
+
* Create a new {@link RestateEndpoint} in request response protocol mode.
|
|
14
|
+
* Bidirectional mode (must be served over http2) can be enabled with .enableHttp2()
|
|
15
|
+
* @deprecated Please use {@link createEndpointHandler}
|
|
16
|
+
*/
|
|
17
|
+
function endpoint() {
|
|
18
|
+
return new require_fetch_endpoint.FetchEndpointImpl("REQUEST_RESPONSE");
|
|
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
|
+
function createEndpointHandler(options) {
|
|
42
|
+
return require_withOptions.withOptions(new require_fetch_endpoint.FetchEndpointImpl(options.bidirectional ? "BIDI_STREAM" : "REQUEST_RESPONSE"), options).handler().fetch;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.CancelledError = require_errors.CancelledError;
|
|
47
|
+
exports.CombineablePromise = require_common_api.CombineablePromise;
|
|
48
|
+
exports.InvocationIdParser = require_context.InvocationIdParser;
|
|
49
|
+
exports.Opts = require_rpc.Opts;
|
|
50
|
+
exports.RestateError = require_errors.RestateError;
|
|
51
|
+
exports.RestatePromise = require_context.RestatePromise;
|
|
52
|
+
exports.RetryableError = require_errors.RetryableError;
|
|
53
|
+
exports.SendOpts = require_rpc.SendOpts;
|
|
54
|
+
exports.TerminalError = require_errors.TerminalError;
|
|
55
|
+
exports.TimeoutError = require_errors.TimeoutError;
|
|
56
|
+
exports.createEndpointHandler = createEndpointHandler;
|
|
57
|
+
exports.createObjectHandler = require_common_api.createObjectHandler;
|
|
58
|
+
exports.createObjectSharedHandler = require_common_api.createObjectSharedHandler;
|
|
59
|
+
exports.createServiceHandler = require_common_api.createServiceHandler;
|
|
60
|
+
exports.createWorkflowHandler = require_common_api.createWorkflowHandler;
|
|
61
|
+
exports.createWorkflowSharedHandler = require_common_api.createWorkflowSharedHandler;
|
|
62
|
+
exports.endpoint = endpoint;
|
|
63
|
+
Object.defineProperty(exports, 'handlers', {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () {
|
|
66
|
+
return require_rpc.handlers;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
exports.object = require_rpc.object;
|
|
70
|
+
Object.defineProperty(exports, 'rpc', {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () {
|
|
73
|
+
return require_rpc.rpc;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, 'serde', {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return __restatedev_restate_sdk_core.serde;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
exports.service = require_rpc.service;
|
|
83
|
+
exports.workflow = require_rpc.workflow;
|
package/dist/fetch.d.cts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.cjs";
|
|
2
|
+
import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.cjs";
|
|
3
|
+
import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request as Request$1, RestatePromise, RunAction, RunOptions, SendOptions, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.cjs";
|
|
4
|
+
import { LogMetadata, LogSource, LoggerContext, LoggerTransport, RestateLogLevel } from "./logging/logger_transport.cjs";
|
|
5
|
+
import { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase } from "./endpoint.cjs";
|
|
6
|
+
import { EndpointOptions } from "./endpoint/types.cjs";
|
|
7
|
+
import { CombineablePromise, Duration, JournalValueCodec, ObjectHandler, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowSharedHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.cjs";
|
|
8
|
+
import { FetchEndpoint } from "./endpoint/fetch_endpoint.cjs";
|
|
9
|
+
|
|
10
|
+
//#region src/fetch.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Create a new {@link RestateEndpoint} in request response protocol mode.
|
|
13
|
+
* Bidirectional mode (must be served over http2) can be enabled with .enableHttp2()
|
|
14
|
+
* @deprecated Please use {@link createEndpointHandler}
|
|
15
|
+
*/
|
|
16
|
+
declare function endpoint(): FetchEndpoint;
|
|
17
|
+
interface FetchEndpointOptions extends EndpointOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Enables bidirectional communication for the handler.
|
|
20
|
+
*
|
|
21
|
+
* When set to `true`, the handler supports bidirectional streaming (e.g., via HTTP/2 or compatible HTTP/1.1 servers).
|
|
22
|
+
* When `false`, the handler operates in request-response mode only.
|
|
23
|
+
*
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
bidirectional?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Fetch handler that encapsulates all the Restate services served by this endpoint.
|
|
30
|
+
*
|
|
31
|
+
* @param {FetchEndpointOptions} options - Configuration options for the endpoint handler.
|
|
32
|
+
* @returns A fetch handler function.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* A typical request-response handler would look like this:
|
|
36
|
+
* ```
|
|
37
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
38
|
+
*
|
|
39
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* A typical bidirectional handler (works with http2 and some http1.1 servers) would look like this:
|
|
43
|
+
* ```
|
|
44
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
45
|
+
*
|
|
46
|
+
* export const handler = createEndpointHandler({ services: [myService], bidirectional: true })
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
declare function createEndpointHandler(options: FetchEndpointOptions): (request: Request, ...extraArgs: unknown[]) => Promise<Response>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, type FetchEndpoint, FetchEndpointOptions, GenericCall, GenericSend, InferArg, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request$1 as Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOptions, SendOpts, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, object, rpc, serde, service, workflow };
|
|
52
|
+
//# sourceMappingURL=fetch.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.cts","names":[],"sources":["../src/fetch.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;iBAyBgB,QAAA,CAAA,GAAY;UAIX,oBAAA,SAA6B;EAJ9B;AAIhB;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,qBAAA,UAA+B,iCAAoB,qCAAA,QAAA"}
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
|
|
2
|
+
import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
|
|
3
|
+
import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request as Request$1, RestatePromise, RunAction, RunOptions, SendOptions, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.js";
|
|
4
|
+
import { LogMetadata, LogSource, LoggerContext, LoggerTransport, RestateLogLevel } from "./logging/logger_transport.js";
|
|
5
|
+
import { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase } from "./endpoint.js";
|
|
6
|
+
import { EndpointOptions } from "./endpoint/types.js";
|
|
7
|
+
import { CombineablePromise, Duration, JournalValueCodec, ObjectHandler, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowSharedHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.js";
|
|
8
|
+
import { FetchEndpoint } from "./endpoint/fetch_endpoint.js";
|
|
9
|
+
|
|
10
|
+
//#region src/fetch.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Create a new {@link RestateEndpoint} in request response protocol mode.
|
|
13
|
+
* Bidirectional mode (must be served over http2) can be enabled with .enableHttp2()
|
|
14
|
+
* @deprecated Please use {@link createEndpointHandler}
|
|
15
|
+
*/
|
|
16
|
+
declare function endpoint(): FetchEndpoint;
|
|
17
|
+
interface FetchEndpointOptions extends EndpointOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Enables bidirectional communication for the handler.
|
|
20
|
+
*
|
|
21
|
+
* When set to `true`, the handler supports bidirectional streaming (e.g., via HTTP/2 or compatible HTTP/1.1 servers).
|
|
22
|
+
* When `false`, the handler operates in request-response mode only.
|
|
23
|
+
*
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
bidirectional?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Fetch handler that encapsulates all the Restate services served by this endpoint.
|
|
30
|
+
*
|
|
31
|
+
* @param {FetchEndpointOptions} options - Configuration options for the endpoint handler.
|
|
32
|
+
* @returns A fetch handler function.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* A typical request-response handler would look like this:
|
|
36
|
+
* ```
|
|
37
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
38
|
+
*
|
|
39
|
+
* export const handler = createEndpointHandler({ services: [myService] })
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* A typical bidirectional handler (works with http2 and some http1.1 servers) would look like this:
|
|
43
|
+
* ```
|
|
44
|
+
* import { createEndpointHandler } from "@restatedev/restate-sdk/fetch";
|
|
45
|
+
*
|
|
46
|
+
* export const handler = createEndpointHandler({ services: [myService], bidirectional: true })
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
declare function createEndpointHandler(options: FetchEndpointOptions): (request: Request, ...extraArgs: unknown[]) => Promise<Response>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, type FetchEndpoint, FetchEndpointOptions, GenericCall, GenericSend, InferArg, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request$1 as Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOptions, SendOpts, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, object, rpc, serde, service, workflow };
|
|
52
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","names":[],"sources":["../src/fetch.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;iBAyBgB,QAAA,CAAA,GAAY;UAIX,oBAAA,SAA6B;EAJ9B;AAIhB;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,qBAAA,UAA+B,iCAAoB,qCAAA,QAAA"}
|