@powerlines/plugin-prisma 0.4.30 → 0.4.31

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/client-generator-AkVOcQPr.mjs +146 -0
  3. package/dist/client-generator-B8dwKgp9.mjs +146 -0
  4. package/dist/client-generator-BAc2oiYI.cjs +152 -0
  5. package/dist/client-generator-Wdm31y35.cjs +152 -0
  6. package/dist/get-schema-Dq1-Jwvo.cjs +138 -0
  7. package/dist/helpers/client-generator.cjs +4 -0
  8. package/dist/helpers/client-generator.mjs +3 -0
  9. package/dist/helpers/get-schema.cjs +2 -80
  10. package/dist/helpers/get-schema.mjs +24 -4
  11. package/dist/helpers/index.cjs +6 -4
  12. package/dist/helpers/index.mjs +3 -2
  13. package/dist/helpers/schema-creator.cjs +1 -1
  14. package/dist/helpers/typed-sql.cjs +38 -0
  15. package/dist/helpers/typed-sql.mjs +36 -0
  16. package/dist/index.cjs +71 -42
  17. package/dist/index.mjs +68 -38
  18. package/dist/types/index.cjs +2 -0
  19. package/dist/types/index.mjs +3 -0
  20. package/package.json +45 -249
  21. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  22. package/dist/_virtual/_rolldown/runtime.mjs +0 -3
  23. package/dist/api/client/client.gen.cjs +0 -176
  24. package/dist/api/client/client.gen.mjs +0 -175
  25. package/dist/api/client/index.cjs +0 -15
  26. package/dist/api/client/index.mjs +0 -7
  27. package/dist/api/client/types.gen.cjs +0 -0
  28. package/dist/api/client/types.gen.mjs +0 -1
  29. package/dist/api/client/utils.gen.cjs +0 -187
  30. package/dist/api/client/utils.gen.mjs +0 -179
  31. package/dist/api/client.gen.cjs +0 -10
  32. package/dist/api/client.gen.mjs +0 -9
  33. package/dist/api/core/auth.gen.cjs +0 -13
  34. package/dist/api/core/auth.gen.mjs +0 -11
  35. package/dist/api/core/bodySerializer.gen.cjs +0 -36
  36. package/dist/api/core/bodySerializer.gen.mjs +0 -32
  37. package/dist/api/core/params.gen.cjs +0 -66
  38. package/dist/api/core/params.gen.mjs +0 -64
  39. package/dist/api/core/pathSerializer.gen.cjs +0 -88
  40. package/dist/api/core/pathSerializer.gen.mjs +0 -81
  41. package/dist/api/core/queryKeySerializer.gen.cjs +0 -67
  42. package/dist/api/core/queryKeySerializer.gen.mjs +0 -63
  43. package/dist/api/core/serverSentEvents.gen.cjs +0 -96
  44. package/dist/api/core/serverSentEvents.gen.mjs +0 -94
  45. package/dist/api/core/types.gen.cjs +0 -0
  46. package/dist/api/core/types.gen.mjs +0 -1
  47. package/dist/api/core/utils.gen.cjs +0 -82
  48. package/dist/api/core/utils.gen.mjs +0 -78
  49. package/dist/api/sdk.gen.cjs +0 -405
  50. package/dist/api/sdk.gen.mjs +0 -404
  51. package/dist/api/types.gen.cjs +0 -0
  52. package/dist/api/types.gen.mjs +0 -1
  53. package/dist/generator.cjs +0 -15
  54. package/dist/generator.mjs +0 -15
  55. package/dist/helpers/prisma-postgres.cjs +0 -17
  56. package/dist/helpers/prisma-postgres.mjs +0 -15
