kaafil-js 0.1.0-beta.2 → 0.1.0-beta.4

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.
@@ -16,20 +16,96 @@ var SECURITY_SCHEME_CARRIERS = {
16
16
  shareAuth: { kind: "bearer" }
17
17
  };
18
18
  var OperationId = {
19
+ AddChecklistItem: "addChecklistItem",
20
+ AddItineraryItem: "addItineraryItem",
21
+ AdjustFloat: "adjustFloat",
22
+ AssignPickupTraveller: "assignPickupTraveller",
23
+ AssignRoomingBed: "assignRoomingBed",
24
+ AssignSeating: "assignSeating",
25
+ AutoAssignRooming: "autoAssignRooming",
26
+ AutoAssignSeating: "autoAssignSeating",
27
+ BoardPickupTraveller: "boardPickupTraveller",
28
+ ClaimStatusIngest: "claimStatusIngest",
29
+ ClosePickupStop: "closePickupStop",
30
+ ConfirmFileUpload: "confirmFileUpload",
31
+ CreatePickupStop: "createPickupStop",
32
+ CreateRoomingRoom: "createRoomingRoom",
33
+ CreateRoomingStayWindow: "createRoomingStayWindow",
34
+ CreateSeatingVehicle: "createSeatingVehicle",
35
+ CreateTrekWalkIn: "createTrekWalkIn",
36
+ DeleteChecklistItem: "deleteChecklistItem",
37
+ DeleteItineraryItem: "deleteItineraryItem",
38
+ DeletePickupStop: "deletePickupStop",
39
+ DeleteRoomingRoom: "deleteRoomingRoom",
40
+ DeleteRoomingStayWindow: "deleteRoomingStayWindow",
41
+ DeleteSeatingVehicle: "deleteSeatingVehicle",
42
+ ExportCloseoutPack: "exportCloseoutPack",
19
43
  GetShareManifest: "getShareManifest",
20
44
  GetShareSnapshot: "getShareSnapshot",
45
+ IssueFloat: "issueFloat",
46
+ LinkExpenseReceipt: "linkExpenseReceipt",
47
+ LinkSeatingManager: "linkSeatingManager",
48
+ ListChecklistTemplates: "listChecklistTemplates",
49
+ ListCollections: "listCollections",
50
+ ListEligibleCollections: "listEligibleCollections",
51
+ ListExpenses: "listExpenses",
21
52
  ListJourneyTriggers: "listJourneyTriggers",
22
53
  ListManagerNotifications: "listManagerNotifications",
54
+ ListPickupStops: "listPickupStops",
55
+ ListRoomingStayWindows: "listRoomingStayWindows",
23
56
  ListTripVendors: "listTripVendors",
57
+ LockCloseout: "lockCloseout",
58
+ LogExpense: "logExpense",
59
+ PatchChecklistItem: "patchChecklistItem",
60
+ PatchItineraryDay: "patchItineraryDay",
61
+ PatchItineraryItem: "patchItineraryItem",
24
62
  PatchJourneyTrigger: "patchJourneyTrigger",
63
+ PatchPickupStop: "patchPickupStop",
64
+ PatchRoomingRoom: "patchRoomingRoom",
65
+ PatchRoomingStayWindow: "patchRoomingStayWindow",
66
+ PatchSeatingVehicle: "patchSeatingVehicle",
67
+ PostponeTrek: "postponeTrek",
68
+ PullChecklistTemplate: "pullChecklistTemplate",
69
+ ReadChecklistAggregate: "readChecklistAggregate",
70
+ ReadCloseout: "readCloseout",
71
+ ReadExpense: "readExpense",
72
+ ReadFile: "readFile",
73
+ ReadFileUrl: "readFileUrl",
74
+ ReadFloatLedger: "readFloatLedger",
75
+ ReadFloatSummary: "readFloatSummary",
76
+ ReadItinerary: "readItinerary",
77
+ ReadItineraryChangeLog: "readItineraryChangeLog",
25
78
  ReadJourney: "readJourney",
26
79
  ReadJourneyCapabilities: "readJourneyCapabilities",
80
+ ReadManifestByPickup: "readManifestByPickup",
81
+ ReadRoomingBoard: "readRoomingBoard",
82
+ ReadSeatingBoard: "readSeatingBoard",
83
+ ReadTrekBoard: "readTrekBoard",
84
+ ReadTrekWalkInMeta: "readTrekWalkInMeta",
27
85
  RebuildJourney: "rebuildJourney",
86
+ RecordCollection: "recordCollection",
87
+ ReopenPickupStop: "reopenPickupStop",
88
+ ReorderItineraryItem: "reorderItineraryItem",
89
+ ReorderPickupStops: "reorderPickupStops",
90
+ RequestFileUpload: "requestFileUpload",
91
+ ReturnFloat: "returnFloat",
28
92
  RunJourneyStep: "runJourneyStep",
93
+ SaveCloseoutHandover: "saveCloseoutHandover",
29
94
  ShareListForms: "shareListForms",
30
95
  ShareRenderForm: "shareRenderForm",
31
96
  ShareSaveForm: "shareSaveForm",
32
- ShareSubmitForm: "shareSubmitForm"};
97
+ ShareSubmitForm: "shareSubmitForm",
98
+ SubmitExpenseClaim: "submitExpenseClaim",
99
+ SyncPullTrip: "syncPullTrip",
100
+ SyncPush: "syncPush",
101
+ SyncPushShare: "syncPushShare",
102
+ ToggleChecklistItem: "toggleChecklistItem",
103
+ UnlinkSeatingManager: "unlinkSeatingManager",
104
+ UnlockCloseout: "unlockCloseout",
105
+ VoidCollection: "voidCollection",
106
+ VoidExpense: "voidExpense",
107
+ WithdrawExpenseClaim: "withdrawExpenseClaim"
108
+ };
33
109
  var OPERATION_SECURITY = {
34
110
  acceptConsoleInvite: [],
35
111
  acceptPlatformAdminInvite: [],
@@ -68,6 +144,7 @@ var OPERATION_SECURITY = {
68
144
  createRoomingRoom: ["managerAuth"],
69
145
  createRoomingStayWindow: ["managerAuth"],
70
146
  createSeatingVehicle: ["managerAuth"],
147
+ createSupportGrant: ["platformAdminAuth"],
71
148
  createTrekWalkIn: ["managerAuth"],
72
149
  deleteBooking: ["apiKeyAuth"],
73
150
  deleteChecklistItem: ["managerAuth"],
@@ -82,7 +159,10 @@ var OPERATION_SECURITY = {
82
159
  deleteSeatingVehicle: ["managerAuth"],
83
160
  dispatchForm: ["managerAuth", "apiKeyAuth"],
84
161
  editWebhookEndpoint: ["consoleAuth"],
162
+ eraseTraveller: ["apiKeyAuth"],
163
+ exportCloseoutPack: ["managerAuth", "apiKeyAuth"],
85
164
  exportFormResponses: ["apiKeyAuth", "managerAuth"],
165
+ exportTraveller: ["apiKeyAuth"],
86
166
  getForm: ["apiKeyAuth", "agencyAdminAuth", "managerAuth"],
87
167
  getFormAggregate: ["apiKeyAuth"],
88
168
  getFormConsentReceipt: ["apiKeyAuth", "managerAuth"],
@@ -121,11 +201,14 @@ var OPERATION_SECURITY = {
121
201
  listPlatformPartnerConsoleUsers: ["platformAdminAuth"],
122
202
  listPlatformPartners: ["platformAdminAuth"],
123
203
  listRoomingStayWindows: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
204
+ listSupportIngestLog: ["platformAdminAuth"],
205
+ listSupportWebhookDeliveries: ["platformAdminAuth"],
124
206
  listTripFormResponses: ["managerAuth", "apiKeyAuth"],
125
207
  listTripForms: ["managerAuth", "apiKeyAuth"],
126
208
  listTripVendors: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
127
209
  listWebhookDeliveries: ["apiKeyAuth"],
128
210
  listWebhookEndpoints: ["consoleAuth"],
211
+ lockCloseout: ["managerAuth"],
129
212
  logExpense: ["managerAuth"],
130
213
  managerCreateFormResponse: ["managerAuth"],
131
214
  markNotificationRead: ["managerAuth"],
@@ -165,6 +248,7 @@ var OPERATION_SECURITY = {
165
248
  readAgencyFeedbackSummary: ["agencyAdminAuth", "apiKeyAuth"],
166
249
  readApiKey: ["consoleAuth"],
167
250
  readChecklistAggregate: ["managerAuth", "apiKeyAuth"],
251
+ readCloseout: ["managerAuth", "apiKeyAuth"],
168
252
  readCommsConfig: ["apiKeyAuth"],
169
253
  readConsoleAudit: ["consoleAuth"],
170
254
  readConsoleChecklist: ["consoleAuth"],
@@ -192,6 +276,8 @@ var OPERATION_SECURITY = {
192
276
  readRoomingBoard: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
193
277
  readSeatingBoard: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
194
278
  readShareToken: ["apiKeyAuth"],
279
+ readSupportJourneyState: ["platformAdminAuth"],
280
+ readSupportWebhookDeliveryDetail: ["platformAdminAuth"],
195
281
  readTrekBoard: ["managerAuth", "apiKeyAuth"],
196
282
  readTrekWalkInMeta: ["managerAuth", "apiKeyAuth"],
197
283
  readTripFeedbackSummary: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
@@ -202,6 +288,7 @@ var OPERATION_SECURITY = {
202
288
  recordCollection: ["managerAuth"],
203
289
  redeliverEndpointDelivery: ["consoleAuth"],
204
290
  redeliverWebhookDelivery: ["apiKeyAuth"],
291
+ redriveSupportWebhookDelivery: ["platformAdminAuth"],
205
292
  refreshAgencyAdminTokens: ["agencyAdminAuth"],
206
293
  refreshManagerTokens: ["managerAuth"],
207
294
  regenerateShareToken: ["apiKeyAuth"],
@@ -217,6 +304,7 @@ var OPERATION_SECURITY = {
217
304
  reorderItineraryItem: ["managerAuth"],
218
305
  reorderPickupStops: ["managerAuth"],
219
306
  replaceBookingVouchers: ["apiKeyAuth"],
307
+ replaySupportWebhookRange: ["platformAdminAuth"],
220
308
  replayWebhookEndpoint: ["apiKeyAuth"],
221
309
  requestFileUpload: ["managerAuth", "apiKeyAuth"],
222
310
  resetPlatformPartnerConsoleUser: ["platformAdminAuth"],
@@ -227,6 +315,7 @@ var OPERATION_SECURITY = {
227
315
  rotateApiKey: ["consoleAuth"],
228
316
  rotateWebhookEndpointSecret: ["consoleAuth"],
229
317
  runJourneyStep: ["apiKeyAuth"],
318
+ saveCloseoutHandover: ["managerAuth"],
230
319
  sendMessage: ["apiKeyAuth"],
231
320
  setPlatformPartnerStatus: ["platformAdminAuth"],
232
321
  shareListForms: ["shareAuth"],
@@ -234,10 +323,15 @@ var OPERATION_SECURITY = {
234
323
  shareSaveForm: ["shareAuth"],
235
324
  shareSubmitForm: ["shareAuth"],
236
325
  submitExpenseClaim: ["managerAuth"],
326
+ syncDigest: ["apiKeyAuth"],
327
+ syncPullTrip: ["managerAuth", "apiKeyAuth"],
328
+ syncPush: ["managerAuth", "apiKeyAuth"],
329
+ syncPushShare: [],
237
330
  toggleChecklistItem: ["managerAuth"],
238
331
  unarchiveForm: ["apiKeyAuth", "agencyAdminAuth"],
239
332
  unassignManager: ["apiKeyAuth"],
240
333
  unlinkSeatingManager: ["managerAuth"],
334
+ unlockCloseout: ["apiKeyAuth"],
241
335
  upsertAgencyAdmin: ["apiKeyAuth"],
242
336
  upsertManager: ["apiKeyAuth"],
243
337
  upsertTravellerProfile: ["apiKeyAuth"],
@@ -284,6 +378,7 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
284
378
  createRoomingRoom: true,
285
379
  createRoomingStayWindow: true,
286
380
  createSeatingVehicle: true,
381
+ createSupportGrant: false,
287
382
  createTrekWalkIn: true,
288
383
  deleteBooking: true,
289
384
  deleteChecklistItem: false,
@@ -298,7 +393,10 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
298
393
  deleteSeatingVehicle: false,
299
394
  dispatchForm: true,
300
395
  editWebhookEndpoint: true,
396
+ eraseTraveller: true,
397
+ exportCloseoutPack: false,
301
398
  exportFormResponses: false,
399
+ exportTraveller: false,
302
400
  getForm: false,
303
401
  getFormAggregate: false,
304
402
  getFormConsentReceipt: false,
@@ -337,11 +435,14 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
337
435
  listPlatformPartnerConsoleUsers: false,
338
436
  listPlatformPartners: false,
339
437
  listRoomingStayWindows: false,
438
+ listSupportIngestLog: false,
439
+ listSupportWebhookDeliveries: false,
340
440
  listTripFormResponses: false,
341
441
  listTripForms: false,
342
442
  listTripVendors: false,
343
443
  listWebhookDeliveries: false,
344
444
  listWebhookEndpoints: false,
445
+ lockCloseout: true,
345
446
  logExpense: true,
346
447
  managerCreateFormResponse: true,
347
448
  markNotificationRead: true,
@@ -381,6 +482,7 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
381
482
  readAgencyFeedbackSummary: false,
382
483
  readApiKey: false,
383
484
  readChecklistAggregate: false,
485
+ readCloseout: false,
384
486
  readCommsConfig: false,
385
487
  readConsoleAudit: false,
386
488
  readConsoleChecklist: false,
@@ -408,6 +510,8 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
408
510
  readRoomingBoard: false,
409
511
  readSeatingBoard: false,
410
512
  readShareToken: false,
513
+ readSupportJourneyState: false,
514
+ readSupportWebhookDeliveryDetail: false,
411
515
  readTrekBoard: false,
412
516
  readTrekWalkInMeta: false,
413
517
  readTripFeedbackSummary: false,
@@ -418,6 +522,7 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
418
522
  recordCollection: true,
419
523
  redeliverEndpointDelivery: true,
420
524
  redeliverWebhookDelivery: true,
525
+ redriveSupportWebhookDelivery: false,
421
526
  refreshAgencyAdminTokens: false,
422
527
  refreshManagerTokens: false,
423
528
  regenerateShareToken: true,
@@ -433,6 +538,7 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
433
538
  reorderItineraryItem: true,
434
539
  reorderPickupStops: true,
435
540
  replaceBookingVouchers: false,
541
+ replaySupportWebhookRange: false,
436
542
  replayWebhookEndpoint: true,
437
543
  requestFileUpload: true,
438
544
  resetPlatformPartnerConsoleUser: false,
@@ -443,6 +549,7 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
443
549
  rotateApiKey: true,
444
550
  rotateWebhookEndpointSecret: true,
445
551
  runJourneyStep: true,
552
+ saveCloseoutHandover: true,
446
553
  sendMessage: true,
447
554
  setPlatformPartnerStatus: false,
448
555
  shareListForms: false,
@@ -450,10 +557,15 @@ var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
450
557
  shareSaveForm: true,
451
558
  shareSubmitForm: true,
452
559
  submitExpenseClaim: true,
560
+ syncDigest: false,
561
+ syncPullTrip: false,
562
+ syncPush: false,
563
+ syncPushShare: false,
453
564
  toggleChecklistItem: true,
454
565
  unarchiveForm: false,
455
566
  unassignManager: true,
456
567
  unlinkSeatingManager: false,
568
+ unlockCloseout: true,
457
569
  upsertAgencyAdmin: true,
458
570
  upsertManager: true,
459
571
  upsertTravellerProfile: true,
@@ -495,10 +607,13 @@ var KaafilErrorCode = {
495
607
  SecretNotReplayable: "SECRET_NOT_REPLAYABLE",
496
608
  ShareTokenExpired: "SHARE_TOKEN_EXPIRED",
497
609
  ShareTokenRevoked: "SHARE_TOKEN_REVOKED",
610
+ ShareWriteGraceExpired: "SHARE_WRITE_GRACE_EXPIRED",
498
611
  StayWindowHasAssignments: "STAY_WINDOW_HAS_ASSIGNMENTS",
499
612
  StayWindowOverlap: "STAY_WINDOW_OVERLAP",
500
613
  StopHasPending: "STOP_HAS_PENDING",
501
614
  SubjectRequired: "SUBJECT_REQUIRED",
615
+ SupportGrantRequired: "SUPPORT_GRANT_REQUIRED",
616
+ SyncTargetRefused: "SYNC_TARGET_REFUSED",
502
617
  TenantScopeMissing: "TENANT_SCOPE_MISSING",
503
618
  Unauthenticated: "UNAUTHENTICATED",
504
619
  UploadMismatch: "UPLOAD_MISMATCH",
@@ -546,10 +661,13 @@ var ERROR_CODE_TABLE = {
546
661
  SECRET_NOT_REPLAYABLE: { status: 409, retryability: "no", outboxClass: "CONFLICT" },
547
662
  SHARE_TOKEN_EXPIRED: { status: 401, retryability: "no", outboxClass: "FATAL" },
548
663
  SHARE_TOKEN_REVOKED: { status: 401, retryability: "no", outboxClass: "FATAL" },
664
+ SHARE_WRITE_GRACE_EXPIRED: { status: 422, retryability: "no", outboxClass: "FATAL" },
549
665
  STAY_WINDOW_HAS_ASSIGNMENTS: { status: 422, retryability: "no", outboxClass: "FATAL" },
550
666
  STAY_WINDOW_OVERLAP: { status: 422, retryability: "no", outboxClass: "FATAL" },
551
667
  STOP_HAS_PENDING: { status: 422, retryability: "no", outboxClass: "FATAL" },
552
668
  SUBJECT_REQUIRED: { status: 422, retryability: "no", outboxClass: "FATAL" },
669
+ SUPPORT_GRANT_REQUIRED: { status: 403, retryability: "no", outboxClass: "FATAL" },
670
+ SYNC_TARGET_REFUSED: { status: 422, retryability: "no", outboxClass: "FATAL" },
553
671
  TENANT_SCOPE_MISSING: { status: 500, retryability: "yes", outboxClass: "TRANSIENT" },
554
672
  UNAUTHENTICATED: { status: 401, retryability: "after-refresh", outboxClass: "FATAL" },
555
673
  UPLOAD_MISMATCH: { status: 422, retryability: "no", outboxClass: "FATAL" },
@@ -1184,7 +1302,8 @@ function createHttpClient(config) {
1184
1302
  random: config.random
1185
1303
  };
1186
1304
  return {
1187
- execute: (request) => execute(ctx, request)
1305
+ execute: (request) => execute(ctx, request),
1306
+ executeBinary: (request) => executeBinary(ctx, request)
1188
1307
  };
1189
1308
  }
1190
1309
  function renderPath(template, params) {
@@ -1241,7 +1360,7 @@ async function buildHeaders(ctx, request, idempotencyKey, hasBody) {
1241
1360
  const acceptedSchemes = OPERATION_SECURITY[request.operationId];
1242
1361
  const credential = await ctx.credentials.resolveHeaders(request.operationId, acceptedSchemes);
1243
1362
  const headers = new Headers();
1244
- headers.set("Accept", "application/json");
1363
+ headers.set("Accept", request.accept ?? "application/json");
1245
1364
  if (hasBody) {
1246
1365
  headers.set("Content-Type", "application/json");
1247
1366
  }
@@ -1317,7 +1436,17 @@ function describeCrossOriginSuspect(url) {
1317
1436
  }
1318
1437
  return `Request failed while calling a different origin (${url.origin}) than the page's own origin (${origin}). The most likely cause is that the API has not allowlisted this origin for CORS \u2014 but the browser withholds the actual reason from JavaScript when it blocks a cross-origin response, so the SDK cannot confirm this; a genuine network outage produces the same rejection. If this is unexpected, the fix is server-side: add this origin to the API's CORS allowlist.`;
1319
1438
  }
1320
- async function sendOnce(ctx, request, idempotencyKey) {
1439
+ async function throwFromErrorResponse(response, status, requestId) {
1440
+ const text = await response.text();
1441
+ const body = text.length > 0 ? tryParseJson(text) : void 0;
1442
+ const retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("retry-after"));
1443
+ throw fromEnvelope(body, {
1444
+ status,
1445
+ ...requestId !== void 0 ? { requestId } : {},
1446
+ ...retryAfterSeconds !== void 0 ? { retryAfterSeconds } : {}
1447
+ });
1448
+ }
1449
+ async function sendOnceWith(ctx, request, idempotencyKey, readSuccess) {
1321
1450
  const hasBody = request.body !== void 0;
1322
1451
  const renderedPath = renderPath(request.path, request.pathParams);
1323
1452
  const url = buildUrl(ctx.baseUrl, renderedPath, request.query);
@@ -1332,23 +1461,10 @@ async function sendOnce(ctx, request, idempotencyKey) {
1332
1461
  });
1333
1462
  const requestId = response.headers.get("x-request-id") ?? void 0;
1334
1463
  const status = response.status;
1335
- const text = await response.text();
1336
- const body = text.length > 0 ? tryParseJson(text) : void 0;
1337
1464
  if (response.ok) {
1338
- if (!isSuccessEnvelope(body)) {
1339
- throw new KaafilNetworkError(`Received an unrecognizable success body for HTTP ${status}`, {
1340
- status,
1341
- ...requestId !== void 0 ? { requestId } : {}
1342
- });
1343
- }
1344
- return { data: body.data, meta: buildResponseMeta(status, requestId, body.meta) };
1465
+ return await readSuccess(response, status, requestId);
1345
1466
  }
1346
- const retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("retry-after"));
1347
- throw fromEnvelope(body, {
1348
- status,
1349
- ...requestId !== void 0 ? { requestId } : {},
1350
- ...retryAfterSeconds !== void 0 ? { retryAfterSeconds } : {}
1351
- });
1467
+ return await throwFromErrorResponse(response, status, requestId);
1352
1468
  } catch (error) {
1353
1469
  if (isKaafilError(error)) {
1354
1470
  throw error;
@@ -1366,6 +1482,30 @@ async function sendOnce(ctx, request, idempotencyKey) {
1366
1482
  combined.cleanup();
1367
1483
  }
1368
1484
  }
1485
+ function sendOnce(ctx, request, idempotencyKey) {
1486
+ return sendOnceWith(ctx, request, idempotencyKey, async (response, status, requestId) => {
1487
+ const text = await response.text();
1488
+ const body = text.length > 0 ? tryParseJson(text) : void 0;
1489
+ if (!isSuccessEnvelope(body)) {
1490
+ throw new KaafilNetworkError(`Received an unrecognizable success body for HTTP ${status}`, {
1491
+ status,
1492
+ ...requestId !== void 0 ? { requestId } : {}
1493
+ });
1494
+ }
1495
+ return { data: body.data, meta: buildResponseMeta(status, requestId, body.meta) };
1496
+ });
1497
+ }
1498
+ function sendOnceBinary(ctx, request, idempotencyKey) {
1499
+ return sendOnceWith(ctx, request, idempotencyKey, async (response, status, requestId) => {
1500
+ const buffer = await response.arrayBuffer();
1501
+ const meta = {
1502
+ status,
1503
+ requestId,
1504
+ contentType: response.headers.get("content-type") ?? void 0
1505
+ };
1506
+ return { bytes: new Uint8Array(buffer), meta };
1507
+ });
1508
+ }
1369
1509
  var MANAGER_TOKENS_REFRESH_PATH = "/api/v1/auth/manager-tokens/refresh";
1370
1510
  var AGENCY_ADMIN_TOKENS_REFRESH_PATH = "/api/v1/auth/agency-admin-tokens/refresh";
1371
1511
  function createRotatingSessionRefreshExchange(baseUrl, refreshPath, networkErrorMessage) {
@@ -1433,17 +1573,19 @@ function toFailureOutcome(error) {
1433
1573
  ...error instanceof KaafilRateLimitedError && error.retryAfterSeconds !== void 0 ? { retryAfterSeconds: error.retryAfterSeconds } : {}
1434
1574
  };
1435
1575
  }
1436
- async function execute(ctx, request) {
1576
+ async function runWithLadder(ctx, request, send) {
1437
1577
  const idempotencyKey = OPERATION_ACCEPTS_IDEMPOTENCY_KEY[request.operationId] ? request.idempotencyKey ?? globalThis.crypto.randomUUID() : void 0;
1438
1578
  let lastError;
1439
1579
  let refreshAttempted = false;
1440
1580
  const sendAndClassify = async () => {
1441
1581
  try {
1442
- const { data, meta } = await sendOnce(ctx, request, idempotencyKey);
1443
- return { ok: true, value: attachMeta(data, meta) };
1582
+ return { ok: true, value: await send(idempotencyKey) };
1444
1583
  } catch (error) {
1445
1584
  const typed = toKaafilError(error);
1446
1585
  lastError = typed;
1586
+ if (typed.kind === "transport" && !isRetryable(typed)) {
1587
+ throw typed;
1588
+ }
1447
1589
  return toFailureOutcome(typed);
1448
1590
  }
1449
1591
  };
@@ -1483,161 +1625,2771 @@ async function execute(ctx, request) {
1483
1625
  throw error;
1484
1626
  }
1485
1627
  }
1628
+ function execute(ctx, request) {
1629
+ return runWithLadder(ctx, request, async (idempotencyKey) => {
1630
+ const { data, meta } = await sendOnce(ctx, request, idempotencyKey);
1631
+ return attachMeta(data, meta);
1632
+ });
1633
+ }
1634
+ function executeBinary(ctx, request) {
1635
+ return runWithLadder(
1636
+ ctx,
1637
+ request,
1638
+ (idempotencyKey) => sendOnceBinary(ctx, request, idempotencyKey)
1639
+ );
1640
+ }
1486
1641
 
1487
1642
  // src/idempotency.ts
1488
1643
  function newIdempotencyKey() {
1489
1644
  return globalThis.crypto.randomUUID();
1490
1645
  }
1491
1646
 
1492
- // src/resources/journey.ts
1493
- var DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS = 6e4;
1494
- var DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS = 1e3;
1495
- function createJourneyResource(client) {
1496
- const resource = {
1497
- async get(options) {
1498
- const { tripRef, signal } = options;
1647
+ // src/resources/sync.ts
1648
+ var KaafilShareBatchUnauthenticatedError = class _KaafilShareBatchUnauthenticatedError extends KaafilInvalidRequestError {
1649
+ constructor() {
1650
+ super(
1651
+ `The vendored spec declares no security scheme for "syncPushShare", so a batched share push would be sent with no credential at all, carrying a traveller's queued writes. Refused locally. Drain share ops through their own endpoints (shareSaveForm / shareSubmitForm) until the engine declares shareAuth on POST /api/v1/sync/push/share.`
1652
+ );
1653
+ this.name = "KaafilShareBatchUnauthenticatedError";
1654
+ Object.setPrototypeOf(this, _KaafilShareBatchUnauthenticatedError.prototype);
1655
+ }
1656
+ };
1657
+ function isShareBatchPushAvailable() {
1658
+ return OPERATION_SECURITY[OperationId.SyncPushShare].includes(
1659
+ SecuritySchemeId.ShareAuth
1660
+ );
1661
+ }
1662
+ function createSyncResource(client) {
1663
+ return {
1664
+ async push(options) {
1665
+ const { ops, signal } = options;
1666
+ const body = { ops: [...ops] };
1499
1667
  return client.execute({
1500
- method: "GET",
1501
- operationId: OperationId.ReadJourney,
1502
- path: "/api/v1/trips/{ref}/journey",
1503
- pathParams: { ref: tripRef },
1668
+ method: "POST",
1669
+ operationId: OperationId.SyncPush,
1670
+ path: "/api/v1/sync/push",
1671
+ body,
1504
1672
  ...signal !== void 0 ? { signal } : {}
1505
1673
  });
1506
1674
  },
1507
- async capabilities(options) {
1508
- const { tripRef, signal } = options;
1675
+ async pullTrip(options) {
1676
+ const { tripRef, since, signal } = options;
1509
1677
  return client.execute({
1510
1678
  method: "GET",
1511
- operationId: OperationId.ReadJourneyCapabilities,
1512
- path: "/api/v1/trips/{ref}/journey/capabilities",
1679
+ operationId: OperationId.SyncPullTrip,
1680
+ path: "/api/v1/trips/{ref}/sync",
1513
1681
  pathParams: { ref: tripRef },
1682
+ // A `since` of `undefined` is omitted by `RequestDescriptor`'s own
1683
+ // rule, which is exactly the cold-start shape: no `?since=` at all.
1684
+ query: { since },
1514
1685
  ...signal !== void 0 ? { signal } : {}
1515
1686
  });
1516
1687
  },
1517
- async rebuild(options) {
1518
- const { tripRef, idempotencyKey, signal } = options;
1688
+ async pushShare(options) {
1689
+ if (!isShareBatchPushAvailable()) {
1690
+ throw new KaafilShareBatchUnauthenticatedError();
1691
+ }
1692
+ const { ops, signal } = options;
1693
+ const body = { ops: [...ops] };
1519
1694
  return client.execute({
1520
1695
  method: "POST",
1521
- operationId: OperationId.RebuildJourney,
1522
- path: "/api/v1/trips/{ref}/journey/rebuild",
1523
- pathParams: { ref: tripRef },
1524
- ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
1696
+ operationId: OperationId.SyncPushShare,
1697
+ path: "/api/v1/sync/push/share",
1698
+ body,
1525
1699
  ...signal !== void 0 ? { signal } : {}
1526
1700
  });
1701
+ }
1702
+ };
1703
+ }
1704
+
1705
+ // src/http/classify.ts
1706
+ var OUTBOX_CLASS_TO_VERDICT = {
1707
+ TRANSIENT: "transient",
1708
+ CONFLICT: "conflict",
1709
+ FATAL: "fatal"
1710
+ };
1711
+ function classifyFailure(input) {
1712
+ if (input.status === null) {
1713
+ return "transient";
1714
+ }
1715
+ const entry = input.code !== void 0 ? ERROR_CODE_TABLE[input.code] : void 0;
1716
+ if (entry !== void 0) {
1717
+ return OUTBOX_CLASS_TO_VERDICT[entry.outboxClass];
1718
+ }
1719
+ if (input.status === 429 || input.status >= 500 && input.status <= 599 && input.status !== 501) {
1720
+ return "transient";
1721
+ }
1722
+ if (input.status === 409) {
1723
+ return "conflict";
1724
+ }
1725
+ return "fatal";
1726
+ }
1727
+
1728
+ // src/offline/blob.ts
1729
+ var BlobStatus = {
1730
+ Pending: "pending",
1731
+ Confirmed: "confirmed",
1732
+ Parked: "parked"
1733
+ };
1734
+ function createBlobLane(options) {
1735
+ const key = `${options.keyPrefix}:blobs`;
1736
+ const now = options.now ?? Date.now;
1737
+ const random = options.random ?? Math.random;
1738
+ let blobs = /* @__PURE__ */ new Map();
1739
+ const bodyBuilders = /* @__PURE__ */ new Map();
1740
+ let backfills = /* @__PURE__ */ new Map();
1741
+ async function persist() {
1742
+ const shape = {
1743
+ blobs: [...blobs.values()],
1744
+ backfills: Object.fromEntries(backfills)
1745
+ };
1746
+ await options.storage.set(key, JSON.stringify(shape));
1747
+ }
1748
+ async function update(id, patch) {
1749
+ const held = blobs.get(id);
1750
+ if (held === void 0) {
1751
+ return void 0;
1752
+ }
1753
+ const next = { ...held, ...patch };
1754
+ blobs.set(id, next);
1755
+ await persist();
1756
+ return next;
1757
+ }
1758
+ async function park(id, reason) {
1759
+ const record = await update(id, {
1760
+ status: BlobStatus.Parked,
1761
+ parkReason: reason,
1762
+ nextRetryAt: null
1763
+ });
1764
+ if (record !== void 0) {
1765
+ options.onParked?.(record);
1766
+ }
1767
+ }
1768
+ async function retryLater(record) {
1769
+ await update(record.id, {
1770
+ attemptCount: record.attemptCount + 1,
1771
+ nextRetryAt: now() + computeRetryDelayMs(record.attemptCount + 1, { random })
1772
+ });
1773
+ }
1774
+ async function driveOne(record) {
1775
+ const backfill = backfills.get(record.id);
1776
+ const buildBody = bodyBuilders.get(record.id);
1777
+ if (backfill === void 0 || buildBody === void 0) {
1778
+ await park(
1779
+ record.id,
1780
+ "No back-fill builder is registered for this blob in the current process, so the file key could not be written onto the parent entity. Re-register it and re-enqueue."
1781
+ );
1782
+ return "parked";
1783
+ }
1784
+ const bytes = await options.source(record.id);
1785
+ if (bytes === void 0) {
1786
+ await park(
1787
+ record.id,
1788
+ "The bytes for this attachment were not retained across the restart, so it can never be uploaded. The entity it belongs to is unaffected."
1789
+ );
1790
+ return "parked";
1791
+ }
1792
+ let fileId = record.fileId;
1793
+ if (fileId === void 0) {
1794
+ try {
1795
+ const created = await options.uploader.request({
1796
+ contentType: record.contentType,
1797
+ sizeBytes: record.sizeBytes,
1798
+ tripRef: record.tripRef
1799
+ });
1800
+ fileId = created.fileId;
1801
+ await update(record.id, { fileId });
1802
+ const put = await options.uploader.put({
1803
+ uploadUrl: created.uploadUrl,
1804
+ bytes,
1805
+ contentType: record.contentType
1806
+ });
1807
+ if (put.status < 200 || put.status >= 300) {
1808
+ await retryLater({ ...record, fileId });
1809
+ return "pending";
1810
+ }
1811
+ } catch {
1812
+ await retryLater(record);
1813
+ return "pending";
1814
+ }
1815
+ }
1816
+ let confirmStatus;
1817
+ let confirmCode;
1818
+ try {
1819
+ const confirmed = await options.uploader.confirm({ fileId });
1820
+ confirmStatus = confirmed.status;
1821
+ confirmCode = confirmed.code;
1822
+ } catch {
1823
+ await retryLater(record);
1824
+ return "pending";
1825
+ }
1826
+ if (confirmStatus < 200 || confirmStatus >= 300) {
1827
+ const verdict = classifyFailure({
1828
+ status: confirmStatus,
1829
+ ...confirmCode !== void 0 ? { code: confirmCode } : {}
1830
+ });
1831
+ if (verdict === "transient") {
1832
+ await retryLater(record);
1833
+ return "pending";
1834
+ }
1835
+ await park(
1836
+ record.id,
1837
+ `The upload could not be confirmed (${confirmCode ?? confirmStatus}). The entity it belongs to is unaffected.`
1838
+ );
1839
+ return "parked";
1840
+ }
1841
+ await options.outbox.enqueue({
1842
+ tripRef: record.tripRef,
1843
+ method: backfill.method,
1844
+ path: backfill.path,
1845
+ operationId: backfill.operationId,
1846
+ body: buildBody(fileId),
1847
+ ...backfill.entity !== void 0 ? { entity: backfill.entity } : {},
1848
+ ...backfill.ifMatch !== void 0 ? { ifMatch: backfill.ifMatch } : {}
1849
+ });
1850
+ await update(record.id, { status: BlobStatus.Confirmed, nextRetryAt: null });
1851
+ return "confirmed";
1852
+ }
1853
+ return {
1854
+ async load() {
1855
+ blobs = /* @__PURE__ */ new Map();
1856
+ backfills = /* @__PURE__ */ new Map();
1857
+ const raw = await options.storage.get(key);
1858
+ if (raw === void 0) {
1859
+ return;
1860
+ }
1861
+ let parsed;
1862
+ try {
1863
+ parsed = JSON.parse(raw);
1864
+ } catch {
1865
+ return;
1866
+ }
1867
+ for (const record of parsed.blobs ?? []) {
1868
+ blobs.set(record.id, record);
1869
+ }
1870
+ for (const [id, shape] of Object.entries(parsed.backfills ?? {})) {
1871
+ backfills.set(id, shape);
1872
+ }
1527
1873
  },
1528
- async runStep(options) {
1529
- const { tripRef, stepId, idempotencyKey, signal } = options;
1530
- return client.execute({
1531
- method: "POST",
1532
- operationId: OperationId.RunJourneyStep,
1533
- path: "/api/v1/trips/{ref}/journey/steps/{stepId}/run",
1534
- pathParams: { ref: tripRef, stepId },
1535
- ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
1536
- ...signal !== void 0 ? { signal } : {}
1874
+ async enqueue(args) {
1875
+ const record = {
1876
+ id: args.blobId,
1877
+ tripRef: args.tripRef,
1878
+ parentOpId: args.parentOpId,
1879
+ contentType: args.contentType,
1880
+ sizeBytes: args.sizeBytes,
1881
+ status: BlobStatus.Pending,
1882
+ attemptCount: 0,
1883
+ nextRetryAt: null,
1884
+ fileId: void 0,
1885
+ parkReason: void 0
1886
+ };
1887
+ blobs.set(record.id, record);
1888
+ backfills.set(record.id, {
1889
+ method: args.backfill.method,
1890
+ path: args.backfill.path,
1891
+ operationId: args.backfill.operationId,
1892
+ entity: args.backfill.entity,
1893
+ ifMatch: args.backfill.ifMatch
1537
1894
  });
1895
+ bodyBuilders.set(record.id, args.backfill.body);
1896
+ await persist();
1897
+ return record;
1538
1898
  },
1539
- async waitUntilReady(options) {
1540
- const {
1541
- tripRef,
1542
- timeoutMs = DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS,
1543
- pollIntervalMs = DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS,
1544
- signal
1545
- } = options;
1546
- const deadlineAt = Date.now() + timeoutMs;
1547
- for (; ; ) {
1548
- try {
1549
- return await resource.get({ tripRef, ...signal !== void 0 ? { signal } : {} });
1550
- } catch (error) {
1551
- if (!(error instanceof KaafilNotFoundError)) {
1552
- throw error;
1553
- }
1554
- const remainingMs = deadlineAt - Date.now();
1555
- if (remainingMs <= 0) {
1556
- throw new KaafilTimeoutError(
1557
- `journey.waitUntilReady timed out after ${String(timeoutMs)}ms waiting for trip "${tripRef}" to become ready. The most likely cause is that the background worker that consumes the build queue is not running against this engine.`,
1558
- { cause: error }
1559
- );
1560
- }
1561
- try {
1562
- await delayWithAbort(Math.min(pollIntervalMs, remainingMs), signal);
1563
- } catch (sleepError) {
1564
- throw new KaafilAbortError("Request aborted", { cause: sleepError });
1565
- }
1899
+ async drain() {
1900
+ let confirmed = 0;
1901
+ let parked = 0;
1902
+ const at = now();
1903
+ for (const record of [...blobs.values()]) {
1904
+ if (record.status !== BlobStatus.Pending) {
1905
+ continue;
1906
+ }
1907
+ if (record.nextRetryAt !== null && record.nextRetryAt > at) {
1908
+ continue;
1909
+ }
1910
+ const outcome = await driveOne(record);
1911
+ if (outcome === "confirmed") {
1912
+ confirmed += 1;
1913
+ } else if (outcome === "parked") {
1914
+ parked += 1;
1566
1915
  }
1567
1916
  }
1568
- },
1569
- triggers: {
1570
- async list(options) {
1571
- const { agencyRef, signal } = options;
1572
- return client.execute({
1573
- method: "GET",
1574
- operationId: OperationId.ListJourneyTriggers,
1575
- path: "/api/v1/agencies/{ref}/journey-triggers",
1576
- pathParams: { ref: agencyRef },
1577
- ...signal !== void 0 ? { signal } : {}
1578
- });
1579
- },
1580
- async patch(options) {
1581
- const { agencyRef, key, version, idempotencyKey, signal, ...body } = options;
1582
- return client.execute({
1583
- method: "PATCH",
1584
- operationId: OperationId.PatchJourneyTrigger,
1585
- path: "/api/v1/agencies/{ref}/journey-triggers/{key}",
1586
- pathParams: { ref: agencyRef, key },
1587
- body,
1588
- headers: { "If-Match": String(version) },
1589
- ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
1590
- ...signal !== void 0 ? { signal } : {}
1591
- });
1917
+ let pending = 0;
1918
+ for (const record of blobs.values()) {
1919
+ if (record.status === BlobStatus.Pending) {
1920
+ pending += 1;
1921
+ }
1592
1922
  }
1923
+ return { confirmed, parked, pending };
1924
+ },
1925
+ all() {
1926
+ return [...blobs.values()];
1593
1927
  }
1594
1928
  };
1595
- return resource;
1596
1929
  }
1597
1930
 
1598
- // src/resources/notifications.ts
1599
- function createNotificationsResource(client) {
1931
+ // src/offline/outbox.ts
1932
+ var OutboxStatus = {
1933
+ /** Waiting to be sent, or waiting out a backoff rung. */
1934
+ Pending: "pending",
1935
+ /** Handed to the transport; not yet answered. */
1936
+ Inflight: "inflight",
1937
+ /** Terminal failure. Out of the FIFO ordering; surfaced to the user. */
1938
+ Parked: "parked",
1939
+ /** Terminal success. Pruned on the next persist. */
1940
+ Done: "done"
1941
+ };
1942
+ var OutboxRetryCause = {
1943
+ Transport: "transport",
1944
+ Server: "server"
1945
+ };
1946
+ function createOutbox(options) {
1947
+ const key = `${options.keyPrefix}:outbox`;
1948
+ const mintId = options.newId ?? newIdempotencyKey;
1949
+ let ops = /* @__PURE__ */ new Map();
1950
+ let seq = 0;
1951
+ function ordered() {
1952
+ return [...ops.values()].sort((a, b) => a.seq - b.seq);
1953
+ }
1954
+ async function persist() {
1955
+ for (const [id, op] of [...ops]) {
1956
+ if (op.status === OutboxStatus.Done) {
1957
+ ops.delete(id);
1958
+ }
1959
+ }
1960
+ const shape = { seq, ops: ordered() };
1961
+ await options.storage.set(key, JSON.stringify(shape));
1962
+ }
1963
+ async function mutate(opId, patch) {
1964
+ const op = ops.get(opId);
1965
+ if (op === void 0) {
1966
+ return;
1967
+ }
1968
+ ops.set(opId, { ...op, ...patch });
1969
+ await persist();
1970
+ }
1600
1971
  return {
1601
- async list(options = {}) {
1602
- const { since, signal } = options;
1603
- return client.execute({
1604
- method: "GET",
1605
- operationId: OperationId.ListManagerNotifications,
1606
- path: "/api/v1/managers/me/notifications",
1607
- ...since !== void 0 ? { query: { since } } : {},
1608
- ...signal !== void 0 ? { signal } : {}
1972
+ async load() {
1973
+ ops = /* @__PURE__ */ new Map();
1974
+ seq = 0;
1975
+ const raw = await options.storage.get(key);
1976
+ if (raw === void 0) {
1977
+ return;
1978
+ }
1979
+ let parsed;
1980
+ try {
1981
+ parsed = JSON.parse(raw);
1982
+ } catch {
1983
+ return;
1984
+ }
1985
+ seq = typeof parsed.seq === "number" ? parsed.seq : 0;
1986
+ for (const op of parsed.ops ?? []) {
1987
+ ops.set(op.id, {
1988
+ ...op,
1989
+ status: op.status === OutboxStatus.Inflight ? OutboxStatus.Pending : op.status
1990
+ });
1991
+ }
1992
+ },
1993
+ async enqueue(input) {
1994
+ seq += 1;
1995
+ const op = {
1996
+ id: mintId(),
1997
+ seq,
1998
+ tripRef: input.tripRef,
1999
+ method: input.method,
2000
+ path: input.path,
2001
+ operationId: input.operationId,
2002
+ body: input.body,
2003
+ ifMatch: input.ifMatch,
2004
+ entity: input.entity,
2005
+ idempotencyKey: input.idempotencyKey ?? newIdempotencyKey(),
2006
+ enqueuedAt: input.enqueuedAt,
2007
+ receiptPending: input.receiptPending === true,
2008
+ blobId: input.blobId,
2009
+ status: OutboxStatus.Pending,
2010
+ attemptCount: 0,
2011
+ nextRetryAt: null,
2012
+ retryCause: void 0,
2013
+ refreshAttempted: false,
2014
+ parkReason: void 0
2015
+ };
2016
+ ops.set(op.id, op);
2017
+ await persist();
2018
+ return op;
2019
+ },
2020
+ get(opId) {
2021
+ return ops.get(opId);
2022
+ },
2023
+ all() {
2024
+ return ordered();
2025
+ },
2026
+ lanes() {
2027
+ const seen = /* @__PURE__ */ new Set();
2028
+ for (const op of ops.values()) {
2029
+ if (op.status === OutboxStatus.Pending) {
2030
+ seen.add(op.tripRef);
2031
+ }
2032
+ }
2033
+ return [...seen];
2034
+ },
2035
+ head(tripRef) {
2036
+ return ordered().find((op) => op.tripRef === tripRef && op.status === OutboxStatus.Pending);
2037
+ },
2038
+ readyPrefix(tripRef, at, limit) {
2039
+ const out = [];
2040
+ for (const op of ordered()) {
2041
+ if (op.tripRef !== tripRef || op.status !== OutboxStatus.Pending) {
2042
+ continue;
2043
+ }
2044
+ if (op.nextRetryAt !== null && op.nextRetryAt > at) {
2045
+ break;
2046
+ }
2047
+ out.push(op);
2048
+ if (out.length >= limit) {
2049
+ break;
2050
+ }
2051
+ }
2052
+ return out;
2053
+ },
2054
+ async markInflight(opId) {
2055
+ await mutate(opId, { status: OutboxStatus.Inflight });
2056
+ },
2057
+ async markDone(opId) {
2058
+ await mutate(opId, { status: OutboxStatus.Done });
2059
+ },
2060
+ async park(opId, reason) {
2061
+ const op = ops.get(opId);
2062
+ await mutate(opId, {
2063
+ status: OutboxStatus.Parked,
2064
+ parkReason: reason,
2065
+ attemptCount: (op?.attemptCount ?? 0) + 1,
2066
+ nextRetryAt: null,
2067
+ retryCause: void 0
2068
+ });
2069
+ },
2070
+ async scheduleRetry(opId, nextRetryAt, cause) {
2071
+ const op = ops.get(opId);
2072
+ await mutate(opId, {
2073
+ status: OutboxStatus.Pending,
2074
+ attemptCount: (op?.attemptCount ?? 0) + 1,
2075
+ nextRetryAt,
2076
+ retryCause: cause
2077
+ });
2078
+ },
2079
+ async clearTransportBackoff() {
2080
+ let cleared = 0;
2081
+ for (const [id, op] of ops) {
2082
+ if (op.status !== OutboxStatus.Pending || op.nextRetryAt === null || op.retryCause !== OutboxRetryCause.Transport) {
2083
+ continue;
2084
+ }
2085
+ ops.set(id, { ...op, nextRetryAt: null, retryCause: void 0 });
2086
+ cleared += 1;
2087
+ }
2088
+ if (cleared > 0) {
2089
+ await persist();
2090
+ }
2091
+ return cleared;
2092
+ },
2093
+ async requeue(opId) {
2094
+ await mutate(opId, {
2095
+ status: OutboxStatus.Pending,
2096
+ nextRetryAt: null,
2097
+ retryCause: void 0
2098
+ });
2099
+ },
2100
+ async markRefreshAttempted(opId) {
2101
+ await mutate(opId, { refreshAttempted: true });
2102
+ },
2103
+ async reissue(opId, patch) {
2104
+ const op = ops.get(opId);
2105
+ if (op === void 0) {
2106
+ return;
2107
+ }
2108
+ ops.set(opId, {
2109
+ ...op,
2110
+ status: OutboxStatus.Pending,
2111
+ nextRetryAt: null,
2112
+ retryCause: void 0,
2113
+ attemptCount: op.attemptCount + 1,
2114
+ ...patch.body !== void 0 ? { body: patch.body } : {},
2115
+ ...patch.ifMatch !== void 0 ? { ifMatch: patch.ifMatch } : {}
1609
2116
  });
2117
+ await persist();
2118
+ },
2119
+ async drop(opId) {
2120
+ if (!ops.delete(opId)) {
2121
+ return;
2122
+ }
2123
+ await persist();
2124
+ },
2125
+ counts() {
2126
+ let pending = 0;
2127
+ let inflight = 0;
2128
+ let parked = 0;
2129
+ for (const op of ops.values()) {
2130
+ if (op.status === OutboxStatus.Pending) {
2131
+ pending += 1;
2132
+ } else if (op.status === OutboxStatus.Inflight) {
2133
+ inflight += 1;
2134
+ } else if (op.status === OutboxStatus.Parked) {
2135
+ parked += 1;
2136
+ }
2137
+ }
2138
+ return { pending, inflight, parked };
1610
2139
  }
1611
2140
  };
1612
2141
  }
1613
2142
 
1614
- // src/resources/share.ts
1615
- function createShareResource(client) {
1616
- return {
1617
- async snapshot(options) {
1618
- const { token, signal } = options;
1619
- return client.execute({
1620
- method: "GET",
1621
- operationId: OperationId.GetShareSnapshot,
1622
- path: "/api/v1/share/{token}",
1623
- pathParams: { token },
1624
- ...signal !== void 0 ? { signal } : {}
2143
+ // src/offline/reconcile.ts
2144
+ function readCurrentVersion(details) {
2145
+ const value = details?.currentVersion;
2146
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
2147
+ }
2148
+ async function reconcileConflict(args) {
2149
+ const { op, transport, snapshot, resolver } = args;
2150
+ const currentVersion = readCurrentVersion(args.details);
2151
+ let current;
2152
+ if (op.entity !== void 0 && transport.readEntity !== void 0) {
2153
+ let read;
2154
+ try {
2155
+ read = await transport.readEntity({
2156
+ tripRef: op.tripRef,
2157
+ listName: op.entity.listName,
2158
+ id: op.entity.id
1625
2159
  });
1626
- },
1627
- async manifest(options) {
1628
- const { token, signal } = options;
1629
- return client.execute({
1630
- method: "GET",
1631
- operationId: OperationId.GetShareManifest,
1632
- path: "/api/v1/share/{token}/manifest",
1633
- pathParams: { token },
1634
- ...signal !== void 0 ? { signal } : {}
2160
+ } catch {
2161
+ return { action: "deferred", body: void 0, currentVersion, current: void 0 };
2162
+ }
2163
+ if (read.status === 200 && read.entity !== void 0) {
2164
+ current = read.entity;
2165
+ await snapshot.upsert({
2166
+ tripRef: op.tripRef,
2167
+ listName: op.entity.listName,
2168
+ row: read.entity
1635
2169
  });
1636
- },
1637
- forms: {
1638
- async list(options) {
1639
- const { token, signal } = options;
1640
- return client.execute({
2170
+ }
2171
+ }
2172
+ const context = { op, currentVersion, current };
2173
+ const resolution = resolver === void 0 ? { action: "surface" } : await resolver(context);
2174
+ return {
2175
+ action: resolution.action,
2176
+ body: resolution.action === "reissue" ? resolution.body : void 0,
2177
+ currentVersion,
2178
+ current
2179
+ };
2180
+ }
2181
+
2182
+ // src/offline/transport.ts
2183
+ var BATCH_THRESHOLD_OPS = 5;
2184
+ var MAX_BATCH_OPS = 200;
2185
+ var CONSOLIDATED_PULL_THRESHOLD_LISTS = 3;
2186
+ function shouldUseBatchTransport(args) {
2187
+ return args.transport.sendBatch !== void 0 && args.readyCount >= BATCH_THRESHOLD_OPS;
2188
+ }
2189
+
2190
+ // src/offline/drainer.ts
2191
+ function userMessageFor(outcome) {
2192
+ if (outcome.code === "LOCKED" || outcome.status === 423) {
2193
+ return "This trip has been closed out, so this change was not saved.";
2194
+ }
2195
+ if (outcome.code === "FILE_PURGED" || outcome.status === 410) {
2196
+ return "That file is no longer available \u2014 its retention period has ended.";
2197
+ }
2198
+ if (outcome.code === "PLAN_FEATURE_DISABLED" || outcome.status === 402) {
2199
+ return "That feature is not included in this plan, so this change was not saved.";
2200
+ }
2201
+ if (outcome.code === "SHARE_WRITE_GRACE_EXPIRED") {
2202
+ return "This link expired \u2014 your submission was not delivered.";
2203
+ }
2204
+ if (outcome.status === 404) {
2205
+ return "That item is no longer available to you.";
2206
+ }
2207
+ if (outcome.status === 401) {
2208
+ return "Your session expired, so this change was not saved. Sign in again.";
2209
+ }
2210
+ return "This change could not be saved.";
2211
+ }
2212
+ function createDrainer(options) {
2213
+ const { outbox, snapshot, transport, events } = options;
2214
+ const now = options.now ?? Date.now;
2215
+ const random = options.random ?? Math.random;
2216
+ let inFlight = null;
2217
+ const ownSignal = new AbortController();
2218
+ function observeServerTime(outcome) {
2219
+ if (outcome.serverTime !== void 0) {
2220
+ options.onServerTime?.(outcome.serverTime);
2221
+ }
2222
+ }
2223
+ async function applySuccess(op, outcome, state) {
2224
+ if (op.entity !== void 0 && outcome.entity !== void 0) {
2225
+ await snapshot.upsert({
2226
+ tripRef: op.tripRef,
2227
+ listName: op.entity.listName,
2228
+ row: outcome.entity,
2229
+ ...outcome.serverTime !== void 0 ? { syncedAt: outcome.serverTime } : {}
2230
+ });
2231
+ }
2232
+ await outbox.markDone(op.id);
2233
+ state.applied += 1;
2234
+ }
2235
+ async function park(op, outcome, state) {
2236
+ const message = userMessageFor(outcome);
2237
+ await outbox.park(op.id, {
2238
+ status: outcome.status,
2239
+ code: outcome.code,
2240
+ userMessage: message
2241
+ });
2242
+ state.parked += 1;
2243
+ events.emit("sync.error", {
2244
+ opId: op.id,
2245
+ tripRef: op.tripRef,
2246
+ error: outcome.error,
2247
+ status: outcome.status,
2248
+ parked: true,
2249
+ userMessage: message
2250
+ });
2251
+ }
2252
+ async function purgeIfCached(op, outcome) {
2253
+ if (op.entity === void 0) {
2254
+ return;
2255
+ }
2256
+ const held = snapshot.list(op.tripRef, op.entity.listName).some((row) => row.id === op.entity?.id);
2257
+ if (!held) {
2258
+ return;
2259
+ }
2260
+ if (outcome.status === 404 || outcome.status === 410) {
2261
+ await snapshot.purgeEntity(op.tripRef, op.entity.listName, op.entity.id);
2262
+ }
2263
+ }
2264
+ async function applyOutcome(op, outcome, state) {
2265
+ observeServerTime(outcome);
2266
+ if (outcome.status !== null && outcome.status >= 200 && outcome.status < 300) {
2267
+ await applySuccess(op, outcome, state);
2268
+ return "terminal";
2269
+ }
2270
+ if (outcome.status === 401 && !op.refreshAttempted) {
2271
+ await outbox.markRefreshAttempted(op.id);
2272
+ let refreshed = false;
2273
+ try {
2274
+ refreshed = await transport.refreshSession?.() === true;
2275
+ } catch {
2276
+ refreshed = false;
2277
+ }
2278
+ if (refreshed) {
2279
+ await outbox.requeue(op.id);
2280
+ return "pending";
2281
+ }
2282
+ events.emit("session.expired", { reason: "refresh-failed" });
2283
+ await park(op, outcome, state);
2284
+ return "terminal";
2285
+ }
2286
+ const verdict = classifyFailure({
2287
+ status: outcome.status,
2288
+ ...outcome.code !== void 0 ? { code: outcome.code } : {},
2289
+ ...outcome.transportFailureKind !== void 0 ? { transportFailureKind: outcome.transportFailureKind } : {}
2290
+ });
2291
+ if (verdict === "transient") {
2292
+ const delay = computeRetryDelayMs(op.attemptCount + 1, {
2293
+ ...outcome.retryAfterSeconds !== void 0 ? { retryAfterSeconds: outcome.retryAfterSeconds } : {},
2294
+ random
2295
+ });
2296
+ await outbox.scheduleRetry(
2297
+ op.id,
2298
+ now() + delay,
2299
+ outcome.status === null ? OutboxRetryCause.Transport : OutboxRetryCause.Server
2300
+ );
2301
+ events.emit("sync.error", {
2302
+ opId: op.id,
2303
+ tripRef: op.tripRef,
2304
+ error: outcome.error,
2305
+ status: outcome.status,
2306
+ parked: false
2307
+ });
2308
+ return "pending";
2309
+ }
2310
+ if (verdict === "conflict") {
2311
+ state.conflicted += 1;
2312
+ const result = await reconcileConflict({
2313
+ op,
2314
+ details: outcome.details,
2315
+ transport,
2316
+ snapshot,
2317
+ resolver: options.conflictResolver
2318
+ });
2319
+ switch (result.action) {
2320
+ case "drop":
2321
+ await outbox.drop(op.id);
2322
+ return "terminal";
2323
+ case "reissue":
2324
+ await outbox.reissue(op.id, {
2325
+ ...result.body !== void 0 ? { body: result.body } : {},
2326
+ ...result.currentVersion !== void 0 ? { ifMatch: result.currentVersion } : {}
2327
+ });
2328
+ return "pending";
2329
+ case "deferred":
2330
+ await outbox.requeue(op.id);
2331
+ return "pending";
2332
+ case "surface":
2333
+ await park(op, outcome, state);
2334
+ return "terminal";
2335
+ }
2336
+ }
2337
+ await purgeIfCached(op, outcome);
2338
+ await park(op, outcome, state);
2339
+ return "terminal";
2340
+ }
2341
+ async function drainLane(tripRef, state, signal) {
2342
+ for (; ; ) {
2343
+ if (signal?.aborted === true) {
2344
+ return;
2345
+ }
2346
+ const head = outbox.head(tripRef);
2347
+ if (head === void 0) {
2348
+ return;
2349
+ }
2350
+ if (head.nextRetryAt !== null && head.nextRetryAt > now()) {
2351
+ return;
2352
+ }
2353
+ const ready = outbox.readyPrefix(tripRef, now(), MAX_BATCH_OPS);
2354
+ if (ready.length === 0) {
2355
+ return;
2356
+ }
2357
+ if (shouldUseBatchTransport({ transport, readyCount: ready.length })) {
2358
+ state.usedBatch = true;
2359
+ const sent = await sendBatchedPrefix(ready, state, signal);
2360
+ if (!sent) {
2361
+ return;
2362
+ }
2363
+ continue;
2364
+ }
2365
+ await outbox.markInflight(head.id);
2366
+ let outcome;
2367
+ try {
2368
+ outcome = await transport.sendOne(head, signal);
2369
+ } catch (error) {
2370
+ outcome = {
2371
+ status: null,
2372
+ transportFailureKind: "network",
2373
+ ...isKaafilLike(error) ? { error } : {}
2374
+ };
2375
+ }
2376
+ const disposition = await applyOutcome(head, outcome, state);
2377
+ if (disposition === "pending") {
2378
+ const again = outbox.get(head.id);
2379
+ if (again !== void 0 && again.nextRetryAt !== null && again.nextRetryAt > now()) {
2380
+ return;
2381
+ }
2382
+ }
2383
+ }
2384
+ }
2385
+ async function sendBatchedPrefix(ready, state, signal) {
2386
+ const sendBatch = transport.sendBatch;
2387
+ if (sendBatch === void 0) {
2388
+ return false;
2389
+ }
2390
+ for (const op of ready) {
2391
+ await outbox.markInflight(op.id);
2392
+ }
2393
+ let outcomes;
2394
+ try {
2395
+ outcomes = await sendBatch(ready, signal);
2396
+ } catch (error) {
2397
+ const cause = isKaafilLike(error) && error.kind === "transport" ? OutboxRetryCause.Transport : OutboxRetryCause.Server;
2398
+ const [head, ...rest] = ready;
2399
+ if (head !== void 0) {
2400
+ await outbox.scheduleRetry(
2401
+ head.id,
2402
+ now() + computeRetryDelayMs(head.attemptCount + 1, { random }),
2403
+ cause
2404
+ );
2405
+ }
2406
+ for (const op of rest) {
2407
+ await outbox.requeue(op.id);
2408
+ }
2409
+ return false;
2410
+ }
2411
+ let halted = false;
2412
+ for (let index = 0; index < ready.length; index += 1) {
2413
+ const op = ready[index];
2414
+ if (op === void 0) {
2415
+ continue;
2416
+ }
2417
+ if (halted) {
2418
+ await outbox.requeue(op.id);
2419
+ continue;
2420
+ }
2421
+ const outcome = outcomes[index];
2422
+ if (outcome === void 0) {
2423
+ await outbox.requeue(op.id);
2424
+ halted = true;
2425
+ continue;
2426
+ }
2427
+ const disposition = await applyOutcome(op, outcome, state);
2428
+ if (disposition === "pending") {
2429
+ halted = true;
2430
+ }
2431
+ }
2432
+ return !halted;
2433
+ }
2434
+ async function runPass(signal) {
2435
+ const state = { applied: 0, parked: 0, conflicted: 0, usedBatch: false };
2436
+ const lanes = outbox.lanes();
2437
+ await Promise.all(lanes.map((tripRef) => drainLane(tripRef, state, signal)));
2438
+ const report = {
2439
+ applied: state.applied,
2440
+ parked: state.parked,
2441
+ conflicted: state.conflicted,
2442
+ remaining: outbox.counts().pending,
2443
+ usedBatchTransport: state.usedBatch,
2444
+ lanes
2445
+ };
2446
+ events.emit("sync.drained", {
2447
+ applied: report.applied,
2448
+ parked: report.parked,
2449
+ conflicted: report.conflicted,
2450
+ remaining: report.remaining,
2451
+ usedBatchTransport: report.usedBatchTransport
2452
+ });
2453
+ return report;
2454
+ }
2455
+ let kickTimer;
2456
+ let pendingKickRestored = false;
2457
+ const drainer = {
2458
+ async drain(drainOptions = {}) {
2459
+ if (inFlight !== null) {
2460
+ return inFlight;
2461
+ }
2462
+ const signal = drainOptions.signal ?? ownSignal.signal;
2463
+ const pass = (async () => {
2464
+ if (drainOptions.connectivityRestored === true) {
2465
+ await outbox.clearTransportBackoff();
2466
+ }
2467
+ return runPass(signal);
2468
+ })().finally(() => {
2469
+ inFlight = null;
2470
+ });
2471
+ inFlight = pass;
2472
+ return pass;
2473
+ },
2474
+ // Deferred to a fresh macrotask, on purpose. `enqueue()` calls this after
2475
+ // EVERY write, and a caller enqueueing several writes in a row (a batch
2476
+ // import, this SDK's own offline smoke test, `06`'s worked example) does
2477
+ // so as a sequence of awaited calls with no real I/O between them —
2478
+ // which means their continuations are all still microtasks. A `kick()`
2479
+ // that started draining synchronously would mark the FIRST op of the
2480
+ // burst `inflight` before the caller's loop even reaches its second
2481
+ // iteration, so `outbox.counts().pending` would under-report a queue
2482
+ // that is, in fact, completely durable (`./outbox.ts`'s promise is about
2483
+ // durability, not about `pending` never dipping). Parking the kick
2484
+ // behind a macrotask lets the whole synchronous burst finish enqueueing
2485
+ // — and, for a real UI, the current paint — before the drain takes its
2486
+ // first op off the pending list. Nothing about durability changes: the
2487
+ // write-ahead persist in `enqueue()` already happened before this method
2488
+ // is even called.
2489
+ kick(kickOptions = {}) {
2490
+ if (kickTimer !== void 0) {
2491
+ pendingKickRestored = pendingKickRestored || kickOptions.connectivityRestored === true;
2492
+ return;
2493
+ }
2494
+ pendingKickRestored = kickOptions.connectivityRestored === true;
2495
+ kickTimer = setTimeout(() => {
2496
+ kickTimer = void 0;
2497
+ const restored = pendingKickRestored;
2498
+ pendingKickRestored = false;
2499
+ void drainer.drain({ connectivityRestored: restored }).catch(() => {
2500
+ });
2501
+ }, 0);
2502
+ },
2503
+ // Called only from `OfflineEngine.close()` (`./engine.ts`). Two separate
2504
+ // handles, both cleared: a `kick()` that is scheduled but has not fired
2505
+ // yet (the `setTimeout` itself), and a pass already running under
2506
+ // `ownSignal` — which, per `drain()` above, is every automatic kick and
2507
+ // any signal-less explicit call. Aborting propagates into
2508
+ // `transport.sendOne`/`sendBatch` and from there into
2509
+ // `../http/client.ts`'s own retry ladder, which is otherwise the one
2510
+ // thing nothing here could ever cut short.
2511
+ cancelKick() {
2512
+ if (kickTimer !== void 0) {
2513
+ clearTimeout(kickTimer);
2514
+ kickTimer = void 0;
2515
+ }
2516
+ ownSignal.abort();
2517
+ },
2518
+ bindOpportunisticTriggers() {
2519
+ const target = typeof globalThis.addEventListener === "function" ? globalThis : void 0;
2520
+ if (target === void 0) {
2521
+ return () => {
2522
+ };
2523
+ }
2524
+ const onOnline = () => {
2525
+ drainer.kick({ connectivityRestored: true });
2526
+ };
2527
+ const onVisible = () => {
2528
+ const state = globalThis.document?.visibilityState;
2529
+ if (state === void 0 || state === "visible") {
2530
+ drainer.kick();
2531
+ }
2532
+ };
2533
+ target.addEventListener("online", onOnline);
2534
+ target.addEventListener("visibilitychange", onVisible);
2535
+ target.addEventListener("focus", onVisible);
2536
+ return () => {
2537
+ target.removeEventListener("online", onOnline);
2538
+ target.removeEventListener("visibilitychange", onVisible);
2539
+ target.removeEventListener("focus", onVisible);
2540
+ };
2541
+ }
2542
+ };
2543
+ return drainer;
2544
+ }
2545
+ function isKaafilLike(error) {
2546
+ return typeof error === "object" && error !== null && "kind" in error && error instanceof Error;
2547
+ }
2548
+
2549
+ // src/offline/events.ts
2550
+ function createOfflineEvents(options = {}) {
2551
+ const handlers = /* @__PURE__ */ new Map();
2552
+ return {
2553
+ on(name, handler) {
2554
+ let set = handlers.get(name);
2555
+ if (set === void 0) {
2556
+ set = /* @__PURE__ */ new Set();
2557
+ handlers.set(name, set);
2558
+ }
2559
+ set.add(handler);
2560
+ let removed = false;
2561
+ return () => {
2562
+ if (removed) {
2563
+ return;
2564
+ }
2565
+ removed = true;
2566
+ set?.delete(handler);
2567
+ };
2568
+ },
2569
+ emit(name, event) {
2570
+ const set = handlers.get(name);
2571
+ if (set === void 0) {
2572
+ return;
2573
+ }
2574
+ for (const handler of [...set]) {
2575
+ try {
2576
+ handler(event);
2577
+ } catch (error) {
2578
+ options.onHandlerError?.(error, name);
2579
+ }
2580
+ }
2581
+ },
2582
+ clear() {
2583
+ handlers.clear();
2584
+ }
2585
+ };
2586
+ }
2587
+
2588
+ // src/offline/pull.ts
2589
+ var SYNC_PULL_SECTIONS = [
2590
+ "rooming",
2591
+ "stayWindows",
2592
+ "pickups",
2593
+ "seating",
2594
+ "bookings",
2595
+ "expenses",
2596
+ "checklist",
2597
+ "float",
2598
+ "collections",
2599
+ "itinerary",
2600
+ "closeout"
2601
+ ];
2602
+ function extractSectionRows(data) {
2603
+ if (Array.isArray(data)) {
2604
+ return isRowArray(data) ? data : void 0;
2605
+ }
2606
+ if (typeof data !== "object" || data === null) {
2607
+ return void 0;
2608
+ }
2609
+ let found;
2610
+ for (const value of Object.values(data)) {
2611
+ if (!Array.isArray(value) || !isRowArray(value)) {
2612
+ continue;
2613
+ }
2614
+ if (found !== void 0) {
2615
+ return void 0;
2616
+ }
2617
+ found = value;
2618
+ }
2619
+ return found;
2620
+ }
2621
+ function isRowArray(value) {
2622
+ return value.every(
2623
+ (item) => typeof item === "object" && item !== null && typeof item.id === "string"
2624
+ );
2625
+ }
2626
+ function createPullCoordinator(options) {
2627
+ const { snapshot, transport, events } = options;
2628
+ function sinceFor(tripRef) {
2629
+ const known = snapshot.listNames(tripRef).filter(
2630
+ (name) => SYNC_PULL_SECTIONS.includes(name)
2631
+ );
2632
+ if (known.length === 0) {
2633
+ return void 0;
2634
+ }
2635
+ let min;
2636
+ for (const name of known) {
2637
+ const cursor = snapshot.cursor(tripRef, name);
2638
+ if (cursor === void 0) {
2639
+ return void 0;
2640
+ }
2641
+ if (min === void 0 || cursor < min) {
2642
+ min = cursor;
2643
+ }
2644
+ }
2645
+ return min;
2646
+ }
2647
+ async function applyOnce(tripRef, since, signal) {
2648
+ const pullTripFn = transport.pullTrip;
2649
+ if (pullTripFn === void 0) {
2650
+ throw new TypeError(
2651
+ "This offline engine was built without a consolidated-pull transport, so pullTrip() has nothing to call. Supply OfflineTransport.pullTrip."
2652
+ );
2653
+ }
2654
+ const response = await pullTripFn({
2655
+ tripRef,
2656
+ since,
2657
+ ...signal !== void 0 ? { signal } : {}
2658
+ });
2659
+ const serverTime = response.serverTime;
2660
+ options.onServerTime?.(serverTime);
2661
+ const present = [];
2662
+ const absent = [];
2663
+ const unmapped = [];
2664
+ const changed = [];
2665
+ let coldRepullNeeded = false;
2666
+ for (const name of SYNC_PULL_SECTIONS) {
2667
+ const section = response.sections[name];
2668
+ if (section === void 0) {
2669
+ absent.push(name);
2670
+ continue;
2671
+ }
2672
+ const rows = extractSectionRows(section.data);
2673
+ if (rows === void 0) {
2674
+ unmapped.push(name);
2675
+ continue;
2676
+ }
2677
+ present.push(name);
2678
+ const hadCursor = snapshot.cursor(tripRef, name) !== void 0;
2679
+ if (!hadCursor && since !== void 0) {
2680
+ coldRepullNeeded = true;
2681
+ }
2682
+ const applied = await snapshot.applyPull({ tripRef, listName: name, rows, serverTime });
2683
+ if (applied.changed) {
2684
+ changed.push(name);
2685
+ }
2686
+ }
2687
+ if (changed.length > 0) {
2688
+ events.emit("snapshot.updated", { tripRef, lists: changed, serverTime });
2689
+ }
2690
+ return {
2691
+ result: { tripRef, serverTime, present, absent, unmapped, changed, coldRepulled: false },
2692
+ coldRepullNeeded
2693
+ };
2694
+ }
2695
+ return {
2696
+ sinceFor,
2697
+ async pullTrip({ tripRef, signal, cold }) {
2698
+ const since = cold === true ? void 0 : sinceFor(tripRef);
2699
+ const first = await applyOnce(tripRef, since, signal);
2700
+ if (!first.coldRepullNeeded) {
2701
+ return first.result;
2702
+ }
2703
+ const second = await applyOnce(tripRef, void 0, signal);
2704
+ return { ...second.result, coldRepulled: true };
2705
+ }
2706
+ };
2707
+ }
2708
+
2709
+ // src/offline/share.ts
2710
+ var SHARE_WRITE_GRACE_MS = 7 * 24 * 60 * 60 * 1e3;
2711
+ var KaafilShareLinkExpiredError = class _KaafilShareLinkExpiredError extends Error {
2712
+ constructor() {
2713
+ super("This link has expired, so it can no longer be used to view or submit anything.");
2714
+ this.name = "KaafilShareLinkExpiredError";
2715
+ Object.setPrototypeOf(this, _KaafilShareLinkExpiredError.prototype);
2716
+ }
2717
+ };
2718
+ function defaultMonotonicClock() {
2719
+ const performanceNow = globalThis.performance?.now;
2720
+ if (typeof performanceNow === "function") {
2721
+ return () => performanceNow.call(globalThis.performance);
2722
+ }
2723
+ let ticks = 0;
2724
+ return () => {
2725
+ ticks += 1;
2726
+ return ticks;
2727
+ };
2728
+ }
2729
+ function createShareGuard(options) {
2730
+ const monotonic = options.monotonic ?? defaultMonotonicClock();
2731
+ const expiresAtMs = Date.parse(options.expiresAt);
2732
+ let anchor;
2733
+ function estimateNow() {
2734
+ if (anchor === void 0) {
2735
+ return void 0;
2736
+ }
2737
+ return anchor.serverMs + Math.max(0, monotonic() - anchor.monotonicMs);
2738
+ }
2739
+ const guard = {
2740
+ observeServerTime(serverTime) {
2741
+ const parsed = Date.parse(serverTime);
2742
+ if (Number.isNaN(parsed)) {
2743
+ return;
2744
+ }
2745
+ if (anchor !== void 0 && parsed <= anchor.serverMs) {
2746
+ return;
2747
+ }
2748
+ anchor = { serverMs: parsed, monotonicMs: monotonic() };
2749
+ },
2750
+ now() {
2751
+ return estimateNow();
2752
+ },
2753
+ isExpired() {
2754
+ const at = estimateNow();
2755
+ if (at === void 0 || Number.isNaN(expiresAtMs)) {
2756
+ return false;
2757
+ }
2758
+ return at >= expiresAtMs;
2759
+ },
2760
+ isGraceClosed() {
2761
+ const at = estimateNow();
2762
+ if (at === void 0 || Number.isNaN(expiresAtMs)) {
2763
+ return false;
2764
+ }
2765
+ return at >= expiresAtMs + SHARE_WRITE_GRACE_MS;
2766
+ },
2767
+ assertWritable() {
2768
+ if (guard.isExpired()) {
2769
+ throw new KaafilShareLinkExpiredError();
2770
+ }
2771
+ },
2772
+ async invalidate(reason, code) {
2773
+ await options.snapshot.purgeTrip(options.tripRef);
2774
+ const preserved = options.outbox.counts().pending;
2775
+ const payload = {
2776
+ code: code === KaafilErrorCode.ShareTokenExpired || code === KaafilErrorCode.ShareTokenRevoked ? code : void 0,
2777
+ snapshotPurged: true,
2778
+ pendingOpsPreserved: preserved
2779
+ };
2780
+ options.events.emit(reason === "expired" ? "share.expired" : "share.revoked", payload);
2781
+ },
2782
+ async applyPreflight(result) {
2783
+ if (result.code === KaafilErrorCode.ShareTokenRevoked) {
2784
+ await guard.invalidate("revoked", result.code);
2785
+ return "revoked";
2786
+ }
2787
+ if (result.code === KaafilErrorCode.ShareTokenExpired) {
2788
+ await guard.invalidate("expired", result.code);
2789
+ return "expired";
2790
+ }
2791
+ return "valid";
2792
+ },
2793
+ async parkOpsPastGrace() {
2794
+ if (!guard.isGraceClosed()) {
2795
+ return 0;
2796
+ }
2797
+ let parked = 0;
2798
+ for (const op of options.outbox.all()) {
2799
+ if (op.status !== "pending") {
2800
+ continue;
2801
+ }
2802
+ await options.outbox.park(op.id, {
2803
+ status: null,
2804
+ code: KaafilErrorCode.ShareWriteGraceExpired,
2805
+ userMessage: "This link expired \u2014 your submission was not delivered."
2806
+ });
2807
+ parked += 1;
2808
+ options.events.emit("sync.error", {
2809
+ opId: op.id,
2810
+ tripRef: op.tripRef,
2811
+ error: void 0,
2812
+ status: null,
2813
+ parked: true,
2814
+ userMessage: "This link expired \u2014 your submission was not delivered."
2815
+ });
2816
+ }
2817
+ return parked;
2818
+ }
2819
+ };
2820
+ return guard;
2821
+ }
2822
+
2823
+ // src/datetime.ts
2824
+ var FULL_DATETIME_WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
2825
+ var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
2826
+ function invalidRequest(fieldPath, message) {
2827
+ return new KaafilInvalidRequestError(`${fieldPath}: ${message}`);
2828
+ }
2829
+ function normalizeDateTimeInput(value, fieldPath) {
2830
+ if (value instanceof Date) {
2831
+ if (Number.isNaN(value.getTime())) {
2832
+ throw invalidRequest(fieldPath, "received an invalid Date (getTime() is NaN).");
2833
+ }
2834
+ return value.toISOString();
2835
+ }
2836
+ if (typeof value === "number") {
2837
+ if (!Number.isFinite(value)) {
2838
+ throw invalidRequest(
2839
+ fieldPath,
2840
+ `received a non-finite number (${String(value)}); expected epoch milliseconds.`
2841
+ );
2842
+ }
2843
+ return new Date(value).toISOString();
2844
+ }
2845
+ if (FULL_DATETIME_WITH_OFFSET.test(value)) {
2846
+ return value;
2847
+ }
2848
+ if (DATE_ONLY.test(value)) {
2849
+ throw invalidRequest(
2850
+ fieldPath,
2851
+ `received a date-only string ("${value}"). This API requires a full ISO-8601 datetime WITH an offset, and the SDK will not guess which timezone you meant (midnight UTC is rarely midnight where the trip actually starts). Pass a \`Date\` instead \u2014 e.g. \`new Date("2026-08-20T09:00:00+05:30")\` \u2014 or add an explicit offset yourself, e.g. "2026-08-20T00:00:00+05:30".`
2852
+ );
2853
+ }
2854
+ throw invalidRequest(
2855
+ fieldPath,
2856
+ `received "${value}", which is not a full ISO-8601 datetime with an offset. Pass a \`Date\`, an epoch-milliseconds number, or a string like "2026-08-20T09:00:00+05:30".`
2857
+ );
2858
+ }
2859
+ function normalizeNullableDateTimeInput(value, fieldPath) {
2860
+ return value === null ? null : normalizeDateTimeInput(value, fieldPath);
2861
+ }
2862
+
2863
+ // src/delta/cursor.ts
2864
+ function isTombstone(row) {
2865
+ return row._tombstone === true;
2866
+ }
2867
+ function mergeDeltaRows(store, rows) {
2868
+ let added = 0;
2869
+ let updated = 0;
2870
+ let removed = 0;
2871
+ let unchanged = 0;
2872
+ for (const row of rows) {
2873
+ const held = store.get(row.id);
2874
+ if (isTombstone(row)) {
2875
+ if (held === void 0 || held.version > row.version) {
2876
+ unchanged += 1;
2877
+ continue;
2878
+ }
2879
+ store.delete(row.id);
2880
+ removed += 1;
2881
+ continue;
2882
+ }
2883
+ if (held === void 0) {
2884
+ store.set(row.id, row);
2885
+ added += 1;
2886
+ continue;
2887
+ }
2888
+ if (held.version >= row.version) {
2889
+ unchanged += 1;
2890
+ continue;
2891
+ }
2892
+ store.set(row.id, row);
2893
+ updated += 1;
2894
+ }
2895
+ return { added, updated, removed, unchanged };
2896
+ }
2897
+ var KaafilDeltaCursorInFlightError = class _KaafilDeltaCursorInFlightError extends Error {
2898
+ constructor() {
2899
+ super(
2900
+ "pull() was called while a previous pull on this delta cursor was still in flight. Two concurrent pulls would settle in an unknown order and leave the cursor at whichever response landed last, not the newest \u2014 await the first one's result."
2901
+ );
2902
+ this.name = "KaafilDeltaCursorInFlightError";
2903
+ Object.setPrototypeOf(this, _KaafilDeltaCursorInFlightError.prototype);
2904
+ }
2905
+ };
2906
+ function createDeltaCursor(config) {
2907
+ const { fetchDelta } = config;
2908
+ const state = {
2909
+ cursor: void 0,
2910
+ isLoading: false
2911
+ };
2912
+ function restore(cursor) {
2913
+ state.cursor = normalizeDateTimeInput(cursor, "cursor");
2914
+ }
2915
+ if (config.cursor !== void 0) {
2916
+ restore(config.cursor);
2917
+ }
2918
+ async function pull(options = {}) {
2919
+ if (state.isLoading) {
2920
+ throw new KaafilDeltaCursorInFlightError();
2921
+ }
2922
+ const previousCursor = state.cursor;
2923
+ state.isLoading = true;
2924
+ try {
2925
+ const response = await fetchDelta({ since: previousCursor, signal: options.signal });
2926
+ state.cursor = response.meta.serverTime;
2927
+ return {
2928
+ data: response,
2929
+ meta: response.meta,
2930
+ cursor: response.meta.serverTime,
2931
+ previousCursor
2932
+ };
2933
+ } finally {
2934
+ state.isLoading = false;
2935
+ }
2936
+ }
2937
+ return {
2938
+ get cursor() {
2939
+ return state.cursor;
2940
+ },
2941
+ get isLoading() {
2942
+ return state.isLoading;
2943
+ },
2944
+ get hasSynced() {
2945
+ return state.cursor !== void 0;
2946
+ },
2947
+ pull,
2948
+ restore,
2949
+ reset() {
2950
+ state.cursor = void 0;
2951
+ }
2952
+ };
2953
+ }
2954
+
2955
+ // src/offline/snapshot.ts
2956
+ var EMPTY_LIST = { cursor: void 0, rows: {}, syncedAt: {} };
2957
+ function createSnapshotStore(options) {
2958
+ const key = `${options.keyPrefix}:snapshot`;
2959
+ let trips = /* @__PURE__ */ new Map();
2960
+ async function persist() {
2961
+ const shape = { trips: {} };
2962
+ for (const [tripRef, lists] of trips) {
2963
+ const out = {};
2964
+ for (const [listName, value] of lists) {
2965
+ out[listName] = value;
2966
+ }
2967
+ shape.trips[tripRef] = out;
2968
+ }
2969
+ await options.storage.set(key, JSON.stringify(shape));
2970
+ }
2971
+ function getList(tripRef, listName) {
2972
+ return trips.get(tripRef)?.get(listName) ?? EMPTY_LIST;
2973
+ }
2974
+ function setList(tripRef, listName, value) {
2975
+ let lists = trips.get(tripRef);
2976
+ if (lists === void 0) {
2977
+ lists = /* @__PURE__ */ new Map();
2978
+ trips.set(tripRef, lists);
2979
+ }
2980
+ lists.set(listName, value);
2981
+ }
2982
+ return {
2983
+ async load() {
2984
+ const raw = await options.storage.get(key);
2985
+ trips = /* @__PURE__ */ new Map();
2986
+ if (raw === void 0) {
2987
+ return;
2988
+ }
2989
+ let parsed;
2990
+ try {
2991
+ parsed = JSON.parse(raw);
2992
+ } catch {
2993
+ return;
2994
+ }
2995
+ for (const [tripRef, lists] of Object.entries(parsed.trips ?? {})) {
2996
+ for (const [listName, value] of Object.entries(lists)) {
2997
+ setList(tripRef, listName, {
2998
+ cursor: value.cursor,
2999
+ rows: value.rows ?? {},
3000
+ syncedAt: value.syncedAt ?? {}
3001
+ });
3002
+ }
3003
+ }
3004
+ },
3005
+ list(tripRef, listName) {
3006
+ return Object.values(getList(tripRef, listName).rows);
3007
+ },
3008
+ cursor(tripRef, listName) {
3009
+ return getList(tripRef, listName).cursor;
3010
+ },
3011
+ syncedAt(tripRef, listName, id) {
3012
+ return getList(tripRef, listName).syncedAt[id];
3013
+ },
3014
+ listNames(tripRef) {
3015
+ return [...trips.get(tripRef)?.keys() ?? []];
3016
+ },
3017
+ async applyPull({ tripRef, listName, rows, serverTime }) {
3018
+ const current = getList(tripRef, listName);
3019
+ const merged = new Map(Object.entries(current.rows));
3020
+ const stats = mergeDeltaRows(merged, rows);
3021
+ const syncedAt = {};
3022
+ for (const id of merged.keys()) {
3023
+ syncedAt[id] = current.rows[id] === merged.get(id) ? current.syncedAt[id] ?? serverTime : serverTime;
3024
+ }
3025
+ setList(tripRef, listName, {
3026
+ cursor: serverTime,
3027
+ rows: Object.fromEntries(merged),
3028
+ syncedAt
3029
+ });
3030
+ await persist();
3031
+ return {
3032
+ stats,
3033
+ // Derived from what the merge DID, not from `rows.length` — an
3034
+ // at-least-once window routinely re-delivers rows that change
3035
+ // nothing, and counting them would report a change that never
3036
+ // happened (`06 §5`).
3037
+ changed: stats.added + stats.updated + stats.removed > 0,
3038
+ cursor: serverTime
3039
+ };
3040
+ },
3041
+ async upsert({ tripRef, listName, row, syncedAt }) {
3042
+ const current = getList(tripRef, listName);
3043
+ const held = current.rows[row.id];
3044
+ if (held !== void 0 && held.version > row.version) {
3045
+ return false;
3046
+ }
3047
+ setList(tripRef, listName, {
3048
+ cursor: current.cursor,
3049
+ rows: { ...current.rows, [row.id]: row },
3050
+ syncedAt: syncedAt !== void 0 ? { ...current.syncedAt, [row.id]: syncedAt } : current.syncedAt
3051
+ });
3052
+ await persist();
3053
+ return true;
3054
+ },
3055
+ async purgeEntity(tripRef, listName, id) {
3056
+ const current = getList(tripRef, listName);
3057
+ if (current.rows[id] === void 0) {
3058
+ return;
3059
+ }
3060
+ const rows = { ...current.rows };
3061
+ const stamps = { ...current.syncedAt };
3062
+ delete rows[id];
3063
+ delete stamps[id];
3064
+ setList(tripRef, listName, { cursor: current.cursor, rows, syncedAt: stamps });
3065
+ await persist();
3066
+ },
3067
+ async purgeTrip(tripRef) {
3068
+ if (!trips.delete(tripRef)) {
3069
+ return;
3070
+ }
3071
+ await persist();
3072
+ }
3073
+ };
3074
+ }
3075
+
3076
+ // src/offline/engine.ts
3077
+ function createOfflineEngine(options) {
3078
+ const keyPrefix = `kaafil:v1:${options.scope}`;
3079
+ const events = createOfflineEvents({
3080
+ ...options.onEventHandlerError !== void 0 ? { onHandlerError: (error) => options.onEventHandlerError?.(error) } : {}
3081
+ });
3082
+ const snapshot = createSnapshotStore({ storage: options.storage, keyPrefix });
3083
+ const outbox = createOutbox({
3084
+ storage: options.storage,
3085
+ keyPrefix,
3086
+ ...options.now !== void 0 ? { now: options.now } : {},
3087
+ ...options.newId !== void 0 ? { newId: options.newId } : {}
3088
+ });
3089
+ let share;
3090
+ const onServerTime = (serverTime) => {
3091
+ share?.observeServerTime(serverTime);
3092
+ };
3093
+ if (options.share !== void 0) {
3094
+ share = createShareGuard({
3095
+ tripRef: options.share.tripRef,
3096
+ expiresAt: options.share.expiresAt,
3097
+ snapshot,
3098
+ outbox,
3099
+ events,
3100
+ ...options.share.monotonic !== void 0 ? { monotonic: options.share.monotonic } : {}
3101
+ });
3102
+ }
3103
+ const drainer = createDrainer({
3104
+ outbox,
3105
+ snapshot,
3106
+ transport: options.transport,
3107
+ events,
3108
+ onServerTime,
3109
+ ...options.conflictResolver !== void 0 ? { conflictResolver: options.conflictResolver } : {},
3110
+ ...options.now !== void 0 ? { now: options.now } : {},
3111
+ ...options.random !== void 0 ? { random: options.random } : {}
3112
+ });
3113
+ const pull = createPullCoordinator({
3114
+ snapshot,
3115
+ transport: options.transport,
3116
+ events,
3117
+ onServerTime
3118
+ });
3119
+ const blobs = options.blob === void 0 ? void 0 : createBlobLane({
3120
+ storage: options.storage,
3121
+ keyPrefix,
3122
+ outbox,
3123
+ uploader: options.blob.uploader,
3124
+ source: options.blob.source,
3125
+ ...options.now !== void 0 ? { now: options.now } : {},
3126
+ ...options.random !== void 0 ? { random: options.random } : {}
3127
+ });
3128
+ let unbind;
3129
+ async function enqueue(input) {
3130
+ share?.assertWritable();
3131
+ const op = await outbox.enqueue({
3132
+ tripRef: input.tripRef,
3133
+ method: input.method,
3134
+ path: input.path,
3135
+ operationId: input.operationId,
3136
+ ...input.body !== void 0 ? { body: input.body } : {},
3137
+ ...input.ifMatch !== void 0 ? { ifMatch: input.ifMatch } : {},
3138
+ ...input.entity !== void 0 ? { entity: input.entity } : {},
3139
+ ...input.idempotencyKey !== void 0 ? { idempotencyKey: input.idempotencyKey } : {},
3140
+ ...input.enqueuedAt !== void 0 ? { enqueuedAt: input.enqueuedAt } : {}
3141
+ });
3142
+ if (input.optimistic !== void 0 && input.entity !== void 0) {
3143
+ await snapshot.upsert({
3144
+ tripRef: input.tripRef,
3145
+ listName: input.entity.listName,
3146
+ row: input.optimistic
3147
+ });
3148
+ }
3149
+ drainer.kick();
3150
+ return op;
3151
+ }
3152
+ return {
3153
+ events,
3154
+ snapshot,
3155
+ outbox,
3156
+ drainer,
3157
+ pull,
3158
+ blobs,
3159
+ share,
3160
+ async open() {
3161
+ await Promise.all([snapshot.load(), outbox.load(), blobs?.load() ?? Promise.resolve()]);
3162
+ unbind = drainer.bindOpportunisticTriggers();
3163
+ },
3164
+ enqueue,
3165
+ async enqueueWithBlob(input) {
3166
+ const { blob, ...rest } = input;
3167
+ share?.assertWritable();
3168
+ const op = await outbox.enqueue({
3169
+ tripRef: rest.tripRef,
3170
+ method: rest.method,
3171
+ path: rest.path,
3172
+ operationId: rest.operationId,
3173
+ receiptPending: true,
3174
+ blobId: blob.id,
3175
+ ...rest.body !== void 0 ? { body: rest.body } : {},
3176
+ ...rest.ifMatch !== void 0 ? { ifMatch: rest.ifMatch } : {},
3177
+ ...rest.entity !== void 0 ? { entity: rest.entity } : {},
3178
+ ...rest.idempotencyKey !== void 0 ? { idempotencyKey: rest.idempotencyKey } : {},
3179
+ ...rest.enqueuedAt !== void 0 ? { enqueuedAt: rest.enqueuedAt } : {}
3180
+ });
3181
+ if (rest.optimistic !== void 0 && rest.entity !== void 0) {
3182
+ await snapshot.upsert({
3183
+ tripRef: rest.tripRef,
3184
+ listName: rest.entity.listName,
3185
+ row: rest.optimistic
3186
+ });
3187
+ }
3188
+ if (blobs !== void 0) {
3189
+ await blobs.enqueue({
3190
+ blobId: blob.id,
3191
+ tripRef: rest.tripRef,
3192
+ parentOpId: op.id,
3193
+ contentType: blob.contentType,
3194
+ sizeBytes: blob.sizeBytes,
3195
+ backfill: blob.backfill
3196
+ });
3197
+ }
3198
+ drainer.kick();
3199
+ return op;
3200
+ },
3201
+ async drain(drainOptions = {}) {
3202
+ await share?.parkOpsPastGrace();
3203
+ const report = await drainer.drain(drainOptions);
3204
+ await blobs?.drain();
3205
+ return report;
3206
+ },
3207
+ close() {
3208
+ unbind?.();
3209
+ unbind = void 0;
3210
+ drainer.cancelKick();
3211
+ events.clear();
3212
+ }
3213
+ };
3214
+ }
3215
+ function outcomeFromError(error) {
3216
+ if (isKaafilError(error)) {
3217
+ const kaafil = error;
3218
+ return {
3219
+ status: kaafil.status ?? null,
3220
+ ...kaafil.code !== void 0 ? { code: kaafil.code } : {},
3221
+ ...kaafil.details !== void 0 ? { details: kaafil.details } : {},
3222
+ ...kaafil.meta?.serverTime !== void 0 ? { serverTime: kaafil.meta.serverTime } : {},
3223
+ error: kaafil
3224
+ };
3225
+ }
3226
+ return { status: null, transportFailureKind: "network" };
3227
+ }
3228
+ function entityFromBody(body) {
3229
+ if (typeof body !== "object" || body === null) {
3230
+ return void 0;
3231
+ }
3232
+ const candidate = body;
3233
+ if (typeof candidate.id === "string" && typeof candidate.version === "number") {
3234
+ return body;
3235
+ }
3236
+ return void 0;
3237
+ }
3238
+ function createHttpOfflineTransport(options) {
3239
+ const { http, sync } = options;
3240
+ const batchable = options.credential !== "share" || isShareBatchPushAvailable();
3241
+ const transport = {
3242
+ async sendOne(op, signal) {
3243
+ try {
3244
+ const response = await http.execute({
3245
+ method: op.method,
3246
+ operationId: op.operationId,
3247
+ path: op.path,
3248
+ // The op's OWN key, fixed at enqueue and reused on every attempt.
3249
+ idempotencyKey: op.idempotencyKey,
3250
+ ...op.body !== void 0 ? { body: op.body } : {},
3251
+ ...op.ifMatch !== void 0 ? { headers: { "If-Match": String(op.ifMatch) } } : {},
3252
+ ...signal !== void 0 ? { signal } : {}
3253
+ });
3254
+ const { meta, ...data } = response;
3255
+ const entity = entityFromBody(data);
3256
+ return {
3257
+ status: meta.status,
3258
+ serverTime: meta.serverTime,
3259
+ ...entity !== void 0 ? { entity } : {}
3260
+ };
3261
+ } catch (error) {
3262
+ return outcomeFromError(error);
3263
+ }
3264
+ },
3265
+ ...options.readEntity !== void 0 ? { readEntity: options.readEntity } : {},
3266
+ async pullTrip({ tripRef, since, signal }) {
3267
+ const response = await sync.pullTrip({
3268
+ tripRef,
3269
+ ...since !== void 0 ? { since } : {},
3270
+ ...signal !== void 0 ? { signal } : {}
3271
+ });
3272
+ return {
3273
+ tripRef: response.tripRef,
3274
+ // `sections` is a PARTIAL record and stays one all the way through —
3275
+ // nothing here fills a missing key with an empty list (`./pull.ts`).
3276
+ sections: response.sections,
3277
+ serverTime: response.meta.serverTime
3278
+ };
3279
+ }
3280
+ };
3281
+ if (!batchable) {
3282
+ return transport;
3283
+ }
3284
+ return {
3285
+ ...transport,
3286
+ async sendBatch(ops, signal) {
3287
+ const push = options.credential === "share" ? sync.pushShare : sync.push;
3288
+ const response = await push({
3289
+ ops: ops.map((op) => ({
3290
+ method: op.method,
3291
+ path: op.path,
3292
+ idempotencyKey: op.idempotencyKey,
3293
+ ...op.ifMatch !== void 0 ? { ifMatch: op.ifMatch } : {},
3294
+ ...op.enqueuedAt !== void 0 ? { enqueuedAt: op.enqueuedAt } : {},
3295
+ ...op.body !== void 0 ? { body: op.body } : {}
3296
+ })),
3297
+ ...signal !== void 0 ? { signal } : {}
3298
+ });
3299
+ const serverTime = response.meta.serverTime;
3300
+ const byIndex = new Map(response.verdicts.map((verdict) => [verdict.index, verdict]));
3301
+ return ops.map((_op, index) => {
3302
+ const verdict = byIndex.get(index);
3303
+ if (verdict === void 0) {
3304
+ return { status: null, transportFailureKind: "network" };
3305
+ }
3306
+ const envelope = verdict.body;
3307
+ if (verdict.status >= 200 && verdict.status < 300) {
3308
+ const entity = entityFromBody(envelope?.data);
3309
+ return {
3310
+ status: verdict.status,
3311
+ serverTime,
3312
+ ...entity !== void 0 ? { entity } : {}
3313
+ };
3314
+ }
3315
+ const code = envelope?.error?.code;
3316
+ const details = envelope?.error?.details;
3317
+ return {
3318
+ status: verdict.status,
3319
+ serverTime,
3320
+ ...typeof code === "string" && code in KaafilErrorCodeValues ? { code } : {},
3321
+ ...typeof details === "object" && details !== null ? { details } : {}
3322
+ };
3323
+ });
3324
+ }
3325
+ };
3326
+ }
3327
+ var KaafilErrorCodeValues = Object.fromEntries(
3328
+ Object.values(KaafilErrorCode).map((code) => [code, true])
3329
+ );
3330
+
3331
+ // src/resources/checklists.ts
3332
+ function createChecklistsResource(client) {
3333
+ return {
3334
+ async read(options) {
3335
+ const { tripRef, since, signal } = options;
3336
+ return client.execute({
3337
+ method: "GET",
3338
+ operationId: OperationId.ReadChecklistAggregate,
3339
+ path: "/api/v1/trips/{ref}/checklist",
3340
+ pathParams: { ref: tripRef },
3341
+ query: { since },
3342
+ ...signal !== void 0 ? { signal } : {}
3343
+ });
3344
+ },
3345
+ items: {
3346
+ async add(options) {
3347
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3348
+ return client.execute({
3349
+ method: "POST",
3350
+ operationId: OperationId.AddChecklistItem,
3351
+ path: "/api/v1/trips/{ref}/checklist/items",
3352
+ pathParams: { ref: tripRef },
3353
+ body,
3354
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3355
+ ...signal !== void 0 ? { signal } : {}
3356
+ });
3357
+ },
3358
+ async patch(options) {
3359
+ const { tripRef, itemId, version, signal, ...body } = options;
3360
+ return client.execute({
3361
+ method: "PATCH",
3362
+ operationId: OperationId.PatchChecklistItem,
3363
+ path: "/api/v1/trips/{ref}/checklist/items/{itemId}",
3364
+ pathParams: { ref: tripRef, itemId },
3365
+ body,
3366
+ headers: { "If-Match": String(version) },
3367
+ ...signal !== void 0 ? { signal } : {}
3368
+ });
3369
+ },
3370
+ async remove(options) {
3371
+ const { tripRef, itemId, version, signal } = options;
3372
+ return client.execute({
3373
+ method: "DELETE",
3374
+ operationId: OperationId.DeleteChecklistItem,
3375
+ path: "/api/v1/trips/{ref}/checklist/items/{itemId}",
3376
+ pathParams: { ref: tripRef, itemId },
3377
+ headers: { "If-Match": String(version) },
3378
+ ...signal !== void 0 ? { signal } : {}
3379
+ });
3380
+ },
3381
+ async toggle(options) {
3382
+ const { tripRef, itemId, idempotencyKey, signal, ...body } = options;
3383
+ return client.execute({
3384
+ method: "POST",
3385
+ operationId: OperationId.ToggleChecklistItem,
3386
+ path: "/api/v1/trips/{ref}/checklist/items/{itemId}/toggle",
3387
+ pathParams: { ref: tripRef, itemId },
3388
+ body,
3389
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3390
+ ...signal !== void 0 ? { signal } : {}
3391
+ });
3392
+ }
3393
+ },
3394
+ templates: {
3395
+ async list(options) {
3396
+ const { tripRef, locale, signal } = options;
3397
+ return client.execute({
3398
+ method: "GET",
3399
+ operationId: OperationId.ListChecklistTemplates,
3400
+ path: "/api/v1/trips/{ref}/checklist/templates",
3401
+ pathParams: { ref: tripRef },
3402
+ query: { locale },
3403
+ ...signal !== void 0 ? { signal } : {}
3404
+ });
3405
+ },
3406
+ async pull(options) {
3407
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3408
+ return client.execute({
3409
+ method: "POST",
3410
+ operationId: OperationId.PullChecklistTemplate,
3411
+ path: "/api/v1/trips/{ref}/checklist/pull-template",
3412
+ pathParams: { ref: tripRef },
3413
+ body,
3414
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3415
+ ...signal !== void 0 ? { signal } : {}
3416
+ });
3417
+ }
3418
+ }
3419
+ };
3420
+ }
3421
+
3422
+ // src/resources/closeout.ts
3423
+ function createCloseoutResource(client) {
3424
+ return {
3425
+ async get(options) {
3426
+ const { tripRef, since, signal } = options;
3427
+ return client.execute({
3428
+ method: "GET",
3429
+ operationId: OperationId.ReadCloseout,
3430
+ path: "/api/v1/trips/{ref}/closeout",
3431
+ pathParams: { ref: tripRef },
3432
+ query: { since },
3433
+ ...signal !== void 0 ? { signal } : {}
3434
+ });
3435
+ },
3436
+ async saveHandover(options) {
3437
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3438
+ return client.execute({
3439
+ method: "POST",
3440
+ operationId: OperationId.SaveCloseoutHandover,
3441
+ path: "/api/v1/trips/{ref}/closeout/handover",
3442
+ pathParams: { ref: tripRef },
3443
+ body,
3444
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3445
+ ...signal !== void 0 ? { signal } : {}
3446
+ });
3447
+ },
3448
+ async lock(options) {
3449
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3450
+ return client.execute({
3451
+ method: "POST",
3452
+ operationId: OperationId.LockCloseout,
3453
+ path: "/api/v1/trips/{ref}/closeout/lock",
3454
+ pathParams: { ref: tripRef },
3455
+ body,
3456
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3457
+ ...signal !== void 0 ? { signal } : {}
3458
+ });
3459
+ },
3460
+ async unlock(options) {
3461
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3462
+ return client.execute({
3463
+ method: "POST",
3464
+ operationId: OperationId.UnlockCloseout,
3465
+ path: "/api/v1/trips/{ref}/closeout/unlock",
3466
+ pathParams: { ref: tripRef },
3467
+ body,
3468
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3469
+ ...signal !== void 0 ? { signal } : {}
3470
+ });
3471
+ },
3472
+ async exportPdf(options) {
3473
+ const { tripRef, signal, ...body } = options;
3474
+ return client.executeBinary({
3475
+ method: "POST",
3476
+ operationId: OperationId.ExportCloseoutPack,
3477
+ path: "/api/v1/trips/{ref}/closeout/export-pdf",
3478
+ pathParams: { ref: tripRef },
3479
+ body,
3480
+ // The one place a non-JSON `Accept` is sent. `exportCloseoutPack`
3481
+ // declares no `Idempotency-Key` parameter
3482
+ // (`OPERATION_ACCEPTS_IDEMPOTENCY_KEY.exportCloseoutPack` is `false`),
3483
+ // and rightly — printing the same pack twice creates nothing — so no
3484
+ // key is offered here and the transport mints none.
3485
+ accept: "application/pdf",
3486
+ ...signal !== void 0 ? { signal } : {}
3487
+ });
3488
+ }
3489
+ };
3490
+ }
3491
+
3492
+ // src/resources/collections.ts
3493
+ function createCollectionsResource(client) {
3494
+ return {
3495
+ async list(options) {
3496
+ const { tripRef, travellerId, since, signal } = options;
3497
+ return client.execute({
3498
+ method: "GET",
3499
+ operationId: OperationId.ListCollections,
3500
+ path: "/api/v1/trips/{ref}/collections",
3501
+ pathParams: { ref: tripRef },
3502
+ query: { travellerId, since },
3503
+ ...signal !== void 0 ? { signal } : {}
3504
+ });
3505
+ },
3506
+ async eligible(options) {
3507
+ const { tripRef, signal } = options;
3508
+ return client.execute({
3509
+ method: "GET",
3510
+ operationId: OperationId.ListEligibleCollections,
3511
+ path: "/api/v1/trips/{ref}/collections/eligible",
3512
+ pathParams: { ref: tripRef },
3513
+ ...signal !== void 0 ? { signal } : {}
3514
+ });
3515
+ },
3516
+ async record(options) {
3517
+ const { tripRef, idempotencyKey, signal, collectedAt, ...rest } = options;
3518
+ const body = {
3519
+ ...rest,
3520
+ ...collectedAt !== void 0 ? { collectedAt: normalizeDateTimeInput(collectedAt, "collectedAt") } : {}
3521
+ };
3522
+ return client.execute({
3523
+ method: "POST",
3524
+ operationId: OperationId.RecordCollection,
3525
+ path: "/api/v1/trips/{ref}/collections",
3526
+ pathParams: { ref: tripRef },
3527
+ body,
3528
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3529
+ ...signal !== void 0 ? { signal } : {}
3530
+ });
3531
+ },
3532
+ async void(options) {
3533
+ const { tripRef, collectionId, version, signal, ...body } = options;
3534
+ return client.execute({
3535
+ method: "DELETE",
3536
+ operationId: OperationId.VoidCollection,
3537
+ path: "/api/v1/trips/{ref}/collections/{id}/void",
3538
+ pathParams: { ref: tripRef, id: collectionId },
3539
+ body,
3540
+ headers: { "If-Match": String(version) },
3541
+ ...signal !== void 0 ? { signal } : {}
3542
+ });
3543
+ }
3544
+ };
3545
+ }
3546
+
3547
+ // src/resources/expenses.ts
3548
+ function createExpensesResource(client) {
3549
+ return {
3550
+ async list(options) {
3551
+ const { tripRef, since, signal, ...filters } = options;
3552
+ return client.execute({
3553
+ method: "GET",
3554
+ operationId: OperationId.ListExpenses,
3555
+ path: "/api/v1/trips/{ref}/expenses",
3556
+ pathParams: { ref: tripRef },
3557
+ query: { ...filters, since },
3558
+ ...signal !== void 0 ? { signal } : {}
3559
+ });
3560
+ },
3561
+ async read(options) {
3562
+ const { tripRef, expenseId, signal } = options;
3563
+ return client.execute({
3564
+ method: "GET",
3565
+ operationId: OperationId.ReadExpense,
3566
+ path: "/api/v1/trips/{ref}/expenses/{id}",
3567
+ pathParams: { ref: tripRef, id: expenseId },
3568
+ ...signal !== void 0 ? { signal } : {}
3569
+ });
3570
+ },
3571
+ async log(options) {
3572
+ const { tripRef, idempotencyKey, signal, spentAt, ...rest } = options;
3573
+ const body = {
3574
+ ...rest,
3575
+ ...spentAt !== void 0 ? { spentAt: normalizeDateTimeInput(spentAt, "spentAt") } : {}
3576
+ };
3577
+ return client.execute({
3578
+ method: "POST",
3579
+ operationId: OperationId.LogExpense,
3580
+ path: "/api/v1/trips/{ref}/expenses",
3581
+ pathParams: { ref: tripRef },
3582
+ body,
3583
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3584
+ ...signal !== void 0 ? { signal } : {}
3585
+ });
3586
+ },
3587
+ async linkReceipt(options) {
3588
+ const { tripRef, expenseId, idempotencyKey, signal, ...body } = options;
3589
+ return client.execute({
3590
+ method: "PATCH",
3591
+ operationId: OperationId.LinkExpenseReceipt,
3592
+ path: "/api/v1/trips/{ref}/expenses/{id}/receipt",
3593
+ pathParams: { ref: tripRef, id: expenseId },
3594
+ body,
3595
+ idempotencyKey,
3596
+ ...signal !== void 0 ? { signal } : {}
3597
+ });
3598
+ },
3599
+ async void(options) {
3600
+ const { tripRef, expenseId, version, signal, ...body } = options;
3601
+ return client.execute({
3602
+ method: "DELETE",
3603
+ operationId: OperationId.VoidExpense,
3604
+ path: "/api/v1/trips/{ref}/expenses/{id}/void",
3605
+ pathParams: { ref: tripRef, id: expenseId },
3606
+ body,
3607
+ headers: { "If-Match": String(version) },
3608
+ ...signal !== void 0 ? { signal } : {}
3609
+ });
3610
+ },
3611
+ claims: {
3612
+ async submit(options) {
3613
+ const { tripRef, expenseId, idempotencyKey, signal } = options;
3614
+ return client.execute({
3615
+ method: "POST",
3616
+ operationId: OperationId.SubmitExpenseClaim,
3617
+ path: "/api/v1/trips/{ref}/expenses/{id}/claim",
3618
+ pathParams: { ref: tripRef, id: expenseId },
3619
+ body: {},
3620
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3621
+ ...signal !== void 0 ? { signal } : {}
3622
+ });
3623
+ },
3624
+ async withdraw(options) {
3625
+ const { tripRef, expenseId, version, signal } = options;
3626
+ return client.execute({
3627
+ method: "DELETE",
3628
+ operationId: OperationId.WithdrawExpenseClaim,
3629
+ path: "/api/v1/trips/{ref}/expenses/{id}/claim/withdraw",
3630
+ pathParams: { ref: tripRef, id: expenseId },
3631
+ body: {},
3632
+ headers: { "If-Match": String(version) },
3633
+ ...signal !== void 0 ? { signal } : {}
3634
+ });
3635
+ },
3636
+ async ingest(options) {
3637
+ const { tripRef, expenseId, idempotencyKey, signal, decisionAt, ...rest } = options;
3638
+ const body = {
3639
+ ...rest,
3640
+ decisionAt: normalizeDateTimeInput(decisionAt, "decisionAt")
3641
+ };
3642
+ return client.execute({
3643
+ method: "POST",
3644
+ operationId: OperationId.ClaimStatusIngest,
3645
+ path: "/api/v1/trips/{ref}/expenses/{id}/claim-status",
3646
+ pathParams: { ref: tripRef, id: expenseId },
3647
+ body,
3648
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3649
+ ...signal !== void 0 ? { signal } : {}
3650
+ });
3651
+ }
3652
+ }
3653
+ };
3654
+ }
3655
+
3656
+ // src/resources/files.ts
3657
+ function createFilesResource(client) {
3658
+ return {
3659
+ async request(options) {
3660
+ const { idempotencyKey, signal, ...body } = options;
3661
+ return client.execute({
3662
+ method: "POST",
3663
+ operationId: OperationId.RequestFileUpload,
3664
+ path: "/api/v1/files",
3665
+ body,
3666
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3667
+ ...signal !== void 0 ? { signal } : {}
3668
+ });
3669
+ },
3670
+ async meta(options) {
3671
+ const { fileId, signal } = options;
3672
+ return client.execute({
3673
+ method: "GET",
3674
+ operationId: OperationId.ReadFile,
3675
+ path: "/api/v1/files/{id}",
3676
+ pathParams: { id: fileId },
3677
+ ...signal !== void 0 ? { signal } : {}
3678
+ });
3679
+ },
3680
+ async confirm(options) {
3681
+ const { fileId, idempotencyKey, signal } = options;
3682
+ return client.execute({
3683
+ method: "POST",
3684
+ operationId: OperationId.ConfirmFileUpload,
3685
+ path: "/api/v1/files/{id}/confirm",
3686
+ pathParams: { id: fileId },
3687
+ body: {},
3688
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3689
+ ...signal !== void 0 ? { signal } : {}
3690
+ });
3691
+ },
3692
+ async url(options) {
3693
+ const { fileId, signal } = options;
3694
+ return client.execute({
3695
+ method: "GET",
3696
+ operationId: OperationId.ReadFileUrl,
3697
+ path: "/api/v1/files/{id}/url",
3698
+ pathParams: { id: fileId },
3699
+ ...signal !== void 0 ? { signal } : {}
3700
+ });
3701
+ }
3702
+ };
3703
+ }
3704
+
3705
+ // src/resources/float.ts
3706
+ function createFloatResource(client) {
3707
+ return {
3708
+ async readSummary(options) {
3709
+ const { tripRef, since, signal } = options;
3710
+ return client.execute({
3711
+ method: "GET",
3712
+ operationId: OperationId.ReadFloatSummary,
3713
+ path: "/api/v1/trips/{ref}/float",
3714
+ pathParams: { ref: tripRef },
3715
+ query: { since },
3716
+ ...signal !== void 0 ? { signal } : {}
3717
+ });
3718
+ },
3719
+ async readLedger(options) {
3720
+ const { tripRef, managerId, signal } = options;
3721
+ return client.execute({
3722
+ method: "GET",
3723
+ operationId: OperationId.ReadFloatLedger,
3724
+ path: "/api/v1/trips/{ref}/float/{managerId}/ledger",
3725
+ pathParams: { ref: tripRef, managerId },
3726
+ ...signal !== void 0 ? { signal } : {}
3727
+ });
3728
+ },
3729
+ async issue(options) {
3730
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3731
+ return client.execute({
3732
+ method: "POST",
3733
+ operationId: OperationId.IssueFloat,
3734
+ path: "/api/v1/trips/{ref}/float/issue",
3735
+ pathParams: { ref: tripRef },
3736
+ body,
3737
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3738
+ ...signal !== void 0 ? { signal } : {}
3739
+ });
3740
+ },
3741
+ async return(options) {
3742
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3743
+ return client.execute({
3744
+ method: "POST",
3745
+ operationId: OperationId.ReturnFloat,
3746
+ path: "/api/v1/trips/{ref}/float/return",
3747
+ pathParams: { ref: tripRef },
3748
+ body,
3749
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3750
+ ...signal !== void 0 ? { signal } : {}
3751
+ });
3752
+ },
3753
+ async adjust(options) {
3754
+ const { tripRef, idempotencyKey, signal, ...body } = options;
3755
+ return client.execute({
3756
+ method: "POST",
3757
+ operationId: OperationId.AdjustFloat,
3758
+ path: "/api/v1/trips/{ref}/float/adjust",
3759
+ pathParams: { ref: tripRef },
3760
+ body,
3761
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3762
+ ...signal !== void 0 ? { signal } : {}
3763
+ });
3764
+ }
3765
+ };
3766
+ }
3767
+
3768
+ // src/resources/itinerary.ts
3769
+ function createItineraryResource(client) {
3770
+ return {
3771
+ async read(options) {
3772
+ const { tripRef, dayIndex, since, signal } = options;
3773
+ return client.execute({
3774
+ method: "GET",
3775
+ operationId: OperationId.ReadItinerary,
3776
+ path: "/api/v1/trips/{ref}/itinerary",
3777
+ pathParams: { ref: tripRef },
3778
+ query: { dayIndex, since },
3779
+ ...signal !== void 0 ? { signal } : {}
3780
+ });
3781
+ },
3782
+ items: {
3783
+ async add(options) {
3784
+ const { tripRef, idempotencyKey, signal, isoDate, startTime, endTime, ...rest } = options;
3785
+ const body = {
3786
+ ...rest,
3787
+ isoDate: normalizeDateTimeInput(isoDate, "isoDate"),
3788
+ ...startTime !== void 0 ? { startTime: normalizeNullableDateTimeInput(startTime, "startTime") } : {},
3789
+ ...endTime !== void 0 ? { endTime: normalizeNullableDateTimeInput(endTime, "endTime") } : {}
3790
+ };
3791
+ return client.execute({
3792
+ method: "POST",
3793
+ operationId: OperationId.AddItineraryItem,
3794
+ path: "/api/v1/trips/{ref}/itinerary/items",
3795
+ pathParams: { ref: tripRef },
3796
+ body,
3797
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3798
+ ...signal !== void 0 ? { signal } : {}
3799
+ });
3800
+ },
3801
+ async patch(options) {
3802
+ const { tripRef, itemId, version, signal, startTime, endTime, ...rest } = options;
3803
+ const body = {
3804
+ ...rest,
3805
+ ...startTime !== void 0 ? { startTime: normalizeNullableDateTimeInput(startTime, "startTime") } : {},
3806
+ ...endTime !== void 0 ? { endTime: normalizeNullableDateTimeInput(endTime, "endTime") } : {}
3807
+ };
3808
+ return client.execute({
3809
+ method: "PATCH",
3810
+ operationId: OperationId.PatchItineraryItem,
3811
+ path: "/api/v1/trips/{ref}/itinerary/items/{itemId}",
3812
+ pathParams: { ref: tripRef, itemId },
3813
+ body,
3814
+ headers: { "If-Match": String(version) },
3815
+ ...signal !== void 0 ? { signal } : {}
3816
+ });
3817
+ },
3818
+ async remove(options) {
3819
+ const { tripRef, itemId, version, signal } = options;
3820
+ return client.execute({
3821
+ method: "DELETE",
3822
+ operationId: OperationId.DeleteItineraryItem,
3823
+ path: "/api/v1/trips/{ref}/itinerary/items/{itemId}",
3824
+ pathParams: { ref: tripRef, itemId },
3825
+ headers: { "If-Match": String(version) },
3826
+ ...signal !== void 0 ? { signal } : {}
3827
+ });
3828
+ },
3829
+ async reorder(options) {
3830
+ const { tripRef, itemId, idempotencyKey, signal, ...body } = options;
3831
+ return client.execute({
3832
+ method: "POST",
3833
+ operationId: OperationId.ReorderItineraryItem,
3834
+ path: "/api/v1/trips/{ref}/itinerary/items/{itemId}/reorder",
3835
+ pathParams: { ref: tripRef, itemId },
3836
+ body,
3837
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3838
+ ...signal !== void 0 ? { signal } : {}
3839
+ });
3840
+ }
3841
+ },
3842
+ days: {
3843
+ async patch(options) {
3844
+ const { tripRef, dayIndex, version, signal, ...body } = options;
3845
+ return client.execute({
3846
+ method: "PATCH",
3847
+ operationId: OperationId.PatchItineraryDay,
3848
+ path: "/api/v1/trips/{ref}/itinerary/days/{dayIndex}",
3849
+ pathParams: { ref: tripRef, dayIndex },
3850
+ body,
3851
+ headers: { "If-Match": String(version) },
3852
+ ...signal !== void 0 ? { signal } : {}
3853
+ });
3854
+ }
3855
+ },
3856
+ changeLog: {
3857
+ async list(options) {
3858
+ const { tripRef, since, signal } = options;
3859
+ return client.execute({
3860
+ method: "GET",
3861
+ operationId: OperationId.ReadItineraryChangeLog,
3862
+ path: "/api/v1/trips/{ref}/itinerary/change-log",
3863
+ pathParams: { ref: tripRef },
3864
+ query: { since },
3865
+ ...signal !== void 0 ? { signal } : {}
3866
+ });
3867
+ }
3868
+ }
3869
+ };
3870
+ }
3871
+
3872
+ // src/resources/journey.ts
3873
+ var DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS = 6e4;
3874
+ var DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS = 1e3;
3875
+ function createJourneyResource(client) {
3876
+ const resource = {
3877
+ async get(options) {
3878
+ const { tripRef, signal } = options;
3879
+ return client.execute({
3880
+ method: "GET",
3881
+ operationId: OperationId.ReadJourney,
3882
+ path: "/api/v1/trips/{ref}/journey",
3883
+ pathParams: { ref: tripRef },
3884
+ ...signal !== void 0 ? { signal } : {}
3885
+ });
3886
+ },
3887
+ async capabilities(options) {
3888
+ const { tripRef, signal } = options;
3889
+ return client.execute({
3890
+ method: "GET",
3891
+ operationId: OperationId.ReadJourneyCapabilities,
3892
+ path: "/api/v1/trips/{ref}/journey/capabilities",
3893
+ pathParams: { ref: tripRef },
3894
+ ...signal !== void 0 ? { signal } : {}
3895
+ });
3896
+ },
3897
+ async rebuild(options) {
3898
+ const { tripRef, idempotencyKey, signal } = options;
3899
+ return client.execute({
3900
+ method: "POST",
3901
+ operationId: OperationId.RebuildJourney,
3902
+ path: "/api/v1/trips/{ref}/journey/rebuild",
3903
+ pathParams: { ref: tripRef },
3904
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3905
+ ...signal !== void 0 ? { signal } : {}
3906
+ });
3907
+ },
3908
+ async runStep(options) {
3909
+ const { tripRef, stepId, idempotencyKey, signal } = options;
3910
+ return client.execute({
3911
+ method: "POST",
3912
+ operationId: OperationId.RunJourneyStep,
3913
+ path: "/api/v1/trips/{ref}/journey/steps/{stepId}/run",
3914
+ pathParams: { ref: tripRef, stepId },
3915
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3916
+ ...signal !== void 0 ? { signal } : {}
3917
+ });
3918
+ },
3919
+ async waitUntilReady(options) {
3920
+ const {
3921
+ tripRef,
3922
+ timeoutMs = DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS,
3923
+ pollIntervalMs = DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS,
3924
+ signal
3925
+ } = options;
3926
+ const deadlineAt = Date.now() + timeoutMs;
3927
+ for (; ; ) {
3928
+ try {
3929
+ return await resource.get({ tripRef, ...signal !== void 0 ? { signal } : {} });
3930
+ } catch (error) {
3931
+ if (!(error instanceof KaafilNotFoundError)) {
3932
+ throw error;
3933
+ }
3934
+ const remainingMs = deadlineAt - Date.now();
3935
+ if (remainingMs <= 0) {
3936
+ throw new KaafilTimeoutError(
3937
+ `journey.waitUntilReady timed out after ${String(timeoutMs)}ms waiting for trip "${tripRef}" to become ready. The most likely cause is that the background worker that consumes the build queue is not running against this engine.`,
3938
+ { cause: error }
3939
+ );
3940
+ }
3941
+ try {
3942
+ await delayWithAbort(Math.min(pollIntervalMs, remainingMs), signal);
3943
+ } catch (sleepError) {
3944
+ throw new KaafilAbortError("Request aborted", { cause: sleepError });
3945
+ }
3946
+ }
3947
+ }
3948
+ },
3949
+ triggers: {
3950
+ async list(options) {
3951
+ const { agencyRef, signal } = options;
3952
+ return client.execute({
3953
+ method: "GET",
3954
+ operationId: OperationId.ListJourneyTriggers,
3955
+ path: "/api/v1/agencies/{ref}/journey-triggers",
3956
+ pathParams: { ref: agencyRef },
3957
+ ...signal !== void 0 ? { signal } : {}
3958
+ });
3959
+ },
3960
+ async patch(options) {
3961
+ const { agencyRef, key, version, idempotencyKey, signal, ...body } = options;
3962
+ return client.execute({
3963
+ method: "PATCH",
3964
+ operationId: OperationId.PatchJourneyTrigger,
3965
+ path: "/api/v1/agencies/{ref}/journey-triggers/{key}",
3966
+ pathParams: { ref: agencyRef, key },
3967
+ body,
3968
+ headers: { "If-Match": String(version) },
3969
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
3970
+ ...signal !== void 0 ? { signal } : {}
3971
+ });
3972
+ }
3973
+ }
3974
+ };
3975
+ return resource;
3976
+ }
3977
+
3978
+ // src/resources/notifications.ts
3979
+ function createNotificationsResource(client) {
3980
+ return {
3981
+ async list(options = {}) {
3982
+ const { since, signal } = options;
3983
+ return client.execute({
3984
+ method: "GET",
3985
+ operationId: OperationId.ListManagerNotifications,
3986
+ path: "/api/v1/managers/me/notifications",
3987
+ ...since !== void 0 ? { query: { since } } : {},
3988
+ ...signal !== void 0 ? { signal } : {}
3989
+ });
3990
+ }
3991
+ };
3992
+ }
3993
+
3994
+ // src/resources/pickups.ts
3995
+ function createPickupsResource(client) {
3996
+ return {
3997
+ async list(options) {
3998
+ const { tripRef, kind, since, signal } = options;
3999
+ return client.execute({
4000
+ method: "GET",
4001
+ operationId: OperationId.ListPickupStops,
4002
+ path: "/api/v1/trips/{ref}/pickups",
4003
+ pathParams: { ref: tripRef },
4004
+ query: { kind, since },
4005
+ ...signal !== void 0 ? { signal } : {}
4006
+ });
4007
+ },
4008
+ async create(options) {
4009
+ const { tripRef, idempotencyKey, signal, scheduledTime, ...rest } = options;
4010
+ const body = {
4011
+ ...rest,
4012
+ scheduledTime: normalizeDateTimeInput(scheduledTime, "scheduledTime")
4013
+ };
4014
+ return client.execute({
4015
+ method: "POST",
4016
+ operationId: OperationId.CreatePickupStop,
4017
+ path: "/api/v1/trips/{ref}/pickups",
4018
+ pathParams: { ref: tripRef },
4019
+ body,
4020
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4021
+ ...signal !== void 0 ? { signal } : {}
4022
+ });
4023
+ },
4024
+ async patch(options) {
4025
+ const { tripRef, pointId, version, signal, scheduledTime, ...rest } = options;
4026
+ const body = {
4027
+ ...rest,
4028
+ ...scheduledTime !== void 0 ? { scheduledTime: normalizeDateTimeInput(scheduledTime, "scheduledTime") } : {}
4029
+ };
4030
+ return client.execute({
4031
+ method: "PATCH",
4032
+ operationId: OperationId.PatchPickupStop,
4033
+ path: "/api/v1/trips/{ref}/pickups/{pointId}",
4034
+ pathParams: { ref: tripRef, pointId },
4035
+ body,
4036
+ headers: { "If-Match": String(version) },
4037
+ ...signal !== void 0 ? { signal } : {}
4038
+ });
4039
+ },
4040
+ async remove(options) {
4041
+ const { tripRef, pointId, version, force, signal } = options;
4042
+ return client.execute({
4043
+ method: "DELETE",
4044
+ operationId: OperationId.DeletePickupStop,
4045
+ path: "/api/v1/trips/{ref}/pickups/{pointId}",
4046
+ pathParams: { ref: tripRef, pointId },
4047
+ query: { force },
4048
+ headers: { "If-Match": String(version) },
4049
+ ...signal !== void 0 ? { signal } : {}
4050
+ });
4051
+ },
4052
+ async reorder(options) {
4053
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4054
+ return client.execute({
4055
+ method: "POST",
4056
+ operationId: OperationId.ReorderPickupStops,
4057
+ path: "/api/v1/trips/{ref}/pickups/reorder",
4058
+ pathParams: { ref: tripRef },
4059
+ body,
4060
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4061
+ ...signal !== void 0 ? { signal } : {}
4062
+ });
4063
+ },
4064
+ async assign(options) {
4065
+ const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
4066
+ return client.execute({
4067
+ method: "POST",
4068
+ operationId: OperationId.AssignPickupTraveller,
4069
+ path: "/api/v1/trips/{ref}/pickups/{pointId}/assign",
4070
+ pathParams: { ref: tripRef, pointId },
4071
+ body,
4072
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4073
+ ...signal !== void 0 ? { signal } : {}
4074
+ });
4075
+ },
4076
+ async board(options) {
4077
+ const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
4078
+ return client.execute({
4079
+ method: "POST",
4080
+ operationId: OperationId.BoardPickupTraveller,
4081
+ path: "/api/v1/trips/{ref}/pickups/{pointId}/board",
4082
+ pathParams: { ref: tripRef, pointId },
4083
+ body,
4084
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4085
+ ...signal !== void 0 ? { signal } : {}
4086
+ });
4087
+ },
4088
+ async close(options) {
4089
+ const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
4090
+ return client.execute({
4091
+ method: "POST",
4092
+ operationId: OperationId.ClosePickupStop,
4093
+ path: "/api/v1/trips/{ref}/pickups/{pointId}/close",
4094
+ pathParams: { ref: tripRef, pointId },
4095
+ body,
4096
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4097
+ ...signal !== void 0 ? { signal } : {}
4098
+ });
4099
+ },
4100
+ async reopen(options) {
4101
+ const { tripRef, pointId, idempotencyKey, signal } = options;
4102
+ return client.execute({
4103
+ method: "POST",
4104
+ operationId: OperationId.ReopenPickupStop,
4105
+ path: "/api/v1/trips/{ref}/pickups/{pointId}/reopen",
4106
+ pathParams: { ref: tripRef, pointId },
4107
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4108
+ ...signal !== void 0 ? { signal } : {}
4109
+ });
4110
+ },
4111
+ async manifestByPickup(options) {
4112
+ const { tripRef, kind, signal } = options;
4113
+ return client.execute({
4114
+ method: "GET",
4115
+ operationId: OperationId.ReadManifestByPickup,
4116
+ path: "/api/v1/trips/{ref}/manifest-by-pickup",
4117
+ pathParams: { ref: tripRef },
4118
+ query: { kind },
4119
+ ...signal !== void 0 ? { signal } : {}
4120
+ });
4121
+ }
4122
+ };
4123
+ }
4124
+
4125
+ // src/resources/rooming.ts
4126
+ function createRoomingResource(client) {
4127
+ return {
4128
+ async read(options) {
4129
+ const { tripRef, stayWindowId, since, signal } = options;
4130
+ return client.execute({
4131
+ method: "GET",
4132
+ operationId: OperationId.ReadRoomingBoard,
4133
+ path: "/api/v1/trips/{ref}/rooming",
4134
+ pathParams: { ref: tripRef },
4135
+ query: { stayWindowId, since },
4136
+ ...signal !== void 0 ? { signal } : {}
4137
+ });
4138
+ },
4139
+ async assign(options) {
4140
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4141
+ return client.execute({
4142
+ method: "POST",
4143
+ operationId: OperationId.AssignRoomingBed,
4144
+ path: "/api/v1/trips/{ref}/rooming/assign",
4145
+ pathParams: { ref: tripRef },
4146
+ body,
4147
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4148
+ ...signal !== void 0 ? { signal } : {}
4149
+ });
4150
+ },
4151
+ async autoAssign(options) {
4152
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4153
+ return client.execute({
4154
+ method: "POST",
4155
+ operationId: OperationId.AutoAssignRooming,
4156
+ path: "/api/v1/trips/{ref}/rooming/auto-assign",
4157
+ pathParams: { ref: tripRef },
4158
+ body,
4159
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4160
+ ...signal !== void 0 ? { signal } : {}
4161
+ });
4162
+ },
4163
+ stayWindows: {
4164
+ async list(options) {
4165
+ const { tripRef, since, signal } = options;
4166
+ return client.execute({
4167
+ method: "GET",
4168
+ operationId: OperationId.ListRoomingStayWindows,
4169
+ path: "/api/v1/trips/{ref}/rooming/stay-windows",
4170
+ pathParams: { ref: tripRef },
4171
+ query: { since },
4172
+ ...signal !== void 0 ? { signal } : {}
4173
+ });
4174
+ },
4175
+ async create(options) {
4176
+ const { tripRef, idempotencyKey, signal, startDate, endDate, ...rest } = options;
4177
+ const body = {
4178
+ ...rest,
4179
+ startDate: normalizeDateTimeInput(startDate, "startDate"),
4180
+ endDate: normalizeDateTimeInput(endDate, "endDate")
4181
+ };
4182
+ return client.execute({
4183
+ method: "POST",
4184
+ operationId: OperationId.CreateRoomingStayWindow,
4185
+ path: "/api/v1/trips/{ref}/rooming/stay-windows",
4186
+ pathParams: { ref: tripRef },
4187
+ body,
4188
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4189
+ ...signal !== void 0 ? { signal } : {}
4190
+ });
4191
+ },
4192
+ async patch(options) {
4193
+ const { tripRef, windowId, version, signal, startDate, endDate, ...rest } = options;
4194
+ const body = {
4195
+ ...rest,
4196
+ ...startDate !== void 0 ? { startDate: normalizeDateTimeInput(startDate, "startDate") } : {},
4197
+ ...endDate !== void 0 ? { endDate: normalizeDateTimeInput(endDate, "endDate") } : {}
4198
+ };
4199
+ return client.execute({
4200
+ method: "PATCH",
4201
+ operationId: OperationId.PatchRoomingStayWindow,
4202
+ path: "/api/v1/trips/{ref}/rooming/stay-windows/{windowId}",
4203
+ pathParams: { ref: tripRef, windowId },
4204
+ body,
4205
+ headers: { "If-Match": String(version) },
4206
+ ...signal !== void 0 ? { signal } : {}
4207
+ });
4208
+ },
4209
+ async remove(options) {
4210
+ const { tripRef, windowId, version, force, signal } = options;
4211
+ return client.execute({
4212
+ method: "DELETE",
4213
+ operationId: OperationId.DeleteRoomingStayWindow,
4214
+ path: "/api/v1/trips/{ref}/rooming/stay-windows/{windowId}",
4215
+ pathParams: { ref: tripRef, windowId },
4216
+ query: { force },
4217
+ headers: { "If-Match": String(version) },
4218
+ ...signal !== void 0 ? { signal } : {}
4219
+ });
4220
+ }
4221
+ },
4222
+ rooms: {
4223
+ async create(options) {
4224
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4225
+ return client.execute({
4226
+ method: "POST",
4227
+ operationId: OperationId.CreateRoomingRoom,
4228
+ path: "/api/v1/trips/{ref}/rooming/rooms",
4229
+ pathParams: { ref: tripRef },
4230
+ body,
4231
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4232
+ ...signal !== void 0 ? { signal } : {}
4233
+ });
4234
+ },
4235
+ async patch(options) {
4236
+ const { tripRef, roomId, version, signal, ...body } = options;
4237
+ return client.execute({
4238
+ method: "PATCH",
4239
+ operationId: OperationId.PatchRoomingRoom,
4240
+ path: "/api/v1/trips/{ref}/rooming/rooms/{roomId}",
4241
+ pathParams: { ref: tripRef, roomId },
4242
+ body,
4243
+ headers: { "If-Match": String(version) },
4244
+ ...signal !== void 0 ? { signal } : {}
4245
+ });
4246
+ },
4247
+ async remove(options) {
4248
+ const { tripRef, roomId, version, force, signal } = options;
4249
+ return client.execute({
4250
+ method: "DELETE",
4251
+ operationId: OperationId.DeleteRoomingRoom,
4252
+ path: "/api/v1/trips/{ref}/rooming/rooms/{roomId}",
4253
+ pathParams: { ref: tripRef, roomId },
4254
+ query: { force },
4255
+ headers: { "If-Match": String(version) },
4256
+ ...signal !== void 0 ? { signal } : {}
4257
+ });
4258
+ }
4259
+ }
4260
+ };
4261
+ }
4262
+
4263
+ // src/resources/seating.ts
4264
+ function createSeatingResource(client) {
4265
+ return {
4266
+ async read(options) {
4267
+ const { tripRef, since, signal } = options;
4268
+ return client.execute({
4269
+ method: "GET",
4270
+ operationId: OperationId.ReadSeatingBoard,
4271
+ path: "/api/v1/trips/{ref}/seating",
4272
+ pathParams: { ref: tripRef },
4273
+ query: { since },
4274
+ ...signal !== void 0 ? { signal } : {}
4275
+ });
4276
+ },
4277
+ async assign(options) {
4278
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4279
+ return client.execute({
4280
+ method: "POST",
4281
+ operationId: OperationId.AssignSeating,
4282
+ path: "/api/v1/trips/{ref}/seating/assign",
4283
+ pathParams: { ref: tripRef },
4284
+ body,
4285
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4286
+ ...signal !== void 0 ? { signal } : {}
4287
+ });
4288
+ },
4289
+ async autoAssign(options) {
4290
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4291
+ return client.execute({
4292
+ method: "POST",
4293
+ operationId: OperationId.AutoAssignSeating,
4294
+ path: "/api/v1/trips/{ref}/seating/auto-assign",
4295
+ pathParams: { ref: tripRef },
4296
+ body,
4297
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4298
+ ...signal !== void 0 ? { signal } : {}
4299
+ });
4300
+ },
4301
+ vehicles: {
4302
+ async create(options) {
4303
+ const { tripRef, idempotencyKey, signal, ...body } = options;
4304
+ return client.execute({
4305
+ method: "POST",
4306
+ operationId: OperationId.CreateSeatingVehicle,
4307
+ path: "/api/v1/trips/{ref}/seating/vehicles",
4308
+ pathParams: { ref: tripRef },
4309
+ body,
4310
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4311
+ ...signal !== void 0 ? { signal } : {}
4312
+ });
4313
+ },
4314
+ async patch(options) {
4315
+ const { tripRef, vehicleId, version, signal, ...body } = options;
4316
+ return client.execute({
4317
+ method: "PATCH",
4318
+ operationId: OperationId.PatchSeatingVehicle,
4319
+ path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}",
4320
+ pathParams: { ref: tripRef, vehicleId },
4321
+ body,
4322
+ headers: { "If-Match": String(version) },
4323
+ ...signal !== void 0 ? { signal } : {}
4324
+ });
4325
+ },
4326
+ async remove(options) {
4327
+ const { tripRef, vehicleId, version, signal } = options;
4328
+ return client.execute({
4329
+ method: "DELETE",
4330
+ operationId: OperationId.DeleteSeatingVehicle,
4331
+ path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}",
4332
+ pathParams: { ref: tripRef, vehicleId },
4333
+ headers: { "If-Match": String(version) },
4334
+ ...signal !== void 0 ? { signal } : {}
4335
+ });
4336
+ },
4337
+ manager: {
4338
+ async link(options) {
4339
+ const { tripRef, vehicleId, idempotencyKey, signal, ...body } = options;
4340
+ return client.execute({
4341
+ method: "POST",
4342
+ operationId: OperationId.LinkSeatingManager,
4343
+ path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}/manager",
4344
+ pathParams: { ref: tripRef, vehicleId },
4345
+ body,
4346
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4347
+ ...signal !== void 0 ? { signal } : {}
4348
+ });
4349
+ },
4350
+ async unlink(options) {
4351
+ const { tripRef, vehicleId, version, signal } = options;
4352
+ return client.execute({
4353
+ method: "DELETE",
4354
+ operationId: OperationId.UnlinkSeatingManager,
4355
+ path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}/manager",
4356
+ pathParams: { ref: tripRef, vehicleId },
4357
+ headers: { "If-Match": String(version) },
4358
+ ...signal !== void 0 ? { signal } : {}
4359
+ });
4360
+ }
4361
+ }
4362
+ }
4363
+ };
4364
+ }
4365
+
4366
+ // src/resources/share.ts
4367
+ function createShareResource(client) {
4368
+ return {
4369
+ async snapshot(options) {
4370
+ const { token, signal } = options;
4371
+ return client.execute({
4372
+ method: "GET",
4373
+ operationId: OperationId.GetShareSnapshot,
4374
+ path: "/api/v1/share/{token}",
4375
+ pathParams: { token },
4376
+ ...signal !== void 0 ? { signal } : {}
4377
+ });
4378
+ },
4379
+ async manifest(options) {
4380
+ const { token, signal } = options;
4381
+ return client.execute({
4382
+ method: "GET",
4383
+ operationId: OperationId.GetShareManifest,
4384
+ path: "/api/v1/share/{token}/manifest",
4385
+ pathParams: { token },
4386
+ ...signal !== void 0 ? { signal } : {}
4387
+ });
4388
+ },
4389
+ forms: {
4390
+ async list(options) {
4391
+ const { token, signal } = options;
4392
+ return client.execute({
1641
4393
  method: "GET",
1642
4394
  operationId: OperationId.ShareListForms,
1643
4395
  path: "/api/v1/share/{token}/forms",
@@ -1686,6 +4438,64 @@ function createShareResource(client) {
1686
4438
  };
1687
4439
  }
1688
4440
 
4441
+ // src/resources/treks.ts
4442
+ var ACTIVE_TREK_REF = "active";
4443
+ function createTreksResource(client) {
4444
+ return {
4445
+ async board(options) {
4446
+ const { trekRef, signal } = options;
4447
+ return client.execute({
4448
+ method: "GET",
4449
+ operationId: OperationId.ReadTrekBoard,
4450
+ path: "/api/v1/treks/{trekRef}/board",
4451
+ pathParams: { trekRef },
4452
+ ...signal !== void 0 ? { signal } : {}
4453
+ });
4454
+ },
4455
+ async postpone(options) {
4456
+ const { trekRef, idempotencyKey, signal, newStartDate, newEndDate, ...rest } = options;
4457
+ const body = {
4458
+ ...rest,
4459
+ newStartDate: normalizeDateTimeInput(newStartDate, "newStartDate"),
4460
+ newEndDate: normalizeDateTimeInput(newEndDate, "newEndDate")
4461
+ };
4462
+ return client.execute({
4463
+ method: "POST",
4464
+ operationId: OperationId.PostponeTrek,
4465
+ path: "/api/v1/treks/{trekRef}/postpone",
4466
+ pathParams: { trekRef },
4467
+ body,
4468
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4469
+ ...signal !== void 0 ? { signal } : {}
4470
+ });
4471
+ },
4472
+ walkIns: {
4473
+ async meta(options) {
4474
+ const { trekRef, signal } = options;
4475
+ return client.execute({
4476
+ method: "GET",
4477
+ operationId: OperationId.ReadTrekWalkInMeta,
4478
+ path: "/api/v1/treks/{trekRef}/walk-ins/meta",
4479
+ pathParams: { trekRef },
4480
+ ...signal !== void 0 ? { signal } : {}
4481
+ });
4482
+ },
4483
+ async create(options) {
4484
+ const { trekRef, idempotencyKey, signal, ...body } = options;
4485
+ return client.execute({
4486
+ method: "POST",
4487
+ operationId: OperationId.CreateTrekWalkIn,
4488
+ path: "/api/v1/treks/{trekRef}/walk-ins",
4489
+ pathParams: { trekRef },
4490
+ body,
4491
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
4492
+ ...signal !== void 0 ? { signal } : {}
4493
+ });
4494
+ }
4495
+ }
4496
+ };
4497
+ }
4498
+
1689
4499
  // src/resources/vendors.ts
1690
4500
  function createVendorsResource(client) {
1691
4501
  return {
@@ -1703,26 +4513,116 @@ function createVendorsResource(client) {
1703
4513
  }
1704
4514
 
1705
4515
  // src/generated/enums.ts
4516
+ var BoardStatus = {
4517
+ Boarded: "BOARDED",
4518
+ NoShow: "NO_SHOW"
4519
+ };
1706
4520
  var BookingStatus = {
1707
4521
  Confirmed: "CONFIRMED",
1708
4522
  Tentative: "TENTATIVE",
1709
4523
  Cancelled: "CANCELLED"
1710
4524
  };
4525
+ var ChecklistAudience = {
4526
+ Internal: "INTERNAL",
4527
+ External: "EXTERNAL"
4528
+ };
4529
+ var ChecklistGate = {
4530
+ None: "NONE",
4531
+ PreToActive: "PRE_TO_ACTIVE",
4532
+ ActiveToClosedOut: "ACTIVE_TO_CLOSED_OUT"
4533
+ };
4534
+ var ChecklistItemStatus = {
4535
+ Open: "OPEN",
4536
+ Complete: "COMPLETE"
4537
+ };
4538
+ var ChecklistPhase = {
4539
+ PreDeparture: "PRE_DEPARTURE",
4540
+ InTrip: "IN_TRIP",
4541
+ PostTrip: "POST_TRIP"
4542
+ };
4543
+ var ChecklistPullTemplateMode = {
4544
+ Append: "append",
4545
+ Replace: "replace"
4546
+ };
1711
4547
  var ClaimStatusIngest = {
1712
4548
  Approved: "APPROVED",
1713
4549
  Paid: "PAID",
1714
4550
  Rejected: "REJECTED"
1715
4551
  };
4552
+ var CloseoutPackSection = {
4553
+ Summary: "summary",
4554
+ Blockers: "blockers",
4555
+ Handover: "handover",
4556
+ Collections: "collections",
4557
+ Expenses: "expenses",
4558
+ Float: "float",
4559
+ Checklists: "checklists",
4560
+ Forms: "forms",
4561
+ Rooming: "rooming",
4562
+ Seating: "seating",
4563
+ Pickups: "pickups",
4564
+ Vendors: "vendors",
4565
+ Itinerary: "itinerary"
4566
+ };
4567
+ var CollectionMode = {
4568
+ Cash: "CASH",
4569
+ Upi: "UPI",
4570
+ Card: "CARD",
4571
+ Bank: "BANK"
4572
+ };
4573
+ var Currency = {
4574
+ Inr: "INR"
4575
+ };
1716
4576
  var EventType = {
1717
4577
  Trip: "TRIP",
1718
4578
  Trek: "TREK"
1719
4579
  };
4580
+ var ExpenseCategory = {
4581
+ Accom: "ACCOM",
4582
+ Food: "FOOD",
4583
+ Transport: "TRANSPORT",
4584
+ Activity: "ACTIVITY",
4585
+ Misc: "MISC"
4586
+ };
4587
+ var ExpensePaymentMode = {
4588
+ FloatCash: "FLOAT_CASH",
4589
+ Personal: "PERSONAL",
4590
+ Other: "OTHER"
4591
+ };
4592
+ var FileContentType = {
4593
+ ImageJpeg: "image/jpeg",
4594
+ ImagePng: "image/png",
4595
+ ImageWebp: "image/webp",
4596
+ ImageHeic: "image/heic",
4597
+ ApplicationPdf: "application/pdf"
4598
+ };
4599
+ var FilePurpose = {
4600
+ ExpenseReceipt: "expense_receipt",
4601
+ FormAttachment: "form_attachment",
4602
+ BookingVoucher: "booking_voucher"
4603
+ };
4604
+ var FloatDirection = {
4605
+ In: "IN",
4606
+ Out: "OUT"
4607
+ };
1720
4608
  var Gender = {
1721
4609
  Male: "MALE",
1722
4610
  Female: "FEMALE",
1723
4611
  Other: "OTHER",
1724
4612
  Unknown: "UNKNOWN"
1725
4613
  };
4614
+ var ItineraryItemStatusUpdate = {
4615
+ Planned: "PLANNED",
4616
+ Completed: "COMPLETED",
4617
+ Skipped: "SKIPPED"
4618
+ };
4619
+ var ItineraryItemType = {
4620
+ Accommodation: "ACCOMMODATION",
4621
+ Transport: "TRANSPORT",
4622
+ Activity: "ACTIVITY",
4623
+ Meal: "MEAL",
4624
+ Other: "OTHER"
4625
+ };
1726
4626
  var ManagerRole = {
1727
4627
  Manager: "MANAGER",
1728
4628
  Coordinator: "COORDINATOR"
@@ -1738,6 +4638,59 @@ var PartyKind = {
1738
4638
  Corporate: "CORPORATE",
1739
4639
  Other: "OTHER"
1740
4640
  };
4641
+ var PickupKind = {
4642
+ Pickup: "PICKUP",
4643
+ Drop: "DROP"
4644
+ };
4645
+ var RoomingFillOrder = {
4646
+ LargestRoomFirst: "LARGEST_ROOM_FIRST",
4647
+ Sequential: "SEQUENTIAL",
4648
+ Balanced: "BALANCED"
4649
+ };
4650
+ var RoomingGenderPolicy = {
4651
+ StrictSeparate: "STRICT_SEPARATE",
4652
+ GroupMixedOk: "GROUP_MIXED_OK",
4653
+ Off: "OFF"
4654
+ };
4655
+ var RoomingHeuristicKey = {
4656
+ MedicalFirst: "medicalFirst",
4657
+ Couples: "couples",
4658
+ Parties: "parties",
4659
+ Gender: "gender",
4660
+ Diet: "diet",
4661
+ SpreadSolos: "spreadSolos",
4662
+ PartyGenderPolicy: "partyGenderPolicy",
4663
+ SameBus: "sameBus"
4664
+ };
4665
+ var RoomType = {
4666
+ Single: "SINGLE",
4667
+ Twin: "TWIN",
4668
+ Shared: "SHARED",
4669
+ Dorm: "DORM"
4670
+ };
4671
+ var SeatingFillOrder = {
4672
+ Balanced: "BALANCED",
4673
+ FillFirst: "FILL_FIRST",
4674
+ ByStop: "BY_STOP"
4675
+ };
4676
+ var SeatingGenderAdjacency = {
4677
+ Off: "OFF",
4678
+ AvoidUnrelated: "AVOID_UNRELATED",
4679
+ StrictRows: "STRICT_ROWS"
4680
+ };
4681
+ var SeatingHeuristicKey = {
4682
+ MedicalFirst: "medicalFirst",
4683
+ Parties: "parties",
4684
+ SameStop: "sameStop",
4685
+ Gender: "gender",
4686
+ BalanceVehicles: "balanceVehicles"
4687
+ };
4688
+ var SyncOpMethod = {
4689
+ Post: "POST",
4690
+ Patch: "PATCH",
4691
+ Put: "PUT",
4692
+ Delete: "DELETE"
4693
+ };
1741
4694
  var TriggerAnchor = {
1742
4695
  Start: "START",
1743
4696
  End: "END"
@@ -1753,6 +4706,19 @@ var TripStatus = {
1753
4706
  Postponed: "POSTPONED",
1754
4707
  Cancelled: "CANCELLED"
1755
4708
  };
4709
+ var VehicleLayout = {
4710
+ TwoTwo: "TWO_TWO",
4711
+ TwoOne: "TWO_ONE",
4712
+ Flat: "FLAT"
4713
+ };
4714
+ var VehicleType = {
4715
+ Bus: "BUS",
4716
+ TempoTraveller: "TEMPO_TRAVELLER",
4717
+ Car: "CAR",
4718
+ Flight: "FLIGHT",
4719
+ Train: "TRAIN",
4720
+ Other: "OTHER"
4721
+ };
1756
4722
 
1757
4723
  // src/pagination/paginator.ts
1758
4724
  var KaafilPaginationError = class extends Error {
@@ -1776,6 +4742,200 @@ var KaafilPaginationExhaustedError = class _KaafilPaginationExhaustedError exten
1776
4742
  }
1777
4743
  };
1778
4744
 
4745
+ // src/rooming/vocabulary.ts
4746
+ var HEURISTIC_SEVERITY = Object.freeze({
4747
+ medicalFirst: "warn",
4748
+ couples: "warn",
4749
+ parties: "split",
4750
+ gender: "never",
4751
+ diet: "info",
4752
+ spreadSolos: "info",
4753
+ partyGenderPolicy: "info",
4754
+ sameBus: "info"
4755
+ });
4756
+ function isRoomingHeuristicKey(rule) {
4757
+ return Object.hasOwn(HEURISTIC_SEVERITY, rule);
4758
+ }
4759
+ function roomingHeuristicSeverity(rule) {
4760
+ return isRoomingHeuristicKey(rule) ? HEURISTIC_SEVERITY[rule] : void 0;
4761
+ }
4762
+ var TONE_FAMILIES = Object.freeze({
4763
+ [Gender.Male]: "male",
4764
+ [Gender.Female]: "female",
4765
+ [Gender.Other]: "other",
4766
+ [Gender.Unknown]: "unknown"
4767
+ });
4768
+ var UNKNOWN_TONE_FAMILY = TONE_FAMILIES[Gender.Unknown];
4769
+ var SHADES_PER_FAMILY = 8;
4770
+ var FALLBACK_GLYPH = "?";
4771
+ function parseRoomingTone(tone) {
4772
+ const separator = tone.lastIndexOf(".");
4773
+ if (separator <= 0 || separator === tone.length - 1) {
4774
+ return void 0;
4775
+ }
4776
+ const family = tone.slice(0, separator);
4777
+ const rawShade = tone.slice(separator + 1);
4778
+ const shade = Number(rawShade);
4779
+ if (!Number.isInteger(shade) || shade < 0) {
4780
+ return void 0;
4781
+ }
4782
+ return { family, shade };
4783
+ }
4784
+
4785
+ // src/storage/adapter.ts
4786
+ function createInMemoryStorageAdapter() {
4787
+ const store = /* @__PURE__ */ new Map();
4788
+ return {
4789
+ async get(key) {
4790
+ return store.get(key);
4791
+ },
4792
+ async set(key, value) {
4793
+ store.set(key, value);
4794
+ },
4795
+ async remove(key) {
4796
+ store.delete(key);
4797
+ },
4798
+ async clear() {
4799
+ store.clear();
4800
+ }
4801
+ };
4802
+ }
4803
+
4804
+ // src/storage/indexeddb.ts
4805
+ var STORE_NAME = "kv";
4806
+ var DEFAULT_DATABASE_PREFIX = "kaafil-js";
4807
+ var SCHEMA_VERSION = 1;
4808
+ var KaafilIndexedDbUnavailableError = class _KaafilIndexedDbUnavailableError extends Error {
4809
+ reason;
4810
+ constructor(reason, detail) {
4811
+ super(
4812
+ `IndexedDB is not usable in this runtime (${reason})${detail !== void 0 ? `: ${detail}` : ""}. No durable offline store was created. Supply your own KaafilStorageAdapter, or use createInMemoryStorageAdapter() and treat queued writes as process-lifetime only.`
4813
+ );
4814
+ this.name = "KaafilIndexedDbUnavailableError";
4815
+ Object.setPrototypeOf(this, _KaafilIndexedDbUnavailableError.prototype);
4816
+ this.reason = reason;
4817
+ }
4818
+ };
4819
+ function promisifyRequest(request) {
4820
+ return new Promise((resolve, reject) => {
4821
+ request.onsuccess = () => {
4822
+ resolve(request.result);
4823
+ };
4824
+ request.onerror = () => {
4825
+ reject(request.error ?? new Error("IndexedDB request failed with no error attached"));
4826
+ };
4827
+ });
4828
+ }
4829
+ async function openDatabase(factory, databaseName) {
4830
+ return new Promise((resolve, reject) => {
4831
+ let request;
4832
+ try {
4833
+ request = factory.open(databaseName, SCHEMA_VERSION);
4834
+ } catch (error) {
4835
+ reject(
4836
+ new KaafilIndexedDbUnavailableError(
4837
+ "open-failed",
4838
+ error instanceof Error ? error.message : String(error)
4839
+ )
4840
+ );
4841
+ return;
4842
+ }
4843
+ request.onupgradeneeded = () => {
4844
+ const db = request.result;
4845
+ if (!db.objectStoreNames.contains(STORE_NAME)) {
4846
+ db.createObjectStore(STORE_NAME);
4847
+ }
4848
+ };
4849
+ request.onsuccess = () => {
4850
+ const db = request.result;
4851
+ if (!db.objectStoreNames.contains(STORE_NAME)) {
4852
+ db.close();
4853
+ reject(new KaafilIndexedDbUnavailableError("open-failed", "object store missing"));
4854
+ return;
4855
+ }
4856
+ resolve(db);
4857
+ };
4858
+ request.onerror = () => {
4859
+ reject(
4860
+ new KaafilIndexedDbUnavailableError(
4861
+ "open-failed",
4862
+ request.error?.message ?? "open request failed"
4863
+ )
4864
+ );
4865
+ };
4866
+ request.onblocked = () => {
4867
+ reject(new KaafilIndexedDbUnavailableError("blocked"));
4868
+ };
4869
+ });
4870
+ }
4871
+ async function createIndexedDbStorageAdapter(options) {
4872
+ if (typeof options.scope !== "string" || options.scope.length === 0) {
4873
+ throw new TypeError(
4874
+ `"scope" is required and must be a non-empty string \u2014 an unscoped offline store lets one credential's queued writes drain under another's session.`
4875
+ );
4876
+ }
4877
+ const factory = options.indexedDB ?? globalThis.indexedDB;
4878
+ if (factory === void 0 || factory === null) {
4879
+ throw new KaafilIndexedDbUnavailableError("no-indexeddb");
4880
+ }
4881
+ const databaseName = `${options.databasePrefix ?? DEFAULT_DATABASE_PREFIX}:${options.scope}`;
4882
+ const db = await openDatabase(factory, databaseName);
4883
+ const onQuotaExceeded = options.onQuotaExceeded;
4884
+ async function write(run) {
4885
+ return new Promise((resolve, reject) => {
4886
+ let tx;
4887
+ try {
4888
+ tx = db.transaction(STORE_NAME, "readwrite");
4889
+ } catch (error) {
4890
+ reject(error);
4891
+ return;
4892
+ }
4893
+ tx.oncomplete = () => {
4894
+ resolve();
4895
+ };
4896
+ const fail = (error) => {
4897
+ if (error instanceof DOMException && error.name === "QuotaExceededError") {
4898
+ onQuotaExceeded?.(error);
4899
+ }
4900
+ reject(error ?? new Error("IndexedDB transaction failed with no error attached"));
4901
+ };
4902
+ tx.onerror = () => {
4903
+ fail(tx.error);
4904
+ };
4905
+ tx.onabort = () => {
4906
+ fail(tx.error);
4907
+ };
4908
+ try {
4909
+ run(tx.objectStore(STORE_NAME));
4910
+ } catch (error) {
4911
+ fail(error);
4912
+ }
4913
+ });
4914
+ }
4915
+ return {
4916
+ async get(key) {
4917
+ const tx = db.transaction(STORE_NAME, "readonly");
4918
+ const value = await promisifyRequest(tx.objectStore(STORE_NAME).get(key));
4919
+ return typeof value === "string" ? value : void 0;
4920
+ },
4921
+ async set(key, value) {
4922
+ await write((store) => {
4923
+ store.put(value, key);
4924
+ });
4925
+ },
4926
+ async remove(key) {
4927
+ await write((store) => {
4928
+ store.delete(key);
4929
+ });
4930
+ },
4931
+ async clear() {
4932
+ await write((store) => {
4933
+ store.clear();
4934
+ });
4935
+ }
4936
+ };
4937
+ }
4938
+
1779
4939
  // src/client-entry.ts
1780
4940
  function openTokenField(input) {
1781
4941
  switch (input.kind) {
@@ -1902,6 +5062,77 @@ var KaafilClient = class {
1902
5062
  get notifications() {
1903
5063
  return this.#requireState().notifications;
1904
5064
  }
5065
+ get itinerary() {
5066
+ return this.#requireState().itinerary;
5067
+ }
5068
+ get rooming() {
5069
+ return this.#requireState().rooming;
5070
+ }
5071
+ get seating() {
5072
+ return this.#requireState().seating;
5073
+ }
5074
+ get pickups() {
5075
+ return this.#requireState().pickups;
5076
+ }
5077
+ get treks() {
5078
+ return this.#requireState().treks;
5079
+ }
5080
+ get checklists() {
5081
+ return this.#requireState().checklists;
5082
+ }
5083
+ get float() {
5084
+ return this.#requireState().float;
5085
+ }
5086
+ get expenses() {
5087
+ return this.#requireState().expenses;
5088
+ }
5089
+ get collections() {
5090
+ return this.#requireState().collections;
5091
+ }
5092
+ get files() {
5093
+ return this.#requireState().files;
5094
+ }
5095
+ get closeout() {
5096
+ return this.#requireState().closeout;
5097
+ }
5098
+ get sync() {
5099
+ return this.#requireState().sync;
5100
+ }
5101
+ /**
5102
+ * Builds the offline layer on top of THIS open session — the durable
5103
+ * snapshot + outbox, the FIFO drainer, the reconciler, the blob lane and
5104
+ * the batched transport (`06-offline-first.md`).
5105
+ *
5106
+ * The transport is assembled here rather than by the caller, so the
5107
+ * automatic parts stay automatic: the op's fixed idempotency key, the
5108
+ * `If-Match` header, the single-vs-batched wire switch and the consolidated
5109
+ * pull are all wired from the session's own `KaafilHttpClient` and `sync`
5110
+ * resource. What the caller supplies is what only the caller can know — a
5111
+ * durable `storage` adapter for its platform, a `scope` for this
5112
+ * credential, optionally an entity re-reader for conflict reconciliation,
5113
+ * and optionally a conflict resolver (with none, every `409` surfaces,
5114
+ * which is the correct default: `06 §6` forbids auto-merging).
5115
+ *
5116
+ * Throws `KaafilClientNotOpenError` before a session is open — there is no
5117
+ * offline layer without a credential to scope it to.
5118
+ */
5119
+ openOffline(options) {
5120
+ const state = this.#requireState();
5121
+ const transport = createHttpOfflineTransport({
5122
+ http: state.http,
5123
+ sync: state.sync,
5124
+ ...options.readEntity !== void 0 ? { readEntity: options.readEntity } : {},
5125
+ ...options.share !== void 0 ? { credential: "share" } : {}
5126
+ });
5127
+ return createOfflineEngine({
5128
+ storage: options.storage,
5129
+ scope: options.scope,
5130
+ transport,
5131
+ ...options.conflictResolver !== void 0 ? { conflictResolver: options.conflictResolver } : {},
5132
+ ...options.blob !== void 0 ? { blob: options.blob } : {},
5133
+ ...options.share !== void 0 ? { share: options.share } : {}
5134
+ });
5135
+ }
1905
5136
  /**
1906
5137
  * Total teardown. One assignment, no field to forget — see
1907
5138
  * `KaafilClientState` above. Safe to call whether or not a session is
@@ -1970,7 +5201,19 @@ var KaafilClient = class {
1970
5201
  vendors: createVendorsResource(http),
1971
5202
  journey: createJourneyResource(http),
1972
5203
  share: createShareResource(http),
1973
- notifications: createNotificationsResource(http)
5204
+ notifications: createNotificationsResource(http),
5205
+ itinerary: createItineraryResource(http),
5206
+ rooming: createRoomingResource(http),
5207
+ seating: createSeatingResource(http),
5208
+ pickups: createPickupsResource(http),
5209
+ treks: createTreksResource(http),
5210
+ checklists: createChecklistsResource(http),
5211
+ float: createFloatResource(http),
5212
+ expenses: createExpensesResource(http),
5213
+ collections: createCollectionsResource(http),
5214
+ files: createFilesResource(http),
5215
+ closeout: createCloseoutResource(http),
5216
+ sync: createSyncResource(http)
1974
5217
  };
1975
5218
  }
1976
5219
  #requireState() {
@@ -1981,20 +5224,44 @@ var KaafilClient = class {
1981
5224
  }
1982
5225
  };
1983
5226
 
5227
+ exports.ACTIVE_TREK_REF = ACTIVE_TREK_REF;
5228
+ exports.BATCH_THRESHOLD_OPS = BATCH_THRESHOLD_OPS;
5229
+ exports.BlobStatus = BlobStatus;
5230
+ exports.BoardStatus = BoardStatus;
1984
5231
  exports.BookingStatus = BookingStatus;
5232
+ exports.CONSOLIDATED_PULL_THRESHOLD_LISTS = CONSOLIDATED_PULL_THRESHOLD_LISTS;
5233
+ exports.ChecklistAudience = ChecklistAudience;
5234
+ exports.ChecklistGate = ChecklistGate;
5235
+ exports.ChecklistItemStatus = ChecklistItemStatus;
5236
+ exports.ChecklistPhase = ChecklistPhase;
5237
+ exports.ChecklistPullTemplateMode = ChecklistPullTemplateMode;
1985
5238
  exports.ClaimStatusIngest = ClaimStatusIngest;
5239
+ exports.CloseoutPackSection = CloseoutPackSection;
5240
+ exports.CollectionMode = CollectionMode;
5241
+ exports.Currency = Currency;
1986
5242
  exports.ERROR_CODE_TABLE = ERROR_CODE_TABLE;
1987
5243
  exports.EventType = EventType;
5244
+ exports.ExpenseCategory = ExpenseCategory;
5245
+ exports.ExpensePaymentMode = ExpensePaymentMode;
5246
+ exports.FALLBACK_GLYPH = FALLBACK_GLYPH;
5247
+ exports.FileContentType = FileContentType;
5248
+ exports.FilePurpose = FilePurpose;
5249
+ exports.FloatDirection = FloatDirection;
1988
5250
  exports.Gender = Gender;
5251
+ exports.HEURISTIC_SEVERITY = HEURISTIC_SEVERITY;
5252
+ exports.ItineraryItemStatusUpdate = ItineraryItemStatusUpdate;
5253
+ exports.ItineraryItemType = ItineraryItemType;
1989
5254
  exports.KaafilAbortError = KaafilAbortError;
1990
5255
  exports.KaafilApiError = KaafilApiError;
1991
5256
  exports.KaafilCapabilityUnavailableError = KaafilCapabilityUnavailableError;
1992
5257
  exports.KaafilClient = KaafilClient;
1993
5258
  exports.KaafilClientAlreadyOpenError = KaafilClientAlreadyOpenError;
1994
5259
  exports.KaafilClientNotOpenError = KaafilClientNotOpenError;
5260
+ exports.KaafilDeltaCursorInFlightError = KaafilDeltaCursorInFlightError;
1995
5261
  exports.KaafilEntitlementError = KaafilEntitlementError;
1996
5262
  exports.KaafilError = KaafilError;
1997
5263
  exports.KaafilErrorCode = KaafilErrorCode;
5264
+ exports.KaafilIndexedDbUnavailableError = KaafilIndexedDbUnavailableError;
1998
5265
  exports.KaafilInvalidRequestError = KaafilInvalidRequestError;
1999
5266
  exports.KaafilLockedError = KaafilLockedError;
2000
5267
  exports.KaafilNetworkError = KaafilNetworkError;
@@ -2005,6 +5272,8 @@ exports.KaafilPaginationExhaustedError = KaafilPaginationExhaustedError;
2005
5272
  exports.KaafilPaginationInFlightError = KaafilPaginationInFlightError;
2006
5273
  exports.KaafilRateLimitedError = KaafilRateLimitedError;
2007
5274
  exports.KaafilReadOnlyRoleError = KaafilReadOnlyRoleError;
5275
+ exports.KaafilShareBatchUnauthenticatedError = KaafilShareBatchUnauthenticatedError;
5276
+ exports.KaafilShareLinkExpiredError = KaafilShareLinkExpiredError;
2008
5277
  exports.KaafilShareTokenExpiredError = KaafilShareTokenExpiredError;
2009
5278
  exports.KaafilShareTokenRevokedError = KaafilShareTokenRevokedError;
2010
5279
  exports.KaafilTimeoutError = KaafilTimeoutError;
@@ -2012,16 +5281,58 @@ exports.KaafilTransportError = KaafilTransportError;
2012
5281
  exports.KaafilUnauthenticatedError = KaafilUnauthenticatedError;
2013
5282
  exports.KaafilValidationError = KaafilValidationError;
2014
5283
  exports.KaafilVersionConflictError = KaafilVersionConflictError;
5284
+ exports.MAX_BATCH_OPS = MAX_BATCH_OPS;
2015
5285
  exports.ManagerRole = ManagerRole;
2016
5286
  exports.ManifestMode = ManifestMode;
2017
5287
  exports.OutboxClass = OutboxClass;
5288
+ exports.OutboxRetryCause = OutboxRetryCause;
5289
+ exports.OutboxStatus = OutboxStatus;
2018
5290
  exports.PartyKind = PartyKind;
5291
+ exports.PickupKind = PickupKind;
2019
5292
  exports.Retryability = Retryability;
5293
+ exports.RoomType = RoomType;
5294
+ exports.RoomingFillOrder = RoomingFillOrder;
5295
+ exports.RoomingGenderPolicy = RoomingGenderPolicy;
5296
+ exports.RoomingHeuristicKey = RoomingHeuristicKey;
5297
+ exports.SHADES_PER_FAMILY = SHADES_PER_FAMILY;
5298
+ exports.SHARE_WRITE_GRACE_MS = SHARE_WRITE_GRACE_MS;
5299
+ exports.SYNC_PULL_SECTIONS = SYNC_PULL_SECTIONS;
5300
+ exports.SeatingFillOrder = SeatingFillOrder;
5301
+ exports.SeatingGenderAdjacency = SeatingGenderAdjacency;
5302
+ exports.SeatingHeuristicKey = SeatingHeuristicKey;
5303
+ exports.SyncOpMethod = SyncOpMethod;
5304
+ exports.TONE_FAMILIES = TONE_FAMILIES;
2020
5305
  exports.TriggerAnchor = TriggerAnchor;
2021
5306
  exports.TripMode = TripMode;
2022
5307
  exports.TripStatus = TripStatus;
5308
+ exports.UNKNOWN_TONE_FAMILY = UNKNOWN_TONE_FAMILY;
2023
5309
  exports.UnsatisfiableSchemeError = UnsatisfiableSchemeError;
5310
+ exports.VehicleLayout = VehicleLayout;
5311
+ exports.VehicleType = VehicleType;
5312
+ exports.createBlobLane = createBlobLane;
5313
+ exports.createDeltaCursor = createDeltaCursor;
5314
+ exports.createDrainer = createDrainer;
5315
+ exports.createHttpOfflineTransport = createHttpOfflineTransport;
5316
+ exports.createInMemoryStorageAdapter = createInMemoryStorageAdapter;
5317
+ exports.createIndexedDbStorageAdapter = createIndexedDbStorageAdapter;
5318
+ exports.createOfflineEngine = createOfflineEngine;
5319
+ exports.createOfflineEvents = createOfflineEvents;
5320
+ exports.createOutbox = createOutbox;
5321
+ exports.createPullCoordinator = createPullCoordinator;
5322
+ exports.createShareGuard = createShareGuard;
5323
+ exports.createSnapshotStore = createSnapshotStore;
5324
+ exports.createSyncResource = createSyncResource;
5325
+ exports.extractSectionRows = extractSectionRows;
2024
5326
  exports.isKaafilError = isKaafilError;
2025
5327
  exports.isRetryable = isRetryable;
5328
+ exports.isRoomingHeuristicKey = isRoomingHeuristicKey;
5329
+ exports.isShareBatchPushAvailable = isShareBatchPushAvailable;
5330
+ exports.isTombstone = isTombstone;
5331
+ exports.mergeDeltaRows = mergeDeltaRows;
5332
+ exports.parseRoomingTone = parseRoomingTone;
5333
+ exports.readCurrentVersion = readCurrentVersion;
5334
+ exports.reconcileConflict = reconcileConflict;
5335
+ exports.roomingHeuristicSeverity = roomingHeuristicSeverity;
5336
+ exports.shouldUseBatchTransport = shouldUseBatchTransport;
2026
5337
  //# sourceMappingURL=client-entry.cjs.map
2027
5338
  //# sourceMappingURL=client-entry.cjs.map