@unpunnyfuns/conduit 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 +25 -0
- package/README.md +202 -0
- package/dist/assert.d.ts +6 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +8 -0
- package/dist/assert.js.map +1 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.d.ts.map +1 -0
- package/dist/cn.js +3 -0
- package/dist/cn.js.map +1 -0
- package/dist/components/Badge.d.ts +6 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +11 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Card.d.ts +20 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +24 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/Diagram.d.ts +37 -0
- package/dist/components/Diagram.d.ts.map +1 -0
- package/dist/components/Diagram.js +92 -0
- package/dist/components/Diagram.js.map +1 -0
- package/dist/components/EdgeLayer.d.ts +23 -0
- package/dist/components/EdgeLayer.d.ts.map +1 -0
- package/dist/components/EdgeLayer.js +85 -0
- package/dist/components/EdgeLayer.js.map +1 -0
- package/dist/components/Lane.d.ts +11 -0
- package/dist/components/Lane.d.ts.map +1 -0
- package/dist/components/Lane.js +6 -0
- package/dist/components/Lane.js.map +1 -0
- package/dist/components/icons.d.ts +7 -0
- package/dist/components/icons.d.ts.map +1 -0
- package/dist/components/icons.js +47 -0
- package/dist/components/icons.js.map +1 -0
- package/dist/components/pulse.d.ts +15 -0
- package/dist/components/pulse.d.ts.map +1 -0
- package/dist/components/pulse.js +10 -0
- package/dist/components/pulse.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/architecture.d.ts +60 -0
- package/dist/layout/architecture.d.ts.map +1 -0
- package/dist/layout/architecture.js +88 -0
- package/dist/layout/architecture.js.map +1 -0
- package/dist/layout/bounds.d.ts +25 -0
- package/dist/layout/bounds.d.ts.map +1 -0
- package/dist/layout/bounds.js +32 -0
- package/dist/layout/bounds.js.map +1 -0
- package/dist/layout/congestion.d.ts +18 -0
- package/dist/layout/congestion.d.ts.map +1 -0
- package/dist/layout/congestion.js +49 -0
- package/dist/layout/congestion.js.map +1 -0
- package/dist/layout/design.d.ts +98 -0
- package/dist/layout/design.d.ts.map +1 -0
- package/dist/layout/design.js +92 -0
- package/dist/layout/design.js.map +1 -0
- package/dist/layout/edges.d.ts +53 -0
- package/dist/layout/edges.d.ts.map +1 -0
- package/dist/layout/edges.js +848 -0
- package/dist/layout/edges.js.map +1 -0
- package/dist/layout/errors.d.ts +6 -0
- package/dist/layout/errors.d.ts.map +1 -0
- package/dist/layout/errors.js +9 -0
- package/dist/layout/errors.js.map +1 -0
- package/dist/layout/frame.d.ts +35 -0
- package/dist/layout/frame.d.ts.map +1 -0
- package/dist/layout/frame.js +63 -0
- package/dist/layout/frame.js.map +1 -0
- package/dist/layout/geometry.d.ts +23 -0
- package/dist/layout/geometry.d.ts.map +1 -0
- package/dist/layout/geometry.js +22 -0
- package/dist/layout/geometry.js.map +1 -0
- package/dist/layout/labels.d.ts +12 -0
- package/dist/layout/labels.d.ts.map +1 -0
- package/dist/layout/labels.js +153 -0
- package/dist/layout/labels.js.map +1 -0
- package/dist/layout/lanes.d.ts +5 -0
- package/dist/layout/lanes.d.ts.map +1 -0
- package/dist/layout/lanes.js +13 -0
- package/dist/layout/lanes.js.map +1 -0
- package/dist/layout/layout.d.ts +42 -0
- package/dist/layout/layout.d.ts.map +1 -0
- package/dist/layout/layout.js +94 -0
- package/dist/layout/layout.js.map +1 -0
- package/dist/layout/rank.d.ts +14 -0
- package/dist/layout/rank.d.ts.map +1 -0
- package/dist/layout/rank.js +78 -0
- package/dist/layout/rank.js.map +1 -0
- package/dist/layout/scope.d.ts +20 -0
- package/dist/layout/scope.d.ts.map +1 -0
- package/dist/layout/scope.js +52 -0
- package/dist/layout/scope.js.map +1 -0
- package/dist/layout/seating.d.ts +27 -0
- package/dist/layout/seating.d.ts.map +1 -0
- package/dist/layout/seating.js +135 -0
- package/dist/layout/seating.js.map +1 -0
- package/dist/layout/text.d.ts +12 -0
- package/dist/layout/text.d.ts.map +1 -0
- package/dist/layout/text.js +148 -0
- package/dist/layout/text.js.map +1 -0
- package/dist/layout/trace.d.ts +8 -0
- package/dist/layout/trace.d.ts.map +1 -0
- package/dist/layout/trace.js +51 -0
- package/dist/layout/trace.js.map +1 -0
- package/dist/layout.d.ts +9 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +6 -0
- package/dist/layout.js.map +1 -0
- package/dist/schema/document.d.ts +239 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +83 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/errors.d.ts +20 -0
- package/dist/schema/errors.d.ts.map +1 -0
- package/dist/schema/errors.js +12 -0
- package/dist/schema/errors.js.map +1 -0
- package/dist/schema/integrity.d.ts +8 -0
- package/dist/schema/integrity.d.ts.map +1 -0
- package/dist/schema/integrity.js +63 -0
- package/dist/schema/integrity.js.map +1 -0
- package/dist/schema/parse.d.ts +6 -0
- package/dist/schema/parse.d.ts.map +1 -0
- package/dist/schema/parse.js +53 -0
- package/dist/schema/parse.js.map +1 -0
- package/dist/schema/primitives.d.ts +58 -0
- package/dist/schema/primitives.d.ts.map +1 -0
- package/dist/schema/primitives.js +44 -0
- package/dist/schema/primitives.js.map +1 -0
- package/dist/theme.css +63 -0
- package/package.json +83 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/layout/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAU3C,MAAM,CAAC,MAAM,UAAU,GACrB,0FAA0F,CAAC;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,qEAAqE,C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,CAAC,IAAY,EAAE,IAAU,EAAE,QAAgB,EAAU,EAAE;IAC5E,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,SAAS,IAAI,IAAI;QAAE,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,QAAQ,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACjE,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Edge } from "../schema/document.js";
|
|
2
|
+
export type Highlight = "neighbours" | "upstream" | "downstream" | "both";
|
|
3
|
+
export type Trace = {
|
|
4
|
+
nodes: ReadonlySet<string>;
|
|
5
|
+
edges: ReadonlySet<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const traceFrom: (edges: readonly Edge[], seeds: readonly string[], highlight: Highlight) => Trace;
|
|
8
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/layout/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;AAE1E,MAAM,MAAM,KAAK,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AA6B/E,eAAO,MAAM,SAAS,UACb,SAAS,IAAI,EAAE,SACf,SAAS,MAAM,EAAE,aACb,SAAS,KACnB,KA0BF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assertNever } from "../assert.js";
|
|
2
|
+
const walk = (edges, seeds, forward, into) => {
|
|
3
|
+
const queue = [...seeds];
|
|
4
|
+
const visited = new Set(seeds);
|
|
5
|
+
while (queue.length > 0) {
|
|
6
|
+
const current = queue.shift();
|
|
7
|
+
if (current === undefined)
|
|
8
|
+
break;
|
|
9
|
+
for (const edge of edges) {
|
|
10
|
+
if (edge.from === edge.to)
|
|
11
|
+
continue;
|
|
12
|
+
const [here, next] = forward ? [edge.from, edge.to] : [edge.to, edge.from];
|
|
13
|
+
if (here !== current)
|
|
14
|
+
continue;
|
|
15
|
+
into.edges.add(edge.id);
|
|
16
|
+
into.nodes.add(next);
|
|
17
|
+
if (!visited.has(next)) {
|
|
18
|
+
visited.add(next);
|
|
19
|
+
queue.push(next);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const traceFrom = (edges, seeds, highlight) => {
|
|
25
|
+
const edgeIds = new Set(edges.map((edge) => edge.id));
|
|
26
|
+
const seedNodes = new Set(seeds.filter((id) => !edgeIds.has(id)));
|
|
27
|
+
const trace = {
|
|
28
|
+
nodes: new Set(seedNodes),
|
|
29
|
+
edges: new Set(seeds.filter((id) => edgeIds.has(id))),
|
|
30
|
+
};
|
|
31
|
+
switch (highlight) {
|
|
32
|
+
case "neighbours":
|
|
33
|
+
for (const edge of edges)
|
|
34
|
+
if (seedNodes.has(edge.from) || seedNodes.has(edge.to))
|
|
35
|
+
trace.edges.add(edge.id);
|
|
36
|
+
return trace;
|
|
37
|
+
case "upstream":
|
|
38
|
+
walk(edges, seedNodes, false, trace);
|
|
39
|
+
return trace;
|
|
40
|
+
case "downstream":
|
|
41
|
+
walk(edges, seedNodes, true, trace);
|
|
42
|
+
return trace;
|
|
43
|
+
case "both":
|
|
44
|
+
walk(edges, seedNodes, false, trace);
|
|
45
|
+
walk(edges, seedNodes, true, trace);
|
|
46
|
+
return trace;
|
|
47
|
+
default:
|
|
48
|
+
return assertNever(highlight, "Unhandled highlight");
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=trace.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AE,IAAI,EAAE,KAAK,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC;QACf;YACE,OAAO,WAAW,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC"}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { layout, type Atlas, type Layout, type LayoutOptions, type PlacedEdge, } from "./layout/layout.js";
|
|
2
|
+
export type { PlacedLane, PlacedNode } from "./layout/architecture.js";
|
|
3
|
+
export { DEFAULT_CARD_HEIGHTS, type CardHeights } from "./layout/design.js";
|
|
4
|
+
export type { Box, Point } from "./layout/geometry.js";
|
|
5
|
+
export { ConduitLayoutError, type LayoutErrorCode } from "./layout/errors.js";
|
|
6
|
+
export { findView, flattenViews } from "./layout/scope.js";
|
|
7
|
+
export type { Direction } from "./schema/primitives.js";
|
|
8
|
+
export { traceFrom, type Highlight, type Trace } from "./layout/trace.js";
|
|
9
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { layout, } from "./layout/layout.js";
|
|
2
|
+
export { DEFAULT_CARD_HEIGHTS } from "./layout/design.js";
|
|
3
|
+
export { ConduitLayoutError } from "./layout/errors.js";
|
|
4
|
+
export { findView, flattenViews } from "./layout/scope.js";
|
|
5
|
+
export { traceFrom } from "./layout/trace.js";
|
|
6
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAKP,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,oBAAoB,EAAoB,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAwB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAA8B,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const Lane: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
label: z.ZodString;
|
|
5
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
6
|
+
order: z.ZodOptional<z.ZodInt>;
|
|
7
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
caution: "caution";
|
|
9
|
+
critical: "critical";
|
|
10
|
+
neutral: "neutral";
|
|
11
|
+
positive: "positive";
|
|
12
|
+
}>>;
|
|
13
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type Lane = z.infer<typeof Lane>;
|
|
16
|
+
export declare const Badge: z.ZodObject<{
|
|
17
|
+
label: z.ZodString;
|
|
18
|
+
tone: z.ZodDefault<z.ZodEnum<{
|
|
19
|
+
caution: "caution";
|
|
20
|
+
critical: "critical";
|
|
21
|
+
neutral: "neutral";
|
|
22
|
+
positive: "positive";
|
|
23
|
+
}>>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type Badge = z.infer<typeof Badge>;
|
|
26
|
+
/**
|
|
27
|
+
* `compact` is the header alone; `chart` reserves a body slot; a number is a
|
|
28
|
+
* height in px, no shorter than a compact card's own height.
|
|
29
|
+
*/
|
|
30
|
+
export declare const NodeSize: z.ZodUnion<readonly [z.ZodLiteral<"compact">, z.ZodLiteral<"chart">, z.ZodNumber]>;
|
|
31
|
+
export type NodeSize = z.infer<typeof NodeSize>;
|
|
32
|
+
export declare const ConduitNode: z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
label: z.ZodString;
|
|
35
|
+
kind: z.ZodEnum<{
|
|
36
|
+
app: "app";
|
|
37
|
+
cache: "cache";
|
|
38
|
+
config: "config";
|
|
39
|
+
datastore: "datastore";
|
|
40
|
+
external: "external";
|
|
41
|
+
function: "function";
|
|
42
|
+
job: "job";
|
|
43
|
+
module: "module";
|
|
44
|
+
other: "other";
|
|
45
|
+
package: "package";
|
|
46
|
+
queue: "queue";
|
|
47
|
+
route: "route";
|
|
48
|
+
service: "service";
|
|
49
|
+
test: "test";
|
|
50
|
+
ui: "ui";
|
|
51
|
+
}>;
|
|
52
|
+
lane: z.ZodString;
|
|
53
|
+
row: z.ZodOptional<z.ZodInt>;
|
|
54
|
+
group: z.ZodOptional<z.ZodString>;
|
|
55
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
56
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
57
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
58
|
+
caution: "caution";
|
|
59
|
+
critical: "critical";
|
|
60
|
+
neutral: "neutral";
|
|
61
|
+
positive: "positive";
|
|
62
|
+
}>>;
|
|
63
|
+
badges: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
tone: z.ZodDefault<z.ZodEnum<{
|
|
66
|
+
caution: "caution";
|
|
67
|
+
critical: "critical";
|
|
68
|
+
neutral: "neutral";
|
|
69
|
+
positive: "positive";
|
|
70
|
+
}>>;
|
|
71
|
+
}, z.core.$strict>>>;
|
|
72
|
+
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"compact">, z.ZodLiteral<"chart">, z.ZodNumber]>>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
export type ConduitNode = z.infer<typeof ConduitNode>;
|
|
75
|
+
export declare const Edge: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
from: z.ZodString;
|
|
78
|
+
to: z.ZodString;
|
|
79
|
+
kind: z.ZodEnum<{
|
|
80
|
+
call: "call";
|
|
81
|
+
data: "data";
|
|
82
|
+
dependency: "dependency";
|
|
83
|
+
event: "event";
|
|
84
|
+
http: "http";
|
|
85
|
+
other: "other";
|
|
86
|
+
queue: "queue";
|
|
87
|
+
render: "render";
|
|
88
|
+
rpc: "rpc";
|
|
89
|
+
}>;
|
|
90
|
+
label: z.ZodOptional<z.ZodString>;
|
|
91
|
+
emphasis: z.ZodDefault<z.ZodEnum<{
|
|
92
|
+
hero: "hero";
|
|
93
|
+
muted: "muted";
|
|
94
|
+
normal: "normal";
|
|
95
|
+
}>>;
|
|
96
|
+
animated: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
98
|
+
caution: "caution";
|
|
99
|
+
critical: "critical";
|
|
100
|
+
neutral: "neutral";
|
|
101
|
+
positive: "positive";
|
|
102
|
+
}>>;
|
|
103
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
export type Edge = z.infer<typeof Edge>;
|
|
106
|
+
/**
|
|
107
|
+
* "All" and "a selection" are distinct states rather than "a selection that
|
|
108
|
+
* happens to be empty", so removing the last element a view pointed at can
|
|
109
|
+
* never silently turn it into a view of everything.
|
|
110
|
+
*/
|
|
111
|
+
export declare const ViewScope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
112
|
+
kind: z.ZodLiteral<"all">;
|
|
113
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
114
|
+
kind: z.ZodLiteral<"selection">;
|
|
115
|
+
lanes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
116
|
+
nodes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
117
|
+
edges: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
118
|
+
}, z.core.$strict>], "kind">;
|
|
119
|
+
export type ViewScope = z.infer<typeof ViewScope>;
|
|
120
|
+
export type View = {
|
|
121
|
+
id: string;
|
|
122
|
+
title: string;
|
|
123
|
+
summary?: string;
|
|
124
|
+
scope: ViewScope;
|
|
125
|
+
children: View[];
|
|
126
|
+
};
|
|
127
|
+
export type ViewInput = {
|
|
128
|
+
id: string;
|
|
129
|
+
title: string;
|
|
130
|
+
summary?: string;
|
|
131
|
+
scope?: {
|
|
132
|
+
kind: "all";
|
|
133
|
+
} | {
|
|
134
|
+
kind: "selection";
|
|
135
|
+
lanes?: string[];
|
|
136
|
+
nodes?: string[];
|
|
137
|
+
edges?: string[];
|
|
138
|
+
};
|
|
139
|
+
children?: ViewInput[];
|
|
140
|
+
};
|
|
141
|
+
export declare const View: z.ZodType<View, ViewInput>;
|
|
142
|
+
export declare const ConduitDocument: z.ZodObject<{
|
|
143
|
+
version: z.ZodLiteral<1>;
|
|
144
|
+
title: z.ZodString;
|
|
145
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
146
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
147
|
+
down: "down";
|
|
148
|
+
right: "right";
|
|
149
|
+
}>>;
|
|
150
|
+
lanes: z.ZodArray<z.ZodObject<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
label: z.ZodString;
|
|
153
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
154
|
+
order: z.ZodOptional<z.ZodInt>;
|
|
155
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
156
|
+
caution: "caution";
|
|
157
|
+
critical: "critical";
|
|
158
|
+
neutral: "neutral";
|
|
159
|
+
positive: "positive";
|
|
160
|
+
}>>;
|
|
161
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$strict>>;
|
|
163
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
164
|
+
id: z.ZodString;
|
|
165
|
+
label: z.ZodString;
|
|
166
|
+
kind: z.ZodEnum<{
|
|
167
|
+
app: "app";
|
|
168
|
+
cache: "cache";
|
|
169
|
+
config: "config";
|
|
170
|
+
datastore: "datastore";
|
|
171
|
+
external: "external";
|
|
172
|
+
function: "function";
|
|
173
|
+
job: "job";
|
|
174
|
+
module: "module";
|
|
175
|
+
other: "other";
|
|
176
|
+
package: "package";
|
|
177
|
+
queue: "queue";
|
|
178
|
+
route: "route";
|
|
179
|
+
service: "service";
|
|
180
|
+
test: "test";
|
|
181
|
+
ui: "ui";
|
|
182
|
+
}>;
|
|
183
|
+
lane: z.ZodString;
|
|
184
|
+
row: z.ZodOptional<z.ZodInt>;
|
|
185
|
+
group: z.ZodOptional<z.ZodString>;
|
|
186
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
187
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
188
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
189
|
+
caution: "caution";
|
|
190
|
+
critical: "critical";
|
|
191
|
+
neutral: "neutral";
|
|
192
|
+
positive: "positive";
|
|
193
|
+
}>>;
|
|
194
|
+
badges: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
195
|
+
label: z.ZodString;
|
|
196
|
+
tone: z.ZodDefault<z.ZodEnum<{
|
|
197
|
+
caution: "caution";
|
|
198
|
+
critical: "critical";
|
|
199
|
+
neutral: "neutral";
|
|
200
|
+
positive: "positive";
|
|
201
|
+
}>>;
|
|
202
|
+
}, z.core.$strict>>>;
|
|
203
|
+
size: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"compact">, z.ZodLiteral<"chart">, z.ZodNumber]>>;
|
|
204
|
+
}, z.core.$strict>>;
|
|
205
|
+
edges: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
206
|
+
id: z.ZodString;
|
|
207
|
+
from: z.ZodString;
|
|
208
|
+
to: z.ZodString;
|
|
209
|
+
kind: z.ZodEnum<{
|
|
210
|
+
call: "call";
|
|
211
|
+
data: "data";
|
|
212
|
+
dependency: "dependency";
|
|
213
|
+
event: "event";
|
|
214
|
+
http: "http";
|
|
215
|
+
other: "other";
|
|
216
|
+
queue: "queue";
|
|
217
|
+
render: "render";
|
|
218
|
+
rpc: "rpc";
|
|
219
|
+
}>;
|
|
220
|
+
label: z.ZodOptional<z.ZodString>;
|
|
221
|
+
emphasis: z.ZodDefault<z.ZodEnum<{
|
|
222
|
+
hero: "hero";
|
|
223
|
+
muted: "muted";
|
|
224
|
+
normal: "normal";
|
|
225
|
+
}>>;
|
|
226
|
+
animated: z.ZodDefault<z.ZodBoolean>;
|
|
227
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
228
|
+
caution: "caution";
|
|
229
|
+
critical: "critical";
|
|
230
|
+
neutral: "neutral";
|
|
231
|
+
positive: "positive";
|
|
232
|
+
}>>;
|
|
233
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, z.core.$strict>>>;
|
|
235
|
+
views: z.ZodDefault<z.ZodArray<z.ZodType<View, ViewInput, z.core.$ZodTypeInternals<View, ViewInput>>>>;
|
|
236
|
+
}, z.core.$strict>;
|
|
237
|
+
export type ConduitDocument = z.infer<typeof ConduitDocument>;
|
|
238
|
+
export type ConduitDocumentInput = z.input<typeof ConduitDocument>;
|
|
239
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EACF;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,GACf;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAChF,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAQ3C,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAS1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Direction, EdgeEmphasis, EdgeKind, Id, Label, NodeKind, Status, Summary, } from "./primitives.js";
|
|
3
|
+
export const Lane = z.strictObject({
|
|
4
|
+
id: Id,
|
|
5
|
+
label: Label,
|
|
6
|
+
subtitle: Label.optional(),
|
|
7
|
+
order: z.int().min(0).max(64).optional(),
|
|
8
|
+
status: Status.default("neutral"),
|
|
9
|
+
summary: Summary.optional(),
|
|
10
|
+
});
|
|
11
|
+
export const Badge = z.strictObject({
|
|
12
|
+
label: Label.max(32),
|
|
13
|
+
tone: Status.default("neutral"),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* `compact` is the header alone; `chart` reserves a body slot; a number is a
|
|
17
|
+
* height in px, no shorter than a compact card's own height.
|
|
18
|
+
*/
|
|
19
|
+
export const NodeSize = z.union([
|
|
20
|
+
z.literal("compact"),
|
|
21
|
+
z.literal("chart"),
|
|
22
|
+
z.number().min(52).max(1000),
|
|
23
|
+
]);
|
|
24
|
+
export const ConduitNode = z.strictObject({
|
|
25
|
+
id: Id,
|
|
26
|
+
label: Label,
|
|
27
|
+
kind: NodeKind,
|
|
28
|
+
lane: Id,
|
|
29
|
+
row: z.int().min(0).max(256).optional(),
|
|
30
|
+
group: Id.optional(),
|
|
31
|
+
subtitle: Label.optional(),
|
|
32
|
+
summary: Summary.optional(),
|
|
33
|
+
status: Status.default("neutral"),
|
|
34
|
+
badges: z.array(Badge).max(6).default([]),
|
|
35
|
+
size: NodeSize.default("compact"),
|
|
36
|
+
});
|
|
37
|
+
export const Edge = z.strictObject({
|
|
38
|
+
id: Id,
|
|
39
|
+
from: Id,
|
|
40
|
+
to: Id,
|
|
41
|
+
kind: EdgeKind,
|
|
42
|
+
label: Label.optional(),
|
|
43
|
+
emphasis: EdgeEmphasis.default("normal"),
|
|
44
|
+
animated: z.boolean().default(false),
|
|
45
|
+
status: Status.default("neutral"),
|
|
46
|
+
summary: Summary.optional(),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* "All" and "a selection" are distinct states rather than "a selection that
|
|
50
|
+
* happens to be empty", so removing the last element a view pointed at can
|
|
51
|
+
* never silently turn it into a view of everything.
|
|
52
|
+
*/
|
|
53
|
+
export const ViewScope = z.discriminatedUnion("kind", [
|
|
54
|
+
z.strictObject({ kind: z.literal("all") }),
|
|
55
|
+
z
|
|
56
|
+
.strictObject({
|
|
57
|
+
kind: z.literal("selection"),
|
|
58
|
+
lanes: z.array(Id).max(64).default([]),
|
|
59
|
+
nodes: z.array(Id).max(256).default([]),
|
|
60
|
+
edges: z.array(Id).max(512).default([]),
|
|
61
|
+
})
|
|
62
|
+
.refine((scope) => scope.lanes.length + scope.nodes.length + scope.edges.length > 0, {
|
|
63
|
+
message: "a selection must name at least one element",
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
|
+
export const View = z.lazy(() => z.strictObject({
|
|
67
|
+
id: Id,
|
|
68
|
+
title: Label,
|
|
69
|
+
summary: Summary.optional(),
|
|
70
|
+
scope: ViewScope.default({ kind: "all" }),
|
|
71
|
+
children: z.array(View).max(32).default([]),
|
|
72
|
+
}));
|
|
73
|
+
export const ConduitDocument = z.strictObject({
|
|
74
|
+
version: z.literal(1),
|
|
75
|
+
title: Label,
|
|
76
|
+
summary: Summary.optional(),
|
|
77
|
+
direction: Direction.default("right"),
|
|
78
|
+
lanes: z.array(Lane).min(1).max(16),
|
|
79
|
+
nodes: z.array(ConduitNode).min(1).max(256),
|
|
80
|
+
edges: z.array(Edge).max(512).default([]),
|
|
81
|
+
views: z.array(View).max(32).default([]),
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/schema/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,EAAE,EACF,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,GACR,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC;IACjC,EAAE,EAAE,EAAE;IACN,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;IAC1B,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;CAC5B,CAAC,CA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4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ConduitDocumentError extends Error {
|
|
8
|
+
readonly code: SchemaErrorCode;
|
|
9
|
+
readonly issues: readonly SchemaIssue[];
|
|
10
|
+
constructor(code: SchemaErrorCode, message: string, issues?: readonly SchemaIssue[]);
|
|
11
|
+
}
|
|
12
|
+
export type Parsed<T> = {
|
|
13
|
+
ok: true;
|
|
14
|
+
value: T;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
error: ConduitDocumentError;
|
|
18
|
+
};
|
|
19
|
+
export declare const formatIssues: (issues: readonly SchemaIssue[]) => string;
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schema/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,cAAc,CAAC;AAEvF,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAExC,YAAY,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,WAAW,EAAO,EAKtF;CACF;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAE5F,eAAO,MAAM,YAAY,WAAY,SAAS,WAAW,EAAE,KAAG,MACqC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class ConduitDocumentError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
issues;
|
|
4
|
+
constructor(code, message, issues = []) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "ConduitDocumentError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const formatIssues = (issues) => issues.map((issue) => ` ${issue.path || "<root>"}: ${issue.message} [${issue.code}]`).join("\n");
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/schema/errors.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAAkB;IACtB,MAAM,CAAyB;IAExC,YAAY,IAAqB,EAAE,OAAe,EAAE,MAAM,GAA2B,EAAE;QACrF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAID,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA8B,EAAU,EAAE,CACrE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConduitDocument } from "./document.js";
|
|
2
|
+
import type { SchemaIssue } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Structural validation says a field holds an id; these checks say the id
|
|
5
|
+
* points at something.
|
|
6
|
+
*/
|
|
7
|
+
export declare const integrityIssues: (doc: ConduitDocument) => SchemaIssue[];
|
|
8
|
+
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrity.d.ts","sourceRoot":"","sources":["../../src/schema/integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkB/C;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,eAAe,KAAG,WAAW,EA4DjE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const duplicates = (ids) => {
|
|
2
|
+
const seen = new Set();
|
|
3
|
+
const repeated = new Set();
|
|
4
|
+
for (const id of ids) {
|
|
5
|
+
if (seen.has(id))
|
|
6
|
+
repeated.add(id);
|
|
7
|
+
seen.add(id);
|
|
8
|
+
}
|
|
9
|
+
return [...repeated];
|
|
10
|
+
};
|
|
11
|
+
const flattenViews = (views, prefix) => views.flatMap((view, index) => {
|
|
12
|
+
const path = `${prefix}[${index}]`;
|
|
13
|
+
return [{ view, path }, ...flattenViews(view.children, `${path}.children`)];
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Structural validation says a field holds an id; these checks say the id
|
|
17
|
+
* points at something.
|
|
18
|
+
*/
|
|
19
|
+
export const integrityIssues = (doc) => {
|
|
20
|
+
const issues = [];
|
|
21
|
+
const broken = (path, message) => issues.push({ code: "BROKEN_REFERENCE", path, message });
|
|
22
|
+
const duplicate = (path, message) => issues.push({ code: "DUPLICATE_ID", path, message });
|
|
23
|
+
const laneIds = new Set(doc.lanes.map((lane) => lane.id));
|
|
24
|
+
const nodeIds = new Set(doc.nodes.map((node) => node.id));
|
|
25
|
+
const edgeIds = new Set(doc.edges.map((edge) => edge.id));
|
|
26
|
+
for (const id of duplicates(doc.lanes.map((lane) => lane.id)))
|
|
27
|
+
duplicate("lanes", `duplicate lane id '${id}'`);
|
|
28
|
+
for (const id of duplicates(doc.nodes.map((node) => node.id)))
|
|
29
|
+
duplicate("nodes", `duplicate node id '${id}'`);
|
|
30
|
+
for (const id of duplicates(doc.edges.map((edge) => edge.id)))
|
|
31
|
+
duplicate("edges", `duplicate edge id '${id}'`);
|
|
32
|
+
doc.nodes.forEach((node, index) => {
|
|
33
|
+
if (!laneIds.has(node.lane))
|
|
34
|
+
broken(`nodes[${index}].lane`, `node '${node.id}' references unknown lane '${node.lane}'`);
|
|
35
|
+
});
|
|
36
|
+
doc.edges.forEach((edge, index) => {
|
|
37
|
+
if (!nodeIds.has(edge.from))
|
|
38
|
+
broken(`edges[${index}].from`, `edge '${edge.id}' references unknown node '${edge.from}'`);
|
|
39
|
+
if (!nodeIds.has(edge.to))
|
|
40
|
+
broken(`edges[${index}].to`, `edge '${edge.id}' references unknown node '${edge.to}'`);
|
|
41
|
+
});
|
|
42
|
+
const views = flattenViews(doc.views, "views");
|
|
43
|
+
for (const id of duplicates(views.map(({ view }) => view.id)))
|
|
44
|
+
duplicate("views", `duplicate view id '${id}'`);
|
|
45
|
+
for (const { view, path } of views) {
|
|
46
|
+
if (view.scope.kind !== "selection")
|
|
47
|
+
continue;
|
|
48
|
+
view.scope.lanes.forEach((id, index) => {
|
|
49
|
+
if (!laneIds.has(id))
|
|
50
|
+
broken(`${path}.scope.lanes[${index}]`, `view '${view.id}' references unknown lane '${id}'`);
|
|
51
|
+
});
|
|
52
|
+
view.scope.nodes.forEach((id, index) => {
|
|
53
|
+
if (!nodeIds.has(id))
|
|
54
|
+
broken(`${path}.scope.nodes[${index}]`, `view '${view.id}' references unknown node '${id}'`);
|
|
55
|
+
});
|
|
56
|
+
view.scope.edges.forEach((id, index) => {
|
|
57
|
+
if (!edgeIds.has(id))
|
|
58
|
+
broken(`${path}.scope.edges[${index}]`, `view '${view.id}' references unknown edge '${id}'`);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
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CAAC;gBAClB,MAAM,CACJ,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAC/B,SAAS,IAAI,CAAC,EAAE,8BAA8B,EAAE,GAAG,CACpD,CAAC;QACN,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,CACJ,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAC/B,SAAS,IAAI,CAAC,EAAE,8BAA8B,EAAE,GAAG,CACpD,CAAC;QACN,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,CACJ,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAC/B,SAAS,IAAI,CAAC,EAAE,8BAA8B,EAAE,GAAG,CACpD,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConduitDocument } from "./document.js";
|
|
2
|
+
import { type Parsed } from "./errors.js";
|
|
3
|
+
/** Structure and referential integrity in one pass. A document that survives this is safe to lay out. */
|
|
4
|
+
export declare const safeParseDocument: (input: unknown) => Parsed<ConduitDocument>;
|
|
5
|
+
export declare const parseDocument: (input: unknown) => ConduitDocument;
|
|
6
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/schema/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAsC,KAAK,MAAM,EAAoB,MAAM,aAAa,CAAC;AA6ChG,yGAAyG;AACzG,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,MAAM,CAAC,eAAe,CAMxE,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,eAI9C,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ConduitDocument } from "./document.js";
|
|
2
|
+
import { formatIssues, ConduitDocumentError } from "./errors.js";
|
|
3
|
+
import { integrityIssues } from "./integrity.js";
|
|
4
|
+
const formatPath = (path) => path.reduce((acc, segment) => {
|
|
5
|
+
if (typeof segment === "number")
|
|
6
|
+
return `${acc}[${segment}]`;
|
|
7
|
+
return acc === "" ? String(segment) : `${acc}.${String(segment)}`;
|
|
8
|
+
}, "");
|
|
9
|
+
const toIssues = (error) => error.issues.map((issue) => ({
|
|
10
|
+
code: "INVALID_DOCUMENT",
|
|
11
|
+
path: formatPath(issue.path),
|
|
12
|
+
message: issue.message,
|
|
13
|
+
}));
|
|
14
|
+
const fail = (issues) => {
|
|
15
|
+
const first = issues[0];
|
|
16
|
+
return new ConduitDocumentError(first ? first.code : "INVALID_DOCUMENT", `invalid conduit document:\n${formatIssues(issues)}`, issues);
|
|
17
|
+
};
|
|
18
|
+
/** A document nested deeply enough exhausts the stack inside zod; report it as what it is. */
|
|
19
|
+
const attemptParse = (input) => {
|
|
20
|
+
try {
|
|
21
|
+
const result = ConduitDocument.safeParse(input);
|
|
22
|
+
return result.success
|
|
23
|
+
? { read: true, value: result.data }
|
|
24
|
+
: { read: false, issues: toIssues(result.error) };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (!(error instanceof RangeError))
|
|
28
|
+
throw error;
|
|
29
|
+
return {
|
|
30
|
+
read: false,
|
|
31
|
+
issues: [
|
|
32
|
+
{ code: "INVALID_DOCUMENT", path: "", message: "document nests too deeply to read" },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/** Structure and referential integrity in one pass. A document that survives this is safe to lay out. */
|
|
38
|
+
export const safeParseDocument = (input) => {
|
|
39
|
+
const result = attemptParse(input);
|
|
40
|
+
if (!result.read)
|
|
41
|
+
return { ok: false, error: fail(result.issues) };
|
|
42
|
+
const issues = integrityIssues(result.value);
|
|
43
|
+
if (issues.length > 0)
|
|
44
|
+
return { ok: false, error: fail(issues) };
|
|
45
|
+
return { ok: true, value: result.value };
|
|
46
|
+
};
|
|
47
|
+
export const parseDocument = (input) => {
|
|
48
|
+
const parsed = safeParseDocument(input);
|
|
49
|
+
if (parsed.ok)
|
|
50
|
+
return parsed.value;
|
|
51
|
+
throw parsed.error;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/schema/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAiC,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAG,CAAC,IAA4B,EAAU,EAAE,CAC1D,IAAI,CAAC,MAAM,CAAS,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IACnC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,GAAG,GAAG,IAAI,OAAO,GAAG,CAAC;IAC7D,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;AACpE,CAAC,EAAE,EAAE,CAAC,CAAC;AAET,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAiB,EAAE,CACpD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC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