@rdlabo/ionic-angular-kit 21.3.4 → 21.4.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.
@@ -0,0 +1,641 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Type, Provider, EnvironmentProviders } from '@angular/core';
3
+ import * as _rdlabo_ionic_angular_kit_offline from '@rdlabo/ionic-angular-kit/offline';
4
+ import { HttpContextToken, HttpRequest, HttpResponse, HttpEvent, HttpInterceptorFn } from '@angular/common/http';
5
+ import { Observable } from 'rxjs';
6
+
7
+ /** SQLite storage affinity for a replicated entity column. */
8
+ type OfflineReplicaSqliteAffinity = 'TEXT' | 'INTEGER' | 'REAL';
9
+ /**
10
+ * Logical storage kind for a replicated column, independent of SQLite affinity.
11
+ *
12
+ * For example, {@link booleanColumn} and {@link datetime} both use INTEGER/TEXT affinity
13
+ * but remain distinguishable at runtime through this marker.
14
+ */
15
+ type OfflineReplicaStorageKind = 'text' | 'integer' | 'real' | 'booleanColumn' | 'json' | 'datetime';
16
+ /** Scope partition persisted on every replica table row. */
17
+ type OfflineReplicaEntityScope = 'user' | 'group';
18
+ /** Field projection policy for a source-model property. */
19
+ type OfflineReplicaFieldPolicy = 'column' | 'serverId' | 'ignored';
20
+ /** Runtime descriptor for one mapped source property. */
21
+ interface OfflineReplicaFieldDescriptor {
22
+ /** Source-model property name from the select shape. */
23
+ readonly sourceKey: string;
24
+ /** How the property is projected into SQLite. */
25
+ readonly policy: OfflineReplicaFieldPolicy;
26
+ /** Physical SQLite column name, or null when {@link policy} is `ignored`. */
27
+ readonly sqliteColumnName: string | null;
28
+ /** SQLite affinity for column policies, otherwise null. */
29
+ readonly affinity: OfflineReplicaSqliteAffinity | null;
30
+ /** Logical storage kind for column policies, otherwise null. */
31
+ readonly storageKind: OfflineReplicaStorageKind | null;
32
+ /** Whether the SQLite column accepts NULL. */
33
+ readonly nullable: boolean;
34
+ /** Human-readable reason when {@link policy} is `ignored`. */
35
+ readonly ignoredReason: string | null;
36
+ }
37
+ /** Materialized replica entity schema used to create and fingerprint SQLite tables. */
38
+ interface OfflineReplicaEntitySchema<TSelect extends Record<string, unknown>> {
39
+ /** Validated SQLite table name. */
40
+ readonly tableName: string;
41
+ /** Stable source key used by sync and repository layers. */
42
+ readonly sourceKey: string;
43
+ /** Whether rows are partitioned by user only or user plus group. */
44
+ readonly scope: OfflineReplicaEntityScope;
45
+ /** Ordered field descriptors derived from the DSL definition. */
46
+ readonly fields: readonly OfflineReplicaFieldDescriptor[];
47
+ /** Deterministic DDL statements for the replica table and indexes. */
48
+ readonly createTableSql: readonly string[];
49
+ /** Canonical string input for schema fingerprinting; hashing is left to callers. */
50
+ readonly schemaFingerprintInput: string;
51
+ /** Phantom marker tying the schema to its select shape. */
52
+ readonly __select?: TSelect;
53
+ }
54
+ declare const replicaNullableBrand: unique symbol;
55
+ /** Phantom nullability brand carried by column builders. */
56
+ interface ReplicaNullableBrand {
57
+ readonly [replicaNullableBrand]: 'nullable' | 'required';
58
+ }
59
+ /** Column builder definition with compile-time nullability tracking. */
60
+ interface OfflineReplicaColumnDef<TValue = unknown, TNullable extends ReplicaNullableBrand = {
61
+ readonly [replicaNullableBrand]: 'required';
62
+ }> {
63
+ readonly kind: 'column';
64
+ readonly affinity: OfflineReplicaSqliteAffinity;
65
+ readonly storageKind: OfflineReplicaStorageKind;
66
+ readonly columnName?: string;
67
+ readonly nullable?: boolean;
68
+ readonly __types?: {
69
+ readonly value: TValue;
70
+ readonly nullable: TNullable[typeof replicaNullableBrand];
71
+ };
72
+ }
73
+ /** Builder marking a source property as the server-assigned identifier. */
74
+ interface OfflineReplicaServerIdDef {
75
+ readonly kind: 'serverId';
76
+ readonly __types?: {
77
+ readonly value: number;
78
+ };
79
+ }
80
+ /** Builder excluding a source property from SQLite projection. */
81
+ interface OfflineReplicaIgnoredDef {
82
+ readonly kind: 'ignored';
83
+ readonly reason: string;
84
+ }
85
+ type StripNullish<T> = Exclude<T, null | undefined>;
86
+ type IsNullableSelectValue<T> = null extends T ? true : undefined extends T ? true : false;
87
+ type OfflineReplicaFieldDefForKey<TSelect extends Record<string, unknown>, K extends keyof TSelect> = (StripNullish<TSelect[K]> extends number ? OfflineReplicaServerIdDef : never) | OfflineReplicaIgnoredDef | (IsNullableSelectValue<TSelect[K]> extends true ? OfflineReplicaColumnDef<StripNullish<TSelect[K]>, {
88
+ readonly [replicaNullableBrand]: 'nullable';
89
+ }> : OfflineReplicaColumnDef<TSelect[K], {
90
+ readonly [replicaNullableBrand]: 'required';
91
+ }>);
92
+ type ExactSelectKeys<TSelect extends Record<string, unknown>, TFields> = Exclude<keyof TFields, keyof TSelect> extends never ? (Exclude<keyof TSelect, keyof TFields> extends never ? TFields : never) : never;
93
+ /** Configuration accepted by {@link defineReplicaEntity}. */
94
+ interface OfflineReplicaEntityDefinition<TSelect extends Record<string, unknown>, TFields extends {
95
+ readonly [K in keyof TSelect]: OfflineReplicaFieldDefForKey<TSelect, K>;
96
+ }> {
97
+ readonly table: string;
98
+ readonly sourceKey: string;
99
+ readonly scope: OfflineReplicaEntityScope;
100
+ readonly fields: ExactSelectKeys<TSelect, TFields> & TFields;
101
+ }
102
+ /**
103
+ * Begins a type-safe replica entity schema definition for the given select shape.
104
+ *
105
+ * Every key in `TSelect` must appear exactly once in `fields`, and column nullability
106
+ * must match the select property nullability.
107
+ */
108
+ declare function defineReplicaEntity<TSelect extends Record<string, unknown>>(): <const TFields extends { readonly [K in keyof TSelect]: OfflineReplicaFieldDefForKey<TSelect, K>; }>(definition: OfflineReplicaEntityDefinition<TSelect, TFields>) => OfflineReplicaEntitySchema<TSelect>;
109
+ /** Maps a non-null string source property to a TEXT column. */
110
+ declare function text(): OfflineReplicaColumnDef<string>;
111
+ /** Maps a non-null integer source property to an INTEGER column. */
112
+ declare function integer(): OfflineReplicaColumnDef<number>;
113
+ /** Maps a non-null floating-point source property to a REAL column. */
114
+ declare function real(): OfflineReplicaColumnDef<number>;
115
+ /** Maps a non-null boolean source property to an INTEGER column. */
116
+ declare function booleanColumn(): OfflineReplicaColumnDef<boolean>;
117
+ /** Maps a non-null JSON-serializable source property to a TEXT column. */
118
+ declare function json<T>(): OfflineReplicaColumnDef<T>;
119
+ /** Maps a non-null datetime source property to a canonical ISO-8601 TEXT column. */
120
+ declare function datetime(): OfflineReplicaColumnDef<string | Date>;
121
+ /** Marks a column builder as nullable for nullable select properties. */
122
+ declare function nullable<TValue>(column: OfflineReplicaColumnDef<TValue, {
123
+ readonly [replicaNullableBrand]: 'required';
124
+ }>): OfflineReplicaColumnDef<TValue, {
125
+ readonly [replicaNullableBrand]: 'nullable';
126
+ }>;
127
+ /** Maps a source property to the shared nullable `server_id` column. */
128
+ declare function serverId(): OfflineReplicaServerIdDef;
129
+ /** Excludes a source property from SQLite while retaining it in the select shape. */
130
+ declare function ignored(reason: string): OfflineReplicaIgnoredDef;
131
+ /**
132
+ * Validates and encodes a source-model row into SQLite-bound column values.
133
+ *
134
+ * Only {@link OfflineReplicaFieldPolicy} `column` fields are emitted, keyed by
135
+ * {@link OfflineReplicaFieldDescriptor.sqliteColumnName} in descriptor order.
136
+ * Source properties mapped as `serverId` or `ignored` may be present but are not encoded.
137
+ */
138
+ declare function encodeOfflineReplicaValues(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, values: unknown): Readonly<Record<string, string | number | null>>;
139
+ /**
140
+ * Validates and decodes SQLite column values into a source-model row.
141
+ *
142
+ * Only {@link OfflineReplicaFieldPolicy} `column` fields are emitted, keyed by
143
+ * {@link OfflineReplicaFieldDescriptor.sourceKey} in descriptor order.
144
+ * Physical columns such as `server_id`, sync metadata, and scope keys may be
145
+ * present in `row` but are not decoded.
146
+ */
147
+ declare function decodeOfflineReplicaValues(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, row: unknown): Readonly<Record<string, unknown>>;
148
+ /**
149
+ * Validates a source-model row and returns the canonical domain projection persisted by every repository.
150
+ *
151
+ * Fields mapped as `serverId` or `ignored` are intentionally omitted. This keeps web and native row shapes
152
+ * identical; the server identifier remains available through the replica row's dedicated `serverId` field.
153
+ */
154
+ declare function projectOfflineReplicaValues(schema: OfflineReplicaEntitySchema<Record<string, unknown>>, values: unknown): Readonly<Record<string, unknown>>;
155
+ /** Domain payload transformed during web replica schema migration. Identity and sync metadata stay outside this shape. */
156
+ interface OfflineReplicaWebMigrationRow {
157
+ readonly sourceKey: string;
158
+ readonly values: Readonly<Record<string, unknown>>;
159
+ readonly confirmedValues: Readonly<Record<string, unknown>> | null;
160
+ }
161
+ /** Result of {@link OfflineReplicaMigration.migrateWebRow}; `null` deletes the stored row. */
162
+ type OfflineReplicaWebMigrationResult = OfflineReplicaWebMigrationRow | null;
163
+ /** Transforms one replica row's domain projection during a web schema migration step. */
164
+ type OfflineReplicaWebMigrationCallback = (row: OfflineReplicaWebMigrationRow) => OfflineReplicaWebMigrationResult | Promise<OfflineReplicaWebMigrationResult>;
165
+ /** One explicit schema-version step applied during offline SQLite and web replica migrations. */
166
+ interface OfflineReplicaMigration {
167
+ /** Source schema version; the migration advances to {@link fromVersion} + 1. */
168
+ readonly fromVersion: number;
169
+ /** Non-empty DDL/DML statements executed in order on native SQLite for this step. Web ignores these. */
170
+ readonly statements: readonly string[];
171
+ /**
172
+ * Transforms one row's domain projection for web storage during this step.
173
+ * The callback receives only {@link OfflineReplicaWebMigrationRow}; it must not read or mutate
174
+ * `localId`, `serverId`, scope, revision, or `syncState`. Return `null` to delete the row.
175
+ */
176
+ readonly migrateWebRow: OfflineReplicaWebMigrationCallback;
177
+ }
178
+ /** Versioned product replica schema bundle with entities and migration path. */
179
+ interface OfflineReplicaSchemaBundle {
180
+ /** Current bundle schema version. */
181
+ readonly version: number;
182
+ /** Entity schemas sorted by {@link OfflineReplicaEntitySchema.sourceKey}. */
183
+ readonly entities: readonly OfflineReplicaEntitySchema<Record<string, unknown>>[];
184
+ /** Migrations sorted by {@link OfflineReplicaMigration.fromVersion}. */
185
+ readonly migrations: readonly OfflineReplicaMigration[];
186
+ /** Canonical fingerprint input spanning version and every entity fingerprint. */
187
+ readonly schemaFingerprintInput: string;
188
+ }
189
+ /** Input accepted by {@link defineOfflineReplicaSchema}. */
190
+ interface OfflineReplicaSchemaDefinition {
191
+ /** Current bundle schema version. */
192
+ readonly version: number;
193
+ /** Entity schemas for the bundle version. */
194
+ readonly entities: readonly OfflineReplicaEntitySchema<Record<string, unknown>>[];
195
+ /** Ordered one-step migrations from older bundle versions. */
196
+ readonly migrations: readonly OfflineReplicaMigration[];
197
+ }
198
+ /**
199
+ * Validates and materializes a versioned offline replica schema bundle.
200
+ *
201
+ * Entity `tableName` and `sourceKey` values must each be unique within the bundle.
202
+ * Migrations must advance one version at a time without duplicates or gaps.
203
+ */
204
+ declare function defineOfflineReplicaSchema(definition: OfflineReplicaSchemaDefinition): OfflineReplicaSchemaBundle;
205
+ /**
206
+ * Computes a lowercase SHA-256 hex digest of {@link OfflineReplicaSchemaBundle.schemaFingerprintInput}.
207
+ */
208
+ declare function sha256OfflineReplicaSchema(bundle: OfflineReplicaSchemaBundle): Promise<string>;
209
+
210
+ /** Current durable storage schema used by both web and native repositories. */
211
+ declare const OFFLINE_SCHEMA_VERSION = 4;
212
+ /** User and group partition of all local offline data. */
213
+ interface OfflineScope {
214
+ userId: number;
215
+ groupId: number;
216
+ }
217
+ /** Synchronization state of a locally materialized product replica row. */
218
+ type OfflineReplicaSyncState = 'confirmed' | 'pending' | 'blocked_auth' | 'rejected' | 'conflict';
219
+ /** Durable processing state of an outbox command. */
220
+ type OfflineCommandState = 'pending' | 'sending' | 'retry_wait' | 'blocked_auth' | 'rejected' | 'conflict';
221
+ /** Product-agnostic mutation persisted in the outbox by local id. */
222
+ interface OfflineCommand<T = unknown> extends OfflineScope {
223
+ commandId: string;
224
+ aggregateType: string;
225
+ /** Immutable local id of the target. The outbox never persists a server id. */
226
+ aggregateLocalId: string;
227
+ operation: string;
228
+ payload: T;
229
+ /** Full optimistic entity value displayed while this command is pending. */
230
+ optimisticValue: unknown;
231
+ payloadHash: string;
232
+ baseRevision: string | number | null;
233
+ state: OfflineCommandState;
234
+ attempts: number;
235
+ retryAt: number | null;
236
+ createdAt: number;
237
+ lastErrorCode: string | null;
238
+ }
239
+ /** Product replica row materialized from a versioned schema entity. */
240
+ interface OfflineReplicaRow<TValues = unknown> extends OfflineScope {
241
+ /** Stable source key matching {@link OfflineReplicaEntitySchema.sourceKey}. */
242
+ sourceKey: string;
243
+ /** Immutable client-generated UUID used as the SQLite primary key. */
244
+ localId: string;
245
+ /** Server-assigned identifier after a successful create, otherwise null. */
246
+ serverId: number | null;
247
+ /** Current optimistic domain values displayed locally. */
248
+ values: TValues;
249
+ /** Last server-confirmed domain values, or null while pending. */
250
+ confirmedValues: TValues | null;
251
+ serverRevision: string | number | null;
252
+ fetchedAt: number;
253
+ syncState: OfflineReplicaSyncState;
254
+ }
255
+ /** Stable address of a product replica row inside a user and group replica. */
256
+ interface OfflineReplicaRowKey extends OfflineScope {
257
+ sourceKey: string;
258
+ localId: string;
259
+ }
260
+ /** Scope partition plus the durable replica pull cursor for that partition. */
261
+ interface OfflineReplicaCursor extends OfflineScope {
262
+ cursor: string;
263
+ }
264
+ /** Atomic changes applied to the local replica and durable outbox together. */
265
+ interface OfflineReplicaTransaction {
266
+ putRows?: readonly OfflineReplicaRow[];
267
+ removeRows?: readonly OfflineReplicaRowKey[];
268
+ putCommands?: readonly OfflineCommand[];
269
+ removeCommandIds?: readonly string[];
270
+ putCursors?: readonly OfflineReplicaCursor[];
271
+ }
272
+ /** Durable local replica and outbox persistence contract. */
273
+ interface OfflineRepository {
274
+ initialize(): Promise<void>;
275
+ getLastUserId(): Promise<number | null>;
276
+ setLastUserId(userId: number): Promise<void>;
277
+ getSessionManifest<T>(userId: number): Promise<T | null>;
278
+ putSessionManifest<T>(userId: number, value: T): Promise<void>;
279
+ getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
280
+ getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
281
+ getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
282
+ getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
283
+ getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
284
+ getCommandsForUser?(userId: number): Promise<OfflineCommand[]>;
285
+ putCommand(command: OfflineCommand): Promise<void>;
286
+ replaceCommand(command: OfflineCommand): Promise<void>;
287
+ removeCommand(commandId: string): Promise<void>;
288
+ clearUser(userId: number): Promise<void>;
289
+ clearGroup(scope: OfflineScope): Promise<void>;
290
+ transactReplica(transaction: OfflineReplicaTransaction): Promise<void>;
291
+ }
292
+ /** DI token for the selected platform repository. */
293
+ declare const OFFLINE_REPOSITORY: InjectionToken<OfflineRepository>;
294
+ /** Selects encrypted SQLite on native platforms and Ionic Storage on web. */
295
+ declare function selectOfflineRepository(platform: string, webRepository: OfflineRepository, nativeRepository: OfflineRepository): OfflineRepository;
296
+ /** WebはIonic StorageのIndexedDB driverを利用する。 */
297
+ declare class IonicOfflineRepository implements OfflineRepository {
298
+ #private;
299
+ initialize(): Promise<void>;
300
+ getLastUserId(): Promise<number | null>;
301
+ setLastUserId(userId: number): Promise<void>;
302
+ getSessionManifest<T>(userId: number): Promise<T | null>;
303
+ putSessionManifest<T>(userId: number, value: T): Promise<void>;
304
+ getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
305
+ getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
306
+ getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
307
+ getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
308
+ getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
309
+ getCommandsForUser(userId: number): Promise<OfflineCommand[]>;
310
+ putCommand(command: OfflineCommand): Promise<void>;
311
+ replaceCommand(command: OfflineCommand): Promise<void>;
312
+ removeCommand(commandId: string): Promise<void>;
313
+ clearUser(userId: number): Promise<void>;
314
+ clearGroup(scope: OfflineScope): Promise<void>;
315
+ transactReplica(transaction: OfflineReplicaTransaction): Promise<void>;
316
+ static ɵfac: i0.ɵɵFactoryDeclaration<IonicOfflineRepository, never>;
317
+ static ɵprov: i0.ɵɵInjectableDeclaration<IonicOfflineRepository>;
318
+ }
319
+
320
+ /** Server pull request for one user/group replica partition. */
321
+ interface OfflineReplicaPullRequest {
322
+ scope: OfflineScope;
323
+ cursor: string;
324
+ schemaVersion: number;
325
+ schemaHash: string;
326
+ }
327
+ /** One server-side replica mutation returned by an explicit pull page. */
328
+ interface OfflineReplicaChange {
329
+ sourceKey: string;
330
+ serverId: number;
331
+ serverRevision: string | number;
332
+ /** Idempotency command ids durably recorded by the server and reflected in this final row state. */
333
+ acknowledgedCommandIds?: readonly string[];
334
+ values: unknown | null;
335
+ deleted: boolean;
336
+ }
337
+ /** One explicit replica pull response page from the application backend. */
338
+ interface OfflineReplicaPullPage {
339
+ schemaVersion: number;
340
+ schemaHash: string;
341
+ changes: readonly OfflineReplicaChange[];
342
+ nextCursor: string;
343
+ hasMore: boolean;
344
+ }
345
+ /** Application-provided transport that fetches explicit replica pull pages from the server. */
346
+ interface OfflineReplicaPuller {
347
+ pull(request: OfflineReplicaPullRequest): Promise<OfflineReplicaPullPage>;
348
+ }
349
+ /** DI token for the application-provided explicit replica pull transport. */
350
+ declare const OFFLINE_REPLICA_PULLER: InjectionToken<OfflineReplicaPuller>;
351
+
352
+ /** Pulls authoritative server deltas into one durable local replica partition. */
353
+ declare class OfflineReplicaPullService {
354
+ #private;
355
+ pull(scope: OfflineScope): Promise<void>;
356
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineReplicaPullService, never>;
357
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineReplicaPullService>;
358
+ }
359
+
360
+ /** Server acknowledgement used to reconcile one optimistic local mutation. */
361
+ interface OfflineCommandResult {
362
+ /** AUTO_INCREMENT id returned by a successful create. */
363
+ serverId?: number;
364
+ serverRevision?: string | number;
365
+ /** Full server-confirmed domain values after applying the mutation. */
366
+ confirmedValues?: unknown;
367
+ /** Removes the local replica row after a confirmed server delete. */
368
+ removeReplica?: boolean;
369
+ response?: unknown;
370
+ }
371
+ /** Target ids resolved from the local replica immediately before transport. */
372
+ interface OfflineCommandTarget {
373
+ localId: string;
374
+ serverId: number | null;
375
+ }
376
+ /** 不透明なoperationを製品APIへ送信し、local replicaへ投影するadapter。 */
377
+ /** Product adapter that sends commands and projects acknowledgements into entities. */
378
+ interface OfflineCommandExecutor {
379
+ /** Sends the command using `command.commandId` as its durable server-side idempotency key. */
380
+ execute(command: OfflineCommand, target: OfflineCommandTarget): Promise<OfflineCommandResult>;
381
+ withServerRevision(command: OfflineCommand, revision: string | number): OfflineCommand;
382
+ }
383
+ /** DI token for the product-specific command transport adapter. */
384
+ declare const OFFLINE_COMMAND_EXECUTOR: InjectionToken<OfflineCommandExecutor>;
385
+ /** Authenticated user and group scopes currently eligible for synchronization. */
386
+ interface OfflineSyncSession {
387
+ userId: number;
388
+ scopes: OfflineScope[];
389
+ }
390
+ /** Product adapter that exposes the currently authenticated synchronization session. */
391
+ interface OfflineSyncContext {
392
+ getSession(): Promise<OfflineSyncSession | null>;
393
+ }
394
+ /** DI token for authenticated synchronization context. */
395
+ declare const OFFLINE_SYNC_CONTEXT: InjectionToken<OfflineSyncContext>;
396
+
397
+ /** Optional product hooks for entity projection and command cleanup. */
398
+ interface OfflineCommandHooks {
399
+ entityType(command: Pick<OfflineCommand, 'operation' | 'aggregateType'>): string;
400
+ onCommandRemoved?(command: OfflineCommand): Promise<void>;
401
+ }
402
+ declare const DEFAULT_OFFLINE_COMMAND_HOOKS: OfflineCommandHooks;
403
+ /** DI token for optional product-specific synchronization hooks. */
404
+ declare const OFFLINE_COMMAND_HOOKS: InjectionToken<OfflineCommandHooks>;
405
+
406
+ /** User choice when logout encounters unconfirmed local mutations. */
407
+ type OfflineLogoutAction = 'sync' | 'discard' | 'cancel';
408
+ /** Coordinates local persistence, session boundaries, network state, and outbox synchronization. */
409
+ declare class OfflineCoordinatorService {
410
+ #private;
411
+ readonly networkState: i0.Signal<_rdlabo_ionic_angular_kit_offline.OfflineNetworkState>;
412
+ readonly syncState: i0.Signal<_rdlabo_ionic_angular_kit_offline.OfflineSyncState>;
413
+ readonly pendingCount: i0.Signal<number>;
414
+ readonly conflicts: i0.Signal<_rdlabo_ionic_angular_kit_offline.OfflineCommand<unknown>[]>;
415
+ initialize(): Promise<void>;
416
+ activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
417
+ clearActiveSession(): Promise<void>;
418
+ prepareLogout(action: OfflineLogoutAction): Promise<boolean>;
419
+ flush(): Promise<void>;
420
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineCoordinatorService, never>;
421
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineCoordinatorService>;
422
+ }
423
+
424
+ /** Product-independent native offline persistence settings. */
425
+ interface OfflineKitOptions {
426
+ /** Encrypted SQLite database name used on iOS and Android. */
427
+ databaseName: string;
428
+ /** Resolves the native database key from secure device storage. Required on iOS and Android. */
429
+ encryptionKey?: () => Promise<string>;
430
+ /** Versioned product replica schema applied to native SQLite during initialization. */
431
+ replicaSchema: OfflineReplicaSchemaBundle;
432
+ }
433
+ /** DI token for product-independent offline persistence settings. */
434
+ declare const OFFLINE_KIT_OPTIONS: InjectionToken<OfflineKitOptions>;
435
+
436
+ type OfflineNetworkState = 'online' | 'offline' | 'unverified';
437
+ /** transport不能(status=0)だけをlocal replica fallback対象にし、HTTPエラーは隠さない。 */
438
+ declare function isOfflineFallbackError(error: unknown): boolean;
439
+ /** Combines operating-system connectivity with observed API reachability. */
440
+ declare class OfflineNetworkService {
441
+ #private;
442
+ readonly state: i0.Signal<OfflineNetworkState>;
443
+ readonly connected: i0.Signal<boolean>;
444
+ initialize(): Promise<void>;
445
+ markApiSuccess(): void;
446
+ markApiFailure(): void;
447
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineNetworkService, never>;
448
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineNetworkService>;
449
+ }
450
+
451
+ /** outbox再送時にoffline interceptorだけを迂回する。認証・retryは維持する。 */
452
+ declare const OFFLINE_BYPASS: HttpContextToken<boolean>;
453
+ /** Header attached to responses served from the local replica fallback. */
454
+ declare const OFFLINE_RESPONSE_HEADER = "X-Offline-Response";
455
+ /** Origin of a synthetic offline response. */
456
+ type OfflineResponseSource = 'local';
457
+ /** Product read policy backed by a local replica fallback for transport failures. */
458
+ interface OfflineReadRequestPlan {
459
+ kind: 'read';
460
+ readLocal(): Promise<HttpResponse<unknown> | null>;
461
+ }
462
+ /** Resolved offline handling strategy for an HTTP request. */
463
+ type OfflineRequestPlan = OfflineReadRequestPlan;
464
+ /** URL・DTO・replica key・feature flagは製品Policyだけが知る。 */
465
+ interface OfflineRequestPolicy {
466
+ resolve(request: HttpRequest<unknown>): OfflineRequestPlan | null;
467
+ }
468
+ /** Multi-provider token containing product request policies. */
469
+ declare const OFFLINE_REQUEST_POLICIES: InjectionToken<readonly OfflineRequestPolicy[]>;
470
+ /** Registers one product request policy with the offline interceptor. */
471
+ declare function provideOfflineRequestPolicy(policy: Type<OfflineRequestPolicy>): Provider[];
472
+ /** Resolves the first product policy matching an HTTP request. */
473
+ declare class OfflineRequestPolicyRegistry {
474
+ #private;
475
+ resolve(request: HttpRequest<unknown>): OfflineRequestPlan | null;
476
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineRequestPolicyRegistry, never>;
477
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineRequestPolicyRegistry>;
478
+ }
479
+
480
+ /** Minimal Capawesome SQLite surface required by the offline repository. */
481
+ interface CapawesomeSqlitePlugin {
482
+ open(options: {
483
+ path: string;
484
+ encryptionKey: string;
485
+ readOnly: false;
486
+ }): Promise<{
487
+ databaseId: string;
488
+ }>;
489
+ execute(options: {
490
+ databaseId: string;
491
+ statement: string;
492
+ values?: SQLiteValue[];
493
+ }): Promise<unknown>;
494
+ query(options: {
495
+ databaseId: string;
496
+ statement: string;
497
+ values?: SQLiteValue[];
498
+ }): Promise<{
499
+ columns?: string[];
500
+ rows?: unknown[];
501
+ }>;
502
+ beginTransaction(options: {
503
+ databaseId: string;
504
+ }): Promise<void>;
505
+ commitTransaction(options: {
506
+ databaseId: string;
507
+ }): Promise<void>;
508
+ rollbackTransaction(options: {
509
+ databaseId: string;
510
+ }): Promise<void>;
511
+ }
512
+ /** DI token for the optional application-installed Capawesome SQLite plugin. */
513
+ declare const CAPAWESOME_SQLITE: InjectionToken<CapawesomeSqlitePlugin | null>;
514
+ type SQLiteValue = string | number | null;
515
+ /** Native iOS/Android uses the encrypted Capawesome SQLite plugin supplied by the application. */
516
+ declare class SqliteOfflineRepository implements OfflineRepository {
517
+ #private;
518
+ initialize(): Promise<void>;
519
+ getLastUserId(): Promise<number | null>;
520
+ setLastUserId(userId: number): Promise<void>;
521
+ getSessionManifest<T>(userId: number): Promise<T | null>;
522
+ putSessionManifest<T>(userId: number, value: T): Promise<void>;
523
+ getReplicaRow<TValues = unknown>(scope: OfflineScope, sourceKey: string, localId: string): Promise<OfflineReplicaRow<TValues> | null>;
524
+ getReplicaRows<TValues = unknown>(scope: OfflineScope, sourceKey: string): Promise<OfflineReplicaRow<TValues>[]>;
525
+ getReplicaRowByServerId<TValues = unknown>(scope: OfflineScope, sourceKey: string, serverId: number): Promise<OfflineReplicaRow<TValues> | null>;
526
+ getReplicaCursor(scope: OfflineScope): Promise<OfflineReplicaCursor | null>;
527
+ getCommands(scope: OfflineScope): Promise<OfflineCommand[]>;
528
+ getCommandsForUser(userId: number): Promise<OfflineCommand[]>;
529
+ putCommand(command: OfflineCommand): Promise<void>;
530
+ replaceCommand(command: OfflineCommand): Promise<void>;
531
+ removeCommand(commandId: string): Promise<void>;
532
+ clearUser(userId: number): Promise<void>;
533
+ clearGroup(scope: OfflineScope): Promise<void>;
534
+ transactReplica(transaction: OfflineReplicaTransaction): Promise<void>;
535
+ static ɵfac: i0.ɵɵFactoryDeclaration<SqliteOfflineRepository, never>;
536
+ static ɵprov: i0.ɵɵInjectableDeclaration<SqliteOfflineRepository>;
537
+ }
538
+
539
+ /** Configuration for the standard offline repository, outbox, and request-policy runtime. */
540
+ interface ProvideOfflineOptions extends OfflineKitOptions {
541
+ /** Product adapter that sends opaque commands to its API. */
542
+ commandExecutor: Type<OfflineCommandExecutor>;
543
+ /** Product transport for explicit cursor-based server delta pulls. */
544
+ replicaPuller: Type<OfflineReplicaPuller>;
545
+ /** Product policies that map URLs and DTOs to generic replica/outbox operations. */
546
+ requestPolicies: readonly Type<OfflineRequestPolicy>[];
547
+ /** Optional product hooks for entity projection and command cleanup. */
548
+ commandHooks?: Type<OfflineCommandHooks>;
549
+ /** Optional additional providers required by product adapters. */
550
+ providers?: readonly Provider[];
551
+ /** Capawesome `Sqlite` plugin. Required only when this runtime is selected on iOS or Android. */
552
+ sqlitePlugin?: CapawesomeSqlitePlugin;
553
+ }
554
+ /**
555
+ * Provide the standard scoped offline runtime.
556
+ *
557
+ * @remarks
558
+ * Web uses Ionic Storage. Native iOS/Android uses encrypted Capawesome SQLite. The application owns
559
+ * URL/DTO policy and command execution; the kit owns persistence, ordering, retries, and session
560
+ * isolation.
561
+ */
562
+ declare function provideOffline(options: ProvideOfflineOptions): EnvironmentProviders;
563
+
564
+ /** Persisted identity and group boundary for one authenticated local replica. */
565
+ interface OfflineSessionManifest {
566
+ userId: number;
567
+ scopeIds: number[];
568
+ /** Authentication-provider subject used to distinguish users on a shared device. */
569
+ authSubject: string | null;
570
+ updatedAt: number;
571
+ }
572
+ /** Owns activation and cleanup of the authenticated local-replica boundary. */
573
+ declare class OfflineSessionService {
574
+ #private;
575
+ readonly activeManifest: i0.Signal<OfflineSessionManifest | null>;
576
+ initialize(): Promise<void>;
577
+ activateSession(userId: number, scopeIds: readonly number[], authSubject: string | null): Promise<void>;
578
+ clearActiveSession(): Promise<void>;
579
+ getSession(): Promise<{
580
+ userId: number;
581
+ scopes: OfflineScope[];
582
+ } | null>;
583
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineSessionService, never>;
584
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineSessionService>;
585
+ }
586
+
587
+ /** Aggregate synchronization state exposed to application UI. */
588
+ type OfflineSyncState = 'idle' | 'pending' | 'syncing' | 'attention';
589
+ /** Mutation and optimistic entity materialization appended atomically to the outbox. */
590
+ interface EnqueueOfflineCommand<T = unknown> {
591
+ groupId: number;
592
+ aggregateType: string;
593
+ /** Stable UUID generated by the client before the entity is first written. */
594
+ aggregateLocalId: string;
595
+ operation: string;
596
+ payload: T;
597
+ /** Full local entity value committed to the replica before the command is exposed to the UI. */
598
+ optimisticValue: unknown;
599
+ baseRevision?: string | number | null;
600
+ }
601
+ /** Raised before persistence when an outbox payload is not losslessly JSON serializable. */
602
+ declare class OfflinePayloadValidationError extends Error {
603
+ constructor(message?: string);
604
+ }
605
+ /** Maintains the optimistic local replica and synchronizes its durable outbox. */
606
+ declare class OfflineSyncService {
607
+ #private;
608
+ readonly pendingCommands: i0.Signal<OfflineCommand<unknown>[]>;
609
+ readonly pendingCount: i0.Signal<number>;
610
+ readonly conflicts: i0.Signal<OfflineCommand<unknown>[]>;
611
+ readonly syncState: i0.Signal<OfflineSyncState>;
612
+ constructor();
613
+ initialize(): Promise<void>;
614
+ noteScope(scope: OfflineScope): void;
615
+ reloadPendingCommands(): Promise<void>;
616
+ refreshSession(): Promise<void>;
617
+ resetSession(): Promise<void>;
618
+ enqueue<T>(request: EnqueueOfflineCommand<T>, options?: {
619
+ flush?: boolean;
620
+ }): Promise<string>;
621
+ discard(commandId: string, options?: {
622
+ flush?: boolean;
623
+ }): Promise<void>;
624
+ discardAllPending(): Promise<void>;
625
+ flush(): Promise<void>;
626
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineSyncService, never>;
627
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineSyncService>;
628
+ }
629
+
630
+ /** Applies product offline read policies while observing real API reachability. */
631
+ declare const offlineInterceptor: HttpInterceptorFn;
632
+ /** Resolves transport failures from the local replica without hiding HTTP errors. */
633
+ declare class OfflineRequestFallbackService {
634
+ #private;
635
+ handle(request: HttpRequest<unknown>, error: unknown, resolvedPlan?: ReturnType<OfflineRequestPolicyRegistry['resolve']>): Observable<HttpEvent<unknown>> | null;
636
+ static ɵfac: i0.ɵɵFactoryDeclaration<OfflineRequestFallbackService, never>;
637
+ static ɵprov: i0.ɵɵInjectableDeclaration<OfflineRequestFallbackService>;
638
+ }
639
+
640
+ export { CAPAWESOME_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, OfflinePayloadValidationError, OfflineReplicaPullService, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineSyncService, SqliteOfflineRepository, booleanColumn, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, ignored, integer, isOfflineFallbackError, json, nullable, offlineInterceptor, projectOfflineReplicaValues, provideOffline, provideOfflineRequestPolicy, real, selectOfflineRepository, serverId, sha256OfflineReplicaSchema, text };
641
+ export type { CapawesomeSqlitePlugin, EnqueueOfflineCommand, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineKitOptions, OfflineLogoutAction, OfflineNetworkState, OfflineReadRequestPlan, 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, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, ProvideOfflineOptions };
@@ -1371,6 +1371,12 @@ declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
1371
1371
  protected suspend(): void;
1372
1372
  /** Reset resync and backoff history when the owning session ends. */
1373
1373
  protected resetConnectionState(): void;
1374
+ /** Register lifecycle listeners and establish the currently requested targets. */
1375
+ protected startConnection(): Promise<void>;
1376
+ /** End the current connection session and release all lifecycle resources. */
1377
+ protected stopConnection(): void;
1378
+ /** Rebuild targets while preserving the owning session's connection intent and listeners. */
1379
+ protected refreshConnectionTargets(): Promise<void>;
1374
1380
  /** Open missing targets, preserving healthy sockets when another target fails. */
1375
1381
  protected open(): Promise<void>;
1376
1382
  static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>, never>;