@pagefront/lint-commerce 0.1.1 → 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 +3 -1
- package/dist/schema-validators.d.ts +10 -0
- package/dist/schema-validators.js +7 -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
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import { lintSheet } from "./lint-sheet.js";
|
|
2
|
-
import { PRODUCT_SCHEMA } from "./product-schema.js";
|
|
3
|
-
import { ORGANIZATION_SCHEMA } from "./organization-schema.js";
|
|
4
2
|
import { detectSheetType } from "./sheet-type.js";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const Ajv2020 = Ajv2020Module.default;
|
|
11
|
-
const addFormats = addFormatsModule.default;
|
|
12
|
-
// Compiled once at module scope: pipeline consumers call
|
|
13
|
-
// validateAndLint in a loop, and schema compilation is the expensive
|
|
14
|
-
// step. `allowUnionTypes` because the product schema legitimately
|
|
15
|
-
// uses union `type` keywords.
|
|
16
|
-
const ajv = new Ajv2020({ allErrors: true, allowUnionTypes: true });
|
|
17
|
-
addFormats(ajv);
|
|
18
|
-
const validateProduct = ajv.compile(PRODUCT_SCHEMA);
|
|
19
|
-
const validateOrganization = ajv.compile(ORGANIZATION_SCHEMA);
|
|
3
|
+
import { validateProduct, validateOrganization } from "./schema-validators.js";
|
|
4
|
+
// The validators are compiled ahead of time (see schema-validators.d.ts):
|
|
5
|
+
// nothing here generates code at load time, so the pipeline runs where
|
|
6
|
+
// eval is unavailable, and consumers calling it in a loop pay no
|
|
7
|
+
// compilation cost.
|
|
20
8
|
/**
|
|
21
9
|
* Validate a parsed-but-unvalidated document against the bundled
|
|
22
10
|
* product JSON Schema (Layer 1), and — only if it passes — lint it
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// ajv ships CJS with `module.exports === exports.default`; under
|
|
3
|
-
// NodeNext the default import binding is the CJS namespace, so the
|
|
4
|
-
// class/function is reached via `.default` (identical at runtime).
|
|
5
|
-
import Ajv2020Module from "ajv/dist/2020.js";
|
|
6
|
-
import addFormatsModule from "ajv-formats";
|
|
7
|
-
const Ajv2020 = Ajv2020Module.default;
|
|
8
|
-
const addFormats = addFormatsModule.default;
|
|
9
|
-
// Compiled once at module scope, mirroring validate-and-lint.
|
|
10
|
-
const ajv = new Ajv2020({ allErrors: true, allowUnionTypes: true });
|
|
11
|
-
addFormats(ajv);
|
|
12
|
-
const validate = ajv.compile(ORGANIZATION_SCHEMA);
|
|
1
|
+
import { validateOrganization as validate } from "./schema-validators.js";
|
|
13
2
|
/**
|
|
14
3
|
* Validate a parsed-but-unvalidated document against the bundled
|
|
15
4
|
* Commerce Organization Sheet JSON Schema. The bundled schema is the
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagefront/lint-commerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pagefront commerce linter: the commerce rule catalogue and CLI, on the @pagefront/lint-core engine.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "tsc",
|
|
38
|
-
"test": "
|
|
37
|
+
"build": "tsc && node scripts/compile-validators.mjs",
|
|
38
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
39
39
|
"prepublishOnly": "npm test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|