@powerlines/plugin-prisma 0.2.207 → 0.2.209

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 (82) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/api/client/client.gen.cjs +175 -8
  3. package/dist/api/client/client.gen.mjs +174 -7
  4. package/dist/api/client/index.cjs +13 -18
  5. package/dist/api/client/index.mjs +5 -10
  6. package/dist/api/client/utils.gen.cjs +186 -13
  7. package/dist/api/client/utils.gen.mjs +178 -5
  8. package/dist/api/client.gen.cjs +8 -12
  9. package/dist/api/client.gen.mjs +7 -11
  10. package/dist/api/core/auth.gen.cjs +11 -2
  11. package/dist/api/core/auth.gen.mjs +9 -1
  12. package/dist/api/core/bodySerializer.gen.cjs +34 -4
  13. package/dist/api/core/bodySerializer.gen.mjs +30 -1
  14. package/dist/api/core/params.gen.cjs +64 -2
  15. package/dist/api/core/params.gen.mjs +62 -1
  16. package/dist/api/core/pathSerializer.gen.cjs +86 -7
  17. package/dist/api/core/pathSerializer.gen.mjs +79 -1
  18. package/dist/api/core/queryKeySerializer.gen.cjs +65 -4
  19. package/dist/api/core/queryKeySerializer.gen.mjs +61 -1
  20. package/dist/api/core/serverSentEvents.gen.cjs +94 -2
  21. package/dist/api/core/serverSentEvents.gen.mjs +92 -1
  22. package/dist/api/core/utils.gen.cjs +80 -6
  23. package/dist/api/core/utils.gen.mjs +76 -2
  24. package/dist/api/sdk.gen.cjs +255 -13
  25. package/dist/api/sdk.gen.mjs +254 -12
  26. package/dist/api/types.gen.cjs +0 -1
  27. package/dist/api/types.gen.mjs +0 -2
  28. package/dist/helpers/get-schema.cjs +80 -2
  29. package/dist/helpers/get-schema.mjs +76 -1
  30. package/dist/helpers/index.cjs +6 -6
  31. package/dist/helpers/index.mjs +3 -3
  32. package/dist/helpers/prisma-postgres.cjs +15 -2
  33. package/dist/helpers/prisma-postgres.mjs +13 -1
  34. package/dist/helpers/schema-creator.cjs +60 -2
  35. package/dist/helpers/schema-creator.mjs +58 -1
  36. package/dist/index.cjs +14 -25
  37. package/dist/index.mjs +6 -18
  38. package/dist/types/index.cjs +0 -3
  39. package/dist/types/index.mjs +0 -4
  40. package/dist/types/plugin.cjs +0 -1
  41. package/dist/types/plugin.mjs +0 -2
  42. package/dist/types/prisma.cjs +0 -1
  43. package/dist/types/prisma.mjs +0 -2
  44. package/package.json +5 -5
  45. package/dist/auth.gen-BFteuMTV.cjs +0 -17
  46. package/dist/auth.gen-C4FxE4_3.mjs +0 -11
  47. package/dist/bodySerializer.gen-BLtxkFoA.cjs +0 -50
  48. package/dist/bodySerializer.gen-DBXNewIA.mjs +0 -32
  49. package/dist/client-BlRUW8mL.mjs +0 -1
  50. package/dist/client-DBAc9HV1.cjs +0 -0
  51. package/dist/client.gen-COMS1glH.mjs +0 -8
  52. package/dist/client.gen-CPQm4WCv.mjs +0 -176
  53. package/dist/client.gen-DPSMNZNm.cjs +0 -181
  54. package/dist/client.gen-JhYC1fDf.cjs +0 -13
  55. package/dist/get-schema-CKw6MiKb.mjs +0 -78
  56. package/dist/get-schema-CqMBOHOd.cjs +0 -118
  57. package/dist/params.gen-BM1l95BD.mjs +0 -64
  58. package/dist/params.gen-BtCSnwiV.cjs +0 -70
  59. package/dist/pathSerializer.gen-BEbuI0Vn.cjs +0 -117
  60. package/dist/pathSerializer.gen-m7BRzH23.mjs +0 -81
  61. package/dist/plugin-DE9fKOLA.cjs +0 -0
  62. package/dist/plugin-EFmNQLKA.mjs +0 -1
  63. package/dist/prisma-BzQJneyW.cjs +0 -0
  64. package/dist/prisma-CB-m5c-j.mjs +0 -1
  65. package/dist/prisma-postgres-CAOpTtWq.mjs +0 -15
  66. package/dist/prisma-postgres-dGaLzxF3.cjs +0 -21
  67. package/dist/queryKeySerializer.gen-4TWHHXn3.cjs +0 -81
  68. package/dist/queryKeySerializer.gen-BMMZAjVN.mjs +0 -63
  69. package/dist/schema-creator-Cfian3ih.mjs +0 -60
  70. package/dist/schema-creator-zmlwh4-l.cjs +0 -66
  71. package/dist/sdk.gen-B2his2jD.mjs +0 -256
  72. package/dist/sdk.gen-CAWIQ8BM.cjs +0 -261
  73. package/dist/serverSentEvents.gen-C4apQvDl.mjs +0 -94
  74. package/dist/serverSentEvents.gen-CiMMmhyQ.cjs +0 -100
  75. package/dist/types-CmY9-4ff.cjs +0 -0
  76. package/dist/types-Dbwx-Khg.mjs +0 -1
  77. package/dist/types.gen-BN-p9nVT.cjs +0 -0
  78. package/dist/types.gen-CS2KiRfG.mjs +0 -1
  79. package/dist/utils.gen-Bk2pTkV1.cjs +0 -101
  80. package/dist/utils.gen-C-7sZa7Z.mjs +0 -180
  81. package/dist/utils.gen-DATakax-.cjs +0 -227
  82. package/dist/utils.gen-RO8GxC4i.mjs +0 -78
