@dsillman2000/yaml-reference-ts 0.0.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 ADDED
@@ -0,0 +1,225 @@
1
+ # YAML Reference Resolver (TypeScript)
2
+
3
+ A Node.js TypeScript library for resolving YAML documents containing `!reference` and `!reference-all` tags. The library uses the `eemeli/yaml` package to parse YAML with custom tags and resolve references to external YAML files.
4
+
5
+ ## Features
6
+
7
+ - **Custom YAML Tags**: Support for `!reference` and `!reference-all` tags
8
+ - **Recursive Resolution**: Automatically resolves nested references
9
+ - **Circular Reference Detection**: Prevents infinite loops with proper error messages
10
+ - **Glob Pattern Support**: `!reference-all` supports glob patterns for multiple files
11
+ - **CLI Interface**: Command-line tool for resolving YAML files
12
+ - **TypeScript Support**: Full type definitions included
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install yaml-reference-ts
18
+ ```
19
+
20
+ Or for global CLI usage:
21
+
22
+ ```bash
23
+ npm install -g yaml-reference-ts
24
+ ```
25
+
26
+ ## YAML Syntax Examples
27
+
28
+ ### Single File Reference
29
+
30
+ ```yaml
31
+ # Block mapping syntax
32
+ database: !reference
33
+ path: ./config/database.yaml
34
+
35
+ # Inline mapping syntax
36
+ settings: !reference {path: ./settings/production.yaml}
37
+ ```
38
+
39
+ ### Multiple File Reference
40
+
41
+ ```yaml
42
+ # Block mapping syntax
43
+ configs: !reference-all
44
+ glob: ./configs/*.yaml
45
+
46
+ # Inline mapping syntax
47
+ files: !reference-all {glob: ./data/*.yaml}
48
+ ```
49
+
50
+ **Note**: Only mapping syntax is supported. Be sure to conform to the API (`!reference {path: <path>}` or `!reference-all {glob: <glob>}`).
51
+
52
+ **Deterministic Ordering**: The `!reference-all` tag resolves files in alphabetical order to ensure consistent, predictable results across different systems and runs.
53
+
54
+ ## Library Usage
55
+
56
+ ### Basic Usage
57
+
58
+ ```typescript
59
+ import { loadAndResolve } from 'yaml-reference-ts';
60
+
61
+ async function loadConfig() {
62
+ try {
63
+ const resolved = await loadAndResolve('./config/main.yaml');
64
+ console.log(resolved);
65
+ } catch (error) {
66
+ console.error('Failed to resolve references:', error);
67
+ }
68
+ }
69
+ ```
70
+
71
+ ### API Reference
72
+
73
+ #### `loadYamlWithReferences(filePath: string): Promise<any>`
74
+ Loads a YAML file and resolves all `!reference` and `!reference-all` tags, returning the fully resolved object.
75
+
76
+ #### `parseYamlWithReferences(content: string, filePath: string): any`
77
+ Parses YAML content with custom tags, setting `_location` on Reference objects.
78
+
79
+ #### `loadYamlWithReferencesSync(filePath: string): any`
80
+ Loads a YAML file and resolves all `!reference` and `!reference-all` tags, returning the fully resolved object synchronously.
81
+
82
+ #### `parseYamlWithReferencesSync(content: string, filePath: string): any`
83
+ Parses YAML content with custom tags, setting `_location` on Reference objects synchronously.
84
+
85
+ #### `Reference` Class
86
+ Represents a `!reference` tag with properties:
87
+ - `_location`: Absolute path to the file containing the reference
88
+ - `path`: Relative path to the referenced YAML file
89
+
90
+ #### `ReferenceAll` Class
91
+ Represents a `!reference-all` tag with properties:
92
+ - `_location`: Absolute path to the file containing the reference
93
+ - `glob`: Glob pattern to match YAML files
94
+
95
+ ## CLI Usage
96
+
97
+ The package includes a CLI tool called `yaml-reference-cli`:
98
+
99
+ ```bash
100
+ # Basic usage
101
+ yaml-reference-cli config.yaml
102
+
103
+ # With conversion back to YAML (requires yq)
104
+ yaml-reference-cli config.yaml | yq -P
105
+
106
+ # Save output to file
107
+ yaml-reference-cli config.yaml | yq -P > .compiled/config.yaml
108
+
109
+ # Show help
110
+ yaml-reference-cli --help
111
+ ```
112
+
113
+ ### CLI Output
114
+ The CLI outputs JSON with:
115
+ - Keys sorted alphabetically
116
+ - 2-space indentation
117
+ - Exit code 0 for success, 1 for errors
118
+
119
+ ## Resolution Rules
120
+
121
+ ### For `!reference` tags:
122
+ 1. The `path` property is parsed from the YAML mapping
123
+ 2. `_location` is automatically set to the absolute path of the containing file
124
+ 3. The referenced YAML file is read and parsed relative to `_location`
125
+ 4. Any references within the referenced file are recursively resolved
126
+ 5. The `Reference` object is replaced with the resolved content
127
+
128
+ ### For `!reference-all` tags:
129
+ 1. The `glob` property is parsed from the YAML mapping
130
+ 2. `_location` is automatically set to the absolute path of the containing file
131
+ 3. The glob pattern is evaluated relative to `_location`
132
+ 4. For each matching YAML file:
133
+ - The file is read and parsed
134
+ - Any references are recursively resolved
135
+ 5. The `ReferenceAll` object is replaced with an array of resolved contents
136
+ 6. Files are sorted and resolved in deterministic alphabetical order for consistent results across systems
137
+ 7. If no files match, an error is thrown
138
+
139
+ **Deterministic Behavior**: The library ensures predictable output by:
140
+ - Sorting `!reference-all` file matches alphabetically before resolution
141
+ - Rejecting scalar syntax (only mapping syntax is allowed)
142
+ - Using consistent error messages for validation failures
143
+
144
+ ## Error Handling
145
+
146
+ The library throws descriptive errors for:
147
+ - Missing referenced files
148
+ - Invalid YAML syntax
149
+ - Circular references (detected via visited file path tracking)
150
+ - Invalid glob patterns
151
+ - Missing required properties (`path` for `!reference`, `glob` for `!reference-all`)
152
+
153
+ ## Development
154
+
155
+ ### Project Structure
156
+
157
+ ```
158
+ yaml-reference-ts/
159
+ ├── src/
160
+ │ ├── index.ts # Main exports
161
+ │ ├── Reference.ts # Reference class
162
+ │ ├── ReferenceAll.ts # ReferenceAll class
163
+ │ ├── resolver.ts # loadAndResolve implementation
164
+ │ ├── parser.ts # YAML parser with custom tags
165
+ │ └── cli/
166
+ │ └── index.ts # CLI implementation
167
+ ├── __tests__/ # Test files
168
+ ├── doc/
169
+ │ └── Design.md # Design specification
170
+ ├── package.json
171
+ ├── tsconfig.json
172
+ └── README.md
173
+ ```
174
+
175
+ ### Building
176
+
177
+ ```bash
178
+ # Install dependencies
179
+ npm install
180
+
181
+ # Build the project
182
+ npm run build
183
+
184
+ # Watch mode for development
185
+ npm run dev
186
+ ```
187
+
188
+ ### Testing
189
+
190
+ ```bash
191
+ # Run tests
192
+ npm test
193
+
194
+ # Watch mode
195
+ npm run test:watch
196
+
197
+ # Coverage report
198
+ npm run test:coverage
199
+
200
+ # Run specific test file
201
+ npm test -- __tests__/parser.test.ts
202
+ ```
203
+
204
+ ### Linting
205
+
206
+ ```bash
207
+ npm run lint
208
+ ```
209
+
210
+ ## Dependencies
211
+
212
+ ### Production
213
+ - `yaml` (eemeli/yaml): YAML parsing with custom tag support
214
+ - `glob`: Pattern matching for `!reference-all` tags
215
+
216
+ ### Development
217
+ - TypeScript
218
+ - Jest for testing
219
+ - ESLint for code quality
220
+
221
+ ## Acknowledgments
222
+
223
+ Author(s):
224
+
225
+ - David Sillman <dsillman2000@gmail.com>
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Reference class representing a !reference tag in YAML
3
+ * This class is instantiated when the YAML parser encounters a !reference tag
4
+ */
5
+ export declare class Reference {
6
+ /**
7
+ * Absolute path to the YAML file where this !reference tag was found
8
+ * This is automatically set by the library during parsing
9
+ */
10
+ _location: string;
11
+ /**
12
+ * Relative path to another YAML file
13
+ * Required, explicitly provided by the user in the YAML document
14
+ */
15
+ path: string;
16
+ /**
17
+ * Creates a new Reference instance
18
+ * @param path - Relative path to another YAML file
19
+ * @param location - Absolute path to the file containing this reference (optional, will be set later)
20
+ */
21
+ constructor(path: string, location?: string);
22
+ /**
23
+ * Returns a string representation of the Reference
24
+ */
25
+ toString(): string;
26
+ }
27
+ //# sourceMappingURL=Reference.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Reference = void 0;
4
+ /**
5
+ * Reference class representing a !reference tag in YAML
6
+ * This class is instantiated when the YAML parser encounters a !reference tag
7
+ */
8
+ class Reference {
9
+ /**
10
+ * Creates a new Reference instance
11
+ * @param path - Relative path to another YAML file
12
+ * @param location - Absolute path to the file containing this reference (optional, will be set later)
13
+ */
14
+ constructor(path, location) {
15
+ this.path = path;
16
+ this._location = location || "";
17
+ }
18
+ /**
19
+ * Returns a string representation of the Reference
20
+ */
21
+ toString() {
22
+ return `Reference { path: "${this.path}", _location: "${this._location}" }`;
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.Reference = Reference;
32
+ //# sourceMappingURL=Reference.js.map
@@ -0,0 +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"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * ReferenceAll class representing a !reference-all tag in YAML
3
+ * This class is instantiated when the YAML parser encounters a !reference-all tag
4
+ */
5
+ export declare class ReferenceAll {
6
+ /**
7
+ * Absolute path to the YAML file where this !reference-all tag was found
8
+ * This is automatically set by the library during parsing
9
+ */
10
+ _location: string;
11
+ /**
12
+ * Glob pattern to match YAML files
13
+ * Required, explicitly provided by the user in the YAML document
14
+ */
15
+ glob: string;
16
+ /**
17
+ * Creates a new ReferenceAll instance
18
+ * @param glob - Glob pattern to match YAML files
19
+ * @param location - Absolute path to the file containing this reference (optional, will be set later)
20
+ */
21
+ constructor(glob: string, location?: string);
22
+ /**
23
+ * Returns a string representation of the ReferenceAll
24
+ */
25
+ toString(): string;
26
+ }
27
+ //# sourceMappingURL=ReferenceAll.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceAll = void 0;
4
+ /**
5
+ * ReferenceAll class representing a !reference-all tag in YAML
6
+ * This class is instantiated when the YAML parser encounters a !reference-all tag
7
+ */
8
+ class ReferenceAll {
9
+ /**
10
+ * Creates a new ReferenceAll instance
11
+ * @param glob - Glob pattern to match YAML files
12
+ * @param location - Absolute path to the file containing this reference (optional, will be set later)
13
+ */
14
+ constructor(glob, location) {
15
+ this.glob = glob;
16
+ this._location = location || "";
17
+ }
18
+ /**
19
+ * Returns a string representation of the ReferenceAll
20
+ */
21
+ toString() {
22
+ return `ReferenceAll { glob: "${this.glob}", _location: "${this._location}" }`;
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.ReferenceAll = ReferenceAll;
32
+ //# sourceMappingURL=ReferenceAll.js.map
@@ -0,0 +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,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,yBAAyB,IAAI,CAAC,IAAI,kBAAkB,IAAI,CAAC,SAAS,KAAK,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACJ;AApCD,oCAoCC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI implementation for yaml-reference-ts
4
+ * Reads YAML file with !reference and !reference-all tags, resolves references,
5
+ * and outputs JSON to stdout with sorted keys and 2-space indentation
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * CLI implementation for yaml-reference-ts
5
+ * Reads YAML file with !reference and !reference-all tags, resolves references,
6
+ * and outputs JSON to stdout with sorted keys and 2-space indentation
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ const resolver_1 = require("../resolver");
43
+ const fs = __importStar(require("fs/promises"));
44
+ /**
45
+ * Display help message
46
+ */
47
+ function showHelp() {
48
+ console.log(`
49
+ YAML Reference Resolver CLI
50
+
51
+ Usage: yaml-reference-cli <file_path>
52
+
53
+ Resolves !reference and !reference-all tags in YAML files and outputs
54
+ the resolved JSON to stdout.
55
+
56
+ Arguments:
57
+ file_path Path to YAML file containing references (required)
58
+
59
+ Options:
60
+ -h, --help Show this help message
61
+
62
+ Output:
63
+ JSON with keys sorted alphabetically and 2-space indentation
64
+
65
+ Examples:
66
+ yaml-reference-cli config.yaml
67
+ yaml-reference-cli config.yaml | yq -P
68
+ yaml-reference-cli config.yaml | yq -P > .compiled/config.yaml
69
+
70
+ Exit Codes:
71
+ 0 - Success
72
+ 1 - General error (file not found, invalid YAML, circular reference, etc.)
73
+ `);
74
+ }
75
+ /**
76
+ * Sort object keys alphabetically (recursively)
77
+ */
78
+ function sortObjectKeys(obj) {
79
+ if (Array.isArray(obj)) {
80
+ return obj.map((item) => sortObjectKeys(item));
81
+ }
82
+ if (obj && typeof obj === "object" && !(obj instanceof Date)) {
83
+ const sortedObj = {};
84
+ // Get keys, sort them alphabetically
85
+ const keys = Object.keys(obj).sort();
86
+ for (const key of keys) {
87
+ sortedObj[key] = sortObjectKeys(obj[key]);
88
+ }
89
+ return sortedObj;
90
+ }
91
+ return obj;
92
+ }
93
+ /**
94
+ * Main CLI function
95
+ */
96
+ async function main() {
97
+ const args = process.argv.slice(2);
98
+ // Check for help flag
99
+ if (args.includes("-h") || args.includes("--help")) {
100
+ showHelp();
101
+ process.exit(0);
102
+ }
103
+ // Check for file path argument
104
+ if (args.length === 0) {
105
+ 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>");
113
+ console.error("Use -h or --help for more information");
114
+ process.exit(1);
115
+ }
116
+ const filePath = args[0];
117
+ try {
118
+ // Check if file exists
119
+ await fs.access(filePath);
120
+ }
121
+ catch (error) {
122
+ console.error(`Error: File not found: ${filePath}`);
123
+ process.exit(1);
124
+ }
125
+ try {
126
+ // Resolve references
127
+ const resolved = await (0, resolver_1.loadAndResolve)(filePath);
128
+ // Sort keys alphabetically
129
+ const sorted = sortObjectKeys(resolved);
130
+ // Output JSON with 2-space indentation
131
+ console.log(JSON.stringify(sorted, null, 2));
132
+ }
133
+ catch (error) {
134
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
135
+ process.exit(1);
136
+ }
137
+ }
138
+ // Run the CLI
139
+ if (require.main === module) {
140
+ main().catch((error) => {
141
+ console.error(`Fatal error: ${error instanceof Error ? error.message : String(error)}`);
142
+ process.exit(1);
143
+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D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CACT,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,cAAc;AACd,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,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"}
@@ -0,0 +1,15 @@
1
+ # Additional configuration file
2
+ extra_config:
3
+ enabled: true
4
+ options:
5
+ - option1
6
+ - option2
7
+ - option3
8
+ settings:
9
+ timeout: 5000
10
+ retry_count: 5
11
+ fallback: true
12
+ metadata:
13
+ created: 2024-01-15
14
+ updated: 2024-01-20
15
+ version: 2.1.0
@@ -0,0 +1,11 @@
1
+ # Database configuration
2
+ host: localhost
3
+ port: 5432
4
+ database: myapp_production
5
+ username: admin
6
+ password: secret123
7
+ pool:
8
+ max: 20
9
+ min: 5
10
+ idle: 10000
11
+ ssl: true
@@ -0,0 +1,15 @@
1
+ # Application settings
2
+ debug: false
3
+ log_level: info
4
+ cache:
5
+ enabled: true
6
+ ttl: 3600
7
+ max_size: 1000
8
+ api:
9
+ timeout: 30000
10
+ retries: 3
11
+ base_url: https://api.example.com
12
+ features:
13
+ analytics: true
14
+ notifications: false
15
+ dark_mode: true
@@ -0,0 +1,30 @@
1
+ # Products data file
2
+ products:
3
+ - id: 101
4
+ name: Laptop Pro
5
+ category: electronics
6
+ price: 1299.99
7
+ in_stock: true
8
+ features:
9
+ - 16GB RAM
10
+ - 512GB SSD
11
+ - Intel i7
12
+ - 15.6" Display
13
+ - id: 102
14
+ name: Wireless Mouse
15
+ category: accessories
16
+ price: 49.99
17
+ in_stock: true
18
+ features:
19
+ - Bluetooth 5.0
20
+ - Rechargeable
21
+ - Ergonomic design
22
+ - id: 103
23
+ name: USB-C Cable
24
+ category: accessories
25
+ price: 19.99
26
+ in_stock: false
27
+ features:
28
+ - 3m length
29
+ - Fast charging
30
+ - Data transfer
@@ -0,0 +1,17 @@
1
+ # Users data file
2
+ users:
3
+ - id: 1
4
+ name: Alice Smith
5
+ email: alice@example.com
6
+ role: admin
7
+ active: true
8
+ - id: 2
9
+ name: Bob Johnson
10
+ email: bob@example.com
11
+ role: user
12
+ active: true
13
+ - id: 3
14
+ name: Charlie Brown
15
+ email: charlie@example.com
16
+ role: user
17
+ active: false
@@ -0,0 +1,19 @@
1
+ # Example main.yaml file with !reference and !reference-all tags
2
+ # This demonstrates the usage of the yaml-reference-ts library
3
+
4
+ app:
5
+ name: My Application
6
+ version: 1.0.0
7
+ config: !reference
8
+ path: ./config/database.yaml
9
+ settings: !reference { path: ./config/settings.yaml }
10
+
11
+ data:
12
+ files: !reference-all
13
+ glob: ./data/*.yaml
14
+ additional: !reference-all { glob: ./additional/*.yaml }
15
+
16
+ metadata:
17
+ author: John Doe
18
+ created: 2024-01-01
19
+ description: Example configuration with references
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Main exports for yaml-reference-ts library
3
+ */
4
+ export { Reference } from "./Reference";
5
+ export { ReferenceAll } from "./ReferenceAll";
6
+ export { parseYamlWithReferencesSync, parseYamlWithReferences } from "./parser";
7
+ /**
8
+ * Convenience alias for loadAndResolve
9
+ * @param filePath - Path to YAML file containing references
10
+ * @returns Resolved object with all references resolved
11
+ */
12
+ export declare function loadYamlWithReferences(filePath: string): Promise<any>;
13
+ /**
14
+ * Convenience alias for loadAndResolveSync
15
+ * @param filePath - Path to YAML file containing references
16
+ * @returns Resolved object with all references resolved
17
+ */
18
+ export declare function loadYamlWithReferencesSync(filePath: string): any;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Main exports for yaml-reference-ts library
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseYamlWithReferences = exports.parseYamlWithReferencesSync = exports.ReferenceAll = exports.Reference = void 0;
7
+ exports.loadYamlWithReferences = loadYamlWithReferences;
8
+ exports.loadYamlWithReferencesSync = loadYamlWithReferencesSync;
9
+ var Reference_1 = require("./Reference");
10
+ Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return Reference_1.Reference; } });
11
+ var ReferenceAll_1 = require("./ReferenceAll");
12
+ Object.defineProperty(exports, "ReferenceAll", { enumerable: true, get: function () { return ReferenceAll_1.ReferenceAll; } });
13
+ const resolver_1 = require("./resolver");
14
+ var parser_1 = require("./parser");
15
+ Object.defineProperty(exports, "parseYamlWithReferencesSync", { enumerable: true, get: function () { return parser_1.parseYamlWithReferencesSync; } });
16
+ Object.defineProperty(exports, "parseYamlWithReferences", { enumerable: true, get: function () { return parser_1.parseYamlWithReferences; } });
17
+ /**
18
+ * Convenience alias for loadAndResolve
19
+ * @param filePath - Path to YAML file containing references
20
+ * @returns Resolved object with all references resolved
21
+ */
22
+ async function loadYamlWithReferences(filePath) {
23
+ return await (0, resolver_1.loadAndResolve)(filePath);
24
+ }
25
+ /**
26
+ * Convenience alias for loadAndResolveSync
27
+ * @param filePath - Path to YAML file containing references
28
+ * @returns Resolved object with all references resolved
29
+ */
30
+ function loadYamlWithReferencesSync(filePath) {
31
+ return (0, resolver_1.loadAndResolveSync)(filePath);
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Parser module for handling YAML with custom !reference and !reference-all tags
3
+ * Uses the eemeli/yaml package to parse YAML with custom tags
4
+ */
5
+ /**
6
+ * Parse YAML content with custom !reference and !reference-all tags
7
+ * @param filePath - Path to the YAML file to be parsed (used for setting _location)
8
+ * @returns Parsed object with Reference and ReferenceAll instances
9
+ */
10
+ export declare function parseYamlWithReferencesSync(filePath: string): any;
11
+ /**
12
+ * Parse YAML content with custom !reference and !reference-all tags (async).
13
+ * @param filePath - Path to the YAML file to be parsed (used for setting _location)
14
+ * @returns Parsed object with Reference and ReferenceAll instances
15
+ */
16
+ export declare function parseYamlWithReferences(filePath: string): Promise<any>;
17
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +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"}
package/dist/parser.js ADDED
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * Parser module for handling YAML with custom !reference and !reference-all tags
4
+ * Uses the eemeli/yaml package to parse YAML with custom tags
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.parseYamlWithReferencesSync = parseYamlWithReferencesSync;
41
+ exports.parseYamlWithReferences = parseYamlWithReferences;
42
+ const yaml_1 = require("yaml");
43
+ const Reference_1 = require("./Reference");
44
+ const ReferenceAll_1 = require("./ReferenceAll");
45
+ const path = __importStar(require("path"));
46
+ const fs = __importStar(require("fs/promises"));
47
+ const fsSync = __importStar(require("fs"));
48
+ /**
49
+ * Custom tag for !reference
50
+ */
51
+ const referenceTag = {
52
+ identify: (value) => value instanceof Reference_1.Reference,
53
+ tag: "!reference",
54
+ collection: "map",
55
+ resolve: (value, _) => {
56
+ // value should be a YAMLMap for mapping syntax
57
+ if (!(value instanceof yaml_1.YAMLMap)) {
58
+ throw new Error('!reference tag must be followed by a mapping with a "path" property');
59
+ }
60
+ // Get the path property from the map
61
+ const pathValue = value.get("path");
62
+ if (!pathValue) {
63
+ throw new Error('!reference tag requires a "path" property');
64
+ }
65
+ if (typeof pathValue !== "string") {
66
+ throw new Error('!reference "path" property must be a string');
67
+ }
68
+ return new Reference_1.Reference(pathValue);
69
+ },
70
+ };
71
+ /**
72
+ * Custom tag for !reference-all
73
+ */
74
+ const referenceAllTag = {
75
+ identify: (value) => value instanceof ReferenceAll_1.ReferenceAll,
76
+ tag: "!reference-all",
77
+ 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
+ }
83
+ // Get the glob property from the map
84
+ const globValue = value.get("glob");
85
+ if (!globValue) {
86
+ throw new Error('!reference-all tag requires a "glob" property');
87
+ }
88
+ if (typeof globValue !== "string") {
89
+ throw new Error('!reference-all "glob" property must be a string');
90
+ }
91
+ return new ReferenceAll_1.ReferenceAll(globValue);
92
+ },
93
+ };
94
+ // Custom tags array for parsing
95
+ const customTags = [referenceTag, referenceAllTag];
96
+ /**
97
+ * Parse YAML content with custom !reference and !reference-all tags
98
+ * @param filePath - Path to the YAML file to be parsed (used for setting _location)
99
+ * @returns Parsed object with Reference and ReferenceAll instances
100
+ */
101
+ function parseYamlWithReferencesSync(filePath) {
102
+ try {
103
+ const absolutePath = path.resolve(filePath);
104
+ const content = fsSync.readFileSync(absolutePath, "utf8");
105
+ const parsed = (0, yaml_1.parse)(content, { customTags });
106
+ // Process the parsed document to set _location on Reference and ReferenceAll objects
107
+ return processParsedDocument(parsed, filePath);
108
+ }
109
+ catch (error) {
110
+ // Re-throw the error with context about which file failed to parse
111
+ throw new Error(`Failed to parse YAML file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
112
+ }
113
+ }
114
+ /**
115
+ * Parse YAML content with custom !reference and !reference-all tags (async).
116
+ * @param filePath - Path to the YAML file to be parsed (used for setting _location)
117
+ * @returns Parsed object with Reference and ReferenceAll instances
118
+ */
119
+ async function parseYamlWithReferences(filePath) {
120
+ try {
121
+ const absolutePath = path.resolve(filePath);
122
+ const content = await fs.readFile(absolutePath, "utf8");
123
+ const parsed = (0, yaml_1.parse)(content, { customTags });
124
+ // Process the parsed document to set _location on Reference and ReferenceAll objects
125
+ return processParsedDocument(parsed, filePath);
126
+ }
127
+ catch (error) {
128
+ // Re-throw the error with context about which file failed to parse
129
+ throw new Error(`Failed to parse YAML file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
130
+ }
131
+ }
132
+ /**
133
+ * Recursively process parsed document to set _location on Reference and ReferenceAll objects
134
+ */
135
+ function processParsedDocument(obj, filePath) {
136
+ if (obj instanceof Reference_1.Reference) {
137
+ obj._location = filePath;
138
+ return obj;
139
+ }
140
+ if (obj instanceof ReferenceAll_1.ReferenceAll) {
141
+ obj._location = filePath;
142
+ return obj;
143
+ }
144
+ if (Array.isArray(obj)) {
145
+ return obj.map((item) => processParsedDocument(item, filePath));
146
+ }
147
+ if (obj && typeof obj === "object") {
148
+ const result = {};
149
+ for (const [key, value] of Object.entries(obj)) {
150
+ result[key] = processParsedDocument(value, filePath);
151
+ }
152
+ return result;
153
+ }
154
+ return obj;
155
+ }
156
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +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,eAAe,GAAG;IACpB,QAAQ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IAED,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Resolver module for resolving !reference and !reference-all tags
3
+ * Handles recursive resolution of references with proper path tracking
4
+ */
5
+ /**
6
+ * Load a YAML file containing references and resolve all references. (async)
7
+ * @param filePath - Path to YAML file containing references
8
+ * @returns Resolved object with all references resolved
9
+ */
10
+ export declare function loadAndResolve(filePath: string): Promise<any>;
11
+ /**
12
+ * Load a YAML file containing references and resolve all references.
13
+ * @param filePath - Path to YAML file containing references
14
+ * @returns Resolved object with all references resolved
15
+ */
16
+ export declare function loadAndResolveSync(filePath: string): any;
17
+ /**
18
+ * Recursively resolve all references in an object (async)
19
+ * @param obj - Object that may contain Reference or ReferenceAll instances
20
+ * @param visitedPaths - Set of visited file paths to detect circular references
21
+ * @returns Object with all references resolved
22
+ */
23
+ export declare function _recursivelyResolveReferences(obj: any, visitedPaths?: Set<string>): Promise<any>;
24
+ /**
25
+ * Recursively resolve all references in an object
26
+ * @param obj - Object that may contain Reference or ReferenceAll instances
27
+ * @param visitedPaths - Set of visited file paths to detect circular references
28
+ * @returns Object with all references resolved
29
+ */
30
+ export declare function _recursivelyResolveReferencesSync(obj: any, visitedPaths?: Set<string>): any;
31
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /**
3
+ * Resolver module for resolving !reference and !reference-all tags
4
+ * Handles recursive resolution of references with proper path tracking
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.loadAndResolve = loadAndResolve;
41
+ exports.loadAndResolveSync = loadAndResolveSync;
42
+ exports._recursivelyResolveReferences = _recursivelyResolveReferences;
43
+ exports._recursivelyResolveReferencesSync = _recursivelyResolveReferencesSync;
44
+ const path = __importStar(require("path"));
45
+ const fs = __importStar(require("fs/promises"));
46
+ const fsSync = __importStar(require("fs"));
47
+ const glob_1 = require("glob");
48
+ const Reference_1 = require("./Reference");
49
+ const ReferenceAll_1 = require("./ReferenceAll");
50
+ const parser_1 = require("./parser");
51
+ /**
52
+ * Load a YAML file containing references and resolve all references. (async)
53
+ * @param filePath - Path to YAML file containing references
54
+ * @returns Resolved object with all references resolved
55
+ */
56
+ async function loadAndResolve(filePath) {
57
+ const parsed = await (0, parser_1.parseYamlWithReferences)(filePath);
58
+ return await _recursivelyResolveReferences(parsed, new Set());
59
+ }
60
+ /**
61
+ * Load a YAML file containing references and resolve all references.
62
+ * @param filePath - Path to YAML file containing references
63
+ * @returns Resolved object with all references resolved
64
+ */
65
+ function loadAndResolveSync(filePath) {
66
+ const parsed = (0, parser_1.parseYamlWithReferencesSync)(filePath);
67
+ return _recursivelyResolveReferencesSync(parsed, new Set());
68
+ }
69
+ /**
70
+ * Recursively resolve all references in an object (async)
71
+ * @param obj - Object that may contain Reference or ReferenceAll instances
72
+ * @param visitedPaths - Set of visited file paths to detect circular references
73
+ * @returns Object with all references resolved
74
+ */
75
+ async function _recursivelyResolveReferences(obj, visitedPaths = new Set()) {
76
+ if (obj instanceof Reference_1.Reference) {
77
+ return await resolveReference(obj, visitedPaths);
78
+ }
79
+ if (obj instanceof ReferenceAll_1.ReferenceAll) {
80
+ return await resolveReferenceAll(obj, visitedPaths);
81
+ }
82
+ if (Array.isArray(obj)) {
83
+ const resolvedArray = [];
84
+ for (const item of obj) {
85
+ resolvedArray.push(await _recursivelyResolveReferences(item, visitedPaths));
86
+ }
87
+ return resolvedArray;
88
+ }
89
+ if (obj && typeof obj === "object") {
90
+ const resolvedObj = {};
91
+ for (const [key, value] of Object.entries(obj)) {
92
+ resolvedObj[key] = await _recursivelyResolveReferences(value, visitedPaths);
93
+ }
94
+ return resolvedObj;
95
+ }
96
+ return obj;
97
+ }
98
+ /**
99
+ * Recursively resolve all references in an object
100
+ * @param obj - Object that may contain Reference or ReferenceAll instances
101
+ * @param visitedPaths - Set of visited file paths to detect circular references
102
+ * @returns Object with all references resolved
103
+ */
104
+ function _recursivelyResolveReferencesSync(obj, visitedPaths = new Set()) {
105
+ if (obj instanceof Reference_1.Reference) {
106
+ return resolveReferenceSync(obj, visitedPaths);
107
+ }
108
+ if (obj instanceof ReferenceAll_1.ReferenceAll) {
109
+ return resolveReferenceAllSync(obj, visitedPaths);
110
+ }
111
+ if (Array.isArray(obj)) {
112
+ const resolvedArray = [];
113
+ for (const item of obj) {
114
+ resolvedArray.push(_recursivelyResolveReferencesSync(item, visitedPaths));
115
+ }
116
+ return resolvedArray;
117
+ }
118
+ if (obj && typeof obj === "object") {
119
+ const resolvedObj = {};
120
+ for (const [key, value] of Object.entries(obj)) {
121
+ resolvedObj[key] = _recursivelyResolveReferencesSync(value, visitedPaths);
122
+ }
123
+ return resolvedObj;
124
+ }
125
+ return obj;
126
+ }
127
+ /**
128
+ * Resolve a single Reference object (async)
129
+ * @param ref Reference object to resolve
130
+ * @param visitedPaths Set of visited paths to detect circular references
131
+ * @returns Resolved object. Will not contain any references.
132
+ * @throws Error if circular reference is detected, or if a reference cannot be resolved
133
+ */
134
+ async function resolveReference(ref, visitedPaths) {
135
+ if (!ref._location) {
136
+ throw new Error(`Reference missing _location: ${ref.toString()}`);
137
+ }
138
+ const refDir = path.dirname(ref._location);
139
+ const targetPath = path.resolve(refDir, ref.path);
140
+ // Check for circular references
141
+ if (visitedPaths.has(targetPath)) {
142
+ throw new Error(`Circular reference detected: ${targetPath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
143
+ }
144
+ // Add to visited paths
145
+ visitedPaths.add(targetPath);
146
+ try {
147
+ // Check if file exists
148
+ await fs.access(targetPath);
149
+ }
150
+ catch (error) {
151
+ throw new Error(`Referenced file not found: ${targetPath} (from ${ref._location})`);
152
+ }
153
+ // Load and parse the referenced file
154
+ const parsed = await (0, parser_1.parseYamlWithReferences)(targetPath);
155
+ // Recursively resolve references in the parsed content
156
+ const resolved = await _recursivelyResolveReferences(parsed, visitedPaths);
157
+ // Remove from visited paths after resolution
158
+ visitedPaths.delete(targetPath);
159
+ return resolved;
160
+ }
161
+ /**
162
+ * Resolve a single Reference object
163
+ * @param ref Reference object to resolve
164
+ * @param visitedPaths Set of visited paths to detect circular references
165
+ * @returns Resolved object. Will not contain any references.
166
+ * @throws Error if circular reference is detected, or if a reference cannot be resolved
167
+ */
168
+ function resolveReferenceSync(ref, visitedPaths) {
169
+ if (!ref._location) {
170
+ throw new Error(`Reference missing _location: ${ref.toString()}`);
171
+ }
172
+ const refDir = path.dirname(ref._location);
173
+ const targetPath = path.resolve(refDir, ref.path);
174
+ // Check for circular references
175
+ if (visitedPaths.has(targetPath)) {
176
+ throw new Error(`Circular reference detected: ${targetPath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
177
+ }
178
+ // Add to visited paths
179
+ visitedPaths.add(targetPath);
180
+ try {
181
+ // Check if file exists
182
+ fsSync.accessSync(targetPath);
183
+ }
184
+ catch (error) {
185
+ throw new Error(`Referenced file not found: ${targetPath} (from ${ref._location})`);
186
+ }
187
+ // Load and parse the referenced file
188
+ const parsed = (0, parser_1.parseYamlWithReferencesSync)(targetPath);
189
+ // Recursively resolve references in the parsed content
190
+ const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths);
191
+ // Remove from visited paths after resolution
192
+ visitedPaths.delete(targetPath);
193
+ return resolved;
194
+ }
195
+ /**
196
+ * Resolve a ReferenceAll object (async)
197
+ * @param refAll ReferenceAll object to resolve
198
+ * @param visitedPaths Set of visited paths to detect circular references
199
+ * @returns Resolved array of objects. Will not contain any references.
200
+ * @throws Error if the ReferenceAll object is missing _location or if the glob pattern is invalid.
201
+ */
202
+ async function resolveReferenceAll(refAll, visitedPaths) {
203
+ if (!refAll._location) {
204
+ throw new Error(`ReferenceAll missing _location: ${refAll.toString()}`);
205
+ }
206
+ const refDir = path.dirname(refAll._location);
207
+ const globPattern = path.resolve(refDir, refAll.glob);
208
+ // Find files matching the glob pattern
209
+ let matchingFiles;
210
+ try {
211
+ matchingFiles = await (0, glob_1.glob)(globPattern, { absolute: true });
212
+ }
213
+ catch (error) {
214
+ throw new Error(`Invalid glob pattern: ${globPattern} (from ${refAll._location})`);
215
+ }
216
+ // Filter to only include YAML files
217
+ matchingFiles = matchingFiles.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml"));
218
+ if (matchingFiles.length === 0) {
219
+ throw new Error(`No YAML files found matching glob pattern: ${globPattern} (from ${refAll._location})`);
220
+ }
221
+ // Sort files alphabetically for consistent ordering
222
+ matchingFiles.sort();
223
+ // Resolve each matching file
224
+ const resolvedContents = [];
225
+ for (const filePath of matchingFiles) {
226
+ // Check for circular references
227
+ if (visitedPaths.has(filePath)) {
228
+ throw new Error(`Circular reference detected: ${filePath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
229
+ }
230
+ visitedPaths.add(filePath);
231
+ try {
232
+ // Load and parse the file
233
+ const parsed = await (0, parser_1.parseYamlWithReferences)(filePath);
234
+ // Recursively resolve references
235
+ const resolved = await _recursivelyResolveReferences(parsed, visitedPaths);
236
+ resolvedContents.push(resolved);
237
+ }
238
+ catch (error) {
239
+ // Remove from visited paths on error
240
+ visitedPaths.delete(filePath);
241
+ throw error;
242
+ }
243
+ visitedPaths.delete(filePath);
244
+ }
245
+ return resolvedContents;
246
+ }
247
+ /**
248
+ * Resolve a ReferenceAll object
249
+ * @param refAll ReferenceAll object to resolve
250
+ * @param visitedPaths Set of visited paths to detect circular references
251
+ * @returns Resolved array of objects. Will not contain any references.
252
+ * @throws Error if the ReferenceAll object is missing _location or if the glob pattern is invalid.
253
+ */
254
+ function resolveReferenceAllSync(refAll, visitedPaths) {
255
+ if (!refAll._location) {
256
+ throw new Error(`ReferenceAll missing _location: ${refAll.toString()}`);
257
+ }
258
+ const refDir = path.dirname(refAll._location);
259
+ const globPattern = path.resolve(refDir, refAll.glob);
260
+ // Find files matching the glob pattern
261
+ let matchingFiles;
262
+ try {
263
+ matchingFiles = (0, glob_1.globSync)(globPattern, { absolute: true });
264
+ }
265
+ catch (error) {
266
+ throw new Error(`Invalid glob pattern: ${globPattern} (from ${refAll._location})`);
267
+ }
268
+ // Filter to only include YAML files
269
+ matchingFiles = matchingFiles.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml"));
270
+ if (matchingFiles.length === 0) {
271
+ throw new Error(`No YAML files found matching glob pattern: ${globPattern} (from ${refAll._location})`);
272
+ }
273
+ // Sort files alphabetically for consistent ordering
274
+ matchingFiles.sort();
275
+ // Resolve each matching file
276
+ const resolvedContents = [];
277
+ for (const filePath of matchingFiles) {
278
+ // Check for circular references
279
+ if (visitedPaths.has(filePath)) {
280
+ throw new Error(`Circular reference detected: ${filePath} (visited: ${Array.from(visitedPaths).join(" -> ")})`);
281
+ }
282
+ visitedPaths.add(filePath);
283
+ try {
284
+ // Load and parse the file
285
+ const parsed = (0, parser_1.parseYamlWithReferencesSync)(filePath);
286
+ // Recursively resolve references
287
+ const resolved = _recursivelyResolveReferencesSync(parsed, visitedPaths);
288
+ resolvedContents.push(resolved);
289
+ }
290
+ catch (error) {
291
+ // Remove from visited paths on error
292
+ visitedPaths.delete(filePath);
293
+ throw error;
294
+ }
295
+ visitedPaths.delete(filePath);
296
+ }
297
+ return resolvedContents;
298
+ }
299
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sour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AED,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@dsillman2000/yaml-reference-ts",
3
+ "version": "0.0.0",
4
+ "description": "A Node.js TypeScript library for resolving YAML documents containing !reference and !reference-all tags",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "yaml-reference-cli": "./dist/cli/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "test:coverage": "jest --coverage",
16
+ "lint": "eslint --config .eslintrc.js src/**/*.ts",
17
+ "prepublishOnly": "npm run build",
18
+ "prepare": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "yaml",
22
+ "reference",
23
+ "resolver",
24
+ "configuration",
25
+ "typescript"
26
+ ],
27
+ "author": "David Sillman <dsillman2000@gmail.com>",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "glob": "^13.0.1",
31
+ "yaml": "^2.8.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/glob": "^8.1.0",
35
+ "@types/jest": "^30.0.0",
36
+ "@types/node": "^25.2.2",
37
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
38
+ "@typescript-eslint/parser": "^8.54.0",
39
+ "eslint": "^9.39.2",
40
+ "jest": "^30.2.0",
41
+ "ts-jest": "^29.4.6",
42
+ "typescript": "^5.9.3"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "README.md"
47
+ ]
48
+ }