Skip to content

Commit

Permalink
Merge pull request #27176 from mshima/jdl-types
Browse files Browse the repository at this point in the history
make jdl types decoupled
  • Loading branch information
DanielFran authored Sep 4, 2024
2 parents 691ee92 + 905f89b commit 2fae076
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
5 changes: 1 addition & 4 deletions jdl/built-in-options/jdl-application-definition.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { jhipsterOptionTypes, jhipsterOptionValues, jhipsterQuotedOptionNames } from '../jhipster/index.js';

export type JDLApplicationOptionValue = string | number | boolean | undefined | never[] | Record<string, string>;
export type JDLApplicationOptionTypeValue = 'string' | 'integer' | 'boolean' | 'list' | 'quotedList';
export type JDLApplicationOptionType = { type: JDLApplicationOptionTypeValue };
import { JDLApplicationOptionType, JDLApplicationOptionTypeValue, JDLApplicationOptionValue } from '../types/types.js';

export default class JDLApplicationDefinition {
optionValues: Record<string, JDLApplicationOptionValue> = jhipsterOptionValues;
Expand Down
6 changes: 1 addition & 5 deletions jdl/jhipster/application-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
*/

import jhipsterDefinition from '../../generators/app/jdl/application-options.js';
import {
JDLApplicationOptionType,
JDLApplicationOptionTypeValue,
JDLApplicationOptionValue,
} from '../built-in-options/jdl-application-definition.js';
import type { JDLApplicationOptionType, JDLApplicationOptionTypeValue, JDLApplicationOptionValue } from '../types/types.js';
import applicationTypes from './application-types.js';
import authenticationTypes from './authentication-types.js';
import databaseTypes from './database-types.js';
Expand Down
3 changes: 2 additions & 1 deletion jdl/models/jdl-application-configuration-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import logger from '../utils/objects/logger.js';
import JDLApplicationDefinition, { JDLApplicationOptionTypeValue } from '../built-in-options/jdl-application-definition.js';
import JDLApplicationDefinition from '../built-in-options/jdl-application-definition.js';
import type { JDLApplicationOptionTypeValue } from '../types/types.js';
import JDLApplicationConfiguration from './jdl-application-configuration.js';
import StringJDLApplicationConfigurationOption from './string-jdl-application-configuration-option.js';
import IntegerJDLApplicationConfigurationOption from './integer-jdl-application-configuration-option.js';
Expand Down
9 changes: 1 addition & 8 deletions jdl/parsing/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { first, flatten, includes, values } from 'lodash-es';
import { tokenMatcher as matchesToken } from 'chevrotain';

import jhipsterDefinition from '../../generators/app/jdl/index.js';
import { JDLValidatorOption } from '../types/types.js';
import JDLParser from './jdl-parser.js';
import { tokens as LexerTokens } from './lexer/lexer.js';
import { checkConfigKeys } from './self-checks/parsing-system-checker.js';
Expand Down Expand Up @@ -52,14 +53,6 @@ const REMEMBER_ME_KEY_PATTERN = /^\S+$/;
const NUMERIC = /^\d$/;
const BASIC_NPM_PACKAGE_NAME_PATTERN = /^(@[a-z0-9-][a-z0-9-._]*\/)?[a-z0-9-][a-z0-9-._]*$/;

export type JDLValidatorOptionType = 'BOOLEAN' | 'INTEGER' | 'list' | 'NAME' | 'qualifiedName' | 'STRING' | 'quotedList';

export type JDLValidatorOption = {
type: JDLValidatorOptionType;
pattern?: RegExp;
msg?: string;
};

const configPropsValidations: Record<string, JDLValidatorOption> = {
APPLICATION_TYPE: {
type: 'NAME',
Expand Down
20 changes: 12 additions & 8 deletions jdl/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@
* limitations under the License.
*/
import { ITokenConfig } from 'chevrotain';
import {
JDLApplicationOptionType,
JDLApplicationOptionTypeValue,
JDLApplicationOptionValue,
} from '../built-in-options/jdl-application-definition.ts';
import { JDLValidatorOption, JDLValidatorOptionType } from '../parsing/validator.ts';

export type JDLTokenConfig = Pick<ITokenConfig, 'name' | 'pattern'>;

export type JDLValidatorOptionType = 'BOOLEAN' | 'INTEGER' | 'list' | 'NAME' | 'qualifiedName' | 'STRING' | 'quotedList';

export type JDLValidatorOption = {
type: JDLValidatorOptionType;
pattern?: RegExp;
msg?: string;
};

export type JDLApplicationOptionValue = string | number | boolean | undefined | never[] | Record<string, string>;
export type JDLApplicationOptionTypeValue = 'string' | 'integer' | 'boolean' | 'list' | 'quotedList';
export type JDLApplicationOptionType = { type: JDLApplicationOptionTypeValue };

export type JDLApplicationConfig = {
tokenConfigs: JDLTokenConfig[];
validatorConfig: Record<string, JDLValidatorOption>;
Expand All @@ -40,5 +46,3 @@ export type JHipsterOptionDefinition = {
tokenValuePattern?: RegExp;
knownChoices?: string[];
};

export { JDLValidatorOption };

0 comments on commit 2fae076

Please sign in to comment.