@powerlines/plugin-alloy 0.18.1 → 0.18.2
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/single-line-comment.d.mts +2 -2
- package/dist/core/components/source-file.d.cts +2 -2
- package/dist/core/contexts/reflection.d.cts +8 -8
- package/dist/core/contexts/reflection.d.mts +8 -8
- package/dist/core/index.d.cts +1 -0
- package/dist/deepkit/src/utilities.cjs +42 -42
- package/dist/deepkit/src/utilities.mjs +42 -42
- package/dist/helpers/capnp.cjs +20 -20
- package/dist/helpers/capnp.d.cts +14 -14
- package/dist/helpers/capnp.d.mts +14 -14
- package/dist/helpers/capnp.mjs +20 -20
- package/dist/helpers/typescript.d.cts +2 -2
- package/dist/helpers/typescript.d.mts +2 -2
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-table.d.cts +4 -4
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/builtin-file.d.mts +2 -2
- 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.cts +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/tsdoc-reflection.d.mts +4 -4
- package/dist/typescript/components/typescript-interface.cjs +2 -2
- package/dist/typescript/components/typescript-interface.d.cts +6 -6
- package/dist/typescript/components/typescript-interface.d.mts +3 -3
- package/dist/typescript/components/typescript-interface.mjs +2 -2
- package/dist/typescript/components/typescript-object.d.cts +6 -6
- package/dist/typescript/components/typescript-object.d.mts +3 -3
- package/dist/typescript/index.d.cts +1 -0
- package/package.json +3 -3
- 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,6 +1,6 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.cjs";
|
|
2
2
|
import { MetaItem } from "../contexts/context.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core5 from "@alloy-js/core";
|
|
4
4
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/output.d.ts
|
|
@@ -17,7 +17,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext, TMeta exte
|
|
|
17
17
|
/**
|
|
18
18
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
19
19
|
*/
|
|
20
|
-
declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>):
|
|
20
|
+
declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>): _alloy_js_core5.Children;
|
|
21
21
|
declare type __ΩOutputProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.mjs";
|
|
2
2
|
import { MetaItem } from "../contexts/context.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
4
4
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/output.d.ts
|
|
@@ -17,7 +17,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext, TMeta exte
|
|
|
17
17
|
/**
|
|
18
18
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
19
19
|
*/
|
|
20
|
-
declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>):
|
|
20
|
+
declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>): _alloy_js_core1.Children;
|
|
21
21
|
declare type __ΩOutputProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core6 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_core6.Children;
|
|
19
19
|
declare type __ΩSingleLineCommentVariant = any[];
|
|
20
20
|
declare type __ΩSingleLineCommentProps = any[];
|
|
21
21
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core0 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_core0.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_core15 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
|
|
@@ -26,7 +26,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
26
26
|
* @param props - The properties for the source file.
|
|
27
27
|
* @returns The rendered source file component.
|
|
28
28
|
*/
|
|
29
|
-
declare function SourceFile(props: SourceFileProps):
|
|
29
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core15.Children;
|
|
30
30
|
declare type __ΩSourceFileProps = any[];
|
|
31
31
|
//#endregion
|
|
32
32
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
|
@@ -1,10 +1,10 @@
|
|
|
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";
|
|
3
|
+
import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
4
4
|
|
|
5
5
|
//#region src/core/contexts/reflection.d.ts
|
|
6
6
|
interface ReflectionClassContextInterface<T extends Record<string, any> = Record<string, any>> {
|
|
7
|
-
reflection:
|
|
7
|
+
reflection: ReflectionClass<T>;
|
|
8
8
|
override?: ReflectionOverrideInterface<T>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -20,33 +20,33 @@ declare function useReflectionClass<T extends Record<string, any> = Record<strin
|
|
|
20
20
|
/**
|
|
21
21
|
* The reflection property context used in template rendering.
|
|
22
22
|
*/
|
|
23
|
-
declare const ReflectionPropertyContext: ComponentContext<
|
|
23
|
+
declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
|
|
24
24
|
/**
|
|
25
25
|
* Hook to access the Reflection Property context.
|
|
26
26
|
*
|
|
27
27
|
* @returns A reactive version of the current reflection.
|
|
28
28
|
*/
|
|
29
|
-
declare function useReflectionProperty():
|
|
29
|
+
declare function useReflectionProperty(): ReflectionProperty;
|
|
30
30
|
/**
|
|
31
31
|
* The reflection method context used in template rendering.
|
|
32
32
|
*/
|
|
33
|
-
declare const ReflectionMethodContext: ComponentContext<
|
|
33
|
+
declare const ReflectionMethodContext: ComponentContext<ReflectionMethod>;
|
|
34
34
|
/**
|
|
35
35
|
* Hook to access the Reflection Method context.
|
|
36
36
|
*
|
|
37
37
|
* @returns A reactive version of the current reflection.
|
|
38
38
|
*/
|
|
39
|
-
declare function useReflectionMethod():
|
|
39
|
+
declare function useReflectionMethod(): ReflectionMethod;
|
|
40
40
|
/**
|
|
41
41
|
* The reflection parameter context used in template rendering.
|
|
42
42
|
*/
|
|
43
|
-
declare const ReflectionParameterContext: ComponentContext<
|
|
43
|
+
declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
|
|
44
44
|
/**
|
|
45
45
|
* Hook to access the Reflection Parameter context.
|
|
46
46
|
*
|
|
47
47
|
* @returns A reactive version of the current reflection.
|
|
48
48
|
*/
|
|
49
|
-
declare function useReflectionParameter():
|
|
49
|
+
declare function useReflectionParameter(): ReflectionParameter;
|
|
50
50
|
declare type __ΩReflectionClassContextInterface = any[];
|
|
51
51
|
//#endregion
|
|
52
52
|
export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -1,10 +1,10 @@
|
|
|
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";
|
|
3
|
+
import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
4
4
|
|
|
5
5
|
//#region src/core/contexts/reflection.d.ts
|
|
6
6
|
interface ReflectionClassContextInterface<T extends Record<string, any> = Record<string, any>> {
|
|
7
|
-
reflection:
|
|
7
|
+
reflection: ReflectionClass<T>;
|
|
8
8
|
override?: ReflectionOverrideInterface<T>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -20,33 +20,33 @@ declare function useReflectionClass<T extends Record<string, any> = Record<strin
|
|
|
20
20
|
/**
|
|
21
21
|
* The reflection property context used in template rendering.
|
|
22
22
|
*/
|
|
23
|
-
declare const ReflectionPropertyContext: ComponentContext<
|
|
23
|
+
declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
|
|
24
24
|
/**
|
|
25
25
|
* Hook to access the Reflection Property context.
|
|
26
26
|
*
|
|
27
27
|
* @returns A reactive version of the current reflection.
|
|
28
28
|
*/
|
|
29
|
-
declare function useReflectionProperty():
|
|
29
|
+
declare function useReflectionProperty(): ReflectionProperty;
|
|
30
30
|
/**
|
|
31
31
|
* The reflection method context used in template rendering.
|
|
32
32
|
*/
|
|
33
|
-
declare const ReflectionMethodContext: ComponentContext<
|
|
33
|
+
declare const ReflectionMethodContext: ComponentContext<ReflectionMethod>;
|
|
34
34
|
/**
|
|
35
35
|
* Hook to access the Reflection Method context.
|
|
36
36
|
*
|
|
37
37
|
* @returns A reactive version of the current reflection.
|
|
38
38
|
*/
|
|
39
|
-
declare function useReflectionMethod():
|
|
39
|
+
declare function useReflectionMethod(): ReflectionMethod;
|
|
40
40
|
/**
|
|
41
41
|
* The reflection parameter context used in template rendering.
|
|
42
42
|
*/
|
|
43
|
-
declare const ReflectionParameterContext: ComponentContext<
|
|
43
|
+
declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
|
|
44
44
|
/**
|
|
45
45
|
* Hook to access the Reflection Parameter context.
|
|
46
46
|
*
|
|
47
47
|
* @returns A reactive version of the current reflection.
|
|
48
48
|
*/
|
|
49
|
-
declare function useReflectionParameter():
|
|
49
|
+
declare function useReflectionParameter(): ReflectionParameter;
|
|
50
50
|
declare type __ΩReflectionClassContextInterface = any[];
|
|
51
51
|
//#endregion
|
|
52
52
|
export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
package/dist/core/index.d.cts
CHANGED
|
@@ -3,4 +3,5 @@ import { Output, OutputProps, __ΩOutputProps } from "./components/output.cjs";
|
|
|
3
3
|
import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.cjs";
|
|
4
4
|
import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.cjs";
|
|
5
5
|
import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.cjs";
|
|
6
|
+
import "./contexts/index.cjs";
|
|
6
7
|
export { MetaItem, Output, OutputProps, PowerlinesContext, PowerlinesContextInterface, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, __ΩMetaItem, __ΩOutputProps, __ΩPowerlinesContextInterface, __ΩReflectionClassContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, useMeta, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -1,6 +1,6 @@
|
|
|
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");
|
|
3
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
4
4
|
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
5
5
|
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
6
6
|
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
@@ -34,7 +34,7 @@ function stringifyStringValue(value) {
|
|
|
34
34
|
* @returns A string representation of the value.
|
|
35
35
|
*/
|
|
36
36
|
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 ===
|
|
37
|
+
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? stringifyStringValue(value) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.enum ? getEnumReflectionType(type).kind === __powerlines_deepkit_vendor_type.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array ? stringifyStringValue(__stryke_json_storm_json.StormJSON.stringify(value)) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.object || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral ? __stryke_json_storm_json.StormJSON.stringify(value) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.property || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
@@ -43,10 +43,10 @@ function stringifyValue(type, value) {
|
|
|
43
43
|
* @returns A string representation of the primitive type.
|
|
44
44
|
*/
|
|
45
45
|
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:
|
|
46
|
+
if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${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: __powerlines_deepkit_vendor_type.ReflectionKind.string } : { kind: __powerlines_deepkit_vendor_type.ReflectionKind.number });
|
|
48
48
|
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:
|
|
49
|
+
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind: __powerlines_deepkit_vendor_type.ReflectionKind.string } : { kind: __powerlines_deepkit_vendor_type.ReflectionKind.number };
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
@@ -55,11 +55,11 @@ function getEnumReflectionType(type) {
|
|
|
55
55
|
* @returns A string representation of the primitive type.
|
|
56
56
|
*/
|
|
57
57
|
function getUnionTypes(type) {
|
|
58
|
-
if (type.kind ===
|
|
58
|
+
if (type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.union && type.types.length > 0) return (0, __stryke_helpers_get_unique.getUniqueBy)(type.types, (member) => member.kind);
|
|
59
59
|
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
60
60
|
}
|
|
61
61
|
function isStringUnion(type) {
|
|
62
|
-
return getUnionTypes(type).some((member) => member.kind ===
|
|
62
|
+
return getUnionTypes(type).some((member) => member.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || member.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(member.literal));
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Converts a ReflectionKind to its string representation.
|
|
@@ -68,41 +68,41 @@ function isStringUnion(type) {
|
|
|
68
68
|
* @returns A string representation of the kind.
|
|
69
69
|
*/
|
|
70
70
|
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 ===
|
|
71
|
+
if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.void) return "void";
|
|
72
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.never) return "never";
|
|
73
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.null) return "null";
|
|
74
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.undefined) return "undefined";
|
|
75
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.symbol) return "symbol";
|
|
76
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.bigint) return "bigint";
|
|
77
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.number) return "number";
|
|
78
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.string) return "string";
|
|
79
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean) return "boolean";
|
|
80
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal) return "literal";
|
|
81
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.class) return "class";
|
|
82
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.array) return "array";
|
|
83
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.object) return "object";
|
|
84
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral) return "objectLiteral";
|
|
85
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.union) return "union";
|
|
86
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.enum) return "enum";
|
|
87
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.regexp) return "regexp";
|
|
88
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.templateLiteral) return "templateLiteral";
|
|
89
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.property) return "property";
|
|
90
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.method) return "method";
|
|
91
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.function) return "function";
|
|
92
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.parameter) return "parameter";
|
|
93
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.promise) return "promise";
|
|
94
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.typeParameter) return "typeParameter";
|
|
95
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.tuple) return "tuple";
|
|
96
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.tupleMember) return "tupleMember";
|
|
97
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.enumMember) return "enumMember";
|
|
98
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.rest) return "rest";
|
|
99
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.indexSignature) return "indexSignature";
|
|
100
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.propertySignature) return "propertySignature";
|
|
101
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.methodSignature) return "methodSignature";
|
|
102
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.infer) return "infer";
|
|
103
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.callSignature) return "callSignature";
|
|
104
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.any) return "any";
|
|
105
|
+
else if (kind === __powerlines_deepkit_vendor_type.ReflectionKind.intersection) return "intersection";
|
|
106
106
|
return "unknown";
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type_exports } from "./vendor/type.mjs";
|
|
2
1
|
import { StormJSON } from "@stryke/json/storm-json";
|
|
2
|
+
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
3
3
|
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
4
4
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
5
5
|
import { isString } from "@stryke/type-checks/is-string";
|
|
@@ -33,7 +33,7 @@ function stringifyStringValue(value) {
|
|
|
33
33
|
* @returns A string representation of the value.
|
|
34
34
|
*/
|
|
35
35
|
function stringifyValue(type, value) {
|
|
36
|
-
return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind ===
|
|
36
|
+
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
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
@@ -42,10 +42,10 @@ function stringifyValue(type, value) {
|
|
|
42
42
|
* @returns A string representation of the primitive type.
|
|
43
43
|
*/
|
|
44
44
|
function getEnumReflectionType(type) {
|
|
45
|
-
if (type.kind !==
|
|
46
|
-
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind:
|
|
45
|
+
if (type.kind !== ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
46
|
+
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number });
|
|
47
47
|
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
48
|
-
return unique[0] && isString(unique[0]) ? { kind:
|
|
48
|
+
return unique[0] && isString(unique[0]) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number };
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
@@ -54,11 +54,11 @@ function getEnumReflectionType(type) {
|
|
|
54
54
|
* @returns A string representation of the primitive type.
|
|
55
55
|
*/
|
|
56
56
|
function getUnionTypes(type) {
|
|
57
|
-
if (type.kind ===
|
|
57
|
+
if (type.kind === ReflectionKind.union && type.types.length > 0) return getUniqueBy(type.types, (member) => member.kind);
|
|
58
58
|
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
59
59
|
}
|
|
60
60
|
function isStringUnion(type) {
|
|
61
|
-
return getUnionTypes(type).some((member) => member.kind ===
|
|
61
|
+
return getUnionTypes(type).some((member) => member.kind === ReflectionKind.string || member.kind === ReflectionKind.literal && isString(member.literal));
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Converts a ReflectionKind to its string representation.
|
|
@@ -67,41 +67,41 @@ function isStringUnion(type) {
|
|
|
67
67
|
* @returns A string representation of the kind.
|
|
68
68
|
*/
|
|
69
69
|
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 ===
|
|
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";
|
|
105
105
|
return "unknown";
|
|
106
106
|
}
|
|
107
107
|
|