@plyaz/types 1.18.0 → 1.18.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/api/endpoints/featureFlags/endpoints.d.ts +83 -0
- package/dist/api/endpoints/featureFlags/index.d.ts +8 -0
- package/dist/api/endpoints/featureFlags/types.d.ts +153 -0
- package/dist/api/endpoints/index.d.ts +1 -0
- package/dist/api/endpoints/types.d.ts +2 -1
- package/dist/api/index.cjs +52 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +52 -0
- package/dist/api/index.js.map +1 -1
- package/dist/core/events/index.d.ts +4 -0
- package/dist/core/events/payloads.d.ts +168 -0
- package/dist/core/featureFlag/enums.d.ts +11 -6
- package/dist/core/featureFlag/types.d.ts +146 -1
- package/dist/core/index.d.ts +3 -0
- package/dist/core/modules.d.ts +408 -0
- package/dist/db/audit.types.d.ts +22 -0
- package/dist/db/config.types.d.ts +21 -1
- package/dist/db/database.types.d.ts +2 -0
- package/dist/db/databaseAdapter.d.ts +13 -3
- package/dist/db/databaseService.d.ts +21 -48
- package/dist/db/dbEnums.d.ts +33 -5
- package/dist/db/extensions.types.d.ts +35 -0
- package/dist/db/features-config.types.d.ts +28 -2
- package/dist/db/health.types.d.ts +16 -0
- package/dist/db/index.cjs +20 -3
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.ts +5 -0
- package/dist/db/index.js +20 -4
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.types.d.ts +60 -0
- package/dist/db/seeds.types.d.ts +49 -0
- package/dist/db/tenant.types.d.ts +14 -0
- package/dist/errors/codes.d.ts +8 -0
- package/dist/errors/enums.d.ts +3 -0
- package/dist/errors/index.cjs +55 -0
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.js +55 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/examples/index.cjs +76 -0
- package/dist/examples/index.cjs.map +1 -0
- package/dist/examples/index.d.ts +17 -0
- package/dist/examples/index.js +68 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/examples/schemas.d.ts +119 -0
- package/dist/examples/types.d.ts +103 -0
- package/dist/features/feature-flag/types.d.ts +62 -32
- package/dist/index.cjs +107 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +103 -14
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/db/dbEnums.d.ts
CHANGED
|
@@ -87,7 +87,9 @@ export declare enum ADAPTERS {
|
|
|
87
87
|
/** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */
|
|
88
88
|
SUPABASE = "supabase",
|
|
89
89
|
/** Raw SQL adapter (direct database queries without ORM) */
|
|
90
|
-
SQL = "sql"
|
|
90
|
+
SQL = "sql",
|
|
91
|
+
/** Mock adapter (in-memory database for testing) */
|
|
92
|
+
MOCK = "mock"
|
|
91
93
|
}
|
|
92
94
|
export declare enum DATABASE_EVENT_TYPE {
|
|
93
95
|
BeforeQuery = "beforeQuery",
|
|
@@ -143,9 +145,34 @@ export declare enum ALERT_SOURCE {
|
|
|
143
145
|
* Audit operation types
|
|
144
146
|
*/
|
|
145
147
|
export declare enum AUDIT_OPERATION {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
Create = "CREATE",
|
|
149
|
+
Update = "UPDATE",
|
|
150
|
+
Delete = "DELETE",
|
|
151
|
+
CreateFailed = "CREATE_FAILED",
|
|
152
|
+
UpdateFailed = "UPDATE_FAILED",
|
|
153
|
+
DeleteFailed = "DELETE_FAILED"
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Extension source identifiers for audit logging
|
|
157
|
+
* Used to track which extension caused an operation failure
|
|
158
|
+
*/
|
|
159
|
+
export declare enum EXTENSION_SOURCE {
|
|
160
|
+
/** Base database adapter (Drizzle, Supabase, SQL, Mock) */
|
|
161
|
+
DatabaseAdapter = "DatabaseAdapter",
|
|
162
|
+
/** Encryption extension - field-level encryption */
|
|
163
|
+
Encryption = "EncryptionExtension",
|
|
164
|
+
/** Soft delete extension - logical deletion */
|
|
165
|
+
SoftDelete = "SoftDeleteExtension",
|
|
166
|
+
/** Caching extension - query result caching */
|
|
167
|
+
Caching = "CachingExtension",
|
|
168
|
+
/** Audit extension - operation logging */
|
|
169
|
+
Audit = "AuditExtension",
|
|
170
|
+
/** Read replica extension - read/write splitting */
|
|
171
|
+
ReadReplica = "ReadReplicaExtension",
|
|
172
|
+
/** Multi-write extension - write replication */
|
|
173
|
+
MultiWrite = "MultiWriteExtension",
|
|
174
|
+
/** Unknown source */
|
|
175
|
+
Unknown = "Unknown"
|
|
149
176
|
}
|
|
150
177
|
/**
|
|
151
178
|
* Database Adapter Types - Enum for adapter selection
|
|
@@ -153,5 +180,6 @@ export declare enum AUDIT_OPERATION {
|
|
|
153
180
|
export declare enum ADAPTER_TYPES {
|
|
154
181
|
DRIZZLE = "drizzle",
|
|
155
182
|
SUPABASE = "supabase",
|
|
156
|
-
SQL = "sql"
|
|
183
|
+
SQL = "sql",
|
|
184
|
+
MOCK = "mock"
|
|
157
185
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DatabaseAdapterType } from './databaseAdapter';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for multi-read extension
|
|
4
|
+
* Enables reading from multiple replica databases with load balancing
|
|
5
|
+
*/
|
|
6
|
+
export interface MultiReadConfig {
|
|
7
|
+
/** Enable multi-read extension */
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
/** Read replica adapters */
|
|
10
|
+
adapters: DatabaseAdapterType[];
|
|
11
|
+
/** Load balancing strategy */
|
|
12
|
+
strategy?: 'round-robin' | 'random' | 'fastest' | 'least-conn';
|
|
13
|
+
/** Fallback to primary on replica failure */
|
|
14
|
+
fallbackToPrimary?: boolean;
|
|
15
|
+
/** Health check interval in milliseconds */
|
|
16
|
+
healthCheckInterval?: number;
|
|
17
|
+
/** Max failures before marking replica unhealthy */
|
|
18
|
+
maxFailures?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for multi-write extension
|
|
22
|
+
* Enables writing to multiple databases for redundancy/replication
|
|
23
|
+
*/
|
|
24
|
+
export interface MultiWriteConfig {
|
|
25
|
+
/** Enable multi-write extension */
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
/** Secondary adapters to replicate writes to */
|
|
28
|
+
adapters: DatabaseAdapterType[];
|
|
29
|
+
/** Write mode: 'best-effort' (async, non-blocking) or 'strict' (sync, all must succeed) */
|
|
30
|
+
mode?: 'best-effort' | 'strict';
|
|
31
|
+
/** Behavior on secondary failure: 'log' (silent), 'warn' (console.warn), 'throw' (error) */
|
|
32
|
+
onSecondaryFailure?: 'log' | 'warn' | 'throw';
|
|
33
|
+
/** Timeout for secondary writes in milliseconds */
|
|
34
|
+
timeout?: number;
|
|
35
|
+
}
|
|
@@ -88,7 +88,7 @@ export interface SoftDeleteConfig {
|
|
|
88
88
|
export interface DBEncryptionConfig {
|
|
89
89
|
/** Whether encryption is enabled */
|
|
90
90
|
enabled: boolean;
|
|
91
|
-
/** Base64 encoded encryption key */
|
|
91
|
+
/** Base64 encoded encryption key - must be 32 bytes for AES-256 */
|
|
92
92
|
key: string;
|
|
93
93
|
/** Fields to encrypt per table */
|
|
94
94
|
fields: Record<string, string[]>;
|
|
@@ -103,14 +103,20 @@ export interface DBEncryptionConfig {
|
|
|
103
103
|
export interface AuditConfig {
|
|
104
104
|
/** Whether audit logging is enabled */
|
|
105
105
|
enabled: boolean;
|
|
106
|
-
/** Number of days to retain audit logs (default:
|
|
106
|
+
/** Number of days to retain audit logs (default: 180 for GDPR/SOX compliance) */
|
|
107
107
|
retentionDays?: number;
|
|
108
108
|
/** Fields to exclude from audit logs */
|
|
109
109
|
excludeFields?: string[];
|
|
110
110
|
/** Tables to exclude from audit logging */
|
|
111
111
|
excludeTables?: string[];
|
|
112
|
+
/** Database schema for audit tables (default: 'audit') */
|
|
113
|
+
schema?: string;
|
|
114
|
+
/** Use daily partitioned tables (audit_log_yyyy_mm_dd format) (default: true) */
|
|
115
|
+
usePartitionedTables?: boolean;
|
|
112
116
|
/** Custom audit event handler */
|
|
113
117
|
onAuditAfterWrite?: (event: AuditEvent) => void | Promise<void>;
|
|
118
|
+
/** Encrypted fields config from encryption extension (for audit metadata) */
|
|
119
|
+
encryptedFields?: Record<string, string[]>;
|
|
114
120
|
}
|
|
115
121
|
/**
|
|
116
122
|
* Configuration for automatic timestamps
|
|
@@ -204,21 +210,35 @@ export interface DrizzleConfig {
|
|
|
204
210
|
url?: string;
|
|
205
211
|
poolSize?: number;
|
|
206
212
|
ssl?: boolean;
|
|
213
|
+
/** Default schema for all tables (e.g., 'test', 'public') */
|
|
214
|
+
schema?: string;
|
|
215
|
+
/** Table ID column mappings for auto-detection */
|
|
216
|
+
tableIdColumns?: Record<string, string>;
|
|
207
217
|
}
|
|
208
218
|
export interface SupabaseConfig {
|
|
209
219
|
supabaseUrl: string;
|
|
210
220
|
supabaseAnonKey: string;
|
|
211
221
|
supabaseServiceKey?: string;
|
|
212
222
|
schema?: string;
|
|
223
|
+
/** Table ID column mappings for auto-detection */
|
|
224
|
+
tableIdColumns?: Record<string, string>;
|
|
213
225
|
}
|
|
214
226
|
export interface SqlConfig {
|
|
215
227
|
connectionString?: string;
|
|
216
228
|
url?: string;
|
|
217
229
|
dialect?: 'postgresql' | 'mysql' | 'sqlite';
|
|
230
|
+
/** Default schema for all tables (e.g., 'test', 'public') */
|
|
231
|
+
schema?: string;
|
|
232
|
+
/** Table ID column mappings for auto-detection */
|
|
233
|
+
tableIdColumns?: Record<string, string>;
|
|
218
234
|
}
|
|
219
235
|
export interface MockConfig {
|
|
220
236
|
logging?: boolean;
|
|
221
237
|
initialData?: Record<string, Record<string, string | number | boolean | Date>[]>;
|
|
238
|
+
/** Default schema for all tables */
|
|
239
|
+
schema?: string;
|
|
240
|
+
/** Table ID column mappings for auto-detection */
|
|
241
|
+
tableIdColumns?: Record<string, string>;
|
|
222
242
|
}
|
|
223
243
|
/**
|
|
224
244
|
* Union type for adapter configurations
|
|
@@ -238,12 +258,18 @@ export interface OperationConfig {
|
|
|
238
258
|
cache?: Partial<DBCacheConfig>;
|
|
239
259
|
/** Force specific adapter usage */
|
|
240
260
|
forceAdapter?: 'primary' | 'replica';
|
|
261
|
+
/** Use a specific named adapter for this operation (from DbService.adapters config) */
|
|
262
|
+
adapter?: string;
|
|
241
263
|
/** Include soft-deleted records in results */
|
|
242
264
|
includeSoftDeleted?: boolean;
|
|
243
265
|
/** Override query timeout for this operation */
|
|
244
266
|
timeout?: number;
|
|
245
267
|
/** Override timestamp settings for this operation */
|
|
246
268
|
timestamps?: Partial<TimestampsConfig>;
|
|
269
|
+
/** Override ID column name for this operation (default: 'id') */
|
|
270
|
+
idColumn?: string;
|
|
271
|
+
/** Override database schema for this operation */
|
|
272
|
+
schema?: string;
|
|
247
273
|
}
|
|
248
274
|
/**
|
|
249
275
|
* Complete database service configuration
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DatabaseAdapterType } from './databaseAdapter';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for HealthManager with auto-failover support
|
|
4
|
+
*/
|
|
5
|
+
export interface HealthManagerConfig {
|
|
6
|
+
/** Primary adapter */
|
|
7
|
+
primary: DatabaseAdapterType;
|
|
8
|
+
/** Backup adapters for failover */
|
|
9
|
+
backups?: DatabaseAdapterType[];
|
|
10
|
+
/** Health check interval in milliseconds */
|
|
11
|
+
healthCheckInterval?: number;
|
|
12
|
+
/** Number of consecutive failures before failover */
|
|
13
|
+
failoverThreshold?: number;
|
|
14
|
+
/** Enable automatic failover */
|
|
15
|
+
autoFailover?: boolean;
|
|
16
|
+
}
|
package/dist/db/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var ADAPTERS = /* @__PURE__ */ ((ADAPTERS2) => {
|
|
|
8
8
|
ADAPTERS2["DRIZZLE"] = "drizzle";
|
|
9
9
|
ADAPTERS2["SUPABASE"] = "supabase";
|
|
10
10
|
ADAPTERS2["SQL"] = "sql";
|
|
11
|
+
ADAPTERS2["MOCK"] = "mock";
|
|
11
12
|
return ADAPTERS2;
|
|
12
13
|
})(ADAPTERS || {});
|
|
13
14
|
var DATABASE_EVENT_TYPE = /* @__PURE__ */ ((DATABASE_EVENT_TYPE2) => {
|
|
@@ -50,15 +51,30 @@ var ALERT_SOURCE = /* @__PURE__ */ ((ALERT_SOURCE2) => {
|
|
|
50
51
|
return ALERT_SOURCE2;
|
|
51
52
|
})(ALERT_SOURCE || {});
|
|
52
53
|
var AUDIT_OPERATION = /* @__PURE__ */ ((AUDIT_OPERATION2) => {
|
|
53
|
-
AUDIT_OPERATION2["
|
|
54
|
-
AUDIT_OPERATION2["
|
|
55
|
-
AUDIT_OPERATION2["
|
|
54
|
+
AUDIT_OPERATION2["Create"] = "CREATE";
|
|
55
|
+
AUDIT_OPERATION2["Update"] = "UPDATE";
|
|
56
|
+
AUDIT_OPERATION2["Delete"] = "DELETE";
|
|
57
|
+
AUDIT_OPERATION2["CreateFailed"] = "CREATE_FAILED";
|
|
58
|
+
AUDIT_OPERATION2["UpdateFailed"] = "UPDATE_FAILED";
|
|
59
|
+
AUDIT_OPERATION2["DeleteFailed"] = "DELETE_FAILED";
|
|
56
60
|
return AUDIT_OPERATION2;
|
|
57
61
|
})(AUDIT_OPERATION || {});
|
|
62
|
+
var EXTENSION_SOURCE = /* @__PURE__ */ ((EXTENSION_SOURCE2) => {
|
|
63
|
+
EXTENSION_SOURCE2["DatabaseAdapter"] = "DatabaseAdapter";
|
|
64
|
+
EXTENSION_SOURCE2["Encryption"] = "EncryptionExtension";
|
|
65
|
+
EXTENSION_SOURCE2["SoftDelete"] = "SoftDeleteExtension";
|
|
66
|
+
EXTENSION_SOURCE2["Caching"] = "CachingExtension";
|
|
67
|
+
EXTENSION_SOURCE2["Audit"] = "AuditExtension";
|
|
68
|
+
EXTENSION_SOURCE2["ReadReplica"] = "ReadReplicaExtension";
|
|
69
|
+
EXTENSION_SOURCE2["MultiWrite"] = "MultiWriteExtension";
|
|
70
|
+
EXTENSION_SOURCE2["Unknown"] = "Unknown";
|
|
71
|
+
return EXTENSION_SOURCE2;
|
|
72
|
+
})(EXTENSION_SOURCE || {});
|
|
58
73
|
var ADAPTER_TYPES = /* @__PURE__ */ ((ADAPTER_TYPES2) => {
|
|
59
74
|
ADAPTER_TYPES2["DRIZZLE"] = "drizzle";
|
|
60
75
|
ADAPTER_TYPES2["SUPABASE"] = "supabase";
|
|
61
76
|
ADAPTER_TYPES2["SQL"] = "sql";
|
|
77
|
+
ADAPTER_TYPES2["MOCK"] = "mock";
|
|
62
78
|
return ADAPTER_TYPES2;
|
|
63
79
|
})(ADAPTER_TYPES || {});
|
|
64
80
|
|
|
@@ -88,6 +104,7 @@ exports.AUDIT_OPERATION = AUDIT_OPERATION;
|
|
|
88
104
|
exports.DATABASE_EVENT_TYPE = DATABASE_EVENT_TYPE;
|
|
89
105
|
exports.DB_POOL_EVENTS = DB_POOL_EVENTS;
|
|
90
106
|
exports.ENCRYPTION_DEFAULTS = ENCRYPTION_DEFAULTS;
|
|
107
|
+
exports.EXTENSION_SOURCE = EXTENSION_SOURCE;
|
|
91
108
|
exports.REPLICA_STRATEGY = REPLICA_STRATEGY;
|
|
92
109
|
//# sourceMappingURL=index.cjs.map
|
|
93
110
|
//# sourceMappingURL=index.cjs.map
|
package/dist/db/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/dbEnums.ts","../../src/db/dbConstant.ts"],"names":["ADAPTERS","DATABASE_EVENT_TYPE","REPLICA_STRATEGY","DB_POOL_EVENTS","ALERT_SEVERITY","ALERT_SOURCE","AUDIT_OPERATION","ADAPTER_TYPES"],"mappings":";;;;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SA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AAA,iBAAA,cAAA,CAAA,GAAe,eAAA;AANL,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;AAaL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AAEL,EAAAA,kBAAA,iBAAA,CAAA,GAAkB,iBAAA;AAElB,EAAAA,kBAAA,YAAA,CAAA,GAAa,qBAAA;AAEb,EAAAA,kBAAA,YAAA,CAAA,GAAa,qBAAA;AAEb,EAAAA,kBAAA,SAAA,CAAA,GAAU,kBAAA;AAEV,EAAAA,kBAAA,OAAA,CAAA,GAAQ,gBAAA;AAER,EAAAA,kBAAA,aAAA,CAAA,GAAc,sBAAA;AAEd,EAAAA,kBAAA,YAAA,CAAA,GAAa,qBAAA;AAEb,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAhBA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA;AAsBL,IAAK,aAAA,qBAAAC,cAAAA,KAAL;AACL,EAAAA,eAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AAJG,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;;;ACzLL,IAAM,mBAAA,GAAsB;AAAA;AAAA,EAEjC,SAAA,EAAW,aAAA;AAAA;AAAA,EAGX,SAAA,EAAW,EAAA;AAAA;AAAA,EAGX,qBAAA,EAAuB,CAAA;AAAA;AAAA,EAGvB,WAAA,EAAa;AACf;AAKO,IAAM,aAAA,GAAgB;AAAA,EAC3B,eAAA,EAAiB,iBAAA;AAAA,EACjB,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa;AACf","file":"index.cjs","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n\n /** Mock adapter (in-memory database for testing) */\n MOCK = 'mock',\n}\n\n// Event type enum\nexport enum DATABASE_EVENT_TYPE {\n BeforeQuery = 'beforeQuery',\n AfterQuery = 'afterQuery',\n QueryError = 'queryError',\n BeforeTransaction = 'beforeTransaction',\n AfterTransaction = 'afterTransaction',\n TransactionRollback = 'transactionRollback',\n HealthChange = 'healthChange',\n}\n\n/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n\n/**\n * Enum for pool event types.\n */\nexport enum DB_POOL_EVENTS {\n CONNECT = 'connect',\n ACQUIRE = 'acquire',\n RELEASE = 'release',\n REMOVE = 'remove',\n}\n\n/**\n * Alert severity levels\n */\nexport enum ALERT_SEVERITY {\n CRITICAL = 'critical',\n ERROR = 'error',\n WARNING = 'warning',\n INFO = 'info',\n}\n\n/**\n * Alert source types\n */\nexport enum ALERT_SOURCE {\n DATABASE = 'database',\n POOL = 'pool',\n REPLICA = 'replica',\n CACHE = 'cache',\n BACKUP = 'backup',\n}\n\n/**\n * Audit operation types\n */\nexport enum AUDIT_OPERATION {\n Create = 'CREATE',\n Update = 'UPDATE',\n Delete = 'DELETE',\n CreateFailed = 'CREATE_FAILED',\n UpdateFailed = 'UPDATE_FAILED',\n DeleteFailed = 'DELETE_FAILED',\n}\n\n/**\n * Extension source identifiers for audit logging\n * Used to track which extension caused an operation failure\n */\nexport enum EXTENSION_SOURCE {\n /** Base database adapter (Drizzle, Supabase, SQL, Mock) */\n DatabaseAdapter = 'DatabaseAdapter',\n /** Encryption extension - field-level encryption */\n Encryption = 'EncryptionExtension',\n /** Soft delete extension - logical deletion */\n SoftDelete = 'SoftDeleteExtension',\n /** Caching extension - query result caching */\n Caching = 'CachingExtension',\n /** Audit extension - operation logging */\n Audit = 'AuditExtension',\n /** Read replica extension - read/write splitting */\n ReadReplica = 'ReadReplicaExtension',\n /** Multi-write extension - write replication */\n MultiWrite = 'MultiWriteExtension',\n /** Unknown source */\n Unknown = 'Unknown',\n}\n\n/**\n * Database Adapter Types - Enum for adapter selection\n */\nexport enum ADAPTER_TYPES {\n DRIZZLE = 'drizzle',\n SUPABASE = 'supabase',\n SQL = 'sql',\n MOCK = 'mock',\n}\n","/**\n * Encryption Extension Constants\n *\n * Centralized constants for encryption configuration to prevent\n * hardcoded values and ensure consistency across the codebase.\n */\n\nexport const ENCRYPTION_DEFAULTS = {\n /** Default encryption algorithm - AES-256-GCM provides authenticated encryption */\n ALGORITHM: 'aes-256-gcm' as const,\n\n /** IV length for AES-256-GCM in bytes */\n IV_LENGTH: 16,\n\n /** Expected parts in encrypted text format (iv:authTag:encrypted) */\n ENCRYPTED_PARTS_COUNT: 3,\n\n /** Default encryption key for testing (32 bytes for AES-256) */\n DEFAULT_KEY: 'abcdefghijklmnopqrstuvwxyz123456',\n} as const;\n\n/**\n * Alert rule IDs\n */\nexport const ALERT_RULE_ID = {\n POOL_EXHAUSTION: 'pool-exhaustion',\n SLOW_QUERY: 'slow-query',\n REPLICA_LAG: 'replica-lag',\n} as const;\n"]}
|
package/dist/db/index.d.ts
CHANGED
|
@@ -13,3 +13,8 @@ export type * from './backup.types';
|
|
|
13
13
|
export type * from './replica.types';
|
|
14
14
|
export * from './dbEnums';
|
|
15
15
|
export * from './dbConstant';
|
|
16
|
+
export type * from './extensions.types';
|
|
17
|
+
export type * from './migrations.types';
|
|
18
|
+
export type * from './seeds.types';
|
|
19
|
+
export type * from './health.types';
|
|
20
|
+
export type * from './tenant.types';
|
package/dist/db/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var ADAPTERS = /* @__PURE__ */ ((ADAPTERS2) => {
|
|
|
6
6
|
ADAPTERS2["DRIZZLE"] = "drizzle";
|
|
7
7
|
ADAPTERS2["SUPABASE"] = "supabase";
|
|
8
8
|
ADAPTERS2["SQL"] = "sql";
|
|
9
|
+
ADAPTERS2["MOCK"] = "mock";
|
|
9
10
|
return ADAPTERS2;
|
|
10
11
|
})(ADAPTERS || {});
|
|
11
12
|
var DATABASE_EVENT_TYPE = /* @__PURE__ */ ((DATABASE_EVENT_TYPE2) => {
|
|
@@ -48,15 +49,30 @@ var ALERT_SOURCE = /* @__PURE__ */ ((ALERT_SOURCE2) => {
|
|
|
48
49
|
return ALERT_SOURCE2;
|
|
49
50
|
})(ALERT_SOURCE || {});
|
|
50
51
|
var AUDIT_OPERATION = /* @__PURE__ */ ((AUDIT_OPERATION2) => {
|
|
51
|
-
AUDIT_OPERATION2["
|
|
52
|
-
AUDIT_OPERATION2["
|
|
53
|
-
AUDIT_OPERATION2["
|
|
52
|
+
AUDIT_OPERATION2["Create"] = "CREATE";
|
|
53
|
+
AUDIT_OPERATION2["Update"] = "UPDATE";
|
|
54
|
+
AUDIT_OPERATION2["Delete"] = "DELETE";
|
|
55
|
+
AUDIT_OPERATION2["CreateFailed"] = "CREATE_FAILED";
|
|
56
|
+
AUDIT_OPERATION2["UpdateFailed"] = "UPDATE_FAILED";
|
|
57
|
+
AUDIT_OPERATION2["DeleteFailed"] = "DELETE_FAILED";
|
|
54
58
|
return AUDIT_OPERATION2;
|
|
55
59
|
})(AUDIT_OPERATION || {});
|
|
60
|
+
var EXTENSION_SOURCE = /* @__PURE__ */ ((EXTENSION_SOURCE2) => {
|
|
61
|
+
EXTENSION_SOURCE2["DatabaseAdapter"] = "DatabaseAdapter";
|
|
62
|
+
EXTENSION_SOURCE2["Encryption"] = "EncryptionExtension";
|
|
63
|
+
EXTENSION_SOURCE2["SoftDelete"] = "SoftDeleteExtension";
|
|
64
|
+
EXTENSION_SOURCE2["Caching"] = "CachingExtension";
|
|
65
|
+
EXTENSION_SOURCE2["Audit"] = "AuditExtension";
|
|
66
|
+
EXTENSION_SOURCE2["ReadReplica"] = "ReadReplicaExtension";
|
|
67
|
+
EXTENSION_SOURCE2["MultiWrite"] = "MultiWriteExtension";
|
|
68
|
+
EXTENSION_SOURCE2["Unknown"] = "Unknown";
|
|
69
|
+
return EXTENSION_SOURCE2;
|
|
70
|
+
})(EXTENSION_SOURCE || {});
|
|
56
71
|
var ADAPTER_TYPES = /* @__PURE__ */ ((ADAPTER_TYPES2) => {
|
|
57
72
|
ADAPTER_TYPES2["DRIZZLE"] = "drizzle";
|
|
58
73
|
ADAPTER_TYPES2["SUPABASE"] = "supabase";
|
|
59
74
|
ADAPTER_TYPES2["SQL"] = "sql";
|
|
75
|
+
ADAPTER_TYPES2["MOCK"] = "mock";
|
|
60
76
|
return ADAPTER_TYPES2;
|
|
61
77
|
})(ADAPTER_TYPES || {});
|
|
62
78
|
|
|
@@ -77,6 +93,6 @@ var ALERT_RULE_ID = {
|
|
|
77
93
|
REPLICA_LAG: "replica-lag"
|
|
78
94
|
};
|
|
79
95
|
|
|
80
|
-
export { ADAPTERS, ADAPTER_TYPES, ALERT_RULE_ID, ALERT_SEVERITY, ALERT_SOURCE, AUDIT_OPERATION, DATABASE_EVENT_TYPE, DB_POOL_EVENTS, ENCRYPTION_DEFAULTS, REPLICA_STRATEGY };
|
|
96
|
+
export { ADAPTERS, ADAPTER_TYPES, ALERT_RULE_ID, ALERT_SEVERITY, ALERT_SOURCE, AUDIT_OPERATION, DATABASE_EVENT_TYPE, DB_POOL_EVENTS, ENCRYPTION_DEFAULTS, EXTENSION_SOURCE, REPLICA_STRATEGY };
|
|
81
97
|
//# sourceMappingURL=index.js.map
|
|
82
98
|
//# sourceMappingURL=index.js.map
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/dbEnums.ts","../../src/db/dbConstant.ts"],"names":["ADAPTERS","DATABASE_EVENT_TYPE","REPLICA_STRATEGY","DB_POOL_EVENTS","ALERT_SEVERITY","ALERT_SOURCE","AUDIT_OPERATION","ADAPTER_TYPES"],"mappings":";;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/db/dbEnums.ts","../../src/db/dbConstant.ts"],"names":["ADAPTERS","DATABASE_EVENT_TYPE","REPLICA_STRATEGY","DB_POOL_EVENTS","ALERT_SEVERITY","ALERT_SOURCE","AUDIT_OPERATION","EXTENSION_SOURCE","ADAPTER_TYPES"],"mappings":";;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAGN,EAAAA,UAAA,MAAA,CAAA,GAAO,MAAA;AAdG,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAkBL,IAAK,mBAAA,qBAAAC,oBAAAA,KAAL;AACL,EAAAA,qBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,mBAAA,CAAA,GAAoB,mBAAA;AACpB,EAAAA,qBAAA,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AA,GAAsB;AAAA;AAAA,EAEjC,SAAA,EAAW,aAAA;AAAA;AAAA,EAGX,SAAA,EAAW,EAAA;AAAA;AAAA,EAGX,qBAAA,EAAuB,CAAA;AAAA;AAAA,EAGvB,WAAA,EAAa;AACf;AAKO,IAAM,aAAA,GAAgB;AAAA,EAC3B,eAAA,EAAiB,iBAAA;AAAA,EACjB,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa;AACf","file":"index.js","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n\n /** Mock adapter (in-memory database for testing) */\n MOCK = 'mock',\n}\n\n// Event type enum\nexport enum DATABASE_EVENT_TYPE {\n BeforeQuery = 'beforeQuery',\n AfterQuery = 'afterQuery',\n QueryError = 'queryError',\n BeforeTransaction = 'beforeTransaction',\n AfterTransaction = 'afterTransaction',\n TransactionRollback = 'transactionRollback',\n HealthChange = 'healthChange',\n}\n\n/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n\n/**\n * Enum for pool event types.\n */\nexport enum DB_POOL_EVENTS {\n CONNECT = 'connect',\n ACQUIRE = 'acquire',\n RELEASE = 'release',\n REMOVE = 'remove',\n}\n\n/**\n * Alert severity levels\n */\nexport enum ALERT_SEVERITY {\n CRITICAL = 'critical',\n ERROR = 'error',\n WARNING = 'warning',\n INFO = 'info',\n}\n\n/**\n * Alert source types\n */\nexport enum ALERT_SOURCE {\n DATABASE = 'database',\n POOL = 'pool',\n REPLICA = 'replica',\n CACHE = 'cache',\n BACKUP = 'backup',\n}\n\n/**\n * Audit operation types\n */\nexport enum AUDIT_OPERATION {\n Create = 'CREATE',\n Update = 'UPDATE',\n Delete = 'DELETE',\n CreateFailed = 'CREATE_FAILED',\n UpdateFailed = 'UPDATE_FAILED',\n DeleteFailed = 'DELETE_FAILED',\n}\n\n/**\n * Extension source identifiers for audit logging\n * Used to track which extension caused an operation failure\n */\nexport enum EXTENSION_SOURCE {\n /** Base database adapter (Drizzle, Supabase, SQL, Mock) */\n DatabaseAdapter = 'DatabaseAdapter',\n /** Encryption extension - field-level encryption */\n Encryption = 'EncryptionExtension',\n /** Soft delete extension - logical deletion */\n SoftDelete = 'SoftDeleteExtension',\n /** Caching extension - query result caching */\n Caching = 'CachingExtension',\n /** Audit extension - operation logging */\n Audit = 'AuditExtension',\n /** Read replica extension - read/write splitting */\n ReadReplica = 'ReadReplicaExtension',\n /** Multi-write extension - write replication */\n MultiWrite = 'MultiWriteExtension',\n /** Unknown source */\n Unknown = 'Unknown',\n}\n\n/**\n * Database Adapter Types - Enum for adapter selection\n */\nexport enum ADAPTER_TYPES {\n DRIZZLE = 'drizzle',\n SUPABASE = 'supabase',\n SQL = 'sql',\n MOCK = 'mock',\n}\n","/**\n * Encryption Extension Constants\n *\n * Centralized constants for encryption configuration to prevent\n * hardcoded values and ensure consistency across the codebase.\n */\n\nexport const ENCRYPTION_DEFAULTS = {\n /** Default encryption algorithm - AES-256-GCM provides authenticated encryption */\n ALGORITHM: 'aes-256-gcm' as const,\n\n /** IV length for AES-256-GCM in bytes */\n IV_LENGTH: 16,\n\n /** Expected parts in encrypted text format (iv:authTag:encrypted) */\n ENCRYPTED_PARTS_COUNT: 3,\n\n /** Default encryption key for testing (32 bytes for AES-256) */\n DEFAULT_KEY: 'abcdefghijklmnopqrstuvwxyz123456',\n} as const;\n\n/**\n * Alert rule IDs\n */\nexport const ALERT_RULE_ID = {\n POOL_EXHAUSTION: 'pool-exhaustion',\n SLOW_QUERY: 'slow-query',\n REPLICA_LAG: 'replica-lag',\n} as const;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DatabaseAdapterType } from './databaseAdapter';
|
|
2
|
+
/**
|
|
3
|
+
* Migration definition
|
|
4
|
+
*/
|
|
5
|
+
export interface Migration {
|
|
6
|
+
/** Migration version (timestamp or number) */
|
|
7
|
+
version: string;
|
|
8
|
+
/** Migration name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Migration up function */
|
|
11
|
+
up: (adapter: DatabaseAdapterType) => Promise<void>;
|
|
12
|
+
/** Migration down function (rollback) */
|
|
13
|
+
down: (adapter: DatabaseAdapterType) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parsed migration file metadata
|
|
17
|
+
*/
|
|
18
|
+
export interface MigrationFile {
|
|
19
|
+
/** Full file path */
|
|
20
|
+
filePath: string;
|
|
21
|
+
/** Migration version extracted from filename */
|
|
22
|
+
version: string;
|
|
23
|
+
/** Migration name extracted from filename */
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Migration record stored in database
|
|
28
|
+
*/
|
|
29
|
+
export interface MigrationRecord {
|
|
30
|
+
/** Migration version */
|
|
31
|
+
version: string;
|
|
32
|
+
/** Migration name */
|
|
33
|
+
name: string;
|
|
34
|
+
/** When migration was applied */
|
|
35
|
+
applied_at: string;
|
|
36
|
+
/** Execution time in milliseconds */
|
|
37
|
+
execution_time: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for MigrationManager
|
|
41
|
+
*/
|
|
42
|
+
export interface MigrationManagerConfig {
|
|
43
|
+
/** Database adapter */
|
|
44
|
+
adapter: DatabaseAdapterType;
|
|
45
|
+
/** Path to migrations directory (default: './migrations') */
|
|
46
|
+
migrationsPath?: string;
|
|
47
|
+
/** Table name for migration history (default: 'schema_migrations') */
|
|
48
|
+
tableName?: string;
|
|
49
|
+
/** Database schema to use (for multi-tenant support) */
|
|
50
|
+
schema?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Migration status response
|
|
54
|
+
*/
|
|
55
|
+
export interface MigrationStatus {
|
|
56
|
+
/** Migrations that have been applied */
|
|
57
|
+
applied: MigrationRecord[];
|
|
58
|
+
/** Migrations that are pending */
|
|
59
|
+
pending: string[];
|
|
60
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DatabaseAdapterType } from './databaseAdapter';
|
|
2
|
+
/**
|
|
3
|
+
* Seed definition
|
|
4
|
+
*/
|
|
5
|
+
export interface Seed {
|
|
6
|
+
/** Seed name */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Seed execution function */
|
|
9
|
+
run: (adapter: DatabaseAdapterType) => Promise<void>;
|
|
10
|
+
/** Optional cleanup function */
|
|
11
|
+
cleanup?: (adapter: DatabaseAdapterType) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parsed seed file metadata
|
|
15
|
+
*/
|
|
16
|
+
export interface SeedFile {
|
|
17
|
+
/** Full file path */
|
|
18
|
+
filePath: string;
|
|
19
|
+
/** Seed order (extracted from filename) */
|
|
20
|
+
order: number;
|
|
21
|
+
/** Seed name (extracted from filename) */
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Seed record stored in database
|
|
26
|
+
*/
|
|
27
|
+
export interface SeedRecord {
|
|
28
|
+
/** Seed name */
|
|
29
|
+
name: string;
|
|
30
|
+
/** When seed was run */
|
|
31
|
+
run_at: string;
|
|
32
|
+
/** Execution time in milliseconds */
|
|
33
|
+
execution_time: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for SeedManager
|
|
37
|
+
*/
|
|
38
|
+
export interface SeedManagerConfig {
|
|
39
|
+
/** Database adapter */
|
|
40
|
+
adapter: DatabaseAdapterType;
|
|
41
|
+
/** Path to seeds directory (default: './seeds') */
|
|
42
|
+
seedsPath?: string;
|
|
43
|
+
/** Table name for seed history (default: 'seed_history') */
|
|
44
|
+
tableName?: string;
|
|
45
|
+
/** Skip seeds that have already been run */
|
|
46
|
+
skipExisting?: boolean;
|
|
47
|
+
/** Database schema to use (for multi-tenant support) */
|
|
48
|
+
schema?: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant context for multi-tenancy support
|
|
3
|
+
*/
|
|
4
|
+
export interface TenantContextType {
|
|
5
|
+
/** Tenant identifier */
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Context for tenant validation operations
|
|
10
|
+
*/
|
|
11
|
+
export interface TenantValidationContext {
|
|
12
|
+
/** Tenant identifier to validate */
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
package/dist/errors/codes.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ import type { ErrorDefinitions } from './types';
|
|
|
13
13
|
* Combined error codes from all @plyaz packages
|
|
14
14
|
*/
|
|
15
15
|
export declare const ERROR_CODES: {
|
|
16
|
+
readonly NOT_IMPLEMENTED: "not.implemented";
|
|
17
|
+
readonly PROVIDER_NOT_IMPLEMENTED: "provider.not.implemented";
|
|
18
|
+
readonly FEATURE_NOT_SUPPORTED: "feature.not.supported";
|
|
16
19
|
readonly CLIENT_INITIALIZATION_FAILED: "CLIENT_INITIALIZATION_FAILED";
|
|
17
20
|
readonly CLIENT_INVALID_CONFIG: "CLIENT_INVALID_CONFIG";
|
|
18
21
|
readonly CLIENT_MISSING_BASE_URL: "CLIENT_MISSING_BASE_URL";
|
|
@@ -359,12 +362,14 @@ export declare const ERROR_CODES: {
|
|
|
359
362
|
readonly DB_INVALID_IN_OPERATOR: "db.invalid_in_operator";
|
|
360
363
|
readonly DB_INVALID_COUNT: "db.invalid_count";
|
|
361
364
|
readonly DB_CONNECTION_FAILED: "db.connection_failed";
|
|
365
|
+
readonly DB_CONNECTION_ERROR: "db.connection_error";
|
|
362
366
|
readonly DB_TIMEOUT: "db.timeout";
|
|
363
367
|
readonly DB_CONSTRAINT_VIOLATION: "db.constraint_violation";
|
|
364
368
|
readonly DB_DEADLOCK: "db.deadlock";
|
|
365
369
|
readonly DB_DUPLICATE_ENTRY: "db.duplicate_entry";
|
|
366
370
|
readonly DB_ENTITY_NOT_FOUND: "db.entity_not_found";
|
|
367
371
|
readonly DB_MIGRATION_FAILED: "db.migration_failed";
|
|
372
|
+
readonly DB_MULTI_WRITE_FAILED: "db.multi_write_failed";
|
|
368
373
|
readonly DB_UNKNOWN_ERROR: "db.unknown_error";
|
|
369
374
|
readonly PAYMENT_TIMEOUT: "payment.timeout";
|
|
370
375
|
readonly PAYMENT_NETWORK_ERROR: "payment.network.error";
|
|
@@ -1014,12 +1019,15 @@ export declare const DATABASE_ERROR_CODES: {
|
|
|
1014
1019
|
readonly INVALID_IN_OPERATOR: "db.invalid_in_operator";
|
|
1015
1020
|
readonly INVALID_COUNT: "db.invalid_count";
|
|
1016
1021
|
readonly CONNECTION_FAILED: "db.connection_failed";
|
|
1022
|
+
readonly CONNECTION_ERROR: "db.connection_error";
|
|
1017
1023
|
readonly CONSTRAINT_VIOLATION: "db.constraint_violation";
|
|
1018
1024
|
readonly TIMEOUT: "db.timeout";
|
|
1019
1025
|
readonly DEADLOCK: "db.deadlock";
|
|
1020
1026
|
readonly ENTITY_NOT_FOUND: "db.entity_not_found";
|
|
1021
1027
|
readonly DUPLICATE_ENTRY: "db.duplicate_entry";
|
|
1022
1028
|
readonly MIGRATION_FAILED: "db.migration_failed";
|
|
1029
|
+
readonly MULTI_WRITE_FAILED: "db.multi_write_failed";
|
|
1030
|
+
readonly NOT_FOUND: "db.record_not_found";
|
|
1023
1031
|
readonly UNKNOWN_ERROR: "db.unknown_error";
|
|
1024
1032
|
};
|
|
1025
1033
|
export type ApiErrorCodeValue = (typeof API_ERROR_CODES)[keyof typeof API_ERROR_CODES] | `HTTP_${number}`;
|
package/dist/errors/enums.d.ts
CHANGED
|
@@ -127,6 +127,8 @@ export declare const ERROR_CATEGORY: {
|
|
|
127
127
|
readonly Plugin: "plugin";
|
|
128
128
|
/** Quota or storage limit error (e.g., exceeded storage quota). */
|
|
129
129
|
readonly Quota: "quota";
|
|
130
|
+
/** Database-related error (e.g., query failure, connection error). */
|
|
131
|
+
readonly Database: "database";
|
|
130
132
|
/** Unknown or unclassified error. */
|
|
131
133
|
readonly Unknown: "unknown";
|
|
132
134
|
};
|
|
@@ -219,6 +221,7 @@ export declare const ERROR_CATEGORY_TO_EMITTER_KEY: {
|
|
|
219
221
|
readonly "file.operation": "fileOperation";
|
|
220
222
|
readonly plugin: "plugin";
|
|
221
223
|
readonly quota: "quota";
|
|
224
|
+
readonly database: "database";
|
|
222
225
|
readonly unknown: "unknown";
|
|
223
226
|
};
|
|
224
227
|
/**
|