tshex-cli 1.0.13 → 1.0.15

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 (38) hide show
  1. package/LICENSE +21 -21
  2. package/build/main.js +21 -46
  3. package/package.json +50 -52
  4. package/readme.md +205 -76
  5. package/source/main.ts +84 -145
  6. package/templates/ctx/index.ts +9 -9
  7. package/templates/lib/index.d.ts +1 -1
  8. package/templates/lib/main.ts +5 -5
  9. package/templates/lib/shared/application/databases.ts +81 -0
  10. package/templates/lib/shared/application/events.ts +121 -0
  11. package/templates/lib/shared/application/{Response.ts → http.ts} +48 -52
  12. package/templates/{cls.example → lib/shared/application/loggers.ts} +50 -50
  13. package/templates/lib/shared/application/{Service.ts → services.ts} +43 -47
  14. package/templates/lib/shared/domain/{Aggregate.ts → aggregates.ts} +44 -48
  15. package/templates/lib/shared/domain/{Entity.ts → entities.ts} +46 -50
  16. package/templates/lib/shared/{application/DataTransferObject.ts → domain/errors.ts} +46 -46
  17. package/templates/lib/shared/domain/value-objects.ts +194 -0
  18. package/templates/ctx/ports/.gitkeep +0 -0
  19. package/templates/lib/shared/adapters/.gitkeep +0 -0
  20. package/templates/lib/shared/application/Logger.ts +0 -54
  21. package/templates/lib/shared/application/data/DataManager.ts +0 -50
  22. package/templates/lib/shared/application/data/Repository.ts +0 -55
  23. package/templates/lib/shared/application/errors/.gitkeep +0 -0
  24. package/templates/lib/shared/application/events/Event.ts +0 -56
  25. package/templates/lib/shared/application/events/EventDispatcher.ts +0 -55
  26. package/templates/lib/shared/application/events/EventHandler.ts +0 -50
  27. package/templates/lib/shared/constants/.gitkeep +0 -0
  28. package/templates/lib/shared/domain/errors/ValueError.ts +0 -69
  29. package/templates/lib/shared/domain/utils/.gitkeep +0 -0
  30. package/templates/lib/shared/domain/value-objects/BooleanValueObject.ts +0 -87
  31. package/templates/lib/shared/domain/value-objects/DateValueObject.ts +0 -100
  32. package/templates/lib/shared/domain/value-objects/EmailValueObject.ts +0 -89
  33. package/templates/lib/shared/domain/value-objects/NullableBooleanValueObject.ts +0 -87
  34. package/templates/lib/shared/domain/value-objects/NumericValueObject.ts +0 -136
  35. package/templates/lib/shared/domain/value-objects/StringValueObject.ts +0 -87
  36. package/templates/lib/shared/domain/value-objects/SymbolValueObject.ts +0 -82
  37. package/templates/lib/shared/domain/value-objects/ValueObject.ts +0 -57
  38. package/templates/rfc.example +0 -42
