@develit-io/backend-sdk 9.0.0 → 9.0.2

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
@@ -3,6 +3,7 @@ import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn
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 } from 'zod';
6
+ export { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.mjs';
6
7
  import * as z from 'zod/v4/core';
7
8
  import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
8
9
  export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
@@ -34,7 +35,7 @@ declare const bankAccount: {
34
35
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
35
36
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
36
37
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]], number | undefined>>;
37
- 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>>;
38
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["EC" | "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" | "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", ...("EC" | "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" | "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>>;
38
39
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
39
40
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
40
41
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -74,13 +75,6 @@ interface AuditLogPayload<T> {
74
75
  entityId?: string;
75
76
  }
76
77
 
77
- interface AuthUser {
78
- id: string;
79
- organizationId: string;
80
- email: string;
81
- role: UserRole;
82
- }
83
-
84
78
  declare const ibanSchema: z$1.ZodString;
85
79
  declare const bicSchema: z$1.ZodString;
86
80
  declare const bankAccountMetadataSchema: z$1.ZodObject<{
@@ -195,6 +189,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
195
189
  AVAX: "AVAX";
196
190
  }>>;
197
191
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
192
+ EC: "EC";
198
193
  AF: "AF";
199
194
  AL: "AL";
200
195
  DZ: "DZ";
@@ -248,7 +243,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
248
243
  DM: "DM";
249
244
  DO: "DO";
250
245
  TL: "TL";
251
- EC: "EC";
252
246
  EG: "EG";
253
247
  SV: "SV";
254
248
  GQ: "GQ";
@@ -415,6 +409,26 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
415
409
  interface BankAccountMetadata extends z$1.infer<typeof bankAccountMetadataSchema> {
416
410
  }
417
411
 
412
+ declare const workflowInstanceStatusSchema: z$1.ZodObject<{
413
+ status: z$1.ZodEnum<{
414
+ unknown: "unknown";
415
+ queued: "queued";
416
+ running: "running";
417
+ paused: "paused";
418
+ errored: "errored";
419
+ terminated: "terminated";
420
+ complete: "complete";
421
+ waiting: "waiting";
422
+ waitingForPause: "waitingForPause";
423
+ }>;
424
+ error: z$1.ZodOptional<z$1.ZodObject<{
425
+ message: z$1.ZodString;
426
+ name: z$1.ZodOptional<z$1.ZodString>;
427
+ }, z$1.core.$strip>>;
428
+ output: z$1.ZodOptional<z$1.ZodUnknown>;
429
+ }, z$1.core.$strip>;
430
+ type WorkflowInstanceStatus = z$1.infer<typeof workflowInstanceStatusSchema>;
431
+
418
432
  interface CommandLogPayload<T = string> {
419
433
  action: T;
420
434
  actorId: string;
@@ -448,16 +462,6 @@ type InferResultType<Tables extends Record<string, unknown>, TableName extends k
448
462
  with: With;
449
463
  }>;
450
464
 
451
- interface IdempotencyVariables {
452
- idempotency: {
453
- key: string;
454
- };
455
- }
456
- interface UserVariables {
457
- user: AuthUser;
458
- jwt: unknown;
459
- }
460
-
461
465
  declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
462
466
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
463
467
  }>>, z.$ZodObjectConfig>;
@@ -465,6 +469,19 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
465
469
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
466
470
  }>>, z.$ZodObjectConfig>;
467
471
 
472
+ interface BaseEvent {
473
+ metadata: {
474
+ timestamp: string;
475
+ correlationId: string;
476
+ entityId: string;
477
+ /**
478
+ * Idempotency key is built as
479
+ * `${entityId}-${eventSignal}-${idempotencySuffix}`
480
+ */
481
+ idempotencySuffix?: string;
482
+ };
483
+ }
484
+
468
485
  type InternalErrorResponseStatus = Exclude<ContentfulStatusCode, SuccessStatusCode>;
