@powerlines/deepkit 0.5.3 → 0.5.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.
Files changed (45) hide show
  1. package/dist/capnp.cjs +47 -49
  2. package/dist/capnp.js +2 -4
  3. package/dist/chunk-23YNDVRG.js +34 -0
  4. package/dist/chunk-5MYRXRS2.cjs +2191 -0
  5. package/dist/{chunk-MSO7PT57.cjs → chunk-7FXYDYVQ.cjs} +128 -128
  6. package/dist/{chunk-B47NLUDW.cjs → chunk-7QZGCBH7.cjs} +2 -2
  7. package/dist/{chunk-47WBQTA6.js → chunk-ALM6UMVU.js} +1 -1
  8. package/dist/chunk-BLLXF42T.cjs +41 -0
  9. package/dist/{chunk-3PKIT7K2.cjs → chunk-CJMS4ES3.cjs} +4 -4
  10. package/dist/{chunk-JSH5MVQG.js → chunk-EJIBYA23.js} +2 -2
  11. package/dist/{chunk-GVS5O43Z.js → chunk-JE36RI7U.js} +2 -2
  12. package/dist/chunk-KGCRCOJQ.cjs +22 -0
  13. package/dist/chunk-SHUYVCID.js +4 -0
  14. package/dist/{chunk-XI47ZADG.js → chunk-TDYIUJGY.js} +9 -9
  15. package/dist/chunk-USNT2KNT.cjs +6 -0
  16. package/dist/chunk-WL27D7L7.js +2183 -0
  17. package/dist/chunk-XHSSGKUT.js +16 -0
  18. package/dist/{chunk-KDKCOXXC.cjs → chunk-YAEE7DDW.cjs} +5 -5
  19. package/dist/esbuild-plugin.cjs +5 -6
  20. package/dist/esbuild-plugin.js +4 -5
  21. package/dist/index.cjs +66 -68
  22. package/dist/index.js +8 -10
  23. package/dist/reflect-type.cjs +6 -8
  24. package/dist/reflect-type.js +5 -7
  25. package/dist/resolve-reflections.cjs +3 -3
  26. package/dist/resolve-reflections.js +2 -2
  27. package/dist/transformer.cjs +4 -5
  28. package/dist/transformer.js +2 -3
  29. package/dist/transpile.cjs +4 -5
  30. package/dist/transpile.js +3 -4
  31. package/dist/utilities.cjs +9 -11
  32. package/dist/utilities.js +2 -4
  33. package/package.json +4 -4
  34. package/dist/chunk-35PNVYKI.js +0 -187
  35. package/dist/chunk-3GQAWCBQ.js +0 -10
  36. package/dist/chunk-3GRTJOID.cjs +0 -193
  37. package/dist/chunk-4UQ4UDET.cjs +0 -19685
  38. package/dist/chunk-5NPGWGPO.cjs +0 -109
  39. package/dist/chunk-BGYQAVKQ.cjs +0 -13
  40. package/dist/chunk-F5QUFY7D.cjs +0 -135
  41. package/dist/chunk-KWUXT6EF.js +0 -127
  42. package/dist/chunk-O2LKJ62Q.cjs +0 -2863
  43. package/dist/chunk-U7WEV6HK.js +0 -19678
  44. package/dist/chunk-W423FBJ2.js +0 -2854
  45. package/dist/chunk-XU55W26B.js +0 -109
