@tracepass/dpp-validate 0.7.0 → 0.8.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/dist/vendor/publish-gate.d.ts +6 -0
- package/dist/vendor/publish-gate.d.ts.map +1 -1
- package/dist/vendor/publish-gate.js +17 -9
- package/dist/vendor/publish-gate.js.map +1 -1
- package/dist/vendor/subcategory.d.ts +16 -0
- package/dist/vendor/subcategory.d.ts.map +1 -0
- package/dist/vendor/subcategory.js +24 -0
- package/dist/vendor/subcategory.js.map +1 -0
- package/package.json +2 -2
|
@@ -78,6 +78,12 @@ export declare function effectiveRequired(tf: Pick<TemplateField, "validation">,
|
|
|
78
78
|
* `batteryCategory`, so `category` is `undefined` and behaviour is unchanged.
|
|
79
79
|
*/
|
|
80
80
|
export declare function effectiveRequiredForBattery(tf: Pick<TemplateField, "validation">, category: string | undefined): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* `effectiveRequired` for any template: the battery scope rule
|
|
83
|
+
* (`effectiveRequiredForBattery`) applies to battery templates only, since a
|
|
84
|
+
* non-battery sub-category such as "laundry" is not an out-of-scope battery.
|
|
85
|
+
*/
|
|
86
|
+
export declare function effectiveRequiredFor(templateCategory: string, tf: Pick<TemplateField, "validation">, subcategory: string | undefined): boolean;
|
|
81
87
|
/**
|
|
82
88
|
* True when the template EXPLICITLY marks this field `notApplicable` for the
|
|
83
89
|
* given category — i.e. the Regulation says it must not be filled or displayed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-gate.d.ts","sourceRoot":"","sources":["../../src/vendor/publish-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"publish-gate.d.ts","sourceRoot":"","sources":["../../src/vendor/publish-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAA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from "./subcategory.js";
|
|
21
22
|
import { isInScopeBatteryCategory } from "./battery-scope.js";
|
|
22
23
|
import { isFieldAbsent } from "./field-emptiness.js";
|
|
23
24
|
const PUBLISHABLE_STATUSES = new Set([
|
|
@@ -78,6 +79,16 @@ export function effectiveRequiredForBattery(tf, category) {
|
|
|
78
79
|
}
|
|
79
80
|
return effectiveRequired(tf, category);
|
|
80
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* `effectiveRequired` for any template: the battery scope rule
|
|
84
|
+
* (`effectiveRequiredForBattery`) applies to battery templates only, since a
|
|
85
|
+
* non-battery sub-category such as "laundry" is not an out-of-scope battery.
|
|
86
|
+
*/
|
|
87
|
+
export function effectiveRequiredFor(templateCategory, tf, subcategory) {
|
|
88
|
+
return templateCategory === "battery"
|
|
89
|
+
? effectiveRequiredForBattery(tf, subcategory)
|
|
90
|
+
: effectiveRequired(tf, subcategory);
|
|
91
|
+
}
|
|
81
92
|
/**
|
|
82
93
|
* True when the template EXPLICITLY marks this field `notApplicable` for the
|
|
83
94
|
* given category — i.e. the Regulation says it must not be filled or displayed.
|
|
@@ -138,14 +149,11 @@ export function checkPublishReady(passport, template) {
|
|
|
138
149
|
blockerType: "hard",
|
|
139
150
|
};
|
|
140
151
|
}
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
const
|
|
146
|
-
const category = categoryField && categoryField.value != null && categoryField.value !== ""
|
|
147
|
-
? String(categoryField.value)
|
|
148
|
-
: undefined;
|
|
152
|
+
// The passport's sub-category, read from the field the template category
|
|
153
|
+
// names (battery: batteryCategory, fmcg: productSubcategory, detergents:
|
|
154
|
+
// detergentUserType; core SUBCATEGORY_FIELD), so effectiveRequired can
|
|
155
|
+
// resolve `requiredBy`. Unset → undefined → the plain `required` flag.
|
|
156
|
+
const category = passportSubcategory(template.category, passport.fields);
|
|
149
157
|
const missingFields = [];
|
|
150
158
|
const unapprovedFields = [];
|
|
151
159
|
for (const tf of template.fields) {
|
|
@@ -154,7 +162,7 @@ export function checkPublishReady(passport, template) {
|
|
|
154
162
|
// publication. Skip them before the required check.
|
|
155
163
|
if (tf.validation.anticipated)
|
|
156
164
|
continue;
|
|
157
|
-
if (!
|
|
165
|
+
if (!effectiveRequiredFor(template.category, tf, category))
|
|
158
166
|
continue;
|
|
159
167
|
const f = passport.fields[tf.key];
|
|
160
168
|
// Shared helper: `[]` stays a valid answer ("none apply"), while a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-gate.js","sourceRoot":"","sources":["../../src/vendor/publish-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"publish-gate.js","sourceRoot":"","sources":["../../src/vendor/publish-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsBrD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAqB;IACvD,OAAO;IACP,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqC,EACrC,QAA4B;IAE5B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC;IAE/C,wEAAwE;IACxE,IAAI,CAAC,UAAU,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,EAAE,CAAC;QACvE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,+CAA+C;IAC/C,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;A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K,CAAC,EAAE,CAAC;QAChE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC;IAClE,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,UAAU,CAAC,CAAC;IAC5E,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,eAAe,CAAC,CAAC;IAEvF,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,aAAa;QACb,gBAAgB;QAChB,MAAM,EAAE,oBAAoB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9C,WAAW,EAAE,KAAK;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The passport's sub-category, read from the field its template category names.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `SUBCATEGORY_FIELD` in `@tracepass/extraction-core` without importing
|
|
5
|
+
* the core, because this runs in client components (the passport editor) and the
|
|
6
|
+
* core pulls in server-only modules. `tests/passports/subcategory.test.ts` pins
|
|
7
|
+
* the two maps equal, so they cannot drift.
|
|
8
|
+
*
|
|
9
|
+
* `requiredBy` maps are keyed by these values; `effectiveRequiredFor` resolves
|
|
10
|
+
* them. Unset → undefined → the field's plain `required` flag applies.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SUBCATEGORY_FIELD: Readonly<Record<string, string>>;
|
|
13
|
+
export declare function passportSubcategory(templateCategory: string | undefined, fields: Readonly<Record<string, {
|
|
14
|
+
value?: unknown;
|
|
15
|
+
} | undefined>> | undefined): string | undefined;
|
|
16
|
+
//# sourceMappingURL=subcategory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subcategory.d.ts","sourceRoot":"","sources":["../../src/vendor/subcategory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI9D,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,GAC5E,MAAM,GAAG,SAAS,CAKpB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The passport's sub-category, read from the field its template category names.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `SUBCATEGORY_FIELD` in `@tracepass/extraction-core` without importing
|
|
5
|
+
* the core, because this runs in client components (the passport editor) and the
|
|
6
|
+
* core pulls in server-only modules. `tests/passports/subcategory.test.ts` pins
|
|
7
|
+
* the two maps equal, so they cannot drift.
|
|
8
|
+
*
|
|
9
|
+
* `requiredBy` maps are keyed by these values; `effectiveRequiredFor` resolves
|
|
10
|
+
* them. Unset → undefined → the field's plain `required` flag applies.
|
|
11
|
+
*/
|
|
12
|
+
export const SUBCATEGORY_FIELD = {
|
|
13
|
+
battery: "batteryCategory",
|
|
14
|
+
fmcg: "productSubcategory",
|
|
15
|
+
detergents: "detergentUserType",
|
|
16
|
+
};
|
|
17
|
+
export function passportSubcategory(templateCategory, fields) {
|
|
18
|
+
const key = templateCategory ? SUBCATEGORY_FIELD[templateCategory] : undefined;
|
|
19
|
+
if (!key)
|
|
20
|
+
return undefined;
|
|
21
|
+
const v = fields?.[key]?.value;
|
|
22
|
+
return v != null && v !== "" ? String(v) : undefined;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=subcategory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subcategory.js","sourceRoot":"","sources":["../../src/vendor/subcategory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IACjE,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,UAAU,EAAE,mBAAmB;CAChC,CAAC;AAEF,MAAM,UAAU,mBAAmB,CACjC,gBAAoC,EACpC,MAA6E;IAE7E,MAAM,GAAG,GAAG,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IAC/B,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracepass/dpp-validate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Evaluate an EU Digital Product Passport against its category field-spec — a three-tier compliance verdict with regulation-cited findings. Pure functions, no third-party runtime dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"digital-product-passport",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"clean": "rm -rf dist"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tracepass/dpp-types": "^0.
|
|
48
|
+
"@tracepass/dpp-types": "^0.8.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^5.6.3"
|