tshex-cli 1.0.1

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/build/main.js +84 -0
  3. package/package.json +30 -0
  4. package/readme.md +53 -0
  5. package/source/index.d.ts +0 -0
  6. package/source/main.ts +137 -0
  7. package/templates/cls.example +50 -0
  8. package/templates/ctx/adapters/.gitkeep +0 -0
  9. package/templates/ctx/application/.gitkeep +0 -0
  10. package/templates/ctx/domain/.gitkeep +0 -0
  11. package/templates/ctx/index.ts +9 -0
  12. package/templates/ctx/ports/.gitkeep +0 -0
  13. package/templates/lib/index.d.ts +1 -0
  14. package/templates/lib/main.ts +5 -0
  15. package/templates/lib/shared/adapters/.gitkeep +0 -0
  16. package/templates/lib/shared/application/DataTransferObject.ts +46 -0
  17. package/templates/lib/shared/application/Facade.ts +47 -0
  18. package/templates/lib/shared/application/Logger.ts +54 -0
  19. package/templates/lib/shared/application/Response.ts +52 -0
  20. package/templates/lib/shared/application/data/DataManager.ts +50 -0
  21. package/templates/lib/shared/application/data/Repository.ts +55 -0
  22. package/templates/lib/shared/application/errors/.gitkeep +0 -0
  23. package/templates/lib/shared/application/events/Event.ts +56 -0
  24. package/templates/lib/shared/application/events/EventDispatcher.ts +55 -0
  25. package/templates/lib/shared/application/events/EventHandler.ts +50 -0
  26. package/templates/lib/shared/constants/.gitkeep +0 -0
  27. package/templates/lib/shared/domain/Entity.ts +50 -0
  28. package/templates/lib/shared/domain/Service.ts +48 -0
  29. package/templates/lib/shared/domain/errors/ValueError.ts +69 -0
  30. package/templates/lib/shared/domain/utils/.gitkeep +0 -0
  31. package/templates/lib/shared/domain/value-objects/BooleanValueObject.ts +83 -0
  32. package/templates/lib/shared/domain/value-objects/DateValueObject.ts +96 -0
  33. package/templates/lib/shared/domain/value-objects/EmailValueObject.ts +89 -0
  34. package/templates/lib/shared/domain/value-objects/NullableBooleanValueObject.ts +83 -0
  35. package/templates/lib/shared/domain/value-objects/NumericValueObject.ts +132 -0
  36. package/templates/lib/shared/domain/value-objects/StringValueObject.ts +83 -0
  37. package/templates/lib/shared/domain/value-objects/SymbolValueObject.ts +78 -0
  38. package/templates/lib/shared/domain/value-objects/ValueObject.ts +57 -0
  39. package/templates/rfc.example +42 -0
