@odg/command 1.13.0 → 1.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odg/command",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "ODGCommander used to create files based in stubs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,23 +41,24 @@
41
41
  "author": "Dragons Gamers <https://www.linkedin.com/in/victor-alves-odgodinho>",
42
42
  "license": "MIT",
43
43
  "devDependencies": {
44
- "@odg/eslint-config": "^3.4.0",
44
+ "@odg/eslint-config": "^3.5.0",
45
45
  "@odg/tsconfig": "^1.3.0",
46
46
  "@types/node": ">=24",
47
- "@vitest/coverage-istanbul": "^4.1.4",
47
+ "@vitest/coverage-istanbul": "^4.1.5",
48
48
  "concurrently": "^9.2.1",
49
49
  "reflect-metadata": "^0.2.2",
50
50
  "rimraf": "^6.1.3",
51
51
  "tsc-alias": "^1.8.16",
52
52
  "tsx": "^4.21.0",
53
53
  "typescript": "^5.9.3",
54
- "vite": "^8.0.8",
55
- "vitest": "^4.1.4"
54
+ "vite": "^8.0.9",
55
+ "vitest": "^4.1.5"
56
56
  },
57
57
  "dependencies": {
58
- "@odg/chemical-x": "^2.4.0",
59
- "@odg/exception": "^1.10.0",
60
- "@odg/log": "^1.8.0",
61
- "commander": "^14.0.3"
58
+ "@odg/chemical-x": "^2.5.0",
59
+ "@odg/exception": "^1.11.0",
60
+ "@odg/log": "^1.9.0",
61
+ "commander": "^14.0.3",
62
+ "ts-morph": "^28.0.0"
62
63
  }
63
64
  }
package/stubs/event.stub CHANGED
@@ -1,19 +1,19 @@
1
1
  import { ODGDecorators } from "@odg/chemical-x";
2
- import { type EventListenerInterface } from "@odg/events";
3
- import { LoggerInterface } from "@odg/log";
4
- import { inject } from "inversify";
2
+ import type { EventListenerInterface } from "@odg/events";
3
+ import type { LoggerInterface } from "@odg/log";
5
4
 
6
- import { type EventBrowserParameters, type EventTypes } from "#types/EventsInterface";
5
+ import type { EventBrowserParameters, EventTypes } from "#types/EventsInterface";
7
6
  import { ContainerName, EventName } from "@enums";
8
- import { {{ EventName:UCFirst }}Page } from "@pages/{{ EventName:UCFirst }}Page";
7
+ import { {{ EventName:UCFirst }}Page } from "@pages";
8
+ import { $inject } from "~/ContainerInject";
9
9
 
10
10
  @ODGDecorators.injectable(ContainerName.{{ EventName:UCFirst }}EventListener, "Singleton")
11
11
  @ODGDecorators.registerListener(EventName.{{ EventName:UCFirst }}Event, ContainerName.{{ EventName:UCFirst }}EventListener, {})
12
12
  export class {{ EventName:UCFirst }}EventListener implements EventListenerInterface<EventTypes, EventName.{{ EventName:UCFirst }}Event> {
13
13
 
14
14
  public constructor(
15
- @inject(ContainerName.Logger) public readonly log: LoggerInterface,
16
- @inject(ContainerName.{{ EventName:UCFirst }}Page) public readonly {{ EventName:LCFirst }}Page: {{ EventName:UCFirst }}Page,
15
+ @$inject(ContainerName.Logger) public readonly log: LoggerInterface,
16
+ @$inject(ContainerName.{{ EventName:UCFirst }}Page) public readonly {{ EventName:LCFirst }}Page: {{ EventName:UCFirst }}Page,
17
17
  ) {
18
18
  }
19
19
 
@@ -1,11 +1,11 @@
1
1
  import {
2
- type HandlerInterface,
3
2
  type HandlerFunction,
4
- HandlerSolution,
5
- RetryAction,
3
+ type HandlerInterface,
4
+ type HandlerSolutionType,
6
5
  ODGDecorators,
6
+ RetryAction,
7
7
  } from "@odg/chemical-x";
8
- import { type Exception } from "@odg/exception";
8
+ import type { Exception } from "@odg/exception";
9
9
 
10
10
  import { ConfigName, ContainerName } from "@enums";
11
11
  import { BaseHandler } from "@handlers/BaseHandler";
@@ -20,44 +20,22 @@ export class {{ HandlerClassName }} extends BaseHandler implements HandlerInterf
20
20
  ]);
21
21
  }
22
22
 
23
- /**
24
- * Return timeout for handler
25
- *
26
- * @returns {Promise<number>}
27
- */
28
23
  public async getTimeout(): Promise<number> {
29
24
  return this.config.get(ConfigName.HANDLER_TIMEOUT);
30
25
  }
31
26
 
32
- /**
33
- * Return number attempt to test this handler
34
- *
35
- * @returns {Promise<number>}
36
- */
37
27
  public async attempt(): Promise<number> {
38
28
  return this.config.get(ConfigName.HANDLER_ATTEMPT);
39
29
  }
