tempest-react-sdk 0.19.1 → 0.21.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/README.md +5 -5
- package/dist/tempest-react-sdk.cjs +3 -3
- package/dist/tempest-react-sdk.cjs.map +1 -1
- package/dist/tempest-react-sdk.d.ts +209 -0
- package/dist/tempest-react-sdk.js +951 -852
- package/dist/tempest-react-sdk.js.map +1 -1
- package/dist/vision.cjs +1 -1
- package/dist/vision.cjs.map +1 -1
- package/dist/vision.d.ts +142 -0
- package/dist/vision.js +499 -354
- package/dist/vision.js.map +1 -1
- package/package.json +1 -1
|
@@ -1531,6 +1531,44 @@ export declare interface CreateLoggerOptions {
|
|
|
1531
1531
|
*/
|
|
1532
1532
|
export declare function createOfflineStore<TItem, TKey extends string | number = string>(config: OfflineStoreConfig<TItem>): OfflineStore<TItem, TKey>;
|
|
1533
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Create an offline-first sync engine over an IndexedDB outbox.
|
|
1536
|
+
*
|
|
1537
|
+
* The engine drains queued mutations to the server (`deliver`) and pulls the
|
|
1538
|
+
* server delta back (`pullPage` + `applyRemote`), advancing a watermark so each
|
|
1539
|
+
* run only fetches what changed. `flush` is single-flight and skips cleanly
|
|
1540
|
+
* while offline; failed deliveries stay queued with their attempt count bumped.
|
|
1541
|
+
*
|
|
1542
|
+
* Dexie is an **optional peer dependency** (via {@link createOfflineStore}) —
|
|
1543
|
+
* install it (`npm i dexie`) when you use this engine.
|
|
1544
|
+
*
|
|
1545
|
+
* @typeParam TPayload - Record snapshot carried by outbox entries.
|
|
1546
|
+
* @typeParam TRemote - Server item shape returned by `pullPage`.
|
|
1547
|
+
* @param config - Transport callbacks + outbox/watermark configuration.
|
|
1548
|
+
* @returns The sync handle (`enqueue`, `flush`, `pendingCount`, …).
|
|
1549
|
+
*
|
|
1550
|
+
* @example
|
|
1551
|
+
* const sync = createOfflineSync<Note, NoteDto>({
|
|
1552
|
+
* databaseName: "NotesOutbox",
|
|
1553
|
+
* watermark: { storageKey: "notes.watermark" },
|
|
1554
|
+
* deliver: async (entry) => {
|
|
1555
|
+
* if (entry.op === "delete") return api.remove(entry.recordId);
|
|
1556
|
+
* await api.upsert(entry.recordId, entry.payload!);
|
|
1557
|
+
* },
|
|
1558
|
+
* pullPage: async (since, cursor) => {
|
|
1559
|
+
* const page = await api.changes(since, cursor);
|
|
1560
|
+
* return { items: page.items, nextCursor: page.next, serverTime: page.now };
|
|
1561
|
+
* },
|
|
1562
|
+
* applyRemote: async (dto) => {
|
|
1563
|
+
* if (dto.deleted) return localStore.remove(dto.id);
|
|
1564
|
+
* await localStore.save(fromDto(dto));
|
|
1565
|
+
* },
|
|
1566
|
+
* });
|
|
1567
|
+
* await sync.enqueue("create", note.id, note);
|
|
1568
|
+
* await sync.flush("after-mutation");
|
|
1569
|
+
*/
|
|
1570
|
+
export declare function createOfflineSync<TPayload = unknown, TRemote = unknown>(config: OfflineSyncConfig<TPayload, TRemote>): OfflineSync<TPayload>;
|
|
1571
|
+
|
|
1534
1572
|
/**
|
|
1535
1573
|
* Build a {@link RoutingBackend} backed by an OSRM server **you host**. OSRM
|
|
1536
1574
|
* only serves a driving profile, so motorcycle/bus durations are derived by
|
|
@@ -4226,6 +4264,85 @@ export declare interface OfflineStoreConfig<TItem> {
|
|
|
4226
4264
|
ownerField?: keyof TItem & string;
|
|
4227
4265
|
}
|
|
4228
4266
|
|
|
4267
|
+
/**
|
|
4268
|
+
* Offline-first sync engine: a durable outbox plus a paginated delta pull.
|
|
4269
|
+
*
|
|
4270
|
+
* @typeParam TPayload - Record snapshot carried by outbox entries.
|
|
4271
|
+
*/
|
|
4272
|
+
export declare interface OfflineSync<TPayload> {
|
|
4273
|
+
/**
|
|
4274
|
+
* Queue a mutation. Returns the generated entry id.
|
|
4275
|
+
*
|
|
4276
|
+
* @param op - The mutation kind.
|
|
4277
|
+
* @param recordId - Primary key of the affected record.
|
|
4278
|
+
* @param payload - Record snapshot (for `create`/`update`).
|
|
4279
|
+
*/
|
|
4280
|
+
enqueue: (op: OutboxOp, recordId: string, payload?: TPayload) => Promise<string>;
|
|
4281
|
+
/**
|
|
4282
|
+
* Run a full sync (drain the outbox, then pull the delta). Concurrent
|
|
4283
|
+
* calls share one in-flight promise, so triggers never overlap.
|
|
4284
|
+
*
|
|
4285
|
+
* @param trigger - Label for why the run happened. Default `"manual"`.
|
|
4286
|
+
*/
|
|
4287
|
+
flush: (trigger?: SyncTrigger) => Promise<SyncRunSummary>;
|
|
4288
|
+
/** Number of mutations still queued. */
|
|
4289
|
+
pendingCount: () => Promise<number>;
|
|
4290
|
+
/** The queued mutations in FIFO order. */
|
|
4291
|
+
listPending: () => Promise<OutboxEntry<TPayload>[]>;
|
|
4292
|
+
/** Drop every queued mutation (e.g. on logout). */
|
|
4293
|
+
clearOutbox: () => Promise<void>;
|
|
4294
|
+
/** Reset the pull watermark (e.g. on logout / account switch). */
|
|
4295
|
+
resetWatermark: () => void;
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4298
|
+
/**
|
|
4299
|
+
* Configuration for {@link createOfflineSync}.
|
|
4300
|
+
*
|
|
4301
|
+
* The engine owns the outbox, the single-flight flush, the offline guard, the
|
|
4302
|
+
* paginated pull loop and the watermark; the three transport callbacks
|
|
4303
|
+
* (`deliver`, `pullPage`, `applyRemote`) are where the app plugs in its own
|
|
4304
|
+
* endpoints, record shape and conflict resolution.
|
|
4305
|
+
*
|
|
4306
|
+
* @typeParam TPayload - Record snapshot carried by outbox entries.
|
|
4307
|
+
* @typeParam TRemote - Server item shape returned by `pullPage`.
|
|
4308
|
+
*/
|
|
4309
|
+
export declare interface OfflineSyncConfig<TPayload, TRemote> {
|
|
4310
|
+
/** IndexedDB database name for the outbox (kept separate per queue). */
|
|
4311
|
+
databaseName: string;
|
|
4312
|
+
/** Outbox object-store name. Default `"outbox"`. */
|
|
4313
|
+
tableName?: string;
|
|
4314
|
+
/** Outbox schema version. Default `1`. */
|
|
4315
|
+
version?: number;
|
|
4316
|
+
/** Prefix for generated entry ids. Default `"outbox"`. */
|
|
4317
|
+
idPrefix?: string;
|
|
4318
|
+
/**
|
|
4319
|
+
* Deliver one queued mutation to the server. Throwing keeps the entry
|
|
4320
|
+
* queued (its `attempts`/`lastError` are bumped) for the next run.
|
|
4321
|
+
*/
|
|
4322
|
+
deliver: (entry: OutboxEntry<TPayload>) => Promise<void>;
|
|
4323
|
+
/** Fetch one page of the server delta since `since`, from `cursor`. */
|
|
4324
|
+
pullPage: (since: string | null, cursor: string | null) => Promise<PullPage<TRemote>>;
|
|
4325
|
+
/**
|
|
4326
|
+
* Merge one pulled item into the local store. The app owns conflict
|
|
4327
|
+
* resolution here (e.g. last-write-wins, keeping newer local pending
|
|
4328
|
+
* edits, resolving tombstones and downloading blobs).
|
|
4329
|
+
*/
|
|
4330
|
+
applyRemote: (item: TRemote) => Promise<void>;
|
|
4331
|
+
/** Watermark persistence, or `{ storageKey }` for a `localStorage` default. */
|
|
4332
|
+
watermark: WatermarkStore | {
|
|
4333
|
+
storageKey: string;
|
|
4334
|
+
};
|
|
4335
|
+
/** Called after an entry is delivered and acked. */
|
|
4336
|
+
onEntryDelivered?: (entry: OutboxEntry<TPayload>) => void | Promise<void>;
|
|
4337
|
+
/** Called after an entry fails delivery (it stays queued). */
|
|
4338
|
+
onEntryFailed?: (entry: OutboxEntry<TPayload>, error: unknown) => void | Promise<void>;
|
|
4339
|
+
/**
|
|
4340
|
+
* Connectivity check. Default reads `navigator.onLine` (always online in
|
|
4341
|
+
* non-browser environments). When it returns `false`, `flush` is skipped.
|
|
4342
|
+
*/
|
|
4343
|
+
isOnline?: () => boolean;
|
|
4344
|
+
}
|
|
4345
|
+
|
|
4229
4346
|
/** Offset-paginated response envelope (fastapi-pagination `Page[T]`). */
|
|
4230
4347
|
export declare interface OffsetPage<T> {
|
|
4231
4348
|
/** The rows for the current page. */
|
|
@@ -4314,6 +4431,39 @@ export declare interface OSRMBackendOptions {
|
|
|
4314
4431
|
modeDurationFactors?: Partial<Record<TravelMode, number>>;
|
|
4315
4432
|
}
|
|
4316
4433
|
|
|
4434
|
+
/**
|
|
4435
|
+
* A single queued mutation.
|
|
4436
|
+
*
|
|
4437
|
+
* @typeParam TPayload - The record snapshot shape carried by
|
|
4438
|
+
* `create`/`update` entries (omitted for `delete`).
|
|
4439
|
+
*/
|
|
4440
|
+
export declare interface OutboxEntry<TPayload = unknown> {
|
|
4441
|
+
/** Stable per-entry id (generated with {@link randomId}). */
|
|
4442
|
+
id: string;
|
|
4443
|
+
/** The mutation kind. */
|
|
4444
|
+
op: OutboxOp;
|
|
4445
|
+
/** Primary key of the record the mutation targets. */
|
|
4446
|
+
recordId: string;
|
|
4447
|
+
/** Epoch milliseconds when the mutation was queued. */
|
|
4448
|
+
enqueuedAt: number;
|
|
4449
|
+
/** How many delivery attempts have been made so far. */
|
|
4450
|
+
attempts: number;
|
|
4451
|
+
/** Last delivery error message, kept for UI/debug. */
|
|
4452
|
+
lastError?: string;
|
|
4453
|
+
/** Record snapshot for `create`/`update`. Omitted for `delete`. */
|
|
4454
|
+
payload?: TPayload;
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
/**
|
|
4458
|
+
* Mutation kinds queued in the outbox.
|
|
4459
|
+
*
|
|
4460
|
+
* `create`/`update` carry a snapshot of the record; `delete` needs only the
|
|
4461
|
+
* record id. The distinction between `create` and `update` is advisory — the
|
|
4462
|
+
* engine treats both as "deliver this record" and leaves the create-vs-update
|
|
4463
|
+
* decision to the app's `deliver` callback (a `PUT` upsert usually ignores it).
|
|
4464
|
+
*/
|
|
4465
|
+
export declare type OutboxOp = "create" | "update" | "delete";
|
|
4466
|
+
|
|
4317
4467
|
export { Outlet }
|
|
4318
4468
|
|
|
4319
4469
|
/**
|
|
@@ -4657,6 +4807,23 @@ export declare type ProgressVariant = "primary" | "success" | "warning" | "dange
|
|
|
4657
4807
|
*/
|
|
4658
4808
|
export declare function projectMercator(coord: Coordinate): MercatorPoint;
|
|
4659
4809
|
|
|
4810
|
+
/**
|
|
4811
|
+
* One page of the server delta pull.
|
|
4812
|
+
*
|
|
4813
|
+
* @typeParam TRemote - The server-side item shape.
|
|
4814
|
+
*/
|
|
4815
|
+
export declare interface PullPage<TRemote> {
|
|
4816
|
+
/** Items changed since the watermark, in this page. */
|
|
4817
|
+
items: TRemote[];
|
|
4818
|
+
/** Cursor for the next page, or `null` when this is the last page. */
|
|
4819
|
+
nextCursor: string | null;
|
|
4820
|
+
/**
|
|
4821
|
+
* Server clock to persist as the next watermark once the whole delta is
|
|
4822
|
+
* applied. `null` leaves the watermark unchanged.
|
|
4823
|
+
*/
|
|
4824
|
+
serverTime: string | null;
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4660
4827
|
/**
|
|
4661
4828
|
* Service-worker context helpers for handling `push` and `notificationclick`
|
|
4662
4829
|
* events. Import these inside your own `sw.ts` — they expect to run in the
|
|
@@ -5574,6 +5741,26 @@ export declare interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputE
|
|
|
5574
5741
|
wrapperClassName?: string;
|
|
5575
5742
|
}
|
|
5576
5743
|
|
|
5744
|
+
/** Outcome of a single {@link OfflineSync.flush} run. */
|
|
5745
|
+
export declare interface SyncRunSummary {
|
|
5746
|
+
/** The trigger passed to `flush`. */
|
|
5747
|
+
trigger: SyncTrigger;
|
|
5748
|
+
/** Entries delivered to the server this run. */
|
|
5749
|
+
succeeded: number;
|
|
5750
|
+
/** Entries that failed and stay queued for the next run. */
|
|
5751
|
+
failed: number;
|
|
5752
|
+
/** Total wall-clock milliseconds the run took. */
|
|
5753
|
+
durationMs: number;
|
|
5754
|
+
/** `true` when the run was skipped because the device was offline. */
|
|
5755
|
+
skipped: boolean;
|
|
5756
|
+
}
|
|
5757
|
+
|
|
5758
|
+
/**
|
|
5759
|
+
* Why a sync run was triggered. The listed values are the common ones; any
|
|
5760
|
+
* string is accepted so apps can add their own telemetry labels.
|
|
5761
|
+
*/
|
|
5762
|
+
export declare type SyncTrigger = "boot" | "online-event" | "after-mutation" | "manual" | "interval" | (string & {});
|
|
5763
|
+
|
|
5577
5764
|
export declare interface TabItem {
|
|
5578
5765
|
id: string;
|
|
5579
5766
|
label: ReactNode;
|
|
@@ -6919,6 +7106,15 @@ export declare interface UseOAuthCallbackResult<T> {
|
|
|
6919
7106
|
status: "pending" | "success" | "error";
|
|
6920
7107
|
}
|
|
6921
7108
|
|
|
7109
|
+
/**
|
|
7110
|
+
* Create an object URL for a `Blob` (or `File`) and revoke it automatically on
|
|
7111
|
+
* unmount or whenever the blob changes. Returns `null` for nullish input.
|
|
7112
|
+
*
|
|
7113
|
+
* @param blob - the blob to expose as an object URL, or `null`/`undefined`.
|
|
7114
|
+
* @returns The object URL string, or `null` when there is no blob.
|
|
7115
|
+
*/
|
|
7116
|
+
export declare function useObjectUrl(blob: Blob | null | undefined): string | null;
|
|
7117
|
+
|
|
6922
7118
|
/**
|
|
6923
7119
|
* Query a single record by id through the active {@link useDataProvider}.
|
|
6924
7120
|
*
|
|
@@ -7710,6 +7906,19 @@ export declare interface VisuallyHiddenProps extends HTMLAttributes<HTMLElement>
|
|
|
7710
7906
|
as?: keyof JSX_2.IntrinsicElements;
|
|
7711
7907
|
}
|
|
7712
7908
|
|
|
7909
|
+
/**
|
|
7910
|
+
* Pluggable persistence for the pull watermark (the "changed since" cursor).
|
|
7911
|
+
* Pass an object with a `storageKey` to use a `localStorage`-backed default.
|
|
7912
|
+
*/
|
|
7913
|
+
export declare interface WatermarkStore {
|
|
7914
|
+
/** Read the current watermark, or `null` when none is stored. */
|
|
7915
|
+
get: () => string | null;
|
|
7916
|
+
/** Persist a new watermark. */
|
|
7917
|
+
set: (value: string) => void;
|
|
7918
|
+
/** Drop the watermark (e.g. on logout / account switch). */
|
|
7919
|
+
clear: () => void;
|
|
7920
|
+
}
|
|
7921
|
+
|
|
7713
7922
|
/**
|
|
7714
7923
|
* Browser-side Web Push helper. Wraps `Notification.requestPermission`,
|
|
7715
7924
|
* `pushManager.subscribe`, and the corresponding teardown. Transport is up to
|