@pagefront/lint-commerce 0.8.0 → 0.10.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.
Files changed (55) hide show
  1. package/README.md +64 -6
  2. package/dist/catalogue.js +12 -3
  3. package/dist/index.d.ts +7 -4
  4. package/dist/index.js +6 -3
  5. package/dist/legacy-schemas.d.ts +9 -0
  6. package/dist/legacy-schemas.js +2446 -0
  7. package/dist/organization-catalogue.js +6 -3
  8. package/dist/organization-schema.d.ts +2 -1
  9. package/dist/organization-schema.js +9 -7
  10. package/dist/product-schema.d.ts +2 -2
  11. package/dist/product-schema.js +54 -22
  12. package/dist/releases.d.ts +36 -0
  13. package/dist/releases.js +41 -0
  14. package/dist/rules/configurator-pricing.d.ts +21 -2
  15. package/dist/rules/configurator-pricing.js +41 -5
  16. package/dist/rules/org-e-002.d.ts +7 -0
  17. package/dist/rules/org-e-002.js +13 -0
  18. package/dist/rules/org-e-003.d.ts +7 -0
  19. package/dist/rules/org-e-003.js +13 -0
  20. package/dist/rules/pdp-e-002.d.ts +3 -9
  21. package/dist/rules/pdp-e-002.js +6 -26
  22. package/dist/rules/pdp-e-008.js +1 -1
  23. package/dist/rules/pdp-e-009.d.ts +1 -1
  24. package/dist/rules/pdp-e-009.js +3 -3
  25. package/dist/rules/pdp-e-013.d.ts +9 -0
  26. package/dist/rules/pdp-e-013.js +26 -0
  27. package/dist/rules/pdp-e-014.d.ts +11 -0
  28. package/dist/rules/pdp-e-014.js +34 -0
  29. package/dist/rules/pdp-e-015.d.ts +2 -0
  30. package/dist/rules/pdp-e-015.js +91 -0
  31. package/dist/rules/pdp-e-016.d.ts +7 -0
  32. package/dist/rules/pdp-e-016.js +13 -0
  33. package/dist/rules/pdp-w-032.d.ts +3 -2
  34. package/dist/rules/pdp-w-032.js +20 -12
  35. package/dist/rules/pdp-w-036.d.ts +2 -0
  36. package/dist/rules/pdp-w-036.js +31 -0
  37. package/dist/rules/pdp-w-037.d.ts +2 -0
  38. package/dist/rules/pdp-w-037.js +37 -0
  39. package/dist/rules/pdp-w-038.d.ts +2 -0
  40. package/dist/rules/pdp-w-038.js +30 -0
  41. package/dist/rules/pdp-w-039.d.ts +10 -0
  42. package/dist/rules/pdp-w-039.js +29 -0
  43. package/dist/rules/release-schema.d.ts +16 -0
  44. package/dist/rules/release-schema.js +77 -0
  45. package/dist/schema-validators.d.ts +2 -0
  46. package/dist/schema-validators.js +10 -4
  47. package/dist/sheet-type.d.ts +17 -0
  48. package/dist/sheet-type.js +25 -0
  49. package/dist/validate-and-lint.d.ts +9 -5
  50. package/dist/validate-and-lint.js +17 -9
  51. package/dist/validate-organization.d.ts +4 -4
  52. package/dist/validate-organization.js +8 -5
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/package.json +2 -2
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.11.0, targeting format 0.9: 48 product rules (`PDP-E-001` to
30
- `PDP-E-012`, `PDP-W-001` to `PDP-W-035`, `PDP-I-001`) and 7 organization
31
- rules (`ORG-E-001`, `ORG-W-001` to `ORG-W-006`), each defined in
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.
@@ -93,6 +95,54 @@ configurator now fails Layer 1.
93
95
 
94
96
  Amounts are summed and compared as exact decimals.
95
97
 
