@prisma/param-graph 7.4.0-integration-parameterization.5 → 7.4.0-integration-parameterization.7
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/dist/index.d.ts +6 -1
- package/dist/index.js +14 -6
- package/dist/index.mjs +6 -1
- package/dist/param-graph.d.ts +76 -91
- package/dist/param-graph.js +134 -2
- package/dist/param-graph.mjs +133 -2
- package/dist/serialization.d.ts +25 -0
- package/dist/serialization.js +353 -0
- package/dist/serialization.mjs +328 -0
- package/dist/serialization.test.d.ts +1 -0
- package/dist/serialization.test.js +86 -0
- package/dist/serialization.test.mjs +85 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +16 -0
- package/dist/types.mjs +0 -0
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { ParamGraph } from './param-graph';
|
|
2
|
+
export type { EnumLookup, InputEdge, InputNode, OutputEdge, OutputNode, RootEntry } from './param-graph';
|
|
3
|
+
export type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData, } from './param-graph';
|
|
2
4
|
export { EdgeFlag, getScalarMask, hasFlag, ScalarMask, scalarTypeToMask } from './param-graph';
|
|
5
|
+
export type { EdgeFlagValue, ScalarMaskValue } from './param-graph';
|
|
6
|
+
export { deserializeParamGraph, serializeParamGraph } from './serialization';
|
|
7
|
+
export type { SerializedParamGraph } from './serialization';
|
package/dist/index.js
CHANGED
|
@@ -18,19 +18,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var index_exports = {};
|
|
20
20
|
__export(index_exports, {
|
|
21
|
-
EdgeFlag: () =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
EdgeFlag: () => import_param_graph2.EdgeFlag,
|
|
22
|
+
ParamGraph: () => import_param_graph.ParamGraph,
|
|
23
|
+
ScalarMask: () => import_param_graph2.ScalarMask,
|
|
24
|
+
deserializeParamGraph: () => import_serialization.deserializeParamGraph,
|
|
25
|
+
getScalarMask: () => import_param_graph2.getScalarMask,
|
|
26
|
+
hasFlag: () => import_param_graph2.hasFlag,
|
|
27
|
+
scalarTypeToMask: () => import_param_graph2.scalarTypeToMask,
|
|
28
|
+
serializeParamGraph: () => import_serialization.serializeParamGraph
|
|
26
29
|
});
|
|
27
30
|
module.exports = __toCommonJS(index_exports);
|
|
28
31
|
var import_param_graph = require("./param-graph");
|
|
32
|
+
var import_param_graph2 = require("./param-graph");
|
|
33
|
+
var import_serialization = require("./serialization");
|
|
29
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
35
|
0 && (module.exports = {
|
|
31
36
|
EdgeFlag,
|
|
37
|
+
ParamGraph,
|
|
32
38
|
ScalarMask,
|
|
39
|
+
deserializeParamGraph,
|
|
33
40
|
getScalarMask,
|
|
34
41
|
hasFlag,
|
|
35
|
-
scalarTypeToMask
|
|
42
|
+
scalarTypeToMask,
|
|
43
|
+
serializeParamGraph
|
|
36
44
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { ParamGraph } from "./param-graph";
|
|
1
2
|
import { EdgeFlag, getScalarMask, hasFlag, ScalarMask, scalarTypeToMask } from "./param-graph";
|
|
3
|
+
import { deserializeParamGraph, serializeParamGraph } from "./serialization";
|
|
2
4
|
export {
|
|
3
5
|
EdgeFlag,
|
|
6
|
+
ParamGraph,
|
|
4
7
|
ScalarMask,
|
|
8
|
+
deserializeParamGraph,
|
|
5
9
|
getScalarMask,
|
|
6
10
|
hasFlag,
|
|
7
|
-
scalarTypeToMask
|
|
11
|
+
scalarTypeToMask,
|
|
12
|
+
serializeParamGraph
|
|
8
13
|
};
|
package/dist/param-graph.d.ts
CHANGED
|
@@ -1,117 +1,101 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ParamGraph:
|
|
2
|
+
* ParamGraph: Runtime class for schema-aware parameterization.
|
|
3
3
|
*
|
|
4
|
-
* This
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* rules and runtime value types agree.
|
|
4
|
+
* This class provides a readable API for navigating the param graph structure
|
|
5
|
+
* at runtime. It's created once per PrismaClient instance from the serialized
|
|
6
|
+
* format embedded in the generated client.
|
|
8
7
|
*/
|
|
8
|
+
import type { SerializedParamGraph } from './serialization';
|
|
9
|
+
import type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData } from './types';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Function type for looking up enum values by name.
|
|
12
|
+
* This allows ParamGraph to remain decoupled from RuntimeDataModel.
|
|
11
13
|
*/
|
|
12
|
-
export type
|
|
13
|
-
/**
|
|
14
|
-
* String table to avoid repeating field names.
|
|
15
|
-
* Field names are referenced by index throughout the graph.
|
|
16
|
-
*/
|
|
17
|
-
s: string[];
|
|
18
|
-
/**
|
|
19
|
-
* User enum names for runtime membership checks.
|
|
20
|
-
* Values are looked up via `runtimeDataModel.enums[enumName].values`.
|
|
21
|
-
*/
|
|
22
|
-
e: string[];
|
|
23
|
-
/**
|
|
24
|
-
* Input nodes used for argument objects and input types.
|
|
25
|
-
* Each node describes which fields are parameterizable or lead to
|
|
26
|
-
* parameterizable descendants.
|
|
27
|
-
*/
|
|
28
|
-
i: InputNode[];
|
|
29
|
-
/**
|
|
30
|
-
* Output nodes used for selection traversal.
|
|
31
|
-
* Each node describes which fields have arguments or lead to
|
|
32
|
-
* nested selections with arguments.
|
|
33
|
-
*/
|
|
34
|
-
o: OutputNode[];
|
|
35
|
-
/**
|
|
36
|
-
* Root mapping: "Model.action" or "action" (for non-model ops).
|
|
37
|
-
* Points to the args node (input) and root output node.
|
|
38
|
-
*/
|
|
39
|
-
r: Record<string, RootEntry>;
|
|
40
|
-
};
|
|
14
|
+
export type EnumLookup = (enumName: string) => readonly string[] | undefined;
|
|
41
15
|
/**
|
|
42
|
-
*
|
|
16
|
+
* Readable view of root entry.
|
|
43
17
|
*/
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
o?: NodeId;
|
|
49
|
-
};
|
|
18
|
+
export interface RootEntry {
|
|
19
|
+
readonly argsNodeId: number | undefined;
|
|
20
|
+
readonly outputNodeId: number | undefined;
|
|
21
|
+
}
|
|
50
22
|
/**
|
|
51
|
-
*
|
|
23
|
+
* Readable view of input node.
|
|
52
24
|
*/
|
|
53
|
-
export
|
|
25
|
+
export interface InputNode {
|
|
26
|
+
readonly id: number;
|
|
27
|
+
}
|
|
54
28
|
/**
|
|
55
|
-
*
|
|
56
|
-
* Only fields that are parameterizable or lead to parameterizable
|
|
57
|
-
* descendants are present.
|
|
29
|
+
* Readable view of output node.
|
|
58
30
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* Omitted if the node has no fields (shouldn't happen in practice).
|
|
63
|
-
*/
|
|
64
|
-
f?: Record<number, InputEdge>;
|
|
65
|
-
};
|
|
31
|
+
export interface OutputNode {
|
|
32
|
+
readonly id: number;
|
|
33
|
+
}
|
|
66
34
|
/**
|
|
67
|
-
*
|
|
68
|
-
* or nested selections that may contain parameterizable args.
|
|
35
|
+
* Readable view of input edge.
|
|
69
36
|
*/
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
37
|
+
export interface InputEdge {
|
|
38
|
+
readonly flags: number;
|
|
39
|
+
readonly childNodeId: number | undefined;
|
|
40
|
+
readonly scalarMask: number;
|
|
41
|
+
readonly enumNameIndex: number | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Readable view of output edge.
|
|
45
|
+
*/
|
|
46
|
+
export interface OutputEdge {
|
|
47
|
+
readonly argsNodeId: number | undefined;
|
|
48
|
+
readonly outputNodeId: number | undefined;
|
|
49
|
+
}
|
|
76
50
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
51
|
+
* ParamGraph provides runtime access to the schema information
|
|
52
|
+
* needed for parameterization decisions.
|
|
79
53
|
*/
|
|
80
|
-
export
|
|
54
|
+
export declare class ParamGraph {
|
|
55
|
+
#private;
|
|
56
|
+
private constructor();
|
|
81
57
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
58
|
+
* Creates a ParamGraph from serialized format.
|
|
59
|
+
* This is the primary factory method for runtime use.
|
|
84
60
|
*/
|
|
85
|
-
|
|
61
|
+
static deserialize(serialized: SerializedParamGraph, enumLookup: EnumLookup): ParamGraph;
|
|
86
62
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
63
|
+
* Creates a ParamGraph from builder data.
|
|
64
|
+
* Used by the builder for testing and direct construction.
|
|
89
65
|
*/
|
|
90
|
-
|
|
66
|
+
static fromData(data: ParamGraphData, enumLookup: EnumLookup): ParamGraph;
|
|
91
67
|
/**
|
|
92
|
-
*
|
|
93
|
-
* Present when field accepts scalar values.
|
|
94
|
-
* See ScalarMask enum below.
|
|
68
|
+
* Look up a root entry by "Model.action" or "action".
|
|
95
69
|
*/
|
|
96
|
-
|
|
70
|
+
root(key: string): RootEntry | undefined;
|
|
97
71
|
/**
|
|
98
|
-
*
|
|
99
|
-
* Present when field accepts a user enum without a plain String scalar.
|
|
100
|
-
* Used for runtime membership validation.
|
|
72
|
+
* Get an input node by ID.
|
|
101
73
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
74
|
+
inputNode(id: number | undefined): InputNode | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Get an output node by ID.
|
|
77
|
+
*/
|
|
78
|
+
outputNode(id: number | undefined): OutputNode | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Get an input edge for a field name within a node.
|
|
81
|
+
*/
|
|
82
|
+
inputEdge(node: InputNode | undefined, fieldName: string): InputEdge | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get an output edge for a field name within a node.
|
|
85
|
+
*/
|
|
86
|
+
outputEdge(node: OutputNode | undefined, fieldName: string): OutputEdge | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Get enum values for an edge that references a user enum.
|
|
89
|
+
* Returns undefined if the edge doesn't reference an enum.
|
|
90
|
+
*/
|
|
91
|
+
enumValues(edge: InputEdge | undefined): readonly string[] | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Get a string from the string table by index.
|
|
94
|
+
*/
|
|
95
|
+
getString(index: number): string | undefined;
|
|
96
|
+
}
|
|
113
97
|
/**
|
|
114
|
-
* Bit flags for InputEdge.
|
|
98
|
+
* Bit flags for InputEdge.flags describing what the field accepts.
|
|
115
99
|
*/
|
|
116
100
|
export declare const EdgeFlag: {
|
|
117
101
|
/**
|
|
@@ -148,7 +132,7 @@ export declare const EdgeFlag: {
|
|
|
148
132
|
export type EdgeFlagValue = (typeof EdgeFlag)[keyof typeof EdgeFlag];
|
|
149
133
|
/**
|
|
150
134
|
* Bit mask for scalar type categories.
|
|
151
|
-
* Used in InputEdge.
|
|
135
|
+
* Used in InputEdge.scalarMask to validate runtime value types.
|
|
152
136
|
*/
|
|
153
137
|
export declare const ScalarMask: {
|
|
154
138
|
readonly String: 1;
|
|
@@ -174,3 +158,4 @@ export declare function getScalarMask(edge: InputEdge): number;
|
|
|
174
158
|
* Maps DMMF scalar type names to ScalarMask values.
|
|
175
159
|
*/
|
|
176
160
|
export declare function scalarTypeToMask(typeName: string): number;
|
|
161
|
+
export type { InputEdgeData, InputNodeData, OutputEdgeData, OutputNodeData, ParamGraphData, RootEntryData };
|
package/dist/param-graph.js
CHANGED
|
@@ -19,12 +19,143 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var param_graph_exports = {};
|
|
20
20
|
__export(param_graph_exports, {
|
|
21
21
|
EdgeFlag: () => EdgeFlag,
|
|
22
|
+
ParamGraph: () => ParamGraph,
|
|
22
23
|
ScalarMask: () => ScalarMask,
|
|
23
24
|
getScalarMask: () => getScalarMask,
|
|
24
25
|
hasFlag: () => hasFlag,
|
|
25
26
|
scalarTypeToMask: () => scalarTypeToMask
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(param_graph_exports);
|
|
29
|
+
var import_serialization = require("./serialization");
|
|
30
|
+
class ParamGraph {
|
|
31
|
+
#data;
|
|
32
|
+
#stringIndex;
|
|
33
|
+
#enumLookup;
|
|
34
|
+
constructor(data, enumLookup) {
|
|
35
|
+
this.#data = data;
|
|
36
|
+
this.#enumLookup = enumLookup;
|
|
37
|
+
this.#stringIndex = /* @__PURE__ */ new Map();
|
|
38
|
+
for (let i = 0; i < data.strings.length; i++) {
|
|
39
|
+
this.#stringIndex.set(data.strings[i], i);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a ParamGraph from serialized format.
|
|
44
|
+
* This is the primary factory method for runtime use.
|
|
45
|
+
*/
|
|
46
|
+
static deserialize(serialized, enumLookup) {
|
|
47
|
+
const data = (0, import_serialization.deserializeParamGraph)(serialized);
|
|
48
|
+
return new ParamGraph(data, enumLookup);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a ParamGraph from builder data.
|
|
52
|
+
* Used by the builder for testing and direct construction.
|
|
53
|
+
*/
|
|
54
|
+
static fromData(data, enumLookup) {
|
|
55
|
+
return new ParamGraph(data, enumLookup);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Look up a root entry by "Model.action" or "action".
|
|
59
|
+
*/
|
|
60
|
+
root(key) {
|
|
61
|
+
const entry = this.#data.roots[key];
|
|
62
|
+
if (!entry) {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
argsNodeId: entry.argsNodeId,
|
|
67
|
+
outputNodeId: entry.outputNodeId
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get an input node by ID.
|
|
72
|
+
*/
|
|
73
|
+
inputNode(id) {
|
|
74
|
+
if (id === void 0 || id < 0 || id >= this.#data.inputNodes.length) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
return { id };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get an output node by ID.
|
|
81
|
+
*/
|
|
82
|
+
outputNode(id) {
|
|
83
|
+
if (id === void 0 || id < 0 || id >= this.#data.outputNodes.length) {
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
return { id };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get an input edge for a field name within a node.
|
|
90
|
+
*/
|
|
91
|
+
inputEdge(node, fieldName) {
|
|
92
|
+
if (!node) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
const nodeData = this.#data.inputNodes[node.id];
|
|
96
|
+
if (!nodeData) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
const fieldIndex = this.#stringIndex.get(fieldName);
|
|
100
|
+
if (fieldIndex === void 0) {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
const edge = nodeData.edges[fieldIndex];
|
|
104
|
+
if (!edge) {
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
flags: edge.flags,
|
|
109
|
+
childNodeId: edge.childNodeId,
|
|
110
|
+
scalarMask: edge.scalarMask ?? 0,
|
|
111
|
+
enumNameIndex: edge.enumNameIndex
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get an output edge for a field name within a node.
|
|
116
|
+
*/
|
|
117
|
+
outputEdge(node, fieldName) {
|
|
118
|
+
if (!node) {
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
const nodeData = this.#data.outputNodes[node.id];
|
|
122
|
+
if (!nodeData) {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
const fieldIndex = this.#stringIndex.get(fieldName);
|
|
126
|
+
if (fieldIndex === void 0) {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
const edge = nodeData.edges[fieldIndex];
|
|
130
|
+
if (!edge) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
argsNodeId: edge.argsNodeId,
|
|
135
|
+
outputNodeId: edge.outputNodeId
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get enum values for an edge that references a user enum.
|
|
140
|
+
* Returns undefined if the edge doesn't reference an enum.
|
|
141
|
+
*/
|
|
142
|
+
enumValues(edge) {
|
|
143
|
+
if (edge?.enumNameIndex === void 0) {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
const enumName = this.#data.strings[edge.enumNameIndex];
|
|
147
|
+
if (!enumName) {
|
|
148
|
+
return void 0;
|
|
149
|
+
}
|
|
150
|
+
return this.#enumLookup(enumName);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get a string from the string table by index.
|
|
154
|
+
*/
|
|
155
|
+
getString(index) {
|
|
156
|
+
return this.#data.strings[index];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
28
159
|
const EdgeFlag = {
|
|
29
160
|
/**
|
|
30
161
|
* Field may be parameterized as a scalar value.
|
|
@@ -69,10 +200,10 @@ const ScalarMask = {
|
|
|
69
200
|
Bytes: 256
|
|
70
201
|
};
|
|
71
202
|
function hasFlag(edge, flag) {
|
|
72
|
-
return (edge.
|
|
203
|
+
return (edge.flags & flag) !== 0;
|
|
73
204
|
}
|
|
74
205
|
function getScalarMask(edge) {
|
|
75
|
-
return edge.
|
|
206
|
+
return edge.scalarMask;
|
|
76
207
|
}
|
|
77
208
|
function scalarTypeToMask(typeName) {
|
|
78
209
|
switch (typeName) {
|
|
@@ -102,6 +233,7 @@ function scalarTypeToMask(typeName) {
|
|
|
102
233
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
234
|
0 && (module.exports = {
|
|
104
235
|
EdgeFlag,
|
|
236
|
+
ParamGraph,
|
|
105
237
|
ScalarMask,
|
|
106
238
|
getScalarMask,
|
|
107
239
|
hasFlag,
|
package/dist/param-graph.mjs
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
+
import { deserializeParamGraph } from "./serialization";
|
|
2
|
+
class ParamGraph {
|
|
3
|
+
#data;
|
|
4
|
+
#stringIndex;
|
|
5
|
+
#enumLookup;
|
|
6
|
+
constructor(data, enumLookup) {
|
|
7
|
+
this.#data = data;
|
|
8
|
+
this.#enumLookup = enumLookup;
|
|
9
|
+
this.#stringIndex = /* @__PURE__ */ new Map();
|
|
10
|
+
for (let i = 0; i < data.strings.length; i++) {
|
|
11
|
+
this.#stringIndex.set(data.strings[i], i);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a ParamGraph from serialized format.
|
|
16
|
+
* This is the primary factory method for runtime use.
|
|
17
|
+
*/
|
|
18
|
+
static deserialize(serialized, enumLookup) {
|
|
19
|
+
const data = deserializeParamGraph(serialized);
|
|
20
|
+
return new ParamGraph(data, enumLookup);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a ParamGraph from builder data.
|
|
24
|
+
* Used by the builder for testing and direct construction.
|
|
25
|
+
*/
|
|
26
|
+
static fromData(data, enumLookup) {
|
|
27
|
+
return new ParamGraph(data, enumLookup);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Look up a root entry by "Model.action" or "action".
|
|
31
|
+
*/
|
|
32
|
+
root(key) {
|
|
33
|
+
const entry = this.#data.roots[key];
|
|
34
|
+
if (!entry) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
argsNodeId: entry.argsNodeId,
|
|
39
|
+
outputNodeId: entry.outputNodeId
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get an input node by ID.
|
|
44
|
+
*/
|
|
45
|
+
inputNode(id) {
|
|
46
|
+
if (id === void 0 || id < 0 || id >= this.#data.inputNodes.length) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
return { id };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get an output node by ID.
|
|
53
|
+
*/
|
|
54
|
+
outputNode(id) {
|
|
55
|
+
if (id === void 0 || id < 0 || id >= this.#data.outputNodes.length) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
return { id };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get an input edge for a field name within a node.
|
|
62
|
+
*/
|
|
63
|
+
inputEdge(node, fieldName) {
|
|
64
|
+
if (!node) {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
const nodeData = this.#data.inputNodes[node.id];
|
|
68
|
+
if (!nodeData) {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
const fieldIndex = this.#stringIndex.get(fieldName);
|
|
72
|
+
if (fieldIndex === void 0) {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
const edge = nodeData.edges[fieldIndex];
|
|
76
|
+
if (!edge) {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
flags: edge.flags,
|
|
81
|
+
childNodeId: edge.childNodeId,
|
|
82
|
+
scalarMask: edge.scalarMask ?? 0,
|
|
83
|
+
enumNameIndex: edge.enumNameIndex
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get an output edge for a field name within a node.
|
|
88
|
+
*/
|
|
89
|
+
outputEdge(node, fieldName) {
|
|
90
|
+
if (!node) {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
const nodeData = this.#data.outputNodes[node.id];
|
|
94
|
+
if (!nodeData) {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
const fieldIndex = this.#stringIndex.get(fieldName);
|
|
98
|
+
if (fieldIndex === void 0) {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
const edge = nodeData.edges[fieldIndex];
|
|
102
|
+
if (!edge) {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
argsNodeId: edge.argsNodeId,
|
|
107
|
+
outputNodeId: edge.outputNodeId
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get enum values for an edge that references a user enum.
|
|
112
|
+
* Returns undefined if the edge doesn't reference an enum.
|
|
113
|
+
*/
|
|
114
|
+
enumValues(edge) {
|
|
115
|
+
if (edge?.enumNameIndex === void 0) {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
const enumName = this.#data.strings[edge.enumNameIndex];
|
|
119
|
+
if (!enumName) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
return this.#enumLookup(enumName);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get a string from the string table by index.
|
|
126
|
+
*/
|
|
127
|
+
getString(index) {
|
|
128
|
+
return this.#data.strings[index];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
1
131
|
const EdgeFlag = {
|
|
2
132
|
/**
|
|
3
133
|
* Field may be parameterized as a scalar value.
|
|
@@ -42,10 +172,10 @@ const ScalarMask = {
|
|
|
42
172
|
Bytes: 256
|
|
43
173
|
};
|
|
44
174
|
function hasFlag(edge, flag) {
|
|
45
|
-
return (edge.
|
|
175
|
+
return (edge.flags & flag) !== 0;
|
|
46
176
|
}
|
|
47
177
|
function getScalarMask(edge) {
|
|
48
|
-
return edge.
|
|
178
|
+
return edge.scalarMask;
|
|
49
179
|
}
|
|
50
180
|
function scalarTypeToMask(typeName) {
|
|
51
181
|
switch (typeName) {
|
|
@@ -74,6 +204,7 @@ function scalarTypeToMask(typeName) {
|
|
|
74
204
|
}
|
|
75
205
|
export {
|
|
76
206
|
EdgeFlag,
|
|
207
|
+
ParamGraph,
|
|
77
208
|
ScalarMask,
|
|
78
209
|
getScalarMask,
|
|
79
210
|
hasFlag,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary serialization for ParamGraph.
|
|
3
|
+
*
|
|
4
|
+
* This module handles compact binary encoding/decoding of the param graph structure.
|
|
5
|
+
* The format uses a hybrid approach: JSON string array for field names + binary blob
|
|
6
|
+
* for structural data (nodes, edges, roots).
|
|
7
|
+
*/
|
|
8
|
+
import type { ParamGraphData } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Serialized format stored in the generated client.
|
|
11
|
+
*/
|
|
12
|
+
export interface SerializedParamGraph {
|
|
13
|
+
/** String table (field names, enum names, root keys) */
|
|
14
|
+
strings: string[];
|
|
15
|
+
/** Base64url-encoded binary blob for structural data */
|
|
16
|
+
graph: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Serializes a ParamGraphData to the compact binary format.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serializeParamGraph(data: ParamGraphData): SerializedParamGraph;
|
|
22
|
+
/**
|
|
23
|
+
* Deserializes a binary-encoded ParamGraph.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deserializeParamGraph(serialized: SerializedParamGraph): ParamGraphData;
|