@develit-io/backend-sdk 10.0.2 → 11.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as drizzle_orm from 'drizzle-orm';
2
- import { Table, ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn } from 'drizzle-orm';
2
+ import { Table, 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 { z as z$1, ZodObject, ZodType, ZodOptional } from 'zod';
@@ -38,7 +38,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
38
38
  city: z$1.ZodOptional<z$1.ZodString>;
39
39
  postalCode: z$1.ZodOptional<z$1.ZodString>;
40
40
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
41
- IM: "IM";
42
41
  AF: "AF";
43
42
  AL: "AL";
44
43
  DZ: "DZ";
@@ -127,6 +126,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
127
126
  IR: "IR";
128
127
  IQ: "IQ";
129
128
  IE: "IE";
129
+ IM: "IM";
130
130
  IL: "IL";
131
131
  IT: "IT";
132
132
  CI: "CI";
@@ -327,7 +327,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
327
327
  city: z$1.ZodOptional<z$1.ZodString>;
328
328
  postalCode: z$1.ZodOptional<z$1.ZodString>;
329
329
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
330
- IM: "IM";
331
330
  AF: "AF";
332
331
  AL: "AL";
333
332
  DZ: "DZ";
@@ -416,6 +415,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
416
415
  IR: "IR";
417
416
  IQ: "IQ";
418
417
  IE: "IE";
418
+ IM: "IM";
419
419
  IL: "IL";
420
420
  IT: "IT";
421
421
  CI: "CI";
@@ -598,7 +598,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
598
598
  AVAX: "AVAX";
599
599
  }>>;
600
600
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
601
- IM: "IM";
602
601
  AF: "AF";
603
602
  AL: "AL";
604
603
  DZ: "DZ";
@@ -687,6 +686,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
687
686
  IR: "IR";
688
687
  IQ: "IQ";
689
688
  IE: "IE";
689
+ IM: "IM";
690
690
  IL: "IL";
691
691
  IT: "IT";
692
692
  CI: "CI";
@@ -828,7 +828,7 @@ declare const bankAccount: {
828
828
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
829
829
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
830
830
  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>>;
831
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["IM" | "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" | "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", ...("IM" | "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" | "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")[]], number | undefined>>;
831
+ 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" | "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")[]], number | undefined>>;
832
832
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
833
833
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
834
834
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -944,26 +944,6 @@ type IdentityContextVariables = {
944
944
  };
945
945
  };
946
946
 
