@atomic-solutions/woocommerce-api-client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/client/index.d.mts +9 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +1461 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +1455 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/http/index.d.mts +11 -0
- package/dist/http/index.d.ts +11 -0
- package/dist/http/index.js +638 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/index.mjs +631 -0
- package/dist/http/index.mjs.map +1 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +2152 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2105 -0
- package/dist/index.mjs.map +1 -0
- package/dist/pagination.schema-CdjWGZJr.d.mts +190 -0
- package/dist/pagination.schema-CdjWGZJr.d.ts +190 -0
- package/dist/products-Cxl54crz.d.mts +3412 -0
- package/dist/products-Cxl54crz.d.ts +3412 -0
- package/dist/schemas/admin-api/index.d.mts +5340 -0
- package/dist/schemas/admin-api/index.d.ts +5340 -0
- package/dist/schemas/admin-api/index.js +584 -0
- package/dist/schemas/admin-api/index.js.map +1 -0
- package/dist/schemas/admin-api/index.mjs +545 -0
- package/dist/schemas/admin-api/index.mjs.map +1 -0
- package/dist/schemas/index.d.mts +4 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.js +887 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/index.mjs +844 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas/store-api/index.d.mts +1076 -0
- package/dist/schemas/store-api/index.d.ts +1076 -0
- package/dist/schemas/store-api/index.js +887 -0
- package/dist/schemas/store-api/index.js.map +1 -0
- package/dist/schemas/store-api/index.mjs +844 -0
- package/dist/schemas/store-api/index.mjs.map +1 -0
- package/dist/types-B-zy1xrP.d.mts +183 -0
- package/dist/types-qKWtrw7A.d.ts +183 -0
- package/dist/utils/index.d.mts +17 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +316 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +308 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +117 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var axios = require('axios');
|
|
4
|
+
var zod = require('zod');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
9
|
+
|
|
10
|
+
// src/client/createClient.ts
|
|
11
|
+
|
|
12
|
+
// src/errors/classes/BaseError.ts
|
|
13
|
+
var BaseError = class extends Error {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options.message);
|
|
16
|
+
this.options = options;
|
|
17
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
18
|
+
this.name = this.constructor.name;
|
|
19
|
+
if (Error.captureStackTrace) {
|
|
20
|
+
Error.captureStackTrace(this, this.constructor);
|
|
21
|
+
}
|
|
22
|
+
if (this.options.cause instanceof Error && this.options.cause.stack) {
|
|
23
|
+
this.stack = `${this.stack}
|
|
24
|
+
Caused by: ${this.options.cause.stack}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get reportable data for error tracking/logging
|
|
29
|
+
* Subclasses should override this to add their own reportable fields
|
|
30
|
+
*/
|
|
31
|
+
getReportableData() {
|
|
32
|
+
const { code, operation, userMessage, retryable } = this.options;
|
|
33
|
+
return {
|
|
34
|
+
code,
|
|
35
|
+
operation,
|
|
36
|
+
userMessage,
|
|
37
|
+
retryable
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custom JSON serialization
|
|
42
|
+
* Makes the error properly serializable for logging/reporting
|
|
43
|
+
*/
|
|
44
|
+
toJSON() {
|
|
45
|
+
return {
|
|
46
|
+
...this.getReportableData(),
|
|
47
|
+
name: this.name,
|
|
48
|
+
message: this.message,
|
|
49
|
+
stack: this.stack
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/errors/mapping/mapWooCommerceCode.ts
|
|
55
|
+
var mapWooCommerceCode = (apiCode) => {
|
|
56
|
+
const directMatches = {
|
|
57
|
+
woocommerce_rest_cart_empty: "cart_empty",
|
|
58
|
+
woocommerce_rest_cart_coupon_error: "invalid_coupon",
|
|
59
|
+
woocommerce_rest_missing_nonce: "missing_nonce",
|
|
60
|
+
woocommerce_rest_invalid_nonce: "invalid_nonce",
|
|
61
|
+
rest_invalid_param: "invalid_params",
|
|
62
|
+
woocommerce_rest_product_invalid_id: "product_not_found",
|
|
63
|
+
woocommerce_rest_product_out_of_stock: "out_of_stock",
|
|
64
|
+
woocommerce_rest_product_not_enough_stock: "insufficient_stock",
|
|
65
|
+
woocommerce_rest_checkout_invalid_payment_method: "invalid_payment_method"
|
|
66
|
+
};
|
|
67
|
+
if (directMatches[apiCode]) {
|
|
68
|
+
return directMatches[apiCode];
|
|
69
|
+
}
|
|
70
|
+
if (apiCode.includes("nonce")) return "invalid_nonce";
|
|
71
|
+
if (apiCode.includes("coupon")) return "invalid_coupon";
|
|
72
|
+
if (apiCode.includes("stock")) return "insufficient_stock";
|
|
73
|
+
if (apiCode.includes("checkout")) return "checkout_error";
|
|
74
|
+
if (apiCode.includes("payment")) return "invalid_payment_method";
|
|
75
|
+
return "unknown_error";
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/errors/mapping/constants.ts
|
|
79
|
+
var WOOCOMMERCE_ERROR_METADATA = {
|
|
80
|
+
cart_empty: {
|
|
81
|
+
operation: "get_cart",
|
|
82
|
+
retryable: false,
|
|
83
|
+
userMessage: "Your cart is empty"
|
|
84
|
+
},
|
|
85
|
+
invalid_coupon: {
|
|
86
|
+
operation: "apply_coupon",
|
|
87
|
+
retryable: false,
|
|
88
|
+
userMessage: "Invalid coupon code"
|
|
89
|
+
},
|
|
90
|
+
missing_nonce: {
|
|
91
|
+
operation: "cart_request",
|
|
92
|
+
retryable: true
|
|
93
|
+
// Auto-retry with new nonce
|
|
94
|
+
},
|
|
95
|
+
invalid_nonce: {
|
|
96
|
+
operation: "cart_request",
|
|
97
|
+
retryable: true
|
|
98
|
+
// Auto-retry with new nonce
|
|
99
|
+
},
|
|
100
|
+
invalid_params: {
|
|
101
|
+
operation: "api_request",
|
|
102
|
+
retryable: false,
|
|
103
|
+
userMessage: "Invalid request parameters"
|
|
104
|
+
},
|
|
105
|
+
product_not_found: {
|
|
106
|
+
operation: "get_product",
|
|
107
|
+
retryable: false,
|
|
108
|
+
userMessage: "Product not found"
|
|
109
|
+
},
|
|
110
|
+
out_of_stock: {
|
|
111
|
+
operation: "add_to_cart",
|
|
112
|
+
retryable: false,
|
|
113
|
+
userMessage: "This product is out of stock"
|
|
114
|
+
},
|
|
115
|
+
insufficient_stock: {
|
|
116
|
+
operation: "add_to_cart",
|
|
117
|
+
retryable: false,
|
|
118
|
+
userMessage: "Not enough stock available"
|
|
119
|
+
},
|
|
120
|
+
invalid_payment_method: {
|
|
121
|
+
operation: "process_checkout",
|
|
122
|
+
retryable: false,
|
|
123
|
+
userMessage: "Invalid payment method"
|
|
124
|
+
},
|
|
125
|
+
checkout_error: {
|
|
126
|
+
operation: "process_checkout",
|
|
127
|
+
retryable: false
|
|
128
|
+
},
|
|
129
|
+
network_error: {
|
|
130
|
+
operation: "network_request",
|
|
131
|
+
retryable: true
|
|
132
|
+
},
|
|
133
|
+
unknown_error: {
|
|
134
|
+
operation: "unknown",
|
|
135
|
+
retryable: false
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// src/errors/classes/WooCommerceApiError.ts
|
|
140
|
+
var WooCommerceApiError = class extends BaseError {
|
|
141
|
+
constructor(options) {
|
|
142
|
+
const metadata = WOOCOMMERCE_ERROR_METADATA[options.code] ?? {
|
|
143
|
+
operation: "woocommerce_api_request",
|
|
144
|
+
retryable: false
|
|
145
|
+
};
|
|
146
|
+
const enrichedOptions = {
|
|
147
|
+
...options,
|
|
148
|
+
operation: options.operation || metadata.operation,
|
|
149
|
+
userMessage: options.userMessage || metadata.userMessage,
|
|
150
|
+
retryable: options.retryable ?? metadata.retryable
|
|
151
|
+
};
|
|
152
|
+
super(enrichedOptions);
|
|
153
|
+
}
|
|
154
|
+
// Convenient getters for frequently accessed fields (no duplication)
|
|
155
|
+
get wooCode() {
|
|
156
|
+
return this.options.code;
|
|
157
|
+
}
|
|
158
|
+
get originalCode() {
|
|
159
|
+
return this.options.originalCode;
|
|
160
|
+
}
|
|
161
|
+
get statusCode() {
|
|
162
|
+
return this.options.statusCode;
|
|
163
|
+
}
|
|
164
|
+
get url() {
|
|
165
|
+
return this.options.url;
|
|
166
|
+
}
|
|
167
|
+
get method() {
|
|
168
|
+
return this.options.method;
|
|
169
|
+
}
|
|
170
|
+
get requestBody() {
|
|
171
|
+
return this.options.requestBody;
|
|
172
|
+
}
|
|
173
|
+
get responseBody() {
|
|
174
|
+
return this.options.responseBody;
|
|
175
|
+
}
|
|
176
|
+
get data() {
|
|
177
|
+
return this.options.data;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get reportable data for error tracking/logging
|
|
181
|
+
* Includes HTTP context and WooCommerce-specific fields
|
|
182
|
+
*/
|
|
183
|
+
getReportableData() {
|
|
184
|
+
return {
|
|
185
|
+
code: this.options.code,
|
|
186
|
+
operation: this.options.operation,
|
|
187
|
+
userMessage: this.options.userMessage,
|
|
188
|
+
retryable: this.options.retryable,
|
|
189
|
+
statusCode: this.options.statusCode,
|
|
190
|
+
url: this.options.url,
|
|
191
|
+
method: this.options.method,
|
|
192
|
+
wooCode: this.options.code,
|
|
193
|
+
originalCode: this.options.originalCode
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/errors/classes/WooCommerceDataValidationError.ts
|
|
199
|
+
var WooCommerceDataValidationError = class _WooCommerceDataValidationError extends BaseError {
|
|
200
|
+
constructor(options) {
|
|
201
|
+
const fieldErrors = options.zodError ? _WooCommerceDataValidationError.extractFieldErrorsFromZod(options.zodError) : void 0;
|
|
202
|
+
super({
|
|
203
|
+
code: "validation_error",
|
|
204
|
+
message: options.message,
|
|
205
|
+
operation: options.operation,
|
|
206
|
+
userMessage: options.userMessage || "Received unexpected data from WooCommerce",
|
|
207
|
+
retryable: false,
|
|
208
|
+
cause: options.cause,
|
|
209
|
+
url: options.url,
|
|
210
|
+
zodError: options.zodError,
|
|
211
|
+
value: options.value,
|
|
212
|
+
fieldErrors
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// Convenient getters for validation-specific fields (no duplication)
|
|
216
|
+
get url() {
|
|
217
|
+
return this.options.url;
|
|
218
|
+
}
|
|
219
|
+
get zodError() {
|
|
220
|
+
return this.options.zodError;
|
|
221
|
+
}
|
|
222
|
+
get invalidValue() {
|
|
223
|
+
return this.options.value;
|
|
224
|
+
}
|
|
225
|
+
get fieldErrors() {
|
|
226
|
+
return this.options.fieldErrors;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get reportable data for error tracking/logging
|
|
230
|
+
* Includes validation-specific fields
|
|
231
|
+
*/
|
|
232
|
+
getReportableData() {
|
|
233
|
+
return {
|
|
234
|
+
code: this.options.code,
|
|
235
|
+
operation: this.options.operation,
|
|
236
|
+
userMessage: this.options.userMessage,
|
|
237
|
+
retryable: false,
|
|
238
|
+
fieldErrors: this.options.fieldErrors,
|
|
239
|
+
url: this.options.url
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Extract field errors from Zod error
|
|
244
|
+
*/
|
|
245
|
+
static extractFieldErrorsFromZod(zodError) {
|
|
246
|
+
if (!zodError?.errors) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
const fieldErrors = {};
|
|
250
|
+
for (const issue of zodError.errors) {
|
|
251
|
+
const path = issue.path.join(".");
|
|
252
|
+
if (!fieldErrors[path]) {
|
|
253
|
+
fieldErrors[path] = [];
|
|
254
|
+
}
|
|
255
|
+
fieldErrors[path].push(issue.message);
|
|
256
|
+
}
|
|
257
|
+
return fieldErrors;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Get all error messages as a flat array
|
|
261
|
+
*/
|
|
262
|
+
getMessages() {
|
|
263
|
+
if (!this.fieldErrors) {
|
|
264
|
+
return [this.message];
|
|
265
|
+
}
|
|
266
|
+
const messages = [];
|
|
267
|
+
for (const fieldMessages of Object.values(this.fieldErrors)) {
|
|
268
|
+
messages.push(...fieldMessages);
|
|
269
|
+
}
|
|
270
|
+
return messages;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Check if a specific field has errors
|
|
274
|
+
*/
|
|
275
|
+
hasFieldError(field) {
|
|
276
|
+
return this.fieldErrors ? field in this.fieldErrors : false;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get error messages for a specific field
|
|
280
|
+
*/
|
|
281
|
+
getFieldError(field) {
|
|
282
|
+
return this.fieldErrors?.[field];
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/http/handleApiResponse.ts
|
|
287
|
+
var handleApiResponse = (response, schema, options) => {
|
|
288
|
+
const validationMode = options?.validationMode ?? "strict";
|
|
289
|
+
if (validationMode === "warn") {
|
|
290
|
+
const result = schema.safeParse(response.data);
|
|
291
|
+
if (!result.success) {
|
|
292
|
+
const validationError = new WooCommerceDataValidationError({
|
|
293
|
+
message: `WooCommerce API response validation failed for ${response.config.url || "unknown endpoint"}`,
|
|
294
|
+
url: response.config.url,
|
|
295
|
+
zodError: result.error,
|
|
296
|
+
value: response.data,
|
|
297
|
+
userMessage: "Received unexpected data from WooCommerce"
|
|
298
|
+
});
|
|
299
|
+
options?.onValidationError?.(validationError);
|
|
300
|
+
options?.errorReporter?.(validationError);
|
|
301
|
+
console.warn("[woocommerce-utils] Validation warning:", validationError.message);
|
|
302
|
+
return response.data;
|
|
303
|
+
}
|
|
304
|
+
return result.data;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return schema.parse(response.data);
|
|
308
|
+
} catch (error2) {
|
|
309
|
+
if (error2 && typeof error2 === "object" && "issues" in error2) {
|
|
310
|
+
const validationError = new WooCommerceDataValidationError({
|
|
311
|
+
message: `WooCommerce API response validation failed for ${response.config.url || "unknown endpoint"}`,
|
|
312
|
+
url: response.config.url,
|
|
313
|
+
zodError: error2,
|
|
314
|
+
value: response.data,
|
|
315
|
+
userMessage: "Received unexpected data from WooCommerce"
|
|
316
|
+
});
|
|
317
|
+
options?.onValidationError?.(validationError);
|
|
318
|
+
options?.errorReporter?.(validationError);
|
|
319
|
+
throw validationError;
|
|
320
|
+
}
|
|
321
|
+
throw error2;
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/utils/calculatePagination.ts
|
|
326
|
+
var calculatePagination = (input) => {
|
|
327
|
+
const { page, perPage, total, totalPages } = input;
|
|
328
|
+
const hasNextPage = page < totalPages;
|
|
329
|
+
const hasPrevPage = page > 1;
|
|
330
|
+
return {
|
|
331
|
+
page,
|
|
332
|
+
perPage,
|
|
333
|
+
total,
|
|
334
|
+
totalPages,
|
|
335
|
+
hasNextPage,
|
|
336
|
+
hasPrevPage,
|
|
337
|
+
nextPage: hasNextPage ? page + 1 : null,
|
|
338
|
+
prevPage: hasPrevPage ? page - 1 : null
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/utils/getPaginationMeta.ts
|
|
343
|
+
var getPaginationMeta = (headers) => {
|
|
344
|
+
if (!headers) {
|
|
345
|
+
return {
|
|
346
|
+
total: 0,
|
|
347
|
+
totalPages: 0
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const wpTotal = headers["x-wp-total"];
|
|
351
|
+
const wpTotalPages = headers["x-wp-totalpages"];
|
|
352
|
+
if (!wpTotal || !wpTotalPages) {
|
|
353
|
+
return {
|
|
354
|
+
total: 0,
|
|
355
|
+
totalPages: 0
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const total = parseInt(wpTotal, 10);
|
|
359
|
+
const totalPages = parseInt(wpTotalPages, 10);
|
|
360
|
+
return {
|
|
361
|
+
total,
|
|
362
|
+
totalPages
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/http/handlePaginatedApiResponse.ts
|
|
367
|
+
var handlePaginatedApiResponse = (response, schema, params = {}, options) => {
|
|
368
|
+
const validationMode = options?.validationMode ?? "strict";
|
|
369
|
+
let data;
|
|
370
|
+
if (validationMode === "warn") {
|
|
371
|
+
const result = schema.safeParse(response.data);
|
|
372
|
+
if (!result.success) {
|
|
373
|
+
const validationError = new WooCommerceDataValidationError({
|
|
374
|
+
message: `WooCommerce API response validation failed for ${response.config.url || "unknown endpoint"}`,
|
|
375
|
+
url: response.config.url,
|
|
376
|
+
zodError: result.error,
|
|
377
|
+
value: response.data,
|
|
378
|
+
userMessage: "Received unexpected data from WooCommerce"
|
|
379
|
+
});
|
|
380
|
+
options?.onValidationError?.(validationError);
|
|
381
|
+
options?.errorReporter?.(validationError);
|
|
382
|
+
console.warn("[woocommerce-utils] Validation warning:", validationError.message);
|
|
383
|
+
data = Array.isArray(response.data) ? response.data : [];
|
|
384
|
+
} else {
|
|
385
|
+
data = result.data;
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
try {
|
|
389
|
+
data = schema.parse(response.data);
|
|
390
|
+
} catch (error2) {
|
|
391
|
+
if (error2 && typeof error2 === "object" && "issues" in error2) {
|
|
392
|
+
const validationError = new WooCommerceDataValidationError({
|
|
393
|
+
message: `WooCommerce API response validation failed for ${response.config.url || "unknown endpoint"}`,
|
|
394
|
+
url: response.config.url,
|
|
395
|
+
zodError: error2,
|
|
396
|
+
value: response.data,
|
|
397
|
+
userMessage: "Received unexpected data from WooCommerce"
|
|
398
|
+
});
|
|
399
|
+
options?.onValidationError?.(validationError);
|
|
400
|
+
options?.errorReporter?.(validationError);
|
|
401
|
+
throw validationError;
|
|
402
|
+
}
|
|
403
|
+
throw error2;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const { total, totalPages } = getPaginationMeta(response.headers);
|
|
407
|
+
const page = params.page || 1;
|
|
408
|
+
const perPage = params.per_page || 10;
|
|
409
|
+
const pagination = calculatePagination({
|
|
410
|
+
page,
|
|
411
|
+
perPage,
|
|
412
|
+
total,
|
|
413
|
+
totalPages
|
|
414
|
+
});
|
|
415
|
+
return {
|
|
416
|
+
data,
|
|
417
|
+
pagination
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// src/logging/logger.ts
|
|
422
|
+
var DEBUG_PREFIX = "[woocommerce-utils]";
|
|
423
|
+
var isDebugEnabled = () => {
|
|
424
|
+
if (typeof process !== "undefined" && process.env) {
|
|
425
|
+
return process.env.DEBUG === "true" || process.env.DEBUG === "1";
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
};
|
|
429
|
+
var debug = (...args) => {
|
|
430
|
+
if (isDebugEnabled()) {
|
|
431
|
+
console.log(DEBUG_PREFIX, ...args);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
var error = (...args) => {
|
|
435
|
+
console.error(DEBUG_PREFIX, ...args);
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
// src/http/interceptors/request.ts
|
|
439
|
+
var requiresAuth = (url) => {
|
|
440
|
+
if (!url) return false;
|
|
441
|
+
const authEndpoints = ["/jwt-auth/", "/customers/me", "/wp/v2/users/me"];
|
|
442
|
+
return authEndpoints.some((endpoint) => url.includes(endpoint));
|
|
443
|
+
};
|
|
444
|
+
var requiresCartAuth = (url) => {
|
|
445
|
+
if (!url) return false;
|
|
446
|
+
return /\/wc\/store\/(v\d+\/)?cart/.test(url) || /\/wc\/store\/(v\d+\/)?checkout/.test(url);
|
|
447
|
+
};
|
|
448
|
+
var setupRequestInterceptor = (axiosInstance, config, client) => {
|
|
449
|
+
axiosInstance.interceptors.request.use(
|
|
450
|
+
async (requestConfig) => {
|
|
451
|
+
const url = requestConfig.url;
|
|
452
|
+
if (requiresAuth(url) && config.jwtToken) {
|
|
453
|
+
const token = await config.jwtToken.get();
|
|
454
|
+
if (token) {
|
|
455
|
+
requestConfig.headers.Authorization = `Bearer ${token}`;
|
|
456
|
+
if (config.debug) {
|
|
457
|
+
debug("Injected JWT token for", url);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (requiresCartAuth(url)) {
|
|
462
|
+
const headers = await config.cartHeaders.get();
|
|
463
|
+
if (headers.nonce) {
|
|
464
|
+
requestConfig.headers.Nonce = headers.nonce;
|
|
465
|
+
}
|
|
466
|
+
if (headers.cartToken) {
|
|
467
|
+
requestConfig.headers["Cart-Token"] = headers.cartToken;
|
|
468
|
+
}
|
|
469
|
+
requestConfig.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
|
470
|
+
requestConfig.headers.Pragma = "no-cache";
|
|
471
|
+
requestConfig.headers.Expires = "0";
|
|
472
|
+
if (config.debug) {
|
|
473
|
+
debug("Injected cart headers for", url, {
|
|
474
|
+
hasNonce: !!headers.nonce,
|
|
475
|
+
hasCartToken: !!headers.cartToken
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (config.debug) {
|
|
480
|
+
debug(
|
|
481
|
+
`${requestConfig.method?.toUpperCase()} ${requestConfig.url}`,
|
|
482
|
+
requestConfig.params || requestConfig.data
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
if (config.onRequest) {
|
|
486
|
+
return config.onRequest(requestConfig, client);
|
|
487
|
+
}
|
|
488
|
+
return requestConfig;
|
|
489
|
+
},
|
|
490
|
+
(error2) => {
|
|
491
|
+
return Promise.reject(error2);
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
// src/http/interceptors/response.ts
|
|
497
|
+
var isCartResponse = (url) => {
|
|
498
|
+
if (!url) return false;
|
|
499
|
+
return /\/wc\/store\/(v\d+\/)?cart/.test(url) || /\/wc\/store\/(v\d+\/)?checkout/.test(url);
|
|
500
|
+
};
|
|
501
|
+
var setupResponseInterceptor = (axiosInstance, config, client) => {
|
|
502
|
+
axiosInstance.interceptors.response.use(
|
|
503
|
+
async (response) => {
|
|
504
|
+
if (isCartResponse(response.config.url)) {
|
|
505
|
+
const nonce = response.headers["nonce"] || response.headers["Nonce"];
|
|
506
|
+
const cartToken = response.headers["cart-token"] || response.headers["Cart-Token"];
|
|
507
|
+
if (nonce || cartToken) {
|
|
508
|
+
await config.cartHeaders.save({
|
|
509
|
+
nonce: nonce || void 0,
|
|
510
|
+
cartToken: cartToken || void 0
|
|
511
|
+
});
|
|
512
|
+
if (config.debug) {
|
|
513
|
+
debug(
|
|
514
|
+
"Saved updated cart headers:",
|
|
515
|
+
response.config.url,
|
|
516
|
+
"nonce:",
|
|
517
|
+
!!nonce,
|
|
518
|
+
"cartToken:",
|
|
519
|
+
!!cartToken
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (config.debug) {
|
|
525
|
+
debug("Response:", response.config.url, response.status);
|
|
526
|
+
}
|
|
527
|
+
if (config.onResponse) {
|
|
528
|
+
return config.onResponse(response, client);
|
|
529
|
+
}
|
|
530
|
+
return response;
|
|
531
|
+
},
|
|
532
|
+
(error2) => {
|
|
533
|
+
return Promise.reject(error2);
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// src/utils/initializeCartSession.ts
|
|
539
|
+
var initializeCartSession = async (client, cartHeaders) => {
|
|
540
|
+
try {
|
|
541
|
+
debug("session", "Initializing cart session");
|
|
542
|
+
const response = await client.get("/wc/store/v1/cart");
|
|
543
|
+
const nonce = response.headers["nonce"] || response.headers["Nonce"];
|
|
544
|
+
const cartToken = response.headers["cart-token"] || response.headers["Cart-Token"];
|
|
545
|
+
if (nonce || cartToken) {
|
|
546
|
+
await cartHeaders.save({
|
|
547
|
+
nonce: nonce || void 0,
|
|
548
|
+
cartToken: cartToken || void 0
|
|
549
|
+
});
|
|
550
|
+
debug("session", "Cart session initialized", {
|
|
551
|
+
hasNonce: !!nonce,
|
|
552
|
+
hasCartToken: !!cartToken
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
} catch (error2) {
|
|
556
|
+
debug("session", "Failed to initialize cart session", error2);
|
|
557
|
+
throw error2;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// src/http/interceptors/error.ts
|
|
562
|
+
var setupErrorInterceptor = (axiosInstance, config, client) => {
|
|
563
|
+
axiosInstance.interceptors.response.use(
|
|
564
|
+
(response) => response,
|
|
565
|
+
async (axiosError) => {
|
|
566
|
+
const status = axiosError.response?.status || 500;
|
|
567
|
+
const errorData = axiosError.response?.data;
|
|
568
|
+
const apiCode = errorData?.code || "unknown_error";
|
|
569
|
+
const wpMessage = errorData?.message || axiosError.message || "Unknown error";
|
|
570
|
+
const errorCode = mapWooCommerceCode(apiCode);
|
|
571
|
+
const errorMetadata = WOOCOMMERCE_ERROR_METADATA[errorCode];
|
|
572
|
+
const wcError = new WooCommerceApiError({
|
|
573
|
+
message: wpMessage,
|
|
574
|
+
statusCode: status,
|
|
575
|
+
code: errorCode,
|
|
576
|
+
// Transformed app-level code
|
|
577
|
+
originalCode: apiCode,
|
|
578
|
+
// Original WooCommerce API code
|
|
579
|
+
retryable: errorMetadata.retryable,
|
|
580
|
+
userMessage: errorMetadata.userMessage,
|
|
581
|
+
operation: errorMetadata.operation,
|
|
582
|
+
url: axiosError.config?.url || "",
|
|
583
|
+
method: axiosError.config?.method?.toUpperCase() || "GET",
|
|
584
|
+
requestBody: axiosError.config?.data,
|
|
585
|
+
responseBody: errorData,
|
|
586
|
+
data: errorData?.data,
|
|
587
|
+
cause: axiosError
|
|
588
|
+
});
|
|
589
|
+
if (config.debug) {
|
|
590
|
+
debug("WooCommerce error:", apiCode, status, wpMessage);
|
|
591
|
+
error(wcError);
|
|
592
|
+
}
|
|
593
|
+
if ((status === 401 || status === 403) && config.onAuthError && axios.isAxiosError(axiosError) && !axiosError.config?._retry) {
|
|
594
|
+
if (config.debug) {
|
|
595
|
+
debug("Auth error detected, calling onAuthError handler");
|
|
596
|
+
}
|
|
597
|
+
try {
|
|
598
|
+
const shouldRetry = await config.onAuthError(wcError, client);
|
|
599
|
+
if (shouldRetry) {
|
|
600
|
+
if (config.debug) {
|
|
601
|
+
debug("Retrying request after auth error");
|
|
602
|
+
}
|
|
603
|
+
axiosError.config._retry = true;
|
|
604
|
+
return axiosInstance.request(axiosError.config);
|
|
605
|
+
}
|
|
606
|
+
} catch (authErrorHandlerError) {
|
|
607
|
+
if (config.debug) {
|
|
608
|
+
debug("onAuthError handler threw error", authErrorHandlerError);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (config.onError) {
|
|
613
|
+
config.onError(wcError, client);
|
|
614
|
+
}
|
|
615
|
+
const isNonceError = errorCode === "missing_nonce" || errorCode === "invalid_nonce";
|
|
616
|
+
if (isNonceError && axios.isAxiosError(axiosError) && !axiosError.config?._retry) {
|
|
617
|
+
if (config.debug) {
|
|
618
|
+
debug("Nonce error detected, retrying with new session");
|
|
619
|
+
}
|
|
620
|
+
try {
|
|
621
|
+
await initializeCartSession(axiosInstance, config.cartHeaders);
|
|
622
|
+
axiosError.config._retry = true;
|
|
623
|
+
return axiosInstance.request(axiosError.config);
|
|
624
|
+
} catch (_retryError) {
|
|
625
|
+
config.errorReporter?.report(wcError);
|
|
626
|
+
return Promise.reject(wcError);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
config.errorReporter?.report(wcError);
|
|
630
|
+
return Promise.reject(wcError);
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
};
|
|
634
|
+
var addressSchema = zod.z.object({
|
|
635
|
+
/** First name */
|
|
636
|
+
first_name: zod.z.string().min(1, "First name is required"),
|
|
637
|
+
/** Last name */
|
|
638
|
+
last_name: zod.z.string().min(1, "Last name is required"),
|
|
639
|
+
/** Company name (optional) */
|
|
640
|
+
company: zod.z.string(),
|
|
641
|
+
/** Address line 1 */
|
|
642
|
+
address_1: zod.z.string().min(1, "Address is required"),
|
|
643
|
+
/** Address line 2 (optional) */
|
|
644
|
+
address_2: zod.z.string(),
|
|
645
|
+
/** City */
|
|
646
|
+
city: zod.z.string().min(1, "City is required"),
|
|
647
|
+
/** State/Province/Region */
|
|
648
|
+
state: zod.z.string(),
|
|
649
|
+
/** Postal code */
|
|
650
|
+
postcode: zod.z.string().min(1, "Postal code is required"),
|
|
651
|
+
/** Country code (ISO 3166-1 alpha-2) */
|
|
652
|
+
country: zod.z.string(),
|
|
653
|
+
/** Phone number */
|
|
654
|
+
phone: zod.z.string().min(1, "Phone number is required")
|
|
655
|
+
});
|
|
656
|
+
var addressSchemaNonMandatory = zod.z.object({
|
|
657
|
+
/** First name */
|
|
658
|
+
first_name: zod.z.string(),
|
|
659
|
+
/** Last name */
|
|
660
|
+
last_name: zod.z.string(),
|
|
661
|
+
/** Company name (optional) */
|
|
662
|
+
company: zod.z.string(),
|
|
663
|
+
/** Address line 1 */
|
|
664
|
+
address_1: zod.z.string(),
|
|
665
|
+
/** Address line 2 (optional) */
|
|
666
|
+
address_2: zod.z.string(),
|
|
667
|
+
/** City */
|
|
668
|
+
city: zod.z.string(),
|
|
669
|
+
/** State/Province/Region */
|
|
670
|
+
state: zod.z.string(),
|
|
671
|
+
/** Postal code */
|
|
672
|
+
postcode: zod.z.string(),
|
|
673
|
+
/** Country code (ISO 3166-1 alpha-2) */
|
|
674
|
+
country: zod.z.string(),
|
|
675
|
+
/** Phone number */
|
|
676
|
+
phone: zod.z.string()
|
|
677
|
+
});
|
|
678
|
+
var billingAddressSchemaMandatory = addressSchema.extend({
|
|
679
|
+
/** Email address (required for billing) */
|
|
680
|
+
email: zod.z.string().email("Valid email is required")
|
|
681
|
+
});
|
|
682
|
+
var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
|
|
683
|
+
/** Email address (can be null for guest carts) */
|
|
684
|
+
email: zod.z.string().nullable()
|
|
685
|
+
});
|
|
686
|
+
var moneySchema = zod.z.object({
|
|
687
|
+
/** Currency code (e.g., 'USD', 'EUR', 'BAM') */
|
|
688
|
+
currency_code: zod.z.string(),
|
|
689
|
+
/** Currency symbol (e.g., '$', '€', 'KM') */
|
|
690
|
+
currency_symbol: zod.z.string(),
|
|
691
|
+
/** Number of decimal places (e.g., 2 for dollars/euros) */
|
|
692
|
+
currency_minor_unit: zod.z.number(),
|
|
693
|
+
/** Decimal separator character (e.g., '.', ',') */
|
|
694
|
+
currency_decimal_separator: zod.z.string(),
|
|
695
|
+
/** Thousands separator character (e.g., ',', '.') */
|
|
696
|
+
currency_thousand_separator: zod.z.string(),
|
|
697
|
+
/** Currency symbol prefix (empty if symbol is suffix) */
|
|
698
|
+
currency_prefix: zod.z.string(),
|
|
699
|
+
/** Currency symbol suffix (empty if symbol is prefix) */
|
|
700
|
+
currency_suffix: zod.z.string()
|
|
701
|
+
});
|
|
702
|
+
var paginationParamsSchema = zod.z.object({
|
|
703
|
+
/** Current page number */
|
|
704
|
+
page: zod.z.number().int().positive().optional(),
|
|
705
|
+
/** Items per page */
|
|
706
|
+
per_page: zod.z.number().int().positive().max(100).optional(),
|
|
707
|
+
/** Offset for pagination */
|
|
708
|
+
offset: zod.z.number().int().nonnegative().optional(),
|
|
709
|
+
/** Sort order */
|
|
710
|
+
order: zod.z.enum(["asc", "desc"]).optional(),
|
|
711
|
+
/** Field to sort by */
|
|
712
|
+
orderby: zod.z.string().optional()
|
|
713
|
+
});
|
|
714
|
+
var paginationMetaSchema = zod.z.object({
|
|
715
|
+
/** Total number of items */
|
|
716
|
+
total: zod.z.number(),
|
|
717
|
+
/** Total number of pages */
|
|
718
|
+
totalPages: zod.z.number(),
|
|
719
|
+
/** Current page */
|
|
720
|
+
currentPage: zod.z.number(),
|
|
721
|
+
/** Items per page */
|
|
722
|
+
perPage: zod.z.number()
|
|
723
|
+
});
|
|
724
|
+
var productImageSchema = zod.z.object({
|
|
725
|
+
/** Alternative text for the image */
|
|
726
|
+
alt: zod.z.string(),
|
|
727
|
+
/** Image unique identifier */
|
|
728
|
+
id: zod.z.number(),
|
|
729
|
+
/** Image filename */
|
|
730
|
+
name: zod.z.string(),
|
|
731
|
+
/** Available image sizes in JSON format */
|
|
732
|
+
sizes: zod.z.string(),
|
|
733
|
+
/** Full-size image URL */
|
|
734
|
+
src: zod.z.string().url(),
|
|
735
|
+
/** Srcset attribute for responsive images */
|
|
736
|
+
srcset: zod.z.string(),
|
|
737
|
+
/** Thumbnail image URL */
|
|
738
|
+
thumbnail: zod.z.string().url()
|
|
739
|
+
});
|
|
740
|
+
var cartItemImageSchema = zod.z.object({
|
|
741
|
+
/** Image ID */
|
|
742
|
+
id: zod.z.number(),
|
|
743
|
+
/** Full image URL */
|
|
744
|
+
src: zod.z.string(),
|
|
745
|
+
/** Thumbnail URL */
|
|
746
|
+
thumbnail: zod.z.string(),
|
|
747
|
+
/** Responsive image srcset */
|
|
748
|
+
srcset: zod.z.string(),
|
|
749
|
+
/** Responsive image sizes */
|
|
750
|
+
sizes: zod.z.string(),
|
|
751
|
+
/** Image name */
|
|
752
|
+
name: zod.z.string(),
|
|
753
|
+
/** Image alt text */
|
|
754
|
+
alt: zod.z.string()
|
|
755
|
+
});
|
|
756
|
+
var pricesSchema = zod.z.object({
|
|
757
|
+
/** Current active price (sale price if on sale, otherwise regular) */
|
|
758
|
+
price: zod.z.string(),
|
|
759
|
+
/** Regular price (before any discounts) */
|
|
760
|
+
regular_price: zod.z.string(),
|
|
761
|
+
/** Sale price (empty string if not on sale) */
|
|
762
|
+
sale_price: zod.z.string(),
|
|
763
|
+
/** Price range for variable products (null for simple products) */
|
|
764
|
+
price_range: zod.z.object({
|
|
765
|
+
min_amount: zod.z.string(),
|
|
766
|
+
max_amount: zod.z.string()
|
|
767
|
+
}).nullable(),
|
|
768
|
+
/** Raw price data without formatting */
|
|
769
|
+
raw_prices: zod.z.object({
|
|
770
|
+
/** Decimal precision */
|
|
771
|
+
precision: zod.z.number(),
|
|
772
|
+
/** Raw price value */
|
|
773
|
+
price: zod.z.string(),
|
|
774
|
+
/** Raw regular price value */
|
|
775
|
+
regular_price: zod.z.string(),
|
|
776
|
+
/** Raw sale price value */
|
|
777
|
+
sale_price: zod.z.string()
|
|
778
|
+
}).optional()
|
|
779
|
+
}).merge(moneySchema);
|
|
780
|
+
|
|
781
|
+
// src/schemas/store-api/cart-item.schema.ts
|
|
782
|
+
var itemTotalsSchema = zod.z.object({
|
|
783
|
+
/** Subtotal before taxes */
|
|
784
|
+
line_subtotal: zod.z.string(),
|
|
785
|
+
/** Tax amount on subtotal */
|
|
786
|
+
line_subtotal_tax: zod.z.string(),
|
|
787
|
+
/** Total after discounts, before taxes */
|
|
788
|
+
line_total: zod.z.string(),
|
|
789
|
+
/** Tax amount on total */
|
|
790
|
+
line_total_tax: zod.z.string()
|
|
791
|
+
}).merge(moneySchema);
|
|
792
|
+
var cartItemSchema = zod.z.object({
|
|
793
|
+
/** Unique cart item key (use this for update/remove operations) */
|
|
794
|
+
key: zod.z.string(),
|
|
795
|
+
/** Product ID */
|
|
796
|
+
id: zod.z.number(),
|
|
797
|
+
/** Quantity of this item in cart */
|
|
798
|
+
quantity: zod.z.number(),
|
|
799
|
+
/** Quantity limits for this product */
|
|
800
|
+
quantity_limits: zod.z.object({
|
|
801
|
+
/** Minimum quantity allowed */
|
|
802
|
+
minimum: zod.z.number(),
|
|
803
|
+
/** Maximum quantity allowed */
|
|
804
|
+
maximum: zod.z.number(),
|
|
805
|
+
/** Quantity must be multiple of this value */
|
|
806
|
+
multiple_of: zod.z.number(),
|
|
807
|
+
/** Whether quantity can be changed */
|
|
808
|
+
editable: zod.z.boolean()
|
|
809
|
+
}),
|
|
810
|
+
/** Product name */
|
|
811
|
+
name: zod.z.string(),
|
|
812
|
+
/** Short product description */
|
|
813
|
+
short_description: zod.z.string(),
|
|
814
|
+
/** Full product description */
|
|
815
|
+
description: zod.z.string(),
|
|
816
|
+
/** Product SKU */
|
|
817
|
+
sku: zod.z.string(),
|
|
818
|
+
/** Remaining stock count if low (null if not low or unlimited) */
|
|
819
|
+
low_stock_remaining: zod.z.number().nullable(),
|
|
820
|
+
/** Whether backorders are allowed */
|
|
821
|
+
backorders_allowed: zod.z.boolean(),
|
|
822
|
+
/** Whether to show backorder badge */
|
|
823
|
+
show_backorder_badge: zod.z.boolean(),
|
|
824
|
+
/** Whether product can only be purchased individually */
|
|
825
|
+
sold_individually: zod.z.boolean(),
|
|
826
|
+
/** Product permalink URL */
|
|
827
|
+
permalink: zod.z.string(),
|
|
828
|
+
/** Product images */
|
|
829
|
+
images: zod.z.array(cartItemImageSchema),
|
|
830
|
+
/** Variation attributes (for variable products) */
|
|
831
|
+
variation: zod.z.array(
|
|
832
|
+
zod.z.object({
|
|
833
|
+
/** Attribute name (e.g., 'Color', 'Size') */
|
|
834
|
+
attribute: zod.z.string(),
|
|
835
|
+
/** Selected value (e.g., 'Red', 'Large') */
|
|
836
|
+
value: zod.z.string()
|
|
837
|
+
})
|
|
838
|
+
),
|
|
839
|
+
/** Additional item data/metadata */
|
|
840
|
+
item_data: zod.z.array(
|
|
841
|
+
zod.z.object({
|
|
842
|
+
key: zod.z.string(),
|
|
843
|
+
value: zod.z.string()
|
|
844
|
+
})
|
|
845
|
+
),
|
|
846
|
+
/** Product pricing information */
|
|
847
|
+
prices: pricesSchema,
|
|
848
|
+
/** Line item totals */
|
|
849
|
+
totals: itemTotalsSchema,
|
|
850
|
+
/** Catalog visibility setting */
|
|
851
|
+
catalog_visibility: zod.z.string(),
|
|
852
|
+
/** Product type */
|
|
853
|
+
type: zod.z.enum(["simple", "variable", "grouped", "external"]),
|
|
854
|
+
/** Extension data from plugins */
|
|
855
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
856
|
+
});
|
|
857
|
+
var cartTotalsSchema = zod.z.object({
|
|
858
|
+
/** Total of all cart items (before discounts and taxes) */
|
|
859
|
+
total_items: zod.z.string(),
|
|
860
|
+
/** Tax on cart items */
|
|
861
|
+
total_items_tax: zod.z.string(),
|
|
862
|
+
/** Total fees */
|
|
863
|
+
total_fees: zod.z.string(),
|
|
864
|
+
/** Tax on fees */
|
|
865
|
+
total_fees_tax: zod.z.string(),
|
|
866
|
+
/** Total discount amount from coupons */
|
|
867
|
+
total_discount: zod.z.string(),
|
|
868
|
+
/** Tax on discounts */
|
|
869
|
+
total_discount_tax: zod.z.string(),
|
|
870
|
+
/** Shipping cost (null if not calculated yet) */
|
|
871
|
+
total_shipping: zod.z.string().nullable(),
|
|
872
|
+
/** Shipping tax (null if not calculated yet) */
|
|
873
|
+
total_shipping_tax: zod.z.string().nullable(),
|
|
874
|
+
/** Final total price (includes all taxes and fees) */
|
|
875
|
+
total_price: zod.z.string(),
|
|
876
|
+
/** Total tax amount */
|
|
877
|
+
total_tax: zod.z.string(),
|
|
878
|
+
/** Tax breakdown by rate */
|
|
879
|
+
tax_lines: zod.z.array(
|
|
880
|
+
zod.z.object({
|
|
881
|
+
/** Tax rate name */
|
|
882
|
+
name: zod.z.string(),
|
|
883
|
+
/** Tax amount */
|
|
884
|
+
price: zod.z.string(),
|
|
885
|
+
/** Tax rate percentage */
|
|
886
|
+
rate: zod.z.string()
|
|
887
|
+
})
|
|
888
|
+
)
|
|
889
|
+
}).merge(moneySchema);
|
|
890
|
+
var cartCouponSchema = zod.z.object({
|
|
891
|
+
/** Coupon code */
|
|
892
|
+
code: zod.z.string(),
|
|
893
|
+
/** Discount totals for this coupon */
|
|
894
|
+
totals: zod.z.object({
|
|
895
|
+
/** Total discount amount (before tax) */
|
|
896
|
+
total_discount: zod.z.string(),
|
|
897
|
+
/** Tax amount on discount */
|
|
898
|
+
total_discount_tax: zod.z.string()
|
|
899
|
+
}).merge(moneySchema)
|
|
900
|
+
});
|
|
901
|
+
var shippingRateSchema = zod.z.object({
|
|
902
|
+
/** Unique rate identifier (format: instance_id:method_id) */
|
|
903
|
+
rate_id: zod.z.string(),
|
|
904
|
+
/** Shipping method name */
|
|
905
|
+
name: zod.z.string(),
|
|
906
|
+
/** Shipping method description */
|
|
907
|
+
description: zod.z.string(),
|
|
908
|
+
/** Estimated delivery time */
|
|
909
|
+
delivery_time: zod.z.string(),
|
|
910
|
+
/** Shipping cost */
|
|
911
|
+
price: zod.z.string(),
|
|
912
|
+
/** Shipping instance ID */
|
|
913
|
+
instance_id: zod.z.number(),
|
|
914
|
+
/** Shipping method ID */
|
|
915
|
+
method_id: zod.z.string(),
|
|
916
|
+
/** Additional metadata for this shipping method */
|
|
917
|
+
meta_data: zod.z.array(
|
|
918
|
+
zod.z.object({
|
|
919
|
+
key: zod.z.string(),
|
|
920
|
+
value: zod.z.string()
|
|
921
|
+
})
|
|
922
|
+
),
|
|
923
|
+
/** Whether this rate is currently selected */
|
|
924
|
+
selected: zod.z.boolean(),
|
|
925
|
+
/** Currency code for the price */
|
|
926
|
+
currency_code: zod.z.string(),
|
|
927
|
+
/** Currency symbol for the price */
|
|
928
|
+
currency_symbol: zod.z.string()
|
|
929
|
+
});
|
|
930
|
+
var shippingPackageSchema = zod.z.object({
|
|
931
|
+
/** Package identifier (0-indexed) */
|
|
932
|
+
package_id: zod.z.number(),
|
|
933
|
+
/** Package name/label */
|
|
934
|
+
name: zod.z.string(),
|
|
935
|
+
/** Shipping destination address */
|
|
936
|
+
destination: zod.z.object({
|
|
937
|
+
address_1: zod.z.string(),
|
|
938
|
+
address_2: zod.z.string().optional(),
|
|
939
|
+
city: zod.z.string(),
|
|
940
|
+
state: zod.z.string(),
|
|
941
|
+
postcode: zod.z.string(),
|
|
942
|
+
country: zod.z.string()
|
|
943
|
+
}),
|
|
944
|
+
/** Items included in this package */
|
|
945
|
+
items: zod.z.array(
|
|
946
|
+
zod.z.object({
|
|
947
|
+
/** Cart item key */
|
|
948
|
+
key: zod.z.string(),
|
|
949
|
+
/** Product name */
|
|
950
|
+
name: zod.z.string(),
|
|
951
|
+
/** Quantity in package */
|
|
952
|
+
quantity: zod.z.number()
|
|
953
|
+
})
|
|
954
|
+
),
|
|
955
|
+
/** Available shipping rates for this package */
|
|
956
|
+
shipping_rates: zod.z.array(shippingRateSchema)
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
// src/schemas/store-api/cart.ts
|
|
960
|
+
var cartSchema = zod.z.object({
|
|
961
|
+
items: zod.z.array(cartItemSchema),
|
|
962
|
+
items_count: zod.z.number(),
|
|
963
|
+
items_weight: zod.z.number(),
|
|
964
|
+
needs_payment: zod.z.boolean(),
|
|
965
|
+
needs_shipping: zod.z.boolean(),
|
|
966
|
+
payment_methods: zod.z.array(zod.z.enum(["cod", "monri"])),
|
|
967
|
+
payment_requirements: zod.z.array(zod.z.string()),
|
|
968
|
+
has_calculated_shipping: zod.z.boolean(),
|
|
969
|
+
shipping_address: addressSchemaNonMandatory,
|
|
970
|
+
billing_address: billingAddressSchemaNonMandatory,
|
|
971
|
+
shipping_rates: zod.z.array(shippingPackageSchema),
|
|
972
|
+
coupons: zod.z.array(cartCouponSchema),
|
|
973
|
+
totals: cartTotalsSchema,
|
|
974
|
+
errors: zod.z.array(
|
|
975
|
+
zod.z.object({
|
|
976
|
+
code: zod.z.string(),
|
|
977
|
+
message: zod.z.string()
|
|
978
|
+
})
|
|
979
|
+
),
|
|
980
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
981
|
+
cross_sells: zod.z.array(zod.z.unknown()),
|
|
982
|
+
fees: zod.z.array(zod.z.unknown())
|
|
983
|
+
});
|
|
984
|
+
var addToCartInputSchema = zod.z.object({
|
|
985
|
+
id: zod.z.number(),
|
|
986
|
+
quantity: zod.z.number().int().positive(),
|
|
987
|
+
variation: zod.z.array(
|
|
988
|
+
zod.z.object({
|
|
989
|
+
attribute: zod.z.string(),
|
|
990
|
+
value: zod.z.string()
|
|
991
|
+
})
|
|
992
|
+
).optional()
|
|
993
|
+
});
|
|
994
|
+
var updateCartItemInputSchema = zod.z.object({
|
|
995
|
+
key: zod.z.string(),
|
|
996
|
+
quantity: zod.z.number().int().positive()
|
|
997
|
+
});
|
|
998
|
+
var removeCartItemInputSchema = zod.z.object({
|
|
999
|
+
key: zod.z.string()
|
|
1000
|
+
});
|
|
1001
|
+
var couponInputSchema = zod.z.object({
|
|
1002
|
+
code: zod.z.string().min(1)
|
|
1003
|
+
});
|
|
1004
|
+
var updateCustomerInputSchema = zod.z.object({
|
|
1005
|
+
billing_address: billingAddressSchemaMandatory.partial(),
|
|
1006
|
+
shipping_address: addressSchema.partial()
|
|
1007
|
+
}).partial();
|
|
1008
|
+
var selectShippingRateInputSchema = zod.z.object({
|
|
1009
|
+
package_id: zod.z.union([zod.z.number(), zod.z.string()]).default(0),
|
|
1010
|
+
rate_id: zod.z.string()
|
|
1011
|
+
});
|
|
1012
|
+
var orderItemImageSchema = zod.z.object({
|
|
1013
|
+
/** Image ID */
|
|
1014
|
+
id: zod.z.number(),
|
|
1015
|
+
/** Full image URL */
|
|
1016
|
+
src: zod.z.string().url(),
|
|
1017
|
+
/** Thumbnail URL */
|
|
1018
|
+
thumbnail: zod.z.string().url(),
|
|
1019
|
+
/** Responsive image srcset */
|
|
1020
|
+
srcset: zod.z.string(),
|
|
1021
|
+
/** Responsive image sizes attribute */
|
|
1022
|
+
sizes: zod.z.string(),
|
|
1023
|
+
/** Image name */
|
|
1024
|
+
name: zod.z.string(),
|
|
1025
|
+
/** Image alt text */
|
|
1026
|
+
alt: zod.z.string()
|
|
1027
|
+
});
|
|
1028
|
+
var orderItemPricesSchema = zod.z.object({
|
|
1029
|
+
/** Formatted price (current price) */
|
|
1030
|
+
price: zod.z.string(),
|
|
1031
|
+
/** Formatted regular price */
|
|
1032
|
+
regular_price: zod.z.string(),
|
|
1033
|
+
/** Formatted sale price */
|
|
1034
|
+
sale_price: zod.z.string(),
|
|
1035
|
+
/** Price range (null for simple products) */
|
|
1036
|
+
price_range: zod.z.null(),
|
|
1037
|
+
/** Currency code (e.g., 'USD', 'EUR') */
|
|
1038
|
+
currency_code: zod.z.string(),
|
|
1039
|
+
/** Currency symbol (e.g., '$', '€') */
|
|
1040
|
+
currency_symbol: zod.z.string(),
|
|
1041
|
+
/** Number of decimal places for currency */
|
|
1042
|
+
currency_minor_unit: zod.z.number(),
|
|
1043
|
+
/** Decimal separator (e.g., '.', ',') */
|
|
1044
|
+
currency_decimal_separator: zod.z.string(),
|
|
1045
|
+
/** Thousand separator (e.g., ',', '.') */
|
|
1046
|
+
currency_thousand_separator: zod.z.string(),
|
|
1047
|
+
/** Currency prefix (e.g., '$') */
|
|
1048
|
+
currency_prefix: zod.z.string(),
|
|
1049
|
+
/** Currency suffix (e.g., 'USD') */
|
|
1050
|
+
currency_suffix: zod.z.string(),
|
|
1051
|
+
/** Raw price values for calculations */
|
|
1052
|
+
raw_prices: zod.z.object({
|
|
1053
|
+
/** Precision for price calculations */
|
|
1054
|
+
precision: zod.z.number(),
|
|
1055
|
+
/** Raw price (in minor units) */
|
|
1056
|
+
price: zod.z.string(),
|
|
1057
|
+
/** Raw regular price (in minor units) */
|
|
1058
|
+
regular_price: zod.z.string(),
|
|
1059
|
+
/** Raw sale price (in minor units) */
|
|
1060
|
+
sale_price: zod.z.string()
|
|
1061
|
+
})
|
|
1062
|
+
});
|
|
1063
|
+
var orderItemTotalsSchema = zod.z.object({
|
|
1064
|
+
/** Line subtotal (before discounts) */
|
|
1065
|
+
line_subtotal: zod.z.string(),
|
|
1066
|
+
/** Line subtotal tax */
|
|
1067
|
+
line_subtotal_tax: zod.z.string(),
|
|
1068
|
+
/** Line total (after discounts) */
|
|
1069
|
+
line_total: zod.z.string(),
|
|
1070
|
+
/** Line total tax */
|
|
1071
|
+
line_total_tax: zod.z.string(),
|
|
1072
|
+
/** Currency code */
|
|
1073
|
+
currency_code: zod.z.string(),
|
|
1074
|
+
/** Currency symbol */
|
|
1075
|
+
currency_symbol: zod.z.string(),
|
|
1076
|
+
/** Currency minor unit */
|
|
1077
|
+
currency_minor_unit: zod.z.number(),
|
|
1078
|
+
/** Decimal separator */
|
|
1079
|
+
currency_decimal_separator: zod.z.string(),
|
|
1080
|
+
/** Thousand separator */
|
|
1081
|
+
currency_thousand_separator: zod.z.string(),
|
|
1082
|
+
/** Currency prefix */
|
|
1083
|
+
currency_prefix: zod.z.string(),
|
|
1084
|
+
/** Currency suffix */
|
|
1085
|
+
currency_suffix: zod.z.string()
|
|
1086
|
+
});
|
|
1087
|
+
var quantityLimitsSchema = zod.z.object({
|
|
1088
|
+
/** Minimum quantity allowed */
|
|
1089
|
+
minimum: zod.z.number(),
|
|
1090
|
+
/** Maximum quantity allowed */
|
|
1091
|
+
maximum: zod.z.number(),
|
|
1092
|
+
/** Quantity must be multiple of this value */
|
|
1093
|
+
multiple_of: zod.z.number(),
|
|
1094
|
+
/** Whether quantity is editable */
|
|
1095
|
+
editable: zod.z.boolean()
|
|
1096
|
+
});
|
|
1097
|
+
var orderItemSchema = zod.z.object({
|
|
1098
|
+
/** Unique cart/order item key */
|
|
1099
|
+
key: zod.z.string(),
|
|
1100
|
+
/** Product ID */
|
|
1101
|
+
id: zod.z.number(),
|
|
1102
|
+
/** Quantity ordered */
|
|
1103
|
+
quantity: zod.z.number(),
|
|
1104
|
+
/** Quantity limits for this product */
|
|
1105
|
+
quantity_limits: quantityLimitsSchema,
|
|
1106
|
+
/** Product name */
|
|
1107
|
+
name: zod.z.string(),
|
|
1108
|
+
/** Short description */
|
|
1109
|
+
short_description: zod.z.string(),
|
|
1110
|
+
/** Full description */
|
|
1111
|
+
description: zod.z.string(),
|
|
1112
|
+
/** Product SKU */
|
|
1113
|
+
sku: zod.z.string(),
|
|
1114
|
+
/** Low stock warning (null if not low) */
|
|
1115
|
+
low_stock_remaining: zod.z.null(),
|
|
1116
|
+
/** Whether backorders are allowed */
|
|
1117
|
+
backorders_allowed: zod.z.boolean(),
|
|
1118
|
+
/** Whether to show backorder badge */
|
|
1119
|
+
show_backorder_badge: zod.z.boolean(),
|
|
1120
|
+
/** Whether product can only be purchased individually */
|
|
1121
|
+
sold_individually: zod.z.boolean(),
|
|
1122
|
+
/** Product permalink URL */
|
|
1123
|
+
permalink: zod.z.string().url(),
|
|
1124
|
+
/** Product images */
|
|
1125
|
+
images: zod.z.array(orderItemImageSchema),
|
|
1126
|
+
/** Variation attributes (empty for simple products) */
|
|
1127
|
+
variation: zod.z.array(zod.z.unknown()),
|
|
1128
|
+
/** Custom item data/metadata */
|
|
1129
|
+
item_data: zod.z.array(zod.z.unknown()),
|
|
1130
|
+
/** Price information */
|
|
1131
|
+
prices: orderItemPricesSchema,
|
|
1132
|
+
/** Totals for this line item */
|
|
1133
|
+
totals: orderItemTotalsSchema,
|
|
1134
|
+
/** Catalog visibility setting */
|
|
1135
|
+
catalog_visibility: zod.z.string()
|
|
1136
|
+
});
|
|
1137
|
+
var orderTotalsSchema = zod.z.object({
|
|
1138
|
+
/** Subtotal (before discounts and fees) */
|
|
1139
|
+
subtotal: zod.z.string(),
|
|
1140
|
+
/** Total discount amount */
|
|
1141
|
+
total_discount: zod.z.string(),
|
|
1142
|
+
/** Total shipping cost */
|
|
1143
|
+
total_shipping: zod.z.string(),
|
|
1144
|
+
/** Total fees */
|
|
1145
|
+
total_fees: zod.z.string(),
|
|
1146
|
+
/** Total tax */
|
|
1147
|
+
total_tax: zod.z.string(),
|
|
1148
|
+
/** Total refund amount */
|
|
1149
|
+
total_refund: zod.z.string(),
|
|
1150
|
+
/** Final total price */
|
|
1151
|
+
total_price: zod.z.string(),
|
|
1152
|
+
/** Total items cost (subtotal after item-level discounts) */
|
|
1153
|
+
total_items: zod.z.string(),
|
|
1154
|
+
/** Tax on items */
|
|
1155
|
+
total_items_tax: zod.z.string(),
|
|
1156
|
+
/** Tax on fees */
|
|
1157
|
+
total_fees_tax: zod.z.string(),
|
|
1158
|
+
/** Tax on discounts */
|
|
1159
|
+
total_discount_tax: zod.z.string(),
|
|
1160
|
+
/** Tax on shipping */
|
|
1161
|
+
total_shipping_tax: zod.z.string(),
|
|
1162
|
+
/** Tax line items breakdown */
|
|
1163
|
+
tax_lines: zod.z.array(zod.z.unknown()),
|
|
1164
|
+
/** Currency code (e.g., 'USD', 'EUR', 'BAM') */
|
|
1165
|
+
currency_code: zod.z.string(),
|
|
1166
|
+
/** Currency symbol (e.g., '$', '€', 'KM') */
|
|
1167
|
+
currency_symbol: zod.z.string(),
|
|
1168
|
+
/** Number of decimal places for currency */
|
|
1169
|
+
currency_minor_unit: zod.z.number(),
|
|
1170
|
+
/** Decimal separator (e.g., '.', ',') */
|
|
1171
|
+
currency_decimal_separator: zod.z.string(),
|
|
1172
|
+
/** Thousand separator (e.g., ',', '.') */
|
|
1173
|
+
currency_thousand_separator: zod.z.string(),
|
|
1174
|
+
/** Currency prefix (e.g., '$') */
|
|
1175
|
+
currency_prefix: zod.z.string(),
|
|
1176
|
+
/** Currency suffix (e.g., 'USD') */
|
|
1177
|
+
currency_suffix: zod.z.string()
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
// src/schemas/store-api/order.schema.ts
|
|
1181
|
+
var orderStatusEnum = zod.z.enum([
|
|
1182
|
+
"pending",
|
|
1183
|
+
// Order received, awaiting payment
|
|
1184
|
+
"processing",
|
|
1185
|
+
// Payment received, order is being processed
|
|
1186
|
+
"on-hold",
|
|
1187
|
+
// Order on hold, awaiting confirmation
|
|
1188
|
+
"completed",
|
|
1189
|
+
// Order fulfilled and complete
|
|
1190
|
+
"cancelled",
|
|
1191
|
+
// Order cancelled by customer or admin
|
|
1192
|
+
"refunded",
|
|
1193
|
+
// Order refunded
|
|
1194
|
+
"failed"
|
|
1195
|
+
// Payment failed or order declined
|
|
1196
|
+
]);
|
|
1197
|
+
var storeApiOrderSchema = zod.z.object({
|
|
1198
|
+
/** Order ID */
|
|
1199
|
+
id: zod.z.number(),
|
|
1200
|
+
/** Order status */
|
|
1201
|
+
status: orderStatusEnum,
|
|
1202
|
+
/** Order line items (products purchased) */
|
|
1203
|
+
items: zod.z.array(orderItemSchema),
|
|
1204
|
+
/** Applied coupons */
|
|
1205
|
+
coupons: zod.z.array(zod.z.unknown()),
|
|
1206
|
+
/** Order fees */
|
|
1207
|
+
fees: zod.z.array(zod.z.unknown()),
|
|
1208
|
+
/** Order totals breakdown */
|
|
1209
|
+
totals: orderTotalsSchema,
|
|
1210
|
+
/** Shipping address */
|
|
1211
|
+
shipping_address: addressSchema,
|
|
1212
|
+
/** Billing address (includes email) */
|
|
1213
|
+
billing_address: billingAddressSchemaMandatory,
|
|
1214
|
+
/** Whether order still needs payment */
|
|
1215
|
+
needs_payment: zod.z.boolean(),
|
|
1216
|
+
/** Whether order needs shipping */
|
|
1217
|
+
needs_shipping: zod.z.boolean(),
|
|
1218
|
+
/** Payment method requirements */
|
|
1219
|
+
payment_requirements: zod.z.array(zod.z.string()),
|
|
1220
|
+
/** Order errors (if any) */
|
|
1221
|
+
errors: zod.z.array(zod.z.unknown()),
|
|
1222
|
+
/** Payment method (optional - returned from checkout) */
|
|
1223
|
+
payment_method: zod.z.string().optional(),
|
|
1224
|
+
/** Payment method title (optional - returned from checkout) */
|
|
1225
|
+
payment_method_title: zod.z.string().optional()
|
|
1226
|
+
});
|
|
1227
|
+
var checkoutSchema = zod.z.object({
|
|
1228
|
+
order_id: zod.z.number(),
|
|
1229
|
+
status: zod.z.string(),
|
|
1230
|
+
order_key: zod.z.string(),
|
|
1231
|
+
customer_note: zod.z.string(),
|
|
1232
|
+
customer_id: zod.z.number(),
|
|
1233
|
+
billing_address: billingAddressSchemaNonMandatory,
|
|
1234
|
+
shipping_address: addressSchemaNonMandatory,
|
|
1235
|
+
payment_method: zod.z.string(),
|
|
1236
|
+
payment_result: zod.z.object({
|
|
1237
|
+
payment_status: zod.z.string(),
|
|
1238
|
+
payment_details: zod.z.array(zod.z.unknown()),
|
|
1239
|
+
redirect_url: zod.z.string()
|
|
1240
|
+
})
|
|
1241
|
+
});
|
|
1242
|
+
var checkoutInputSchema = zod.z.object({
|
|
1243
|
+
payment_method: zod.z.string(),
|
|
1244
|
+
payment_data: zod.z.array(
|
|
1245
|
+
zod.z.object({
|
|
1246
|
+
key: zod.z.string(),
|
|
1247
|
+
value: zod.z.union([zod.z.string(), zod.z.boolean()])
|
|
1248
|
+
})
|
|
1249
|
+
).optional(),
|
|
1250
|
+
billing_address: billingAddressSchemaMandatory.optional(),
|
|
1251
|
+
shipping_address: addressSchema.optional(),
|
|
1252
|
+
customer_note: zod.z.string().optional(),
|
|
1253
|
+
create_account: zod.z.boolean().optional(),
|
|
1254
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1255
|
+
});
|
|
1256
|
+
var addToCartSchema = zod.z.object({
|
|
1257
|
+
/** Description for add to cart action */
|
|
1258
|
+
description: zod.z.string(),
|
|
1259
|
+
/** Maximum quantity that can be added */
|
|
1260
|
+
maximum: zod.z.number(),
|
|
1261
|
+
/** Minimum quantity that can be added */
|
|
1262
|
+
minimum: zod.z.number(),
|
|
1263
|
+
/** Quantity must be a multiple of this number */
|
|
1264
|
+
multiple_of: zod.z.number(),
|
|
1265
|
+
/** Text for add to cart button */
|
|
1266
|
+
text: zod.z.string(),
|
|
1267
|
+
/** URL for add to cart action */
|
|
1268
|
+
url: zod.z.string()
|
|
1269
|
+
});
|
|
1270
|
+
var embeddedCategorySchema = zod.z.object({
|
|
1271
|
+
/** Category unique identifier */
|
|
1272
|
+
id: zod.z.number(),
|
|
1273
|
+
/** Category display name */
|
|
1274
|
+
name: zod.z.string(),
|
|
1275
|
+
/** URL-friendly category identifier */
|
|
1276
|
+
slug: zod.z.string(),
|
|
1277
|
+
/** Link to category page */
|
|
1278
|
+
link: zod.z.string(),
|
|
1279
|
+
/** Parent category ID (0 for root categories) - optional in embedded */
|
|
1280
|
+
parent: zod.z.number().optional(),
|
|
1281
|
+
/** Category description - optional in embedded */
|
|
1282
|
+
description: zod.z.string().optional(),
|
|
1283
|
+
/** Display type - optional in embedded */
|
|
1284
|
+
display: zod.z.string().optional(),
|
|
1285
|
+
/** Category image - optional in embedded */
|
|
1286
|
+
image: productImageSchema.nullable().optional(),
|
|
1287
|
+
/** Menu order for sorting - optional in embedded */
|
|
1288
|
+
menu_order: zod.z.number().optional(),
|
|
1289
|
+
/** Number of products in this category - optional in embedded */
|
|
1290
|
+
count: zod.z.number().optional()
|
|
1291
|
+
});
|
|
1292
|
+
var productCategorySchema = zod.z.object({
|
|
1293
|
+
/** Category unique identifier */
|
|
1294
|
+
id: zod.z.number(),
|
|
1295
|
+
/** Category display name */
|
|
1296
|
+
name: zod.z.string(),
|
|
1297
|
+
/** URL-friendly category identifier */
|
|
1298
|
+
slug: zod.z.string(),
|
|
1299
|
+
/** Parent category ID (0 for root categories) */
|
|
1300
|
+
parent: zod.z.number(),
|
|
1301
|
+
/** Category description */
|
|
1302
|
+
description: zod.z.string(),
|
|
1303
|
+
/** Category image */
|
|
1304
|
+
image: productImageSchema.nullable(),
|
|
1305
|
+
/** Menu order for sorting */
|
|
1306
|
+
menu_order: zod.z.number().optional(),
|
|
1307
|
+
/** Number of products in this category */
|
|
1308
|
+
count: zod.z.number()
|
|
1309
|
+
});
|
|
1310
|
+
var storeProductsSearchParamsSchema = zod.z.object({
|
|
1311
|
+
// Pagination
|
|
1312
|
+
/** Current page number */
|
|
1313
|
+
page: zod.z.number(),
|
|
1314
|
+
/** Number of products per page (1-100) */
|
|
1315
|
+
per_page: zod.z.number().min(1).max(100).default(10),
|
|
1316
|
+
// Ordering
|
|
1317
|
+
/** Field to order results by */
|
|
1318
|
+
orderby: zod.z.enum([
|
|
1319
|
+
"date",
|
|
1320
|
+
"id",
|
|
1321
|
+
"include",
|
|
1322
|
+
"title",
|
|
1323
|
+
"slug",
|
|
1324
|
+
"price",
|
|
1325
|
+
"popularity",
|
|
1326
|
+
"rating",
|
|
1327
|
+
"menu_order",
|
|
1328
|
+
"date_modified"
|
|
1329
|
+
]).optional(),
|
|
1330
|
+
/** Sort order (ascending or descending) */
|
|
1331
|
+
order: zod.z.enum(["asc", "desc"]).optional(),
|
|
1332
|
+
// Filtering
|
|
1333
|
+
/** Search query string */
|
|
1334
|
+
search: zod.z.string().optional(),
|
|
1335
|
+
/** Exact slug match */
|
|
1336
|
+
slug: zod.z.string().optional(),
|
|
1337
|
+
// Date filtering
|
|
1338
|
+
/** Filter products published after this date */
|
|
1339
|
+
after: zod.z.string().datetime().optional(),
|
|
1340
|
+
/** Filter products published before this date */
|
|
1341
|
+
before: zod.z.string().datetime().optional(),
|
|
1342
|
+
/** Filter products modified after this date */
|
|
1343
|
+
modified_after: zod.z.string().datetime().optional(),
|
|
1344
|
+
/** Filter products modified before this date */
|
|
1345
|
+
modified_before: zod.z.string().datetime().optional(),
|
|
1346
|
+
// ID filtering
|
|
1347
|
+
/** Include specific product IDs */
|
|
1348
|
+
include: zod.z.array(zod.z.number()).optional(),
|
|
1349
|
+
/** Exclude specific product IDs */
|
|
1350
|
+
exclude: zod.z.array(zod.z.number()).optional(),
|
|
1351
|
+
// Parent/Child
|
|
1352
|
+
/** Filter by parent product IDs */
|
|
1353
|
+
parent: zod.z.array(zod.z.number()).optional(),
|
|
1354
|
+
/** Exclude products with these parent IDs */
|
|
1355
|
+
parent_exclude: zod.z.array(zod.z.number()).optional(),
|
|
1356
|
+
// Type & Status
|
|
1357
|
+
/** Filter by product type */
|
|
1358
|
+
type: zod.z.enum(["simple", "grouped", "external", "variable", "variation"]).optional(),
|
|
1359
|
+
/** Filter by product status */
|
|
1360
|
+
status: zod.z.enum(["any", "draft", "pending", "private", "publish"]).optional(),
|
|
1361
|
+
// Featured
|
|
1362
|
+
/** Filter featured products */
|
|
1363
|
+
featured: zod.z.boolean().optional(),
|
|
1364
|
+
// Visibility
|
|
1365
|
+
/** Filter by catalog visibility */
|
|
1366
|
+
catalog_visibility: zod.z.enum(["any", "visible", "catalog", "search", "hidden"]).optional(),
|
|
1367
|
+
// Stock
|
|
1368
|
+
/** Filter by stock status */
|
|
1369
|
+
stock_status: zod.z.array(zod.z.enum(["instock", "outofstock", "onbackorder"])).optional(),
|
|
1370
|
+
// Category & Tag filtering
|
|
1371
|
+
/** Filter by category slug or ID */
|
|
1372
|
+
category: zod.z.string().optional(),
|
|
1373
|
+
/** Category filter operator */
|
|
1374
|
+
category_operator: zod.z.enum(["in", "not_in", "and"]).optional(),
|
|
1375
|
+
/** Filter by tag slug or ID */
|
|
1376
|
+
tag: zod.z.string().optional(),
|
|
1377
|
+
/** Tag filter operator */
|
|
1378
|
+
tag_operator: zod.z.enum(["in", "not_in", "and"]).optional(),
|
|
1379
|
+
// Attribute filtering
|
|
1380
|
+
/** Filter by product attributes */
|
|
1381
|
+
attributes: zod.z.array(
|
|
1382
|
+
zod.z.object({
|
|
1383
|
+
/** Attribute name */
|
|
1384
|
+
attribute: zod.z.string(),
|
|
1385
|
+
/** Filter by attribute term IDs */
|
|
1386
|
+
term_id: zod.z.array(zod.z.number()).optional(),
|
|
1387
|
+
/** Filter by attribute term slugs */
|
|
1388
|
+
slug: zod.z.array(zod.z.string()).optional(),
|
|
1389
|
+
/** Attribute filter operator */
|
|
1390
|
+
operator: zod.z.enum(["in", "not_in", "and"]).optional()
|
|
1391
|
+
})
|
|
1392
|
+
).optional(),
|
|
1393
|
+
/** Relationship between attribute filters */
|
|
1394
|
+
attribute_relation: zod.z.enum(["in", "and"]).optional(),
|
|
1395
|
+
// Price filtering
|
|
1396
|
+
/** Minimum price filter */
|
|
1397
|
+
min_price: zod.z.string().optional(),
|
|
1398
|
+
/** Maximum price filter */
|
|
1399
|
+
max_price: zod.z.string().optional(),
|
|
1400
|
+
// Sale status
|
|
1401
|
+
/** Filter products on sale */
|
|
1402
|
+
on_sale: zod.z.boolean().optional(),
|
|
1403
|
+
// Rating filter
|
|
1404
|
+
/** Filter by product rating (1-5 stars) */
|
|
1405
|
+
rating: zod.z.array(zod.z.number().min(1).max(5)).optional()
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
// src/schemas/store-api/products.ts
|
|
1409
|
+
var productSchema = zod.z.object({
|
|
1410
|
+
id: zod.z.number(),
|
|
1411
|
+
name: zod.z.string(),
|
|
1412
|
+
slug: zod.z.string(),
|
|
1413
|
+
type: zod.z.string(),
|
|
1414
|
+
variation: zod.z.string(),
|
|
1415
|
+
permalink: zod.z.string().url(),
|
|
1416
|
+
sku: zod.z.string(),
|
|
1417
|
+
short_description: zod.z.string(),
|
|
1418
|
+
description: zod.z.string(),
|
|
1419
|
+
is_purchasable: zod.z.boolean(),
|
|
1420
|
+
is_in_stock: zod.z.boolean(),
|
|
1421
|
+
is_on_backorder: zod.z.boolean(),
|
|
1422
|
+
low_stock_remaining: zod.z.number().nullable(),
|
|
1423
|
+
sold_individually: zod.z.boolean(),
|
|
1424
|
+
add_to_cart: addToCartSchema,
|
|
1425
|
+
has_options: zod.z.boolean(),
|
|
1426
|
+
on_sale: zod.z.boolean(),
|
|
1427
|
+
parent: zod.z.number(),
|
|
1428
|
+
attributes: zod.z.array(zod.z.unknown()),
|
|
1429
|
+
categories: zod.z.array(embeddedCategorySchema),
|
|
1430
|
+
tags: zod.z.array(zod.z.unknown()),
|
|
1431
|
+
images: zod.z.array(productImageSchema),
|
|
1432
|
+
variations: zod.z.array(zod.z.unknown()),
|
|
1433
|
+
price_html: zod.z.string(),
|
|
1434
|
+
prices: pricesSchema,
|
|
1435
|
+
average_rating: zod.z.string(),
|
|
1436
|
+
review_count: zod.z.number(),
|
|
1437
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
// src/api/cart.ts
|
|
1441
|
+
var createCartAPI = (client, endpoints, options) => ({
|
|
1442
|
+
get: async () => {
|
|
1443
|
+
const response = await client.get(endpoints.cart);
|
|
1444
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1445
|
+
},
|
|
1446
|
+
addItem: async (input) => {
|
|
1447
|
+
const response = await client.post(endpoints.addItem, input);
|
|
1448
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1449
|
+
},
|
|
1450
|
+
updateItem: async (input) => {
|
|
1451
|
+
const response = await client.post(endpoints.updateItem, input);
|
|
1452
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1453
|
+
},
|
|
1454
|
+
removeItem: async (input) => {
|
|
1455
|
+
const response = await client.post(endpoints.removeItem, input);
|
|
1456
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1457
|
+
},
|
|
1458
|
+
applyCoupon: async (input) => {
|
|
1459
|
+
const response = await client.post(endpoints.applyCoupon, input);
|
|
1460
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1461
|
+
},
|
|
1462
|
+
removeCoupon: async (input) => {
|
|
1463
|
+
const response = await client.post(endpoints.removeCoupon, input);
|
|
1464
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1465
|
+
},
|
|
1466
|
+
updateCustomer: async (input) => {
|
|
1467
|
+
const response = await client.post(endpoints.updateCustomer, input);
|
|
1468
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1469
|
+
},
|
|
1470
|
+
selectShippingRate: async (input) => {
|
|
1471
|
+
const response = await client.post(endpoints.selectShippingRate, input);
|
|
1472
|
+
return handleApiResponse(response, cartSchema, options);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
|
|
1476
|
+
// src/api/checkout.ts
|
|
1477
|
+
var createCheckoutAPI = (client, endpoints, options) => ({
|
|
1478
|
+
get: async () => {
|
|
1479
|
+
const response = await client.get(endpoints.checkout);
|
|
1480
|
+
return handleApiResponse(response, checkoutSchema, options);
|
|
1481
|
+
},
|
|
1482
|
+
process: async (input) => {
|
|
1483
|
+
const response = await client.post(endpoints.checkout, input);
|
|
1484
|
+
return handleApiResponse(response, checkoutSchema, options);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
// src/api/orders.ts
|
|
1489
|
+
var createOrdersAPI = (client, endpoints, options) => ({
|
|
1490
|
+
/**
|
|
1491
|
+
* Get a single order by ID
|
|
1492
|
+
* Uses Store API - supports guest lookup with billing_email + key
|
|
1493
|
+
*/
|
|
1494
|
+
get: async (input) => {
|
|
1495
|
+
const { id, billing_email, key } = input;
|
|
1496
|
+
const params = billing_email && key ? { billing_email, key } : void 0;
|
|
1497
|
+
const response = await client.get(`${endpoints.order}/${id}`, { params });
|
|
1498
|
+
return handleApiResponse(response, storeApiOrderSchema, options);
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
var createProductsAPI = (client, endpoints, options) => ({
|
|
1502
|
+
list: async (params) => {
|
|
1503
|
+
const response = await client.get(endpoints.products, { params });
|
|
1504
|
+
return handlePaginatedApiResponse(response, zod.z.array(productSchema), params, options);
|
|
1505
|
+
},
|
|
1506
|
+
get: async (id) => {
|
|
1507
|
+
const response = await client.get(`${endpoints.products}/${id}`);
|
|
1508
|
+
return handleApiResponse(response, productSchema, options);
|
|
1509
|
+
},
|
|
1510
|
+
categories: async () => {
|
|
1511
|
+
const response = await client.get(endpoints.categories);
|
|
1512
|
+
return handleApiResponse(response, zod.z.array(productCategorySchema), options);
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
// src/constants/endpoints.ts
|
|
1517
|
+
var createEndpoints = (version = "legacy") => {
|
|
1518
|
+
const prefix = version === "v1" ? "/wc/store/v1" : "/wc/store";
|
|
1519
|
+
return {
|
|
1520
|
+
// Products
|
|
1521
|
+
products: `${prefix}/products`,
|
|
1522
|
+
categories: `${prefix}/products/categories`,
|
|
1523
|
+
// Cart
|
|
1524
|
+
cart: `${prefix}/cart`,
|
|
1525
|
+
addItem: `${prefix}/cart/add-item`,
|
|
1526
|
+
updateItem: `${prefix}/cart/update-item`,
|
|
1527
|
+
removeItem: `${prefix}/cart/remove-item`,
|
|
1528
|
+
applyCoupon: `${prefix}/cart/apply-coupon`,
|
|
1529
|
+
removeCoupon: `${prefix}/cart/remove-coupon`,
|
|
1530
|
+
updateCustomer: `${prefix}/cart/update-customer`,
|
|
1531
|
+
selectShippingRate: `${prefix}/cart/select-shipping-rate`,
|
|
1532
|
+
// Checkout
|
|
1533
|
+
checkout: `${prefix}/checkout`,
|
|
1534
|
+
// Orders
|
|
1535
|
+
order: `${prefix}/order`
|
|
1536
|
+
};
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1539
|
+
// src/client/createClient.ts
|
|
1540
|
+
var DEFAULT_ERROR_REPORTER = {
|
|
1541
|
+
report: (error2) => {
|
|
1542
|
+
console.error("[woocommerce-utils]", error2);
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
var createClient = (config) => {
|
|
1546
|
+
const fullConfig = {
|
|
1547
|
+
...config,
|
|
1548
|
+
errorReporter: config.errorReporter ?? DEFAULT_ERROR_REPORTER
|
|
1549
|
+
};
|
|
1550
|
+
const axiosInstance = axios__default.default.create({
|
|
1551
|
+
baseURL: fullConfig.baseURL,
|
|
1552
|
+
timeout: fullConfig.timeout || 3e4,
|
|
1553
|
+
headers: {
|
|
1554
|
+
"Content-Type": "application/json",
|
|
1555
|
+
...fullConfig.headers
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
const endpoints = createEndpoints(fullConfig.storeApiVersion ?? "legacy");
|
|
1559
|
+
const responseOptions = {
|
|
1560
|
+
validationMode: fullConfig.validationMode,
|
|
1561
|
+
errorReporter: fullConfig.errorReporter?.report,
|
|
1562
|
+
onValidationError: fullConfig.onValidationError
|
|
1563
|
+
};
|
|
1564
|
+
const client = {
|
|
1565
|
+
config: fullConfig,
|
|
1566
|
+
axios: axiosInstance,
|
|
1567
|
+
products: createProductsAPI(axiosInstance, endpoints, responseOptions),
|
|
1568
|
+
cart: createCartAPI(axiosInstance, endpoints, responseOptions),
|
|
1569
|
+
checkout: createCheckoutAPI(axiosInstance, endpoints, responseOptions),
|
|
1570
|
+
orders: createOrdersAPI(axiosInstance, endpoints, responseOptions)
|
|
1571
|
+
};
|
|
1572
|
+
setupRequestInterceptor(axiosInstance, fullConfig, client);
|
|
1573
|
+
setupResponseInterceptor(axiosInstance, fullConfig, client);
|
|
1574
|
+
setupErrorInterceptor(axiosInstance, fullConfig, client);
|
|
1575
|
+
return client;
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
// src/schemas/admin-api/enums/enums-raw.ts
|
|
1579
|
+
var ORDER_STATUS = [
|
|
1580
|
+
"cancelled",
|
|
1581
|
+
"completed",
|
|
1582
|
+
"pending",
|
|
1583
|
+
"processing",
|
|
1584
|
+
"on-hold",
|
|
1585
|
+
"auto-draft",
|
|
1586
|
+
"trash",
|
|
1587
|
+
"refunded",
|
|
1588
|
+
"failed",
|
|
1589
|
+
"checkout-draft"
|
|
1590
|
+
];
|
|
1591
|
+
var PAYMENT_METHODS = ["cod", "monri", "pikpay", "bacs", "cheque"];
|
|
1592
|
+
var PRODUCT_TYPES = ["simple", "grouped", "external", "variable"];
|
|
1593
|
+
var PRODUCT_STATUS = [
|
|
1594
|
+
"any",
|
|
1595
|
+
"future",
|
|
1596
|
+
"trash",
|
|
1597
|
+
"draft",
|
|
1598
|
+
"pending",
|
|
1599
|
+
"private",
|
|
1600
|
+
"publish"
|
|
1601
|
+
];
|
|
1602
|
+
var STOCK_STATUS = ["instock", "outofstock", "onbackorder"];
|
|
1603
|
+
var USER_ROLES = [
|
|
1604
|
+
"all",
|
|
1605
|
+
"administrator",
|
|
1606
|
+
"editor",
|
|
1607
|
+
"author",
|
|
1608
|
+
"contributor",
|
|
1609
|
+
"subscriber",
|
|
1610
|
+
"customer",
|
|
1611
|
+
"shop_manager",
|
|
1612
|
+
"dc_pending_vendor",
|
|
1613
|
+
"dc_rejected_vendor",
|
|
1614
|
+
"dc_vendor",
|
|
1615
|
+
"translator"
|
|
1616
|
+
];
|
|
1617
|
+
var REVIEW_STATUS = ["all", "hold", "approved", "spam", "trash"];
|
|
1618
|
+
var SORT_ORDER = ["asc", "desc"];
|
|
1619
|
+
var COUPONS_ORDER_BY = ["date", "id", "include", "title", "slug", "modified"];
|
|
1620
|
+
var PRODUCT_SORT_FIELDS = [
|
|
1621
|
+
"date",
|
|
1622
|
+
"id",
|
|
1623
|
+
"include",
|
|
1624
|
+
"title",
|
|
1625
|
+
"slug",
|
|
1626
|
+
"modified",
|
|
1627
|
+
"popularity",
|
|
1628
|
+
"rating",
|
|
1629
|
+
"menu_order",
|
|
1630
|
+
"price"
|
|
1631
|
+
];
|
|
1632
|
+
var CATEGORY_SORT_FIELDS = [
|
|
1633
|
+
"id",
|
|
1634
|
+
"include",
|
|
1635
|
+
"name",
|
|
1636
|
+
"slug",
|
|
1637
|
+
"term_group",
|
|
1638
|
+
"description",
|
|
1639
|
+
"count"
|
|
1640
|
+
];
|
|
1641
|
+
var ORDER_SORT_FIELDS = ["date", "id", "include", "title", "slug", "modified"];
|
|
1642
|
+
var ERROR_CODES = ["registration-error-email-exists", "rest_no_route"];
|
|
1643
|
+
var CATALOG_VISIBILITY = ["visible", "catalog", "search", "hidden"];
|
|
1644
|
+
var CUSTOMER_ROLE = [
|
|
1645
|
+
"all",
|
|
1646
|
+
"administrator",
|
|
1647
|
+
"editor",
|
|
1648
|
+
"author",
|
|
1649
|
+
"contributor",
|
|
1650
|
+
"subscriber",
|
|
1651
|
+
"customer",
|
|
1652
|
+
"shop_manager"
|
|
1653
|
+
];
|
|
1654
|
+
var CUSTOMER_SORT_FIELDS = ["id", "include", "name", "registered_date"];
|
|
1655
|
+
var PRODUCT_REVIEWS_SORT_FIELDS = ["date", "date_gmt", "id", "include", "product"];
|
|
1656
|
+
var ENUM_RAW = {
|
|
1657
|
+
ORDER: {
|
|
1658
|
+
STATUS: ORDER_STATUS,
|
|
1659
|
+
SORT_FIELDS: ORDER_SORT_FIELDS
|
|
1660
|
+
},
|
|
1661
|
+
PAYMENT: {
|
|
1662
|
+
METHODS: PAYMENT_METHODS
|
|
1663
|
+
},
|
|
1664
|
+
PRODUCT: {
|
|
1665
|
+
TYPES: PRODUCT_TYPES,
|
|
1666
|
+
STATUS: PRODUCT_STATUS,
|
|
1667
|
+
STOCK_STATUS,
|
|
1668
|
+
CATALOG_VISIBILITY,
|
|
1669
|
+
SORT_FIELDS: PRODUCT_SORT_FIELDS
|
|
1670
|
+
},
|
|
1671
|
+
USER: {
|
|
1672
|
+
ROLES: USER_ROLES
|
|
1673
|
+
},
|
|
1674
|
+
REVIEW: {
|
|
1675
|
+
STATUS: REVIEW_STATUS,
|
|
1676
|
+
SORT_FIELDS: PRODUCT_REVIEWS_SORT_FIELDS
|
|
1677
|
+
},
|
|
1678
|
+
CATEGORY: {
|
|
1679
|
+
SORT_FIELDS: CATEGORY_SORT_FIELDS
|
|
1680
|
+
},
|
|
1681
|
+
COMMON: {
|
|
1682
|
+
SORT_ORDER,
|
|
1683
|
+
ERROR_CODES},
|
|
1684
|
+
CUSTOMER: {
|
|
1685
|
+
ROLE: CUSTOMER_ROLE,
|
|
1686
|
+
SORT_FIELDS: CUSTOMER_SORT_FIELDS
|
|
1687
|
+
},
|
|
1688
|
+
COUPONS: {
|
|
1689
|
+
ORDER_BY: COUPONS_ORDER_BY
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1693
|
+
// src/schemas/admin-api/enums/enums.ts
|
|
1694
|
+
var APP_ENUMS = {
|
|
1695
|
+
PRODUCT_TYPES: {
|
|
1696
|
+
RAW: ENUM_RAW.PRODUCT.TYPES,
|
|
1697
|
+
ZOD: zod.z.enum(ENUM_RAW.PRODUCT.TYPES)
|
|
1698
|
+
},
|
|
1699
|
+
PRODUCT_STATUS: {
|
|
1700
|
+
RAW: ENUM_RAW.PRODUCT.STATUS,
|
|
1701
|
+
ZOD: zod.z.enum(ENUM_RAW.PRODUCT.STATUS)
|
|
1702
|
+
},
|
|
1703
|
+
PRODUCT_STOCK_STATUS: {
|
|
1704
|
+
RAW: ENUM_RAW.PRODUCT.STOCK_STATUS,
|
|
1705
|
+
ZOD: zod.z.enum(ENUM_RAW.PRODUCT.STOCK_STATUS)
|
|
1706
|
+
},
|
|
1707
|
+
PRODUCT_CATALOG_VISIBILITY: {
|
|
1708
|
+
RAW: ENUM_RAW.PRODUCT.CATALOG_VISIBILITY,
|
|
1709
|
+
ZOD: zod.z.enum(ENUM_RAW.PRODUCT.CATALOG_VISIBILITY)
|
|
1710
|
+
},
|
|
1711
|
+
PRODUCT_SORT_FIELDS: {
|
|
1712
|
+
RAW: ENUM_RAW.PRODUCT.SORT_FIELDS,
|
|
1713
|
+
ZOD: zod.z.enum(ENUM_RAW.PRODUCT.SORT_FIELDS)
|
|
1714
|
+
},
|
|
1715
|
+
ORDER_STATUS: {
|
|
1716
|
+
RAW: ENUM_RAW.ORDER.STATUS,
|
|
1717
|
+
ZOD: zod.z.enum(ENUM_RAW.ORDER.STATUS)
|
|
1718
|
+
},
|
|
1719
|
+
ORDER_SORT_FIELDS: {
|
|
1720
|
+
RAW: ENUM_RAW.ORDER.SORT_FIELDS,
|
|
1721
|
+
ZOD: zod.z.enum(ENUM_RAW.ORDER.SORT_FIELDS)
|
|
1722
|
+
},
|
|
1723
|
+
PAYMENT_METHODS: {
|
|
1724
|
+
RAW: ENUM_RAW.PAYMENT.METHODS,
|
|
1725
|
+
ZOD: zod.z.enum(ENUM_RAW.PAYMENT.METHODS)
|
|
1726
|
+
},
|
|
1727
|
+
USER_ROLES: {
|
|
1728
|
+
RAW: ENUM_RAW.USER.ROLES,
|
|
1729
|
+
ZOD: zod.z.enum(ENUM_RAW.USER.ROLES)
|
|
1730
|
+
},
|
|
1731
|
+
REVIEW_STATUS: {
|
|
1732
|
+
RAW: ENUM_RAW.REVIEW.STATUS,
|
|
1733
|
+
ZOD: zod.z.enum(ENUM_RAW.REVIEW.STATUS)
|
|
1734
|
+
},
|
|
1735
|
+
CATEGORY_SORT_FIELDS: {
|
|
1736
|
+
RAW: ENUM_RAW.CATEGORY.SORT_FIELDS,
|
|
1737
|
+
ZOD: zod.z.enum(ENUM_RAW.CATEGORY.SORT_FIELDS)
|
|
1738
|
+
},
|
|
1739
|
+
COMMON_SORT_ORDER: {
|
|
1740
|
+
RAW: ENUM_RAW.COMMON.SORT_ORDER,
|
|
1741
|
+
ZOD: zod.z.enum(ENUM_RAW.COMMON.SORT_ORDER)
|
|
1742
|
+
},
|
|
1743
|
+
COMMON_ERROR_CODES: {
|
|
1744
|
+
RAW: ENUM_RAW.COMMON.ERROR_CODES,
|
|
1745
|
+
ZOD: zod.z.enum(ENUM_RAW.COMMON.ERROR_CODES)
|
|
1746
|
+
},
|
|
1747
|
+
CUSTOMER_ROLE: {
|
|
1748
|
+
RAW: ENUM_RAW.CUSTOMER.ROLE,
|
|
1749
|
+
ZOD: zod.z.enum(ENUM_RAW.CUSTOMER.ROLE)
|
|
1750
|
+
},
|
|
1751
|
+
CUSTOMER_SORT_FIELDS: {
|
|
1752
|
+
RAW: ENUM_RAW.CUSTOMER.SORT_FIELDS,
|
|
1753
|
+
ZOD: zod.z.enum(ENUM_RAW.CUSTOMER.SORT_FIELDS)
|
|
1754
|
+
},
|
|
1755
|
+
REVIEW_SORT_FIELDS: {
|
|
1756
|
+
RAW: ENUM_RAW.REVIEW.SORT_FIELDS,
|
|
1757
|
+
ZOD: zod.z.enum(ENUM_RAW.REVIEW.SORT_FIELDS)
|
|
1758
|
+
},
|
|
1759
|
+
COUPONS_ORDER_BY: {
|
|
1760
|
+
RAW: ENUM_RAW.COUPONS.ORDER_BY,
|
|
1761
|
+
ZOD: zod.z.enum(ENUM_RAW.COUPONS.ORDER_BY)
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
var getAppEnumZod = (key) => APP_ENUMS[key].ZOD;
|
|
1765
|
+
var getAppEnumRaw = (key) => APP_ENUMS[key].RAW;
|
|
1766
|
+
var basePaginationSchema = zod.z.object({
|
|
1767
|
+
page: zod.z.number().positive().default(1),
|
|
1768
|
+
per_page: zod.z.number().positive().max(100).default(10),
|
|
1769
|
+
offset: zod.z.number().nonnegative().optional()
|
|
1770
|
+
});
|
|
1771
|
+
var baseFilteringSchema = zod.z.object({
|
|
1772
|
+
search: zod.z.string().optional(),
|
|
1773
|
+
exclude: zod.z.array(zod.z.number()).default([]),
|
|
1774
|
+
include: zod.z.array(zod.z.number()).default([])
|
|
1775
|
+
});
|
|
1776
|
+
zod.z.object({
|
|
1777
|
+
status: zod.z.enum(["publish", "future", "draft", "pending", "private"]).optional()
|
|
1778
|
+
});
|
|
1779
|
+
zod.z.object({
|
|
1780
|
+
"x-wp-total": zod.z.string().transform(Number),
|
|
1781
|
+
"x-wp-totalpages": zod.z.string().transform(Number)
|
|
1782
|
+
});
|
|
1783
|
+
zod.z.object({
|
|
1784
|
+
...basePaginationSchema.shape,
|
|
1785
|
+
...baseFilteringSchema.shape,
|
|
1786
|
+
context: zod.z.enum(["view", "edit"]).default("view")
|
|
1787
|
+
});
|
|
1788
|
+
var wpLinksSchema = zod.z.object({
|
|
1789
|
+
self: zod.z.array(zod.z.object({ href: zod.z.string() })),
|
|
1790
|
+
collection: zod.z.array(zod.z.object({ href: zod.z.string() })),
|
|
1791
|
+
about: zod.z.array(zod.z.object({ href: zod.z.string() })).optional(),
|
|
1792
|
+
author: zod.z.array(
|
|
1793
|
+
zod.z.object({
|
|
1794
|
+
embeddable: zod.z.boolean().optional(),
|
|
1795
|
+
href: zod.z.string()
|
|
1796
|
+
})
|
|
1797
|
+
).optional()
|
|
1798
|
+
});
|
|
1799
|
+
|
|
1800
|
+
// src/schemas/admin-api/base/base-wc.schema.ts
|
|
1801
|
+
var wcSortingSchema = zod.z.object({
|
|
1802
|
+
order: getAppEnumZod("COMMON_SORT_ORDER").default("desc"),
|
|
1803
|
+
orderby: zod.z.string().optional()
|
|
1804
|
+
});
|
|
1805
|
+
var wcDateFilterSchema = zod.z.object({
|
|
1806
|
+
after: zod.z.string().datetime().optional(),
|
|
1807
|
+
before: zod.z.string().datetime().optional(),
|
|
1808
|
+
modified_after: zod.z.string().datetime().optional(),
|
|
1809
|
+
modified_before: zod.z.string().datetime().optional(),
|
|
1810
|
+
dates_are_gmt: zod.z.boolean().default(false)
|
|
1811
|
+
});
|
|
1812
|
+
var wcMetaDataSchema = zod.z.object({
|
|
1813
|
+
id: zod.z.number(),
|
|
1814
|
+
key: zod.z.string(),
|
|
1815
|
+
value: zod.z.any()
|
|
1816
|
+
});
|
|
1817
|
+
var wcAddressSchema = zod.z.object({
|
|
1818
|
+
first_name: zod.z.string().default(""),
|
|
1819
|
+
last_name: zod.z.string().default(""),
|
|
1820
|
+
company: zod.z.string().default(""),
|
|
1821
|
+
address_1: zod.z.string().default(""),
|
|
1822
|
+
address_2: zod.z.string().default(""),
|
|
1823
|
+
city: zod.z.string().default(""),
|
|
1824
|
+
state: zod.z.string().default(""),
|
|
1825
|
+
postcode: zod.z.string().default(""),
|
|
1826
|
+
country: zod.z.string().default("BA"),
|
|
1827
|
+
phone: zod.z.string().default(""),
|
|
1828
|
+
email: zod.z.string().email().optional()
|
|
1829
|
+
});
|
|
1830
|
+
var wcBaseParamsSchema = zod.z.object({
|
|
1831
|
+
...basePaginationSchema.shape,
|
|
1832
|
+
...baseFilteringSchema.shape,
|
|
1833
|
+
...wcSortingSchema.shape
|
|
1834
|
+
});
|
|
1835
|
+
var wcBaseResponseSchema = zod.z.object({
|
|
1836
|
+
_links: wpLinksSchema,
|
|
1837
|
+
meta_data: zod.z.array(wcMetaDataSchema).optional()
|
|
1838
|
+
});
|
|
1839
|
+
zod.z.object({
|
|
1840
|
+
total: zod.z.number(),
|
|
1841
|
+
totalPages: zod.z.number(),
|
|
1842
|
+
currentPage: zod.z.number(),
|
|
1843
|
+
perPage: zod.z.number()
|
|
1844
|
+
});
|
|
1845
|
+
var wcErrorResponseSchema = zod.z.object({
|
|
1846
|
+
code: getAppEnumZod("COMMON_ERROR_CODES"),
|
|
1847
|
+
message: zod.z.string(),
|
|
1848
|
+
data: zod.z.object({
|
|
1849
|
+
status: zod.z.number()
|
|
1850
|
+
}).optional()
|
|
1851
|
+
}).passthrough();
|
|
1852
|
+
|
|
1853
|
+
// src/schemas/admin-api/coupons/coupon-filter.schema.ts
|
|
1854
|
+
var couponFilterSchema = wcBaseParamsSchema.extend({
|
|
1855
|
+
orderby: getAppEnumZod("COUPONS_ORDER_BY").default("date"),
|
|
1856
|
+
code: zod.z.string().optional()
|
|
1857
|
+
});
|
|
1858
|
+
var couponSchema = wcBaseResponseSchema.extend({
|
|
1859
|
+
id: zod.z.number(),
|
|
1860
|
+
code: zod.z.string(),
|
|
1861
|
+
amount: zod.z.string(),
|
|
1862
|
+
status: zod.z.string(),
|
|
1863
|
+
discount_type: zod.z.enum(["percent", "fixed_cart", "fixed_product"]),
|
|
1864
|
+
description: zod.z.string(),
|
|
1865
|
+
date_expires: zod.z.string().nullable(),
|
|
1866
|
+
usage_count: zod.z.number(),
|
|
1867
|
+
individual_use: zod.z.boolean(),
|
|
1868
|
+
product_ids: zod.z.array(zod.z.number()),
|
|
1869
|
+
excluded_product_ids: zod.z.array(zod.z.number()),
|
|
1870
|
+
usage_limit: zod.z.number().nullable(),
|
|
1871
|
+
usage_limit_per_user: zod.z.number().nullable(),
|
|
1872
|
+
limit_usage_to_x_items: zod.z.number().nullable(),
|
|
1873
|
+
free_shipping: zod.z.boolean(),
|
|
1874
|
+
product_categories: zod.z.array(zod.z.number()),
|
|
1875
|
+
excluded_product_categories: zod.z.array(zod.z.number()),
|
|
1876
|
+
exclude_sale_items: zod.z.boolean(),
|
|
1877
|
+
minimum_amount: zod.z.string(),
|
|
1878
|
+
maximum_amount: zod.z.string(),
|
|
1879
|
+
email_restrictions: zod.z.array(zod.z.string())
|
|
1880
|
+
});
|
|
1881
|
+
var createCouponSchema = couponSchema.omit({
|
|
1882
|
+
id: true,
|
|
1883
|
+
usage_count: true
|
|
1884
|
+
}).extend({
|
|
1885
|
+
code: zod.z.string().min(1, "Code is required"),
|
|
1886
|
+
amount: zod.z.string().min(1, "Amount is required")
|
|
1887
|
+
});
|
|
1888
|
+
var customerFilterSchema = wcBaseParamsSchema.extend({
|
|
1889
|
+
orderby: getAppEnumZod("CUSTOMER_SORT_FIELDS").default("name"),
|
|
1890
|
+
role: getAppEnumZod("CUSTOMER_ROLE").default("customer"),
|
|
1891
|
+
email: zod.z.string().email().optional()
|
|
1892
|
+
});
|
|
1893
|
+
var customerSchema = wcBaseResponseSchema.extend({
|
|
1894
|
+
id: zod.z.number(),
|
|
1895
|
+
username: zod.z.string(),
|
|
1896
|
+
first_name: zod.z.string(),
|
|
1897
|
+
last_name: zod.z.string(),
|
|
1898
|
+
email: zod.z.string().email(),
|
|
1899
|
+
role: getAppEnumZod("CUSTOMER_ROLE"),
|
|
1900
|
+
date_created: zod.z.string(),
|
|
1901
|
+
date_modified: zod.z.string(),
|
|
1902
|
+
is_paying_customer: zod.z.boolean(),
|
|
1903
|
+
avatar_url: zod.z.string(),
|
|
1904
|
+
billing: wcAddressSchema.extend({
|
|
1905
|
+
email: zod.z.string().email()
|
|
1906
|
+
}),
|
|
1907
|
+
shipping: wcAddressSchema
|
|
1908
|
+
});
|
|
1909
|
+
var createCustomerSchema = customerSchema.pick({
|
|
1910
|
+
email: true,
|
|
1911
|
+
first_name: true,
|
|
1912
|
+
last_name: true,
|
|
1913
|
+
shipping: true
|
|
1914
|
+
}).extend({
|
|
1915
|
+
loyalty_card_number: zod.z.string().optional()
|
|
1916
|
+
});
|
|
1917
|
+
var updateCustomerSchema = createCustomerSchema.merge(
|
|
1918
|
+
customerSchema.pick({
|
|
1919
|
+
billing: true
|
|
1920
|
+
})
|
|
1921
|
+
).partial();
|
|
1922
|
+
var orderFilterSchema = wcBaseParamsSchema.extend({
|
|
1923
|
+
orderby: getAppEnumZod("ORDER_SORT_FIELDS").default("date"),
|
|
1924
|
+
status: zod.z.array(getAppEnumZod("ORDER_STATUS")).optional(),
|
|
1925
|
+
customer: zod.z.number().optional(),
|
|
1926
|
+
product: zod.z.number().optional(),
|
|
1927
|
+
dp: zod.z.number().default(2).optional()
|
|
1928
|
+
// decimal points
|
|
1929
|
+
}).merge(wcDateFilterSchema);
|
|
1930
|
+
var orderLineItemSchema = zod.z.object({
|
|
1931
|
+
id: zod.z.number(),
|
|
1932
|
+
name: zod.z.string(),
|
|
1933
|
+
product_id: zod.z.number(),
|
|
1934
|
+
variation_id: zod.z.number(),
|
|
1935
|
+
quantity: zod.z.number(),
|
|
1936
|
+
tax_class: zod.z.string(),
|
|
1937
|
+
subtotal: zod.z.string(),
|
|
1938
|
+
subtotal_tax: zod.z.string(),
|
|
1939
|
+
total: zod.z.string(),
|
|
1940
|
+
total_tax: zod.z.string(),
|
|
1941
|
+
sku: zod.z.string(),
|
|
1942
|
+
price: zod.z.number()
|
|
1943
|
+
});
|
|
1944
|
+
var orderSchema = wcBaseResponseSchema.extend({
|
|
1945
|
+
id: zod.z.number(),
|
|
1946
|
+
parent_id: zod.z.number(),
|
|
1947
|
+
status: getAppEnumZod("ORDER_STATUS"),
|
|
1948
|
+
currency: zod.z.string(),
|
|
1949
|
+
version: zod.z.string(),
|
|
1950
|
+
prices_include_tax: zod.z.boolean(),
|
|
1951
|
+
date_created: zod.z.string(),
|
|
1952
|
+
date_modified: zod.z.string(),
|
|
1953
|
+
discount_total: zod.z.string(),
|
|
1954
|
+
shipping_total: zod.z.string(),
|
|
1955
|
+
cart_tax: zod.z.string(),
|
|
1956
|
+
total: zod.z.string(),
|
|
1957
|
+
customer_id: zod.z.number(),
|
|
1958
|
+
order_key: zod.z.string(),
|
|
1959
|
+
billing: wcAddressSchema.extend({
|
|
1960
|
+
email: zod.z.string().email()
|
|
1961
|
+
}),
|
|
1962
|
+
shipping: wcAddressSchema,
|
|
1963
|
+
payment_method: getAppEnumZod("PAYMENT_METHODS"),
|
|
1964
|
+
payment_method_title: zod.z.string(),
|
|
1965
|
+
line_items: zod.z.array(orderLineItemSchema),
|
|
1966
|
+
// specific fields
|
|
1967
|
+
payment_url: zod.z.string().optional(),
|
|
1968
|
+
pikpay_transaction_id: zod.z.string().optional(),
|
|
1969
|
+
pikpay_status: zod.z.string().optional(),
|
|
1970
|
+
monri_transaction_id: zod.z.string().optional(),
|
|
1971
|
+
monri_status: zod.z.string().optional()
|
|
1972
|
+
});
|
|
1973
|
+
var paymentMethodFilterSchema = wcBaseParamsSchema.extend({
|
|
1974
|
+
enabled: zod.z.boolean().optional()
|
|
1975
|
+
});
|
|
1976
|
+
var paymentMethodSchema = wcBaseResponseSchema.extend({
|
|
1977
|
+
id: getAppEnumZod("PAYMENT_METHODS"),
|
|
1978
|
+
title: zod.z.string(),
|
|
1979
|
+
description: zod.z.string(),
|
|
1980
|
+
enabled: zod.z.boolean(),
|
|
1981
|
+
method_title: zod.z.string(),
|
|
1982
|
+
method_description: zod.z.string()
|
|
1983
|
+
});
|
|
1984
|
+
var categoryFilterSchema = wcBaseParamsSchema.extend({
|
|
1985
|
+
orderby: getAppEnumZod("CATEGORY_SORT_FIELDS").default("name"),
|
|
1986
|
+
hide_empty: zod.z.boolean().default(false),
|
|
1987
|
+
parent: zod.z.number().optional(),
|
|
1988
|
+
product: zod.z.number().nullable().default(null),
|
|
1989
|
+
slug: zod.z.string().optional()
|
|
1990
|
+
});
|
|
1991
|
+
var productImageSchema2 = zod.z.object({
|
|
1992
|
+
id: zod.z.number(),
|
|
1993
|
+
date_created: zod.z.string(),
|
|
1994
|
+
date_modified: zod.z.string(),
|
|
1995
|
+
src: zod.z.string(),
|
|
1996
|
+
name: zod.z.string(),
|
|
1997
|
+
alt: zod.z.string()
|
|
1998
|
+
});
|
|
1999
|
+
var productSchema2 = wcBaseResponseSchema.extend({
|
|
2000
|
+
id: zod.z.number(),
|
|
2001
|
+
name: zod.z.string(),
|
|
2002
|
+
slug: zod.z.string(),
|
|
2003
|
+
date_created: zod.z.string(),
|
|
2004
|
+
date_modified: zod.z.string(),
|
|
2005
|
+
type: zod.z.string(),
|
|
2006
|
+
status: zod.z.string(),
|
|
2007
|
+
featured: zod.z.boolean(),
|
|
2008
|
+
catalog_visibility: zod.z.string(),
|
|
2009
|
+
description: zod.z.string(),
|
|
2010
|
+
short_description: zod.z.string(),
|
|
2011
|
+
sku: zod.z.string(),
|
|
2012
|
+
price: zod.z.string(),
|
|
2013
|
+
regular_price: zod.z.string(),
|
|
2014
|
+
sale_price: zod.z.string(),
|
|
2015
|
+
stock_status: getAppEnumZod("PRODUCT_STOCK_STATUS"),
|
|
2016
|
+
stock_quantity: zod.z.number().nullable(),
|
|
2017
|
+
categories: zod.z.array(
|
|
2018
|
+
zod.z.object({
|
|
2019
|
+
id: zod.z.number(),
|
|
2020
|
+
name: zod.z.string(),
|
|
2021
|
+
slug: zod.z.string()
|
|
2022
|
+
})
|
|
2023
|
+
),
|
|
2024
|
+
images: zod.z.array(productImageSchema2),
|
|
2025
|
+
attributes: zod.z.array(
|
|
2026
|
+
zod.z.object({
|
|
2027
|
+
id: zod.z.number(),
|
|
2028
|
+
name: zod.z.string(),
|
|
2029
|
+
position: zod.z.number(),
|
|
2030
|
+
visible: zod.z.boolean(),
|
|
2031
|
+
variation: zod.z.boolean(),
|
|
2032
|
+
options: zod.z.array(zod.z.string())
|
|
2033
|
+
})
|
|
2034
|
+
),
|
|
2035
|
+
meta_data: zod.z.array(wcMetaDataSchema),
|
|
2036
|
+
on_sale: zod.z.boolean(),
|
|
2037
|
+
manufacturer: zod.z.string().optional()
|
|
2038
|
+
});
|
|
2039
|
+
|
|
2040
|
+
// src/schemas/admin-api/products/category.schema.ts
|
|
2041
|
+
var productCategorySchema2 = wcBaseResponseSchema.extend({
|
|
2042
|
+
id: zod.z.number(),
|
|
2043
|
+
name: zod.z.string(),
|
|
2044
|
+
slug: zod.z.string(),
|
|
2045
|
+
parent: zod.z.number(),
|
|
2046
|
+
description: zod.z.string(),
|
|
2047
|
+
display: zod.z.string(),
|
|
2048
|
+
image: productImageSchema2.nullable(),
|
|
2049
|
+
menu_order: zod.z.number(),
|
|
2050
|
+
count: zod.z.number()
|
|
2051
|
+
});
|
|
2052
|
+
var productFilterSchema = wcBaseParamsSchema.extend({
|
|
2053
|
+
orderby: getAppEnumZod("PRODUCT_SORT_FIELDS").default("date"),
|
|
2054
|
+
status: getAppEnumZod("PRODUCT_STATUS").default("any"),
|
|
2055
|
+
type: getAppEnumZod("PRODUCT_TYPES").optional(),
|
|
2056
|
+
sku: zod.z.string().optional(),
|
|
2057
|
+
featured: zod.z.boolean().optional(),
|
|
2058
|
+
category: zod.z.string().optional(),
|
|
2059
|
+
tag: zod.z.string().optional(),
|
|
2060
|
+
shipping_class: zod.z.string().optional(),
|
|
2061
|
+
attribute: zod.z.string().optional(),
|
|
2062
|
+
attribute_term: zod.z.string().optional(),
|
|
2063
|
+
stock_status: getAppEnumZod("PRODUCT_STOCK_STATUS").optional(),
|
|
2064
|
+
on_sale: zod.z.boolean().optional(),
|
|
2065
|
+
min_price: zod.z.string().optional(),
|
|
2066
|
+
max_price: zod.z.string().optional()
|
|
2067
|
+
}).merge(wcDateFilterSchema);
|
|
2068
|
+
var createCategorySchema = productCategorySchema2.omit({
|
|
2069
|
+
id: true,
|
|
2070
|
+
count: true
|
|
2071
|
+
}).extend({
|
|
2072
|
+
name: zod.z.string().min(1, "Name is required")
|
|
2073
|
+
});
|
|
2074
|
+
|
|
2075
|
+
// src/schemas/admin-api/index.ts
|
|
2076
|
+
var schemas = {
|
|
2077
|
+
resources: {
|
|
2078
|
+
product: {
|
|
2079
|
+
filter: productFilterSchema,
|
|
2080
|
+
entity: productSchema2,
|
|
2081
|
+
category: {
|
|
2082
|
+
filter: categoryFilterSchema,
|
|
2083
|
+
entity: productCategorySchema2
|
|
2084
|
+
}
|
|
2085
|
+
},
|
|
2086
|
+
order: {
|
|
2087
|
+
filter: orderFilterSchema,
|
|
2088
|
+
entity: orderSchema,
|
|
2089
|
+
lineItem: orderLineItemSchema
|
|
2090
|
+
},
|
|
2091
|
+
customer: {
|
|
2092
|
+
filter: customerFilterSchema,
|
|
2093
|
+
entity: customerSchema,
|
|
2094
|
+
create: createCustomerSchema,
|
|
2095
|
+
update: updateCustomerSchema
|
|
2096
|
+
},
|
|
2097
|
+
coupon: {
|
|
2098
|
+
filter: couponFilterSchema,
|
|
2099
|
+
entity: couponSchema,
|
|
2100
|
+
create: createCouponSchema
|
|
2101
|
+
},
|
|
2102
|
+
paymentMethod: {
|
|
2103
|
+
filter: paymentMethodFilterSchema,
|
|
2104
|
+
entity: paymentMethodSchema
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
exports.WooCommerceApiError = WooCommerceApiError;
|
|
2110
|
+
exports.WooCommerceDataValidationError = WooCommerceDataValidationError;
|
|
2111
|
+
exports.addToCartInputSchema = addToCartInputSchema;
|
|
2112
|
+
exports.addressSchema = addressSchema;
|
|
2113
|
+
exports.adminCategoryFilterSchema = categoryFilterSchema;
|
|
2114
|
+
exports.adminCouponFilterSchema = couponFilterSchema;
|
|
2115
|
+
exports.adminCouponSchema = couponSchema;
|
|
2116
|
+
exports.adminOrderFilterSchema = orderFilterSchema;
|
|
2117
|
+
exports.adminOrderSchema = orderSchema;
|
|
2118
|
+
exports.adminProductCategorySchema = productCategorySchema2;
|
|
2119
|
+
exports.adminProductFilterSchema = productFilterSchema;
|
|
2120
|
+
exports.adminProductSchema = productSchema2;
|
|
2121
|
+
exports.billingAddressSchema = billingAddressSchemaMandatory;
|
|
2122
|
+
exports.cartItemImageSchema = cartItemImageSchema;
|
|
2123
|
+
exports.cartSchema = cartSchema;
|
|
2124
|
+
exports.checkoutInputSchema = checkoutInputSchema;
|
|
2125
|
+
exports.checkoutSchema = checkoutSchema;
|
|
2126
|
+
exports.couponInputSchema = couponInputSchema;
|
|
2127
|
+
exports.createCategorySchema = createCategorySchema;
|
|
2128
|
+
exports.createClient = createClient;
|
|
2129
|
+
exports.createCouponSchema = createCouponSchema;
|
|
2130
|
+
exports.createCustomerSchema = createCustomerSchema;
|
|
2131
|
+
exports.customerFilterSchema = customerFilterSchema;
|
|
2132
|
+
exports.customerSchema = customerSchema;
|
|
2133
|
+
exports.getAppEnumRaw = getAppEnumRaw;
|
|
2134
|
+
exports.getAppEnumZod = getAppEnumZod;
|
|
2135
|
+
exports.paginationMetaSchema = paginationMetaSchema;
|
|
2136
|
+
exports.paginationParamsSchema = paginationParamsSchema;
|
|
2137
|
+
exports.paymentMethodFilterSchema = paymentMethodFilterSchema;
|
|
2138
|
+
exports.paymentMethodSchema = paymentMethodSchema;
|
|
2139
|
+
exports.productCategorySchema = productCategorySchema;
|
|
2140
|
+
exports.productImageSchema = productImageSchema;
|
|
2141
|
+
exports.productSchema = productSchema;
|
|
2142
|
+
exports.removeCartItemInputSchema = removeCartItemInputSchema;
|
|
2143
|
+
exports.schemas = schemas;
|
|
2144
|
+
exports.searchParamsSchema = storeProductsSearchParamsSchema;
|
|
2145
|
+
exports.selectShippingRateInputSchema = selectShippingRateInputSchema;
|
|
2146
|
+
exports.storeApiOrderSchema = storeApiOrderSchema;
|
|
2147
|
+
exports.updateCartItemInputSchema = updateCartItemInputSchema;
|
|
2148
|
+
exports.updateCustomerInputSchema = updateCustomerInputSchema;
|
|
2149
|
+
exports.updateCustomerSchema = updateCustomerSchema;
|
|
2150
|
+
exports.wcErrorResponseSchema = wcErrorResponseSchema;
|
|
2151
|
+
//# sourceMappingURL=index.js.map
|
|
2152
|
+
//# sourceMappingURL=index.js.map
|