kaafil-react-uikit 0.3.0 → 0.3.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.
- package/dist/admin/index.cjs +72 -72
- package/dist/admin/index.js +2 -2
- package/dist/{chunk-MNUCVVIE.cjs → chunk-6TI6YQPE.cjs} +136 -27
- package/dist/chunk-6TI6YQPE.cjs.map +1 -0
- package/dist/{chunk-FVK7HMQ5.cjs → chunk-IU2UM5JP.cjs} +19 -19
- package/dist/{chunk-FVK7HMQ5.cjs.map → chunk-IU2UM5JP.cjs.map} +1 -1
- package/dist/{chunk-WTTGPWMR.js → chunk-JHMN6Q5R.js} +137 -28
- package/dist/chunk-JHMN6Q5R.js.map +1 -0
- package/dist/{chunk-YTSYRLGS.js → chunk-RO2RNHQP.js} +3 -3
- package/dist/{chunk-YTSYRLGS.js.map → chunk-RO2RNHQP.js.map} +1 -1
- package/dist/core/index.cjs +45 -45
- package/dist/core/index.js +3 -3
- package/dist/manager/index.cjs +38 -38
- package/dist/manager/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-MNUCVVIE.cjs.map +0 -1
- package/dist/chunk-WTTGPWMR.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OfflineEngineContext, KaafilClientContext, useCapabilityRows, UNKNOWN_CAPABILITY_TRIPLE, deriveCapabilityTriple, darkReasonFor, useKaafilClient, useOfflineMutation, usePersona, isDevelopment, useOfflineEvent } from './chunk-A4Z2YBEF.js';
|
|
2
|
-
import { UnsatisfiableSchemeError, isKaafilError, SyncOpMethod } from 'kaafil-js/client';
|
|
2
|
+
import { UnsatisfiableSchemeError, isKaafilError, SyncOpMethod, normalizeDateTimeInput } from 'kaafil-js/client';
|
|
3
3
|
export { FALLBACK_GLYPH, SHADES_PER_FAMILY, TONE_FAMILIES, parseRoomingTone, roomingHeuristicSeverity } from 'kaafil-js/client';
|
|
4
4
|
import { useContext, useState, useRef, useCallback, useEffect } from 'react';
|
|
5
5
|
|
|
@@ -176,6 +176,43 @@ function createDomainHook(moduleKey, build) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
// src/core/hooks/useChecklists.ts
|
|
179
|
+
function optimisticChecklistItem(input, sections, fetchedAt) {
|
|
180
|
+
return {
|
|
181
|
+
// Replaced by the id the engine mints — this hook never invents identity.
|
|
182
|
+
id: "pending",
|
|
183
|
+
// Cannot beat any server row in the snapshot's version-guarded merge.
|
|
184
|
+
version: 0,
|
|
185
|
+
// The write addresses a section by KEY; the board groups rows by ID. An
|
|
186
|
+
// unknown section leaves the row ungrouped rather than filing it under a
|
|
187
|
+
// heading that does not exist.
|
|
188
|
+
sectionId: sections.find((section) => section.key === input.sectionKey)?.id ?? "",
|
|
189
|
+
// The server derives the key from the title when one is not sent. Blank
|
|
190
|
+
// rather than a guessed slug: a key that disagrees with the server's is
|
|
191
|
+
// worse than an obviously-absent one, and nothing renders it.
|
|
192
|
+
key: input.key ?? "",
|
|
193
|
+
title: input.title,
|
|
194
|
+
subLine: null,
|
|
195
|
+
status: "OPEN",
|
|
196
|
+
// `=== true`, never `?? false` (hard rule #5): an omitted `mandatory` is
|
|
197
|
+
// the SERVER's default to apply, not this hook's to guess.
|
|
198
|
+
isMandatory: input.mandatory === true,
|
|
199
|
+
// `'NONE'`, never null. The add request carries no `gate` at all — the
|
|
200
|
+
// engine derives it from `phase` — and `'NONE'` is the one value that
|
|
201
|
+
// cannot make a pending item look like it is blocking the trip.
|
|
202
|
+
gate: "NONE",
|
|
203
|
+
dayOffset: null,
|
|
204
|
+
// Appended. The server's own ordering arrives with the canonical row.
|
|
205
|
+
sortOrder: Number.MAX_SAFE_INTEGER,
|
|
206
|
+
completedByManagerId: null,
|
|
207
|
+
performedByKind: null,
|
|
208
|
+
performedById: null,
|
|
209
|
+
completedAt: null,
|
|
210
|
+
// The last reading the SERVER gave this hook, never a device clock (hard
|
|
211
|
+
// rule #6). Blank when nothing has been fetched yet, which is the only
|
|
212
|
+
// honest answer and which the board already prefers `fetchedAt` over.
|
|
213
|
+
updatedAt: fetchedAt ?? ""
|
|
214
|
+
};
|
|
215
|
+
}
|
|
179
216
|
function appendPendingRows(fromAggregate, fromSnapshot) {
|
|
180
217
|
if (fromSnapshot.length === 0) {
|
|
181
218
|
return fromAggregate;
|
|
@@ -283,28 +320,7 @@ var useChecklistsInternal = createDomainHook("checklists", (tripRef) => {
|
|
|
283
320
|
// yet resolves to `''` and the row sits ungrouped until the write
|
|
284
321
|
// lands — correct rather than clever: inventing a section id would
|
|
285
322
|
// put the item under a heading that does not exist.
|
|
286
|
-
optimistic:
|
|
287
|
-
id: "pending",
|
|
288
|
-
version: 0,
|
|
289
|
-
sectionId: aggregate.sections.find((section) => section.key === input.sectionKey)?.id ?? "",
|
|
290
|
-
key: input.key ?? null,
|
|
291
|
-
title: input.title,
|
|
292
|
-
subLine: null,
|
|
293
|
-
status: "OPEN",
|
|
294
|
-
// `=== true`, never `?? false` (hard rule #5): an omitted
|
|
295
|
-
// `mandatory` is the SERVER's default to apply, not this hook's to
|
|
296
|
-
// guess. The optimistic row shows it unstarred for the moment it
|
|
297
|
-
// takes the write to land, and the canonical row replaces it.
|
|
298
|
-
isMandatory: input.mandatory === true,
|
|
299
|
-
gate: null,
|
|
300
|
-
dayOffset: null,
|
|
301
|
-
sortOrder: Number.MAX_SAFE_INTEGER,
|
|
302
|
-
completedByManagerId: null,
|
|
303
|
-
performedByKind: null,
|
|
304
|
-
performedById: null,
|
|
305
|
-
completedAt: null,
|
|
306
|
-
updatedAt: null
|
|
307
|
-
}
|
|
323
|
+
optimistic: optimisticChecklistItem(input, aggregate.sections, aggregate.fetchedAt)
|
|
308
324
|
}),
|
|
309
325
|
// ── THE DESK LANE ─────────────────────────────────────────────────
|
|
310
326
|
// All five checklist writes take the admin triple, and a desk console
|
|
@@ -539,6 +555,34 @@ var useCloseoutInternal = createDomainHook("closing-day", (tripRef) => {
|
|
|
539
555
|
function useCloseout(tripRef) {
|
|
540
556
|
return useCloseoutInternal(tripRef);
|
|
541
557
|
}
|
|
558
|
+
function optimisticCollection(input, syncedAt) {
|
|
559
|
+
const collectedAt = input.collectedAt === void 0 ? "" : normalizeDateTimeInput(input.collectedAt, "collectedAt");
|
|
560
|
+
return {
|
|
561
|
+
// Replaced by the id the engine mints.
|
|
562
|
+
id: "pending",
|
|
563
|
+
version: 0,
|
|
564
|
+
travellerId: input.travellerId,
|
|
565
|
+
amountMinor: input.amountMinor,
|
|
566
|
+
// The request's own default, restated: this tenant's money unit.
|
|
567
|
+
currency: input.currency ?? "INR",
|
|
568
|
+
mode: input.mode,
|
|
569
|
+
reference: input.reference ?? null,
|
|
570
|
+
note: input.note ?? null,
|
|
571
|
+
collectedByManagerId: null,
|
|
572
|
+
performedByKind: null,
|
|
573
|
+
performedById: null,
|
|
574
|
+
collectedAt,
|
|
575
|
+
reportedAt: null,
|
|
576
|
+
voidedAt: null,
|
|
577
|
+
voidReason: null,
|
|
578
|
+
// The server's arithmetic, deliberately not guessed — see above.
|
|
579
|
+
outstandingMinor: null,
|
|
580
|
+
// The last reading the SERVER gave this list, never a device clock
|
|
581
|
+
// (hard rule #6).
|
|
582
|
+
createdAt: syncedAt ?? "",
|
|
583
|
+
updatedAt: syncedAt ?? ""
|
|
584
|
+
};
|
|
585
|
+
}
|
|
542
586
|
var useCollectionsInternal = createDomainHook("collections", (tripRef) => {
|
|
543
587
|
const client = useKaafilClient();
|
|
544
588
|
const {
|
|
@@ -588,7 +632,12 @@ var useCollectionsInternal = createDomainHook("collections", (tripRef) => {
|
|
|
588
632
|
// hardcoded literal, verified against
|
|
589
633
|
// `kaafil-js/src/generated/security.ts` this session.
|
|
590
634
|
operationId: "recordCollection",
|
|
591
|
-
body: input
|
|
635
|
+
body: input,
|
|
636
|
+
// A payment recorded out of signal appears at once — see
|
|
637
|
+
// `optimisticCollection` for what it deliberately does not claim.
|
|
638
|
+
creates: true,
|
|
639
|
+
entity: { listName: "collections" },
|
|
640
|
+
optimistic: optimisticCollection(input, syncedAt)
|
|
592
641
|
}),
|
|
593
642
|
// The desk lane. `recordCollection` takes the admin triple, and a desk
|
|
594
643
|
// console mounts no `OfflineShell` — without this the write has no
|
|
@@ -1576,6 +1625,34 @@ function useParties(tripRef) {
|
|
|
1576
1625
|
remove
|
|
1577
1626
|
};
|
|
1578
1627
|
}
|
|
1628
|
+
function optimisticPickupStop(input, syncedAt) {
|
|
1629
|
+
return {
|
|
1630
|
+
// Replaced by the id the engine mints.
|
|
1631
|
+
id: "pending",
|
|
1632
|
+
version: 0,
|
|
1633
|
+
// The request's own default, restated rather than guessed: the SDK's
|
|
1634
|
+
// `kind` is optional and the engine treats an absent one as a pickup.
|
|
1635
|
+
kind: input.kind ?? "PICKUP",
|
|
1636
|
+
name: input.name,
|
|
1637
|
+
locationLabel: input.locationLabel ?? null,
|
|
1638
|
+
lat: input.lat ?? null,
|
|
1639
|
+
lng: input.lng ?? null,
|
|
1640
|
+
scheduledTime: normalizeDateTimeInput(input.scheduledTime, "scheduledTime"),
|
|
1641
|
+
// Appended; the server's ordering arrives with the canonical row.
|
|
1642
|
+
sortOrder: input.sortOrder ?? Number.MAX_SAFE_INTEGER,
|
|
1643
|
+
status: "OPEN",
|
|
1644
|
+
closedAt: null,
|
|
1645
|
+
closedByManagerId: null,
|
|
1646
|
+
performedByKind: null,
|
|
1647
|
+
performedById: null,
|
|
1648
|
+
rollup: "not_started",
|
|
1649
|
+
boardedCount: 0,
|
|
1650
|
+
expectedCount: 0,
|
|
1651
|
+
// The last reading the SERVER gave this list, never a device clock
|
|
1652
|
+
// (hard rule #6).
|
|
1653
|
+
updatedAt: syncedAt ?? ""
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1579
1656
|
var usePickupsInternal = createDomainHook("pickup-points", (tripRef) => {
|
|
1580
1657
|
const client = useKaafilClient();
|
|
1581
1658
|
const {
|
|
@@ -1599,7 +1676,14 @@ var usePickupsInternal = createDomainHook("pickup-points", (tripRef) => {
|
|
|
1599
1676
|
// literal below is checked against `kaafil-js/src/generated/
|
|
1600
1677
|
// security.ts`'s own operation-id table.
|
|
1601
1678
|
operationId: "createPickupStop",
|
|
1602
|
-
body: input
|
|
1679
|
+
body: input,
|
|
1680
|
+
// A stop added out of signal appears at once, keyed on an id the
|
|
1681
|
+
// ENGINE mints and swapped for the server's row when the write lands
|
|
1682
|
+
// — see `optimisticPickupStop` for why every field here is one the
|
|
1683
|
+
// client can honestly know.
|
|
1684
|
+
creates: true,
|
|
1685
|
+
entity: { listName: "pickups" },
|
|
1686
|
+
optimistic: optimisticPickupStop(input, syncedAt)
|
|
1603
1687
|
}),
|
|
1604
1688
|
// The desk lane. `board`, `close` and `reopen` below deliberately get
|
|
1605
1689
|
// NONE — they are `managerAuth`-only on the wire, so a direct call from
|
|
@@ -1745,6 +1829,24 @@ var usePickupsInternal = createDomainHook("pickup-points", (tripRef) => {
|
|
|
1745
1829
|
function usePickups(tripRef) {
|
|
1746
1830
|
return usePickupsInternal(tripRef);
|
|
1747
1831
|
}
|
|
1832
|
+
function optimisticStayWindow(input, syncedAt) {
|
|
1833
|
+
return {
|
|
1834
|
+
// Replaced by the id the engine mints.
|
|
1835
|
+
id: "pending",
|
|
1836
|
+
version: 0,
|
|
1837
|
+
label: input.label,
|
|
1838
|
+
startDate: normalizeDateTimeInput(input.startDate, "startDate"),
|
|
1839
|
+
endDate: normalizeDateTimeInput(input.endDate, "endDate"),
|
|
1840
|
+
// Appended; the server's ordering arrives with the canonical row.
|
|
1841
|
+
sortOrder: input.sortOrder ?? Number.MAX_SAFE_INTEGER,
|
|
1842
|
+
// A window created by hand has no CRM segment behind it. This is a fact
|
|
1843
|
+
// about the write, not a placeholder.
|
|
1844
|
+
sourceSegmentRef: null,
|
|
1845
|
+
sourceUpdatedAt: null,
|
|
1846
|
+
// The last reading the SERVER gave this list, never a device clock.
|
|
1847
|
+
updatedAt: syncedAt ?? ""
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1748
1850
|
var useRoomingInternal = createDomainHook("rooming", (tripRef) => {
|
|
1749
1851
|
const client = useKaafilClient();
|
|
1750
1852
|
const {
|
|
@@ -1832,7 +1934,14 @@ var useRoomingInternal = createDomainHook("rooming", (tripRef) => {
|
|
|
1832
1934
|
method: SyncOpMethod.Post,
|
|
1833
1935
|
path: `/api/v1/trips/${tripRef}/rooming/stay-windows`,
|
|
1834
1936
|
operationId: "createRoomingStayWindow",
|
|
1835
|
-
body: input
|
|
1937
|
+
body: input,
|
|
1938
|
+
// A window added out of signal appears at once. Every field of a
|
|
1939
|
+
// stay window is either given by the caller or genuinely absent —
|
|
1940
|
+
// which is exactly what `createRoom` below cannot say, and why only
|
|
1941
|
+
// this one of the two gets an optimistic row.
|
|
1942
|
+
creates: true,
|
|
1943
|
+
entity: { listName: "stayWindows" },
|
|
1944
|
+
optimistic: optimisticStayWindow(input, windowsSyncedAt)
|
|
1836
1945
|
}),
|
|
1837
1946
|
direct: (liveClient, input) => liveClient.rooming.stayWindows.create({ tripRef, ...input })
|
|
1838
1947
|
});
|
|
@@ -2221,5 +2330,5 @@ function useVendors(tripRef, agencyRef) {
|
|
|
2221
2330
|
}
|
|
2222
2331
|
|
|
2223
2332
|
export { ERROR_HANDLING_PATH, FORM_FIELD_KIND_SINGLE_BOOLEAN, classifyError, createDomainHook, useChecklists, useCloseout, useCollections, useExpenses, useFiles, useFloat, useForms, useItinerary, useManagerToday, useManagers, useParties, usePickups, useRooming, useSeating, useSnapshotList, useTravellerProfile, useVendors };
|
|
2224
|
-
//# sourceMappingURL=chunk-
|
|
2225
|
-
//# sourceMappingURL=chunk-
|
|
2333
|
+
//# sourceMappingURL=chunk-JHMN6Q5R.js.map
|
|
2334
|
+
//# sourceMappingURL=chunk-JHMN6Q5R.js.map
|