@prisma/param-graph-builder 7.4.0-integration-parameterization.6 → 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/build-param-graph.d.ts +19 -7
- package/dist/build-param-graph.js +12 -400
- package/dist/build-param-graph.mjs +10 -402
- package/dist/dmmf-traverser.d.ts +36 -0
- package/dist/dmmf-traverser.js +338 -0
- package/dist/dmmf-traverser.mjs +314 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -0
- package/dist/index.mjs +6 -1
- package/dist/param-graph-builder.d.ts +56 -0
- package/dist/param-graph-builder.js +139 -0
- package/dist/param-graph-builder.mjs +115 -0
- package/package.json +3 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParamGraphBuilder: Data holder for building ParamGraph.
|
|
3
|
+
*
|
|
4
|
+
* This class manages allocation and caching during graph construction.
|
|
5
|
+
* The actual traversal logic is in DMMFTraverser.
|
|
6
|
+
*/
|
|
7
|
+
import type { InputEdgeData, OutputEdgeData, ParamGraphData, RootEntryData, SerializedParamGraph } from '@prisma/param-graph';
|
|
8
|
+
export type NodeId = number;
|
|
9
|
+
/**
|
|
10
|
+
* Builder class that accumulates graph data during construction.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ParamGraphBuilder {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Interns a string into the string table, returning its index.
|
|
16
|
+
* Both field names and enum names go through this method.
|
|
17
|
+
*/
|
|
18
|
+
internString(str: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* Allocates a new input node and returns its ID.
|
|
21
|
+
*/
|
|
22
|
+
allocateInputNode(): NodeId;
|
|
23
|
+
/**
|
|
24
|
+
* Sets edges on an input node.
|
|
25
|
+
*/
|
|
26
|
+
setInputNodeEdges(nodeId: NodeId, edges: Record<number, InputEdgeData>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Allocates a new output node and returns its ID.
|
|
29
|
+
*/
|
|
30
|
+
allocateOutputNode(): NodeId;
|
|
31
|
+
/**
|
|
32
|
+
* Sets edges on an output node.
|
|
33
|
+
*/
|
|
34
|
+
setOutputNodeEdges(nodeId: NodeId, edges: Record<number, OutputEdgeData>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Records a root entry for an operation.
|
|
37
|
+
*/
|
|
38
|
+
setRoot(key: string, entry: RootEntryData): void;
|
|
39
|
+
getInputTypeNode(typeName: string): NodeId | undefined;
|
|
40
|
+
setInputTypeNode(typeName: string, nodeId: NodeId | undefined): void;
|
|
41
|
+
hasInputTypeNode(typeName: string): boolean;
|
|
42
|
+
getUnionNode(key: string): NodeId | undefined;
|
|
43
|
+
setUnionNode(key: string, nodeId: NodeId | undefined): void;
|
|
44
|
+
hasUnionNode(key: string): boolean;
|
|
45
|
+
getOutputTypeNode(typeName: string): NodeId | undefined;
|
|
46
|
+
setOutputTypeNode(typeName: string, nodeId: NodeId | undefined): void;
|
|
47
|
+
hasOutputTypeNode(typeName: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Builds the final ParamGraphData structure.
|
|
50
|
+
*/
|
|
51
|
+
build(): ParamGraphData;
|
|
52
|
+
/**
|
|
53
|
+
* Builds and serializes to the compact binary format.
|
|
54
|
+
*/
|
|
55
|
+
buildAndSerialize(): SerializedParamGraph;
|
|
56
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var param_graph_builder_exports = {};
|
|
20
|
+
__export(param_graph_builder_exports, {
|
|
21
|
+
ParamGraphBuilder: () => ParamGraphBuilder
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(param_graph_builder_exports);
|
|
24
|
+
var import_param_graph = require("@prisma/param-graph");
|
|
25
|
+
class ParamGraphBuilder {
|
|
26
|
+
#stringTable = [];
|
|
27
|
+
#stringToIndex = /* @__PURE__ */ new Map();
|
|
28
|
+
#inputNodes = [];
|
|
29
|
+
#outputNodes = [];
|
|
30
|
+
#roots = {};
|
|
31
|
+
#inputTypeNodeCache = /* @__PURE__ */ new Map();
|
|
32
|
+
#unionNodeCache = /* @__PURE__ */ new Map();
|
|
33
|
+
#outputTypeNodeCache = /* @__PURE__ */ new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Interns a string into the string table, returning its index.
|
|
36
|
+
* Both field names and enum names go through this method.
|
|
37
|
+
*/
|
|
38
|
+
internString(str) {
|
|
39
|
+
let index = this.#stringToIndex.get(str);
|
|
40
|
+
if (index === void 0) {
|
|
41
|
+
index = this.#stringTable.length;
|
|
42
|
+
this.#stringTable.push(str);
|
|
43
|
+
this.#stringToIndex.set(str, index);
|
|
44
|
+
}
|
|
45
|
+
return index;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Allocates a new input node and returns its ID.
|
|
49
|
+
*/
|
|
50
|
+
allocateInputNode() {
|
|
51
|
+
const id = this.#inputNodes.length;
|
|
52
|
+
this.#inputNodes.push({ edges: {} });
|
|
53
|
+
return id;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sets edges on an input node.
|
|
57
|
+
*/
|
|
58
|
+
setInputNodeEdges(nodeId, edges) {
|
|
59
|
+
if (Object.keys(edges).length > 0) {
|
|
60
|
+
this.#inputNodes[nodeId].edges = edges;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Allocates a new output node and returns its ID.
|
|
65
|
+
*/
|
|
66
|
+
allocateOutputNode() {
|
|
67
|
+
const id = this.#outputNodes.length;
|
|
68
|
+
this.#outputNodes.push({ edges: {} });
|
|
69
|
+
return id;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sets edges on an output node.
|
|
73
|
+
*/
|
|
74
|
+
setOutputNodeEdges(nodeId, edges) {
|
|
75
|
+
if (Object.keys(edges).length > 0) {
|
|
76
|
+
this.#outputNodes[nodeId].edges = edges;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Records a root entry for an operation.
|
|
81
|
+
*/
|
|
82
|
+
setRoot(key, entry) {
|
|
83
|
+
if (entry.argsNodeId !== void 0 || entry.outputNodeId !== void 0) {
|
|
84
|
+
this.internString(key);
|
|
85
|
+
this.#roots[key] = entry;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Cache methods for input type nodes
|
|
89
|
+
getInputTypeNode(typeName) {
|
|
90
|
+
return this.#inputTypeNodeCache.get(typeName);
|
|
91
|
+
}
|
|
92
|
+
setInputTypeNode(typeName, nodeId) {
|
|
93
|
+
this.#inputTypeNodeCache.set(typeName, nodeId);
|
|
94
|
+
}
|
|
95
|
+
hasInputTypeNode(typeName) {
|
|
96
|
+
return this.#inputTypeNodeCache.has(typeName);
|
|
97
|
+
}
|
|
98
|
+
// Cache methods for union nodes
|
|
99
|
+
getUnionNode(key) {
|
|
100
|
+
return this.#unionNodeCache.get(key);
|
|
101
|
+
}
|
|
102
|
+
setUnionNode(key, nodeId) {
|
|
103
|
+
this.#unionNodeCache.set(key, nodeId);
|
|
104
|
+
}
|
|
105
|
+
hasUnionNode(key) {
|
|
106
|
+
return this.#unionNodeCache.has(key);
|
|
107
|
+
}
|
|
108
|
+
// Cache methods for output type nodes
|
|
109
|
+
getOutputTypeNode(typeName) {
|
|
110
|
+
return this.#outputTypeNodeCache.get(typeName);
|
|
111
|
+
}
|
|
112
|
+
setOutputTypeNode(typeName, nodeId) {
|
|
113
|
+
this.#outputTypeNodeCache.set(typeName, nodeId);
|
|
114
|
+
}
|
|
115
|
+
hasOutputTypeNode(typeName) {
|
|
116
|
+
return this.#outputTypeNodeCache.has(typeName);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Builds the final ParamGraphData structure.
|
|
120
|
+
*/
|
|
121
|
+
build() {
|
|
122
|
+
return {
|
|
123
|
+
strings: this.#stringTable,
|
|
124
|
+
inputNodes: this.#inputNodes,
|
|
125
|
+
outputNodes: this.#outputNodes,
|
|
126
|
+
roots: this.#roots
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Builds and serializes to the compact binary format.
|
|
131
|
+
*/
|
|
132
|
+
buildAndSerialize() {
|
|
133
|
+
return (0, import_param_graph.serializeParamGraph)(this.build());
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
ParamGraphBuilder
|
|
139
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { serializeParamGraph } from "@prisma/param-graph";
|
|
2
|
+
class ParamGraphBuilder {
|
|
3
|
+
#stringTable = [];
|
|
4
|
+
#stringToIndex = /* @__PURE__ */ new Map();
|
|
5
|
+
#inputNodes = [];
|
|
6
|
+
#outputNodes = [];
|
|
7
|
+
#roots = {};
|
|
8
|
+
#inputTypeNodeCache = /* @__PURE__ */ new Map();
|
|
9
|
+
#unionNodeCache = /* @__PURE__ */ new Map();
|
|
10
|
+
#outputTypeNodeCache = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Interns a string into the string table, returning its index.
|
|
13
|
+
* Both field names and enum names go through this method.
|
|
14
|
+
*/
|
|
15
|
+
internString(str) {
|
|
16
|
+
let index = this.#stringToIndex.get(str);
|
|
17
|
+
if (index === void 0) {
|
|
18
|
+
index = this.#stringTable.length;
|
|
19
|
+
this.#stringTable.push(str);
|
|
20
|
+
this.#stringToIndex.set(str, index);
|
|
21
|
+
}
|
|
22
|
+
return index;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Allocates a new input node and returns its ID.
|
|
26
|
+
*/
|
|
27
|
+
allocateInputNode() {
|
|
28
|
+
const id = this.#inputNodes.length;
|
|
29
|
+
this.#inputNodes.push({ edges: {} });
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sets edges on an input node.
|
|
34
|
+
*/
|
|
35
|
+
setInputNodeEdges(nodeId, edges) {
|
|
36
|
+
if (Object.keys(edges).length > 0) {
|
|
37
|
+
this.#inputNodes[nodeId].edges = edges;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Allocates a new output node and returns its ID.
|
|
42
|
+
*/
|
|
43
|
+
allocateOutputNode() {
|
|
44
|
+
const id = this.#outputNodes.length;
|
|
45
|
+
this.#outputNodes.push({ edges: {} });
|
|
46
|
+
return id;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets edges on an output node.
|
|
50
|
+
*/
|
|
51
|
+
setOutputNodeEdges(nodeId, edges) {
|
|
52
|
+
if (Object.keys(edges).length > 0) {
|
|
53
|
+
this.#outputNodes[nodeId].edges = edges;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Records a root entry for an operation.
|
|
58
|
+
*/
|
|
59
|
+
setRoot(key, entry) {
|
|
60
|
+
if (entry.argsNodeId !== void 0 || entry.outputNodeId !== void 0) {
|
|
61
|
+
this.internString(key);
|
|
62
|
+
this.#roots[key] = entry;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Cache methods for input type nodes
|
|
66
|
+
getInputTypeNode(typeName) {
|
|
67
|
+
return this.#inputTypeNodeCache.get(typeName);
|
|
68
|
+
}
|
|
69
|
+
setInputTypeNode(typeName, nodeId) {
|
|
70
|
+
this.#inputTypeNodeCache.set(typeName, nodeId);
|
|
71
|
+
}
|
|
72
|
+
hasInputTypeNode(typeName) {
|
|
73
|
+
return this.#inputTypeNodeCache.has(typeName);
|
|
74
|
+
}
|
|
75
|
+
// Cache methods for union nodes
|
|
76
|
+
getUnionNode(key) {
|
|
77
|
+
return this.#unionNodeCache.get(key);
|
|
78
|
+
}
|
|
79
|
+
setUnionNode(key, nodeId) {
|
|
80
|
+
this.#unionNodeCache.set(key, nodeId);
|
|
81
|
+
}
|
|
82
|
+
hasUnionNode(key) {
|
|
83
|
+
return this.#unionNodeCache.has(key);
|
|
84
|
+
}
|
|
85
|
+
// Cache methods for output type nodes
|
|
86
|
+
getOutputTypeNode(typeName) {
|
|
87
|
+
return this.#outputTypeNodeCache.get(typeName);
|
|
88
|
+
}
|
|
89
|
+
setOutputTypeNode(typeName, nodeId) {
|
|
90
|
+
this.#outputTypeNodeCache.set(typeName, nodeId);
|
|
91
|
+
}
|
|
92
|
+
hasOutputTypeNode(typeName) {
|
|
93
|
+
return this.#outputTypeNodeCache.has(typeName);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Builds the final ParamGraphData structure.
|
|
97
|
+
*/
|
|
98
|
+
build() {
|
|
99
|
+
return {
|
|
100
|
+
strings: this.#stringTable,
|
|
101
|
+
inputNodes: this.#inputNodes,
|
|
102
|
+
outputNodes: this.#outputNodes,
|
|
103
|
+
roots: this.#roots
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Builds and serializes to the compact binary format.
|
|
108
|
+
*/
|
|
109
|
+
buildAndSerialize() {
|
|
110
|
+
return serializeParamGraph(this.build());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
ParamGraphBuilder
|
|
115
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/param-graph-builder",
|
|
3
|
-
"version": "7.4.0-integration-parameterization.
|
|
3
|
+
"version": "7.4.0-integration-parameterization.7",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@prisma/dmmf": "7.4.0-integration-parameterization.
|
|
28
|
-
"@prisma/param-graph": "7.4.0-integration-parameterization.
|
|
27
|
+
"@prisma/dmmf": "7.4.0-integration-parameterization.7",
|
|
28
|
+
"@prisma/param-graph": "7.4.0-integration-parameterization.7"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist"
|