@myparcel-dev/pdk-checkout-common 2.1.3 → 2.2.1
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/CHANGELOG.md +20 -0
- package/dist/__tests__/getMockCheckoutContext.d.ts +2 -1
- package/dist/__tests__/getMockPdkCheckoutConfig.d.ts +2 -1
- package/dist/__tests__/mockPdkCheckout.d.ts +2 -1
- package/dist/__tests__/spies.d.ts +2 -2
- package/dist/data/address.d.ts +8 -0
- package/package.json +3 -3
- package/src/__tests__/__snapshots__/exports.spec.ts.snap +1 -0
- package/src/__tests__/getMockCheckoutContext.ts +2 -1
- package/src/__tests__/getMockPdkCheckoutConfig.ts +4 -2
- package/src/__tests__/mockPdkCheckout.ts +5 -1
- package/src/data/address.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- MONOWEAVE:BELOW -->
|
|
4
4
|
|
|
5
|
+
## [2.2.1](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-checkout-common@2.2.0...@myparcel-dev/pdk-checkout-common@2.2.1) "@myparcel-dev/pdk-checkout-common" (2026-09-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Reverts
|
|
9
|
+
|
|
10
|
+
* build(deps): update vitest to 4 and vite to 8 ([7696c6f](https://github.com/myparcelnl/js-pdk/commit/7696c6f8d344619c2e554f0fae5ed5db2d5c71f8)), closes [#463](https://github.com/myparcelnl/js-pdk/issues/463)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [2.2.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-checkout-common@2.1.3...@myparcel-dev/pdk-checkout-common@2.2.0) "@myparcel-dev/pdk-checkout-common" (2026-09-24)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **checkout:** refresh the context when the recipient business flag changes ([#461](https://github.com/myparcelnl/js-pdk/issues/461)) ([0689762](https://github.com/myparcelnl/js-pdk/commit/0689762ae5b14c592e664b286612796aed0c7a9d)), closes [myparcelnl/woocommerce#1848](https://github.com/myparcelnl/woocommerce/issues/1848) [#359](https://github.com/myparcelnl/js-pdk/issues/359)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
5
25
|
## [2.1.2](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-checkout-common@2.1.1...@myparcel-dev/pdk-checkout-common@2.1.2) "@myparcel-dev/pdk-checkout-common" (2026-08-13)
|
|
6
26
|
|
|
7
27
|
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { type RecursivePartial } from '@myparcel-dev/ts-utils';
|
|
1
2
|
import { type Plugin } from '@myparcel-dev/pdk-common';
|
|
2
|
-
export declare const getMockCheckoutContext: import("vitest").Mock<(context?:
|
|
3
|
+
export declare const getMockCheckoutContext: import("vitest").Mock<(context?: RecursivePartial<Plugin.ModelContextCheckoutContext>) => Plugin.ModelContextCheckoutContext>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { type RecursivePartial } from '@myparcel-dev/ts-utils';
|
|
1
2
|
import { type PdkCheckoutConfigInput } from '../types';
|
|
2
|
-
export declare const getMockPdkCheckoutConfig: import("vitest").Mock<(config?:
|
|
3
|
+
export declare const getMockPdkCheckoutConfig: import("vitest").Mock<(config?: RecursivePartial<PdkCheckoutConfigInput>) => PdkCheckoutConfigInput>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { type RecursivePartial } from '@myparcel-dev/ts-utils';
|
|
1
2
|
import { type PdkCheckoutConfigInput } from '../types';
|
|
2
|
-
export declare const mockPdkCheckout: (config?:
|
|
3
|
+
export declare const mockPdkCheckout: (config?: RecursivePartial<PdkCheckoutConfigInput>, includeElements?: boolean) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type PdkFormData } from '../types';
|
|
2
|
-
export declare const doRequestSpy: import("vitest").Mock<(
|
|
2
|
+
export declare const doRequestSpy: import("vitest").Mock<import("@vitest/spy").Procedure>;
|
|
3
3
|
export declare const getFormSpy: import("vitest").Mock<() => HTMLFormElement>;
|
|
4
4
|
export declare const getFormDataSpy: import("vitest").Mock<() => PdkFormData>;
|
|
5
5
|
export declare const hasAddressTypeSpy: import("vitest").Mock<() => boolean>;
|
|
6
6
|
export declare const initializeSpy: import("vitest").Mock<() => Promise<void>>;
|
|
7
|
-
export declare const toggleFieldSpy: import("vitest").Mock<(
|
|
7
|
+
export declare const toggleFieldSpy: import("vitest").Mock<import("@vitest/spy").Procedure>;
|
package/dist/data/address.d.ts
CHANGED
|
@@ -13,3 +13,11 @@ export declare enum PdkField {
|
|
|
13
13
|
AddressType = "addressType",
|
|
14
14
|
ShippingMethod = "shippingMethod"
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Key a platform can add to the form data of an address to report a business recipient. It reports
|
|
18
|
+
* the flag and never the company name, the same way the PHP PDK keeps the company in
|
|
19
|
+
* `ContactDetails` and puts only the flag in the checkout context.
|
|
20
|
+
*
|
|
21
|
+
* It is not an `AddressField`, because those describe fields every platform has to provide.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ADDRESS_FIELD_IS_BUSINESS = "isBusiness";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myparcel-dev/pdk-checkout-common",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/myparcelnl/js-pdk.git",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@myparcel-dev/constants": "^2.7.0",
|
|
31
31
|
"@myparcel-dev/delivery-options": "^7.5.0",
|
|
32
|
-
"@myparcel-dev/pdk-common": "^2.1
|
|
32
|
+
"@myparcel-dev/pdk-common": "^2.2.1",
|
|
33
33
|
"radash": "^12.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"typescript": "^5.2.2",
|
|
37
|
-
"vitest": "^
|
|
37
|
+
"vitest": "^4.1.11"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=20"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {vi} from 'vitest';
|
|
2
|
+
import {type RecursivePartial} from '@myparcel-dev/ts-utils';
|
|
2
3
|
import {FrontendEndpoint, type Plugin} from '@myparcel-dev/pdk-common';
|
|
3
4
|
import {KEY_CONFIG} from '@myparcel-dev/delivery-options';
|
|
4
5
|
import {PackageTypeName} from '@myparcel-dev/constants';
|
|
5
6
|
import {getMockDeliveryOptionsConfig} from './getMockDeliveryOptionsConfig';
|
|
6
7
|
|
|
7
8
|
export const getMockCheckoutContext = vi.fn(
|
|
8
|
-
(context?:
|
|
9
|
+
(context?: RecursivePartial<Plugin.ModelContextCheckoutContext>): Plugin.ModelContextCheckoutContext => {
|
|
9
10
|
return {
|
|
10
11
|
settings: {
|
|
11
12
|
hasDeliveryOptions: true,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {vi} from 'vitest';
|
|
2
|
+
import {type RecursivePartial} from '@myparcel-dev/ts-utils';
|
|
2
3
|
import {type PdkCheckoutConfigInput} from '../types';
|
|
3
4
|
import {AddressField, AddressType, PdkField} from '../data';
|
|
4
5
|
import {doRequestSpy, getFormDataSpy, getFormSpy, hasAddressTypeSpy, initializeSpy, toggleFieldSpy} from './spies';
|
|
5
6
|
import {getMockFormData} from './getMockFormData';
|
|
6
7
|
|
|
7
8
|
export const getMockPdkCheckoutConfig = vi.fn(
|
|
8
|
-
(config?:
|
|
9
|
+
(config?: RecursivePartial<PdkCheckoutConfigInput>): PdkCheckoutConfigInput => ({
|
|
9
10
|
doRequest: doRequestSpy,
|
|
10
11
|
getForm: getFormSpy,
|
|
11
12
|
getFormData: getFormDataSpy,
|
|
@@ -39,7 +40,8 @@ export const getMockPdkCheckoutConfig = vi.fn(
|
|
|
39
40
|
...config?.fields?.[AddressType.Shipping],
|
|
40
41
|
},
|
|
41
42
|
...config?.fields,
|
|
42
|
-
|
|
43
|
+
// A recursive partial makes every value optional; the defaults above fill the gaps.
|
|
44
|
+
} as PdkCheckoutConfigInput['fields'],
|
|
43
45
|
|
|
44
46
|
formData: getMockFormData(config?.formData),
|
|
45
47
|
}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {type RecursivePartial} from '@myparcel-dev/ts-utils';
|
|
1
2
|
import {usePdkCheckout} from '../utils';
|
|
2
3
|
import {type PdkCheckoutConfigInput} from '../types';
|
|
3
4
|
import {createPdkCheckout} from '../createPdkCheckout';
|
|
@@ -13,7 +14,10 @@ function reset() {
|
|
|
13
14
|
document.getElementById('test-wrapper')?.remove();
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export const mockPdkCheckout = (
|
|
17
|
+
export const mockPdkCheckout = (
|
|
18
|
+
config?: RecursivePartial<PdkCheckoutConfigInput>,
|
|
19
|
+
includeElements = true,
|
|
20
|
+
): Promise<void> => {
|
|
17
21
|
reset();
|
|
18
22
|
|
|
19
23
|
return new Promise((resolve, reject) => {
|
package/src/data/address.ts
CHANGED
|
@@ -15,3 +15,12 @@ export enum PdkField {
|
|
|
15
15
|
AddressType = 'addressType',
|
|
16
16
|
ShippingMethod = 'shippingMethod',
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Key a platform can add to the form data of an address to report a business recipient. It reports
|
|
21
|
+
* the flag and never the company name, the same way the PHP PDK keeps the company in
|
|
22
|
+
* `ContactDetails` and puts only the flag in the checkout context.
|
|
23
|
+
*
|
|
24
|
+
* It is not an `AddressField`, because those describe fields every platform has to provide.
|
|
25
|
+
*/
|
|
26
|
+
export const ADDRESS_FIELD_IS_BUSINESS = 'isBusiness';
|