tshex-cli 1.0.17 → 1.0.18

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": "tshex-cli",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "author": "https://github.com/virtualitems/",
5
5
  "description": "Typescript Hexagonal Architecture CLI",
6
6
  "type": "module",
@@ -26,25 +26,23 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/virtualitems/tshex-cli/issues"
28
28
  },
29
+ "types": "./source/index.d.ts",
29
30
  "files": [
30
31
  "./build",
31
32
  "./source",
32
33
  "./templates"
33
34
  ],
34
- "types": "./source/index.d.ts",
35
- "devDependencies": {
36
- "@types/node": "^22.5.4",
37
- "typescript": "^5.4.5"
35
+ "bin": {
36
+ "tshex": "./build/main.js"
38
37
  },
39
38
  "dependencies": {
40
39
  "commander": "^12.1.0"
41
40
  },
42
- "bin": {
43
- "tshex": "./build/main.js"
41
+ "devDependencies": {
42
+ "@types/node": "^22.5.4",
43
+ "typescript": "^5.4.5"
44
44
  },
45
45
  "scripts": {
46
- "examples": "tsc -p examples",
47
- "build": "tsc",
48
- "dev": "tsc -w"
46
+ "build": "tsc"
49
47
  }
50
48
  }
@@ -74,7 +74,7 @@ export abstract class DatasetManager<T = Generic> extends DataManager<T> {
74
74
 
75
75
  public abstract difference(other: Array<T>): Promise<Array<T>>
76
76
 
77
- public abstract symmetric_difference(other: Array<T>): Promise<Array<T>>
77
+ public abstract symmetricDifference(other: Array<T>): Promise<Array<T>>
78
78
 
79
79
  public abstract complement(other: Array<T>): Promise<Array<T>>
80
80
  } //:: class
@@ -1,48 +1,36 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
1
+ /**
2
+ * @description
3
+ */
4
+ export interface HttpRequest {}
8
5
 
9
- // Constants
6
+ /**
7
+ * @description
8
+ */
9
+ export interface HttpResponse {}
10
10
 
11
11
  /**
12
12
  * @description
13
13
  */
14
- export class HttpResponseBody {
14
+ export interface HttpResponseBody {
15
15
  [property: string]: unknown
16
+ readonly data: Record<string, unknown> | null
17
+ readonly errors: string[] | null
18
+ readonly links: Record<string, URL> | null
19
+ }
16
20
 
17
- // public ATTRIBUTES
18
-
19
- // protected ATTRIBUTES
20
-
21
- // private ATTRIBUTES
22
-
23
- // public static ATTRIBUTES
24
-
25
- // protected static ATTRIBUTES
26
-
27
- // private static ATTRIBUTES
28
-
29
- // Constructor, Getters, Setters
30
-
31
- public constructor(
32
- public readonly data: Record<string, unknown> | null = null,
33
- public readonly errors: string[] | null = null,
34
- public readonly links: Record<string, URL> | null = null
35
- ) {}
36
-
37
- // public METHODS
38
-
39
- // protected METHODS
40
-
41
- // private METHODS
42
-
43
- // public static METHODS
44
-
45
- // protected static METHODS
21
+ /**
22
+ * @description
23
+ */
24
+ export interface HttpRequestHandler {
25
+ handle(request: HttpRequest): HttpResponse | Promise<HttpResponse>
26
+ }
46
27
 
47
- // private static METHODS
48
- } //:: class
28
+ /**
29
+ * @description
30
+ */
31
+ export interface HttpMiddleware {
32
+ process(
33
+ request: HttpRequest,
34
+ handler: HttpRequestHandler
35
+ ): HttpResponse | Promise<HttpResponse>
36
+ }
package/readme.md DELETED
@@ -1,217 +0,0 @@
1
- # Hexagonal Architecture CLI
2
-
3
- This CLI will help you to generate a hexagonal architecture structure.
4
-
5
- # Why?
6
-
7
- Hexagonal architecture is a software design pattern that separates the internal domain of the application from the external dependencies. This separation is achieved by dividing the application into layers. Each layer has a specific responsibility and interacts with the other layers in a specific way.
8
-
9
- The goal is to separate the domain code from installed dependencies. A Hexagonal Architecture _framework_ would work against that goal, since it couples the domain code to the framework itself. That is why this CLI exists: it scaffolds the structure for you, using your own codebase instead of a framework.
10
-
11
- # Note
12
-
13
- This tool and its templates are in constant development, so be aware that some changes may occur and be careful when updating the tool.
14
-
15
- If you have any suggestions or improvements, please let me know.
16
-
17
- https://github.com/virtualitems/tshex-cli/issues
18
-
19
- # Getting started
20
-
21
- `tshex` scaffolds folders and files for a hexagonal architecture project. It does not write business logic for you; it only generates the structure, so you can fill it in with your own code.
22
-
23
- There are four things you can generate:
24
-
25
- - A **library** (`--lib`): the shared foundation of a project. It contains the domain and application contracts (entities, value objects, services, etc.) that the rest of the code depends on.
26
- - A **context** (`--ctx`): a specific business area (e.g. `users`, `billing`, `orders`). It contains the `domain/`, `application/`, and `adapters/` folders where you implement that area's logic.
27
- - A **React context** (`--react-context`): a React-ready context scaffold.
28
-
29
- A typical project has one library and one or more contexts inside it.
30
-
31
- ## Install
32
-
33
- Install the CLI globally:
34
-
35
- ```bash
36
- npm install -g tshex-cli
37
- ```
38
-
39
- Check the installation:
40
-
41
- ```bash
42
- tshex --version
43
- ```
44
-
45
- Show the command options:
46
-
47
- ```bash
48
- tshex --help
49
- ```
50
-
51
- ## Usage
52
-
53
- ```bash
54
- tshex [--lib <name>] [--ctx <name>] [--react-context <name>] [--dir <path>]
55
- ```
56
-
57
- | Option | Purpose |
58
- | -------------- | ------------------------------------------------------------------- |
59
- | `--lib <name>` | Generate a library called `<name>`, based on `templates/lib`. |
60
- | `--ctx <name>` | Generate a context called `<name>`, based on `templates/ctx`. |
61
- | `--react-context <name>` | Generate a React context called `<name>`, based on `templates/react-context`. |
62
- | `--dir <path>` | Parent directory where the library/context will be created. Defaults to the current directory. |
63
- | `--help` | Show the command options. |
64
- | `--version` | Show the installed version. |
65
-
66
- `--lib`, `--ctx`, and `--react-context` can be used together in a single command. Running `tshex` without any options just prints the help text — it does not generate anything.
67
-
68
- ## Create a library
69
-
70
- Use this when you are starting a new project and need the shared contracts that the rest of your code will build on:
71
-
72
- ```bash
73
- tshex --lib core
74
- ```
75
-
76
- This generates a `core/` folder in the current directory:
77
-
78
- ```text
79
- core/
80
- ├── index.d.ts
81
- ├── main.ts
82
- └── shared/
83
- ├── application/
84
- │ ├── databases.ts
85
- │ ├── events.ts
86
- │ ├── http.ts
87
- │ ├── loggers.ts
88
- │ └── services.ts
89
- └── domain/
90
- ├── aggregates.ts
91
- ├── entities.ts
92
- ├── errors.ts
93
- └── value-objects.ts
94
- ```
95
-
96
- What each file is for:
97
-
98
- | File | Purpose |
99
- | ------------------ | --------------------------------------------- |
100
- | `index.d.ts` | Declare library types. |
101
- | `main.ts` | Export the library API. |
102
- | `entities.ts` | Define entity contracts. |
103
- | `value-objects.ts` | Define value objects and validation. |
104
- | `aggregates.ts` | Define aggregate contracts. |
105
- | `errors.ts` | Define domain errors. |
106
- | `services.ts` | Define application service contracts. |
107
- | `databases.ts` | Define data manager and repository contracts. |
108
- | `events.ts` | Define event contracts. |
109
- | `http.ts` | Define HTTP response contracts. |
110
- | `loggers.ts` | Define logger contracts. |
111
-
112
- `main.ts` is generated with a placeholder `throw new Error('Not implemented yet')`, so the library fails loudly if you try to use it before filling it in. To start using it, open `main.ts`, remove that line, and export your own code, built on top of the shared contracts. For example:
113
-
114
- ```ts
115
- export { Entity } from './shared/domain/entities.js'
116
- export { ValueObject, Email } from './shared/domain/value-objects.js'
117
-
118
- class User extends Entity {
119
- constructor(public readonly email: Email) {
120
- super()
121
- }
122
- }
123
- ```
124
-
125
- ## Create a context
126
-
127
- Use this to scaffold a specific business area, such as `users`, inside an existing library (or on its own):
128
-
129
- ```bash
130
- tshex --ctx users
131
- ```
132
-
133
- This generates a `users/` folder in the current directory:
134
-
135
- ```text
136
- users/
137
- ├── adapters/
138
- ├── application/
139
- ├── domain/
140
- └── index.ts
141
- ```
142
-
143
- What each part is for:
144
-
145
- | Path | Purpose |
146
- | -------------- | ---------------------------------------------------------------- |
147
- | `domain/` | Entities, value objects, aggregates, and domain errors. |
148
- | `application/` | Use cases, services, DTOs, and contracts. |
149
- | `adapters/` | Database, HTTP, event, file, and service implementations. |
150
- | `index.ts` | Export or compose the context's public API. |
151
-
152
- ## Choose the destination folder
153
-
154
- By default, `tshex` creates files in your current directory. Use `--dir` to choose a different parent directory instead.
155
-
156
- Create a library inside `./src`:
157
-
158
- ```bash
159
- tshex --lib core --dir ./src
160
- ```
161
-
162
- This generates the library at:
163
-
164
- ```text
165
- ./src/core
166
- ```
167
-
168
- Create a context inside that library:
169
-
170
- ```bash
171
- tshex --ctx users --dir ./src/core
172
- ```
173
-
174
- This generates the context at:
175
-
176
- ```text
177
- ./src/core/users
178
- ```
179
-
180
- You can also use an absolute path:
181
-
182
- ```bash
183
- tshex --ctx users --dir /workspace/project/src
184
- ```
185
-
186
- ## Create a library and a context together
187
-
188
- You can generate both in a single command. `tshex` creates the library first, then creates the context inside it:
189
-
190
- ```bash
191
- tshex --dir ./src --lib core --ctx users
192
- ```
193
-
194
- Result:
195
-
196
- ```text
197
- src/
198
- └── core/
199
- ├── index.d.ts
200
- ├── main.ts
201
- ├── shared/
202
- └── users/
203
- ├── adapters/
204
- ├── application/
205
- ├── domain/
206
- └── index.ts
207
- ```
208
-
209
- ## Create a React context
210
-
211
- Use this when you want only the React context scaffold:
212
-
213
- ```bash
214
- tshex --react-context users
215
- ```
216
-
217
- This generates a `users/` folder in the current directory.