947
- /**
948
- * Utility type to infer possible relation includes (`with`) for a given table.
949
- * This helps define which relations (one-to-many, many-to-one) can be included in a query.
950
- *
951
- * @template Tables - The Drizzle ORM schema object.
952
- * @template TableName - The table for which relations should be inferred.
953
- */
954
- type IncludeRelation<Tables extends Record<string, unknown>, TableName extends keyof ExtractTablesWithRelations<Tables>> = DBQueryConfig<'one' | 'many', boolean, ExtractTablesWithRelations<Tables>, ExtractTablesWithRelations<Tables>[TableName]>['with'];
955
- /**
956
- * Infers the result type of Drizzle ORM select query with optional relations.
957
- * This ensures correct TypeScript inference when querying tables and their relations.
958
- *
959
- * @template Tables - The Drizzle ORM schema object.
960
- * @template TableName - The table for which the query result is being inferred.
961
- * @template With - (Optional) Specifies which relations should be included in the result.
962
- */
963
- type InferResultType<Tables extends Record<string, unknown>, TableName extends keyof ExtractTablesWithRelations<Tables>, With extends IncludeRelation<Tables, TableName> | undefined = undefined> = BuildQueryResult<ExtractTablesWithRelations<Tables>, ExtractTablesWithRelations<Tables>[TableName], {
964
- with: With;
965
- }>;
966
-
967
947
  interface RequestLog {
968
948
  method: string;
969
949
  path: string;
@@ -1137,11 +1117,8 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
1137
1117
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
1138
1118
 
1139
1119
  declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
1140
- declare const getD1DatabaseIdFromWrangler: () => string | undefined;
1141
- declare const getD1Credentials: () => {
1142
- driver?: undefined;
1143
- dbCredentials?: undefined;
1144
- } | {
1120
+ declare const getLocalD1DatabaseIdFromWrangler: () => string | undefined;
1121
+ declare const getD1Credentials: () => Promise<{
1145
1122
  driver: string;
1146
1123
  dbCredentials: {
1147
1124
  accountId: string | undefined;
@@ -1157,14 +1134,8 @@ declare const getD1Credentials: () => {
1157
1134
  token?: undefined;
1158
1135
  };
1159
1136
  driver?: undefined;
1160
- };
1161
- declare const getDrizzleD1Config: () => {
1162
- driver?: undefined;
1163
- dbCredentials?: undefined;
1164
- schema: string;
1165
- out: string;
1166
- dialect: "sqlite";
1167
- } | {
1137
+ }>;
1138
+ declare const getDrizzleD1Config: () => Promise<{
1168
1139
  driver: string;
1169
1140
  dbCredentials: {
1170
1141
  accountId: string | undefined;
@@ -1186,7 +1157,7 @@ declare const getDrizzleD1Config: () => {
1186
1157
  schema: string;
1187
1158
  out: string;
1188
1159
  dialect: "sqlite";
1189
- };
1160
+ }>;
1190
1161
 
1191
1162
  type Operator = 'like' | 'ilike';
1192
1163
  type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
@@ -1339,5 +1310,5 @@ interface WithRetryCounterOptions {
1339
1310
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
1340
1311
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
1341
1312
 
1342
- 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, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
1343
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
1313
+ 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 };
1314
+ 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,5 +1,5 @@
1
1
  import * as drizzle_orm from 'drizzle-orm';
2
- import { Table, ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn } from 'drizzle-orm';
2
+ import { Table, 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 { z as z$1, ZodObject, ZodType, ZodOptional } from 'zod';
@@ -38,7 +38,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
38
38
  city: z$1.ZodOptional<z$1.ZodString>;
39
39
  postalCode: z$1.ZodOptional<z$1.ZodString>;
40
40
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
41
- IM: "IM";
42
41
  AF: "AF";
43
42
  AL: "AL";
44
43
  DZ: "DZ";
@@ -127,6 +126,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
127
126
  IR: "IR";
128
127
  IQ: "IQ";
129
128
  IE: "IE";
129
+ IM: "IM";
130
130
  IL: "IL";
131
131
  IT: "IT";
132
132
  CI: "CI";
@@ -327,7 +327,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
327
327
  city: z$1.ZodOptional<z$1.ZodString>;
328
328
  postalCode: z$1.ZodOptional<z$1.ZodString>;
329
329
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
330
- IM: "IM";
331
330
  AF: "AF";
332
331
  AL: "AL";
333
332
  DZ: "DZ";
@@ -416,6 +415,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
416
415
  IR: "IR";
417
416
  IQ: "IQ";
418
417
  IE: "IE";
418
+ IM: "IM";
419
419
  IL: "IL";
420
420
  IT: "IT";
421
421
  CI: "CI";
@@ -598,7 +598,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
598
598
  AVAX: "AVAX";
599
599
  }>>;
600
600
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
601
- IM: "IM";
602
601
  AF: "AF";
603
602
  AL: "AL";
604
603
  DZ: "DZ";
@@ -687,6 +686,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
687
686
  IR: "IR";
688
687
  IQ: "IQ";
689
688
  IE: "IE";
689
+ IM: "IM";
690
690
  IL: "IL";
691
691
  IT: "IT";
692
692
  CI: "CI";
@@ -828,7 +828,7 @@ declare const bankAccount: {
828
828
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
829
829
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
830
830
  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>>;
831
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["IM" | "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" | "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", ...("IM" | "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" | "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")[]], number | undefined>>;
831
+ 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" | "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")[]], number | undefined>>;
832
832
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
833
833
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
834
834
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -944,26 +944,6 @@ type IdentityContextVariables = {
944
944
  };
945
945
  };
946
946
 
947
- /**
948
- * Utility type to infer possible relation includes (`with`) for a given table.
949
- * This helps define which relations (one-to-many, many-to-one) can be included in a query.
950
- *
951
- * @template Tables - The Drizzle ORM schema object.
952
- * @template TableName - The table for which relations should be inferred.
953
- */
954
- type IncludeRelation<Tables extends Record<string, unknown>, TableName extends keyof ExtractTablesWithRelations<Tables>> = DBQueryConfig<'one' | 'many', boolean, ExtractTablesWithRelations<Tables>, ExtractTablesWithRelations<Tables>[TableName]>['with'];
955
- /**
956
- * Infers the result type of Drizzle ORM select query with optional relations.
957
- * This ensures correct TypeScript inference when querying tables and their relations.
958
- *
959
- * @template Tables - The Drizzle ORM schema object.
960
- * @template TableName - The table for which the query result is being inferred.
961
- * @template With - (Optional) Specifies which relations should be included in the result.
962
- */
963
- type InferResultType<Tables extends Record<string, unknown>, TableName extends keyof ExtractTablesWithRelations<Tables>, With extends IncludeRelation<Tables, TableName> | undefined = undefined> = BuildQueryResult<ExtractTablesWithRelations<Tables>, ExtractTablesWithRelations<Tables>[TableName], {
964
- with: With;
965
- }>;
966
-
967
947
  interface RequestLog {
968
948
  method: string;
969
949
  path: string;
@@ -1137,11 +1117,8 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
1137
1117
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
1138
1118
 
1139
1119
  declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
1140
- declare const getD1DatabaseIdFromWrangler: () => string | undefined;
1141
- declare const getD1Credentials: () => {
1142
- driver?: undefined;
1143
- dbCredentials?: undefined;
1144
- } | {
1120
+ declare const getLocalD1DatabaseIdFromWrangler: () => string | undefined;
1121
+ declare const getD1Credentials: () => Promise<{
1145
1122
  driver: string;
1146
1123
  dbCredentials: {
1147
1124
  accountId: string | undefined;
@@ -1157,14 +1134,8 @@ declare const getD1Credentials: () => {
1157
1134
  token?: undefined;
1158
1135
  };
1159
1136
  driver?: undefined;
1160
- };
1161
- declare const getDrizzleD1Config: () => {
1162
- driver?: undefined;
1163
- dbCredentials?: undefined;
1164
- schema: string;
1165
- out: string;
1166
- dialect: "sqlite";
1167
- } | {
1137
+ }>;
1138
+ declare const getDrizzleD1Config: () => Promise<{
1168
1139
  driver: string;
1169
1140
  dbCredentials: {
1170
1141
  accountId: string | undefined;
@@ -1186,7 +1157,7 @@ declare const getDrizzleD1Config: () => {
1186
1157
  schema: string;
1187
1158
  out: string;
1188
1159
  dialect: "sqlite";
1189
- };
1160
+ }>;
1190
1161
 
1191
1162
  type Operator = 'like' | 'ilike';
1192
1163
  type Wrap = 'both' | 'prefix' | 'suffix' | 'none';
@@ -1339,5 +1310,5 @@ interface WithRetryCounterOptions {
1339
1310
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
1340
1311
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
1341
1312
 
1342
- 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, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
1343
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
1313
+ 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 };
1314
+ 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
@@ -6,11 +6,11 @@ import { createInsertSchema as createInsertSchema$1 } from 'drizzle-zod';
6
6
  export { createSelectSchema } from 'drizzle-zod';
7
7
  import { z as z$1 } from 'zod';
8
8
  import * as z from 'zod/v4/core';
9
- import 'cloudflare';
10
- import fs from 'node:fs';
9
+ import Cloudflare from 'cloudflare';
10
+ import { parse } from 'comment-json';
11
11
  import crypto$1 from 'node:crypto';
12
+ import fs from 'node:fs';
12
13
  import path from 'node:path';
13
- import { parse } from 'comment-json';
14
14
  import superjson from 'superjson';
15
15
 
16
16
  const ENVIRONMENT = ["dev", "test", "staging", "production"];
@@ -470,41 +470,42 @@ function derivePortFromId(id, base = 4e3, range = 1e4) {
470
470
  return base + hash % range;
471
471
  }
472
472
 
473
+ const readWranglerConfig = () => {
474
+ try {
475
+ const content = fs.readFileSync(path.resolve("./wrangler.jsonc"), "utf-8");
476
+ return parse(content);
477
+ } catch (err) {
478
+ console.warn(`Warning: Could not read wrangler.jsonc: ${err}`);
479
+ }
480
+ };
473
481
  function durableObjectNamespaceIdFromName(uniqueKey, name) {
474
482
  const key = crypto$1.createHash("sha256").update(uniqueKey).digest();
475
483
  const nameHmac = crypto$1.createHmac("sha256", key).update(name).digest().subarray(0, 16);
476
484
  const hmac = crypto$1.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
477
485
  return Buffer.concat([nameHmac, hmac]).toString("hex");
478
486
  }
479
- const getD1DatabaseIdFromWrangler = () => {
480
- try {
481
- const wranglerPath = path.resolve("./wrangler.jsonc");
482
- const wranglerContent = fs.readFileSync(wranglerPath, "utf-8");
483
- const config = parse(wranglerContent);
484
- const environment = process.env.ENVIRONMENT || "localhost";
485
- let databaseId;
486
- if (environment !== "localhost" && config.env?.[environment]) {
487
- databaseId = config.env[environment].d1_databases?.[0]?.database_id;
488
- console.log(
489
- `Using database_id for environment '${environment}': ${databaseId}`
490
- );
491
- }
492
- if (!databaseId) {
493
- databaseId = config.d1_databases?.[0]?.database_id;
494
- console.log(
495
- `Using default database_id for environment '${environment}': ${databaseId}`
496
- );
497
- }
498
- if (!databaseId) {
499
- throw new Error("database_id not found in wrangler.jsonc");
487
+ const getD1DatabaseId = async (instanceName) => {
488
+ const cloudflare = new Cloudflare({
489
+ apiToken: process.env.CLOUDFLARE_API_TOKEN
490
+ });
491
+ const databases = cloudflare.d1.database.list({
492
+ account_id: process.env.CLOUDFLARE_ACCOUNT_ID
493
+ });
494
+ for await (const db of databases) {
495
+ if (db.name === instanceName) {
496
+ return db.uuid;
500
497
  }
501
- return databaseId;
502
- } catch (err) {
503
- console.warn(
504
- `Warning: Could not read database_id from wrangler.jsonc: ${err}`
505
- );
506
498
  }
507
499
  };
500
+ const getLocalD1DatabaseIdFromWrangler = () => {
501
+ const databaseId = readWranglerConfig()?.d1_databases?.[0]?.database_id;
502
+ if (!databaseId) {
503
+ console.warn("Warning: database_id not found in wrangler.jsonc");
504
+ return;
505
+ }
506
+ console.log(`Using local database_id: ${databaseId}`);
507
+ return databaseId;
508
+ };
508
509
  const getLocalD1 = (databaseId) => {
509
510
  const name = durableObjectNamespaceIdFromName(
510
511
  "miniflare-D1DatabaseObject",
@@ -532,13 +533,12 @@ const getLocalD1 = (databaseId) => {
532
533
  }
533
534
  }
534
535
  };
535
- const getD1Credentials = () => {
536
+ const getD1Credentials = async () => {
536
537
  const environment = process.env.ENVIRONMENT;
537
- if (environment === "localhost") {
538
- return {};
539
- }
540
- const databaseId = getD1DatabaseIdFromWrangler() ?? "";
541
538
  if (isRemoteEnvironment()) {
539
+ const workerName = readWranglerConfig()?.name ?? "";
540
+ const instanceName = environment === "production" ? workerName : `${workerName}-${environment}`;
541
+ const databaseId = await getD1DatabaseId(instanceName) ?? "";
542
542
  return {
543
543
  driver: "d1-http",
544
544
  dbCredentials: {
@@ -547,19 +547,18 @@ const getD1Credentials = () => {
547
547
  token: process.env.CLOUDFLARE_API_TOKEN
548
548
  }
549
549
  };
550
- } else {
551
- return {
552
- dbCredentials: {
553
- url: getLocalD1(databaseId)
554
- }
555
- };
556
550
  }
551
+ return {
552
+ dbCredentials: {
553
+ url: getLocalD1(getLocalD1DatabaseIdFromWrangler() ?? "")
554
+ }
555
+ };
557
556
  };
558
- const getDrizzleD1Config = () => ({
557
+ const getDrizzleD1Config = async () => ({
559
558
  schema: "./src/database/schema/",
560
559
  out: "./src/database/migrations/",
561
560
  dialect: "sqlite",
562
- ...getD1Credentials()
561
+ ...await getD1Credentials()
563
562
  });
564
563
 
565
564
  const buildSearchConditions = (search, columns, opts = {}) => {
@@ -795,24 +794,9 @@ function develitWorker(Worker) {
795
794
  class DevelitWorker extends Worker {
796
795
  name = "not-set";
797
796
  action = "not-set";
798
- // public db!: DatabaseTransaction<string>
799
797
  async fetch() {
800
798
  return new Response("Service is up and running!");
801
799
  }
802
- // initializeDB<TAuditAction = string>(
803
- // database: D1Database,
804
- // schema: Record<string, unknown>,
805
- // auditLogWriter?: AuditLogWriter<TAuditAction>,
806
- // ): void {
807
- // const drizzleInstance = drizzle(database, {
808
- // schema,
809
- // }) as DrizzleD1Database<Record<string, unknown>>
810
- // this.db = new DatabaseTransaction<TAuditAction>(
811
- // drizzleInstance,
812
- // this.name,
813
- // auditLogWriter,
814
- // ) as unknown as DatabaseTransaction<string>
815
- // }
816
800
  handleInput({
817
801
  input,
818
802
  schema
@@ -906,4 +890,4 @@ function develitWorker(Worker) {
906
890
  return DevelitWorker;
907
891
  }
908
892
 
909
- 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, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, structuredAddressSchema, useFetch, useResult, useResultSync, workflowInstanceStatusSchema };
893
+ 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 };
@@ -2,10 +2,10 @@ import { createMiddleware } from 'hono/factory';
2
2
  import { HTTPException } from 'hono/http-exception';
3
3
  import { z } from 'zod';
4
4
  import 'cloudflare';
5
- import 'node:fs';
5
+ import 'comment-json';
6
6
  import 'node:crypto';
7
+ import 'node:fs';
7
8
  import 'node:path';
8
- import 'comment-json';
9
9
  import 'drizzle-orm';
10
10
  import { u as uuidv4 } from './shared/backend-sdk.D_gzDKeC.mjs';
11
11
  import { verifyPayloadSignature } from './utils/signature.util.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "10.0.2",
3
+ "version": "11.0.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -34,15 +34,15 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
+ "@cloudflare/workers-types": "^4.20260217.0",
37
38
  "cloudflare": "^5.2.0",
38
39
  "comment-json": "^4.5.1",
39
40
  "superjson": "^2.2.5"
40
41
  },
41
42
  "peerDependencies": {
42
- "@cloudflare/workers-types": "^4.20260217.0",
43
43
  "@develit-io/general-codes": "^1.19.0",
44
- "drizzle-orm": "^0.45.1",
45
- "drizzle-zod": "^0.8.3",
44
+ "drizzle-orm": "1.0.0-rc.1",
45
+ "drizzle-zod": "1.0.0-beta.14-a36c63d",
46
46
  "hono": "^4.12.7",
47
47
  "zod": "^4.3.6"
48
48
  },