@pagefront/lint-commerce 0.1.0 → 0.2.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 +5 -2
- package/dist/organization-schema.js +2 -2
- package/dist/product-schema.js +1 -1
- package/dist/schema-validators.d.ts +10 -0
- package/dist/schema-validators.js +7 -0
- package/dist/sheet-type.d.ts +4 -2
- package/dist/sheet-type.js +4 -0
- package/dist/validate-and-lint.js +5 -17
- package/dist/validate-organization.js +1 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -39,7 +39,9 @@ internal):
|
|
|
39
39
|
`{ layer: 1, schemaErrors: SchemaError[] }` or
|
|
40
40
|
`{ layer: 2, report: Report }`. The bundled schemas are the current
|
|
41
41
|
format version; a document declaring another `format_version` fails
|
|
42
|
-
Layer 1 by design.
|
|
42
|
+
Layer 1 by design. Layer 1 runs validators compiled ahead of time at
|
|
43
|
+
package build, so the pipeline needs no runtime code generation and
|
|
44
|
+
runs under Cloudflare Workers and strict Content Security Policies.
|
|
43
45
|
- `lintSheet(sheet: Sheet, options?: LintOptions): Report` — Layer 2
|
|
44
46
|
only, for input you have already schema-validated. Dispatches to the
|
|
45
47
|
page type's catalogue the same way.
|
|
@@ -48,7 +50,8 @@ internal):
|
|
|
48
50
|
`{ valid: true }` or `{ valid: false, schemaErrors: SchemaError[] }`.
|
|
49
51
|
- `detectSheetType(sheet: Sheet): SheetType` — the page-type dispatch:
|
|
50
52
|
`"organization"` when the envelope `$schema` path contains
|
|
51
|
-
`/
|
|
53
|
+
`/spec/commerce/organization/` or `/schemas/organization/` (a
|
|
54
|
+
`/spec/commerce/product/` or `/schemas/product/` path likewise wins
|
|
52
55
|
for `"product"`), falling back to a data block whose `@type` is
|
|
53
56
|
`Organization`/`OnlineStore`/`OnlineBusiness` with
|
|
54
57
|
`pagefront:commerceRole` present; `"product"` otherwise.
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const ORGANIZATION_SCHEMA = {
|
|
10
10
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
11
|
-
"$id": "https://themachineweb.org/pagefront/commerce/
|
|
11
|
+
"$id": "https://themachineweb.org/pagefront/spec/commerce/organization/v0.9.json",
|
|
12
12
|
"title": "Pagefront Commerce Organization Sheet v0.9",
|
|
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
|
|
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.",
|
|
14
14
|
"type": "object",
|
|
15
15
|
"required": [
|
|
16
16
|
"format_version",
|
package/dist/product-schema.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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/commerce/
|
|
11
|
+
"$id": "https://themachineweb.org/pagefront/spec/commerce/product/v0.9.json",
|
|
12
12
|
"title": "Pagefront Product Sheet v0.9",
|
|
13
13
|
"description": "Formal schema for the Pagefront product sheet. v0.9 is 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",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Layer 1 validators, compiled ahead of time from the bundled
|
|
3
|
+
* schemas by scripts/compile-validators.mjs into dist/schema-validators.js
|
|
4
|
+
* (the second half of `npm run build`). This declaration is the module's
|
|
5
|
+
* type; the script copies it beside the generated file.
|
|
6
|
+
*/
|
|
7
|
+
import type { ValidateFunction } from "ajv";
|
|
8
|
+
|
|
9
|
+
export const validateProduct: ValidateFunction;
|
|
10
|
+
export const validateOrganization: ValidateFunction;
|