@rdlabo/ionic-angular-kit 21.5.16 → 21.5.17
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.
|
@@ -5,8 +5,8 @@ import { toObservable } from '@angular/core/rxjs-interop';
|
|
|
5
5
|
import { map, distinctUntilChanged } from 'rxjs/operators';
|
|
6
6
|
import { App } from '@capacitor/app';
|
|
7
7
|
import { Network } from '@capacitor/network';
|
|
8
|
+
import { HttpErrorResponse, HttpContextToken, HttpResponse } from '@angular/common/http';
|
|
8
9
|
import { Capacitor } from '@capacitor/core';
|
|
9
|
-
import { HttpContextToken, HttpResponse } from '@angular/common/http';
|
|
10
10
|
import { defer, catchError, throwError, tap, from, concatMap, of } from 'rxjs';
|
|
11
11
|
|
|
12
12
|
const MAX_OFFLINE_NATURAL_KEY_TEXT_BYTES = 1024;
|
|
@@ -3309,6 +3309,79 @@ function assertOfflineRemoteIdentity(identity) {
|
|
|
3309
3309
|
}
|
|
3310
3310
|
}
|
|
3311
3311
|
|
|
3312
|
+
/**
|
|
3313
|
+
* A successful HTTP response that violates the offline mutation protocol.
|
|
3314
|
+
*
|
|
3315
|
+
* Status 502 deliberately keeps the response in the retryable server-failure class.
|
|
3316
|
+
*/
|
|
3317
|
+
class OfflineMutationProtocolError extends HttpErrorResponse {
|
|
3318
|
+
constructor(message, url) {
|
|
3319
|
+
super({
|
|
3320
|
+
error: { code: 'OFFLINE_MUTATION_PROTOCOL_ERROR', message },
|
|
3321
|
+
status: 502,
|
|
3322
|
+
statusText: 'Bad Gateway',
|
|
3323
|
+
url,
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
3328
|
+
const isPositiveSafeInteger = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value > 0;
|
|
3329
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3330
|
+
/** Strictly parses the wire envelope returned by an offline mutation endpoint. */
|
|
3331
|
+
function parseOfflineMutationEnvelope(input, options) {
|
|
3332
|
+
const label = options.label ?? 'Offline mutation response';
|
|
3333
|
+
const invalid = (detail) => {
|
|
3334
|
+
throw new OfflineMutationProtocolError(`${label} ${detail}`, options.url);
|
|
3335
|
+
};
|
|
3336
|
+
const envelope = isRecord(input) ? input : invalid('must be an object.');
|
|
3337
|
+
let id = null;
|
|
3338
|
+
switch (options.id) {
|
|
3339
|
+
case 'required': {
|
|
3340
|
+
const rawId = envelope['id'];
|
|
3341
|
+
id = hasOwn(envelope, 'id') && isPositiveSafeInteger(rawId) ? rawId : invalid('id must be a positive safe integer.');
|
|
3342
|
+
break;
|
|
3343
|
+
}
|
|
3344
|
+
case 'optional': {
|
|
3345
|
+
if (hasOwn(envelope, 'id')) {
|
|
3346
|
+
const rawId = envelope['id'];
|
|
3347
|
+
id = isPositiveSafeInteger(rawId) ? rawId : invalid('id must be a positive safe integer when present.');
|
|
3348
|
+
}
|
|
3349
|
+
break;
|
|
3350
|
+
}
|
|
3351
|
+
case 'forbidden':
|
|
3352
|
+
if (['id', 'serverId', 'remoteId'].some((key) => hasOwn(envelope, key))) {
|
|
3353
|
+
invalid('must not contain id, serverId, or remoteId.');
|
|
3354
|
+
}
|
|
3355
|
+
break;
|
|
3356
|
+
}
|
|
3357
|
+
const rawRevision = envelope['revision'];
|
|
3358
|
+
const revision = hasOwn(envelope, 'revision') && isPositiveSafeInteger(rawRevision) ? rawRevision : invalid('revision must be a positive safe integer.');
|
|
3359
|
+
const values = envelope['values'];
|
|
3360
|
+
switch (options.values) {
|
|
3361
|
+
case 'object':
|
|
3362
|
+
if (!isRecord(values)) {
|
|
3363
|
+
invalid('values must be an object.');
|
|
3364
|
+
}
|
|
3365
|
+
break;
|
|
3366
|
+
case 'tombstone':
|
|
3367
|
+
if (values !== null) {
|
|
3368
|
+
invalid('values must be null.');
|
|
3369
|
+
}
|
|
3370
|
+
break;
|
|
3371
|
+
case 'object-or-tombstone':
|
|
3372
|
+
if (values !== null && !isRecord(values)) {
|
|
3373
|
+
invalid('values must be an object or null.');
|
|
3374
|
+
}
|
|
3375
|
+
break;
|
|
3376
|
+
case 'optional-object-or-tombstone':
|
|
3377
|
+
if (values !== undefined && values !== null && !isRecord(values)) {
|
|
3378
|
+
invalid('values must be an object, null, or undefined.');
|
|
3379
|
+
}
|
|
3380
|
+
break;
|
|
3381
|
+
}
|
|
3382
|
+
return { id, revision, values: values };
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3312
3385
|
/** outbox再送時にoffline interceptorだけを迂回する。認証・retryは維持する。 */
|
|
3313
3386
|
const OFFLINE_BYPASS = new HttpContextToken(() => false);
|
|
3314
3387
|
/** Header attached to responses served from the local replica fallback. */
|
|
@@ -4232,5 +4305,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
4232
4305
|
* Generated bundle index. Do not edit.
|
|
4233
4306
|
*/
|
|
4234
4307
|
|
|
4235
|
-
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_HEADER, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCoordinatorService, 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, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, replicaAddressFromIdentity, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, text };
|
|
4308
|
+
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_HEADER, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCoordinatorService, OfflineMutationProtocolError, 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, provideOfflineRequestPolicy, real, replicaAddressFromIdentity, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, text };
|
|
4236
4309
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-offline.mjs.map
|