@pagefront/lint-commerce 0.9.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.
- package/README.md +37 -6
- package/dist/catalogue.js +5 -3
- package/dist/index.d.ts +7 -4
- package/dist/index.js +6 -3
- package/dist/legacy-schemas.d.ts +9 -0
- package/dist/legacy-schemas.js +2446 -0
- package/dist/organization-catalogue.js +6 -3
- package/dist/organization-schema.d.ts +2 -1
- package/dist/organization-schema.js +9 -7
- package/dist/product-schema.d.ts +2 -2
- package/dist/product-schema.js +9 -8
- package/dist/releases.d.ts +36 -0
- package/dist/releases.js +41 -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/release-schema.d.ts +16 -0
- package/dist/rules/release-schema.js +77 -0
- package/dist/schema-validators.d.ts +2 -0
- package/dist/schema-validators.js +9 -3
- package/dist/sheet-type.d.ts +17 -0
- package/dist/sheet-type.js +25 -0
- package/dist/validate-and-lint.d.ts +9 -5
- package/dist/validate-and-lint.js +17 -9
- package/dist/validate-organization.d.ts +4 -4
- package/dist/validate-organization.js +8 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { KNOWN_RELEASES } from "./releases.js";
|
|
1
2
|
import { orgE001 } from "./rules/org-e-001.js";
|
|
3
|
+
import { orgE002 } from "./rules/org-e-002.js";
|
|
4
|
+
import { orgE003 } from "./rules/org-e-003.js";
|
|
2
5
|
import { orgW001 } from "./rules/org-w-001.js";
|
|
3
6
|
import { orgW002 } from "./rules/org-w-002.js";
|
|
4
7
|
import { orgW003 } from "./rules/org-w-003.js";
|
|
@@ -16,7 +19,7 @@ import { orgW006 } from "./rules/org-w-006.js";
|
|
|
16
19
|
*/
|
|
17
20
|
export const organizationCatalogue = {
|
|
18
21
|
vertical: "commerce",
|
|
19
|
-
|
|
20
|
-
catalogueVersion: "0.
|
|
21
|
-
rules: [orgE001, orgW001, orgW002, orgW003, orgW004, orgW005, orgW006],
|
|
22
|
+
releases: KNOWN_RELEASES,
|
|
23
|
+
catalogueVersion: "0.15.0",
|
|
24
|
+
rules: [orgE001, orgE002, orgE003, orgW001, orgW002, orgW003, orgW004, orgW005, orgW006],
|
|
22
25
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Pagefront Commerce Organization Sheet JSON Schema
|
|
3
|
-
* (commerce/spec/organization.json,
|
|
3
|
+
* (commerce/spec/organization.json, the current sheet-spec version on
|
|
4
|
+
* the release line), bundled verbatim so
|
|
4
5
|
* the published package can run Layer 1 validation without the
|
|
5
6
|
* monorepo checkout. Generated from the spec file; the schema drift
|
|
6
7
|
* test (test/schema.test.mjs) fails when the two diverge. Regenerate
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Pagefront Commerce Organization Sheet JSON Schema
|
|
3
|
-
* (commerce/spec/organization.json,
|
|
3
|
+
* (commerce/spec/organization.json, the current sheet-spec version on
|
|
4
|
+
* the release line), bundled verbatim so
|
|
4
5
|
* the published package can run Layer 1 validation without the
|
|
5
6
|
* monorepo checkout. Generated from the spec file; the schema drift
|
|
6
7
|
* test (test/schema.test.mjs) fails when the two diverge. Regenerate
|
|
@@ -8,12 +9,12 @@
|
|
|
8
9
|
*/
|
|
9
10
|
export const ORGANIZATION_SCHEMA = {
|
|
10
11
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
11
|
-
"$id": "https://themachineweb.org/pagefront/spec/commerce/organization/v0.
|
|
12
|
-
"title": "Pagefront Commerce Organization Sheet
|
|
13
|
-
"description": "Formal schema for the Pagefront Commerce Organization Sheet — the sheet describing the entity behind products (brand owner, manufacturer, seller), introduced with commerce format 0.9 alongside the reference-capable legalEntity and the seller-sheet return/shipping model. The data block roots on Schema.org Organization (recognized subtypes permitted; @type is not constrained to a single value). pagefront:commerceRole is the required role discriminator, an array of one or more values from the closed enum brand_owner / manufacturer / seller. pagefront:fulfillmentTerms carries the store-wide shipping defaults as an array of Schema.org-native OfferShippingDetails objects; only the attachment shell is validated, the payload is Schema.org content. pagefront:socialAccount carries the organization's official social accounts (platform / url / handle; publisher-stated only), distinct from sameAs, which carries identity authority records only. pagefront:authorizedResellers carries the brand's authorization claim over its distribution — a pagefront:AuthorizedResellers object with an optional exhaustive flag and a reseller array whose entries name an Organization either as a reference stub (@id) or inline (name plus url and/or address), with optional Schema.org-native areaServed; valid only where commerceRole includes brand_owner (linter ORG-W-006). There is no GTIN-equivalent identifier requirement: identity is @id + name. Validates the envelope and pagefront-namespaced extensions strictly; Schema.org-typed blocks permit additional unspecified properties.",
|
|
12
|
+
"$id": "https://themachineweb.org/pagefront/spec/commerce/organization/v0.3.0.json",
|
|
13
|
+
"title": "Pagefront Commerce Organization Sheet 0.3.0",
|
|
14
|
+
"description": "Sheet spec version 0.3.0, a member of commerce release 0.3.0: the envelope carries release in place of format_version, and $schema names this sheet-spec version; a sheet carrying format_version belongs to the legacy draft line and validates against the legacy schema at .../organization/v0.9.json, which is otherwise identical. Formal schema for the Pagefront Commerce Organization Sheet — the sheet describing the entity behind products (brand owner, manufacturer, seller), introduced with commerce format 0.9 alongside the reference-capable legalEntity and the seller-sheet return/shipping model. The data block roots on Schema.org Organization (recognized subtypes permitted; @type is not constrained to a single value). pagefront:commerceRole is the required role discriminator, an array of one or more values from the closed enum brand_owner / manufacturer / seller. pagefront:fulfillmentTerms carries the store-wide shipping defaults as an array of Schema.org-native OfferShippingDetails objects; only the attachment shell is validated, the payload is Schema.org content. pagefront:socialAccount carries the organization's official social accounts (platform / url / handle; publisher-stated only), distinct from sameAs, which carries identity authority records only. pagefront:authorizedResellers carries the brand's authorization claim over its distribution — a pagefront:AuthorizedResellers object with an optional exhaustive flag and a reseller array whose entries name an Organization either as a reference stub (@id) or inline (name plus url and/or address), with optional Schema.org-native areaServed; valid only where commerceRole includes brand_owner (linter ORG-W-006). There is no GTIN-equivalent identifier requirement: identity is @id + name. Validates the envelope and pagefront-namespaced extensions strictly; Schema.org-typed blocks permit additional unspecified properties.",
|
|
14
15
|
"type": "object",
|
|
15
16
|
"required": [
|
|
16
|
-
"
|
|
17
|
+
"release",
|
|
17
18
|
"schema_org_version",
|
|
18
19
|
"canonical_url",
|
|
19
20
|
"sheet_url",
|
|
@@ -25,8 +26,9 @@ export const ORGANIZATION_SCHEMA = {
|
|
|
25
26
|
"type": "string",
|
|
26
27
|
"format": "uri"
|
|
27
28
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"release": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
|
|
30
32
|
},
|
|
31
33
|
"schema_org_version": {
|
|
32
34
|
"type": "string",
|
package/dist/product-schema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Pagefront
|
|
3
|
-
*
|
|
2
|
+
* The Pagefront Product Sheet JSON Schema (commerce/spec/product.json,
|
|
3
|
+
* the current sheet-spec version on the release line), bundled verbatim so the published package can run
|
|
4
4
|
* Layer 1 validation without the monorepo checkout. Generated from
|
|
5
5
|
* the spec file; the schema drift test (test/schema.test.mjs) fails
|
|
6
6
|
* when the two diverge. Regenerate on any schema change, in the same
|
package/dist/product-schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Pagefront
|
|
3
|
-
*
|
|
2
|
+
* The Pagefront Product Sheet JSON Schema (commerce/spec/product.json,
|
|
3
|
+
* the current sheet-spec version on the release line), bundled verbatim so the published package can run
|
|
4
4
|
* Layer 1 validation without the monorepo checkout. Generated from
|
|
5
5
|
* the spec file; the schema drift test (test/schema.test.mjs) fails
|
|
6
6
|
* when the two diverge. Regenerate on any schema change, in the same
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const PRODUCT_SCHEMA = {
|
|
10
10
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
11
|
-
"$id": "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json",
|
|
12
|
-
"title": "Pagefront Product Sheet
|
|
13
|
-
"description": "Formal schema for the Pagefront
|
|
11
|
+
"$id": "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.0.json",
|
|
12
|
+
"title": "Pagefront Product Sheet 0.9.0",
|
|
13
|
+
"description": "Formal schema for the Pagefront Product Sheet, sheet spec version 0.9.0, a member of commerce release 0.3.0. The envelope carries release in place of format_version: release names the commerce release the sheet is written against, and $schema names this sheet-spec version. A sheet carrying format_version belongs to the legacy draft line and validates against the legacy schema at .../product/v0.9.json, which is otherwise identical. History, in legacy format versions: revision of 2026-10-01 (breaking, within v0.9): configurator pricing moves from pagefront:configurator to the offer. The configurator loses basePrice, basePriceCurrency and priceFormula, its options lose priceModifier and currency, and it gains an optional @id and an exclusions[] array; configurator dimensions gain affectsPrice, inputType (select or text, for free-text dimensions) and maxLength; Offer and AggregateOffer accept pagefront:configuratorPricing, which names the configurator it prices and carries baseConfiguration, basePrice, modifiers, optional adjustments[] and a pricing completeness flag; every amount field (Offer price, AggregateOffer lowPrice and highPrice, variant price hints, promotion discountAmount, and the pricing block's basePrice, modifiers and adjustment amounts) references a shared definition, a JSON number or a plain decimal string: nonNegativeAmount for prices, bounds, base prices, price hints and discount amounts, and the signed amount for modifiers and adjustment amounts. v0.9 sheets that carried prices inside the configurator no longer validate. v0.9 was otherwise an additive release on top of v0.8: the legalEntity entry's organization now also validates in reference-stub form (@type + @id, no name) so entries can reference a Commerce Organization Sheet; the inline form and all other constraints are unchanged, and v0.8 sheets remain valid once their format_version is updated. v0.8 is an additive release on top of v0.7: it adds a pagefront:featureGroup[] array for grouped, ordered technical specifications (groups of Schema.org PropertyValue entries, with an optional pagefront:presentationValue display variant per entry), a pagefront:productHighlights[] array of ordered publisher-authored selling-point strings, and a pagefront:legalEntity[] array for role-typed legal entities behind a product (closed role enum: brand_owner, licensee, authorized_representative, importer, manufacturer — EU GPSR responsible persons and similar). gtin and gtin13 now accept a string or an array of strings (regional packaging, re-releases); category now accepts the display string, a Schema.org CategoryCode object, or a mixed array of both. The pagefront:Document role enum gains repairability_index, recall_notice, and declaration_of_conformity; the pagefront:RelatedProduct relationship enum gains service. v0.8 also adds two GPSR-driven safety fields: a pagefront:safetyWarning[] array for typed, language-scoped safety warnings (text required; optional pictogram URL and open-vocabulary hazardCategory) and a pagefront:safetyNotice[] array for structured recall/safety notices (closed noticeType enum: recall, warning; closed remedy enum: repair, replacement, refund). v0.7 sheets remain valid under v0.8 once their format_version is updated. Validates the envelope and pagefront-namespaced extensions strictly; Schema.org-typed blocks permit additional unspecified properties.",
|
|
14
14
|
"type": "object",
|
|
15
15
|
"required": [
|
|
16
|
-
"
|
|
16
|
+
"release",
|
|
17
17
|
"schema_org_version",
|
|
18
18
|
"canonical_url",
|
|
19
19
|
"sheet_url",
|
|
@@ -25,8 +25,9 @@ export const PRODUCT_SCHEMA = {
|
|
|
25
25
|
"type": "string",
|
|
26
26
|
"format": "uri"
|
|
27
27
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"release": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
|
|
30
31
|
},
|
|
31
32
|
"schema_org_version": {
|
|
32
33
|
"type": "string",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SheetType } from "./sheet-type.js";
|
|
2
|
+
/**
|
|
3
|
+
* The commerce release manifest (commerce/spec/releases.json), bundled
|
|
4
|
+
* verbatim: each release and the member versions it bundles. Generated
|
|
5
|
+
* from the spec file; the drift test (test/releases.test.mjs) fails
|
|
6
|
+
* when the two diverge. Regenerate when a release is cut.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RELEASE_MANIFEST: {
|
|
9
|
+
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.";
|
|
10
|
+
readonly vertical: "commerce";
|
|
11
|
+
readonly schema_url_template: "https://themachineweb.org/pagefront/spec/commerce/{sheet}/v{version}.json";
|
|
12
|
+
readonly releases: readonly [{
|
|
13
|
+
readonly release: "0.3.0";
|
|
14
|
+
readonly date: "2026-10-01";
|
|
15
|
+
readonly vocabulary: "0.3.0";
|
|
16
|
+
readonly sheets: {
|
|
17
|
+
readonly product: "0.9.0";
|
|
18
|
+
readonly organization: "0.3.0";
|
|
19
|
+
};
|
|
20
|
+
}];
|
|
21
|
+
readonly legacy: {
|
|
22
|
+
readonly envelope_field: "format_version";
|
|
23
|
+
readonly format_versions: readonly ["0.9"];
|
|
24
|
+
readonly schemas: {
|
|
25
|
+
readonly product: "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json";
|
|
26
|
+
readonly organization: "https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/** Every release the manifest lists, in manifest order. */
|
|
31
|
+
export declare const KNOWN_RELEASES: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* The sheet-spec version a release bundles for a sheet type, or
|
|
34
|
+
* undefined when the manifest does not list the release.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sheetSpecVersionFor(release: string, sheetType: SheetType): string | undefined;
|
package/dist/releases.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commerce release manifest (commerce/spec/releases.json), bundled
|
|
3
|
+
* verbatim: each release and the member versions it bundles. Generated
|
|
4
|
+
* from the spec file; the drift test (test/releases.test.mjs) fails
|
|
5
|
+
* when the two diverge. Regenerate when a release is cut.
|
|
6
|
+
*/
|
|
7
|
+
export const RELEASE_MANIFEST = {
|
|
8
|
+
"$comment": "The commerce release manifest: each release and the member versions it bundles. Consumed by the linter; the human-readable form is releases.md.",
|
|
9
|
+
"vertical": "commerce",
|
|
10
|
+
"schema_url_template": "https://themachineweb.org/pagefront/spec/commerce/{sheet}/v{version}.json",
|
|
11
|
+
"releases": [
|
|
12
|
+
{
|
|
13
|
+
"release": "0.3.0",
|
|
14
|
+
"date": "2026-10-01",
|
|
15
|
+
"vocabulary": "0.3.0",
|
|
16
|
+
"sheets": {
|
|
17
|
+
"product": "0.9.0",
|
|
18
|
+
"organization": "0.3.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"legacy": {
|
|
23
|
+
"envelope_field": "format_version",
|
|
24
|
+
"format_versions": [
|
|
25
|
+
"0.9"
|
|
26
|
+
],
|
|
27
|
+
"schemas": {
|
|
28
|
+
"product": "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json",
|
|
29
|
+
"organization": "https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/** Every release the manifest lists, in manifest order. */
|
|
34
|
+
export const KNOWN_RELEASES = RELEASE_MANIFEST.releases.map((r) => r.release);
|
|
35
|
+
/**
|
|
36
|
+
* The sheet-spec version a release bundles for a sheet type, or
|
|
37
|
+
* undefined when the manifest does not list the release.
|
|
38
|
+
*/
|
|
39
|
+
export function sheetSpecVersionFor(release, sheetType) {
|
|
40
|
+
return RELEASE_MANIFEST.releases.find((r) => r.release === release)?.sheets[sheetType];
|
|
41
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "@pagefront/lint-core";
|
|
2
|
+
/**
|
|
3
|
+
* ORG-E-002 — Sheet carries both format_version and release.
|
|
4
|
+
* The organization-sheet counterpart of PDP-E-016. Transcribed from
|
|
5
|
+
* commerce/spec/rules.md (normative).
|
|
6
|
+
*/
|
|
7
|
+
export declare const orgE002: Rule;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BOTH_VERSION_FIELDS, bothVersionFields } from "./release-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* ORG-E-002 — Sheet carries both format_version and release.
|
|
4
|
+
* The organization-sheet counterpart of PDP-E-016. Transcribed from
|
|
5
|
+
* commerce/spec/rules.md (normative).
|
|
6
|
+
*/
|
|
7
|
+
export const orgE002 = {
|
|
8
|
+
id: "ORG-E-002",
|
|
9
|
+
...BOTH_VERSION_FIELDS,
|
|
10
|
+
check: bothVersionFields,
|
|
11
|
+
introduced: "release 0.3.0",
|
|
12
|
+
specReference: "organization.md#the-envelope",
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RELEASE_SCHEMA_MISMATCH, releaseSchemaMismatch } from "./release-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* ORG-E-003 — Release / schema mismatch.
|
|
4
|
+
* The organization-sheet counterpart of PDP-E-002. Transcribed from
|
|
5
|
+
* commerce/spec/rules.md (normative).
|
|
6
|
+
*/
|
|
7
|
+
export const orgE003 = {
|
|
8
|
+
id: "ORG-E-003",
|
|
9
|
+
...RELEASE_SCHEMA_MISMATCH,
|
|
10
|
+
check: releaseSchemaMismatch("organization"),
|
|
11
|
+
introduced: "release 0.3.0",
|
|
12
|
+
specReference: "organization.md#the-envelope",
|
|
13
|
+
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { Rule } from "@pagefront/lint-core";
|
|
2
2
|
/**
|
|
3
|
-
* PDP-E-002 —
|
|
4
|
-
* Transcribed from commerce/spec/rules.md
|
|
5
|
-
*
|
|
6
|
-
* `$schema` is read via the rule context, per the target line. The
|
|
7
|
-
* version segment is the trailing `v<version>.json` of the `$schema`
|
|
8
|
-
* URL. Two quiet cases, both documented readings: `$schema` absent
|
|
9
|
-
* (optional at Layer 1 — nothing to compare), and a `$schema` with no
|
|
10
|
-
* parseable version segment (it declares no version, so no mismatch
|
|
11
|
-
* can be asserted; the message requires `{schema_version}`).
|
|
3
|
+
* PDP-E-002 — Release / schema mismatch (until release 0.3.0: "Format
|
|
4
|
+
* version / schema mismatch"). Transcribed from commerce/spec/rules.md
|
|
5
|
+
* (normative); the check is shared with ORG-E-003 (release-schema.ts).
|
|
12
6
|
*/
|
|
13
7
|
export declare const pdpE002: Rule;
|
package/dist/rules/pdp-e-002.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
|
+
import { RELEASE_SCHEMA_MISMATCH, releaseSchemaMismatch } from "./release-schema.js";
|
|
1
2
|
/**
|
|
2
|
-
* PDP-E-002 —
|
|
3
|
-
* Transcribed from commerce/spec/rules.md
|
|
4
|
-
*
|
|
5
|
-
* `$schema` is read via the rule context, per the target line. The
|
|
6
|
-
* version segment is the trailing `v<version>.json` of the `$schema`
|
|
7
|
-
* URL. Two quiet cases, both documented readings: `$schema` absent
|
|
8
|
-
* (optional at Layer 1 — nothing to compare), and a `$schema` with no
|
|
9
|
-
* parseable version segment (it declares no version, so no mismatch
|
|
10
|
-
* can be asserted; the message requires `{schema_version}`).
|
|
3
|
+
* PDP-E-002 — Release / schema mismatch (until release 0.3.0: "Format
|
|
4
|
+
* version / schema mismatch"). Transcribed from commerce/spec/rules.md
|
|
5
|
+
* (normative); the check is shared with ORG-E-003 (release-schema.ts).
|
|
11
6
|
*/
|
|
12
7
|
export const pdpE002 = {
|
|
13
8
|
id: "PDP-E-002",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
target: "$.format_version",
|
|
17
|
-
check: (match, ctx) => {
|
|
18
|
-
const formatVersion = String(match.value);
|
|
19
|
-
const schema = ctx.sheet.$schema;
|
|
20
|
-
if (typeof schema !== "string")
|
|
21
|
-
return null;
|
|
22
|
-
const segment = /v(\d+(?:\.\d+)*)\.json$/.exec(schema);
|
|
23
|
-
if (segment === null)
|
|
24
|
-
return null;
|
|
25
|
-
return segment[1] === formatVersion
|
|
26
|
-
? null
|
|
27
|
-
: { values: { format_version: formatVersion, schema_version: segment[1] } };
|
|
28
|
-
},
|
|
29
|
-
messageTemplate: "`format_version` is `{format_version}` but `$schema` URL declares version `{schema_version}`.",
|
|
30
|
-
remediation: "Align both fields to the same version. Whichever version was intended, update the other field to match.",
|
|
9
|
+
...RELEASE_SCHEMA_MISMATCH,
|
|
10
|
+
check: releaseSchemaMismatch("product"),
|
|
31
11
|
introduced: "v0.6",
|
|
32
12
|
specReference: "product.md#the-envelope",
|
|
33
13
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "@pagefront/lint-core";
|
|
2
|
+
/**
|
|
3
|
+
* PDP-E-016 — Sheet carries both format_version and release.
|
|
4
|
+
* Transcribed from commerce/spec/rules.md (normative); the check is
|
|
5
|
+
* shared with ORG-E-002 (release-schema.ts).
|
|
6
|
+
*/
|
|
7
|
+
export declare const pdpE016: Rule;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BOTH_VERSION_FIELDS, bothVersionFields } from "./release-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* PDP-E-016 — Sheet carries both format_version and release.
|
|
4
|
+
* Transcribed from commerce/spec/rules.md (normative); the check is
|
|
5
|
+
* shared with ORG-E-002 (release-schema.ts).
|
|
6
|
+
*/
|
|
7
|
+
export const pdpE016 = {
|
|
8
|
+
id: "PDP-E-016",
|
|
9
|
+
...BOTH_VERSION_FIELDS,
|
|
10
|
+
check: bothVersionFields,
|
|
11
|
+
introduced: "release 0.3.0",
|
|
12
|
+
specReference: "product.md#the-envelope",
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CheckFn, Rule } from "@pagefront/lint-core";
|
|
2
|
+
import type { SheetType } from "../sheet-type.js";
|
|
3
|
+
/**
|
|
4
|
+
* Release / schema mismatch. On the release line the `$schema` version
|
|
5
|
+
* segment must be the sheet-spec version the release manifest maps the
|
|
6
|
+
* declared `release` and the sheet type to; a release the manifest does
|
|
7
|
+
* not list has no mapping and the rule is silent. On the legacy line
|
|
8
|
+
* the segment must equal `format_version`, as before. Quiet when
|
|
9
|
+
* `$schema` is absent or names no version, and when the sheet carries
|
|
10
|
+
* both fields (the both-fields rule reports that).
|
|
11
|
+
*/
|
|
12
|
+
export declare function releaseSchemaMismatch(sheetType: SheetType): CheckFn;
|
|
13
|
+
export declare const RELEASE_SCHEMA_MISMATCH: Pick<Rule, "title" | "severity" | "target" | "messageTemplate" | "remediation">;
|
|
14
|
+
/** A sheet carrying both `format_version` and `release`. */
|
|
15
|
+
export declare const bothVersionFields: CheckFn;
|
|
16
|
+
export declare const BOTH_VERSION_FIELDS: Pick<Rule, "title" | "severity" | "target" | "messageTemplate" | "remediation">;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { sheetSpecVersionFor } from "../releases.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared checks for the envelope's version fields, used by the product
|
|
4
|
+
* and organization catalogues (PDP-E-002 / ORG-E-003, PDP-E-016 /
|
|
5
|
+
* ORG-E-002). Transcribed from commerce/spec/rules.md (normative).
|
|
6
|
+
*/
|
|
7
|
+
/** The trailing `v<version>.json` of a `$schema` URL. */
|
|
8
|
+
const SCHEMA_VERSION = /v(\d+(?:\.\d+)*)\.json$/;
|
|
9
|
+
const SHEET_LABEL = {
|
|
10
|
+
product: "Product Sheet",
|
|
11
|
+
organization: "Organization Sheet",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Release / schema mismatch. On the release line the `$schema` version
|
|
15
|
+
* segment must be the sheet-spec version the release manifest maps the
|
|
16
|
+
* declared `release` and the sheet type to; a release the manifest does
|
|
17
|
+
* not list has no mapping and the rule is silent. On the legacy line
|
|
18
|
+
* the segment must equal `format_version`, as before. Quiet when
|
|
19
|
+
* `$schema` is absent or names no version, and when the sheet carries
|
|
20
|
+
* both fields (the both-fields rule reports that).
|
|
21
|
+
*/
|
|
22
|
+
export function releaseSchemaMismatch(sheetType) {
|
|
23
|
+
return (_match, ctx) => {
|
|
24
|
+
const { release, format_version: formatVersion, $schema: schema } = ctx.sheet;
|
|
25
|
+
if (typeof schema !== "string")
|
|
26
|
+
return null;
|
|
27
|
+
const schemaVersion = SCHEMA_VERSION.exec(schema)?.[1];
|
|
28
|
+
if (schemaVersion === undefined)
|
|
29
|
+
return null;
|
|
30
|
+
if (release !== undefined && formatVersion !== undefined)
|
|
31
|
+
return null;
|
|
32
|
+
if (typeof release === "string") {
|
|
33
|
+
const expected = sheetSpecVersionFor(release, sheetType);
|
|
34
|
+
if (expected === undefined || expected === schemaVersion)
|
|
35
|
+
return null;
|
|
36
|
+
return {
|
|
37
|
+
path: "$['release']",
|
|
38
|
+
values: {
|
|
39
|
+
declared: `\`release\` \`${release}\` bundles ${SHEET_LABEL[sheetType]} spec \`${expected}\``,
|
|
40
|
+
release,
|
|
41
|
+
expected,
|
|
42
|
+
schema_version: schemaVersion,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (formatVersion !== undefined) {
|
|
47
|
+
const declared = String(formatVersion);
|
|
48
|
+
if (declared === schemaVersion)
|
|
49
|
+
return null;
|
|
50
|
+
return {
|
|
51
|
+
path: "$['format_version']",
|
|
52
|
+
values: {
|
|
53
|
+
declared: `\`format_version\` is \`${declared}\``,
|
|
54
|
+
format_version: declared,
|
|
55
|
+
schema_version: schemaVersion,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export const RELEASE_SCHEMA_MISMATCH = {
|
|
63
|
+
title: "Release / schema mismatch",
|
|
64
|
+
severity: "error",
|
|
65
|
+
target: "$",
|
|
66
|
+
messageTemplate: "{declared} but `$schema` URL declares version `{schema_version}`.",
|
|
67
|
+
remediation: "Point `$schema` at the sheet-spec version the declared release bundles (see releases.md), or declare the release that bundles the schema the sheet was written against. On a legacy sheet, align `format_version` and the `$schema` version.",
|
|
68
|
+
};
|
|
69
|
+
/** A sheet carrying both `format_version` and `release`. */
|
|
70
|
+
export const bothVersionFields = (_match, ctx) => ctx.sheet.release !== undefined && ctx.sheet.format_version !== undefined ? {} : null;
|
|
71
|
+
export const BOTH_VERSION_FIELDS = {
|
|
72
|
+
title: "Sheet carries both format_version and release",
|
|
73
|
+
severity: "error",
|
|
74
|
+
target: "$",
|
|
75
|
+
messageTemplate: "Sheet carries both `format_version` and `release`; a sheet declares one.",
|
|
76
|
+
remediation: "Keep `release` and remove `format_version`. A sheet on the legacy draft line keeps `format_version` alone and its legacy `$schema`.",
|
|
77
|
+
};
|