@flexops/sdk 1.1.1 → 3.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/dist/index.js CHANGED
@@ -21,33 +21,85 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AnalyticsResource: () => AnalyticsResource,
24
- ApiKeysResource: () => ApiKeysResource,
25
24
  AuthResource: () => AuthResource,
25
+ CarbonOffsetsResource: () => CarbonOffsetsResource,
26
26
  CarriersResource: () => CarriersResource,
27
27
  EmailTemplatesResource: () => EmailTemplatesResource,
28
28
  FlexOps: () => FlexOps,
29
29
  FlexOpsAuthError: () => FlexOpsAuthError,
30
30
  FlexOpsError: () => FlexOpsError,
31
31
  FlexOpsRateLimitError: () => FlexOpsRateLimitError,
32
+ HazmatClassification: () => HazmatClassification,
32
33
  HsCodesResource: () => HsCodesResource,
33
34
  InsuranceResource: () => InsuranceResource,
34
35
  InventoryResource: () => InventoryResource,
35
- OffsetResource: () => OffsetResource,
36
36
  OrdersResource: () => OrdersResource,
37
37
  PickupsResource: () => PickupsResource,
38
+ RecurrenceInterval: () => RecurrenceInterval,
38
39
  RecurringShipmentsResource: () => RecurringShipmentsResource,
39
- ReportsResource: () => ReportsResource,
40
+ ReportFormat: () => ReportFormat,
41
+ ReportFrequency: () => ReportFrequency,
42
+ ReportSchedulesResource: () => ReportSchedulesResource,
40
43
  ReturnsResource: () => ReturnsResource,
41
44
  RulesResource: () => RulesResource,
42
45
  ScanFormsResource: () => ScanFormsResource,
43
46
  ShippingResource: () => ShippingResource,
47
+ TrackingEmailEvent: () => TrackingEmailEvent,
44
48
  WalletResource: () => WalletResource,
49
+ WebhookEventType: () => WebhookEventType,
45
50
  WebhooksResource: () => WebhooksResource,
51
+ WorkspaceRole: () => WorkspaceRole,
46
52
  WorkspacesResource: () => WorkspacesResource
47
53
  });
48
54
  module.exports = __toCommonJS(index_exports);
49
55
 
50
56
  // src/types.ts
