@powerlines/plugin-alloy 0.15.5 → 0.15.6
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/_virtual/rolldown_runtime.cjs +0 -8
- package/dist/core/components/output.d.cts +2 -2
- package/dist/core/components/output.d.mts +2 -2
- package/dist/core/components/single-line-comment.d.cts +2 -2
- package/dist/core/components/source-file.d.cts +2 -2
- package/dist/core/components/source-file.d.mts +2 -2
- package/dist/core/contexts/reflection.d.cts +7 -8
- package/dist/core/contexts/reflection.d.mts +7 -8
- package/dist/deepkit/src/utilities.cjs +41 -42
- package/dist/deepkit/src/utilities.mjs +41 -42
- package/dist/helpers/capnp.cjs +18 -20
- package/dist/helpers/capnp.d.cts +13 -14
- package/dist/helpers/capnp.d.mts +13 -14
- package/dist/helpers/capnp.mjs +18 -20
- package/dist/helpers/typescript.d.cts +1 -3
- package/dist/helpers/typescript.d.mts +1 -3
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-file.d.mts +3 -3
- package/dist/markdown/components/markdown-table.d.cts +4 -4
- package/dist/markdown/components/markdown-table.d.mts +4 -4
- package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
- package/dist/typescript/components/entry-file.d.mts +2 -2
- package/dist/typescript/components/tsdoc-reflection.d.cts +4 -4
- package/dist/typescript/components/typescript-interface.cjs +1 -2
- package/dist/typescript/components/typescript-interface.d.cts +5 -6
- package/dist/typescript/components/typescript-interface.d.mts +2 -3
- package/dist/typescript/components/typescript-interface.mjs +1 -2
- package/dist/typescript/components/typescript-object.d.cts +5 -6
- package/dist/typescript/components/typescript-object.d.mts +5 -6
- package/package.json +5 -5
- package/dist/_virtual/rolldown_runtime.mjs +0 -29
- package/dist/deepkit/src/vendor/core.cjs +0 -20
- package/dist/deepkit/src/vendor/core.mjs +0 -11
- package/dist/deepkit/src/vendor/type.cjs +0 -20
- package/dist/deepkit/src/vendor/type.d.cts +0 -7
- package/dist/deepkit/src/vendor/type.d.mts +0 -7
- package/dist/deepkit/src/vendor/type.mjs +0 -11
|
@@ -19,13 +19,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
}
|
|
20
20
|
return to;
|
|
21
21
|
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
23
|
-
if (symbols) {
|
|
24
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
26
|
-
}
|
|
27
|
-
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
28
|
-
};
|
|
29
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
23
|
value: mod,
|
|
31
24
|
enumerable: true
|
|
@@ -33,5 +26,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
26
|
|
|
34
27
|
//#endregion
|
|
35
28
|
|
|
36
|
-
exports.__reExport = __reExport;
|
|
37
29
|
exports.__toESM = __toESM;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core3 from "@alloy-js/core";
|
|
3
3
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/core/components/output.d.ts
|
|
@@ -12,7 +12,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext> extends Ou
|
|
|
12
12
|
/**
|
|
13
13
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
14
14
|
*/
|
|
15
|
-
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>):
|
|
15
|
+
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core3.Children;
|
|
16
16
|
declare type __ΩOutputProps = any[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core4 from "@alloy-js/core";
|
|
3
3
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/core/components/output.d.ts
|
|
@@ -12,7 +12,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext> extends Ou
|
|
|
12
12
|
/**
|
|
13
13
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
14
14
|
*/
|
|
15
|
-
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>):
|
|
15
|
+
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core4.Children;
|
|
16
16
|
declare type __ΩOutputProps = any[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/components/single-line-comment.d.ts
|
|
5
5
|
type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
|
|
@@ -15,7 +15,7 @@ interface SingleLineCommentProps extends ComponentProps {
|
|
|
15
15
|
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
16
16
|
* are broken into multiple lines
|
|
17
17
|
*/
|
|
18
|
-
declare function SingleLineComment(props: SingleLineCommentProps):
|
|
18
|
+
declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core1.Children;
|
|
19
19
|
declare type __ΩSingleLineCommentVariant = any[];
|
|
20
20
|
declare type __ΩSingleLineCommentProps = any[];
|
|
21
21
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePreset } from "../../powerlines/src/types/fs.cjs";
|
|
2
2
|
import { ComponentProps } from "../../types/components.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
4
4
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
@@ -25,7 +25,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
25
25
|
* @param props - The properties for the source file.
|
|
26
26
|
* @returns The rendered source file component.
|
|
27
27
|
*/
|
|
28
|
-
declare function SourceFile(props: SourceFileProps):
|
|
28
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core2.Children;
|
|
29
29
|
declare type __ΩSourceFileProps = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePreset } from "../../powerlines/src/types/fs.mjs";
|
|
2
2
|
import { ComponentProps } from "../../types/components.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core3 from "@alloy-js/core";
|
|
4
4
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
@@ -25,7 +25,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
25
25
|
* @param props - The properties for the source file.
|
|
26
26
|
* @returns The rendered source file component.
|
|
27
27
|
*/
|
|
28
|
-
declare function SourceFile(props: SourceFileProps):
|
|
28
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core3.Children;
|
|
29
29
|
declare type __ΩSourceFileProps = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ReflectionOverrideInterface } from "../../types/components.cjs";
|
|
2
|
-
import { type_d_exports } from "../../deepkit/src/vendor/type.cjs";
|
|
3
2
|
import { ComponentContext } from "@alloy-js/core";
|
|
4
3
|
|
|
5
4
|
//#region src/core/contexts/reflection.d.ts
|
|
6
5
|
interface ReflectionClassContextInterface<T extends Record<string, any> = Record<string, any>> {
|
|
7
|
-
reflection:
|
|
6
|
+
reflection: ReflectionClass<T>;
|
|
8
7
|
override?: ReflectionOverrideInterface<T>;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
@@ -20,33 +19,33 @@ declare function useReflectionClass<T extends Record<string, any> = Record<strin
|
|
|
20
19
|
/**
|
|
21
20
|
* The reflection property context used in template rendering.
|
|
22
21
|
*/
|
|
23
|
-
declare const ReflectionPropertyContext: ComponentContext<
|
|
22
|
+
declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
|
|
24
23
|
/**
|
|
25
24
|
* Hook to access the Reflection Property context.
|
|
26
25
|
*
|
|
27
26
|
* @returns A reactive version of the current reflection.
|
|
28
27
|
*/
|
|
29
|
-
declare function useReflectionProperty():
|
|
28
|
+
declare function useReflectionProperty(): ReflectionProperty;
|
|
30
29
|
/**
|
|
31
30
|
* The reflection method context used in template rendering.
|
|
32
31
|
*/
|
|
33
|
-
declare const ReflectionMethodContext: ComponentContext<
|
|
32
|
+
declare const ReflectionMethodContext: ComponentContext<ReflectionMethod>;
|
|
34
33
|
/**
|
|
35
34
|
* Hook to access the Reflection Method context.
|
|
36
35
|
*
|
|
37
36
|
* @returns A reactive version of the current reflection.
|
|
38
37
|
*/
|
|
39
|
-
declare function useReflectionMethod():
|
|
38
|
+
declare function useReflectionMethod(): ReflectionMethod;
|
|
40
39
|
/**
|
|
41
40
|
* The reflection parameter context used in template rendering.
|
|
42
41
|
*/
|
|
43
|
-
declare const ReflectionParameterContext: ComponentContext<
|
|
42
|
+
declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
|
|
44
43
|
/**
|
|
45
44
|
* Hook to access the Reflection Parameter context.
|
|
46
45
|
*
|
|
47
46
|
* @returns A reactive version of the current reflection.
|
|
48
47
|
*/
|
|
49
|
-
declare function useReflectionParameter():
|
|
48
|
+
declare function useReflectionParameter(): ReflectionParameter;
|
|
50
49
|
declare type __ΩReflectionClassContextInterface = any[];
|
|
51
50
|
//#endregion
|
|
52
51
|
export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ReflectionOverrideInterface } from "../../types/components.mjs";
|
|
2
|
-
import { type_d_exports } from "../../deepkit/src/vendor/type.mjs";
|
|
3
2
|
import { ComponentContext } from "@alloy-js/core";
|
|
4
3
|
|
|
5
4
|
//#region src/core/contexts/reflection.d.ts
|
|
6
5
|
interface ReflectionClassContextInterface<T extends Record<string, any> = Record<string, any>> {
|
|
7
|
-
reflection:
|
|
6
|
+
reflection: ReflectionClass<T>;
|
|
8
7
|
override?: ReflectionOverrideInterface<T>;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
@@ -20,33 +19,33 @@ declare function useReflectionClass<T extends Record<string, any> = Record<strin
|
|
|
20
19
|
/**
|
|
21
20
|
* The reflection property context used in template rendering.
|
|
22
21
|
*/
|
|
23
|
-
declare const ReflectionPropertyContext: ComponentContext<
|
|
22
|
+
declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
|
|
24
23
|
/**
|
|
25
24
|
* Hook to access the Reflection Property context.
|
|
26
25
|
*
|
|
27
26
|
* @returns A reactive version of the current reflection.
|
|
28
27
|
*/
|
|
29
|
-
declare function useReflectionProperty():
|
|
28
|
+
declare function useReflectionProperty(): ReflectionProperty;
|
|
30
29
|
/**
|
|
31
30
|
* The reflection method context used in template rendering.
|
|
32
31
|
*/
|
|
33
|
-
declare const ReflectionMethodContext: ComponentContext<
|
|
32
|
+
declare const ReflectionMethodContext: ComponentContext<ReflectionMethod>;
|
|
34
33
|
/**
|
|
35
34
|
* Hook to access the Reflection Method context.
|
|
36
35
|
*
|
|
37
36
|
* @returns A reactive version of the current reflection.
|
|
38
37
|
*/
|
|
39
|
-
declare function useReflectionMethod():
|
|
38
|
+
declare function useReflectionMethod(): ReflectionMethod;
|
|
40
39
|
/**
|
|
41
40
|
* The reflection parameter context used in template rendering.
|
|
42
41
|
*/
|
|
43
|
-
declare const ReflectionParameterContext: ComponentContext<
|
|
42
|
+
declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
|
|
44
43
|
/**
|
|
45
44
|
* Hook to access the Reflection Parameter context.
|
|
46
45
|
*
|
|
47
46
|
* @returns A reactive version of the current reflection.
|
|
48
47
|
*/
|
|
49
|
-
declare function useReflectionParameter():
|
|
48
|
+
declare function useReflectionParameter(): ReflectionParameter;
|
|
50
49
|
declare type __ΩReflectionClassContextInterface = any[];
|
|
51
50
|
//#endregion
|
|
52
51
|
export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_type = require('./vendor/type.cjs');
|
|
3
2
|
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
4
3
|
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
5
4
|
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
@@ -34,7 +33,7 @@ function stringifyStringValue(value) {
|
|
|
34
33
|
* @returns A string representation of the value.
|
|
35
34
|
*/
|
|
36
35
|
function stringifyValue(type, value) {
|
|
37
|
-
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind ===
|
|
36
|
+
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind === ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && (0, __stryke_type_checks_is_string.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(__stryke_json_storm_json.StormJSON.stringify(value)) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? __stryke_json_storm_json.StormJSON.stringify(value) : type.kind === ReflectionKind.property || type.kind === ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
39
|
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
@@ -43,10 +42,10 @@ function stringifyValue(type, value) {
|
|
|
43
42
|
* @returns A string representation of the primitive type.
|
|
44
43
|
*/
|
|
45
44
|
function getEnumReflectionType(type) {
|
|
46
|
-
if (type.kind !==
|
|
47
|
-
const unique = (0, __stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => (0, __stryke_type_checks_is_string.isString)(enumMember) ? { kind:
|
|
45
|
+
if (type.kind !== ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
46
|
+
const unique = (0, __stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => (0, __stryke_type_checks_is_string.isString)(enumMember) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number });
|
|
48
47
|
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
49
|
-
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind:
|
|
48
|
+
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number };
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
51
|
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
@@ -55,11 +54,11 @@ function getEnumReflectionType(type) {
|
|
|
55
54
|
* @returns A string representation of the primitive type.
|
|
56
55
|
*/
|
|
57
56
|
function getUnionTypes(type) {
|
|
58
|
-
if (type.kind ===
|
|
57
|
+
if (type.kind === ReflectionKind.union && type.types.length > 0) return (0, __stryke_helpers_get_unique.getUniqueBy)(type.types, (member) => member.kind);
|
|
59
58
|
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
60
59
|
}
|
|
61
60
|
function isStringUnion(type) {
|
|
62
|
-
return getUnionTypes(type).some((member) => member.kind ===
|
|
61
|
+
return getUnionTypes(type).some((member) => member.kind === ReflectionKind.string || member.kind === ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(member.literal));
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Converts a ReflectionKind to its string representation.
|
|
@@ -68,41 +67,41 @@ function isStringUnion(type) {
|
|
|
68
67
|
* @returns A string representation of the kind.
|
|
69
68
|
*/
|
|
70
69
|
function kindToName(kind) {
|
|
71
|
-
if (kind ===
|
|
72
|
-
else if (kind ===
|
|
73
|
-
else if (kind ===
|
|
74
|
-
else if (kind ===
|
|
75
|
-
else if (kind ===
|
|
76
|
-
else if (kind ===
|
|
77
|
-
else if (kind ===
|
|
78
|
-
else if (kind ===
|
|
79
|
-
else if (kind ===
|
|
80
|
-
else if (kind ===
|
|
81
|
-
else if (kind ===
|
|
82
|
-
else if (kind ===
|
|
83
|
-
else if (kind ===
|
|
84
|
-
else if (kind ===
|
|
85
|
-
else if (kind ===
|
|
86
|
-
else if (kind ===
|
|
87
|
-
else if (kind ===
|
|
88
|
-
else if (kind ===
|
|
89
|
-
else if (kind ===
|
|
90
|
-
else if (kind ===
|
|
91
|
-
else if (kind ===
|
|
92
|
-
else if (kind ===
|
|
93
|
-
else if (kind ===
|
|
94
|
-
else if (kind ===
|
|
95
|
-
else if (kind ===
|
|
96
|
-
else if (kind ===
|
|
97
|
-
else if (kind ===
|
|
98
|
-
else if (kind ===
|
|
99
|
-
else if (kind ===
|
|
100
|
-
else if (kind ===
|
|
101
|
-
else if (kind ===
|
|
102
|
-
else if (kind ===
|
|
103
|
-
else if (kind ===
|
|
104
|
-
else if (kind ===
|
|
105
|
-
else if (kind ===
|
|
70
|
+
if (kind === ReflectionKind.void) return "void";
|
|
71
|
+
else if (kind === ReflectionKind.never) return "never";
|
|
72
|
+
else if (kind === ReflectionKind.null) return "null";
|
|
73
|
+
else if (kind === ReflectionKind.undefined) return "undefined";
|
|
74
|
+
else if (kind === ReflectionKind.symbol) return "symbol";
|
|
75
|
+
else if (kind === ReflectionKind.bigint) return "bigint";
|
|
76
|
+
else if (kind === ReflectionKind.number) return "number";
|
|
77
|
+
else if (kind === ReflectionKind.string) return "string";
|
|
78
|
+
else if (kind === ReflectionKind.boolean) return "boolean";
|
|
79
|
+
else if (kind === ReflectionKind.literal) return "literal";
|
|
80
|
+
else if (kind === ReflectionKind.class) return "class";
|
|
81
|
+
else if (kind === ReflectionKind.array) return "array";
|
|
82
|
+
else if (kind === ReflectionKind.object) return "object";
|
|
83
|
+
else if (kind === ReflectionKind.objectLiteral) return "objectLiteral";
|
|
84
|
+
else if (kind === ReflectionKind.union) return "union";
|
|
85
|
+
else if (kind === ReflectionKind.enum) return "enum";
|
|
86
|
+
else if (kind === ReflectionKind.regexp) return "regexp";
|
|
87
|
+
else if (kind === ReflectionKind.templateLiteral) return "templateLiteral";
|
|
88
|
+
else if (kind === ReflectionKind.property) return "property";
|
|
89
|
+
else if (kind === ReflectionKind.method) return "method";
|
|
90
|
+
else if (kind === ReflectionKind.function) return "function";
|
|
91
|
+
else if (kind === ReflectionKind.parameter) return "parameter";
|
|
92
|
+
else if (kind === ReflectionKind.promise) return "promise";
|
|
93
|
+
else if (kind === ReflectionKind.typeParameter) return "typeParameter";
|
|
94
|
+
else if (kind === ReflectionKind.tuple) return "tuple";
|
|
95
|
+
else if (kind === ReflectionKind.tupleMember) return "tupleMember";
|
|
96
|
+
else if (kind === ReflectionKind.enumMember) return "enumMember";
|
|
97
|
+
else if (kind === ReflectionKind.rest) return "rest";
|
|
98
|
+
else if (kind === ReflectionKind.indexSignature) return "indexSignature";
|
|
99
|
+
else if (kind === ReflectionKind.propertySignature) return "propertySignature";
|
|
100
|
+
else if (kind === ReflectionKind.methodSignature) return "methodSignature";
|
|
101
|
+
else if (kind === ReflectionKind.infer) return "infer";
|
|
102
|
+
else if (kind === ReflectionKind.callSignature) return "callSignature";
|
|
103
|
+
else if (kind === ReflectionKind.any) return "any";
|
|
104
|
+
else if (kind === ReflectionKind.intersection) return "intersection";
|
|
106
105
|
return "unknown";
|
|
107
106
|
}
|
|
108
107
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type_exports } from "./vendor/type.mjs";
|
|
2
1
|
import { StormJSON } from "@stryke/json/storm-json";
|
|
3
2
|
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
4
3
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
@@ -33,7 +32,7 @@ function stringifyStringValue(value) {
|
|
|
33
32
|
* @returns A string representation of the value.
|
|
34
33
|
*/
|
|
35
34
|
function stringifyValue(type, value) {
|
|
36
|
-
return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind ===
|
|
35
|
+
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);
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
@@ -42,10 +41,10 @@ function stringifyValue(type, value) {
|
|
|
42
41
|
* @returns A string representation of the primitive type.
|
|
43
42
|
*/
|
|
44
43
|
function getEnumReflectionType(type) {
|
|
45
|
-
if (type.kind !==
|
|
46
|
-
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind:
|
|
44
|
+
if (type.kind !== ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
45
|
+
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number });
|
|
47
46
|
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
48
|
-
return unique[0] && isString(unique[0]) ? { kind:
|
|
47
|
+
return unique[0] && isString(unique[0]) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number };
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
@@ -54,11 +53,11 @@ function getEnumReflectionType(type) {
|
|
|
54
53
|
* @returns A string representation of the primitive type.
|
|
55
54
|
*/
|
|
56
55
|
function getUnionTypes(type) {
|
|
57
|
-
if (type.kind ===
|
|
56
|
+
if (type.kind === ReflectionKind.union && type.types.length > 0) return getUniqueBy(type.types, (member) => member.kind);
|
|
58
57
|
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
59
58
|
}
|
|
60
59
|
function isStringUnion(type) {
|
|
61
|
-
return getUnionTypes(type).some((member) => member.kind ===
|
|
60
|
+
return getUnionTypes(type).some((member) => member.kind === ReflectionKind.string || member.kind === ReflectionKind.literal && isString(member.literal));
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
64
63
|
* Converts a ReflectionKind to its string representation.
|
|
@@ -67,41 +66,41 @@ function isStringUnion(type) {
|
|
|
67
66
|
* @returns A string representation of the kind.
|
|
68
67
|
*/
|
|
69
68
|
function kindToName(kind) {
|
|
70
|
-
if (kind ===
|
|
71
|
-
else if (kind ===
|
|
72
|
-
else if (kind ===
|
|
73
|
-
else if (kind ===
|
|
74
|
-
else if (kind ===
|
|
75
|
-
else if (kind ===
|
|
76
|
-
else if (kind ===
|
|
77
|
-
else if (kind ===
|
|
78
|
-
else if (kind ===
|
|
79
|
-
else if (kind ===
|
|
80
|
-
else if (kind ===
|
|
81
|
-
else if (kind ===
|
|
82
|
-
else if (kind ===
|
|
83
|
-
else if (kind ===
|
|
84
|
-
else if (kind ===
|
|
85
|
-
else if (kind ===
|
|
86
|
-
else if (kind ===
|
|
87
|
-
else if (kind ===
|
|
88
|
-
else if (kind ===
|
|
89
|
-
else if (kind ===
|
|
90
|
-
else if (kind ===
|
|
91
|
-
else if (kind ===
|
|
92
|
-
else if (kind ===
|
|
93
|
-
else if (kind ===
|
|
94
|
-
else if (kind ===
|
|
95
|
-
else if (kind ===
|
|
96
|
-
else if (kind ===
|
|
97
|
-
else if (kind ===
|
|
98
|
-
else if (kind ===
|
|
99
|
-
else if (kind ===
|
|
100
|
-
else if (kind ===
|
|
101
|
-
else if (kind ===
|
|
102
|
-
else if (kind ===
|
|
103
|
-
else if (kind ===
|
|
104
|
-
else if (kind ===
|
|
69
|
+
if (kind === ReflectionKind.void) return "void";
|
|
70
|
+
else if (kind === ReflectionKind.never) return "never";
|
|
71
|
+
else if (kind === ReflectionKind.null) return "null";
|
|
72
|
+
else if (kind === ReflectionKind.undefined) return "undefined";
|
|
73
|
+
else if (kind === ReflectionKind.symbol) return "symbol";
|
|
74
|
+
else if (kind === ReflectionKind.bigint) return "bigint";
|
|
75
|
+
else if (kind === ReflectionKind.number) return "number";
|
|
76
|
+
else if (kind === ReflectionKind.string) return "string";
|
|
77
|
+
else if (kind === ReflectionKind.boolean) return "boolean";
|
|
78
|
+
else if (kind === ReflectionKind.literal) return "literal";
|
|
79
|
+
else if (kind === ReflectionKind.class) return "class";
|
|
80
|
+
else if (kind === ReflectionKind.array) return "array";
|
|
81
|
+
else if (kind === ReflectionKind.object) return "object";
|
|
82
|
+
else if (kind === ReflectionKind.objectLiteral) return "objectLiteral";
|
|
83
|
+
else if (kind === ReflectionKind.union) return "union";
|
|
84
|
+
else if (kind === ReflectionKind.enum) return "enum";
|
|
85
|
+
else if (kind === ReflectionKind.regexp) return "regexp";
|
|
86
|
+
else if (kind === ReflectionKind.templateLiteral) return "templateLiteral";
|
|
87
|
+
else if (kind === ReflectionKind.property) return "property";
|
|
88
|
+
else if (kind === ReflectionKind.method) return "method";
|
|
89
|
+
else if (kind === ReflectionKind.function) return "function";
|
|
90
|
+
else if (kind === ReflectionKind.parameter) return "parameter";
|
|
91
|
+
else if (kind === ReflectionKind.promise) return "promise";
|
|
92
|
+
else if (kind === ReflectionKind.typeParameter) return "typeParameter";
|
|
93
|
+
else if (kind === ReflectionKind.tuple) return "tuple";
|
|
94
|
+
else if (kind === ReflectionKind.tupleMember) return "tupleMember";
|
|
95
|
+
else if (kind === ReflectionKind.enumMember) return "enumMember";
|
|
96
|
+
else if (kind === ReflectionKind.rest) return "rest";
|
|
97
|
+
else if (kind === ReflectionKind.indexSignature) return "indexSignature";
|
|
98
|
+
else if (kind === ReflectionKind.propertySignature) return "propertySignature";
|
|
99
|
+
else if (kind === ReflectionKind.methodSignature) return "methodSignature";
|
|
100
|
+
else if (kind === ReflectionKind.infer) return "infer";
|
|
101
|
+
else if (kind === ReflectionKind.callSignature) return "callSignature";
|
|
102
|
+
else if (kind === ReflectionKind.any) return "any";
|
|
103
|
+
else if (kind === ReflectionKind.intersection) return "intersection";
|
|
105
104
|
return "unknown";
|
|
106
105
|
}
|
|
107
106
|
|
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
3
2
|
const require_utilities = require('../deepkit/src/utilities.cjs');
|
|
4
|
-
const require_core = require('../deepkit/src/vendor/core.cjs');
|
|
5
3
|
const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
|
|
6
4
|
let defu = require("defu");
|
|
7
5
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
@@ -65,7 +63,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
65
63
|
* @returns A string representation of the value.
|
|
66
64
|
*/
|
|
67
65
|
function stringifyCapnpValue(type, value) {
|
|
68
|
-
return type.kind ===
|
|
66
|
+
return type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === ReflectionKind.enum ? `${(0, __stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === ReflectionKind.array ? __stryke_json.StormJSON.stringify(value) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? __stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
69
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -74,7 +72,7 @@ function stringifyCapnpValue(type, value) {
|
|
|
74
72
|
* @returns A string representation of the property.
|
|
75
73
|
*/
|
|
76
74
|
function getCapnpEnumTypes(type) {
|
|
77
|
-
if (type.kind !==
|
|
75
|
+
if (type.kind !== ReflectionKind.enum) return null;
|
|
78
76
|
const unique = (0, __stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => !(0, __stryke_type_checks_is_undefined.isUndefined)(value) && !(0, __stryke_type_checks_is_null.isNull)(value)), (enumMember) => (0, __stryke_type_checks_is_string.isString)(enumMember) ? "Text" : "Float32");
|
|
79
77
|
if (unique.length === 0) return null;
|
|
80
78
|
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
|
|
@@ -86,7 +84,7 @@ function getCapnpEnumTypes(type) {
|
|
|
86
84
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
87
85
|
*/
|
|
88
86
|
function isVoidType(type) {
|
|
89
|
-
return type.kind ===
|
|
87
|
+
return type.kind === ReflectionKind.void || type.kind === ReflectionKind.never || type.kind === ReflectionKind.null || type.kind === ReflectionKind.undefined || type.kind === ReflectionKind.symbol;
|
|
90
88
|
}
|
|
91
89
|
/**
|
|
92
90
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -104,7 +102,7 @@ function getCapnpUnionTypes(type) {
|
|
|
104
102
|
* @returns An array of Cap'n Proto primitive types.
|
|
105
103
|
*/
|
|
106
104
|
function isCapnpStringUnion(type) {
|
|
107
|
-
return getCapnpUnionTypes(type).some((member) => member.kind ===
|
|
105
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === ReflectionKind.string);
|
|
108
106
|
}
|
|
109
107
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
110
108
|
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
@@ -144,7 +142,7 @@ function formatEnumName(name) {
|
|
|
144
142
|
return (0, __stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
145
143
|
}
|
|
146
144
|
function generateCapnpEnums(reflection) {
|
|
147
|
-
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind ===
|
|
145
|
+
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === ReflectionKind.enum || prop.type.kind === ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === ReflectionKind.literal && ((0, __stryke_type_checks_is_string.isString)(type.literal) || (0, __stryke_type_checks_is_number.isNumber)(type.literal))).length === 1)).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
148
146
|
if (enums.length === 0) return "";
|
|
149
147
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
150
148
|
|
|
@@ -153,7 +151,7 @@ function generateCapnpEnums(reflection) {
|
|
|
153
151
|
function generateCapnpSchema(reflection, options = {}) {
|
|
154
152
|
let index = 0;
|
|
155
153
|
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
156
|
-
return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind ===
|
|
154
|
+
return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind === ReflectionKind.class && prop.type.classType === Map) ? `
|
|
157
155
|
struct Map(Key, Value) {
|
|
158
156
|
entries @0 :List(Entry);
|
|
159
157
|
|
|
@@ -161,7 +159,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
161
159
|
key @0 :Key;
|
|
162
160
|
value @1 :Value;
|
|
163
161
|
}
|
|
164
|
-
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind ===
|
|
162
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === ReflectionKind.class && prop.type.classType === Date) ? `
|
|
165
163
|
struct Date {
|
|
166
164
|
# A standard Gregorian calendar date.
|
|
167
165
|
|
|
@@ -202,17 +200,17 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
202
200
|
return "";
|
|
203
201
|
}
|
|
204
202
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
205
|
-
if (reflection.type.kind ===
|
|
203
|
+
if (reflection.type.kind === ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
206
204
|
${generateCapnpPropertyComment(reflection)}`;
|
|
207
|
-
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind ===
|
|
205
|
+
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === ReflectionKind.literal && ((0, __stryke_type_checks_is_string.isString)(type.literal) || (0, __stryke_type_checks_is_number.isNumber)(type.literal))).length === 1) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
208
206
|
${generateCapnpPropertyComment(reflection)}`;
|
|
209
207
|
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
|
|
210
208
|
${getCapnpUnionTypes(reflection.type).map((type) => ` ${require_utilities.kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
211
209
|
}
|
|
212
210
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
|
-
else if (reflection.type.kind ===
|
|
211
|
+
else if (reflection.type.kind === ReflectionKind.array) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
214
212
|
${generateCapnpPropertyComment(reflection)}`;
|
|
215
|
-
else if (reflection.type.kind ===
|
|
213
|
+
else if (reflection.type.kind === ReflectionKind.class) if (reflection.type.classType === Map) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Map(${!reflection.type.typeArguments || reflection.type.typeArguments.length === 0 || !reflection.type.typeArguments[0] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[0])}, ${!reflection.type.typeArguments || reflection.type.typeArguments.length < 2 || !reflection.type.typeArguments[1] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[1])})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
216
214
|
${generateCapnpPropertyComment(reflection)}`;
|
|
217
215
|
else if (reflection.type.classType === Date) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
218
216
|
${generateCapnpPropertyComment(reflection)}`;
|
|
@@ -220,24 +218,24 @@ ${generateCapnpPropertyComment(reflection)}`;
|
|
|
220
218
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
219
|
else if (reflection.type.classType === ArrayBuffer) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
222
220
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName ||
|
|
221
|
+
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || getClassName(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || getClassName(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
224
222
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
|
-
else if (reflection.type.kind ===
|
|
223
|
+
else if (reflection.type.kind === ReflectionKind.objectLiteral) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || memberNameToString(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || memberNameToString(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
226
224
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
|
-
else if (reflection.type.kind ===
|
|
225
|
+
else if (reflection.type.kind === ReflectionKind.enum) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
228
226
|
${generateCapnpPropertyComment(reflection)}`;
|
|
229
227
|
return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
230
228
|
${generateCapnpPropertyComment(reflection)}`;
|
|
231
229
|
}
|
|
232
230
|
function generateCapnpEnumSchema(type, name) {
|
|
233
|
-
if (type.kind ===
|
|
234
|
-
kind:
|
|
231
|
+
if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
|
+
kind: ReflectionKind.enum,
|
|
235
233
|
indexType: type,
|
|
236
234
|
enum: type.types.reduce((ret, type$1) => {
|
|
237
235
|
if ((0, __stryke_type_checks_is_string.isString)(type$1.literal) || (0, __stryke_type_checks_is_number.isNumber)(type$1.literal)) ret[(0, __stryke_string_format_camel_case.camelCase)(String(type$1.literal))] = type$1.literal;
|
|
238
236
|
return ret;
|
|
239
237
|
}, {}),
|
|
240
|
-
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind ===
|
|
238
|
+
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind === ReflectionKind.literal && ((0, __stryke_type_checks_is_string.isString)(type$1.literal) || (0, __stryke_type_checks_is_number.isNumber)(type$1.literal))).map((type$1) => type$1.literal)
|
|
241
239
|
}, name);
|
|
242
240
|
let index = 0;
|
|
243
241
|
const indexCounter = () => index++;
|
|
@@ -254,7 +252,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
254
252
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
255
253
|
*/
|
|
256
254
|
function generateCapnpPrimitive(type) {
|
|
257
|
-
return type.kind ===
|
|
255
|
+
return type.kind === ReflectionKind.never || type.kind === ReflectionKind.void || type.kind === ReflectionKind.null || type.kind === ReflectionKind.undefined || type.kind === ReflectionKind.symbol ? "Void" : type.kind === ReflectionKind.class && type.classType === Date ? "Date" : type.kind === ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === ReflectionKind.bigint ? "UInt64" : type.kind === ReflectionKind.number ? "Float64" : type.kind === ReflectionKind.string || type.kind === ReflectionKind.regexp ? "Text" : type.kind === ReflectionKind.boolean ? "Bool" : type.kind === ReflectionKind.literal ? (0, __stryke_type_checks_is_number.isNumber)(type.literal) ? "Float64" : (0, __stryke_type_checks_is_bigint.isBigInt)(type.literal) ? "UInt64" : (0, __stryke_type_checks_is_string.isString)(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
|
|
258
256
|
}
|
|
259
257
|
|
|
260
258
|
//#endregion
|