@absolutejs/sync-capacitor 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -15
- package/dist/index.js.map +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,7 +46,8 @@ Signing back in as the same verified principal unlocks the same partition.
|
|
|
46
46
|
|
|
47
47
|
## Installed-data upgrades
|
|
48
48
|
|
|
49
|
-
`storageSchema` accepts the same generated `SyncLocalStoreSchema`
|
|
49
|
+
`storageSchema` accepts the same generated `SyncLocalStoreSchema` or
|
|
50
|
+
component bundle used by
|
|
50
51
|
`createIndexedDbSyncLocalStore`. Before any foreground transaction begins, the
|
|
51
52
|
adapter migrates every principal's collections, durable mutations, and logical
|
|
52
53
|
schema marker inside one SQLite transaction. A transform failure or process
|
|
@@ -80,6 +81,11 @@ const store = createCapacitorSyncLocalStore({
|
|
|
80
81
|
});
|
|
81
82
|
```
|
|
82
83
|
|
|
84
|
+
Absolute composes the app schema and every installed Sync pack into a
|
|
85
|
+
deterministic component bundle. SQLite tracks each component independently,
|
|
86
|
+
keeps removed-pack ledgers as orphan diagnostics, and migrates all records and
|
|
87
|
+
ledger updates in one transaction.
|
|
88
|
+
|
|
83
89
|
## Managed native background Sync
|
|
84
90
|
|
|
85
91
|
AbsoluteJS also configures `AbsoluteBackgroundSync` when the application uses
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SQLiteDBConnection } from '@capacitor-community/sqlite';
|
|
2
|
-
import type { SyncLocalStore,
|
|
2
|
+
import type { SyncLocalStore, SyncLocalStoreSchemaInput } from '@absolutejs/sync/client';
|
|
3
3
|
import type { DeviceLifecycleCapability, DeviceNetworkCapability, DeviceSubscription } from '@absolutejs/devices';
|
|
4
4
|
import type { SyncClient } from '@absolutejs/sync/client';
|
|
5
5
|
export type CapacitorBackgroundSyncConfig = {
|
|
@@ -38,7 +38,7 @@ export type CapacitorSyncLocalStoreOptions = {
|
|
|
38
38
|
/** Injection seam for tests and custom SQLCipher provisioning. */
|
|
39
39
|
connection?: CapacitorSyncSqliteFactory;
|
|
40
40
|
/** Same generated logical migration plan used by web IndexedDB. */
|
|
41
|
-
storageSchema?:
|
|
41
|
+
storageSchema?: SyncLocalStoreSchemaInput;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Native SQLite implementation of Sync's principal-partitioned atomic cache
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
SQLiteConnection
|
|
5
5
|
} from "@capacitor-community/sqlite";
|
|
6
6
|
import {
|
|
7
|
+
createSyncLocalSchemaStatus,
|
|
7
8
|
migrateSyncLocalCollectionRecord,
|
|
8
9
|
migrateSyncLocalMutationRecord,
|
|
9
|
-
|
|
10
|
+
resolveSyncLocalSchemaComponents
|
|
10
11
|
} from "@absolutejs/sync/client";
|
|
11
12
|
import { registerPlugin } from "@capacitor/core";
|
|
12
13
|
var AbsoluteBackgroundSync = registerPlugin("AbsoluteBackgroundSync");
|
|
@@ -16,6 +17,10 @@ CREATE TABLE IF NOT EXISTS absolute_sync_schema (
|
|
|
16
17
|
singleton_id INTEGER PRIMARY KEY NOT NULL CHECK (singleton_id = 1),
|
|
17
18
|
logical_version INTEGER NOT NULL
|
|
18
19
|
);
|
|
20
|
+
CREATE TABLE IF NOT EXISTS absolute_sync_schema_components (
|
|
21
|
+
component_id TEXT PRIMARY KEY NOT NULL,
|
|
22
|
+
logical_version INTEGER NOT NULL
|
|
23
|
+
);
|
|
19
24
|
CREATE TABLE IF NOT EXISTS absolute_sync_metadata (
|
|
20
25
|
namespace TEXT PRIMARY KEY NOT NULL,
|
|
21
26
|
installation_id TEXT NOT NULL
|
|
@@ -75,10 +80,19 @@ var createCapacitorSyncLocalStore = ({
|
|
|
75
80
|
const prepareSchema = async (database) => {
|
|
76
81
|
await database.beginTransaction();
|
|
77
82
|
try {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
83
|
+
const legacySaved = (await database.query("SELECT logical_version FROM absolute_sync_schema WHERE singleton_id = 1 LIMIT 1")).values?.[0]?.logical_version;
|
|
84
|
+
const componentRows = (await database.query("SELECT component_id, logical_version FROM absolute_sync_schema_components ORDER BY component_id")).values;
|
|
85
|
+
const storedVersions = {};
|
|
86
|
+
for (const row of componentRows ?? []) {
|
|
87
|
+
if (typeof row.component_id !== "string" || typeof row.logical_version !== "number")
|
|
88
|
+
throw new Error("Capacitor Sync SQLite returned an invalid schema component ledger.");
|
|
89
|
+
storedVersions[row.component_id] = row.logical_version;
|
|
90
|
+
}
|
|
91
|
+
if (storedVersions["@absolutejs/app"] === undefined && typeof legacySaved === "number")
|
|
92
|
+
storedVersions["@absolutejs/app"] = legacySaved;
|
|
93
|
+
const resolved = resolveSyncLocalSchemaComponents(storedVersions, storageSchema);
|
|
94
|
+
const steps = resolved.components.flatMap((component) => component.steps);
|
|
95
|
+
if (steps.length > 0) {
|
|
82
96
|
const collections = (await database.query("SELECT namespace, collection_key, record_json FROM absolute_sync_collections ORDER BY namespace, collection_key")).values;
|
|
83
97
|
for (const row of collections ?? []) {
|
|
84
98
|
const namespace = row.namespace;
|
|
@@ -88,7 +102,7 @@ var createCapacitorSyncLocalStore = ({
|
|
|
88
102
|
const record = parseRecord(row.record_json, "collection");
|
|
89
103
|
if (record === undefined)
|
|
90
104
|
throw new Error("Capacitor Sync SQLite returned a missing collection record.");
|
|
91
|
-
const migrated = migrateSyncLocalCollectionRecord(record, { key, namespace },
|
|
105
|
+
const migrated = migrateSyncLocalCollectionRecord(record, { key, namespace }, steps);
|
|
92
106
|
if (migrated === null)
|
|
93
107
|
await database.run("DELETE FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ?", [namespace, key], false);
|
|
94
108
|
else
|
|
@@ -103,7 +117,7 @@ var createCapacitorSyncLocalStore = ({
|
|
|
103
117
|
const record = parseRecord(row.record_json, "mutation");
|
|
104
118
|
if (record === undefined)
|
|
105
119
|
throw new Error("Capacitor Sync SQLite returned a missing mutation record.");
|
|
106
|
-
const migrated = migrateSyncLocalMutationRecord(record, { key: operationId, namespace },
|
|
120
|
+
const migrated = migrateSyncLocalMutationRecord(record, { key: operationId, namespace }, steps);
|
|
107
121
|
if (migrated === null)
|
|
108
122
|
await database.run("DELETE FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ?", [namespace, operationId], false);
|
|
109
123
|
else
|
|
@@ -115,14 +129,13 @@ var createCapacitorSyncLocalStore = ({
|
|
|
115
129
|
], false);
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
|
-
|
|
132
|
+
for (const component of resolved.components)
|
|
133
|
+
await database.run("INSERT INTO absolute_sync_schema_components (component_id, logical_version) VALUES (?, ?) ON CONFLICT(component_id) DO UPDATE SET logical_version = excluded.logical_version", [component.id, component.targetVersion], false);
|
|
134
|
+
const app = resolved.components.find((component) => component.id === "@absolutejs/app");
|
|
135
|
+
if (app !== undefined)
|
|
136
|
+
await database.run("INSERT INTO absolute_sync_schema (singleton_id, logical_version) VALUES (1, ?) ON CONFLICT(singleton_id) DO UPDATE SET logical_version = excluded.logical_version", [app.targetVersion], false);
|
|
119
137
|
await database.commitTransaction();
|
|
120
|
-
schemaStatus =
|
|
121
|
-
minimumCompatibleVersion: resolved.minimumCompatibleVersion,
|
|
122
|
-
state: "ready",
|
|
123
|
-
storedVersion: resolved.targetVersion,
|
|
124
|
-
targetVersion: resolved.targetVersion
|
|
125
|
-
};
|
|
138
|
+
schemaStatus = createSyncLocalSchemaStatus(resolved.components, resolved.orphanedComponents, "components" in storageSchema);
|
|
126
139
|
} catch (error) {
|
|
127
140
|
try {
|
|
128
141
|
await database.rollbackTransaction();
|
|
@@ -288,5 +301,5 @@ export {
|
|
|
288
301
|
AbsoluteBackgroundSync
|
|
289
302
|
};
|
|
290
303
|
|
|
291
|
-
//# debugId=
|
|
304
|
+
//# debugId=F21A450F9CF54D0C64756E2164756E21
|
|
292
305
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import {\n\tCapacitorSQLite,\n\tSQLiteConnection,\n\ttype SQLiteDBConnection\n} from '@capacitor-community/sqlite';\nimport type {\n\tLocalCollectionRecord,\n\tLocalMutationRecord,\n\tSyncLocalStore,\n\tSyncLocalStoreMode,\n\tSyncLocalStoreSchema,\n\tSyncLocalStoreSchemaStatus,\n\tSyncLocalTransaction\n} from '@absolutejs/sync/client';\nimport {\n\tmigrateSyncLocalCollectionRecord,\n\tmigrateSyncLocalMutationRecord,\n\tresolveSyncLocalMigrations\n} from '@absolutejs/sync/client';\nimport type {\n\tDeviceLifecycleCapability,\n\tDeviceNetworkCapability,\n\tDeviceSubscription\n} from '@absolutejs/devices';\nimport type { SyncClient } from '@absolutejs/sync/client';\nimport { registerPlugin } from '@capacitor/core';\n\nexport type CapacitorBackgroundSyncConfig = {\n\tendpoint: string;\n\tissuer: string;\n\tclientId: string;\n\tnamespace: string;\n\tdatabaseName?: string;\n\tintervalMinutes?: number;\n\tmaxMutations?: number;\n\tmaxPulls?: number;\n\tmaxAttempts?: number;\n};\n\nexport type CapacitorBackgroundSyncStatus = {\n\tconfigured: boolean;\n\trunning: boolean;\n\tlastRunAt?: number;\n\tlastError?: string;\n\tlastAcknowledged?: number;\n\tlastPulled?: number;\n};\n\nexport type AbsoluteBackgroundSyncPlugin = {\n\tconfigure(options: CapacitorBackgroundSyncConfig): Promise<void>;\n\tclear(): Promise<void>;\n\trunNow(): Promise<CapacitorBackgroundSyncStatus>;\n\tstatus(): Promise<CapacitorBackgroundSyncStatus>;\n};\n\nexport const AbsoluteBackgroundSync =\n\tregisterPlugin<AbsoluteBackgroundSyncPlugin>('AbsoluteBackgroundSync');\n\n/** Configure the managed scheduler. Auth credentials remain in the native vault. */\nexport const configureCapacitorBackgroundSync = (\n\toptions: CapacitorBackgroundSyncConfig,\n\tplugin: AbsoluteBackgroundSyncPlugin = AbsoluteBackgroundSync\n) => plugin.configure(options);\n\nexport type CapacitorSyncSqliteConnection = Pick<\n\tSQLiteDBConnection,\n\t| 'beginTransaction'\n\t| 'commitTransaction'\n\t| 'execute'\n\t| 'open'\n\t| 'query'\n\t| 'rollbackTransaction'\n\t| 'run'\n>;\n\nexport type CapacitorSyncSqliteFactory = () =>\n\t| CapacitorSyncSqliteConnection\n\t| Promise<CapacitorSyncSqliteConnection>;\n\nexport type CapacitorSyncLocalStoreOptions = {\n\t/** Defaults to `absolutejs-sync-local-v1`. */\n\tdatabaseName?: string;\n\t/** Injection seam for tests and custom SQLCipher provisioning. */\n\tconnection?: CapacitorSyncSqliteFactory;\n\t/** Same generated logical migration plan used by web IndexedDB. */\n\tstorageSchema?: SyncLocalStoreSchema;\n};\n\nconst SCHEMA = `\nCREATE TABLE IF NOT EXISTS absolute_sync_schema (\n singleton_id INTEGER PRIMARY KEY NOT NULL CHECK (singleton_id = 1),\n logical_version INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_metadata (\n namespace TEXT PRIMARY KEY NOT NULL,\n installation_id TEXT NOT NULL\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_collections (\n namespace TEXT NOT NULL,\n collection_key TEXT NOT NULL,\n record_json TEXT NOT NULL,\n PRIMARY KEY (namespace, collection_key)\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_mutations (\n namespace TEXT NOT NULL,\n operation_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n record_json TEXT NOT NULL,\n PRIMARY KEY (namespace, operation_id)\n);\nCREATE INDEX IF NOT EXISTS absolute_sync_mutations_order\n ON absolute_sync_mutations (namespace, created_at, operation_id);\n`;\n\ntype SqliteRow = Record<string, unknown>;\n\nconst firstString = (rows: SqliteRow[] | undefined, field: string) => {\n\tconst value = rows?.[0]?.[field];\n\treturn typeof value === 'string' ? value : undefined;\n};\n\nconst parseRecord = <T>(value: unknown, label: string): T | undefined => {\n\tif (value === undefined) return undefined;\n\tif (typeof value !== 'string')\n\t\tthrow new Error(\n\t\t\t`Capacitor Sync SQLite returned invalid ${label} JSON.`\n\t\t);\n\ttry {\n\t\treturn JSON.parse(value) as T;\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`Capacitor Sync SQLite could not parse ${label} JSON.`,\n\t\t\t{\n\t\t\t\tcause\n\t\t\t}\n\t\t);\n\t}\n};\n\nconst defaultConnection = async (\n\tdatabaseName: string\n): Promise<CapacitorSyncSqliteConnection> => {\n\tconst sqlite = new SQLiteConnection(CapacitorSQLite);\n\tconst existing = await sqlite.isConnection(databaseName, false);\n\tconst connection = existing.result\n\t\t? await sqlite.retrieveConnection(databaseName, false)\n\t\t: await sqlite.createConnection(\n\t\t\t\tdatabaseName,\n\t\t\t\tfalse,\n\t\t\t\t'no-encryption',\n\t\t\t\t1,\n\t\t\t\tfalse\n\t\t\t);\n\tawait connection.open();\n\treturn connection;\n};\n\nconst requireNamespace = (namespace: string) => {\n\tif (namespace.length === 0)\n\t\tthrow new Error('Sync local-store namespace must not be empty');\n};\n\n/**\n * Native SQLite implementation of Sync's principal-partitioned atomic cache\n * and mutation outbox. All calls are serialized because a Capacitor database\n * connection owns one explicit transaction at a time.\n */\nexport const createCapacitorSyncLocalStore = ({\n\tdatabaseName = 'absolutejs-sync-local-v1',\n\tconnection: createConnection = () => defaultConnection(databaseName),\n\tstorageSchema = { version: 1 }\n}: CapacitorSyncLocalStoreOptions = {}): SyncLocalStore => {\n\tif (databaseName.length === 0)\n\t\tthrow new TypeError('Capacitor Sync databaseName cannot be empty.');\n\tlet schemaStatus: SyncLocalStoreSchemaStatus | undefined;\n\tconst prepareSchema = async (\n\t\tdatabase: CapacitorSyncSqliteConnection\n\t): Promise<void> => {\n\t\tawait database.beginTransaction();\n\t\ttry {\n\t\t\tconst saved = (\n\t\t\t\tawait database.query(\n\t\t\t\t\t'SELECT logical_version FROM absolute_sync_schema WHERE singleton_id = 1 LIMIT 1'\n\t\t\t\t)\n\t\t\t).values?.[0]?.logical_version;\n\t\t\tconst storedVersion = typeof saved === 'number' ? saved : 1;\n\t\t\tconst resolved = resolveSyncLocalMigrations(\n\t\t\t\tstoredVersion,\n\t\t\t\tstorageSchema\n\t\t\t);\n\t\t\tif (resolved.steps.length > 0) {\n\t\t\t\tconst collections = (\n\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t'SELECT namespace, collection_key, record_json FROM absolute_sync_collections ORDER BY namespace, collection_key'\n\t\t\t\t\t)\n\t\t\t\t).values;\n\t\t\t\tfor (const row of collections ?? []) {\n\t\t\t\t\tconst namespace = row.namespace;\n\t\t\t\t\tconst key = row.collection_key;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof namespace !== 'string' ||\n\t\t\t\t\t\ttypeof key !== 'string'\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned an invalid collection identity.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst record = parseRecord<LocalCollectionRecord>(\n\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t'collection'\n\t\t\t\t\t);\n\t\t\t\t\tif (record === undefined)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned a missing collection record.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst migrated = migrateSyncLocalCollectionRecord(\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\t{ key, namespace },\n\t\t\t\t\t\tresolved.steps\n\t\t\t\t\t);\n\t\t\t\t\tif (migrated === null)\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'DELETE FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t\t[namespace, key],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\telse\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'UPDATE absolute_sync_collections SET record_json = ? WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t\t[JSON.stringify(migrated), namespace, key],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst mutations = (\n\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t'SELECT namespace, operation_id, record_json FROM absolute_sync_mutations ORDER BY namespace, operation_id'\n\t\t\t\t\t)\n\t\t\t\t).values;\n\t\t\t\tfor (const row of mutations ?? []) {\n\t\t\t\t\tconst namespace = row.namespace;\n\t\t\t\t\tconst operationId = row.operation_id;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof namespace !== 'string' ||\n\t\t\t\t\t\ttypeof operationId !== 'string'\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned an invalid mutation identity.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst record = parseRecord<LocalMutationRecord>(\n\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t'mutation'\n\t\t\t\t\t);\n\t\t\t\t\tif (record === undefined)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned a missing mutation record.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst migrated = migrateSyncLocalMutationRecord(\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\t{ key: operationId, namespace },\n\t\t\t\t\t\tresolved.steps\n\t\t\t\t\t);\n\t\t\t\t\tif (migrated === null)\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'DELETE FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t\t[namespace, operationId],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\telse\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'UPDATE absolute_sync_mutations SET created_at = ?, record_json = ? WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tmigrated.createdAt,\n\t\t\t\t\t\t\t\tJSON.stringify(migrated),\n\t\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\t\toperationId\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait database.run(\n\t\t\t\t'INSERT INTO absolute_sync_schema (singleton_id, logical_version) VALUES (1, ?) ON CONFLICT(singleton_id) DO UPDATE SET logical_version = excluded.logical_version',\n\t\t\t\t[resolved.targetVersion],\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tawait database.commitTransaction();\n\t\t\tschemaStatus = {\n\t\t\t\tminimumCompatibleVersion: resolved.minimumCompatibleVersion,\n\t\t\t\tstate: 'ready',\n\t\t\t\tstoredVersion: resolved.targetVersion,\n\t\t\t\ttargetVersion: resolved.targetVersion\n\t\t\t};\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait database.rollbackTransaction();\n\t\t\t} catch (rollbackError) {\n\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t[error, rollbackError],\n\t\t\t\t\t'Capacitor Sync SQLite migration and rollback both failed'\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t};\n\n\tlet connectionPromise: Promise<CapacitorSyncSqliteConnection> | undefined;\n\tconst connection = () => {\n\t\tconnectionPromise ??= Promise.resolve(createConnection()).then(\n\t\t\tasync (database) => {\n\t\t\t\tawait database.execute(SCHEMA);\n\t\t\t\tawait prepareSchema(database);\n\t\t\t\treturn database;\n\t\t\t}\n\t\t);\n\t\treturn connectionPromise;\n\t};\n\tlet tail = Promise.resolve();\n\tconst locked = async <R>(run: () => Promise<R>): Promise<R> => {\n\t\tlet release!: () => void;\n\t\tconst previous = tail;\n\t\ttail = new Promise<void>((resolve) => {\n\t\t\trelease = resolve;\n\t\t});\n\t\tawait previous;\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t};\n\n\tconst transaction = async <R>(\n\t\tnamespace: string,\n\t\tmode: SyncLocalStoreMode,\n\t\trun: (tx: SyncLocalTransaction) => Promise<R>\n\t): Promise<R> => {\n\t\trequireNamespace(namespace);\n\t\treturn locked(async () => {\n\t\t\tconst database = await connection();\n\t\t\tawait database.beginTransaction();\n\t\t\tconst writable = () => {\n\t\t\t\tif (mode !== 'readwrite')\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Cannot write in a readonly Sync local transaction'\n\t\t\t\t\t);\n\t\t\t};\n\t\t\tconst tx: SyncLocalTransaction = {\n\t\t\t\tgetInstallationId: async () =>\n\t\t\t\t\tfirstString(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT installation_id FROM absolute_sync_metadata WHERE namespace = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values,\n\t\t\t\t\t\t'installation_id'\n\t\t\t\t\t),\n\t\t\t\tsetInstallationId: async (installationId) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tif (installationId.length === 0)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Sync installation id must not be empty'\n\t\t\t\t\t\t);\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_metadata (namespace, installation_id) VALUES (?, ?) ON CONFLICT(namespace) DO UPDATE SET installation_id = excluded.installation_id',\n\t\t\t\t\t\t[namespace, installationId],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tgetCollection: async <T>(key: string) =>\n\t\t\t\t\tparseRecord<LocalCollectionRecord<T>>(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace, key]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values?.[0]?.record_json,\n\t\t\t\t\t\t'collection'\n\t\t\t\t\t),\n\t\t\t\tlistCollections: async () => {\n\t\t\t\t\tconst rows = (\n\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t'SELECT collection_key, record_json FROM absolute_sync_collections WHERE namespace = ? ORDER BY collection_key ASC',\n\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t)\n\t\t\t\t\t).values;\n\t\t\t\t\treturn (rows ?? [])\n\t\t\t\t\t\t.map((row) => {\n\t\t\t\t\t\t\tconst key = row.collection_key;\n\t\t\t\t\t\t\tconst record = parseRecord<LocalCollectionRecord>(\n\t\t\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t\t\t'collection'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn typeof key === 'string' && record\n\t\t\t\t\t\t\t\t? { key, record }\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tentry\n\t\t\t\t\t\t\t): entry is {\n\t\t\t\t\t\t\t\tkey: string;\n\t\t\t\t\t\t\t\trecord: LocalCollectionRecord;\n\t\t\t\t\t\t\t} => entry !== undefined\n\t\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tputCollection: async (key, record) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_collections (namespace, collection_key, record_json) VALUES (?, ?, ?) ON CONFLICT(namespace, collection_key) DO UPDATE SET record_json = excluded.record_json',\n\t\t\t\t\t\t[namespace, key, JSON.stringify(record)],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tdeleteCollection: async (key) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'DELETE FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t[namespace, key],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tlistMutations: async () => {\n\t\t\t\t\tconst rows = (\n\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_mutations WHERE namespace = ? ORDER BY created_at ASC, operation_id ASC',\n\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t)\n\t\t\t\t\t).values;\n\t\t\t\t\treturn (rows ?? [])\n\t\t\t\t\t\t.map((row) =>\n\t\t\t\t\t\t\tparseRecord<LocalMutationRecord>(\n\t\t\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t\t\t'mutation'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(record): record is LocalMutationRecord =>\n\t\t\t\t\t\t\t\trecord !== undefined\n\t\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tgetMutation: async (operationId) =>\n\t\t\t\t\tparseRecord<LocalMutationRecord>(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace, operationId]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values?.[0]?.record_json,\n\t\t\t\t\t\t'mutation'\n\t\t\t\t\t),\n\t\t\t\tputMutation: async (record) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_mutations (namespace, operation_id, created_at, record_json) VALUES (?, ?, ?, ?) ON CONFLICT(namespace, operation_id) DO UPDATE SET created_at = excluded.created_at, record_json = excluded.record_json',\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\trecord.operationId,\n\t\t\t\t\t\t\trecord.createdAt,\n\t\t\t\t\t\t\tJSON.stringify(record)\n\t\t\t\t\t\t],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tdeleteMutation: async (operationId) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'DELETE FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t[namespace, operationId],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst result = await run(tx);\n\t\t\t\tawait database.commitTransaction();\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait database.rollbackTransaction();\n\t\t\t\t} catch (rollbackError) {\n\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t[error, rollbackError],\n\t\t\t\t\t\t'Capacitor Sync SQLite transaction and rollback both failed'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t};\n\n\treturn {\n\t\ttransaction,\n\t\tgetSchemaStatus: async () => {\n\t\t\tawait connection();\n\t\t\tif (schemaStatus === undefined)\n\t\t\t\tthrow new Error('Capacitor Sync schema was not prepared.');\n\t\t\treturn { ...schemaStatus };\n\t\t},\n\t\tdeleteNamespace: async (namespace) => {\n\t\t\trequireNamespace(namespace);\n\t\t\tawait locked(async () => {\n\t\t\t\tconst database = await connection();\n\t\t\t\tawait database.beginTransaction();\n\t\t\t\ttry {\n\t\t\t\t\tfor (const table of [\n\t\t\t\t\t\t'absolute_sync_metadata',\n\t\t\t\t\t\t'absolute_sync_collections',\n\t\t\t\t\t\t'absolute_sync_mutations'\n\t\t\t\t\t])\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t`DELETE FROM ${table} WHERE namespace = ?`,\n\t\t\t\t\t\t\t[namespace],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\tawait database.commitTransaction();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait database.rollbackTransaction();\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n};\n\nexport type CapacitorSyncLifecycleOptions = {\n\tclient: Pick<SyncClient, 'reconnect'> & Partial<Pick<SyncClient, 'flush'>>;\n\tlifecycle: DeviceLifecycleCapability;\n\tnetwork: DeviceNetworkCapability;\n\t/** Finite outbox budget after a wake-up. Defaults to 10 seconds. */\n\tflushTimeoutMs?: number;\n\t/** Lifecycle flush failures are observable without becoming unhandled. */\n\tonError?: (error: unknown) => void;\n};\n\n/** Refreshes the socket/ticket and runs a bounded outbox flush after wake-up. */\nexport const installCapacitorSyncLifecycle = async ({\n\tclient,\n\tlifecycle,\n\tnetwork,\n\tflushTimeoutMs = 10_000,\n\tonError\n}: CapacitorSyncLifecycleOptions): Promise<DeviceSubscription> => {\n\tif (!Number.isFinite(flushTimeoutMs) || flushTimeoutMs < 0)\n\t\tthrow new TypeError(\n\t\t\t'Capacitor Sync flushTimeoutMs must be a non-negative number.'\n\t\t);\n\tconst wake = () => {\n\t\tclient.reconnect();\n\t\tvoid client\n\t\t\t.flush?.({ timeoutMs: flushTimeoutMs })\n\t\t\t.catch((error) => onError?.(error));\n\t};\n\tconst removers = await Promise.all([\n\t\tlifecycle.onResume?.(wake) ?? (() => undefined),\n\t\tnetwork.onChange((status) => {\n\t\t\tif (status.connected) wake();\n\t\t})\n\t]);\n\tlet active = true;\n\treturn async () => {\n\t\tif (!active) return;\n\t\tactive = false;\n\t\tawait Promise.all(removers.map((remove) => remove()));\n\t};\n};\n"
|
|
5
|
+
"import {\n\tCapacitorSQLite,\n\tSQLiteConnection,\n\ttype SQLiteDBConnection\n} from '@capacitor-community/sqlite';\nimport type {\n\tLocalCollectionRecord,\n\tLocalMutationRecord,\n\tSyncLocalStore,\n\tSyncLocalStoreMode,\n\tSyncLocalStoreSchemaInput,\n\tSyncLocalStoreSchemaStatus,\n\tSyncLocalTransaction\n} from '@absolutejs/sync/client';\nimport {\n\tcreateSyncLocalSchemaStatus,\n\tmigrateSyncLocalCollectionRecord,\n\tmigrateSyncLocalMutationRecord,\n\tresolveSyncLocalSchemaComponents\n} from '@absolutejs/sync/client';\nimport type {\n\tDeviceLifecycleCapability,\n\tDeviceNetworkCapability,\n\tDeviceSubscription\n} from '@absolutejs/devices';\nimport type { SyncClient } from '@absolutejs/sync/client';\nimport { registerPlugin } from '@capacitor/core';\n\nexport type CapacitorBackgroundSyncConfig = {\n\tendpoint: string;\n\tissuer: string;\n\tclientId: string;\n\tnamespace: string;\n\tdatabaseName?: string;\n\tintervalMinutes?: number;\n\tmaxMutations?: number;\n\tmaxPulls?: number;\n\tmaxAttempts?: number;\n};\n\nexport type CapacitorBackgroundSyncStatus = {\n\tconfigured: boolean;\n\trunning: boolean;\n\tlastRunAt?: number;\n\tlastError?: string;\n\tlastAcknowledged?: number;\n\tlastPulled?: number;\n};\n\nexport type AbsoluteBackgroundSyncPlugin = {\n\tconfigure(options: CapacitorBackgroundSyncConfig): Promise<void>;\n\tclear(): Promise<void>;\n\trunNow(): Promise<CapacitorBackgroundSyncStatus>;\n\tstatus(): Promise<CapacitorBackgroundSyncStatus>;\n};\n\nexport const AbsoluteBackgroundSync =\n\tregisterPlugin<AbsoluteBackgroundSyncPlugin>('AbsoluteBackgroundSync');\n\n/** Configure the managed scheduler. Auth credentials remain in the native vault. */\nexport const configureCapacitorBackgroundSync = (\n\toptions: CapacitorBackgroundSyncConfig,\n\tplugin: AbsoluteBackgroundSyncPlugin = AbsoluteBackgroundSync\n) => plugin.configure(options);\n\nexport type CapacitorSyncSqliteConnection = Pick<\n\tSQLiteDBConnection,\n\t| 'beginTransaction'\n\t| 'commitTransaction'\n\t| 'execute'\n\t| 'open'\n\t| 'query'\n\t| 'rollbackTransaction'\n\t| 'run'\n>;\n\nexport type CapacitorSyncSqliteFactory = () =>\n\t| CapacitorSyncSqliteConnection\n\t| Promise<CapacitorSyncSqliteConnection>;\n\nexport type CapacitorSyncLocalStoreOptions = {\n\t/** Defaults to `absolutejs-sync-local-v1`. */\n\tdatabaseName?: string;\n\t/** Injection seam for tests and custom SQLCipher provisioning. */\n\tconnection?: CapacitorSyncSqliteFactory;\n\t/** Same generated logical migration plan used by web IndexedDB. */\n\tstorageSchema?: SyncLocalStoreSchemaInput;\n};\n\nconst SCHEMA = `\nCREATE TABLE IF NOT EXISTS absolute_sync_schema (\n singleton_id INTEGER PRIMARY KEY NOT NULL CHECK (singleton_id = 1),\n logical_version INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_schema_components (\n component_id TEXT PRIMARY KEY NOT NULL,\n logical_version INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_metadata (\n namespace TEXT PRIMARY KEY NOT NULL,\n installation_id TEXT NOT NULL\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_collections (\n namespace TEXT NOT NULL,\n collection_key TEXT NOT NULL,\n record_json TEXT NOT NULL,\n PRIMARY KEY (namespace, collection_key)\n);\nCREATE TABLE IF NOT EXISTS absolute_sync_mutations (\n namespace TEXT NOT NULL,\n operation_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n record_json TEXT NOT NULL,\n PRIMARY KEY (namespace, operation_id)\n);\nCREATE INDEX IF NOT EXISTS absolute_sync_mutations_order\n ON absolute_sync_mutations (namespace, created_at, operation_id);\n`;\n\ntype SqliteRow = Record<string, unknown>;\n\nconst firstString = (rows: SqliteRow[] | undefined, field: string) => {\n\tconst value = rows?.[0]?.[field];\n\treturn typeof value === 'string' ? value : undefined;\n};\n\nconst parseRecord = <T>(value: unknown, label: string): T | undefined => {\n\tif (value === undefined) return undefined;\n\tif (typeof value !== 'string')\n\t\tthrow new Error(\n\t\t\t`Capacitor Sync SQLite returned invalid ${label} JSON.`\n\t\t);\n\ttry {\n\t\treturn JSON.parse(value) as T;\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`Capacitor Sync SQLite could not parse ${label} JSON.`,\n\t\t\t{\n\t\t\t\tcause\n\t\t\t}\n\t\t);\n\t}\n};\n\nconst defaultConnection = async (\n\tdatabaseName: string\n): Promise<CapacitorSyncSqliteConnection> => {\n\tconst sqlite = new SQLiteConnection(CapacitorSQLite);\n\tconst existing = await sqlite.isConnection(databaseName, false);\n\tconst connection = existing.result\n\t\t? await sqlite.retrieveConnection(databaseName, false)\n\t\t: await sqlite.createConnection(\n\t\t\t\tdatabaseName,\n\t\t\t\tfalse,\n\t\t\t\t'no-encryption',\n\t\t\t\t1,\n\t\t\t\tfalse\n\t\t\t);\n\tawait connection.open();\n\treturn connection;\n};\n\nconst requireNamespace = (namespace: string) => {\n\tif (namespace.length === 0)\n\t\tthrow new Error('Sync local-store namespace must not be empty');\n};\n\n/**\n * Native SQLite implementation of Sync's principal-partitioned atomic cache\n * and mutation outbox. All calls are serialized because a Capacitor database\n * connection owns one explicit transaction at a time.\n */\nexport const createCapacitorSyncLocalStore = ({\n\tdatabaseName = 'absolutejs-sync-local-v1',\n\tconnection: createConnection = () => defaultConnection(databaseName),\n\tstorageSchema = { version: 1 }\n}: CapacitorSyncLocalStoreOptions = {}): SyncLocalStore => {\n\tif (databaseName.length === 0)\n\t\tthrow new TypeError('Capacitor Sync databaseName cannot be empty.');\n\tlet schemaStatus: SyncLocalStoreSchemaStatus | undefined;\n\tconst prepareSchema = async (\n\t\tdatabase: CapacitorSyncSqliteConnection\n\t): Promise<void> => {\n\t\tawait database.beginTransaction();\n\t\ttry {\n\t\t\tconst legacySaved = (\n\t\t\t\tawait database.query(\n\t\t\t\t\t'SELECT logical_version FROM absolute_sync_schema WHERE singleton_id = 1 LIMIT 1'\n\t\t\t\t)\n\t\t\t).values?.[0]?.logical_version;\n\t\t\tconst componentRows = (\n\t\t\t\tawait database.query(\n\t\t\t\t\t'SELECT component_id, logical_version FROM absolute_sync_schema_components ORDER BY component_id'\n\t\t\t\t)\n\t\t\t).values;\n\t\t\tconst storedVersions: Record<string, number> = {};\n\t\t\tfor (const row of componentRows ?? []) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof row.component_id !== 'string' ||\n\t\t\t\t\ttypeof row.logical_version !== 'number'\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Capacitor Sync SQLite returned an invalid schema component ledger.'\n\t\t\t\t\t);\n\t\t\t\tstoredVersions[row.component_id] = row.logical_version;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tstoredVersions['@absolutejs/app'] === undefined &&\n\t\t\t\ttypeof legacySaved === 'number'\n\t\t\t)\n\t\t\t\tstoredVersions['@absolutejs/app'] = legacySaved;\n\t\t\tconst resolved = resolveSyncLocalSchemaComponents(\n\t\t\t\tstoredVersions,\n\t\t\t\tstorageSchema\n\t\t\t);\n\t\t\tconst steps = resolved.components.flatMap(\n\t\t\t\t(component) => component.steps\n\t\t\t);\n\t\t\tif (steps.length > 0) {\n\t\t\t\tconst collections = (\n\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t'SELECT namespace, collection_key, record_json FROM absolute_sync_collections ORDER BY namespace, collection_key'\n\t\t\t\t\t)\n\t\t\t\t).values;\n\t\t\t\tfor (const row of collections ?? []) {\n\t\t\t\t\tconst namespace = row.namespace;\n\t\t\t\t\tconst key = row.collection_key;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof namespace !== 'string' ||\n\t\t\t\t\t\ttypeof key !== 'string'\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned an invalid collection identity.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst record = parseRecord<LocalCollectionRecord>(\n\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t'collection'\n\t\t\t\t\t);\n\t\t\t\t\tif (record === undefined)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned a missing collection record.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst migrated = migrateSyncLocalCollectionRecord(\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\t{ key, namespace },\n\t\t\t\t\t\tsteps\n\t\t\t\t\t);\n\t\t\t\t\tif (migrated === null)\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'DELETE FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t\t[namespace, key],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\telse\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'UPDATE absolute_sync_collections SET record_json = ? WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t\t[JSON.stringify(migrated), namespace, key],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst mutations = (\n\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t'SELECT namespace, operation_id, record_json FROM absolute_sync_mutations ORDER BY namespace, operation_id'\n\t\t\t\t\t)\n\t\t\t\t).values;\n\t\t\t\tfor (const row of mutations ?? []) {\n\t\t\t\t\tconst namespace = row.namespace;\n\t\t\t\t\tconst operationId = row.operation_id;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof namespace !== 'string' ||\n\t\t\t\t\t\ttypeof operationId !== 'string'\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned an invalid mutation identity.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst record = parseRecord<LocalMutationRecord>(\n\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t'mutation'\n\t\t\t\t\t);\n\t\t\t\t\tif (record === undefined)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Capacitor Sync SQLite returned a missing mutation record.'\n\t\t\t\t\t\t);\n\t\t\t\t\tconst migrated = migrateSyncLocalMutationRecord(\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\t{ key: operationId, namespace },\n\t\t\t\t\t\tsteps\n\t\t\t\t\t);\n\t\t\t\t\tif (migrated === null)\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'DELETE FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t\t[namespace, operationId],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\telse\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t'UPDATE absolute_sync_mutations SET created_at = ?, record_json = ? WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tmigrated.createdAt,\n\t\t\t\t\t\t\t\tJSON.stringify(migrated),\n\t\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\t\toperationId\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const component of resolved.components)\n\t\t\t\tawait database.run(\n\t\t\t\t\t'INSERT INTO absolute_sync_schema_components (component_id, logical_version) VALUES (?, ?) ON CONFLICT(component_id) DO UPDATE SET logical_version = excluded.logical_version',\n\t\t\t\t\t[component.id, component.targetVersion],\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\tconst app = resolved.components.find(\n\t\t\t\t(component) => component.id === '@absolutejs/app'\n\t\t\t);\n\t\t\tif (app !== undefined)\n\t\t\t\tawait database.run(\n\t\t\t\t\t'INSERT INTO absolute_sync_schema (singleton_id, logical_version) VALUES (1, ?) ON CONFLICT(singleton_id) DO UPDATE SET logical_version = excluded.logical_version',\n\t\t\t\t\t[app.targetVersion],\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\tawait database.commitTransaction();\n\t\t\tschemaStatus = createSyncLocalSchemaStatus(\n\t\t\t\tresolved.components,\n\t\t\t\tresolved.orphanedComponents,\n\t\t\t\t'components' in storageSchema\n\t\t\t);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait database.rollbackTransaction();\n\t\t\t} catch (rollbackError) {\n\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t[error, rollbackError],\n\t\t\t\t\t'Capacitor Sync SQLite migration and rollback both failed'\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t};\n\n\tlet connectionPromise: Promise<CapacitorSyncSqliteConnection> | undefined;\n\tconst connection = () => {\n\t\tconnectionPromise ??= Promise.resolve(createConnection()).then(\n\t\t\tasync (database) => {\n\t\t\t\tawait database.execute(SCHEMA);\n\t\t\t\tawait prepareSchema(database);\n\t\t\t\treturn database;\n\t\t\t}\n\t\t);\n\t\treturn connectionPromise;\n\t};\n\tlet tail = Promise.resolve();\n\tconst locked = async <R>(run: () => Promise<R>): Promise<R> => {\n\t\tlet release!: () => void;\n\t\tconst previous = tail;\n\t\ttail = new Promise<void>((resolve) => {\n\t\t\trelease = resolve;\n\t\t});\n\t\tawait previous;\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t};\n\n\tconst transaction = async <R>(\n\t\tnamespace: string,\n\t\tmode: SyncLocalStoreMode,\n\t\trun: (tx: SyncLocalTransaction) => Promise<R>\n\t): Promise<R> => {\n\t\trequireNamespace(namespace);\n\t\treturn locked(async () => {\n\t\t\tconst database = await connection();\n\t\t\tawait database.beginTransaction();\n\t\t\tconst writable = () => {\n\t\t\t\tif (mode !== 'readwrite')\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Cannot write in a readonly Sync local transaction'\n\t\t\t\t\t);\n\t\t\t};\n\t\t\tconst tx: SyncLocalTransaction = {\n\t\t\t\tgetInstallationId: async () =>\n\t\t\t\t\tfirstString(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT installation_id FROM absolute_sync_metadata WHERE namespace = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values,\n\t\t\t\t\t\t'installation_id'\n\t\t\t\t\t),\n\t\t\t\tsetInstallationId: async (installationId) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tif (installationId.length === 0)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Sync installation id must not be empty'\n\t\t\t\t\t\t);\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_metadata (namespace, installation_id) VALUES (?, ?) ON CONFLICT(namespace) DO UPDATE SET installation_id = excluded.installation_id',\n\t\t\t\t\t\t[namespace, installationId],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tgetCollection: async <T>(key: string) =>\n\t\t\t\t\tparseRecord<LocalCollectionRecord<T>>(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace, key]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values?.[0]?.record_json,\n\t\t\t\t\t\t'collection'\n\t\t\t\t\t),\n\t\t\t\tlistCollections: async () => {\n\t\t\t\t\tconst rows = (\n\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t'SELECT collection_key, record_json FROM absolute_sync_collections WHERE namespace = ? ORDER BY collection_key ASC',\n\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t)\n\t\t\t\t\t).values;\n\t\t\t\t\treturn (rows ?? [])\n\t\t\t\t\t\t.map((row) => {\n\t\t\t\t\t\t\tconst key = row.collection_key;\n\t\t\t\t\t\t\tconst record = parseRecord<LocalCollectionRecord>(\n\t\t\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t\t\t'collection'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn typeof key === 'string' && record\n\t\t\t\t\t\t\t\t? { key, record }\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tentry\n\t\t\t\t\t\t\t): entry is {\n\t\t\t\t\t\t\t\tkey: string;\n\t\t\t\t\t\t\t\trecord: LocalCollectionRecord;\n\t\t\t\t\t\t\t} => entry !== undefined\n\t\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tputCollection: async (key, record) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_collections (namespace, collection_key, record_json) VALUES (?, ?, ?) ON CONFLICT(namespace, collection_key) DO UPDATE SET record_json = excluded.record_json',\n\t\t\t\t\t\t[namespace, key, JSON.stringify(record)],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tdeleteCollection: async (key) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'DELETE FROM absolute_sync_collections WHERE namespace = ? AND collection_key = ?',\n\t\t\t\t\t\t[namespace, key],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tlistMutations: async () => {\n\t\t\t\t\tconst rows = (\n\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_mutations WHERE namespace = ? ORDER BY created_at ASC, operation_id ASC',\n\t\t\t\t\t\t\t[namespace]\n\t\t\t\t\t\t)\n\t\t\t\t\t).values;\n\t\t\t\t\treturn (rows ?? [])\n\t\t\t\t\t\t.map((row) =>\n\t\t\t\t\t\t\tparseRecord<LocalMutationRecord>(\n\t\t\t\t\t\t\t\trow.record_json,\n\t\t\t\t\t\t\t\t'mutation'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(record): record is LocalMutationRecord =>\n\t\t\t\t\t\t\t\trecord !== undefined\n\t\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tgetMutation: async (operationId) =>\n\t\t\t\t\tparseRecord<LocalMutationRecord>(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait database.query(\n\t\t\t\t\t\t\t\t'SELECT record_json FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ? LIMIT 1',\n\t\t\t\t\t\t\t\t[namespace, operationId]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).values?.[0]?.record_json,\n\t\t\t\t\t\t'mutation'\n\t\t\t\t\t),\n\t\t\t\tputMutation: async (record) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'INSERT INTO absolute_sync_mutations (namespace, operation_id, created_at, record_json) VALUES (?, ?, ?, ?) ON CONFLICT(namespace, operation_id) DO UPDATE SET created_at = excluded.created_at, record_json = excluded.record_json',\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\trecord.operationId,\n\t\t\t\t\t\t\trecord.createdAt,\n\t\t\t\t\t\t\tJSON.stringify(record)\n\t\t\t\t\t\t],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tdeleteMutation: async (operationId) => {\n\t\t\t\t\twritable();\n\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t'DELETE FROM absolute_sync_mutations WHERE namespace = ? AND operation_id = ?',\n\t\t\t\t\t\t[namespace, operationId],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst result = await run(tx);\n\t\t\t\tawait database.commitTransaction();\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait database.rollbackTransaction();\n\t\t\t\t} catch (rollbackError) {\n\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t[error, rollbackError],\n\t\t\t\t\t\t'Capacitor Sync SQLite transaction and rollback both failed'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t};\n\n\treturn {\n\t\ttransaction,\n\t\tgetSchemaStatus: async () => {\n\t\t\tawait connection();\n\t\t\tif (schemaStatus === undefined)\n\t\t\t\tthrow new Error('Capacitor Sync schema was not prepared.');\n\t\t\treturn { ...schemaStatus };\n\t\t},\n\t\tdeleteNamespace: async (namespace) => {\n\t\t\trequireNamespace(namespace);\n\t\t\tawait locked(async () => {\n\t\t\t\tconst database = await connection();\n\t\t\t\tawait database.beginTransaction();\n\t\t\t\ttry {\n\t\t\t\t\tfor (const table of [\n\t\t\t\t\t\t'absolute_sync_metadata',\n\t\t\t\t\t\t'absolute_sync_collections',\n\t\t\t\t\t\t'absolute_sync_mutations'\n\t\t\t\t\t])\n\t\t\t\t\t\tawait database.run(\n\t\t\t\t\t\t\t`DELETE FROM ${table} WHERE namespace = ?`,\n\t\t\t\t\t\t\t[namespace],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\tawait database.commitTransaction();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait database.rollbackTransaction();\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n};\n\nexport type CapacitorSyncLifecycleOptions = {\n\tclient: Pick<SyncClient, 'reconnect'> & Partial<Pick<SyncClient, 'flush'>>;\n\tlifecycle: DeviceLifecycleCapability;\n\tnetwork: DeviceNetworkCapability;\n\t/** Finite outbox budget after a wake-up. Defaults to 10 seconds. */\n\tflushTimeoutMs?: number;\n\t/** Lifecycle flush failures are observable without becoming unhandled. */\n\tonError?: (error: unknown) => void;\n};\n\n/** Refreshes the socket/ticket and runs a bounded outbox flush after wake-up. */\nexport const installCapacitorSyncLifecycle = async ({\n\tclient,\n\tlifecycle,\n\tnetwork,\n\tflushTimeoutMs = 10_000,\n\tonError\n}: CapacitorSyncLifecycleOptions): Promise<DeviceSubscription> => {\n\tif (!Number.isFinite(flushTimeoutMs) || flushTimeoutMs < 0)\n\t\tthrow new TypeError(\n\t\t\t'Capacitor Sync flushTimeoutMs must be a non-negative number.'\n\t\t);\n\tconst wake = () => {\n\t\tclient.reconnect();\n\t\tvoid client\n\t\t\t.flush?.({ timeoutMs: flushTimeoutMs })\n\t\t\t.catch((error) => onError?.(error));\n\t};\n\tconst removers = await Promise.all([\n\t\tlifecycle.onResume?.(wake) ?? (() => undefined),\n\t\tnetwork.onChange((status) => {\n\t\t\tif (status.connected) wake();\n\t\t})\n\t]);\n\tlet active = true;\n\treturn async () => {\n\t\tif (!active) return;\n\t\tactive = false;\n\t\tawait Promise.all(removers.map((remove) => remove()));\n\t};\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAAA;AAAA;AAAA;AAAA;AAcA;AAAA;AAAA;AAAA;AAAA;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAAA;AAAA;AAAA;AAAA;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AA8BO,IAAM,yBACZ,eAA6C,wBAAwB;AAG/D,IAAM,mCAAmC,CAC/C,SACA,SAAuC,2BACnC,OAAO,UAAU,OAAO;AA0B7B,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCf,IAAM,cAAc,CAAC,MAA+B,UAAkB;AAAA,EACrE,MAAM,QAAQ,OAAO,KAAK;AAAA,EAC1B,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA;AAG5C,IAAM,cAAc,CAAI,OAAgB,UAAiC;AAAA,EACxE,IAAI,UAAU;AAAA,IAAW;AAAA,EACzB,IAAI,OAAO,UAAU;AAAA,IACpB,MAAM,IAAI,MACT,0CAA0C,a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
|
|
8
|
+
"debugId": "F21A450F9CF54D0C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/sync-capacitor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Transactional Capacitor SQLite local store and native lifecycle adapter for @absolutejs/sync",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@absolutejs/devices": ">=0.0.3 <0.1.0",
|
|
40
40
|
"@absolutejs/devices-capacitor": ">=0.1.3 <0.2.0",
|
|
41
|
-
"@absolutejs/sync": ">=2.
|
|
41
|
+
"@absolutejs/sync": ">=2.26.0 <3",
|
|
42
42
|
"@capacitor/core": ">=8 <9",
|
|
43
43
|
"@capacitor-community/sqlite": ">=8.1.1 <9"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@absolutejs/devices": "0.0.3",
|
|
47
47
|
"@absolutejs/devices-capacitor": "0.1.3",
|
|
48
|
-
"@absolutejs/sync": "2.
|
|
48
|
+
"@absolutejs/sync": "2.26.0",
|
|
49
49
|
"@capacitor/core": "8.5.0",
|
|
50
50
|
"@capacitor-community/sqlite": "8.1.1",
|
|
51
51
|
"@types/bun": "1.3.14",
|