57
+ var WorkspaceRole = {
58
+ Owner: 0,
59
+ Admin: 1,
60
+ Member: 2,
61
+ Merchant: 3
62
+ };
63
+ var HazmatClassification = {
64
+ None: 0,
65
+ LimitedQuantity: 1,
66
+ LithiumBatteryContainedInEquipment: 2,
67
+ LithiumBatteryPackedWithEquipment: 3,
68
+ LithiumBatteryStandalone: 4,
69
+ OtherRestricted: 5,
70
+ LithiumBatteryUsedDevice: 6
71
+ };
72
+ var WebhookEventType = {
73
+ LabelCreated: "LabelCreated",
74
+ LabelCanceled: "LabelCanceled",
75
+ BatchCompleted: "BatchCompleted",
76
+ TrackingUpdated: "TrackingUpdated",
77
+ TrackingDelivered: "TrackingDelivered"
78
+ };
79
+ var RecurrenceInterval = {
80
+ Daily: 0,
81
+ Weekly: 1,
82
+ Biweekly: 2,
83
+ Monthly: 3,
84
+ Custom: 4
85
+ };
86
+ var ReportFormat = {
87
+ Csv: 0,
88
+ Json: 1
89
+ };
90
+ var ReportFrequency = {
91
+ Daily: 0,
92
+ Weekly: 1,
93
+ Monthly: 2
94
+ };
95
+ var TrackingEmailEvent = {
96
+ LabelCreated: 0,
97
+ InTransit: 1,
98
+ OutForDelivery: 2,
99
+ Delivered: 3,
100
+ Exception: 4,
101
+ ReturnToSender: 5
102
+ };
51
103
  var FlexOpsError = class extends Error {
52
104
  constructor(message, status, code, errors) {
53
105
  super(message);
@@ -71,6 +123,20 @@ var FlexOpsAuthError = class extends FlexOpsError {
71
123
  }
72
124
  };
73
125
 
126
+ // src/node-crypto.ts
127
+ function loadNodeCrypto(purpose) {
128
+ const fromProcess = globalThis.process?.getBuiltinModule?.("node:crypto");
129
+ if (fromProcess) return fromProcess;
130
+ if (typeof require === "function") {
131
+ return require("crypto");
132
+ }
133
+ throw new Error(`${purpose} needs node:crypto (Node.js 20.16+ for the ES module build).`);
134
+ }
135
+ function randomUuid() {
136
+ const webCrypto = globalThis.crypto;
137
+ return webCrypto?.randomUUID ? webCrypto.randomUUID() : loadNodeCrypto("Generating an Idempotency-Key").randomUUID();
138
+ }
139
+
74
140
  // src/http.ts
75
141
  var DEFAULT_BASE_URL = "https://gateway.flexops.io";
76
142
  var DEFAULT_TIMEOUT = 3e4;
@@ -79,6 +145,9 @@ var DEFAULT_RETRY = {
79
145
  baseDelay: 1e3,
80
146
  retryableStatusCodes: [429, 500, 502, 503, 504]
81
147
  };
148
+ var WRITE_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
149
+ var WRITE_RETRYABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
150
+ var IDEMPOTENCY_CONFLICT = "IDEMPOTENCY_CONFLICT";
82
151
  var HttpClient = class {
83
152
  baseUrl;
84
153
  timeout;
@@ -99,6 +168,10 @@ var HttpClient = class {
99
168
  setAccessToken(token) {
100
169
  this.accessToken = token;
101
170
  }
171
+ /** The JWT access token in use, if any. */
172
+ getAccessToken() {
173
+ return this.accessToken;
174
+ }
102
175
  setApiKey(key) {
103
176
  this.apiKey = key;
104
177
  }
@@ -107,6 +180,10 @@ var HttpClient = class {
107
180
  const headers = this.buildHeaders(options?.headers);
108
181
  const body = options?.body ? JSON.stringify(options.body) : void 0;
109
182
  const timeout = options?.timeout ?? this.timeout;
183
+ const verb = method.toUpperCase();
184
+ if (WRITE_METHODS.has(verb) && !Object.keys(headers).some((h) => h.toLowerCase() === "idempotency-key")) {
185
+ headers["Idempotency-Key"] = randomUuid();
186
+ }
110
187
  let lastError;
111
188
  for (let attempt = 0; attempt <= this.retry.maxRetries; attempt++) {
112
189
  if (attempt > 0) {
@@ -115,65 +192,60 @@ var HttpClient = class {
115
192
  }
116
193
  const controller = new AbortController();
117
194
  const timer = setTimeout(() => controller.abort(), timeout);
195
+ let response;
118
196
  try {
119
- const response = await this.fetchFn(url, {
197
+ response = await this.fetchFn(url, {
120
198
  method,
121
199
  headers,
122
200
  body,
123
201
  signal: controller.signal
124
202
  });
125
- clearTimeout(timer);
126
- if (response.ok) {
127
- const contentType = response.headers.get("content-type") ?? "";
128
- if (contentType.includes("application/json")) {
129
- return await response.json();
130
- }
131
- return response;
132
- }
133
- if (response.status === 429) {
134
- const retryAfter = parseInt(response.headers.get("retry-after") ?? "0", 10);
135
- lastError = new FlexOpsRateLimitError(
136
- `Rate limited. Retry after ${retryAfter}s`,
137
- retryAfter
138
- );
139
- if (this.retry.retryableStatusCodes.includes(429)) continue;
140
- throw lastError;
141
- }
142
- if (response.status === 401) {
143
- throw new FlexOpsAuthError("Authentication required. Check your access token or API key.");
144
- }
145
- if (response.status === 403) {
146
- throw new FlexOpsError("Access denied. Check your plan tier and feature entitlements.", 403, "FORBIDDEN");
147
- }
148
- let errorBody = {};
149
- try {
150
- errorBody = await response.json();
151
- } catch {
152
- }
153
- const error = new FlexOpsError(
154
- errorBody.message ?? `HTTP ${response.status}: ${response.statusText}`,
155
- response.status,
156
- void 0,
157
- errorBody.errors
158
- );
159
- if (this.retry.retryableStatusCodes.includes(response.status)) {
160
- lastError = error;
161
- continue;
162
- }
163
- throw error;
164
203
  } catch (err) {
204
+ lastError = err instanceof DOMException && err.name === "AbortError" ? new FlexOpsError(`Request timed out after ${timeout}ms`, 0, "TIMEOUT") : err instanceof Error ? err : new Error(String(err));
205
+ if (verb === "DELETE") throw lastError;
206
+ continue;
207
+ } finally {
165
208
  clearTimeout(timer);
166
- if (err instanceof FlexOpsError) {
167
- if (err instanceof FlexOpsRateLimitError && attempt < this.retry.maxRetries) continue;
168
- throw err;
209
+ }
210
+ if (response.ok) {
211
+ if (response.status === 204 || response.headers.get("content-length") === "0") {
212
+ return void 0;
169
213
  }
170
- if (err instanceof DOMException && err.name === "AbortError") {
171
- lastError = new FlexOpsError(`Request timed out after ${timeout}ms`, 0, "TIMEOUT");
172
- continue;
214
+ const contentType = response.headers.get("content-type") ?? "";
215
+ if (contentType.includes("application/json")) {
216
+ return await response.json();
173
217
  }
174
- lastError = err instanceof Error ? err : new Error(String(err));
175
- if (attempt < this.retry.maxRetries) continue;
218
+ return response;
219
+ }
220
+ if (response.status === 429) {
221
+ const retryAfter = parseInt(response.headers.get("retry-after") ?? "0", 10);
222
+ lastError = new FlexOpsRateLimitError(
223
+ `Rate limited. Retry after ${retryAfter}s`,
224
+ retryAfter
225
+ );
226
+ if (this.retry.retryableStatusCodes.includes(429)) continue;
227
+ throw lastError;
228
+ }
229
+ if (response.status === 401) {
230
+ throw new FlexOpsAuthError("Authentication required. Check your access token or API key.");
176
231
  }
232
+ let errorBody = {};
233
+ try {
234
+ errorBody = await response.json();
235
+ } catch {
236
+ }
237
+ const code = errorBody.code ?? errorBody.errorCode;
238
+ const error = new FlexOpsError(
239
+ errorBody.message ?? `HTTP ${response.status}: ${response.statusText}`,
240
+ response.status,
241
+ code ?? (response.status === 403 ? "FORBIDDEN" : void 0),
242
+ errorBody.errors
243
+ );
244
+ if (this.isRetryable(verb, response.status, code)) {
245
+ lastError = error;
246
+ continue;
247
+ }
248
+ throw error;
177
249
  }
178
250
  throw lastError ?? new FlexOpsError("Request failed after retries", 0, "RETRY_EXHAUSTED");
179
251
  }
@@ -217,6 +289,17 @@ var HttpClient = class {
217
289
  }
218
290
  return headers;
219
291
  }
292
+ /**
293
+ * GETs retry on every configured status. A write retries only where the Gateway either did not
294
+ * run it or will replay it for the same Idempotency-Key: never after a 500, whose response the
295
+ * Gateway does not cache, so a retry would run the write again. A DELETE retries only on 429.
296
+ */
297
+ isRetryable(verb, status, code) {
298
+ if (verb === "GET" || verb === "HEAD") return this.retry.retryableStatusCodes.includes(status);
299
+ if (verb === "DELETE") return false;
300
+ if (status === 409) return code === IDEMPOTENCY_CONFLICT;
301
+ return WRITE_RETRYABLE_STATUSES.has(status) && this.retry.retryableStatusCodes.includes(status);
302
+ }
220
303
  calculateBackoff(attempt) {
221
304
  const jitter = Math.random() * 0.3 + 0.85;
222
305
  return Math.min(this.retry.baseDelay * Math.pow(2, attempt - 1) * jitter, 3e4);
@@ -231,30 +314,34 @@ var AuthResource = class {
231
314
  constructor(http) {
232
315
  this.http = http;
233
316
  }
234
- /** Authenticate with email and password. Returns JWT tokens. */
317
+ /**
318
+ * Authenticate with email and password. On success the returned access token (`data.token`) is
319
+ * used for later requests. When `data.requiresTwoFactor` is true no token is issued yet.
320
+ */
235
321
  async login(request) {
236
322
  const result = await this.http.post(
237
323
  "/api/Account/login",
238
324
  request
239
325
  );
240
- if (result.data?.accessToken) {
241
- this.http.setAccessToken(result.data.accessToken);
326
+ if (result.data?.token) {
327
+ this.http.setAccessToken(result.data.token);
242
328
  }
243
329
  return result;
244
330
  }
245
- /** Register a new account. */
246
- async register(request) {
247
- return this.http.post("/api/Account/register", request);
248
- }
249
- /** Refresh an expired access token. */
250
- async refreshToken(refreshToken) {
251
- const response = await this.http.request(
252
- "POST",
331
+ /**
332
+ * Exchange a refresh token for a new access token. The Gateway needs the expired access token
333
+ * too; it defaults to the one this client holds.
334
+ */
335
+ async refreshToken(refreshToken, accessToken = this.http.getAccessToken()) {
336
+ if (!accessToken) {
337
+ throw new FlexOpsAuthError("refreshToken needs the expired access token; log in first or pass it.");
338
+ }
339
+ const response = await this.http.post(
253
340
  "/api/Account/refresh-token",
254
- { headers: { "X-Current-Session-Token": refreshToken } }
341
+ { token: accessToken, refreshToken }
255
342
  );
256
- if (response.data?.accessToken) {
257
- this.http.setAccessToken(response.data.accessToken);
343
+ if (response.data?.token) {
344
+ this.http.setAccessToken(response.data.token);
258
345
  }
259
346
  return response;
260
347
  }
@@ -262,33 +349,6 @@ var AuthResource = class {
262
349
  async logout() {
263
350
  return this.http.post("/api/Account/logout");
264
351
  }
265
- /** Get the current user's profile. */
266
- async getProfile() {
267
- return this.http.get("/api/Account/profile");
268
- }
269
- /** Update the current user's profile. */
270
- async updateProfile(data) {
271
- return this.http.put("/api/Account/profile", data);
272
- }
273
- /** Change the current user's password. */
274
- async changePassword(currentPassword, newPassword) {
275
- return this.http.post("/api/Account/change-password", {
276
- currentPassword,
277
- newPassword
278
- });
279
- }
280
- /** Request a password reset email. */
281
- async forgotPassword(email) {
282
- return this.http.post("/api/Account/forgot-password", { email });
283
- }
284
- /** Reset password using a reset token. */
285
- async resetPassword(token, newPassword) {
286
- return this.http.post("/api/Account/reset-password", { token, newPassword });
287
- }
288
- /** Verify email with the verification token. */
289
- async verifyEmail(token) {
290
- return this.http.post("/api/Account/verify-email", { token });
291
- }
292
352
  };
293
353
 
294
354
  // src/resources/workspaces.ts
@@ -311,29 +371,21 @@ var WorkspacesResource = class {
311
371
  const id = workspaceId ?? this.getWorkspaceId();
312
372
  return this.http.get(`/api/workspaces/${id}`);
313
373
  }
314
- /** Create a new workspace. */
315
- async create(request) {
316
- return this.http.post("/api/workspaces", request);
317
- }
318
- /** Update workspace settings. */
319
- async update(data) {
320
- return this.http.put(this.wsPath(), data);
321
- }
322
- /** List members of the current workspace. */
374
+ /** List the current workspace's members and pending invites. */
323
375
  async listMembers() {
324
376
  return this.http.get(this.wsPath("members"));
325
377
  }
326
378
  /** Invite a user to the workspace. */
327
- async inviteMember(email, role = "Member") {
379
+ async inviteMember(email, role = WorkspaceRole.Member) {
328
380
  return this.http.post(this.wsPath("members/invite"), { email, role });
329
381
  }
330
382
  /** Remove a member from the workspace. */
331
383
  async removeMember(userId) {
332
384
  return this.http.delete(this.wsPath(`members/${userId}`));
333
385
  }
334
- /** Update a member's role. */
386
+ /** Change a member's role. */
335
387
  async updateMemberRole(userId, role) {
336
- return this.http.put(this.wsPath(`members/${userId}/role`), { role });
388
+ return this.http.put(this.wsPath(`members/${userId}/role`), { newRole: role });
337
389
  }
338
390
  };
339
391
 
@@ -353,15 +405,15 @@ var ShippingResource = class {
353
405
  // -----------------------------------------------------------------------
354
406
  /** Get shipping rates from all configured carriers. */
355
407
  async getRates(request) {
356
- return this.http.post("/api/shipping/rates", request);
408
+ return this.http.post("/api/shipping/rates", toRateWire(request));
357
409
  }
358
410
  /** Get the single cheapest rate across all carriers. */
359
411
  async getCheapestRate(request) {
360
- return this.http.post("/api/shipping/rates/cheapest", request);
412
+ return this.http.post("/api/shipping/rates/cheapest", toRateWire(request));
361
413
  }
362
414
  /** Get the single fastest rate across all carriers. */
363
415
  async getFastestRate(request) {
364
- return this.http.post("/api/shipping/rates/fastest", request);
416
+ return this.http.post("/api/shipping/rates/fastest", toRateWire(request));
365
417
  }
366
418
  // -----------------------------------------------------------------------
367
419
  // Labels
@@ -372,7 +424,41 @@ var ShippingResource = class {
372
424
  * server-side and postage is settled atomically. Returns the raw label (HTTP 201).
373
425
  */
374
426
  async createLabel(request) {
375
- return this.http.post("/api/shipping/labels", request, void 0);
427
+ const { body, idempotencyKey } = toLabelWire(request);
428
+ const result = await this.http.request("POST", "/api/shipping/labels", {
429
+ body,
430
+ ...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
431
+ });
432
+ if ("status" in result) throw new FlexOpsError("Approval required. Use prepareLabel, review its preview, then purchaseLabel.", 400, "ApprovalRequired");
433
+ return result;
434
+ }
435
+ /** Preview without approval. Keep the returned immutable operation for every purchase attempt. */
436
+ async prepareLabel(request, maximumPostageAmount, idempotencyKey) {
437
+ if (!idempotencyKey.trim() || !Number.isFinite(maximumPostageAmount) || maximumPostageAmount <= 0 || maximumPostageAmount > 1e6 || Math.abs(maximumPostageAmount * 100 - Math.round(maximumPostageAmount * 100)) > 1e-7)
438
+ throw new FlexOpsError("Supply a stable key and positive USD maximum with at most two decimal places.", 400, "InvalidApproval");
439
+ const body = JSON.parse(JSON.stringify(request));
440
+ for (const key of Object.keys(body)) if (["confirmationtoken", "maximumpostageamount"].includes(key.toLowerCase())) delete body[key];
441
+ body.maximumPostageAmount = maximumPostageAmount;
442
+ const result = await this.http.request("POST", "/api/shipping/labels", {
443
+ body,
444
+ headers: { "Idempotency-Key": idempotencyKey }
445
+ });
446
+ if ("isSandbox" in result && result.isSandbox === true)
447
+ return Object.freeze({ idempotencyKey, requestJson: JSON.stringify(body), preview: null, sandboxLabel: result });
448
+ if (!("status" in result) || result.status !== "Preview" || !result.confirmationToken || result.currency !== "USD" || !Number.isFinite(result.quotedPostageAmount) || result.quotedPostageAmount <= 0 || result.quotedPostageAmount > maximumPostageAmount || result.maximumPostageAmount !== maximumPostageAmount || !Number.isFinite(Date.parse(result.expiresAt)))
449
+ throw new FlexOpsError("Gateway did not return a valid bounded preview.", 502, "InvalidPreview");
450
+ body.confirmationToken = result.confirmationToken;
451
+ return Object.freeze({ idempotencyKey, requestJson: JSON.stringify(body), preview: Object.freeze(result) });
452
+ }
453
+ /** Call only after explicit approval. Same-key replay remains valid after token expiry. */
454
+ async purchaseLabel(approval) {
455
+ if (approval.sandboxLabel) return approval.sandboxLabel;
456
+ const result = await this.http.request("POST", "/api/shipping/labels", {
457
+ body: JSON.parse(approval.requestJson),
458
+ headers: { "Idempotency-Key": approval.idempotencyKey }
459
+ });
460
+ if (!result.trackingNumber) throw new FlexOpsError("Unresolved purchase. Retain the operation and reconcile before creating another label.", 409, "OutcomeUnknown");
461
+ return result;
376
462
  }
377
463
  /** Cancel (void) a shipping label. `carrierCode` is required. */
378
464
  async cancelLabel(labelId, carrierCode) {
@@ -392,7 +478,16 @@ var ShippingResource = class {
392
478
  // -----------------------------------------------------------------------
393
479
  /** Validate and correct a shipping address. */
394
480
  async validateAddress(address) {
395
- return this.http.post("/api/shipping/addresses/validate", address);
481
+ const a = toShippingAddress(address);
482
+ return this.http.post("/api/addresses/validate", {
483
+ name: a.name,
484
+ line1: a.addressLine1,
485
+ line2: a.addressLine2,
486
+ city: a.city,
487
+ state: a.stateProvince,
488
+ postalCode: a.postalCode,
489
+ country: a.countryCode ?? "US"
490
+ });
396
491
  }
397
492
  // -----------------------------------------------------------------------
398
493
  // Batch Labels
@@ -436,6 +531,48 @@ var ShippingResource = class {
436
531
  return this.http.get("/api/shipping/savings");
437
532
  }
438
533
  };
534
+ function unsupported(message) {
535
+ return new FlexOpsError(message, 400, "UnsupportedRequestShape");
536
+ }
537
+ function toShippingAddress(address) {
538
+ if (!("street1" in address)) return address;
539
+ return {
540
+ name: address.name,
541
+ company: address.company,
542
+ addressLine1: address.street1,
543
+ addressLine2: address.street2,
544
+ city: address.city,
545
+ stateProvince: address.state,
546
+ postalCode: address.zip,
547
+ countryCode: address.country,
548
+ phone: address.phone,
549
+ email: address.email
550
+ };
551
+ }
552
+ function toRateWire(request) {
553
+ if ("fromZip" in request)
554
+ throw unsupported("The Gateway needs full origin and destination addresses. Use origin, destination and package.");
555
+ return request;
556
+ }
557
+ function isLegacyLabelRequest(request) {
558
+ return "fromAddress" in request && !("origin" in request);
559
+ }
560
+ function toLabelWire(request) {
561
+ if (!isLegacyLabelRequest(request)) return { body: request };
562
+ if (request.returnLabel)
563
+ throw unsupported("createLabel cannot buy return labels. Use the returns API.");
564
+ const body = {
565
+ carrierCode: request.carrier,
566
+ serviceCode: request.service,
567
+ origin: toShippingAddress(request.fromAddress),
568
+ destination: toShippingAddress(request.toAddress),
569
+ package: { ...request.parcel },
570
+ labelFormat: request.labelFormat,
571
+ orderId: request.orderId,
572
+ hazmatClassification: request.hazmatClassification
573
+ };
574
+ return { body, idempotencyKey: request.idempotencyKey };
575
+ }
439
576
 
440
577
  // src/resources/carriers.ts
441
578
  var CarriersResource = class {
@@ -455,38 +592,94 @@ var CarriersResource = class {
455
592
  cityStateLookup: (zipCode) => this.http.get(this.proxy("api/v3/AddressValidation/getUspsCityStateLookupByZipCode"), { zipCode }),
456
593
  /** ZIP code lookup by address. */
457
594
  zipCodeLookup: (params) => this.http.get(this.proxy("api/v3/AddressValidation/getUspsZipCodeLookupByAddress"), params),
458
- /** Search domestic shipping rates. */
595
+ /**
596
+ * Search domestic shipping rates.
597
+ *
598
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
599
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
600
+ * cover this.
601
+ */
459
602
  getDomesticRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchDomesticBaseRates"), body),
460
- /** Search domestic product eligibility. */
603
+ /**
604
+ * Search domestic product eligibility.
605
+ *
606
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
607
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
608
+ * cover this.
609
+ */
461
610
  getDomesticProducts: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleDomesticProducts"), body),
462
- /** Search domestic prices. */
611
+ /**
612
+ * Search domestic prices.
613
+ *
614
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
615
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
616
+ * cover this.
617
+ */
463
618
  getDomesticPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleDomesticPrices"), body),
464
- /** Search international rates. */
619
+ /**
620
+ * Search international rates.
621
+ *
622
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
623
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
624
+ * cover this.
625
+ */
465
626
  getInternationalRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchInternationalBaseRates"), body),
466
- /** Search international prices. */
627
+ /**
628
+ * Search international prices.
629
+ *
630
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
631
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
632
+ * cover this.
633
+ */
467
634
  getInternationalPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleInternationalPrices"), body),
468
635
  /** Generate a domestic shipping label. */
469
636
  // Domestic USPS labels go through the reliable order-based Gateway path
470
637
  // (POST /api/shipping/labels): pass a LabelRequest body with carrierCode:'USPS'
471
638
  // and orderId set — server-side order validation + atomic postage settlement.
472
- createDomesticLabel: (body) => this.http.post("/api/shipping/labels", body),
473
- /** Generate a domestic return label. */
474
- createReturnLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateDomesticReturnsShippingLabel"), body),
475
- /** Generate an international shipping label. */
476
- createInternationalLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateInternationalShippingLabel"), body),
477
- /** Cancel a domestic label. */
639
+ createDomesticLabel: (body) => new ShippingResource(this.http, () => void 0).createLabel(body),
640
+ /**
641
+ * Cancel a domestic label.
642
+ *
643
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
644
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
645
+ * cover this.
646
+ */
478
647
  cancelDomesticLabel: () => this.http.delete(this.proxy("api/v3/Shipping/cancelUspsDomesticShipmentLabel")),
479
- /** Cancel an international label. */
648
+ /**
649
+ * Cancel an international label.
650
+ *
651
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
652
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
653
+ * cover this.
654
+ */
480
655
  cancelInternationalLabel: () => this.http.delete(this.proxy("api/v3/Shipping/cancelUspsInternationalShipmentLabel")),
481
656
  /** Get tracking summary. */
482
657
  trackSummary: (params) => this.http.get(this.proxy("api/v3/Tracking/getUspsTrackingSummaryInformation"), params),
483
658
  /** Get detailed tracking info. */
484
659
  trackDetail: (params) => this.http.get(this.proxy("api/v3/Tracking/getUspsTrackingDetailInformation"), params),
485
- /** Schedule a carrier pickup. */
660
+ /**
661
+ * Schedule a carrier pickup.
662
+ *
663
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
664
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
665
+ * cover this.
666
+ */
486
667
  createPickup: (body) => this.http.post(this.proxy("api/v3/CarrierPickup/postUspsCreateCarrierPickupSchedule"), body),
487
- /** Cancel a pickup. */
668
+ /**
669
+ * Cancel a pickup.
670
+ *
671
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
672
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
673
+ * cover this.
674
+ */
488
675
  cancelPickup: () => this.http.delete(this.proxy("api/v3/CarrierPickup/cancelUspsCarrierPickupSchedule")),
489
- /** Create a scan form. */
676
+ /**
677
+ * Create a scan form.
678
+ *
679
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
680
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
681
+ * cover this.
682
+ */
490
683
  createScanForm: (body) => this.http.post(this.proxy("api/v3/ScanForm/postUspsCreateScanFormLabelShipment"), body),
491
684
  /** Get delivery standards estimates. */
492
685
  deliveryStandards: (params) => this.http.get(this.proxy("api/v3/ServiceStandards/getUspsGetDeliveryStandardsEstimates"), params),
@@ -499,77 +692,245 @@ var CarriersResource = class {
499
692
  // UPS (V2 endpoints)
500
693
  // -----------------------------------------------------------------------
501
694
  ups = {
502
- /** Verify an address via UPS. */
695
+ /**
696
+ * Verify an address via UPS.
697
+ *
698
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
699
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
700
+ * cover this.
701
+ */
503
702
  validateAddress: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsVerifyAddress"), body),
504
- /** Get UPS rate quotes. */
703
+ /**
704
+ * Get UPS rate quotes.
705
+ *
706
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
707
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
708
+ * cover this.
709
+ */
505
710
  getRates: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsRateCheck"), body),
506
- /** Generate a UPS shipping label. */
507
- createLabel: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/generateNewUpsShipLabel"), body),
508
711
  /** Track a UPS shipment. */
509
712
  track: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getSingleUpsTrackingDetail"), params),
510
- /** Create a UPS pickup. */
713
+ /**
714
+ * Create a UPS pickup.
715
+ *
716
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
717
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
718
+ * cover this.
719
+ */
511
720
  createPickup: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsCreatePickup"), body),
512
- /** Cancel a UPS pickup. */
721
+ /**
722
+ * Cancel a UPS pickup.
723
+ *
724
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
725
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
726
+ * cover this.
727
+ */
513
728
  cancelPickup: () => this.http.delete(this.proxy("api/v2/ShippingLabel/deleteUpsPickup")),
514
- /** Get UPS transit times. */
729
+ /**
730
+ * Get UPS transit times.
731
+ *
732
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
733
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
734
+ * cover this.
735
+ */
515
736
  getTransitTimes: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetTransitTimes"), body),
516
- /** Get UPS landed cost quote (international). */
737
+ /**
738
+ * Get UPS landed cost quote (international).
739
+ *
740
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
741
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
742
+ * cover this.
743
+ */
517
744
  getLandedCost: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetLandedCostQuote"), body),
518
- /** Search UPS locations. */
745
+ /**
746
+ * Search UPS locations.
747
+ *
748
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
749
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
750
+ * cover this.
751
+ */
519
752
  searchLocations: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsSearchLocations"), body),
520
- /** Upload paperless trade document. */
753
+ /**
754
+ * Upload paperless trade document.
755
+ *
756
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
757
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
758
+ * cover this.
759
+ */
521
760
  uploadDocument: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsUploadPaperlessDocument"), body),
522
- /** Create UPS freight shipment. */
761
+ /**
762
+ * Create UPS freight shipment.
763
+ *
764
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
765
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
766
+ * cover this.
767
+ */
523
768
  createFreightShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsCreateFreightShipment"), body),
524
- /** Get UPS freight rate. */
769
+ /**
770
+ * Get UPS freight rate.
771
+ *
772
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
773
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
774
+ * cover this.
775
+ */
525
776
  getFreightRate: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetFreightRate"), body)
526
777
  };
527
778
  // -----------------------------------------------------------------------
528
779
  // FedEx (V3 endpoints)
529
780
  // -----------------------------------------------------------------------
530
781
  fedex = {
531
- /** Validate a domestic address via FedEx. */
782
+ /**
783
+ * Validate a domestic address via FedEx.
784
+ *
785
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
786
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
787
+ * cover this.
788
+ */
532
789
  validateAddress: (body) => this.http.post(this.proxy("api/v3/AddressValidation/postFedExValidateAndCorrectDomesticAddress"), body),
533
- /** Validate a postal code. */
790
+ /**
791
+ * Validate a postal code.
792
+ *
793
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
794
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
795
+ * cover this.
796
+ */
534
797
  validatePostalCode: (body) => this.http.post(this.proxy("api/v3/AddressValidation/postFedExValidatePostalCode"), body),
535
- /** Get FedEx rate and transit times. */
798
+ /**
799
+ * Get FedEx rate and transit times.
800
+ *
801
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
802
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
803
+ * cover this.
804
+ */
536
805
  getRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postRetrieveFedExRateAndTransitTimesAsync"), body),
537
- /** Create a FedEx shipment. */
538
- createShipment: (body) => this.http.post(this.proxy("api/v3/Shipping/postFedExCreateNewShipment"), body),
539
- /** Cancel a FedEx shipment. */
806
+ /**
807
+ * Cancel a FedEx shipment.
808
+ *
809
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
810
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
811
+ * cover this.
812
+ */
540
813
  cancelShipment: (body) => this.http.put(this.proxy("api/v3/Shipping/putFedExCancelShipment"), body),
541
- /** Validate a shipment (dry run). */
814
+ /**
815
+ * Validate a shipment (dry run).
816
+ *
817
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
818
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
819
+ * cover this.
820
+ */
542
821
  validateShipment: (body) => this.http.post(this.proxy("api/v3/Shipping/postFedExValidateShipment"), body),
543
- /** Create a return shipment. */
544
- createReturnShipment: (body) => this.http.post(this.proxy("api/v3/Shipping/postFedExCreateNewReturnShipment"), body),
545
- /** Track by tracking number. */
822
+ /**
823
+ * Track by tracking number.
824
+ *
825
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
826
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
827
+ * cover this.
828
+ */
546
829
  track: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRetrieveTrackingInfoByTrackingNumber"), body),
547
- /** Track multi-piece shipment. */
830
+ /**
831
+ * Track multi-piece shipment.
832
+ *
833
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
834
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
835
+ * cover this.
836
+ */
548
837
  trackMultiPiece: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRetrieveTrackingInfoForMultiPieceShipment"), body),
549
- /** Register for tracking notifications. */
838
+ /**
839
+ * Register for tracking notifications.
840
+ *
841
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
842
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
843
+ * cover this.
844
+ */
550
845
  registerTrackingNotification: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRegisterForTrackingNotification"), body),
551
- /** Create a carrier pickup. */
846
+ /**
847
+ * Create a carrier pickup.
848
+ *
849
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
850
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
851
+ * cover this.
852
+ */
552
853
  createPickup: (body) => this.http.post(this.proxy("api/v3/CarrierPickup/postFedExCreateCarrierPickupRequest"), body),
553
- /** Cancel a pickup. */
854
+ /**
855
+ * Cancel a pickup.
856
+ *
857
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
858
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
859
+ * cover this.
860
+ */
554
861
  cancelPickup: (body) => this.http.put(this.proxy("api/v3/CarrierPickup/putFedExCancelCarrierPickupRequest"), body),
555
- /** Search valid locations. */
862
+ /**
863
+ * Search valid locations.
864
+ *
865
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
866
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
867
+ * cover this.
868
+ */
556
869
  searchLocations: (body) => this.http.post(this.proxy("api/v3/LocationSearch/postFedExSearchValidLocations"), body),
557
- /** Get service standards and transit times. */
870
+ /**
871
+ * Get service standards and transit times.
872
+ *
873
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
874
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
875
+ * cover this.
876
+ */
558
877
  getServiceStandards: (body) => this.http.post(this.proxy("api/v3/ServiceStandards/postFedExRetrieveServicesAndTransitTimes"), body),
559
- /** Get freight rate quote. */
878
+ /**
879
+ * Get freight rate quote.
880
+ *
881
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
882
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
883
+ * cover this.
884
+ */
560
885
  getFreightRate: (body) => this.http.post(this.proxy("api/v3/Freight/postFedExGetFreightRateQuote"), body),
561
- /** Create freight shipment. */
886
+ /**
887
+ * Create freight shipment.
888
+ *
889
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
890
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
891
+ * cover this.
892
+ */
562
893
  createFreightShipment: (body) => this.http.post(this.proxy("api/v3/Freight/postFedExCreateFreightShipment"), body),
563
- /** Ground close with documents. */
894
+ /**
895
+ * Ground close with documents.
896
+ *
897
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
898
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
899
+ * cover this.
900
+ */
564
901
  groundClose: (body) => this.http.post(this.proxy("api/v3/GroundClose/postFedExCloseWithDocuments"), body),
565
- /** Upload trade documents. */
902
+ /**
903
+ * Upload trade documents.
904
+ *
905
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
906
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
907
+ * cover this.
908
+ */
566
909
  uploadTradeDocuments: (body) => this.http.post(this.proxy("api/v3/Trade/postFedExUploadTradeDocuments"), body),
567
910
  // --- Open Ship (multi-package) ---
568
- /** Create an open shipment. */
911
+ /**
912
+ * Create an open shipment.
913
+ *
914
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
915
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
916
+ * cover this.
917
+ */
569
918
  createOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExCreateOpenShipment"), body),
570
- /** Add packages to an open shipment. */
919
+ /**
920
+ * Add packages to an open shipment.
921
+ *
922
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
923
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
924
+ * cover this.
925
+ */
571
926
  addPackagesToOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExAddPackagesToOpenShipment"), body),
572
- /** Confirm and finalize an open shipment. */
927
+ /**
928
+ * Confirm and finalize an open shipment.
929
+ *
930
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
931
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
932
+ * cover this.
933
+ */
573
934
  confirmOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExConfirmOpenShipment"), body)
574
935
  };
575
936
  // -----------------------------------------------------------------------
@@ -580,27 +941,59 @@ var CarriersResource = class {
580
941
  validateAddress: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlValidateAddress"), params),
581
942
  /** Get DHL shipping rates. */
582
943
  getRates: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlRates"), params),
583
- /** Get multi-piece rates. */
944
+ /**
945
+ * Get multi-piece rates.
946
+ *
947
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
948
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
949
+ * cover this.
950
+ */
584
951
  getMultiPieceRates: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlMultiPieceRates"), body),
585
952
  /** Get DHL products/services. */
586
953
  getProducts: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlProducts"), params),
587
- /** Create a DHL shipment (label). */
588
- createShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCreateShipment"), body),
589
954
  /** Track a DHL shipment. */
590
955
  track: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlTrackSingleShipment"), params),
591
956
  /** Track multiple DHL shipments. */
592
957
  trackMultiple: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlTrackMultipleShipments"), params),
593
- /** Create a DHL pickup. */
958
+ /**
959
+ * Create a DHL pickup.
960
+ *
961
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
962
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
963
+ * cover this.
964
+ */
594
965
  createPickup: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCreatePickup"), body),
595
- /** Update a DHL pickup. */
596
- updatePickup: (body) => this.http.patch(this.proxy("api/v2/ShippingLabel/patchDhlUpdatePickup"), body),
597
- /** Cancel a DHL pickup. */
966
+ /**
967
+ * Cancel a DHL pickup.
968
+ *
969
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
970
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
971
+ * cover this.
972
+ */
598
973
  cancelPickup: () => this.http.delete(this.proxy("api/v2/ShippingLabel/deleteDhlPickup")),
599
- /** Calculate landed cost (duties/taxes). */
974
+ /**
975
+ * Calculate landed cost (duties/taxes).
976
+ *
977
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
978
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
979
+ * cover this.
980
+ */
600
981
  calculateLandedCost: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCalculateLandedCost"), body),
601
- /** Screen a shipment for compliance. */
982
+ /**
983
+ * Screen a shipment for compliance.
984
+ *
985
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
986
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
987
+ * cover this.
988
+ */
602
989
  screenShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlScreenShipment"), body),
603
- /** Upload an invoice. */
990
+ /**
991
+ * Upload an invoice.
992
+ *
993
+ * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
994
+ * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
995
+ * cover this.
996
+ */
604
997
  uploadInvoice: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlUploadInvoice"), body),
605
998
  /** Get electronic proof of delivery. */
606
999
  getProofOfDelivery: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlElectronicProofOfDelivery"), params),
@@ -626,17 +1019,21 @@ var WebhooksResource = class {
626
1019
  async list() {
627
1020
  return this.http.get(this.wsPath(""));
628
1021
  }
629
- /** Get a webhook subscription by ID. */
630
- async get(webhookId) {
631
- return this.http.get(this.wsPath(webhookId));
632
- }
633
- /** Create a webhook subscription. */
1022
+ /**
1023
+ * Create a webhook subscription. `events` is sent as the Gateway's comma-separated `eventTypes`;
1024
+ * omit it to receive every event. The result's `data.secret` is the signing secret, returned only here.
1025
+ * @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
1026
+ */
634
1027
  async create(request) {
635
- return this.http.post(this.wsPath(""), request);
1028
+ const body = await this.http.post(this.wsPath(""), toWireRequest(request));
1029
+ return toEnvelope(body);
636
1030
  }
637
- /** Update a webhook subscription. */
1031
+ /**
1032
+ * Update a webhook subscription. `events`, when given, replaces the subscribed events.
1033
+ * @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
1034
+ */
638
1035
  async update(webhookId, data) {
639
- return this.http.put(this.wsPath(webhookId), data);
1036
+ return this.http.put(this.wsPath(webhookId), toWireRequest(data));
640
1037
  }
641
1038
  /** Delete a webhook subscription. */
642
1039
  async delete(webhookId) {
@@ -650,23 +1047,80 @@ var WebhooksResource = class {
650
1047
  async listDeliveryLogs(webhookId) {
651
1048
  return this.http.get(this.wsPath(`${webhookId}/deliveries`));
652
1049
  }
1050
+ /** Send a test event to a webhook's endpoint. */
1051
+ async test(webhookId) {
1052
+ return this.http.post(this.wsPath(`${webhookId}/test`));
1053
+ }
653
1054
  /**
654
- * Verify a webhook signature from an incoming request.
655
- * Use this in your webhook handler to validate authenticity.
1055
+ * Verify that an incoming request is a genuine FlexOps webhook delivery.
1056
+ *
1057
+ * FlexOps signs `{X-FlexOps-Timestamp}.{raw body}` with HMAC-SHA256, keyed with the
1058
+ * subscription secret (the whole `whsec_...` string), and sends
1059
+ * `X-FlexOps-Signature: sha256=<lowercase hex>`.
1060
+ *
1061
+ * @param payload The raw request body exactly as received (string or bytes). Do not pass
1062
+ * re-serialized JSON: `JSON.stringify(req.body)` will not reproduce the signed bytes.
1063
+ * @param signature The `X-FlexOps-Signature` header. `sha256=<hex>` and bare `<hex>` are accepted.
1064
+ * @param secret The subscription signing secret.
1065
+ * @param timestamp The `X-FlexOps-Timestamp` header (Unix seconds).
1066
+ * @param options `toleranceSeconds` (default 300) bounds how far the timestamp may be from now
1067
+ * in either direction; `now` (Unix seconds) overrides the clock, for tests.
1068
+ * @returns `true` only when the signature matches and the timestamp is within tolerance.
1069
+ * @throws TypeError when `secret` is empty or `payload` is not a string or bytes.
656
1070
  */
657
- static verifySignature(payload, signature, secret) {
658
- try {
659
- const crypto = require("crypto");
660
- const expected = crypto.createHmac("sha256", secret).update(payload, "utf-8").digest("hex");
661
- return crypto.timingSafeEqual(
662
- Buffer.from(signature, "hex"),
663
- Buffer.from(expected, "hex")
664
- );
665
- } catch {
666
- return false;
1071
+ static verifySignature(payload, signature, secret, timestamp, options = {}) {
1072
+ if (typeof secret !== "string" || secret.length === 0) {
1073
+ throw new TypeError("A webhook signing secret is required.");
1074
+ }
1075
+ if (typeof payload !== "string" && !(payload instanceof Uint8Array)) {
1076
+ throw new TypeError("payload must be the raw request body as a string or bytes.");
667
1077
  }
1078
+ const toleranceSeconds = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
1079
+ if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {
1080
+ throw new TypeError("toleranceSeconds must be a non-negative number.");
1081
+ }
1082
+ if (typeof signature !== "string" || typeof timestamp !== "string") return false;
1083
+ const ts = timestamp.trim();
1084
+ if (!/^[0-9]+$/.test(ts)) return false;
1085
+ const now = options.now ?? Date.now() / 1e3;
1086
+ if (!(Math.abs(now - Number(ts)) <= toleranceSeconds)) return false;
1087
+ let hex = signature.trim();
1088
+ if (hex.slice(0, SIGNATURE_PREFIX.length).toLowerCase() === SIGNATURE_PREFIX) {
1089
+ hex = hex.slice(SIGNATURE_PREFIX.length);
1090
+ }
1091
+ hex = hex.toLowerCase();
1092
+ if (!/^[0-9a-f]{64}$/.test(hex)) return false;
1093
+ const crypto = loadNodeCrypto("Webhook signature verification");
1094
+ const expected = crypto.createHmac("sha256", secret).update(`${ts}.`, "utf8").update(payload).digest();
1095
+ return crypto.timingSafeEqual(Buffer.from(hex, "hex"), expected);
668
1096
  }
669
1097
  };
1098
+ var DEFAULT_TOLERANCE_SECONDS = 300;
1099
+ var SIGNATURE_PREFIX = "sha256=";
1100
+ var KNOWN_EVENTS = new Set(Object.values(WebhookEventType));
1101
+ function toWireRequest(request) {
1102
+ const { events, ...rest } = request;
1103
+ if (events === void 0) return rest;
1104
+ if (!Array.isArray(events) || events.length === 0) {
1105
+ throw new FlexOpsError("events must name at least one event; omit it to receive every event.", 400, "UnknownWebhookEvent");
1106
+ }
1107
+ const unknown = events.filter((name) => !KNOWN_EVENTS.has(name));
1108
+ if (unknown.length > 0) {
1109
+ throw new FlexOpsError(
1110
+ `Unknown webhook event: ${unknown.join(", ")}. FlexOps sends ${[...KNOWN_EVENTS].join(", ")}.`,
1111
+ 400,
1112
+ "UnknownWebhookEvent"
1113
+ );
1114
+ }
1115
+ return { ...rest, eventTypes: [...new Set(events)].join(",") };
1116
+ }
1117
+ function toEnvelope(body) {
1118
+ if (isObject(body) && isObject(body.data)) return body;
1119
+ return { success: true, data: body };
1120
+ }
1121
+ function isObject(value) {
1122
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1123
+ }
670
1124
 
671
1125
  // src/resources/wallet.ts
672
1126
  var WalletResource = class {
@@ -674,29 +1128,11 @@ var WalletResource = class {
674
1128
  this.http = http;
675
1129
  this.getWorkspaceId = getWorkspaceId;
676
1130
  }
677
- wsPath(suffix) {
1131
+ /** Get the configured workspace's wallet balance. */
1132
+ async getBalance() {
678
1133
  const id = this.getWorkspaceId();
679
1134
  if (!id) throw new Error("workspaceId is required.");
680
- return `/api/workspaces/${id}/wallet/${suffix}`;
681
- }
682
- /** Get the current wallet balance. */
683
- async getBalance() {
684
- return this.http.get(this.wsPath("balance"));
685
- }
686
- /** Add funds to the wallet. */
687
- async addFunds(amount) {
688
- return this.http.post(this.wsPath("add-funds"), { amount });
689
- }
690
- /** List wallet transactions. */
691
- async listTransactions(query) {
692
- return this.http.get(
693
- this.wsPath("transactions"),
694
- query
695
- );
696
- }
697
- /** Configure auto-reload settings. */
698
- async configureAutoReload(config) {
699
- return this.http.put(this.wsPath("auto-reload"), config);
1135
+ return this.http.request("GET", "/api/wallet/my-balance", { headers: { "X-Workspace-Id": id } });
700
1136
  }
701
1137
  };
702
1138
 
@@ -719,17 +1155,27 @@ var InsuranceResource = class {
719
1155
  async getQuote(request) {
720
1156
  return this.http.post(this.wsPath("quote"), request);
721
1157
  }
722
- /** Purchase insurance for a shipment. */
723
- async purchase(request) {
724
- return this.http.post(this.wsPath("purchase"), request);
1158
+ /**
1159
+ * Purchase insurance for a shipment. The premium is charged to the workspace wallet. A shipment
1160
+ * that already has a policy in force is refused with 409 `ALREADY_EXISTS`.
1161
+ *
1162
+ * Pass an `idempotencyKey` you store with the purchase to make your own retry safe: after an error or
1163
+ * a timeout, retry with the same key and the Gateway returns the first result instead of buying again.
1164
+ * Without one, the SDK's own retries still share a key, but a new call gets a new key.
1165
+ */
1166
+ async purchase(request, idempotencyKey) {
1167
+ return this.http.request("POST", this.wsPath("policies"), {
1168
+ body: request,
1169
+ headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
1170
+ });
725
1171
  }
726
- /** Void an insurance policy. */
1172
+ /** Void (cancel) an insurance policy. */
727
1173
  async void(policyId) {
728
1174
  return this.http.delete(this.wsPath(`policies/${policyId}`));
729
1175
  }
730
- /** File an insurance claim. */
731
- async fileClaim(policyId, claim) {
732
- return this.http.post(this.wsPath(`policies/${policyId}/claims`), claim);
1176
+ /** File a claim against a policy. */
1177
+ async fileClaim(claim) {
1178
+ return this.http.post(this.wsPath("claims"), claim);
733
1179
  }
734
1180
  };
735
1181
 
@@ -742,9 +1188,9 @@ var ReturnsResource = class {
742
1188
  wsPath(suffix) {
743
1189
  const id = this.getWorkspaceId();
744
1190
  if (!id) throw new Error("workspaceId is required.");
745
- return `/api/workspaces/${id}/returns/${suffix}`;
1191
+ return `/api/workspaces/${id}/returns${suffix ? `/${suffix}` : ""}`;
746
1192
  }
747
- /** List all return authorizations. */
1193
+ /** List return authorizations, optionally created between `startDate` and `endDate` (ISO 8601). */
748
1194
  async list(query) {
749
1195
  return this.http.get(
750
1196
  this.wsPath(""),
@@ -755,62 +1201,24 @@ var ReturnsResource = class {
755
1201
  async get(returnId) {
756
1202
  return this.http.get(this.wsPath(returnId));
757
1203
  }
758
- /** Create a return authorization (RMA). */
1204
+ /** Create a return authorization (RMA) for an order. */
759
1205
  async create(request) {
760
- return this.http.post(this.wsPath(""), request);
761
- }
762
- /** Approve a return authorization. */
763
- async approve(returnId) {
764
- return this.http.post(this.wsPath(`${returnId}/approve`));
765
- }
766
- /** Reject a return authorization. */
767
- async reject(returnId, reason) {
768
- return this.http.post(this.wsPath(`${returnId}/reject`), { reason });
769
- }
770
- /** Cancel a return authorization. */
771
- async cancel(returnId) {
772
- return this.http.post(this.wsPath(`${returnId}/cancel`));
773
- }
774
- /** Generate a return label for an approved RMA. */
775
- async generateLabel(returnId) {
776
- return this.http.post(this.wsPath(`${returnId}/label`));
777
- }
778
- /** Mark items as received. */
779
- async markReceived(returnId, items) {
780
- return this.http.post(this.wsPath(`${returnId}/receive`), { items });
781
- }
782
- /** Process refund for a return. */
783
- async processRefund(returnId) {
784
- return this.http.post(this.wsPath(`${returnId}/refund`));
1206
+ return this.http.post(this.wsPath("rma"), request);
785
1207
  }
786
- };
787
-
788
- // src/resources/api-keys.ts
789
- var ApiKeysResource = class {
790
- constructor(http, getWorkspaceId) {
791
- this.http = http;
792
- this.getWorkspaceId = getWorkspaceId;
793
- }
794
- wsPath(suffix) {
795
- const id = this.getWorkspaceId();
796
- if (!id) throw new Error("workspaceId is required.");
797
- return `/api/workspaces/${id}/api-keys${suffix ? `/${suffix}` : ""}`;
798
- }
799
- /** List all API keys for the workspace. */
800
- async list() {
801
- return this.http.get(this.wsPath(""));
802
- }
803
- /** Create a new API key. The full key is only returned once. */
804
- async create(request) {
805
- return this.http.post(this.wsPath(""), request);
806
- }
807
- /** Revoke an API key. */
808
- async revoke(keyId) {
809
- return this.http.delete(this.wsPath(keyId));
1208
+ /**
1209
+ * Generate a return label for an approved RMA.
1210
+ *
1211
+ * The Gateway binds a required request body, so one is always sent (`{}` when `request` is
1212
+ * omitted). Pass `weightOz`, `lengthIn`, `widthIn` and `heightIn`: a workspace with no default
1213
+ * shipping preset has nothing else to take the package from and the call fails with a 400 that
1214
+ * names the missing fields.
1215
+ */
1216
+ async generateLabel(rmaNumber, request = {}) {
1217
+ return this.http.post(this.wsPath(`${rmaNumber}/label`), request);
810
1218
  }
811
- /** Rotate an API key (revoke + create new). */
812
- async rotate(keyId) {
813
- return this.http.post(this.wsPath(`${keyId}/rotate`));
1219
+ /** Record the inspected items of a returned package at a warehouse. */
1220
+ async markReceived(rmaId, request) {
1221
+ return this.http.post(this.wsPath(`${rmaId}/receive`), request);
814
1222
  }
815
1223
  };
816
1224
 
@@ -892,10 +1300,6 @@ var OrdersResource = class {
892
1300
  path(endpoint) {
893
1301
  return `/api/ApiProxy/api/v1/Order/${endpoint}`;
894
1302
  }
895
- /** Create a new order. */
896
- async create(order) {
897
- return this.http.post(this.path("postNewOrder"), order);
898
- }
899
1303
  /** Get new orders awaiting processing. */
900
1304
  async getNewOrders(params) {
901
1305
  return this.http.get(this.path("getNewOrderList"), params);
@@ -916,10 +1320,6 @@ var OrdersResource = class {
916
1320
  async getStatus(orderNumber) {
917
1321
  return this.http.get(this.path("getIndividualOrderStatusByOrderNumber"), { orderNumber });
918
1322
  }
919
- /** Cancel an order. */
920
- async cancel(orderNumber) {
921
- return this.http.post(this.path("cancelOrderByOrderNumber"), { orderNumber });
922
- }
923
1323
  /** Get all items for an order. */
924
1324
  async getItems(orderNumber) {
925
1325
  return this.http.get(this.path("getAllOrderItemsByOrderNumber"), { orderNumber });
@@ -947,10 +1347,6 @@ var InventoryResource = class {
947
1347
  constructor(http) {
948
1348
  this.http = http;
949
1349
  }
950
- /** Post a new ASN (Advance Shipment Notice) receipt. */
951
- async postAsnReceipt(receipt) {
952
- return this.http.post("/api/ApiProxy/api/v1/Inventory/postNewAsnReceipt", receipt);
953
- }
954
1350
  /** Get a warehouse inventory snapshot. */
955
1351
  async getWarehouseSnapshot(params) {
956
1352
  return this.http.get("/api/ApiProxy/api/v1/Inventory/getWarehouseInventorySnapshot", params);
@@ -963,10 +1359,6 @@ var InventoryResource = class {
963
1359
  async getPartNumbers(params) {
964
1360
  return this.http.get("/api/ApiProxy/api/v1/Inventory/getPartNumberList", params);
965
1361
  }
966
- /** Update customer inventory (V2). */
967
- async updateInventory(data) {
968
- return this.http.post("/api/ApiProxy/api/v2/Inventory/postCustomerInventoryUpdate", data);
969
- }
970
1362
  };
971
1363
 
972
1364
  // src/resources/pickups.ts
@@ -986,11 +1378,11 @@ var PickupsResource = class {
986
1378
  }
987
1379
  /** List scheduled pickups. */
988
1380
  async list() {
989
- return this.http.get(this.wsPath(""));
1381
+ return this.http.get(this.wsPath("scheduled"));
990
1382
  }
991
- /** Get pickup details. */
992
- async get(pickupId) {
993
- return this.http.get(this.wsPath(pickupId));
1383
+ /** Get pickup details. The carrier defaults to `usps` on the Gateway. */
1384
+ async get(pickupId, carrierCode) {
1385
+ return this.http.get(this.wsPath(pickupId), { carrierCode });
994
1386
  }
995
1387
  /** Cancel a scheduled pickup. */
996
1388
  async cancel(pickupId) {
@@ -1046,7 +1438,7 @@ var RulesResource = class {
1046
1438
  async create(rule) {
1047
1439
  return this.http.post(this.wsPath(""), rule);
1048
1440
  }
1049
- /** Update a shipping rule. */
1441
+ /** Replace a shipping rule. */
1050
1442
  async update(ruleId, rule) {
1051
1443
  return this.http.put(this.wsPath(ruleId), rule);
1052
1444
  }
@@ -1054,62 +1446,66 @@ var RulesResource = class {
1054
1446
  async delete(ruleId) {
1055
1447
  return this.http.delete(this.wsPath(ruleId));
1056
1448
  }
1057
- /** Reorder rules (set priority). */
1449
+ /** Reorder rules: each listed rule gets its position in `ruleIds` as its priority (0 first). */
1058
1450
  async reorder(ruleIds) {
1059
- return this.http.put(this.wsPath("reorder"), { ruleIds });
1451
+ return this.http.post(this.wsPath("reorder"), {
1452
+ rules: ruleIds.map((ruleId, priority) => ({ ruleId, priority }))
1453
+ });
1454
+ }
1455
+ /** Dry-run the workspace's rules against a sample shipment, without changing anything. */
1456
+ async test(request) {
1457
+ return this.http.post(this.wsPath("test"), { tags: [], ...request });
1060
1458
  }
1061
1459
  };
1062
1460
 
1063
- // src/resources/offsets.ts
1064
- var OffsetResource = class {
1461
+ // src/resources/carbon-offsets.ts
1462
+ var CarbonOffsetsResource = class {
1065
1463
  constructor(http, getWorkspaceId) {
1066
1464
  this.http = http;
1067
1465
  this.getWorkspaceId = getWorkspaceId;
1068
1466
  }
1069
- wsPath(suffix) {
1467
+ wsPath(suffix = "") {
1070
1468
  const id = this.getWorkspaceId();
1071
1469
  if (!id) throw new Error("workspaceId is required.");
1072
- return `/api/workspaces/${id}/${suffix}`;
1470
+ return `/api/workspaces/${id}/carbon-offsets${suffix ? `/${suffix}` : ""}`;
1073
1471
  }
1074
- /** Purchase a certified carbon offset for a label. */
1075
- async offset(labelId) {
1076
- return this.http.post(this.wsPath(`shipping/labels/${labelId}/offset`));
1077
- }
1078
- /** Get the estimated CO2 emissions for a label before purchasing an offset. */
1079
- async getEmissions(labelId) {
1080
- return this.http.get(this.wsPath(`shipping/labels/${labelId}/emissions`));
1472
+ /** Quote an offset for a shipment without buying it. */
1473
+ async quote(request) {
1474
+ return this.http.post(this.wsPath("quote"), request);
1081
1475
  }
1082
- /** Purchase carbon offsets for multiple labels in a single request. */
1083
- async batchOffset(labelIds) {
1084
- return this.http.post(this.wsPath("shipping/labels/offset/batch"), { labelIds });
1476
+ /**
1477
+ * Buy an offset for a shipment. The cost is charged to the workspace wallet and refunded if the
1478
+ * offset provider fails.
1479
+ *
1480
+ * Pass an `idempotencyKey` you store with the purchase to make your own retry safe: after an error or
1481
+ * a timeout, retry with the same key and the Gateway returns the first result instead of buying again.
1482
+ * Without one, the SDK's own retries still share a key, but a new call gets a new key.
1483
+ */
1484
+ async purchase(request, idempotencyKey) {
1485
+ return this.http.request("POST", this.wsPath("purchase"), {
1486
+ body: request,
1487
+ headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
1488
+ });
1085
1489
  }
1086
- };
1087
-
1088
- // src/resources/hs-codes.ts
1089
- var HsCodesResource = class {
1090
- constructor(http, getWorkspaceId) {
1091
- this.http = http;
1092
- this.getWorkspaceId = getWorkspaceId;
1490
+ /** List the workspace's offsets, newest first. */
1491
+ async list(query) {
1492
+ return this.http.get(this.wsPath(), query);
1093
1493
  }
1094
- wsPath(suffix) {
1095
- const id = this.getWorkspaceId();
1096
- if (!id) throw new Error("workspaceId is required.");
1097
- return `/api/workspaces/${id}/${suffix}`;
1494
+ /** Get one offset. */
1495
+ async get(offsetId) {
1496
+ return this.http.get(this.wsPath(offsetId));
1098
1497
  }
1099
- /** Search for HS codes by product description. Requires Enterprise plan. */
1100
- async search(query, options) {
1101
- return this.http.get(this.wsPath("shipping/hs-codes/search"), {
1102
- query,
1103
- ...options
1104
- });
1498
+ /** Totals across the workspace's offsets. */
1499
+ async getSummary() {
1500
+ return this.http.get(this.wsPath("summary"));
1105
1501
  }
1106
- /** Look up a specific HS code by its tariff number. Requires Enterprise plan. */
1107
- async lookup(code) {
1108
- return this.http.get(this.wsPath(`shipping/hs-codes/${code}`));
1502
+ /** Get the automatic-offset setting. */
1503
+ async getSettings() {
1504
+ return this.http.get(this.wsPath("settings"));
1109
1505
  }
1110
- /** Estimate the total landed cost (duty + tax + shipping) for a shipment. Requires Enterprise plan. */
1111
- async estimateLandedCost(request) {
1112
- return this.http.post(this.wsPath("shipping/landed-cost"), request);
1506
+ /** Turn automatic offsets on or off. */
1507
+ async updateSettings(settings) {
1508
+ return this.http.put(this.wsPath("settings"), settings);
1113
1509
  }
1114
1510
  };
1115
1511
 
@@ -1119,115 +1515,136 @@ var RecurringShipmentsResource = class {
1119
1515
  this.http = http;
1120
1516
  this.getWorkspaceId = getWorkspaceId;
1121
1517
  }
1122
- wsPath(suffix) {
1518
+ wsPath(suffix = "") {
1123
1519
  const id = this.getWorkspaceId();
1124
1520
  if (!id) throw new Error("workspaceId is required.");
1125
- return `/api/workspaces/${id}/recurring-shipments/${suffix}`;
1521
+ return `/api/workspaces/${id}/recurring-shipments${suffix ? `/${suffix}` : ""}`;
1126
1522
  }
1127
- /** List all recurring shipment schedules. */
1128
- async list(query) {
1129
- return this.http.get(
1130
- this.wsPath(""),
1131
- query
1132
- );
1523
+ /** List the workspace's recurring shipments. */
1524
+ async list() {
1525
+ return this.http.get(this.wsPath());
1133
1526
  }
1134
- /** Get a recurring shipment schedule by ID. */
1527
+ /** Get one recurring shipment. */
1135
1528
  async get(id) {
1136
1529
  return this.http.get(this.wsPath(id));
1137
1530
  }
1138
- /** Create a recurring shipment schedule. */
1531
+ /** Create a recurring shipment. The first run is at `firstRunUtc`. */
1139
1532
  async create(request) {
1140
- return this.http.post(this.wsPath(""), request);
1533
+ return this.http.post(this.wsPath(), request);
1141
1534
  }
1142
- /** Update a recurring shipment schedule. */
1535
+ /** Change a recurring shipment. Fields left out stay as they are. */
1143
1536
  async update(id, request) {
1144
1537
  return this.http.put(this.wsPath(id), request);
1145
1538
  }
1146
- /** Delete a recurring shipment schedule. */
1539
+ /** Delete a recurring shipment. */
1147
1540
  async delete(id) {
1148
- return this.http.delete(this.wsPath(id));
1541
+ await this.http.delete(this.wsPath(id));
1149
1542
  }
1150
- /** Pause a recurring shipment (stops automatic execution without deleting). */
1543
+ /** Stop scheduled runs until `resume` is called. */
1151
1544
  async pause(id) {
1152
- return this.http.post(this.wsPath(`${id}/pause`));
1545
+ await this.http.post(this.wsPath(`${id}/pause`));
1153
1546
  }
1154
- /** Resume a paused recurring shipment. */
1547
+ /** Restart scheduled runs. */
1155
1548
  async resume(id) {
1156
- return this.http.post(this.wsPath(`${id}/resume`));
1549
+ await this.http.post(this.wsPath(`${id}/resume`));
1157
1550
  }
1158
- /** Trigger an immediate execution outside the normal schedule. */
1159
- async trigger(id) {
1160
- return this.http.post(this.wsPath(`${id}/trigger`));
1551
+ /**
1552
+ * Run a recurring shipment now, which creates an order. Pass your own `idempotencyKey` to make a
1553
+ * retry from your side safe too; the SDK's own retries always reuse one key.
1554
+ */
1555
+ async trigger(id, idempotencyKey) {
1556
+ await this.http.request("POST", this.wsPath(`${id}/trigger`), {
1557
+ headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
1558
+ });
1161
1559
  }
1162
1560
  };
1163
1561
 
1164
- // src/resources/email-templates.ts
1165
- var EmailTemplatesResource = class {
1562
+ // src/resources/report-schedules.ts
1563
+ var ReportSchedulesResource = class {
1166
1564
  constructor(http, getWorkspaceId) {
1167
1565
  this.http = http;
1168
1566
  this.getWorkspaceId = getWorkspaceId;
1169
1567
  }
1170
- wsPath(suffix) {
1568
+ wsPath(suffix = "") {
1171
1569
  const id = this.getWorkspaceId();
1172
1570
  if (!id) throw new Error("workspaceId is required.");
1173
- return `/api/workspaces/${id}/shipment-email-templates/${suffix}`;
1571
+ return `/api/workspaces/${id}/report-schedules${suffix ? `/${suffix}` : ""}`;
1174
1572
  }
1175
- /** List all email templates. */
1573
+ /** List the workspace's report schedules. */
1176
1574
  async list() {
1177
- return this.http.get(this.wsPath(""));
1575
+ return this.http.get(this.wsPath());
1178
1576
  }
1179
- /** Get an email template by ID. */
1577
+ /** Get one report schedule. */
1180
1578
  async get(id) {
1181
1579
  return this.http.get(this.wsPath(id));
1182
1580
  }
1183
- /** Create an email template. */
1581
+ /** Create a report schedule. */
1184
1582
  async create(request) {
1185
- return this.http.post(this.wsPath(""), request);
1583
+ return this.http.post(this.wsPath(), request);
1186
1584
  }
1187
- /** Update an email template. */
1585
+ /** Change a report schedule. Fields left out stay as they are. */
1188
1586
  async update(id, request) {
1189
1587
  return this.http.put(this.wsPath(id), request);
1190
1588
  }
1191
- /** Delete an email template. */
1589
+ /** Delete a report schedule. */
1192
1590
  async delete(id) {
1193
- return this.http.delete(this.wsPath(id));
1591
+ await this.http.delete(this.wsPath(id));
1194
1592
  }
1195
- /** Preview a rendered email template with optional sample data. */
1196
- async preview(id, context) {
1197
- return this.http.post(this.wsPath(`${id}/preview`), context ?? {});
1593
+ /** Turn a schedule on or off (flips `isEnabled`). */
1594
+ async toggle(id) {
1595
+ return this.http.post(this.wsPath(`${id}/toggle`));
1198
1596
  }
1199
1597
  };
1200
1598
 
1201
- // src/resources/reports.ts
1202
- var ReportsResource = class {
1599
+ // src/resources/email-templates.ts
1600
+ var EmailTemplatesResource = class {
1203
1601
  constructor(http, getWorkspaceId) {
1204
1602
  this.http = http;
1205
1603
  this.getWorkspaceId = getWorkspaceId;
1206
1604
  }
1207
- wsPath(suffix) {
1605
+ wsPath(suffix = "") {
1208
1606
  const id = this.getWorkspaceId();
1209
1607
  if (!id) throw new Error("workspaceId is required.");
1210
- return `/api/workspaces/${id}/report-schedules/${suffix}`;
1608
+ return `/api/workspaces/${id}/email-templates${suffix ? `/${suffix}` : ""}`;
1211
1609
  }
1212
- /** List all scheduled report configurations. */
1610
+ /** List the workspace's templates. */
1213
1611
  async list() {
1214
- return this.http.get(this.wsPath(""));
1612
+ return this.http.get(this.wsPath());
1215
1613
  }
1216
- /** Get a report schedule by ID. */
1217
- async get(id) {
1218
- return this.http.get(this.wsPath(id));
1614
+ /** Get one template. */
1615
+ async get(templateId) {
1616
+ return this.http.get(this.wsPath(templateId));
1219
1617
  }
1220
- /** Create a scheduled report. */
1221
- async create(request) {
1222
- return this.http.post(this.wsPath(""), request);
1618
+ /** Create or replace the template for `request.eventType`. */
1619
+ async upsert(request) {
1620
+ return this.http.put(this.wsPath(), request);
1223
1621
  }
1224
- /** Update a scheduled report. */
1225
- async update(id, request) {
1226
- return this.http.put(this.wsPath(id), request);
1622
+ /** Delete a template; that event then uses the FlexOps default email. */
1623
+ async delete(templateId) {
1624
+ await this.http.delete(this.wsPath(templateId));
1227
1625
  }
1228
- /** Delete a scheduled report. */
1229
- async delete(id) {
1230
- return this.http.delete(this.wsPath(id));
1626
+ /** Render a subject and body with sample shipment data, without saving anything. */
1627
+ async preview(request) {
1628
+ return this.http.post(this.wsPath("preview"), request);
1629
+ }
1630
+ };
1631
+
1632
+ // src/resources/hs-codes.ts
1633
+ var HsCodesResource = class {
1634
+ constructor(http) {
1635
+ this.http = http;
1636
+ }
1637
+ /** Search for HS codes by product description. Requires Enterprise plan. */
1638
+ async search(query, options) {
1639
+ return this.http.get("/api/shipping/hs-codes/search", { query, ...options });
1640
+ }
1641
+ /** Look up a specific HS code by its tariff number. Requires Enterprise plan. */
1642
+ async lookup(code) {
1643
+ return this.http.get(`/api/shipping/hs-codes/${encodeURIComponent(code)}`);
1644
+ }
1645
+ /** Estimate the total landed cost (duty + tax + shipping) for a shipment. Requires Enterprise plan. */
1646
+ async estimateLandedCost(request) {
1647
+ return this.http.post("/api/shipping/landed-cost", request);
1231
1648
  }
1232
1649
  };
1233
1650
 
@@ -1244,18 +1661,17 @@ var FlexOps = class {
1244
1661
  wallet;
1245
1662
  insurance;
1246
1663
  returns;
1247
- apiKeys;
1248
1664
  analytics;
1249
1665
  orders;
1250
1666
  inventory;
1251
1667
  pickups;
1252
1668
  scanForms;
1253
1669
  rules;
1254
- offsets;
1255
- hsCodes;
1670
+ carbonOffsets;
1256
1671
  recurringShipments;
1672
+ reportSchedules;
1257
1673
  emailTemplates;
1258
- reports;
1674
+ hsCodes;
1259
1675
  constructor(config = {}) {
1260
1676
  this.http = new HttpClient(config);
1261
1677
  this._workspaceId = config.workspaceId;
@@ -1268,18 +1684,17 @@ var FlexOps = class {
1268
1684
  this.wallet = new WalletResource(this.http, getWsId);
1269
1685
  this.insurance = new InsuranceResource(this.http, getWsId);
1270
1686
  this.returns = new ReturnsResource(this.http, getWsId);
1271
- this.apiKeys = new ApiKeysResource(this.http, getWsId);
1272
1687
  this.analytics = new AnalyticsResource(this.http);
1273
1688
  this.orders = new OrdersResource(this.http);
1274
1689
  this.inventory = new InventoryResource(this.http);
1275
1690
  this.pickups = new PickupsResource(this.http, getWsId);
1276
1691
  this.scanForms = new ScanFormsResource(this.http, getWsId);
1277
1692
  this.rules = new RulesResource(this.http, getWsId);
1278
- this.offsets = new OffsetResource(this.http, getWsId);
1279
- this.hsCodes = new HsCodesResource(this.http, getWsId);
1693
+ this.carbonOffsets = new CarbonOffsetsResource(this.http, getWsId);
1280
1694
  this.recurringShipments = new RecurringShipmentsResource(this.http, getWsId);
1695
+ this.reportSchedules = new ReportSchedulesResource(this.http, getWsId);
1281
1696
  this.emailTemplates = new EmailTemplatesResource(this.http, getWsId);
1282
- this.reports = new ReportsResource(this.http, getWsId);
1697
+ this.hsCodes = new HsCodesResource(this.http);
1283
1698
  }
1284
1699
  /** Get or set the active workspace ID. */
1285
1700
  get workspaceId() {
@@ -1300,27 +1715,33 @@ var FlexOps = class {
1300
1715
  // Annotate the CommonJS export names for ESM import in node:
1301
1716
  0 && (module.exports = {
1302
1717
  AnalyticsResource,
1303
- ApiKeysResource,
1304
1718
  AuthResource,
1719
+ CarbonOffsetsResource,
1305
1720
  CarriersResource,
1306
1721
  EmailTemplatesResource,
1307
1722
  FlexOps,
1308
1723
  FlexOpsAuthError,
1309
1724
  FlexOpsError,
1310
1725
  FlexOpsRateLimitError,
1726
+ HazmatClassification,
1311
1727
  HsCodesResource,
1312
1728
  InsuranceResource,
1313
1729
  InventoryResource,
1314
- OffsetResource,
1315
1730
  OrdersResource,
1316
1731
  PickupsResource,
1732
+ RecurrenceInterval,
1317
1733
  RecurringShipmentsResource,
1318
- ReportsResource,
1734
+ ReportFormat,
1735
+ ReportFrequency,
1736
+ ReportSchedulesResource,
1319
1737
  ReturnsResource,
1320
1738
  RulesResource,
1321
1739
  ScanFormsResource,
1322
1740
  ShippingResource,
1741
+ TrackingEmailEvent,
1323
1742
  WalletResource,
1743
+ WebhookEventType,
1324
1744
  WebhooksResource,
1745
+ WorkspaceRole,
1325
1746
  WorkspacesResource
1326
1747
  });