@rdlabo/ionic-angular-kit 21.5.6 → 21.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "21.5.6",
3
+ "version": "21.5.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
@@ -19,6 +19,29 @@ type OfflineReplicaStorageKind = 'text' | 'integer' | 'real' | 'booleanColumn' |
19
19
  type OfflineReplicaEntityScope = 'user' | 'partition';
20
20
  /** Field projection policy for a source-model property. */
21
21
  type OfflineReplicaFieldPolicy = 'column' | 'serverId' | 'ignored';
22
+ /** Canonical value types accepted in a composite server-side natural key. */
23
+ type OfflineNaturalKeyValue = string | number;
24
+ /** Ordered natural-key values keyed by source-model field name. */
25
+ type OfflineNaturalKey = Readonly<Record<string, OfflineNaturalKeyValue>>;
26
+ /** Remote row identity. Exactly one variant is valid for a replicated entity. */
27
+ type OfflineReplicaRemoteIdentity = {
28
+ readonly serverId: number;
29
+ readonly naturalKey?: never;
30
+ } | {
31
+ readonly serverId?: never;
32
+ readonly naturalKey: OfflineNaturalKey;
33
+ };
34
+ /** Runtime identity policy materialized into an entity schema. */
35
+ type OfflineReplicaIdentityDescriptor = {
36
+ readonly kind: 'localOnly';
37
+ readonly sourceKeys: readonly [];
38
+ } | {
39
+ readonly kind: 'serverId';
40
+ readonly sourceKeys: readonly [string];
41
+ } | {
42
+ readonly kind: 'naturalKey';
43
+ readonly sourceKeys: readonly string[];
44
+ };
22
45
  /** Runtime descriptor for one mapped source property. */
