Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make jdl types decoupled #27176

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };
Loading