@stryke/json 0.9.44 → 0.10.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 +7 -0
- package/dist/code-frames-BMkA9i6j.d.mts +17 -0
- package/dist/code-frames-BMkA9i6j.d.mts.map +1 -0
- package/dist/code-frames-BUtrssZ5.d.cts +17 -0
- package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
- package/dist/code-frames-Cv8r5tSN.cjs +82 -0
- package/dist/code-frames-DISWdYL6.mjs +77 -0
- package/dist/code-frames-DISWdYL6.mjs.map +1 -0
- package/dist/find-reference-BCg3dQx1.cjs +157 -0
- package/dist/find-reference-C-YleCds.d.cts +52 -0
- package/dist/find-reference-C-YleCds.d.cts.map +1 -0
- package/dist/find-reference-b7rRdLFx.d.mts +52 -0
- package/dist/find-reference-b7rRdLFx.d.mts.map +1 -0
- package/dist/find-reference-woYMiWzN.mjs +135 -0
- package/dist/find-reference-woYMiWzN.mjs.map +1 -0
- package/dist/index-B_e8BwCm.d.cts +1 -0
- package/dist/index-CDAfh8Ew.d.cts +1 -0
- package/dist/index-DwO9IdNa.d.mts +1 -0
- package/dist/index-VWno75SQ.d.mts +1 -0
- package/dist/index.cjs +32 -14
- package/dist/index.d.cts +11 -8
- package/dist/index.d.mts +12 -9
- package/dist/index.mjs +13 -8
- package/dist/is-number-BIwzZzyi.mjs +31 -0
- package/dist/is-number-BIwzZzyi.mjs.map +1 -0
- package/dist/is-number-c5xguIbS.cjs +42 -0
- package/dist/{type-checks/src/is-plain-object.mjs → is-object-BpfmzHWa.mjs} +19 -3
- package/dist/is-object-BpfmzHWa.mjs.map +1 -0
- package/dist/{type-checks/src/is-plain-object.cjs → is-object-umGh91v1.cjs} +24 -3
- package/dist/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
- package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
- package/dist/is-string-CLiBUSKV.mjs.map +1 -0
- package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
- package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
- package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
- package/dist/parse-BGlhbY16.d.cts +9 -0
- package/dist/parse-BGlhbY16.d.cts.map +1 -0
- package/dist/parse-Crgv3Nl1.mjs +81 -0
- package/dist/parse-Crgv3Nl1.mjs.map +1 -0
- package/dist/parse-DZfi3d96.d.cts +51 -0
- package/dist/parse-DZfi3d96.d.cts.map +1 -0
- package/dist/parse-DgYW5BBj.d.mts +9 -0
- package/dist/parse-DgYW5BBj.d.mts.map +1 -0
- package/dist/parse-KiRakdIR.cjs +127 -0
- package/dist/parse-ZRTh45ZI.d.mts +51 -0
- package/dist/parse-ZRTh45ZI.d.mts.map +1 -0
- package/dist/parse-error-7K8s4vWf.d.cts +15 -0
- package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
- package/dist/parse-error-C3Qmubee.mjs +34 -0
- package/dist/parse-error-C3Qmubee.mjs.map +1 -0
- package/dist/parse-error-DY_MelEh.d.mts +15 -0
- package/dist/parse-error-DY_MelEh.d.mts.map +1 -0
- package/dist/parse-error-Dzwg4sdE.cjs +39 -0
- package/dist/parse-obdkJfj5.mjs +52 -0
- package/dist/parse-obdkJfj5.mjs.map +1 -0
- package/dist/parse-wxSDzBPf.cjs +62 -0
- package/dist/pointer/find-reference.cjs +5 -65
- package/dist/pointer/find-reference.d.cts +2 -52
- package/dist/pointer/find-reference.d.mts +2 -52
- package/dist/pointer/find-reference.mjs +2 -63
- package/dist/pointer/index.cjs +15 -14
- package/dist/pointer/index.d.cts +2 -2
- package/dist/pointer/index.d.mts +2 -2
- package/dist/pointer/index.mjs +3 -2
- package/dist/pointer/parse.cjs +9 -86
- package/dist/pointer/parse.d.cts +2 -44
- package/dist/pointer/parse.d.mts +2 -44
- package/dist/pointer/parse.mjs +2 -80
- package/dist/pointer-Cc7IR0Bj.cjs +0 -0
- package/dist/pointer-CiTXvh1G.mjs +0 -0
- package/dist/schema-B1RVJHzJ.d.cts +7 -0
- package/dist/schema-B1RVJHzJ.d.cts.map +1 -0
- package/dist/schema-CfhPLy30.mjs +9 -0
- package/dist/schema-CfhPLy30.mjs.map +1 -0
- package/dist/schema-D5Aqvh2i.cjs +14 -0
- package/dist/schema-ai_NU-JC.d.mts +7 -0
- package/dist/schema-ai_NU-JC.d.mts.map +1 -0
- package/dist/schema.cjs +3 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.mts +3 -0
- package/dist/schema.mjs +3 -0
- package/dist/storm-json-6WpS7qnH.cjs +154 -0
- package/dist/storm-json-AaFeOao2.d.cts +70 -0
- package/dist/storm-json-AaFeOao2.d.cts.map +1 -0
- package/dist/storm-json-BvRkzAlR.d.mts +70 -0
- package/dist/storm-json-BvRkzAlR.d.mts.map +1 -0
- package/dist/storm-json-Cy3PuAhj.mjs +116 -0
- package/dist/storm-json-Cy3PuAhj.mjs.map +1 -0
- package/dist/storm-json.cjs +3 -116
- package/dist/storm-json.d.cts +2 -70
- package/dist/storm-json.d.mts +3 -70
- package/dist/storm-json.mjs +3 -115
- package/dist/stringify-B6iAeg0u.d.mts +13 -0
- package/dist/stringify-B6iAeg0u.d.mts.map +1 -0
- package/dist/stringify-Bc8OkhIr.d.cts +13 -0
- package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
- package/dist/stringify-D5baUfEe.mjs +68 -0
- package/dist/stringify-D5baUfEe.mjs.map +1 -0
- package/dist/stringify-DEw3S4_Z.cjs +78 -0
- package/dist/strip-comments-Bg3R_Y4S.d.mts +11 -0
- package/dist/strip-comments-Bg3R_Y4S.d.mts.map +1 -0
- package/dist/strip-comments-CMaAgTqz.mjs +89 -0
- package/dist/strip-comments-CMaAgTqz.mjs.map +1 -0
- package/dist/strip-comments-CtFoX0xG.cjs +94 -0
- package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
- package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
- package/dist/types-BUeTTE_U.d.cts +222 -0
- package/dist/types-BUeTTE_U.d.cts.map +1 -0
- package/dist/types-C_KlcCNw.d.mts +222 -0
- package/dist/types-C_KlcCNw.d.mts.map +1 -0
- package/dist/types.d.cts +2 -69
- package/dist/types.d.mts +2 -69
- package/dist/types.mjs +0 -1
- package/dist/utils/code-frames.cjs +2 -76
- package/dist/utils/code-frames.d.cts +2 -17
- package/dist/utils/code-frames.d.mts +2 -17
- package/dist/utils/code-frames.mjs +2 -76
- package/dist/utils/index.cjs +13 -12
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.mts +6 -5
- package/dist/utils/index.mjs +6 -5
- package/dist/utils/parse-error.cjs +2 -33
- package/dist/utils/parse-error.d.cts +2 -15
- package/dist/utils/parse-error.d.mts +2 -15
- package/dist/utils/parse-error.mjs +2 -33
- package/dist/utils/parse.cjs +3 -51
- package/dist/utils/parse.d.cts +2 -9
- package/dist/utils/parse.d.mts +2 -9
- package/dist/utils/parse.mjs +2 -51
- package/dist/utils/stringify.cjs +3 -67
- package/dist/utils/stringify.d.cts +2 -13
- package/dist/utils/stringify.d.mts +2 -13
- package/dist/utils/stringify.mjs +2 -67
- package/dist/utils/strip-comments.cjs +2 -85
- package/dist/utils/strip-comments.d.cts +2 -11
- package/dist/utils/strip-comments.d.mts +2 -11
- package/dist/utils/strip-comments.mjs +2 -86
- package/dist/utils-CVcIdLuL.mjs +0 -0
- package/dist/utils-Cz3OCwUK.cjs +0 -0
- package/package.json +7 -2
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/pointer/find-reference.d.cts.map +0 -1
- package/dist/pointer/find-reference.d.mts.map +0 -1
- package/dist/pointer/find-reference.mjs.map +0 -1
- package/dist/pointer/parse.d.cts.map +0 -1
- package/dist/pointer/parse.d.mts.map +0 -1
- package/dist/pointer/parse.mjs.map +0 -1
- package/dist/storm-json.d.cts.map +0 -1
- package/dist/storm-json.d.mts.map +0 -1
- package/dist/storm-json.mjs.map +0 -1
- package/dist/type-checks/src/get-object-tag.cjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
- package/dist/type-checks/src/is-empty.cjs +0 -20
- package/dist/type-checks/src/is-empty.mjs +0 -21
- package/dist/type-checks/src/is-empty.mjs.map +0 -1
- package/dist/type-checks/src/is-non-null-object.cjs +0 -16
- package/dist/type-checks/src/is-non-null-object.mjs +0 -17
- package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
- package/dist/type-checks/src/is-null.cjs +0 -12
- package/dist/type-checks/src/is-null.mjs +0 -12
- package/dist/type-checks/src/is-null.mjs.map +0 -1
- package/dist/type-checks/src/is-number.cjs +0 -18
- package/dist/type-checks/src/is-number.mjs +0 -18
- package/dist/type-checks/src/is-number.mjs.map +0 -1
- package/dist/type-checks/src/is-object.cjs +0 -19
- package/dist/type-checks/src/is-object.mjs +0 -20
- package/dist/type-checks/src/is-object.mjs.map +0 -1
- package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set-object.cjs +0 -19
- package/dist/type-checks/src/is-set-object.mjs +0 -20
- package/dist/type-checks/src/is-set-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set.cjs +0 -19
- package/dist/type-checks/src/is-set.mjs +0 -20
- package/dist/type-checks/src/is-set.mjs.map +0 -1
- package/dist/type-checks/src/is-string.mjs.map +0 -1
- package/dist/type-checks/src/is-undefined.mjs.map +0 -1
- package/dist/types/src/base.cjs +0 -6
- package/dist/types/src/base.mjs +0 -6
- package/dist/types/src/base.mjs.map +0 -1
- package/dist/types/src/json.d.cts +0 -12
- package/dist/types/src/json.d.cts.map +0 -1
- package/dist/types/src/json.d.mts +0 -12
- package/dist/types/src/json.d.mts.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/utils/code-frames.d.cts.map +0 -1
- package/dist/utils/code-frames.d.mts.map +0 -1
- package/dist/utils/code-frames.mjs.map +0 -1
- package/dist/utils/parse-error.d.cts.map +0 -1
- package/dist/utils/parse-error.d.mts.map +0 -1
- package/dist/utils/parse-error.mjs.map +0 -1
- package/dist/utils/parse.d.cts.map +0 -1
- package/dist/utils/parse.d.mts.map +0 -1
- package/dist/utils/parse.mjs.map +0 -1
- package/dist/utils/stringify.d.cts.map +0 -1
- package/dist/utils/stringify.d.mts.map +0 -1
- package/dist/utils/stringify.mjs.map +0 -1
- package/dist/utils/strip-comments.d.cts.map +0 -1
- package/dist/utils/strip-comments.d.mts.map +0 -1
- package/dist/utils/strip-comments.mjs.map +0 -1
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isSetObject } from "../type-checks/src/is-set-object.mjs";
|
|
1
|
+
import { i as isObjectReference, n as isArrayEnd, r as isArrayReference, t as find } from "../find-reference-woYMiWzN.mjs";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
const { isArray } = Array;
|
|
6
|
-
/**
|
|
7
|
-
* Finds a target in document specified by JSON Pointer. Also returns the
|
|
8
|
-
* object containing the target and key used to reference that object.
|
|
9
|
-
*
|
|
10
|
-
* Throws Error('NOT_FOUND') if pointer does not result into a value in the middle
|
|
11
|
-
* of the path. If the last element of the path does not result into a value, the
|
|
12
|
-
* lookup succeeds with `val` set to `undefined`. It can be used to discriminate
|
|
13
|
-
* missing values, because `undefined` is not a valid JSON value.
|
|
14
|
-
*
|
|
15
|
-
* If last element in array is targeted using "-", e.g. "/arr/-", use
|
|
16
|
-
* `isArrayEnd` to verify that:
|
|
17
|
-
*
|
|
18
|
-
* ```js
|
|
19
|
-
* const ref = find({arr: [1, 2, 3], ['arr', '-']});
|
|
20
|
-
* if (isArrayReference(ref)) {
|
|
21
|
-
* if (isArrayEnd(ref)) {
|
|
22
|
-
* // ...
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param val - Document to search in.
|
|
28
|
-
* @param path - JSON Pointer path.
|
|
29
|
-
* @returns Reference to the target.
|
|
30
|
-
*/
|
|
31
|
-
const find = (val, path) => {
|
|
32
|
-
const pathLength = path.length;
|
|
33
|
-
if (!pathLength) return { val };
|
|
34
|
-
let obj;
|
|
35
|
-
let key;
|
|
36
|
-
for (let i = 0; i < pathLength; i++) {
|
|
37
|
-
obj = val;
|
|
38
|
-
key = path[i];
|
|
39
|
-
if (isArray(obj)) {
|
|
40
|
-
const length = obj.length;
|
|
41
|
-
if (key === "-") key = length;
|
|
42
|
-
else if (isString(key)) {
|
|
43
|
-
const key2 = Math.trunc(Number.parseInt(key));
|
|
44
|
-
if (String(key2) !== key) throw new Error("INVALID_INDEX");
|
|
45
|
-
key = key2;
|
|
46
|
-
if (key < 0) throw new Error("INVALID_INDEX");
|
|
47
|
-
}
|
|
48
|
-
if (key) val = obj[key];
|
|
49
|
-
} else if (isSetObject(obj)) val = key && key in obj ? obj[key] : void 0;
|
|
50
|
-
else throw new Error("NOT_FOUND");
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
val,
|
|
54
|
-
obj,
|
|
55
|
-
key
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const isArrayReference = (ref) => isArray(ref.obj) && typeof ref.key === "number";
|
|
59
|
-
const isArrayEnd = (ref) => ref.obj.length === ref.key;
|
|
60
|
-
const isObjectReference = (ref) => typeof ref.obj === "object" && typeof ref.key === "string";
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { find, isArrayEnd, isArrayReference, isObjectReference };
|
|
64
|
-
//# sourceMappingURL=find-reference.mjs.map
|
|
3
|
+
export { find, isArrayEnd, isArrayReference, isObjectReference };
|
package/dist/pointer/index.cjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_find_reference = require('../find-reference-BCg3dQx1.cjs');
|
|
2
|
+
const require_parse = require('../parse-KiRakdIR.cjs');
|
|
3
|
+
require('../pointer-Cc7IR0Bj.cjs');
|
|
3
4
|
|
|
4
|
-
exports.escapePointerSegment =
|
|
5
|
-
exports.find =
|
|
6
|
-
exports.formatJsonPointer =
|
|
7
|
-
exports.isArrayEnd =
|
|
8
|
-
exports.isArrayReference =
|
|
9
|
-
exports.isInteger =
|
|
10
|
-
exports.isObjectReference =
|
|
11
|
-
exports.isRoot =
|
|
12
|
-
exports.isValidIndex =
|
|
13
|
-
exports.parent =
|
|
14
|
-
exports.parseJsonPointer =
|
|
15
|
-
exports.unescapePointerSegment =
|
|
5
|
+
exports.escapePointerSegment = require_parse.escapePointerSegment;
|
|
6
|
+
exports.find = require_find_reference.find;
|
|
7
|
+
exports.formatJsonPointer = require_parse.formatJsonPointer;
|
|
8
|
+
exports.isArrayEnd = require_find_reference.isArrayEnd;
|
|
9
|
+
exports.isArrayReference = require_find_reference.isArrayReference;
|
|
10
|
+
exports.isInteger = require_parse.isInteger;
|
|
11
|
+
exports.isObjectReference = require_find_reference.isObjectReference;
|
|
12
|
+
exports.isRoot = require_parse.isRoot;
|
|
13
|
+
exports.isValidIndex = require_parse.isValidIndex;
|
|
14
|
+
exports.parent = require_parse.parent;
|
|
15
|
+
exports.parseJsonPointer = require_parse.parseJsonPointer;
|
|
16
|
+
exports.unescapePointerSegment = require_parse.unescapePointerSegment;
|
package/dist/pointer/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-C-YleCds.cjs";
|
|
2
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-DZfi3d96.cjs";
|
|
3
3
|
export { ArrayReference, ObjectReference, Reference, escapePointerSegment, find, formatJsonPointer, isArrayEnd, isArrayReference, isInteger, isObjectReference, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
package/dist/pointer/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-b7rRdLFx.mjs";
|
|
2
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-ZRTh45ZI.mjs";
|
|
3
3
|
export { ArrayReference, ObjectReference, Reference, escapePointerSegment, find, formatJsonPointer, isArrayEnd, isArrayReference, isInteger, isObjectReference, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
package/dist/pointer/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as isObjectReference, n as isArrayEnd, r as isArrayReference, t as find } from "../find-reference-woYMiWzN.mjs";
|
|
2
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-Crgv3Nl1.mjs";
|
|
3
|
+
import "../pointer-CiTXvh1G.mjs";
|
|
3
4
|
|
|
4
5
|
export { escapePointerSegment, find, formatJsonPointer, isArrayEnd, isArrayReference, isInteger, isObjectReference, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
package/dist/pointer/parse.cjs
CHANGED
|
@@ -1,87 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_is_number = require('../type-checks/src/is-number.cjs');
|
|
1
|
+
const require_parse = require('../parse-KiRakdIR.cjs');
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param segment - JSON pointer path segment.
|
|
13
|
-
* @returns Escaped JSON pointer path segment.
|
|
14
|
-
*/
|
|
15
|
-
function escapePointerSegment(segment) {
|
|
16
|
-
if (!segment.includes("/") && !segment.includes("~")) return segment;
|
|
17
|
-
return segment.replace(TILDE, "~0").replace(FORWARD_SLASH, "~1");
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Unescapes a JSON pointer path segment.
|
|
21
|
-
*
|
|
22
|
-
* @param segment - JSON pointer path segment.
|
|
23
|
-
* @returns Unescaped JSON pointer path segment.
|
|
24
|
-
*/
|
|
25
|
-
function unescapePointerSegment(segment) {
|
|
26
|
-
if (!segment.includes("~")) return segment;
|
|
27
|
-
return segment.replace(TILDE_ONE, "/").replace(TILDE_ZERO, "~");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
31
|
-
* also un-escaping reserved characters.
|
|
32
|
-
*/
|
|
33
|
-
function parseJsonPointer(pointer) {
|
|
34
|
-
if (!pointer) return [];
|
|
35
|
-
return pointer.slice(1).split("/").map((segment) => unescapePointerSegment(segment));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
39
|
-
* like "/foo/bar".
|
|
40
|
-
*/
|
|
41
|
-
function formatJsonPointer(path) {
|
|
42
|
-
if (isRoot(path)) return "";
|
|
43
|
-
return `/${path.map((segment) => escapePointerSegment(String(segment))).join("/")}`;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
47
|
-
*/
|
|
48
|
-
const isRoot = (path) => require_is_string.isString(path) ? path === "" : require_is_number.isNumber(path) ? path === 0 : Array.isArray(path) && path.length === 0;
|
|
49
|
-
/**
|
|
50
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
51
|
-
*/
|
|
52
|
-
function parent(path) {
|
|
53
|
-
if (path.length === 0) throw new Error("NO_PARENT");
|
|
54
|
-
return path.slice(0, -1);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if path component can be a valid array index.
|
|
58
|
-
*/
|
|
59
|
-
function isValidIndex(index) {
|
|
60
|
-
if (require_is_number.isNumber(index)) return true;
|
|
61
|
-
const n = Number.parseInt(index, 10);
|
|
62
|
-
return String(n) === index && n >= 0;
|
|
63
|
-
}
|
|
64
|
-
const isInteger = (str) => {
|
|
65
|
-
const len = str.length;
|
|
66
|
-
let i = 0;
|
|
67
|
-
let charCode;
|
|
68
|
-
while (i < len) {
|
|
69
|
-
charCode = str.codePointAt(i);
|
|
70
|
-
if (charCode >= 48 && charCode <= 57) {
|
|
71
|
-
i++;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
exports.escapePointerSegment = escapePointerSegment;
|
|
81
|
-
exports.formatJsonPointer = formatJsonPointer;
|
|
82
|
-
exports.isInteger = isInteger;
|
|
83
|
-
exports.isRoot = isRoot;
|
|
84
|
-
exports.isValidIndex = isValidIndex;
|
|
85
|
-
exports.parent = parent;
|
|
86
|
-
exports.parseJsonPointer = parseJsonPointer;
|
|
87
|
-
exports.unescapePointerSegment = unescapePointerSegment;
|
|
3
|
+
exports.escapePointerSegment = require_parse.escapePointerSegment;
|
|
4
|
+
exports.formatJsonPointer = require_parse.formatJsonPointer;
|
|
5
|
+
exports.isInteger = require_parse.isInteger;
|
|
6
|
+
exports.isRoot = require_parse.isRoot;
|
|
7
|
+
exports.isValidIndex = require_parse.isValidIndex;
|
|
8
|
+
exports.parent = require_parse.parent;
|
|
9
|
+
exports.parseJsonPointer = require_parse.parseJsonPointer;
|
|
10
|
+
exports.unescapePointerSegment = require_parse.unescapePointerSegment;
|
package/dist/pointer/parse.d.cts
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/pointer/parse.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Escapes a JSON pointer path segment.
|
|
7
|
-
*
|
|
8
|
-
* @param segment - JSON pointer path segment.
|
|
9
|
-
* @returns Escaped JSON pointer path segment.
|
|
10
|
-
*/
|
|
11
|
-
declare function escapePointerSegment(segment: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Unescapes a JSON pointer path segment.
|
|
14
|
-
*
|
|
15
|
-
* @param segment - JSON pointer path segment.
|
|
16
|
-
* @returns Unescaped JSON pointer path segment.
|
|
17
|
-
*/
|
|
18
|
-
declare function unescapePointerSegment(segment: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
21
|
-
* also un-escaping reserved characters.
|
|
22
|
-
*/
|
|
23
|
-
declare function parseJsonPointer(pointer: string): JsonPointerPath;
|
|
24
|
-
/**
|
|
25
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
26
|
-
* like "/foo/bar".
|
|
27
|
-
*/
|
|
28
|
-
declare function formatJsonPointer(path: JsonPointerPath): string;
|
|
29
|
-
/**
|
|
30
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
31
|
-
*/
|
|
32
|
-
declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
35
|
-
*/
|
|
36
|
-
declare function parent(path: JsonPointerPath): JsonPointerPath;
|
|
37
|
-
/**
|
|
38
|
-
* Check if path component can be a valid array index.
|
|
39
|
-
*/
|
|
40
|
-
declare function isValidIndex(index: string | number): boolean;
|
|
41
|
-
declare const isInteger: (str: string) => boolean;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
|
44
|
-
//# sourceMappingURL=parse.d.cts.map
|
|
1
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-DZfi3d96.cjs";
|
|
2
|
+
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
package/dist/pointer/parse.d.mts
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/pointer/parse.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Escapes a JSON pointer path segment.
|
|
7
|
-
*
|
|
8
|
-
* @param segment - JSON pointer path segment.
|
|
9
|
-
* @returns Escaped JSON pointer path segment.
|
|
10
|
-
*/
|
|
11
|
-
declare function escapePointerSegment(segment: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Unescapes a JSON pointer path segment.
|
|
14
|
-
*
|
|
15
|
-
* @param segment - JSON pointer path segment.
|
|
16
|
-
* @returns Unescaped JSON pointer path segment.
|
|
17
|
-
*/
|
|
18
|
-
declare function unescapePointerSegment(segment: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
21
|
-
* also un-escaping reserved characters.
|
|
22
|
-
*/
|
|
23
|
-
declare function parseJsonPointer(pointer: string): JsonPointerPath;
|
|
24
|
-
/**
|
|
25
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
26
|
-
* like "/foo/bar".
|
|
27
|
-
*/
|
|
28
|
-
declare function formatJsonPointer(path: JsonPointerPath): string;
|
|
29
|
-
/**
|
|
30
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
31
|
-
*/
|
|
32
|
-
declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
35
|
-
*/
|
|
36
|
-
declare function parent(path: JsonPointerPath): JsonPointerPath;
|
|
37
|
-
/**
|
|
38
|
-
* Check if path component can be a valid array index.
|
|
39
|
-
*/
|
|
40
|
-
declare function isValidIndex(index: string | number): boolean;
|
|
41
|
-
declare const isInteger: (str: string) => boolean;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
|
44
|
-
//# sourceMappingURL=parse.d.mts.map
|
|
1
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-ZRTh45ZI.mjs";
|
|
2
|
+
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
package/dist/pointer/parse.mjs
CHANGED
|
@@ -1,81 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isNumber } from "../type-checks/src/is-number.mjs";
|
|
1
|
+
import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-Crgv3Nl1.mjs";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
const TILDE_ONE = /~1/g;
|
|
6
|
-
const TILDE_ZERO = /~0/g;
|
|
7
|
-
const TILDE = /~/g;
|
|
8
|
-
const FORWARD_SLASH = /\//g;
|
|
9
|
-
/**
|
|
10
|
-
* Escapes a JSON pointer path segment.
|
|
11
|
-
*
|
|
12
|
-
* @param segment - JSON pointer path segment.
|
|
13
|
-
* @returns Escaped JSON pointer path segment.
|
|
14
|
-
*/
|
|
15
|
-
function escapePointerSegment(segment) {
|
|
16
|
-
if (!segment.includes("/") && !segment.includes("~")) return segment;
|
|
17
|
-
return segment.replace(TILDE, "~0").replace(FORWARD_SLASH, "~1");
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Unescapes a JSON pointer path segment.
|
|
21
|
-
*
|
|
22
|
-
* @param segment - JSON pointer path segment.
|
|
23
|
-
* @returns Unescaped JSON pointer path segment.
|
|
24
|
-
*/
|
|
25
|
-
function unescapePointerSegment(segment) {
|
|
26
|
-
if (!segment.includes("~")) return segment;
|
|
27
|
-
return segment.replace(TILDE_ONE, "/").replace(TILDE_ZERO, "~");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
31
|
-
* also un-escaping reserved characters.
|
|
32
|
-
*/
|
|
33
|
-
function parseJsonPointer(pointer) {
|
|
34
|
-
if (!pointer) return [];
|
|
35
|
-
return pointer.slice(1).split("/").map((segment) => unescapePointerSegment(segment));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
39
|
-
* like "/foo/bar".
|
|
40
|
-
*/
|
|
41
|
-
function formatJsonPointer(path) {
|
|
42
|
-
if (isRoot(path)) return "";
|
|
43
|
-
return `/${path.map((segment) => escapePointerSegment(String(segment))).join("/")}`;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
47
|
-
*/
|
|
48
|
-
const isRoot = (path) => isString(path) ? path === "" : isNumber(path) ? path === 0 : Array.isArray(path) && path.length === 0;
|
|
49
|
-
/**
|
|
50
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
51
|
-
*/
|
|
52
|
-
function parent(path) {
|
|
53
|
-
if (path.length === 0) throw new Error("NO_PARENT");
|
|
54
|
-
return path.slice(0, -1);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if path component can be a valid array index.
|
|
58
|
-
*/
|
|
59
|
-
function isValidIndex(index) {
|
|
60
|
-
if (isNumber(index)) return true;
|
|
61
|
-
const n = Number.parseInt(index, 10);
|
|
62
|
-
return String(n) === index && n >= 0;
|
|
63
|
-
}
|
|
64
|
-
const isInteger = (str) => {
|
|
65
|
-
const len = str.length;
|
|
66
|
-
let i = 0;
|
|
67
|
-
let charCode;
|
|
68
|
-
while (i < len) {
|
|
69
|
-
charCode = str.codePointAt(i);
|
|
70
|
-
if (charCode >= 48 && charCode <= 57) {
|
|
71
|
-
i++;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
|
81
|
-
//# sourceMappingURL=parse.mjs.map
|
|
3
|
+
export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { F as JsonSchema7StringType, L as JsonSchema7Type, f as JsonSchema7AllOfType } from "./types-BUeTTE_U.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/schema.d.ts
|
|
4
|
+
declare const isJsonSchema7AllOfType: (type: JsonSchema7Type | JsonSchema7StringType) => type is JsonSchema7AllOfType;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isJsonSchema7AllOfType as t };
|
|
7
|
+
//# sourceMappingURL=schema-B1RVJHzJ.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-B1RVJHzJ.d.cts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;cAwBa,+BACL,kBAAkB,kCACf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/schema.ts
|
|
2
|
+
const isJsonSchema7AllOfType = (type) => {
|
|
3
|
+
if ("type" in type && type.type === "string") return false;
|
|
4
|
+
return "allOf" in type;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isJsonSchema7AllOfType as t };
|
|
9
|
+
//# sourceMappingURL=schema-CfhPLy30.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-CfhPLy30.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n JsonSchema7AllOfType,\n JsonSchema7StringType,\n JsonSchema7Type\n} from \"./types\";\n\nexport const isJsonSchema7AllOfType = (\n type: JsonSchema7Type | JsonSchema7StringType\n): type is JsonSchema7AllOfType => {\n if (\"type\" in type && type.type === \"string\") return false;\n return \"allOf\" in type;\n};\n"],"mappings":";AAwBA,MAAa,0BACX,SACiC;AACjC,KAAI,UAAU,QAAQ,KAAK,SAAS,SAAU,QAAO;AACrD,QAAO,WAAW"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/schema.ts
|
|
3
|
+
const isJsonSchema7AllOfType = (type) => {
|
|
4
|
+
if ("type" in type && type.type === "string") return false;
|
|
5
|
+
return "allOf" in type;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
Object.defineProperty(exports, 'isJsonSchema7AllOfType', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return isJsonSchema7AllOfType;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { F as JsonSchema7StringType, L as JsonSchema7Type, f as JsonSchema7AllOfType } from "./types-C_KlcCNw.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/schema.d.ts
|
|
4
|
+
declare const isJsonSchema7AllOfType: (type: JsonSchema7Type | JsonSchema7StringType) => type is JsonSchema7AllOfType;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isJsonSchema7AllOfType as t };
|
|
7
|
+
//# sourceMappingURL=schema-ai_NU-JC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-ai_NU-JC.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;cAwBa,+BACL,kBAAkB,kCACf"}
|
package/dist/schema.cjs
ADDED
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
const require_is_object = require('./is-object-umGh91v1.cjs');
|
|
29
|
+
const require_is_string = require('./is-string-C2RK4Gjs.cjs');
|
|
30
|
+
const require_parse = require('./parse-wxSDzBPf.cjs');
|
|
31
|
+
const require_parse_error = require('./parse-error-Dzwg4sdE.cjs');
|
|
32
|
+
const require_stringify = require('./stringify-DEw3S4_Z.cjs');
|
|
33
|
+
let jsonc_parser = require("jsonc-parser");
|
|
34
|
+
let node_buffer = require("node:buffer");
|
|
35
|
+
let superjson = require("superjson");
|
|
36
|
+
superjson = __toESM(superjson);
|
|
37
|
+
|
|
38
|
+
//#region src/storm-json.ts
|
|
39
|
+
/**
|
|
40
|
+
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
44
|
+
*/
|
|
45
|
+
var StormJSON = class StormJSON extends superjson.default {
|
|
46
|
+
static #instance;
|
|
47
|
+
static get instance() {
|
|
48
|
+
if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
|
|
49
|
+
return StormJSON.#instance;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Deserialize the given value with superjson using the given metadata
|
|
53
|
+
*/
|
|
54
|
+
static deserialize(payload) {
|
|
55
|
+
return StormJSON.instance.deserialize(payload);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Serialize the given value with superjson
|
|
59
|
+
*/
|
|
60
|
+
static serialize(object) {
|
|
61
|
+
return StormJSON.instance.serialize(object);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse the given string value with superjson using the given metadata
|
|
65
|
+
*
|
|
66
|
+
* @param value - The string value to parse
|
|
67
|
+
* @returns The parsed data
|
|
68
|
+
*/
|
|
69
|
+
static parse(value) {
|
|
70
|
+
return require_parse.parse(value);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Serializes the given data to a JSON string.
|
|
74
|
+
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
75
|
+
*
|
|
76
|
+
* @param value - Object which should be serialized to JSON
|
|
77
|
+
* @param options - JSON serialize options
|
|
78
|
+
* @returns the formatted JSON representation of the object
|
|
79
|
+
*/
|
|
80
|
+
static stringify(value, options) {
|
|
81
|
+
const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
|
|
82
|
+
let result = value;
|
|
83
|
+
if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
|
|
84
|
+
return require_stringify.stringify(result, options?.spaces ?? 2);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parses the given JSON string and returns the object the JSON content represents.
|
|
88
|
+
* By default javascript-style comments and trailing commas are allowed.
|
|
89
|
+
*
|
|
90
|
+
* @param strData - JSON content as string
|
|
91
|
+
* @param options - JSON parse options
|
|
92
|
+
* @returns Object the JSON content represents
|
|
93
|
+
*/
|
|
94
|
+
static parseJson(strData, options) {
|
|
95
|
+
try {
|
|
96
|
+
if (options?.expectComments === false) return StormJSON.instance.parse(strData);
|
|
97
|
+
} catch {}
|
|
98
|
+
const errors = [];
|
|
99
|
+
const result = (0, jsonc_parser.parse)(strData, errors, {
|
|
100
|
+
allowTrailingComma: true,
|
|
101
|
+
...options
|
|
102
|
+
});
|
|
103
|
+
if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(strData, errors[0]));
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Register a custom schema with superjson
|
|
108
|
+
*
|
|
109
|
+
* @param name - The name of the schema
|
|
110
|
+
* @param serialize - The function to serialize the schema
|
|
111
|
+
* @param deserialize - The function to deserialize the schema
|
|
112
|
+
* @param isApplicable - The function to check if the schema is applicable
|
|
113
|
+
*/
|
|
114
|
+
static register(name, serialize, deserialize, isApplicable) {
|
|
115
|
+
StormJSON.instance.registerCustom({
|
|
116
|
+
isApplicable,
|
|
117
|
+
serialize,
|
|
118
|
+
deserialize
|
|
119
|
+
}, name);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Register a class with superjson
|
|
123
|
+
*
|
|
124
|
+
* @param classConstructor - The class constructor to register
|
|
125
|
+
*/
|
|
126
|
+
static registerClass(classConstructor, options) {
|
|
127
|
+
StormJSON.instance.registerClass(classConstructor, {
|
|
128
|
+
identifier: require_is_string.isString(options) ? options : options?.identifier || classConstructor.name,
|
|
129
|
+
allowProps: options && require_is_object.isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
constructor() {
|
|
133
|
+
super({ dedupe: true });
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
StormJSON.instance.registerCustom({
|
|
137
|
+
isApplicable: (v) => typeof node_buffer.Buffer.isBuffer === "function" && node_buffer.Buffer.isBuffer(v),
|
|
138
|
+
serialize: (v) => v.toString("base64"),
|
|
139
|
+
deserialize: (v) => node_buffer.Buffer.from(v, "base64")
|
|
140
|
+
}, "Bytes");
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
Object.defineProperty(exports, 'StormJSON', {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return StormJSON;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, '__toESM', {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return __toESM;
|
|
153
|
+
}
|
|
154
|
+
});
|