@develit-io/backend-sdk 5.8.3 → 5.9.0
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/dist/index.cjs +36 -19
- package/dist/index.d.cts +12 -6
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.mjs +36 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -232,6 +232,21 @@ function createAuditLogWriter(table) {
|
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
function first(rows) {
|
|
236
|
+
return rows.length > 0 ? rows[0] : void 0;
|
|
237
|
+
}
|
|
238
|
+
function firstOrError(rows) {
|
|
239
|
+
if (rows.length === 0) {
|
|
240
|
+
throw new Error("Query did not return any data.");
|
|
241
|
+
}
|
|
242
|
+
return rows[0];
|
|
243
|
+
}
|
|
244
|
+
const uuidv4 = () => crypto.randomUUID();
|
|
245
|
+
const isRemoteEnvironment = () => {
|
|
246
|
+
const environment = process.env.ENVIRONMENT;
|
|
247
|
+
return environment && environment !== "localhost";
|
|
248
|
+
};
|
|
249
|
+
|
|
235
250
|
function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
236
251
|
const key = crypto__default.createHash("sha256").update(uniqueKey).digest();
|
|
237
252
|
const nameHmac = crypto__default.createHmac("sha256", key).update(name).digest().subarray(0, 16);
|
|
@@ -267,10 +282,6 @@ const getDatabaseIdFromWrangler = () => {
|
|
|
267
282
|
);
|
|
268
283
|
}
|
|
269
284
|
};
|
|
270
|
-
const isRemoteEnvironment = () => {
|
|
271
|
-
const environment = process.env.ENVIRONMENT;
|
|
272
|
-
return environment && environment !== "localhost";
|
|
273
|
-
};
|
|
274
285
|
const getLocalD1 = (databaseId) => {
|
|
275
286
|
const name = durableObjectNamespaceIdFromName(
|
|
276
287
|
"miniflare-D1DatabaseObject",
|
|
@@ -298,7 +309,11 @@ const getLocalD1 = (databaseId) => {
|
|
|
298
309
|
}
|
|
299
310
|
}
|
|
300
311
|
};
|
|
301
|
-
const
|
|
312
|
+
const getD1Credentials = () => {
|
|
313
|
+
const environment = process.env.ENVIRONMENT;
|
|
314
|
+
if (environment === "localhost") {
|
|
315
|
+
return {};
|
|
316
|
+
}
|
|
302
317
|
const databaseId = getDatabaseIdFromWrangler() ?? "";
|
|
303
318
|
if (isRemoteEnvironment()) {
|
|
304
319
|
return {
|
|
@@ -321,7 +336,7 @@ const drizzleD1Config = {
|
|
|
321
336
|
schema: "./src/database/schema/",
|
|
322
337
|
out: "./src/database/migrations/",
|
|
323
338
|
dialect: "sqlite",
|
|
324
|
-
...
|
|
339
|
+
...getD1Credentials()
|
|
325
340
|
};
|
|
326
341
|
|
|
327
342
|
class DatabaseTransaction {
|
|
@@ -386,24 +401,26 @@ const defineCommand = (handler) => {
|
|
|
386
401
|
});
|
|
387
402
|
};
|
|
388
403
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
404
|
+
const getPgCredentials = () => {
|
|
405
|
+
if (isRemoteEnvironment()) {
|
|
406
|
+
return {
|
|
407
|
+
dbCredentials: {
|
|
408
|
+
url: process.env.DATABASE_URL
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
} else {
|
|
412
|
+
return {
|
|
413
|
+
dbCredentials: {
|
|
414
|
+
url: `postgres://db_user:db_password@127.0.0.1:${process.env.DB_LOCAL_PORT}/db`
|
|
415
|
+
}
|
|
416
|
+
};
|
|
395
417
|
}
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
const uuidv4 = () => crypto.randomUUID();
|
|
399
|
-
|
|
418
|
+
};
|
|
400
419
|
const drizzlePgConfig = {
|
|
401
420
|
schema: "./src/database/schema/",
|
|
402
421
|
out: "./src/database/migrations/",
|
|
403
422
|
dialect: "postgresql",
|
|
404
|
-
|
|
405
|
-
url: process.env.DATABASE_URL
|
|
406
|
-
},
|
|
423
|
+
...getPgCredentials(),
|
|
407
424
|
migrations: {
|
|
408
425
|
table: "__drizzle_migrations",
|
|
409
426
|
schema: "public"
|
package/dist/index.d.cts
CHANGED
|
@@ -192,6 +192,12 @@ declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTabl
|
|
|
192
192
|
|
|
193
193
|
declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
|
|
194
194
|
declare const drizzleD1Config: {
|
|
195
|
+
driver?: undefined;
|
|
196
|
+
dbCredentials?: undefined;
|
|
197
|
+
schema: string;
|
|
198
|
+
out: string;
|
|
199
|
+
dialect: "sqlite";
|
|
200
|
+
} | {
|
|
195
201
|
driver: string;
|
|
196
202
|
dbCredentials: {
|
|
197
203
|
accountId: string | undefined;
|
|
@@ -253,16 +259,16 @@ declare const createInternalError: (error: unknown, details?: {
|
|
|
253
259
|
declare const isInternalError: (error: unknown) => error is InternalError;
|
|
254
260
|
|
|
255
261
|
declare const drizzlePgConfig: {
|
|
256
|
-
schema: string;
|
|
257
|
-
out: string;
|
|
258
|
-
dialect: "postgresql";
|
|
259
|
-
dbCredentials: {
|
|
260
|
-
url: string;
|
|
261
|
-
};
|
|
262
262
|
migrations: {
|
|
263
263
|
table: string;
|
|
264
264
|
schema: string;
|
|
265
265
|
};
|
|
266
|
+
dbCredentials: {
|
|
267
|
+
url: string;
|
|
268
|
+
};
|
|
269
|
+
schema: string;
|
|
270
|
+
out: string;
|
|
271
|
+
dialect: "postgresql";
|
|
266
272
|
};
|
|
267
273
|
|
|
268
274
|
declare const calculateExponentialBackoff: (attempts: number, baseDelaySeconds: number) => number;
|
package/dist/index.d.mts
CHANGED
|
@@ -192,6 +192,12 @@ declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTabl
|
|
|
192
192
|
|
|
193
193
|
declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
|
|
194
194
|
declare const drizzleD1Config: {
|
|
195
|
+
driver?: undefined;
|
|
196
|
+
dbCredentials?: undefined;
|
|
197
|
+
schema: string;
|
|
198
|
+
out: string;
|
|
199
|
+
dialect: "sqlite";
|
|
200
|
+
} | {
|
|
195
201
|
driver: string;
|
|
196
202
|
dbCredentials: {
|
|
197
203
|
accountId: string | undefined;
|
|
@@ -253,16 +259,16 @@ declare const createInternalError: (error: unknown, details?: {
|
|
|
253
259
|
declare const isInternalError: (error: unknown) => error is InternalError;
|
|
254
260
|
|
|
255
261
|
declare const drizzlePgConfig: {
|
|
256
|
-
schema: string;
|
|
257
|
-
out: string;
|
|
258
|
-
dialect: "postgresql";
|
|
259
|
-
dbCredentials: {
|
|
260
|
-
url: string;
|
|
261
|
-
};
|
|
262
262
|
migrations: {
|
|
263
263
|
table: string;
|
|
264
264
|
schema: string;
|
|
265
265
|
};
|
|
266
|
+
dbCredentials: {
|
|
267
|
+
url: string;
|
|
268
|
+
};
|
|
269
|
+
schema: string;
|
|
270
|
+
out: string;
|
|
271
|
+
dialect: "postgresql";
|
|
266
272
|
};
|
|
267
273
|
|
|
268
274
|
declare const calculateExponentialBackoff: (attempts: number, baseDelaySeconds: number) => number;
|
package/dist/index.d.ts
CHANGED
|
@@ -192,6 +192,12 @@ declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTabl
|
|
|
192
192
|
|
|
193
193
|
declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
|
|
194
194
|
declare const drizzleD1Config: {
|
|
195
|
+
driver?: undefined;
|
|
196
|
+
dbCredentials?: undefined;
|
|
197
|
+
schema: string;
|
|
198
|
+
out: string;
|
|
199
|
+
dialect: "sqlite";
|
|
200
|
+
} | {
|
|
195
201
|
driver: string;
|
|
196
202
|
dbCredentials: {
|
|
197
203
|
accountId: string | undefined;
|
|
@@ -253,16 +259,16 @@ declare const createInternalError: (error: unknown, details?: {
|
|
|
253
259
|
declare const isInternalError: (error: unknown) => error is InternalError;
|
|
254
260
|
|
|
255
261
|
declare const drizzlePgConfig: {
|
|
256
|
-
schema: string;
|
|
257
|
-
out: string;
|
|
258
|
-
dialect: "postgresql";
|
|
259
|
-
dbCredentials: {
|
|
260
|
-
url: string;
|
|
261
|
-
};
|
|
262
262
|
migrations: {
|
|
263
263
|
table: string;
|
|
264
264
|
schema: string;
|
|
265
265
|
};
|
|
266
|
+
dbCredentials: {
|
|
267
|
+
url: string;
|
|
268
|
+
};
|
|
269
|
+
schema: string;
|
|
270
|
+
out: string;
|
|
271
|
+
dialect: "postgresql";
|
|
266
272
|
};
|
|
267
273
|
|
|
268
274
|
declare const calculateExponentialBackoff: (attempts: number, baseDelaySeconds: number) => number;
|
package/dist/index.mjs
CHANGED
|
@@ -210,6 +210,21 @@ function createAuditLogWriter(table) {
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
function first(rows) {
|
|
214
|
+
return rows.length > 0 ? rows[0] : void 0;
|
|
215
|
+
}
|
|
216
|
+
function firstOrError(rows) {
|
|
217
|
+
if (rows.length === 0) {
|
|
218
|
+
throw new Error("Query did not return any data.");
|
|
219
|
+
}
|
|
220
|
+
return rows[0];
|
|
221
|
+
}
|
|
222
|
+
const uuidv4 = () => crypto.randomUUID();
|
|
223
|
+
const isRemoteEnvironment = () => {
|
|
224
|
+
const environment = process.env.ENVIRONMENT;
|
|
225
|
+
return environment && environment !== "localhost";
|
|
226
|
+
};
|
|
227
|
+
|
|
213
228
|
function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
214
229
|
const key = crypto$1.createHash("sha256").update(uniqueKey).digest();
|
|
215
230
|
const nameHmac = crypto$1.createHmac("sha256", key).update(name).digest().subarray(0, 16);
|
|
@@ -245,10 +260,6 @@ const getDatabaseIdFromWrangler = () => {
|
|
|
245
260
|
);
|
|
246
261
|
}
|
|
247
262
|
};
|
|
248
|
-
const isRemoteEnvironment = () => {
|
|
249
|
-
const environment = process.env.ENVIRONMENT;
|
|
250
|
-
return environment && environment !== "localhost";
|
|
251
|
-
};
|
|
252
263
|
const getLocalD1 = (databaseId) => {
|
|
253
264
|
const name = durableObjectNamespaceIdFromName(
|
|
254
265
|
"miniflare-D1DatabaseObject",
|
|
@@ -276,7 +287,11 @@ const getLocalD1 = (databaseId) => {
|
|
|
276
287
|
}
|
|
277
288
|
}
|
|
278
289
|
};
|
|
279
|
-
const
|
|
290
|
+
const getD1Credentials = () => {
|
|
291
|
+
const environment = process.env.ENVIRONMENT;
|
|
292
|
+
if (environment === "localhost") {
|
|
293
|
+
return {};
|
|
294
|
+
}
|
|
280
295
|
const databaseId = getDatabaseIdFromWrangler() ?? "";
|
|
281
296
|
if (isRemoteEnvironment()) {
|
|
282
297
|
return {
|
|
@@ -299,7 +314,7 @@ const drizzleD1Config = {
|
|
|
299
314
|
schema: "./src/database/schema/",
|
|
300
315
|
out: "./src/database/migrations/",
|
|
301
316
|
dialect: "sqlite",
|
|
302
|
-
...
|
|
317
|
+
...getD1Credentials()
|
|
303
318
|
};
|
|
304
319
|
|
|
305
320
|
class DatabaseTransaction {
|
|
@@ -364,24 +379,26 @@ const defineCommand = (handler) => {
|
|
|
364
379
|
});
|
|
365
380
|
};
|
|
366
381
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
382
|
+
const getPgCredentials = () => {
|
|
383
|
+
if (isRemoteEnvironment()) {
|
|
384
|
+
return {
|
|
385
|
+
dbCredentials: {
|
|
386
|
+
url: process.env.DATABASE_URL
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
} else {
|
|
390
|
+
return {
|
|
391
|
+
dbCredentials: {
|
|
392
|
+
url: `postgres://db_user:db_password@127.0.0.1:${process.env.DB_LOCAL_PORT}/db`
|
|
393
|
+
}
|
|
394
|
+
};
|
|
373
395
|
}
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
const uuidv4 = () => crypto.randomUUID();
|
|
377
|
-
|
|
396
|
+
};
|
|
378
397
|
const drizzlePgConfig = {
|
|
379
398
|
schema: "./src/database/schema/",
|
|
380
399
|
out: "./src/database/migrations/",
|
|
381
400
|
dialect: "postgresql",
|
|
382
|
-
|
|
383
|
-
url: process.env.DATABASE_URL
|
|
384
|
-
},
|
|
401
|
+
...getPgCredentials(),
|
|
385
402
|
migrations: {
|
|
386
403
|
table: "__drizzle_migrations",
|
|
387
404
|
schema: "public"
|