@myparcel-dev/pdk-admin 2.4.0 → 2.4.2-beta-oidc.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.4.1](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-admin@2.4.0...@myparcel-dev/pdk-admin@2.4.1) "@myparcel-dev/pdk-admin" (2026-11-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **admin:** offer the €100 insurance tier in the shipment options form ([#520](https://github.com/myparcelnl/js-pdk/issues/520)) ([498b0db](https://github.com/myparcelnl/js-pdk/commit/498b0db6087bb0836c89c328be5cc1550ade35ff)), closes [myparcelnl/prestashop#269](https://github.com/myparcelnl/prestashop/issues/269) [myparcelnl/prestashop#238](https://github.com/myparcelnl/prestashop/issues/238)
11
+
12
+
13
+
14
+
5
15
  ## [2.4.0](https://github.com/myparcelnl/js-pdk/compare/@myparcel-dev/pdk-admin@2.3.0...@myparcel-dev/pdk-admin@2.4.0) "@myparcel-dev/pdk-admin" (2026-10-22)
6
16
 
7
17
 
@@ -6,7 +6,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
6
6
  required: true;
7
7
  };
8
8
  }, {
9
- returnsForm: import("@myparcel-vfb/core").FormInstance<import("@myparcel-vfb/core").FormValues>;
9
+ returnsForm: import("@myparcel-dev/vue-form-builder").FormInstance;
10
10
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
11
11
  orderId: {
12
12
  type: StringConstructor;
@@ -1 +1,2 @@
1
- export declare const createReturnsForm: (id: string) => import("@myparcel-vfb/core").FormInstance<import("@myparcel-vfb/core").FormValues>;
1
+ import { type FormInstance } from '@myparcel-dev/vue-form-builder';
2
+ export declare const createReturnsForm: (id: string) => FormInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myparcel-dev/pdk-admin",
3
- "version": "2.4.0",
3
+ "version": "2.4.2-beta-oidc.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/myparcelnl/js-pdk.git",
@@ -22,24 +22,16 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "files": [
24
24
  "./src",
25
- "./dist"
25
+ "./dist",
26
+ "CHANGELOG.md"
26
27
  ],
27
- "scripts": {
28
- "build": "run ws:vue:build \"$(pwd)\"",
29
- "clean": "run ws:clean \"$(pwd)\"",
30
- "lint": "run ws:lint \"$(pwd)\"",
31
- "lint:fix": "run ws:lint:fix \"$(pwd)\"",
32
- "test": "run ws:test \"$(pwd)\"",
33
- "test:coverage": "run ws:test:coverage \"$(pwd)\"",
34
- "test:run": "run ws:test:run \"$(pwd)\"",
35
- "test:update": "run ws:test:update \"$(pwd)\"",
36
- "typecheck": "run ws:vue:typecheck \"$(pwd)\""
37
- },
38
28
  "dependencies": {
39
29
  "@myparcel-dev/constants": "^2.9.0",
40
- "@myparcel-dev/pdk-common": "^2.3.1",
30
+ "@myparcel-dev/pdk-common": "^2.3.2-beta-oidc.0",
41
31
  "@myparcel-dev/sdk": "^5.1.0",
32
+ "@myparcel-dev/ts-utils": "^1.15.0",
42
33
  "@myparcel-dev/vue-form-builder": "1.0.0-beta.42.6",
34
+ "@tanstack/query-core": "^4.43.0",
43
35
  "@tanstack/vue-query": "~4.43.0",
44
36
  "@vueuse/core": "^10.0.0",
45
37
  "lodash": "^4.17.21",
@@ -49,22 +41,35 @@
49
41
  "vue": "3.4.31"
50
42
  },
51
43
  "devDependencies": {
44
+ "@myparcel-dev/do-shared": "^7.5.3",
52
45
  "@myparcel-dev/pdk-build-vite": "1.0.0-alpha.0",
46
+ "@pinia/testing": ">= 0.1.0 < 1",
53
47
  "@types/lodash-es": "^4.17.6",
48
+ "@vitejs/plugin-vue": "^6.0.9",
54
49
  "@vue/test-utils": "^2.5.1",
55
50
  "typescript": "^5.2.2",
56
51
  "vite": "^8.3.1",
57
- "vitest": "^4.1.11",
58
52
  "vue-tsc": "^3.3.9"
59
53
  },
60
54
  "engines": {
61
55
  "node": ">=20"
62
56
  },
63
- "volta": {
64
- "extends": "../../package.json"
65
- },
66
57
  "publishConfig": {
67
58
  "access": "public"
68
59
  },
69
- "deployGroup": "admin"
60
+ "nx": {
61
+ "targets": {
62
+ "clean": {},
63
+ "lint": {},
64
+ "lint:fix": {},
65
+ "test": {},
66
+ "test:coverage": {},
67
+ "test:run": {},
68
+ "test:update": {}
69
+ }
70
+ },
71
+ "scripts": {
72
+ "build": "vue-tsc --project tsconfig.base.json --noEmit false --declaration --emitDeclarationOnly --declarationDir dist",
73
+ "typecheck": "vue-tsc --project tsconfig.base.json --noEmit"
74
+ }
70
75
  }
@@ -1,7 +1,6 @@
1
- import {defineForm} from '@myparcel-dev/vue-form-builder';
1
+ import {defineForm, type FormInstance} from '@myparcel-dev/vue-form-builder';
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
- export const createReturnsForm = (id: string) => {
3
+ export const createReturnsForm = (id: string): FormInstance => {
5
4
  return defineForm(`returns${id}`, {
6
5
  fields: [],
7
6
  });
@@ -195,14 +195,21 @@ describe('useFormCapabilities', () => {
195
195
  expect(useFormCapabilities().getInsuranceOptions(formStub('POSTNL'), formatter)).toEqual([]);
196
196
  });
197
197
 
198
- it('switches step from 250 to 500 across the 500€ threshold', async () => {
198
+ // Same cases as InsuranceTierMathTest in the PHP PDK, so both sides offer the same tiers.
199
+ it.each([
200
+ [100, 100, ['100']],
201
+ [500, 100, ['500']],
202
+ [0, 200_000, ['0', '10000', '25000', '50000', '100000', '150000', '200000']],
203
+ [30_000, 100_000, ['30000', '50000', '100000']],
204
+ [50_000, 150_000, ['50000', '100000', '150000']],
205
+ [0, 37_500, ['0', '10000', '25000', '37500']],
206
+ ])('builds the tier ladder for min %i and max %i', async (min, max, expected) => {
199
207
  const shipment = buildCarrier({
200
208
  carrier: 'POSTNL',
201
209
  options: {
202
210
  insurance: {
203
- min: {amount: 0, currency: 'EUR'},
204
- // max is 1000€ in cents
205
- max: {amount: 100_000, currency: 'EUR'},
211
+ min: {amount: min, currency: 'EUR'},
212
+ max: {amount: max, currency: 'EUR'},
206
213
  default: {amount: 0, currency: 'EUR'},
207
214
  } as never,
208
215
  },
@@ -210,14 +217,13 @@ describe('useFormCapabilities', () => {
210
217
  queryStore.setQuery(shipmentModifier('order-1'), 'success', [shipment]);
211
218
 
212
219
  const {useFormCapabilities} = await import('./useFormCapabilities');
213
- const opts = useFormCapabilities().getInsuranceOptions(formStub('POSTNL'), formatter);
214
- const values = opts.map((o) => o.value);
220
+ const values = useFormCapabilities()
221
+ .getInsuranceOptions(formStub('POSTNL'), formatter)
222
+ .map((o) => o.value);
215
223
 
216
224
  // First entry is the inherit default; subsequent values are cent amounts as strings.
217
225
  expect(values[0]).toBe(TriState.Inherit);
218
- // 0, 250, 500 (low steps) — then 1000 (high step from 500). Exact sequence verifies
219
- // the boundary semantics — replacing `<` with `<=` on LOW_THRESHOLD would shift these.
220
- expect(values.slice(1)).toEqual(['0', '25000', '50000', '100000']);
226
+ expect(values.slice(1)).toEqual(expected);
221
227
  });
222
228
 
223
229
  it('returns [] when the carrier advertises insurance without limits', async () => {
@@ -7,6 +7,30 @@ import {type AdminContext, type SelectOption} from '../../types';
7
7
  import {useQueryStore, type ResolvedQuery} from '../../stores';
8
8
  import {Format, type Formatter} from '../../composables';
9
9
 
10
+ const INSURANCE_FLOOR_TIERS = [10_000, 25_000, 50_000];
11
+ const INSURANCE_STEP = 50_000;
12
+
13
+ /**
14
+ * Build the insurance tier ladder for a min/max range, in cents. Mirrors
15
+ * `InsuranceTierMath::buildTiers` in the PHP PDK, so the dropdown offers the same amounts the
16
+ * backend accepts: min, the floor tiers €100, €250 and €500, then €500 steps, then max.
17
+ */
18
+ const buildInsuranceTiers = (min: number, max: number): number[] => {
19
+ if (min >= max) {
20
+ return [min];
21
+ }
22
+
23
+ const tiers = [min, ...INSURANCE_FLOOR_TIERS.filter((tier) => tier > min && tier < max)];
24
+
25
+ for (let tier = Math.max(min, INSURANCE_STEP) + INSURANCE_STEP; tier < max; tier += INSURANCE_STEP) {
26
+ tiers.push(tier);
27
+ }
28
+
29
+ tiers.push(max);
30
+
31
+ return [...new Set(tiers)];
32
+ };
33
+
10
34
  /**
11
35
  * Bag of capability resolvers, each pre-bound to a Pinia store + orderId snapshot captured at
12
36
  * the composable's invocation time. Returned by {@link useFormCapabilities}.
@@ -129,25 +153,15 @@ export const useFormCapabilities = (): FormCapabilities => {
129
153
  };
130
154
 
131
155
  const getInsuranceOptions = (form: FormInstance, formatter: Formatter): SelectOption[] => {
132
- // Insurance bracket steps: €250 increments below €500, €500 increments above. Switching
133
- // step size at the threshold keeps the dropdown short for high-value shipments.
134
- const STEP_BELOW_THRESHOLD = 250;
135
- const STEP_ABOVE_THRESHOLD = 500;
136
- const STEP_THRESHOLD = 500;
137
-
138
156
  const carrier = getCarrierCapabilitiesForShipment(form);
139
157
  const insuranceData = carrier?.options?.insurance;
140
158
 
141
- const min = insuranceData?.min?.amount ? insuranceData.min.amount / 100 : 0;
142
- const max = insuranceData?.max?.amount ? insuranceData.max.amount / 100 : 0;
159
+ const min = insuranceData?.min?.amount ?? 0;
160
+ const max = insuranceData?.max?.amount ?? 0;
143
161
 
144
162
  if (max === 0) return [];
145
163
 
146
- const insurancePossibilities: number[] = [];
147
-
148
- for (let i = min; i <= max; i += i < STEP_THRESHOLD ? STEP_BELOW_THRESHOLD : STEP_ABOVE_THRESHOLD) {
149
- insurancePossibilities.push(i * 100);
150
- }
164
+ const insurancePossibilities = buildInsuranceTiers(min, max);
151
165
 
152
166
  return [
153
167
  {label: 'option_default', value: TriState.Inherit},