@tanstack/expo-db-sqlite-persistence 0.1.11 → 0.2.1
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/dist/cjs/expo.cjs +2 -2
- package/dist/cjs/expo.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/expo.js +3 -3
- package/dist/esm/expo.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +3 -1
- package/package.json +2 -2
- package/src/expo.ts +7 -2
- package/src/index.ts +5 -1
package/dist/cjs/expo.cjs
CHANGED
|
@@ -25,8 +25,8 @@ function createInternalSQLiteDriver(options) {
|
|
|
25
25
|
}
|
|
26
26
|
function resolveAdapterBaseOptions(options) {
|
|
27
27
|
return {
|
|
28
|
-
appliedTxPruneMaxRows: options.appliedTxPruneMaxRows,
|
|
29
|
-
appliedTxPruneMaxAgeSeconds: options.appliedTxPruneMaxAgeSeconds,
|
|
28
|
+
appliedTxPruneMaxRows: options.appliedTxPruneMaxRows ?? dbSqlitePersistenceCore.DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
29
|
+
appliedTxPruneMaxAgeSeconds: options.appliedTxPruneMaxAgeSeconds ?? dbSqlitePersistenceCore.DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
30
30
|
pullSinceReloadThreshold: options.pullSinceReloadThreshold
|
|
31
31
|
};
|
|
32
32
|
}
|
package/dist/cjs/expo.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.cjs","sources":["../../src/expo.ts"],"sourcesContent":["import {\n SingleProcessCoordinator,\n createSQLiteCorePersistenceAdapter,\n} from '@tanstack/db-sqlite-persistence-core'\nimport { ExpoSQLiteDriver } from './expo-sqlite-driver'\nimport type {\n PersistedCollectionCoordinator,\n PersistedCollectionMode,\n PersistedCollectionPersistence,\n SQLiteCoreAdapterOptions,\n SQLiteDriver,\n} from '@tanstack/db-sqlite-persistence-core'\nimport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\nexport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\ntype ExpoSQLiteCoreSchemaMismatchPolicy =\n | `sync-present-reset`\n | `sync-absent-error`\n | `reset`\n\nexport type ExpoSQLiteSchemaMismatchPolicy =\n | ExpoSQLiteCoreSchemaMismatchPolicy\n | `throw`\n\nexport type ExpoSQLitePersistenceOptions = Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> & {\n database: ExpoSQLiteDatabaseLike\n coordinator?: PersistedCollectionCoordinator\n schemaMismatchPolicy?: ExpoSQLiteSchemaMismatchPolicy\n}\n\nfunction normalizeSchemaMismatchPolicy(\n policy: ExpoSQLiteSchemaMismatchPolicy,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (policy === `throw`) {\n return `sync-absent-error`\n }\n\n return policy\n}\n\nfunction resolveSchemaMismatchPolicy(\n explicitPolicy: ExpoSQLiteSchemaMismatchPolicy | undefined,\n mode: PersistedCollectionMode,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (explicitPolicy) {\n return normalizeSchemaMismatchPolicy(explicitPolicy)\n }\n\n return mode === `sync-present` ? `sync-present-reset` : `sync-absent-error`\n}\n\nfunction createAdapterCacheKey(\n schemaMismatchPolicy: ExpoSQLiteCoreSchemaMismatchPolicy,\n schemaVersion: number | undefined,\n): string {\n const schemaVersionKey =\n schemaVersion === undefined ? `schema:default` : `schema:${schemaVersion}`\n return `${schemaMismatchPolicy}|${schemaVersionKey}`\n}\n\nfunction createInternalSQLiteDriver(\n options: ExpoSQLitePersistenceOptions,\n): SQLiteDriver {\n return new ExpoSQLiteDriver({\n database: options.database,\n })\n}\n\nfunction resolveAdapterBaseOptions(\n options: ExpoSQLitePersistenceOptions,\n): Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> {\n return {\n appliedTxPruneMaxRows
|
|
1
|
+
{"version":3,"file":"expo.cjs","sources":["../../src/expo.ts"],"sourcesContent":["import {\n DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,\n DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,\n SingleProcessCoordinator,\n createSQLiteCorePersistenceAdapter,\n} from '@tanstack/db-sqlite-persistence-core'\nimport { ExpoSQLiteDriver } from './expo-sqlite-driver'\nimport type {\n PersistedCollectionCoordinator,\n PersistedCollectionMode,\n PersistedCollectionPersistence,\n SQLiteCoreAdapterOptions,\n SQLiteDriver,\n} from '@tanstack/db-sqlite-persistence-core'\nimport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\nexport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\ntype ExpoSQLiteCoreSchemaMismatchPolicy =\n | `sync-present-reset`\n | `sync-absent-error`\n | `reset`\n\nexport type ExpoSQLiteSchemaMismatchPolicy =\n | ExpoSQLiteCoreSchemaMismatchPolicy\n | `throw`\n\nexport type ExpoSQLitePersistenceOptions = Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> & {\n database: ExpoSQLiteDatabaseLike\n coordinator?: PersistedCollectionCoordinator\n schemaMismatchPolicy?: ExpoSQLiteSchemaMismatchPolicy\n}\n\nfunction normalizeSchemaMismatchPolicy(\n policy: ExpoSQLiteSchemaMismatchPolicy,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (policy === `throw`) {\n return `sync-absent-error`\n }\n\n return policy\n}\n\nfunction resolveSchemaMismatchPolicy(\n explicitPolicy: ExpoSQLiteSchemaMismatchPolicy | undefined,\n mode: PersistedCollectionMode,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (explicitPolicy) {\n return normalizeSchemaMismatchPolicy(explicitPolicy)\n }\n\n return mode === `sync-present` ? `sync-present-reset` : `sync-absent-error`\n}\n\nfunction createAdapterCacheKey(\n schemaMismatchPolicy: ExpoSQLiteCoreSchemaMismatchPolicy,\n schemaVersion: number | undefined,\n): string {\n const schemaVersionKey =\n schemaVersion === undefined ? `schema:default` : `schema:${schemaVersion}`\n return `${schemaMismatchPolicy}|${schemaVersionKey}`\n}\n\nfunction createInternalSQLiteDriver(\n options: ExpoSQLitePersistenceOptions,\n): SQLiteDriver {\n return new ExpoSQLiteDriver({\n database: options.database,\n })\n}\n\nfunction resolveAdapterBaseOptions(\n options: ExpoSQLitePersistenceOptions,\n): Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> {\n return {\n appliedTxPruneMaxRows:\n options.appliedTxPruneMaxRows ?? DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,\n appliedTxPruneMaxAgeSeconds:\n options.appliedTxPruneMaxAgeSeconds ??\n DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,\n pullSinceReloadThreshold: options.pullSinceReloadThreshold,\n }\n}\n\nexport function createExpoSQLitePersistence(\n options: ExpoSQLitePersistenceOptions,\n): PersistedCollectionPersistence {\n const { coordinator, schemaMismatchPolicy } = options\n const driver = createInternalSQLiteDriver(options)\n const adapterBaseOptions = resolveAdapterBaseOptions(options)\n const resolvedCoordinator = coordinator ?? new SingleProcessCoordinator()\n const adapterCache = new Map<\n string,\n ReturnType<typeof createSQLiteCorePersistenceAdapter>\n >()\n\n const getAdapterForCollection = (\n mode: PersistedCollectionMode,\n schemaVersion: number | undefined,\n ) => {\n const resolvedSchemaMismatchPolicy = resolveSchemaMismatchPolicy(\n schemaMismatchPolicy,\n mode,\n )\n const cacheKey = createAdapterCacheKey(\n resolvedSchemaMismatchPolicy,\n schemaVersion,\n )\n const cachedAdapter = adapterCache.get(cacheKey)\n if (cachedAdapter) {\n return cachedAdapter\n }\n\n const adapter = createSQLiteCorePersistenceAdapter({\n ...adapterBaseOptions,\n driver,\n schemaMismatchPolicy: resolvedSchemaMismatchPolicy,\n ...(schemaVersion === undefined ? {} : { schemaVersion }),\n })\n adapterCache.set(cacheKey, adapter)\n return adapter\n }\n\n const createCollectionPersistence = (\n mode: PersistedCollectionMode,\n schemaVersion: number | undefined,\n ): PersistedCollectionPersistence => ({\n adapter: getAdapterForCollection(mode, schemaVersion),\n coordinator: resolvedCoordinator,\n })\n\n const defaultPersistence = createCollectionPersistence(\n `sync-absent`,\n undefined,\n )\n\n return {\n ...defaultPersistence,\n resolvePersistenceForCollection: ({ mode, schemaVersion }) =>\n createCollectionPersistence(mode, schemaVersion),\n resolvePersistenceForMode: (mode) =>\n createCollectionPersistence(mode, undefined),\n }\n}\n"],"names":["ExpoSQLiteDriver","DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS","DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS","SingleProcessCoordinator","createSQLiteCorePersistenceAdapter"],"mappings":";;;;AAoCA,SAAS,8BACP,QACoC;AACpC,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,SAAS,4BACP,gBACA,MACoC;AACpC,MAAI,gBAAgB;AAClB,WAAO,8BAA8B,cAAc;AAAA,EACrD;AAEA,SAAO,SAAS,iBAAiB,uBAAuB;AAC1D;AAEA,SAAS,sBACP,sBACA,eACQ;AACR,QAAM,mBACJ,kBAAkB,SAAY,mBAAmB,UAAU,aAAa;AAC1E,SAAO,GAAG,oBAAoB,IAAI,gBAAgB;AACpD;AAEA,SAAS,2BACP,SACc;AACd,SAAO,IAAIA,iBAAAA,iBAAiB;AAAA,IAC1B,UAAU,QAAQ;AAAA,EAAA,CACnB;AACH;AAEA,SAAS,0BACP,SAIA;AACA,SAAO;AAAA,IACL,uBACE,QAAQ,yBAAyBC,wBAAAA;AAAAA,IACnC,6BACE,QAAQ,+BACRC,wBAAAA;AAAAA,IACF,0BAA0B,QAAQ;AAAA,EAAA;AAEtC;AAEO,SAAS,4BACd,SACgC;AAChC,QAAM,EAAE,aAAa,qBAAA,IAAyB;AAC9C,QAAM,SAAS,2BAA2B,OAAO;AACjD,QAAM,qBAAqB,0BAA0B,OAAO;AAC5D,QAAM,sBAAsB,eAAe,IAAIC,iDAAA;AAC/C,QAAM,mCAAmB,IAAA;AAKzB,QAAM,0BAA0B,CAC9B,MACA,kBACG;AACH,UAAM,+BAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IAAA;AAEF,UAAM,WAAW;AAAA,MACf;AAAA,MACA;AAAA,IAAA;AAEF,UAAM,gBAAgB,aAAa,IAAI,QAAQ;AAC/C,QAAI,eAAe;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,UAAUC,wBAAAA,mCAAmC;AAAA,MACjD,GAAG;AAAA,MACH;AAAA,MACA,sBAAsB;AAAA,MACtB,GAAI,kBAAkB,SAAY,CAAA,IAAK,EAAE,cAAA;AAAA,IAAc,CACxD;AACD,iBAAa,IAAI,UAAU,OAAO;AAClC,WAAO;AAAA,EACT;AAEA,QAAM,8BAA8B,CAClC,MACA,mBACoC;AAAA,IACpC,SAAS,wBAAwB,MAAM,aAAa;AAAA,IACpD,aAAa;AAAA,EAAA;AAGf,QAAM,qBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,iCAAiC,CAAC,EAAE,MAAM,oBACxC,4BAA4B,MAAM,aAAa;AAAA,IACjD,2BAA2B,CAAC,SAC1B,4BAA4B,MAAM,MAAS;AAAA,EAAA;AAEjD;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const expo = require("./expo.cjs");
|
|
4
4
|
const dbSqlitePersistenceCore = require("@tanstack/db-sqlite-persistence-core");
|
|
5
5
|
exports.createExpoSQLitePersistence = expo.createExpoSQLitePersistence;
|
|
6
|
+
Object.defineProperty(exports, "DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: () => dbSqlitePersistenceCore.DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, "DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => dbSqlitePersistenceCore.DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS
|
|
13
|
+
});
|
|
6
14
|
Object.defineProperty(exports, "persistedCollectionOptions", {
|
|
7
15
|
enumerable: true,
|
|
8
16
|
get: () => dbSqlitePersistenceCore.persistedCollectionOptions
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createExpoSQLitePersistence } from './expo.cjs';
|
|
2
2
|
export type { ExpoSQLiteDatabaseLike, ExpoSQLitePersistenceOptions, ExpoSQLiteSchemaMismatchPolicy, } from './expo.cjs';
|
|
3
|
-
export { persistedCollectionOptions } from '@tanstack/db-sqlite-persistence-core';
|
|
3
|
+
export { DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS, DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS, persistedCollectionOptions, } from '@tanstack/db-sqlite-persistence-core';
|
|
4
4
|
export type { PersistedCollectionCoordinator, PersistedCollectionPersistence, } from '@tanstack/db-sqlite-persistence-core';
|
package/dist/esm/expo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SingleProcessCoordinator, createSQLiteCorePersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
|
|
1
|
+
import { SingleProcessCoordinator, createSQLiteCorePersistenceAdapter, DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS, DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS } from "@tanstack/db-sqlite-persistence-core";
|
|
2
2
|
import { ExpoSQLiteDriver } from "./expo-sqlite-driver.js";
|
|
3
3
|
function normalizeSchemaMismatchPolicy(policy) {
|
|
4
4
|
if (policy === `throw`) {
|
|
@@ -23,8 +23,8 @@ function createInternalSQLiteDriver(options) {
|
|
|
23
23
|
}
|
|
24
24
|
function resolveAdapterBaseOptions(options) {
|
|
25
25
|
return {
|
|
26
|
-
appliedTxPruneMaxRows: options.appliedTxPruneMaxRows,
|
|
27
|
-
appliedTxPruneMaxAgeSeconds: options.appliedTxPruneMaxAgeSeconds,
|
|
26
|
+
appliedTxPruneMaxRows: options.appliedTxPruneMaxRows ?? DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
27
|
+
appliedTxPruneMaxAgeSeconds: options.appliedTxPruneMaxAgeSeconds ?? DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
28
28
|
pullSinceReloadThreshold: options.pullSinceReloadThreshold
|
|
29
29
|
};
|
|
30
30
|
}
|
package/dist/esm/expo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.js","sources":["../../src/expo.ts"],"sourcesContent":["import {\n SingleProcessCoordinator,\n createSQLiteCorePersistenceAdapter,\n} from '@tanstack/db-sqlite-persistence-core'\nimport { ExpoSQLiteDriver } from './expo-sqlite-driver'\nimport type {\n PersistedCollectionCoordinator,\n PersistedCollectionMode,\n PersistedCollectionPersistence,\n SQLiteCoreAdapterOptions,\n SQLiteDriver,\n} from '@tanstack/db-sqlite-persistence-core'\nimport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\nexport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\ntype ExpoSQLiteCoreSchemaMismatchPolicy =\n | `sync-present-reset`\n | `sync-absent-error`\n | `reset`\n\nexport type ExpoSQLiteSchemaMismatchPolicy =\n | ExpoSQLiteCoreSchemaMismatchPolicy\n | `throw`\n\nexport type ExpoSQLitePersistenceOptions = Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> & {\n database: ExpoSQLiteDatabaseLike\n coordinator?: PersistedCollectionCoordinator\n schemaMismatchPolicy?: ExpoSQLiteSchemaMismatchPolicy\n}\n\nfunction normalizeSchemaMismatchPolicy(\n policy: ExpoSQLiteSchemaMismatchPolicy,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (policy === `throw`) {\n return `sync-absent-error`\n }\n\n return policy\n}\n\nfunction resolveSchemaMismatchPolicy(\n explicitPolicy: ExpoSQLiteSchemaMismatchPolicy | undefined,\n mode: PersistedCollectionMode,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (explicitPolicy) {\n return normalizeSchemaMismatchPolicy(explicitPolicy)\n }\n\n return mode === `sync-present` ? `sync-present-reset` : `sync-absent-error`\n}\n\nfunction createAdapterCacheKey(\n schemaMismatchPolicy: ExpoSQLiteCoreSchemaMismatchPolicy,\n schemaVersion: number | undefined,\n): string {\n const schemaVersionKey =\n schemaVersion === undefined ? `schema:default` : `schema:${schemaVersion}`\n return `${schemaMismatchPolicy}|${schemaVersionKey}`\n}\n\nfunction createInternalSQLiteDriver(\n options: ExpoSQLitePersistenceOptions,\n): SQLiteDriver {\n return new ExpoSQLiteDriver({\n database: options.database,\n })\n}\n\nfunction resolveAdapterBaseOptions(\n options: ExpoSQLitePersistenceOptions,\n): Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> {\n return {\n appliedTxPruneMaxRows
|
|
1
|
+
{"version":3,"file":"expo.js","sources":["../../src/expo.ts"],"sourcesContent":["import {\n DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,\n DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,\n SingleProcessCoordinator,\n createSQLiteCorePersistenceAdapter,\n} from '@tanstack/db-sqlite-persistence-core'\nimport { ExpoSQLiteDriver } from './expo-sqlite-driver'\nimport type {\n PersistedCollectionCoordinator,\n PersistedCollectionMode,\n PersistedCollectionPersistence,\n SQLiteCoreAdapterOptions,\n SQLiteDriver,\n} from '@tanstack/db-sqlite-persistence-core'\nimport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\nexport type { ExpoSQLiteDatabaseLike } from './expo-sqlite-driver'\n\ntype ExpoSQLiteCoreSchemaMismatchPolicy =\n | `sync-present-reset`\n | `sync-absent-error`\n | `reset`\n\nexport type ExpoSQLiteSchemaMismatchPolicy =\n | ExpoSQLiteCoreSchemaMismatchPolicy\n | `throw`\n\nexport type ExpoSQLitePersistenceOptions = Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> & {\n database: ExpoSQLiteDatabaseLike\n coordinator?: PersistedCollectionCoordinator\n schemaMismatchPolicy?: ExpoSQLiteSchemaMismatchPolicy\n}\n\nfunction normalizeSchemaMismatchPolicy(\n policy: ExpoSQLiteSchemaMismatchPolicy,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (policy === `throw`) {\n return `sync-absent-error`\n }\n\n return policy\n}\n\nfunction resolveSchemaMismatchPolicy(\n explicitPolicy: ExpoSQLiteSchemaMismatchPolicy | undefined,\n mode: PersistedCollectionMode,\n): ExpoSQLiteCoreSchemaMismatchPolicy {\n if (explicitPolicy) {\n return normalizeSchemaMismatchPolicy(explicitPolicy)\n }\n\n return mode === `sync-present` ? `sync-present-reset` : `sync-absent-error`\n}\n\nfunction createAdapterCacheKey(\n schemaMismatchPolicy: ExpoSQLiteCoreSchemaMismatchPolicy,\n schemaVersion: number | undefined,\n): string {\n const schemaVersionKey =\n schemaVersion === undefined ? `schema:default` : `schema:${schemaVersion}`\n return `${schemaMismatchPolicy}|${schemaVersionKey}`\n}\n\nfunction createInternalSQLiteDriver(\n options: ExpoSQLitePersistenceOptions,\n): SQLiteDriver {\n return new ExpoSQLiteDriver({\n database: options.database,\n })\n}\n\nfunction resolveAdapterBaseOptions(\n options: ExpoSQLitePersistenceOptions,\n): Omit<\n SQLiteCoreAdapterOptions,\n `driver` | `schemaVersion` | `schemaMismatchPolicy`\n> {\n return {\n appliedTxPruneMaxRows:\n options.appliedTxPruneMaxRows ?? DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,\n appliedTxPruneMaxAgeSeconds:\n options.appliedTxPruneMaxAgeSeconds ??\n DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,\n pullSinceReloadThreshold: options.pullSinceReloadThreshold,\n }\n}\n\nexport function createExpoSQLitePersistence(\n options: ExpoSQLitePersistenceOptions,\n): PersistedCollectionPersistence {\n const { coordinator, schemaMismatchPolicy } = options\n const driver = createInternalSQLiteDriver(options)\n const adapterBaseOptions = resolveAdapterBaseOptions(options)\n const resolvedCoordinator = coordinator ?? new SingleProcessCoordinator()\n const adapterCache = new Map<\n string,\n ReturnType<typeof createSQLiteCorePersistenceAdapter>\n >()\n\n const getAdapterForCollection = (\n mode: PersistedCollectionMode,\n schemaVersion: number | undefined,\n ) => {\n const resolvedSchemaMismatchPolicy = resolveSchemaMismatchPolicy(\n schemaMismatchPolicy,\n mode,\n )\n const cacheKey = createAdapterCacheKey(\n resolvedSchemaMismatchPolicy,\n schemaVersion,\n )\n const cachedAdapter = adapterCache.get(cacheKey)\n if (cachedAdapter) {\n return cachedAdapter\n }\n\n const adapter = createSQLiteCorePersistenceAdapter({\n ...adapterBaseOptions,\n driver,\n schemaMismatchPolicy: resolvedSchemaMismatchPolicy,\n ...(schemaVersion === undefined ? {} : { schemaVersion }),\n })\n adapterCache.set(cacheKey, adapter)\n return adapter\n }\n\n const createCollectionPersistence = (\n mode: PersistedCollectionMode,\n schemaVersion: number | undefined,\n ): PersistedCollectionPersistence => ({\n adapter: getAdapterForCollection(mode, schemaVersion),\n coordinator: resolvedCoordinator,\n })\n\n const defaultPersistence = createCollectionPersistence(\n `sync-absent`,\n undefined,\n )\n\n return {\n ...defaultPersistence,\n resolvePersistenceForCollection: ({ mode, schemaVersion }) =>\n createCollectionPersistence(mode, schemaVersion),\n resolvePersistenceForMode: (mode) =>\n createCollectionPersistence(mode, undefined),\n }\n}\n"],"names":[],"mappings":";;AAoCA,SAAS,8BACP,QACoC;AACpC,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,SAAS,4BACP,gBACA,MACoC;AACpC,MAAI,gBAAgB;AAClB,WAAO,8BAA8B,cAAc;AAAA,EACrD;AAEA,SAAO,SAAS,iBAAiB,uBAAuB;AAC1D;AAEA,SAAS,sBACP,sBACA,eACQ;AACR,QAAM,mBACJ,kBAAkB,SAAY,mBAAmB,UAAU,aAAa;AAC1E,SAAO,GAAG,oBAAoB,IAAI,gBAAgB;AACpD;AAEA,SAAS,2BACP,SACc;AACd,SAAO,IAAI,iBAAiB;AAAA,IAC1B,UAAU,QAAQ;AAAA,EAAA,CACnB;AACH;AAEA,SAAS,0BACP,SAIA;AACA,SAAO;AAAA,IACL,uBACE,QAAQ,yBAAyB;AAAA,IACnC,6BACE,QAAQ,+BACR;AAAA,IACF,0BAA0B,QAAQ;AAAA,EAAA;AAEtC;AAEO,SAAS,4BACd,SACgC;AAChC,QAAM,EAAE,aAAa,qBAAA,IAAyB;AAC9C,QAAM,SAAS,2BAA2B,OAAO;AACjD,QAAM,qBAAqB,0BAA0B,OAAO;AAC5D,QAAM,sBAAsB,eAAe,IAAI,yBAAA;AAC/C,QAAM,mCAAmB,IAAA;AAKzB,QAAM,0BAA0B,CAC9B,MACA,kBACG;AACH,UAAM,+BAA+B;AAAA,MACnC;AAAA,MACA;AAAA,IAAA;AAEF,UAAM,WAAW;AAAA,MACf;AAAA,MACA;AAAA,IAAA;AAEF,UAAM,gBAAgB,aAAa,IAAI,QAAQ;AAC/C,QAAI,eAAe;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,mCAAmC;AAAA,MACjD,GAAG;AAAA,MACH;AAAA,MACA,sBAAsB;AAAA,MACtB,GAAI,kBAAkB,SAAY,CAAA,IAAK,EAAE,cAAA;AAAA,IAAc,CACxD;AACD,iBAAa,IAAI,UAAU,OAAO;AAClC,WAAO;AAAA,EACT;AAEA,QAAM,8BAA8B,CAClC,MACA,mBACoC;AAAA,IACpC,SAAS,wBAAwB,MAAM,aAAa;AAAA,IACpD,aAAa;AAAA,EAAA;AAGf,QAAM,qBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,iCAAiC,CAAC,EAAE,MAAM,oBACxC,4BAA4B,MAAM,aAAa;AAAA,IACjD,2BAA2B,CAAC,SAC1B,4BAA4B,MAAM,MAAS;AAAA,EAAA;AAEjD;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createExpoSQLitePersistence } from './expo.js';
|
|
2
2
|
export type { ExpoSQLiteDatabaseLike, ExpoSQLitePersistenceOptions, ExpoSQLiteSchemaMismatchPolicy, } from './expo.js';
|
|
3
|
-
export { persistedCollectionOptions } from '@tanstack/db-sqlite-persistence-core';
|
|
3
|
+
export { DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS, DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS, persistedCollectionOptions, } from '@tanstack/db-sqlite-persistence-core';
|
|
4
4
|
export type { PersistedCollectionCoordinator, PersistedCollectionPersistence, } from '@tanstack/db-sqlite-persistence-core';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createExpoSQLitePersistence } from "./expo.js";
|
|
2
|
-
import { persistedCollectionOptions } from "@tanstack/db-sqlite-persistence-core";
|
|
2
|
+
import { DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS, DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS, persistedCollectionOptions } from "@tanstack/db-sqlite-persistence-core";
|
|
3
3
|
export {
|
|
4
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
5
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
4
6
|
createExpoSQLitePersistence,
|
|
5
7
|
persistedCollectionOptions
|
|
6
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/expo-db-sqlite-persistence",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Expo SQLite persisted collection adapter for TanStack DB",
|
|
5
5
|
"author": "TanStack Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"src"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@tanstack/db-sqlite-persistence-core": "0.1
|
|
53
|
+
"@tanstack/db-sqlite-persistence-core": "0.2.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"expo-sqlite": "^55.0.10",
|
package/src/expo.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
3
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
2
4
|
SingleProcessCoordinator,
|
|
3
5
|
createSQLiteCorePersistenceAdapter,
|
|
4
6
|
} from '@tanstack/db-sqlite-persistence-core'
|
|
@@ -77,8 +79,11 @@ function resolveAdapterBaseOptions(
|
|
|
77
79
|
`driver` | `schemaVersion` | `schemaMismatchPolicy`
|
|
78
80
|
> {
|
|
79
81
|
return {
|
|
80
|
-
appliedTxPruneMaxRows:
|
|
81
|
-
|
|
82
|
+
appliedTxPruneMaxRows:
|
|
83
|
+
options.appliedTxPruneMaxRows ?? DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
84
|
+
appliedTxPruneMaxAgeSeconds:
|
|
85
|
+
options.appliedTxPruneMaxAgeSeconds ??
|
|
86
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
82
87
|
pullSinceReloadThreshold: options.pullSinceReloadThreshold,
|
|
83
88
|
}
|
|
84
89
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,11 @@ export type {
|
|
|
4
4
|
ExpoSQLitePersistenceOptions,
|
|
5
5
|
ExpoSQLiteSchemaMismatchPolicy,
|
|
6
6
|
} from './expo'
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS,
|
|
9
|
+
DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS,
|
|
10
|
+
persistedCollectionOptions,
|
|
11
|
+
} from '@tanstack/db-sqlite-persistence-core'
|
|
8
12
|
export type {
|
|
9
13
|
PersistedCollectionCoordinator,
|
|
10
14
|
PersistedCollectionPersistence,
|