@myparcel-dev/pdk-checkout-common 2.1.3 → 2.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  <!-- MONOWEAVE:BELOW -->
4
4
 
5
+ ## [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)
6
+
7
+
8
+ ### Features
9
+
10
+ * **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)
11
+
12
+
13
+
14
+
5
15
  ## [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
16
 
7
17
 
@@ -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?: Partial<Plugin.ModelContextCheckoutContext>) => Plugin.ModelContextCheckoutContext>;
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?: Partial<PdkCheckoutConfigInput>) => PdkCheckoutConfigInput>;
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?: Partial<PdkCheckoutConfigInput>, includeElements?: boolean) => Promise<void>;
3
+ export declare const mockPdkCheckout: (config?: RecursivePartial<PdkCheckoutConfigInput>, includeElements?: boolean) => Promise<void>;
@@ -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",
3
+ "version": "2.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/myparcelnl/js-pdk.git",
@@ -29,7 +29,7 @@
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.2",
32
+ "@myparcel-dev/pdk-common": "^2.2.0",
33
33
  "radash": "^12.1.0"
34
34
  },
35
35
  "devDependencies": {
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports[`exports > exports from index.ts 1`] = `
4
4
  [
5
+ "ADDRESS_FIELD_IS_BUSINESS",
5
6
  "ATTRIBUTE_CONTEXT",
6
7
  "AddressField",
7
8
  "AddressType",
@@ -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?: Partial<Plugin.ModelContextCheckoutContext>): Plugin.ModelContextCheckoutContext => {
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?: Partial<PdkCheckoutConfigInput>): PdkCheckoutConfigInput => ({
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 = (config?: Partial<PdkCheckoutConfigInput>, includeElements = true): Promise<void> => {
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) => {
@@ -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';