@procedures/client 0.22.0 → 0.23.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.d.ts +2 -2
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/browser.js +2 -0
  6. package/dist/browser.js.map +1 -1
  7. package/dist/client/client.d.ts +10 -3
  8. package/dist/client/client.d.ts.map +1 -1
  9. package/dist/client/client.js +14 -2
  10. package/dist/client/client.js.map +1 -1
  11. package/dist/events/publisher.d.ts +9 -4
  12. package/dist/events/publisher.d.ts.map +1 -1
  13. package/dist/events/publisher.js +39 -11
  14. package/dist/events/publisher.js.map +1 -1
  15. package/dist/procedures/collection/partition.d.ts +21 -0
  16. package/dist/procedures/collection/partition.d.ts.map +1 -1
  17. package/dist/procedures/collection/partition.js +27 -0
  18. package/dist/procedures/collection/partition.js.map +1 -1
  19. package/dist/procedures/envelope.d.ts +119 -0
  20. package/dist/procedures/envelope.d.ts.map +1 -0
  21. package/dist/procedures/envelope.js +371 -0
  22. package/dist/procedures/envelope.js.map +1 -0
  23. package/dist/procedures/index.d.ts +2 -0
  24. package/dist/procedures/index.d.ts.map +1 -1
  25. package/dist/procedures/index.js +2 -0
  26. package/dist/procedures/index.js.map +1 -1
  27. package/dist/server/procedure-server.d.ts +13 -1
  28. package/dist/server/procedure-server.d.ts.map +1 -1
  29. package/dist/server/procedure-server.js +16 -2
  30. package/dist/server/procedure-server.js.map +1 -1
  31. package/dist/server/types.d.ts +11 -0
  32. package/dist/server/types.d.ts.map +1 -1
  33. package/dist/server/types.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/browser.ts +9 -0
  36. package/src/client/client.ts +17 -4
  37. package/src/events/publisher.ts +47 -15
  38. package/src/procedures/collection/partition.ts +32 -0
  39. package/src/procedures/envelope.ts +468 -0
  40. package/src/procedures/index.ts +4 -0
  41. package/src/server/procedure-server.ts +23 -3
  42. package/src/server/types.ts +11 -0
@@ -147,6 +147,33 @@ export function assertTopicsApart(plain, hasPartitions) {
147
147
  throw new CollectionTopicCollisionError(collection, shared.collection, shared.partition);
148
148
  }
149
149
  }
150
+ /**
151
+ * This function gives the check of a subscriber that listens to the plain topic of a collection
152
+ * (roadmap CLI-70, decision D23). When no partition has that topic, it gives undefined. The check
153
+ * throws `FORBIDDEN` (reason `partition-not-allowed`) while the repository of the call gives
154
+ * partitions to the collection of that partition.
155
+ *
156
+ * - The plain topic of `a.b` is also the topic of the partition `b` of `a`. Thus a subscriber of
157
+ * that topic gets the events of the partition `b` of `a`.
158
+ * - `ProcedureServer` refuses a storage of `a.b` while `a` has partitions (roadmap CLI-57). A
159
+ * collection `a.b` with partitions and no storage passes that check. When its resolver gives no
160
+ * partition, a subscriber of `a.b` listens to the plain topic. This check refuses it.
161
+ * - `EventPublisher` does the check at the start of a subscription, at each re-check and before
162
+ * each event. Thus partitions of `a` that come later also end the subscription.
163
+ *
164
+ * @param ctx - The context of the subscription: the check reads its repository each time
165
+ * @param collection - The collection whose plain topic the subscriber listens to
166
+ */
167
+ export function plainTopicCheck(ctx, collection) {
168
+ const shared = partitionOfPlainTopic(collection);
169
+ if (!shared)
170
+ return undefined;
171
+ return () => {
172
+ if (!ctx.repository?.hasPartitions?.(shared.collection))
173
+ return;
174
+ throw partitionRefused(ctx, `The call has no partition of ${collection}, and the plain topic "${collectionChangeTopic(collection)}" is also the topic of the partition "${shared.partition}" of ${shared.collection} (roadmap CLI-70)`);
175
+ };
176
+ }
150
177
  // The parse of a topic lives in topic.ts, with the encode (roadmap CLI-42)
151
178
  export { collectionTopicPartition, collectionTopicTarget } from "./topic.js";