@@ -1,14 +1,256 @@
1
- require('../serverSentEvents.gen-CiMMmhyQ.cjs');
2
- require('../pathSerializer.gen-BEbuI0Vn.cjs');
3
- require('../utils.gen-Bk2pTkV1.cjs');
4
- require('../auth.gen-BFteuMTV.cjs');
5
- require('../bodySerializer.gen-BLtxkFoA.cjs');
6
- require('../utils.gen-DATakax-.cjs');
7
- require('../client.gen-DPSMNZNm.cjs');
8
- require('../params.gen-BtCSnwiV.cjs');
9
- require('../queryKeySerializer.gen-4TWHHXn3.cjs');
10
- require('../client-DBAc9HV1.cjs');
11
- require('../client.gen-JhYC1fDf.cjs');
12
- const require_sdk_gen = require('../sdk.gen-CAWIQ8BM.cjs');
1
+ const require_api_client_gen = require('./client.gen.cjs');
13
2
 
14
- exports.PrismaClient = require_sdk_gen.PrismaClient;
3
+ //#region src/api/sdk.gen.ts
4
+ var HeyApiClient = class {
5
+ client;
6
+ constructor(args) {
7
+ this.client = args?.client ?? require_api_client_gen.client;
8
+ }
9
+ };
10
+ var HeyApiRegistry = class {
11
+ defaultKey = "default";
12
+ instances = /* @__PURE__ */ new Map();
13
+ get(key) {
14
+ const instance = this.instances.get(key ?? this.defaultKey);
15
+ if (!instance) throw new Error(`No SDK client found. Create one with "new PrismaClient()" to fix this error.`);
16
+ return instance;
17
+ }
18
+ set(value, key) {
19
+ this.instances.set(key ?? this.defaultKey, value);
20
+ }
21
+ };
22
+ var PrismaClient = class PrismaClient extends HeyApiClient {
23
+ static __registry = new HeyApiRegistry();
24
+ constructor(args) {
25
+ super(args);
26
+ PrismaClient.__registry.set(this, args?.key);
27
+ }
28
+ /**
29
+ * Delete database connection string
30
+ *
31
+ * Deletes the database connection string with the given ID.
32
+ */
33
+ deleteDatabaseConnectionString(options) {
34
+ return (options.client ?? this.client).delete({
35
+ url: "/v1/connections/{id}",
36
+ ...options
37
+ });
38
+ }
39
+ /**
40
+ * Delete database
41
+ *
42
+ * Deletes the database with the given ID.
43
+ */
44
+ deleteDatabase(options) {
45
+ return (options.client ?? this.client).delete({
46
+ url: "/v1/databases/{databaseId}",
47
+ ...options
48
+ });
49
+ }
50
+ /**
51
+ * Get database
52
+ *
53
+ * Returns the database with the given ID.
54
+ */
55
+ getDatabase(options) {
56
+ return (options.client ?? this.client).get({
57
+ url: "/v1/databases/{databaseId}",
58
+ ...options
59
+ });
60
+ }
61
+ /**
62
+ * Get list of database connections
63
+ *
64
+ * Returns all connections for the given database.
65
+ */
66
+ listDatabaseConnections(options) {
67
+ return (options.client ?? this.client).get({
68
+ url: "/v1/databases/{databaseId}/connections",
69
+ ...options
70
+ });
71
+ }
72
+ /**
73
+ * Create database connection string
74
+ *
75
+ * Creates a new connection string for the given database.
76
+ */
77
+ createDatabaseConnectionString(options) {
78
+ return (options.client ?? this.client).post({
79
+ url: "/v1/databases/{databaseId}/connections",
80
+ ...options,
81
+ headers: {
82
+ "Content-Type": "application/json",
83
+ ...options.headers
84
+ }
85
+ });
86
+ }
87
+ /**
88
+ * Get list of backups
89
+ *
90
+ * Returns backups for the specified database.
91
+ */
92
+ listBackups(options) {
93
+ return (options.client ?? this.client).get({
94
+ url: "/v1/databases/{databaseId}/backups",
95
+ ...options
96
+ });
97
+ }
98
+ /**
99
+ * Get database usage metrics
100
+ *
101
+ * Returns usage metrics for the specified database.
102
+ */
103
+ getDatabaseUsageMetrics(options) {
104
+ return (options.client ?? this.client).get({
105
+ url: "/v1/databases/{databaseId}/usage",
106
+ ...options
107
+ });
108
+ }
109
+ /**
110
+ * Get list of projects
111
+ *
112
+ * Returns the list of projects the token has access to.
113
+ */
114
+ listProjects(options) {
115
+ return (options?.client ?? this.client).get({
116
+ url: "/v1/projects",
117
+ ...options
118
+ });
119
+ }
120
+ /**
121
+ * Create project with a postgres database
122
+ *
123
+ * Creates a new project with a postgres database.
124
+ */
125
+ createProjectWithPostgresDatabase(options) {
126
+ return (options?.client ?? this.client).post({
127
+ url: "/v1/projects",
128
+ ...options,
129
+ headers: {
130
+ "Content-Type": "application/json",
131
+ ...options?.headers
132
+ }
133
+ });
134
+ }
135
+ /**
136
+ * Delete project
137
+ *
138
+ * Deletes the project with the given ID.
139
+ */
140
+ deleteProject(options) {
141
+ return (options.client ?? this.client).delete({
142
+ url: "/v1/projects/{id}",
143
+ ...options
144
+ });
145
+ }
146
+ /**
147
+ * Get project
148
+ *
149
+ * Returns the project with the given ID.
150
+ */
151
+ getProject(options) {
152
+ return (options.client ?? this.client).get({
153
+ url: "/v1/projects/{id}",
154
+ ...options
155
+ });
156
+ }
157
+ /**
158
+ * Transfer project
159
+ *
160
+ * Transfer the project with the given ID to the new owner's workspace
161
+ */
162
+ transferProject(options) {
163
+ return (options.client ?? this.client).post({
164
+ url: "/v1/projects/{id}/transfer",
165
+ ...options,
166
+ headers: {
167
+ "Content-Type": "application/json",
168
+ ...options.headers
169
+ }
170
+ });
171
+ }
172
+ /**
173
+ * Get list of databases
174
+ *
175
+ * Returns databases for the given project.
176
+ */
177
+ listDatabases(options) {
178
+ return (options.client ?? this.client).get({
179
+ url: "/v1/projects/{projectId}/databases",
180
+ ...options
181
+ });
182
+ }
183
+ /**
184
+ * Create database
185
+ *
186
+ * Creates a new database for the given project.
187
+ */
188
+ createDatabase(options) {
189
+ return (options.client ?? this.client).post({
190
+ url: "/v1/projects/{projectId}/databases",
191
+ ...options,
192
+ headers: {
193
+ "Content-Type": "application/json",
194
+ ...options.headers
195
+ }
196
+ });
197
+ }
198
+ /**
199
+ * Get list of integrations
200
+ *
201
+ * Returns integrations for the given workspace.
202
+ */
203
+ listIntegrations(options) {
204
+ return (options.client ?? this.client).get({
205
+ url: "/v1/workspaces/{workspaceId}/integrations",
206
+ ...options
207
+ });
208
+ }
209
+ /**
210
+ * Revoke integration tokens
211
+ *
212
+ * Revokes the integration tokens with the given client ID.
213
+ */
214
+ revokeIntegrationTokens(options) {
215
+ return (options.client ?? this.client).delete({
216
+ url: "/v1/workspaces/{workspaceId}/integrations/{clientId}",
217
+ ...options
218
+ });
219
+ }
220
+ /**
221
+ * Get Prisma Postgres regions
222
+ *
223
+ * Returns all available regions for Prisma Postgres.
224
+ */
225
+ getPrismaPostgresRegions(options) {
226
+ return (options?.client ?? this.client).get({
227
+ url: "/v1/regions/postgres",
228
+ ...options
229
+ });
230
+ }
231
+ /**
232
+ * Get Prisma Accelerate regions
233
+ *
234
+ * Returns all available regions for Prisma Accelerate.
235
+ */
236
+ getPrismaAccelerateRegions(options) {
237
+ return (options?.client ?? this.client).get({
238
+ url: "/v1/regions/accelerate",
239
+ ...options
240
+ });
241
+ }
242
+ /**
243
+ * Get list of workspaces
244
+ *
245
+ * Returns the list of workspaces the current token can access.
246
+ */
247
+ listWorkspaces(options) {
248
+ return (options?.client ?? this.client).get({
249
+ url: "/v1/workspaces",
250
+ ...options
251
+ });
252
+ }
253
+ };
254
+
255
+ //#endregion
256
+ exports.PrismaClient = PrismaClient;
@@ -1,14 +1,256 @@
1
- import "../serverSentEvents.gen-C4apQvDl.mjs";
2
- import "../pathSerializer.gen-m7BRzH23.mjs";
3
- import "../utils.gen-RO8GxC4i.mjs";
4
- import "../auth.gen-C4FxE4_3.mjs";
5
- import "../bodySerializer.gen-DBXNewIA.mjs";
6
- import "../utils.gen-C-7sZa7Z.mjs";
7
- import "../client.gen-CPQm4WCv.mjs";
8
- import "../params.gen-BM1l95BD.mjs";
9
- import "../queryKeySerializer.gen-BMMZAjVN.mjs";
10
- import "../client-BlRUW8mL.mjs";
11
- import "../client.gen-COMS1glH.mjs";
12
- import { t as PrismaClient } from "../sdk.gen-B2his2jD.mjs";
1
+ import { client } from "./client.gen.mjs";
13
2
 
