kaafil-js 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/client-entry.cjs +1782 -0
- package/dist/client-entry.cjs.map +1 -0
- package/dist/client-entry.d.cts +187 -0
- package/dist/client-entry.d.ts +187 -0
- package/dist/client-entry.js +1739 -0
- package/dist/client-entry.js.map +1 -0
- package/dist/index.cjs +3541 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2311 -0
- package/dist/index.d.ts +2311 -0
- package/dist/index.js +3458 -0
- package/dist/index.js.map +1 -0
- package/dist/paginator-CE9JhsLi.d.cts +24009 -0
- package/dist/paginator-CE9JhsLi.d.ts +24009 -0
- package/package.json +75 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3541 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/generated/security.ts
|
|
4
|
+
var SecuritySchemeId = {
|
|
5
|
+
AgencyAdminAuth: "agencyAdminAuth",
|
|
6
|
+
ApiKeyAuth: "apiKeyAuth",
|
|
7
|
+
ManagerAuth: "managerAuth",
|
|
8
|
+
ShareAuth: "shareAuth"
|
|
9
|
+
};
|
|
10
|
+
var SECURITY_SCHEME_CARRIERS = {
|
|
11
|
+
agencyAdminAuth: { kind: "bearer" },
|
|
12
|
+
apiKeyAuth: { kind: "header", headerName: "X-API-Key" },
|
|
13
|
+
consoleAuth: { kind: "cookie", cookieName: "kaafil_console_session" },
|
|
14
|
+
managerAuth: { kind: "bearer" },
|
|
15
|
+
platformAdminAuth: { kind: "bearer" },
|
|
16
|
+
shareAuth: { kind: "bearer" }
|
|
17
|
+
};
|
|
18
|
+
var OperationId = {
|
|
19
|
+
AddChecklistItem: "addChecklistItem",
|
|
20
|
+
AddItineraryItem: "addItineraryItem",
|
|
21
|
+
AdjustFloat: "adjustFloat",
|
|
22
|
+
AssignManager: "assignManager",
|
|
23
|
+
AssignPickupTraveller: "assignPickupTraveller",
|
|
24
|
+
AssignRoomingBed: "assignRoomingBed",
|
|
25
|
+
AssignSeating: "assignSeating",
|
|
26
|
+
AutoAssignRooming: "autoAssignRooming",
|
|
27
|
+
AutoAssignSeating: "autoAssignSeating",
|
|
28
|
+
BoardPickupTraveller: "boardPickupTraveller",
|
|
29
|
+
CancelTrip: "cancelTrip",
|
|
30
|
+
ClaimStatusIngest: "claimStatusIngest",
|
|
31
|
+
ClosePickupStop: "closePickupStop",
|
|
32
|
+
ConfirmFileUpload: "confirmFileUpload",
|
|
33
|
+
CreatePickupStop: "createPickupStop",
|
|
34
|
+
CreateRoomingRoom: "createRoomingRoom",
|
|
35
|
+
CreateRoomingStayWindow: "createRoomingStayWindow",
|
|
36
|
+
CreateSeatingVehicle: "createSeatingVehicle",
|
|
37
|
+
CreateTrekWalkIn: "createTrekWalkIn",
|
|
38
|
+
DeleteChecklistItem: "deleteChecklistItem",
|
|
39
|
+
DeleteItineraryItem: "deleteItineraryItem",
|
|
40
|
+
DeletePickupStop: "deletePickupStop",
|
|
41
|
+
DeleteRoomingRoom: "deleteRoomingRoom",
|
|
42
|
+
DeleteRoomingStayWindow: "deleteRoomingStayWindow",
|
|
43
|
+
DeleteSeatingVehicle: "deleteSeatingVehicle",
|
|
44
|
+
GetTrip: "getTrip",
|
|
45
|
+
IssueFloat: "issueFloat",
|
|
46
|
+
LinkExpenseReceipt: "linkExpenseReceipt",
|
|
47
|
+
LinkSeatingManager: "linkSeatingManager",
|
|
48
|
+
ListChecklistTemplates: "listChecklistTemplates",
|
|
49
|
+
ListCollections: "listCollections",
|
|
50
|
+
ListEligibleCollections: "listEligibleCollections",
|
|
51
|
+
ListEvents: "listEvents",
|
|
52
|
+
ListExpenses: "listExpenses",
|
|
53
|
+
ListJourneyTriggers: "listJourneyTriggers",
|
|
54
|
+
ListPickupStops: "listPickupStops",
|
|
55
|
+
ListRoomingStayWindows: "listRoomingStayWindows",
|
|
56
|
+
ListTripVendors: "listTripVendors",
|
|
57
|
+
ListWebhookDeliveries: "listWebhookDeliveries",
|
|
58
|
+
LogExpense: "logExpense",
|
|
59
|
+
MintAgencyAdminTokens: "mintAgencyAdminTokens",
|
|
60
|
+
MintManagerTokens: "mintManagerTokens",
|
|
61
|
+
MintShareToken: "mintShareToken",
|
|
62
|
+
PatchChecklistItem: "patchChecklistItem",
|
|
63
|
+
PatchItineraryDay: "patchItineraryDay",
|
|
64
|
+
PatchItineraryItem: "patchItineraryItem",
|
|
65
|
+
PatchJourneyTrigger: "patchJourneyTrigger",
|
|
66
|
+
PatchPickupStop: "patchPickupStop",
|
|
67
|
+
PatchRoomingRoom: "patchRoomingRoom",
|
|
68
|
+
PatchRoomingStayWindow: "patchRoomingStayWindow",
|
|
69
|
+
PatchSeatingVehicle: "patchSeatingVehicle",
|
|
70
|
+
PostponeTrek: "postponeTrek",
|
|
71
|
+
PullChecklistTemplate: "pullChecklistTemplate",
|
|
72
|
+
PushBulkTrips: "pushBulkTrips",
|
|
73
|
+
PushManifest: "pushManifest",
|
|
74
|
+
PushTripBalances: "pushTripBalances",
|
|
75
|
+
ReadChecklistAggregate: "readChecklistAggregate",
|
|
76
|
+
ReadExpense: "readExpense",
|
|
77
|
+
ReadFile: "readFile",
|
|
78
|
+
ReadFileUrl: "readFileUrl",
|
|
79
|
+
ReadFloatLedger: "readFloatLedger",
|
|
80
|
+
ReadFloatSummary: "readFloatSummary",
|
|
81
|
+
ReadItinerary: "readItinerary",
|
|
82
|
+
ReadItineraryChangeLog: "readItineraryChangeLog",
|
|
83
|
+
ReadJourney: "readJourney",
|
|
84
|
+
ReadJourneyCapabilities: "readJourneyCapabilities",
|
|
85
|
+
ReadManifestByPickup: "readManifestByPickup",
|
|
86
|
+
ReadRoomingBoard: "readRoomingBoard",
|
|
87
|
+
ReadSeatingBoard: "readSeatingBoard",
|
|
88
|
+
ReadShareToken: "readShareToken",
|
|
89
|
+
ReadTrekBoard: "readTrekBoard",
|
|
90
|
+
ReadTrekWalkInMeta: "readTrekWalkInMeta",
|
|
91
|
+
ReadWebhookDelivery: "readWebhookDelivery",
|
|
92
|
+
RebuildJourney: "rebuildJourney",
|
|
93
|
+
RecordCollection: "recordCollection",
|
|
94
|
+
RedeliverWebhookDelivery: "redeliverWebhookDelivery",
|
|
95
|
+
RemoveFromManifest: "removeFromManifest",
|
|
96
|
+
ReopenPickupStop: "reopenPickupStop",
|
|
97
|
+
ReorderItineraryItem: "reorderItineraryItem",
|
|
98
|
+
ReorderPickupStops: "reorderPickupStops",
|
|
99
|
+
ReplayWebhookEndpoint: "replayWebhookEndpoint",
|
|
100
|
+
RequestFileUpload: "requestFileUpload",
|
|
101
|
+
ReturnFloat: "returnFloat",
|
|
102
|
+
RevokeShareToken: "revokeShareToken",
|
|
103
|
+
RunJourneyStep: "runJourneyStep",
|
|
104
|
+
SubmitExpenseClaim: "submitExpenseClaim",
|
|
105
|
+
ToggleChecklistItem: "toggleChecklistItem",
|
|
106
|
+
UnassignManager: "unassignManager",
|
|
107
|
+
UnlinkSeatingManager: "unlinkSeatingManager",
|
|
108
|
+
UpsertManager: "upsertManager",
|
|
109
|
+
UpsertTravellerProfile: "upsertTravellerProfile",
|
|
110
|
+
UpsertTrip: "upsertTrip",
|
|
111
|
+
VoidCollection: "voidCollection",
|
|
112
|
+
VoidExpense: "voidExpense",
|
|
113
|
+
WithdrawExpenseClaim: "withdrawExpenseClaim"
|
|
114
|
+
};
|
|
115
|
+
var OPERATION_SECURITY = {
|
|
116
|
+
acceptConsoleInvite: [],
|
|
117
|
+
acceptPlatformAdminInvite: [],
|
|
118
|
+
addChecklistItem: ["managerAuth"],
|
|
119
|
+
addItineraryItem: ["managerAuth"],
|
|
120
|
+
adjustFloat: ["managerAuth", "apiKeyAuth", "agencyAdminAuth"],
|
|
121
|
+
assignManager: ["apiKeyAuth"],
|
|
122
|
+
assignPickupTraveller: ["managerAuth"],
|
|
123
|
+
assignRoomingBed: ["managerAuth"],
|
|
124
|
+
assignSeating: ["managerAuth"],
|
|
125
|
+
autoAssignRooming: ["managerAuth"],
|
|
126
|
+
autoAssignSeating: ["managerAuth"],
|
|
127
|
+
boardPickupTraveller: ["managerAuth"],
|
|
128
|
+
cancelTrip: ["apiKeyAuth"],
|
|
129
|
+
changeOwnPlatformPassword: ["platformAdminAuth"],
|
|
130
|
+
claimStatusIngest: ["apiKeyAuth"],
|
|
131
|
+
closePickupStop: ["managerAuth"],
|
|
132
|
+
confirmFileUpload: ["managerAuth"],
|
|
133
|
+
consoleLogin: [],
|
|
134
|
+
consoleLogout: ["consoleAuth"],
|
|
135
|
+
consoleSwitchPlane: ["consoleAuth"],
|
|
136
|
+
createApiKey: ["consoleAuth"],
|
|
137
|
+
createConsoleUser: ["consoleAuth"],
|
|
138
|
+
createPickupStop: ["managerAuth"],
|
|
139
|
+
createPlatformAdmin: ["platformAdminAuth"],
|
|
140
|
+
createPlatformPartner: ["platformAdminAuth"],
|
|
141
|
+
createPlatformPartnerConsoleUser: ["platformAdminAuth"],
|
|
142
|
+
createRoomingRoom: ["managerAuth"],
|
|
143
|
+
createRoomingStayWindow: ["managerAuth"],
|
|
144
|
+
createSeatingVehicle: ["managerAuth"],
|
|
145
|
+
createTrekWalkIn: ["managerAuth"],
|
|
146
|
+
deleteChecklistItem: ["managerAuth"],
|
|
147
|
+
deleteItineraryItem: ["managerAuth"],
|
|
148
|
+
deletePickupStop: ["managerAuth"],
|
|
149
|
+
deletePlatformPartnerPlan: ["platformAdminAuth"],
|
|
150
|
+
deleteRoomingRoom: ["managerAuth"],
|
|
151
|
+
deleteRoomingStayWindow: ["managerAuth"],
|
|
152
|
+
deleteSeatingVehicle: ["managerAuth"],
|
|
153
|
+
editWebhookEndpoint: ["consoleAuth"],
|
|
154
|
+
getTrip: ["apiKeyAuth"],
|
|
155
|
+
health: [],
|
|
156
|
+
healthV1: [],
|
|
157
|
+
inspectConsoleInvite: [],
|
|
158
|
+
inspectPlatformAdminInvite: [],
|
|
159
|
+
issueFloat: ["managerAuth", "apiKeyAuth", "agencyAdminAuth"],
|
|
160
|
+
linkExpenseReceipt: ["managerAuth"],
|
|
161
|
+
linkSeatingManager: ["managerAuth"],
|
|
162
|
+
listAgencies: ["consoleAuth"],
|
|
163
|
+
listApiKeys: ["consoleAuth"],
|
|
164
|
+
listChecklistTemplates: ["managerAuth", "apiKeyAuth"],
|
|
165
|
+
listCollections: ["managerAuth", "apiKeyAuth"],
|
|
166
|
+
listConsoleTrips: ["consoleAuth"],
|
|
167
|
+
listConsoleUsers: ["consoleAuth"],
|
|
168
|
+
listEligibleCollections: ["managerAuth", "apiKeyAuth"],
|
|
169
|
+
listEvents: ["apiKeyAuth"],
|
|
170
|
+
listExpenses: ["managerAuth", "apiKeyAuth"],
|
|
171
|
+
listJourneyTriggers: ["apiKeyAuth", "agencyAdminAuth"],
|
|
172
|
+
listPickupStops: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
173
|
+
listPlatformAdmins: ["platformAdminAuth"],
|
|
174
|
+
listPlatformPartnerApiKeys: ["platformAdminAuth"],
|
|
175
|
+
listPlatformPartnerConsoleUsers: ["platformAdminAuth"],
|
|
176
|
+
listPlatformPartners: ["platformAdminAuth"],
|
|
177
|
+
listRoomingStayWindows: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
178
|
+
listTripVendors: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
|
|
179
|
+
listWebhookDeliveries: ["apiKeyAuth"],
|
|
180
|
+
listWebhookEndpoints: ["consoleAuth"],
|
|
181
|
+
logExpense: ["managerAuth"],
|
|
182
|
+
mintAgencyAdminTokens: ["apiKeyAuth"],
|
|
183
|
+
mintManagerTokens: ["apiKeyAuth"],
|
|
184
|
+
mintShareToken: ["apiKeyAuth"],
|
|
185
|
+
patchAgencyEntitlement: ["consoleAuth"],
|
|
186
|
+
patchChecklistItem: ["managerAuth"],
|
|
187
|
+
patchConsoleUser: ["consoleAuth"],
|
|
188
|
+
patchItineraryDay: ["managerAuth"],
|
|
189
|
+
patchItineraryItem: ["managerAuth"],
|
|
190
|
+
patchJourneyTrigger: ["apiKeyAuth", "agencyAdminAuth"],
|
|
191
|
+
patchPickupStop: ["managerAuth"],
|
|
192
|
+
patchPlatformAdmin: ["platformAdminAuth"],
|
|
193
|
+
patchPlatformPartnerConsoleUser: ["platformAdminAuth"],
|
|
194
|
+
patchRoomingRoom: ["managerAuth"],
|
|
195
|
+
patchRoomingStayWindow: ["managerAuth"],
|
|
196
|
+
patchSeatingVehicle: ["managerAuth"],
|
|
197
|
+
platformLogin: [],
|
|
198
|
+
platformLogout: ["platformAdminAuth"],
|
|
199
|
+
platformMe: ["platformAdminAuth"],
|
|
200
|
+
platformRefreshTokens: ["platformAdminAuth"],
|
|
201
|
+
postponeTrek: ["managerAuth"],
|
|
202
|
+
pullChecklistTemplate: ["managerAuth"],
|
|
203
|
+
pushBulkTrips: ["apiKeyAuth"],
|
|
204
|
+
pushManifest: ["apiKeyAuth"],
|
|
205
|
+
pushTripBalances: ["apiKeyAuth"],
|
|
206
|
+
putPlatformPartnerPlan: ["platformAdminAuth"],
|
|
207
|
+
readAgencyEntitlement: ["consoleAuth"],
|
|
208
|
+
readApiKey: ["consoleAuth"],
|
|
209
|
+
readChecklistAggregate: ["managerAuth", "apiKeyAuth"],
|
|
210
|
+
readConsoleAudit: ["consoleAuth"],
|
|
211
|
+
readConsoleChecklist: ["consoleAuth"],
|
|
212
|
+
readConsoleItinerary: ["consoleAuth"],
|
|
213
|
+
readConsolePickups: ["consoleAuth"],
|
|
214
|
+
readConsoleRooming: ["consoleAuth"],
|
|
215
|
+
readConsoleSeating: ["consoleAuth"],
|
|
216
|
+
readConsoleUserInvite: ["consoleAuth"],
|
|
217
|
+
readEndpointDeliveries: ["consoleAuth"],
|
|
218
|
+
readEndpointDelivery: ["consoleAuth"],
|
|
219
|
+
readEntitlementCatalog: ["consoleAuth"],
|
|
220
|
+
readExpense: ["managerAuth", "apiKeyAuth"],
|
|
221
|
+
readFile: ["managerAuth", "apiKeyAuth"],
|
|
222
|
+
readFileUrl: ["managerAuth", "apiKeyAuth"],
|
|
223
|
+
readFloatLedger: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
224
|
+
readFloatSummary: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
225
|
+
readIngestLog: ["consoleAuth"],
|
|
226
|
+
readItinerary: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
|
|
227
|
+
readItineraryChangeLog: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
|
|
228
|
+
readJourney: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
|
|
229
|
+
readJourneyCapabilities: ["apiKeyAuth", "managerAuth", "agencyAdminAuth"],
|
|
230
|
+
readManifestByPickup: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
231
|
+
readPlan: ["consoleAuth"],
|
|
232
|
+
readPlatformPartner: ["platformAdminAuth"],
|
|
233
|
+
readRoomingBoard: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
234
|
+
readSeatingBoard: ["managerAuth", "agencyAdminAuth", "apiKeyAuth"],
|
|
235
|
+
readShareToken: ["apiKeyAuth"],
|
|
236
|
+
readTrekBoard: ["managerAuth", "apiKeyAuth"],
|
|
237
|
+
readTrekWalkInMeta: ["managerAuth", "apiKeyAuth"],
|
|
238
|
+
readUsage: ["consoleAuth"],
|
|
239
|
+
readWebhookDelivery: ["apiKeyAuth"],
|
|
240
|
+
readWebhookEndpoint: ["consoleAuth"],
|
|
241
|
+
rebuildJourney: ["apiKeyAuth"],
|
|
242
|
+
recordCollection: ["managerAuth"],
|
|
243
|
+
redeliverEndpointDelivery: ["consoleAuth"],
|
|
244
|
+
redeliverWebhookDelivery: ["apiKeyAuth"],
|
|
245
|
+
refreshAgencyAdminTokens: ["agencyAdminAuth"],
|
|
246
|
+
refreshManagerTokens: ["managerAuth"],
|
|
247
|
+
registerWebhookEndpoint: ["consoleAuth"],
|
|
248
|
+
reissueConsoleUserInvite: ["consoleAuth"],
|
|
249
|
+
reissuePlatformAdminInvite: ["platformAdminAuth"],
|
|
250
|
+
reissuePlatformPartnerConsoleUserInvite: ["platformAdminAuth"],
|
|
251
|
+
removeFromManifest: ["apiKeyAuth"],
|
|
252
|
+
renamePlatformPartner: ["platformAdminAuth"],
|
|
253
|
+
reopenPickupStop: ["managerAuth"],
|
|
254
|
+
reorderItineraryItem: ["managerAuth"],
|
|
255
|
+
reorderPickupStops: ["managerAuth"],
|
|
256
|
+
replayWebhookEndpoint: ["apiKeyAuth"],
|
|
257
|
+
requestFileUpload: ["managerAuth"],
|
|
258
|
+
resetPlatformPartnerConsoleUser: ["platformAdminAuth"],
|
|
259
|
+
returnFloat: ["managerAuth"],
|
|
260
|
+
revokeApiKey: ["consoleAuth"],
|
|
261
|
+
revokePlatformPartnerApiKey: ["platformAdminAuth"],
|
|
262
|
+
revokeShareToken: ["apiKeyAuth"],
|
|
263
|
+
rotateApiKey: ["consoleAuth"],
|
|
264
|
+
rotateWebhookEndpointSecret: ["consoleAuth"],
|
|
265
|
+
runJourneyStep: ["apiKeyAuth"],
|
|
266
|
+
setPlatformPartnerStatus: ["platformAdminAuth"],
|
|
267
|
+
submitExpenseClaim: ["managerAuth"],
|
|
268
|
+
toggleChecklistItem: ["managerAuth"],
|
|
269
|
+
unassignManager: ["apiKeyAuth"],
|
|
270
|
+
unlinkSeatingManager: ["managerAuth"],
|
|
271
|
+
upsertAgencyAdmin: ["apiKeyAuth"],
|
|
272
|
+
upsertManager: ["apiKeyAuth"],
|
|
273
|
+
upsertTravellerProfile: ["apiKeyAuth"],
|
|
274
|
+
upsertTrip: ["apiKeyAuth"],
|
|
275
|
+
voidCollection: ["managerAuth"],
|
|
276
|
+
voidExpense: ["managerAuth"],
|
|
277
|
+
withdrawExpenseClaim: ["managerAuth"]
|
|
278
|
+
};
|
|
279
|
+
var OPERATION_ACCEPTS_IDEMPOTENCY_KEY = {
|
|
280
|
+
acceptConsoleInvite: true,
|
|
281
|
+
acceptPlatformAdminInvite: true,
|
|
282
|
+
addChecklistItem: true,
|
|
283
|
+
addItineraryItem: true,
|
|
284
|
+
adjustFloat: true,
|
|
285
|
+
assignManager: true,
|
|
286
|
+
assignPickupTraveller: true,
|
|
287
|
+
assignRoomingBed: true,
|
|
288
|
+
assignSeating: true,
|
|
289
|
+
autoAssignRooming: true,
|
|
290
|
+
autoAssignSeating: true,
|
|
291
|
+
boardPickupTraveller: true,
|
|
292
|
+
cancelTrip: true,
|
|
293
|
+
changeOwnPlatformPassword: false,
|
|
294
|
+
claimStatusIngest: true,
|
|
295
|
+
closePickupStop: true,
|
|
296
|
+
confirmFileUpload: true,
|
|
297
|
+
consoleLogin: false,
|
|
298
|
+
consoleLogout: false,
|
|
299
|
+
consoleSwitchPlane: false,
|
|
300
|
+
createApiKey: true,
|
|
301
|
+
createConsoleUser: true,
|
|
302
|
+
createPickupStop: true,
|
|
303
|
+
createPlatformAdmin: false,
|
|
304
|
+
createPlatformPartner: false,
|
|
305
|
+
createPlatformPartnerConsoleUser: false,
|
|
306
|
+
createRoomingRoom: true,
|
|
307
|
+
createRoomingStayWindow: true,
|
|
308
|
+
createSeatingVehicle: true,
|
|
309
|
+
createTrekWalkIn: true,
|
|
310
|
+
deleteChecklistItem: false,
|
|
311
|
+
deleteItineraryItem: false,
|
|
312
|
+
deletePickupStop: false,
|
|
313
|
+
deletePlatformPartnerPlan: false,
|
|
314
|
+
deleteRoomingRoom: false,
|
|
315
|
+
deleteRoomingStayWindow: false,
|
|
316
|
+
deleteSeatingVehicle: false,
|
|
317
|
+
editWebhookEndpoint: true,
|
|
318
|
+
getTrip: false,
|
|
319
|
+
health: false,
|
|
320
|
+
healthV1: false,
|
|
321
|
+
inspectConsoleInvite: false,
|
|
322
|
+
inspectPlatformAdminInvite: false,
|
|
323
|
+
issueFloat: true,
|
|
324
|
+
linkExpenseReceipt: true,
|
|
325
|
+
linkSeatingManager: true,
|
|
326
|
+
listAgencies: false,
|
|
327
|
+
listApiKeys: false,
|
|
328
|
+
listChecklistTemplates: false,
|
|
329
|
+
listCollections: false,
|
|
330
|
+
listConsoleTrips: false,
|
|
331
|
+
listConsoleUsers: false,
|
|
332
|
+
listEligibleCollections: false,
|
|
333
|
+
listEvents: false,
|
|
334
|
+
listExpenses: false,
|
|
335
|
+
listJourneyTriggers: false,
|
|
336
|
+
listPickupStops: false,
|
|
337
|
+
listPlatformAdmins: false,
|
|
338
|
+
listPlatformPartnerApiKeys: false,
|
|
339
|
+
listPlatformPartnerConsoleUsers: false,
|
|
340
|
+
listPlatformPartners: false,
|
|
341
|
+
listRoomingStayWindows: false,
|
|
342
|
+
listTripVendors: false,
|
|
343
|
+
listWebhookDeliveries: false,
|
|
344
|
+
listWebhookEndpoints: false,
|
|
345
|
+
logExpense: true,
|
|
346
|
+
mintAgencyAdminTokens: false,
|
|
347
|
+
mintManagerTokens: false,
|
|
348
|
+
mintShareToken: true,
|
|
349
|
+
patchAgencyEntitlement: true,
|
|
350
|
+
patchChecklistItem: false,
|
|
351
|
+
patchConsoleUser: true,
|
|
352
|
+
patchItineraryDay: false,
|
|
353
|
+
patchItineraryItem: false,
|
|
354
|
+
patchJourneyTrigger: true,
|
|
355
|
+
patchPickupStop: false,
|
|
356
|
+
patchPlatformAdmin: false,
|
|
357
|
+
patchPlatformPartnerConsoleUser: false,
|
|
358
|
+
patchRoomingRoom: false,
|
|
359
|
+
patchRoomingStayWindow: false,
|
|
360
|
+
patchSeatingVehicle: false,
|
|
361
|
+
platformLogin: true,
|
|
362
|
+
platformLogout: false,
|
|
363
|
+
platformMe: false,
|
|
364
|
+
platformRefreshTokens: true,
|
|
365
|
+
postponeTrek: true,
|
|
366
|
+
pullChecklistTemplate: true,
|
|
367
|
+
pushBulkTrips: true,
|
|
368
|
+
pushManifest: true,
|
|
369
|
+
pushTripBalances: true,
|
|
370
|
+
putPlatformPartnerPlan: false,
|
|
371
|
+
readAgencyEntitlement: false,
|
|
372
|
+
readApiKey: false,
|
|
373
|
+
readChecklistAggregate: false,
|
|
374
|
+
readConsoleAudit: false,
|
|
375
|
+
readConsoleChecklist: false,
|
|
376
|
+
readConsoleItinerary: false,
|
|
377
|
+
readConsolePickups: false,
|
|
378
|
+
readConsoleRooming: false,
|
|
379
|
+
readConsoleSeating: false,
|
|
380
|
+
readConsoleUserInvite: false,
|
|
381
|
+
readEndpointDeliveries: false,
|
|
382
|
+
readEndpointDelivery: false,
|
|
383
|
+
readEntitlementCatalog: false,
|
|
384
|
+
readExpense: false,
|
|
385
|
+
readFile: false,
|
|
386
|
+
readFileUrl: false,
|
|
387
|
+
readFloatLedger: false,
|
|
388
|
+
readFloatSummary: false,
|
|
389
|
+
readIngestLog: false,
|
|
390
|
+
readItinerary: false,
|
|
391
|
+
readItineraryChangeLog: false,
|
|
392
|
+
readJourney: false,
|
|
393
|
+
readJourneyCapabilities: false,
|
|
394
|
+
readManifestByPickup: false,
|
|
395
|
+
readPlan: false,
|
|
396
|
+
readPlatformPartner: false,
|
|
397
|
+
readRoomingBoard: false,
|
|
398
|
+
readSeatingBoard: false,
|
|
399
|
+
readShareToken: false,
|
|
400
|
+
readTrekBoard: false,
|
|
401
|
+
readTrekWalkInMeta: false,
|
|
402
|
+
readUsage: false,
|
|
403
|
+
readWebhookDelivery: false,
|
|
404
|
+
readWebhookEndpoint: false,
|
|
405
|
+
rebuildJourney: true,
|
|
406
|
+
recordCollection: true,
|
|
407
|
+
redeliverEndpointDelivery: true,
|
|
408
|
+
redeliverWebhookDelivery: true,
|
|
409
|
+
refreshAgencyAdminTokens: false,
|
|
410
|
+
refreshManagerTokens: false,
|
|
411
|
+
registerWebhookEndpoint: true,
|
|
412
|
+
reissueConsoleUserInvite: true,
|
|
413
|
+
reissuePlatformAdminInvite: false,
|
|
414
|
+
reissuePlatformPartnerConsoleUserInvite: false,
|
|
415
|
+
removeFromManifest: true,
|
|
416
|
+
renamePlatformPartner: false,
|
|
417
|
+
reopenPickupStop: true,
|
|
418
|
+
reorderItineraryItem: true,
|
|
419
|
+
reorderPickupStops: true,
|
|
420
|
+
replayWebhookEndpoint: true,
|
|
421
|
+
requestFileUpload: true,
|
|
422
|
+
resetPlatformPartnerConsoleUser: false,
|
|
423
|
+
returnFloat: true,
|
|
424
|
+
revokeApiKey: true,
|
|
425
|
+
revokePlatformPartnerApiKey: false,
|
|
426
|
+
revokeShareToken: false,
|
|
427
|
+
rotateApiKey: true,
|
|
428
|
+
rotateWebhookEndpointSecret: true,
|
|
429
|
+
runJourneyStep: true,
|
|
430
|
+
setPlatformPartnerStatus: false,
|
|
431
|
+
submitExpenseClaim: true,
|
|
432
|
+
toggleChecklistItem: true,
|
|
433
|
+
unassignManager: true,
|
|
434
|
+
unlinkSeatingManager: false,
|
|
435
|
+
upsertAgencyAdmin: true,
|
|
436
|
+
upsertManager: true,
|
|
437
|
+
upsertTravellerProfile: true,
|
|
438
|
+
upsertTrip: true,
|
|
439
|
+
voidCollection: false,
|
|
440
|
+
voidExpense: false,
|
|
441
|
+
withdrawExpenseClaim: false
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// src/generated/error-codes.ts
|
|
445
|
+
var KaafilErrorCode = {
|
|
446
|
+
BusinessRuleViolation: "BUSINESS_RULE_VIOLATION",
|
|
447
|
+
CannotPostpone: "CANNOT_POSTPONE",
|
|
448
|
+
CapabilityUnavailable: "CAPABILITY_UNAVAILABLE",
|
|
449
|
+
ConflictVersion: "CONFLICT_VERSION",
|
|
450
|
+
FileOrphaned: "FILE_ORPHANED",
|
|
451
|
+
FilePurged: "FILE_PURGED",
|
|
452
|
+
IdempotencyKeyReused: "IDEMPOTENCY_KEY_REUSED",
|
|
453
|
+
InternalError: "INTERNAL_ERROR",
|
|
454
|
+
Locked: "LOCKED",
|
|
455
|
+
NotATrek: "NOT_A_TREK",
|
|
456
|
+
NotImplemented: "NOT_IMPLEMENTED",
|
|
457
|
+
OutOfTripWindow: "OUT_OF_TRIP_WINDOW",
|
|
458
|
+
PlanFeatureDisabled: "PLAN_FEATURE_DISABLED",
|
|
459
|
+
RateLimited: "RATE_LIMITED",
|
|
460
|
+
ReadOnlyRole: "READ_ONLY_ROLE",
|
|
461
|
+
ResourceNotFound: "RESOURCE_NOT_FOUND",
|
|
462
|
+
ResponseClosed: "RESPONSE_CLOSED",
|
|
463
|
+
SeatingCapacityOrphan: "SEATING_CAPACITY_ORPHAN",
|
|
464
|
+
SecretNotReplayable: "SECRET_NOT_REPLAYABLE",
|
|
465
|
+
ShareTokenExpired: "SHARE_TOKEN_EXPIRED",
|
|
466
|
+
ShareTokenRevoked: "SHARE_TOKEN_REVOKED",
|
|
467
|
+
StayWindowHasAssignments: "STAY_WINDOW_HAS_ASSIGNMENTS",
|
|
468
|
+
StayWindowOverlap: "STAY_WINDOW_OVERLAP",
|
|
469
|
+
StopHasPending: "STOP_HAS_PENDING",
|
|
470
|
+
SubjectRequired: "SUBJECT_REQUIRED",
|
|
471
|
+
TenantScopeMissing: "TENANT_SCOPE_MISSING",
|
|
472
|
+
Unauthenticated: "UNAUTHENTICATED",
|
|
473
|
+
UploadMismatch: "UPLOAD_MISMATCH",
|
|
474
|
+
ValidationError: "VALIDATION_ERROR"
|
|
475
|
+
};
|
|
476
|
+
var Retryability = {
|
|
477
|
+
No: "no",
|
|
478
|
+
Yes: "yes",
|
|
479
|
+
AfterRefresh: "after-refresh",
|
|
480
|
+
HonourRetryAfter: "honour-retry-after"
|
|
481
|
+
};
|
|
482
|
+
var OutboxClass = {
|
|
483
|
+
Transient: "TRANSIENT",
|
|
484
|
+
Conflict: "CONFLICT",
|
|
485
|
+
Fatal: "FATAL"
|
|
486
|
+
};
|
|
487
|
+
var ERROR_CODE_TABLE = {
|
|
488
|
+
BUSINESS_RULE_VIOLATION: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
489
|
+
CANNOT_POSTPONE: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
490
|
+
CAPABILITY_UNAVAILABLE: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
491
|
+
CONFLICT_VERSION: { status: 409, retryability: "no", outboxClass: "CONFLICT" },
|
|
492
|
+
FILE_ORPHANED: { status: 409, retryability: "no", outboxClass: "FATAL" },
|
|
493
|
+
FILE_PURGED: { status: 410, retryability: "no", outboxClass: "FATAL" },
|
|
494
|
+
IDEMPOTENCY_KEY_REUSED: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
495
|
+
INTERNAL_ERROR: { status: 500, retryability: "yes", outboxClass: "TRANSIENT" },
|
|
496
|
+
LOCKED: { status: 423, retryability: "no", outboxClass: "FATAL" },
|
|
497
|
+
NOT_A_TREK: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
498
|
+
NOT_IMPLEMENTED: { status: 501, retryability: "no", outboxClass: "FATAL" },
|
|
499
|
+
OUT_OF_TRIP_WINDOW: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
500
|
+
PLAN_FEATURE_DISABLED: { status: 402, retryability: "no", outboxClass: "FATAL" },
|
|
501
|
+
RATE_LIMITED: { status: 429, retryability: "honour-retry-after", outboxClass: "TRANSIENT" },
|
|
502
|
+
READ_ONLY_ROLE: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
503
|
+
RESOURCE_NOT_FOUND: { status: 404, retryability: "no", outboxClass: "FATAL" },
|
|
504
|
+
RESPONSE_CLOSED: { status: 409, retryability: "no", outboxClass: "FATAL" },
|
|
505
|
+
SEATING_CAPACITY_ORPHAN: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
506
|
+
SECRET_NOT_REPLAYABLE: { status: 409, retryability: "no", outboxClass: "CONFLICT" },
|
|
507
|
+
SHARE_TOKEN_EXPIRED: { status: 401, retryability: "no", outboxClass: "FATAL" },
|
|
508
|
+
SHARE_TOKEN_REVOKED: { status: 401, retryability: "no", outboxClass: "FATAL" },
|
|
509
|
+
STAY_WINDOW_HAS_ASSIGNMENTS: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
510
|
+
STAY_WINDOW_OVERLAP: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
511
|
+
STOP_HAS_PENDING: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
512
|
+
SUBJECT_REQUIRED: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
513
|
+
TENANT_SCOPE_MISSING: { status: 500, retryability: "yes", outboxClass: "TRANSIENT" },
|
|
514
|
+
UNAUTHENTICATED: { status: 401, retryability: "after-refresh", outboxClass: "FATAL" },
|
|
515
|
+
UPLOAD_MISMATCH: { status: 422, retryability: "no", outboxClass: "FATAL" },
|
|
516
|
+
VALIDATION_ERROR: { status: 422, retryability: "no", outboxClass: "FATAL" }
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// src/http/errors.ts
|
|
520
|
+
var KaafilError = class extends Error {
|
|
521
|
+
code;
|
|
522
|
+
status;
|
|
523
|
+
details;
|
|
524
|
+
requestId;
|
|
525
|
+
meta;
|
|
526
|
+
constructor(message, init = {}) {
|
|
527
|
+
super(message, init.cause !== void 0 ? { cause: init.cause } : void 0);
|
|
528
|
+
this.name = "KaafilError";
|
|
529
|
+
this.code = init.code;
|
|
530
|
+
this.status = init.status;
|
|
531
|
+
this.details = init.details;
|
|
532
|
+
this.requestId = init.requestId;
|
|
533
|
+
this.meta = init.meta;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
var KaafilApiError = class _KaafilApiError extends KaafilError {
|
|
537
|
+
kind = "api";
|
|
538
|
+
code;
|
|
539
|
+
constructor(code, message, init = {}) {
|
|
540
|
+
super(message, { ...init, code });
|
|
541
|
+
this.name = "KaafilApiError";
|
|
542
|
+
this.code = code;
|
|
543
|
+
Object.setPrototypeOf(this, _KaafilApiError.prototype);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
var KaafilNotFoundError = class _KaafilNotFoundError extends KaafilApiError {
|
|
547
|
+
code;
|
|
548
|
+
constructor(message, init = {}) {
|
|
549
|
+
super(KaafilErrorCode.ResourceNotFound, message, init);
|
|
550
|
+
this.name = "KaafilNotFoundError";
|
|
551
|
+
this.code = KaafilErrorCode.ResourceNotFound;
|
|
552
|
+
Object.setPrototypeOf(this, _KaafilNotFoundError.prototype);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var KaafilEntitlementError = class _KaafilEntitlementError extends KaafilApiError {
|
|
556
|
+
code;
|
|
557
|
+
constructor(message, init = {}) {
|
|
558
|
+
super(KaafilErrorCode.PlanFeatureDisabled, message, init);
|
|
559
|
+
this.name = "KaafilEntitlementError";
|
|
560
|
+
this.code = KaafilErrorCode.PlanFeatureDisabled;
|
|
561
|
+
Object.setPrototypeOf(this, _KaafilEntitlementError.prototype);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* `details.reason` — which of three different people can fix this. Read
|
|
565
|
+
* defensively, like `.fields`/`.currentVersion` below: `details` is
|
|
566
|
+
* untyped at the transport boundary, so a value this SDK does not
|
|
567
|
+
* recognise (an engine that ships a fourth reason before this SDK knows
|
|
568
|
+
* about it) surfaces as `undefined` rather than a wrong branch.
|
|
569
|
+
*/
|
|
570
|
+
get reason() {
|
|
571
|
+
const value = this.details?.reason;
|
|
572
|
+
return value === "agencyFlag" || value === "partnerTier" || value === "tripQuota" ? value : void 0;
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
var KaafilCapabilityUnavailableError = class _KaafilCapabilityUnavailableError extends KaafilApiError {
|
|
576
|
+
code;
|
|
577
|
+
constructor(message, init = {}) {
|
|
578
|
+
super(KaafilErrorCode.CapabilityUnavailable, message, init);
|
|
579
|
+
this.name = "KaafilCapabilityUnavailableError";
|
|
580
|
+
this.code = KaafilErrorCode.CapabilityUnavailable;
|
|
581
|
+
Object.setPrototypeOf(this, _KaafilCapabilityUnavailableError.prototype);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
var KaafilReadOnlyRoleError = class _KaafilReadOnlyRoleError extends KaafilApiError {
|
|
585
|
+
code;
|
|
586
|
+
constructor(message, init = {}) {
|
|
587
|
+
super(KaafilErrorCode.ReadOnlyRole, message, init);
|
|
588
|
+
this.name = "KaafilReadOnlyRoleError";
|
|
589
|
+
this.code = KaafilErrorCode.ReadOnlyRole;
|
|
590
|
+
Object.setPrototypeOf(this, _KaafilReadOnlyRoleError.prototype);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
var KaafilValidationError = class _KaafilValidationError extends KaafilApiError {
|
|
594
|
+
code;
|
|
595
|
+
constructor(message, init = {}) {
|
|
596
|
+
super(KaafilErrorCode.ValidationError, message, init);
|
|
597
|
+
this.name = "KaafilValidationError";
|
|
598
|
+
this.code = KaafilErrorCode.ValidationError;
|
|
599
|
+
Object.setPrototypeOf(this, _KaafilValidationError.prototype);
|
|
600
|
+
}
|
|
601
|
+
get fields() {
|
|
602
|
+
const value = this.details?.fields;
|
|
603
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
var KaafilVersionConflictError = class _KaafilVersionConflictError extends KaafilApiError {
|
|
607
|
+
code;
|
|
608
|
+
constructor(message, init = {}) {
|
|
609
|
+
super(KaafilErrorCode.ConflictVersion, message, init);
|
|
610
|
+
this.name = "KaafilVersionConflictError";
|
|
611
|
+
this.code = KaafilErrorCode.ConflictVersion;
|
|
612
|
+
Object.setPrototypeOf(this, _KaafilVersionConflictError.prototype);
|
|
613
|
+
}
|
|
614
|
+
get currentVersion() {
|
|
615
|
+
const value = this.details?.currentVersion;
|
|
616
|
+
return typeof value === "number" ? value : void 0;
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
var KaafilLockedError = class _KaafilLockedError extends KaafilApiError {
|
|
620
|
+
code;
|
|
621
|
+
constructor(message, init = {}) {
|
|
622
|
+
super(KaafilErrorCode.Locked, message, init);
|
|
623
|
+
this.name = "KaafilLockedError";
|
|
624
|
+
this.code = KaafilErrorCode.Locked;
|
|
625
|
+
Object.setPrototypeOf(this, _KaafilLockedError.prototype);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var KaafilRateLimitedError = class _KaafilRateLimitedError extends KaafilApiError {
|
|
629
|
+
code;
|
|
630
|
+
retryAfterSeconds;
|
|
631
|
+
constructor(message, init = {}) {
|
|
632
|
+
const { retryAfterSeconds, ...rest } = init;
|
|
633
|
+
super(KaafilErrorCode.RateLimited, message, rest);
|
|
634
|
+
this.name = "KaafilRateLimitedError";
|
|
635
|
+
this.code = KaafilErrorCode.RateLimited;
|
|
636
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
637
|
+
Object.setPrototypeOf(this, _KaafilRateLimitedError.prototype);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
var KaafilUnauthenticatedError = class _KaafilUnauthenticatedError extends KaafilApiError {
|
|
641
|
+
code;
|
|
642
|
+
constructor(message, init = {}) {
|
|
643
|
+
super(KaafilErrorCode.Unauthenticated, message, init);
|
|
644
|
+
this.name = "KaafilUnauthenticatedError";
|
|
645
|
+
this.code = KaafilErrorCode.Unauthenticated;
|
|
646
|
+
Object.setPrototypeOf(this, _KaafilUnauthenticatedError.prototype);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
var KaafilShareTokenExpiredError = class _KaafilShareTokenExpiredError extends KaafilApiError {
|
|
650
|
+
code;
|
|
651
|
+
constructor(message, init = {}) {
|
|
652
|
+
super(KaafilErrorCode.ShareTokenExpired, message, init);
|
|
653
|
+
this.name = "KaafilShareTokenExpiredError";
|
|
654
|
+
this.code = KaafilErrorCode.ShareTokenExpired;
|
|
655
|
+
Object.setPrototypeOf(this, _KaafilShareTokenExpiredError.prototype);
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
var KaafilShareTokenRevokedError = class _KaafilShareTokenRevokedError extends KaafilApiError {
|
|
659
|
+
code;
|
|
660
|
+
constructor(message, init = {}) {
|
|
661
|
+
super(KaafilErrorCode.ShareTokenRevoked, message, init);
|
|
662
|
+
this.name = "KaafilShareTokenRevokedError";
|
|
663
|
+
this.code = KaafilErrorCode.ShareTokenRevoked;
|
|
664
|
+
Object.setPrototypeOf(this, _KaafilShareTokenRevokedError.prototype);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
var KaafilNotImplementedError = class _KaafilNotImplementedError extends KaafilApiError {
|
|
668
|
+
code;
|
|
669
|
+
constructor(message, init = {}) {
|
|
670
|
+
super(KaafilErrorCode.NotImplemented, message, init);
|
|
671
|
+
this.name = "KaafilNotImplementedError";
|
|
672
|
+
this.code = KaafilErrorCode.NotImplemented;
|
|
673
|
+
Object.setPrototypeOf(this, _KaafilNotImplementedError.prototype);
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
var KaafilTransportError = class extends KaafilError {
|
|
677
|
+
kind = "transport";
|
|
678
|
+
code;
|
|
679
|
+
constructor(message, init = {}) {
|
|
680
|
+
super(message, init);
|
|
681
|
+
this.code = void 0;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var KaafilTimeoutError = class _KaafilTimeoutError extends KaafilTransportError {
|
|
685
|
+
constructor(message = "Request timed out", init = {}) {
|
|
686
|
+
super(message, init);
|
|
687
|
+
this.name = "KaafilTimeoutError";
|
|
688
|
+
Object.setPrototypeOf(this, _KaafilTimeoutError.prototype);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
var KaafilAbortError = class _KaafilAbortError extends KaafilTransportError {
|
|
692
|
+
constructor(message = "Request aborted", init = {}) {
|
|
693
|
+
super(message, init);
|
|
694
|
+
this.name = "KaafilAbortError";
|
|
695
|
+
Object.setPrototypeOf(this, _KaafilAbortError.prototype);
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var KaafilNetworkError = class _KaafilNetworkError extends KaafilTransportError {
|
|
699
|
+
constructor(message = "Network request failed", init = {}) {
|
|
700
|
+
super(message, init);
|
|
701
|
+
this.name = "KaafilNetworkError";
|
|
702
|
+
Object.setPrototypeOf(this, _KaafilNetworkError.prototype);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
var KaafilInvalidRequestError = class _KaafilInvalidRequestError extends KaafilTransportError {
|
|
706
|
+
constructor(message, init = {}) {
|
|
707
|
+
super(message, init);
|
|
708
|
+
this.name = "KaafilInvalidRequestError";
|
|
709
|
+
Object.setPrototypeOf(this, _KaafilInvalidRequestError.prototype);
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
function isKaafilError(error) {
|
|
713
|
+
if (error instanceof KaafilError) {
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
if (typeof error !== "object" || error === null) {
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
const candidate = error;
|
|
720
|
+
return (candidate.kind === "api" || candidate.kind === "transport") && typeof candidate.message === "string";
|
|
721
|
+
}
|
|
722
|
+
var RETRYABLE_CODES = new Set(
|
|
723
|
+
Object.keys(ERROR_CODE_TABLE).filter(
|
|
724
|
+
(code) => ERROR_CODE_TABLE[code].retryability !== Retryability.No
|
|
725
|
+
)
|
|
726
|
+
);
|
|
727
|
+
function isRetryable(error) {
|
|
728
|
+
if (!isKaafilError(error)) {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
if (error.kind === "transport") {
|
|
732
|
+
return !(error instanceof KaafilAbortError) && !(error instanceof KaafilInvalidRequestError);
|
|
733
|
+
}
|
|
734
|
+
return error.code !== void 0 && RETRYABLE_CODES.has(error.code);
|
|
735
|
+
}
|
|
736
|
+
var KAAFIL_ERROR_CODE_VALUES = new Set(Object.values(KaafilErrorCode));
|
|
737
|
+
function isKaafilErrorCode(value) {
|
|
738
|
+
return KAAFIL_ERROR_CODE_VALUES.has(value);
|
|
739
|
+
}
|
|
740
|
+
function parseErrorEnvelope(body) {
|
|
741
|
+
if (typeof body !== "object" || body === null) {
|
|
742
|
+
return void 0;
|
|
743
|
+
}
|
|
744
|
+
const errorField = body.error;
|
|
745
|
+
if (typeof errorField !== "object" || errorField === null) {
|
|
746
|
+
return void 0;
|
|
747
|
+
}
|
|
748
|
+
const errorRecord = errorField;
|
|
749
|
+
const code = errorRecord.code;
|
|
750
|
+
const message = errorRecord.message;
|
|
751
|
+
if (typeof code !== "string" || !isKaafilErrorCode(code) || typeof message !== "string") {
|
|
752
|
+
return void 0;
|
|
753
|
+
}
|
|
754
|
+
const details = errorRecord.details;
|
|
755
|
+
return {
|
|
756
|
+
code,
|
|
757
|
+
message,
|
|
758
|
+
details: typeof details === "object" && details !== null ? details : void 0
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
function buildApiErrorInit(init, details) {
|
|
762
|
+
return {
|
|
763
|
+
status: init.status,
|
|
764
|
+
...details !== void 0 ? { details } : {},
|
|
765
|
+
...init.requestId !== void 0 ? { requestId: init.requestId } : {},
|
|
766
|
+
...init.meta !== void 0 ? { meta: init.meta } : {},
|
|
767
|
+
...init.cause !== void 0 ? { cause: init.cause } : {}
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function fromEnvelope(body, init) {
|
|
771
|
+
const parsed = parseErrorEnvelope(body);
|
|
772
|
+
if (parsed === void 0) {
|
|
773
|
+
return new KaafilNetworkError(
|
|
774
|
+
`Received an unrecognizable error body for HTTP ${init.status}`,
|
|
775
|
+
buildApiErrorInit(init, void 0)
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
const commonInit = buildApiErrorInit(init, parsed.details);
|
|
779
|
+
switch (parsed.code) {
|
|
780
|
+
case KaafilErrorCode.ResourceNotFound:
|
|
781
|
+
return new KaafilNotFoundError(parsed.message, commonInit);
|
|
782
|
+
case KaafilErrorCode.PlanFeatureDisabled:
|
|
783
|
+
return new KaafilEntitlementError(parsed.message, commonInit);
|
|
784
|
+
case KaafilErrorCode.CapabilityUnavailable:
|
|
785
|
+
return new KaafilCapabilityUnavailableError(parsed.message, commonInit);
|
|
786
|
+
case KaafilErrorCode.ReadOnlyRole:
|
|
787
|
+
return new KaafilReadOnlyRoleError(parsed.message, commonInit);
|
|
788
|
+
case KaafilErrorCode.ValidationError:
|
|
789
|
+
return new KaafilValidationError(parsed.message, commonInit);
|
|
790
|
+
case KaafilErrorCode.ConflictVersion:
|
|
791
|
+
return new KaafilVersionConflictError(parsed.message, commonInit);
|
|
792
|
+
case KaafilErrorCode.Locked:
|
|
793
|
+
return new KaafilLockedError(parsed.message, commonInit);
|
|
794
|
+
case KaafilErrorCode.RateLimited:
|
|
795
|
+
return new KaafilRateLimitedError(parsed.message, {
|
|
796
|
+
...commonInit,
|
|
797
|
+
...init.retryAfterSeconds !== void 0 ? { retryAfterSeconds: init.retryAfterSeconds } : {}
|
|
798
|
+
});
|
|
799
|
+
case KaafilErrorCode.Unauthenticated:
|
|
800
|
+
return new KaafilUnauthenticatedError(parsed.message, commonInit);
|
|
801
|
+
case KaafilErrorCode.ShareTokenExpired:
|
|
802
|
+
return new KaafilShareTokenExpiredError(parsed.message, commonInit);
|
|
803
|
+
case KaafilErrorCode.ShareTokenRevoked:
|
|
804
|
+
return new KaafilShareTokenRevokedError(parsed.message, commonInit);
|
|
805
|
+
case KaafilErrorCode.NotImplemented:
|
|
806
|
+
return new KaafilNotImplementedError(parsed.message, commonInit);
|
|
807
|
+
default:
|
|
808
|
+
return new KaafilApiError(parsed.code, parsed.message, commonInit);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// src/auth/credentials.ts
|
|
813
|
+
async function resolveValue(value) {
|
|
814
|
+
return typeof value === "function" ? await value() : value;
|
|
815
|
+
}
|
|
816
|
+
var CredentialKind = {
|
|
817
|
+
AgencyAdmin: "agencyAdmin",
|
|
818
|
+
ApiKey: "apiKey",
|
|
819
|
+
ManagerSession: "managerSession",
|
|
820
|
+
ShareToken: "shareToken"
|
|
821
|
+
};
|
|
822
|
+
var ROTATING_ACCESS_TOKEN_REFRESH_SKEW_MS = 3e4;
|
|
823
|
+
function isRotatingCredentialKind(kind) {
|
|
824
|
+
return kind === CredentialKind.AgencyAdmin || kind === CredentialKind.ManagerSession;
|
|
825
|
+
}
|
|
826
|
+
function isRotatingConfig(config) {
|
|
827
|
+
return isRotatingCredentialKind(config.kind);
|
|
828
|
+
}
|
|
829
|
+
var CREDENTIAL_KIND_SCHEME = {
|
|
830
|
+
agencyAdmin: SecuritySchemeId.AgencyAdminAuth,
|
|
831
|
+
apiKey: SecuritySchemeId.ApiKeyAuth,
|
|
832
|
+
managerSession: SecuritySchemeId.ManagerAuth,
|
|
833
|
+
shareToken: SecuritySchemeId.ShareAuth
|
|
834
|
+
};
|
|
835
|
+
var UnsatisfiableSchemeError = class _UnsatisfiableSchemeError extends KaafilInvalidRequestError {
|
|
836
|
+
operationId;
|
|
837
|
+
acceptedSchemes;
|
|
838
|
+
credentialKind;
|
|
839
|
+
constructor(operationId, acceptedSchemes, credentialKind) {
|
|
840
|
+
const schemeList = acceptedSchemes.length > 0 ? acceptedSchemes.join(", ") : "(no scheme declared)";
|
|
841
|
+
super(
|
|
842
|
+
`"${operationId}" accepts [${schemeList}], but the configured "${credentialKind}" credential cannot satisfy any of them.`
|
|
843
|
+
);
|
|
844
|
+
this.name = "UnsatisfiableSchemeError";
|
|
845
|
+
Object.setPrototypeOf(this, _UnsatisfiableSchemeError.prototype);
|
|
846
|
+
this.operationId = operationId;
|
|
847
|
+
this.acceptedSchemes = acceptedSchemes;
|
|
848
|
+
this.credentialKind = credentialKind;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
function headersForCarrier(schemeId, value) {
|
|
852
|
+
const carrier = SECURITY_SCHEME_CARRIERS[schemeId];
|
|
853
|
+
switch (carrier.kind) {
|
|
854
|
+
case "header":
|
|
855
|
+
return { [carrier.headerName]: value };
|
|
856
|
+
case "bearer":
|
|
857
|
+
return { Authorization: `Bearer ${value}` };
|
|
858
|
+
case "cookie":
|
|
859
|
+
throw new Error(`Scheme "${schemeId}" is cookie-borne and has no SDK-side credential kind.`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function createInitialState(config) {
|
|
863
|
+
return {
|
|
864
|
+
rotating: isRotatingCredentialKind(config.kind) ? { current: null, refreshPromise: null } : null
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function isExpiringSoon(expiresAt, nowMs) {
|
|
868
|
+
if (expiresAt === void 0) {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
const expiryMs = Date.parse(expiresAt);
|
|
872
|
+
if (Number.isNaN(expiryMs)) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
return expiryMs - nowMs <= ROTATING_ACCESS_TOKEN_REFRESH_SKEW_MS;
|
|
876
|
+
}
|
|
877
|
+
var CredentialResolver = class {
|
|
878
|
+
config;
|
|
879
|
+
state;
|
|
880
|
+
/**
|
|
881
|
+
* The default exchange for a rotating (`managerSession`/`agencyAdmin`)
|
|
882
|
+
* credential — `undefined` for the two non-rotating kinds, and for a
|
|
883
|
+
* rotating config that always uses its own `refresh` override instead.
|
|
884
|
+
* See `RotatingSessionExchange`'s doc comment for why this arrives as a
|
|
885
|
+
* constructor argument rather than an import.
|
|
886
|
+
*/
|
|
887
|
+
rotatingSessionExchange;
|
|
888
|
+
constructor(config, rotatingSessionExchange) {
|
|
889
|
+
this.config = config;
|
|
890
|
+
this.state = createInitialState(config);
|
|
891
|
+
this.rotatingSessionExchange = rotatingSessionExchange;
|
|
892
|
+
}
|
|
893
|
+
get kind() {
|
|
894
|
+
return this.config.kind;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Picks the first scheme in `acceptedSchemes` (spec declaration order)
|
|
898
|
+
* the configured credential can satisfy and returns its headers. Throws
|
|
899
|
+
* `UnsatisfiableSchemeError` — never makes the doomed round trip — if
|
|
900
|
+
* none match. An empty `acceptedSchemes` (a public operation) needs no
|
|
901
|
+
* credential and returns no headers.
|
|
902
|
+
*/
|
|
903
|
+
async resolveHeaders(operationId, acceptedSchemes) {
|
|
904
|
+
if (acceptedSchemes.length === 0) {
|
|
905
|
+
return { schemeId: null, headers: {} };
|
|
906
|
+
}
|
|
907
|
+
const config = this.config;
|
|
908
|
+
const mySchemeId = CREDENTIAL_KIND_SCHEME[config.kind];
|
|
909
|
+
if (!acceptedSchemes.includes(mySchemeId)) {
|
|
910
|
+
throw new UnsatisfiableSchemeError(operationId, acceptedSchemes, config.kind);
|
|
911
|
+
}
|
|
912
|
+
const value = await this.currentValue(config);
|
|
913
|
+
return { schemeId: mySchemeId, headers: headersForCarrier(mySchemeId, value) };
|
|
914
|
+
}
|
|
915
|
+
async currentValue(config) {
|
|
916
|
+
switch (config.kind) {
|
|
917
|
+
case CredentialKind.ApiKey:
|
|
918
|
+
return resolveValue(config.apiKey);
|
|
919
|
+
case CredentialKind.ShareToken:
|
|
920
|
+
return resolveValue(config.token);
|
|
921
|
+
case CredentialKind.ManagerSession:
|
|
922
|
+
case CredentialKind.AgencyAdmin:
|
|
923
|
+
return this.currentRotatingAccessToken(config);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
async currentRotatingAccessToken(config) {
|
|
927
|
+
const state = this.rotatingSessionState();
|
|
928
|
+
if (!state.current) {
|
|
929
|
+
const [accessToken, refreshToken, expiresAt] = await Promise.all([
|
|
930
|
+
resolveValue(config.accessToken),
|
|
931
|
+
resolveValue(config.refreshToken),
|
|
932
|
+
config.expiresAt !== void 0 ? resolveValue(config.expiresAt) : Promise.resolve(void 0)
|
|
933
|
+
]);
|
|
934
|
+
state.current = { accessToken, refreshToken, expiresAt };
|
|
935
|
+
}
|
|
936
|
+
if (isExpiringSoon(state.current.expiresAt, Date.now())) {
|
|
937
|
+
const result = await this.refreshRotatingSession();
|
|
938
|
+
return result.accessToken;
|
|
939
|
+
}
|
|
940
|
+
return state.current.accessToken;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Single-flight refresh: concurrent triggers (N simultaneous `401`s, or a
|
|
944
|
+
* pre-emptive check racing a `401`) share one in-flight promise, so the
|
|
945
|
+
* rotating refresh token is presented exactly once. The promise is
|
|
946
|
+
* cleared on both success and failure — a rejected refresh never stays
|
|
947
|
+
* sticky, and the next trigger always starts a fresh exchange
|
|
948
|
+
* (`architecture/03-auth-and-tokens.md §2`). Callers make one attempt per
|
|
949
|
+
* request and surface the failure; this method does not loop. Shared by
|
|
950
|
+
* both rotating kinds — see the module header's argument for why this is
|
|
951
|
+
* one implementation, not one per kind.
|
|
952
|
+
*/
|
|
953
|
+
async refreshRotatingSession() {
|
|
954
|
+
const config = this.config;
|
|
955
|
+
if (!isRotatingConfig(config)) {
|
|
956
|
+
throw new Error(
|
|
957
|
+
'refreshRotatingSession() is only valid for a rotating ("managerSession" or "agencyAdmin") credential.'
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
const state = this.rotatingSessionState();
|
|
961
|
+
if (state.refreshPromise) {
|
|
962
|
+
return state.refreshPromise;
|
|
963
|
+
}
|
|
964
|
+
const promise = this.performRotatingRefresh(config, state);
|
|
965
|
+
state.refreshPromise = promise;
|
|
966
|
+
try {
|
|
967
|
+
return await promise;
|
|
968
|
+
} finally {
|
|
969
|
+
state.refreshPromise = null;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
async performRotatingRefresh(config, state) {
|
|
973
|
+
const refreshToken = state.current?.refreshToken ?? await resolveValue(config.refreshToken);
|
|
974
|
+
const result = config.refresh !== void 0 ? await config.refresh(refreshToken) : await this.defaultRotatingRefresh(config, state, refreshToken);
|
|
975
|
+
state.current = {
|
|
976
|
+
accessToken: result.accessToken,
|
|
977
|
+
refreshToken: result.refreshToken,
|
|
978
|
+
expiresAt: result.expiresAt
|
|
979
|
+
};
|
|
980
|
+
await config.onRefresh?.(result);
|
|
981
|
+
return result;
|
|
982
|
+
}
|
|
983
|
+
async defaultRotatingRefresh(config, state, refreshToken) {
|
|
984
|
+
if (this.rotatingSessionExchange === void 0) {
|
|
985
|
+
throw new Error(
|
|
986
|
+
'invariant: a rotating credential without a "refresh" override needs the exchange function the entry point constructs it with \u2014 see "./client-entry.ts".'
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
const accessToken = state.current?.accessToken ?? await resolveValue(config.accessToken);
|
|
990
|
+
return this.rotatingSessionExchange(accessToken, refreshToken);
|
|
991
|
+
}
|
|
992
|
+
rotatingSessionState() {
|
|
993
|
+
const state = this.state.rotating;
|
|
994
|
+
if (!state) {
|
|
995
|
+
throw new Error("invariant: rotating-session state missing for a rotating credential.");
|
|
996
|
+
}
|
|
997
|
+
return state;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Resets every piece of per-session state in one assignment — teardown
|
|
1001
|
+
* that cannot forget a field because the state is rebuilt from scratch,
|
|
1002
|
+
* not cleared field by field.
|
|
1003
|
+
*/
|
|
1004
|
+
reset() {
|
|
1005
|
+
this.state = createInitialState(this.config);
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
// src/config.ts
|
|
1010
|
+
var Environment = {
|
|
1011
|
+
Live: "live",
|
|
1012
|
+
Test: "test"
|
|
1013
|
+
};
|
|
1014
|
+
var ENVIRONMENT_BASE_URLS = {
|
|
1015
|
+
live: "https://api.kaafil.com",
|
|
1016
|
+
test: "https://api.test.kaafil.com"
|
|
1017
|
+
};
|
|
1018
|
+
var API_KEY_ENVIRONMENT_PREFIX = {
|
|
1019
|
+
live: "kf_live_",
|
|
1020
|
+
test: "kf_test_"
|
|
1021
|
+
};
|
|
1022
|
+
var KaafilConfigError = class extends Error {
|
|
1023
|
+
constructor(message) {
|
|
1024
|
+
super(message);
|
|
1025
|
+
this.name = "KaafilConfigError";
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
var ApiKeyEnvironmentMismatchError = class extends KaafilConfigError {
|
|
1029
|
+
environment;
|
|
1030
|
+
keyPrefix;
|
|
1031
|
+
constructor(environment, apiKey) {
|
|
1032
|
+
const keyPrefix = apiKey.includes("_") ? `${apiKey.split("_").slice(0, 2).join("_")}_` : apiKey;
|
|
1033
|
+
super(
|
|
1034
|
+
`environment: "${environment}" expects an API key prefixed "${API_KEY_ENVIRONMENT_PREFIX[environment]}", but the configured key is prefixed "${keyPrefix}".`
|
|
1035
|
+
);
|
|
1036
|
+
this.name = "ApiKeyEnvironmentMismatchError";
|
|
1037
|
+
this.environment = environment;
|
|
1038
|
+
this.keyPrefix = keyPrefix;
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
function isValidAbsoluteUrl(value) {
|
|
1042
|
+
try {
|
|
1043
|
+
const url = new URL(value);
|
|
1044
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
1045
|
+
} catch {
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function resolveBaseUrl(environment, baseUrl) {
|
|
1050
|
+
if (baseUrl === void 0) {
|
|
1051
|
+
return ENVIRONMENT_BASE_URLS[environment];
|
|
1052
|
+
}
|
|
1053
|
+
if (!isValidAbsoluteUrl(baseUrl)) {
|
|
1054
|
+
throw new KaafilConfigError(
|
|
1055
|
+
`"baseUrl" must be an absolute http(s) URL; received "${baseUrl}".`
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
return baseUrl;
|
|
1059
|
+
}
|
|
1060
|
+
function assertValidTimeout(timeoutMs) {
|
|
1061
|
+
if (timeoutMs === void 0) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
1065
|
+
throw new KaafilConfigError(`"timeoutMs" must be a positive number; received ${timeoutMs}.`);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
function assertValidMaxAttempts(maxAttempts) {
|
|
1069
|
+
if (maxAttempts === void 0) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (!Number.isInteger(maxAttempts) || maxAttempts <= 0) {
|
|
1073
|
+
throw new KaafilConfigError(
|
|
1074
|
+
`"maxAttempts" must be a positive integer; received ${maxAttempts}.`
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function assertApiKeyMatchesEnvironment(apiKey, environment) {
|
|
1079
|
+
const expectedPrefix = API_KEY_ENVIRONMENT_PREFIX[environment];
|
|
1080
|
+
const isKnownPrefix = apiKey.startsWith(API_KEY_ENVIRONMENT_PREFIX.live) || apiKey.startsWith(API_KEY_ENVIRONMENT_PREFIX.test);
|
|
1081
|
+
if (!isKnownPrefix) {
|
|
1082
|
+
throw new KaafilConfigError(
|
|
1083
|
+
`"apiKey" does not look like a Kaafil API key (expected a "${API_KEY_ENVIRONMENT_PREFIX.live}" or "${API_KEY_ENVIRONMENT_PREFIX.test}" prefix).`
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
if (!apiKey.startsWith(expectedPrefix)) {
|
|
1087
|
+
throw new ApiKeyEnvironmentMismatchError(environment, apiKey);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function guardApiKeyEnvironment(apiKey, environment) {
|
|
1091
|
+
if (typeof apiKey !== "function") {
|
|
1092
|
+
assertApiKeyMatchesEnvironment(apiKey, environment);
|
|
1093
|
+
return apiKey;
|
|
1094
|
+
}
|
|
1095
|
+
const resolver = apiKey;
|
|
1096
|
+
return async () => {
|
|
1097
|
+
const value = await resolver();
|
|
1098
|
+
assertApiKeyMatchesEnvironment(value, environment);
|
|
1099
|
+
return value;
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// src/http/retry.ts
|
|
1104
|
+
var RETRY_LADDER_MS = [1e3, 5e3, 15e3, 6e4, 3e5, 9e5, 36e5];
|
|
1105
|
+
var DEFAULT_MAX_ATTEMPTS = 24;
|
|
1106
|
+
function isRetryableFailure(input) {
|
|
1107
|
+
if (input.status === null) {
|
|
1108
|
+
return true;
|
|
1109
|
+
}
|
|
1110
|
+
const entry = input.code !== void 0 ? ERROR_CODE_TABLE[input.code] : void 0;
|
|
1111
|
+
if (entry !== void 0) {
|
|
1112
|
+
return entry.retryability === Retryability.Yes || entry.retryability === Retryability.HonourRetryAfter;
|
|
1113
|
+
}
|
|
1114
|
+
return input.status === 429 || input.status >= 500 && input.status <= 599;
|
|
1115
|
+
}
|
|
1116
|
+
function computeRetryDelayMs(attempt, options = {}) {
|
|
1117
|
+
if (options.retryAfterSeconds !== void 0) {
|
|
1118
|
+
return Math.max(1, Math.floor(options.retryAfterSeconds)) * 1e3;
|
|
1119
|
+
}
|
|
1120
|
+
const index = Math.min(Math.max(attempt - 1, 0), RETRY_LADDER_MS.length - 1);
|
|
1121
|
+
const base = RETRY_LADDER_MS[index];
|
|
1122
|
+
if (base === void 0) {
|
|
1123
|
+
throw new Error("unreachable: index is clamped to RETRY_LADDER_MS bounds");
|
|
1124
|
+
}
|
|
1125
|
+
const random = options.random ?? Math.random;
|
|
1126
|
+
const half = base / 2;
|
|
1127
|
+
return Math.floor(half + random() * half);
|
|
1128
|
+
}
|
|
1129
|
+
function delayWithAbort(ms, signal) {
|
|
1130
|
+
if (signal?.aborted === true) {
|
|
1131
|
+
return Promise.reject(signal.reason);
|
|
1132
|
+
}
|
|
1133
|
+
return new Promise((resolve, reject) => {
|
|
1134
|
+
const onAbort = () => {
|
|
1135
|
+
clearTimeout(timer);
|
|
1136
|
+
reject(signal?.reason);
|
|
1137
|
+
};
|
|
1138
|
+
const timer = setTimeout(() => {
|
|
1139
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1140
|
+
resolve();
|
|
1141
|
+
}, ms);
|
|
1142
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
var RetryExhaustedError = class extends Error {
|
|
1146
|
+
failure;
|
|
1147
|
+
attempts;
|
|
1148
|
+
constructor(failure, attempts) {
|
|
1149
|
+
super(`retry exhausted after ${attempts} attempt(s), last status ${String(failure.status)}`);
|
|
1150
|
+
this.name = "RetryExhaustedError";
|
|
1151
|
+
this.failure = failure;
|
|
1152
|
+
this.attempts = attempts;
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
async function executeWithRetry(attempt, options = {}) {
|
|
1156
|
+
const unsafeToReplay = options.hasBody === true && options.idempotencyKey === void 0;
|
|
1157
|
+
const maxAttempts = unsafeToReplay ? 1 : options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
1158
|
+
const random = options.random ?? Math.random;
|
|
1159
|
+
for (let attemptNumber = 1; attemptNumber <= maxAttempts; attemptNumber += 1) {
|
|
1160
|
+
if (options.signal?.aborted === true) {
|
|
1161
|
+
throw options.signal.reason;
|
|
1162
|
+
}
|
|
1163
|
+
const outcome = await attempt(attemptNumber);
|
|
1164
|
+
if (outcome.ok) {
|
|
1165
|
+
return outcome.value;
|
|
1166
|
+
}
|
|
1167
|
+
const retryable = isRetryableFailure(outcome);
|
|
1168
|
+
if (!retryable || attemptNumber === maxAttempts) {
|
|
1169
|
+
throw new RetryExhaustedError(outcome, attemptNumber);
|
|
1170
|
+
}
|
|
1171
|
+
const delayMs = computeRetryDelayMs(attemptNumber, {
|
|
1172
|
+
...outcome.retryAfterSeconds !== void 0 ? { retryAfterSeconds: outcome.retryAfterSeconds } : {},
|
|
1173
|
+
random
|
|
1174
|
+
});
|
|
1175
|
+
await delayWithAbort(delayMs, options.signal);
|
|
1176
|
+
}
|
|
1177
|
+
throw new Error("unreachable: executeWithRetry loop exited without returning or throwing");
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/http/client.ts
|
|
1181
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
1182
|
+
function createHttpClient(config) {
|
|
1183
|
+
const ctx = {
|
|
1184
|
+
baseUrl: config.baseUrl,
|
|
1185
|
+
credentials: config.credentials,
|
|
1186
|
+
timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
1187
|
+
maxAttempts: config.maxAttempts,
|
|
1188
|
+
userAgent: config.userAgent,
|
|
1189
|
+
random: config.random
|
|
1190
|
+
};
|
|
1191
|
+
return {
|
|
1192
|
+
execute: (request) => execute(ctx, request)
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function renderPath(template, params) {
|
|
1196
|
+
return template.replace(/\{([^}]+)\}/g, (_match, name) => {
|
|
1197
|
+
const raw = params?.[name];
|
|
1198
|
+
if (raw === void 0) {
|
|
1199
|
+
throw new KaafilInvalidRequestError(
|
|
1200
|
+
`Missing path parameter "${name}" for "${template}". Pass it in the call's options.`
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1203
|
+
return encodeURIComponent(String(raw));
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
function buildUrl(baseUrl, renderedPath, query) {
|
|
1207
|
+
const normalizedBase = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
1208
|
+
const relativePath = renderedPath.startsWith("/") ? renderedPath.slice(1) : renderedPath;
|
|
1209
|
+
const url = new URL(relativePath, normalizedBase);
|
|
1210
|
+
if (query !== void 0) {
|
|
1211
|
+
for (const [key, value] of Object.entries(query)) {
|
|
1212
|
+
if (value === void 0) {
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
url.searchParams.set(key, String(value));
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return url;
|
|
1219
|
+
}
|
|
1220
|
+
var TIMEOUT_REASON = /* @__PURE__ */ Symbol("kaafil-timeout");
|
|
1221
|
+
function combineSignals(callerSignal, timeoutMs) {
|
|
1222
|
+
const controller = new AbortController();
|
|
1223
|
+
const cleanupFns = [];
|
|
1224
|
+
if (callerSignal !== void 0) {
|
|
1225
|
+
if (callerSignal.aborted) {
|
|
1226
|
+
controller.abort(callerSignal.reason);
|
|
1227
|
+
} else {
|
|
1228
|
+
const onAbort = () => controller.abort(callerSignal.reason);
|
|
1229
|
+
callerSignal.addEventListener("abort", onAbort, { once: true });
|
|
1230
|
+
cleanupFns.push(() => callerSignal.removeEventListener("abort", onAbort));
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
const timer = setTimeout(() => controller.abort(TIMEOUT_REASON), timeoutMs);
|
|
1234
|
+
cleanupFns.push(() => clearTimeout(timer));
|
|
1235
|
+
return {
|
|
1236
|
+
signal: controller.signal,
|
|
1237
|
+
isTimeout: () => controller.signal.reason === TIMEOUT_REASON,
|
|
1238
|
+
cleanup: () => {
|
|
1239
|
+
for (const fn of cleanupFns) {
|
|
1240
|
+
fn();
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
async function buildHeaders(ctx, request, idempotencyKey, hasBody) {
|
|
1246
|
+
const acceptedSchemes = OPERATION_SECURITY[request.operationId];
|
|
1247
|
+
const credential = await ctx.credentials.resolveHeaders(request.operationId, acceptedSchemes);
|
|
1248
|
+
const headers = new Headers();
|
|
1249
|
+
headers.set("Accept", "application/json");
|
|
1250
|
+
if (hasBody) {
|
|
1251
|
+
headers.set("Content-Type", "application/json");
|
|
1252
|
+
}
|
|
1253
|
+
for (const [key, value] of Object.entries(credential.headers)) {
|
|
1254
|
+
headers.set(key, value);
|
|
1255
|
+
}
|
|
1256
|
+
if (idempotencyKey !== void 0) {
|
|
1257
|
+
headers.set("Idempotency-Key", idempotencyKey);
|
|
1258
|
+
}
|
|
1259
|
+
if (ctx.userAgent !== void 0) {
|
|
1260
|
+
try {
|
|
1261
|
+
headers.set("User-Agent", ctx.userAgent);
|
|
1262
|
+
} catch {
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (request.headers !== void 0) {
|
|
1266
|
+
for (const [key, value] of Object.entries(request.headers)) {
|
|
1267
|
+
headers.set(key, value);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return headers;
|
|
1271
|
+
}
|
|
1272
|
+
function tryParseJson(text) {
|
|
1273
|
+
try {
|
|
1274
|
+
return JSON.parse(text);
|
|
1275
|
+
} catch {
|
|
1276
|
+
return void 0;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function isSuccessEnvelope(body) {
|
|
1280
|
+
if (typeof body !== "object" || body === null) {
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
const record = body;
|
|
1284
|
+
if (record.ok !== true) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
if (typeof record.data !== "object" || record.data === null) {
|
|
1288
|
+
return false;
|
|
1289
|
+
}
|
|
1290
|
+
const meta = record.meta;
|
|
1291
|
+
if (typeof meta !== "object" || meta === null) {
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
return typeof meta.serverTime === "string";
|
|
1295
|
+
}
|
|
1296
|
+
function buildResponseMeta(status, requestId, meta) {
|
|
1297
|
+
return {
|
|
1298
|
+
status,
|
|
1299
|
+
serverTime: meta.serverTime,
|
|
1300
|
+
requestId,
|
|
1301
|
+
page: meta.page
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function parseRetryAfterSeconds(headerValue) {
|
|
1305
|
+
if (headerValue === null) {
|
|
1306
|
+
return void 0;
|
|
1307
|
+
}
|
|
1308
|
+
const seconds = Number(headerValue);
|
|
1309
|
+
return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
|
|
1310
|
+
}
|
|
1311
|
+
function attachMeta(data, meta) {
|
|
1312
|
+
return Object.assign(data, { meta });
|
|
1313
|
+
}
|
|
1314
|
+
function describeCrossOriginSuspect(url) {
|
|
1315
|
+
const loc = globalThis.location;
|
|
1316
|
+
if (typeof loc !== "object" || loc === null) {
|
|
1317
|
+
return void 0;
|
|
1318
|
+
}
|
|
1319
|
+
const origin = loc.origin;
|
|
1320
|
+
if (typeof origin !== "string" || origin === url.origin) {
|
|
1321
|
+
return void 0;
|
|
1322
|
+
}
|
|
1323
|
+
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.`;
|
|
1324
|
+
}
|
|
1325
|
+
async function sendOnce(ctx, request, idempotencyKey) {
|
|
1326
|
+
const hasBody = request.body !== void 0;
|
|
1327
|
+
const renderedPath = renderPath(request.path, request.pathParams);
|
|
1328
|
+
const url = buildUrl(ctx.baseUrl, renderedPath, request.query);
|
|
1329
|
+
const headers = await buildHeaders(ctx, request, idempotencyKey, hasBody);
|
|
1330
|
+
const combined = combineSignals(request.signal, ctx.timeoutMs);
|
|
1331
|
+
try {
|
|
1332
|
+
const response = await fetch(url, {
|
|
1333
|
+
method: request.method,
|
|
1334
|
+
headers,
|
|
1335
|
+
signal: combined.signal,
|
|
1336
|
+
...hasBody ? { body: JSON.stringify(request.body) } : {}
|
|
1337
|
+
});
|
|
1338
|
+
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
1339
|
+
const status = response.status;
|
|
1340
|
+
const text = await response.text();
|
|
1341
|
+
const body = text.length > 0 ? tryParseJson(text) : void 0;
|
|
1342
|
+
if (response.ok) {
|
|
1343
|
+
if (!isSuccessEnvelope(body)) {
|
|
1344
|
+
throw new KaafilNetworkError(`Received an unrecognizable success body for HTTP ${status}`, {
|
|
1345
|
+
status,
|
|
1346
|
+
...requestId !== void 0 ? { requestId } : {}
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
return { data: body.data, meta: buildResponseMeta(status, requestId, body.meta) };
|
|
1350
|
+
}
|
|
1351
|
+
const retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("retry-after"));
|
|
1352
|
+
throw fromEnvelope(body, {
|
|
1353
|
+
status,
|
|
1354
|
+
...requestId !== void 0 ? { requestId } : {},
|
|
1355
|
+
...retryAfterSeconds !== void 0 ? { retryAfterSeconds } : {}
|
|
1356
|
+
});
|
|
1357
|
+
} catch (error) {
|
|
1358
|
+
if (isKaafilError(error)) {
|
|
1359
|
+
throw error;
|
|
1360
|
+
}
|
|
1361
|
+
if (combined.signal.aborted) {
|
|
1362
|
+
if (combined.isTimeout()) {
|
|
1363
|
+
throw new KaafilTimeoutError("Request timed out", { cause: error });
|
|
1364
|
+
}
|
|
1365
|
+
throw new KaafilAbortError("Request aborted", { cause: error });
|
|
1366
|
+
}
|
|
1367
|
+
throw new KaafilNetworkError(describeCrossOriginSuspect(url) ?? "Request failed", {
|
|
1368
|
+
cause: error
|
|
1369
|
+
});
|
|
1370
|
+
} finally {
|
|
1371
|
+
combined.cleanup();
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
function toKaafilError(error) {
|
|
1375
|
+
if (isKaafilError(error)) {
|
|
1376
|
+
return error;
|
|
1377
|
+
}
|
|
1378
|
+
return new KaafilNetworkError("Unexpected transport failure", { cause: error });
|
|
1379
|
+
}
|
|
1380
|
+
function toFailureOutcome(error) {
|
|
1381
|
+
return {
|
|
1382
|
+
ok: false,
|
|
1383
|
+
status: error.status ?? null,
|
|
1384
|
+
...error.code !== void 0 ? { code: error.code } : {},
|
|
1385
|
+
...error instanceof KaafilRateLimitedError && error.retryAfterSeconds !== void 0 ? { retryAfterSeconds: error.retryAfterSeconds } : {}
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
async function execute(ctx, request) {
|
|
1389
|
+
const idempotencyKey = OPERATION_ACCEPTS_IDEMPOTENCY_KEY[request.operationId] ? request.idempotencyKey ?? globalThis.crypto.randomUUID() : void 0;
|
|
1390
|
+
let lastError;
|
|
1391
|
+
let refreshAttempted = false;
|
|
1392
|
+
const sendAndClassify = async () => {
|
|
1393
|
+
try {
|
|
1394
|
+
const { data, meta } = await sendOnce(ctx, request, idempotencyKey);
|
|
1395
|
+
return { ok: true, value: attachMeta(data, meta) };
|
|
1396
|
+
} catch (error) {
|
|
1397
|
+
const typed = toKaafilError(error);
|
|
1398
|
+
lastError = typed;
|
|
1399
|
+
return toFailureOutcome(typed);
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
const attempt = async (_attemptNumber) => {
|
|
1403
|
+
const outcome = await sendAndClassify();
|
|
1404
|
+
if (outcome.ok) {
|
|
1405
|
+
return outcome;
|
|
1406
|
+
}
|
|
1407
|
+
const canRefresh = !refreshAttempted && outcome.code === KaafilErrorCode.Unauthenticated && isRotatingCredentialKind(ctx.credentials.kind);
|
|
1408
|
+
if (!canRefresh) {
|
|
1409
|
+
return outcome;
|
|
1410
|
+
}
|
|
1411
|
+
refreshAttempted = true;
|
|
1412
|
+
try {
|
|
1413
|
+
await ctx.credentials.refreshRotatingSession();
|
|
1414
|
+
} catch {
|
|
1415
|
+
return outcome;
|
|
1416
|
+
}
|
|
1417
|
+
return sendAndClassify();
|
|
1418
|
+
};
|
|
1419
|
+
renderPath(request.path, request.pathParams);
|
|
1420
|
+
try {
|
|
1421
|
+
return await executeWithRetry(attempt, {
|
|
1422
|
+
...ctx.maxAttempts !== void 0 ? { maxAttempts: ctx.maxAttempts } : {},
|
|
1423
|
+
...request.signal !== void 0 ? { signal: request.signal } : {},
|
|
1424
|
+
...ctx.random !== void 0 ? { random: ctx.random } : {},
|
|
1425
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1426
|
+
hasBody: request.body !== void 0
|
|
1427
|
+
});
|
|
1428
|
+
} catch (error) {
|
|
1429
|
+
if (error instanceof RetryExhaustedError) {
|
|
1430
|
+
throw lastError ?? error;
|
|
1431
|
+
}
|
|
1432
|
+
if (request.signal?.aborted === true) {
|
|
1433
|
+
throw new KaafilAbortError("Request aborted", { cause: lastError ?? error });
|
|
1434
|
+
}
|
|
1435
|
+
throw error;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// src/idempotency.ts
|
|
1440
|
+
function newIdempotencyKey() {
|
|
1441
|
+
return globalThis.crypto.randomUUID();
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// src/resources/auth.ts
|
|
1445
|
+
function createAuthResource(client) {
|
|
1446
|
+
return {
|
|
1447
|
+
async mintManagerToken(options) {
|
|
1448
|
+
const { signal, ...body } = options;
|
|
1449
|
+
return client.execute({
|
|
1450
|
+
method: "POST",
|
|
1451
|
+
operationId: OperationId.MintManagerTokens,
|
|
1452
|
+
path: "/api/v1/auth/manager-tokens",
|
|
1453
|
+
body,
|
|
1454
|
+
...signal !== void 0 ? { signal } : {}
|
|
1455
|
+
});
|
|
1456
|
+
},
|
|
1457
|
+
async mintAgencyAdminToken(options) {
|
|
1458
|
+
const { signal, ...body } = options;
|
|
1459
|
+
return client.execute({
|
|
1460
|
+
method: "POST",
|
|
1461
|
+
operationId: OperationId.MintAgencyAdminTokens,
|
|
1462
|
+
path: "/api/v1/auth/agency-admin-tokens",
|
|
1463
|
+
body,
|
|
1464
|
+
...signal !== void 0 ? { signal } : {}
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
// src/resources/checklists.ts
|
|
1471
|
+
function createChecklistsResource(client) {
|
|
1472
|
+
return {
|
|
1473
|
+
async read(options) {
|
|
1474
|
+
const { tripRef, since, signal } = options;
|
|
1475
|
+
return client.execute({
|
|
1476
|
+
method: "GET",
|
|
1477
|
+
operationId: OperationId.ReadChecklistAggregate,
|
|
1478
|
+
path: "/api/v1/trips/{ref}/checklist",
|
|
1479
|
+
pathParams: { ref: tripRef },
|
|
1480
|
+
query: { since },
|
|
1481
|
+
...signal !== void 0 ? { signal } : {}
|
|
1482
|
+
});
|
|
1483
|
+
},
|
|
1484
|
+
items: {
|
|
1485
|
+
async add(options) {
|
|
1486
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
1487
|
+
return client.execute({
|
|
1488
|
+
method: "POST",
|
|
1489
|
+
operationId: OperationId.AddChecklistItem,
|
|
1490
|
+
path: "/api/v1/trips/{ref}/checklist/items",
|
|
1491
|
+
pathParams: { ref: tripRef },
|
|
1492
|
+
body,
|
|
1493
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1494
|
+
...signal !== void 0 ? { signal } : {}
|
|
1495
|
+
});
|
|
1496
|
+
},
|
|
1497
|
+
async patch(options) {
|
|
1498
|
+
const { tripRef, itemId, version, signal, ...body } = options;
|
|
1499
|
+
return client.execute({
|
|
1500
|
+
method: "PATCH",
|
|
1501
|
+
operationId: OperationId.PatchChecklistItem,
|
|
1502
|
+
path: "/api/v1/trips/{ref}/checklist/items/{itemId}",
|
|
1503
|
+
pathParams: { ref: tripRef, itemId },
|
|
1504
|
+
body,
|
|
1505
|
+
headers: { "If-Match": String(version) },
|
|
1506
|
+
...signal !== void 0 ? { signal } : {}
|
|
1507
|
+
});
|
|
1508
|
+
},
|
|
1509
|
+
async remove(options) {
|
|
1510
|
+
const { tripRef, itemId, version, signal } = options;
|
|
1511
|
+
return client.execute({
|
|
1512
|
+
method: "DELETE",
|
|
1513
|
+
operationId: OperationId.DeleteChecklistItem,
|
|
1514
|
+
path: "/api/v1/trips/{ref}/checklist/items/{itemId}",
|
|
1515
|
+
pathParams: { ref: tripRef, itemId },
|
|
1516
|
+
headers: { "If-Match": String(version) },
|
|
1517
|
+
...signal !== void 0 ? { signal } : {}
|
|
1518
|
+
});
|
|
1519
|
+
},
|
|
1520
|
+
async toggle(options) {
|
|
1521
|
+
const { tripRef, itemId, idempotencyKey, signal, ...body } = options;
|
|
1522
|
+
return client.execute({
|
|
1523
|
+
method: "POST",
|
|
1524
|
+
operationId: OperationId.ToggleChecklistItem,
|
|
1525
|
+
path: "/api/v1/trips/{ref}/checklist/items/{itemId}/toggle",
|
|
1526
|
+
pathParams: { ref: tripRef, itemId },
|
|
1527
|
+
body,
|
|
1528
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1529
|
+
...signal !== void 0 ? { signal } : {}
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
templates: {
|
|
1534
|
+
async list(options) {
|
|
1535
|
+
const { tripRef, locale, signal } = options;
|
|
1536
|
+
return client.execute({
|
|
1537
|
+
method: "GET",
|
|
1538
|
+
operationId: OperationId.ListChecklistTemplates,
|
|
1539
|
+
path: "/api/v1/trips/{ref}/checklist/templates",
|
|
1540
|
+
pathParams: { ref: tripRef },
|
|
1541
|
+
query: { locale },
|
|
1542
|
+
...signal !== void 0 ? { signal } : {}
|
|
1543
|
+
});
|
|
1544
|
+
},
|
|
1545
|
+
async pull(options) {
|
|
1546
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
1547
|
+
return client.execute({
|
|
1548
|
+
method: "POST",
|
|
1549
|
+
operationId: OperationId.PullChecklistTemplate,
|
|
1550
|
+
path: "/api/v1/trips/{ref}/checklist/pull-template",
|
|
1551
|
+
pathParams: { ref: tripRef },
|
|
1552
|
+
body,
|
|
1553
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1554
|
+
...signal !== void 0 ? { signal } : {}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// src/datetime.ts
|
|
1562
|
+
var FULL_DATETIME_WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
1563
|
+
var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
1564
|
+
function invalidRequest(fieldPath, message) {
|
|
1565
|
+
return new KaafilInvalidRequestError(`${fieldPath}: ${message}`);
|
|
1566
|
+
}
|
|
1567
|
+
function normalizeDateTimeInput(value, fieldPath) {
|
|
1568
|
+
if (value instanceof Date) {
|
|
1569
|
+
if (Number.isNaN(value.getTime())) {
|
|
1570
|
+
throw invalidRequest(fieldPath, "received an invalid Date (getTime() is NaN).");
|
|
1571
|
+
}
|
|
1572
|
+
return value.toISOString();
|
|
1573
|
+
}
|
|
1574
|
+
if (typeof value === "number") {
|
|
1575
|
+
if (!Number.isFinite(value)) {
|
|
1576
|
+
throw invalidRequest(
|
|
1577
|
+
fieldPath,
|
|
1578
|
+
`received a non-finite number (${String(value)}); expected epoch milliseconds.`
|
|
1579
|
+
);
|
|
1580
|
+
}
|
|
1581
|
+
return new Date(value).toISOString();
|
|
1582
|
+
}
|
|
1583
|
+
if (FULL_DATETIME_WITH_OFFSET.test(value)) {
|
|
1584
|
+
return value;
|
|
1585
|
+
}
|
|
1586
|
+
if (DATE_ONLY.test(value)) {
|
|
1587
|
+
throw invalidRequest(
|
|
1588
|
+
fieldPath,
|
|
1589
|
+
`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".`
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
throw invalidRequest(
|
|
1593
|
+
fieldPath,
|
|
1594
|
+
`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".`
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
function normalizeNullableDateTimeInput(value, fieldPath) {
|
|
1598
|
+
return value === null ? null : normalizeDateTimeInput(value, fieldPath);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// src/resources/collections.ts
|
|
1602
|
+
function createCollectionsResource(client) {
|
|
1603
|
+
return {
|
|
1604
|
+
async list(options) {
|
|
1605
|
+
const { tripRef, travellerId, since, signal } = options;
|
|
1606
|
+
return client.execute({
|
|
1607
|
+
method: "GET",
|
|
1608
|
+
operationId: OperationId.ListCollections,
|
|
1609
|
+
path: "/api/v1/trips/{ref}/collections",
|
|
1610
|
+
pathParams: { ref: tripRef },
|
|
1611
|
+
query: { travellerId, since },
|
|
1612
|
+
...signal !== void 0 ? { signal } : {}
|
|
1613
|
+
});
|
|
1614
|
+
},
|
|
1615
|
+
async eligible(options) {
|
|
1616
|
+
const { tripRef, signal } = options;
|
|
1617
|
+
return client.execute({
|
|
1618
|
+
method: "GET",
|
|
1619
|
+
operationId: OperationId.ListEligibleCollections,
|
|
1620
|
+
path: "/api/v1/trips/{ref}/collections/eligible",
|
|
1621
|
+
pathParams: { ref: tripRef },
|
|
1622
|
+
...signal !== void 0 ? { signal } : {}
|
|
1623
|
+
});
|
|
1624
|
+
},
|
|
1625
|
+
async record(options) {
|
|
1626
|
+
const { tripRef, idempotencyKey, signal, collectedAt, ...rest } = options;
|
|
1627
|
+
const body = {
|
|
1628
|
+
...rest,
|
|
1629
|
+
...collectedAt !== void 0 ? { collectedAt: normalizeDateTimeInput(collectedAt, "collectedAt") } : {}
|
|
1630
|
+
};
|
|
1631
|
+
return client.execute({
|
|
1632
|
+
method: "POST",
|
|
1633
|
+
operationId: OperationId.RecordCollection,
|
|
1634
|
+
path: "/api/v1/trips/{ref}/collections",
|
|
1635
|
+
pathParams: { ref: tripRef },
|
|
1636
|
+
body,
|
|
1637
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1638
|
+
...signal !== void 0 ? { signal } : {}
|
|
1639
|
+
});
|
|
1640
|
+
},
|
|
1641
|
+
async void(options) {
|
|
1642
|
+
const { tripRef, collectionId, version, signal, ...body } = options;
|
|
1643
|
+
return client.execute({
|
|
1644
|
+
method: "DELETE",
|
|
1645
|
+
operationId: OperationId.VoidCollection,
|
|
1646
|
+
path: "/api/v1/trips/{ref}/collections/{id}/void",
|
|
1647
|
+
pathParams: { ref: tripRef, id: collectionId },
|
|
1648
|
+
body,
|
|
1649
|
+
headers: { "If-Match": String(version) },
|
|
1650
|
+
...signal !== void 0 ? { signal } : {}
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
// src/pagination/paginator.ts
|
|
1657
|
+
var KaafilPaginationError = class extends Error {
|
|
1658
|
+
constructor(message) {
|
|
1659
|
+
super(message);
|
|
1660
|
+
this.name = "KaafilPaginationError";
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
var KaafilPaginationInFlightError = class _KaafilPaginationInFlightError extends KaafilPaginationError {
|
|
1664
|
+
constructor() {
|
|
1665
|
+
super("next() was called while a previous call on this paginator was still in flight.");
|
|
1666
|
+
this.name = "KaafilPaginationInFlightError";
|
|
1667
|
+
Object.setPrototypeOf(this, _KaafilPaginationInFlightError.prototype);
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
var KaafilPaginationExhaustedError = class _KaafilPaginationExhaustedError extends KaafilPaginationError {
|
|
1671
|
+
constructor() {
|
|
1672
|
+
super("next() was called after this paginator was already exhausted (hasNext is false).");
|
|
1673
|
+
this.name = "KaafilPaginationExhaustedError";
|
|
1674
|
+
Object.setPrototypeOf(this, _KaafilPaginationExhaustedError.prototype);
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([402, 404, 422]);
|
|
1678
|
+
function isTerminalStatus(error) {
|
|
1679
|
+
return typeof error === "object" && error !== null && "status" in error && typeof error.status === "number" && TERMINAL_STATUSES.has(error.status);
|
|
1680
|
+
}
|
|
1681
|
+
function createInitialState2(filters) {
|
|
1682
|
+
return {
|
|
1683
|
+
cursor: void 0,
|
|
1684
|
+
hasNext: true,
|
|
1685
|
+
isLoading: false,
|
|
1686
|
+
lastError: void 0,
|
|
1687
|
+
meta: void 0,
|
|
1688
|
+
items: [],
|
|
1689
|
+
filters
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
function createPaginator(config) {
|
|
1693
|
+
const { fetchPage, limit } = config;
|
|
1694
|
+
const state = createInitialState2(config.filters);
|
|
1695
|
+
async function next() {
|
|
1696
|
+
if (state.isLoading) {
|
|
1697
|
+
throw new KaafilPaginationInFlightError();
|
|
1698
|
+
}
|
|
1699
|
+
if (!state.hasNext) {
|
|
1700
|
+
throw new KaafilPaginationExhaustedError();
|
|
1701
|
+
}
|
|
1702
|
+
state.isLoading = true;
|
|
1703
|
+
try {
|
|
1704
|
+
const page = await fetchPage({ cursor: state.cursor, limit, filters: state.filters });
|
|
1705
|
+
state.items.push(...page.items);
|
|
1706
|
+
state.cursor = page.meta.page.cursor ?? void 0;
|
|
1707
|
+
state.hasNext = page.meta.page.hasNext;
|
|
1708
|
+
state.meta = page.meta;
|
|
1709
|
+
state.lastError = void 0;
|
|
1710
|
+
return page.items;
|
|
1711
|
+
} catch (error) {
|
|
1712
|
+
state.lastError = error;
|
|
1713
|
+
if (isTerminalStatus(error)) {
|
|
1714
|
+
state.hasNext = false;
|
|
1715
|
+
return [];
|
|
1716
|
+
}
|
|
1717
|
+
throw error;
|
|
1718
|
+
} finally {
|
|
1719
|
+
state.isLoading = false;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
function setFilters(filters) {
|
|
1723
|
+
const fresh = createInitialState2(filters);
|
|
1724
|
+
state.cursor = fresh.cursor;
|
|
1725
|
+
state.hasNext = fresh.hasNext;
|
|
1726
|
+
state.isLoading = fresh.isLoading;
|
|
1727
|
+
state.lastError = fresh.lastError;
|
|
1728
|
+
state.meta = fresh.meta;
|
|
1729
|
+
state.items.length = 0;
|
|
1730
|
+
state.filters = filters;
|
|
1731
|
+
}
|
|
1732
|
+
async function* iterate() {
|
|
1733
|
+
while (state.hasNext) {
|
|
1734
|
+
const page = await next();
|
|
1735
|
+
for (const item of page) {
|
|
1736
|
+
yield item;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
get items() {
|
|
1742
|
+
return state.items;
|
|
1743
|
+
},
|
|
1744
|
+
get hasNext() {
|
|
1745
|
+
return state.hasNext;
|
|
1746
|
+
},
|
|
1747
|
+
get isLoading() {
|
|
1748
|
+
return state.isLoading;
|
|
1749
|
+
},
|
|
1750
|
+
get lastError() {
|
|
1751
|
+
return state.lastError;
|
|
1752
|
+
},
|
|
1753
|
+
get meta() {
|
|
1754
|
+
return state.meta;
|
|
1755
|
+
},
|
|
1756
|
+
next,
|
|
1757
|
+
setFilters,
|
|
1758
|
+
[Symbol.asyncIterator]: iterate
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
// src/resources/internal.ts
|
|
1763
|
+
function narrowPaged(response) {
|
|
1764
|
+
if (response.meta.page === void 0) {
|
|
1765
|
+
throw new Error("invariant: a cursor-paginated response arrived without meta.page.");
|
|
1766
|
+
}
|
|
1767
|
+
return response;
|
|
1768
|
+
}
|
|
1769
|
+
function toPaginatorPage(response) {
|
|
1770
|
+
const paged = narrowPaged(response);
|
|
1771
|
+
return { items: paged, meta: paged.meta };
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// src/resources/events.ts
|
|
1775
|
+
async function fetchEventsPage(client, request) {
|
|
1776
|
+
const response = await client.execute({
|
|
1777
|
+
method: "GET",
|
|
1778
|
+
operationId: OperationId.ListEvents,
|
|
1779
|
+
path: "/api/v1/events",
|
|
1780
|
+
query: { ...request.filters, cursor: request.cursor, limit: request.limit }
|
|
1781
|
+
});
|
|
1782
|
+
return toPaginatorPage(response);
|
|
1783
|
+
}
|
|
1784
|
+
function createEventsResource(client) {
|
|
1785
|
+
return {
|
|
1786
|
+
list(options = {}) {
|
|
1787
|
+
return createPaginator({
|
|
1788
|
+
fetchPage: (request) => fetchEventsPage(client, request),
|
|
1789
|
+
filters: options.filters ?? {},
|
|
1790
|
+
...options.limit !== void 0 ? { limit: options.limit } : {}
|
|
1791
|
+
});
|
|
1792
|
+
},
|
|
1793
|
+
async listPage(options = {}) {
|
|
1794
|
+
const { cursor, limit, signal, ...filters } = options;
|
|
1795
|
+
const response = await client.execute({
|
|
1796
|
+
method: "GET",
|
|
1797
|
+
operationId: OperationId.ListEvents,
|
|
1798
|
+
path: "/api/v1/events",
|
|
1799
|
+
query: { ...filters, cursor, limit },
|
|
1800
|
+
...signal !== void 0 ? { signal } : {}
|
|
1801
|
+
});
|
|
1802
|
+
return narrowPaged(response);
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
// src/resources/expenses.ts
|
|
1808
|
+
function createExpensesResource(client) {
|
|
1809
|
+
return {
|
|
1810
|
+
async list(options) {
|
|
1811
|
+
const { tripRef, since, signal, ...filters } = options;
|
|
1812
|
+
return client.execute({
|
|
1813
|
+
method: "GET",
|
|
1814
|
+
operationId: OperationId.ListExpenses,
|
|
1815
|
+
path: "/api/v1/trips/{ref}/expenses",
|
|
1816
|
+
pathParams: { ref: tripRef },
|
|
1817
|
+
query: { ...filters, since },
|
|
1818
|
+
...signal !== void 0 ? { signal } : {}
|
|
1819
|
+
});
|
|
1820
|
+
},
|
|
1821
|
+
async read(options) {
|
|
1822
|
+
const { tripRef, expenseId, signal } = options;
|
|
1823
|
+
return client.execute({
|
|
1824
|
+
method: "GET",
|
|
1825
|
+
operationId: OperationId.ReadExpense,
|
|
1826
|
+
path: "/api/v1/trips/{ref}/expenses/{id}",
|
|
1827
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1828
|
+
...signal !== void 0 ? { signal } : {}
|
|
1829
|
+
});
|
|
1830
|
+
},
|
|
1831
|
+
async log(options) {
|
|
1832
|
+
const { tripRef, idempotencyKey, signal, spentAt, ...rest } = options;
|
|
1833
|
+
const body = {
|
|
1834
|
+
...rest,
|
|
1835
|
+
...spentAt !== void 0 ? { spentAt: normalizeDateTimeInput(spentAt, "spentAt") } : {}
|
|
1836
|
+
};
|
|
1837
|
+
return client.execute({
|
|
1838
|
+
method: "POST",
|
|
1839
|
+
operationId: OperationId.LogExpense,
|
|
1840
|
+
path: "/api/v1/trips/{ref}/expenses",
|
|
1841
|
+
pathParams: { ref: tripRef },
|
|
1842
|
+
body,
|
|
1843
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1844
|
+
...signal !== void 0 ? { signal } : {}
|
|
1845
|
+
});
|
|
1846
|
+
},
|
|
1847
|
+
async linkReceipt(options) {
|
|
1848
|
+
const { tripRef, expenseId, idempotencyKey, signal, ...body } = options;
|
|
1849
|
+
return client.execute({
|
|
1850
|
+
method: "PATCH",
|
|
1851
|
+
operationId: OperationId.LinkExpenseReceipt,
|
|
1852
|
+
path: "/api/v1/trips/{ref}/expenses/{id}/receipt",
|
|
1853
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1854
|
+
body,
|
|
1855
|
+
idempotencyKey,
|
|
1856
|
+
...signal !== void 0 ? { signal } : {}
|
|
1857
|
+
});
|
|
1858
|
+
},
|
|
1859
|
+
async void(options) {
|
|
1860
|
+
const { tripRef, expenseId, version, signal, ...body } = options;
|
|
1861
|
+
return client.execute({
|
|
1862
|
+
method: "DELETE",
|
|
1863
|
+
operationId: OperationId.VoidExpense,
|
|
1864
|
+
path: "/api/v1/trips/{ref}/expenses/{id}/void",
|
|
1865
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1866
|
+
body,
|
|
1867
|
+
headers: { "If-Match": String(version) },
|
|
1868
|
+
...signal !== void 0 ? { signal } : {}
|
|
1869
|
+
});
|
|
1870
|
+
},
|
|
1871
|
+
claims: {
|
|
1872
|
+
async submit(options) {
|
|
1873
|
+
const { tripRef, expenseId, idempotencyKey, signal } = options;
|
|
1874
|
+
return client.execute({
|
|
1875
|
+
method: "POST",
|
|
1876
|
+
operationId: OperationId.SubmitExpenseClaim,
|
|
1877
|
+
path: "/api/v1/trips/{ref}/expenses/{id}/claim",
|
|
1878
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1879
|
+
body: {},
|
|
1880
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1881
|
+
...signal !== void 0 ? { signal } : {}
|
|
1882
|
+
});
|
|
1883
|
+
},
|
|
1884
|
+
async withdraw(options) {
|
|
1885
|
+
const { tripRef, expenseId, version, signal } = options;
|
|
1886
|
+
return client.execute({
|
|
1887
|
+
method: "DELETE",
|
|
1888
|
+
operationId: OperationId.WithdrawExpenseClaim,
|
|
1889
|
+
path: "/api/v1/trips/{ref}/expenses/{id}/claim/withdraw",
|
|
1890
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1891
|
+
body: {},
|
|
1892
|
+
headers: { "If-Match": String(version) },
|
|
1893
|
+
...signal !== void 0 ? { signal } : {}
|
|
1894
|
+
});
|
|
1895
|
+
},
|
|
1896
|
+
async ingest(options) {
|
|
1897
|
+
const { tripRef, expenseId, idempotencyKey, signal, decisionAt, ...rest } = options;
|
|
1898
|
+
const body = {
|
|
1899
|
+
...rest,
|
|
1900
|
+
decisionAt: normalizeDateTimeInput(decisionAt, "decisionAt")
|
|
1901
|
+
};
|
|
1902
|
+
return client.execute({
|
|
1903
|
+
method: "POST",
|
|
1904
|
+
operationId: OperationId.ClaimStatusIngest,
|
|
1905
|
+
path: "/api/v1/trips/{ref}/expenses/{id}/claim-status",
|
|
1906
|
+
pathParams: { ref: tripRef, id: expenseId },
|
|
1907
|
+
body,
|
|
1908
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1909
|
+
...signal !== void 0 ? { signal } : {}
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
// src/resources/files.ts
|
|
1917
|
+
function createFilesResource(client) {
|
|
1918
|
+
return {
|
|
1919
|
+
async request(options) {
|
|
1920
|
+
const { idempotencyKey, signal, ...body } = options;
|
|
1921
|
+
return client.execute({
|
|
1922
|
+
method: "POST",
|
|
1923
|
+
operationId: OperationId.RequestFileUpload,
|
|
1924
|
+
path: "/api/v1/files",
|
|
1925
|
+
body,
|
|
1926
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1927
|
+
...signal !== void 0 ? { signal } : {}
|
|
1928
|
+
});
|
|
1929
|
+
},
|
|
1930
|
+
async meta(options) {
|
|
1931
|
+
const { fileId, signal } = options;
|
|
1932
|
+
return client.execute({
|
|
1933
|
+
method: "GET",
|
|
1934
|
+
operationId: OperationId.ReadFile,
|
|
1935
|
+
path: "/api/v1/files/{id}",
|
|
1936
|
+
pathParams: { id: fileId },
|
|
1937
|
+
...signal !== void 0 ? { signal } : {}
|
|
1938
|
+
});
|
|
1939
|
+
},
|
|
1940
|
+
async confirm(options) {
|
|
1941
|
+
const { fileId, idempotencyKey, signal } = options;
|
|
1942
|
+
return client.execute({
|
|
1943
|
+
method: "POST",
|
|
1944
|
+
operationId: OperationId.ConfirmFileUpload,
|
|
1945
|
+
path: "/api/v1/files/{id}/confirm",
|
|
1946
|
+
pathParams: { id: fileId },
|
|
1947
|
+
body: {},
|
|
1948
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1949
|
+
...signal !== void 0 ? { signal } : {}
|
|
1950
|
+
});
|
|
1951
|
+
},
|
|
1952
|
+
async url(options) {
|
|
1953
|
+
const { fileId, signal } = options;
|
|
1954
|
+
return client.execute({
|
|
1955
|
+
method: "GET",
|
|
1956
|
+
operationId: OperationId.ReadFileUrl,
|
|
1957
|
+
path: "/api/v1/files/{id}/url",
|
|
1958
|
+
pathParams: { id: fileId },
|
|
1959
|
+
...signal !== void 0 ? { signal } : {}
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
// src/resources/float.ts
|
|
1966
|
+
function createFloatResource(client) {
|
|
1967
|
+
return {
|
|
1968
|
+
async readSummary(options) {
|
|
1969
|
+
const { tripRef, since, signal } = options;
|
|
1970
|
+
return client.execute({
|
|
1971
|
+
method: "GET",
|
|
1972
|
+
operationId: OperationId.ReadFloatSummary,
|
|
1973
|
+
path: "/api/v1/trips/{ref}/float",
|
|
1974
|
+
pathParams: { ref: tripRef },
|
|
1975
|
+
query: { since },
|
|
1976
|
+
...signal !== void 0 ? { signal } : {}
|
|
1977
|
+
});
|
|
1978
|
+
},
|
|
1979
|
+
async readLedger(options) {
|
|
1980
|
+
const { tripRef, managerId, signal } = options;
|
|
1981
|
+
return client.execute({
|
|
1982
|
+
method: "GET",
|
|
1983
|
+
operationId: OperationId.ReadFloatLedger,
|
|
1984
|
+
path: "/api/v1/trips/{ref}/float/{managerId}/ledger",
|
|
1985
|
+
pathParams: { ref: tripRef, managerId },
|
|
1986
|
+
...signal !== void 0 ? { signal } : {}
|
|
1987
|
+
});
|
|
1988
|
+
},
|
|
1989
|
+
async issue(options) {
|
|
1990
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
1991
|
+
return client.execute({
|
|
1992
|
+
method: "POST",
|
|
1993
|
+
operationId: OperationId.IssueFloat,
|
|
1994
|
+
path: "/api/v1/trips/{ref}/float/issue",
|
|
1995
|
+
pathParams: { ref: tripRef },
|
|
1996
|
+
body,
|
|
1997
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
1998
|
+
...signal !== void 0 ? { signal } : {}
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
2001
|
+
async return(options) {
|
|
2002
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2003
|
+
return client.execute({
|
|
2004
|
+
method: "POST",
|
|
2005
|
+
operationId: OperationId.ReturnFloat,
|
|
2006
|
+
path: "/api/v1/trips/{ref}/float/return",
|
|
2007
|
+
pathParams: { ref: tripRef },
|
|
2008
|
+
body,
|
|
2009
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2010
|
+
...signal !== void 0 ? { signal } : {}
|
|
2011
|
+
});
|
|
2012
|
+
},
|
|
2013
|
+
async adjust(options) {
|
|
2014
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2015
|
+
return client.execute({
|
|
2016
|
+
method: "POST",
|
|
2017
|
+
operationId: OperationId.AdjustFloat,
|
|
2018
|
+
path: "/api/v1/trips/{ref}/float/adjust",
|
|
2019
|
+
pathParams: { ref: tripRef },
|
|
2020
|
+
body,
|
|
2021
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2022
|
+
...signal !== void 0 ? { signal } : {}
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
// src/resources/itinerary.ts
|
|
2029
|
+
function createItineraryResource(client) {
|
|
2030
|
+
return {
|
|
2031
|
+
async read(options) {
|
|
2032
|
+
const { tripRef, dayIndex, since, signal } = options;
|
|
2033
|
+
return client.execute({
|
|
2034
|
+
method: "GET",
|
|
2035
|
+
operationId: OperationId.ReadItinerary,
|
|
2036
|
+
path: "/api/v1/trips/{ref}/itinerary",
|
|
2037
|
+
pathParams: { ref: tripRef },
|
|
2038
|
+
query: { dayIndex, since },
|
|
2039
|
+
...signal !== void 0 ? { signal } : {}
|
|
2040
|
+
});
|
|
2041
|
+
},
|
|
2042
|
+
items: {
|
|
2043
|
+
async add(options) {
|
|
2044
|
+
const { tripRef, idempotencyKey, signal, isoDate, startTime, endTime, ...rest } = options;
|
|
2045
|
+
const body = {
|
|
2046
|
+
...rest,
|
|
2047
|
+
isoDate: normalizeDateTimeInput(isoDate, "isoDate"),
|
|
2048
|
+
...startTime !== void 0 ? { startTime: normalizeNullableDateTimeInput(startTime, "startTime") } : {},
|
|
2049
|
+
...endTime !== void 0 ? { endTime: normalizeNullableDateTimeInput(endTime, "endTime") } : {}
|
|
2050
|
+
};
|
|
2051
|
+
return client.execute({
|
|
2052
|
+
method: "POST",
|
|
2053
|
+
operationId: OperationId.AddItineraryItem,
|
|
2054
|
+
path: "/api/v1/trips/{ref}/itinerary/items",
|
|
2055
|
+
pathParams: { ref: tripRef },
|
|
2056
|
+
body,
|
|
2057
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2058
|
+
...signal !== void 0 ? { signal } : {}
|
|
2059
|
+
});
|
|
2060
|
+
},
|
|
2061
|
+
async patch(options) {
|
|
2062
|
+
const { tripRef, itemId, version, signal, startTime, endTime, ...rest } = options;
|
|
2063
|
+
const body = {
|
|
2064
|
+
...rest,
|
|
2065
|
+
...startTime !== void 0 ? { startTime: normalizeNullableDateTimeInput(startTime, "startTime") } : {},
|
|
2066
|
+
...endTime !== void 0 ? { endTime: normalizeNullableDateTimeInput(endTime, "endTime") } : {}
|
|
2067
|
+
};
|
|
2068
|
+
return client.execute({
|
|
2069
|
+
method: "PATCH",
|
|
2070
|
+
operationId: OperationId.PatchItineraryItem,
|
|
2071
|
+
path: "/api/v1/trips/{ref}/itinerary/items/{itemId}",
|
|
2072
|
+
pathParams: { ref: tripRef, itemId },
|
|
2073
|
+
body,
|
|
2074
|
+
headers: { "If-Match": String(version) },
|
|
2075
|
+
...signal !== void 0 ? { signal } : {}
|
|
2076
|
+
});
|
|
2077
|
+
},
|
|
2078
|
+
async remove(options) {
|
|
2079
|
+
const { tripRef, itemId, version, signal } = options;
|
|
2080
|
+
return client.execute({
|
|
2081
|
+
method: "DELETE",
|
|
2082
|
+
operationId: OperationId.DeleteItineraryItem,
|
|
2083
|
+
path: "/api/v1/trips/{ref}/itinerary/items/{itemId}",
|
|
2084
|
+
pathParams: { ref: tripRef, itemId },
|
|
2085
|
+
headers: { "If-Match": String(version) },
|
|
2086
|
+
...signal !== void 0 ? { signal } : {}
|
|
2087
|
+
});
|
|
2088
|
+
},
|
|
2089
|
+
async reorder(options) {
|
|
2090
|
+
const { tripRef, itemId, idempotencyKey, signal, ...body } = options;
|
|
2091
|
+
return client.execute({
|
|
2092
|
+
method: "POST",
|
|
2093
|
+
operationId: OperationId.ReorderItineraryItem,
|
|
2094
|
+
path: "/api/v1/trips/{ref}/itinerary/items/{itemId}/reorder",
|
|
2095
|
+
pathParams: { ref: tripRef, itemId },
|
|
2096
|
+
body,
|
|
2097
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2098
|
+
...signal !== void 0 ? { signal } : {}
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
},
|
|
2102
|
+
days: {
|
|
2103
|
+
async patch(options) {
|
|
2104
|
+
const { tripRef, dayIndex, version, signal, ...body } = options;
|
|
2105
|
+
return client.execute({
|
|
2106
|
+
method: "PATCH",
|
|
2107
|
+
operationId: OperationId.PatchItineraryDay,
|
|
2108
|
+
path: "/api/v1/trips/{ref}/itinerary/days/{dayIndex}",
|
|
2109
|
+
pathParams: { ref: tripRef, dayIndex },
|
|
2110
|
+
body,
|
|
2111
|
+
headers: { "If-Match": String(version) },
|
|
2112
|
+
...signal !== void 0 ? { signal } : {}
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
},
|
|
2116
|
+
changeLog: {
|
|
2117
|
+
async list(options) {
|
|
2118
|
+
const { tripRef, since, signal } = options;
|
|
2119
|
+
return client.execute({
|
|
2120
|
+
method: "GET",
|
|
2121
|
+
operationId: OperationId.ReadItineraryChangeLog,
|
|
2122
|
+
path: "/api/v1/trips/{ref}/itinerary/change-log",
|
|
2123
|
+
pathParams: { ref: tripRef },
|
|
2124
|
+
query: { since },
|
|
2125
|
+
...signal !== void 0 ? { signal } : {}
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
// src/resources/journey.ts
|
|
2133
|
+
var DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS = 6e4;
|
|
2134
|
+
var DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS = 1e3;
|
|
2135
|
+
function createJourneyResource(client) {
|
|
2136
|
+
const resource = {
|
|
2137
|
+
async get(options) {
|
|
2138
|
+
const { tripRef, signal } = options;
|
|
2139
|
+
return client.execute({
|
|
2140
|
+
method: "GET",
|
|
2141
|
+
operationId: OperationId.ReadJourney,
|
|
2142
|
+
path: "/api/v1/trips/{ref}/journey",
|
|
2143
|
+
pathParams: { ref: tripRef },
|
|
2144
|
+
...signal !== void 0 ? { signal } : {}
|
|
2145
|
+
});
|
|
2146
|
+
},
|
|
2147
|
+
async capabilities(options) {
|
|
2148
|
+
const { tripRef, signal } = options;
|
|
2149
|
+
return client.execute({
|
|
2150
|
+
method: "GET",
|
|
2151
|
+
operationId: OperationId.ReadJourneyCapabilities,
|
|
2152
|
+
path: "/api/v1/trips/{ref}/journey/capabilities",
|
|
2153
|
+
pathParams: { ref: tripRef },
|
|
2154
|
+
...signal !== void 0 ? { signal } : {}
|
|
2155
|
+
});
|
|
2156
|
+
},
|
|
2157
|
+
async rebuild(options) {
|
|
2158
|
+
const { tripRef, idempotencyKey, signal } = options;
|
|
2159
|
+
return client.execute({
|
|
2160
|
+
method: "POST",
|
|
2161
|
+
operationId: OperationId.RebuildJourney,
|
|
2162
|
+
path: "/api/v1/trips/{ref}/journey/rebuild",
|
|
2163
|
+
pathParams: { ref: tripRef },
|
|
2164
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2165
|
+
...signal !== void 0 ? { signal } : {}
|
|
2166
|
+
});
|
|
2167
|
+
},
|
|
2168
|
+
async runStep(options) {
|
|
2169
|
+
const { tripRef, stepId, idempotencyKey, signal } = options;
|
|
2170
|
+
return client.execute({
|
|
2171
|
+
method: "POST",
|
|
2172
|
+
operationId: OperationId.RunJourneyStep,
|
|
2173
|
+
path: "/api/v1/trips/{ref}/journey/steps/{stepId}/run",
|
|
2174
|
+
pathParams: { ref: tripRef, stepId },
|
|
2175
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2176
|
+
...signal !== void 0 ? { signal } : {}
|
|
2177
|
+
});
|
|
2178
|
+
},
|
|
2179
|
+
async waitUntilReady(options) {
|
|
2180
|
+
const {
|
|
2181
|
+
tripRef,
|
|
2182
|
+
timeoutMs = DEFAULT_WAIT_UNTIL_READY_TIMEOUT_MS,
|
|
2183
|
+
pollIntervalMs = DEFAULT_WAIT_UNTIL_READY_POLL_INTERVAL_MS,
|
|
2184
|
+
signal
|
|
2185
|
+
} = options;
|
|
2186
|
+
const deadlineAt = Date.now() + timeoutMs;
|
|
2187
|
+
for (; ; ) {
|
|
2188
|
+
try {
|
|
2189
|
+
return await resource.get({ tripRef, ...signal !== void 0 ? { signal } : {} });
|
|
2190
|
+
} catch (error) {
|
|
2191
|
+
if (!(error instanceof KaafilNotFoundError)) {
|
|
2192
|
+
throw error;
|
|
2193
|
+
}
|
|
2194
|
+
const remainingMs = deadlineAt - Date.now();
|
|
2195
|
+
if (remainingMs <= 0) {
|
|
2196
|
+
throw new KaafilTimeoutError(
|
|
2197
|
+
`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.`,
|
|
2198
|
+
{ cause: error }
|
|
2199
|
+
);
|
|
2200
|
+
}
|
|
2201
|
+
try {
|
|
2202
|
+
await delayWithAbort(Math.min(pollIntervalMs, remainingMs), signal);
|
|
2203
|
+
} catch (sleepError) {
|
|
2204
|
+
throw new KaafilAbortError("Request aborted", { cause: sleepError });
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
triggers: {
|
|
2210
|
+
async list(options) {
|
|
2211
|
+
const { agencyRef, signal } = options;
|
|
2212
|
+
return client.execute({
|
|
2213
|
+
method: "GET",
|
|
2214
|
+
operationId: OperationId.ListJourneyTriggers,
|
|
2215
|
+
path: "/api/v1/agencies/{ref}/journey-triggers",
|
|
2216
|
+
pathParams: { ref: agencyRef },
|
|
2217
|
+
...signal !== void 0 ? { signal } : {}
|
|
2218
|
+
});
|
|
2219
|
+
},
|
|
2220
|
+
async patch(options) {
|
|
2221
|
+
const { agencyRef, key, version, idempotencyKey, signal, ...body } = options;
|
|
2222
|
+
return client.execute({
|
|
2223
|
+
method: "PATCH",
|
|
2224
|
+
operationId: OperationId.PatchJourneyTrigger,
|
|
2225
|
+
path: "/api/v1/agencies/{ref}/journey-triggers/{key}",
|
|
2226
|
+
pathParams: { ref: agencyRef, key },
|
|
2227
|
+
body,
|
|
2228
|
+
headers: { "If-Match": String(version) },
|
|
2229
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2230
|
+
...signal !== void 0 ? { signal } : {}
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
};
|
|
2235
|
+
return resource;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// src/resources/pickups.ts
|
|
2239
|
+
function createPickupsResource(client) {
|
|
2240
|
+
return {
|
|
2241
|
+
async list(options) {
|
|
2242
|
+
const { tripRef, kind, since, signal } = options;
|
|
2243
|
+
return client.execute({
|
|
2244
|
+
method: "GET",
|
|
2245
|
+
operationId: OperationId.ListPickupStops,
|
|
2246
|
+
path: "/api/v1/trips/{ref}/pickups",
|
|
2247
|
+
pathParams: { ref: tripRef },
|
|
2248
|
+
query: { kind, since },
|
|
2249
|
+
...signal !== void 0 ? { signal } : {}
|
|
2250
|
+
});
|
|
2251
|
+
},
|
|
2252
|
+
async create(options) {
|
|
2253
|
+
const { tripRef, idempotencyKey, signal, scheduledTime, ...rest } = options;
|
|
2254
|
+
const body = {
|
|
2255
|
+
...rest,
|
|
2256
|
+
scheduledTime: normalizeDateTimeInput(scheduledTime, "scheduledTime")
|
|
2257
|
+
};
|
|
2258
|
+
return client.execute({
|
|
2259
|
+
method: "POST",
|
|
2260
|
+
operationId: OperationId.CreatePickupStop,
|
|
2261
|
+
path: "/api/v1/trips/{ref}/pickups",
|
|
2262
|
+
pathParams: { ref: tripRef },
|
|
2263
|
+
body,
|
|
2264
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2265
|
+
...signal !== void 0 ? { signal } : {}
|
|
2266
|
+
});
|
|
2267
|
+
},
|
|
2268
|
+
async patch(options) {
|
|
2269
|
+
const { tripRef, pointId, version, signal, scheduledTime, ...rest } = options;
|
|
2270
|
+
const body = {
|
|
2271
|
+
...rest,
|
|
2272
|
+
...scheduledTime !== void 0 ? { scheduledTime: normalizeDateTimeInput(scheduledTime, "scheduledTime") } : {}
|
|
2273
|
+
};
|
|
2274
|
+
return client.execute({
|
|
2275
|
+
method: "PATCH",
|
|
2276
|
+
operationId: OperationId.PatchPickupStop,
|
|
2277
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}",
|
|
2278
|
+
pathParams: { ref: tripRef, pointId },
|
|
2279
|
+
body,
|
|
2280
|
+
headers: { "If-Match": String(version) },
|
|
2281
|
+
...signal !== void 0 ? { signal } : {}
|
|
2282
|
+
});
|
|
2283
|
+
},
|
|
2284
|
+
async remove(options) {
|
|
2285
|
+
const { tripRef, pointId, version, force, signal } = options;
|
|
2286
|
+
return client.execute({
|
|
2287
|
+
method: "DELETE",
|
|
2288
|
+
operationId: OperationId.DeletePickupStop,
|
|
2289
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}",
|
|
2290
|
+
pathParams: { ref: tripRef, pointId },
|
|
2291
|
+
query: { force },
|
|
2292
|
+
headers: { "If-Match": String(version) },
|
|
2293
|
+
...signal !== void 0 ? { signal } : {}
|
|
2294
|
+
});
|
|
2295
|
+
},
|
|
2296
|
+
async reorder(options) {
|
|
2297
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2298
|
+
return client.execute({
|
|
2299
|
+
method: "POST",
|
|
2300
|
+
operationId: OperationId.ReorderPickupStops,
|
|
2301
|
+
path: "/api/v1/trips/{ref}/pickups/reorder",
|
|
2302
|
+
pathParams: { ref: tripRef },
|
|
2303
|
+
body,
|
|
2304
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2305
|
+
...signal !== void 0 ? { signal } : {}
|
|
2306
|
+
});
|
|
2307
|
+
},
|
|
2308
|
+
async assign(options) {
|
|
2309
|
+
const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
|
|
2310
|
+
return client.execute({
|
|
2311
|
+
method: "POST",
|
|
2312
|
+
operationId: OperationId.AssignPickupTraveller,
|
|
2313
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}/assign",
|
|
2314
|
+
pathParams: { ref: tripRef, pointId },
|
|
2315
|
+
body,
|
|
2316
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2317
|
+
...signal !== void 0 ? { signal } : {}
|
|
2318
|
+
});
|
|
2319
|
+
},
|
|
2320
|
+
async board(options) {
|
|
2321
|
+
const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
|
|
2322
|
+
return client.execute({
|
|
2323
|
+
method: "POST",
|
|
2324
|
+
operationId: OperationId.BoardPickupTraveller,
|
|
2325
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}/board",
|
|
2326
|
+
pathParams: { ref: tripRef, pointId },
|
|
2327
|
+
body,
|
|
2328
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2329
|
+
...signal !== void 0 ? { signal } : {}
|
|
2330
|
+
});
|
|
2331
|
+
},
|
|
2332
|
+
async close(options) {
|
|
2333
|
+
const { tripRef, pointId, idempotencyKey, signal, ...body } = options;
|
|
2334
|
+
return client.execute({
|
|
2335
|
+
method: "POST",
|
|
2336
|
+
operationId: OperationId.ClosePickupStop,
|
|
2337
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}/close",
|
|
2338
|
+
pathParams: { ref: tripRef, pointId },
|
|
2339
|
+
body,
|
|
2340
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2341
|
+
...signal !== void 0 ? { signal } : {}
|
|
2342
|
+
});
|
|
2343
|
+
},
|
|
2344
|
+
async reopen(options) {
|
|
2345
|
+
const { tripRef, pointId, idempotencyKey, signal } = options;
|
|
2346
|
+
return client.execute({
|
|
2347
|
+
method: "POST",
|
|
2348
|
+
operationId: OperationId.ReopenPickupStop,
|
|
2349
|
+
path: "/api/v1/trips/{ref}/pickups/{pointId}/reopen",
|
|
2350
|
+
pathParams: { ref: tripRef, pointId },
|
|
2351
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2352
|
+
...signal !== void 0 ? { signal } : {}
|
|
2353
|
+
});
|
|
2354
|
+
},
|
|
2355
|
+
async manifestByPickup(options) {
|
|
2356
|
+
const { tripRef, kind, signal } = options;
|
|
2357
|
+
return client.execute({
|
|
2358
|
+
method: "GET",
|
|
2359
|
+
operationId: OperationId.ReadManifestByPickup,
|
|
2360
|
+
path: "/api/v1/trips/{ref}/manifest-by-pickup",
|
|
2361
|
+
pathParams: { ref: tripRef },
|
|
2362
|
+
query: { kind },
|
|
2363
|
+
...signal !== void 0 ? { signal } : {}
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
// src/resources/rooming.ts
|
|
2370
|
+
function createRoomingResource(client) {
|
|
2371
|
+
return {
|
|
2372
|
+
async read(options) {
|
|
2373
|
+
const { tripRef, stayWindowId, since, signal } = options;
|
|
2374
|
+
return client.execute({
|
|
2375
|
+
method: "GET",
|
|
2376
|
+
operationId: OperationId.ReadRoomingBoard,
|
|
2377
|
+
path: "/api/v1/trips/{ref}/rooming",
|
|
2378
|
+
pathParams: { ref: tripRef },
|
|
2379
|
+
query: { stayWindowId, since },
|
|
2380
|
+
...signal !== void 0 ? { signal } : {}
|
|
2381
|
+
});
|
|
2382
|
+
},
|
|
2383
|
+
async assign(options) {
|
|
2384
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2385
|
+
return client.execute({
|
|
2386
|
+
method: "POST",
|
|
2387
|
+
operationId: OperationId.AssignRoomingBed,
|
|
2388
|
+
path: "/api/v1/trips/{ref}/rooming/assign",
|
|
2389
|
+
pathParams: { ref: tripRef },
|
|
2390
|
+
body,
|
|
2391
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2392
|
+
...signal !== void 0 ? { signal } : {}
|
|
2393
|
+
});
|
|
2394
|
+
},
|
|
2395
|
+
async autoAssign(options) {
|
|
2396
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2397
|
+
return client.execute({
|
|
2398
|
+
method: "POST",
|
|
2399
|
+
operationId: OperationId.AutoAssignRooming,
|
|
2400
|
+
path: "/api/v1/trips/{ref}/rooming/auto-assign",
|
|
2401
|
+
pathParams: { ref: tripRef },
|
|
2402
|
+
body,
|
|
2403
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2404
|
+
...signal !== void 0 ? { signal } : {}
|
|
2405
|
+
});
|
|
2406
|
+
},
|
|
2407
|
+
stayWindows: {
|
|
2408
|
+
async list(options) {
|
|
2409
|
+
const { tripRef, since, signal } = options;
|
|
2410
|
+
return client.execute({
|
|
2411
|
+
method: "GET",
|
|
2412
|
+
operationId: OperationId.ListRoomingStayWindows,
|
|
2413
|
+
path: "/api/v1/trips/{ref}/rooming/stay-windows",
|
|
2414
|
+
pathParams: { ref: tripRef },
|
|
2415
|
+
query: { since },
|
|
2416
|
+
...signal !== void 0 ? { signal } : {}
|
|
2417
|
+
});
|
|
2418
|
+
},
|
|
2419
|
+
async create(options) {
|
|
2420
|
+
const { tripRef, idempotencyKey, signal, startDate, endDate, ...rest } = options;
|
|
2421
|
+
const body = {
|
|
2422
|
+
...rest,
|
|
2423
|
+
startDate: normalizeDateTimeInput(startDate, "startDate"),
|
|
2424
|
+
endDate: normalizeDateTimeInput(endDate, "endDate")
|
|
2425
|
+
};
|
|
2426
|
+
return client.execute({
|
|
2427
|
+
method: "POST",
|
|
2428
|
+
operationId: OperationId.CreateRoomingStayWindow,
|
|
2429
|
+
path: "/api/v1/trips/{ref}/rooming/stay-windows",
|
|
2430
|
+
pathParams: { ref: tripRef },
|
|
2431
|
+
body,
|
|
2432
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2433
|
+
...signal !== void 0 ? { signal } : {}
|
|
2434
|
+
});
|
|
2435
|
+
},
|
|
2436
|
+
async patch(options) {
|
|
2437
|
+
const { tripRef, windowId, version, signal, startDate, endDate, ...rest } = options;
|
|
2438
|
+
const body = {
|
|
2439
|
+
...rest,
|
|
2440
|
+
...startDate !== void 0 ? { startDate: normalizeDateTimeInput(startDate, "startDate") } : {},
|
|
2441
|
+
...endDate !== void 0 ? { endDate: normalizeDateTimeInput(endDate, "endDate") } : {}
|
|
2442
|
+
};
|
|
2443
|
+
return client.execute({
|
|
2444
|
+
method: "PATCH",
|
|
2445
|
+
operationId: OperationId.PatchRoomingStayWindow,
|
|
2446
|
+
path: "/api/v1/trips/{ref}/rooming/stay-windows/{windowId}",
|
|
2447
|
+
pathParams: { ref: tripRef, windowId },
|
|
2448
|
+
body,
|
|
2449
|
+
headers: { "If-Match": String(version) },
|
|
2450
|
+
...signal !== void 0 ? { signal } : {}
|
|
2451
|
+
});
|
|
2452
|
+
},
|
|
2453
|
+
async remove(options) {
|
|
2454
|
+
const { tripRef, windowId, version, force, signal } = options;
|
|
2455
|
+
return client.execute({
|
|
2456
|
+
method: "DELETE",
|
|
2457
|
+
operationId: OperationId.DeleteRoomingStayWindow,
|
|
2458
|
+
path: "/api/v1/trips/{ref}/rooming/stay-windows/{windowId}",
|
|
2459
|
+
pathParams: { ref: tripRef, windowId },
|
|
2460
|
+
query: { force },
|
|
2461
|
+
headers: { "If-Match": String(version) },
|
|
2462
|
+
...signal !== void 0 ? { signal } : {}
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
},
|
|
2466
|
+
rooms: {
|
|
2467
|
+
async create(options) {
|
|
2468
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2469
|
+
return client.execute({
|
|
2470
|
+
method: "POST",
|
|
2471
|
+
operationId: OperationId.CreateRoomingRoom,
|
|
2472
|
+
path: "/api/v1/trips/{ref}/rooming/rooms",
|
|
2473
|
+
pathParams: { ref: tripRef },
|
|
2474
|
+
body,
|
|
2475
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2476
|
+
...signal !== void 0 ? { signal } : {}
|
|
2477
|
+
});
|
|
2478
|
+
},
|
|
2479
|
+
async patch(options) {
|
|
2480
|
+
const { tripRef, roomId, version, signal, ...body } = options;
|
|
2481
|
+
return client.execute({
|
|
2482
|
+
method: "PATCH",
|
|
2483
|
+
operationId: OperationId.PatchRoomingRoom,
|
|
2484
|
+
path: "/api/v1/trips/{ref}/rooming/rooms/{roomId}",
|
|
2485
|
+
pathParams: { ref: tripRef, roomId },
|
|
2486
|
+
body,
|
|
2487
|
+
headers: { "If-Match": String(version) },
|
|
2488
|
+
...signal !== void 0 ? { signal } : {}
|
|
2489
|
+
});
|
|
2490
|
+
},
|
|
2491
|
+
async remove(options) {
|
|
2492
|
+
const { tripRef, roomId, version, force, signal } = options;
|
|
2493
|
+
return client.execute({
|
|
2494
|
+
method: "DELETE",
|
|
2495
|
+
operationId: OperationId.DeleteRoomingRoom,
|
|
2496
|
+
path: "/api/v1/trips/{ref}/rooming/rooms/{roomId}",
|
|
2497
|
+
pathParams: { ref: tripRef, roomId },
|
|
2498
|
+
query: { force },
|
|
2499
|
+
headers: { "If-Match": String(version) },
|
|
2500
|
+
...signal !== void 0 ? { signal } : {}
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
// src/resources/seating.ts
|
|
2508
|
+
function createSeatingResource(client) {
|
|
2509
|
+
return {
|
|
2510
|
+
async read(options) {
|
|
2511
|
+
const { tripRef, since, signal } = options;
|
|
2512
|
+
return client.execute({
|
|
2513
|
+
method: "GET",
|
|
2514
|
+
operationId: OperationId.ReadSeatingBoard,
|
|
2515
|
+
path: "/api/v1/trips/{ref}/seating",
|
|
2516
|
+
pathParams: { ref: tripRef },
|
|
2517
|
+
query: { since },
|
|
2518
|
+
...signal !== void 0 ? { signal } : {}
|
|
2519
|
+
});
|
|
2520
|
+
},
|
|
2521
|
+
async assign(options) {
|
|
2522
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2523
|
+
return client.execute({
|
|
2524
|
+
method: "POST",
|
|
2525
|
+
operationId: OperationId.AssignSeating,
|
|
2526
|
+
path: "/api/v1/trips/{ref}/seating/assign",
|
|
2527
|
+
pathParams: { ref: tripRef },
|
|
2528
|
+
body,
|
|
2529
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2530
|
+
...signal !== void 0 ? { signal } : {}
|
|
2531
|
+
});
|
|
2532
|
+
},
|
|
2533
|
+
async autoAssign(options) {
|
|
2534
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2535
|
+
return client.execute({
|
|
2536
|
+
method: "POST",
|
|
2537
|
+
operationId: OperationId.AutoAssignSeating,
|
|
2538
|
+
path: "/api/v1/trips/{ref}/seating/auto-assign",
|
|
2539
|
+
pathParams: { ref: tripRef },
|
|
2540
|
+
body,
|
|
2541
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2542
|
+
...signal !== void 0 ? { signal } : {}
|
|
2543
|
+
});
|
|
2544
|
+
},
|
|
2545
|
+
vehicles: {
|
|
2546
|
+
async create(options) {
|
|
2547
|
+
const { tripRef, idempotencyKey, signal, ...body } = options;
|
|
2548
|
+
return client.execute({
|
|
2549
|
+
method: "POST",
|
|
2550
|
+
operationId: OperationId.CreateSeatingVehicle,
|
|
2551
|
+
path: "/api/v1/trips/{ref}/seating/vehicles",
|
|
2552
|
+
pathParams: { ref: tripRef },
|
|
2553
|
+
body,
|
|
2554
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2555
|
+
...signal !== void 0 ? { signal } : {}
|
|
2556
|
+
});
|
|
2557
|
+
},
|
|
2558
|
+
async patch(options) {
|
|
2559
|
+
const { tripRef, vehicleId, version, signal, ...body } = options;
|
|
2560
|
+
return client.execute({
|
|
2561
|
+
method: "PATCH",
|
|
2562
|
+
operationId: OperationId.PatchSeatingVehicle,
|
|
2563
|
+
path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}",
|
|
2564
|
+
pathParams: { ref: tripRef, vehicleId },
|
|
2565
|
+
body,
|
|
2566
|
+
headers: { "If-Match": String(version) },
|
|
2567
|
+
...signal !== void 0 ? { signal } : {}
|
|
2568
|
+
});
|
|
2569
|
+
},
|
|
2570
|
+
async remove(options) {
|
|
2571
|
+
const { tripRef, vehicleId, version, signal } = options;
|
|
2572
|
+
return client.execute({
|
|
2573
|
+
method: "DELETE",
|
|
2574
|
+
operationId: OperationId.DeleteSeatingVehicle,
|
|
2575
|
+
path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}",
|
|
2576
|
+
pathParams: { ref: tripRef, vehicleId },
|
|
2577
|
+
headers: { "If-Match": String(version) },
|
|
2578
|
+
...signal !== void 0 ? { signal } : {}
|
|
2579
|
+
});
|
|
2580
|
+
},
|
|
2581
|
+
manager: {
|
|
2582
|
+
async link(options) {
|
|
2583
|
+
const { tripRef, vehicleId, idempotencyKey, signal, ...body } = options;
|
|
2584
|
+
return client.execute({
|
|
2585
|
+
method: "POST",
|
|
2586
|
+
operationId: OperationId.LinkSeatingManager,
|
|
2587
|
+
path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}/manager",
|
|
2588
|
+
pathParams: { ref: tripRef, vehicleId },
|
|
2589
|
+
body,
|
|
2590
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2591
|
+
...signal !== void 0 ? { signal } : {}
|
|
2592
|
+
});
|
|
2593
|
+
},
|
|
2594
|
+
async unlink(options) {
|
|
2595
|
+
const { tripRef, vehicleId, version, signal } = options;
|
|
2596
|
+
return client.execute({
|
|
2597
|
+
method: "DELETE",
|
|
2598
|
+
operationId: OperationId.UnlinkSeatingManager,
|
|
2599
|
+
path: "/api/v1/trips/{ref}/seating/vehicles/{vehicleId}/manager",
|
|
2600
|
+
pathParams: { ref: tripRef, vehicleId },
|
|
2601
|
+
headers: { "If-Match": String(version) },
|
|
2602
|
+
...signal !== void 0 ? { signal } : {}
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
// src/resources/share-tokens.ts
|
|
2611
|
+
function createShareTokensResource(client) {
|
|
2612
|
+
return {
|
|
2613
|
+
async create(options) {
|
|
2614
|
+
const { idempotencyKey, signal, expiresAt, ...rest } = options;
|
|
2615
|
+
const body = {
|
|
2616
|
+
...rest,
|
|
2617
|
+
...expiresAt !== void 0 ? { expiresAt: normalizeDateTimeInput(expiresAt, "expiresAt") } : {}
|
|
2618
|
+
};
|
|
2619
|
+
return client.execute({
|
|
2620
|
+
method: "POST",
|
|
2621
|
+
operationId: OperationId.MintShareToken,
|
|
2622
|
+
path: "/api/v1/share-tokens",
|
|
2623
|
+
body,
|
|
2624
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2625
|
+
...signal !== void 0 ? { signal } : {}
|
|
2626
|
+
});
|
|
2627
|
+
},
|
|
2628
|
+
async read(options) {
|
|
2629
|
+
const { id, signal } = options;
|
|
2630
|
+
return client.execute({
|
|
2631
|
+
method: "GET",
|
|
2632
|
+
operationId: OperationId.ReadShareToken,
|
|
2633
|
+
path: "/api/v1/share-tokens/{id}",
|
|
2634
|
+
pathParams: { id },
|
|
2635
|
+
...signal !== void 0 ? { signal } : {}
|
|
2636
|
+
});
|
|
2637
|
+
},
|
|
2638
|
+
async revoke(options) {
|
|
2639
|
+
const { id, signal } = options;
|
|
2640
|
+
return client.execute({
|
|
2641
|
+
method: "DELETE",
|
|
2642
|
+
operationId: OperationId.RevokeShareToken,
|
|
2643
|
+
path: "/api/v1/share-tokens/{id}",
|
|
2644
|
+
pathParams: { id },
|
|
2645
|
+
...signal !== void 0 ? { signal } : {}
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// src/resources/treks.ts
|
|
2652
|
+
var ACTIVE_TREK_REF = "active";
|
|
2653
|
+
function createTreksResource(client) {
|
|
2654
|
+
return {
|
|
2655
|
+
async board(options) {
|
|
2656
|
+
const { trekRef, signal } = options;
|
|
2657
|
+
return client.execute({
|
|
2658
|
+
method: "GET",
|
|
2659
|
+
operationId: OperationId.ReadTrekBoard,
|
|
2660
|
+
path: "/api/v1/treks/{trekRef}/board",
|
|
2661
|
+
pathParams: { trekRef },
|
|
2662
|
+
...signal !== void 0 ? { signal } : {}
|
|
2663
|
+
});
|
|
2664
|
+
},
|
|
2665
|
+
async postpone(options) {
|
|
2666
|
+
const { trekRef, idempotencyKey, signal, newStartDate, newEndDate, ...rest } = options;
|
|
2667
|
+
const body = {
|
|
2668
|
+
...rest,
|
|
2669
|
+
newStartDate: normalizeDateTimeInput(newStartDate, "newStartDate"),
|
|
2670
|
+
newEndDate: normalizeDateTimeInput(newEndDate, "newEndDate")
|
|
2671
|
+
};
|
|
2672
|
+
return client.execute({
|
|
2673
|
+
method: "POST",
|
|
2674
|
+
operationId: OperationId.PostponeTrek,
|
|
2675
|
+
path: "/api/v1/treks/{trekRef}/postpone",
|
|
2676
|
+
pathParams: { trekRef },
|
|
2677
|
+
body,
|
|
2678
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2679
|
+
...signal !== void 0 ? { signal } : {}
|
|
2680
|
+
});
|
|
2681
|
+
},
|
|
2682
|
+
walkIns: {
|
|
2683
|
+
async meta(options) {
|
|
2684
|
+
const { trekRef, signal } = options;
|
|
2685
|
+
return client.execute({
|
|
2686
|
+
method: "GET",
|
|
2687
|
+
operationId: OperationId.ReadTrekWalkInMeta,
|
|
2688
|
+
path: "/api/v1/treks/{trekRef}/walk-ins/meta",
|
|
2689
|
+
pathParams: { trekRef },
|
|
2690
|
+
...signal !== void 0 ? { signal } : {}
|
|
2691
|
+
});
|
|
2692
|
+
},
|
|
2693
|
+
async create(options) {
|
|
2694
|
+
const { trekRef, idempotencyKey, signal, ...body } = options;
|
|
2695
|
+
return client.execute({
|
|
2696
|
+
method: "POST",
|
|
2697
|
+
operationId: OperationId.CreateTrekWalkIn,
|
|
2698
|
+
path: "/api/v1/treks/{trekRef}/walk-ins",
|
|
2699
|
+
pathParams: { trekRef },
|
|
2700
|
+
body,
|
|
2701
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2702
|
+
...signal !== void 0 ? { signal } : {}
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
// src/resources/trips.ts
|
|
2710
|
+
function normalizeBulkTripsItem(item, tripIndex) {
|
|
2711
|
+
const { startDate, endDate, sourceUpdatedAt, travellers, balance, managers, ...rest } = item;
|
|
2712
|
+
return {
|
|
2713
|
+
...rest,
|
|
2714
|
+
startDate: normalizeDateTimeInput(startDate, `trips[${tripIndex}].startDate`),
|
|
2715
|
+
endDate: normalizeDateTimeInput(endDate, `trips[${tripIndex}].endDate`),
|
|
2716
|
+
sourceUpdatedAt: normalizeDateTimeInput(sourceUpdatedAt, `trips[${tripIndex}].sourceUpdatedAt`),
|
|
2717
|
+
...travellers !== void 0 ? {
|
|
2718
|
+
travellers: travellers.map((traveller, index) => ({
|
|
2719
|
+
...traveller,
|
|
2720
|
+
sourceUpdatedAt: normalizeDateTimeInput(
|
|
2721
|
+
traveller.sourceUpdatedAt,
|
|
2722
|
+
`trips[${tripIndex}].travellers[${index}].sourceUpdatedAt`
|
|
2723
|
+
)
|
|
2724
|
+
}))
|
|
2725
|
+
} : {},
|
|
2726
|
+
...balance !== void 0 ? {
|
|
2727
|
+
balance: balance.map((row, index) => ({
|
|
2728
|
+
...row,
|
|
2729
|
+
sourceUpdatedAt: normalizeDateTimeInput(
|
|
2730
|
+
row.sourceUpdatedAt,
|
|
2731
|
+
`trips[${tripIndex}].balance[${index}].sourceUpdatedAt`
|
|
2732
|
+
)
|
|
2733
|
+
}))
|
|
2734
|
+
} : {},
|
|
2735
|
+
...managers !== void 0 ? {
|
|
2736
|
+
managers: managers.map((manager, index) => ({
|
|
2737
|
+
...manager,
|
|
2738
|
+
sourceUpdatedAt: normalizeDateTimeInput(
|
|
2739
|
+
manager.sourceUpdatedAt,
|
|
2740
|
+
`trips[${tripIndex}].managers[${index}].sourceUpdatedAt`
|
|
2741
|
+
)
|
|
2742
|
+
}))
|
|
2743
|
+
} : {}
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
function createTripsResource(client) {
|
|
2747
|
+
return {
|
|
2748
|
+
async upsert(options) {
|
|
2749
|
+
const { idempotencyKey, signal, startDate, endDate, sourceUpdatedAt, segments, ...rest } = options;
|
|
2750
|
+
const body = {
|
|
2751
|
+
...rest,
|
|
2752
|
+
startDate: normalizeDateTimeInput(startDate, "startDate"),
|
|
2753
|
+
endDate: normalizeDateTimeInput(endDate, "endDate"),
|
|
2754
|
+
sourceUpdatedAt: normalizeDateTimeInput(sourceUpdatedAt, "sourceUpdatedAt"),
|
|
2755
|
+
...segments !== void 0 ? {
|
|
2756
|
+
segments: segments.map((segment, index) => ({
|
|
2757
|
+
...segment,
|
|
2758
|
+
startDate: normalizeDateTimeInput(
|
|
2759
|
+
segment.startDate,
|
|
2760
|
+
`segments[${index}].startDate`
|
|
2761
|
+
),
|
|
2762
|
+
endDate: normalizeDateTimeInput(segment.endDate, `segments[${index}].endDate`)
|
|
2763
|
+
}))
|
|
2764
|
+
} : {}
|
|
2765
|
+
};
|
|
2766
|
+
return client.execute({
|
|
2767
|
+
method: "POST",
|
|
2768
|
+
operationId: OperationId.UpsertTrip,
|
|
2769
|
+
path: "/api/v1/trips",
|
|
2770
|
+
body,
|
|
2771
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2772
|
+
...signal !== void 0 ? { signal } : {}
|
|
2773
|
+
});
|
|
2774
|
+
},
|
|
2775
|
+
async get(options) {
|
|
2776
|
+
const { tripRef, signal } = options;
|
|
2777
|
+
return client.execute({
|
|
2778
|
+
method: "GET",
|
|
2779
|
+
operationId: OperationId.GetTrip,
|
|
2780
|
+
path: "/api/v1/trips/{ref}",
|
|
2781
|
+
pathParams: { ref: tripRef },
|
|
2782
|
+
...signal !== void 0 ? { signal } : {}
|
|
2783
|
+
});
|
|
2784
|
+
},
|
|
2785
|
+
async cancel(options) {
|
|
2786
|
+
const { tripRef, idempotencyKey, signal } = options;
|
|
2787
|
+
return client.execute({
|
|
2788
|
+
method: "DELETE",
|
|
2789
|
+
operationId: OperationId.CancelTrip,
|
|
2790
|
+
path: "/api/v1/trips/{ref}",
|
|
2791
|
+
pathParams: { ref: tripRef },
|
|
2792
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2793
|
+
...signal !== void 0 ? { signal } : {}
|
|
2794
|
+
});
|
|
2795
|
+
},
|
|
2796
|
+
travellers: {
|
|
2797
|
+
async upsert(options) {
|
|
2798
|
+
const { travellerRef, idempotencyKey, signal, sourceUpdatedAt, ...rest } = options;
|
|
2799
|
+
const body = {
|
|
2800
|
+
...rest,
|
|
2801
|
+
sourceUpdatedAt: normalizeDateTimeInput(sourceUpdatedAt, "sourceUpdatedAt")
|
|
2802
|
+
};
|
|
2803
|
+
return client.execute({
|
|
2804
|
+
method: "POST",
|
|
2805
|
+
operationId: OperationId.UpsertTravellerProfile,
|
|
2806
|
+
path: "/api/v1/travellers/{ref}",
|
|
2807
|
+
pathParams: { ref: travellerRef },
|
|
2808
|
+
body,
|
|
2809
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2810
|
+
...signal !== void 0 ? { signal } : {}
|
|
2811
|
+
});
|
|
2812
|
+
},
|
|
2813
|
+
async pushManifest(options) {
|
|
2814
|
+
const { tripRef, idempotencyKey, signal, travellers, ...rest } = options;
|
|
2815
|
+
const body = {
|
|
2816
|
+
...rest,
|
|
2817
|
+
travellers: travellers.map((traveller, index) => ({
|
|
2818
|
+
...traveller,
|
|
2819
|
+
sourceUpdatedAt: normalizeDateTimeInput(
|
|
2820
|
+
traveller.sourceUpdatedAt,
|
|
2821
|
+
`travellers[${index}].sourceUpdatedAt`
|
|
2822
|
+
)
|
|
2823
|
+
}))
|
|
2824
|
+
};
|
|
2825
|
+
return client.execute({
|
|
2826
|
+
method: "POST",
|
|
2827
|
+
operationId: OperationId.PushManifest,
|
|
2828
|
+
path: "/api/v1/trips/{ref}/travellers",
|
|
2829
|
+
pathParams: { ref: tripRef },
|
|
2830
|
+
body,
|
|
2831
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2832
|
+
...signal !== void 0 ? { signal } : {}
|
|
2833
|
+
});
|
|
2834
|
+
},
|
|
2835
|
+
async remove(options) {
|
|
2836
|
+
const { tripRef, travellerRef, idempotencyKey, signal } = options;
|
|
2837
|
+
return client.execute({
|
|
2838
|
+
method: "DELETE",
|
|
2839
|
+
operationId: OperationId.RemoveFromManifest,
|
|
2840
|
+
path: "/api/v1/trips/{ref}/travellers/{travellerRef}",
|
|
2841
|
+
pathParams: { ref: tripRef, travellerRef },
|
|
2842
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2843
|
+
...signal !== void 0 ? { signal } : {}
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
},
|
|
2847
|
+
managers: {
|
|
2848
|
+
async upsert(options) {
|
|
2849
|
+
const { idempotencyKey, signal, sourceUpdatedAt, ...rest } = options;
|
|
2850
|
+
const body = {
|
|
2851
|
+
...rest,
|
|
2852
|
+
sourceUpdatedAt: normalizeDateTimeInput(sourceUpdatedAt, "sourceUpdatedAt")
|
|
2853
|
+
};
|
|
2854
|
+
return client.execute({
|
|
2855
|
+
method: "POST",
|
|
2856
|
+
operationId: OperationId.UpsertManager,
|
|
2857
|
+
path: "/api/v1/managers",
|
|
2858
|
+
body,
|
|
2859
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2860
|
+
...signal !== void 0 ? { signal } : {}
|
|
2861
|
+
});
|
|
2862
|
+
},
|
|
2863
|
+
async assign(options) {
|
|
2864
|
+
const { tripRef, idempotencyKey, signal, sourceUpdatedAt, ...rest } = options;
|
|
2865
|
+
const body = {
|
|
2866
|
+
...rest,
|
|
2867
|
+
sourceUpdatedAt: normalizeDateTimeInput(sourceUpdatedAt, "sourceUpdatedAt")
|
|
2868
|
+
};
|
|
2869
|
+
return client.execute({
|
|
2870
|
+
method: "POST",
|
|
2871
|
+
operationId: OperationId.AssignManager,
|
|
2872
|
+
path: "/api/v1/trips/{ref}/managers",
|
|
2873
|
+
pathParams: { ref: tripRef },
|
|
2874
|
+
body,
|
|
2875
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2876
|
+
...signal !== void 0 ? { signal } : {}
|
|
2877
|
+
});
|
|
2878
|
+
},
|
|
2879
|
+
async unassign(options) {
|
|
2880
|
+
const { tripRef, managerRef, idempotencyKey, signal } = options;
|
|
2881
|
+
return client.execute({
|
|
2882
|
+
method: "DELETE",
|
|
2883
|
+
operationId: OperationId.UnassignManager,
|
|
2884
|
+
path: "/api/v1/trips/{ref}/managers/{managerRef}",
|
|
2885
|
+
pathParams: { ref: tripRef, managerRef },
|
|
2886
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2887
|
+
...signal !== void 0 ? { signal } : {}
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
},
|
|
2891
|
+
balance: {
|
|
2892
|
+
async push(options) {
|
|
2893
|
+
const { tripRef, balances, idempotencyKey, signal } = options;
|
|
2894
|
+
const body = balances.map((row, index) => ({
|
|
2895
|
+
...row,
|
|
2896
|
+
sourceUpdatedAt: normalizeDateTimeInput(
|
|
2897
|
+
row.sourceUpdatedAt,
|
|
2898
|
+
`balances[${index}].sourceUpdatedAt`
|
|
2899
|
+
)
|
|
2900
|
+
}));
|
|
2901
|
+
return client.execute({
|
|
2902
|
+
method: "POST",
|
|
2903
|
+
operationId: OperationId.PushTripBalances,
|
|
2904
|
+
path: "/api/v1/trips/{ref}/balance",
|
|
2905
|
+
pathParams: { ref: tripRef },
|
|
2906
|
+
body,
|
|
2907
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2908
|
+
...signal !== void 0 ? { signal } : {}
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
},
|
|
2912
|
+
bulk: {
|
|
2913
|
+
async push(options) {
|
|
2914
|
+
const { trips, idempotencyKey, signal } = options;
|
|
2915
|
+
const body = trips.map(
|
|
2916
|
+
(item, index) => normalizeBulkTripsItem(item, index)
|
|
2917
|
+
);
|
|
2918
|
+
return client.execute({
|
|
2919
|
+
method: "POST",
|
|
2920
|
+
operationId: OperationId.PushBulkTrips,
|
|
2921
|
+
path: "/api/v1/bulk/trips",
|
|
2922
|
+
body,
|
|
2923
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2924
|
+
...signal !== void 0 ? { signal } : {}
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
// src/resources/vendors.ts
|
|
2932
|
+
function createVendorsResource(client) {
|
|
2933
|
+
return {
|
|
2934
|
+
async list(options) {
|
|
2935
|
+
const { tripRef, signal } = options;
|
|
2936
|
+
return client.execute({
|
|
2937
|
+
method: "GET",
|
|
2938
|
+
operationId: OperationId.ListTripVendors,
|
|
2939
|
+
path: "/api/v1/trips/{ref}/vendors",
|
|
2940
|
+
pathParams: { ref: tripRef },
|
|
2941
|
+
...signal !== void 0 ? { signal } : {}
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
// src/resources/webhooks.ts
|
|
2948
|
+
async function fetchDeliveriesPage(client, request) {
|
|
2949
|
+
const response = await client.execute({
|
|
2950
|
+
method: "GET",
|
|
2951
|
+
operationId: OperationId.ListWebhookDeliveries,
|
|
2952
|
+
path: "/api/v1/webhooks/deliveries",
|
|
2953
|
+
query: { ...request.filters, cursor: request.cursor, limit: request.limit }
|
|
2954
|
+
});
|
|
2955
|
+
return toPaginatorPage(response);
|
|
2956
|
+
}
|
|
2957
|
+
function createWebhooksResource(client) {
|
|
2958
|
+
return {
|
|
2959
|
+
deliveries: {
|
|
2960
|
+
list(options = {}) {
|
|
2961
|
+
return createPaginator({
|
|
2962
|
+
fetchPage: (request) => fetchDeliveriesPage(client, request),
|
|
2963
|
+
filters: options.filters ?? {},
|
|
2964
|
+
...options.limit !== void 0 ? { limit: options.limit } : {}
|
|
2965
|
+
});
|
|
2966
|
+
},
|
|
2967
|
+
async listPage(options = {}) {
|
|
2968
|
+
const { cursor, limit, signal, ...filters } = options;
|
|
2969
|
+
const response = await client.execute({
|
|
2970
|
+
method: "GET",
|
|
2971
|
+
operationId: OperationId.ListWebhookDeliveries,
|
|
2972
|
+
path: "/api/v1/webhooks/deliveries",
|
|
2973
|
+
query: { ...filters, cursor, limit },
|
|
2974
|
+
...signal !== void 0 ? { signal } : {}
|
|
2975
|
+
});
|
|
2976
|
+
return narrowPaged(response);
|
|
2977
|
+
},
|
|
2978
|
+
async read(options) {
|
|
2979
|
+
const { id, signal } = options;
|
|
2980
|
+
return client.execute({
|
|
2981
|
+
method: "GET",
|
|
2982
|
+
operationId: OperationId.ReadWebhookDelivery,
|
|
2983
|
+
path: "/api/v1/webhooks/deliveries/{id}",
|
|
2984
|
+
pathParams: { id },
|
|
2985
|
+
...signal !== void 0 ? { signal } : {}
|
|
2986
|
+
});
|
|
2987
|
+
},
|
|
2988
|
+
async redeliver(options) {
|
|
2989
|
+
const { id, idempotencyKey, signal } = options;
|
|
2990
|
+
return client.execute({
|
|
2991
|
+
method: "POST",
|
|
2992
|
+
operationId: OperationId.RedeliverWebhookDelivery,
|
|
2993
|
+
path: "/api/v1/webhooks/deliveries/{id}/redeliver",
|
|
2994
|
+
pathParams: { id },
|
|
2995
|
+
body: {},
|
|
2996
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
2997
|
+
...signal !== void 0 ? { signal } : {}
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
},
|
|
3001
|
+
async replay(options) {
|
|
3002
|
+
const { endpointId, idempotencyKey, signal, ...body } = options;
|
|
3003
|
+
return client.execute({
|
|
3004
|
+
method: "POST",
|
|
3005
|
+
operationId: OperationId.ReplayWebhookEndpoint,
|
|
3006
|
+
path: "/api/v1/webhooks/endpoints/{id}/replay",
|
|
3007
|
+
pathParams: { id: endpointId },
|
|
3008
|
+
body,
|
|
3009
|
+
...idempotencyKey !== void 0 ? { idempotencyKey } : {},
|
|
3010
|
+
...signal !== void 0 ? { signal } : {}
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
// src/client.ts
|
|
3017
|
+
var KaafilClosedError = class _KaafilClosedError extends Error {
|
|
3018
|
+
constructor() {
|
|
3019
|
+
super("This Kaafil client has been closed; construct a new one to keep making requests.");
|
|
3020
|
+
this.name = "KaafilClosedError";
|
|
3021
|
+
Object.setPrototypeOf(this, _KaafilClosedError.prototype);
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
var Kaafil = class {
|
|
3025
|
+
#state;
|
|
3026
|
+
constructor(options) {
|
|
3027
|
+
assertValidTimeout(options.timeoutMs);
|
|
3028
|
+
assertValidMaxAttempts(options.maxAttempts);
|
|
3029
|
+
const baseUrl = resolveBaseUrl(options.environment, options.baseUrl);
|
|
3030
|
+
const apiKey = guardApiKeyEnvironment(options.apiKey, options.environment);
|
|
3031
|
+
const credentials = new CredentialResolver({ kind: "apiKey", apiKey });
|
|
3032
|
+
const http = createHttpClient({
|
|
3033
|
+
baseUrl,
|
|
3034
|
+
credentials,
|
|
3035
|
+
...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
|
|
3036
|
+
...options.maxAttempts !== void 0 ? { maxAttempts: options.maxAttempts } : {},
|
|
3037
|
+
...options.userAgent !== void 0 ? { userAgent: options.userAgent } : {},
|
|
3038
|
+
...options.random !== void 0 ? { random: options.random } : {}
|
|
3039
|
+
});
|
|
3040
|
+
this.#state = {
|
|
3041
|
+
http,
|
|
3042
|
+
auth: createAuthResource(http),
|
|
3043
|
+
shareTokens: createShareTokensResource(http),
|
|
3044
|
+
trips: createTripsResource(http),
|
|
3045
|
+
itinerary: createItineraryResource(http),
|
|
3046
|
+
rooming: createRoomingResource(http),
|
|
3047
|
+
seating: createSeatingResource(http),
|
|
3048
|
+
pickups: createPickupsResource(http),
|
|
3049
|
+
treks: createTreksResource(http),
|
|
3050
|
+
checklists: createChecklistsResource(http),
|
|
3051
|
+
vendors: createVendorsResource(http),
|
|
3052
|
+
journey: createJourneyResource(http),
|
|
3053
|
+
webhooks: createWebhooksResource(http),
|
|
3054
|
+
events: createEventsResource(http),
|
|
3055
|
+
files: createFilesResource(http),
|
|
3056
|
+
collections: createCollectionsResource(http),
|
|
3057
|
+
expenses: createExpensesResource(http),
|
|
3058
|
+
float: createFloatResource(http)
|
|
3059
|
+
};
|
|
3060
|
+
}
|
|
3061
|
+
get auth() {
|
|
3062
|
+
return this.#requireState().auth;
|
|
3063
|
+
}
|
|
3064
|
+
get shareTokens() {
|
|
3065
|
+
return this.#requireState().shareTokens;
|
|
3066
|
+
}
|
|
3067
|
+
get trips() {
|
|
3068
|
+
return this.#requireState().trips;
|
|
3069
|
+
}
|
|
3070
|
+
get itinerary() {
|
|
3071
|
+
return this.#requireState().itinerary;
|
|
3072
|
+
}
|
|
3073
|
+
get rooming() {
|
|
3074
|
+
return this.#requireState().rooming;
|
|
3075
|
+
}
|
|
3076
|
+
get seating() {
|
|
3077
|
+
return this.#requireState().seating;
|
|
3078
|
+
}
|
|
3079
|
+
get pickups() {
|
|
3080
|
+
return this.#requireState().pickups;
|
|
3081
|
+
}
|
|
3082
|
+
get treks() {
|
|
3083
|
+
return this.#requireState().treks;
|
|
3084
|
+
}
|
|
3085
|
+
get checklists() {
|
|
3086
|
+
return this.#requireState().checklists;
|
|
3087
|
+
}
|
|
3088
|
+
get vendors() {
|
|
3089
|
+
return this.#requireState().vendors;
|
|
3090
|
+
}
|
|
3091
|
+
get journey() {
|
|
3092
|
+
return this.#requireState().journey;
|
|
3093
|
+
}
|
|
3094
|
+
get webhooks() {
|
|
3095
|
+
return this.#requireState().webhooks;
|
|
3096
|
+
}
|
|
3097
|
+
get events() {
|
|
3098
|
+
return this.#requireState().events;
|
|
3099
|
+
}
|
|
3100
|
+
get files() {
|
|
3101
|
+
return this.#requireState().files;
|
|
3102
|
+
}
|
|
3103
|
+
get collections() {
|
|
3104
|
+
return this.#requireState().collections;
|
|
3105
|
+
}
|
|
3106
|
+
get expenses() {
|
|
3107
|
+
return this.#requireState().expenses;
|
|
3108
|
+
}
|
|
3109
|
+
get float() {
|
|
3110
|
+
return this.#requireState().float;
|
|
3111
|
+
}
|
|
3112
|
+
/**
|
|
3113
|
+
* Total teardown. One assignment, no field to forget — see `KaafilState`
|
|
3114
|
+
* above. Every subsequent call through any resource getter throws
|
|
3115
|
+
* `KaafilClosedError` instead of quietly continuing to work off a
|
|
3116
|
+
* credential this client no longer considers live.
|
|
3117
|
+
*/
|
|
3118
|
+
close() {
|
|
3119
|
+
this.#state = null;
|
|
3120
|
+
}
|
|
3121
|
+
/**
|
|
3122
|
+
* Mints an idempotency key outside the normal per-call flow. Every
|
|
3123
|
+
* mutating method already mints and reuses one automatically
|
|
3124
|
+
* (`http/client.ts`) — this exists for the rare case of pinning a key
|
|
3125
|
+
* ahead of time, to replay the exact same logical operation across a
|
|
3126
|
+
* process restart.
|
|
3127
|
+
*/
|
|
3128
|
+
static newIdempotencyKey() {
|
|
3129
|
+
return newIdempotencyKey();
|
|
3130
|
+
}
|
|
3131
|
+
#requireState() {
|
|
3132
|
+
if (this.#state === null) {
|
|
3133
|
+
throw new KaafilClosedError();
|
|
3134
|
+
}
|
|
3135
|
+
return this.#state;
|
|
3136
|
+
}
|
|
3137
|
+
};
|
|
3138
|
+
|
|
3139
|
+
// src/delta/cursor.ts
|
|
3140
|
+
function isTombstone(row) {
|
|
3141
|
+
return row._tombstone === true;
|
|
3142
|
+
}
|
|
3143
|
+
function mergeDeltaRows(store, rows) {
|
|
3144
|
+
let added = 0;
|
|
3145
|
+
let updated = 0;
|
|
3146
|
+
let removed = 0;
|
|
3147
|
+
let unchanged = 0;
|
|
3148
|
+
for (const row of rows) {
|
|
3149
|
+
const held = store.get(row.id);
|
|
3150
|
+
if (isTombstone(row)) {
|
|
3151
|
+
if (held === void 0 || held.version > row.version) {
|
|
3152
|
+
unchanged += 1;
|
|
3153
|
+
continue;
|
|
3154
|
+
}
|
|
3155
|
+
store.delete(row.id);
|
|
3156
|
+
removed += 1;
|
|
3157
|
+
continue;
|
|
3158
|
+
}
|
|
3159
|
+
if (held === void 0) {
|
|
3160
|
+
store.set(row.id, row);
|
|
3161
|
+
added += 1;
|
|
3162
|
+
continue;
|
|
3163
|
+
}
|
|
3164
|
+
if (held.version >= row.version) {
|
|
3165
|
+
unchanged += 1;
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3168
|
+
store.set(row.id, row);
|
|
3169
|
+
updated += 1;
|
|
3170
|
+
}
|
|
3171
|
+
return { added, updated, removed, unchanged };
|
|
3172
|
+
}
|
|
3173
|
+
var KaafilDeltaCursorInFlightError = class _KaafilDeltaCursorInFlightError extends Error {
|
|
3174
|
+
constructor() {
|
|
3175
|
+
super(
|
|
3176
|
+
"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."
|
|
3177
|
+
);
|
|
3178
|
+
this.name = "KaafilDeltaCursorInFlightError";
|
|
3179
|
+
Object.setPrototypeOf(this, _KaafilDeltaCursorInFlightError.prototype);
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
function createDeltaCursor(config) {
|
|
3183
|
+
const { fetchDelta } = config;
|
|
3184
|
+
const state = {
|
|
3185
|
+
cursor: void 0,
|
|
3186
|
+
isLoading: false
|
|
3187
|
+
};
|
|
3188
|
+
function restore(cursor) {
|
|
3189
|
+
state.cursor = normalizeDateTimeInput(cursor, "cursor");
|
|
3190
|
+
}
|
|
3191
|
+
if (config.cursor !== void 0) {
|
|
3192
|
+
restore(config.cursor);
|
|
3193
|
+
}
|
|
3194
|
+
async function pull(options = {}) {
|
|
3195
|
+
if (state.isLoading) {
|
|
3196
|
+
throw new KaafilDeltaCursorInFlightError();
|
|
3197
|
+
}
|
|
3198
|
+
const previousCursor = state.cursor;
|
|
3199
|
+
state.isLoading = true;
|
|
3200
|
+
try {
|
|
3201
|
+
const response = await fetchDelta({ since: previousCursor, signal: options.signal });
|
|
3202
|
+
state.cursor = response.meta.serverTime;
|
|
3203
|
+
return {
|
|
3204
|
+
data: response,
|
|
3205
|
+
meta: response.meta,
|
|
3206
|
+
cursor: response.meta.serverTime,
|
|
3207
|
+
previousCursor
|
|
3208
|
+
};
|
|
3209
|
+
} finally {
|
|
3210
|
+
state.isLoading = false;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
return {
|
|
3214
|
+
get cursor() {
|
|
3215
|
+
return state.cursor;
|
|
3216
|
+
},
|
|
3217
|
+
get isLoading() {
|
|
3218
|
+
return state.isLoading;
|
|
3219
|
+
},
|
|
3220
|
+
get hasSynced() {
|
|
3221
|
+
return state.cursor !== void 0;
|
|
3222
|
+
},
|
|
3223
|
+
pull,
|
|
3224
|
+
restore,
|
|
3225
|
+
reset() {
|
|
3226
|
+
state.cursor = void 0;
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
// src/generated/enums.ts
|
|
3232
|
+
var BoardStatus = {
|
|
3233
|
+
Boarded: "BOARDED",
|
|
3234
|
+
NoShow: "NO_SHOW"
|
|
3235
|
+
};
|
|
3236
|
+
var BookingStatus = {
|
|
3237
|
+
Confirmed: "CONFIRMED",
|
|
3238
|
+
Tentative: "TENTATIVE",
|
|
3239
|
+
Cancelled: "CANCELLED"
|
|
3240
|
+
};
|
|
3241
|
+
var ChecklistAudience = {
|
|
3242
|
+
Internal: "INTERNAL",
|
|
3243
|
+
External: "EXTERNAL"
|
|
3244
|
+
};
|
|
3245
|
+
var ChecklistGate = {
|
|
3246
|
+
None: "NONE",
|
|
3247
|
+
PreToActive: "PRE_TO_ACTIVE",
|
|
3248
|
+
ActiveToClosedOut: "ACTIVE_TO_CLOSED_OUT"
|
|
3249
|
+
};
|
|
3250
|
+
var ChecklistItemStatus = {
|
|
3251
|
+
Open: "OPEN",
|
|
3252
|
+
Complete: "COMPLETE"
|
|
3253
|
+
};
|
|
3254
|
+
var ChecklistPhase = {
|
|
3255
|
+
PreDeparture: "PRE_DEPARTURE",
|
|
3256
|
+
InTrip: "IN_TRIP",
|
|
3257
|
+
PostTrip: "POST_TRIP"
|
|
3258
|
+
};
|
|
3259
|
+
var ChecklistPullTemplateMode = {
|
|
3260
|
+
Append: "append",
|
|
3261
|
+
Replace: "replace"
|
|
3262
|
+
};
|
|
3263
|
+
var ClaimStatusIngest = {
|
|
3264
|
+
Approved: "APPROVED",
|
|
3265
|
+
Paid: "PAID",
|
|
3266
|
+
Rejected: "REJECTED"
|
|
3267
|
+
};
|
|
3268
|
+
var CollectionMode = {
|
|
3269
|
+
Cash: "CASH",
|
|
3270
|
+
Upi: "UPI",
|
|
3271
|
+
Card: "CARD",
|
|
3272
|
+
Bank: "BANK"
|
|
3273
|
+
};
|
|
3274
|
+
var Currency = {
|
|
3275
|
+
Inr: "INR"
|
|
3276
|
+
};
|
|
3277
|
+
var EventType = {
|
|
3278
|
+
Trip: "TRIP",
|
|
3279
|
+
Trek: "TREK"
|
|
3280
|
+
};
|
|
3281
|
+
var ExpenseCategory = {
|
|
3282
|
+
Accom: "ACCOM",
|
|
3283
|
+
Food: "FOOD",
|
|
3284
|
+
Transport: "TRANSPORT",
|
|
3285
|
+
Activity: "ACTIVITY",
|
|
3286
|
+
Misc: "MISC"
|
|
3287
|
+
};
|
|
3288
|
+
var ExpensePaymentMode = {
|
|
3289
|
+
FloatCash: "FLOAT_CASH",
|
|
3290
|
+
Personal: "PERSONAL",
|
|
3291
|
+
Other: "OTHER"
|
|
3292
|
+
};
|
|
3293
|
+
var FileContentType = {
|
|
3294
|
+
ImageJpeg: "image/jpeg",
|
|
3295
|
+
ImagePng: "image/png",
|
|
3296
|
+
ImageWebp: "image/webp",
|
|
3297
|
+
ImageHeic: "image/heic",
|
|
3298
|
+
ApplicationPdf: "application/pdf"
|
|
3299
|
+
};
|
|
3300
|
+
var FilePurpose = {
|
|
3301
|
+
ExpenseReceipt: "expense_receipt",
|
|
3302
|
+
FormAttachment: "form_attachment",
|
|
3303
|
+
BookingVoucher: "booking_voucher"
|
|
3304
|
+
};
|
|
3305
|
+
var FloatDirection = {
|
|
3306
|
+
In: "IN",
|
|
3307
|
+
Out: "OUT"
|
|
3308
|
+
};
|
|
3309
|
+
var Gender = {
|
|
3310
|
+
Male: "MALE",
|
|
3311
|
+
Female: "FEMALE",
|
|
3312
|
+
Other: "OTHER",
|
|
3313
|
+
Unknown: "UNKNOWN"
|
|
3314
|
+
};
|
|
3315
|
+
var ItineraryItemStatusUpdate = {
|
|
3316
|
+
Planned: "PLANNED",
|
|
3317
|
+
Completed: "COMPLETED",
|
|
3318
|
+
Skipped: "SKIPPED"
|
|
3319
|
+
};
|
|
3320
|
+
var ItineraryItemType = {
|
|
3321
|
+
Accommodation: "ACCOMMODATION",
|
|
3322
|
+
Transport: "TRANSPORT",
|
|
3323
|
+
Activity: "ACTIVITY",
|
|
3324
|
+
Meal: "MEAL",
|
|
3325
|
+
Other: "OTHER"
|
|
3326
|
+
};
|
|
3327
|
+
var ManagerRole = {
|
|
3328
|
+
Manager: "MANAGER",
|
|
3329
|
+
Coordinator: "COORDINATOR"
|
|
3330
|
+
};
|
|
3331
|
+
var ManifestMode = {
|
|
3332
|
+
Merge: "merge",
|
|
3333
|
+
Replace: "replace"
|
|
3334
|
+
};
|
|
3335
|
+
var PartyKind = {
|
|
3336
|
+
Family: "FAMILY",
|
|
3337
|
+
Couple: "COUPLE",
|
|
3338
|
+
Friends: "FRIENDS",
|
|
3339
|
+
Corporate: "CORPORATE",
|
|
3340
|
+
Other: "OTHER"
|
|
3341
|
+
};
|
|
3342
|
+
var PickupKind = {
|
|
3343
|
+
Pickup: "PICKUP",
|
|
3344
|
+
Drop: "DROP"
|
|
3345
|
+
};
|
|
3346
|
+
var RoomingFillOrder = {
|
|
3347
|
+
LargestRoomFirst: "LARGEST_ROOM_FIRST",
|
|
3348
|
+
Sequential: "SEQUENTIAL",
|
|
3349
|
+
Balanced: "BALANCED"
|
|
3350
|
+
};
|
|
3351
|
+
var RoomingGenderPolicy = {
|
|
3352
|
+
StrictSeparate: "STRICT_SEPARATE",
|
|
3353
|
+
GroupMixedOk: "GROUP_MIXED_OK",
|
|
3354
|
+
Off: "OFF"
|
|
3355
|
+
};
|
|
3356
|
+
var RoomingHeuristicKey = {
|
|
3357
|
+
MedicalFirst: "medicalFirst",
|
|
3358
|
+
Couples: "couples",
|
|
3359
|
+
Parties: "parties",
|
|
3360
|
+
Gender: "gender",
|
|
3361
|
+
Diet: "diet",
|
|
3362
|
+
SpreadSolos: "spreadSolos",
|
|
3363
|
+
PartyGenderPolicy: "partyGenderPolicy",
|
|
3364
|
+
SameBus: "sameBus"
|
|
3365
|
+
};
|
|
3366
|
+
var RoomType = {
|
|
3367
|
+
Single: "SINGLE",
|
|
3368
|
+
Twin: "TWIN",
|
|
3369
|
+
Shared: "SHARED",
|
|
3370
|
+
Dorm: "DORM"
|
|
3371
|
+
};
|
|
3372
|
+
var SeatingFillOrder = {
|
|
3373
|
+
Balanced: "BALANCED",
|
|
3374
|
+
FillFirst: "FILL_FIRST",
|
|
3375
|
+
ByStop: "BY_STOP"
|
|
3376
|
+
};
|
|
3377
|
+
var SeatingGenderAdjacency = {
|
|
3378
|
+
Off: "OFF",
|
|
3379
|
+
AvoidUnrelated: "AVOID_UNRELATED",
|
|
3380
|
+
StrictRows: "STRICT_ROWS"
|
|
3381
|
+
};
|
|
3382
|
+
var SeatingHeuristicKey = {
|
|
3383
|
+
MedicalFirst: "medicalFirst",
|
|
3384
|
+
Parties: "parties",
|
|
3385
|
+
SameStop: "sameStop",
|
|
3386
|
+
Gender: "gender",
|
|
3387
|
+
BalanceVehicles: "balanceVehicles"
|
|
3388
|
+
};
|
|
3389
|
+
var TriggerAnchor = {
|
|
3390
|
+
Start: "START",
|
|
3391
|
+
End: "END"
|
|
3392
|
+
};
|
|
3393
|
+
var TripMode = {
|
|
3394
|
+
Group: "GROUP",
|
|
3395
|
+
Personalized: "PERSONALIZED"
|
|
3396
|
+
};
|
|
3397
|
+
var TripStatus = {
|
|
3398
|
+
Confirmed: "CONFIRMED",
|
|
3399
|
+
InProgress: "IN_PROGRESS",
|
|
3400
|
+
Completed: "COMPLETED",
|
|
3401
|
+
Postponed: "POSTPONED",
|
|
3402
|
+
Cancelled: "CANCELLED"
|
|
3403
|
+
};
|
|
3404
|
+
var VehicleLayout = {
|
|
3405
|
+
TwoTwo: "TWO_TWO",
|
|
3406
|
+
TwoOne: "TWO_ONE",
|
|
3407
|
+
Flat: "FLAT"
|
|
3408
|
+
};
|
|
3409
|
+
var VehicleType = {
|
|
3410
|
+
Bus: "BUS",
|
|
3411
|
+
TempoTraveller: "TEMPO_TRAVELLER",
|
|
3412
|
+
Car: "CAR",
|
|
3413
|
+
Flight: "FLIGHT",
|
|
3414
|
+
Train: "TRAIN",
|
|
3415
|
+
Other: "OTHER"
|
|
3416
|
+
};
|
|
3417
|
+
|
|
3418
|
+
// src/rooming/vocabulary.ts
|
|
3419
|
+
var HEURISTIC_SEVERITY = Object.freeze({
|
|
3420
|
+
medicalFirst: "warn",
|
|
3421
|
+
couples: "warn",
|
|
3422
|
+
parties: "split",
|
|
3423
|
+
gender: "never",
|
|
3424
|
+
diet: "info",
|
|
3425
|
+
spreadSolos: "info",
|
|
3426
|
+
partyGenderPolicy: "info",
|
|
3427
|
+
sameBus: "info"
|
|
3428
|
+
});
|
|
3429
|
+
function isRoomingHeuristicKey(rule) {
|
|
3430
|
+
return Object.hasOwn(HEURISTIC_SEVERITY, rule);
|
|
3431
|
+
}
|
|
3432
|
+
function roomingHeuristicSeverity(rule) {
|
|
3433
|
+
return isRoomingHeuristicKey(rule) ? HEURISTIC_SEVERITY[rule] : void 0;
|
|
3434
|
+
}
|
|
3435
|
+
var TONE_FAMILIES = Object.freeze({
|
|
3436
|
+
[Gender.Male]: "male",
|
|
3437
|
+
[Gender.Female]: "female",
|
|
3438
|
+
[Gender.Other]: "other",
|
|
3439
|
+
[Gender.Unknown]: "unknown"
|
|
3440
|
+
});
|
|
3441
|
+
var UNKNOWN_TONE_FAMILY = TONE_FAMILIES[Gender.Unknown];
|
|
3442
|
+
var SHADES_PER_FAMILY = 8;
|
|
3443
|
+
var FALLBACK_GLYPH = "?";
|
|
3444
|
+
function parseRoomingTone(tone) {
|
|
3445
|
+
const separator = tone.lastIndexOf(".");
|
|
3446
|
+
if (separator <= 0 || separator === tone.length - 1) {
|
|
3447
|
+
return void 0;
|
|
3448
|
+
}
|
|
3449
|
+
const family = tone.slice(0, separator);
|
|
3450
|
+
const rawShade = tone.slice(separator + 1);
|
|
3451
|
+
const shade = Number(rawShade);
|
|
3452
|
+
if (!Number.isInteger(shade) || shade < 0) {
|
|
3453
|
+
return void 0;
|
|
3454
|
+
}
|
|
3455
|
+
return { family, shade };
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
exports.ACTIVE_TREK_REF = ACTIVE_TREK_REF;
|
|
3459
|
+
exports.ApiKeyEnvironmentMismatchError = ApiKeyEnvironmentMismatchError;
|
|
3460
|
+
exports.BoardStatus = BoardStatus;
|
|
3461
|
+
exports.BookingStatus = BookingStatus;
|
|
3462
|
+
exports.ChecklistAudience = ChecklistAudience;
|
|
3463
|
+
exports.ChecklistGate = ChecklistGate;
|
|
3464
|
+
exports.ChecklistItemStatus = ChecklistItemStatus;
|
|
3465
|
+
exports.ChecklistPhase = ChecklistPhase;
|
|
3466
|
+
exports.ChecklistPullTemplateMode = ChecklistPullTemplateMode;
|
|
3467
|
+
exports.ClaimStatusIngest = ClaimStatusIngest;
|
|
3468
|
+
exports.CollectionMode = CollectionMode;
|
|
3469
|
+
exports.Currency = Currency;
|
|
3470
|
+
exports.ERROR_CODE_TABLE = ERROR_CODE_TABLE;
|
|
3471
|
+
exports.Environment = Environment;
|
|
3472
|
+
exports.EventType = EventType;
|
|
3473
|
+
exports.ExpenseCategory = ExpenseCategory;
|
|
3474
|
+
exports.ExpensePaymentMode = ExpensePaymentMode;
|
|
3475
|
+
exports.FALLBACK_GLYPH = FALLBACK_GLYPH;
|
|
3476
|
+
exports.FileContentType = FileContentType;
|
|
3477
|
+
exports.FilePurpose = FilePurpose;
|
|
3478
|
+
exports.FloatDirection = FloatDirection;
|
|
3479
|
+
exports.Gender = Gender;
|
|
3480
|
+
exports.HEURISTIC_SEVERITY = HEURISTIC_SEVERITY;
|
|
3481
|
+
exports.ItineraryItemStatusUpdate = ItineraryItemStatusUpdate;
|
|
3482
|
+
exports.ItineraryItemType = ItineraryItemType;
|
|
3483
|
+
exports.Kaafil = Kaafil;
|
|
3484
|
+
exports.KaafilAbortError = KaafilAbortError;
|
|
3485
|
+
exports.KaafilApiError = KaafilApiError;
|
|
3486
|
+
exports.KaafilCapabilityUnavailableError = KaafilCapabilityUnavailableError;
|
|
3487
|
+
exports.KaafilClosedError = KaafilClosedError;
|
|
3488
|
+
exports.KaafilConfigError = KaafilConfigError;
|
|
3489
|
+
exports.KaafilDeltaCursorInFlightError = KaafilDeltaCursorInFlightError;
|
|
3490
|
+
exports.KaafilEntitlementError = KaafilEntitlementError;
|
|
3491
|
+
exports.KaafilError = KaafilError;
|
|
3492
|
+
exports.KaafilErrorCode = KaafilErrorCode;
|
|
3493
|
+
exports.KaafilInvalidRequestError = KaafilInvalidRequestError;
|
|
3494
|
+
exports.KaafilLockedError = KaafilLockedError;
|
|
3495
|
+
exports.KaafilNetworkError = KaafilNetworkError;
|
|
3496
|
+
exports.KaafilNotFoundError = KaafilNotFoundError;
|
|
3497
|
+
exports.KaafilNotImplementedError = KaafilNotImplementedError;
|
|
3498
|
+
exports.KaafilPaginationError = KaafilPaginationError;
|
|
3499
|
+
exports.KaafilPaginationExhaustedError = KaafilPaginationExhaustedError;
|
|
3500
|
+
exports.KaafilPaginationInFlightError = KaafilPaginationInFlightError;
|
|
3501
|
+
exports.KaafilRateLimitedError = KaafilRateLimitedError;
|
|
3502
|
+
exports.KaafilReadOnlyRoleError = KaafilReadOnlyRoleError;
|
|
3503
|
+
exports.KaafilShareTokenExpiredError = KaafilShareTokenExpiredError;
|
|
3504
|
+
exports.KaafilShareTokenRevokedError = KaafilShareTokenRevokedError;
|
|
3505
|
+
exports.KaafilTimeoutError = KaafilTimeoutError;
|
|
3506
|
+
exports.KaafilTransportError = KaafilTransportError;
|
|
3507
|
+
exports.KaafilUnauthenticatedError = KaafilUnauthenticatedError;
|
|
3508
|
+
exports.KaafilValidationError = KaafilValidationError;
|
|
3509
|
+
exports.KaafilVersionConflictError = KaafilVersionConflictError;
|
|
3510
|
+
exports.ManagerRole = ManagerRole;
|
|
3511
|
+
exports.ManifestMode = ManifestMode;
|
|
3512
|
+
exports.OutboxClass = OutboxClass;
|
|
3513
|
+
exports.PartyKind = PartyKind;
|
|
3514
|
+
exports.PickupKind = PickupKind;
|
|
3515
|
+
exports.Retryability = Retryability;
|
|
3516
|
+
exports.RoomType = RoomType;
|
|
3517
|
+
exports.RoomingFillOrder = RoomingFillOrder;
|
|
3518
|
+
exports.RoomingGenderPolicy = RoomingGenderPolicy;
|
|
3519
|
+
exports.RoomingHeuristicKey = RoomingHeuristicKey;
|
|
3520
|
+
exports.SHADES_PER_FAMILY = SHADES_PER_FAMILY;
|
|
3521
|
+
exports.SeatingFillOrder = SeatingFillOrder;
|
|
3522
|
+
exports.SeatingGenderAdjacency = SeatingGenderAdjacency;
|
|
3523
|
+
exports.SeatingHeuristicKey = SeatingHeuristicKey;
|
|
3524
|
+
exports.TONE_FAMILIES = TONE_FAMILIES;
|
|
3525
|
+
exports.TriggerAnchor = TriggerAnchor;
|
|
3526
|
+
exports.TripMode = TripMode;
|
|
3527
|
+
exports.TripStatus = TripStatus;
|
|
3528
|
+
exports.UNKNOWN_TONE_FAMILY = UNKNOWN_TONE_FAMILY;
|
|
3529
|
+
exports.UnsatisfiableSchemeError = UnsatisfiableSchemeError;
|
|
3530
|
+
exports.VehicleLayout = VehicleLayout;
|
|
3531
|
+
exports.VehicleType = VehicleType;
|
|
3532
|
+
exports.createDeltaCursor = createDeltaCursor;
|
|
3533
|
+
exports.isKaafilError = isKaafilError;
|
|
3534
|
+
exports.isRetryable = isRetryable;
|
|
3535
|
+
exports.isRoomingHeuristicKey = isRoomingHeuristicKey;
|
|
3536
|
+
exports.isTombstone = isTombstone;
|
|
3537
|
+
exports.mergeDeltaRows = mergeDeltaRows;
|
|
3538
|
+
exports.parseRoomingTone = parseRoomingTone;
|
|
3539
|
+
exports.roomingHeuristicSeverity = roomingHeuristicSeverity;
|
|
3540
|
+
//# sourceMappingURL=index.cjs.map
|
|
3541
|
+
//# sourceMappingURL=index.cjs.map
|