@framers/sql-storage-adapter 0.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -0
  3. package/dist/adapters/baseStorageAdapter.d.ts +204 -0
  4. package/dist/adapters/baseStorageAdapter.d.ts.map +1 -0
  5. package/dist/adapters/baseStorageAdapter.js +364 -0
  6. package/dist/adapters/baseStorageAdapter.js.map +1 -0
  7. package/dist/adapters/betterSqliteAdapter.d.ts +64 -0
  8. package/dist/adapters/betterSqliteAdapter.d.ts.map +1 -0
  9. package/dist/adapters/betterSqliteAdapter.js +206 -0
  10. package/dist/adapters/betterSqliteAdapter.js.map +1 -0
  11. package/dist/adapters/capacitorSqliteAdapter.d.ts +33 -0
  12. package/dist/adapters/capacitorSqliteAdapter.d.ts.map +1 -0
  13. package/dist/adapters/capacitorSqliteAdapter.js +95 -0
  14. package/dist/adapters/capacitorSqliteAdapter.js.map +1 -0
  15. package/dist/adapters/postgresAdapter.d.ts +180 -0
  16. package/dist/adapters/postgresAdapter.d.ts.map +1 -0
  17. package/dist/adapters/postgresAdapter.js +271 -0
  18. package/dist/adapters/postgresAdapter.js.map +1 -0
  19. package/dist/adapters/sqlJsAdapter.d.ts +28 -0
  20. package/dist/adapters/sqlJsAdapter.d.ts.map +1 -0
  21. package/dist/adapters/sqlJsAdapter.js +136 -0
  22. package/dist/adapters/sqlJsAdapter.js.map +1 -0
  23. package/dist/adapters/supabase.d.ts +58 -0
  24. package/dist/adapters/supabase.d.ts.map +1 -0
  25. package/dist/adapters/supabase.js +385 -0
  26. package/dist/adapters/supabase.js.map +1 -0
  27. package/dist/database.d.ts +124 -0
  28. package/dist/database.d.ts.map +1 -0
  29. package/dist/database.js +136 -0
  30. package/dist/database.js.map +1 -0
  31. package/dist/index.d.ts +17 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +25 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/resolver.d.ts +24 -0
  36. package/dist/resolver.d.ts.map +1 -0
  37. package/dist/resolver.js +91 -0
  38. package/dist/resolver.js.map +1 -0
  39. package/dist/types/context.d.ts +221 -0
  40. package/dist/types/context.d.ts.map +1 -0
  41. package/dist/types/context.js +9 -0
  42. package/dist/types/context.js.map +1 -0
  43. package/dist/types/events.d.ts +225 -0
  44. package/dist/types/events.d.ts.map +1 -0
  45. package/dist/types/events.js +8 -0
  46. package/dist/types/events.js.map +1 -0
  47. package/dist/types/extensions.d.ts +73 -0
  48. package/dist/types/extensions.d.ts.map +1 -0
  49. package/dist/types/extensions.js +7 -0
  50. package/dist/types/extensions.js.map +1 -0
  51. package/dist/types/limitations.d.ts +46 -0
  52. package/dist/types/limitations.d.ts.map +1 -0
  53. package/dist/types/limitations.js +154 -0
  54. package/dist/types/limitations.js.map +1 -0
  55. package/dist/types.d.ts +235 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/types.js +18 -0
  58. package/dist/types.js.map +1 -0
  59. package/dist/utils/cloudBackup.d.ts +219 -0
  60. package/dist/utils/cloudBackup.d.ts.map +1 -0
  61. package/dist/utils/cloudBackup.js +289 -0
  62. package/dist/utils/cloudBackup.js.map +1 -0
  63. package/dist/utils/dataExport.d.ts +77 -0
  64. package/dist/utils/dataExport.d.ts.map +1 -0
  65. package/dist/utils/dataExport.js +212 -0
  66. package/dist/utils/dataExport.js.map +1 -0
  67. package/dist/utils/dataImport.d.ts +54 -0
  68. package/dist/utils/dataImport.d.ts.map +1 -0
  69. package/dist/utils/dataImport.js +324 -0
  70. package/dist/utils/dataImport.js.map +1 -0
  71. package/dist/utils/migration.d.ts +89 -0
  72. package/dist/utils/migration.d.ts.map +1 -0
  73. package/dist/utils/migration.js +184 -0
  74. package/dist/utils/migration.js.map +1 -0
  75. package/dist/utils/parameterUtils.d.ts +9 -0
  76. package/dist/utils/parameterUtils.d.ts.map +1 -0
  77. package/dist/utils/parameterUtils.js +17 -0
  78. package/dist/utils/parameterUtils.js.map +1 -0
  79. package/dist/utils/syncManager.d.ts +342 -0
  80. package/dist/utils/syncManager.d.ts.map +1 -0
  81. package/dist/utils/syncManager.js +533 -0
  82. package/dist/utils/syncManager.js.map +1 -0
  83. package/package.json +108 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Runtime context and introspection types for storage adapters.
