@develit-io/backend-sdk 9.3.0 → 9.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -37,7 +37,7 @@ declare const bankAccount: {
37
37
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
38
38
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
39
39
  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>>;
40
- 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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
40
+ 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>>;
41
41
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
42
42
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
43
43
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -191,7 +191,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
191
191
  AVAX: "AVAX";
192
192
  }>>;
193
193
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
194
- IM: "IM";
195
194
  AF: "AF";
196
195
  AL: "AL";
197
196
  DZ: "DZ";
@@ -280,6 +279,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
280
279
  IR: "IR";
281
280
  IQ: "IQ";
282
281
  IE: "IE";
282
+ IM: "IM";
283
283
  IL: "IL";
284
284
  IT: "IT";
285
285
  CI: "CI";
@@ -447,11 +447,14 @@ interface CommandItem<TAuditAction = string> {
447
447
  interface IdempotencyContextVariables {
448
448
  key: string;
449
449
  }
450
- interface UserContextVariables {
451
- email: string;
452
- role: string;
453
- organizationId: string;
454
- }
450
+ type IdentityContextVariables = {
451
+ user: {
452
+ id: string;
453
+ email: string;
454
+ role: string;
455
+ rawUserMetaData: string | null;
456
+ };
457
+ };
455
458
 
456
459
  /**
457
460
  * Utility type to infer possible relation includes (`with`) for a given table.
@@ -844,4 +847,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
844
847
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
845
848
 
846
849
  export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, useFetch, useResult, useResultSync, uuidv4, workflowInstanceStatusSchema };
847
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserContextVariables, UserRole, ValidatedInput, WorkflowInstanceStatus };
850
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare const bankAccount: {
37
37
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
38
38
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
39
39
  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>>;
40
- 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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
40
+ 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>>;
41
41
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
42
42
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
43
43
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -191,7 +191,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
191
191
  AVAX: "AVAX";
192
192
  }>>;
193
193
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
194
- IM: "IM";
195
194
  AF: "AF";
196
195
  AL: "AL";
197
196
  DZ: "DZ";
@@ -280,6 +279,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
280
279
  IR: "IR";
281
280
  IQ: "IQ";
282
281
  IE: "IE";
282
+ IM: "IM";
283
283
  IL: "IL";
284
284
  IT: "IT";
285
285
  CI: "CI";
@@ -447,11 +447,14 @@ interface CommandItem<TAuditAction = string> {
447
447
  interface IdempotencyContextVariables {
448
448
  key: string;
449
449
  }
450
- interface UserContextVariables {
451
- email: string;
452
- role: string;
453
- organizationId: string;
454
- }
450
+ type IdentityContextVariables = {
451
+ user: {
452
+ id: string;
453
+ email: string;
454
+ role: string;
455
+ rawUserMetaData: string | null;
456
+ };
457
+ };
455
458
 
456
459
  /**
457
460
  * Utility type to infer possible relation includes (`with`) for a given table.
@@ -844,4 +847,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
844
847
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
845
848
 
846
849
  export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, useFetch, useResult, useResultSync, uuidv4, workflowInstanceStatusSchema };
847
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserContextVariables, UserRole, ValidatedInput, WorkflowInstanceStatus };
850
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserRole, ValidatedInput, WorkflowInstanceStatus };
@@ -1,5 +1,16 @@
1
1
  import { MiddlewareHandler } from 'hono/types';
2
2
 
3
+ interface AccessMiddlewareOptions {
4
+ errorMessage?: string;
5
+ }
6
+ interface AccessRequest<TScope extends string = string> {
7
+ scope: TScope;
8
+ resourceId?: string;
9
+ resourcePath?: string;
10
+ }
11
+ type AccessRequestResolver<TScope extends string = string> = AccessRequest<TScope>[] | ((context: unknown) => AccessRequest<TScope>[]);
12
+ declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
13
+
3
14
  declare const idempotency: () => MiddlewareHandler;
4
15
 
5
16
  declare const jwt: () => MiddlewareHandler;
@@ -10,4 +21,4 @@ declare const logger: () => MiddlewareHandler;
10
21
 
11
22
  declare const signature: () => MiddlewareHandler;
12
23
 
13
- export { idempotency, ip, jwt, logger, signature };
24
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -1,5 +1,16 @@
1
1
  import { MiddlewareHandler } from 'hono/types';
2
2
 
3
+ interface AccessMiddlewareOptions {
4
+ errorMessage?: string;
5
+ }
6
+ interface AccessRequest<TScope extends string = string> {
7
+ scope: TScope;
8
+ resourceId?: string;
9
+ resourcePath?: string;
10
+ }
11
+ type AccessRequestResolver<TScope extends string = string> = AccessRequest<TScope>[] | ((context: unknown) => AccessRequest<TScope>[]);
12
+ declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
13
+
3
14
  declare const idempotency: () => MiddlewareHandler;
4
15
 
5
16
  declare const jwt: () => MiddlewareHandler;
@@ -10,4 +21,4 @@ declare const logger: () => MiddlewareHandler;
10
21
 
11
22
  declare const signature: () => MiddlewareHandler;
12
23
 
13
- export { idempotency, ip, jwt, logger, signature };
24
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -33,6 +33,26 @@ const getRequestUserAgent = (request) => {
33
33
  return request.header("user-agent") || "UNKNOWN";
34
34
  };
35
35
 
36
+ const access = (accessRequests, options = {}) => {
37
+ return createMiddleware(async (context, next) => {
38
+ if (!context.env.MIDDLEWARE_ACCESS_DISABLED) {
39
+ const identity = context.get("identity");
40
+ const requests = typeof accessRequests === "function" ? accessRequests(context) : accessRequests;
41
+ const { data: verifyData, error: verifyError } = await context.env.RBAC_SERVICE.verifyAccess({
42
+ userId: identity.user.id,
43
+ accessRequests: requests,
44
+ jwt: identity
45
+ });
46
+ if (verifyError || !verifyData?.isVerified) {
47
+ throw new HTTPException(404, {
48
+ message: options.errorMessage || "Forbidden"
49
+ });
50
+ }
51
+ }
52
+ await next();
53
+ });
54
+ };
55
+
36
56
  const idempotency = () => {
37
57
  return createMiddleware(async (context, next) => {
38
58
  if (!context.env.MIDDLEWARE_IDEMPOTENCY_DISABLED) {
@@ -94,17 +114,13 @@ const jwt = () => {
94
114
  }
95
115
  const rawUserMetaDataString = data.payload.user.rawUserMetaData;
96
116
  const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
97
- const organizationId = rawUserMetaData?.organizationId ?? null;
98
- if (!organizationId) {
117
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
118
+ if (!identityId) {
99
119
  throw new HTTPException(422, {
100
120
  message: "User data integrity check failed."
101
121
  });
102
122
  }
103
- context.set("user", {
104
- email: data.payload.user.email,
105
- role: data.payload.user.role,
106
- organizationId
107
- });
123
+ context.set("identity", data.payload);
108
124
  }
109
125
  await next();
110
126
  });
@@ -114,14 +130,17 @@ const ip = () => {
114
130
  return createMiddleware(async (context, next) => {
115
131
  if (!context.env.MIDDLEWARE_IP_DISABLED) {
116
132
  const requestIp = getRequestIpAddress(context.req);
117
- const user = context.get("user");
118
- if (!user.organizationId) {
133
+ const identityContext = context.get("identity");
134
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
135
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
136
+ const organizationId = rawUserMetaData.organizationId;
137
+ if (!organizationId) {
119
138
  throw new HTTPException(401, {
120
139
  message: "Failed to retrieve request organization ID."
121
140
  });
122
141
  }
123
142
  const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
124
- organizationId: user.organizationId
143
+ organizationId
125
144
  });
126
145
  if (!organization || error) {
127
146
  throw new HTTPException(404, {
@@ -166,7 +185,9 @@ const logger = () => {
166
185
  const requestLog = await composeRequestLog(context.req);
167
186
  logRequest(requestLog);
168
187
  if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
169
- const userContext = context.get("user");
188
+ const identityContext = context.get("identity");
189
+ const rawUserMetaDataString = identityContext?.user?.rawUserMetaData;
190
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
170
191
  const requestId = uuidv4();
171
192
  context.set("auditLog", {
172
193
  requestId
@@ -176,8 +197,12 @@ const logger = () => {
176
197
  method: requestLog.method,
177
198
  path: requestLog.path,
178
199
  actor: {
179
- email: userContext?.email || "NOT_AUTHORIZED",
180
- organizationId: userContext?.organizationId || "NOT_AUTHORIZED"
200
+ email: identityContext?.user?.email || "NOT_AUTHORIZED",
201
+ ...rawUserMetaData?.organizationId ? {
202
+ organizationId: rawUserMetaData.organizationId || "NOT_AUTHORIZED"
203
+ } : rawUserMetaData?.exchangeOfficeId ? {
204
+ exchangeOfficeId: rawUserMetaData.exchangeOfficeId || "NOT_AUTHORIZED"
205
+ } : null
181
206
  },
182
207
  metadata: {
183
208
  ip: getRequestIpAddress(context.req),
@@ -198,15 +223,21 @@ const logger = () => {
198
223
  );
199
224
  logResponse(responseLog);
200
225
  if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
201
- const userContext = context.get("user");
226
+ const identityContext = context.get("identity");
227
+ const rawUserMetaDataString = identityContext?.user?.rawUserMetaData;
228
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
202
229
  const auditLogContext = context.get("auditLog");
203
230
  await context.env.AUDITLOG_SERVICE.processLog({
204
231
  type: "RESPONSE",
205
232
  method: responseLog.method,
206
233
  path: responseLog.path,
207
234
  actor: {
208
- email: userContext?.email || "NOT_AUTHORIZED",
209
- organizationId: userContext?.organizationId || "NOT_AUTHORIZED"
235
+ email: identityContext?.user?.email || "NOT_AUTHORIZED",
236
+ ...rawUserMetaData?.organizationId ? {
237
+ organizationId: rawUserMetaData.organizationId || "NOT_AUTHORIZED"
238
+ } : rawUserMetaData?.exchangeOfficeId ? {
239
+ exchangeOfficeId: rawUserMetaData.exchangeOfficeId || "NOT_AUTHORIZED"
240
+ } : null
210
241
  },
211
242
  metadata: {
212
243
  ip: getRequestIpAddress(context.req),
@@ -236,14 +267,17 @@ const signature = () => {
236
267
  });
237
268
  }
238
269
  const payload = JSON.stringify(await context.req.json().catch(() => null));
239
- const user = context.get("user");
240
- if (!user.organizationId) {
270
+ const identityContext = context.get("identity");
271
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
272
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
273
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
274
+ if (!identityId) {
241
275
  throw new HTTPException(401, {
242
- message: "Failed to retrieve request organization ID."
276
+ message: "Failed to retrieve request identity ID."
243
277
  });
244
278
  }
245
279
  const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
246
- organizationId: user.organizationId
280
+ organizationId: identityId
247
281
  });
248
282
  if (!organization || error) {
249
283
  throw new HTTPException(404, {
@@ -273,4 +307,4 @@ const signature = () => {
273
307
  });
274
308
  };
275
309
 
276
- export { idempotency, ip, jwt, logger, signature };
310
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -1,11 +1,12 @@
1
- declare const createSignatureKeyPair: () => Promise<{
2
- publicKey: string;
3
- privateKey: string;
4
- }>;
5
1
  declare const signPayload: ({ payload, privateKey, }: {
6
2
  payload: string;
7
3
  privateKey: string;
8
4
  }) => Promise<string>;
5
+
6
+ declare const createSignatureKeyPair: () => Promise<{
7
+ publicKey: string;
8
+ privateKey: string;
9
+ }>;
9
10
  declare const algParams: {
10
11
  [key: string]: {
11
12
  name: string;
@@ -1,11 +1,12 @@
1
- declare const createSignatureKeyPair: () => Promise<{
2
- publicKey: string;
3
- privateKey: string;
4
- }>;
5
1
  declare const signPayload: ({ payload, privateKey, }: {
6
2
  payload: string;
7
3
  privateKey: string;
8
4
  }) => Promise<string>;
5
+
6
+ declare const createSignatureKeyPair: () => Promise<{
7
+ publicKey: string;
8
+ privateKey: string;
9
+ }>;
9
10
  declare const algParams: {
10
11
  [key: string]: {
11
12
  name: string;
@@ -1,21 +1,3 @@
1
- const createSignatureKeyPair = async () => {
2
- const { publicKey, privateKey } = await crypto.subtle.generateKey(
3
- {
4
- name: "RSASSA-PKCS1-v1_5",
5
- modulusLength: 4096,
6
- publicExponent: new Uint8Array([1, 0, 1]),
7
- hash: "SHA-256"
8
- },
9
- true,
10
- ["sign", "verify"]
11
- );
12
- const exportedPublicKey = await crypto.subtle.exportKey("spki", publicKey);
13
- const exportedPrivateKey = await crypto.subtle.exportKey("pkcs8", privateKey);
14
- return {
15
- publicKey: Buffer.from(exportedPublicKey).toString("base64"),
16
- privateKey: Buffer.from(exportedPrivateKey).toString("base64")
17
- };
18
- };
19
1
  const signPayload = async ({
20
2
  payload,
21
3
  privateKey
@@ -47,6 +29,25 @@ const signPayload = async ({
47
29
  );
48
30
  return base64Signature;
49
31
  };
32
+
33
+ const createSignatureKeyPair = async () => {
34
+ const { publicKey, privateKey } = await crypto.subtle.generateKey(
35
+ {
36
+ name: "RSASSA-PKCS1-v1_5",
37
+ modulusLength: 4096,
38
+ publicExponent: new Uint8Array([1, 0, 1]),
39
+ hash: "SHA-256"
40
+ },
41
+ true,
42
+ ["sign", "verify"]
43
+ );
44
+ const exportedPublicKey = await crypto.subtle.exportKey("spki", publicKey);
45
+ const exportedPrivateKey = await crypto.subtle.exportKey("pkcs8", privateKey);
46
+ return {
47
+ publicKey: Buffer.from(exportedPublicKey).toString("base64"),
48
+ privateKey: Buffer.from(exportedPrivateKey).toString("base64")
49
+ };
50
+ };
50
51
  const algParams = {
51
52
  RSA: {
52
53
  name: "RSASSA-PKCS1-v1_5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "9.3.0",
3
+ "version": "9.4.1",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",