graphenix-format 1.2.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/README.md +274 -0
- package/dist/crud.d.ts +25 -0
- package/dist/crud.d.ts.map +1 -0
- package/dist/crud.js +184 -0
- package/dist/crud.js.map +1 -0
- package/dist/examples/minimal-graph.d.ts +3 -0
- package/dist/examples/minimal-graph.d.ts.map +1 -0
- package/dist/examples/minimal-graph.js +103 -0
- package/dist/examples/minimal-graph.js.map +1 -0
- package/dist/examples/validate-minimal.d.ts +2 -0
- package/dist/examples/validate-minimal.d.ts.map +1 -0
- package/dist/examples/validate-minimal.js +13 -0
- package/dist/examples/validate-minimal.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +30 -0
- package/dist/validate.js.map +1 -0
- package/package.json +44 -0
- package/schema/graphenix-format-1.0.0.schema.json +438 -0
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
## `@graphenix/format`
|
|
2
|
+
|
|
3
|
+
TypeScript/JavaScript utilities for working with the **Graphenix Format 1.0.0**:
|
|
4
|
+
|
|
5
|
+
- **JSON Schema** for validation (`schema/graphenix-format-1.0.0.schema.json`)
|
|
6
|
+
- **Runtime validator** built on [`ajv`](https://ajv.js.org)
|
|
7
|
+
- Lightweight **CRUD helpers** for nodes, edges, types and subgraphs
|
|
8
|
+
- First-class **TypeScript types** for graph documents
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
### Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @graphenix/format
|
|
16
|
+
# or
|
|
17
|
+
yarn add @graphenix/format
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
#### Validate a graph document
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { validateGraph, type GraphDocument } from "@graphenix/format";
|
|
28
|
+
|
|
29
|
+
const doc: GraphDocument = {
|
|
30
|
+
formatVersion: "1.0.0",
|
|
31
|
+
id: "graph:auth/user-signup",
|
|
32
|
+
graph: {
|
|
33
|
+
nodes: [],
|
|
34
|
+
edges: [],
|
|
35
|
+
inputs: [],
|
|
36
|
+
outputs: []
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const result = validateGraph(doc);
|
|
41
|
+
|
|
42
|
+
if (!result.valid) {
|
|
43
|
+
console.error(result.errors);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Each error has:
|
|
48
|
+
|
|
49
|
+
- **`message`**: human readable message
|
|
50
|
+
- **`path`**: JSON Pointer to the failing instance
|
|
51
|
+
- **`keyword`** and **`params`** from `ajv` for tooling.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
#### Quick start: minimal Graphenix document
|
|
56
|
+
|
|
57
|
+
This is a minimal but complete **Graphenix Format 1.0.0** document that you can load, validate, and then modify:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import {
|
|
61
|
+
validateGraph,
|
|
62
|
+
type GraphDocument,
|
|
63
|
+
addNode,
|
|
64
|
+
addEdge
|
|
65
|
+
} from "@graphenix/format";
|
|
66
|
+
|
|
67
|
+
const doc: GraphDocument = {
|
|
68
|
+
formatVersion: "1.0.0",
|
|
69
|
+
id: "graph:auth/user-signup",
|
|
70
|
+
name: "User Signup",
|
|
71
|
+
graph: {
|
|
72
|
+
nodes: [
|
|
73
|
+
{
|
|
74
|
+
id: "node:validate-input",
|
|
75
|
+
kind: "builtin:validate",
|
|
76
|
+
inputs: [
|
|
77
|
+
{
|
|
78
|
+
id: "in:payload",
|
|
79
|
+
direction: "input",
|
|
80
|
+
type: "builtin:object",
|
|
81
|
+
required: true
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
outputs: [
|
|
85
|
+
{
|
|
86
|
+
id: "out:validated",
|
|
87
|
+
direction: "output",
|
|
88
|
+
type: "builtin:object"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
parameters: {
|
|
92
|
+
schemaType: "type:User"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
edges: [],
|
|
97
|
+
inputs: [
|
|
98
|
+
{
|
|
99
|
+
id: "graph-input:request",
|
|
100
|
+
name: "Request Body",
|
|
101
|
+
type: "builtin:object",
|
|
102
|
+
target: {
|
|
103
|
+
nodeId: "node:validate-input",
|
|
104
|
+
portId: "in:payload"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
outputs: [],
|
|
109
|
+
metadata: {}
|
|
110
|
+
},
|
|
111
|
+
types: [
|
|
112
|
+
{
|
|
113
|
+
id: "type:User",
|
|
114
|
+
kind: "object",
|
|
115
|
+
fields: [
|
|
116
|
+
{ name: "id", type: "builtin:string", required: true },
|
|
117
|
+
{ name: "email", type: "builtin:string", required: true }
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Validate against the Graphenix JSON Schema
|
|
124
|
+
const res = validateGraph(doc);
|
|
125
|
+
if (!res.valid) {
|
|
126
|
+
throw new Error(JSON.stringify(res.errors, null, 2));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Programmatically add a new node + edge
|
|
130
|
+
const withCreateNode = addNode(doc, {
|
|
131
|
+
id: "node:create-user",
|
|
132
|
+
kind: "task:http-request",
|
|
133
|
+
inputs: [
|
|
134
|
+
{
|
|
135
|
+
id: "in:validated",
|
|
136
|
+
direction: "input",
|
|
137
|
+
type: "type:User",
|
|
138
|
+
required: true
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
outputs: [
|
|
142
|
+
{
|
|
143
|
+
id: "out:user",
|
|
144
|
+
direction: "output",
|
|
145
|
+
type: "type:User"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
parameters: {
|
|
149
|
+
method: "POST",
|
|
150
|
+
url: "https://example.com/users"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const finalDoc = addEdge(withCreateNode, {
|
|
155
|
+
id: "edge:validate-to-create",
|
|
156
|
+
from: { nodeId: "node:validate-input", portId: "out:validated" },
|
|
157
|
+
to: { nodeId: "node:create-user", portId: "in:validated" }
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This matches the structure described in `GRAPHENIX-FORMAT.md` and can be fed directly to your executor.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
#### CRUD helpers
|
|
166
|
+
|
|
167
|
+
CRUD helpers operate on an in-memory `GraphDocument` and return a new document by default (immutable), or mutate in-place when `mutate: true` is passed.
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import {
|
|
171
|
+
addNode,
|
|
172
|
+
updateNode,
|
|
173
|
+
removeNode,
|
|
174
|
+
addEdge,
|
|
175
|
+
removeEdge,
|
|
176
|
+
addType
|
|
177
|
+
} from "@graphenix/format";
|
|
178
|
+
|
|
179
|
+
import type { GraphDocument } from "@graphenix/format";
|
|
180
|
+
|
|
181
|
+
let doc: GraphDocument = /* ... */;
|
|
182
|
+
|
|
183
|
+
// Add a node (immutable)
|
|
184
|
+
doc = addNode(doc, {
|
|
185
|
+
id: "node:validate-input",
|
|
186
|
+
kind: "builtin:validate",
|
|
187
|
+
inputs: [],
|
|
188
|
+
outputs: []
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// Update a node
|
|
192
|
+
doc = updateNode(doc, "node:validate-input", {
|
|
193
|
+
name: "Validate Input"
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Remove a node (also removes attached edges and graph IO)
|
|
197
|
+
doc = removeNode(doc, "node:validate-input");
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
All CRUD helpers accept an optional `{ mutate?: boolean }`:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
addNode(doc, newNode, { mutate: true }); // modifies `doc` in place
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Available helpers:
|
|
207
|
+
|
|
208
|
+
- **Nodes**: `getNode`, `addNode`, `updateNode`, `removeNode`
|
|
209
|
+
- **Edges**: `getEdge`, `addEdge`, `updateEdge`, `removeEdge`
|
|
210
|
+
- **Types**: `getType`, `addType`, `updateType`, `removeType`
|
|
211
|
+
- **Subgraphs**: `getSubgraph`, `addSubgraph`, `updateSubgraph`, `removeSubgraph`
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### Working with subgraphs and types
|
|
216
|
+
|
|
217
|
+
Subgraphs are just nested `graph` structures that can be referenced via node `kind`:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import {
|
|
221
|
+
type GraphDocument,
|
|
222
|
+
addSubgraph,
|
|
223
|
+
addNode
|
|
224
|
+
} from "@graphenix/format";
|
|
225
|
+
|
|
226
|
+
let doc: GraphDocument = /* existing document */;
|
|
227
|
+
|
|
228
|
+
// Add a reusable subgraph
|
|
229
|
+
doc = addSubgraph(doc, {
|
|
230
|
+
id: "graph:user-validation",
|
|
231
|
+
name: "User Validation",
|
|
232
|
+
graph: {
|
|
233
|
+
nodes: [],
|
|
234
|
+
edges: [],
|
|
235
|
+
inputs: [],
|
|
236
|
+
outputs: []
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Use it as a node in the main graph
|
|
241
|
+
doc = addNode(doc, {
|
|
242
|
+
id: "node:user-validation",
|
|
243
|
+
kind: "subgraph:graph:user-validation",
|
|
244
|
+
inputs: [],
|
|
245
|
+
outputs: []
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
For a full description of all fields and constraints, see `GRAPHENIX-FORMAT.md` in this repo.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### Build & test locally
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# install dev dependencies
|
|
257
|
+
npm install
|
|
258
|
+
|
|
259
|
+
# build ESM + CJS
|
|
260
|
+
npm run build
|
|
261
|
+
|
|
262
|
+
# run a tiny smoke test that validates the minimal example graph
|
|
263
|
+
npm test
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The minimal example graph lives in `src/examples/minimal-graph.ts` and mirrors the example from `GRAPHENIX-FORMAT.md`.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### Notes
|
|
271
|
+
|
|
272
|
+
- The package is **execution-agnostic**: it only knows about the static Graphenix format.
|
|
273
|
+
- Runtime concerns (scheduling, retries, parallelism, logging, etc.) are intentionally left to your executor/runtime.
|
|
274
|
+
|
package/dist/crud.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GraphDocument, Node, Edge, TypeDefinition, SubgraphDefinition } from "./types";
|
|
2
|
+
export interface CrudOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true, mutations are applied to the passed-in object.
|
|
5
|
+
* When false (default), a shallow-cloned document is returned.
|
|
6
|
+
*/
|
|
7
|
+
mutate?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function getNode(doc: GraphDocument, nodeId: string): Node | undefined;
|
|
10
|
+
export declare function addNode(doc: GraphDocument, node: Node, options?: CrudOptions): GraphDocument;
|
|
11
|
+
export declare function updateNode(doc: GraphDocument, nodeId: string, patch: Partial<Node>, options?: CrudOptions): GraphDocument;
|
|
12
|
+
export declare function removeNode(doc: GraphDocument, nodeId: string, options?: CrudOptions): GraphDocument;
|
|
13
|
+
export declare function getEdge(doc: GraphDocument, edgeId: string): Edge | undefined;
|
|
14
|
+
export declare function addEdge(doc: GraphDocument, edge: Edge, options?: CrudOptions): GraphDocument;
|
|
15
|
+
export declare function updateEdge(doc: GraphDocument, edgeId: string, patch: Partial<Edge>, options?: CrudOptions): GraphDocument;
|
|
16
|
+
export declare function removeEdge(doc: GraphDocument, edgeId: string, options?: CrudOptions): GraphDocument;
|
|
17
|
+
export declare function getType(doc: GraphDocument, typeId: string): TypeDefinition | undefined;
|
|
18
|
+
export declare function addType(doc: GraphDocument, typeDef: TypeDefinition, options?: CrudOptions): GraphDocument;
|
|
19
|
+
export declare function updateType(doc: GraphDocument, typeId: string, patch: Partial<TypeDefinition>, options?: CrudOptions): GraphDocument;
|
|
20
|
+
export declare function removeType(doc: GraphDocument, typeId: string, options?: CrudOptions): GraphDocument;
|
|
21
|
+
export declare function getSubgraph(doc: GraphDocument, subgraphId: string): SubgraphDefinition | undefined;
|
|
22
|
+
export declare function addSubgraph(doc: GraphDocument, subgraph: SubgraphDefinition, options?: CrudOptions): GraphDocument;
|
|
23
|
+
export declare function updateSubgraph(doc: GraphDocument, subgraphId: string, patch: Partial<SubgraphDefinition>, options?: CrudOptions): GraphDocument;
|
|
24
|
+
export declare function removeSubgraph(doc: GraphDocument, subgraphId: string, options?: CrudOptions): GraphDocument;
|
|
25
|
+
//# sourceMappingURL=crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../src/crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAgBD,wBAAgB,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAE5E;AAED,wBAAgB,OAAO,CACr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xB,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAWf;AAID,wBAAgB,WAAW,CACzB,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,GACjB,kBAAkB,GAAG,SAAS,CAEhC;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAQf;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAClC,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAef;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAWf"}
|
package/dist/crud.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNode = getNode;
|
|
4
|
+
exports.addNode = addNode;
|
|
5
|
+
exports.updateNode = updateNode;
|
|
6
|
+
exports.removeNode = removeNode;
|
|
7
|
+
exports.getEdge = getEdge;
|
|
8
|
+
exports.addEdge = addEdge;
|
|
9
|
+
exports.updateEdge = updateEdge;
|
|
10
|
+
exports.removeEdge = removeEdge;
|
|
11
|
+
exports.getType = getType;
|
|
12
|
+
exports.addType = addType;
|
|
13
|
+
exports.updateType = updateType;
|
|
14
|
+
exports.removeType = removeType;
|
|
15
|
+
exports.getSubgraph = getSubgraph;
|
|
16
|
+
exports.addSubgraph = addSubgraph;
|
|
17
|
+
exports.updateSubgraph = updateSubgraph;
|
|
18
|
+
exports.removeSubgraph = removeSubgraph;
|
|
19
|
+
function cloneIfNeeded(value, mutate) {
|
|
20
|
+
if (mutate)
|
|
21
|
+
return value;
|
|
22
|
+
return structuredClone(value);
|
|
23
|
+
}
|
|
24
|
+
function ensureGraph(doc) {
|
|
25
|
+
if (!doc.graph) {
|
|
26
|
+
throw new Error("GraphDocument.graph is missing");
|
|
27
|
+
}
|
|
28
|
+
return doc.graph;
|
|
29
|
+
}
|
|
30
|
+
// NODES
|
|
31
|
+
function getNode(doc, nodeId) {
|
|
32
|
+
return ensureGraph(doc).nodes.find((n) => n.id === nodeId);
|
|
33
|
+
}
|
|
34
|
+
function addNode(doc, node, options) {
|
|
35
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
36
|
+
const graph = ensureGraph(next);
|
|
37
|
+
if (graph.nodes.some((n) => n.id === node.id)) {
|
|
38
|
+
throw new Error(`Node with id '${node.id}' already exists`);
|
|
39
|
+
}
|
|
40
|
+
graph.nodes.push(node);
|
|
41
|
+
return next;
|
|
42
|
+
}
|
|
43
|
+
function updateNode(doc, nodeId, patch, options) {
|
|
44
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
45
|
+
const graph = ensureGraph(next);
|
|
46
|
+
const idx = graph.nodes.findIndex((n) => n.id === nodeId);
|
|
47
|
+
if (idx === -1) {
|
|
48
|
+
throw new Error(`Node with id '${nodeId}' not found`);
|
|
49
|
+
}
|
|
50
|
+
graph.nodes[idx] = { ...graph.nodes[idx], ...patch, id: graph.nodes[idx].id };
|
|
51
|
+
return next;
|
|
52
|
+
}
|
|
53
|
+
function removeNode(doc, nodeId, options) {
|
|
54
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
55
|
+
const graph = ensureGraph(next);
|
|
56
|
+
const before = graph.nodes.length;
|
|
57
|
+
graph.nodes = graph.nodes.filter((n) => n.id !== nodeId);
|
|
58
|
+
if (graph.nodes.length === before) {
|
|
59
|
+
throw new Error(`Node with id '${nodeId}' not found`);
|
|
60
|
+
}
|
|
61
|
+
// Also remove edges and graph IO that reference this node
|
|
62
|
+
graph.edges = graph.edges.filter((e) => e.from.nodeId !== nodeId && e.to.nodeId !== nodeId);
|
|
63
|
+
graph.inputs = graph.inputs.filter((i) => i.target.nodeId !== nodeId);
|
|
64
|
+
graph.outputs = graph.outputs.filter((o) => o.source.nodeId !== nodeId);
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
// EDGES
|
|
68
|
+
function getEdge(doc, edgeId) {
|
|
69
|
+
return ensureGraph(doc).edges.find((e) => e.id === edgeId);
|
|
70
|
+
}
|
|
71
|
+
function addEdge(doc, edge, options) {
|
|
72
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
73
|
+
const graph = ensureGraph(next);
|
|
74
|
+
if (graph.edges.some((e) => e.id === edge.id)) {
|
|
75
|
+
throw new Error(`Edge with id '${edge.id}' already exists`);
|
|
76
|
+
}
|
|
77
|
+
graph.edges.push(edge);
|
|
78
|
+
return next;
|
|
79
|
+
}
|
|
80
|
+
function updateEdge(doc, edgeId, patch, options) {
|
|
81
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
82
|
+
const graph = ensureGraph(next);
|
|
83
|
+
const idx = graph.edges.findIndex((e) => e.id === edgeId);
|
|
84
|
+
if (idx === -1) {
|
|
85
|
+
throw new Error(`Edge with id '${edgeId}' not found`);
|
|
86
|
+
}
|
|
87
|
+
graph.edges[idx] = { ...graph.edges[idx], ...patch, id: graph.edges[idx].id };
|
|
88
|
+
return next;
|
|
89
|
+
}
|
|
90
|
+
function removeEdge(doc, edgeId, options) {
|
|
91
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
92
|
+
const graph = ensureGraph(next);
|
|
93
|
+
const before = graph.edges.length;
|
|
94
|
+
graph.edges = graph.edges.filter((e) => e.id !== edgeId);
|
|
95
|
+
if (graph.edges.length === before) {
|
|
96
|
+
throw new Error(`Edge with id '${edgeId}' not found`);
|
|
97
|
+
}
|
|
98
|
+
return next;
|
|
99
|
+
}
|
|
100
|
+
// TYPES
|
|
101
|
+
function getType(doc, typeId) {
|
|
102
|
+
return (doc.types ?? []).find((t) => t.id === typeId);
|
|
103
|
+
}
|
|
104
|
+
function addType(doc, typeDef, options) {
|
|
105
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
106
|
+
if (!next.types)
|
|
107
|
+
next.types = [];
|
|
108
|
+
if (next.types.some((t) => t.id === typeDef.id)) {
|
|
109
|
+
throw new Error(`Type with id '${typeDef.id}' already exists`);
|
|
110
|
+
}
|
|
111
|
+
next.types.push(typeDef);
|
|
112
|
+
return next;
|
|
113
|
+
}
|
|
114
|
+
function updateType(doc, typeId, patch, options) {
|
|
115
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
116
|
+
if (!next.types) {
|
|
117
|
+
throw new Error("No types are defined on this document");
|
|
118
|
+
}
|
|
119
|
+
const idx = next.types.findIndex((t) => t.id === typeId);
|
|
120
|
+
if (idx === -1) {
|
|
121
|
+
throw new Error(`Type with id '${typeId}' not found`);
|
|
122
|
+
}
|
|
123
|
+
next.types[idx] = {
|
|
124
|
+
...next.types[idx],
|
|
125
|
+
...patch,
|
|
126
|
+
id: next.types[idx].id
|
|
127
|
+
};
|
|
128
|
+
return next;
|
|
129
|
+
}
|
|
130
|
+
function removeType(doc, typeId, options) {
|
|
131
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
132
|
+
if (!next.types) {
|
|
133
|
+
throw new Error("No types are defined on this document");
|
|
134
|
+
}
|
|
135
|
+
const before = next.types.length;
|
|
136
|
+
next.types = next.types.filter((t) => t.id !== typeId);
|
|
137
|
+
if (next.types.length === before) {
|
|
138
|
+
throw new Error(`Type with id '${typeId}' not found`);
|
|
139
|
+
}
|
|
140
|
+
return next;
|
|
141
|
+
}
|
|
142
|
+
// SUBGRAPHS
|
|
143
|
+
function getSubgraph(doc, subgraphId) {
|
|
144
|
+
return (doc.subgraphs ?? []).find((s) => s.id === subgraphId);
|
|
145
|
+
}
|
|
146
|
+
function addSubgraph(doc, subgraph, options) {
|
|
147
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
148
|
+
if (!next.subgraphs)
|
|
149
|
+
next.subgraphs = [];
|
|
150
|
+
if (next.subgraphs.some((s) => s.id === subgraph.id)) {
|
|
151
|
+
throw new Error(`Subgraph with id '${subgraph.id}' already exists`);
|
|
152
|
+
}
|
|
153
|
+
next.subgraphs.push(subgraph);
|
|
154
|
+
return next;
|
|
155
|
+
}
|
|
156
|
+
function updateSubgraph(doc, subgraphId, patch, options) {
|
|
157
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
158
|
+
if (!next.subgraphs) {
|
|
159
|
+
throw new Error("No subgraphs are defined on this document");
|
|
160
|
+
}
|
|
161
|
+
const idx = next.subgraphs.findIndex((s) => s.id === subgraphId);
|
|
162
|
+
if (idx === -1) {
|
|
163
|
+
throw new Error(`Subgraph with id '${subgraphId}' not found`);
|
|
164
|
+
}
|
|
165
|
+
next.subgraphs[idx] = {
|
|
166
|
+
...next.subgraphs[idx],
|
|
167
|
+
...patch,
|
|
168
|
+
id: next.subgraphs[idx].id
|
|
169
|
+
};
|
|
170
|
+
return next;
|
|
171
|
+
}
|
|
172
|
+
function removeSubgraph(doc, subgraphId, options) {
|
|
173
|
+
const next = cloneIfNeeded(doc, options?.mutate);
|
|
174
|
+
if (!next.subgraphs) {
|
|
175
|
+
throw new Error("No subgraphs are defined on this document");
|
|
176
|
+
}
|
|
177
|
+
const before = next.subgraphs.length;
|
|
178
|
+
next.subgraphs = next.subgraphs.filter((s) => s.id !== subgraphId);
|
|
179
|
+
if (next.subgraphs.length === before) {
|
|
180
|
+
throw new Error(`Subgraph with id '${subgraphId}' not found`);
|
|
181
|
+
}
|
|
182
|
+
return next;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=crud.js.map
|
package/dist/crud.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.js","sourceRoot":"","sources":["../src/crud.ts"],"names":[],"mappings":";;AA+BA,0BAEC;AAED,0BAYC;AAED,gCAcC;AAED,gCAmBC;AAID,0BAEC;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MAAM,CAAC,CAAC;IACjD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,aAAa,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-graph.d.ts","sourceRoot":"","sources":["../../src/examples/minimal-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,YAAY,EAAE,aAkG1B,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minimalGraph = void 0;
|
|
4
|
+
exports.minimalGraph = {
|
|
5
|
+
formatVersion: "1.0.0",
|
|
6
|
+
id: "graph:auth/user-signup",
|
|
7
|
+
name: "User Signup",
|
|
8
|
+
graph: {
|
|
9
|
+
nodes: [
|
|
10
|
+
{
|
|
11
|
+
id: "node:validate-input",
|
|
12
|
+
kind: "builtin:validate",
|
|
13
|
+
inputs: [
|
|
14
|
+
{
|
|
15
|
+
id: "in:payload",
|
|
16
|
+
direction: "input",
|
|
17
|
+
type: "builtin:object",
|
|
18
|
+
required: true
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
outputs: [
|
|
22
|
+
{
|
|
23
|
+
id: "out:validated",
|
|
24
|
+
direction: "output",
|
|
25
|
+
type: "builtin:object"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
parameters: {
|
|
29
|
+
schemaType: "type:User"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "node:create-user",
|
|
34
|
+
kind: "task:http-request",
|
|
35
|
+
inputs: [
|
|
36
|
+
{
|
|
37
|
+
id: "in:validated",
|
|
38
|
+
direction: "input",
|
|
39
|
+
type: "type:User",
|
|
40
|
+
required: true
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
outputs: [
|
|
44
|
+
{
|
|
45
|
+
id: "out:user",
|
|
46
|
+
direction: "output",
|
|
47
|
+
type: "type:User"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
parameters: {
|
|
51
|
+
method: "POST",
|
|
52
|
+
url: "https://example.com/users"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
edges: [
|
|
57
|
+
{
|
|
58
|
+
id: "edge:validate-to-create",
|
|
59
|
+
from: {
|
|
60
|
+
nodeId: "node:validate-input",
|
|
61
|
+
portId: "out:validated"
|
|
62
|
+
},
|
|
63
|
+
to: {
|
|
64
|
+
nodeId: "node:create-user",
|
|
65
|
+
portId: "in:validated"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
inputs: [
|
|
70
|
+
{
|
|
71
|
+
id: "graph-input:request",
|
|
72
|
+
name: "Request Body",
|
|
73
|
+
type: "builtin:object",
|
|
74
|
+
target: {
|
|
75
|
+
nodeId: "node:validate-input",
|
|
76
|
+
portId: "in:payload"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
outputs: [
|
|
81
|
+
{
|
|
82
|
+
id: "graph-output:user",
|
|
83
|
+
name: "Created User",
|
|
84
|
+
type: "type:User",
|
|
85
|
+
source: {
|
|
86
|
+
nodeId: "node:create-user",
|
|
87
|
+
portId: "out:user"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
types: [
|
|
93
|
+
{
|
|
94
|
+
id: "type:User",
|
|
95
|
+
kind: "object",
|
|
96
|
+
fields: [
|
|
97
|
+
{ name: "id", type: "builtin:string", required: true },
|
|
98
|
+
{ name: "email", type: "builtin:string", required: true }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=minimal-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-graph.js","sourceRoot":"","sources":["../../src/examples/minimal-graph.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAkB;IACzC,aAAa,EAAE,OAAO;IACtB,EAAE,EAAE,wBAAwB;IAC5B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE;QACL,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,qBAAqB;gBACzB,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,YAAY;wBAChB,SAAS,EAAE,OAAO;wBAClB,IAAI,EAAE,gBAAgB;wBACtB,QAAQ,EAAE,IAAI;qBACf;iBACF;gBACD,OAAO,EAAE;oBACP;wBACE,EAAE,EAAE,eAAe;wBACnB,SAAS,EAAE,QAAQ;wBACnB,IAAI,EAAE,gBAAgB;qBACvB;iBACF;gBACD,UAAU,EAAE;oBACV,UAAU,EAAE,WAAW;iBACxB;aACF;YACD;gBACE,EAAE,EAAE,kBAAkB;gBACtB,IAAI,EAAE,mBAAmB;gBACzB,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,cAAc;wBAClB,SAAS,EAAE,OAAO;wBAClB,IAAI,EAAE,WAAW;wBACjB,QAAQ,EAAE,IAAI;qBACf;iBACF;gBACD,OAAO,EAAE;oBACP;wBACE,EAAE,EAAE,UAAU;wBACd,SAAS,EAAE,QAAQ;wBACnB,IAAI,EAAE,WAAW;qBAClB;iBACF;gBACD,UAAU,EAAE;oBACV,MAAM,EAAE,MAAM;oBACd,GAAG,EAAE,2BAA2B;iBACjC;aACF;SACF;QACD,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,yBAAyB;gBAC7B,IAAI,EAAE;oBACJ,MAAM,EAAE,qBAAqB;oBAC7B,MAAM,EAAE,eAAe;iBACxB;gBACD,EAAE,EAAE;oBACF,MAAM,EAAE,kBAAkB;oBAC1B,MAAM,EAAE,cAAc;iBACvB;aACF;SACF;QACD,MAAM,EAAE;YACN;gBACE,EAAE,EAAE,qBAAqB;gBACzB,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE;oBACN,MAAM,EAAE,qBAAqB;oBAC7B,MAAM,EAAE,YAAY;iBACrB;aACF;SACF;QACD,OAAO,EAAE;YACP;gBACE,EAAE,EAAE,mBAAmB;gBACvB,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE;oBACN,MAAM,EAAE,kBAAkB;oBAC1B,MAAM,EAAE,UAAU;iBACnB;aACF;SACF;KACF;IACD,KAAK,EAAE;QACL;YACE,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACtD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC1D;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-minimal.d.ts","sourceRoot":"","sources":["../../src/examples/validate-minimal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validate_1 = require("../validate");
|
|
4
|
+
const minimal_graph_1 = require("./minimal-graph");
|
|
5
|
+
const result = (0, validate_1.validateGraph)(minimal_graph_1.minimalGraph);
|
|
6
|
+
if (!result.valid) {
|
|
7
|
+
console.error("Minimal graph is INVALID", result.errors);
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
console.log("Minimal graph is valid according to Graphenix format 1.0.0");
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=validate-minimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-minimal.js","sourceRoot":"","sources":["../../src/examples/validate-minimal.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAC5C,mDAA+C;AAE/C,MAAM,MAAM,GAAG,IAAA,wBAAa,EAAC,4BAAY,CAAC,CAAC;AAE3C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./validate"), exports);
|
|
19
|
+
__exportStar(require("./crud"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface PortDefinition {
|
|
2
|
+
id: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
direction: "input" | "output";
|
|
5
|
+
type: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
default?: any | null;
|
|
8
|
+
}
|
|
9
|
+
export interface EdgeEndpoint {
|
|
10
|
+
nodeId: string;
|
|
11
|
+
portId: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Edge {
|
|
14
|
+
id: string;
|
|
15
|
+
from: EdgeEndpoint;
|
|
16
|
+
to: EdgeEndpoint;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
extensions?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface Node {
|
|
21
|
+
id: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
inputs?: PortDefinition[];
|
|
25
|
+
outputs?: PortDefinition[];
|
|
26
|
+
parameters?: Record<string, any>;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
extensions?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface GraphInput {
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
type: string;
|
|
34
|
+
target: EdgeEndpoint;
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
extensions?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface GraphOutput {
|
|
39
|
+
id: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
type: string;
|
|
42
|
+
source: EdgeEndpoint;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
extensions?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
export interface Graph {
|
|
47
|
+
nodes: Node[];
|
|
48
|
+
edges: Edge[];
|
|
49
|
+
inputs: GraphInput[];
|
|
50
|
+
outputs: GraphOutput[];
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
export interface TypeField {
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
required?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface TypeBase {
|
|
59
|
+
id: string;
|
|
60
|
+
kind: "object" | "union" | "alias";
|
|
61
|
+
description?: string;
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
extensions?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export interface TypeObject extends TypeBase {
|
|
66
|
+
kind: "object";
|
|
67
|
+
fields: TypeField[];
|
|
68
|
+
}
|
|
69
|
+
export interface TypeUnion extends TypeBase {
|
|
70
|
+
kind: "union";
|
|
71
|
+
options: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface TypeAlias extends TypeBase {
|
|
74
|
+
kind: "alias";
|
|
75
|
+
target: string;
|
|
76
|
+
}
|
|
77
|
+
export type TypeDefinition = TypeObject | TypeUnion | TypeAlias;
|
|
78
|
+
export interface SubgraphDefinition {
|
|
79
|
+
id: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
graph: Graph;
|
|
82
|
+
metadata?: Record<string, unknown>;
|
|
83
|
+
extensions?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
export interface GraphDocument {
|
|
86
|
+
formatVersion: string;
|
|
87
|
+
id: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
tags?: string[];
|
|
91
|
+
graph: Graph;
|
|
92
|
+
types?: TypeDefinition[];
|
|
93
|
+
subgraphs?: SubgraphDefinition[];
|
|
94
|
+
extensions?: Record<string, unknown>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,YAAY,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;I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E,cAAc,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ValidationError {
|
|
2
|
+
message: string;
|
|
3
|
+
path: string;
|
|
4
|
+
keyword: string;
|
|
5
|
+
params: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface ValidationResult {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
errors: ValidationError[];
|
|
10
|
+
}
|
|
11
|
+
export declare function validateGraph(document: unknown): ValidationResult;
|
|
12
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAkBD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAQjE"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateGraph = validateGraph;
|
|
7
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
+
const graphenix_format_1_0_0_schema_json_1 = __importDefault(require("../schema/graphenix-format-1.0.0.schema.json"));
|
|
9
|
+
const ajv = new ajv_1.default({
|
|
10
|
+
allErrors: true,
|
|
11
|
+
strict: false
|
|
12
|
+
});
|
|
13
|
+
const validateFn = ajv.compile(graphenix_format_1_0_0_schema_json_1.default);
|
|
14
|
+
function normalizeError(error) {
|
|
15
|
+
return {
|
|
16
|
+
message: error.message ?? "Validation error",
|
|
17
|
+
path: error.instancePath || error.schemaPath,
|
|
18
|
+
keyword: error.keyword,
|
|
19
|
+
params: (error.params ?? {})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function validateGraph(document) {
|
|
23
|
+
const valid = validateFn(document);
|
|
24
|
+
if (valid) {
|
|
25
|
+
return { valid: true, errors: [] };
|
|
26
|
+
}
|
|
27
|
+
const errors = (validateFn.errors ?? []).map(normalizeError);
|
|
28
|
+
return { valid: false, errors };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":";;;;;AAgCA,sCAQC;AAxCD,8CAA4C;AAC5C,sHAAkE;AAelE,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC;IAClB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,KAAK;CACd,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAgB,4CAAa,CAAC,CAAC;AAE7D,SAAS,cAAc,CAAC,KAAkB;IACxC,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,kBAAkB;QAC5C,IAAI,EAAE,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,UAAU;QAC5C,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAA4B;KACxD,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAAC,QAAiB;IAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "graphenix-format",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Graphenix graph description format: JSON schema, validation, and CRUD helpers.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
11
|
+
"clean": "rimraf dist",
|
|
12
|
+
"lint": "echo \"no lint configured\"",
|
|
13
|
+
"prepare": "npm run build",
|
|
14
|
+
"test": "node ./dist/examples/validate-minimal.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"schema"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"graph",
|
|
22
|
+
"workflow",
|
|
23
|
+
"json-schema",
|
|
24
|
+
"validation",
|
|
25
|
+
"graphenix"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://example.com/graphenix-format.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://example.com/graphenix-format/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://example.com/graphenix-format#readme",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"ajv": "^8.17.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.10.1",
|
|
40
|
+
"rimraf": "^6.0.1",
|
|
41
|
+
"typescript": "^5.6.3"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://graphenix.dev/schema/graphenix-format-1.0.0.json",
|
|
4
|
+
"title": "Graphenix Format 1.0.0",
|
|
5
|
+
"description": "JSON Schema for the Graphenix graph description format (version 1.0.0). Execution semantics are out of scope.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["formatVersion", "id", "graph"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"formatVersion": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Semantic version of the graphenix-format used by this document (e.g. 1.0.0)."
|
|
13
|
+
},
|
|
14
|
+
"id": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Globally unique identifier for this graph within the system."
|
|
17
|
+
},
|
|
18
|
+
"name": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Human-readable name for the graph."
|
|
21
|
+
},
|
|
22
|
+
"description": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Free-form description of the graph."
|
|
25
|
+
},
|
|
26
|
+
"tags": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"description": "Tags for classification, search, and filtering."
|
|
32
|
+
},
|
|
33
|
+
"graph": {
|
|
34
|
+
"$ref": "#/$defs/Graph"
|
|
35
|
+
},
|
|
36
|
+
"types": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"$ref": "#/$defs/TypeDefinition"
|
|
40
|
+
},
|
|
41
|
+
"description": "Custom logical types referenced by nodes and ports."
|
|
42
|
+
},
|
|
43
|
+
"subgraphs": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": {
|
|
46
|
+
"$ref": "#/$defs/SubgraphDefinition"
|
|
47
|
+
},
|
|
48
|
+
"description": "Inlined reusable graphs."
|
|
49
|
+
},
|
|
50
|
+
"extensions": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"description": "Namespaced extension object. Engines that do not recognize an extension namespace must ignore it.",
|
|
53
|
+
"additionalProperties": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"$defs": {
|
|
57
|
+
"Graph": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["nodes", "edges", "inputs", "outputs"],
|
|
60
|
+
"additionalProperties": false,
|
|
61
|
+
"properties": {
|
|
62
|
+
"nodes": {
|
|
63
|
+
"type": "array",
|
|
64
|
+
"items": {
|
|
65
|
+
"$ref": "#/$defs/Node"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"edges": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": {
|
|
71
|
+
"$ref": "#/$defs/Edge"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"inputs": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": {
|
|
77
|
+
"$ref": "#/$defs/GraphInput"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"outputs": {
|
|
81
|
+
"type": "array",
|
|
82
|
+
"items": {
|
|
83
|
+
"$ref": "#/$defs/GraphOutput"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"metadata": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"description": "Arbitrary metadata not affecting execution semantics.",
|
|
89
|
+
"additionalProperties": true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"Node": {
|
|
94
|
+
"type": "object",
|
|
95
|
+
"required": ["id", "kind"],
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"properties": {
|
|
98
|
+
"id": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"description": "Unique identifier within the containing graph."
|
|
101
|
+
},
|
|
102
|
+
"name": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "Human-readable name for UIs and logs."
|
|
105
|
+
},
|
|
106
|
+
"kind": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "Logical type of node determining how the executor interprets it (e.g. builtin:map, task:http-request, subgraph:graph:user-validation)."
|
|
109
|
+
},
|
|
110
|
+
"inputs": {
|
|
111
|
+
"type": "array",
|
|
112
|
+
"items": {
|
|
113
|
+
"$ref": "#/$defs/PortDefinition"
|
|
114
|
+
},
|
|
115
|
+
"default": []
|
|
116
|
+
},
|
|
117
|
+
"outputs": {
|
|
118
|
+
"type": "array",
|
|
119
|
+
"items": {
|
|
120
|
+
"$ref": "#/$defs/PortDefinition"
|
|
121
|
+
},
|
|
122
|
+
"default": []
|
|
123
|
+
},
|
|
124
|
+
"parameters": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"description": "Static configuration for the node. Interpretation is executor-specific based on kind.",
|
|
127
|
+
"additionalProperties": true,
|
|
128
|
+
"default": {}
|
|
129
|
+
},
|
|
130
|
+
"metadata": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"description": "Arbitrary metadata not affecting execution semantics (e.g. UI position).",
|
|
133
|
+
"additionalProperties": true
|
|
134
|
+
},
|
|
135
|
+
"extensions": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"description": "Namespaced extension data.",
|
|
138
|
+
"additionalProperties": true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"PortDefinition": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"required": ["id", "direction", "type"],
|
|
145
|
+
"additionalProperties": false,
|
|
146
|
+
"properties": {
|
|
147
|
+
"id": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"description": "Unique identifier within the node."
|
|
150
|
+
},
|
|
151
|
+
"name": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"description": "Human-readable label."
|
|
154
|
+
},
|
|
155
|
+
"direction": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"enum": ["input", "output"],
|
|
158
|
+
"description": "Direction of data flow."
|
|
159
|
+
},
|
|
160
|
+
"type": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"description": "Type identifier (built-in type or custom type id)."
|
|
163
|
+
},
|
|
164
|
+
"required": {
|
|
165
|
+
"type": "boolean",
|
|
166
|
+
"description": "Indicates if a value must be present for the node to execute.",
|
|
167
|
+
"default": false
|
|
168
|
+
},
|
|
169
|
+
"default": {
|
|
170
|
+
"description": "Default value when no incoming edge provides one. Must be compatible with the declared type.",
|
|
171
|
+
"type": ["string", "number", "boolean", "array", "object", "null"]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"EdgeEndpoint": {
|
|
176
|
+
"type": "object",
|
|
177
|
+
"required": ["nodeId", "portId"],
|
|
178
|
+
"additionalProperties": false,
|
|
179
|
+
"properties": {
|
|
180
|
+
"nodeId": {
|
|
181
|
+
"type": "string",
|
|
182
|
+
"description": "ID of the node."
|
|
183
|
+
},
|
|
184
|
+
"portId": {
|
|
185
|
+
"type": "string",
|
|
186
|
+
"description": "ID of the port on the referenced node."
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"Edge": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"required": ["id", "from", "to"],
|
|
193
|
+
"additionalProperties": false,
|
|
194
|
+
"properties": {
|
|
195
|
+
"id": {
|
|
196
|
+
"type": "string",
|
|
197
|
+
"description": "Unique identifier within the graph."
|
|
198
|
+
},
|
|
199
|
+
"from": {
|
|
200
|
+
"$ref": "#/$defs/EdgeEndpoint",
|
|
201
|
+
"description": "Source of the edge; must reference an existing node/output port."
|
|
202
|
+
},
|
|
203
|
+
"to": {
|
|
204
|
+
"$ref": "#/$defs/EdgeEndpoint",
|
|
205
|
+
"description": "Target of the edge; must reference an existing node/input port."
|
|
206
|
+
},
|
|
207
|
+
"metadata": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"description": "Metadata not affecting execution (e.g. edge label in UI).",
|
|
210
|
+
"additionalProperties": true
|
|
211
|
+
},
|
|
212
|
+
"extensions": {
|
|
213
|
+
"type": "object",
|
|
214
|
+
"description": "Namespaced extension data.",
|
|
215
|
+
"additionalProperties": true
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"GraphInput": {
|
|
220
|
+
"type": "object",
|
|
221
|
+
"required": ["id", "type", "target"],
|
|
222
|
+
"additionalProperties": false,
|
|
223
|
+
"properties": {
|
|
224
|
+
"id": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"description": "Unique identifier within the graph."
|
|
227
|
+
},
|
|
228
|
+
"name": {
|
|
229
|
+
"type": "string",
|
|
230
|
+
"description": "Human-readable name."
|
|
231
|
+
},
|
|
232
|
+
"type": {
|
|
233
|
+
"type": "string",
|
|
234
|
+
"description": "Logical type identifier for the external input."
|
|
235
|
+
},
|
|
236
|
+
"target": {
|
|
237
|
+
"$ref": "#/$defs/EdgeEndpoint",
|
|
238
|
+
"description": "Node and input port that consume this graph input."
|
|
239
|
+
},
|
|
240
|
+
"metadata": {
|
|
241
|
+
"type": "object",
|
|
242
|
+
"description": "Metadata not affecting execution.",
|
|
243
|
+
"additionalProperties": true
|
|
244
|
+
},
|
|
245
|
+
"extensions": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"description": "Namespaced extension data.",
|
|
248
|
+
"additionalProperties": true
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"GraphOutput": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"required": ["id", "type", "source"],
|
|
255
|
+
"additionalProperties": false,
|
|
256
|
+
"properties": {
|
|
257
|
+
"id": {
|
|
258
|
+
"type": "string",
|
|
259
|
+
"description": "Unique identifier within the graph."
|
|
260
|
+
},
|
|
261
|
+
"name": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"description": "Human-readable name."
|
|
264
|
+
},
|
|
265
|
+
"type": {
|
|
266
|
+
"type": "string",
|
|
267
|
+
"description": "Logical type identifier for the external output."
|
|
268
|
+
},
|
|
269
|
+
"source": {
|
|
270
|
+
"$ref": "#/$defs/EdgeEndpoint",
|
|
271
|
+
"description": "Node and output port that provide this graph output."
|
|
272
|
+
},
|
|
273
|
+
"metadata": {
|
|
274
|
+
"type": "object",
|
|
275
|
+
"description": "Metadata not affecting execution.",
|
|
276
|
+
"additionalProperties": true
|
|
277
|
+
},
|
|
278
|
+
"extensions": {
|
|
279
|
+
"type": "object",
|
|
280
|
+
"description": "Namespaced extension data.",
|
|
281
|
+
"additionalProperties": true
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"TypeField": {
|
|
286
|
+
"type": "object",
|
|
287
|
+
"required": ["name", "type"],
|
|
288
|
+
"additionalProperties": false,
|
|
289
|
+
"properties": {
|
|
290
|
+
"name": {
|
|
291
|
+
"type": "string",
|
|
292
|
+
"description": "Field name."
|
|
293
|
+
},
|
|
294
|
+
"type": {
|
|
295
|
+
"type": "string",
|
|
296
|
+
"description": "Type identifier for the field (built-in or custom)."
|
|
297
|
+
},
|
|
298
|
+
"required": {
|
|
299
|
+
"type": "boolean",
|
|
300
|
+
"description": "Whether this field must be present.",
|
|
301
|
+
"default": false
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"TypeObject": {
|
|
306
|
+
"type": "object",
|
|
307
|
+
"required": ["id", "kind", "fields"],
|
|
308
|
+
"additionalProperties": false,
|
|
309
|
+
"properties": {
|
|
310
|
+
"id": {
|
|
311
|
+
"type": "string",
|
|
312
|
+
"description": "Unique type identifier (e.g. type:User)."
|
|
313
|
+
},
|
|
314
|
+
"kind": {
|
|
315
|
+
"const": "object"
|
|
316
|
+
},
|
|
317
|
+
"description": {
|
|
318
|
+
"type": "string"
|
|
319
|
+
},
|
|
320
|
+
"fields": {
|
|
321
|
+
"type": "array",
|
|
322
|
+
"items": {
|
|
323
|
+
"$ref": "#/$defs/TypeField"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"metadata": {
|
|
327
|
+
"type": "object",
|
|
328
|
+
"additionalProperties": true
|
|
329
|
+
},
|
|
330
|
+
"extensions": {
|
|
331
|
+
"type": "object",
|
|
332
|
+
"additionalProperties": true
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"TypeUnion": {
|
|
337
|
+
"type": "object",
|
|
338
|
+
"required": ["id", "kind", "options"],
|
|
339
|
+
"additionalProperties": false,
|
|
340
|
+
"properties": {
|
|
341
|
+
"id": {
|
|
342
|
+
"type": "string",
|
|
343
|
+
"description": "Unique type identifier."
|
|
344
|
+
},
|
|
345
|
+
"kind": {
|
|
346
|
+
"const": "union"
|
|
347
|
+
},
|
|
348
|
+
"description": {
|
|
349
|
+
"type": "string"
|
|
350
|
+
},
|
|
351
|
+
"options": {
|
|
352
|
+
"type": "array",
|
|
353
|
+
"items": {
|
|
354
|
+
"type": "string"
|
|
355
|
+
},
|
|
356
|
+
"description": "Array of type IDs or built-in types."
|
|
357
|
+
},
|
|
358
|
+
"metadata": {
|
|
359
|
+
"type": "object",
|
|
360
|
+
"additionalProperties": true
|
|
361
|
+
},
|
|
362
|
+
"extensions": {
|
|
363
|
+
"type": "object",
|
|
364
|
+
"additionalProperties": true
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"TypeAlias": {
|
|
369
|
+
"type": "object",
|
|
370
|
+
"required": ["id", "kind", "target"],
|
|
371
|
+
"additionalProperties": false,
|
|
372
|
+
"properties": {
|
|
373
|
+
"id": {
|
|
374
|
+
"type": "string",
|
|
375
|
+
"description": "Unique type identifier."
|
|
376
|
+
},
|
|
377
|
+
"kind": {
|
|
378
|
+
"const": "alias"
|
|
379
|
+
},
|
|
380
|
+
"description": {
|
|
381
|
+
"type": "string"
|
|
382
|
+
},
|
|
383
|
+
"target": {
|
|
384
|
+
"type": "string",
|
|
385
|
+
"description": "Type ID (or built-in) this type refers to."
|
|
386
|
+
},
|
|
387
|
+
"metadata": {
|
|
388
|
+
"type": "object",
|
|
389
|
+
"additionalProperties": true
|
|
390
|
+
},
|
|
391
|
+
"extensions": {
|
|
392
|
+
"type": "object",
|
|
393
|
+
"additionalProperties": true
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
"TypeDefinition": {
|
|
398
|
+
"oneOf": [
|
|
399
|
+
{
|
|
400
|
+
"$ref": "#/$defs/TypeObject"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"$ref": "#/$defs/TypeUnion"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"$ref": "#/$defs/TypeAlias"
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
},
|
|
410
|
+
"SubgraphDefinition": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"required": ["id", "graph"],
|
|
413
|
+
"additionalProperties": false,
|
|
414
|
+
"properties": {
|
|
415
|
+
"id": {
|
|
416
|
+
"type": "string",
|
|
417
|
+
"description": "Unique identifier for the subgraph within the document."
|
|
418
|
+
},
|
|
419
|
+
"name": {
|
|
420
|
+
"type": "string",
|
|
421
|
+
"description": "Human-readable name for the subgraph."
|
|
422
|
+
},
|
|
423
|
+
"graph": {
|
|
424
|
+
"$ref": "#/$defs/Graph"
|
|
425
|
+
},
|
|
426
|
+
"metadata": {
|
|
427
|
+
"type": "object",
|
|
428
|
+
"additionalProperties": true
|
|
429
|
+
},
|
|
430
|
+
"extensions": {
|
|
431
|
+
"type": "object",
|
|
432
|
+
"additionalProperties": true
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|