@kizlo/woocommerce 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -7
- package/dist/index.js +41 -4
- package/dist/test.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1042,6 +1042,8 @@ declare const ConfirmCheckoutInput: z$2.ZodObject<{
|
|
|
1042
1042
|
}, z$2.core.$strip>>>;
|
|
1043
1043
|
additionalFields: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnion<readonly [z$2.ZodString, z$2.ZodBoolean]>>>;
|
|
1044
1044
|
extensions: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
|
|
1045
|
+
successPath: z$2.ZodOptional<z$2.ZodString>;
|
|
1046
|
+
cancelPath: z$2.ZodOptional<z$2.ZodString>;
|
|
1045
1047
|
}, z$2.core.$strip>;
|
|
1046
1048
|
type ConfirmCheckoutInput = z$2.input<typeof ConfirmCheckoutInput>;
|
|
1047
1049
|
declare const RetryCheckoutInput: z$2.ZodObject<{
|
|
@@ -1083,6 +1085,8 @@ declare const RetryCheckoutInput: z$2.ZodObject<{
|
|
|
1083
1085
|
customerNote: z$2.ZodOptional<z$2.ZodString>;
|
|
1084
1086
|
additionalFields: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnion<readonly [z$2.ZodString, z$2.ZodBoolean]>>>;
|
|
1085
1087
|
extensions: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
|
|
1088
|
+
successPath: z$2.ZodOptional<z$2.ZodString>;
|
|
1089
|
+
cancelPath: z$2.ZodOptional<z$2.ZodString>;
|
|
1086
1090
|
}, z$2.core.$strip>;
|
|
1087
1091
|
type RetryCheckoutInput = z$2.input<typeof RetryCheckoutInput>;
|
|
1088
1092
|
//#endregion
|
|
@@ -2975,8 +2979,8 @@ declare const ProductStockStatus: z.ZodEnum<{
|
|
|
2975
2979
|
type ProductStockStatus = z.infer<typeof ProductStockStatus>;
|
|
2976
2980
|
declare const PRODUCT_CATALOG_VISIBILITIES: readonly ["any", "visible", "catalog", "search", "hidden"];
|
|
2977
2981
|
declare const ProductCatalogVisibility: z.ZodEnum<{
|
|
2978
|
-
search: "search";
|
|
2979
2982
|
any: "any";
|
|
2983
|
+
search: "search";
|
|
2980
2984
|
visible: "visible";
|
|
2981
2985
|
catalog: "catalog";
|
|
2982
2986
|
hidden: "hidden";
|
|
@@ -3091,8 +3095,8 @@ declare const ListProductInput: z.ZodObject<{
|
|
|
3091
3095
|
and: "and";
|
|
3092
3096
|
}>>;
|
|
3093
3097
|
catalogVisibility: z.ZodOptional<z.ZodEnum<{
|
|
3094
|
-
search: "search";
|
|
3095
3098
|
any: "any";
|
|
3099
|
+
search: "search";
|
|
3096
3100
|
visible: "visible";
|
|
3097
3101
|
catalog: "catalog";
|
|
3098
3102
|
hidden: "hidden";
|
|
@@ -3260,13 +3264,12 @@ declare const ProductAttributeCount: z.ZodObject<{
|
|
|
3260
3264
|
}, z.core.$strip>;
|
|
3261
3265
|
type ProductAttributeCount = z.input<typeof ProductAttributeCount>;
|
|
3262
3266
|
declare const RetrieveProductFiltersInput: z.ZodObject<{
|
|
3263
|
-
search: z.ZodOptional<z.ZodString>;
|
|
3264
3267
|
type: z.ZodOptional<z.ZodString>;
|
|
3265
3268
|
sku: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
3266
3269
|
slug: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
3267
3270
|
catalogVisibility: z.ZodOptional<z.ZodEnum<{
|
|
3268
|
-
search: "search";
|
|
3269
3271
|
any: "any";
|
|
3272
|
+
search: "search";
|
|
3270
3273
|
visible: "visible";
|
|
3271
3274
|
catalog: "catalog";
|
|
3272
3275
|
hidden: "hidden";
|
|
@@ -3285,6 +3288,7 @@ declare const RetrieveProductFiltersInput: z.ZodObject<{
|
|
|
3285
3288
|
asc: "asc";
|
|
3286
3289
|
desc: "desc";
|
|
3287
3290
|
}>>;
|
|
3291
|
+
search: z.ZodOptional<z.ZodString>;
|
|
3288
3292
|
related: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
|
|
3289
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>>>]>>;
|
|
3290
3294
|
page: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
|
|
@@ -6053,7 +6057,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6053
6057
|
operator?: "in" | "not_in" | "and" | undefined;
|
|
6054
6058
|
}[] | undefined;
|
|
6055
6059
|
attributeRelation?: "in" | "and" | undefined;
|
|
6056
|
-
catalogVisibility?: "
|
|
6060
|
+
catalogVisibility?: "any" | "search" | "visible" | "catalog" | "hidden" | undefined;
|
|
6057
6061
|
rating?: string | number | (string | number)[] | undefined;
|
|
6058
6062
|
related?: string | number | undefined;
|
|
6059
6063
|
taxonomies?: {
|
|
@@ -6066,11 +6070,10 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6066
6070
|
}, ProductList, {}>;
|
|
6067
6071
|
filters: kizlo0.Procedure<"api", {
|
|
6068
6072
|
query?: {
|
|
6069
|
-
search?: string | undefined;
|
|
6070
6073
|
type?: string | undefined;
|
|
6071
6074
|
sku?: string | string[] | undefined;
|
|
6072
6075
|
slug?: string | string[] | undefined;
|
|
6073
|
-
catalogVisibility?: "
|
|
6076
|
+
catalogVisibility?: "any" | "search" | "visible" | "catalog" | "hidden" | undefined;
|
|
6074
6077
|
attributes?: {
|
|
6075
6078
|
taxonomy: string;
|
|
6076
6079
|
slug?: string | string[] | undefined;
|
|
@@ -6078,6 +6081,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6078
6081
|
operator?: "in" | "not_in" | "and" | undefined;
|
|
6079
6082
|
}[] | undefined;
|
|
6080
6083
|
order?: "asc" | "desc" | undefined;
|
|
6084
|
+
search?: string | undefined;
|
|
6081
6085
|
related?: string | number | undefined;
|
|
6082
6086
|
parent?: string | number | (string | number)[] | undefined;
|
|
6083
6087
|
page?: string | number | undefined;
|
|
@@ -8486,6 +8490,8 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
8486
8490
|
}[] | undefined;
|
|
8487
8491
|
additionalFields?: Record<string, string | boolean> | undefined;
|
|
8488
8492
|
extensions?: Record<string, unknown> | undefined;
|
|
8493
|
+
successPath?: string | undefined;
|
|
8494
|
+
cancelPath?: string | undefined;
|
|
8489
8495
|
};
|
|
8490
8496
|
}, {
|
|
8491
8497
|
orderId: number | null;
|
|
@@ -8881,6 +8887,10 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
8881
8887
|
readonly status: 400;
|
|
8882
8888
|
readonly message: "A payment method is required.";
|
|
8883
8889
|
};
|
|
8890
|
+
readonly CHECKOUT_SHIPPING_OPTION_INVALID: {
|
|
8891
|
+
readonly status: 400;
|
|
8892
|
+
readonly message: "The selected shipping option is missing or unavailable.";
|
|
8893
|
+
};
|
|
8884
8894
|
readonly CHECKOUT_VALIDATION_FAILED: {
|
|
8885
8895
|
readonly status: 400;
|
|
8886
8896
|
readonly message: "Checkout validation failed.";
|
|
@@ -11063,6 +11073,8 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
11063
11073
|
key: string;
|
|
11064
11074
|
value: string | boolean;
|
|
11065
11075
|
}[] | undefined;
|
|
11076
|
+
successPath?: string | undefined;
|
|
11077
|
+
cancelPath?: string | undefined;
|
|
11066
11078
|
billingEmail?: string | undefined;
|
|
11067
11079
|
};
|
|
11068
11080
|
params: {
|
package/dist/index.js
CHANGED
|
@@ -1417,6 +1417,10 @@ const CONFIRM_CHECKOUT_ERROR_MAP = defineErrorMap({
|
|
|
1417
1417
|
status: 400,
|
|
1418
1418
|
message: "A payment method is required."
|
|
1419
1419
|
},
|
|
1420
|
+
CHECKOUT_SHIPPING_OPTION_INVALID: {
|
|
1421
|
+
status: 400,
|
|
1422
|
+
message: "The selected shipping option is missing or unavailable."
|
|
1423
|
+
},
|
|
1420
1424
|
CHECKOUT_VALIDATION_FAILED: {
|
|
1421
1425
|
status: 400,
|
|
1422
1426
|
message: "Checkout validation failed.",
|
|
@@ -1570,6 +1574,7 @@ const CheckoutPaymentData = z$2.array(z$2.object({
|
|
|
1570
1574
|
key: z$2.string(),
|
|
1571
1575
|
value: z$2.union([z$2.string(), z$2.boolean()])
|
|
1572
1576
|
}));
|
|
1577
|
+
const RelativePath = z$2.string().refine((value) => /^\/(?![/\\])/.test(value), "must be a relative path starting with a single '/'");
|
|
1573
1578
|
const CheckoutPaymentResult = z$2.object({
|
|
1574
1579
|
status: z$2.string(),
|
|
1575
1580
|
details: z$2.array(z$2.object({
|
|
@@ -1609,7 +1614,9 @@ const ConfirmCheckoutInput = z$2.object({
|
|
|
1609
1614
|
customerPassword: z$2.string().optional(),
|
|
1610
1615
|
paymentData: CheckoutPaymentData.optional(),
|
|
1611
1616
|
additionalFields: CheckoutAdditionalFields.optional(),
|
|
1612
|
-
extensions: CheckoutExtensions.optional()
|
|
1617
|
+
extensions: CheckoutExtensions.optional(),
|
|
1618
|
+
successPath: RelativePath.optional(),
|
|
1619
|
+
cancelPath: RelativePath.optional()
|
|
1613
1620
|
});
|
|
1614
1621
|
const RetryCheckoutInput = z$2.object({
|
|
1615
1622
|
key: z$2.string(),
|
|
@@ -1621,7 +1628,9 @@ const RetryCheckoutInput = z$2.object({
|
|
|
1621
1628
|
shippingAddress: CartShippingAddress.optional(),
|
|
1622
1629
|
customerNote: z$2.string().optional(),
|
|
1623
1630
|
additionalFields: CheckoutAdditionalFields.optional(),
|
|
1624
|
-
extensions: CheckoutExtensions.optional()
|
|
1631
|
+
extensions: CheckoutExtensions.optional(),
|
|
1632
|
+
successPath: RelativePath.optional(),
|
|
1633
|
+
cancelPath: RelativePath.optional()
|
|
1625
1634
|
});
|
|
1626
1635
|
|
|
1627
1636
|
//#endregion
|
|
@@ -1657,6 +1666,27 @@ function deserializeCheckout(data) {
|
|
|
1657
1666
|
extensions
|
|
1658
1667
|
};
|
|
1659
1668
|
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Fold the per-checkout redirect paths into `extensions.kizlo` so WooCommerce can
|
|
1671
|
+
* stamp them on the order and redirect there after checkout. Only defined paths
|
|
1672
|
+
* are added, and any existing `extensions.kizlo` block a caller passed is kept.
|
|
1673
|
+
* Returns the extensions unchanged when neither path is set.
|
|
1674
|
+
*/
|
|
1675
|
+
function withKizloRedirectPaths(extensions, paths) {
|
|
1676
|
+
const kizlo = {};
|
|
1677
|
+
if (paths.successPath !== void 0) kizlo.success_path = paths.successPath;
|
|
1678
|
+
if (paths.cancelPath !== void 0) kizlo.cancel_path = paths.cancelPath;
|
|
1679
|
+
if (Object.keys(kizlo).length === 0) return extensions;
|
|
1680
|
+
const existing = extensions?.kizlo;
|
|
1681
|
+
const existingKizlo = typeof existing === "object" && existing !== null && !Array.isArray(existing) ? existing : {};
|
|
1682
|
+
return {
|
|
1683
|
+
...extensions,
|
|
1684
|
+
kizlo: {
|
|
1685
|
+
...existingKizlo,
|
|
1686
|
+
...kizlo
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1660
1690
|
function serializeCheckoutShippingAddress(address) {
|
|
1661
1691
|
return serializeCartShippingAddress(address);
|
|
1662
1692
|
}
|
|
@@ -1757,7 +1787,10 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1757
1787
|
customer_password: input.body.customerPassword,
|
|
1758
1788
|
payment_data: input.body.paymentData,
|
|
1759
1789
|
additional_fields: input.body.additionalFields,
|
|
1760
|
-
extensions: input.body.extensions
|
|
1790
|
+
extensions: withKizloRedirectPaths(input.body.extensions, {
|
|
1791
|
+
successPath: input.body.successPath,
|
|
1792
|
+
cancelPath: input.body.cancelPath
|
|
1793
|
+
})
|
|
1761
1794
|
}, { headers: context.sessionHeaders });
|
|
1762
1795
|
if (response.error) {
|
|
1763
1796
|
const conflict = conflictData(response.error.data);
|
|
@@ -1774,6 +1807,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1774
1807
|
case "woocommerce_rest_checkout_process_payment_error": throw errors.CHECKOUT_PAYMENT_FAILED({ message: response.error.message });
|
|
1775
1808
|
case "woocommerce_rest_checkout_payment_method_disabled": throw errors.CHECKOUT_PAYMENT_METHOD_DISABLED({ message: response.error.message });
|
|
1776
1809
|
case "woocommerce_rest_checkout_missing_payment_method": throw errors.CHECKOUT_PAYMENT_METHOD_MISSING({ message: response.error.message });
|
|
1810
|
+
case "woocommerce_rest_invalid_shipping_option": throw errors.CHECKOUT_SHIPPING_OPTION_INVALID({ message: response.error.message });
|
|
1777
1811
|
case "woocommerce_rest_checkout_custom_validation_error": throw errors.CHECKOUT_VALIDATION_FAILED({
|
|
1778
1812
|
message: response.error.message,
|
|
1779
1813
|
data: { fields: {} }
|
|
@@ -1839,7 +1873,10 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1839
1873
|
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1840
1874
|
customer_note: input.body.customerNote,
|
|
1841
1875
|
additional_fields: input.body.additionalFields,
|
|
1842
|
-
extensions: input.body.extensions
|
|
1876
|
+
extensions: withKizloRedirectPaths(input.body.extensions, {
|
|
1877
|
+
successPath: input.body.successPath,
|
|
1878
|
+
cancelPath: input.body.cancelPath
|
|
1879
|
+
})
|
|
1843
1880
|
}, { headers: context.sessionHeaders });
|
|
1844
1881
|
if (response.error) switch (response.error.code) {
|
|
1845
1882
|
case "rest_invalid_param": throw errors.CHECKOUT_VALIDATION_FAILED({
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as kizlo19 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
|
+
}): kizlo19.Fixture;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { BANK_TRANSFER_DESCRIPTION, BANK_TRANSFER_TITLE, woocommerce };
|