@xeno-js/cli 0.1.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/.github/.copilot-instruction.md +73 -0
- package/.github/agents/git-operator.agent.md +86 -0
- package/.github/agents/unit-tester.agent.md +68 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +37 -0
- package/LICENSE +15 -0
- package/README.md +236 -0
- package/commitlint.config.cjs +39 -0
- package/dist/domain/contracts/icommand-cli.contracts.js +2 -0
- package/dist/domain/contracts/icommand-runner.contracts.js +2 -0
- package/dist/domain/contracts/idispatch.contracts.js +2 -0
- package/dist/domain/contracts/ifile-service.contracts.js +2 -0
- package/dist/domain/contracts/igenerator.contracts.js +2 -0
- package/dist/domain/contracts/index.js +2 -0
- package/dist/domain/contracts/iscaffold-strategy.contracts.js +2 -0
- package/dist/domain/index.js +2 -0
- package/dist/generator.contracts.js +13 -0
- package/dist/index.js +31 -0
- package/dist/infrastructure/bootstrap/bootstrapper.js +32 -0
- package/dist/infrastructure/bootstrap/index.js +17 -0
- package/dist/infrastructure/builder/builder.js +16 -0
- package/dist/infrastructure/builder/builder.test.js +30 -0
- package/dist/infrastructure/builder/index.js +17 -0
- package/dist/infrastructure/command_launcher/command.utils.js +30 -0
- package/dist/infrastructure/command_launcher/index.js +2 -0
- package/dist/infrastructure/commands/command-runner.service.js +36 -0
- package/dist/infrastructure/commands/generate.command.js +48 -0
- package/dist/infrastructure/commands/help.command.js +44 -0
- package/dist/infrastructure/commands/index.js +20 -0
- package/dist/infrastructure/commands/new-project.command.js +43 -0
- package/dist/infrastructure/dispatcher/dispatcher.js +39 -0
- package/dist/infrastructure/dispatcher/index.js +17 -0
- package/dist/infrastructure/file/file.service.js +13 -0
- package/dist/infrastructure/file/index.js +17 -0
- package/dist/infrastructure/generators/bootstrap.generator.js +118 -0
- package/dist/infrastructure/generators/core/bootstrap.generator.js +118 -0
- package/dist/infrastructure/generators/core/command/cqrs.generator.js +49 -0
- package/dist/infrastructure/generators/core/command/generate-command.generator.js +163 -0
- package/dist/infrastructure/generators/core/command/generate-query.generator.js +131 -0
- package/dist/infrastructure/generators/core/drizzle-sql-lite.generator.js +78 -0
- package/dist/infrastructure/generators/core/drizzle.generator.js +85 -0
- package/dist/infrastructure/generators/core/env.generator.js +69 -0
- package/dist/infrastructure/generators/core/index.js +25 -0
- package/dist/infrastructure/generators/core/main.generator.js +45 -0
- package/dist/infrastructure/generators/core/packagejson.generator.js +78 -0
- package/dist/infrastructure/generators/core/readme.generator.js +431 -0
- package/dist/infrastructure/generators/core/registry.generator.js +46 -0
- package/dist/infrastructure/generators/core/tsconfig.generator.js +41 -0
- package/dist/infrastructure/generators/core-packagejson.generator.js +78 -0
- package/dist/infrastructure/generators/drizzle-sql-lite.generator.js +78 -0
- package/dist/infrastructure/generators/drizzle.generator.js +85 -0
- package/dist/infrastructure/generators/env-vue.generator.js +40 -0
- package/dist/infrastructure/generators/env.generator.js +71 -0
- package/dist/infrastructure/generators/gitignore.generator.js +62 -0
- package/dist/infrastructure/generators/index.js +26 -0
- package/dist/infrastructure/generators/main.generator.js +45 -0
- package/dist/infrastructure/generators/readme.generator.js +431 -0
- package/dist/infrastructure/generators/registry.generator.js +46 -0
- package/dist/infrastructure/generators/tsconfig-vue.generator.js +39 -0
- package/dist/infrastructure/generators/tsconfig.generator.js +41 -0
- package/dist/infrastructure/generators/vite-config.generator.js +39 -0
- package/dist/infrastructure/generators/vue/app-vue.generator.js +26 -0
- package/dist/infrastructure/generators/vue/bootstrap-ts.generator.js +59 -0
- package/dist/infrastructure/generators/vue/command_query/cqrs.generator.js +36 -0
- package/dist/infrastructure/generators/vue/command_query/generate-command-vue.generator.js +139 -0
- package/dist/infrastructure/generators/vue/command_query/generate-query-vue.generator.js +147 -0
- package/dist/infrastructure/generators/vue/env.generator.js +40 -0
- package/dist/infrastructure/generators/vue/index-html.generator.js +29 -0
- package/dist/infrastructure/generators/vue/index.js +28 -0
- package/dist/infrastructure/generators/vue/main.generator.js +45 -0
- package/dist/infrastructure/generators/vue/packagejson.generator.js +59 -0
- package/dist/infrastructure/generators/vue/readme.generator.js +394 -0
- package/dist/infrastructure/generators/vue/registry-ts.generator.js +28 -0
- package/dist/infrastructure/generators/vue/router.generator.js +33 -0
- package/dist/infrastructure/generators/vue/tailwind.generator.js +19 -0
- package/dist/infrastructure/generators/vue/tsconfig.generator.js +39 -0
- package/dist/infrastructure/generators/vue/use-app.generator.js +43 -0
- package/dist/infrastructure/generators/vue/vite-config.generator.js +39 -0
- package/dist/infrastructure/generators/vue-packagejson.generator.js +59 -0
- package/dist/infrastructure/generators/vue-readme.generator.js +53 -0
- package/dist/infrastructure/generators/vue-source-files.generator.js +136 -0
- package/dist/infrastructure/index.js +21 -0
- package/dist/infrastructure/strategies/core-scaffold.strategy.js +99 -0
- package/dist/infrastructure/strategies/index.js +18 -0
- package/dist/infrastructure/strategies/vue-scaffold.strategy.js +79 -0
- package/dist/scaffolding.engine.js +60 -0
- package/dist/shared/constants/command.constants.js +19 -0
- package/dist/shared/constants/core.constants.js +10 -0
- package/dist/shared/constants/index.js +18 -0
- package/dist/shared/index.js +18 -0
- package/dist/shared/types/common.types.js +2 -0
- package/dist/shared/types/index.js +2 -0
- package/dist/shared/utils/guards.utils.js +310 -0
- package/dist/shared/utils/index.js +18 -0
- package/dist/shared/utils/string.utils.js +62 -0
- package/eslint.config.mjs +305 -0
- package/lint-staged.config.mjs +5 -0
- package/logo/logo.png +0 -0
- package/package.json +65 -0
- package/src/domain/contracts/icommand-cli.contracts.ts +13 -0
- package/src/domain/contracts/icommand-runner.contracts.ts +3 -0
- package/src/domain/contracts/idispatch.contracts.ts +3 -0
- package/src/domain/contracts/ifile-service.contracts.ts +3 -0
- package/src/domain/contracts/igenerator.contracts.ts +5 -0
- package/src/domain/contracts/index.ts +6 -0
- package/src/domain/contracts/iscaffold-strategy.contracts.ts +7 -0
- package/src/domain/index.ts +1 -0
- package/src/index.ts +30 -0
- package/src/infrastructure/bootstrap/bootstrapper.ts +30 -0
- package/src/infrastructure/bootstrap/index.ts +1 -0
- package/src/infrastructure/builder/builder.test.ts +36 -0
- package/src/infrastructure/builder/builder.ts +15 -0
- package/src/infrastructure/builder/index.ts +1 -0
- package/src/infrastructure/command_launcher/command.utils.ts +31 -0
- package/src/infrastructure/command_launcher/index.ts +0 -0
- package/src/infrastructure/commands/command-runner.service.ts +36 -0
- package/src/infrastructure/commands/generate.command.ts +55 -0
- package/src/infrastructure/commands/help.command.ts +63 -0
- package/src/infrastructure/commands/index.ts +4 -0
- package/src/infrastructure/commands/new-project.command.ts +47 -0
- package/src/infrastructure/dispatcher/dispatcher.ts +45 -0
- package/src/infrastructure/dispatcher/index.ts +1 -0
- package/src/infrastructure/file/file.service.ts +14 -0
- package/src/infrastructure/file/index.ts +1 -0
- package/src/infrastructure/generators/core/bootstrap.generator.ts +118 -0
- package/src/infrastructure/generators/core/command/cqrs.generator.ts +63 -0
- package/src/infrastructure/generators/core/command/generate-command.generator.ts +191 -0
- package/src/infrastructure/generators/core/command/generate-query.generator.ts +150 -0
- package/src/infrastructure/generators/core/drizzle-sql-lite.generator.ts +76 -0
- package/src/infrastructure/generators/core/drizzle.generator.ts +86 -0
- package/src/infrastructure/generators/core/env.generator.ts +69 -0
- package/src/infrastructure/generators/core/index.ts +9 -0
- package/src/infrastructure/generators/core/main.generator.ts +41 -0
- package/src/infrastructure/generators/core/packagejson.generator.ts +70 -0
- package/src/infrastructure/generators/core/readme.generator.ts +427 -0
- package/src/infrastructure/generators/core/registry.generator.ts +40 -0
- package/src/infrastructure/generators/core/tsconfig.generator.ts +39 -0
- package/src/infrastructure/generators/gitignore.generator.ts +60 -0
- package/src/infrastructure/generators/vue/app-vue.generator.ts +21 -0
- package/src/infrastructure/generators/vue/bootstrap-ts.generator.ts +60 -0
- package/src/infrastructure/generators/vue/command_query/cqrs.generator.ts +36 -0
- package/src/infrastructure/generators/vue/command_query/generate-command-vue.generator.ts +153 -0
- package/src/infrastructure/generators/vue/command_query/generate-query-vue.generator.ts +161 -0
- package/src/infrastructure/generators/vue/env.generator.ts +39 -0
- package/src/infrastructure/generators/vue/index-html.generator.ts +24 -0
- package/src/infrastructure/generators/vue/index.ts +12 -0
- package/src/infrastructure/generators/vue/main.generator.ts +41 -0
- package/src/infrastructure/generators/vue/packagejson.generator.ts +50 -0
- package/src/infrastructure/generators/vue/readme.generator.ts +389 -0
- package/src/infrastructure/generators/vue/registry-ts.generator.ts +26 -0
- package/src/infrastructure/generators/vue/router.generator.ts +35 -0
- package/src/infrastructure/generators/vue/tailwind.generator.ts +17 -0
- package/src/infrastructure/generators/vue/tsconfig.generator.ts +38 -0
- package/src/infrastructure/generators/vue/use-app.generator.ts +38 -0
- package/src/infrastructure/generators/vue/vite-config.generator.ts +35 -0
- package/src/infrastructure/index.ts +5 -0
- package/src/infrastructure/strategies/core-scaffold.strategy.ts +100 -0
- package/src/infrastructure/strategies/index.ts +2 -0
- package/src/infrastructure/strategies/vue-scaffold.strategy.ts +79 -0
- package/src/shared/constants/command.constants.ts +18 -0
- package/src/shared/constants/core.constants.ts +7 -0
- package/src/shared/constants/index.ts +2 -0
- package/src/shared/index.ts +3 -0
- package/src/shared/types/common.types.ts +68 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/utils/guards.utils.ts +334 -0
- package/src/shared/utils/index.ts +2 -0
- package/src/shared/utils/string.utils.ts +60 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guards = void 0;
|
|
4
|
+
const OBJECT_TAG = '[object Object]';
|
|
5
|
+
const DATE_TAG = '[object Date]';
|
|
6
|
+
/**
|
|
7
|
+
* @description Centralized type guards and runtime predicates.
|
|
8
|
+
|
|
9
|
+
*
|
|
10
|
+
* @author Xeno
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
* @since 2025-09-30
|
|
13
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
14
|
+
*/
|
|
15
|
+
exports.Guards = Object.freeze({
|
|
16
|
+
/**
|
|
17
|
+
* @description Checks value is neither null nor undefined.
|
|
18
|
+
* @param value Candidate value.
|
|
19
|
+
* @returns True when value is defined.
|
|
20
|
+
|
|
21
|
+
*
|
|
22
|
+
* @author Xeno
|
|
23
|
+
* @version 1.0.0
|
|
24
|
+
* @since 2025-09-30
|
|
25
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
26
|
+
*/
|
|
27
|
+
isDefined(value) {
|
|
28
|
+
return value !== null && value !== undefined && value !== '' && !Number.isNaN(value);
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* @description Checks value is null, undefined, empty string, or false.
|
|
32
|
+
* @param value Candidate value.
|
|
33
|
+
* @returns True when value is null, undefined, empty string, or false.
|
|
34
|
+
|
|
35
|
+
*
|
|
36
|
+
* @author Xeno
|
|
37
|
+
* @version 1.0.0
|
|
38
|
+
* @since 2025-09-30
|
|
39
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
40
|
+
*/
|
|
41
|
+
isNullOrEmpty(value) {
|
|
42
|
+
return (!exports.Guards.isDefined(value) ||
|
|
43
|
+
(exports.Guards.isString(value) && value.trim() === '') ||
|
|
44
|
+
(exports.Guards.isArray(value) && value.length === 0));
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* @description Throws an error if the value is null, undefined, empty string, or false.
|
|
48
|
+
* @param value Candidate value.
|
|
49
|
+
* @param errorMessage Error message to throw if the check fails.
|
|
50
|
+
* @throws Error with the provided message if the value is null, undefined, empty string, or false.
|
|
51
|
+
|
|
52
|
+
*
|
|
53
|
+
* @author Xeno
|
|
54
|
+
* @version 1.0.0
|
|
55
|
+
* @since 2025-09-30
|
|
56
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
57
|
+
*/
|
|
58
|
+
throwIfNullOrEmpty(value, errorMessage) {
|
|
59
|
+
if (exports.Guards.isNullOrEmpty(value)) {
|
|
60
|
+
throw new Error(errorMessage);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* @description Throws an error if the value is not a positive integer.
|
|
65
|
+
* @param value Candidate value.
|
|
66
|
+
* @param errorMessage Error message to throw if the check fails.
|
|
67
|
+
* @throws Error with the provided message if the value is not a positive integer.
|
|
68
|
+
|
|
69
|
+
*
|
|
70
|
+
* @author Xeno
|
|
71
|
+
* @version 1.0.0
|
|
72
|
+
* @since 2025-09-30
|
|
73
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
74
|
+
*/
|
|
75
|
+
throwIfNegative(value, errorMessage) {
|
|
76
|
+
if (exports.Guards.isInteger(value) && value < 0) {
|
|
77
|
+
throw new Error(errorMessage);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* @description Throws an error if the value is not an integer.
|
|
82
|
+
* @param value Candidate value.
|
|
83
|
+
* @param errorMessage Error message to throw if the check fails.
|
|
84
|
+
* @throws Error with the provided message if the value is not an integer.
|
|
85
|
+
|
|
86
|
+
*
|
|
87
|
+
* @author Xeno
|
|
88
|
+
* @version 1.0.0
|
|
89
|
+
* @since 2025-09-30
|
|
90
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
91
|
+
*/
|
|
92
|
+
throwIfNotInteger(value, errorMessage) {
|
|
93
|
+
if (!exports.Guards.isInteger(value)) {
|
|
94
|
+
throw new Error(errorMessage);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* @description Checks if an object has a method with the given name.
|
|
99
|
+
* @param obj Object to check.
|
|
100
|
+
* @param methodName Name of the method to look for.
|
|
101
|
+
* @returns True when obj has a function property named methodName.
|
|
102
|
+
|
|
103
|
+
*
|
|
104
|
+
* @author Xeno
|
|
105
|
+
* @version 1.0.0
|
|
106
|
+
* @since 2025-09-30
|
|
107
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
108
|
+
*/
|
|
109
|
+
hasMethod(obj, methodName) {
|
|
110
|
+
if (!this.isDefined(obj))
|
|
111
|
+
return false;
|
|
112
|
+
// Essendo all'interno del namespace di utilità, l'uso di typeof qui è consentito
|
|
113
|
+
return exports.Guards.isFunction(obj[methodName]);
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* @description Checks value is a string.
|
|
117
|
+
* @param value Candidate value.
|
|
118
|
+
* @returns True when value is string.
|
|
119
|
+
|
|
120
|
+
*
|
|
121
|
+
* @author Xeno
|
|
122
|
+
* @version 1.0.0
|
|
123
|
+
* @since 2025-09-30
|
|
124
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
125
|
+
*/
|
|
126
|
+
isString(value) {
|
|
127
|
+
return typeof value === 'string';
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* @description Checks value is a finite number.
|
|
131
|
+
* @param value Candidate value.
|
|
132
|
+
* @returns True when value is finite number.
|
|
133
|
+
|
|
134
|
+
*
|
|
135
|
+
* @author Xeno
|
|
136
|
+
* @version 1.0.0
|
|
137
|
+
* @since 2025-09-30
|
|
138
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
139
|
+
*/
|
|
140
|
+
isNumber(value) {
|
|
141
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* @description Checks value is an integer number.
|
|
145
|
+
* @param value Candidate value.
|
|
146
|
+
* @returns True when value is integer number.
|
|
147
|
+
|
|
148
|
+
*
|
|
149
|
+
* @author Xeno
|
|
150
|
+
* @version 1.0.0
|
|
151
|
+
* @since 2025-09-30
|
|
152
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
153
|
+
*/
|
|
154
|
+
isInteger(value) {
|
|
155
|
+
return exports.Guards.isNumber(value) && Number.isInteger(value);
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* @description Checks value is boolean.
|
|
159
|
+
* @param value Candidate value.
|
|
160
|
+
* @returns True when value is boolean.
|
|
161
|
+
|
|
162
|
+
*
|
|
163
|
+
* @author Xeno
|
|
164
|
+
* @version 1.0.0
|
|
165
|
+
* @since 2025-09-30
|
|
166
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
167
|
+
*/
|
|
168
|
+
isBoolean(value) {
|
|
169
|
+
return typeof value === 'boolean';
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* @description Checks value is bigint.
|
|
173
|
+
* @param value Candidate value.
|
|
174
|
+
* @returns True when value is bigint.
|
|
175
|
+
|
|
176
|
+
*
|
|
177
|
+
* @author Xeno
|
|
178
|
+
* @version 1.0.0
|
|
179
|
+
* @since 2025-09-30
|
|
180
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
181
|
+
*/
|
|
182
|
+
isBigInt(value) {
|
|
183
|
+
return typeof value === 'bigint';
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* @description Checks value is symbol.
|
|
187
|
+
* @param value Candidate value.
|
|
188
|
+
* @returns True when value is symbol.
|
|
189
|
+
|
|
190
|
+
*
|
|
191
|
+
* @author Xeno
|
|
192
|
+
* @version 1.0.0
|
|
193
|
+
* @since 2025-09-30
|
|
194
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
195
|
+
*/
|
|
196
|
+
isSymbol(value) {
|
|
197
|
+
return typeof value === 'symbol';
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* @description Checks value is a function.
|
|
201
|
+
* @param value Candidate value.
|
|
202
|
+
* @returns True when value is function.
|
|
203
|
+
|
|
204
|
+
*
|
|
205
|
+
* @author Xeno
|
|
206
|
+
* @version 1.0.0
|
|
207
|
+
* @since 2025-09-30
|
|
208
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
209
|
+
*/
|
|
210
|
+
isFunction(value) {
|
|
211
|
+
return typeof value === 'function';
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* @description Checks value is an array.
|
|
215
|
+
* @param value Candidate value.
|
|
216
|
+
* @returns True when value is array.
|
|
217
|
+
|
|
218
|
+
*
|
|
219
|
+
* @author Xeno
|
|
220
|
+
* @version 1.0.0
|
|
221
|
+
* @since 2025-09-30
|
|
222
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
223
|
+
*/
|
|
224
|
+
isArray(value) {
|
|
225
|
+
return Array.isArray(value);
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
* @description Checks value is a Date instance with valid timestamp.
|
|
229
|
+
* @param value Candidate value.
|
|
230
|
+
* @returns True when value is valid Date.
|
|
231
|
+
|
|
232
|
+
*
|
|
233
|
+
* @author Xeno
|
|
234
|
+
* @version 1.0.0
|
|
235
|
+
* @since 2025-09-30
|
|
236
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
237
|
+
*/
|
|
238
|
+
isDate(value) {
|
|
239
|
+
if (Object.prototype.toString.call(value) !== DATE_TAG) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return Number.isFinite(value.getTime());
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* @description Checks value is an Error instance.
|
|
246
|
+
* @param value Candidate value.
|
|
247
|
+
* @returns True when value is Error.
|
|
248
|
+
|
|
249
|
+
*
|
|
250
|
+
* @author Xeno
|
|
251
|
+
* @version 1.0.0
|
|
252
|
+
* @since 2025-09-30
|
|
253
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
254
|
+
*/
|
|
255
|
+
isError(value) {
|
|
256
|
+
return value instanceof Error;
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* @description Checks value is a plain object record.
|
|
260
|
+
* @param value Candidate value.
|
|
261
|
+
* @returns True when value is object record.
|
|
262
|
+
|
|
263
|
+
*
|
|
264
|
+
* @author Xeno
|
|
265
|
+
* @version 1.0.0
|
|
266
|
+
* @since 2025-09-30
|
|
267
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
268
|
+
*/
|
|
269
|
+
isObjectRecord(value) {
|
|
270
|
+
if (!exports.Guards.isDefined(value)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
return Object.prototype.toString.call(value) === OBJECT_TAG;
|
|
274
|
+
},
|
|
275
|
+
/**
|
|
276
|
+
* @description Checks value is an object (not null).
|
|
277
|
+
* @param value Candidate value.
|
|
278
|
+
* @returns True when value is object.
|
|
279
|
+
|
|
280
|
+
*
|
|
281
|
+
* @author Xeno
|
|
282
|
+
* @version 1.0.0
|
|
283
|
+
* @since 2025-09-30
|
|
284
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
285
|
+
*/
|
|
286
|
+
isObject(value) {
|
|
287
|
+
return typeof value === 'object' && exports.Guards.isDefined(value);
|
|
288
|
+
},
|
|
289
|
+
/**
|
|
290
|
+
* @description Checks value is PromiseLike.
|
|
291
|
+
* @param value Candidate value.
|
|
292
|
+
* @returns True when value has then function.
|
|
293
|
+
|
|
294
|
+
*
|
|
295
|
+
* @author Xeno
|
|
296
|
+
* @version 1.0.0
|
|
297
|
+
* @since 2025-09-30
|
|
298
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
299
|
+
*/
|
|
300
|
+
isPromiseLike(value) {
|
|
301
|
+
if (!exports.Guards.isDefined(value)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
if (!exports.Guards.isObject(value) && !exports.Guards.isFunction(value)) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
const thenMember = value['then'];
|
|
308
|
+
return exports.Guards.isFunction(thenMember);
|
|
309
|
+
},
|
|
310
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./guards.utils"), exports);
|
|
18
|
+
__exportStar(require("./string.utils"), exports);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringUtils = void 0;
|
|
4
|
+
const guards_utils_1 = require("./guards.utils");
|
|
5
|
+
exports.StringUtils = Object.freeze({
|
|
6
|
+
/**
|
|
7
|
+
* @description Inserisce un underscore (_) tra la fine di una parola e l'inizio della successiva in formato camelCase o PascalCase.
|
|
8
|
+
* @param input Stringa in input (es. "CreateUser").
|
|
9
|
+
* @returns Stringa separata da underscore (es. "Create_User").
|
|
10
|
+
*
|
|
11
|
+
* @author Xeno
|
|
12
|
+
* @version 1.0.0
|
|
13
|
+
* @since 2026-09-18
|
|
14
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
15
|
+
*/
|
|
16
|
+
splitCamelCaseWithUnderscore(input) {
|
|
17
|
+
if (!guards_utils_1.Guards.isString(input) || guards_utils_1.Guards.isNullOrEmpty(input))
|
|
18
|
+
return input;
|
|
19
|
+
return input.replace(/([a-z])([A-Z])/g, '$1_$2');
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* @description Converts a string to camelCase.
|
|
23
|
+
* @param input Input string (supports snake_case, kebab-case, or space-separated).
|
|
24
|
+
* @returns camelCase string.
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
* @author Xeno
|
|
28
|
+
* @version 1.0.0
|
|
29
|
+
* @since 2025-09-30
|
|
30
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
31
|
+
*/
|
|
32
|
+
camelCase(input) {
|
|
33
|
+
const segments = input.split(/[-_\s]+/);
|
|
34
|
+
const [first, ...rest] = segments;
|
|
35
|
+
const head = guards_utils_1.Guards.isDefined(first) ? first.toLowerCase() : '';
|
|
36
|
+
return head + rest.map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join('');
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* @description Converts a string to PascalCase.
|
|
40
|
+
* @param input Input string (supports snake_case, kebab-case, space-separated, or camelCase).
|
|
41
|
+
* @returns PascalCase string.
|
|
42
|
+
*
|
|
43
|
+
* @author Xeno
|
|
44
|
+
* @version 1.0.0
|
|
45
|
+
* @since 2026-09-18
|
|
46
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
47
|
+
*/
|
|
48
|
+
pascalCase(input) {
|
|
49
|
+
if (!guards_utils_1.Guards.isString(input) || guards_utils_1.Guards.isNullOrEmpty(input))
|
|
50
|
+
return '';
|
|
51
|
+
const segments = input.split(/[-_\s]+/);
|
|
52
|
+
return segments
|
|
53
|
+
.filter((seg) => seg.length > 0)
|
|
54
|
+
.map((seg) => {
|
|
55
|
+
// Se il segmento è tutto maiuscolo (es. CREATE), lo normalizziamo in minuscolo per evitare cREATE.
|
|
56
|
+
// Altrimenti, preserviamo il casing interno originale (es. UserService resta UserService).
|
|
57
|
+
const normalized = seg === seg.toUpperCase() ? seg.toLowerCase() : seg;
|
|
58
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
59
|
+
})
|
|
60
|
+
.join('');
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import eslint from '@eslint/js'
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier'
|
|
3
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
4
|
+
import tseslint from 'typescript-eslint'
|
|
5
|
+
|
|
6
|
+
export default tseslint.config(
|
|
7
|
+
// ── Global ignores ───────────────────────────────────────────────────────
|
|
8
|
+
{
|
|
9
|
+
ignores: [
|
|
10
|
+
'**/node_modules/**',
|
|
11
|
+
'**/dist/**',
|
|
12
|
+
'**/coverage/**',
|
|
13
|
+
'.husky/**',
|
|
14
|
+
'eslint.config.mjs',
|
|
15
|
+
'lint-staged.config.mjs',
|
|
16
|
+
'commitlint.config.cjs',
|
|
17
|
+
'vitest.config.ts',
|
|
18
|
+
'demo/**',
|
|
19
|
+
'packages/**',
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// ── Base configs ─────────────────────────────────────────────────────────
|
|
24
|
+
eslint.configs.recommended,
|
|
25
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
26
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
27
|
+
|
|
28
|
+
// ── Type-aware parser (project-wide) ─────────────────────────────────────
|
|
29
|
+
{
|
|
30
|
+
languageOptions: {
|
|
31
|
+
parserOptions: {
|
|
32
|
+
project: ['./tsconfig.json', './tsconfig.test.json'],
|
|
33
|
+
tsconfigRootDir: import.meta.dirname,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// ── Source + test rules ──────────────────────────────────────────────────
|
|
39
|
+
{
|
|
40
|
+
files: ['src/**/*.ts', 'tests/**/*.ts'],
|
|
41
|
+
plugins: {
|
|
42
|
+
'simple-import-sort': simpleImportSort,
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
// ── Core JS ──────────────────────────────────────────────────────────
|
|
46
|
+
'curly': ['error', 'all'],
|
|
47
|
+
'eqeqeq': ['error', 'always', { null: 'ignore' }],
|
|
48
|
+
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
|
|
49
|
+
// Disabled: the core rule does not understand TypeScript's `import type`
|
|
50
|
+
// and flags intentional type/value split imports from the same module.
|
|
51
|
+
// `@typescript-eslint/consistent-type-imports` already enforces correct usage.
|
|
52
|
+
'no-duplicate-imports': 'off',
|
|
53
|
+
'no-var': 'error',
|
|
54
|
+
'object-shorthand': ['error', 'always'],
|
|
55
|
+
'prefer-const': 'error',
|
|
56
|
+
'prefer-template': 'error',
|
|
57
|
+
|
|
58
|
+
// ── Import order ──────────────────────────────────────────────────────
|
|
59
|
+
'simple-import-sort/imports': 'error',
|
|
60
|
+
'simple-import-sort/exports': 'error',
|
|
61
|
+
|
|
62
|
+
// ── TypeScript: type-safe guarantees ──────────────────────────────────
|
|
63
|
+
'@typescript-eslint/consistent-type-exports': 'error',
|
|
64
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
65
|
+
'error',
|
|
66
|
+
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
|
|
67
|
+
],
|
|
68
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
69
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
70
|
+
'@typescript-eslint/no-misused-promises': [
|
|
71
|
+
'error',
|
|
72
|
+
{ checksVoidReturn: { attributes: false } },
|
|
73
|
+
],
|
|
74
|
+
'@typescript-eslint/only-throw-error': 'error',
|
|
75
|
+
// '@typescript-eslint/return-await': ['error', 'in-try-catch'],
|
|
76
|
+
'@typescript-eslint/strict-boolean-expressions': [
|
|
77
|
+
'error',
|
|
78
|
+
{
|
|
79
|
+
allowString: false,
|
|
80
|
+
allowNumber: false,
|
|
81
|
+
allowNullableObject: false,
|
|
82
|
+
allowNullableBoolean: false,
|
|
83
|
+
allowNullableString: false,
|
|
84
|
+
allowNullableNumber: false,
|
|
85
|
+
allowAny: false,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
'@typescript-eslint/unbound-method': 'error',
|
|
89
|
+
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
90
|
+
'@typescript-eslint/no-unsafe-call': 'error',
|
|
91
|
+
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
92
|
+
'@typescript-eslint/no-unsafe-return': 'error',
|
|
93
|
+
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
94
|
+
'@typescript-eslint/restrict-template-expressions': 'error',
|
|
95
|
+
'@typescript-eslint/restrict-plus-operands': 'error',
|
|
96
|
+
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
|
97
|
+
'@typescript-eslint/require-await': 'off',
|
|
98
|
+
// ── TypeScript: code quality ──────────────────────────────────────────
|
|
99
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
100
|
+
'@typescript-eslint/no-unused-vars': [
|
|
101
|
+
'error',
|
|
102
|
+
{
|
|
103
|
+
argsIgnorePattern: '^_',
|
|
104
|
+
varsIgnorePattern: '^_',
|
|
105
|
+
ignoreRestSiblings: true,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
|
|
109
|
+
// ── TypeScript: naming conventions ────────────────────────────────────
|
|
110
|
+
'@typescript-eslint/naming-convention': [
|
|
111
|
+
'error',
|
|
112
|
+
// Type constructs → PascalCase
|
|
113
|
+
{ selector: 'typeLike', format: ['PascalCase'] },
|
|
114
|
+
// Enum members → UPPER_CASE (PascalCase tolerated for legacy)
|
|
115
|
+
{ selector: 'enumMember', format: ['UPPER_CASE', 'PascalCase'] },
|
|
116
|
+
// Default catch-all → camelCase (leading _ allowed for intentionally unused)
|
|
117
|
+
{
|
|
118
|
+
selector: 'default',
|
|
119
|
+
format: ['camelCase'],
|
|
120
|
+
leadingUnderscore: 'allow',
|
|
121
|
+
trailingUnderscore: 'forbid',
|
|
122
|
+
},
|
|
123
|
+
// Variables: also allow UPPER_CASE for module-level constants, PascalCase for imported classes
|
|
124
|
+
{
|
|
125
|
+
selector: 'variable',
|
|
126
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
127
|
+
leadingUnderscore: 'allow',
|
|
128
|
+
},
|
|
129
|
+
// Imports: PascalCase (classes/namespaces) and camelCase (functions/values)
|
|
130
|
+
{ selector: 'import', format: ['camelCase', 'PascalCase'] },
|
|
131
|
+
// Object literal properties: no restriction (external API / DB column mapping)
|
|
132
|
+
{ selector: 'objectLiteralProperty', format: null },
|
|
133
|
+
// Destructured variables: no restriction (external sources)
|
|
134
|
+
{ selector: 'variable', modifiers: ['destructured'], format: null },
|
|
135
|
+
],
|
|
136
|
+
|
|
137
|
+
// ── Disabled / adjusted ───────────────────────────────────────────────
|
|
138
|
+
'dot-notation': 'off',
|
|
139
|
+
'@typescript-eslint/dot-notation': 'off',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
// ── Test files: relax rules that conflict with test patterns ────────────
|
|
144
|
+
{
|
|
145
|
+
files: ['tests/**/*.ts'],
|
|
146
|
+
rules: {
|
|
147
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
148
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
149
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
// ── Layered architecture boundaries (DDD / Clean Architecture) ─────────
|
|
154
|
+
{
|
|
155
|
+
files: ['src/shared/**/*.ts'],
|
|
156
|
+
rules: {
|
|
157
|
+
'no-restricted-imports': [
|
|
158
|
+
'error',
|
|
159
|
+
{
|
|
160
|
+
patterns: [
|
|
161
|
+
{
|
|
162
|
+
group: [
|
|
163
|
+
'@/domain',
|
|
164
|
+
'@/domain/**',
|
|
165
|
+
'@/application',
|
|
166
|
+
'@/application/**',
|
|
167
|
+
'@/infrastructure',
|
|
168
|
+
'@/infrastructure/**',
|
|
169
|
+
'@/presentation',
|
|
170
|
+
'@/presentation/**',
|
|
171
|
+
],
|
|
172
|
+
message: 'shared can only import from shared and external libraries.',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
group: [
|
|
176
|
+
'../**/domain',
|
|
177
|
+
'../**/domain/**',
|
|
178
|
+
'../**/application',
|
|
179
|
+
'../**/application/**',
|
|
180
|
+
'../**/infrastructure',
|
|
181
|
+
'../**/infrastructure/**',
|
|
182
|
+
'../**/presentation',
|
|
183
|
+
'../**/presentation/**',
|
|
184
|
+
],
|
|
185
|
+
message: 'shared can only import from shared and external libraries.',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
files: ['src/domain/**/*.ts'],
|
|
194
|
+
rules: {
|
|
195
|
+
'no-restricted-imports': [
|
|
196
|
+
'error',
|
|
197
|
+
{
|
|
198
|
+
patterns: [
|
|
199
|
+
{
|
|
200
|
+
group: [
|
|
201
|
+
'@/application',
|
|
202
|
+
'@/application/**',
|
|
203
|
+
'@/infrastructure',
|
|
204
|
+
'@/infrastructure/**',
|
|
205
|
+
'@/presentation',
|
|
206
|
+
'@/presentation/**',
|
|
207
|
+
],
|
|
208
|
+
message: 'domain can only import from domain, shared, and external libraries.',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
group: [
|
|
212
|
+
'../**/application',
|
|
213
|
+
'../**/application/**',
|
|
214
|
+
'../**/infrastructure',
|
|
215
|
+
'../**/infrastructure/**',
|
|
216
|
+
'../**/presentation',
|
|
217
|
+
'../**/presentation/**',
|
|
218
|
+
],
|
|
219
|
+
message: 'domain can only import from domain, shared, and external libraries.',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
files: ['src/application/**/*.ts'],
|
|
228
|
+
rules: {
|
|
229
|
+
'no-restricted-imports': [
|
|
230
|
+
'error',
|
|
231
|
+
{
|
|
232
|
+
patterns: [
|
|
233
|
+
{
|
|
234
|
+
group: [
|
|
235
|
+
'@/infrastructure',
|
|
236
|
+
'@/infrastructure/**',
|
|
237
|
+
'@/presentation',
|
|
238
|
+
'@/presentation/**',
|
|
239
|
+
],
|
|
240
|
+
message:
|
|
241
|
+
'application can only import from application, domain, shared, and external libraries.',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
group: [
|
|
245
|
+
'../**/infrastructure',
|
|
246
|
+
'../**/infrastructure/**',
|
|
247
|
+
'../**/presentation',
|
|
248
|
+
'../**/presentation/**',
|
|
249
|
+
],
|
|
250
|
+
message:
|
|
251
|
+
'application can only import from application, domain, shared, and external libraries.',
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
files: ['src/infrastructure/**/*.ts'],
|
|
260
|
+
rules: {
|
|
261
|
+
'no-restricted-imports': [
|
|
262
|
+
'error',
|
|
263
|
+
{
|
|
264
|
+
patterns: [
|
|
265
|
+
{
|
|
266
|
+
group: ['@/presentation', '@/presentation/**'],
|
|
267
|
+
message:
|
|
268
|
+
'infrastructure can only import from infrastructure, domain, application, shared, and external libraries.',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
group: ['../**/presentation', '../**/presentation/**'],
|
|
272
|
+
message:
|
|
273
|
+
'infrastructure can only import from infrastructure, domain, application, shared, and external libraries.',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
files: ['src/presentation/**/*.ts'],
|
|
282
|
+
rules: {
|
|
283
|
+
'no-restricted-imports': [
|
|
284
|
+
'error',
|
|
285
|
+
{
|
|
286
|
+
patterns: [
|
|
287
|
+
{
|
|
288
|
+
group: ['@/infrastructure', '@/infrastructure/**'],
|
|
289
|
+
message:
|
|
290
|
+
'presentation can only import from presentation, domain, application, shared, and external libraries.',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
group: ['../**/infrastructure', '../**/infrastructure/**'],
|
|
294
|
+
message:
|
|
295
|
+
'presentation can only import from presentation, domain, application, shared, and external libraries.',
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
// ── Prettier (must be last) ───────────────────────────────────────────────
|
|
304
|
+
eslintConfigPrettier,
|
|
305
|
+
)
|