23
46
  interface OfflineReplicaFieldDescriptor {
24
47
  /** Source-model property name from the select shape. */
@@ -44,6 +67,8 @@ interface OfflineReplicaEntitySchema<TSelect extends Record<string, unknown>> {
44
67
  readonly sourceKey: string;
45
68
  /** Whether rows are partitioned by user only or user plus scope partition. */
46
69
  readonly scope: OfflineReplicaEntityScope;
70
+ /** Remote identity policy used by repository and pull reconciliation. */
71
+ readonly identity: OfflineReplicaIdentityDescriptor;
47
72
  /** Ordered field descriptors derived from the DSL definition. */
48
73
  readonly fields: readonly OfflineReplicaFieldDescriptor[];
49
74
  /** Deterministic DDL statements for the replica table and indexes. */
@@ -84,6 +109,11 @@ interface OfflineReplicaIgnoredDef {
84
109
  readonly kind: 'ignored';
85
110
  readonly reason: string;
86
111
  }
112
+ /** Builder selecting non-null source columns as a composite remote identity. */
113
+ interface OfflineReplicaNaturalKeyDef<TKey extends string = string> {
114
+ readonly kind: 'naturalKey';
115
+ readonly sourceKeys: readonly TKey[];
116
+ }
87
117
  type StripNullish<T> = Exclude<T, null | undefined>;
88
118
  type NormalizeReplicaColumnValue<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends Date ? string | Date : T;
89
119
  type StrictNullChecksEnabled = undefined extends null ? false : true;
@@ -104,6 +134,7 @@ interface OfflineReplicaEntityDefinition<TSelect extends Record<string, unknown>
104
134
  readonly table: string;
105
135
  readonly sourceKey: string;
106
136
  readonly scope: OfflineReplicaEntityScope;
137
+ readonly identity?: OfflineReplicaNaturalKeyDef<Extract<keyof TSelect, string>>;
107
138
  readonly fields: ExactSelectKeys<TSelect, TFields> & TFields;
108
139
  }
109
140
  /**
@@ -134,8 +165,18 @@ declare function nullable<TValue>(column: OfflineReplicaColumnDef<TValue, {
134
165
  }>;
135
166
  /** Maps a source property to the shared nullable `server_id` column. */
136
167
  declare function serverId(): OfflineReplicaServerIdDef;
168
+ /** Declares an ordered composite natural key without changing the immutable local UUID. */
169
+ declare function naturalKey<const TKey extends string>(sourceKeys: readonly TKey[]): OfflineReplicaNaturalKeyDef<TKey>;
137
170
  /** Rejects a remote identity on a local-only projection before it reaches platform storage. */
138
171
  declare function assertOfflineReplicaServerId(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, value: number | null): void;
172
+ /** Extracts and validates an entity's natural key in declared component order. */
173
+ declare function offlineNaturalKeyFromValues(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, values: unknown): OfflineNaturalKey | null;
174
+ /** Validates a supplied natural key and returns it in schema-declared order. */
175
+ declare function normalizeOfflineNaturalKey(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, naturalKey: OfflineNaturalKey): OfflineNaturalKey;
176
+ /** Stable, type-tagged identity key used by web uniqueness and pull collapse. */
177
+ declare function canonicalOfflineRemoteIdentity(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, identity: OfflineReplicaRemoteIdentity): string;
178
+ /** Enforces one immutable natural identity across optimistic and confirmed row values. */
179
+ declare function assertOfflineReplicaNaturalKeyBaseline(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, values: unknown, confirmedValues: unknown | null): void;
139
180
  /** Excludes a source property from SQLite while retaining it in the select shape. */
140
181
  declare function ignored(reason: string): OfflineReplicaIgnoredDef;
141
182
  /**
@@ -218,7 +259,7 @@ declare function defineOfflineReplicaSchema(definition: OfflineReplicaSchemaDefi
218
259
  declare function sha256OfflineReplicaSchema(bundle: OfflineReplicaSchemaBundle): Promise<string>;
219
260
 
220
261
  /** Current durable storage schema used by both web and native repositories. */
221
- declare const OFFLINE_SCHEMA_VERSION = 4;
262
+ declare const OFFLINE_SCHEMA_VERSION = 5;
222
263
  /** User and partition scope of all local offline data. */
223
264
  interface OfflineScope {
224
265
  userId: number;
@@ -226,6 +267,8 @@ interface OfflineScope {
226
267
  }
227
268
  /** Synchronization state of a locally materialized product replica row. */
228
269
  type OfflineReplicaSyncState = 'confirmed' | 'pending' | 'blocked_auth' | 'rejected' | 'conflict';
270
+ type OfflineReplicaVisibility = 'present' | 'pending_delete';
271
+ type OfflineReplicaMutation = 'upsert' | 'delete';
229
272
  /** Durable processing state of an outbox command. */
230
273
  type OfflineCommandState = 'pending' | 'sending' | 'retry_wait' | 'blocked_auth' | 'rejected' | 'conflict';
231
274
  /** Product-agnostic mutation persisted in the outbox by local id. */
@@ -238,6 +281,8 @@ interface OfflineCommand<T = unknown> extends OfflineScope {
238
281
  payload: T;
239
282
  /** Full optimistic entity value displayed while this command is pending. */
240
283
  optimisticValue: unknown;
284
+ /** Durable intent used to preserve a hidden tombstone across restart and replay. */
285
+ replicaMutation?: OfflineReplicaMutation;
241
286
  payloadHash: string;
242
287
  baseRevision: string | number | null;
243
288
  state: OfflineCommandState;
@@ -261,6 +306,8 @@ interface OfflineReplicaRow<TValues = unknown> extends OfflineScope {
261
306
  serverRevision: string | number | null;
262
307
  fetchedAt: number;
263
308
  syncState: OfflineReplicaSyncState;
309
+ /** Library-owned visibility; pending deletes remain durable but are hidden from product reads. */
310
+ visibility?: OfflineReplicaVisibility;
264
311
  }
265
312
  /** Stable address of a product replica row inside a user or partition-scoped replica. */
266
313
  interface OfflineReplicaRowKey extends OfflineScope {
@@ -287,8 +334,11 @@ interface OfflineRepository {
287
334
  getSessionManifest<T>(userId: number): Promise<T | null>;
288
335
  putSessionManifest<T>(userId: number, value: T): Promise<void>;
289
336
  getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
337
+ /** Internal durable lookup used by synchronization; includes pending-delete tombstones. */
338
+ getReplicaRowIncludingPendingDelete?<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
290
339
  getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
291
340
  getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
341
+ getReplicaRowByRemoteIdentity<TValues = unknown>(scope: OfflineScope, sourceKey: string, identity: OfflineReplicaRemoteIdentity): Promise<OfflineReplicaRow<TValues> | null>;
292
342
  getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
293
343
  getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
294
344
  getCommandsForUser?(userId: number): Promise<OfflineCommand[]>;
@@ -312,8 +362,10 @@ declare class IonicOfflineRepository implements OfflineRepository {
312
362
  getSessionManifest<T>(userId: number): Promise<T | null>;
313
363
  putSessionManifest<T>(userId: number, value: T): Promise<void>;
314
364
  getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
365
+ getReplicaRowIncludingPendingDelete<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
315
366
  getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
316
367
  getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
368
+ getReplicaRowByRemoteIdentity<TValues = unknown>(scope: OfflineScope, sourceKey: string, identity: OfflineReplicaRemoteIdentity): Promise<OfflineReplicaRow<TValues> | null>;
317
369
  getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
318
370
  getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
319
371
  getCommandsForUser(userId: number): Promise<OfflineCommand[]>;
@@ -335,9 +387,8 @@ interface OfflineReplicaPullRequest {
335
387
  schemaHash: string;
336
388
  }
337
389
  /** One server-side replica mutation returned by an explicit pull page. */
338
- interface OfflineReplicaChange {
390
+ interface OfflineReplicaChangeBase {
339
391
  sourceKey: string;
340
- serverId: number;
341
392
  serverRevision: string | number;
342
393
  /**
343
394
  * Idempotency command ids durably recorded by the server and reflected in this final row state.
@@ -347,6 +398,8 @@ interface OfflineReplicaChange {
347
398
  values: unknown | null;
348
399
  deleted: boolean;
349
400
  }
401
+ /** One server-side mutation with the identity kind declared by its replica schema. */
402
+ type OfflineReplicaChange = OfflineReplicaChangeBase & OfflineReplicaRemoteIdentity;
350
403
  /** One explicit replica pull response page from the application backend. */
351
404
  interface OfflineReplicaPullPage {
352
405
  schemaVersion: number;
@@ -385,6 +438,8 @@ interface OfflineCommandResult {
385
438
  interface OfflineCommandTarget {
386
439
  localId: string;
387
440
  serverId: number | null;
441
+ /** Composite identity derived from current replica values for a natural-key entity. */
442
+ naturalKey?: OfflineNaturalKey;
388
443
  }
389
444
  /** 不透明なoperationを製品APIへ送信し、local replicaへ投影するadapter。 */
390
445
  /** Product adapter that sends commands and projects acknowledgements into entities. */
@@ -708,8 +763,10 @@ declare class SqliteOfflineRepository implements OfflineRepository {
708
763
  getSessionManifest<T>(userId: number): Promise<T | null>;
709
764
  putSessionManifest<T>(userId: number, value: T): Promise<void>;
710
765
  getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
766
+ getReplicaRowIncludingPendingDelete<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
711
767
  getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
712
768
  getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
769
+ getReplicaRowByRemoteIdentity<TValues = unknown>(scope: OfflineScope, sourceKey: string, identity: OfflineReplicaRemoteIdentity): Promise<OfflineReplicaRow<TValues> | null>;
713
770
  getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
714
771
  getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
715
772
  getCommandsForUser(userId: number): Promise<OfflineCommand[]>;
@@ -762,6 +819,11 @@ interface EnqueueOfflineCommand<T = unknown> {
762
819
  payload: T;
763
820
  /** Full local entity value committed to the replica before the command is exposed to the UI. */
764
821
  optimisticValue: unknown;
822
+ /**
823
+ * Optimistically hides an existing DB row while retaining its identity and
824
+ * confirmed baseline for durable replay, conflict handling, and discard.
825
+ */
826
+ replicaMutation?: 'upsert' | 'delete';
765
827
  baseRevision?: string | number | null;
766
828
  }
767
829
  /** Raised before persistence when an outbox payload is not losslessly JSON serializable. */
@@ -814,5 +876,5 @@ declare class OfflineRequestFallbackService {
814
876
  static ɵprov: i0.ɵɵInjectableDeclaration<OfflineRequestFallbackService>;
815
877
  }
816
878
 
817
- 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, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, assertOfflineReplicaServerId, booleanColumn, createCommunitySqliteDriver, createOfflineAuthBridge, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, ignored, integer, isOfflineFallbackError, json, nullable, offlineInterceptor, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, selectOfflineRepository, serverId, sha256OfflineReplicaSchema, text };
818
- export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, CreateOfflineAuthBridgeOptions, EnqueueOfflineCommand, OfflineAuthBridgeConfig, OfflineAuthExchangeContext, OfflineAuthExchangePhase, OfflineAuthResumeContext, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineKitOptions, OfflineLogoutAction, OfflineNetworkState, OfflineOutboxLimits, OfflineReadRequestPlan, OfflineRemoteIdentity, OfflineReplicaChange, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIgnoredDef, OfflineReplicaMigration, OfflineReplicaPullPage, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaServerIdDef, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineRepository, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineScope, OfflineSessionManifest, OfflineSessionTransitionLease, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, ProvideOfflineOptions };
879
+ 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, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, assertOfflineReplicaNaturalKeyBaseline, assertOfflineReplicaServerId, booleanColumn, canonicalOfflineRemoteIdentity, createCommunitySqliteDriver, createOfflineAuthBridge, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, ignored, integer, isOfflineFallbackError, json, naturalKey, normalizeOfflineNaturalKey, nullable, offlineInterceptor, offlineNaturalKeyFromValues, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, selectOfflineRepository, serverId, sha256OfflineReplicaSchema, text };
880
+ export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, CreateOfflineAuthBridgeOptions, EnqueueOfflineCommand, OfflineAuthBridgeConfig, OfflineAuthExchangeContext, OfflineAuthExchangePhase, OfflineAuthResumeContext, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineKitOptions, OfflineLogoutAction, OfflineNaturalKey, OfflineNaturalKeyValue, OfflineNetworkState, OfflineOutboxLimits, OfflineReadRequestPlan, OfflineRemoteIdentity, OfflineReplicaChange, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIdentityDescriptor, OfflineReplicaIgnoredDef, OfflineReplicaMigration, OfflineReplicaMutation, OfflineReplicaNaturalKeyDef, OfflineReplicaPullPage, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaRemoteIdentity, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaServerIdDef, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaVisibility, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineRepository, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineScope, OfflineSessionManifest, OfflineSessionTransitionLease, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, ProvideOfflineOptions };