@pagefront/lint-commerce 0.9.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 +57 -13
- package/dist/catalogue.js +5 -3
- package/dist/generated/release-manifest.d.ts +22 -0
- package/dist/generated/release-manifest.js +27 -0
- package/dist/generated/schema-ids.d.ts +1 -0
- package/dist/generated/schema-ids.js +7 -0
- package/dist/generated/schema-properties.d.ts +1 -0
- package/dist/{schema-properties.js → generated/schema-properties.js} +2 -10
- package/dist/generated/schemas.d.ts +1 -0
- package/dist/generated/schemas.js +4883 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +9 -3
- package/dist/organization-catalogue.js +6 -3
- package/dist/releases.d.ts +22 -0
- package/dist/releases.js +27 -0
- package/dist/rules/org-e-002.d.ts +7 -0
- package/dist/rules/org-e-002.js +13 -0
- package/dist/rules/org-e-003.d.ts +7 -0
- package/dist/rules/org-e-003.js +13 -0
- package/dist/rules/pdp-e-002.d.ts +3 -9
- package/dist/rules/pdp-e-002.js +6 -26
- package/dist/rules/pdp-e-016.d.ts +7 -0
- package/dist/rules/pdp-e-016.js +13 -0
- package/dist/rules/pdp-i-001.js +3 -2
- package/dist/rules/release-schema.d.ts +16 -0
- package/dist/rules/release-schema.js +77 -0
- package/dist/schema-registry.d.ts +29 -0
- package/dist/schema-registry.js +35 -0
- package/dist/schema-validators.d.ts +7 -6
- package/dist/schema-validators.js +15 -3
- package/dist/sheet-type.d.ts +17 -0
- package/dist/sheet-type.js +25 -0
- package/dist/validate-and-lint.d.ts +24 -17
- package/dist/validate-and-lint.js +47 -28
- package/dist/validate-organization.d.ts +5 -5
- package/dist/validate-organization.js +8 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/organization-schema.d.ts +0 -9
- package/dist/organization-schema.js +0 -441
- package/dist/product-schema.d.ts +0 -9
- package/dist/product-schema.js +0 -2014
- package/dist/schema-properties.d.ts +0 -10
package/README.md
CHANGED
|
@@ -26,9 +26,11 @@ lint with their own catalogue, dispatched by sheet type.
|
|
|
26
26
|
|
|
27
27
|
## Catalogue
|
|
28
28
|
|
|
29
|
-
Catalogue 0.
|
|
30
|
-
|
|
31
|
-
rules (`
|
|
29
|
+
Catalogue 0.15.0, supporting commerce release 0.3.0 (Product Sheet spec
|
|
30
|
+
0.9.0, Organization Sheet spec 0.3.0) and the legacy draft line (format
|
|
31
|
+
0.9): 56 product rules (`PDP-E-001` to `PDP-E-016`, `PDP-W-001` to
|
|
32
|
+
`PDP-W-039`, `PDP-I-001`) and 9 organization rules (`ORG-E-001` to
|
|
33
|
+
`ORG-E-003`, `ORG-W-001` to `ORG-W-006`), each defined in
|
|
32
34
|
[`rules.md`](https://github.com/themachineweb/pagefront/blob/main/commerce/spec/rules.md)
|
|
33
35
|
with its target, check, message and remediation. Every report carries the
|
|
34
36
|
`catalogue_version` it was produced with.
|
|
@@ -120,29 +122,65 @@ prices, bounds and base prices no longer accept a negative amount.
|
|
|
120
122
|
- `PDP-W-039` — size advice carries a `description` and no
|
|
121
123
|
`sizeAdjustment` beside a sizing dimension
|
|
122
124
|
|
|
125
|
+
Added in 0.10.0 (catalogue 0.15.0), with commerce release 0.3.0 and the
|
|
126
|
+
[versioning scheme](https://github.com/themachineweb/pagefront/blob/main/commerce/spec/releases.md)
|
|
127
|
+
that replaces format versions:
|
|
128
|
+
|
|
129
|
+
- Sheets carry `release` in place of `format_version`, and `$schema` names
|
|
130
|
+
the sheet-spec version (`product/v0.9.0.json`, `organization/v0.3.0.json`).
|
|
131
|
+
Sheets carrying `format_version` are the legacy draft line and keep
|
|
132
|
+
validating against the bundled legacy schemas.
|
|
133
|
+
- `PDP-E-002` becomes "Release / schema mismatch": `$schema` must name the
|
|
134
|
+
sheet-spec version the release manifest maps the declared `release` to.
|
|
135
|
+
On legacy sheets it compares `format_version` with `$schema`, as before.
|
|
136
|
+
`ORG-E-003` is the same check for Organization Sheets.
|
|
137
|
+
- `PDP-E-016` and `ORG-E-002` — a sheet carries both `format_version` and
|
|
138
|
+
`release`
|
|
139
|
+
- **Breaking:** the report carries `release` (the value the sheet declares;
|
|
140
|
+
a legacy sheet's `format_version` value) and `sheet_spec_version` (parsed
|
|
141
|
+
from `$schema`) in place of `spec_version`. Requires
|
|
142
|
+
`@pagefront/lint-core` 0.2.0.
|
|
143
|
+
- New exports: `detectSheetLine`, `RELEASE_MANIFEST`, `KNOWN_RELEASES`,
|
|
144
|
+
`sheetSpecVersionFor`.
|
|
145
|
+
|
|
146
|
+
Changed in 0.11.0 (catalogue 0.15.0, unchanged):
|
|
147
|
+
|
|
148
|
+
- Layer 1 validates a sheet against the published schema its `$schema`
|
|
149
|
+
names. The package bundles every file in the repository's frozen schema
|
|
150
|
+
store (`commerce/schemas/`) at build time, with the release manifest;
|
|
151
|
+
nothing is embedded by hand.
|
|
152
|
+
- A `$schema` naming no bundled schema fails Layer 1 with one error. In
|
|
153
|
+
0.10.0 the schema was chosen from the envelope field, so a release
|
|
154
|
+
sheet pointing at another version passed Layer 1 and fired `PDP-E-002`;
|
|
155
|
+
it now fails Layer 1 against the schema it names.
|
|
156
|
+
- New exports: `CURRENT_RELEASE`, `schemaUrlFor`, `BUNDLED_SCHEMA_IDS`.
|
|
157
|
+
|
|
123
158
|
## API
|
|
124
159
|
|
|
125
160
|
The public surface — everything importable from the package root, and
|
|
126
|
-
nothing else (the bundled
|
|
161
|
+
nothing else (the bundled schemas and the individual rule modules are
|
|
127
162
|
internal):
|
|
128
163
|
|
|
129
164
|
- `validateAndLint(input: unknown, options?: LintOptions)` — the CLI's
|
|
130
|
-
own pipeline as a function: Layer 1 against the
|
|
131
|
-
|
|
132
|
-
catalogue
|
|
133
|
-
Commerce Organization Sheets to the organization ones (see
|
|
134
|
-
`detectSheetType`). Returns
|
|
165
|
+
own pipeline as a function: Layer 1 against the published schema the
|
|
166
|
+
document's `$schema` names, then Layer 2 against its page type's
|
|
167
|
+
catalogue (see `detectSheetType`). Returns
|
|
135
168
|
`{ layer: 1, schemaErrors: SchemaError[] }` or
|
|
136
|
-
`{ layer: 2, report: Report }`. The
|
|
137
|
-
|
|
138
|
-
|
|
169
|
+
`{ layer: 2, report: Report }`. The package bundles every published
|
|
170
|
+
schema, on both lines: the sheet-spec versions of each release and the
|
|
171
|
+
legacy format 0.9 schemas. A `$schema` naming a version the package
|
|
172
|
+
does not bundle fails Layer 1 with a single error at `/$schema`
|
|
173
|
+
(keyword `$schema`); the document is not validated against another
|
|
174
|
+
version. A document with no `$schema` is validated against the schema
|
|
175
|
+
its `release` or `format_version` leads to.
|
|
176
|
+
Layer 1 runs validators compiled ahead of time at
|
|
139
177
|
package build, so the pipeline needs no runtime code generation and
|
|
140
178
|
runs under Cloudflare Workers and strict Content Security Policies.
|
|
141
179
|
- `lintSheet(sheet: Sheet, options?: LintOptions): Report` — Layer 2
|
|
142
180
|
only, for input you have already schema-validated. Dispatches to the
|
|
143
181
|
page type's catalogue the same way.
|
|
144
182
|
- `validateOrganizationSheet(input: unknown)` — Layer 1 only, against
|
|
145
|
-
the
|
|
183
|
+
the Commerce Organization Sheet schema the document names. Returns
|
|
146
184
|
`{ valid: true }` or `{ valid: false, schemaErrors: SchemaError[] }`.
|
|
147
185
|
- `detectSheetType(sheet: Sheet): SheetType` — the page-type dispatch:
|
|
148
186
|
`"organization"` when the envelope `$schema` path contains
|
|
@@ -211,6 +249,12 @@ await writeFile("report.html", renderHtml(report));
|
|
|
211
249
|
|
|
212
250
|
## Versioning
|
|
213
251
|
|
|
252
|
+
This package has its own semver, separate from the rule catalogue's
|
|
253
|
+
(`catalogue_version` in every report) and from the commerce release and
|
|
254
|
+
sheet-spec versions a sheet declares (`release` and `sheet_spec_version`
|
|
255
|
+
in every report). The scheme is in
|
|
256
|
+
[`releases.md`](https://github.com/themachineweb/pagefront/blob/main/commerce/spec/releases.md).
|
|
257
|
+
|
|
214
258
|
Pre-1.0: minor versions may break the API. The surface listed above is
|
|
215
259
|
what versioning tracks — imports that reach past it (`dist/` paths,
|
|
216
260
|
rule modules) are internal and may change without notice in any
|
package/dist/catalogue.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KNOWN_RELEASES } from "./releases.js";
|
|
1
2
|
import { pdpE001 } from "./rules/pdp-e-001.js";
|
|
2
3
|
import { pdpE002 } from "./rules/pdp-e-002.js";
|
|
3
4
|
import { pdpE003 } from "./rules/pdp-e-003.js";
|
|
@@ -13,6 +14,7 @@ import { pdpE012 } from "./rules/pdp-e-012.js";
|
|
|
13
14
|
import { pdpE013 } from "./rules/pdp-e-013.js";
|
|
14
15
|
import { pdpE014 } from "./rules/pdp-e-014.js";
|
|
15
16
|
import { pdpE015 } from "./rules/pdp-e-015.js";
|
|
17
|
+
import { pdpE016 } from "./rules/pdp-e-016.js";
|
|
16
18
|
import { pdpW001 } from "./rules/pdp-w-001.js";
|
|
17
19
|
import { pdpW002 } from "./rules/pdp-w-002.js";
|
|
18
20
|
import { pdpW003 } from "./rules/pdp-w-003.js";
|
|
@@ -62,7 +64,7 @@ import { pdpI001 } from "./rules/pdp-i-001.js";
|
|
|
62
64
|
*/
|
|
63
65
|
export const commerceCatalogue = {
|
|
64
66
|
vertical: "commerce",
|
|
65
|
-
|
|
66
|
-
catalogueVersion: "0.
|
|
67
|
-
rules: [pdpE001, pdpE002, pdpE003, pdpE004, pdpE005, pdpE006, pdpE007, pdpE008, pdpE009, pdpE010, pdpE011, pdpE012, pdpE013, pdpE014, pdpE015, pdpW001, pdpW002, pdpW003, pdpW004, pdpW005, pdpW006, pdpW007, pdpW008, pdpW009, pdpW010, pdpW011, pdpW012, pdpW013, pdpW014, pdpW015, pdpW016, pdpW017, pdpW018, pdpW019, pdpW020, pdpW021, pdpW022, pdpW023, pdpW024, pdpW025, pdpW026, pdpW027, pdpW028, pdpW029, pdpW030, pdpW031, pdpW032, pdpW033, pdpW034, pdpW035, pdpW036, pdpW037, pdpW038, pdpW039, pdpI001],
|
|
67
|
+
releases: KNOWN_RELEASES,
|
|
68
|
+
catalogueVersion: "0.15.0",
|
|
69
|
+
rules: [pdpE001, pdpE002, pdpE003, pdpE004, pdpE005, pdpE006, pdpE007, pdpE008, pdpE009, pdpE010, pdpE011, pdpE012, pdpE013, pdpE014, pdpE015, pdpE016, pdpW001, pdpW002, pdpW003, pdpW004, pdpW005, pdpW006, pdpW007, pdpW008, pdpW009, pdpW010, pdpW011, pdpW012, pdpW013, pdpW014, pdpW015, pdpW016, pdpW017, pdpW018, pdpW019, pdpW020, pdpW021, pdpW022, pdpW023, pdpW024, pdpW025, pdpW026, pdpW027, pdpW028, pdpW029, pdpW030, pdpW031, pdpW032, pdpW033, pdpW034, pdpW035, pdpW036, pdpW037, pdpW038, pdpW039, pdpI001],
|
|
68
70
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const RELEASE_MANIFEST: {
|
|
2
|
+
readonly $comment: "The commerce release manifest: each release and the member versions it bundles. Consumed by the linter; the human-readable form is releases.md.";
|
|
3
|
+
readonly vertical: "commerce";
|
|
4
|
+
readonly schema_url_template: "https://themachineweb.org/pagefront/spec/commerce/{sheet}/v{version}.json";
|
|
5
|
+
readonly releases: readonly [{
|
|
6
|
+
readonly release: "0.3.0";
|
|
7
|
+
readonly date: "2026-10-01";
|
|
8
|
+
readonly vocabulary: "0.3.0";
|
|
9
|
+
readonly sheets: {
|
|
10
|
+
readonly product: "0.9.0";
|
|
11
|
+
readonly organization: "0.3.0";
|
|
12
|
+
};
|
|
13
|
+
}];
|
|
14
|
+
readonly legacy: {
|
|
15
|
+
readonly envelope_field: "format_version";
|
|
16
|
+
readonly format_versions: readonly ["0.9"];
|
|
17
|
+
readonly schemas: {
|
|
18
|
+
readonly product: "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json";
|
|
19
|
+
readonly organization: "https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Generated by scripts/bundle-schemas.mjs; do not edit, do not commit.
|
|
2
|
+
export const RELEASE_MANIFEST = {
|
|
3
|
+
"$comment": "The commerce release manifest: each release and the member versions it bundles. Consumed by the linter; the human-readable form is releases.md.",
|
|
4
|
+
"vertical": "commerce",
|
|
5
|
+
"schema_url_template": "https://themachineweb.org/pagefront/spec/commerce/{sheet}/v{version}.json",
|
|
6
|
+
"releases": [
|
|
7
|
+
{
|
|
8
|
+
"release": "0.3.0",
|
|
9
|
+
"date": "2026-10-01",
|
|
10
|
+
"vocabulary": "0.3.0",
|
|
11
|
+
"sheets": {
|
|
12
|
+
"product": "0.9.0",
|
|
13
|
+
"organization": "0.3.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"legacy": {
|
|
18
|
+
"envelope_field": "format_version",
|
|
19
|
+
"format_versions": [
|
|
20
|
+
"0.9"
|
|
21
|
+
],
|
|
22
|
+
"schemas": {
|
|
23
|
+
"product": "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json",
|
|
24
|
+
"organization": "https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SCHEMA_IDS: readonly string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Generated by scripts/bundle-schemas.mjs; do not edit, do not commit.
|
|
2
|
+
export const SCHEMA_IDS = [
|
|
3
|
+
"https://themachineweb.org/pagefront/spec/commerce/organization/v0.3.0.json",
|
|
4
|
+
"https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json",
|
|
5
|
+
"https://themachineweb.org/pagefront/spec/commerce/product/v0.9.0.json",
|
|
6
|
+
"https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json"
|
|
7
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATA_BLOCK_PROPERTIES: readonly string[];
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The data-block property inventory for PDP-I-001, derived from the
|
|
3
|
-
* Pagefront JSON Schema (commerce/spec/product.json, format 0.9) —
|
|
4
|
-
* the normative property inventory per the catalogue's Definitions
|
|
5
|
-
* section. Generated from `$defs.dataBlock.properties`; the
|
|
6
|
-
* inventory drift test (test/inventory.test.mjs) fails when the
|
|
7
|
-
* schema and this list diverge. Regenerate on schema change, in the
|
|
8
|
-
* same catalogue-versioned change.
|
|
9
|
-
*/
|
|
1
|
+
// Generated by scripts/bundle-schemas.mjs; do not edit, do not commit.
|
|
10
2
|
export const DATA_BLOCK_PROPERTIES = [
|
|
11
3
|
"@context",
|
|
12
4
|
"@id",
|
|
@@ -64,5 +56,5 @@ export const DATA_BLOCK_PROPERTIES = [
|
|
|
64
56
|
"variesBy",
|
|
65
57
|
"video",
|
|
66
58
|
"weight",
|
|
67
|
-
"width"
|
|
59
|
+
"width"
|
|
68
60
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SCHEMAS: Readonly<Record<string, Record<string, unknown>>>;
|