@kizlo/woocommerce 0.17.0 → 0.18.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/README.md +16 -0
- package/dist/index.d.ts +189 -1
- package/dist/index.js +89 -43
- package/dist/test.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,12 @@ const commerce = woocommerce({ allowGuest: false })
|
|
|
65
65
|
|
|
66
66
|
`allowGuest` defaults to `true`, permitting logged-out checkout subject to WooCommerce's own guest-checkout settings and validation. Customer APIs such as `customers.get` always require login. Guest carts, product/storefront reads, and order ownership/key checks (including guest receipts) keep their existing behavior. After installing a release containing this option, replace your application checkout-auth wrapper with `woocommerce({ allowGuest: false })`; procedure inputs, outputs, and hooks stay the same.
|
|
67
67
|
|
|
68
|
+
## Read a customer before loading a cart
|
|
69
|
+
|
|
70
|
+
`customers.get()` resolves the signed-in user's email and creates a missing WooCommerce customer on demand. Account and address pages can call it directly after signup. Existing accounts and saved details are preserved; customer and cart requests share the same identity and creation lock.
|
|
71
|
+
|
|
72
|
+
Install the matching companion plugin and regenerate your WordPress contract before upgrading the SDK. The contract must include `woocommerce.kizlo.customers.retrieve`. Provisioning or lock failures return `SERVICE_UNAVAILABLE` (503), which you can retry; they do not return an empty customer or require checkout first.
|
|
73
|
+
|
|
68
74
|
## Submit partial checkout addresses
|
|
69
75
|
|
|
70
76
|
Confirm and retry accept optional core address fields, including billing email. Send only the fields you collect. The billing address object is required; shipping is optional. Each supplied address must include `additionalFields`, with any registered required answers (or `{}` when none are required).
|
|
@@ -85,6 +91,16 @@ await kizlo.woocommerce.checkout.retry.call({
|
|
|
85
91
|
|
|
86
92
|
Omitted fields produce no wire keys; explicit empty strings request clearing where WooCommerce permits it. WooCommerce validates the resulting address against its live rules through the existing checkout errors. Full-address callers remain valid. See [Billing Tax IDs](#billing-tax-ids) for Tax ID omission and [additional checkout fields](https://kizlo.io/docs/concepts/additional-checkout-fields) for registered answer contracts and native billing-to-shipping mirroring.
|
|
87
93
|
|
|
94
|
+
## Order history
|
|
95
|
+
|
|
96
|
+
`client.woocommerce.orders.list({ query: { page: 1, perPage: 10 } })` returns `{ items: Order[], meta: ListMetadata }` for the signed-in customer. Both query inputs are optional positive integers; `perPage` is capped at 100. Orders are newest first, with descending ID breaking ties. Metadata includes `page`, `totalItems`, `totalPages`, `nextPage`, `prevPage`, `hasNextPage`, and `hasPrevPage`. Empty history and pages beyond the last page succeed with an empty `items` array.
|
|
97
|
+
|
|
98
|
+
List items use the same normalized `Order` as `orders.get`, including items, additional fields, currency and totals. Both expose `number`, preserving the store's custom order numbering, and `createdAt`, the order's UTC creation time as Unix milliseconds (`0` when unavailable). Raw `status` values preserve custom statuses. Use the backend's `isPaid` and `needsPayment` flags for payment behavior; status labels do not define whether an order is paid.
|
|
99
|
+
|
|
100
|
+
History always requires login, including when `allowGuest` is enabled. The server derives the customer from the authenticated session; caller-selected email/customer IDs cannot change ownership. Internal checkout drafts and trash are excluded. Anonymous calls return `UNAUTHORIZED`, backend access denial returns `FORBIDDEN`, and other backend failures remain errors rather than empty history. History HTTP responses use `Cache-Control: private, no-store`. The existing order-key/email checks still apply to guest `orders.get` receipts.
|
|
101
|
+
|
|
102
|
+
Update the Kizlo WooCommerce plugin and run `kizlo generate` before using this API so your generated contract includes `woocommerce.kizlo.orders.list` and the shared order metadata.
|
|
103
|
+
|
|
88
104
|
## Billing Tax IDs
|
|
89
105
|
|
|
90
106
|
Billing addresses expose `taxId` on customers, carts, checkout responses, and orders. The field is always a string on output and defaults to `""` when it has not been set. Billing address inputs accept an optional `taxId`; shipping addresses have no native `taxId`, and Kizlo discards managed shipping copies independently of the hidden UI rule.
|
package/dist/index.d.ts
CHANGED
|
@@ -5647,6 +5647,8 @@ declare const Order: z.ZodObject<{
|
|
|
5647
5647
|
}>>>;
|
|
5648
5648
|
id: z.ZodNumber;
|
|
5649
5649
|
status: z.ZodString;
|
|
5650
|
+
number: z.ZodString;
|
|
5651
|
+
createdAt: z.ZodNumber;
|
|
5650
5652
|
isPaid: z.ZodBoolean;
|
|
5651
5653
|
items: z.ZodArray<z.ZodObject<{
|
|
5652
5654
|
id: z.ZodNumber;
|
|
@@ -5806,6 +5808,186 @@ declare const GetOrderInput: z.ZodObject<{
|
|
|
5806
5808
|
billingEmail: z.ZodOptional<z.ZodEmail>;
|
|
5807
5809
|
}, z.core.$strip>;
|
|
5808
5810
|
type GetOrderInput = z.input<typeof GetOrderInput>;
|
|
5811
|
+
declare const ListOrderInput: z.ZodObject<{
|
|
5812
|
+
page: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>, z.ZodInt>>;
|
|
5813
|
+
perPage: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>, z.ZodInt>>;
|
|
5814
|
+
}, z.core.$strip>;
|
|
5815
|
+
type ListOrderInput = z.input<typeof ListOrderInput>;
|
|
5816
|
+
declare const OrderList: z.ZodObject<{
|
|
5817
|
+
items: z.ZodArray<z.ZodObject<{
|
|
5818
|
+
additionalFields: z.ZodType<{
|
|
5819
|
+
[x: string]: string | boolean | undefined;
|
|
5820
|
+
}, Partial<{
|
|
5821
|
+
[x: string]: string | boolean | undefined;
|
|
5822
|
+
}>, z.core.$ZodTypeInternals<{
|
|
5823
|
+
[x: string]: string | boolean | undefined;
|
|
5824
|
+
}, Partial<{
|
|
5825
|
+
[x: string]: string | boolean | undefined;
|
|
5826
|
+
}>>>;
|
|
5827
|
+
id: z.ZodNumber;
|
|
5828
|
+
status: z.ZodString;
|
|
5829
|
+
number: z.ZodString;
|
|
5830
|
+
createdAt: z.ZodNumber;
|
|
5831
|
+
isPaid: z.ZodBoolean;
|
|
5832
|
+
items: z.ZodArray<z.ZodObject<{
|
|
5833
|
+
id: z.ZodNumber;
|
|
5834
|
+
productId: z.ZodNullable<z.ZodNumber>;
|
|
5835
|
+
variationId: z.ZodNullable<z.ZodNumber>;
|
|
5836
|
+
hsCode: z.ZodNullable<z.ZodString>;
|
|
5837
|
+
name: z.ZodString;
|
|
5838
|
+
quantity: z.ZodNumber;
|
|
5839
|
+
selectedAttributes: z.ZodArray<z.ZodObject<{
|
|
5840
|
+
name: z.ZodString;
|
|
5841
|
+
attribute: z.ZodString;
|
|
5842
|
+
value: z.ZodString;
|
|
5843
|
+
}, z.core.$strip>>;
|
|
5844
|
+
itemData: z.ZodArray<z.ZodObject<{
|
|
5845
|
+
name: z.ZodString;
|
|
5846
|
+
value: z.ZodString;
|
|
5847
|
+
display: z.ZodNullable<z.ZodString>;
|
|
5848
|
+
}, z.core.$strip>>;
|
|
5849
|
+
totals: z.ZodObject<{
|
|
5850
|
+
subtotal: z.ZodNumber;
|
|
5851
|
+
subtotalTax: z.ZodNumber;
|
|
5852
|
+
total: z.ZodNumber;
|
|
5853
|
+
totalTax: z.ZodNumber;
|
|
5854
|
+
}, z.core.$strip>;
|
|
5855
|
+
product: z.ZodNullable<z.ZodObject<{
|
|
5856
|
+
sku: z.ZodNullable<z.ZodString>;
|
|
5857
|
+
slug: z.ZodString;
|
|
5858
|
+
url: z.ZodNullable<z.ZodString>;
|
|
5859
|
+
shortDescription: z.ZodString;
|
|
5860
|
+
description: z.ZodString;
|
|
5861
|
+
images: z.ZodArray<z.ZodObject<{
|
|
5862
|
+
id: z.ZodNumber;
|
|
5863
|
+
name: z.ZodString;
|
|
5864
|
+
src: z.ZodString;
|
|
5865
|
+
mime: z.ZodOptional<z.ZodString>;
|
|
5866
|
+
type: z.ZodLiteral<"image">;
|
|
5867
|
+
alt: z.ZodString;
|
|
5868
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
5869
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
5870
|
+
variants: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
5871
|
+
src: z.ZodString;
|
|
5872
|
+
width: z.ZodNumber;
|
|
5873
|
+
height: z.ZodNumber;
|
|
5874
|
+
}, z.core.$strict>>>;
|
|
5875
|
+
srcset: z.ZodOptional<z.ZodString>;
|
|
5876
|
+
}, z.core.$strict>>;
|
|
5877
|
+
prices: z.ZodObject<{
|
|
5878
|
+
price: z.ZodNumber;
|
|
5879
|
+
regularPrice: z.ZodNumber;
|
|
5880
|
+
salePrice: z.ZodNullable<z.ZodNumber>;
|
|
5881
|
+
priceRange: z.ZodNullable<z.ZodObject<{
|
|
5882
|
+
minAmount: z.ZodNumber;
|
|
5883
|
+
maxAmount: z.ZodNumber;
|
|
5884
|
+
}, z.core.$strip>>;
|
|
5885
|
+
}, z.core.$strip>;
|
|
5886
|
+
custom: z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>;
|
|
5887
|
+
}, z.core.$strip>>;
|
|
5888
|
+
extensions: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5889
|
+
}, z.core.$strip>>;
|
|
5890
|
+
coupons: z.ZodArray<z.ZodObject<{
|
|
5891
|
+
code: z.ZodString;
|
|
5892
|
+
discountType: z.ZodString;
|
|
5893
|
+
totals: z.ZodObject<{
|
|
5894
|
+
discount: z.ZodNumber;
|
|
5895
|
+
discountTax: z.ZodNumber;
|
|
5896
|
+
}, z.core.$strip>;
|
|
5897
|
+
}, z.core.$strip>>;
|
|
5898
|
+
fees: z.ZodArray<z.ZodObject<{
|
|
5899
|
+
id: z.ZodNumber;
|
|
5900
|
+
name: z.ZodString;
|
|
5901
|
+
totals: z.ZodObject<{
|
|
5902
|
+
total: z.ZodNumber;
|
|
5903
|
+
tax: z.ZodNumber;
|
|
5904
|
+
}, z.core.$strip>;
|
|
5905
|
+
}, z.core.$strip>>;
|
|
5906
|
+
billingAddress: z.ZodObject<{
|
|
5907
|
+
additionalFields: z.ZodType<BillingAdditionalFields, BillingAdditionalFieldsInput, z.core.$ZodTypeInternals<BillingAdditionalFields, BillingAdditionalFieldsInput>>;
|
|
5908
|
+
taxId: z.ZodDefault<z.ZodString>;
|
|
5909
|
+
email: z.ZodString;
|
|
5910
|
+
firstName: z.ZodString;
|
|
5911
|
+
lastName: z.ZodString;
|
|
5912
|
+
company: z.ZodString;
|
|
5913
|
+
address1: z.ZodString;
|
|
5914
|
+
address2: z.ZodString;
|
|
5915
|
+
city: z.ZodString;
|
|
5916
|
+
state: z.ZodString;
|
|
5917
|
+
postcode: z.ZodString;
|
|
5918
|
+
country: z.ZodString;
|
|
5919
|
+
phone: z.ZodString;
|
|
5920
|
+
}, z.core.$strip>;
|
|
5921
|
+
shippingAddress: z.ZodObject<{
|
|
5922
|
+
firstName: z.ZodString;
|
|
5923
|
+
lastName: z.ZodString;
|
|
5924
|
+
company: z.ZodString;
|
|
5925
|
+
address1: z.ZodString;
|
|
5926
|
+
address2: z.ZodString;
|
|
5927
|
+
city: z.ZodString;
|
|
5928
|
+
state: z.ZodString;
|
|
5929
|
+
postcode: z.ZodString;
|
|
5930
|
+
country: z.ZodString;
|
|
5931
|
+
phone: z.ZodString;
|
|
5932
|
+
additionalFields: z.ZodType<{
|
|
5933
|
+
[x: string]: string | boolean | undefined;
|
|
5934
|
+
}, Partial<{
|
|
5935
|
+
[x: string]: string | boolean | undefined;
|
|
5936
|
+
}>, z.core.$ZodTypeInternals<{
|
|
5937
|
+
[x: string]: string | boolean | undefined;
|
|
5938
|
+
}, Partial<{
|
|
5939
|
+
[x: string]: string | boolean | undefined;
|
|
5940
|
+
}>>>;
|
|
5941
|
+
}, z.core.$strip>;
|
|
5942
|
+
needsPayment: z.ZodBoolean;
|
|
5943
|
+
needsShipping: z.ZodBoolean;
|
|
5944
|
+
paymentRequirements: z.ZodArray<z.ZodString>;
|
|
5945
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
5946
|
+
code: z.ZodString;
|
|
5947
|
+
message: z.ZodString;
|
|
5948
|
+
}, z.core.$strip>>;
|
|
5949
|
+
totals: z.ZodObject<{
|
|
5950
|
+
subtotal: z.ZodNumber;
|
|
5951
|
+
itemsTotal: z.ZodNumber;
|
|
5952
|
+
itemsTaxTotal: z.ZodNumber;
|
|
5953
|
+
feesTotal: z.ZodNumber;
|
|
5954
|
+
feesTaxTotal: z.ZodNumber;
|
|
5955
|
+
discountTotal: z.ZodNumber;
|
|
5956
|
+
discountTaxTotal: z.ZodNumber;
|
|
5957
|
+
shippingTotal: z.ZodNullable<z.ZodNumber>;
|
|
5958
|
+
shippingTaxTotal: z.ZodNullable<z.ZodNumber>;
|
|
5959
|
+
taxTotal: z.ZodNumber;
|
|
5960
|
+
refundTotal: z.ZodNumber;
|
|
5961
|
+
total: z.ZodNumber;
|
|
5962
|
+
taxLines: z.ZodArray<z.ZodObject<{
|
|
5963
|
+
name: z.ZodString;
|
|
5964
|
+
price: z.ZodNumber;
|
|
5965
|
+
rate: z.ZodString;
|
|
5966
|
+
}, z.core.$strip>>;
|
|
5967
|
+
}, z.core.$strip>;
|
|
5968
|
+
currencyFormat: z.ZodObject<{
|
|
5969
|
+
currencyCode: z.ZodString;
|
|
5970
|
+
currencySymbol: z.ZodString;
|
|
5971
|
+
currencyPrefix: z.ZodString;
|
|
5972
|
+
currencySuffix: z.ZodString;
|
|
5973
|
+
currencyMinorUnit: z.ZodNumber;
|
|
5974
|
+
currencyDecimalSeparator: z.ZodString;
|
|
5975
|
+
currencyThousandSeparator: z.ZodString;
|
|
5976
|
+
}, z.core.$strip>;
|
|
5977
|
+
}, z.core.$strip>>;
|
|
5978
|
+
meta: z.ZodObject<{
|
|
5979
|
+
page: z.ZodNumber;
|
|
5980
|
+
totalItems: z.ZodNumber;
|
|
5981
|
+
totalPages: z.ZodNumber;
|
|
5982
|
+
nextPage: z.ZodNullable<z.ZodNumber>;
|
|
5983
|
+
prevPage: z.ZodNullable<z.ZodNumber>;
|
|
5984
|
+
hasNextPage: z.ZodBoolean;
|
|
5985
|
+
hasPrevPage: z.ZodBoolean;
|
|
5986
|
+
}, z.core.$strip>;
|
|
5987
|
+
}, z.core.$strip>;
|
|
5988
|
+
type OrderList = Omit<z.infer<typeof OrderList>, "items"> & {
|
|
5989
|
+
items: Order[];
|
|
5990
|
+
};
|
|
5809
5991
|
//#endregion
|
|
5810
5992
|
//#region src/product/schema.d.ts
|
|
5811
5993
|
declare const SWATCH_TYPES: readonly ["text", "color", "image"];
|
|
@@ -8171,6 +8353,12 @@ declare function woocommerce(options?: WooCommerceOptions): kizlo0.Integration<"
|
|
|
8171
8353
|
get: kizlo0.Procedure<"api", {}, Customer, kizlo0.DefinedErrorMapLike>;
|
|
8172
8354
|
};
|
|
8173
8355
|
orders: {
|
|
8356
|
+
list: kizlo0.Procedure<"api", {
|
|
8357
|
+
query?: {
|
|
8358
|
+
page?: string | number | undefined;
|
|
8359
|
+
perPage?: string | number | undefined;
|
|
8360
|
+
} | undefined;
|
|
8361
|
+
}, OrderList, kizlo0.DefinedErrorMapLike>;
|
|
8174
8362
|
get: kizlo0.Procedure<"api", {
|
|
8175
8363
|
params: {
|
|
8176
8364
|
orderId: string | number;
|
|
@@ -8292,4 +8480,4 @@ declare function woocommerce(options?: WooCommerceOptions): kizlo0.Integration<"
|
|
|
8292
8480
|
};
|
|
8293
8481
|
}>;
|
|
8294
8482
|
//#endregion
|
|
8295
|
-
export { AddCartItemInput, type AddressAdditionalFields, type AddressAdditionalFieldsInput, ApplyCouponInput, type BillingAdditionalFields, type BillingAdditionalFieldsInput, BillingFieldProjections, Cart, CartAdditionalFields, CartBillingAddress, CartBillingAddressInput, CartBillingAddressSubmission, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingAddressInput, CartShippingAddressSubmission, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, type CheckoutAdditionalFieldsInput, CheckoutBillingAddressInput, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, CheckoutRegisteredFieldReference, CheckoutShippingAddressInput, CheckoutValidationData, CheckoutValidationIssue, ConfirmCheckoutInput, type ContactAdditionalFields, GetOrderInput, ListProductInput, ListProductInputOut, Order, OrderFee, OrderItem, OrderItemProduct, OrderTotals, PRODUCT_ATTRIBUTE_RELATIONS, PRODUCT_CATALOG_VISIBILITIES, PRODUCT_DATE_COLUMNS, PRODUCT_RATINGS, PRODUCT_STOCK_STATUSES, PRODUCT_TYPES, Product, ProductAddToCart, ProductAttributeCount, ProductAttributeFilter, ProductAttributeRelation, ProductAttributeSummary, ProductAttributeTermSummary, ProductBrandSummary, ProductCatalogVisibility, ProductCategorySummary, ProductCustomFieldsSchema, ProductDateColumn, ProductDimensions, ProductExtensions, ProductFilters, ProductFiltersAttributeTerm, ProductFiltersPriceRange, ProductFiltersRatingCount, ProductFiltersStockStatus, ProductFiltersTaxonomyTerm, ProductFiltersTerm, ProductList, ProductOrderBy, ProductPriceRange, ProductPrices, ProductRating, ProductRecommendations, ProductStockAvailability, ProductStockStatus, ProductSummary, ProductTagSummary, ProductTaxonomyFilter, ProductTaxonomyOperator, ProductTermSummary, ProductType, ProductVariationAttributeSummary, ProductVariationSummary, type RegisteredFieldGroup, type RegisteredFieldLocations, type RegisteredFieldTarget, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductFiltersInputOut, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, Storefront, StorefrontAddress, StorefrontCatalog, StorefrontCheckout, StorefrontCountry, StorefrontField, StorefrontFieldOption, StorefrontFieldOverride, StorefrontFieldRule, StorefrontFieldSchema, StorefrontPricing, SwatchType, UpdateCartAddressInput, UpdateCartItemInput, UpdateCheckoutInput, WooCommerceOptions, resolveRegisteredFieldTarget, woocommerce };
|
|
8483
|
+
export { AddCartItemInput, type AddressAdditionalFields, type AddressAdditionalFieldsInput, ApplyCouponInput, type BillingAdditionalFields, type BillingAdditionalFieldsInput, BillingFieldProjections, Cart, CartAdditionalFields, CartBillingAddress, CartBillingAddressInput, CartBillingAddressSubmission, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingAddressInput, CartShippingAddressSubmission, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, type CheckoutAdditionalFieldsInput, CheckoutBillingAddressInput, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, CheckoutRegisteredFieldReference, CheckoutShippingAddressInput, CheckoutValidationData, CheckoutValidationIssue, ConfirmCheckoutInput, type ContactAdditionalFields, GetOrderInput, ListOrderInput, ListProductInput, ListProductInputOut, Order, OrderFee, OrderItem, OrderItemProduct, OrderList, OrderTotals, PRODUCT_ATTRIBUTE_RELATIONS, PRODUCT_CATALOG_VISIBILITIES, PRODUCT_DATE_COLUMNS, PRODUCT_RATINGS, PRODUCT_STOCK_STATUSES, PRODUCT_TYPES, Product, ProductAddToCart, ProductAttributeCount, ProductAttributeFilter, ProductAttributeRelation, ProductAttributeSummary, ProductAttributeTermSummary, ProductBrandSummary, ProductCatalogVisibility, ProductCategorySummary, ProductCustomFieldsSchema, ProductDateColumn, ProductDimensions, ProductExtensions, ProductFilters, ProductFiltersAttributeTerm, ProductFiltersPriceRange, ProductFiltersRatingCount, ProductFiltersStockStatus, ProductFiltersTaxonomyTerm, ProductFiltersTerm, ProductList, ProductOrderBy, ProductPriceRange, ProductPrices, ProductRating, ProductRecommendations, ProductStockAvailability, ProductStockStatus, ProductSummary, ProductTagSummary, ProductTaxonomyFilter, ProductTaxonomyOperator, ProductTermSummary, ProductType, ProductVariationAttributeSummary, ProductVariationSummary, type RegisteredFieldGroup, type RegisteredFieldLocations, type RegisteredFieldTarget, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductFiltersInputOut, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, Storefront, StorefrontAddress, StorefrontCatalog, StorefrontCheckout, StorefrontCountry, StorefrontField, StorefrontFieldOption, StorefrontFieldOverride, StorefrontFieldRule, StorefrontFieldSchema, StorefrontPricing, SwatchType, UpdateCartAddressInput, UpdateCartItemInput, UpdateCheckoutInput, WooCommerceOptions, resolveRegisteredFieldTarget, woocommerce };
|
package/dist/index.js
CHANGED
|
@@ -2082,12 +2082,11 @@ const CUSTOMER_PROCEDURES = { get: createProcedure({
|
|
|
2082
2082
|
}, async ({ context, errors }) => {
|
|
2083
2083
|
const session = await context.getSession();
|
|
2084
2084
|
if (!session) throw errors.FORBIDDEN();
|
|
2085
|
-
const response = await context.wordpress.woocommerce.customers.
|
|
2086
|
-
email: session.email,
|
|
2087
|
-
role: "all"
|
|
2088
|
-
} });
|
|
2085
|
+
const response = await context.wordpress.woocommerce.kizlo.customers.retrieve(void 0, { headers: { "X-Kizlo-User-Email": session.email } });
|
|
2089
2086
|
if (response.error) switch (response.error.code) {
|
|
2090
|
-
case "
|
|
2087
|
+
case "kizlo_invalid_identity": throw errors.UNAUTHORIZED({ message: response.error.message });
|
|
2088
|
+
case "kizlo_forbidden_identity": throw errors.FORBIDDEN({ message: response.error.message });
|
|
2089
|
+
case "kizlo_customer_unavailable": throw errors.SERVICE_UNAVAILABLE({ message: response.error.message });
|
|
2091
2090
|
default:
|
|
2092
2091
|
context.logger.error("Get customer unhandled error", response.error, {
|
|
2093
2092
|
email: session.email,
|
|
@@ -2095,9 +2094,7 @@ const CUSTOMER_PROCEDURES = { get: createProcedure({
|
|
|
2095
2094
|
});
|
|
2096
2095
|
throw errors.INTERNAL_SERVER_ERROR();
|
|
2097
2096
|
}
|
|
2098
|
-
|
|
2099
|
-
if (!customer) throw errors.NOT_FOUND();
|
|
2100
|
-
return deserializeCustomer(customer);
|
|
2097
|
+
return deserializeCustomer(response.data);
|
|
2101
2098
|
}) };
|
|
2102
2099
|
|
|
2103
2100
|
//#endregion
|
|
@@ -2165,6 +2162,8 @@ const Order = z.object({
|
|
|
2165
2162
|
additionalFields: CheckoutAdditionalFieldsSchema,
|
|
2166
2163
|
id: z.number(),
|
|
2167
2164
|
status: z.string(),
|
|
2165
|
+
number: z.string(),
|
|
2166
|
+
createdAt: z.number(),
|
|
2168
2167
|
isPaid: z.boolean(),
|
|
2169
2168
|
items: z.array(OrderItem),
|
|
2170
2169
|
coupons: z.array(CartCoupon),
|
|
@@ -2183,6 +2182,14 @@ const GetOrderInput = z.object({
|
|
|
2183
2182
|
key: z.string().optional(),
|
|
2184
2183
|
billingEmail: z.email().optional()
|
|
2185
2184
|
});
|
|
2185
|
+
const ListOrderInput = z.object({
|
|
2186
|
+
page: NumberLike.pipe(z.int().min(1)).optional(),
|
|
2187
|
+
perPage: NumberLike.pipe(z.int().min(1).max(100)).optional()
|
|
2188
|
+
});
|
|
2189
|
+
const OrderList = z.object({
|
|
2190
|
+
items: z.array(Order),
|
|
2191
|
+
meta: ListMetadata
|
|
2192
|
+
});
|
|
2186
2193
|
|
|
2187
2194
|
//#endregion
|
|
2188
2195
|
//#region src/order/utils.ts
|
|
@@ -2209,6 +2216,8 @@ function deserializeOrder(data) {
|
|
|
2209
2216
|
additionalFields: additionalFieldValues(data.additional_fields),
|
|
2210
2217
|
id: data.id,
|
|
2211
2218
|
status: data.status,
|
|
2219
|
+
number: typeof kizlo.number === "string" ? kizlo.number : String(data.id),
|
|
2220
|
+
createdAt: timestampFromWpGmt(typeof kizlo.date_created_gmt === "string" ? kizlo.date_created_gmt : null) ?? 0,
|
|
2212
2221
|
isPaid: kizlo.is_paid === true,
|
|
2213
2222
|
items: data.items.map(deserializeOrderItem),
|
|
2214
2223
|
coupons: data.coupons.map((coupon) => ({
|
|
@@ -2322,41 +2331,76 @@ function nullableMoney(value) {
|
|
|
2322
2331
|
|
|
2323
2332
|
//#endregion
|
|
2324
2333
|
//#region src/order/index.ts
|
|
2325
|
-
const ORDER_PROCEDURES = {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
if (response.status === 404) throw errors.ORDER_NOT_FOUND({ message: response.error.message });
|
|
2348
|
-
throw errors.ORDER_FORBIDDEN({ message: response.error.message });
|
|
2349
|
-
case "woocommerce_rest_invalid_billing_email":
|
|
2350
|
-
case "woocommerce_rest_invalid_user": throw errors.ORDER_FORBIDDEN({ message: response.error.message });
|
|
2351
|
-
default:
|
|
2352
|
-
context.logger.error("Get order unhandled error", response.error, {
|
|
2353
|
-
orderId: input.params.orderId,
|
|
2354
|
-
code: response.error.code
|
|
2355
|
-
});
|
|
2334
|
+
const ORDER_PROCEDURES = {
|
|
2335
|
+
list: createProcedure({
|
|
2336
|
+
scope: "api",
|
|
2337
|
+
method: "GET",
|
|
2338
|
+
path: "/orders",
|
|
2339
|
+
query: ListOrderInput.optional(),
|
|
2340
|
+
output: schemaType(OrderList),
|
|
2341
|
+
middlewares: [createMiddleware(async ({ context, next }) => {
|
|
2342
|
+
context.headers?.set("Cache-Control", "private, no-store");
|
|
2343
|
+
return next();
|
|
2344
|
+
}), sessionMiddleware({ allowGuest: false })]
|
|
2345
|
+
}, async ({ context, input, errors }) => {
|
|
2346
|
+
const query = {
|
|
2347
|
+
page: input.query?.page ?? 1,
|
|
2348
|
+
per_page: input.query?.perPage ?? 10
|
|
2349
|
+
};
|
|
2350
|
+
const response = await context.wordpress.woocommerce.kizlo.orders.list({ query }, { headers: context.sessionHeaders });
|
|
2351
|
+
if (response.error) {
|
|
2352
|
+
if (response.status === 401) throw errors.UNAUTHORIZED();
|
|
2353
|
+
if (response.status === 403) throw errors.FORBIDDEN();
|
|
2354
|
+
if (response.status === 400) throw errors.BAD_REQUEST({ message: response.error.message });
|
|
2355
|
+
context.logger.error("List orders unhandled error", response.error, { code: response.error.code });
|
|
2356
2356
|
throw errors.INTERNAL_SERVER_ERROR();
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2357
|
+
}
|
|
2358
|
+
const list = context.wordpress.resolveList({
|
|
2359
|
+
data: response.data,
|
|
2360
|
+
headers: response.headers,
|
|
2361
|
+
searchParams: query
|
|
2362
|
+
});
|
|
2363
|
+
return {
|
|
2364
|
+
items: list.items.map(deserializeOrder),
|
|
2365
|
+
meta: deserializeListMetadata(list.meta)
|
|
2366
|
+
};
|
|
2367
|
+
}),
|
|
2368
|
+
get: createProcedure({
|
|
2369
|
+
scope: "api",
|
|
2370
|
+
method: "GET",
|
|
2371
|
+
path: "/orders/{orderId}",
|
|
2372
|
+
params: GetOrderInput.pick({ orderId: true }),
|
|
2373
|
+
query: GetOrderInput.pick({
|
|
2374
|
+
key: true,
|
|
2375
|
+
billingEmail: true
|
|
2376
|
+
}).optional(),
|
|
2377
|
+
output: schemaType(Order),
|
|
2378
|
+
errors: GET_ORDER_ERROR_MAP,
|
|
2379
|
+
middlewares: [sessionMiddleware()]
|
|
2380
|
+
}, async ({ context, input, errors }) => {
|
|
2381
|
+
const response = await context.wordpress.woocommerce.store.order.retrieve({
|
|
2382
|
+
params: { id: String(input.params.orderId) },
|
|
2383
|
+
query: {
|
|
2384
|
+
key: input.query?.key,
|
|
2385
|
+
billing_email: input.query?.billingEmail
|
|
2386
|
+
}
|
|
2387
|
+
}, { headers: context.sessionHeaders });
|
|
2388
|
+
if (response.error) switch (response.error.code) {
|
|
2389
|
+
case "woocommerce_rest_invalid_order":
|
|
2390
|
+
if (response.status === 404) throw errors.ORDER_NOT_FOUND({ message: response.error.message });
|
|
2391
|
+
throw errors.ORDER_FORBIDDEN({ message: response.error.message });
|
|
2392
|
+
case "woocommerce_rest_invalid_billing_email":
|
|
2393
|
+
case "woocommerce_rest_invalid_user": throw errors.ORDER_FORBIDDEN({ message: response.error.message });
|
|
2394
|
+
default:
|
|
2395
|
+
context.logger.error("Get order unhandled error", response.error, {
|
|
2396
|
+
orderId: input.params.orderId,
|
|
2397
|
+
code: response.error.code
|
|
2398
|
+
});
|
|
2399
|
+
throw errors.INTERNAL_SERVER_ERROR();
|
|
2400
|
+
}
|
|
2401
|
+
return deserializeOrder(response.data);
|
|
2402
|
+
})
|
|
2403
|
+
};
|
|
2360
2404
|
|
|
2361
2405
|
//#endregion
|
|
2362
2406
|
//#region src/product/error.ts
|
|
@@ -2701,6 +2745,8 @@ function woocommerce(options = {}) {
|
|
|
2701
2745
|
}],
|
|
2702
2746
|
endpoints: [
|
|
2703
2747
|
"woocommerce.customers",
|
|
2748
|
+
"woocommerce.kizlo.customers",
|
|
2749
|
+
"woocommerce.kizlo.orders.list",
|
|
2704
2750
|
"woocommerce.kizlo.storefront",
|
|
2705
2751
|
"woocommerce.products",
|
|
2706
2752
|
"woocommerce.store.cart",
|
|
@@ -2721,4 +2767,4 @@ function woocommerce(options = {}) {
|
|
|
2721
2767
|
}
|
|
2722
2768
|
|
|
2723
2769
|
//#endregion
|
|
2724
|
-
export { AddCartItemInput, ApplyCouponInput, BillingFieldProjections, Cart, CartAdditionalFields, CartBillingAddress, CartBillingAddressSubmission, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingAddressSubmission, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutBillingAddressInput, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, CheckoutRegisteredFieldReference, CheckoutShippingAddressInput, CheckoutValidationData, CheckoutValidationIssue, ConfirmCheckoutInput, GetOrderInput, ListProductInput, Order, OrderFee, OrderItem, OrderItemProduct, OrderTotals, PRODUCT_ATTRIBUTE_RELATIONS, PRODUCT_CATALOG_VISIBILITIES, PRODUCT_DATE_COLUMNS, PRODUCT_RATINGS, PRODUCT_STOCK_STATUSES, PRODUCT_TYPES, Product, ProductAddToCart, ProductAttributeCount, ProductAttributeFilter, ProductAttributeRelation, ProductAttributeSummary, ProductAttributeTermSummary, ProductBrandSummary, ProductCatalogVisibility, ProductCategorySummary, ProductCustomFieldsSchema, ProductDateColumn, ProductDimensions, ProductExtensions, ProductFilters, ProductFiltersAttributeTerm, ProductFiltersPriceRange, ProductFiltersRatingCount, ProductFiltersStockStatus, ProductFiltersTaxonomyTerm, ProductFiltersTerm, ProductList, ProductOrderBy, ProductPriceRange, ProductPrices, ProductRating, ProductRecommendations, ProductStockAvailability, ProductStockStatus, ProductSummary, ProductTagSummary, ProductTaxonomyFilter, ProductTaxonomyOperator, ProductTermSummary, ProductType, ProductVariationAttributeSummary, ProductVariationSummary, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, Storefront, StorefrontAddress, StorefrontCatalog, StorefrontCheckout, StorefrontCountry, StorefrontField, StorefrontFieldOption, StorefrontFieldOverride, StorefrontFieldRule, StorefrontFieldSchema, StorefrontPricing, SwatchType, UpdateCartAddressInput, UpdateCartItemInput, UpdateCheckoutInput, resolveRegisteredFieldTarget, woocommerce };
|
|
2770
|
+
export { AddCartItemInput, ApplyCouponInput, BillingFieldProjections, Cart, CartAdditionalFields, CartBillingAddress, CartBillingAddressSubmission, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingAddressSubmission, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutBillingAddressInput, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, CheckoutRegisteredFieldReference, CheckoutShippingAddressInput, CheckoutValidationData, CheckoutValidationIssue, ConfirmCheckoutInput, GetOrderInput, ListOrderInput, ListProductInput, Order, OrderFee, OrderItem, OrderItemProduct, OrderList, OrderTotals, PRODUCT_ATTRIBUTE_RELATIONS, PRODUCT_CATALOG_VISIBILITIES, PRODUCT_DATE_COLUMNS, PRODUCT_RATINGS, PRODUCT_STOCK_STATUSES, PRODUCT_TYPES, Product, ProductAddToCart, ProductAttributeCount, ProductAttributeFilter, ProductAttributeRelation, ProductAttributeSummary, ProductAttributeTermSummary, ProductBrandSummary, ProductCatalogVisibility, ProductCategorySummary, ProductCustomFieldsSchema, ProductDateColumn, ProductDimensions, ProductExtensions, ProductFilters, ProductFiltersAttributeTerm, ProductFiltersPriceRange, ProductFiltersRatingCount, ProductFiltersStockStatus, ProductFiltersTaxonomyTerm, ProductFiltersTerm, ProductList, ProductOrderBy, ProductPriceRange, ProductPrices, ProductRating, ProductRecommendations, ProductStockAvailability, ProductStockStatus, ProductSummary, ProductTagSummary, ProductTaxonomyFilter, ProductTaxonomyOperator, ProductTermSummary, ProductType, ProductVariationAttributeSummary, ProductVariationSummary, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, Storefront, StorefrontAddress, StorefrontCatalog, StorefrontCheckout, StorefrontCountry, StorefrontField, StorefrontFieldOption, StorefrontFieldOverride, StorefrontFieldRule, StorefrontFieldSchema, StorefrontPricing, SwatchType, UpdateCartAddressInput, UpdateCartItemInput, UpdateCheckoutInput, resolveRegisteredFieldTarget, woocommerce };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as kizlo23 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
|
+
}): kizlo23.Fixture;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { BANK_TRANSFER_DESCRIPTION, BANK_TRANSFER_TITLE, woocommerce };
|