generator-jhipster 8.0.0-rc.1 → 8.0.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/README.md +10 -1
- package/dist/cli/environment-builder.mjs +3 -3
- package/dist/cli/jhipster-command.mjs +7 -3
- package/dist/cli/program.mjs +1 -1
- package/dist/generators/angular/generator.mjs +8 -7
- package/dist/generators/angular/resources/package.json +10 -9
- package/dist/generators/angular/templates/package.json.ejs +4 -8
- package/dist/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.html.ejs +6 -10
- package/dist/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/service/_entityFile_.service.ts.ejs +1 -1
- package/dist/generators/angular/templates/src/main/webapp/app/layouts/navbar/navbar.component.scss.ejs +1 -1
- package/dist/generators/angular/templates/webpack/webpack.microfrontend.js.ejs +48 -126
- package/dist/generators/app/support/config.mjs +3 -3
- package/dist/generators/base/generator.mjs +0 -3
- package/dist/generators/base/support/config.mjs +6 -6
- package/dist/generators/base/support/jhipster7-context.mjs +3 -3
- package/dist/generators/base-application/generator.mjs +2 -2
- package/dist/generators/base-application/support/enum.mjs +1 -1
- package/dist/generators/base-application/support/prepare-entity.mjs +14 -10
- package/dist/generators/base-application/support/prepare-field.mjs +11 -7
- package/dist/generators/base-application/support/prepare-relationship.mjs +12 -14
- package/dist/generators/base-workspaces/internal/docker-prompts.mjs +13 -12
- package/dist/generators/bootstrap/generator.mjs +64 -43
- package/dist/generators/bootstrap/support/auto-crlf-transform.mjs +34 -21
- package/dist/generators/bootstrap/support/eslint-transform.mjs +2 -5
- package/dist/generators/bootstrap/support/java-unused-imports-transform.mjs +2 -2
- package/dist/generators/bootstrap/support/multi-step-transform/index.mjs +17 -28
- package/dist/generators/bootstrap/support/multi-step-transform/template-file-fs.mjs +12 -6
- package/dist/generators/bootstrap/support/multi-step-transform/template-file.mjs +1 -0
- package/dist/generators/bootstrap/support/prettier-support.mjs +2 -2
- package/dist/generators/bootstrap-application/generator.mjs +10 -3
- package/dist/generators/bootstrap-application-base/generator.mjs +9 -6
- package/dist/generators/bootstrap-application-server/generator.mjs +2 -2
- package/dist/generators/client/resources/package.json +3 -3
- package/dist/generators/client/templates/src/main/webapp/content/css/loading.css.ejs +1 -1
- package/dist/generators/client/templates/webpack/webpack.microfrontend.js.jhi.ejs +14 -1
- package/dist/generators/common/files.mjs +1 -1
- package/dist/generators/common/generator.mjs +29 -7
- package/dist/generators/common/resources/package.json +3 -3
- package/dist/generators/common/templates/.lintstagedrc.cjs.ejs +21 -0
- package/dist/generators/common/templates/.prettierrc.ejs +1 -1
- package/dist/generators/common/templates/README.md.jhi.ejs +2 -0
- package/dist/generators/cypress/templates/src/test/javascript/cypress/e2e/account/settings-page.cy.ts.ejs +3 -0
- package/dist/generators/entity/prompts.mjs +123 -306
- package/dist/generators/generator-constants.mjs +5 -5
- package/dist/generators/heroku/generator.mjs +318 -595
- package/dist/generators/heroku/templates/Procfile.ejs +1 -1
- package/dist/generators/heroku/templates/application-heroku.yml.ejs +0 -12
- package/dist/generators/info/generator.mjs +6 -4
- package/dist/generators/init/generator.mjs +2 -2
- package/dist/generators/java/entity-files.mjs +1 -1
- package/dist/generators/java/generator.mjs +12 -13
- package/dist/generators/java/support/package-info-transform.mjs +20 -6
- package/dist/generators/java/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.ejs +24 -28
- package/dist/generators/java/templates/src/main/java/_package_/_entityPackage_/domain/enumeration/_enumName_.java.ejs +3 -3
- package/dist/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_Test.java.ejs +86 -8
- package/dist/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_TestSamples.java.ejs +85 -0
- package/dist/generators/jdl/generator.mjs +14 -5
- package/dist/generators/kubernetes/templates/ingress.yml.ejs +0 -1
- package/dist/generators/languages/command.mjs +5 -0
- package/dist/generators/languages/generator.mjs +20 -13
- package/dist/generators/languages/translation-data.mjs +8 -13
- package/dist/generators/liquibase/generator.mjs +7 -3
- package/dist/generators/project-name/generator.mjs +1 -1
- package/dist/generators/react/generator.mjs +18 -10
- package/dist/generators/react/resources/package.json +19 -18
- package/dist/generators/react/templates/package.json.ejs +4 -5
- package/dist/generators/react/templates/src/main/webapp/app/config/icon-loader.ts.ejs +35 -33
- package/dist/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.tsx.ejs +7 -2
- package/dist/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_.reducer.ts.ejs +1 -1
- package/dist/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_.tsx.ejs +1 -1
- package/dist/generators/react/templates/src/main/webapp/app/modules/home/home.tsx.ejs +1 -1
- package/dist/generators/react/templates/src/main/webapp/app/routes.tsx.ejs +9 -2
- package/dist/generators/react/templates/src/main/webapp/app/shared/layout/header/header-components.tsx.ejs +1 -1
- package/dist/generators/react/templates/src/main/webapp/app/shared/layout/header/header.scss.ejs +5 -4
- package/dist/generators/react/templates/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs +10 -1
- package/dist/generators/react/templates/tsconfig.test.json.ejs +1 -1
- package/dist/generators/react/templates/webpack/webpack.microfrontend.js.jhi.react.ejs +13 -58
- package/dist/generators/server/generator.mjs +13 -4
- package/dist/generators/server/resources/Dockerfile +7 -7
- package/dist/generators/server/resources/gradle/libs.versions.toml +1 -1
- package/dist/generators/server/resources/pom.xml +11 -11
- package/dist/generators/server/support/config.mjs +4 -4
- package/dist/generators/server/support/prepare-entity.mjs +5 -5
- package/dist/generators/server/support/prepare-field.mjs +20 -0
- package/dist/generators/server/support/relationship.mjs +2 -1
- package/dist/generators/server/support/templates/field-values.mjs +5 -2
- package/dist/generators/server/templates/README.md.jhi.spring-boot.ejs +0 -1
- package/dist/generators/server/templates/package.json.ejs +0 -5
- package/dist/generators/server/templates/pom.xml.ejs +1 -8
- package/dist/generators/server/templates/src/main/java/_package_/_entityPackage_/_partials_entity_/get_all_template.ejs +3 -3
- package/dist/generators/server/templates/src/main/java/_package_/_entityPackage_/service/dto/_dtoClass_.java.ejs +2 -2
- package/dist/generators/server/templates/src/main/java/_package_/_entityPackage_/web/rest/_entityClass_Resource.java.ejs +11 -11
- package/dist/generators/server/templates/src/main/java/_package_/config/JacksonConfiguration.java.ejs +2 -1
- package/dist/generators/server/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs +1 -1
- package/dist/generators/server/templates/src/main/java/_package_/config/SecurityConfiguration_reactive.java.ejs +2 -0
- package/dist/generators/server/templates/src/main/java/_package_/service/MailService.java.ejs +10 -4
- package/dist/generators/server/templates/src/main/java/_package_/web/rest/PublicUserResource.java.ejs +3 -4
- package/dist/generators/server/templates/src/main/java/_package_/web/rest/UserResource.java.ejs +0 -2
- package/dist/generators/server/templates/src/main/java/_package_/web/rest/errors/ExceptionTranslator.java.ejs +4 -7
- package/dist/generators/server/templates/src/test/java/_package_/_entityPackage_/web/rest/_entityClass_ResourceIT.java.ejs +3 -3
- package/dist/generators/server/templates/src/test/java/_package_/web/rest/AccountResourceIT.java.ejs +4 -4
- package/dist/generators/spring-data-elasticsearch/templates/src/main/java/_package_/_entityPackage_/repository/search/_entityClass_SearchRepository.java.ejs +0 -2
- package/dist/generators/spring-data-neo4j/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.spring_data_neo4j.ejs +3 -37
- package/dist/generators/vue/generator.mjs +25 -16
- package/dist/generators/vue/resources/package.json +17 -16
- package/dist/generators/vue/templates/package.json.ejs +3 -5
- package/dist/generators/vue/templates/src/main/webapp/app/core/jhi-navbar/jhi-navbar.component.ts.ejs +10 -3
- package/dist/generators/vue/templates/src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue.ejs +3 -4
- package/dist/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_.service.ts.ejs +1 -1
- package/dist/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_.vue.ejs +12 -0
- package/dist/generators/vue/templates/src/main/webapp/app/router/index.ts.ejs +8 -1
- package/dist/generators/vue/templates/webpack/webpack.microfrontend.js.jhi.vue.ejs +19 -34
- package/dist/jdl/converters/jdl-to-json/jdl-to-json-option-converter.js +2 -2
- package/dist/jdl/converters/jdl-to-json/jdl-to-json-relationship-converter.js +1 -1
- package/dist/jdl/converters/jdl-to-json/jdl-without-application-to-json-converter.js +1 -1
- package/dist/jdl/converters/parsed-jdl-to-jdl-object/application-converter.js +1 -17
- package/dist/jdl/exporters/applications/jhipster-application-formatter.js +17 -1
- package/dist/jdl/exporters/config.js +11 -0
- package/dist/jdl/exporters/export-utils.js +2 -13
- package/dist/jdl/index.js +1 -0
- package/dist/jdl/jdl-importer.js +6 -2
- package/dist/jdl/models/jdl-application-configuration-factory.js +34 -2
- package/dist/jdl/models/jdl-application-configuration.js +6 -3
- package/dist/jdl/models/jdl-application-factory.js +2 -2
- package/dist/jdl/models/jdl-application.js +12 -3
- package/dist/jdl/parsing/jdl-ast-builder-visitor.js +63 -7
- package/dist/jdl/parsing/jdl-parser.js +52 -6
- package/dist/jdl/parsing/lexer/application-tokens.js +1 -1
- package/dist/jdl/validators/entity-validator.js +4 -2
- package/dist/jdl/validators/enum-validator.js +4 -2
- package/dist/jdl/validators/jdl-with-application-validator.js +18 -8
- package/dist/jdl/validators/jdl-without-application-validator.js +30 -29
- package/dist/jdl/validators/validator.js +1 -1
- package/dist/types/generators/base/support/config.d.mts +3 -3
- package/dist/types/generators/base-application/support/prepare-entity.d.mts +6 -1
- package/dist/types/generators/bootstrap/support/auto-crlf-transform.d.mts +3 -2
- package/dist/types/generators/bootstrap/support/multi-step-transform/index.d.mts +3 -20
- package/dist/types/generators/bootstrap/support/multi-step-transform/template-file-fs.d.mts +15 -9
- package/dist/types/generators/bootstrap/support/multi-step-transform/template-file.d.mts +1 -0
- package/dist/types/generators/generator-constants.d.mts +3 -3
- package/dist/types/generators/java/support/package-info-transform.d.mts +1 -4
- package/dist/types/generators/server/support/templates/field-values.d.mts +1 -1
- package/dist/types/jdl/exporters/config.d.ts +1 -0
- package/dist/types/jdl/index.d.ts +1 -0
- package/dist/types/jdl/jdl-importer.d.ts +1 -0
- package/dist/types/jdl/models/jdl-application-configuration-factory.d.ts +1 -0
- package/dist/types/jdl/models/jdl-application-configuration-option.d.ts +2 -2
- package/dist/types/jdl/models/jdl-application-configuration.d.ts +8 -6
- package/dist/types/jdl/models/jdl-application-factory.d.ts +1 -1
- package/dist/types/jdl/models/jdl-application.d.ts +8 -4
- package/dist/types/jdl/models/jdl-object.d.ts +1 -1
- package/dist/types/jdl/models/list-jdl-application-configuration-option.d.ts +1 -1
- package/dist/types/jdl/parsing/jdl-ast-builder-visitor.d.ts +10 -0
- package/dist/types/jdl/parsing/jdl-parser.d.ts +3 -0
- package/dist/types/jdl/parsing/lexer/application-tokens.d.ts +1 -0
- package/dist/types/jdl/validators/entity-validator.d.ts +2 -2
- package/dist/types/jdl/validators/enum-validator.d.ts +2 -2
- package/dist/types/jdl/validators/validator.d.ts +4 -1
- package/package.json +31 -31
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GENERATOR_NAME } from './export-utils.js';
|
|
2
|
+
export const mergeYoRcContent = (oldConfig, newConfig) => {
|
|
3
|
+
const merged = { [GENERATOR_NAME]: {} };
|
|
4
|
+
for (const ns of new Set([...Object.keys(oldConfig), ...Object.keys(newConfig)])) {
|
|
5
|
+
merged[ns] = { ...oldConfig[ns], ...newConfig[ns] };
|
|
6
|
+
}
|
|
7
|
+
if (oldConfig[GENERATOR_NAME]?.creationTimestamp) {
|
|
8
|
+
merged[GENERATOR_NAME].creationTimestamp = oldConfig[GENERATOR_NAME].creationTimestamp;
|
|
9
|
+
}
|
|
10
|
+
return merged;
|
|
11
|
+
};
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import fs from 'fs';
|
|
20
20
|
import { doesFileExist } from '../utils/file-utils.js';
|
|
21
|
+
import { mergeYoRcContent } from './config.js';
|
|
21
22
|
export const GENERATOR_NAME = 'generator-jhipster';
|
|
22
23
|
/**
|
|
23
24
|
* This function writes a Yeoman config file in the current folder.
|
|
@@ -28,19 +29,7 @@ export function writeConfigFile(config, yoRcPath = '.yo-rc.json') {
|
|
|
28
29
|
let newYoRc = { ...config };
|
|
29
30
|
if (doesFileExist(yoRcPath)) {
|
|
30
31
|
const yoRc = JSON.parse(fs.readFileSync(yoRcPath, { encoding: 'utf-8' }));
|
|
31
|
-
|
|
32
|
-
if (yoRc[GENERATOR_NAME] && yoRc[GENERATOR_NAME].creationTimestamp) {
|
|
33
|
-
creationTimestamp = yoRc[GENERATOR_NAME].creationTimestamp;
|
|
34
|
-
}
|
|
35
|
-
newYoRc = {
|
|
36
|
-
...yoRc,
|
|
37
|
-
...config,
|
|
38
|
-
[GENERATOR_NAME]: {
|
|
39
|
-
...yoRc[GENERATOR_NAME],
|
|
40
|
-
...config[GENERATOR_NAME],
|
|
41
|
-
creationTimestamp,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
32
|
+
newYoRc = mergeYoRcContent(yoRc, config);
|
|
44
33
|
}
|
|
45
34
|
fs.writeFileSync(yoRcPath, JSON.stringify(newYoRc, null, 2).concat('\n'));
|
|
46
35
|
}
|
package/dist/jdl/index.js
CHANGED
package/dist/jdl/jdl-importer.js
CHANGED
|
@@ -204,8 +204,10 @@ function importOneApplicationAndEntities(jdlObject, configuration) {
|
|
|
204
204
|
jdlObject,
|
|
205
205
|
});
|
|
206
206
|
const jsonEntities = entitiesPerApplicationMap.get(applicationName);
|
|
207
|
+
const { 'generator-jhipster': config, ...remaining } = formattedApplication;
|
|
207
208
|
importState.exportedApplicationsWithEntities[applicationName] = {
|
|
208
|
-
config
|
|
209
|
+
config,
|
|
210
|
+
...remaining,
|
|
209
211
|
entities: [],
|
|
210
212
|
};
|
|
211
213
|
if (jsonEntities.length !== 0) {
|
|
@@ -239,8 +241,10 @@ function importApplicationsAndEntities(jdlObject, configuration) {
|
|
|
239
241
|
forSeveralApplications: true,
|
|
240
242
|
});
|
|
241
243
|
const exportedConfig = importState.exportedApplications.find(config => applicationName === config['generator-jhipster'].baseName);
|
|
244
|
+
const { 'generator-jhipster': config, ...remaining } = exportedConfig;
|
|
242
245
|
importState.exportedApplicationsWithEntities[applicationName] = {
|
|
243
|
-
config
|
|
246
|
+
config,
|
|
247
|
+
...remaining,
|
|
244
248
|
entities: exportedJSONEntities,
|
|
245
249
|
};
|
|
246
250
|
importState.exportedEntities = uniqBy([...importState.exportedEntities, ...exportedJSONEntities], 'name');
|
|
@@ -32,12 +32,44 @@ export default function createApplicationConfigurationFromObject(configurationOb
|
|
|
32
32
|
logger.debug(`Unrecognized application option name and value: '${optionName}' and '${optionValue}'.`);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
configuration.setOption(
|
|
35
|
+
configuration.setOption(createApplicationJDLConfigurationOption(optionName, optionValue));
|
|
36
36
|
});
|
|
37
37
|
return configuration;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
export function createApplicationNamespaceConfigurationFromObject(parsedNamespaceConfigs = {}) {
|
|
40
|
+
return Object.entries(parsedNamespaceConfigs).map(([namespace, parsedConfig]) => {
|
|
41
|
+
const configuration = new JDLApplicationConfiguration(namespace);
|
|
42
|
+
for (const [optionName, optionValue] of Object.entries(parsedConfig)) {
|
|
43
|
+
configuration.setOption(createUnknownJDLConfigurationOption(optionName, optionValue));
|
|
44
|
+
}
|
|
45
|
+
return configuration;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function createUnknownJDLConfigurationOption(name, value) {
|
|
49
|
+
let type;
|
|
50
|
+
if (typeof value === 'boolean') {
|
|
51
|
+
type = 'boolean';
|
|
52
|
+
}
|
|
53
|
+
else if (/^\d+$/.test(value)) {
|
|
54
|
+
value = parseInt(value, 10);
|
|
55
|
+
type = 'integer';
|
|
56
|
+
}
|
|
57
|
+
else if (Array.isArray(value)) {
|
|
58
|
+
type = 'list';
|
|
59
|
+
}
|
|
60
|
+
else if (typeof value === 'string') {
|
|
61
|
+
type = 'string';
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new Error(`Unknown value type for option ${name}`);
|
|
65
|
+
}
|
|
66
|
+
return createJDLConfigurationOption(type, name, value);
|
|
67
|
+
}
|
|
68
|
+
function createApplicationJDLConfigurationOption(name, value) {
|
|
40
69
|
const type = applicationDefinition.getTypeForOption(name);
|
|
70
|
+
return createJDLConfigurationOption(type, name, value);
|
|
71
|
+
}
|
|
72
|
+
function createJDLConfigurationOption(type, name, value) {
|
|
41
73
|
switch (type) {
|
|
42
74
|
case 'string':
|
|
43
75
|
return new StringJDLApplicationConfigurationOption(name, value, applicationDefinition.shouldTheValueBeQuoted(name));
|
|
@@ -20,8 +20,10 @@ import ApplicationOptions from '../jhipster/application-options.js';
|
|
|
20
20
|
const { OptionNames } = ApplicationOptions;
|
|
21
21
|
export default class JDLApplicationConfiguration {
|
|
22
22
|
options;
|
|
23
|
-
|
|
23
|
+
namespace;
|
|
24
|
+
constructor(namespace) {
|
|
24
25
|
this.options = {};
|
|
26
|
+
this.namespace = namespace;
|
|
25
27
|
}
|
|
26
28
|
hasOption(optionName) {
|
|
27
29
|
if (!optionName) {
|
|
@@ -54,12 +56,13 @@ export default class JDLApplicationConfiguration {
|
|
|
54
56
|
}
|
|
55
57
|
toString(indent = 0) {
|
|
56
58
|
const spaceBeforeConfigKeyword = ' '.repeat(indent);
|
|
59
|
+
const namespace = this.namespace ? `:${this.namespace}` : '';
|
|
57
60
|
if (Object.keys(this.options).length === 0) {
|
|
58
|
-
return `${spaceBeforeConfigKeyword}config {}`;
|
|
61
|
+
return `${spaceBeforeConfigKeyword}config${namespace} {}`;
|
|
59
62
|
}
|
|
60
63
|
const spaceBeforeOption = ' '.repeat(2 * indent);
|
|
61
64
|
const config = getFormattedConfigOptionsString(this.options, spaceBeforeOption);
|
|
62
|
-
return `${spaceBeforeConfigKeyword}config {
|
|
65
|
+
return `${spaceBeforeConfigKeyword}config${namespace} {
|
|
63
66
|
${config}
|
|
64
67
|
${spaceBeforeConfigKeyword}}`;
|
|
65
68
|
}
|
|
@@ -22,6 +22,6 @@ import JDLApplication from './jdl-application.js';
|
|
|
22
22
|
* @param {Object} config - the application configuration.
|
|
23
23
|
* @returns {JDLApplication} the created JDL application.
|
|
24
24
|
*/
|
|
25
|
-
export default function createJDLApplication(config
|
|
26
|
-
return new JDLApplication({ config: { baseName: 'jhipster', ...config } });
|
|
25
|
+
export default function createJDLApplication(config, namespaceConfigs) {
|
|
26
|
+
return new JDLApplication({ config: { baseName: 'jhipster', ...config }, namespaceConfigs });
|
|
27
27
|
}
|
|
@@ -16,15 +16,17 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import createApplicationConfigurationFromObject from './jdl-application-configuration-factory.js';
|
|
19
|
+
import createApplicationConfigurationFromObject, { createApplicationNamespaceConfigurationFromObject, } from './jdl-application-configuration-factory.js';
|
|
20
20
|
import JDLApplicationEntities from './jdl-application-entities.js';
|
|
21
21
|
import JDLOptions from './jdl-options.js';
|
|
22
22
|
export default class JDLApplication {
|
|
23
23
|
config;
|
|
24
|
+
namespaceConfigs;
|
|
24
25
|
entityNames;
|
|
25
26
|
options;
|
|
26
|
-
constructor({ config = {}, entityNames = [] } = {}) {
|
|
27
|
+
constructor({ config = {}, entityNames = [], namespaceConfigs = {} } = {}) {
|
|
27
28
|
this.config = createApplicationConfigurationFromObject(config);
|
|
29
|
+
this.namespaceConfigs = createApplicationNamespaceConfigurationFromObject(namespaceConfigs);
|
|
28
30
|
this.entityNames = new JDLApplicationEntities(entityNames);
|
|
29
31
|
this.options = new JDLOptions();
|
|
30
32
|
}
|
|
@@ -50,6 +52,11 @@ export default class JDLApplication {
|
|
|
50
52
|
forEachConfigurationOption(passedFunction) {
|
|
51
53
|
this.config.forEachOption(passedFunction);
|
|
52
54
|
}
|
|
55
|
+
forEachNamespaceConfiguration(passedFunction) {
|
|
56
|
+
for (const namespaceConfig of this.namespaceConfigs) {
|
|
57
|
+
passedFunction(namespaceConfig);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
53
60
|
addEntityName(entityName) {
|
|
54
61
|
if (!entityName) {
|
|
55
62
|
throw new Error('An entity name has to be passed so as to be added to the application.');
|
|
@@ -87,7 +94,9 @@ export default class JDLApplication {
|
|
|
87
94
|
return this.options.size();
|
|
88
95
|
}
|
|
89
96
|
toString() {
|
|
90
|
-
let stringifiedApplication = `application {
|
|
97
|
+
let stringifiedApplication = `application {
|
|
98
|
+
${this.config.toString(2)}
|
|
99
|
+
${this.namespaceConfigs.map(config => `${config.toString(2)}\n`).join()}`;
|
|
91
100
|
if (this.entityNames.size() !== 0) {
|
|
92
101
|
stringifiedApplication += `\n${this.entityNames.toString(2)}\n`;
|
|
93
102
|
}
|
|
@@ -135,14 +135,29 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor {
|
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
annotationDeclaration(context) {
|
|
138
|
+
const optionName = context.option[0].image;
|
|
138
139
|
if (!context.value) {
|
|
139
|
-
return { optionName
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
return { optionName, type: 'UNARY' };
|
|
141
|
+
}
|
|
142
|
+
let { image: optionValue } = context.value[0];
|
|
143
|
+
const { tokenType } = context.value[0];
|
|
144
|
+
switch (tokenType.name) {
|
|
145
|
+
case 'INTEGER':
|
|
146
|
+
optionValue = parseInt(optionValue, 10);
|
|
147
|
+
break;
|
|
148
|
+
case 'DECIMAL':
|
|
149
|
+
optionValue = parseFloat(optionValue);
|
|
150
|
+
break;
|
|
151
|
+
case 'TRUE':
|
|
152
|
+
optionValue = true;
|
|
153
|
+
break;
|
|
154
|
+
case 'FALSE':
|
|
155
|
+
optionValue = false;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
optionValue = optionValue.replace(/"/g, '');
|
|
159
|
+
}
|
|
160
|
+
return { optionName, optionValue, type: 'BINARY' };
|
|
146
161
|
}
|
|
147
162
|
entityTableNameDeclaration(context) {
|
|
148
163
|
return context.NAME[0].image;
|
|
@@ -380,6 +395,7 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor {
|
|
|
380
395
|
applicationSubDeclaration(context) {
|
|
381
396
|
const applicationSubDeclaration = {
|
|
382
397
|
config: {},
|
|
398
|
+
namespaceConfigs: {},
|
|
383
399
|
entities: { entityList: [], excluded: [] },
|
|
384
400
|
options: {},
|
|
385
401
|
useOptions: [],
|
|
@@ -388,6 +404,10 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor {
|
|
|
388
404
|
// Apparently the pegjs grammar only returned the last config
|
|
389
405
|
applicationSubDeclaration.config = this.visit(context.applicationSubConfig[context.applicationSubConfig.length - 1]);
|
|
390
406
|
}
|
|
407
|
+
if (context.applicationSubNamespaceConfig) {
|
|
408
|
+
const { namespace, config } = this.visit(context.applicationSubNamespaceConfig[context.applicationSubNamespaceConfig.length - 1]);
|
|
409
|
+
applicationSubDeclaration.namespaceConfigs[namespace] = config;
|
|
410
|
+
}
|
|
391
411
|
if (context.applicationSubEntities) {
|
|
392
412
|
// Apparently the pegjs grammar only returned the last entities
|
|
393
413
|
applicationSubDeclaration.entities = this.visit(context.applicationSubEntities[context.applicationSubEntities.length - 1]);
|
|
@@ -429,6 +449,42 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor {
|
|
|
429
449
|
}
|
|
430
450
|
return applicationSubDeclaration;
|
|
431
451
|
}
|
|
452
|
+
applicationSubNamespaceConfig(context) {
|
|
453
|
+
const config = {};
|
|
454
|
+
const namespace = context.namespace[0].image;
|
|
455
|
+
if (context.applicationNamespaceConfigDeclaration) {
|
|
456
|
+
const configProps = context.applicationNamespaceConfigDeclaration.map(this.visit, this);
|
|
457
|
+
configProps.forEach(configProp => {
|
|
458
|
+
config[configProp.key] = configProp.value;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return { namespace, config };
|
|
462
|
+
}
|
|
463
|
+
applicationNamespaceConfigDeclaration(context) {
|
|
464
|
+
const key = context.NAME[0].image;
|
|
465
|
+
const value = this.visit(context.namespaceConfigValue);
|
|
466
|
+
return { key, value };
|
|
467
|
+
}
|
|
468
|
+
namespaceConfigValue(context) {
|
|
469
|
+
if (context.qualifiedName) {
|
|
470
|
+
return this.visit(context.qualifiedName);
|
|
471
|
+
}
|
|
472
|
+
if (context.list) {
|
|
473
|
+
return this.visit(context.list);
|
|
474
|
+
}
|
|
475
|
+
if (context.INTEGER) {
|
|
476
|
+
return context.INTEGER[0].image;
|
|
477
|
+
}
|
|
478
|
+
if (context.STRING) {
|
|
479
|
+
const stringImage = context.STRING[0].image;
|
|
480
|
+
return stringImage.substring(1, stringImage.length - 1);
|
|
481
|
+
}
|
|
482
|
+
if (context.BOOLEAN) {
|
|
483
|
+
return context.BOOLEAN[0].image === 'true';
|
|
484
|
+
}
|
|
485
|
+
/* istanbul ignore next */
|
|
486
|
+
throw new Error('No valid config value was found, expected a qualified name, a list, an integer, a string or a boolean.');
|
|
487
|
+
}
|
|
432
488
|
applicationSubConfig(context) {
|
|
433
489
|
const config = {};
|
|
434
490
|
if (context.applicationConfigDeclaration) {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { CstParser } from 'chevrotain';
|
|
20
20
|
import { tokens as LexerTokens } from './lexer/lexer.js';
|
|
21
|
+
import { NAME } from './lexer/shared-tokens.js';
|
|
21
22
|
let instance;
|
|
22
23
|
export default class JDLParser extends CstParser {
|
|
23
24
|
constructor() {
|
|
@@ -64,9 +65,12 @@ export default class JDLParser extends CstParser {
|
|
|
64
65
|
this.applicationDeclaration();
|
|
65
66
|
this.applicationSubDeclaration();
|
|
66
67
|
this.applicationSubConfig();
|
|
68
|
+
this.applicationSubNamespaceConfig();
|
|
67
69
|
this.applicationSubEntities();
|
|
68
70
|
this.applicationConfigDeclaration();
|
|
69
71
|
this.configValue();
|
|
72
|
+
this.applicationNamespaceConfigDeclaration();
|
|
73
|
+
this.namespaceConfigValue();
|
|
70
74
|
this.qualifiedName();
|
|
71
75
|
this.list();
|
|
72
76
|
// very important to call this after all the rules have been defined.
|
|
@@ -133,12 +137,17 @@ export default class JDLParser extends CstParser {
|
|
|
133
137
|
this.CONSUME(LexerTokens.NAME, { LABEL: 'option' });
|
|
134
138
|
this.OPTION(() => {
|
|
135
139
|
this.CONSUME(LexerTokens.LPAREN);
|
|
136
|
-
this.OR(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
this.OR({
|
|
141
|
+
IGNORE_AMBIGUITIES: true,
|
|
142
|
+
DEF: [
|
|
143
|
+
{ ALT: () => this.CONSUME(LexerTokens.STRING, { LABEL: 'value' }) },
|
|
144
|
+
{ ALT: () => this.CONSUME(LexerTokens.INTEGER, { LABEL: 'value' }) },
|
|
145
|
+
{ ALT: () => this.CONSUME(LexerTokens.DECIMAL, { LABEL: 'value' }) },
|
|
146
|
+
{ ALT: () => this.CONSUME(LexerTokens.TRUE, { LABEL: 'value' }) },
|
|
147
|
+
{ ALT: () => this.CONSUME(LexerTokens.FALSE, { LABEL: 'value' }) },
|
|
148
|
+
{ ALT: () => this.CONSUME2(LexerTokens.NAME, { LABEL: 'value' }) },
|
|
149
|
+
],
|
|
150
|
+
});
|
|
142
151
|
this.CONSUME(LexerTokens.RPAREN);
|
|
143
152
|
});
|
|
144
153
|
});
|
|
@@ -455,6 +464,7 @@ export default class JDLParser extends CstParser {
|
|
|
455
464
|
this.RULE('applicationSubDeclaration', () => {
|
|
456
465
|
this.MANY(() => {
|
|
457
466
|
this.OR([
|
|
467
|
+
{ ALT: () => this.SUBRULE(this.applicationSubNamespaceConfig) },
|
|
458
468
|
{ ALT: () => this.SUBRULE(this.applicationSubConfig) },
|
|
459
469
|
{ ALT: () => this.SUBRULE(this.applicationSubEntities) },
|
|
460
470
|
{ ALT: () => this.SUBRULE(this.unaryOptionDeclaration) },
|
|
@@ -464,6 +474,42 @@ export default class JDLParser extends CstParser {
|
|
|
464
474
|
});
|
|
465
475
|
});
|
|
466
476
|
}
|
|
477
|
+
applicationSubNamespaceConfig() {
|
|
478
|
+
this.RULE('applicationSubNamespaceConfig', () => {
|
|
479
|
+
this.CONSUME(LexerTokens.CONFIG);
|
|
480
|
+
this.CONSUME(LexerTokens.LPAREN);
|
|
481
|
+
this.CONSUME(LexerTokens.NAME, { LABEL: 'namespace' });
|
|
482
|
+
this.CONSUME(LexerTokens.RPAREN);
|
|
483
|
+
this.CONSUME(LexerTokens.LCURLY);
|
|
484
|
+
this.MANY(() => {
|
|
485
|
+
this.OR([
|
|
486
|
+
{ ALT: () => this.CONSUME(LexerTokens.JAVADOC) },
|
|
487
|
+
{ ALT: () => this.SUBRULE(this.applicationNamespaceConfigDeclaration) },
|
|
488
|
+
]);
|
|
489
|
+
});
|
|
490
|
+
this.CONSUME(LexerTokens.RCURLY);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
applicationNamespaceConfigDeclaration() {
|
|
494
|
+
this.RULE('applicationNamespaceConfigDeclaration', () => {
|
|
495
|
+
this.CONSUME(NAME);
|
|
496
|
+
this.SUBRULE(this.namespaceConfigValue);
|
|
497
|
+
this.OPTION(() => {
|
|
498
|
+
this.CONSUME(LexerTokens.COMMA);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
namespaceConfigValue() {
|
|
503
|
+
this.RULE('namespaceConfigValue', () => {
|
|
504
|
+
this.OR([
|
|
505
|
+
{ ALT: () => this.CONSUME(LexerTokens.BOOLEAN) },
|
|
506
|
+
{ ALT: () => this.SUBRULE(this.qualifiedName) },
|
|
507
|
+
{ ALT: () => this.SUBRULE(this.list) },
|
|
508
|
+
{ ALT: () => this.CONSUME(LexerTokens.INTEGER) },
|
|
509
|
+
{ ALT: () => this.CONSUME(LexerTokens.STRING) },
|
|
510
|
+
]);
|
|
511
|
+
});
|
|
512
|
+
}
|
|
467
513
|
applicationSubConfig() {
|
|
468
514
|
this.RULE('applicationSubConfig', () => {
|
|
469
515
|
this.CONSUME(LexerTokens.CONFIG);
|
|
@@ -23,7 +23,7 @@ import { applicationOptions } from '../../jhipster/index.mjs';
|
|
|
23
23
|
import jhipsterDefinition from '../../../generators/app/jdl/index.mjs';
|
|
24
24
|
const { OptionNames } = applicationOptions;
|
|
25
25
|
const { APPLICATION_TYPE, AUTHENTICATION_TYPE, BASE_NAME, BLUEPRINT, BLUEPRINTS, BUILD_TOOL, CACHE_PROVIDER, CLIENT_FRAMEWORK, CLIENT_PACKAGE_MANAGER, CLIENT_THEME, CLIENT_THEME_VARIANT, CREATION_TIMESTAMP, DATABASE_TYPE, DEV_DATABASE_TYPE, DTO_SUFFIX, EMBEDDABLE_LAUNCH_SCRIPT, ENABLE_HIBERNATE_CACHE, ENABLE_SWAGGER_CODEGEN, ENABLE_TRANSLATION, ENTITY_SUFFIX, GATEWAY_SERVER_PORT, JHIPSTER_VERSION, JHI_PREFIX, JWT_SECRET_KEY, LANGUAGES, MICROFRONTEND, MICROFRONTENDS, NATIVE_LANGUAGE, PACKAGE_NAME, PROD_DATABASE_TYPE, REACTIVE, REMEMBER_ME_KEY, SEARCH_ENGINE, SERVER_PORT, SKIP_CLIENT, SKIP_SERVER, SKIP_USER_MANAGEMENT, TEST_FRAMEWORKS, WEBSOCKET, WITH_ADMIN_UI, ENABLE_GRADLE_ENTERPRISE, GRADLE_ENTERPRISE_HOST, } = OptionNames;
|
|
26
|
-
const applicationConfigCategoryToken = createTokenFromConfig({ name: 'CONFIG_KEY', pattern: Lexer.NA });
|
|
26
|
+
export const applicationConfigCategoryToken = createTokenFromConfig({ name: 'CONFIG_KEY', pattern: Lexer.NA });
|
|
27
27
|
const applicationConfigTokens = [
|
|
28
28
|
{ name: 'BASE_NAME', pattern: BASE_NAME },
|
|
29
29
|
{ name: 'BLUEPRINTS', pattern: BLUEPRINTS },
|
|
@@ -23,9 +23,11 @@ export default class EntityValidator extends Validator {
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super('entity', ['name', 'tableName']);
|
|
25
25
|
}
|
|
26
|
-
validate(jdlEntity) {
|
|
26
|
+
validate(jdlEntity, options = {}) {
|
|
27
27
|
super.validate(jdlEntity);
|
|
28
|
-
|
|
28
|
+
if (options.checkReservedKeywords) {
|
|
29
|
+
checkForReservedClassName(jdlEntity);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
function checkForReservedClassName(jdlEntity) {
|
|
@@ -23,9 +23,11 @@ export default class EnumValidator extends Validator {
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super('enum', ['name']);
|
|
25
25
|
}
|
|
26
|
-
validate(jdlEnum) {
|
|
26
|
+
validate(jdlEnum, options = {}) {
|
|
27
27
|
super.validate(jdlEnum);
|
|
28
|
-
|
|
28
|
+
if (options.checkReservedKeywords) {
|
|
29
|
+
checkForReservedClassName(jdlEnum);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
function checkForReservedClassName(jdlEnum) {
|
|
@@ -42,20 +42,30 @@ export default function createValidator(jdlObject, logger = console) {
|
|
|
42
42
|
checkForErrors: () => {
|
|
43
43
|
jdlObject.forEachApplication(jdlApplication => {
|
|
44
44
|
const blueprints = jdlApplication.getConfigurationOptionValue(BLUEPRINTS);
|
|
45
|
-
|
|
45
|
+
const checkReservedKeywords = (blueprints?.length ?? 0) === 0;
|
|
46
|
+
checkForNamespaceConfigErrors(jdlApplication);
|
|
47
|
+
checkForRelationshipErrors();
|
|
48
|
+
checkForEntityErrors(jdlApplication, { checkReservedKeywords });
|
|
49
|
+
checkForEnumErrors({ checkReservedKeywords });
|
|
50
|
+
if (!checkReservedKeywords) {
|
|
46
51
|
logger.warn('Blueprints are being used, the JDL validation phase is skipped.');
|
|
47
52
|
return;
|
|
48
53
|
}
|
|
49
|
-
checkForEntityErrors(jdlApplication);
|
|
50
|
-
checkForRelationshipErrors();
|
|
51
|
-
checkForEnumErrors();
|
|
52
54
|
checkDeploymentsErrors();
|
|
53
55
|
checkForOptionErrors();
|
|
54
56
|
});
|
|
55
57
|
checkForRelationshipsBetweenApplications();
|
|
56
58
|
},
|
|
57
59
|
};
|
|
58
|
-
function
|
|
60
|
+
function checkForNamespaceConfigErrors(jdlApplication) {
|
|
61
|
+
jdlApplication.forEachNamespaceConfiguration(config => {
|
|
62
|
+
const blueprints = jdlApplication.config.getOption('blueprints');
|
|
63
|
+
if (!blueprints || !blueprints.getValue().some(blueprint => blueprint === config.namespace)) {
|
|
64
|
+
throw new Error(`Blueprint namespace config ${config.namespace} requires the blueprint ${config.namespace}`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function checkForEntityErrors(jdlApplication, options) {
|
|
59
69
|
if (jdlObject.getEntityQuantity() === 0) {
|
|
60
70
|
return;
|
|
61
71
|
}
|
|
@@ -64,7 +74,7 @@ export default function createValidator(jdlObject, logger = console) {
|
|
|
64
74
|
if (!jdlApplication.hasEntityName(jdlEntity.name)) {
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
67
|
-
validator.validate(jdlEntity);
|
|
77
|
+
validator.validate(jdlEntity, options);
|
|
68
78
|
checkForFieldErrors(jdlEntity.name, jdlEntity.fields, jdlApplication);
|
|
69
79
|
});
|
|
70
80
|
}
|
|
@@ -100,13 +110,13 @@ export default function createValidator(jdlObject, logger = console) {
|
|
|
100
110
|
});
|
|
101
111
|
});
|
|
102
112
|
}
|
|
103
|
-
function checkForEnumErrors() {
|
|
113
|
+
function checkForEnumErrors(options) {
|
|
104
114
|
if (jdlObject.getEnumQuantity() === 0) {
|
|
105
115
|
return;
|
|
106
116
|
}
|
|
107
117
|
const validator = new EnumValidator();
|
|
108
118
|
jdlObject.forEachEnum(jdlEnum => {
|
|
109
|
-
validator.validate(jdlEnum);
|
|
119
|
+
validator.validate(jdlEnum, options);
|
|
110
120
|
});
|
|
111
121
|
}
|
|
112
122
|
function checkDeploymentsErrors() {
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import EntityValidator from './entity-validator.js';
|
|
20
20
|
import FieldValidator from './field-validator.js';
|
|
21
|
-
import { fieldTypes, applicationTypes, databaseTypes, binaryOptions,
|
|
21
|
+
import { fieldTypes, applicationTypes, databaseTypes, binaryOptions, relationshipOptions } from '../jhipster/index.mjs';
|
|
22
22
|
import ValidationValidator from './validation-validator.js';
|
|
23
23
|
import RelationshipValidator from './relationship-validator.js';
|
|
24
24
|
import EnumValidator from './enum-validator.js';
|
|
25
25
|
import DeploymentValidator from './deployment-validator.js';
|
|
26
26
|
import UnaryOptionValidator from './unary-option-validator.js';
|
|
27
27
|
import BinaryOptionValidator from './binary-option-validator.js';
|
|
28
|
+
import { isReservedFieldName, isReservedPaginationWords, isReservedTableName } from '../jhipster/reserved-keywords.js';
|
|
28
29
|
const { BUILT_IN_ENTITY } = relationshipOptions;
|
|
29
|
-
const { isReservedFieldName, isReservedTableName, isReservedPaginationWords } = reservedKeywords;
|
|
30
30
|
const { SQL } = databaseTypes;
|
|
31
31
|
/**
|
|
32
32
|
* Constructor taking the jdl object to check against application settings.
|
|
@@ -43,49 +43,50 @@ export default function createValidator(jdlObject, applicationSettings = {}, log
|
|
|
43
43
|
if (!jdlObject) {
|
|
44
44
|
throw new Error('A JDL object must be passed to check for business errors.');
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
checkForErrors: () => {
|
|
49
|
-
logger.warn('Blueprints are being used, the JDL validation phase is skipped.');
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
46
|
+
const { blueprints, databaseType } = applicationSettings;
|
|
47
|
+
const checkReservedKeywords = Boolean((databaseType ?? 'no') !== 'no') && (blueprints?.length ?? 0) === 0;
|
|
53
48
|
return {
|
|
54
49
|
checkForErrors: () => {
|
|
55
|
-
checkForEntityErrors();
|
|
50
|
+
checkForEntityErrors({ checkReservedKeywords });
|
|
56
51
|
checkForRelationshipErrors();
|
|
57
|
-
checkForEnumErrors();
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
checkForEnumErrors({ checkReservedKeywords });
|
|
53
|
+
if (checkReservedKeywords) {
|
|
54
|
+
checkDeploymentsErrors();
|
|
55
|
+
checkForOptionErrors();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logger.warn('Blueprints are being used, the JDL validation phase is skipped.');
|
|
59
|
+
}
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
|
-
function checkForEntityErrors() {
|
|
62
|
+
function checkForEntityErrors(options) {
|
|
63
63
|
if (jdlObject.getEntityQuantity() === 0) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
if (!applicationSettings.databaseType) {
|
|
67
|
-
throw new Error('Database type is required to validate entities.');
|
|
68
|
-
}
|
|
69
66
|
const validator = new EntityValidator();
|
|
70
67
|
jdlObject.forEachEntity(jdlEntity => {
|
|
71
|
-
validator.validate(jdlEntity);
|
|
72
|
-
if (
|
|
73
|
-
|
|
68
|
+
validator.validate(jdlEntity, options);
|
|
69
|
+
if (options.checkReservedKeywords) {
|
|
70
|
+
if (isReservedTableName(jdlEntity.tableName, applicationSettings.databaseType)) {
|
|
71
|
+
logger.warn(`The table name '${jdlEntity.tableName}' is a reserved keyword, so it will be prefixed with the value of 'jhiPrefix'.`);
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
|
-
checkForFieldErrors(jdlEntity.name, jdlEntity.fields);
|
|
74
|
+
checkForFieldErrors(jdlEntity.name, jdlEntity.fields, options);
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
|
-
function checkForFieldErrors(entityName, jdlFields) {
|
|
77
|
+
function checkForFieldErrors(entityName, jdlFields, options) {
|
|
79
78
|
const validator = new FieldValidator();
|
|
80
79
|
const filtering = applicationSettings.databaseType === SQL;
|
|
81
80
|
Object.keys(jdlFields).forEach(fieldName => {
|
|
82
81
|
const jdlField = jdlFields[fieldName];
|
|
83
82
|
validator.validate(jdlField);
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
if (options.checkReservedKeywords) {
|
|
84
|
+
if (isReservedFieldName(jdlField.name)) {
|
|
85
|
+
logger.warn(`The name '${jdlField.name}' is a reserved keyword, so it will be prefixed with the value of 'jhiPrefix'.`);
|
|
86
|
+
}
|
|
87
|
+
if (filtering && isReservedPaginationWords(jdlField.name)) {
|
|
88
|
+
throw new Error(`Field name '${fieldName}' found in ${entityName} is a reserved keyword, as it is used by Spring for pagination in the URL.`);
|
|
89
|
+
}
|
|
89
90
|
}
|
|
90
91
|
const typeCheckingFunction = getTypeCheckingFunction(entityName, applicationSettings);
|
|
91
92
|
if (!jdlObject.hasEnum(jdlField.type) && !typeCheckingFunction(jdlField.type)) {
|
|
@@ -117,13 +118,13 @@ export default function createValidator(jdlObject, applicationSettings = {}, log
|
|
|
117
118
|
});
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
|
-
function checkForEnumErrors() {
|
|
121
|
+
function checkForEnumErrors(options) {
|
|
121
122
|
if (jdlObject.getEnumQuantity() === 0) {
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
const validator = new EnumValidator();
|
|
125
126
|
jdlObject.forEachEnum(jdlEnum => {
|
|
126
|
-
validator.validate(jdlEnum);
|
|
127
|
+
validator.validate(jdlEnum, options);
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
130
|
function checkDeploymentsErrors() {
|
|
@@ -38,10 +38,10 @@ export declare const pickFields: (source: Record<string | number, any>, fields:
|
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* // application = { prop: 'foo-bar', prop2: 'foo2' }
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* mutateData(
|
|
42
|
+
* data,
|
|
43
43
|
* { prop: 'foo', prop2: ({ prop }) => prop + 2 },
|
|
44
44
|
* { prop: ({ prop }) => prop + '-bar', prop2: 'won\'t override' },
|
|
45
45
|
* );
|
|
46
46
|
*/
|
|
47
|
-
export declare const
|
|
47
|
+
export declare const mutateData: (context: Record<string | number, any>, ...mutations: Record<string | number, any>[]) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type BaseGenerator from '../../base-core/index.mjs';
|
|
2
2
|
import { Entity } from '../types/index.mjs';
|
|
3
|
+
import type CoreGenerator from '../../base-core/generator.mjs';
|
|
3
4
|
export declare const entityDefaultConfig: {
|
|
4
5
|
pagination: string;
|
|
5
6
|
anyPropertyHasValidation: boolean;
|
|
@@ -16,7 +17,11 @@ export declare const entityDefaultConfig: {
|
|
|
16
17
|
};
|
|
17
18
|
export default function prepareEntity(entityWithConfig: any, generator: any, application: any): any;
|
|
18
19
|
export declare function derivedPrimaryKeyProperties(primaryKey: any): void;
|
|
19
|
-
export declare function prepareEntityPrimaryKeyForTemplates(
|
|
20
|
+
export declare function prepareEntityPrimaryKeyForTemplates(this: CoreGenerator | void, { entity: entityWithConfig, enableCompositeId, application }: {
|
|
21
|
+
entity: any;
|
|
22
|
+
enableCompositeId?: boolean;
|
|
23
|
+
application?: any;
|
|
24
|
+
}): any;
|
|
20
25
|
/**
|
|
21
26
|
* Copy required application config into entity.
|
|
22
27
|
* Some entity features are related to the backend instead of the current app.
|