@abp/ng.schematics 10.5.0-rc.4 → 10.6.0-rc.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.
- package/commands/ai-config/index.d.ts +3 -3
- package/commands/ai-config/index.js +88 -88
- package/commands/ai-config/index.js.map +1 -1
- package/commands/ai-config/model.d.ts +10 -10
- package/commands/ai-config/model.js +2 -2
- package/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template +6 -4
- package/commands/api/index.d.ts +2 -2
- package/commands/api/index.js +139 -138
- package/commands/api/index.js.map +1 -1
- package/commands/change-theme/index.d.ts +28 -28
- package/commands/change-theme/index.js +474 -473
- package/commands/change-theme/index.js.map +1 -1
- package/commands/change-theme/model.d.ts +5 -5
- package/commands/change-theme/model.js +2 -2
- package/commands/change-theme/style-map.d.ts +16 -16
- package/commands/change-theme/style-map.js +424 -424
- package/commands/change-theme/theme-options.enum.d.ts +6 -6
- package/commands/change-theme/theme-options.enum.js +11 -11
- package/commands/change-theme/theme-options.enum.js.map +1 -1
- package/commands/create-lib/index.d.ts +13 -13
- package/commands/create-lib/index.js +298 -298
- package/commands/create-lib/index.js.map +1 -1
- package/commands/create-lib/models/generate-lib-schema.d.ts +20 -20
- package/commands/create-lib/models/generate-lib-schema.js +8 -8
- package/commands/create-lib/models/generate-lib-schema.js.map +1 -1
- package/commands/create-lib/models/index.d.ts +1 -1
- package/commands/create-lib/models/index.js +4 -17
- package/commands/create-lib/models/index.js.map +1 -1
- package/commands/proxy-add/index.d.ts +2 -2
- package/commands/proxy-add/index.js +41 -41
- package/commands/proxy-add/index.js.map +1 -1
- package/commands/proxy-index/index.d.ts +5 -5
- package/commands/proxy-index/index.js +14 -14
- package/commands/proxy-index/index.js.map +1 -1
- package/commands/proxy-refresh/index.d.ts +3 -3
- package/commands/proxy-refresh/index.js +27 -27
- package/commands/proxy-refresh/index.js.map +1 -1
- package/commands/proxy-remove/index.d.ts +3 -3
- package/commands/proxy-remove/index.js +33 -33
- package/commands/proxy-remove/index.js.map +1 -1
- package/commands/ssr-add/index.d.ts +11 -11
- package/commands/ssr-add/index.js +360 -361
- package/commands/ssr-add/index.js.map +1 -1
- package/commands/ssr-add/server/index.d.ts +10 -10
- package/commands/ssr-add/server/index.js +209 -205
- package/commands/ssr-add/server/index.js.map +1 -1
- package/commands/ssr-add/server/index.ts +6 -2
- package/constants/api.d.ts +1 -1
- package/constants/api.js +4 -4
- package/constants/index.d.ts +4 -4
- package/constants/index.js +7 -20
- package/constants/index.js.map +1 -1
- package/constants/proxy.d.ts +4 -4
- package/constants/proxy.js +7 -7
- package/constants/symbols.d.ts +1 -1
- package/constants/symbols.js +4 -4
- package/constants/system-types.d.ts +1 -1
- package/constants/system-types.js +29 -29
- package/constants/volo.d.ts +5 -5
- package/constants/volo.js +34 -34
- package/enums/binding-source-id.d.ts +8 -7
- package/enums/binding-source-id.js +12 -11
- package/enums/binding-source-id.js.map +1 -1
- package/enums/exception.d.ts +17 -17
- package/enums/exception.js +2 -2
- package/enums/import-keyword.d.ts +4 -4
- package/enums/import-keyword.js +8 -8
- package/enums/import-keyword.js.map +1 -1
- package/enums/index.d.ts +5 -5
- package/enums/index.js +8 -21
- package/enums/index.js.map +1 -1
- package/enums/method-modifier.d.ts +6 -6
- package/enums/method-modifier.js +10 -10
- package/enums/method-modifier.js.map +1 -1
- package/enums/service-types.d.ts +6 -6
- package/enums/service-types.js +10 -10
- package/enums/service-types.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +6 -19
- package/index.js.map +1 -1
- package/models/api-definition.d.ts +97 -93
- package/models/api-definition.js +2 -2
- package/models/generate-proxy-schema.d.ts +28 -28
- package/models/generate-proxy-schema.js +2 -2
- package/models/import.d.ts +11 -11
- package/models/import.js +13 -13
- package/models/index.d.ts +11 -11
- package/models/index.js +14 -27
- package/models/index.js.map +1 -1
- package/models/method.d.ts +36 -34
- package/models/method.js +73 -70
- package/models/method.js.map +1 -1
- package/models/model.d.ts +48 -48
- package/models/model.js +76 -76
- package/models/model.js.map +1 -1
- package/models/project.d.ts +5 -5
- package/models/project.js +2 -2
- package/models/proxy-config.d.ts +4 -4
- package/models/proxy-config.js +2 -2
- package/models/rule.d.ts +2 -2
- package/models/rule.js +2 -2
- package/models/service.d.ts +21 -21
- package/models/service.js +11 -11
- package/models/tree.d.ts +1 -1
- package/models/tree.js +2 -2
- package/models/util.d.ts +7 -7
- package/models/util.js +2 -2
- package/package.json +6 -6
- package/utils/angular/add-declaration-to-ng-module.d.ts +20 -20
- package/utils/angular/add-declaration-to-ng-module.js +45 -45
- package/utils/angular/add-declaration-to-ng-module.js.map +1 -1
- package/utils/angular/ast-utils.d.ts +106 -106
- package/utils/angular/ast-utils.js +518 -518
- package/utils/angular/ast-utils.js.map +1 -1
- package/utils/angular/change.d.ts +68 -68
- package/utils/angular/change.js +121 -121
- package/utils/angular/change.js.map +1 -1
- package/utils/angular/dependencies.d.ts +23 -23
- package/utils/angular/dependencies.js +56 -56
- package/utils/angular/dependencies.js.map +1 -1
- package/utils/angular/dependency.d.ts +96 -96
- package/utils/angular/dependency.js +123 -122
- package/utils/angular/dependency.js.map +1 -1
- package/utils/angular/eol.d.ts +8 -8
- package/utils/angular/eol.js +22 -23
- package/utils/angular/eol.js.map +1 -1
- package/utils/angular/find-module.d.ts +33 -33
- package/utils/angular/find-module.js +105 -105
- package/utils/angular/find-module.js.map +1 -1
- package/utils/angular/generate-from-files.d.ts +19 -19
- package/utils/angular/generate-from-files.js +48 -49
- package/utils/angular/generate-from-files.js.map +1 -1
- package/utils/angular/index.d.ts +15 -15
- package/utils/angular/index.js +18 -31
- package/utils/angular/index.js.map +1 -1
- package/utils/angular/json-file.d.ts +24 -24
- package/utils/angular/json-file.js +71 -71
- package/utils/angular/json-file.js.map +1 -1
- package/utils/angular/latest-versions/index.d.ts +28 -28
- package/utils/angular/latest-versions/index.js +31 -31
- package/utils/angular/ng-ast-utils.d.ts +12 -12
- package/utils/angular/ng-ast-utils.js +79 -79
- package/utils/angular/ng-ast-utils.js.map +1 -1
- package/utils/angular/parse-name.d.ts +13 -13
- package/utils/angular/parse-name.js +19 -20
- package/utils/angular/parse-name.js.map +1 -1
- package/utils/angular/paths.d.ts +8 -8
- package/utils/angular/paths.js +17 -18
- package/utils/angular/paths.js.map +1 -1
- package/utils/angular/project-targets.d.ts +11 -11
- package/utils/angular/project-targets.js +21 -22
- package/utils/angular/project-targets.js.map +1 -1
- package/utils/angular/standalone/app_component.d.ts +29 -29
- package/utils/angular/standalone/app_component.js +107 -107
- package/utils/angular/standalone/app_component.js.map +1 -1
- package/utils/angular/standalone/app_config.d.ts +23 -23
- package/utils/angular/standalone/app_config.js +89 -89
- package/utils/angular/standalone/app_config.js.map +1 -1
- package/utils/angular/standalone/code_block.d.ts +53 -53
- package/utils/angular/standalone/code_block.js +80 -79
- package/utils/angular/standalone/code_block.js.map +1 -1
- package/utils/angular/standalone/index.d.ts +9 -9
- package/utils/angular/standalone/index.js +13 -13
- package/utils/angular/standalone/rules.d.ts +45 -45
- package/utils/angular/standalone/rules.js +187 -188
- package/utils/angular/standalone/rules.js.map +1 -1
- package/utils/angular/standalone/util.d.ts +35 -35
- package/utils/angular/standalone/util.js +135 -135
- package/utils/angular/standalone/util.js.map +1 -1
- package/utils/angular/test/create-app-module.d.ts +9 -9
- package/utils/angular/test/create-app-module.js +14 -15
- package/utils/angular/test/create-app-module.js.map +1 -1
- package/utils/angular/test/get-file-content.d.ts +9 -9
- package/utils/angular/test/get-file-content.js +17 -18
- package/utils/angular/test/get-file-content.js.map +1 -1
- package/utils/angular/test/index.d.ts +9 -9
- package/utils/angular/test/index.js +12 -25
- package/utils/angular/test/index.js.map +1 -1
- package/utils/angular/validation.d.ts +10 -10
- package/utils/angular/validation.js +28 -28
- package/utils/angular/validation.js.map +1 -1
- package/utils/angular/workspace-models.d.ts +167 -167
- package/utils/angular/workspace-models.js +43 -43
- package/utils/angular/workspace-models.js.map +1 -1
- package/utils/angular/workspace.d.ts +65 -65
- package/utils/angular/workspace.js +135 -135
- package/utils/angular/workspace.js.map +1 -1
- package/utils/angular-schematic/generate-lib.d.ts +3 -3
- package/utils/angular-schematic/generate-lib.js +52 -53
- package/utils/angular-schematic/generate-lib.js.map +1 -1
- package/utils/angular-schematic/index.d.ts +1 -1
- package/utils/angular-schematic/index.js +4 -17
- package/utils/angular-schematic/index.js.map +1 -1
- package/utils/api.d.ts +2 -2
- package/utils/api.js +7 -8
- package/utils/api.js.map +1 -1
- package/utils/ast.d.ts +5 -5
- package/utils/ast.js +28 -28
- package/utils/ast.js.map +1 -1
- package/utils/barrel.d.ts +4 -4
- package/utils/barrel.js +86 -87
- package/utils/barrel.js.map +1 -1
- package/utils/common.d.ts +11 -11
- package/utils/common.js +78 -78
- package/utils/common.js.map +1 -1
- package/utils/enum.d.ts +18 -18
- package/utils/enum.js +39 -40
- package/utils/enum.js.map +1 -1
- package/utils/file.d.ts +2 -2
- package/utils/file.js +8 -9
- package/utils/file.js.map +1 -1
- package/utils/generics.d.ts +26 -26
- package/utils/generics.js +89 -89
- package/utils/generics.js.map +1 -1
- package/utils/import.d.ts +3 -3
- package/utils/import.js +10 -11
- package/utils/import.js.map +1 -1
- package/utils/index.d.ts +22 -22
- package/utils/index.js +25 -38
- package/utils/index.js.map +1 -1
- package/utils/methods.d.ts +4 -4
- package/utils/methods.js +31 -29
- package/utils/methods.js.map +1 -1
- package/utils/model.d.ts +14 -14
- package/utils/model.js +217 -211
- package/utils/model.js.map +1 -1
- package/utils/namespace.d.ts +1 -1
- package/utils/namespace.js +17 -18
- package/utils/namespace.js.map +1 -1
- package/utils/ng-module.d.ts +46 -46
- package/utils/ng-module.js +126 -125
- package/utils/ng-module.js.map +1 -1
- package/utils/path.d.ts +2 -2
- package/utils/path.js +35 -36
- package/utils/path.js.map +1 -1
- package/utils/rule.d.ts +4 -4
- package/utils/rule.js +32 -33
- package/utils/rule.js.map +1 -1
- package/utils/service.d.ts +8 -8
- package/utils/service.js +280 -171
- package/utils/service.js.map +1 -1
- package/utils/source.d.ts +13 -13
- package/utils/source.js +165 -165
- package/utils/source.js.map +1 -1
- package/utils/standalone.d.ts +59 -59
- package/utils/standalone.js +146 -145
- package/utils/standalone.js.map +1 -1
- package/utils/text.d.ts +10 -10
- package/utils/text.js +59 -59
- package/utils/text.js.map +1 -1
- package/utils/tree.d.ts +14 -14
- package/utils/tree.js +83 -83
- package/utils/tree.js.map +1 -1
- package/utils/type.d.ts +13 -13
- package/utils/type.js +112 -113
- package/utils/type.js.map +1 -1
- package/utils/workspace.d.ts +20 -20
- package/utils/workspace.js +113 -114
- package/utils/workspace.js.map +1 -1
package/utils/model.js
CHANGED
|
@@ -1,212 +1,218 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
prop.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
.reduce(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createImportRefsToModelReducer = createImportRefsToModelReducer;
|
|
4
|
+
exports.createImportRefToInterfaceReducerCreator = createImportRefToInterfaceReducerCreator;
|
|
5
|
+
exports.createRefToImportReducerCreator = createRefToImportReducerCreator;
|
|
6
|
+
exports.parseBaseTypeWithGenericTypes = parseBaseTypeWithGenericTypes;
|
|
7
|
+
exports.resolveAbpPackages = resolveAbpPackages;
|
|
8
|
+
exports.resolveSelfGenericProps = resolveSelfGenericProps;
|
|
9
|
+
const models_1 = require("../models");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const namespace_1 = require("./namespace");
|
|
12
|
+
const path_1 = require("./path");
|
|
13
|
+
const text_1 = require("./text");
|
|
14
|
+
const tree_1 = require("./tree");
|
|
15
|
+
const type_1 = require("./type");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
18
|
+
const shouldQuote = require('should-quote');
|
|
19
|
+
function createImportRefsToModelReducer(params) {
|
|
20
|
+
const reduceImportRefsToInterfaces = createImportRefToInterfaceReducerCreator(params);
|
|
21
|
+
const createRefToImportReducer = createRefToImportReducerCreator(params);
|
|
22
|
+
const { solution, types } = params;
|
|
23
|
+
return (models, importRefs) => {
|
|
24
|
+
const enums = [];
|
|
25
|
+
const interfaces = importRefs.reduce(reduceImportRefsToInterfaces, []);
|
|
26
|
+
sortInterfaces(interfaces);
|
|
27
|
+
interfaces.forEach(_interface => {
|
|
28
|
+
if (constants_1.VOLO_REGEX.test(_interface.ref) || constants_1.VOLO_PACKAGE_PROXY_IMPORTS.has(_interface.ref))
|
|
29
|
+
return;
|
|
30
|
+
if (types[_interface.ref].isEnum) {
|
|
31
|
+
if (!enums.includes(_interface.ref))
|
|
32
|
+
enums.push(_interface.ref);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const index = models.findIndex(m => m.namespace === _interface.namespace);
|
|
36
|
+
if (index > -1) {
|
|
37
|
+
if (models[index].interfaces.some(i => i.identifier === _interface.identifier))
|
|
38
|
+
return;
|
|
39
|
+
models[index].interfaces.push(_interface);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const { namespace } = _interface;
|
|
43
|
+
models.push(new models_1.Model({
|
|
44
|
+
interfaces: [_interface],
|
|
45
|
+
namespace,
|
|
46
|
+
path: (0, path_1.relativePathToModel)(namespace, namespace),
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
models.forEach(model => {
|
|
51
|
+
const toBeImported = [];
|
|
52
|
+
model.interfaces.forEach(_interface => {
|
|
53
|
+
const { baseType } = types[_interface.ref];
|
|
54
|
+
if (baseType && (0, namespace_1.parseNamespace)(solution, baseType) !== model.namespace) {
|
|
55
|
+
const baseTypeWithGenericParams = parseBaseTypeWithGenericTypes(baseType);
|
|
56
|
+
baseTypeWithGenericParams.forEach(t => {
|
|
57
|
+
// A generic argument of the base type (e.g. T in PagedResultDto<T>) may live in the
|
|
58
|
+
// same namespace as this model, which means it is generated into the same models.ts
|
|
59
|
+
// file. Importing it would produce an invalid self-import (`from './models'`), so we
|
|
60
|
+
// skip same-namespace types here, mirroring the property handling below. See #25080.
|
|
61
|
+
if ((0, namespace_1.parseNamespace)(solution, t) === model.namespace) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
toBeImported.push({
|
|
65
|
+
type: t,
|
|
66
|
+
isEnum: false,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
[..._interface.properties, ..._interface.generics].forEach(prop => {
|
|
71
|
+
prop.refs.forEach(ref => {
|
|
72
|
+
const propType = types[ref];
|
|
73
|
+
if (!propType) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (propType.isEnum) {
|
|
77
|
+
toBeImported.push({ type: ref, isEnum: true });
|
|
78
|
+
}
|
|
79
|
+
else if ((0, namespace_1.parseNamespace)(solution, ref) !== model.namespace) {
|
|
80
|
+
toBeImported.push({ type: ref, isEnum: false });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
if (!toBeImported.length)
|
|
86
|
+
return;
|
|
87
|
+
const reduceRefToImport = createRefToImportReducer(model.namespace);
|
|
88
|
+
reduceRefToImport(model.imports, toBeImported);
|
|
89
|
+
});
|
|
90
|
+
return models;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function sortInterfaces(interfaces) {
|
|
94
|
+
interfaces.sort((a, b) => (a.identifier > b.identifier ? 1 : -1));
|
|
95
|
+
}
|
|
96
|
+
function createImportRefToInterfaceReducerCreator(params) {
|
|
97
|
+
const { solution, types } = params;
|
|
98
|
+
const parseType = (0, type_1.createTypeParser)(type_1.removeTypeModifiers);
|
|
99
|
+
const simplifyType = (0, type_1.createTypeSimplifier)();
|
|
100
|
+
const getIdentifier = (type) => (0, type_1.removeTypeModifiers)(simplifyType(type));
|
|
101
|
+
const genericsCollector = new generics_1.GenericsCollector(getIdentifier);
|
|
102
|
+
return reduceRefsToInterfaces;
|
|
103
|
+
function reduceRefsToInterfaces(interfaces, ref) {
|
|
104
|
+
const typeDef = types[ref];
|
|
105
|
+
if (!typeDef)
|
|
106
|
+
return interfaces;
|
|
107
|
+
const namespace = (0, namespace_1.parseNamespace)(solution, ref);
|
|
108
|
+
let { baseType: base, genericArguments } = typeDef;
|
|
109
|
+
genericArguments = genericArguments || [];
|
|
110
|
+
let identifier = getIdentifier(ref);
|
|
111
|
+
identifier = (0, generics_1.replacePlaceholdersWithGenerics)(identifier, genericArguments, genericsCollector);
|
|
112
|
+
if (base) {
|
|
113
|
+
if ((0, type_1.extendsSelf)(ref, base)) {
|
|
114
|
+
genericsCollector.collect((0, generics_1.extractGenerics)(base).generics, genericArguments);
|
|
115
|
+
return reduceRefsToInterfaces(interfaces, (0, generics_1.generateRefWithPlaceholders)(base));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
base = getIdentifier(base);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const { generics } = genericsCollector;
|
|
122
|
+
const _interface = new models_1.Interface({ identifier, base, namespace, ref, generics });
|
|
123
|
+
genericsCollector.reset();
|
|
124
|
+
typeDef.properties?.forEach(prop => {
|
|
125
|
+
let name = prop.jsonName || (0, text_1.camel)(prop.name);
|
|
126
|
+
name = shouldQuote(name) ? `'${name}'` : name;
|
|
127
|
+
let type = simplifyType(prop.typeSimple);
|
|
128
|
+
if (prop.typeSimple.includes('enum')) {
|
|
129
|
+
type = simplifyType(prop.type);
|
|
130
|
+
}
|
|
131
|
+
if (prop.isNullable) {
|
|
132
|
+
type = `${type} | null`;
|
|
133
|
+
}
|
|
134
|
+
const refs = parseType(prop.type).reduce((acc, r) => acc.concat((0, tree_1.parseGenerics)(r).toGenerics()), []);
|
|
135
|
+
const property = new models_1.Property({ name, type, refs });
|
|
136
|
+
property.setOptional(isOptionalProperty(prop));
|
|
137
|
+
_interface.properties.push(property);
|
|
138
|
+
});
|
|
139
|
+
interfaces.push(_interface);
|
|
140
|
+
return [..._interface.properties, ..._interface.generics]
|
|
141
|
+
.reduce((refs, prop) => {
|
|
142
|
+
prop.refs.forEach(type => {
|
|
143
|
+
if (types[type]?.isEnum)
|
|
144
|
+
return;
|
|
145
|
+
if (interfaces.some(i => i.ref === type))
|
|
146
|
+
return;
|
|
147
|
+
refs.push(type);
|
|
148
|
+
});
|
|
149
|
+
return refs;
|
|
150
|
+
}, [])
|
|
151
|
+
.concat(base ? (0, tree_1.parseGenerics)(typeDef.baseType).toGenerics() : [])
|
|
152
|
+
.reduce(reduceRefsToInterfaces, interfaces);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function createRefToImportReducerCreator(params) {
|
|
156
|
+
const { solution } = params;
|
|
157
|
+
return (namespace) => (0, type_1.createTypesToImportsReducer)(solution, namespace);
|
|
158
|
+
}
|
|
159
|
+
function isOptionalProperty(prop) {
|
|
160
|
+
return !prop.isRequired;
|
|
161
|
+
}
|
|
162
|
+
function parseBaseTypeWithGenericTypes(type) {
|
|
163
|
+
const parsedTypeNode = (0, tree_1.parseGenerics)(type);
|
|
164
|
+
const nodeToText = (node, acc = []) => {
|
|
165
|
+
acc.push(node.data);
|
|
166
|
+
if (node.children && node.children.length > 0) {
|
|
167
|
+
node.children.forEach(child => {
|
|
168
|
+
nodeToText(child, acc);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return acc;
|
|
172
|
+
};
|
|
173
|
+
return nodeToText(parsedTypeNode);
|
|
174
|
+
}
|
|
175
|
+
function resolveAbpPackages(models) {
|
|
176
|
+
for (const model of models) {
|
|
177
|
+
renamePropForTenant(model.interfaces);
|
|
178
|
+
model.imports.forEach((imp, i) => {
|
|
179
|
+
for (const ref of imp.refs) {
|
|
180
|
+
const path = constants_1.VOLO_PACKAGE_PROXY_IMPORTS.get(ref);
|
|
181
|
+
if (path) {
|
|
182
|
+
model.imports[i] = new models_1.Import({ ...imp, path });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function renamePropForTenant(interfaces) {
|
|
189
|
+
for (const inters of interfaces) {
|
|
190
|
+
for (const prop of inters.properties) {
|
|
191
|
+
const isTenant = prop.name.toLocaleLowerCase().includes(constants_1.TENANT_KEY);
|
|
192
|
+
const isSaasDto = prop.refs.filter(f => f.startsWith(constants_1.SAAS_NAMESPACE)).length > 0;
|
|
193
|
+
if (isTenant && isSaasDto && !prop.type.startsWith('Saas')) {
|
|
194
|
+
prop.type = 'Saas' + prop.type;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function resolveSelfGenericProps(params) {
|
|
200
|
+
const { types, solution } = params;
|
|
201
|
+
if (!types || !solution) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
Object.keys(types)
|
|
205
|
+
.filter(f => f.startsWith(solution))
|
|
206
|
+
.forEach(key => {
|
|
207
|
+
const type = types[key];
|
|
208
|
+
if (type.genericArguments?.length) {
|
|
209
|
+
type.properties?.map(prop => {
|
|
210
|
+
if (prop.type.includes('<>')) {
|
|
211
|
+
prop.type = prop.type.replace('<>', `<${type.genericArguments.join(', ')}>`);
|
|
212
|
+
prop.typeSimple = prop.typeSimple.replace('<>', `<${type.genericArguments.join(', ')}>`);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
212
218
|
//# sourceMappingURL=model.js.map
|
package/utils/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/model.ts"],"names":[],"mappings":";;AA+BA,wEAoFC;AAMD,4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GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CACvC,IAAI,EACJ,IAAI,IAAI,CAAC,gBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACzC,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/utils/namespace.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function parseNamespace(solution: string, type: string): string;
|
|
1
|
+
export declare function parseNamespace(solution: string, type: string): string;
|
package/utils/namespace.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseNamespace =
|
|
4
|
-
const type_1 = require("./type");
|
|
5
|
-
function parseNamespace(solution, type) {
|
|
6
|
-
const parseType = (0, type_1.createTypeParser)(type_1.removeGenerics);
|
|
7
|
-
let namespace = parseType(type)[0].split('.').slice(0, -1).join('.');
|
|
8
|
-
if (solution === namespace)
|
|
9
|
-
return '';
|
|
10
|
-
solution.split('.').reduceRight((acc, part) => {
|
|
11
|
-
acc = `${part}\\.${acc}`;
|
|
12
|
-
const regex = new RegExp(`^${acc}(Controllers\\.)?`);
|
|
13
|
-
namespace = namespace.replace(regex, '');
|
|
14
|
-
return acc;
|
|
15
|
-
}, '');
|
|
16
|
-
return namespace;
|
|
17
|
-
}
|
|
18
|
-
exports.parseNamespace = parseNamespace;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseNamespace = parseNamespace;
|
|
4
|
+
const type_1 = require("./type");
|
|
5
|
+
function parseNamespace(solution, type) {
|
|
6
|
+
const parseType = (0, type_1.createTypeParser)(type_1.removeGenerics);
|
|
7
|
+
let namespace = parseType(type)[0].split('.').slice(0, -1).join('.');
|
|
8
|
+
if (solution === namespace)
|
|
9
|
+
return '';
|
|
10
|
+
solution.split('.').reduceRight((acc, part) => {
|
|
11
|
+
acc = `${part}\\.${acc}`;
|
|
12
|
+
const regex = new RegExp(`^${acc}(Controllers\\.)?`);
|
|
13
|
+
namespace = namespace.replace(regex, '');
|
|
14
|
+
return acc;
|
|
15
|
+
}, '');
|
|
16
|
+
return namespace;
|
|
17
|
+
}
|
|
19
18
|
//# sourceMappingURL=namespace.js.map
|
package/utils/namespace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/namespace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/namespace.ts"],"names":[],"mappings":";;AAEA,wCAcC;AAhBD,iCAA0D;AAE1D,SAAgB,cAAc,CAAC,QAAgB,EAAE,IAAY;IAC3D,MAAM,SAAS,GAAG,IAAA,uBAAgB,EAAC,qBAAc,CAAC,CAAC;IACnD,IAAI,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAErE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAEtC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAC5C,GAAG,GAAG,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAC,CAAC;QACrD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/utils/ng-module.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Tree, UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
-
import * as ts from 'typescript';
|
|
3
|
-
import { Path } from '@angular-devkit/core';
|
|
4
|
-
/**
|
|
5
|
-
* Checks whether a specific import or provider exists in the specified metadata
|
|
6
|
-
* array (`imports`, `providers`, etc.) of the `NgModule` decorator in the AppModule.
|
|
7
|
-
*
|
|
8
|
-
* This function locates the AppModule file of the given Angular project,
|
|
9
|
-
* parses its AST, and inspects the specified metadata array to determine
|
|
10
|
-
* if it includes an element matching the provided string (e.g., `CommonModule`, `HttpClientModule`).
|
|
11
|
-
*
|
|
12
|
-
* @param host - The virtual file system tree used by Angular schematics.
|
|
13
|
-
* @param projectName - The name of the Angular project.
|
|
14
|
-
* @param metadataFn - The name (string) to match against the elements of the metadata array.
|
|
15
|
-
* @param metadataName - The metadata field to search in (e.g., 'imports', 'providers'). Defaults to 'imports'.
|
|
16
|
-
* @returns A promise that resolves to `true` if the metadata function is found, or `false` otherwise.
|
|
17
|
-
* @throws SchematicsException if the AppModule file or expected metadata is not found or malformed.
|
|
18
|
-
*/
|
|
19
|
-
export declare const hasImportInNgModule: (host: Tree, projectName: string, metadataFn: string, metadataName?: string) => Promise<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* Attempts to locate the path of the `AppRoutingModule` file that is imported
|
|
22
|
-
* within the root AppModule file of an Angular application.
|
|
23
|
-
*
|
|
24
|
-
* This function reads the AppModule file (resolved from the main file path),
|
|
25
|
-
* parses its AST, and searches for an import declaration that imports
|
|
26
|
-
* `AppRoutingModule`. Once found, it resolves the import path to a normalized
|
|
27
|
-
* file path relative to the workspace root.
|
|
28
|
-
*
|
|
29
|
-
* @param tree - The virtual file system tree used by Angular schematics.
|
|
30
|
-
* @param mainFilePath - The path to the main entry file of the Angular application (typically `main.ts`).
|
|
31
|
-
* @returns A normalized workspace-relative path to the AppRoutingModule file if found, or `null` otherwise.
|
|
32
|
-
* @throws If the route file path is resolved but the file does not exist in the tree.
|
|
33
|
-
*/
|
|
34
|
-
export declare function findAppRoutesModulePath(tree: Tree, mainFilePath: string): Promise<Path | null>;
|
|
35
|
-
/**
|
|
36
|
-
* Cleans up empty or invalid expressions (e.g., extra commas) from the `imports` and `providers`
|
|
37
|
-
* arrays in the NgModule decorator of an Angular module file.
|
|
38
|
-
*
|
|
39
|
-
* This function parses the source file's AST, locates the `NgModule` decorator, and processes
|
|
40
|
-
* the `imports` and `providers` metadata fields. If these fields contain array literals with
|
|
41
|
-
* empty slots (such as trailing or double commas), they are removed and the array is rewritten.
|
|
42
|
-
*
|
|
43
|
-
* @param source - The TypeScript source file containing the Angular module.
|
|
44
|
-
* @param recorder - The recorder used to apply changes to the source file.
|
|
45
|
-
*/
|
|
46
|
-
export declare function cleanEmptyExprFromModule(source: ts.SourceFile, recorder: UpdateRecorder): void;
|
|
1
|
+
import { Tree, UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { Path } from '@angular-devkit/core';
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether a specific import or provider exists in the specified metadata
|
|
6
|
+
* array (`imports`, `providers`, etc.) of the `NgModule` decorator in the AppModule.
|
|
7
|
+
*
|
|
8
|
+
* This function locates the AppModule file of the given Angular project,
|
|
9
|
+
* parses its AST, and inspects the specified metadata array to determine
|
|
10
|
+
* if it includes an element matching the provided string (e.g., `CommonModule`, `HttpClientModule`).
|
|
11
|
+
*
|
|
12
|
+
* @param host - The virtual file system tree used by Angular schematics.
|
|
13
|
+
* @param projectName - The name of the Angular project.
|
|
14
|
+
* @param metadataFn - The name (string) to match against the elements of the metadata array.
|
|
15
|
+
* @param metadataName - The metadata field to search in (e.g., 'imports', 'providers'). Defaults to 'imports'.
|
|
16
|
+
* @returns A promise that resolves to `true` if the metadata function is found, or `false` otherwise.
|
|
17
|
+
* @throws SchematicsException if the AppModule file or expected metadata is not found or malformed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const hasImportInNgModule: (host: Tree, projectName: string, metadataFn: string, metadataName?: string) => Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Attempts to locate the path of the `AppRoutingModule` file that is imported
|
|
22
|
+
* within the root AppModule file of an Angular application.
|
|
23
|
+
*
|
|
24
|
+
* This function reads the AppModule file (resolved from the main file path),
|
|
25
|
+
* parses its AST, and searches for an import declaration that imports
|
|
26
|
+
* `AppRoutingModule`. Once found, it resolves the import path to a normalized
|
|
27
|
+
* file path relative to the workspace root.
|
|
28
|
+
*
|
|
29
|
+
* @param tree - The virtual file system tree used by Angular schematics.
|
|
30
|
+
* @param mainFilePath - The path to the main entry file of the Angular application (typically `main.ts`).
|
|
31
|
+
* @returns A normalized workspace-relative path to the AppRoutingModule file if found, or `null` otherwise.
|
|
32
|
+
* @throws If the route file path is resolved but the file does not exist in the tree.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findAppRoutesModulePath(tree: Tree, mainFilePath: string): Promise<Path | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Cleans up empty or invalid expressions (e.g., extra commas) from the `imports` and `providers`
|
|
37
|
+
* arrays in the NgModule decorator of an Angular module file.
|
|
38
|
+
*
|
|
39
|
+
* This function parses the source file's AST, locates the `NgModule` decorator, and processes
|
|
40
|
+
* the `imports` and `providers` metadata fields. If these fields contain array literals with
|
|
41
|
+
* empty slots (such as trailing or double commas), they are removed and the array is rewritten.
|
|
42
|
+
*
|
|
43
|
+
* @param source - The TypeScript source file containing the Angular module.
|
|
44
|
+
* @param recorder - The recorder used to apply changes to the source file.
|
|
45
|
+
*/
|
|
46
|
+
export declare function cleanEmptyExprFromModule(source: ts.SourceFile, recorder: UpdateRecorder): void;
|