@develit-io/backend-sdk 9.0.2 → 9.1.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 +32 -4
- package/dist/index.d.ts +32 -4
- package/dist/middlewares.d.mts +6 -73
- package/dist/middlewares.d.ts +6 -73
- package/dist/middlewares.mjs +112 -73
- package/package.json +1 -1
- package/dist/shared/backend-sdk.BBnNdxMl.d.mts +0 -14
- package/dist/shared/backend-sdk.BBnNdxMl.d.ts +0 -14
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ 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';
|
|
7
6
|
import * as z from 'zod/v4/core';
|
|
8
7
|
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
9
8
|
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
@@ -35,7 +34,7 @@ declare const bankAccount: {
|
|
|
35
34
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
|
|
36
35
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
|
|
37
36
|
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>>;
|
|
38
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["
|
|
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>>;
|
|
39
38
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
|
|
40
39
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
|
|
41
40
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
|
|
@@ -189,7 +188,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
189
188
|
AVAX: "AVAX";
|
|
190
189
|
}>>;
|
|
191
190
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
192
|
-
EC: "EC";
|
|
193
191
|
AF: "AF";
|
|
194
192
|
AL: "AL";
|
|
195
193
|
DZ: "DZ";
|
|
@@ -243,6 +241,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
243
241
|
DM: "DM";
|
|
244
242
|
DO: "DO";
|
|
245
243
|
TL: "TL";
|
|
244
|
+
EC: "EC";
|
|
246
245
|
EG: "EG";
|
|
247
246
|
SV: "SV";
|
|
248
247
|
GQ: "GQ";
|
|
@@ -442,6 +441,19 @@ interface CommandItem<TAuditAction = string> {
|
|
|
442
441
|
id: string;
|
|
443
442
|
}
|
|
444
443
|
|
|
444
|
+
interface IdempotencyContextVariables {
|
|
445
|
+
idempotency: {
|
|
446
|
+
key: string;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
interface UserContextVariables {
|
|
450
|
+
user: {
|
|
451
|
+
email: string;
|
|
452
|
+
role: string;
|
|
453
|
+
organizationId: string;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
|
|
445
457
|
/**
|
|
446
458
|
* Utility type to infer possible relation includes (`with`) for a given table.
|
|
447
459
|
* This helps define which relations (one-to-many, many-to-one) can be included in a query.
|
|
@@ -462,6 +474,22 @@ type InferResultType<Tables extends Record<string, unknown>, TableName extends k
|
|
|
462
474
|
with: With;
|
|
463
475
|
}>;
|
|
464
476
|
|
|
477
|
+
interface RequestLog {
|
|
478
|
+
method: string;
|
|
479
|
+
path: string;
|
|
480
|
+
query: Record<string, string>;
|
|
481
|
+
headers: Record<string, string>;
|
|
482
|
+
body: Record<string, unknown> | null;
|
|
483
|
+
}
|
|
484
|
+
interface ResponseLog {
|
|
485
|
+
method: string;
|
|
486
|
+
path: string;
|
|
487
|
+
status: number;
|
|
488
|
+
statusText: string;
|
|
489
|
+
headers: Record<string, string>;
|
|
490
|
+
body: unknown;
|
|
491
|
+
}
|
|
492
|
+
|
|
465
493
|
declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
|
|
466
494
|
[k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
|
|
467
495
|
}>>, z.$ZodObjectConfig>;
|
|
@@ -832,4 +860,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
|
|
|
832
860
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
833
861
|
|
|
834
862
|
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 };
|
|
835
|
-
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, ValidatedInput, WorkflowInstanceStatus };
|
|
863
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ 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';
|
|
7
6
|
import * as z from 'zod/v4/core';
|
|
8
7
|
import { ContentfulStatusCode, SuccessStatusCode } from 'hono/utils/http-status';
|
|
9
8
|
export { ContentfulStatusCode as InternalResponseStatus } from 'hono/utils/http-status';
|
|
@@ -35,7 +34,7 @@ declare const bankAccount: {
|
|
|
35
34
|
swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
|
|
36
35
|
bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
|
|
37
36
|
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>>;
|
|
38
|
-
countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["
|
|
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>>;
|
|
39
38
|
routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
|
|
40
39
|
sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
|
|
41
40
|
clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
|
|
@@ -189,7 +188,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
189
188
|
AVAX: "AVAX";
|
|
190
189
|
}>>;
|
|
191
190
|
countryCode: z$1.ZodOptional<z$1.ZodEnum<{
|
|
192
|
-
EC: "EC";
|
|
193
191
|
AF: "AF";
|
|
194
192
|
AL: "AL";
|
|
195
193
|
DZ: "DZ";
|
|
@@ -243,6 +241,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
|
|
|
243
241
|
DM: "DM";
|
|
244
242
|
DO: "DO";
|
|
245
243
|
TL: "TL";
|
|
244
|
+
EC: "EC";
|
|
246
245
|
EG: "EG";
|
|
247
246
|
SV: "SV";
|
|
248
247
|
GQ: "GQ";
|
|
@@ -442,6 +441,19 @@ interface CommandItem<TAuditAction = string> {
|
|
|
442
441
|
id: string;
|
|
443
442
|
}
|
|
444
443
|
|
|
444
|
+
interface IdempotencyContextVariables {
|
|
445
|
+
idempotency: {
|
|
446
|
+
key: string;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
interface UserContextVariables {
|
|
450
|
+
user: {
|
|
451
|
+
email: string;
|
|
452
|
+
role: string;
|
|
453
|
+
organizationId: string;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
|
|
445
457
|
/**
|
|
446
458
|
* Utility type to infer possible relation includes (`with`) for a given table.
|
|
447
459
|
* This helps define which relations (one-to-many, many-to-one) can be included in a query.
|
|
@@ -462,6 +474,22 @@ type InferResultType<Tables extends Record<string, unknown>, TableName extends k
|
|
|
462
474
|
with: With;
|
|
463
475
|
}>;
|
|
464
476
|
|
|
477
|
+
interface RequestLog {
|
|
478
|
+
method: string;
|
|
479
|
+
path: string;
|
|
480
|
+
query: Record<string, string>;
|
|
481
|
+
headers: Record<string, string>;
|
|
482
|
+
body: Record<string, unknown> | null;
|
|
483
|
+
}
|
|
484
|
+
interface ResponseLog {
|
|
485
|
+
method: string;
|
|
486
|
+
path: string;
|
|
487
|
+
status: number;
|
|
488
|
+
statusText: string;
|
|
489
|
+
headers: Record<string, string>;
|
|
490
|
+
body: unknown;
|
|
491
|
+
}
|
|
492
|
+
|
|
465
493
|
declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
|
|
466
494
|
[k: string]: z.$ZodType<unknown, unknown, z.$ZodTypeInternals<unknown, unknown>>;
|
|
467
495
|
}>>, z.$ZodObjectConfig>;
|
|
@@ -832,4 +860,4 @@ type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...a
|
|
|
832
860
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
833
861
|
|
|
834
862
|
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 };
|
|
835
|
-
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, ValidatedInput, WorkflowInstanceStatus };
|
|
863
|
+
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 };
|
package/dist/middlewares.d.mts
CHANGED
|
@@ -1,80 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.mjs';
|
|
1
|
+
import { MiddlewareHandler } from 'hono/types';
|
|
3
2
|
|
|
4
|
-
declare const idempotency: () =>
|
|
5
|
-
Variables: IdempotencyContextVariables;
|
|
6
|
-
Bindings: {
|
|
7
|
-
IDEMPOTENCY_KV: KVNamespace;
|
|
8
|
-
};
|
|
9
|
-
}, string, {}, Response>;
|
|
3
|
+
declare const idempotency: () => MiddlewareHandler;
|
|
10
4
|
|
|
11
|
-
|
|
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>;
|
|
5
|
+
declare const jwt: () => MiddlewareHandler;
|
|
33
6
|
|
|
34
|
-
|
|
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>;
|
|
7
|
+
declare const ip: () => MiddlewareHandler;
|
|
55
8
|
|
|
56
|
-
declare const logger: () =>
|
|
9
|
+
declare const logger: () => MiddlewareHandler;
|
|
57
10
|
|
|
58
|
-
|
|
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>;
|
|
11
|
+
declare const signature: () => MiddlewareHandler;
|
|
79
12
|
|
|
80
13
|
export { idempotency, ip, jwt, logger, signature };
|
package/dist/middlewares.d.ts
CHANGED
|
@@ -1,80 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { I as IdempotencyContextVariables, U as UserContextVariables } from './shared/backend-sdk.BBnNdxMl.js';
|
|
1
|
+
import { MiddlewareHandler } from 'hono/types';
|
|
3
2
|
|
|
4
|
-
declare const idempotency: () =>
|
|
5
|
-
Variables: IdempotencyContextVariables;
|
|
6
|
-
Bindings: {
|
|
7
|
-
IDEMPOTENCY_KV: KVNamespace;
|
|
8
|
-
};
|
|
9
|
-
}, string, {}, Response>;
|
|
3
|
+
declare const idempotency: () => MiddlewareHandler;
|
|
10
4
|
|
|
11
|
-
|
|
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>;
|
|
5
|
+
declare const jwt: () => MiddlewareHandler;
|
|
33
6
|
|
|
34
|
-
|
|
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>;
|
|
7
|
+
declare const ip: () => MiddlewareHandler;
|
|
55
8
|
|
|
56
|
-
declare const logger: () =>
|
|
9
|
+
declare const logger: () => MiddlewareHandler;
|
|
57
10
|
|
|
58
|
-
|
|
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>;
|
|
11
|
+
declare const signature: () => MiddlewareHandler;
|
|
79
12
|
|
|
80
13
|
export { idempotency, ip, jwt, logger, signature };
|
package/dist/middlewares.mjs
CHANGED
|
@@ -25,89 +25,94 @@ const logRequest = (log) => {
|
|
|
25
25
|
const logResponse = (log) => {
|
|
26
26
|
console.log(`RESPONSE | An outgoing response has been recorded.`, log);
|
|
27
27
|
};
|
|
28
|
+
const getRequestIpAddress = (request) => {
|
|
29
|
+
return request.header("cf-connecting-ip") || request.header("x-real-ip") || request.header("x-forwarded-for") || "UNKNOWN";
|
|
30
|
+
};
|
|
31
|
+
const getRequestUserAgent = (request) => {
|
|
32
|
+
return request.header("user-agent") || "UNKNOWN";
|
|
33
|
+
};
|
|
28
34
|
|
|
29
35
|
const idempotency = () => {
|
|
30
36
|
return createMiddleware(async (context, next) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
if (!context.env.MIDDLEWARE_IDEMPOTENCY_DISABLED) {
|
|
38
|
+
const idempotencyKeyHeader = context.req.header("x-idempotency-key");
|
|
39
|
+
if (!idempotencyKeyHeader) {
|
|
40
|
+
throw new HTTPException(401, {
|
|
41
|
+
message: `The 'x-idempotency-key' header must exist and must have a value.`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const existingIdempotencyRecord = await context.env.IDEMPOTENCY_KV.get(idempotencyKeyHeader);
|
|
45
|
+
if (existingIdempotencyRecord) {
|
|
46
|
+
throw new HTTPException(409, {
|
|
47
|
+
message: "The identical request has already been processed. The idempotency key is not unique."
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
await context.env.IDEMPOTENCY_KV.put(
|
|
51
|
+
idempotencyKeyHeader,
|
|
52
|
+
idempotencyKeyHeader,
|
|
53
|
+
{
|
|
54
|
+
expirationTtl: 60 * 60 * 24 * 3
|
|
55
|
+
// 3 days
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
context.set("idempotency", {
|
|
59
|
+
key: idempotencyKeyHeader
|
|
41
60
|
});
|
|
42
61
|
}
|
|
43
|
-
await context.env.IDEMPOTENCY_KV.put(
|
|
44
|
-
idempotencyKeyHeader,
|
|
45
|
-
idempotencyKeyHeader,
|
|
46
|
-
{
|
|
47
|
-
expirationTtl: 60 * 60 * 24 * 3
|
|
48
|
-
// 3 days
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
context.set("idempotency", {
|
|
52
|
-
key: idempotencyKeyHeader
|
|
53
|
-
});
|
|
54
62
|
await next();
|
|
55
63
|
});
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
const jwt = () => {
|
|
59
67
|
return createMiddleware(async (context, next) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!data || error) {
|
|
81
|
-
throw new HTTPException(401, {
|
|
82
|
-
message: "The JWT must contain valid user information."
|
|
68
|
+
if (!context.env.MIDDLEWARE_JWT_DISABLED) {
|
|
69
|
+
const authorizationHeader = context.req.header("authorization");
|
|
70
|
+
if (!authorizationHeader) {
|
|
71
|
+
throw new HTTPException(401, {
|
|
72
|
+
message: `The 'authorization' header must exist and must have a value.`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (!validateBearerScheme(authorizationHeader)) {
|
|
76
|
+
throw new HTTPException(401, {
|
|
77
|
+
message: `The 'authorization' header value must use the Bearer scheme.`
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const bearerToken = extractBearerToken(authorizationHeader);
|
|
81
|
+
if (!validateBearerToken(bearerToken)) {
|
|
82
|
+
throw new HTTPException(401, {
|
|
83
|
+
message: `The Bearer token in the 'authorization' header value must be a JWT.`
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const { data, error } = await context.env.AUTH_SERVICE.verifyAccessToken({
|
|
87
|
+
accessToken: bearerToken
|
|
83
88
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if (!data || error) {
|
|
90
|
+
throw new HTTPException(401, {
|
|
91
|
+
message: "The JWT must contain valid user information."
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const rawUserMetaDataString = data.payload.user.rawUserMetaData;
|
|
95
|
+
const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
|
|
96
|
+
const organizationId = rawUserMetaData?.organizationId ?? null;
|
|
97
|
+
if (!organizationId) {
|
|
98
|
+
throw new HTTPException(422, {
|
|
99
|
+
message: "User data integrity check failed."
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
context.set("user", {
|
|
103
|
+
email: data.payload.user.email,
|
|
104
|
+
role: data.payload.user.role,
|
|
105
|
+
organizationId
|
|
91
106
|
});
|
|
92
107
|
}
|
|
93
|
-
context.set("user", {
|
|
94
|
-
email: data.payload.user.email,
|
|
95
|
-
role: data.payload.user.role,
|
|
96
|
-
organizationId
|
|
97
|
-
});
|
|
98
108
|
await next();
|
|
99
109
|
});
|
|
100
110
|
};
|
|
101
111
|
|
|
102
112
|
const ip = () => {
|
|
103
113
|
return createMiddleware(async (context, next) => {
|
|
104
|
-
if (!
|
|
105
|
-
const requestIp =
|
|
106
|
-
if (!requestIp) {
|
|
107
|
-
throw new HTTPException(401, {
|
|
108
|
-
message: "Failed to retrieve request IP address."
|
|
109
|
-
});
|
|
110
|
-
}
|
|
114
|
+
if (!context.env.MIDDLEWARE_IP_DISABLED) {
|
|
115
|
+
const requestIp = getRequestIpAddress(context.req);
|
|
111
116
|
const user = context.get("user");
|
|
112
117
|
if (!user.organizationId) {
|
|
113
118
|
throw new HTTPException(401, {
|
|
@@ -156,22 +161,56 @@ const composeResponseLog = async (response, method, path) => {
|
|
|
156
161
|
|
|
157
162
|
const logger = () => {
|
|
158
163
|
return createMiddleware(async (context, next) => {
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
if (!context.env.MIDDLEWARE_LOGGER_DISABLED) {
|
|
165
|
+
const requestLog = await composeRequestLog(context.req);
|
|
166
|
+
logRequest(requestLog);
|
|
167
|
+
if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
|
|
168
|
+
const user = context.get("user");
|
|
169
|
+
await context.env.AUDITLOG_SERVICE.processLog({
|
|
170
|
+
type: "REQUEST",
|
|
171
|
+
actor: {
|
|
172
|
+
email: user.email,
|
|
173
|
+
organizationId: user.organizationId
|
|
174
|
+
},
|
|
175
|
+
metadata: {
|
|
176
|
+
ip: getRequestIpAddress(context.req),
|
|
177
|
+
userAgent: getRequestUserAgent(context.req)
|
|
178
|
+
},
|
|
179
|
+
log: requestLog
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
161
183
|
await next();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
if (!context.env.MIDDLEWARE_LOGGER_DISABLED) {
|
|
185
|
+
const response = context.res.clone();
|
|
186
|
+
const responseLog = await composeResponseLog(
|
|
187
|
+
response,
|
|
188
|
+
context.req.method,
|
|
189
|
+
context.req.url
|
|
190
|
+
);
|
|
191
|
+
logResponse(responseLog);
|
|
192
|
+
if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
|
|
193
|
+
const user = context.get("user");
|
|
194
|
+
await context.env.AUDITLOG_SERVICE.processLog({
|
|
195
|
+
type: "RESPONSE",
|
|
196
|
+
actor: {
|
|
197
|
+
email: user.email,
|
|
198
|
+
organizationId: user.organizationId
|
|
199
|
+
},
|
|
200
|
+
metadata: {
|
|
201
|
+
ip: getRequestIpAddress(context.req),
|
|
202
|
+
userAgent: getRequestUserAgent(context.req)
|
|
203
|
+
},
|
|
204
|
+
log: responseLog
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
169
208
|
});
|
|
170
209
|
};
|
|
171
210
|
|
|
172
211
|
const signature = () => {
|
|
173
212
|
return createMiddleware(async (context, next) => {
|
|
174
|
-
if (!
|
|
213
|
+
if (!context.env.MIDDLEWARE_SIGNATURE_DISABLED) {
|
|
175
214
|
const signatureHeader = context.req.header("x-signature");
|
|
176
215
|
if (!signatureHeader) {
|
|
177
216
|
throw new HTTPException(401, {
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
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 };
|
|
@@ -1,14 +0,0 @@
|
|
|
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 };
|