@shell-shock/core 0.9.7 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.cjs +4 -4
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/helpers.d.cts +6 -6
- package/dist/components/helpers.d.mts +6 -6
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/options-parser-logic.cjs +31 -31
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +26 -26
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +5 -5
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.mjs +4 -4
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +204 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +13 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +13 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +208 -5
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +2 -2
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.d.cts +1 -1
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +4 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +2 -2
- package/dist/helpers/automd.cjs.map +1 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +125 -0
- package/dist/helpers/paths.cjs.map +1 -0
- package/dist/helpers/paths.mjs +121 -0
- package/dist/helpers/paths.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +68 -116
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +68 -116
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +5 -5
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -1
- package/dist/helpers/utilities.mjs +1 -1
- package/dist/helpers/validations.cjs +2 -3
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +2 -2
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +72 -0
- package/dist/plugin-utils/deepkit.cjs.map +1 -0
- package/dist/plugin-utils/deepkit.d.cts +24 -0
- package/dist/plugin-utils/deepkit.d.cts.map +1 -0
- package/dist/plugin-utils/deepkit.d.mts +24 -0
- package/dist/plugin-utils/deepkit.d.mts.map +1 -0
- package/dist/plugin-utils/deepkit.mjs +70 -0
- package/dist/plugin-utils/deepkit.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +2 -2
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/index.cjs +27 -18
- package/dist/plugin-utils/index.d.cts +3 -1
- package/dist/plugin-utils/index.d.mts +3 -1
- package/dist/plugin-utils/index.mjs +3 -1
- package/dist/plugin-utils/reflect.cjs +4 -5
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +4 -4
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +89 -0
- package/dist/plugin-utils/type-checks.cjs.map +1 -0
- package/dist/plugin-utils/type-checks.d.cts +42 -0
- package/dist/plugin-utils/type-checks.d.cts.map +1 -0
- package/dist/plugin-utils/type-checks.d.mts +42 -0
- package/dist/plugin-utils/type-checks.d.mts.map +1 -0
- package/dist/plugin-utils/type-checks.mjs +84 -0
- package/dist/plugin-utils/type-checks.mjs.map +1 -0
- package/dist/plugin.cjs +48 -45
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +30 -26
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +129 -0
- package/dist/resolver/deepkit.cjs.map +1 -0
- package/dist/resolver/deepkit.mjs +128 -0
- package/dist/resolver/deepkit.mjs.map +1 -0
- package/dist/resolver/helpers.cjs +173 -0
- package/dist/resolver/helpers.cjs.map +1 -0
- package/dist/resolver/helpers.mjs +168 -0
- package/dist/resolver/helpers.mjs.map +1 -0
- package/dist/resolver/module.cjs +144 -0
- package/dist/resolver/module.cjs.map +1 -0
- package/dist/resolver/module.mjs +143 -0
- package/dist/resolver/module.mjs.map +1 -0
- package/dist/resolver/resolve.cjs +209 -0
- package/dist/resolver/resolve.cjs.map +1 -0
- package/dist/resolver/resolve.mjs +208 -0
- package/dist/resolver/resolve.mjs.map +1 -0
- package/dist/types/command.cjs +131 -99
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +49 -75
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +49 -75
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +119 -91
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -2
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +2 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +2 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -1
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts +3 -3
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -3
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/index.cjs +13 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +34 -79
- package/dist/helpers/resolve-command.cjs +0 -410
- package/dist/helpers/resolve-command.cjs.map +0 -1
- package/dist/helpers/resolve-command.mjs +0 -405
- package/dist/helpers/resolve-command.mjs.map +0 -1
package/dist/types/command.d.cts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
2
|
+
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
import { JsonSchema7TupleType } from "@stryke/json";
|
|
2
4
|
import { AnyFunction } from "@stryke/types/base";
|
|
3
|
-
import {
|
|
5
|
+
import { JSONSchema7Object } from "json-schema";
|
|
6
|
+
import * as z3 from "zod/v3";
|
|
4
7
|
|
|
5
8
|
//#region src/types/command.d.ts
|
|
9
|
+
type CommandParameterType = string | number | boolean | (string | number)[];
|
|
10
|
+
declare const CommandParameterKinds: {
|
|
11
|
+
readonly string: "string";
|
|
12
|
+
readonly number: "number";
|
|
13
|
+
readonly boolean: "boolean";
|
|
14
|
+
};
|
|
15
|
+
type CommandParameterKind = (typeof CommandParameterKinds)[keyof typeof CommandParameterKinds];
|
|
6
16
|
interface BaseCommandParameter {
|
|
7
17
|
/**
|
|
8
18
|
* The option name.
|
|
@@ -11,7 +21,7 @@ interface BaseCommandParameter {
|
|
|
11
21
|
/**
|
|
12
22
|
* The option kind.
|
|
13
23
|
*/
|
|
14
|
-
kind:
|
|
24
|
+
kind: CommandParameterKind;
|
|
15
25
|
/**
|
|
16
26
|
* The display title.
|
|
17
27
|
*/
|
|
@@ -37,21 +47,29 @@ interface StringCommandParameter extends BaseCommandParameter {
|
|
|
37
47
|
/**
|
|
38
48
|
* The option kind.
|
|
39
49
|
*/
|
|
40
|
-
kind:
|
|
50
|
+
kind: "string";
|
|
41
51
|
/**
|
|
42
52
|
* The default value.
|
|
43
53
|
*/
|
|
44
54
|
default?: string;
|
|
55
|
+
/**
|
|
56
|
+
* A standard string format to validate the option value against.
|
|
57
|
+
*/
|
|
58
|
+
format?: "email" | "uri" | "uuid" | "ipv4" | "ipv6" | "date" | "time" | "date-time" | "duration";
|
|
45
59
|
/**
|
|
46
60
|
* Whether the option accepts multiple values.
|
|
47
61
|
*/
|
|
48
62
|
variadic: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The allowed choices for the option value.
|
|
65
|
+
*/
|
|
66
|
+
choices?: string[];
|
|
49
67
|
}
|
|
50
68
|
interface NumberCommandParameter extends BaseCommandParameter {
|
|
51
69
|
/**
|
|
52
70
|
* The option kind.
|
|
53
71
|
*/
|
|
54
|
-
kind:
|
|
72
|
+
kind: "number";
|
|
55
73
|
/**
|
|
56
74
|
* The default value.
|
|
57
75
|
*/
|
|
@@ -60,42 +78,30 @@ interface NumberCommandParameter extends BaseCommandParameter {
|
|
|
60
78
|
* Whether the option accepts multiple values.
|
|
61
79
|
*/
|
|
62
80
|
variadic: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The allowed choices for the option value.
|
|
83
|
+
*/
|
|
84
|
+
choices?: number[];
|
|
63
85
|
}
|
|
64
86
|
interface BooleanCommandParameter extends BaseCommandParameter {
|
|
65
87
|
/**
|
|
66
88
|
* The option kind.
|
|
67
89
|
*/
|
|
68
|
-
kind:
|
|
90
|
+
kind: "boolean";
|
|
69
91
|
/**
|
|
70
92
|
* The default value.
|
|
71
93
|
*/
|
|
72
94
|
default?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The option this negates.
|
|
75
|
-
*/
|
|
76
|
-
isNegativeOf?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Whether to skip adding a negative option.
|
|
79
|
-
*/
|
|
80
|
-
skipAddingNegative?: boolean;
|
|
81
|
-
}
|
|
82
|
-
interface StringCommandOption extends StringCommandParameter {
|
|
83
|
-
/**
|
|
84
|
-
* The property reflection.
|
|
85
|
-
*/
|
|
86
|
-
reflection?: ReflectionProperty;
|
|
87
|
-
}
|
|
88
|
-
interface NumberCommandOption extends NumberCommandParameter {
|
|
89
|
-
/**
|
|
90
|
-
* The property reflection.
|
|
91
|
-
*/
|
|
92
|
-
reflection?: ReflectionProperty;
|
|
93
95
|
}
|
|
96
|
+
type CommandParameter = StringCommandParameter | NumberCommandParameter | BooleanCommandParameter;
|
|
97
|
+
type AsCommandParameterConfig<T extends BaseCommandParameter> = Pick<T, "kind" | "alias"> & Partial<Omit<T, "kind" | "alias">> & {
|
|
98
|
+
alias?: string | string[];
|
|
99
|
+
};
|
|
100
|
+
type StringCommandParameterConfig = AsCommandParameterConfig<StringCommandParameter>;
|
|
101
|
+
type NumberCommandParameterConfig = AsCommandParameterConfig<NumberCommandParameter>;
|
|
102
|
+
type BooleanCommandParameterConfig = AsCommandParameterConfig<BooleanCommandParameter>;
|
|
103
|
+
type CommandParameterConfig = StringCommandParameterConfig | NumberCommandParameterConfig | BooleanCommandParameterConfig;
|
|
94
104
|
interface BooleanCommandOption extends BooleanCommandParameter {
|
|
95
|
-
/**
|
|
96
|
-
* The property reflection.
|
|
97
|
-
*/
|
|
98
|
-
reflection?: ReflectionProperty;
|
|
99
105
|
/**
|
|
100
106
|
* The option this negates.
|
|
101
107
|
*/
|
|
@@ -105,26 +111,10 @@ interface BooleanCommandOption extends BooleanCommandParameter {
|
|
|
105
111
|
*/
|
|
106
112
|
skipAddingNegative?: boolean;
|
|
107
113
|
}
|
|
108
|
-
type CommandOption =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*/
|
|
113
|
-
reflection: ReflectionParameter;
|
|
114
|
-
}
|
|
115
|
-
interface NumberCommandArgument extends NumberCommandParameter {
|
|
116
|
-
/**
|
|
117
|
-
* The parameter reflection.
|
|
118
|
-
*/
|
|
119
|
-
reflection: ReflectionParameter;
|
|
120
|
-
}
|
|
121
|
-
interface BooleanCommandArgument extends BooleanCommandParameter {
|
|
122
|
-
/**
|
|
123
|
-
* The parameter reflection.
|
|
124
|
-
*/
|
|
125
|
-
reflection: ReflectionParameter;
|
|
126
|
-
}
|
|
127
|
-
type CommandArgument = StringCommandArgument | NumberCommandArgument | BooleanCommandArgument;
|
|
114
|
+
type CommandOption = StringCommandParameter | NumberCommandParameter | BooleanCommandOption;
|
|
115
|
+
type CommandOptionConfig = AsCommandParameterConfig<CommandOption>;
|
|
116
|
+
type CommandArgument = StringCommandParameter | NumberCommandParameter | BooleanCommandParameter;
|
|
117
|
+
type CommandArgumentConfig = AsCommandParameterConfig<CommandArgument>;
|
|
128
118
|
interface CommandBase {
|
|
129
119
|
/**
|
|
130
120
|
* The command id.
|
|
@@ -166,7 +156,7 @@ interface CommandBase {
|
|
|
166
156
|
*/
|
|
167
157
|
isVirtual: boolean;
|
|
168
158
|
}
|
|
169
|
-
interface
|
|
159
|
+
interface CommandConfig extends CommandBase {
|
|
170
160
|
/**
|
|
171
161
|
* The command id.
|
|
172
162
|
*/
|
|
@@ -176,7 +166,7 @@ interface CommandInput extends CommandBase {
|
|
|
176
166
|
*/
|
|
177
167
|
entry: ResolvedEntryTypeDefinition;
|
|
178
168
|
}
|
|
179
|
-
type CommandTree =
|
|
169
|
+
type CommandTree = CommandConfig & {
|
|
180
170
|
/**
|
|
181
171
|
* The display title.
|
|
182
172
|
*/
|
|
@@ -196,7 +186,7 @@ type CommandTree = CommandInput & {
|
|
|
196
186
|
/**
|
|
197
187
|
* The positional arguments provided to the command.
|
|
198
188
|
*/
|
|
199
|
-
|
|
189
|
+
args: CommandArgument[];
|
|
200
190
|
/**
|
|
201
191
|
* The parent command.
|
|
202
192
|
*/
|
|
@@ -205,22 +195,8 @@ type CommandTree = CommandInput & {
|
|
|
205
195
|
* Child commands.
|
|
206
196
|
*/
|
|
207
197
|
children: Record<string, CommandTree>;
|
|
208
|
-
/**
|
|
209
|
-
* The command handler reflection.
|
|
210
|
-
*/
|
|
211
|
-
reflection: ReflectionFunction | null;
|
|
212
198
|
};
|
|
213
|
-
type
|
|
214
|
-
type SerializedCommandArgument = Omit<CommandArgument, "reflection">;
|
|
215
|
-
type SerializedCommandTree = Omit<CommandTree, "options" | "arguments" | "parent" | "children" | "reflection"> & {
|
|
216
|
-
/**
|
|
217
|
-
* The command options.
|
|
218
|
-
*/
|
|
219
|
-
options: Record<string, SerializedCommandOption>;
|
|
220
|
-
/**
|
|
221
|
-
* The positional arguments provided to the command.
|
|
222
|
-
*/
|
|
223
|
-
arguments: SerializedCommandArgument[];
|
|
199
|
+
type SerializedCommandTree = Omit<CommandTree, "parent" | "children"> & {
|
|
224
200
|
/**
|
|
225
201
|
* The parent command id.
|
|
226
202
|
*/
|
|
@@ -229,12 +205,8 @@ type SerializedCommandTree = Omit<CommandTree, "options" | "arguments" | "parent
|
|
|
229
205
|
* Serialized child commands.
|
|
230
206
|
*/
|
|
231
207
|
children: Record<string, SerializedCommandTree>;
|
|
232
|
-
/**
|
|
233
|
-
* The command handler reflection.
|
|
234
|
-
*/
|
|
235
|
-
reflection?: SerializedTypes;
|
|
236
208
|
};
|
|
237
|
-
interface
|
|
209
|
+
interface CommandMetadata {
|
|
238
210
|
/**
|
|
239
211
|
* The display name of the command.
|
|
240
212
|
*
|
|
@@ -262,9 +234,11 @@ interface Metadata {
|
|
|
262
234
|
icon?: string;
|
|
263
235
|
}
|
|
264
236
|
interface CommandModule {
|
|
265
|
-
metadata?:
|
|
237
|
+
metadata?: CommandMetadata;
|
|
238
|
+
options?: Record<string, CommandOptionConfig> | JSONSchema7Object | StandardJSONSchemaV1<Record<string, CommandParameterType>> | z3.AnyZodObject;
|
|
239
|
+
args?: CommandArgumentConfig[] | JsonSchema7TupleType | StandardJSONSchemaV1<CommandParameterType[]> | z3.AnyZodTuple;
|
|
266
240
|
default?: AnyFunction;
|
|
267
241
|
}
|
|
268
242
|
//#endregion
|
|
269
|
-
export {
|
|
243
|
+
export { AsCommandParameterConfig, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, StringCommandParameter, StringCommandParameterConfig };
|
|
270
244
|
//# sourceMappingURL=command.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.cts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.cts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAyBY,oBAAA;cAMC;EAND,SAAA,MAAA,EAAA,QAAoB;EAMnB,SAAA,MAAA,EAAA,QAIH;EAEE,SAAA,OAAA,EAAA,SAAoB;AAGhC,CAAA;AA+BiB,KAlCL,oBAAA,GAkC4B,CAAA,OAjC9B,qBAiC0D,CAAA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R,yBACA,yBACA;KACQ,qBAAA,GAAwB,yBAAyB;UAE5C,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkDA,aAAA,SAAsB;;;;;;;;SAS9B;;KAGG,WAAA,GAAc;;;;;;;;;;;;;;;;WAgBf,eAAe;;;;QAIlB;;;;iBAIS;;;;YAIL,eAAe;;KAGf,qBAAA,GAAwB,KAAK;;;;;;;;YAQ7B,eAAe;;UAGV,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BA,aAAA;aACJ;YAEP,eAAe,uBACf,oBACA,qBAAqB,eAAe,yBACpC,EAAA,CAAG;SAEH,0BACA,uBACA,qBAAqB,0BACrB,EAAA,CAAG;YACG"}
|
package/dist/types/command.d.mts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
2
|
+
import { JsonSchema7TupleType } from "@stryke/json";
|
|
3
|
+
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
2
4
|
import { AnyFunction } from "@stryke/types/base";
|
|
3
|
-
import {
|
|
5
|
+
import { JSONSchema7Object } from "json-schema";
|
|
6
|
+
import * as z3 from "zod/v3";
|
|
4
7
|
|
|
5
8
|
//#region src/types/command.d.ts
|
|
9
|
+
type CommandParameterType = string | number | boolean | (string | number)[];
|
|
10
|
+
declare const CommandParameterKinds: {
|
|
11
|
+
readonly string: "string";
|
|
12
|
+
readonly number: "number";
|
|
13
|
+
readonly boolean: "boolean";
|
|
14
|
+
};
|
|
15
|
+
type CommandParameterKind = (typeof CommandParameterKinds)[keyof typeof CommandParameterKinds];
|
|
6
16
|
interface BaseCommandParameter {
|
|
7
17
|
/**
|
|
8
18
|
* The option name.
|
|
@@ -11,7 +21,7 @@ interface BaseCommandParameter {
|
|
|
11
21
|
/**
|
|
12
22
|
* The option kind.
|
|
13
23
|
*/
|
|
14
|
-
kind:
|
|
24
|
+
kind: CommandParameterKind;
|
|
15
25
|
/**
|
|
16
26
|
* The display title.
|
|
17
27
|
*/
|
|
@@ -37,21 +47,29 @@ interface StringCommandParameter extends BaseCommandParameter {
|
|
|
37
47
|
/**
|
|
38
48
|
* The option kind.
|
|
39
49
|
*/
|
|
40
|
-
kind:
|
|
50
|
+
kind: "string";
|
|
41
51
|
/**
|
|
42
52
|
* The default value.
|
|
43
53
|
*/
|
|
44
54
|
default?: string;
|
|
55
|
+
/**
|
|
56
|
+
* A standard string format to validate the option value against.
|
|
57
|
+
*/
|
|
58
|
+
format?: "email" | "uri" | "uuid" | "ipv4" | "ipv6" | "date" | "time" | "date-time" | "duration";
|
|
45
59
|
/**
|
|
46
60
|
* Whether the option accepts multiple values.
|
|
47
61
|
*/
|
|
48
62
|
variadic: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The allowed choices for the option value.
|
|
65
|
+
*/
|
|
66
|
+
choices?: string[];
|
|
49
67
|
}
|
|
50
68
|
interface NumberCommandParameter extends BaseCommandParameter {
|
|
51
69
|
/**
|
|
52
70
|
* The option kind.
|
|
53
71
|
*/
|
|
54
|
-
kind:
|
|
72
|
+
kind: "number";
|
|
55
73
|
/**
|
|
56
74
|
* The default value.
|
|
57
75
|
*/
|
|
@@ -60,42 +78,30 @@ interface NumberCommandParameter extends BaseCommandParameter {
|
|
|
60
78
|
* Whether the option accepts multiple values.
|
|
61
79
|
*/
|
|
62
80
|
variadic: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The allowed choices for the option value.
|
|
83
|
+
*/
|
|
84
|
+
choices?: number[];
|
|
63
85
|
}
|
|
64
86
|
interface BooleanCommandParameter extends BaseCommandParameter {
|
|
65
87
|
/**
|
|
66
88
|
* The option kind.
|
|
67
89
|
*/
|
|
68
|
-
kind:
|
|
90
|
+
kind: "boolean";
|
|
69
91
|
/**
|
|
70
92
|
* The default value.
|
|
71
93
|
*/
|
|
72
94
|
default?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The option this negates.
|
|
75
|
-
*/
|
|
76
|
-
isNegativeOf?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Whether to skip adding a negative option.
|
|
79
|
-
*/
|
|
80
|
-
skipAddingNegative?: boolean;
|
|
81
|
-
}
|
|
82
|
-
interface StringCommandOption extends StringCommandParameter {
|
|
83
|
-
/**
|
|
84
|
-
* The property reflection.
|
|
85
|
-
*/
|
|
86
|
-
reflection?: ReflectionProperty;
|
|
87
|
-
}
|
|
88
|
-
interface NumberCommandOption extends NumberCommandParameter {
|
|
89
|
-
/**
|
|
90
|
-
* The property reflection.
|
|
91
|
-
*/
|
|
92
|
-
reflection?: ReflectionProperty;
|
|
93
95
|
}
|
|
96
|
+
type CommandParameter = StringCommandParameter | NumberCommandParameter | BooleanCommandParameter;
|
|
97
|
+
type AsCommandParameterConfig<T extends BaseCommandParameter> = Pick<T, "kind" | "alias"> & Partial<Omit<T, "kind" | "alias">> & {
|
|
98
|
+
alias?: string | string[];
|
|
99
|
+
};
|
|
100
|
+
type StringCommandParameterConfig = AsCommandParameterConfig<StringCommandParameter>;
|
|
101
|
+
type NumberCommandParameterConfig = AsCommandParameterConfig<NumberCommandParameter>;
|
|
102
|
+
type BooleanCommandParameterConfig = AsCommandParameterConfig<BooleanCommandParameter>;
|
|
103
|
+
type CommandParameterConfig = StringCommandParameterConfig | NumberCommandParameterConfig | BooleanCommandParameterConfig;
|
|
94
104
|
interface BooleanCommandOption extends BooleanCommandParameter {
|
|
95
|
-
/**
|
|
96
|
-
* The property reflection.
|
|
97
|
-
*/
|
|
98
|
-
reflection?: ReflectionProperty;
|
|
99
105
|
/**
|
|
100
106
|
* The option this negates.
|
|
101
107
|
*/
|
|
@@ -105,26 +111,10 @@ interface BooleanCommandOption extends BooleanCommandParameter {
|
|
|
105
111
|
*/
|
|
106
112
|
skipAddingNegative?: boolean;
|
|
107
113
|
}
|
|
108
|
-
type CommandOption =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*/
|
|
113
|
-
reflection: ReflectionParameter;
|
|
114
|
-
}
|
|
115
|
-
interface NumberCommandArgument extends NumberCommandParameter {
|
|
116
|
-
/**
|
|
117
|
-
* The parameter reflection.
|
|
118
|
-
*/
|
|
119
|
-
reflection: ReflectionParameter;
|
|
120
|
-
}
|
|
121
|
-
interface BooleanCommandArgument extends BooleanCommandParameter {
|
|
122
|
-
/**
|
|
123
|
-
* The parameter reflection.
|
|
124
|
-
*/
|
|
125
|
-
reflection: ReflectionParameter;
|
|
126
|
-
}
|
|
127
|
-
type CommandArgument = StringCommandArgument | NumberCommandArgument | BooleanCommandArgument;
|
|
114
|
+
type CommandOption = StringCommandParameter | NumberCommandParameter | BooleanCommandOption;
|
|
115
|
+
type CommandOptionConfig = AsCommandParameterConfig<CommandOption>;
|
|
116
|
+
type CommandArgument = StringCommandParameter | NumberCommandParameter | BooleanCommandParameter;
|
|
117
|
+
type CommandArgumentConfig = AsCommandParameterConfig<CommandArgument>;
|
|
128
118
|
interface CommandBase {
|
|
129
119
|
/**
|
|
130
120
|
* The command id.
|
|
@@ -166,7 +156,7 @@ interface CommandBase {
|
|
|
166
156
|
*/
|
|
167
157
|
isVirtual: boolean;
|
|
168
158
|
}
|
|
169
|
-
interface
|
|
159
|
+
interface CommandConfig extends CommandBase {
|
|
170
160
|
/**
|
|
171
161
|
* The command id.
|
|
172
162
|
*/
|
|
@@ -176,7 +166,7 @@ interface CommandInput extends CommandBase {
|
|
|
176
166
|
*/
|
|
177
167
|
entry: ResolvedEntryTypeDefinition;
|
|
178
168
|
}
|
|
179
|
-
type CommandTree =
|
|
169
|
+
type CommandTree = CommandConfig & {
|
|
180
170
|
/**
|
|
181
171
|
* The display title.
|
|
182
172
|
*/
|
|
@@ -196,7 +186,7 @@ type CommandTree = CommandInput & {
|
|
|
196
186
|
/**
|
|
197
187
|
* The positional arguments provided to the command.
|
|
198
188
|
*/
|
|
199
|
-
|
|
189
|
+
args: CommandArgument[];
|
|
200
190
|
/**
|
|
201
191
|
* The parent command.
|
|
202
192
|
*/
|
|
@@ -205,22 +195,8 @@ type CommandTree = CommandInput & {
|
|
|
205
195
|
* Child commands.
|
|
206
196
|
*/
|
|
207
197
|
children: Record<string, CommandTree>;
|
|
208
|
-
/**
|
|
209
|
-
* The command handler reflection.
|
|
210
|
-
*/
|
|
211
|
-
reflection: ReflectionFunction | null;
|
|
212
198
|
};
|
|
213
|
-
type
|
|
214
|
-
type SerializedCommandArgument = Omit<CommandArgument, "reflection">;
|
|
215
|
-
type SerializedCommandTree = Omit<CommandTree, "options" | "arguments" | "parent" | "children" | "reflection"> & {
|
|
216
|
-
/**
|
|
217
|
-
* The command options.
|
|
218
|
-
*/
|
|
219
|
-
options: Record<string, SerializedCommandOption>;
|
|
220
|
-
/**
|
|
221
|
-
* The positional arguments provided to the command.
|
|
222
|
-
*/
|
|
223
|
-
arguments: SerializedCommandArgument[];
|
|
199
|
+
type SerializedCommandTree = Omit<CommandTree, "parent" | "children"> & {
|
|
224
200
|
/**
|
|
225
201
|
* The parent command id.
|
|
226
202
|
*/
|
|
@@ -229,12 +205,8 @@ type SerializedCommandTree = Omit<CommandTree, "options" | "arguments" | "parent
|
|
|
229
205
|
* Serialized child commands.
|
|
230
206
|
*/
|
|
231
207
|
children: Record<string, SerializedCommandTree>;
|
|
232
|
-
/**
|
|
233
|
-
* The command handler reflection.
|
|
234
|
-
*/
|
|
235
|
-
reflection?: SerializedTypes;
|
|
236
208
|
};
|
|
237
|
-
interface
|
|
209
|
+
interface CommandMetadata {
|
|
238
210
|
/**
|
|
239
211
|
* The display name of the command.
|
|
240
212
|
*
|
|
@@ -262,9 +234,11 @@ interface Metadata {
|
|
|
262
234
|
icon?: string;
|
|
263
235
|
}
|
|
264
236
|
interface CommandModule {
|
|
265
|
-
metadata?:
|
|
237
|
+
metadata?: CommandMetadata;
|
|
238
|
+
options?: Record<string, CommandOptionConfig> | JSONSchema7Object | StandardJSONSchemaV1<Record<string, CommandParameterType>> | z3.AnyZodObject;
|
|
239
|
+
args?: CommandArgumentConfig[] | JsonSchema7TupleType | StandardJSONSchemaV1<CommandParameterType[]> | z3.AnyZodTuple;
|
|
266
240
|
default?: AnyFunction;
|
|
267
241
|
}
|
|
268
242
|
//#endregion
|
|
269
|
-
export {
|
|
243
|
+
export { AsCommandParameterConfig, BaseCommandParameter, BooleanCommandOption, BooleanCommandParameter, BooleanCommandParameterConfig, CommandArgument, CommandArgumentConfig, CommandBase, CommandConfig, CommandMetadata, CommandModule, CommandOption, CommandOptionConfig, CommandParameter, CommandParameterConfig, CommandParameterKind, CommandParameterKinds, CommandParameterType, CommandTree, NumberCommandParameter, NumberCommandParameterConfig, SerializedCommandTree, StringCommandParameter, StringCommandParameterConfig };
|
|
270
244
|
//# sourceMappingURL=command.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.mts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.mts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAyBY,oBAAA;cAMC;EAND,SAAA,MAAA,EAAA,QAAoB;EAMnB,SAAA,MAAA,EAAA,QAIH;EAEE,SAAA,OAAA,EAAA,SAAoB;AAGhC,CAAA;AA+BiB,KAlCL,oBAAA,GAkC4B,CAAA,OAjC9B,qBAiC0D,CAAA,CAAA,MAAA,OAjCtB,qBAiCsB,CAAA;AAiCnD,UAhEA,oBAAA,CAgEuB;EAoBvB;AAWjB;;EAEI,IAAA,EAAA,MAAA;EACA;;AAEJ;EAA+C,IAAA,EA5FvC,oBA4FuC;EAC7C;;;EAGQ,KAAA,EAAA,MAAA;EAAR;;AAIF;EAEY,WAAA,EAAA,MAAA;EAEA;AAGZ;;EAEI,KAAA,EAAA,MAAA,EAAA;EACA;;AAEJ;EAWY,GAAA,EAAA,MAAA,GAAA,KAAa;EACrB;;;EAEoB,QAAA,EAAA,OAAA;AACxB;AAEY,UA1GK,sBAAA,SAA+B,oBA0GrB,C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