@5ss/ai-tools 3.6.0 → 3.7.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.
|
@@ -2,30 +2,122 @@ import { t as ToolError } from "../../errors-DoSpNHvs.js";
|
|
|
2
2
|
import { n as defineModule, r as defineTool } from "../../define-ieoksEQ0.js";
|
|
3
3
|
import { n as requireAuth } from "../../provider-CgDAlg6K.js";
|
|
4
4
|
import { t as HttpService } from "../../http-service-BMBIryAL.js";
|
|
5
|
+
import { n as bytesToBase64, o as utf8ToBytes } from "../../bytes-BxpimpQx.js";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
//#region src/vendors/shipstation/contracts.ts
|
|
7
|
-
const shipstationAuthSchema = z.object({
|
|
8
|
+
const shipstationAuthSchema = z.object({
|
|
9
|
+
v2_api_key: z.string().min(1).describe("ShipStation V2 API key"),
|
|
10
|
+
v1_api_key: z.string().min(1).describe("ShipStation V1 API key"),
|
|
11
|
+
v1_api_secret: z.string().min(1).describe("ShipStation V1 API secret")
|
|
12
|
+
});
|
|
8
13
|
const shipstationPageSchema = z.int().min(1).optional().describe("Provider page number, starting at 1");
|
|
9
14
|
const shipstationPageSizeSchema = z.int().min(1).max(500).optional().describe("Records per page, from 1 to 500; defaults to 25");
|
|
15
|
+
const shipstationMoneySchema = z.looseObject({
|
|
16
|
+
currency: z.string().min(1),
|
|
17
|
+
amount: z.number().nonnegative()
|
|
18
|
+
});
|
|
19
|
+
const shipstationRefundDetailsRawSchema = z.looseObject({
|
|
20
|
+
refund_status: z.string().nullable().optional(),
|
|
21
|
+
request_date: z.string().nullable().optional(),
|
|
22
|
+
amount_paid: shipstationMoneySchema.nullable().optional(),
|
|
23
|
+
amount_requested: shipstationMoneySchema.nullable().optional()
|
|
24
|
+
});
|
|
10
25
|
const shipstationLabelRawSchema = z.looseObject({
|
|
11
26
|
label_id: z.string().min(1),
|
|
12
27
|
shipment_id: z.string().nullable().optional(),
|
|
28
|
+
external_shipment_id: z.string().nullable().optional(),
|
|
13
29
|
external_order_id: z.string().nullable().optional(),
|
|
30
|
+
carrier_id: z.string().nullable().optional(),
|
|
31
|
+
service_code: z.string().nullable().optional(),
|
|
14
32
|
tracking_number: z.string().nullable().optional(),
|
|
15
33
|
created_at: z.string().nullable().optional(),
|
|
16
34
|
modified_at: z.string().nullable().optional(),
|
|
17
35
|
ship_date: z.string().nullable().optional(),
|
|
36
|
+
shipment_cost: shipstationMoneySchema.nullable().optional(),
|
|
37
|
+
insurance_cost: shipstationMoneySchema.nullable().optional(),
|
|
38
|
+
voided: z.boolean().nullable().optional(),
|
|
18
39
|
voided_at: z.string().nullable().optional(),
|
|
40
|
+
refund_details: shipstationRefundDetailsRawSchema.nullable().optional(),
|
|
19
41
|
status: z.string().nullable().optional()
|
|
20
42
|
});
|
|
21
43
|
const shipstationShipmentRawSchema = z.looseObject({
|
|
22
44
|
shipment_id: z.string().min(1),
|
|
23
45
|
external_order_id: z.string().nullable().optional(),
|
|
24
46
|
shipment_number: z.string().nullable().optional(),
|
|
47
|
+
carrier_id: z.string().nullable().optional(),
|
|
48
|
+
service_code: z.string().nullable().optional(),
|
|
49
|
+
store_id: z.string().nullable().optional(),
|
|
25
50
|
created_at: z.string().nullable().optional(),
|
|
26
51
|
modified_at: z.string().nullable().optional(),
|
|
27
52
|
shipment_status: z.string().nullable().optional()
|
|
28
53
|
});
|
|
54
|
+
const shipstationFulfillmentRawSchema = z.looseObject({
|
|
55
|
+
fulfillment_id: z.string().min(1),
|
|
56
|
+
shipment_id: z.string().nullable().optional(),
|
|
57
|
+
shipment_number: z.string().nullable().optional(),
|
|
58
|
+
tracking_number: z.string().nullable().optional(),
|
|
59
|
+
carrier_code: z.string().nullable().optional(),
|
|
60
|
+
fulfillment_provider_code: z.string().nullable().optional(),
|
|
61
|
+
created_at: z.string().nullable().optional(),
|
|
62
|
+
ship_date: z.string().nullable().optional()
|
|
63
|
+
});
|
|
64
|
+
const shipstationCarrierServiceRawSchema = z.looseObject({
|
|
65
|
+
service_code: z.string().min(1),
|
|
66
|
+
name: z.string().nullable().optional(),
|
|
67
|
+
carrier_id: z.string().nullable().optional(),
|
|
68
|
+
carrier_code: z.string().nullable().optional(),
|
|
69
|
+
domestic: z.boolean().nullable().optional(),
|
|
70
|
+
international: z.boolean().nullable().optional()
|
|
71
|
+
});
|
|
72
|
+
const shipstationCarrierPackageRawSchema = z.looseObject({
|
|
73
|
+
package_code: z.string().min(1),
|
|
74
|
+
name: z.string().nullable().optional(),
|
|
75
|
+
carrier_id: z.string().nullable().optional(),
|
|
76
|
+
carrier_code: z.string().nullable().optional()
|
|
77
|
+
});
|
|
78
|
+
const shipstationCarrierOptionRawSchema = z.looseObject({
|
|
79
|
+
name: z.string().min(1),
|
|
80
|
+
description: z.string().nullable().optional(),
|
|
81
|
+
default_value: z.union([
|
|
82
|
+
z.string(),
|
|
83
|
+
z.number(),
|
|
84
|
+
z.boolean()
|
|
85
|
+
]).nullable().optional()
|
|
86
|
+
});
|
|
87
|
+
const shipstationCarrierRawSchema = z.looseObject({
|
|
88
|
+
carrier_id: z.string().min(1),
|
|
89
|
+
carrier_code: z.string().nullable().optional(),
|
|
90
|
+
account_number: z.string().nullable().optional(),
|
|
91
|
+
nickname: z.string().nullable().optional(),
|
|
92
|
+
friendly_name: z.string().nullable().optional(),
|
|
93
|
+
primary: z.boolean().nullable().optional(),
|
|
94
|
+
connection_status: z.string().nullable().optional(),
|
|
95
|
+
services: z.array(shipstationCarrierServiceRawSchema).optional(),
|
|
96
|
+
packages: z.array(shipstationCarrierPackageRawSchema).optional(),
|
|
97
|
+
options: z.array(shipstationCarrierOptionRawSchema).optional()
|
|
98
|
+
});
|
|
99
|
+
const shipstationOrderRawSchema = z.looseObject({
|
|
100
|
+
orderId: z.int(),
|
|
101
|
+
orderNumber: z.string().nullable().optional(),
|
|
102
|
+
orderKey: z.string().nullable().optional(),
|
|
103
|
+
orderStatus: z.string().nullable().optional(),
|
|
104
|
+
createDate: z.string().nullable().optional(),
|
|
105
|
+
modifyDate: z.string().nullable().optional(),
|
|
106
|
+
orderDate: z.string().nullable().optional(),
|
|
107
|
+
paymentDate: z.string().nullable().optional(),
|
|
108
|
+
shipByDate: z.string().nullable().optional(),
|
|
109
|
+
storeId: z.int().nullable().optional()
|
|
110
|
+
});
|
|
111
|
+
const shipstationStoreRawSchema = z.looseObject({
|
|
112
|
+
storeId: z.int(),
|
|
113
|
+
storeName: z.string().nullable().optional(),
|
|
114
|
+
marketplaceId: z.int().nullable().optional(),
|
|
115
|
+
marketplaceName: z.string().nullable().optional(),
|
|
116
|
+
active: z.boolean().nullable().optional(),
|
|
117
|
+
createDate: z.string().nullable().optional(),
|
|
118
|
+
modifyDate: z.string().nullable().optional(),
|
|
119
|
+
autoRefresh: z.boolean().nullable().optional()
|
|
120
|
+
});
|
|
29
121
|
const shipstationPaginationSchema = z.object({
|
|
30
122
|
total: z.int().nonnegative(),
|
|
31
123
|
page: z.int().min(1),
|
|
@@ -47,7 +139,7 @@ const shipstationListLabelsPageInputSchema = z.strictObject({
|
|
|
47
139
|
warehouse_id: z.string().min(1).optional().describe("ShipStation warehouse id filter"),
|
|
48
140
|
created_at_start: z.iso.datetime({ offset: true }).optional().describe("Include labels created at or after this ISO 8601 timestamp"),
|
|
49
141
|
created_at_end: z.iso.datetime({ offset: true }).optional().describe("Include labels created at or before this ISO 8601 timestamp"),
|
|
50
|
-
refund_status: z.string().min(1).optional().describe("
|
|
142
|
+
refund_status: z.string().min(1).optional().describe("Comma-separated label refund statuses"),
|
|
51
143
|
sort_dir: z.enum(["asc", "desc"]).optional().describe("Provider slice direction; defaults to desc"),
|
|
52
144
|
sort_by: z.enum([
|
|
53
145
|
"modified_at",
|
|
@@ -84,6 +176,75 @@ const shipstationListShipmentsPageOutputSchema = z.object({
|
|
|
84
176
|
items: z.array(shipstationShipmentRawSchema),
|
|
85
177
|
pagination: shipstationPaginationSchema
|
|
86
178
|
});
|
|
179
|
+
const shipstationListFulfillmentsPageInputSchema = z.strictObject({
|
|
180
|
+
page: shipstationPageSchema,
|
|
181
|
+
page_size: shipstationPageSizeSchema,
|
|
182
|
+
ship_to_name: z.string().min(1).optional().describe("Recipient name filter"),
|
|
183
|
+
ship_to_country_code: z.string().length(2).optional().describe("Two-letter destination country code"),
|
|
184
|
+
shipment_number: z.string().min(1).optional().describe("Shipment number filter"),
|
|
185
|
+
shipment_id: z.string().min(1).optional().describe("Shipment id filter"),
|
|
186
|
+
fulfillment_id: z.string().min(1).optional().describe("Fulfillment id filter"),
|
|
187
|
+
batch_id: z.string().min(1).optional().describe("Batch id filter"),
|
|
188
|
+
order_source_id: z.string().min(1).optional().describe("Order source id filter"),
|
|
189
|
+
fulfillment_provider_code: z.string().min(1).optional().describe("Fulfillment provider code filter"),
|
|
190
|
+
tracking_number: z.string().min(1).optional().describe("Tracking number filter"),
|
|
191
|
+
ship_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest fulfillment ship time"),
|
|
192
|
+
ship_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest fulfillment ship time"),
|
|
193
|
+
create_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest fulfillment creation time"),
|
|
194
|
+
create_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest fulfillment creation time"),
|
|
195
|
+
sort_dir: z.enum(["asc", "desc"]).optional().describe("Provider slice direction"),
|
|
196
|
+
sort_by: z.literal("created_at").optional().describe("Fulfillment field used to sort the provider slice")
|
|
197
|
+
});
|
|
198
|
+
const shipstationListFulfillmentsPageOutputSchema = z.object({
|
|
199
|
+
items: z.array(shipstationFulfillmentRawSchema),
|
|
200
|
+
pagination: shipstationPaginationSchema
|
|
201
|
+
});
|
|
202
|
+
const shipstationCarrierIdInputSchema = z.strictObject({ carrier_id: z.string().min(1).describe("ShipStation V2 carrier id") });
|
|
203
|
+
const shipstationListCarriersOutputSchema = z.object({ items: z.array(shipstationCarrierRawSchema) });
|
|
204
|
+
const shipstationGetCarrierOutputSchema = shipstationCarrierRawSchema;
|
|
205
|
+
const shipstationListCarrierServicesOutputSchema = z.object({ items: z.array(shipstationCarrierServiceRawSchema) });
|
|
206
|
+
const shipstationListCarrierPackagesOutputSchema = z.object({ items: z.array(shipstationCarrierPackageRawSchema) });
|
|
207
|
+
const shipstationListCarrierOptionsOutputSchema = z.object({ items: z.array(shipstationCarrierOptionRawSchema) });
|
|
208
|
+
const shipstationListOrdersPageInputSchema = z.strictObject({
|
|
209
|
+
page: shipstationPageSchema,
|
|
210
|
+
page_size: shipstationPageSizeSchema,
|
|
211
|
+
customer_name: z.string().min(1).optional().describe("Customer name filter"),
|
|
212
|
+
item_keyword: z.string().min(1).optional().describe("Order item SKU, description, or option filter"),
|
|
213
|
+
create_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest ShipStation creation time"),
|
|
214
|
+
create_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest ShipStation creation time"),
|
|
215
|
+
modify_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest modification time"),
|
|
216
|
+
modify_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest modification time"),
|
|
217
|
+
order_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest order time"),
|
|
218
|
+
order_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest order time"),
|
|
219
|
+
order_number: z.string().min(1).optional().describe("Order number prefix filter"),
|
|
220
|
+
order_status: z.enum([
|
|
221
|
+
"awaiting_payment",
|
|
222
|
+
"awaiting_shipment",
|
|
223
|
+
"pending_fulfillment",
|
|
224
|
+
"shipped",
|
|
225
|
+
"on_hold",
|
|
226
|
+
"cancelled",
|
|
227
|
+
"rejected_fulfillment"
|
|
228
|
+
]).optional().describe("Order status filter"),
|
|
229
|
+
payment_date_start: z.iso.datetime({ offset: true }).optional().describe("Earliest payment time"),
|
|
230
|
+
payment_date_end: z.iso.datetime({ offset: true }).optional().describe("Latest payment time"),
|
|
231
|
+
store_id: z.int().optional().describe("V1 store id filter"),
|
|
232
|
+
sort_by: z.enum([
|
|
233
|
+
"OrderDate",
|
|
234
|
+
"ModifyDate",
|
|
235
|
+
"CreateDate"
|
|
236
|
+
]).optional().describe("Order sort field"),
|
|
237
|
+
sort_dir: z.enum(["ASC", "DESC"]).optional().describe("Order sort direction")
|
|
238
|
+
});
|
|
239
|
+
const shipstationListOrdersPageOutputSchema = z.object({
|
|
240
|
+
items: z.array(shipstationOrderRawSchema),
|
|
241
|
+
pagination: shipstationPaginationSchema
|
|
242
|
+
});
|
|
243
|
+
const shipstationListStoresInputSchema = z.strictObject({
|
|
244
|
+
show_inactive: z.boolean().optional().describe("Include inactive stores"),
|
|
245
|
+
marketplace_id: z.int().optional().describe("Marketplace type id filter")
|
|
246
|
+
});
|
|
247
|
+
const shipstationListStoresOutputSchema = z.object({ items: z.array(shipstationStoreRawSchema) });
|
|
87
248
|
const shipstationListLabelsResponseSchema = z.looseObject({
|
|
88
249
|
labels: z.array(shipstationLabelRawSchema),
|
|
89
250
|
total: z.int().nonnegative(),
|
|
@@ -96,30 +257,73 @@ const shipstationListShipmentsResponseSchema = z.looseObject({
|
|
|
96
257
|
page: z.int().min(1),
|
|
97
258
|
pages: z.int().nonnegative()
|
|
98
259
|
});
|
|
260
|
+
const shipstationListFulfillmentsResponseSchema = z.looseObject({
|
|
261
|
+
fulfillments: z.array(shipstationFulfillmentRawSchema),
|
|
262
|
+
total: z.int().nonnegative(),
|
|
263
|
+
page: z.int().min(1),
|
|
264
|
+
pages: z.int().nonnegative()
|
|
265
|
+
});
|
|
266
|
+
const shipstationListCarriersResponseSchema = z.looseObject({ carriers: z.array(shipstationCarrierRawSchema) });
|
|
267
|
+
const shipstationListCarrierServicesResponseSchema = z.looseObject({ services: z.array(shipstationCarrierServiceRawSchema) });
|
|
268
|
+
const shipstationListCarrierPackagesResponseSchema = z.looseObject({ packages: z.array(shipstationCarrierPackageRawSchema) });
|
|
269
|
+
const shipstationListCarrierOptionsResponseSchema = z.looseObject({ options: z.array(shipstationCarrierOptionRawSchema) });
|
|
270
|
+
const shipstationListOrdersResponseSchema = z.looseObject({
|
|
271
|
+
orders: z.array(shipstationOrderRawSchema),
|
|
272
|
+
total: z.int().nonnegative(),
|
|
273
|
+
page: z.int().min(1),
|
|
274
|
+
pages: z.int().nonnegative()
|
|
275
|
+
});
|
|
276
|
+
const shipstationListStoresResponseSchema = z.array(shipstationStoreRawSchema);
|
|
99
277
|
//#endregion
|
|
100
278
|
//#region src/vendors/shipstation/client.ts
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* Host: `new ShipstationClient(auth)`. Agent tools: `fromContext(ctx)`.
|
|
104
|
-
*/
|
|
105
|
-
const SHIPSTATION_API_BASE = "https://api.shipstation.com/v2";
|
|
279
|
+
const SHIPSTATION_V2_API_BASE = "https://api.shipstation.com/v2";
|
|
280
|
+
const SHIPSTATION_V1_API_BASE = "https://ssapi.shipstation.com";
|
|
106
281
|
const DEFAULT_PAGE_SIZE = 25;
|
|
282
|
+
function parseInput(schema, input, message) {
|
|
283
|
+
const parsed = schema.safeParse(input);
|
|
284
|
+
if (!parsed.success) throw new ToolError(message, {
|
|
285
|
+
code: "bad_input",
|
|
286
|
+
details: { issues: parsed.error.issues.map((issue) => issue.message) }
|
|
287
|
+
});
|
|
288
|
+
return parsed.data;
|
|
289
|
+
}
|
|
290
|
+
function parseResponse(schema, data, message) {
|
|
291
|
+
const parsed = schema.safeParse(data);
|
|
292
|
+
if (!parsed.success) throw new ToolError(message, {
|
|
293
|
+
code: "upstream",
|
|
294
|
+
details: { issues: parsed.error.issues.map((issue) => issue.message) }
|
|
295
|
+
});
|
|
296
|
+
return parsed.data;
|
|
297
|
+
}
|
|
298
|
+
function v1Authorization(apiKey, apiSecret) {
|
|
299
|
+
return `Basic ${bytesToBase64(utf8ToBytes(`${apiKey}:${apiSecret}`))}`;
|
|
300
|
+
}
|
|
107
301
|
var ShipstationClient = class ShipstationClient {
|
|
108
|
-
#
|
|
302
|
+
#v2;
|
|
303
|
+
#v1;
|
|
109
304
|
constructor(auth, options = {}) {
|
|
110
305
|
const parsed = shipstationAuthSchema.safeParse(auth);
|
|
111
306
|
if (!parsed.success) throw new ToolError("Invalid ShipStation auth credentials", {
|
|
112
307
|
code: "bad_auth",
|
|
113
308
|
details: { issues: parsed.error.issues.map((issue) => issue.message) }
|
|
114
309
|
});
|
|
115
|
-
this.#
|
|
310
|
+
this.#v2 = new HttpService({
|
|
116
311
|
...options,
|
|
117
|
-
baseURL:
|
|
312
|
+
baseURL: SHIPSTATION_V2_API_BASE,
|
|
118
313
|
headers: {
|
|
119
314
|
Accept: "application/json",
|
|
120
|
-
"API-Key": parsed.data.
|
|
315
|
+
"API-Key": parsed.data.v2_api_key
|
|
121
316
|
},
|
|
122
|
-
label: "ShipStation"
|
|
317
|
+
label: "ShipStation V2"
|
|
318
|
+
});
|
|
319
|
+
this.#v1 = new HttpService({
|
|
320
|
+
...options,
|
|
321
|
+
baseURL: SHIPSTATION_V1_API_BASE,
|
|
322
|
+
headers: {
|
|
323
|
+
Accept: "application/json",
|
|
324
|
+
Authorization: v1Authorization(parsed.data.v1_api_key, parsed.data.v1_api_secret)
|
|
325
|
+
},
|
|
326
|
+
label: "ShipStation V1"
|
|
123
327
|
});
|
|
124
328
|
}
|
|
125
329
|
static fromContext(ctx) {
|
|
@@ -129,79 +333,169 @@ var ShipstationClient = class ShipstationClient {
|
|
|
129
333
|
...ctx.signal && { signal: ctx.signal }
|
|
130
334
|
});
|
|
131
335
|
}
|
|
132
|
-
/** One GET /labels request with provider pagination and filters. */
|
|
336
|
+
/** One V2 GET /labels request with provider pagination and filters. */
|
|
133
337
|
async listLabelsPage(input = {}) {
|
|
134
|
-
const parsedInput = shipstationListLabelsPageInputSchema
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
const page = parsedInput.data.page ?? 1;
|
|
140
|
-
const pageSize = parsedInput.data.page_size ?? DEFAULT_PAGE_SIZE;
|
|
141
|
-
const { data } = await this.#http.get("/labels", {
|
|
338
|
+
const parsedInput = parseInput(shipstationListLabelsPageInputSchema, input, "Invalid ShipStation labels page input");
|
|
339
|
+
const page = parsedInput.page ?? 1;
|
|
340
|
+
const pageSize = parsedInput.page_size ?? DEFAULT_PAGE_SIZE;
|
|
341
|
+
const { data } = await this.#v2.get("/labels", {
|
|
142
342
|
label: "ShipStation listLabelsPage",
|
|
143
343
|
query: {
|
|
144
|
-
...parsedInput
|
|
344
|
+
...parsedInput,
|
|
145
345
|
page,
|
|
146
346
|
page_size: pageSize
|
|
147
347
|
}
|
|
148
348
|
});
|
|
149
|
-
const
|
|
150
|
-
if (!parsedResponse.success) throw new ToolError("ShipStation returned an invalid labels page", {
|
|
151
|
-
code: "upstream",
|
|
152
|
-
details: { issues: parsedResponse.error.issues.map((issue) => issue.message) }
|
|
153
|
-
});
|
|
349
|
+
const response = parseResponse(shipstationListLabelsResponseSchema, data, "ShipStation returned an invalid labels page");
|
|
154
350
|
return {
|
|
155
|
-
items:
|
|
351
|
+
items: response.labels,
|
|
156
352
|
pagination: {
|
|
157
|
-
total:
|
|
158
|
-
page:
|
|
159
|
-
pages:
|
|
353
|
+
total: response.total,
|
|
354
|
+
page: response.page,
|
|
355
|
+
pages: response.pages,
|
|
160
356
|
page_size: pageSize,
|
|
161
|
-
has_more:
|
|
357
|
+
has_more: response.page < response.pages
|
|
162
358
|
}
|
|
163
359
|
};
|
|
164
360
|
}
|
|
165
|
-
/** One GET /shipments request with provider pagination and filters. */
|
|
361
|
+
/** One V2 GET /shipments request with provider pagination and filters. */
|
|
166
362
|
async listShipmentsPage(input = {}) {
|
|
167
|
-
const parsedInput = shipstationListShipmentsPageInputSchema
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
172
|
-
const page = parsedInput.data.page ?? 1;
|
|
173
|
-
const pageSize = parsedInput.data.page_size ?? DEFAULT_PAGE_SIZE;
|
|
174
|
-
const { data } = await this.#http.get("/shipments", {
|
|
363
|
+
const parsedInput = parseInput(shipstationListShipmentsPageInputSchema, input, "Invalid ShipStation shipments page input");
|
|
364
|
+
const page = parsedInput.page ?? 1;
|
|
365
|
+
const pageSize = parsedInput.page_size ?? DEFAULT_PAGE_SIZE;
|
|
366
|
+
const { data } = await this.#v2.get("/shipments", {
|
|
175
367
|
label: "ShipStation listShipmentsPage",
|
|
176
368
|
query: {
|
|
177
|
-
...parsedInput
|
|
369
|
+
...parsedInput,
|
|
178
370
|
page,
|
|
179
371
|
page_size: pageSize
|
|
180
372
|
}
|
|
181
373
|
});
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
374
|
+
const response = parseResponse(shipstationListShipmentsResponseSchema, data, "ShipStation returned an invalid shipments page");
|
|
375
|
+
return {
|
|
376
|
+
items: response.shipments,
|
|
377
|
+
pagination: {
|
|
378
|
+
total: response.total,
|
|
379
|
+
page: response.page,
|
|
380
|
+
pages: response.pages,
|
|
381
|
+
page_size: pageSize,
|
|
382
|
+
has_more: response.page < response.pages
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/** One V2 GET /fulfillments request with provider pagination and filters. */
|
|
387
|
+
async listFulfillmentsPage(input = {}) {
|
|
388
|
+
const parsedInput = parseInput(shipstationListFulfillmentsPageInputSchema, input, "Invalid ShipStation fulfillments page input");
|
|
389
|
+
const page = parsedInput.page ?? 1;
|
|
390
|
+
const pageSize = parsedInput.page_size ?? DEFAULT_PAGE_SIZE;
|
|
391
|
+
const { data } = await this.#v2.get("/fulfillments", {
|
|
392
|
+
label: "ShipStation listFulfillmentsPage",
|
|
393
|
+
query: {
|
|
394
|
+
...parsedInput,
|
|
395
|
+
page,
|
|
396
|
+
page_size: pageSize
|
|
397
|
+
}
|
|
186
398
|
});
|
|
399
|
+
const response = parseResponse(shipstationListFulfillmentsResponseSchema, data, "ShipStation returned an invalid fulfillments page");
|
|
187
400
|
return {
|
|
188
|
-
items:
|
|
401
|
+
items: response.fulfillments,
|
|
189
402
|
pagination: {
|
|
190
|
-
total:
|
|
191
|
-
page:
|
|
192
|
-
pages:
|
|
403
|
+
total: response.total,
|
|
404
|
+
page: response.page,
|
|
405
|
+
pages: response.pages,
|
|
193
406
|
page_size: pageSize,
|
|
194
|
-
has_more:
|
|
407
|
+
has_more: response.page < response.pages
|
|
195
408
|
}
|
|
196
409
|
};
|
|
197
410
|
}
|
|
411
|
+
/** V2 GET /carriers. */
|
|
412
|
+
async listCarriers() {
|
|
413
|
+
const { data } = await this.#v2.get("/carriers", { label: "ShipStation listCarriers" });
|
|
414
|
+
return { items: parseResponse(shipstationListCarriersResponseSchema, data, "ShipStation returned an invalid carriers response").carriers };
|
|
415
|
+
}
|
|
416
|
+
/** V2 GET /carriers/{carrier_id}. */
|
|
417
|
+
async getCarrier(input) {
|
|
418
|
+
const parsedInput = parseInput(shipstationCarrierIdInputSchema, input, "Invalid ShipStation carrier input");
|
|
419
|
+
const { data } = await this.#v2.get(`/carriers/${encodeURIComponent(parsedInput.carrier_id)}`, { label: "ShipStation getCarrier" });
|
|
420
|
+
return parseResponse(shipstationCarrierRawSchema, data, "ShipStation returned an invalid carrier");
|
|
421
|
+
}
|
|
422
|
+
/** V2 GET /carriers/{carrier_id}/services. */
|
|
423
|
+
async listCarrierServices(input) {
|
|
424
|
+
const parsedInput = parseInput(shipstationCarrierIdInputSchema, input, "Invalid ShipStation carrier input");
|
|
425
|
+
const { data } = await this.#v2.get(`/carriers/${encodeURIComponent(parsedInput.carrier_id)}/services`, { label: "ShipStation listCarrierServices" });
|
|
426
|
+
return { items: parseResponse(shipstationListCarrierServicesResponseSchema, data, "ShipStation returned invalid carrier services").services };
|
|
427
|
+
}
|
|
428
|
+
/** V2 GET /carriers/{carrier_id}/packages. */
|
|
429
|
+
async listCarrierPackages(input) {
|
|
430
|
+
const parsedInput = parseInput(shipstationCarrierIdInputSchema, input, "Invalid ShipStation carrier input");
|
|
431
|
+
const { data } = await this.#v2.get(`/carriers/${encodeURIComponent(parsedInput.carrier_id)}/packages`, { label: "ShipStation listCarrierPackages" });
|
|
432
|
+
return { items: parseResponse(shipstationListCarrierPackagesResponseSchema, data, "ShipStation returned invalid carrier packages").packages };
|
|
433
|
+
}
|
|
434
|
+
/** V2 GET /carriers/{carrier_id}/options. */
|
|
435
|
+
async listCarrierOptions(input) {
|
|
436
|
+
const parsedInput = parseInput(shipstationCarrierIdInputSchema, input, "Invalid ShipStation carrier input");
|
|
437
|
+
const { data } = await this.#v2.get(`/carriers/${encodeURIComponent(parsedInput.carrier_id)}/options`, { label: "ShipStation listCarrierOptions" });
|
|
438
|
+
return { items: parseResponse(shipstationListCarrierOptionsResponseSchema, data, "ShipStation returned invalid carrier options").options };
|
|
439
|
+
}
|
|
440
|
+
/** One legacy V1 GET /orders request. */
|
|
441
|
+
async listOrdersPage(input = {}) {
|
|
442
|
+
const parsedInput = parseInput(shipstationListOrdersPageInputSchema, input, "Invalid ShipStation orders page input");
|
|
443
|
+
const page = parsedInput.page ?? 1;
|
|
444
|
+
const pageSize = parsedInput.page_size ?? DEFAULT_PAGE_SIZE;
|
|
445
|
+
const { data } = await this.#v1.get("/orders", {
|
|
446
|
+
label: "ShipStation listOrdersPage",
|
|
447
|
+
query: {
|
|
448
|
+
page,
|
|
449
|
+
pageSize,
|
|
450
|
+
...parsedInput.customer_name && { customerName: parsedInput.customer_name },
|
|
451
|
+
...parsedInput.item_keyword && { itemKeyword: parsedInput.item_keyword },
|
|
452
|
+
...parsedInput.create_date_start && { createDateStart: parsedInput.create_date_start },
|
|
453
|
+
...parsedInput.create_date_end && { createDateEnd: parsedInput.create_date_end },
|
|
454
|
+
...parsedInput.modify_date_start && { modifyDateStart: parsedInput.modify_date_start },
|
|
455
|
+
...parsedInput.modify_date_end && { modifyDateEnd: parsedInput.modify_date_end },
|
|
456
|
+
...parsedInput.order_date_start && { orderDateStart: parsedInput.order_date_start },
|
|
457
|
+
...parsedInput.order_date_end && { orderDateEnd: parsedInput.order_date_end },
|
|
458
|
+
...parsedInput.order_number && { orderNumber: parsedInput.order_number },
|
|
459
|
+
...parsedInput.order_status && { orderStatus: parsedInput.order_status },
|
|
460
|
+
...parsedInput.payment_date_start && { paymentDateStart: parsedInput.payment_date_start },
|
|
461
|
+
...parsedInput.payment_date_end && { paymentDateEnd: parsedInput.payment_date_end },
|
|
462
|
+
...parsedInput.store_id !== void 0 && { storeId: parsedInput.store_id },
|
|
463
|
+
...parsedInput.sort_by && { sortBy: parsedInput.sort_by },
|
|
464
|
+
...parsedInput.sort_dir && { sortDir: parsedInput.sort_dir }
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
const response = parseResponse(shipstationListOrdersResponseSchema, data, "ShipStation returned an invalid orders page");
|
|
468
|
+
return {
|
|
469
|
+
items: response.orders,
|
|
470
|
+
pagination: {
|
|
471
|
+
total: response.total,
|
|
472
|
+
page: response.page,
|
|
473
|
+
pages: response.pages,
|
|
474
|
+
page_size: pageSize,
|
|
475
|
+
has_more: response.page < response.pages
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
/** Legacy V1 GET /stores. */
|
|
480
|
+
async listStores(input = {}) {
|
|
481
|
+
const parsedInput = parseInput(shipstationListStoresInputSchema, input, "Invalid ShipStation stores input");
|
|
482
|
+
const { data } = await this.#v1.get("/stores", {
|
|
483
|
+
label: "ShipStation listStores",
|
|
484
|
+
query: {
|
|
485
|
+
...parsedInput.show_inactive !== void 0 && { showInactive: parsedInput.show_inactive },
|
|
486
|
+
...parsedInput.marketplace_id !== void 0 && { marketplaceId: parsedInput.marketplace_id }
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
return { items: parseResponse(shipstationListStoresResponseSchema, data, "ShipStation returned an invalid stores response") };
|
|
490
|
+
}
|
|
198
491
|
};
|
|
199
492
|
//#endregion
|
|
200
493
|
//#region src/vendors/shipstation/module.ts
|
|
494
|
+
const emptyInputSchema = z.strictObject({}).describe("No input fields");
|
|
201
495
|
const shipstationListLabelsTool = defineTool({
|
|
202
496
|
id: "shipstation-list-labels",
|
|
203
497
|
name: "shipstationListLabels",
|
|
204
|
-
description: "List one page of ShipStation labels
|
|
498
|
+
description: "List one V2 page of ShipStation labels, including shipping and insurance cost, carrier, service, tracking, void, and refund data.",
|
|
205
499
|
inputSchema: shipstationListLabelsPageInputSchema,
|
|
206
500
|
outputSchema: shipstationListLabelsPageOutputSchema,
|
|
207
501
|
sideEffect: "read",
|
|
@@ -213,6 +507,7 @@ const shipstationListLabelsTool = defineTool({
|
|
|
213
507
|
"labels",
|
|
214
508
|
"shipping",
|
|
215
509
|
"tracking",
|
|
510
|
+
"costs",
|
|
216
511
|
"fulfillment"
|
|
217
512
|
],
|
|
218
513
|
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listLabelsPage(input)
|
|
@@ -220,7 +515,7 @@ const shipstationListLabelsTool = defineTool({
|
|
|
220
515
|
const shipstationListShipmentsTool = defineTool({
|
|
221
516
|
id: "shipstation-list-shipments",
|
|
222
517
|
name: "shipstationListShipments",
|
|
223
|
-
description: "List one page of ShipStation shipments. Filter by
|
|
518
|
+
description: "List one V2 page of ShipStation shipments. Filter by time, status, order, store, recipient, item, batch, pickup, or shipment identifiers.",
|
|
224
519
|
inputSchema: shipstationListShipmentsPageInputSchema,
|
|
225
520
|
outputSchema: shipstationListShipmentsPageOutputSchema,
|
|
226
521
|
sideEffect: "read",
|
|
@@ -236,10 +531,146 @@ const shipstationListShipmentsTool = defineTool({
|
|
|
236
531
|
],
|
|
237
532
|
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listShipmentsPage(input)
|
|
238
533
|
});
|
|
534
|
+
const shipstationListFulfillmentsTool = defineTool({
|
|
535
|
+
id: "shipstation-list-fulfillments",
|
|
536
|
+
name: "shipstationListFulfillments",
|
|
537
|
+
description: "List one V2 page of completed ShipStation fulfillments with shipment, provider, tracking, creation, and ship-date filters.",
|
|
538
|
+
inputSchema: shipstationListFulfillmentsPageInputSchema,
|
|
539
|
+
outputSchema: shipstationListFulfillmentsPageOutputSchema,
|
|
540
|
+
sideEffect: "read",
|
|
541
|
+
runtime: "both",
|
|
542
|
+
idempotent: true,
|
|
543
|
+
network: true,
|
|
544
|
+
supportsCancel: true,
|
|
545
|
+
tags: [
|
|
546
|
+
"fulfillments",
|
|
547
|
+
"shipments",
|
|
548
|
+
"tracking"
|
|
549
|
+
],
|
|
550
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listFulfillmentsPage(input)
|
|
551
|
+
});
|
|
552
|
+
const shipstationListCarriersTool = defineTool({
|
|
553
|
+
id: "shipstation-list-carriers",
|
|
554
|
+
name: "shipstationListCarriers",
|
|
555
|
+
description: "List connected V2 ShipStation carrier accounts and their available shipping capabilities.",
|
|
556
|
+
inputSchema: emptyInputSchema,
|
|
557
|
+
outputSchema: shipstationListCarriersOutputSchema,
|
|
558
|
+
sideEffect: "read",
|
|
559
|
+
runtime: "both",
|
|
560
|
+
idempotent: true,
|
|
561
|
+
network: true,
|
|
562
|
+
supportsCancel: true,
|
|
563
|
+
tags: ["carriers", "shipping"],
|
|
564
|
+
execute: async (_input, ctx) => ShipstationClient.fromContext(ctx).listCarriers()
|
|
565
|
+
});
|
|
566
|
+
const shipstationGetCarrierTool = defineTool({
|
|
567
|
+
id: "shipstation-get-carrier",
|
|
568
|
+
name: "shipstationGetCarrier",
|
|
569
|
+
description: "Get one connected V2 ShipStation carrier account and its capabilities.",
|
|
570
|
+
inputSchema: shipstationCarrierIdInputSchema,
|
|
571
|
+
outputSchema: shipstationGetCarrierOutputSchema,
|
|
572
|
+
sideEffect: "read",
|
|
573
|
+
runtime: "both",
|
|
574
|
+
idempotent: true,
|
|
575
|
+
network: true,
|
|
576
|
+
supportsCancel: true,
|
|
577
|
+
tags: ["carriers", "shipping"],
|
|
578
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).getCarrier(input)
|
|
579
|
+
});
|
|
580
|
+
const shipstationListCarrierServicesTool = defineTool({
|
|
581
|
+
id: "shipstation-list-carrier-services",
|
|
582
|
+
name: "shipstationListCarrierServices",
|
|
583
|
+
description: "List shipping services available through one V2 ShipStation carrier account.",
|
|
584
|
+
inputSchema: shipstationCarrierIdInputSchema,
|
|
585
|
+
outputSchema: shipstationListCarrierServicesOutputSchema,
|
|
586
|
+
sideEffect: "read",
|
|
587
|
+
runtime: "both",
|
|
588
|
+
idempotent: true,
|
|
589
|
+
network: true,
|
|
590
|
+
supportsCancel: true,
|
|
591
|
+
tags: [
|
|
592
|
+
"carriers",
|
|
593
|
+
"services",
|
|
594
|
+
"shipping"
|
|
595
|
+
],
|
|
596
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listCarrierServices(input)
|
|
597
|
+
});
|
|
598
|
+
const shipstationListCarrierPackagesTool = defineTool({
|
|
599
|
+
id: "shipstation-list-carrier-packages",
|
|
600
|
+
name: "shipstationListCarrierPackages",
|
|
601
|
+
description: "List package types available through one V2 ShipStation carrier account.",
|
|
602
|
+
inputSchema: shipstationCarrierIdInputSchema,
|
|
603
|
+
outputSchema: shipstationListCarrierPackagesOutputSchema,
|
|
604
|
+
sideEffect: "read",
|
|
605
|
+
runtime: "both",
|
|
606
|
+
idempotent: true,
|
|
607
|
+
network: true,
|
|
608
|
+
supportsCancel: true,
|
|
609
|
+
tags: [
|
|
610
|
+
"carriers",
|
|
611
|
+
"packages",
|
|
612
|
+
"shipping"
|
|
613
|
+
],
|
|
614
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listCarrierPackages(input)
|
|
615
|
+
});
|
|
616
|
+
const shipstationListCarrierOptionsTool = defineTool({
|
|
617
|
+
id: "shipstation-list-carrier-options",
|
|
618
|
+
name: "shipstationListCarrierOptions",
|
|
619
|
+
description: "List advanced options available through one V2 ShipStation carrier account.",
|
|
620
|
+
inputSchema: shipstationCarrierIdInputSchema,
|
|
621
|
+
outputSchema: shipstationListCarrierOptionsOutputSchema,
|
|
622
|
+
sideEffect: "read",
|
|
623
|
+
runtime: "both",
|
|
624
|
+
idempotent: true,
|
|
625
|
+
network: true,
|
|
626
|
+
supportsCancel: true,
|
|
627
|
+
tags: [
|
|
628
|
+
"carriers",
|
|
629
|
+
"options",
|
|
630
|
+
"shipping"
|
|
631
|
+
],
|
|
632
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listCarrierOptions(input)
|
|
633
|
+
});
|
|
634
|
+
const shipstationListOrdersTool = defineTool({
|
|
635
|
+
id: "shipstation-list-orders",
|
|
636
|
+
name: "shipstationListOrders",
|
|
637
|
+
description: "List one legacy V1 page of ShipStation sales orders. Filter by creation, modification, order, or payment time plus customer, item, number, status, or store.",
|
|
638
|
+
inputSchema: shipstationListOrdersPageInputSchema,
|
|
639
|
+
outputSchema: shipstationListOrdersPageOutputSchema,
|
|
640
|
+
sideEffect: "read",
|
|
641
|
+
runtime: "both",
|
|
642
|
+
idempotent: true,
|
|
643
|
+
network: true,
|
|
644
|
+
supportsCancel: true,
|
|
645
|
+
tags: [
|
|
646
|
+
"orders",
|
|
647
|
+
"sales",
|
|
648
|
+
"stores"
|
|
649
|
+
],
|
|
650
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listOrdersPage(input)
|
|
651
|
+
});
|
|
652
|
+
const shipstationListStoresTool = defineTool({
|
|
653
|
+
id: "shipstation-list-stores",
|
|
654
|
+
name: "shipstationListStores",
|
|
655
|
+
description: "List installed legacy V1 ShipStation stores, optionally including inactive stores or one marketplace.",
|
|
656
|
+
inputSchema: shipstationListStoresInputSchema,
|
|
657
|
+
outputSchema: shipstationListStoresOutputSchema,
|
|
658
|
+
sideEffect: "read",
|
|
659
|
+
runtime: "both",
|
|
660
|
+
idempotent: true,
|
|
661
|
+
network: true,
|
|
662
|
+
supportsCancel: true,
|
|
663
|
+
tags: [
|
|
664
|
+
"stores",
|
|
665
|
+
"orders",
|
|
666
|
+
"marketplaces"
|
|
667
|
+
],
|
|
668
|
+
execute: async (input, ctx) => ShipstationClient.fromContext(ctx).listStores(input)
|
|
669
|
+
});
|
|
239
670
|
const shipstationModule = defineModule({
|
|
240
671
|
id: "shipstation",
|
|
241
672
|
title: "ShipStation",
|
|
242
|
-
description: "ShipStation V2
|
|
673
|
+
description: "Hybrid ShipStation pack: V2 shipping operations plus legacy V1 sales orders and stores.",
|
|
243
674
|
runtime: "both",
|
|
244
675
|
auth: {
|
|
245
676
|
type: "custom",
|
|
@@ -250,12 +681,26 @@ const shipstationModule = defineModule({
|
|
|
250
681
|
tags: [
|
|
251
682
|
"labels",
|
|
252
683
|
"shipments",
|
|
253
|
-
"
|
|
254
|
-
"
|
|
684
|
+
"fulfillments",
|
|
685
|
+
"carriers",
|
|
686
|
+
"orders",
|
|
687
|
+
"stores",
|
|
688
|
+
"tracking"
|
|
255
689
|
],
|
|
256
|
-
tools: [
|
|
690
|
+
tools: [
|
|
691
|
+
shipstationListLabelsTool,
|
|
692
|
+
shipstationListShipmentsTool,
|
|
693
|
+
shipstationListFulfillmentsTool,
|
|
694
|
+
shipstationListCarriersTool,
|
|
695
|
+
shipstationGetCarrierTool,
|
|
696
|
+
shipstationListCarrierServicesTool,
|
|
697
|
+
shipstationListCarrierPackagesTool,
|
|
698
|
+
shipstationListCarrierOptionsTool,
|
|
699
|
+
shipstationListOrdersTool,
|
|
700
|
+
shipstationListStoresTool
|
|
701
|
+
]
|
|
257
702
|
});
|
|
258
703
|
//#endregion
|
|
259
|
-
export { ShipstationClient, shipstationAuthSchema, shipstationLabelRawSchema, shipstationListLabelsPageInputSchema, shipstationListLabelsPageOutputSchema, shipstationListLabelsResponseSchema, shipstationListLabelsTool, shipstationListShipmentsPageInputSchema, shipstationListShipmentsPageOutputSchema, shipstationListShipmentsResponseSchema, shipstationListShipmentsTool, shipstationModule, shipstationPaginationSchema, shipstationShipmentRawSchema };
|
|
704
|
+
export { ShipstationClient, shipstationAuthSchema, shipstationCarrierIdInputSchema, shipstationCarrierOptionRawSchema, shipstationCarrierPackageRawSchema, shipstationCarrierRawSchema, shipstationCarrierServiceRawSchema, shipstationFulfillmentRawSchema, shipstationGetCarrierOutputSchema, shipstationGetCarrierTool, shipstationLabelRawSchema, shipstationListCarrierOptionsOutputSchema, shipstationListCarrierOptionsResponseSchema, shipstationListCarrierOptionsTool, shipstationListCarrierPackagesOutputSchema, shipstationListCarrierPackagesResponseSchema, shipstationListCarrierPackagesTool, shipstationListCarrierServicesOutputSchema, shipstationListCarrierServicesResponseSchema, shipstationListCarrierServicesTool, shipstationListCarriersOutputSchema, shipstationListCarriersResponseSchema, shipstationListCarriersTool, shipstationListFulfillmentsPageInputSchema, shipstationListFulfillmentsPageOutputSchema, shipstationListFulfillmentsResponseSchema, shipstationListFulfillmentsTool, shipstationListLabelsPageInputSchema, shipstationListLabelsPageOutputSchema, shipstationListLabelsResponseSchema, shipstationListLabelsTool, shipstationListOrdersPageInputSchema, shipstationListOrdersPageOutputSchema, shipstationListOrdersResponseSchema, shipstationListOrdersTool, shipstationListShipmentsPageInputSchema, shipstationListShipmentsPageOutputSchema, shipstationListShipmentsResponseSchema, shipstationListShipmentsTool, shipstationListStoresInputSchema, shipstationListStoresOutputSchema, shipstationListStoresResponseSchema, shipstationListStoresTool, shipstationModule, shipstationMoneySchema, shipstationOrderRawSchema, shipstationPaginationSchema, shipstationRefundDetailsRawSchema, shipstationShipmentRawSchema, shipstationStoreRawSchema };
|
|
260
705
|
|
|
261
706
|
//# sourceMappingURL=index.js.map
|