@framers/sql-storage-adapter 0.7.2 → 0.7.4
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 +41 -0
- package/dist/adapters/electron/preload.cjs +289 -0
- package/dist/adapters/electron/renderer.d.ts +9 -0
- package/dist/adapters/electron/renderer.d.ts.map +1 -0
- package/dist/adapters/electron/renderer.js +8 -0
- package/dist/adapters/electron/renderer.js.map +1 -0
- package/dist/cjs/adapters/__tests__/indexedDbAdapter.spec.d.ts +2 -0
- package/dist/cjs/adapters/__tests__/indexedDbAdapter.spec.js +133 -0
- package/dist/cjs/adapters/baseStorageAdapter.d.ts +368 -0
- package/dist/cjs/adapters/baseStorageAdapter.js +744 -0
- package/dist/cjs/adapters/betterSqliteAdapter.d.ts +124 -0
- package/dist/cjs/adapters/betterSqliteAdapter.js +334 -0
- package/dist/cjs/adapters/capacitorSqliteAdapter.d.ts +83 -0
- package/dist/cjs/adapters/capacitorSqliteAdapter.js +250 -0
- package/dist/cjs/adapters/electron/electronMainAdapter.d.ts +251 -0
- package/dist/cjs/adapters/electron/electronMainAdapter.js +392 -0
- package/dist/cjs/adapters/electron/electronRendererAdapter.d.ts +177 -0
- package/dist/cjs/adapters/electron/electronRendererAdapter.js +283 -0
- package/dist/cjs/adapters/electron/index.d.ts +74 -0
- package/dist/cjs/adapters/electron/index.js +86 -0
- package/dist/cjs/adapters/electron/ipc/channels.d.ts +196 -0
- package/dist/cjs/adapters/electron/ipc/channels.js +127 -0
- package/dist/cjs/adapters/electron/ipc/index.d.ts +11 -0
- package/dist/cjs/adapters/electron/ipc/index.js +38 -0
- package/dist/cjs/adapters/electron/ipc/protocol.d.ts +78 -0
- package/dist/cjs/adapters/electron/ipc/protocol.js +341 -0
- package/dist/cjs/adapters/electron/ipc/types.d.ts +248 -0
- package/dist/cjs/adapters/electron/ipc/types.js +15 -0
- package/dist/cjs/adapters/electron/migration/autoMigrator.d.ts +184 -0
- package/dist/cjs/adapters/electron/migration/autoMigrator.js +441 -0
- package/dist/cjs/adapters/electron/migration/index.d.ts +9 -0
- package/dist/cjs/adapters/electron/migration/index.js +29 -0
- package/dist/cjs/adapters/electron/preload.d.ts +126 -0
- package/dist/cjs/adapters/electron/preload.js +233 -0
- package/dist/cjs/adapters/electron/recovery/corruptionDetector.d.ts +214 -0
- package/dist/cjs/adapters/electron/recovery/corruptionDetector.js +359 -0
- package/dist/cjs/adapters/electron/recovery/index.d.ts +11 -0
- package/dist/cjs/adapters/electron/recovery/index.js +34 -0
- package/dist/cjs/adapters/electron/recovery/walCheckpoint.d.ts +186 -0
- package/dist/cjs/adapters/electron/recovery/walCheckpoint.js +263 -0
- package/dist/cjs/adapters/electron/renderer.d.ts +9 -0
- package/dist/cjs/adapters/electron/renderer.js +33 -0
- package/dist/cjs/adapters/electron/window/index.d.ts +9 -0
- package/dist/cjs/adapters/electron/window/index.js +29 -0
- package/dist/cjs/adapters/electron/window/windowManager.d.ts +190 -0
- package/dist/cjs/adapters/electron/window/windowManager.js +321 -0
- package/dist/cjs/adapters/indexedDbAdapter.d.ts +490 -0
- package/dist/cjs/adapters/indexedDbAdapter.js +993 -0
- package/dist/cjs/adapters/postgresAdapter.d.ts +424 -0
- package/dist/cjs/adapters/postgresAdapter.js +889 -0
- package/dist/cjs/adapters/sqlJsAdapter.d.ts +64 -0
- package/dist/cjs/adapters/sqlJsAdapter.js +268 -0
- package/dist/cjs/adapters/supabase.d.ts +58 -0
- package/dist/cjs/adapters/supabase.js +401 -0
- package/dist/cjs/codecs/BrowserBlobCodec.d.ts +14 -0
- package/dist/cjs/codecs/BrowserBlobCodec.js +57 -0
- package/dist/cjs/codecs/NodeBlobCodec.d.ts +14 -0
- package/dist/cjs/codecs/NodeBlobCodec.js +59 -0
- package/dist/cjs/core/contracts/blobCodec.d.ts +15 -0
- package/dist/cjs/core/contracts/blobCodec.js +15 -0
- package/dist/cjs/core/contracts/context.d.ts +221 -0
- package/dist/cjs/core/contracts/context.js +15 -0
- package/dist/cjs/core/contracts/dialect.d.ts +154 -0
- package/dist/cjs/core/contracts/dialect.js +15 -0
- package/dist/cjs/core/contracts/events.d.ts +225 -0
- package/dist/cjs/core/contracts/events.js +15 -0
- package/dist/cjs/core/contracts/exporter.d.ts +13 -0
- package/dist/cjs/core/contracts/exporter.js +15 -0
- package/dist/cjs/core/contracts/extensions.d.ts +73 -0
- package/dist/cjs/core/contracts/extensions.js +15 -0
- package/dist/cjs/core/contracts/features.d.ts +25 -0
- package/dist/cjs/core/contracts/features.js +61 -0
- package/dist/cjs/core/contracts/fts.d.ts +66 -0
- package/dist/cjs/core/contracts/fts.js +15 -0
- package/dist/cjs/core/contracts/hooks.d.ts +481 -0
- package/dist/cjs/core/contracts/hooks.js +140 -0
- package/dist/cjs/core/contracts/index.d.ts +260 -0
- package/dist/cjs/core/contracts/index.js +41 -0
- package/dist/cjs/core/contracts/limitations.d.ts +46 -0
- package/dist/cjs/core/contracts/limitations.js +218 -0
- package/dist/cjs/core/contracts/performance.d.ts +308 -0
- package/dist/cjs/core/contracts/performance.js +144 -0
- package/dist/cjs/core/database.d.ts +220 -0
- package/dist/cjs/core/database.js +136 -0
- package/dist/cjs/core/portable.d.ts +24 -0
- package/dist/cjs/core/portable.js +68 -0
- package/dist/cjs/core/resolver.d.ts +77 -0
- package/dist/cjs/core/resolver.js +235 -0
- package/dist/cjs/dialects/PostgresDialect.d.ts +35 -0
- package/dist/cjs/dialects/PostgresDialect.js +143 -0
- package/dist/cjs/dialects/SqliteDialect.d.ts +35 -0
- package/dist/cjs/dialects/SqliteDialect.js +142 -0
- package/dist/cjs/dialects/shared.d.ts +17 -0
- package/dist/cjs/dialects/shared.js +90 -0
- package/dist/cjs/exporters/PostgresExporter.d.ts +14 -0
- package/dist/cjs/exporters/PostgresExporter.js +61 -0
- package/dist/cjs/exporters/SqliteFileExporter.d.ts +16 -0
- package/dist/cjs/exporters/SqliteFileExporter.js +43 -0
- package/dist/cjs/features/auth/authJsAdapter.d.ts +110 -0
- package/dist/cjs/features/auth/authJsAdapter.js +251 -0
- package/dist/cjs/features/backup/cloudBackup.d.ts +219 -0
- package/dist/cjs/features/backup/cloudBackup.js +209 -0
- package/dist/cjs/features/kv/idb.d.ts +79 -0
- package/dist/cjs/features/kv/idb.js +32 -0
- package/dist/cjs/features/kv/index.d.ts +14 -0
- package/dist/cjs/features/kv/index.js +40 -0
- package/dist/cjs/features/kv/indexedDbKeyValueStore.d.ts +77 -0
- package/dist/cjs/features/kv/indexedDbKeyValueStore.js +116 -0
- package/dist/cjs/features/kv/keyValueStore.d.ts +48 -0
- package/dist/cjs/features/kv/keyValueStore.js +67 -0
- package/dist/cjs/features/kv/sqlKeyValueStore.d.ts +34 -0
- package/dist/cjs/features/kv/sqlKeyValueStore.js +81 -0
- package/dist/cjs/features/kv/valueCodec.d.ts +35 -0
- package/dist/cjs/features/kv/valueCodec.js +426 -0
- package/dist/cjs/features/migrations/dataExport.d.ts +77 -0
- package/dist/cjs/features/migrations/dataExport.js +194 -0
- package/dist/cjs/features/migrations/dataImport.d.ts +54 -0
- package/dist/cjs/features/migrations/dataImport.js +300 -0
- package/dist/cjs/features/migrations/migration.d.ts +89 -0
- package/dist/cjs/features/migrations/migration.js +187 -0
- package/dist/cjs/features/migrations/schemaMigrations.d.ts +93 -0
- package/dist/cjs/features/migrations/schemaMigrations.js +220 -0
- package/dist/cjs/features/sync/conflicts/conflictResolver.d.ts +222 -0
- package/dist/cjs/features/sync/conflicts/conflictResolver.js +366 -0
- package/dist/cjs/features/sync/conflicts/index.d.ts +9 -0
- package/dist/cjs/features/sync/conflicts/index.js +21 -0
- package/dist/cjs/features/sync/crossPlatformSync.d.ts +281 -0
- package/dist/cjs/features/sync/crossPlatformSync.js +551 -0
- package/dist/cjs/features/sync/devices/deviceManager.d.ts +243 -0
- package/dist/cjs/features/sync/devices/deviceManager.js +450 -0
- package/dist/cjs/features/sync/devices/index.d.ts +10 -0
- package/dist/cjs/features/sync/devices/index.js +21 -0
- package/dist/cjs/features/sync/index.d.ts +37 -0
- package/dist/cjs/features/sync/index.js +111 -0
- package/dist/cjs/features/sync/protocol/index.d.ts +11 -0
- package/dist/cjs/features/sync/protocol/index.js +23 -0
- package/dist/cjs/features/sync/protocol/messages.d.ts +348 -0
- package/dist/cjs/features/sync/protocol/messages.js +215 -0
- package/dist/cjs/features/sync/protocol/vectorClock.d.ts +164 -0
- package/dist/cjs/features/sync/protocol/vectorClock.js +256 -0
- package/dist/cjs/features/sync/syncManager.d.ts +348 -0
- package/dist/cjs/features/sync/syncManager.js +455 -0
- package/dist/cjs/features/sync/tables/index.d.ts +10 -0
- package/dist/cjs/features/sync/tables/index.js +21 -0
- package/dist/cjs/features/sync/tables/syncLogManager.d.ts +216 -0
- package/dist/cjs/features/sync/tables/syncLogManager.js +423 -0
- package/dist/cjs/features/sync/transport/httpTransport.d.ts +123 -0
- package/dist/cjs/features/sync/transport/httpTransport.js +346 -0
- package/dist/cjs/features/sync/transport/index.d.ts +12 -0
- package/dist/cjs/features/sync/transport/index.js +25 -0
- package/dist/cjs/features/sync/transport/transport.d.ts +259 -0
- package/dist/cjs/features/sync/transport/transport.js +163 -0
- package/dist/cjs/features/sync/transport/websocketTransport.d.ts +126 -0
- package/dist/cjs/features/sync/transport/websocketTransport.js +342 -0
- package/dist/cjs/fts/PostgresFts.d.ts +29 -0
- package/dist/cjs/fts/PostgresFts.js +77 -0
- package/dist/cjs/fts/SqliteFts5.d.ts +22 -0
- package/dist/cjs/fts/SqliteFts5.js +58 -0
- package/dist/cjs/index.d.ts +31 -0
- package/dist/cjs/index.js +103 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/shared/connectionGate.d.ts +94 -0
- package/dist/cjs/shared/connectionGate.js +77 -0
- package/dist/cjs/shared/errors.d.ts +23 -0
- package/dist/cjs/shared/errors.js +45 -0
- package/dist/cjs/shared/logger.d.ts +26 -0
- package/dist/cjs/shared/logger.js +40 -0
- package/dist/cjs/shared/parameterUtils.d.ts +16 -0
- package/dist/cjs/shared/parameterUtils.js +59 -0
- package/dist/cjs/shared/postgresTarget.d.ts +11 -0
- package/dist/cjs/shared/postgresTarget.js +30 -0
- package/dist/cjs/shared/segment.d.ts +43 -0
- package/dist/cjs/shared/segment.js +63 -0
- package/dist/cjs/shared/serializedTransaction.d.ts +14 -0
- package/dist/cjs/shared/serializedTransaction.js +74 -0
- package/dist/cjs/shared/splitSqlStatements.d.ts +27 -0
- package/dist/cjs/shared/splitSqlStatements.js +163 -0
- package/dist/cjs/shared/sqlPlaceholders.d.ts +48 -0
- package/dist/cjs/shared/sqlPlaceholders.js +263 -0
- package/dist/cjs/types/index.d.ts +29 -0
- package/dist/cjs/types/index.js +33 -0
- package/dist/core/portable.d.ts +24 -0
- package/dist/core/portable.d.ts.map +1 -0
- package/dist/core/portable.js +24 -0
- package/dist/core/portable.js.map +1 -0
- package/dist/features/auth/authJsAdapter.d.ts +110 -0
- package/dist/features/auth/authJsAdapter.d.ts.map +1 -0
- package/dist/features/auth/authJsAdapter.js +248 -0
- package/dist/features/auth/authJsAdapter.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +149 -24
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for IPC messages in Electron SQL Storage Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe request/response patterns for IPC communication
|
|
5
|
+
* between main and renderer processes.
|
|
6
|
+
*/
|
|
7
|
+
import type { StorageParameters, StorageRunResult, StorageOpenOptions, StorageCapability, BatchOperation, BatchResult } from '../../../core/contracts/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Base request structure with correlation ID for request tracking.
|
|
10
|
+
*/
|
|
11
|
+
export interface IpcRequest<T = unknown> {
|
|
12
|
+
/** Unique identifier for correlating request/response pairs */
|
|
13
|
+
messageId: string;
|
|
14
|
+
/** Request payload */
|
|
15
|
+
payload: T;
|
|
16
|
+
/** Timestamp when request was created */
|
|
17
|
+
timestamp: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Base response structure with success/error handling.
|
|
21
|
+
*/
|
|
22
|
+
export interface IpcResponse<T = unknown> {
|
|
23
|
+
/** Correlation ID matching the request */
|
|
24
|
+
messageId: string;
|
|
25
|
+
/** Whether the operation succeeded */
|
|
26
|
+
success: boolean;
|
|
27
|
+
/** Response data (if successful) */
|
|
28
|
+
data?: T;
|
|
29
|
+
/** Error information (if failed) */
|
|
30
|
+
error?: IpcError;
|
|
31
|
+
/** Operation duration in milliseconds */
|
|
32
|
+
duration?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error structure for IPC responses.
|
|
36
|
+
*/
|
|
37
|
+
export interface IpcError {
|
|
38
|
+
/** Error code for programmatic handling */
|
|
39
|
+
code: string;
|
|
40
|
+
/** Human-readable error message */
|
|
41
|
+
message: string;
|
|
42
|
+
/** Optional stack trace (development only) */
|
|
43
|
+
stack?: string;
|
|
44
|
+
/** Original error details */
|
|
45
|
+
cause?: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Payload for run/get/all operations.
|
|
49
|
+
*/
|
|
50
|
+
export interface SqlOperationPayload {
|
|
51
|
+
statement: string;
|
|
52
|
+
parameters?: StorageParameters;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Payload for exec operations.
|
|
56
|
+
*/
|
|
57
|
+
export interface ExecPayload {
|
|
58
|
+
script: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Payload for batch operations.
|
|
62
|
+
*/
|
|
63
|
+
export interface BatchPayload {
|
|
64
|
+
operations: BatchOperation[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Payload for open operations.
|
|
68
|
+
*/
|
|
69
|
+
export interface OpenPayload {
|
|
70
|
+
options?: StorageOpenOptions;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Transaction context for multi-step transactions.
|
|
74
|
+
*/
|
|
75
|
+
export interface TransactionContext {
|
|
76
|
+
/** Unique transaction ID */
|
|
77
|
+
transactionId: string;
|
|
78
|
+
/** Whether the transaction is active */
|
|
79
|
+
active: boolean;
|
|
80
|
+
/** Timestamp when transaction started */
|
|
81
|
+
startedAt: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Payload for transaction operations.
|
|
85
|
+
*/
|
|
86
|
+
export interface TransactionOperationPayload {
|
|
87
|
+
transactionId: string;
|
|
88
|
+
operation: SqlOperationPayload;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sync status information.
|
|
92
|
+
*/
|
|
93
|
+
export interface SyncStatus {
|
|
94
|
+
/** Whether sync is currently running */
|
|
95
|
+
isSyncing: boolean;
|
|
96
|
+
/** Last sync timestamp */
|
|
97
|
+
lastSyncAt: number | null;
|
|
98
|
+
/** Number of pending changes */
|
|
99
|
+
pendingChanges: number;
|
|
100
|
+
/** Connected device count */
|
|
101
|
+
connectedDevices: number;
|
|
102
|
+
/** Current sync progress (0-100) */
|
|
103
|
+
progress?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Backup information.
|
|
107
|
+
*/
|
|
108
|
+
export interface BackupInfo {
|
|
109
|
+
id: string;
|
|
110
|
+
createdAt: number;
|
|
111
|
+
size: number;
|
|
112
|
+
provider: string;
|
|
113
|
+
path?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Database change notification payload.
|
|
117
|
+
*/
|
|
118
|
+
export interface DbChangeEvent {
|
|
119
|
+
/** Type of change */
|
|
120
|
+
type: 'insert' | 'update' | 'delete' | 'transaction';
|
|
121
|
+
/** Affected table(s) */
|
|
122
|
+
tables: string[];
|
|
123
|
+
/** Number of affected rows */
|
|
124
|
+
changes: number;
|
|
125
|
+
/** Timestamp of change */
|
|
126
|
+
timestamp: number;
|
|
127
|
+
/** Source window ID (if applicable) */
|
|
128
|
+
sourceWindowId?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Connection state change payload.
|
|
132
|
+
*/
|
|
133
|
+
export interface ConnectionStateEvent {
|
|
134
|
+
/** New connection state */
|
|
135
|
+
state: 'open' | 'closed' | 'error';
|
|
136
|
+
/** Timestamp of state change */
|
|
137
|
+
timestamp: number;
|
|
138
|
+
/** Error details (if state is 'error') */
|
|
139
|
+
error?: IpcError;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Integrity check result.
|
|
143
|
+
*/
|
|
144
|
+
export interface IntegrityCheckResult {
|
|
145
|
+
/** Whether the database is healthy */
|
|
146
|
+
ok: boolean;
|
|
147
|
+
/** List of issues found */
|
|
148
|
+
issues: string[];
|
|
149
|
+
/** Timestamp of check */
|
|
150
|
+
checkedAt: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* WAL checkpoint result.
|
|
154
|
+
*/
|
|
155
|
+
export interface WalCheckpointResult {
|
|
156
|
+
/** Number of frames checkpointed */
|
|
157
|
+
framesCheckpointed: number;
|
|
158
|
+
/** Total frames in WAL */
|
|
159
|
+
totalFrames: number;
|
|
160
|
+
/** Whether checkpoint was successful */
|
|
161
|
+
success: boolean;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Migration status.
|
|
165
|
+
*/
|
|
166
|
+
export interface MigrationStatus {
|
|
167
|
+
/** Current database version */
|
|
168
|
+
currentVersion: number;
|
|
169
|
+
/** Latest available version */
|
|
170
|
+
latestVersion: number;
|
|
171
|
+
/** List of pending migrations */
|
|
172
|
+
pending: string[];
|
|
173
|
+
/** List of applied migrations */
|
|
174
|
+
applied: string[];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Map of channel to request payload types.
|
|
178
|
+
*/
|
|
179
|
+
export interface IpcRequestPayloads {
|
|
180
|
+
'sql-storage:db:run': SqlOperationPayload;
|
|
181
|
+
'sql-storage:db:get': SqlOperationPayload;
|
|
182
|
+
'sql-storage:db:all': SqlOperationPayload;
|
|
183
|
+
'sql-storage:db:exec': ExecPayload;
|
|
184
|
+
'sql-storage:db:batch': BatchPayload;
|
|
185
|
+
'sql-storage:db:open': OpenPayload;
|
|
186
|
+
'sql-storage:db:close': void;
|
|
187
|
+
'sql-storage:db:is-open': void;
|
|
188
|
+
'sql-storage:db:capabilities': void;
|
|
189
|
+
'sql-storage:transaction:begin': void;
|
|
190
|
+
'sql-storage:transaction:commit': {
|
|
191
|
+
transactionId: string;
|
|
192
|
+
};
|
|
193
|
+
'sql-storage:transaction:rollback': {
|
|
194
|
+
transactionId: string;
|
|
195
|
+
};
|
|
196
|
+
'sql-storage:transaction:execute': TransactionOperationPayload;
|
|
197
|
+
'sql-storage:sync:status': void;
|
|
198
|
+
'sql-storage:sync:trigger': void;
|
|
199
|
+
'sql-storage:backup:trigger': void;
|
|
200
|
+
'sql-storage:backup:list': void;
|
|
201
|
+
'sql-storage:backup:restore': {
|
|
202
|
+
backupId: string;
|
|
203
|
+
};
|
|
204
|
+
'sql-storage:recovery:check-integrity': void;
|
|
205
|
+
'sql-storage:recovery:wal-checkpoint': void;
|
|
206
|
+
'sql-storage:recovery:repair': void;
|
|
207
|
+
'sql-storage:migration:run': void;
|
|
208
|
+
'sql-storage:migration:status': void;
|
|
209
|
+
'sql-storage:migration:rollback': void;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Map of channel to response data types.
|
|
213
|
+
*/
|
|
214
|
+
export interface IpcResponseData {
|
|
215
|
+
'sql-storage:db:run': StorageRunResult;
|
|
216
|
+
'sql-storage:db:get': unknown;
|
|
217
|
+
'sql-storage:db:all': unknown[];
|
|
218
|
+
'sql-storage:db:exec': void;
|
|
219
|
+
'sql-storage:db:batch': BatchResult;
|
|
220
|
+
'sql-storage:db:open': void;
|
|
221
|
+
'sql-storage:db:close': void;
|
|
222
|
+
'sql-storage:db:is-open': boolean;
|
|
223
|
+
'sql-storage:db:capabilities': StorageCapability[];
|
|
224
|
+
'sql-storage:transaction:begin': TransactionContext;
|
|
225
|
+
'sql-storage:transaction:commit': void;
|
|
226
|
+
'sql-storage:transaction:rollback': void;
|
|
227
|
+
'sql-storage:transaction:execute': StorageRunResult | unknown;
|
|
228
|
+
'sql-storage:sync:status': SyncStatus;
|
|
229
|
+
'sql-storage:sync:trigger': void;
|
|
230
|
+
'sql-storage:backup:trigger': void;
|
|
231
|
+
'sql-storage:backup:list': BackupInfo[];
|
|
232
|
+
'sql-storage:backup:restore': void;
|
|
233
|
+
'sql-storage:recovery:check-integrity': IntegrityCheckResult;
|
|
234
|
+
'sql-storage:recovery:wal-checkpoint': WalCheckpointResult;
|
|
235
|
+
'sql-storage:recovery:repair': void;
|
|
236
|
+
'sql-storage:migration:run': void;
|
|
237
|
+
'sql-storage:migration:status': MigrationStatus;
|
|
238
|
+
'sql-storage:migration:rollback': void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Helper type for typed invoke calls.
|
|
242
|
+
*/
|
|
243
|
+
export type TypedIpcInvoke = <K extends keyof IpcRequestPayloads>(channel: K, payload: IpcRequestPayloads[K]) => Promise<IpcResponseData[K]>;
|
|
244
|
+
/**
|
|
245
|
+
* Helper type for typed handle registration.
|
|
246
|
+
*/
|
|
247
|
+
export type TypedIpcHandle = <K extends keyof IpcRequestPayloads>(channel: K, handler: (event: Electron.IpcMainInvokeEvent, request: IpcRequest<IpcRequestPayloads[K]>) => Promise<IpcResponse<IpcResponseData[K]>>) => void;
|
|
248
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Migration System for Electron Apps.
|
|
3
|
+
*
|
|
4
|
+
* Automatically runs database migrations when the application version
|
|
5
|
+
* changes. Tracks applied migrations and supports rollback.
|
|
6
|
+
*
|
|
7
|
+
* ## Features
|
|
8
|
+
* - Version detection via package.json or app.getVersion()
|
|
9
|
+
* - Automatic migration on app update
|
|
10
|
+
* - Migration file discovery and ordering
|
|
11
|
+
* - Rollback support
|
|
12
|
+
* - Transaction-wrapped migrations
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const migrator = new AutoMigrator(adapter, {
|
|
17
|
+
* migrationsPath: path.join(__dirname, 'migrations'),
|
|
18
|
+
* runOnVersionChange: true,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* await migrator.initialize();
|
|
22
|
+
* await migrator.runPending();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import type { StorageAdapter } from '../../../core/contracts/index.js';
|
|
26
|
+
/**
|
|
27
|
+
* Migration file definition.
|
|
28
|
+
*/
|
|
29
|
+
export interface MigrationFile {
|
|
30
|
+
/** Migration version/order number */
|
|
31
|
+
version: number;
|
|
32
|
+
/** Migration name */
|
|
33
|
+
name: string;
|
|
34
|
+
/** Full file path */
|
|
35
|
+
path: string;
|
|
36
|
+
/** SQL content (up migration) */
|
|
37
|
+
up: string;
|
|
38
|
+
/** SQL content (down migration, optional) */
|
|
39
|
+
down?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Applied migration record.
|
|
43
|
+
*/
|
|
44
|
+
export interface AppliedMigration {
|
|
45
|
+
version: number;
|
|
46
|
+
name: string;
|
|
47
|
+
appliedAt: number;
|
|
48
|
+
appVersion: string;
|
|
49
|
+
checksum: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Migration result.
|
|
53
|
+
*/
|
|
54
|
+
export interface MigrationResult {
|
|
55
|
+
success: boolean;
|
|
56
|
+
migrationsRun: number;
|
|
57
|
+
migrationsFailed: number;
|
|
58
|
+
duration: number;
|
|
59
|
+
appliedMigrations: string[];
|
|
60
|
+
errors: Array<{
|
|
61
|
+
migration: string;
|
|
62
|
+
error: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Auto-migrator configuration.
|
|
67
|
+
*/
|
|
68
|
+
export interface AutoMigratorConfig {
|
|
69
|
+
/** Path to migrations directory */
|
|
70
|
+
migrationsPath: string;
|
|
71
|
+
/** Run migrations on version change (default: true) */
|
|
72
|
+
runOnVersionChange?: boolean;
|
|
73
|
+
/** Table name for tracking migrations (default: '_migrations') */
|
|
74
|
+
tableName?: string;
|
|
75
|
+
/** Enable verbose logging (default: false) */
|
|
76
|
+
verbose?: boolean;
|
|
77
|
+
/** Get current app version (default: reads from package.json or electron) */
|
|
78
|
+
getAppVersion?: () => string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Auto Migration Manager.
|
|
82
|
+
*
|
|
83
|
+
* Handles automatic database migrations for Electron applications.
|
|
84
|
+
*/
|
|
85
|
+
export declare class AutoMigrator {
|
|
86
|
+
private readonly adapter;
|
|
87
|
+
private readonly config;
|
|
88
|
+
private migrations;
|
|
89
|
+
private isInitialized;
|
|
90
|
+
private lastMigrationResult;
|
|
91
|
+
constructor(adapter: StorageAdapter, config: AutoMigratorConfig);
|
|
92
|
+
/**
|
|
93
|
+
* Initialize the migration system.
|
|
94
|
+
*/
|
|
95
|
+
initialize(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Create the migrations tracking table.
|
|
98
|
+
*/
|
|
99
|
+
private createMigrationsTable;
|
|
100
|
+
/**
|
|
101
|
+
* Load all migration files from the migrations directory.
|
|
102
|
+
*/
|
|
103
|
+
private loadMigrations;
|
|
104
|
+
/**
|
|
105
|
+
* Parse a migration file.
|
|
106
|
+
*/
|
|
107
|
+
private parseMigrationFile;
|
|
108
|
+
/**
|
|
109
|
+
* Parse a SQL migration file.
|
|
110
|
+
* Supports UP and DOWN sections separated by `-- DOWN`.
|
|
111
|
+
*/
|
|
112
|
+
private parseSqlMigration;
|
|
113
|
+
/**
|
|
114
|
+
* Parse a JS/TS migration file.
|
|
115
|
+
* Expects exports: { up: string, down?: string }
|
|
116
|
+
*/
|
|
117
|
+
private parseJsMigration;
|
|
118
|
+
/**
|
|
119
|
+
* Run all pending migrations.
|
|
120
|
+
*/
|
|
121
|
+
runPending(): Promise<MigrationResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Run a single migration.
|
|
124
|
+
*/
|
|
125
|
+
private applyMigration;
|
|
126
|
+
/**
|
|
127
|
+
* Run a specific migration by version.
|
|
128
|
+
*/
|
|
129
|
+
runMigrationByVersion(version: number): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Rollback the last applied migration.
|
|
132
|
+
*/
|
|
133
|
+
rollbackLast(): Promise<MigrationResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Rollback to a specific version.
|
|
136
|
+
*/
|
|
137
|
+
rollbackTo(targetVersion: number): Promise<MigrationResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Get all applied migrations.
|
|
140
|
+
*/
|
|
141
|
+
getAppliedMigrations(): Promise<AppliedMigration[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Get pending migrations.
|
|
144
|
+
*/
|
|
145
|
+
getPendingMigrations(): Promise<MigrationFile[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Get migration status.
|
|
148
|
+
*/
|
|
149
|
+
getStatus(): Promise<{
|
|
150
|
+
currentVersion: number;
|
|
151
|
+
latestVersion: number;
|
|
152
|
+
pending: string[];
|
|
153
|
+
applied: string[];
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Check if migrations should run based on version change.
|
|
157
|
+
*/
|
|
158
|
+
private shouldRunMigrations;
|
|
159
|
+
/**
|
|
160
|
+
* Default app version getter.
|
|
161
|
+
*/
|
|
162
|
+
private defaultGetAppVersion;
|
|
163
|
+
/**
|
|
164
|
+
* Calculate checksum of migration content.
|
|
165
|
+
*/
|
|
166
|
+
private calculateChecksum;
|
|
167
|
+
/**
|
|
168
|
+
* Log a message if verbose mode is enabled.
|
|
169
|
+
*/
|
|
170
|
+
private log;
|
|
171
|
+
/**
|
|
172
|
+
* Get the last migration result.
|
|
173
|
+
*/
|
|
174
|
+
getLastResult(): MigrationResult | null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create an Auto Migrator.
|
|
178
|
+
*
|
|
179
|
+
* @param adapter - Storage adapter to manage
|
|
180
|
+
* @param config - Migrator configuration
|
|
181
|
+
* @returns AutoMigrator instance
|
|
182
|
+
*/
|
|
183
|
+
export declare function createAutoMigrator(adapter: StorageAdapter, config: AutoMigratorConfig): AutoMigrator;
|
|
184
|
+
//# sourceMappingURL=autoMigrator.d.ts.map
|