@openaddresses/batch-schema 7.4.0 → 7.5.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/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v7.5.0
14
+
15
+ - :tada: Add support for inline JSON Schemas
16
+
13
17
  ### v7.4.0
14
18
 
15
19
  - :tada: Add experimental `blueprint()` function
package/lib/schema.js CHANGED
@@ -71,7 +71,7 @@ export default class Schemas {
71
71
 
72
72
  // Load dynamic routes directory
73
73
  for (const r of fs.readdirSync(dirpath)) {
74
- if (!opts.silent) console.error(`ok - loaded routes/${r}`);
74
+ if (!opts.silent) console.log(`ok - loaded routes/${r}`);
75
75
  await (await import(path.resolve(dirpath, r))).default(this, config);
76
76
  }
77
77
  }
@@ -85,7 +85,7 @@ export default class Schemas {
85
85
  * @param {boolean} opts.silent Squelch StdOut
86
86
  */
87
87
  async blueprint(bp_class, config, opts = {}) {
88
- if (!opts.silent) console.error(`ok - loaded ${bp_class}`);
88
+ if (!opts.silent) console.log(`ok - loaded ${bp_class.name}`);
89
89
  await bp_class.blueprint(this, config);
90
90
  }
91
91
 
@@ -140,11 +140,17 @@ export default class Schemas {
140
140
  if (!schemas[type]) continue;
141
141
 
142
142
  // TODO: Write schemas to a tmp directory so blueprints & main schemas are in the same place
143
- schemas[`${type}_url`] = '../schema/' + schemas[type];
144
- try {
145
- schemas[type] = await $RefParser.dereference((new URL(`../schema/${schemas[type]}`, import.meta.url)).pathname);
146
- } catch (err) {
147
- schemas[type] = await $RefParser.dereference(`${this.schemas_path}/${schemas[type]}`);
143
+ if (typeof schemas[type] === 'object') {
144
+ schemas[`${type}_url`] = null;
145
+ } else if (typeof schemas[type] === 'string') {
146
+ schemas[`${type}_url`] = '../schema/' + schemas[type];
147
+ try {
148
+ schemas[type] = await $RefParser.dereference((new URL(`../schema/${schemas[type]}`, import.meta.url)).pathname);
149
+ } catch (err) {
150
+ schemas[type] = await $RefParser.dereference(`${this.schemas_path}/${schemas[type]}`);
151
+ }
152
+ } else {
153
+ throw new Error(`Unsupported Value in ${type} value for ${url}`);
148
154
  }
149
155
  }
150
156
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "root": true,
5
5
  "main": "index.js",
6
- "version": "7.4.0",
6
+ "version": "7.5.0",
7
7
  "description": "Strongly Validated JSON Schema support for address",
8
8
  "repository": "git@github.com:openaddresses/batch-schema",
9
9
  "author": "ingalls <nick@ingalls.ca>",