@@ -1,109 +0,0 @@
1
- 'use strict';
2
-
3
- // ../../node_modules/.pnpm/@deepkit+type-spec@1.0.1_patch_hash=f3c3a4fd486751022d78f17d39a5a79f493bca20b185964ca1aba41fbfc93244/node_modules/@deepkit/type-spec/dist/esm/src/type.js
4
- exports.TypeNumberBrand = void 0;
5
- (function(TypeNumberBrand2) {
6
- TypeNumberBrand2[TypeNumberBrand2["integer"] = 0] = "integer";
7
- TypeNumberBrand2[TypeNumberBrand2["int8"] = 1] = "int8";
8
- TypeNumberBrand2[TypeNumberBrand2["int16"] = 2] = "int16";
9
- TypeNumberBrand2[TypeNumberBrand2["int32"] = 3] = "int32";
10
- TypeNumberBrand2[TypeNumberBrand2["uint8"] = 4] = "uint8";
11
- TypeNumberBrand2[TypeNumberBrand2["uint16"] = 5] = "uint16";
12
- TypeNumberBrand2[TypeNumberBrand2["uint32"] = 6] = "uint32";
13
- TypeNumberBrand2[TypeNumberBrand2["float"] = 7] = "float";
14
- TypeNumberBrand2[TypeNumberBrand2["float32"] = 8] = "float32";
15
- TypeNumberBrand2[TypeNumberBrand2["float64"] = 9] = "float64";
16
- })(exports.TypeNumberBrand || (exports.TypeNumberBrand = {}));
17
- exports.ReflectionOp = void 0;
18
- (function(ReflectionOp2) {
19
- ReflectionOp2[ReflectionOp2["never"] = 0] = "never";
20
- ReflectionOp2[ReflectionOp2["any"] = 1] = "any";
21
- ReflectionOp2[ReflectionOp2["unknown"] = 2] = "unknown";
22
- ReflectionOp2[ReflectionOp2["void"] = 3] = "void";
23
- ReflectionOp2[ReflectionOp2["object"] = 4] = "object";
24
- ReflectionOp2[ReflectionOp2["string"] = 5] = "string";
25
- ReflectionOp2[ReflectionOp2["number"] = 6] = "number";
26
- ReflectionOp2[ReflectionOp2["numberBrand"] = 7] = "numberBrand";
27
- ReflectionOp2[ReflectionOp2["boolean"] = 8] = "boolean";
28
- ReflectionOp2[ReflectionOp2["bigint"] = 9] = "bigint";
29
- ReflectionOp2[ReflectionOp2["symbol"] = 10] = "symbol";
30
- ReflectionOp2[ReflectionOp2["null"] = 11] = "null";
31
- ReflectionOp2[ReflectionOp2["undefined"] = 12] = "undefined";
32
- ReflectionOp2[ReflectionOp2["literal"] = 13] = "literal";
33
- ReflectionOp2[ReflectionOp2["function"] = 14] = "function";
34
- ReflectionOp2[ReflectionOp2["method"] = 15] = "method";
35
- ReflectionOp2[ReflectionOp2["methodSignature"] = 16] = "methodSignature";
36
- ReflectionOp2[ReflectionOp2["parameter"] = 17] = "parameter";
37
- ReflectionOp2[ReflectionOp2["property"] = 18] = "property";
38
- ReflectionOp2[ReflectionOp2["propertySignature"] = 19] = "propertySignature";
39
- ReflectionOp2[ReflectionOp2["class"] = 20] = "class";
40
- ReflectionOp2[ReflectionOp2["classExtends"] = 21] = "classExtends";
41
- ReflectionOp2[ReflectionOp2["classReference"] = 22] = "classReference";
42
- ReflectionOp2[ReflectionOp2["optional"] = 23] = "optional";
43
- ReflectionOp2[ReflectionOp2["readonly"] = 24] = "readonly";
44
- ReflectionOp2[ReflectionOp2["public"] = 25] = "public";
45
- ReflectionOp2[ReflectionOp2["private"] = 26] = "private";
46
- ReflectionOp2[ReflectionOp2["protected"] = 27] = "protected";
47
- ReflectionOp2[ReflectionOp2["abstract"] = 28] = "abstract";
48
- ReflectionOp2[ReflectionOp2["defaultValue"] = 29] = "defaultValue";
49
- ReflectionOp2[ReflectionOp2["description"] = 30] = "description";
50
- ReflectionOp2[ReflectionOp2["rest"] = 31] = "rest";
51
- ReflectionOp2[ReflectionOp2["regexp"] = 32] = "regexp";
52
- ReflectionOp2[ReflectionOp2["enum"] = 33] = "enum";
53
- ReflectionOp2[ReflectionOp2["enumMember"] = 34] = "enumMember";
54
- ReflectionOp2[ReflectionOp2["set"] = 35] = "set";
55
- ReflectionOp2[ReflectionOp2["map"] = 36] = "map";
56
- ReflectionOp2[ReflectionOp2["array"] = 37] = "array";
57
- ReflectionOp2[ReflectionOp2["tuple"] = 38] = "tuple";
58
- ReflectionOp2[ReflectionOp2["tupleMember"] = 39] = "tupleMember";
59
- ReflectionOp2[ReflectionOp2["namedTupleMember"] = 40] = "namedTupleMember";
60
- ReflectionOp2[ReflectionOp2["union"] = 41] = "union";
61
- ReflectionOp2[ReflectionOp2["intersection"] = 42] = "intersection";
62
- ReflectionOp2[ReflectionOp2["indexSignature"] = 43] = "indexSignature";
63
- ReflectionOp2[ReflectionOp2["objectLiteral"] = 44] = "objectLiteral";
64
- ReflectionOp2[ReflectionOp2["mappedType"] = 45] = "mappedType";
65
- ReflectionOp2[ReflectionOp2["in"] = 46] = "in";
66
- ReflectionOp2[ReflectionOp2["frame"] = 47] = "frame";
67
- ReflectionOp2[ReflectionOp2["moveFrame"] = 48] = "moveFrame";
68
- ReflectionOp2[ReflectionOp2["return"] = 49] = "return";
69
- ReflectionOp2[ReflectionOp2["templateLiteral"] = 50] = "templateLiteral";
70
- ReflectionOp2[ReflectionOp2["date"] = 51] = "date";
71
- ReflectionOp2[ReflectionOp2["int8Array"] = 52] = "int8Array";
72
- ReflectionOp2[ReflectionOp2["uint8ClampedArray"] = 53] = "uint8ClampedArray";
73
- ReflectionOp2[ReflectionOp2["uint8Array"] = 54] = "uint8Array";
74
- ReflectionOp2[ReflectionOp2["int16Array"] = 55] = "int16Array";
75
- ReflectionOp2[ReflectionOp2["uint16Array"] = 56] = "uint16Array";
76
- ReflectionOp2[ReflectionOp2["int32Array"] = 57] = "int32Array";
77
- ReflectionOp2[ReflectionOp2["uint32Array"] = 58] = "uint32Array";
78
- ReflectionOp2[ReflectionOp2["float32Array"] = 59] = "float32Array";
79
- ReflectionOp2[ReflectionOp2["float64Array"] = 60] = "float64Array";
80
- ReflectionOp2[ReflectionOp2["bigInt64Array"] = 61] = "bigInt64Array";
81
- ReflectionOp2[ReflectionOp2["arrayBuffer"] = 62] = "arrayBuffer";
82
- ReflectionOp2[ReflectionOp2["promise"] = 63] = "promise";
83
- ReflectionOp2[ReflectionOp2["arg"] = 64] = "arg";
84
- ReflectionOp2[ReflectionOp2["typeParameter"] = 65] = "typeParameter";
85
- ReflectionOp2[ReflectionOp2["typeParameterDefault"] = 66] = "typeParameterDefault";
86
- ReflectionOp2[ReflectionOp2["var"] = 67] = "var";
87
- ReflectionOp2[ReflectionOp2["loads"] = 68] = "loads";
88
- ReflectionOp2[ReflectionOp2["indexAccess"] = 69] = "indexAccess";
89
- ReflectionOp2[ReflectionOp2["keyof"] = 70] = "keyof";
90
- ReflectionOp2[ReflectionOp2["infer"] = 71] = "infer";
91
- ReflectionOp2[ReflectionOp2["typeof"] = 72] = "typeof";
92
- ReflectionOp2[ReflectionOp2["condition"] = 73] = "condition";
93
- ReflectionOp2[ReflectionOp2["jumpCondition"] = 74] = "jumpCondition";
94
- ReflectionOp2[ReflectionOp2["jump"] = 75] = "jump";
95
- ReflectionOp2[ReflectionOp2["call"] = 76] = "call";
96
- ReflectionOp2[ReflectionOp2["inline"] = 77] = "inline";
97
- ReflectionOp2[ReflectionOp2["inlineCall"] = 78] = "inlineCall";
98
- ReflectionOp2[ReflectionOp2["distribute"] = 79] = "distribute";
99
- ReflectionOp2[ReflectionOp2["extends"] = 80] = "extends";
100
- ReflectionOp2[ReflectionOp2["widen"] = 81] = "widen";
101
- ReflectionOp2[ReflectionOp2["static"] = 82] = "static";
102
- ReflectionOp2[ReflectionOp2["mappedType2"] = 83] = "mappedType2";
103
- ReflectionOp2[ReflectionOp2["functionReference"] = 84] = "functionReference";
104
- ReflectionOp2[ReflectionOp2["callSignature"] = 85] = "callSignature";
105
- ReflectionOp2[ReflectionOp2["typeName"] = 86] = "typeName";
106
- ReflectionOp2[ReflectionOp2["implements"] = 87] = "implements";
107
- ReflectionOp2[ReflectionOp2["nominal"] = 88] = "nominal";
108
- ReflectionOp2[ReflectionOp2["tags"] = 89] = "tags";
109
- })(exports.ReflectionOp || (exports.ReflectionOp = {}));
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
- }) : x)(function(x) {
8
- if (typeof require !== "undefined") return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
-
12
- exports.__name = __name;
13
- exports.__require = __require;
@@ -1,135 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk4UQ4UDET_cjs = require('./chunk-4UQ4UDET.cjs');
4
- var chunkBGYQAVKQ_cjs = require('./chunk-BGYQAVKQ.cjs');
5
- var getUnique = require('@stryke/helpers/get-unique');
6
- var stormJson = require('@stryke/json/storm-json');
7
- var isNull = require('@stryke/type-checks/is-null');
8
- var isString = require('@stryke/type-checks/is-string');
9
- var isUndefined = require('@stryke/type-checks/is-undefined');
10
-
11
- function stringifyDefaultValue(property, value) {
12
- return stringifyValue(property.type, value ?? property.getDefaultValue());
13
- }
14
- chunkBGYQAVKQ_cjs.__name(stringifyDefaultValue, "stringifyDefaultValue");
15
- function stringifyStringValue(value) {
16
- return `"${String(value).replaceAll('"', '\\"')}"`;
17
- }
18
- chunkBGYQAVKQ_cjs.__name(stringifyStringValue, "stringifyStringValue");
19
- function stringifyValue(type, value) {
20
- return isUndefined.isUndefined(value) ? "undefined" : isNull.isNull(value) ? "null" : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.string || type.kind === chunk4UQ4UDET_cjs.ReflectionKind.literal && isString.isString(type.literal) ? stringifyStringValue(value) : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.enum ? getEnumReflectionType(type).kind === chunk4UQ4UDET_cjs.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.array ? stringifyStringValue(stormJson.StormJSON.stringify(value)) : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.object || type.kind === chunk4UQ4UDET_cjs.ReflectionKind.objectLiteral ? stormJson.StormJSON.stringify(value) : type.kind === chunk4UQ4UDET_cjs.ReflectionKind.property || type.kind === chunk4UQ4UDET_cjs.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
21
- }
22
- chunkBGYQAVKQ_cjs.__name(stringifyValue, "stringifyValue");
23
- function getEnumReflectionType(type) {
24
- if (type.kind !== chunk4UQ4UDET_cjs.ReflectionKind.enum) {
25
- throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
26
- }
27
- const unique = getUnique.getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString.isString(enumMember) ? {
28
- kind: chunk4UQ4UDET_cjs.ReflectionKind.string
29
- } : {
30
- kind: chunk4UQ4UDET_cjs.ReflectionKind.number
31
- });
32
- if (unique.length === 0) {
33
- throw new Error(`No valid enum members could be found.`);
34
- }
35
- return unique[0] && isString.isString(unique[0]) ? {
36
- kind: chunk4UQ4UDET_cjs.ReflectionKind.string
37
- } : {
38
- kind: chunk4UQ4UDET_cjs.ReflectionKind.number
39
- };
40
- }
41
- chunkBGYQAVKQ_cjs.__name(getEnumReflectionType, "getEnumReflectionType");
42
- function getUnionTypes(type) {
43
- if (type.kind === chunk4UQ4UDET_cjs.ReflectionKind.union && type.types.length > 0) {
44
- return getUnique.getUniqueBy(type.types, (member) => member.kind);
45
- }
46
- throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
47
- }
48
- chunkBGYQAVKQ_cjs.__name(getUnionTypes, "getUnionTypes");
49
- function isStringUnion(type) {
50
- return getUnionTypes(type).some((member) => member.kind === chunk4UQ4UDET_cjs.ReflectionKind.string || member.kind === chunk4UQ4UDET_cjs.ReflectionKind.literal && isString.isString(member.literal));
51
- }
52
- chunkBGYQAVKQ_cjs.__name(isStringUnion, "isStringUnion");
53
- function kindToName(kind) {
54
- if (kind === chunk4UQ4UDET_cjs.ReflectionKind.void) {
55
- return "void";
56
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.never) {
57
- return "never";
58
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.null) {
59
- return "null";
60
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.undefined) {
61
- return "undefined";
62
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.symbol) {
63
- return "symbol";
64
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.bigint) {
65
- return "bigint";
66
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.number) {
67
- return "number";
68
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.string) {
69
- return "string";
70
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.boolean) {
71
- return "boolean";
72
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.literal) {
73
- return "literal";
74
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.class) {
75
- return "class";
76
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.array) {
77
- return "array";
78
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.object) {
79
- return "object";
80
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.objectLiteral) {
81
- return "objectLiteral";
82
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.union) {
83
- return "union";
84
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.enum) {
85
- return "enum";
86
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.regexp) {
87
- return "regexp";
88
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.templateLiteral) {
89
- return "templateLiteral";
90
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.property) {
91
- return "property";
92
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.method) {
93
- return "method";
94
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.function) {
95
- return "function";
96
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.parameter) {
97
- return "parameter";
98
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.promise) {
99
- return "promise";
100
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.typeParameter) {
101
- return "typeParameter";
102
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.tuple) {
103
- return "tuple";
104
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.tupleMember) {
105
- return "tupleMember";
106
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.enumMember) {
107
- return "enumMember";
108
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.rest) {
109
- return "rest";
110
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.indexSignature) {
111
- return "indexSignature";
112
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.propertySignature) {
113
- return "propertySignature";
114
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.methodSignature) {
115
- return "methodSignature";
116
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.infer) {
117
- return "infer";
118
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.callSignature) {
119
- return "callSignature";
120
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.any) {
121
- return "any";
122
- } else if (kind === chunk4UQ4UDET_cjs.ReflectionKind.intersection) {
123
- return "intersection";
124
- }
125
- return "unknown";
126
- }
127
- chunkBGYQAVKQ_cjs.__name(kindToName, "kindToName");
128
-
129
- exports.getEnumReflectionType = getEnumReflectionType;
130
- exports.getUnionTypes = getUnionTypes;
131
- exports.isStringUnion = isStringUnion;
132
- exports.kindToName = kindToName;
133
- exports.stringifyDefaultValue = stringifyDefaultValue;
134
- exports.stringifyStringValue = stringifyStringValue;
135
- exports.stringifyValue = stringifyValue;
@@ -1,127 +0,0 @@
1
- import { ReflectionKind } from './chunk-U7WEV6HK.js';
2
- import { __name } from './chunk-3GQAWCBQ.js';
3
- import { getUniqueBy } from '@stryke/helpers/get-unique';
4
- import { StormJSON } from '@stryke/json/storm-json';
5
- import { isNull } from '@stryke/type-checks/is-null';
6
- import { isString } from '@stryke/type-checks/is-string';
7
- import { isUndefined } from '@stryke/type-checks/is-undefined';
8
-
9
- function stringifyDefaultValue(property, value) {
10
- return stringifyValue(property.type, value ?? property.getDefaultValue());
11
- }
12
- __name(stringifyDefaultValue, "stringifyDefaultValue");
13
- function stringifyStringValue(value) {
14
- return `"${String(value).replaceAll('"', '\\"')}"`;
15
- }
16
- __name(stringifyStringValue, "stringifyStringValue");
17
- function stringifyValue(type, value) {
18
- return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind === ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && isString(type.literal) ? stringifyStringValue(value) : type.kind === ReflectionKind.enum ? getEnumReflectionType(type).kind === ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === ReflectionKind.array ? stringifyStringValue(StormJSON.stringify(value)) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? StormJSON.stringify(value) : type.kind === ReflectionKind.property || type.kind === ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
19
- }
20
- __name(stringifyValue, "stringifyValue");
21
- function getEnumReflectionType(type) {
22
- if (type.kind !== ReflectionKind.enum) {
23
- throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
24
- }
25
- const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? {
26
- kind: ReflectionKind.string
27
- } : {
28
- kind: ReflectionKind.number
29
- });
30
- if (unique.length === 0) {
31
- throw new Error(`No valid enum members could be found.`);
32
- }
33
- return unique[0] && isString(unique[0]) ? {
34
- kind: ReflectionKind.string
35
- } : {
36
- kind: ReflectionKind.number
37
- };
38
- }
39
- __name(getEnumReflectionType, "getEnumReflectionType");
40
- function getUnionTypes(type) {
41
- if (type.kind === ReflectionKind.union && type.types.length > 0) {
42
- return getUniqueBy(type.types, (member) => member.kind);
43
- }
44
- throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
45
- }
46
- __name(getUnionTypes, "getUnionTypes");
47
- function isStringUnion(type) {
48
- return getUnionTypes(type).some((member) => member.kind === ReflectionKind.string || member.kind === ReflectionKind.literal && isString(member.literal));
49
- }
50
- __name(isStringUnion, "isStringUnion");
51
- function kindToName(kind) {
52
- if (kind === ReflectionKind.void) {
53
- return "void";
54
- } else if (kind === ReflectionKind.never) {
55
- return "never";
56
- } else if (kind === ReflectionKind.null) {
57
- return "null";
58
- } else if (kind === ReflectionKind.undefined) {
59
- return "undefined";
60
- } else if (kind === ReflectionKind.symbol) {
61
- return "symbol";
62
- } else if (kind === ReflectionKind.bigint) {
63
- return "bigint";
64
- } else if (kind === ReflectionKind.number) {
65
- return "number";
66
- } else if (kind === ReflectionKind.string) {
67
- return "string";
68
- } else if (kind === ReflectionKind.boolean) {
69
- return "boolean";
70
- } else if (kind === ReflectionKind.literal) {
71
- return "literal";
72
- } else if (kind === ReflectionKind.class) {
73
- return "class";
74
- } else if (kind === ReflectionKind.array) {
75
- return "array";
76
- } else if (kind === ReflectionKind.object) {
77
- return "object";
78
- } else if (kind === ReflectionKind.objectLiteral) {
79
- return "objectLiteral";
80
- } else if (kind === ReflectionKind.union) {
81
- return "union";
82
- } else if (kind === ReflectionKind.enum) {
83
- return "enum";
84
- } else if (kind === ReflectionKind.regexp) {
85
- return "regexp";
86
- } else if (kind === ReflectionKind.templateLiteral) {
87
- return "templateLiteral";
88
- } else if (kind === ReflectionKind.property) {
89
- return "property";
90
- } else if (kind === ReflectionKind.method) {
91
- return "method";
92
- } else if (kind === ReflectionKind.function) {
93
- return "function";
94
- } else if (kind === ReflectionKind.parameter) {
95
- return "parameter";
96
- } else if (kind === ReflectionKind.promise) {
97
- return "promise";
98
- } else if (kind === ReflectionKind.typeParameter) {
99
- return "typeParameter";
100
- } else if (kind === ReflectionKind.tuple) {
101
- return "tuple";
102
- } else if (kind === ReflectionKind.tupleMember) {
103
- return "tupleMember";
104
- } else if (kind === ReflectionKind.enumMember) {
105
- return "enumMember";
106
- } else if (kind === ReflectionKind.rest) {
107
- return "rest";
108
- } else if (kind === ReflectionKind.indexSignature) {
109
- return "indexSignature";
110
- } else if (kind === ReflectionKind.propertySignature) {
111
- return "propertySignature";
112
- } else if (kind === ReflectionKind.methodSignature) {
113
- return "methodSignature";
114
- } else if (kind === ReflectionKind.infer) {
115
- return "infer";
116
- } else if (kind === ReflectionKind.callSignature) {
117
- return "callSignature";
118
- } else if (kind === ReflectionKind.any) {
119
- return "any";
120
- } else if (kind === ReflectionKind.intersection) {
121
- return "intersection";
122
- }
123
- return "unknown";
124
- }
125
- __name(kindToName, "kindToName");
126
-
127
- export { getEnumReflectionType, getUnionTypes, isStringUnion, kindToName, stringifyDefaultValue, stringifyStringValue, stringifyValue };