@framers/sql-storage-adapter 0.7.1 → 0.7.3
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 +43 -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 +23 -0
- package/dist/cjs/core/portable.js +66 -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/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 +30 -0
- package/dist/cjs/index.js +101 -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 +23 -0
- package/dist/core/portable.d.ts.map +1 -0
- package/dist/core/portable.js +23 -0
- package/dist/core/portable.js.map +1 -0
- package/dist/features/migrations/schemaMigrations.d.ts +93 -0
- package/dist/features/migrations/schemaMigrations.d.ts.map +1 -0
- package/dist/features/migrations/schemaMigrations.js +216 -0
- package/dist/features/migrations/schemaMigrations.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 +139 -24
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var electronRendererAdapter_exports = {};
|
|
19
|
+
__export(electronRendererAdapter_exports, {
|
|
20
|
+
ElectronRendererAdapter: () => ElectronRendererAdapter,
|
|
21
|
+
createElectronRendererAdapter: () => createElectronRendererAdapter,
|
|
22
|
+
isElectronRenderer: () => isElectronRenderer,
|
|
23
|
+
isPreloadApiAvailable: () => isPreloadApiAvailable
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(electronRendererAdapter_exports);
|
|
26
|
+
class ElectronRendererAdapter {
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this.kind = "electron-renderer";
|
|
29
|
+
this.eventUnsubscribers = [];
|
|
30
|
+
this.isInitialized = false;
|
|
31
|
+
this.cachedCapabilities = [];
|
|
32
|
+
this.options = options;
|
|
33
|
+
this.capabilities = /* @__PURE__ */ new Set([
|
|
34
|
+
"transactions",
|
|
35
|
+
"persistence",
|
|
36
|
+
"batch"
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Private Helpers
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Get the preload API, throwing if not available.
|
|
44
|
+
*/
|
|
45
|
+
getApi() {
|
|
46
|
+
if (typeof window === "undefined" || !window.sqlStorage) {
|
|
47
|
+
throw new Error("[ElectronRendererAdapter] window.sqlStorage not available. Ensure the preload script is loaded and contextBridge is properly configured.");
|
|
48
|
+
}
|
|
49
|
+
return window.sqlStorage;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Log a message if verbose mode is enabled.
|
|
53
|
+
*/
|
|
54
|
+
log(message) {
|
|
55
|
+
if (this.options.verbose) {
|
|
56
|
+
console.log(`[ElectronRendererAdapter] ${message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Lifecycle Methods
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Open connection to the database via main process.
|
|
64
|
+
*/
|
|
65
|
+
async open(options) {
|
|
66
|
+
if (this.isInitialized) {
|
|
67
|
+
this.log("Already initialized, skipping open()");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const api = this.getApi();
|
|
71
|
+
await api.open(options);
|
|
72
|
+
this.cachedCapabilities = await api.getCapabilities();
|
|
73
|
+
this.capabilities = new Set(this.cachedCapabilities);
|
|
74
|
+
this.subscribeToEvents();
|
|
75
|
+
this.isInitialized = true;
|
|
76
|
+
this.log("Connected to main process");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Close connection.
|
|
80
|
+
*/
|
|
81
|
+
async close() {
|
|
82
|
+
if (!this.isInitialized) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const unsubscribe of this.eventUnsubscribers) {
|
|
86
|
+
unsubscribe();
|
|
87
|
+
}
|
|
88
|
+
this.eventUnsubscribers = [];
|
|
89
|
+
this.isInitialized = false;
|
|
90
|
+
this.log("Disconnected from main process");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Subscribe to database events from main process.
|
|
94
|
+
*/
|
|
95
|
+
subscribeToEvents() {
|
|
96
|
+
const api = this.getApi();
|
|
97
|
+
if (this.options.onDatabaseChange) {
|
|
98
|
+
const unsubscribe = api.onDatabaseChange(this.options.onDatabaseChange);
|
|
99
|
+
this.eventUnsubscribers.push(unsubscribe);
|
|
100
|
+
}
|
|
101
|
+
if (this.options.onSyncProgress) {
|
|
102
|
+
const unsubscribe = api.onSyncProgress(this.options.onSyncProgress);
|
|
103
|
+
this.eventUnsubscribers.push(unsubscribe);
|
|
104
|
+
}
|
|
105
|
+
if (this.options.onSyncComplete) {
|
|
106
|
+
const unsubscribe = api.onSyncComplete(this.options.onSyncComplete);
|
|
107
|
+
this.eventUnsubscribers.push(unsubscribe);
|
|
108
|
+
}
|
|
109
|
+
if (this.options.onSyncError) {
|
|
110
|
+
const unsubscribe = api.onSyncError(this.options.onSyncError);
|
|
111
|
+
this.eventUnsubscribers.push(unsubscribe);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Storage Adapter Interface
|
|
116
|
+
// ============================================================================
|
|
117
|
+
/**
|
|
118
|
+
* Execute a mutation statement (INSERT, UPDATE, DELETE).
|
|
119
|
+
*/
|
|
120
|
+
async run(statement, parameters) {
|
|
121
|
+
this.assertOpen();
|
|
122
|
+
return this.getApi().run(statement, parameters);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get a single row.
|
|
126
|
+
*/
|
|
127
|
+
async get(statement, parameters) {
|
|
128
|
+
this.assertOpen();
|
|
129
|
+
return this.getApi().get(statement, parameters);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get all matching rows.
|
|
133
|
+
*/
|
|
134
|
+
async all(statement, parameters) {
|
|
135
|
+
this.assertOpen();
|
|
136
|
+
return this.getApi().all(statement, parameters);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Execute a SQL script.
|
|
140
|
+
*/
|
|
141
|
+
async exec(script) {
|
|
142
|
+
this.assertOpen();
|
|
143
|
+
return this.getApi().exec(script);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Execute operations within a transaction.
|
|
147
|
+
*/
|
|
148
|
+
async transaction(fn) {
|
|
149
|
+
this.assertOpen();
|
|
150
|
+
const trxAdapter = new TransactionProxyAdapter(this.getApi());
|
|
151
|
+
return this.getApi().transaction(async (trx) => {
|
|
152
|
+
const wrappedTrx = {
|
|
153
|
+
kind: "electron-renderer-transaction",
|
|
154
|
+
capabilities: this.capabilities,
|
|
155
|
+
open: async () => {
|
|
156
|
+
},
|
|
157
|
+
close: async () => {
|
|
158
|
+
},
|
|
159
|
+
run: trx.run,
|
|
160
|
+
get: trx.get,
|
|
161
|
+
all: trx.all,
|
|
162
|
+
exec: async () => {
|
|
163
|
+
throw new Error("exec not supported in transaction");
|
|
164
|
+
},
|
|
165
|
+
transaction: async () => {
|
|
166
|
+
throw new Error("Nested transactions not supported");
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return fn(wrappedTrx);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Execute batch operations.
|
|
174
|
+
*/
|
|
175
|
+
async batch(operations) {
|
|
176
|
+
this.assertOpen();
|
|
177
|
+
return this.getApi().batch(operations);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Prepared statements are not directly supported in renderer.
|
|
181
|
+
* Use the main process adapter for prepared statements.
|
|
182
|
+
*/
|
|
183
|
+
prepare(_statement) {
|
|
184
|
+
throw new Error("Prepared statements not supported in renderer process. Use transactions instead.");
|
|
185
|
+
}
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Sync Operations
|
|
188
|
+
// ============================================================================
|
|
189
|
+
/**
|
|
190
|
+
* Get current sync status.
|
|
191
|
+
*/
|
|
192
|
+
async getSyncStatus() {
|
|
193
|
+
this.assertOpen();
|
|
194
|
+
return this.getApi().getSyncStatus();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Trigger a manual sync.
|
|
198
|
+
*/
|
|
199
|
+
async triggerSync() {
|
|
200
|
+
this.assertOpen();
|
|
201
|
+
return this.getApi().triggerSync();
|
|
202
|
+
}
|
|
203
|
+
// ============================================================================
|
|
204
|
+
// Utility Methods
|
|
205
|
+
// ============================================================================
|
|
206
|
+
/**
|
|
207
|
+
* Assert that the adapter is open.
|
|
208
|
+
*/
|
|
209
|
+
assertOpen() {
|
|
210
|
+
if (!this.isInitialized) {
|
|
211
|
+
throw new Error("[ElectronRendererAdapter] Adapter not open. Call open() first.");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Check if the adapter is open.
|
|
216
|
+
*/
|
|
217
|
+
isOpen() {
|
|
218
|
+
return this.isInitialized;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Check if the main process database is open.
|
|
222
|
+
*/
|
|
223
|
+
async isMainProcessOpen() {
|
|
224
|
+
try {
|
|
225
|
+
return await this.getApi().isOpen();
|
|
226
|
+
} catch {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Add an event listener for database changes.
|
|
232
|
+
*/
|
|
233
|
+
onDatabaseChange(callback) {
|
|
234
|
+
const unsubscribe = this.getApi().onDatabaseChange(callback);
|
|
235
|
+
this.eventUnsubscribers.push(unsubscribe);
|
|
236
|
+
return unsubscribe;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class TransactionProxyAdapter {
|
|
240
|
+
constructor(api) {
|
|
241
|
+
this.api = api;
|
|
242
|
+
this.kind = "electron-renderer-transaction";
|
|
243
|
+
this.capabilities = /* @__PURE__ */ new Set();
|
|
244
|
+
}
|
|
245
|
+
async open() {
|
|
246
|
+
}
|
|
247
|
+
async close() {
|
|
248
|
+
}
|
|
249
|
+
async run(statement, parameters) {
|
|
250
|
+
return this.api.run(statement, parameters);
|
|
251
|
+
}
|
|
252
|
+
async get(statement, parameters) {
|
|
253
|
+
return this.api.get(statement, parameters);
|
|
254
|
+
}
|
|
255
|
+
async all(statement, parameters) {
|
|
256
|
+
return this.api.all(statement, parameters);
|
|
257
|
+
}
|
|
258
|
+
async exec(_script) {
|
|
259
|
+
throw new Error("exec not supported within transactions from renderer");
|
|
260
|
+
}
|
|
261
|
+
async transaction(_fn) {
|
|
262
|
+
throw new Error("Nested transactions not supported");
|
|
263
|
+
}
|
|
264
|
+
async batch(_operations) {
|
|
265
|
+
throw new Error("Batch operations not supported within transactions from renderer");
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function createElectronRendererAdapter(options = {}) {
|
|
269
|
+
return new ElectronRendererAdapter(options);
|
|
270
|
+
}
|
|
271
|
+
function isElectronRenderer() {
|
|
272
|
+
return typeof window !== "undefined" && typeof window.process === "object" && window.process?.type === "renderer";
|
|
273
|
+
}
|
|
274
|
+
function isPreloadApiAvailable() {
|
|
275
|
+
return typeof window !== "undefined" && !!window.sqlStorage;
|
|
276
|
+
}
|
|
277
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
278
|
+
0 && (module.exports = {
|
|
279
|
+
ElectronRendererAdapter,
|
|
280
|
+
createElectronRendererAdapter,
|
|
281
|
+
isElectronRenderer,
|
|
282
|
+
isPreloadApiAvailable
|
|
283
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Electron Storage Adapter Module.
|
|
3
|
+
*
|
|
4
|
+
* Provides database access for Electron applications with:
|
|
5
|
+
* - Main process adapter (owns the database connection)
|
|
6
|
+
* - Renderer process adapter (IPC proxy to main)
|
|
7
|
+
* - Preload script for secure IPC bridge
|
|
8
|
+
* - WAL management and crash recovery
|
|
9
|
+
* - Multi-window change broadcasting
|
|
10
|
+
*
|
|
11
|
+
* ## Quick Start
|
|
12
|
+
*
|
|
13
|
+
* ### Main Process (main.ts)
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createElectronMainAdapter } from '@framers/sql-storage-adapter/electron';
|
|
16
|
+
* import { app } from 'electron';
|
|
17
|
+
* import path from 'path';
|
|
18
|
+
*
|
|
19
|
+
* const db = createElectronMainAdapter({
|
|
20
|
+
* filePath: path.join(app.getPath('userData'), 'app.db'),
|
|
21
|
+
* wal: { enabled: true },
|
|
22
|
+
* recovery: { checkOnOpen: true },
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* app.whenReady().then(async () => {
|
|
26
|
+
* await db.open();
|
|
27
|
+
* // Database ready for use
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ### BrowserWindow Configuration
|
|
32
|
+
* ```typescript
|
|
33
|
+
* new BrowserWindow({
|
|
34
|
+
* webPreferences: {
|
|
35
|
+
* preload: path.join(__dirname, 'preload.js'),
|
|
36
|
+
* contextIsolation: true,
|
|
37
|
+
* nodeIntegration: false,
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ### Preload Script (preload.ts)
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Just import the preload module - it auto-registers
|
|
45
|
+
* import '@framers/sql-storage-adapter/electron/preload';
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* ### Renderer Process
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { createElectronRendererAdapter } from '@framers/sql-storage-adapter/electron';
|
|
51
|
+
*
|
|
52
|
+
* const db = createElectronRendererAdapter({
|
|
53
|
+
* onDatabaseChange: (change) => {
|
|
54
|
+
* console.log('Database changed:', change);
|
|
55
|
+
* },
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* await db.open();
|
|
59
|
+
* const users = await db.all('SELECT * FROM users');
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @packageDocumentation
|
|
63
|
+
*/
|
|
64
|
+
export { ElectronMainAdapter, createElectronMainAdapter, type ElectronMainAdapterOptions, type WalConfig, type RecoveryConfig, type MigrationConfig, type BackupConfig, type CloudBackupProvider, type MultiWindowConfig, } from './electronMainAdapter.js';
|
|
65
|
+
export { ElectronRendererAdapter, createElectronRendererAdapter, isElectronRenderer, isPreloadApiAvailable, type ElectronRendererAdapterOptions, } from './electronRendererAdapter.js';
|
|
66
|
+
export { sqlStorageApi, type SqlStorageApi, } from './preload.js';
|
|
67
|
+
export { IPC_CHANNELS, DB_CHANNELS, TRANSACTION_CHANNELS, SYNC_CHANNELS, BACKUP_CHANNELS, RECOVERY_CHANNELS, MIGRATION_CHANNELS, BROADCAST_CHANNELS, type IpcChannel, } from './ipc/channels.js';
|
|
68
|
+
export type { IpcRequest, IpcResponse, IpcError, SqlOperationPayload, ExecPayload, BatchPayload, OpenPayload, TransactionContext, TransactionOperationPayload, SyncStatus, BackupInfo, DbChangeEvent, ConnectionStateEvent, IntegrityCheckResult, WalCheckpointResult, MigrationStatus, } from './ipc/types.js';
|
|
69
|
+
export { IpcProtocolManager, protocolManager, initializeIpcProtocol, disposeIpcProtocol, } from './ipc/protocol.js';
|
|
70
|
+
export { WalCheckpointManager, createWalCheckpointManager, type WalCheckpointConfig, type CheckpointStrategy, type CheckpointResult, type WalStatus, CorruptionDetector, createCorruptionDetector, type CorruptionDetectorConfig, type IntegrityCheckLevel, type IntegrityCheckResult as RecoveryIntegrityCheckResult, type CorruptionIssue, type RepairStrategy, type RepairResult, } from './recovery/index.js';
|
|
71
|
+
export { AutoMigrator, createAutoMigrator, type AutoMigratorConfig, type MigrationFile, type AppliedMigration, type MigrationResult, } from './migration/index.js';
|
|
72
|
+
export { WindowManager, createWindowManager, type WindowManagerConfig, type WindowManagerCallbacks, type RegisteredWindow, } from './window/index.js';
|
|
73
|
+
export type { StorageAdapter, StorageCapability, StorageOpenOptions, StorageParameters, StorageRunResult, BatchOperation, BatchResult, } from '../../core/contracts/index.js';
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var electron_exports = {};
|
|
19
|
+
__export(electron_exports, {
|
|
20
|
+
AutoMigrator: () => import_migration.AutoMigrator,
|
|
21
|
+
BACKUP_CHANNELS: () => import_channels.BACKUP_CHANNELS,
|
|
22
|
+
BROADCAST_CHANNELS: () => import_channels.BROADCAST_CHANNELS,
|
|
23
|
+
CorruptionDetector: () => import_recovery.CorruptionDetector,
|
|
24
|
+
DB_CHANNELS: () => import_channels.DB_CHANNELS,
|
|
25
|
+
ElectronMainAdapter: () => import_electronMainAdapter.ElectronMainAdapter,
|
|
26
|
+
ElectronRendererAdapter: () => import_electronRendererAdapter.ElectronRendererAdapter,
|
|
27
|
+
IPC_CHANNELS: () => import_channels.IPC_CHANNELS,
|
|
28
|
+
IpcProtocolManager: () => import_protocol.IpcProtocolManager,
|
|
29
|
+
MIGRATION_CHANNELS: () => import_channels.MIGRATION_CHANNELS,
|
|
30
|
+
RECOVERY_CHANNELS: () => import_channels.RECOVERY_CHANNELS,
|
|
31
|
+
SYNC_CHANNELS: () => import_channels.SYNC_CHANNELS,
|
|
32
|
+
TRANSACTION_CHANNELS: () => import_channels.TRANSACTION_CHANNELS,
|
|
33
|
+
WalCheckpointManager: () => import_recovery.WalCheckpointManager,
|
|
34
|
+
WindowManager: () => import_window.WindowManager,
|
|
35
|
+
createAutoMigrator: () => import_migration.createAutoMigrator,
|
|
36
|
+
createCorruptionDetector: () => import_recovery.createCorruptionDetector,
|
|
37
|
+
createElectronMainAdapter: () => import_electronMainAdapter.createElectronMainAdapter,
|
|
38
|
+
createElectronRendererAdapter: () => import_electronRendererAdapter.createElectronRendererAdapter,
|
|
39
|
+
createWalCheckpointManager: () => import_recovery.createWalCheckpointManager,
|
|
40
|
+
createWindowManager: () => import_window.createWindowManager,
|
|
41
|
+
disposeIpcProtocol: () => import_protocol.disposeIpcProtocol,
|
|
42
|
+
initializeIpcProtocol: () => import_protocol.initializeIpcProtocol,
|
|
43
|
+
isElectronRenderer: () => import_electronRendererAdapter.isElectronRenderer,
|
|
44
|
+
isPreloadApiAvailable: () => import_electronRendererAdapter.isPreloadApiAvailable,
|
|
45
|
+
protocolManager: () => import_protocol.protocolManager,
|
|
46
|
+
sqlStorageApi: () => import_preload.sqlStorageApi
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(electron_exports);
|
|
49
|
+
var import_electronMainAdapter = require("./electronMainAdapter.js");
|
|
50
|
+
var import_electronRendererAdapter = require("./electronRendererAdapter.js");
|
|
51
|
+
var import_preload = require("./preload.js");
|
|
52
|
+
var import_channels = require("./ipc/channels.js");
|
|
53
|
+
var import_protocol = require("./ipc/protocol.js");
|
|
54
|
+
var import_recovery = require("./recovery/index.js");
|
|
55
|
+
var import_migration = require("./migration/index.js");
|
|
56
|
+
var import_window = require("./window/index.js");
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
AutoMigrator,
|
|
60
|
+
BACKUP_CHANNELS,
|
|
61
|
+
BROADCAST_CHANNELS,
|
|
62
|
+
CorruptionDetector,
|
|
63
|
+
DB_CHANNELS,
|
|
64
|
+
ElectronMainAdapter,
|
|
65
|
+
ElectronRendererAdapter,
|
|
66
|
+
IPC_CHANNELS,
|
|
67
|
+
IpcProtocolManager,
|
|
68
|
+
MIGRATION_CHANNELS,
|
|
69
|
+
RECOVERY_CHANNELS,
|
|
70
|
+
SYNC_CHANNELS,
|
|
71
|
+
TRANSACTION_CHANNELS,
|
|
72
|
+
WalCheckpointManager,
|
|
73
|
+
WindowManager,
|
|
74
|
+
createAutoMigrator,
|
|
75
|
+
createCorruptionDetector,
|
|
76
|
+
createElectronMainAdapter,
|
|
77
|
+
createElectronRendererAdapter,
|
|
78
|
+
createWalCheckpointManager,
|
|
79
|
+
createWindowManager,
|
|
80
|
+
disposeIpcProtocol,
|
|
81
|
+
initializeIpcProtocol,
|
|
82
|
+
isElectronRenderer,
|
|
83
|
+
isPreloadApiAvailable,
|
|
84
|
+
protocolManager,
|
|
85
|
+
sqlStorageApi
|
|
86
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC Channel Constants for Electron SQL Storage Adapter.
|
|
3
|
+
*
|
|
4
|
+
* All IPC communication between main and renderer processes
|
|
5
|
+
* uses these standardized channel names to ensure type safety
|
|
6
|
+
* and prevent channel name collisions.
|
|
7
|
+
*
|
|
8
|
+
* Channel naming convention: `sql-storage:{category}:{action}`
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Database operation channels.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DB_CHANNELS: {
|
|
14
|
+
/** Execute a mutation (INSERT/UPDATE/DELETE) */
|
|
15
|
+
readonly RUN: "sql-storage:db:run";
|
|
16
|
+
/** Get a single row */
|
|
17
|
+
readonly GET: "sql-storage:db:get";
|
|
18
|
+
/** Get all matching rows */
|
|
19
|
+
readonly ALL: "sql-storage:db:all";
|
|
20
|
+
/** Execute a SQL script */
|
|
21
|
+
readonly EXEC: "sql-storage:db:exec";
|
|
22
|
+
/** Execute batch operations */
|
|
23
|
+
readonly BATCH: "sql-storage:db:batch";
|
|
24
|
+
/** Open database connection */
|
|
25
|
+
readonly OPEN: "sql-storage:db:open";
|
|
26
|
+
/** Close database connection */
|
|
27
|
+
readonly CLOSE: "sql-storage:db:close";
|
|
28
|
+
/** Check if database is open */
|
|
29
|
+
readonly IS_OPEN: "sql-storage:db:is-open";
|
|
30
|
+
/** Get adapter capabilities */
|
|
31
|
+
readonly CAPABILITIES: "sql-storage:db:capabilities";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Transaction channels.
|
|
35
|
+
*/
|
|
36
|
+
export declare const TRANSACTION_CHANNELS: {
|
|
37
|
+
/** Begin a transaction */
|
|
38
|
+
readonly BEGIN: "sql-storage:transaction:begin";
|
|
39
|
+
/** Commit current transaction */
|
|
40
|
+
readonly COMMIT: "sql-storage:transaction:commit";
|
|
41
|
+
/** Rollback current transaction */
|
|
42
|
+
readonly ROLLBACK: "sql-storage:transaction:rollback";
|
|
43
|
+
/** Execute operation within transaction context */
|
|
44
|
+
readonly EXECUTE: "sql-storage:transaction:execute";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Sync operation channels.
|
|
48
|
+
*/
|
|
49
|
+
export declare const SYNC_CHANNELS: {
|
|
50
|
+
/** Get sync status */
|
|
51
|
+
readonly STATUS: "sql-storage:sync:status";
|
|
52
|
+
/** Trigger manual sync */
|
|
53
|
+
readonly TRIGGER: "sql-storage:sync:trigger";
|
|
54
|
+
/** Sync progress updates (main -> renderer) */
|
|
55
|
+
readonly PROGRESS: "sql-storage:sync:progress";
|
|
56
|
+
/** Sync completed (main -> renderer) */
|
|
57
|
+
readonly COMPLETE: "sql-storage:sync:complete";
|
|
58
|
+
/** Sync error (main -> renderer) */
|
|
59
|
+
readonly ERROR: "sql-storage:sync:error";
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Backup operation channels.
|
|
63
|
+
*/
|
|
64
|
+
export declare const BACKUP_CHANNELS: {
|
|
65
|
+
/** Trigger cloud backup */
|
|
66
|
+
readonly TRIGGER: "sql-storage:backup:trigger";
|
|
67
|
+
/** Backup progress (main -> renderer) */
|
|
68
|
+
readonly PROGRESS: "sql-storage:backup:progress";
|
|
69
|
+
/** Backup completed (main -> renderer) */
|
|
70
|
+
readonly COMPLETE: "sql-storage:backup:complete";
|
|
71
|
+
/** Restore from backup */
|
|
72
|
+
readonly RESTORE: "sql-storage:backup:restore";
|
|
73
|
+
/** List available backups */
|
|
74
|
+
readonly LIST: "sql-storage:backup:list";
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Recovery operation channels.
|
|
78
|
+
*/
|
|
79
|
+
export declare const RECOVERY_CHANNELS: {
|
|
80
|
+
/** Run integrity check */
|
|
81
|
+
readonly CHECK_INTEGRITY: "sql-storage:recovery:check-integrity";
|
|
82
|
+
/** Trigger WAL checkpoint */
|
|
83
|
+
readonly WAL_CHECKPOINT: "sql-storage:recovery:wal-checkpoint";
|
|
84
|
+
/** Repair database */
|
|
85
|
+
readonly REPAIR: "sql-storage:recovery:repair";
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Migration channels.
|
|
89
|
+
*/
|
|
90
|
+
export declare const MIGRATION_CHANNELS: {
|
|
91
|
+
/** Run pending migrations */
|
|
92
|
+
readonly RUN: "sql-storage:migration:run";
|
|
93
|
+
/** Get migration status */
|
|
94
|
+
readonly STATUS: "sql-storage:migration:status";
|
|
95
|
+
/** Rollback last migration */
|
|
96
|
+
readonly ROLLBACK: "sql-storage:migration:rollback";
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Broadcast channels (main -> all renderers).
|
|
100
|
+
*/
|
|
101
|
+
export declare const BROADCAST_CHANNELS: {
|
|
102
|
+
/** Database change notification */
|
|
103
|
+
readonly DB_CHANGE: "sql-storage:broadcast:db-change";
|
|
104
|
+
/** Connection state change */
|
|
105
|
+
readonly CONNECTION_STATE: "sql-storage:broadcast:connection-state";
|
|
106
|
+
/** Error notification */
|
|
107
|
+
readonly ERROR: "sql-storage:broadcast:error";
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* All IPC channels grouped by category.
|
|
111
|
+
*/
|
|
112
|
+
export declare const IPC_CHANNELS: {
|
|
113
|
+
readonly db: {
|
|
114
|
+
/** Execute a mutation (INSERT/UPDATE/DELETE) */
|
|
115
|
+
readonly RUN: "sql-storage:db:run";
|
|
116
|
+
/** Get a single row */
|
|
117
|
+
readonly GET: "sql-storage:db:get";
|
|
118
|
+
/** Get all matching rows */
|
|
119
|
+
readonly ALL: "sql-storage:db:all";
|
|
120
|
+
/** Execute a SQL script */
|
|
121
|
+
readonly EXEC: "sql-storage:db:exec";
|
|
122
|
+
/** Execute batch operations */
|
|
123
|
+
readonly BATCH: "sql-storage:db:batch";
|
|
124
|
+
/** Open database connection */
|
|
125
|
+
readonly OPEN: "sql-storage:db:open";
|
|
126
|
+
/** Close database connection */
|
|
127
|
+
readonly CLOSE: "sql-storage:db:close";
|
|
128
|
+
/** Check if database is open */
|
|
129
|
+
readonly IS_OPEN: "sql-storage:db:is-open";
|
|
130
|
+
/** Get adapter capabilities */
|
|
131
|
+
readonly CAPABILITIES: "sql-storage:db:capabilities";
|
|
132
|
+
};
|
|
133
|
+
readonly transaction: {
|
|
134
|
+
/** Begin a transaction */
|
|
135
|
+
readonly BEGIN: "sql-storage:transaction:begin";
|
|
136
|
+
/** Commit current transaction */
|
|
137
|
+
readonly COMMIT: "sql-storage:transaction:commit";
|
|
138
|
+
/** Rollback current transaction */
|
|
139
|
+
readonly ROLLBACK: "sql-storage:transaction:rollback";
|
|
140
|
+
/** Execute operation within transaction context */
|
|
141
|
+
readonly EXECUTE: "sql-storage:transaction:execute";
|
|
142
|
+
};
|
|
143
|
+
readonly sync: {
|
|
144
|
+
/** Get sync status */
|
|
145
|
+
readonly STATUS: "sql-storage:sync:status";
|
|
146
|
+
/** Trigger manual sync */
|
|
147
|
+
readonly TRIGGER: "sql-storage:sync:trigger";
|
|
148
|
+
/** Sync progress updates (main -> renderer) */
|
|
149
|
+
readonly PROGRESS: "sql-storage:sync:progress";
|
|
150
|
+
/** Sync completed (main -> renderer) */
|
|
151
|
+
readonly COMPLETE: "sql-storage:sync:complete";
|
|
152
|
+
/** Sync error (main -> renderer) */
|
|
153
|
+
readonly ERROR: "sql-storage:sync:error";
|
|
154
|
+
};
|
|
155
|
+
readonly backup: {
|
|
156
|
+
/** Trigger cloud backup */
|
|
157
|
+
readonly TRIGGER: "sql-storage:backup:trigger";
|
|
158
|
+
/** Backup progress (main -> renderer) */
|
|
159
|
+
readonly PROGRESS: "sql-storage:backup:progress";
|
|
160
|
+
/** Backup completed (main -> renderer) */
|
|
161
|
+
readonly COMPLETE: "sql-storage:backup:complete";
|
|
162
|
+
/** Restore from backup */
|
|
163
|
+
readonly RESTORE: "sql-storage:backup:restore";
|
|
164
|
+
/** List available backups */
|
|
165
|
+
readonly LIST: "sql-storage:backup:list";
|
|
166
|
+
};
|
|
167
|
+
readonly recovery: {
|
|
168
|
+
/** Run integrity check */
|
|
169
|
+
readonly CHECK_INTEGRITY: "sql-storage:recovery:check-integrity";
|
|
170
|
+
/** Trigger WAL checkpoint */
|
|
171
|
+
readonly WAL_CHECKPOINT: "sql-storage:recovery:wal-checkpoint";
|
|
172
|
+
/** Repair database */
|
|
173
|
+
readonly REPAIR: "sql-storage:recovery:repair";
|
|
174
|
+
};
|
|
175
|
+
readonly migration: {
|
|
176
|
+
/** Run pending migrations */
|
|
177
|
+
readonly RUN: "sql-storage:migration:run";
|
|
178
|
+
/** Get migration status */
|
|
179
|
+
readonly STATUS: "sql-storage:migration:status";
|
|
180
|
+
/** Rollback last migration */
|
|
181
|
+
readonly ROLLBACK: "sql-storage:migration:rollback";
|
|
182
|
+
};
|
|
183
|
+
readonly broadcast: {
|
|
184
|
+
/** Database change notification */
|
|
185
|
+
readonly DB_CHANGE: "sql-storage:broadcast:db-change";
|
|
186
|
+
/** Connection state change */
|
|
187
|
+
readonly CONNECTION_STATE: "sql-storage:broadcast:connection-state";
|
|
188
|
+
/** Error notification */
|
|
189
|
+
readonly ERROR: "sql-storage:broadcast:error";
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Union type of all channel values for type checking.
|
|
194
|
+
*/
|
|
195
|
+
export type IpcChannel = (typeof DB_CHANNELS)[keyof typeof DB_CHANNELS] | (typeof TRANSACTION_CHANNELS)[keyof typeof TRANSACTION_CHANNELS] | (typeof SYNC_CHANNELS)[keyof typeof SYNC_CHANNELS] | (typeof BACKUP_CHANNELS)[keyof typeof BACKUP_CHANNELS] | (typeof RECOVERY_CHANNELS)[keyof typeof RECOVERY_CHANNELS] | (typeof MIGRATION_CHANNELS)[keyof typeof MIGRATION_CHANNELS] | (typeof BROADCAST_CHANNELS)[keyof typeof BROADCAST_CHANNELS];
|
|
196
|
+
//# sourceMappingURL=channels.d.ts.map
|