@rdlabo/ionic-angular-kit 22.0.0-beta.pr96.sha53b4ae63682a → 22.0.0-beta.pr97.sha9efc6bcb3163
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.
|
@@ -3138,7 +3138,7 @@ class OfflineSyncService {
|
|
|
3138
3138
|
const materializations = [];
|
|
3139
3139
|
for (const [index, entry] of prepared.entries()) {
|
|
3140
3140
|
this.#assertEnqueueScope(session, entry.request.scopeId);
|
|
3141
|
-
materializations.push(await this.#materializeEnqueue(session.userId, entry.request, replaced[index]));
|
|
3141
|
+
materializations.push(await this.#materializeEnqueue(session.userId, entry.request, repository, replaced[index]));
|
|
3142
3142
|
}
|
|
3143
3143
|
const retained = knownCommands.filter((command) => !replaced.some((item) => item.commandId === command.commandId));
|
|
3144
3144
|
this.#assertDistinctBatchFootprints(materializations, retained, true);
|
|
@@ -3181,8 +3181,8 @@ class OfflineSyncService {
|
|
|
3181
3181
|
async #enqueue(request, options, generation, replaced, repository = this.#repository) {
|
|
3182
3182
|
const session = await this.#beginEnqueueSession(generation);
|
|
3183
3183
|
this.#assertEnqueueScope(session, request.scopeId);
|
|
3184
|
-
const materialization = await this.#materializeEnqueue(session.userId, request, replaced);
|
|
3185
|
-
const currentCommands = await this.#commandsForUser(session.userId);
|
|
3184
|
+
const materialization = await this.#materializeEnqueue(session.userId, request, repository, replaced);
|
|
3185
|
+
const currentCommands = await this.#commandsForUser(session.userId, repository);
|
|
3186
3186
|
const retainedCommands = replaced ? currentCommands.filter((command) => command.commandId !== replaced.commandId) : currentCommands;
|
|
3187
3187
|
this.#assertDistinctBatchFootprints([materialization], retainedCommands);
|
|
3188
3188
|
await this.#assertOutboxCapacity(session.userId, [materialization.command], replaced ? [replaced.commandId] : undefined, currentCommands);
|
|
@@ -3194,14 +3194,14 @@ class OfflineSyncService {
|
|
|
3194
3194
|
throw new Error('Prepared offline batch must contain at least one command.');
|
|
3195
3195
|
}
|
|
3196
3196
|
const session = await this.#beginEnqueueSession(generation);
|
|
3197
|
-
const currentCommands = await this.#commandsForUser(session.userId);
|
|
3197
|
+
const currentCommands = await this.#commandsForUser(session.userId, repository);
|
|
3198
3198
|
this.#rememberCreatedAt(currentCommands);
|
|
3199
3199
|
const firstCreatedAt = Math.max(Date.now(), this.#lastCommandCreatedAt + 1);
|
|
3200
3200
|
this.#lastCommandCreatedAt = firstCreatedAt + prepared.length - 1;
|
|
3201
3201
|
const materializations = [];
|
|
3202
3202
|
for (const [index, entry] of prepared.entries()) {
|
|
3203
3203
|
this.#assertEnqueueScope(session, entry.request.scopeId);
|
|
3204
|
-
materializations.push(await this.#materializeEnqueue(session.userId, entry.request, undefined, firstCreatedAt + index));
|
|
3204
|
+
materializations.push(await this.#materializeEnqueue(session.userId, entry.request, repository, undefined, firstCreatedAt + index));
|
|
3205
3205
|
}
|
|
3206
3206
|
this.#assertDistinctBatchFootprints(materializations, currentCommands);
|
|
3207
3207
|
await this.#assertOutboxCapacity(session.userId, materializations.map((item) => item.command), undefined, currentCommands);
|
|
@@ -3230,11 +3230,11 @@ class OfflineSyncService {
|
|
|
3230
3230
|
}
|
|
3231
3231
|
this.noteScope({ userId: session.userId, scopeId });
|
|
3232
3232
|
}
|
|
3233
|
-
async #materializeEnqueue(userId, request, replaced, createdAt) {
|
|
3233
|
+
async #materializeEnqueue(userId, request, repository, replaced, createdAt) {
|
|
3234
3234
|
const scope = { userId, scopeId: request.scopeId };
|
|
3235
3235
|
this.noteScope(scope);
|
|
3236
3236
|
const commandIdentity = offlineCommandLookupIdentity(request.identity);
|
|
3237
|
-
const normalized = await this.#normalizeEnqueueRequest(scope, request, commandIdentity);
|
|
3237
|
+
const normalized = await this.#normalizeEnqueueRequest(scope, request, commandIdentity, repository);
|
|
3238
3238
|
const commandId = crypto.randomUUID();
|
|
3239
3239
|
const sourceKey = this.#hooks.entityType(request);
|
|
3240
3240
|
const localOnlyFootprint = this.#normalizedLocalOnlyFootprint(scope, request.localOnlyFootprint);
|
|
@@ -3253,7 +3253,7 @@ class OfflineSyncService {
|
|
|
3253
3253
|
state: 'pending',
|
|
3254
3254
|
attempts: 0,
|
|
3255
3255
|
retryAt: null,
|
|
3256
|
-
createdAt: replaced?.createdAt ?? createdAt ?? (await this.#nextCommandCreatedAt(userId)),
|
|
3256
|
+
createdAt: replaced?.createdAt ?? createdAt ?? (await this.#nextCommandCreatedAt(userId, repository)),
|
|
3257
3257
|
lastErrorCode: null,
|
|
3258
3258
|
};
|
|
3259
3259
|
if (localOnlyFootprint.length > 0)
|
|
@@ -3277,10 +3277,10 @@ class OfflineSyncService {
|
|
|
3277
3277
|
if (schema.identity.kind === 'naturalKey' && request.identity.kind !== 'natural') {
|
|
3278
3278
|
throw new Error(`Offline replica source "${entityType}" requires natural identity.`);
|
|
3279
3279
|
}
|
|
3280
|
-
if (request.replicaMutation === 'delete' && !
|
|
3280
|
+
if (request.replicaMutation === 'delete' && !repository.getReplicaRowIncludingPendingDelete) {
|
|
3281
3281
|
throw new Error('Offline repository does not support durable replica delete tombstones.');
|
|
3282
3282
|
}
|
|
3283
|
-
const existing = await this.#getReplicaRowForSync(scope, entityType, commandIdentity);
|
|
3283
|
+
const existing = await this.#getReplicaRowForSync(scope, entityType, commandIdentity, repository);
|
|
3284
3284
|
const generatedIdentity = request.identity.kind === 'generated' ? request.identity : null;
|
|
3285
3285
|
const initialRemoteId = this.#initialRemoteId(schema, existing?.identity.kind === 'generated' ? existing.identity.remoteId : null, generatedIdentity?.remoteId);
|
|
3286
3286
|
this.#assertRemoteIdHint(schema, existing?.identity.kind === 'generated' ? existing.identity.remoteId : null, generatedIdentity?.remoteIdHint);
|
|
@@ -3312,7 +3312,7 @@ class OfflineSyncService {
|
|
|
3312
3312
|
}
|
|
3313
3313
|
}
|
|
3314
3314
|
if (remoteIdentity !== null) {
|
|
3315
|
-
const mapped = await
|
|
3315
|
+
const mapped = await repository.getReplicaRowByRemoteIdentity(scope, entityType, remoteIdentity);
|
|
3316
3316
|
if (mapped !== null && !commandIdentityMatchesReplicaRow(schema, mapped, commandIdentity)) {
|
|
3317
3317
|
if ('remoteId' in remoteIdentity) {
|
|
3318
3318
|
throw new Error(`Offline replica remote id ${String(remoteIdentity.remoteId)} is already mapped to another row.`);
|
|
@@ -3404,7 +3404,7 @@ class OfflineSyncService {
|
|
|
3404
3404
|
putCommands: entries.map((entry) => entry.command),
|
|
3405
3405
|
removeCommandIds,
|
|
3406
3406
|
});
|
|
3407
|
-
await this.#refreshState().catch((error) => this.#reportError(error));
|
|
3407
|
+
await this.#refreshState(generation, repository).catch((error) => this.#reportError(error));
|
|
3408
3408
|
if (options.flush !== false && this.#canSynchronize())
|
|
3409
3409
|
this.#flushInBackground();
|
|
3410
3410
|
}
|
|
@@ -3899,10 +3899,10 @@ class OfflineSyncService {
|
|
|
3899
3899
|
}
|
|
3900
3900
|
}
|
|
3901
3901
|
}
|
|
3902
|
-
async #normalizeEnqueueRequest(scope, request, commandIdentity) {
|
|
3902
|
+
async #normalizeEnqueueRequest(scope, request, commandIdentity, repository) {
|
|
3903
3903
|
let baseRevision = request.baseRevision ?? null;
|
|
3904
3904
|
const sourceKey = this.#hooks.entityType(request);
|
|
3905
|
-
const row = await this.#getReplicaRowForSync(scope, sourceKey, commandIdentity);
|
|
3905
|
+
const row = await this.#getReplicaRowForSync(scope, sourceKey, commandIdentity, repository);
|
|
3906
3906
|
if (row?.serverRevision != null && row.serverRevision !== baseRevision) {
|
|
3907
3907
|
baseRevision = row.serverRevision;
|
|
3908
3908
|
}
|
|
@@ -3918,7 +3918,7 @@ class OfflineSyncService {
|
|
|
3918
3918
|
if (result.clearRemoteId === true && result.serverRevision !== undefined) {
|
|
3919
3919
|
throw new Error('Offline command cannot return serverRevision and clearRemoteId together.');
|
|
3920
3920
|
}
|
|
3921
|
-
const latestCommands = (await this.#readKnownCommands()).filter((candidate) => this.#aggregateKey(candidate) === this.#aggregateKey(command));
|
|
3921
|
+
const latestCommands = (await this.#readKnownCommands(repository)).filter((candidate) => this.#aggregateKey(candidate) === this.#aggregateKey(command));
|
|
3922
3922
|
const latestIndex = latestCommands.findIndex((candidate) => candidate.commandId === command.commandId);
|
|
3923
3923
|
if (latestIndex < 0)
|
|
3924
3924
|
return;
|
|
@@ -3929,7 +3929,7 @@ class OfflineSyncService {
|
|
|
3929
3929
|
: revision === undefined
|
|
3930
3930
|
? following
|
|
3931
3931
|
: following.map((item) => offlineCommandWithBaseRevision(item, revision));
|
|
3932
|
-
const current = await this.#rowForCommand(command);
|
|
3932
|
+
const current = await this.#rowForCommand(command, repository);
|
|
3933
3933
|
if (!this.#isCurrent(generation))
|
|
3934
3934
|
return;
|
|
3935
3935
|
if (!current) {
|
|
@@ -4269,8 +4269,8 @@ class OfflineSyncService {
|
|
|
4269
4269
|
this.#rememberCreatedAt(commands);
|
|
4270
4270
|
return commands;
|
|
4271
4271
|
}
|
|
4272
|
-
async #nextCommandCreatedAt(userId) {
|
|
4273
|
-
const commands = await this.#commandsForUser(userId);
|
|
4272
|
+
async #nextCommandCreatedAt(userId, repository = this.#repository) {
|
|
4273
|
+
const commands = await this.#commandsForUser(userId, repository);
|
|
4274
4274
|
this.#rememberCreatedAt(commands);
|
|
4275
4275
|
const createdAt = Math.max(Date.now(), this.#lastCommandCreatedAt + 1);
|
|
4276
4276
|
this.#lastCommandCreatedAt = createdAt;
|