@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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An OpenRPC document from a manifest (roadmap R23).
|
|
3
|
+
*
|
|
4
|
+
* The manifest of a host (`describeRegistry()`, `procedure.manifest`, roadmap R17) has the JSON
|
|
5
|
+
* Schemas of each procedure. This module writes them as an OpenRPC 1.3 document: one method for
|
|
6
|
+
* each procedure. A tool of the OpenRPC ecosystem can then show the procedures or make a client.
|
|
7
|
+
*
|
|
8
|
+
* The keys of each object have a fixed order, and the methods are in the order of their names.
|
|
9
|
+
* Thus one manifest always gives the same text, and a golden file can hold it.
|
|
10
|
+
*/
|
|
11
|
+
import type { Effects, ProcedureManifest, ProcedurePath } from "@procedures/client/browser";
|
|
12
|
+
/** The version of the OpenRPC specification of the documents. */
|
|
13
|
+
export declare const OPENRPC_VERSION = "1.3.2";
|
|
14
|
+
/** A content descriptor of OpenRPC: a name and a JSON Schema. */
|
|
15
|
+
export interface OpenRpcContentDescriptor {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly required?: boolean | undefined;
|
|
18
|
+
readonly schema: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** One method of an OpenRPC document: one procedure. */
|
|
21
|
+
export interface OpenRpcMethod {
|
|
22
|
+
/** The key of the procedure: its path with dots. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly description?: string | undefined;
|
|
25
|
+
readonly tags?: ReadonlyArray<{
|
|
26
|
+
readonly name: string;
|
|
27
|
+
}> | undefined;
|
|
28
|
+
readonly params: readonly [OpenRpcContentDescriptor];
|
|
29
|
+
readonly result: OpenRpcContentDescriptor;
|
|
30
|
+
readonly deprecated?: boolean | undefined;
|
|
31
|
+
/** The path of the procedure. A segment can have a dot, so the name alone does not give the path. */
|
|
32
|
+
readonly "x-path": ProcedurePath;
|
|
33
|
+
/** The declared effects of the procedure. Absent: the procedure does not declare its effects. */
|
|
34
|
+
readonly "x-effects"?: Effects | undefined;
|
|
35
|
+
/** True: the procedure operates its input as a program (control flow, a defined procedure). */
|
|
36
|
+
readonly "x-data-driven"?: boolean | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** An OpenRPC 1.3 document. */
|
|
39
|
+
export interface OpenRpcDocument {
|
|
40
|
+
readonly openrpc: string;
|
|
41
|
+
readonly info: {
|
|
42
|
+
readonly title: string;
|
|
43
|
+
readonly version: string;
|
|
44
|
+
readonly description?: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
readonly methods: OpenRpcMethod[];
|
|
47
|
+
}
|
|
48
|
+
/** The options of `toOpenRpc()`. */
|
|
49
|
+
export interface OpenRpcOptions {
|
|
50
|
+
/** The title of the document. The default is "Procedures". */
|
|
51
|
+
readonly title?: string | undefined;
|
|
52
|
+
/** The version of the document. The default is the hash of the manifest. */
|
|
53
|
+
readonly version?: string | undefined;
|
|
54
|
+
/** The description of the document. */
|
|
55
|
+
readonly description?: string | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* This function writes a manifest as an OpenRPC 1.3 document. Each procedure is a method with
|
|
59
|
+
* its key as the name. The input schema is the one parameter `input`. The output schema is the
|
|
60
|
+
* result `output`. The declared effects are the extension `x-effects`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function toOpenRpc(manifest: ProcedureManifest, options?: OpenRpcOptions): OpenRpcDocument;
|
|
63
|
+
//# sourceMappingURL=openrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openrpc.d.ts","sourceRoot":"","sources":["../src/openrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE5F,iEAAiE;AACjE,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,iEAAiE;AACjE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IACrE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,wBAAwB,CAAC,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1C,qGAAqG;IACrG,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,iGAAiG;IACjG,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,+FAA+F;IAC/F,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChD;AAED,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC/G,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;CACnC;AAED,oCAAoC;AACpC,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,uCAAuC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAmBD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,GAAE,cAAmB,GAAG,eAAe,CAwBpG"}
|
package/dist/openrpc.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An OpenRPC document from a manifest (roadmap R23).
|
|
3
|
+
*
|
|
4
|
+
* The manifest of a host (`describeRegistry()`, `procedure.manifest`, roadmap R17) has the JSON
|
|
5
|
+
* Schemas of each procedure. This module writes them as an OpenRPC 1.3 document: one method for
|
|
6
|
+
* each procedure. A tool of the OpenRPC ecosystem can then show the procedures or make a client.
|
|
7
|
+
*
|
|
8
|
+
* The keys of each object have a fixed order, and the methods are in the order of their names.
|
|
9
|
+
* Thus one manifest always gives the same text, and a golden file can hold it.
|
|
10
|
+
*/
|
|
11
|
+
/** The version of the OpenRPC specification of the documents. */
|
|
12
|
+
export const OPENRPC_VERSION = "1.3.2";
|
|
13
|
+
/** A copy of a JSON value: only JSON values, and no `undefined`. */
|
|
14
|
+
function jsonCopy(value) {
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return {};
|
|
17
|
+
const copy = JSON.parse(JSON.stringify(value));
|
|
18
|
+
return copy !== null && typeof copy === "object" && !Array.isArray(copy) ? copy : {};
|
|
19
|
+
}
|
|
20
|
+
/** The effects with their keys in a fixed order. */
|
|
21
|
+
function effectsCopy(effects) {
|
|
22
|
+
return {
|
|
23
|
+
...(effects.reads ? { reads: [...effects.reads] } : {}),
|
|
24
|
+
...(effects.writes ? { writes: [...effects.writes] } : {}),
|
|
25
|
+
...(effects.destructive !== undefined ? { destructive: effects.destructive } : {}),
|
|
26
|
+
...(effects.idempotent !== undefined ? { idempotent: effects.idempotent } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This function writes a manifest as an OpenRPC 1.3 document. Each procedure is a method with
|
|
31
|
+
* its key as the name. The input schema is the one parameter `input`. The output schema is the
|
|
32
|
+
* result `output`. The declared effects are the extension `x-effects`.
|
|
33
|
+
*/
|
|
34
|
+
export function toOpenRpc(manifest, options = {}) {
|
|
35
|
+
const entries = [...manifest.procedures].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
36
|
+
const methods = entries.map((entry) => ({
|
|
37
|
+
name: entry.key,
|
|
38
|
+
...(entry.description !== undefined ? { description: entry.description } : {}),
|
|
39
|
+
...(entry.tags && entry.tags.length > 0 ? { tags: entry.tags.map((name) => ({ name })) } : {}),
|
|
40
|
+
params: [{ name: "input", required: true, schema: jsonCopy(entry.input) }],
|
|
41
|
+
result: { name: "output", schema: jsonCopy(entry.output) },
|
|
42
|
+
...(entry.deprecated ? { deprecated: true } : {}),
|
|
43
|
+
"x-path": [...entry.path],
|
|
44
|
+
...(entry.effects ? { "x-effects": effectsCopy(entry.effects) } : {}),
|
|
45
|
+
...(entry.dataDriven ? { "x-data-driven": true } : {}),
|
|
46
|
+
}));
|
|
47
|
+
return {
|
|
48
|
+
openrpc: OPENRPC_VERSION,
|
|
49
|
+
info: {
|
|
50
|
+
title: options.title ?? "Procedures",
|
|
51
|
+
version: options.version ?? manifest.hash,
|
|
52
|
+
...(options.description !== undefined ? { description: options.description } : {}),
|
|
53
|
+
},
|
|
54
|
+
methods,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=openrpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openrpc.js","sourceRoot":"","sources":["../src/openrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AA2CvC,oEAAoE;AACpE,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAY,CAAC;IAC1D,OAAO,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpH,CAAC;AAED,oDAAoD;AACpD,SAAS,WAAW,CAAC,OAAgB;IACnC,OAAO;QACL,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,C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package/dist/print.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A text form of the IR, with one node on each line. The golden tests and the persons who read
|
|
3
|
+
* the result of the compiler use it.
|
|
4
|
+
*/
|
|
5
|
+
import type { ProgramIR } from "./ir.js";
|
|
6
|
+
/** This function gives the text of the IR of a program. */
|
|
7
|
+
export declare function printIR(ir: ProgramIR): string;
|
|
8
|
+
//# sourceMappingURL=print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../src/print.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAA8B,SAAS,EAAiB,MAAM,SAAS,CAAC;AA2BpF,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CA6G7C"}
|
package/dist/print.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A text form of the IR, with one node on each line. The golden tests and the persons who read
|
|
3
|
+
* the result of the compiler use it.
|
|
4
|
+
*/
|
|
5
|
+
function json(value) {
|
|
6
|
+
try {
|
|
7
|
+
const text = JSON.stringify(value);
|
|
8
|
+
return text === undefined ? String(value) : text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return "<not JSON>";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function binding(value) {
|
|
15
|
+
if (!value)
|
|
16
|
+
return "-";
|
|
17
|
+
return value.name === undefined ? `b${value.id}` : `b${value.id}:${value.name}`;
|
|
18
|
+
}
|
|
19
|
+
function scope(snapshot) {
|
|
20
|
+
if (!snapshot)
|
|
21
|
+
return "none";
|
|
22
|
+
return snapshot
|
|
23
|
+
.map((frame) => `[${frame.names.map(([name, value]) => `${name}=${binding(value)}`).join(" ")}${frame.last ? ` $last=${binding(frame.last)}` : ""}]`)
|
|
24
|
+
.join(" ");
|
|
25
|
+
}
|
|
26
|
+
function extra(value) {
|
|
27
|
+
return Object.keys(value).length > 0 ? ` extra=${json(value)}` : "";
|
|
28
|
+
}
|
|
29
|
+
/** This function gives the text of the IR of a program. */
|
|
30
|
+
export function printIR(ir) {
|
|
31
|
+
const lines = [`program mode=${ir.mode}${ir.input ? ` input=${binding(ir.input)}` : ""}`];
|
|
32
|
+
const line = (depth, text) => {
|
|
33
|
+
lines.push(`${" ".repeat(depth)}${text}`);
|
|
34
|
+
};
|
|
35
|
+
const items = (spec, depth) => {
|
|
36
|
+
if (spec.kind === "list") {
|
|
37
|
+
line(depth, `items list(${spec.items.length})`);
|
|
38
|
+
for (const item of spec.items)
|
|
39
|
+
visit(item, depth + 1);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
line(depth, "items value");
|
|
43
|
+
visit(spec.value, depth + 1);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const visit = (node, depth) => {
|
|
47
|
+
const at = ` @${json(node.pointer)}`;
|
|
48
|
+
switch (node.kind) {
|
|
49
|
+
case "literal":
|
|
50
|
+
line(depth, `literal ${node.origin} ${json(node.value)}${at}`);
|
|
51
|
+
return;
|
|
52
|
+
case "object":
|
|
53
|
+
line(depth, `object${at}`);
|
|
54
|
+
for (const entry of node.entries) {
|
|
55
|
+
line(depth + 1, `key ${json(entry.key)}`);
|
|
56
|
+
visit(entry.value, depth + 2);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
case "array":
|
|
60
|
+
line(depth, `array(${node.items.length})${at}`);
|
|
61
|
+
for (const item of node.items)
|
|
62
|
+
visit(item, depth + 1);
|
|
63
|
+
return;
|
|
64
|
+
case "reference":
|
|
65
|
+
line(depth, `ref ${json(node.text)} -> ${node.binding ? binding(node.binding) : node.deferred ? "data (deferred)" : "unknown"}${at}`);
|
|
66
|
+
return;
|
|
67
|
+
case "call":
|
|
68
|
+
line(depth, `call ${node.key} ${node.position}${extra(node.extra)}${at}`);
|
|
69
|
+
visit(node.input, depth + 1);
|
|
70
|
+
return;
|
|
71
|
+
case "deferred":
|
|
72
|
+
line(depth, `deferred ${node.key} when=${json(node.when)}${at}`);
|
|
73
|
+
visit(node.input, depth + 1);
|
|
74
|
+
return;
|
|
75
|
+
case "dynamic":
|
|
76
|
+
line(depth, `dynamic ${node.key} ${node.position} reason=${node.reason}${extra(node.extra)} scope=${scope(node.scope)}${at}`);
|
|
77
|
+
visit(node.input, depth + 1);
|
|
78
|
+
if (node.model) {
|
|
79
|
+
line(depth + 1, "model");
|
|
80
|
+
visit(node.model, depth + 2);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
case "fail":
|
|
84
|
+
line(depth, `fail ${json(node.message)}${at}`);
|
|
85
|
+
return;
|
|
86
|
+
case "chain":
|
|
87
|
+
line(depth, `chain${node.implicit ? " implicit" : ""} ${node.position}${node.passThrough ? ` passThrough initial=${binding(node.initial)}` : ""}${at}`);
|
|
88
|
+
if (node.initialInput) {
|
|
89
|
+
line(depth + 1, "initialInput");
|
|
90
|
+
visit(node.initialInput, depth + 2);
|
|
91
|
+
}
|
|
92
|
+
for (const step of node.steps) {
|
|
93
|
+
line(depth + 1, `step -> ${binding(step.result)}`);
|
|
94
|
+
visit(step.node, depth + 2);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
case "parallel":
|
|
98
|
+
line(depth, `parallel ${node.position} concurrency=${node.concurrency ?? "all"} failFast=${node.failFast}${at}`);
|
|
99
|
+
for (const task of node.tasks)
|
|
100
|
+
visit(task, depth + 1);
|
|
101
|
+
return;
|
|
102
|
+
case "conditional":
|
|
103
|
+
line(depth, `conditional ${node.position}${at}`);
|
|
104
|
+
visit(node.condition, depth + 1);
|
|
105
|
+
line(depth + 1, "then");
|
|
106
|
+
if (node.then)
|
|
107
|
+
visit(node.then, depth + 2);
|
|
108
|
+
line(depth + 1, "else");
|
|
109
|
+
if (node.else)
|
|
110
|
+
visit(node.else, depth + 2);
|
|
111
|
+
return;
|
|
112
|
+
case "try":
|
|
113
|
+
line(depth, `try ${node.position} error=${binding(node.error)}${at}`);
|
|
114
|
+
visit(node.try, depth + 1);
|
|
115
|
+
line(depth + 1, "catch");
|
|
116
|
+
visit(node.catch, depth + 2);
|
|
117
|
+
return;
|
|
118
|
+
case "and":
|
|
119
|
+
case "or":
|
|
120
|
+
line(depth, `${node.kind} ${node.position}${at}`);
|
|
121
|
+
for (const value of node.values)
|
|
122
|
+
visit(value, depth + 1);
|
|
123
|
+
return;
|
|
124
|
+
case "map":
|
|
125
|
+
line(depth, `map ${node.position} item=${binding(node.item)} index=${binding(node.index)}${at}`);
|
|
126
|
+
items(node.items, depth + 1);
|
|
127
|
+
if (node.fn) {
|
|
128
|
+
line(depth + 1, "fn");
|
|
129
|
+
visit(node.fn, depth + 2);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
case "reduce":
|
|
133
|
+
line(depth, `reduce ${node.position} acc=${binding(node.acc)} item=${binding(node.item)} index=${binding(node.index)}${at}`);
|
|
134
|
+
if (node.items)
|
|
135
|
+
items(node.items, depth + 1);
|
|
136
|
+
line(depth + 1, "initial");
|
|
137
|
+
visit(node.initial, depth + 2);
|
|
138
|
+
if (node.fn) {
|
|
139
|
+
line(depth + 1, "fn");
|
|
140
|
+
visit(node.fn, depth + 2);
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
visit(ir.root, 1);
|
|
146
|
+
return `${lines.join("\n")}\n`;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../src/print.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,SAAS,IAAI,CAAC,KAAc;IAC1B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,IAAI,KAAK,SA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E,CAAC,CAAC;gBAC7H,IAAI,IAAI,CAAC,KAAK;oBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC7C,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC/B,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;oBACZ,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;oBACtB,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC5B,CAAC;gBACD,OAAO;QACX,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAClB,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.check procedure
|
|
3
|
+
*
|
|
4
|
+
* Check a program before it runs: the names, the procedures, the inputs, the capability and the
|
|
5
|
+
* effects. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProcedureContext } from "@procedures/client/browser";
|
|
8
|
+
import { type ProgramCheckInput, type ProgramCheckOutput } from "../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* This function checks a program against the registry and the expose rule of the host. The
|
|
11
|
+
* capability is the capability of the input, or the capability of the caller.
|
|
12
|
+
*/
|
|
13
|
+
export declare function programCheck(input: ProgramCheckInput, ctx?: ProcedureContext): Promise<ProgramCheckOutput>;
|
|
14
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,EAAgB,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAG/F;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAchH"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.check procedure
|
|
3
|
+
*
|
|
4
|
+
* Check a program before it runs: the names, the procedures, the inputs, the capability and the
|
|
5
|
+
* effects. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { PROCEDURE_REGISTRY } from "@procedures/client/browser";
|
|
8
|
+
import { checkProgram } from "../../program.js";
|
|
9
|
+
import { toCapability } from "../../types.js";
|
|
10
|
+
import { effectsOutput } from "./effects-output.js";
|
|
11
|
+
/**
|
|
12
|
+
* This function checks a program against the registry and the expose rule of the host. The
|
|
13
|
+
* capability is the capability of the input, or the capability of the caller.
|
|
14
|
+
*/
|
|
15
|
+
export async function programCheck(input, ctx) {
|
|
16
|
+
const result = checkProgram(input.program, {
|
|
17
|
+
registry: ctx?.registry ?? PROCEDURE_REGISTRY,
|
|
18
|
+
expose: ctx?.expose,
|
|
19
|
+
capability: input.capability ? toCapability(input.capability) : ctx?.capability,
|
|
20
|
+
mode: input.mode,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
ok: result.ok,
|
|
24
|
+
effects: effectsOutput(result.effects),
|
|
25
|
+
mustEffects: result.mustEffects,
|
|
26
|
+
diagnostics: result.diagnostics,
|
|
27
|
+
registryHash: result.registryHash,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/procedures/program/check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAmD,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB,EAAE,GAAsB;IACjF,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE;QACzC,QAAQ,EAAE,GAAG,EAAE,QAAQ,IAAI,kBAAkB;QAC7C,MAAM,EAAE,GAAG,EAAE,MAAM;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU;QAC/E,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IACH,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.compile procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure compiles a program to a JavaScript function. It checks the program first. Then
|
|
5
|
+
* it writes the text of an ES module.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProcedureContext } from "@procedures/client/browser";
|
|
8
|
+
import { type ProgramCompileInput, type ProgramCompileOutput } from "../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* This function compiles a program against the registry and the expose rule of the host. The
|
|
11
|
+
* output has the source text, not the closure code: a closure does not go through JSON.
|
|
12
|
+
*/
|
|
13
|
+
export declare function programCompile(input: ProgramCompileInput, ctx?: ProcedureContext): Promise<ProgramCompileOutput>;
|
|
14
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/compile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,EAAgB,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGnG;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmBtH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.compile procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure compiles a program to a JavaScript function. It checks the program first. Then
|
|
5
|
+
* it writes the text of an ES module.
|
|
6
|
+
*/
|
|
7
|
+
import { PROCEDURE_REGISTRY } from "@procedures/client/browser";
|
|
8
|
+
import { compileProgram } from "../../program.js";
|
|
9
|
+
import { toCapability } from "../../types.js";
|
|
10
|
+
import { effectsOutput } from "./effects-output.js";
|
|
11
|
+
/**
|
|
12
|
+
* This function compiles a program against the registry and the expose rule of the host. The
|
|
13
|
+
* output has the source text, not the closure code: a closure does not go through JSON.
|
|
14
|
+
*/
|
|
15
|
+
export async function programCompile(input, ctx) {
|
|
16
|
+
const result = await compileProgram(input.program, {
|
|
17
|
+
registry: ctx?.registry ?? PROCEDURE_REGISTRY,
|
|
18
|
+
expose: ctx?.expose,
|
|
19
|
+
capability: input.capability ? toCapability(input.capability) : ctx?.capability,
|
|
20
|
+
mode: input.mode,
|
|
21
|
+
fold: input.fold,
|
|
22
|
+
language: input.language,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
ok: result.ok,
|
|
26
|
+
effects: effectsOutput(result.effects),
|
|
27
|
+
mustEffects: result.mustEffects,
|
|
28
|
+
diagnostics: result.diagnostics,
|
|
29
|
+
registryHash: result.registryHash,
|
|
30
|
+
code: result.code,
|
|
31
|
+
sourceMap: result.sourceMap,
|
|
32
|
+
folded: [...result.folded],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../src/procedures/program/compile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAuD,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B,EAAE,GAAsB;IACrF,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE;QACjD,QAAQ,EAAE,GAAG,EAAE,QAAQ,IAAI,kBAAkB;QAC7C,MAAM,EAAE,GAAG,EAAE,MAAM;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU;QAC/E,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.diagram procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure draws a program as a Mermaid flowchart: the order of the calls, the control
|
|
5
|
+
* flow and the names. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProcedureContext } from "@procedures/client/browser";
|
|
8
|
+
import type { ProgramDiagramInput, ProgramDiagramOutput } from "../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* This function checks a program against the registry and the expose rule of the host. It gives
|
|
11
|
+
* the flowchart of the IR and the diagnostics of the check.
|
|
12
|
+
*/
|
|
13
|
+
export declare function programDiagram(input: ProgramDiagramInput, ctx?: ProcedureContext): Promise<ProgramDiagramOutput>;
|
|
14
|
+
//# sourceMappingURL=diagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/diagram.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEhF;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAStH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.diagram procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure draws a program as a Mermaid flowchart: the order of the calls, the control
|
|
5
|
+
* flow and the names. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { PROCEDURE_REGISTRY } from "@procedures/client/browser";
|
|
8
|
+
import { diagramProgram } from "../../mermaid.js";
|
|
9
|
+
/**
|
|
10
|
+
* This function checks a program against the registry and the expose rule of the host. It gives
|
|
11
|
+
* the flowchart of the IR and the diagnostics of the check.
|
|
12
|
+
*/
|
|
13
|
+
export async function programDiagram(input, ctx) {
|
|
14
|
+
const result = diagramProgram(input.program, {
|
|
15
|
+
registry: ctx?.registry ?? PROCEDURE_REGISTRY,
|
|
16
|
+
expose: ctx?.expose,
|
|
17
|
+
capability: ctx?.capability,
|
|
18
|
+
mode: input.mode,
|
|
19
|
+
direction: input.direction,
|
|
20
|
+
});
|
|
21
|
+
return { mermaid: result.mermaid, diagnostics: result.diagnostics };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=diagram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram.js","sourceRoot":"","sources":["../../../src/procedures/program/diagram.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B,EAAE,GAAsB;IACrF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE;QAC3C,QAAQ,EAAE,GAAG,EAAE,QAAQ,IAAI,kBAAkB;QAC7C,MAAM,EAAE,GAAG,EAAE,MAAM;QACnB,UAAU,EAAE,GAAG,EAAE,UAAU;QAC3B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The effects of a program in the JSON output of the procedures.
|
|
3
|
+
*/
|
|
4
|
+
import type { Effects } from "@procedures/client/browser";
|
|
5
|
+
import type { EffectsOutput } from "../../types.js";
|
|
6
|
+
/** This function copies the effects into mutable lists for the output schema. */
|
|
7
|
+
export declare function effectsOutput(effects: Effects): EffectsOutput;
|
|
8
|
+
//# sourceMappingURL=effects-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects-output.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/effects-output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAO7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The effects of a program in the JSON output of the procedures.
|
|
3
|
+
*/
|
|
4
|
+
/** This function copies the effects into mutable lists for the output schema. */
|
|
5
|
+
export function effectsOutput(effects) {
|
|
6
|
+
return {
|
|
7
|
+
...(effects.reads ? { reads: [...effects.reads] } : {}),
|
|
8
|
+
...(effects.writes ? { writes: [...effects.writes] } : {}),
|
|
9
|
+
...(effects.destructive !== undefined ? { destructive: effects.destructive } : {}),
|
|
10
|
+
...(effects.idempotent !== undefined ? { idempotent: effects.idempotent } : {}),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=effects-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects-output.js","sourceRoot":"","sources":["../../../src/procedures/program/effects-output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;QACL,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.explain procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure explains a program before it starts: the effects, each call with its declared
|
|
5
|
+
* effects and the answer of the capability, and the diagnostics. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProcedureContext } from "@procedures/client/browser";
|
|
8
|
+
import { type ProgramExplainInput, type ProgramExplainOutput } from "../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* This function explains a program against the registry and the expose rule of the host. The
|
|
11
|
+
* capability is the capability of the input, or the capability of the caller.
|
|
12
|
+
*/
|
|
13
|
+
export declare function programExplain(input: ProgramExplainInput, ctx?: ProcedureContext): Promise<ProgramExplainOutput>;
|
|
14
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/explain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,EAA4C,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAG/H;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BtH"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* program.explain procedure
|
|
3
|
+
*
|
|
4
|
+
* This procedure explains a program before it starts: the effects, each call with its declared
|
|
5
|
+
* effects and the answer of the capability, and the diagnostics. No call of the program starts.
|
|
6
|
+
*/
|
|
7
|
+
import { PROCEDURE_REGISTRY } from "@procedures/client/browser";
|
|
8
|
+
import { explainProgram } from "../../explain.js";
|
|
9
|
+
import { toCapability } from "../../types.js";
|
|
10
|
+
import { effectsOutput } from "./effects-output.js";
|
|
11
|
+
/**
|
|
12
|
+
* This function explains a program against the registry and the expose rule of the host. The
|
|
13
|
+
* capability is the capability of the input, or the capability of the caller.
|
|
14
|
+
*/
|
|
15
|
+
export async function programExplain(input, ctx) {
|
|
16
|
+
const result = explainProgram(input.program, {
|
|
17
|
+
registry: ctx?.registry ?? PROCEDURE_REGISTRY,
|
|
18
|
+
expose: ctx?.expose,
|
|
19
|
+
capability: input.capability ? toCapability(input.capability) : ctx?.capability,
|
|
20
|
+
mode: input.mode,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
ok: result.ok,
|
|
24
|
+
effects: effectsOutput(result.effects),
|
|
25
|
+
mustEffects: result.mustEffects,
|
|
26
|
+
calls: result.calls.map((call) => ({
|
|
27
|
+
key: call.key,
|
|
28
|
+
path: [...call.path],
|
|
29
|
+
pointer: call.pointer,
|
|
30
|
+
kind: call.kind,
|
|
31
|
+
...(call.effects ? { effects: effectsOutput(call.effects) } : {}),
|
|
32
|
+
known: call.known,
|
|
33
|
+
exposed: call.exposed,
|
|
34
|
+
permitted: call.permitted,
|
|
35
|
+
...(call.reason !== undefined ? { reason: call.reason } : {}),
|
|
36
|
+
message: call.message,
|
|
37
|
+
})),
|
|
38
|
+
diagnostics: result.diagnostics,
|
|
39
|
+
registryHash: result.registryHash,
|
|
40
|
+
summary: result.summary,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../../../src/procedures/program/explain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAmF,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B,EAAE,GAAsB;IACrF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE;QAC3C,QAAQ,EAAE,GAAG,EAAE,QAAQ,IAAI,kBAAkB;QAC7C,MAAM,EAAE,GAAG,EAAE,MAAM;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU;QAC/E,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IACH,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CACrB,CAAC,IAAI,EAAyB,EAAE,CAAC,CAAC;YAChC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CACH;QACD,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/program/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/program/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manifest that the procedures `sdk.openrpc` and `sdk.typescript` read.
|
|
3
|
+
*/
|
|
4
|
+
import { type ProcedureContext, type ProcedureManifest } from "@procedures/client/browser";
|
|
5
|
+
import type { SdkInput } from "../../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* This function describes the registry of the caller, as `procedure.manifest` does. The manifest
|
|
8
|
+
* has only the procedures that the host exposes, and only one namespace when the input names it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function manifestOf(input: SdkInput, ctx?: ProcedureContext): ProcedureManifest;
|
|
11
|
+
//# sourceMappingURL=manifest.d.ts.map
|