@jsnw/srv-utils 1.0.6 → 1.0.7

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.
@@ -34,7 +34,7 @@ class ConfigLoader {
34
34
  console.error(loadError.message);
35
35
  process.exit(1);
36
36
  }
37
- const [processedYaml, includeErrors] = loader.processIncludes(yaml);
37
+ const [processedYaml, includeErrors] = loader.processIncludes(path, yaml);
38
38
  if (includeErrors && includeErrors.length > 0) {
39
39
  for (const err of includeErrors)
40
40
  console.error(`$include error: ${err.message}`);
@@ -97,11 +97,12 @@ class ConfigLoader {
97
97
  return [parsed, null];
98
98
  }
99
99
  /**
100
+ * @param {string} mainYamlPath
100
101
  * @param yaml
101
102
  * @returns {ErrorResult<any, Error[]>}
102
103
  * @protected
103
104
  */
104
- processIncludes(yaml) {
105
+ processIncludes(mainYamlPath, yaml) {
105
106
  if (typeof yaml !== 'object')
106
107
  return yaml;
107
108
  const nodesToVisit = [yaml], errors = [];
@@ -110,7 +111,7 @@ class ConfigLoader {
110
111
  if (typeof node !== 'object' || Array.isArray(node))
111
112
  continue;
112
113
  if (node['$include'] && typeof node['$include'] === 'string') {
113
- const [loadedYaml, loadError] = this.loadYamlFile((0, node_path_1.resolve)(node['$include']));
114
+ const [loadedYaml, loadError] = this.loadYamlFile((0, node_path_1.resolve)(mainYamlPath, node['$include']));
114
115
  delete node['$include'];
115
116
  if (loadError) {
116
117
  errors.push(loadError);
@@ -33,10 +33,11 @@ export declare class ConfigLoader {
33
33
  */
34
34
  protected validateYaml<T extends z.ZodTypeAny>(data: any, schema: T): ErrorResult<z.infer<T>, Error>;
35
35
  /**
36
+ * @param {string} mainYamlPath
36
37
  * @param yaml
37
38
  * @returns {ErrorResult<any, Error[]>}
38
39
  * @protected
39
40
  */
40
- protected processIncludes(yaml: any): ErrorResult<any, Error[]>;
41
+ protected processIncludes(mainYamlPath: string, yaml: any): ErrorResult<any, Error[]>;
41
42
  private resolvePkgRootPath;
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsnw/srv-utils",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Server-side utilities for Node.js/TypeScript: tsconfig paths, Nest helpers, and config loading.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",