98
+ Added in 0.9.0 (catalogue 0.14.0), from the same section and from
99
+ ["Size guidance"](https://themachineweb.org/pagefront/spec/commerce/product#size-guidance-pagefrontsizechart-and-pagefrontsizerecommendation):
100
+ option values are identifiers, free-text dimensions, order-time services
101
+ kept out of `options`, notes as facts, and size advice in the sizing
102
+ dimension's system. From 0.9.0 every amount is a JSON number or a plain
103
+ decimal string, one carrier per Sheet, and amounts are compared numerically
104
+ whatever the carrier; 0.8.0 validated pricing-block amounts as decimal
105
+ strings only. An Offer's `price`, a variant's `price` and a promotion's
106
+ `discountAmount` no longer accept a string that is not a plain decimal, and
107
+ prices, bounds and base prices no longer accept a negative amount.
108
+
109
+ - `PDP-E-013` — a dimension declares `inputType: "text"` and enumerates
110
+ options
111
+ - `PDP-W-036` — an option value looks like a display label (whitespace,
112
+ an uppercase letter, or a unit suffix); sizing dimensions are exempt
113
+ - `PDP-W-037` — an option in a sizing dimension (`system` of `UK`, `EU`,
114
+ `US` or `JP`) is not written as a size in that system
115
+ - `PDP-W-032`, `PDP-E-009` and the computed band of `PDP-E-011` now cover
116
+ the `"*"` modifier of a priced text dimension
117
+ - `PDP-E-014` — a size adjustment's `sizeSystem` is another system than
118
+ the configurator's sizing dimension
119
+ - `PDP-E-015` — the Sheet's amounts mix JSON numbers and strings
120
+ - `PDP-W-038` — a configurator dimension's `note` reads as page copy
121
+ (English Sheets: `you`, `your`, `select`, `order`, `contact`)
122
+ - `PDP-W-039` — size advice carries a `description` and no
123
+ `sizeAdjustment` beside a sizing dimension
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
+
96
146
  ## API
97
147
 
98
148
  The public surface — everything importable from the package root, and
@@ -106,9 +156,11 @@ internal):
106
156
  Commerce Organization Sheets to the organization ones (see
107
157
  `detectSheetType`). Returns
108
158
  `{ layer: 1, schemaErrors: SchemaError[] }` or
109
- `{ layer: 2, report: Report }`. The bundled schemas are the current
110
- format version; a document declaring another `format_version` fails
111
- Layer 1 by design. Layer 1 runs validators compiled ahead of time at
159
+ `{ layer: 2, report: Report }`. Two lines are validated: a sheet
160
+ carrying `release` against the current sheet-spec schema for its type,
161
+ and a legacy sheet carrying `format_version` against the frozen legacy
162
+ schema (format 0.9). A sheet carrying both fields fails Layer 1.
163
+ Layer 1 runs validators compiled ahead of time at
112
164
  package build, so the pipeline needs no runtime code generation and
113
165
  runs under Cloudflare Workers and strict Content Security Policies.
114
166
  - `lintSheet(sheet: Sheet, options?: LintOptions): Report` — Layer 2
@@ -184,6 +236,12 @@ await writeFile("report.html", renderHtml(report));
184
236
 
185
237
  ## Versioning
186
238
 
