@rdlabo/ionic-angular-kit 21.5.30 → 21.5.32
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.
|
@@ -852,6 +852,8 @@ function normalizeOfflineReplicaPullPage(page) {
|
|
|
852
852
|
}
|
|
853
853
|
/** DI token for the application-provided explicit replica pull transport. */
|
|
854
854
|
const OFFLINE_REPLICA_PULLER = new InjectionToken('OFFLINE_REPLICA_PULLER');
|
|
855
|
+
/** Optional product adapter for local-only replica projections. */
|
|
856
|
+
const OFFLINE_REPLICA_PROJECTOR = new InjectionToken('OFFLINE_REPLICA_PROJECTOR');
|
|
855
857
|
|
|
856
858
|
/** DI token for product-independent offline persistence settings. */
|
|
857
859
|
const OFFLINE_KIT_OPTIONS = new InjectionToken('OFFLINE_KIT_OPTIONS');
|
|
@@ -900,6 +902,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
900
902
|
|
|
901
903
|
/** Current durable storage schema used by both web and native repositories. */
|
|
902
904
|
const OFFLINE_SCHEMA_VERSION = 1;
|
|
905
|
+
/** Canonical physical key shared by every repository and replica transaction coordinator. */
|
|
906
|
+
function canonicalOfflineReplicaRowKey(schema, row) {
|
|
907
|
+
const partition = schema.scope === 'user' ? 'user' : String(row.scopeId);
|
|
908
|
+
return `${canonicalOfflinePrincipalId(row.userId)}:${partition}:${row.sourceKey}:${canonicalOfflineReplicaIdentity(row.identity)}`;
|
|
909
|
+
}
|
|
903
910
|
/** DI token for the selected platform repository. */
|
|
904
911
|
const OFFLINE_REPOSITORY = new InjectionToken('OFFLINE_REPOSITORY');
|
|
905
912
|
/** Selects encrypted SQLite on native platforms and Ionic Storage on web. */
|
|
@@ -1422,8 +1429,7 @@ class IonicOfflineRepository {
|
|
|
1422
1429
|
}
|
|
1423
1430
|
#rowKey(row) {
|
|
1424
1431
|
const schema = this.#resolveReplicaEntitySchema(row.sourceKey);
|
|
1425
|
-
|
|
1426
|
-
return `${canonicalOfflinePrincipalId(row.userId)}:${partition}:${row.sourceKey}:${canonicalOfflineReplicaIdentity(row.identity)}`;
|
|
1432
|
+
return canonicalOfflineReplicaRowKey(schema, row);
|
|
1427
1433
|
}
|
|
1428
1434
|
#findRowByAddress(rows, scope, sourceKey, schema, identity) {
|
|
1429
1435
|
return Object.values(rows).find((row) => {
|
|
@@ -1613,6 +1619,7 @@ class OfflineReplicaPullService {
|
|
|
1613
1619
|
#repository = inject(OFFLINE_REPOSITORY);
|
|
1614
1620
|
#options = inject(OFFLINE_KIT_OPTIONS);
|
|
1615
1621
|
#puller = inject(OFFLINE_REPLICA_PULLER);
|
|
1622
|
+
#projector = inject(OFFLINE_REPLICA_PROJECTOR, { optional: true });
|
|
1616
1623
|
#executor = inject(OFFLINE_COMMAND_EXECUTOR);
|
|
1617
1624
|
#replicaMutations = inject(OfflineReplicaMutationCoordinator);
|
|
1618
1625
|
#schemaHash = null;
|
|
@@ -1620,33 +1627,55 @@ class OfflineReplicaPullService {
|
|
|
1620
1627
|
if (this.#options.mode === 'readCacheOnly')
|
|
1621
1628
|
return;
|
|
1622
1629
|
const schemaHash = await (this.#schemaHash ??= sha256OfflineReplicaSchema(this.#options.replicaSchema));
|
|
1623
|
-
let
|
|
1630
|
+
let persistedCursor = (await this.#repository.getReplicaCursor(scope))?.cursor ?? '';
|
|
1631
|
+
let requestCursor = persistedCursor;
|
|
1632
|
+
let rebaselinePending = false;
|
|
1624
1633
|
for (;;) {
|
|
1625
1634
|
const page = await this.#puller.pull({
|
|
1626
1635
|
scope,
|
|
1627
|
-
cursor,
|
|
1636
|
+
cursor: requestCursor,
|
|
1628
1637
|
schemaVersion: this.#options.replicaSchema.version,
|
|
1629
1638
|
schemaHash,
|
|
1630
1639
|
});
|
|
1631
1640
|
this.#assertPullPage(page);
|
|
1632
1641
|
this.#assertHandshake(page.schemaVersion, page.schemaHash, schemaHash);
|
|
1633
|
-
if (page.hasMore && page.nextCursor ===
|
|
1642
|
+
if (page.hasMore && page.nextCursor === requestCursor) {
|
|
1634
1643
|
throw new Error(`Offline replica pull cursor did not advance for scope ${scope.userId}:${scope.scopeId}.`);
|
|
1635
1644
|
}
|
|
1636
|
-
if (page.changes.length === 0 && !page.hasMore && page.nextCursor ===
|
|
1645
|
+
if (page.changes.length === 0 && !page.hasMore && page.nextCursor === requestCursor && !rebaselinePending) {
|
|
1637
1646
|
return;
|
|
1638
1647
|
}
|
|
1648
|
+
if (page.rebaselineRequired && page.changes.length === 0 && !page.hasMore) {
|
|
1649
|
+
throw new Error('Offline replica rebaseline marker must lead to a snapshot page.');
|
|
1650
|
+
}
|
|
1651
|
+
if (page.rebaselineRequired && page.changes.length === 0 && page.hasMore) {
|
|
1652
|
+
rebaselinePending = true;
|
|
1653
|
+
requestCursor = page.nextCursor;
|
|
1654
|
+
continue;
|
|
1655
|
+
}
|
|
1639
1656
|
const applied = await this.#replicaMutations.run(async () => {
|
|
1640
1657
|
const currentCursor = (await this.#repository.getReplicaCursor(scope))?.cursor ?? '';
|
|
1641
|
-
if (currentCursor !==
|
|
1658
|
+
if (currentCursor !== persistedCursor)
|
|
1642
1659
|
return currentCursor;
|
|
1643
1660
|
const scopeCommands = await this.#repository.getCommands(scope);
|
|
1644
1661
|
const userCommands = this.#repository.getCommandsForUser ? await this.#repository.getCommandsForUser(scope.userId) : scopeCommands;
|
|
1645
1662
|
const changes = this.#collapseChanges(page.changes);
|
|
1663
|
+
const projection = await this.#projector?.project({
|
|
1664
|
+
scope,
|
|
1665
|
+
changes,
|
|
1666
|
+
commands: scopeCommands,
|
|
1667
|
+
repository: this.#repository,
|
|
1668
|
+
});
|
|
1669
|
+
this.#assertProjection(scope, projection);
|
|
1646
1670
|
const putRows = [];
|
|
1647
1671
|
const removeRows = [];
|
|
1672
|
+
const rebasedPutRows = [];
|
|
1673
|
+
const rebasedRemoveRows = [];
|
|
1648
1674
|
const putCommands = new Map();
|
|
1649
1675
|
const removeCommandIds = new Set();
|
|
1676
|
+
if (rebaselinePending || page.rebaselineRequired) {
|
|
1677
|
+
removeRows.push(...(await this.#confirmedRowsForRebaseline(scope, userCommands)));
|
|
1678
|
+
}
|
|
1650
1679
|
for (const change of changes) {
|
|
1651
1680
|
const schema = this.#entitySchema(change.sourceKey);
|
|
1652
1681
|
const commands = schema.scope === 'user' ? userCommands : scopeCommands;
|
|
@@ -1730,10 +1759,29 @@ class OfflineReplicaPullService {
|
|
|
1730
1759
|
});
|
|
1731
1760
|
continue;
|
|
1732
1761
|
}
|
|
1733
|
-
const
|
|
1762
|
+
const revisionChanged = related.some((command) => command.baseRevision !== change.serverRevision);
|
|
1763
|
+
const rebaseEligible = related.every((command) => (command.state === 'pending' || command.state === 'retry_wait') && command.serverCommitUnknown !== true);
|
|
1764
|
+
const rebase = revisionChanged && rebaseEligible
|
|
1765
|
+
? ((await this.#executor.rebasePendingCommands?.(related, confirmedValues, change.serverRevision, await this.#projectedCompanionRows(related, projection))) ?? null)
|
|
1766
|
+
: null;
|
|
1767
|
+
this.#assertRebasedSteps(related, rebase?.steps ?? null);
|
|
1768
|
+
const conflicted = revisionChanged && rebase === null;
|
|
1769
|
+
const rebasedCommands = rebase
|
|
1770
|
+
? related.map((command, index) => ({
|
|
1771
|
+
...command,
|
|
1772
|
+
baseRevision: change.serverRevision,
|
|
1773
|
+
optimisticValue: rebase.steps[index].optimisticValue,
|
|
1774
|
+
...(rebase.steps[index].optimisticCompanions === undefined
|
|
1775
|
+
? {}
|
|
1776
|
+
: { optimisticCompanions: rebase.steps[index].optimisticCompanions }),
|
|
1777
|
+
}))
|
|
1778
|
+
: [];
|
|
1779
|
+
for (const command of rebasedCommands)
|
|
1780
|
+
putCommands.set(command.commandId, command);
|
|
1781
|
+
this.#appendRebasedCompanionRows(rebasedCommands, rebasedPutRows, rebasedRemoveRows);
|
|
1734
1782
|
putRows.push({
|
|
1735
1783
|
...existing,
|
|
1736
|
-
values: hasPending ? existing.values : confirmedValues,
|
|
1784
|
+
values: rebasedCommands.at(-1)?.optimisticValue ?? (hasPending ? existing.values : confirmedValues),
|
|
1737
1785
|
confirmedValues,
|
|
1738
1786
|
serverRevision: change.serverRevision,
|
|
1739
1787
|
fetchedAt: Date.now(),
|
|
@@ -1750,9 +1798,14 @@ class OfflineReplicaPullService {
|
|
|
1750
1798
|
}
|
|
1751
1799
|
}
|
|
1752
1800
|
}
|
|
1801
|
+
const finalRows = this.#mergeRowMutations([
|
|
1802
|
+
{ putRows, removeRows },
|
|
1803
|
+
{ putRows: projection?.putRows ?? [], removeRows: projection?.removeRows ?? [] },
|
|
1804
|
+
{ putRows: rebasedPutRows, removeRows: rebasedRemoveRows },
|
|
1805
|
+
]);
|
|
1753
1806
|
await this.#repository.transactReplica({
|
|
1754
|
-
putRows,
|
|
1755
|
-
removeRows,
|
|
1807
|
+
putRows: finalRows.putRows,
|
|
1808
|
+
removeRows: finalRows.removeRows,
|
|
1756
1809
|
putCommands: [...putCommands.values()],
|
|
1757
1810
|
removeCommandIds: [...removeCommandIds],
|
|
1758
1811
|
putCursors: [{ ...scope, cursor: page.nextCursor }],
|
|
@@ -1760,14 +1813,55 @@ class OfflineReplicaPullService {
|
|
|
1760
1813
|
return page.nextCursor;
|
|
1761
1814
|
});
|
|
1762
1815
|
if (applied !== page.nextCursor) {
|
|
1763
|
-
|
|
1816
|
+
persistedCursor = applied;
|
|
1817
|
+
requestCursor = applied;
|
|
1818
|
+
rebaselinePending = false;
|
|
1764
1819
|
continue;
|
|
1765
1820
|
}
|
|
1766
|
-
|
|
1821
|
+
persistedCursor = page.nextCursor;
|
|
1822
|
+
requestCursor = page.nextCursor;
|
|
1823
|
+
rebaselinePending = false;
|
|
1767
1824
|
if (!page.hasMore)
|
|
1768
1825
|
return;
|
|
1769
1826
|
}
|
|
1770
1827
|
}
|
|
1828
|
+
async #confirmedRowsForRebaseline(scope, commands) {
|
|
1829
|
+
const preserved = new Set(commands.flatMap((command) => (command.optimisticCompanions ?? []).map((companion) => this.#rowKey(companion.key))));
|
|
1830
|
+
const rows = (await Promise.all(this.#options.replicaSchema.entities.map((entity) => this.#repository.getReplicaRows(scope, entity.sourceKey)))).flat();
|
|
1831
|
+
return rows.filter((row) => row.syncState === 'confirmed' && !preserved.has(this.#rowKey(row)));
|
|
1832
|
+
}
|
|
1833
|
+
#rowKey(row) {
|
|
1834
|
+
return canonicalOfflineReplicaRowKey(this.#entitySchema(row.sourceKey), row);
|
|
1835
|
+
}
|
|
1836
|
+
#mergeRowMutations(layers) {
|
|
1837
|
+
const mutations = new Map();
|
|
1838
|
+
for (const layer of layers) {
|
|
1839
|
+
for (const row of layer.removeRows)
|
|
1840
|
+
mutations.set(this.#rowKey(row), { kind: 'remove', row });
|
|
1841
|
+
for (const row of layer.putRows)
|
|
1842
|
+
mutations.set(this.#rowKey(row), { kind: 'put', row });
|
|
1843
|
+
}
|
|
1844
|
+
const putRows = [];
|
|
1845
|
+
const removeRows = [];
|
|
1846
|
+
for (const mutation of mutations.values()) {
|
|
1847
|
+
if (mutation.kind === 'put')
|
|
1848
|
+
putRows.push(mutation.row);
|
|
1849
|
+
else
|
|
1850
|
+
removeRows.push(mutation.row);
|
|
1851
|
+
}
|
|
1852
|
+
return { putRows, removeRows };
|
|
1853
|
+
}
|
|
1854
|
+
#assertProjection(scope, projection) {
|
|
1855
|
+
for (const row of [...(projection?.putRows ?? []), ...(projection?.removeRows ?? [])]) {
|
|
1856
|
+
const schema = this.#entitySchema(row.sourceKey);
|
|
1857
|
+
if (schema.identity.kind !== 'localOnly') {
|
|
1858
|
+
throw new Error(`Offline replica projector may only mutate localOnly source "${row.sourceKey}".`);
|
|
1859
|
+
}
|
|
1860
|
+
if (row.userId !== scope.userId || row.scopeId !== scope.scopeId || row.identity.kind !== 'local') {
|
|
1861
|
+
throw new Error('Offline replica projector rows must use the current scope and local identity.');
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1771
1865
|
#assertPullPage(page) {
|
|
1772
1866
|
if (typeof page.nextCursor !== 'string') {
|
|
1773
1867
|
throw new Error('Offline replica pull page nextCursor must be a string.');
|
|
@@ -1778,10 +1872,65 @@ class OfflineReplicaPullService {
|
|
|
1778
1872
|
if (!Array.isArray(page.changes)) {
|
|
1779
1873
|
throw new Error('Offline replica pull page changes must be an array.');
|
|
1780
1874
|
}
|
|
1875
|
+
if (page.rebaselineRequired !== undefined && typeof page.rebaselineRequired !== 'boolean') {
|
|
1876
|
+
throw new Error('Offline replica pull page rebaselineRequired must be a boolean when present.');
|
|
1877
|
+
}
|
|
1781
1878
|
for (const [index, change] of page.changes.entries()) {
|
|
1782
1879
|
this.#assertPullChange(change, index);
|
|
1783
1880
|
}
|
|
1784
1881
|
}
|
|
1882
|
+
#assertRebasedSteps(original, steps) {
|
|
1883
|
+
if (steps === null)
|
|
1884
|
+
return;
|
|
1885
|
+
if (steps.length !== original.length) {
|
|
1886
|
+
throw new Error('Rebased offline values must match the aggregate command count.');
|
|
1887
|
+
}
|
|
1888
|
+
for (const [index, step] of steps.entries()) {
|
|
1889
|
+
const originalKeys = (original[index]?.optimisticCompanions ?? []).map((item) => this.#rowKey(item.key)).sort();
|
|
1890
|
+
const rebasedKeys = (step.optimisticCompanions ?? []).map((item) => this.#rowKey(item.key)).sort();
|
|
1891
|
+
if (JSON.stringify(originalKeys) !== JSON.stringify(rebasedKeys)) {
|
|
1892
|
+
throw new Error('Rebased offline companions must preserve each command footprint.');
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
#appendRebasedCompanionRows(commands, putRows, removeRows) {
|
|
1897
|
+
const latest = new Map();
|
|
1898
|
+
for (const command of commands) {
|
|
1899
|
+
for (const companion of command.optimisticCompanions ?? []) {
|
|
1900
|
+
latest.set(this.#rowKey(companion.key), { key: companion.key, after: companion.after });
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
for (const { key, after } of latest.values()) {
|
|
1904
|
+
if (after)
|
|
1905
|
+
putRows.push(after);
|
|
1906
|
+
else
|
|
1907
|
+
removeRows.push(key);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
async #currentCompanionRows(commands) {
|
|
1911
|
+
const keys = new Map(commands.flatMap((command) => (command.optimisticCompanions ?? []).map((companion) => [this.#rowKey(companion.key), companion.key])));
|
|
1912
|
+
const rows = await Promise.all([...keys.values()].map((key) => {
|
|
1913
|
+
const companionScope = { userId: key.userId, scopeId: key.scopeId };
|
|
1914
|
+
return (this.#repository.getReplicaRowIncludingPendingDelete?.(companionScope, key.sourceKey, key.identity) ??
|
|
1915
|
+
this.#repository.getReplicaRow(companionScope, key.sourceKey, key.identity));
|
|
1916
|
+
}));
|
|
1917
|
+
return rows.filter((row) => row !== null);
|
|
1918
|
+
}
|
|
1919
|
+
async #projectedCompanionRows(commands, projection) {
|
|
1920
|
+
const footprint = new Set(commands.flatMap((command) => (command.optimisticCompanions ?? []).map((companion) => this.#rowKey(companion.key))));
|
|
1921
|
+
const rows = new Map((await this.#currentCompanionRows(commands)).map((row) => [this.#rowKey(row), row]));
|
|
1922
|
+
for (const row of projection?.removeRows ?? []) {
|
|
1923
|
+
const key = this.#rowKey(row);
|
|
1924
|
+
if (footprint.has(key))
|
|
1925
|
+
rows.delete(key);
|
|
1926
|
+
}
|
|
1927
|
+
for (const row of projection?.putRows ?? []) {
|
|
1928
|
+
const key = this.#rowKey(row);
|
|
1929
|
+
if (footprint.has(key))
|
|
1930
|
+
rows.set(key, row);
|
|
1931
|
+
}
|
|
1932
|
+
return [...rows.values()];
|
|
1933
|
+
}
|
|
1785
1934
|
#assertPullChange(change, index) {
|
|
1786
1935
|
const label = `Offline replica pull page changes[${index}]`;
|
|
1787
1936
|
if (!isPlainObject(change)) {
|
|
@@ -2449,7 +2598,10 @@ class OfflineSyncService {
|
|
|
2449
2598
|
const session = await this.#beginEnqueueSession(generation);
|
|
2450
2599
|
this.#assertEnqueueScope(session, request.scopeId);
|
|
2451
2600
|
const materialization = await this.#materializeEnqueue(session.userId, request, replicaTransaction, replaced);
|
|
2452
|
-
await this.#
|
|
2601
|
+
const currentCommands = await this.#commandsForUser(session.userId);
|
|
2602
|
+
const retainedCommands = replaced ? currentCommands.filter((command) => command.commandId !== replaced.commandId) : currentCommands;
|
|
2603
|
+
this.#assertDistinctBatchFootprints([materialization], retainedCommands);
|
|
2604
|
+
await this.#assertOutboxCapacity(session.userId, [materialization.command], replaced?.commandId, currentCommands);
|
|
2453
2605
|
await this.#commitMaterializedEnqueues([materialization], generation, options, replaced ? [replaced.commandId] : undefined);
|
|
2454
2606
|
return materialization.command.commandId;
|
|
2455
2607
|
}
|
|
@@ -2467,7 +2619,7 @@ class OfflineSyncService {
|
|
|
2467
2619
|
this.#assertEnqueueScope(session, entry.request.scopeId);
|
|
2468
2620
|
materializations.push(await this.#materializeEnqueue(session.userId, entry.request, entry.replicaTransaction, undefined, firstCreatedAt + index));
|
|
2469
2621
|
}
|
|
2470
|
-
this.#assertDistinctBatchFootprints(materializations);
|
|
2622
|
+
this.#assertDistinctBatchFootprints(materializations, currentCommands);
|
|
2471
2623
|
await this.#assertOutboxCapacity(session.userId, materializations.map((item) => item.command), undefined, currentCommands);
|
|
2472
2624
|
options.assertCurrent?.();
|
|
2473
2625
|
await this.#commitMaterializedEnqueues(materializations, generation, options);
|
|
@@ -2599,9 +2751,15 @@ class OfflineSyncService {
|
|
|
2599
2751
|
command = { ...command, optimisticCompanions };
|
|
2600
2752
|
return { command, optimisticRow, optimisticCompanions };
|
|
2601
2753
|
}
|
|
2602
|
-
#assertDistinctBatchFootprints(entries) {
|
|
2754
|
+
#assertDistinctBatchFootprints(entries, existingCommands) {
|
|
2603
2755
|
const aggregates = new Set();
|
|
2604
2756
|
const replicaKeys = new Set();
|
|
2757
|
+
const existingFootprints = new Map();
|
|
2758
|
+
for (const command of existingCommands) {
|
|
2759
|
+
const aggregate = this.#aggregateKey(command);
|
|
2760
|
+
for (const key of this.#commandFootprintKeys(command))
|
|
2761
|
+
existingFootprints.set(key, aggregate);
|
|
2762
|
+
}
|
|
2605
2763
|
for (const entry of entries) {
|
|
2606
2764
|
const aggregate = this.#aggregateKey(entry.command);
|
|
2607
2765
|
if (aggregates.has(aggregate)) {
|
|
@@ -2615,10 +2773,23 @@ class OfflineSyncService {
|
|
|
2615
2773
|
if (replicaKeys.has(key)) {
|
|
2616
2774
|
throw new Error('Prepared offline batch contains overlapping replica footprints.');
|
|
2617
2775
|
}
|
|
2776
|
+
const existingAggregate = existingFootprints.get(key);
|
|
2777
|
+
if (existingAggregate !== undefined && existingAggregate !== aggregate) {
|
|
2778
|
+
throw new Error('Offline commands for different aggregates cannot share a replica footprint.');
|
|
2779
|
+
}
|
|
2618
2780
|
replicaKeys.add(key);
|
|
2619
2781
|
}
|
|
2620
2782
|
}
|
|
2621
2783
|
}
|
|
2784
|
+
#commandFootprintKeys(command) {
|
|
2785
|
+
const identity = command.identity.kind === 'generated'
|
|
2786
|
+
? offlineGeneratedReplicaIdentity(command.identity.localId, null)
|
|
2787
|
+
: { kind: 'natural', naturalKey: command.identity.naturalKey };
|
|
2788
|
+
return [
|
|
2789
|
+
this.#replicaRowKey({ ...command, identity }),
|
|
2790
|
+
...(command.optimisticCompanions ?? []).map((companion) => this.#replicaRowKey(companion.key)),
|
|
2791
|
+
];
|
|
2792
|
+
}
|
|
2622
2793
|
async #commitMaterializedEnqueues(entries, generation, options, removeCommandIds) {
|
|
2623
2794
|
if (generation !== this.#generation) {
|
|
2624
2795
|
throw new Error('Offline session changed before the command could be persisted');
|
|
@@ -2716,7 +2887,7 @@ class OfflineSyncService {
|
|
|
2716
2887
|
};
|
|
2717
2888
|
}
|
|
2718
2889
|
#replicaRowKey(key) {
|
|
2719
|
-
return
|
|
2890
|
+
return canonicalOfflineReplicaRowKey(this.#entitySchema(key.sourceKey), key);
|
|
2720
2891
|
}
|
|
2721
2892
|
async #assertOutboxCapacity(userId, newCommands, excludingCommandId, knownCommands) {
|
|
2722
2893
|
const currentCommands = knownCommands ?? (await this.#commandsForUser(userId));
|
|
@@ -4641,7 +4812,7 @@ class SqliteOfflineRepository {
|
|
|
4641
4812
|
}
|
|
4642
4813
|
#replicaRowKey(row) {
|
|
4643
4814
|
const schema = this.#resolveReplicaEntitySchema(row.sourceKey);
|
|
4644
|
-
return
|
|
4815
|
+
return canonicalOfflineReplicaRowKey(schema, row);
|
|
4645
4816
|
}
|
|
4646
4817
|
#assertReplicaIdentityAssignment(schema, existing, incoming, release) {
|
|
4647
4818
|
if (release && schema.identity.kind !== 'generated') {
|
|
@@ -4794,6 +4965,9 @@ function provideOffline(options) {
|
|
|
4794
4965
|
? { provide: OFFLINE_REPLICA_PULLER, useExisting: options.replicaPuller }
|
|
4795
4966
|
: { provide: OFFLINE_REPLICA_PULLER, useValue: READ_CACHE_ONLY_REPLICA_PULLER },
|
|
4796
4967
|
...(options.commandHooks ? [options.commandHooks, { provide: OFFLINE_COMMAND_HOOKS, useExisting: options.commandHooks }] : []),
|
|
4968
|
+
...(options.replicaProjector
|
|
4969
|
+
? [options.replicaProjector, { provide: OFFLINE_REPLICA_PROJECTOR, useExisting: options.replicaProjector }]
|
|
4970
|
+
: []),
|
|
4797
4971
|
...options.requestPolicies.flatMap((policy) => provideOfflineRequestPolicy(policy)),
|
|
4798
4972
|
...(options.mutationPolicies ?? []).flatMap((policy) => provideOfflineMutationRequestPolicy(policy)),
|
|
4799
4973
|
...(options.providers ?? []),
|
|
@@ -4921,5 +5095,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
4921
5095
|
* Generated bundle index. Do not edit.
|
|
4922
5096
|
*/
|
|
4923
5097
|
|
|
4924
|
-
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_HEADER, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineFallbackError, json, localOnly, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReplicaRemoteIdentity, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, real, replicaAddressFromIdentity, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, text };
|
|
5098
|
+
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PROJECTOR, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_HEADER, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, canonicalOfflineReplicaRowKey, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineFallbackError, json, localOnly, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReplicaRemoteIdentity, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, real, replicaAddressFromIdentity, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, text };
|
|
4925
5099
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-offline.mjs.map
|