@shell-shock/core 0.17.10 → 0.17.11

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 (257) hide show
  1. package/dist/api.cjs +31 -143
  2. package/dist/api.cjs.map +1 -0
  3. package/dist/api.d.cts +2 -77
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +2 -76
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +30 -140
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/command-validation-logic.cjs +14 -15
  10. package/dist/components/command-validation-logic.cjs.map +1 -0
  11. package/dist/components/command-validation-logic.d.cts +1 -3
  12. package/dist/components/command-validation-logic.d.cts.map +1 -1
  13. package/dist/components/command-validation-logic.d.mts +1 -3
  14. package/dist/components/command-validation-logic.d.mts.map +1 -1
  15. package/dist/components/command-validation-logic.mjs +12 -13
  16. package/dist/components/command-validation-logic.mjs.map +1 -1
  17. package/dist/components/docs.cjs +6 -6
  18. package/dist/components/docs.cjs.map +1 -0
  19. package/dist/components/docs.d.cts +4 -5
  20. package/dist/components/docs.d.cts.map +1 -1
  21. package/dist/components/docs.d.mts +4 -5
  22. package/dist/components/docs.d.mts.map +1 -1
  23. package/dist/components/docs.mjs +4 -4
  24. package/dist/components/docs.mjs.map +1 -1
  25. package/dist/components/exec-builtin.cjs +9 -11
  26. package/dist/components/exec-builtin.cjs.map +1 -0
  27. package/dist/components/exec-builtin.d.cts +1 -2
  28. package/dist/components/exec-builtin.d.cts.map +1 -1
  29. package/dist/components/exec-builtin.d.mts +1 -2
  30. package/dist/components/exec-builtin.d.mts.map +1 -1
  31. package/dist/components/exec-builtin.mjs +7 -10
  32. package/dist/components/exec-builtin.mjs.map +1 -1
  33. package/dist/components/helpers.cjs +4 -5
  34. package/dist/components/helpers.cjs.map +1 -0
  35. package/dist/components/helpers.d.cts +6 -8
  36. package/dist/components/helpers.d.cts.map +1 -1
  37. package/dist/components/helpers.d.mts +6 -8
  38. package/dist/components/helpers.d.mts.map +1 -1
  39. package/dist/components/helpers.mjs +2 -3
  40. package/dist/components/helpers.mjs.map +1 -1
  41. package/dist/components/options-parser-logic.cjs +29 -30
  42. package/dist/components/options-parser-logic.cjs.map +1 -0
  43. package/dist/components/options-parser-logic.d.cts +8 -9
  44. package/dist/components/options-parser-logic.d.cts.map +1 -1
  45. package/dist/components/options-parser-logic.d.mts +8 -9
  46. package/dist/components/options-parser-logic.d.mts.map +1 -1
  47. package/dist/components/options-parser-logic.mjs +27 -28
  48. package/dist/components/options-parser-logic.mjs.map +1 -1
  49. package/dist/components/state-builtin.cjs +3 -2
  50. package/dist/components/state-builtin.cjs.map +1 -0
  51. package/dist/components/state-builtin.d.cts +4 -5
  52. package/dist/components/state-builtin.d.cts.map +1 -1
  53. package/dist/components/state-builtin.d.mts +4 -5
  54. package/dist/components/state-builtin.d.mts.map +1 -1
  55. package/dist/components/state-builtin.mjs +1 -1
  56. package/dist/components/state-builtin.mjs.map +1 -1
  57. package/dist/components/usage.cjs +4 -5
  58. package/dist/components/usage.cjs.map +1 -0
  59. package/dist/components/usage.d.cts +1 -2
  60. package/dist/components/usage.d.cts.map +1 -1
  61. package/dist/components/usage.d.mts +1 -2
  62. package/dist/components/usage.d.mts.map +1 -1
  63. package/dist/components/usage.mjs +2 -3
  64. package/dist/components/usage.mjs.map +1 -1
  65. package/dist/components/utils-builtin.cjs +5 -4
  66. package/dist/components/utils-builtin.cjs.map +1 -0
  67. package/dist/components/utils-builtin.d.cts +7 -8
  68. package/dist/components/utils-builtin.d.cts.map +1 -1
  69. package/dist/components/utils-builtin.d.mts +7 -8
  70. package/dist/components/utils-builtin.d.mts.map +1 -1
  71. package/dist/components/utils-builtin.mjs +3 -3
  72. package/dist/components/utils-builtin.mjs.map +1 -1
  73. package/dist/config.cjs +53 -19
  74. package/dist/config.cjs.map +1 -0
  75. package/dist/config.d.cts +29 -8
  76. package/dist/config.d.cts.map +1 -1
  77. package/dist/config.d.mts +29 -8
  78. package/dist/config.d.mts.map +1 -1
  79. package/dist/config.mjs +51 -18
  80. package/dist/config.mjs.map +1 -1
  81. package/dist/contexts/command.cjs +2 -2
  82. package/dist/contexts/command.cjs.map +1 -0
  83. package/dist/contexts/command.d.cts.map +1 -1
  84. package/dist/contexts/command.d.mts.map +1 -1
  85. package/dist/contexts/command.mjs.map +1 -1
  86. package/dist/contexts/options.cjs +4 -4
  87. package/dist/contexts/options.cjs.map +1 -0
  88. package/dist/contexts/options.d.cts.map +1 -1
  89. package/dist/contexts/options.d.mts.map +1 -1
  90. package/dist/contexts/options.mjs +2 -3
  91. package/dist/contexts/options.mjs.map +1 -1
  92. package/dist/engine.cjs +138 -0
  93. package/dist/engine.cjs.map +1 -0
  94. package/dist/engine.d.cts +79 -0
  95. package/dist/engine.d.cts.map +1 -0
  96. package/dist/engine.d.mts +79 -0
  97. package/dist/engine.d.mts.map +1 -0
  98. package/dist/engine.mjs +136 -0
  99. package/dist/engine.mjs.map +1 -0
  100. package/dist/helpers/automd.cjs +6 -7
  101. package/dist/helpers/automd.cjs.map +1 -0
  102. package/dist/helpers/automd.mjs +2 -3
  103. package/dist/helpers/automd.mjs.map +1 -1
  104. package/dist/helpers/docs-helpers.cjs +2 -2
  105. package/dist/helpers/docs-helpers.cjs.map +1 -0
  106. package/dist/helpers/docs-helpers.mjs.map +1 -1
  107. package/dist/helpers/get-framework.cjs +24 -0
  108. package/dist/helpers/get-framework.cjs.map +1 -0
  109. package/dist/helpers/get-framework.mjs +24 -0
  110. package/dist/helpers/get-framework.mjs.map +1 -0
  111. package/dist/helpers/paths.cjs +5 -5
  112. package/dist/helpers/paths.cjs.map +1 -0
  113. package/dist/helpers/paths.mjs +4 -4
  114. package/dist/helpers/paths.mjs.map +1 -1
  115. package/dist/helpers/persistence.cjs +4 -6
  116. package/dist/helpers/persistence.cjs.map +1 -0
  117. package/dist/helpers/persistence.mjs +3 -3
  118. package/dist/helpers/persistence.mjs.map +1 -1
  119. package/dist/helpers/update-package-json.cjs +2 -2
  120. package/dist/helpers/update-package-json.cjs.map +1 -0
  121. package/dist/helpers/update-package-json.mjs.map +1 -1
  122. package/dist/helpers/utilities.cjs +3 -3
  123. package/dist/helpers/utilities.cjs.map +1 -0
  124. package/dist/helpers/utilities.mjs +1 -1
  125. package/dist/helpers/utilities.mjs.map +1 -1
  126. package/dist/helpers/validations.cjs +3 -3
  127. package/dist/helpers/validations.cjs.map +1 -0
  128. package/dist/helpers/validations.mjs +1 -3
  129. package/dist/helpers/validations.mjs.map +1 -1
  130. package/dist/index.cjs +121 -51
  131. package/dist/index.cjs.map +1 -0
  132. package/dist/index.d.cts +80 -5
  133. package/dist/index.d.cts.map +1 -0
  134. package/dist/index.d.mts +80 -5
  135. package/dist/index.d.mts.map +1 -0
  136. package/dist/index.mjs +118 -6
  137. package/dist/index.mjs.map +1 -0
  138. package/dist/package.cjs +12 -0
  139. package/dist/package.cjs.map +1 -0
  140. package/dist/package.mjs +6 -0
  141. package/dist/package.mjs.map +1 -0
  142. package/dist/plugin-utils/compute-bin.cjs +8 -10
  143. package/dist/plugin-utils/compute-bin.cjs.map +1 -0
  144. package/dist/plugin-utils/compute-bin.d.cts +2 -2
  145. package/dist/plugin-utils/compute-bin.d.cts.map +1 -1
  146. package/dist/plugin-utils/compute-bin.d.mts +2 -2
  147. package/dist/plugin-utils/compute-bin.d.mts.map +1 -1
  148. package/dist/plugin-utils/compute-bin.mjs +6 -8
  149. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  150. package/dist/plugin-utils/context-helpers.cjs +7 -14
  151. package/dist/plugin-utils/context-helpers.cjs.map +1 -0
  152. package/dist/plugin-utils/context-helpers.d.cts +4 -4
  153. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  154. package/dist/plugin-utils/context-helpers.d.mts +4 -4
  155. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  156. package/dist/plugin-utils/context-helpers.mjs +5 -12
  157. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  158. package/dist/plugin-utils/deepkit.cjs +15 -16
  159. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  160. package/dist/plugin-utils/deepkit.d.cts +5 -5
  161. package/dist/plugin-utils/deepkit.d.cts.map +1 -1
  162. package/dist/plugin-utils/deepkit.d.mts +5 -5
  163. package/dist/plugin-utils/deepkit.d.mts.map +1 -1
  164. package/dist/plugin-utils/deepkit.mjs +14 -15
  165. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  166. package/dist/plugin-utils/description-helpers.cjs +2 -1
  167. package/dist/plugin-utils/description-helpers.cjs.map +1 -0
  168. package/dist/plugin-utils/description-helpers.d.cts.map +1 -1
  169. package/dist/plugin-utils/description-helpers.d.mts.map +1 -1
  170. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  171. package/dist/plugin-utils/get-command-tree.cjs +2 -1
  172. package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
  173. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
  174. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
  175. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  176. package/dist/plugin-utils/index.cjs +1 -1
  177. package/dist/plugin-utils/index.d.cts +2 -2
  178. package/dist/plugin-utils/index.d.mts +2 -2
  179. package/dist/plugin-utils/index.mjs +2 -2
  180. package/dist/plugin-utils/reflect.cjs +5 -5
  181. package/dist/plugin-utils/reflect.cjs.map +1 -0
  182. package/dist/plugin-utils/reflect.d.cts.map +1 -1
  183. package/dist/plugin-utils/reflect.d.mts.map +1 -1
  184. package/dist/plugin-utils/reflect.mjs +3 -5
  185. package/dist/plugin-utils/reflect.mjs.map +1 -1
  186. package/dist/plugin-utils/traverse-command-tree.cjs +2 -1
  187. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
  188. package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -1
  189. package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -1
  190. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  191. package/dist/plugin-utils/type-checks.cjs +146 -17
  192. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  193. package/dist/plugin-utils/type-checks.d.cts +5 -5
  194. package/dist/plugin-utils/type-checks.d.cts.map +1 -1
  195. package/dist/plugin-utils/type-checks.d.mts +5 -5
  196. package/dist/plugin-utils/type-checks.d.mts.map +1 -1
  197. package/dist/plugin-utils/type-checks.mjs +145 -16
  198. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  199. package/dist/plugin.cjs +80 -56
  200. package/dist/plugin.cjs.map +1 -0
  201. package/dist/plugin.d.cts.map +1 -1
  202. package/dist/plugin.d.mts.map +1 -1
  203. package/dist/plugin.mjs +75 -52
  204. package/dist/plugin.mjs.map +1 -1
  205. package/dist/resolver/helpers.cjs +33 -24
  206. package/dist/resolver/helpers.cjs.map +1 -0
  207. package/dist/resolver/helpers.mjs +32 -22
  208. package/dist/resolver/helpers.mjs.map +1 -1
  209. package/dist/resolver/resolve.cjs +316 -59
  210. package/dist/resolver/resolve.cjs.map +1 -0
  211. package/dist/resolver/resolve.mjs +313 -56
  212. package/dist/resolver/resolve.mjs.map +1 -1
  213. package/dist/types/command.cjs +43 -82
  214. package/dist/types/command.cjs.map +1 -0
  215. package/dist/types/command.d.cts +61 -119
  216. package/dist/types/command.d.cts.map +1 -1
  217. package/dist/types/command.d.mts +61 -119
  218. package/dist/types/command.d.mts.map +1 -1
  219. package/dist/types/command.mjs +42 -80
  220. package/dist/types/command.mjs.map +1 -1
  221. package/dist/types/config.cjs +45 -4
  222. package/dist/types/config.cjs.map +1 -0
  223. package/dist/types/config.d.cts +15 -10
  224. package/dist/types/config.d.cts.map +1 -1
  225. package/dist/types/config.d.mts +15 -10
  226. package/dist/types/config.d.mts.map +1 -1
  227. package/dist/types/config.mjs +40 -4
  228. package/dist/types/config.mjs.map +1 -1
  229. package/dist/types/context.cjs +9 -1
  230. package/dist/types/context.cjs.map +1 -0
  231. package/dist/types/context.d.cts +3 -2
  232. package/dist/types/context.d.cts.map +1 -1
  233. package/dist/types/context.d.mts +3 -2
  234. package/dist/types/context.d.mts.map +1 -1
  235. package/dist/types/context.mjs +7 -1
  236. package/dist/types/context.mjs.map +1 -1
  237. package/dist/types/env.cjs +2 -1
  238. package/dist/types/env.cjs.map +1 -0
  239. package/dist/types/env.d.cts.map +1 -1
  240. package/dist/types/env.d.mts.map +1 -1
  241. package/dist/types/env.mjs.map +1 -1
  242. package/dist/types/index.cjs +6 -3
  243. package/dist/types/index.d.cts +4 -4
  244. package/dist/types/index.d.mts +4 -4
  245. package/dist/types/index.mjs +4 -4
  246. package/dist/types/options.cjs +2 -1
  247. package/dist/types/options.cjs.map +1 -0
  248. package/dist/types/options.d.cts.map +1 -1
  249. package/dist/types/options.d.mts.map +1 -1
  250. package/dist/types/options.mjs.map +1 -1
  251. package/package.json +43 -35
  252. package/dist/resolver/deepkit.cjs +0 -135
  253. package/dist/resolver/deepkit.mjs +0 -135
  254. package/dist/resolver/deepkit.mjs.map +0 -1
  255. package/dist/resolver/module.cjs +0 -145
  256. package/dist/resolver/module.mjs +0 -145
  257. package/dist/resolver/module.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.17.10",