40
30
 
41
- /**
42
- * Called Always handler attempt error.
43
- *
44
- * @param {Exception} exception Exception error
45
- * @param {number} attempt Current attempt
46
- * @returns {Promise<RetryAction>}
47
- */
48
- public async retrying(exception: Exception, attempt: number): Promise<RetryAction> {
31
+ public override async retrying(exception: Exception, attempt: number): Promise<RetryAction> {
49
32
  await this.log.debug(`Step {{ HandlerClassName }}: Failed Attempt ${attempt}.`);
50
33
  await this.log.warning(exception.message);
51
34
 
52
35
  return RetryAction.Default;
53
36
  }
54
37
 
55
- /**
56
- * Handler finish with success after all attempts
57
- *
58
- * @returns {Promise<void>}
59
- */
60
- public async success(): Promise<void> {
38
+ public override async success(): Promise<void> {
61
39
  await this.log.debug("Step {{ HandlerClassName }} finish with success.");
62
40
  }
63
41
 
@@ -69,7 +47,7 @@ export class {{ HandlerClassName }} extends BaseHandler implements HandlerInterf
69
47
  * @returns {Promise<HandlerFunction>}
70
48
  */
71
49
  public async identifySuccess(): Promise<HandlerFunction> {
72
- return this.page.waitForSelector(this.$$s.example.success, { timeout: await this.getTimeout() })
50
+ return this.page.waitForSelector(this.$$s.{{ HandlerPageSelectorBundle }}.success, { timeout: await this.getTimeout() })
73
51
  .then(() => this.successSolution.bind(this));
74
52
  }
75
53
 
@@ -81,17 +59,17 @@ export class {{ HandlerClassName }} extends BaseHandler implements HandlerInterf
81
59
  * @returns {Promise<HandlerFunction>}
82
60
  */
83
61
  public async identifyError(): Promise<HandlerFunction> {
84
- return this.page.waitForSelector(this.$$s.example.example2, { timeout: await this.getTimeout() })
62
+ return this.page.waitForSelector(this.$$s.{{ HandlerPageSelectorBundle }}.example2, { timeout: await this.getTimeout() })
85
63
  .then(() => this.errorSolution.bind(this));
86
64
  }
87
65
 
88
66
  /**
89
67
  * Action if example handler
90
68
  *
91
- * @returns {Promise<HandlerSolution>}
69
+ * @returns {Promise<HandlerSolutionType>}
92
70
  */
93
- public async errorSolution(): Promise<HandlerSolution> {
94
- return HandlerSolution.Resolve;
71
+ public async errorSolution(): Promise<HandlerSolutionType> {
72
+ return RetryAction.Resolve;
95
73
  }
96
74
 
97
75
  }
package/stubs/page.stub CHANGED
@@ -3,38 +3,20 @@ import { ODGDecorators, type PageInterface } from "@odg/chemical-x";
3
3
  import { ConfigName, ContainerName } from "@enums";
4
4
  import { BasePage } from "@pages/BasePage";
5
5
  import {
6
- type {{ PageName:UCFirst }}SelectorType,
7
6
  {{ PageName:LCFirst }}Selector,
7
+ type {{ PageName:UCFirst }}SelectorType,
8
8
  } from "@selectors";
9
9
 
10
- /**
11
- * Generated page {{ PageName:UCFirst }}
12
- */
13
10
  @ODGDecorators.injectable(ContainerName.{{ PageName:UCFirst }}Page)
14
11
  @ODGDecorators.attemptableFlow()
15
12
  export class {{ PageName:UCFirst }}Page extends BasePage implements PageInterface {
16
13
 
17
- /**
18
- * Selector to {{ PageName:UCFirst }}Page
19
- *
20
- * @type {{{ PageName:UCFirst }}SelectorType}
21
- */
22
- public $s: {{ PageName:UCFirst }}SelectorType = {{ PageName:LCFirst }}Selector;
14
+ public readonly $s: {{ PageName:UCFirst }}SelectorType = {{ PageName:LCFirst }}Selector;
23
15
 
24
- /**
25
- * Execute this step
26
- *
27
- * @returns {Promise<void>}
28
- */
29
16
  public async execute(): Promise<void> {
30
17
  // Create execution command step here and remove this comment
31
18
  }
32
19
 
33
- /**
34
- * Number of attempt this step
35
- *
36
- * @returns {Promise<number>}
37
- */
38
20
  public async attempt(): Promise<number> {
39
21
  return this.config.get(ConfigName.PAGE_ATTEMPT);
40
22
  }
@@ -1,5 +1,7 @@
1
1
  export const {{ SelectorName:LCFirst }}Selector = {
2
+ success: "#success",
2
3
  example: "#example",
4
+ example2: "#example2",
3
5
  };
4
6
 
5
7
  export type {{ SelectorName:UCFirst }}SelectorType = typeof {{ SelectorName:LCFirst }}Selector;