toolcraft-openapi 0.0.549 → 0.0.551
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/dist/composition.json
CHANGED
|
@@ -10,59 +10,72 @@ export function isJsonValue(value, options = {}) {
|
|
|
10
10
|
const maxDepth = options.maxDepth ?? 64;
|
|
11
11
|
if (maxNodes !== Infinity && (!Number.isSafeInteger(maxNodes) || maxNodes < 1))
|
|
12
12
|
throw new Error("maxNodes must be a positive safe integer");
|
|
13
|
-
if (!Number.isSafeInteger(maxDepth) || maxDepth < 0
|
|
14
|
-
throw new Error("maxDepth must be
|
|
13
|
+
if (maxDepth !== Infinity && (!Number.isSafeInteger(maxDepth) || maxDepth < 0))
|
|
14
|
+
throw new Error("maxDepth must be a nonnegative safe integer");
|
|
15
15
|
const ancestors = new Set();
|
|
16
|
+
const stack = [];
|
|
17
|
+
function* properties(item) {
|
|
18
|
+
if (Array.isArray(item)) {
|
|
19
|
+
for (let index = 0; index < item.length; index++)
|
|
20
|
+
yield Object.getOwnPropertyDescriptor(item, String(index));
|
|
21
|
+
}
|
|
22
|
+
else
|
|
23
|
+
for (const key in item) {
|
|
24
|
+
const property = Object.getOwnPropertyDescriptor(item, key);
|
|
25
|
+
if (property !== undefined)
|
|
26
|
+
yield property;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
let nodes = 0;
|
|
17
|
-
|
|
30
|
+
let item = value, depth = 0;
|
|
31
|
+
while (true) {
|
|
18
32
|
if (++nodes > maxNodes || depth > maxDepth)
|
|
19
33
|
return false;
|
|
20
|
-
if (item
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return Number.isFinite(item);
|
|
24
|
-
if (typeof item !== "object" || ancestors.has(item))
|
|
25
|
-
return false;
|
|
26
|
-
if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype &&
|
|
27
|
-
Object.getPrototypeOf(item) !== null)
|
|
28
|
-
return false;
|
|
29
|
-
let hookOwner = item;
|
|
30
|
-
let prototypeDepth = 0;
|
|
31
|
-
while (hookOwner !== null) {
|
|
32
|
-
if (++prototypeDepth > 64)
|
|
33
|
-
return false;
|
|
34
|
-
const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
|
|
35
|
-
if (serializationHook !== undefined) {
|
|
36
|
-
if (!("value" in serializationHook) || typeof serializationHook.value === "function")
|
|
34
|
+
if (item !== null && typeof item !== "string" && typeof item !== "boolean") {
|
|
35
|
+
if (typeof item === "number") {
|
|
36
|
+
if (!Number.isFinite(item))
|
|
37
37
|
return false;
|
|
38
|
-
break;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
else {
|
|
40
|
+
if (typeof item !== "object" || ancestors.has(item))
|
|
41
|
+
return false;
|
|
42
|
+
if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype &&
|
|
43
|
+
Object.getPrototypeOf(item) !== null)
|
|
44
|
+
return false;
|
|
45
|
+
let hookOwner = item;
|
|
46
|
+
let prototypeDepth = 0;
|
|
47
|
+
while (hookOwner !== null) {
|
|
48
|
+
if (++prototypeDepth > 64)
|
|
49
|
+
return false;
|
|
50
|
+
const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
|
|
51
|
+
if (serializationHook !== undefined) {
|
|
52
|
+
if (!("value" in serializationHook) || typeof serializationHook.value === "function")
|
|
53
|
+
return false;
|
|
52
54
|
break;
|
|
53
55
|
}
|
|
56
|
+
hookOwner = Object.getPrototypeOf(hookOwner);
|
|
54
57
|
}
|
|
58
|
+
if (Array.isArray(item) && item.length > maxNodes)
|
|
59
|
+
return false;
|
|
60
|
+
ancestors.add(item);
|
|
61
|
+
stack.push({ owner: item, children: properties(item), depth });
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
let next;
|
|
65
|
+
while (stack.length) {
|
|
66
|
+
const frame = stack[stack.length - 1];
|
|
67
|
+
next = frame.children.next();
|
|
68
|
+
if (!next.done) {
|
|
69
|
+
if (next.value === undefined || !("value" in next.value))
|
|
70
|
+
return false;
|
|
71
|
+
item = next.value.value;
|
|
72
|
+
depth = frame.depth + 1;
|
|
73
|
+
break;
|
|
63
74
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
ancestors.delete(frame.owner);
|
|
76
|
+
stack.pop();
|
|
77
|
+
}
|
|
78
|
+
if (!stack.length)
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
68
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.551",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"toolcraft-openapi-generate": "dist/bin/generate.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"toolcraft": "0.0.
|
|
33
|
+
"toolcraft": "0.0.551",
|
|
34
34
|
"fast-string-width": "^3.0.2",
|
|
35
35
|
"fast-wrap-ansi": "^0.2.0",
|
|
36
36
|
"sisteransi": "^1.0.5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"directory": "packages/toolcraft-openapi"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"toolcraft-schema": "0.0.
|
|
48
|
+
"toolcraft-schema": "0.0.551",
|
|
49
49
|
"toolcraft-design": "*",
|
|
50
50
|
"@poe-code/frontmatter": "*"
|
|
51
51
|
},
|