@cloudflare/cabidela 0.2.3 → 0.2.4

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
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.4] - 2025-03-24
6
+
7
+ ### Changed
8
+
9
+ - Fixed a bug where root level $ref's were not being resolved correctly
10
+
5
11
  ## [0.2.3] - 2025-03-19
6
12
 
7
13
  ### Changed
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ var traverseSchema = (options, definitions, obj) => {
55
55
  if (cb) {
56
56
  cb(merge);
57
57
  } else {
58
+ hits++;
58
59
  Object.assign(obj2, merge);
59
60
  delete obj2[key];
60
61
  }
@@ -64,7 +65,13 @@ var traverseSchema = (options, definitions, obj) => {
64
65
  const { $id, $path } = parse$ref(obj2[key]);
65
66
  const { resolvedObject } = resolvePayload($path, definitions[$id]);
66
67
  if (resolvedObject) {
67
- cb(resolvedObject);
68
+ if (cb) {
69
+ cb(resolvedObject);
70
+ } else {
71
+ hits++;
72
+ Object.assign(obj2, resolvedObject);
73
+ delete obj2[key];
74
+ }
68
75
  } else {
69
76
  throw new Error(`Could not resolve '${obj2[key]}' $ref`);
70
77
  }
package/dist/index.mjs CHANGED
@@ -29,6 +29,7 @@ var traverseSchema = (options, definitions, obj) => {
29
29
  if (cb) {
30
30
  cb(merge);
31
31
  } else {
32
+ hits++;
32
33
  Object.assign(obj2, merge);
33
34
  delete obj2[key];
34
35
  }
@@ -38,7 +39,13 @@ var traverseSchema = (options, definitions, obj) => {
38
39
  const { $id, $path } = parse$ref(obj2[key]);
39
40
  const { resolvedObject } = resolvePayload($path, definitions[$id]);
40
41
  if (resolvedObject) {
41
- cb(resolvedObject);
42
+ if (cb) {
43
+ cb(resolvedObject);
44
+ } else {
45
+ hits++;
46
+ Object.assign(obj2, resolvedObject);
47
+ delete obj2[key];
48
+ }
42
49
  } else {
43
50
  throw new Error(`Could not resolve '${obj2[key]}' $ref`);
44
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/cabidela",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Cabidela is a small, fast, eval-less, Cloudflare Workers compatible, dynamic JSON Schema validator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",