@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
@@ -0,0 +1,208 @@
1
+ import { getDynamicPathSegmentName, isDynamicPathSegment } from "../plugin-utils/context-helpers.mjs";
2
+ import { extractType } from "../plugin-utils/deepkit.mjs";
3
+ import { getDefaultOptions } from "../helpers/utilities.mjs";
4
+ import { applyArgsDefaults, applyDefaults, applyOptionsDefaults, resolveVirtualCommand } from "./helpers.mjs";
5
+ import { resolveFromBytecode } from "./deepkit.mjs";
6
+ import { resolveFromExports } from "./module.mjs";
7
+ import { constantCase } from "@stryke/string-format/constant-case";
8
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
9
+ import { titleCase } from "@stryke/string-format/title-case";
10
+ import { ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
11
+ import { esbuildPlugin } from "@powerlines/deepkit/esbuild-plugin";
12
+ import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
13
+
14
+ //#region src/resolver/resolve.ts
15
+ function __assignType(fn, args) {
16
+ fn.__type = args;
17
+ return fn;
18
+ }
19
+ async function initialize(input) {
20
+ const { context, command, parent } = input;
21
+ const title = command.title || `${parent?.title ? `${parent.isVirtual ? parent.title.replace(/(?:c|C)ommands?$/, "").trim() : parent.title} - ` : ""}${titleCase(command.name)}${command.isVirtual ? " Commands" : ""}`;
22
+ const result = {
23
+ input,
24
+ output: {
25
+ alias: [],
26
+ icon: parent?.icon,
27
+ ...command,
28
+ title,
29
+ options: getDefaultOptions(context, command),
30
+ args: [],
31
+ parent: parent ?? null,
32
+ children: {}
33
+ }
34
+ };
35
+ if (!command.isVirtual) {
36
+ if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
37
+ context.debug(`Adding reflection for user-defined command: ${command.id} (file: ${command.entry.input.file})`);
38
+ result.module = await (resolveModule.Ω = [["CommandModule", "\"w!"]], resolveModule(context, command.entry.input, { plugins: [esbuildPlugin(context, {
39
+ reflection: "default",
40
+ reflectionLevel: "verbose"
41
+ })] }));
42
+ }
43
+ return result;
44
+ }
45
+ initialize.__type = [
46
+ "ResolverInput",
47
+ "input",
48
+ "ResolverContext",
49
+ "initialize",
50
+ "P\"w!2\"\"w#`/$"
51
+ ];
52
+ async function postprocess(ctx) {
53
+ ctx.output.options = applyOptionsDefaults(ctx.output.options);
54
+ ctx.output.args = applyArgsDefaults(ctx.output.args);
55
+ ctx.output.args.forEach(__assignType((argument, index) => {
56
+ const found = ctx.output.args.findIndex(__assignType((arg) => arg.name === argument.name, [
57
+ "arg",
58
+ "",
59
+ "P\"2!\"/\""
60
+ ]));
61
+ if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment) === argument.name, [
62
+ "segment",
63
+ "",
64
+ "P\"2!\"/\""
65
+ ]))) {
66
+ argument.name += `_${ctx.output.segments.filter(__assignType((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === argument.name, [
67
+ "segment",
68
+ "",
69
+ "P\"2!\"/\""
70
+ ])).length + ctx.output.args.filter(__assignType((arg) => arg.name.replace(/_\d+$/, "") === argument.name, [
71
+ "arg",
72
+ "",
73
+ "P\"2!\"/\""
74
+ ])).length}`;
75
+ argument.env = constantCase(argument.name);
76
+ }
77
+ }, [
78
+ "argument",
79
+ "index",
80
+ "",
81
+ "P\"2!\"2\"\"/#"
82
+ ]));
83
+ applyDefaults(ctx);
84
+ if (ctx.input.context.env) {
85
+ if (isSetObject(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => option.env !== false, [
86
+ "option",
87
+ "",
88
+ "P\"2!\"/\""
89
+ ])).forEach(__assignType((option) => {
90
+ ctx.input.context.env.types.env.addProperty({
91
+ name: option.env,
92
+ optional: option.optional ? true : void 0,
93
+ description: option.description,
94
+ visibility: ReflectionVisibility.public,
95
+ type: extractType(option),
96
+ default: option.default,
97
+ tags: {
98
+ title: option.title,
99
+ alias: option.alias.filter(__assignType((alias) => alias.length > 1, [
100
+ "alias",
101
+ "",
102
+ "P\"2!\"/\""
103
+ ])).map(__assignType((alias) => constantCase(alias), [
104
+ "alias",
105
+ "",
106
+ "P\"2!\"/\""
107
+ ])),
108
+ domain: "cli"
109
+ }
110
+ });
111
+ }, [
112
+ "option",
113
+ "",
114
+ "P\"2!\"/\""
115
+ ]));
116
+ ctx.output.args.filter(__assignType((arg) => arg.env !== false, [
117
+ "arg",
118
+ "",
119
+ "P\"2!\"/\""
120
+ ])).forEach(__assignType((arg) => ctx.input.context.env.types.env.addProperty({
121
+ name: arg.env,
122
+ optional: arg.optional ? true : void 0,
123
+ description: arg.description,
124
+ visibility: ReflectionVisibility.public,
125
+ type: extractType(arg),
126
+ default: arg.default,
127
+ tags: {
128
+ alias: arg.alias.filter(__assignType((alias) => alias.length > 1, [
129
+ "alias",
130
+ "",
131
+ "P\"2!\"/\""
132
+ ])).map(__assignType((alias) => constantCase(alias), [
133
+ "alias",
134
+ "",
135
+ "P\"2!\"/\""
136
+ ])),
137
+ domain: "cli"
138
+ }
139
+ }), [
140
+ "arg",
141
+ "",
142
+ "P\"2!\"/\""
143
+ ]));
144
+ }
145
+ for (const input of ctx.input.context.inputs.filter(__assignType((input$1) => input$1.segments.filter(__assignType((segment) => !isDynamicPathSegment(segment), [
146
+ "segment",
147
+ "",
148
+ "P\"2!\"/\""
149
+ ])).length === ctx.input.command.segments.filter(__assignType((segment) => !isDynamicPathSegment(segment), [
150
+ "segment",
151
+ "",
152
+ "P\"2!\"/\""
153
+ ])).length + 1 && input$1.segments.slice(0, ctx.input.command.segments.length).every(__assignType((value, index) => value === ctx.input.command.segments[index], [
154
+ "value",
155
+ "index",
156
+ "",
157
+ "P\"2!\"2\"\"/#"
158
+ ])), [
159
+ "input",
160
+ "",
161
+ "P\"2!\"/\""
162
+ ]))) ctx.output.children[input.name] = await (resolve.Ω = [[
163
+ () => ctx,
164
+ "ResolverContext",
165
+ "Pi!\"w\"q\"!j"
166
+ ]], resolve({
167
+ context: ctx.input.context,
168
+ command: input,
169
+ parent: ctx.output
170
+ }));
171
+ return ctx.output;
172
+ }
173
+ postprocess.__type = [
174
+ "ResolverContext",
175
+ "ctx",
176
+ "CommandTree",
177
+ "postprocess",
178
+ "P\"w!2\"\"w#`/$"
179
+ ];
180
+ /**
181
+ * Resolves a command tree from the given resolver input.
182
+ *
183
+ * @param input - The resolver input containing the context, command, and optional parent command tree.
184
+ * @returns A promise that resolves to the resolved command tree.
185
+ */
186
+ async function resolve(input) {
187
+ const ctx = await (initialize.Ω = [[
188
+ () => input,
189
+ "ResolverInput",
190
+ "Pi!\"w\"q\"!j"
191
+ ]], initialize(input));
192
+ if (!ctx.output.isVirtual) {
193
+ await resolveFromExports(ctx);
194
+ resolveFromBytecode(ctx);
195
+ } else resolveVirtualCommand(ctx);
196
+ return postprocess(ctx);
197
+ }
198
+ resolve.__type = [
199
+ "ResolverInput",
200
+ "input",
201
+ "CommandTree",
202
+ "resolve",
203
+ "P\"w!2\"\"w#`/$"
204
+ ];
205
+
206
+ //#endregion
207
+ export { resolve };
208
+ //# sourceMappingURL=resolve.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/resolver/resolve.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getDefaultOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx.output.options);\n ctx.output.args = applyArgsDefaults(ctx.output.args);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((argument, index) => {\n const found = ctx.output.args.findIndex(arg => arg.name === argument.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n ctx.output.args.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of ctx.input.context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every((value, index) => value === ctx.input.command.segments[index])\n )) {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n }\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualCommand(ctx);\n }\n\n return postprocess(ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,eAAe,WAAI,OAAA;CACf,MAAM,EAAE,SAAG,SAAA,WAAA;CACX,MAAM,QAAQ,QAAI,SACd,GAAG,QAAQ,QACL,GAAG,OAAC,YACA,OAAO,MAAM,QAAQ,oBAAM,GAAA,CAAA,MAAA,GAC3B,OAAO,MAAK;CAY1B,MAAM,SAAS;EACX;EACA,QAZW;GACX,OAAO,EAAE;GACT,MAAM,QAAQ;GACd,GAAG;;GAEH,SAAM,kBAAA,SAAA,QAAA;GACN,MAAM,EAAE;GACV,QAAA,UAAA;GACE,UAAU,EAAA;GACb;EAIA;AACD,KAAI,CAAC,QAAE,WAAA;AACH,MAAI,CAAC,QAAQ,MAAM,OAAO,yDAEtB,OAAK,IAAA,MAAA,GAAA,CAAA,QAAA,MAAA,OAAA,OAAA,YAAA,eAAA,2BAAA,QAAA,KAAA,GAAA;AAET,UAAQ,MAAM,+CAAA,QAAA,GAAA,UAAA,QAAA,MAAA,MAAA,KAAA,GAAA;AACd,SAAM,SAAA,OAAA,cAAA,IAAA,CAAA,CAAA,iBAAA,OAAA,CAAA,EAAA,cAAA,SAAA,QAAA,MAAA,OAAA,EACL,SAAA,CACO,cAAc,SAAS;GAC3B,YAAA;GACQ,iBAAM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A,IAAA;;;;AAKJ,YAAY,SAAS;CAAC;CAAmB;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOzC,eAAsB,QAAQ,OAAO;CACjC,MAAM,MAAM,OAAO,WAAW,IAAI,CAAC;QAAO;EAAK;EAAA;EAAA,CAAA,EAAA,WAAA,MAAA;AAC/C,KAAI,CAAC,IAAI,OAAO,WAAW;AACvB,QAAM,mBAAmB,IAAE;AAC3B,sBAAU,IAAA;OAGV,uBAAsB,IAAI;AAE9B,QAAO,YAAY,IAAG;;AAE1B,QAAQ,SAAI;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1,10 +1,15 @@
1
1
 