3
+ //#region src/api/sdk.gen.ts
4
+ var HeyApiClient = class {
5
+ client;
6
+ constructor(args) {
7
+ this.client = args?.client ?? client;
8
+ }
9
+ };
10
+ var HeyApiRegistry = class {
11
+ defaultKey = "default";
12
+ instances = /* @__PURE__ */ new Map();
13
+ get(key) {
14
+ const instance = this.instances.get(key ?? this.defaultKey);
15
+ if (!instance) throw new Error(`No SDK client found. Create one with "new PrismaClient()" to fix this error.`);
16
+ return instance;
17
+ }
18
+ set(value, key) {
19
+ this.instances.set(key ?? this.defaultKey, value);
20
+ }
21
+ };
22
+ var PrismaClient = class PrismaClient extends HeyApiClient {
23
+ static __registry = new HeyApiRegistry();
24
+ constructor(args) {
25
+ super(args);
26
+ PrismaClient.__registry.set(this, args?.key);
27
+ }
28
+ /**
29
+ * Delete database connection string
30
+ *
31
+ * Deletes the database connection string with the given ID.
32
+ */
33
+ deleteDatabaseConnectionString(options) {
34
+ return (options.client ?? this.client).delete({
35
+ url: "/v1/connections/{id}",
36
+ ...options
37
+ });
38
+ }
39
+ /**
40
+ * Delete database
41
+ *
42
+ * Deletes the database with the given ID.
43
+ */
44
+ deleteDatabase(options) {
45
+ return (options.client ?? this.client).delete({
46
+ url: "/v1/databases/{databaseId}",
47
+ ...options
48
+ });
49
+ }
50
+ /**
51
+ * Get database
52
+ *
53
+ * Returns the database with the given ID.
54
+ */
55
+ getDatabase(options) {
56
+ return (options.client ?? this.client).get({
57
+ url: "/v1/databases/{databaseId}",
58
+ ...options
59
+ });
60
+ }
61
+ /**
62
+ * Get list of database connections
63
+ *
64
+ * Returns all connections for the given database.
65
+ */
66
+ listDatabaseConnections(options) {
67
+ return (options.client ?? this.client).get({
68
+ url: "/v1/databases/{databaseId}/connections",
69
+ ...options
70
+ });
71
+ }
72
+ /**
73
+ * Create database connection string
74
+ *
75
+ * Creates a new connection string for the given database.
76
+ */
77
+ createDatabaseConnectionString(options) {
78
+ return (options.client ?? this.client).post({
79
+ url: "/v1/databases/{databaseId}/connections",
80
+ ...options,
81
+ headers: {
82
+ "Content-Type": "application/json",
83
+ ...options.headers
84
+ }
85
+ });
86
+ }
87
+ /**
88
+ * Get list of backups
89
+ *
90
+ * Returns backups for the specified database.
91
+ */
92
+ listBackups(options) {
93
+ return (options.client ?? this.client).get({
94
+ url: "/v1/databases/{databaseId}/backups",
95
+ ...options
96
+ });
97
+ }
98
+ /**
99
+ * Get database usage metrics
100
+ *
101
+ * Returns usage metrics for the specified database.
102
+ */
103
+ getDatabaseUsageMetrics(options) {
104
+ return (options.client ?? this.client).get({
105
+ url: "/v1/databases/{databaseId}/usage",
106
+ ...options
107
+ });
108
+ }
109
+ /**
110
+ * Get list of projects
111
+ *
112
+ * Returns the list of projects the token has access to.
113
+ */
114
+ listProjects(options) {
115
+ return (options?.client ?? this.client).get({
116
+ url: "/v1/projects",
117
+ ...options
118
+ });
119
+ }
120
+ /**
121
+ * Create project with a postgres database
122
+ *
123
+ * Creates a new project with a postgres database.
124
+ */
125
+ createProjectWithPostgresDatabase(options) {
126
+ return (options?.client ?? this.client).post({
127
+ url: "/v1/projects",
128
+ ...options,
129
+ headers: {
130
+ "Content-Type": "application/json",
131
+ ...options?.headers
132
+ }
133
+ });
134
+ }
135
+ /**
136
+ * Delete project
137
+ *
138
+ * Deletes the project with the given ID.
139
+ */
140
+ deleteProject(options) {
141
+ return (options.client ?? this.client).delete({
142
+ url: "/v1/projects/{id}",
143
+ ...options
144
+ });
145
+ }
146
+ /**
147
+ * Get project
148
+ *
149
+ * Returns the project with the given ID.
150
+ */
151
+ getProject(options) {
152
+ return (options.client ?? this.client).get({
153
+ url: "/v1/projects/{id}",
154
+ ...options
155
+ });
156
+ }
157
+ /**
158
+ * Transfer project
159
+ *
160
+ * Transfer the project with the given ID to the new owner's workspace
161
+ */
162
+ transferProject(options) {
163
+ return (options.client ?? this.client).post({
164
+ url: "/v1/projects/{id}/transfer",
165
+ ...options,
166
+ headers: {
167
+ "Content-Type": "application/json",
168
+ ...options.headers
169
+ }
170
+ });
171
+ }
172
+ /**
173
+ * Get list of databases
174
+ *
175
+ * Returns databases for the given project.
176
+ */
177
+ listDatabases(options) {
178
+ return (options.client ?? this.client).get({
179
+ url: "/v1/projects/{projectId}/databases",
180
+ ...options
181
+ });
182
+ }
183
+ /**
184
+ * Create database
185
+ *
186
+ * Creates a new database for the given project.
187
+ */
188
+ createDatabase(options) {
189
+ return (options.client ?? this.client).post({
190
+ url: "/v1/projects/{projectId}/databases",
191
+ ...options,
192
+ headers: {
193
+ "Content-Type": "application/json",
194
+ ...options.headers
195
+ }
196
+ });
197
+ }
198
+ /**
199
+ * Get list of integrations
200
+ *
201
+ * Returns integrations for the given workspace.
202
+ */
203
+ listIntegrations(options) {
204
+ return (options.client ?? this.client).get({
205
+ url: "/v1/workspaces/{workspaceId}/integrations",
206
+ ...options
207
+ });
208
+ }
209
+ /**
210
+ * Revoke integration tokens
211
+ *
212
+ * Revokes the integration tokens with the given client ID.
213
+ */
214
+ revokeIntegrationTokens(options) {
215
+ return (options.client ?? this.client).delete({
216
+ url: "/v1/workspaces/{workspaceId}/integrations/{clientId}",
217
+ ...options
218
+ });
219
+ }
220
+ /**
221
+ * Get Prisma Postgres regions
222
+ *
223
+ * Returns all available regions for Prisma Postgres.
224
+ */
225
+ getPrismaPostgresRegions(options) {
226
+ return (options?.client ?? this.client).get({
227
+ url: "/v1/regions/postgres",
228
+ ...options
229
+ });
230
+ }
231
+ /**
232
+ * Get Prisma Accelerate regions
233
+ *
234
+ * Returns all available regions for Prisma Accelerate.
235
+ */
236
+ getPrismaAccelerateRegions(options) {
237
+ return (options?.client ?? this.client).get({
238
+ url: "/v1/regions/accelerate",
239
+ ...options
240
+ });
241
+ }
242
+ /**
243
+ * Get list of workspaces
244
+ *
245
+ * Returns the list of workspaces the current token can access.
246
+ */
247
+ listWorkspaces(options) {
248
+ return (options?.client ?? this.client).get({
249
+ url: "/v1/workspaces",
250
+ ...options
251
+ });
252
+ }
253
+ };
254
+
255
+ //#endregion
14
256
  export { PrismaClient };
