@powerlines/plugin-prisma 0.2.75 → 0.2.77

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.
Files changed (86) hide show
  1. package/dist/api/client/client.gen.cjs +8 -175
  2. package/dist/api/client/client.gen.mjs +7 -174
  3. package/dist/api/client/index.cjs +18 -13
  4. package/dist/api/client/index.mjs +10 -5
  5. package/dist/api/client/utils.gen.cjs +13 -186
  6. package/dist/api/client/utils.gen.mjs +5 -178
  7. package/dist/api/client.gen.cjs +12 -8
  8. package/dist/api/client.gen.mjs +11 -7
  9. package/dist/api/core/auth.gen.cjs +2 -11
  10. package/dist/api/core/auth.gen.mjs +1 -9
  11. package/dist/api/core/bodySerializer.gen.cjs +4 -34
  12. package/dist/api/core/bodySerializer.gen.mjs +1 -30
  13. package/dist/api/core/params.gen.cjs +2 -64
  14. package/dist/api/core/params.gen.mjs +1 -62
  15. package/dist/api/core/pathSerializer.gen.cjs +7 -86
  16. package/dist/api/core/pathSerializer.gen.mjs +1 -79
  17. package/dist/api/core/queryKeySerializer.gen.cjs +4 -65
  18. package/dist/api/core/queryKeySerializer.gen.mjs +1 -61
  19. package/dist/api/core/serverSentEvents.gen.cjs +2 -94
  20. package/dist/api/core/serverSentEvents.gen.mjs +1 -92
  21. package/dist/api/core/utils.gen.cjs +6 -80
  22. package/dist/api/core/utils.gen.mjs +2 -76
  23. package/dist/api/sdk.gen.cjs +13 -255
  24. package/dist/api/sdk.gen.mjs +12 -254
  25. package/dist/api/types.gen.cjs +1 -0
  26. package/dist/api/types.gen.mjs +2 -0
  27. package/dist/auth.gen-BFteuMTV.cjs +17 -0
  28. package/dist/auth.gen-C4FxE4_3.mjs +11 -0
  29. package/dist/bodySerializer.gen-BLtxkFoA.cjs +50 -0
  30. package/dist/bodySerializer.gen-DBXNewIA.mjs +32 -0
  31. package/dist/client-BlRUW8mL.mjs +1 -0
  32. package/dist/client-DBAc9HV1.cjs +0 -0
  33. package/dist/client.gen-COMS1glH.mjs +8 -0
  34. package/dist/client.gen-CPQm4WCv.mjs +176 -0
  35. package/dist/client.gen-DPSMNZNm.cjs +181 -0
  36. package/dist/client.gen-JhYC1fDf.cjs +13 -0
  37. package/dist/get-schema-CKw6MiKb.mjs +78 -0
  38. package/dist/get-schema-CqMBOHOd.cjs +118 -0
  39. package/dist/helpers/get-schema.cjs +2 -80
  40. package/dist/helpers/get-schema.mjs +1 -76
  41. package/dist/helpers/index.cjs +6 -6
  42. package/dist/helpers/index.mjs +3 -3
  43. package/dist/helpers/prisma-postgres.cjs +2 -15
  44. package/dist/helpers/prisma-postgres.mjs +1 -13
  45. package/dist/helpers/schema-creator.cjs +2 -60
  46. package/dist/helpers/schema-creator.mjs +1 -58
  47. package/dist/index.cjs +107 -20
  48. package/dist/index.mjs +96 -8
  49. package/dist/params.gen-BM1l95BD.mjs +64 -0
  50. package/dist/params.gen-BtCSnwiV.cjs +70 -0
  51. package/dist/pathSerializer.gen-BEbuI0Vn.cjs +117 -0
  52. package/dist/pathSerializer.gen-m7BRzH23.mjs +81 -0
  53. package/dist/plugin-DE9fKOLA.cjs +0 -0
  54. package/dist/plugin-EFmNQLKA.mjs +1 -0
  55. package/dist/prisma-BzQJneyW.cjs +0 -0
  56. package/dist/prisma-CB-m5c-j.mjs +1 -0
  57. package/dist/prisma-postgres-CAOpTtWq.mjs +15 -0
  58. package/dist/prisma-postgres-dGaLzxF3.cjs +21 -0
  59. package/dist/queryKeySerializer.gen-4TWHHXn3.cjs +81 -0
  60. package/dist/queryKeySerializer.gen-BMMZAjVN.mjs +63 -0
  61. package/dist/schema-creator-Cfian3ih.mjs +60 -0
  62. package/dist/schema-creator-zmlwh4-l.cjs +66 -0
  63. package/dist/sdk.gen-B2his2jD.mjs +256 -0
  64. package/dist/sdk.gen-CAWIQ8BM.cjs +261 -0
  65. package/dist/serverSentEvents.gen-C4apQvDl.mjs +94 -0
  66. package/dist/serverSentEvents.gen-CiMMmhyQ.cjs +100 -0
  67. package/dist/types/index.cjs +3 -0
  68. package/dist/types/index.mjs +4 -0
  69. package/dist/types/plugin.cjs +1 -0
  70. package/dist/types/plugin.mjs +2 -0
  71. package/dist/types/prisma.cjs +1 -0
  72. package/dist/types/prisma.mjs +2 -0
  73. package/dist/types-CmY9-4ff.cjs +0 -0
  74. package/dist/types-Dbwx-Khg.mjs +1 -0
  75. package/dist/types.gen-BN-p9nVT.cjs +0 -0
  76. package/dist/types.gen-CS2KiRfG.mjs +1 -0
  77. package/dist/utils.gen-Bk2pTkV1.cjs +101 -0
  78. package/dist/utils.gen-C-7sZa7Z.mjs +180 -0
  79. package/dist/utils.gen-DATakax-.cjs +227 -0
  80. package/dist/utils.gen-RO8GxC4i.mjs +78 -0
  81. package/package.json +6 -6
  82. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  83. package/dist/powerlines/src/plugin-utils/get-config-path.cjs +0 -49
  84. package/dist/powerlines/src/plugin-utils/get-config-path.mjs +0 -48
  85. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  86. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