@@ -1,63 +0,0 @@
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 { queryKeyJsonReplacer, serializeQueryKeyValue, stringifyToJsonValue };
@@ -1,96 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/api/core/serverSentEvents.gen.ts
4
- const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
5
- let lastEventId;
6
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
7
- const createStream = async function* () {
8
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
9
- let attempt = 0;
10
- const signal = options.signal ?? new AbortController().signal;
11
- while (true) {
12
- if (signal.aborted) break;
13
- attempt++;
14
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
15
- if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
16
- try {
17
- const requestInit = {
18
- redirect: "follow",
19
- ...options,
20
- body: options.serializedBody,
21
- headers,
22
- signal
23
- };
24
- let request = new Request(url, requestInit);
25
- if (onRequest) request = await onRequest(url, requestInit);
26
- const response = await (options.fetch ?? globalThis.fetch)(request);
27
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
28
- if (!response.body) throw new Error("No body in SSE response");
29
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
30
- let buffer = "";
31
- const abortHandler = () => {
32
- try {
33
- reader.cancel();
34
- } catch {}
35
- };
36
- signal.addEventListener("abort", abortHandler);
37
- try {
38
- while (true) {
39
- const { done, value } = await reader.read();
40
- if (done) break;
41
- buffer += value;
42
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
43
- const chunks = buffer.split("\n\n");
44
- buffer = chunks.pop() ?? "";
45
- for (const chunk of chunks) {
46
- const lines = chunk.split("\n");
47
- const dataLines = [];
48
- let eventName;
49
- for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
50
- else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
51
- else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
52
- else if (line.startsWith("retry:")) {
53
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
54
- if (!Number.isNaN(parsed)) retryDelay = parsed;
55
- }
56
- let data;
57
- let parsedJson = false;
58
- if (dataLines.length) {
59
- const rawData = dataLines.join("\n");
60
- try {
61
- data = JSON.parse(rawData);
62
- parsedJson = true;
63
- } catch {
64
- data = rawData;
65
- }
66
- }
67
- if (parsedJson) {
68
- if (responseValidator) await responseValidator(data);
69
- if (responseTransformer) data = await responseTransformer(data);
70
- }
71
- onSseEvent?.({
72
- data,
73
- event: eventName,
74
- id: lastEventId,
75
- retry: retryDelay
76
- });
77
- if (dataLines.length) yield data;
78
- }
79
- }
80
- } finally {
81
- signal.removeEventListener("abort", abortHandler);
82
- reader.releaseLock();
83
- }
84
- break;
85
- } catch (error) {
86
- onSseError?.(error);
87
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
88
- await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
89
- }
90
- }
91
- };
92
- return { stream: createStream() };
93
- };
94
-
95
- //#endregion
96
- exports.createSseClient = createSseClient;
@@ -1,94 +0,0 @@
1
- //#region src/api/core/serverSentEvents.gen.ts
2
- const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
3
- let lastEventId;
4
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
5
- const createStream = async function* () {
6
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
7
- let attempt = 0;
8
- const signal = options.signal ?? new AbortController().signal;
9
- while (true) {
10
- if (signal.aborted) break;
11
- attempt++;
12
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
13
- if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
14
- try {
15
- const requestInit = {
16
- redirect: "follow",
17
- ...options,
18
- body: options.serializedBody,
19
- headers,
20
- signal
21
- };
22
- let request = new Request(url, requestInit);
23
- if (onRequest) request = await onRequest(url, requestInit);
24
- const response = await (options.fetch ?? globalThis.fetch)(request);
25
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
26
- if (!response.body) throw new Error("No body in SSE response");
27
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
28
- let buffer = "";
29
- const abortHandler = () => {
30
- try {
31
- reader.cancel();
32
- } catch {}
33
- };
34
- signal.addEventListener("abort", abortHandler);
35
- try {
36
- while (true) {
37
- const { done, value } = await reader.read();
38
- if (done) break;
39
- buffer += value;
40
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
41
- const chunks = buffer.split("\n\n");
42
- buffer = chunks.pop() ?? "";
43
- for (const chunk of chunks) {
44
- const lines = chunk.split("\n");
45
- const dataLines = [];
46
- let eventName;
47
- for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
48
- else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
49
- else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
50
- else if (line.startsWith("retry:")) {
51
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
52
- if (!Number.isNaN(parsed)) retryDelay = parsed;
53
- }
54
- let data;
55
- let parsedJson = false;
56
- if (dataLines.length) {
57
- const rawData = dataLines.join("\n");
58
- try {
59
- data = JSON.parse(rawData);
60
- parsedJson = true;
61
- } catch {
62
- data = rawData;
63
- }
64
- }
65
- if (parsedJson) {
66
- if (responseValidator) await responseValidator(data);
67
- if (responseTransformer) data = await responseTransformer(data);
68
- }
69
- onSseEvent?.({
70
- data,
71
- event: eventName,
72
- id: lastEventId,
73
- retry: retryDelay
74
- });
75
- if (dataLines.length) yield data;
76
- }
77
- }
78
- } finally {
79
- signal.removeEventListener("abort", abortHandler);
80
- reader.releaseLock();
81
- }
82
- break;
83
- } catch (error) {
84
- onSseError?.(error);
85
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
86
- await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
87
- }
88
- }
89
- };
90
- return { stream: createStream() };
91
- };
92
-
93
- //#endregion
94
- export { createSseClient };
File without changes
@@ -1 +0,0 @@
1
- export { };
@@ -1,82 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_api_core_pathSerializer_gen = require('./pathSerializer.gen.cjs');
3
-
4
- //#region src/api/core/utils.gen.ts
5
- const PATH_PARAM_RE = /\{[^{}]+\}/g;
6
- const defaultPathSerializer = ({ path, url: _url }) => {
7
- let url = _url;
8
- const matches = _url.match(PATH_PARAM_RE);
9
- if (matches) for (const match of matches) {
10
- let explode = false;
11
- let name = match.substring(1, match.length - 1);
12
- let style = "simple";
13
- if (name.endsWith("*")) {
14
- explode = true;
15
- name = name.substring(0, name.length - 1);
16
- }
17
- if (name.startsWith(".")) {
18
- name = name.substring(1);
19
- style = "label";
20
- } else if (name.startsWith(";")) {
21
- name = name.substring(1);
22
- style = "matrix";
23
- }
24
- const value = path[name];
25
- if (value === void 0 || value === null) continue;
26
- if (Array.isArray(value)) {
27
- url = url.replace(match, require_api_core_pathSerializer_gen.serializeArrayParam({
28
- explode,
29
- name,
30
- style,
31
- value
32
- }));
33
- continue;
34
- }
35
- if (typeof value === "object") {
36
- url = url.replace(match, require_api_core_pathSerializer_gen.serializeObjectParam({
37
- explode,
38
- name,
39
- style,
40
- value,
41
- valueOnly: true
42
- }));
43
- continue;
44
- }
45
- if (style === "matrix") {
46
- url = url.replace(match, `;${require_api_core_pathSerializer_gen.serializePrimitiveParam({
47
- name,
48
- value
49
- })}`);
50
- continue;
51
- }
52
- const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
53
- url = url.replace(match, replaceValue);
54
- }
55
- return url;
56
- };
57
- const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
58
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
59
- let url = (baseUrl ?? "") + pathUrl;
60
- if (path) url = defaultPathSerializer({
61
- path,
62
- url
63
- });
64
- let search = query ? querySerializer(query) : "";
65
- if (search.startsWith("?")) search = search.substring(1);
66
- if (search) url += `?${search}`;
67
- return url;
68
- };
69
- function getValidRequestBody(options) {
70
- const hasBody = options.body !== void 0;
71
- if (hasBody && options.bodySerializer) {
72
- if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
73
- return options.body !== "" ? options.body : null;
74
- }
75
- if (hasBody) return options.body;
76
- }
77
-
78
- //#endregion
79
- exports.PATH_PARAM_RE = PATH_PARAM_RE;
80
- exports.defaultPathSerializer = defaultPathSerializer;
81
- exports.getUrl = getUrl;
82
- exports.getValidRequestBody = getValidRequestBody;
@@ -1,78 +0,0 @@
1
- import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "./pathSerializer.gen.mjs";
2
-
3
- //#region src/api/core/utils.gen.ts
4
- const PATH_PARAM_RE = /\{[^{}]+\}/g;
5
- const defaultPathSerializer = ({ path, url: _url }) => {
6
- let url = _url;
7
- const matches = _url.match(PATH_PARAM_RE);
8
- if (matches) for (const match of matches) {
9
- let explode = false;
10
- let name = match.substring(1, match.length - 1);
11
- let style = "simple";
12
- if (name.endsWith("*")) {
13
- explode = true;
14
- name = name.substring(0, name.length - 1);
15
- }
16
- if (name.startsWith(".")) {
17
- name = name.substring(1);
18
- style = "label";
19
- } else if (name.startsWith(";")) {
20
- name = name.substring(1);
21
- style = "matrix";
22
- }
23
- const value = path[name];
24
- if (value === void 0 || value === null) continue;
25
- if (Array.isArray(value)) {
26
- url = url.replace(match, serializeArrayParam({
27
- explode,
28
- name,
29
- style,
30
- value
31
- }));
32
- continue;
33
- }
34
- if (typeof value === "object") {
35
- url = url.replace(match, serializeObjectParam({
36
- explode,
37
- name,
38
- style,
39
- value,
40
- valueOnly: true
41
- }));
42
- continue;
43
- }
44
- if (style === "matrix") {
45
- url = url.replace(match, `;${serializePrimitiveParam({
46
- name,
47
- value
48
- })}`);
49
- continue;
50
- }
51
- const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
52
- url = url.replace(match, replaceValue);
53
- }
54
- return url;
55
- };
56
- const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
57
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
58
- let url = (baseUrl ?? "") + pathUrl;
59
- if (path) url = defaultPathSerializer({
60
- path,
61
- url
62
- });
63
- let search = query ? querySerializer(query) : "";
64
- if (search.startsWith("?")) search = search.substring(1);
65
- if (search) url += `?${search}`;
66
- return url;
67
- };
68
- function getValidRequestBody(options) {
69
- const hasBody = options.body !== void 0;
70
- if (hasBody && options.bodySerializer) {
71
- if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
72
- return options.body !== "" ? options.body : null;
73
- }
74
- if (hasBody) return options.body;
75
- }
76
-
77
- //#endregion
78
- export { PATH_PARAM_RE, defaultPathSerializer, getUrl, getValidRequestBody };