152
179
  //# sourceMappingURL=partition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"partition.js","sourceRoot":"","sources":["../../../src/procedures/collection/partition.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAA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,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;YAAE,OAAO;QAChE,MAAM,gBAAgB,CACpB,GAAG,EACH,gCAAgC,UAAU,0BAA0B,qBAAqB,CAAC,UAAU,CAAC,yCAAyC,MAAM,CAAC,SAAS,QAAQ,MAAM,CAAC,UAAU,mBAAmB,CAC3M,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The envelope form of a program (coeval, decisions D6, D9 and D10, roadmap item M7).
3
+ *
4
+ * A document of coeval is an envelope: `{ type, value }`. The header can also have `name` and
5
+ * `own`. In the envelope form of a program:
6
+ *
7
+ * - A call is `{ type: path, value: input }`. The type is the path of a procedure, as an array of
8
+ * keys. A ref into the world, `{ type: "ref", value: ["world", ...path] }`, is also a type.
9
+ * - A ref is `{ type: "ref", value: ["names", name, ...fields] }`. The name `last` reads the result
10
+ * of the step before.
11
+ * - A literal is `{ type: "literal", value }`. Nothing in its value runs.
12
+ *
13
+ * The envelope form is a surface. `fromEnvelopeProgram()` changes it into the `$proc` form, and
14
+ * `hydrateInput()` starts that form. In the input of a `$proc` program, an envelope is data. Thus
15
+ * the root of a program decides its form, and the old programs do not change.
16
+ */
17
+ import { type AnyProcedureRef, type ProcedureRefJson } from "./ref.js";
18
+ /** This type is a path of keys from a root of the context (coeval D10). */
19
+ export type EnvelopePath = readonly (string | number)[];
20
+ /**
21
+ * This document reads a value: `{ type: "ref", value: [root, step, ...] }` (coeval D10). A client
22
+ * program reads only the root `names`. A ref into the world is only the type of a call.
23
+ */
24
+ export interface EnvelopeRef {
25
+ readonly type: "ref";
26
+ readonly value: EnvelopePath;
27
+ }
28
+ /** This document gives its value as data. Nothing in the value runs. */
29
+ export interface EnvelopeLiteral {
30
+ readonly type: "literal";
31
+ readonly value: unknown;
32
+ }
33
+ /**
34
+ * This document is a call in the envelope form (coeval D9). The type is the path of the
35
+ * procedure, or a ref into the world. The value is the input. A value of `null` gives no input.
36
+ */
37
+ export interface EnvelopeProgram {
38
+ /** The path of the procedure, or a ref into the world: `{ type: "ref", value: ["world", ...path] }`. */
39
+ readonly type: readonly string[] | EnvelopeRef;
40
+ /** The input of the call. `null` gives a call without input. */
41
+ readonly value: unknown;
42
+ /** The name of the result. A later step of `client.chain` reads it as `["names", name]`. */
43
+ readonly name?: string | undefined;
44
+ /** The own entries of the document. A client program has none: the conversion refuses this key. */
45
+ readonly own?: unknown;
46
+ }
47
+ /**
48
+ * This function gives true if a value is a program in the envelope form. The value is a plain
49
+ * object with the keys `type` and `value`, and only the header keys `name` and `own` in
50
+ * addition. The type is a procedure path (an array of one or more strings), or a ref into the
51
+ * world: `{ type: "ref", value: ["world", ...path] }`.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * isEnvelopeProgram({ type: ["client", "add"], value: { a: 1, b: 2 } }); // true
56
+ * isEnvelopeProgram({ $proc: ["client", "add"], input: { a: 1, b: 2 } }); // false
57
+ * ```
58
+ */
59
+ export declare function isEnvelopeProgram(value: unknown): value is EnvelopeProgram;
60
+ /**
61
+ * This function changes a program in the envelope form into the `$proc` form. `hydrateInput()`
62
+ * and `client.exec()` start the result.
63
+ *
64
+ * The conversion:
65
+ * - A call gives `{ $proc: path, input }`. A value of `null` gives a call without `input`. The
66
+ * header `name` gives `$name`.
67
+ * - A ref `["names", "last"]` gives `{ $ref: "$last" }`. A ref `["names", name, ...fields]` gives
68
+ * `{ $ref: "name.field" }`.
69
+ * - A literal gives `{ $literal: value }`.
70
+ * - An object with a `$proc`, `$ref` or `$literal` key is data: the function puts it in a
71
+ * `$literal`. A runtime `ProcedureRef` is data too.
72
+ * - The function copies the arrays and the other plain objects. Other values stay the same.
73
+ *
74
+ * The function throws an error for a ref with a root other than `names`, and for a bad key of a
75
+ * ref path. It also throws an error for a header on a ref or a literal, and for the key `own`.
76
+ * The envelope form has no `$when`: a program that needs it keeps the `$proc` form.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * fromEnvelopeProgram({
81
+ * type: ["client", "multiply"],
82
+ * value: { a: { type: "ref", value: ["names", "item"] }, b: 10 },
83
+ * });
84
+ * // { $proc: ["client", "multiply"], input: { a: { $ref: "item" }, b: 10 } }
85
+ * ```
86
+ */
87
+ export declare function fromEnvelopeProgram(program: EnvelopeProgram): ProcedureRefJson;
88
+ /**
89
+ * This function changes a program in the `$proc` form into the envelope form, for a tool that
90
+ * shows it. `fromEnvelopeProgram()` changes the result back into the same program.
91
+ *
92
+ * The conversion:
93
+ * - A call gives `{ type: path, value: input }`. A call without input gives the value `null`.
94
+ * `$name` gives the header `name`.
95
+ * - `{ $ref: "$last" }` gives `["names", "last"]`. `{ $ref: "a.b" }` gives `["names", "a", "b"]`.
96
+ * - `{ $literal: value }` gives a literal.
97
+ * - Data that the envelope form reads in a different way gives a literal. This data is an object
98
+ * with the shape of a call, a ref or a literal. It is also an object with a `$proc`, `$ref` or
99
+ * `$literal` key.
100
+ *
101
+ * The function throws an error for a program that the envelope form cannot keep:
102
+ * - a call with `$when`, or with a key other than the path, the input and the name,
103
+ * - a `$ref` object with other keys, or a ref to a step with the name `last`,
104
+ * - such data that holds a call, a `$ref` or a `$literal`.
105
+ *
106
+ * These programs keep the `$proc` form.
107
+ *
108
+ * The round trip gives the same program, with two exceptions. A call with the input `null`, and
109
+ * data that the envelope form reads in a different way, come back in a `$literal`. They give
110
+ * the same values.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * toEnvelopeProgram({ $proc: ["client", "add"], input: { a: { $ref: "$last" }, b: 1 }, $name: "sum" });
115
+ * // { type: ["client", "add"], value: { a: { type: "ref", value: ["names", "last"] }, b: 1 }, name: "sum" }
116
+ * ```
117
+ */
118
+ export declare function toEnvelopeProgram(program: AnyProcedureRef): EnvelopeProgram;
119
+ //# sourceMappingURL=envelope.d.ts.map
@@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**
2
+ * The envelope form of a program (coeval, decisions D6, D9 and D10, roadmap item M7).
3
+ *
4
+ * A document of coeval is an envelope: `{ type, value }`. The header can also have `name` and
5
+ * `own`. In the envelope form of a program:
6
+ *
7
+ * - A call is `{ type: path, value: input }`. The type is the path of a procedure, as an array of
8
+ * keys. A ref into the world, `{ type: "ref", value: ["world", ...path] }`, is also a type.
9
+ * - A ref is `{ type: "ref", value: ["names", name, ...fields] }`. The name `last` reads the result
10
+ * of the step before.
11
+ * - A literal is `{ type: "literal", value }`. Nothing in its value runs.
12
+ *
13
+ * The envelope form is a surface. `fromEnvelopeProgram()` changes it into the `$proc` form, and
14
+ * `hydrateInput()` starts that form. In the input of a `$proc` program, an envelope is data. Thus
15
+ * the root of a program decides its form, and the old programs do not change.
16
+ */
17
+ import { LITERAL_KEY, MAX_DATA_DEPTH, OUTPUT_REF_KEY, PROCEDURE_JSON_KEY, PROCEDURE_NAME_KEY, PROCEDURE_WHEN_KEY, isAnyProcedureRef, isLiteral, isOutputRef, isPlainObject, isProcedureRef, normalizeRef, } from "./ref.js";
18
+ // =============================================================================
19
+ // The shapes of the envelope form
20
+ // =============================================================================
21
+ /** The keys of an envelope (coeval D6). */
22
+ const HEADER_KEYS = new Set(["type", "value", "name", "own"]);
23
+ /** The keys that make an object a construct of the `$proc` form. */
24
+ const NATIVE_KEYS = [PROCEDURE_JSON_KEY, OUTPUT_REF_KEY, LITERAL_KEY];
25
+ /** The keys of a `$proc` call that the envelope form keeps (`$when` gives its own error). */
26
+ const CALL_KEYS = new Set([PROCEDURE_JSON_KEY, "input", PROCEDURE_NAME_KEY, PROCEDURE_WHEN_KEY]);
27
+ /** The keys of a runtime `ProcedureRef` that the envelope form keeps. */
28
+ const RUNTIME_CALL_KEYS = new Set(["path", "input", PROCEDURE_NAME_KEY, PROCEDURE_WHEN_KEY]);
29
+ const REF_TYPE = "ref";
30
+ const LITERAL_TYPE = "literal";
31
+ const NAMES_ROOT = "names";
32
+ const WORLD_ROOT = "world";
33
+ /** The name of the result of the step before, in the envelope form. */
34
+ const LAST_NAME = "last";
35
+ /** The name of the result of the step before, in the `$proc` form. */
36
+ const NATIVE_LAST = "$last";
37
+ /** This function gives true if a value is a plain object with `type`, `value` and only header keys. */
38
+ function isEnvelopeShape(value) {
39
+ return (isPlainObject(value) &&
40
+ Object.hasOwn(value, "type") &&
41
+ Object.hasOwn(value, "value") &&
42
+ Object.keys(value).every((key) => HEADER_KEYS.has(key)));
43
+ }
44
+ /** This function gives true if a value is a procedure path: an array of one or more strings. */
45
+ function isProcedurePath(value) {
46
+ return Array.isArray(value) && value.length > 0 && value.every((key) => typeof key === "string");
47
+ }
48
+ /** This function gives the procedure path of the type of a call, or undefined for another type. */
49
+ function callPath(type) {
50
+ if (isProcedurePath(type))
51
+ return [...type];
52
+ if (!isEnvelopeShape(type) || type.type !== REF_TYPE || Object.keys(type).length !== 2)
53
+ return undefined;
54
+ const path = type.value;
55
+ if (!Array.isArray(path) || path[0] !== WORLD_ROOT)
56
+ return undefined;
57
+ const steps = path.slice(1);
58
+ return isProcedurePath(steps) ? [...steps] : undefined;
59
+ }
60
+ /** This function gives the kind of an envelope, or undefined for data. */
61
+ function envelopeKind(value) {
62
+ if (!isEnvelopeShape(value))
63
+ return undefined;
64
+ if (callPath(value.type))
65
+ return "call";
66
+ if (value.type === REF_TYPE)
67
+ return "ref";
68
+ if (value.type === LITERAL_TYPE)
69
+ return "literal";
70
+ if (isPlainObject(value.type) && value.type["type"] === REF_TYPE)
71
+ return "bad-type";
72
+ return undefined;
73
+ }
74
+ /** This function gives true if a plain object has a key of the `$proc` form. */
75
+ function hasNativeKey(value) {
76
+ return NATIVE_KEYS.some((key) => Object.hasOwn(value, key));
77
+ }
78
+ /** This function gives a short JSON text of a value for an error message. */
79
+ function preview(value) {
80
+ let text;
81
+ try {
82
+ text = JSON.stringify(value);
83
+ }
84
+ catch {
85
+ text = undefined;
86
+ }
87
+ text ??= String(value);
88
+ return text.length > 80 ? `${text.slice(0, 77)}...` : text;
89
+ }
90
+ /**
91
+ * This function gives the result of `fn` one level deeper in a walk of a program. It refuses an
92
+ * object that contains itself, and a program deeper than `MAX_DATA_DEPTH`, as hydration does.
93
+ */
94
+ function within(value, path, depth, fn) {
95
+ if (depth > MAX_DATA_DEPTH) {
96
+ throw new Error(`The program has more than ${MAX_DATA_DEPTH} levels of nesting`);
97
+ }
98
+ if (path.has(value)) {
99
+ throw new Error("The program is cyclic (an object contains itself)");
100
+ }
101
+ path.add(value);
102
+ try {
103
+ return fn();
104
+ }
105
+ finally {
106
+ path.delete(value);
107
+ }
108
+ }
109
+ // =============================================================================
110
+ // The envelope form to the $proc form
111
+ // =============================================================================
112
+ /**
113
+ * This function gives true if a value is a program in the envelope form. The value is a plain
114
+ * object with the keys `type` and `value`, and only the header keys `name` and `own` in
115
+ * addition. The type is a procedure path (an array of one or more strings), or a ref into the
116
+ * world: `{ type: "ref", value: ["world", ...path] }`.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * isEnvelopeProgram({ type: ["client", "add"], value: { a: 1, b: 2 } }); // true
121
+ * isEnvelopeProgram({ $proc: ["client", "add"], input: { a: 1, b: 2 } }); // false
122
+ * ```
123
+ */
124
+ export function isEnvelopeProgram(value) {
125
+ return envelopeKind(value) === "call";
126
+ }
127
+ /**
128
+ * This function changes a program in the envelope form into the `$proc` form. `hydrateInput()`
129
+ * and `client.exec()` start the result.
130
+ *
131
+ * The conversion:
132
+ * - A call gives `{ $proc: path, input }`. A value of `null` gives a call without `input`. The
133
+ * header `name` gives `$name`.
134
+ * - A ref `["names", "last"]` gives `{ $ref: "$last" }`. A ref `["names", name, ...fields]` gives
135
+ * `{ $ref: "name.field" }`.
136
+ * - A literal gives `{ $literal: value }`.
137
+ * - An object with a `$proc`, `$ref` or `$literal` key is data: the function puts it in a
138
+ * `$literal`. A runtime `ProcedureRef` is data too.
139
+ * - The function copies the arrays and the other plain objects. Other values stay the same.
140
+ *
141
+ * The function throws an error for a ref with a root other than `names`, and for a bad key of a
142
+ * ref path. It also throws an error for a header on a ref or a literal, and for the key `own`.
143
+ * The envelope form has no `$when`: a program that needs it keeps the `$proc` form.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * fromEnvelopeProgram({
148
+ * type: ["client", "multiply"],
149
+ * value: { a: { type: "ref", value: ["names", "item"] }, b: 10 },
150
+ * });
151
+ * // { $proc: ["client", "multiply"], input: { a: { $ref: "item" }, b: 10 } }
152
+ * ```
153
+ */
154
+ export function fromEnvelopeProgram(program) {
155
+ if (!isEnvelopeProgram(program)) {
156
+ throw new Error(`fromEnvelopeProgram() requires a call: { "type": [procedure path], "value": input }. Got ${preview(program)}`);
157
+ }
158
+ const path = new Set();
159
+ return within(program, path, 0, () => fromCall(program, path, 0));
160
+ }
161
+ /** This function changes a call envelope into a `$proc` call. */
162
+ function fromCall(call, path, depth) {
163
+ const procedurePath = callPath(call.type);
164
+ if (call.own !== undefined) {
165
+ throw new Error(`A client program has no own entries: remove the key "own" of the call of ${preview(procedurePath)}`);
166
+ }
167
+ if (call.name !== undefined && typeof call.name !== "string") {
168
+ throw new Error(`The name of a call must be a string. The call of ${preview(procedurePath)} has the name ${preview(call.name)}`);
169
+ }
170
+ const native = { $proc: procedurePath };
171
+ // A call without input gets undefined, as a $proc call without `input` (PROGRAM-FORMAT section 1)
172
+ if (call.value !== null && call.value !== undefined)
173
+ native.input = fromValue(call.value, path, depth + 1);
174
+ if (call.name !== undefined)
175
+ native.$name = call.name;
176
+ return native;
177
+ }
178
+ /** This function refuses a header on an envelope that is not a call. */
179
+ function refuseHeader(envelope) {
180
+ for (const key of ["name", "own"]) {
181
+ if (envelope[key] !== undefined) {
182
+ throw new Error(`Only a call has a header. The ${String(envelope.type)} ${preview(envelope)} has the key "${key}"`);
183
+ }
184
+ }
185
+ }
186
+ /** This function gives the text of one key of a ref path. */
187
+ function keyText(key, refPath) {
188
+ if (typeof key === "string" && !key.includes("."))
189
+ return key;
190
+ if (typeof key === "number" && Number.isSafeInteger(key) && key >= 0)
191
+ return String(key);
192
+ throw new Error(`Each key of a ref path must be a string without a dot or an integer of 0 or more. ` +
193
+ `The key ${preview(key)} of the ref ${preview(refPath)} is not`);
194
+ }
195
+ /** This function changes a ref envelope into a `$ref` object. */
196
+ function fromRef(ref) {
197
+ refuseHeader(ref);
198
+ const refPath = ref.value;
199
+ if (!Array.isArray(refPath) || refPath.length === 0) {
200
+ throw new Error(`The value of a ref must be a path: [root, step, ...]. Got ${preview(refPath)}`);
201
+ }
202
+ const [root, ...steps] = refPath;
203
+ if (root !== NAMES_ROOT) {
204
+ const where = root === WORLD_ROOT ? ` A ref into the world is only the type of a call.` : "";
205
+ throw new Error(`A client program reads only the root "names". The ref ${preview(refPath)} has the root ${preview(root)}.${where}`);
206
+ }
207
+ if (steps.length === 0) {
208
+ throw new Error(`A ref to the root "names" needs a name: ["names", name, ...fields]. Got ${preview(refPath)}`);
209
+ }
210
+ const [name, ...fields] = steps.map((key) => keyText(key, refPath));
211
+ return { $ref: [name === LAST_NAME ? NATIVE_LAST : name, ...fields].join(".") };
212
+ }
213
+ /** This function changes a value of an envelope program into the `$proc` form. */
214
+ function fromValue(value, path, depth) {
215
+ if (value === null || typeof value !== "object")
216
+ return value;
217
+ if (Array.isArray(value)) {
218
+ return within(value, path, depth, () => value.map((item) => fromValue(item, path, depth + 1)));
219
+ }
220
+ // The $proc form is data in an envelope program: a runtime ref, and each object that
221
+ // hydration reads as a call or a $ref
222
+ if (isProcedureRef(value))
223
+ return { $literal: value };
224
+ if (!isPlainObject(value)) {
225
+ // Values that are not plain data (Date, Map, class instances) stay the same object
226
+ return isAnyProcedureRef(value) || isOutputRef(value) ? { $literal: value } : value;
227
+ }
228
+ switch (envelopeKind(value)) {
229
+ case "call":
230
+ return within(value, path, depth, () => fromCall(value, path, depth));
231
+ case "ref":
232
+ return fromRef(value);
233
+ case "literal":
234
+ refuseHeader(value);
235
+ return { $literal: value["value"] };
236
+ case "bad-type":
237
+ throw new Error(`The type of a call must be a procedure path or a ref into the world: ["world", ...path]. Got ${preview(value["type"])}`);
238
+ }
239
+ // An object of the $proc form is data in an envelope program
240
+ if (hasNativeKey(value))
241
+ return { $literal: value };
242
+ return within(value, path, depth, () =>
243
+ // Object.fromEntries makes own properties, also for a key such as "__proto__"
244
+ Object.fromEntries(Object.entries(value).map(([key, item]) => [key, fromValue(item, path, depth + 1)])));
245
+ }
246
+ // =============================================================================
247
+ // The $proc form to the envelope form
248
+ // =============================================================================
249
+ /**
250
+ * This function changes a program in the `$proc` form into the envelope form, for a tool that
251
+ * shows it. `fromEnvelopeProgram()` changes the result back into the same program.
252
+ *
253
+ * The conversion:
254
+ * - A call gives `{ type: path, value: input }`. A call without input gives the value `null`.
255
+ * `$name` gives the header `name`.
256
+ * - `{ $ref: "$last" }` gives `["names", "last"]`. `{ $ref: "a.b" }` gives `["names", "a", "b"]`.
257
+ * - `{ $literal: value }` gives a literal.
258
+ * - Data that the envelope form reads in a different way gives a literal. This data is an object
259
+ * with the shape of a call, a ref or a literal. It is also an object with a `$proc`, `$ref` or
260
+ * `$literal` key.
261
+ *
262
+ * The function throws an error for a program that the envelope form cannot keep:
263
+ * - a call with `$when`, or with a key other than the path, the input and the name,
264
+ * - a `$ref` object with other keys, or a ref to a step with the name `last`,
265
+ * - such data that holds a call, a `$ref` or a `$literal`.
266
+ *
267
+ * These programs keep the `$proc` form.
268
+ *
269
+ * The round trip gives the same program, with two exceptions. A call with the input `null`, and
270
+ * data that the envelope form reads in a different way, come back in a `$literal`. They give
271
+ * the same values.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * toEnvelopeProgram({ $proc: ["client", "add"], input: { a: { $ref: "$last" }, b: 1 }, $name: "sum" });
276
+ * // { type: ["client", "add"], value: { a: { type: "ref", value: ["names", "last"] }, b: 1 }, name: "sum" }
277
+ * ```
278
+ */
279
+ export function toEnvelopeProgram(program) {
280
+ if (!isAnyProcedureRef(program)) {
281
+ throw new Error(`toEnvelopeProgram() requires a call: { "$proc": [procedure path], "input": input }. Got ${preview(program)}`);
282
+ }
283
+ const path = new Set();
284
+ return within(program, path, 0, () => toCall(program, path, 0));
285
+ }
286
+ /** This function changes a `$proc` call into a call envelope. */
287
+ function toCall(call, path, depth) {
288
+ const { path: procedurePath, input, $name, $when } = normalizeRef(call);
289
+ if ($when !== undefined) {
290
+ throw new Error(`The call of ${preview(procedurePath)} has "$when": ${preview($when)}. ` +
291
+ `The envelope form has no $when: keep this program in the $proc form`);
292
+ }
293
+ if (!isProcedurePath(procedurePath)) {
294
+ throw new Error(`The path of a call must be one or more strings. Got ${preview(procedurePath)}`);
295
+ }
296
+ // A key that the envelope form cannot keep has no envelope form: the conversion does not drop it
297
+ const keys = isProcedureRef(call) ? RUNTIME_CALL_KEYS : CALL_KEYS;
298
+ const other = Object.keys(call).find((key) => !keys.has(key));
299
+ if (other !== undefined) {
300
+ throw new Error(`The call of ${preview(procedurePath)} has the key "${other}". The envelope form keeps only ` +
301
+ `the path, the input and the name: keep this program in the $proc form`);
302
+ }
303
+ if ($name !== undefined && typeof $name !== "string") {
304
+ throw new Error(`The $name of a call must be a string. The call of ${preview(procedurePath)} has ${preview($name)}`);
305
+ }
306
+ const value = input === undefined
307
+ ? null
308
+ : input === null
309
+ ? { type: LITERAL_TYPE, value: null }
310
+ : toValue(input, path, depth + 1);
311
+ return { type: [...procedurePath], value, ...($name !== undefined ? { name: $name } : {}) };
312
+ }
313
+ /** This function changes a `$ref` object into a ref envelope. */
314
+ function toRef(ref) {
315
+ const refText = ref.$ref;
316
+ if (Object.keys(ref).length !== 1) {
317
+ throw new Error(`The $ref object ${preview(ref)} has other keys. The envelope form keeps only the path: keep this program in the $proc form`);
318
+ }
319
+ const [name, ...fields] = refText.split(".");
320
+ if (name === LAST_NAME) {
321
+ throw new Error(`The ref "${refText}" reads a step with the name "last". In the envelope form, ` +
322
+ `["names", "last"] reads the result of the step before: give the step a different name`);
323
+ }
324
+ return { type: REF_TYPE, value: [NAMES_ROOT, name === NATIVE_LAST ? LAST_NAME : name, ...fields] };
325
+ }
326
+ /** This function gives true if a value of the `$proc` form is a call, a `$ref` or a `$literal`. */
327
+ function isNativeConstruct(value) {
328
+ return isAnyProcedureRef(value) || isOutputRef(value) || isLiteral(value);
329
+ }
330
+ /** This function gives true if the arrays and plain objects in a value hold a construct of the `$proc` form. */
331
+ function holdsNativeConstruct(value, path, depth) {
332
+ const children = Array.isArray(value) ? value : isPlainObject(value) ? Object.values(value) : [];
333
+ if (children.length === 0)
334
+ return false;
335
+ return within(value, path, depth, () => children.some((child) => isNativeConstruct(child) || holdsNativeConstruct(child, path, depth + 1)));
336
+ }
337
+ /** This function changes a value of a `$proc` program into the envelope form. */
338
+ function toValue(value, path, depth) {
339
+ if (value === null || typeof value !== "object")
340
+ return value;
341
+ // The same order as hydration: a $literal, then a $ref, then a call
342
+ if (isLiteral(value))
343
+ return { type: LITERAL_TYPE, value: value.$literal };
344
+ if (isOutputRef(value))
345
+ return toRef(value);
346
+ if (isAnyProcedureRef(value))
347
+ return within(value, path, depth, () => toCall(value, path, depth));
348
+ if (Array.isArray(value)) {
349
+ return within(value, path, depth, () => value.map((item) => toValue(item, path, depth + 1)));
350
+ }
351
+ // Values that are not plain data (Date, Map, class instances) stay the same object
352
+ if (!isPlainObject(value))
353
+ return value;
354
+ if (envelopeKind(value) !== undefined || hasNativeKey(value)) {
355
+ // The envelope form reads this data in a different way: it becomes a literal. A literal
356
+ // stops the hydration of its value, so a value that holds a construct has no envelope form.
357
+ if (holdsNativeConstruct(value, path, depth)) {
358
+ throw new Error(`The data ${preview(value)} has the shape of a construct of the envelope form, and it holds a ` +
359
+ `call, a $ref or a $literal. It has no envelope form: keep this program in the $proc form`);
360
+ }
361
+ return { type: LITERAL_TYPE, value };
362
+ }
363
+ const converted = within(value, path, depth, () => Object.fromEntries(Object.entries(value).map(([key, item]) => [key, toValue(item, path, depth + 1)])));
364
+ // A $ref in the type of such data gives a type that is a ref, but not into the world
365
+ if (envelopeKind(converted) !== undefined) {
366
+ throw new Error(`The data ${preview(value)} has a type that the envelope form reads as a ref. It has no envelope form: ` +
367
+ `keep this program in the $proc form`);
368
+ }
369
+ return converted;
370
+ }
371
+ //# sourceMappingURL=envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/procedures/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,GAIb,MAAM,UAAU,CAAC;AAwClB,gFAAgF;AAChF,kCAAkC;AAClC,gFAAgF;AAEhF,2CAA2C;AAC3C,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAEnF,oEAAoE;AACpE,MAAM,WAAW,GAAsB,CAAC,kBAAkB,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;AAEzF,6FAA6F;AAC7F,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEtH,yEAAyE;AACzE,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAElH,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,uEAAuE;AACvE,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,sEAAsE;AACtE,MAAM,WAAW,GAAG,OAAO,CAAC;AAQ5B,uGAAuG;AACvG,SAAS,eAAe,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Y, PROCEDURE_NAME_KEY, WHEN_IMMEDIATE, WHEN_NEVER, WHEN_PARENT, isProcedureRef, isProcedureRefJson, isAnyProcedureRef, getRefWhen, getRefName, shouldExecuteRef, proc, ProcedureRefBuilder, fromJson, toJson, normalizeRef, hydrateInput, prepareRootCall, observeHydration, isControlFlowPath, isDataDriven, markDataDriven, RUNS_REFS_TAG, RAW_INPUT_TAG, takesRawInput, rawInputRule, MAX_DATA_DEPTH, LITERAL_KEY, isLiteral, isPlainObject, createRefScope, lookupOutputRef, resolveOutputRef, withScope, scopeOf, executeRef, extractTemplate, parseProcedureJson, stringifyProcedureJson, } from "./ref.js";
36
36
  export type { ProcedureWhen, ProcedureRef, ProcedureRefJson, AnyProcedureRef, RefExecutor, HydrateOptions, HydrationEvent, StepResultInfo, ContinueDecision, OutputRef, RefScope, } from "./ref.js";
