@navios/commander 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +72 -0
- package/dist/src/commander.factory.d.mts +5 -0
- package/dist/src/commander.factory.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +26 -0
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts +34 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/index.d.mts +3 -0
- package/dist/src/legacy-compat/decorators/index.d.mts.map +1 -0
- package/dist/src/legacy-compat/index.d.mts +28 -0
- package/dist/src/legacy-compat/index.d.mts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/cli-module.decorator-CkP22084.cjs +71 -0
- package/lib/cli-module.decorator-CkP22084.cjs.map +1 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts +411 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts.map +1 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts +213 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts.map +1 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs +66 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs.map +1 -0
- package/lib/command.decorator-DVLSAqYZ.mjs +135 -0
- package/lib/command.decorator-DVLSAqYZ.mjs.map +1 -0
- package/lib/command.decorator-UrNJmQN0.cjs +176 -0
- package/lib/command.decorator-UrNJmQN0.cjs.map +1 -0
- package/lib/{help-command.token-BPEgaaxY.mjs → help-command.token-C0Kgj60o.mjs} +3 -134
- package/lib/help-command.token-C0Kgj60o.mjs.map +1 -0
- package/lib/{help-command.token-DcvTjwbA.cjs → help-command.token-CMWYI6em.cjs} +1 -174
- package/lib/help-command.token-CMWYI6em.cjs.map +1 -0
- package/lib/{help.command-D9lsIDIe.cjs → help.command-DQyv6ali.cjs} +4 -3
- package/lib/{help.command-DtokRzad.mjs.map → help.command-DQyv6ali.cjs.map} +1 -1
- package/lib/{help.command-DtokRzad.mjs → help.command-dtZbhq0w.mjs} +3 -2
- package/lib/{help.command-D9lsIDIe.cjs.map → help.command-dtZbhq0w.mjs.map} +1 -1
- package/lib/index.cjs +19 -76
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +7 -209
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +7 -407
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +7 -64
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +108 -0
- package/lib/legacy-compat/index.cjs.map +1 -0
- package/lib/legacy-compat/index.d.cts +63 -0
- package/lib/legacy-compat/index.d.cts.map +1 -0
- package/lib/legacy-compat/index.d.mts +63 -0
- package/lib/legacy-compat/index.d.mts.map +1 -0
- package/lib/legacy-compat/index.mjs +101 -0
- package/lib/legacy-compat/index.mjs.map +1 -0
- package/package.json +11 -1
- package/src/commander.factory.mts +10 -0
- package/src/legacy-compat/decorators/cli-module.decorator.mts +46 -0
- package/src/legacy-compat/decorators/command.decorator.mts +46 -0
- package/src/legacy-compat/decorators/index.mts +2 -0
- package/src/legacy-compat/index.mts +31 -0
- package/tsdown.config.mts +1 -1
- package/lib/help-command.token-BPEgaaxY.mjs.map +0 -1
- package/lib/help-command.token-DcvTjwbA.cjs.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { i as CommandOptions, n as CliModuleOptions } from "../cli-module.decorator-DVl8009Q.cjs";
|
|
2
|
+
import { ClassType } from "@navios/core";
|
|
3
|
+
export * from "@navios/core/legacy-compat";
|
|
4
|
+
|
|
5
|
+
//#region src/legacy-compat/decorators/command.decorator.d.mts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Legacy-compatible Command decorator.
|
|
9
|
+
*
|
|
10
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
11
|
+
*
|
|
12
|
+
* @param options - Command configuration options
|
|
13
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { Command, CommandHandler } from '@navios/commander/legacy-compat'
|
|
18
|
+
* import { z } from 'zod'
|
|
19
|
+
*
|
|
20
|
+
* const optionsSchema = z.object({
|
|
21
|
+
* name: z.string(),
|
|
22
|
+
* greeting: z.string().optional().default('Hello')
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* @Command({
|
|
26
|
+
* path: 'greet',
|
|
27
|
+
* optionsSchema: optionsSchema
|
|
28
|
+
* })
|
|
29
|
+
* export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
|
|
30
|
+
* async execute(options) {
|
|
31
|
+
* console.log(`${options.greeting}, ${options.name}!`)
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function Command(options: CommandOptions): (target: ClassType) => any;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/legacy-compat/decorators/cli-module.decorator.d.mts
|
|
39
|
+
/**
|
|
40
|
+
* Legacy-compatible CliModule decorator.
|
|
41
|
+
*
|
|
42
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
43
|
+
*
|
|
44
|
+
* @param options - CLI module configuration options
|
|
45
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { CliModule } from '@navios/commander/legacy-compat'
|
|
50
|
+
* import { GreetCommand } from './greet.command'
|
|
51
|
+
* import { UserModule } from './user.module'
|
|
52
|
+
*
|
|
53
|
+
* @CliModule({
|
|
54
|
+
* commands: [GreetCommand],
|
|
55
|
+
* imports: [UserModule]
|
|
56
|
+
* })
|
|
57
|
+
* export class AppModule {}
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function CliModule(options?: CliModuleOptions): (target: ClassType) => ClassType;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CliModule, type CliModuleOptions, Command, type CommandOptions };
|
|
63
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["ClassType","CommandOptions","Command","ClassType","CliModuleOptions","CliModule"],"sources":["../../src/legacy-compat/decorators/command.decorator.d.mts","../../src/legacy-compat/decorators/cli-module.decorator.d.mts"],"sourcesContent":["import type { ClassType } from '@navios/core';\nimport { type CommandOptions } from '../../decorators/command.decorator.mjs';\nexport type { CommandOptions };\n/**\n * Legacy-compatible Command decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Command configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander/legacy-compat'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command(options: CommandOptions): (target: ClassType) => any;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType } from '@navios/core';\nimport { type CliModuleOptions } from '../../decorators/cli-module.decorator.mjs';\nexport type { CliModuleOptions };\n/**\n * Legacy-compatible CliModule decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - CLI module configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander/legacy-compat'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule(options?: CliModuleOptions): (target: ClassType) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map"],"mappings":";;;;;;;;;AAgCA;;;;ACRA;;;;;;;;;;;;;;;;;;;;;;iBDQwBE,OAAAA,UAAiBD,0BAA0BD;;;;;;AAAnE;;;;ACRA;;;;;;;;;;;;;;iBAAwBK,SAAAA,WAAoBD,4BAA4BD,cAAcA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { i as CommandOptions, n as CliModuleOptions } from "../cli-module.decorator-DGuGfpex.mjs";
|
|
2
|
+
import { ClassType } from "@navios/core";
|
|
3
|
+
export * from "@navios/core/legacy-compat";
|
|
4
|
+
|
|
5
|
+
//#region src/legacy-compat/decorators/command.decorator.d.mts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Legacy-compatible Command decorator.
|
|
9
|
+
*
|
|
10
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
11
|
+
*
|
|
12
|
+
* @param options - Command configuration options
|
|
13
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { Command, CommandHandler } from '@navios/commander/legacy-compat'
|
|
18
|
+
* import { z } from 'zod'
|
|
19
|
+
*
|
|
20
|
+
* const optionsSchema = z.object({
|
|
21
|
+
* name: z.string(),
|
|
22
|
+
* greeting: z.string().optional().default('Hello')
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* @Command({
|
|
26
|
+
* path: 'greet',
|
|
27
|
+
* optionsSchema: optionsSchema
|
|
28
|
+
* })
|
|
29
|
+
* export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
|
|
30
|
+
* async execute(options) {
|
|
31
|
+
* console.log(`${options.greeting}, ${options.name}!`)
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function Command(options: CommandOptions): (target: ClassType) => any;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/legacy-compat/decorators/cli-module.decorator.d.mts
|
|
39
|
+
/**
|
|
40
|
+
* Legacy-compatible CliModule decorator.
|
|
41
|
+
*
|
|
42
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
43
|
+
*
|
|
44
|
+
* @param options - CLI module configuration options
|
|
45
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { CliModule } from '@navios/commander/legacy-compat'
|
|
50
|
+
* import { GreetCommand } from './greet.command'
|
|
51
|
+
* import { UserModule } from './user.module'
|
|
52
|
+
*
|
|
53
|
+
* @CliModule({
|
|
54
|
+
* commands: [GreetCommand],
|
|
55
|
+
* imports: [UserModule]
|
|
56
|
+
* })
|
|
57
|
+
* export class AppModule {}
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function CliModule(options?: CliModuleOptions): (target: ClassType) => ClassType;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CliModule, type CliModuleOptions, Command, type CommandOptions };
|
|
63
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["ClassType","CommandOptions","Command","ClassType","CliModuleOptions","CliModule"],"sources":["../../src/legacy-compat/decorators/command.decorator.d.mts","../../src/legacy-compat/decorators/cli-module.decorator.d.mts"],"sourcesContent":["import type { ClassType } from '@navios/core';\nimport { type CommandOptions } from '../../decorators/command.decorator.mjs';\nexport type { CommandOptions };\n/**\n * Legacy-compatible Command decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Command configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander/legacy-compat'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command(options: CommandOptions): (target: ClassType) => any;\n//# sourceMappingURL=command.decorator.d.mts.map","import type { ClassType } from '@navios/core';\nimport { type CliModuleOptions } from '../../decorators/cli-module.decorator.mjs';\nexport type { CliModuleOptions };\n/**\n * Legacy-compatible CliModule decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - CLI module configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander/legacy-compat'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule(options?: CliModuleOptions): (target: ClassType) => ClassType;\n//# sourceMappingURL=cli-module.decorator.d.mts.map"],"mappings":";;;;;;;;;AAgCA;;;;ACRA;;;;;;;;;;;;;;;;;;;;;;iBDQwBE,OAAAA,UAAiBD,0BAA0BD;;;;;;AAAnE;;;;ACRA;;;;;;;;;;;;;;iBAAwBK,SAAAA,WAAoBD,4BAA4BD,cAAcA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { t as Command$1 } from "../command.decorator-DVLSAqYZ.mjs";
|
|
2
|
+
import { t as CliModule$1 } from "../cli-module.decorator-UGbtkRYc.mjs";
|
|
3
|
+
|
|
4
|
+
export * from "@navios/core/legacy-compat"
|
|
5
|
+
|
|
6
|
+
//#region ../../node_modules/@navios/di/lib/legacy-compat/index.mjs
|
|
7
|
+
/**
|
|
8
|
+
* Compatibility layer for converting legacy decorator signatures to Stage 3 format.
|
|
9
|
+
*
|
|
10
|
+
* This module provides utilities to create mock Stage 3 decorator contexts
|
|
11
|
+
* from legacy decorator arguments, and manages metadata storage using WeakMap.
|
|
12
|
+
*/ const classMetadataMap = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
/**
|
|
14
|
+
* Creates a mock ClassDecoratorContext for legacy class decorators.
|
|
15
|
+
* @internal
|
|
16
|
+
*/ function createClassContext(target) {
|
|
17
|
+
if (!classMetadataMap.has(target)) classMetadataMap.set(target, {});
|
|
18
|
+
const metadata = classMetadataMap.get(target);
|
|
19
|
+
return {
|
|
20
|
+
kind: "class",
|
|
21
|
+
name: target.name,
|
|
22
|
+
metadata,
|
|
23
|
+
addInitializer() {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/legacy-compat/decorators/command.decorator.mts
|
|
29
|
+
/**
|
|
30
|
+
* Legacy-compatible Command decorator.
|
|
31
|
+
*
|
|
32
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
33
|
+
*
|
|
34
|
+
* @param options - Command configuration options
|
|
35
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { Command, CommandHandler } from '@navios/commander/legacy-compat'
|
|
40
|
+
* import { z } from 'zod'
|
|
41
|
+
*
|
|
42
|
+
* const optionsSchema = z.object({
|
|
43
|
+
* name: z.string(),
|
|
44
|
+
* greeting: z.string().optional().default('Hello')
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* @Command({
|
|
48
|
+
* path: 'greet',
|
|
49
|
+
* optionsSchema: optionsSchema
|
|
50
|
+
* })
|
|
51
|
+
* export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
|
|
52
|
+
* async execute(options) {
|
|
53
|
+
* console.log(`${options.greeting}, ${options.name}!`)
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/ function Command(options) {
|
|
58
|
+
return function(target) {
|
|
59
|
+
const context = createClassContext(target);
|
|
60
|
+
return Command$1(options)(target, context);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/legacy-compat/decorators/cli-module.decorator.mts
|
|
66
|
+
/**
|
|
67
|
+
* Legacy-compatible CliModule decorator.
|
|
68
|
+
*
|
|
69
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
70
|
+
*
|
|
71
|
+
* @param options - CLI module configuration options
|
|
72
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { CliModule } from '@navios/commander/legacy-compat'
|
|
77
|
+
* import { GreetCommand } from './greet.command'
|
|
78
|
+
* import { UserModule } from './user.module'
|
|
79
|
+
*
|
|
80
|
+
* @CliModule({
|
|
81
|
+
* commands: [GreetCommand],
|
|
82
|
+
* imports: [UserModule]
|
|
83
|
+
* })
|
|
84
|
+
* export class AppModule {}
|
|
85
|
+
* ```
|
|
86
|
+
*/ function CliModule(options = {
|
|
87
|
+
commands: [],
|
|
88
|
+
controllers: [],
|
|
89
|
+
imports: [],
|
|
90
|
+
guards: [],
|
|
91
|
+
overrides: []
|
|
92
|
+
}) {
|
|
93
|
+
return function(target) {
|
|
94
|
+
const context = createClassContext(target);
|
|
95
|
+
return CliModule$1(options)(target, context);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { CliModule, Command };
|
|
101
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["createClassContext","Command","OriginalCommand","options","target","context","originalDecorator","createClassContext","CliModule","OriginalCliModule","options","commands","controllers","imports","guards","overrides","target","context","originalDecorator"],"sources":["../../../../node_modules/@navios/di/lib/legacy-compat/index.mjs","../../src/legacy-compat/decorators/command.decorator.mts","../../src/legacy-compat/decorators/cli-module.decorator.mts"],"sourcesContent":["import { t as Injectable$1 } from \"../injectable.decorator-CyPrBzBN.mjs\";\nimport { t as Factory$1 } from \"../factory.decorator-_IPWcwQn.mjs\";\n\n//#region src/legacy-compat/context-compat.mts\n/**\n* Compatibility layer for converting legacy decorator signatures to Stage 3 format.\n*\n* This module provides utilities to create mock Stage 3 decorator contexts\n* from legacy decorator arguments, and manages metadata storage using WeakMap.\n*/ const classMetadataMap = /* @__PURE__ */ new WeakMap();\n/**\n* Gets the constructor from a prototype (for method decorators).\n*/ function getConstructor(prototype) {\n\tif (!prototype || typeof prototype !== \"object\") return null;\n\tconst constructor = prototype.constructor;\n\tif (constructor && typeof constructor === \"function\") return constructor;\n\treturn null;\n}\n/**\n* Creates a mock ClassDecoratorContext for legacy class decorators.\n* @internal\n*/ function createClassContext(target) {\n\tif (!classMetadataMap.has(target)) classMetadataMap.set(target, {});\n\tconst metadata = classMetadataMap.get(target);\n\treturn {\n\t\tkind: \"class\",\n\t\tname: target.name,\n\t\tmetadata,\n\t\taddInitializer() {}\n\t};\n}\n/**\n* Creates a mock ClassMethodDecoratorContext for legacy method decorators.\n*\n* Note: Method decorators need to share metadata with the class context\n* because endpoint metadata is stored at the class level.\n* @internal\n*/ function createMethodContext(target, propertyKey, descriptor) {\n\tconst constructor = getConstructor(target);\n\tif (!constructor) throw new Error(\"[Navios] Could not determine class constructor from method decorator target.\");\n\tif (!classMetadataMap.has(constructor)) classMetadataMap.set(constructor, {});\n\treturn {\n\t\tkind: \"method\",\n\t\tname: propertyKey,\n\t\tmetadata: classMetadataMap.get(constructor),\n\t\tstatic: false,\n\t\tprivate: false,\n\t\taccess: {\n\t\t\thas: () => true,\n\t\t\tget: () => descriptor.value,\n\t\t\tset: () => {}\n\t\t},\n\t\taddInitializer() {}\n\t};\n}\n\n//#endregion\n//#region src/legacy-compat/injectable.decorator.mts\n/**\n* Legacy-compatible Injectable decorator.\n*\n* Works with TypeScript experimental decorators (legacy API).\n*\n* @param options - Injectable configuration options\n* @returns A class decorator compatible with legacy decorator API\n*\n* @example\n* ```typescript\n* @Injectable()\n* export class UserService {\n* getUser(id: string) {\n* return { id, name: 'John' }\n* }\n* }\n* ```\n*/ function Injectable(options = {}) {\n\treturn function(target) {\n\t\tconst context = createClassContext(target);\n\t\treturn (Object.keys(options).length === 0 ? Injectable$1() : Injectable$1(options))(target, context);\n\t};\n}\n\n//#endregion\n//#region src/legacy-compat/factory.decorator.mts\n/**\n* Legacy-compatible Factory decorator.\n*\n* Works with TypeScript experimental decorators (legacy API).\n*\n* @param options - Factory configuration options\n* @returns A class decorator compatible with legacy decorator API\n*\n* @example\n* ```typescript\n* @Factory()\n* export class DatabaseConnectionFactory {\n* create() {\n* return { host: 'localhost', port: 5432 }\n* }\n* }\n* ```\n*/ function Factory(options = {}) {\n\treturn function(target) {\n\t\tconst context = createClassContext(target);\n\t\treturn (Object.keys(options).length === 0 ? Factory$1() : Factory$1(options))(target, context);\n\t};\n}\n\n//#endregion\nexport { Factory, Injectable, createClassContext, createMethodContext };\n//# sourceMappingURL=index.mjs.map","import type { ClassType } from '@navios/core'\nimport { createClassContext } from '@navios/di/legacy-compat'\n\nimport {\n Command as OriginalCommand,\n type CommandOptions,\n} from '../../decorators/command.decorator.mjs'\n\nexport type { CommandOptions }\n\n/**\n * Legacy-compatible Command decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Command configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander/legacy-compat'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport function Command(options: CommandOptions) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n const originalDecorator = OriginalCommand(options)\n return originalDecorator(target, context)\n }\n}\n","import type { ClassType } from '@navios/core'\nimport { createClassContext } from '@navios/di/legacy-compat'\n\nimport {\n CliModule as OriginalCliModule,\n type CliModuleOptions,\n} from '../../decorators/cli-module.decorator.mjs'\n\nexport type { CliModuleOptions }\n\n/**\n * Legacy-compatible CliModule decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - CLI module configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander/legacy-compat'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n */\nexport function CliModule(\n options: CliModuleOptions = {\n commands: [],\n controllers: [],\n imports: [],\n guards: [],\n overrides: [],\n },\n) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n const originalDecorator = OriginalCliModule(options)\n return originalDecorator(target, context)\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;GASG,MAAM,mCAAmC,IAAI,SAAS;;;;GAYtD,SAAS,mBAAmB,QAAQ;AACtC,KAAI,CAAC,iBAAiB,IAAI,OAAO,CAAE,kBAAiB,IAAI,QAAQ,EAAE,CAAC;CACnE,MAAM,WAAW,iBAAiB,IAAI,OAAO;AAC7C,QAAO;EACN,MAAM;EACN,MAAM,OAAO;EACb;EACA,iBAAiB;EACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCUF,SAAgBC,QAAQE,SAAuB;AAC7C,QAAO,SAAUC,QAAiB;EAChC,MAAMC,UAAUL,mBAAmBI,OAAAA;AAEnC,SAD0BF,UAAgBC,QAAAA,CACjBC,QAAQC,QAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GCZrC,SAAgBG,UACdE,UAA4B;CAC1BC,UAAU,EAAE;CACZC,aAAa,EAAE;CACfC,SAAS,EAAE;CACXC,QAAQ,EAAE;CACVC,WAAW,EAAE;CACd,EAAA;AAED,QAAO,SAAUC,QAAiB;EAChC,MAAMC,UAAUV,mBAAmBS,OAAAA;AAEnC,SAD0BP,YAAkBC,QAAAA,CACnBM,QAAQC,QAAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/commander",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Oleksandr Hanzha",
|
|
6
6
|
"email": "alex@granted.name"
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
"types": "./lib/index.d.cts",
|
|
34
34
|
"default": "./lib/index.cjs"
|
|
35
35
|
}
|
|
36
|
+
},
|
|
37
|
+
"./legacy-compat": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./lib/legacy-compat/index.d.mts",
|
|
40
|
+
"default": "./lib/legacy-compat/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./lib/legacy-compat/index.d.cts",
|
|
44
|
+
"default": "./lib/legacy-compat/index.cjs"
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
},
|
|
38
48
|
"devDependencies": {
|
|
@@ -62,6 +62,11 @@ export interface CommanderTuiOptions {
|
|
|
62
62
|
* @default true
|
|
63
63
|
*/
|
|
64
64
|
exitOnCtrlC?: boolean
|
|
65
|
+
/**
|
|
66
|
+
* Adapter to use for the TUI.
|
|
67
|
+
* @default 'react'
|
|
68
|
+
*/
|
|
69
|
+
adapter?: 'react' | 'solid'
|
|
65
70
|
/**
|
|
66
71
|
* Sidebar width in columns.
|
|
67
72
|
*/
|
|
@@ -178,6 +183,11 @@ export class CommanderFactory {
|
|
|
178
183
|
options: CommanderFactoryOptions = {},
|
|
179
184
|
): Promise<NaviosApplication<CliEnvironment>> {
|
|
180
185
|
if (options.enableTUI) {
|
|
186
|
+
if (options.tuiOptions?.adapter === 'solid') {
|
|
187
|
+
await import('@navios/commander-tui/adapters/solid')
|
|
188
|
+
} else {
|
|
189
|
+
await import('@navios/commander-tui/adapters/react')
|
|
190
|
+
}
|
|
181
191
|
// Dynamic import to keep commander-tui as optional peer dependency
|
|
182
192
|
let tuiModule: typeof import('@navios/commander-tui')
|
|
183
193
|
try {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClassType } from '@navios/core'
|
|
2
|
+
import { createClassContext } from '@navios/di/legacy-compat'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CliModule as OriginalCliModule,
|
|
6
|
+
type CliModuleOptions,
|
|
7
|
+
} from '../../decorators/cli-module.decorator.mjs'
|
|
8
|
+
|
|
9
|
+
export type { CliModuleOptions }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Legacy-compatible CliModule decorator.
|
|
13
|
+
*
|
|
14
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
15
|
+
*
|
|
16
|
+
* @param options - CLI module configuration options
|
|
17
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { CliModule } from '@navios/commander/legacy-compat'
|
|
22
|
+
* import { GreetCommand } from './greet.command'
|
|
23
|
+
* import { UserModule } from './user.module'
|
|
24
|
+
*
|
|
25
|
+
* @CliModule({
|
|
26
|
+
* commands: [GreetCommand],
|
|
27
|
+
* imports: [UserModule]
|
|
28
|
+
* })
|
|
29
|
+
* export class AppModule {}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function CliModule(
|
|
33
|
+
options: CliModuleOptions = {
|
|
34
|
+
commands: [],
|
|
35
|
+
controllers: [],
|
|
36
|
+
imports: [],
|
|
37
|
+
guards: [],
|
|
38
|
+
overrides: [],
|
|
39
|
+
},
|
|
40
|
+
) {
|
|
41
|
+
return function (target: ClassType) {
|
|
42
|
+
const context = createClassContext(target)
|
|
43
|
+
const originalDecorator = OriginalCliModule(options)
|
|
44
|
+
return originalDecorator(target, context)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClassType } from '@navios/core'
|
|
2
|
+
import { createClassContext } from '@navios/di/legacy-compat'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Command as OriginalCommand,
|
|
6
|
+
type CommandOptions,
|
|
7
|
+
} from '../../decorators/command.decorator.mjs'
|
|
8
|
+
|
|
9
|
+
export type { CommandOptions }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Legacy-compatible Command decorator.
|
|
13
|
+
*
|
|
14
|
+
* Works with TypeScript experimental decorators (legacy API).
|
|
15
|
+
*
|
|
16
|
+
* @param options - Command configuration options
|
|
17
|
+
* @returns A class decorator compatible with legacy decorator API
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Command, CommandHandler } from '@navios/commander/legacy-compat'
|
|
22
|
+
* import { z } from 'zod'
|
|
23
|
+
*
|
|
24
|
+
* const optionsSchema = z.object({
|
|
25
|
+
* name: z.string(),
|
|
26
|
+
* greeting: z.string().optional().default('Hello')
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* @Command({
|
|
30
|
+
* path: 'greet',
|
|
31
|
+
* optionsSchema: optionsSchema
|
|
32
|
+
* })
|
|
33
|
+
* export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
|
|
34
|
+
* async execute(options) {
|
|
35
|
+
* console.log(`${options.greeting}, ${options.name}!`)
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function Command(options: CommandOptions) {
|
|
41
|
+
return function (target: ClassType) {
|
|
42
|
+
const context = createClassContext(target)
|
|
43
|
+
const originalDecorator = OriginalCommand(options)
|
|
44
|
+
return originalDecorator(target, context)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy-compatible decorators for projects using TypeScript experimental decorators.
|
|
3
|
+
*
|
|
4
|
+
* These decorators wrap the Stage 3 decorator implementations and convert
|
|
5
|
+
* the legacy decorator arguments to Stage 3 format internally.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Command, CliModule, CommandHandler } from '@navios/commander/legacy-compat'
|
|
10
|
+
*
|
|
11
|
+
* @Command({ path: 'greet' })
|
|
12
|
+
* export class GreetCommand implements CommandHandler {
|
|
13
|
+
* async execute() {
|
|
14
|
+
* console.log('Hello!')
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* @CliModule({
|
|
19
|
+
* commands: [GreetCommand],
|
|
20
|
+
* })
|
|
21
|
+
* export class AppModule {}
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// Export legacy-compatible decorators (commander-specific)
|
|
28
|
+
export * from './decorators/index.mjs'
|
|
29
|
+
|
|
30
|
+
// Re-export core/DI legacy-compat utilities for convenience
|
|
31
|
+
export * from '@navios/core/legacy-compat'
|
package/tsdown.config.mts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help-command.token-BPEgaaxY.mjs","names":["CommandMetadataKey","Symbol","getCommandMetadata","target","context","path","description","optionsSchema","metadata","newMetadata","customAttributes","Map","Error","extractCommandMetadata","hasCommandMetadata","extractModuleMetadata","CommandEntryKey","Symbol","extractModuleCommands","moduleClass","metadata","customEntries","get","Set","Injectable","InjectableScope","InjectionToken","getCommandMetadata","Command","path","description","token","optionsSchema","priority","registry","target","context","kind","Error","tokenToUse","create","metadata","scope","Singleton","Injectable","CommandRegistryService","commands","Map","register","path","command","has","Error","set","getByPath","get","getAll","getAllAsArray","result","class","cls","push","formatCommandList","lines","metadata","description","padEnd","join","formatCommandHelp","commandPath","optionsSchema","shape","def","key","fieldSchema","Object","entries","kebabKey","replace","toLowerCase","optionFlag","fieldType","getSchemaTypeName","schema","currentSchema","typeName","type","isOptional","defaultValue","innerType","undefined","JSON","stringify","getSchemaMeta","directMeta","meta","clear","InjectionToken","HelpCommandToken","create"],"sources":["../src/metadata/command.metadata.mts","../src/metadata/command-entry.metadata.mts","../src/decorators/command.decorator.mts","../src/services/command-registry.service.mts","../src/tokens/help-command.token.mts"],"sourcesContent":["import type { ClassType } from '@navios/core'\nimport type { ZodObject } from 'zod'\n\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport const CommandMetadataKey = Symbol('CommandMetadataKey')\n\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string\n /**\n * Optional description of the command for help text.\n */\n description?: string\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>\n}\n\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param description - Optional description for help text\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport function getCommandMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n path: string,\n description?: string,\n optionsSchema?: ZodObject,\n): CommandMetadata {\n if (context.metadata) {\n const metadata = context.metadata[CommandMetadataKey] as\n | CommandMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const newMetadata: CommandMetadata = {\n path,\n description,\n optionsSchema,\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[CommandMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[CommandMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios Commander] Wrong environment.')\n}\n\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport function extractCommandMetadata(target: ClassType): CommandMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[CommandMetadataKey] as CommandMetadata | undefined\n if (!metadata) {\n throw new Error(\n '[Navios Commander] Command metadata not found. Make sure to use @Command decorator.',\n )\n }\n return metadata\n}\n\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport function hasCommandMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[CommandMetadataKey] as CommandMetadata | undefined\n return !!metadata\n}\n","import type { ClassType } from '@navios/core'\n\nimport { extractModuleMetadata } from '@navios/core'\n\n/**\n * Symbol key for storing commands in ModuleMetadata.customEntries.\n * Used by @CliModule to store command classes.\n *\n * @public\n */\nexport const CommandEntryKey = Symbol('CommandEntryKey')\n\n/**\n * Type for the command entry value stored in customEntries.\n *\n * @public\n */\nexport type CommandEntryValue = Set<ClassType>\n\n/**\n * Extracts commands from a module's metadata.\n * Returns empty set if no commands are defined.\n *\n * @param moduleClass - The module class decorated with @CliModule or @Module\n * @returns Set of command classes registered in the module\n *\n * @example\n * ```typescript\n * const commands = extractModuleCommands(AppModule)\n * for (const command of commands) {\n * console.log(command.name)\n * }\n * ```\n */\nexport function extractModuleCommands(moduleClass: ClassType): Set<ClassType> {\n const metadata = extractModuleMetadata(moduleClass)\n return (\n (metadata.customEntries.get(CommandEntryKey) as CommandEntryValue) ??\n new Set()\n )\n}\n","import { Injectable, InjectableScope, InjectionToken } from '@navios/core'\n\nimport type { ClassType, ClassTypeWithInstance, Registry } from '@navios/core'\nimport type { ZodObject } from 'zod'\n\nimport { getCommandMetadata } from '../metadata/index.mjs'\n\nimport type { CommandHandler } from '../interfaces/index.mjs'\n\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The token to use for the command.\n * If provided, the command will be registered with this token.\n */\n token?: InjectionToken<ClassTypeWithInstance<CommandHandler<any>>>\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string\n /**\n * Optional description of the command for help text.\n * Displayed when users run `help` or `--help`.\n */\n description?: string\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject\n /**\n * Priority level for the command.\n * Higher priority commands will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the command.\n * Registry is used to store the command and its options schema.\n */\n registry?: Registry\n}\n\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport function Command({\n path,\n description,\n token,\n optionsSchema,\n priority,\n registry,\n}: CommandOptions) {\n return function (target: ClassType, context: ClassDecoratorContext) {\n if (context.kind !== 'class') {\n throw new Error('[Navios Commander] @Command decorator can only be used on classes.')\n }\n const tokenToUse =\n token ?? InjectionToken.create<ClassTypeWithInstance<CommandHandler<any>>>(target)\n\n if (context.metadata) {\n getCommandMetadata(target, context, path, description, optionsSchema)\n }\n // @ts-expect-error Injectable is callable\n return Injectable({\n token: tokenToUse,\n scope: InjectableScope.Singleton,\n priority,\n registry,\n })(target, context)\n }\n}\n","import type { ClassType } from '@navios/core'\n\nimport { Injectable } from '@navios/core'\n\nimport type { CommandMetadata } from '../metadata/index.mjs'\n\n/**\n * Represents a registered command with its metadata and module information.\n *\n * @public\n */\nexport interface RegisteredCommand {\n /**\n * The command class\n */\n class: ClassType\n /**\n * The command metadata from @Command decorator\n */\n metadata: CommandMetadata\n /**\n * Name of the module this command belongs to\n */\n moduleName: string\n}\n\n/**\n * Service for registering and looking up CLI commands.\n * Used internally by the CLI adapter to manage discovered commands.\n *\n * @public\n */\n@Injectable()\nexport class CommandRegistryService {\n private commands = new Map<string, RegisteredCommand>()\n\n /**\n * Register a command with its metadata.\n *\n * @param path - The command path (e.g., 'greet', 'user:create')\n * @param command - The registered command data\n * @throws Error if a command with the same path is already registered\n */\n register(path: string, command: RegisteredCommand): void {\n if (this.commands.has(path)) {\n throw new Error(`[Navios Commander] Duplicate command path: ${path}`)\n }\n this.commands.set(path, command)\n }\n\n /**\n * Get a command by its path.\n *\n * @param path - The command path\n * @returns The registered command or undefined if not found\n */\n getByPath(path: string): RegisteredCommand | undefined {\n return this.commands.get(path)\n }\n\n /**\n * Get all registered commands.\n *\n * @returns Map of path to registered command\n */\n getAll(): Map<string, RegisteredCommand> {\n return new Map(this.commands)\n }\n\n /**\n * Get all registered commands as an array of path and class pairs.\n * Useful for listing available commands.\n *\n * @returns Array of objects containing path and class\n */\n getAllAsArray(): Array<{ path: string; class: ClassType }> {\n const result: Array<{ path: string; class: ClassType }> = []\n for (const [path, { class: cls }] of this.commands) {\n result.push({ path, class: cls })\n }\n return result\n }\n\n /**\n * Formats help text listing all available commands with descriptions.\n *\n * @returns Formatted string listing all commands\n */\n formatCommandList(): string {\n const lines = ['Available commands:', '']\n for (const [path, { metadata }] of this.commands) {\n const description = metadata.description\n if (description) {\n lines.push(` ${path.padEnd(20)} ${description}`)\n } else {\n lines.push(` ${path}`)\n }\n }\n return lines.join('\\n')\n }\n\n /**\n * Formats help text for a specific command.\n *\n * @param commandPath - The command path to show help for\n * @returns Formatted string with command help\n */\n formatCommandHelp(commandPath: string): string {\n const command = this.commands.get(commandPath)\n if (!command) {\n return `Unknown command: ${commandPath}\\n\\n${this.formatCommandList()}`\n }\n\n const { metadata } = command\n const lines: string[] = []\n\n lines.push(`Usage: ${metadata.path} [options]`)\n lines.push('')\n\n if (metadata.description) {\n lines.push(metadata.description)\n lines.push('')\n }\n\n // Extract options from schema if available\n if (metadata.optionsSchema) {\n lines.push('Options:')\n try {\n const shape = metadata.optionsSchema.def.shape\n if (shape && typeof shape === 'object') {\n for (const [key, fieldSchema] of Object.entries(shape)) {\n const kebabKey = key.replace(/([A-Z])/g, '-$1').toLowerCase()\n const optionFlag = `--${kebabKey}`\n const fieldType = this.getSchemaTypeName(fieldSchema as any)\n lines.push(` ${optionFlag.padEnd(20)} ${fieldType}`)\n }\n }\n } catch {\n // Schema introspection failed, skip options\n }\n }\n\n return lines.join('\\n')\n }\n\n /**\n * Gets a human-readable type name from a Zod schema.\n */\n private getSchemaTypeName(schema: any): string {\n try {\n let currentSchema = schema\n let typeName = currentSchema?.def?.type\n let isOptional = false\n let defaultValue: any\n\n // Unwrap optional/default wrappers\n while (typeName === 'optional' || typeName === 'default') {\n if (typeName === 'optional') {\n isOptional = true\n }\n if (typeName === 'default') {\n isOptional = true\n defaultValue = currentSchema?.def?.defaultValue?.()\n }\n currentSchema = currentSchema?.def?.innerType\n typeName = currentSchema?.def?.type\n }\n\n let result = `<${typeName || 'unknown'}>`\n if (defaultValue !== undefined) {\n result += ` (default: ${JSON.stringify(defaultValue)})`\n } else if (isOptional) {\n result += ' (optional)'\n }\n\n // Get description from meta() if available\n const description = this.getSchemaMeta(schema)?.description\n if (description) {\n result += ` - ${description}`\n }\n\n return result\n } catch {\n return '<unknown>'\n }\n }\n\n /**\n * Gets metadata from a Zod schema, traversing innerType if needed.\n * Zod v4 stores meta at the outermost layer when .meta() is called last,\n * or in innerType when .meta() is called before .optional()/.default().\n */\n private getSchemaMeta(schema: any): Record<string, unknown> | undefined {\n try {\n // First check direct meta (when .meta() is called last in chain)\n const directMeta = schema.meta?.()\n if (directMeta) return directMeta\n\n // Check innerType for wrapped schemas (optional, default, etc.)\n const innerType = schema.def?.innerType\n if (innerType) {\n return this.getSchemaMeta(innerType)\n }\n\n return undefined\n } catch {\n return undefined\n }\n }\n\n /**\n * Clear all registered commands.\n */\n clear(): void {\n this.commands.clear()\n }\n}\n","import { InjectionToken } from '@navios/core'\n\nimport type { HelpCommand } from '../overrides/help.command.mjs'\n\nexport const HelpCommandToken = InjectionToken.create<HelpCommand>('HelpCommand')\n"],"mappings":";;;;;;GAOA,MAAaA,qBAAqBC,OAAO,qBAAA;;;;;;;;;;;GAqCzC,SAAgBC,mBACdC,QACAC,SACAC,MACAC,aACAC,eAAyB;AAEzB,KAAIH,QAAQI,UAAU;EACpB,MAAMA,WAAWJ,QAAQI,SAASR;AAGlC,MAAIQ,SACF,QAAOA;OACF;GACL,MAAMC,cAA+B;IACnCJ;IACAC;IACAC;IACAG,kCAAkB,IAAIC,KAAAA;IACxB;AACAP,WAAQI,SAASR,sBAAsBS;AAEvCN,UAAOH,sBAAsBS;AAC7B,UAAOA;;;AAGX,OAAM,IAAIG,MAAM,wCAAA;;;;;;;;;;;;;;GAgBlB,SAAgBC,uBAAuBV,QAAiB;CAEtD,MAAMK,WAAWL,OAAOH;AACxB,KAAI,CAACQ,SACH,OAAM,IAAII,MACR,sFAAA;AAGJ,QAAOJ;;;;;;;GAST,SAAgBM,mBAAmBX,QAAiB;AAGlD,QAAO,CAAC,CADSA,OAAOH;;;;;;;;;;GC/F1B,MAAagB,kBAAkBC,OAAO,kBAAA;;;;;;;;;;;;;;;GAwBtC,SAAgBC,sBAAsBC,aAAsB;AAE1D,QADiBJ,sBAAsBI,YAAAA,CAE3BE,cAAcC,IAAIN,gBAAAA,oBAC5B,IAAIO,KAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCuCR,SAAgBK,QAAQ,EACtBC,MACAC,aACAC,OACAC,eACAC,UACAC,YACe;AACf,QAAO,SAAUC,Q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AIA,aAAa,WACfE,cAAa;AAEf,QAAIF,aAAa,WAAW;AAC1BE,kBAAa;AACbC,oBAAeJ,eAAeZ,KAAKgB,gBAAAA;;AAErCJ,oBAAgBA,eAAeZ,KAAKiB;AACpCJ,eAAWD,eAAeZ,KAAKc;;GAGjC,IAAI5B,SAAS,IAAI2B,YAAY,UAAU;AACvC,OAAIG,iBAAiBE,OACnBhC,WAAU,cAAciC,KAAKC,UAAUJ,aAAAA,CAAc;YAC5CD,WACT7B,WAAU;GAIZ,MAAMO,cAAc,KAAK4B,cAAcV,OAAAA,EAASlB;AAChD,OAAIA,YACFP,WAAU,MAAMO;AAGlB,UAAOP;UACD;AACN,UAAO;;;;;;;IASX,cAAsByB,QAAkD;AACtE,MAAI;GAEF,MAAMW,aAAaX,OAAOY,QAAI;AAC9B,OAAID,WAAY,QAAOA;GAGvB,MAAML,YAAYN,OAAOX,KAAKiB;AAC9B,OAAIA,UACF,QAAO,KAAKI,cAAcJ,UAAAA;AAG5B;UACM;AACN;;;;;IAOJO,QAAc;AACZ,OAAKlD,SAASkD,OAAK;;;;;;;;;AClNvB,MAAaE,mBAAmBD,eAAeE,OAAoB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help-command.token-DcvTjwbA.cjs","names":["CommandMetadataKey","Symbol","getCommandMetadata","target","context","path","description","optionsSchema","metadata","newMetadata","customAttributes","Map","Error","extractCommandMetadata","hasCommandMetadata","extractModuleMetadata","CommandEntryKey","Symbol","extractModuleCommands","moduleClass","metadata","customEntries","get","Set","Injectable","InjectableScope","InjectionToken","getCommandMetadata","Command","path","description","token","optionsSchema","priority","registry","target","context","kind","Error","tokenToUse","create","metadata","scope","Singleton","Injectable","CommandRegistryService","commands","Map","register","path","command","has","Error","set","getByPath","get","getAll","getAllAsArray","result","class","cls","push","formatCommandList","lines","metadata","description","padEnd","join","formatCommandHelp","commandPath","optionsSchema","shape","def","key","fieldSchema","Object","entries","kebabKey","replace","toLowerCase","optionFlag","fieldType","getSchemaTypeName","schema","currentSchema","typeName","type","isOptional","defaultValue","innerType","undefined","JSON","stringify","getSchemaMeta","directMeta","meta","clear","InjectionToken","HelpCommandToken","create"],"sources":["../src/metadata/command.metadata.mts","../src/metadata/command-entry.metadata.mts","../src/decorators/command.decorator.mts","../src/services/command-registry.service.mts","../src/tokens/help-command.token.mts"],"sourcesContent":["import type { ClassType } from '@navios/core'\nimport type { ZodObject } from 'zod'\n\n/**\n * @internal\n * Symbol key used to store command metadata on classes.\n */\nexport const CommandMetadataKey = Symbol('CommandMetadataKey')\n\n/**\n * Metadata associated with a command.\n *\n * @public\n */\nexport interface CommandMetadata {\n /**\n * The command path (e.g., 'greet', 'user:create').\n */\n path: string\n /**\n * Optional description of the command for help text.\n */\n description?: string\n /**\n * Optional Zod schema for validating command options.\n */\n optionsSchema?: ZodObject\n /**\n * Map of custom attributes that can be attached to the command.\n */\n customAttributes: Map<string | symbol, any>\n}\n\n/**\n * Gets or creates command metadata for a class.\n *\n * @internal\n * @param target - The command class\n * @param context - The decorator context\n * @param path - The command path\n * @param description - Optional description for help text\n * @param optionsSchema - Optional Zod schema\n * @returns The command metadata\n */\nexport function getCommandMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n path: string,\n description?: string,\n optionsSchema?: ZodObject,\n): CommandMetadata {\n if (context.metadata) {\n const metadata = context.metadata[CommandMetadataKey] as\n | CommandMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const newMetadata: CommandMetadata = {\n path,\n description,\n optionsSchema,\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[CommandMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[CommandMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios Commander] Wrong environment.')\n}\n\n/**\n * Extracts command metadata from a class.\n *\n * @param target - The command class\n * @returns The command metadata\n * @throws {Error} If the class is not decorated with @Command\n *\n * @example\n * ```typescript\n * const metadata = extractCommandMetadata(GreetCommand)\n * console.log(metadata.path) // 'greet'\n * ```\n */\nexport function extractCommandMetadata(target: ClassType): CommandMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[CommandMetadataKey] as CommandMetadata | undefined\n if (!metadata) {\n throw new Error(\n '[Navios Commander] Command metadata not found. Make sure to use @Command decorator.',\n )\n }\n return metadata\n}\n\n/**\n * Checks if a class has command metadata.\n *\n * @param target - The class to check\n * @returns `true` if the class is decorated with @Command, `false` otherwise\n */\nexport function hasCommandMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[CommandMetadataKey] as CommandMetadata | undefined\n return !!metadata\n}\n","import type { ClassType } from '@navios/core'\n\nimport { extractModuleMetadata } from '@navios/core'\n\n/**\n * Symbol key for storing commands in ModuleMetadata.customEntries.\n * Used by @CliModule to store command classes.\n *\n * @public\n */\nexport const CommandEntryKey = Symbol('CommandEntryKey')\n\n/**\n * Type for the command entry value stored in customEntries.\n *\n * @public\n */\nexport type CommandEntryValue = Set<ClassType>\n\n/**\n * Extracts commands from a module's metadata.\n * Returns empty set if no commands are defined.\n *\n * @param moduleClass - The module class decorated with @CliModule or @Module\n * @returns Set of command classes registered in the module\n *\n * @example\n * ```typescript\n * const commands = extractModuleCommands(AppModule)\n * for (const command of commands) {\n * console.log(command.name)\n * }\n * ```\n */\nexport function extractModuleCommands(moduleClass: ClassType): Set<ClassType> {\n const metadata = extractModuleMetadata(moduleClass)\n return (\n (metadata.customEntries.get(CommandEntryKey) as CommandEntryValue) ??\n new Set()\n )\n}\n","import { Injectable, InjectableScope, InjectionToken } from '@navios/core'\n\nimport type { ClassType, ClassTypeWithInstance, Registry } from '@navios/core'\nimport type { ZodObject } from 'zod'\n\nimport { getCommandMetadata } from '../metadata/index.mjs'\n\nimport type { CommandHandler } from '../interfaces/index.mjs'\n\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The token to use for the command.\n * If provided, the command will be registered with this token.\n */\n token?: InjectionToken<ClassTypeWithInstance<CommandHandler<any>>>\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string\n /**\n * Optional description of the command for help text.\n * Displayed when users run `help` or `--help`.\n */\n description?: string\n /**\n * Optional Zod schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: ZodObject\n /**\n * Priority level for the command.\n * Higher priority commands will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the command.\n * Registry is used to store the command and its options schema.\n */\n registry?: Registry\n}\n\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport function Command({\n path,\n description,\n token,\n optionsSchema,\n priority,\n registry,\n}: CommandOptions) {\n return function (target: ClassType, context: ClassDecoratorContext) {\n if (context.kind !== 'class') {\n throw new Error('[Navios Commander] @Command decorator can only be used on classes.')\n }\n const tokenToUse =\n token ?? InjectionToken.create<ClassTypeWithInstance<CommandHandler<any>>>(target)\n\n if (context.metadata) {\n getCommandMetadata(target, context, path, description, optionsSchema)\n }\n // @ts-expect-error Injectable is callable\n return Injectable({\n token: tokenToUse,\n scope: InjectableScope.Singleton,\n priority,\n registry,\n })(target, context)\n }\n}\n","import type { ClassType } from '@navios/core'\n\nimport { Injectable } from '@navios/core'\n\nimport type { CommandMetadata } from '../metadata/index.mjs'\n\n/**\n * Represents a registered command with its metadata and module information.\n *\n * @public\n */\nexport interface RegisteredCommand {\n /**\n * The command class\n */\n class: ClassType\n /**\n * The command metadata from @Command decorator\n */\n metadata: CommandMetadata\n /**\n * Name of the module this command belongs to\n */\n moduleName: string\n}\n\n/**\n * Service for registering and looking up CLI commands.\n * Used internally by the CLI adapter to manage discovered commands.\n *\n * @public\n */\n@Injectable()\nexport class CommandRegistryService {\n private commands = new Map<string, RegisteredCommand>()\n\n /**\n * Register a command with its metadata.\n *\n * @param path - The command path (e.g., 'greet', 'user:create')\n * @param command - The registered command data\n * @throws Error if a command with the same path is already registered\n */\n register(path: string, command: RegisteredCommand): void {\n if (this.commands.has(path)) {\n throw new Error(`[Navios Commander] Duplicate command path: ${path}`)\n }\n this.commands.set(path, command)\n }\n\n /**\n * Get a command by its path.\n *\n * @param path - The command path\n * @returns The registered command or undefined if not found\n */\n getByPath(path: string): RegisteredCommand | undefined {\n return this.commands.get(path)\n }\n\n /**\n * Get all registered commands.\n *\n * @returns Map of path to registered command\n */\n getAll(): Map<string, RegisteredCommand> {\n return new Map(this.commands)\n }\n\n /**\n * Get all registered commands as an array of path and class pairs.\n * Useful for listing available commands.\n *\n * @returns Array of objects containing path and class\n */\n getAllAsArray(): Array<{ path: string; class: ClassType }> {\n const result: Array<{ path: string; class: ClassType }> = []\n for (const [path, { class: cls }] of this.commands) {\n result.push({ path, class: cls })\n }\n return result\n }\n\n /**\n * Formats help text listing all available commands with descriptions.\n *\n * @returns Formatted string listing all commands\n */\n formatCommandList(): string {\n const lines = ['Available commands:', '']\n for (const [path, { metadata }] of this.commands) {\n const description = metadata.description\n if (description) {\n lines.push(` ${path.padEnd(20)} ${description}`)\n } else {\n lines.push(` ${path}`)\n }\n }\n return lines.join('\\n')\n }\n\n /**\n * Formats help text for a specific command.\n *\n * @param commandPath - The command path to show help for\n * @returns Formatted string with command help\n */\n formatCommandHelp(commandPath: string): string {\n const command = this.commands.get(commandPath)\n if (!command) {\n return `Unknown command: ${commandPath}\\n\\n${this.formatCommandList()}`\n }\n\n const { metadata } = command\n const lines: string[] = []\n\n lines.push(`Usage: ${metadata.path} [options]`)\n lines.push('')\n\n if (metadata.description) {\n lines.push(metadata.description)\n lines.push('')\n }\n\n // Extract options from schema if available\n if (metadata.optionsSchema) {\n lines.push('Options:')\n try {\n const shape = metadata.optionsSchema.def.shape\n if (shape && typeof shape === 'object') {\n for (const [key, fieldSchema] of Object.entries(shape)) {\n const kebabKey = key.replace(/([A-Z])/g, '-$1').toLowerCase()\n const optionFlag = `--${kebabKey}`\n const fieldType = this.getSchemaTypeName(fieldSchema as any)\n lines.push(` ${optionFlag.padEnd(20)} ${fieldType}`)\n }\n }\n } catch {\n // Schema introspection failed, skip options\n }\n }\n\n return lines.join('\\n')\n }\n\n /**\n * Gets a human-readable type name from a Zod schema.\n */\n private getSchemaTypeName(schema: any): string {\n try {\n let currentSchema = schema\n let typeName = currentSchema?.def?.type\n let isOptional = false\n let defaultValue: any\n\n // Unwrap optional/default wrappers\n while (typeName === 'optional' || typeName === 'default') {\n if (typeName === 'optional') {\n isOptional = true\n }\n if (typeName === 'default') {\n isOptional = true\n defaultValue = currentSchema?.def?.defaultValue?.()\n }\n currentSchema = currentSchema?.def?.innerType\n typeName = currentSchema?.def?.type\n }\n\n let result = `<${typeName || 'unknown'}>`\n if (defaultValue !== undefined) {\n result += ` (default: ${JSON.stringify(defaultValue)})`\n } else if (isOptional) {\n result += ' (optional)'\n }\n\n // Get description from meta() if available\n const description = this.getSchemaMeta(schema)?.description\n if (description) {\n result += ` - ${description}`\n }\n\n return result\n } catch {\n return '<unknown>'\n }\n }\n\n /**\n * Gets metadata from a Zod schema, traversing innerType if needed.\n * Zod v4 stores meta at the outermost layer when .meta() is called last,\n * or in innerType when .meta() is called before .optional()/.default().\n */\n private getSchemaMeta(schema: any): Record<string, unknown> | undefined {\n try {\n // First check direct meta (when .meta() is called last in chain)\n const directMeta = schema.meta?.()\n if (directMeta) return directMeta\n\n // Check innerType for wrapped schemas (optional, default, etc.)\n const innerType = schema.def?.innerType\n if (innerType) {\n return this.getSchemaMeta(innerType)\n }\n\n return undefined\n } catch {\n return undefined\n }\n }\n\n /**\n * Clear all registered commands.\n */\n clear(): void {\n this.commands.clear()\n }\n}\n","import { InjectionToken } from '@navios/core'\n\nimport type { HelpCommand } from '../overrides/help.command.mjs'\n\nexport const HelpCommandToken = InjectionToken.create<HelpCommand>('HelpCommand')\n"],"mappings":";;;;;;GAOA,MAAaA,qBAAqBC,OAAO,qBAAA;;;;;;;;;;;GAqCzC,SAAgBC,mBACdC,QACAC,SACAC,MACAC,aACAC,eAAyB;AAEzB,KAAIH,QAAQI,UAAU;EACpB,MAAMA,WAAWJ,QAAQI,SAASR;AAGlC,MAAIQ,SACF,QAAOA;OACF;GACL,MAAMC,cAA+B;IACnCJ;IACAC;IACAC;IACAG,kCAAkB,IAAIC,KAAAA;IACxB;AACAP,WAAQI,SAASR,sBAAsBS;AAEvCN,UAAOH,sBAAsBS;AAC7B,UAAOA;;;AAGX,OAAM,IAAIG,MAAM,wCAAA;;;;;;;;;;;;;;GAgBlB,SAAgBC,uBAAuBV,QAAiB;CAEtD,MAAMK,WAAWL,OAAOH;AACxB,KAAI,CAACQ,SACH,OAAM,IAAII,MACR,sFAAA;AAGJ,QAAOJ;;;;;;;GAST,SAAgBM,mBAAmBX,QAAiB;AAGlD,QAAO,CAAC,CADSA,OAAOH;;;;;;;;;;GC/F1B,MAAagB,kBAAkBC,OAAO,kBAAA;;;;;;;;;;;;;;;GAwBtC,SAAgBC,sBAAsBC,aAAsB;AAE1D,gDADuCA,YAAAA,CAE3BE,cAAcC,IAAIN,gBAAAA,oBAC5B,IAAIO,KAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCuCR,SAAgBK,QAAQ,EACtBC,MACAC,aACAC,OACAC,eACAC,UACAC,YACe;AACf,QAAO,SAAUC,QAAmBC,SAA8B;AAChE,MAAIA,QAAQC,SAAS,QACnB,OAAM,IAAIC,MAAM,q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