@restatedev/restate-sdk-zod 1.13.0 → 1.14.1

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.
@@ -1,8 +1,106 @@
1
1
  //#region ../restate-sdk-core/src/serde_api.d.ts
2
+ /**
3
+ * Serializer/deserializer pair for any Restate-managed value of type `T` —
4
+ * handler inputs and outputs, service state, side-effect results,
5
+ * awakeables, durable promises, and so on.
6
+ *
7
+ * A `Serde<T>` is responsible for two conversions:
8
+ *
9
+ * - **Wire format**: `serialize` / `deserialize` convert a value `T` to and
10
+ * from the raw bytes that flow over the network and get stored in the
11
+ * journal.
12
+ * - **JSON preview (optional)**: `preview.toJsonString` /
13
+ * `preview.fromJsonString` convert a value `T` to and from a JSON string,
14
+ * used by tooling to render and edit values that humans can read.
15
+ *
16
+ * It also advertises metadata (`contentType`, `jsonSchema`) that surfaces in
17
+ * service discovery.
18
+ */
2
19
  interface Serde<T> {
20
+ /**
21
+ * MIME type of the bytes produced by `serialize` (and accepted by
22
+ * `deserialize`).
23
+ */
3
24
  contentType?: string;
25
+ /**
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
+ */
4
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`.
96
+ */
5
97
  serialize(value: T): Uint8Array;
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
+ */
6
104
  deserialize(data: Uint8Array): T;
7
105
  }
8
106
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"serde_api.d.cts","names":[],"sources":["../../../../restate-sdk-core/src/serde_api.ts"],"sourcesContent":[],"mappings":";AAmBiB,UAAA,KAAK,CAAA,CAAA,CAAA,CAAA;EAIH,WAAA,CAAA,EAAA,MAAA;EAAI,UAAA,CAAA,EAAA,MAAA;EAEH,SAAA,CAAA,KAAA,EAFD,CAEC,CAAA,EAFG,UAEH;EAAa,WAAA,CAAA,IAAA,EAAb,UAAa,CAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"serde_api.d.cts","names":[],"sources":["../../../../restate-sdk-core/src/serde_api.ts"],"sourcesContent":[],"mappings":";AAoCA;;;;;;;;;;;;;;;;;UAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkEO,IAAI;;;;;kCAMM,QAAQ,KAAK;;;;;;;;;mBAU5B,IAAI;;;;;;;oBAQH,aAAa"}
@@ -1,8 +1,106 @@
1
1
  //#region ../restate-sdk-core/src/serde_api.d.ts
2
+ /**
3
+ * Serializer/deserializer pair for any Restate-managed value of type `T` —
4
+ * handler inputs and outputs, service state, side-effect results,
5
+ * awakeables, durable promises, and so on.
6
+ *
7
+ * A `Serde<T>` is responsible for two conversions:
8
+ *
9
+ * - **Wire format**: `serialize` / `deserialize` convert a value `T` to and
10
+ * from the raw bytes that flow over the network and get stored in the
11
+ * journal.
12
+ * - **JSON preview (optional)**: `preview.toJsonString` /
13
+ * `preview.fromJsonString` convert a value `T` to and from a JSON string,
14
+ * used by tooling to render and edit values that humans can read.
15
+ *
16
+ * It also advertises metadata (`contentType`, `jsonSchema`) that surfaces in
17
+ * service discovery.
18
+ */
2
19
  interface Serde<T> {
20
+ /**
21
+ * MIME type of the bytes produced by `serialize` (and accepted by
22
+ * `deserialize`).
23
+ */
3
24
  contentType?: string;
25
+ /**
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
+ */
4
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`.
96
+ */
5
97
  serialize(value: T): Uint8Array;
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
+ */
6
104
  deserialize(data: Uint8Array): T;
7
105
  }
8
106
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"serde_api.d.ts","names":[],"sources":["../../../../restate-sdk-core/src/serde_api.ts"],"sourcesContent":[],"mappings":";AAmBiB,UAAA,KAAK,CAAA,CAAA,CAAA,CAAA;EAIH,WAAA,CAAA,EAAA,MAAA;EAAI,UAAA,CAAA,EAAA,MAAA;EAEH,SAAA,CAAA,KAAA,EAFD,CAEC,CAAA,EAFG,UAEH;EAAa,WAAA,CAAA,IAAA,EAAb,UAAa,CAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"serde_api.d.ts","names":[],"sources":["../../../../restate-sdk-core/src/serde_api.ts"],"sourcesContent":[],"mappings":";AAoCA;;;;;;;;;;;;;;;;;UAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkEO,IAAI;;;;;kCAMM,QAAQ,KAAK;;;;;;;;;mBAU5B,IAAI;;;;;;;oBAQH,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk-zod",
3
- "version": "1.13.0",
3
+ "version": "1.14.1",
4
4
  "description": "Typescript SDK for Restate",
5
5
  "author": "Restate Developers",
6
6
  "email": "code@restate.dev",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {},
35
35
  "devDependencies": {
36
36
  "zod": "^4.2.0",
37
- "@restatedev/restate-sdk-core": "1.13.0"
37
+ "@restatedev/restate-sdk-core": "1.14.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "zod": "^3.25.0 || ^4.0.0"