@restatedev/restate-sdk-core 1.16.8 → 1.17.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.
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 - Restate Software, Inc., Restate GmbH
3
+ *
4
+ * This file is part of the Restate SDK for Node.js/TypeScript,
5
+ * which is released under the MIT license.
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
10
+ */
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ import { serde } from "./serde_api.js";
13
+ export function makeHandlerDescriptor(inputSerde, outputSerde, shared) {
14
+ return {
15
+ _inputSerde: inputSerde,
16
+ _outputSerde: outputSerde,
17
+ _shared: shared,
18
+ };
19
+ }
20
+ /**
21
+ * Declare a service interface (contract) as a runtime value carrying handler
22
+ * names + input/output serdes, without an implementation. Place it in a shared
23
+ * package that both the server (via `implement()`) and callers (via
24
+ * `ctx.serviceClient(iface)` / `connect().serviceClient(iface)`) import.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const greeter = iface.service("greeter", {
29
+ * greet: iface.schemas({ input: GreetReq, output: GreetRes }),
30
+ * ping: iface.json<void, string>(),
31
+ * });
32
+ * ```
33
+ */
34
+ export const iface = {
35
+ service: function (name, handlers) {
36
+ return { name, _kind: "service", _handlers: handlers };
37
+ },
38
+ object: function (name, handlers) {
39
+ return { name, _kind: "object", _handlers: handlers };
40
+ },
41
+ workflow: function (name, handlers) {
42
+ return { name, _kind: "workflow", _handlers: handlers };
43
+ },
44
+ json: function () {
45
+ return makeHandlerDescriptor(undefined, undefined, false);
46
+ },
47
+ serdes: function (opts) {
48
+ return makeHandlerDescriptor(opts.input, opts.output, false);
49
+ },
50
+ schemas: function (opts) {
51
+ return makeHandlerDescriptor(opts.input ? serde.schema(opts.input) : undefined, opts.output ? serde.schema(opts.output) : undefined, false);
52
+ },
53
+ shared: {
54
+ json: function () {
55
+ return makeHandlerDescriptor(undefined, undefined, true);
56
+ },
57
+ serdes: function (opts) {
58
+ return makeHandlerDescriptor(opts.input, opts.output, true);
59
+ },
60
+ schemas: function (opts) {
61
+ return makeHandlerDescriptor(opts.input ? serde.schema(opts.input) : undefined, opts.output ? serde.schema(opts.output) : undefined, true);
62
+ },
63
+ },
64
+ };
65
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,uDAAuD;AAGvD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAsBvC,MAAM,UAAU,qBAAqB,CACnC,UAAqB,EACrB,WAAsB,EACtB,MAAe;IAEf,OAAO;QACL,WAAW,EAAE,UAAU;QACvB,YAAY,EAAE,WAAW;QACzB,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC;AA4ID;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAqB;IACrC,OAAO,EAAE,UAGP,IAAO,EAAE,QAAW;QACpB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACzD,CAAC;IACD,MAAM,EAAE,UAGN,IAAO,EAAE,QAAW;QACpB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACxD,CAAC;IACD,QAAQ,EAAE,UAGR,IAAO,EAAE,QAAW;QACpB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IAC1D,CAAC;IACD,IAAI,EAAE;QACJ,OAAO,qBAAqB,CAAc,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,EAAE,UAAwD,IAG/D;QACC,OAAO,qBAAqB,CAC1B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,KAAK,CACN,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,UAGP,IAGD;QAKC,OAAO,qBAAqB,CAC1B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACjD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EACnD,KAAK,CACN,CAAC;IACJ,CAAC;IACD,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,OAAO,qBAAqB,CAAa,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,EAAE,UAAwD,IAG/D;YACC,OAAO,qBAAqB,CAC1B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CACL,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,UAGP,IAGD;YAKC,OAAO,qBAAqB,CAC1B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACjD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EACnD,IAAI,CACL,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -1,7 +1,4 @@
1
- import { StandardSchemaV1 } from "./standard_schema.js";
2
-
3
- //#region src/serde_api.d.ts
4
-
1
+ import type { StandardSchemaV1 } from "./standard_schema.js";
5
2
  /**
6
3
  * Serializer/deserializer pair for any Restate-managed value of type `T` —
7
4
  * handler inputs and outputs, service state, side-effect results,
@@ -19,117 +16,115 @@ import { StandardSchemaV1 } from "./standard_schema.js";
19
16
  * It also advertises metadata (`contentType`, `jsonSchema`) that surfaces in
20
17
  * service discovery.
21
18
  */
