@x12i/graphenix-core 2.0.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 +252 -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 +109 -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 +114 -0
- package/dist/examples/validate-minimal.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +150 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +21 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +46 -0
- package/dist/validate.js.map +1 -0
- package/dist/validateWorox.d.ts +22 -0
- package/dist/validateWorox.d.ts.map +1 -0
- package/dist/validateWorox.js +90 -0
- package/dist/validateWorox.js.map +1 -0
- package/docs/interop-worox-graph.md +32 -0
- package/package.json +48 -0
- package/schema/graphenix-format-2.0.0.schema.json +348 -0
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# @x12i/graphenix-core
|
|
2
|
+
|
|
3
|
+
Core tier of the Graphenix ecosystem — **Format 2.0.0**.
|
|
4
|
+
|
|
5
|
+
Execution-neutral graph description: JSON schema, TypeScript types, validation, and CRUD helpers. Profile packages build strict subtypes on top of this core via generic metadata, typed parameters, and `validateGraphWithProfile()`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @x12i/graphenix-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Validate a graph document
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
validateGraph,
|
|
18
|
+
GRAPHENIX_FORMAT_VERSION,
|
|
19
|
+
type GraphDocument
|
|
20
|
+
} from "@x12i/graphenix-core";
|
|
21
|
+
|
|
22
|
+
const doc: GraphDocument = {
|
|
23
|
+
formatVersion: GRAPHENIX_FORMAT_VERSION,
|
|
24
|
+
id: "graph:auth/user-signup",
|
|
25
|
+
graph: {
|
|
26
|
+
nodes: [],
|
|
27
|
+
edges: [],
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: []
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const result = validateGraph(doc);
|
|
34
|
+
if (!result.valid) {
|
|
35
|
+
console.error(result.errors);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Each error is a `GraphValidationError`:
|
|
40
|
+
|
|
41
|
+
- **`message`** — human-readable message
|
|
42
|
+
- **`path`** — JSON Pointer to the failing instance
|
|
43
|
+
- **`keyword`** / **`params`** — from AJV when applicable
|
|
44
|
+
- **`source`** — `'graphenix'` or `'profile'`
|
|
45
|
+
- **`code`** — optional profile-specific error code
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Document fields
|
|
50
|
+
|
|
51
|
+
| Field | Required | Description |
|
|
52
|
+
| ----- | -------- | ----------- |
|
|
53
|
+
| `formatVersion` | yes | Must be `"2.0.0"` |
|
|
54
|
+
| `id` | yes | Globally unique graph identifier |
|
|
55
|
+
| `revision` | no | Version of this graph document (not the format version) |
|
|
56
|
+
| `graph` | yes | Structural graph (nodes, edges, inputs, outputs) |
|
|
57
|
+
| `metadata` | no | Document metadata, extensions, summary contracts |
|
|
58
|
+
| `types` | no | Custom type definitions |
|
|
59
|
+
| `subgraphs` | no | Inlined reusable graphs |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Namespaced extensions (`metadata.extensions`)
|
|
64
|
+
|
|
65
|
+
Custom data lives in `metadata.extensions`, keyed by namespace (e.g. `x12i.execution/v1`). Graphenix core validates that `extensions` is an object but does not interpret namespace payloads.
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"graph": {
|
|
70
|
+
"metadata": {
|
|
71
|
+
"extensions": {
|
|
72
|
+
"x12i.execution/v1": {
|
|
73
|
+
"modelConfig": {}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The same convention applies on document, graph, node, edge, input, output, type, and subgraph metadata.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import type { GraphenixMetadata, GraphenixExtensions } from "@x12i/graphenix-core";
|
|
85
|
+
|
|
86
|
+
type X12iGraphMetadata = GraphenixMetadata & {
|
|
87
|
+
extensions: GraphenixExtensions & {
|
|
88
|
+
"x12i.execution/v1": { modelConfig: Record<string, unknown> };
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Execution-specific fields (models, runtime, credentials, studio envelopes, etc.) belong in profile packages via extensions — not in Graphenix core.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Generic types for profile subtypes
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import type { GraphDocument, GraphenixMetadata } from "@x12i/graphenix-core";
|
|
101
|
+
|
|
102
|
+
interface X12iGraphMetadata extends GraphenixMetadata {
|
|
103
|
+
extensions: {
|
|
104
|
+
"x12i.execution/v1": { modelConfig: Record<string, unknown> };
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type X12iNodeParameters = { prompt?: string };
|
|
109
|
+
|
|
110
|
+
type X12iExecutableGraphDocument = GraphDocument<
|
|
111
|
+
GraphenixMetadata,
|
|
112
|
+
X12iGraphMetadata,
|
|
113
|
+
X12iNodeParameters,
|
|
114
|
+
GraphenixMetadata
|
|
115
|
+
>;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Aliases: `GraphNode`, `GraphEdge`, `GraphPort`, `GraphType`, `Subgraph`.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Profile validation
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import {
|
|
126
|
+
validateGraphWithProfile,
|
|
127
|
+
type GraphProfileValidator,
|
|
128
|
+
type GraphValidationError
|
|
129
|
+
} from "@x12i/graphenix-core";
|
|
130
|
+
|
|
131
|
+
const validateX12iProfile: GraphProfileValidator = (doc) => {
|
|
132
|
+
const errors: GraphValidationError[] = [];
|
|
133
|
+
const ext = doc.graph.metadata?.extensions?.["x12i.execution/v1"];
|
|
134
|
+
if (!ext || typeof ext !== "object" || !("modelConfig" in ext)) {
|
|
135
|
+
errors.push({
|
|
136
|
+
source: "profile",
|
|
137
|
+
code: "X12I_MODEL_CONFIG_MISSING",
|
|
138
|
+
message: "Execution profile is missing modelConfig.",
|
|
139
|
+
path: "/graph/metadata/extensions/x12i.execution~1v1/modelConfig"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return { valid: errors.length === 0, errors };
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
validateGraphWithProfile(doc, validateX12iProfile);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Base validation runs first; profile validation runs only when base validation passes.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Input and output contracts
|
|
153
|
+
|
|
154
|
+
**Per-port input contract** — `graph.inputs[].contract`:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"id": "rawRecord",
|
|
159
|
+
"type": "object",
|
|
160
|
+
"target": { "nodeId": "q1", "portId": "record" },
|
|
161
|
+
"contract": {
|
|
162
|
+
"semanticKind": "record",
|
|
163
|
+
"required": true,
|
|
164
|
+
"schema": { "type": "object" }
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Per-port output contract** — `graph.outputs[].contract`:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"id": "graph-output:final",
|
|
174
|
+
"type": "builtin:object",
|
|
175
|
+
"source": { "nodeId": "node:finalizer", "portId": "out:final" },
|
|
176
|
+
"contract": {
|
|
177
|
+
"semanticKind": "final-output",
|
|
178
|
+
"required": true,
|
|
179
|
+
"schema": { "type": "object" }
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Graph-level summary contracts** — complement per-port contracts:
|
|
185
|
+
|
|
186
|
+
| Layer | Purpose |
|
|
187
|
+
| ----- | ------- |
|
|
188
|
+
| `graph.inputs[].contract` | Contract for a specific graph input port |
|
|
189
|
+
| `metadata.graphEntry` | Summary contract for graph invocation |
|
|
190
|
+
| `graph.outputs[].contract` | Contract for a specific graph output port |
|
|
191
|
+
| `metadata.graphResponse` | Summary contract for final graph result |
|
|
192
|
+
|
|
193
|
+
Optional AJV checks against `executionSchema` / `finalOutputSchema`:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import {
|
|
197
|
+
validateExecutionAgainstContract,
|
|
198
|
+
validateFinalOutputAgainstContract
|
|
199
|
+
} from "@x12i/graphenix-core";
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
See [`docs/interop-worox-graph.md`](./docs/interop-worox-graph.md) for worox-graph interop notes.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## CRUD helpers
|
|
207
|
+
|
|
208
|
+
Immutable by default; pass `{ mutate: true }` to modify in place.
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { addNode, updateNode, removeNode, addEdge } from "@x12i/graphenix-core";
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- **Nodes**: `getNode`, `addNode`, `updateNode`, `removeNode`
|
|
215
|
+
- **Edges**: `getEdge`, `addEdge`, `updateEdge`, `removeEdge`
|
|
216
|
+
- **Types**: `getType`, `addType`, `updateType`, `removeType`
|
|
217
|
+
- **Subgraphs**: `getSubgraph`, `addSubgraph`, `updateSubgraph`, `removeSubgraph`
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## JSON Schema
|
|
222
|
+
|
|
223
|
+
Published at `schema/graphenix-format-2.0.0.schema.json` (`$id`: `https://graphenix.dev/schema/graphenix-format-2.0.0.json`).
|
|
224
|
+
|
|
225
|
+
Full field reference: [`GRAPHENIX-FORMAT.md`](./GRAPHENIX-FORMAT.md).
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Development
|
|
230
|
+
|
|
231
|
+
From the monorepo root:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npm install
|
|
235
|
+
npm run build
|
|
236
|
+
npm test
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Or from this package:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npm run build
|
|
243
|
+
npm test
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Notes
|
|
249
|
+
|
|
250
|
+
- **Execution-agnostic** — core defines structure only.
|
|
251
|
+
- Profile packages enforce execution semantics via extensions, typed parameters, and profile validators.
|
|
252
|
+
- Graphenix may **allow** execution-specific data through `metadata.extensions`; core does not interpret or enforce it.
|
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":[],"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,GAAG,SAAS,CAE5B;AAED,wBAAgB,OAAO,CACrB,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAQf;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,aAAa,CAef;AAED,wBAAgB,UAAU,CACxB,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;AAED,0BAYC;AAED,gCAcC;AAED,gCAaC;AAID,0BAKC;AAED,0BAYC;AAED,gCAoBC;AAED,gCAeC;AAID,kCAKC;AAED,kCAYC;AAED,wCAoBC;AAED,wCAeC;AAlPD,SAAS,aAAa,CAAI,KAAQ,EAAE,MAAgB;IAClD,IAAI,MAAM;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,GAAkB;IACrC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC;AACnB,CAAC;AAED,QAAQ;AAER,SAAgB,OAAO,CAAC,GAAkB,EAAE,MAAc;IACxD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;AAC7D,CAAC;AAED,SAAgB,OAAO,CACrB,GAAkB,EAClB,IAAU,EACV,OAAqB;IAErB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC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GAAG,CAAC,GAAG;QACpB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QACtB,GAAG,KAAK;QACR,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;KAC3B,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,cAAc,CAC5B,GAAkB,EAClB,UAAkB,EAClB,OAAqB;IAErB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,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,EAA4B,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAuG1B,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minimalGraph = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
exports.minimalGraph = {
|
|
6
|
+
formatVersion: types_1.GRAPHENIX_FORMAT_VERSION,
|
|
7
|
+
id: "graph:auth/user-signup",
|
|
8
|
+
name: "User Signup",
|
|
9
|
+
graph: {
|
|
10
|
+
nodes: [
|
|
11
|
+
{
|
|
12
|
+
id: "node:validate-input",
|
|
13
|
+
kind: "builtin:validate",
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
id: "in:payload",
|
|
17
|
+
direction: "input",
|
|
18
|
+
type: "builtin:object",
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
outputs: [
|
|
23
|
+
{
|
|
24
|
+
id: "out:validated",
|
|
25
|
+
direction: "output",
|
|
26
|
+
type: "builtin:object"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
parameters: {
|
|
30
|
+
schemaType: "type:User"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "node:create-user",
|
|
35
|
+
kind: "task:http-request",
|
|
36
|
+
inputs: [
|
|
37
|
+
{
|
|
38
|
+
id: "in:validated",
|
|
39
|
+
direction: "input",
|
|
40
|
+
type: "type:User",
|
|
41
|
+
required: true
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
outputs: [
|
|
45
|
+
{
|
|
46
|
+
id: "out:user",
|
|
47
|
+
direction: "output",
|
|
48
|
+
type: "type:User"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
parameters: {
|
|
52
|
+
method: "POST",
|
|
53
|
+
url: "https://example.com/users"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
edges: [
|
|
58
|
+
{
|
|
59
|
+
id: "edge:validate-to-create",
|
|
60
|
+
from: {
|
|
61
|
+
nodeId: "node:validate-input",
|
|
62
|
+
portId: "out:validated"
|
|
63
|
+
},
|
|
64
|
+
to: {
|
|
65
|
+
nodeId: "node:create-user",
|
|
66
|
+
portId: "in:validated"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
inputs: [
|
|
71
|
+
{
|
|
72
|
+
id: "graph-input:request",
|
|
73
|
+
name: "Request Body",
|
|
74
|
+
type: "builtin:object",
|
|
75
|
+
target: {
|
|
76
|
+
nodeId: "node:validate-input",
|
|
77
|
+
portId: "in:payload"
|
|
78
|
+
},
|
|
79
|
+
contract: {
|
|
80
|
+
semanticKind: "record",
|
|
81
|
+
required: true,
|
|
82
|
+
schema: { type: "object" }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
outputs: [
|
|
87
|
+
{
|
|
88
|
+
id: "graph-output:user",
|
|
89
|
+
name: "Created User",
|
|
90
|
+
type: "type:User",
|
|
91
|
+
source: {
|
|
92
|
+
nodeId: "node:create-user",
|
|
93
|
+
portId: "out:user"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
types: [
|
|
99
|
+
{
|
|
100
|
+
id: "type:User",
|
|
101
|
+
kind: "object",
|
|
102
|
+
fields: [
|
|
103
|
+
{ name: "id", type: "builtin:string", required: true },
|
|
104
|
+
{ name: "email", type: "builtin:string", required: true }
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=minimal-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-graph.js","sourceRoot":"","sources":["../../src/examples/minimal-graph.ts"],"names":[],"mappings":";;;AAAA,oCAAwE;AAE3D,QAAA,YAAY,GAAkB;IACzC,aAAa,EAAE,gCAAwB;IACvC,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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,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":""}
|