@develit-io/backend-sdk 11.1.0 → 11.3.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 +88 -16
- package/dist/index.d.ts +88 -16
- package/dist/index.mjs +48 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as drizzle_orm from 'drizzle-orm';
|
|
2
|
-
import { Table, InferInsertModel, AnyColumn } from 'drizzle-orm';
|
|
2
|
+
import { Table, InferInsertModel, InferSelectModel, 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
|
-
import { z as z$1, ZodObject, ZodOptional
|
|
5
|
+
import { z as z$1, ZodType, ZodObject, ZodOptional } from 'zod';
|
|
6
6
|
import * as z from 'zod/v4/core';
|
|
7
7
|
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
9
9
|
import { Queue } from '@cloudflare/workers-types';
|
|
10
10
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
11
11
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
12
|
-
export { createSelectSchema } from 'drizzle-orm/zod';
|
|
13
12
|
|
|
14
13
|
declare const ENVIRONMENT: string[];
|
|
15
14
|
|
|
@@ -38,7 +37,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
|
|
|
38
37
|
city: z$1.ZodOptional<z$1.ZodString>;
|
|
39
38
|
postalCode: z$1.ZodOptional<z$1.ZodString>;
|
|
40
39
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
41
|
-
IM: "IM";
|
|
42
40
|
AF: "AF";
|
|
43
41
|
AL: "AL";
|
|
44
42
|
DZ: "DZ";
|
|
@@ -127,6 +125,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
|
|
|
127
125
|
IR: "IR";
|
|
128
126
|
IQ: "IQ";
|
|
129
127
|
IE: "IE";
|
|
128
|
+
IM: "IM";
|
|
130
129
|
IL: "IL";
|
|
131
130
|
IT: "IT";
|
|
132
131
|
CI: "CI";
|
|
@@ -327,7 +326,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
327
326
|
city: z$1.ZodOptional<z$1.ZodString>;
|
|
328
327
|
postalCode: z$1.ZodOptional<z$1.ZodString>;
|
|
329
328
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
330
|
-
IM: "IM";
|
|
331
329
|
AF: "AF";
|
|
332
330
|
AL: "AL";
|
|
333
331
|
DZ: "DZ";
|
|
@@ -416,6 +414,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
416
414
|
IR: "IR";
|
|
417
415
|
IQ: "IQ";
|
|
418
416
|
IE: "IE";
|
|
417
|
+
IM: "IM";
|
|
419
418
|
IL: "IL";
|
|
420
419
|
IT: "IT";
|
|
421
420
|
CI: "CI";
|
|
@@ -598,7 +597,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
598
597
|
AVAX: "AVAX";
|
|
599
598
|
}>>;
|
|
600
599
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
601
|
-
IM: "IM";
|
|
602
600
|
AF: "AF";
|
|
603
601
|
AL: "AL";
|
|
604
602
|
DZ: "DZ";
|
|
@@ -687,6 +685,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
687
685
|
IR: "IR";
|
|
688
686
|
IQ: "IQ";
|
|
689
687
|
IE: "IE";
|
|
688
|
+
IM: "IM";
|
|
690
689
|
IL: "IL";
|
|
691
690
|
IT: "IT";
|
|
692
691
|
CI: "CI";
|
|
@@ -828,7 +827,7 @@ declare const bankAccount: {
|
|
|
828
827
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
829
828
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
830
829
|
currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["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")[]]>>;
|
|
831
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["
|
|
830
|
+
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["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" | "US" | "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" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
|
|
832
831
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
833
832
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
834
833
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
@@ -838,34 +837,63 @@ declare const bankAccount: {
|
|
|
838
837
|
|
|
839
838
|
declare const auditFieldKeys: readonly ["createdAt", "createdBy", "updatedAt", "updatedBy", "deletedAt", "deletedBy"];
|
|
840
839
|
type AuditKey = (typeof auditFieldKeys)[number];
|
|
840
|
+
type Customizations = Record<string, () => ZodType>;
|
|
841
|
+
type ResolveCustomizations<TC extends Customizations> = {
|
|
842
|
+
[K in keyof TC]: TC[K] extends () => infer R ? R extends ZodType ? R : never : never;
|
|
843
|
+
};
|
|
841
844
|
type FieldSchema<T> = undefined extends T ? ZodOptional<ZodType<Exclude<T, undefined>>> : ZodType<T>;
|
|
842
|
-
type
|
|
845
|
+
type InsertShape<TTable extends Table> = {
|
|
843
846
|
[K in keyof Omit<InferInsertModel<TTable>, AuditKey | 'id'>]-?: FieldSchema<InferInsertModel<TTable>[K]>;
|
|
844
847
|
} & {
|
|
845
848
|
id: ZodOptional<ZodType<string>>;
|
|
846
|
-
}
|
|
847
|
-
type
|
|
849
|
+
};
|
|
850
|
+
type UpdateShape<TTable extends Table> = {
|
|
848
851
|
[K in keyof Omit<InferInsertModel<TTable>, AuditKey | 'id'>]-?: ZodOptional<ZodType<Exclude<InferInsertModel<TTable>[K], undefined>>>;
|
|
849
852
|
} & {
|
|
850
853
|
id: ZodType<string>;
|
|
851
|
-
}
|
|
854
|
+
};
|
|
855
|
+
type SelectShape<TTable extends Table> = {
|
|
856
|
+
[K in keyof InferSelectModel<TTable>]-?: FieldSchema<InferSelectModel<TTable>[K]>;
|
|
857
|
+
};
|
|
858
|
+
type WithCustomizations<TShape, TC extends Customizations> = Omit<TShape, keyof TC> & ResolveCustomizations<TC>;
|
|
859
|
+
type InsertSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<InsertShape<TTable>, TC>>;
|
|
860
|
+
type UpdateSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<UpdateShape<TTable>, TC>>;
|
|
861
|
+
type SelectSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<SelectShape<TTable>, TC>>;
|
|
852
862
|
/**
|
|
853
|
-
* Creates Zod schema for DB insert
|
|
863
|
+
* Creates Zod schema for DB insert.
|
|
854
864
|
* - `id` optional (auto-generated if not provided)
|
|
855
865
|
* - Audit fields omitted (set by DB)
|
|
866
|
+
*
|
|
867
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
868
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* const schema = createInsertSchema(account, {
|
|
872
|
+
* lastSyncMetadata: () => z.custom<LastSyncMetadata>().optional(),
|
|
873
|
+
* })
|
|
856
874
|
*/
|
|
857
|
-
declare function createInsertSchema<TTable extends Table
|
|
875
|
+
declare function createInsertSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): InsertSchemaOf<TTable, TC>;
|
|
858
876
|
/**
|
|
859
|
-
* Creates Zod schema for DB update
|
|
877
|
+
* Creates Zod schema for DB update.
|
|
860
878
|
* - `id` required
|
|
861
879
|
* - All other fields optional
|
|
862
880
|
* - Audit fields omitted
|
|
881
|
+
*
|
|
882
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
883
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
863
884
|
*/
|
|
864
|
-
declare function createUpdateSchema<TTable extends Table
|
|
885
|
+
declare function createUpdateSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): UpdateSchemaOf<TTable, TC>;
|
|
865
886
|
/**
|
|
866
887
|
* Creates Zod schema for API PATCH (alias for updateSchema)
|
|
867
888
|
*/
|
|
868
889
|
declare const createPatchSchema: typeof createUpdateSchema;
|
|
890
|
+
/**
|
|
891
|
+
* Creates Zod schema for DB select rows.
|
|
892
|
+
*
|
|
893
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
894
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
895
|
+
*/
|
|
896
|
+
declare function createSelectSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): SelectSchemaOf<TTable, TC>;
|
|
869
897
|
|
|
870
898
|
declare const USER_ROLES: readonly ["OWNER", "ADMIN", "MEMBER"];
|
|
871
899
|
type UserRole = (typeof USER_ROLES)[number];
|
|
@@ -1160,6 +1188,28 @@ declare const getDrizzleD1Config: () => Promise<{
|
|
|
1160
1188
|
dialect: "sqlite";
|
|
1161
1189
|
}>;
|
|
1162
1190
|
|
|
1191
|
+
interface QueryInChunksOptions {
|
|
1192
|
+
/**
|
|
1193
|
+
* Maximum number of values per chunk. Cloudflare D1's hard limit is 100
|
|
1194
|
+
* bound parameters per statement; defaults to 90 to leave room for
|
|
1195
|
+
* additional `WHERE` predicates.
|
|
1196
|
+
*/
|
|
1197
|
+
chunkSize?: number;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Runs the given query function over `values` in chunks small enough to fit
|
|
1201
|
+
* under Cloudflare D1's 100-parameter limit, concatenating the results.
|
|
1202
|
+
*
|
|
1203
|
+
* Use this whenever an `inArray(column, ids)` (or similar) query may exceed
|
|
1204
|
+
* ~80 values — D1 will reject larger statements with a parameter limit error.
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* const payments = await queryInChunks(bankRefIds, (chunk) =>
|
|
1208
|
+
* db.select().from(payment).where(inArray(payment.bankRefId, chunk)),
|
|
1209
|
+
* )
|
|
1210
|
+
*/
|
|
1211
|
+
declare function queryInChunks<TParam, TResult>(values: readonly TParam[], queryFn: (chunk: TParam[]) => Promise<TResult[]>, options?: QueryInChunksOptions): Promise<TResult[]>;
|
|
1212
|
+
|
|
1163
1213
|
type Operator = 'like' | 'ilike';
|
|
1164
1214
|
type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
|
|
1165
1215
|
type BuildSearchOptions = {
|
|
@@ -1223,6 +1273,28 @@ type OptionalToNull<T> = {
|
|
|
1223
1273
|
declare function optionalToNull<T extends object>(obj: T): OptionalToNull<T>;
|
|
1224
1274
|
|
|
1225
1275
|
declare const calculateExponentialBackoff: (attempts: number, baseDelaySeconds: number) => number;
|
|
1276
|
+
/**
|
|
1277
|
+
* Splits messages into chunks that fit Cloudflare Queue sendBatch limits
|
|
1278
|
+
* (100 messages OR 256 KB total per batch). Oversized single messages are
|
|
1279
|
+
* emitted alone — Cloudflare will reject them, but the helper does not loop.
|
|
1280
|
+
*/
|
|
1281
|
+
declare function chunkQueueMessages<T>(messages: T[]): Generator<T[]>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Sends a single message via `queue.send()` or a batch via `queue.sendBatch()`.
|
|
1284
|
+
* Batches are automatically chunked to respect Cloudflare Queue limits.
|
|
1285
|
+
*/
|
|
1286
|
+
declare function pushToQueue<T>(queue: Queue, message: T | T[]): Promise<void>;
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Deep-clones an object and replaces values of sensitive keys with '[REDACTED]'.
|
|
1290
|
+
* Key matching is case-insensitive and ignores underscores/hyphens,
|
|
1291
|
+
* so `password`, `Password`, `access_token`, `accessToken`, `ACCESS_TOKEN` are all matched.
|
|
1292
|
+
*
|
|
1293
|
+
* @param value - The value to redact
|
|
1294
|
+
* @param sensitiveKeys - Additional keys to redact (merged with defaults)
|
|
1295
|
+
* @returns A deep copy with sensitive values replaced
|
|
1296
|
+
*/
|
|
1297
|
+
declare function redact<T>(value: T, sensitiveKeys?: string[]): T;
|
|
1226
1298
|
|
|
1227
1299
|
declare const RPCResponse: {
|
|
1228
1300
|
/**
|
|
@@ -1311,5 +1383,5 @@ interface WithRetryCounterOptions {
|
|
|
1311
1383
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
1312
1384
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
1313
1385
|
|
|
1314
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
|
|
1386
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, pushToQueue, queryInChunks, redact, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
|
|
1315
1387
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as drizzle_orm from 'drizzle-orm';
|
|
2
|
-
import { Table, InferInsertModel, AnyColumn } from 'drizzle-orm';
|
|
2
|
+
import { Table, InferInsertModel, InferSelectModel, 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
|
-
import { z as z$1, ZodObject, ZodOptional
|
|
5
|
+
import { z as z$1, ZodType, ZodObject, ZodOptional } from 'zod';
|
|
6
6
|
import * as z from 'zod/v4/core';
|
|
7
7
|
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
9
9
|
import { Queue } from '@cloudflare/workers-types';
|
|
10
10
|
import { BatchItem } from 'drizzle-orm/batch';
|
|
11
11
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
12
|
-
export { createSelectSchema } from 'drizzle-orm/zod';
|
|
13
12
|
|
|
14
13
|
declare const ENVIRONMENT: string[];
|
|
15
14
|
|
|
@@ -38,7 +37,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
|
|
|
38
37
|
city: z$1.ZodOptional<z$1.ZodString>;
|
|
39
38
|
postalCode: z$1.ZodOptional<z$1.ZodString>;
|
|
40
39
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
41
|
-
IM: "IM";
|
|
42
40
|
AF: "AF";
|
|
43
41
|
AL: "AL";
|
|
44
42
|
DZ: "DZ";
|
|
@@ -127,6 +125,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
|
|
|
127
125
|
IR: "IR";
|
|
128
126
|
IQ: "IQ";
|
|
129
127
|
IE: "IE";
|
|
128
|
+
IM: "IM";
|
|
130
129
|
IL: "IL";
|
|
131
130
|
IT: "IT";
|
|
132
131
|
CI: "CI";
|
|
@@ -327,7 +326,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
327
326
|
city: z$1.ZodOptional<z$1.ZodString>;
|
|
328
327
|
postalCode: z$1.ZodOptional<z$1.ZodString>;
|
|
329
328
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
330
|
-
IM: "IM";
|
|
331
329
|
AF: "AF";
|
|
332
330
|
AL: "AL";
|
|
333
331
|
DZ: "DZ";
|
|
@@ -416,6 +414,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
416
414
|
IR: "IR";
|
|
417
415
|
IQ: "IQ";
|
|
418
416
|
IE: "IE";
|
|
417
|
+
IM: "IM";
|
|
419
418
|
IL: "IL";
|
|
420
419
|
IT: "IT";
|
|
421
420
|
CI: "CI";
|
|
@@ -598,7 +597,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
598
597
|
AVAX: "AVAX";
|
|
599
598
|
}>>;
|
|
600
599
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
601
|
-
IM: "IM";
|
|
602
600
|
AF: "AF";
|
|
603
601
|
AL: "AL";
|
|
604
602
|
DZ: "DZ";
|
|
@@ -687,6 +685,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
687
685
|
IR: "IR";
|
|
688
686
|
IQ: "IQ";
|
|
689
687
|
IE: "IE";
|
|
688
|
+
IM: "IM";
|
|
690
689
|
IL: "IL";
|
|
691
690
|
IT: "IT";
|
|
692
691
|
CI: "CI";
|
|
@@ -828,7 +827,7 @@ declare const bankAccount: {
|
|
|
828
827
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
829
828
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
830
829
|
currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["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")[]]>>;
|
|
831
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["
|
|
830
|
+
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["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" | "US" | "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" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
|
|
832
831
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
833
832
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
834
833
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
|
|
@@ -838,34 +837,63 @@ declare const bankAccount: {
|
|
|
838
837
|
|
|
839
838
|
declare const auditFieldKeys: readonly ["createdAt", "createdBy", "updatedAt", "updatedBy", "deletedAt", "deletedBy"];
|
|
840
839
|
type AuditKey = (typeof auditFieldKeys)[number];
|
|
840
|
+
type Customizations = Record<string, () => ZodType>;
|
|
841
|
+
type ResolveCustomizations<TC extends Customizations> = {
|
|
842
|
+
[K in keyof TC]: TC[K] extends () => infer R ? R extends ZodType ? R : never : never;
|
|
843
|
+
};
|
|
841
844
|
type FieldSchema<T> = undefined extends T ? ZodOptional<ZodType<Exclude<T, undefined>>> : ZodType<T>;
|
|
842
|
-
type
|
|
845
|
+
type InsertShape<TTable extends Table> = {
|
|
843
846
|
[K in keyof Omit<InferInsertModel<TTable>, AuditKey | 'id'>]-?: FieldSchema<InferInsertModel<TTable>[K]>;
|
|
844
847
|
} & {
|
|
845
848
|
id: ZodOptional<ZodType<string>>;
|
|
846
|
-
}
|
|
847
|
-
type
|
|
849
|
+
};
|
|
850
|
+
type UpdateShape<TTable extends Table> = {
|
|
848
851
|
[K in keyof Omit<InferInsertModel<TTable>, AuditKey | 'id'>]-?: ZodOptional<ZodType<Exclude<InferInsertModel<TTable>[K], undefined>>>;
|
|
849
852
|
} & {
|
|
850
853
|
id: ZodType<string>;
|
|
851
|
-
}
|
|
854
|
+
};
|
|
855
|
+
type SelectShape<TTable extends Table> = {
|
|
856
|
+
[K in keyof InferSelectModel<TTable>]-?: FieldSchema<InferSelectModel<TTable>[K]>;
|
|
857
|
+
};
|
|
858
|
+
type WithCustomizations<TShape, TC extends Customizations> = Omit<TShape, keyof TC> & ResolveCustomizations<TC>;
|
|
859
|
+
type InsertSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<InsertShape<TTable>, TC>>;
|
|
860
|
+
type UpdateSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<UpdateShape<TTable>, TC>>;
|
|
861
|
+
type SelectSchemaOf<TTable extends Table, TC extends Customizations = Record<never, never>> = ZodObject<WithCustomizations<SelectShape<TTable>, TC>>;
|
|
852
862
|
/**
|
|
853
|
-
* Creates Zod schema for DB insert
|
|
863
|
+
* Creates Zod schema for DB insert.
|
|
854
864
|
* - `id` optional (auto-generated if not provided)
|
|
855
865
|
* - Audit fields omitted (set by DB)
|
|
866
|
+
*
|
|
867
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
868
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* const schema = createInsertSchema(account, {
|
|
872
|
+
* lastSyncMetadata: () => z.custom<LastSyncMetadata>().optional(),
|
|
873
|
+
* })
|
|
856
874
|
*/
|
|
857
|
-
declare function createInsertSchema<TTable extends Table
|
|
875
|
+
declare function createInsertSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): InsertSchemaOf<TTable, TC>;
|
|
858
876
|
/**
|
|
859
|
-
* Creates Zod schema for DB update
|
|
877
|
+
* Creates Zod schema for DB update.
|
|
860
878
|
* - `id` required
|
|
861
879
|
* - All other fields optional
|
|
862
880
|
* - Audit fields omitted
|
|
881
|
+
*
|
|
882
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
883
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
863
884
|
*/
|
|
864
|
-
declare function createUpdateSchema<TTable extends Table
|
|
885
|
+
declare function createUpdateSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): UpdateSchemaOf<TTable, TC>;
|
|
865
886
|
/**
|
|
866
887
|
* Creates Zod schema for API PATCH (alias for updateSchema)
|
|
867
888
|
*/
|
|
868
889
|
declare const createPatchSchema: typeof createUpdateSchema;
|
|
890
|
+
/**
|
|
891
|
+
* Creates Zod schema for DB select rows.
|
|
892
|
+
*
|
|
893
|
+
* Pass `customizations` to re-narrow columns whose `.$type<T>()` annotation
|
|
894
|
+
* is lost by drizzle-orm/zod (typically JSON columns).
|
|
895
|
+
*/
|
|
896
|
+
declare function createSelectSchema<TTable extends Table, const TC extends Customizations = Record<never, never>>(table: TTable, customizations?: TC): SelectSchemaOf<TTable, TC>;
|
|
869
897
|
|
|
870
898
|
declare const USER_ROLES: readonly ["OWNER", "ADMIN", "MEMBER"];
|
|
871
899
|
type UserRole = (typeof USER_ROLES)[number];
|
|
@@ -1160,6 +1188,28 @@ declare const getDrizzleD1Config: () => Promise<{
|
|
|
1160
1188
|
dialect: "sqlite";
|
|
1161
1189
|
}>;
|
|
1162
1190
|
|
|
1191
|
+
interface QueryInChunksOptions {
|
|
1192
|
+
/**
|
|
1193
|
+
* Maximum number of values per chunk. Cloudflare D1's hard limit is 100
|
|
1194
|
+
* bound parameters per statement; defaults to 90 to leave room for
|
|
1195
|
+
* additional `WHERE` predicates.
|
|
1196
|
+
*/
|
|
1197
|
+
chunkSize?: number;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Runs the given query function over `values` in chunks small enough to fit
|
|
1201
|
+
* under Cloudflare D1's 100-parameter limit, concatenating the results.
|
|
1202
|
+
*
|
|
1203
|
+
* Use this whenever an `inArray(column, ids)` (or similar) query may exceed
|
|
1204
|
+
* ~80 values — D1 will reject larger statements with a parameter limit error.
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* const payments = await queryInChunks(bankRefIds, (chunk) =>
|
|
1208
|
+
* db.select().from(payment).where(inArray(payment.bankRefId, chunk)),
|
|
1209
|
+
* )
|
|
1210
|
+
*/
|
|
1211
|
+
declare function queryInChunks<TParam, TResult>(values: readonly TParam[], queryFn: (chunk: TParam[]) => Promise<TResult[]>, options?: QueryInChunksOptions): Promise<TResult[]>;
|
|
1212
|
+
|
|
1163
1213
|
type Operator = 'like' | 'ilike';
|
|
1164
1214
|
type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
|
|
1165
1215
|
type BuildSearchOptions = {
|
|
@@ -1223,6 +1273,28 @@ type OptionalToNull<T> = {
|
|
|
1223
1273
|
declare function optionalToNull<T extends object>(obj: T): OptionalToNull<T>;
|
|
1224
1274
|
|
|
1225
1275
|
declare const calculateExponentialBackoff: (attempts: number, baseDelaySeconds: number) => number;
|
|
1276
|
+
/**
|
|
1277
|
+
* Splits messages into chunks that fit Cloudflare Queue sendBatch limits
|
|
1278
|
+
* (100 messages OR 256 KB total per batch). Oversized single messages are
|
|
1279
|
+
* emitted alone — Cloudflare will reject them, but the helper does not loop.
|
|
1280
|
+
*/
|
|
1281
|
+
declare function chunkQueueMessages<T>(messages: T[]): Generator<T[]>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Sends a single message via `queue.send()` or a batch via `queue.sendBatch()`.
|
|
1284
|
+
* Batches are automatically chunked to respect Cloudflare Queue limits.
|
|
1285
|
+
*/
|
|
1286
|
+
declare function pushToQueue<T>(queue: Queue, message: T | T[]): Promise<void>;
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Deep-clones an object and replaces values of sensitive keys with '[REDACTED]'.
|
|
1290
|
+
* Key matching is case-insensitive and ignores underscores/hyphens,
|
|
1291
|
+
* so `password`, `Password`, `access_token`, `accessToken`, `ACCESS_TOKEN` are all matched.
|
|
1292
|
+
*
|
|
1293
|
+
* @param value - The value to redact
|
|
1294
|
+
* @param sensitiveKeys - Additional keys to redact (merged with defaults)
|
|
1295
|
+
* @returns A deep copy with sensitive values replaced
|
|
1296
|
+
*/
|
|
1297
|
+
declare function redact<T>(value: T, sensitiveKeys?: string[]): T;
|
|
1226
1298
|
|
|
1227
1299
|
declare const RPCResponse: {
|
|
1228
1300
|
/**
|
|
@@ -1311,5 +1383,5 @@ interface WithRetryCounterOptions {
|
|
|
1311
1383
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
1312
1384
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
1313
1385
|
|
|
1314
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
|
|
1386
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, pushToQueue, queryInChunks, redact, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
|
|
1315
1387
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,7 @@ export { u as uuidv4, a as uuidv5 } from './shared/backend-sdk.D_gzDKeC.mjs';
|
|
|
2
2
|
import { sql, inArray, eq, gte, lte, and, or } from 'drizzle-orm';
|
|
3
3
|
import { text, integer } from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
|
|
5
|
-
import { createInsertSchema as createInsertSchema$1 } from 'drizzle-orm/zod';
|
|
6
|
-
export { createSelectSchema } from 'drizzle-orm/zod';
|
|
5
|
+
import { createInsertSchema as createInsertSchema$1, createSelectSchema as createSelectSchema$1 } from 'drizzle-orm/zod';
|
|
7
6
|
import { z as z$1 } from 'zod';
|
|
8
7
|
import * as z from 'zod/v4/core';
|
|
9
8
|
import Cloudflare from 'cloudflare';
|
|
@@ -62,10 +61,14 @@ const auditFieldKeys = [
|
|
|
62
61
|
"deletedAt",
|
|
63
62
|
"deletedBy"
|
|
64
63
|
];
|
|
65
|
-
function
|
|
64
|
+
function toInsertShape(table) {
|
|
66
65
|
const schema = createInsertSchema$1(table);
|
|
67
66
|
return schema.shape;
|
|
68
67
|
}
|
|
68
|
+
function toSelectShape(table) {
|
|
69
|
+
const schema = createSelectSchema$1(table);
|
|
70
|
+
return schema.shape;
|
|
71
|
+
}
|
|
69
72
|
function omitAuditFields(shape) {
|
|
70
73
|
return Object.fromEntries(
|
|
71
74
|
Object.entries(shape).filter(
|
|
@@ -73,24 +76,42 @@ function omitAuditFields(shape) {
|
|
|
73
76
|
)
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
79
|
+
function resolveCustomizations(customizations) {
|
|
80
|
+
if (!customizations) return {};
|
|
81
|
+
return Object.fromEntries(
|
|
82
|
+
Object.entries(customizations).filter(([, fn]) => typeof fn === "function").map(([k, fn]) => [k, fn()])
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
function createInsertSchema(table, customizations) {
|
|
86
|
+
const shape = omitAuditFields(toInsertShape(table));
|
|
78
87
|
const idField = shape["id"];
|
|
79
88
|
if (!idField) throw new Error(`createInsertSchema: table has no 'id' column`);
|
|
80
89
|
return z$1.object({
|
|
81
90
|
...shape,
|
|
91
|
+
...resolveCustomizations(customizations),
|
|
82
92
|
id: idField.optional()
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
|
-
function createUpdateSchema(table) {
|
|
86
|
-
const { id, ...rest } = omitAuditFields(
|
|
95
|
+
function createUpdateSchema(table, customizations) {
|
|
96
|
+
const { id, ...rest } = omitAuditFields(toInsertShape(table));
|
|
87
97
|
if (!id) throw new Error(`createUpdateSchema: table has no 'id' column`);
|
|
88
98
|
const partialRest = Object.fromEntries(
|
|
89
99
|
Object.entries(rest).map(([k, v]) => [k, v.optional()])
|
|
90
100
|
);
|
|
91
|
-
return z$1.object({
|
|
101
|
+
return z$1.object({
|
|
102
|
+
...partialRest,
|
|
103
|
+
...resolveCustomizations(customizations),
|
|
104
|
+
id
|
|
105
|
+
});
|
|
92
106
|
}
|
|
93
107
|
const createPatchSchema = createUpdateSchema;
|
|
108
|
+
function createSelectSchema(table, customizations) {
|
|
109
|
+
const shape = toSelectShape(table);
|
|
110
|
+
return z$1.object({
|
|
111
|
+
...shape,
|
|
112
|
+
...resolveCustomizations(customizations)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
94
115
|
|
|
95
116
|
const USER_ROLES = ["OWNER", "ADMIN", "MEMBER"];
|
|
96
117
|
|
|
@@ -561,6 +582,24 @@ const getDrizzleD1Config = async () => ({
|
|
|
561
582
|
...await getD1Credentials()
|
|
562
583
|
});
|
|
563
584
|
|
|
585
|
+
const D1_MAX_BIND_VALUES = 90;
|
|
586
|
+
async function queryInChunks(values, queryFn, options) {
|
|
587
|
+
const chunkSize = options?.chunkSize ?? D1_MAX_BIND_VALUES;
|
|
588
|
+
if (chunkSize <= 0) {
|
|
589
|
+
throw new Error(
|
|
590
|
+
`queryInChunks: chunkSize must be positive, got ${chunkSize}`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
if (values.length === 0) return [];
|
|
594
|
+
const results = [];
|
|
595
|
+
for (let i = 0; i < values.length; i += chunkSize) {
|
|
596
|
+
const chunk = values.slice(i, i + chunkSize);
|
|
597
|
+
const rows = await queryFn(chunk);
|
|
598
|
+
results.push(...rows);
|
|
599
|
+
}
|
|
600
|
+
return results;
|
|
601
|
+
}
|
|
602
|
+
|
|
564
603
|
const buildSearchConditions = (search, columns, opts = {}) => {
|
|
565
604
|
const { wrap = "both" } = opts;
|
|
566
605
|
if (!search || search.trim() === "" || columns.length === 0) return void 0;
|
|
@@ -919,4 +958,4 @@ function develitWorker(Worker) {
|
|
|
919
958
|
return DevelitWorker;
|
|
920
959
|
}
|
|
921
960
|
|
|
922
|
-
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, workflowInstanceStatusSchema };
|
|
961
|
+
export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, pushToQueue, queryInChunks, redact, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, workflowInstanceStatusSchema };
|