@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.
Files changed (159) hide show
  1. package/dist/api.cjs +1 -2
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +1 -1
  4. package/dist/api.d.mts +1 -1
  5. package/dist/api.mjs +1 -2
  6. package/dist/api.mjs.map +1 -1
  7. package/dist/components/docs.cjs +4 -4
  8. package/dist/components/docs.cjs.map +1 -1
  9. package/dist/components/docs.d.cts +5 -5
  10. package/dist/components/docs.d.mts +5 -5
  11. package/dist/components/helpers.d.cts +6 -6
  12. package/dist/components/helpers.d.mts +6 -6
  13. package/dist/components/helpers.d.mts.map +1 -1
  14. package/dist/components/index.cjs +1 -0
  15. package/dist/components/index.d.cts +2 -2
  16. package/dist/components/index.d.mts +2 -2
  17. package/dist/components/index.mjs +2 -2
  18. package/dist/components/options-parser-logic.cjs +31 -31
  19. package/dist/components/options-parser-logic.cjs.map +1 -1
  20. package/dist/components/options-parser-logic.d.cts +9 -9
  21. package/dist/components/options-parser-logic.d.cts.map +1 -1
  22. package/dist/components/options-parser-logic.d.mts +9 -9
  23. package/dist/components/options-parser-logic.d.mts.map +1 -1
  24. package/dist/components/options-parser-logic.mjs +26 -26
  25. package/dist/components/options-parser-logic.mjs.map +1 -1
  26. package/dist/components/usage.cjs +5 -5
  27. package/dist/components/usage.cjs.map +1 -1
  28. package/dist/components/usage.d.cts +2 -2
  29. package/dist/components/usage.d.cts.map +1 -1
  30. package/dist/components/usage.mjs +4 -4
  31. package/dist/components/usage.mjs.map +1 -1
  32. package/dist/components/utils-builtin.cjs +204 -0
  33. package/dist/components/utils-builtin.cjs.map +1 -1
  34. package/dist/components/utils-builtin.d.cts +13 -9
  35. package/dist/components/utils-builtin.d.cts.map +1 -1
  36. package/dist/components/utils-builtin.d.mts +13 -9
  37. package/dist/components/utils-builtin.d.mts.map +1 -1
  38. package/dist/components/utils-builtin.mjs +208 -5
  39. package/dist/components/utils-builtin.mjs.map +1 -1
  40. package/dist/contexts/options.cjs +2 -2
  41. package/dist/contexts/options.cjs.map +1 -1
  42. package/dist/contexts/options.d.cts +1 -1
  43. package/dist/contexts/options.d.cts.map +1 -1
  44. package/dist/contexts/options.d.mts +1 -1
  45. package/dist/contexts/options.d.mts.map +1 -1
  46. package/dist/contexts/options.mjs +4 -4
  47. package/dist/contexts/options.mjs.map +1 -1
  48. package/dist/helpers/automd.cjs +2 -2
  49. package/dist/helpers/automd.cjs.map +1 -1
  50. package/dist/helpers/automd.mjs.map +1 -1
  51. package/dist/helpers/docs-helpers.cjs +1 -1
  52. package/dist/helpers/docs-helpers.cjs.map +1 -1
  53. package/dist/helpers/docs-helpers.mjs +1 -1
  54. package/dist/helpers/docs-helpers.mjs.map +1 -1
  55. package/dist/helpers/paths.cjs +125 -0
  56. package/dist/helpers/paths.cjs.map +1 -0
  57. package/dist/helpers/paths.mjs +121 -0
  58. package/dist/helpers/paths.mjs.map +1 -0
  59. package/dist/helpers/persistence.cjs +68 -116
  60. package/dist/helpers/persistence.cjs.map +1 -1
  61. package/dist/helpers/persistence.mjs +68 -116
  62. package/dist/helpers/persistence.mjs.map +1 -1
  63. package/dist/helpers/update-package-json.cjs +5 -5
  64. package/dist/helpers/update-package-json.cjs.map +1 -1
  65. package/dist/helpers/update-package-json.mjs +1 -1
  66. package/dist/helpers/update-package-json.mjs.map +1 -1
  67. package/dist/helpers/utilities.cjs +1 -1
  68. package/dist/helpers/utilities.mjs +1 -1
  69. package/dist/helpers/validations.cjs +2 -3
  70. package/dist/helpers/validations.cjs.map +1 -1
  71. package/dist/helpers/validations.mjs +2 -2
  72. package/dist/helpers/validations.mjs.map +1 -1
  73. package/dist/index.cjs +14 -15
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +2 -4
  76. package/dist/index.d.mts +2 -4
  77. package/dist/index.mjs +3 -5
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/plugin-utils/deepkit.cjs +72 -0
  80. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  81. package/dist/plugin-utils/deepkit.d.cts +24 -0
  82. package/dist/plugin-utils/deepkit.d.cts.map +1 -0
  83. package/dist/plugin-utils/deepkit.d.mts +24 -0
  84. package/dist/plugin-utils/deepkit.d.mts.map +1 -0
  85. package/dist/plugin-utils/deepkit.mjs +70 -0
  86. package/dist/plugin-utils/deepkit.mjs.map +1 -0
  87. package/dist/plugin-utils/get-command-tree.cjs +2 -2
  88. package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
  89. package/dist/plugin-utils/index.cjs +27 -18
  90. package/dist/plugin-utils/index.d.cts +3 -1
  91. package/dist/plugin-utils/index.d.mts +3 -1
  92. package/dist/plugin-utils/index.mjs +3 -1
  93. package/dist/plugin-utils/reflect.cjs +4 -5
  94. package/dist/plugin-utils/reflect.cjs.map +1 -1
  95. package/dist/plugin-utils/reflect.mjs +4 -4
  96. package/dist/plugin-utils/reflect.mjs.map +1 -1
  97. package/dist/plugin-utils/type-checks.cjs +89 -0
  98. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  99. package/dist/plugin-utils/type-checks.d.cts +42 -0
  100. package/dist/plugin-utils/type-checks.d.cts.map +1 -0
  101. package/dist/plugin-utils/type-checks.d.mts +42 -0
  102. package/dist/plugin-utils/type-checks.d.mts.map +1 -0
  103. package/dist/plugin-utils/type-checks.mjs +84 -0
  104. package/dist/plugin-utils/type-checks.mjs.map +1 -0
  105. package/dist/plugin.cjs +48 -45
  106. package/dist/plugin.cjs.map +1 -1
  107. package/dist/plugin.d.cts.map +1 -1
  108. package/dist/plugin.d.mts.map +1 -1
  109. package/dist/plugin.mjs +30 -26
  110. package/dist/plugin.mjs.map +1 -1
  111. package/dist/resolver/deepkit.cjs +129 -0
  112. package/dist/resolver/deepkit.cjs.map +1 -0
  113. package/dist/resolver/deepkit.mjs +128 -0
  114. package/dist/resolver/deepkit.mjs.map +1 -0
  115. package/dist/resolver/helpers.cjs +173 -0
  116. package/dist/resolver/helpers.cjs.map +1 -0
  117. package/dist/resolver/helpers.mjs +168 -0
  118. package/dist/resolver/helpers.mjs.map +1 -0
  119. package/dist/resolver/module.cjs +144 -0
  120. package/dist/resolver/module.cjs.map +1 -0
  121. package/dist/resolver/module.mjs +143 -0
  122. package/dist/resolver/module.mjs.map +1 -0
  123. package/dist/resolver/resolve.cjs +209 -0
  124. package/dist/resolver/resolve.cjs.map +1 -0
  125. package/dist/resolver/resolve.mjs +208 -0
  126. package/dist/resolver/resolve.mjs.map +1 -0
  127. package/dist/types/command.cjs +131 -99
  128. package/dist/types/command.cjs.map +1 -1
  129. package/dist/types/command.d.cts +49 -75
  130. package/dist/types/command.d.cts.map +1 -1
  131. package/dist/types/command.d.mts +49 -75
  132. package/dist/types/command.d.mts.map +1 -1
  133. package/dist/types/command.mjs +119 -91
  134. package/dist/types/command.mjs.map +1 -1
  135. package/dist/types/config.cjs +1 -2
  136. package/dist/types/config.cjs.map +1 -1
  137. package/dist/types/config.d.cts +2 -2
  138. package/dist/types/config.d.cts.map +1 -1
  139. package/dist/types/config.d.mts +2 -2
  140. package/dist/types/config.d.mts.map +1 -1
  141. package/dist/types/config.mjs +1 -2
  142. package/dist/types/config.mjs.map +1 -1
  143. package/dist/types/context.cjs +1 -1
  144. package/dist/types/context.cjs.map +1 -1
  145. package/dist/types/context.d.cts +3 -3
  146. package/dist/types/context.d.cts.map +1 -1
  147. package/dist/types/context.d.mts +3 -3
  148. package/dist/types/context.d.mts.map +1 -1
  149. package/dist/types/context.mjs +1 -1
  150. package/dist/types/context.mjs.map +1 -1
  151. package/dist/types/index.cjs +13 -9
  152. package/dist/types/index.d.cts +2 -2
  153. package/dist/types/index.d.mts +2 -2
  154. package/dist/types/index.mjs +2 -2
  155. package/package.json +34 -79
  156. package/dist/helpers/resolve-command.cjs +0 -410
  157. package/dist/helpers/resolve-command.cjs.map +0 -1
  158. package/dist/helpers/resolve-command.mjs +0 -405
  159. package/dist/helpers/resolve-command.mjs.map +0 -1
