@amritk/helpers 0.7.0 → 0.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amritk/helpers",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Shared utilities for the mjst code generation ecosystem.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -90,6 +90,21 @@ describe('walk-ref-graph', () => {
90
90
  warn.mockRestore()
91
91
  })
92
92
 
93
+ it('handles circular refs (A → B → A) without infinite looping', () => {
94
+ const schema = {
95
+ properties: { root: { $ref: '#/$defs/a' } },
96
+ $defs: {
97
+ a: { type: 'object', properties: { b: { $ref: '#/$defs/b' } } },
98
+ b: { type: 'object', properties: { a: { $ref: '#/$defs/a' } } },
99
+ },
100
+ }
101
+
102
+ const nodes = collect(schema, 'Document')
103
+
104
+ // Both defs are visited exactly once each despite the cycle.
105
+ expect(nodes.map((n) => n.filename)).toEqual(['document', 'a', 'b'])
106
+ })
107
+
93
108
  it('reuses cached resolution across repeated walks of the same schema object', () => {
94
109
  // The second walk should produce the same nodes from the per-root cache,
95
110
  // proving the cache does not corrupt or drop results on reuse.