@jasonbelmonti/markdown-engine 3.0.0 → 3.1.1
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/CHANGELOG.md +28 -0
- package/README.md +77 -8
- package/dist/api/contracts.d.ts +2 -1
- package/dist/api/contracts.d.ts.map +1 -1
- package/dist/api/contracts.js +1 -0
- package/dist/api/contracts.js.map +1 -1
- package/dist/api/declarative-validation.d.ts +1 -1
- package/dist/api/declarative-validation.d.ts.map +1 -1
- package/dist/api/declarative-validation.js.map +1 -1
- package/dist/api/document-set-validation-types.d.ts +32 -0
- package/dist/api/document-set-validation-types.d.ts.map +1 -0
- package/dist/api/document-set-validation-types.js +2 -0
- package/dist/api/document-set-validation-types.js.map +1 -0
- package/dist/api/document-set-validation.d.ts +4 -0
- package/dist/api/document-set-validation.d.ts.map +1 -0
- package/dist/api/document-set-validation.js +60 -0
- package/dist/api/document-set-validation.js.map +1 -0
- package/dist/api/serialize.d.ts +2 -1
- package/dist/api/serialize.d.ts.map +1 -1
- package/dist/api/serialize.js.map +1 -1
- package/dist/declarative-validation/assertions/evaluator.d.ts.map +1 -1
- package/dist/declarative-validation/assertions/evaluator.js +6 -0
- package/dist/declarative-validation/assertions/evaluator.js.map +1 -1
- package/dist/declarative-validation/assertions/frontmatter-shape.d.ts +9 -0
- package/dist/declarative-validation/assertions/frontmatter-shape.d.ts.map +1 -0
- package/dist/declarative-validation/assertions/frontmatter-shape.js +105 -0
- package/dist/declarative-validation/assertions/frontmatter-shape.js.map +1 -0
- package/dist/declarative-validation/assertions/text-format.d.ts +9 -0
- package/dist/declarative-validation/assertions/text-format.d.ts.map +1 -0
- package/dist/declarative-validation/assertions/text-format.js +75 -0
- package/dist/declarative-validation/assertions/text-format.js.map +1 -0
- package/dist/declarative-validation/compiler/assertion-builders.d.ts.map +1 -1
- package/dist/declarative-validation/compiler/assertion-builders.js +38 -1
- package/dist/declarative-validation/compiler/assertion-builders.js.map +1 -1
- package/dist/declarative-validation/compiler/assertion-shapes.d.ts +3 -1
- package/dist/declarative-validation/compiler/assertion-shapes.d.ts.map +1 -1
- package/dist/declarative-validation/compiler/assertion-shapes.js +30 -0
- package/dist/declarative-validation/compiler/assertion-shapes.js.map +1 -1
- package/dist/declarative-validation/compiler/assertions.d.ts.map +1 -1
- package/dist/declarative-validation/compiler/assertions.js +2 -0
- package/dist/declarative-validation/compiler/assertions.js.map +1 -1
- package/dist/declarative-validation/compiler/compatibility.d.ts.map +1 -1
- package/dist/declarative-validation/compiler/compatibility.js +2 -0
- package/dist/declarative-validation/compiler/compatibility.js.map +1 -1
- package/dist/declarative-validation/compiler/plan.d.ts +8 -1
- package/dist/declarative-validation/compiler/plan.d.ts.map +1 -1
- package/dist/declarative-validation/evidence/index.d.ts.map +1 -1
- package/dist/declarative-validation/evidence/index.js +2 -1
- package/dist/declarative-validation/evidence/index.js.map +1 -1
- package/dist/declarative-validation/profile/assertion-schema.d.ts.map +1 -1
- package/dist/declarative-validation/profile/assertion-schema.js +48 -3
- package/dist/declarative-validation/profile/assertion-schema.js.map +1 -1
- package/dist/declarative-validation/profile/frontmatter-shape-schema.d.ts +8 -0
- package/dist/declarative-validation/profile/frontmatter-shape-schema.d.ts.map +1 -0
- package/dist/declarative-validation/profile/frontmatter-shape-schema.js +178 -0
- package/dist/declarative-validation/profile/frontmatter-shape-schema.js.map +1 -0
- package/dist/declarative-validation/profile/index.d.ts +21 -0
- package/dist/declarative-validation/profile/index.d.ts.map +1 -1
- package/dist/declarative-validation/profile/text-format-contract.d.ts +4 -0
- package/dist/declarative-validation/profile/text-format-contract.d.ts.map +1 -0
- package/dist/declarative-validation/profile/text-format-contract.js +6 -0
- package/dist/declarative-validation/profile/text-format-contract.js.map +1 -0
- package/dist/internal/package-version.d.ts +2 -0
- package/dist/internal/package-version.d.ts.map +1 -0
- package/dist/internal/package-version.js +2 -0
- package/dist/internal/package-version.js.map +1 -0
- package/dist-bundled/markdown-engine-cli.mjs +556 -6
- package/docs/contracts/api.md +60 -0
- package/docs/contracts/declarative-validation.md +161 -22
- package/fixtures/declarative-validation/examples/okf-v0.1/fail/invalid-log-date/log.md +5 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/fail/missing-concept-type/concepts/customer-metric.md +8 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/fail/non-root-index-frontmatter/datasets/index.md +7 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/pass/datasets/index.md +3 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/pass/datasets/sales.md +16 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/pass/index.md +8 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/pass/log.md +9 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/pass/playbooks/incident-response.md +17 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/profiles/concept.yaml +14 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/profiles/log.yaml +10 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/profiles/non-root-index.yaml +9 -0
- package/fixtures/declarative-validation/examples/okf-v0.1/profiles/root-index.yaml +12 -0
- package/package.json +3 -2
- package/scripts/install-markdown-engine-cli.sh +113 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,34 @@
|
|
|
4
4
|
|
|
5
5
|
No unreleased changes.
|
|
6
6
|
|
|
7
|
+
## 3.1.1 - 2026-07-03
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Corrected the constrained-harness installer pin to use the 3.1.1 bundled CLI
|
|
12
|
+
package version and artifact hash.
|
|
13
|
+
- Corrected declarative validation evidence so `engineVersion` records the
|
|
14
|
+
package version that produced the JSON.
|
|
15
|
+
|
|
16
|
+
## 3.1.0 - 2026-07-03
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Added `validateDocumentSet(...)` as a public API for validating multiple
|
|
21
|
+
Markdown documents with declarative validation profiles.
|
|
22
|
+
- Added Declarative Validation V2 support for `frontmatterShape` and
|
|
23
|
+
`textFormat: isoDate` across profile schema validation, compiler contracts,
|
|
24
|
+
runtime evaluation, API contracts, and fixtures.
|
|
25
|
+
- Added OKF profile examples, role-profile fixtures, document-set proof tests,
|
|
26
|
+
and release-readiness evidence for profile-backed validation workflows.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Expanded the GitHub Pages consumer site and docs with conditional validation,
|
|
31
|
+
OKF profile composition, repair-loop, and policy-validation guidance.
|
|
32
|
+
- Made the standalone CLI installer provider-neutral and removed its runtime
|
|
33
|
+
dependency on `npx markdown-engine`.
|
|
34
|
+
|
|
7
35
|
## 3.0.0 - 2026-06-05
|
|
8
36
|
|
|
9
37
|
### Added
|
package/README.md
CHANGED
|
@@ -6,13 +6,15 @@ profile and runtime work.
|
|
|
6
6
|
Package release state:
|
|
7
7
|
|
|
8
8
|
- package name: `@jasonbelmonti/markdown-engine`
|
|
9
|
-
- package metadata version: `3.
|
|
10
|
-
- published npm versions before this release: `0.1.0`, `1.0.0`, `2.0.0
|
|
11
|
-
|
|
9
|
+
- package metadata version: `3.1.1`
|
|
10
|
+
- published npm versions before this release: `0.1.0`, `1.0.0`, `2.0.0`,
|
|
11
|
+
`3.0.0`, `3.1.0`
|
|
12
|
+
- npm release target: `3.1.1` on `latest`
|
|
12
13
|
- website: <https://jasonbelmonti.github.io/markdown-engine/>
|
|
13
|
-
- release focus:
|
|
14
|
-
|
|
15
|
-
default API and
|
|
14
|
+
- release focus: document-set validation, V2 `frontmatterShape` and
|
|
15
|
+
`textFormat: isoDate` support, and OKF profile examples while retaining the
|
|
16
|
+
existing `documentVersion: "1.0.0"` rich IR contract as the default API and
|
|
17
|
+
CLI document shape
|
|
16
18
|
- maintainer documentation map: [docs/README.md](docs/README.md)
|
|
17
19
|
- design reference:
|
|
18
20
|
[Markdown Engine 1.0 Rich IR design](docs/design/markdown-engine-1.0-rich-ir-operational-design-spec.md)
|
|
@@ -43,6 +45,7 @@ The package root exports:
|
|
|
43
45
|
- `validateAnnotations(document, annotations)`
|
|
44
46
|
- `parseValidationProfile(input, options?)`
|
|
45
47
|
- `validateWithProfile(document, profile, options?)`
|
|
48
|
+
- `validateDocumentSet(entries, options?)`
|
|
46
49
|
|
|
47
50
|
Example:
|
|
48
51
|
|
|
@@ -83,7 +86,7 @@ console.log(validationResult.valid);
|
|
|
83
86
|
console.log(serialize(validationResult, { pretty: true }));
|
|
84
87
|
```
|
|
85
88
|
|
|
86
|
-
Package 3.
|
|
89
|
+
Package 3.1 retains the serialized document contract at
|
|
87
90
|
`documentVersion: "1.0.0"` and makes that rich IR path the default for
|
|
88
91
|
`normalize(parsed)`. Callers may still pass
|
|
89
92
|
`normalize(parsed, { documentVersion: "1.0.0" })` explicitly. That path adds
|
|
@@ -202,7 +205,72 @@ node dist/cli/index.js validate --file fixtures/declarative-validation/examples/
|
|
|
202
205
|
The passing example exits `0`; the failing example exits `1` and prints JSON
|
|
203
206
|
diagnostics for review.
|
|
204
207
|
|
|
205
|
-
|
|
208
|
+
### OKF v0.1 example composition
|
|
209
|
+
|
|
210
|
+
The packaged OKF v0.1 examples show how callers can compose generic
|
|
211
|
+
declarative-validation primitives without making `markdown-engine` an OKF
|
|
212
|
+
adapter. The example profiles use `frontmatterShape` for role-specific
|
|
213
|
+
frontmatter checks, `textFormat` for `log.md` date headings, and
|
|
214
|
+
`validateDocumentSet` to aggregate caller-supplied Markdown/profile pairs.
|
|
215
|
+
|
|
216
|
+
The caller remains responsible for caller-owned path classification, bundle
|
|
217
|
+
traversal, IO, and profile selection. A caller-owned router should classify
|
|
218
|
+
non-reserved concept documents separately from reserved files:
|
|
219
|
+
|
|
220
|
+
- concept documents use `profiles/concept.yaml`, where `frontmatterShape`
|
|
221
|
+
requires a non-empty string `type`
|
|
222
|
+
- the bundle-root `index.md` uses `profiles/root-index.yaml`, which permits the
|
|
223
|
+
OKF version exception `okf_version: "0.1"`
|
|
224
|
+
- non-root `index.md` files use `profiles/non-root-index.yaml`, where
|
|
225
|
+
frontmatter is forbidden
|
|
226
|
+
- `log.md` uses `profiles/log.yaml`, where `textFormat` validates level-2 date
|
|
227
|
+
headings as real `YYYY-MM-DD` calendar dates
|
|
228
|
+
|
|
229
|
+
This package does not discover bundles, classify OKF paths, route roles for
|
|
230
|
+
callers, reject unknown concept types, check links, require optional
|
|
231
|
+
`index.md` files, or publish an OKF CLI.
|
|
232
|
+
|
|
233
|
+
### Bundled CLI install for constrained agent harnesses
|
|
234
|
+
|
|
235
|
+
The package ships a single-file bundled CLI at
|
|
236
|
+
`dist-bundled/markdown-engine-cli.mjs`. Agent harnesses that forbid random
|
|
237
|
+
runtime package execution should install this artifact once and run it through a
|
|
238
|
+
local wrapper instead of using `npx`:
|
|
239
|
+
|
|
240
|
+
```sh
|
|
241
|
+
scripts/install-markdown-engine-cli.sh
|
|
242
|
+
export PATH="${MARKDOWN_ENGINE_BIN_DIR:-$HOME/.local/bin}:$PATH"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
From a project root where the package is installed as a dependency, invoke the
|
|
246
|
+
packaged installer directly:
|
|
247
|
+
|
|
248
|
+
```sh
|
|
249
|
+
node_modules/@jasonbelmonti/markdown-engine/scripts/install-markdown-engine-cli.sh
|
|
250
|
+
export PATH="${MARKDOWN_ENGINE_BIN_DIR:-$HOME/.local/bin}:$PATH"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
By default, the installer places the CLI under
|
|
254
|
+
`${MARKDOWN_ENGINE_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/markdown-engine}`
|
|
255
|
+
and writes the wrapper to
|
|
256
|
+
`${MARKDOWN_ENGINE_BIN_DIR:-$HOME/.local/bin}/markdown-engine`. The installer
|
|
257
|
+
uses a local bundled artifact only when it matches the pinned artifact hash.
|
|
258
|
+
Otherwise it downloads `@jasonbelmonti/markdown-engine@3.1.1` with `npm pack
|
|
259
|
+
--ignore-scripts` and extracts only
|
|
260
|
+
`package/dist-bundled/markdown-engine-cli.mjs` from the tarball. It verifies the
|
|
261
|
+
pinned artifact hash before installing:
|
|
262
|
+
|
|
263
|
+
```text
|
|
264
|
+
8c7ff572765cbdc6c38b94de52d69709f583ee7b4d2b7e25ba6be8c92125addf
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
The installed wrapper is:
|
|
268
|
+
|
|
269
|
+
```sh
|
|
270
|
+
"${MARKDOWN_ENGINE_BIN_DIR:-$HOME/.local/bin}/markdown-engine" validate --file <file.md> --profile <profile.yaml> --format json
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Package 3.1 keeps the 2.0 API normalization default: callers that invoke
|
|
206
274
|
`normalize(parsed)` receive the rich IR `1.0.0` document shape. Consumers that
|
|
207
275
|
still need the legacy `0.0.0` shape should consume the rich IR fields
|
|
208
276
|
(`target`, `sections`, `textSpans`, `tables`, `lists`, and `links`) or pin
|
|
@@ -248,6 +316,7 @@ currently check these evidence records:
|
|
|
248
316
|
- [Rich IR contract documentation gate](docs/evidence/wp-5-evd-6-rich-ir-contract.md)
|
|
249
317
|
- [Declarative validation contract review](docs/evidence/wp-5-evd-7-declarative-validation-contract-review.md)
|
|
250
318
|
- [Declarative validation boundary audit](docs/evidence/wp-5-evd-8-declarative-validation-boundary-audit.md)
|
|
319
|
+
- [OKF validation seal evidence](docs/evidence/bel-1332-okf-release-readiness.md)
|
|
251
320
|
|
|
252
321
|
Snapshot baseline updates are operational changes, not routine test-output
|
|
253
322
|
cleanup. Use the [testing and snapshot operations](docs/testing.md) guide before
|
package/dist/api/contracts.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export type MarkdownEngineApiName = "parse" | "normalize" | "validate" | "serialize" | "documentQueries" | "validateAnnotations" | "parseValidationProfile" | "validateWithProfile";
|
|
1
|
+
export type MarkdownEngineApiName = "parse" | "normalize" | "validate" | "serialize" | "documentQueries" | "validateAnnotations" | "parseValidationProfile" | "validateWithProfile" | "validateDocumentSet";
|
|
2
2
|
export * from "./annotations.js";
|
|
3
3
|
export * from "./declarative-validation.js";
|
|
4
|
+
export * from "./document-set-validation.js";
|
|
4
5
|
export * from "./diagnostics.js";
|
|
5
6
|
export * from "./document.js";
|
|
6
7
|
export * from "./document-queries.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,qBAAqB,GACrB,wBAAwB,GACxB,qBAAqB,CAAC;AAE1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,qBAAqB,GACrB,wBAAwB,GACxB,qBAAqB,GACrB,qBAAqB,CAAC;AAE1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/dist/api/contracts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"AAWA,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EngineDocument } from "./document.js";
|
|
2
2
|
import type { DeclarativeProfileParseOptions, DeclarativeProfileParseResult, JsonSafeValue, ValidationProfile } from "../declarative-validation/profile/index.js";
|
|
3
3
|
import type { DeclarativeValidationOptions, DeclarativeValidationResult } from "../declarative-validation/results/index.js";
|
|
4
|
-
export type { DeclarativeAssertion, DeclarativeValidationApplicability, DeclarativeValidationAllOfRule, DeclarativeValidationAnyOfRule, DeclarativeValidationBranch, DeclarativeValidationFlatRule, DeclarativeValidationGroupRule, DeclarativeValidationRuleFields, DeclarativeIdSource, DeclarativeOutputFormat, DeclarativeProfileParseOptions, DeclarativeProfileParseResult, DeclarativeSectionOrder, DeclarativeSelector, DeclarativeTableCellPredicate, DeclarativeTableColumnCoverage, DeclarativeTableColumnCoverageSource, DeclarativeTableColumnCoverageTarget, DeclarativeValidationRule, DeclarativeValidationSeverity, JsonSafeValue, ValidationProfile, } from "../declarative-validation/profile/index.js";
|
|
4
|
+
export type { DeclarativeAssertion, DeclarativeValidationApplicability, DeclarativeValidationAllOfRule, DeclarativeValidationAnyOfRule, DeclarativeValidationBranch, DeclarativeValidationFlatRule, DeclarativeFrontmatterFieldShape, DeclarativeFrontmatterPresence, DeclarativeFrontmatterShape, DeclarativeFrontmatterValueType, DeclarativeValidationGroupRule, DeclarativeValidationRuleFields, DeclarativeIdSource, DeclarativeOutputFormat, DeclarativeProfileParseOptions, DeclarativeProfileParseResult, DeclarativeSectionOrder, DeclarativeSelector, DeclarativeTableCellPredicate, DeclarativeTableColumnCoverage, DeclarativeTableColumnCoverageSource, DeclarativeTableColumnCoverageTarget, DeclarativeValidationRule, DeclarativeValidationSeverity, JsonSafeValue, ValidationProfile, } from "../declarative-validation/profile/index.js";
|
|
5
5
|
export type { DeclarativeValidationEvidence } from "../declarative-validation/evidence/index.js";
|
|
6
6
|
export type { DeclarativeValidationAllOfEvaluationResult, DeclarativeValidationAnyOfEvaluationResult, DeclarativeValidationApplicabilityResult, DeclarativeValidationAssertionsEvaluationResult, DeclarativeValidationBranchReference, DeclarativeValidationBranchResult, DeclarativeValidationCliJsonResult, DeclarativeValidationConfigErrorResult, DeclarativeValidationOptions, DeclarativeValidationResultV1, DeclarativeValidationResultV2, DeclarativeValidationRuleEvaluationResult, DeclarativeValidationRuleResultV2, DeclarativeValidationRuleStatus, DeclarativeValidationSkippedEvaluationResult, DeclarativeValidationResult, } from "../declarative-validation/results/index.js";
|
|
7
7
|
export interface DeclarativeValidationApi {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarative-validation.d.ts","sourceRoot":"","sources":["../../src/api/declarative-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkBpD,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,EAClB,MAAM,4CAA4C,CAAC;AAKpD,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,4CAA4C,CAAC;AAGpD,YAAY,EACV,oBAAoB,EACpB,kCAAkC,EAClC,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,EACvB,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,oCAAoC,EACpC,yBAAyB,EACzB,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,YAAY,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AACjG,YAAY,EACV,0CAA0C,EAC1C,0CAA0C,EAC1C,wCAAwC,EACxC,+CAA+C,EAC/C,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,sCAAsC,EACtC,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,yCAAyC,EACzC,iCAAiC,EACjC,+BAA+B,EAC/B,4CAA4C,EAC5C,2BAA2B,GAC5B,MAAM,4CAA4C,CAAC;AAEpD,MAAM,WAAW,wBAAwB;IACvC,sBAAsB,CACpB,KAAK,EAAE,MAAM,GAAG,aAAa,EAC7B,OAAO,CAAC,EAAE,8BAA8B,GACvC,6BAA6B,CAAC;IACjC,mBAAmB,CACjB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,4BAA4B,GACrC,2BAA2B,CAAC;CAChC;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,GAAG,aAAa,EAC7B,OAAO,GAAE,8BAAmC,GAC3C,6BAA6B,CAE/B;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CAgD7B"}
|
|
1
|
+
{"version":3,"file":"declarative-validation.d.ts","sourceRoot":"","sources":["../../src/api/declarative-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkBpD,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,EAClB,MAAM,4CAA4C,CAAC;A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Q,EAAE,cAAc,EACxB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CAgD7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarative-validation.js","sourceRoot":"","sources":["../../src/api/declarative-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4CAA4C,EAAE,MAAM,kDAAkD,CAAC;AAChH,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAMvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AAOpG,OAAO,EACL,iCAAiC,EACjC,4CAA4C,GAC7C,MAAM,4CAA4C,CAAC;AAKpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"declarative-validation.js","sourceRoot":"","sources":["../../src/api/declarative-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4CAA4C,EAAE,MAAM,kDAAkD,CAAC;AAChH,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAMvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AAOpG,OAAO,EACL,iCAAiC,EACjC,4CAA4C,GAC7C,MAAM,4CAA4C,CAAC;AAKpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AA8D1F,MAAM,UAAU,sBAAsB,CACpC,KAA6B,EAC7B,UAA0C,EAAE;IAE5C,OAAO,2BA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SAAS,mBAAmB,CAC1B,IAAuC;IAEvC,OAAO,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;AACjD,CAAC;AAED,SAAS,iCAAiC,CACxC,sBAAiD,EACjD,eAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE,4BAA4B,sBAAsB,sCAAsC,eAAe,IAAI;QACpH,QAAQ,EAAE,OAAgB;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DeclarativeValidationOptions, DeclarativeValidationResult, JsonSafeValue, ValidationProfile } from "./declarative-validation.js";
|
|
2
|
+
import type { MarkdownDiagnostic } from "./diagnostics.js";
|
|
3
|
+
import type { NormalizeOptions } from "./normalize.js";
|
|
4
|
+
export type ValidateDocumentSetProfileInput = string | JsonSafeValue | ValidationProfile;
|
|
5
|
+
export interface ValidateDocumentSetEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
markdown: string;
|
|
8
|
+
profile: ValidateDocumentSetProfileInput;
|
|
9
|
+
profilePath?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ValidateDocumentSetOptions {
|
|
12
|
+
documentVersion?: NormalizeOptions["documentVersion"];
|
|
13
|
+
preserveSourceLocations?: NormalizeOptions["preserveSourceLocations"];
|
|
14
|
+
includeEvidence?: DeclarativeValidationOptions["includeEvidence"];
|
|
15
|
+
}
|
|
16
|
+
export interface ValidateDocumentSetEntryResult {
|
|
17
|
+
path: string;
|
|
18
|
+
profilePath?: string;
|
|
19
|
+
diagnostics: MarkdownDiagnostic[];
|
|
20
|
+
parseDiagnostics: MarkdownDiagnostic[];
|
|
21
|
+
normalizationDiagnostics: MarkdownDiagnostic[];
|
|
22
|
+
profileDiagnostics: MarkdownDiagnostic[];
|
|
23
|
+
validationDiagnostics: MarkdownDiagnostic[];
|
|
24
|
+
validationResult?: DeclarativeValidationResult;
|
|
25
|
+
}
|
|
26
|
+
export interface ValidateDocumentSetResult {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
diagnostics: MarkdownDiagnostic[];
|
|
29
|
+
entries: ValidateDocumentSetEntryResult[];
|
|
30
|
+
}
|
|
31
|
+
export type ValidateDocumentSetFunction = (entries: readonly ValidateDocumentSetEntry[], options?: ValidateDocumentSetOptions) => ValidateDocumentSetResult;
|
|
32
|
+
//# sourceMappingURL=document-set-validation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-set-validation-types.d.ts","sourceRoot":"","sources":["../../src/api/document-set-validation-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,aAAa,EACb,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,+BAA+B,GACvC,MAAM,GACN,aAAa,GACb,iBAAiB,CAAC;AAEtB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,+BAA+B,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACtD,uBAAuB,CAAC,EAAE,gBAAgB,CAAC,yBAAyB,CAAC,CAAC;IACtE,eAAe,CAAC,EAAE,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,gBAAgB,EAAE,kBAAkB,EAAE,CAAC;IACvC,wBAAwB,EAAE,kBAAkB,EAAE,CAAC;IAC/C,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;IACzC,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;IAC5C,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;CAChD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,OAAO,EAAE,8BAA8B,EAAE,CAAC;CAC3C;AAED,MAAM,MAAM,2BAA2B,GAAG,CACxC,OAAO,EAAE,SAAS,wBAAwB,EAAE,EAC5C,OAAO,CAAC,EAAE,0BAA0B,KACjC,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-set-validation-types.js","sourceRoot":"","sources":["../../src/api/document-set-validation-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ValidateDocumentSetFunction } from "./document-set-validation-types.js";
|
|
2
|
+
export type { ValidateDocumentSetEntry, ValidateDocumentSetEntryResult, ValidateDocumentSetFunction, ValidateDocumentSetOptions, ValidateDocumentSetProfileInput, ValidateDocumentSetResult, } from "./document-set-validation-types.js";
|
|
3
|
+
export declare const validateDocumentSet: ValidateDocumentSetFunction;
|
|
4
|
+
//# sourceMappingURL=document-set-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-set-validation.d.ts","sourceRoot":"","sources":["../../src/api/document-set-validation.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAGV,2BAA2B,EAG5B,MAAM,oCAAoC,CAAC;AAG5C,YAAY,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAE5C,eAAO,MAAM,mBAAmB,EAAE,2BAgBjC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { parseValidationProfile, validateWithProfile, } from "./declarative-validation.js";
|
|
2
|
+
import { normalize } from "./normalize.js";
|
|
3
|
+
import { parse } from "./parse.js";
|
|
4
|
+
import { cloneDiagnostics, hasErrorDiagnostic } from "../diagnostics/index.js";
|
|
5
|
+
export const validateDocumentSet = (entries, options = {}) => {
|
|
6
|
+
const entryResults = entries.map((entry) => validateDocumentSetEntry(entry, options));
|
|
7
|
+
const diagnostics = cloneDiagnostics(entryResults.flatMap((entry) => entry.diagnostics));
|
|
8
|
+
return {
|
|
9
|
+
valid: !hasErrorDiagnostic(diagnostics),
|
|
10
|
+
diagnostics,
|
|
11
|
+
entries: entryResults,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
function validateDocumentSetEntry(entry, options) {
|
|
15
|
+
const parseResult = parse(entry.markdown, { path: entry.path });
|
|
16
|
+
const normalizeResult = normalize(parseResult.parsed, normalizeOptions(options));
|
|
17
|
+
const profileResult = parseValidationProfile(profileParserInput(entry.profile), {
|
|
18
|
+
...(entry.profilePath !== undefined ? { path: entry.profilePath } : {}),
|
|
19
|
+
});
|
|
20
|
+
let validationResult;
|
|
21
|
+
if (profileResult.profile !== undefined &&
|
|
22
|
+
!hasErrorDiagnostic(profileResult.diagnostics)) {
|
|
23
|
+
validationResult = validateWithProfile(normalizeResult.document, profileResult.profile, {
|
|
24
|
+
path: entry.path,
|
|
25
|
+
...(options.includeEvidence !== undefined
|
|
26
|
+
? { includeEvidence: options.includeEvidence }
|
|
27
|
+
: {}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const validationDiagnostics = validationResult === undefined ? [] : validationResult.diagnostics;
|
|
31
|
+
const diagnostics = cloneDiagnostics([
|
|
32
|
+
...normalizeResult.diagnostics,
|
|
33
|
+
...profileResult.diagnostics,
|
|
34
|
+
...validationDiagnostics,
|
|
35
|
+
]);
|
|
36
|
+
return {
|
|
37
|
+
path: entry.path,
|
|
38
|
+
...(entry.profilePath !== undefined ? { profilePath: entry.profilePath } : {}),
|
|
39
|
+
diagnostics,
|
|
40
|
+
parseDiagnostics: cloneDiagnostics(parseResult.diagnostics),
|
|
41
|
+
normalizationDiagnostics: cloneDiagnostics(normalizeResult.diagnostics),
|
|
42
|
+
profileDiagnostics: cloneDiagnostics(profileResult.diagnostics),
|
|
43
|
+
validationDiagnostics: cloneDiagnostics(validationDiagnostics),
|
|
44
|
+
...(validationResult !== undefined ? { validationResult } : {}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function normalizeOptions(options) {
|
|
48
|
+
return {
|
|
49
|
+
...(options.documentVersion !== undefined
|
|
50
|
+
? { documentVersion: options.documentVersion }
|
|
51
|
+
: {}),
|
|
52
|
+
...(options.preserveSourceLocations !== undefined
|
|
53
|
+
? { preserveSourceLocations: options.preserveSourceLocations }
|
|
54
|
+
: {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function profileParserInput(input) {
|
|
58
|
+
return input;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=document-set-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-set-validation.js","sourceRoot":"","sources":["../../src/api/document-set-validation.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAQnC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW/E,MAAM,CAAC,MAAM,mBAAmB,GAAgC,CAC9D,OAAO,EACP,OAAO,GAAG,EAAE,EACZ,EAAE;IACF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACzC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CACzC,CAAC;IACF,MAAM,WAAW,GAAG,gBAA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atibilityMode } from "./compatibility.js";
|
|
2
|
+
import type { ValidateDocumentSetResult } from "./document-set-validation-types.js";
|
|
2
3
|
import type { SerializableEngineResult } from "./document.js";
|
|
3
4
|
import type { NormalizeResult } from "./normalize.js";
|
|
4
5
|
import type { ParseResult } from "./parse.js";
|
|
5
6
|
import type { ValidationResult } from "./validate.js";
|
|
6
|
-
export type SerializableMarkdownEngineResult = ParseResult | NormalizeResult | ValidationResult | SerializableEngineResult;
|
|
7
|
+
export type SerializableMarkdownEngineResult = ParseResult | NormalizeResult | ValidateDocumentSetResult | ValidationResult | SerializableEngineResult;
|
|
7
8
|
export { EngineCompatibilityError, type EngineCompatibilityMode, } from "./compatibility.js";
|
|
8
9
|
export interface SerializeOptions {
|
|
9
10
|
pretty?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,gCAAgC,GACxC,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,wBAAwB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;CAC7C;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,gCAAgC,EACxC,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,CAAC;AAEZ,eAAO,MAAM,SAAS,EAAE,iBAYvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,gCAAgC,GACxC,WAAW,GACX,eAAe,GACf,yBAAyB,GACzB,gBAAgB,GAChB,wBAAwB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;CAC7C;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,gCAAgC,EACxC,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,CAAC;AAEZ,eAAO,MAAM,SAAS,EAAE,iBAYvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAStE,OAAO,EACL,wBAAwB,GAEzB,MAAM,oBAAoB,CAAC;AAY5B,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IACnE,IAAI,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC5C,6BAA6B,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAC/B,wBAAwB,CAAC,MAAM,CAAC,EAChC,IAAI,EACJ,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAChC,CAAC;IAEF,OAAO,UAAU,IAAI,MAAM,CAAC;AAC9B,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../src/declarative-validation/assertions/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAEV,2CAA2C,EAC5C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../src/declarative-validation/assertions/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAEV,2CAA2C,EAC5C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAiBlE,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,2CAA2C,EACjD,SAAS,EAAE,oBAAoB,GAC9B,oBAAoB,CAgBtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { evaluateExists } from "./exists.js";
|
|
2
|
+
import { evaluateFrontmatterShape } from "./frontmatter-shape.js";
|
|
2
3
|
import { evaluateFrontmatterRequired } from "./frontmatter-required.js";
|
|
3
4
|
import { evaluateIds } from "./ids.js";
|
|
4
5
|
import { sortAssertionDiagnostics } from "./ordering.js";
|
|
@@ -7,6 +8,7 @@ import { evaluateSectionsRequired } from "./sections-required.js";
|
|
|
7
8
|
import { evaluateTableColumnCoverage } from "./table-column-coverage.js";
|
|
8
9
|
import { evaluateTableColumnsRequired } from "./table-columns-required.js";
|
|
9
10
|
import { evaluateText } from "./text.js";
|
|
11
|
+
import { evaluateTextFormat } from "./text-format.js";
|
|
10
12
|
import { evaluateTextLength } from "./text-length.js";
|
|
11
13
|
import { evaluateTextOccurrenceCount } from "./text-occurrence-count.js";
|
|
12
14
|
export function evaluateCompiledDeclarativeRule(rule, selection) {
|
|
@@ -34,6 +36,8 @@ function evaluateAssertion(assertion, context) {
|
|
|
34
36
|
return evaluateTextOccurrenceCount(assertion, context);
|
|
35
37
|
case "textLength":
|
|
36
38
|
return evaluateTextLength(assertion, context);
|
|
39
|
+
case "textFormat":
|
|
40
|
+
return evaluateTextFormat(assertion, context);
|
|
37
41
|
case "frontmatterRequired":
|
|
38
42
|
return evaluateFrontmatterRequired(assertion, context);
|
|
39
43
|
case "tableColumnsRequired":
|
|
@@ -44,6 +48,8 @@ function evaluateAssertion(assertion, context) {
|
|
|
44
48
|
return evaluateReferences(assertion, context);
|
|
45
49
|
case "tableColumnCoverage":
|
|
46
50
|
return evaluateTableColumnCoverage(assertion, context);
|
|
51
|
+
case "frontmatterShape":
|
|
52
|
+
return evaluateFrontmatterShape(assertion, context);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
//# sourceMappingURL=evaluator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../src/declarative-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BAAsB;YACzB,OAAO,4BAA4B,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE1D,KAAK,KAAK;YACR,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEzC,KAAK,YAAY;YACf,OAAO,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEhD,KAAK,qBAAqB;YACxB,OAAO,2BAA2B,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEzD,KAAK,kBAAkB;YACrB,OAAO,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CompiledDeclarativeAssertion } from "../compiler/plan.js";
|
|
2
|
+
import type { AssertionEvaluationContext } from "./context.js";
|
|
3
|
+
import type { AssertionDiagnostic } from "./diagnostics.js";
|
|
4
|
+
type FrontmatterShapeAssertion = Extract<CompiledDeclarativeAssertion, {
|
|
5
|
+
kind: "frontmatterShape";
|
|
6
|
+
}>;
|
|
7
|
+
export declare function evaluateFrontmatterShape(assertion: FrontmatterShapeAssertion, context: AssertionEvaluationContext): AssertionDiagnostic[];
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=frontmatter-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-shape.d.ts","sourceRoot":"","sources":["../../../src/declarative-validation/assertions/frontmatter-shape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,KAAK,yBAAyB,GAAG,OAAO,CACtC,4BAA4B,EAC5B;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAC7B,CAAC;AAMF,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,yBAAyB,EACpC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,EAAE,CAiCvB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { hasOwnProperty, isPlainRecord } from "../../internal/plain-record.js";
|
|
2
|
+
import { validationDiagnostic } from "./diagnostics.js";
|
|
3
|
+
export function evaluateFrontmatterShape(assertion, context) {
|
|
4
|
+
const frontmatter = context.selection.document.frontmatter;
|
|
5
|
+
const diagnostics = [];
|
|
6
|
+
if (assertion.presence === "required" && frontmatter === undefined) {
|
|
7
|
+
diagnostics.push(requiredFrontmatterDiagnostic(context));
|
|
8
|
+
}
|
|
9
|
+
if (assertion.presence === "forbidden" && frontmatter !== undefined) {
|
|
10
|
+
diagnostics.push(forbiddenFrontmatterDiagnostic(context));
|
|
11
|
+
}
|
|
12
|
+
if (assertion.fields === undefined) {
|
|
13
|
+
return diagnostics;
|
|
14
|
+
}
|
|
15
|
+
if (!isPlainRecord(frontmatter)) {
|
|
16
|
+
for (const [fieldOrder, field] of assertion.fields.entries()) {
|
|
17
|
+
if (field.required === true) {
|
|
18
|
+
diagnostics.push(missingFieldDiagnostic(field, context, fieldOrder));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return diagnostics;
|
|
22
|
+
}
|
|
23
|
+
for (const [fieldOrder, field] of assertion.fields.entries()) {
|
|
24
|
+
diagnostics.push(...evaluateFrontmatterField(frontmatter, field, context, fieldOrder));
|
|
25
|
+
}
|
|
26
|
+
return diagnostics;
|
|
27
|
+
}
|
|
28
|
+
function evaluateFrontmatterField(frontmatter, field, context, fieldOrder) {
|
|
29
|
+
if (!hasOwnProperty(frontmatter, field.field)) {
|
|
30
|
+
return field.required === true
|
|
31
|
+
? [missingFieldDiagnostic(field, context, fieldOrder)]
|
|
32
|
+
: [];
|
|
33
|
+
}
|
|
34
|
+
const value = frontmatter[field.field];
|
|
35
|
+
const diagnostics = [];
|
|
36
|
+
if (field.valueType !== undefined &&
|
|
37
|
+
!matchesFrontmatterValueType(value, field.valueType)) {
|
|
38
|
+
diagnostics.push(typeMismatchDiagnostic(field, context, fieldOrder));
|
|
39
|
+
}
|
|
40
|
+
if (field.nonEmpty === true && failsNonEmptyStringPredicate(value, field)) {
|
|
41
|
+
diagnostics.push(emptyFieldDiagnostic(field, context, fieldOrder));
|
|
42
|
+
}
|
|
43
|
+
return diagnostics;
|
|
44
|
+
}
|
|
45
|
+
function requiredFrontmatterDiagnostic(context) {
|
|
46
|
+
return validationDiagnostic("profile.validation.frontmatterMissing", "Frontmatter is required.", context.rule, {
|
|
47
|
+
assertionIndex: context.assertionIndex,
|
|
48
|
+
targetKey: "frontmatter:presence:required",
|
|
49
|
+
diagnosticOrder: 0,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function forbiddenFrontmatterDiagnostic(context) {
|
|
53
|
+
return validationDiagnostic("profile.validation.frontmatterForbidden", "Frontmatter is forbidden.", context.rule, {
|
|
54
|
+
assertionIndex: context.assertionIndex,
|
|
55
|
+
targetKey: "frontmatter:presence:forbidden",
|
|
56
|
+
diagnosticOrder: 0,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function missingFieldDiagnostic(field, context, fieldOrder) {
|
|
60
|
+
return validationDiagnostic("profile.validation.frontmatterFieldMissing", `Required frontmatter field "${field.field}" is missing.`, context.rule, {
|
|
61
|
+
assertionIndex: context.assertionIndex,
|
|
62
|
+
targetKey: frontmatterFieldTargetKey(field, "missing"),
|
|
63
|
+
diagnosticOrder: fieldOrder,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function typeMismatchDiagnostic(field, context, fieldOrder) {
|
|
67
|
+
return validationDiagnostic("profile.validation.frontmatterFieldTypeMismatch", `Frontmatter field "${field.field}" must be ${field.valueType}.`, context.rule, {
|
|
68
|
+
assertionIndex: context.assertionIndex,
|
|
69
|
+
targetKey: frontmatterFieldTargetKey(field, "type"),
|
|
70
|
+
diagnosticOrder: fieldOrder,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function emptyFieldDiagnostic(field, context, fieldOrder) {
|
|
74
|
+
return validationDiagnostic("profile.validation.frontmatterFieldEmpty", `Frontmatter field "${field.field}" must be a non-empty string.`, context.rule, {
|
|
75
|
+
assertionIndex: context.assertionIndex,
|
|
76
|
+
targetKey: frontmatterFieldTargetKey(field, "nonEmpty"),
|
|
77
|
+
diagnosticOrder: fieldOrder,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function frontmatterFieldTargetKey(field, predicate) {
|
|
81
|
+
return `frontmatter:${field.field}:${predicate}`;
|
|
82
|
+
}
|
|
83
|
+
function matchesFrontmatterValueType(value, valueType) {
|
|
84
|
+
switch (valueType) {
|
|
85
|
+
case "string":
|
|
86
|
+
return typeof value === "string";
|
|
87
|
+
case "number":
|
|
88
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
89
|
+
case "boolean":
|
|
90
|
+
return typeof value === "boolean";
|
|
91
|
+
case "array":
|
|
92
|
+
return Array.isArray(value);
|
|
93
|
+
case "object":
|
|
94
|
+
return isPlainRecord(value);
|
|
95
|
+
case "null":
|
|
96
|
+
return value === null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function failsNonEmptyStringPredicate(value, field) {
|
|
100
|
+
if (field.valueType === "string" && typeof value !== "string") {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return typeof value !== "string" || value.length === 0;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=frontmatter-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-shape.js","sourceRoot":"","sources":["../../../src/declarative-validation/assertions/frontmatter-shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAWxD,MAAM,UAAU,wBAAwB,CACtC,SAAoC,E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AAK,KAAK,QAAQ,CAAC;QAEnC,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE7D,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;QAEpC,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE9B,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAE9B,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,IAAI,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,SAAS,4BAA4B,CACnC,KAAc,EACd,KAA4B;IAE5B,IAAI,KAAK,CAAC,SAAS,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CompiledDeclarativeAssertion } from "../compiler/plan.js";
|
|
2
|
+
import type { AssertionEvaluationContext } from "./context.js";
|
|
3
|
+
import type { AssertionDiagnostic } from "./diagnostics.js";
|
|
4
|
+
type TextFormatAssertion = Extract<CompiledDeclarativeAssertion, {
|
|
5
|
+
kind: "textFormat";
|
|
6
|
+
}>;
|
|
7
|
+
export declare function evaluateTextFormat(assertion: TextFormatAssertion, context: AssertionEvaluationContext): AssertionDiagnostic[];
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=text-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-format.d.ts","sourceRoot":"","sources":["../../../src/declarative-validation/assertions/text-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,KAAK,mBAAmB,GAAG,OAAO,CAChC,4BAA4B,EAC5B;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CACvB,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,EAAE,CAWvB"}
|