@graview/studio 0.0.0-stage → 0.1.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/LICENSE +96 -0
- package/README.md +31 -2
- package/dist/agent-panel.d.ts +11 -0
- package/dist/agent-panel.d.ts.map +1 -0
- package/dist/agent-panel.js +334 -0
- package/dist/agent-panel.js.map +1 -0
- package/dist/agent.d.ts +24 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +371 -0
- package/dist/agent.js.map +1 -0
- package/dist/changes.d.ts +49 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +217 -0
- package/dist/changes.js.map +1 -0
- package/dist/from-declaration.d.ts +13 -0
- package/dist/from-declaration.d.ts.map +1 -0
- package/dist/from-declaration.js +204 -0
- package/dist/from-declaration.js.map +1 -0
- package/dist/in-place.d.ts +27 -0
- package/dist/in-place.d.ts.map +1 -0
- package/dist/in-place.js +151 -0
- package/dist/in-place.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lens.d.ts +9 -0
- package/dist/lens.d.ts.map +1 -0
- package/dist/lens.js +40 -0
- package/dist/lens.js.map +1 -0
- package/dist/meta.d.ts +2648 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +553 -0
- package/dist/meta.js.map +1 -0
- package/dist/migration.d.ts +15 -0
- package/dist/migration.d.ts.map +1 -0
- package/dist/migration.js +82 -0
- package/dist/migration.js.map +1 -0
- package/dist/place.d.ts +61 -0
- package/dist/place.d.ts.map +1 -0
- package/dist/place.js +328 -0
- package/dist/place.js.map +1 -0
- package/dist/rewrite.d.ts +28 -0
- package/dist/rewrite.d.ts.map +1 -0
- package/dist/rewrite.js +52 -0
- package/dist/rewrite.js.map +1 -0
- package/dist/source.d.ts +69 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +465 -0
- package/dist/source.js.map +1 -0
- package/dist/studio.d.ts +64 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +96 -0
- package/dist/studio.js.map +1 -0
- package/dist/to-declaration.d.ts +24 -0
- package/dist/to-declaration.d.ts.map +1 -0
- package/dist/to-declaration.js +439 -0
- package/dist/to-declaration.js.map +1 -0
- package/dist/write-in-place.d.ts +27 -0
- package/dist/write-in-place.d.ts.map +1 -0
- package/dist/write-in-place.js +61 -0
- package/dist/write-in-place.js.map +1 -0
- package/dist/zod-source.d.ts +7 -0
- package/dist/zod-source.d.ts.map +1 -0
- package/dist/zod-source.js +124 -0
- package/dist/zod-source.js.map +1 -0
- package/package.json +58 -3
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AnyMutationDefinition, GraphEdge, GraphSnapshot, AnySchema, GraviewApp } from "@graview/core";
|
|
2
|
+
import type { FieldType } from "./meta.js";
|
|
3
|
+
import { type ZodUses } from "./zod-source.js";
|
|
4
|
+
export type Node = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly kind: string;
|
|
7
|
+
} & Record<string, unknown>;
|
|
8
|
+
interface Reading {
|
|
9
|
+
readonly nodes: readonly Node[];
|
|
10
|
+
readonly edges: readonly GraphEdge[];
|
|
11
|
+
}
|
|
12
|
+
export interface SourceOptions {
|
|
13
|
+
/** The app's name, for the comments. */
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
/** The exported schema's variable name; `graview create` uses `<camel>Schema`. */
|
|
16
|
+
readonly schemaVar?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The app the studio opened on. A judgement and a hand-written body are
|
|
19
|
+
* code the studio cannot write; for a rule or an act the checkout
|
|
20
|
+
* already has, the file says so LOUDLY — a stub that throws naming what
|
|
21
|
+
* belongs there — rather than a stub that quietly holds. Every rule the
|
|
22
|
+
* checkout wrote used to come back as `evaluate() { return []; }` under
|
|
23
|
+
* a comment claiming the checkout's evaluate was kept.
|
|
24
|
+
*/
|
|
25
|
+
readonly base?: GraviewApp<AnySchema>;
|
|
26
|
+
}
|
|
27
|
+
export interface WrittenFile {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly contents: string;
|
|
30
|
+
/** The bodies the checkout must supply, by name: what this file could not write. */
|
|
31
|
+
readonly kept: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
export declare const q: (text: string) => string;
|
|
34
|
+
export declare const camel: (slug: string) => string;
|
|
35
|
+
export declare const label: (node: Node) => string;
|
|
36
|
+
export declare class Read {
|
|
37
|
+
readonly reading: Reading;
|
|
38
|
+
private readonly byId;
|
|
39
|
+
constructor(reading: Reading);
|
|
40
|
+
node(id: string): Node | undefined;
|
|
41
|
+
ofKind(kind: string): Node[];
|
|
42
|
+
out(from: string, kind: string): Node[];
|
|
43
|
+
in(to: string, kind: string): Node[];
|
|
44
|
+
}
|
|
45
|
+
export declare function zodSource(type: FieldType, required: boolean, options?: readonly string[]): string;
|
|
46
|
+
/** A kind's fields, as the graph holds them. */
|
|
47
|
+
export declare function fieldsOf(read: Read, kind: Node): {
|
|
48
|
+
name: string;
|
|
49
|
+
type: FieldType;
|
|
50
|
+
required: boolean;
|
|
51
|
+
options: string[] | undefined;
|
|
52
|
+
}[];
|
|
53
|
+
/** An edge's declaration, one property per entry: `to: ["gardener"]`, `cardinality: "one"`, … */
|
|
54
|
+
export declare function edgeParts(read: Read, edge: Node): string[];
|
|
55
|
+
/** A kind's whole `defineNode` statement, as the graph holds it. */
|
|
56
|
+
export declare function kindLines(read: Read, kind: Node, base: GraviewApp<AnySchema> | undefined, keptFormats: string[], uses?: ZodUses): string[];
|
|
57
|
+
/**
|
|
58
|
+
* An act's whole `defineMutation` statement, as the graph holds it. `kept`
|
|
59
|
+
* is an act the checkout already wrote: its body is code the studio never
|
|
60
|
+
* saw, so the statement throws where the body belongs rather than doing
|
|
61
|
+
* something else quietly.
|
|
62
|
+
*/
|
|
63
|
+
export declare function actLines(read: Read, act: Node, kept: boolean, checkout?: AnyMutationDefinition, uses?: ZodUses): string[];
|
|
64
|
+
/** A rule's whole `defineInvariant` statement. `kept`: the checkout already judges it, so its evaluate is not the studio's to write. */
|
|
65
|
+
export declare function ruleLines(read: Read, rule: Node, kept: boolean): string[];
|
|
66
|
+
/** `src/domain/schema.ts`, `mutations.ts`, `invariants.ts` and, with roles, `policy.ts`. */
|
|
67
|
+
export declare function declarationFiles(snapshot: GraphSnapshot | Reading, options?: SourceOptions): WrittenFile[];
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE5G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAUzD,MAAM,MAAM,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5F,UAAU,OAAO;IACf,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ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Q1D;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,EAAE,EACrB,IAAI,GAAE,OAA4C,GACjD,MAAM,EAAE,CAiEV;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,qBAAqB,EAChC,IAAI,GAAE,OAA2C,GAChD,MAAM,EAAE,CA6FV;AAED,wIAAwI;AACxI,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CA6BzE;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,WAAW,EAAE,CA4H9G"}
|
package/dist/source.js
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { fieldTypeOf } from "./from-declaration.js";
|
|
2
|
+
import { printZod } from "./zod-source.js";
|
|
3
|
+
export const q = (text) => JSON.stringify(text);
|
|
4
|
+
export const camel = (slug) => slug.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
5
|
+
const pascal = (slug) => {
|
|
6
|
+
const c = camel(slug);
|
|
7
|
+
return c.charAt(0).toUpperCase() + c.slice(1);
|
|
8
|
+
};
|
|
9
|
+
export const label = (node) => String(node["label"] ?? node.id);
|
|
10
|
+
const str = (node, key) => (typeof node[key] === "string" ? node[key] : undefined);
|
|
11
|
+
const bool = (node, key) => node[key] === true;
|
|
12
|
+
const list = (node, key) => (Array.isArray(node[key]) ? node[key].map(String) : undefined);
|
|
13
|
+
export class Read {
|
|
14
|
+
reading;
|
|
15
|
+
byId = new Map();
|
|
16
|
+
constructor(reading) {
|
|
17
|
+
this.reading = reading;
|
|
18
|
+
for (const node of reading.nodes)
|
|
19
|
+
this.byId.set(node.id, node);
|
|
20
|
+
}
|
|
21
|
+
node(id) {
|
|
22
|
+
return this.byId.get(id);
|
|
23
|
+
}
|
|
24
|
+
ofKind(kind) {
|
|
25
|
+
return this.reading.nodes.filter((node) => node.kind === kind);
|
|
26
|
+
}
|
|
27
|
+
out(from, kind) {
|
|
28
|
+
return this.reading.edges.filter((edge) => edge.from === from && edge.kind === kind).map((edge) => this.byId.get(edge.to)).filter((node) => node !== undefined);
|
|
29
|
+
}
|
|
30
|
+
in(to, kind) {
|
|
31
|
+
return this.reading.edges.filter((edge) => edge.to === to && edge.kind === kind).map((edge) => this.byId.get(edge.from)).filter((node) => node !== undefined);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function zodSource(type, required, options) {
|
|
35
|
+
const base = type === "number"
|
|
36
|
+
? "z.number()"
|
|
37
|
+
: type === "boolean"
|
|
38
|
+
? "z.boolean()"
|
|
39
|
+
: type === "enum" && options && options.length > 0
|
|
40
|
+
? `z.enum([${options.map(q).join(", ")}])`
|
|
41
|
+
: type === "list"
|
|
42
|
+
? "z.array(z.string())"
|
|
43
|
+
: type === "string"
|
|
44
|
+
? "z.string().min(1)"
|
|
45
|
+
: "z.string()";
|
|
46
|
+
return required ? base : `${base}.optional()`;
|
|
47
|
+
}
|
|
48
|
+
const defaultSource = (type, options) => type === "number" ? "0" : type === "boolean" ? "false" : type === "enum" ? q(options?.[0] ?? "") : type === "list" ? "[]" : type === "date" ? "new Date().toISOString().slice(0, 10)" : '""';
|
|
49
|
+
/**
|
|
50
|
+
* The lines of a `defineNode` the studio carries from the checkout rather
|
|
51
|
+
* than from its graph, narrowed to the fields that still exist — a label
|
|
52
|
+
* for a field somebody deleted is not preserved, it is meaningless.
|
|
53
|
+
*/
|
|
54
|
+
function carried(base, kind, fields, keptFormats) {
|
|
55
|
+
const was = base?.schema?.tryDefinition?.(kind);
|
|
56
|
+
if (!was)
|
|
57
|
+
return [];
|
|
58
|
+
const lines = [];
|
|
59
|
+
const pairs = (record) => {
|
|
60
|
+
const left = Object.entries(record ?? {}).filter(([field]) => fields.has(field));
|
|
61
|
+
return left.length === 0 ? undefined : `{ ${left.map(([at, value]) => `${q(at)}: ${q(value)}`).join(", ")} }`;
|
|
62
|
+
};
|
|
63
|
+
const labels = pairs(was.display?.labels);
|
|
64
|
+
const hide = was.display?.hide?.filter((field) => fields.has(field));
|
|
65
|
+
const formatted = Object.keys(was.display?.format ?? {}).filter((field) => fields.has(field));
|
|
66
|
+
if (labels || (hide && hide.length > 0)) {
|
|
67
|
+
lines.push(` display: {`);
|
|
68
|
+
if (labels)
|
|
69
|
+
lines.push(` labels: ${labels},`);
|
|
70
|
+
if (hide && hide.length > 0)
|
|
71
|
+
lines.push(` hide: [${hide.map(q).join(", ")}],`);
|
|
72
|
+
if (formatted.length > 0) {
|
|
73
|
+
lines.push(` // The checkout also formats ${formatted.map(q).join(", ")}; a format is a`, ` // FUNCTION and the studio cannot write one. Carry it over from`, ` // the file you are replacing, or these fields read as raw values.`);
|
|
74
|
+
}
|
|
75
|
+
lines.push(` },`);
|
|
76
|
+
}
|
|
77
|
+
else if (formatted.length > 0) {
|
|
78
|
+
lines.push(` // The checkout formats ${formatted.map(q).join(", ")} with a function the`, ` // studio cannot write. Carry display.format over from the file you`, ` // are replacing, or these fields read as raw values.`);
|
|
79
|
+
}
|
|
80
|
+
for (const field of formatted)
|
|
81
|
+
keptFormats.push(`${kind}.${field} (display.format)`);
|
|
82
|
+
const fixed = pairs(was.fixed);
|
|
83
|
+
if (fixed)
|
|
84
|
+
lines.push(` fixed: ${fixed},`);
|
|
85
|
+
const roles = Object.entries(was.fieldRoles ?? {}).filter(([, field]) => fields.has(String(field)));
|
|
86
|
+
if (roles.length > 0) {
|
|
87
|
+
lines.push(` fieldRoles: { ${roles.map(([role, field]) => `${q(role)}: ${q(String(field))}`).join(", ")} },`);
|
|
88
|
+
}
|
|
89
|
+
return lines;
|
|
90
|
+
}
|
|
91
|
+
/** A kind's fields, as the graph holds them. */
|
|
92
|
+
export function fieldsOf(read, kind) {
|
|
93
|
+
return read.in(kind.id, "of").map((field) => ({
|
|
94
|
+
name: label(field),
|
|
95
|
+
type: (str(field, "type") ?? "string"),
|
|
96
|
+
required: bool(field, "required"),
|
|
97
|
+
options: list(field, "options"),
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/** An edge's declaration, one property per entry: `to: ["gardener"]`, `cardinality: "one"`, … */
|
|
101
|
+
export function edgeParts(read, edge) {
|
|
102
|
+
const targets = read.out(edge.id, "to-kind").map(label);
|
|
103
|
+
const parts = [`to: ${bool(edge, "toAny") ? '"*"' : `[${targets.map(q).join(", ")}]`}`];
|
|
104
|
+
if (str(edge, "cardinality") === "one")
|
|
105
|
+
parts.push(`cardinality: "one"`);
|
|
106
|
+
if (str(edge, "description"))
|
|
107
|
+
parts.push(`description: ${q(str(edge, "description"))}`);
|
|
108
|
+
if (str(edge, "inverse"))
|
|
109
|
+
parts.push(`inverse: ${q(str(edge, "inverse"))}`);
|
|
110
|
+
if (bool(edge, "appendOnly"))
|
|
111
|
+
parts.push(`appendOnly: true`);
|
|
112
|
+
return parts;
|
|
113
|
+
}
|
|
114
|
+
/** A kind's whole `defineNode` statement, as the graph holds it. */
|
|
115
|
+
export function kindLines(read, kind, base, keptFormats, uses = { nodeRef: false, isoDate: false }) {
|
|
116
|
+
const fields = fieldsOf(read, kind);
|
|
117
|
+
// The checkout's own schema for a field the studio still reads the same way.
|
|
118
|
+
const baseShape = (base?.schema.tryDefinition(label(kind))?.fields?.shape ?? {});
|
|
119
|
+
const fieldSource = (field) => {
|
|
120
|
+
const own = baseShape[field.name];
|
|
121
|
+
if (own !== undefined) {
|
|
122
|
+
const was = fieldTypeOf(own);
|
|
123
|
+
const same = was.type === field.type &&
|
|
124
|
+
was.required === field.required &&
|
|
125
|
+
(was.options ?? []).join("|") === (field.options ?? []).join("|");
|
|
126
|
+
const printed = same ? printZod(own, uses) : null;
|
|
127
|
+
if (printed !== null)
|
|
128
|
+
return printed;
|
|
129
|
+
}
|
|
130
|
+
return zodSource(field.type, field.required, field.options);
|
|
131
|
+
};
|
|
132
|
+
const edges = read.in(kind.id, "from-kind");
|
|
133
|
+
const lifecycleField = str(kind, "lifecycleField");
|
|
134
|
+
const retired = list(kind, "retired");
|
|
135
|
+
const lines = [`export const ${camel(label(kind))} = defineNode(${q(label(kind))}, {`];
|
|
136
|
+
if (str(kind, "description"))
|
|
137
|
+
lines.push(` description: ${q(str(kind, "description"))},`);
|
|
138
|
+
lines.push(` fields: z.object({`);
|
|
139
|
+
for (const field of fields)
|
|
140
|
+
lines.push(` ${/^[a-z_$][\w$]*$/i.test(field.name) ? field.name : q(field.name)}: ${fieldSource(field)},`);
|
|
141
|
+
lines.push(` }),`);
|
|
142
|
+
if (edges.length > 0) {
|
|
143
|
+
lines.push(` edges: {`);
|
|
144
|
+
for (const edge of edges) {
|
|
145
|
+
lines.push(` ${q(label(edge))}: {`, ...edgeParts(read, edge).map((part) => ` ${part},`), ` },`);
|
|
146
|
+
}
|
|
147
|
+
lines.push(` },`);
|
|
148
|
+
}
|
|
149
|
+
if (str(kind, "plural"))
|
|
150
|
+
lines.push(` plural: ${q(str(kind, "plural"))},`);
|
|
151
|
+
if (str(kind, "noun"))
|
|
152
|
+
lines.push(` noun: ${q(str(kind, "noun"))},`);
|
|
153
|
+
if (fields.some((field) => field.name === "label"))
|
|
154
|
+
lines.push(` label: (node) => node.label,`);
|
|
155
|
+
else if (typeof base?.schema?.tryDefinition?.(label(kind))?.label === "function") {
|
|
156
|
+
/*
|
|
157
|
+
* A NAME BUILT FROM FIELDS is a function, and the studio cannot write
|
|
158
|
+
* one. A vehicle named "2027 Subaru Forester Sport" from its year, make
|
|
159
|
+
* and model came back with no label at all — every card an id — and
|
|
160
|
+
* nothing said so.
|
|
161
|
+
*/
|
|
162
|
+
lines.push(` // The checkout names ${q(label(kind))} with a function the studio cannot write;`, ` // carry \`label\` over from the file you are replacing, or every one is named by its id.`);
|
|
163
|
+
keptFormats.push(`${label(kind)} (label)`);
|
|
164
|
+
}
|
|
165
|
+
if (lifecycleField && retired)
|
|
166
|
+
lines.push(` lifecycle: { field: ${q(lifecycleField)}, retired: ${retired[0] === "date" ? '"date"' : `[${retired.map(q).join(", ")}]`} },`);
|
|
167
|
+
// The drawing is part of the declaration, so it is part of the file.
|
|
168
|
+
if (str(kind, "figure"))
|
|
169
|
+
lines.push(` figure: ${q(str(kind, "figure"))},`);
|
|
170
|
+
/*
|
|
171
|
+
* WHAT THE STUDIO DOES NOT MODEL, IT WRITES BACK ANYWAY.
|
|
172
|
+
*
|
|
173
|
+
* How a field reads, what is fixed and which fields answer a lens's
|
|
174
|
+
* roles are decisions in the checkout that the studio has no act for.
|
|
175
|
+
* Rebuilding a kind from the graph alone dropped all of them — so
|
|
176
|
+
* applying would have turned "Blocked 09:00" back into
|
|
177
|
+
* `plannedAt: 540` on every card. The one thing that genuinely cannot
|
|
178
|
+
* be written is a `format` function; the file SAYS SO where it finds
|
|
179
|
+
* one rather than losing it silently.
|
|
180
|
+
*/
|
|
181
|
+
lines.push(...carried(base, label(kind), new Set(fields.map((field) => field.name)), keptFormats));
|
|
182
|
+
lines.push(`});`);
|
|
183
|
+
return lines;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* An act's whole `defineMutation` statement, as the graph holds it. `kept`
|
|
187
|
+
* is an act the checkout already wrote: its body is code the studio never
|
|
188
|
+
* saw, so the statement throws where the body belongs rather than doing
|
|
189
|
+
* something else quietly.
|
|
190
|
+
*/
|
|
191
|
+
export function actLines(read, act, kept, checkout, uses = { nodeRef: true, isoDate: false }) {
|
|
192
|
+
const actName = label(act);
|
|
193
|
+
const on = read.out(act.id, "on").map((kind) => label(kind));
|
|
194
|
+
const creates = read.out(act.id, "creates").map((kind) => label(kind));
|
|
195
|
+
const connects = read.out(act.id, "connects");
|
|
196
|
+
const severs = read.out(act.id, "severs");
|
|
197
|
+
const writes = list(act, "writes") ?? [];
|
|
198
|
+
const arg = str(act, "subjectArg") ?? "id";
|
|
199
|
+
// The checkout's own word for the far end, kept; `to` only for an act the studio declared.
|
|
200
|
+
const far = str(act, "targetArg") ?? "to";
|
|
201
|
+
const onAny = bool(act, "onAny");
|
|
202
|
+
const subjectKinds = onAny ? '"*"' : `[${on.map(q).join(", ")}]`;
|
|
203
|
+
const lines = [`export const ${camel(actName)} = defineMutation(${q(actName)}, {`];
|
|
204
|
+
const body = [];
|
|
205
|
+
if (str(act, "title"))
|
|
206
|
+
lines.push(` title: ${q(str(act, "title"))},`);
|
|
207
|
+
if (str(act, "fromTheOtherEnd"))
|
|
208
|
+
lines.push(` fromTheOtherEnd: ${q(str(act, "fromTheOtherEnd"))},`);
|
|
209
|
+
if (str(act, "description"))
|
|
210
|
+
lines.push(` description: ${q(str(act, "description"))},`);
|
|
211
|
+
if (bool(act, "destructive"))
|
|
212
|
+
lines.push(` destructive: true,`);
|
|
213
|
+
if (onAny || on.length > 0)
|
|
214
|
+
lines.push(` subject: { kinds: ${subjectKinds}, arg: ${q(arg)} },`);
|
|
215
|
+
if (creates.length > 0)
|
|
216
|
+
lines.push(` creates: [${creates.map(q).join(", ")}],`);
|
|
217
|
+
if (connects.length > 0)
|
|
218
|
+
lines.push(` connects: [${connects.map((edge) => q(label(edge))).join(", ")}],`);
|
|
219
|
+
if (severs.length > 0)
|
|
220
|
+
lines.push(` severs: [${severs.map((edge) => q(label(edge))).join(", ")}],`);
|
|
221
|
+
if (writes.length > 0)
|
|
222
|
+
lines.push(` writes: [${writes.map(q).join(", ")}],`);
|
|
223
|
+
if (creates.length > 0) {
|
|
224
|
+
const kind = creates[0];
|
|
225
|
+
const kindNode = read.ofKind("kind").find((node) => label(node) === kind);
|
|
226
|
+
const fields = kindNode ? fieldsOf(read, kindNode).filter((field) => field.name !== "label") : [];
|
|
227
|
+
const asked = fields.filter((field) => field.required && field.type !== "list");
|
|
228
|
+
lines.push(` input: z.object({ label: z.string().min(1)${asked.map((field) => `, ${field.name}: ${zodSource(field.type, false, field.options)}`).join("")} }),`);
|
|
229
|
+
lines.push(` describe: (args) => \`${str(act, "title") ?? actName}: \${args.label}\`,`);
|
|
230
|
+
body.push(` ctx.addNode({`);
|
|
231
|
+
body.push(` id: ctx.freshId(args.label, ${q(kind)}),`);
|
|
232
|
+
body.push(` kind: ${q(kind)},`);
|
|
233
|
+
body.push(` label: args.label,`);
|
|
234
|
+
for (const field of fields)
|
|
235
|
+
if (field.required)
|
|
236
|
+
body.push(` ${field.name}: args.${field.name} ?? ${defaultSource(field.type, field.options)},`);
|
|
237
|
+
body.push(` });`);
|
|
238
|
+
}
|
|
239
|
+
else if (connects[0] ?? severs[0]) {
|
|
240
|
+
const edge = (connects[0] ?? severs[0]);
|
|
241
|
+
const targets = read.out(edge.id, "to-kind").map((target) => label(target));
|
|
242
|
+
const making = connects.length > 0;
|
|
243
|
+
lines.push(` input: z.object({ ${arg}: nodeRef(${subjectKinds}), ${far}: nodeRef(${targets.length > 0 ? `[${targets.map(q).join(", ")}]` : '"*"'}) }),`);
|
|
244
|
+
lines.push(` describe: (args, graph) => \`${str(act, "title") ?? actName}: \${nameOf(graph as Reader, args.${arg})} ${making ? "→" : "⇸"} \${nameOf(graph as Reader, args.${far})}\`,`);
|
|
245
|
+
body.push(` ctx.${making ? "addEdge" : "removeEdge"}({ kind: ${q(label(edge))}, from: args.${arg}, to: args.${far} });`);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const declared = new Map();
|
|
249
|
+
for (const kindNode of read.ofKind("kind"))
|
|
250
|
+
if (on.includes(label(kindNode)))
|
|
251
|
+
for (const field of fieldsOf(read, kindNode))
|
|
252
|
+
declared.set(field.name, { type: field.type, options: field.options });
|
|
253
|
+
lines.push(` input: z.object({ ${arg}: nodeRef(${subjectKinds})${writes.map((field) => `, ${field}: ${declared.has(field) ? zodSource(declared.get(field).type, false, declared.get(field).options) : "z.string().optional()"}`).join("")} }),`);
|
|
254
|
+
lines.push(` describe: (args, graph) => \`${str(act, "title") ?? actName}: \${nameOf(graph as Reader, args.${arg})}\`,`);
|
|
255
|
+
if (writes.length > 0) {
|
|
256
|
+
body.push(` const patch: Record<string, unknown> = {};`);
|
|
257
|
+
for (const field of writes)
|
|
258
|
+
body.push(` if (args.${field} !== undefined) patch[${q(field)}] = args.${field};`);
|
|
259
|
+
body.push(` if (Object.keys(patch).length > 0) ctx.patchNode(args.${arg}, patch);`);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
body.push(` // Declared in the studio with no create, connect, sever or write: give it a body.`);
|
|
263
|
+
body.push(` void ctx;`);
|
|
264
|
+
body.push(` void args;`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/*
|
|
268
|
+
* AN ACT THE CHECKOUT WROTE KEEPS ITS OWN ARGUMENTS AND ITS OWN WORDS.
|
|
269
|
+
* The input above is derived from what the act declares — its kind's
|
|
270
|
+
* fields, its tie's two ends — which is the checkout's input only by
|
|
271
|
+
* luck; and the history's sentence is a function the studio never saw.
|
|
272
|
+
*/
|
|
273
|
+
if (kept && checkout) {
|
|
274
|
+
const printed = printZod(checkout.input, uses);
|
|
275
|
+
const at = lines.findIndex((line) => line.startsWith(" input: "));
|
|
276
|
+
if (at >= 0 && printed !== null)
|
|
277
|
+
lines[at] = ` input: ${printed},`;
|
|
278
|
+
const said = lines.findIndex((line) => line.startsWith(" describe: "));
|
|
279
|
+
if (said >= 0 && checkout.describe) {
|
|
280
|
+
lines.splice(said, 1, ` // describe: the checkout's own sentence for the history belongs here — the studio cannot write a function it never saw.`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
lines.push(` apply(ctx, args) {`);
|
|
284
|
+
if (kept) {
|
|
285
|
+
/*
|
|
286
|
+
* AN ACT THE CHECKOUT WROTE keeps its declaration and loses its body
|
|
287
|
+
* here, because a body is code the studio never saw. A generated one
|
|
288
|
+
* that does something ELSE — "close it" patching only when a status
|
|
289
|
+
* is passed, a tie without the checkout's own guard — is worse than
|
|
290
|
+
* none, so the stub throws, naming what belongs here, and `kept`
|
|
291
|
+
* says so to whoever writes the files.
|
|
292
|
+
*/
|
|
293
|
+
lines.push(` // The checkout's own body belongs here: the studio cannot write what it never saw.`);
|
|
294
|
+
lines.push(` void ctx;`);
|
|
295
|
+
lines.push(` void args;`);
|
|
296
|
+
lines.push(` throw new Error(${q(`${actName}: the checkout's apply belongs here — the studio cannot write a hand-written body`)});`);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
lines.push(...body);
|
|
300
|
+
}
|
|
301
|
+
lines.push(` },`);
|
|
302
|
+
lines.push(`});`);
|
|
303
|
+
return lines;
|
|
304
|
+
}
|
|
305
|
+
/** A rule's whole `defineInvariant` statement. `kept`: the checkout already judges it, so its evaluate is not the studio's to write. */
|
|
306
|
+
export function ruleLines(read, rule, kept) {
|
|
307
|
+
const ruleName = label(rule);
|
|
308
|
+
const over = read.out(rule.id, "over")[0];
|
|
309
|
+
const repairs = [...read.out(rule.id, "repairs").map(label), ...(list(rule, "derivedRepairs") ?? [])];
|
|
310
|
+
const whole = bool(rule, "wholeGraph") || !over;
|
|
311
|
+
const lines = [`export const ${camel(ruleName)} = ${whole ? "defineGraphInvariant" : "defineInvariant"}(${q(ruleName)}, {`];
|
|
312
|
+
// The checkout's words for it, not its identifier.
|
|
313
|
+
lines.push(` label: ${q(str(rule, "title") ?? ruleName)},`);
|
|
314
|
+
if (str(rule, "description"))
|
|
315
|
+
lines.push(` description: ${q(str(rule, "description"))},`);
|
|
316
|
+
if (!whole)
|
|
317
|
+
lines.push(` scope: { kind: ${q(label(over))} },`);
|
|
318
|
+
if (repairs.length > 0)
|
|
319
|
+
lines.push(` repairs: [${repairs.map(q).join(", ")}],`);
|
|
320
|
+
if (bool(rule, "judgesPast"))
|
|
321
|
+
lines.push(` judgesPast: true,`);
|
|
322
|
+
lines.push(` evaluate(): Violation[] {`);
|
|
323
|
+
if (kept) {
|
|
324
|
+
/*
|
|
325
|
+
* A rule the checkout already judges: its evaluate is code the
|
|
326
|
+
* studio never saw. A stub that returns nothing would hold, and a
|
|
327
|
+
* rule that holds when it should not is a lie the interface tells
|
|
328
|
+
* with a green light. So it throws, naming what belongs here.
|
|
329
|
+
*/
|
|
330
|
+
lines.push(` // The checkout's own judgement belongs here: the studio cannot write what it never saw.`);
|
|
331
|
+
lines.push(` throw new Error(${q(`${ruleName}: the checkout's evaluate belongs here — the studio cannot write a judgement`)});`);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
lines.push(` // The judgement: return a violation per subject that breaks the rule.`);
|
|
335
|
+
lines.push(` return [];`);
|
|
336
|
+
}
|
|
337
|
+
lines.push(` },`);
|
|
338
|
+
lines.push(`});`);
|
|
339
|
+
return lines;
|
|
340
|
+
}
|
|
341
|
+
/** `src/domain/schema.ts`, `mutations.ts`, `invariants.ts` and, with roles, `policy.ts`. */
|
|
342
|
+
export function declarationFiles(snapshot, options = {}) {
|
|
343
|
+
const read = new Read(snapshot);
|
|
344
|
+
const schemaVar = options.schemaVar ?? "schema";
|
|
345
|
+
const name = options.name ?? "the app";
|
|
346
|
+
const baseActs = new Set((options.base?.mutations ?? []).map((mutation) => mutation.name));
|
|
347
|
+
const baseRules = new Set((options.base?.invariants ?? []).map((rule) => rule.name));
|
|
348
|
+
const keptActs = [];
|
|
349
|
+
const keptRules = [];
|
|
350
|
+
const keptFormats = [];
|
|
351
|
+
const kinds = read.ofKind("kind");
|
|
352
|
+
/*
|
|
353
|
+
* `z` FROM THE FRAMEWORK. A product never installs zod — `@graview/core`
|
|
354
|
+
* re-exports it, and a second copy makes every kind's fields a nominally
|
|
355
|
+
* different type — so a file importing "zod" is a file the product
|
|
356
|
+
* cannot resolve.
|
|
357
|
+
*/
|
|
358
|
+
const schemaUses = { nodeRef: false, isoDate: false };
|
|
359
|
+
const kindText = kinds.flatMap((kind) => ["", ...kindLines(read, kind, options.base, keptFormats, schemaUses)]);
|
|
360
|
+
const schemaTs = [
|
|
361
|
+
`import { createSchema, defineNode, ${schemaUses.isoDate ? "isoDate, " : ""}z } from "@graview/core";`,
|
|
362
|
+
``,
|
|
363
|
+
`/*`,
|
|
364
|
+
` * ${name}'s kinds, written by the studio. The shape is the declaration's;`,
|
|
365
|
+
` * edit it here or there, and \`graview check\` judges either.`,
|
|
366
|
+
` */`,
|
|
367
|
+
...kindText,
|
|
368
|
+
``,
|
|
369
|
+
`export const ${schemaVar} = createSchema([${kinds.map((kind) => camel(label(kind))).join(", ")}]);`,
|
|
370
|
+
`export type ${pascal(schemaVar)} = typeof ${schemaVar};`,
|
|
371
|
+
``,
|
|
372
|
+
].join("\n");
|
|
373
|
+
const acts = read.ofKind("act").filter((act) => !bool(act, "derived"));
|
|
374
|
+
const actUses = { nodeRef: true, isoDate: false };
|
|
375
|
+
const actText = acts.flatMap((act) => {
|
|
376
|
+
const kept = baseActs.has(label(act));
|
|
377
|
+
if (kept)
|
|
378
|
+
keptActs.push(label(act));
|
|
379
|
+
const checkout = options.base?.mutations?.find((mutation) => mutation.name === label(act));
|
|
380
|
+
return ["", ...actLines(read, act, kept, checkout, actUses)];
|
|
381
|
+
});
|
|
382
|
+
const mutationsTs = [
|
|
383
|
+
`import { bindSchema, ${actUses.isoDate ? "isoDate, " : ""}nodeRef, z, type GraphReader } from "@graview/core";`,
|
|
384
|
+
`import { ${schemaVar} } from "./schema.js";`,
|
|
385
|
+
``,
|
|
386
|
+
`const { defineMutation } = bindSchema(${schemaVar});`,
|
|
387
|
+
``,
|
|
388
|
+
`// A node's name for the history: an id in the interface is a bug you shipped.`,
|
|
389
|
+
`type Reader = GraphReader<{ id: string; kind: string } & Record<string, unknown>>;`,
|
|
390
|
+
`const nameOf = (graph: Reader, id: string): string => {`,
|
|
391
|
+
` const node = graph.getNode(id);`,
|
|
392
|
+
` return typeof node?.["label"] === "string" ? (node["label"] as string) : id;`,
|
|
393
|
+
`};`,
|
|
394
|
+
``,
|
|
395
|
+
`/*`,
|
|
396
|
+
` * ${name}'s acts, written by the studio from what each act declares:`,
|
|
397
|
+
` * create, connect, sever or write. Where the checkout's own body did`,
|
|
398
|
+
` * more, keep the checkout's body under the studio's declaration.`,
|
|
399
|
+
` */`,
|
|
400
|
+
...actText,
|
|
401
|
+
``,
|
|
402
|
+
`export const mutations = [${acts.map((act) => camel(label(act))).join(", ")}];`,
|
|
403
|
+
``,
|
|
404
|
+
].join("\n");
|
|
405
|
+
const rules = read.ofKind("rule");
|
|
406
|
+
const invariantsTs = [
|
|
407
|
+
`import { bindSchema, type Violation } from "@graview/core";`,
|
|
408
|
+
`import { ${schemaVar} } from "./schema.js";`,
|
|
409
|
+
``,
|
|
410
|
+
`const { defineInvariant, defineGraphInvariant } = bindSchema(${schemaVar});`,
|
|
411
|
+
``,
|
|
412
|
+
`/*`,
|
|
413
|
+
` * ${name}'s rules, as the studio declares them: what each judges and what`,
|
|
414
|
+
` * repairs it. A judgement is code — a rule the studio declared holds`,
|
|
415
|
+
` * nothing wrong until its evaluate says otherwise; a rule the checkout`,
|
|
416
|
+
` * already judges keeps the checkout's evaluate.`,
|
|
417
|
+
` */`,
|
|
418
|
+
...rules.flatMap((rule) => {
|
|
419
|
+
const kept = baseRules.has(label(rule));
|
|
420
|
+
if (kept)
|
|
421
|
+
keptRules.push(label(rule));
|
|
422
|
+
return ["", ...ruleLines(read, rule, kept)];
|
|
423
|
+
}),
|
|
424
|
+
``,
|
|
425
|
+
`export const invariants = [${rules.map((rule) => camel(label(rule))).join(", ")}];`,
|
|
426
|
+
``,
|
|
427
|
+
].join("\n");
|
|
428
|
+
const roles = read.ofKind("role").map(label);
|
|
429
|
+
const grants = read.ofKind("grant");
|
|
430
|
+
const files = [
|
|
431
|
+
// A format is a function; the file names the ones it could not write.
|
|
432
|
+
{ path: "src/domain/schema.ts", contents: schemaTs, kept: keptFormats },
|
|
433
|
+
{ path: "src/domain/mutations.ts", contents: mutationsTs, kept: keptActs.map((act) => `${act}: apply`) },
|
|
434
|
+
{ path: "src/domain/invariants.ts", contents: invariantsTs, kept: keptRules.map((rule) => `${rule}: evaluate`) },
|
|
435
|
+
];
|
|
436
|
+
if (roles.length > 0 || grants.length > 0) {
|
|
437
|
+
const policyTs = [
|
|
438
|
+
`import type { Policy } from "@graview/core";`,
|
|
439
|
+
``,
|
|
440
|
+
`/* Who may do what in ${name}, as the studio declares it. */`,
|
|
441
|
+
`export const policy: Policy = {`,
|
|
442
|
+
` roles: [${roles.map(q).join(", ")}],`,
|
|
443
|
+
` grants: [`,
|
|
444
|
+
...grants.map((g) => {
|
|
445
|
+
const lets = read.out(g.id, "lets").map(label);
|
|
446
|
+
const may = read.out(g.id, "may").map(label);
|
|
447
|
+
const over = read.out(g.id, "allows-on").map(label);
|
|
448
|
+
const parts = [
|
|
449
|
+
`roles: ${bool(g, "everyone") ? '"*"' : `[${lets.map(q).join(", ")}]`}`,
|
|
450
|
+
`mutations: ${bool(g, "allActs") ? '"*"' : `[${may.map(q).join(", ")}]`}`,
|
|
451
|
+
...(bool(g, "allKinds") ? [] : [`kinds: [${over.map(q).join(", ")}]`]),
|
|
452
|
+
...(str(g, "describe") ? [`describe: ${q(str(g, "describe"))}`] : []),
|
|
453
|
+
...(bool(g, "self") ? ["self: true"] : []),
|
|
454
|
+
];
|
|
455
|
+
return ` { ${parts.join(", ")} },`;
|
|
456
|
+
}),
|
|
457
|
+
` ],`,
|
|
458
|
+
`};`,
|
|
459
|
+
``,
|
|
460
|
+
].join("\n");
|
|
461
|
+
files.push({ path: "src/domain/policy.ts", contents: policyTs, kept: [] });
|
|
462
|
+
}
|
|
463
|
+
return files;
|
|
464
|
+
}
|
|
465
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD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MAAM;YACN,IAAI;YACJ,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/studio.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Store, type AnySchema, type Batch, type CheckResult, type GraviewApp, type MigrationDeclaration, type MutationCall, type Principal } from "@graview/core";
|
|
2
|
+
import { type SourceChanges } from "./changes.js";
|
|
3
|
+
import { type StudioSchema } from "./meta.js";
|
|
4
|
+
import { type SourceOptions, type WrittenFile } from "./source.js";
|
|
5
|
+
export interface Studio<S extends AnySchema = AnySchema> {
|
|
6
|
+
/** The store the interface edits: the declaration as a graph. */
|
|
7
|
+
readonly store: Store<StudioSchema>;
|
|
8
|
+
/** The app the studio opened on. */
|
|
9
|
+
readonly base: GraviewApp<S>;
|
|
10
|
+
/** The declaration as it now stands, runnable and checkable. */
|
|
11
|
+
declaration(): GraviewApp<AnySchema>;
|
|
12
|
+
/** What `graview check` says about the declaration as it now stands. */
|
|
13
|
+
check(): CheckResult;
|
|
14
|
+
/** Batches applied since the studio opened — every change, with its author and intent. */
|
|
15
|
+
changes(): readonly Batch[];
|
|
16
|
+
/** The changes an agent seat made and nobody has taken back. */
|
|
17
|
+
proposals(): readonly Batch[];
|
|
18
|
+
/** An agent's proposed change: applied under its seat, in a batch of its own, so a person can keep or take it back. */
|
|
19
|
+
propose(call: MutationCall, agent: Principal, intent?: string): {
|
|
20
|
+
readonly batch: string;
|
|
21
|
+
readonly ok: true;
|
|
22
|
+
} | {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
};
|
|
26
|
+
/** Take a proposal back. */
|
|
27
|
+
decline(batch: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* WHAT THE CHECKER WOULD SAY IF THIS CALL WERE MADE — without making it.
|
|
30
|
+
*
|
|
31
|
+
* A proposal a person is shown has to be judged BEFORE they are asked to
|
|
32
|
+
* keep it: a change that would fail the build is not a choice, it is a
|
|
33
|
+
* trap. The call is applied to a copy of the store and the copy's
|
|
34
|
+
* declaration is checked, so the real declaration is untouched whatever
|
|
35
|
+
* the answer is — and a call the store itself refuses comes back as a
|
|
36
|
+
* refusal in the store's own words rather than as a thrown error.
|
|
37
|
+
*/
|
|
38
|
+
would(call: MutationCall | readonly MutationCall[]): {
|
|
39
|
+
readonly ok: true;
|
|
40
|
+
readonly check: CheckResult;
|
|
41
|
+
} | {
|
|
42
|
+
readonly ok: false;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
};
|
|
45
|
+
/** The new app and, where a stored graph needs one, the migration to it. Refused while the checker finds errors. */
|
|
46
|
+
apply(): {
|
|
47
|
+
readonly ok: true;
|
|
48
|
+
readonly app: GraviewApp<AnySchema>;
|
|
49
|
+
readonly migration: MigrationDeclaration | null;
|
|
50
|
+
} | {
|
|
51
|
+
readonly ok: false;
|
|
52
|
+
readonly check: CheckResult;
|
|
53
|
+
};
|
|
54
|
+
/** The declaration as the files `graview create` writes. */
|
|
55
|
+
files(options?: SourceOptions): readonly WrittenFile[];
|
|
56
|
+
/** What changed since the studio opened, as edits the checkout's own source can take — and what cannot be written that way yet. */
|
|
57
|
+
sourceChanges(): SourceChanges;
|
|
58
|
+
}
|
|
59
|
+
export interface StudioOptions {
|
|
60
|
+
readonly name?: string;
|
|
61
|
+
readonly principal?: Principal;
|
|
62
|
+
}
|
|
63
|
+
export declare function createStudio<S extends AnySchema>(base: GraviewApp<S>, options?: StudioOptions): Studio<S>;
|
|
64
|
+
//# sourceMappingURL=studio.d.ts.map
|