@@ -1 +0,0 @@
1
- require('../types.gen-BN-p9nVT.cjs');
@@ -1,3 +1 @@
1
- import "../types.gen-CS2KiRfG.mjs";
2
-
3
1
  export { };
@@ -1,3 +1,81 @@
1
- const require_get_schema = require('../get-schema-CqMBOHOd.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __prisma_get_platform = require("@prisma/get-platform");
3
+ let __prisma_prisma_schema_wasm = require("@prisma/prisma-schema-wasm");
4
+ __prisma_prisma_schema_wasm = require_rolldown_runtime.__toESM(__prisma_prisma_schema_wasm);
5
+ let fp_ts_Either = require("fp-ts/Either");
6
+ fp_ts_Either = require_rolldown_runtime.__toESM(fp_ts_Either);
7
+ let fp_ts_lib_function = require("fp-ts/lib/function");
8
+ let ts_pattern = require("ts-pattern");
2
9
 
3
- exports.getSchema = require_get_schema.getSchema;
10
+ //#region src/helpers/get-schema.ts
11
+ async function resolveBinaryTargets(generator) {
12
+ for (const binaryTarget of generator.binaryTargets) {
13
+ if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
14
+ const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
15
+ if (Array.isArray(value)) {
16
+ generator.binaryTargets = value.map((v) => ({
17
+ fromEnvVar: null,
18
+ value: v
19
+ }));
20
+ await resolveBinaryTargets(generator);
21
+ } else binaryTarget.value = value;
22
+ }
23
+ if (binaryTarget.value === "native") {
24
+ binaryTarget.value = await (0, __prisma_get_platform.getBinaryTargetForCurrentPlatform)();
25
+ binaryTarget.native = true;
26
+ }
27
+ }
28
+ if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
29
+ fromEnvVar: null,
30
+ value: await (0, __prisma_get_platform.getBinaryTargetForCurrentPlatform)(),
31
+ native: true
32
+ }];
33
+ }
34
+ /**
35
+ * Retrieves the Prisma schema using the provided options.
36
+ *
37
+ * @param options - The options to customize the schema retrieval.
38
+ * @returns The Prisma schema.
39
+ */
40
+ async function getSchema(options) {
41
+ const configEither = (0, fp_ts_lib_function.pipe)(fp_ts_Either.tryCatch(() => {
42
+ if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) __prisma_prisma_schema_wasm.default.debug_panic();
43
+ const params = JSON.stringify({
44
+ prismaSchema: options.datamodel,
45
+ datasourceOverrides: {},
46
+ ignoreEnvVarErrors: options.ignoreEnvVarErrors ?? false,
47
+ env: process.env
48
+ });
49
+ return __prisma_prisma_schema_wasm.default.get_config(params);
50
+ }, (e) => ({
51
+ type: "wasm-error",
52
+ reason: "(get-config wasm)",
53
+ error: e
54
+ })), fp_ts_Either.map((result) => ({ result })), fp_ts_Either.chainW(({ result }) => fp_ts_Either.tryCatch(() => JSON.parse(result), (e) => ({
55
+ type: "parse-json",
56
+ reason: "Unable to parse JSON",
57
+ error: e
58
+ }))), fp_ts_Either.chainW((response) => {
59
+ if (response.errors.length > 0) return fp_ts_Either.left({
60
+ type: "validation-error",
61
+ reason: "(get-config wasm)",
62
+ error: response.errors
63
+ });
64
+ return fp_ts_Either.right(response.config);
65
+ }));
66
+ if (fp_ts_Either.isRight(configEither)) {
67
+ const { right: data } = configEither;
68
+ for (const generator of data.generators) await resolveBinaryTargets(generator);
69
+ return Promise.resolve(data);
70
+ }
71
+ throw (0, ts_pattern.match)(configEither.left).with({ type: "wasm-error" }, (e) => {
72
+ return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
73
+ }).with({ type: "validation-error" }, (e) => {
74
+ return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
75
+ }).otherwise((e) => {
76
+ return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
77
+ });
78
+ }
79
+
80
+ //#endregion
81
+ exports.getSchema = getSchema;
@@ -1,3 +1,78 @@
1
- import { t as getSchema } from "../get-schema-CKw6MiKb.mjs";
1
+ import { getBinaryTargetForCurrentPlatform } from "@prisma/get-platform";
2
+ import prismaSchemaWasm from "@prisma/prisma-schema-wasm";
3
+ import * as E from "fp-ts/Either";
4
+ import { pipe } from "fp-ts/lib/function";
5
+ import { match } from "ts-pattern";
2
6
 
