@zerodot/woocommerce 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +56 -2
- package/dist/index.cjs +1367 -0
- package/package.json +46 -3
- package/woocommerce.svg +1 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1367 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
let _zerodot_node_sdk = require("@zerodot/node-sdk");
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
5
|
+
// src/api.ts
|
|
6
|
+
const WOOCOMMERCE_CREDENTIAL = "woocommerce.api";
|
|
7
|
+
/** The most items that "return all" collects. A node output has a size limit too. */
|
|
8
|
+
const MAX_ITEMS = 5e3;
|
|
9
|
+
/** The address of the store, checked. Only `https` is allowed. */
|
|
10
|
+
function storeUrlOf(value) {
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = new URL(value.trim());
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error("The \"url\" of the credential is not an address, such as https://example.com");
|
|
16
|
+
}
|
|
17
|
+
if (parsed.protocol !== "https:") throw new Error("The \"url\" of the credential must start with https://. The keys need HTTPS");
|
|
18
|
+
return `${parsed.origin}${parsed.pathname.replace(/\/+$/, "")}`;
|
|
19
|
+
}
|
|
20
|
+
/** The store address, the key, and the secret of a credential. */
|
|
21
|
+
function wooAccess(credential) {
|
|
22
|
+
if (!credential || credential.type !== "woocommerce.api") throw new Error("The node needs a WooCommerce credential");
|
|
23
|
+
const { url, consumerKey, consumerSecret, includeCredentialsInQuery } = credential.data;
|
|
24
|
+
for (const [name, value] of [
|
|
25
|
+
["url", url],
|
|
26
|
+
["consumerKey", consumerKey],
|
|
27
|
+
["consumerSecret", consumerSecret]
|
|
28
|
+
]) if (typeof value !== "string" || value.trim() === "") throw new Error(`The credential has no "${name}"`);
|
|
29
|
+
return {
|
|
30
|
+
url: storeUrlOf(String(url)),
|
|
31
|
+
consumerKey: String(consumerKey).trim(),
|
|
32
|
+
consumerSecret: String(consumerSecret).trim(),
|
|
33
|
+
inQuery: includeCredentialsInQuery === true || includeCredentialsInQuery === "true"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The base address of the REST API of a store. */
|
|
37
|
+
const baseUrl = (access) => `${access.url}/wp-json/wc/v3`;
|
|
38
|
+
/** An error that WooCommerce gave. */
|
|
39
|
+
var WooError = class extends Error {
|
|
40
|
+
status;
|
|
41
|
+
constructor(message, status) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = "WooError";
|
|
44
|
+
this.status = status;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/** Short help for the statuses that people see most. */
|
|
48
|
+
const HINTS = {
|
|
49
|
+
401: "WooCommerce did not accept the consumer key and secret",
|
|
50
|
+
403: "The key cannot use this resource. Check the permissions of the key",
|
|
51
|
+
404: "WooCommerce did not find the resource. Check the IDs and the store address",
|
|
52
|
+
429: "WooCommerce limits the requests. Try again later"
|
|
53
|
+
};
|
|
54
|
+
/** The error for an answer with an error status. The text never has the key or the secret. */
|
|
55
|
+
function wooErrorOf(label, status, answer) {
|
|
56
|
+
const parts = [`WooCommerce ${label} failed (${status})`];
|
|
57
|
+
if (typeof answer === "object" && answer !== null && !Array.isArray(answer)) {
|
|
58
|
+
const { code, message } = answer;
|
|
59
|
+
if (typeof message === "string" && message) parts.push(message.replace(/<[^>]*>/g, "").trim());
|
|
60
|
+
if (typeof code === "string" && code) parts.push(`code: ${code}`);
|
|
61
|
+
}
|
|
62
|
+
const hint = HINTS[status];
|
|
63
|
+
if (hint) parts.push(hint);
|
|
64
|
+
return new WooError(parts.join(". "), status);
|
|
65
|
+
}
|
|
66
|
+
const basicAuth = (access) => `Basic ${Buffer.from(`${access.consumerKey}:${access.consumerSecret}`).toString("base64")}`;
|
|
67
|
+
/** One call. The answer is the JSON of WooCommerce: an object, or a list for a list call. */
|
|
68
|
+
async function callWoo(access, call, options) {
|
|
69
|
+
const url = new URL(`${baseUrl(access)}${call.path}`);
|
|
70
|
+
for (const [key, value] of Object.entries(call.query ?? {})) {
|
|
71
|
+
if (value === void 0 || value === "") continue;
|
|
72
|
+
url.searchParams.set(key, String(value));
|
|
73
|
+
}
|
|
74
|
+
if (access.inQuery) {
|
|
75
|
+
url.searchParams.set("consumer_key", access.consumerKey);
|
|
76
|
+
url.searchParams.set("consumer_secret", access.consumerSecret);
|
|
77
|
+
}
|
|
78
|
+
const label = `${call.method} ${call.path.replace(/^\/+/, "").split("/").slice(0, 1).join("")}`;
|
|
79
|
+
const response = await fetch(url, {
|
|
80
|
+
method: call.method,
|
|
81
|
+
headers: {
|
|
82
|
+
accept: "application/json",
|
|
83
|
+
...access.inQuery ? {} : { authorization: basicAuth(access) },
|
|
84
|
+
...call.body ? { "content-type": "application/json" } : {}
|
|
85
|
+
},
|
|
86
|
+
body: call.body ? JSON.stringify(call.body) : void 0,
|
|
87
|
+
redirect: "error",
|
|
88
|
+
signal: AbortSignal.any([options.signal, AbortSignal.timeout(options.timeoutMs)])
|
|
89
|
+
});
|
|
90
|
+
if (response.status === 204) return {};
|
|
91
|
+
const answer = await response.json().catch(() => null);
|
|
92
|
+
if (!response.ok) throw wooErrorOf(label, response.status, answer);
|
|
93
|
+
return answer ?? {};
|
|
94
|
+
}
|
|
95
|
+
/** An object answer. A call that gives a list fails here. */
|
|
96
|
+
async function callWooObject(access, call, options) {
|
|
97
|
+
const answer = await callWoo(access, call, options);
|
|
98
|
+
return typeof answer === "object" && answer !== null && !Array.isArray(answer) ? answer : {};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A list. Reads pages with `per_page` and `page` until it has `limit` items, or all items when
|
|
102
|
+
* `limit` is null. A page with fewer items than `per_page` is the last page.
|
|
103
|
+
*/
|
|
104
|
+
async function callWooList(access, call, limit, options) {
|
|
105
|
+
const wanted = Math.min(limit ?? 5e3, MAX_ITEMS);
|
|
106
|
+
const items = [];
|
|
107
|
+
const size = Math.min(100, wanted);
|
|
108
|
+
let page = 1;
|
|
109
|
+
while (items.length < wanted) {
|
|
110
|
+
const answer = await callWoo(access, {
|
|
111
|
+
...call,
|
|
112
|
+
query: {
|
|
113
|
+
...call.query,
|
|
114
|
+
per_page: size,
|
|
115
|
+
page
|
|
116
|
+
}
|
|
117
|
+
}, options);
|
|
118
|
+
if (!Array.isArray(answer) || answer.length === 0) break;
|
|
119
|
+
items.push(...answer);
|
|
120
|
+
if (answer.length < size) break;
|
|
121
|
+
page += 1;
|
|
122
|
+
}
|
|
123
|
+
return items.slice(0, wanted);
|
|
124
|
+
}
|
|
125
|
+
// src/icon.ts
|
|
126
|
+
const WOOCOMMERCE_ICON = (0, _zerodot_node_sdk.fileIcon)(require("url").pathToFileURL(__filename).href, "../woocommerce.svg");
|
|
127
|
+
// src/credential.ts
|
|
128
|
+
const TIMEOUT_MS$1 = 1e4;
|
|
129
|
+
const woocommerceCredential = {
|
|
130
|
+
type: WOOCOMMERCE_CREDENTIAL,
|
|
131
|
+
label: "WooCommerce API",
|
|
132
|
+
fields: zod.z.object({
|
|
133
|
+
/** From WooCommerce: Settings, Advanced, REST API, Add key. */
|
|
134
|
+
consumerKey: zod.z.string().min(1).meta({
|
|
135
|
+
title: "Consumer Key",
|
|
136
|
+
placeholder: "ck_..."
|
|
137
|
+
}),
|
|
138
|
+
/** From the same page. WooCommerce shows it one time only. The trigger uses it for webhooks. */
|
|
139
|
+
consumerSecret: zod.z.string().min(1).meta({
|
|
140
|
+
title: "Consumer Secret",
|
|
141
|
+
placeholder: "cs_..."
|
|
142
|
+
}),
|
|
143
|
+
url: zod.z.string().min(1).meta({
|
|
144
|
+
title: "WooCommerce URL",
|
|
145
|
+
placeholder: "https://example.com"
|
|
146
|
+
}),
|
|
147
|
+
includeCredentialsInQuery: zod.z.enum(["true", "false"]).optional().meta({
|
|
148
|
+
title: "Include Credentials in Query",
|
|
149
|
+
labels: {
|
|
150
|
+
true: "Yes",
|
|
151
|
+
false: "No"
|
|
152
|
+
},
|
|
153
|
+
description: "Some servers do not read the Authorization header. WooCommerce then says \"Consumer key is missing\". Set Yes to send the key and the secret in the query"
|
|
154
|
+
})
|
|
155
|
+
}),
|
|
156
|
+
secretFields: ["consumerKey", "consumerSecret"],
|
|
157
|
+
icon: "ShoppingCart01Icon",
|
|
158
|
+
iconUrl: WOOCOMMERCE_ICON,
|
|
159
|
+
async test(credential) {
|
|
160
|
+
await callWoo(wooAccess(credential), {
|
|
161
|
+
method: "GET",
|
|
162
|
+
path: "/products/categories",
|
|
163
|
+
query: { per_page: 1 }
|
|
164
|
+
}, {
|
|
165
|
+
signal: AbortSignal.timeout(TIMEOUT_MS$1),
|
|
166
|
+
timeoutMs: TIMEOUT_MS$1
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
// src/config.ts
|
|
171
|
+
const RESOURCES = [
|
|
172
|
+
"customer",
|
|
173
|
+
"order",
|
|
174
|
+
"product"
|
|
175
|
+
];
|
|
176
|
+
const OPERATIONS = [
|
|
177
|
+
"create",
|
|
178
|
+
"delete",
|
|
179
|
+
"get",
|
|
180
|
+
"getAll",
|
|
181
|
+
"update"
|
|
182
|
+
];
|
|
183
|
+
const ORDER_STATUSES = [
|
|
184
|
+
"cancelled",
|
|
185
|
+
"completed",
|
|
186
|
+
"failed",
|
|
187
|
+
"on-hold",
|
|
188
|
+
"pending",
|
|
189
|
+
"processing",
|
|
190
|
+
"refunded",
|
|
191
|
+
"trash"
|
|
192
|
+
];
|
|
193
|
+
const SORT_ORDERS = ["asc", "desc"];
|
|
194
|
+
const PRODUCT_TYPES = [
|
|
195
|
+
"simple",
|
|
196
|
+
"grouped",
|
|
197
|
+
"external",
|
|
198
|
+
"variable"
|
|
199
|
+
];
|
|
200
|
+
const STOCK_STATUSES = [
|
|
201
|
+
"instock",
|
|
202
|
+
"outofstock",
|
|
203
|
+
"onbackorder"
|
|
204
|
+
];
|
|
205
|
+
/** Show a field for these operations of one resource, or of many resources. */
|
|
206
|
+
const on = (resources, operations) => ({ showWhen: {
|
|
207
|
+
resource: [...resources],
|
|
208
|
+
operation: [...operations]
|
|
209
|
+
} });
|
|
210
|
+
const ISO_HINT = "A date and time as ISO 8601, such as 2025-01-31T10:00:00";
|
|
211
|
+
const IDS_HINT = "IDs with commas between, such as 12,15";
|
|
212
|
+
const sortLabels = {
|
|
213
|
+
asc: "ASC",
|
|
214
|
+
desc: "DESC"
|
|
215
|
+
};
|
|
216
|
+
const metaPair = zod.z.object({
|
|
217
|
+
key: zod.z.string().meta({ description: "Name of the metadata key to add" }),
|
|
218
|
+
value: zod.z.string().meta({ description: "Value to set for the metadata key" })
|
|
219
|
+
});
|
|
220
|
+
const metadata = zod.z.array(metaPair);
|
|
221
|
+
/** The address of a customer. The names are the names of the API. */
|
|
222
|
+
const customerAddress = zod.z.object({
|
|
223
|
+
first_name: zod.z.string(),
|
|
224
|
+
last_name: zod.z.string(),
|
|
225
|
+
company: zod.z.string(),
|
|
226
|
+
address_1: zod.z.string(),
|
|
227
|
+
address_2: zod.z.string(),
|
|
228
|
+
city: zod.z.string(),
|
|
229
|
+
state: zod.z.string(),
|
|
230
|
+
postcode: zod.z.string(),
|
|
231
|
+
country: zod.z.string(),
|
|
232
|
+
email: zod.z.string().meta({ placeholder: "name@email.com" }),
|
|
233
|
+
phone: zod.z.string()
|
|
234
|
+
}).partial();
|
|
235
|
+
const customerUpdateFields = zod.z.object({
|
|
236
|
+
billing: customerAddress.meta({ title: "Billing Address" }),
|
|
237
|
+
first_name: zod.z.string(),
|
|
238
|
+
last_name: zod.z.string(),
|
|
239
|
+
meta_data: zod.z.array(metaPair).meta({ title: "Metadata" }),
|
|
240
|
+
shipping: customerAddress.meta({ title: "Shipping Address" })
|
|
241
|
+
}).partial();
|
|
242
|
+
const customerCreateFields = customerUpdateFields.extend({
|
|
243
|
+
password: zod.z.string(),
|
|
244
|
+
username: zod.z.string()
|
|
245
|
+
}).partial();
|
|
246
|
+
const productFields = {
|
|
247
|
+
backorders: zod.z.enum([
|
|
248
|
+
"no",
|
|
249
|
+
"notify",
|
|
250
|
+
"yes"
|
|
251
|
+
]).meta({
|
|
252
|
+
labels: {
|
|
253
|
+
no: "No",
|
|
254
|
+
notify: "Notify",
|
|
255
|
+
yes: "Yes"
|
|
256
|
+
},
|
|
257
|
+
description: "If managing stock, this controls if backorders are allowed"
|
|
258
|
+
}),
|
|
259
|
+
buttonText: zod.z.string().meta({ description: "Product external button text. Only for external products" }),
|
|
260
|
+
catalogVisibility: zod.z.enum([
|
|
261
|
+
"visible",
|
|
262
|
+
"catalog",
|
|
263
|
+
"search",
|
|
264
|
+
"hidden"
|
|
265
|
+
]).meta({ labels: {
|
|
266
|
+
visible: "Visible",
|
|
267
|
+
catalog: "Catalog",
|
|
268
|
+
search: "Search",
|
|
269
|
+
hidden: "Hidden"
|
|
270
|
+
} }),
|
|
271
|
+
categories: zod.z.string().meta({
|
|
272
|
+
title: "Category IDs",
|
|
273
|
+
description: `The categories of the product. ${IDS_HINT}`
|
|
274
|
+
}),
|
|
275
|
+
crossSellIds: zod.z.string().meta({
|
|
276
|
+
title: "Cross Sell IDs",
|
|
277
|
+
description: `The IDs of the cross-sell products. ${IDS_HINT}`
|
|
278
|
+
}),
|
|
279
|
+
dateOnSaleFrom: zod.z.string().meta({ description: `Start date of the sale price, in the time zone of the site. ${ISO_HINT}` }),
|
|
280
|
+
dateOnSaleTo: zod.z.string().meta({ description: `End date of the sale price, in the time zone of the site. ${ISO_HINT}` }),
|
|
281
|
+
description: zod.z.string().meta({ description: "Product description" }),
|
|
282
|
+
downloadable: zod.z.boolean().meta({ description: "Whether the product is downloadable" }),
|
|
283
|
+
externalUrl: zod.z.string().meta({
|
|
284
|
+
title: "External URL",
|
|
285
|
+
description: "Product external URL. Only for external products"
|
|
286
|
+
}),
|
|
287
|
+
featured: zod.z.boolean().meta({ description: "Whether the product is featured" }),
|
|
288
|
+
manageStock: zod.z.boolean().meta({ description: "Stock management at product level" }),
|
|
289
|
+
menuOrder: zod.z.number().int().meta({ description: "Menu order, used to custom sort products" }),
|
|
290
|
+
parentId: zod.z.string().meta({
|
|
291
|
+
title: "Parent ID",
|
|
292
|
+
description: "Product parent ID"
|
|
293
|
+
}),
|
|
294
|
+
purchaseNote: zod.z.string().meta({ description: "Optional note to send the customer after purchase" }),
|
|
295
|
+
regularPrice: zod.z.string().meta({ description: "Product regular price" }),
|
|
296
|
+
reviewsAllowed: zod.z.boolean().meta({ description: "Whether to allow reviews" }),
|
|
297
|
+
salePrice: zod.z.string().meta({ description: "Product sale price" }),
|
|
298
|
+
shippingClass: zod.z.string().meta({ description: "Shipping class slug" }),
|
|
299
|
+
shortDescription: zod.z.string().meta({ description: "Product short description" }),
|
|
300
|
+
sku: zod.z.string().meta({
|
|
301
|
+
title: "SKU",
|
|
302
|
+
description: "Unique identifier"
|
|
303
|
+
}),
|
|
304
|
+
slug: zod.z.string().meta({ description: "Product slug" }),
|
|
305
|
+
soldIndividually: zod.z.boolean().meta({ description: "Whether to allow one item to be bought in a single order" }),
|
|
306
|
+
status: zod.z.enum([
|
|
307
|
+
"draft",
|
|
308
|
+
"pending",
|
|
309
|
+
"private",
|
|
310
|
+
"publish"
|
|
311
|
+
]).meta({
|
|
312
|
+
labels: {
|
|
313
|
+
draft: "Draft",
|
|
314
|
+
pending: "Pending",
|
|
315
|
+
private: "Private",
|
|
316
|
+
publish: "Publish"
|
|
317
|
+
},
|
|
318
|
+
description: "A named status for the product"
|
|
319
|
+
}),
|
|
320
|
+
stockQuantity: zod.z.number().int(),
|
|
321
|
+
stockStatus: zod.z.enum(STOCK_STATUSES).meta({
|
|
322
|
+
labels: {
|
|
323
|
+
instock: "In Stock",
|
|
324
|
+
outofstock: "Out Of Stock",
|
|
325
|
+
onbackorder: "On Back Order"
|
|
326
|
+
},
|
|
327
|
+
description: "Controls the stock status of the product"
|
|
328
|
+
}),
|
|
329
|
+
tags: zod.z.string().meta({
|
|
330
|
+
title: "Tag IDs",
|
|
331
|
+
description: `The tags of the product. ${IDS_HINT}`
|
|
332
|
+
}),
|
|
333
|
+
taxClass: zod.z.string(),
|
|
334
|
+
taxStatus: zod.z.enum([
|
|
335
|
+
"taxable",
|
|
336
|
+
"shipping",
|
|
337
|
+
"none"
|
|
338
|
+
]).meta({ labels: {
|
|
339
|
+
taxable: "Taxable",
|
|
340
|
+
shipping: "Shipping",
|
|
341
|
+
none: "None"
|
|
342
|
+
} }),
|
|
343
|
+
type: zod.z.enum(PRODUCT_TYPES).meta({
|
|
344
|
+
labels: {
|
|
345
|
+
simple: "Simple",
|
|
346
|
+
grouped: "Grouped",
|
|
347
|
+
external: "External",
|
|
348
|
+
variable: "Variable"
|
|
349
|
+
},
|
|
350
|
+
description: "Product type"
|
|
351
|
+
}),
|
|
352
|
+
upsellIds: zod.z.string().meta({
|
|
353
|
+
title: "Upsell IDs",
|
|
354
|
+
description: `The IDs of the up-sell products. ${IDS_HINT}`
|
|
355
|
+
}),
|
|
356
|
+
virtual: zod.z.boolean().meta({ description: "Whether the product is virtual" }),
|
|
357
|
+
weight: zod.z.string().meta({ description: "Product weight" })
|
|
358
|
+
};
|
|
359
|
+
const productCreateFields = zod.z.object(productFields).partial();
|
|
360
|
+
const productUpdateFields = zod.z.object({
|
|
361
|
+
...productFields,
|
|
362
|
+
name: zod.z.string().meta({ description: "Product name" })
|
|
363
|
+
}).partial();
|
|
364
|
+
const orderFields = {
|
|
365
|
+
currency: zod.z.string().meta({ description: "Currency the order was created with" }),
|
|
366
|
+
customerId: zod.z.string().meta({
|
|
367
|
+
title: "Customer ID",
|
|
368
|
+
description: "User ID who owns the order. 0 for guests"
|
|
369
|
+
}),
|
|
370
|
+
customerNote: zod.z.string().meta({ description: "Note left by customer during checkout" }),
|
|
371
|
+
parentId: zod.z.string().meta({
|
|
372
|
+
title: "Parent ID",
|
|
373
|
+
description: "Parent order ID"
|
|
374
|
+
}),
|
|
375
|
+
paymentMethodId: zod.z.string().meta({ title: "Payment Method ID" }),
|
|
376
|
+
paymentMethodTitle: zod.z.string(),
|
|
377
|
+
status: zod.z.enum(ORDER_STATUSES).meta({ labels: {
|
|
378
|
+
cancelled: "Cancelled",
|
|
379
|
+
completed: "Completed",
|
|
380
|
+
failed: "Failed",
|
|
381
|
+
"on-hold": "on-hold",
|
|
382
|
+
pending: "Pending",
|
|
383
|
+
processing: "Processing",
|
|
384
|
+
refunded: "Refunded",
|
|
385
|
+
trash: "Trash"
|
|
386
|
+
} }),
|
|
387
|
+
transactionID: zod.z.string().meta({
|
|
388
|
+
title: "Transaction ID",
|
|
389
|
+
description: "Unique transaction ID"
|
|
390
|
+
})
|
|
391
|
+
};
|
|
392
|
+
const orderCreateFields = zod.z.object({
|
|
393
|
+
...orderFields,
|
|
394
|
+
setPaid: zod.z.boolean().meta({ description: "Whether the order is paid. It will set the status to processing and reduce stock items" })
|
|
395
|
+
}).partial();
|
|
396
|
+
const orderUpdateFields = zod.z.object(orderFields).partial();
|
|
397
|
+
const addressFields = {
|
|
398
|
+
firstName: zod.z.string(),
|
|
399
|
+
lastName: zod.z.string(),
|
|
400
|
+
company: zod.z.string(),
|
|
401
|
+
address_1: zod.z.string().meta({ title: "Address Line 1" }),
|
|
402
|
+
address_2: zod.z.string().meta({ title: "Address Line 2" }),
|
|
403
|
+
city: zod.z.string(),
|
|
404
|
+
state: zod.z.string().meta({ description: "ISO code or name of the state, province or district" }),
|
|
405
|
+
postcode: zod.z.string().meta({ title: "Postal Code" }),
|
|
406
|
+
country: zod.z.string()
|
|
407
|
+
};
|
|
408
|
+
const billingAddress = zod.z.object({
|
|
409
|
+
...addressFields,
|
|
410
|
+
email: zod.z.string().meta({ placeholder: "name@email.com" }),
|
|
411
|
+
phone: zod.z.string()
|
|
412
|
+
}).partial();
|
|
413
|
+
const shippingAddress = zod.z.object(addressFields).partial();
|
|
414
|
+
const lineMetadata = metadata.optional().meta({
|
|
415
|
+
title: "Metadata",
|
|
416
|
+
description: "Meta data"
|
|
417
|
+
});
|
|
418
|
+
const couponLine = zod.z.object({
|
|
419
|
+
code: zod.z.string().meta({ description: "Coupon code" }),
|
|
420
|
+
metadata: lineMetadata
|
|
421
|
+
}).partial();
|
|
422
|
+
const feeLine = zod.z.object({
|
|
423
|
+
name: zod.z.string().meta({ description: "Fee name" }),
|
|
424
|
+
taxClass: zod.z.string().meta({ description: "Tax class of fee" }),
|
|
425
|
+
taxStatus: zod.z.enum(["taxable", "none"]).meta({
|
|
426
|
+
labels: {
|
|
427
|
+
taxable: "Taxable",
|
|
428
|
+
none: "None"
|
|
429
|
+
},
|
|
430
|
+
description: "Tax status of fee"
|
|
431
|
+
}),
|
|
432
|
+
total: zod.z.string().meta({ description: "Line total (after discounts)" }),
|
|
433
|
+
metadata: lineMetadata
|
|
434
|
+
}).partial();
|
|
435
|
+
const lineItem = zod.z.object({
|
|
436
|
+
name: zod.z.string().meta({ description: "Product name" }),
|
|
437
|
+
productId: zod.z.number().int().meta({ title: "Product ID" }),
|
|
438
|
+
variationId: zod.z.number().int().meta({
|
|
439
|
+
title: "Variation ID",
|
|
440
|
+
description: "Variation ID, if applicable"
|
|
441
|
+
}),
|
|
442
|
+
quantity: zod.z.number().meta({ description: "Quantity ordered" }),
|
|
443
|
+
taxClass: zod.z.string().meta({ description: "Slug of the tax class of product" }),
|
|
444
|
+
subtotal: zod.z.string().meta({ description: "Line subtotal (before discounts)" }),
|
|
445
|
+
total: zod.z.string().meta({ description: "Line total (after discounts)" }),
|
|
446
|
+
metadata: lineMetadata
|
|
447
|
+
}).partial();
|
|
448
|
+
const shippingLine = zod.z.object({
|
|
449
|
+
methodTitle: zod.z.string().meta({ description: "Shipping method name" }),
|
|
450
|
+
methodId: zod.z.string().meta({
|
|
451
|
+
title: "Method ID",
|
|
452
|
+
description: "Shipping method ID"
|
|
453
|
+
}),
|
|
454
|
+
total: zod.z.string().meta({ description: "Line total (after discounts)" }),
|
|
455
|
+
metadata: lineMetadata
|
|
456
|
+
}).partial();
|
|
457
|
+
const dimensions = zod.z.object({
|
|
458
|
+
height: zod.z.string().meta({ description: "Product height" }),
|
|
459
|
+
length: zod.z.string().meta({ description: "Product length" }),
|
|
460
|
+
width: zod.z.string().meta({ description: "Product width" })
|
|
461
|
+
}).partial();
|
|
462
|
+
const image = zod.z.object({
|
|
463
|
+
alt: zod.z.string().meta({ description: "Image alternative text" }),
|
|
464
|
+
src: zod.z.string().meta({
|
|
465
|
+
title: "Src",
|
|
466
|
+
description: "Image URL"
|
|
467
|
+
}),
|
|
468
|
+
name: zod.z.string().meta({ description: "Image name" })
|
|
469
|
+
}).partial();
|
|
470
|
+
const customerFilters = zod.z.object({
|
|
471
|
+
email: zod.z.string().meta({
|
|
472
|
+
placeholder: "name@email.com",
|
|
473
|
+
description: "Email address to filter customers by"
|
|
474
|
+
}),
|
|
475
|
+
order: zod.z.enum(SORT_ORDERS).meta({
|
|
476
|
+
title: "Sort Order",
|
|
477
|
+
labels: {
|
|
478
|
+
asc: "Ascending",
|
|
479
|
+
desc: "Descending"
|
|
480
|
+
}
|
|
481
|
+
}),
|
|
482
|
+
orderby: zod.z.enum([
|
|
483
|
+
"id",
|
|
484
|
+
"include",
|
|
485
|
+
"name",
|
|
486
|
+
"registered_date"
|
|
487
|
+
]).meta({
|
|
488
|
+
title: "Order By",
|
|
489
|
+
labels: {
|
|
490
|
+
id: "ID",
|
|
491
|
+
include: "Include",
|
|
492
|
+
name: "Name",
|
|
493
|
+
registered_date: "Registered Date"
|
|
494
|
+
}
|
|
495
|
+
})
|
|
496
|
+
}).partial();
|
|
497
|
+
const productOptions = zod.z.object({
|
|
498
|
+
after: zod.z.string().meta({ description: `Only products published after this time. ${ISO_HINT}` }),
|
|
499
|
+
before: zod.z.string().meta({ description: `Only products published before this time. ${ISO_HINT}` }),
|
|
500
|
+
category: zod.z.string().meta({
|
|
501
|
+
title: "Category ID",
|
|
502
|
+
description: "Limit result set to products assigned a specific category ID"
|
|
503
|
+
}),
|
|
504
|
+
context: zod.z.enum([
|
|
505
|
+
"view",
|
|
506
|
+
"embed",
|
|
507
|
+
"edit"
|
|
508
|
+
]).meta({
|
|
509
|
+
labels: {
|
|
510
|
+
view: "View",
|
|
511
|
+
embed: "Embed",
|
|
512
|
+
edit: "Edit"
|
|
513
|
+
},
|
|
514
|
+
description: "Scope under which the request is made. It sets the fields in the answer"
|
|
515
|
+
}),
|
|
516
|
+
featured: zod.z.boolean().meta({ description: "Whether to limit the result set to featured products" }),
|
|
517
|
+
maxPrice: zod.z.string().meta({ description: "Limit result set to products with a maximum price" }),
|
|
518
|
+
minPrice: zod.z.string().meta({ description: "Limit result set to products with a minimum price" }),
|
|
519
|
+
order: zod.z.enum(SORT_ORDERS).meta({
|
|
520
|
+
labels: sortLabels,
|
|
521
|
+
description: "Order sort attribute ascending or descending"
|
|
522
|
+
}),
|
|
523
|
+
orderBy: zod.z.enum([
|
|
524
|
+
"date",
|
|
525
|
+
"id",
|
|
526
|
+
"include",
|
|
527
|
+
"slug",
|
|
528
|
+
"title"
|
|
529
|
+
]).meta({
|
|
530
|
+
labels: {
|
|
531
|
+
date: "Date",
|
|
532
|
+
id: "ID",
|
|
533
|
+
include: "Include",
|
|
534
|
+
slug: "Slug",
|
|
535
|
+
title: "Title"
|
|
536
|
+
},
|
|
537
|
+
description: "Sort collection by object attribute"
|
|
538
|
+
}),
|
|
539
|
+
search: zod.z.string().meta({ description: "Limit results to those matching a string" }),
|
|
540
|
+
sku: zod.z.string().meta({
|
|
541
|
+
title: "SKU",
|
|
542
|
+
description: "Limit result set to products with a specific SKU"
|
|
543
|
+
}),
|
|
544
|
+
slug: zod.z.string().meta({ description: "Limit result set to products with a specific slug" }),
|
|
545
|
+
status: zod.z.enum([
|
|
546
|
+
"any",
|
|
547
|
+
"draft",
|
|
548
|
+
"pending",
|
|
549
|
+
"private",
|
|
550
|
+
"publish"
|
|
551
|
+
]).meta({
|
|
552
|
+
labels: {
|
|
553
|
+
any: "Any",
|
|
554
|
+
draft: "Draft",
|
|
555
|
+
pending: "Pending",
|
|
556
|
+
private: "Private",
|
|
557
|
+
publish: "Publish"
|
|
558
|
+
},
|
|
559
|
+
description: "Limit result set to products assigned a specific status"
|
|
560
|
+
}),
|
|
561
|
+
stockStatus: zod.z.enum(STOCK_STATUSES).meta({
|
|
562
|
+
labels: {
|
|
563
|
+
instock: "In Stock",
|
|
564
|
+
outofstock: "Out Of Stock",
|
|
565
|
+
onbackorder: "On Back Order"
|
|
566
|
+
},
|
|
567
|
+
description: "Controls the stock status of the product"
|
|
568
|
+
}),
|
|
569
|
+
tag: zod.z.string().meta({
|
|
570
|
+
title: "Tag ID",
|
|
571
|
+
description: "Limit result set to products assigned a specific tag ID"
|
|
572
|
+
}),
|
|
573
|
+
taxClass: zod.z.enum([
|
|
574
|
+
"standard",
|
|
575
|
+
"reduced-rate",
|
|
576
|
+
"zero-rate"
|
|
577
|
+
]).meta({
|
|
578
|
+
labels: {
|
|
579
|
+
standard: "Standard",
|
|
580
|
+
"reduced-rate": "Reduced Rate",
|
|
581
|
+
"zero-rate": "Zero Rate"
|
|
582
|
+
},
|
|
583
|
+
description: "Limit result set to products with a specific tax class"
|
|
584
|
+
}),
|
|
585
|
+
type: zod.z.enum(PRODUCT_TYPES).meta({
|
|
586
|
+
labels: {
|
|
587
|
+
simple: "Simple",
|
|
588
|
+
grouped: "Grouped",
|
|
589
|
+
external: "External",
|
|
590
|
+
variable: "Variable"
|
|
591
|
+
},
|
|
592
|
+
description: "Product type"
|
|
593
|
+
})
|
|
594
|
+
}).partial();
|
|
595
|
+
const orderOptions = zod.z.object({
|
|
596
|
+
after: zod.z.string().meta({ description: `Only orders published after this time. ${ISO_HINT}` }),
|
|
597
|
+
before: zod.z.string().meta({ description: `Only orders published before this time. ${ISO_HINT}` }),
|
|
598
|
+
customer: zod.z.string().meta({ description: "Limit result set to orders assigned a specific customer" }),
|
|
599
|
+
decimalPoints: zod.z.number().int().min(0).max(10).meta({ description: "Number of decimal points to use in each resource" }),
|
|
600
|
+
order: zod.z.enum(SORT_ORDERS).meta({
|
|
601
|
+
labels: sortLabels,
|
|
602
|
+
description: "Order sort attribute ascending or descending"
|
|
603
|
+
}),
|
|
604
|
+
product: zod.z.string().meta({ description: "Limit result set to orders assigned a specific product" }),
|
|
605
|
+
orderBy: zod.z.enum([
|
|
606
|
+
"date",
|
|
607
|
+
"id",
|
|
608
|
+
"include",
|
|
609
|
+
"slug",
|
|
610
|
+
"title"
|
|
611
|
+
]).meta({
|
|
612
|
+
labels: {
|
|
613
|
+
date: "Date",
|
|
614
|
+
id: "ID",
|
|
615
|
+
include: "Include",
|
|
616
|
+
slug: "Slug",
|
|
617
|
+
title: "Title"
|
|
618
|
+
},
|
|
619
|
+
description: "Sort collection by object attribute"
|
|
620
|
+
}),
|
|
621
|
+
search: zod.z.string().meta({ description: "Limit results to those matching a string" }),
|
|
622
|
+
status: zod.z.enum(["any", ...ORDER_STATUSES]).meta({
|
|
623
|
+
labels: {
|
|
624
|
+
any: "Any",
|
|
625
|
+
cancelled: "Cancelled",
|
|
626
|
+
completed: "Completed",
|
|
627
|
+
failed: "Failed",
|
|
628
|
+
"on-hold": "On-Hold",
|
|
629
|
+
pending: "Pending",
|
|
630
|
+
processing: "Processing",
|
|
631
|
+
refunded: "Refunded",
|
|
632
|
+
trash: "Trash"
|
|
633
|
+
},
|
|
634
|
+
description: "Limit result set to orders assigned a specific status"
|
|
635
|
+
})
|
|
636
|
+
}).partial();
|
|
637
|
+
const orderWrite = on(["order"], ["create", "update"]);
|
|
638
|
+
const productWrite = on(["product"], ["create", "update"]);
|
|
639
|
+
const woocommerceConfig = zod.z.object({
|
|
640
|
+
resource: zod.z.enum(RESOURCES).default("product").meta({
|
|
641
|
+
labels: {
|
|
642
|
+
customer: "Customer",
|
|
643
|
+
order: "Order",
|
|
644
|
+
product: "Product"
|
|
645
|
+
},
|
|
646
|
+
hints: {
|
|
647
|
+
customer: "A customer of the store",
|
|
648
|
+
order: "An order of the store",
|
|
649
|
+
product: "A product of the store"
|
|
650
|
+
}
|
|
651
|
+
}),
|
|
652
|
+
operation: zod.z.enum(OPERATIONS).default("create").meta({
|
|
653
|
+
labels: {
|
|
654
|
+
create: "Create",
|
|
655
|
+
delete: "Delete",
|
|
656
|
+
get: "Get",
|
|
657
|
+
getAll: "Get Many",
|
|
658
|
+
update: "Update"
|
|
659
|
+
},
|
|
660
|
+
hints: {
|
|
661
|
+
create: "Create an item",
|
|
662
|
+
delete: "Delete an item for always",
|
|
663
|
+
get: "Retrieve one item",
|
|
664
|
+
getAll: "Retrieve many items",
|
|
665
|
+
update: "Change an item"
|
|
666
|
+
}
|
|
667
|
+
}),
|
|
668
|
+
email: zod.z.string().optional().meta({
|
|
669
|
+
...on(["customer"], ["create"]),
|
|
670
|
+
placeholder: "name@email.com"
|
|
671
|
+
}),
|
|
672
|
+
customerId: zod.z.string().optional().meta({
|
|
673
|
+
...on(["customer"], [
|
|
674
|
+
"delete",
|
|
675
|
+
"get",
|
|
676
|
+
"update"
|
|
677
|
+
]),
|
|
678
|
+
title: "Customer ID",
|
|
679
|
+
description: "The ID of the customer"
|
|
680
|
+
}),
|
|
681
|
+
customerAdditionalFields: customerCreateFields.default({}).meta({
|
|
682
|
+
...on(["customer"], ["create"]),
|
|
683
|
+
title: "Additional Fields"
|
|
684
|
+
}),
|
|
685
|
+
customerUpdateFields: customerUpdateFields.default({}).meta({
|
|
686
|
+
...on(["customer"], ["update"]),
|
|
687
|
+
title: "Update Fields"
|
|
688
|
+
}),
|
|
689
|
+
customerFilters: customerFilters.default({}).meta({
|
|
690
|
+
...on(["customer"], ["getAll"]),
|
|
691
|
+
title: "Filters"
|
|
692
|
+
}),
|
|
693
|
+
name: zod.z.string().optional().meta({
|
|
694
|
+
...on(["product"], ["create"]),
|
|
695
|
+
description: "Product name"
|
|
696
|
+
}),
|
|
697
|
+
productId: zod.z.string().optional().meta({
|
|
698
|
+
...on(["product"], [
|
|
699
|
+
"delete",
|
|
700
|
+
"get",
|
|
701
|
+
"update"
|
|
702
|
+
]),
|
|
703
|
+
title: "Product ID",
|
|
704
|
+
description: "The ID of the product"
|
|
705
|
+
}),
|
|
706
|
+
productAdditionalFields: productCreateFields.default({}).meta({
|
|
707
|
+
...on(["product"], ["create"]),
|
|
708
|
+
title: "Additional Fields"
|
|
709
|
+
}),
|
|
710
|
+
productUpdateFields: productUpdateFields.default({}).meta({
|
|
711
|
+
...on(["product"], ["update"]),
|
|
712
|
+
title: "Update Fields"
|
|
713
|
+
}),
|
|
714
|
+
dimensions: dimensions.optional().meta({
|
|
715
|
+
...productWrite,
|
|
716
|
+
description: "Product dimensions"
|
|
717
|
+
}),
|
|
718
|
+
images: zod.z.array(image).optional().meta({
|
|
719
|
+
...productWrite,
|
|
720
|
+
description: "Product images"
|
|
721
|
+
}),
|
|
722
|
+
productOptions: productOptions.default({}).meta({
|
|
723
|
+
...on(["product"], ["getAll"]),
|
|
724
|
+
title: "Options"
|
|
725
|
+
}),
|
|
726
|
+
orderId: zod.z.string().optional().meta({
|
|
727
|
+
...on(["order"], [
|
|
728
|
+
"delete",
|
|
729
|
+
"get",
|
|
730
|
+
"update"
|
|
731
|
+
]),
|
|
732
|
+
title: "Order ID",
|
|
733
|
+
description: "The ID of the order"
|
|
734
|
+
}),
|
|
735
|
+
orderAdditionalFields: orderCreateFields.default({}).meta({
|
|
736
|
+
...on(["order"], ["create"]),
|
|
737
|
+
title: "Additional Fields"
|
|
738
|
+
}),
|
|
739
|
+
orderUpdateFields: orderUpdateFields.default({}).meta({
|
|
740
|
+
...on(["order"], ["update"]),
|
|
741
|
+
title: "Update Fields"
|
|
742
|
+
}),
|
|
743
|
+
billing: billingAddress.optional().meta({
|
|
744
|
+
...orderWrite,
|
|
745
|
+
description: "Billing address"
|
|
746
|
+
}),
|
|
747
|
+
shipping: shippingAddress.optional().meta({
|
|
748
|
+
...orderWrite,
|
|
749
|
+
description: "Shipping address"
|
|
750
|
+
}),
|
|
751
|
+
couponLines: zod.z.array(couponLine).optional().meta({
|
|
752
|
+
...orderWrite,
|
|
753
|
+
description: "Coupons line data"
|
|
754
|
+
}),
|
|
755
|
+
feeLines: zod.z.array(feeLine).optional().meta({
|
|
756
|
+
...orderWrite,
|
|
757
|
+
description: "Fee line data"
|
|
758
|
+
}),
|
|
759
|
+
lineItems: zod.z.array(lineItem).optional().meta({
|
|
760
|
+
...orderWrite,
|
|
761
|
+
description: "Line item data"
|
|
762
|
+
}),
|
|
763
|
+
shippingLines: zod.z.array(shippingLine).optional().meta({
|
|
764
|
+
...orderWrite,
|
|
765
|
+
description: "Shipping line data"
|
|
766
|
+
}),
|
|
767
|
+
metadata: metadata.optional().meta({
|
|
768
|
+
showWhen: [{
|
|
769
|
+
resource: ["product"],
|
|
770
|
+
operation: ["create", "update"]
|
|
771
|
+
}, {
|
|
772
|
+
resource: ["order"],
|
|
773
|
+
operation: ["create", "update"]
|
|
774
|
+
}],
|
|
775
|
+
title: "Metadata",
|
|
776
|
+
description: "Meta data"
|
|
777
|
+
}),
|
|
778
|
+
orderOptions: orderOptions.default({}).meta({
|
|
779
|
+
...on(["order"], ["getAll"]),
|
|
780
|
+
title: "Options"
|
|
781
|
+
}),
|
|
782
|
+
returnAll: zod.z.boolean().default(false).meta({
|
|
783
|
+
...on(RESOURCES, ["getAll"]),
|
|
784
|
+
description: "Whether to return all results or only up to a given limit"
|
|
785
|
+
}),
|
|
786
|
+
limit: zod.z.number().int().min(1).max(5e3).default(50).meta({
|
|
787
|
+
showWhen: {
|
|
788
|
+
resource: [...RESOURCES],
|
|
789
|
+
operation: ["getAll"],
|
|
790
|
+
returnAll: [false]
|
|
791
|
+
},
|
|
792
|
+
description: "Max number of results to return"
|
|
793
|
+
}),
|
|
794
|
+
timeoutMs: zod.z.number().int().min(1).max(3e5).default(3e4)
|
|
795
|
+
});
|
|
796
|
+
// src/request.ts
|
|
797
|
+
const need = (value, name, operation) => {
|
|
798
|
+
if (value === void 0 || typeof value === "string" && value.trim() === "") throw new Error(`WooCommerce ${operation} needs "${name}"`);
|
|
799
|
+
return value;
|
|
800
|
+
};
|
|
801
|
+
/** An ID goes in a path, so it must be digits only. */
|
|
802
|
+
const id = (value, name, operation) => {
|
|
803
|
+
const text = need(value, name, operation).trim();
|
|
804
|
+
if (!/^\d{1,20}$/.test(text)) throw new Error(`WooCommerce ${operation}: "${name}" is not a valid ID`);
|
|
805
|
+
return text;
|
|
806
|
+
};
|
|
807
|
+
/** A whole number from a text. Empty text gives undefined. */
|
|
808
|
+
const intOf = (value, name, operation) => {
|
|
809
|
+
if (value === void 0 || value.trim() === "") return void 0;
|
|
810
|
+
const number = Number(value);
|
|
811
|
+
if (!Number.isInteger(number)) throw new Error(`WooCommerce ${operation}: "${name}" is not a whole number`);
|
|
812
|
+
return number;
|
|
813
|
+
};
|
|
814
|
+
/** IDs with commas between, as numbers. */
|
|
815
|
+
const idsOf = (text, name, operation) => (text ?? "").split(",").map((item) => item.trim()).filter(Boolean).map((item) => {
|
|
816
|
+
const number = Number(item);
|
|
817
|
+
if (!Number.isInteger(number)) throw new Error(`WooCommerce ${operation}: "${name}" has a value that is not an ID`);
|
|
818
|
+
return number;
|
|
819
|
+
});
|
|
820
|
+
/** `taxClass` as `tax_class`. `metadata` as `meta_data`. `address_1` stays. */
|
|
821
|
+
function snake(key) {
|
|
822
|
+
if (key === "metadata") return "meta_data";
|
|
823
|
+
if (key === "transactionID") return "transaction_id";
|
|
824
|
+
return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
825
|
+
}
|
|
826
|
+
/** A copy with snake case keys. A line with metadata gets `meta_data`. Undefined values go. */
|
|
827
|
+
function snaked(row) {
|
|
828
|
+
const result = {};
|
|
829
|
+
for (const [key, value] of Object.entries(row)) {
|
|
830
|
+
if (value === void 0) continue;
|
|
831
|
+
result[snake(key)] = value;
|
|
832
|
+
}
|
|
833
|
+
return result;
|
|
834
|
+
}
|
|
835
|
+
const hasKeys = (row) => row !== void 0 && Object.values(row).some((value) => value !== void 0);
|
|
836
|
+
/** Fields of a product. The tags and categories are `{ id }` objects. */
|
|
837
|
+
function productBody(fields, operation) {
|
|
838
|
+
const body = {};
|
|
839
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
840
|
+
if (value === void 0) continue;
|
|
841
|
+
if (key === "categories" || key === "tags") body[key] = idsOf(String(value), key, operation).map((item) => ({ id: item }));
|
|
842
|
+
else if (key === "crossSellIds" || key === "upsellIds") body[snake(key)] = idsOf(String(value), key, operation);
|
|
843
|
+
else if (key === "parentId") {
|
|
844
|
+
const parent = intOf(String(value), key, operation);
|
|
845
|
+
if (parent !== void 0) body.parent_id = parent;
|
|
846
|
+
} else body[snake(key)] = value;
|
|
847
|
+
}
|
|
848
|
+
return body;
|
|
849
|
+
}
|
|
850
|
+
/** The order fields that are not lines. The IDs are numbers. */
|
|
851
|
+
function orderBody(fields, operation) {
|
|
852
|
+
const body = {};
|
|
853
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
854
|
+
if (value === void 0) continue;
|
|
855
|
+
if (key === "customerId" || key === "parentId") {
|
|
856
|
+
const number = intOf(String(value), key, operation);
|
|
857
|
+
if (number !== void 0) body[snake(key)] = number;
|
|
858
|
+
} else if (key === "paymentMethodId") body.payment_method = value;
|
|
859
|
+
else if (key === "paymentMethodTitle") body.payment_method_title = value;
|
|
860
|
+
else body[snake(key)] = value;
|
|
861
|
+
}
|
|
862
|
+
return body;
|
|
863
|
+
}
|
|
864
|
+
/** A line of an order, with its own metadata. */
|
|
865
|
+
const lineOf = (line) => snaked(line);
|
|
866
|
+
/** The address, line, and metadata parts that create and update of an order share. */
|
|
867
|
+
function orderParts(c) {
|
|
868
|
+
const body = {};
|
|
869
|
+
if (hasKeys(c.billing)) body.billing = snaked(c.billing);
|
|
870
|
+
if (hasKeys(c.shipping)) body.shipping = snaked(c.shipping);
|
|
871
|
+
if (c.couponLines?.length) body.coupon_lines = c.couponLines.map(lineOf);
|
|
872
|
+
if (c.feeLines?.length) body.fee_lines = c.feeLines.map(lineOf);
|
|
873
|
+
if (c.lineItems?.length) body.line_items = c.lineItems.map(lineOf);
|
|
874
|
+
if (c.metadata?.length) body.meta_data = c.metadata;
|
|
875
|
+
if (c.shippingLines?.length) body.shipping_lines = c.shippingLines.map(lineOf);
|
|
876
|
+
return body;
|
|
877
|
+
}
|
|
878
|
+
/** The query of a list call. Empty values are left out. */
|
|
879
|
+
const queryOf = (entries) => {
|
|
880
|
+
const query = {};
|
|
881
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
882
|
+
if (value === void 0 || value === "" || value === false) continue;
|
|
883
|
+
query[key] = value;
|
|
884
|
+
}
|
|
885
|
+
return query;
|
|
886
|
+
};
|
|
887
|
+
/** The call for the config of the node. It makes no request. */
|
|
888
|
+
function buildRequest(c) {
|
|
889
|
+
const operation = `${c.resource} ${c.operation}`;
|
|
890
|
+
if (c.resource === "customer") switch (c.operation) {
|
|
891
|
+
case "create": return { call: {
|
|
892
|
+
method: "POST",
|
|
893
|
+
path: "/customers",
|
|
894
|
+
body: {
|
|
895
|
+
email: need(c.email, "email", operation),
|
|
896
|
+
...c.customerAdditionalFields
|
|
897
|
+
}
|
|
898
|
+
} };
|
|
899
|
+
case "delete": return { call: {
|
|
900
|
+
method: "DELETE",
|
|
901
|
+
path: `/customers/${id(c.customerId, "customerId", operation)}`,
|
|
902
|
+
query: { force: true }
|
|
903
|
+
} };
|
|
904
|
+
case "get": return { call: {
|
|
905
|
+
method: "GET",
|
|
906
|
+
path: `/customers/${id(c.customerId, "customerId", operation)}`
|
|
907
|
+
} };
|
|
908
|
+
case "getAll": return {
|
|
909
|
+
list: true,
|
|
910
|
+
call: {
|
|
911
|
+
method: "GET",
|
|
912
|
+
path: "/customers",
|
|
913
|
+
query: queryOf({ ...c.customerFilters })
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
case "update": return { call: {
|
|
917
|
+
method: "PUT",
|
|
918
|
+
path: `/customers/${id(c.customerId, "customerId", operation)}`,
|
|
919
|
+
body: { ...c.customerUpdateFields }
|
|
920
|
+
} };
|
|
921
|
+
}
|
|
922
|
+
if (c.resource === "product") switch (c.operation) {
|
|
923
|
+
case "create":
|
|
924
|
+
case "update": {
|
|
925
|
+
const fields = c.operation === "create" ? c.productAdditionalFields : c.productUpdateFields;
|
|
926
|
+
const body = productBody(c.operation === "create" ? {
|
|
927
|
+
name: need(c.name, "name", operation),
|
|
928
|
+
...fields
|
|
929
|
+
} : fields, operation);
|
|
930
|
+
if (hasKeys(c.dimensions)) body.dimensions = snaked(c.dimensions);
|
|
931
|
+
if (c.images?.length) body.images = c.images;
|
|
932
|
+
if (c.metadata?.length) body.meta_data = c.metadata;
|
|
933
|
+
return c.operation === "create" ? { call: {
|
|
934
|
+
method: "POST",
|
|
935
|
+
path: "/products",
|
|
936
|
+
body
|
|
937
|
+
} } : { call: {
|
|
938
|
+
method: "PUT",
|
|
939
|
+
path: `/products/${id(c.productId, "productId", operation)}`,
|
|
940
|
+
body
|
|
941
|
+
} };
|
|
942
|
+
}
|
|
943
|
+
case "delete": return { call: {
|
|
944
|
+
method: "DELETE",
|
|
945
|
+
path: `/products/${id(c.productId, "productId", operation)}`,
|
|
946
|
+
query: { force: true }
|
|
947
|
+
} };
|
|
948
|
+
case "get": return { call: {
|
|
949
|
+
method: "GET",
|
|
950
|
+
path: `/products/${id(c.productId, "productId", operation)}`
|
|
951
|
+
} };
|
|
952
|
+
case "getAll": {
|
|
953
|
+
const o = c.productOptions;
|
|
954
|
+
return {
|
|
955
|
+
list: true,
|
|
956
|
+
call: {
|
|
957
|
+
method: "GET",
|
|
958
|
+
path: "/products",
|
|
959
|
+
query: queryOf({
|
|
960
|
+
after: o.after,
|
|
961
|
+
before: o.before,
|
|
962
|
+
category: o.category,
|
|
963
|
+
context: o.context,
|
|
964
|
+
featured: o.featured,
|
|
965
|
+
max_price: o.maxPrice,
|
|
966
|
+
min_price: o.minPrice,
|
|
967
|
+
order: o.order,
|
|
968
|
+
orderby: o.orderBy,
|
|
969
|
+
search: o.search,
|
|
970
|
+
sku: o.sku,
|
|
971
|
+
slug: o.slug,
|
|
972
|
+
status: o.status,
|
|
973
|
+
stock_status: o.stockStatus,
|
|
974
|
+
tag: o.tag,
|
|
975
|
+
tax_class: o.taxClass,
|
|
976
|
+
type: o.type
|
|
977
|
+
})
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
switch (c.operation) {
|
|
983
|
+
case "create": return { call: {
|
|
984
|
+
method: "POST",
|
|
985
|
+
path: "/orders",
|
|
986
|
+
body: {
|
|
987
|
+
...orderBody(c.orderAdditionalFields, operation),
|
|
988
|
+
...orderParts(c)
|
|
989
|
+
}
|
|
990
|
+
} };
|
|
991
|
+
case "update": return { call: {
|
|
992
|
+
method: "PUT",
|
|
993
|
+
path: `/orders/${id(c.orderId, "orderId", operation)}`,
|
|
994
|
+
body: {
|
|
995
|
+
...orderBody(c.orderUpdateFields, operation),
|
|
996
|
+
...orderParts(c)
|
|
997
|
+
}
|
|
998
|
+
} };
|
|
999
|
+
case "delete": return { call: {
|
|
1000
|
+
method: "DELETE",
|
|
1001
|
+
path: `/orders/${id(c.orderId, "orderId", operation)}`,
|
|
1002
|
+
query: { force: true }
|
|
1003
|
+
} };
|
|
1004
|
+
case "get": return { call: {
|
|
1005
|
+
method: "GET",
|
|
1006
|
+
path: `/orders/${id(c.orderId, "orderId", operation)}`
|
|
1007
|
+
} };
|
|
1008
|
+
case "getAll": {
|
|
1009
|
+
const o = c.orderOptions;
|
|
1010
|
+
return {
|
|
1011
|
+
list: true,
|
|
1012
|
+
call: {
|
|
1013
|
+
method: "GET",
|
|
1014
|
+
path: "/orders",
|
|
1015
|
+
query: queryOf({
|
|
1016
|
+
after: o.after,
|
|
1017
|
+
before: o.before,
|
|
1018
|
+
customer: intOf(o.customer, "customer", operation),
|
|
1019
|
+
dp: o.decimalPoints,
|
|
1020
|
+
product: intOf(o.product, "product", operation),
|
|
1021
|
+
order: o.order,
|
|
1022
|
+
orderby: o.orderBy,
|
|
1023
|
+
search: o.search,
|
|
1024
|
+
status: o.status
|
|
1025
|
+
})
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
// src/node.ts
|
|
1032
|
+
var node_default = (0, _zerodot_node_sdk.defineNode)({
|
|
1033
|
+
type: "woocommerce.api",
|
|
1034
|
+
label: "WooCommerce",
|
|
1035
|
+
description: "Manage customers, orders, and products with WooCommerce",
|
|
1036
|
+
category: "integration",
|
|
1037
|
+
app: "WooCommerce",
|
|
1038
|
+
actions: [
|
|
1039
|
+
{
|
|
1040
|
+
label: "Create a customer",
|
|
1041
|
+
config: {
|
|
1042
|
+
resource: "customer",
|
|
1043
|
+
operation: "create"
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
label: "Delete a customer",
|
|
1048
|
+
config: {
|
|
1049
|
+
resource: "customer",
|
|
1050
|
+
operation: "delete"
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
label: "Get a customer",
|
|
1055
|
+
config: {
|
|
1056
|
+
resource: "customer",
|
|
1057
|
+
operation: "get"
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
label: "Get many customers",
|
|
1062
|
+
config: {
|
|
1063
|
+
resource: "customer",
|
|
1064
|
+
operation: "getAll"
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
label: "Update a customer",
|
|
1069
|
+
config: {
|
|
1070
|
+
resource: "customer",
|
|
1071
|
+
operation: "update"
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
label: "Create an order",
|
|
1076
|
+
config: {
|
|
1077
|
+
resource: "order",
|
|
1078
|
+
operation: "create"
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
label: "Delete an order",
|
|
1083
|
+
config: {
|
|
1084
|
+
resource: "order",
|
|
1085
|
+
operation: "delete"
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
label: "Get an order",
|
|
1090
|
+
config: {
|
|
1091
|
+
resource: "order",
|
|
1092
|
+
operation: "get"
|
|
1093
|
+
}
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
label: "Get many orders",
|
|
1097
|
+
config: {
|
|
1098
|
+
resource: "order",
|
|
1099
|
+
operation: "getAll"
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
label: "Update an order",
|
|
1104
|
+
config: {
|
|
1105
|
+
resource: "order",
|
|
1106
|
+
operation: "update"
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
label: "Create a product",
|
|
1111
|
+
config: {
|
|
1112
|
+
resource: "product",
|
|
1113
|
+
operation: "create"
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
label: "Delete a product",
|
|
1118
|
+
config: {
|
|
1119
|
+
resource: "product",
|
|
1120
|
+
operation: "delete"
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
label: "Get a product",
|
|
1125
|
+
config: {
|
|
1126
|
+
resource: "product",
|
|
1127
|
+
operation: "get"
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
label: "Get many products",
|
|
1132
|
+
config: {
|
|
1133
|
+
resource: "product",
|
|
1134
|
+
operation: "getAll"
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
label: "Update a product",
|
|
1139
|
+
config: {
|
|
1140
|
+
resource: "product",
|
|
1141
|
+
operation: "update"
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
],
|
|
1145
|
+
icon: "ShoppingCart01Icon",
|
|
1146
|
+
iconUrl: WOOCOMMERCE_ICON,
|
|
1147
|
+
config: woocommerceConfig,
|
|
1148
|
+
defaultConfig: {
|
|
1149
|
+
resource: "product",
|
|
1150
|
+
operation: "create",
|
|
1151
|
+
name: "",
|
|
1152
|
+
email: "",
|
|
1153
|
+
customerId: "",
|
|
1154
|
+
productId: "",
|
|
1155
|
+
orderId: "",
|
|
1156
|
+
customerAdditionalFields: {},
|
|
1157
|
+
customerUpdateFields: {},
|
|
1158
|
+
customerFilters: {},
|
|
1159
|
+
productAdditionalFields: {},
|
|
1160
|
+
productUpdateFields: {},
|
|
1161
|
+
productOptions: {},
|
|
1162
|
+
orderAdditionalFields: {},
|
|
1163
|
+
orderUpdateFields: {},
|
|
1164
|
+
orderOptions: {},
|
|
1165
|
+
returnAll: false,
|
|
1166
|
+
limit: 50,
|
|
1167
|
+
timeoutMs: 3e4
|
|
1168
|
+
},
|
|
1169
|
+
credentialTypes: [WOOCOMMERCE_CREDENTIAL],
|
|
1170
|
+
ports: {
|
|
1171
|
+
in: ["in"],
|
|
1172
|
+
out: ["out"]
|
|
1173
|
+
},
|
|
1174
|
+
subtitle: (config) => typeof config.operation === "string" ? `${config.operation}: ${String(config.resource ?? "product")}` : void 0,
|
|
1175
|
+
async run({ config, credential, signal }) {
|
|
1176
|
+
const access = wooAccess(credential);
|
|
1177
|
+
const options = {
|
|
1178
|
+
signal,
|
|
1179
|
+
timeoutMs: config.timeoutMs
|
|
1180
|
+
};
|
|
1181
|
+
const request = buildRequest(config);
|
|
1182
|
+
if (request.list) return {
|
|
1183
|
+
port: "out",
|
|
1184
|
+
data: await callWooList(access, request.call, config.returnAll ? null : config.limit, options)
|
|
1185
|
+
};
|
|
1186
|
+
return {
|
|
1187
|
+
port: "out",
|
|
1188
|
+
data: await callWoo(access, request.call, options)
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
// src/trigger.ts
|
|
1193
|
+
const TIMEOUT_MS = 15e3;
|
|
1194
|
+
/** The most pages of webhooks that the trigger reads. */
|
|
1195
|
+
const MAX_PAGES = 20;
|
|
1196
|
+
const EVENTS = [
|
|
1197
|
+
"coupon.created",
|
|
1198
|
+
"coupon.deleted",
|
|
1199
|
+
"coupon.updated",
|
|
1200
|
+
"customer.created",
|
|
1201
|
+
"customer.deleted",
|
|
1202
|
+
"customer.updated",
|
|
1203
|
+
"order.created",
|
|
1204
|
+
"order.deleted",
|
|
1205
|
+
"order.updated",
|
|
1206
|
+
"product.created",
|
|
1207
|
+
"product.deleted",
|
|
1208
|
+
"product.updated"
|
|
1209
|
+
];
|
|
1210
|
+
const triggerConfig = zod.z.object({ event: zod.z.enum(EVENTS).default("order.created").meta({
|
|
1211
|
+
title: "Event",
|
|
1212
|
+
description: "Determines which resource events the webhook is triggered for",
|
|
1213
|
+
labels: Object.fromEntries(EVENTS.map((name) => [name, name]))
|
|
1214
|
+
}) });
|
|
1215
|
+
/** The value of a header. The name is not case sensitive. */
|
|
1216
|
+
function header(headers, name) {
|
|
1217
|
+
const wanted = name.toLowerCase();
|
|
1218
|
+
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === wanted) return value;
|
|
1219
|
+
}
|
|
1220
|
+
/** The signature of WooCommerce: the base64 HMAC-SHA256 of the raw body, with the secret as key. */
|
|
1221
|
+
function wooSignature(secret, rawBody) {
|
|
1222
|
+
return (0, node_crypto.createHmac)("sha256", secret).update(rawBody).digest("base64");
|
|
1223
|
+
}
|
|
1224
|
+
/** True when the signature header is the signature of the body. */
|
|
1225
|
+
function verifyWooSignature(secret, rawBody, given) {
|
|
1226
|
+
if (!given) return false;
|
|
1227
|
+
const wanted = Buffer.from(wooSignature(secret, rawBody));
|
|
1228
|
+
const actual = Buffer.from(given.trim());
|
|
1229
|
+
return actual.byteLength === wanted.byteLength && (0, node_crypto.timingSafeEqual)(actual, wanted);
|
|
1230
|
+
}
|
|
1231
|
+
const ignored = () => ({
|
|
1232
|
+
verdict: "ignore",
|
|
1233
|
+
response: {
|
|
1234
|
+
status: 200,
|
|
1235
|
+
body: { ok: true }
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
/** The body of an event: parsed JSON, or the text of the raw body. */
|
|
1239
|
+
function bodyOf(request) {
|
|
1240
|
+
if (request.body !== void 0 && request.body !== null && request.body !== "") return request.body;
|
|
1241
|
+
try {
|
|
1242
|
+
return JSON.parse(request.rawBody ?? "null");
|
|
1243
|
+
} catch {
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Decides about a request. WooCommerce signs each event with the secret of the webhook. A
|
|
1249
|
+
* request with no webhook ID (the ping of a new webhook) gets status 200 and starts no run.
|
|
1250
|
+
*/
|
|
1251
|
+
function checkWooEvent(config, secret, request) {
|
|
1252
|
+
if (request.method.toUpperCase() !== "POST") return ignored();
|
|
1253
|
+
const signature = header(request.headers, "x-wc-webhook-signature");
|
|
1254
|
+
if (header(request.headers, "x-wc-webhook-id") === void 0 && signature === void 0) return ignored();
|
|
1255
|
+
if (typeof request.rawBody !== "string" || !verifyWooSignature(secret, request.rawBody, signature)) return {
|
|
1256
|
+
verdict: "forbidden",
|
|
1257
|
+
status: 401
|
|
1258
|
+
};
|
|
1259
|
+
const topic = header(request.headers, "x-wc-webhook-topic");
|
|
1260
|
+
if (topic !== void 0 && topic !== config.event) return ignored();
|
|
1261
|
+
return {
|
|
1262
|
+
verdict: "accept",
|
|
1263
|
+
input: bodyOf(request)
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
async function deleteHook(access, webhookId, options) {
|
|
1267
|
+
try {
|
|
1268
|
+
await callWoo(access, {
|
|
1269
|
+
method: "DELETE",
|
|
1270
|
+
path: `/webhooks/${encodeURIComponent(String(webhookId))}`,
|
|
1271
|
+
query: { force: true }
|
|
1272
|
+
}, options);
|
|
1273
|
+
} catch (error) {
|
|
1274
|
+
if (!/\(404\)/.test(String(error))) throw error;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
/** Removes each webhook of the store that has this address and this event. */
|
|
1278
|
+
async function removeHooks(access, url, event, options) {
|
|
1279
|
+
const ids = [];
|
|
1280
|
+
for (let page = 1; page <= MAX_PAGES; page += 1) {
|
|
1281
|
+
const answer = await callWoo(access, {
|
|
1282
|
+
method: "GET",
|
|
1283
|
+
path: "/webhooks",
|
|
1284
|
+
query: {
|
|
1285
|
+
per_page: 100,
|
|
1286
|
+
page
|
|
1287
|
+
}
|
|
1288
|
+
}, options);
|
|
1289
|
+
if (!Array.isArray(answer) || answer.length === 0) break;
|
|
1290
|
+
for (const hook of answer) if (hook.delivery_url === url && hook.topic === event && hook.id !== void 0) ids.push(hook.id);
|
|
1291
|
+
if (answer.length < 100) break;
|
|
1292
|
+
}
|
|
1293
|
+
for (const id of ids) await deleteHook(access, id, options);
|
|
1294
|
+
}
|
|
1295
|
+
// src/index.ts
|
|
1296
|
+
const nodes = [(0, _zerodot_node_sdk.defineNode)({
|
|
1297
|
+
type: "trigger.woocommerce",
|
|
1298
|
+
label: "WooCommerce Trigger",
|
|
1299
|
+
description: "Start the workflow when a coupon, customer, order, or product changes",
|
|
1300
|
+
category: "trigger",
|
|
1301
|
+
app: "WooCommerce",
|
|
1302
|
+
icon: "ShoppingCart01Icon",
|
|
1303
|
+
iconUrl: WOOCOMMERCE_ICON,
|
|
1304
|
+
config: triggerConfig,
|
|
1305
|
+
defaultConfig: { event: "order.created" },
|
|
1306
|
+
credentialTypes: [WOOCOMMERCE_CREDENTIAL],
|
|
1307
|
+
ports: {
|
|
1308
|
+
in: [],
|
|
1309
|
+
out: ["out"]
|
|
1310
|
+
},
|
|
1311
|
+
subtitle: (config) => typeof config.event === "string" ? config.event : void 0,
|
|
1312
|
+
run: ({ input }) => ({
|
|
1313
|
+
port: "out",
|
|
1314
|
+
data: input
|
|
1315
|
+
}),
|
|
1316
|
+
webhook: {
|
|
1317
|
+
async receive({ config: raw, state, request }) {
|
|
1318
|
+
const secret = state?.secret;
|
|
1319
|
+
if (typeof secret !== "string" || secret === "") return {
|
|
1320
|
+
verdict: "forbidden",
|
|
1321
|
+
status: 401
|
|
1322
|
+
};
|
|
1323
|
+
return checkWooEvent(triggerConfig.parse(raw), secret, request);
|
|
1324
|
+
},
|
|
1325
|
+
/** Makes the webhook in the store. A webhook with this address and event is removed first. */
|
|
1326
|
+
async activate({ config: raw, credential, url, signal }) {
|
|
1327
|
+
const config = triggerConfig.parse(raw);
|
|
1328
|
+
const access = wooAccess(credential);
|
|
1329
|
+
const options = {
|
|
1330
|
+
signal,
|
|
1331
|
+
timeoutMs: TIMEOUT_MS
|
|
1332
|
+
};
|
|
1333
|
+
await removeHooks(access, url, config.event, options);
|
|
1334
|
+
const secret = (0, node_crypto.randomBytes)(32).toString("hex");
|
|
1335
|
+
const hook = await callWooObject(access, {
|
|
1336
|
+
method: "POST",
|
|
1337
|
+
path: "/webhooks",
|
|
1338
|
+
body: {
|
|
1339
|
+
delivery_url: url,
|
|
1340
|
+
topic: config.event,
|
|
1341
|
+
secret
|
|
1342
|
+
}
|
|
1343
|
+
}, options);
|
|
1344
|
+
if (typeof hook.id !== "number") throw new Error("WooCommerce did not give the ID of the webhook");
|
|
1345
|
+
return {
|
|
1346
|
+
webhookId: hook.id,
|
|
1347
|
+
secret
|
|
1348
|
+
};
|
|
1349
|
+
},
|
|
1350
|
+
/** Removes the webhook. A webhook that is gone already is fine. */
|
|
1351
|
+
async deactivate({ config: raw, credential, url, state, signal }) {
|
|
1352
|
+
const access = wooAccess(credential);
|
|
1353
|
+
const options = {
|
|
1354
|
+
signal,
|
|
1355
|
+
timeoutMs: TIMEOUT_MS
|
|
1356
|
+
};
|
|
1357
|
+
const saved = state;
|
|
1358
|
+
if (saved?.webhookId !== void 0) await deleteHook(access, saved.webhookId, options);
|
|
1359
|
+
else await removeHooks(access, url, triggerConfig.parse(raw).event, options);
|
|
1360
|
+
return null;
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
webhookTest: { hint: "A test run makes a webhook in the store for the test address. Change a coupon, customer, order, or product of the event to send it" }
|
|
1364
|
+
}), node_default];
|
|
1365
|
+
const credentialTypes = [woocommerceCredential];
|
|
1366
|
+
exports.credentialTypes = credentialTypes;
|
|
1367
|
+
exports.nodes = nodes;
|