@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validate_1 = require("../validate");
|
|
4
|
+
const validateWorox_1 = require("../validateWorox");
|
|
5
|
+
const minimal_graph_1 = require("./minimal-graph");
|
|
6
|
+
const result = (0, validate_1.validateGraph)(minimal_graph_1.minimalGraph);
|
|
7
|
+
if (!result.valid) {
|
|
8
|
+
console.error("Minimal graph is INVALID", result.errors);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
console.log("Minimal graph is valid according to Graphenix format 2.0.0");
|
|
13
|
+
}
|
|
14
|
+
const withExtensions = {
|
|
15
|
+
...minimal_graph_1.minimalGraph,
|
|
16
|
+
revision: "1.0.0",
|
|
17
|
+
metadata: {
|
|
18
|
+
extensions: {
|
|
19
|
+
"x12i.execution/v1": {
|
|
20
|
+
modelConfig: {}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
graph: {
|
|
25
|
+
...minimal_graph_1.minimalGraph.graph,
|
|
26
|
+
metadata: {
|
|
27
|
+
extensions: {
|
|
28
|
+
"x12i.execution/v1": {
|
|
29
|
+
modelConfig: {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
outputs: [
|
|
34
|
+
{
|
|
35
|
+
id: "graph-output:user",
|
|
36
|
+
name: "Created User",
|
|
37
|
+
type: "type:User",
|
|
38
|
+
source: {
|
|
39
|
+
nodeId: "node:create-user",
|
|
40
|
+
portId: "out:user"
|
|
41
|
+
},
|
|
42
|
+
contract: {
|
|
43
|
+
semanticKind: "final-output",
|
|
44
|
+
required: true,
|
|
45
|
+
schema: { type: "object" }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const extResult = (0, validate_1.validateGraph)(withExtensions);
|
|
52
|
+
if (!extResult.valid) {
|
|
53
|
+
console.error("Extensions graph is INVALID", extResult.errors);
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
}
|
|
56
|
+
const noopProfile = () => ({ valid: true, errors: [] });
|
|
57
|
+
const profileResult = (0, validate_1.validateGraphWithProfile)(withExtensions, noopProfile);
|
|
58
|
+
if (!profileResult.valid) {
|
|
59
|
+
console.error("Profile validation failed unexpectedly", profileResult.errors);
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
}
|
|
62
|
+
const failingProfile = () => ({
|
|
63
|
+
valid: false,
|
|
64
|
+
errors: [
|
|
65
|
+
{
|
|
66
|
+
source: "profile",
|
|
67
|
+
code: "TEST_ERROR",
|
|
68
|
+
message: "Profile smoke test error",
|
|
69
|
+
path: "/graph/metadata/extensions/x12i.execution~1v1"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
const profileFail = (0, validate_1.validateGraphWithProfile)(withExtensions, failingProfile);
|
|
74
|
+
if (profileFail.valid || profileFail.errors[0]?.source !== "profile") {
|
|
75
|
+
console.error("Profile failure path did not behave as expected", profileFail);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
78
|
+
const withWoroxMetadata = {
|
|
79
|
+
...minimal_graph_1.minimalGraph,
|
|
80
|
+
metadata: {
|
|
81
|
+
graphEntry: {
|
|
82
|
+
summary: "Smoke-test entry contract",
|
|
83
|
+
requiredExecutionPaths: [["node:validate-input"]],
|
|
84
|
+
executionSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: { ok: { type: "boolean" } },
|
|
87
|
+
required: ["ok"]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
graphResponse: {
|
|
91
|
+
summary: "Smoke-test response contract",
|
|
92
|
+
finalOutputSchema: { type: "string", minLength: 1 }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const woroxDoc = (0, validate_1.validateGraph)(withWoroxMetadata);
|
|
97
|
+
if (!woroxDoc.valid) {
|
|
98
|
+
console.error("Worox metadata document is INVALID", woroxDoc.errors);
|
|
99
|
+
process.exitCode = 1;
|
|
100
|
+
}
|
|
101
|
+
const execOk = (0, validateWorox_1.validateExecutionAgainstContract)(withWoroxMetadata, { ok: true });
|
|
102
|
+
const execBad = (0, validateWorox_1.validateExecutionAgainstContract)(withWoroxMetadata, {});
|
|
103
|
+
const outOk = (0, validateWorox_1.validateFinalOutputAgainstContract)(withWoroxMetadata, "done");
|
|
104
|
+
const outBad = (0, validateWorox_1.validateFinalOutputAgainstContract)(withWoroxMetadata, "");
|
|
105
|
+
if (!execOk.valid || execBad.valid || !outOk.valid || outBad.valid) {
|
|
106
|
+
console.error("Worox runtime validation smoke test failed", {
|
|
107
|
+
execOk,
|
|
108
|
+
execBad,
|
|
109
|
+
outOk,
|
|
110
|
+
outBad
|
|
111
|
+
});
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
}
|
|
114
|
+
//# 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,0CAIqB;AACrB,oDAG0B;AAE1B,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;AAED,MAAM,cAAc,GAAkB;IACpC,GAAG,4BAAY;IACf,QAAQ,EAAE,OAAO;IACjB,QAAQ,EAAE;QACR,UAAU,EAAE;YACV,mBAAmB,EAAE;gBACnB,WAAW,EAAE,EAAE;aAChB;SACF;KACF;IACD,KAAK,EAAE;QACL,GAAG,4BAAY,CAAC,KAAK;QACrB,QAAQ,EAAE;YACR,UAAU,EAAE;gBACV,mBAAmB,EAAE;oBACnB,WAAW,EAAE,EAAE;iBAChB;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;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;IACnE,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE;QAC1D,MAAM;QACN,OAAO;QACP,KAAK;QACL,MAAM;KACP,CAAC,CAAC;IACH,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,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,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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("./validateWorox"), exports);
|
|
20
|
+
__exportStar(require("./crud"), exports);
|
|
21
|
+
//# 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,kDAAgC;AAChC,yCAAuB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type ExtensionNamespace = string;
|
|
2
|
+
export interface GraphenixExtensions {
|
|
3
|
+
[namespace: ExtensionNamespace]: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface GraphenixMetadata {
|
|
6
|
+
extensions?: GraphenixExtensions;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface PortDefinition {
|
|
10
|
+
id: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
direction: "input" | "output";
|
|
13
|
+
type: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
default?: any | null;
|
|
16
|
+
}
|
|
17
|
+
export type GraphPort = PortDefinition;
|
|
18
|
+
export interface EdgeEndpoint {
|
|
19
|
+
nodeId: string;
|
|
20
|
+
portId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Edge<TMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
23
|
+
id: string;
|
|
24
|
+
from: EdgeEndpoint;
|
|
25
|
+
to: EdgeEndpoint;
|
|
26
|
+
metadata?: TMetadata;
|
|
27
|
+
}
|
|
28
|
+
export type GraphEdge<TMetadata extends GraphenixMetadata = GraphenixMetadata> = Edge<TMetadata>;
|
|
29
|
+
export interface Node<TParameters = Record<string, unknown>, TMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
30
|
+
id: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
kind: string;
|
|
33
|
+
inputs?: PortDefinition[];
|
|
34
|
+
outputs?: PortDefinition[];
|
|
35
|
+
parameters?: TParameters;
|
|
36
|
+
metadata?: TMetadata;
|
|
37
|
+
}
|
|
38
|
+
export type GraphNode<TParameters = Record<string, unknown>, TMetadata extends GraphenixMetadata = GraphenixMetadata> = Node<TParameters, TMetadata>;
|
|
39
|
+
export type GraphInputSemanticKind = "record" | "query" | "user-input" | "content" | "metadata" | "execution" | (string & {});
|
|
40
|
+
export interface GraphInputResolver {
|
|
41
|
+
kind?: string;
|
|
42
|
+
graphId?: string;
|
|
43
|
+
metadataFilter?: Record<string, unknown>;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface GraphInputContract {
|
|
47
|
+
semanticKind?: GraphInputSemanticKind;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
schema?: JsonSchemaObject;
|
|
50
|
+
resolver?: GraphInputResolver;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
export type GraphOutputSemanticKind = "record" | "content" | "metadata" | "execution" | "final-output" | (string & {});
|
|
54
|
+
export interface GraphOutputContract {
|
|
55
|
+
semanticKind?: GraphOutputSemanticKind;
|
|
56
|
+
required?: boolean;
|
|
57
|
+
schema?: JsonSchemaObject;
|
|
58
|
+
description?: string;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
export interface GraphInput<TMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
62
|
+
id: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
type: string;
|
|
65
|
+
target: EdgeEndpoint;
|
|
66
|
+
contract?: GraphInputContract;
|
|
67
|
+
metadata?: TMetadata;
|
|
68
|
+
}
|
|
69
|
+
export interface GraphOutput<TMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
70
|
+
id: string;
|
|
71
|
+
name?: string;
|
|
72
|
+
type: string;
|
|
73
|
+
source?: EdgeEndpoint;
|
|
74
|
+
contract?: GraphOutputContract;
|
|
75
|
+
metadata?: TMetadata;
|
|
76
|
+
}
|
|
77
|
+
export interface Graph<TGraphMetadata extends GraphenixMetadata = GraphenixMetadata, TNodeParameters = Record<string, unknown>, TNodeMetadata extends GraphenixMetadata = GraphenixMetadata, TEdgeMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
78
|
+
nodes: Node<TNodeParameters, TNodeMetadata>[];
|
|
79
|
+
edges: Edge<TEdgeMetadata>[];
|
|
80
|
+
inputs: GraphInput[];
|
|
81
|
+
outputs: GraphOutput[];
|
|
82
|
+
metadata?: TGraphMetadata;
|
|
83
|
+
}
|
|
84
|
+
export interface TypeField {
|
|
85
|
+
name: string;
|
|
86
|
+
type: string;
|
|
87
|
+
required?: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface TypeBase<TMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
90
|
+
id: string;
|
|
91
|
+
kind: "object" | "union" | "alias";
|
|
92
|
+
description?: string;
|
|
93
|
+
metadata?: TMetadata;
|
|
94
|
+
}
|
|
95
|
+
export interface TypeObject<TMetadata extends GraphenixMetadata = GraphenixMetadata> extends TypeBase<TMetadata> {
|
|
96
|
+
kind: "object";
|
|
97
|
+
fields: TypeField[];
|
|
98
|
+
}
|
|
99
|
+
export interface TypeUnion<TMetadata extends GraphenixMetadata = GraphenixMetadata> extends TypeBase<TMetadata> {
|
|
100
|
+
kind: "union";
|
|
101
|
+
options: string[];
|
|
102
|
+
}
|
|
103
|
+
export interface TypeAlias<TMetadata extends GraphenixMetadata = GraphenixMetadata> extends TypeBase<TMetadata> {
|
|
104
|
+
kind: "alias";
|
|
105
|
+
target: string;
|
|
106
|
+
}
|
|
107
|
+
export type TypeDefinition<TMetadata extends GraphenixMetadata = GraphenixMetadata> = TypeObject<TMetadata> | TypeUnion<TMetadata> | TypeAlias<TMetadata>;
|
|
108
|
+
export type GraphType<TMetadata extends GraphenixMetadata = GraphenixMetadata> = TypeDefinition<TMetadata>;
|
|
109
|
+
export interface SubgraphDefinition<TGraphMetadata extends GraphenixMetadata = GraphenixMetadata, TNodeParameters = Record<string, unknown>, TNodeMetadata extends GraphenixMetadata = GraphenixMetadata, TEdgeMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
110
|
+
id: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
graph: Graph<TGraphMetadata, TNodeParameters, TNodeMetadata, TEdgeMetadata>;
|
|
113
|
+
metadata?: GraphenixMetadata;
|
|
114
|
+
}
|
|
115
|
+
export type Subgraph<TGraphMetadata extends GraphenixMetadata = GraphenixMetadata, TNodeParameters = Record<string, unknown>, TNodeMetadata extends GraphenixMetadata = GraphenixMetadata, TEdgeMetadata extends GraphenixMetadata = GraphenixMetadata> = SubgraphDefinition<TGraphMetadata, TNodeParameters, TNodeMetadata, TEdgeMetadata>;
|
|
116
|
+
export type JsonSchemaObject = Record<string, unknown>;
|
|
117
|
+
export interface GraphEntryContract {
|
|
118
|
+
summary?: string;
|
|
119
|
+
requiredExecutionPaths?: unknown[];
|
|
120
|
+
executionSchema?: JsonSchemaObject;
|
|
121
|
+
notableExecutionPaths?: unknown[];
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
export interface GraphResponseContract {
|
|
125
|
+
summary?: string;
|
|
126
|
+
finalOutputSchema?: JsonSchemaObject;
|
|
127
|
+
[key: string]: unknown;
|
|
128
|
+
}
|
|
129
|
+
export type WoroxCatalogRequest = Record<string, unknown>;
|
|
130
|
+
export type WoroxCatalogBinding = Record<string, unknown>;
|
|
131
|
+
export type WoroxCatalogRequests = WoroxCatalogRequest[] | Record<string, WoroxCatalogRequest>;
|
|
132
|
+
export type GraphDocumentMetadata = GraphenixMetadata & {
|
|
133
|
+
graphEntry?: GraphEntryContract;
|
|
134
|
+
graphResponse?: GraphResponseContract;
|
|
135
|
+
catalogRequests?: WoroxCatalogRequests;
|
|
136
|
+
};
|
|
137
|
+
export interface GraphDocument<TDocumentMetadata extends GraphenixMetadata = GraphenixMetadata, TGraphMetadata extends GraphenixMetadata = GraphenixMetadata, TNodeParameters = Record<string, unknown>, TNodeMetadata extends GraphenixMetadata = GraphenixMetadata, TEdgeMetadata extends GraphenixMetadata = GraphenixMetadata> {
|
|
138
|
+
formatVersion: "2.0.0";
|
|
139
|
+
id: string;
|
|
140
|
+
revision?: string;
|
|
141
|
+
name?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
tags?: string[];
|
|
144
|
+
graph: Graph<TGraphMetadata, TNodeParameters, TNodeMetadata, TEdgeMetadata>;
|
|
145
|
+
types?: TypeDefinition[];
|
|
146
|
+
subgraphs?: SubgraphDefinition<TGraphMetadata, TNodeParameters, TNodeMetadata, TEdgeMetadata>[];
|
|
147
|
+
metadata?: TDocumentMetadata;
|
|
148
|
+
}
|
|
149
|
+
export declare const GRAPHENIX_FORMAT_VERSION: "2.0.0";
|
|
150
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,mBAAmB;IAClC,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,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,MAAM,SAAS,GAAG,cAAc,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI,CAAC,SAAS,SAAS,iBAAiB,GAAG,iBAAiB;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE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
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuQa,QAAA,wBAAwB,GAAG,OAAgB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GraphDocument } from "./types";
|
|
2
|
+
export interface GraphValidationError {
|
|
3
|
+
message: string;
|
|
4
|
+
path: string;
|
|
5
|
+
keyword?: string;
|
|
6
|
+
params?: Record<string, unknown>;
|
|
7
|
+
code?: string;
|
|
8
|
+
source?: "graphenix" | "profile";
|
|
9
|
+
}
|
|
10
|
+
export interface ValidationResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
errors: GraphValidationError[];
|
|
13
|
+
}
|
|
14
|
+
export interface GraphProfileValidationResult {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors: GraphValidationError[];
|
|
17
|
+
}
|
|
18
|
+
export type GraphProfileValidator<TDoc extends GraphDocument = GraphDocument> = (doc: TDoc) => GraphProfileValidationResult;
|
|
19
|
+
export declare function validateGraph(document: unknown): ValidationResult;
|
|
20
|
+
export declare function validateGraphWithProfile<TDoc extends GraphDocument>(doc: unknown, profileValidator: GraphProfileValidator<TDoc>): GraphProfileValidationResult;
|
|
21
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa,IAC1E,CAAC,GAAG,EAAE,IAAI,KAAK,4BAA4B,CAAC;AAmB9C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAQjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,SAAS,aAAa,EACjE,GAAG,EAAE,OAAO,EACZ,gBAAgB,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAC5C,4BAA4B,CAc9B"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
exports.validateGraphWithProfile = validateGraphWithProfile;
|
|
8
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
9
|
+
const graphenix_format_2_0_0_schema_json_1 = __importDefault(require("../schema/graphenix-format-2.0.0.schema.json"));
|
|
10
|
+
const ajv = new ajv_1.default({
|
|
11
|
+
allErrors: true,
|
|
12
|
+
strict: false
|
|
13
|
+
});
|
|
14
|
+
const validateFn = ajv.compile(graphenix_format_2_0_0_schema_json_1.default);
|
|
15
|
+
function normalizeError(error) {
|
|
16
|
+
return {
|
|
17
|
+
message: error.message ?? "Validation error",
|
|
18
|
+
path: error.instancePath || error.schemaPath,
|
|
19
|
+
keyword: error.keyword,
|
|
20
|
+
params: (error.params ?? {}),
|
|
21
|
+
source: "graphenix"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function validateGraph(document) {
|
|
25
|
+
const valid = validateFn(document);
|
|
26
|
+
if (valid) {
|
|
27
|
+
return { valid: true, errors: [] };
|
|
28
|
+
}
|
|
29
|
+
const errors = (validateFn.errors ?? []).map(normalizeError);
|
|
30
|
+
return { valid: false, errors };
|
|
31
|
+
}
|
|
32
|
+
function validateGraphWithProfile(doc, profileValidator) {
|
|
33
|
+
const baseResult = validateGraph(doc);
|
|
34
|
+
if (!baseResult.valid) {
|
|
35
|
+
return baseResult;
|
|
36
|
+
}
|
|
37
|
+
const profileResult = profileValidator(doc);
|
|
38
|
+
return {
|
|
39
|
+
valid: profileResult.valid,
|
|
40
|
+
errors: profileResult.errors.map((error) => ({
|
|
41
|
+
...error,
|
|
42
|
+
source: error.source ?? "profile"
|
|
43
|
+
}))
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":";;;;;AA2CA,sCAQC;AAED,4DAiBC;AAtED,8CAA4C;AAC5C,sHAAkE;AAyBlE,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,4CAAgB,CAAC,CAAC;AAEhE,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;QACvD,MAAM,EAAE,WAAW;KACpB,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;AAED,SAAgB,wBAAwB,CACtC,GAAY,EACZ,gBAA6C;IAE7C,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,GAAW,CAAC,CAAC;IACpD,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC3C,GAAG,KAAK;YACR,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS;SAClC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Ajv from "ajv";
|
|
2
|
+
import type { GraphDocument, GraphDocumentMetadata } from "./types";
|
|
3
|
+
import type { ValidationResult } from "./validate";
|
|
4
|
+
export interface WoroxRuntimeValidationOptions {
|
|
5
|
+
/**
|
|
6
|
+
* AJV instance used to compile `executionSchema` / `finalOutputSchema`.
|
|
7
|
+
* When omitted, a shared default instance (`strict: false`, `allErrors: true`) is used.
|
|
8
|
+
*/
|
|
9
|
+
ajv?: Ajv;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validates `execution` against `document.metadata.graphEntry.executionSchema` when present.
|
|
13
|
+
* If there is no schema, or `graphEntry` is missing, returns `{ valid: true, errors: [] }`.
|
|
14
|
+
* This is optional tooling; graphenix planning does not require it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateExecutionAgainstContract(document: GraphDocument<GraphDocumentMetadata>, execution: unknown, options?: WoroxRuntimeValidationOptions): ValidationResult;
|
|
17
|
+
/**
|
|
18
|
+
* Validates `finalOutput` against `document.metadata.graphResponse.finalOutputSchema` when present.
|
|
19
|
+
* If there is no schema, or `graphResponse` is missing, returns `{ valid: true, errors: [] }`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateFinalOutputAgainstContract(document: GraphDocument<GraphDocumentMetadata>, finalOutput: unknown, options?: WoroxRuntimeValidationOptions): ValidationResult;
|
|
22
|
+
//# sourceMappingURL=validateWorox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateWorox.d.ts","sourceRoot":"","sources":["../src/validateWorox.ts"],"names":[],"mappings":"AAAA,OAAO,GAAgD,MAAM,KAAK,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAyBzE,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,EAC9C,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAwBlB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,EAC9C,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAwBlB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.validateExecutionAgainstContract = validateExecutionAgainstContract;
|
|
7
|
+
exports.validateFinalOutputAgainstContract = validateFinalOutputAgainstContract;
|
|
8
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
9
|
+
const defaultAjv = new ajv_1.default({
|
|
10
|
+
allErrors: true,
|
|
11
|
+
strict: false
|
|
12
|
+
});
|
|
13
|
+
function normalizeError(error) {
|
|
14
|
+
return {
|
|
15
|
+
message: error.message ?? "Validation error",
|
|
16
|
+
path: error.instancePath || error.schemaPath,
|
|
17
|
+
keyword: error.keyword,
|
|
18
|
+
params: (error.params ?? {})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function runCompiled(validate, data) {
|
|
22
|
+
const valid = validate(data);
|
|
23
|
+
if (valid) {
|
|
24
|
+
return { valid: true, errors: [] };
|
|
25
|
+
}
|
|
26
|
+
const errors = (validate.errors ?? []).map(normalizeError);
|
|
27
|
+
return { valid: false, errors };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validates `execution` against `document.metadata.graphEntry.executionSchema` when present.
|
|
31
|
+
* If there is no schema, or `graphEntry` is missing, returns `{ valid: true, errors: [] }`.
|
|
32
|
+
* This is optional tooling; graphenix planning does not require it.
|
|
33
|
+
*/
|
|
34
|
+
function validateExecutionAgainstContract(document, execution, options) {
|
|
35
|
+
const schema = document.metadata?.graphEntry?.executionSchema;
|
|
36
|
+
if (schema === undefined || schema === null || typeof schema !== "object") {
|
|
37
|
+
return { valid: true, errors: [] };
|
|
38
|
+
}
|
|
39
|
+
const ajv = options?.ajv ?? defaultAjv;
|
|
40
|
+
let validate;
|
|
41
|
+
try {
|
|
42
|
+
validate = ajv.compile(schema);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
46
|
+
return {
|
|
47
|
+
valid: false,
|
|
48
|
+
errors: [
|
|
49
|
+
{
|
|
50
|
+
message: `Invalid executionSchema: ${message}`,
|
|
51
|
+
path: "/metadata/graphEntry/executionSchema",
|
|
52
|
+
keyword: "compile",
|
|
53
|
+
params: {}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return runCompiled(validate, execution);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates `finalOutput` against `document.metadata.graphResponse.finalOutputSchema` when present.
|
|
62
|
+
* If there is no schema, or `graphResponse` is missing, returns `{ valid: true, errors: [] }`.
|
|
63
|
+
*/
|
|
64
|
+
function validateFinalOutputAgainstContract(document, finalOutput, options) {
|
|
65
|
+
const schema = document.metadata?.graphResponse?.finalOutputSchema;
|
|
66
|
+
if (schema === undefined || schema === null || typeof schema !== "object") {
|
|
67
|
+
return { valid: true, errors: [] };
|
|
68
|
+
}
|
|
69
|
+
const ajv = options?.ajv ?? defaultAjv;
|
|
70
|
+
let validate;
|
|
71
|
+
try {
|
|
72
|
+
validate = ajv.compile(schema);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
76
|
+
return {
|
|
77
|
+
valid: false,
|
|
78
|
+
errors: [
|
|
79
|
+
{
|
|
80
|
+
message: `Invalid finalOutputSchema: ${message}`,
|
|
81
|
+
path: "/metadata/graphResponse/finalOutputSchema",
|
|
82
|
+
keyword: "compile",
|
|
83
|
+
params: {}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return runCompiled(validate, finalOutput);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=validateWorox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3D,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN;oBACE,OAAO,EAAE,8BAA8B,OAAO,EAAE;oBAChD,IAAI,EAAE,2CAA2C;oBACjD,OAAO,EAAE,SAAS;oBAClB,MAAM,EAAE,EAAE;iBACX;aACF;SACF,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Interop: worox-graph JSON and Graphenix `Graph`
|
|
2
|
+
|
|
3
|
+
How **worox-graph** graph JSON relates to the port-based `Graph` type in `@x12i/graphenix-core`.
|
|
4
|
+
|
|
5
|
+
## Two representations
|
|
6
|
+
|
|
7
|
+
| Area | worox-graph | Graphenix core `Graph` |
|
|
8
|
+
|------|-------------|------------------------|
|
|
9
|
+
| Topology | Task nodes, edges, `outputMapping`, finalizers | Nodes, edges, **ports**, `GraphInput` / `GraphOutput` |
|
|
10
|
+
| Execution shape | Engine-specific (tasks, DAG scheduling) | **Execution-agnostic** static description |
|
|
11
|
+
| I/O contracts | Often embedded in graph JSON and tooling | **Optional** `metadata.graphEntry` / `metadata.graphResponse` on the **document** |
|
|
12
|
+
| Planning (catalog) | Optional `metadata.catalogRequests`; per task node `metadata.catalogRequest` / `metadata.catalogBinding` | Same optional keys on **`GraphDocument.metadata`** and **node `metadata`** (execution unchanged) |
|
|
13
|
+
|
|
14
|
+
worox-graph focuses on runnable task graphs and visibility into execution paths. Graphenix describes a **static** graph layout (ports, graph-level inputs/outputs) without prescribing how the runtime schedules tasks.
|
|
15
|
+
|
|
16
|
+
Planning-only catalog fields do not alter execution. Graphenix exposes matching optional JSON Schema `$defs` for tooling that wants a single validator story.
|
|
17
|
+
|
|
18
|
+
## Where worox-graph JSON lives
|
|
19
|
+
|
|
20
|
+
- **Canonical for core:** optional **`GraphDocument.metadata.graphEntry`** and **`GraphDocument.metadata.graphResponse`**. These match worox contracts used when values are copied to `variables.__graphModel`.
|
|
21
|
+
- **Namespaced extensions:** worox-only payloads may also live under `metadata.extensions` when a profile namespace owns them.
|
|
22
|
+
|
|
23
|
+
Graphenix core does not change execution model: the `Graph` remains port-based.
|
|
24
|
+
|
|
25
|
+
## DAG nodes vs ports: is there a converter?
|
|
26
|
+
|
|
27
|
+
**Not in `@x12i/graphenix-core` today.** A future optional converter could map worox task nodes ↔ port graphs. Until such a tool exists, treat worox graph JSON and Graphenix `Graph` as related **documentation and planning** layers, not automatic transforms.
|
|
28
|
+
|
|
29
|
+
## See also
|
|
30
|
+
|
|
31
|
+
- [`../README.md`](../README.md) — graph-level summary contracts (I/O layers 01 / 08).
|
|
32
|
+
- `schema/graphenix-format-2.0.0.schema.json` — `$defs/GraphEntryContract`, `$defs/GraphResponseContract`, and optional worox planning `$defs`.
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x12i/graphenix-core",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Graphenix core tier: format 2.0.0 JSON schema, validation, and CRUD helpers.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"lint": "echo \"no lint configured\"",
|
|
12
|
+
"prepare": "npm run build",
|
|
13
|
+
"test": "node ./dist/examples/validate-minimal.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"schema",
|
|
18
|
+
"docs"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"graph",
|
|
22
|
+
"workflow",
|
|
23
|
+
"json-schema",
|
|
24
|
+
"validation",
|
|
25
|
+
"graphenix"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/x12i/graphenix-format.git",
|
|
30
|
+
"directory": "packages/core"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/x12i/graphenix-format/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/x12i/graphenix-format/tree/master/packages/core#readme",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"ajv": "^8.17.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.10.1",
|
|
45
|
+
"rimraf": "^6.0.1",
|
|
46
|
+
"typescript": "^5.6.3"
|
|
47
|
+
}
|
|
48
|
+
}
|