@metaobjectsdev/metadata 0.6.0 → 0.7.0-rc.10
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 +54 -3
- package/dist/attr-schema-validate.js +7 -7
- package/dist/attr-schema-validate.js.map +1 -1
- package/dist/core/export-json.d.ts +6 -7
- package/dist/core/export-json.d.ts.map +1 -1
- package/dist/core/export-json.js +15 -17
- package/dist/core/export-json.js.map +1 -1
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/parser-yaml.d.ts.map +1 -1
- package/dist/core/parser-yaml.js +36 -11
- package/dist/core/parser-yaml.js.map +1 -1
- package/dist/core/yaml-desugar.d.ts.map +1 -1
- package/dist/core/yaml-desugar.js +54 -5
- package/dist/core/yaml-desugar.js.map +1 -1
- package/dist/core/yaml-positions-walker.d.ts +21 -0
- package/dist/core/yaml-positions-walker.d.ts.map +1 -0
- package/dist/core/yaml-positions-walker.js +75 -0
- package/dist/core/yaml-positions-walker.js.map +1 -0
- package/dist/core/yaml-positions.d.ts +19 -0
- package/dist/core/yaml-positions.d.ts.map +1 -0
- package/dist/core/yaml-positions.js +60 -0
- package/dist/core/yaml-positions.js.map +1 -0
- package/dist/core-types.d.ts.map +1 -1
- package/dist/core-types.js +7 -4
- package/dist/core-types.js.map +1 -1
- package/dist/errors.d.ts +32 -9
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +44 -5
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/json-path.d.ts +8 -0
- package/dist/json-path.d.ts.map +1 -0
- package/dist/json-path.js +39 -0
- package/dist/json-path.js.map +1 -0
- package/dist/loader/meta-data-loader.d.ts +47 -6
- package/dist/loader/meta-data-loader.d.ts.map +1 -1
- package/dist/loader/meta-data-loader.js +126 -8
- package/dist/loader/meta-data-loader.js.map +1 -1
- package/dist/loader/meta-data-source.d.ts +6 -2
- package/dist/loader/meta-data-source.d.ts.map +1 -1
- package/dist/loader/meta-data-source.js +10 -6
- package/dist/loader/meta-data-source.js.map +1 -1
- package/dist/loader/shortcuts.d.ts +9 -0
- package/dist/loader/shortcuts.d.ts.map +1 -0
- package/dist/loader/shortcuts.js +19 -0
- package/dist/loader/shortcuts.js.map +1 -0
- package/dist/loader/sources/directory-source.d.ts +15 -0
- package/dist/loader/sources/directory-source.d.ts.map +1 -0
- package/dist/loader/sources/directory-source.js +80 -0
- package/dist/loader/sources/directory-source.js.map +1 -0
- package/dist/loader/sources/file-source.d.ts +12 -0
- package/dist/loader/sources/file-source.d.ts.map +1 -0
- package/dist/loader/sources/file-source.js +46 -0
- package/dist/loader/sources/file-source.js.map +1 -0
- package/dist/loader/sources/index.d.ts +5 -0
- package/dist/loader/sources/index.d.ts.map +1 -0
- package/dist/loader/sources/index.js +5 -0
- package/dist/loader/sources/index.js.map +1 -0
- package/dist/loader/sources/uri-source.d.ts +9 -0
- package/dist/loader/sources/uri-source.d.ts.map +1 -0
- package/dist/loader/sources/uri-source.js +42 -0
- package/dist/loader/sources/uri-source.js.map +1 -0
- package/dist/loader/validation-passes.d.ts.map +1 -1
- package/dist/loader/validation-passes.js +92 -28
- package/dist/loader/validation-passes.js.map +1 -1
- package/dist/naming.d.ts +15 -2
- package/dist/naming.d.ts.map +1 -1
- package/dist/naming.js +20 -6
- package/dist/naming.js.map +1 -1
- package/dist/parser-core.d.ts +17 -4
- package/dist/parser-core.d.ts.map +1 -1
- package/dist/parser-core.js +371 -44
- package/dist/parser-core.js.map +1 -1
- package/dist/parser-json.d.ts.map +1 -1
- package/dist/parser-json.js +10 -2
- package/dist/parser-json.js.map +1 -1
- package/dist/persistence/source/validate-source-roles.js +2 -2
- package/dist/persistence/source/validate-source-roles.js.map +1 -1
- package/dist/semantic-diff.d.ts +5 -0
- package/dist/semantic-diff.d.ts.map +1 -0
- package/dist/semantic-diff.js +49 -0
- package/dist/semantic-diff.js.map +1 -0
- package/dist/shared/meta-data.d.ts +10 -0
- package/dist/shared/meta-data.d.ts.map +1 -1
- package/dist/shared/meta-data.js +23 -0
- package/dist/shared/meta-data.js.map +1 -1
- package/dist/source.d.ts +96 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +38 -0
- package/dist/source.js.map +1 -0
- package/dist/subtype-rules.js +1 -1
- package/dist/subtype-rules.js.map +1 -1
- package/dist/super-resolve.d.ts +2 -0
- package/dist/super-resolve.d.ts.map +1 -1
- package/dist/super-resolve.js +1 -1
- package/dist/super-resolve.js.map +1 -1
- package/dist/template/template-constants.d.ts +3 -1
- package/dist/template/template-constants.d.ts.map +1 -1
- package/dist/template/template-constants.js +22 -6
- package/dist/template/template-constants.js.map +1 -1
- package/dist/template/template-schema.d.ts.map +1 -1
- package/dist/template/template-schema.js +41 -1
- package/dist/template/template-schema.js.map +1 -1
- package/package.json +1 -1
- package/src/attr-schema-validate.ts +7 -7
- package/src/core/export-json.ts +15 -18
- package/src/core/index.ts +8 -2
- package/src/core/parser-yaml.ts +38 -11
- package/src/core/yaml-desugar.ts +58 -4
- package/src/core/yaml-positions-walker.ts +101 -0
- package/src/core/yaml-positions.ts +80 -0
- package/src/core-types.ts +7 -4
- package/src/errors.ts +57 -8
- package/src/index.ts +28 -3
- package/src/json-path.ts +46 -0
- package/src/loader/meta-data-loader.ts +168 -10
- package/src/loader/meta-data-source.ts +10 -6
- package/src/loader/shortcuts.ts +31 -0
- package/src/loader/sources/directory-source.ts +90 -0
- package/src/{core → loader/sources}/file-source.ts +3 -3
- package/src/loader/sources/index.ts +6 -0
- package/src/loader/sources/uri-source.ts +44 -0
- package/src/loader/validation-passes.ts +96 -29
- package/src/naming.ts +39 -7
- package/src/parser-core.ts +412 -46
- package/src/parser-json.ts +11 -2
- package/src/persistence/source/validate-source-roles.ts +2 -2
- package/src/semantic-diff.ts +48 -0
- package/src/shared/meta-data.ts +28 -0
- package/src/source.ts +99 -0
- package/src/subtype-rules.ts +1 -1
- package/src/super-resolve.ts +3 -1
- package/src/template/template-constants.ts +23 -6
- package/src/template/template-schema.ts +43 -0
- package/src/core/file-meta-data-loader.ts +0 -89
package/README.md
CHANGED
|
@@ -11,13 +11,64 @@ pnpm add @metaobjectsdev/metadata
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { MetaDataLoader,
|
|
14
|
+
import { MetaDataLoader, InMemoryStringSource } from "@metaobjectsdev/metadata";
|
|
15
15
|
|
|
16
16
|
const json = `{ "metadata.root": { "package": "demo", "children": [] } }`;
|
|
17
|
-
const result = await new MetaDataLoader().load([new
|
|
17
|
+
const result = await new MetaDataLoader().load([new InMemoryStringSource(json)]);
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
The public loader API is `MetaDataLoader` + `
|
|
20
|
+
The public loader API is `MetaDataLoader` + `InMemoryStringSource`. A `MetaDataLoader` instance is single-use; construct a new one per load.
|
|
21
|
+
|
|
22
|
+
## Loader errors (FR5a)
|
|
23
|
+
|
|
24
|
+
Every loader error conforms to the cross-port `LoaderError` envelope
|
|
25
|
+
(ADR-0009):
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
interface LoaderError {
|
|
29
|
+
code: string; // ERR_UNKNOWN_TYPE, ERR_BAD_ATTR_VALUE, ...
|
|
30
|
+
message: string;
|
|
31
|
+
source: ErrorSource; // always populated
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type ErrorSource =
|
|
35
|
+
| { format: "json"; files: [string]; jsonPath: string }
|
|
36
|
+
| { format: "yaml"; files: [string]; jsonPath: string; yamlPosition?: { line: number; col: number } }
|
|
37
|
+
| { format: "merged"; files: string[]; jsonPath: string; contributors: Contributor[] }
|
|
38
|
+
| { format: "resolved"; files: string[]; jsonPath?: string; referrer?: string; target?: string }
|
|
39
|
+
| { format: "database"; dbLocation: { table: string; id: string }; jsonPath?: string }
|
|
40
|
+
| { format: "code"; caller?: string };
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Every `MetaData` node also carries a populated `source` field, so
|
|
44
|
+
post-load consumers (drift detection, MCP, debug tools) can answer
|
|
45
|
+
"where did this node come from?" without an extra lookup table.
|
|
46
|
+
|
|
47
|
+
`LoadResult.warnings` is a parallel `LoaderWarning[]` channel — same
|
|
48
|
+
envelope shape, `WARN_*` prefixed codes. Pre-FR5a string warnings are
|
|
49
|
+
wrapped at the loader boundary as `WARN_LEGACY` envelopes; FR5c will
|
|
50
|
+
retire the legacy code by routing each emit site through a proper
|
|
51
|
+
envelope-shaped helper.
|
|
52
|
+
|
|
53
|
+
The package re-exports the envelope types and the `codeSource()`
|
|
54
|
+
helper for consumers that catch + repackage `ParseError`s or build
|
|
55
|
+
synthetic envelopes for programmatic-construction tests:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import type {
|
|
59
|
+
ErrorSource,
|
|
60
|
+
LoaderError,
|
|
61
|
+
LoaderWarning,
|
|
62
|
+
NodeContext,
|
|
63
|
+
Contributor,
|
|
64
|
+
} from "@metaobjectsdev/metadata";
|
|
65
|
+
import { codeSource } from "@metaobjectsdev/metadata";
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See [ADR-0009](../../../../spec/decisions/ADR-0009-loader-error-envelope-and-source-on-node.md)
|
|
69
|
+
for the full schema and the FR5 family for the per-error-class
|
|
70
|
+
rollout plan (5a JSON shape, 5b YAML positions, 5c multi-file merge
|
|
71
|
+
attribution, 5d reference resolution, 5e database sources).
|
|
21
72
|
|
|
22
73
|
## Links
|
|
23
74
|
|
|
@@ -67,7 +67,7 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
67
67
|
for (const ca of registry.getCommonAttrs()) {
|
|
68
68
|
if (byName.has(ca.name)) {
|
|
69
69
|
if (!reportedConflicts.has(typeKey)) {
|
|
70
|
-
errors.push(new ParseError(`Common attr '${ca.name}' conflicts with per-type attr on ${typeKey}`, { code: "ERR_PROVIDER_ATTR_CONFLICT" }));
|
|
70
|
+
errors.push(new ParseError(`Common attr '${ca.name}' conflicts with per-type attr on ${typeKey}`, { code: "ERR_PROVIDER_ATTR_CONFLICT", source: node.source }));
|
|
71
71
|
reportedConflicts.add(typeKey);
|
|
72
72
|
}
|
|
73
73
|
continue; // per-type wins
|
|
@@ -87,7 +87,7 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
87
87
|
const effective = node.attrs();
|
|
88
88
|
for (const spec of byName.values()) {
|
|
89
89
|
if (spec.required && !effective.has(spec.name)) {
|
|
90
|
-
errors.push(new ParseError(`${nodeLabel(node)} is missing required attribute '@${spec.name}'`, { code: "ERR_MISSING_REQUIRED_ATTR" }));
|
|
90
|
+
errors.push(new ParseError(`${nodeLabel(node)} is missing required attribute '@${spec.name}'`, { code: "ERR_MISSING_REQUIRED_ATTR", source: node.source }));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
// --- Checks 2 + 3: declared attrs on the node are well-typed + in range ---
|
|
@@ -104,7 +104,7 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
104
104
|
const valueErrors = inst.validateValue(value);
|
|
105
105
|
if (valueErrors.length > 0) {
|
|
106
106
|
for (const ve of valueErrors) {
|
|
107
|
-
errors.push(new ParseError(`${nodeLabel(node)} ${ve.message}`, { code: "ERR_BAD_ATTR_VALUE" }));
|
|
107
|
+
errors.push(new ParseError(`${nodeLabel(node)} ${ve.message}`, { code: "ERR_BAD_ATTR_VALUE", source: node.source }));
|
|
108
108
|
}
|
|
109
109
|
continue; // type wrong → skip allowedValues
|
|
110
110
|
}
|
|
@@ -114,7 +114,7 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
114
114
|
if (!spec.allowedValues.includes(value)) {
|
|
115
115
|
errors.push(new ParseError(`${nodeLabel(node)} attribute '@${inst.name}' has value ` +
|
|
116
116
|
`'${String(value)}' which is not one of the allowed values: ` +
|
|
117
|
-
`${spec.allowedValues.map((v) => String(v)).join(", ")}`, { code: "ERR_BAD_ATTR_VALUE" }));
|
|
117
|
+
`${spec.allowedValues.map((v) => String(v)).join(", ")}`, { code: "ERR_BAD_ATTR_VALUE", source: node.source }));
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -129,7 +129,7 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
129
129
|
const rawValues = node.ownAttrs().get(FIELD_ATTR_VALUES);
|
|
130
130
|
if (Array.isArray(rawValues)) {
|
|
131
131
|
if (rawValues.length === 0) {
|
|
132
|
-
errors.push(new ParseError(`${nodeLabel(node)} must declare at least one value in '@${FIELD_ATTR_VALUES}'.`, { code: "ERR_BAD_ATTR_VALUE" }));
|
|
132
|
+
errors.push(new ParseError(`${nodeLabel(node)} must declare at least one value in '@${FIELD_ATTR_VALUES}'.`, { code: "ERR_BAD_ATTR_VALUE", source: node.source }));
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
135
|
// rawValues is the only array variant of AttrValue, so each member is a
|
|
@@ -139,10 +139,10 @@ function validateNode(node, registry, errors, reportedConflicts) {
|
|
|
139
139
|
if (!ENUM_MEMBER_PATTERN.test(member)) {
|
|
140
140
|
errors.push(new ParseError(`${nodeLabel(node)} attribute '@${FIELD_ATTR_VALUES}' member '${member}' ` +
|
|
141
141
|
`is not a valid identifier (must match ${ENUM_MEMBER_PATTERN.source}). ` +
|
|
142
|
-
`Non-identifier-safe member strings require a symbol↔value mapping (deferred).`, { code: "ERR_BAD_ATTR_VALUE" }));
|
|
142
|
+
`Non-identifier-safe member strings require a symbol↔value mapping (deferred).`, { code: "ERR_BAD_ATTR_VALUE", source: node.source }));
|
|
143
143
|
}
|
|
144
144
|
else if (seen.has(member)) {
|
|
145
|
-
errors.push(new ParseError(`${nodeLabel(node)} attribute '@${FIELD_ATTR_VALUES}' has duplicate member '${member}'.`, { code: "ERR_BAD_ATTR_VALUE" }));
|
|
145
|
+
errors.push(new ParseError(`${nodeLabel(node)} attribute '@${FIELD_ATTR_VALUES}' has duplicate member '${member}'.`, { code: "ERR_BAD_ATTR_VALUE", source: node.source }));
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
148
|
seen.add(member);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr-schema-validate.js","sourceRoot":"","sources":["../src/attr-schema-validate.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,+EAA+E;AAC/E,+DAA+D;AAC/D,sEAAsE;AACtE,oCAAoC;AACpC,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,iFAAiF;AACjF,0EAA0E;AAC1E,8EAA8E;AAC9E,sEAAsE;AACtE,mFAAmF;AACnF,iFAAiF;AACjF,EAAE;AACF,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,wEAAwE;AACxE,uBAAuB;AACvB,EAAE;AACF,iEAAiE;AACjE,8EAA8E;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAOzC,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,UAAU,kBAAkB,CAChC,IAAc,EACd,QAAsB;IAEtB,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,+EAA+E;IAC/E,2EAA2E;IAC3E,4EAA4E;IAC5E,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,IAA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AG,SAAS,CAAC,IAAI,CAAC,gBAAgB,iBAAiB,2BAA2B,MAAM,IAAI,EACxF,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CACpD,CACF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBACnB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LoadOptions } from "../loader/meta-data-loader.js";
|
|
2
2
|
export interface ExportResult {
|
|
3
3
|
/** The single flattened canonical-JSON document of the entire loaded metadata model. */
|
|
4
4
|
json: string;
|
|
@@ -14,14 +14,13 @@ export interface ExportResult {
|
|
|
14
14
|
* Load all metadata under `dir` and export the entire model as one flattened
|
|
15
15
|
* canonical-JSON document.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* composed via `composeRegistry(coreProviders)`),
|
|
19
|
-
* resulting tree with `canonicalSerialize`.
|
|
17
|
+
* Routes through `MetaDataLoader.fromDirectory` (using the default registry
|
|
18
|
+
* composed via `composeRegistry(coreProviders)` when none supplied), then
|
|
19
|
+
* serializes the resulting tree with `canonicalSerialize`.
|
|
20
20
|
*
|
|
21
21
|
* @param dir Absolute or relative path to the directory containing `meta.*.json` files.
|
|
22
|
-
* @param opts Optional loader options
|
|
23
|
-
*
|
|
24
|
-
* supplied as `opts.exclude` — see `FileMetaDataLoader.loadDirectory`.
|
|
22
|
+
* @param opts Optional loader options (registry, freeze, strict). The
|
|
23
|
+
* `exclude` glob list can be supplied as `opts.exclude`.
|
|
25
24
|
*/
|
|
26
25
|
export declare function loadAndExportJson(dir: string, opts?: LoadOptions & {
|
|
27
26
|
exclude?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-json.d.ts","sourceRoot":"","sources":["../../src/core/export-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export-json.d.ts","sourceRoot":"","sources":["../../src/core/export-json.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAOjF,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC1C,OAAO,CAAC,YAAY,CAAC,CAWvB"}
|
package/dist/core/export-json.js
CHANGED
|
@@ -10,36 +10,34 @@
|
|
|
10
10
|
// - Content errors (parse/validation failures) are collected in errors[] and
|
|
11
11
|
// returned in the result — they do NOT throw. `json` is still produced from
|
|
12
12
|
// whatever tree the Loader returned (Loader always returns a valid MetaData).
|
|
13
|
-
// - I/O failures (missing/unreadable directory)
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
import {
|
|
13
|
+
// - I/O failures (missing/unreadable directory) surface as collected errors
|
|
14
|
+
// via MetaDataLoader.fromDirectory; `loadAndExportJson` surfaces them
|
|
15
|
+
// unchanged in `ExportResult.errors`. It does not throw for directory or
|
|
16
|
+
// metadata problems.
|
|
17
|
+
import { MetaDataLoader } from "../loader/meta-data-loader.js";
|
|
18
18
|
import { canonicalSerialize } from "../serializer-json.js";
|
|
19
19
|
/**
|
|
20
20
|
* Load all metadata under `dir` and export the entire model as one flattened
|
|
21
21
|
* canonical-JSON document.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* composed via `composeRegistry(coreProviders)`),
|
|
25
|
-
* resulting tree with `canonicalSerialize`.
|
|
23
|
+
* Routes through `MetaDataLoader.fromDirectory` (using the default registry
|
|
24
|
+
* composed via `composeRegistry(coreProviders)` when none supplied), then
|
|
25
|
+
* serializes the resulting tree with `canonicalSerialize`.
|
|
26
26
|
*
|
|
27
27
|
* @param dir Absolute or relative path to the directory containing `meta.*.json` files.
|
|
28
|
-
* @param opts Optional loader options
|
|
29
|
-
*
|
|
30
|
-
* supplied as `opts.exclude` — see `FileMetaDataLoader.loadDirectory`.
|
|
28
|
+
* @param opts Optional loader options (registry, freeze, strict). The
|
|
29
|
+
* `exclude` glob list can be supplied as `opts.exclude`.
|
|
31
30
|
*/
|
|
32
31
|
export async function loadAndExportJson(dir, opts) {
|
|
33
|
-
const
|
|
34
|
-
const loader = new FileMetaDataLoader(loaderOpts);
|
|
35
|
-
// Only pass the exclude option when defined, to satisfy exactOptionalPropertyTypes.
|
|
36
|
-
const dirOpts = exclude !== undefined ? { exclude } : undefined;
|
|
37
|
-
const result = await loader.loadDirectory(dir, dirOpts);
|
|
32
|
+
const result = await MetaDataLoader.fromDirectory(dir, opts);
|
|
38
33
|
const json = canonicalSerialize(result.root);
|
|
39
34
|
return {
|
|
40
35
|
json,
|
|
41
36
|
errors: result.errors,
|
|
42
|
-
|
|
37
|
+
// FR5a: LoadResult.warnings is now LoaderWarning[]; ExportResult preserves
|
|
38
|
+
// its public string[] shape (callers print warnings as text). Extract the
|
|
39
|
+
// message for back-compat.
|
|
40
|
+
warnings: result.warnings.map((w) => w.message),
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
//# sourceMappingURL=export-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-json.js","sourceRoot":"","sources":["../../src/core/export-json.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2BAA2B;AAC3B,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,uEAAuE;AACvE,iEAAiE;AACjE,EAAE;AACF,oDAAoD;AACpD,+EAA+E;AAC/E,gFAAgF;AAChF,kFAAkF;AAClF,
|
|
1
|
+
{"version":3,"file":"export-json.js","sourceRoot":"","sources":["../../src/core/export-json.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2BAA2B;AAC3B,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,uEAAuE;AACvE,iEAAiE;AACjE,EAAE;AACF,oDAAoD;AACpD,+EAA+E;AAC/E,gFAAgF;AAChF,kFAAkF;AAClF,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,yBAAyB;AAEzB,OAAO,EAAE,cAAc,EAAoB,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAkB3D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,IAA2C;IAE3C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,2EAA2E;QAC3E,0EAA0E;QAC1E,2BAA2B;QAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { FileSource } from "
|
|
2
|
-
export {
|
|
1
|
+
export { FileSource } from "../loader/sources/file-source.js";
|
|
2
|
+
export { DirectorySource } from "../loader/sources/directory-source.js";
|
|
3
|
+
export type { DirectoryOptions } from "../loader/sources/directory-source.js";
|
|
4
|
+
export { UriSource } from "../loader/sources/uri-source.js";
|
|
3
5
|
export { parseYaml } from "./parser-yaml.js";
|
|
4
6
|
export { loadAndExportJson } from "./export-json.js";
|
|
5
7
|
export type { ExportResult } from "./export-json.js";
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
// dependency: the file loaders, the YAML authoring parser, and the
|
|
5
5
|
// load-and-export convenience. The root `@metaobjectsdev/metadata` entry is
|
|
6
6
|
// browser-safe and imports none of this. See the package README.
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Source impls — the node:fs-backed MetaDataSource implementations. Live
|
|
8
|
+
// under `loader/sources/`; re-exported here so server-side consumers can pull
|
|
9
|
+
// them from the same `/core` entry that already houses the YAML parser.
|
|
10
|
+
export { FileSource } from "../loader/sources/file-source.js";
|
|
11
|
+
export { DirectorySource } from "../loader/sources/directory-source.js";
|
|
12
|
+
export { UriSource } from "../loader/sources/uri-source.js";
|
|
9
13
|
export { parseYaml } from "./parser-yaml.js";
|
|
10
14
|
export { loadAndExportJson } from "./export-json.js";
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,4EAA4E;AAC5E,iEAAiE;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,4EAA4E;AAC5E,iEAAiE;AAEjE,yEAAyE;AACzE,8EAA8E;AAC9E,wEAAwE;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-yaml.d.ts","sourceRoot":"","sources":["../../src/core/parser-yaml.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser-yaml.d.ts","sourceRoot":"","sources":["../../src/core/parser-yaml.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqBnE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,CAoD1E"}
|
package/dist/core/parser-yaml.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
// Authoring YAML parser.
|
|
2
2
|
//
|
|
3
|
-
// parseYaml is a front-end:
|
|
4
|
-
// (parser-core.ts). The desugar applies the four authoring-sugar
|
|
5
|
-
// resulting typed tree is identical to the one the equivalent
|
|
6
|
-
// produces.
|
|
7
|
-
|
|
3
|
+
// parseYaml is a front-end: parseYamlWithPositions → desugar → the shared
|
|
4
|
+
// buildTree (parser-core.ts). The desugar applies the four authoring-sugar
|
|
5
|
+
// rules so the resulting typed tree is identical to the one the equivalent
|
|
6
|
+
// canonical JSON produces.
|
|
7
|
+
//
|
|
8
|
+
// FR5b: the parse phase now preserves YAML source positions through the
|
|
9
|
+
// pipeline. parseYamlWithPositions attaches a Symbol-keyed position-by-key
|
|
10
|
+
// map onto every mapping object; desugar shallow-copies that property; and
|
|
11
|
+
// buildTree's `format: "yaml"` mode reads the position when stamping
|
|
12
|
+
// `node.source.yamlPosition` (see parser-core.ts).
|
|
8
13
|
import { ParseError } from "../errors.js";
|
|
9
|
-
import { buildTree
|
|
14
|
+
import { buildTree } from "../parser-core.js";
|
|
10
15
|
import { desugar } from "./yaml-desugar.js";
|
|
16
|
+
import { parseYamlWithPositions } from "./yaml-positions-walker.js";
|
|
17
|
+
/** FR5a / ADR-0009 — build a YAML-source envelope rooted at "$".
|
|
18
|
+
* yamlPosition on the envelope is left undefined here; envelopes for
|
|
19
|
+
* THROWN parser errors carry positions only when the parse phase pushed
|
|
20
|
+
* the path into the live parser-core builder (see populateNodeSource in
|
|
21
|
+
* parser-core.ts). Errors raised before buildTree (e.g. yaml syntax
|
|
22
|
+
* failures, an empty desugar result) lack a node — `yamlPosition` is
|
|
23
|
+
* intentionally omitted, per the spec's "skip on desugar-synthesized
|
|
24
|
+
* nodes" decision. */
|
|
25
|
+
function yamlSource(sourceName) {
|
|
26
|
+
return {
|
|
27
|
+
format: "yaml",
|
|
28
|
+
files: [sourceName ?? "<unknown>"],
|
|
29
|
+
jsonPath: "$",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
11
32
|
export function parseYaml(content, opts) {
|
|
12
33
|
// Strip UTF-8 BOM if present (consistent with parseJson).
|
|
13
34
|
const normalizedContent = content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;
|
|
@@ -15,10 +36,10 @@ export function parseYaml(content, opts) {
|
|
|
15
36
|
// The loader's per-source try/catch collects the throw into LoadResult.errors.
|
|
16
37
|
let parsed;
|
|
17
38
|
try {
|
|
18
|
-
parsed =
|
|
39
|
+
parsed = parseYamlWithPositions(normalizedContent).value;
|
|
19
40
|
}
|
|
20
41
|
catch (err) {
|
|
21
|
-
throw new ParseError(`Invalid YAML: ${err.message}`, {
|
|
42
|
+
throw new ParseError(`Invalid YAML: ${err.message}`, { code: "ERR_MALFORMED_YAML", source: yamlSource(opts.sourceName) });
|
|
22
43
|
}
|
|
23
44
|
// Desugar the sugared authoring object into the canonical structure.
|
|
24
45
|
const { canonical, errors: desugarErrors } = desugar(parsed, opts.registry);
|
|
@@ -26,21 +47,25 @@ export function parseYaml(content, opts) {
|
|
|
26
47
|
// first desugar error as a throw — parallels parseJson's top-level throws.
|
|
27
48
|
if (Object.keys(canonical).length === 0) {
|
|
28
49
|
const first = desugarErrors[0];
|
|
29
|
-
throw new ParseError(first.message, {
|
|
50
|
+
throw new ParseError(first.message, { code: first.code ?? "ERR_MALFORMED_YAML", source: yamlSource(opts.sourceName) });
|
|
30
51
|
}
|
|
31
|
-
|
|
52
|
+
// FR5b — buildTree needs to know the source-format discriminant so
|
|
53
|
+
// populateNodeSource emits `format: "yaml"` envelopes (with the
|
|
54
|
+
// optional yamlPosition) instead of the default `format: "json"`.
|
|
55
|
+
const result = buildTree(canonical, { ...opts, sourceFormat: "yaml" });
|
|
32
56
|
// Merge collected desugar errors ahead of buildTree's own collected errors.
|
|
33
57
|
// Each CollectedError carries its own stable code when set (e.g.
|
|
34
58
|
// ERR_YAML_COERCION from the D2 type-coercion guard); the malformed-document
|
|
35
59
|
// shape errors fall back to ERR_MALFORMED_YAML.
|
|
36
60
|
const desugarParseErrors = desugarErrors.map((e) => new ParseError(e.message, {
|
|
37
|
-
...errOpts(opts.sourceName),
|
|
38
61
|
code: e.code ?? "ERR_MALFORMED_YAML",
|
|
62
|
+
source: yamlSource(opts.sourceName),
|
|
39
63
|
}));
|
|
40
64
|
return {
|
|
41
65
|
root: result.root,
|
|
42
66
|
warnings: result.warnings,
|
|
43
67
|
errors: [...desugarParseErrors, ...result.errors],
|
|
68
|
+
envelopeWarnings: result.envelopeWarnings,
|
|
44
69
|
};
|
|
45
70
|
}
|
|
46
71
|
//# sourceMappingURL=parser-yaml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-yaml.js","sourceRoot":"","sources":["../../src/core/parser-yaml.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"parser-yaml.js","sourceRoot":"","sources":["../../src/core/parser-yaml.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,2BAA2B;AAC3B,EAAE;AACF,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AACrE,mDAAmD;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;;uBAOuB;AACvB,SAAS,UAAU,CAAC,UAA8B;IAChD,OAAO;QACL,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,CAAC,UAAU,IAAI,WAAW,CAAC;QAClC,QAAQ,EAAE,GAAG;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAkB;IAC3D,0DAA0D;IAC1D,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAEhE,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AM,EAAE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;KACpC,CAAC,CACL,CAAC;IACF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE,CAAC,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;QACjD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-desugar.d.ts","sourceRoot":"","sources":["../../src/core/yaml-desugar.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-desugar.d.ts","sourceRoot":"","sources":["../../src/core/yaml-desugar.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA0B9C,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,iDAAiD;IACjD,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAG,aAAa,CAI7E"}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
// CollectedError entries (a string message + optional stable error code) and a
|
|
29
29
|
// safe placeholder is substituted so buildTree does not double-report.
|
|
30
30
|
import { ATTR_PREFIX, RESERVED_KEYS, RESERVED_KEY_CHILDREN, RESERVED_KEY_NAME, RESERVED_KEY_IS_ARRAY, TYPE_SUBTYPE_SEPARATOR, } from "../shared/structural.js";
|
|
31
|
+
import { getPositionMap, setPositionMap, } from "./yaml-positions.js";
|
|
31
32
|
import { ATTR_SUBTYPE_STRING, ATTR_SUBTYPE_CLASS, ATTR_SUBTYPE_INT, ATTR_SUBTYPE_LONG, ATTR_SUBTYPE_DOUBLE, ATTR_SUBTYPE_BOOLEAN, ATTR_SUBTYPE_STRINGARRAY, } from "./attr/attr-constants.js";
|
|
32
33
|
const ARRAY_SUFFIX = "[]";
|
|
33
34
|
/** Desugar a parsed-YAML authoring document into a canonical-shaped object. */
|
|
@@ -53,6 +54,10 @@ function desugarNode(input, registry, errors, path) {
|
|
|
53
54
|
}
|
|
54
55
|
const rawKey = entries[0];
|
|
55
56
|
const rawBody = input[rawKey];
|
|
57
|
+
// FR5b — capture the wrapper-level position-by-key map BEFORE re-keying.
|
|
58
|
+
// The author's raw key (with `[]` suffix and possibly omitted subType) is
|
|
59
|
+
// the lookup key; the desugar's canonical key is what we emit.
|
|
60
|
+
const wrapperPositions = getPositionMap(input);
|
|
56
61
|
// Rule 4: a trailing "[]" on the key → isArray.
|
|
57
62
|
let key = rawKey;
|
|
58
63
|
let isArray = false;
|
|
@@ -63,7 +68,10 @@ function desugarNode(input, registry, errors, path) {
|
|
|
63
68
|
// Rule 1: a bare `type` key → the type's registry default subType.
|
|
64
69
|
const canonicalKey = resolveKey(key, registry, errors, path);
|
|
65
70
|
// Rule 2: a scalar body → { name: <scalar> }.
|
|
66
|
-
|
|
71
|
+
// FR5b — propagate the wrapper-key's position into the synthesized body
|
|
72
|
+
// when the input body was a scalar (no body-side positions to inherit).
|
|
73
|
+
const wrapperKeyPos = wrapperPositions?.[rawKey];
|
|
74
|
+
const body = desugarBody(rawBody, registry, canonicalKey, errors, path, wrapperKeyPos);
|
|
67
75
|
// Rule 4 (cont.): stamp isArray onto the canonical body.
|
|
68
76
|
if (isArray)
|
|
69
77
|
body[RESERVED_KEY_IS_ARRAY] = true;
|
|
@@ -81,7 +89,15 @@ function desugarNode(input, registry, errors, path) {
|
|
|
81
89
|
body[RESERVED_KEY_CHILDREN] = children;
|
|
82
90
|
}
|
|
83
91
|
// A non-array `children` value is left untouched — buildTree reports it.
|
|
84
|
-
|
|
92
|
+
// FR5b — emit a wrapper-level position-by-key map for the canonical wrapper
|
|
93
|
+
// so buildTree's per-child iteration can read the position via the same
|
|
94
|
+
// lookup it uses for JSON input. The single key transformation is
|
|
95
|
+
// rawKey → canonicalKey (Rule 1 fuses the subType, Rule 4 strips `[]`).
|
|
96
|
+
const outWrapper = { [canonicalKey]: body };
|
|
97
|
+
if (wrapperKeyPos !== undefined) {
|
|
98
|
+
setPositionMap(outWrapper, { [canonicalKey]: wrapperKeyPos });
|
|
99
|
+
}
|
|
100
|
+
return outWrapper;
|
|
85
101
|
}
|
|
86
102
|
// Rule 1 — resolve a possibly-bare key to a fused `type.subType` token.
|
|
87
103
|
function resolveKey(key, registry, errors, path) {
|
|
@@ -106,14 +122,28 @@ function resolveKey(key, registry, errors, path) {
|
|
|
106
122
|
// (type, subType) declares with a typed `valueType`, if the raw JS value's
|
|
107
123
|
// type was silently coerced by YAML 1.2 to something incompatible (e.g. a
|
|
108
124
|
// `boolean` for a `string`-declared attr), an ERR_YAML_COERCION is collected.
|
|
109
|
-
function desugarBody(rawBody, registry, canonicalKey, errors, path
|
|
125
|
+
function desugarBody(rawBody, registry, canonicalKey, errors, path,
|
|
126
|
+
/** FR5b — position of the WRAPPER key (the `field.string:` line). Used to
|
|
127
|
+
* back-fill `yamlPosition` on synthesized bodies (Rule 2's scalar lift) +
|
|
128
|
+
* empty bodies; for mapping bodies we use the body's own position-by-key
|
|
129
|
+
* map. */
|
|
130
|
+
wrapperKeyPos) {
|
|
110
131
|
if (typeof rawBody === "string" ||
|
|
111
132
|
typeof rawBody === "number" ||
|
|
112
133
|
typeof rawBody === "boolean") {
|
|
113
|
-
|
|
134
|
+
// FR5b — the synthesized `{ name: rawBody }` has no YAML-side
|
|
135
|
+
// counterpart; we attribute the `name` slot to the wrapper-key's
|
|
136
|
+
// position (the only YAML position that meaningfully belongs to this
|
|
137
|
+
// synthesis).
|
|
138
|
+
const out = { [RESERVED_KEY_NAME]: rawBody };
|
|
139
|
+
if (wrapperKeyPos !== undefined) {
|
|
140
|
+
setPositionMap(out, { [RESERVED_KEY_NAME]: wrapperKeyPos });
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
114
143
|
}
|
|
115
144
|
if (rawBody === null || rawBody === undefined) {
|
|
116
145
|
// An empty body (`field.string:` with nothing after) → an empty node.
|
|
146
|
+
// No body keys to position; the wrapper carries the node's position.
|
|
117
147
|
return {};
|
|
118
148
|
}
|
|
119
149
|
if (Array.isArray(rawBody)) {
|
|
@@ -127,10 +157,21 @@ function desugarBody(rawBody, registry, canonicalKey, errors, path) {
|
|
|
127
157
|
// Rule D2 (type-coercion guard).
|
|
128
158
|
const src = rawBody;
|
|
129
159
|
const out = {};
|
|
160
|
+
// FR5b — translate the body's position-by-key map across the sigil-free
|
|
161
|
+
// rewrite. A bare `filterable` key in the source maps to `@filterable` in
|
|
162
|
+
// the canonical body; the YAML position belongs to BOTH names (the YAML
|
|
163
|
+
// author only wrote one). We re-key the position map to match the canonical
|
|
164
|
+
// body's keys so buildTree's per-attr inspection (FR5b follow-ups, e.g.
|
|
165
|
+
// ERR_BAD_ATTR_VALUE) can find the position via the canonical key.
|
|
166
|
+
const srcPositions = getPositionMap(src);
|
|
167
|
+
const outPositions = {};
|
|
168
|
+
let hasOutPositions = false;
|
|
130
169
|
const schemaIndex = attrSchemaIndex(registry, canonicalKey);
|
|
131
170
|
for (const key of Object.keys(src)) {
|
|
171
|
+
let outKey;
|
|
132
172
|
if (RESERVED_KEYS.has(key) || key.startsWith(ATTR_PREFIX)) {
|
|
133
173
|
out[key] = src[key];
|
|
174
|
+
outKey = key;
|
|
134
175
|
// D2 also applies to author-written @-keys (the awkward form).
|
|
135
176
|
const attrName = key.startsWith(ATTR_PREFIX) ? key.slice(ATTR_PREFIX.length) : "";
|
|
136
177
|
if (attrName !== "" && !RESERVED_KEYS.has(attrName)) {
|
|
@@ -138,10 +179,18 @@ function desugarBody(rawBody, registry, canonicalKey, errors, path) {
|
|
|
138
179
|
}
|
|
139
180
|
}
|
|
140
181
|
else {
|
|
141
|
-
|
|
182
|
+
outKey = `${ATTR_PREFIX}${key}`;
|
|
183
|
+
out[outKey] = src[key];
|
|
142
184
|
checkCoercion(key, src[key], schemaIndex, errors, path);
|
|
143
185
|
}
|
|
186
|
+
const pos = srcPositions?.[key];
|
|
187
|
+
if (pos !== undefined) {
|
|
188
|
+
outPositions[outKey] = pos;
|
|
189
|
+
hasOutPositions = true;
|
|
190
|
+
}
|
|
144
191
|
}
|
|
192
|
+
if (hasOutPositions)
|
|
193
|
+
setPositionMap(out, outPositions);
|
|
145
194
|
return out;
|
|
146
195
|
}
|
|
147
196
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-desugar.js","sourceRoot":"","sources":["../../src/core/yaml-desugar.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;AAC/E,iCAAiC;AACjC,sEAAsE;AACtE,4EAA4E;AAC5E,yEAAyE;AACzE,mEAAmE;AACnE,gFAAgF;AAChF,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AACjE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,uEAAuE;AACvE,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,+EAA+E;AAC/E,uEAAuE;AAIvE,OAAO,EACL,WAAW,EACX,aAAa,EACb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+
/** Result of parsing YAML text with positions retained. */
|
|
3
|
+
export interface YamlParseResult {
|
|
4
|
+
/** The JS object (same shape as `yaml.parse(text)` returns), with
|
|
5
|
+
* position-by-key maps attached to every mapping. */
|
|
6
|
+
value: unknown;
|
|
7
|
+
/** The yaml library's LineCounter — exposed for callers that need to map
|
|
8
|
+
* additional ranges (e.g. surfacing errors raised by the YAML library
|
|
9
|
+
* itself). */
|
|
10
|
+
lineCounter: LineCounter;
|
|
11
|
+
}
|
|
12
|
+
/** Parse YAML text and return a JS object with positions attached.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors the contract of `yaml.parse(text)` for the shapes the metaobjects
|
|
15
|
+
* authoring grammar uses (mappings, sequences, scalars). Aliases and tags
|
|
16
|
+
* are deferred via the underlying parseDocument call — i.e. they resolve as
|
|
17
|
+
* the library normally would.
|
|
18
|
+
*
|
|
19
|
+
* Throws on YAML syntax errors (same behavior as `yaml.parse`). */
|
|
20
|
+
export declare function parseYamlWithPositions(text: string): YamlParseResult;
|
|
21
|
+
//# sourceMappingURL=yaml-positions-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-positions-walker.d.ts","sourceRoot":"","sources":["../../src/core/yaml-positions-walker.ts"],"names":[],"mappings":"AAOA,OAAO,EAML,WAAW,EAEZ,MAAM,MAAM,CAAC;AAOd,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B;0DACsD;IACtD,KAAK,EAAE,OAAO,CAAC;IACf;;mBAEe;IACf,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;oEAOoE;AACpE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAUpE"}
|