kaafil-js 0.1.0 → 0.2.0
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/dist/client-entry.cjs +82 -3
- package/dist/client-entry.cjs.map +1 -1
- package/dist/client-entry.d.cts +97 -31
- package/dist/client-entry.d.ts +97 -31
- package/dist/client-entry.js +82 -4
- package/dist/client-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/client-entry.d.cts
CHANGED
|
@@ -1036,36 +1036,10 @@ declare function createDrainer(options: CreateDrainerOptions): Drainer;
|
|
|
1036
1036
|
/** Every section the vendored spec can send. */
|
|
1037
1037
|
declare const SYNC_PULL_SECTIONS: readonly ["rooming", "stayWindows", "pickups", "seating", "bookings", "expenses", "checklist", "float", "collections", "itinerary", "closeout"];
|
|
1038
1038
|
type SyncPullSection = (typeof SYNC_PULL_SECTIONS)[number];
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
*
|
|
1042
|
-
|
|
1043
|
-
*
|
|
1044
|
-
* NEVER GUESSES. An array of identified rows is taken as-is; an object with
|
|
1045
|
-
* EXACTLY ONE array-valued property whose elements carry `id` is taken from
|
|
1046
|
-
* that property. Zero such properties, or two, and this returns `undefined`,
|
|
1047
|
-
* which the caller treats exactly like an absent section: rows untouched,
|
|
1048
|
-
* cursor untouched. Picking the likelier of two arrays would be a silent
|
|
1049
|
-
* wrong answer, and the failure mode of a silent wrong answer here is a
|
|
1050
|
-
* manager's screen showing the wrong list.
|
|
1051
|
-
*
|
|
1052
|
-
* TWO ARRAYS IS USUALLY NOT AMBIGUITY — IT IS ONE FEED PLUS A PROJECTION.
|
|
1053
|
-
* `rooming` is the worked example. `RoomingBoardResponse` carries three
|
|
1054
|
-
* arrays, and only `rooms[]` is delta-shaped: its items are `anyOf` a live
|
|
1055
|
-
* row (`id`/`version`/`updatedAt`) or a tombstone (`_tombstone`/`id`/
|
|
1056
|
-
* `version`/`deletedAt`). `windows[]` and `unassigned[]` are plain objects
|
|
1057
|
-
* keyed on `stayWindowId`/`travellerId`, with no tombstone branch and no
|
|
1058
|
-
* version — they are DERIVED projections the engine recomputes per read
|
|
1059
|
-
* (`windows[]` carries `assignedCount`/`roomCount`; `unassigned[]` carries
|
|
1060
|
-
* `assignSource`). So this function selecting `rooms[]` alone is the correct
|
|
1061
|
-
* answer here, not a limitation to route around: caching `unassigned[]` as
|
|
1062
|
-
* delta rows would be a real bug, because no tombstone can ever arrive for a
|
|
1063
|
-
* traveller who GETS a bed, and `applyPull` rebases by id rather than
|
|
1064
|
-
* replacing — the cached pool would grow monotonically and never shrink.
|
|
1065
|
-
* A consumer that needs a derived projection reads it live from its own
|
|
1066
|
-
* resource call; it is not cache-first data and must not be made to look so.
|
|
1067
|
-
*/
|
|
1068
|
-
declare function extractSectionRows(data: unknown): readonly DeltaRow<SnapshotRow>[] | undefined;
|
|
1039
|
+
declare function extractSectionRows(data: unknown,
|
|
1040
|
+
/** The section this `data` came from, when the caller knows it. An external
|
|
1041
|
+
* caller inspecting an arbitrary payload omits it and gets the heuristic. */
|
|
1042
|
+
section?: SyncPullSection): readonly DeltaRow<SnapshotRow>[] | undefined;
|
|
1069
1043
|
interface PullTripResult {
|
|
1070
1044
|
readonly tripRef: string;
|
|
1071
1045
|
/** The cursor now stored for every section that was PRESENT: this
|
|
@@ -1107,6 +1081,92 @@ declare function createPullCoordinator(options: {
|
|
|
1107
1081
|
readonly onServerTime?: (serverTime: string) => void;
|
|
1108
1082
|
}): PullCoordinator;
|
|
1109
1083
|
|
|
1084
|
+
/**
|
|
1085
|
+
* The THIRD half of the local store: last-known-good whole responses for
|
|
1086
|
+
* reads that are not delta lists.
|
|
1087
|
+
*
|
|
1088
|
+
* ── WHY THIS IS NOT THE SNAPSHOT STORE ────────────────────────────────────
|
|
1089
|
+
*
|
|
1090
|
+
* `./snapshot.ts` merges by `id` + `version`, in both directions, and that
|
|
1091
|
+
* guarantee is the reason it is safe. It can only hold rows that genuinely
|
|
1092
|
+
* carry a `DeltaIdentity`, because a fabricated `version` turns a
|
|
1093
|
+
* version-guarded merge into a coin toss: the same row written twice either
|
|
1094
|
+
* silently wins or silently loses depending on a number that means nothing.
|
|
1095
|
+
*
|
|
1096
|
+
* Some reads this SDK exposes are not delta lists and never will be.
|
|
1097
|
+
* `GET /manager/me/trips` is the motivating one — its rows carry a
|
|
1098
|
+
* `tripRef`, a name and a status, but no `id` and no `version`, because it
|
|
1099
|
+
* is a projection of the caller's assignments rather than a table. It has no
|
|
1100
|
+
* `?since=` window, no tombstones, and no per-row identity to merge on. It
|
|
1101
|
+
* is a whole answer or it is nothing.
|
|
1102
|
+
*
|
|
1103
|
+
* Forcing such a response through the snapshot store would mean inventing
|
|
1104
|
+
* the identity that makes the snapshot store correct. So it gets its own
|
|
1105
|
+
* lane instead, with a deliberately smaller promise.
|
|
1106
|
+
*
|
|
1107
|
+
* ── THE PROMISE, AND ITS LIMITS ───────────────────────────────────────────
|
|
1108
|
+
*
|
|
1109
|
+
* Exactly one thing: **the last response that actually landed, and when the
|
|
1110
|
+
* SERVER said that was.** Whole-value replace, last writer wins, no merge,
|
|
1111
|
+
* no cursor, no tombstones, no events.
|
|
1112
|
+
*
|
|
1113
|
+
* That is enough for the case it exists for — a field surface that must
|
|
1114
|
+
* paint what it last knew rather than blank when the read cannot be made —
|
|
1115
|
+
* and it is deliberately not enough to build a sync lane on. Anything with a
|
|
1116
|
+
* per-row identity and a delta window belongs in the snapshot store, and
|
|
1117
|
+
* putting it here instead would lose rows the moment two writers overlap.
|
|
1118
|
+
*
|
|
1119
|
+
* `syncedAt` is the response's own `meta.serverTime` and there is no setter
|
|
1120
|
+
* that takes anything else, for the same reason `applyPull` has none: a
|
|
1121
|
+
* device clock would make "as of 14:02" a lie on exactly the devices whose
|
|
1122
|
+
* clocks are worst.
|
|
1123
|
+
*
|
|
1124
|
+
* Keys are opaque to this module and chosen by the caller. They are
|
|
1125
|
+
* namespaced under the engine's credential scope by `keyPrefix`, so one
|
|
1126
|
+
* manager's cached answer can never be read under another's session.
|
|
1127
|
+
*/
|
|
1128
|
+
|
|
1129
|
+
/** One cached response, as it sits on disk. */
|
|
1130
|
+
interface CachedRead<T = unknown> {
|
|
1131
|
+
readonly value: T;
|
|
1132
|
+
/** The `meta.serverTime` of the response this came from — never a device
|
|
1133
|
+
* clock. */
|
|
1134
|
+
readonly syncedAt: string;
|
|
1135
|
+
}
|
|
1136
|
+
interface ReadCacheStore {
|
|
1137
|
+
/**
|
|
1138
|
+
* The last response that landed for this key, or `undefined` if none ever
|
|
1139
|
+
* has. Resolves from memory once `load()` has run — a first paint must not
|
|
1140
|
+
* wait on a disk read it already did.
|
|
1141
|
+
*
|
|
1142
|
+
* The value is returned as it was stored. This module does not know the
|
|
1143
|
+
* shape and does not validate it: a caller that changes what it puts under
|
|
1144
|
+
* a key is responsible for tolerating the old shape, exactly as it would
|
|
1145
|
+
* be for anything else that outlives a deploy.
|
|
1146
|
+
*/
|
|
1147
|
+
get<T>(key: string): CachedRead<T> | undefined;
|
|
1148
|
+
/**
|
|
1149
|
+
* Replaces the value under `key` wholesale.
|
|
1150
|
+
*
|
|
1151
|
+
* `serverTime` MUST be the `meta.serverTime` of the response `value` came
|
|
1152
|
+
* in. There is no overload that omits it, because a cached read whose age
|
|
1153
|
+
* is unknown is worse than no cached read: a surface will render it with
|
|
1154
|
+
* confidence.
|
|
1155
|
+
*/
|
|
1156
|
+
set(key: string, value: unknown, serverTime: string): Promise<void>;
|
|
1157
|
+
/** Drops one key. Nothing in this SDK calls it; it exists so a host that
|
|
1158
|
+
* caches something sensitive can stop. */
|
|
1159
|
+
purge(key: string): Promise<void>;
|
|
1160
|
+
/** Hydrates from the durable adapter. Call once, before first paint. */
|
|
1161
|
+
load(): Promise<void>;
|
|
1162
|
+
}
|
|
1163
|
+
interface CreateReadCacheStoreOptions {
|
|
1164
|
+
readonly storage: KaafilStorageAdapter;
|
|
1165
|
+
/** Namespacing key prefix, already credential-scoped by the engine. */
|
|
1166
|
+
readonly keyPrefix: string;
|
|
1167
|
+
}
|
|
1168
|
+
declare function createReadCacheStore(options: CreateReadCacheStoreOptions): ReadCacheStore;
|
|
1169
|
+
|
|
1110
1170
|
/**
|
|
1111
1171
|
* Share-token offline: local expiry enforcement, reconnect re-validation, the
|
|
1112
1172
|
* minimal write set, and the 7-day post-expiry grace.
|
|
@@ -1264,6 +1324,12 @@ interface EnqueueWithBlobOptions extends EnqueueWriteOptions {
|
|
|
1264
1324
|
interface OfflineEngine {
|
|
1265
1325
|
readonly events: OfflineEvents;
|
|
1266
1326
|
readonly snapshot: SnapshotStore;
|
|
1327
|
+
/**
|
|
1328
|
+
* Last-known-good whole responses for reads that are NOT delta lists —
|
|
1329
|
+
* see `./reads.ts` for why those cannot live in `snapshot`. Durable and
|
|
1330
|
+
* credential-scoped like every other store here.
|
|
1331
|
+
*/
|
|
1332
|
+
readonly reads: ReadCacheStore;
|
|
1267
1333
|
readonly outbox: Outbox;
|
|
1268
1334
|
readonly drainer: Drainer;
|
|
1269
1335
|
readonly pull: PullCoordinator;
|
|
@@ -2720,4 +2786,4 @@ declare class KaafilClient {
|
|
|
2720
2786
|
static newIdempotencyKey(): string;
|
|
2721
2787
|
}
|
|
2722
2788
|
|
|
2723
|
-
export { AgenciesResource, AgencyAdminMeResource, AgencyAdminRefreshResult, type ApplyPullResult, BATCH_THRESHOLD_OPS, type BlobBackfill, type BlobBytes, type BlobDrainReport, type BlobLane, type BlobRecord, type BlobSource, BlobStatus, type BlobUploader, BookingsResource, type BoundAgenciesResource, type BoundChecklistsResource, type BoundCreateAgencyChecklistTemplateOptions, type BoundCreateFormOptions, type BoundCreateTravellerOptions, type BoundCreateVendorOptions, type BoundDeleteAgencyChecklistTemplateOptions, type BoundDeleteVendorOptions, type BoundFeedbackNpsResource, type BoundFormsResource, type BoundGetAgencyManagerProfileOptions, type BoundGetAgencyTripOptions, type BoundGetTravellerAgencyProfileOptions, type BoundJourneyResource, type BoundListAgencyChecklistTemplatesOptions, type BoundListAgencyManagersOptions, type BoundListAgencyManagersPageOptions, type BoundListAgencyTripsOptions, type BoundListAgencyTripsPageOptions, type BoundListForAgencyOptions, type BoundListForAgencyPageOptions, type BoundListFormsOptions, type BoundListJourneyTriggersOptions, type BoundListTripManifestOptions, type BoundListTripManifestPageOptions, type BoundPatchAgencyChecklistTemplateOptions, type BoundPatchAgencySettingsOptions, type BoundPatchJourneyTriggerOptions, type BoundPublishAgencyChecklistTemplateOptions, type BoundReadAgencyFeedbackSummaryOptions, type BoundReadAgencySettingsOptions, type BoundTravellersResource, type BoundUpsertVendorOptions, type BoundVendorsResource, CONSOLIDATED_PULL_THRESHOLD_LISTS, ChecklistsResource, CloseoutResource, CollectionsResource, type CompressImageOptions, type CompressedImage, CompressionOutcome, type ConflictContext, type ConflictResolution, type ConflictResolver, CreateAgencyChecklistTemplateOptions, type CreateDrainerOptions, CreateFormOptions, type CreateOfflineEngineOptions, type CreateOutboxOptions, CreateTravellerOptions, CreateVendorOptions, DeleteAgencyChecklistTemplateOptions, DeleteVendorOptions, DeltaIdentity, DeltaMergeStats, DeltaRow, type DrainOptions, type DrainReport, type Drainer, type EnqueueOptions, type EnqueueWithBlobOptions, type EnqueueWriteOptions, type EntityReadResult, type EntityReader, Environment, ExpensesResource, FeedbackNpsResource, FilesResource, FloatResource, FormsResource, GetAgencyManagerProfileOptions, GetAgencyTripOptions, GetTravellerAgencyProfileOptions, type IndexedDbStorageAdapterOptions, ItineraryResource, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilResponse, KaafilShareLinkExpiredError, type KaafilStorageAdapter, ListAgencyChecklistTemplatesOptions, ListAgencyManagersOptions, ListAgencyManagersPageOptions, ListAgencyTripsOptions, ListAgencyTripsPageOptions, ListForAgencyOptions, ListForAgencyPageOptions, ListFormsOptions, type ListManagerExpensesOptions, type ListManagerNotificationsOptions, type ListOwnManagerTripsOptions, type ListShareFormsOptions, ListTripManifestOptions, ListTripManifestPageOptions, type LosslessImageOptions, MAX_BATCH_OPS, type ManagerExpenseFilters, type ManagerExpensesResource, type ManagerMeResource, type ManagerOwnTrip, type ManagerOwnTripsResponse, ManagerRefreshResult, ManagerTodayResource, type MarkNotificationReadOptions, type MonotonicClock, type NotificationsResource, type OfflineEngine, type OfflineEventHandler, type OfflineEventMap, type OfflineEventName, type OfflineEvents, type OfflineTransport, type OpOutcome, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenOfflineOptions, type OpenShareTokenOptions, type Outbox, type OutboxCounts, type OutboxEntityRef, type OutboxOp, type OutboxParkReason, OutboxRetryCause, OutboxStatus, PatchAgencyChecklistTemplateOptions, PatchAgencySettingsOptions, PickupsResource, PublishAgencyChecklistTemplateOptions, type PullCoordinator, type PullResult, type PullSection, type PullTripResult, ReadAgencyFeedbackSummaryOptions, ReadAgencySettingsOptions, type ReadManagerExpenseLogMetaOptions, type ReadManagerExpenseOptions, type ReadShareFormOptions, type ReadShareManifestOptions, type ReadShareSnapshotOptions, type ReconcileOutcome, Resolvable, RoomingResource, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, type SaveShareFormOptions, SeatingResource, type ShareFormsResource, type ShareGuard, type ShareInvalidatedEvent, type ShareResource, ShareTokensResource, type SnapshotList, type SnapshotRow, type SnapshotStore, type SnapshotUpdatedEvent, type SubmitShareFormOptions, type SyncDrainedEvent, type SyncErrorEvent, SyncOpMethod, type SyncPullSection, SyncResource, TravellersResource, TreksResource, TripsResource, type Unsubscribe, UpsertVendorOptions, VendorsResource, compressImage, convertImageLossless, createBlobLane, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createShareGuard, createSnapshotStore, extractSectionRows, isCompressibleType, isImageCompressionSupported, readCurrentVersion, reconcileConflict, scaledDimensions, shouldUseBatchTransport };
|
|
2789
|
+
export { AgenciesResource, AgencyAdminMeResource, AgencyAdminRefreshResult, type ApplyPullResult, BATCH_THRESHOLD_OPS, type BlobBackfill, type BlobBytes, type BlobDrainReport, type BlobLane, type BlobRecord, type BlobSource, BlobStatus, type BlobUploader, BookingsResource, type BoundAgenciesResource, type BoundChecklistsResource, type BoundCreateAgencyChecklistTemplateOptions, type BoundCreateFormOptions, type BoundCreateTravellerOptions, type BoundCreateVendorOptions, type BoundDeleteAgencyChecklistTemplateOptions, type BoundDeleteVendorOptions, type BoundFeedbackNpsResource, type BoundFormsResource, type BoundGetAgencyManagerProfileOptions, type BoundGetAgencyTripOptions, type BoundGetTravellerAgencyProfileOptions, type BoundJourneyResource, type BoundListAgencyChecklistTemplatesOptions, type BoundListAgencyManagersOptions, type BoundListAgencyManagersPageOptions, type BoundListAgencyTripsOptions, type BoundListAgencyTripsPageOptions, type BoundListForAgencyOptions, type BoundListForAgencyPageOptions, type BoundListFormsOptions, type BoundListJourneyTriggersOptions, type BoundListTripManifestOptions, type BoundListTripManifestPageOptions, type BoundPatchAgencyChecklistTemplateOptions, type BoundPatchAgencySettingsOptions, type BoundPatchJourneyTriggerOptions, type BoundPublishAgencyChecklistTemplateOptions, type BoundReadAgencyFeedbackSummaryOptions, type BoundReadAgencySettingsOptions, type BoundTravellersResource, type BoundUpsertVendorOptions, type BoundVendorsResource, CONSOLIDATED_PULL_THRESHOLD_LISTS, type CachedRead, ChecklistsResource, CloseoutResource, CollectionsResource, type CompressImageOptions, type CompressedImage, CompressionOutcome, type ConflictContext, type ConflictResolution, type ConflictResolver, CreateAgencyChecklistTemplateOptions, type CreateDrainerOptions, CreateFormOptions, type CreateOfflineEngineOptions, type CreateOutboxOptions, type CreateReadCacheStoreOptions, CreateTravellerOptions, CreateVendorOptions, DeleteAgencyChecklistTemplateOptions, DeleteVendorOptions, DeltaIdentity, DeltaMergeStats, DeltaRow, type DrainOptions, type DrainReport, type Drainer, type EnqueueOptions, type EnqueueWithBlobOptions, type EnqueueWriteOptions, type EntityReadResult, type EntityReader, Environment, ExpensesResource, FeedbackNpsResource, FilesResource, FloatResource, FormsResource, GetAgencyManagerProfileOptions, GetAgencyTripOptions, GetTravellerAgencyProfileOptions, type IndexedDbStorageAdapterOptions, ItineraryResource, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilResponse, KaafilShareLinkExpiredError, type KaafilStorageAdapter, ListAgencyChecklistTemplatesOptions, ListAgencyManagersOptions, ListAgencyManagersPageOptions, ListAgencyTripsOptions, ListAgencyTripsPageOptions, ListForAgencyOptions, ListForAgencyPageOptions, ListFormsOptions, type ListManagerExpensesOptions, type ListManagerNotificationsOptions, type ListOwnManagerTripsOptions, type ListShareFormsOptions, ListTripManifestOptions, ListTripManifestPageOptions, type LosslessImageOptions, MAX_BATCH_OPS, type ManagerExpenseFilters, type ManagerExpensesResource, type ManagerMeResource, type ManagerOwnTrip, type ManagerOwnTripsResponse, ManagerRefreshResult, ManagerTodayResource, type MarkNotificationReadOptions, type MonotonicClock, type NotificationsResource, type OfflineEngine, type OfflineEventHandler, type OfflineEventMap, type OfflineEventName, type OfflineEvents, type OfflineTransport, type OpOutcome, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenOfflineOptions, type OpenShareTokenOptions, type Outbox, type OutboxCounts, type OutboxEntityRef, type OutboxOp, type OutboxParkReason, OutboxRetryCause, OutboxStatus, PatchAgencyChecklistTemplateOptions, PatchAgencySettingsOptions, PickupsResource, PublishAgencyChecklistTemplateOptions, type PullCoordinator, type PullResult, type PullSection, type PullTripResult, ReadAgencyFeedbackSummaryOptions, ReadAgencySettingsOptions, type ReadCacheStore, type ReadManagerExpenseLogMetaOptions, type ReadManagerExpenseOptions, type ReadShareFormOptions, type ReadShareManifestOptions, type ReadShareSnapshotOptions, type ReconcileOutcome, Resolvable, RoomingResource, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, type SaveShareFormOptions, SeatingResource, type ShareFormsResource, type ShareGuard, type ShareInvalidatedEvent, type ShareResource, ShareTokensResource, type SnapshotList, type SnapshotRow, type SnapshotStore, type SnapshotUpdatedEvent, type SubmitShareFormOptions, type SyncDrainedEvent, type SyncErrorEvent, SyncOpMethod, type SyncPullSection, SyncResource, TravellersResource, TreksResource, TripsResource, type Unsubscribe, UpsertVendorOptions, VendorsResource, compressImage, convertImageLossless, createBlobLane, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createReadCacheStore, createShareGuard, createSnapshotStore, extractSectionRows, isCompressibleType, isImageCompressionSupported, readCurrentVersion, reconcileConflict, scaledDimensions, shouldUseBatchTransport };
|
package/dist/client-entry.d.ts
CHANGED
|
@@ -1036,36 +1036,10 @@ declare function createDrainer(options: CreateDrainerOptions): Drainer;
|
|
|
1036
1036
|
/** Every section the vendored spec can send. */
|
|
1037
1037
|
declare const SYNC_PULL_SECTIONS: readonly ["rooming", "stayWindows", "pickups", "seating", "bookings", "expenses", "checklist", "float", "collections", "itinerary", "closeout"];
|
|
1038
1038
|
type SyncPullSection = (typeof SYNC_PULL_SECTIONS)[number];
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
*
|
|
1042
|
-
|
|
1043
|
-
*
|
|
1044
|
-
* NEVER GUESSES. An array of identified rows is taken as-is; an object with
|
|
1045
|
-
* EXACTLY ONE array-valued property whose elements carry `id` is taken from
|
|
1046
|
-
* that property. Zero such properties, or two, and this returns `undefined`,
|
|
1047
|
-
* which the caller treats exactly like an absent section: rows untouched,
|
|
1048
|
-
* cursor untouched. Picking the likelier of two arrays would be a silent
|
|
1049
|
-
* wrong answer, and the failure mode of a silent wrong answer here is a
|
|
1050
|
-
* manager's screen showing the wrong list.
|
|
1051
|
-
*
|
|
1052
|
-
* TWO ARRAYS IS USUALLY NOT AMBIGUITY — IT IS ONE FEED PLUS A PROJECTION.
|
|
1053
|
-
* `rooming` is the worked example. `RoomingBoardResponse` carries three
|
|
1054
|
-
* arrays, and only `rooms[]` is delta-shaped: its items are `anyOf` a live
|
|
1055
|
-
* row (`id`/`version`/`updatedAt`) or a tombstone (`_tombstone`/`id`/
|
|
1056
|
-
* `version`/`deletedAt`). `windows[]` and `unassigned[]` are plain objects
|
|
1057
|
-
* keyed on `stayWindowId`/`travellerId`, with no tombstone branch and no
|
|
1058
|
-
* version — they are DERIVED projections the engine recomputes per read
|
|
1059
|
-
* (`windows[]` carries `assignedCount`/`roomCount`; `unassigned[]` carries
|
|
1060
|
-
* `assignSource`). So this function selecting `rooms[]` alone is the correct
|
|
1061
|
-
* answer here, not a limitation to route around: caching `unassigned[]` as
|
|
1062
|
-
* delta rows would be a real bug, because no tombstone can ever arrive for a
|
|
1063
|
-
* traveller who GETS a bed, and `applyPull` rebases by id rather than
|
|
1064
|
-
* replacing — the cached pool would grow monotonically and never shrink.
|
|
1065
|
-
* A consumer that needs a derived projection reads it live from its own
|
|
1066
|
-
* resource call; it is not cache-first data and must not be made to look so.
|
|
1067
|
-
*/
|
|
1068
|
-
declare function extractSectionRows(data: unknown): readonly DeltaRow<SnapshotRow>[] | undefined;
|
|
1039
|
+
declare function extractSectionRows(data: unknown,
|
|
1040
|
+
/** The section this `data` came from, when the caller knows it. An external
|
|
1041
|
+
* caller inspecting an arbitrary payload omits it and gets the heuristic. */
|
|
1042
|
+
section?: SyncPullSection): readonly DeltaRow<SnapshotRow>[] | undefined;
|
|
1069
1043
|
interface PullTripResult {
|
|
1070
1044
|
readonly tripRef: string;
|
|
1071
1045
|
/** The cursor now stored for every section that was PRESENT: this
|
|
@@ -1107,6 +1081,92 @@ declare function createPullCoordinator(options: {
|
|
|
1107
1081
|
readonly onServerTime?: (serverTime: string) => void;
|
|
1108
1082
|
}): PullCoordinator;
|
|
1109
1083
|
|
|
1084
|
+
/**
|
|
1085
|
+
* The THIRD half of the local store: last-known-good whole responses for
|
|
1086
|
+
* reads that are not delta lists.
|
|
1087
|
+
*
|
|
1088
|
+
* ── WHY THIS IS NOT THE SNAPSHOT STORE ────────────────────────────────────
|
|
1089
|
+
*
|
|
1090
|
+
* `./snapshot.ts` merges by `id` + `version`, in both directions, and that
|
|
1091
|
+
* guarantee is the reason it is safe. It can only hold rows that genuinely
|
|
1092
|
+
* carry a `DeltaIdentity`, because a fabricated `version` turns a
|
|
1093
|
+
* version-guarded merge into a coin toss: the same row written twice either
|
|
1094
|
+
* silently wins or silently loses depending on a number that means nothing.
|
|
1095
|
+
*
|
|
1096
|
+
* Some reads this SDK exposes are not delta lists and never will be.
|
|
1097
|
+
* `GET /manager/me/trips` is the motivating one — its rows carry a
|
|
1098
|
+
* `tripRef`, a name and a status, but no `id` and no `version`, because it
|
|
1099
|
+
* is a projection of the caller's assignments rather than a table. It has no
|
|
1100
|
+
* `?since=` window, no tombstones, and no per-row identity to merge on. It
|
|
1101
|
+
* is a whole answer or it is nothing.
|
|
1102
|
+
*
|
|
1103
|
+
* Forcing such a response through the snapshot store would mean inventing
|
|
1104
|
+
* the identity that makes the snapshot store correct. So it gets its own
|
|
1105
|
+
* lane instead, with a deliberately smaller promise.
|
|
1106
|
+
*
|
|
1107
|
+
* ── THE PROMISE, AND ITS LIMITS ───────────────────────────────────────────
|
|
1108
|
+
*
|
|
1109
|
+
* Exactly one thing: **the last response that actually landed, and when the
|
|
1110
|
+
* SERVER said that was.** Whole-value replace, last writer wins, no merge,
|
|
1111
|
+
* no cursor, no tombstones, no events.
|
|
1112
|
+
*
|
|
1113
|
+
* That is enough for the case it exists for — a field surface that must
|
|
1114
|
+
* paint what it last knew rather than blank when the read cannot be made —
|
|
1115
|
+
* and it is deliberately not enough to build a sync lane on. Anything with a
|
|
1116
|
+
* per-row identity and a delta window belongs in the snapshot store, and
|
|
1117
|
+
* putting it here instead would lose rows the moment two writers overlap.
|
|
1118
|
+
*
|
|
1119
|
+
* `syncedAt` is the response's own `meta.serverTime` and there is no setter
|
|
1120
|
+
* that takes anything else, for the same reason `applyPull` has none: a
|
|
1121
|
+
* device clock would make "as of 14:02" a lie on exactly the devices whose
|
|
1122
|
+
* clocks are worst.
|
|
1123
|
+
*
|
|
1124
|
+
* Keys are opaque to this module and chosen by the caller. They are
|
|
1125
|
+
* namespaced under the engine's credential scope by `keyPrefix`, so one
|
|
1126
|
+
* manager's cached answer can never be read under another's session.
|
|
1127
|
+
*/
|
|
1128
|
+
|
|
1129
|
+
/** One cached response, as it sits on disk. */
|
|
1130
|
+
interface CachedRead<T = unknown> {
|
|
1131
|
+
readonly value: T;
|
|
1132
|
+
/** The `meta.serverTime` of the response this came from — never a device
|
|
1133
|
+
* clock. */
|
|
1134
|
+
readonly syncedAt: string;
|
|
1135
|
+
}
|
|
1136
|
+
interface ReadCacheStore {
|
|
1137
|
+
/**
|
|
1138
|
+
* The last response that landed for this key, or `undefined` if none ever
|
|
1139
|
+
* has. Resolves from memory once `load()` has run — a first paint must not
|
|
1140
|
+
* wait on a disk read it already did.
|
|
1141
|
+
*
|
|
1142
|
+
* The value is returned as it was stored. This module does not know the
|
|
1143
|
+
* shape and does not validate it: a caller that changes what it puts under
|
|
1144
|
+
* a key is responsible for tolerating the old shape, exactly as it would
|
|
1145
|
+
* be for anything else that outlives a deploy.
|
|
1146
|
+
*/
|
|
1147
|
+
get<T>(key: string): CachedRead<T> | undefined;
|
|
1148
|
+
/**
|
|
1149
|
+
* Replaces the value under `key` wholesale.
|
|
1150
|
+
*
|
|
1151
|
+
* `serverTime` MUST be the `meta.serverTime` of the response `value` came
|
|
1152
|
+
* in. There is no overload that omits it, because a cached read whose age
|
|
1153
|
+
* is unknown is worse than no cached read: a surface will render it with
|
|
1154
|
+
* confidence.
|
|
1155
|
+
*/
|
|
1156
|
+
set(key: string, value: unknown, serverTime: string): Promise<void>;
|
|
1157
|
+
/** Drops one key. Nothing in this SDK calls it; it exists so a host that
|
|
1158
|
+
* caches something sensitive can stop. */
|
|
1159
|
+
purge(key: string): Promise<void>;
|
|
1160
|
+
/** Hydrates from the durable adapter. Call once, before first paint. */
|
|
1161
|
+
load(): Promise<void>;
|
|
1162
|
+
}
|
|
1163
|
+
interface CreateReadCacheStoreOptions {
|
|
1164
|
+
readonly storage: KaafilStorageAdapter;
|
|
1165
|
+
/** Namespacing key prefix, already credential-scoped by the engine. */
|
|
1166
|
+
readonly keyPrefix: string;
|
|
1167
|
+
}
|
|
1168
|
+
declare function createReadCacheStore(options: CreateReadCacheStoreOptions): ReadCacheStore;
|
|
1169
|
+
|
|
1110
1170
|
/**
|
|
1111
1171
|
* Share-token offline: local expiry enforcement, reconnect re-validation, the
|
|
1112
1172
|
* minimal write set, and the 7-day post-expiry grace.
|
|
@@ -1264,6 +1324,12 @@ interface EnqueueWithBlobOptions extends EnqueueWriteOptions {
|
|
|
1264
1324
|
interface OfflineEngine {
|
|
1265
1325
|
readonly events: OfflineEvents;
|
|
1266
1326
|
readonly snapshot: SnapshotStore;
|
|
1327
|
+
/**
|
|
1328
|
+
* Last-known-good whole responses for reads that are NOT delta lists —
|
|
1329
|
+
* see `./reads.ts` for why those cannot live in `snapshot`. Durable and
|
|
1330
|
+
* credential-scoped like every other store here.
|
|
1331
|
+
*/
|
|
1332
|
+
readonly reads: ReadCacheStore;
|
|
1267
1333
|
readonly outbox: Outbox;
|
|
1268
1334
|
readonly drainer: Drainer;
|
|
1269
1335
|
readonly pull: PullCoordinator;
|
|
@@ -2720,4 +2786,4 @@ declare class KaafilClient {
|
|
|
2720
2786
|
static newIdempotencyKey(): string;
|
|
2721
2787
|
}
|
|
2722
2788
|
|
|
2723
|
-
export { AgenciesResource, AgencyAdminMeResource, AgencyAdminRefreshResult, type ApplyPullResult, BATCH_THRESHOLD_OPS, type BlobBackfill, type BlobBytes, type BlobDrainReport, type BlobLane, type BlobRecord, type BlobSource, BlobStatus, type BlobUploader, BookingsResource, type BoundAgenciesResource, type BoundChecklistsResource, type BoundCreateAgencyChecklistTemplateOptions, type BoundCreateFormOptions, type BoundCreateTravellerOptions, type BoundCreateVendorOptions, type BoundDeleteAgencyChecklistTemplateOptions, type BoundDeleteVendorOptions, type BoundFeedbackNpsResource, type BoundFormsResource, type BoundGetAgencyManagerProfileOptions, type BoundGetAgencyTripOptions, type BoundGetTravellerAgencyProfileOptions, type BoundJourneyResource, type BoundListAgencyChecklistTemplatesOptions, type BoundListAgencyManagersOptions, type BoundListAgencyManagersPageOptions, type BoundListAgencyTripsOptions, type BoundListAgencyTripsPageOptions, type BoundListForAgencyOptions, type BoundListForAgencyPageOptions, type BoundListFormsOptions, type BoundListJourneyTriggersOptions, type BoundListTripManifestOptions, type BoundListTripManifestPageOptions, type BoundPatchAgencyChecklistTemplateOptions, type BoundPatchAgencySettingsOptions, type BoundPatchJourneyTriggerOptions, type BoundPublishAgencyChecklistTemplateOptions, type BoundReadAgencyFeedbackSummaryOptions, type BoundReadAgencySettingsOptions, type BoundTravellersResource, type BoundUpsertVendorOptions, type BoundVendorsResource, CONSOLIDATED_PULL_THRESHOLD_LISTS, ChecklistsResource, CloseoutResource, CollectionsResource, type CompressImageOptions, type CompressedImage, CompressionOutcome, type ConflictContext, type ConflictResolution, type ConflictResolver, CreateAgencyChecklistTemplateOptions, type CreateDrainerOptions, CreateFormOptions, type CreateOfflineEngineOptions, type CreateOutboxOptions, CreateTravellerOptions, CreateVendorOptions, DeleteAgencyChecklistTemplateOptions, DeleteVendorOptions, DeltaIdentity, DeltaMergeStats, DeltaRow, type DrainOptions, type DrainReport, type Drainer, type EnqueueOptions, type EnqueueWithBlobOptions, type EnqueueWriteOptions, type EntityReadResult, type EntityReader, Environment, ExpensesResource, FeedbackNpsResource, FilesResource, FloatResource, FormsResource, GetAgencyManagerProfileOptions, GetAgencyTripOptions, GetTravellerAgencyProfileOptions, type IndexedDbStorageAdapterOptions, ItineraryResource, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilResponse, KaafilShareLinkExpiredError, type KaafilStorageAdapter, ListAgencyChecklistTemplatesOptions, ListAgencyManagersOptions, ListAgencyManagersPageOptions, ListAgencyTripsOptions, ListAgencyTripsPageOptions, ListForAgencyOptions, ListForAgencyPageOptions, ListFormsOptions, type ListManagerExpensesOptions, type ListManagerNotificationsOptions, type ListOwnManagerTripsOptions, type ListShareFormsOptions, ListTripManifestOptions, ListTripManifestPageOptions, type LosslessImageOptions, MAX_BATCH_OPS, type ManagerExpenseFilters, type ManagerExpensesResource, type ManagerMeResource, type ManagerOwnTrip, type ManagerOwnTripsResponse, ManagerRefreshResult, ManagerTodayResource, type MarkNotificationReadOptions, type MonotonicClock, type NotificationsResource, type OfflineEngine, type OfflineEventHandler, type OfflineEventMap, type OfflineEventName, type OfflineEvents, type OfflineTransport, type OpOutcome, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenOfflineOptions, type OpenShareTokenOptions, type Outbox, type OutboxCounts, type OutboxEntityRef, type OutboxOp, type OutboxParkReason, OutboxRetryCause, OutboxStatus, PatchAgencyChecklistTemplateOptions, PatchAgencySettingsOptions, PickupsResource, PublishAgencyChecklistTemplateOptions, type PullCoordinator, type PullResult, type PullSection, type PullTripResult, ReadAgencyFeedbackSummaryOptions, ReadAgencySettingsOptions, type ReadManagerExpenseLogMetaOptions, type ReadManagerExpenseOptions, type ReadShareFormOptions, type ReadShareManifestOptions, type ReadShareSnapshotOptions, type ReconcileOutcome, Resolvable, RoomingResource, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, type SaveShareFormOptions, SeatingResource, type ShareFormsResource, type ShareGuard, type ShareInvalidatedEvent, type ShareResource, ShareTokensResource, type SnapshotList, type SnapshotRow, type SnapshotStore, type SnapshotUpdatedEvent, type SubmitShareFormOptions, type SyncDrainedEvent, type SyncErrorEvent, SyncOpMethod, type SyncPullSection, SyncResource, TravellersResource, TreksResource, TripsResource, type Unsubscribe, UpsertVendorOptions, VendorsResource, compressImage, convertImageLossless, createBlobLane, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createShareGuard, createSnapshotStore, extractSectionRows, isCompressibleType, isImageCompressionSupported, readCurrentVersion, reconcileConflict, scaledDimensions, shouldUseBatchTransport };
|
|
2789
|
+
export { AgenciesResource, AgencyAdminMeResource, AgencyAdminRefreshResult, type ApplyPullResult, BATCH_THRESHOLD_OPS, type BlobBackfill, type BlobBytes, type BlobDrainReport, type BlobLane, type BlobRecord, type BlobSource, BlobStatus, type BlobUploader, BookingsResource, type BoundAgenciesResource, type BoundChecklistsResource, type BoundCreateAgencyChecklistTemplateOptions, type BoundCreateFormOptions, type BoundCreateTravellerOptions, type BoundCreateVendorOptions, type BoundDeleteAgencyChecklistTemplateOptions, type BoundDeleteVendorOptions, type BoundFeedbackNpsResource, type BoundFormsResource, type BoundGetAgencyManagerProfileOptions, type BoundGetAgencyTripOptions, type BoundGetTravellerAgencyProfileOptions, type BoundJourneyResource, type BoundListAgencyChecklistTemplatesOptions, type BoundListAgencyManagersOptions, type BoundListAgencyManagersPageOptions, type BoundListAgencyTripsOptions, type BoundListAgencyTripsPageOptions, type BoundListForAgencyOptions, type BoundListForAgencyPageOptions, type BoundListFormsOptions, type BoundListJourneyTriggersOptions, type BoundListTripManifestOptions, type BoundListTripManifestPageOptions, type BoundPatchAgencyChecklistTemplateOptions, type BoundPatchAgencySettingsOptions, type BoundPatchJourneyTriggerOptions, type BoundPublishAgencyChecklistTemplateOptions, type BoundReadAgencyFeedbackSummaryOptions, type BoundReadAgencySettingsOptions, type BoundTravellersResource, type BoundUpsertVendorOptions, type BoundVendorsResource, CONSOLIDATED_PULL_THRESHOLD_LISTS, type CachedRead, ChecklistsResource, CloseoutResource, CollectionsResource, type CompressImageOptions, type CompressedImage, CompressionOutcome, type ConflictContext, type ConflictResolution, type ConflictResolver, CreateAgencyChecklistTemplateOptions, type CreateDrainerOptions, CreateFormOptions, type CreateOfflineEngineOptions, type CreateOutboxOptions, type CreateReadCacheStoreOptions, CreateTravellerOptions, CreateVendorOptions, DeleteAgencyChecklistTemplateOptions, DeleteVendorOptions, DeltaIdentity, DeltaMergeStats, DeltaRow, type DrainOptions, type DrainReport, type Drainer, type EnqueueOptions, type EnqueueWithBlobOptions, type EnqueueWriteOptions, type EntityReadResult, type EntityReader, Environment, ExpensesResource, FeedbackNpsResource, FilesResource, FloatResource, FormsResource, GetAgencyManagerProfileOptions, GetAgencyTripOptions, GetTravellerAgencyProfileOptions, type IndexedDbStorageAdapterOptions, ItineraryResource, JourneyResource, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, type KaafilClientOptions, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilResponse, KaafilShareLinkExpiredError, type KaafilStorageAdapter, ListAgencyChecklistTemplatesOptions, ListAgencyManagersOptions, ListAgencyManagersPageOptions, ListAgencyTripsOptions, ListAgencyTripsPageOptions, ListForAgencyOptions, ListForAgencyPageOptions, ListFormsOptions, type ListManagerExpensesOptions, type ListManagerNotificationsOptions, type ListOwnManagerTripsOptions, type ListShareFormsOptions, ListTripManifestOptions, ListTripManifestPageOptions, type LosslessImageOptions, MAX_BATCH_OPS, type ManagerExpenseFilters, type ManagerExpensesResource, type ManagerMeResource, type ManagerOwnTrip, type ManagerOwnTripsResponse, ManagerRefreshResult, ManagerTodayResource, type MarkNotificationReadOptions, type MonotonicClock, type NotificationsResource, type OfflineEngine, type OfflineEventHandler, type OfflineEventMap, type OfflineEventName, type OfflineEvents, type OfflineTransport, type OpOutcome, type OpenAgencyAdminSessionOptions, type OpenManagerSessionOptions, type OpenOfflineOptions, type OpenShareTokenOptions, type Outbox, type OutboxCounts, type OutboxEntityRef, type OutboxOp, type OutboxParkReason, OutboxRetryCause, OutboxStatus, PatchAgencyChecklistTemplateOptions, PatchAgencySettingsOptions, PickupsResource, PublishAgencyChecklistTemplateOptions, type PullCoordinator, type PullResult, type PullSection, type PullTripResult, ReadAgencyFeedbackSummaryOptions, ReadAgencySettingsOptions, type ReadCacheStore, type ReadManagerExpenseLogMetaOptions, type ReadManagerExpenseOptions, type ReadShareFormOptions, type ReadShareManifestOptions, type ReadShareSnapshotOptions, type ReconcileOutcome, Resolvable, RoomingResource, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, type SaveShareFormOptions, SeatingResource, type ShareFormsResource, type ShareGuard, type ShareInvalidatedEvent, type ShareResource, ShareTokensResource, type SnapshotList, type SnapshotRow, type SnapshotStore, type SnapshotUpdatedEvent, type SubmitShareFormOptions, type SyncDrainedEvent, type SyncErrorEvent, SyncOpMethod, type SyncPullSection, SyncResource, TravellersResource, TreksResource, TripsResource, type Unsubscribe, UpsertVendorOptions, VendorsResource, compressImage, convertImageLossless, createBlobLane, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createReadCacheStore, createShareGuard, createSnapshotStore, extractSectionRows, isCompressibleType, isImageCompressionSupported, readCurrentVersion, reconcileConflict, scaledDimensions, shouldUseBatchTransport };
|
package/dist/client-entry.js
CHANGED
|
@@ -2962,7 +2962,35 @@ var SYNC_PULL_SECTIONS = [
|
|
|
2962
2962
|
"itinerary",
|
|
2963
2963
|
"closeout"
|
|
2964
2964
|
];
|
|
2965
|
-
|
|
2965
|
+
var SECTION_ROW_KEY = {
|
|
2966
|
+
// Delta-shaped `rooms[]`; `windows[]`/`unassigned[]` are derived
|
|
2967
|
+
// projections — the long note above is still exactly right about this one.
|
|
2968
|
+
rooming: "rooms",
|
|
2969
|
+
// The same decision in the same shape: `vehicles[]` is the feed,
|
|
2970
|
+
// `unassignedPool[]` the projection that must never be cached as rows.
|
|
2971
|
+
seating: "vehicles",
|
|
2972
|
+
expenses: "items",
|
|
2973
|
+
float: "data",
|
|
2974
|
+
// The one that was silently dead. `sections[]` is a grouping projection and
|
|
2975
|
+
// `availableTemplates[]` is agency-level catalogue; `items[]` is the trip's
|
|
2976
|
+
// own entity list and the only one of the three carrying tombstones.
|
|
2977
|
+
checklist: "items",
|
|
2978
|
+
// `days[]` is the day-by-day projection the engine recomputes per read;
|
|
2979
|
+
// `items[]` is the entity list.
|
|
2980
|
+
itinerary: "items",
|
|
2981
|
+
closeout: null
|
|
2982
|
+
// `stayWindows`, `pickups`, `bookings` and `collections` send a top-level
|
|
2983
|
+
// array and never reach this table.
|
|
2984
|
+
};
|
|
2985
|
+
function extractSectionRows(data, section) {
|
|
2986
|
+
if (section !== void 0 && section in SECTION_ROW_KEY) {
|
|
2987
|
+
const key = SECTION_ROW_KEY[section];
|
|
2988
|
+
if (key === null || key === void 0 || typeof data !== "object" || data === null) {
|
|
2989
|
+
return void 0;
|
|
2990
|
+
}
|
|
2991
|
+
const value = data[key];
|
|
2992
|
+
return Array.isArray(value) && isRowArray(value) ? value : void 0;
|
|
2993
|
+
}
|
|
2966
2994
|
if (Array.isArray(data)) {
|
|
2967
2995
|
return isRowArray(data) ? data : void 0;
|
|
2968
2996
|
}
|
|
@@ -3032,7 +3060,7 @@ function createPullCoordinator(options) {
|
|
|
3032
3060
|
absent.push(name);
|
|
3033
3061
|
continue;
|
|
3034
3062
|
}
|
|
3035
|
-
const rows = extractSectionRows(section.data);
|
|
3063
|
+
const rows = extractSectionRows(section.data, name);
|
|
3036
3064
|
if (rows === void 0) {
|
|
3037
3065
|
unmapped.push(name);
|
|
3038
3066
|
continue;
|
|
@@ -3069,6 +3097,49 @@ function createPullCoordinator(options) {
|
|
|
3069
3097
|
};
|
|
3070
3098
|
}
|
|
3071
3099
|
|
|
3100
|
+
// src/offline/reads.ts
|
|
3101
|
+
function createReadCacheStore(options) {
|
|
3102
|
+
const key = `${options.keyPrefix}:reads`;
|
|
3103
|
+
let reads = /* @__PURE__ */ new Map();
|
|
3104
|
+
async function persist() {
|
|
3105
|
+
const shape = { reads: Object.fromEntries(reads) };
|
|
3106
|
+
await options.storage.set(key, JSON.stringify(shape));
|
|
3107
|
+
}
|
|
3108
|
+
return {
|
|
3109
|
+
get(readKey) {
|
|
3110
|
+
return reads.get(readKey);
|
|
3111
|
+
},
|
|
3112
|
+
async set(readKey, value, serverTime) {
|
|
3113
|
+
reads.set(readKey, { value, syncedAt: serverTime });
|
|
3114
|
+
await persist();
|
|
3115
|
+
},
|
|
3116
|
+
async purge(readKey) {
|
|
3117
|
+
if (!reads.delete(readKey)) {
|
|
3118
|
+
return;
|
|
3119
|
+
}
|
|
3120
|
+
await persist();
|
|
3121
|
+
},
|
|
3122
|
+
async load() {
|
|
3123
|
+
reads = /* @__PURE__ */ new Map();
|
|
3124
|
+
const raw = await options.storage.get(key);
|
|
3125
|
+
if (raw === void 0) {
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
let parsed;
|
|
3129
|
+
try {
|
|
3130
|
+
parsed = JSON.parse(raw);
|
|
3131
|
+
} catch {
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
for (const [readKey, entry] of Object.entries(parsed.reads ?? {})) {
|
|
3135
|
+
if (entry !== null && typeof entry === "object" && typeof entry.syncedAt === "string") {
|
|
3136
|
+
reads.set(readKey, entry);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3072
3143
|
// src/offline/share.ts
|
|
3073
3144
|
var SHARE_WRITE_GRACE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
3074
3145
|
var KaafilShareLinkExpiredError = class _KaafilShareLinkExpiredError extends Error {
|
|
@@ -3443,6 +3514,7 @@ function createOfflineEngine(options) {
|
|
|
3443
3514
|
...options.onEventHandlerError !== void 0 ? { onHandlerError: (error) => options.onEventHandlerError?.(error) } : {}
|
|
3444
3515
|
});
|
|
3445
3516
|
const snapshot = createSnapshotStore({ storage: options.storage, keyPrefix });
|
|
3517
|
+
const reads = createReadCacheStore({ storage: options.storage, keyPrefix });
|
|
3446
3518
|
const outbox = createOutbox({
|
|
3447
3519
|
storage: options.storage,
|
|
3448
3520
|
keyPrefix,
|
|
@@ -3515,13 +3587,19 @@ function createOfflineEngine(options) {
|
|
|
3515
3587
|
return {
|
|
3516
3588
|
events,
|
|
3517
3589
|
snapshot,
|
|
3590
|
+
reads,
|
|
3518
3591
|
outbox,
|
|
3519
3592
|
drainer,
|
|
3520
3593
|
pull,
|
|
3521
3594
|
blobs,
|
|
3522
3595
|
share,
|
|
3523
3596
|
async open() {
|
|
3524
|
-
await Promise.all([
|
|
3597
|
+
await Promise.all([
|
|
3598
|
+
snapshot.load(),
|
|
3599
|
+
reads.load(),
|
|
3600
|
+
outbox.load(),
|
|
3601
|
+
blobs?.load() ?? Promise.resolve()
|
|
3602
|
+
]);
|
|
3525
3603
|
unbind = drainer.bindOpportunisticTriggers();
|
|
3526
3604
|
drainer.kick();
|
|
3527
3605
|
},
|
|
@@ -7411,6 +7489,6 @@ var KaafilClient = class {
|
|
|
7411
7489
|
}
|
|
7412
7490
|
};
|
|
7413
7491
|
|
|
7414
|
-
export { ACTIVE_TREK_REF, BATCH_THRESHOLD_OPS, BlobStatus, BoardStatus, BookingStatus, CONSOLIDATED_PULL_THRESHOLD_LISTS, ChecklistAudience, ChecklistGate, ChecklistItemStatus, ChecklistPhase, ChecklistPullTemplateMode, ClaimStatusIngest, CloseoutPackSection, CollectionMode, CompressionOutcome, Currency, ERROR_CODE_TABLE, EventType, ExpenseCategory, ExpensePaymentMode, FALLBACK_GLYPH, FileContentType, FilePurpose, FloatDirection, Gender, HEURISTIC_SEVERITY, ItineraryItemStatusUpdate, ItineraryItemType, KaafilAbortError, KaafilApiError, KaafilCapabilityUnavailableError, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, KaafilDeltaCursorInFlightError, KaafilEntitlementError, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilInvalidRequestError, KaafilLockedError, KaafilNetworkError, KaafilNotFoundError, KaafilNotImplementedError, KaafilPaginationError, KaafilPaginationExhaustedError, KaafilPaginationInFlightError, KaafilRateLimitedError, KaafilReadOnlyRoleError, KaafilShareBatchUnauthenticatedError, KaafilShareLinkExpiredError, KaafilShareTokenExpiredError, KaafilShareTokenRevokedError, KaafilTimeoutError, KaafilTransportError, KaafilUnauthenticatedError, KaafilValidationError, KaafilVersionConflictError, MAX_BATCH_OPS, ManagerRole, ManifestMode, OutboxClass, OutboxRetryCause, OutboxStatus, PartyKind, PickupKind, Retryability, RoomType, RoomingFillOrder, RoomingGenderPolicy, RoomingHeuristicKey, SHADES_PER_FAMILY, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, SeatingFillOrder, SeatingGenderAdjacency, SeatingHeuristicKey, SyncOpMethod, TONE_FAMILIES, TriggerAnchor, TripMode, TripStatus, UNKNOWN_TONE_FAMILY, UnsatisfiableSchemeError, VehicleLayout, VehicleType, compressImage, convertImageLossless, createBlobLane, createDeltaCursor, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createShareGuard, createSnapshotStore, createSyncResource, extractSectionRows, isCompressibleType, isImageCompressionSupported, isKaafilError, isRetryable, isRoomingHeuristicKey, isShareBatchPushAvailable, isTombstone, mergeDeltaRows, parseRoomingTone, readCurrentVersion, reconcileConflict, roomingHeuristicSeverity, scaledDimensions, shouldUseBatchTransport };
|
|
7492
|
+
export { ACTIVE_TREK_REF, BATCH_THRESHOLD_OPS, BlobStatus, BoardStatus, BookingStatus, CONSOLIDATED_PULL_THRESHOLD_LISTS, ChecklistAudience, ChecklistGate, ChecklistItemStatus, ChecklistPhase, ChecklistPullTemplateMode, ClaimStatusIngest, CloseoutPackSection, CollectionMode, CompressionOutcome, Currency, ERROR_CODE_TABLE, EventType, ExpenseCategory, ExpensePaymentMode, FALLBACK_GLYPH, FileContentType, FilePurpose, FloatDirection, Gender, HEURISTIC_SEVERITY, ItineraryItemStatusUpdate, ItineraryItemType, KaafilAbortError, KaafilApiError, KaafilCapabilityUnavailableError, KaafilClient, KaafilClientAlreadyOpenError, KaafilClientNotOpenError, KaafilDeltaCursorInFlightError, KaafilEntitlementError, KaafilError, KaafilErrorCode, KaafilIndexedDbUnavailableError, KaafilInvalidRequestError, KaafilLockedError, KaafilNetworkError, KaafilNotFoundError, KaafilNotImplementedError, KaafilPaginationError, KaafilPaginationExhaustedError, KaafilPaginationInFlightError, KaafilRateLimitedError, KaafilReadOnlyRoleError, KaafilShareBatchUnauthenticatedError, KaafilShareLinkExpiredError, KaafilShareTokenExpiredError, KaafilShareTokenRevokedError, KaafilTimeoutError, KaafilTransportError, KaafilUnauthenticatedError, KaafilValidationError, KaafilVersionConflictError, MAX_BATCH_OPS, ManagerRole, ManifestMode, OutboxClass, OutboxRetryCause, OutboxStatus, PartyKind, PickupKind, Retryability, RoomType, RoomingFillOrder, RoomingGenderPolicy, RoomingHeuristicKey, SHADES_PER_FAMILY, SHARE_WRITE_GRACE_MS, SYNC_PULL_SECTIONS, SeatingFillOrder, SeatingGenderAdjacency, SeatingHeuristicKey, SyncOpMethod, TONE_FAMILIES, TriggerAnchor, TripMode, TripStatus, UNKNOWN_TONE_FAMILY, UnsatisfiableSchemeError, VehicleLayout, VehicleType, compressImage, convertImageLossless, createBlobLane, createDeltaCursor, createDrainer, createHttpOfflineTransport, createInMemoryStorageAdapter, createIndexedDbStorageAdapter, createOfflineEngine, createOfflineEvents, createOutbox, createPullCoordinator, createReadCacheStore, createShareGuard, createSnapshotStore, createSyncResource, extractSectionRows, isCompressibleType, isImageCompressionSupported, isKaafilError, isRetryable, isRoomingHeuristicKey, isShareBatchPushAvailable, isTombstone, mergeDeltaRows, parseRoomingTone, readCurrentVersion, reconcileConflict, roomingHeuristicSeverity, scaledDimensions, shouldUseBatchTransport };
|
|
7415
7493
|
//# sourceMappingURL=client-entry.js.map
|
|
7416
7494
|
//# sourceMappingURL=client-entry.js.map
|