239
+ This package has its own semver, separate from the rule catalogue's
240
+ (`catalogue_version` in every report) and from the commerce release and
241
+ sheet-spec versions a sheet declares (`release` and `sheet_spec_version`
242
+ in every report). The scheme is in
243
+ [`releases.md`](https://github.com/themachineweb/pagefront/blob/main/commerce/spec/releases.md).
244
+
187
245
  Pre-1.0: minor versions may break the API. The surface listed above is
188
246
  what versioning tracks — imports that reach past it (`dist/` paths,
189
247
  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";
@@ -10,6 +11,10 @@ import { pdpE009 } from "./rules/pdp-e-009.js";
10
11
  import { pdpE010 } from "./rules/pdp-e-010.js";
11
12
  import { pdpE011 } from "./rules/pdp-e-011.js";
12
13
  import { pdpE012 } from "./rules/pdp-e-012.js";
14
+ import { pdpE013 } from "./rules/pdp-e-013.js";
15
+ import { pdpE014 } from "./rules/pdp-e-014.js";
16
+ import { pdpE015 } from "./rules/pdp-e-015.js";
17
+ import { pdpE016 } from "./rules/pdp-e-016.js";
13
18
  import { pdpW001 } from "./rules/pdp-w-001.js";
14
19
  import { pdpW002 } from "./rules/pdp-w-002.js";
15
20
  import { pdpW003 } from "./rules/pdp-w-003.js";
@@ -45,6 +50,10 @@ import { pdpW032 } from "./rules/pdp-w-032.js";
45
50
  import { pdpW033 } from "./rules/pdp-w-033.js";
46
51
  import { pdpW034 } from "./rules/pdp-w-034.js";
47
52
  import { pdpW035 } from "./rules/pdp-w-035.js";
53
+ import { pdpW036 } from "./rules/pdp-w-036.js";
54
+ import { pdpW037 } from "./rules/pdp-w-037.js";
55
+ import { pdpW038 } from "./rules/pdp-w-038.js";
56
+ import { pdpW039 } from "./rules/pdp-w-039.js";
48
57
  import { pdpI001 } from "./rules/pdp-i-001.js";
49
58
  /**
50
59
  * The commerce product-sheet rule catalogue — the executable form of
@@ -55,7 +64,7 @@ import { pdpI001 } from "./rules/pdp-i-001.js";
55
64
  */
56
65
  export const commerceCatalogue = {
57
66
  vertical: "commerce",
58
- formatVersion: "0.9",
59
- catalogueVersion: "0.11.0",
60
- rules: [pdpE001, pdpE002, pdpE003, pdpE004, pdpE005, pdpE006, pdpE007, pdpE008, pdpE009, pdpE010, pdpE011, pdpE012, 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, 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],
61
70
  };
package/dist/index.d.ts CHANGED
@@ -7,8 +7,10 @@
7
7
  * `validateOrganizationSheet` (Layer 1 for the Commerce Organization
8
8
  * Sheet; no organization catalogue exists yet), the commerce
9
9
  * catalogue object, and the types those signatures mention.
10
- * `product-schema.ts`, `organization-schema.ts`, and the individual
11
- * rule modules are internal.
10
+ * `product-schema.ts`, `organization-schema.ts`, `legacy-schemas.ts`
11
+ * and the individual rule modules are internal. The release manifest
12
+ * (`RELEASE_MANIFEST`, `sheetSpecVersionFor`) is exported so callers
13
+ * can resolve a release to its sheet-spec versions.
12
14
  */
13
15
  export { lintSheet } from "./lint-sheet.js";
14
16
  export { validateAndLint } from "./validate-and-lint.js";
@@ -17,6 +19,7 @@ export { validateOrganizationSheet } from "./validate-organization.js";
17
19
  export type { ValidateOrganizationResult } from "./validate-organization.js";
18
20
  export { commerceCatalogue } from "./catalogue.js";
19
21
  export { organizationCatalogue } from "./organization-catalogue.js";
20
- export { detectSheetType } from "./sheet-type.js";
21
- export type { SheetType } from "./sheet-type.js";
22
+ export { detectSheetType, detectSheetLine } from "./sheet-type.js";
23
+ export type { SheetType, SheetLine } from "./sheet-type.js";
24
+ export { RELEASE_MANIFEST, KNOWN_RELEASES, sheetSpecVersionFor } from "./releases.js";
22
25
  export type { Report, Finding, Summary, Severity, LintOptions, Sheet, } from "@pagefront/lint-core";
package/dist/index.js CHANGED
@@ -7,12 +7,15 @@
7
7
  * `validateOrganizationSheet` (Layer 1 for the Commerce Organization
8
8
  * Sheet; no organization catalogue exists yet), the commerce
9
9
  * catalogue object, and the types those signatures mention.
10
- * `product-schema.ts`, `organization-schema.ts`, and the individual
11
- * rule modules are internal.
10
+ * `product-schema.ts`, `organization-schema.ts`, `legacy-schemas.ts`
11
+ * and the individual rule modules are internal. The release manifest
12
+ * (`RELEASE_MANIFEST`, `sheetSpecVersionFor`) is exported so callers
13
+ * can resolve a release to its sheet-spec versions.
12
14
  */
13
15
  export { lintSheet } from "./lint-sheet.js";
14
16
  export { validateAndLint } from "./validate-and-lint.js";
15
17
  export { validateOrganizationSheet } from "./validate-organization.js";
16
18
  export { commerceCatalogue } from "./catalogue.js";
17
19
  export { organizationCatalogue } from "./organization-catalogue.js";
18
- export { detectSheetType } from "./sheet-type.js";
20
+ export { detectSheetType, detectSheetLine } from "./sheet-type.js";
21
+ export { RELEASE_MANIFEST, KNOWN_RELEASES, sheetSpecVersionFor } from "./releases.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The legacy draft line's JSON Schemas (commerce/spec/legacy/*.v0.9.json),
3
+ * bundled verbatim so sheets carrying `format_version` keep validating
4
+ * against the schemas their `$schema` URLs name. The files are frozen:
5
+ * the schema drift test (test/schema.test.mjs) fails if a bundled copy
6
+ * and its source diverge.
7
+ */
8
+ export declare const LEGACY_PRODUCT_SCHEMA: Record<string, unknown>;
9
+ export declare const LEGACY_ORGANIZATION_SCHEMA: Record<string, unknown>;