@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.
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var import_vitest = require("vitest");
3
+ var import_serialization = require("./serialization");
4
+ (0, import_vitest.describe)("param-graph serialization", () => {
5
+ (0, import_vitest.test)("roundtrip with empty data", () => {
6
+ const data = {
7
+ strings: ["root1"],
8
+ inputNodes: [],
9
+ outputNodes: [],
10
+ roots: { root1: {} }
11
+ };
12
+ const serialized = (0, import_serialization.serializeParamGraph)(data);
13
+ const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
14
+ (0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
15
+ (0, import_vitest.expect)(deserialized.inputNodes).toEqual(data.inputNodes);
16
+ (0, import_vitest.expect)(deserialized.outputNodes).toEqual(data.outputNodes);
17
+ (0, import_vitest.expect)(deserialized.roots).toEqual(data.roots);
18
+ });
19
+ (0, import_vitest.test)("roundtrip with small data", () => {
20
+ const data = {
21
+ strings: ["findMany", "where", "id"],
22
+ inputNodes: [{ edges: { 1: { flags: 0, scalarMask: 1 } } }],
23
+ outputNodes: [{ edges: { 2: { argsNodeId: 0 } } }],
24
+ roots: { findMany: { argsNodeId: 0, outputNodeId: 0 } }
25
+ };
26
+ const serialized = (0, import_serialization.serializeParamGraph)(data);
27
+ const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
28
+ (0, import_vitest.expect)(deserialized.strings).toEqual(data.strings);
29
+ (0, import_vitest.expect)(deserialized.inputNodes.length).toBe(data.inputNodes.length);
30
+ (0, import_vitest.expect)(deserialized.outputNodes.length).toBe(data.outputNodes.length);
31
+ (0, import_vitest.expect)(Object.keys(deserialized.roots)).toEqual(Object.keys(data.roots));
32
+ });
33
+ (0, import_vitest.test)("roundtrip with multiple nodes and edges", () => {
34
+ const data = {
35
+ strings: ["findMany", "create", "update", "where", "data", "id", "name", "Status"],
36
+ inputNodes: [
37
+ { edges: { 3: { flags: 1, scalarMask: 1, childNodeId: 1 }, 4: { flags: 0, scalarMask: 2 } } },
38
+ { edges: { 5: { flags: 2, enumNameIndex: 7 } } }
39
+ ],
40
+ outputNodes: [{ edges: { 6: { argsNodeId: 0, outputNodeId: 1 } } }, { edges: {} }],
41
+ roots: {
42
+ findMany: { argsNodeId: 0, outputNodeId: 0 },
43
+ create: { argsNodeId: 1, outputNodeId: 1 },
44
+ update: { argsNodeId: 0 }
45
+ }
46
+ };
47
+ const serialized = (0, import_serialization.serializeParamGraph)(data);
48
+ const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
49
+ (0, import_vitest.expect)(deserialized.inputNodes.length).toBe(2);
50
+ (0, import_vitest.expect)(deserialized.outputNodes.length).toBe(2);
51
+ (0, import_vitest.expect)(Object.keys(deserialized.roots).length).toBe(3);
52
+ const inputEdge = deserialized.inputNodes[0].edges[3];
53
+ (0, import_vitest.expect)(inputEdge.flags).toBe(1);
54
+ (0, import_vitest.expect)(inputEdge.scalarMask).toBe(1);
55
+ (0, import_vitest.expect)(inputEdge.childNodeId).toBe(1);
56
+ const enumEdge = deserialized.inputNodes[1].edges[5];
57
+ (0, import_vitest.expect)(enumEdge.flags).toBe(2);
58
+ (0, import_vitest.expect)(enumEdge.enumNameIndex).toBe(7);
59
+ });
60
+ (0, import_vitest.test)("handles undefined values correctly", () => {
61
+ const data = {
62
+ strings: ["root"],
63
+ inputNodes: [{ edges: { 0: { flags: 0 } } }],
64
+ outputNodes: [{ edges: { 0: {} } }],
65
+ roots: { root: { argsNodeId: 0 } }
66
+ };
67
+ const serialized = (0, import_serialization.serializeParamGraph)(data);
68
+ const deserialized = (0, import_serialization.deserializeParamGraph)(serialized);
69
+ (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].childNodeId).toBeUndefined();
70
+ (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].scalarMask).toBeUndefined();
71
+ (0, import_vitest.expect)(deserialized.inputNodes[0].edges[0].enumNameIndex).toBeUndefined();
72
+ (0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].argsNodeId).toBeUndefined();
73
+ (0, import_vitest.expect)(deserialized.outputNodes[0].edges[0].outputNodeId).toBeUndefined();
74
+ (0, import_vitest.expect)(deserialized.roots["root"].outputNodeId).toBeUndefined();
75
+ });
76
+ (0, import_vitest.test)("base64url encoding produces URL-safe output", () => {
77
+ const data = {
78
+ strings: ["test"],
79
+ inputNodes: [{ edges: { 255: { flags: 255, scalarMask: 65535, childNodeId: 0, enumNameIndex: 0 } } }],
80
+ outputNodes: [],
81
+ roots: { test: { argsNodeId: 0 } }
82
+ };
83
+ const serialized = (0, import_serialization.serializeParamGraph)(data);
84
+ (0, import_vitest.expect)(serialized.graph).toMatch(/^[A-Za-z0-9_-]+$/);
85
+ });
86
+ });
@@ -0,0 +1,85 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { serializeParamGraph, deserializeParamGraph } from "./serialization";
3
+ describe("param-graph serialization", () => {
4
+ test("roundtrip with empty data", () => {
5
+ const data = {
6
+ strings: ["root1"],
7
+ inputNodes: [],
8
+ outputNodes: [],
9
+ roots: { root1: {} }
10
+ };
11
+ const serialized = serializeParamGraph(data);
12
+ const deserialized = deserializeParamGraph(serialized);
13
+ expect(deserialized.strings).toEqual(data.strings);
14
+ expect(deserialized.inputNodes).toEqual(data.inputNodes);
15
+ expect(deserialized.outputNodes).toEqual(data.outputNodes);
16
+ expect(deserialized.roots).toEqual(data.roots);
17
+ });
18
+ test("roundtrip with small data", () => {
19
+ const data = {
20
+ strings: ["findMany", "where", "id"],
21
+ inputNodes: [{ edges: { 1: { flags: 0, scalarMask: 1 } } }],
22
+ outputNodes: [{ edges: { 2: { argsNodeId: 0 } } }],
23
+ roots: { findMany: { argsNodeId: 0, outputNodeId: 0 } }
24
+ };
25
+ const serialized = serializeParamGraph(data);
26
+ const deserialized = deserializeParamGraph(serialized);
27
+ expect(deserialized.strings).toEqual(data.strings);
28
+ expect(deserialized.inputNodes.length).toBe(data.inputNodes.length);
29
+ expect(deserialized.outputNodes.length).toBe(data.outputNodes.length);
30
+ expect(Object.keys(deserialized.roots)).toEqual(Object.keys(data.roots));
31
+ });
32
+ test("roundtrip with multiple nodes and edges", () => {
33
+ const data = {
34
+ strings: ["findMany", "create", "update", "where", "data", "id", "name", "Status"],
35
+ inputNodes: [
36
+ { edges: { 3: { flags: 1, scalarMask: 1, childNodeId: 1 }, 4: { flags: 0, scalarMask: 2 } } },
37
+ { edges: { 5: { flags: 2, enumNameIndex: 7 } } }
38
+ ],
39
+ outputNodes: [{ edges: { 6: { argsNodeId: 0, outputNodeId: 1 } } }, { edges: {} }],
40
+ roots: {
41
+ findMany: { argsNodeId: 0, outputNodeId: 0 },
42
+ create: { argsNodeId: 1, outputNodeId: 1 },
43
+ update: { argsNodeId: 0 }
44
+ }
45
+ };
46
+ const serialized = serializeParamGraph(data);
47
+ const deserialized = deserializeParamGraph(serialized);
48
+ expect(deserialized.inputNodes.length).toBe(2);
49
+ expect(deserialized.outputNodes.length).toBe(2);
50
+ expect(Object.keys(deserialized.roots).length).toBe(3);
51
+ const inputEdge = deserialized.inputNodes[0].edges[3];
52
+ expect(inputEdge.flags).toBe(1);
53
+ expect(inputEdge.scalarMask).toBe(1);
54
+ expect(inputEdge.childNodeId).toBe(1);
55
+ const enumEdge = deserialized.inputNodes[1].edges[5];
56
+ expect(enumEdge.flags).toBe(2);
57
+ expect(enumEdge.enumNameIndex).toBe(7);
58
+ });
59
+ test("handles undefined values correctly", () => {
60
+ const data = {
61
+ strings: ["root"],
62
+ inputNodes: [{ edges: { 0: { flags: 0 } } }],
63
+ outputNodes: [{ edges: { 0: {} } }],
64
+ roots: { root: { argsNodeId: 0 } }
65
+ };
66
+ const serialized = serializeParamGraph(data);
67
+ const deserialized = deserializeParamGraph(serialized);
68
+ expect(deserialized.inputNodes[0].edges[0].childNodeId).toBeUndefined();
69
+ expect(deserialized.inputNodes[0].edges[0].scalarMask).toBeUndefined();
70
+ expect(deserialized.inputNodes[0].edges[0].enumNameIndex).toBeUndefined();
71
+ expect(deserialized.outputNodes[0].edges[0].argsNodeId).toBeUndefined();
72
+ expect(deserialized.outputNodes[0].edges[0].outputNodeId).toBeUndefined();
73
+ expect(deserialized.roots["root"].outputNodeId).toBeUndefined();
74
+ });
75
+ test("base64url encoding produces URL-safe output", () => {
76
+ const data = {
77
+ strings: ["test"],
78
+ inputNodes: [{ edges: { 255: { flags: 255, scalarMask: 65535, childNodeId: 0, enumNameIndex: 0 } } }],
79
+ outputNodes: [],
80
+ roots: { test: { argsNodeId: 0 } }
81
+ };
82
+ const serialized = serializeParamGraph(data);
83
+ expect(serialized.graph).toMatch(/^[A-Za-z0-9_-]+$/);
84
+ });
85
+ });
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Internal data types for ParamGraph.
3
+ *
4
+ * These types represent the in-memory structure of the param graph,
5
+ * used both during building and after deserialization.
6
+ */
7
+ /**
8
+ * Complete param graph data structure.
9
+ * This is the internal representation, not the serialized format.
10
+ */
11
+ export interface ParamGraphData {
12
+ /** String table containing field names and enum names */
13
+ strings: string[];
14
+ /** Input nodes for argument objects and input types */
15
+ inputNodes: InputNodeData[];
16
+ /** Output nodes for selection traversal */
17
+ outputNodes: OutputNodeData[];
18
+ /** Root mapping: "Model.action" -> entry */
19
+ roots: Record<string, RootEntryData>;
20
+ }
21
+ /**
22
+ * Input node data: describes parameterizable fields in an input object.
23
+ */
24
+ export interface InputNodeData {
25
+ /** Map from string-table index to edge descriptor */
26
+ edges: Record<number, InputEdgeData>;
27
+ }
28
+ /**
29
+ * Output node data: describes fields in a selection set.
30
+ */
31
+ export interface OutputNodeData {
32
+ /** Map from string-table index to edge descriptor */
33
+ edges: Record<number, OutputEdgeData>;
34
+ }
35
+ /**
36
+ * Input edge data: describes what a field accepts.
37
+ */
38
+ export interface InputEdgeData {
39
+ /** Bit flags describing field capabilities (see EdgeFlag) */
40
+ flags: number;
41
+ /** Child input node id (for object values) */
42
+ childNodeId?: number;
43
+ /** Scalar type mask (see ScalarMask) */
44
+ scalarMask?: number;
45
+ /** Enum name index into string table */
46
+ enumNameIndex?: number;
47
+ }
48
+ /**
49
+ * Output edge data: describes a field in a selection set.
50
+ */
51
+ export interface OutputEdgeData {
52
+ /** Args node id for this field */
53
+ argsNodeId?: number;
54
+ /** Next output node id for nested selection */
55
+ outputNodeId?: number;
56
+ }
57
+ /**
58
+ * Root entry data: entry point for an operation.
59
+ */
60
+ export interface RootEntryData {
61
+ /** Args node id */
62
+ argsNodeId?: number;
63
+ /** Output node id */
64
+ outputNodeId?: number;
65
+ }
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
package/dist/types.mjs ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/param-graph",
3
- "version": "7.4.0-integration-parameterization.5",
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",
@@ -23,12 +23,16 @@
23
23
  "directory": "packages/param-graph"
24
24
  },
25
25
  "license": "Apache-2.0",
26
+ "devDependencies": {
27
+ "vitest": "^2.1.8"
28
+ },
26
29
  "files": [
27
30
  "dist"
28
31
  ],
29
32
  "sideEffects": false,
30
33
  "scripts": {
31
34
  "dev": "DEV=true tsx helpers/build.ts",
32
- "build": "tsx helpers/build.ts"
35
+ "build": "tsx helpers/build.ts",
36
+ "test": "vitest run"
33
37
  }
34
38
  }