37
+ export { isEnvelopeProgram, fromEnvelopeProgram, toEnvelopeProgram } from "./envelope.js";
38
+ export type { EnvelopeProgram, EnvelopeRef, EnvelopeLiteral, EnvelopePath } from "./envelope.js";
37
39
  export { coreProcedures, coreModule, allCoreProcedures, allCoreModules, chainProcedure, parallelProcedure, conditionalProcedure, andProcedure, orProcedure, notProcedure, allProcedure, anyProcedure, noneProcedure, mapProcedure, reduceProcedure, identityProcedure, constantProcedure, throwProcedure, tryCatchProcedure, anySchema, typedAnySchema, zodAdapter, outputSchema, type ZodLikeSchema, } from "./core/index.js";
38
40
  export { validateSchema, validateSchemaAsync, jsonSchemaOf, isStandardSchema, describeIssues, } from "./schema.js";
39
41
  export type { StandardSchemaV1, StandardJSONSchemaConverter, ProcedureSchema, InferSchema, SchemaResult, JsonSchema, JsonSchemaTarget, JsonSchemaSource, } from "./schema.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,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AW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,EACN,SAAS,EACT,UAAU,EACV,aAAa,EACb,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhJ,OAAO,E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ACT,QAAQ,GACT,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGjG,OAAO,EACL,cAAc,EACd,UAAU,EAEV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EAEjB,SAAS,EACT,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EACf,WAAW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
@@ -49,6 +49,8 @@ fromJson, toJson, normalizeRef,
49
49
  hydrateInput, prepareRootCall, observeHydration, isControlFlowPath, isDataDriven, markDataDriven, RUNS_REFS_TAG, RAW_INPUT_TAG, takesRawInput, rawInputRule, MAX_DATA_DEPTH, LITERAL_KEY, isLiteral, isPlainObject, createRefScope, lookupOutputRef, resolveOutputRef, withScope, scopeOf, executeRef,
50
50
  // Templates
51
51
  extractTemplate, parseProcedureJson, stringifyProcedureJson, } from "./ref.js";
52
+ // The envelope form of a program (coeval D6, D9 and D10, roadmap item M7)
53
+ export { isEnvelopeProgram, fromEnvelopeProgram, toEnvelopeProgram } from "./envelope.js";
52
54
  // Core language procedures (chain, parallel, if, etc.)
53
55
  export { coreProcedures, coreModule,
54
56
  // Every core procedure (math, comparison, string, type, object, array, meta too). Not registered by default.