@kizlo/woocommerce 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -8
- package/dist/index.js +46 -51
- package/dist/test.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as zod_v4_core0 from "zod/v4/core";
|
|
|
8
8
|
//#region src/product/types.d.ts
|
|
9
9
|
|
|
10
10
|
/** The exact resolved custom-field shape configured for products on this WordPress site. */
|
|
11
|
-
type ProductCustomFields = WP_CustomFields<"postTypes.product">;
|
|
11
|
+
type ProductCustomFields = WP_CustomFields<"kizlo.postTypes.product">;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/cart/schema.d.ts
|
|
14
14
|
declare const CartAdditionalFields: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodBoolean]>>;
|
|
@@ -2979,8 +2979,8 @@ declare const ProductStockStatus: z.ZodEnum<{
|
|
|
2979
2979
|
type ProductStockStatus = z.infer<typeof ProductStockStatus>;
|
|
2980
2980
|
declare const PRODUCT_CATALOG_VISIBILITIES: readonly ["any", "visible", "catalog", "search", "hidden"];
|
|
2981
2981
|
declare const ProductCatalogVisibility: z.ZodEnum<{
|
|
2982
|
-
any: "any";
|
|
2983
2982
|
search: "search";
|
|
2983
|
+
any: "any";
|
|
2984
2984
|
visible: "visible";
|
|
2985
2985
|
catalog: "catalog";
|
|
2986
2986
|
hidden: "hidden";
|
|
@@ -3095,8 +3095,8 @@ declare const ListProductInput: z.ZodObject<{
|
|
|
3095
3095
|
and: "and";
|
|
3096
3096
|
}>>;
|
|
3097
3097
|
catalogVisibility: z.ZodOptional<z.ZodEnum<{
|
|
3098
|
-
any: "any";
|
|
3099
3098
|
search: "search";
|
|
3099
|
+
any: "any";
|
|
3100
3100
|
visible: "visible";
|
|
3101
3101
|
catalog: "catalog";
|
|
3102
3102
|
hidden: "hidden";
|
|
@@ -3264,12 +3264,13 @@ declare const ProductAttributeCount: z.ZodObject<{
|
|
|
3264
3264
|
}, z.core.$strip>;
|
|
3265
3265
|
type ProductAttributeCount = z.input<typeof ProductAttributeCount>;
|
|
3266
3266
|
declare const RetrieveProductFiltersInput: z.ZodObject<{
|
|
3267
|
+
search: z.ZodOptional<z.ZodString>;
|
|
3267
3268
|
type: z.ZodOptional<z.ZodString>;
|
|
3268
3269
|
sku: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
3269
3270
|
slug: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
3270
3271
|
catalogVisibility: z.ZodOptional<z.ZodEnum<{
|
|
3271
|
-
any: "any";
|
|
3272
3272
|
search: "search";
|
|
3273
|
+
any: "any";
|
|
3273
3274
|
visible: "visible";
|
|
3274
3275
|
catalog: "catalog";
|
|
3275
3276
|
hidden: "hidden";
|
|
@@ -3288,7 +3289,6 @@ declare const RetrieveProductFiltersInput: z.ZodObject<{
|
|
|
3288
3289
|
asc: "asc";
|
|
3289
3290
|
desc: "desc";
|
|
3290
3291
|
}>>;
|
|
3291
|
-
search: z.ZodOptional<z.ZodString>;
|
|
3292
3292
|
related: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
|
|
3293
3293
|
parent: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>, z.ZodArray<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>]>>;
|
|
3294
3294
|
page: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
|
|
@@ -6057,7 +6057,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6057
6057
|
operator?: "in" | "not_in" | "and" | undefined;
|
|
6058
6058
|
}[] | undefined;
|
|
6059
6059
|
attributeRelation?: "in" | "and" | undefined;
|
|
6060
|
-
catalogVisibility?: "
|
|
6060
|
+
catalogVisibility?: "search" | "any" | "visible" | "catalog" | "hidden" | undefined;
|
|
6061
6061
|
rating?: string | number | (string | number)[] | undefined;
|
|
6062
6062
|
related?: string | number | undefined;
|
|
6063
6063
|
taxonomies?: {
|
|
@@ -6070,10 +6070,11 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6070
6070
|
}, ProductList, {}>;
|
|
6071
6071
|
filters: kizlo0.Procedure<"api", {
|
|
6072
6072
|
query?: {
|
|
6073
|
+
search?: string | undefined;
|
|
6073
6074
|
type?: string | undefined;
|
|
6074
6075
|
sku?: string | string[] | undefined;
|
|
6075
6076
|
slug?: string | string[] | undefined;
|
|
6076
|
-
catalogVisibility?: "
|
|
6077
|
+
catalogVisibility?: "search" | "any" | "visible" | "catalog" | "hidden" | undefined;
|
|
6077
6078
|
attributes?: {
|
|
6078
6079
|
taxonomy: string;
|
|
6079
6080
|
slug?: string | string[] | undefined;
|
|
@@ -6081,7 +6082,6 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6081
6082
|
operator?: "in" | "not_in" | "and" | undefined;
|
|
6082
6083
|
}[] | undefined;
|
|
6083
6084
|
order?: "asc" | "desc" | undefined;
|
|
6084
|
-
search?: string | undefined;
|
|
6085
6085
|
related?: string | number | undefined;
|
|
6086
6086
|
parent?: string | number | (string | number)[] | undefined;
|
|
6087
6087
|
page?: string | number | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1203,7 +1203,7 @@ const CART_PROCEDURES = {
|
|
|
1203
1203
|
errors: GET_CART_ERROR_MAP,
|
|
1204
1204
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1205
1205
|
}, async ({ context, errors }) => {
|
|
1206
|
-
const response = await context.wordpress.woocommerce.store.cart.
|
|
1206
|
+
const response = await context.wordpress.woocommerce.store.cart.retrieve({}, { headers: context.sessionHeaders });
|
|
1207
1207
|
if (response.error) switch (response.error.code) {
|
|
1208
1208
|
default:
|
|
1209
1209
|
context.logger.error("Get cart unhandled error", response.error, { code: response.error.code });
|
|
@@ -1220,7 +1220,7 @@ const CART_PROCEDURES = {
|
|
|
1220
1220
|
errors: UPDATE_CART_ERROR_MAP,
|
|
1221
1221
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1222
1222
|
}, async ({ context, input: { body: input }, errors }) => {
|
|
1223
|
-
const response = await context.wordpress.woocommerce.store.cart.updateCustomer(serializeCartUpdateInput(input), { headers: context.sessionHeaders });
|
|
1223
|
+
const response = await context.wordpress.woocommerce.store.cart.updateCustomer.create({ body: serializeCartUpdateInput(input) }, { headers: context.sessionHeaders });
|
|
1224
1224
|
if (response.error) switch (response.error.code) {
|
|
1225
1225
|
case "rest_invalid_param":
|
|
1226
1226
|
case "woocommerce_rest_invalid_address":
|
|
@@ -1242,10 +1242,10 @@ const CART_PROCEDURES = {
|
|
|
1242
1242
|
errors: SELECT_SHIPPING_RATE_ERROR_MAP,
|
|
1243
1243
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1244
1244
|
}, async ({ context, input: { body }, errors }) => {
|
|
1245
|
-
const response = await context.wordpress.woocommerce.store.cart.selectShippingRate({
|
|
1245
|
+
const response = await context.wordpress.woocommerce.store.cart.selectShippingRate.create({ body: {
|
|
1246
1246
|
rate_id: body.rateId,
|
|
1247
1247
|
package_id: body.packageId
|
|
1248
|
-
}, { headers: context.sessionHeaders });
|
|
1248
|
+
} }, { headers: context.sessionHeaders });
|
|
1249
1249
|
if (response.error) switch (response.error.code) {
|
|
1250
1250
|
case "woocommerce_rest_cart_shipping_rate_not_found": throw errors.CART_SHIPPING_RATE_NOT_FOUND({ message: response.error.message });
|
|
1251
1251
|
case "woocommerce_rest_shipping_disabled": throw errors.CART_SHIPPING_DISABLED({ message: response.error.message });
|
|
@@ -1265,11 +1265,11 @@ const CART_PROCEDURES = {
|
|
|
1265
1265
|
errors: ADD_CART_ITEM_ERROR_MAP,
|
|
1266
1266
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1267
1267
|
}, async ({ context, input: { body: input }, errors }) => {
|
|
1268
|
-
const response = await context.wordpress.woocommerce.store.cart.addItem({
|
|
1268
|
+
const response = await context.wordpress.woocommerce.store.cart.addItem.create({ body: {
|
|
1269
1269
|
id: input.variationId ?? input.productId,
|
|
1270
1270
|
quantity: input.quantity,
|
|
1271
1271
|
variation: input.selectedAttributes ?? []
|
|
1272
|
-
}, { headers: context.sessionHeaders });
|
|
1272
|
+
} }, { headers: context.sessionHeaders });
|
|
1273
1273
|
if (response.error) switch (response.error.code) {
|
|
1274
1274
|
case "woocommerce_rest_product_out_of_stock": throw errors.CART_ITEM_OUT_OF_STOCK({ message: response.error.message });
|
|
1275
1275
|
case "woocommerce_rest_product_partially_out_of_stock": throw errors.CART_ITEM_INSUFFICIENT_STOCK({ message: response.error.message });
|
|
@@ -1298,10 +1298,10 @@ const CART_PROCEDURES = {
|
|
|
1298
1298
|
errors: UPDATE_CART_ITEM_ERROR_MAP,
|
|
1299
1299
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1300
1300
|
}, async ({ context, input: { params, body }, errors }) => {
|
|
1301
|
-
const response = await context.wordpress.woocommerce.store.cart.updateItem({
|
|
1301
|
+
const response = await context.wordpress.woocommerce.store.cart.updateItem.create({ body: {
|
|
1302
1302
|
key: params.key,
|
|
1303
1303
|
quantity: body.quantity
|
|
1304
|
-
}, { headers: context.sessionHeaders });
|
|
1304
|
+
} }, { headers: context.sessionHeaders });
|
|
1305
1305
|
if (response.error) switch (response.error.code) {
|
|
1306
1306
|
case "woocommerce_rest_cart_invalid_key": throw errors.CART_ITEM_NOT_FOUND({ message: response.error.message });
|
|
1307
1307
|
case "woocommerce_rest_cart_invalid_product": throw errors.CART_PRODUCT_INVALID({ message: response.error.message });
|
|
@@ -1323,7 +1323,7 @@ const CART_PROCEDURES = {
|
|
|
1323
1323
|
errors: REMOVE_CART_ITEM_ERROR_MAP,
|
|
1324
1324
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1325
1325
|
}, async ({ context, input: { params }, errors }) => {
|
|
1326
|
-
const response = await context.wordpress.woocommerce.store.cart.removeItem({ key: params.key }, { headers: context.sessionHeaders });
|
|
1326
|
+
const response = await context.wordpress.woocommerce.store.cart.removeItem.create({ body: { key: params.key } }, { headers: context.sessionHeaders });
|
|
1327
1327
|
if (response.error) switch (response.error.code) {
|
|
1328
1328
|
case "woocommerce_rest_cart_invalid_key": throw errors.CART_ITEM_NOT_FOUND({ message: response.error.message });
|
|
1329
1329
|
default:
|
|
@@ -1343,7 +1343,7 @@ const CART_PROCEDURES = {
|
|
|
1343
1343
|
errors: APPLY_COUPON_ERROR_MAP,
|
|
1344
1344
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1345
1345
|
}, async ({ context, input: { body }, errors }) => {
|
|
1346
|
-
const response = await context.wordpress.woocommerce.store.cart.applyCoupon({ code: body.code }, { headers: context.sessionHeaders });
|
|
1346
|
+
const response = await context.wordpress.woocommerce.store.cart.applyCoupon.create({ body: { code: body.code } }, { headers: context.sessionHeaders });
|
|
1347
1347
|
if (response.error) switch (response.error.code) {
|
|
1348
1348
|
case "woocommerce_rest_cart_coupon_error": throw errors.CART_COUPON_INVALID({ message: response.error.message });
|
|
1349
1349
|
case "woocommerce_rest_cart_coupon_disabled": throw errors.CART_COUPON_DISABLED({ message: response.error.message });
|
|
@@ -1362,7 +1362,7 @@ const CART_PROCEDURES = {
|
|
|
1362
1362
|
errors: REMOVE_COUPON_ERROR_MAP,
|
|
1363
1363
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1364
1364
|
}, async ({ context, input, errors }) => {
|
|
1365
|
-
const response = await context.wordpress.woocommerce.store.cart.removeCoupon({ code: input.params.code }, { headers: context.sessionHeaders });
|
|
1365
|
+
const response = await context.wordpress.woocommerce.store.cart.removeCoupon.create({ body: { code: input.params.code } }, { headers: context.sessionHeaders });
|
|
1366
1366
|
if (response.error) switch (response.error.code) {
|
|
1367
1367
|
case "woocommerce_rest_cart_coupon_error": throw errors.CART_COUPON_INVALID({ message: response.error.message });
|
|
1368
1368
|
case "woocommerce_rest_cart_coupon_disabled": throw errors.CART_COUPON_DISABLED({ message: response.error.message });
|
|
@@ -1708,7 +1708,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1708
1708
|
errors: GET_CHECKOUT_ERROR_MAP,
|
|
1709
1709
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1710
1710
|
}, async ({ context, errors }) => {
|
|
1711
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1711
|
+
const response = await context.wordpress.woocommerce.store.checkout.retrieve({}, { headers: context.sessionHeaders });
|
|
1712
1712
|
if (response.error) {
|
|
1713
1713
|
if (response.error.code === "woocommerce_rest_checkout_missing_order") throw errors.CHECKOUT_ORDER_NOT_FOUND({ message: response.error.message });
|
|
1714
1714
|
context.logger.error("Get checkout unhandled error", response.error, { code: response.error.code });
|
|
@@ -1725,13 +1725,13 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1725
1725
|
errors: UPDATE_CHECKOUT_ERROR_MAP,
|
|
1726
1726
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1727
1727
|
}, async ({ context, input, errors }) => {
|
|
1728
|
-
const response = await context.wordpress.woocommerce.store.checkout.update({
|
|
1728
|
+
const response = await context.wordpress.woocommerce.store.checkout.update({ body: {
|
|
1729
1729
|
order_notes: input.body.customerNote,
|
|
1730
1730
|
payment_method: gateway(input.body.paymentMethod),
|
|
1731
1731
|
additional_fields: input.body.additionalFields,
|
|
1732
1732
|
extensions: input.body.extensions,
|
|
1733
1733
|
__experimental_calc_totals: input.body.recalculateTotals
|
|
1734
|
-
}, { headers: context.sessionHeaders });
|
|
1734
|
+
} }, { headers: context.sessionHeaders });
|
|
1735
1735
|
if (response.error) {
|
|
1736
1736
|
const conflict = conflictData(response.error.data);
|
|
1737
1737
|
switch (response.error.code) {
|
|
@@ -1778,7 +1778,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1778
1778
|
errors: CONFIRM_CHECKOUT_ERROR_MAP,
|
|
1779
1779
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1780
1780
|
}, async ({ context, input, errors }) => {
|
|
1781
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1781
|
+
const response = await context.wordpress.woocommerce.store.checkout.create({ body: {
|
|
1782
1782
|
billing_address: serializeCheckoutBillingAddress(input.body.billingAddress),
|
|
1783
1783
|
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1784
1784
|
payment_method: gateway(input.body.paymentMethod),
|
|
@@ -1791,7 +1791,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1791
1791
|
successPath: input.body.successPath,
|
|
1792
1792
|
cancelPath: input.body.cancelPath
|
|
1793
1793
|
})
|
|
1794
|
-
}, { headers: context.sessionHeaders });
|
|
1794
|
+
} }, { headers: context.sessionHeaders });
|
|
1795
1795
|
if (response.error) {
|
|
1796
1796
|
const conflict = conflictData(response.error.data);
|
|
1797
1797
|
switch (response.error.code) {
|
|
@@ -1863,20 +1863,22 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1863
1863
|
errors: RETRY_CHECKOUT_ERROR_MAP,
|
|
1864
1864
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1865
1865
|
}, async ({ context, input, errors }) => {
|
|
1866
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1866
|
+
const response = await context.wordpress.woocommerce.store.checkout.updateById({
|
|
1867
|
+
params: { id: String(input.params.orderId) },
|
|
1868
|
+
body: {
|
|
1869
|
+
key: input.body.key,
|
|
1870
|
+
payment_data: input.body.paymentData,
|
|
1871
|
+
billing_email: input.body.billingEmail,
|
|
1872
|
+
payment_method: gateway(input.body.paymentMethod),
|
|
1873
|
+
billing_address: serializeCheckoutBillingAddress(input.body.billingAddress),
|
|
1874
|
+
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1875
|
+
customer_note: input.body.customerNote,
|
|
1876
|
+
additional_fields: input.body.additionalFields,
|
|
1877
|
+
extensions: withKizloRedirectPaths(input.body.extensions, {
|
|
1878
|
+
successPath: input.body.successPath,
|
|
1879
|
+
cancelPath: input.body.cancelPath
|
|
1880
|
+
})
|
|
1881
|
+
}
|
|
1880
1882
|
}, { headers: context.sessionHeaders });
|
|
1881
1883
|
if (response.error) switch (response.error.code) {
|
|
1882
1884
|
case "rest_invalid_param": throw errors.CHECKOUT_VALIDATION_FAILED({
|
|
@@ -2027,10 +2029,10 @@ const CUSTOMER_PROCEDURES = { get: createProcedure({
|
|
|
2027
2029
|
}, async ({ context, errors }) => {
|
|
2028
2030
|
const session = await context.getSession();
|
|
2029
2031
|
if (!session) throw errors.FORBIDDEN();
|
|
2030
|
-
const response = await context.wordpress.woocommerce.customers.list({
|
|
2032
|
+
const response = await context.wordpress.woocommerce.customers.list({ query: {
|
|
2031
2033
|
email: session.email,
|
|
2032
2034
|
role: "all"
|
|
2033
|
-
});
|
|
2035
|
+
} });
|
|
2034
2036
|
if (response.error) switch (response.error.code) {
|
|
2035
2037
|
case "woocommerce_rest_cannot_view": throw errors.FORBIDDEN();
|
|
2036
2038
|
default:
|
|
@@ -2273,10 +2275,12 @@ const ORDER_PROCEDURES = { get: createProcedure({
|
|
|
2273
2275
|
errors: GET_ORDER_ERROR_MAP,
|
|
2274
2276
|
middlewares: [sessionMiddleware()]
|
|
2275
2277
|
}, async ({ context, input, errors }) => {
|
|
2276
|
-
const response = await context.wordpress.woocommerce.store.
|
|
2277
|
-
id: input.params.orderId,
|
|
2278
|
-
|
|
2279
|
-
|
|
2278
|
+
const response = await context.wordpress.woocommerce.store.order.retrieve({
|
|
2279
|
+
params: { id: String(input.params.orderId) },
|
|
2280
|
+
query: {
|
|
2281
|
+
key: input.query?.key,
|
|
2282
|
+
billing_email: input.query?.billingEmail
|
|
2283
|
+
}
|
|
2280
2284
|
}, { headers: context.sessionHeaders });
|
|
2281
2285
|
if (response.error) switch (response.error.code) {
|
|
2282
2286
|
case "woocommerce_rest_invalid_order":
|
|
@@ -2321,7 +2325,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2321
2325
|
if (input.query?.previewToken) {
|
|
2322
2326
|
const result = await context.verifyPreviewToken(input.query.previewToken);
|
|
2323
2327
|
if (!result) throw errors.PRODUCT_NOT_FOUND();
|
|
2324
|
-
const response$1 = await context.wordpress.woocommerce.products.retrieve({ id: Number(result.id) });
|
|
2328
|
+
const response$1 = await context.wordpress.woocommerce.products.retrieve({ params: { id: Number(result.id) } });
|
|
2325
2329
|
if (response$1.error) switch (response$1.error.code) {
|
|
2326
2330
|
case "woocommerce_rest_product_invalid_id": throw errors.PRODUCT_NOT_FOUND({ message: response$1.error.message });
|
|
2327
2331
|
default:
|
|
@@ -2336,13 +2340,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2336
2340
|
const identifier = input.params.identifier;
|
|
2337
2341
|
const includeRecommendations = input.query?.recommendations ?? false;
|
|
2338
2342
|
const embeds = includeRecommendations ? { _embed: PRODUCT_EMBEDS } : {};
|
|
2339
|
-
const response = typeof identifier === "number" ? await context.wordpress.woocommerce.store.products.
|
|
2340
|
-
id: identifier,
|
|
2341
|
-
...embeds
|
|
2342
|
-
}) : await context.wordpress.woocommerce.store.products.getBySlug({
|
|
2343
|
-
slug: identifier,
|
|
2344
|
-
...embeds
|
|
2345
|
-
});
|
|
2343
|
+
const response = typeof identifier === "number" ? await context.wordpress.woocommerce.store.products.retrieve({ params: { id: identifier } }, { searchParams: embeds }) : await context.wordpress.woocommerce.store.products.retrieveBySlug({ params: { slug: identifier } }, { searchParams: embeds });
|
|
2346
2344
|
if (response.error) switch (response.error.code) {
|
|
2347
2345
|
case "woocommerce_rest_product_invalid_id":
|
|
2348
2346
|
case "woocommerce_rest_product_invalid_slug": throw errors.PRODUCT_NOT_FOUND({ message: response.error.message });
|
|
@@ -2366,10 +2364,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2366
2364
|
const searchParams = serializeProductListInput(input.query);
|
|
2367
2365
|
const includeRecommendations = input.query?.recommendations ?? false;
|
|
2368
2366
|
const embeds = includeRecommendations ? { _embed: PRODUCT_EMBEDS } : {};
|
|
2369
|
-
const response = await context.wordpress.woocommerce.store.products.list({
|
|
2370
|
-
...searchParams,
|
|
2371
|
-
...embeds
|
|
2372
|
-
});
|
|
2367
|
+
const response = await context.wordpress.woocommerce.store.products.list({ query: searchParams }, { searchParams: embeds });
|
|
2373
2368
|
if (response.error) switch (response.error.code) {
|
|
2374
2369
|
default:
|
|
2375
2370
|
context.logger.error("List products unhandled error", response.error, { code: response.error.code });
|
|
@@ -2393,7 +2388,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2393
2388
|
output: ProductFilters.nullable()
|
|
2394
2389
|
}, async ({ context, errors, input }) => {
|
|
2395
2390
|
const searchParams = serializeProductListInput(input.query);
|
|
2396
|
-
const response = await context.wordpress.woocommerce.store.products.collectionData({
|
|
2391
|
+
const response = await context.wordpress.woocommerce.store.products.collectionData.retrieve({ query: {
|
|
2397
2392
|
...searchParams,
|
|
2398
2393
|
calculate_price_range: true,
|
|
2399
2394
|
calculate_rating_counts: input.query?.ratingCounts,
|
|
@@ -2403,7 +2398,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2403
2398
|
taxonomy: item.taxonomy,
|
|
2404
2399
|
query_type: item.operator
|
|
2405
2400
|
}))
|
|
2406
|
-
});
|
|
2401
|
+
} });
|
|
2407
2402
|
if (response.error) switch (response.error.code) {
|
|
2408
2403
|
default:
|
|
2409
2404
|
context.logger.error("Filter products unhandled error", response.error, { code: response.error.code });
|
|
@@ -2428,7 +2423,7 @@ function woocommerce() {
|
|
|
2428
2423
|
"woocommerce.products",
|
|
2429
2424
|
"woocommerce.store.cart",
|
|
2430
2425
|
"woocommerce.store.checkout",
|
|
2431
|
-
"woocommerce.store.
|
|
2426
|
+
"woocommerce.store.order",
|
|
2432
2427
|
"woocommerce.store.products"
|
|
2433
2428
|
]
|
|
2434
2429
|
},
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as kizlo0 from "kizlo";
|
|
2
2
|
import { DevPluginSource } from "kizlo/test";
|
|
3
3
|
|
|
4
4
|
//#region src/test/index.d.ts
|
|
@@ -20,6 +20,6 @@ declare const BANK_TRANSFER_DESCRIPTION = "Pay by transferring to our test bank
|
|
|
20
20
|
*/
|
|
21
21
|
declare function woocommerce(opts?: {
|
|
22
22
|
plugins?: DevPluginSource[];
|
|
23
|
-
}):
|
|
23
|
+
}): kizlo0.Fixture;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { BANK_TRANSFER_DESCRIPTION, BANK_TRANSFER_TITLE, woocommerce };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizlo/woocommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "WooCommerce integration for Kizlo.",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@kizlo/shared": "0.
|
|
52
|
+
"@kizlo/shared": "0.10.0",
|
|
53
53
|
"jose": "6.1.0",
|
|
54
54
|
"zod": "^4.3.6"
|
|
55
55
|
},
|