@kizlo/woocommerce 0.10.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 +21 -0
- package/dist/index.d.ts +317 -1
- package/dist/index.js +193 -3
- package/dist/test.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,27 @@ await kizlo.woocommerce.cart.update.call({
|
|
|
54
54
|
|
|
55
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
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
|
+
|
|
57
78
|
## License
|
|
58
79
|
|
|
59
80
|
[Apache 2.0](./LICENSE) © Kizlo
|
package/dist/index.d.ts
CHANGED
|
@@ -3392,6 +3392,229 @@ declare const RetrieveProductFiltersInput: z.ZodObject<{
|
|
|
3392
3392
|
type RetrieveProductFiltersInput = z.input<typeof RetrieveProductFiltersInput>;
|
|
3393
3393
|
type RetrieveProductFiltersInputOut = z.output<typeof RetrieveProductFiltersInput>;
|
|
3394
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
|
|
3395
3618
|
//#region src/index.d.ts
|
|
3396
3619
|
declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
3397
3620
|
cart: {
|
|
@@ -11618,6 +11841,99 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
11618
11841
|
};
|
|
11619
11842
|
}>;
|
|
11620
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
|
+
};
|
|
11621
11937
|
}>;
|
|
11622
11938
|
//#endregion
|
|
11623
|
-
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
|
@@ -2427,6 +2427,194 @@ const PRODUCT_PROCEDURES = {
|
|
|
2427
2427
|
})
|
|
2428
2428
|
};
|
|
2429
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
|
+
|
|
2430
2618
|
//#endregion
|
|
2431
2619
|
//#region src/index.ts
|
|
2432
2620
|
function woocommerce() {
|
|
@@ -2435,10 +2623,11 @@ function woocommerce() {
|
|
|
2435
2623
|
requires: {
|
|
2436
2624
|
plugins: [{
|
|
2437
2625
|
name: "kizlo-woocommerce",
|
|
2438
|
-
version: "0.
|
|
2626
|
+
version: "0.11.0"
|
|
2439
2627
|
}],
|
|
2440
2628
|
endpoints: [
|
|
2441
2629
|
"woocommerce.customers",
|
|
2630
|
+
"woocommerce.kizlo.storefront",
|
|
2442
2631
|
"woocommerce.products",
|
|
2443
2632
|
"woocommerce.store.cart",
|
|
2444
2633
|
"woocommerce.store.checkout",
|
|
@@ -2451,10 +2640,11 @@ function woocommerce() {
|
|
|
2451
2640
|
products: PRODUCT_PROCEDURES,
|
|
2452
2641
|
checkout: CHECKOUT_PROCEDURES,
|
|
2453
2642
|
customers: CUSTOMER_PROCEDURES,
|
|
2454
|
-
orders: ORDER_PROCEDURES
|
|
2643
|
+
orders: ORDER_PROCEDURES,
|
|
2644
|
+
storefront: STOREFRONT_PROCEDURES
|
|
2455
2645
|
}
|
|
2456
2646
|
});
|
|
2457
2647
|
}
|
|
2458
2648
|
|
|
2459
2649
|
//#endregion
|
|
2460
|
-
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
|
|
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
|
-
}):
|
|
23
|
+
}): kizlo21.Fixture;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { BANK_TRANSFER_DESCRIPTION, BANK_TRANSFER_TITLE, woocommerce };
|