@scalar/json-magic 0.4.3 → 0.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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +10 -0
- package/dist/bundle/bundle.d.ts +0 -10
- package/dist/bundle/bundle.d.ts.map +1 -1
- package/dist/bundle/bundle.js +27 -29
- package/dist/bundle/bundle.js.map +2 -2
- package/dist/bundle/plugins/fetch-urls/index.d.ts.map +1 -1
- package/dist/bundle/plugins/fetch-urls/index.js +2 -2
- package/dist/bundle/plugins/fetch-urls/index.js.map +2 -2
- package/dist/bundle/plugins/parse-json/index.d.ts.map +1 -1
- package/dist/bundle/plugins/parse-json/index.js +1 -1
- package/dist/bundle/plugins/parse-json/index.js.map +2 -2
- package/dist/bundle/plugins/parse-yaml/index.d.ts.map +1 -1
- package/dist/bundle/plugins/parse-yaml/index.js +1 -1
- package/dist/bundle/plugins/parse-yaml/index.js.map +2 -2
- package/dist/bundle/plugins/read-files/index.d.ts.map +1 -1
- package/dist/bundle/plugins/read-files/index.js +1 -1
- package/dist/bundle/plugins/read-files/index.js.map +2 -2
- package/dist/helpers/convert-to-local-ref.d.ts +10 -0
- package/dist/helpers/convert-to-local-ref.d.ts.map +1 -0
- package/dist/helpers/convert-to-local-ref.js +26 -0
- package/dist/helpers/convert-to-local-ref.js.map +7 -0
- package/dist/helpers/escape-json-pointer.d.ts.map +1 -0
- package/dist/{utils → helpers}/escape-json-pointer.js.map +1 -1
- package/dist/helpers/get-schemas.d.ts +21 -0
- package/dist/helpers/get-schemas.d.ts.map +1 -0
- package/dist/helpers/get-schemas.js +37 -0
- package/dist/helpers/get-schemas.js.map +7 -0
- package/dist/helpers/get-segments-from-path.d.ts.map +1 -0
- package/dist/{utils → helpers}/get-segments-from-path.js.map +1 -1
- package/dist/helpers/get-value-by-path.d.ts +24 -0
- package/dist/helpers/get-value-by-path.d.ts.map +1 -0
- package/dist/helpers/get-value-by-path.js +23 -0
- package/dist/helpers/get-value-by-path.js.map +7 -0
- package/dist/helpers/is-json-object.d.ts.map +1 -0
- package/dist/{utils → helpers}/is-json-object.js +1 -1
- package/dist/helpers/is-json-object.js.map +7 -0
- package/dist/helpers/is-object.d.ts.map +1 -0
- package/dist/{utils → helpers}/is-object.js.map +1 -1
- package/dist/helpers/is-yaml.d.ts.map +1 -0
- package/dist/{utils → helpers}/is-yaml.js.map +1 -1
- package/dist/{utils → helpers}/json-path-utils.d.ts +0 -11
- package/dist/helpers/json-path-utils.d.ts.map +1 -0
- package/dist/{utils → helpers}/json-path-utils.js +0 -9
- package/dist/helpers/json-path-utils.js.map +7 -0
- package/dist/helpers/normalize.d.ts.map +1 -0
- package/dist/{utils → helpers}/normalize.js.map +1 -1
- package/dist/helpers/unescape-json-pointer.d.ts.map +1 -0
- package/dist/{utils → helpers}/unescape-json-pointer.js.map +1 -1
- package/dist/magic-proxy/proxy.d.ts +35 -10
- package/dist/magic-proxy/proxy.d.ts.map +1 -1
- package/dist/magic-proxy/proxy.js +40 -20
- package/dist/magic-proxy/proxy.js.map +2 -2
- package/esbuild.ts +1 -0
- package/package.json +6 -1
- package/src/bundle/bundle.test.ts +462 -25
- package/src/bundle/bundle.ts +37 -36
- package/src/bundle/plugins/fetch-urls/index.ts +2 -2
- package/src/bundle/plugins/parse-json/index.ts +1 -1
- package/src/bundle/plugins/parse-yaml/index.ts +3 -2
- package/src/bundle/plugins/read-files/index.ts +1 -1
- package/src/helpers/convert-to-local-ref.test.ts +211 -0
- package/src/helpers/convert-to-local-ref.ts +43 -0
- package/src/helpers/get-schemas.test.ts +356 -0
- package/src/helpers/get-schemas.ts +80 -0
- package/src/helpers/get-value-by-path.test.ts +338 -0
- package/src/helpers/get-value-by-path.ts +44 -0
- package/src/{utils → helpers}/is-json-object.ts +1 -1
- package/src/{utils → helpers}/json-path-utils.ts +0 -19
- package/src/{utils → helpers}/normalize.test.ts +2 -1
- package/src/magic-proxy/proxy.test.ts +548 -0
- package/src/magic-proxy/proxy.ts +80 -31
- package/dist/utils/escape-json-pointer.d.ts.map +0 -1
- package/dist/utils/get-segments-from-path.d.ts.map +0 -1
- package/dist/utils/is-json-object.d.ts.map +0 -1
- package/dist/utils/is-json-object.js.map +0 -7
- package/dist/utils/is-object.d.ts.map +0 -1
- package/dist/utils/is-yaml.d.ts.map +0 -1
- package/dist/utils/json-path-utils.d.ts.map +0 -1
- package/dist/utils/json-path-utils.js.map +0 -7
- package/dist/utils/normalize.d.ts.map +0 -1
- package/dist/utils/unescape-json-pointer.d.ts.map +0 -1
- /package/dist/{utils → helpers}/escape-json-pointer.d.ts +0 -0
- /package/dist/{utils → helpers}/escape-json-pointer.js +0 -0
- /package/dist/{utils → helpers}/get-segments-from-path.d.ts +0 -0
- /package/dist/{utils → helpers}/get-segments-from-path.js +0 -0
- /package/dist/{utils → helpers}/is-json-object.d.ts +0 -0
- /package/dist/{utils → helpers}/is-object.d.ts +0 -0
- /package/dist/{utils → helpers}/is-object.js +0 -0
- /package/dist/{utils → helpers}/is-yaml.d.ts +0 -0
- /package/dist/{utils → helpers}/is-yaml.js +0 -0
- /package/dist/{utils → helpers}/normalize.d.ts +0 -0
- /package/dist/{utils → helpers}/normalize.js +0 -0
- /package/dist/{utils → helpers}/unescape-json-pointer.d.ts +0 -0
- /package/dist/{utils → helpers}/unescape-json-pointer.js +0 -0
- /package/src/{utils → helpers}/escape-json-pointer.test.ts +0 -0
- /package/src/{utils → helpers}/escape-json-pointer.ts +0 -0
- /package/src/{utils → helpers}/get-segments-from-path.test.ts +0 -0
- /package/src/{utils → helpers}/get-segments-from-path.ts +0 -0
- /package/src/{utils → helpers}/is-object.test.ts +0 -0
- /package/src/{utils → helpers}/is-object.ts +0 -0
- /package/src/{utils → helpers}/is-yaml.ts +0 -0
- /package/src/{utils → helpers}/json-path-utils.test.ts +0 -0
- /package/src/{utils → helpers}/normalize.ts +0 -0
- /package/src/{utils → helpers}/unescape-json-pointer.test.ts +0 -0
- /package/src/{utils → helpers}/unescape-json-pointer.ts +0 -0
package/src/magic-proxy/proxy.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { convertToLocalRef } from '@/helpers/convert-to-local-ref'
|
|
2
|
+
import { getId, getSchemas } from '@/helpers/get-schemas'
|
|
3
|
+
import { getValueByPath } from '@/helpers/get-value-by-path'
|
|
4
|
+
import { isObject } from '@/helpers/is-object'
|
|
5
|
+
import { createPathFromSegments, parseJsonPointer } from '@/helpers/json-path-utils'
|
|
2
6
|
import type { UnknownObject } from '@/types'
|
|
3
|
-
import { getSegmentsFromPath } from '@/utils/get-segments-from-path'
|
|
4
|
-
import { isObject } from '@/utils/is-object'
|
|
5
|
-
import { createPathFromSegments, getValueByPath, parseJsonPointer } from '@/utils/json-path-utils'
|
|
6
7
|
|
|
7
8
|
const isMagicProxy = Symbol('isMagicProxy')
|
|
8
9
|
const magicProxyTarget = Symbol('magicProxyTarget')
|
|
@@ -14,16 +15,16 @@ const REF_KEY = '$ref'
|
|
|
14
15
|
* Creates a "magic" proxy for a given object or array, enabling transparent access to
|
|
15
16
|
* JSON Reference ($ref) values as if they were directly present on the object.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - All nested objects and arrays are recursively wrapped in proxies, so reference resolution
|
|
20
|
-
*
|
|
21
|
-
* - Properties starting with an underscore (_) are hidden and will not be accessible through
|
|
22
|
-
* the proxy (returns undefined on access, false on 'in' checks, excluded from enumeration).
|
|
18
|
+
* Features:
|
|
19
|
+
* - If an object contains a `$ref` property, accessing the special `$ref-value` property will resolve and return the referenced value from the root object.
|
|
20
|
+
* - All nested objects and arrays are recursively wrapped in proxies, so reference resolution works at any depth.
|
|
21
|
+
* - Properties starting with an underscore (_) are considered internal and are hidden by default: they return undefined on access, are excluded from enumeration, and `'in'` checks return false. This can be overridden with the `showInternal` option.
|
|
23
22
|
* - Setting, deleting, and enumerating properties works as expected, including for proxied references.
|
|
23
|
+
* - Ensures referential stability by caching proxies for the same target object.
|
|
24
24
|
*
|
|
25
25
|
* @param target - The object or array to wrap in a magic proxy
|
|
26
|
-
* @param
|
|
26
|
+
* @param options - Optional settings (e.g., showInternal to expose internal properties)
|
|
27
|
+
* @param args - Internal arguments for advanced usage (root object, proxy/cache maps, current context)
|
|
27
28
|
* @returns A proxied version of the input object/array with magic $ref-value support
|
|
28
29
|
*
|
|
29
30
|
* @example
|
|
@@ -50,18 +51,47 @@ const REF_KEY = '$ref'
|
|
|
50
51
|
*/
|
|
51
52
|
export const createMagicProxy = <T extends Record<keyof T & symbol, unknown>, S extends UnknownObject>(
|
|
52
53
|
target: T,
|
|
53
|
-
options?: { showInternal
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
options?: Partial<{ showInternal: boolean }>,
|
|
55
|
+
args: {
|
|
56
|
+
/**
|
|
57
|
+
* The root object for resolving local JSON references.
|
|
58
|
+
*/
|
|
59
|
+
root: S | T
|
|
60
|
+
/**
|
|
61
|
+
* Cache to store already created proxies for target objects to ensure referential stability.
|
|
62
|
+
*
|
|
63
|
+
* It is helpful when dealing with reactive frameworks like Vue,
|
|
64
|
+
*/
|
|
65
|
+
proxyCache: WeakMap<object, T>
|
|
66
|
+
/**
|
|
67
|
+
* Cache to store resolved JSON references.
|
|
68
|
+
*/
|
|
69
|
+
cache: Map<string, unknown>
|
|
70
|
+
/**
|
|
71
|
+
* Map of all schemas by their $id or $anchor for cross-document reference resolution.
|
|
72
|
+
*/
|
|
73
|
+
schemas: Map<string, string>
|
|
74
|
+
/**
|
|
75
|
+
* The current JSON path context within the root object.
|
|
76
|
+
*
|
|
77
|
+
* Used to resolve $anchor references correctly.
|
|
78
|
+
*/
|
|
79
|
+
currentContext: string
|
|
80
|
+
} = {
|
|
81
|
+
root: target,
|
|
82
|
+
proxyCache: new WeakMap(),
|
|
83
|
+
cache: new Map(),
|
|
84
|
+
schemas: getSchemas(target),
|
|
85
|
+
currentContext: '',
|
|
86
|
+
},
|
|
57
87
|
) => {
|
|
58
88
|
if (!isObject(target) && !Array.isArray(target)) {
|
|
59
89
|
return target
|
|
60
90
|
}
|
|
61
91
|
|
|
62
92
|
// Return existing proxy for the same target to ensure referential stability
|
|
63
|
-
if (proxyCache.has(target)) {
|
|
64
|
-
return proxyCache.get(target)
|
|
93
|
+
if (args.proxyCache.has(target)) {
|
|
94
|
+
return args.proxyCache.get(target)
|
|
65
95
|
}
|
|
66
96
|
|
|
67
97
|
const handler: ProxyHandler<T> = {
|
|
@@ -84,33 +114,45 @@ export const createMagicProxy = <T extends Record<keyof T & symbol, unknown>, S
|
|
|
84
114
|
return target
|
|
85
115
|
}
|
|
86
116
|
|
|
87
|
-
const ref = Reflect.get(target, REF_KEY, receiver)
|
|
88
|
-
|
|
89
117
|
// Hide properties starting with underscore - these are considered internal/private properties
|
|
90
118
|
// and should not be accessible through the magic proxy interface
|
|
91
119
|
if (typeof prop === 'string' && prop.startsWith('_') && !options?.showInternal) {
|
|
92
120
|
return undefined
|
|
93
121
|
}
|
|
94
122
|
|
|
123
|
+
// Get the $ref value of the current target (if any)
|
|
124
|
+
const ref = Reflect.get(target, REF_KEY, receiver)
|
|
125
|
+
// Get the identifier ($id) of the current target for context tracking
|
|
126
|
+
const id = getId(target)
|
|
127
|
+
|
|
95
128
|
// If accessing "$ref-value" and $ref is a local reference, resolve and return the referenced value
|
|
96
|
-
if (prop === REF_VALUE && typeof ref === 'string'
|
|
129
|
+
if (prop === REF_VALUE && typeof ref === 'string') {
|
|
97
130
|
// Check cache first for performance optimization
|
|
98
|
-
if (cache.has(ref)) {
|
|
99
|
-
return cache.get(ref)
|
|
131
|
+
if (args.cache.has(ref)) {
|
|
132
|
+
return args.cache.get(ref)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const path = convertToLocalRef(ref, id ?? args.currentContext, args.schemas)
|
|
136
|
+
|
|
137
|
+
if (path === undefined) {
|
|
138
|
+
return undefined
|
|
100
139
|
}
|
|
101
140
|
|
|
102
141
|
// Resolve the reference and create a new magic proxy
|
|
103
|
-
const resolvedValue = getValueByPath(root, parseJsonPointer(
|
|
104
|
-
const proxiedValue = createMagicProxy(resolvedValue, options,
|
|
142
|
+
const resolvedValue = getValueByPath(args.root, parseJsonPointer(`#/${path}`))
|
|
143
|
+
const proxiedValue = createMagicProxy(resolvedValue.value, options, {
|
|
144
|
+
...args,
|
|
145
|
+
currentContext: resolvedValue.context,
|
|
146
|
+
})
|
|
105
147
|
|
|
106
148
|
// Store in cache for future lookups
|
|
107
|
-
cache.set(ref, proxiedValue)
|
|
149
|
+
args.cache.set(ref, proxiedValue)
|
|
108
150
|
return proxiedValue
|
|
109
151
|
}
|
|
110
152
|
|
|
111
153
|
// For all other properties, recursively wrap the value in a magic proxy
|
|
112
154
|
const value = Reflect.get(target, prop, receiver)
|
|
113
|
-
return createMagicProxy(value as T, options,
|
|
155
|
+
return createMagicProxy(value as T, options, { ...args, currentContext: id ?? args.currentContext })
|
|
114
156
|
},
|
|
115
157
|
/**
|
|
116
158
|
* Proxy "set" trap for magic proxy.
|
|
@@ -127,18 +169,25 @@ export const createMagicProxy = <T extends Record<keyof T & symbol, unknown>, S
|
|
|
127
169
|
return true
|
|
128
170
|
}
|
|
129
171
|
|
|
130
|
-
if (prop === REF_VALUE && typeof ref === 'string'
|
|
131
|
-
const
|
|
172
|
+
if (prop === REF_VALUE && typeof ref === 'string') {
|
|
173
|
+
const id = getId(target)
|
|
174
|
+
const path = convertToLocalRef(ref, id ?? args.currentContext, args.schemas)
|
|
175
|
+
|
|
176
|
+
if (path === undefined) {
|
|
177
|
+
return undefined
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const segments = parseJsonPointer(`#/${path}`)
|
|
132
181
|
|
|
133
182
|
if (segments.length === 0) {
|
|
134
183
|
return false // Can not set top level $ref-value
|
|
135
184
|
}
|
|
136
185
|
|
|
137
186
|
// Get the parent node or create it if it does not exist
|
|
138
|
-
const getParentNode = () => getValueByPath(root, segments.slice(0, -1))
|
|
187
|
+
const getParentNode = () => getValueByPath(args.root, segments.slice(0, -1)).value
|
|
139
188
|
|
|
140
189
|
if (getParentNode() === undefined) {
|
|
141
|
-
createPathFromSegments(root, segments.slice(0, -1))
|
|
190
|
+
createPathFromSegments(args.root, segments.slice(0, -1))
|
|
142
191
|
|
|
143
192
|
// In this case the ref is pointing to an invalid path, so we warn the user
|
|
144
193
|
console.warn(
|
|
@@ -233,7 +282,7 @@ export const createMagicProxy = <T extends Record<keyof T & symbol, unknown>, S
|
|
|
233
282
|
}
|
|
234
283
|
|
|
235
284
|
const proxied = new Proxy<T>(target, handler)
|
|
236
|
-
proxyCache.set(target, proxied)
|
|
285
|
+
args.proxyCache.set(target, proxied)
|
|
237
286
|
return proxied
|
|
238
287
|
}
|
|
239
288
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escape-json-pointer.d.ts","sourceRoot":"","sources":["../../src/utils/escape-json-pointer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAE5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-segments-from-path.d.ts","sourceRoot":"","sources":["../../src/utils/get-segments-from-path.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,YAW/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-json-object.d.ts","sourceRoot":"","sources":["../../src/utils/is-json-object.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,WAYzC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/is-json-object.ts"],
|
|
4
|
-
"sourcesContent": ["import { isObject } from '@/utils/is-object'\n\n/**\n * Determines if a string represents a valid JSON object (i.e., a plain object, not an array, primitive, or null).\n * The function first checks if the string appears to start with an opening curly brace (ignoring leading whitespace),\n * which is a quick heuristic to rule out arrays, primitives, and most invalid JSON. If this check passes,\n * it attempts to parse the string with JSON.parse. The result is then checked to ensure it is a plain object\n * (not an array, null, or primitive) using the isObject utility.\n *\n * @param value - The string to evaluate\n * @returns true if the string is valid JSON and parses to a plain object, false otherwise\n *\n * @example\n * isJsonObject('{\"foo\": \"bar\"}') // true\n * isJsonObject('[1,2,3]') // false\n * isJsonObject('not json') // false\n * isJsonObject('42') // false\n */\nexport function isJsonObject(value: string) {\n // Quickly rule out anything that doesn't start with an object brace\n if (!/^\\s*(\\{)/.test(value.slice(0, 500))) {\n return false\n }\n\n try {\n const val = JSON.parse(value)\n return isObject(val)\n } catch {\n return false\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AAkBlB,SAAS,aAAa,OAAe;AAE1C,MAAI,CAAC,WAAW,KAAK,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,KAAK;AAC5B,WAAO,SAAS,GAAG;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../src/utils/is-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,MAAwE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-yaml.d.ts","sourceRoot":"","sources":["../../src/utils/is-yaml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-path-utils.d.ts","sourceRoot":"","sources":["../../src/utils/json-path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAO1E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAWlE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/json-path-utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Parses a JSON Pointer string into an array of path segments\n *\n * @example\n * ```ts\n * parseJsonPointer('#/components/schemas/User')\n *\n * ['components', 'schemas', 'User']\n * ```\n */\nexport function parseJsonPointer(pointer: string): string[] {\n return (\n pointer\n // Split on '/'\n .split('/')\n // Remove the leading '#' if present\n .filter((segment, index) => (index !== 0 || segment !== '#') && segment)\n )\n}\n\n/**\n * Retrieves a nested value from the source document using a path array\n *\n * @example\n * ```ts\n * getValueByPath(document, ['components', 'schemas', 'User'])\n *\n * { id: '123', name: 'John Doe' }\n * ```\n */\nexport function getValueByPath<R = unknown>(obj: any, pointer: string[]): R {\n return pointer.reduce((acc, part) => {\n if (acc === undefined || acc === null) {\n return undefined\n }\n return acc[part]\n }, obj)\n}\n\n/**\n * Creates a nested path in an object from an array of path segments.\n * Only creates intermediate objects/arrays if they don't already exist.\n *\n * @param obj - The target object to create the path in\n * @param segments - Array of path segments to create\n * @returns The final nested object/array at the end of the path\n *\n * @example\n * ```ts\n * const obj = {}\n * createPathFromSegments(obj, ['components', 'schemas', 'User'])\n * // Creates: { components: { schemas: { User: {} } } }\n *\n * createPathFromSegments(obj, ['items', '0', 'name'])\n * // Creates: { items: [{ name: {} }] }\n * ```\n */\nexport function createPathFromSegments(obj: any, segments: string[]) {\n return segments.reduce((acc, part) => {\n if (acc[part] === undefined) {\n if (isNaN(Number(part))) {\n acc[part] = {}\n } else {\n acc[part] = []\n }\n }\n return acc[part]\n }, obj)\n}\n"],
|
|
5
|
-
"mappings": "AAUO,SAAS,iBAAiB,SAA2B;AAC1D,SACE,QAEG,MAAM,GAAG,EAET,OAAO,CAAC,SAAS,WAAW,UAAU,KAAK,YAAY,QAAQ,OAAO;AAE7E;AAYO,SAAS,eAA4B,KAAU,SAAsB;AAC1E,SAAO,QAAQ,OAAO,CAAC,KAAK,SAAS;AACnC,QAAI,QAAQ,UAAa,QAAQ,MAAM;AACrC,aAAO;AAAA,IACT;AACA,WAAO,IAAI,IAAI;AAAA,EACjB,GAAG,GAAG;AACR;AAoBO,SAAS,uBAAuB,KAAU,UAAoB;AACnE,SAAO,SAAS,OAAO,CAAC,KAAK,SAAS;AACpC,QAAI,IAAI,IAAI,MAAM,QAAW;AAC3B,UAAI,MAAM,OAAO,IAAI,CAAC,GAAG;AACvB,YAAI,IAAI,IAAI,CAAC;AAAA,MACf,OAAO;AACL,YAAI,IAAI,IAAI,CAAC;AAAA,MACf;AAAA,IACF;AACA,WAAO,IAAI,IAAI;AAAA,EACjB,GAAG,GAAG;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,OA4BrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unescape-json-pointer.d.ts","sourceRoot":"","sources":["../../src/utils/unescape-json-pointer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,UAE9C"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|