@@ -1,47 +1,43 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description
14
- * function arguments are Entity
15
- */
16
- export default abstract class Service
17
- {
18
-
19
- [property: string]: unknown;
20
-
21
- // public ATTRIBUTES
22
-
23
- // protected ATTRIBUTES
24
-
25
- // private ATTRIBUTES
26
-
27
- // public static ATTRIBUTES
28
-
29
- // protected static ATTRIBUTES
30
-
31
- // private static ATTRIBUTES
32
-
33
- // Constructor, Getters, Setters
34
-
35
- // public METHODS
36
-
37
- // protected METHODS
38
-
39
- // private METHODS
40
-
41
- // public static METHODS
42
-
43
- // protected static METHODS
44
-
45
- // private static METHODS
46
-
47
- } //:: class
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ // Lower Layers
6
+
7
+ // Types
8
+
9
+ // Constants
10
+
11
+ /**
12
+ * @description
13
+ * function arguments are Entity
14
+ */
15
+ export abstract class Service {
16
+ [property: string]: unknown
17
+
18
+ // public ATTRIBUTES
19
+
20
+ // protected ATTRIBUTES
21
+
22
+ // private ATTRIBUTES
23
+
24
+ // public static ATTRIBUTES
25
+
26
+ // protected static ATTRIBUTES
27
+
28
+ // private static ATTRIBUTES
29
+
30
+ // Constructor, Getters, Setters
31
+
32
+ // public METHODS
33
+
34
+ // protected METHODS
35
+
36
+ // private METHODS
37
+
38
+ // public static METHODS
39
+
40
+ // protected static METHODS
41
+
42
+ // private static METHODS
43
+ } //:: class
@@ -1,48 +1,44 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description An Aggregate is a class that contains business logic that doesn't belong to any entity.
14
- * It is used to perform operations that don't fit into an entity or involve multiple entities.
15
- * Normally, method arguments are entities.
16
- */
17
- export default abstract class Aggregate
18
- {
19
-
20
- [property: string]: unknown;
21
-
22
- // public ATTRIBUTES
23
-
24
- // protected ATTRIBUTES
25
-
26
- // private ATTRIBUTES
27
-
28
- // public static ATTRIBUTES
29
-
30
- // protected static ATTRIBUTES
31
-
32
- // private static ATTRIBUTES
33
-
34
- // Constructor, Getters, Setters
35
-
36
- // public METHODS
37
-
38
- // protected METHODS
39
-
40
- // private METHODS
41
-
42
- // public static METHODS
43
-
44
- // protected static METHODS
45
-
46
- // private static METHODS
47
-
48
- } //:: class
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ // Lower Layers
6
+
7
+ // Types
8
+
9
+ // Constants
10
+
11
+ /**
12
+ * @description An Aggregate is a class that contains business logic that doesn't belong to any entity.
13
+ * It is used to perform operations that don't fit into an entity or involve multiple entities.
14
+ * Normally, method arguments are entities.
15
+ */
16
+ export abstract class Aggregate {
17
+ [property: string]: unknown
18
+
19
+ // public ATTRIBUTES
20
+
21
+ // protected ATTRIBUTES
22
+
23
+ // private ATTRIBUTES
24
+
25
+ // public static ATTRIBUTES
26
+
27
+ // protected static ATTRIBUTES
28
+
29
+ // private static ATTRIBUTES
30
+
31
+ // Constructor, Getters, Setters
32
+
33
+ // public METHODS
34
+
35
+ // protected METHODS
36
+
37
+ // private METHODS
38
+
39
+ // public static METHODS
40
+
41
+ // protected static METHODS
42
+
43
+ // private static METHODS
44
+ } //:: class
@@ -1,50 +1,46 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description An Entity is a class that represents a domain concept or element.
14
- */
15
- export default abstract class Entity
16
- {
17
-
18
- [property: string]: unknown;
19
-
20
- // public ATTRIBUTES
21
-
22
- // protected ATTRIBUTES
23
-
24
- // private ATTRIBUTES
25
-
26
- // public static ATTRIBUTES
27
-
28
- // protected static ATTRIBUTES
29
-
30
- // private static ATTRIBUTES
31
-
32
- // Constructor, Getters, Setters
33
-
34
- // public METHODS
35
-
36
- public abstract equals(other: Entity): boolean;
37
-
38
- public abstract flatten(): Record<string, unknown>;
39
-
40
- // protected METHODS
41
-
42
- // private METHODS
43
-
44
- // public static METHODS
45
-
46
- // protected static METHODS
47
-
48
- // private static METHODS
49
-
50
- } //:: class
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ // Lower Layers
6
+
7
+ // Types
8
+
9
+ // Constants
10
+
11
+ /**
12
+ * @description An Entity is a class that represents a domain concept or element.
13
+ */
14
+ export abstract class Entity {
15
+ [property: string]: unknown
16
+
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 METHODS
32
+
33
+ public abstract equals(other: Entity): boolean
34
+
35
+ public abstract toJSON(): Record<string, unknown>
36
+
37
+ // protected METHODS
38
+
39
+ // private METHODS
40
+
41
+ // public static METHODS
42
+
43
+ // protected static METHODS
44
+
45
+ // private static METHODS
46
+ } //:: class
@@ -1,46 +1,46 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description
14
- */
15
- export default abstract class DataTransferObject
16
- {
17
-
18
- [property: string]: unknown;
19
-
20
- // public ATTRIBUTES
21
-
22
- // protected ATTRIBUTES
23
-
24
- // private ATTRIBUTES
25
-
26
- // public static ATTRIBUTES
27
-
28
- // protected static ATTRIBUTES
29
-
30
- // private static ATTRIBUTES
31
-
32
- // Constructor, Getters, Setters
33
-
34
- // public METHODS
35
-
36
- // protected METHODS
37
-
38
- // private METHODS
39
-
40
- // public static METHODS
41
-
42
- // protected static METHODS
43
-
44
- // private static METHODS
45
-
46
- } //:: class
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ // Lower Layers
6
+
7
+ // Types
8
+
9
+ // Constants
10
+
11
+ /**
12
+ * @description
13
+ */
14
+ export class ValueError extends Error {
15
+ [property: string]: unknown
16
+
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(received: string, expected: string) {
32
+ super(`Invalid value ${received} for ${expected}.`)
33
+ }
34
+
35
+ // public METHODS
36
+
37
+ // protected METHODS
38
+
39
+ // private METHODS
40
+
41
+ // public static METHODS
42
+
43
+ // protected static METHODS
44
+
45
+ // private static METHODS
46
+ } //:: class
@@ -0,0 +1,194 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ import { ValueError } from './errors.js'
6
+
7
+ // Lower Layers
8
+
9
+ // Types
10
+
11
+ // Constants
12
+
13
+ /**
14
+ * @see https://emailregex.com/
15
+ */
16
+ const VALID_EMAIL_REGEX =
17
+ /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
18
+
19
+ /**
20
+ * @description
21
+ */
22
+ export abstract class ValueObject<T = unknown> {
23
+ [property: string]: unknown
24
+
25
+ // public ATTRIBUTES
26
+
27
+ public abstract readonly value: T
28
+
29
+ // protected ATTRIBUTES
30
+
31
+ // private ATTRIBUTES
32
+
33
+ // public static ATTRIBUTES
34
+
35
+ // protected static ATTRIBUTES
36
+
37
+ // private static ATTRIBUTES
38
+
39
+ // Constructor, Getters, Setters
40
+
41
+ // public METHODS
42
+
43
+ public toString(): string {
44
+ return String(this.value)
45
+ }
46
+
47
+ public abstract equals(other: ValueObject<T> | null | undefined): boolean
48
+
49
+ // protected METHODS
50
+
51
+ // private METHODS
52
+
53
+ // public static METHODS
54
+
55
+ public static isValid(value: unknown): boolean {
56
+ return (
57
+ value !== null &&
58
+ value !== undefined &&
59
+ Object.is(value, NaN) === false
60
+ )
61
+ }
62
+
63
+ // protected static METHODS
64
+
65
+ // private static METHODS
66
+ } //:: class
67
+
68
+ /**
69
+ * @description
70
+ */
71
+ export class NullableBoolean extends ValueObject<boolean | null> {
72
+ [property: string]: unknown
73
+
74
+ // public ATTRIBUTES
75
+
76
+ public override readonly value: boolean | null
77
+
78
+ // protected ATTRIBUTES
79
+
80
+ // private ATTRIBUTES
81
+
82
+ // public static ATTRIBUTES
83
+
84
+ // protected static ATTRIBUTES
85
+
86
+ // private static ATTRIBUTES
87
+
88
+ // Constructor, Getters, Setters
89
+
90
+ protected constructor(value: boolean | null) {
91
+ super()
92
+ this.value = value
93
+ }
94
+
95
+ // public METHODS
96
+
97
+ public override equals(other: NullableBoolean | null | undefined): boolean {
98
+ if (other === null || other === undefined) return false
99
+ return this.value === other.value
100
+ }
101
+
102
+ public isIndeterminate(): boolean {
103
+ return this.value === null
104
+ }
105
+
106
+ // protected METHODS
107
+
108
+ // private METHODS
109
+
110
+ // public static METHODS
111
+
112
+ public static from(value: boolean | null): NullableBoolean {
113
+ return new this(value)
114
+ }
115
+
116
+ // protected static METHODS
117
+
118
+ // private static METHODS
119
+ } //:: class
120
+
121
+ /**
122
+ * @description
123
+ */
124
+ export class Email extends ValueObject<string> {
125
+ [property: string]: unknown
126
+
127
+ // public ATTRIBUTES
128
+
129
+ public override readonly value: string
130
+
131
+ // protected ATTRIBUTES
132
+
133
+ // private ATTRIBUTES
134
+
135
+ // public static ATTRIBUTES
136
+
137
+ // protected static ATTRIBUTES
138
+
139
+ // private static ATTRIBUTES
140
+
141
+ // Constructor, Getters, Setters
142
+
143
+ protected constructor(value: string) {
144
+ super()
145
+ this.value = value
146
+ }
147
+
148
+ get username(): string | undefined {
149
+ return this.value.split('@').shift()
150
+ }
151
+
152
+ get domain(): string | undefined {
153
+ return this.value.split('@').pop()
154
+ }
155
+
156
+ get tld(): string | undefined {
157
+ return this.domain?.split('.').pop()
158
+ }
159
+
160
+ // public METHODS
161
+
162
+ public override equals(other: Email | null | undefined): boolean {
163
+ if (other === null || other === undefined) {
164
+ return false
165
+ }
166
+
167
+ return this.value === other.value
168
+ }
169
+
170
+ // protected METHODS
171
+
172
+ // private METHODS
173
+
174
+ // public static METHODS
175
+
176
+ public static override isValid(value: unknown): boolean {
177
+ if (super.isValid(value) === false) return false
178
+
179
+ return (
180
+ 'string' === typeof value && VALID_EMAIL_REGEX.test(value as string)
181
+ )
182
+ }
183
+
184
+ public static from(value: string): Email {
185
+ if (this.isValid(value) === false)
186
+ throw new ValueError(value, this.name)
187
+
188
+ return new this(value)
189
+ }
190
+
191
+ // protected static METHODS
192
+
193
+ // private static METHODS
194
+ } //:: class
File without changes
File without changes
@@ -1,54 +0,0 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description
14
- */
15
- export default abstract class Logger
16
- {
17
-
18
- [property: string]: unknown;
19
-
20
- // public ATTRIBUTES
21
-
22
- // protected ATTRIBUTES
23
-
24
- // private ATTRIBUTES
25
-
26
- // public static ATTRIBUTES
27
-
28
- // protected static ATTRIBUTES
29
-
30
- // private static ATTRIBUTES
31
-
32
- // Constructor, Getters, Setters
33
-
34
- // public METHODS
35
-
36
- public abstract debug(message: string): void;
37
-
38
- public abstract info(message: string): void;
39
-
40
- public abstract warning(message: string): void;
41
-
42
- public abstract error(message: string): void;
43
-
44
- // protected METHODS
45
-
46
- // private METHODS
47
-
48
- // public static METHODS
49
-
50
- // protected static METHODS
51
-
52
- // private static METHODS
53
-
54
- } //:: class
@@ -1,50 +0,0 @@
1
- // Libraries
2
-
3
- // Same Layer
4
-
5
- // Lower Layers
6
-
7
- // Types
8
-
9
- // Constants
10
-
11
-
12
- /**
13
- * @description
14
- */
15
- export default abstract class DataManager
16
- {
17
-
18
- [property: string]: unknown;
19
-
20
- // Public Attributes
21
-
22
- // Protected Attributes
23
-
24
- // Private Attributes
25
-
26
- // Public Static Attributes
27
-
28
- // Protected Static Attributes
29
-
30
- // Private Static Attributes
31
-
32
- // Constructor, Getters, Setters
33
-
34
- // Public Methods
35
-
36
- public abstract connect(...args: unknown[]): Promise<unknown>;
37
-
38
- public abstract disconnect(): Promise<unknown>;
39
-
40
- // Protected Methods
41
-
42
- // Private Methods
43
-
44
- // Public Static Methods
45
-
46
- // Protected Static Methods
47
-
48
- // Private Static Methods
49
-
50
- } //:: class