3
+ "version": "0.17.11",
4
4
  "private": false,
5
5
  "description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
6
6
  "keywords": ["shell-shock", "powerlines", "storm-software"],
@@ -241,6 +241,20 @@
241
241
  "default": "./dist/contexts/options.mjs"
242
242
  }
243
243
  },
244
+ "./engine": {
245
+ "require": {
246
+ "types": "./dist/engine.d.cts",
247
+ "default": "./dist/engine.cjs"
248
+ },
249
+ "import": {
250
+ "types": "./dist/engine.d.mts",
251
+ "default": "./dist/engine.mjs"
252
+ },
253
+ "default": {
254
+ "types": "./dist/engine.d.mts",
255
+ "default": "./dist/engine.mjs"
256
+ }
257
+ },
244
258
  "./package.json": "./package.json",
245
259
  "./plugin": {
246
260
  "require": {
@@ -359,45 +373,39 @@
359
373
  "module": "./dist/index.mjs",
360
374
  "types": "./dist/index.d.cts",
361
375
  "typings": "dist/index.d.mts",
362
- "files": ["dist/**/*"],
376
+ "files": ["dist"],
363
377
  "dependencies": {
364
- "@alloy-js/core": "0.23.0-dev.8",
365
- "@alloy-js/markdown": "0.23.0-dev.1",
366
- "@alloy-js/typescript": "0.23.0-dev.4",
367
- "@powerlines/deepkit": "^0.8.64",
368
- "@powerlines/engine": "^0.47.4",
369
- "@powerlines/plugin-alloy": "^0.26.84",
370
- "@powerlines/plugin-automd": "^0.1.465",
371
- "@powerlines/plugin-deepkit": "^0.11.347",
372
- "@powerlines/plugin-nodejs": "^0.1.393",
373
- "@powerlines/plugin-tsdown": "^0.1.406",
374
- "@standard-schema/spec": "^1.1.0",
375
- "@standard-schema/utils": "^0.3.0",
376
- "@stryke/cli": "^0.13.42",
377
- "@stryke/convert": "^0.7.3",
378
- "@stryke/fs": "^0.33.70",
379
- "@stryke/helpers": "^0.10.12",
380
- "@stryke/json": "^0.14.16",
381
- "@stryke/path": "^0.28.2",
382
- "@stryke/string-format": "^0.17.13",
383
- "@stryke/type-checks": "^0.6.5",
384
- "@stryke/types": "^0.12.0",
385
- "@stryke/zod": "^0.3.17",
378
+ "@alloy-js/core": "^0.23.1",
379
+ "@alloy-js/markdown": "^0.23.0",
380
+ "@alloy-js/typescript": "^0.23.0",
381
+ "@powerlines/core": "^0.48.46",
382
+ "@powerlines/deepkit": "^0.9.78",
383
+ "@powerlines/engine": "^0.49.48",
384
+ "@powerlines/plugin-alloy": "^0.26.217",
385
+ "@powerlines/plugin-automd": "^0.1.585",
386
+ "@powerlines/plugin-deepkit": "^0.11.467",
387
+ "@powerlines/plugin-nodejs": "^0.1.529",
388
+ "@powerlines/plugin-tsdown": "^0.1.525",
389
+ "@powerlines/schema": "^0.11.106",
390
+ "@stryke/cli": "^0.13.57",
391
+ "@stryke/convert": "^0.7.15",
392
+ "@stryke/fs": "^0.33.85",
393
+ "@stryke/helpers": "^0.10.24",
394
+ "@stryke/json": "^0.15.8",
395
+ "@stryke/path": "^0.29.11",
396
+ "@stryke/string-format": "^0.17.26",
397
+ "@stryke/type-checks": "^0.6.17",
398
+ "@stryke/types": "^0.12.12",
386
399
  "automd": "^0.4.3",
387
400
  "defu": "^6.1.7",
388
- "json-schema": "^0.4.0",
389
- "powerlines": "^0.47.4",
390
- "tsdown": "^0.21.10"
401
+ "powerlines": "^0.47.124",
402
+ "tsdown": "^0.22.1"
391
403
  },
392
404
  "devDependencies": {
393
- "@powerlines/plugin-plugin": "^0.12.416",
394
- "@types/json-schema": "^7.0.15",
395
- "@types/node": "^25.6.0",
396
- "typescript": "^6.0.3",
397
- "zod": "^4.4.3"
405
+ "@powerlines/plugin-plugin": "^0.12.536",
406
+ "@types/node": "^25.9.1",
407
+ "typescript": "^6.0.3"
398
408
  },
399
- "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" },
400
- "peerDependenciesMeta": { "zod": { "optional": true } },
401
409
  "publishConfig": { "access": "public" },
402
- "gitHead": "7b4030fd6be000c960e8cc4c4f7b4db205054e69"
410
+ "gitHead": "9401c1de122d800040306fc89ad1835930c1a826"
403
411
  }
