@develit-io/backend-sdk 5.34.0 → 5.34.1
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.d.mts +28 -88
- package/dist/index.d.ts +28 -88
- package/dist/index.mjs +7 -44
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -307,16 +307,14 @@ declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTabl
|
|
|
307
307
|
|
|
308
308
|
declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
|
|
309
309
|
declare const getD1DatabaseIdFromWrangler: () => string | undefined;
|
|
310
|
-
declare const getD1Credentials: (
|
|
311
|
-
instanceName: string;
|
|
312
|
-
}) => Promise<{
|
|
310
|
+
declare const getD1Credentials: () => {
|
|
313
311
|
driver?: undefined;
|
|
314
312
|
dbCredentials?: undefined;
|
|
315
313
|
} | {
|
|
316
314
|
driver: string;
|
|
317
315
|
dbCredentials: {
|
|
318
316
|
accountId: string | undefined;
|
|
319
|
-
databaseId: string
|
|
317
|
+
databaseId: string;
|
|
320
318
|
token: string | undefined;
|
|
321
319
|
url?: undefined;
|
|
322
320
|
};
|
|
@@ -328,90 +326,32 @@ declare const getD1Credentials: ({ instanceName, }: {
|
|
|
328
326
|
token?: undefined;
|
|
329
327
|
};
|
|
330
328
|
driver?: undefined;
|
|
331
|
-
}
|
|
332
|
-
declare const getDrizzleD1Config: (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
} | {
|
|
358
|
-
driver: string;
|
|
359
|
-
dbCredentials: {
|
|
360
|
-
accountId: string | undefined;
|
|
361
|
-
databaseId: string | undefined;
|
|
362
|
-
token: string | undefined;
|
|
363
|
-
url?: undefined;
|
|
364
|
-
};
|
|
365
|
-
} | {
|
|
366
|
-
dbCredentials: {
|
|
367
|
-
url: string | undefined;
|
|
368
|
-
accountId?: undefined;
|
|
369
|
-
databaseId?: undefined;
|
|
370
|
-
token?: undefined;
|
|
371
|
-
};
|
|
372
|
-
driver?: undefined;
|
|
373
|
-
}) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
374
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<{
|
|
375
|
-
driver?: undefined;
|
|
376
|
-
dbCredentials?: undefined;
|
|
377
|
-
} | {
|
|
378
|
-
driver: string;
|
|
379
|
-
dbCredentials: {
|
|
380
|
-
accountId: string | undefined;
|
|
381
|
-
databaseId: string | undefined;
|
|
382
|
-
token: string | undefined;
|
|
383
|
-
url?: undefined;
|
|
384
|
-
};
|
|
385
|
-
} | {
|
|
386
|
-
dbCredentials: {
|
|
387
|
-
url: string | undefined;
|
|
388
|
-
accountId?: undefined;
|
|
389
|
-
databaseId?: undefined;
|
|
390
|
-
token?: undefined;
|
|
391
|
-
};
|
|
392
|
-
driver?: undefined;
|
|
393
|
-
} | TResult>;
|
|
394
|
-
finally(onfinally?: (() => void) | null | undefined): Promise<{
|
|
395
|
-
driver?: undefined;
|
|
396
|
-
dbCredentials?: undefined;
|
|
397
|
-
} | {
|
|
398
|
-
driver: string;
|
|
399
|
-
dbCredentials: {
|
|
400
|
-
accountId: string | undefined;
|
|
401
|
-
databaseId: string | undefined;
|
|
402
|
-
token: string | undefined;
|
|
403
|
-
url?: undefined;
|
|
404
|
-
};
|
|
405
|
-
} | {
|
|
406
|
-
dbCredentials: {
|
|
407
|
-
url: string | undefined;
|
|
408
|
-
accountId?: undefined;
|
|
409
|
-
databaseId?: undefined;
|
|
410
|
-
token?: undefined;
|
|
411
|
-
};
|
|
412
|
-
driver?: undefined;
|
|
413
|
-
}>;
|
|
414
|
-
[Symbol.toStringTag]: string;
|
|
329
|
+
};
|
|
330
|
+
declare const getDrizzleD1Config: () => {
|
|
331
|
+
driver?: undefined;
|
|
332
|
+
dbCredentials?: undefined;
|
|
333
|
+
schema: string;
|
|
334
|
+
out: string;
|
|
335
|
+
dialect: "sqlite";
|
|
336
|
+
} | {
|
|
337
|
+
driver: string;
|
|
338
|
+
dbCredentials: {
|
|
339
|
+
accountId: string | undefined;
|
|
340
|
+
databaseId: string;
|
|
341
|
+
token: string | undefined;
|
|
342
|
+
url?: undefined;
|
|
343
|
+
};
|
|
344
|
+
schema: string;
|
|
345
|
+
out: string;
|
|
346
|
+
dialect: "sqlite";
|
|
347
|
+
} | {
|
|
348
|
+
dbCredentials: {
|
|
349
|
+
url: string | undefined;
|
|
350
|
+
accountId?: undefined;
|
|
351
|
+
databaseId?: undefined;
|
|
352
|
+
token?: undefined;
|
|
353
|
+
};
|
|
354
|
+
driver?: undefined;
|
|
415
355
|
schema: string;
|
|
416
356
|
out: string;
|
|
417
357
|
dialect: "sqlite";
|
package/dist/index.d.ts
CHANGED
|
@@ -307,16 +307,14 @@ declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTabl
|
|
|
307
307
|
|
|
308
308
|
declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
|
|
309
309
|
declare const getD1DatabaseIdFromWrangler: () => string | undefined;
|
|
310
|
-
declare const getD1Credentials: (
|
|
311
|
-
instanceName: string;
|
|
312
|
-
}) => Promise<{
|
|
310
|
+
declare const getD1Credentials: () => {
|
|
313
311
|
driver?: undefined;
|
|
314
312
|
dbCredentials?: undefined;
|
|
315
313
|
} | {
|
|
316
314
|
driver: string;
|
|
317
315
|
dbCredentials: {
|
|
318
316
|
accountId: string | undefined;
|
|
319
|
-
databaseId: string
|
|
317
|
+
databaseId: string;
|
|
320
318
|
token: string | undefined;
|
|
321
319
|
url?: undefined;
|
|
322
320
|
};
|
|
@@ -328,90 +326,32 @@ declare const getD1Credentials: ({ instanceName, }: {
|
|
|
328
326
|
token?: undefined;
|
|
329
327
|
};
|
|
330
328
|
driver?: undefined;
|
|
331
|
-
}
|
|
332
|
-
declare const getDrizzleD1Config: (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
} | {
|
|
358
|
-
driver: string;
|
|
359
|
-
dbCredentials: {
|
|
360
|
-
accountId: string | undefined;
|
|
361
|
-
databaseId: string | undefined;
|
|
362
|
-
token: string | undefined;
|
|
363
|
-
url?: undefined;
|
|
364
|
-
};
|
|
365
|
-
} | {
|
|
366
|
-
dbCredentials: {
|
|
367
|
-
url: string | undefined;
|
|
368
|
-
accountId?: undefined;
|
|
369
|
-
databaseId?: undefined;
|
|
370
|
-
token?: undefined;
|
|
371
|
-
};
|
|
372
|
-
driver?: undefined;
|
|
373
|
-
}) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
374
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<{
|
|
375
|
-
driver?: undefined;
|
|
376
|
-
dbCredentials?: undefined;
|
|
377
|
-
} | {
|
|
378
|
-
driver: string;
|
|
379
|
-
dbCredentials: {
|
|
380
|
-
accountId: string | undefined;
|
|
381
|
-
databaseId: string | undefined;
|
|
382
|
-
token: string | undefined;
|
|
383
|
-
url?: undefined;
|
|
384
|
-
};
|
|
385
|
-
} | {
|
|
386
|
-
dbCredentials: {
|
|
387
|
-
url: string | undefined;
|
|
388
|
-
accountId?: undefined;
|
|
389
|
-
databaseId?: undefined;
|
|
390
|
-
token?: undefined;
|
|
391
|
-
};
|
|
392
|
-
driver?: undefined;
|
|
393
|
-
} | TResult>;
|
|
394
|
-
finally(onfinally?: (() => void) | null | undefined): Promise<{
|
|
395
|
-
driver?: undefined;
|
|
396
|
-
dbCredentials?: undefined;
|
|
397
|
-
} | {
|
|
398
|
-
driver: string;
|
|
399
|
-
dbCredentials: {
|
|
400
|
-
accountId: string | undefined;
|
|
401
|
-
databaseId: string | undefined;
|
|
402
|
-
token: string | undefined;
|
|
403
|
-
url?: undefined;
|
|
404
|
-
};
|
|
405
|
-
} | {
|
|
406
|
-
dbCredentials: {
|
|
407
|
-
url: string | undefined;
|
|
408
|
-
accountId?: undefined;
|
|
409
|
-
databaseId?: undefined;
|
|
410
|
-
token?: undefined;
|
|
411
|
-
};
|
|
412
|
-
driver?: undefined;
|
|
413
|
-
}>;
|
|
414
|
-
[Symbol.toStringTag]: string;
|
|
329
|
+
};
|
|
330
|
+
declare const getDrizzleD1Config: () => {
|
|
331
|
+
driver?: undefined;
|
|
332
|
+
dbCredentials?: undefined;
|
|
333
|
+
schema: string;
|
|
334
|
+
out: string;
|
|
335
|
+
dialect: "sqlite";
|
|
336
|
+
} | {
|
|
337
|
+
driver: string;
|
|
338
|
+
dbCredentials: {
|
|
339
|
+
accountId: string | undefined;
|
|
340
|
+
databaseId: string;
|
|
341
|
+
token: string | undefined;
|
|
342
|
+
url?: undefined;
|
|
343
|
+
};
|
|
344
|
+
schema: string;
|
|
345
|
+
out: string;
|
|
346
|
+
dialect: "sqlite";
|
|
347
|
+
} | {
|
|
348
|
+
dbCredentials: {
|
|
349
|
+
url: string | undefined;
|
|
350
|
+
accountId?: undefined;
|
|
351
|
+
databaseId?: undefined;
|
|
352
|
+
token?: undefined;
|
|
353
|
+
};
|
|
354
|
+
driver?: undefined;
|
|
415
355
|
schema: string;
|
|
416
356
|
out: string;
|
|
417
357
|
dialect: "sqlite";
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { z as z$1 } from 'zod';
|
|
|
6
6
|
import * as z from 'zod/v4/core';
|
|
7
7
|
import 'http-status-codes';
|
|
8
8
|
import { createError } from 'h3';
|
|
9
|
-
import
|
|
9
|
+
import 'cloudflare';
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import crypto$1 from 'node:crypto';
|
|
12
12
|
import path from 'node:path';
|
|
@@ -345,37 +345,6 @@ function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
|
345
345
|
const hmac = crypto$1.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
|
|
346
346
|
return Buffer.concat([nameHmac, hmac]).toString("hex");
|
|
347
347
|
}
|
|
348
|
-
const getD1DatabaseId = async ({
|
|
349
|
-
instanceName,
|
|
350
|
-
environment
|
|
351
|
-
}) => {
|
|
352
|
-
const remoteD1s = [];
|
|
353
|
-
const cloudflare = new Cloudflare({
|
|
354
|
-
apiToken: process.env.CLOUDFLARE_API_TOKEN
|
|
355
|
-
});
|
|
356
|
-
let currentPage = await cloudflare.d1.database.list({
|
|
357
|
-
account_id: process.env.CLOUDFLARE_ACCOUNT_ID
|
|
358
|
-
});
|
|
359
|
-
remoteD1s.push(...currentPage.getPaginatedItems());
|
|
360
|
-
while (currentPage.hasNextPage()) {
|
|
361
|
-
const pageInfo = currentPage.nextPageInfo();
|
|
362
|
-
let nextPageParams;
|
|
363
|
-
if ("params" in pageInfo) {
|
|
364
|
-
nextPageParams = pageInfo.params;
|
|
365
|
-
} else {
|
|
366
|
-
nextPageParams = Object.fromEntries(pageInfo.url.searchParams);
|
|
367
|
-
}
|
|
368
|
-
currentPage = await cloudflare.d1.database.list({
|
|
369
|
-
account_id: process.env.CLOUDFLARE_ACCOUNT_ID,
|
|
370
|
-
...nextPageParams
|
|
371
|
-
});
|
|
372
|
-
remoteD1s.push(...currentPage.getPaginatedItems());
|
|
373
|
-
}
|
|
374
|
-
const instancesByName = remoteD1s.filter(
|
|
375
|
-
(d1) => d1.name?.includes(instanceName)
|
|
376
|
-
);
|
|
377
|
-
return instancesByName.filter((name) => name.name?.includes(environment)).at(0)?.uuid;
|
|
378
|
-
};
|
|
379
348
|
const getD1DatabaseIdFromWrangler = () => {
|
|
380
349
|
try {
|
|
381
350
|
const wranglerPath = path.resolve("./wrangler.jsonc");
|
|
@@ -432,40 +401,34 @@ const getLocalD1 = (databaseId) => {
|
|
|
432
401
|
}
|
|
433
402
|
}
|
|
434
403
|
};
|
|
435
|
-
const getD1Credentials =
|
|
436
|
-
instanceName
|
|
437
|
-
}) => {
|
|
404
|
+
const getD1Credentials = () => {
|
|
438
405
|
const environment = process.env.ENVIRONMENT;
|
|
439
406
|
if (environment === "localhost") {
|
|
440
407
|
return {};
|
|
441
408
|
}
|
|
409
|
+
const databaseId = getD1DatabaseIdFromWrangler() ?? "";
|
|
442
410
|
if (isRemoteEnvironment()) {
|
|
443
411
|
return {
|
|
444
412
|
driver: "d1-http",
|
|
445
413
|
dbCredentials: {
|
|
446
414
|
accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
|
|
447
|
-
databaseId
|
|
448
|
-
environment,
|
|
449
|
-
instanceName
|
|
450
|
-
}),
|
|
415
|
+
databaseId,
|
|
451
416
|
token: process.env.CLOUDFLARE_API_TOKEN
|
|
452
417
|
}
|
|
453
418
|
};
|
|
454
419
|
} else {
|
|
455
420
|
return {
|
|
456
421
|
dbCredentials: {
|
|
457
|
-
url: getLocalD1(
|
|
422
|
+
url: getLocalD1(databaseId)
|
|
458
423
|
}
|
|
459
424
|
};
|
|
460
425
|
}
|
|
461
426
|
};
|
|
462
|
-
const getDrizzleD1Config = ({
|
|
463
|
-
instanceName
|
|
464
|
-
}) => ({
|
|
427
|
+
const getDrizzleD1Config = () => ({
|
|
465
428
|
schema: "./src/database/schema/",
|
|
466
429
|
out: "./src/database/migrations/",
|
|
467
430
|
dialect: "sqlite",
|
|
468
|
-
...getD1Credentials(
|
|
431
|
+
...getD1Credentials()
|
|
469
432
|
});
|
|
470
433
|
|
|
471
434
|
class DatabaseTransaction {
|