@@ -1,8 +1,18 @@
1
- import { ReflectionFunction, ReflectionKind, ReflectionParameter, ReflectionProperty, SerializedTypes } from "@powerlines/deepkit/vendor/type";
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 { ResolvedEntryTypeDefinition } from "powerlines/types/resolved";
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: ReflectionKind;
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: ReflectionKind.string;
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: ReflectionKind.number;
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: ReflectionKind.boolean;
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 = StringCommandOption | NumberCommandOption | BooleanCommandOption;
109
- interface StringCommandArgument extends StringCommandParameter {
110
- /**
111
- * The parameter reflection.
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 CommandInput extends CommandBase {
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 = CommandInput & {
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
- arguments: CommandArgument[];
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 SerializedCommandOption = Omit<CommandOption, "reflection">;
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 Metadata {
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?: 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 { BaseCommandParameter, BooleanCommandArgument, BooleanCommandOption, BooleanCommandParameter, CommandArgument, CommandBase, CommandInput, CommandModule, CommandOption, CommandTree, Metadata, NumberCommandArgument, NumberCommandOption, NumberCommandParameter, SerializedCommandArgument, SerializedCommandOption, SerializedCommandTree, StringCommandArgument, StringCommandOption, StringCommandParameter };
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":";;;;;UA4BiB,oBAAA;;AAAjB;AA+BA;EAeiB,IAAA,EAAA,MAAA;EAeA;AAmBjB;AAOA;EAOiB,IAAA,EAtFT,cAsFS;EAeL;;;EAGR,KAAA,EAAA,MAAA;EAAoB;AAExB;AAOA;EAOiB,WAAA,EAAA,MAAA;EAOL;;;EAGR,KAAA,EAAA,MAAA,EAAA;EAAsB;AAE1B;AAkDA;EAYY,GAAA,EAAA,MAAA,GAAW,KAAA;EAAG;;;EAoBb,QAAA,EAAA,OAAA;;AAQc,UAvMV,sBAAA,SAA+B,oBAuMrB,CAAA;EAAf;;;EAOA,IAAA,EA1MJ,cAAA,CAAe,MA0MY;EAEvB;AAEZ;;EAAoC,OAAA,CAAA,EAAA,MAAA;EAOV;;;EAYC,QAAA,EAAA,OAAA;;AAIZ,UA1NE,sBAAA,SAA+B,oBA0NjC,CAAA;EAAe;AAG9B;AA+BA;QAxPQ,cAAA,CAAe;;;;;;;;;;UAWN,uBAAA,SAAgC;;;;QAIzC,cAAA,CAAe;;;;;;;;;;;;;;UAeN,mBAAA,SAA4B;;;;eAI9B;;UAGE,mBAAA,SAA4B;;;;eAI9B;;UAGE,oBAAA,SAA6B;;;;eAI/B;;;;;;;;;;KAWH,aAAA,GACR,sBACA,sBACA;UAEa,qBAAA,SAA8B;;;;cAIjC;;UAGG,qBAAA,SAA8B;;;;cAIjC;;UAGG,sBAAA,SAA+B;;;;cAIlC;;KAGF,eAAA,GACR,wBACA,wBACA;UAEa,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkDA,YAAA,SAAqB;;;;;;;;SAS7B;;KAGG,WAAA,GAAc;;;;;;;;;;;;;;;;WAgBf,eAAe;;;;aAI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,SAA+B,oBAoL9B,CAAA;EAGD;AA+BjB;;EAGqB,IAAA,EAAA,QAAA;EAAf;;;EAEqB,OAAA,CAAA,EAAA,MAAA;EAArB;;;EAIA,QAAA,EAAA,OAAA;EACqB;;;EAEf,OAAA,CAAA,EAAA,MAAA,EAAA;;UA9MK,uBAAA,SAAgC;;;;;;;;;;KAWrC,gBAAA,GACR,yBACA,yBACA;KAEQ,mCAAmC,wBAAwB,KACrE,uBAGA,QAAQ,KAAK;;;KAIH,4BAAA,GACV,yBAAyB;KACf,4BAAA,GACV,yBAAyB;KACf,6BAAA,GACV,yBAAyB;KAEf,sBAAA,GACR,+BACA,+BACA;UAEa,oBAAA,SAA6B;;;;;;;;;;KAWlC,aAAA,GACR,yBACA,yBACA;KACQ,mBAAA,GAAsB,yBAAyB;KAE/C,eAAA,GACR,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"}
@@ -1,8 +1,18 @@
1
- import { ReflectionFunction, ReflectionKind, ReflectionParameter, ReflectionProperty, SerializedTypes } from "@powerlines/deepkit/vendor/type";
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 { ResolvedEntryTypeDefinition } from "powerlines/types/resolved";
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: ReflectionKind;
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: ReflectionKind.string;
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: ReflectionKind.number;
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: ReflectionKind.boolean;
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 = StringCommandOption | NumberCommandOption | BooleanCommandOption;
109
- interface StringCommandArgument extends StringCommandParameter {
110
- /**
111
- * The parameter reflection.
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 CommandInput extends CommandBase {
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 = CommandInput & {
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
- arguments: CommandArgument[];
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 SerializedCommandOption = Omit<CommandOption, "reflection">;
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 Metadata {
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?: 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 { BaseCommandParameter, BooleanCommandArgument, BooleanCommandOption, BooleanCommandParameter, CommandArgument, CommandBase, CommandInput, CommandModule, CommandOption, CommandTree, Metadata, NumberCommandArgument, NumberCommandOption, NumberCommandParameter, SerializedCommandArgument, SerializedCommandOption, SerializedCommandTree, StringCommandArgument, StringCommandOption, StringCommandParameter };
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":";;;;;UA4BiB,oBAAA;;AAAjB;AA+BA;EAeiB,IAAA,EAAA,MAAA;EAeA;AAmBjB;AAOA;EAOiB,IAAA,EAtFT,cAsFS;EAe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