@flexops/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +449 -0
- package/dist/index.d.mts +1220 -0
- package/dist/index.d.ts +1220 -0
- package/dist/index.js +1317 -0
- package/dist/index.mjs +1274 -0
- package/package.json +63 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
interface FlexOpsConfig {
|
|
2
|
+
/** Base URL of the FlexOps Gateway API. Default: https://gateway.flexops.io */
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
/** JWT access token (from login or API key auth) */
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
/** Workspace API key for server-to-server authentication */
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
/** Workspace ID to scope requests to */
|
|
9
|
+
workspaceId?: string;
|
|
10
|
+
/** Request timeout in milliseconds. Default: 30000 */
|
|
11
|
+
timeout?: number;
|
|
12
|
+
/** Custom fetch implementation (for Node 18+ or polyfills) */
|
|
13
|
+
fetch?: typeof globalThis.fetch;
|
|
14
|
+
/** Custom headers added to every request */
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/** Retry configuration */
|
|
17
|
+
retry?: RetryConfig;
|
|
18
|
+
}
|
|
19
|
+
interface RetryConfig {
|
|
20
|
+
/** Maximum number of retries. Default: 3 */
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
/** Base delay in ms for exponential backoff. Default: 1000 */
|
|
23
|
+
baseDelay?: number;
|
|
24
|
+
/** HTTP status codes to retry on. Default: [429, 500, 502, 503, 504] */
|
|
25
|
+
retryableStatusCodes?: number[];
|
|
26
|
+
}
|
|
27
|
+
interface ApiResponse<T> {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: T;
|
|
30
|
+
message?: string;
|
|
31
|
+
errors?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface PaginatedResponse<T> {
|
|
34
|
+
items: T[];
|
|
35
|
+
totalCount: number;
|
|
36
|
+
page: number;
|
|
37
|
+
pageSize: number;
|
|
38
|
+
totalPages: number;
|
|
39
|
+
}
|
|
40
|
+
interface LoginRequest {
|
|
41
|
+
email: string;
|
|
42
|
+
password: string;
|
|
43
|
+
}
|
|
44
|
+
interface LoginResponse {
|
|
45
|
+
accessToken: string;
|
|
46
|
+
refreshToken: string;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
}
|
|
50
|
+
interface RegisterRequest {
|
|
51
|
+
email: string;
|
|
52
|
+
password: string;
|
|
53
|
+
firstName: string;
|
|
54
|
+
lastName: string;
|
|
55
|
+
companyName?: string;
|
|
56
|
+
}
|
|
57
|
+
interface Workspace {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
slug: string;
|
|
61
|
+
planId: string;
|
|
62
|
+
ownerId: string;
|
|
63
|
+
isActive: boolean;
|
|
64
|
+
monthlyLabelLimit: number;
|
|
65
|
+
labelsUsedThisMonth: number;
|
|
66
|
+
userLimit: number;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
}
|
|
69
|
+
interface CreateWorkspaceRequest {
|
|
70
|
+
name: string;
|
|
71
|
+
planId?: string;
|
|
72
|
+
}
|
|
73
|
+
interface WorkspaceMember {
|
|
74
|
+
userId: string;
|
|
75
|
+
email: string;
|
|
76
|
+
role: 'Owner' | 'Admin' | 'Member' | 'Guest';
|
|
77
|
+
joinedAt: string;
|
|
78
|
+
}
|
|
79
|
+
interface RateRequest {
|
|
80
|
+
fromZip: string;
|
|
81
|
+
toZip: string;
|
|
82
|
+
weight: number;
|
|
83
|
+
weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
84
|
+
length?: number;
|
|
85
|
+
width?: number;
|
|
86
|
+
height?: number;
|
|
87
|
+
dimensionUnit?: 'in' | 'cm';
|
|
88
|
+
packageType?: string;
|
|
89
|
+
carriers?: string[];
|
|
90
|
+
}
|
|
91
|
+
interface ShippingRate {
|
|
92
|
+
carrier: string;
|
|
93
|
+
service: string;
|
|
94
|
+
rate: number;
|
|
95
|
+
currency: string;
|
|
96
|
+
estimatedDays: number;
|
|
97
|
+
deliveryDate?: string;
|
|
98
|
+
}
|
|
99
|
+
interface CreateLabelRequest {
|
|
100
|
+
carrier: string;
|
|
101
|
+
service: string;
|
|
102
|
+
fromAddress: Address;
|
|
103
|
+
toAddress: Address;
|
|
104
|
+
parcel: Parcel;
|
|
105
|
+
returnLabel?: boolean;
|
|
106
|
+
labelFormat?: 'PDF' | 'PNG' | 'ZPL';
|
|
107
|
+
idempotencyKey?: string;
|
|
108
|
+
}
|
|
109
|
+
interface Label {
|
|
110
|
+
labelId: string;
|
|
111
|
+
trackingNumber: string;
|
|
112
|
+
carrier: string;
|
|
113
|
+
service: string;
|
|
114
|
+
labelData: string;
|
|
115
|
+
labelFormat: string;
|
|
116
|
+
rate: number;
|
|
117
|
+
createdAt: string;
|
|
118
|
+
}
|
|
119
|
+
interface Address {
|
|
120
|
+
name: string;
|
|
121
|
+
company?: string;
|
|
122
|
+
street1: string;
|
|
123
|
+
street2?: string;
|
|
124
|
+
city: string;
|
|
125
|
+
state: string;
|
|
126
|
+
zip: string;
|
|
127
|
+
country: string;
|
|
128
|
+
phone?: string;
|
|
129
|
+
email?: string;
|
|
130
|
+
}
|
|
131
|
+
interface Parcel {
|
|
132
|
+
weight: number;
|
|
133
|
+
weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
134
|
+
length?: number;
|
|
135
|
+
width?: number;
|
|
136
|
+
height?: number;
|
|
137
|
+
dimensionUnit?: 'in' | 'cm';
|
|
138
|
+
}
|
|
139
|
+
interface TrackingInfo {
|
|
140
|
+
trackingNumber: string;
|
|
141
|
+
carrier: string;
|
|
142
|
+
status: string;
|
|
143
|
+
statusDetail: string;
|
|
144
|
+
estimatedDelivery?: string;
|
|
145
|
+
events: TrackingEvent[];
|
|
146
|
+
}
|
|
147
|
+
interface TrackingEvent {
|
|
148
|
+
timestamp: string;
|
|
149
|
+
status: string;
|
|
150
|
+
description: string;
|
|
151
|
+
location?: string;
|
|
152
|
+
}
|
|
153
|
+
interface AddressValidationResult {
|
|
154
|
+
isValid: boolean;
|
|
155
|
+
correctedAddress?: Address;
|
|
156
|
+
messages?: string[];
|
|
157
|
+
}
|
|
158
|
+
interface BatchLabelRequest {
|
|
159
|
+
items: CreateLabelRequest[];
|
|
160
|
+
idempotencyKey?: string;
|
|
161
|
+
}
|
|
162
|
+
interface BatchLabelJob {
|
|
163
|
+
jobId: string;
|
|
164
|
+
status: 'Queued' | 'Processing' | 'Completed' | 'Failed';
|
|
165
|
+
totalItems: number;
|
|
166
|
+
completedItems: number;
|
|
167
|
+
failedItems: number;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
}
|
|
170
|
+
interface Order {
|
|
171
|
+
orderNumber: string;
|
|
172
|
+
status: string;
|
|
173
|
+
customerName?: string;
|
|
174
|
+
items: OrderItem[];
|
|
175
|
+
shippingAddress: Address;
|
|
176
|
+
createdAt: string;
|
|
177
|
+
}
|
|
178
|
+
interface OrderItem {
|
|
179
|
+
sku: string;
|
|
180
|
+
name: string;
|
|
181
|
+
quantity: number;
|
|
182
|
+
unitPrice: number;
|
|
183
|
+
}
|
|
184
|
+
interface WebhookSubscription {
|
|
185
|
+
id: string;
|
|
186
|
+
url: string;
|
|
187
|
+
events: string[];
|
|
188
|
+
isActive: boolean;
|
|
189
|
+
secret: string;
|
|
190
|
+
createdAt: string;
|
|
191
|
+
}
|
|
192
|
+
interface CreateWebhookRequest {
|
|
193
|
+
url: string;
|
|
194
|
+
events: string[];
|
|
195
|
+
}
|
|
196
|
+
interface WalletBalance {
|
|
197
|
+
balance: number;
|
|
198
|
+
currency: string;
|
|
199
|
+
autoReloadEnabled: boolean;
|
|
200
|
+
autoReloadThreshold?: number;
|
|
201
|
+
autoReloadAmount?: number;
|
|
202
|
+
}
|
|
203
|
+
interface InsuranceQuote {
|
|
204
|
+
provider: string;
|
|
205
|
+
premium: number;
|
|
206
|
+
coverage: number;
|
|
207
|
+
currency: string;
|
|
208
|
+
}
|
|
209
|
+
interface InsurancePolicy {
|
|
210
|
+
policyId: string;
|
|
211
|
+
provider: string;
|
|
212
|
+
trackingNumber: string;
|
|
213
|
+
coverage: number;
|
|
214
|
+
premium: number;
|
|
215
|
+
status: string;
|
|
216
|
+
}
|
|
217
|
+
interface ReturnRequest {
|
|
218
|
+
orderId: string;
|
|
219
|
+
reason: string;
|
|
220
|
+
items: ReturnItem[];
|
|
221
|
+
}
|
|
222
|
+
interface ReturnItem {
|
|
223
|
+
sku: string;
|
|
224
|
+
quantity: number;
|
|
225
|
+
reason?: string;
|
|
226
|
+
}
|
|
227
|
+
interface ReturnAuthorization {
|
|
228
|
+
rmaId: string;
|
|
229
|
+
status: string;
|
|
230
|
+
returnLabel?: Label;
|
|
231
|
+
createdAt: string;
|
|
232
|
+
}
|
|
233
|
+
interface ApiKeyInfo {
|
|
234
|
+
id: string;
|
|
235
|
+
name: string;
|
|
236
|
+
prefix: string;
|
|
237
|
+
scopes: string[];
|
|
238
|
+
lastUsedAt?: string;
|
|
239
|
+
expiresAt?: string;
|
|
240
|
+
createdAt: string;
|
|
241
|
+
}
|
|
242
|
+
interface CreateApiKeyRequest {
|
|
243
|
+
name: string;
|
|
244
|
+
scopes?: string[];
|
|
245
|
+
expiresInDays?: number;
|
|
246
|
+
}
|
|
247
|
+
interface CreateApiKeyResponse {
|
|
248
|
+
id: string;
|
|
249
|
+
key: string;
|
|
250
|
+
name: string;
|
|
251
|
+
prefix: string;
|
|
252
|
+
}
|
|
253
|
+
interface ShipmentsTrend {
|
|
254
|
+
date: string;
|
|
255
|
+
count: number;
|
|
256
|
+
totalCost: number;
|
|
257
|
+
}
|
|
258
|
+
interface CarrierSummary {
|
|
259
|
+
carrier: string;
|
|
260
|
+
labelCount: number;
|
|
261
|
+
totalCost: number;
|
|
262
|
+
averageCost: number;
|
|
263
|
+
}
|
|
264
|
+
interface ShippingRule {
|
|
265
|
+
id: string;
|
|
266
|
+
name: string;
|
|
267
|
+
isActive: boolean;
|
|
268
|
+
priority: number;
|
|
269
|
+
conditions: RuleCondition[];
|
|
270
|
+
actions: RuleAction[];
|
|
271
|
+
}
|
|
272
|
+
interface RuleCondition {
|
|
273
|
+
field: string;
|
|
274
|
+
operator: string;
|
|
275
|
+
value: string;
|
|
276
|
+
group?: number;
|
|
277
|
+
}
|
|
278
|
+
interface RuleAction {
|
|
279
|
+
type: string;
|
|
280
|
+
value: string;
|
|
281
|
+
}
|
|
282
|
+
interface PickupRequest {
|
|
283
|
+
carrier: string;
|
|
284
|
+
pickupDate: string;
|
|
285
|
+
readyTime: string;
|
|
286
|
+
closeTime: string;
|
|
287
|
+
address: Address;
|
|
288
|
+
packageCount: number;
|
|
289
|
+
totalWeight: number;
|
|
290
|
+
}
|
|
291
|
+
interface PickupConfirmation {
|
|
292
|
+
confirmationNumber: string;
|
|
293
|
+
carrier: string;
|
|
294
|
+
pickupDate: string;
|
|
295
|
+
status: string;
|
|
296
|
+
}
|
|
297
|
+
interface ScanFormRequest {
|
|
298
|
+
trackingNumbers: string[];
|
|
299
|
+
}
|
|
300
|
+
interface ScanForm {
|
|
301
|
+
scanFormId: string;
|
|
302
|
+
formData: string;
|
|
303
|
+
trackingNumbers: string[];
|
|
304
|
+
createdAt: string;
|
|
305
|
+
}
|
|
306
|
+
interface CarrierRecommendationRequest {
|
|
307
|
+
originPostalCode: string;
|
|
308
|
+
destinationPostalCode: string;
|
|
309
|
+
weightOz?: number;
|
|
310
|
+
/** Scoring bias: 'balanced' | 'cost' | 'speed' | 'reliability'. Default: 'balanced' */
|
|
311
|
+
priority?: string;
|
|
312
|
+
}
|
|
313
|
+
interface CarrierRecommendationResponse {
|
|
314
|
+
lane: string;
|
|
315
|
+
sampleSize: number;
|
|
316
|
+
recommendations: CarrierRecommendation[];
|
|
317
|
+
}
|
|
318
|
+
interface CarrierRecommendation {
|
|
319
|
+
carrierCode: string;
|
|
320
|
+
score: number;
|
|
321
|
+
onTimePercent: number;
|
|
322
|
+
avgTransitDays: number;
|
|
323
|
+
avgCost: number;
|
|
324
|
+
shipmentCount: number;
|
|
325
|
+
exceptionRate: number;
|
|
326
|
+
reason: string;
|
|
327
|
+
seasonalAdjustment: string | null;
|
|
328
|
+
seasonalScoreMultiplier: number;
|
|
329
|
+
}
|
|
330
|
+
interface DeliveryPredictionRequest {
|
|
331
|
+
carrierCode: string;
|
|
332
|
+
serviceCode?: string;
|
|
333
|
+
originPostalCode: string;
|
|
334
|
+
destinationPostalCode: string;
|
|
335
|
+
shipDate?: string;
|
|
336
|
+
}
|
|
337
|
+
interface DeliveryPredictionResponse {
|
|
338
|
+
carrierCode: string;
|
|
339
|
+
predictedDeliveryDate: string;
|
|
340
|
+
earliestDelivery: string;
|
|
341
|
+
latestDelivery: string;
|
|
342
|
+
worstCaseDelivery: string;
|
|
343
|
+
predictedTransitDays: number;
|
|
344
|
+
confidence: number;
|
|
345
|
+
sampleSize: number;
|
|
346
|
+
onTimeRate: number;
|
|
347
|
+
}
|
|
348
|
+
interface CostSavingsSummary {
|
|
349
|
+
totalPotentialSavings: number;
|
|
350
|
+
lanesAnalyzed: number;
|
|
351
|
+
lanesWithSavings: number;
|
|
352
|
+
topLanes: LaneSavingsOpportunity[];
|
|
353
|
+
}
|
|
354
|
+
interface LaneSavingsOpportunity {
|
|
355
|
+
lane: string;
|
|
356
|
+
currentCarrier: string;
|
|
357
|
+
recommendedCarrier: string;
|
|
358
|
+
currentAvgCost: number;
|
|
359
|
+
recommendedAvgCost: number;
|
|
360
|
+
estimatedSavings: number;
|
|
361
|
+
shipmentCount: number;
|
|
362
|
+
currentOnTimeRate: number;
|
|
363
|
+
recommendedOnTimeRate: number;
|
|
364
|
+
}
|
|
365
|
+
interface OffsetResult {
|
|
366
|
+
labelId: string;
|
|
367
|
+
offsetId: string;
|
|
368
|
+
kgCo2e: number;
|
|
369
|
+
cost: {
|
|
370
|
+
amount: number;
|
|
371
|
+
currency: string;
|
|
372
|
+
};
|
|
373
|
+
provider: string;
|
|
374
|
+
certificateUrl: string;
|
|
375
|
+
}
|
|
376
|
+
interface EmissionsEstimate {
|
|
377
|
+
labelId: string;
|
|
378
|
+
kgCo2e: number;
|
|
379
|
+
carrier: string;
|
|
380
|
+
service: string;
|
|
381
|
+
distanceMiles: number;
|
|
382
|
+
model: string;
|
|
383
|
+
}
|
|
384
|
+
interface HsCodeResult {
|
|
385
|
+
hsCode: string;
|
|
386
|
+
description: string;
|
|
387
|
+
chapter: string;
|
|
388
|
+
chapterDescription: string;
|
|
389
|
+
dutyRatePercent: number | null;
|
|
390
|
+
notes: string | null;
|
|
391
|
+
}
|
|
392
|
+
interface LandedCostRequest {
|
|
393
|
+
destinationCountry: string;
|
|
394
|
+
shippingCost?: number;
|
|
395
|
+
items: CustomsItem[];
|
|
396
|
+
}
|
|
397
|
+
interface CustomsItem {
|
|
398
|
+
description: string;
|
|
399
|
+
quantity: number;
|
|
400
|
+
value: number;
|
|
401
|
+
weightOz?: number;
|
|
402
|
+
hsCode?: string;
|
|
403
|
+
originCountry?: string;
|
|
404
|
+
skuOrProductId?: string;
|
|
405
|
+
}
|
|
406
|
+
interface LandedCostEstimate {
|
|
407
|
+
shippingCost: number;
|
|
408
|
+
estimatedDuty: number;
|
|
409
|
+
estimatedTax: number;
|
|
410
|
+
totalLandedCost: number;
|
|
411
|
+
currency: string;
|
|
412
|
+
dutyRateApplied: string | null;
|
|
413
|
+
isEstimate: boolean;
|
|
414
|
+
disclaimer: string | null;
|
|
415
|
+
}
|
|
416
|
+
interface RecurringShipment {
|
|
417
|
+
id: string;
|
|
418
|
+
name: string;
|
|
419
|
+
isActive: boolean;
|
|
420
|
+
scheduleExpression: string;
|
|
421
|
+
nextRunAt: string | null;
|
|
422
|
+
lastRunAt: string | null;
|
|
423
|
+
createdAt: string;
|
|
424
|
+
}
|
|
425
|
+
interface CreateRecurringShipmentRequest {
|
|
426
|
+
name: string;
|
|
427
|
+
scheduleExpression: string;
|
|
428
|
+
labelRequest: CreateLabelRequest;
|
|
429
|
+
}
|
|
430
|
+
interface UpdateRecurringShipmentRequest {
|
|
431
|
+
name?: string;
|
|
432
|
+
scheduleExpression?: string;
|
|
433
|
+
labelRequest?: Partial<CreateLabelRequest>;
|
|
434
|
+
}
|
|
435
|
+
interface EmailTemplate {
|
|
436
|
+
id: string;
|
|
437
|
+
name: string;
|
|
438
|
+
subject: string;
|
|
439
|
+
triggerEvent: string;
|
|
440
|
+
isActive: boolean;
|
|
441
|
+
createdAt: string;
|
|
442
|
+
updatedAt: string;
|
|
443
|
+
}
|
|
444
|
+
interface CreateEmailTemplateRequest {
|
|
445
|
+
name: string;
|
|
446
|
+
subject: string;
|
|
447
|
+
bodyHtml: string;
|
|
448
|
+
triggerEvent: string;
|
|
449
|
+
isActive?: boolean;
|
|
450
|
+
}
|
|
451
|
+
interface UpdateEmailTemplateRequest {
|
|
452
|
+
name?: string;
|
|
453
|
+
subject?: string;
|
|
454
|
+
bodyHtml?: string;
|
|
455
|
+
triggerEvent?: string;
|
|
456
|
+
isActive?: boolean;
|
|
457
|
+
}
|
|
458
|
+
interface ReportSchedule {
|
|
459
|
+
id: string;
|
|
460
|
+
name: string;
|
|
461
|
+
reportType: string;
|
|
462
|
+
recipientEmail: string;
|
|
463
|
+
scheduleExpression: string;
|
|
464
|
+
isActive: boolean;
|
|
465
|
+
lastSentAt: string | null;
|
|
466
|
+
createdAt: string;
|
|
467
|
+
}
|
|
468
|
+
interface CreateReportScheduleRequest {
|
|
469
|
+
name: string;
|
|
470
|
+
reportType: string;
|
|
471
|
+
recipientEmail: string;
|
|
472
|
+
scheduleExpression: string;
|
|
473
|
+
isActive?: boolean;
|
|
474
|
+
}
|
|
475
|
+
interface UpdateReportScheduleRequest {
|
|
476
|
+
name?: string;
|
|
477
|
+
reportType?: string;
|
|
478
|
+
recipientEmail?: string;
|
|
479
|
+
scheduleExpression?: string;
|
|
480
|
+
isActive?: boolean;
|
|
481
|
+
}
|
|
482
|
+
declare class FlexOpsError extends Error {
|
|
483
|
+
readonly status: number;
|
|
484
|
+
readonly code?: string | undefined;
|
|
485
|
+
readonly errors?: string[] | undefined;
|
|
486
|
+
constructor(message: string, status: number, code?: string | undefined, errors?: string[] | undefined);
|
|
487
|
+
}
|
|
488
|
+
declare class FlexOpsRateLimitError extends FlexOpsError {
|
|
489
|
+
readonly retryAfter?: number | undefined;
|
|
490
|
+
constructor(message: string, retryAfter?: number | undefined);
|
|
491
|
+
}
|
|
492
|
+
declare class FlexOpsAuthError extends FlexOpsError {
|
|
493
|
+
constructor(message: string);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
declare class HttpClient {
|
|
497
|
+
private readonly baseUrl;
|
|
498
|
+
private readonly timeout;
|
|
499
|
+
private readonly retry;
|
|
500
|
+
private readonly customHeaders;
|
|
501
|
+
private readonly fetchFn;
|
|
502
|
+
private accessToken?;
|
|
503
|
+
private apiKey?;
|
|
504
|
+
constructor(config: FlexOpsConfig);
|
|
505
|
+
setAccessToken(token: string): void;
|
|
506
|
+
setApiKey(key: string): void;
|
|
507
|
+
request<T>(method: string, path: string, options?: {
|
|
508
|
+
body?: unknown;
|
|
509
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
510
|
+
headers?: Record<string, string>;
|
|
511
|
+
timeout?: number;
|
|
512
|
+
}): Promise<T>;
|
|
513
|
+
get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
514
|
+
post<T>(path: string, body?: unknown, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
515
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
516
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
517
|
+
delete<T>(path: string): Promise<T>;
|
|
518
|
+
private buildUrl;
|
|
519
|
+
private buildHeaders;
|
|
520
|
+
private calculateBackoff;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
declare class AuthResource {
|
|
524
|
+
private readonly http;
|
|
525
|
+
constructor(http: HttpClient);
|
|
526
|
+
/** Authenticate with email and password. Returns JWT tokens. */
|
|
527
|
+
login(request: LoginRequest): Promise<ApiResponse<LoginResponse>>;
|
|
528
|
+
/** Register a new account. */
|
|
529
|
+
register(request: RegisterRequest): Promise<ApiResponse<unknown>>;
|
|
530
|
+
/** Refresh an expired access token. */
|
|
531
|
+
refreshToken(refreshToken: string): Promise<ApiResponse<LoginResponse>>;
|
|
532
|
+
/** Log out and invalidate the current session. */
|
|
533
|
+
logout(): Promise<ApiResponse<unknown>>;
|
|
534
|
+
/** Get the current user's profile. */
|
|
535
|
+
getProfile(): Promise<ApiResponse<unknown>>;
|
|
536
|
+
/** Update the current user's profile. */
|
|
537
|
+
updateProfile(data: Record<string, unknown>): Promise<ApiResponse<unknown>>;
|
|
538
|
+
/** Change the current user's password. */
|
|
539
|
+
changePassword(currentPassword: string, newPassword: string): Promise<ApiResponse<unknown>>;
|
|
540
|
+
/** Request a password reset email. */
|
|
541
|
+
forgotPassword(email: string): Promise<ApiResponse<unknown>>;
|
|
542
|
+
/** Reset password using a reset token. */
|
|
543
|
+
resetPassword(token: string, newPassword: string): Promise<ApiResponse<unknown>>;
|
|
544
|
+
/** Verify email with the verification token. */
|
|
545
|
+
verifyEmail(token: string): Promise<ApiResponse<unknown>>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
declare class WorkspacesResource {
|
|
549
|
+
private readonly http;
|
|
550
|
+
private readonly getWorkspaceId;
|
|
551
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
552
|
+
private wsPath;
|
|
553
|
+
/** List all workspaces the current user belongs to. */
|
|
554
|
+
list(): Promise<ApiResponse<Workspace[]>>;
|
|
555
|
+
/** Get details for a specific workspace. */
|
|
556
|
+
get(workspaceId?: string): Promise<ApiResponse<Workspace>>;
|
|
557
|
+
/** Create a new workspace. */
|
|
558
|
+
create(request: CreateWorkspaceRequest): Promise<ApiResponse<Workspace>>;
|
|
559
|
+
/** Update workspace settings. */
|
|
560
|
+
update(data: Partial<Workspace>): Promise<ApiResponse<Workspace>>;
|
|
561
|
+
/** List members of the current workspace. */
|
|
562
|
+
listMembers(): Promise<ApiResponse<WorkspaceMember[]>>;
|
|
563
|
+
/** Invite a user to the workspace. */
|
|
564
|
+
inviteMember(email: string, role?: WorkspaceMember['role']): Promise<ApiResponse<unknown>>;
|
|
565
|
+
/** Remove a member from the workspace. */
|
|
566
|
+
removeMember(userId: string): Promise<ApiResponse<unknown>>;
|
|
567
|
+
/** Update a member's role. */
|
|
568
|
+
updateMemberRole(userId: string, role: WorkspaceMember['role']): Promise<ApiResponse<unknown>>;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
declare class ShippingResource {
|
|
572
|
+
private readonly http;
|
|
573
|
+
private readonly getWorkspaceId;
|
|
574
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
575
|
+
private wsPath;
|
|
576
|
+
/** Get shipping rates from all configured carriers. */
|
|
577
|
+
getRates(request: RateRequest): Promise<ApiResponse<ShippingRate[]>>;
|
|
578
|
+
/** Get the single cheapest rate across all carriers. */
|
|
579
|
+
getCheapestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
|
|
580
|
+
/** Get the single fastest rate across all carriers. */
|
|
581
|
+
getFastestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
|
|
582
|
+
/** Create a shipping label. */
|
|
583
|
+
createLabel(request: CreateLabelRequest): Promise<ApiResponse<Label>>;
|
|
584
|
+
/** Cancel (void) a shipping label. */
|
|
585
|
+
cancelLabel(labelId: string): Promise<ApiResponse<unknown>>;
|
|
586
|
+
/** Track a shipment by tracking number. */
|
|
587
|
+
track(trackingNumber: string): Promise<ApiResponse<TrackingInfo>>;
|
|
588
|
+
/** Validate and correct a shipping address. */
|
|
589
|
+
validateAddress(address: Address): Promise<ApiResponse<AddressValidationResult>>;
|
|
590
|
+
/** Create labels in batch. */
|
|
591
|
+
createBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
|
|
592
|
+
/** Preview a batch without purchasing (dry-run). */
|
|
593
|
+
previewBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
|
|
594
|
+
/** Get batch job status. */
|
|
595
|
+
getBatchStatus(jobId: string): Promise<ApiResponse<BatchLabelJob>>;
|
|
596
|
+
/** Download a label from a batch job. */
|
|
597
|
+
downloadBatchLabel(jobId: string, itemId: string): Promise<Response>;
|
|
598
|
+
/** List available carriers and their services. */
|
|
599
|
+
getCarriers(): Promise<ApiResponse<unknown>>;
|
|
600
|
+
/** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
|
|
601
|
+
getRecommendations(request: CarrierRecommendationRequest): Promise<ApiResponse<CarrierRecommendationResponse>>;
|
|
602
|
+
/** Predict delivery dates (P25/P50/P75/P95) for a carrier/service/lane combination. */
|
|
603
|
+
predictDelivery(request: DeliveryPredictionRequest): Promise<ApiResponse<DeliveryPredictionResponse>>;
|
|
604
|
+
/** Get cost-saving opportunities: lanes where switching carriers saves money without sacrificing reliability. */
|
|
605
|
+
getSavings(): Promise<ApiResponse<CostSavingsSummary>>;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Direct carrier operations via the VisionSuite Core Services API proxy.
|
|
610
|
+
*
|
|
611
|
+
* These methods provide pass-through access to carrier-specific endpoints
|
|
612
|
+
* (USPS, UPS, FedEx, DHL) via the Gateway's ApiProxy route. Use the
|
|
613
|
+
* high-level `client.shipping` methods for normalized operations, or
|
|
614
|
+
* these carrier-specific methods when you need full control.
|
|
615
|
+
*/
|
|
616
|
+
declare class CarriersResource {
|
|
617
|
+
private readonly http;
|
|
618
|
+
constructor(http: HttpClient);
|
|
619
|
+
private proxy;
|
|
620
|
+
readonly usps: {
|
|
621
|
+
/** Validate and correct a US address via USPS. */
|
|
622
|
+
validateAddress: (params: Record<string, string>) => Promise<unknown>;
|
|
623
|
+
/** City/State lookup by ZIP code. */
|
|
624
|
+
cityStateLookup: (zipCode: string) => Promise<unknown>;
|
|
625
|
+
/** ZIP code lookup by address. */
|
|
626
|
+
zipCodeLookup: (params: Record<string, string>) => Promise<unknown>;
|
|
627
|
+
/** Search domestic shipping rates. */
|
|
628
|
+
getDomesticRates: (body: unknown) => Promise<unknown>;
|
|
629
|
+
/** Search domestic product eligibility. */
|
|
630
|
+
getDomesticProducts: (body: unknown) => Promise<unknown>;
|
|
631
|
+
/** Search domestic prices. */
|
|
632
|
+
getDomesticPrices: (body: unknown) => Promise<unknown>;
|
|
633
|
+
/** Search international rates. */
|
|
634
|
+
getInternationalRates: (body: unknown) => Promise<unknown>;
|
|
635
|
+
/** Search international prices. */
|
|
636
|
+
getInternationalPrices: (body: unknown) => Promise<unknown>;
|
|
637
|
+
/** Generate a domestic shipping label. */
|
|
638
|
+
createDomesticLabel: (body: unknown) => Promise<unknown>;
|
|
639
|
+
/** Generate a domestic return label. */
|
|
640
|
+
createReturnLabel: (body: unknown) => Promise<unknown>;
|
|
641
|
+
/** Generate an international shipping label. */
|
|
642
|
+
createInternationalLabel: (body: unknown) => Promise<unknown>;
|
|
643
|
+
/** Cancel a domestic label. */
|
|
644
|
+
cancelDomesticLabel: () => Promise<unknown>;
|
|
645
|
+
/** Cancel an international label. */
|
|
646
|
+
cancelInternationalLabel: () => Promise<unknown>;
|
|
647
|
+
/** Get tracking summary. */
|
|
648
|
+
trackSummary: (params: Record<string, string>) => Promise<unknown>;
|
|
649
|
+
/** Get detailed tracking info. */
|
|
650
|
+
trackDetail: (params: Record<string, string>) => Promise<unknown>;
|
|
651
|
+
/** Schedule a carrier pickup. */
|
|
652
|
+
createPickup: (body: unknown) => Promise<unknown>;
|
|
653
|
+
/** Cancel a pickup. */
|
|
654
|
+
cancelPickup: () => Promise<unknown>;
|
|
655
|
+
/** Create a scan form. */
|
|
656
|
+
createScanForm: (body: unknown) => Promise<unknown>;
|
|
657
|
+
/** Get delivery standards estimates. */
|
|
658
|
+
deliveryStandards: (params: Record<string, string>) => Promise<unknown>;
|
|
659
|
+
/** Find drop-off locations. */
|
|
660
|
+
findDropOffLocations: (params: Record<string, string>) => Promise<unknown>;
|
|
661
|
+
/** Find post office locations. */
|
|
662
|
+
findPostOffices: (params: Record<string, string>) => Promise<unknown>;
|
|
663
|
+
};
|
|
664
|
+
readonly ups: {
|
|
665
|
+
/** Verify an address via UPS. */
|
|
666
|
+
validateAddress: (body: unknown) => Promise<unknown>;
|
|
667
|
+
/** Get UPS rate quotes. */
|
|
668
|
+
getRates: (body: unknown) => Promise<unknown>;
|
|
669
|
+
/** Generate a UPS shipping label. */
|
|
670
|
+
createLabel: (body: unknown) => Promise<unknown>;
|
|
671
|
+
/** Track a UPS shipment. */
|
|
672
|
+
track: (params: Record<string, string>) => Promise<unknown>;
|
|
673
|
+
/** Create a UPS pickup. */
|
|
674
|
+
createPickup: (body: unknown) => Promise<unknown>;
|
|
675
|
+
/** Cancel a UPS pickup. */
|
|
676
|
+
cancelPickup: () => Promise<unknown>;
|
|
677
|
+
/** Get UPS transit times. */
|
|
678
|
+
getTransitTimes: (body: unknown) => Promise<unknown>;
|
|
679
|
+
/** Get UPS landed cost quote (international). */
|
|
680
|
+
getLandedCost: (body: unknown) => Promise<unknown>;
|
|
681
|
+
/** Search UPS locations. */
|
|
682
|
+
searchLocations: (body: unknown) => Promise<unknown>;
|
|
683
|
+
/** Upload paperless trade document. */
|
|
684
|
+
uploadDocument: (body: unknown) => Promise<unknown>;
|
|
685
|
+
/** Create UPS freight shipment. */
|
|
686
|
+
createFreightShipment: (body: unknown) => Promise<unknown>;
|
|
687
|
+
/** Get UPS freight rate. */
|
|
688
|
+
getFreightRate: (body: unknown) => Promise<unknown>;
|
|
689
|
+
};
|
|
690
|
+
readonly fedex: {
|
|
691
|
+
/** Validate a domestic address via FedEx. */
|
|
692
|
+
validateAddress: (body: unknown) => Promise<unknown>;
|
|
693
|
+
/** Validate a postal code. */
|
|
694
|
+
validatePostalCode: (body: unknown) => Promise<unknown>;
|
|
695
|
+
/** Get FedEx rate and transit times. */
|
|
696
|
+
getRates: (body: unknown) => Promise<unknown>;
|
|
697
|
+
/** Create a FedEx shipment. */
|
|
698
|
+
createShipment: (body: unknown) => Promise<unknown>;
|
|
699
|
+
/** Cancel a FedEx shipment. */
|
|
700
|
+
cancelShipment: (body: unknown) => Promise<unknown>;
|
|
701
|
+
/** Validate a shipment (dry run). */
|
|
702
|
+
validateShipment: (body: unknown) => Promise<unknown>;
|
|
703
|
+
/** Create a return shipment. */
|
|
704
|
+
createReturnShipment: (body: unknown) => Promise<unknown>;
|
|
705
|
+
/** Track by tracking number. */
|
|
706
|
+
track: (body: unknown) => Promise<unknown>;
|
|
707
|
+
/** Track multi-piece shipment. */
|
|
708
|
+
trackMultiPiece: (body: unknown) => Promise<unknown>;
|
|
709
|
+
/** Register for tracking notifications. */
|
|
710
|
+
registerTrackingNotification: (body: unknown) => Promise<unknown>;
|
|
711
|
+
/** Create a carrier pickup. */
|
|
712
|
+
createPickup: (body: unknown) => Promise<unknown>;
|
|
713
|
+
/** Cancel a pickup. */
|
|
714
|
+
cancelPickup: (body: unknown) => Promise<unknown>;
|
|
715
|
+
/** Search valid locations. */
|
|
716
|
+
searchLocations: (body: unknown) => Promise<unknown>;
|
|
717
|
+
/** Get service standards and transit times. */
|
|
718
|
+
getServiceStandards: (body: unknown) => Promise<unknown>;
|
|
719
|
+
/** Get freight rate quote. */
|
|
720
|
+
getFreightRate: (body: unknown) => Promise<unknown>;
|
|
721
|
+
/** Create freight shipment. */
|
|
722
|
+
createFreightShipment: (body: unknown) => Promise<unknown>;
|
|
723
|
+
/** Ground close with documents. */
|
|
724
|
+
groundClose: (body: unknown) => Promise<unknown>;
|
|
725
|
+
/** Upload trade documents. */
|
|
726
|
+
uploadTradeDocuments: (body: unknown) => Promise<unknown>;
|
|
727
|
+
/** Create an open shipment. */
|
|
728
|
+
createOpenShipment: (body: unknown) => Promise<unknown>;
|
|
729
|
+
/** Add packages to an open shipment. */
|
|
730
|
+
addPackagesToOpenShipment: (body: unknown) => Promise<unknown>;
|
|
731
|
+
/** Confirm and finalize an open shipment. */
|
|
732
|
+
confirmOpenShipment: (body: unknown) => Promise<unknown>;
|
|
733
|
+
};
|
|
734
|
+
readonly dhl: {
|
|
735
|
+
/** Validate an address via DHL. */
|
|
736
|
+
validateAddress: (params: Record<string, string>) => Promise<unknown>;
|
|
737
|
+
/** Get DHL shipping rates. */
|
|
738
|
+
getRates: (params: Record<string, string>) => Promise<unknown>;
|
|
739
|
+
/** Get multi-piece rates. */
|
|
740
|
+
getMultiPieceRates: (body: unknown) => Promise<unknown>;
|
|
741
|
+
/** Get DHL products/services. */
|
|
742
|
+
getProducts: (params: Record<string, string>) => Promise<unknown>;
|
|
743
|
+
/** Create a DHL shipment (label). */
|
|
744
|
+
createShipment: (body: unknown) => Promise<unknown>;
|
|
745
|
+
/** Track a DHL shipment. */
|
|
746
|
+
track: (params: Record<string, string>) => Promise<unknown>;
|
|
747
|
+
/** Track multiple DHL shipments. */
|
|
748
|
+
trackMultiple: (params: Record<string, string>) => Promise<unknown>;
|
|
749
|
+
/** Create a DHL pickup. */
|
|
750
|
+
createPickup: (body: unknown) => Promise<unknown>;
|
|
751
|
+
/** Update a DHL pickup. */
|
|
752
|
+
updatePickup: (body: unknown) => Promise<unknown>;
|
|
753
|
+
/** Cancel a DHL pickup. */
|
|
754
|
+
cancelPickup: () => Promise<unknown>;
|
|
755
|
+
/** Calculate landed cost (duties/taxes). */
|
|
756
|
+
calculateLandedCost: (body: unknown) => Promise<unknown>;
|
|
757
|
+
/** Screen a shipment for compliance. */
|
|
758
|
+
screenShipment: (body: unknown) => Promise<unknown>;
|
|
759
|
+
/** Upload an invoice. */
|
|
760
|
+
uploadInvoice: (body: unknown) => Promise<unknown>;
|
|
761
|
+
/** Get electronic proof of delivery. */
|
|
762
|
+
getProofOfDelivery: (params: Record<string, string>) => Promise<unknown>;
|
|
763
|
+
/** Get reference data (countries, services, etc.). */
|
|
764
|
+
getReferenceData: (params: Record<string, string>) => Promise<unknown>;
|
|
765
|
+
/** Find DHL service points. */
|
|
766
|
+
findServicePoints: (params: Record<string, string>) => Promise<unknown>;
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
declare class WebhooksResource {
|
|
771
|
+
private readonly http;
|
|
772
|
+
private readonly getWorkspaceId;
|
|
773
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
774
|
+
private wsPath;
|
|
775
|
+
/** List all webhook subscriptions for the workspace. */
|
|
776
|
+
list(): Promise<ApiResponse<WebhookSubscription[]>>;
|
|
777
|
+
/** Get a webhook subscription by ID. */
|
|
778
|
+
get(webhookId: string): Promise<ApiResponse<WebhookSubscription>>;
|
|
779
|
+
/** Create a webhook subscription. */
|
|
780
|
+
create(request: CreateWebhookRequest): Promise<ApiResponse<WebhookSubscription>>;
|
|
781
|
+
/** Update a webhook subscription. */
|
|
782
|
+
update(webhookId: string, data: Partial<CreateWebhookRequest>): Promise<ApiResponse<WebhookSubscription>>;
|
|
783
|
+
/** Delete a webhook subscription. */
|
|
784
|
+
delete(webhookId: string): Promise<ApiResponse<unknown>>;
|
|
785
|
+
/** Rotate the signing secret for a webhook. */
|
|
786
|
+
rotateSecret(webhookId: string): Promise<ApiResponse<{
|
|
787
|
+
secret: string;
|
|
788
|
+
}>>;
|
|
789
|
+
/** List delivery logs for a webhook. */
|
|
790
|
+
listDeliveryLogs(webhookId: string): Promise<ApiResponse<unknown[]>>;
|
|
791
|
+
/**
|
|
792
|
+
* Verify a webhook signature from an incoming request.
|
|
793
|
+
* Use this in your webhook handler to validate authenticity.
|
|
794
|
+
*/
|
|
795
|
+
static verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
declare class WalletResource {
|
|
799
|
+
private readonly http;
|
|
800
|
+
private readonly getWorkspaceId;
|
|
801
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
802
|
+
private wsPath;
|
|
803
|
+
/** Get the current wallet balance. */
|
|
804
|
+
getBalance(): Promise<ApiResponse<WalletBalance>>;
|
|
805
|
+
/** Add funds to the wallet. */
|
|
806
|
+
addFunds(amount: number): Promise<ApiResponse<unknown>>;
|
|
807
|
+
/** List wallet transactions. */
|
|
808
|
+
listTransactions(query?: {
|
|
809
|
+
page?: number;
|
|
810
|
+
pageSize?: number;
|
|
811
|
+
startDate?: string;
|
|
812
|
+
endDate?: string;
|
|
813
|
+
}): Promise<ApiResponse<unknown>>;
|
|
814
|
+
/** Configure auto-reload settings. */
|
|
815
|
+
configureAutoReload(config: {
|
|
816
|
+
enabled: boolean;
|
|
817
|
+
threshold?: number;
|
|
818
|
+
amount?: number;
|
|
819
|
+
}): Promise<ApiResponse<unknown>>;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
declare class InsuranceResource {
|
|
823
|
+
private readonly http;
|
|
824
|
+
private readonly getWorkspaceId;
|
|
825
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
826
|
+
private wsPath;
|
|
827
|
+
/** Get available insurance providers for this workspace. */
|
|
828
|
+
getProviders(): Promise<ApiResponse<string[]>>;
|
|
829
|
+
/** Get an insurance quote. */
|
|
830
|
+
getQuote(request: {
|
|
831
|
+
carrier: string;
|
|
832
|
+
declaredValue: number;
|
|
833
|
+
provider?: string;
|
|
834
|
+
}): Promise<ApiResponse<InsuranceQuote>>;
|
|
835
|
+
/** Purchase insurance for a shipment. */
|
|
836
|
+
purchase(request: {
|
|
837
|
+
trackingNumber: string;
|
|
838
|
+
carrier: string;
|
|
839
|
+
declaredValue: number;
|
|
840
|
+
provider?: string;
|
|
841
|
+
}): Promise<ApiResponse<InsurancePolicy>>;
|
|
842
|
+
/** Void an insurance policy. */
|
|
843
|
+
void(policyId: string): Promise<ApiResponse<unknown>>;
|
|
844
|
+
/** File an insurance claim. */
|
|
845
|
+
fileClaim(policyId: string, claim: {
|
|
846
|
+
description: string;
|
|
847
|
+
claimAmount: number;
|
|
848
|
+
}): Promise<ApiResponse<unknown>>;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
declare class ReturnsResource {
|
|
852
|
+
private readonly http;
|
|
853
|
+
private readonly getWorkspaceId;
|
|
854
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
855
|
+
private wsPath;
|
|
856
|
+
/** List all return authorizations. */
|
|
857
|
+
list(query?: {
|
|
858
|
+
page?: number;
|
|
859
|
+
pageSize?: number;
|
|
860
|
+
status?: string;
|
|
861
|
+
}): Promise<ApiResponse<ReturnAuthorization[]>>;
|
|
862
|
+
/** Get a return authorization by ID. */
|
|
863
|
+
get(returnId: string): Promise<ApiResponse<ReturnAuthorization>>;
|
|
864
|
+
/** Create a return authorization (RMA). */
|
|
865
|
+
create(request: ReturnRequest): Promise<ApiResponse<ReturnAuthorization>>;
|
|
866
|
+
/** Approve a return authorization. */
|
|
867
|
+
approve(returnId: string): Promise<ApiResponse<ReturnAuthorization>>;
|
|
868
|
+
/** Reject a return authorization. */
|
|
869
|
+
reject(returnId: string, reason: string): Promise<ApiResponse<ReturnAuthorization>>;
|
|
870
|
+
/** Cancel a return authorization. */
|
|
871
|
+
cancel(returnId: string): Promise<ApiResponse<unknown>>;
|
|
872
|
+
/** Generate a return label for an approved RMA. */
|
|
873
|
+
generateLabel(returnId: string): Promise<ApiResponse<unknown>>;
|
|
874
|
+
/** Mark items as received. */
|
|
875
|
+
markReceived(returnId: string, items: {
|
|
876
|
+
sku: string;
|
|
877
|
+
quantity: number;
|
|
878
|
+
condition: string;
|
|
879
|
+
}[]): Promise<ApiResponse<unknown>>;
|
|
880
|
+
/** Process refund for a return. */
|
|
881
|
+
processRefund(returnId: string): Promise<ApiResponse<unknown>>;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
declare class ApiKeysResource {
|
|
885
|
+
private readonly http;
|
|
886
|
+
private readonly getWorkspaceId;
|
|
887
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
888
|
+
private wsPath;
|
|
889
|
+
/** List all API keys for the workspace. */
|
|
890
|
+
list(): Promise<ApiResponse<ApiKeyInfo[]>>;
|
|
891
|
+
/** Create a new API key. The full key is only returned once. */
|
|
892
|
+
create(request: CreateApiKeyRequest): Promise<ApiResponse<CreateApiKeyResponse>>;
|
|
893
|
+
/** Revoke an API key. */
|
|
894
|
+
revoke(keyId: string): Promise<ApiResponse<unknown>>;
|
|
895
|
+
/** Rotate an API key (revoke + create new). */
|
|
896
|
+
rotate(keyId: string): Promise<ApiResponse<CreateApiKeyResponse>>;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
type DateRange = {
|
|
900
|
+
startDate?: string;
|
|
901
|
+
endDate?: string;
|
|
902
|
+
period?: 'day' | 'week' | 'month';
|
|
903
|
+
};
|
|
904
|
+
declare class AnalyticsResource {
|
|
905
|
+
private readonly http;
|
|
906
|
+
constructor(http: HttpClient);
|
|
907
|
+
private path;
|
|
908
|
+
/** Shipments trend over time. */
|
|
909
|
+
shipmentsTrend(params?: DateRange): Promise<ApiResponse<ShipmentsTrend[]>>;
|
|
910
|
+
/** Carrier usage summary. */
|
|
911
|
+
carrierSummary(params?: DateRange): Promise<ApiResponse<CarrierSummary[]>>;
|
|
912
|
+
/** Top shipping destinations. */
|
|
913
|
+
topDestinations(params?: DateRange & {
|
|
914
|
+
limit?: number;
|
|
915
|
+
}): Promise<ApiResponse<unknown>>;
|
|
916
|
+
/** Inventory metrics (stock levels, low-stock alerts). */
|
|
917
|
+
inventoryMetrics(): Promise<ApiResponse<unknown>>;
|
|
918
|
+
/** Stock levels by warehouse. */
|
|
919
|
+
stockByWarehouse(): Promise<ApiResponse<unknown>>;
|
|
920
|
+
/** Order metrics (volume, revenue). */
|
|
921
|
+
orderMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
922
|
+
/** Order trend over time. */
|
|
923
|
+
orderTrend(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
924
|
+
/** Top selling products. */
|
|
925
|
+
topSellingProducts(params?: DateRange & {
|
|
926
|
+
limit?: number;
|
|
927
|
+
}): Promise<ApiResponse<unknown>>;
|
|
928
|
+
/** Returns metrics. */
|
|
929
|
+
returnsMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
930
|
+
/** Returns trend over time. */
|
|
931
|
+
returnsTrend(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
932
|
+
/** Return reasons breakdown. */
|
|
933
|
+
returnReasons(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
934
|
+
/** Fulfillment performance metrics. */
|
|
935
|
+
performanceMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
936
|
+
/** Carrier delivery performance. */
|
|
937
|
+
carrierPerformance(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
938
|
+
/** Shipping cost analytics. */
|
|
939
|
+
shippingCostAnalytics(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
940
|
+
/** Delivery performance (on-time %). */
|
|
941
|
+
deliveryPerformance(params?: DateRange): Promise<ApiResponse<unknown>>;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
declare class OrdersResource {
|
|
945
|
+
private readonly http;
|
|
946
|
+
constructor(http: HttpClient);
|
|
947
|
+
private path;
|
|
948
|
+
/** Create a new order. */
|
|
949
|
+
create(order: unknown): Promise<ApiResponse<unknown>>;
|
|
950
|
+
/** Get new orders awaiting processing. */
|
|
951
|
+
getNewOrders(params?: Record<string, string>): Promise<ApiResponse<Order[]>>;
|
|
952
|
+
/** Get all orders filtered by status. */
|
|
953
|
+
getByStatus(params?: Record<string, string>): Promise<ApiResponse<Order[]>>;
|
|
954
|
+
/** Get complete order details by order number. */
|
|
955
|
+
getDetails(orderNumber: string): Promise<ApiResponse<Order>>;
|
|
956
|
+
/** Get extended order details by order number. */
|
|
957
|
+
getExtendedDetails(orderNumber: string): Promise<ApiResponse<unknown>>;
|
|
958
|
+
/** Get order status by order number. */
|
|
959
|
+
getStatus(orderNumber: string): Promise<ApiResponse<unknown>>;
|
|
960
|
+
/** Cancel an order. */
|
|
961
|
+
cancel(orderNumber: string): Promise<ApiResponse<unknown>>;
|
|
962
|
+
/** Get all items for an order. */
|
|
963
|
+
getItems(orderNumber: string): Promise<ApiResponse<unknown>>;
|
|
964
|
+
/** Get available ship methods. */
|
|
965
|
+
getShipMethods(): Promise<ApiResponse<unknown>>;
|
|
966
|
+
/** Get active warehouse list. */
|
|
967
|
+
getWarehouses(): Promise<ApiResponse<unknown>>;
|
|
968
|
+
/** Get country codes. */
|
|
969
|
+
getCountryCodes(): Promise<ApiResponse<unknown>>;
|
|
970
|
+
/** Get order status types. */
|
|
971
|
+
getStatusTypes(): Promise<ApiResponse<unknown>>;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
declare class InventoryResource {
|
|
975
|
+
private readonly http;
|
|
976
|
+
constructor(http: HttpClient);
|
|
977
|
+
/** Post a new ASN (Advance Shipment Notice) receipt. */
|
|
978
|
+
postAsnReceipt(receipt: unknown): Promise<ApiResponse<unknown>>;
|
|
979
|
+
/** Get a warehouse inventory snapshot. */
|
|
980
|
+
getWarehouseSnapshot(params?: Record<string, string>): Promise<ApiResponse<unknown>>;
|
|
981
|
+
/** Get a complete inventory snapshot across all warehouses. */
|
|
982
|
+
getCompleteSnapshot(params?: Record<string, string>): Promise<ApiResponse<unknown>>;
|
|
983
|
+
/** Get the list of all part numbers. */
|
|
984
|
+
getPartNumbers(params?: Record<string, string>): Promise<ApiResponse<unknown>>;
|
|
985
|
+
/** Update customer inventory (V2). */
|
|
986
|
+
updateInventory(data: unknown): Promise<ApiResponse<unknown>>;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
declare class PickupsResource {
|
|
990
|
+
private readonly http;
|
|
991
|
+
private readonly getWorkspaceId;
|
|
992
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
993
|
+
private wsPath;
|
|
994
|
+
/** Schedule a carrier pickup. */
|
|
995
|
+
schedule(request: PickupRequest): Promise<ApiResponse<PickupConfirmation>>;
|
|
996
|
+
/** List scheduled pickups. */
|
|
997
|
+
list(): Promise<ApiResponse<PickupConfirmation[]>>;
|
|
998
|
+
/** Get pickup details. */
|
|
999
|
+
get(pickupId: string): Promise<ApiResponse<PickupConfirmation>>;
|
|
1000
|
+
/** Cancel a scheduled pickup. */
|
|
1001
|
+
cancel(pickupId: string): Promise<ApiResponse<unknown>>;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
declare class ScanFormsResource {
|
|
1005
|
+
private readonly http;
|
|
1006
|
+
private readonly getWorkspaceId;
|
|
1007
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1008
|
+
private wsPath;
|
|
1009
|
+
/** Create a USPS scan form (SCAN/manifest). */
|
|
1010
|
+
create(request: ScanFormRequest): Promise<ApiResponse<ScanForm>>;
|
|
1011
|
+
/** List scan forms. */
|
|
1012
|
+
list(): Promise<ApiResponse<ScanForm[]>>;
|
|
1013
|
+
/** Get a scan form by ID. */
|
|
1014
|
+
get(scanFormId: string): Promise<ApiResponse<ScanForm>>;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
declare class RulesResource {
|
|
1018
|
+
private readonly http;
|
|
1019
|
+
private readonly getWorkspaceId;
|
|
1020
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1021
|
+
private wsPath;
|
|
1022
|
+
/** List all shipping automation rules. Max 100 per workspace. */
|
|
1023
|
+
list(): Promise<ApiResponse<ShippingRule[]>>;
|
|
1024
|
+
/** Get a rule by ID. */
|
|
1025
|
+
get(ruleId: string): Promise<ApiResponse<ShippingRule>>;
|
|
1026
|
+
/** Create a shipping rule. */
|
|
1027
|
+
create(rule: Omit<ShippingRule, 'id'>): Promise<ApiResponse<ShippingRule>>;
|
|
1028
|
+
/** Update a shipping rule. */
|
|
1029
|
+
update(ruleId: string, rule: Partial<ShippingRule>): Promise<ApiResponse<ShippingRule>>;
|
|
1030
|
+
/** Delete a shipping rule. */
|
|
1031
|
+
delete(ruleId: string): Promise<ApiResponse<unknown>>;
|
|
1032
|
+
/** Reorder rules (set priority). */
|
|
1033
|
+
reorder(ruleIds: string[]): Promise<ApiResponse<unknown>>;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
declare class OffsetResource {
|
|
1037
|
+
private readonly http;
|
|
1038
|
+
private readonly getWorkspaceId;
|
|
1039
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1040
|
+
private wsPath;
|
|
1041
|
+
/** Purchase a certified carbon offset for a label. */
|
|
1042
|
+
offset(labelId: string): Promise<ApiResponse<OffsetResult>>;
|
|
1043
|
+
/** Get the estimated CO2 emissions for a label before purchasing an offset. */
|
|
1044
|
+
getEmissions(labelId: string): Promise<ApiResponse<EmissionsEstimate>>;
|
|
1045
|
+
/** Purchase carbon offsets for multiple labels in a single request. */
|
|
1046
|
+
batchOffset(labelIds: string[]): Promise<ApiResponse<OffsetResult[]>>;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
declare class HsCodesResource {
|
|
1050
|
+
private readonly http;
|
|
1051
|
+
private readonly getWorkspaceId;
|
|
1052
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1053
|
+
private wsPath;
|
|
1054
|
+
/** Search for HS codes by product description. Requires Enterprise plan. */
|
|
1055
|
+
search(query: string, options?: {
|
|
1056
|
+
destinationCountry?: string;
|
|
1057
|
+
maxResults?: number;
|
|
1058
|
+
}): Promise<ApiResponse<HsCodeResult[]>>;
|
|
1059
|
+
/** Look up a specific HS code by its tariff number. Requires Enterprise plan. */
|
|
1060
|
+
lookup(code: string): Promise<ApiResponse<HsCodeResult>>;
|
|
1061
|
+
/** Estimate the total landed cost (duty + tax + shipping) for a shipment. Requires Enterprise plan. */
|
|
1062
|
+
estimateLandedCost(request: LandedCostRequest): Promise<ApiResponse<LandedCostEstimate>>;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
declare class RecurringShipmentsResource {
|
|
1066
|
+
private readonly http;
|
|
1067
|
+
private readonly getWorkspaceId;
|
|
1068
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1069
|
+
private wsPath;
|
|
1070
|
+
/** List all recurring shipment schedules. */
|
|
1071
|
+
list(query?: {
|
|
1072
|
+
page?: number;
|
|
1073
|
+
pageSize?: number;
|
|
1074
|
+
isActive?: boolean;
|
|
1075
|
+
}): Promise<ApiResponse<RecurringShipment[]>>;
|
|
1076
|
+
/** Get a recurring shipment schedule by ID. */
|
|
1077
|
+
get(id: string): Promise<ApiResponse<RecurringShipment>>;
|
|
1078
|
+
/** Create a recurring shipment schedule. */
|
|
1079
|
+
create(request: CreateRecurringShipmentRequest): Promise<ApiResponse<RecurringShipment>>;
|
|
1080
|
+
/** Update a recurring shipment schedule. */
|
|
1081
|
+
update(id: string, request: UpdateRecurringShipmentRequest): Promise<ApiResponse<RecurringShipment>>;
|
|
1082
|
+
/** Delete a recurring shipment schedule. */
|
|
1083
|
+
delete(id: string): Promise<ApiResponse<unknown>>;
|
|
1084
|
+
/** Pause a recurring shipment (stops automatic execution without deleting). */
|
|
1085
|
+
pause(id: string): Promise<ApiResponse<RecurringShipment>>;
|
|
1086
|
+
/** Resume a paused recurring shipment. */
|
|
1087
|
+
resume(id: string): Promise<ApiResponse<RecurringShipment>>;
|
|
1088
|
+
/** Trigger an immediate execution outside the normal schedule. */
|
|
1089
|
+
trigger(id: string): Promise<ApiResponse<unknown>>;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
declare class EmailTemplatesResource {
|
|
1093
|
+
private readonly http;
|
|
1094
|
+
private readonly getWorkspaceId;
|
|
1095
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1096
|
+
private wsPath;
|
|
1097
|
+
/** List all email templates. */
|
|
1098
|
+
list(): Promise<ApiResponse<EmailTemplate[]>>;
|
|
1099
|
+
/** Get an email template by ID. */
|
|
1100
|
+
get(id: string): Promise<ApiResponse<EmailTemplate>>;
|
|
1101
|
+
/** Create an email template. */
|
|
1102
|
+
create(request: CreateEmailTemplateRequest): Promise<ApiResponse<EmailTemplate>>;
|
|
1103
|
+
/** Update an email template. */
|
|
1104
|
+
update(id: string, request: UpdateEmailTemplateRequest): Promise<ApiResponse<EmailTemplate>>;
|
|
1105
|
+
/** Delete an email template. */
|
|
1106
|
+
delete(id: string): Promise<ApiResponse<unknown>>;
|
|
1107
|
+
/** Preview a rendered email template with optional sample data. */
|
|
1108
|
+
preview(id: string, context?: Record<string, unknown>): Promise<ApiResponse<{
|
|
1109
|
+
html: string;
|
|
1110
|
+
subject: string;
|
|
1111
|
+
}>>;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
declare class ReportsResource {
|
|
1115
|
+
private readonly http;
|
|
1116
|
+
private readonly getWorkspaceId;
|
|
1117
|
+
constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
|
|
1118
|
+
private wsPath;
|
|
1119
|
+
/** List all scheduled report configurations. */
|
|
1120
|
+
list(): Promise<ApiResponse<ReportSchedule[]>>;
|
|
1121
|
+
/** Get a report schedule by ID. */
|
|
1122
|
+
get(id: string): Promise<ApiResponse<ReportSchedule>>;
|
|
1123
|
+
/** Create a scheduled report. */
|
|
1124
|
+
create(request: CreateReportScheduleRequest): Promise<ApiResponse<ReportSchedule>>;
|
|
1125
|
+
/** Update a scheduled report. */
|
|
1126
|
+
update(id: string, request: UpdateReportScheduleRequest): Promise<ApiResponse<ReportSchedule>>;
|
|
1127
|
+
/** Delete a scheduled report. */
|
|
1128
|
+
delete(id: string): Promise<ApiResponse<unknown>>;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* FlexOps Platform SDK Client
|
|
1133
|
+
*
|
|
1134
|
+
* The main entry point for interacting with the FlexOps multi-carrier
|
|
1135
|
+
* shipping platform API.
|
|
1136
|
+
*
|
|
1137
|
+
* @example Authentication with API key (recommended for server-to-server)
|
|
1138
|
+
* ```typescript
|
|
1139
|
+
* import { FlexOps } from '@flexops/sdk';
|
|
1140
|
+
*
|
|
1141
|
+
* const client = new FlexOps({
|
|
1142
|
+
* apiKey: 'fxk_live_...',
|
|
1143
|
+
* workspaceId: 'ws_abc123',
|
|
1144
|
+
* });
|
|
1145
|
+
*
|
|
1146
|
+
* // Get shipping rates
|
|
1147
|
+
* const rates = await client.shipping.getRates({
|
|
1148
|
+
* fromZip: '10001',
|
|
1149
|
+
* toZip: '90210',
|
|
1150
|
+
* weight: 16,
|
|
1151
|
+
* weightUnit: 'oz',
|
|
1152
|
+
* });
|
|
1153
|
+
*
|
|
1154
|
+
* // Create a label with the cheapest rate
|
|
1155
|
+
* const label = await client.shipping.createLabel({
|
|
1156
|
+
* carrier: rates.data[0].carrier,
|
|
1157
|
+
* service: rates.data[0].service,
|
|
1158
|
+
* fromAddress: { ... },
|
|
1159
|
+
* toAddress: { ... },
|
|
1160
|
+
* parcel: { weight: 16, weightUnit: 'oz' },
|
|
1161
|
+
* });
|
|
1162
|
+
* ```
|
|
1163
|
+
*
|
|
1164
|
+
* @example Authentication with email/password
|
|
1165
|
+
* ```typescript
|
|
1166
|
+
* const client = new FlexOps({ baseUrl: 'https://gateway.flexops.io' });
|
|
1167
|
+
* await client.auth.login({ email: 'user@co.com', password: '...' });
|
|
1168
|
+
* // Token is automatically stored and used for subsequent requests
|
|
1169
|
+
* ```
|
|
1170
|
+
*
|
|
1171
|
+
* @example Direct carrier operations
|
|
1172
|
+
* ```typescript
|
|
1173
|
+
* // USPS domestic label (full carrier-specific payload)
|
|
1174
|
+
* const uspsLabel = await client.carriers.usps.createDomesticLabel({
|
|
1175
|
+
* imageType: 'PDF',
|
|
1176
|
+
* mailClass: 'PRIORITY_MAIL',
|
|
1177
|
+
* weightInOunces: 16,
|
|
1178
|
+
* // ... full USPS payload
|
|
1179
|
+
* });
|
|
1180
|
+
*
|
|
1181
|
+
* // FedEx rate quote
|
|
1182
|
+
* const fedexRates = await client.carriers.fedex.getRates({
|
|
1183
|
+
* // ... full FedEx payload
|
|
1184
|
+
* });
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
declare class FlexOps {
|
|
1188
|
+
private readonly http;
|
|
1189
|
+
private _workspaceId?;
|
|
1190
|
+
readonly auth: AuthResource;
|
|
1191
|
+
readonly workspaces: WorkspacesResource;
|
|
1192
|
+
readonly shipping: ShippingResource;
|
|
1193
|
+
readonly carriers: CarriersResource;
|
|
1194
|
+
readonly webhooks: WebhooksResource;
|
|
1195
|
+
readonly wallet: WalletResource;
|
|
1196
|
+
readonly insurance: InsuranceResource;
|
|
1197
|
+
readonly returns: ReturnsResource;
|
|
1198
|
+
readonly apiKeys: ApiKeysResource;
|
|
1199
|
+
readonly analytics: AnalyticsResource;
|
|
1200
|
+
readonly orders: OrdersResource;
|
|
1201
|
+
readonly inventory: InventoryResource;
|
|
1202
|
+
readonly pickups: PickupsResource;
|
|
1203
|
+
readonly scanForms: ScanFormsResource;
|
|
1204
|
+
readonly rules: RulesResource;
|
|
1205
|
+
readonly offsets: OffsetResource;
|
|
1206
|
+
readonly hsCodes: HsCodesResource;
|
|
1207
|
+
readonly recurringShipments: RecurringShipmentsResource;
|
|
1208
|
+
readonly emailTemplates: EmailTemplatesResource;
|
|
1209
|
+
readonly reports: ReportsResource;
|
|
1210
|
+
constructor(config?: FlexOpsConfig);
|
|
1211
|
+
/** Get or set the active workspace ID. */
|
|
1212
|
+
get workspaceId(): string | undefined;
|
|
1213
|
+
set workspaceId(id: string | undefined);
|
|
1214
|
+
/** Set the JWT access token for authentication. */
|
|
1215
|
+
setAccessToken(token: string): void;
|
|
1216
|
+
/** Set the API key for authentication. */
|
|
1217
|
+
setApiKey(key: string): void;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
|