@develit-io/backend-sdk 5.33.0 → 5.34.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.d.mts +92 -30
- package/dist/index.d.ts +92 -30
- package/dist/index.mjs +57 -7
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -55,7 +55,7 @@ declare const bankAccountPostgres: {
|
|
|
55
55
|
|
|
56
56
|
declare const ENVIRONMENT: string[];
|
|
57
57
|
|
|
58
|
-
type Environment = string | 'dev' | 'test' | 'staging' | 'production';
|
|
58
|
+
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
59
59
|
|
|
60
60
|
type Project = 'creditio' | 'paycorp-fiat-processor' | 'dbu-mdm' | 'moneio' | 'dbu-txs' | 'lrf-website';
|
|
61
61
|
|
|
@@ -307,14 +307,16 @@ 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: (
|
|
310
|
+
declare const getD1Credentials: ({ instanceName, }: {
|
|
311
|
+
instanceName: string;
|
|
312
|
+
}) => Promise<{
|
|
311
313
|
driver?: undefined;
|
|
312
314
|
dbCredentials?: undefined;
|
|
313
315
|
} | {
|
|
314
316
|
driver: string;
|
|
315
317
|
dbCredentials: {
|
|
316
318
|
accountId: string | undefined;
|
|
317
|
-
databaseId: string;
|
|
319
|
+
databaseId: string | undefined;
|
|
318
320
|
token: string | undefined;
|
|
319
321
|
url?: undefined;
|
|
320
322
|
};
|
|
@@ -326,32 +328,90 @@ declare const getD1Credentials: () => {
|
|
|
326
328
|
token?: undefined;
|
|
327
329
|
};
|
|
328
330
|
driver?: undefined;
|
|
329
|
-
}
|
|
330
|
-
declare const getDrizzleD1Config: (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} | {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
331
|
+
}>;
|
|
332
|
+
declare const getDrizzleD1Config: ({ instanceName, }: {
|
|
333
|
+
instanceName: string;
|
|
334
|
+
}) => {
|
|
335
|
+
then<TResult1 = {
|
|
336
|
+
driver?: undefined;
|
|
337
|
+
dbCredentials?: undefined;
|
|
338
|
+
} | {
|
|
339
|
+
driver: string;
|
|
340
|
+
dbCredentials: {
|
|
341
|
+
accountId: string | undefined;
|
|
342
|
+
databaseId: string | undefined;
|
|
343
|
+
token: string | undefined;
|
|
344
|
+
url?: undefined;
|
|
345
|
+
};
|
|
346
|
+
} | {
|
|
347
|
+
dbCredentials: {
|
|
348
|
+
url: string | undefined;
|
|
349
|
+
accountId?: undefined;
|
|
350
|
+
databaseId?: undefined;
|
|
351
|
+
token?: undefined;
|
|
352
|
+
};
|
|
353
|
+
driver?: undefined;
|
|
354
|
+
}, TResult2 = never>(onfulfilled?: ((value: {
|
|
355
|
+
driver?: undefined;
|
|
356
|
+
dbCredentials?: undefined;
|
|
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;
|
|
355
415
|
schema: string;
|
|
356
416
|
out: string;
|
|
357
417
|
dialect: "sqlite";
|
|
@@ -487,6 +547,8 @@ declare const useResult: <T>(promise: Promise<T>) => Promise<Result<T>>;
|
|
|
487
547
|
*/
|
|
488
548
|
declare const useResultSync: <T>(fn: () => T) => Result<T>;
|
|
489
549
|
|
|
550
|
+
declare const getSecret: (secretName: string, env: unknown) => Promise<string>;
|
|
551
|
+
|
|
490
552
|
declare const service: (serviceName: string) => <T extends new (...args: any[]) => object>(constructor: T) => {
|
|
491
553
|
new (...args: any[]): {
|
|
492
554
|
name: string;
|
|
@@ -506,5 +568,5 @@ interface WithRetryCounterOptions {
|
|
|
506
568
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
507
569
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
508
570
|
|
|
509
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
|
571
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, getSecret, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
|
510
572
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, ValidatedInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ declare const bankAccountPostgres: {
|
|
|
55
55
|
|
|
56
56
|
declare const ENVIRONMENT: string[];
|
|
57
57
|
|
|
58
|
-
type Environment = string | 'dev' | 'test' | 'staging' | 'production';
|
|
58
|
+
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
59
59
|
|
|
60
60
|
type Project = 'creditio' | 'paycorp-fiat-processor' | 'dbu-mdm' | 'moneio' | 'dbu-txs' | 'lrf-website';
|
|
61
61
|
|
|
@@ -307,14 +307,16 @@ 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: (
|
|
310
|
+
declare const getD1Credentials: ({ instanceName, }: {
|
|
311
|
+
instanceName: string;
|
|
312
|
+
}) => Promise<{
|
|
311
313
|
driver?: undefined;
|
|
312
314
|
dbCredentials?: undefined;
|
|
313
315
|
} | {
|
|
314
316
|
driver: string;
|
|
315
317
|
dbCredentials: {
|
|
316
318
|
accountId: string | undefined;
|
|
317
|
-
databaseId: string;
|
|
319
|
+
databaseId: string | undefined;
|
|
318
320
|
token: string | undefined;
|
|
319
321
|
url?: undefined;
|
|
320
322
|
};
|
|
@@ -326,32 +328,90 @@ declare const getD1Credentials: () => {
|
|
|
326
328
|
token?: undefined;
|
|
327
329
|
};
|
|
328
330
|
driver?: undefined;
|
|
329
|
-
}
|
|
330
|
-
declare const getDrizzleD1Config: (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} | {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
331
|
+
}>;
|
|
332
|
+
declare const getDrizzleD1Config: ({ instanceName, }: {
|
|
333
|
+
instanceName: string;
|
|
334
|
+
}) => {
|
|
335
|
+
then<TResult1 = {
|
|
336
|
+
driver?: undefined;
|
|
337
|
+
dbCredentials?: undefined;
|
|
338
|
+
} | {
|
|
339
|
+
driver: string;
|
|
340
|
+
dbCredentials: {
|
|
341
|
+
accountId: string | undefined;
|
|
342
|
+
databaseId: string | undefined;
|
|
343
|
+
token: string | undefined;
|
|
344
|
+
url?: undefined;
|
|
345
|
+
};
|
|
346
|
+
} | {
|
|
347
|
+
dbCredentials: {
|
|
348
|
+
url: string | undefined;
|
|
349
|
+
accountId?: undefined;
|
|
350
|
+
databaseId?: undefined;
|
|
351
|
+
token?: undefined;
|
|
352
|
+
};
|
|
353
|
+
driver?: undefined;
|
|
354
|
+
}, TResult2 = never>(onfulfilled?: ((value: {
|
|
355
|
+
driver?: undefined;
|
|
356
|
+
dbCredentials?: undefined;
|
|
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;
|
|
355
415
|
schema: string;
|
|
356
416
|
out: string;
|
|
357
417
|
dialect: "sqlite";
|
|
@@ -487,6 +547,8 @@ declare const useResult: <T>(promise: Promise<T>) => Promise<Result<T>>;
|
|
|
487
547
|
*/
|
|
488
548
|
declare const useResultSync: <T>(fn: () => T) => Result<T>;
|
|
489
549
|
|
|
550
|
+
declare const getSecret: (secretName: string, env: unknown) => Promise<string>;
|
|
551
|
+
|
|
490
552
|
declare const service: (serviceName: string) => <T extends new (...args: any[]) => object>(constructor: T) => {
|
|
491
553
|
new (...args: any[]): {
|
|
492
554
|
name: string;
|
|
@@ -506,5 +568,5 @@ interface WithRetryCounterOptions {
|
|
|
506
568
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
507
569
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
508
570
|
|
|
509
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
|
571
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, getSecret, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
|
510
572
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, ValidatedInput };
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +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 Cloudflare from 'cloudflare';
|
|
9
10
|
import fs from 'node:fs';
|
|
10
11
|
import crypto$1 from 'node:crypto';
|
|
11
12
|
import path from 'node:path';
|
|
@@ -344,6 +345,37 @@ function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
|
344
345
|
const hmac = crypto$1.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
|
|
345
346
|
return Buffer.concat([nameHmac, hmac]).toString("hex");
|
|
346
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
|
+
};
|
|
347
379
|
const getD1DatabaseIdFromWrangler = () => {
|
|
348
380
|
try {
|
|
349
381
|
const wranglerPath = path.resolve("./wrangler.jsonc");
|
|
@@ -400,34 +432,40 @@ const getLocalD1 = (databaseId) => {
|
|
|
400
432
|
}
|
|
401
433
|
}
|
|
402
434
|
};
|
|
403
|
-
const getD1Credentials = (
|
|
435
|
+
const getD1Credentials = async ({
|
|
436
|
+
instanceName
|
|
437
|
+
}) => {
|
|
404
438
|
const environment = process.env.ENVIRONMENT;
|
|
405
439
|
if (environment === "localhost") {
|
|
406
440
|
return {};
|
|
407
441
|
}
|
|
408
|
-
const databaseId = getD1DatabaseIdFromWrangler() ?? "";
|
|
409
442
|
if (isRemoteEnvironment()) {
|
|
410
443
|
return {
|
|
411
444
|
driver: "d1-http",
|
|
412
445
|
dbCredentials: {
|
|
413
446
|
accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
|
|
414
|
-
databaseId
|
|
447
|
+
databaseId: await getD1DatabaseId({
|
|
448
|
+
environment,
|
|
449
|
+
instanceName
|
|
450
|
+
}),
|
|
415
451
|
token: process.env.CLOUDFLARE_API_TOKEN
|
|
416
452
|
}
|
|
417
453
|
};
|
|
418
454
|
} else {
|
|
419
455
|
return {
|
|
420
456
|
dbCredentials: {
|
|
421
|
-
url: getLocalD1(
|
|
457
|
+
url: getLocalD1(getD1DatabaseIdFromWrangler() || "")
|
|
422
458
|
}
|
|
423
459
|
};
|
|
424
460
|
}
|
|
425
461
|
};
|
|
426
|
-
const getDrizzleD1Config = (
|
|
462
|
+
const getDrizzleD1Config = ({
|
|
463
|
+
instanceName
|
|
464
|
+
}) => ({
|
|
427
465
|
schema: "./src/database/schema/",
|
|
428
466
|
out: "./src/database/migrations/",
|
|
429
467
|
dialect: "sqlite",
|
|
430
|
-
...getD1Credentials()
|
|
468
|
+
...getD1Credentials({ instanceName })
|
|
431
469
|
});
|
|
432
470
|
|
|
433
471
|
class DatabaseTransaction {
|
|
@@ -574,6 +612,18 @@ const calculateExponentialBackoff = (attempts, baseDelaySeconds) => {
|
|
|
574
612
|
return baseDelaySeconds ** attempts;
|
|
575
613
|
};
|
|
576
614
|
|
|
615
|
+
const getSecret = async (secretName, env) => {
|
|
616
|
+
const environment = env;
|
|
617
|
+
if (!(secretName in environment)) {
|
|
618
|
+
throw new Error(`Could not find a secret named '${secretName}'.`);
|
|
619
|
+
}
|
|
620
|
+
const secret = environment[secretName];
|
|
621
|
+
if (typeof secret === "string") {
|
|
622
|
+
return secret;
|
|
623
|
+
}
|
|
624
|
+
return await secret.get();
|
|
625
|
+
};
|
|
626
|
+
|
|
577
627
|
const service = (serviceName) => {
|
|
578
628
|
return function(constructor) {
|
|
579
629
|
return class extends constructor {
|
|
@@ -714,4 +764,4 @@ function develitWorker(Worker) {
|
|
|
714
764
|
return DevelitWorker;
|
|
715
765
|
}
|
|
716
766
|
|
|
717
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
|
767
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, action, bankAccount, bankAccountBankCodeEnum, bankAccountCountryCodeEnum, bankAccountCurrencyEnum, bankAccountMetadataSchema, bankAccountPostgres, base, basePostgres, bicSchema, calculateExponentialBackoff, cloudflareQueue, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getDrizzlePgConfig, getPgCredentials, getPgDatabaseIdFromWrangler, getPgLocalConnectionString, getSecret, handleAction, handleActionResponse, ibanSchema, isInternalError, paginationQuerySchema, paginationSchema, service, useFetch, useResult, useResultSync, uuidv4 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develit-io/backend-sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.34.0",
|
|
4
4
|
"description": "Develit Backend SDK",
|
|
5
5
|
"author": "Develit.io",
|
|
6
6
|
"license": "ISC",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@develit-io/general-codes": "^1.14.0",
|
|
41
|
-
"
|
|
41
|
+
"cloudflare": "^5.2.0",
|
|
42
|
+
"zod": "^4.1.12"
|
|
42
43
|
}
|
|
43
44
|
}
|