2
2
  //#region src/types/command.ts
3
- const __ΩRecord = [
3
+ const __ΩPick = [
4
+ "T",
4
5
  "K",
6
+ "Pick",
7
+ "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
8
+ ];
9
+ const __ΩPartial = [
5
10
  "T",
6
- "Record",
7
- "l'e#\"Rb!b\"Pde\"!N#!w#y"
11
+ "Partial",
12
+ "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
8
13
  ];
9
14
  const __ΩOmit = [
10
15
  "T",
@@ -14,11 +19,11 @@ const __ΩOmit = [
14
19
  "Omit",
15
20
  "b!b\"e!!e!!ge!\"o$#o##w%y"
16
21
  ];
17
- const __ΩPick = [
18
- "T",
22
+ const __ΩRecord = [
19
23
  "K",
20
- "Pick",
21
- "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
24
+ "T",
25
+ "Record",
26
+ "l'e#\"Rb!b\"Pde\"!N#!w#y"
22
27
  ];
23
28
  const __ΩExclude = [
24
29
  "T",
@@ -26,9 +31,21 @@ const __ΩExclude = [
26
31
  "Exclude",
27
32
  "l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
28
33
  ];
34
+ const __ΩCommandParameterType = ["CommandParameterType", "P&')P&'JFJw!y"];
35
+ const CommandParameterKinds = {
36
+ string: "string",
37
+ number: "number",
38
+ boolean: "boolean"
39
+ };
40
+ const __ΩCommandParameterKind = [
41
+ () => CommandParameterKinds,
42
+ () => CommandParameterKinds,
43
+ "CommandParameterKind",
44
+ "i!i\"gfw#y"
45
+ ];
29
46
  const __ΩBaseCommandParameter = [
30
47
  "name",
31
- "ReflectionKind",
48
+ () => __ΩCommandParameterKind,
32
49
  "kind",
33
50
  "title",
34
51
  "description",
@@ -37,94 +54,124 @@ const __ΩBaseCommandParameter = [
37
54
  "env",
38
55
  "optional",
39
56
  "BaseCommandParameter",
40
- "P&4!\"w\"4#&4$&4%&F4&P&.'J4()4)Mw*y"
57
+ "P&4!n\"4#&4$&4%&F4&P&.'J4()4)Mw*y"
41
58
  ];
42
59
  const __ΩStringCommandParameter = [
43
60
  () => __ΩBaseCommandParameter,
44
- 5,
61
+ "string",
45
62
  "kind",
46
63
  "default",
64
+ "email",
65
+ "uri",
66
+ "uuid",
67
+ "ipv4",
68
+ "ipv6",
69
+ "date",
70
+ "time",
71
+ "date-time",
72
+ "duration",
73
+ "format",
47
74
  "variadic",
75
+ "choices",
48
76
  "StringCommandParameter",
49
- "Pn!a\"4#&4$8)4%Mw&y"
77
+ "Pn!.\"4#&4$8P.%.&.'.(.).*.+.,.-J4.8)4/&F408Mw1y"
50
78
  ];
51
79
  const __ΩNumberCommandParameter = [
52
80
  () => __ΩBaseCommandParameter,
53
- 6,
81
+ "number",
54
82
  "kind",
55
83
  "default",
56
84
  "variadic",
85
+ "choices",
57
86
  "NumberCommandParameter",
58
- "Pn!a\"4#'4$8)4%Mw&y"
87
+ "Pn!.\"4#'4$8)4%'F4&8Mw'y"
59
88
  ];
60
89
  const __ΩBooleanCommandParameter = [
61
90
  () => __ΩBaseCommandParameter,
62
- 7,
91
+ "boolean",
63
92
  "kind",
64
93
  "default",
65
- "isNegativeOf",
66
- "skipAddingNegative",
67
94
  "BooleanCommandParameter",
68
- "Pn!a\"4#)4$8&4%8)4&8Mw'y"
95
+ "Pn!.\"4#)4$8Mw%y"
69
96
  ];
70
- const __ΩStringCommandOption = [
97
+ const __ΩCommandParameter = [
71
98
  () => __ΩStringCommandParameter,
72
- "ReflectionProperty",
73
- "reflection",
74
- "StringCommandOption",
75
- "Pn!\"w\"4#8Mw$y"
99
+ () => __ΩNumberCommandParameter,
100
+ () => __ΩBooleanCommandParameter,
101
+ "CommandParameter",
102
+ "Pn!n\"n#Jw$y"
76
103
  ];
77
- const __ΩNumberCommandOption = [
104
+ const __ΩAsCommandParameterConfig = [
105
+ "T",
106
+ () => __ΩPick,
107
+ "kind",
108
+ "alias",
109
+ () => __ΩPartial,
110
+ () => __ΩOmit,
111
+ "kind",
112
+ "alias",
113
+ "alias",
114
+ "AsCommandParameterConfig",
115
+ "b!Pe\"!P.#.$Jo\"#e\"!P.'.(Jo&#o%\"PP&&FJ4)8MKw*y"
116
+ ];
117
+ const __ΩStringCommandParameterConfig = [
118
+ () => __ΩAsCommandParameterConfig,
119
+ () => __ΩStringCommandParameter,
120
+ "StringCommandParameterConfig",
121
+ "n\"o!\"w#y"
122
+ ];
123
+ const __ΩNumberCommandParameterConfig = [
124
+ () => __ΩAsCommandParameterConfig,
78
125
  () => __ΩNumberCommandParameter,
79
- "ReflectionProperty",
80
- "reflection",
81
- "NumberCommandOption",
82
- "Pn!\"w\"4#8Mw$y"
126
+ "NumberCommandParameterConfig",
127
+ "n\"o!\"w#y"
128
+ ];
129
+ const __ΩBooleanCommandParameterConfig = [
130
+ () => __ΩAsCommandParameterConfig,
131
+ () => __ΩBooleanCommandParameter,
132
+ "BooleanCommandParameterConfig",
133
+ "n\"o!\"w#y"
134
+ ];
135
+ const __ΩCommandParameterConfig = [
136
+ () => __ΩStringCommandParameterConfig,
137
+ () => __ΩNumberCommandParameterConfig,
138
+ () => __ΩBooleanCommandParameterConfig,
139
+ "CommandParameterConfig",
140
+ "Pn!n\"n#Jw$y"
83
141
  ];
84
142
  const __ΩBooleanCommandOption = [
85
143
  () => __ΩBooleanCommandParameter,
86
- "ReflectionProperty",
87
- "reflection",
88
144
  "isNegativeOf",
89
145
  "skipAddingNegative",
90
146
  "BooleanCommandOption",
91
- "Pn!\"w\"4#8&4$8)4%8Mw&y"
147
+ "Pn!&4\"8)4#8Mw$y"
92
148
  ];
93
149
  const __ΩCommandOption = [
94
- () => __ΩStringCommandOption,
95
- () => __ΩNumberCommandOption,
150
+ () => __ΩStringCommandParameter,
151
+ () => __ΩNumberCommandParameter,
96
152
  () => __ΩBooleanCommandOption,
97
153
  "CommandOption",
98
154
  "Pn!n\"n#Jw$y"
99
155
  ];
100
- const __ΩStringCommandArgument = [
101
- () => __ΩStringCommandParameter,
102
- "ReflectionParameter",
103
- "reflection",
104
- "StringCommandArgument",
105
- "Pn!\"w\"4#Mw$y"
156
+ const __ΩCommandOptionConfig = [
157
+ () => __ΩAsCommandParameterConfig,
158
+ () => __ΩCommandOption,
159
+ "CommandOptionConfig",
160
+ "n\"o!\"w#y"
106
161
  ];
107
- const __ΩNumberCommandArgument = [
162
+ const __ΩCommandArgument = [
163
+ () => __ΩStringCommandParameter,
108
164
  () => __ΩNumberCommandParameter,
109
- "ReflectionParameter",
110
- "reflection",
111
- "NumberCommandArgument",
112
- "Pn!\"w\"4#Mw$y"
113
- ];
114
- const __ΩBooleanCommandArgument = [
115
165
  () => __ΩBooleanCommandParameter,
116
- "ReflectionParameter",
117
- "reflection",
118
- "BooleanCommandArgument",
119
- "Pn!\"w\"4#Mw$y"
120
- ];
121
- const __ΩCommandArgument = [
122
- () => __ΩStringCommandArgument,
123
- () => __ΩNumberCommandArgument,
124
- () => __ΩBooleanCommandArgument,
125
166
  "CommandArgument",
126
167
  "Pn!n\"n#Jw$y"
127
168
  ];
169
+ const __ΩCommandArgumentConfig = [
170
+ () => __ΩAsCommandParameterConfig,
171
+ () => __ΩCommandArgument,
172
+ "CommandArgumentConfig",
173
+ "n\"o!\"w#y"
174
+ ];
128
175
  const __ΩCommandBase = [
129
176
  "id",
130
177
  "name",
@@ -138,15 +185,15 @@ const __ΩCommandBase = [
138
185
  "CommandBase",
139
186
  "PP&,J4!&4\"P&,J4#&F4$&4%8&4&8&F4'8&4(8)4)Mw*y"
140
187
  ];
141
- const __ΩCommandInput = [
188
+ const __ΩCommandConfig = [
142
189
  () => __ΩCommandBase,
143
190
  "id",
144
191
  "entry",
145
- "CommandInput",
192
+ "CommandConfig",
146
193
  "Pn!&4\"!4#Mw$y"
147
194
  ];
148
195
  const __ΩCommandTree = [
149
- () => __ΩCommandInput,
196
+ () => __ΩCommandConfig,
150
197
  "title",
151
198
  "description",
152
199
  "alias",
@@ -154,88 +201,73 @@ const __ΩCommandTree = [
154
201
  () => __ΩCommandOption,
155
202
  "options",
156
203
  () => __ΩCommandArgument,
157
- "arguments",
204
+ "args",
158
205
  0,
159
206
  "parent",
160
207
  () => __ΩRecord,
161
208
  0,
162
209
  "children",
163
- "ReflectionFunction",
164
- "reflection",
165
210
  "CommandTree",
166
- "Pn!P&4\"&4#&F4$&n&o%#4'n(F4)P,n*J4+&n-o,#4.P\"w/,J40MKw1y"
167
- ];
168
- const __ΩSerializedCommandOption = [
169
- () => __ΩOmit,
170
- () => __ΩCommandOption,
171
- "reflection",
172
- "SerializedCommandOption",
173
- "n\".#o!#w$y"
174
- ];
175
- const __ΩSerializedCommandArgument = [
176
- () => __ΩOmit,
177
- () => __ΩCommandArgument,
178
- "reflection",
179
- "SerializedCommandArgument",
180
- "n\".#o!#w$y"
211
+ "Pn!P&4\"&4#&F4$&n&o%#4'n(F4)P,n*J4+&n-o,#4.MKw/y"
181
212
  ];
182
213
  const __ΩSerializedCommandTree = [
183
214
  () => __ΩOmit,
184
215
  () => __ΩCommandTree,
185
- "options",
186
- "arguments",
187
216
  "parent",
188
217
  "children",
189
- "reflection",
190
- () => __ΩRecord,
191
- () => __ΩSerializedCommandOption,
192
- "options",
193
- () => __ΩSerializedCommandArgument,
194
- "arguments",
195
218
  "parent",
196
219
  () => __ΩRecord,
197
220
  0,
198
221
  "children",
199
- "SerializedTypes",
200
- "reflection",
201
222
  "SerializedCommandTree",
202
- "Pn\"P.#.$.%.&.'Jo!#P&n)o(#4*n+F4,P,&J4-&n/o.#40\"w1428MKw3y"
223
+ "Pn\"P.#.$Jo!#PP,&J4%&n'o&#4(MKw)y"
203
224
  ];
204
- const __ΩMetadata = [
225
+ const __ΩCommandMetadata = [
205
226
  "title",
206
227
  "description",
207
228
  "alias",
208
229
  "icon",
209
- "Metadata",
230
+ "CommandMetadata",
210
231
  "P&4!8&4\"8P&&FJ4#8&4$8Mw%y"
211
232
  ];
212
233
  const __ΩCommandModule = [
213
- () => __ΩMetadata,
234
+ () => __ΩCommandMetadata,
214
235
  "metadata",
236
+ () => __ΩRecord,
237
+ () => __ΩCommandOptionConfig,
238
+ "JSONSchema7Object",
239
+ "StandardJSONSchemaV1",
240
+ "options",
241
+ () => __ΩCommandArgumentConfig,
242
+ "args",
215
243
  "default",
216
244
  "CommandModule",
217
- "Pn!4\"8!4#8Mw$y"
245
+ "Pn!4\"8P&n$o##\"w%\"w&!J4'8Pn(F!\"w&!J4)8!4*8Mw+y"
218
246
  ];
219
247
 
220
248
  //#endregion
249
+ exports.CommandParameterKinds = CommandParameterKinds;
250
+ exports.__ΩAsCommandParameterConfig = __ΩAsCommandParameterConfig;
221
251
  exports.__ΩBaseCommandParameter = __ΩBaseCommandParameter;
222
- exports.__ΩBooleanCommandArgument = __ΩBooleanCommandArgument;
223
252
  exports.__ΩBooleanCommandOption = __ΩBooleanCommandOption;
224
253
  exports.__ΩBooleanCommandParameter = __ΩBooleanCommandParameter;
254
+ exports.__ΩBooleanCommandParameterConfig = __ΩBooleanCommandParameterConfig;
225
255
  exports.__ΩCommandArgument = __ΩCommandArgument;
256
+ exports.__ΩCommandArgumentConfig = __ΩCommandArgumentConfig;
226
257
  exports.__ΩCommandBase = __ΩCommandBase;
227
- exports.__ΩCommandInput = __ΩCommandInput;
258
+ exports.__ΩCommandConfig = __ΩCommandConfig;
259
+ exports.__ΩCommandMetadata = __ΩCommandMetadata;
228
260
  exports.__ΩCommandModule = __ΩCommandModule;
229
261
  exports.__ΩCommandOption = __ΩCommandOption;
262
+ exports.__ΩCommandOptionConfig = __ΩCommandOptionConfig;
263
+ exports.__ΩCommandParameter = __ΩCommandParameter;
264
+ exports.__ΩCommandParameterConfig = __ΩCommandParameterConfig;
265
+ exports.__ΩCommandParameterKind = __ΩCommandParameterKind;
266
+ exports.__ΩCommandParameterType = __ΩCommandParameterType;
230
267
  exports.__ΩCommandTree = __ΩCommandTree;
231
- exports.__ΩMetadata = __ΩMetadata;
232
- exports.__ΩNumberCommandArgument = __ΩNumberCommandArgument;
233
- exports.__ΩNumberCommandOption = __ΩNumberCommandOption;
234
268
  exports.__ΩNumberCommandParameter = __ΩNumberCommandParameter;
235
- exports.__ΩSerializedCommandArgument = __ΩSerializedCommandArgument;
236
- exports.__ΩSerializedCommandOption = __ΩSerializedCommandOption;
269
+ exports.__ΩNumberCommandParameterConfig = __ΩNumberCommandParameterConfig;
237
270
  exports.__ΩSerializedCommandTree = __ΩSerializedCommandTree;
238
- exports.__ΩStringCommandArgument = __ΩStringCommandArgument;
239
- exports.__ΩStringCommandOption = __ΩStringCommandOption;
240
271
  exports.__ΩStringCommandParameter = __ΩStringCommandParameter;
272
+ exports.__ΩStringCommandParameterConfig = __ΩStringCommandParameterConfig;
241
273
  //# sourceMappingURL=command.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.cjs","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionFunction,\n ReflectionKind,\n ReflectionParameter,\n ReflectionProperty,\n SerializedTypes\n} from \"@powerlines/deepkit/vendor/type\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport type { ResolvedEntryTypeDefinition } from \"powerlines/types/resolved\";\n\nexport interface BaseCommandParameter {\n /**\n * The option name.\n */\n name: string;\n /**\n * The option kind.\n */\n kind: ReflectionKind;\n /**\n * The display title.\n */\n title: string;\n /**\n * The option description.\n */\n description: string;\n /**\n * Alternative option names.\n */\n alias: string[];\n /**\n * The environment variable name or false to disable.\n */\n env: string | false;\n /**\n * Whether the option is optional.\n */\n optional: boolean;\n}\n\nexport interface StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: ReflectionKind.string;\n /**\n * The default value.\n */\n default?: string;\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n}\n\nexport interface NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: ReflectionKind.number;\n /**\n * The default value.\n */\n default?: number;\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: ReflectionKind.boolean;\n /**\n * The default value.\n */\n default?: boolean;\n /**\n * The option this negates.\n */\n isNegativeOf?: string;\n /**\n * Whether to skip adding a negative option.\n */\n skipAddingNegative?: boolean;\n}\n\nexport interface StringCommandOption extends StringCommandParameter {\n /**\n * The property reflection.\n */\n reflection?: ReflectionProperty;\n}\n\nexport interface NumberCommandOption extends NumberCommandParameter {\n /**\n * The property reflection.\n */\n reflection?: ReflectionProperty;\n}\n\nexport interface BooleanCommandOption extends BooleanCommandParameter {\n /**\n * The property reflection.\n */\n reflection?: ReflectionProperty;\n /**\n * The option this negates.\n */\n isNegativeOf?: string;\n /**\n * Whether to skip adding a negative option.\n */\n skipAddingNegative?: boolean;\n}\n\nexport type CommandOption =\n | StringCommandOption\n | NumberCommandOption\n | BooleanCommandOption;\n\nexport interface StringCommandArgument extends StringCommandParameter {\n /**\n * The parameter reflection.\n */\n reflection: ReflectionParameter;\n}\n\nexport interface NumberCommandArgument extends NumberCommandParameter {\n /**\n * The parameter reflection.\n */\n reflection: ReflectionParameter;\n}\n\nexport interface BooleanCommandArgument extends BooleanCommandParameter {\n /**\n * The parameter reflection.\n */\n reflection: ReflectionParameter;\n}\n\nexport type CommandArgument =\n | StringCommandArgument\n | NumberCommandArgument\n | BooleanCommandArgument;\n\nexport interface CommandBase {\n /**\n * The command id.\n */\n id: string | null;\n\n /**\n * The command name.\n */\n name: string;\n\n /**\n * The full command path value.\n */\n path: string | null;\n\n /**\n * The path segments.\n */\n segments: string[];\n\n /**\n * The display title.\n */\n title?: string;\n\n /**\n * The command description.\n */\n description?: string;\n\n /**\n * Alternative command names.\n */\n alias?: string[];\n\n /**\n * The command icon.\n */\n icon?: string;\n\n /**\n * Whether the command is virtual.\n *\n * @remarks\n * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.\n */\n isVirtual: boolean;\n}\n\nexport interface CommandInput extends CommandBase {\n /**\n * The command id.\n */\n id: string;\n\n /**\n * The resolved entry definition.\n */\n entry: ResolvedEntryTypeDefinition;\n}\n\nexport type CommandTree = CommandInput & {\n /**\n * The display title.\n */\n title: string;\n /**\n * The command description.\n */\n description: string;\n /**\n * Alternative command names.\n */\n alias: string[];\n /**\n * The command options.\n */\n options: Record<string, CommandOption>;\n /**\n * The positional arguments provided to the command.\n */\n arguments: CommandArgument[];\n /**\n * The parent command.\n */\n parent: null | CommandTree;\n /**\n * Child commands.\n */\n children: Record<string, CommandTree>;\n /**\n * The command handler reflection.\n */\n reflection: ReflectionFunction | null;\n};\n\nexport type SerializedCommandOption = Omit<CommandOption, \"reflection\">;\n\nexport type SerializedCommandArgument = Omit<CommandArgument, \"reflection\">;\n\nexport type SerializedCommandTree = Omit<\n CommandTree,\n \"options\" | \"arguments\" | \"parent\" | \"children\" | \"reflection\"\n> & {\n /**\n * The command options.\n */\n options: Record<string, SerializedCommandOption>;\n /**\n * The positional arguments provided to the command.\n */\n arguments: SerializedCommandArgument[];\n /**\n * The parent command id.\n */\n parent: null | string;\n /**\n * Serialized child commands.\n */\n children: Record<string, SerializedCommandTree>;\n /**\n * The command handler reflection.\n */\n reflection?: SerializedTypes;\n};\n\nexport interface Metadata {\n /**\n * The display name of the command.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a formatted value of the command name will be used.\n */\n title?: string;\n\n /**\n * A brief description of what the command does.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a default message may be shown.\n */\n description?: string;\n\n /**\n * One or more alternative names for the command.\n */\n alias?: string | string[];\n\n /**\n * An optional icon to visually represent the command in user interfaces.\n *\n * @remarks\n * This can be a string containing an emoji, a Unicode character, or any other symbol that helps to visually identify the command. If not provided, no icon will be displayed.\n */\n icon?: string;\n}\n\nexport interface CommandModule {\n metadata?: Metadata;\n default?: AnyFunction;\n}\n"],"mappings":";;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;;;;;;;;AAEhE,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAAY;;;;;;;AAE/C,MAAM,0BAA0B;CAAC;CAAQ;CAAkB;CAAQ;CAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,4BAA4B;OAAO;CAAyB;CAAG;CAAE;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;AAIvE,MAAM,6BAA6B;OAAO;CAAyB;CAAG;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;AAEvE,MAAM,yBAAyB;OAAO;CAAqB;CAAA;CAAA;CAAA;CAAA;AAE3D,MAAM,yBAAyB;OAAK;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,0BAA0B;OAAO;CAA4B;CAAG;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,mBAAM;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAEZ,MAAM,2BAAU;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEhB,MAAM,2BAAc;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,4BAA4B;OAAM;CAAA;CAAA;CAAA;CAAA;CAAA;AAExC,MAAM,qBAAqB;OAAO;OAAgC;OAAU;CAAA;CAAA;CAAA;AAE5E,MAAM,iBAAiB;CAAC;CAAM;CAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtC,MAAM,kBAAc;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,iBAAQ;OAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEd,MAAM,6BAAc;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,+BAAgB;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AAEtB,MAAM,2BAAgB;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtB,MAAM,cAAS;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEf,MAAM,mBAAmB;OAAE;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"command.cjs","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema7TupleType } from \"@stryke/json\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport type { JSONSchema7Object } from \"json-schema\";\nimport type { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport type * as z3 from \"zod/v3\";\n\nexport type CommandParameterType =\n | string\n | number\n | boolean\n | (string | number)[];\n\nexport const CommandParameterKinds = {\n string: \"string\",\n number: \"number\",\n boolean: \"boolean\"\n} as const;\n\nexport type CommandParameterKind =\n (typeof CommandParameterKinds)[keyof typeof CommandParameterKinds];\n\nexport interface BaseCommandParameter {\n /**\n * The option name.\n */\n name: string;\n /**\n * The option kind.\n */\n kind: CommandParameterKind;\n /**\n * The display title.\n */\n title: string;\n /**\n * The option description.\n */\n description: string;\n /**\n * Alternative option names.\n */\n alias: string[];\n /**\n * The environment variable name or false to disable.\n */\n env: string | false;\n /**\n * Whether the option is optional.\n */\n optional: boolean;\n}\n\nexport interface StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n /**\n * The default value.\n */\n default?: string;\n /**\n * A standard string format to validate the option value against.\n */\n format?:\n | \"email\"\n | \"uri\"\n | \"uuid\"\n | \"ipv4\"\n | \"ipv6\"\n | \"date\"\n | \"time\"\n | \"date-time\"\n | \"duration\";\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: string[];\n}\n\nexport interface NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n /**\n * The default value.\n */\n default?: number;\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n /**\n * The default value.\n */\n default?: boolean;\n}\n\nexport type CommandParameter =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\n\nexport type AsCommandParameterConfig<T extends BaseCommandParameter> = Pick<\n T,\n \"kind\" | \"alias\"\n> &\n Partial<Omit<T, \"kind\" | \"alias\">> & {\n alias?: string | string[];\n };\n\nexport type StringCommandParameterConfig =\n AsCommandParameterConfig<StringCommandParameter>;\nexport type NumberCommandParameterConfig =\n AsCommandParameterConfig<NumberCommandParameter>;\nexport type BooleanCommandParameterConfig =\n AsCommandParameterConfig<BooleanCommandParameter>;\n\nexport type CommandParameterConfig =\n | StringCommandParameterConfig\n | NumberCommandParameterConfig\n | BooleanCommandParameterConfig;\n\nexport interface BooleanCommandOption extends BooleanCommandParameter {\n /**\n * The option this negates.\n */\n isNegativeOf?: string;\n /**\n * Whether to skip adding a negative option.\n */\n skipAddingNegative?: boolean;\n}\n\nexport type CommandOption =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandOption;\nexport type CommandOptionConfig = AsCommandParameterConfig<CommandOption>;\n\nexport type CommandArgument =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\nexport type CommandArgumentConfig = AsCommandParameterConfig<CommandArgument>;\n\nexport interface CommandBase {\n /**\n * The command id.\n */\n id: string | null;\n\n /**\n * The command name.\n */\n name: string;\n\n /**\n * The full command path value.\n */\n path: string | null;\n\n /**\n * The path segments.\n */\n segments: string[];\n\n /**\n * The display title.\n */\n title?: string;\n\n /**\n * The command description.\n */\n description?: string;\n\n /**\n * Alternative command names.\n */\n alias?: string[];\n\n /**\n * The command icon.\n */\n icon?: string;\n\n /**\n * Whether the command is virtual.\n *\n * @remarks\n * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.\n */\n isVirtual: boolean;\n}\n\nexport interface CommandConfig extends CommandBase {\n /**\n * The command id.\n */\n id: string;\n\n /**\n * The resolved entry definition.\n */\n entry: ResolvedEntryTypeDefinition;\n}\n\nexport type CommandTree = CommandConfig & {\n /**\n * The display title.\n */\n title: string;\n /**\n * The command description.\n */\n description: string;\n /**\n * Alternative command names.\n */\n alias: string[];\n /**\n * The command options.\n */\n options: Record<string, CommandOption>;\n /**\n * The positional arguments provided to the command.\n */\n args: CommandArgument[];\n /**\n * The parent command.\n */\n parent: null | CommandTree;\n /**\n * Child commands.\n */\n children: Record<string, CommandTree>;\n};\n\nexport type SerializedCommandTree = Omit<CommandTree, \"parent\" | \"children\"> & {\n /**\n * The parent command id.\n */\n parent: null | string;\n /**\n * Serialized child commands.\n */\n children: Record<string, SerializedCommandTree>;\n};\n\nexport interface CommandMetadata {\n /**\n * The display name of the command.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a formatted value of the command name will be used.\n */\n title?: string;\n\n /**\n * A brief description of what the command does.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a default message may be shown.\n */\n description?: string;\n\n /**\n * One or more alternative names for the command.\n */\n alias?: string | string[];\n\n /**\n * An optional icon to visually represent the command in user interfaces.\n *\n * @remarks\n * This can be a string containing an emoji, a Unicode character, or any other symbol that helps to visually identify the command. If not provided, no icon will be displayed.\n */\n icon?: string;\n}\n\nexport interface CommandModule {\n metadata?: CommandMetadata;\n options?:\n | Record<string, CommandOptionConfig>\n | JSONSchema7Object\n | StandardJSONSchemaV1<Record<string, CommandParameterType>>\n | z3.AnyZodObject;\n args?:\n | CommandArgumentConfig[]\n | JsonSchema7TupleType\n | StandardJSONSchemaV1<CommandParameterType[]>\n | z3.AnyZodTuple;\n default?: AnyFunction;\n}\n"],"mappings":";;AAAA,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAA4B;;;;;;AAE/D,MAAM,UAAU;CAAC;CAAK;OAAW;OAAc;CAAA;CAAA;CAAA;;;;;;;AAE/C,MAAM,aAAa;CAAC;CAAK;CAAK;CAAW;CAA6B;AACtE,MAAM,0BAA0B,CAAC,wBAAwB,gBAAW;AAEpE,MAAa,wBAAwB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