@plyaz/db 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -0
- package/dist/adapters/drizzle/DrizzleAdapter.d.ts +269 -0
- package/dist/adapters/drizzle/DrizzleAdapter.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +20 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/sql/SQLAdapter.d.ts +282 -0
- package/dist/adapters/sql/SQLAdapter.d.ts.map +1 -0
- package/dist/adapters/supabase/SupabaseAdapter.d.ts +305 -0
- package/dist/adapters/supabase/SupabaseAdapter.d.ts.map +1 -0
- package/dist/advanced/backup/BackupService.d.ts +159 -0
- package/dist/advanced/backup/BackupService.d.ts.map +1 -0
- package/dist/advanced/backup/index.d.ts +2 -0
- package/dist/advanced/backup/index.d.ts.map +1 -0
- package/dist/advanced/caching/CacheEvict.decorator.d.ts +3 -0
- package/dist/advanced/caching/CacheEvict.decorator.d.ts.map +1 -0
- package/dist/advanced/caching/Cacheable.decorator.d.ts +99 -0
- package/dist/advanced/caching/Cacheable.decorator.d.ts.map +1 -0
- package/dist/advanced/caching/RedisCache.d.ts +417 -0
- package/dist/advanced/caching/RedisCache.d.ts.map +1 -0
- package/dist/advanced/caching/index.d.ts +4 -0
- package/dist/advanced/caching/index.d.ts.map +1 -0
- package/dist/advanced/connection-pool/DynamicPool.d.ts +234 -0
- package/dist/advanced/connection-pool/DynamicPool.d.ts.map +1 -0
- package/dist/advanced/connection-pool/index.d.ts +2 -0
- package/dist/advanced/connection-pool/index.d.ts.map +1 -0
- package/dist/advanced/index.d.ts +8 -0
- package/dist/advanced/index.d.ts.map +1 -0
- package/dist/advanced/monitoring/AlertManager.d.ts +72 -0
- package/dist/advanced/monitoring/AlertManager.d.ts.map +1 -0
- package/dist/advanced/monitoring/MetricsCollector.d.ts +81 -0
- package/dist/advanced/monitoring/MetricsCollector.d.ts.map +1 -0
- package/dist/advanced/monitoring/index.d.ts +3 -0
- package/dist/advanced/monitoring/index.d.ts.map +1 -0
- package/dist/advanced/multi-tenancy/TenantContext.d.ts +52 -0
- package/dist/advanced/multi-tenancy/TenantContext.d.ts.map +1 -0
- package/dist/advanced/multi-tenancy/TenantRepository.d.ts +292 -0
- package/dist/advanced/multi-tenancy/TenantRepository.d.ts.map +1 -0
- package/dist/advanced/multi-tenancy/index.d.ts +3 -0
- package/dist/advanced/multi-tenancy/index.d.ts.map +1 -0
- package/dist/advanced/read-replica/ReadReplicaAdapter.d.ts +516 -0
- package/dist/advanced/read-replica/ReadReplicaAdapter.d.ts.map +1 -0
- package/dist/advanced/read-replica/ReadReplicaManager.d.ts +68 -0
- package/dist/advanced/read-replica/ReadReplicaManager.d.ts.map +1 -0
- package/dist/advanced/read-replica/UseReplica.decorator.d.ts +24 -0
- package/dist/advanced/read-replica/UseReplica.decorator.d.ts.map +1 -0
- package/dist/advanced/read-replica/index.d.ts +3 -0
- package/dist/advanced/read-replica/index.d.ts.map +1 -0
- package/dist/advanced/sharding/ShardKey.d.ts +80 -0
- package/dist/advanced/sharding/ShardKey.d.ts.map +1 -0
- package/dist/advanced/sharding/ShardRouter.d.ts +66 -0
- package/dist/advanced/sharding/ShardRouter.d.ts.map +1 -0
- package/dist/advanced/sharding/index.d.ts +3 -0
- package/dist/advanced/sharding/index.d.ts.map +1 -0
- package/dist/builder/query/index.d.ts +7 -0
- package/dist/builder/query/index.d.ts.map +1 -0
- package/dist/builder/query/orm.d.ts +22 -0
- package/dist/builder/query/orm.d.ts.map +1 -0
- package/dist/builder/query/sql.d.ts +29 -0
- package/dist/builder/query/sql.d.ts.map +1 -0
- package/dist/extensions/AuditExtension.d.ts +468 -0
- package/dist/extensions/AuditExtension.d.ts.map +1 -0
- package/dist/extensions/CachingAdapter.d.ts +451 -0
- package/dist/extensions/CachingAdapter.d.ts.map +1 -0
- package/dist/extensions/EncryptionExtension.d.ts +95 -0
- package/dist/extensions/EncryptionExtension.d.ts.map +1 -0
- package/dist/extensions/ReadReplicaAdapter.d.ts +32 -0
- package/dist/extensions/ReadReplicaAdapter.d.ts.map +1 -0
- package/dist/extensions/SoftDeleteExtension.d.ts +430 -0
- package/dist/extensions/SoftDeleteExtension.d.ts.map +1 -0
- package/dist/extensions/index.d.ts +79 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/factory/AdapterFactory.d.ts +111 -0
- package/dist/factory/AdapterFactory.d.ts.map +1 -0
- package/dist/factory/createDatabaseService.d.ts +121 -0
- package/dist/factory/createDatabaseService.d.ts.map +1 -0
- package/dist/index.cjs +8518 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +8480 -0
- package/dist/index.mjs.map +1 -0
- package/dist/repository/BaseRepository.d.ts +209 -0
- package/dist/repository/BaseRepository.d.ts.map +1 -0
- package/dist/repository/index.d.ts +80 -0
- package/dist/repository/index.d.ts.map +1 -0
- package/dist/security/index.cjs +118 -0
- package/dist/security/index.cjs.map +1 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.mjs +114 -0
- package/dist/security/index.mjs.map +1 -0
- package/dist/security/sanitizers/html.sanitizer.d.ts +31 -0
- package/dist/security/sanitizers/html.sanitizer.d.ts.map +1 -0
- package/dist/security/serializers/DataValidation.d.ts +34 -0
- package/dist/security/serializers/DataValidation.d.ts.map +1 -0
- package/dist/service/DatabaseService.d.ts +136 -0
- package/dist/service/DatabaseService.d.ts.map +1 -0
- package/dist/service/EventEmitter.d.ts +110 -0
- package/dist/service/EventEmitter.d.ts.map +1 -0
- package/dist/service/HealthManager.d.ts +166 -0
- package/dist/service/HealthManager.d.ts.map +1 -0
- package/dist/utils/ConfigMerger.d.ts +227 -0
- package/dist/utils/ConfigMerger.d.ts.map +1 -0
- package/dist/utils/databaseResultHelpers.d.ts +98 -0
- package/dist/utils/databaseResultHelpers.d.ts.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/normalizeDetails.d.ts +111 -0
- package/dist/utils/normalizeDetails.d.ts.map +1 -0
- package/dist/utils/pagination.d.ts +77 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/regex.d.ts +199 -0
- package/dist/utils/regex.d.ts.map +1 -0
- package/dist/utils/typeGuards.d.ts +57 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +146 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/package.json +156 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Soft Delete Extension for @plyaz/db package
|
|
3
|
+
*
|
|
4
|
+
* This module provides the SoftDeleteAdapter extension that implements logical deletion
|
|
5
|
+
* instead of physical record removal. It automatically intercepts delete operations
|
|
6
|
+
* and converts them to timestamp updates, while filtering queries to exclude soft-deleted records.
|
|
7
|
+
*
|
|
8
|
+
* Part of the @plyaz/db package - a TypeScript database abstraction layer with
|
|
9
|
+
* support for multiple adapters (Drizzle, Supabase, SQL), extensions (audit, encryption,
|
|
10
|
+
* soft delete), and advanced features (caching, read replicas, multi-tenancy).
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
import type { DatabaseAdapterType, DatabaseResult, PaginatedResult, QueryOptions, Filter, DatabaseHealthStatus, Transaction } from "@plyaz/types/db";
|
|
14
|
+
/**
|
|
15
|
+
* SOFT DELETE ADAPTER - Logical Deletion Layer
|
|
16
|
+
*
|
|
17
|
+
* Soft delete extension that implements logical deletion instead of physical removal.
|
|
18
|
+
* Third layer in the adapter chain.
|
|
19
|
+
*
|
|
20
|
+
* **Adapter Chain Position:**
|
|
21
|
+
* ReadReplica -> Audit -> Cache -> **SoftDelete** -> Encryption -> Base Adapter
|
|
22
|
+
*
|
|
23
|
+
* **What this adapter does:**
|
|
24
|
+
* 1. Intercepts delete() operations sets deletedAt timestamp instead of removing
|
|
25
|
+
* 2. Intercepts query/list operations adds "WHERE deletedAt IS NULL" filter
|
|
26
|
+
* 3. Provides restore() method to undelete records
|
|
27
|
+
* 4. Honors includeSoftDeleted flag from operation config
|
|
28
|
+
*
|
|
29
|
+
* **Called by:** CachingAdapter (or AuditAdapter if no caching)
|
|
30
|
+
* **Calls:** EncryptionAdapter (or base adapter if no encryption)
|
|
31
|
+
* **Provides:** restore(), permanentDelete() methods
|
|
32
|
+
*
|
|
33
|
+
* **Soft Delete Flow:**
|
|
34
|
+
* - **Delete:** Sets deletedAt = NOW() instead of removing record
|
|
35
|
+
* - **Queries:** Automatically filters WHERE deletedAt IS NULL
|
|
36
|
+
* - **Restore:** Sets deletedAt = NULL to undelete
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ### Configuration
|
|
40
|
+
* ```typescript
|
|
41
|
+
* softDelete: {
|
|
42
|
+
* enabled: true,
|
|
43
|
+
* field: 'deletedAt', // Custom field name
|
|
44
|
+
* excludeTables: ['audit_logs'] // Tables that use hard delete
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ### Usage Flow
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Normal delete - sets deletedAt timestamp
|
|
52
|
+
* await db.delete(Tables.USERS, 'user-123');
|
|
53
|
+
*
|
|
54
|
+
* // Query automatically excludes soft-deleted records
|
|
55
|
+
* const activeUsers = await db.query(Tables.USERS, {});
|
|
56
|
+
*
|
|
57
|
+
* // Include soft-deleted records with operation config
|
|
58
|
+
* const allUsers = await db.query(Tables.USERS, {}, {
|
|
59
|
+
* includeSoftDeleted: true
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Restore soft-deleted record
|
|
63
|
+
* await db.restore(Tables.USERS, 'user-123');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class SoftDeleteAdapter implements DatabaseAdapterType {
|
|
67
|
+
private baseAdapter;
|
|
68
|
+
private config;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new SoftDeleteAdapter instance.
|
|
71
|
+
*
|
|
72
|
+
* **RESPONSIBILITY:** Wraps base adapter with soft delete functionality
|
|
73
|
+
* **CONFIGURATION:** Sets up deletion field name and excluded tables
|
|
74
|
+
*
|
|
75
|
+
* @param baseAdapter - The underlying database adapter to wrap
|
|
76
|
+
* @param config - Soft delete configuration options
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const softDeleteAdapter = new SoftDeleteAdapter(baseAdapter, {
|
|
81
|
+
* enabled: true,
|
|
82
|
+
* field: 'deletedAt',
|
|
83
|
+
* excludeTables: ['audit_logs', 'system_events']
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
constructor(baseAdapter: DatabaseAdapterType, config: {
|
|
88
|
+
enabled: boolean;
|
|
89
|
+
field?: string;
|
|
90
|
+
excludeTables?: string[];
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Initializes the soft delete adapter and underlying adapter.
|
|
94
|
+
*
|
|
95
|
+
* **RESPONSIBILITY:** Passes initialization to base adapter
|
|
96
|
+
* **BEHAVIOR:** No additional initialization needed for soft delete
|
|
97
|
+
*
|
|
98
|
+
* @returns Promise resolving to initialization result
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const result = await softDeleteAdapter.initialize();
|
|
103
|
+
* if (result.success) {
|
|
104
|
+
* console.log('Soft delete adapter initialized');
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
initialize(): Promise<DatabaseResult<void>>;
|
|
109
|
+
/**
|
|
110
|
+
* Establishes database connection through base adapter.
|
|
111
|
+
*
|
|
112
|
+
* **RESPONSIBILITY:** Delegates connection to underlying adapter
|
|
113
|
+
* **BEHAVIOR:** No additional connection logic needed
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* await softDeleteAdapter.connect();
|
|
118
|
+
* console.log('Connected with soft delete support');
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
connect(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Closes database connection through base adapter.
|
|
124
|
+
*
|
|
125
|
+
* **RESPONSIBILITY:** Delegates disconnection to underlying adapter
|
|
126
|
+
* **BEHAVIOR:** No additional cleanup needed for soft delete
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* await softDeleteAdapter.disconnect();
|
|
131
|
+
* console.log('Disconnected gracefully');
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
disconnect(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the underlying database client.
|
|
137
|
+
*
|
|
138
|
+
* **RESPONSIBILITY:** Provides access to raw database client
|
|
139
|
+
* **USE CASE:** For operations that bypass soft delete logic
|
|
140
|
+
*
|
|
141
|
+
* @returns Database client object
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const client = softDeleteAdapter.getClient();
|
|
146
|
+
* // Use for direct database operations if needed
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
getClient(): object;
|
|
150
|
+
/**
|
|
151
|
+
* Executes raw SQL query through base adapter.
|
|
152
|
+
*
|
|
153
|
+
* **RESPONSIBILITY:** Passes raw SQL to base adapter without modification
|
|
154
|
+
* **BEHAVIOR:** Does not apply soft delete filtering to raw SQL
|
|
155
|
+
* **NOTE:** Use findMany() for automatic soft delete filtering
|
|
156
|
+
*
|
|
157
|
+
* @param sql - SQL query string
|
|
158
|
+
* @param params - Query parameters
|
|
159
|
+
* @returns Query results
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Raw SQL bypasses soft delete filtering
|
|
164
|
+
* const allUsers = await adapter.query(
|
|
165
|
+
* 'SELECT * FROM users', // Includes soft-deleted records
|
|
166
|
+
* []
|
|
167
|
+
* );
|
|
168
|
+
*
|
|
169
|
+
* // Use findMany for automatic filtering
|
|
170
|
+
* const activeUsers = await adapter.findMany('users'); // Excludes soft-deleted
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
query<T>(sql: string, params?: T[]): Promise<T[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Registers a table schema with the base adapter.
|
|
176
|
+
*
|
|
177
|
+
* **RESPONSIBILITY:** Passes table registration to base adapter
|
|
178
|
+
* **BEHAVIOR:** No additional registration logic needed
|
|
179
|
+
*
|
|
180
|
+
* @param name - Table name
|
|
181
|
+
* @param table - Table schema
|
|
182
|
+
* @param idColumn - Primary key column
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* softDeleteAdapter.registerTable('users', userSchema, 'id');
|
|
187
|
+
* // Table now supports soft delete operations
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
registerTable<T, U>(name: string, table: T, idColumn?: U): void;
|
|
191
|
+
/**
|
|
192
|
+
* Finds a record by ID with automatic soft delete filtering.
|
|
193
|
+
*
|
|
194
|
+
* **RESPONSIBILITY:** Retrieves single record, excluding soft-deleted by default
|
|
195
|
+
* **FILTERING:** Automatically excludes records where deletedAt IS NOT NULL
|
|
196
|
+
* **OVERRIDE:** Can include soft-deleted records with operation config
|
|
197
|
+
*
|
|
198
|
+
* @param table - Table name
|
|
199
|
+
* @param id - Record ID
|
|
200
|
+
* @returns Found record or null
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // Excludes soft-deleted records by default
|
|
205
|
+
* const user = await adapter.findById('users', 'user-123');
|
|
206
|
+
* if (!user.value) {
|
|
207
|
+
* console.log('User not found or soft-deleted');
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* // Include soft-deleted records with config
|
|
211
|
+
* const userIncludingDeleted = await adapter.findById('users', 'user-123', {
|
|
212
|
+
* includeSoftDeleted: true
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
findById<T>(table: string, id: string): Promise<DatabaseResult<T | null>>;
|
|
217
|
+
findMany<T>(table: string, options?: QueryOptions): Promise<DatabaseResult<PaginatedResult<T>>>;
|
|
218
|
+
/**
|
|
219
|
+
* Creates a new record through base adapter.
|
|
220
|
+
*
|
|
221
|
+
* **RESPONSIBILITY:** Passes creation to base adapter without modification
|
|
222
|
+
* **BEHAVIOR:** New records have deletedAt = NULL by default
|
|
223
|
+
*
|
|
224
|
+
* @param table - Table name
|
|
225
|
+
* @param data - Record data
|
|
226
|
+
* @returns Created record
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const result = await adapter.create('users', {
|
|
231
|
+
* name: 'John Doe',
|
|
232
|
+
* email: 'john@example.com'
|
|
233
|
+
* // deletedAt will be NULL (not soft-deleted)
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* if (result.success) {
|
|
237
|
+
* console.log('User created:', result.value.id);
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
create<T>(table: string, data: T): Promise<DatabaseResult<T>>;
|
|
242
|
+
/**
|
|
243
|
+
* Updates an existing record through base adapter.
|
|
244
|
+
*
|
|
245
|
+
* **RESPONSIBILITY:** Passes update to base adapter without modification
|
|
246
|
+
* **BEHAVIOR:** Can update soft-deleted records (they remain soft-deleted)
|
|
247
|
+
* **NOTE:** Use restore() to undelete records
|
|
248
|
+
*
|
|
249
|
+
* @param table - Table name
|
|
250
|
+
* @param id - Record ID
|
|
251
|
+
* @param data - Partial record data
|
|
252
|
+
* @returns Updated record
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* // Update active record
|
|
257
|
+
* const result = await adapter.update('users', 'user-123', {
|
|
258
|
+
* name: 'Jane Doe'
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* // Can also update soft-deleted records
|
|
262
|
+
* const softDeletedUpdate = await adapter.update('users', 'deleted-user', {
|
|
263
|
+
* email: 'newemail@example.com'
|
|
264
|
+
* // Record remains soft-deleted after update
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
update<T>(table: string, id: string, data: Partial<T>): Promise<DatabaseResult<T>>;
|
|
269
|
+
delete(table: string, id: string): Promise<DatabaseResult<void>>;
|
|
270
|
+
/**
|
|
271
|
+
* Executes operations within a transaction.
|
|
272
|
+
*
|
|
273
|
+
* **RESPONSIBILITY:** Passes transaction to base adapter
|
|
274
|
+
* **BEHAVIOR:** Soft delete operations within transaction are atomic
|
|
275
|
+
* **ROLLBACK:** Failed transactions rollback soft delete operations
|
|
276
|
+
*
|
|
277
|
+
* @param callback - Transaction callback function
|
|
278
|
+
* @returns Transaction result
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const result = await adapter.transaction(async (trx) => {
|
|
283
|
+
* // Create user
|
|
284
|
+
* const user = await trx.create('users', { name: 'John' });
|
|
285
|
+
*
|
|
286
|
+
* // Soft delete old user (sets deletedAt)
|
|
287
|
+
* await trx.delete('users', 'old-user-id');
|
|
288
|
+
*
|
|
289
|
+
* return user;
|
|
290
|
+
* });
|
|
291
|
+
*
|
|
292
|
+
* // If transaction fails, both operations are rolled back
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
transaction<T>(callback: (trx: Transaction) => Promise<T>): Promise<DatabaseResult<T>>;
|
|
296
|
+
/**
|
|
297
|
+
* Checks if a record exists, excluding soft-deleted records.
|
|
298
|
+
*
|
|
299
|
+
* **RESPONSIBILITY:** Verifies record existence with soft delete filtering
|
|
300
|
+
* **BEHAVIOR:** Returns false for soft-deleted records by default
|
|
301
|
+
* **FILTERING:** Automatically excludes records where deletedAt IS NOT NULL
|
|
302
|
+
*
|
|
303
|
+
* @param table - Table name
|
|
304
|
+
* @param id - Record ID
|
|
305
|
+
* @returns True if record exists and is not soft-deleted
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* // Check if active user exists
|
|
310
|
+
* const userExists = await adapter.exists('users', 'user-123');
|
|
311
|
+
* if (userExists.value) {
|
|
312
|
+
* console.log('User exists and is active');
|
|
313
|
+
* } else {
|
|
314
|
+
* console.log('User not found or soft-deleted');
|
|
315
|
+
* }
|
|
316
|
+
*
|
|
317
|
+
* // Soft-deleted records return false
|
|
318
|
+
* await adapter.delete('users', 'user-123'); // Soft delete
|
|
319
|
+
* const stillExists = await adapter.exists('users', 'user-123'); // false
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
exists(table: string, id: string): Promise<DatabaseResult<boolean>>;
|
|
323
|
+
/**
|
|
324
|
+
* Counts records in a table, excluding soft-deleted records.
|
|
325
|
+
*
|
|
326
|
+
* **RESPONSIBILITY:** Counts records with automatic soft delete filtering
|
|
327
|
+
* **BEHAVIOR:** Excludes soft-deleted records from count by default
|
|
328
|
+
* **FILTERING:** Automatically adds deletedAt IS NULL filter
|
|
329
|
+
*
|
|
330
|
+
* @param table - Table name
|
|
331
|
+
* @param filter - Optional filter conditions
|
|
332
|
+
* @returns Count of non-soft-deleted records
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* // Count active users only
|
|
337
|
+
* const activeCount = await adapter.count('users');
|
|
338
|
+
* console.log('Active users:', activeCount.value);
|
|
339
|
+
*
|
|
340
|
+
* // Count with additional filter
|
|
341
|
+
* const premiumActiveUsers = await adapter.count('users', {
|
|
342
|
+
* field: 'plan',
|
|
343
|
+
* operator: 'eq',
|
|
344
|
+
* value: 'premium'
|
|
345
|
+
* });
|
|
346
|
+
* // Returns count of premium users that are NOT soft-deleted
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
count(table: string, filter?: Filter): Promise<DatabaseResult<number>>;
|
|
350
|
+
/**
|
|
351
|
+
* Performs health check through base adapter.
|
|
352
|
+
*
|
|
353
|
+
* **RESPONSIBILITY:** Delegates health check to underlying adapter
|
|
354
|
+
* **BEHAVIOR:** No additional health metrics for soft delete
|
|
355
|
+
*
|
|
356
|
+
* @returns Health status from base adapter
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const health = await adapter.healthCheck();
|
|
361
|
+
* if (health.success && health.value?.isHealthy) {
|
|
362
|
+
* console.log('Database healthy with soft delete support');
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
healthCheck(): Promise<DatabaseResult<DatabaseHealthStatus>>;
|
|
367
|
+
/**
|
|
368
|
+
* Restores a previously soft-deleted record by clearing the deletion timestamp
|
|
369
|
+
*
|
|
370
|
+
* Undeletes a record by setting the soft delete field (typically 'deletedAt') to null,
|
|
371
|
+
* making it visible in queries again. This operation is only available when soft delete
|
|
372
|
+
* is enabled in the configuration.
|
|
373
|
+
*
|
|
374
|
+
* **Restore Process:**
|
|
375
|
+
* 1. Validates that soft delete is enabled
|
|
376
|
+
* 2. Sets the deletion field to null via update operation
|
|
377
|
+
* 3. Logs the restoration for audit purposes
|
|
378
|
+
* 4. Returns success or failure result
|
|
379
|
+
*
|
|
380
|
+
* @param {string} table - Name of the table containing the record to restore
|
|
381
|
+
* @param {string} id - Primary key ID of the record to restore
|
|
382
|
+
* @returns {Promise<DatabaseResult<void>>} Promise resolving to success/failure result
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* // Restore a soft-deleted user
|
|
387
|
+
* const restoreResult = await softDeleteAdapter.restore('users', 'user-123');
|
|
388
|
+
* if (restoreResult.success) {
|
|
389
|
+
* console.log('User restored successfully');
|
|
390
|
+
* } else {
|
|
391
|
+
* console.error('Restore failed:', restoreResult.error.message);
|
|
392
|
+
* }
|
|
393
|
+
*
|
|
394
|
+
* // After restoration, the record will appear in queries again
|
|
395
|
+
* const user = await adapter.findById('users', 'user-123');
|
|
396
|
+
* // user will now be found (not null)
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @throws {DatabaseError} SOFT_DELETE_NOT_ENABLED - If soft delete is not enabled in configuration
|
|
400
|
+
* @throws {DatabaseError} SOFT_DELETE_RESTORE_FAILED - If the restore operation fails
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
restore(table: string, id: string): Promise<DatabaseResult<void>>;
|
|
404
|
+
/**
|
|
405
|
+
* Checks if a table is excluded from soft delete functionality.
|
|
406
|
+
*
|
|
407
|
+
* **RESPONSIBILITY:** Determines if table should use hard delete instead
|
|
408
|
+
* **CONFIGURATION:** Based on excludeTables array in config
|
|
409
|
+
* **USE CASE:** Some tables like audit logs need permanent deletion
|
|
410
|
+
*
|
|
411
|
+
* @private
|
|
412
|
+
* @param table - Name of the table to check
|
|
413
|
+
* @returns True if table is excluded from soft delete
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* // Configuration: { excludeTables: ['audit_logs', 'temp_data'] }
|
|
418
|
+
*
|
|
419
|
+
* this.isExcluded('users'); // false - uses soft delete
|
|
420
|
+
* this.isExcluded('audit_logs'); // true - uses hard delete
|
|
421
|
+
* this.isExcluded('t
|
|
422
|
+
private isExcluded(table: string): boolean {
|
|
423
|
+
return this.config.excludeTables?.includes(table) ?? false;
|
|
424
|
+
}emp_data'); // true - uses hard delete
|
|
425
|
+
* ```
|
|
426
|
+
*
|
|
427
|
+
*/
|
|
428
|
+
private isExcluded;
|
|
429
|
+
}
|
|
430
|
+
//# sourceMappingURL=SoftDeleteExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SoftDeleteExtension.d.ts","sourceRoot":"","sources":["../../src/extensions/SoftDeleteExtension.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Database Extension Adapters — Advanced Database Functionality
|
|
3
|
+
*
|
|
4
|
+
* Provides a collection of extension adapters that enhance core database operations
|
|
5
|
+
* with advanced features such as soft deletes, encryption, audit logging, caching,
|
|
6
|
+
* and read replica support.
|
|
7
|
+
*
|
|
8
|
+
* These extensions implement the **Decorator Pattern**, wrapping base adapters
|
|
9
|
+
* to transparently add behavior while maintaining full type safety and composability.
|
|
10
|
+
*
|
|
11
|
+
* ---
|
|
12
|
+
*
|
|
13
|
+
* **Extension Chain Architecture:**
|
|
14
|
+
* ```
|
|
15
|
+
* DatabaseService → Extension Chain → Base Adapter → Database
|
|
16
|
+
* ↓ ↓ ↓ ↓
|
|
17
|
+
* Operations AuditAdapter DrizzleAdapter PostgreSQL
|
|
18
|
+
* ↓ ↓
|
|
19
|
+
* SoftDeleteAdapter SQL Execution
|
|
20
|
+
* ↓
|
|
21
|
+
* EncryptionAdapter
|
|
22
|
+
* ↓
|
|
23
|
+
* CachingAdapter
|
|
24
|
+
* ↓
|
|
25
|
+
* ReadReplicaAdapter
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* **Available Extensions:**
|
|
31
|
+
* - **SoftDeleteAdapter** → Logical deletion with restore capabilities
|
|
32
|
+
* - **AuditAdapter** → Comprehensive audit logging with context tracking
|
|
33
|
+
* - **EncryptionAdapter** → Field-level encryption for sensitive data
|
|
34
|
+
* - **CachingAdapter** → Query result caching for high-performance reads
|
|
35
|
+
* - **ReadReplicaAdapter** → Read/write splitting and replica load balancing
|
|
36
|
+
*
|
|
37
|
+
* ---
|
|
38
|
+
*
|
|
39
|
+
* **Extension Benefits:**
|
|
40
|
+
* - **Composable** → Mix and match extensions as needed
|
|
41
|
+
* - **Transparent** → No changes required in business logic
|
|
42
|
+
* - **Configurable** → Fine-grained setup via unified configuration schema
|
|
43
|
+
* - **Type-Safe** → Full TypeScript support with strict type definitions
|
|
44
|
+
* - **Observable** → Integrates with monitoring and metrics systems
|
|
45
|
+
*
|
|
46
|
+
* ---
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Extensions are automatically configured via createDatabaseService
|
|
51
|
+
* const service = await createDatabaseService({
|
|
52
|
+
* adapter: 'drizzle',
|
|
53
|
+
* connectionString: process.env.DATABASE_URL,
|
|
54
|
+
*
|
|
55
|
+
* // Extension configurations
|
|
56
|
+
* softDelete: { enabled: true, field: 'deletedAt' },
|
|
57
|
+
* encryption: { enabled: true, key: process.env.ENCRYPTION_KEY },
|
|
58
|
+
* audit: { enabled: true, retentionDays: 90 },
|
|
59
|
+
* cache: { enabled: true, ttl: 300 },
|
|
60
|
+
* replica: { enabled: true, replicas: ['postgres://replica1', 'postgres://replica2'] }
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* // All operations automatically use configured extensions
|
|
64
|
+
* await service.create('users', userData); // → encrypted, audited
|
|
65
|
+
* await service.delete('users', '123'); // → soft deleted, audited
|
|
66
|
+
* const users = await service.findMany('users'); // → cached, routed to replica
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
/** Logical deletion with restore capabilities */
|
|
70
|
+
export { SoftDeleteAdapter } from "./SoftDeleteExtension";
|
|
71
|
+
/** Comprehensive audit logging with context tracking */
|
|
72
|
+
export { AuditAdapter } from "./AuditExtension";
|
|
73
|
+
/** Field-level encryption for sensitive data protection */
|
|
74
|
+
export { EncryptionAdapter } from "./EncryptionExtension";
|
|
75
|
+
/** Query result caching for improved performance */
|
|
76
|
+
export { CachingAdapter } from "./CachingAdapter";
|
|
77
|
+
/** Read/write splitting with replica load balancing and failover */
|
|
78
|
+
export { ReadReplicaAdapter } from "./ReadReplicaAdapter";
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,iDAAiD;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,wDAAwD;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,2DAA2D;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,oDAAoD;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,oEAAoE;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Adapter Factory for @plyaz/db package
|
|
3
|
+
*
|
|
4
|
+
* This module provides the AdapterFactory class responsible for creating database adapter instances
|
|
5
|
+
* based on configuration. Supports multiple database adapters including Drizzle ORM, Supabase,
|
|
6
|
+
* and raw SQL adapters.
|
|
7
|
+
*
|
|
8
|
+
* Part of the @plyaz/db package factory system that creates the complete adapter chain:
|
|
9
|
+
* AdapterFactory → Base Adapter → Extension Wrappers → Final Adapter Chain
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import type { DatabaseAdapterType, DatabaseConfig } from "@plyaz/types/db";
|
|
13
|
+
/**
|
|
14
|
+
* ADAPTER FACTORY - Database Adapter Creation
|
|
15
|
+
*
|
|
16
|
+
* Factory class responsible for creating database adapter instances based on configuration.
|
|
17
|
+
* This is the first step in the adapter chain creation process.
|
|
18
|
+
*
|
|
19
|
+
* **Factory Pattern Implementation:**
|
|
20
|
+
* - Takes adapter type and configuration as input
|
|
21
|
+
* - Returns appropriate DatabaseAdapterType implementation
|
|
22
|
+
* - Handles type safety and error cases
|
|
23
|
+
* - Supports all available database adapters
|
|
24
|
+
*
|
|
25
|
+
* **Supported Adapters:**
|
|
26
|
+
* - DrizzleAdapter: For Drizzle ORM integration
|
|
27
|
+
* - SupabaseAdapter: For Supabase database integration
|
|
28
|
+
* - SQLAdapter: For raw SQL database operations
|
|
29
|
+
*
|
|
30
|
+
* **Usage Flow:**
|
|
31
|
+
* createDatabaseService() → **AdapterFactory.create()** → Base Adapter → Extension Wrappers
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Create Drizzle adapter
|
|
36
|
+
* const drizzleAdapter = AdapterFactory.create(ADAPTERS.DRIZZLE, {
|
|
37
|
+
* adapter: ADAPTERS.DRIZZLE,
|
|
38
|
+
* connection: { host: 'localhost', port: 5432 },
|
|
39
|
+
* database: 'myapp'
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Create Supabase adapter
|
|
43
|
+
* const supabaseAdapter = AdapterFactory.create(ADAPTERS.SUPABASE, {
|
|
44
|
+
* adapter: ADAPTERS.SUPABASE,
|
|
45
|
+
* url: 'https://project.supabase.co',
|
|
46
|
+
* key: 'your-anon-key'
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export declare class AdapterFactory {
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new database adapter instance based on the configuration
|
|
54
|
+
*
|
|
55
|
+
* This is the core factory method that instantiates the appropriate database adapter
|
|
56
|
+
* based on the provided type and configuration. Uses TypeScript generics to ensure
|
|
57
|
+
* type safety between adapter type and configuration.
|
|
58
|
+
*
|
|
59
|
+
* **Creation Process:**
|
|
60
|
+
* 1. Validates input parameters (type and config)
|
|
61
|
+
* 2. Uses switch statement to match adapter type
|
|
62
|
+
* 3. Instantiates appropriate adapter class with type-safe config
|
|
63
|
+
* 4. Returns DatabaseAdapterType interface implementation
|
|
64
|
+
*
|
|
65
|
+
* **Type Safety:**
|
|
66
|
+
* - Generic T extends DatabaseConfig ensures config matches adapter type
|
|
67
|
+
* - Type assertions (as DrizzleAdapterConfig) provide compile-time safety
|
|
68
|
+
* - Runtime validation prevents invalid configurations
|
|
69
|
+
*
|
|
70
|
+
* @template T - Database configuration type that extends DatabaseConfig
|
|
71
|
+
* @param {T["adapter"]} type - Adapter type from ADAPTERS enum (drizzle, supabase, sql)
|
|
72
|
+
* @param {T} config - Database configuration object matching the adapter type
|
|
73
|
+
* @returns {DatabaseAdapterType} The appropriate adapter implementation
|
|
74
|
+
*
|
|
75
|
+
* @throws {Error} If adapter type is not provided
|
|
76
|
+
* @throws {Error} If adapter configuration is not provided
|
|
77
|
+
* @throws {Error} If unsupported adapter type is specified
|
|
78
|
+
* @throws {Error} If adapter instantiation fails
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Create Drizzle adapter with PostgreSQL
|
|
83
|
+
* const drizzleAdapter = AdapterFactory.create(ADAPTERS.DRIZZLE, {
|
|
84
|
+
* adapter: ADAPTERS.DRIZZLE,
|
|
85
|
+
* connection: {
|
|
86
|
+
* host: 'localhost',
|
|
87
|
+
* port: 5432,
|
|
88
|
+
* database: 'myapp',
|
|
89
|
+
* user: 'postgres',
|
|
90
|
+
* password: 'password'
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Create Supabase adapter
|
|
95
|
+
* const supabaseAdapter = AdapterFactory.create(ADAPTERS.SUPABASE, {
|
|
96
|
+
* adapter: ADAPTERS.SUPABASE,
|
|
97
|
+
* url: 'https://xyzcompany.supabase.co',
|
|
98
|
+
* key: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* // Create SQL adapter for custom database
|
|
102
|
+
* const sqlAdapter = AdapterFactory.create(ADAPTERS.SQL, {
|
|
103
|
+
* adapter: ADAPTERS.SQL,
|
|
104
|
+
* connectionString: 'postgresql://user:pass@localhost:5432/db'
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
static create<T extends DatabaseConfig>(type: T["adapter"], config: T): DatabaseAdapterType;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=AdapterFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdapterFactory.d.ts","sourceRoot":"","sources":["../../src/factory/AdapterFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAKzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,cAAc;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,cAAc,EACpC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,EAClB,MAAM,EAAE,CAAC,GACR,mBAAmB;CAiEvB"}
|