@@ -1,135 +0,0 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_types_command = require('../types/command.cjs');
3
- const require_helpers = require('./helpers.cjs');
4
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
5
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
- let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
7
- let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
8
- let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
9
-
10
- //#region src/resolver/deepkit.ts
11
- function __assignType(fn, args) {
12
- fn.__type = args;
13
- return fn;
14
- }
15
- function extractCommandParameterKind(type) {
16
- const isKind = !((0, _stryke_type_checks_is_set_object.isSetObject)(type) && "kind" in type);
17
- const kind = !isKind ? type.kind : type;
18
- if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.string) return require_types_command.CommandParameterKinds.string;
19
- else if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || kind === _powerlines_deepkit_vendor_type.ReflectionKind.bigint || !isKind && type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(type.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal))) return require_types_command.CommandParameterKinds.number;
20
- else if (kind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean) return require_types_command.CommandParameterKinds.boolean;
21
- else return require_types_command.CommandParameterKinds.string;
22
- }
23
- extractCommandParameterKind.__type = [
24
- "type",
25
- "CommandParameterKind",
26
- "extractCommandParameterKind",
27
- "PP!!J2!\"w\"/#"
28
- ];
29
- function resolveCommandOption(ctx, reflection) {
30
- const type = reflection.getType();
31
- const existing = ctx.output.options[reflection.getNameAsString()] ?? {};
32
- const option = {
33
- name: reflection.getNameAsString(),
34
- alias: reflection.getTags().alias ?? [],
35
- title: reflection.getTags().title?.trim(),
36
- description: reflection.getDescription(),
37
- kind: extractCommandParameterKind(type),
38
- optional: reflection.isOptional(),
39
- default: reflection.getDefaultValue(),
40
- variadic: reflection.isArray()
41
- };
42
- if (option.variadic) option.kind = extractCommandParameterKind(type.type.kind);
43
- else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) {
44
- option.kind = type.types.every(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(t.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal)), [
45
- "t",
46
- "",
47
- "P\"2!\"/\""
48
- ])) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string;
49
- option.choices = type.types.map(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(t.literal) ? t.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal) ? Number(t.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(t.literal) ? t.literal.source : String(t.literal) : null, [
50
- "t",
51
- "",
52
- "P\"2!\"/\""
53
- ])).filter(Boolean);
54
- } else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal) option.choices = [(0, _stryke_type_checks_is_number.isNumber)(type.literal) ? type.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? Number(type.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
55
- else if (!existing.kind && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[], number[], or literal[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
56
- return require_helpers.mergeCommandParameter(existing, option);
57
- }
58
- resolveCommandOption.__type = [
59
- "ResolverContext",
60
- "ctx",
61
- "reflection",
62
- "CommandOption",
63
- "resolveCommandOption",
64
- "P\"w!2\"!2#\"w$/%"
65
- ];
66
- function resolveCommandArgument(ctx, index, reflection) {
67
- const type = reflection.getType();
68
- const existing = ctx.output.args.length > index ? ctx.output.args[index] : {};
69
- const argument = {
70
- name: reflection.getName() || reflection.parameter.name,
71
- alias: reflection.getAlias(),
72
- kind: extractCommandParameterKind(type.kind),
73
- title: reflection.getTitle() || reflection.parameter.tags?.title,
74
- description: reflection.parameter.description,
75
- optional: reflection.isOptional(),
76
- default: reflection.getDefaultValue() || reflection.parameter.default
77
- };
78
- if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array) if (type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number) {
79
- argument.variadic = true;
80
- argument.kind = extractCommandParameterKind(type.type.kind);
81
- } else throw new Error(`Unsupported array type for positional argument "${argument.name}" in command "${ctx.input.command.name}". Only string[], number[], or literal[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
82
- else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) {
83
- argument.kind = type.types.every(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(t.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal)), [
84
- "t",
85
- "",
86
- "P\"2!\"/\""
87
- ])) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string;
88
- argument.choices = type.types.map(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(t.literal) ? t.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal) ? Number(t.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(t.literal) ? t.literal.source : String(t.literal) : null, [
89
- "t",
90
- "",
91
- "P\"2!\"/\""
92
- ])).filter(Boolean);
93
- } else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal) argument.choices = [(0, _stryke_type_checks_is_number.isNumber)(type.literal) ? type.literal : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? Number(type.literal) : (0, _stryke_type_checks_is_regexp.isRegExp)(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
94
- else if (!ctx.output.args?.length && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.boolean && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.string && type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.number) throw new Error(`Unsupported type for positional argument "${argument.name}" in command "${ctx.input.command.name}". Only string, number, boolean, string[], number[], or literal[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
95
- return require_helpers.mergeCommandParameter(existing, argument, { name: `arg${index}` });
96
- }
97
- resolveCommandArgument.__type = [
98
- "ResolverContext",
99
- "ctx",
100
- "index",
101
- "reflection",
102
- "CommandArgument",
103
- "resolveCommandArgument",
104
- "P\"w!2\"'2#!2$\"w%/&"
105
- ];
106
- function resolveFromBytecode(ctx) {
107
- const { input, module } = ctx;
108
- const type = (0, _powerlines_deepkit_vendor_type.reflect)(module);
109
- if (type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.function) throw new Error(`The command entry file "${input.command.entry.input?.file || input.command.path}" does not export a valid function.`);
110
- const reflection = new _powerlines_deepkit_vendor_type.ReflectionFunction(type);
111
- ctx.output.description ??= ctx.input.command.description || reflection.getDescription() || type.description;
112
- const parameters = reflection.getParameters();
113
- if (parameters.length > 0) {
114
- const hasOptions = parameters[0] && (parameters[0].type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral || parameters[0].type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class);
115
- if (hasOptions) {
116
- const optionsReflection = _powerlines_deepkit_vendor_type.ReflectionClass.from(parameters[0]?.type);
117
- for (const propertyReflection of optionsReflection.getProperties()) ctx.output.options[propertyReflection.getNameAsString()] = resolveCommandOption(ctx, propertyReflection);
118
- }
119
- ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(__assignType((arg, index) => resolveCommandArgument(ctx, index, arg), [
120
- "arg",
121
- "index",
122
- "",
123
- "P\"2!\"2\"\"/#"
124
- ]));
125
- }
126
- }
127
- resolveFromBytecode.__type = [
128
- "ResolverContext",
129
- "ctx",
130
- "resolveFromBytecode",
131
- "P\"w!2\"\"/#"
132
- ];
133
-
134
- //#endregion
135
- exports.resolveFromBytecode = resolveFromBytecode;
@@ -1,135 +0,0 @@
1
- import { CommandParameterKinds } from "../types/command.mjs";
2
- import { mergeCommandParameter } from "./helpers.mjs";
3
- import { ReflectionClass, ReflectionFunction, ReflectionKind, reflect, stringifyType } from "@powerlines/deepkit/vendor/type";
4
- import { isSetObject } from "@stryke/type-checks/is-set-object";
5
- import { isBigInt } from "@stryke/type-checks/is-bigint";
6
- import { isNumber } from "@stryke/type-checks/is-number";
7
- import { isRegExp } from "@stryke/type-checks/is-regexp";
8
-
9
- //#region src/resolver/deepkit.ts
10
- function __assignType(fn, args) {
11
- fn.__type = args;
12
- return fn;
13
- }
14
- function extractCommandParameterKind(type) {
15
- const isKind = !(isSetObject(type) && "kind" in type);
16
- const kind = !isKind ? type.kind : type;
17
- if (kind === ReflectionKind.string) return CommandParameterKinds.string;
18
- else if (kind === ReflectionKind.number || kind === ReflectionKind.bigint || !isKind && type.kind === ReflectionKind.literal && (isNumber(type.literal) || isBigInt(type.literal))) return CommandParameterKinds.number;
19
- else if (kind === ReflectionKind.boolean) return CommandParameterKinds.boolean;
20
- else return CommandParameterKinds.string;
21
- }
22
- extractCommandParameterKind.__type = [
23
- "type",
24
- "CommandParameterKind",
25
- "extractCommandParameterKind",
26
- "PP!!J2!\"w\"/#"
27
- ];
28
- function resolveCommandOption(ctx, reflection) {
29
- const type = reflection.getType();
30
- const existing = ctx.output.options[reflection.getNameAsString()] ?? {};
31
- const option = {
32
- name: reflection.getNameAsString(),
33
- alias: reflection.getTags().alias ?? [],
34
- title: reflection.getTags().title?.trim(),
35
- description: reflection.getDescription(),
36
- kind: extractCommandParameterKind(type),
37
- optional: reflection.isOptional(),
38
- default: reflection.getDefaultValue(),
39
- variadic: reflection.isArray()
40
- };
41
- if (option.variadic) option.kind = extractCommandParameterKind(type.type.kind);
42
- else if (type.kind === ReflectionKind.union) {
43
- option.kind = type.types.every(__assignType((t) => t.kind === ReflectionKind.number || t.kind === ReflectionKind.literal && (isNumber(t.literal) || isBigInt(t.literal)), [
44
- "t",
45
- "",
46
- "P\"2!\"/\""
47
- ])) ? CommandParameterKinds.number : CommandParameterKinds.string;
48
- option.choices = type.types.map(__assignType((t) => t.kind === ReflectionKind.literal ? isNumber(t.literal) ? t.literal : isBigInt(t.literal) ? Number(t.literal) : isRegExp(t.literal) ? t.literal.source : String(t.literal) : null, [
49
- "t",
50
- "",
51
- "P\"2!\"/\""
52
- ])).filter(Boolean);
53
- } else if (type.kind === ReflectionKind.literal) option.choices = [isNumber(type.literal) ? type.literal : isBigInt(type.literal) ? Number(type.literal) : isRegExp(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
54
- else if (!existing.kind && type.kind !== ReflectionKind.boolean && type.kind !== ReflectionKind.string && type.kind !== ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
55
- return mergeCommandParameter(existing, option);
56
- }
57
- resolveCommandOption.__type = [
58
- "ResolverContext",
59
- "ctx",
60
- "reflection",
61
- "CommandOption",
62
- "resolveCommandOption",
63
- "P\"w!2\"!2#\"w$/%"
64
- ];
65
- function resolveCommandArgument(ctx, index, reflection) {
66
- const type = reflection.getType();
67
- const existing = ctx.output.args.length > index ? ctx.output.args[index] : {};
68
- const argument = {
69
- name: reflection.getName() || reflection.parameter.name,
70
- alias: reflection.getAlias(),
71
- kind: extractCommandParameterKind(type.kind),
72
- title: reflection.getTitle() || reflection.parameter.tags?.title,
73
- description: reflection.parameter.description,
74
- optional: reflection.isOptional(),
75
- default: reflection.getDefaultValue() || reflection.parameter.default
76
- };
77
- if (type.kind === ReflectionKind.array) if (type.type.kind === ReflectionKind.string || type.type.kind === ReflectionKind.number) {
78
- argument.variadic = true;
79
- argument.kind = extractCommandParameterKind(type.type.kind);
80
- } else throw new Error(`Unsupported array type for positional argument "${argument.name}" in command "${ctx.input.command.name}". Only string[], number[], or literal[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
81
- else if (type.kind === ReflectionKind.union) {
82
- argument.kind = type.types.every(__assignType((t) => t.kind === ReflectionKind.number || t.kind === ReflectionKind.literal && (isNumber(t.literal) || isBigInt(t.literal)), [
83
- "t",
84
- "",
85
- "P\"2!\"/\""
86
- ])) ? CommandParameterKinds.number : CommandParameterKinds.string;
87
- argument.choices = type.types.map(__assignType((t) => t.kind === ReflectionKind.literal ? isNumber(t.literal) ? t.literal : isBigInt(t.literal) ? Number(t.literal) : isRegExp(t.literal) ? t.literal.source : String(t.literal) : null, [
88
- "t",
89
- "",
90
- "P\"2!\"/\""
91
- ])).filter(Boolean);
92
- } else if (type.kind === ReflectionKind.literal) argument.choices = [isNumber(type.literal) ? type.literal : isBigInt(type.literal) ? Number(type.literal) : isRegExp(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
93
- else if (!ctx.output.args?.length && type.kind !== ReflectionKind.boolean && type.kind !== ReflectionKind.string && type.kind !== ReflectionKind.number) throw new Error(`Unsupported type for positional argument "${argument.name}" in command "${ctx.input.command.name}". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
94
- return mergeCommandParameter(existing, argument, { name: `arg${index}` });
95
- }
96
- resolveCommandArgument.__type = [
97
- "ResolverContext",
98
- "ctx",
99
- "index",
100
- "reflection",
101
- "CommandArgument",
102
- "resolveCommandArgument",
103
- "P\"w!2\"'2#!2$\"w%/&"
104
- ];
105
- function resolveFromBytecode(ctx) {
106
- const { input, module } = ctx;
107
- const type = reflect(module);
108
- if (type.kind !== ReflectionKind.function) throw new Error(`The command entry file "${input.command.entry.input?.file || input.command.path}" does not export a valid function.`);
109
- const reflection = new ReflectionFunction(type);
110
- ctx.output.description ??= ctx.input.command.description || reflection.getDescription() || type.description;
111
- const parameters = reflection.getParameters();
112
- if (parameters.length > 0) {
113
- const hasOptions = parameters[0] && (parameters[0].type.kind === ReflectionKind.objectLiteral || parameters[0].type.kind === ReflectionKind.class);
114
- if (hasOptions) {
115
- const optionsReflection = ReflectionClass.from(parameters[0]?.type);
116
- for (const propertyReflection of optionsReflection.getProperties()) ctx.output.options[propertyReflection.getNameAsString()] = resolveCommandOption(ctx, propertyReflection);
117
- }
118
- ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(__assignType((arg, index) => resolveCommandArgument(ctx, index, arg), [
119
- "arg",
120
- "index",
121
- "",
122
- "P\"2!\"2\"\"/#"
123
- ]));
124
- }
125
- }
126
- resolveFromBytecode.__type = [
127
- "ResolverContext",
128
- "ctx",
129
- "resolveFromBytecode",
130
- "P\"w!2\"\"/#"
131
- ];
132
-
133
- //#endregion
134
- export { resolveFromBytecode };
135
- //# sourceMappingURL=deepkit.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.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 ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue() || reflection.parameter.default\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":"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"}
@@ -1,145 +0,0 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_types_command = require('../types/command.cjs');
3
- const require_type_checks = require('../plugin-utils/type-checks.cjs');
4
- require('../plugin-utils/index.cjs');
5
- let _stryke_convert_to_array = require("@stryke/convert/to-array");
6
- let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
8
- let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
9
- let _stryke_json = require("@stryke/json");
10
- let _stryke_zod = require("@stryke/zod");
11
-
12
- //#region src/resolver/module.ts
13
- const __ΩPartial = [
14
- "T",
15
- "Partial",
16
- "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
17
- ];
18
- function __assignType(fn, args) {
19
- fn.__type = args;
20
- return fn;
21
- }
22
- function resolveCommandOption(name, parent, schema) {
23
- const result = {
24
- name,
25
- kind: (0, _stryke_json.isJsonSchema7ArrayType)(schema) && schema.items ? (0, _stryke_json.isJsonSchema7NumberType)(schema.items) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string : (0, _stryke_json.isJsonSchema7BooleanType)(schema) ? require_types_command.CommandParameterKinds.boolean : (0, _stryke_json.isJsonSchema7NumberType)(schema) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string,
26
- title: schema.title,
27
- description: schema.description,
28
- alias: (0, _stryke_convert_to_array.toArray)(schema.alias || []),
29
- env: schema.env,
30
- optional: !parent.required?.includes(name),
31
- default: schema.default
32
- };
33
- if (result.kind === require_types_command.CommandParameterKinds.string || result.kind === require_types_command.CommandParameterKinds.number) {
34
- result.variadic = (0, _stryke_json.isJsonSchema7ArrayType)(schema);
35
- if (result.kind === require_types_command.CommandParameterKinds.string) result.format = schema.format;
36
- if (((0, _stryke_json.isJsonSchema7StringType)(schema) || (0, _stryke_json.isJsonSchema7NumberType)(schema)) && schema.enum) result.choices = schema.enum;
37
- } else if (result.kind === require_types_command.CommandParameterKinds.boolean && !result.variadic) {
38
- result.skipAddingNegative = schema.skipAddingNegative;
39
- result.isNegativeOf = schema.isNegativeOf;
40
- }
41
- return result;
42
- }
43
- resolveCommandOption.__type = [
44
- "name",
45
- "parent",
46
- "schema",
47
- () => __ΩPartial,
48
- "CommandOption",
49
- "resolveCommandOption",
50
- "P&2!!2\"!2#\"w%o$\"/&"
51
- ];
52
- function resolveCommandArgument(schema) {
53
- const result = {
54
- name: schema.name,
55
- kind: (0, _stryke_json.isJsonSchema7ArrayType)(schema) && schema.items ? (0, _stryke_json.isJsonSchema7NumberType)(schema.items) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string : (0, _stryke_json.isJsonSchema7BooleanType)(schema) ? require_types_command.CommandParameterKinds.boolean : (0, _stryke_json.isJsonSchema7NumberType)(schema) ? require_types_command.CommandParameterKinds.number : require_types_command.CommandParameterKinds.string,
56
- title: schema.title,
57
- description: schema.description,
58
- alias: (0, _stryke_convert_to_array.toArray)(schema.alias || []),
59
- env: schema.env,
60
- default: schema.default
61
- };
62
- if (result.kind === require_types_command.CommandParameterKinds.string || result.kind === require_types_command.CommandParameterKinds.number) {
63
- result.variadic = (0, _stryke_json.isJsonSchema7ArrayType)(schema);
64
- if (result.kind === require_types_command.CommandParameterKinds.string) result.format = schema.format;
65
- if (((0, _stryke_json.isJsonSchema7StringType)(schema) || (0, _stryke_json.isJsonSchema7NumberType)(schema)) && schema.enum) result.choices = schema.enum;
66
- }
67
- return result;
68
- }
69
- resolveCommandArgument.__type = [
70
- "schema",
71
- () => __ΩPartial,
72
- "CommandArgument",
73
- "resolveCommandArgument",
74
- "P!2!\"w#o\"\"/$"
75
- ];
76
- async function resolveFromExports(ctx) {
77
- validateExports(ctx);
78
- const metadata = ctx.module?.metadata ?? {};
79
- if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.title)) ctx.output.title = metadata.title;
80
- if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.description)) ctx.output.description = metadata.description;
81
- if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.alias) || Array.isArray(metadata.alias) && metadata.alias.length > 0) ctx.output.alias = (0, _stryke_convert_to_array.toArray)(metadata.alias);
82
- if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.icon)) ctx.output.icon = metadata.icon;
83
- if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.tags)) ctx.output.tags = (0, _stryke_helpers_get_unique.getUnique)(ctx.output.tags.concat((0, _stryke_convert_to_array.toArray)(metadata.tags)));
84
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(ctx.module?.options)) if ((0, _stryke_zod.isZod3Type)(ctx.module.options) || (0, _stryke_json.isStandardJsonSchema)(ctx.module.options) || (0, _stryke_json.isJsonSchema7ObjectType)(ctx.module.options)) {
85
- let jsonSchema;
86
- if ((0, _stryke_zod.isZod3Type)(ctx.module.options)) jsonSchema = (0, _stryke_zod.extractJsonSchema7)(ctx.module.options);
87
- else if ((0, _stryke_json.isStandardJsonSchema)(ctx.module.options)) jsonSchema = ctx.module.options["~standard"].jsonSchema.input({ target: "draft-07" });
88
- else jsonSchema = ctx.module.options;
89
- if (!(0, _stryke_json.isJsonSchema7ObjectType)(jsonSchema)) throw new TypeError(`Command options for command at path "${ctx.input.command.path}" must be defined as a Zod object schema, a standard JSON Schema object, or a JSON Schema object.`);
90
- ctx.output.options = Object.fromEntries(Object.entries(jsonSchema.properties).map(__assignType(([name, property]) => [name, resolveCommandOption(name, jsonSchema, property)], [
91
- "param0",
92
- "",
93
- "P\"2!\"/\""
94
- ])).concat(Object.entries(ctx.output.options)));
95
- } else if (Object.values(ctx.module.options).every(require_type_checks.isCommandParameterConfig)) ctx.output.options = Object.fromEntries(Object.entries(ctx.module.options).map(__assignType(([name, option]) => [name, {
96
- name,
97
- ...option,
98
- alias: (0, _stryke_convert_to_array.toArray)(option.alias)
99
- }], [
100
- "param0",
101
- "",
102
- "P\"2!\"/\""
103
- ])).concat(Object.entries(ctx.output.options)));
104
- else throw new TypeError(`Command options for command at path "${ctx.input.command.path}" must be defined as a record of valid CommandOption objects, a Zod object schema, or a standard JSON Schema object.`);
105
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(ctx.module?.args)) if ((0, _stryke_zod.isZod3Type)(ctx.module.args) || (0, _stryke_json.isStandardJsonSchema)(ctx.module.args) || (0, _stryke_json.isJsonSchema7TupleType)(ctx.module.args)) {
106
- let jsonSchema;
107
- if ((0, _stryke_zod.isZod3Type)(ctx.module.args)) jsonSchema = (0, _stryke_zod.extractJsonSchema7)(ctx.module.args);
108
- else if ((0, _stryke_json.isStandardJsonSchema)(ctx.module.args)) jsonSchema = ctx.module.args["~standard"].jsonSchema.input({ target: "draft-07" });
109
- else jsonSchema = ctx.module.args;
110
- if (!(0, _stryke_json.isJsonSchema7TupleType)(jsonSchema)) throw new TypeError(`Command arguments for command at path "${ctx.input.command.path}" must be defined as a Zod tuple schema, a standard JSON Schema tuple object, or a JSON Schema tuple object.`);
111
- ctx.output.args = jsonSchema.items.map(__assignType((item) => resolveCommandArgument(item), [
112
- "item",
113
- "",
114
- "P\"2!\"/\""
115
- ]));
116
- } else if (Object.values(ctx.module.args).every(require_type_checks.isCommandParameterConfig)) ctx.output.args = ctx.module.args.map(__assignType((arg) => ({
117
- ...arg,
118
- alias: (0, _stryke_convert_to_array.toArray)(arg.alias)
119
- }), [
120
- "arg",
121
- "",
122
- "P\"2!\"/\""
123
- ]));
124
- else throw new TypeError(`Command arguments for command at path "${ctx.input.command.path}" must be defined as a record of valid CommandArgument objects, a Zod tuple schema, or a standard JSON Schema tuple object.`);
125
- }
126
- resolveFromExports.__type = [
127
- "ResolverContext",
128
- "ctx",
129
- "resolveFromExports",
130
- "P\"w!2\"\"/#"
131
- ];
132
- function validateExports(ctx) {
133
- if (!ctx.module) throw new Error(`Command module at path "${ctx.input.command.path}" is undefined or null. Please ensure the module exports a valid command.`);
134
- else if (!(0, _stryke_type_checks_is_set_object.isSetObject)(ctx.module)) throw new TypeError(`Command module at path "${ctx.input.command.path}" is not an object. Please ensure the module exports a valid command.`);
135
- else if (!("default" in ctx.module)) throw new Error(`Command module at path "${ctx.input.command.path}" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`);
136
- }
137
- validateExports.__type = [
138
- "ResolverContext",
139
- "ctx",
140
- "validateExports",
141
- "P\"w!2\"\"/#"
142
- ];
143
-
144
- //#endregion
145
- exports.resolveFromExports = resolveFromExports;