@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types and schemas of the procedures of this package: `program.check`, `program.compile`,
|
|
3
|
+
* `program.diagram`, `program.explain`, `sdk.openrpc` and `sdk.typescript`.
|
|
4
|
+
*
|
|
5
|
+
* mark procedure new adds the types of each new procedure here.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import type { Capability } from "@procedures/client/browser";
|
|
9
|
+
import type { Diagnostic } from "./diagnostics.js";
|
|
10
|
+
/** The JSON form of a capability: the effects that the run can have. */
|
|
11
|
+
export interface CapabilityInput {
|
|
12
|
+
clearance?: unknown;
|
|
13
|
+
effects?: {
|
|
14
|
+
reads?: string[] | "any" | undefined;
|
|
15
|
+
writes?: string[] | "any" | undefined;
|
|
16
|
+
destructive?: boolean | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
deadline?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** The schema of a capability in the input of the procedures. */
|
|
21
|
+
export declare const CapabilityInputSchema: z.ZodType<CapabilityInput>;
|
|
22
|
+
/** This function makes a capability from its JSON form. */
|
|
23
|
+
export declare function toCapability(input: CapabilityInput): Capability<unknown>;
|
|
24
|
+
/** The effects of a program, in the output of the procedures. */
|
|
25
|
+
export interface EffectsOutput {
|
|
26
|
+
reads?: string[] | undefined;
|
|
27
|
+
writes?: string[] | undefined;
|
|
28
|
+
destructive?: boolean | undefined;
|
|
29
|
+
idempotent?: boolean | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The input of `program.check`. */
|
|
32
|
+
export interface ProgramCheckInput {
|
|
33
|
+
program: unknown;
|
|
34
|
+
capability?: CapabilityInput | undefined;
|
|
35
|
+
mode?: "exec" | "body" | undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare const ProgramCheckInputSchema: z.ZodType<ProgramCheckInput>;
|
|
38
|
+
/** The output of `program.check`. */
|
|
39
|
+
export interface ProgramCheckOutput {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
effects: EffectsOutput;
|
|
42
|
+
mustEffects: {
|
|
43
|
+
reads: string[];
|
|
44
|
+
writes: string[];
|
|
45
|
+
};
|
|
46
|
+
diagnostics: Diagnostic[];
|
|
47
|
+
registryHash: string;
|
|
48
|
+
}
|
|
49
|
+
export declare const ProgramCheckOutputSchema: z.ZodType<ProgramCheckOutput>;
|
|
50
|
+
/** The input of `program.compile`. */
|
|
51
|
+
export interface ProgramCompileInput extends ProgramCheckInput {
|
|
52
|
+
fold?: boolean | undefined;
|
|
53
|
+
language?: "js" | "ts" | undefined;
|
|
54
|
+
}
|
|
55
|
+
export declare const ProgramCompileInputSchema: z.ZodType<ProgramCompileInput>;
|
|
56
|
+
/** The output of `program.compile`. */
|
|
57
|
+
export interface ProgramCompileOutput extends ProgramCheckOutput {
|
|
58
|
+
code: string;
|
|
59
|
+
sourceMap: Array<{
|
|
60
|
+
line: number;
|
|
61
|
+
pointer: string;
|
|
62
|
+
}>;
|
|
63
|
+
folded: string[];
|
|
64
|
+
}
|
|
65
|
+
export declare const ProgramCompileOutputSchema: z.ZodType<ProgramCompileOutput>;
|
|
66
|
+
/** The input of `program.diagram`. */
|
|
67
|
+
export interface ProgramDiagramInput {
|
|
68
|
+
program: unknown;
|
|
69
|
+
mode?: "exec" | "body" | undefined;
|
|
70
|
+
direction?: "TD" | "LR" | undefined;
|
|
71
|
+
}
|
|
72
|
+
export declare const ProgramDiagramInputSchema: z.ZodType<ProgramDiagramInput>;
|
|
73
|
+
/** The output of `program.diagram`. */
|
|
74
|
+
export interface ProgramDiagramOutput {
|
|
75
|
+
mermaid: string;
|
|
76
|
+
diagnostics: Diagnostic[];
|
|
77
|
+
}
|
|
78
|
+
export declare const ProgramDiagramOutputSchema: z.ZodType<ProgramDiagramOutput>;
|
|
79
|
+
/** The input of `program.explain`. */
|
|
80
|
+
export type ProgramExplainInput = ProgramCheckInput;
|
|
81
|
+
export declare const ProgramExplainInputSchema: z.ZodType<ProgramExplainInput>;
|
|
82
|
+
/** The explanation of one call, in the output of `program.explain`. */
|
|
83
|
+
export interface CallExplanationOutput {
|
|
84
|
+
key: string;
|
|
85
|
+
path: string[];
|
|
86
|
+
pointer: string;
|
|
87
|
+
kind: "call" | "control" | "dynamic";
|
|
88
|
+
effects?: EffectsOutput | undefined;
|
|
89
|
+
known: boolean;
|
|
90
|
+
exposed: boolean;
|
|
91
|
+
permitted: boolean;
|
|
92
|
+
reason?: "effects-undeclared" | "effects-exceeded" | "clearance" | "deadline" | "not-found" | undefined;
|
|
93
|
+
message: string;
|
|
94
|
+
}
|
|
95
|
+
/** The output of `program.explain`. */
|
|
96
|
+
export interface ProgramExplainOutput extends ProgramCheckOutput {
|
|
97
|
+
calls: CallExplanationOutput[];
|
|
98
|
+
summary: string;
|
|
99
|
+
}
|
|
100
|
+
export declare const ProgramExplainOutputSchema: z.ZodType<ProgramExplainOutput>;
|
|
101
|
+
/** The input of `sdk.openrpc` and `sdk.typescript`. */
|
|
102
|
+
export interface SdkInput {
|
|
103
|
+
namespace?: string | undefined;
|
|
104
|
+
}
|
|
105
|
+
/** The input of `sdk.openrpc`. */
|
|
106
|
+
export type SdkOpenrpcInput = SdkInput;
|
|
107
|
+
export declare const SdkOpenrpcInputSchema: z.ZodType<SdkOpenrpcInput>;
|
|
108
|
+
/** The output of `sdk.openrpc`: an OpenRPC 1.3 document. */
|
|
109
|
+
export interface SdkOpenrpcOutput {
|
|
110
|
+
openrpc: string;
|
|
111
|
+
info: {
|
|
112
|
+
title: string;
|
|
113
|
+
version: string;
|
|
114
|
+
description?: string | undefined;
|
|
115
|
+
};
|
|
116
|
+
methods: Array<Record<string, unknown>>;
|
|
117
|
+
}
|
|
118
|
+
export declare const SdkOpenrpcOutputSchema: z.ZodType<SdkOpenrpcOutput>;
|
|
119
|
+
/** The input of `sdk.typescript`. */
|
|
120
|
+
export type SdkTypescriptInput = SdkInput;
|
|
121
|
+
export declare const SdkTypescriptInputSchema: z.ZodType<SdkTypescriptInput>;
|
|
122
|
+
/** The output of `sdk.typescript`. */
|
|
123
|
+
export interface SdkTypescriptOutput {
|
|
124
|
+
code: string;
|
|
125
|
+
procedures: number;
|
|
126
|
+
registryHash: string;
|
|
127
|
+
}
|
|
128
|
+
export declare const SdkTypescriptOutputSchema: z.ZodType<SdkTypescriptOutput>;
|
|
129
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MA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M,GAAG,SAAS,CAAA;KAAE,CAAC;IAC3E,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAY9B,CAAC;AAMlC,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE1C,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAkB,CAAC;AAEtF,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAIjC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types and schemas of the procedures of this package: `program.check`, `program.compile`,
|
|
3
|
+
* `program.diagram`, `program.explain`, `sdk.openrpc` and `sdk.typescript`.
|
|
4
|
+
*
|
|
5
|
+
* mark procedure new adds the types of each new procedure here.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
const PermitSchema = z.union([z.array(z.string()), z.literal("any")]);
|
|
9
|
+
/** The schema of a capability in the input of the procedures. */
|
|
10
|
+
export const CapabilityInputSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
clearance: z.unknown().optional().describe("The clearance of the run"),
|
|
13
|
+
effects: z
|
|
14
|
+
.object({
|
|
15
|
+
reads: PermitSchema.optional().describe('The resources that a call can read: names, or "any"'),
|
|
16
|
+
writes: PermitSchema.optional().describe('The resources that a call can change: names, or "any". An empty list: no change.'),
|
|
17
|
+
destructive: z.boolean().optional().describe("False: a call cannot start a destructive procedure"),
|
|
18
|
+
})
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("The effects that the calls can have. Absent: all effects."),
|
|
21
|
+
deadline: z.number().optional().describe("The deadline (the static check does not use it)"),
|
|
22
|
+
})
|
|
23
|
+
.describe("The capability of the run. Absent: the capability of the caller.");
|
|
24
|
+
/** This function makes a capability from its JSON form. */
|
|
25
|
+
export function toCapability(input) {
|
|
26
|
+
const effects = {};
|
|
27
|
+
if (input.effects?.reads !== undefined)
|
|
28
|
+
effects.reads = input.effects.reads;
|
|
29
|
+
if (input.effects?.writes !== undefined)
|
|
30
|
+
effects.writes = input.effects.writes;
|
|
31
|
+
if (input.effects?.destructive !== undefined)
|
|
32
|
+
effects.destructive = input.effects.destructive;
|
|
33
|
+
return {
|
|
34
|
+
...(input.clearance !== undefined ? { clearance: input.clearance } : {}),
|
|
35
|
+
...(input.effects ? { effects: effects } : {}),
|
|
36
|
+
...(input.deadline !== undefined ? { deadline: input.deadline } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const EffectsOutputSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
reads: z.array(z.string()).optional().describe("The resources that a run can read. Absent: not known."),
|
|
42
|
+
writes: z.array(z.string()).optional().describe("The resources that a run can change. Absent: not known."),
|
|
43
|
+
destructive: z.boolean().optional().describe("True: a call can delete or overwrite data"),
|
|
44
|
+
idempotent: z.boolean().optional().describe("True: each call that changes data is idempotent"),
|
|
45
|
+
})
|
|
46
|
+
.describe("The effects that a run can have (the upper bound)");
|
|
47
|
+
const MustEffectsSchema = z
|
|
48
|
+
.object({
|
|
49
|
+
reads: z.array(z.string()).describe("The resources that each run reads"),
|
|
50
|
+
writes: z.array(z.string()).describe("The resources that each run changes"),
|
|
51
|
+
})
|
|
52
|
+
.describe("The effects of each run in which no call fails (the lower bound)");
|
|
53
|
+
const DiagnosticSchema = z.object({
|
|
54
|
+
severity: z.enum(["error", "warning", "info"]).describe("An error stops the program"),
|
|
55
|
+
code: z.string().describe("The code of the problem, for example unknown-name"),
|
|
56
|
+
message: z.string().describe("The text of the problem"),
|
|
57
|
+
pointer: z.string().describe("The JSON pointer of the part of the program"),
|
|
58
|
+
});
|
|
59
|
+
const ProgramField = z.unknown().describe("The program: a call ({ $proc, input }). The procedure reads it as data: nothing in it starts.");
|
|
60
|
+
const ModeField = z
|
|
61
|
+
.enum(["exec", "body"])
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("exec (the default): the program runs as client.exec runs it. body: as the body of a defined procedure, with input in scope.");
|
|
64
|
+
export const ProgramCheckInputSchema = z.object({
|
|
65
|
+
program: ProgramField,
|
|
66
|
+
capability: CapabilityInputSchema.optional(),
|
|
67
|
+
mode: ModeField,
|
|
68
|
+
});
|
|
69
|
+
const checkOutputFields = {
|
|
70
|
+
ok: z.boolean().describe("True when no diagnostic is an error: then the host can start the program"),
|
|
71
|
+
effects: EffectsOutputSchema,
|
|
72
|
+
mustEffects: MustEffectsSchema,
|
|
73
|
+
diagnostics: z.array(DiagnosticSchema).describe("The problems, in the order of the program"),
|
|
74
|
+
registryHash: z.string().describe("The hash of the manifest that the check used"),
|
|
75
|
+
};
|
|
76
|
+
export const ProgramCheckOutputSchema = z.object(checkOutputFields);
|
|
77
|
+
export const ProgramCompileInputSchema = z.object({
|
|
78
|
+
program: ProgramField,
|
|
79
|
+
capability: CapabilityInputSchema.optional(),
|
|
80
|
+
mode: ModeField,
|
|
81
|
+
fold: z.boolean().optional().describe("True: compute the pure core calls with literal inputs now"),
|
|
82
|
+
language: z.enum(["js", "ts"]).optional().describe("The language of the code: js (the default) or ts"),
|
|
83
|
+
});
|
|
84
|
+
export const ProgramCompileOutputSchema = z.object({
|
|
85
|
+
...checkOutputFields,
|
|
86
|
+
code: z.string().describe("The ES module: its default export is async (ctx, input) => output"),
|
|
87
|
+
sourceMap: z
|
|
88
|
+
.array(z.object({ line: z.number().describe("The line of the code, from 1"), pointer: z.string().describe("The JSON pointer of the part of the program") }))
|
|
89
|
+
.describe("The lines of the code that start a part of the program"),
|
|
90
|
+
folded: z.array(z.string()).describe("The pointers of the calls that the fold pass computed"),
|
|
91
|
+
});
|
|
92
|
+
export const ProgramDiagramInputSchema = z.object({
|
|
93
|
+
program: ProgramField,
|
|
94
|
+
mode: ModeField,
|
|
95
|
+
direction: z.enum(["TD", "LR"]).optional().describe("The direction of the flowchart: TD (from the top down, the default) or LR (from left to right)"),
|
|
96
|
+
});
|
|
97
|
+
export const ProgramDiagramOutputSchema = z.object({
|
|
98
|
+
mermaid: z.string().describe("The Mermaid flowchart of the program. A node with an error has the class error."),
|
|
99
|
+
diagnostics: z.array(DiagnosticSchema).describe("The problems that the check found, in the order of the program"),
|
|
100
|
+
});
|
|
101
|
+
export const ProgramExplainInputSchema = z.object({
|
|
102
|
+
program: ProgramField,
|
|
103
|
+
capability: CapabilityInputSchema.optional(),
|
|
104
|
+
mode: ModeField,
|
|
105
|
+
});
|
|
106
|
+
const DeclaredEffectsSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
reads: z.array(z.string()).optional().describe("The resources that the procedure can read. Absent: not declared."),
|
|
109
|
+
writes: z.array(z.string()).optional().describe("The resources that the procedure can change. Absent: not declared."),
|
|
110
|
+
destructive: z.boolean().optional().describe("True: the procedure can delete or overwrite data"),
|
|
111
|
+
idempotent: z.boolean().optional().describe("True: a second call with the same input changes nothing more"),
|
|
112
|
+
})
|
|
113
|
+
.describe("The effects that the procedure declares. Absent: the procedure declares none.");
|
|
114
|
+
const CallExplanationSchema = z.object({
|
|
115
|
+
key: z.string().describe("The key of the procedure: its path with dots"),
|
|
116
|
+
path: z.array(z.string()).describe("The path of the procedure"),
|
|
117
|
+
pointer: z.string().describe("The JSON pointer of the call in the program"),
|
|
118
|
+
kind: z.enum(["call", "control", "dynamic"]).describe("call, a control-flow call, or a dynamic call whose input is a program"),
|
|
119
|
+
effects: DeclaredEffectsSchema.optional(),
|
|
120
|
+
known: z.boolean().describe("True when the host has a procedure at the path"),
|
|
121
|
+
exposed: z.boolean().describe("True when the host has the procedure and lets a program call it"),
|
|
122
|
+
permitted: z.boolean().describe("True when the capability permits the call"),
|
|
123
|
+
reason: z
|
|
124
|
+
.enum(["effects-undeclared", "effects-exceeded", "clearance", "deadline", "not-found"])
|
|
125
|
+
.optional()
|
|
126
|
+
.describe("The reason of a refusal, or not-found for a path without a procedure"),
|
|
127
|
+
message: z.string().describe("The answer of the capability in words"),
|
|
128
|
+
});
|
|
129
|
+
export const ProgramExplainOutputSchema = z.object({
|
|
130
|
+
...checkOutputFields,
|
|
131
|
+
calls: z.array(CallExplanationSchema).describe("The calls of the program, in the order of the tree: a call comes before the calls of its input"),
|
|
132
|
+
summary: z.string().describe("The explanation in short sentences"),
|
|
133
|
+
});
|
|
134
|
+
const SdkInputSchema = z.object({
|
|
135
|
+
namespace: z.string().optional().describe("Only the procedures under this first path segment"),
|
|
136
|
+
});
|
|
137
|
+
export const SdkOpenrpcInputSchema = SdkInputSchema;
|
|
138
|
+
export const SdkOpenrpcOutputSchema = z.object({
|
|
139
|
+
openrpc: z.string().describe("The version of the OpenRPC specification"),
|
|
140
|
+
info: z
|
|
141
|
+
.object({
|
|
142
|
+
title: z.string().describe("The title of the document"),
|
|
143
|
+
version: z.string().describe("The version of the document: the hash of the manifest"),
|
|
144
|
+
description: z.string().optional().describe("The description of the document"),
|
|
145
|
+
})
|
|
146
|
+
.describe("The information about the document"),
|
|
147
|
+
methods: z
|
|
148
|
+
.array(z.record(z.string(), z.unknown()))
|
|
149
|
+
.describe("One method for each procedure, in the order of the names: params, result, x-path and x-effects"),
|
|
150
|
+
});
|
|
151
|
+
export const SdkTypescriptInputSchema = SdkInputSchema;
|
|
152
|
+
export const SdkTypescriptOutputSchema = z.object({
|
|
153
|
+
code: z.string().describe("The source of the TypeScript module: the types, the interface Sdk and the function createSdk"),
|
|
154
|
+
procedures: z.number().describe("The number of procedures in the SDK"),
|
|
155
|
+
registryHash: z.string().describe("The hash of the manifest that the SDK comes from"),
|
|
156
|
+
});
|
|
157
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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Q,CAAC,kDAAkD,CAAC;CACtF,CAAmC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A typed TypeScript SDK from a manifest (roadmap R23).
|
|
3
|
+
*
|
|
4
|
+
* The manifest of a host has the JSON Schemas of each procedure. This module writes the source
|
|
5
|
+
* of a TypeScript module from them:
|
|
6
|
+
*
|
|
7
|
+
* - One input type and one output type for each procedure.
|
|
8
|
+
* - The interface `Sdk`, with one method for each procedure at `sdk.<namespace>.<name>`.
|
|
9
|
+
* - The function `createSdk(client)`, whose methods call `client.call(path, input)`.
|
|
10
|
+
*
|
|
11
|
+
* The converter knows a part of JSON Schema. It knows objects with the `required` list, arrays,
|
|
12
|
+
* strings, numbers, booleans, `null`, `enum`, `const`, `anyOf`, `oneOf` and `additionalProperties`.
|
|
13
|
+
* It writes `unknown` for each other schema. The source has no imports, and it type-checks with
|
|
14
|
+
* the strict options of this repository.
|
|
15
|
+
*/
|
|
16
|
+
import { type ProcedureManifest } from "@procedures/client/browser";
|
|
17
|
+
/** The options of `toTypeScriptSdk()`. */
|
|
18
|
+
export interface TypeScriptSdkOptions {
|
|
19
|
+
/** The text of the first comment of the module. The default names the manifest and its hash. */
|
|
20
|
+
readonly header?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This function gives the TypeScript type of a JSON Schema (draft-07). It knows objects, arrays,
|
|
24
|
+
* strings, numbers, booleans, `null`, `enum`, `const`, `anyOf`, `oneOf` and `additionalProperties`.
|
|
25
|
+
* Each other schema gives `unknown`. `indent` is the indentation of the lines of an object type.
|
|
26
|
+
*/
|
|
27
|
+
export declare function schemaToType(schema: unknown, indent?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* This function writes the source of a typed TypeScript SDK for the procedures of a manifest.
|
|
30
|
+
* The module exports an input type and an output type for each procedure, the interface `Sdk`,
|
|
31
|
+
* the interface `SdkClient` and the function `createSdk()`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function toTypeScriptSdk(manifest: ProcedureManifest, options?: TypeScriptSdkOptions): string;
|
|
34
|
+
//# sourceMappingURL=typescript-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-sdk.d.ts","sourceRoot":"","sources":["../src/typescript-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAwC,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE1G,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,gGAAgG;IAChG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAiDD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,MAAM,CA6BzE;AA8FD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CA6EvG"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A typed TypeScript SDK from a manifest (roadmap R23).
|
|
3
|
+
*
|
|
4
|
+
* The manifest of a host has the JSON Schemas of each procedure. This module writes the source
|
|
5
|
+
* of a TypeScript module from them:
|
|
6
|
+
*
|
|
7
|
+
* - One input type and one output type for each procedure.
|
|
8
|
+
* - The interface `Sdk`, with one method for each procedure at `sdk.<namespace>.<name>`.
|
|
9
|
+
* - The function `createSdk(client)`, whose methods call `client.call(path, input)`.
|
|
10
|
+
*
|
|
11
|
+
* The converter knows a part of JSON Schema. It knows objects with the `required` list, arrays,
|
|
12
|
+
* strings, numbers, booleans, `null`, `enum`, `const`, `anyOf`, `oneOf` and `additionalProperties`.
|
|
13
|
+
* It writes `unknown` for each other schema. The source has no imports, and it type-checks with
|
|
14
|
+
* the strict options of this repository.
|
|
15
|
+
*/
|
|
16
|
+
import { MANIFEST_FORMAT } from "@procedures/client/browser";
|
|
17
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
18
|
+
function isSchema(value) {
|
|
19
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
/** The name of a property in a type: an identifier as it is, else a string literal. */
|
|
22
|
+
function propertyName(name) {
|
|
23
|
+
return IDENTIFIER.test(name) ? name : JSON.stringify(name);
|
|
24
|
+
}
|
|
25
|
+
/** The key of a property in an object literal. The key `__proto__` sets the prototype, so it is a computed key. */
|
|
26
|
+
function literalKey(name) {
|
|
27
|
+
return name === "__proto__" ? '["__proto__"]' : propertyName(name);
|
|
28
|
+
}
|
|
29
|
+
/** The text of a comment: no end of the comment, and no line breaks. */
|
|
30
|
+
function commentText(text) {
|
|
31
|
+
return text.replace(/\*\//g, "*\\/").replace(/[\r\n\u2028\u2029]+/g, " ").trim();
|
|
32
|
+
}
|
|
33
|
+
/** The type of a JSON value in `const` or `enum`: a literal type, or `unknown` for an object. */
|
|
34
|
+
function literalType(value) {
|
|
35
|
+
if (value === null)
|
|
36
|
+
return "null";
|
|
37
|
+
if (typeof value === "string")
|
|
38
|
+
return JSON.stringify(value);
|
|
39
|
+
if (typeof value === "boolean")
|
|
40
|
+
return String(value);
|
|
41
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
42
|
+
return String(value);
|
|
43
|
+
return "unknown";
|
|
44
|
+
}
|
|
45
|
+
function union(types) {
|
|
46
|
+
const unique = [...new Set(types)];
|
|
47
|
+
if (unique.length === 0)
|
|
48
|
+
return "never";
|
|
49
|
+
if (unique.includes("unknown"))
|
|
50
|
+
return "unknown";
|
|
51
|
+
return unique.join(" | ");
|
|
52
|
+
}
|
|
53
|
+
/** True when an object schema has an empty `required` list, or none: then the input can be absent. */
|
|
54
|
+
function noRequired(schema) {
|
|
55
|
+
if (!isSchema(schema))
|
|
56
|
+
return false;
|
|
57
|
+
if (schema["type"] !== "object")
|
|
58
|
+
return false;
|
|
59
|
+
const required = schema["required"];
|
|
60
|
+
return !Array.isArray(required) || required.length === 0;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* This function gives the TypeScript type of a JSON Schema (draft-07). It knows objects, arrays,
|
|
64
|
+
* strings, numbers, booleans, `null`, `enum`, `const`, `anyOf`, `oneOf` and `additionalProperties`.
|
|
65
|
+
* Each other schema gives `unknown`. `indent` is the indentation of the lines of an object type.
|
|
66
|
+
*/
|
|
67
|
+
export function schemaToType(schema, indent = "") {
|
|
68
|
+
if (schema === false)
|
|
69
|
+
return "never";
|
|
70
|
+
if (!isSchema(schema))
|
|
71
|
+
return "unknown";
|
|
72
|
+
if ("const" in schema)
|
|
73
|
+
return literalType(schema["const"]);
|
|
74
|
+
const values = schema["enum"];
|
|
75
|
+
if (Array.isArray(values))
|
|
76
|
+
return union(values.map(literalType));
|
|
77
|
+
const variants = schema["anyOf"] ?? schema["oneOf"];
|
|
78
|
+
if (Array.isArray(variants))
|
|
79
|
+
return union(variants.map((variant) => schemaToType(variant, indent)));
|
|
80
|
+
const type = schema["type"];
|
|
81
|
+
if (Array.isArray(type))
|
|
82
|
+
return union(type.map((name) => schemaToType({ ...schema, type: name }, indent)));
|
|
83
|
+
switch (type) {
|
|
84
|
+
case "string":
|
|
85
|
+
return "string";
|
|
86
|
+
case "number":
|
|
87
|
+
case "integer":
|
|
88
|
+
return "number";
|
|
89
|
+
case "boolean":
|
|
90
|
+
return "boolean";
|
|
91
|
+
case "null":
|
|
92
|
+
return "null";
|
|
93
|
+
case "array": {
|
|
94
|
+
const items = schema["items"];
|
|
95
|
+
return `Array<${Array.isArray(items) ? "unknown" : schemaToType(items, indent)}>`;
|
|
96
|
+
}
|
|
97
|
+
case "object":
|
|
98
|
+
return objectType(schema, indent);
|
|
99
|
+
default:
|
|
100
|
+
return "unknown";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function objectType(schema, indent) {
|
|
104
|
+
const properties = isSchema(schema["properties"]) ? Object.entries(schema["properties"]) : [];
|
|
105
|
+
const required = new Set(Array.isArray(schema["required"]) ? schema["required"].filter((name) => typeof name === "string") : []);
|
|
106
|
+
const extra = schema["additionalProperties"];
|
|
107
|
+
const inner = `${indent} `;
|
|
108
|
+
const lines = [];
|
|
109
|
+
for (const [name, property] of properties) {
|
|
110
|
+
const description = isSchema(property) && typeof property["description"] === "string" ? commentText(property["description"]) : "";
|
|
111
|
+
if (description)
|
|
112
|
+
lines.push(`${inner}/** ${description} */`);
|
|
113
|
+
const optional = !required.has(name);
|
|
114
|
+
lines.push(`${inner}${propertyName(name)}${optional ? "?" : ""}: ${schemaToType(property, inner)}${optional ? " | undefined" : ""};`);
|
|
115
|
+
}
|
|
116
|
+
// Absent additionalProperties: an object without properties is open, and an object with properties is closed
|
|
117
|
+
const open = extra === true || (isSchema(extra) && Object.keys(extra).length === 0) || (extra === undefined && properties.length === 0);
|
|
118
|
+
if (open) {
|
|
119
|
+
lines.push(`${inner}[key: string]: unknown;`);
|
|
120
|
+
}
|
|
121
|
+
else if (isSchema(extra)) {
|
|
122
|
+
// An index signature must agree with each property, so a schema with properties gets unknown
|
|
123
|
+
lines.push(`${inner}[key: string]: ${properties.length === 0 ? schemaToType(extra, inner) : "unknown"};`);
|
|
124
|
+
}
|
|
125
|
+
if (lines.length === 0)
|
|
126
|
+
return "Record<string, never>";
|
|
127
|
+
return `{\n${lines.join("\n")}\n${indent}}`;
|
|
128
|
+
}
|
|
129
|
+
/** The PascalCase name of a path: the letters and digits of each segment. */
|
|
130
|
+
function pascalName(path) {
|
|
131
|
+
const name = path
|
|
132
|
+
.flatMap((segment) => segment.split(/[^A-Za-z0-9]+/))
|
|
133
|
+
.filter((part) => part.length > 0)
|
|
134
|
+
.map((part) => part[0].toUpperCase() + part.slice(1))
|
|
135
|
+
.join("");
|
|
136
|
+
return name === "" || /^[0-9]/.test(name) ? `P${name}` : name;
|
|
137
|
+
}
|
|
138
|
+
function signature(procedure) {
|
|
139
|
+
return `(input${procedure.optionalInput ? "?" : ""}: ${procedure.input}) => Promise<${procedure.output}>`;
|
|
140
|
+
}
|
|
141
|
+
/** The members of a node in the interface `Sdk`. */
|
|
142
|
+
function interfaceMembers(node, indent) {
|
|
143
|
+
const lines = [];
|
|
144
|
+
for (const [segment, child] of node.children) {
|
|
145
|
+
const description = child.procedure?.entry.description;
|
|
146
|
+
if (description)
|
|
147
|
+
lines.push(`${indent}/** ${commentText(description)} */`);
|
|
148
|
+
lines.push(`${indent}readonly ${propertyName(segment)}: ${memberType(child, indent)};`);
|
|
149
|
+
}
|
|
150
|
+
return lines;
|
|
151
|
+
}
|
|
152
|
+
function memberType(node, indent) {
|
|
153
|
+
const members = node.children.size > 0 ? `{\n${interfaceMembers(node, `${indent} `).join("\n")}\n${indent}}` : undefined;
|
|
154
|
+
if (!node.procedure)
|
|
155
|
+
return members ?? "Record<string, never>";
|
|
156
|
+
const fn = signature(node.procedure);
|
|
157
|
+
return members ? `(${fn}) & ${members}` : fn;
|
|
158
|
+
}
|
|
159
|
+
/** The value of a node in `createSdk()`. */
|
|
160
|
+
function memberValue(node, indent) {
|
|
161
|
+
const members = node.children.size > 0
|
|
162
|
+
? `{\n${[...node.children].map(([segment, child]) => `${indent} ${literalKey(segment)}: ${memberValue(child, `${indent} `)},`).join("\n")}\n${indent}}`
|
|
163
|
+
: undefined;
|
|
164
|
+
if (!node.procedure)
|
|
165
|
+
return members ?? "{}";
|
|
166
|
+
const procedure = node.procedure;
|
|
167
|
+
const path = `[${procedure.entry.path.map((segment) => JSON.stringify(segment)).join(", ")}]`;
|
|
168
|
+
const argument = procedure.emptyObject ? "input ?? {}" : "input";
|
|
169
|
+
const fn = `(input${procedure.optionalInput ? "?" : ""}: ${procedure.input}): Promise<${procedure.output}> => call(${path}, ${argument})`;
|
|
170
|
+
return members ? `withMembers(${fn}, ${members})` : fn;
|
|
171
|
+
}
|
|
172
|
+
function hasBoth(node) {
|
|
173
|
+
if (node.procedure && node.children.size > 0)
|
|
174
|
+
return true;
|
|
175
|
+
return [...node.children.values()].some(hasBoth);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* This function writes the source of a typed TypeScript SDK for the procedures of a manifest.
|
|
179
|
+
* The module exports an input type and an output type for each procedure, the interface `Sdk`,
|
|
180
|
+
* the interface `SdkClient` and the function `createSdk()`.
|
|
181
|
+
*/
|
|
182
|
+
export function toTypeScriptSdk(manifest, options = {}) {
|
|
183
|
+
const entries = [...manifest.procedures].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
184
|
+
const used = new Set();
|
|
185
|
+
const procedures = entries.map((entry) => {
|
|
186
|
+
let name = pascalName(entry.path);
|
|
187
|
+
for (let suffix = 2; used.has(name); suffix++)
|
|
188
|
+
name = `${pascalName(entry.path)}${suffix}`;
|
|
189
|
+
used.add(name);
|
|
190
|
+
const emptyObject = noRequired(entry.input);
|
|
191
|
+
const anyInput = schemaToType(entry.input) === "unknown";
|
|
192
|
+
return { entry, input: `${name}Input`, output: `${name}Output`, optionalInput: anyInput || emptyObject, emptyObject };
|
|
193
|
+
});
|
|
194
|
+
const root = { procedure: undefined, children: new Map() };
|
|
195
|
+
for (const procedure of procedures) {
|
|
196
|
+
let node = root;
|
|
197
|
+
for (const segment of procedure.entry.path) {
|
|
198
|
+
let child = node.children.get(segment);
|
|
199
|
+
if (!child) {
|
|
200
|
+
child = { procedure: undefined, children: new Map() };
|
|
201
|
+
node.children.set(segment, child);
|
|
202
|
+
}
|
|
203
|
+
node = child;
|
|
204
|
+
}
|
|
205
|
+
node.procedure = procedure;
|
|
206
|
+
}
|
|
207
|
+
const header = options.header ??
|
|
208
|
+
`The typed SDK of ${procedures.length} procedures. @procedures/compiler wrote this file from the manifest ${manifest.hash} (${MANIFEST_FORMAT}). Do not edit it: write it again from the manifest.`;
|
|
209
|
+
const out = [`/**`, ` * ${commentText(header)}`, ` */`, ""];
|
|
210
|
+
for (const procedure of procedures) {
|
|
211
|
+
const { entry } = procedure;
|
|
212
|
+
out.push(`/** The input of \`${commentText(entry.key)}\`. */`);
|
|
213
|
+
out.push(`export type ${procedure.input} = ${schemaToType(entry.input)};`, "");
|
|
214
|
+
out.push(`/** The output of \`${commentText(entry.key)}\`. */`);
|
|
215
|
+
out.push(`export type ${procedure.output} = ${schemaToType(entry.output)};`, "");
|
|
216
|
+
}
|
|
217
|
+
out.push("/** A client that calls a procedure by its path: `ctx.client` of a procedure handler, or an adapter of a `Client`. */", "export interface SdkClient {", " call(path: string[], input: unknown): Promise<unknown>;", "}", "", "/** The methods of the procedures, at `sdk.<namespace>.<name>`. */", `export interface Sdk {`, ...interfaceMembers(root, " "), "}", "");
|
|
218
|
+
if (hasBoth(root)) {
|
|
219
|
+
out.push("/** This function gives a function with the members of a namespace (a path that is a procedure and a namespace). */", "function withMembers<F extends object, M extends object>(fn: F, members: M): F & M {", " for (const [key, value] of Object.entries(members)) Object.defineProperty(fn, key, { value, enumerable: true });", " return fn as F & M;", "}", "");
|
|
220
|
+
}
|
|
221
|
+
out.push("/** This function gives the SDK: each method calls `client.call(path, input)`. */");
|
|
222
|
+
if (procedures.length === 0) {
|
|
223
|
+
// No method uses the client, and the strict options refuse an unused parameter
|
|
224
|
+
out.push("export function createSdk(_client: SdkClient): Sdk {", " return {};", "}", "");
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
out.push("export function createSdk(client: SdkClient): Sdk {", " const call = <T>(path: string[], input: unknown): Promise<T> => client.call(path, input) as Promise<T>;", ` return ${memberValue(root, " ")};`, "}", "");
|
|
228
|
+
}
|
|
229
|
+
return out.join("\n");
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=typescript-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-sdk.js","sourceRoot":"","sources":["../src/typescript-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAA+C,MAAM,4BAA4B,CAAC;AAU1G,MAAM,UAAU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