@procedures/compiler 0.0.0-stage → 0.3.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/CHANGELOG.md +45 -0
- package/LICENSE +21 -0
- package/README.md +254 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/checks.d.ts +24 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +123 -0
- package/dist/checks.js.map +1 -0
- package/dist/codegen-closure.d.ts +19 -0
- package/dist/codegen-closure.d.ts.map +1 -0
- package/dist/codegen-closure.js +200 -0
- package/dist/codegen-closure.js.map +1 -0
- package/dist/codegen-text.d.ts +44 -0
- package/dist/codegen-text.d.ts.map +1 -0
- package/dist/codegen-text.js +360 -0
- package/dist/codegen-text.js.map +1 -0
- package/dist/diagnostics.d.ts +67 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +38 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/effects.d.ts +63 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/effects.js +185 -0
- package/dist/effects.js.map +1 -0
- package/dist/explain.d.ts +58 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +144 -0
- package/dist/explain.js.map +1 -0
- package/dist/facts.d.ts +66 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +102 -0
- package/dist/facts.js.map +1 -0
- package/dist/fold.d.ts +27 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/fold.js +128 -0
- package/dist/fold.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor.d.ts +51 -0
- package/dist/interceptor.d.ts.map +1 -0
- package/dist/interceptor.js +116 -0
- package/dist/interceptor.js.map +1 -0
- package/dist/ir.d.ts +240 -0
- package/dist/ir.d.ts.map +1 -0
- package/dist/ir.js +74 -0
- package/dist/ir.js.map +1 -0
- package/dist/mermaid.d.ts +53 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +423 -0
- package/dist/mermaid.js.map +1 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +124 -0
- package/dist/module.js.map +1 -0
- package/dist/normalize.d.ts +43 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +529 -0
- package/dist/normalize.js.map +1 -0
- package/dist/openrpc.d.ts +63 -0
- package/dist/openrpc.d.ts.map +1 -0
- package/dist/openrpc.js +57 -0
- package/dist/openrpc.js.map +1 -0
- package/dist/print.d.ts +8 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +148 -0
- package/dist/print.js.map +1 -0
- package/dist/procedures/program/check.d.ts +14 -0
- package/dist/procedures/program/check.d.ts.map +1 -0
- package/dist/procedures/program/check.js +30 -0
- package/dist/procedures/program/check.js.map +1 -0
- package/dist/procedures/program/compile.d.ts +14 -0
- package/dist/procedures/program/compile.d.ts.map +1 -0
- package/dist/procedures/program/compile.js +35 -0
- package/dist/procedures/program/compile.js.map +1 -0
- package/dist/procedures/program/diagram.d.ts +14 -0
- package/dist/procedures/program/diagram.d.ts.map +1 -0
- package/dist/procedures/program/diagram.js +23 -0
- package/dist/procedures/program/diagram.js.map +1 -0
- package/dist/procedures/program/effects-output.d.ts +8 -0
- package/dist/procedures/program/effects-output.d.ts.map +1 -0
- package/dist/procedures/program/effects-output.js +13 -0
- package/dist/procedures/program/effects-output.js.map +1 -0
- package/dist/procedures/program/explain.d.ts +14 -0
- package/dist/procedures/program/explain.d.ts.map +1 -0
- package/dist/procedures/program/explain.js +43 -0
- package/dist/procedures/program/explain.js.map +1 -0
- package/dist/procedures/program/index.d.ts +5 -0
- package/dist/procedures/program/index.d.ts.map +1 -0
- package/dist/procedures/program/index.js +5 -0
- package/dist/procedures/program/index.js.map +1 -0
- package/dist/procedures/sdk/index.d.ts +3 -0
- package/dist/procedures/sdk/index.d.ts.map +1 -0
- package/dist/procedures/sdk/index.js +3 -0
- package/dist/procedures/sdk/index.js.map +1 -0
- package/dist/procedures/sdk/manifest.d.ts +11 -0
- package/dist/procedures/sdk/manifest.d.ts.map +1 -0
- package/dist/procedures/sdk/manifest.js +15 -0
- package/dist/procedures/sdk/manifest.js.map +1 -0
- package/dist/procedures/sdk/openrpc.d.ts +11 -0
- package/dist/procedures/sdk/openrpc.d.ts.map +1 -0
- package/dist/procedures/sdk/openrpc.js +13 -0
- package/dist/procedures/sdk/openrpc.js.map +1 -0
- package/dist/procedures/sdk/typescript.d.ts +11 -0
- package/dist/procedures/sdk/typescript.d.ts.map +1 -0
- package/dist/procedures/sdk/typescript.js +14 -0
- package/dist/procedures/sdk/typescript.js.map +1 -0
- package/dist/program.d.ts +84 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +108 -0
- package/dist/program.js.map +1 -0
- package/dist/refs.d.ts +9 -0
- package/dist/refs.d.ts.map +1 -0
- package/dist/refs.js +9 -0
- package/dist/refs.js.map +1 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +8 -0
- package/dist/register.js.map +1 -0
- package/dist/runtime.d.ts +68 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +138 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema.d.ts +41 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +325 -0
- package/dist/schema.js.map +1 -0
- package/dist/scopes.d.ts +25 -0
- package/dist/scopes.d.ts.map +1 -0
- package/dist/scopes.js +202 -0
- package/dist/scopes.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +157 -0
- package/dist/types.js.map +1 -0
- package/dist/typescript-sdk.d.ts +34 -0
- package/dist/typescript-sdk.d.ts.map +1 -0
- package/dist/typescript-sdk.js +231 -0
- package/dist/typescript-sdk.js.map +1 -0
- package/package.json +83 -3
- package/src/checks.ts +128 -0
- package/src/codegen-closure.ts +224 -0
- package/src/codegen-text.ts +396 -0
- package/src/diagnostics.ts +98 -0
- package/src/effects.ts +231 -0
- package/src/explain.ts +194 -0
- package/src/facts.ts +161 -0
- package/src/fold.ts +136 -0
- package/src/index.ts +35 -0
- package/src/interceptor.ts +149 -0
- package/src/ir.ts +330 -0
- package/src/mermaid.ts +460 -0
- package/src/module.ts +171 -0
- package/src/normalize.ts +694 -0
- package/src/openrpc.ts +104 -0
- package/src/print.ts +143 -0
- package/src/procedures/program/check.ts +31 -0
- package/src/procedures/program/compile.ts +36 -0
- package/src/procedures/program/diagram.ts +25 -0
- package/src/procedures/program/effects-output.ts +16 -0
- package/src/procedures/program/explain.ts +46 -0
- package/src/procedures/program/index.ts +4 -0
- package/src/procedures/sdk/index.ts +2 -0
- package/src/procedures/sdk/manifest.ts +17 -0
- package/src/procedures/sdk/openrpc.ts +16 -0
- package/src/procedures/sdk/typescript.ts +17 -0
- package/src/program.ts +181 -0
- package/src/refs.ts +9 -0
- package/src/register.ts +10 -0
- package/src/runtime.ts +188 -0
- package/src/schema.ts +318 -0
- package/src/scopes.ts +196 -0
- package/src/types.ts +318 -0
- package/src/typescript-sdk.ts +282 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAElE,0EAA0E;AAC1E,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACpG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5F,wCAAwC;AACxC,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAW3C;AAED,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,CAiBvF;AAED,+BAA+B;AAC/B,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AA2PD,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW,EAAE,CAKvE"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The check of an input against the JSON Schema of a procedure (the manifest gives draft-07).
|
|
3
|
+
*
|
|
4
|
+
* The compiler knows only a part of an input before the run: the literals, and the keys of an
|
|
5
|
+
* object whose values are calls. This validator works on such a partial value (a shape). It
|
|
6
|
+
* reports only a definite problem: a value that the compiler knows and that the schema refuses.
|
|
7
|
+
* A part that the compiler does not know agrees with each schema.
|
|
8
|
+
*/
|
|
9
|
+
import { isPlainObject } from "@procedures/client/browser";
|
|
10
|
+
import { childPointer } from "./ir.js";
|
|
11
|
+
/** The shape of the value of a node. */
|
|
12
|
+
export function shapeOf(node) {
|
|
13
|
+
switch (node.kind) {
|
|
14
|
+
case "literal":
|
|
15
|
+
return { kind: "known", value: node.value, pointer: node.pointer };
|
|
16
|
+
case "object":
|
|
17
|
+
return { kind: "object", entries: new Map(node.entries.map((entry) => [entry.key, shapeOf(entry.value)])), pointer: node.pointer };
|
|
18
|
+
case "array":
|
|
19
|
+
return { kind: "array", items: node.items.map(shapeOf), pointer: node.pointer };
|
|
20
|
+
default:
|
|
21
|
+
return { kind: "unknown", pointer: node.pointer };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** The shape of an input with the parent context of control flow (`callOperand()`). */
|
|
25
|
+
export function withExtra(shape, extra) {
|
|
26
|
+
const keys = Object.keys(extra);
|
|
27
|
+
if (keys.length === 0)
|
|
28
|
+
return shape;
|
|
29
|
+
const extraEntries = keys.map((key) => [key, { kind: "known", value: extra[key], pointer: shape.pointer }]);
|
|
30
|
+
switch (shape.kind) {
|
|
31
|
+
case "object":
|
|
32
|
+
return { kind: "object", entries: new Map([...shape.entries, ...extraEntries]), pointer: shape.pointer };
|
|
33
|
+
case "known": {
|
|
34
|
+
const value = shape.value;
|
|
35
|
+
const base = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
36
|
+
return { kind: "known", value: { ...base, ...extra }, pointer: shape.pointer };
|
|
37
|
+
}
|
|
38
|
+
case "array":
|
|
39
|
+
return { kind: "known", value: { ...extra }, pointer: shape.pointer };
|
|
40
|
+
case "unknown":
|
|
41
|
+
return shape;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The JSON type of a known value, or undefined for a value that JSON does not have. */
|
|
45
|
+
function jsonType(value) {
|
|
46
|
+
if (value === null)
|
|
47
|
+
return "null";
|
|
48
|
+
if (Array.isArray(value))
|
|
49
|
+
return "array";
|
|
50
|
+
switch (typeof value) {
|
|
51
|
+
case "string":
|
|
52
|
+
return "string";
|
|
53
|
+
case "number":
|
|
54
|
+
return Number.isFinite(value) ? "number" : undefined;
|
|
55
|
+
case "boolean":
|
|
56
|
+
return "boolean";
|
|
57
|
+
case "object":
|
|
58
|
+
return isPlainObject(value) ? "object" : undefined;
|
|
59
|
+
case "undefined":
|
|
60
|
+
return "undefined";
|
|
61
|
+
default:
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function deepEqual(a, b) {
|
|
66
|
+
if (Object.is(a, b))
|
|
67
|
+
return true;
|
|
68
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
69
|
+
return false;
|
|
70
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
71
|
+
return false;
|
|
72
|
+
if (Array.isArray(a) && Array.isArray(b))
|
|
73
|
+
return a.length === b.length && a.every((item, index) => deepEqual(item, b[index]));
|
|
74
|
+
const keysA = Object.keys(a);
|
|
75
|
+
const keysB = Object.keys(b);
|
|
76
|
+
return keysA.length === keysB.length && keysA.every((key) => Object.hasOwn(b, key) && deepEqual(a[key], b[key]));
|
|
77
|
+
}
|
|
78
|
+
function pathText(path) {
|
|
79
|
+
let text = "";
|
|
80
|
+
for (const part of path)
|
|
81
|
+
text += typeof part === "number" ? `[${part}]` : text === "" ? part : `.${part}`;
|
|
82
|
+
return text;
|
|
83
|
+
}
|
|
84
|
+
/** The shape of a known value: an object or an array gives entries, so a problem has a path. */
|
|
85
|
+
function expand(shape) {
|
|
86
|
+
if (shape.kind !== "known")
|
|
87
|
+
return shape;
|
|
88
|
+
const value = shape.value;
|
|
89
|
+
if (Array.isArray(value)) {
|
|
90
|
+
return { kind: "array", items: value.map((item, index) => ({ kind: "known", value: item, pointer: childPointer(shape.pointer, index) })), pointer: shape.pointer };
|
|
91
|
+
}
|
|
92
|
+
if (isPlainObject(value)) {
|
|
93
|
+
return {
|
|
94
|
+
kind: "object",
|
|
95
|
+
entries: new Map(Object.entries(value).map(([key, item]) => [key, { kind: "known", value: item, pointer: childPointer(shape.pointer, key) }])),
|
|
96
|
+
pointer: shape.pointer,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return shape;
|
|
100
|
+
}
|
|
101
|
+
/** The JSON type of a shape, or undefined when the compiler does not know it. */
|
|
102
|
+
function typeOfShape(shape) {
|
|
103
|
+
switch (shape.kind) {
|
|
104
|
+
case "object":
|
|
105
|
+
return "object";
|
|
106
|
+
case "array":
|
|
107
|
+
return "array";
|
|
108
|
+
case "known":
|
|
109
|
+
return jsonType(shape.value);
|
|
110
|
+
case "unknown":
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function typeMatches(actual, expected, value) {
|
|
115
|
+
const types = Array.isArray(expected) ? expected : [expected];
|
|
116
|
+
return types.some((type) => type === actual || (type === "integer" && actual === "number" && Number.isInteger(value)) || (type === "number" && actual === "integer"));
|
|
117
|
+
}
|
|
118
|
+
class Validator {
|
|
119
|
+
root;
|
|
120
|
+
issues = [];
|
|
121
|
+
depth = 0;
|
|
122
|
+
constructor(root) {
|
|
123
|
+
this.root = root;
|
|
124
|
+
}
|
|
125
|
+
issue(shape, path, message) {
|
|
126
|
+
this.issues.push({ pointer: shape.pointer, path: pathText(path), message });
|
|
127
|
+
}
|
|
128
|
+
resolve(ref) {
|
|
129
|
+
if (!ref.startsWith("#"))
|
|
130
|
+
return undefined;
|
|
131
|
+
let current = this.root;
|
|
132
|
+
for (const part of ref.slice(1).split("/").filter((segment) => segment !== "")) {
|
|
133
|
+
const key = decodeURIComponent(part).replace(/~1/g, "/").replace(/~0/g, "~");
|
|
134
|
+
if (current === null || typeof current !== "object" || !Object.hasOwn(current, key))
|
|
135
|
+
return undefined;
|
|
136
|
+
current = current[key];
|
|
137
|
+
}
|
|
138
|
+
return typeof current === "boolean" || (typeof current === "object" && current !== null) ? current : undefined;
|
|
139
|
+
}
|
|
140
|
+
/** True when the shape agrees with the schema (no definite problem). The problems go to `issues`. */
|
|
141
|
+
validate(shape, schema, path) {
|
|
142
|
+
if (schema === undefined || schema === true)
|
|
143
|
+
return true;
|
|
144
|
+
if (schema === false) {
|
|
145
|
+
if (shape.kind === "unknown")
|
|
146
|
+
return true;
|
|
147
|
+
this.issue(shape, path, "no value is valid here");
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (shape.kind === "unknown")
|
|
151
|
+
return true;
|
|
152
|
+
if (this.depth > 50)
|
|
153
|
+
return true;
|
|
154
|
+
this.depth++;
|
|
155
|
+
try {
|
|
156
|
+
return this.validateObject(shape, schema, path);
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
this.depth--;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
branches(shape, schemas, path) {
|
|
163
|
+
if (!Array.isArray(schemas))
|
|
164
|
+
return true;
|
|
165
|
+
for (const branch of schemas) {
|
|
166
|
+
const probe = new Validator(this.root);
|
|
167
|
+
if (probe.validate(shape, branch, path))
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
validateObject(shape, schema, path) {
|
|
173
|
+
const before = this.issues.length;
|
|
174
|
+
const ref = schema["$ref"];
|
|
175
|
+
if (typeof ref === "string") {
|
|
176
|
+
const target = this.resolve(ref);
|
|
177
|
+
if (target !== undefined)
|
|
178
|
+
this.validate(shape, target, path);
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(schema["allOf"]))
|
|
181
|
+
for (const part of schema["allOf"])
|
|
182
|
+
this.validate(shape, part, path);
|
|
183
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
184
|
+
if (schema[key] !== undefined && !this.branches(shape, schema[key], path)) {
|
|
185
|
+
this.issue(shape, path, "the value agrees with none of the allowed forms");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const actual = typeOfShape(shape);
|
|
189
|
+
const value = shape.kind === "known" ? shape.value : undefined;
|
|
190
|
+
if (actual === undefined)
|
|
191
|
+
return this.issues.length === before;
|
|
192
|
+
if (schema["type"] !== undefined && !typeMatches(actual, schema["type"], value)) {
|
|
193
|
+
const expected = Array.isArray(schema["type"]) ? schema["type"].join(" or ") : String(schema["type"]);
|
|
194
|
+
this.issue(shape, path, `expected ${expected}, got ${actual}`);
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (shape.kind === "known" && actual !== "object" && actual !== "array") {
|
|
198
|
+
if (Array.isArray(schema["enum"]) && !schema["enum"].some((option) => deepEqual(option, value))) {
|
|
199
|
+
this.issue(shape, path, `expected one of ${schema["enum"].map((option) => JSON.stringify(option)).join(", ")}`);
|
|
200
|
+
}
|
|
201
|
+
if (Object.hasOwn(schema, "const") && !deepEqual(schema["const"], value)) {
|
|
202
|
+
this.issue(shape, path, `expected ${JSON.stringify(schema["const"])}`);
|
|
203
|
+
}
|
|
204
|
+
if (actual === "string")
|
|
205
|
+
this.string(shape, value, schema, path);
|
|
206
|
+
if (actual === "number" || actual === "integer")
|
|
207
|
+
this.number(shape, value, schema, path);
|
|
208
|
+
return this.issues.length === before;
|
|
209
|
+
}
|
|
210
|
+
const expanded = expand(shape);
|
|
211
|
+
if (expanded.kind === "object")
|
|
212
|
+
this.properties(expanded, schema, path);
|
|
213
|
+
if (expanded.kind === "array")
|
|
214
|
+
this.items(expanded, schema, path);
|
|
215
|
+
if (shape.kind === "known" && (Array.isArray(schema["enum"]) || Object.hasOwn(schema, "const"))) {
|
|
216
|
+
const options = Array.isArray(schema["enum"]) ? schema["enum"] : [schema["const"]];
|
|
217
|
+
if (!options.some((option) => deepEqual(option, value)))
|
|
218
|
+
this.issue(shape, path, "the value is not one of the allowed values");
|
|
219
|
+
}
|
|
220
|
+
return this.issues.length === before;
|
|
221
|
+
}
|
|
222
|
+
string(shape, value, schema, path) {
|
|
223
|
+
const min = schema["minLength"];
|
|
224
|
+
const max = schema["maxLength"];
|
|
225
|
+
if (typeof min === "number" && value.length < min)
|
|
226
|
+
this.issue(shape, path, `expected a string of ${min} characters or more`);
|
|
227
|
+
if (typeof max === "number" && value.length > max)
|
|
228
|
+
this.issue(shape, path, `expected a string of ${max} characters or fewer`);
|
|
229
|
+
const pattern = schema["pattern"];
|
|
230
|
+
if (typeof pattern === "string") {
|
|
231
|
+
let regex;
|
|
232
|
+
try {
|
|
233
|
+
regex = new RegExp(pattern);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
regex = undefined;
|
|
237
|
+
}
|
|
238
|
+
if (regex && !regex.test(value))
|
|
239
|
+
this.issue(shape, path, `expected a string that matches ${pattern}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
number(shape, value, schema, path) {
|
|
243
|
+
const minimum = schema["minimum"];
|
|
244
|
+
const maximum = schema["maximum"];
|
|
245
|
+
const exclusiveMinimum = schema["exclusiveMinimum"];
|
|
246
|
+
const exclusiveMaximum = schema["exclusiveMaximum"];
|
|
247
|
+
if (typeof minimum === "number" && (exclusiveMinimum === true ? value <= minimum : value < minimum)) {
|
|
248
|
+
this.issue(shape, path, `expected a number ${exclusiveMinimum === true ? "greater than" : "of"} ${minimum}${exclusiveMinimum === true ? "" : " or more"}`);
|
|
249
|
+
}
|
|
250
|
+
if (typeof maximum === "number" && (exclusiveMaximum === true ? value >= maximum : value > maximum)) {
|
|
251
|
+
this.issue(shape, path, `expected a number ${exclusiveMaximum === true ? "less than" : "of"} ${maximum}${exclusiveMaximum === true ? "" : " or less"}`);
|
|
252
|
+
}
|
|
253
|
+
if (typeof exclusiveMinimum === "number" && value <= exclusiveMinimum)
|
|
254
|
+
this.issue(shape, path, `expected a number greater than ${exclusiveMinimum}`);
|
|
255
|
+
if (typeof exclusiveMaximum === "number" && value >= exclusiveMaximum)
|
|
256
|
+
this.issue(shape, path, `expected a number less than ${exclusiveMaximum}`);
|
|
257
|
+
const multipleOf = schema["multipleOf"];
|
|
258
|
+
if (typeof multipleOf === "number" && multipleOf > 0) {
|
|
259
|
+
const quotient = value / multipleOf;
|
|
260
|
+
if (Math.abs(quotient - Math.round(quotient)) > 1e-9)
|
|
261
|
+
this.issue(shape, path, `expected a multiple of ${multipleOf}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
properties(shape, schema, path) {
|
|
265
|
+
const properties = isPlainObject(schema["properties"]) ? schema["properties"] : {};
|
|
266
|
+
const present = (key) => {
|
|
267
|
+
const entry = shape.entries.get(key);
|
|
268
|
+
return entry !== undefined && !(entry.kind === "known" && entry.value === undefined);
|
|
269
|
+
};
|
|
270
|
+
if (Array.isArray(schema["required"])) {
|
|
271
|
+
for (const key of schema["required"]) {
|
|
272
|
+
if (typeof key === "string" && !present(key))
|
|
273
|
+
this.issue(shape, [...path, key], "the input has no value for this required key");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const patterns = isPlainObject(schema["patternProperties"]) ? Object.keys(schema["patternProperties"]) : [];
|
|
277
|
+
const additional = schema["additionalProperties"];
|
|
278
|
+
for (const [key, entry] of shape.entries) {
|
|
279
|
+
if (entry.kind === "known" && entry.value === undefined)
|
|
280
|
+
continue;
|
|
281
|
+
if (Object.hasOwn(properties, key)) {
|
|
282
|
+
this.validate(entry, properties[key], [...path, key]);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (patterns.some((pattern) => safeTest(pattern, key)))
|
|
286
|
+
continue;
|
|
287
|
+
if (additional === false)
|
|
288
|
+
this.issue(entry, [...path, key], "the schema does not allow this key");
|
|
289
|
+
else if (typeof additional === "object" && additional !== null)
|
|
290
|
+
this.validate(entry, additional, [...path, key]);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
items(shape, schema, path) {
|
|
294
|
+
const minItems = schema["minItems"];
|
|
295
|
+
const maxItems = schema["maxItems"];
|
|
296
|
+
if (typeof minItems === "number" && shape.items.length < minItems)
|
|
297
|
+
this.issue(shape, path, `expected ${minItems} items or more`);
|
|
298
|
+
if (typeof maxItems === "number" && shape.items.length > maxItems)
|
|
299
|
+
this.issue(shape, path, `expected ${maxItems} items or fewer`);
|
|
300
|
+
const prefix = Array.isArray(schema["prefixItems"]) ? schema["prefixItems"] : Array.isArray(schema["items"]) ? schema["items"] : undefined;
|
|
301
|
+
const rest = prefix ? (Array.isArray(schema["items"]) ? schema["additionalItems"] : schema["items"]) : schema["items"];
|
|
302
|
+
shape.items.forEach((item, index) => {
|
|
303
|
+
const itemSchema = prefix && index < prefix.length ? prefix[index] : rest;
|
|
304
|
+
if (itemSchema !== undefined)
|
|
305
|
+
this.validate(item, itemSchema, [...path, index]);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function safeTest(pattern, value) {
|
|
310
|
+
try {
|
|
311
|
+
return new RegExp(pattern).test(value);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/** This function gives the definite problems of a partial input against a JSON Schema. */
|
|
318
|
+
export function checkShape(shape, schema) {
|
|
319
|
+
if (schema === undefined || schema === null || (typeof schema !== "object" && typeof schema !== "boolean"))
|
|
320
|
+
return [];
|
|
321
|
+
const validator = new Validator(schema);
|
|
322
|
+
validator.validate(shape, schema, []);
|
|
323
|
+
return validator.issues;
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAA6B,MAAM,SAAS,CAAC;AASlE,wCAAwC;AACxC,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC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
+
* The scopes pass: each `$ref` gets the binding that the interpreter reads.
|
|
3
|
+
*
|
|
4
|
+
* The pass follows `lookupOutputRef()` of the client. The innermost frame with the name gives the
|
|
5
|
+
* value. `$last` is the last result of the innermost frame that has one. A chain frame gets a
|
|
6
|
+
* name after its step: a step reads only the names of the steps before it. A name that no frame
|
|
7
|
+
* has is an error (`Unknown $ref name`). In the input of a deferred call, the runner can give the
|
|
8
|
+
* name later, so there the name stays.
|
|
9
|
+
*/
|
|
10
|
+
import { type Binding, type ProgramIR, type ScopeSnapshot } from "./ir.js";
|
|
11
|
+
import type { Diagnostic } from "./diagnostics.js";
|
|
12
|
+
/** A frame while the pass walks: the names grow as the steps of a chain pass. */
|
|
13
|
+
interface Frame {
|
|
14
|
+
readonly names: Map<string, Binding>;
|
|
15
|
+
last: Binding | undefined;
|
|
16
|
+
/** The names of this step and the later steps of a chain, to find a use before the definition. */
|
|
17
|
+
later: ReadonlySet<string>;
|
|
18
|
+
}
|
|
19
|
+
type Env = readonly Frame[] | undefined;
|
|
20
|
+
/** This function resolves the references of the IR and gives the diagnostics of the names. */
|
|
21
|
+
export declare function resolveScopes(ir: ProgramIR): Diagnostic[];
|
|
22
|
+
/** The static scope at a point: a copy of the frames, as `withScope()` gives them to a raw input. */
|
|
23
|
+
export declare function snapshot(env: Env): ScopeSnapshot;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAgB,KAAK,OAAO,EAA6C,KAAK,SAAS,EAAuC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AACzK,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,iFAAiF;AACjF,UAAU,KAAK;IACb,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,kGAAkG;IAClG,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,KAAK,GAAG,GAAG,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC;AAExC,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,UAAU,EAAE,CAKzD;AAMD,qGAAqG;AACrG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,aAAa,CAGhD"}
|
package/dist/scopes.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scopes pass: each `$ref` gets the binding that the interpreter reads.
|
|
3
|
+
*
|
|
4
|
+
* The pass follows `lookupOutputRef()` of the client. The innermost frame with the name gives the
|
|
5
|
+
* value. `$last` is the last result of the innermost frame that has one. A chain frame gets a
|
|
6
|
+
* name after its step: a step reads only the names of the steps before it. A name that no frame
|
|
7
|
+
* has is an error (`Unknown $ref name`). In the input of a deferred call, the runner can give the
|
|
8
|
+
* name later, so there the name stays.
|
|
9
|
+
*/
|
|
10
|
+
import { isPlainObject } from "@procedures/client/browser";
|
|
11
|
+
import { isOutputRef } from "./refs.js";
|
|
12
|
+
import { childPointer } from "./ir.js";
|
|
13
|
+
/** This function resolves the references of the IR and gives the diagnostics of the names. */
|
|
14
|
+
export function resolveScopes(ir) {
|
|
15
|
+
const diagnostics = [];
|
|
16
|
+
const root = ir.input ? [frameOf([["input", ir.input]])] : undefined;
|
|
17
|
+
visit(ir.root, root, diagnostics);
|
|
18
|
+
return diagnostics;
|
|
19
|
+
}
|
|
20
|
+
function frameOf(names) {
|
|
21
|
+
return { names: new Map(names), last: undefined, later: new Set() };
|
|
22
|
+
}
|
|
23
|
+
/** The static scope at a point: a copy of the frames, as `withScope()` gives them to a raw input. */
|
|
24
|
+
export function snapshot(env) {
|
|
25
|
+
if (!env)
|
|
26
|
+
return undefined;
|
|
27
|
+
return env.map((frame) => ({ names: [...frame.names.entries()], last: frame.last }));
|
|
28
|
+
}
|
|
29
|
+
/** `lookupOutputRef()`: the binding of a name, or undefined. */
|
|
30
|
+
function lookup(env, name) {
|
|
31
|
+
if (!env)
|
|
32
|
+
return undefined;
|
|
33
|
+
for (let index = env.length - 1; index >= 0; index--) {
|
|
34
|
+
const frame = env[index];
|
|
35
|
+
if (name === "$last") {
|
|
36
|
+
if (frame.last)
|
|
37
|
+
return frame.last;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const binding = frame.names.get(name);
|
|
41
|
+
if (binding)
|
|
42
|
+
return binding;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function resolve(node, env, diagnostics) {
|
|
48
|
+
if (node.synthetic)
|
|
49
|
+
return;
|
|
50
|
+
node.binding = lookup(env, node.name);
|
|
51
|
+
if (node.binding)
|
|
52
|
+
return;
|
|
53
|
+
if (node.deferred) {
|
|
54
|
+
diagnostics.push({
|
|
55
|
+
severity: "info",
|
|
56
|
+
code: "unknown-name",
|
|
57
|
+
message: `No scope has the name "${node.name}" here. In the input of a deferred call, the $ref stays data for the runner.`,
|
|
58
|
+
pointer: node.pointer,
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const later = env?.some((frame) => frame.later.has(node.name)) ?? false;
|
|
63
|
+
const names = [...new Set((env ?? []).flatMap((frame) => [...frame.names.keys(), ...(frame.last ? ["$last"] : [])]))];
|
|
64
|
+
const known = names.length > 0 ? ` The names here: ${names.join(", ")}.` : " No name is in the scope here.";
|
|
65
|
+
diagnostics.push(later
|
|
66
|
+
? {
|
|
67
|
+
severity: "error",
|
|
68
|
+
code: "use-before-definition",
|
|
69
|
+
message: `The $ref "${node.text}" reads "${node.name}" before the step that makes it: a step reads only the names of the steps before it.`,
|
|
70
|
+
pointer: node.pointer,
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
severity: "error",
|
|
74
|
+
code: "unknown-name",
|
|
75
|
+
message: `Unknown $ref name "${node.name}" in "${node.text}".${known}${node.name === "$last" ? " The first step of a chain has no $last." : ""}`,
|
|
76
|
+
pointer: node.pointer,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function visitItems(items, env, diagnostics) {
|
|
80
|
+
if (items.kind === "list")
|
|
81
|
+
for (const item of items.items)
|
|
82
|
+
visit(item, env, diagnostics);
|
|
83
|
+
else
|
|
84
|
+
visit(items.value, env, diagnostics);
|
|
85
|
+
}
|
|
86
|
+
function visit(node, env, diagnostics) {
|
|
87
|
+
switch (node.kind) {
|
|
88
|
+
case "literal":
|
|
89
|
+
case "fail":
|
|
90
|
+
return;
|
|
91
|
+
case "reference":
|
|
92
|
+
resolve(node, env, diagnostics);
|
|
93
|
+
return;
|
|
94
|
+
case "object":
|
|
95
|
+
for (const entry of node.entries)
|
|
96
|
+
visit(entry.value, env, diagnostics);
|
|
97
|
+
return;
|
|
98
|
+
case "array":
|
|
99
|
+
for (const item of node.items)
|
|
100
|
+
visit(item, env, diagnostics);
|
|
101
|
+
return;
|
|
102
|
+
case "call":
|
|
103
|
+
case "deferred":
|
|
104
|
+
visit(node.input, env, diagnostics);
|
|
105
|
+
return;
|
|
106
|
+
case "dynamic":
|
|
107
|
+
node.scope = snapshot(env);
|
|
108
|
+
visit(node.input, env, diagnostics);
|
|
109
|
+
if (node.model)
|
|
110
|
+
visit(node.model, env, diagnostics);
|
|
111
|
+
// The body of procedure.define has its own scope (`input`): the program checks it as a body
|
|
112
|
+
else if (node.reason === "runs-refs" && node.key !== "procedure.define")
|
|
113
|
+
scanRaw(node.input, env, diagnostics);
|
|
114
|
+
return;
|
|
115
|
+
case "chain": {
|
|
116
|
+
const names = node.steps.map((step) => step.result.name);
|
|
117
|
+
const frame = { names: new Map(), last: undefined, later: new Set() };
|
|
118
|
+
const inner = [...(env ?? []), frame];
|
|
119
|
+
if (node.initialInput)
|
|
120
|
+
visit(node.initialInput, inner, diagnostics);
|
|
121
|
+
node.steps.forEach((step, index) => {
|
|
122
|
+
frame.later = new Set(names.slice(index).filter((name) => name !== undefined));
|
|
123
|
+
visit(step.node, inner, diagnostics);
|
|
124
|
+
if (step.result.name !== undefined)
|
|
125
|
+
frame.names.set(step.result.name, step.result);
|
|
126
|
+
frame.last = step.result;
|
|
127
|
+
});
|
|
128
|
+
frame.later = new Set();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
case "parallel":
|
|
132
|
+
for (const task of node.tasks)
|
|
133
|
+
visit(task, env, diagnostics);
|
|
134
|
+
return;
|
|
135
|
+
case "conditional":
|
|
136
|
+
visit(node.condition, env, diagnostics);
|
|
137
|
+
if (node.then)
|
|
138
|
+
visit(node.then, env, diagnostics);
|
|
139
|
+
if (node.else)
|
|
140
|
+
visit(node.else, env, diagnostics);
|
|
141
|
+
return;
|
|
142
|
+
case "try":
|
|
143
|
+
visit(node.try, env, diagnostics);
|
|
144
|
+
visit(node.catch, [...(env ?? []), frameOf([["error", node.error]])], diagnostics);
|
|
145
|
+
return;
|
|
146
|
+
case "and":
|
|
147
|
+
case "or":
|
|
148
|
+
for (const value of node.values)
|
|
149
|
+
visit(value, env, diagnostics);
|
|
150
|
+
return;
|
|
151
|
+
case "map": {
|
|
152
|
+
visitItems(node.items, env, diagnostics);
|
|
153
|
+
// scopeWith({ [as]: item, index }): with `as: "index"`, the index replaces the item
|
|
154
|
+
if (node.fn)
|
|
155
|
+
visit(node.fn, [...(env ?? []), frameOf([[node.item.name, node.item], ["index", node.index]])], diagnostics);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
case "reduce": {
|
|
159
|
+
if (node.items)
|
|
160
|
+
visitItems(node.items, env, diagnostics);
|
|
161
|
+
visit(node.initial, env, diagnostics);
|
|
162
|
+
if (node.fn) {
|
|
163
|
+
visit(node.fn, [...(env ?? []), frameOf([["acc", node.acc], ["item", node.item], ["index", node.index]])], diagnostics);
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* This function examines the raw input of a procedure that runs refs (`dag.traverse`, `core.catch`).
|
|
171
|
+
* Its `$ref` values read the scope of the caller, or a name that the runner gives. An unknown
|
|
172
|
+
* name is a warning.
|
|
173
|
+
*/
|
|
174
|
+
function scanRaw(node, env, diagnostics) {
|
|
175
|
+
if (node.kind !== "literal")
|
|
176
|
+
return;
|
|
177
|
+
const seen = new Set();
|
|
178
|
+
const walk = (value, pointer) => {
|
|
179
|
+
if (value === null || typeof value !== "object" || seen.has(value))
|
|
180
|
+
return;
|
|
181
|
+
seen.add(value);
|
|
182
|
+
if (isOutputRef(value)) {
|
|
183
|
+
const name = value.$ref.split(".")[0] ?? "";
|
|
184
|
+
if (env && !lookup(env, name)) {
|
|
185
|
+
diagnostics.push({
|
|
186
|
+
severity: "warning",
|
|
187
|
+
code: "unknown-name",
|
|
188
|
+
message: `No scope has the name "${name}" here. The procedure that runs this input can give the name, or the $ref fails.`,
|
|
189
|
+
pointer,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (Array.isArray(value))
|
|
195
|
+
value.forEach((item, index) => walk(item, childPointer(pointer, index)));
|
|
196
|
+
else if (isPlainObject(value))
|
|
197
|
+
for (const [key, item] of Object.entries(value))
|
|
198
|
+
walk(item, childPointer(pointer, key));
|
|
199
|
+
};
|
|
200
|
+
walk(node.value, node.pointer);
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,WAA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