@@ -0,0 +1,64 @@
1
+ //#region src/api/core/params.gen.ts
2
+ const extraPrefixes = Object.entries({
3
+ $body_: "body",
4
+ $headers_: "headers",
5
+ $path_: "path",
6
+ $query_: "query"
7
+ });
8
+ const buildKeyMap = (fields, map) => {
9
+ if (!map) map = /* @__PURE__ */ new Map();
10
+ for (const config of fields) if ("in" in config) {
11
+ if (config.key) map.set(config.key, {
12
+ in: config.in,
13
+ map: config.map
14
+ });
15
+ } else if ("key" in config) map.set(config.key, { map: config.map });
16
+ else if (config.args) buildKeyMap(config.args, map);
17
+ return map;
18
+ };
19
+ const stripEmptySlots = (params) => {
20
+ for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Object.keys(value).length) delete params[slot];
21
+ };
22
+ const buildClientParams = (args, fields) => {
23
+ const params = {
24
+ body: {},
25
+ headers: {},
26
+ path: {},
27
+ query: {}
28
+ };
29
+ const map = buildKeyMap(fields);
30
+ let config;
31
+ for (const [index, arg] of args.entries()) {
32
+ if (fields[index]) config = fields[index];
33
+ if (!config) continue;
34
+ if ("in" in config) if (config.key) {
35
+ const field = map.get(config.key);
36
+ const name = field.map || config.key;
37
+ if (field.in) params[field.in][name] = arg;
38
+ } else params.body = arg;
39
+ else for (const [key, value] of Object.entries(arg ?? {})) {
40
+ const field = map.get(key);
41
+ if (field) if (field.in) {
42
+ const name = field.map || key;
43
+ params[field.in][name] = value;
44
+ } else params[field.map] = value;
45
+ else {
46
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
47
+ if (extra) {
48
+ const [prefix, slot] = extra;
49
+ params[slot][key.slice(prefix.length)] = value;
50
+ } else if ("allowExtra" in config && config.allowExtra) {
51
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
52
+ params[slot][key] = value;
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ stripEmptySlots(params);
60
+ return params;
61
+ };
62
+
63
+ //#endregion
64
+ export { buildClientParams as t };
@@ -0,0 +1,70 @@
1
+
2
+ //#region src/api/core/params.gen.ts
3
+ const extraPrefixes = Object.entries({
4
+ $body_: "body",
5
+ $headers_: "headers",
6
+ $path_: "path",
7
+ $query_: "query"
8
+ });
9
+ const buildKeyMap = (fields, map) => {
10
+ if (!map) map = /* @__PURE__ */ new Map();
11
+ for (const config of fields) if ("in" in config) {
12
+ if (config.key) map.set(config.key, {
13
+ in: config.in,
14
+ map: config.map
15
+ });
16
+ } else if ("key" in config) map.set(config.key, { map: config.map });
17
+ else if (config.args) buildKeyMap(config.args, map);
18
+ return map;
19
+ };
20
+ const stripEmptySlots = (params) => {
21
+ for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Object.keys(value).length) delete params[slot];
22
+ };
23
+ const buildClientParams = (args, fields) => {
24
+ const params = {
25
+ body: {},
26
+ headers: {},
27
+ path: {},
28
+ query: {}
29
+ };
30
+ const map = buildKeyMap(fields);
31
+ let config;
32
+ for (const [index, arg] of args.entries()) {
33
+ if (fields[index]) config = fields[index];
34
+ if (!config) continue;
35
+ if ("in" in config) if (config.key) {
36
+ const field = map.get(config.key);
37
+ const name = field.map || config.key;
38
+ if (field.in) params[field.in][name] = arg;
39
+ } else params.body = arg;
40
+ else for (const [key, value] of Object.entries(arg ?? {})) {
41
+ const field = map.get(key);
42
+ if (field) if (field.in) {
43
+ const name = field.map || key;
44
+ params[field.in][name] = value;
45
+ } else params[field.map] = value;
46
+ else {
47
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
48
+ if (extra) {
49
+ const [prefix, slot] = extra;
50
+ params[slot][key.slice(prefix.length)] = value;
51
+ } else if ("allowExtra" in config && config.allowExtra) {
52
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
53
+ params[slot][key] = value;
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ stripEmptySlots(params);
61
+ return params;
62
+ };
63
+
64
+ //#endregion
65
+ Object.defineProperty(exports, 'buildClientParams', {
66
+ enumerable: true,
67
+ get: function () {
68
+ return buildClientParams;
69
+ }
70
+ });
@@ -0,0 +1,117 @@
1
+
2
+ //#region src/api/core/pathSerializer.gen.ts
3
+ const separatorArrayExplode = (style) => {
4
+ switch (style) {
5
+ case "label": return ".";
6
+ case "matrix": return ";";
7
+ case "simple": return ",";
8
+ default: return "&";
9
+ }
10
+ };
11
+ const separatorArrayNoExplode = (style) => {
12
+ switch (style) {
13
+ case "form": return ",";
14
+ case "pipeDelimited": return "|";
15
+ case "spaceDelimited": return "%20";
16
+ default: return ",";
17
+ }
18
+ };
19
+ const separatorObjectExplode = (style) => {
20
+ switch (style) {
21
+ case "label": return ".";
22
+ case "matrix": return ";";
23
+ case "simple": return ",";
24
+ default: return "&";
25
+ }
26
+ };
27
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
28
+ if (!explode) {
29
+ const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
30
+ switch (style) {
31
+ case "label": return `.${joinedValues$1}`;
32
+ case "matrix": return `;${name}=${joinedValues$1}`;
33
+ case "simple": return joinedValues$1;
34
+ default: return `${name}=${joinedValues$1}`;
35
+ }
36
+ }
37
+ const separator = separatorArrayExplode(style);
38
+ const joinedValues = value.map((v) => {
39
+ if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
40
+ return serializePrimitiveParam({
41
+ allowReserved,
42
+ name,
43
+ value: v
44
+ });
45
+ }).join(separator);
46
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
47
+ };
48
+ const serializePrimitiveParam = ({ allowReserved, name, value }) => {
49
+ if (value === void 0 || value === null) return "";
50
+ if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
51
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
52
+ };
53
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
54
+ if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
55
+ if (style !== "deepObject" && !explode) {
56
+ let values = [];
57
+ Object.entries(value).forEach(([key, v]) => {
58
+ values = [
59
+ ...values,
60
+ key,
61
+ allowReserved ? v : encodeURIComponent(v)
62
+ ];
63
+ });
64
+ const joinedValues$1 = values.join(",");
65
+ switch (style) {
66
+ case "form": return `${name}=${joinedValues$1}`;
67
+ case "label": return `.${joinedValues$1}`;
68
+ case "matrix": return `;${name}=${joinedValues$1}`;
69
+ default: return joinedValues$1;
70
+ }
71
+ }
72
+ const separator = separatorObjectExplode(style);
73
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
74
+ allowReserved,
75
+ name: style === "deepObject" ? `${name}[${key}]` : key,
76
+ value: v
77
+ })).join(separator);
78
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
79
+ };
80
+
81
+ //#endregion
82
+ Object.defineProperty(exports, 'separatorArrayExplode', {
83
+ enumerable: true,
84
+ get: function () {
85
+ return separatorArrayExplode;
86
+ }
87
+ });
88
+ Object.defineProperty(exports, 'separatorArrayNoExplode', {
89
+ enumerable: true,
90
+ get: function () {
91
+ return separatorArrayNoExplode;
92
+ }
93
+ });
94
+ Object.defineProperty(exports, 'separatorObjectExplode', {
95
+ enumerable: true,
96
+ get: function () {
97
+ return separatorObjectExplode;
98
+ }
99
+ });
100
+ Object.defineProperty(exports, 'serializeArrayParam', {
101
+ enumerable: true,
102
+ get: function () {
103
+ return serializeArrayParam;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, 'serializeObjectParam', {
107
+ enumerable: true,
108
+ get: function () {
109
+ return serializeObjectParam;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, 'serializePrimitiveParam', {
113
+ enumerable: true,
114
+ get: function () {
115
+ return serializePrimitiveParam;
116
+ }
117
+ });
@@ -0,0 +1,81 @@
1
+ //#region src/api/core/pathSerializer.gen.ts
2
+ const separatorArrayExplode = (style) => {
3
+ switch (style) {
4
+ case "label": return ".";
5
+ case "matrix": return ";";
6
+ case "simple": return ",";
7
+ default: return "&";
8
+ }
9
+ };
10
+ const separatorArrayNoExplode = (style) => {
11
+ switch (style) {
12
+ case "form": return ",";
13
+ case "pipeDelimited": return "|";
14
+ case "spaceDelimited": return "%20";
15
+ default: return ",";
16
+ }
17
+ };
18
+ const separatorObjectExplode = (style) => {
19
+ switch (style) {
20
+ case "label": return ".";
21
+ case "matrix": return ";";
22
+ case "simple": return ",";
23
+ default: return "&";
24
+ }
25
+ };
26
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
27
+ if (!explode) {
28
+ const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
29
+ switch (style) {
30
+ case "label": return `.${joinedValues$1}`;
31
+ case "matrix": return `;${name}=${joinedValues$1}`;
32
+ case "simple": return joinedValues$1;
33
+ default: return `${name}=${joinedValues$1}`;
34
+ }
35
+ }
36
+ const separator = separatorArrayExplode(style);
37
+ const joinedValues = value.map((v) => {
38
+ if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
39
+ return serializePrimitiveParam({
40
+ allowReserved,
41
+ name,
42
+ value: v
43
+ });
44
+ }).join(separator);
45
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
46
+ };
47
+ const serializePrimitiveParam = ({ allowReserved, name, value }) => {
48
+ if (value === void 0 || value === null) return "";
49
+ if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
50
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
51
+ };
52
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
53
+ if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
54
+ if (style !== "deepObject" && !explode) {
55
+ let values = [];
56
+ Object.entries(value).forEach(([key, v]) => {
57
+ values = [
58
+ ...values,
59
+ key,
60
+ allowReserved ? v : encodeURIComponent(v)
61
+ ];
62
+ });
63
+ const joinedValues$1 = values.join(",");
64
+ switch (style) {
65
+ case "form": return `${name}=${joinedValues$1}`;
66
+ case "label": return `.${joinedValues$1}`;
67
+ case "matrix": return `;${name}=${joinedValues$1}`;
68
+ default: return joinedValues$1;
69
+ }
70
+ }
71
+ const separator = separatorObjectExplode(style);
72
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
73
+ allowReserved,
74
+ name: style === "deepObject" ? `${name}[${key}]` : key,
75
+ value: v
76
+ })).join(separator);
77
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
78
+ };
79
+
80
+ //#endregion
81
+ export { serializeObjectParam as a, serializeArrayParam as i, separatorArrayNoExplode as n, serializePrimitiveParam as o, separatorObjectExplode as r, separatorArrayExplode as t };
File without changes
@@ -0,0 +1 @@
1
+ export { };
File without changes
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,15 @@
1
+ //#region src/helpers/prisma-postgres.ts
2
+ /**
3
+ * Find a Postgres database by name.
4
+ *
5
+ * @param context - The Prisma plugin context.
6
+ * @param name - The name of the database to find.
7
+ * @returns The database object if found, otherwise undefined.
8
+ */
9
+ async function findDatabaseByName(context, name) {
10
+ if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
11
+ return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
12
+ }
13
+
14
+ //#endregion
15
+ export { findDatabaseByName as t };
@@ -0,0 +1,21 @@
1
+
2
+ //#region src/helpers/prisma-postgres.ts
3
+ /**
4
+ * Find a Postgres database by name.
5
+ *
6
+ * @param context - The Prisma plugin context.
7
+ * @param name - The name of the database to find.
8
+ * @returns The database object if found, otherwise undefined.
9
+ */
10
+ async function findDatabaseByName(context, name) {
11
+ if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
12
+ return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
13
+ }
14
+
15
+ //#endregion
16
+ Object.defineProperty(exports, 'findDatabaseByName', {
17
+ enumerable: true,
18
+ get: function () {
19
+ return findDatabaseByName;
20
+ }
21
+ });
@@ -0,0 +1,81 @@
1
+
2
+ //#region src/api/core/queryKeySerializer.gen.ts
3
+ /**
4
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
5
+ */
6
+ const queryKeyJsonReplacer = (_key, value) => {
7
+ if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
8
+ if (typeof value === "bigint") return value.toString();
9
+ if (value instanceof Date) return value.toISOString();
10
+ return value;
11
+ };
12
+ /**
13
+ * Safely stringifies a value and parses it back into a JsonValue.
14
+ */
15
+ const stringifyToJsonValue = (input) => {
16
+ try {
17
+ const json = JSON.stringify(input, queryKeyJsonReplacer);
18
+ if (json === void 0) return;
19
+ return JSON.parse(json);
20
+ } catch {
21
+ return;
22
+ }
23
+ };
24
+ /**
25
+ * Detects plain objects (including objects with a null prototype).
26
+ */
27
+ const isPlainObject = (value) => {
28
+ if (value === null || typeof value !== "object") return false;
29
+ const prototype = Object.getPrototypeOf(value);
30
+ return prototype === Object.prototype || prototype === null;
31
+ };
32
+ /**
33
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
34
+ */
35
+ const serializeSearchParams = (params) => {
36
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
37
+ const result = {};
38
+ for (const [key, value] of entries) {
39
+ const existing = result[key];
40
+ if (existing === void 0) {
41
+ result[key] = value;
42
+ continue;
43
+ }
44
+ if (Array.isArray(existing)) existing.push(value);
45
+ else result[key] = [existing, value];
46
+ }
47
+ return result;
48
+ };
49
+ /**
50
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
51
+ */
52
+ const serializeQueryKeyValue = (value) => {
53
+ if (value === null) return null;
54
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
55
+ if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
56
+ if (typeof value === "bigint") return value.toString();
57
+ if (value instanceof Date) return value.toISOString();
58
+ if (Array.isArray(value)) return stringifyToJsonValue(value);
59
+ if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) return serializeSearchParams(value);
60
+ if (isPlainObject(value)) return stringifyToJsonValue(value);
61
+ };
62
+
63
+ //#endregion
64
+ Object.defineProperty(exports, 'queryKeyJsonReplacer', {
65
+ enumerable: true,
66
+ get: function () {
67
+ return queryKeyJsonReplacer;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, 'serializeQueryKeyValue', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return serializeQueryKeyValue;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, 'stringifyToJsonValue', {
77
+ enumerable: true,
78
+ get: function () {
79
+ return stringifyToJsonValue;
80
+ }
81
+ });
@@ -0,0 +1,63 @@
1
+ //#region src/api/core/queryKeySerializer.gen.ts
2
+ /**
3
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
4
+ */
5
+ const queryKeyJsonReplacer = (_key, value) => {
6
+ if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
7
+ if (typeof value === "bigint") return value.toString();
8
+ if (value instanceof Date) return value.toISOString();
9
+ return value;
10
+ };
11
+ /**
12
+ * Safely stringifies a value and parses it back into a JsonValue.
13
+ */
14
+ const stringifyToJsonValue = (input) => {
15
+ try {
16
+ const json = JSON.stringify(input, queryKeyJsonReplacer);
17
+ if (json === void 0) return;
18
+ return JSON.parse(json);
19
+ } catch {
20
+ return;
21
+ }
22
+ };
23
+ /**
24
+ * Detects plain objects (including objects with a null prototype).
25
+ */
26
+ const isPlainObject = (value) => {
27
+ if (value === null || typeof value !== "object") return false;
28
+ const prototype = Object.getPrototypeOf(value);
29
+ return prototype === Object.prototype || prototype === null;
30
+ };
31
+ /**
32
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
33
+ */
34
+ const serializeSearchParams = (params) => {
35
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
36
+ const result = {};
37
+ for (const [key, value] of entries) {
38
+ const existing = result[key];
39
+ if (existing === void 0) {
40
+ result[key] = value;
41
+ continue;
42
+ }
43
+ if (Array.isArray(existing)) existing.push(value);
44
+ else result[key] = [existing, value];
45
+ }
46
+ return result;
47
+ };
48
+ /**
49
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
50
+ */
51
+ const serializeQueryKeyValue = (value) => {
52
+ if (value === null) return null;
53
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
54
+ if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
55
+ if (typeof value === "bigint") return value.toString();
56
+ if (value instanceof Date) return value.toISOString();
57
+ if (Array.isArray(value)) return stringifyToJsonValue(value);
58
+ if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) return serializeSearchParams(value);
59
+ if (isPlainObject(value)) return stringifyToJsonValue(value);
60
+ };
61
+
62
+ //#endregion
63
+ export { serializeQueryKeyValue as n, stringifyToJsonValue as r, queryKeyJsonReplacer as t };
@@ -0,0 +1,60 @@
1
+ import { SchemaCreator } from "prisma-util/schema-creator";
2
+
3
+ //#region src/helpers/schema-creator.ts
4
+ /**
5
+ * Prisma schema creator that allows building a schema via code.
6
+ */
7
+ var PrismaSchemaCreator = class extends SchemaCreator {
8
+ /** Prisma plugin context */
9
+ #context;
10
+ get generators() {
11
+ return this.#context.prisma.schema.generators;
12
+ }
13
+ set generators(value) {
14
+ this.#context.prisma.schema.generators = value;
15
+ }
16
+ constructor(context) {
17
+ super();
18
+ this.#context = context;
19
+ this.#context.prisma ??= {};
20
+ this.#context.prisma.schema ??= {
21
+ generators: [],
22
+ datasources: [],
23
+ warnings: []
24
+ };
25
+ this.#context.prisma.schema.generators.forEach((generator) => {
26
+ this.pushGenerator(generator);
27
+ });
28
+ }
29
+ pushGenerator(generator) {
30
+ if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
31
+ else this.generators.push(generator);
32
+ return this;
33
+ }
34
+ build() {
35
+ let schema = super.build();
36
+ for (const generator of this.generators) schema = `
37
+ generator ${generator.name} {
38
+ provider = "${generator.provider.value}"
39
+ output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
40
+ previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
41
+ if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
42
+ else return `${key} = "${value}"`;
43
+ }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
44
+ binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
45
+ env = {${generator.envPaths?.rootEnvPath ? `
46
+ root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
47
+ schema = "${generator.envPaths.schemaEnvPath}"` : ""}
48
+ }` : ""}
49
+ }
50
+
51
+ ${schema}`;
52
+ return schema;
53
+ }
54
+ async write() {
55
+ await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
56
+ }
57
+ };
58
+
59
+ //#endregion
60
+ export { PrismaSchemaCreator as t };
@@ -0,0 +1,66 @@
1
+ const require_get_schema = require('./get-schema-CqMBOHOd.cjs');
2
+ let prisma_util_schema_creator = require("prisma-util/schema-creator");
3
+
4
+ //#region src/helpers/schema-creator.ts
5
+ /**
6
+ * Prisma schema creator that allows building a schema via code.
7
+ */
8
+ var PrismaSchemaCreator = class extends prisma_util_schema_creator.SchemaCreator {
9
+ /** Prisma plugin context */
10
+ #context;
11
+ get generators() {
12
+ return this.#context.prisma.schema.generators;
13
+ }
14
+ set generators(value) {
15
+ this.#context.prisma.schema.generators = value;
16
+ }
17
+ constructor(context) {
18
+ super();
19
+ this.#context = context;
20
+ this.#context.prisma ??= {};
21
+ this.#context.prisma.schema ??= {
22
+ generators: [],
23
+ datasources: [],
24
+ warnings: []
25
+ };
26
+ this.#context.prisma.schema.generators.forEach((generator) => {
27
+ this.pushGenerator(generator);
28
+ });
29
+ }
30
+ pushGenerator(generator) {
31
+ if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
32
+ else this.generators.push(generator);
33
+ return this;
34
+ }
35
+ build() {
36
+ let schema = super.build();
37
+ for (const generator of this.generators) schema = `
38
+ generator ${generator.name} {
39
+ provider = "${generator.provider.value}"
40
+ output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
41
+ previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
42
+ if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
43
+ else return `${key} = "${value}"`;
44
+ }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
45
+ binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
46
+ env = {${generator.envPaths?.rootEnvPath ? `
47
+ root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
48
+ schema = "${generator.envPaths.schemaEnvPath}"` : ""}
49
+ }` : ""}
50
+ }
51
+
52
+ ${schema}`;
53
+ return schema;
54
+ }
55
+ async write() {
56
+ await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
57
+ }
58
+ };
59
+
60
+ //#endregion
61
+ Object.defineProperty(exports, 'PrismaSchemaCreator', {
62
+ enumerable: true,
63
+ get: function () {
64
+ return PrismaSchemaCreator;
65
+ }
66
+ });