tshex-cli 1.0.2

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 +87 -0
  32. package/templates/lib/shared/domain/value-objects/DateValueObject.ts +100 -0
  33. package/templates/lib/shared/domain/value-objects/EmailValueObject.ts +89 -0
  34. package/templates/lib/shared/domain/value-objects/NullableBooleanValueObject.ts +87 -0
  35. package/templates/lib/shared/domain/value-objects/NumericValueObject.ts +136 -0
  36. package/templates/lib/shared/domain/value-objects/StringValueObject.ts +87 -0
  37. package/templates/lib/shared/domain/value-objects/SymbolValueObject.ts +82 -0
  38. package/templates/lib/shared/domain/value-objects/ValueObject.ts +57 -0
  39. package/templates/rfc.example +42 -0
@@ -0,0 +1,87 @@
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 | null | undefined): boolean
51
+ {
52
+ if (other === null || other === undefined) {
53
+ return false;
54
+ }
55
+
56
+ return this.value === other.value;
57
+ }
58
+
59
+ public isIndeterminate(): boolean
60
+ {
61
+ return this.value === null;
62
+ }
63
+
64
+ // protected METHODS
65
+
66
+ // private METHODS
67
+
68
+ // public static METHODS
69
+
70
+ public static override isValid(value: unknown): boolean
71
+ {
72
+ return (value === null) || (value === true) || (value === false);
73
+ }
74
+
75
+ public static from(value: T): NullableBooleanValueObject
76
+ {
77
+ if (!this.isValid(value)) {
78
+ throw new ValueError(value, this.name);
79
+ }
80
+ return new this(value);
81
+ }
82
+
83
+ // protected static METHODS
84
+
85
+ // private static METHODS
86
+
87
+ } //:: class
@@ -0,0 +1,136 @@
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 | null | undefined): boolean
51
+ {
52
+ if (other === null || other === undefined) {
53
+ return false;
54
+ }
55
+
56
+ return this.value === other.value;
57
+ }
58
+
59
+ public isInteger(): boolean
60
+ {
61
+ return Number.isInteger(this.value);
62
+ }
63
+
64
+ public isZero(): boolean
65
+ {
66
+ return this.value === 0;
67
+ }
68
+
69
+ public isPositive(): boolean
70
+ {
71
+ return this.value > 0;
72
+ }
73
+
74
+ public isNegative(): boolean
75
+ {
76
+ return this.value < 0;
77
+ }
78
+
79
+ public isOdd(): boolean
80
+ {
81
+ return (this.value & 1) === 1;
82
+ }
83
+
84
+ public isEven(): boolean
85
+ {
86
+ return (this.value & 1) === 0;
87
+ }
88
+
89
+ public isBetween(min: T, max: T, inclusiveMin = true, inclusiveMax = true): boolean
90
+ {
91
+
92
+ if (inclusiveMin && inclusiveMax) {
93
+ return this.value >= min && this.value <= max;
94
+ }
95
+
96
+ if (inclusiveMin) {
97
+ return this.value >= min && this.value < max;
98
+ }
99
+
100
+ if (inclusiveMax) {
101
+ return this.value > min && this.value <= max;
102
+ }
103
+
104
+ return this.value > min && this.value < max;
105
+
106
+ }
107
+
108
+ // protected METHODS
109
+
110
+ // private METHODS
111
+
112
+ // public static METHODS
113
+
114
+ public static override isValid(value: unknown): boolean
115
+ {
116
+ return (
117
+ 'number' === typeof value
118
+ && !Object.is(value, NaN)
119
+ && !Object.is(value, Infinity)
120
+ && !Object.is(value, -Infinity)
121
+ );
122
+ }
123
+
124
+ public static from(value: T): NumericValueObject
125
+ {
126
+ if (!this.isValid(value)) {
127
+ throw new ValueError(value, this.name);
128
+ }
129
+ return new this(value);
130
+ }
131
+
132
+ // protected static METHODS
133
+
134
+ // private static METHODS
135
+
136
+ } //:: class
@@ -0,0 +1,87 @@
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 | null | undefined): boolean
51
+ {
52
+ if (other === null || other === undefined) {
53
+ return false;
54
+ }
55
+
56
+ return this.value === other.value;
57
+ }
58
+
59
+ public isEmpty(): boolean
60
+ {
61
+ return this.value === '';
62
+ }
63
+
64
+ // protected METHODS
65
+
66
+ // private METHODS
67
+
68
+ // public static METHODS
69
+
70
+ public static override isValid(value: unknown): boolean
71
+ {
72
+ return ('string' === typeof value);
73
+ }
74
+
75
+ public static from(value: T): StringValueObject
76
+ {
77
+ if (!this.isValid(value)) {
78
+ throw new ValueError(value, this.name);
79
+ }
80
+ return new this(value);
81
+ }
82
+
83
+ // protected static METHODS
84
+
85
+ // private static METHODS
86
+
87
+ } //:: class
@@ -0,0 +1,82 @@
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 | null | undefined): boolean
51
+ {
52
+ if (other === null || other === undefined) {
53
+ return false;
54
+ }
55
+
56
+ return this.value === other.value;
57
+ }
58
+
59
+ // protected METHODS
60
+
61
+ // private METHODS
62
+
63
+ // public static METHODS
64
+
65
+ public static override isValid(value: unknown): boolean
66
+ {
67
+ return ('symbol' === typeof value);
68
+ }
69
+
70
+ public static from(value: T): SymbolValueObject
71
+ {
72
+ if (!this.isValid(value)) {
73
+ throw new ValueError(value, this.name);
74
+ }
75
+ return new this(value);
76
+ }
77
+
78
+ // protected static METHODS
79
+
80
+ // private static METHODS
81
+
82
+ } //:: 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 | null | undefined): 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