@develit-io/backend-sdk 6.0.0 → 7.0.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 +22 -8
- package/dist/index.d.ts +22 -8
- package/dist/index.mjs +54 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as drizzle_orm from 'drizzle-orm';
|
|
2
|
-
import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult } from 'drizzle-orm';
|
|
2
|
+
import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn } from 'drizzle-orm';
|
|
3
3
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
|
|
5
5
|
import { MiddlewareHandler } from 'hono/types';
|
|
@@ -11,12 +11,14 @@ import { Queue } from '@cloudflare/workers-types';
|
|
|
11
11
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
12
12
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
13
13
|
|
|
14
|
-
declare const
|
|
14
|
+
declare const ENVIRONMENT: string[];
|
|
15
15
|
|
|
16
16
|
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
17
17
|
|
|
18
18
|
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'cryptobyte-website' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
19
19
|
|
|
20
|
+
declare const uuidv4: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
21
|
+
|
|
20
22
|
declare const base: {
|
|
21
23
|
id: drizzle_orm.IsPrimaryKey<drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"id", [string, ...string[]], number | undefined>>>;
|
|
22
24
|
createdAt: drizzle_orm.HasDefault<drizzle_orm_sqlite_core.SQLiteTimestampBuilderInitial<"created_at">>;
|
|
@@ -33,7 +35,7 @@ declare const bankAccount: {
|
|
|
33
35
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
|
|
34
36
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
|
|
35
37
|
currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]], number | undefined>>;
|
|
36
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["
|
|
38
|
+
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
|
|
37
39
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
|
|
38
40
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
|
|
39
41
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
|
|
@@ -77,8 +79,6 @@ declare const logger: () => MiddlewareHandler;
|
|
|
77
79
|
|
|
78
80
|
declare const signature: <TOrganizationService, TJwtPayload>() => MiddlewareHandler;
|
|
79
81
|
|
|
80
|
-
declare const ENVIRONMENT: string[];
|
|
81
|
-
|
|
82
82
|
interface AuditLogPayload<T> {
|
|
83
83
|
action: T;
|
|
84
84
|
actorId: string;
|
|
@@ -208,7 +208,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
208
208
|
AVAX: "AVAX";
|
|
209
209
|
}>>;
|
|
210
210
|
country: z$1.ZodOptional<z$1.ZodEnum<{
|
|
211
|
-
EC: "EC";
|
|
212
211
|
AF: "AF";
|
|
213
212
|
AL: "AL";
|
|
214
213
|
DZ: "DZ";
|
|
@@ -262,6 +261,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
262
261
|
DM: "DM";
|
|
263
262
|
DO: "DO";
|
|
264
263
|
TL: "TL";
|
|
264
|
+
EC: "EC";
|
|
265
265
|
EG: "EG";
|
|
266
266
|
SV: "SV";
|
|
267
267
|
GQ: "GQ";
|
|
@@ -678,6 +678,16 @@ declare const getDrizzleD1Config: () => {
|
|
|
678
678
|
dialect: "sqlite";
|
|
679
679
|
};
|
|
680
680
|
|
|
681
|
+
type Operator = 'like' | 'ilike';
|
|
682
|
+
type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
|
|
683
|
+
type BuildSearchOptions = {
|
|
684
|
+
operator?: Operator;
|
|
685
|
+
wrap?: Wrap;
|
|
686
|
+
};
|
|
687
|
+
declare const buildSearchConditions: (search: string | undefined | null, columns: ReadonlyArray<AnyColumn>, opts?: BuildSearchOptions) => drizzle_orm.SQL<unknown> | undefined;
|
|
688
|
+
declare const buildMultiFilterConditions: <T>(column: drizzle_orm.Column, value: T | T[] | undefined) => drizzle_orm.SQL<unknown> | undefined;
|
|
689
|
+
declare const buildRangeFilterConditions: <T>(column: drizzle_orm.Column, minValue: T | undefined, maxValue: T | undefined) => drizzle_orm.SQL<unknown> | undefined;
|
|
690
|
+
|
|
681
691
|
interface Command<TAuditAction = string> {
|
|
682
692
|
handler: (db: DrizzleD1Database<Record<string, unknown>>) => CommandItem<TAuditAction>;
|
|
683
693
|
}
|
|
@@ -720,6 +730,10 @@ interface UseFetchOptions extends RequestInit {
|
|
|
720
730
|
}
|
|
721
731
|
declare function useFetch<T = unknown>(url: string, { parseAs, ...options }?: UseFetchOptions): Promise<Result<T>>;
|
|
722
732
|
|
|
733
|
+
declare const createSignatureKeyPair: () => Promise<{
|
|
734
|
+
publicKey: string;
|
|
735
|
+
privateKey: string;
|
|
736
|
+
}>;
|
|
723
737
|
declare const signPayload: ({ payload, privateKey, }: {
|
|
724
738
|
payload: string;
|
|
725
739
|
privateKey: string;
|
|
@@ -820,5 +834,5 @@ interface WithRetryCounterOptions {
|
|
|
820
834
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
821
835
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
822
836
|
|
|
823
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|
|
824
|
-
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput };
|
|
837
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|
|
838
|
+
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as drizzle_orm from 'drizzle-orm';
|
|
2
|
-
import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult } from 'drizzle-orm';
|
|
2
|
+
import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn } from 'drizzle-orm';
|
|
3
3
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { AnySQLiteTable } from 'drizzle-orm/sqlite-core';
|
|
5
5
|
import { MiddlewareHandler } from 'hono/types';
|
|
@@ -11,12 +11,14 @@ import { Queue } from '@cloudflare/workers-types';
|
|
|
11
11
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
12
12
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
13
13
|
|
|
14
|
-
declare const
|
|
14
|
+
declare const ENVIRONMENT: string[];
|
|
15
15
|
|
|
16
16
|
type Environment = string | 'localhost' | 'dev' | 'test' | 'staging' | 'production';
|
|
17
17
|
|
|
18
18
|
type Project = 'creditio' | 'dbu-mdm' | 'dbu-txs' | 'cryptobyte-website' | 'lrf-website' | 'moneio' | 'paycorp-fiat-processor';
|
|
19
19
|
|
|
20
|
+
declare const uuidv4: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
21
|
+
|
|
20
22
|
declare const base: {
|
|
21
23
|
id: drizzle_orm.IsPrimaryKey<drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"id", [string, ...string[]], number | undefined>>>;
|
|
22
24
|
createdAt: drizzle_orm.HasDefault<drizzle_orm_sqlite_core.SQLiteTimestampBuilderInitial<"created_at">>;
|
|
@@ -33,7 +35,7 @@ declare const bankAccount: {
|
|
|
33
35
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
|
|
34
36
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
|
|
35
37
|
currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]], number | undefined>>;
|
|
36
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["
|
|
38
|
+
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
|
|
37
39
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
|
|
38
40
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
|
|
39
41
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
|
|
@@ -77,8 +79,6 @@ declare const logger: () => MiddlewareHandler;
|
|
|
77
79
|
|
|
78
80
|
declare const signature: <TOrganizationService, TJwtPayload>() => MiddlewareHandler;
|
|
79
81
|
|
|
80
|
-
declare const ENVIRONMENT: string[];
|
|
81
|
-
|
|
82
82
|
interface AuditLogPayload<T> {
|
|
83
83
|
action: T;
|
|
84
84
|
actorId: string;
|
|
@@ -208,7 +208,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
208
208
|
AVAX: "AVAX";
|
|
209
209
|
}>>;
|
|
210
210
|
country: z$1.ZodOptional<z$1.ZodEnum<{
|
|
211
|
-
EC: "EC";
|
|
212
211
|
AF: "AF";
|
|
213
212
|
AL: "AL";
|
|
214
213
|
DZ: "DZ";
|
|
@@ -262,6 +261,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
262
261
|
DM: "DM";
|
|
263
262
|
DO: "DO";
|
|
264
263
|
TL: "TL";
|
|
264
|
+
EC: "EC";
|
|
265
265
|
EG: "EG";
|
|
266
266
|
SV: "SV";
|
|
267
267
|
GQ: "GQ";
|
|
@@ -678,6 +678,16 @@ declare const getDrizzleD1Config: () => {
|
|
|
678
678
|
dialect: "sqlite";
|
|
679
679
|
};
|
|
680
680
|
|
|
681
|
+
type Operator = 'like' | 'ilike';
|
|
682
|
+
type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
|
|
683
|
+
type BuildSearchOptions = {
|
|
684
|
+
operator?: Operator;
|
|
685
|
+
wrap?: Wrap;
|
|
686
|
+
};
|
|
687
|
+
declare const buildSearchConditions: (search: string | undefined | null, columns: ReadonlyArray<AnyColumn>, opts?: BuildSearchOptions) => drizzle_orm.SQL<unknown> | undefined;
|
|
688
|
+
declare const buildMultiFilterConditions: <T>(column: drizzle_orm.Column, value: T | T[] | undefined) => drizzle_orm.SQL<unknown> | undefined;
|
|
689
|
+
declare const buildRangeFilterConditions: <T>(column: drizzle_orm.Column, minValue: T | undefined, maxValue: T | undefined) => drizzle_orm.SQL<unknown> | undefined;
|
|
690
|
+
|
|
681
691
|
interface Command<TAuditAction = string> {
|
|
682
692
|
handler: (db: DrizzleD1Database<Record<string, unknown>>) => CommandItem<TAuditAction>;
|
|
683
693
|
}
|
|
@@ -720,6 +730,10 @@ interface UseFetchOptions extends RequestInit {
|
|
|
720
730
|
}
|
|
721
731
|
declare function useFetch<T = unknown>(url: string, { parseAs, ...options }?: UseFetchOptions): Promise<Result<T>>;
|
|
722
732
|
|
|
733
|
+
declare const createSignatureKeyPair: () => Promise<{
|
|
734
|
+
publicKey: string;
|
|
735
|
+
privateKey: string;
|
|
736
|
+
}>;
|
|
723
737
|
declare const signPayload: ({ payload, privateKey, }: {
|
|
724
738
|
payload: string;
|
|
725
739
|
privateKey: string;
|
|
@@ -820,5 +834,5 @@ interface WithRetryCounterOptions {
|
|
|
820
834
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
821
835
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
822
836
|
|
|
823
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|
|
824
|
-
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput };
|
|
837
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|
|
838
|
+
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
|
1
|
+
import { sql, or, inArray, eq, gte, lte, and } from 'drizzle-orm';
|
|
2
2
|
import { integer, text } from 'drizzle-orm/sqlite-core';
|
|
3
3
|
import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
|
|
4
4
|
import { createMiddleware } from 'hono/factory';
|
|
@@ -7,12 +7,17 @@ import { createError } from 'h3';
|
|
|
7
7
|
import { z as z$1 } from 'zod';
|
|
8
8
|
import 'cloudflare';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
|
-
import crypto$1 from 'node:crypto';
|
|
10
|
+
import crypto$1, { subtle } from 'node:crypto';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { parse } from 'comment-json';
|
|
13
13
|
import * as z from 'zod/v4/core';
|
|
14
14
|
import superjson from 'superjson';
|
|
15
15
|
|
|
16
|
+
const ENVIRONMENT = ["dev", "test", "staging", "production"];
|
|
17
|
+
|
|
18
|
+
const COMPATIBILITY_DATE = "2025-06-04";
|
|
19
|
+
const COMPATIBILITY_FLAGS = ["nodejs_compat"];
|
|
20
|
+
|
|
16
21
|
const uuidv4 = () => crypto.randomUUID();
|
|
17
22
|
|
|
18
23
|
const base = {
|
|
@@ -48,11 +53,6 @@ const bankAccount = {
|
|
|
48
53
|
|
|
49
54
|
const USER_ROLES = ["OWNER", "ADMIN", "MEMBER"];
|
|
50
55
|
|
|
51
|
-
const ENVIRONMENT = ["dev", "test", "staging", "production"];
|
|
52
|
-
|
|
53
|
-
const COMPATIBILITY_DATE = "2025-06-04";
|
|
54
|
-
const COMPATIBILITY_FLAGS = ["nodejs_compat"];
|
|
55
|
-
|
|
56
56
|
const composeWranglerBase = ({
|
|
57
57
|
project,
|
|
58
58
|
name
|
|
@@ -386,6 +386,34 @@ const getDrizzleD1Config = () => ({
|
|
|
386
386
|
...getD1Credentials()
|
|
387
387
|
});
|
|
388
388
|
|
|
389
|
+
const buildSearchConditions = (search, columns, opts = {}) => {
|
|
390
|
+
const { wrap = "both" } = opts;
|
|
391
|
+
if (!search || search.trim() === "" || columns.length === 0) return void 0;
|
|
392
|
+
const searchTerm = search.toLowerCase();
|
|
393
|
+
const pattern = wrap === "both" ? `%${searchTerm}%` : wrap === "prefix" ? `%${searchTerm}` : wrap === "suffix" ? `${searchTerm}%` : searchTerm;
|
|
394
|
+
const parts = columns.map((col) => sql`LOWER(${col} || '') LIKE ${pattern}`);
|
|
395
|
+
return parts.length === 1 ? parts[0] : or(...parts);
|
|
396
|
+
};
|
|
397
|
+
const buildMultiFilterConditions = (column, value) => {
|
|
398
|
+
if (value === void 0) return void 0;
|
|
399
|
+
if (Array.isArray(value)) {
|
|
400
|
+
return value.length > 0 ? inArray(column, value) : void 0;
|
|
401
|
+
}
|
|
402
|
+
return eq(column, value);
|
|
403
|
+
};
|
|
404
|
+
const buildRangeFilterConditions = (column, minValue, maxValue) => {
|
|
405
|
+
const conditions = [];
|
|
406
|
+
if (minValue !== void 0) {
|
|
407
|
+
conditions.push(gte(column, minValue));
|
|
408
|
+
}
|
|
409
|
+
if (maxValue !== void 0) {
|
|
410
|
+
conditions.push(lte(column, maxValue));
|
|
411
|
+
}
|
|
412
|
+
if (conditions.length === 0) return void 0;
|
|
413
|
+
if (conditions.length === 1) return conditions[0];
|
|
414
|
+
return and(...conditions);
|
|
415
|
+
};
|
|
416
|
+
|
|
389
417
|
class DatabaseTransaction {
|
|
390
418
|
constructor(db, serviceName, auditLogWriter) {
|
|
391
419
|
this.db = db;
|
|
@@ -488,6 +516,24 @@ const logResponse = (log) => {
|
|
|
488
516
|
console.log(`RESPONSE | An outgoing response has been recorded.`, log);
|
|
489
517
|
};
|
|
490
518
|
|
|
519
|
+
const createSignatureKeyPair = async () => {
|
|
520
|
+
const { publicKey, privateKey } = await subtle.generateKey(
|
|
521
|
+
{
|
|
522
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
523
|
+
modulusLength: 4096,
|
|
524
|
+
publicExponent: new Uint8Array([1, 0, 1]),
|
|
525
|
+
hash: "SHA-256"
|
|
526
|
+
},
|
|
527
|
+
true,
|
|
528
|
+
["sign", "verify"]
|
|
529
|
+
);
|
|
530
|
+
const exportedPublicKey = await subtle.exportKey("spki", publicKey);
|
|
531
|
+
const exportedPrivateKey = await subtle.exportKey("pkcs8", privateKey);
|
|
532
|
+
return {
|
|
533
|
+
publicKey: Buffer.from(exportedPublicKey).toString("base64"),
|
|
534
|
+
privateKey: Buffer.from(exportedPrivateKey).toString("base64")
|
|
535
|
+
};
|
|
536
|
+
};
|
|
491
537
|
const signPayload = async ({
|
|
492
538
|
payload,
|
|
493
539
|
privateKey
|
|
@@ -1006,4 +1052,4 @@ function develitWorker(Worker) {
|
|
|
1006
1052
|
return DevelitWorker;
|
|
1007
1053
|
}
|
|
1008
1054
|
|
|
1009
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|
|
1055
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, handleActionResponse, ibanSchema, idempotency, ip, isInternalError, jwt, logger, paginationQuerySchema, paginationSchema, service, signPayload, signature, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature };
|