@dsillman2000/yaml-reference-ts 1.0.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,8 +4,9 @@ A Node.js TypeScript library for resolving YAML documents containing `!reference
4
4
 
5
5
  ## Features
6
6
 
7
- - **Custom YAML Tags**: Support for `!reference` and `!reference-all` tags
7
+ - **Custom YAML Tags**: Support for `!reference`, `!reference-all`, and `!flatten` tags
8
8
  - **Recursive Resolution**: Automatically resolves nested references
9
+ - **Sequence Flattening**: `!flatten` tag for flattening nested arrays
9
10
  - **Circular Reference Detection**: Prevents infinite loops with proper error messages
10
11
  - **Glob Pattern Support**: `!reference-all` supports glob patterns for multiple files
11
12
  - **CLI Interface**: Command-line tool for resolving YAML files
@@ -13,7 +14,7 @@ A Node.js TypeScript library for resolving YAML documents containing `!reference
13
14
 
14
15
  ## Spec
15
16
 
16
- This Node.js TypeScript library implements the YAML specification for cross-file references in YAML files using tags `!reference` and `!reference-all` as defined in the [yaml-reference-specs project](https://github.com/dsillman2000/yaml-reference-specs).
17
+ This Node.js TypeScript library implements the YAML specification for cross-file references in YAML files using tags `!reference`, `!reference-all` and `!flatten` tags as defined in the [yaml-reference-specs project](https://github.com/dsillman2000/yaml-reference-specs).
17
18
 
18
19
  ## Installation
19
20
 
@@ -51,7 +52,21 @@ configs: !reference-all
51
52
  files: !reference-all {glob: ./data/*.yaml}
52
53
  ```
53
54
 
54
- **Note**: Only mapping syntax is supported. Be sure to conform to the API (`!reference {path: <path>}` or `!reference-all {glob: <glob>}`).
55
+ ### Sequence Flattening
56
+
57
+ ```yaml
58
+ # Block sequence syntax
59
+ data: !flatten
60
+ - 1
61
+ - [2, 3]
62
+ - !reference
63
+ path: ./config/item.yaml
64
+
65
+ # Inline sequence syntax
66
+ simple: !flatten [1, 2, 3]
67
+ ```
68
+
69
+ **Note**: For `!reference` and `!reference-all` tags, only mapping syntax is supported. Be sure to conform to the API (`!reference {path: <path>}` or `!reference-all {glob: <glob>}`). For `!flatten` tags, only sequence syntax is supported.
55
70
 
56
71
  **Deterministic Ordering**: The `!reference-all` tag resolves files in alphabetical order to ensure consistent, predictable results across different systems and runs.
57
72
 
@@ -74,17 +89,17 @@ async function loadConfig() {
74
89
 
75
90
  ### API Reference
76
91
 
77
- #### `loadYamlWithReferences(filePath: string): Promise<any>`
78
- Loads a YAML file and resolves all `!reference` and `!reference-all` tags, returning the fully resolved object.
92
+ #### `loadYamlWithReferences(filePath: string, allowPaths?: string[]): Promise<any>`
93
+ Loads a YAML file and resolves all `!reference`, `!reference-all`, and `!flatten` tags, returning the fully resolved object. The optional `allowPaths` parameter restricts which directories can be referenced (see Path Restrictions section).
79
94
 
80
95
  #### `parseYamlWithReferences(content: string, filePath: string): Promise<any>`
81
- Parses YAML content with custom tags, setting `_location` on Reference objects.
96
+ Parses YAML content with custom tags, setting `_location` on Reference and parsing Flatten objects.
82
97
 
83
- #### `loadYamlWithReferencesSync(filePath: string): any`
84
- Loads a YAML file and resolves all `!reference` and `!reference-all` tags, returning the fully resolved object synchronously.
98
+ #### `loadYamlWithReferencesSync(filePath: string, allowPaths?: string[]): any`
99
+ Loads a YAML file and resolves all `!reference`, `!reference-all`, and `!flatten` tags, returning the fully resolved object synchronously. The optional `allowPaths` parameter restricts which directories can be referenced (see Path Restrictions section).
85
100
 
86
101
  #### `parseYamlWithReferencesSync(content: string, filePath: string): any`
87
- Parses YAML content with custom tags, setting `_location` on Reference objects synchronously.
102
+ Parses YAML content with custom tags, setting `_location` on Reference and parsing Flatten objects synchronously.
88
103
 
89
104
  #### `Reference` Class
90
105
  Represents a `!reference` tag with properties:
@@ -96,6 +111,10 @@ Represents a `!reference-all` tag with properties:
96
111
  - `_location`: Absolute path to the file containing the reference
97
112
  - `glob`: Glob pattern to match YAML files
98
113
 
114
+ #### `Flatten` Class
115
+ Represents a `!flatten` tag with properties:
116
+ - `sequence`: The sequence to be flattened (can contain nested arrays, Reference, and ReferenceAll objects)
117
+
99
118
  ## CLI Usage
100
119
 
101
120
  The package includes a CLI tool called `yaml-reference-cli`:
@@ -113,6 +132,9 @@ With other files containing valid YAML data, then we can use the CLI to visualiz
113
132
  ```bash
114
133
  # Basic usage (resolve references, stdout as json)
115
134
  $ yaml-reference-cli config.yaml
135
+
136
+ # Allow references to specific directory outside the current directory
137
+ $ yaml-reference-cli config.yaml --allow ../../my-dependency
116
138
  {
117
139
  "connections": [
118
140
  {
@@ -137,6 +159,9 @@ $ yaml-reference-cli config.yaml
137
159
  }
138
160
  # Pipe to a file
139
161
  $ yaml-reference-cli config.yaml > .compiled/config.json
162
+
163
+ # With allowed paths
164
+ $ yaml-reference-cli config.yaml --allow ../shared-configs > .compiled/config.json
140
165
  ```
141
166
 
142
167
  If you have the `yq` CLI installed ([mikefarah/yq](https://github.com/mikefarah/yq)), resolved YAML can be pretty-printed as well (with keys sorted):
@@ -144,6 +169,9 @@ If you have the `yq` CLI installed ([mikefarah/yq](https://github.com/mikefarah/
144
169
  ```bash
145
170
  # Basic usage (resolve references, stdout as json, convert to YAML)
146
171
  $ yaml-reference-cli config.yaml | yq -P
172
+
173
+ # With allowed paths
174
+ $ yaml-reference-cli config.yaml --allow ../../external-configs | yq -P
147
175
  connections:
148
176
  - name: payments_pg
149
177
  type: postgres
@@ -156,6 +184,9 @@ $ yaml-reference-cli config.yaml | yq -P
156
184
  type: service
157
185
  # Pipe to a file
158
186
  $ yaml-reference-cli config.yaml | yq -P > .compiled/config.yaml
187
+
188
+ # With allowed paths
189
+ $ yaml-reference-cli config.yaml --allow ../app/configs | yq -P > .compiled/config.yaml
159
190
  ```
160
191
 
161
192
  This basic CLI usage is also explained in the help message.
@@ -164,36 +195,81 @@ This basic CLI usage is also explained in the help message.
164
195
  yaml-reference-cli --help
165
196
  ```
166
197
 
198
+ The CLI supports restricting which directories can be referenced using the `--allow` option:
199
+
200
+ ```bash
201
+ # Allow references to parent directory
202
+ yaml-reference-cli config.yaml --allow ..
203
+
204
+ # Multiple allowed paths
205
+ yaml-reference-cli config.yaml --allow ../shared --allow ../../common
206
+ ```
207
+
167
208
  ### CLI Output
168
209
  The CLI outputs JSON with:
169
210
  - Keys sorted alphabetically
170
211
  - 2-space indentation
171
212
  - Exit code 0 for success, 1 for errors
172
213
 
214
+ ## Path Restrictions
215
+
216
+ By default, references are only allowed within the directory containing the loaded YAML file and its subdirectories. This provides security by preventing references to files outside the expected scope.
217
+
218
+ ### Default Behavior
219
+ - When no `allowPaths` are specified, only files within the same directory as the loaded file (and its subdirectories) can be referenced
220
+ - The parent directory of the loaded file is automatically included in allowed paths
221
+
222
+ ### Using `allowPaths` Parameter
223
+ To allow references to files in other directories, provide an `allowPaths` array when calling `loadYamlWithReferences()`:
224
+
225
+ ```typescript
226
+ // Allow references to files in /etc/config and /var/lib/config
227
+ const resolved = await loadYamlWithReferences('./config/main.yaml', [
228
+ '../../../shared/config',
229
+ ]);
230
+ ```
231
+
232
+ ### Path Validation Rules
233
+ 1. **Relative Paths Only**: `!reference` and `!reference-all` tags must use relative paths (absolute paths will throw an error)
234
+ 2. **Directory-based Allowance**: A reference is allowed if the target file's absolute path starts with any of the allowed directory paths
235
+ 3. **Automatic Inclusion**: The parent directory of the loaded file is always included in allowed paths, even when `allowPaths` is provided
236
+
173
237
  ## Resolution Rules
174
238
 
175
239
  ### For `!reference` tags:
176
- 1. The `path` property is parsed from the YAML mapping
240
+ 1. The `path` property is parsed from the YAML mapping (must be a relative path)
177
241
  2. `_location` is automatically set to the absolute path of the containing file
178
242
  3. The referenced YAML file is read and parsed relative to `_location`
179
- 4. Any references within the referenced file are recursively resolved
180
- 5. The `Reference` object is replaced with the resolved content
243
+ 4. The target path is checked against allowed paths (see Path Restrictions)
244
+ 5. Any references within the referenced file are recursively resolved
245
+ 6. The `Reference` object is replaced with the resolved content
181
246
 
182
247
  ### For `!reference-all` tags:
183
- 1. The `glob` property is parsed from the YAML mapping
248
+ 1. The `glob` property is parsed from the YAML mapping (must be a relative glob pattern)
184
249
  2. `_location` is automatically set to the absolute path of the containing file
185
250
  3. The glob pattern is evaluated relative to `_location`
186
- 4. For each matching YAML file:
251
+ 4. Matching files are filtered based on allowed paths (see Path Restrictions)
252
+ 5. For each matching YAML file:
187
253
  - The file is read and parsed
188
254
  - Any references are recursively resolved
189
- 5. The `ReferenceAll` object is replaced with an array of resolved contents
190
- 6. Files are sorted and resolved in deterministic alphabetical order for consistent results across systems
191
- 7. If no files match, an error is thrown
255
+ 6. The `ReferenceAll` object is replaced with an array of resolved contents
256
+ 7. Files are sorted and resolved in deterministic alphabetical order for consistent results across systems
257
+ 8. If no files match, an error is thrown
258
+
259
+ ### For `!flatten` tags:
260
+ 1. The sequence is parsed from the YAML (must be a sequence/array)
261
+ 3. The sequence is recursively flattened:
262
+ - Nested arrays are flattened into a single-level array
263
+ - `Reference` and `ReferenceAll` objects are resolved first, then flattened
264
+ - Other values are preserved as-is
265
+ 4. The `Flatten` object is replaced with the flattened array. No elements of the resulting array are themselves arrays.
192
266
 
193
267
  **Deterministic Behavior**: The library ensures predictable output by:
194
268
  - Sorting `!reference-all` file matches alphabetically before resolution
195
- - Rejecting scalar syntax (only mapping syntax is allowed)
269
+ - Rejecting scalar syntax for `!reference` and `!reference-all` tags (only mapping syntax is allowed)
270
+ - Rejecting mapping syntax for `!flatten` tags (only sequence syntax is allowed)
196
271
  - Using consistent error messages for validation failures
272
+ - Enforcing path restrictions to prevent unauthorized file access
197
273
 
198
274
  ## Error Handling
199
275
 
@@ -203,6 +279,9 @@ The library throws descriptive errors for:
203
279
  - Circular references (detected via visited file path tracking)
204
280
  - Invalid glob patterns
205
281
  - Missing required properties (`path` for `!reference`, `glob` for `!reference-all`)
282
+ - Absolute paths in `!reference` or `!reference-all` tags (only relative paths are allowed)
283
+ - References to files outside allowed paths
284
+ - `!flatten` tag applied to non-sequence values
206
285
 
207
286
  ## Development
208
287
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Flatten class representing a !flatten tag in YAML
3
+ * This class is instantiated when the YAML parser encounters a !flatten tag
4
+ * The !flatten tag should be applied to Sequence nodes to flatten nested arrays
5
+ */
6
+ export declare class Flatten {
7
+ /**
8
+ * The sequence to be flattened
9
+ * This contains the raw parsed YAML document sequence
10
+ */
11
+ sequence: any[];
12
+ /**
13
+ * Creates a new Flatten instance
14
+ * @param sequence - The sequence to be flattened
15
+ * @param location - Absolute path to the file containing this flatten tag (optional, will be set later)
16
+ */
17
+ constructor(sequence: any[]);
18
+ /**
19
+ * Returns a string representation of the Flatten
20
+ */
21
+ toString(): string;
22
+ }
23
+ //# sourceMappingURL=Flatten.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flatten.d.ts","sourceRoot":"","sources":["../src/Flatten.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,OAAO;IAChB;;;OAGG;IACH,QAAQ,EAAE,GAAG,EAAE,CAAC;IAEhB;;;;OAIG;gBACS,QAAQ,EAAE,GAAG,EAAE;IAI3B;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUrB"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Flatten = void 0;
4
+ /**
5
+ * Flatten class representing a !flatten tag in YAML
6
+ * This class is instantiated when the YAML parser encounters a !flatten tag
7
+ * The !flatten tag should be applied to Sequence nodes to flatten nested arrays
8
+ */
9
+ class Flatten {
10
+ /**
11
+ * Creates a new Flatten instance
12
+ * @param sequence - The sequence to be flattened
13
+ * @param location - Absolute path to the file containing this flatten tag (optional, will be set later)
14
+ */
15
+ constructor(sequence) {
16
+ this.sequence = sequence;
17
+ }
18
+ /**
19
+ * Returns a string representation of the Flatten
20
+ */
21
+ toString() {
22
+ return `Flatten { sequence: ${JSON.stringify(this.sequence)} }`;
23
+ }
24
+ /**
25
+ * Custom inspection method for Node.js console
26
+ */
27
+ [Symbol.for("nodejs.util.inspect.custom")]() {
28
+ return this.toString();
29
+ }
30
+ }
31
+ exports.Flatten = Flatten;
32
+ //# sourceMappingURL=Flatten.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flatten.js","sourceRoot":"","sources":["../src/Flatten.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,OAAO;IAOhB;;;;OAIG;IACH,YAAY,QAAe;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,uBAAuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AA7BD,0BA6BC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../src/Reference.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,SAAS;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAK3C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUrB"}
1
+ {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../src/Reference.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,SAAS;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAiB3C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUrB"}
package/dist/Reference.js CHANGED
@@ -1,6 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.Reference = void 0;
37
+ const pathModule = __importStar(require("path"));
4
38
  /**
5
39
  * Reference class representing a !reference tag in YAML
6
40
  * This class is instantiated when the YAML parser encounters a !reference tag
@@ -12,6 +46,14 @@ class Reference {
12
46
  * @param location - Absolute path to the file containing this reference (optional, will be set later)
13
47
  */
14
48
  constructor(path, location) {
49
+ // Ensure path is not empty
50
+ if (!path || path.length === 0) {
51
+ throw new Error("Reference path must not be empty");
52
+ }
53
+ // Validate that path is not absolute
54
+ if (path && path.length > 0 && pathModule.isAbsolute(path)) {
55
+ throw new Error(`Reference path must be relative, not absolute: "${path}"`);
56
+ }
15
57
  this.path = path;
16
58
  this._location = location || "";
17
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Reference.js","sourceRoot":"","sources":["../src/Reference.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,SAAS;IAalB;;;;OAIG;IACH,YAAY,IAAY,EAAE,QAAiB;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,sBAAsB,IAAI,CAAC,IAAI,kBAAkB,IAAI,CAAC,SAAS,KAAK,CAAC;IAChF,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AApCD,8BAoCC"}
1
+ {"version":3,"file":"Reference.js","sourceRoot":"","sources":["../src/Reference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC;;;GAGG;AACH,MAAa,SAAS;IAalB;;;;OAIG;IACH,YAAY,IAAY,EAAE,QAAiB;QACvC,2BAA2B;QAC3B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACxD,CAAC;QAED,qCAAqC;QACrC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CACX,mDAAmD,IAAI,GAAG,CAC7D,CAAC;QACN,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,sBAAsB,IAAI,CAAC,IAAI,kBAAkB,IAAI,CAAC,SAAS,KAAK,CAAC;IAChF,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AAhDD,8BAgDC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReferenceAll.d.ts","sourceRoot":"","sources":["../src/ReferenceAll.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,YAAY;IACrB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAK3C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUrB"}
1
+ {"version":3,"file":"ReferenceAll.d.ts","sourceRoot":"","sources":["../src/ReferenceAll.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,YAAY;IACrB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAiB3C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAUrB"}
@@ -1,6 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.ReferenceAll = void 0;
37
+ const pathModule = __importStar(require("path"));
4
38
  /**
5
39
  * ReferenceAll class representing a !reference-all tag in YAML
6
40
  * This class is instantiated when the YAML parser encounters a !reference-all tag
@@ -12,6 +46,14 @@ class ReferenceAll {
12
46
  * @param location - Absolute path to the file containing this reference (optional, will be set later)
13
47
  */
14
48
  constructor(glob, location) {
49
+ // Ensure glob is not empty
50
+ if (!glob || glob.length === 0) {
51
+ throw new Error("ReferenceAll glob must not be empty");
52
+ }
53
+ // Validate that glob is not absolute
54
+ if (glob && glob.length > 0 && pathModule.isAbsolute(glob)) {
55
+ throw new Error(`ReferenceAll glob must be relative, not absolute: "${glob}"`);
56
+ }
15
57
  this.glob = glob;
16
58
  this._location = location || "";
17
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReferenceAll.js","sourceRoot":"","sources":["../src/ReferenceAll.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,YAAY;IAarB;;;;OAIG;IACH,YAAY,IAAY,EAAE,QAAiB;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,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AC;CACJ;AAhDD,oCAgDC"}
package/dist/cli/index.js CHANGED
@@ -48,13 +48,14 @@ function showHelp() {
48
48
  console.log(`
49
49
  YAML Reference Resolver CLI
50
50
 
51
- Usage: yaml-reference-cli <file_path>
51
+ Usage: yaml-reference-cli <file_path> [--allow <path1> --allow <path2>...]
52
52
 
53
53
  Resolves !reference and !reference-all tags in YAML files and outputs
54
54
  the resolved JSON to stdout.
55
55
 
56
56
  Arguments:
57
57
  file_path Path to YAML file containing references (required)
58
+ allow_paths Paths to allow references to (optional)
58
59
 
59
60
  Options:
60
61
  -h, --help Show this help message
@@ -69,7 +70,7 @@ Examples:
69
70
 
70
71
  Exit Codes:
71
72
  0 - Success
72
- 1 - General error (file not found, invalid YAML, circular reference, etc.)
73
+ 1 - General error (file not found or not allowed, invalid YAML, circular reference, etc.)
73
74
  `);
74
75
  }
75
76
  /**
@@ -100,20 +101,43 @@ async function main() {
100
101
  showHelp();
101
102
  process.exit(0);
102
103
  }
104
+ // Parse arguments
105
+ let filePath = null;
106
+ const allowPaths = [];
107
+ for (let i = 0; i < args.length; i++) {
108
+ const arg = args[i];
109
+ if (arg === "--allow") {
110
+ if (i + 1 >= args.length) {
111
+ console.error("Error: --allow requires a path argument");
112
+ console.error("Usage: yaml-reference-cli <file_path> [--allow <path1> --allow <path2>...]");
113
+ console.error("Use -h or --help for more information");
114
+ process.exit(1);
115
+ }
116
+ allowPaths.push(args[i + 1]);
117
+ i++; // Skip the next argument since we consumed it
118
+ }
119
+ else if (arg.startsWith("-")) {
120
+ console.error(`Error: Unknown option: ${arg}`);
121
+ console.error("Use -h or --help for more information");
122
+ process.exit(1);
123
+ }
124
+ else {
125
+ if (filePath !== null) {
126
+ console.error("Error: Multiple file paths provided");
127
+ console.error("Usage: yaml-reference-cli <file_path> [--allow <path1> --allow <path2>...]");
128
+ console.error("Use -h or --help for more information");
129
+ process.exit(1);
130
+ }
131
+ filePath = arg;
132
+ }
133
+ }
103
134
  // Check for file path argument
104
- if (args.length === 0) {
135
+ if (filePath === null) {
105
136
  console.error("Error: No file path provided");
106
- console.error("Usage: yaml-reference-cli <file_path>");
107
- console.error("Use -h or --help for more information");
108
- process.exit(1);
109
- }
110
- if (args.length > 1) {
111
- console.error("Error: Too many arguments");
112
- console.error("Usage: yaml-reference-cli <file_path>");
137
+ console.error("Usage: yaml-reference-cli <file_path> [--allow <path1> --allow <path2>...]");
113
138
  console.error("Use -h or --help for more information");
114
139
  process.exit(1);
115
140
  }
116
- const filePath = args[0];
117
141
  try {
118
142
  // Check if file exists
119
143
  await fs.access(filePath);
@@ -124,7 +148,7 @@ async function main() {
124
148
  }
125
149
  try {
126
150
  // Resolve references
127
- const resolved = await (0, resolver_1.loadAndResolve)(filePath);
151
+ const resolved = await (0, resolver_1.loadAndResolve)(filePath, allowPaths.length > 0 ? allowPaths : undefined);
128
152
  // Sort keys alphabetically
129
153
  const sorted = sortObjectKeys(resolved);
130
154
  // Output JSON with 2-space indentation
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0CAA6C;AAC7C,gDAAkC;AAElC;;GAEG;AACH,SAAS,QAAQ;IACb,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBf,CAAC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,GAAQ;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,SAAS,GAAQ,EAAE,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E,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,OAAO,CAAC,KAAK,CACT,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC3E,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,17 +3,18 @@
3
3
  */
4
4
  export { Reference } from "./Reference";
5
5
  export { ReferenceAll } from "./ReferenceAll";
6
+ export { Flatten } from "./Flatten";
6
7
  export { parseYamlWithReferencesSync, parseYamlWithReferences } from "./parser";
7
8
  /**
8
9
  * Convenience alias for loadAndResolve
9
10
  * @param filePath - Path to YAML file containing references
10
11
  * @returns Resolved object with all references resolved
11
12
  */
12
- export declare function loadYamlWithReferences(filePath: string): Promise<any>;
13
+ export declare function loadYamlWithReferences(filePath: string, allowPaths?: string[]): Promise<any>;
13
14
  /**
14
15
  * Convenience alias for loadAndResolveSync
15
16
  * @param filePath - Path to YAML file containing references
16
17
  * @returns Resolved object with all references resolved
17
18
  */
18
- export declare function loadYamlWithReferencesSync(filePath: string): any;
19
+ export declare function loadYamlWithReferencesSync(filePath: string, allowPaths?: string[]): any;
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEhF;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAEhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEhF;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,GAAG,CAAC,CAEd;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,GAAG,CAEL"}
package/dist/index.js CHANGED
@@ -3,13 +3,15 @@
3
3
  * Main exports for yaml-reference-ts library
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseYamlWithReferences = exports.parseYamlWithReferencesSync = exports.ReferenceAll = exports.Reference = void 0;
6
+ exports.parseYamlWithReferences = exports.parseYamlWithReferencesSync = exports.Flatten = exports.ReferenceAll = exports.Reference = void 0;
7
7
  exports.loadYamlWithReferences = loadYamlWithReferences;
8
8
  exports.loadYamlWithReferencesSync = loadYamlWithReferencesSync;
9
9
  var Reference_1 = require("./Reference");
10
10
  Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return Reference_1.Reference; } });
11
11
  var ReferenceAll_1 = require("./ReferenceAll");
12
12
  Object.defineProperty(exports, "ReferenceAll", { enumerable: true, get: function () { return ReferenceAll_1.ReferenceAll; } });
13
+ var Flatten_1 = require("./Flatten");
14
+ Object.defineProperty(exports, "Flatten", { enumerable: true, get: function () { return Flatten_1.Flatten; } });
13
15
  const resolver_1 = require("./resolver");
14
16
  var parser_1 = require("./parser");
15
17
  Object.defineProperty(exports, "parseYamlWithReferencesSync", { enumerable: true, get: function () { return parser_1.parseYamlWithReferencesSync; } });
@@ -19,15 +21,15 @@ Object.defineProperty(exports, "parseYamlWithReferences", { enumerable: true, ge
19
21
  * @param filePath - Path to YAML file containing references
20
22
  * @returns Resolved object with all references resolved
21
23
  */
22
- async function loadYamlWithReferences(filePath) {
23
- return await (0, resolver_1.loadAndResolve)(filePath);
24
+ async function loadYamlWithReferences(filePath, allowPaths) {
25
+ return await (0, resolver_1.loadAndResolve)(filePath, allowPaths);
24
26
  }
25
27
  /**
26
28
  * Convenience alias for loadAndResolveSync
27
29
  * @param filePath - Path to YAML file containing references
28
30
  * @returns Resolved object with all references resolved
29
31
  */
30
- function loadYamlWithReferencesSync(filePath) {
31
- return (0, resolver_1.loadAndResolveSync)(filePath);
32
+ function loadYamlWithReferencesSync(filePath, allowPaths) {
33
+ return (0, resolver_1.loadAndResolveSync)(filePath, allowPaths);
32
34
  }
33
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAYH,wDAEC;AAOD,gEAEC;AArBD,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yCAAgE;AAChE,mCAAgF;AAAvE,qHAAA,2BAA2B,OAAA;AAAE,iHAAA,uBAAuB,OAAA;AAE7D;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IACzD,OAAO,MAAM,IAAA,yBAAc,EAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAgB,0BAA0B,CAAC,QAAgB;IACvD,OAAO,IAAA,6BAAkB,EAAC,QAAQ,CAAC,CAAC;AACxC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAaH,wDAKC;AAOD,gEAKC;AA5BD,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yCAAgE;AAChE,mCAAgF;AAAvE,qHAAA,2BAA2B,OAAA;AAAE,iHAAA,uBAAuB,OAAA;AAE7D;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CACxC,QAAgB,EAChB,UAAqB;IAErB,OAAO,MAAM,IAAA,yBAAc,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAgB,0BAA0B,CACtC,QAAgB,EAChB,UAAqB;IAErB,OAAO,IAAA,6BAAkB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAgBjE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAgB5E"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkGH;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAgBjE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAgB5E"}
package/dist/parser.js CHANGED
@@ -42,6 +42,7 @@ exports.parseYamlWithReferences = parseYamlWithReferences;
42
42
  const yaml_1 = require("yaml");
43
43
  const Reference_1 = require("./Reference");
44
44
  const ReferenceAll_1 = require("./ReferenceAll");
45
+ const Flatten_1 = require("./Flatten");
45
46
  const path = __importStar(require("path"));
46
47
  const fs = __importStar(require("fs/promises"));
47
48
  const fsSync = __importStar(require("fs"));
@@ -52,18 +53,18 @@ const referenceTag = {
52
53
  identify: (value) => value instanceof Reference_1.Reference,
53
54
  tag: "!reference",
54
55
  collection: "map",
55
- resolve: (value, _) => {
56
+ resolve: (value, onError) => {
56
57
  // value should be a YAMLMap for mapping syntax
57
58
  if (!(value instanceof yaml_1.YAMLMap)) {
58
- throw new Error('!reference tag must be followed by a mapping with a "path" property');
59
+ return onError('!reference tag must be followed by a mapping with a "path" property');
59
60
  }
60
61
  // Get the path property from the map
61
62
  const pathValue = value.get("path");
62
63
  if (!pathValue) {
63
- throw new Error('!reference tag requires a "path" property');
64
+ return onError('!reference tag requires a "path" property');
64
65
  }
65
66
  if (typeof pathValue !== "string") {
66
- throw new Error('!reference "path" property must be a string');
67
+ return onError('!reference "path" property must be a string');
67
68
  }
68
69
  return new Reference_1.Reference(pathValue);
69
70
  },
@@ -75,24 +76,51 @@ const referenceAllTag = {
75
76
  identify: (value) => value instanceof ReferenceAll_1.ReferenceAll,
76
77
  tag: "!reference-all",
77
78
  collection: "map",
78
- resolve: (value, _) => {
79
- // value should be a YAMLMap for mapping syntax
80
- if (!(value instanceof yaml_1.YAMLMap)) {
81
- throw new Error('!reference-all tag must be followed by a mapping with a "glob" property');
82
- }
79
+ resolve: (value, onError) => {
83
80
  // Get the glob property from the map
84
81
  const globValue = value.get("glob");
85
- if (!globValue) {
86
- throw new Error('!reference-all tag requires a "glob" property');
82
+ if (!globValue || globValue === null) {
83
+ return onError('!reference-all tag requires a "glob" property');
87
84
  }
88
85
  if (typeof globValue !== "string") {
89
- throw new Error('!reference-all "glob" property must be a string');
86
+ return onError('!reference-all "glob" property must be a string');
90
87
  }
91
88
  return new ReferenceAll_1.ReferenceAll(globValue);
92
89
  },
93
90
  };
91
+ const referentialTags = [referenceTag, referenceAllTag];
92
+ /**
93
+ * Custom tag for !flatten
94
+ */
95
+ const flattenTag = {
96
+ identify: (value) => value instanceof Flatten_1.Flatten,
97
+ tag: "!flatten",
98
+ collection: "seq",
99
+ resolve: (value, _) => {
100
+ const sequence = new yaml_1.Document(value, {
101
+ customTags: referentialTags,
102
+ }).toJS();
103
+ return new Flatten_1.Flatten(sequence);
104
+ },
105
+ };
106
+ /**
107
+ * Dummy illegal flag when flatten is used on a mapping.
108
+ */
109
+ const illegalFlattenOnMapping = {
110
+ identify: (value) => value instanceof Flatten_1.Flatten,
111
+ tag: "!flatten",
112
+ collection: "map",
113
+ resolve: (_, onError) => {
114
+ return onError("!flatten tag cannot be used on a mapping");
115
+ },
116
+ };
94
117
  // Custom tags array for parsing
95
- const customTags = [referenceTag, referenceAllTag];
118
+ const customTags = [
119
+ referenceTag,
120
+ referenceAllTag,
121
+ flattenTag,
122
+ illegalFlattenOnMapping,
123
+ ];
96
124
  /**
97
125
  * Parse YAML content with custom !reference and !reference-all tags
98
126
  * @param filePath - Path to the YAML file to be parsed (used for setting _location)
@@ -102,7 +130,7 @@ function parseYamlWithReferencesSync(filePath) {
102
130
  try {
103
131
  const absolutePath = path.resolve(filePath);
104
132
  const content = fsSync.readFileSync(absolutePath, "utf8");
105
- const parsed = (0, yaml_1.parse)(content, { customTags });
133
+ const parsed = (0, yaml_1.parse)(content, { customTags: customTags });
106
134
  // Process the parsed document to set _location on Reference and ReferenceAll objects
107
135
  return processParsedDocument(parsed, filePath);
108
136
  }
@@ -120,7 +148,7 @@ async function parseYamlWithReferences(filePath) {
120
148
  try {
121
149
  const absolutePath = path.resolve(filePath);
122
150
  const content = await fs.readFile(absolutePath, "utf8");
123
- const parsed = (0, yaml_1.parse)(content, { customTags });
151
+ const parsed = (0, yaml_1.parse)(content, { customTags: customTags });
124
152
  // Process the parsed document to set _location on Reference and ReferenceAll objects
125
153
  return processParsedDocument(parsed, filePath);
126
154
  }
@@ -141,6 +169,10 @@ function processParsedDocument(obj, filePath) {
141
169
  obj._location = filePath;
142
170
  return obj;
143
171
  }
172
+ if (obj instanceof Flatten_1.Flatten) {
173
+ let processed = obj.sequence.map((item) => processParsedDocument(item, filePath));
174
+ return new Flatten_1.Flatten(processed);
175
+ }
144
176
  if (Array.isArray(obj)) {
145
177
  return obj.map((item) => processParsedDocument(item, filePath));
146
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EH,kEAgBC;AAOD,0DAgBC;AAhHD,+BAAsC;AACtC,2CAAwC;AACxC,iDAA8C;AAC9C,2CAA6B;AAC7B,gDAAkC;AAClC,2CAA6B;AAE7B;;GAEG;AACH,MAAM,YAAY,GAAG;IACjB,QAAQ,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,YAAY,qBAAS;IACpD,GAAG,EAAE,YAAY;IACjB,UAAU,EAAE,KAAc;IAC1B,OAAO,EAAE,CAAC,KAAU,EAAE,CAA4B,EAAE,EAAE;QAClD,+CAA+C;QAC/C,IAAI,CAAC,CAAC,KAAK,YAAY,cAAO,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACX,qEAAqE,CACxE,CAAC;QACN,CAAC;QAED,qCAAqC;QACrC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,qBAAS,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,eAA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,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -2,30 +2,40 @@
2
2
  * Resolver module for resolving !reference and !reference-all tags
3
3
  * Handles recursive resolution of references with proper path tracking
4
4
  */
5
+ /**
6
+ * Recursively flatten all arrays in an object
7
+ * @param obj - Object that may contain nested arrays
8
+ * @returns Object with all arrays flattened
9
+ */
10
+ export declare function flattenSequences(obj: any): any;
5
11
  /**
6
12
  * Load a YAML file containing references and resolve all references. (async)
7
13
  * @param filePath - Path to YAML file containing references
14
+ * @param allowPaths - Optional list of allowed paths for references
8
15
  * @returns Resolved object with all references resolved
9
16
  */
10
- export declare function loadAndResolve(filePath: string): Promise<any>;
17
+ export declare function loadAndResolve(filePath: string, allowPaths?: string[]): Promise<any>;
11
18
  /**
12
19
  * Load a YAML file containing references and resolve all references.
13
20
  * @param filePath - Path to YAML file containing references
21
+ * @param allowPaths - Optional list of allowed paths for references
14
22
  * @returns Resolved object with all references resolved
15
23
  */
16
- export declare function loadAndResolveSync(filePath: string): any;
24
+ export declare function loadAndResolveSync(filePath: string, allowPaths?: string[]): any;
17
25
  /**
18
26
  * Recursively resolve all references in an object (async)
19
27
  * @param obj - Object that may contain Reference or ReferenceAll instances
20
28
  * @param visitedPaths - Set of visited file paths to detect circular references
29
+ * @param allowPaths - Optional list of allowed paths for references
21
30
  * @returns Object with all references resolved
22
31
  */
23
- export declare function _recursivelyResolveReferences(obj: any, visitedPaths?: Set<string>): Promise<any>;
32
+ export declare function _recursivelyResolveReferences(obj: any, visitedPaths?: Set<string>, allowPaths?: string[]): Promise<any>;
24
33
  /**
25
34
  * Recursively resolve all references in an object
26
35
  * @param obj - Object that may contain Reference or ReferenceAll instances
27
36
  * @param visitedPaths - Set of visited file paths to detect circular references
37
+ * @param allowPaths - Optional list of allowed paths for references
28
38
  * @returns Object with all references resolved
29
39
  */
30
- export declare function _recursivelyResolveReferencesSync(obj: any, visitedPaths?: Set<string>): any;
40
+ export declare function _recursivelyResolveReferencesSync(obj: any, visitedPaths?: Set<string>, allowPaths?: string[]): any;
31
41
  //# sourceMappingURL=resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAGxD;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAC/C,GAAG,EAAE,GAAG,EACR,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,GACtC,OAAO,CAAC,GAAG,CAAC,CA+Bd;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC7C,GAAG,EAAE,GAAG,EACR,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,GACtC,GAAG,CA+BL"}
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqCH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CA4B9C;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAChC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,GAAG,CAAC,CASd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,GAAG,CASL;AAED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAC/C,GAAG,EAAE,GAAG,EACR,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,EACrC,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,GAAG,CAAC,CAmDd;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC7C,GAAG,EAAE,GAAG,EACR,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,EACrC,UAAU,CAAC,EAAE,MAAM,EAAE,GACtB,GAAG,CAmDL"}
package/dist/resolver.js CHANGED
@@ -37,6 +37,7 @@ var __importStar = (this && this.__importStar) || (function () {
37
37
  };
38
38
  })();
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.flattenSequences = flattenSequences;
40
41
  exports.loadAndResolve = loadAndResolve;
41
42
  exports.loadAndResolveSync = loadAndResolveSync;
42
43
  exports._recursivelyResolveReferences = _recursivelyResolveReferences;
@@ -47,49 +48,116 @@ const fsSync = __importStar(require("fs"));
47
48
  const glob_1 = require("glob");
48
49
  const Reference_1 = require("./Reference");
49
50
  const ReferenceAll_1 = require("./ReferenceAll");
51
+ const Flatten_1 = require("./Flatten");
50
52
  const parser_1 = require("./parser");
53
+ /**
54
+ * Normalize allowPaths to always include the parent directory of filePath
55
+ */
56
+ function normalizeAllowPaths(filePath, allowPaths) {
57
+ const parentDir = path.dirname(path.resolve(filePath));
58
+ const normalizedPaths = [];
59
+ // Add parent directory first
60
+ normalizedPaths.push(parentDir);
61
+ // Add any provided allowPaths that aren't already included
62
+ if (allowPaths && allowPaths.length > 0) {
63
+ for (const allowedPath of allowPaths) {
64
+ const resolvedAllowedPath = path.resolve(allowedPath);
65
+ if (!normalizedPaths.includes(resolvedAllowedPath)) {
66
+ normalizedPaths.push(resolvedAllowedPath);
67
+ }
68
+ }
69
+ }
70
+ return normalizedPaths;
71
+ }
72
+ /**
73
+ * Recursively flatten all arrays in an object
74
+ * @param obj - Object that may contain nested arrays
75
+ * @returns Object with all arrays flattened
76
+ */
77
+ function flattenSequences(obj) {
78
+ if (Array.isArray(obj)) {
79
+ const flattened = [];
80
+ for (const item of obj) {
81
+ const flattenedItem = flattenSequences(item);
82
+ if (Array.isArray(flattenedItem)) {
83
+ flattened.push(...flattenedItem);
84
+ }
85
+ else {
86
+ flattened.push(flattenedItem);
87
+ }
88
+ }
89
+ return flattened;
90
+ }
91
+ if (obj && typeof obj === "object") {
92
+ if (obj instanceof Flatten_1.Flatten) {
93
+ // Flatten the sequence inside the Flatten object
94
+ return flattenSequences(obj.sequence);
95
+ }
96
+ const result = {};
97
+ for (const [key, value] of Object.entries(obj)) {
98
+ result[key] = flattenSequences(value);
99
+ }
100
+ return result;
101
+ }
102
+ return obj;
103
+ }
51
104
  /**
52
105
  * Load a YAML file containing references and resolve all references. (async)
53
106
  * @param filePath - Path to YAML file containing references
107
+ * @param allowPaths - Optional list of allowed paths for references
54
108
  * @returns Resolved object with all references resolved
55
109
  */
56
- async function loadAndResolve(filePath) {
110
+ async function loadAndResolve(filePath, allowPaths) {
57
111
  const parsed = await (0, parser_1.parseYamlWithReferences)(filePath);
58
- return await _recursivelyResolveReferences(parsed, new Set());
112
+ const normalizedAllowPaths = normalizeAllowPaths(filePath, allowPaths);
113
+ const resolved = await _recursivelyResolveReferences(parsed, new Set(), normalizedAllowPaths);
114
+ return flattenSequences(resolved);
59
115
  }
60
116
  /**
61
117
  * Load a YAML file containing references and resolve all references.
62
118
  * @param filePath - Path to YAML file containing references
119
+ * @param allowPaths - Optional list of allowed paths for references
63
120
  * @returns Resolved object with all references resolved
64
121
  */
65
- function loadAndResolveSync(filePath) {
122
+ function loadAndResolveSync(filePath, allowPaths) {
66
123
  const parsed = (0, parser_1.parseYamlWithReferencesSync)(filePath);
67
- return _recursivelyResolveReferencesSync(parsed, new Set());
124
+ const normalizedAllowPaths = normalizeAllowPaths(filePath, allowPaths);
125
+ const resolved = _recursivelyResolveReferencesSync(parsed, new Set(), normalizedAllowPaths);
126
+ return flattenSequences(resolved);
68
127
  }
69
128
  /**
70
129
  * Recursively resolve all references in an object (async)
71
130
  * @param obj - Object that may contain Reference or ReferenceAll instances
72
131
  * @param visitedPaths - Set of visited file paths to detect circular references
132
+ * @param allowPaths - Optional list of allowed paths for references
73
133
  * @returns Object with all references resolved
74
134
  */
75
- async function _recursivelyResolveReferences(obj, visitedPaths = new Set()) {
135
+ async function _recursivelyResolveReferences(obj, visitedPaths = new Set(), allowPaths) {
76
136
  if (obj instanceof Reference_1.Reference) {
77
- return await resolveReference(obj, visitedPaths);
137
+ return await resolveReference(obj, visitedPaths, allowPaths);
78
138
  }
79
139
  if (obj instanceof ReferenceAll_1.ReferenceAll) {
80
- return await resolveReferenceAll(obj, visitedPaths);
140
+ return await resolveReferenceAll(obj, visitedPaths, allowPaths);
141
+ }
142
+ if (obj instanceof Flatten_1.Flatten) {
143
+ // Resolve references within the sequence first, then flatten will be applied later
144
+ const resolvedSequence = [];
145
+ for (const item of obj.sequence) {
146
+ resolvedSequence.push(await _recursivelyResolveReferences(item, visitedPaths, allowPaths));
147
+ }
148
+ return new Flatten_1.Flatten(resolvedSequence);
81
149
  }
82
150
  if (Array.isArray(obj)) {
83
151
  const resolvedArray = [];
84
152
  for (const item of obj) {
85
- resolvedArray.push(await _recursivelyResolveReferences(item, visitedPaths));
153
+ resolvedArray.push(await _recursivelyResolveReferences(item, visitedPaths, allowPaths));
86
154
  }
87
155
  return resolvedArray;
88
156
  }
89
157
  if (obj && typeof obj === "object") {
90
158
  const resolvedObj = {};
91
159
  for (const [key, value] of Object.entries(obj)) {
92
- resolvedObj[key] = await _recursivelyResolveReferences(value, visitedPaths);
160
+ resolvedObj[key] = await _recursivelyResolveReferences(value, visitedPaths, allowPaths);
93
161
  }
94
162
  return resolvedObj;
95
163
  }
@@ -99,26 +167,35 @@ async function _recursivelyResolveReferences(obj, visitedPaths = new Set()) {
99
167
  * Recursively resolve all references in an object
100
168
  * @param obj - Object that may contain Reference or ReferenceAll instances
101
169
  * @param visitedPaths - Set of visited file paths to detect circular references
170
+ * @param allowPaths - Optional list of allowed paths for references
102
171
  * @returns Object with all references resolved
103
172
  */
104
- function _recursivelyResolveReferencesSync(obj, visitedPaths = new Set()) {
173
+ function _recursivelyResolveReferencesSync(obj, visitedPaths = new Set(), allowPaths) {
105
174
  if (obj instanceof Reference_1.Reference) {
106
- return resolveReferenceSync(obj, visitedPaths);
175
+ return resolveReferenceSync(obj, visitedPaths, allowPaths);
107
176
  }
108
177
  if (obj instanceof ReferenceAll_1.ReferenceAll) {
109
- return resolveReferenceAllSync(obj, visitedPaths);
178
+ return resolveReferenceAllSync(obj, visitedPaths, allowPaths);
179
+ }
180
+ if (obj instanceof Flatten_1.Flatten) {
181
+ // Resolve references within the sequence first, then flatten will be applied later
182
+ const resolvedSequence = [];
183
+ for (const item of obj.sequence) {
184
+ resolvedSequence.push(_recursivelyResolveReferencesSync(item, visitedPaths, allowPaths));
185
+ }
186
+ return new Flatten_1.Flatten(resolvedSequence);
110
187
  }
111
188
  if (Array.isArray(obj)) {
112
189
  const resolvedArray = [];
113
190
  for (const item of obj) {
114
- resolvedArray.push(_recursivelyResolveReferencesSync(item, visitedPaths));
191
+ resolvedArray.push(_recursivelyResolveReferencesSync(item, visitedPaths, allowPaths));
115
192
  }
116
193
  return resolvedArray;
117
194
  }
118
195
  if (obj && typeof obj === "object") {
119
196
  const resolvedObj = {};
120
197
  for (const [key, value] of Object.entries(obj)) {
121
- resolvedObj[key] = _recursivelyResolveReferencesSync(value, visitedPaths);
198
+ resolvedObj[key] = _recursivelyResolveReferencesSync(value, visitedPaths, allowPaths);
122
199
  }
123
200
  return resolvedObj;
124
201
  }
@@ -128,15 +205,27 @@ function _recursivelyResolveReferencesSync(obj, visitedPaths = new Set()) {
128
205
  * Resolve a single Reference object (async)
129
206
  * @param ref Reference object to resolve
130
207
  * @param visitedPaths Set of visited paths to detect circular references
208
+ * @param allowPaths Optional list of allowed paths for references
131
209
  * @returns Resolved object. Will not contain any references.
132
210
  * @throws Error if circular reference is detected, or if a reference cannot be resolved
133
211
  */
134
- async function resolveReference(ref, visitedPaths) {
212
+ async function resolveReference(ref, visitedPaths, allowPaths) {
135
213
  if (!ref._location) {
136
214
  throw new Error(`Reference missing _location: ${ref.toString()}`);
137
215
  }
138
216
  const refDir = path.dirname(ref._location);
139
217
  const targetPath = path.resolve(refDir, ref.path);
218
+ // Check if path is allowed
219
+ if (allowPaths && allowPaths.length > 0) {
220
+ const isAllowed = allowPaths.some((allowedPath) => {
221
+ const resolvedAllowedPath = path.resolve(allowedPath);
222
+ const resolvedTargetPath = path.resolve(targetPath);
223
+ return resolvedTargetPath.startsWith(resolvedAllowedPath);
224
+ });
225
+ if (!isAllowed) {
226
+ throw new Error(`Reference to ${targetPath} is not allowed. Allowed paths: ${allowPaths.join(", ")}`);
227
+ }
228
+ }
140
229
  // Check for circular references
141
230
  if (visitedPaths.has(targetPath)) {
142
231
  throw new Error(`Circular reference detected: ${targetPath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
@@ -153,7 +242,7 @@ async function resolveReference(ref, visitedPaths) {
153
242
  // Load and parse the referenced file
154
243
  const parsed = await (0, parser_1.parseYamlWithReferences)(targetPath);
155
244
  // Recursively resolve references in the parsed content
156
- const resolved = await _recursivelyResolveReferences(parsed, visitedPaths);
245
+ const resolved = await _recursivelyResolveReferences(parsed, visitedPaths, allowPaths);
157
246
  // Remove from visited paths after resolution
158
247
  visitedPaths.delete(targetPath);
159
248
  return resolved;
@@ -162,15 +251,27 @@ async function resolveReference(ref, visitedPaths) {
162
251
  * Resolve a single Reference object
163
252
  * @param ref Reference object to resolve
164
253
  * @param visitedPaths Set of visited paths to detect circular references
254
+ * @param allowPaths Optional list of allowed paths for references
165
255
  * @returns Resolved object. Will not contain any references.
166
256
  * @throws Error if circular reference is detected, or if a reference cannot be resolved
167
257
  */
168
- function resolveReferenceSync(ref, visitedPaths) {
258
+ function resolveReferenceSync(ref, visitedPaths, allowPaths) {
169
259
  if (!ref._location) {
170
260
  throw new Error(`Reference missing _location: ${ref.toString()}`);
171
261
  }
172
262
  const refDir = path.dirname(ref._location);
173
263
  const targetPath = path.resolve(refDir, ref.path);
264
+ // Check if path is allowed
265
+ if (allowPaths && allowPaths.length > 0) {
266
+ const isAllowed = allowPaths.some((allowedPath) => {
267
+ const resolvedAllowedPath = path.resolve(allowedPath);
268
+ const resolvedTargetPath = path.resolve(targetPath);
269
+ return resolvedTargetPath.startsWith(resolvedAllowedPath);
270
+ });
271
+ if (!isAllowed) {
272
+ throw new Error(`Reference to ${targetPath} is not allowed. Allowed paths: ${allowPaths.join(", ")}`);
273
+ }
274
+ }
174
275
  // Check for circular references
175
276
  if (visitedPaths.has(targetPath)) {
176
277
  throw new Error(`Circular reference detected: ${targetPath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
@@ -187,7 +288,7 @@ function resolveReferenceSync(ref, visitedPaths) {
187
288
  // Load and parse the referenced file
188
289
  const parsed = (0, parser_1.parseYamlWithReferencesSync)(targetPath);
189
290
  // Recursively resolve references in the parsed content
190
- const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths);
291
+ const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths, allowPaths);
191
292
  // Remove from visited paths after resolution
192
293
  visitedPaths.delete(targetPath);
193
294
  return resolved;
@@ -196,10 +297,11 @@ function resolveReferenceSync(ref, visitedPaths) {
196
297
  * Resolve a ReferenceAll object (async)
197
298
  * @param refAll ReferenceAll object to resolve
198
299
  * @param visitedPaths Set of visited paths to detect circular references
300
+ * @param allowPaths Optional list of allowed paths for references
199
301
  * @returns Resolved array of objects. Will not contain any references.
200
302
  * @throws Error if the ReferenceAll object is missing _location or if the glob pattern is invalid.
201
303
  */
202
- async function resolveReferenceAll(refAll, visitedPaths) {
304
+ async function resolveReferenceAll(refAll, visitedPaths, allowPaths) {
203
305
  if (!refAll._location) {
204
306
  throw new Error(`ReferenceAll missing _location: ${refAll.toString()}`);
205
307
  }
@@ -215,6 +317,16 @@ async function resolveReferenceAll(refAll, visitedPaths) {
215
317
  }
216
318
  // Filter to only include YAML files
217
319
  matchingFiles = matchingFiles.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml"));
320
+ // Filter by allowed paths if specified
321
+ if (allowPaths && allowPaths.length > 0) {
322
+ matchingFiles = matchingFiles.filter((filePath) => {
323
+ const resolvedFilePath = path.resolve(filePath);
324
+ return allowPaths.some((allowedPath) => {
325
+ const resolvedAllowedPath = path.resolve(allowedPath);
326
+ return resolvedFilePath.startsWith(resolvedAllowedPath);
327
+ });
328
+ });
329
+ }
218
330
  if (matchingFiles.length === 0) {
219
331
  throw new Error(`No YAML files found matching glob pattern: ${globPattern} (from ${refAll._location})`);
220
332
  }
@@ -232,7 +344,7 @@ async function resolveReferenceAll(refAll, visitedPaths) {
232
344
  // Load and parse the file
233
345
  const parsed = await (0, parser_1.parseYamlWithReferences)(filePath);
234
346
  // Recursively resolve references
235
- const resolved = await _recursivelyResolveReferences(parsed, visitedPaths);
347
+ const resolved = await _recursivelyResolveReferences(parsed, visitedPaths, allowPaths);
236
348
  resolvedContents.push(resolved);
237
349
  }
238
350
  catch (error) {
@@ -248,10 +360,11 @@ async function resolveReferenceAll(refAll, visitedPaths) {
248
360
  * Resolve a ReferenceAll object
249
361
  * @param refAll ReferenceAll object to resolve
250
362
  * @param visitedPaths Set of visited paths to detect circular references
363
+ * @param allowPaths Optional list of allowed paths for references
251
364
  * @returns Resolved array of objects. Will not contain any references.
252
365
  * @throws Error if the ReferenceAll object is missing _location or if the glob pattern is invalid.
253
366
  */
254
- function resolveReferenceAllSync(refAll, visitedPaths) {
367
+ function resolveReferenceAllSync(refAll, visitedPaths, allowPaths) {
255
368
  if (!refAll._location) {
256
369
  throw new Error(`ReferenceAll missing _location: ${refAll.toString()}`);
257
370
  }
@@ -267,6 +380,16 @@ function resolveReferenceAllSync(refAll, visitedPaths) {
267
380
  }
268
381
  // Filter to only include YAML files
269
382
  matchingFiles = matchingFiles.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml"));
383
+ // Filter by allowed paths if specified
384
+ if (allowPaths && allowPaths.length > 0) {
385
+ matchingFiles = matchingFiles.filter((filePath) => {
386
+ const resolvedFilePath = path.resolve(filePath);
387
+ return allowPaths.some((allowedPath) => {
388
+ const resolvedAllowedPath = path.resolve(allowedPath);
389
+ return resolvedFilePath.startsWith(resolvedAllowedPath);
390
+ });
391
+ });
392
+ }
270
393
  if (matchingFiles.length === 0) {
271
394
  throw new Error(`No YAML files found matching glob pattern: ${globPattern} (from ${refAll._location})`);
272
395
  }
@@ -284,7 +407,7 @@ function resolveReferenceAllSync(refAll, visitedPaths) {
284
407
  // Load and parse the file
285
408
  const parsed = (0, parser_1.parseYamlWithReferencesSync)(filePath);
286
409
  // Recursively resolve references
287
- const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths);
410
+ const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths, allowPaths);
288
411
  resolvedContents.push(resolved);
289
412
  }
290
413
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeH,wCAGC;AAOD,gDAGC;AAQD,sEAkCC;AAQD,8EAkCC;AA9GD,2CAA6B;AAC7B,gDAAkC;AAClC,2CAA6B;AAC7B,+BAAsC;AACtC,2CAAwC;AACxC,iDAA8C;AAC9C,qCAAgF;AAEhF;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,QAAgB;IACjD,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAuB,EAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,MAAM,6BAA6B,CAAC,MAAM,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;AAC1E,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,QAAgB;IAC/C,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,QAAQ,CAAC,CAAC;IACrD,OAAO,iCAAiC,CAAC,MAAM,EAAE,IAAI,GAAG,E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,cAAc,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CACjG,CAAC;QACN,CAAC;QAED,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE3B,IAAI,CAAC;YACD,0BAA0B;YAC1B,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,QAAQ,CAAC,CAAC;YAErD,iCAAiC;YACjC,MAAM,QAAQ,GAAG,iCAAiC,CAC9C,MAAM,EACN,YAAY,EACZ,UAAU,CACb,CAAC;YACF,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,qCAAqC;YACrC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,MAAM,KAAK,CAAC;QAChB,CAAC;QAED,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsillman2000/yaml-reference-ts",
3
- "version": "1.0.6",
3
+ "version": "1.2.0",
4
4
  "description": "A Node.js TypeScript library for resolving YAML documents containing !reference and !reference-all tags",
5
5
  "repository": {
6
6
  "type": "git",