22
- interface Serde<T> {
23
- /**
24
- * MIME type of the bytes produced by `serialize` (and accepted by
25
- * `deserialize`).
26
- */
27
- contentType?: string;
28
- /**
29
- * Optional JSON Schema describing the logical shape of `T`. Surfaced in
30
- * discovery so that tooling can generate forms, auto-complete payloads,
31
- * etc. Has no effect on serialization at runtime.
32
- */
33
- jsonSchema?: object;
34
- /**
35
- * Optional bridge between the serde's wire format and a JSON
36
- * representation that humans (and tooling like the Restate UI) can read
37
- * and edit.
38
- *
39
- * Only useful for serdes whose wire format isn't already plain JSON —
40
- * protobuf, MessagePack, length-prefixed binary, JSON variants that need
41
- * post-processing for bigints/dates, etc. Both methods may be async if the
42
- * conversion needs I/O.
43
- *
44
- * ### Preview flow
45
- *
46
- * Together with `serialize` / `deserialize`, the four functions chain in
47
- * both directions between a JSON string and on-the-wire bytes:
48
- *
49
- * ```text
50
- * JSON string ──fromJsonString──► T ──serialize──► wire bytes
51
- * wire bytes ──deserialize────► T ──toJsonString──► JSON string
52
- * ```
53
- *
54
- * The split keeps `serialize` / `deserialize` responsible for the full
55
- * on-the-wire format; `preview` only handles the JSON ↔ `T` bridge.
56
- *
57
- * @example
58
- * ```ts
59
- * // Wire format is protobuf; the protobuf-es runtime already ships
60
- * // `toJsonString` / `fromJsonString`, so preview is a direct pass-through.
61
- * import {
62
- * fromBinary,
63
- * fromJsonString,
64
- * toBinary,
65
- * toJsonString,
66
- * } from "@bufbuild/protobuf";
67
- * import { PersonSchema, type Person } from "./person_pb.js";
68
- *
69
- * const personSerde: Serde<Person> = {
70
- * contentType: "application/protobuf",
71
- * serialize(message) { return toBinary(PersonSchema, message); },
72
- * deserialize(bytes) { return fromBinary(PersonSchema, bytes); },
73
- * preview: {
74
- * toJsonString: (v) => toJsonString(PersonSchema, v),
75
- * fromJsonString: (j) => fromJsonString(PersonSchema, j),
76
- * },
77
- * };
78
- * ```
79
- */
80
- preview?: {
19
+ export interface Serde<T> {
81
20
  /**
82
- * Convert a value into a JSON string for display or editing by humans.
83
- * The returned string must round-trip through `fromJsonString` back to
84
- * the same logical value.
21
+ * MIME type of the bytes produced by `serialize` (and accepted by
22
+ * `deserialize`).
85
23
  */
86
- toJsonString(value: T): Promise<string> | string;
24
+ contentType?: string;
87
25
  /**
88
- * Parse a human-supplied JSON string back into a value of type `T`.
89
- * Should throw (or reject) if `json` is invalid for this serde.
26
+ * Optional JSON Schema describing the logical shape of `T`. Surfaced in
27
+ * discovery so that tooling can generate forms, auto-complete payloads,
28
+ * etc. Has no effect on serialization at runtime.
29
+ */
30
+ jsonSchema?: object;
31
+ /**
32
+ * Optional bridge between the serde's wire format and a JSON
33
+ * representation that humans (and tooling like the Restate UI) can read
34
+ * and edit.
35
+ *
36
+ * Only useful for serdes whose wire format isn't already plain JSON —
37
+ * protobuf, MessagePack, length-prefixed binary, JSON variants that need
38
+ * post-processing for bigints/dates, etc. Both methods may be async if the
39
+ * conversion needs I/O.
40
+ *
41
+ * ### Preview flow
42
+ *
43
+ * Together with `serialize` / `deserialize`, the four functions chain in
44
+ * both directions between a JSON string and on-the-wire bytes:
45
+ *
46
+ * ```text
47
+ * JSON string ──fromJsonString──► T ──serialize──► wire bytes
48
+ * wire bytes ──deserialize────► T ──toJsonString──► JSON string
49
+ * ```
50
+ *
51
+ * The split keeps `serialize` / `deserialize` responsible for the full
52
+ * on-the-wire format; `preview` only handles the JSON ↔ `T` bridge.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * // Wire format is protobuf; the protobuf-es runtime already ships
57
+ * // `toJsonString` / `fromJsonString`, so preview is a direct pass-through.
58
+ * import {
59
+ * fromBinary,
60
+ * fromJsonString,
61
+ * toBinary,
62
+ * toJsonString,
63
+ * } from "@bufbuild/protobuf";
64
+ * import { PersonSchema, type Person } from "./person_pb.js";
65
+ *
66
+ * const personSerde: Serde<Person> = {
67
+ * contentType: "application/protobuf",
68
+ * serialize(message) { return toBinary(PersonSchema, message); },
69
+ * deserialize(bytes) { return fromBinary(PersonSchema, bytes); },
70
+ * preview: {
71
+ * toJsonString: (v) => toJsonString(PersonSchema, v),
72
+ * fromJsonString: (j) => fromJsonString(PersonSchema, j),
73
+ * },
74
+ * };
75
+ * ```
76
+ */
77
+ preview?: {
78
+ /**
79
+ * Convert a value into a JSON string for display or editing by humans.
80
+ * The returned string must round-trip through `fromJsonString` back to
81
+ * the same logical value.
82
+ */
83
+ toJsonString(value: T): Promise<string> | string;
84
+ /**
85
+ * Parse a human-supplied JSON string back into a value of type `T`.
86
+ * Should throw (or reject) if `json` is invalid for this serde.
87
+ */
88
+ fromJsonString(json: string): Promise<T> | T;
89
+ };
90
+ /**
91
+ * Convert a value of type `T` into its on-the-wire bytes. This is the
92
+ * format Restate sends between services and persists in the journal.
93
+ *
94
+ * Must be the inverse of `deserialize` — `deserialize(serialize(v))`
95
+ * should produce a value equivalent to `v`.
90
96
  */
91
- fromJsonString(json: string): Promise<T> | T;
92
- };
93
- /**
94
- * Convert a value of type `T` into its on-the-wire bytes. This is the
95
- * format Restate sends between services and persists in the journal.
96
- *
97
- * Must be the inverse of `deserialize` — `deserialize(serialize(v))`
98
- * should produce a value equivalent to `v`.
99
- */
100
- serialize(value: T): Uint8Array;
101
- /**
102
- * Convert on-the-wire bytes back into a value of type `T`. Must be the
103
- * inverse of `serialize`.
104
- *
105
- * May throw if `data` doesn't conform to the expected wire format.
106
- */
107
- deserialize(data: Uint8Array): T;
108
- }
109
- declare namespace serde {
110
- class JsonSerde<T> implements Serde<T | undefined> {
111
- readonly jsonSchema?: object | undefined;
112
- contentType: string;
113
- constructor(jsonSchema?: object | undefined);
114
97
  serialize(value: T): Uint8Array;
115
- deserialize(data: Uint8Array): T | undefined;
116
- schema<U>(schema: object): Serde<U>;
117
- }
118
- const json: JsonSerde<any>;
119
- const binary: Serde<Uint8Array>;
120
- const empty: Serde<void>;
121
- /**
122
- * A Standard Schema-based serde.
123
- *
124
- * @param schema the standard schema
125
- * @param validateOptions options passed to `StandardSchemaV1.Options.libraryOptions` when validating
126
- * @param jsonSchemaOptions options passed to `StandardJsonSchemaV1.Options.libraryOptions` for code generation
127
- * @returns a serde that will validate the data with the standard schema
128
- */
129
- const schema: <T extends {
130
- "~standard": StandardSchemaV1.Props;
131
- }>(schema: T, validateOptions?: Record<string, unknown>, jsonSchemaOptions?: Record<string, unknown>) => Serde<StandardSchemaV1.InferOutput<T>>;
98
+ /**
99
+ * Convert on-the-wire bytes back into a value of type `T`. Must be the
100
+ * inverse of `serialize`.
101
+ *
102
+ * May throw if `data` doesn't conform to the expected wire format.
103
+ */
104
+ deserialize(data: Uint8Array): T;
105
+ }
106
+ export declare namespace serde {
107
+ class JsonSerde<T> implements Serde<T | undefined> {
108
+ readonly jsonSchema?: object | undefined;
109
+ contentType: string;
110
+ constructor(jsonSchema?: object | undefined);
111
+ serialize(value: T): Uint8Array;
112
+ deserialize(data: Uint8Array): T | undefined;
113
+ schema<U>(schema: object): Serde<U>;
114
+ }
115
+ const json: JsonSerde<any>;
116
+ const binary: Serde<Uint8Array>;
117
+ const empty: Serde<void>;
118
+ /**
119
+ * A Standard Schema-based serde.
120
+ *
121
+ * @param schema the standard schema
122
+ * @param validateOptions options passed to `StandardSchemaV1.Options.libraryOptions` when validating
123
+ * @param jsonSchemaOptions options passed to `StandardJsonSchemaV1.Options.libraryOptions` for code generation
124
+ * @returns a serde that will validate the data with the standard schema
125
+ */
126
+ const schema: <T extends {
127
+ "~standard": StandardSchemaV1.Props;
128
+ }>(schema: T, validateOptions?: Record<string, unknown>, jsonSchemaOptions?: Record<string, unknown>) => Serde<StandardSchemaV1.InferOutput<T>>;
132
129
  }
133
- //#endregion
134
- export { Serde, serde };
135
130
  //# sourceMappingURL=serde_api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serde_api.d.ts","names":[],"sources":["../src/serde_api.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;;;;;;;;;;;AAiOA;;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,CAAC;IACrB,MAAa,SAAS,CAAC,CAAC,CAAE,YAAW,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC;QAG3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;QAFxC,WAAW,SAAsB;oBAEZ,UAAU,CAAC,EAAE,MAAM,YAAA;QAExC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,UAAU;QAO/B,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,CAAC,GAAG,SAAS;QAO5C,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;KAGpC;IAEM,MAAM,IAAI,EAAE,SAAS,CAAC,GAAG,CAAwB,CAAC;IAClD,MAAM,MAAM,EAAE,KAAK,CAAC,UAAU,CAAqB,CAAC;IACpD,MAAM,KAAK,EAAE,KAAK,CAAC,IAAI,CAAmB,CAAC;IAElD;;;;;;;OAOG;IACI,MAAM,MAAM,GAAI,CAAC,SAAS;QAAE,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAA;KAAE,EACtE,QAAQ,CAAC,EACT,kBAAkB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,oBAAoB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1C,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAEvC,CAAC;CACH"}
package/dist/serde_api.js CHANGED
@@ -1,93 +1,157 @@
1
- //#region src/serde_api.ts
2
- var BinarySerde = class {
3
- contentType = "application/octet-stream";
4
- serialize(value) {
5
- return value;
6
- }
7
- deserialize(data) {
8
- return data;
9
- }
10
- };
11
- var VoidSerde = class {
12
- serialize(value) {
13
- if (value !== void 0) throw new Error("Expected undefined value");
14
- return new Uint8Array(0);
15
- }
16
- deserialize(data) {
17
- if (data.length !== 0) throw new Error("Expected empty data");
18
- }
19
- };
20
- var StandardSchemaSerde = class {
21
- contentType = "application/json";
22
- jsonSchema;
23
- constructor(schema, validateOptions, jsonSchemaOptions) {
24
- this.schema = schema;
25
- this.validateOptions = validateOptions;
26
- const standard = schema["~standard"];
27
- if (isStandardJSONSchemaV1(standard)) try {
28
- this.jsonSchema = standard.jsonSchema.output({
29
- target: "draft-2020-12",
30
- libraryOptions: jsonSchemaOptions
31
- });
32
- } catch {
33
- this.jsonSchema = void 0;
34
- }
35
- const testResult = standard.validate(void 0);
36
- if (testResult && typeof testResult === "object" && "then" in testResult) {} else if (!testResult.issues) this.contentType = void 0;
37
- }
38
- serialize(value) {
39
- if (value === void 0) return new Uint8Array(0);
40
- return new TextEncoder().encode(JSON.stringify(value));
41
- }
42
- deserialize(data) {
43
- const js = data.length === 0 ? void 0 : JSON.parse(new TextDecoder().decode(data));
44
- const result = this.schema["~standard"].validate(js, this.validateOptions);
45
- if (result && typeof result === "object" && "then" in result) throw new TypeError("Async validation is not supported in Serde. Restate SDK supports only synchronous validation.");
46
- if (result.issues) {
47
- const errorMessages = result.issues.map(formatStandardSchemaIssue).join("\n");
48
- throw new TypeError(`Standard schema validation failed:\n${errorMessages}`);
49
- }
50
- return result.value;
51
- }
52
- };
1
+ /*
2
+ * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH
3
+ *
4
+ * This file is part of the Restate SDK for Node.js/TypeScript,
5
+ * which is released under the MIT license.
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
10
+ */
11
+ class BinarySerde {
12
+ contentType = "application/octet-stream";
13
+ serialize(value) {
14
+ return value;
15
+ }
16
+ deserialize(data) {
17
+ return data;
18
+ }
19
+ }
20
+ class VoidSerde {
21
+ serialize(value) {
22
+ if (value !== undefined) {
23
+ throw new Error("Expected undefined value");
24
+ }
25
+ return new Uint8Array(0);
26
+ }
27
+ deserialize(data) {
28
+ if (data.length !== 0) {
29
+ throw new Error("Expected empty data");
30
+ }
31
+ }
32
+ }
33
+ class StandardSchemaSerde {
34
+ schema;
35
+ validateOptions;
36
+ contentType = "application/json";
37
+ jsonSchema;
38
+ constructor(schema, validateOptions, jsonSchemaOptions) {
39
+ this.schema = schema;
40
+ this.validateOptions = validateOptions;
41
+ // Extract JSON schema if available
42
+ const standard = schema["~standard"];
43
+ if (isStandardJSONSchemaV1(standard)) {
44
+ try {
45
+ this.jsonSchema = standard.jsonSchema.output({
46
+ target: "draft-2020-12",
47
+ libraryOptions: jsonSchemaOptions,
48
+ });
49
+ }
50
+ catch {
51
+ // If JSON schema generation fails, leave it undefined
52
+ this.jsonSchema = undefined;
53
+ }
54
+ }
55
+ // Check if schema is for void/undefined type
56
+ // Standard Schema doesn't have a direct way to detect void types,
57
+ // so we serialize undefined and check if validation succeeds
58
+ const testResult = standard.validate(undefined);
59
+ // Handle both sync and async validation results
60
+ if (testResult && typeof testResult === "object" && "then" in testResult) {
61
+ // If it's a Promise, we can't determine contentType synchronously
62
+ // Keep contentType as "application/json"
63
+ }
64
+ else if (!testResult.issues) {
65
+ this.contentType = undefined;
66
+ }
67
+ }
68
+ serialize(value) {
69
+ if (value === undefined) {
70
+ return new Uint8Array(0);
71
+ }
72
+ return new TextEncoder().encode(JSON.stringify(value));
73
+ }
74
+ deserialize(data) {
75
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76
+ const js = data.length === 0
77
+ ? undefined
78
+ : JSON.parse(new TextDecoder().decode(data));
79
+ const result = this.schema["~standard"].validate(js, this.validateOptions);
80
+ // Standard Schema validate can return a Promise, but Serde must be synchronous
81
+ if (result && typeof result === "object" && "then" in result) {
82
+ throw new TypeError("Async validation is not supported in Serde. Restate SDK supports only synchronous validation.");
83
+ }
84
+ if (result.issues) {
85
+ const errorMessages = result.issues
86
+ .map(formatStandardSchemaIssue)
87
+ .join("\n");
88
+ throw new TypeError(`Standard schema validation failed:\n${errorMessages}`);
89
+ }
90
+ return result.value;
91
+ }
92
+ }
53
93
  function formatStandardSchemaIssue(issue) {
54
- if (issue.path && issue.path.length > 0) return `* (at ${"/" + issue.path.map((p) => {
55
- if (typeof p === "object" && p !== null && "key" in p) return String(p.key);
56
- return String(p);
57
- }).join("/")}) ${issue.message}`;
58
- return `* ${issue.message}`;
94
+ if (issue.path && issue.path.length > 0) {
95
+ const jsonPointer = "/" +
96
+ issue.path
97
+ .map((p) => {
98
+ // Handle both PathSegment objects and primitive PropertyKey values
99
+ if (typeof p === "object" && p !== null && "key" in p) {
100
+ return String(p.key);
101
+ }
102
+ return String(p);
103
+ })
104
+ .join("/");
105
+ return `* (at ${jsonPointer}) ${issue.message}`;
106
+ }
107
+ return `* ${issue.message}`;
59
108
  }
60
109
  function isStandardJSONSchemaV1(standard) {
61
- return standard != void 0 && "jsonSchema" in standard && typeof standard.jsonSchema === "object" && standard.jsonSchema !== null && "output" in standard.jsonSchema && typeof standard.jsonSchema.output === "function";
110
+ return (standard != undefined &&
111
+ "jsonSchema" in standard &&
112
+ typeof standard.jsonSchema === "object" &&
113
+ standard.jsonSchema !== null &&
114
+ "output" in standard.jsonSchema &&
115
+ typeof standard.jsonSchema.output === "function");
62
116
  }
63
- let serde;
64
- (function(_serde) {
65
- class JsonSerde {
66
- contentType = "application/json";
67
- constructor(jsonSchema) {
68
- this.jsonSchema = jsonSchema;
69
- }
70
- serialize(value) {
71
- if (value === void 0) return new Uint8Array(0);
72
- return new TextEncoder().encode(JSON.stringify(value));
73
- }
74
- deserialize(data) {
75
- if (data.length === 0) return;
76
- return JSON.parse(new TextDecoder().decode(data));
77
- }
78
- schema(schema) {
79
- return new JsonSerde(schema);
80
- }
81
- }
82
- _serde.JsonSerde = JsonSerde;
83
- _serde.json = new JsonSerde();
84
- _serde.binary = new BinarySerde();
85
- _serde.empty = new VoidSerde();
86
- _serde.schema = (schema, validateOptions, jsonSchemaOptions) => {
87
- return new StandardSchemaSerde(schema, validateOptions, jsonSchemaOptions);
88
- };
117
+ export var serde;
118
+ (function (serde) {
119
+ class JsonSerde {
120
+ jsonSchema;
121
+ contentType = "application/json";
122
+ constructor(jsonSchema) {
123
+ this.jsonSchema = jsonSchema;
124
+ }
125
+ serialize(value) {
126
+ if (value === undefined) {
127
+ return new Uint8Array(0);
128
+ }
129
+ return new TextEncoder().encode(JSON.stringify(value));
130
+ }
131
+ deserialize(data) {
132
+ if (data.length === 0) {
133
+ return undefined;
134
+ }
135
+ return JSON.parse(new TextDecoder().decode(data));
136
+ }
137
+ schema(schema) {
138
+ return new JsonSerde(schema);
139
+ }
140
+ }
141
+ serde.JsonSerde = JsonSerde;
142
+ serde.json = new JsonSerde();
143
+ serde.binary = new BinarySerde();
144
+ serde.empty = new VoidSerde();
145
+ /**
146
+ * A Standard Schema-based serde.
147
+ *
148
+ * @param schema the standard schema
149
+ * @param validateOptions options passed to `StandardSchemaV1.Options.libraryOptions` when validating
150
+ * @param jsonSchemaOptions options passed to `StandardJsonSchemaV1.Options.libraryOptions` for code generation
151
+ * @returns a serde that will validate the data with the standard schema
152
+ */
153
+ serde.schema = (schema, validateOptions, jsonSchemaOptions) => {
154
+ return new StandardSchemaSerde(schema, validateOptions, jsonSchemaOptions);
155
+ };
89
156
  })(serde || (serde = {}));
90
-
91
- //#endregion
92
- export { serde };
93
157
  //# sourceMappingURL=serde_api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serde_api.js","names":["schema: T","validateOptions?: Record<string, unknown>","jsonSchema?: object"],"sources":["../src/serde_api.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH\n *\n * This file is part of the Restate SDK for Node.js/TypeScript,\n * which is released under the MIT license.\n *\n * You can find a copy of the license in file LICENSE in the root\n * directory of this repository or package, or at\n * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-namespace */\n\nimport type {\n StandardJSONSchemaV1,\n StandardSchemaV1,\n} from \"./standard_schema.js\";\n\n/**\n * Serializer/deserializer pair for any Restate-managed value of type `T` —\n * handler inputs and outputs, service state, side-effect results,\n * awakeables, durable promises, and so on.\n *\n * A `Serde<T>` is responsible for two conversions:\n *\n * - **Wire format**: `serialize` / `deserialize` convert a value `T` to and\n * from the raw bytes that flow over the network and get stored in the\n * journal.\n * - **JSON preview (optional)**: `preview.toJsonString` /\n * `preview.fromJsonString` convert a value `T` to and from a JSON string,\n * used by tooling to render and edit values that humans can read.\n *\n * It also advertises metadata (`contentType`, `jsonSchema`) that surfaces in\n * service discovery.\n */\nexport interface Serde<T> {\n /**\n * MIME type of the bytes produced by `serialize` (and accepted by\n * `deserialize`).\n */\n contentType?: string;\n\n /**\n * Optional JSON Schema describing the logical shape of `T`. Surfaced in\n * discovery so that tooling can generate forms, auto-complete payloads,\n * etc. Has no effect on serialization at runtime.\n */\n jsonSchema?: object;\n\n /**\n * Optional bridge between the serde's wire format and a JSON\n * representation that humans (and tooling like the Restate UI) can read\n * and edit.\n *\n * Only useful for serdes whose wire format isn't already plain JSON —\n * protobuf, MessagePack, length-prefixed binary, JSON variants that need\n * post-processing for bigints/dates, etc. Both methods may be async if the\n * conversion needs I/O.\n *\n * ### Preview flow\n *\n * Together with `serialize` / `deserialize`, the four functions chain in\n * both directions between a JSON string and on-the-wire bytes:\n *\n * ```text\n * JSON string ──fromJsonString──► T ──serialize──► wire bytes\n * wire bytes ──deserialize────► T ──toJsonString──► JSON string\n * ```\n *\n * The split keeps `serialize` / `deserialize` responsible for the full\n * on-the-wire format; `preview` only handles the JSON ↔ `T` bridge.\n *\n * @example\n * ```ts\n * // Wire format is protobuf; the protobuf-es runtime already ships\n * // `toJsonString` / `fromJsonString`, so preview is a direct pass-through.\n * import {\n * fromBinary,\n * fromJsonString,\n * toBinary,\n * toJsonString,\n * } from \"@bufbuild/protobuf\";\n * import { PersonSchema, type Person } from \"./person_pb.js\";\n *\n * const personSerde: Serde<Person> = {\n * contentType: \"application/protobuf\",\n * serialize(message) { return toBinary(PersonSchema, message); },\n * deserialize(bytes) { return fromBinary(PersonSchema, bytes); },\n * preview: {\n * toJsonString: (v) => toJsonString(PersonSchema, v),\n * fromJsonString: (j) => fromJsonString(PersonSchema, j),\n * },\n * };\n * ```\n */\n preview?: {\n /**\n * Convert a value into a JSON string for display or editing by humans.\n * The returned string must round-trip through `fromJsonString` back to\n * the same logical value.\n */\n toJsonString(value: T): Promise<string> | string;\n\n /**\n * Parse a human-supplied JSON string back into a value of type `T`.\n * Should throw (or reject) if `json` is invalid for this serde.\n */\n fromJsonString(json: string): Promise<T> | T;\n };\n\n /**\n * Convert a value of type `T` into its on-the-wire bytes. This is the\n * format Restate sends between services and persists in the journal.\n *\n * Must be the inverse of `deserialize` — `deserialize(serialize(v))`\n * should produce a value equivalent to `v`.\n */\n serialize(value: T): Uint8Array;\n\n /**\n * Convert on-the-wire bytes back into a value of type `T`. Must be the\n * inverse of `serialize`.\n *\n * May throw if `data` doesn't conform to the expected wire format.\n */\n deserialize(data: Uint8Array): T;\n}\n\nclass BinarySerde implements Serde<Uint8Array> {\n contentType = \"application/octet-stream\";\n\n serialize(value: Uint8Array): Uint8Array {\n return value;\n }\n\n deserialize(data: Uint8Array): Uint8Array {\n return data;\n }\n}\n\nclass VoidSerde implements Serde<void> {\n serialize(value: any): Uint8Array {\n if (value !== undefined) {\n throw new Error(\"Expected undefined value\");\n }\n return new Uint8Array(0);\n }\n\n deserialize(data: Uint8Array): void {\n if (data.length !== 0) {\n throw new Error(\"Expected empty data\");\n }\n }\n}\n\nclass StandardSchemaSerde<\n T extends { \"~standard\": StandardSchemaV1.Props },\n> implements Serde<StandardSchemaV1.InferOutput<T>> {\n contentType? = \"application/json\";\n jsonSchema?: object | undefined;\n\n constructor(\n private readonly schema: T,\n private readonly validateOptions?: Record<string, unknown>,\n jsonSchemaOptions?: Record<string, unknown>\n ) {\n // Extract JSON schema if available\n const standard = schema[\"~standard\"];\n if (isStandardJSONSchemaV1(standard)) {\n try {\n this.jsonSchema = (\n standard as unknown as StandardJSONSchemaV1.Props\n ).jsonSchema.output({\n target: \"draft-2020-12\",\n libraryOptions: jsonSchemaOptions,\n });\n } catch {\n // If JSON schema generation fails, leave it undefined\n this.jsonSchema = undefined;\n }\n }\n\n // Check if schema is for void/undefined type\n // Standard Schema doesn't have a direct way to detect void types,\n // so we serialize undefined and check if validation succeeds\n const testResult = standard.validate(undefined);\n // Handle both sync and async validation results\n if (testResult && typeof testResult === \"object\" && \"then\" in testResult) {\n // If it's a Promise, we can't determine contentType synchronously\n // Keep contentType as \"application/json\"\n } else if (!testResult.issues) {\n this.contentType = undefined;\n }\n }\n\n serialize(value: StandardSchemaV1.InferOutput<T>): Uint8Array {\n if (value === undefined) {\n return new Uint8Array(0);\n }\n return new TextEncoder().encode(JSON.stringify(value));\n }\n\n deserialize(data: Uint8Array): StandardSchemaV1.InferOutput<T> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const js =\n data.length === 0\n ? undefined\n : JSON.parse(new TextDecoder().decode(data));\n\n const result = this.schema[\"~standard\"].validate(js, this.validateOptions);\n\n // Standard Schema validate can return a Promise, but Serde must be synchronous\n if (result && typeof result === \"object\" && \"then\" in result) {\n throw new TypeError(\n \"Async validation is not supported in Serde. Restate SDK supports only synchronous validation.\"\n );\n }\n\n if (result.issues) {\n const errorMessages = result.issues\n .map(formatStandardSchemaIssue)\n .join(\"\\n\");\n throw new TypeError(\n `Standard schema validation failed:\\n${errorMessages}`\n );\n }\n\n return result.value as StandardSchemaV1.InferOutput<T>;\n }\n}\n\nfunction formatStandardSchemaIssue(issue: StandardSchemaV1.Issue): string {\n if (issue.path && issue.path.length > 0) {\n const jsonPointer =\n \"/\" +\n issue.path\n .map((p) => {\n // Handle both PathSegment objects and primitive PropertyKey values\n if (typeof p === \"object\" && p !== null && \"key\" in p) {\n return String(p.key);\n }\n return String(p);\n })\n .join(\"/\");\n return `* (at ${jsonPointer}) ${issue.message}`;\n }\n return `* ${issue.message}`;\n}\n\nfunction isStandardJSONSchemaV1(standard: StandardSchemaV1.Props): boolean {\n return (\n standard != undefined &&\n \"jsonSchema\" in standard &&\n typeof standard.jsonSchema === \"object\" &&\n standard.jsonSchema !== null &&\n \"output\" in standard.jsonSchema &&\n typeof standard.jsonSchema.output === \"function\"\n );\n}\n\nexport namespace serde {\n export class JsonSerde<T> implements Serde<T | undefined> {\n contentType = \"application/json\";\n\n constructor(readonly jsonSchema?: object) {}\n\n serialize(value: T): Uint8Array {\n if (value === undefined) {\n return new Uint8Array(0);\n }\n return new TextEncoder().encode(JSON.stringify(value));\n }\n\n deserialize(data: Uint8Array): T | undefined {\n if (data.length === 0) {\n return undefined;\n }\n return JSON.parse(new TextDecoder().decode(data)) as T;\n }\n\n schema<U>(schema: object): Serde<U> {\n return new JsonSerde<U>(schema) as Serde<U>;\n }\n }\n\n export const json: JsonSerde<any> = new JsonSerde<any>();\n export const binary: Serde<Uint8Array> = new BinarySerde();\n export const empty: Serde<void> = new VoidSerde();\n\n /**\n * A Standard Schema-based serde.\n *\n * @param schema the standard schema\n * @param validateOptions options passed to `StandardSchemaV1.Options.libraryOptions` when validating\n * @param jsonSchemaOptions options passed to `StandardJsonSchemaV1.Options.libraryOptions` for code generation\n * @returns a serde that will validate the data with the standard schema\n */\n export const schema = <T extends { \"~standard\": StandardSchemaV1.Props }>(\n schema: T,\n validateOptions?: Record<string, unknown>,\n jsonSchemaOptions?: Record<string, unknown>\n ): Serde<StandardSchemaV1.InferOutput<T>> => {\n return new StandardSchemaSerde(schema, validateOptions, jsonSchemaOptions);\n };\n}\n"],"mappings":";AAiIA,IAAM,cAAN,MAA+C;CAC7C,cAAc;CAEd,UAAU,OAA+B;AACvC,SAAO;;CAGT,YAAY,MAA8B;AACxC,SAAO;;;AAIX,IAAM,YAAN,MAAuC;CACrC,UAAU,OAAwB;AAChC,MAAI,UAAU,OACZ,OAAM,IAAI,MAAM,2BAA2B;AAE7C,SAAO,IAAI,WAAW,EAAE;;CAG1B,YAAY,MAAwB;AAClC,MAAI,KAAK,WAAW,EAClB,OAAM,IAAI,MAAM,sBAAsB;;;AAK5C,IAAM,sBA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