7
+ //#region src/helpers/get-schema.ts
8
+ async function resolveBinaryTargets(generator) {
9
+ for (const binaryTarget of generator.binaryTargets) {
10
+ if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
11
+ const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
12
+ if (Array.isArray(value)) {
13
+ generator.binaryTargets = value.map((v) => ({
14
+ fromEnvVar: null,
15
+ value: v
16
+ }));
17
+ await resolveBinaryTargets(generator);
18
+ } else binaryTarget.value = value;
19
+ }
20
+ if (binaryTarget.value === "native") {
21
+ binaryTarget.value = await getBinaryTargetForCurrentPlatform();
22
+ binaryTarget.native = true;
23
+ }
24
+ }
25
+ if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
26
+ fromEnvVar: null,
27
+ value: await getBinaryTargetForCurrentPlatform(),
28
+ native: true
29
+ }];
30
+ }
31
+ /**
32
+ * Retrieves the Prisma schema using the provided options.
33
+ *
34
+ * @param options - The options to customize the schema retrieval.
35
+ * @returns The Prisma schema.
36
+ */
37
+ async function getSchema(options) {
38
+ const configEither = pipe(E.tryCatch(() => {
39
+ if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) prismaSchemaWasm.debug_panic();
40
+ const params = JSON.stringify({
41
+ prismaSchema: options.datamodel,
42
+ datasourceOverrides: {},
43
+ ignoreEnvVarErrors: options.ignoreEnvVarErrors ?? false,
44
+ env: process.env
45
+ });
46
+ return prismaSchemaWasm.get_config(params);
47
+ }, (e) => ({
48
+ type: "wasm-error",
49
+ reason: "(get-config wasm)",
50
+ error: e
51
+ })), E.map((result) => ({ result })), E.chainW(({ result }) => E.tryCatch(() => JSON.parse(result), (e) => ({
52
+ type: "parse-json",
53
+ reason: "Unable to parse JSON",
54
+ error: e
55
+ }))), E.chainW((response) => {
56
+ if (response.errors.length > 0) return E.left({
57
+ type: "validation-error",
58
+ reason: "(get-config wasm)",
59
+ error: response.errors
60
+ });
61
+ return E.right(response.config);
62
+ }));
63
+ if (E.isRight(configEither)) {
64
+ const { right: data } = configEither;
65
+ for (const generator of data.generators) await resolveBinaryTargets(generator);
66
+ return Promise.resolve(data);
67
+ }
68
+ throw match(configEither.left).with({ type: "wasm-error" }, (e) => {
69
+ return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
70
+ }).with({ type: "validation-error" }, (e) => {
71
+ return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
72
+ }).otherwise((e) => {
73
+ return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
74
+ });
75
+ }
76
+
77
+ //#endregion
3
78
  export { getSchema };