469
486
  interface InternalError {
470
487
  status: InternalErrorResponseStatus;
@@ -497,39 +514,6 @@ interface GatewayResponse<T> {
497
514
  */
498
515
  type Result<T> = [data: T | null, error: InternalError | null];
499
516
 
500
- interface BaseEvent {
501
- metadata: {
502
- timestamp: string;
503
- correlationId: string;
504
- entityId: string;
505
- /**
506
- * Idempotency key is built as
507
- * `${entityId}-${eventSignal}-${idempotencySuffix}`
508
- */
509
- idempotencySuffix?: string;
510
- };
511
- }
512
-
513
- declare const workflowInstanceStatusSchema: z$1.ZodObject<{
514
- status: z$1.ZodEnum<{
515
- unknown: "unknown";
516
- queued: "queued";
517
- running: "running";
518
- paused: "paused";
519
- errored: "errored";
520
- terminated: "terminated";
521
- complete: "complete";
522
- waiting: "waiting";
523
- waitingForPause: "waitingForPause";
524
- }>;
525
- error: z$1.ZodOptional<z$1.ZodObject<{
526
- message: z$1.ZodString;
527
- name: z$1.ZodOptional<z$1.ZodString>;
528
- }, z$1.core.$strip>>;
529
- output: z$1.ZodOptional<z$1.ZodUnknown>;
530
- }, z$1.core.$strip>;
531
- type WorkflowInstanceStatus = z$1.infer<typeof workflowInstanceStatusSchema>;
532
-
533
517
  type Constructor<T = {}> = abstract new (...args: any[]) => T;
534
518
  interface DevelitWorkerMethods {
535
519
  name: string;
@@ -848,4 +832,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
848
832
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
849
833
 
850
834
  export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
851
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput, WorkflowInstanceStatus };
835
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { ExtractTablesWithRelations, DBQueryConfig, BuildQueryResult, AnyColumn
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 } from 'zod';
6
+ export { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.js';
6
7
  import * as z from 'zod/v4/core';
7
8
  import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
8
9
  export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
@@ -34,7 +35,7 @@ declare const bankAccount: {
34
35
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
35
36
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
36
37
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]], number | undefined>>;
37
- 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>>;
38
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["EC" | "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" | "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", ...("EC" | "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" | "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>>;
38
39
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
39
40
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
40
41
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -74,13 +75,6 @@ interface AuditLogPayload<T> {
74
75
  entityId?: string;
75
76
  }
76
77
 
77
- interface AuthUser {
78
- id: string;
79
- organizationId: string;
80
- email: string;
81
- role: UserRole;
82
- }
83
-
84
78
  declare const ibanSchema: z$1.ZodString;
85
79
  declare const bicSchema: z$1.ZodString;
86
80
  declare const bankAccountMetadataSchema: z$1.ZodObject<{
@@ -195,6 +189,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
195
189
  AVAX: "AVAX";
196
190
  }>>;
197
191
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
192
+ EC: "EC";
198
193
  AF: "AF";
199
194
  AL: "AL";
200
195
  DZ: "DZ";
@@ -248,7 +243,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
248
243
  DM: "DM";
249
244
  DO: "DO";
250
245
  TL: "TL";
251
- EC: "EC";
252
246
  EG: "EG";
253
247
  SV: "SV";
254
248
  GQ: "GQ";
@@ -415,6 +409,26 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
415
409
  interface BankAccountMetadata extends z$1.infer<typeof bankAccountMetadataSchema> {
416
410
  }
417
411
 
412
+ declare const workflowInstanceStatusSchema: z$1.ZodObject<{
413
+ status: z$1.ZodEnum<{
414
+ unknown: "unknown";
415
+ queued: "queued";
416
+ running: "running";
417
+ paused: "paused";
418
+ errored: "errored";
419
+ terminated: "terminated";
420
+ complete: "complete";
421
+ waiting: "waiting";
422
+ waitingForPause: "waitingForPause";
423
+ }>;
424
+ error: z$1.ZodOptional<z$1.ZodObject<{
425
+ message: z$1.ZodString;
426
+ name: z$1.ZodOptional<z$1.ZodString>;
427
+ }, z$1.core.$strip>>;
428
+ output: z$1.ZodOptional<z$1.ZodUnknown>;
429
+ }, z$1.core.$strip>;
430
+ type WorkflowInstanceStatus = z$1.infer<typeof workflowInstanceStatusSchema>;
431
+
418
432
  interface CommandLogPayload<T = string> {
419
433
  action: T;
420
434
  actorId: string;
@@ -448,16 +462,6 @@ type InferResultType<Tables extends Record<string, unknown>, TableName extends k
448
462
  with: With;
449
463
  }>;
450
464
 
451
- interface IdempotencyVariables {
452
- idempotency: {
453
- key: string;
454
- };
455
- }
456
- interface UserVariables {
457
- user: AuthUser;
458
- jwt: unknown;
459
- }
460
-
461
465
  declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
462
466
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
463
467
  }>>, z.$ZodObjectConfig>;
@@ -465,6 +469,19 @@ declare const paginationSchema: z.$ZodObject<Readonly<Readonly<{
465
469
  [k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
466
470
  }>>, z.$ZodObjectConfig>;
467
471
 
472
+ interface BaseEvent {
473
+ metadata: {
474
+ timestamp: string;
475
+ correlationId: string;
476
+ entityId: string;
477
+ /**
478
+ * Idempotency key is built as
479
+ * `${entityId}-${eventSignal}-${idempotencySuffix}`
480
+ */
481
+ idempotencySuffix?: string;
482
+ };
483
+ }
484
+
468
485
  type InternalErrorResponseStatus = Exclude<ContentfulStatusCode, SuccessStatusCode>;
469
486
  interface InternalError {
470
487
  status: InternalErrorResponseStatus;
@@ -497,39 +514,6 @@ interface GatewayResponse<T> {
497
514
  */
498
515
  type Result<T> = [data: T | null, error: InternalError | null];
499
516
 
500
- interface BaseEvent {
501
- metadata: {
502
- timestamp: string;
503
- correlationId: string;
504
- entityId: string;
505
- /**
506
- * Idempotency key is built as
507
- * `${entityId}-${eventSignal}-${idempotencySuffix}`
508
- */
509
- idempotencySuffix?: string;
510
- };
511
- }
512
-
513
- declare const workflowInstanceStatusSchema: z$1.ZodObject<{
514
- status: z$1.ZodEnum<{
515
- unknown: "unknown";
516
- queued: "queued";
517
- running: "running";
518
- paused: "paused";
519
- errored: "errored";
520
- terminated: "terminated";
521
- complete: "complete";
522
- waiting: "waiting";
523
- waitingForPause: "waitingForPause";
524
- }>;
525
- error: z$1.ZodOptional<z$1.ZodObject<{
526
- message: z$1.ZodString;
527
- name: z$1.ZodOptional<z$1.ZodString>;
528
- }, z$1.core.$strip>>;
529
- output: z$1.ZodOptional<z$1.ZodUnknown>;
530
- }, z$1.core.$strip>;
531
- type WorkflowInstanceStatus = z$1.infer<typeof workflowInstanceStatusSchema>;
532
-
533
517
  type Constructor<T = {}> = abstract new (...args: any[]) => T;
534
518
  interface DevelitWorkerMethods {
535
519
  name: string;
@@ -848,4 +832,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
848
832
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
849
833
 
850
834
  export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
851
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput, WorkflowInstanceStatus };
835
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.mjs CHANGED
@@ -103,6 +103,29 @@ const bankAccountMetadataSchema = z$1.object({
103
103
  // Brazil
104
104
  });
105
105
 
106
+ const workflowInstanceStatusSchema = z$1.object({
107
+ status: z$1.enum([
108
+ "queued",
109
+ // means that instance is waiting to be started (see concurrency limits)
110
+ "running",
111
+ "paused",
112
+ "errored",
113
+ "terminated",
114
+ // user terminated the instance while it was running
115
+ "complete",
116
+ "waiting",
117
+ // instance is hibernating and waiting for sleep or event to finish
118
+ "waitingForPause",
119
+ // instance is finishing the current work to pause
120
+ "unknown"
121
+ ]),
122
+ error: z$1.object({
123
+ message: z$1.string(),
124
+ name: z$1.string().optional()
125
+ }).optional(),
126
+ output: z$1.unknown().optional()
127
+ });
128
+
106
129
  const paginationQuerySchema = new z.$ZodObject({
107
130
  type: "object",
108
131
  shape: {
@@ -188,29 +211,6 @@ const paginationSchema = new z.$ZodObject({
188
211
  }
189
212
  });
190
213
 
191
- const workflowInstanceStatusSchema = z$1.object({
192
- status: z$1.enum([
193
- "queued",
194
- // means that instance is waiting to be started (see concurrency limits)
195
- "running",
196
- "paused",
197
- "errored",
198
- "terminated",
199
- // user terminated the instance while it was running
200
- "complete",
201
- "waiting",
202
- // instance is hibernating and waiting for sleep or event to finish
203
- "waitingForPause",
204
- // instance is finishing the current work to pause
205
- "unknown"
206
- ]),
207
- error: z$1.object({
208
- message: z$1.string(),
209
- name: z$1.string().optional()
210
- }).optional(),
211
- output: z$1.unknown().optional()
212
- });
213
-
214
214
  const createInternalError = (error, details) => {
215
215
  return {
216
216
  status: details?.status || 500,
@@ -1,13 +1,80 @@
1
- import { MiddlewareHandler } from 'hono/types';
1
+ import * as hono_types from 'hono/types';
2
+ import { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.mjs';
2
3
 
3
- declare const idempotency: () => MiddlewareHandler;
4
+ declare const idempotency: () => hono_types.MiddlewareHandler<{
5
+ Variables: IdempotencyContextVariables;
6
+ Bindings: {
7
+ IDEMPOTENCY_KV: KVNamespace;
8
+ };
9
+ }, string, {}, Response>;
4
10
 
5
- declare const jwt: () => MiddlewareHandler;
11
+ type AuthService = {
12
+ verifyAccessToken: (params: {
13
+ accessToken: string;
14
+ }) => Promise<{
15
+ data?: {
16
+ payload: {
17
+ user: {
18
+ email: string;
19
+ role: string;
20
+ rawUserMetaData: string | null;
21
+ };
22
+ };
23
+ };
24
+ error?: unknown;
25
+ }>;
26
+ };
27
+ declare const jwt: () => hono_types.MiddlewareHandler<{
28
+ Variables: UserContextVariables;
29
+ Bindings: {
30
+ AUTH_SERVICE: AuthService;
31
+ };
32
+ }, string, {}, Response>;
6
33
 
7
- declare const ip: () => MiddlewareHandler;
34
+ type OrganizationService$1 = {
35
+ getOrganization: (params: {
36
+ organizationId: string;
37
+ }) => Promise<{
38
+ data: {
39
+ id: string;
40
+ ipAuthorization: boolean;
41
+ authorizedIps: {
42
+ ip: string;
43
+ }[];
44
+ } | null | undefined;
45
+ error: boolean;
46
+ }>;
47
+ };
48
+ declare const ip: () => hono_types.MiddlewareHandler<{
49
+ Variables: UserContextVariables;
50
+ Bindings: {
51
+ ENVIRONMENT: string;
52
+ ORGANIZATION_SERVICE: OrganizationService$1;
53
+ };
54
+ }, string, {}, Response>;
8
55
 
9
- declare const logger: () => MiddlewareHandler;
56
+ declare const logger: () => hono_types.MiddlewareHandler<any, string, {}, Response>;
10
57
 
11
- declare const signature: () => MiddlewareHandler;
58
+ type OrganizationService = {
59
+ getOrganization: (params: {
60
+ organizationId: string;
61
+ }) => Promise<{
62
+ data: {
63
+ id: string;
64
+ signatureKeys: {
65
+ name: string;
66
+ publicKey: string;
67
+ }[];
68
+ } | null | undefined;
69
+ error: boolean;
70
+ }>;
71
+ };
72
+ declare const signature: () => hono_types.MiddlewareHandler<{
73
+ Variables: UserContextVariables;
74
+ Bindings: {
75
+ ENVIRONMENT: string;
76
+ ORGANIZATION_SERVICE: OrganizationService;
77
+ };
78
+ }, string, {}, Response>;
12
79
 
13
80
  export { idempotency, ip, jwt, logger, signature };
@@ -1,13 +1,80 @@
1
- import { MiddlewareHandler } from 'hono/types';
1
+ import * as hono_types from 'hono/types';
2
+ import { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.js';
2
3
 
3
- declare const idempotency: () => MiddlewareHandler;
4
+ declare const idempotency: () => hono_types.MiddlewareHandler<{
5
+ Variables: IdempotencyContextVariables;
6
+ Bindings: {
7
+ IDEMPOTENCY_KV: KVNamespace;
8
+ };
9
+ }, string, {}, Response>;
4
10
 
5
- declare const jwt: () => MiddlewareHandler;
11
+ type AuthService = {
12
+ verifyAccessToken: (params: {
13
+ accessToken: string;
14
+ }) => Promise<{
15
+ data?: {
16
+ payload: {
17
+ user: {
18
+ email: string;
19
+ role: string;
20
+ rawUserMetaData: string | null;
21
+ };
22
+ };
23
+ };
24
+ error?: unknown;
25
+ }>;
26
+ };
27
+ declare const jwt: () => hono_types.MiddlewareHandler<{
28
+ Variables: UserContextVariables;
29
+ Bindings: {
30
+ AUTH_SERVICE: AuthService;
31
+ };
32
+ }, string, {}, Response>;
6
33
 
7
- declare const ip: () => MiddlewareHandler;
34
+ type OrganizationService$1 = {
35
+ getOrganization: (params: {
36
+ organizationId: string;
37
+ }) => Promise<{
38
+ data: {
39
+ id: string;
40
+ ipAuthorization: boolean;
41
+ authorizedIps: {
42
+ ip: string;
43
+ }[];
44
+ } | null | undefined;
45
+ error: boolean;
46
+ }>;
47
+ };
48
+ declare const ip: () => hono_types.MiddlewareHandler<{
49
+ Variables: UserContextVariables;
50
+ Bindings: {
51
+ ENVIRONMENT: string;
52
+ ORGANIZATION_SERVICE: OrganizationService$1;
53
+ };
54
+ }, string, {}, Response>;
8
55
 
9
- declare const logger: () => MiddlewareHandler;
56
+ declare const logger: () => hono_types.MiddlewareHandler<any, string, {}, Response>;
10
57
 
11
- declare const signature: () => MiddlewareHandler;
58
+ type OrganizationService = {
59
+ getOrganization: (params: {
60
+ organizationId: string;
61
+ }) => Promise<{
62
+ data: {
63
+ id: string;
64
+ signatureKeys: {
65
+ name: string;
66
+ publicKey: string;
67
+ }[];
68
+ } | null | undefined;
69
+ error: boolean;
70
+ }>;
71
+ };
72
+ declare const signature: () => hono_types.MiddlewareHandler<{
73
+ Variables: UserContextVariables;
74
+ Bindings: {
75
+ ENVIRONMENT: string;
76
+ ORGANIZATION_SERVICE: OrganizationService;
77
+ };
78
+ }, string, {}, Response>;
12
79
 
13
80
  export { idempotency, ip, jwt, logger, signature };
@@ -28,10 +28,10 @@ const logResponse = (log) => {
28
28
 
29
29
  const idempotency = () => {
30
30
  return createMiddleware(async (context, next) => {
31
- const idempotencyKeyHeader = context.req.header("X-Idempotency-Key");
31
+ const idempotencyKeyHeader = context.req.header("x-idempotency-key");
32
32
  if (!idempotencyKeyHeader) {
33
33
  throw new HTTPException(401, {
34
- message: `The 'X-Idempotency-Key' header must exist and must have a value.`
34
+ message: `The 'x-idempotency-key' header must exist and must have a value.`
35
35
  });
36
36
  }
37
37
  const existingIdempotencyRecord = await context.env.IDEMPOTENCY_KV.get(idempotencyKeyHeader);
@@ -57,21 +57,21 @@ const idempotency = () => {
57
57
 
58
58
  const jwt = () => {
59
59
  return createMiddleware(async (context, next) => {
60
- const authorizationHeader = context.req.header("Authorization");
60
+ const authorizationHeader = context.req.header("authorization");
61
61
  if (!authorizationHeader) {
62
62
  throw new HTTPException(401, {
63
- message: `The 'Authorization' header must exist and must have a value.`
63
+ message: `The 'authorization' header must exist and must have a value.`
64
64
  });
65
65
  }
66
66
  if (!validateBearerScheme(authorizationHeader)) {
67
67
  throw new HTTPException(401, {
68
- message: `The 'Authorization' header value must use the Bearer scheme.`
68
+ message: `The 'authorization' header value must use the Bearer scheme.`
69
69
  });
70
70
  }
71
71
  const bearerToken = extractBearerToken(authorizationHeader);
72
72
  if (!validateBearerToken(bearerToken)) {
73
73
  throw new HTTPException(401, {
74
- message: `The Bearer token in the 'Authorization' header value must be a JWT.`
74
+ message: `The Bearer token in the 'authorization' header value must be a JWT.`
75
75
  });
76
76
  }
77
77
  const { data, error } = await context.env.AUTH_SERVICE.verifyAccessToken({
@@ -95,7 +95,6 @@ const jwt = () => {
95
95
  role: data.payload.user.role,
96
96
  organizationId
97
97
  });
98
- context.set("jwt", data.payload);
99
98
  await next();
100
99
  });
101
100
  };
@@ -173,16 +172,16 @@ const logger = () => {
173
172
  const signature = () => {
174
173
  return createMiddleware(async (context, next) => {
175
174
  if (!["localhost", "dev"].includes(context.env.ENVIRONMENT)) {
176
- const signatureHeader = context.req.header("X-Signature");
175
+ const signatureHeader = context.req.header("x-signature");
177
176
  if (!signatureHeader) {
178
177
  throw new HTTPException(401, {
179
- message: `The 'X-Signature' header must exist and must have a value.`
178
+ message: `The 'x-signature' header must exist and must have a value.`
180
179
  });
181
180
  }
182
181
  const signatureKeyHeader = context.req.header("X-Signature-Key");
183
182
  if (!signatureKeyHeader) {
184
183
  throw new HTTPException(401, {
185
- message: `The 'X-Signature-Key' header must exist and must have a value.`
184
+ message: `The 'x-signature-key' header must exist and must have a value.`
186
185
  });
187
186
  }
188
187
  const payload = JSON.stringify(await context.req.json().catch(() => null));
@@ -0,0 +1,14 @@
1
+ interface IdempotencyContextVariables {
2
+ idempotency: {
3
+ key: string;
4
+ };
5
+ }
6
+ interface UserContextVariables {
7
+ user: {
8
+ email: string;
9
+ role: string;
10
+ organizationId: string;
11
+ };
12
+ }
13
+
14
+ export type { IdempotencyContextVariables as I, UserContextVariables as U };
@@ -0,0 +1,14 @@
1
+ interface IdempotencyContextVariables {
2
+ idempotency: {
3
+ key: string;
4
+ };
5
+ }
6
+ interface UserContextVariables {
7
+ user: {
8
+ email: string;
9
+ role: string;
10
+ organizationId: string;
11
+ };
12
+ }
13
+
14
+ export type { IdempotencyContextVariables as I, UserContextVariables as U };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",