@ultra-network/sdk-ts 0.1.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 +91 -0
- package/dist/index.cjs +114 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +575 -0
- package/dist/index.d.ts +575 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
interface components {
|
|
2
|
+
schemas: {
|
|
3
|
+
Money: {
|
|
4
|
+
/** Minor units (cents). 10000 = USD 100.00. */
|
|
5
|
+
amount: number;
|
|
6
|
+
/** ISO 4217 currency code. */
|
|
7
|
+
currency: string;
|
|
8
|
+
};
|
|
9
|
+
Error: {
|
|
10
|
+
error: {
|
|
11
|
+
code:
|
|
12
|
+
| 'unauthenticated'
|
|
13
|
+
| 'forbidden'
|
|
14
|
+
| 'not_found'
|
|
15
|
+
| 'method_not_allowed'
|
|
16
|
+
| 'validation_failed'
|
|
17
|
+
| 'rate_limited'
|
|
18
|
+
| 'conflict'
|
|
19
|
+
| 'internal_error'
|
|
20
|
+
| 'upstream_unavailable'
|
|
21
|
+
| 'feature_disabled';
|
|
22
|
+
message: string;
|
|
23
|
+
/** Same value as the X-Request-Id response header. */
|
|
24
|
+
request_id: string;
|
|
25
|
+
/** Optional structured context (e.g. Zod issues for validation_failed). */
|
|
26
|
+
details?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
PageMeta: {
|
|
30
|
+
/** Cursor for the next page. `null` when no more results. */
|
|
31
|
+
next_cursor: string | null;
|
|
32
|
+
has_more: boolean;
|
|
33
|
+
limit: number;
|
|
34
|
+
};
|
|
35
|
+
Trip: {
|
|
36
|
+
id: string;
|
|
37
|
+
organization_id: string;
|
|
38
|
+
title: string | null;
|
|
39
|
+
stage:
|
|
40
|
+
| 'enquiry_received'
|
|
41
|
+
| 'qualifying'
|
|
42
|
+
| 'draft_plan'
|
|
43
|
+
| 'proposal_sent'
|
|
44
|
+
| 'negotiating'
|
|
45
|
+
| 'booked'
|
|
46
|
+
| 'follow_up'
|
|
47
|
+
| 'in_progress'
|
|
48
|
+
| 'completed'
|
|
49
|
+
| 'lost'
|
|
50
|
+
| 'archived';
|
|
51
|
+
priority: 'low' | 'medium' | 'high' | 'urgent';
|
|
52
|
+
source: 'whatsapp' | 'sms' | 'email' | 'web_form' | 'widget' | 'manual' | 'phone';
|
|
53
|
+
destination: string | null;
|
|
54
|
+
origin_city: string | null;
|
|
55
|
+
start_date: string | null;
|
|
56
|
+
end_date: string | null;
|
|
57
|
+
party_size: number;
|
|
58
|
+
/** Indicative budget. May be advisor-internal — clients without view access see `null`. */
|
|
59
|
+
budget: components['schemas']['Money'] | null;
|
|
60
|
+
/** Lead traveller. PII (email, phone) is intentionally omitted from v1. */
|
|
61
|
+
client: { id: string; name: string } | null;
|
|
62
|
+
created_at: string;
|
|
63
|
+
updated_at: string;
|
|
64
|
+
booked_at: string | null;
|
|
65
|
+
completed_at: string | null;
|
|
66
|
+
};
|
|
67
|
+
CreateTripInput: {
|
|
68
|
+
/** Lead traveller — must already exist and belong to your org. */
|
|
69
|
+
client_id: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
destination?: string;
|
|
72
|
+
origin_city?: string;
|
|
73
|
+
start_date?: string;
|
|
74
|
+
end_date?: string;
|
|
75
|
+
party_size?: number;
|
|
76
|
+
priority?: 'low' | 'medium' | 'high' | 'urgent';
|
|
77
|
+
source?: 'whatsapp' | 'sms' | 'email' | 'web_form' | 'widget' | 'manual' | 'phone';
|
|
78
|
+
budget?: components['schemas']['Money'];
|
|
79
|
+
special_requests?: string[];
|
|
80
|
+
/** Free-form notes attached to the trip. Stored but not surfaced in any public read. */
|
|
81
|
+
internal_notes?: string;
|
|
82
|
+
};
|
|
83
|
+
SupplierContact: {
|
|
84
|
+
name: string | null;
|
|
85
|
+
email: string | null;
|
|
86
|
+
phone: string | null;
|
|
87
|
+
website: string | null;
|
|
88
|
+
};
|
|
89
|
+
Supplier: {
|
|
90
|
+
id: string;
|
|
91
|
+
organization_id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
category:
|
|
94
|
+
| 'hotel'
|
|
95
|
+
| 'restaurant'
|
|
96
|
+
| 'transport_car'
|
|
97
|
+
| 'transport_jet'
|
|
98
|
+
| 'transport_helicopter'
|
|
99
|
+
| 'flight'
|
|
100
|
+
| 'activity'
|
|
101
|
+
| 'cruise'
|
|
102
|
+
| 'tour'
|
|
103
|
+
| 'dmc'
|
|
104
|
+
| 'wholesale'
|
|
105
|
+
| 'platform'
|
|
106
|
+
| 'channel_manager'
|
|
107
|
+
| 'hub_marketplace'
|
|
108
|
+
| 'insurance'
|
|
109
|
+
| 'visa'
|
|
110
|
+
| 'other';
|
|
111
|
+
onboarding_status:
|
|
112
|
+
| 'pending_application'
|
|
113
|
+
| 'application_approved'
|
|
114
|
+
| 'profile_setup'
|
|
115
|
+
| 'documents_uploaded'
|
|
116
|
+
| 'agreement_pending'
|
|
117
|
+
| 'agreement_signed'
|
|
118
|
+
| 'active'
|
|
119
|
+
| 'suspended';
|
|
120
|
+
/** ISO 3166-1 alpha-2. */
|
|
121
|
+
country: string | null;
|
|
122
|
+
address: string | null;
|
|
123
|
+
logo_url: string | null;
|
|
124
|
+
cover_image_url: string | null;
|
|
125
|
+
is_active: boolean;
|
|
126
|
+
/** Hint that this supplier is on the Ultra preferred-partner list. A curation flag, not a quality score. */
|
|
127
|
+
is_preferred: boolean;
|
|
128
|
+
/** Null when the supplier is not fully onboarded (privacy gate). */
|
|
129
|
+
contact: components['schemas']['SupplierContact'] | null;
|
|
130
|
+
created_at: string;
|
|
131
|
+
updated_at: string;
|
|
132
|
+
};
|
|
133
|
+
Booking: {
|
|
134
|
+
id: string;
|
|
135
|
+
trip_id: string;
|
|
136
|
+
/** The supplier adapter that owns this booking (e.g. `hbt`, `drivado`, `manual`). */
|
|
137
|
+
supplier_source: string;
|
|
138
|
+
/** The supplier's own reference for this booking (PNR / confirmation code). */
|
|
139
|
+
supplier_booking_id: string | null;
|
|
140
|
+
venue_name: string;
|
|
141
|
+
venue_type: string | null;
|
|
142
|
+
destination: string | null;
|
|
143
|
+
check_in: string | null;
|
|
144
|
+
check_out: string | null;
|
|
145
|
+
guest_count: number | null;
|
|
146
|
+
total: components['schemas']['Money'];
|
|
147
|
+
status:
|
|
148
|
+
| 'provisional'
|
|
149
|
+
| 'confirmed'
|
|
150
|
+
| 'active'
|
|
151
|
+
| 'completed'
|
|
152
|
+
| 'expired'
|
|
153
|
+
| 'failed'
|
|
154
|
+
| 'cancelled'
|
|
155
|
+
| 'pending_supplier_confirmation'
|
|
156
|
+
| 'rejected'
|
|
157
|
+
| 'modified';
|
|
158
|
+
payment_status:
|
|
159
|
+
| 'pending'
|
|
160
|
+
| 'pending_confirmation'
|
|
161
|
+
| 'authorized'
|
|
162
|
+
| 'captured'
|
|
163
|
+
| 'partially_refunded'
|
|
164
|
+
| 'refunded'
|
|
165
|
+
| 'failed'
|
|
166
|
+
| 'cancelled'
|
|
167
|
+
| 'disputed';
|
|
168
|
+
/** Direct link to the supplier-issued voucher / itinerary PDF, when available. */
|
|
169
|
+
voucher_url: string | null;
|
|
170
|
+
created_at: string;
|
|
171
|
+
confirmed_at: string | null;
|
|
172
|
+
cancelled_at: string | null;
|
|
173
|
+
completed_at: string | null;
|
|
174
|
+
updated_at: string;
|
|
175
|
+
};
|
|
176
|
+
CreateBookingInput: {
|
|
177
|
+
/** The trip this booking belongs to. Must belong to your org. */
|
|
178
|
+
trip_id: string;
|
|
179
|
+
supplier_source?:
|
|
180
|
+
| 'manual'
|
|
181
|
+
| 'hbt'
|
|
182
|
+
| 'drivado'
|
|
183
|
+
| 'nuitee'
|
|
184
|
+
| 'ratestellar'
|
|
185
|
+
| 'saltours'
|
|
186
|
+
| 'mews'
|
|
187
|
+
| 'apaleo'
|
|
188
|
+
| 'tue'
|
|
189
|
+
| 'limohawk'
|
|
190
|
+
| 'oracle_ohip';
|
|
191
|
+
/** For `manual`: optional link to the trip item this confirms. For any adapter source: REQUIRED. */
|
|
192
|
+
plan_item_id?: string;
|
|
193
|
+
supplier_booking_id?: string;
|
|
194
|
+
venue_name?: string;
|
|
195
|
+
venue_type?: string;
|
|
196
|
+
destination?: string;
|
|
197
|
+
check_in?: string;
|
|
198
|
+
check_out?: string;
|
|
199
|
+
guest_count?: number;
|
|
200
|
+
total?: components['schemas']['Money'];
|
|
201
|
+
voucher_url?: string;
|
|
202
|
+
/** Lead guest. Required for adapter-dispatched sources; ignored for `manual`. */
|
|
203
|
+
guest?: {
|
|
204
|
+
first_name: string;
|
|
205
|
+
last_name: string;
|
|
206
|
+
email?: string;
|
|
207
|
+
phone?: string;
|
|
208
|
+
nationality?: string;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
UpdateBookingInput: {
|
|
212
|
+
status?: components['schemas']['Booking']['status'];
|
|
213
|
+
payment_status?: components['schemas']['Booking']['payment_status'];
|
|
214
|
+
supplier_booking_id?: string | null;
|
|
215
|
+
voucher_url?: string | null;
|
|
216
|
+
cancellation_reason?: string;
|
|
217
|
+
};
|
|
218
|
+
TripItem: {
|
|
219
|
+
id: string;
|
|
220
|
+
type: 'accommodation' | 'transport' | 'activity' | 'dining' | 'other';
|
|
221
|
+
title: string;
|
|
222
|
+
/** 0-indexed day within the trip. Day 0 = arrival day. */
|
|
223
|
+
day_index: number;
|
|
224
|
+
location: string | null;
|
|
225
|
+
/** 24-hour HH:MM. Null when not scheduled. */
|
|
226
|
+
start_time: string | null;
|
|
227
|
+
end_time: string | null;
|
|
228
|
+
check_in: string | null;
|
|
229
|
+
check_out: string | null;
|
|
230
|
+
notes: string | null;
|
|
231
|
+
price: components['schemas']['Money'] | null;
|
|
232
|
+
supplier_source: string | null;
|
|
233
|
+
};
|
|
234
|
+
CreateTripItemInput: {
|
|
235
|
+
type: 'accommodation' | 'transport' | 'activity' | 'dining' | 'other';
|
|
236
|
+
title: string;
|
|
237
|
+
day_index: number;
|
|
238
|
+
location?: string;
|
|
239
|
+
start_time?: string;
|
|
240
|
+
end_time?: string;
|
|
241
|
+
check_in?: string;
|
|
242
|
+
check_out?: string;
|
|
243
|
+
notes?: string;
|
|
244
|
+
price?: components['schemas']['Money'];
|
|
245
|
+
supplier_source?: string;
|
|
246
|
+
};
|
|
247
|
+
UpdateTripItemInput: {
|
|
248
|
+
type?: 'accommodation' | 'transport' | 'activity' | 'dining' | 'other';
|
|
249
|
+
title?: string;
|
|
250
|
+
day_index?: number;
|
|
251
|
+
location?: string | null;
|
|
252
|
+
start_time?: string | null;
|
|
253
|
+
end_time?: string | null;
|
|
254
|
+
check_in?: string | null;
|
|
255
|
+
check_out?: string | null;
|
|
256
|
+
notes?: string | null;
|
|
257
|
+
price?: components['schemas']['Money'] | null;
|
|
258
|
+
supplier_source?: string | null;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @ultra-network/sdk-ts — official TypeScript client for the Ultra Network Public API v1.
|
|
265
|
+
*
|
|
266
|
+
* Types are derived from the same OpenAPI document that powers the API, MCP
|
|
267
|
+
* server, and CLI (see ./generated/schema). One contract, every surface.
|
|
268
|
+
*
|
|
269
|
+
* import { UltraClient } from '@ultra-network/sdk-ts';
|
|
270
|
+
* const ultra = new UltraClient({ apiKey: process.env.ULTRA_API_KEY! });
|
|
271
|
+
* const { data } = await ultra.suppliers.list({ category: 'hotel' });
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
type Schemas = components['schemas'];
|
|
275
|
+
type Money = Schemas['Money'];
|
|
276
|
+
type PageMeta = Schemas['PageMeta'];
|
|
277
|
+
type Trip = Schemas['Trip'];
|
|
278
|
+
type CreateTripInput = Schemas['CreateTripInput'];
|
|
279
|
+
type Supplier = Schemas['Supplier'];
|
|
280
|
+
type SupplierContact = Schemas['SupplierContact'];
|
|
281
|
+
type Booking = Schemas['Booking'];
|
|
282
|
+
type CreateBookingInput = Schemas['CreateBookingInput'];
|
|
283
|
+
type UpdateBookingInput = Schemas['UpdateBookingInput'];
|
|
284
|
+
type TripItem = Schemas['TripItem'];
|
|
285
|
+
type CreateTripItemInput = Schemas['CreateTripItemInput'];
|
|
286
|
+
type UpdateTripItemInput = Schemas['UpdateTripItemInput'];
|
|
287
|
+
type ApiErrorCode = Schemas['Error']['error']['code'];
|
|
288
|
+
/** A keyset-paginated list response. Pass `page.next_cursor` back as `cursor` for the next page. */
|
|
289
|
+
interface Page<T> {
|
|
290
|
+
data: T[];
|
|
291
|
+
page: PageMeta;
|
|
292
|
+
}
|
|
293
|
+
interface UltraClientConfig {
|
|
294
|
+
/** Bearer API key (`ulk_…`), issued from the Ultra developer dashboard. */
|
|
295
|
+
apiKey: string;
|
|
296
|
+
/** API base URL. Defaults to the production API. */
|
|
297
|
+
baseUrl?: string;
|
|
298
|
+
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
299
|
+
fetch?: typeof fetch;
|
|
300
|
+
}
|
|
301
|
+
interface ListParams {
|
|
302
|
+
cursor?: string;
|
|
303
|
+
limit?: number;
|
|
304
|
+
}
|
|
305
|
+
interface ListTripsParams extends ListParams {
|
|
306
|
+
stage?: Trip['stage'];
|
|
307
|
+
organization_id?: string;
|
|
308
|
+
updated_since?: string;
|
|
309
|
+
}
|
|
310
|
+
interface ListSuppliersParams extends ListParams {
|
|
311
|
+
category?: Supplier['category'];
|
|
312
|
+
country?: string;
|
|
313
|
+
organization_id?: string;
|
|
314
|
+
active_only?: boolean;
|
|
315
|
+
updated_since?: string;
|
|
316
|
+
}
|
|
317
|
+
interface ListBookingsParams extends ListParams {
|
|
318
|
+
trip_id?: string;
|
|
319
|
+
status?: Booking['status'];
|
|
320
|
+
updated_since?: string;
|
|
321
|
+
}
|
|
322
|
+
/** Thrown for any non-2xx response. Branch on `code`, never `message`. */
|
|
323
|
+
declare class UltraApiError extends Error {
|
|
324
|
+
readonly code: ApiErrorCode | 'unknown';
|
|
325
|
+
readonly status: number;
|
|
326
|
+
readonly requestId?: string;
|
|
327
|
+
readonly details?: Record<string, unknown>;
|
|
328
|
+
constructor(message: string, info: {
|
|
329
|
+
code: ApiErrorCode | 'unknown';
|
|
330
|
+
status: number;
|
|
331
|
+
requestId?: string;
|
|
332
|
+
details?: Record<string, unknown>;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
declare class UltraClient {
|
|
336
|
+
#private;
|
|
337
|
+
constructor(config: UltraClientConfig);
|
|
338
|
+
readonly trips: {
|
|
339
|
+
list: (params?: ListTripsParams) => Promise<Page<{
|
|
340
|
+
id: string;
|
|
341
|
+
organization_id: string;
|
|
342
|
+
title: string | null;
|
|
343
|
+
stage: "enquiry_received" | "qualifying" | "draft_plan" | "proposal_sent" | "negotiating" | "booked" | "follow_up" | "in_progress" | "completed" | "lost" | "archived";
|
|
344
|
+
priority: "low" | "medium" | "high" | "urgent";
|
|
345
|
+
source: "whatsapp" | "sms" | "email" | "web_form" | "widget" | "manual" | "phone";
|
|
346
|
+
destination: string | null;
|
|
347
|
+
origin_city: string | null;
|
|
348
|
+
start_date: string | null;
|
|
349
|
+
end_date: string | null;
|
|
350
|
+
party_size: number;
|
|
351
|
+
budget: components["schemas"]["Money"] | null;
|
|
352
|
+
client: {
|
|
353
|
+
id: string;
|
|
354
|
+
name: string;
|
|
355
|
+
} | null;
|
|
356
|
+
created_at: string;
|
|
357
|
+
updated_at: string;
|
|
358
|
+
booked_at: string | null;
|
|
359
|
+
completed_at: string | null;
|
|
360
|
+
}>>;
|
|
361
|
+
create: (input: CreateTripInput) => Promise<{
|
|
362
|
+
id: string;
|
|
363
|
+
organization_id: string;
|
|
364
|
+
title: string | null;
|
|
365
|
+
stage: "enquiry_received" | "qualifying" | "draft_plan" | "proposal_sent" | "negotiating" | "booked" | "follow_up" | "in_progress" | "completed" | "lost" | "archived";
|
|
366
|
+
priority: "low" | "medium" | "high" | "urgent";
|
|
367
|
+
source: "whatsapp" | "sms" | "email" | "web_form" | "widget" | "manual" | "phone";
|
|
368
|
+
destination: string | null;
|
|
369
|
+
origin_city: string | null;
|
|
370
|
+
start_date: string | null;
|
|
371
|
+
end_date: string | null;
|
|
372
|
+
party_size: number;
|
|
373
|
+
budget: components["schemas"]["Money"] | null;
|
|
374
|
+
client: {
|
|
375
|
+
id: string;
|
|
376
|
+
name: string;
|
|
377
|
+
} | null;
|
|
378
|
+
created_at: string;
|
|
379
|
+
updated_at: string;
|
|
380
|
+
booked_at: string | null;
|
|
381
|
+
completed_at: string | null;
|
|
382
|
+
}>;
|
|
383
|
+
get: (id: string) => Promise<{
|
|
384
|
+
id: string;
|
|
385
|
+
organization_id: string;
|
|
386
|
+
title: string | null;
|
|
387
|
+
stage: "enquiry_received" | "qualifying" | "draft_plan" | "proposal_sent" | "negotiating" | "booked" | "follow_up" | "in_progress" | "completed" | "lost" | "archived";
|
|
388
|
+
priority: "low" | "medium" | "high" | "urgent";
|
|
389
|
+
source: "whatsapp" | "sms" | "email" | "web_form" | "widget" | "manual" | "phone";
|
|
390
|
+
destination: string | null;
|
|
391
|
+
origin_city: string | null;
|
|
392
|
+
start_date: string | null;
|
|
393
|
+
end_date: string | null;
|
|
394
|
+
party_size: number;
|
|
395
|
+
budget: components["schemas"]["Money"] | null;
|
|
396
|
+
client: {
|
|
397
|
+
id: string;
|
|
398
|
+
name: string;
|
|
399
|
+
} | null;
|
|
400
|
+
created_at: string;
|
|
401
|
+
updated_at: string;
|
|
402
|
+
booked_at: string | null;
|
|
403
|
+
completed_at: string | null;
|
|
404
|
+
}>;
|
|
405
|
+
items: {
|
|
406
|
+
list: (tripId: string, params?: ListParams) => Promise<Page<{
|
|
407
|
+
id: string;
|
|
408
|
+
type: "accommodation" | "transport" | "activity" | "dining" | "other";
|
|
409
|
+
title: string;
|
|
410
|
+
day_index: number;
|
|
411
|
+
location: string | null;
|
|
412
|
+
start_time: string | null;
|
|
413
|
+
end_time: string | null;
|
|
414
|
+
check_in: string | null;
|
|
415
|
+
check_out: string | null;
|
|
416
|
+
notes: string | null;
|
|
417
|
+
price: components["schemas"]["Money"] | null;
|
|
418
|
+
supplier_source: string | null;
|
|
419
|
+
}>>;
|
|
420
|
+
create: (tripId: string, input: CreateTripItemInput) => Promise<{
|
|
421
|
+
id: string;
|
|
422
|
+
type: "accommodation" | "transport" | "activity" | "dining" | "other";
|
|
423
|
+
title: string;
|
|
424
|
+
day_index: number;
|
|
425
|
+
location: string | null;
|
|
426
|
+
start_time: string | null;
|
|
427
|
+
end_time: string | null;
|
|
428
|
+
check_in: string | null;
|
|
429
|
+
check_out: string | null;
|
|
430
|
+
notes: string | null;
|
|
431
|
+
price: components["schemas"]["Money"] | null;
|
|
432
|
+
supplier_source: string | null;
|
|
433
|
+
}>;
|
|
434
|
+
update: (tripId: string, itemId: string, input: UpdateTripItemInput) => Promise<{
|
|
435
|
+
id: string;
|
|
436
|
+
type: "accommodation" | "transport" | "activity" | "dining" | "other";
|
|
437
|
+
title: string;
|
|
438
|
+
day_index: number;
|
|
439
|
+
location: string | null;
|
|
440
|
+
start_time: string | null;
|
|
441
|
+
end_time: string | null;
|
|
442
|
+
check_in: string | null;
|
|
443
|
+
check_out: string | null;
|
|
444
|
+
notes: string | null;
|
|
445
|
+
price: components["schemas"]["Money"] | null;
|
|
446
|
+
supplier_source: string | null;
|
|
447
|
+
}>;
|
|
448
|
+
remove: (tripId: string, itemId: string) => Promise<void>;
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
readonly suppliers: {
|
|
452
|
+
list: (params?: ListSuppliersParams) => Promise<Page<{
|
|
453
|
+
id: string;
|
|
454
|
+
organization_id: string;
|
|
455
|
+
name: string;
|
|
456
|
+
category: "hotel" | "restaurant" | "transport_car" | "transport_jet" | "transport_helicopter" | "flight" | "activity" | "cruise" | "tour" | "dmc" | "wholesale" | "platform" | "channel_manager" | "hub_marketplace" | "insurance" | "visa" | "other";
|
|
457
|
+
onboarding_status: "pending_application" | "application_approved" | "profile_setup" | "documents_uploaded" | "agreement_pending" | "agreement_signed" | "active" | "suspended";
|
|
458
|
+
country: string | null;
|
|
459
|
+
address: string | null;
|
|
460
|
+
logo_url: string | null;
|
|
461
|
+
cover_image_url: string | null;
|
|
462
|
+
is_active: boolean;
|
|
463
|
+
is_preferred: boolean;
|
|
464
|
+
contact: components["schemas"]["SupplierContact"] | null;
|
|
465
|
+
created_at: string;
|
|
466
|
+
updated_at: string;
|
|
467
|
+
}>>;
|
|
468
|
+
get: (id: string) => Promise<{
|
|
469
|
+
id: string;
|
|
470
|
+
organization_id: string;
|
|
471
|
+
name: string;
|
|
472
|
+
category: "hotel" | "restaurant" | "transport_car" | "transport_jet" | "transport_helicopter" | "flight" | "activity" | "cruise" | "tour" | "dmc" | "wholesale" | "platform" | "channel_manager" | "hub_marketplace" | "insurance" | "visa" | "other";
|
|
473
|
+
onboarding_status: "pending_application" | "application_approved" | "profile_setup" | "documents_uploaded" | "agreement_pending" | "agreement_signed" | "active" | "suspended";
|
|
474
|
+
country: string | null;
|
|
475
|
+
address: string | null;
|
|
476
|
+
logo_url: string | null;
|
|
477
|
+
cover_image_url: string | null;
|
|
478
|
+
is_active: boolean;
|
|
479
|
+
is_preferred: boolean;
|
|
480
|
+
contact: components["schemas"]["SupplierContact"] | null;
|
|
481
|
+
created_at: string;
|
|
482
|
+
updated_at: string;
|
|
483
|
+
}>;
|
|
484
|
+
};
|
|
485
|
+
readonly bookings: {
|
|
486
|
+
list: (params?: ListBookingsParams) => Promise<Page<{
|
|
487
|
+
id: string;
|
|
488
|
+
trip_id: string;
|
|
489
|
+
supplier_source: string;
|
|
490
|
+
supplier_booking_id: string | null;
|
|
491
|
+
venue_name: string;
|
|
492
|
+
venue_type: string | null;
|
|
493
|
+
destination: string | null;
|
|
494
|
+
check_in: string | null;
|
|
495
|
+
check_out: string | null;
|
|
496
|
+
guest_count: number | null;
|
|
497
|
+
total: components["schemas"]["Money"];
|
|
498
|
+
status: "provisional" | "confirmed" | "active" | "completed" | "expired" | "failed" | "cancelled" | "pending_supplier_confirmation" | "rejected" | "modified";
|
|
499
|
+
payment_status: "pending" | "pending_confirmation" | "authorized" | "captured" | "partially_refunded" | "refunded" | "failed" | "cancelled" | "disputed";
|
|
500
|
+
voucher_url: string | null;
|
|
501
|
+
created_at: string;
|
|
502
|
+
confirmed_at: string | null;
|
|
503
|
+
cancelled_at: string | null;
|
|
504
|
+
completed_at: string | null;
|
|
505
|
+
updated_at: string;
|
|
506
|
+
}>>;
|
|
507
|
+
create: (input: CreateBookingInput) => Promise<{
|
|
508
|
+
id: string;
|
|
509
|
+
trip_id: string;
|
|
510
|
+
supplier_source: string;
|
|
511
|
+
supplier_booking_id: string | null;
|
|
512
|
+
venue_name: string;
|
|
513
|
+
venue_type: string | null;
|
|
514
|
+
destination: string | null;
|
|
515
|
+
check_in: string | null;
|
|
516
|
+
check_out: string | null;
|
|
517
|
+
guest_count: number | null;
|
|
518
|
+
total: components["schemas"]["Money"];
|
|
519
|
+
status: "provisional" | "confirmed" | "active" | "completed" | "expired" | "failed" | "cancelled" | "pending_supplier_confirmation" | "rejected" | "modified";
|
|
520
|
+
payment_status: "pending" | "pending_confirmation" | "authorized" | "captured" | "partially_refunded" | "refunded" | "failed" | "cancelled" | "disputed";
|
|
521
|
+
voucher_url: string | null;
|
|
522
|
+
created_at: string;
|
|
523
|
+
confirmed_at: string | null;
|
|
524
|
+
cancelled_at: string | null;
|
|
525
|
+
completed_at: string | null;
|
|
526
|
+
updated_at: string;
|
|
527
|
+
}>;
|
|
528
|
+
get: (id: string) => Promise<{
|
|
529
|
+
id: string;
|
|
530
|
+
trip_id: string;
|
|
531
|
+
supplier_source: string;
|
|
532
|
+
supplier_booking_id: string | null;
|
|
533
|
+
venue_name: string;
|
|
534
|
+
venue_type: string | null;
|
|
535
|
+
destination: string | null;
|
|
536
|
+
check_in: string | null;
|
|
537
|
+
check_out: string | null;
|
|
538
|
+
guest_count: number | null;
|
|
539
|
+
total: components["schemas"]["Money"];
|
|
540
|
+
status: "provisional" | "confirmed" | "active" | "completed" | "expired" | "failed" | "cancelled" | "pending_supplier_confirmation" | "rejected" | "modified";
|
|
541
|
+
payment_status: "pending" | "pending_confirmation" | "authorized" | "captured" | "partially_refunded" | "refunded" | "failed" | "cancelled" | "disputed";
|
|
542
|
+
voucher_url: string | null;
|
|
543
|
+
created_at: string;
|
|
544
|
+
confirmed_at: string | null;
|
|
545
|
+
cancelled_at: string | null;
|
|
546
|
+
completed_at: string | null;
|
|
547
|
+
updated_at: string;
|
|
548
|
+
}>;
|
|
549
|
+
update: (id: string, input: UpdateBookingInput) => Promise<{
|
|
550
|
+
id: string;
|
|
551
|
+
trip_id: string;
|
|
552
|
+
supplier_source: string;
|
|
553
|
+
supplier_booking_id: string | null;
|
|
554
|
+
venue_name: string;
|
|
555
|
+
venue_type: string | null;
|
|
556
|
+
destination: string | null;
|
|
557
|
+
check_in: string | null;
|
|
558
|
+
check_out: string | null;
|
|
559
|
+
guest_count: number | null;
|
|
560
|
+
total: components["schemas"]["Money"];
|
|
561
|
+
status: "provisional" | "confirmed" | "active" | "completed" | "expired" | "failed" | "cancelled" | "pending_supplier_confirmation" | "rejected" | "modified";
|
|
562
|
+
payment_status: "pending" | "pending_confirmation" | "authorized" | "captured" | "partially_refunded" | "refunded" | "failed" | "cancelled" | "disputed";
|
|
563
|
+
voucher_url: string | null;
|
|
564
|
+
created_at: string;
|
|
565
|
+
confirmed_at: string | null;
|
|
566
|
+
cancelled_at: string | null;
|
|
567
|
+
completed_at: string | null;
|
|
568
|
+
updated_at: string;
|
|
569
|
+
}>;
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
/** Convenience factory — equivalent to `new UltraClient(config)`. */
|
|
573
|
+
declare function createUltraClient(config: UltraClientConfig): UltraClient;
|
|
574
|
+
|
|
575
|
+
export { type ApiErrorCode, type Booking, type CreateBookingInput, type CreateTripInput, type CreateTripItemInput, type ListBookingsParams, type ListParams, type ListSuppliersParams, type ListTripsParams, type Money, type Page, type PageMeta, type Supplier, type SupplierContact, type Trip, type TripItem, UltraApiError, UltraClient, type UltraClientConfig, type UpdateBookingInput, type UpdateTripItemInput, createUltraClient };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var UltraApiError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
status;
|
|
5
|
+
requestId;
|
|
6
|
+
details;
|
|
7
|
+
constructor(message, info) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "UltraApiError";
|
|
10
|
+
this.code = info.code;
|
|
11
|
+
this.status = info.status;
|
|
12
|
+
this.requestId = info.requestId;
|
|
13
|
+
this.details = info.details;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var DEFAULT_BASE_URL = "https://ultranetwork.co/api/v1";
|
|
17
|
+
var UltraClient = class {
|
|
18
|
+
#apiKey;
|
|
19
|
+
#baseUrl;
|
|
20
|
+
#fetch;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
if (!config?.apiKey) throw new Error("UltraClient: `apiKey` is required.");
|
|
23
|
+
this.#apiKey = config.apiKey;
|
|
24
|
+
this.#baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
25
|
+
this.#fetch = config.fetch ?? globalThis.fetch;
|
|
26
|
+
if (typeof this.#fetch !== "function") {
|
|
27
|
+
throw new Error("UltraClient: no `fetch` available \u2014 pass `config.fetch` on runtimes without a global fetch.");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async #request(method, path, opts) {
|
|
31
|
+
const url = new URL(this.#baseUrl + path);
|
|
32
|
+
if (opts?.query) {
|
|
33
|
+
for (const [key, value] of Object.entries(opts.query)) {
|
|
34
|
+
if (value !== void 0 && value !== null) url.searchParams.set(key, String(value));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const headers = {
|
|
38
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
39
|
+
Accept: "application/json"
|
|
40
|
+
};
|
|
41
|
+
if (opts?.body !== void 0) headers["Content-Type"] = "application/json";
|
|
42
|
+
const res = await this.#fetch(url.toString(), {
|
|
43
|
+
method,
|
|
44
|
+
headers,
|
|
45
|
+
body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
46
|
+
});
|
|
47
|
+
if (res.status === 204) return void 0;
|
|
48
|
+
const text = await res.text();
|
|
49
|
+
const json = text ? JSON.parse(text) : void 0;
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
const envelope = json?.error;
|
|
52
|
+
throw new UltraApiError(envelope?.message ?? `Ultra API request failed with status ${res.status}`, {
|
|
53
|
+
code: envelope?.code ?? "unknown",
|
|
54
|
+
status: res.status,
|
|
55
|
+
requestId: envelope?.request_id ?? res.headers.get("x-request-id") ?? void 0,
|
|
56
|
+
details: envelope?.details
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return json;
|
|
60
|
+
}
|
|
61
|
+
trips = {
|
|
62
|
+
list: (params) => this.#request("GET", "/trips", { query: params }),
|
|
63
|
+
create: (input) => this.#request("POST", "/trips", { body: input }),
|
|
64
|
+
get: (id) => this.#request("GET", `/trips/${encodeURIComponent(id)}`),
|
|
65
|
+
items: {
|
|
66
|
+
list: (tripId, params) => this.#request("GET", `/trips/${encodeURIComponent(tripId)}/items`, { query: params }),
|
|
67
|
+
create: (tripId, input) => this.#request("POST", `/trips/${encodeURIComponent(tripId)}/items`, { body: input }),
|
|
68
|
+
update: (tripId, itemId, input) => this.#request("PATCH", `/trips/${encodeURIComponent(tripId)}/items/${encodeURIComponent(itemId)}`, {
|
|
69
|
+
body: input
|
|
70
|
+
}),
|
|
71
|
+
remove: (tripId, itemId) => this.#request("DELETE", `/trips/${encodeURIComponent(tripId)}/items/${encodeURIComponent(itemId)}`)
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
suppliers = {
|
|
75
|
+
list: (params) => this.#request("GET", "/suppliers", { query: params }),
|
|
76
|
+
get: (id) => this.#request("GET", `/suppliers/${encodeURIComponent(id)}`)
|
|
77
|
+
};
|
|
78
|
+
bookings = {
|
|
79
|
+
list: (params) => this.#request("GET", "/bookings", { query: params }),
|
|
80
|
+
create: (input) => this.#request("POST", "/bookings", { body: input }),
|
|
81
|
+
get: (id) => this.#request("GET", `/bookings/${encodeURIComponent(id)}`),
|
|
82
|
+
update: (id, input) => this.#request("PATCH", `/bookings/${encodeURIComponent(id)}`, { body: input })
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
function createUltraClient(config) {
|
|
86
|
+
return new UltraClient(config);
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
UltraApiError,
|
|
90
|
+
UltraClient,
|
|
91
|
+
createUltraClient
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=index.js.map
|