@@ -0,0 +1,83 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ import ValueObject from './ValueObject.js';
6
+
7
+ import ValueError from '../errors/ValueError.js';
8
+
9
+ // Lower Layers
10
+
11
+ // Types
12
+
13
+ type T = boolean | null;
14
+
15
+ // Constants
16
+
17
+
18
+ /**
19
+ * @description
20
+ */
21
+ export default class NullableBooleanValueObject extends ValueObject
22
+ {
23
+
24
+ [property: string]: unknown;
25
+
26
+ // public ATTRIBUTES
27
+
28
+ public override readonly value: T;
29
+
30
+ // protected ATTRIBUTES
31
+
32
+ // private ATTRIBUTES
33
+
34
+ // public static ATTRIBUTES
35
+
36
+ // protected static ATTRIBUTES
37
+
38
+ // private static ATTRIBUTES
39
+
40
+ // Constructor, Getters, Setters
41
+
42
+ protected constructor(value: T)
43
+ {
44
+ super();
45
+ this.value = value;
46
+ }
47
+
48
+ // public METHODS
49
+
50
+ public override equals(other: NullableBooleanValueObject): boolean
51
+ {
52
+ return this.value === other.value;
53
+ }
54
+
55
+ public isIndeterminate(): boolean
56
+ {
57
+ return this.value === null;
58
+ }
59
+
60
+ // protected METHODS
61
+
62
+ // private METHODS
63
+
64
+ // public static METHODS
65
+
66
+ public static override isValid(value: unknown): boolean
67
+ {
68
+ return (value === null) || (value === true) || (value === false);
69
+ }
70
+
71
+ public static from(value: T): NullableBooleanValueObject
72
+ {
73
+ if (!this.isValid(value)) {
74
+ throw new ValueError(value, this.name);
75
+ }
76
+ return new this(value);
77
+ }
78
+
79
+ // protected static METHODS
80
+
81
+ // private static METHODS
82
+
83
+ } //:: class
@@ -0,0 +1,132 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ import ValueObject from './ValueObject.js';
6
+
7
+ import ValueError from '../errors/ValueError.js';
8
+
9
+ // Lower Layers
10
+
11
+ // Types
12
+
13
+ type T = number;
14
+
15
+ // Constants
16
+
17
+
18
+ /**
19
+ * @description
20
+ */
21
+ export default class NumericValueObject extends ValueObject
22
+ {
23
+
24
+ [property: string]: unknown;
25
+
26
+ // public ATTRIBUTES
27
+
28
+ public override readonly value: T;
29
+
30
+ // protected ATTRIBUTES
31
+
32
+ // private ATTRIBUTES
33
+
34
+ // public static ATTRIBUTES
35
+
36
+ // protected static ATTRIBUTES
37
+
38
+ // private static ATTRIBUTES
39
+
40
+ // Constructor, Getters, Setters
41
+
42
+ protected constructor(value: T)
43
+ {
44
+ super();
45
+ this.value = value;
46
+ }
47
+
48
+ // public METHODS
49
+
50
+ public override equals(other: NumericValueObject): boolean
51
+ {
52
+ return this.value === other.value;
53
+ }
54
+
55
+ public isInteger(): boolean
56
+ {
57
+ return Number.isInteger(this.value);
58
+ }
59
+
60
+ public isZero(): boolean
61
+ {
62
+ return this.value === 0;
63
+ }
64
+
65
+ public isPositive(): boolean
66
+ {
67
+ return this.value > 0;
68
+ }
69
+
70
+ public isNegative(): boolean
71
+ {
72
+ return this.value < 0;
73
+ }
74
+
75
+ public isOdd(): boolean
76
+ {
77
+ return (this.value & 1) === 1;
78
+ }
79
+
80
+ public isEven(): boolean
81
+ {
82
+ return (this.value & 1) === 0;
83
+ }
84
+
85
+ public isBetween(min: T, max: T, inclusiveMin = true, inclusiveMax = true): boolean
86
+ {
87
+
88
+ if (inclusiveMin && inclusiveMax) {
89
+ return this.value >= min && this.value <= max;
90
+ }
91
+
92
+ if (inclusiveMin) {
93
+ return this.value >= min && this.value < max;
94
+ }
95
+
96
+ if (inclusiveMax) {
97
+ return this.value > min && this.value <= max;
98
+ }
99
+
100
+ return this.value > min && this.value < max;
101
+
102
+ }
103
+
104
+ // protected METHODS
105
+
106
+ // private METHODS
107
+
108
+ // public static METHODS
109
+
110
+ public static override isValid(value: unknown): boolean
111
+ {
112
+ return (
113
+ 'number' === typeof value
114
+ && !Object.is(value, NaN)
115
+ && !Object.is(value, Infinity)
116
+ && !Object.is(value, -Infinity)
117
+ );
118
+ }
119
+
120
+ public static from(value: T): NumericValueObject
121
+ {
122
+ if (!this.isValid(value)) {
123
+ throw new ValueError(value, this.name);
124
+ }
125
+ return new this(value);
126
+ }
127
+
128
+ // protected static METHODS
129
+
130
+ // private static METHODS
131
+
132
+ } //:: class
@@ -0,0 +1,83 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ import ValueObject from './ValueObject.js';
6
+
7
+ import ValueError from '../errors/ValueError.js';
8
+
9
+ // Lower Layers
10
+
11
+ // Types
12
+
13
+ type T = string;
14
+
15
+ // Constants
16
+
17
+
18
+ /**
19
+ * @description
20
+ */
21
+ export default class StringValueObject extends ValueObject
22
+ {
23
+
24
+ [property: string]: unknown;
25
+
26
+ // public ATTRIBUTES
27
+
28
+ public override readonly value: T;
29
+
30
+ // protected ATTRIBUTES
31
+
32
+ // private ATTRIBUTES
33
+
34
+ // public static ATTRIBUTES
35
+
36
+ // protected static ATTRIBUTES
37
+
38
+ // private static ATTRIBUTES
39
+
40
+ // Constructor, Getters, Setters
41
+
42
+ protected constructor(value: T)
43
+ {
44
+ super();
45
+ this.value = value;
46
+ }
47
+
48
+ // public METHODS
49
+
50
+ public override equals(other: StringValueObject): boolean
51
+ {
52
+ return this.value === other.value;
53
+ }
54
+
55
+ public isEmpty(): boolean
56
+ {
57
+ return this.value === '';
58
+ }
59
+
60
+ // protected METHODS
61
+
62
+ // private METHODS
63
+
64
+ // public static METHODS
65
+
66
+ public static override isValid(value: unknown): boolean
67
+ {
68
+ return ('string' === typeof value);
69
+ }
70
+
71
+ public static from(value: T): StringValueObject
72
+ {
73
+ if (!this.isValid(value)) {
74
+ throw new ValueError(value, this.name);
75
+ }
76
+ return new this(value);
77
+ }
78
+
79
+ // protected static METHODS
80
+
81
+ // private static METHODS
82
+
83
+ } //:: class
@@ -0,0 +1,78 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ import ValueObject from './ValueObject.js';
6
+
7
+ import ValueError from '../errors/ValueError.js';
8
+
9
+ // Lower Layers
10
+
11
+ // Types
12
+
13
+ type T = symbol;
14
+
15
+ // Constants
16
+
17
+
18
+ /**
19
+ * @description
20
+ */
21
+ export default class SymbolValueObject extends ValueObject
22
+ {
23
+
24
+ [property: string]: unknown;
25
+
26
+ // public ATTRIBUTES
27
+
28
+ public override readonly value: T;
29
+
30
+ // protected ATTRIBUTES
31
+
32
+ // private ATTRIBUTES
33
+
34
+ // public static ATTRIBUTES
35
+
36
+ // protected static ATTRIBUTES
37
+
38
+ // private static ATTRIBUTES
39
+
40
+ // Constructor, Getters, Setters
41
+
42
+ protected constructor(value: T)
43
+ {
44
+ super();
45
+ this.value = value;
46
+ }
47
+
48
+ // public METHODS
49
+
50
+ public override equals(other: SymbolValueObject): boolean
51
+ {
52
+ return this.value === other.value;
53
+ }
54
+
55
+ // protected METHODS
56
+
57
+ // private METHODS
58
+
59
+ // public static METHODS
60
+
61
+ public static override isValid(value: unknown): boolean
62
+ {
63
+ return ('symbol' === typeof value);
64
+ }
65
+
66
+ public static from(value: T): SymbolValueObject
67
+ {
68
+ if (!this.isValid(value)) {
69
+ throw new ValueError(value, this.name);
70
+ }
71
+ return new this(value);
72
+ }
73
+
74
+ // protected static METHODS
75
+
76
+ // private static METHODS
77
+
78
+ } //:: class
@@ -0,0 +1,57 @@
1
+ // Libraries
2
+
3
+ // Same Layer
4
+
5
+ // Lower Layers
6
+
7
+ // Types
8
+
9
+ type TValue = string | symbol | number | bigint | boolean | object | null;
10
+
11
+ // Constants
12
+
13
+
14
+ /**
15
+ * @description
16
+ */
17
+ export default abstract class ValueObject
18
+ {
19
+
20
+ [property: string]: unknown;
21
+
22
+ // public ATTRIBUTES
23
+
24
+ public abstract readonly value: TValue;
25
+
26
+ // protected ATTRIBUTES
27
+
28
+ // private ATTRIBUTES
29
+
30
+ // public static ATTRIBUTES
31
+
32
+ // protected static ATTRIBUTES
33
+
34
+ // private static ATTRIBUTES
35
+
36
+ // Constructor, Getters, Setters
37
+
38
+ // public METHODS
39
+
40
+ public abstract equals(other: ValueObject): boolean;
41
+
42
+ // protected METHODS
43
+
44
+ // private METHODS
45
+
46
+ // public static METHODS
47
+
48
+ public static isValid(value: unknown): boolean
49
+ {
50
+ return value !== null && value !== undefined && !Object.is(value, NaN);
51
+ }
52
+
53
+ // protected static METHODS
54
+
55
+ // private static METHODS
56
+
57
+ } //:: class
@@ -0,0 +1,42 @@
1
+ // Libraries
2
+
3
+ import React from 'react';
4
+
5
+ // Components
6
+
7
+ // Features
8
+
9
+ // Hooks
10
+
11
+ // Languages
12
+
13
+ // Styles
14
+
15
+ // Types
16
+
17
+ type Props = React.HTMLProps<HTMLElement> & {};
18
+
19
+ // Constants
20
+
21
+
22
+ /**
23
+ * @description
24
+ */
25
+ export default function __COMPONENT__(props: Props): React.ReactElement
26
+ {
27
+
28
+ // MODEL -----------------------------
29
+
30
+ // VIEW MODEL ------------------------
31
+
32
+ // EFFECTS ---------------------------
33
+
34
+ // HANDLERS --------------------------
35
+
36
+ // VIEW ------------------------------
37
+
38
+ return (
39
+ React.createElement(React.Fragment, null, props.children)
40
+ );
41
+
42
+ } //:: ReactElement