@origints/yaml 0.1.1 → 0.3.2
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 +141 -112
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +293 -168
- package/dist/index.es.js.map +1 -1
- package/dist/parse.d.ts +5 -4
- package/dist/yaml-node.d.ts +2 -0
- package/dist/yaml-spec-builder.d.ts +40 -0
- package/dist/yaml-spec-executor.d.ts +6 -0
- package/dist/yaml-spec.d.ts +19 -0
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Why
|
|
8
|
-
|
|
9
|
-
YAML parsers typically discard structural information like anchors, aliases, and tags during parsing. When you need to trace where a value came from in a complex YAML document with references, you're out of luck.
|
|
10
|
-
|
|
11
|
-
This package preserves YAML's structural features while integrating with Origins' provenance system. Every value can be traced back to its source location, even through anchor references.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
7
|
## Features
|
|
16
8
|
|
|
17
9
|
- Parse single or multi-document YAML streams
|
|
@@ -23,148 +15,185 @@ This package preserves YAML's structural features while integrating with Origins
|
|
|
23
15
|
|
|
24
16
|
---
|
|
25
17
|
|
|
26
|
-
##
|
|
18
|
+
## Installation
|
|
27
19
|
|
|
28
20
|
```bash
|
|
29
21
|
npm install @origints/yaml @origints/core
|
|
30
22
|
```
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
import { parseYaml } from "@origints/yaml";
|
|
34
|
-
|
|
35
|
-
const yaml = `
|
|
36
|
-
name: Alice
|
|
37
|
-
age: 30
|
|
38
|
-
`;
|
|
24
|
+
---
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
## Usage with Planner
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
console.log(result.value.get("name").asString());
|
|
44
|
-
}
|
|
45
|
-
```
|
|
28
|
+
### Extract values from a YAML config file
|
|
46
29
|
|
|
47
|
-
|
|
30
|
+
```ts
|
|
31
|
+
import { Planner, loadFile, run } from '@origints/core'
|
|
32
|
+
import { parseYaml } from '@origints/yaml'
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
const plan = new Planner()
|
|
35
|
+
.in(loadFile('config.yaml'))
|
|
36
|
+
.mapIn(parseYaml())
|
|
37
|
+
.emit((out, $) =>
|
|
38
|
+
out
|
|
39
|
+
.add('host', $.get('database').get('host').string())
|
|
40
|
+
.add('port', $.get('database').get('port').number())
|
|
41
|
+
)
|
|
42
|
+
.compile()
|
|
43
|
+
|
|
44
|
+
const result = await run(plan, { readFile, registry })
|
|
45
|
+
// result.value: { host: 'localhost', port: 5432 }
|
|
51
46
|
```
|
|
52
47
|
|
|
53
|
-
|
|
48
|
+
### Extract nested structures
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
```ts
|
|
51
|
+
// config.yaml:
|
|
52
|
+
// app:
|
|
53
|
+
// name: MyApp
|
|
54
|
+
// settings:
|
|
55
|
+
// theme: dark
|
|
56
|
+
// language: en
|
|
57
|
+
|
|
58
|
+
const plan = new Planner()
|
|
59
|
+
.in(loadFile('config.yaml'))
|
|
60
|
+
.mapIn(parseYaml())
|
|
61
|
+
.emit((out, $) =>
|
|
62
|
+
out
|
|
63
|
+
.add('appName', $.get('app').get('name').string())
|
|
64
|
+
.add('theme', $.get('app').get('settings').get('theme').string())
|
|
65
|
+
.add('lang', $.get('app').get('settings').get('language').string())
|
|
66
|
+
)
|
|
67
|
+
.compile()
|
|
68
|
+
```
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
- macOS / Linux / Windows
|
|
59
|
-
- Runtime requirements:
|
|
60
|
-
- Node.js >= 18
|
|
61
|
-
- Package managers:
|
|
62
|
-
- npm, pnpm, yarn
|
|
63
|
-
- Peer dependencies:
|
|
64
|
-
- @origints/core ^0.1.0
|
|
70
|
+
### Extract arrays
|
|
65
71
|
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
```ts
|
|
73
|
+
// users.yaml:
|
|
74
|
+
// users:
|
|
75
|
+
// - name: Alice
|
|
76
|
+
// role: admin
|
|
77
|
+
// - name: Bob
|
|
78
|
+
// role: user
|
|
79
|
+
|
|
80
|
+
const plan = new Planner()
|
|
81
|
+
.in(loadFile('users.yaml'))
|
|
82
|
+
.mapIn(parseYaml())
|
|
83
|
+
.emit((out, $) =>
|
|
84
|
+
out
|
|
85
|
+
.add(
|
|
86
|
+
'names',
|
|
87
|
+
$.get('users').array(u => u.get('name').string())
|
|
88
|
+
)
|
|
89
|
+
.add(
|
|
90
|
+
'roles',
|
|
91
|
+
$.get('users').array(u => u.get('role').string())
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
.compile()
|
|
95
|
+
|
|
96
|
+
const result = await run(plan, { readFile, registry })
|
|
97
|
+
// result.value: { names: ['Alice', 'Bob'], roles: ['admin', 'user'] }
|
|
70
98
|
```
|
|
71
99
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
## Usage
|
|
100
|
+
### Convenience collection methods
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
For simple sequences of scalars, use `strings()` or `numbers()` instead of `array()`:
|
|
77
103
|
|
|
78
104
|
```ts
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
// config.yaml:
|
|
106
|
+
// tags:
|
|
107
|
+
// - dev
|
|
108
|
+
// - staging
|
|
109
|
+
// - prod
|
|
110
|
+
// ports:
|
|
111
|
+
// - 3000
|
|
112
|
+
// - 3001
|
|
113
|
+
// - 3002
|
|
114
|
+
|
|
115
|
+
const plan = new Planner()
|
|
116
|
+
.in(loadFile('config.yaml'))
|
|
117
|
+
.mapIn(parseYaml())
|
|
118
|
+
.emit((out, $) =>
|
|
119
|
+
out
|
|
120
|
+
.add('tags', $.get('tags').strings())
|
|
121
|
+
.add('ports', $.get('ports').numbers())
|
|
122
|
+
)
|
|
123
|
+
.compile()
|
|
124
|
+
|
|
125
|
+
const result = await run(plan, { readFile, registry })
|
|
126
|
+
// result.value: { tags: ['dev', 'staging', 'prod'], ports: [3000, 3001, 3002] }
|
|
92
127
|
```
|
|
93
128
|
|
|
94
|
-
### Multi-document
|
|
129
|
+
### Multi-document YAML
|
|
95
130
|
|
|
96
131
|
```ts
|
|
97
|
-
import { parseYamlAll } from
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
132
|
+
import { parseYamlAll } from '@origints/yaml'
|
|
133
|
+
|
|
134
|
+
const plan = new Planner()
|
|
135
|
+
.in(loadFile('multi.yaml'))
|
|
136
|
+
.mapIn(parseYamlAll())
|
|
137
|
+
.emit((out, $) =>
|
|
138
|
+
out.add(
|
|
139
|
+
'names',
|
|
140
|
+
$.array(doc => doc.get('name').string())
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
.compile()
|
|
111
144
|
```
|
|
112
145
|
|
|
113
|
-
###
|
|
146
|
+
### Combine YAML with other sources
|
|
114
147
|
|
|
115
148
|
```ts
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
149
|
+
const plan = new Planner()
|
|
150
|
+
.in(loadFile('defaults.yaml'))
|
|
151
|
+
.mapIn(parseYaml())
|
|
152
|
+
.emit((out, $) =>
|
|
153
|
+
out.add('host', $.get('host').string()).add('port', $.get('port').number())
|
|
154
|
+
)
|
|
155
|
+
.in(loadFile('overrides.yaml'))
|
|
122
156
|
.mapIn(parseYaml())
|
|
123
|
-
.emit((out, $) =>
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
.compile();
|
|
157
|
+
.emit((out, $) => out.addIfEmpty('host', $.get('host').string()))
|
|
158
|
+
.compile()
|
|
127
159
|
```
|
|
128
160
|
|
|
129
|
-
###
|
|
161
|
+
### Standalone usage (without Planner)
|
|
130
162
|
|
|
131
163
|
```ts
|
|
132
|
-
import {
|
|
133
|
-
|
|
134
|
-
const result = parseYaml(yamlString);
|
|
135
|
-
if (result.ok) {
|
|
136
|
-
const json = toJson(result.value);
|
|
137
|
-
}
|
|
138
|
-
```
|
|
164
|
+
import { parseYamlImpl, toJson, YamlNode } from '@origints/yaml'
|
|
139
165
|
|
|
140
|
-
|
|
166
|
+
const node = parseYamlImpl.execute(yamlString) as YamlNode
|
|
141
167
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
## Non-Goals
|
|
149
|
-
|
|
150
|
-
- Not a YAML serializer (output/writing)
|
|
151
|
-
- Not a schema validator for YAML
|
|
152
|
-
- Not a replacement for js-yaml or yaml packages
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Documentation
|
|
168
|
+
// Navigate with Result types
|
|
169
|
+
const name = node.get('name')
|
|
170
|
+
if (name.ok) {
|
|
171
|
+
console.log(name.value.asString().value)
|
|
172
|
+
}
|
|
157
173
|
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
// Or convert to JSON
|
|
175
|
+
const json = toJson(node)
|
|
176
|
+
if (json.ok) {
|
|
177
|
+
console.log(json.value)
|
|
178
|
+
}
|
|
179
|
+
```
|
|
160
180
|
|
|
161
181
|
---
|
|
162
182
|
|
|
163
|
-
##
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
## API
|
|
184
|
+
|
|
185
|
+
| Export | Description |
|
|
186
|
+
| ---------------------------------- | ------------------------------------------------- |
|
|
187
|
+
| `parseYaml(options?)` | Create a transform AST for single-document YAML |
|
|
188
|
+
| `parseYamlAll(options?)` | Create a transform AST for multi-document YAML |
|
|
189
|
+
| `parseYamlImpl` | Sync transform implementation (string input) |
|
|
190
|
+
| `parseYamlAsyncImpl` | Async transform implementation (string or stream) |
|
|
191
|
+
| `parseYamlAllImpl` | Async multi-document implementation |
|
|
192
|
+
| `registerYamlTransforms(registry)` | Register all YAML transforms with a registry |
|
|
193
|
+
| `YamlNode` | Navigable wrapper around parsed YAML |
|
|
194
|
+
| `toJson(node, options?)` | Convert YamlNode to JSON |
|
|
195
|
+
| `toJsonValue(node)` | Convert YamlNode to JSON with defaults |
|
|
196
|
+
| `ok`, `fail`, `formatYamlPath` | Result helpers |
|
|
168
197
|
|
|
169
198
|
---
|
|
170
199
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("yaml");function o(t,e){return{ok:!0,value:t,path:e}}function u(t,e,r,n){return{ok:!1,failure:{kind:t,message:e,path:r,position:n}}}function b(t){return t.length===0?"root":t.map(e=>typeof e=="number"?`[${e}]`:`.${e}`).join("").replace(/^\./,"")}class c{constructor(e,r,n){this.node=e,this._path=r,this.doc=n}static fromDocument(e){return new c(e.contents,[],e)}static fromNode(e,r,n){return new c(e,r,n)}get path(){return this._path}get position(){if(!this.node||!this.node.range)return;const[e,r]=this.node.range;return{start:{line:0,column:0,offset:e},end:{line:0,column:0,offset:r}}}get nodeType(){return this.node?i.isAlias(this.node)?"alias":i.isMap(this.node)?"mapping":i.isSeq(this.node)?"sequence":"scalar":"scalar"}unwrap(){if(!this.node)return null;if(this._path.length===0)return this.doc.toJSON();const e=this.doc.toJSON();return this.navigatePath(e,this._path)}navigatePath(e,r){let n=e;for(const s of r){if(n==null)return;if(typeof s=="number"&&Array.isArray(n))n=n[s];else if(typeof s=="string"&&typeof n=="object")n=n[s];else return}return n}tag(){return this.node?i.isScalar(this.node)?o(this.node.tag??null,this._path):i.isMap(this.node)||i.isSeq(this.node)?o(this.node.tag??null,this._path):o(null,this._path):o(null,this._path)}anchor(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.anchor??null,this._path):o(null,this._path):o(null,this._path)}isAlias(){return this.node!==null&&i.isAlias(this.node)}aliasTarget(){return!this.node||!i.isAlias(this.node)?u("alias","Node is not an alias",this._path,this.position):o(this.node.source,this._path)}resolveAlias(){if(!this.node||!i.isAlias(this.node))return u("alias","Node is not an alias",this._path,this.position);const e=this.node.resolve(this.doc);return e?o(new c(e,[...this._path],this.doc),this._path):u("anchor",`Anchor "${this.node.source}" not found`,this._path,this.position)}commentBefore(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.commentBefore??null,this._path):o(null,this._path):o(null,this._path)}comment(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.comment??null,this._path):o(null,this._path):o(null,this._path)}get(e){const r=this.resolveIfAlias();if(!r.ok)return r;const n=r.value.node;if(!n||!i.isMap(n))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const s=n.items.find(l=>{if(!i.isPair(l))return!1;const h=l.key;return i.isScalar(h)?h.value===e:!1});if(!s)return u("missing",`Key "${e}" not found`,this._path,this.position);const a=[...this._path,e];return o(new c(s.value,a,this.doc),a)}at(e){const r=this.resolveIfAlias();if(!r.ok)return r;const n=r.value.node;if(!n||!i.isSeq(n))return u("type",`Expected sequence, got ${this.nodeType}`,this._path,this.position);if(e<0||e>=n.items.length)return u("missing",`Index ${e} out of bounds (length: ${n.items.length})`,this._path,this.position);const s=[...this._path,e];return o(new c(n.items[e],s,this.doc),s)}keys(){const e=this.resolveIfAlias();if(!e.ok)return e;const r=e.value.node;if(!r||!i.isMap(r))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const n=[];for(const s of r.items)i.isPair(s)&&i.isScalar(s.key)&&n.push(String(s.key.value));return o(n,this._path)}entries(){const e=this.resolveIfAlias();if(!e.ok)return e;const r=e.value.node;if(!r||!i.isMap(r))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const n=[];for(const s of r.items)if(i.isPair(s)&&i.isScalar(s.key)){const a=String(s.key.value),l=[...this._path,a];n.push([a,new c(s.value,l,this.doc)])}return o(n,this._path)}items(){const e=this.resolveIfAlias();if(!e.ok)return e;const r=e.value.node;if(!r||!i.isSeq(r))return u("type",`Expected sequence, got ${this.nodeType}`,this._path,this.position);const n=[];for(let s=0;s<r.items.length;s++){const a=[...this._path,s];n.push(new c(r.items[s],a,this.doc))}return o(n,this._path)}has(e){const r=this.resolveIfAlias();if(!r.ok)return!1;const n=r.value.node;return!n||!i.isMap(n)?!1:n.items.some(s=>{if(!i.isPair(s))return!1;const a=s.key;return i.isScalar(a)?a.value===e:!1})}asString(){const e=this.getScalarValue();return typeof e!="string"?u("type",`Expected string, got ${d(e)}`,this._path,this.position):o(e,this._path)}asNumber(){const e=this.getScalarValue();return typeof e!="number"?u("type",`Expected number, got ${d(e)}`,this._path,this.position):o(e,this._path)}asBoolean(){const e=this.getScalarValue();return typeof e!="boolean"?u("type",`Expected boolean, got ${d(e)}`,this._path,this.position):o(e,this._path)}asNull(){const e=this.getScalarValue();return e!==null?u("type",`Expected null, got ${d(e)}`,this._path,this.position):o(null,this._path)}asSequence(){return this.items()}asMapping(){const e=this.entries();if(!e.ok)return e;const r={};for(const[n,s]of e.value)r[n]=s;return o(r,this._path)}isScalar(){if(!this.node)return!0;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return!e||i.isScalar(e)}return i.isScalar(this.node)}isSequence(){if(!this.node)return!1;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e!==null&&i.isSeq(e)}return i.isSeq(this.node)}isMapping(){if(!this.node)return!1;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e!==null&&i.isMap(e)}return i.isMap(this.node)}isString(){return typeof this.getScalarValue()=="string"}isNumber(){return typeof this.getScalarValue()=="number"}isBoolean(){return typeof this.getScalarValue()=="boolean"}isNull(){return this.getScalarValue()===null}resolveIfAlias(){return this.node&&i.isAlias(this.node)?this.resolveAlias():o(this,this._path)}getScalarValue(){if(!this.node)return null;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e?i.isScalar(e)?e.value:e.toJSON():null}return i.isScalar(this.node)?this.node.value:this.node.toJSON()}}function d(t){return t===null?"null":Array.isArray(t)?"sequence":typeof t=="object"?"mapping":typeof t}async function S(t){const e=t.getReader(),r=new TextDecoder,n=[];try{for(;;){const{done:s,value:a}=await e.read();if(s)break;n.push(r.decode(a,{stream:!0}))}return n.push(r.decode()),n.join("")}finally{e.releaseLock()}}function Y(t){return{kind:"transform",namespace:"@origints/yaml",name:"parseYaml",args:t}}function $(t){return{kind:"transform",namespace:"@origints/yaml",name:"parseYamlAll",args:t}}const M={namespace:"@origints/yaml",name:"parseYaml",execute(t,e){const n=A(e??{});let s;if(typeof t=="string")s=t;else throw t instanceof ReadableStream?new Error("parseYaml received a stream. Use streamToString first or ensure the input is a string."):new Error(`parseYaml expects string input, got ${typeof t}`);const a=i.parseDocument(s,n);if(a.errors.length>0){const l=a.errors[0];throw new Error(`YAML parse error: ${l.message}`)}return c.fromDocument(a)}},_={namespace:"@origints/yaml",name:"parseYaml",async execute(t,e){const n=A(e??{});let s;if(typeof t=="string")s=t;else if(t instanceof ReadableStream)s=await S(t);else throw new Error(`parseYaml expects string or stream input, got ${typeof t}`);const a=i.parseDocument(s,n);if(a.errors.length>0){const l=a.errors[0];throw new Error(`YAML parse error: ${l.message}`)}return c.fromDocument(a)}},k={namespace:"@origints/yaml",name:"parseYamlAll",async execute(t,e){const n=A(e??{});let s;if(typeof t=="string")s=t;else if(t instanceof ReadableStream)s=await S(t);else throw new Error(`parseYamlAll expects string or stream input, got ${typeof t}`);const a=i.parseAllDocuments(s,n);for(const l of a)if(l.errors.length>0){const h=l.errors[0];throw new Error(`YAML parse error: ${h.message}`)}return a.map(l=>c.fromDocument(l))}};function A(t){return{uniqueKeys:t.duplicateKeys!=="last",keepSourceTokens:!0,version:t.version??"1.2"}}function O(t){const e=t.unwrap();return v(e)?o(e,t.path):u("type",`Cannot convert YAML value to JSON: ${typeof e}`,t.path,t.position)}function v(t){return t===null||typeof t=="boolean"?!0:typeof t=="number"?Number.isFinite(t):typeof t=="string"?!0:Array.isArray(t)?t.every(v):typeof t=="object"?Object.values(t).every(v):!1}function q(t,e={}){const r=t;return m(r.node,r.doc,t.path,e)}function m(t,e,r,n){if(t===null)return o(null,r);if(i.isAlias(t)){const s=t.resolve(e);return s?m(s,e,r,n):u("anchor",`Unresolved alias: ${t.source}`,r,y(t))}if(i.isScalar(t)){const s=t.value;if(s===null)return o(null,r);if(typeof s=="boolean"||typeof s=="string")return o(s,r);if(typeof s=="number"){if(!Number.isFinite(s))switch(n.nonJsonValues??"error"){case"null":return o(null,r);case"string":return o(String(s),r);default:return u("type",`Cannot convert ${s} to JSON`,r,y(t))}return o(s,r)}if(s instanceof Date)switch(n.dates??"iso"){case"iso":return o(s.toISOString(),r);case"timestamp":return o(s.getTime(),r);default:return u("type","Date objects are not JSON-compatible",r,y(t))}return o(String(s),r)}if(i.isSeq(t)){const s=[];for(let a=0;a<t.items.length;a++){const l=t.items[a],h=[...r,a],p=m(l,e,h,n);if(!p.ok)return p;s.push(p.value)}return o(s,r)}if(i.isMap(t)){const s={};for(const a of t.items){if(!i.isPair(a))continue;let l;const h=a.key;if(h===null)l="null";else if(i.isAlias(h)){const f=h.resolve(e);f&&i.isScalar(f)?l=String(f.value):l=String(h.source)}else if(i.isScalar(h))l=String(h.value);else{const f=m(h,e,r,n);if(!f.ok)return f;l=JSON.stringify(f.value)}const p=[...r,l],w=a.value,g=m(w,e,p,n);if(!g.ok)return g;s[l]=g.value}return o(s,r)}return u("type","Unexpected YAML node type",r,void 0)}function y(t){if(!t.range)return;const[e,r]=t.range;return{start:{line:0,column:0,offset:e},end:{line:0,column:0,offset:r}}}function P(t){t.register(_),t.register(k)}exports.YamlNode=c;exports.fail=u;exports.formatYamlPath=b;exports.ok=o;exports.parseYaml=Y;exports.parseYamlAll=$;exports.parseYamlAllImpl=k;exports.parseYamlAsyncImpl=_;exports.parseYamlImpl=M;exports.registerYamlTransforms=P;exports.streamToString=S;exports.toJson=q;exports.toJsonValue=O;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@origints/core"),i=require("yaml");function o(t,e){return{ok:!0,value:t,path:e}}function u(t,e,s,r){return{ok:!1,failure:{kind:t,message:e,path:s,position:r}}}function T(t){return t.length===0?"root":t.map(e=>typeof e=="number"?`[${e}]`:`.${e}`).join("").replace(/^\./,"")}class f{constructor(e,s,r){this.node=e,this._path=s,this.doc=r}get[w.TYPE_LABEL](){return`YamlNode(${this.nodeType})`}static fromDocument(e){return new f(e.contents,[],e)}static fromNode(e,s,r){return new f(e,s,r)}get path(){return this._path}get position(){if(!this.node||!this.node.range)return;const[e,s]=this.node.range;return{start:{line:0,column:0,offset:e},end:{line:0,column:0,offset:s}}}get nodeType(){return this.node?i.isAlias(this.node)?"alias":i.isMap(this.node)?"mapping":i.isSeq(this.node)?"sequence":"scalar":"scalar"}unwrap(){if(!this.node)return null;if(this._path.length===0)return this.doc.toJSON();const e=this.doc.toJSON();return this.navigatePath(e,this._path)}navigatePath(e,s){let r=e;for(const n of s){if(r==null)return;if(typeof n=="number"&&Array.isArray(r))r=r[n];else if(typeof n=="string"&&typeof r=="object")r=r[n];else return}return r}tag(){return this.node?i.isScalar(this.node)?o(this.node.tag??null,this._path):i.isMap(this.node)||i.isSeq(this.node)?o(this.node.tag??null,this._path):o(null,this._path):o(null,this._path)}anchor(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.anchor??null,this._path):o(null,this._path):o(null,this._path)}isAlias(){return this.node!==null&&i.isAlias(this.node)}aliasTarget(){return!this.node||!i.isAlias(this.node)?u("alias","Node is not an alias",this._path,this.position):o(this.node.source,this._path)}resolveAlias(){if(!this.node||!i.isAlias(this.node))return u("alias","Node is not an alias",this._path,this.position);const e=this.node.resolve(this.doc);return e?o(new f(e,[...this._path],this.doc),this._path):u("anchor",`Anchor "${this.node.source}" not found`,this._path,this.position)}commentBefore(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.commentBefore??null,this._path):o(null,this._path):o(null,this._path)}comment(){return this.node?i.isScalar(this.node)||i.isMap(this.node)||i.isSeq(this.node)?o(this.node.comment??null,this._path):o(null,this._path):o(null,this._path)}get(e){const s=this.resolveIfAlias();if(!s.ok)return s;const r=s.value.node;if(!r||!i.isMap(r))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const n=r.items.find(l=>{if(!i.isPair(l))return!1;const c=l.key;return i.isScalar(c)?c.value===e:!1});if(!n)return u("missing",`Key "${e}" not found`,this._path,this.position);const a=[...this._path,e];return o(new f(n.value,a,this.doc),a)}at(e){const s=this.resolveIfAlias();if(!s.ok)return s;const r=s.value.node;if(!r||!i.isSeq(r))return u("type",`Expected sequence, got ${this.nodeType}`,this._path,this.position);if(e<0||e>=r.items.length)return u("missing",`Index ${e} out of bounds (length: ${r.items.length})`,this._path,this.position);const n=[...this._path,e];return o(new f(r.items[e],n,this.doc),n)}keys(){const e=this.resolveIfAlias();if(!e.ok)return e;const s=e.value.node;if(!s||!i.isMap(s))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const r=[];for(const n of s.items)i.isPair(n)&&i.isScalar(n.key)&&r.push(String(n.key.value));return o(r,this._path)}entries(){const e=this.resolveIfAlias();if(!e.ok)return e;const s=e.value.node;if(!s||!i.isMap(s))return u("type",`Expected mapping, got ${this.nodeType}`,this._path,this.position);const r=[];for(const n of s.items)if(i.isPair(n)&&i.isScalar(n.key)){const a=String(n.key.value),l=[...this._path,a];r.push([a,new f(n.value,l,this.doc)])}return o(r,this._path)}items(){const e=this.resolveIfAlias();if(!e.ok)return e;const s=e.value.node;if(!s||!i.isSeq(s))return u("type",`Expected sequence, got ${this.nodeType}`,this._path,this.position);const r=[];for(let n=0;n<s.items.length;n++){const a=[...this._path,n];r.push(new f(s.items[n],a,this.doc))}return o(r,this._path)}has(e){const s=this.resolveIfAlias();if(!s.ok)return!1;const r=s.value.node;return!r||!i.isMap(r)?!1:r.items.some(n=>{if(!i.isPair(n))return!1;const a=n.key;return i.isScalar(a)?a.value===e:!1})}asString(){const e=this.getScalarValue();return typeof e!="string"?u("type",`Expected string, got ${S(e)}`,this._path,this.position):o(e,this._path)}asNumber(){const e=this.getScalarValue();return typeof e!="number"?u("type",`Expected number, got ${S(e)}`,this._path,this.position):o(e,this._path)}asBoolean(){const e=this.getScalarValue();return typeof e!="boolean"?u("type",`Expected boolean, got ${S(e)}`,this._path,this.position):o(e,this._path)}asNull(){const e=this.getScalarValue();return e!==null?u("type",`Expected null, got ${S(e)}`,this._path,this.position):o(null,this._path)}asSequence(){return this.items()}asMapping(){const e=this.entries();if(!e.ok)return e;const s={};for(const[r,n]of e.value)s[r]=n;return o(s,this._path)}isScalar(){if(!this.node)return!0;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return!e||i.isScalar(e)}return i.isScalar(this.node)}isSequence(){if(!this.node)return!1;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e!==null&&i.isSeq(e)}return i.isSeq(this.node)}isMapping(){if(!this.node)return!1;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e!==null&&i.isMap(e)}return i.isMap(this.node)}isString(){return typeof this.getScalarValue()=="string"}isNumber(){return typeof this.getScalarValue()=="number"}isBoolean(){return typeof this.getScalarValue()=="boolean"}isNull(){return this.getScalarValue()===null}resolveIfAlias(){return this.node&&i.isAlias(this.node)?this.resolveAlias():o(this,this._path)}getScalarValue(){if(!this.node)return null;if(i.isAlias(this.node)){const e=this.node.resolve(this.doc);return e?i.isScalar(e)?e.value:e.toJSON():null}return i.isScalar(this.node)?this.node.value:this.node.toJSON()}}function S(t){return t===null?"null":Array.isArray(t)?"sequence":typeof t=="object"?"mapping":typeof t}function g(t,e){return{kind:"extract",format:"yaml",steps:t,extract:e}}class m{constructor(e){this.steps=e}static root(){return new m([])}get(e){return new m([...this.steps,{kind:"get",key:e}])}at(e){return new m([...this.steps,{kind:"at",index:e}])}string(){return g(this.steps,"string")}number(){return g(this.steps,"number")}boolean(){return g(this.steps,"boolean")}null(){return g(this.steps,"null")}array(e){const s=e(m.root());return{kind:"array",source:g(this.steps,"items"),items:s}}strings(){return this.array(e=>e.string())}numbers(){return this.array(e=>e.number())}}async function _(t){const e=t.getReader(),s=new TextDecoder,r=[];try{for(;;){const{done:n,value:a}=await e.read();if(n)break;r.push(s.decode(a,{stream:!0}))}return r.push(s.decode()),r.join("")}finally{e.releaseLock()}}function q(t){return{kind:"transform",namespace:"@origints/yaml",name:"parseYaml",args:t,specBuilderFactory:()=>m.root()}}function P(t){return{kind:"transform",namespace:"@origints/yaml",name:"parseYamlAll",args:t}}const I={namespace:"@origints/yaml",name:"parseYaml",execute(t,e){const r=$(e??{});let n;if(typeof t=="string")n=t;else throw t instanceof ReadableStream?new Error("parseYaml received a stream. Use streamToString first or ensure the input is a string."):new Error(`parseYaml expects string input, got ${typeof t}`);const a=i.parseDocument(n,r);if(a.errors.length>0){const l=a.errors[0];throw new Error(`YAML parse error: ${l.message}`)}return f.fromDocument(a)}},Y={namespace:"@origints/yaml",name:"parseYaml",async execute(t,e){const r=$(e??{});let n;if(typeof t=="string")n=t;else if(t instanceof ReadableStream)n=await _(t);else if(t instanceof Uint8Array)n=new TextDecoder().decode(t);else if(t instanceof ArrayBuffer)n=new TextDecoder().decode(t);else throw new Error(`parseYaml expects a string, stream, Uint8Array, or ArrayBuffer input, got ${typeof t}`);const a=i.parseDocument(n,r);if(a.errors.length>0){const l=a.errors[0];throw new Error(`YAML parse error: ${l.message}`)}return f.fromDocument(a)}},x={namespace:"@origints/yaml",name:"parseYamlAll",async execute(t,e){const r=$(e??{});let n;if(typeof t=="string")n=t;else if(t instanceof ReadableStream)n=await _(t);else throw new Error(`parseYamlAll expects string or stream input, got ${typeof t}`);const a=i.parseAllDocuments(n,r);for(const l of a)if(l.errors.length>0){const c=l.errors[0];throw new Error(`YAML parse error: ${c.message}`)}return a.map(l=>f.fromDocument(l))}};function $(t){return{uniqueKeys:t.duplicateKeys!=="last",keepSourceTokens:!0,version:t.version??"1.2"}}function y(t){return{ok:!0,value:t,path:[]}}function h(t){return{ok:!1,kind:"format",message:t,path:[]}}function M(t,e){if(t.kind!=="extract"||t.format!=="yaml")return h(`Expected spec kind "extract" with format "yaml", got kind "${t.kind}" format "${t.format}"`);let s=e;for(const r of t.steps)switch(r.kind){case"get":{const n=s.get(r.key);if(!n.ok)return h(`YAML navigation failed at get("${r.key}"): ${n.failure.message}`);s=n.value;break}case"at":{const n=s.at(r.index);if(!n.ok)return h(`YAML navigation failed at at(${r.index}): ${n.failure.message}`);s=n.value;break}}switch(t.extract){case"string":{const r=s.asString();return r.ok?y(r.value):h(`YAML extraction failed: ${r.failure.message}`)}case"number":{const r=s.asNumber();return r.ok?y(r.value):h(`YAML extraction failed: ${r.failure.message}`)}case"boolean":{const r=s.asBoolean();return r.ok?y(r.value):h(`YAML extraction failed: ${r.failure.message}`)}case"null":{const r=s.asNull();return r.ok?y(r.value):h(`YAML extraction failed: ${r.failure.message}`)}case"items":{const r=s.items();return r.ok?y(r.value):h(`YAML extraction failed: ${r.failure.message}`)}}}function L(t){const e=t.unwrap();return b(e)?o(e,t.path):u("type",`Cannot convert YAML value to JSON: ${typeof e}`,t.path,t.position)}function b(t){return t===null||typeof t=="boolean"?!0:typeof t=="number"?Number.isFinite(t):typeof t=="string"?!0:Array.isArray(t)?t.every(b):typeof t=="object"?Object.values(t).every(b):!1}function J(t,e={}){const s=t;return v(s.node,s.doc,t.path,e)}function v(t,e,s,r){if(t===null)return o(null,s);if(i.isAlias(t)){const n=t.resolve(e);return n?v(n,e,s,r):u("anchor",`Unresolved alias: ${t.source}`,s,A(t))}if(i.isScalar(t)){const n=t.value;if(n===null)return o(null,s);if(typeof n=="boolean"||typeof n=="string")return o(n,s);if(typeof n=="number"){if(!Number.isFinite(n))switch(r.nonJsonValues??"error"){case"null":return o(null,s);case"string":return o(String(n),s);default:return u("type",`Cannot convert ${n} to JSON`,s,A(t))}return o(n,s)}if(n instanceof Date)switch(r.dates??"iso"){case"iso":return o(n.toISOString(),s);case"timestamp":return o(n.getTime(),s);default:return u("type","Date objects are not JSON-compatible",s,A(t))}return o(String(n),s)}if(i.isSeq(t)){const n=[];for(let a=0;a<t.items.length;a++){const l=t.items[a],c=[...s,a],d=v(l,e,c,r);if(!d.ok)return d;n.push(d.value)}return o(n,s)}if(i.isMap(t)){const n={};for(const a of t.items){if(!i.isPair(a))continue;let l;const c=a.key;if(c===null)l="null";else if(i.isAlias(c)){const p=c.resolve(e);p&&i.isScalar(p)?l=String(p.value):l=String(c.source)}else if(i.isScalar(c))l=String(c.value);else{const p=v(c,e,s,r);if(!p.ok)return p;l=JSON.stringify(p.value)}const d=[...s,l],O=a.value,k=v(O,e,d,r);if(!k.ok)return k;n[l]=k.value}return o(n,s)}return u("type","Unexpected YAML node type",s,void 0)}function A(t){if(!t.range)return;const[e,s]=t.range;return{start:{line:0,column:0,offset:e},end:{line:0,column:0,offset:s}}}function E(t){t.register(Y),t.register(x)}E(w.globalRegistry);w.registerSpecExecutor("yaml",(t,e)=>M(t,e));exports.YamlNode=f;exports.YamlSpecBuilder=m;exports.executeYamlSpec=M;exports.fail=u;exports.formatYamlPath=T;exports.ok=o;exports.parseYaml=q;exports.parseYamlAll=P;exports.parseYamlAllImpl=x;exports.parseYamlAsyncImpl=Y;exports.parseYamlImpl=I;exports.registerYamlTransforms=E;exports.streamToString=_;exports.toJson=J;exports.toJsonValue=L;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/yaml-result.ts","../src/yaml-node.ts","../src/util.ts","../src/parse.ts","../src/convert.ts","../src/index.ts"],"sourcesContent":["/**\n * Result types for YAML operations.\n *\n * @module yaml/yaml-result\n */\n\n/**\n * Path through a YAML structure, tracking how we arrived at a value.\n * Each element is either a string (mapping key) or number (sequence index).\n */\nexport type YamlPath = readonly (string | number)[]\n\n/**\n * Failure kinds specific to YAML operations.\n */\nexport type YamlFailureKind =\n | 'parse' // YAML parsing error\n | 'type' // Wrong type at path\n | 'missing' // Key or index not found\n | 'anchor' // Anchor not found or invalid\n | 'alias' // Alias resolution failed\n | 'tag' // Invalid or unsupported tag\n\n/**\n * A failure during YAML traversal or extraction.\n */\nexport interface YamlFailure {\n readonly kind: YamlFailureKind\n readonly message: string\n readonly path: YamlPath\n readonly position?: SourcePosition\n}\n\n/**\n * Position in source document.\n */\nexport interface SourcePosition {\n readonly start: { line: number; column: number; offset: number }\n readonly end: { line: number; column: number; offset: number }\n}\n\n/**\n * Result of a YAML extraction - either a successful value or a failure.\n */\nexport type YamlResult<T> =\n | { readonly ok: true; readonly value: T; readonly path: YamlPath }\n | { readonly ok: false; readonly failure: YamlFailure }\n\n/**\n * Creates a success result.\n */\nexport function ok<T>(value: T, path: YamlPath): YamlResult<T> {\n return { ok: true, value, path }\n}\n\n/**\n * Creates a failure result.\n */\nexport function fail(\n kind: YamlFailureKind,\n message: string,\n path: YamlPath,\n position?: SourcePosition\n): YamlResult<never> {\n return {\n ok: false,\n failure: { kind, message, path, position },\n }\n}\n\n/**\n * Formats a path for display.\n */\nexport function formatYamlPath(path: YamlPath): string {\n if (path.length === 0) return 'root'\n return path\n .map(p => (typeof p === 'number' ? `[${p}]` : `.${p}`))\n .join('')\n .replace(/^\\./, '')\n}\n","/**\n * YamlNode - wrapper around YAML AST with path tracking and typed extraction.\n *\n * @module yaml/yaml-node\n */\n\nimport {\n Document,\n Pair,\n Node as YamlAstNode,\n isScalar,\n isMap,\n isSeq,\n isAlias,\n isPair,\n} from 'yaml'\nimport {\n YamlResult,\n YamlPath,\n SourcePosition,\n ok,\n fail,\n} from './yaml-result'\n\n/**\n * The type of YAML node.\n */\nexport type YamlNodeType = 'scalar' | 'mapping' | 'sequence' | 'alias'\n\n/**\n * A wrapper around YAML AST nodes with full metadata preservation.\n *\n * YamlNode enables typed navigation through YAML structures while maintaining\n * provenance information. Each traversal operation returns a new YamlNode\n * with an extended path, allowing you to trace exactly how you arrived at\n * any value.\n *\n * YAML-specific features preserved:\n * - Anchors (&name)\n * - Aliases (*name)\n * - Tags (!!str, !!int, custom tags)\n * - Comments (before and inline)\n */\nexport class YamlNode {\n private constructor(\n private readonly node: YamlAstNode | null,\n private readonly _path: YamlPath,\n private readonly doc: Document\n ) {}\n\n /**\n * Creates a YamlNode from a parsed YAML document.\n */\n static fromDocument(doc: Document): YamlNode {\n return new YamlNode(doc.contents, [], doc)\n }\n\n /**\n * Creates a YamlNode from a YAML AST node.\n * @internal\n */\n static fromNode(\n node: YamlAstNode | null,\n path: YamlPath,\n doc: Document\n ): YamlNode {\n return new YamlNode(node, path, doc)\n }\n\n /**\n * Returns the current path through the YAML structure.\n */\n get path(): YamlPath {\n return this._path\n }\n\n /**\n * Returns the source position of this node, if available.\n */\n get position(): SourcePosition | undefined {\n if (!this.node || !this.node.range) return undefined\n const [startOffset, endOffset] = this.node.range\n\n // The yaml library doesn't provide line/column directly on nodes\n // We need to compute them from the source\n // For now, return offset-based position\n return {\n start: { line: 0, column: 0, offset: startOffset },\n end: { line: 0, column: 0, offset: endOffset },\n }\n }\n\n /**\n * Returns the type of this YAML node.\n */\n get nodeType(): YamlNodeType {\n if (!this.node) return 'scalar' // null is a scalar\n if (isAlias(this.node)) return 'alias'\n if (isMap(this.node)) return 'mapping'\n if (isSeq(this.node)) return 'sequence'\n return 'scalar'\n }\n\n /**\n * Returns the underlying raw value.\n * Resolves all aliases using the document context.\n */\n unwrap(): unknown {\n if (!this.node) return null\n // For root node, use document's toJSON which handles aliases properly\n if (this._path.length === 0) {\n return this.doc.toJSON()\n }\n // For nested nodes, navigate through the document's JSON representation\n const root = this.doc.toJSON() as Record<string, unknown>\n return this.navigatePath(root, this._path)\n }\n\n /**\n * Navigate to a nested value in a JSON structure using the path.\n */\n private navigatePath(obj: unknown, path: YamlPath): unknown {\n let current = obj\n for (const segment of path) {\n if (current === null || current === undefined) return undefined\n if (typeof segment === 'number' && Array.isArray(current)) {\n current = current[segment]\n } else if (typeof segment === 'string' && typeof current === 'object') {\n current = (current as Record<string, unknown>)[segment]\n } else {\n return undefined\n }\n }\n return current\n }\n\n // ---------------------------------------------------------------------------\n // YAML-SPECIFIC METADATA\n // ---------------------------------------------------------------------------\n\n /**\n * Get the YAML tag (e.g., '!!str', '!!int', custom tags).\n */\n tag(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node)) {\n return ok(this.node.tag ?? null, this._path)\n }\n if (isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.tag ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Get anchor name if this node defines one.\n */\n anchor(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.anchor ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Check if this node is an alias reference.\n */\n isAlias(): boolean {\n return this.node !== null && isAlias(this.node)\n }\n\n /**\n * If alias, get the anchor name it references.\n */\n aliasTarget(): YamlResult<string> {\n if (!this.node || !isAlias(this.node)) {\n return fail('alias', 'Node is not an alias', this._path, this.position)\n }\n return ok(this.node.source, this._path)\n }\n\n /**\n * If alias, resolve to the actual node.\n */\n resolveAlias(): YamlResult<YamlNode> {\n if (!this.node || !isAlias(this.node)) {\n return fail('alias', 'Node is not an alias', this._path, this.position)\n }\n const resolved = this.node.resolve(this.doc)\n if (!resolved) {\n return fail(\n 'anchor',\n `Anchor \"${this.node.source}\" not found`,\n this._path,\n this.position\n )\n }\n return ok(new YamlNode(resolved, [...this._path], this.doc), this._path)\n }\n\n /**\n * Get comment before this node.\n */\n commentBefore(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.commentBefore ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Get comment on same line as this node.\n */\n comment(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.comment ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n // ---------------------------------------------------------------------------\n // NAVIGATION\n // ---------------------------------------------------------------------------\n\n /**\n * Navigate to a property of a mapping.\n * Automatically resolves aliases.\n */\n get(key: string): YamlResult<YamlNode> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const pair = node.items.find(item => {\n if (!isPair(item)) return false\n const k = item.key\n if (isScalar(k)) return k.value === key\n return false\n }) as Pair | undefined\n\n if (!pair) {\n return fail(\n 'missing',\n `Key \"${key}\" not found`,\n this._path,\n this.position\n )\n }\n\n const newPath = [...this._path, key]\n return ok(\n new YamlNode(pair.value as YamlAstNode | null, newPath, this.doc),\n newPath\n )\n }\n\n /**\n * Navigate to an element of a sequence.\n * Automatically resolves aliases.\n */\n at(index: number): YamlResult<YamlNode> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved\n\n const node = resolved.value.node\n if (!node || !isSeq(node)) {\n return fail(\n 'type',\n `Expected sequence, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n if (index < 0 || index >= node.items.length) {\n return fail(\n 'missing',\n `Index ${index} out of bounds (length: ${node.items.length})`,\n this._path,\n this.position\n )\n }\n\n const newPath = [...this._path, index]\n return ok(\n new YamlNode(node.items[index] as YamlAstNode | null, newPath, this.doc),\n newPath\n )\n }\n\n /**\n * Get all keys of a mapping.\n */\n keys(): YamlResult<readonly string[]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const keys: string[] = []\n for (const item of node.items) {\n if (isPair(item) && isScalar(item.key)) {\n keys.push(String(item.key.value))\n }\n }\n return ok(keys, this._path)\n }\n\n /**\n * Get all values of a mapping as [key, node] pairs.\n */\n entries(): YamlResult<readonly [string, YamlNode][]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const entries: [string, YamlNode][] = []\n for (const item of node.items) {\n if (isPair(item) && isScalar(item.key)) {\n const key = String(item.key.value)\n const newPath = [...this._path, key]\n entries.push([\n key,\n new YamlNode(item.value as YamlAstNode | null, newPath, this.doc),\n ])\n }\n }\n return ok(entries, this._path)\n }\n\n /**\n * Get all items of a sequence.\n */\n items(): YamlResult<readonly YamlNode[]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isSeq(node)) {\n return fail(\n 'type',\n `Expected sequence, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const items: YamlNode[] = []\n for (let i = 0; i < node.items.length; i++) {\n const newPath = [...this._path, i]\n items.push(\n new YamlNode(node.items[i] as YamlAstNode | null, newPath, this.doc)\n )\n }\n return ok(items, this._path)\n }\n\n /**\n * Check if mapping has key.\n */\n has(key: string): boolean {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return false\n\n const node = resolved.value.node\n if (!node || !isMap(node)) return false\n\n return node.items.some(item => {\n if (!isPair(item)) return false\n const k = item.key\n if (isScalar(k)) return k.value === key\n return false\n })\n }\n\n // ---------------------------------------------------------------------------\n // TYPE EXTRACTION\n // ---------------------------------------------------------------------------\n\n /**\n * Extract as a string.\n */\n asString(): YamlResult<string> {\n const value = this.getScalarValue()\n if (typeof value !== 'string') {\n return fail(\n 'type',\n `Expected string, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as a number.\n */\n asNumber(): YamlResult<number> {\n const value = this.getScalarValue()\n if (typeof value !== 'number') {\n return fail(\n 'type',\n `Expected number, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as a boolean.\n */\n asBoolean(): YamlResult<boolean> {\n const value = this.getScalarValue()\n if (typeof value !== 'boolean') {\n return fail(\n 'type',\n `Expected boolean, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as null.\n */\n asNull(): YamlResult<null> {\n const value = this.getScalarValue()\n if (value !== null) {\n return fail(\n 'type',\n `Expected null, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(null, this._path)\n }\n\n /**\n * Extract as a sequence of YamlNodes.\n */\n asSequence(): YamlResult<readonly YamlNode[]> {\n return this.items()\n }\n\n /**\n * Extract as a mapping with YamlNode values.\n */\n asMapping(): YamlResult<Readonly<Record<string, YamlNode>>> {\n const entriesResult = this.entries()\n if (!entriesResult.ok) return entriesResult as YamlResult<never>\n\n const mapping: Record<string, YamlNode> = {}\n for (const [key, node] of entriesResult.value) {\n mapping[key] = node\n }\n return ok(mapping, this._path)\n }\n\n // ---------------------------------------------------------------------------\n // PREDICATES\n // ---------------------------------------------------------------------------\n\n isScalar(): boolean {\n if (!this.node) return true // null is a scalar\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return !resolved || isScalar(resolved)\n }\n return isScalar(this.node)\n }\n\n isSequence(): boolean {\n if (!this.node) return false\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return resolved !== null && isSeq(resolved)\n }\n return isSeq(this.node)\n }\n\n isMapping(): boolean {\n if (!this.node) return false\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return resolved !== null && isMap(resolved)\n }\n return isMap(this.node)\n }\n\n isString(): boolean {\n return typeof this.getScalarValue() === 'string'\n }\n\n isNumber(): boolean {\n return typeof this.getScalarValue() === 'number'\n }\n\n isBoolean(): boolean {\n return typeof this.getScalarValue() === 'boolean'\n }\n\n isNull(): boolean {\n return this.getScalarValue() === null\n }\n\n // ---------------------------------------------------------------------------\n // HELPERS\n // ---------------------------------------------------------------------------\n\n /**\n * Resolve alias if this is one, otherwise return self.\n */\n private resolveIfAlias(): YamlResult<YamlNode> {\n if (this.node && isAlias(this.node)) {\n return this.resolveAlias()\n }\n return ok(this, this._path)\n }\n\n /**\n * Get the scalar value, resolving aliases.\n */\n private getScalarValue(): unknown {\n if (!this.node) return null\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n if (!resolved) return null\n if (isScalar(resolved)) return resolved.value\n return resolved.toJSON()\n }\n if (isScalar(this.node)) return this.node.value\n return this.node.toJSON()\n }\n}\n\n/**\n * Returns a human-readable type name.\n */\nfunction typeOf(value: unknown): string {\n if (value === null) return 'null'\n if (Array.isArray(value)) return 'sequence'\n if (typeof value === 'object') return 'mapping'\n return typeof value\n}\n","/**\n * Utility functions for YAML package.\n *\n * @module yaml/util\n */\n\n/**\n * Convert a ReadableStream<Uint8Array> to a string.\n */\nexport async function streamToString(\n stream: ReadableStream<Uint8Array>\n): Promise<string> {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n const chunks: string[] = []\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n chunks.push(decoder.decode(value, { stream: true }))\n }\n // Flush the decoder\n chunks.push(decoder.decode())\n return chunks.join('')\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * YAML parsing transform for Origins.\n *\n * @module yaml/parse\n */\n\nimport {\n parseDocument,\n parseAllDocuments,\n ParseOptions,\n DocumentOptions,\n} from 'yaml'\nimport type { TransformAst, TransformImpl } from '@origints/core'\nimport { YamlNode } from './yaml-node'\nimport { streamToString } from './util'\n\n/**\n * Options for parsing YAML.\n */\nexport interface YamlParseOptions {\n /**\n * How to handle duplicate keys in mappings.\n * - 'error': Throw an error (default)\n * - 'warn': Log a warning and use the last value\n * - 'last': Silently use the last value\n */\n duplicateKeys?: 'error' | 'warn' | 'last'\n\n /**\n * Maximum number of aliases to resolve.\n * This is a security measure to prevent YAML bombs.\n * Default: 100\n */\n maxAliasCount?: number\n\n /**\n * Preserve comments in the parsed document.\n * Default: true\n */\n preserveComments?: boolean\n\n /**\n * YAML version to use.\n * Default: '1.2'\n */\n version?: '1.1' | '1.2'\n}\n\n/**\n * Creates a TransformAst for parsing YAML.\n *\n * @example\n * ```ts\n * const plan = new Planner()\n * .in(loadFile('config.yaml'))\n * .mapIn(parseYaml())\n * .emit((out, $) => out\n * .add('host', $.get('server').get('host').asString())\n * )\n * .compile()\n * ```\n */\nexport function parseYaml(options?: YamlParseOptions): TransformAst {\n return {\n kind: 'transform',\n namespace: '@origints/yaml',\n name: 'parseYaml',\n args: options,\n }\n}\n\n/**\n * Creates a TransformAst for parsing multi-document YAML.\n * Returns an array of YamlNodes, one for each document.\n *\n * @example\n * ```ts\n * const plan = new Planner()\n * .in(loadFile('multi.yaml'))\n * .mapIn(parseYamlAll())\n * .emit((out, $) => out\n * .add('docs', $.items().all(doc => doc.get('name').asString()))\n * )\n * .compile()\n * ```\n */\nexport function parseYamlAll(options?: YamlParseOptions): TransformAst {\n return {\n kind: 'transform',\n namespace: '@origints/yaml',\n name: 'parseYamlAll',\n args: options,\n }\n}\n\n/**\n * Transform implementation for parseYaml.\n */\nexport const parseYamlImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYaml',\n\n execute(input: unknown, args?: unknown): YamlNode {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n // This will be handled asynchronously by the executor\n throw new Error(\n 'parseYaml received a stream. Use streamToString first or ensure the input is a string.'\n )\n } else {\n throw new Error(`parseYaml expects string input, got ${typeof input}`)\n }\n\n const doc = parseDocument(content, yamlOptions)\n\n // Check for errors\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n\n return YamlNode.fromDocument(doc)\n },\n}\n\n/**\n * Async transform implementation for parseYaml (handles streams).\n */\nexport const parseYamlAsyncImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYaml',\n\n async execute(input: unknown, args?: unknown): Promise<YamlNode> {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n content = await streamToString(input)\n } else {\n throw new Error(\n `parseYaml expects string or stream input, got ${typeof input}`\n )\n }\n\n const doc = parseDocument(content, yamlOptions)\n\n // Check for errors\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n\n return YamlNode.fromDocument(doc)\n },\n}\n\n/**\n * Transform implementation for parseYamlAll.\n */\nexport const parseYamlAllImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYamlAll',\n\n async execute(input: unknown, args?: unknown): Promise<YamlNode[]> {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n content = await streamToString(input)\n } else {\n throw new Error(\n `parseYamlAll expects string or stream input, got ${typeof input}`\n )\n }\n\n const docs = parseAllDocuments(content, yamlOptions)\n\n // Check for errors in any document\n for (const doc of docs) {\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n }\n\n return docs.map(doc => YamlNode.fromDocument(doc))\n },\n}\n\n/**\n * Convert our options to yaml library options.\n * Note: maxAliasCount is used during toJS conversion, not during parsing.\n */\nfunction toYamlParseOptions(\n options: YamlParseOptions\n): ParseOptions & DocumentOptions {\n return {\n uniqueKeys: options.duplicateKeys !== 'last',\n keepSourceTokens: true, // Needed for position tracking\n version: options.version ?? '1.2',\n }\n}\n","/**\n * Conversion from YamlNode to JSON.\n *\n * @module yaml/convert\n */\n\nimport {\n Document,\n Node as YamlAstNode,\n isScalar,\n isMap,\n isSeq,\n isAlias,\n isPair,\n} from 'yaml'\nimport { YamlNode } from './yaml-node'\nimport { YamlResult, ok, fail, YamlPath, SourcePosition } from './yaml-result'\n\n/**\n * JSON value type (mirrors @origints/core JsonValue).\n */\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | JsonValue[]\n | { [key: string]: JsonValue }\n\n/**\n * Convert a YamlNode to a plain JSON value.\n *\n * This conversion:\n * - Resolves all aliases\n * - Strips tags, comments, and anchors\n * - Converts all values to JSON-compatible types\n *\n * @param node The YamlNode to convert\n * @returns A JSON value\n */\nexport function toJsonValue(node: YamlNode): YamlResult<JsonValue> {\n const raw = node.unwrap()\n\n if (!isJsonCompatible(raw)) {\n return fail(\n 'type',\n `Cannot convert YAML value to JSON: ${typeof raw}`,\n node.path,\n node.position\n )\n }\n\n return ok(raw as JsonValue, node.path)\n}\n\n/**\n * Check if a value is JSON-compatible.\n */\nfunction isJsonCompatible(value: unknown): boolean {\n if (value === null) return true\n if (typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (typeof value === 'string') return true\n if (Array.isArray(value)) return value.every(isJsonCompatible)\n if (typeof value === 'object') {\n return Object.values(value).every(isJsonCompatible)\n }\n return false\n}\n\n/**\n * Options for YAML to JSON conversion.\n */\nexport interface ToJsonOptions {\n /**\n * How to handle non-JSON-compatible values (Infinity, NaN, undefined).\n * - 'error': Throw an error (default)\n * - 'null': Convert to null\n * - 'string': Convert to string representation\n */\n nonJsonValues?: 'error' | 'null' | 'string'\n\n /**\n * How to handle Date objects.\n * - 'iso': Convert to ISO 8601 string (default)\n * - 'timestamp': Convert to Unix timestamp (number)\n * - 'preserve': Keep as Date object (not JSON-compatible)\n */\n dates?: 'iso' | 'timestamp' | 'preserve'\n}\n\n/**\n * Convert a YamlNode to JSON with options.\n * This walks the AST to properly handle Date objects and other YAML-specific types.\n */\nexport function toJson(\n node: YamlNode,\n options: ToJsonOptions = {}\n): YamlResult<JsonValue> {\n // Access internal AST for proper type handling\n const internal = node as unknown as {\n node: YamlAstNode | null\n doc: Document\n }\n return convertAstNode(internal.node, internal.doc, node.path, options)\n}\n\nfunction convertAstNode(\n astNode: YamlAstNode | null,\n doc: Document,\n path: YamlPath,\n options: ToJsonOptions\n): YamlResult<JsonValue> {\n if (astNode === null) return ok(null, path)\n\n // Handle aliases by resolving them\n if (isAlias(astNode)) {\n const resolved = astNode.resolve(doc)\n if (!resolved) {\n return fail(\n 'anchor',\n `Unresolved alias: ${astNode.source}`,\n path,\n getPosition(astNode)\n )\n }\n return convertAstNode(resolved, doc, path, options)\n }\n\n // Handle scalars\n if (isScalar(astNode)) {\n const value = astNode.value\n\n if (value === null) return ok(null, path)\n if (typeof value === 'boolean') return ok(value, path)\n if (typeof value === 'string') return ok(value, path)\n\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n switch (options.nonJsonValues ?? 'error') {\n case 'null':\n return ok(null, path)\n case 'string':\n return ok(String(value), path)\n default:\n return fail(\n 'type',\n `Cannot convert ${value} to JSON`,\n path,\n getPosition(astNode)\n )\n }\n }\n return ok(value, path)\n }\n\n if (value instanceof Date) {\n switch (options.dates ?? 'iso') {\n case 'iso':\n return ok(value.toISOString(), path)\n case 'timestamp':\n return ok(value.getTime(), path)\n default:\n return fail(\n 'type',\n 'Date objects are not JSON-compatible',\n path,\n getPosition(astNode)\n )\n }\n }\n\n // Fallback for other scalar types\n return ok(String(value), path)\n }\n\n // Handle sequences\n if (isSeq(astNode)) {\n const result: JsonValue[] = []\n for (let i = 0; i < astNode.items.length; i++) {\n const item = astNode.items[i] as YamlAstNode | null\n const itemPath = [...path, i] as YamlPath\n const itemResult = convertAstNode(item, doc, itemPath, options)\n if (!itemResult.ok) return itemResult\n result.push(itemResult.value)\n }\n return ok(result, path)\n }\n\n // Handle mappings\n if (isMap(astNode)) {\n const result: { [key: string]: JsonValue } = {}\n for (const pair of astNode.items) {\n if (!isPair(pair)) continue\n\n // Get key (handle scalar keys, resolve alias keys)\n let key: string\n const keyNode = pair.key as YamlAstNode | null\n if (keyNode === null) {\n key = 'null'\n } else if (isAlias(keyNode)) {\n const resolvedKey = keyNode.resolve(doc)\n if (resolvedKey && isScalar(resolvedKey)) {\n key = String(resolvedKey.value)\n } else {\n key = String(keyNode.source)\n }\n } else if (isScalar(keyNode)) {\n key = String(keyNode.value)\n } else {\n // Complex keys - recursively convert and stringify\n const keyResult = convertAstNode(keyNode, doc, path, options)\n if (!keyResult.ok) return keyResult\n key = JSON.stringify(keyResult.value)\n }\n\n const valuePath = [...path, key] as YamlPath\n const valueNode = pair.value as YamlAstNode | null\n const valueResult = convertAstNode(valueNode, doc, valuePath, options)\n if (!valueResult.ok) return valueResult\n result[key] = valueResult.value\n }\n return ok(result, path)\n }\n\n // Should not reach here - all YAML node types are handled above\n return fail('type', 'Unexpected YAML node type', path, undefined)\n}\n\nfunction getPosition(node: YamlAstNode): SourcePosition | undefined {\n if (!node.range) return undefined\n const [startOffset, endOffset] = node.range\n return {\n start: { line: 0, column: 0, offset: startOffset },\n end: { line: 0, column: 0, offset: endOffset },\n }\n}\n","/**\n * @origints/yaml - YAML parsing for Origins with anchor/alias/tag preservation.\n *\n * @packageDocumentation\n */\n\n// Re-export types\nexport type {\n YamlPath,\n YamlFailure,\n YamlFailureKind,\n YamlResult,\n SourcePosition,\n} from './yaml-result'\nexport { ok, fail, formatYamlPath } from './yaml-result'\n\n// Re-export YamlNode\nexport type { YamlNodeType } from './yaml-node'\nexport { YamlNode } from './yaml-node'\n\n// Re-export parse functions and implementations\nexport type { YamlParseOptions } from './parse'\nexport {\n parseYaml,\n parseYamlAll,\n parseYamlImpl,\n parseYamlAsyncImpl,\n parseYamlAllImpl,\n} from './parse'\n\n// Re-export conversion utilities\nexport type { JsonValue, ToJsonOptions } from './convert'\nexport { toJson, toJsonValue } from './convert'\n\n// Re-export utilities\nexport { streamToString } from './util'\n\n// ---------------------------------------------------------------------------\n// Auto-registration of transforms\n// ---------------------------------------------------------------------------\n\nimport { parseYamlAsyncImpl, parseYamlAllImpl } from './parse'\n\n/**\n * Register the YAML transforms with a registry.\n * Call this to enable parseYaml() and parseYamlAll() in your plans.\n *\n * @example\n * ```ts\n * import { globalRegistry } from '@origints/core'\n * import { registerYamlTransforms } from '@origints/yaml'\n *\n * registerYamlTransforms(globalRegistry)\n * ```\n */\nexport function registerYamlTransforms(registry: {\n register(impl: {\n namespace: string\n name: string\n execute: (...args: unknown[]) => unknown\n }): void\n}): void {\n registry.register(parseYamlAsyncImpl)\n registry.register(parseYamlAllImpl)\n}\n"],"names":["ok","value","path","fail","kind","message","position","formatYamlPath","p","YamlNode","node","_path","doc","startOffset","endOffset","isAlias","isMap","isSeq","root","obj","current","segment","isScalar","resolved","key","pair","item","isPair","k","newPath","index","keys","entries","items","i","typeOf","entriesResult","mapping","streamToString","stream","reader","decoder","chunks","done","parseYaml","options","parseYamlAll","parseYamlImpl","input","args","yamlOptions","toYamlParseOptions","content","parseDocument","error","parseYamlAsyncImpl","parseYamlAllImpl","docs","parseAllDocuments","toJsonValue","raw","isJsonCompatible","toJson","internal","convertAstNode","astNode","getPosition","result","itemPath","itemResult","keyNode","resolvedKey","keyResult","valuePath","valueNode","valueResult","registerYamlTransforms","registry"],"mappings":"wGAmDO,SAASA,EAAMC,EAAUC,EAA+B,CAC7D,MAAO,CAAE,GAAI,GAAM,MAAAD,EAAO,KAAAC,CAAA,CAC5B,CAKO,SAASC,EACdC,EACAC,EACAH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AI,EAAG,SAGnB,IAAID,EACJ,MAAM8C,EAAU7C,EAAK,IACrB,GAAI6C,IAAY,KACd9C,EAAM,eACGT,UAAQuD,CAAO,EAAG,CAC3B,MAAMC,EAAcD,EAAQ,QAAQ1D,CAAG,EACnC2D,GAAejD,WAASiD,CAAW,EACrC/C,EAAM,OAAO+C,EAAY,KAAK,EAE9B/C,EAAM,OAAO8C,EAAQ,MAAM,CAE/B,SAAWhD,WAASgD,CAAO,EACzB9C,EAAM,OAAO8C,EAAQ,KAAK,MACrB,CAEL,MAAME,EAAYR,EAAeM,EAAS1D,EAAKV,EAAM2C,CAAO,EAC5D,GAAI,CAAC2B,EAAU,GAAI,OAAOA,EAC1BhD,EAAM,KAAK,UAAUgD,EAAU,KAAK,CACtC,CAEA,MAAMC,EAAY,CAAC,GAAGvE,EAAMsB,CAAG,EACzBkD,EAAYjD,EAAK,MACjBkD,EAAcX,EAAeU,EAAW9D,EAAK6D,EAAW5B,CAAO,EACrE,GAAI,CAAC8B,EAAY,GAAI,OAAOA,EAC5BR,EAAO3C,CAAG,EAAImD,EAAY,KAC5B,CACA,OAAO3E,EAAGmE,EAAQjE,CAAI,CACxB,CAGA,OAAOC,EAAK,OAAQ,4BAA6BD,EAAM,MAAS,CAClE,CAEA,SAASgE,EAAYxD,EAA+C,CAClE,GAAI,CAACA,EAAK,MAAO,OACjB,KAAM,CAACG,EAAaC,CAAS,EAAIJ,EAAK,MACtC,MAAO,CACL,MAAO,CAAE,KAAM,EAAG,OAAQ,EAAG,OAAQG,CAAA,EACrC,IAAK,CAAE,KAAM,EAAG,OAAQ,EAAG,OAAQC,CAAA,CAAU,CAEjD,CCrLO,SAAS8D,EAAuBC,EAM9B,CACPA,EAAS,SAAStB,CAAkB,EACpCsB,EAAS,SAASrB,CAAgB,CACpC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/yaml-result.ts","../src/yaml-node.ts","../src/yaml-spec-builder.ts","../src/util.ts","../src/parse.ts","../src/yaml-spec-executor.ts","../src/convert.ts","../src/index.ts"],"sourcesContent":["/**\n * Result types for YAML operations.\n *\n * @module yaml/yaml-result\n */\n\n/**\n * Path through a YAML structure, tracking how we arrived at a value.\n * Each element is either a string (mapping key) or number (sequence index).\n */\nexport type YamlPath = readonly (string | number)[]\n\n/**\n * Failure kinds specific to YAML operations.\n */\nexport type YamlFailureKind =\n | 'parse' // YAML parsing error\n | 'type' // Wrong type at path\n | 'missing' // Key or index not found\n | 'anchor' // Anchor not found or invalid\n | 'alias' // Alias resolution failed\n | 'tag' // Invalid or unsupported tag\n\n/**\n * A failure during YAML traversal or extraction.\n */\nexport interface YamlFailure {\n readonly kind: YamlFailureKind\n readonly message: string\n readonly path: YamlPath\n readonly position?: SourcePosition\n}\n\n/**\n * Position in source document.\n */\nexport interface SourcePosition {\n readonly start: { line: number; column: number; offset: number }\n readonly end: { line: number; column: number; offset: number }\n}\n\n/**\n * Result of a YAML extraction - either a successful value or a failure.\n */\nexport type YamlResult<T> =\n | { readonly ok: true; readonly value: T; readonly path: YamlPath }\n | { readonly ok: false; readonly failure: YamlFailure }\n\n/**\n * Creates a success result.\n */\nexport function ok<T>(value: T, path: YamlPath): YamlResult<T> {\n return { ok: true, value, path }\n}\n\n/**\n * Creates a failure result.\n */\nexport function fail(\n kind: YamlFailureKind,\n message: string,\n path: YamlPath,\n position?: SourcePosition\n): YamlResult<never> {\n return {\n ok: false,\n failure: { kind, message, path, position },\n }\n}\n\n/**\n * Formats a path for display.\n */\nexport function formatYamlPath(path: YamlPath): string {\n if (path.length === 0) return 'root'\n return path\n .map(p => (typeof p === 'number' ? `[${p}]` : `.${p}`))\n .join('')\n .replace(/^\\./, '')\n}\n","/**\n * YamlNode - wrapper around YAML AST with path tracking and typed extraction.\n *\n * @module yaml/yaml-node\n */\n\nimport { TYPE_LABEL } from '@origints/core'\nimport {\n Document,\n Pair,\n Node as YamlAstNode,\n isScalar,\n isMap,\n isSeq,\n isAlias,\n isPair,\n} from 'yaml'\nimport { YamlResult, YamlPath, SourcePosition, ok, fail } from './yaml-result'\n\n/**\n * The type of YAML node.\n */\nexport type YamlNodeType = 'scalar' | 'mapping' | 'sequence' | 'alias'\n\n/**\n * A wrapper around YAML AST nodes with full metadata preservation.\n *\n * YamlNode enables typed navigation through YAML structures while maintaining\n * provenance information. Each traversal operation returns a new YamlNode\n * with an extended path, allowing you to trace exactly how you arrived at\n * any value.\n *\n * YAML-specific features preserved:\n * - Anchors (&name)\n * - Aliases (*name)\n * - Tags (!!str, !!int, custom tags)\n * - Comments (before and inline)\n */\nexport class YamlNode {\n get [TYPE_LABEL]() {\n return `YamlNode(${this.nodeType})`\n }\n\n private constructor(\n private readonly node: YamlAstNode | null,\n private readonly _path: YamlPath,\n private readonly doc: Document\n ) {}\n\n /**\n * Creates a YamlNode from a parsed YAML document.\n */\n static fromDocument(doc: Document): YamlNode {\n return new YamlNode(doc.contents, [], doc)\n }\n\n /**\n * Creates a YamlNode from a YAML AST node.\n * @internal\n */\n static fromNode(\n node: YamlAstNode | null,\n path: YamlPath,\n doc: Document\n ): YamlNode {\n return new YamlNode(node, path, doc)\n }\n\n /**\n * Returns the current path through the YAML structure.\n */\n get path(): YamlPath {\n return this._path\n }\n\n /**\n * Returns the source position of this node, if available.\n */\n get position(): SourcePosition | undefined {\n if (!this.node || !this.node.range) return undefined\n const [startOffset, endOffset] = this.node.range\n\n // The yaml library doesn't provide line/column directly on nodes\n // We need to compute them from the source\n // For now, return offset-based position\n return {\n start: { line: 0, column: 0, offset: startOffset },\n end: { line: 0, column: 0, offset: endOffset },\n }\n }\n\n /**\n * Returns the type of this YAML node.\n */\n get nodeType(): YamlNodeType {\n if (!this.node) return 'scalar' // null is a scalar\n if (isAlias(this.node)) return 'alias'\n if (isMap(this.node)) return 'mapping'\n if (isSeq(this.node)) return 'sequence'\n return 'scalar'\n }\n\n /**\n * Returns the underlying raw value.\n * Resolves all aliases using the document context.\n */\n unwrap(): unknown {\n if (!this.node) return null\n // For root node, use document's toJSON which handles aliases properly\n if (this._path.length === 0) {\n return this.doc.toJSON()\n }\n // For nested nodes, navigate through the document's JSON representation\n const root = this.doc.toJSON() as Record<string, unknown>\n return this.navigatePath(root, this._path)\n }\n\n /**\n * Navigate to a nested value in a JSON structure using the path.\n */\n private navigatePath(obj: unknown, path: YamlPath): unknown {\n let current = obj\n for (const segment of path) {\n if (current === null || current === undefined) return undefined\n if (typeof segment === 'number' && Array.isArray(current)) {\n current = current[segment]\n } else if (typeof segment === 'string' && typeof current === 'object') {\n current = (current as Record<string, unknown>)[segment]\n } else {\n return undefined\n }\n }\n return current\n }\n\n // ---------------------------------------------------------------------------\n // YAML-SPECIFIC METADATA\n // ---------------------------------------------------------------------------\n\n /**\n * Get the YAML tag (e.g., '!!str', '!!int', custom tags).\n */\n tag(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node)) {\n return ok(this.node.tag ?? null, this._path)\n }\n if (isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.tag ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Get anchor name if this node defines one.\n */\n anchor(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.anchor ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Check if this node is an alias reference.\n */\n isAlias(): boolean {\n return this.node !== null && isAlias(this.node)\n }\n\n /**\n * If alias, get the anchor name it references.\n */\n aliasTarget(): YamlResult<string> {\n if (!this.node || !isAlias(this.node)) {\n return fail('alias', 'Node is not an alias', this._path, this.position)\n }\n return ok(this.node.source, this._path)\n }\n\n /**\n * If alias, resolve to the actual node.\n */\n resolveAlias(): YamlResult<YamlNode> {\n if (!this.node || !isAlias(this.node)) {\n return fail('alias', 'Node is not an alias', this._path, this.position)\n }\n const resolved = this.node.resolve(this.doc)\n if (!resolved) {\n return fail(\n 'anchor',\n `Anchor \"${this.node.source}\" not found`,\n this._path,\n this.position\n )\n }\n return ok(new YamlNode(resolved, [...this._path], this.doc), this._path)\n }\n\n /**\n * Get comment before this node.\n */\n commentBefore(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.commentBefore ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n /**\n * Get comment on same line as this node.\n */\n comment(): YamlResult<string | null> {\n if (!this.node) return ok(null, this._path)\n if (isScalar(this.node) || isMap(this.node) || isSeq(this.node)) {\n return ok(this.node.comment ?? null, this._path)\n }\n return ok(null, this._path)\n }\n\n // ---------------------------------------------------------------------------\n // NAVIGATION\n // ---------------------------------------------------------------------------\n\n /**\n * Navigate to a property of a mapping.\n * Automatically resolves aliases.\n */\n get(key: string): YamlResult<YamlNode> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const pair = node.items.find(item => {\n if (!isPair(item)) return false\n const k = item.key\n if (isScalar(k)) return k.value === key\n return false\n }) as Pair | undefined\n\n if (!pair) {\n return fail(\n 'missing',\n `Key \"${key}\" not found`,\n this._path,\n this.position\n )\n }\n\n const newPath = [...this._path, key]\n return ok(\n new YamlNode(pair.value as YamlAstNode | null, newPath, this.doc),\n newPath\n )\n }\n\n /**\n * Navigate to an element of a sequence.\n * Automatically resolves aliases.\n */\n at(index: number): YamlResult<YamlNode> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved\n\n const node = resolved.value.node\n if (!node || !isSeq(node)) {\n return fail(\n 'type',\n `Expected sequence, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n if (index < 0 || index >= node.items.length) {\n return fail(\n 'missing',\n `Index ${index} out of bounds (length: ${node.items.length})`,\n this._path,\n this.position\n )\n }\n\n const newPath = [...this._path, index]\n return ok(\n new YamlNode(node.items[index] as YamlAstNode | null, newPath, this.doc),\n newPath\n )\n }\n\n /**\n * Get all keys of a mapping.\n */\n keys(): YamlResult<readonly string[]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const keys: string[] = []\n for (const item of node.items) {\n if (isPair(item) && isScalar(item.key)) {\n keys.push(String(item.key.value))\n }\n }\n return ok(keys, this._path)\n }\n\n /**\n * Get all values of a mapping as [key, node] pairs.\n */\n entries(): YamlResult<readonly [string, YamlNode][]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isMap(node)) {\n return fail(\n 'type',\n `Expected mapping, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const entries: [string, YamlNode][] = []\n for (const item of node.items) {\n if (isPair(item) && isScalar(item.key)) {\n const key = String(item.key.value)\n const newPath = [...this._path, key]\n entries.push([\n key,\n new YamlNode(item.value as YamlAstNode | null, newPath, this.doc),\n ])\n }\n }\n return ok(entries, this._path)\n }\n\n /**\n * Get all items of a sequence.\n */\n items(): YamlResult<readonly YamlNode[]> {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return resolved as YamlResult<never>\n\n const node = resolved.value.node\n if (!node || !isSeq(node)) {\n return fail(\n 'type',\n `Expected sequence, got ${this.nodeType}`,\n this._path,\n this.position\n )\n }\n\n const items: YamlNode[] = []\n for (let i = 0; i < node.items.length; i++) {\n const newPath = [...this._path, i]\n items.push(\n new YamlNode(node.items[i] as YamlAstNode | null, newPath, this.doc)\n )\n }\n return ok(items, this._path)\n }\n\n /**\n * Check if mapping has key.\n */\n has(key: string): boolean {\n const resolved = this.resolveIfAlias()\n if (!resolved.ok) return false\n\n const node = resolved.value.node\n if (!node || !isMap(node)) return false\n\n return node.items.some(item => {\n if (!isPair(item)) return false\n const k = item.key\n if (isScalar(k)) return k.value === key\n return false\n })\n }\n\n // ---------------------------------------------------------------------------\n // TYPE EXTRACTION\n // ---------------------------------------------------------------------------\n\n /**\n * Extract as a string.\n */\n asString(): YamlResult<string> {\n const value = this.getScalarValue()\n if (typeof value !== 'string') {\n return fail(\n 'type',\n `Expected string, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as a number.\n */\n asNumber(): YamlResult<number> {\n const value = this.getScalarValue()\n if (typeof value !== 'number') {\n return fail(\n 'type',\n `Expected number, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as a boolean.\n */\n asBoolean(): YamlResult<boolean> {\n const value = this.getScalarValue()\n if (typeof value !== 'boolean') {\n return fail(\n 'type',\n `Expected boolean, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(value, this._path)\n }\n\n /**\n * Extract as null.\n */\n asNull(): YamlResult<null> {\n const value = this.getScalarValue()\n if (value !== null) {\n return fail(\n 'type',\n `Expected null, got ${typeOf(value)}`,\n this._path,\n this.position\n )\n }\n return ok(null, this._path)\n }\n\n /**\n * Extract as a sequence of YamlNodes.\n */\n asSequence(): YamlResult<readonly YamlNode[]> {\n return this.items()\n }\n\n /**\n * Extract as a mapping with YamlNode values.\n */\n asMapping(): YamlResult<Readonly<Record<string, YamlNode>>> {\n const entriesResult = this.entries()\n if (!entriesResult.ok) return entriesResult as YamlResult<never>\n\n const mapping: Record<string, YamlNode> = {}\n for (const [key, node] of entriesResult.value) {\n mapping[key] = node\n }\n return ok(mapping, this._path)\n }\n\n // ---------------------------------------------------------------------------\n // PREDICATES\n // ---------------------------------------------------------------------------\n\n isScalar(): boolean {\n if (!this.node) return true // null is a scalar\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return !resolved || isScalar(resolved)\n }\n return isScalar(this.node)\n }\n\n isSequence(): boolean {\n if (!this.node) return false\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return resolved !== null && isSeq(resolved)\n }\n return isSeq(this.node)\n }\n\n isMapping(): boolean {\n if (!this.node) return false\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n return resolved !== null && isMap(resolved)\n }\n return isMap(this.node)\n }\n\n isString(): boolean {\n return typeof this.getScalarValue() === 'string'\n }\n\n isNumber(): boolean {\n return typeof this.getScalarValue() === 'number'\n }\n\n isBoolean(): boolean {\n return typeof this.getScalarValue() === 'boolean'\n }\n\n isNull(): boolean {\n return this.getScalarValue() === null\n }\n\n // ---------------------------------------------------------------------------\n // HELPERS\n // ---------------------------------------------------------------------------\n\n /**\n * Resolve alias if this is one, otherwise return self.\n */\n private resolveIfAlias(): YamlResult<YamlNode> {\n if (this.node && isAlias(this.node)) {\n return this.resolveAlias()\n }\n return ok(this, this._path)\n }\n\n /**\n * Get the scalar value, resolving aliases.\n */\n private getScalarValue(): unknown {\n if (!this.node) return null\n if (isAlias(this.node)) {\n const resolved = this.node.resolve(this.doc)\n if (!resolved) return null\n if (isScalar(resolved)) return resolved.value\n return resolved.toJSON()\n }\n if (isScalar(this.node)) return this.node.value\n return this.node.toJSON()\n }\n}\n\n/**\n * Returns a human-readable type name.\n */\nfunction typeOf(value: unknown): string {\n if (value === null) return 'null'\n if (Array.isArray(value)) return 'sequence'\n if (typeof value === 'object') return 'mapping'\n return typeof value\n}\n","/**\n * YAML spec builders — build-time recorders that produce YamlSpec objects.\n *\n * Mirror the runtime YamlNode API but record navigation steps\n * as JSON-serializable specs.\n *\n * @module yaml/yaml-spec-builder\n */\n\nimport type { ExtractSpec, ArraySpec, Spec } from '@origints/core'\nimport type { YamlStep, YamlExtract } from './yaml-spec'\n\nfunction buildSpec<E extends YamlExtract>(\n steps: readonly YamlStep[],\n extract: E\n): ExtractSpec<YamlStep, E> {\n return { kind: 'extract', format: 'yaml', steps, extract }\n}\n\n/**\n * Spec builder for a YAML node — navigation and extraction.\n *\n * Used as `$` in `emit()` after `.mapIn(parseYaml())`.\n *\n * @example\n * ```ts\n * .mapIn(parseYaml())\n * .emit((out, $) => out\n * .add('host', $.get('server').get('host').string())\n * .add('port', $.get('server').get('port').number())\n * )\n * ```\n */\nexport class YamlSpecBuilder {\n private constructor(private readonly steps: readonly YamlStep[]) {}\n\n /** Create a root spec builder */\n static root(): YamlSpecBuilder {\n return new YamlSpecBuilder([])\n }\n\n /** Navigate to a mapping property */\n get(key: string): YamlSpecBuilder {\n return new YamlSpecBuilder([...this.steps, { kind: 'get', key }])\n }\n\n /** Navigate to a sequence element */\n at(index: number): YamlSpecBuilder {\n return new YamlSpecBuilder([...this.steps, { kind: 'at', index }])\n }\n\n /** Extract as string */\n string(): ExtractSpec<YamlStep, 'string'> {\n return buildSpec(this.steps, 'string')\n }\n\n /** Extract as number */\n number(): ExtractSpec<YamlStep, 'number'> {\n return buildSpec(this.steps, 'number')\n }\n\n /** Extract as boolean */\n boolean(): ExtractSpec<YamlStep, 'boolean'> {\n return buildSpec(this.steps, 'boolean')\n }\n\n /** Extract as null */\n null(): ExtractSpec<YamlStep, 'null'> {\n return buildSpec(this.steps, 'null')\n }\n\n /** Iterate over sequence items, mapping each to a spec */\n array<T extends Spec>(\n itemMapper: (item: YamlSpecBuilder) => T\n ): ArraySpec<T> {\n const itemSpec = itemMapper(YamlSpecBuilder.root())\n return {\n kind: 'array',\n source: buildSpec(this.steps, 'items'),\n items: itemSpec,\n }\n }\n\n /** Extract all items as strings */\n strings(): ArraySpec<ExtractSpec<YamlStep, 'string'>> {\n return this.array(item => item.string())\n }\n\n /** Extract all items as numbers */\n numbers(): ArraySpec<ExtractSpec<YamlStep, 'number'>> {\n return this.array(item => item.number())\n }\n}\n","/**\n * Utility functions for YAML package.\n *\n * @module yaml/util\n */\n\n/**\n * Convert a ReadableStream<Uint8Array> to a string.\n */\nexport async function streamToString(\n stream: ReadableStream<Uint8Array>\n): Promise<string> {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n const chunks: string[] = []\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n chunks.push(decoder.decode(value, { stream: true }))\n }\n // Flush the decoder\n chunks.push(decoder.decode())\n return chunks.join('')\n } finally {\n reader.releaseLock()\n }\n}\n","/**\n * YAML parsing transform for Origins.\n *\n * @module yaml/parse\n */\n\nimport {\n parseDocument,\n parseAllDocuments,\n ParseOptions,\n DocumentOptions,\n} from 'yaml'\nimport type {\n TransformAst,\n TransformImpl,\n TypedTransformAst,\n} from '@origints/core'\nimport { YamlSpecBuilder } from './yaml-spec-builder'\nimport { YamlNode } from './yaml-node'\nimport { streamToString } from './util'\n\n/**\n * Options for parsing YAML.\n */\nexport interface YamlParseOptions {\n /**\n * How to handle duplicate keys in mappings.\n * - 'error': Throw an error (default)\n * - 'warn': Log a warning and use the last value\n * - 'last': Silently use the last value\n */\n duplicateKeys?: 'error' | 'warn' | 'last'\n\n /**\n * Maximum number of aliases to resolve.\n * This is a security measure to prevent YAML bombs.\n * Default: 100\n */\n maxAliasCount?: number\n\n /**\n * Preserve comments in the parsed document.\n * Default: true\n */\n preserveComments?: boolean\n\n /**\n * YAML version to use.\n * Default: '1.2'\n */\n version?: '1.1' | '1.2'\n}\n\n/**\n * Creates a TransformAst for parsing YAML.\n *\n * @example\n * ```ts\n * const plan = new Planner()\n * .in(loadFile('config.yaml'))\n * .mapIn(parseYaml())\n * .emit((out, $) => out\n * .add('host', $.get('server').get('host').string())\n * )\n * .compile()\n * ```\n */\nexport function parseYaml(\n options?: YamlParseOptions\n): TypedTransformAst<YamlSpecBuilder> {\n return {\n kind: 'transform',\n namespace: '@origints/yaml',\n name: 'parseYaml',\n args: options,\n specBuilderFactory: () => YamlSpecBuilder.root(),\n }\n}\n\n/**\n * Creates a TransformAst for parsing multi-document YAML.\n * Returns an array of YamlNodes, one for each document.\n *\n * @example\n * ```ts\n * const plan = new Planner()\n * .in(loadFile('multi.yaml'))\n * .mapIn(parseYamlAll())\n * .emit((out, $) => out\n * .add('names', $.array(doc => doc.get('name').string()))\n * )\n * .compile()\n * ```\n */\nexport function parseYamlAll(options?: YamlParseOptions): TransformAst {\n return {\n kind: 'transform',\n namespace: '@origints/yaml',\n name: 'parseYamlAll',\n args: options,\n }\n}\n\n/**\n * Transform implementation for parseYaml.\n */\nexport const parseYamlImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYaml',\n\n execute(input: unknown, args?: unknown): YamlNode {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n // This will be handled asynchronously by the executor\n throw new Error(\n 'parseYaml received a stream. Use streamToString first or ensure the input is a string.'\n )\n } else {\n throw new Error(`parseYaml expects string input, got ${typeof input}`)\n }\n\n const doc = parseDocument(content, yamlOptions)\n\n // Check for errors\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n\n return YamlNode.fromDocument(doc)\n },\n}\n\n/**\n * Async transform implementation for parseYaml (handles streams).\n */\nexport const parseYamlAsyncImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYaml',\n\n async execute(input: unknown, args?: unknown): Promise<YamlNode> {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n content = await streamToString(input)\n } else if (input instanceof Uint8Array) {\n content = new TextDecoder().decode(input)\n } else if (input instanceof ArrayBuffer) {\n content = new TextDecoder().decode(input)\n } else {\n throw new Error(\n `parseYaml expects a string, stream, Uint8Array, or ArrayBuffer input, got ${typeof input}`\n )\n }\n\n const doc = parseDocument(content, yamlOptions)\n\n // Check for errors\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n\n return YamlNode.fromDocument(doc)\n },\n}\n\n/**\n * Transform implementation for parseYamlAll.\n */\nexport const parseYamlAllImpl: TransformImpl = {\n namespace: '@origints/yaml',\n name: 'parseYamlAll',\n\n async execute(input: unknown, args?: unknown): Promise<YamlNode[]> {\n const options = (args as YamlParseOptions) ?? {}\n const yamlOptions = toYamlParseOptions(options)\n\n let content: string\n if (typeof input === 'string') {\n content = input\n } else if (input instanceof ReadableStream) {\n content = await streamToString(input)\n } else {\n throw new Error(\n `parseYamlAll expects string or stream input, got ${typeof input}`\n )\n }\n\n const docs = parseAllDocuments(content, yamlOptions)\n\n // Check for errors in any document\n for (const doc of docs) {\n if (doc.errors.length > 0) {\n const error = doc.errors[0]\n throw new Error(`YAML parse error: ${error.message}`)\n }\n }\n\n return docs.map(doc => YamlNode.fromDocument(doc))\n },\n}\n\n/**\n * Convert our options to yaml library options.\n * Note: maxAliasCount is used during toJS conversion, not during parsing.\n */\nfunction toYamlParseOptions(\n options: YamlParseOptions\n): ParseOptions & DocumentOptions {\n return {\n uniqueKeys: options.duplicateKeys !== 'last',\n keepSourceTokens: true, // Needed for position tracking\n version: options.version ?? '1.2',\n }\n}\n","/**\n * Runtime executor for YamlSpec — walks spec steps against a YamlNode.\n *\n * @module yaml/yaml-spec-executor\n */\n\nimport type { ExtractionResult } from '@origints/core'\nimport type { YamlSpec } from './yaml-spec'\nimport type { YamlNode } from './yaml-node'\n\nfunction success<T>(value: T): ExtractionResult<T> {\n return { ok: true, value, path: [] }\n}\n\nfunction failure(message: string): ExtractionResult<never> {\n return { ok: false, kind: 'format', message, path: [] }\n}\n\n/**\n * Execute a YamlSpec against data (expected to be a YamlNode).\n */\nexport function executeYamlSpec(\n spec: YamlSpec,\n data: unknown\n): ExtractionResult<unknown> {\n if (spec.kind !== 'extract' || spec.format !== 'yaml') {\n return failure(\n `Expected spec kind \"extract\" with format \"yaml\", got kind \"${spec.kind}\" format \"${(spec as YamlSpec).format}\"`\n )\n }\n\n let node = data as YamlNode\n\n for (const step of spec.steps) {\n switch (step.kind) {\n case 'get': {\n const result = node.get(step.key)\n if (!result.ok)\n return failure(\n `YAML navigation failed at get(\"${step.key}\"): ${result.failure.message}`\n )\n node = result.value\n break\n }\n case 'at': {\n const result = node.at(step.index)\n if (!result.ok)\n return failure(\n `YAML navigation failed at at(${step.index}): ${result.failure.message}`\n )\n node = result.value\n break\n }\n }\n }\n\n switch (spec.extract) {\n case 'string': {\n const result = node.asString()\n if (!result.ok)\n return failure(`YAML extraction failed: ${result.failure.message}`)\n return success(result.value)\n }\n case 'number': {\n const result = node.asNumber()\n if (!result.ok)\n return failure(`YAML extraction failed: ${result.failure.message}`)\n return success(result.value)\n }\n case 'boolean': {\n const result = node.asBoolean()\n if (!result.ok)\n return failure(`YAML extraction failed: ${result.failure.message}`)\n return success(result.value)\n }\n case 'null': {\n const result = node.asNull()\n if (!result.ok)\n return failure(`YAML extraction failed: ${result.failure.message}`)\n return success(result.value)\n }\n case 'items': {\n const result = node.items()\n if (!result.ok)\n return failure(`YAML extraction failed: ${result.failure.message}`)\n return success(result.value)\n }\n }\n}\n","/**\n * Conversion from YamlNode to JSON.\n *\n * @module yaml/convert\n */\n\nimport {\n Document,\n Node as YamlAstNode,\n isScalar,\n isMap,\n isSeq,\n isAlias,\n isPair,\n} from 'yaml'\nimport { YamlNode } from './yaml-node'\nimport { YamlResult, ok, fail, YamlPath, SourcePosition } from './yaml-result'\n\n/**\n * JSON value type (mirrors @origints/core JsonValue).\n */\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | JsonValue[]\n | { [key: string]: JsonValue }\n\n/**\n * Convert a YamlNode to a plain JSON value.\n *\n * This conversion:\n * - Resolves all aliases\n * - Strips tags, comments, and anchors\n * - Converts all values to JSON-compatible types\n *\n * @param node The YamlNode to convert\n * @returns A JSON value\n */\nexport function toJsonValue(node: YamlNode): YamlResult<JsonValue> {\n const raw = node.unwrap()\n\n if (!isJsonCompatible(raw)) {\n return fail(\n 'type',\n `Cannot convert YAML value to JSON: ${typeof raw}`,\n node.path,\n node.position\n )\n }\n\n return ok(raw as JsonValue, node.path)\n}\n\n/**\n * Check if a value is JSON-compatible.\n */\nfunction isJsonCompatible(value: unknown): boolean {\n if (value === null) return true\n if (typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (typeof value === 'string') return true\n if (Array.isArray(value)) return value.every(isJsonCompatible)\n if (typeof value === 'object') {\n return Object.values(value).every(isJsonCompatible)\n }\n return false\n}\n\n/**\n * Options for YAML to JSON conversion.\n */\nexport interface ToJsonOptions {\n /**\n * How to handle non-JSON-compatible values (Infinity, NaN, undefined).\n * - 'error': Throw an error (default)\n * - 'null': Convert to null\n * - 'string': Convert to string representation\n */\n nonJsonValues?: 'error' | 'null' | 'string'\n\n /**\n * How to handle Date objects.\n * - 'iso': Convert to ISO 8601 string (default)\n * - 'timestamp': Convert to Unix timestamp (number)\n * - 'preserve': Keep as Date object (not JSON-compatible)\n */\n dates?: 'iso' | 'timestamp' | 'preserve'\n}\n\n/**\n * Convert a YamlNode to JSON with options.\n * This walks the AST to properly handle Date objects and other YAML-specific types.\n */\nexport function toJson(\n node: YamlNode,\n options: ToJsonOptions = {}\n): YamlResult<JsonValue> {\n // Access internal AST for proper type handling\n const internal = node as unknown as {\n node: YamlAstNode | null\n doc: Document\n }\n return convertAstNode(internal.node, internal.doc, node.path, options)\n}\n\nfunction convertAstNode(\n astNode: YamlAstNode | null,\n doc: Document,\n path: YamlPath,\n options: ToJsonOptions\n): YamlResult<JsonValue> {\n if (astNode === null) return ok(null, path)\n\n // Handle aliases by resolving them\n if (isAlias(astNode)) {\n const resolved = astNode.resolve(doc)\n if (!resolved) {\n return fail(\n 'anchor',\n `Unresolved alias: ${astNode.source}`,\n path,\n getPosition(astNode)\n )\n }\n return convertAstNode(resolved, doc, path, options)\n }\n\n // Handle scalars\n if (isScalar(astNode)) {\n const value = astNode.value\n\n if (value === null) return ok(null, path)\n if (typeof value === 'boolean') return ok(value, path)\n if (typeof value === 'string') return ok(value, path)\n\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n switch (options.nonJsonValues ?? 'error') {\n case 'null':\n return ok(null, path)\n case 'string':\n return ok(String(value), path)\n default:\n return fail(\n 'type',\n `Cannot convert ${value} to JSON`,\n path,\n getPosition(astNode)\n )\n }\n }\n return ok(value, path)\n }\n\n if (value instanceof Date) {\n switch (options.dates ?? 'iso') {\n case 'iso':\n return ok(value.toISOString(), path)\n case 'timestamp':\n return ok(value.getTime(), path)\n default:\n return fail(\n 'type',\n 'Date objects are not JSON-compatible',\n path,\n getPosition(astNode)\n )\n }\n }\n\n // Fallback for other scalar types\n return ok(String(value), path)\n }\n\n // Handle sequences\n if (isSeq(astNode)) {\n const result: JsonValue[] = []\n for (let i = 0; i < astNode.items.length; i++) {\n const item = astNode.items[i] as YamlAstNode | null\n const itemPath = [...path, i] as YamlPath\n const itemResult = convertAstNode(item, doc, itemPath, options)\n if (!itemResult.ok) return itemResult\n result.push(itemResult.value)\n }\n return ok(result, path)\n }\n\n // Handle mappings\n if (isMap(astNode)) {\n const result: { [key: string]: JsonValue } = {}\n for (const pair of astNode.items) {\n if (!isPair(pair)) continue\n\n // Get key (handle scalar keys, resolve alias keys)\n let key: string\n const keyNode = pair.key as YamlAstNode | null\n if (keyNode === null) {\n key = 'null'\n } else if (isAlias(keyNode)) {\n const resolvedKey = keyNode.resolve(doc)\n if (resolvedKey && isScalar(resolvedKey)) {\n key = String(resolvedKey.value)\n } else {\n key = String(keyNode.source)\n }\n } else if (isScalar(keyNode)) {\n key = String(keyNode.value)\n } else {\n // Complex keys - recursively convert and stringify\n const keyResult = convertAstNode(keyNode, doc, path, options)\n if (!keyResult.ok) return keyResult\n key = JSON.stringify(keyResult.value)\n }\n\n const valuePath = [...path, key] as YamlPath\n const valueNode = pair.value as YamlAstNode | null\n const valueResult = convertAstNode(valueNode, doc, valuePath, options)\n if (!valueResult.ok) return valueResult\n result[key] = valueResult.value\n }\n return ok(result, path)\n }\n\n // Should not reach here - all YAML node types are handled above\n return fail('type', 'Unexpected YAML node type', path, undefined)\n}\n\nfunction getPosition(node: YamlAstNode): SourcePosition | undefined {\n if (!node.range) return undefined\n const [startOffset, endOffset] = node.range\n return {\n start: { line: 0, column: 0, offset: startOffset },\n end: { line: 0, column: 0, offset: endOffset },\n }\n}\n","/**\n * @origints/yaml - YAML parsing for Origins with anchor/alias/tag preservation.\n *\n * @packageDocumentation\n */\n\n// Re-export types\nexport type {\n YamlPath,\n YamlFailure,\n YamlFailureKind,\n YamlResult,\n SourcePosition,\n} from './yaml-result'\nexport { ok, fail, formatYamlPath } from './yaml-result'\n\n// Re-export YamlNode\nexport type { YamlNodeType } from './yaml-node'\nexport { YamlNode } from './yaml-node'\n\n// Re-export parse functions and implementations\nexport type { YamlParseOptions } from './parse'\nexport {\n parseYaml,\n parseYamlAll,\n parseYamlImpl,\n parseYamlAsyncImpl,\n parseYamlAllImpl,\n} from './parse'\n\n// Spec types and builders\nexport type { YamlSpec, YamlStep, YamlExtract } from './yaml-spec'\nexport { YamlSpecBuilder } from './yaml-spec-builder'\nexport { executeYamlSpec } from './yaml-spec-executor'\n\n// Re-export conversion utilities\nexport type { JsonValue, ToJsonOptions } from './convert'\nexport { toJson, toJsonValue } from './convert'\n\n// Re-export utilities\nexport { streamToString } from './util'\n\n// ---------------------------------------------------------------------------\n// Auto-registration of transforms\n// ---------------------------------------------------------------------------\n\nimport { globalRegistry, registerSpecExecutor } from '@origints/core'\nimport { parseYamlAsyncImpl, parseYamlAllImpl } from './parse'\nimport { executeYamlSpec as _executeYamlSpec } from './yaml-spec-executor'\nimport type { YamlSpec } from './yaml-spec'\n\n/**\n * Register the YAML transforms with a registry.\n * Call this to enable parseYaml() and parseYamlAll() in your plans.\n *\n * @example\n * ```ts\n * import { globalRegistry } from '@origints/core'\n * import { registerYamlTransforms } from '@origints/yaml'\n *\n * registerYamlTransforms(globalRegistry)\n * ```\n */\nexport function registerYamlTransforms(registry: {\n register(impl: {\n namespace: string\n name: string\n execute: (...args: unknown[]) => unknown\n }): void\n}): void {\n registry.register(parseYamlAsyncImpl)\n registry.register(parseYamlAllImpl)\n}\n\n// Auto-register transforms\nregisterYamlTransforms(globalRegistry)\nregisterSpecExecutor('yaml', (spec, data) =>\n _executeYamlSpec(spec as YamlSpec, data)\n)\n"],"names":["ok","value","path","fail","kind","message","position","formatYamlPath","p","YamlNode","node","_path","doc","TYPE_LABEL","startOffset","endOffset","isAlias","isMap","isSeq","root","obj","current","segment","isScalar","resolved","key","pair","item","isPair","k","newPath","index","keys","entries","items","i","typeOf","entriesResult","mapping","buildSpec","steps","extract","YamlSpecBuilder","itemMapper","itemSpec","streamToString","stream","reader","decoder","chunks","done","parseYaml","options","parseYamlAll","parseYamlImpl","input","args","yamlOptions","toYamlParseOptions","content","parseDocument","error","parseYamlAsyncImpl","parseYamlAllImpl","docs","parseAllDocuments","success","failure","executeYamlSpec","spec","data","step","result","toJsonValue","raw","isJsonCompatible","toJson","internal","convertAstNode","astNode","getPosition","itemPath","itemResult","keyNode","resolvedKey","keyResult","valuePath","valueNode","valueResult","registerYamlTransforms","registry","globalRegistry","registerSpecExecutor","_executeYamlSpec"],"mappings":"oIAmDO,SAASA,EAAMC,EAAUC,EAA+B,CAC7D,MAAO,CAAE,GAAI,GAAM,MAAAD,EAAO,KAAAC,CAAA,CAC5B,CAKO,SAASC,EACdC,EACAC,EACAH,EACAI,EACmB,CACnB,MAAO,CACL,GAAI,GACJ,QAAS,CAAE,KAAAF,EAAM,QAAAC,EAAS,KAAAH,EAAM,SAAAI,CAAA,CAAS,CAE7C,CAKO,SAASC,EAAeL,EAAwB,CACrD,OAAIA,EAAK,SAAW,EAAU,OACvBA,EACJ,IAAIM,GAAM,OAAOA,GAAM,SAAW,IAAIA,CAAC,IAAM,IAAIA,CAAC,EAAG,EACrD,KAAK,EAAE,EACP,QAAQ,MAAO,EAAE,CACtB,CCzCO,MAAMC,CAAS,CAKZ,YACWC,EACAC,EACAC,EACjB,CAHiB,KAAA,KAAAF,EACA,KAAA,MAAAC,EACA,KAAA,IAAAC,CAChB,CARH,IAAKC,EAAAA,U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9
9
|
export { YamlNode } from './yaml-node';
|
|
10
10
|
export type { YamlParseOptions } from './parse';
|
|
11
11
|
export { parseYaml, parseYamlAll, parseYamlImpl, parseYamlAsyncImpl, parseYamlAllImpl, } from './parse';
|
|
12
|
+
export type { YamlSpec, YamlStep, YamlExtract } from './yaml-spec';
|
|
13
|
+
export { YamlSpecBuilder } from './yaml-spec-builder';
|
|
14
|
+
export { executeYamlSpec } from './yaml-spec-executor';
|
|
12
15
|
export type { JsonValue, ToJsonOptions } from './convert';
|
|
13
16
|
export { toJson, toJsonValue } from './convert';
|
|
14
17
|
export { streamToString } from './util';
|