3
+ *
4
+ * These types enable runtime inspection of adapter capabilities,
5
+ * connection state, and performance characteristics without requiring
6
+ * developers to manually check capability flags.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Event system types for adapter lifecycle and query monitoring.
3
+ *
4
+ * These types enable applications to subscribe to adapter events
5
+ * for logging, monitoring, debugging, and analytics purposes.
6
+ */
7
+ import type { StorageParameters } from '../types';
8
+ import type { AdapterContext } from './context';
9
+ /**
10
+ * Event emitted when a connection is opened.
11
+ */
12
+ export interface ConnectionOpenedEvent {
13
+ type: 'connection:opened';
14
+ context: AdapterContext;
15
+ timestamp: Date;
16
+ }
17
+ /**
18
+ * Event emitted when a connection is closed.
19
+ */
20
+ export interface ConnectionClosedEvent {
21
+ type: 'connection:closed';
22
+ context: AdapterContext;
23
+ timestamp: Date;
24
+ }
25
+ /**
26
+ * Event emitted when a connection error occurs.
27
+ */
28
+ export interface ConnectionErrorEvent {
29
+ type: 'connection:error';
30
+ error: Error;
31
+ context: AdapterContext;
32
+ timestamp: Date;
33
+ }
34
+ /**
35
+ * Event emitted when a query starts execution.
36
+ */
37
+ export interface QueryStartEvent {
38
+ type: 'query:start';
39
+ statement: string;
40
+ parameters?: StorageParameters;
41
+ timestamp: Date;
42
+ queryId?: string;
43
+ }
44
+ /**
45
+ * Event emitted when a query completes successfully.
46
+ */
47
+ export interface QueryCompleteEvent {
48
+ type: 'query:complete';
49
+ statement: string;
50
+ duration: number;
51
+ rows?: number;
52
+ timestamp: Date;
53
+ queryId?: string;
54
+ }
55
+ /**
56
+ * Event emitted when a query fails.
57
+ */
58
+ export interface QueryErrorEvent {
59
+ type: 'query:error';
60
+ statement: string;
61
+ error: Error;
62
+ duration: number;
63
+ timestamp: Date;
64
+ queryId?: string;
65
+ }
66
+ /**
67
+ * Event emitted when a transaction starts.
68
+ */
69
+ export interface TransactionStartEvent {
70
+ type: 'transaction:start';
71
+ id: string;
72
+ timestamp: Date;
73
+ }
74
+ /**
75
+ * Event emitted when a transaction commits successfully.
76
+ */
77
+ export interface TransactionCommitEvent {
78
+ type: 'transaction:commit';
79
+ id: string;
80
+ duration: number;
81
+ timestamp: Date;
82
+ }
83
+ /**
84
+ * Event emitted when a transaction is rolled back.
85
+ */
86
+ export interface TransactionRollbackEvent {
87
+ type: 'transaction:rollback';
88
+ id: string;
89
+ error?: Error;
90
+ timestamp: Date;
91
+ }
92
+ /**
93
+ * Event emitted when a slow query is detected.
94
+ */
95
+ export interface PerformanceSlowQueryEvent {
96
+ type: 'performance:slow-query';
97
+ statement: string;
98
+ duration: number;
99
+ threshold: number;
100
+ timestamp: Date;
101
+ }
102
+ /**
103
+ * Event emitted when a cache hit occurs.
104
+ */
105
+ export interface CacheHitEvent {
106
+ type: 'cache:hit';
107
+ key: string;
108
+ statement: string;
109
+ timestamp: Date;
110
+ }
111
+ /**
112
+ * Event emitted when a cache miss occurs.
113
+ */
114
+ export interface CacheMissEvent {
115
+ type: 'cache:miss';
116
+ key: string;
117
+ statement: string;
118
+ timestamp: Date;
119
+ }
120
+ /**
121
+ * Event emitted when the cache is cleared.
122
+ */
123
+ export interface CacheClearEvent {
124
+ type: 'cache:clear';
125
+ entriesCleared: number;
126
+ timestamp: Date;
127
+ }
128
+ /**
129
+ * Union of all possible adapter events.
130
+ */
131
+ export type AdapterEvent = ConnectionOpenedEvent | ConnectionClosedEvent | ConnectionErrorEvent | QueryStartEvent | QueryCompleteEvent | QueryErrorEvent | TransactionStartEvent | TransactionCommitEvent | TransactionRollbackEvent | PerformanceSlowQueryEvent | CacheHitEvent | CacheMissEvent | CacheClearEvent;
132
+ /**
133
+ * Extract event type from AdapterEvent discriminated union.
134
+ */
135
+ export type AdapterEventType = AdapterEvent['type'];
136
+ /**
137
+ * Listener function for adapter events.
138
+ */
139
+ export type AdapterEventListener<T extends AdapterEvent = AdapterEvent> = (event: T) => void;
140
+ /**
141
+ * Unsubscribe function returned by event listeners.
142
+ */
143
+ export type UnsubscribeFn = () => void;
144
+ /**
145
+ * Event emitter interface for storage adapters.
146
+ *
147
+ * Provides a simple pub/sub mechanism for monitoring adapter
148
+ * lifecycle and query execution.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * // Subscribe to all query errors
153
+ * const unsubscribe = events.on('query:error', (event) => {
154
+ * console.error('Query failed:', event.statement, event.error);
155
+ * });
156
+ *
157
+ * // Later, unsubscribe
158
+ * unsubscribe();
159
+ *
160
+ * // Subscribe to slow queries
161
+ * events.on('performance:slow-query', (event) => {
162
+ * if (event.duration > 5000) {
163
+ * analytics.track('very_slow_query', {
164
+ * statement: event.statement,
165
+ * duration: event.duration
166
+ * });
167
+ * }
168
+ * });
169
+ * ```
170
+ */
171
+ export interface AdapterEventEmitter {
172
+ /**
173
+ * Subscribe to an event type.
174
+ *
175
+ * @param eventType - The type of event to listen for
176
+ * @param listener - Callback function to invoke when event occurs
177
+ * @returns Unsubscribe function
178
+ */
179
+ on<T extends AdapterEventType>(eventType: T, listener: AdapterEventListener<Extract<AdapterEvent, {
180
+ type: T;
181
+ }>>): UnsubscribeFn;
182
+ /**
183
+ * Subscribe to an event type once (auto-unsubscribes after first call).
184
+ *
185
+ * @param eventType - The type of event to listen for
186
+ * @param listener - Callback function to invoke when event occurs
187
+ * @returns Unsubscribe function
188
+ */
189
+ once<T extends AdapterEventType>(eventType: T, listener: AdapterEventListener<Extract<AdapterEvent, {
190
+ type: T;
191
+ }>>): UnsubscribeFn;
192
+ /**
193
+ * Emit an event to all subscribers.
194
+ *
195
+ * @param event - The event to emit
196
+ */
197
+ emit(event: AdapterEvent): void;
198
+ /**
199
+ * Remove all event listeners.
200
+ */
201
+ removeAllListeners(): void;
202
+ /**
203
+ * Remove all listeners for a specific event type.
204
+ *
205
+ * @param eventType - The event type to clear listeners for
206
+ */
207
+ removeListeners(eventType: AdapterEventType): void;
208
+ /**
209
+ * Get the number of listeners for an event type.
210
+ *
211
+ * @param eventType - The event type to count listeners for
212
+ * @returns Number of active listeners
213
+ */
214
+ listenerCount(eventType: AdapterEventType): number;
215
+ }
216
+ /**
217
+ * Helper type for creating type-safe event emitter implementations.
218
+ */
219
+ export interface EventEmitterOptions {
220
+ /** Maximum number of listeners before warning (default: 10) */
221
+ maxListeners?: number;
222
+ /** Whether to log warnings for too many listeners */
223
+ warnOnMaxListeners?: boolean;
224
+ }
225
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AAC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,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,GACjE,aAAa,CAAC;IAEjB;;;;;;OAMG;IACH,IAAI,CAAC,CAAC,SAAS,gBAAgB,EAC7B,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,GACjE,aAAa,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;;;OAIG;IACH,eAAe,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAEnD;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Event system types for adapter lifecycle and query monitoring.
3
+ *
4
+ * These types enable applications to subscribe to adapter events
5
+ * for logging, monitoring, debugging, and analytics purposes.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Extended types for advanced adapter features.
3
+ * These types are used by adapters that provide additional functionality
4
+ * beyond the core StorageAdapter interface.
5
+ */
6
+ import type { BatchOperation as CoreBatchOperation } from '../types';
7
+ /**
8
+ * Performance metrics for monitoring adapter usage.
9
+ */
10
+ export interface PerformanceMetrics {
11
+ totalQueries: number;
12
+ totalDuration: number;
13
+ averageDuration: number;
14
+ cacheHits?: number;
15
+ cacheMisses?: number;
16
+ slowQueries?: Array<{
17
+ query: string;
18
+ duration: number;
19
+ timestamp: Date;
20
+ }>;
21
+ }
22
+ /**
23
+ * Options for streaming large result sets.
24
+ */
25
+ export interface StreamOptions {
26
+ batchSize?: number;
27
+ highWaterMark?: number;
28
+ }
29
+ /**
30
+ * Database migration definition.
31
+ */
32
+ export interface Migration {
33
+ id: string;
34
+ version: number;
35
+ up: string;
36
+ down?: string;
37
+ description?: string;
38
+ appliedAt?: Date;
39
+ }
40
+ /**
41
+ * Extended batch operation with additional metadata.
42
+ * Used by adapters that support richer batch operation semantics.
43
+ */
44
+ export interface ExtendedBatchOperation extends CoreBatchOperation {
45
+ type?: 'insert' | 'update' | 'delete';
46
+ table?: string;
47
+ values?: Record<string, unknown> | Array<Record<string, unknown>>;
48
+ where?: Record<string, unknown>;
49
+ }
50
+ /**
51
+ * Extended storage adapter interface for advanced features.
52
+ */
53
+ export interface StorageAdapterExtensions {
54
+ /**
55
+ * Apply database migrations.
56
+ */
57
+ migrate?(migrations: Migration[]): Promise<void>;
58
+ /**
59
+ * Get migration status.
60
+ */
61
+ getMigrationStatus?(): Promise<Migration[]>;
62
+ /**
63
+ * Get performance metrics.
64
+ */
65
+ getMetrics?(): PerformanceMetrics;
66
+ /**
67
+ * Stream large result sets.
68
+ */
69
+ stream?<T>(statement: string, parameters?: unknown, options?: StreamOptions): AsyncIterableIterator<T>;
70
+ }
71
+ export type { BatchOperation } from '../types';
72
+ export type { BatchResult } from '../types';
73
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/types/extensions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,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;;OAEG;IACH,MAAM,CAAC,CAAC,CAAC,EACP,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,aAAa,GACtB,qBAAqB,CAAC,CAAC,CAAC,CAAC;CAC7B;AAGD,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extended types for advanced adapter features.
3
+ * These types are used by adapters that provide additional functionality
4
+ * beyond the core StorageAdapter interface.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/types/extensions.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Adapter-specific limitation definitions.
3
+ *
4
+ * This module provides concrete limitation specifications for each
5
+ * supported database adapter, enabling runtime introspection and
6
+ * automatic constraint enforcement.
7
+ */
8
+ import type { AdapterLimitations } from './context';
9
+ /**
10
+ * Limitations for better-sqlite3 adapter.
11
+ */
12
+ export declare const BETTER_SQLITE3_LIMITATIONS: AdapterLimitations;
13
+ /**
14
+ * Limitations for SQL.js adapter (WebAssembly SQLite).
15
+ */
16
+ export declare const SQLJS_LIMITATIONS: AdapterLimitations;
17
+ /**
18
+ * Limitations for Capacitor SQLite adapter (mobile).
19
+ */
20
+ export declare const CAPACITOR_SQLITE_LIMITATIONS: AdapterLimitations;
21
+ /**
22
+ * Limitations for PostgreSQL adapter.
23
+ */
24
+ export declare const POSTGRES_LIMITATIONS: AdapterLimitations;
25
+ /**
26
+ * Limitations for Supabase adapter (PostgreSQL with extensions).
27
+ */
28
+ export declare const SUPABASE_LIMITATIONS: AdapterLimitations;
29
+ /**
30
+ * Map adapter kinds to their limitation definitions.
31
+ */
32
+ export declare const ADAPTER_LIMITATIONS_MAP: {
33
+ readonly 'better-sqlite3': AdapterLimitations;
34
+ readonly sqljs: AdapterLimitations;
35
+ readonly capacitor: AdapterLimitations;
36
+ readonly postgres: AdapterLimitations;
37
+ readonly supabase: AdapterLimitations;
38
+ };
39
+ /**
40
+ * Get limitations for a specific adapter kind.
41
+ *
42
+ * @param kind - Adapter kind
43
+ * @returns Adapter limitations
44
+ */
45
+ export declare function getLimitationsForAdapter(kind: keyof typeof ADAPTER_LIMITATIONS_MAP): AdapterLimitations;
46
+ //# sourceMappingURL=limitations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitations.d.ts","sourceRoot":"","sources":["../../src/types/limitations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,WAAW,CAAC;AAqBnB;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,kBAmBxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAqB/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,kBAqB1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBA4BlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBA4BlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;CAM1B,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,OAAO,uBAAuB,GACzC,kBAAkB,CAEpB"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Adapter-specific limitation definitions.
3
+ *
4
+ * This module provides concrete limitation specifications for each
5
+ * supported database adapter, enabling runtime introspection and
6
+ * automatic constraint enforcement.
7
+ */
8
+ /**
9
+ * Create performance characteristics object.
10
+ */
11
+ function createPerformanceCharacteristics(concurrency, persistence, transactionIsolation, usesConnectionPool, asyncExecution) {
12
+ return {
13
+ concurrency,
14
+ persistence,
15
+ transactionIsolation,
16
+ usesConnectionPool,
17
+ asyncExecution
18
+ };
19
+ }
20
+ /**
21
+ * Limitations for better-sqlite3 adapter.
22
+ */
23
+ export const BETTER_SQLITE3_LIMITATIONS = {
24
+ maxConnections: 1, // Single connection (SQLite limitation)
25
+ maxStatementLength: 1000000, // 1MB
26
+ maxBatchSize: undefined, // No hard limit, but memory constrained
27
+ maxParameterSize: undefined, // Limited by available memory
28
+ supportedDataTypes: ['INTEGER', 'REAL', 'TEXT', 'BLOB', 'NULL'],
29
+ unsupportedFeatures: ['streaming', 'concurrent', 'json', 'arrays'],
30
+ performanceCharacteristics: createPerformanceCharacteristics('single', 'file', ['SERIALIZABLE'], // SQLite only supports serializable
31
+ false, // No connection pooling
32
+ false // Synchronous by default
33
+ ),
34
+ constraints: {
35
+ supportsWAL: true,
36
+ supportsInMemory: true,
37
+ requiresFilePath: false // Can use :memory:
38
+ }
39
+ };
40
+ /**
41
+ * Limitations for SQL.js adapter (WebAssembly SQLite).
42
+ */
43
+ export const SQLJS_LIMITATIONS = {
44
+ maxConnections: 1, // Single connection
45
+ maxStatementLength: 1000000, // 1MB
46
+ maxBatchSize: undefined,
47
+ maxParameterSize: undefined,
48
+ supportedDataTypes: ['INTEGER', 'REAL', 'TEXT', 'BLOB', 'NULL'],
49
+ unsupportedFeatures: ['streaming', 'concurrent', 'json', 'arrays', 'wal', 'locks'],
50
+ performanceCharacteristics: createPerformanceCharacteristics('single', 'memory', // Typically in-memory or manual file persistence
51
+ ['SERIALIZABLE'], false, true // Async wrapper over sync WASM
52
+ ),
53
+ constraints: {
54
+ supportsWAL: false,
55
+ supportsInMemory: true,
56
+ requiresFilePath: false,
57
+ requiresWASM: true,
58
+ browserCompatible: true
59
+ }
60
+ };
61
+ /**
62
+ * Limitations for Capacitor SQLite adapter (mobile).
63
+ */
64
+ export const CAPACITOR_SQLITE_LIMITATIONS = {
65
+ maxConnections: 1, // Mobile SQLite single connection
66
+ maxStatementLength: 1000000,
67
+ maxBatchSize: undefined,
68
+ maxParameterSize: undefined,
69
+ supportedDataTypes: ['INTEGER', 'REAL', 'TEXT', 'BLOB', 'NULL'],
70
+ unsupportedFeatures: ['streaming', 'concurrent', 'json', 'arrays'],
71
+ performanceCharacteristics: createPerformanceCharacteristics('single', 'file', ['SERIALIZABLE'], false, true // Async through Capacitor bridge
72
+ ),
73
+ constraints: {
74
+ supportsWAL: true,
75
+ supportsInMemory: false, // Mobile requires file persistence
76
+ requiresFilePath: true,
77
+ requiresCapacitor: true,
78
+ mobileOnly: true
79
+ }
80
+ };
81
+ /**
82
+ * Limitations for PostgreSQL adapter.
83
+ */
84
+ export const POSTGRES_LIMITATIONS = {
85
+ maxConnections: 100, // Default pool size (configurable)
86
+ maxStatementLength: 1073741824, // 1GB theoretical limit
87
+ maxBatchSize: 1000, // Recommended batch size
88
+ maxParameterSize: 1073741824, // 1GB for BYTEA/TEXT
89
+ supportedDataTypes: [
90
+ 'INTEGER', 'BIGINT', 'SMALLINT', 'SERIAL', 'BIGSERIAL',
91
+ 'REAL', 'DOUBLE PRECISION', 'NUMERIC', 'DECIMAL',
92
+ 'TEXT', 'VARCHAR', 'CHAR', 'BYTEA',
93
+ 'BOOLEAN', 'DATE', 'TIME', 'TIMESTAMP', 'TIMESTAMPTZ',
94
+ 'JSON', 'JSONB', 'UUID', 'ARRAY', 'HSTORE', 'XML'
95
+ ],
96
+ unsupportedFeatures: ['wal'], // WAL is PostgreSQL-specific, not exposed as capability
97
+ performanceCharacteristics: createPerformanceCharacteristics('pooled', 'network', ['READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'], true, // Connection pooling
98
+ true // Fully async
99
+ ),
100
+ constraints: {
101
+ supportsWAL: false, // Not relevant for client connections
102
+ supportsInMemory: false,
103
+ requiresFilePath: false,
104
+ requiresNetwork: true,
105
+ supportsReplication: true,
106
+ supportsPartitioning: true
107
+ }
108
+ };
109
+ /**
110
+ * Limitations for Supabase adapter (PostgreSQL with extensions).
111
+ */
112
+ export const SUPABASE_LIMITATIONS = {
113
+ maxConnections: 15, // Supabase free tier default
114
+ maxStatementLength: 1073741824,
115
+ maxBatchSize: 1000,
116
+ maxParameterSize: 1073741824,
117
+ supportedDataTypes: [
118
+ ...POSTGRES_LIMITATIONS.supportedDataTypes,
119
+ 'VECTOR' // pgvector extension
120
+ ],
121
+ unsupportedFeatures: [],
122
+ performanceCharacteristics: createPerformanceCharacteristics('pooled', 'network', ['READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'], true, true),
123
+ constraints: {
124
+ supportsWAL: false,
125
+ supportsInMemory: false,
126
+ requiresFilePath: false,
127
+ requiresNetwork: true,
128
+ supportsReplication: true,
129
+ supportsPartitioning: true,
130
+ supportsRowLevelSecurity: true,
131
+ supportsRealtimeSubscriptions: true, // Supabase-specific
132
+ managedService: true
133
+ }
134
+ };
135
+ /**
136
+ * Map adapter kinds to their limitation definitions.
137
+ */
138
+ export const ADAPTER_LIMITATIONS_MAP = {
139
+ 'better-sqlite3': BETTER_SQLITE3_LIMITATIONS,
140
+ 'sqljs': SQLJS_LIMITATIONS,
141
+ 'capacitor': CAPACITOR_SQLITE_LIMITATIONS,
142
+ 'postgres': POSTGRES_LIMITATIONS,
143
+ 'supabase': SUPABASE_LIMITATIONS
144
+ };
145
+ /**
146
+ * Get limitations for a specific adapter kind.
147
+ *
148
+ * @param kind - Adapter kind
149
+ * @returns Adapter limitations
150
+ */
151
+ export function getLimitationsForAdapter(kind) {
152
+ return ADAPTER_LIMITATIONS_MAP[kind];
153
+ }
154
+ //# sourceMappingURL=limitations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitations.js","sourceRoot":"","sources":["../../src/types/limitations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH;;GAEG;AACH,SAAS,gCAAgC,CACvC,WAA6B,EAC7B,WAA6B,EAC7B,oBAA8B,EAC9B,kBAA2B,EAC3B,cAAuB;IAEvB,OAAO;QACL,WAAW;QACX,WAAW;QACX,oBAAoB;Q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