@kizlo/woocommerce 0.9.0 → 0.11.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 CHANGED
@@ -42,6 +42,39 @@ pnpm add @kizlo/woocommerce
42
42
 
43
43
  See the [docs](https://kizlo.io/docs) for setup and usage.
44
44
 
45
+ ## Billing Tax IDs
46
+
47
+ 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 never expose or persist one.
48
+
49
+ ```ts
50
+ await kizlo.woocommerce.cart.update.call({
51
+ body: { billingAddress: { taxId: "GB123456789" } },
52
+ })
53
+ ```
54
+
55
+ Store administrators can make the field mandatory from **WooCommerce → Settings → Accounts & Privacy → Checkout → Require Tax ID at checkout**. It remains optional by default.
56
+
57
+ ## Storefront settings
58
+
59
+ `storefront.get` returns the store-wide settings a storefront renders with, so nothing has to be hardcoded:
60
+
61
+ - `address`: the countries the store sells and ships to, their states, the per-country field rules, and every checkout field including ones plugins register
62
+ - `checkout`: guest checkout, coupons, tax display, shipping and local pickup
63
+ - `pricing`: the currency format, plus how prices show tax
64
+ - `catalog`: units, review rules and stock display
65
+
66
+ A field's rules for a country are its default merged with that country's override, the way WooCommerce's Checkout block builds them:
67
+
68
+ ```ts
69
+ const store = await kizlo.woocommerce.storefront.get.call()
70
+
71
+ const country = store.address.countries.find((entry) => entry.code === "AE")
72
+ const postcode = { ...store.address.fields.postcode, ...country?.locale.postcode }
73
+ // { label: "Postal code", required: false, hidden: true, ... }
74
+ ```
75
+
76
+ The response is cached in WordPress per locale. Changing a WooCommerce setting clears it and sends the `settings.woocommerce.updated` webhook event.
77
+
45
78
  ## License
46
79
 
47
- [Apache 2.0](./LICENSE) © Kizlo
80
+ [Apache 2.0](./LICENSE) © Kizlo
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ declare const CartShippingAddress: z$1.ZodObject<{
29
29
  type CartShippingAddress = z$1.infer<typeof CartShippingAddress>;
30
30
  declare const CartBillingAddress: z$1.ZodObject<{
31
31
  email: z$1.ZodString;
32
+ taxId: z$1.ZodDefault<z$1.ZodString>;
32
33
  firstName: z$1.ZodString;
33
34
  lastName: z$1.ZodString;
34
35
  company: z$1.ZodString;
@@ -344,6 +345,7 @@ declare const Cart: z$1.ZodObject<{
344
345
  itemsWeight: z$1.ZodNumber;
345
346
  billingAddress: z$1.ZodObject<{
346
347
  email: z$1.ZodString;
348
+ taxId: z$1.ZodDefault<z$1.ZodString>;
347
349
  firstName: z$1.ZodString;
348
350
  lastName: z$1.ZodString;
349
351
  company: z$1.ZodString;
@@ -619,6 +621,7 @@ declare const UpdateCartInput: z$1.ZodObject<{
619
621
  }, z$1.core.$strip>>;
620
622
  billingAddress: z$1.ZodOptional<z$1.ZodObject<{
621
623
  email: z$1.ZodOptional<z$1.ZodString>;
624
+ taxId: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodString>>;
622
625
  firstName: z$1.ZodOptional<z$1.ZodString>;
623
626
  lastName: z$1.ZodOptional<z$1.ZodString>;
624
627
  company: z$1.ZodOptional<z$1.ZodString>;
@@ -663,6 +666,7 @@ declare const Checkout: z$2.ZodObject<{
663
666
  customerNote: z$2.ZodString;
664
667
  billingAddress: z$2.ZodObject<{
665
668
  email: z$2.ZodString;
669
+ taxId: z$2.ZodDefault<z$2.ZodString>;
666
670
  firstName: z$2.ZodString;
667
671
  lastName: z$2.ZodString;
668
672
  company: z$2.ZodString;
@@ -770,6 +774,7 @@ declare const Checkout: z$2.ZodObject<{
770
774
  itemsWeight: z$2.ZodNumber;
771
775
  billingAddress: z$2.ZodObject<{
772
776
  email: z$2.ZodString;
777
+ taxId: z$2.ZodDefault<z$2.ZodString>;
773
778
  firstName: z$2.ZodString;
774
779
  lastName: z$2.ZodString;
775
780
  company: z$2.ZodString;
@@ -1008,6 +1013,7 @@ type UpdateCheckoutInput = z$2.input<typeof UpdateCheckoutInput>;
1008
1013
  declare const ConfirmCheckoutInput: z$2.ZodObject<{
1009
1014
  billingAddress: z$2.ZodObject<{
1010
1015
  email: z$2.ZodString;
1016
+ taxId: z$2.ZodDefault<z$2.ZodString>;
1011
1017
  firstName: z$2.ZodString;
1012
1018
  lastName: z$2.ZodString;
1013
1019
  company: z$2.ZodString;
@@ -1054,6 +1060,7 @@ declare const RetryCheckoutInput: z$2.ZodObject<{
1054
1060
  billingEmail: z$2.ZodOptional<z$2.ZodEmail>;
1055
1061
  billingAddress: z$2.ZodObject<{
1056
1062
  email: z$2.ZodString;
1063
+ taxId: z$2.ZodDefault<z$2.ZodString>;
1057
1064
  firstName: z$2.ZodString;
1058
1065
  lastName: z$2.ZodString;
1059
1066
  company: z$2.ZodString;
@@ -1132,6 +1139,7 @@ declare const OrderItem: z.ZodObject<{
1132
1139
  id: z.ZodNumber;
1133
1140
  productId: z.ZodNullable<z.ZodNumber>;
1134
1141
  variationId: z.ZodNullable<z.ZodNumber>;
1142
+ hsCode: z.ZodNullable<z.ZodString>;
1135
1143
  name: z.ZodString;
1136
1144
  quantity: z.ZodNumber;
1137
1145
  selectedAttributes: z.ZodArray<z.ZodObject<{
@@ -1225,6 +1233,7 @@ declare const Order: z.ZodObject<{
1225
1233
  id: z.ZodNumber;
1226
1234
  productId: z.ZodNullable<z.ZodNumber>;
1227
1235
  variationId: z.ZodNullable<z.ZodNumber>;
1236
+ hsCode: z.ZodNullable<z.ZodString>;
1228
1237
  name: z.ZodString;
1229
1238
  quantity: z.ZodNumber;
1230
1239
  selectedAttributes: z.ZodArray<z.ZodObject<{
@@ -1296,6 +1305,7 @@ declare const Order: z.ZodObject<{
1296
1305
  }, z.core.$strip>>;
1297
1306
  billingAddress: z.ZodObject<{
1298
1307
  email: z.ZodString;
1308
+ taxId: z.ZodDefault<z.ZodString>;
1299
1309
  firstName: z.ZodString;
1300
1310
  lastName: z.ZodString;
1301
1311
  company: z.ZodString;
@@ -2035,6 +2045,7 @@ declare const Product: z.ZodObject<{
2035
2045
  formattedWeight: z.ZodString;
2036
2046
  formattedDimensions: z.ZodString;
2037
2047
  stockQuantity: z.ZodNullable<z.ZodNumber>;
2048
+ hsCode: z.ZodNullable<z.ZodString>;
2038
2049
  saleStartsAt: z.ZodNullable<z.ZodNumber>;
2039
2050
  saleEndsAt: z.ZodNullable<z.ZodNumber>;
2040
2051
  seo: z.ZodNullable<z.ZodObject<{
@@ -2537,6 +2548,7 @@ declare const ProductList: z.ZodObject<{
2537
2548
  formattedWeight: z.ZodString;
2538
2549
  formattedDimensions: z.ZodString;
2539
2550
  stockQuantity: z.ZodNullable<z.ZodNumber>;
2551
+ hsCode: z.ZodNullable<z.ZodString>;
2540
2552
  saleStartsAt: z.ZodNullable<z.ZodNumber>;
2541
2553
  saleEndsAt: z.ZodNullable<z.ZodNumber>;
2542
2554
  seo: z.ZodNullable<z.ZodObject<{
@@ -3380,6 +3392,229 @@ declare const RetrieveProductFiltersInput: z.ZodObject<{
3380
3392
  type RetrieveProductFiltersInput = z.input<typeof RetrieveProductFiltersInput>;
3381
3393
  type RetrieveProductFiltersInputOut = z.output<typeof RetrieveProductFiltersInput>;
3382
3394
  //#endregion
3395
+ //#region src/storefront/schema.d.ts
3396
+ /**
3397
+ * A plugin-registered field may make `required` or `hidden` a JSON Schema rule evaluated against the
3398
+ * checkout rather than a fixed boolean.
3399
+ */
3400
+ declare const StorefrontFieldRule: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3401
+ type StorefrontFieldRule = z$2.infer<typeof StorefrontFieldRule>;
3402
+ declare const StorefrontFieldOption: z$2.ZodObject<{
3403
+ value: z$2.ZodString;
3404
+ label: z$2.ZodString;
3405
+ }, z$2.core.$strip>;
3406
+ type StorefrontFieldOption = z$2.infer<typeof StorefrontFieldOption>;
3407
+ declare const StorefrontField: z$2.ZodObject<{
3408
+ label: z$2.ZodString;
3409
+ optionalLabel: z$2.ZodString;
3410
+ required: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3411
+ hidden: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3412
+ type: z$2.ZodNullable<z$2.ZodString>;
3413
+ autocomplete: z$2.ZodNullable<z$2.ZodString>;
3414
+ index: z$2.ZodNullable<z$2.ZodNumber>;
3415
+ placeholder: z$2.ZodNullable<z$2.ZodString>;
3416
+ options: z$2.ZodArray<z$2.ZodObject<{
3417
+ value: z$2.ZodString;
3418
+ label: z$2.ZodString;
3419
+ }, z$2.core.$strip>>;
3420
+ }, z$2.core.$strip>;
3421
+ type StorefrontField = z$2.infer<typeof StorefrontField>;
3422
+ /** What a country changes about a field. Anything it leaves out keeps the field's default. */
3423
+ declare const StorefrontFieldOverride: z$2.ZodObject<{
3424
+ label: z$2.ZodOptional<z$2.ZodString>;
3425
+ required: z$2.ZodOptional<z$2.ZodBoolean>;
3426
+ hidden: z$2.ZodOptional<z$2.ZodBoolean>;
3427
+ index: z$2.ZodOptional<z$2.ZodNumber>;
3428
+ }, z$2.core.$strip>;
3429
+ type StorefrontFieldOverride = z$2.infer<typeof StorefrontFieldOverride>;
3430
+ declare const StorefrontCountry: z$2.ZodObject<{
3431
+ code: z$2.ZodString;
3432
+ name: z$2.ZodString;
3433
+ allowBilling: z$2.ZodBoolean;
3434
+ allowShipping: z$2.ZodBoolean;
3435
+ states: z$2.ZodArray<z$2.ZodObject<{
3436
+ code: z$2.ZodString;
3437
+ name: z$2.ZodString;
3438
+ }, z$2.core.$strip>>;
3439
+ locale: z$2.ZodRecord<z$2.ZodString, z$2.ZodObject<{
3440
+ label: z$2.ZodOptional<z$2.ZodString>;
3441
+ required: z$2.ZodOptional<z$2.ZodBoolean>;
3442
+ hidden: z$2.ZodOptional<z$2.ZodBoolean>;
3443
+ index: z$2.ZodOptional<z$2.ZodNumber>;
3444
+ }, z$2.core.$strip>>;
3445
+ format: z$2.ZodString;
3446
+ }, z$2.core.$strip>;
3447
+ type StorefrontCountry = z$2.infer<typeof StorefrontCountry>;
3448
+ declare const StorefrontAddress: z$2.ZodObject<{
3449
+ countries: z$2.ZodArray<z$2.ZodObject<{
3450
+ code: z$2.ZodString;
3451
+ name: z$2.ZodString;
3452
+ allowBilling: z$2.ZodBoolean;
3453
+ allowShipping: z$2.ZodBoolean;
3454
+ states: z$2.ZodArray<z$2.ZodObject<{
3455
+ code: z$2.ZodString;
3456
+ name: z$2.ZodString;
3457
+ }, z$2.core.$strip>>;
3458
+ locale: z$2.ZodRecord<z$2.ZodString, z$2.ZodObject<{
3459
+ label: z$2.ZodOptional<z$2.ZodString>;
3460
+ required: z$2.ZodOptional<z$2.ZodBoolean>;
3461
+ hidden: z$2.ZodOptional<z$2.ZodBoolean>;
3462
+ index: z$2.ZodOptional<z$2.ZodNumber>;
3463
+ }, z$2.core.$strip>>;
3464
+ format: z$2.ZodString;
3465
+ }, z$2.core.$strip>>;
3466
+ defaultAddressFormat: z$2.ZodString;
3467
+ fields: z$2.ZodRecord<z$2.ZodString, z$2.ZodObject<{
3468
+ label: z$2.ZodString;
3469
+ optionalLabel: z$2.ZodString;
3470
+ required: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3471
+ hidden: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3472
+ type: z$2.ZodNullable<z$2.ZodString>;
3473
+ autocomplete: z$2.ZodNullable<z$2.ZodString>;
3474
+ index: z$2.ZodNullable<z$2.ZodNumber>;
3475
+ placeholder: z$2.ZodNullable<z$2.ZodString>;
3476
+ options: z$2.ZodArray<z$2.ZodObject<{
3477
+ value: z$2.ZodString;
3478
+ label: z$2.ZodString;
3479
+ }, z$2.core.$strip>>;
3480
+ }, z$2.core.$strip>>;
3481
+ fieldLocations: z$2.ZodObject<{
3482
+ address: z$2.ZodArray<z$2.ZodString>;
3483
+ contact: z$2.ZodArray<z$2.ZodString>;
3484
+ order: z$2.ZodArray<z$2.ZodString>;
3485
+ }, z$2.core.$strip>;
3486
+ baseCountry: z$2.ZodString;
3487
+ defaultCountry: z$2.ZodNullable<z$2.ZodString>;
3488
+ }, z$2.core.$strip>;
3489
+ type StorefrontAddress = z$2.infer<typeof StorefrontAddress>;
3490
+ declare const StorefrontCheckout: z$2.ZodObject<{
3491
+ allowsGuest: z$2.ZodBoolean;
3492
+ couponsEnabled: z$2.ZodBoolean;
3493
+ forcedBillingAddress: z$2.ZodBoolean;
3494
+ taxesEnabled: z$2.ZodBoolean;
3495
+ displayCartPricesIncludingTax: z$2.ZodBoolean;
3496
+ displayItemizedTaxes: z$2.ZodBoolean;
3497
+ shippingEnabled: z$2.ZodBoolean;
3498
+ localPickup: z$2.ZodObject<{
3499
+ enabled: z$2.ZodBoolean;
3500
+ title: z$2.ZodString;
3501
+ cost: z$2.ZodString;
3502
+ }, z$2.core.$strip>;
3503
+ }, z$2.core.$strip>;
3504
+ type StorefrontCheckout = z$2.infer<typeof StorefrontCheckout>;
3505
+ declare const StorefrontPricing: z$2.ZodObject<{
3506
+ currency: z$2.ZodObject<{
3507
+ currencyCode: z$2.ZodString;
3508
+ currencySymbol: z$2.ZodString;
3509
+ currencyPrefix: z$2.ZodString;
3510
+ currencySuffix: z$2.ZodString;
3511
+ currencyMinorUnit: z$2.ZodNumber;
3512
+ currencyDecimalSeparator: z$2.ZodString;
3513
+ currencyThousandSeparator: z$2.ZodString;
3514
+ }, z$2.core.$strip>;
3515
+ pricesIncludeTax: z$2.ZodBoolean;
3516
+ displayShopPricesIncludingTax: z$2.ZodBoolean;
3517
+ priceSuffix: z$2.ZodString;
3518
+ }, z$2.core.$strip>;
3519
+ type StorefrontPricing = z$2.infer<typeof StorefrontPricing>;
3520
+ declare const StorefrontCatalog: z$2.ZodObject<{
3521
+ weightUnit: z$2.ZodString;
3522
+ dimensionUnit: z$2.ZodString;
3523
+ reviewsEnabled: z$2.ZodBoolean;
3524
+ reviewRatingsEnabled: z$2.ZodBoolean;
3525
+ reviewRatingRequired: z$2.ZodBoolean;
3526
+ reviewsVerifiedOwnersOnly: z$2.ZodBoolean;
3527
+ stockFormat: z$2.ZodString;
3528
+ hideOutOfStock: z$2.ZodBoolean;
3529
+ placeholderImage: z$2.ZodString;
3530
+ cartRedirectAfterAdd: z$2.ZodBoolean;
3531
+ }, z$2.core.$strip>;
3532
+ type StorefrontCatalog = z$2.infer<typeof StorefrontCatalog>;
3533
+ declare const Storefront: z$2.ZodObject<{
3534
+ address: z$2.ZodObject<{
3535
+ countries: z$2.ZodArray<z$2.ZodObject<{
3536
+ code: z$2.ZodString;
3537
+ name: z$2.ZodString;
3538
+ allowBilling: z$2.ZodBoolean;
3539
+ allowShipping: z$2.ZodBoolean;
3540
+ states: z$2.ZodArray<z$2.ZodObject<{
3541
+ code: z$2.ZodString;
3542
+ name: z$2.ZodString;
3543
+ }, z$2.core.$strip>>;
3544
+ locale: z$2.ZodRecord<z$2.ZodString, z$2.ZodObject<{
3545
+ label: z$2.ZodOptional<z$2.ZodString>;
3546
+ required: z$2.ZodOptional<z$2.ZodBoolean>;
3547
+ hidden: z$2.ZodOptional<z$2.ZodBoolean>;
3548
+ index: z$2.ZodOptional<z$2.ZodNumber>;
3549
+ }, z$2.core.$strip>>;
3550
+ format: z$2.ZodString;
3551
+ }, z$2.core.$strip>>;
3552
+ defaultAddressFormat: z$2.ZodString;
3553
+ fields: z$2.ZodRecord<z$2.ZodString, z$2.ZodObject<{
3554
+ label: z$2.ZodString;
3555
+ optionalLabel: z$2.ZodString;
3556
+ required: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3557
+ hidden: z$2.ZodUnion<readonly [z$2.ZodBoolean, z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>]>;
3558
+ type: z$2.ZodNullable<z$2.ZodString>;
3559
+ autocomplete: z$2.ZodNullable<z$2.ZodString>;
3560
+ index: z$2.ZodNullable<z$2.ZodNumber>;
3561
+ placeholder: z$2.ZodNullable<z$2.ZodString>;
3562
+ options: z$2.ZodArray<z$2.ZodObject<{
3563
+ value: z$2.ZodString;
3564
+ label: z$2.ZodString;
3565
+ }, z$2.core.$strip>>;
3566
+ }, z$2.core.$strip>>;
3567
+ fieldLocations: z$2.ZodObject<{
3568
+ address: z$2.ZodArray<z$2.ZodString>;
3569
+ contact: z$2.ZodArray<z$2.ZodString>;
3570
+ order: z$2.ZodArray<z$2.ZodString>;
3571
+ }, z$2.core.$strip>;
3572
+ baseCountry: z$2.ZodString;
3573
+ defaultCountry: z$2.ZodNullable<z$2.ZodString>;
3574
+ }, z$2.core.$strip>;
3575
+ checkout: z$2.ZodObject<{
3576
+ allowsGuest: z$2.ZodBoolean;
3577
+ couponsEnabled: z$2.ZodBoolean;
3578
+ forcedBillingAddress: z$2.ZodBoolean;
3579
+ taxesEnabled: z$2.ZodBoolean;
3580
+ displayCartPricesIncludingTax: z$2.ZodBoolean;
3581
+ displayItemizedTaxes: z$2.ZodBoolean;
3582
+ shippingEnabled: z$2.ZodBoolean;
3583
+ localPickup: z$2.ZodObject<{
3584
+ enabled: z$2.ZodBoolean;
3585
+ title: z$2.ZodString;
3586
+ cost: z$2.ZodString;
3587
+ }, z$2.core.$strip>;
3588
+ }, z$2.core.$strip>;
3589
+ pricing: z$2.ZodObject<{
3590
+ currency: z$2.ZodObject<{
3591
+ currencyCode: z$2.ZodString;
3592
+ currencySymbol: z$2.ZodString;
3593
+ currencyPrefix: z$2.ZodString;
3594
+ currencySuffix: z$2.ZodString;
3595
+ currencyMinorUnit: z$2.ZodNumber;
3596
+ currencyDecimalSeparator: z$2.ZodString;
3597
+ currencyThousandSeparator: z$2.ZodString;
3598
+ }, z$2.core.$strip>;
3599
+ pricesIncludeTax: z$2.ZodBoolean;
3600
+ displayShopPricesIncludingTax: z$2.ZodBoolean;
3601
+ priceSuffix: z$2.ZodString;
3602
+ }, z$2.core.$strip>;
3603
+ catalog: z$2.ZodObject<{
3604
+ weightUnit: z$2.ZodString;
3605
+ dimensionUnit: z$2.ZodString;
3606
+ reviewsEnabled: z$2.ZodBoolean;
3607
+ reviewRatingsEnabled: z$2.ZodBoolean;
3608
+ reviewRatingRequired: z$2.ZodBoolean;
3609
+ reviewsVerifiedOwnersOnly: z$2.ZodBoolean;
3610
+ stockFormat: z$2.ZodString;
3611
+ hideOutOfStock: z$2.ZodBoolean;
3612
+ placeholderImage: z$2.ZodString;
3613
+ cartRedirectAfterAdd: z$2.ZodBoolean;
3614
+ }, z$2.core.$strip>;
3615
+ }, z$2.core.$strip>;
3616
+ type Storefront = z$2.infer<typeof Storefront>;
3617
+ //#endregion
3383
3618
  //#region src/index.d.ts
3384
3619
  declare function woocommerce(): kizlo0.Integration<"woocommerce", {
3385
3620
  cart: {
@@ -3459,6 +3694,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
3459
3694
  itemsWeight: number;
3460
3695
  billingAddress: {
3461
3696
  email: string;
3697
+ taxId: string;
3462
3698
  firstName: string;
3463
3699
  lastName: string;
3464
3700
  company: string;
@@ -3708,6 +3944,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
3708
3944
  } | undefined;
3709
3945
  billingAddress?: {
3710
3946
  email?: string | undefined;
3947
+ taxId?: string | undefined;
3711
3948
  firstName?: string | undefined;
3712
3949
  lastName?: string | undefined;
3713
3950
  company?: string | undefined;
@@ -3797,6 +4034,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
3797
4034
  itemsWeight: number;
3798
4035
  billingAddress: {
3799
4036
  email: string;
4037
+ taxId: string;
3800
4038
  firstName: string;
3801
4039
  lastName: string;
3802
4040
  company: string;
@@ -4115,6 +4353,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
4115
4353
  itemsWeight: number;
4116
4354
  billingAddress: {
4117
4355
  email: string;
4356
+ taxId: string;
4118
4357
  firstName: string;
4119
4358
  lastName: string;
4120
4359
  company: string;
@@ -4443,6 +4682,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
4443
4682
  itemsWeight: number;
4444
4683
  billingAddress: {
4445
4684
  email: string;
4685
+ taxId: string;
4446
4686
  firstName: string;
4447
4687
  lastName: string;
4448
4688
  company: string;
@@ -4787,6 +5027,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
4787
5027
  itemsWeight: number;
4788
5028
  billingAddress: {
4789
5029
  email: string;
5030
+ taxId: string;
4790
5031
  firstName: string;
4791
5032
  lastName: string;
4792
5033
  company: string;
@@ -5120,6 +5361,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
5120
5361
  itemsWeight: number;
5121
5362
  billingAddress: {
5122
5363
  email: string;
5364
+ taxId: string;
5123
5365
  firstName: string;
5124
5366
  lastName: string;
5125
5367
  company: string;
@@ -5439,6 +5681,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
5439
5681
  itemsWeight: number;
5440
5682
  billingAddress: {
5441
5683
  email: string;
5684
+ taxId: string;
5442
5685
  firstName: string;
5443
5686
  lastName: string;
5444
5687
  company: string;
@@ -5760,6 +6003,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
5760
6003
  itemsWeight: number;
5761
6004
  billingAddress: {
5762
6005
  email: string;
6006
+ taxId: string;
5763
6007
  firstName: string;
5764
6008
  lastName: string;
5765
6009
  company: string;
@@ -6194,6 +6438,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
6194
6438
  customerNote: string;
6195
6439
  billingAddress: {
6196
6440
  email: string;
6441
+ taxId: string;
6197
6442
  firstName: string;
6198
6443
  lastName: string;
6199
6444
  company: string;
@@ -6311,6 +6556,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
6311
6556
  itemsWeight: number;
6312
6557
  billingAddress: {
6313
6558
  email: string;
6559
+ taxId: string;
6314
6560
  firstName: string;
6315
6561
  lastName: string;
6316
6562
  company: string;
@@ -6570,6 +6816,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
6570
6816
  customerNote: string;
6571
6817
  billingAddress: {
6572
6818
  email: string;
6819
+ taxId: string;
6573
6820
  firstName: string;
6574
6821
  lastName: string;
6575
6822
  company: string;
@@ -6687,6 +6934,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
6687
6934
  itemsWeight: number;
6688
6935
  billingAddress: {
6689
6936
  email: string;
6937
+ taxId: string;
6690
6938
  firstName: string;
6691
6939
  lastName: string;
6692
6940
  company: string;
@@ -7018,6 +7266,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
7018
7266
  itemsWeight: zod0.ZodNumber;
7019
7267
  billingAddress: zod0.ZodObject<{
7020
7268
  email: zod0.ZodString;
7269
+ taxId: zod0.ZodDefault<zod0.ZodString>;
7021
7270
  firstName: zod0.ZodString;
7022
7271
  lastName: zod0.ZodString;
7023
7272
  company: zod0.ZodString;
@@ -7320,6 +7569,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
7320
7569
  itemsWeight: zod0.ZodNumber;
7321
7570
  billingAddress: zod0.ZodObject<{
7322
7571
  email: zod0.ZodString;
7572
+ taxId: zod0.ZodDefault<zod0.ZodString>;
7323
7573
  firstName: zod0.ZodString;
7324
7574
  lastName: zod0.ZodString;
7325
7575
  company: zod0.ZodString;
@@ -7622,6 +7872,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
7622
7872
  itemsWeight: zod0.ZodNumber;
7623
7873
  billingAddress: zod0.ZodObject<{
7624
7874
  email: zod0.ZodString;
7875
+ taxId: zod0.ZodDefault<zod0.ZodString>;
7625
7876
  firstName: zod0.ZodString;
7626
7877
  lastName: zod0.ZodString;
7627
7878
  company: zod0.ZodString;
@@ -7924,6 +8175,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
7924
8175
  itemsWeight: zod0.ZodNumber;
7925
8176
  billingAddress: zod0.ZodObject<{
7926
8177
  email: zod0.ZodString;
8178
+ taxId: zod0.ZodDefault<zod0.ZodString>;
7927
8179
  firstName: zod0.ZodString;
7928
8180
  lastName: zod0.ZodString;
7929
8181
  company: zod0.ZodString;
@@ -8226,6 +8478,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8226
8478
  itemsWeight: zod0.ZodNumber;
8227
8479
  billingAddress: zod0.ZodObject<{
8228
8480
  email: zod0.ZodString;
8481
+ taxId: zod0.ZodDefault<zod0.ZodString>;
8229
8482
  firstName: zod0.ZodString;
8230
8483
  lastName: zod0.ZodString;
8231
8484
  company: zod0.ZodString;
@@ -8470,6 +8723,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8470
8723
  additionalFields: {
8471
8724
  [x: string]: string | boolean;
8472
8725
  };
8726
+ taxId?: string | undefined;
8473
8727
  };
8474
8728
  paymentMethod: string;
8475
8729
  shippingAddress?: {
@@ -8507,6 +8761,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8507
8761
  customerNote: string;
8508
8762
  billingAddress: {
8509
8763
  email: string;
8764
+ taxId: string;
8510
8765
  firstName: string;
8511
8766
  lastName: string;
8512
8767
  company: string;
@@ -8624,6 +8879,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8624
8879
  itemsWeight: number;
8625
8880
  billingAddress: {
8626
8881
  email: string;
8882
+ taxId: string;
8627
8883
  firstName: string;
8628
8884
  lastName: string;
8629
8885
  company: string;
@@ -8999,6 +9255,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8999
9255
  itemsWeight: zod0.ZodNumber;
9000
9256
  billingAddress: zod0.ZodObject<{
9001
9257
  email: zod0.ZodString;
9258
+ taxId: zod0.ZodDefault<zod0.ZodString>;
9002
9259
  firstName: zod0.ZodString;
9003
9260
  lastName: zod0.ZodString;
9004
9261
  company: zod0.ZodString;
@@ -9301,6 +9558,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
9301
9558
  itemsWeight: zod0.ZodNumber;
9302
9559
  billingAddress: zod0.ZodObject<{
9303
9560
  email: zod0.ZodString;
9561
+ taxId: zod0.ZodDefault<zod0.ZodString>;
9304
9562
  firstName: zod0.ZodString;
9305
9563
  lastName: zod0.ZodString;
9306
9564
  company: zod0.ZodString;
@@ -9603,6 +9861,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
9603
9861
  itemsWeight: zod0.ZodNumber;
9604
9862
  billingAddress: zod0.ZodObject<{
9605
9863
  email: zod0.ZodString;
9864
+ taxId: zod0.ZodDefault<zod0.ZodString>;
9606
9865
  firstName: zod0.ZodString;
9607
9866
  lastName: zod0.ZodString;
9608
9867
  company: zod0.ZodString;
@@ -9905,6 +10164,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
9905
10164
  itemsWeight: zod0.ZodNumber;
9906
10165
  billingAddress: zod0.ZodObject<{
9907
10166
  email: zod0.ZodString;
10167
+ taxId: zod0.ZodDefault<zod0.ZodString>;
9908
10168
  firstName: zod0.ZodString;
9909
10169
  lastName: zod0.ZodString;
9910
10170
  company: zod0.ZodString;
@@ -10207,6 +10467,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
10207
10467
  itemsWeight: zod0.ZodNumber;
10208
10468
  billingAddress: zod0.ZodObject<{
10209
10469
  email: zod0.ZodString;
10470
+ taxId: zod0.ZodDefault<zod0.ZodString>;
10210
10471
  firstName: zod0.ZodString;
10211
10472
  lastName: zod0.ZodString;
10212
10473
  company: zod0.ZodString;
@@ -10509,6 +10770,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
10509
10770
  itemsWeight: zod0.ZodNumber;
10510
10771
  billingAddress: zod0.ZodObject<{
10511
10772
  email: zod0.ZodString;
10773
+ taxId: zod0.ZodDefault<zod0.ZodString>;
10512
10774
  firstName: zod0.ZodString;
10513
10775
  lastName: zod0.ZodString;
10514
10776
  company: zod0.ZodString;
@@ -10811,6 +11073,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
10811
11073
  itemsWeight: zod0.ZodNumber;
10812
11074
  billingAddress: zod0.ZodObject<{
10813
11075
  email: zod0.ZodString;
11076
+ taxId: zod0.ZodDefault<zod0.ZodString>;
10814
11077
  firstName: zod0.ZodString;
10815
11078
  lastName: zod0.ZodString;
10816
11079
  company: zod0.ZodString;
@@ -11055,6 +11318,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11055
11318
  additionalFields: {
11056
11319
  [x: string]: string | boolean;
11057
11320
  };
11321
+ taxId?: string | undefined;
11058
11322
  };
11059
11323
  key: string;
11060
11324
  paymentMethod: string;
@@ -11095,6 +11359,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11095
11359
  customerNote: string;
11096
11360
  billingAddress: {
11097
11361
  email: string;
11362
+ taxId: string;
11098
11363
  firstName: string;
11099
11364
  lastName: string;
11100
11365
  company: string;
@@ -11212,6 +11477,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11212
11477
  itemsWeight: number;
11213
11478
  billingAddress: {
11214
11479
  email: string;
11480
+ taxId: string;
11215
11481
  firstName: string;
11216
11482
  lastName: string;
11217
11483
  company: string;
@@ -11507,6 +11773,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11507
11773
  state: string;
11508
11774
  country: string;
11509
11775
  email: string;
11776
+ taxId: string;
11510
11777
  company?: string | undefined;
11511
11778
  address2?: string | undefined;
11512
11779
  };
@@ -11574,6 +11841,99 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11574
11841
  };
11575
11842
  }>;
11576
11843
  };
11844
+ storefront: {
11845
+ get: kizlo0.Procedure<"api", {}, {
11846
+ address: {
11847
+ countries: {
11848
+ code: string;
11849
+ name: string;
11850
+ allowBilling: boolean;
11851
+ allowShipping: boolean;
11852
+ states: {
11853
+ code: string;
11854
+ name: string;
11855
+ }[];
11856
+ locale: {
11857
+ [x: string]: {
11858
+ label?: string | undefined;
11859
+ required?: boolean | undefined;
11860
+ hidden?: boolean | undefined;
11861
+ index?: number | undefined;
11862
+ };
11863
+ };
11864
+ format: string;
11865
+ }[];
11866
+ defaultAddressFormat: string;
11867
+ fields: {
11868
+ [x: string]: {
11869
+ label: string;
11870
+ optionalLabel: string;
11871
+ required: boolean | {
11872
+ [x: string]: unknown;
11873
+ };
11874
+ hidden: boolean | {
11875
+ [x: string]: unknown;
11876
+ };
11877
+ type: string | null;
11878
+ autocomplete: string | null;
11879
+ index: number | null;
11880
+ placeholder: string | null;
11881
+ options: {
11882
+ value: string;
11883
+ label: string;
11884
+ }[];
11885
+ };
11886
+ };
11887
+ fieldLocations: {
11888
+ address: string[];
11889
+ contact: string[];
11890
+ order: string[];
11891
+ };
11892
+ baseCountry: string;
11893
+ defaultCountry: string | null;
11894
+ };
11895
+ checkout: {
11896
+ allowsGuest: boolean;
11897
+ couponsEnabled: boolean;
11898
+ forcedBillingAddress: boolean;
11899
+ taxesEnabled: boolean;
11900
+ displayCartPricesIncludingTax: boolean;
11901
+ displayItemizedTaxes: boolean;
11902
+ shippingEnabled: boolean;
11903
+ localPickup: {
11904
+ enabled: boolean;
11905
+ title: string;
11906
+ cost: string;
11907
+ };
11908
+ };
11909
+ pricing: {
11910
+ currency: {
11911
+ currencyCode: string;
11912
+ currencySymbol: string;
11913
+ currencyPrefix: string;
11914
+ currencySuffix: string;
11915
+ currencyMinorUnit: number;
11916
+ currencyDecimalSeparator: string;
11917
+ currencyThousandSeparator: string;
11918
+ };
11919
+ pricesIncludeTax: boolean;
11920
+ displayShopPricesIncludingTax: boolean;
11921
+ priceSuffix: string;
11922
+ };
11923
+ catalog: {
11924
+ weightUnit: string;
11925
+ dimensionUnit: string;
11926
+ reviewsEnabled: boolean;
11927
+ reviewRatingsEnabled: boolean;
11928
+ reviewRatingRequired: boolean;
11929
+ reviewsVerifiedOwnersOnly: boolean;
11930
+ stockFormat: string;
11931
+ hideOutOfStock: boolean;
11932
+ placeholderImage: string;
11933
+ cartRedirectAfterAdd: boolean;
11934
+ };
11935
+ }, kizlo0.DefinedErrorMapLike>;
11936
+ };
11577
11937
  }>;
11578
11938
  //#endregion
11579
- export { AddCartItemInput, ApplyCouponInput, Cart, CartAdditionalFields, CartBillingAddress, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, ConfirmCheckoutInput, 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, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductFiltersInputOut, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, SwatchType, UpdateCartInput, UpdateCartItemInput, UpdateCheckoutInput, woocommerce };
11939
+ export { AddCartItemInput, ApplyCouponInput, Cart, CartAdditionalFields, CartBillingAddress, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, ConfirmCheckoutInput, 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, RemoveCartItemInput, RemoveCouponInput, RetrieveProductFiltersInput, RetrieveProductFiltersInputOut, RetrieveProductInput, RetryCheckoutInput, SWATCH_TYPES, SelectCartShippingRateInput, Storefront, StorefrontAddress, StorefrontCatalog, StorefrontCheckout, StorefrontCountry, StorefrontField, StorefrontFieldOption, StorefrontFieldOverride, StorefrontFieldRule, StorefrontPricing, SwatchType, UpdateCartInput, UpdateCartItemInput, UpdateCheckoutInput, woocommerce };
package/dist/index.js CHANGED
@@ -314,6 +314,7 @@ const Product = ProductSummary.extend({
314
314
  formattedWeight: z.string(),
315
315
  formattedDimensions: z.string(),
316
316
  stockQuantity: z.number().nullable(),
317
+ hsCode: z.string().nullable(),
317
318
  saleStartsAt: z.number().nullable(),
318
319
  saleEndsAt: z.number().nullable(),
319
320
  seo: Seo.nullable(),
@@ -501,7 +502,8 @@ const CartAddressFields = {
501
502
  const CartShippingAddress = z$1.object(CartAddressFields);
502
503
  const CartBillingAddress = z$1.object({
503
504
  ...CartAddressFields,
504
- email: z$1.string()
505
+ email: z$1.string(),
506
+ taxId: z$1.string().default("")
505
507
  });
506
508
  const CartShippingDestination = z$1.object({
507
509
  address1: z$1.string(),
@@ -675,10 +677,7 @@ const SelectCartShippingRateInput = z$1.object({
675
677
  packageId: z$1.union([z$1.number(), z$1.string()]).nullable().optional()
676
678
  });
677
679
  const CartShippingAddressInput = z$1.object(CartAddressFields).partial();
678
- const CartBillingAddressInput = z$1.object({
679
- ...CartAddressFields,
680
- email: z$1.string()
681
- }).partial();
680
+ const CartBillingAddressInput = CartBillingAddress.partial();
682
681
  const UpdateCartInput = z$1.object({
683
682
  shippingAddress: CartShippingAddressInput.optional(),
684
683
  billingAddress: CartBillingAddressInput.optional()
@@ -701,6 +700,7 @@ function deserializeStoreProduct(data, recommendations) {
701
700
  formattedWeight: data.formatted_weight,
702
701
  formattedDimensions: data.formatted_dimensions,
703
702
  stockQuantity: nullableNumber(kizlo.stock),
703
+ hsCode: typeof kizlo.hs_code === "string" && kizlo.hs_code !== "" ? kizlo.hs_code : null,
704
704
  saleStartsAt: timestampFromIso(typeof kizlo.on_sale_from === "string" ? kizlo.on_sale_from : null),
705
705
  saleEndsAt: timestampFromIso(typeof kizlo.on_sale_to === "string" ? kizlo.on_sale_to : null),
706
706
  seo: isRecord$1(kizlo.seo) ? deserializeSeo(kizlo.seo) : null,
@@ -931,6 +931,7 @@ function nullableNumber(value) {
931
931
 
932
932
  //#endregion
933
933
  //#region src/cart/utils.ts
934
+ const TAX_ID_KEY = "kizlo/tax-id";
934
935
  function assertNoMissing$2() {}
935
936
  assertNoMissing$2();
936
937
  assertNoMissing$2();
@@ -1139,6 +1140,7 @@ function deserializeCartBillingAddress(address) {
1139
1140
  return {
1140
1141
  ...deserializeCartShippingAddress(address),
1141
1142
  email: address.email,
1143
+ taxId: taxId(address),
1142
1144
  additionalFields: additionalAddressFields(address, BILLING_ADDRESS_KEYS)
1143
1145
  };
1144
1146
  }
@@ -1152,12 +1154,16 @@ const SHIPPING_ADDRESS_KEYS = new Set([
1152
1154
  "state",
1153
1155
  "postcode",
1154
1156
  "country",
1155
- "phone"
1157
+ "phone",
1158
+ TAX_ID_KEY
1156
1159
  ]);
1157
1160
  const BILLING_ADDRESS_KEYS = new Set([...SHIPPING_ADDRESS_KEYS, "email"]);
1158
1161
  function additionalAddressFields(address, standardKeys) {
1159
1162
  return Object.fromEntries(Object.entries(address).filter((entry) => !standardKeys.has(entry[0]) && (typeof entry[1] === "string" || typeof entry[1] === "boolean")));
1160
1163
  }
1164
+ function taxId(address) {
1165
+ return typeof address[TAX_ID_KEY] === "string" ? address[TAX_ID_KEY] : "";
1166
+ }
1161
1167
  function serializeCartUpdateInput(input) {
1162
1168
  return {
1163
1169
  ...input.billingAddress !== void 0 && { billing_address: serializeCartBillingAddress(input.billingAddress) },
@@ -1166,7 +1172,7 @@ function serializeCartUpdateInput(input) {
1166
1172
  }
1167
1173
  function serializeCartShippingAddress(address) {
1168
1174
  return compactAddress({
1169
- ...address.additionalFields,
1175
+ ...Object.fromEntries(Object.entries(address.additionalFields ?? {}).filter(([key]) => key !== TAX_ID_KEY)),
1170
1176
  first_name: address.firstName,
1171
1177
  last_name: address.lastName,
1172
1178
  company: address.company,
@@ -1182,7 +1188,8 @@ function serializeCartShippingAddress(address) {
1182
1188
  function serializeCartBillingAddress(address) {
1183
1189
  return compactAddress({
1184
1190
  ...serializeCartShippingAddress(address),
1185
- email: address.email
1191
+ email: address.email,
1192
+ [TAX_ID_KEY]: address.taxId
1186
1193
  });
1187
1194
  }
1188
1195
  function compactAddress(address) {
@@ -1960,7 +1967,10 @@ const ShippingAddress = z$1.object({
1960
1967
  state: z$1.string(),
1961
1968
  country: z$1.string()
1962
1969
  });
1963
- const BillingAddress = ShippingAddress.extend({ email: z$1.string() });
1970
+ const BillingAddress = ShippingAddress.extend({
1971
+ email: z$1.string(),
1972
+ taxId: z$1.string().default("")
1973
+ });
1964
1974
 
1965
1975
  //#endregion
1966
1976
  //#region src/customer/schema.ts
@@ -1982,21 +1992,23 @@ const Customer = z$2.object({
1982
1992
  //#endregion
1983
1993
  //#region src/customer/utils.ts
1984
1994
  function deserializeCustomer(data) {
1995
+ const billing = data.billing;
1985
1996
  return {
1986
1997
  id: data.id,
1987
1998
  avatarUrl: data.avatar_url.length ? data.avatar_url : null,
1988
1999
  billing: {
1989
- firstName: data.billing.first_name,
1990
- lastName: data.billing.last_name,
1991
- address1: data.billing.address_1,
1992
- city: data.billing.city,
1993
- country: data.billing.country,
1994
- email: data.billing.email,
1995
- phone: data.billing.phone,
1996
- postcode: data.billing.postcode,
1997
- state: data.billing.state,
1998
- address2: data.billing.address_2,
1999
- company: data.billing.company
2000
+ firstName: billing.first_name,
2001
+ lastName: billing.last_name,
2002
+ address1: billing.address_1,
2003
+ city: billing.city,
2004
+ country: billing.country,
2005
+ email: billing.email,
2006
+ phone: billing.phone,
2007
+ postcode: billing.postcode,
2008
+ state: billing.state,
2009
+ address2: billing.address_2,
2010
+ company: billing.company,
2011
+ taxId: typeof billing.tax_id === "string" ? billing.tax_id : ""
2000
2012
  },
2001
2013
  shipping: {
2002
2014
  firstName: data.shipping.first_name,
@@ -2078,6 +2090,7 @@ const OrderItem = z.object({
2078
2090
  id: z.number(),
2079
2091
  productId: z.number().nullable(),
2080
2092
  variationId: z.number().nullable(),
2093
+ hsCode: z.string().nullable(),
2081
2094
  name: z.string(),
2082
2095
  quantity: z.number(),
2083
2096
  selectedAttributes: z.array(CartSelectedAttribute),
@@ -2209,6 +2222,7 @@ function deserializeOrderItem(item) {
2209
2222
  id: item.id,
2210
2223
  productId,
2211
2224
  variationId,
2225
+ hsCode: typeof kizlo.hs_code === "string" && kizlo.hs_code !== "" ? kizlo.hs_code : null,
2212
2226
  name: item.name,
2213
2227
  quantity: item.quantity,
2214
2228
  selectedAttributes: item.variation.map((attribute) => ({
@@ -2413,6 +2427,194 @@ const PRODUCT_PROCEDURES = {
2413
2427
  })
2414
2428
  };
2415
2429
 
2430
+ //#endregion
2431
+ //#region src/storefront/schema.ts
2432
+ /**
2433
+ * A plugin-registered field may make `required` or `hidden` a JSON Schema rule evaluated against the
2434
+ * checkout rather than a fixed boolean.
2435
+ */
2436
+ const StorefrontFieldRule = z$2.union([z$2.boolean(), z$2.record(z$2.string(), z$2.unknown())]);
2437
+ const StorefrontFieldOption = z$2.object({
2438
+ value: z$2.string(),
2439
+ label: z$2.string()
2440
+ });
2441
+ const StorefrontField = z$2.object({
2442
+ label: z$2.string(),
2443
+ optionalLabel: z$2.string(),
2444
+ required: StorefrontFieldRule,
2445
+ hidden: StorefrontFieldRule,
2446
+ type: z$2.string().nullable(),
2447
+ autocomplete: z$2.string().nullable(),
2448
+ index: z$2.number().nullable(),
2449
+ placeholder: z$2.string().nullable(),
2450
+ options: z$2.array(StorefrontFieldOption)
2451
+ });
2452
+ /** What a country changes about a field. Anything it leaves out keeps the field's default. */
2453
+ const StorefrontFieldOverride = z$2.object({
2454
+ label: z$2.string().optional(),
2455
+ required: z$2.boolean().optional(),
2456
+ hidden: z$2.boolean().optional(),
2457
+ index: z$2.number().optional()
2458
+ });
2459
+ const StorefrontCountry = z$2.object({
2460
+ code: z$2.string(),
2461
+ name: z$2.string(),
2462
+ allowBilling: z$2.boolean(),
2463
+ allowShipping: z$2.boolean(),
2464
+ states: z$2.array(z$2.object({
2465
+ code: z$2.string(),
2466
+ name: z$2.string()
2467
+ })),
2468
+ locale: z$2.record(z$2.string(), StorefrontFieldOverride),
2469
+ format: z$2.string()
2470
+ });
2471
+ const StorefrontAddress = z$2.object({
2472
+ countries: z$2.array(StorefrontCountry),
2473
+ defaultAddressFormat: z$2.string(),
2474
+ fields: z$2.record(z$2.string(), StorefrontField),
2475
+ fieldLocations: z$2.object({
2476
+ address: z$2.array(z$2.string()),
2477
+ contact: z$2.array(z$2.string()),
2478
+ order: z$2.array(z$2.string())
2479
+ }),
2480
+ baseCountry: z$2.string(),
2481
+ defaultCountry: z$2.string().nullable()
2482
+ });
2483
+ const StorefrontCheckout = z$2.object({
2484
+ allowsGuest: z$2.boolean(),
2485
+ couponsEnabled: z$2.boolean(),
2486
+ forcedBillingAddress: z$2.boolean(),
2487
+ taxesEnabled: z$2.boolean(),
2488
+ displayCartPricesIncludingTax: z$2.boolean(),
2489
+ displayItemizedTaxes: z$2.boolean(),
2490
+ shippingEnabled: z$2.boolean(),
2491
+ localPickup: z$2.object({
2492
+ enabled: z$2.boolean(),
2493
+ title: z$2.string(),
2494
+ cost: z$2.string()
2495
+ })
2496
+ });
2497
+ const StorefrontPricing = z$2.object({
2498
+ currency: CurrencyFormat,
2499
+ pricesIncludeTax: z$2.boolean(),
2500
+ displayShopPricesIncludingTax: z$2.boolean(),
2501
+ priceSuffix: z$2.string()
2502
+ });
2503
+ const StorefrontCatalog = z$2.object({
2504
+ weightUnit: z$2.string(),
2505
+ dimensionUnit: z$2.string(),
2506
+ reviewsEnabled: z$2.boolean(),
2507
+ reviewRatingsEnabled: z$2.boolean(),
2508
+ reviewRatingRequired: z$2.boolean(),
2509
+ reviewsVerifiedOwnersOnly: z$2.boolean(),
2510
+ stockFormat: z$2.string(),
2511
+ hideOutOfStock: z$2.boolean(),
2512
+ placeholderImage: z$2.string(),
2513
+ cartRedirectAfterAdd: z$2.boolean()
2514
+ });
2515
+ const Storefront = z$2.object({
2516
+ address: StorefrontAddress,
2517
+ checkout: StorefrontCheckout,
2518
+ pricing: StorefrontPricing,
2519
+ catalog: StorefrontCatalog
2520
+ });
2521
+
2522
+ //#endregion
2523
+ //#region src/storefront/utils.ts
2524
+ function deserializeStorefront(data) {
2525
+ const { address, checkout, pricing, catalog } = data;
2526
+ return {
2527
+ address: {
2528
+ countries: address.countries.map(deserializeCountry),
2529
+ defaultAddressFormat: address.default_address_format,
2530
+ fields: Object.fromEntries(Object.entries(address.fields).map(([key, field]) => [key, deserializeField(field)])),
2531
+ fieldLocations: address.field_locations,
2532
+ baseCountry: address.base_country,
2533
+ defaultCountry: address.default_country ?? null
2534
+ },
2535
+ checkout: {
2536
+ allowsGuest: checkout.allows_guest,
2537
+ couponsEnabled: checkout.coupons_enabled,
2538
+ forcedBillingAddress: checkout.forced_billing_address,
2539
+ taxesEnabled: checkout.taxes_enabled,
2540
+ displayCartPricesIncludingTax: checkout.display_cart_prices_including_tax,
2541
+ displayItemizedTaxes: checkout.display_itemized_taxes,
2542
+ shippingEnabled: checkout.shipping_enabled,
2543
+ localPickup: checkout.local_pickup
2544
+ },
2545
+ pricing: {
2546
+ currency: deserializeCurrencyFormat(pricing.currency),
2547
+ pricesIncludeTax: pricing.prices_include_tax,
2548
+ displayShopPricesIncludingTax: pricing.display_shop_prices_including_tax,
2549
+ priceSuffix: pricing.price_suffix
2550
+ },
2551
+ catalog: {
2552
+ weightUnit: catalog.weight_unit,
2553
+ dimensionUnit: catalog.dimension_unit,
2554
+ reviewsEnabled: catalog.reviews_enabled,
2555
+ reviewRatingsEnabled: catalog.review_ratings_enabled,
2556
+ reviewRatingRequired: catalog.review_rating_required,
2557
+ reviewsVerifiedOwnersOnly: catalog.reviews_verified_owners_only,
2558
+ stockFormat: catalog.stock_format,
2559
+ hideOutOfStock: catalog.hide_out_of_stock,
2560
+ placeholderImage: catalog.placeholder_image,
2561
+ cartRedirectAfterAdd: catalog.cart_redirect_after_add
2562
+ }
2563
+ };
2564
+ }
2565
+ function deserializeCountry(country) {
2566
+ return {
2567
+ code: country.code,
2568
+ name: country.name,
2569
+ allowBilling: country.allowBilling,
2570
+ allowShipping: country.allowShipping,
2571
+ states: country.states,
2572
+ locale: Object.fromEntries(Object.entries(country.locale).map(([key, override]) => [key, deserializeOverride(override)])),
2573
+ format: country.format
2574
+ };
2575
+ }
2576
+ function deserializeOverride(override) {
2577
+ return {
2578
+ ...typeof override.label === "string" && { label: override.label },
2579
+ ...typeof override.required === "boolean" && { required: override.required },
2580
+ ...typeof override.hidden === "boolean" && { hidden: override.hidden },
2581
+ ...typeof override.index === "number" && { index: override.index }
2582
+ };
2583
+ }
2584
+ function deserializeField(field) {
2585
+ return {
2586
+ label: field.label,
2587
+ optionalLabel: field.optionalLabel,
2588
+ required: deserializeRule(field.required),
2589
+ hidden: deserializeRule(field.hidden),
2590
+ type: field.type ?? null,
2591
+ autocomplete: field.autocomplete ?? null,
2592
+ index: field.index ?? null,
2593
+ placeholder: field.placeholder ?? null,
2594
+ options: field.options ?? []
2595
+ };
2596
+ }
2597
+ function deserializeRule(rule) {
2598
+ if (typeof rule === "boolean") return rule;
2599
+ return typeof rule === "object" && rule !== null && !Array.isArray(rule) ? rule : false;
2600
+ }
2601
+
2602
+ //#endregion
2603
+ //#region src/storefront/index.ts
2604
+ const STOREFRONT_PROCEDURES = { get: createProcedure({
2605
+ scope: "api",
2606
+ method: "GET",
2607
+ path: "/storefront",
2608
+ output: Storefront
2609
+ }, async ({ context, errors }) => {
2610
+ const response = await context.wordpress.woocommerce.kizlo.storefront.retrieve();
2611
+ if (response.error) {
2612
+ context.logger.error("Get storefront unhandled error", response.error, { code: response.error.code });
2613
+ throw errors.INTERNAL_SERVER_ERROR();
2614
+ }
2615
+ return deserializeStorefront(response.data);
2616
+ }) };
2617
+
2416
2618
  //#endregion
2417
2619
  //#region src/index.ts
2418
2620
  function woocommerce() {
@@ -2421,10 +2623,11 @@ function woocommerce() {
2421
2623
  requires: {
2422
2624
  plugins: [{
2423
2625
  name: "kizlo-woocommerce",
2424
- version: "0.10.0"
2626
+ version: "0.11.0"
2425
2627
  }],
2426
2628
  endpoints: [
2427
2629
  "woocommerce.customers",
2630
+ "woocommerce.kizlo.storefront",
2428
2631
  "woocommerce.products",
2429
2632
  "woocommerce.store.cart",
2430
2633
  "woocommerce.store.checkout",
@@ -2437,10 +2640,11 @@ function woocommerce() {
2437
2640
  products: PRODUCT_PROCEDURES,
2438
2641
  checkout: CHECKOUT_PROCEDURES,
2439
2642
  customers: CUSTOMER_PROCEDURES,
2440
- orders: ORDER_PROCEDURES
2643
+ orders: ORDER_PROCEDURES,
2644
+ storefront: STOREFRONT_PROCEDURES
2441
2645
  }
2442
2646
  });
2443
2647
  }
2444
2648
 
2445
2649
  //#endregion
2446
- export { AddCartItemInput, ApplyCouponInput, Cart, CartAdditionalFields, CartBillingAddress, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, 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, SwatchType, UpdateCartInput, UpdateCartItemInput, UpdateCheckoutInput, woocommerce };
2650
+ export { AddCartItemInput, ApplyCouponInput, Cart, CartAdditionalFields, CartBillingAddress, CartCoupon, CartCouponTotals, CartError, CartFee, CartFeeTotals, CartItem, CartItemData, CartItemQuantityLimits, CartItemTotals, CartPaymentMethod, CartSelectedAttribute, CartShippingAddress, CartShippingDestination, CartShippingItem, CartShippingPackage, CartShippingRate, CartShippingRateMetadata, CartTaxLine, CartTotals, Checkout, CheckoutAdditionalFields, CheckoutExtensions, CheckoutPaymentData, CheckoutPaymentResult, 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, StorefrontPricing, SwatchType, UpdateCartInput, UpdateCartItemInput, UpdateCheckoutInput, woocommerce };
package/dist/test.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as kizlo19 from "kizlo";
1
+ import * as kizlo21 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
- }): kizlo19.Fixture;
23
+ }): kizlo21.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.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "WooCommerce integration for Kizlo.",