@prisma/param-graph 7.10.1 → 7.11.0-dev.1
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 +12 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -1
- package/dist/index.mjs +7 -1
- package/dist/param-graph.d.ts +1 -0
- package/dist/param-graph.test.d.ts +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -15,3 +15,15 @@ ParamGraph is a compact data structure generated from DMMF (Data Model Metadata
|
|
|
15
15
|
- `ScalarMask` - Bit mask for scalar type categories
|
|
16
16
|
- `scalarTypeToMask` - Maps DMMF scalar type names to mask values
|
|
17
17
|
- `hasFlag` / `getScalarMask` - Helper functions for edge inspection
|
|
18
|
+
|
|
19
|
+
## Repeated deserialization
|
|
20
|
+
|
|
21
|
+
`ParamGraph.deserialize` shares decoded data for the same immutable serialized schema object. Each call creates a separate wrapper with its own enum lookup and string index. Different schema objects have separate cache entries, and the weak cache does not keep discarded schema objects alive.
|
|
22
|
+
|
|
23
|
+
To measure repeated construction with a synthetic graph and no database, run from the repository root:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
node --expose-gc --import tsx packages/param-graph/helpers/benchmark-deserialization.ts 32 4096
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The arguments are the number of live instances and the number of input/output nodes. The output reports the first construction separately from subsequent constructions and their additional retained heap after garbage collection. Run the same script before and after a change to compare results. The first decode still has to construct the full graph.
|
package/dist/index.d.mts
CHANGED
|
@@ -144,6 +144,7 @@ export declare class ParamGraph {
|
|
|
144
144
|
/**
|
|
145
145
|
* Creates a ParamGraph from serialized format.
|
|
146
146
|
* This is the primary factory method for runtime use.
|
|
147
|
+
* Serialized schemas must not be mutated after successful deserialization.
|
|
147
148
|
*/
|
|
148
149
|
static deserialize(serialized: SerializedParamGraph, enumLookup: EnumLookup): ParamGraph;
|
|
149
150
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ export declare class ParamGraph {
|
|
|
144
144
|
/**
|
|
145
145
|
* Creates a ParamGraph from serialized format.
|
|
146
146
|
* This is the primary factory method for runtime use.
|
|
147
|
+
* Serialized schemas must not be mutated after successful deserialization.
|
|
147
148
|
*/
|
|
148
149
|
static deserialize(serialized: SerializedParamGraph, enumLookup: EnumLookup): ParamGraph;
|
|
149
150
|
/**
|
package/dist/index.js
CHANGED
|
@@ -282,6 +282,7 @@ var Deserializer = class {
|
|
|
282
282
|
|
|
283
283
|
// src/param-graph.ts
|
|
284
284
|
var ParamGraph = class _ParamGraph {
|
|
285
|
+
static #decodedGraphs = /* @__PURE__ */ new WeakMap();
|
|
285
286
|
#data;
|
|
286
287
|
#stringIndex;
|
|
287
288
|
#enumLookup;
|
|
@@ -296,9 +297,14 @@ var ParamGraph = class _ParamGraph {
|
|
|
296
297
|
/**
|
|
297
298
|
* Creates a ParamGraph from serialized format.
|
|
298
299
|
* This is the primary factory method for runtime use.
|
|
300
|
+
* Serialized schemas must not be mutated after successful deserialization.
|
|
299
301
|
*/
|
|
300
302
|
static deserialize(serialized, enumLookup) {
|
|
301
|
-
|
|
303
|
+
let data = _ParamGraph.#decodedGraphs.get(serialized);
|
|
304
|
+
if (data === void 0) {
|
|
305
|
+
data = deserializeParamGraph(serialized);
|
|
306
|
+
_ParamGraph.#decodedGraphs.set(serialized, data);
|
|
307
|
+
}
|
|
302
308
|
return new _ParamGraph(data, enumLookup);
|
|
303
309
|
}
|
|
304
310
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -249,6 +249,7 @@ var Deserializer = class {
|
|
|
249
249
|
|
|
250
250
|
// src/param-graph.ts
|
|
251
251
|
var ParamGraph = class _ParamGraph {
|
|
252
|
+
static #decodedGraphs = /* @__PURE__ */ new WeakMap();
|
|
252
253
|
#data;
|
|
253
254
|
#stringIndex;
|
|
254
255
|
#enumLookup;
|
|
@@ -263,9 +264,14 @@ var ParamGraph = class _ParamGraph {
|
|
|
263
264
|
/**
|
|
264
265
|
* Creates a ParamGraph from serialized format.
|
|
265
266
|
* This is the primary factory method for runtime use.
|
|
267
|
+
* Serialized schemas must not be mutated after successful deserialization.
|
|
266
268
|
*/
|
|
267
269
|
static deserialize(serialized, enumLookup) {
|
|
268
|
-
|
|
270
|
+
let data = _ParamGraph.#decodedGraphs.get(serialized);
|
|
271
|
+
if (data === void 0) {
|
|
272
|
+
data = deserializeParamGraph(serialized);
|
|
273
|
+
_ParamGraph.#decodedGraphs.set(serialized, data);
|
|
274
|
+
}
|
|
269
275
|
return new _ParamGraph(data, enumLookup);
|
|
270
276
|
}
|
|
271
277
|
/**
|
package/dist/param-graph.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare class ParamGraph {
|
|
|
61
61
|
/**
|
|
62
62
|
* Creates a ParamGraph from serialized format.
|
|
63
63
|
* This is the primary factory method for runtime use.
|
|
64
|
+
* Serialized schemas must not be mutated after successful deserialization.
|
|
64
65
|
*/
|
|
65
66
|
static deserialize(serialized: SerializedParamGraph, enumLookup: EnumLookup): ParamGraph;
|
|
66
67
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/param-graph",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.0-dev.1",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"scripts": {
|
|
31
31
|
"dev": "DEV=true tsx helpers/build.ts",
|
|
32
|
-
"build": "tsx helpers/build.ts"
|
|
33
|
-
"test": "vitest run"
|
|
32
|
+
"build": "tsx helpers/build.ts"
|
|
34
33
|
}
|
|
35
34
|
}
|