diff --git a/.github/workflows/jira_link_to_pr.yml b/.github/workflows/jira_link_to_pr.yml index 53efb67..0a2a10c 100644 --- a/.github/workflows/jira_link_to_pr.yml +++ b/.github/workflows/jira_link_to_pr.yml @@ -5,19 +5,19 @@ # follow the pattern: : name: jira-description-action on: - pull_request: - types: [opened, reopened] + pull_request: + types: [ opened, reopened ] jobs: - add-jira-description: - runs-on: ubuntu-latest - steps: - - uses: cakeinpanic/jira-description-action@v0.9.0 - name: jira-description-action - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - jira-token: ${{ secrets.JIRA_TOKEN }} - jira-base-url: https://hackolade.atlassian.net - skip-branches: '^(develop|main|master)$' #optional - jira-project-key: 'HCK' #optional - use: 'both' - fail-when-jira-issue-not-found: false + add-jira-description: + runs-on: ubuntu-latest + steps: + - uses: cakeinpanic/jira-description-action@v0.9.0 + name: jira-description-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + jira-token: ${{ secrets.JIRA_TOKEN }} + jira-base-url: https://hackolade.atlassian.net + skip-branches: '^(develop|main|master)$' #optional + jira-project-key: 'HCK' #optional + use: 'both' + fail-when-jira-issue-not-found: false diff --git a/.github/workflows/notif-push-to-slack.yml b/.github/workflows/notif-push-to-slack.yml index 61315cd..db6972a 100644 --- a/.github/workflows/notif-push-to-slack.yml +++ b/.github/workflows/notif-push-to-slack.yml @@ -1,34 +1,34 @@ #https://docs.github.com/en/webhooks/webhook-events-and-payloads#push name: notify-push on: - push: - branches: - - develop + push: + branches: + - develop jobs: - notify: - runs-on: ubuntu-latest - env: - AUTHOR: ${{ github.event.pusher.name }} - COMMIT_PUSH_SOURCE: ${{ secrets.COMMIT_PUSH_SOURCE }} - steps: - - name: notify slack - id: slack - if: ${{ env.AUTHOR == env.COMMIT_PUSH_SOURCE }} - uses: slackapi/slack-github-action@v1.26.0 - with: - channel-id: 'develop-direct-pushes' - payload: | - { - "text": " ${{ github.event.head_commit.url }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Push: ${{ github.event.head_commit.url }}" - } - } - ] - } + notify: + runs-on: ubuntu-latest env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} \ No newline at end of file + AUTHOR: ${{ github.event.pusher.name }} + COMMIT_PUSH_SOURCE: ${{ secrets.COMMIT_PUSH_SOURCE }} + steps: + - name: notify slack + id: slack + if: ${{ env.AUTHOR == env.COMMIT_PUSH_SOURCE }} + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: 'develop-direct-pushes' + payload: | + { + "text": " ${{ github.event.head_commit.url }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Push: ${{ github.event.head_commit.url }}" + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/trigger-pr-tests-plugins.yml b/.github/workflows/trigger-pr-tests-plugins.yml index b618ae1..17a0e8e 100644 --- a/.github/workflows/trigger-pr-tests-plugins.yml +++ b/.github/workflows/trigger-pr-tests-plugins.yml @@ -1,19 +1,19 @@ name: Trigger PR tests (Plugins) on: - pull_request: - types: [auto_merge_enabled] + pull_request: + types: [auto_merge_enabled] jobs: - trigger-pr-tests-plugins: - name: Trigger PR tests (Plugins) - runs-on: ubuntu-latest - steps: - - name: Call TeamCity API endpoint - run: | - curl \ - -X POST \ - -H 'Authorization: Bearer ${{ secrets.TEAMCITY_TRIGGER_TESTS_TOKEN }}' \ - -H 'Content-Type: application/json' \ - -d '{"branchName": "pull/${{ github.event.number }}", "buildType": {"id": "${{ vars.TEAMCITY_BUILD_ID_FOR_TESTING_PLUGIN_PR }}"}}' \ - ${{ vars.TEAMCITY_API_URL }}/buildQueue \ No newline at end of file + trigger-pr-tests-plugins: + name: Trigger PR tests (Plugins) + runs-on: ubuntu-latest + steps: + - name: Call TeamCity API endpoint + run: | + curl \ + -X POST \ + -H 'Authorization: Bearer ${{ secrets.TEAMCITY_TRIGGER_TESTS_TOKEN }}' \ + -H 'Content-Type: application/json' \ + -d '{"branchName": "pull/${{ github.event.number }}", "buildType": {"id": "${{ vars.TEAMCITY_BUILD_ID_FOR_TESTING_PLUGIN_PR }}"}}' \ + ${{ vars.TEAMCITY_API_URL }}/buildQueue diff --git a/.prettierrc b/.prettierrc index 1ebc338..2709baa 100644 --- a/.prettierrc +++ b/.prettierrc @@ -8,5 +8,9 @@ "trailingComma": "all", "bracketSpacing": true, "bracketSameLine": false, - "arrowParens": "avoid" + "arrowParens": "avoid", + "plugins": ["prettier-plugin-jsdoc"], + "jsdocSeparateReturnsFromParam": false, + "jsdocSeparateTagGroups": false, + "jsdocCommentLineStrategy": "keep" } diff --git a/eslint.config.js b/eslint.config.js index 17a0bd7..359e548 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,14 +3,17 @@ const prettierPlugin = require('eslint-plugin-prettier'); const eslintConfigPrettier = require('eslint-config-prettier'); const importPlugin = require('eslint-plugin-import'); const unusedImportsPlugin = require('eslint-plugin-unused-imports'); +const jsdocPlugin = require('eslint-plugin-jsdoc'); /** * @type {import('eslint').Linter.Config[]} */ module.exports = [ + jsdocPlugin.configs['flat/recommended'], { plugins: { 'import': importPlugin, + 'jsdoc': jsdocPlugin, 'unused-imports': unusedImportsPlugin, 'prettier': prettierPlugin, }, @@ -31,6 +34,27 @@ module.exports = [ files: ['**/*.{js,cjs,mjs}'], rules: { ...eslintConfigPrettier.rules, + 'jsdoc/require-jsdoc': [ + 'error', + { + 'publicOnly': false, + 'require': { + 'FunctionDeclaration': true, + 'FunctionExpression': true, + 'ArrowFunctionExpression': true, + 'MethodDefinition': true, + }, + 'contexts': [ + 'FunctionDeclaration', + 'FunctionExpression', + 'ArrowFunctionExpression', + 'MethodDefinition', + ], + }, + ], + 'jsdoc/tag-lines': 'off', // disabled due to conflict with prettier + 'jsdoc/require-param-description': 'off', + 'jsdoc/require-returns-description': 'off', 'no-cond-assign': 'error', 'no-const-assign': 'error', 'no-dupe-args': 'error', diff --git a/forward_engineering/api.js b/forward_engineering/api.js index a100e02..630e02a 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -1,6 +1,5 @@ /** - * @import { ContainerLevelScriptFEData, GenerateContainerLevelScriptCallback } from "./types/types" - * @import { Logger } from "../shared/types/types" + * @import {ContainerLevelScriptFEData, GenerateContainerLevelScriptCallback, ValidateScriptCallback, Logger} from "../shared/types/types" */ const validationHelper = require('./helpers/schemaValidationHelper'); @@ -70,9 +69,9 @@ module.exports = { /** * Validates the given script data. * - * @param {Object} data - The data for validation. + * @param {object} data - The data for validation. * @param {string} data.script - The script to be validated. - * @param {Object} data.targetScriptOptions - Options for the target script. + * @param {object} data.targetScriptOptions - Options for the target script. * @param {Logger} logger - The logger for logging errors. * @param {ValidateScriptCallback} cb - The callback function. */ diff --git a/forward_engineering/helpers/addRequiredHelper.js b/forward_engineering/helpers/addRequiredHelper.js index de1a44a..7b9d005 100644 --- a/forward_engineering/helpers/addRequiredHelper.js +++ b/forward_engineering/helpers/addRequiredHelper.js @@ -1,7 +1,7 @@ /** * Adds required indicator. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.type - The type name statement. * @param {boolean} param0.required - Indicates if the field is required. * @returns {string} - The type name with required indicator. diff --git a/forward_engineering/helpers/commentLinesHelper.js b/forward_engineering/helpers/commentLinesHelper.js index fc6afad..31d23e3 100644 --- a/forward_engineering/helpers/commentLinesHelper.js +++ b/forward_engineering/helpers/commentLinesHelper.js @@ -1,9 +1,8 @@ /** - * Adds comment markers to each line of a GraphQL statement. - * This function takes a GraphQL statement and prepends a '#' character - * to each line, commenting out the entire statement. + * Adds comment markers to each line of a GraphQL statement. This function takes a GraphQL statement and prepends a '#' + * character to each line, commenting out the entire statement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.statement - The GraphQL statement to comment out * @returns {string} - Commented out statement */ diff --git a/forward_engineering/helpers/descriptionsHelper.js b/forward_engineering/helpers/descriptionsHelper.js index 2a9c65e..8bcda0b 100644 --- a/forward_engineering/helpers/descriptionsHelper.js +++ b/forward_engineering/helpers/descriptionsHelper.js @@ -1,8 +1,8 @@ /** - * Formats the description for a GraphQL statement. - * Uses triple quotes for multi-line descriptions and single quotes for single-line descriptions. + * Formats the description for a GraphQL statement. Uses triple quotes for multi-line descriptions and single quotes for + * single-line descriptions. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.description - The description to format * @returns {string} - The formatted description */ diff --git a/forward_engineering/helpers/feStatementFormatHelper.js b/forward_engineering/helpers/feStatementFormatHelper.js index c678864..644149b 100644 --- a/forward_engineering/helpers/feStatementFormatHelper.js +++ b/forward_engineering/helpers/feStatementFormatHelper.js @@ -1,5 +1,5 @@ /** - * @import { FEStatement } from "../types/types" + * @import {FEStatement} from "../../shared/types/types"; */ const { commentLines } = require('./commentLinesHelper'); @@ -7,10 +7,10 @@ const { getStatementDescription } = require('./descriptionsHelper'); const { addIndentToStatement } = require('./feStatementIndentHelper'); /** - * Combines the description and statement, and comments out the statement if it is deactivated. - * Adds formatted nested statements if they exist. + * Combines the description and statement, and comments out the statement if it is deactivated. Adds formatted nested + * statements if they exist. * - * @param {Object} param0 + * @param {object} param0 * @param {FEStatement} param0.feStatement - The forward engineering statement object. * @returns {string} - The final formatted statement. */ @@ -51,6 +51,10 @@ function formatFEStatement({ feStatement }) { return result; } +/** + * @param {string} [description] + * @returns {string} + */ function formatDescription(description) { if (description?.trim()) { const formattedDescription = getStatementDescription({ description }); @@ -59,6 +63,10 @@ function formatDescription(description) { return ''; } +/** + * @param {FEStatement & { isParentActivated: boolean }} params + * @returns {string} + */ function formatNestedStatements({ nestedStatements, isParentActivated, @@ -113,6 +121,10 @@ function formatNestedStatements({ return `${formatSingleLineComment(comment)}\n${formattedNestedStatements}`; } +/** + * @param {string} comment + * @returns {string} + */ function formatSingleLineComment(comment) { return comment ? ` # ${comment}` : ''; } diff --git a/forward_engineering/helpers/feStatementIndentHelper.js b/forward_engineering/helpers/feStatementIndentHelper.js index 8e131d2..87bd840 100644 --- a/forward_engineering/helpers/feStatementIndentHelper.js +++ b/forward_engineering/helpers/feStatementIndentHelper.js @@ -3,9 +3,10 @@ const { GRAPHQL_SCHEMA_SCRIPT_INDENT } = require('../constants/feScriptConstants /** * Adds indentation to each line of a given statement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.statement - The statement to which indentation will be added. - * @param {string} [param0.indent=GRAPHQL_SCHEMA_SCRIPT_INDENT] - The indentation string to use. Defaults to GRAPHQL_INDENT. + * @param {string} [param0.indent] - The indentation string to use. Defaults to GRAPHQL_INDENT. Default is + * `GRAPHQL_SCHEMA_SCRIPT_INDENT` * @returns {string} - The indented statement. */ function addIndentToStatement({ statement, indent = GRAPHQL_SCHEMA_SCRIPT_INDENT }) { diff --git a/forward_engineering/helpers/feStatementJoinHelper.js b/forward_engineering/helpers/feStatementJoinHelper.js index 2583df3..86edc14 100644 --- a/forward_engineering/helpers/feStatementJoinHelper.js +++ b/forward_engineering/helpers/feStatementJoinHelper.js @@ -1,9 +1,10 @@ /** - * Joins an array of statements into a single line. - * Trims each statement, filters out empty statements, and joins them with a space. + * Joins an array of statements into a single line. Trims each statement, filters out empty statements, and joins them + * with a space. * - * @param {Object} param0 + * @param {object} param0 * @param {string[]} param0.statements - The array of statements to join. + * @param {string} [param0.separator] * @returns {string} - The joined statements as a single line. */ function joinInlineStatements({ statements, separator = ' ' }) { diff --git a/forward_engineering/helpers/generateIdToNameMap.js b/forward_engineering/helpers/generateIdToNameMap.js index 5ce7e80..b6d0414 100644 --- a/forward_engineering/helpers/generateIdToNameMap.js +++ b/forward_engineering/helpers/generateIdToNameMap.js @@ -4,8 +4,8 @@ const SYSTEM_NAMES = ['Scalars', 'Enums', 'Objects', 'Interfaces', 'Input object /** * Generate the ID to Name map for the given model definitions schema. * - * @param {Object} modelDefinitionsSchema - The model definitions object properties. - * @returns {Object} - The ID to Name map + * @param {object} modelDefinitionsSchema - The model definitions object properties. + * @returns {object} - The ID to Name map */ const generateIdToNameMap = (modelDefinitionsSchema = {}) => { let idToNameMap = {}; diff --git a/forward_engineering/helpers/referenceHelper.js b/forward_engineering/helpers/referenceHelper.js index f88aa88..c01f995 100644 --- a/forward_engineering/helpers/referenceHelper.js +++ b/forward_engineering/helpers/referenceHelper.js @@ -1,12 +1,13 @@ /** * Get the definition name from the reference path * - * @param {Object} param0 - * @param {string} [param0.referencePath] - The reference path, separated by '/', where the definition name is the last element. + * @param {object} param0 + * @param {string} [param0.referencePath] - The reference path, separated by '/', where the definition name is the last + * element. * @returns {string} - The definition name. */ function getDefinitionNameFromReferencePath({ referencePath = '' }) { - return referencePath.split('/').pop(); + return referencePath.split('/').pop() || ''; } module.exports = { diff --git a/forward_engineering/helpers/referencesHelper.js b/forward_engineering/helpers/referencesHelper.js deleted file mode 100644 index 02fd6ac..0000000 --- a/forward_engineering/helpers/referencesHelper.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Get the definition name from the reference path - * - * @param {Object} param0 - * @param {string} param0.referencePath - The reference path, separated by '/', where the definition name is the last element. - * @returns {string} - The definition name. - */ -function getDefinitionNameFromReferencePath({ referencePath = '' }) { - return referencePath.split('/').pop(); -} - -module.exports = { - getDefinitionNameFromReferencePath, -}; diff --git a/forward_engineering/helpers/schemaValidationHelper.js b/forward_engineering/helpers/schemaValidationHelper.js index fe26058..dd29b2e 100644 --- a/forward_engineering/helpers/schemaValidationHelper.js +++ b/forward_engineering/helpers/schemaValidationHelper.js @@ -1,12 +1,13 @@ /** - * @import { ValidationResponseItem } from "../types/types" + * @import {ValidationResponseItem} from "../../shared/types/types" */ const { buildSchema, validateSchema } = require('graphql'); /** * Validates the given GraphQL schema. - * @param {Object} params - The parameters for validation. + * + * @param {object} params - The parameters for validation. * @param {string} params.schema - The GraphQL schema to be validated. * @returns {ValidationResponseItem[]} An array of validation results. */ @@ -28,9 +29,10 @@ function validate({ schema }) { /** * Maps a GraphQL validation error to a custom error format. - * @param {Object} error - The GraphQL validation error. + * + * @param {object} error - The GraphQL validation error. * @param {string} error.message - The error message. - * @param {Object[]} [error.locations] - The locations of the error in the schema. + * @param {object[]} [error.locations] - The locations of the error in the schema. * @returns {ValidationResponseItem} The mapped error object. */ function mapValidationError(error) { @@ -43,8 +45,9 @@ function mapValidationError(error) { /** * Gets the error position message from a GraphQL validation error. - * @param {Object} error - The GraphQL validation error. - * @param {Object[]} [error.locations] - The locations of the error in the schema. + * + * @param {object} error - The GraphQL validation error. + * @param {object[]} [error.locations] - The locations of the error in the schema. * @param {number} error.locations[].line - The line number of the error location. * @param {number} error.locations[].column - The column number of the error location. * @returns {string} The error position message. @@ -59,6 +62,7 @@ function getErrorPositionMessage(error) { /** * Gets the success response for a valid GraphQL schema. + * * @returns {ValidationResponseItem[]} An array containing the success response. */ function getSucceedResponse() { @@ -67,7 +71,8 @@ function getSucceedResponse() { /** * Gets a response entity. - * @param {Object} params - The parameters for the response entity. + * + * @param {object} params - The parameters for the response entity. * @param {string} params.type - The type of the entity. * @param {string} params.label - The label for the entity. * @param {string} params.title - The title of the entity. diff --git a/forward_engineering/mappers/argumentDefaultValue.js b/forward_engineering/mappers/argumentDefaultValue.js index 6518ca0..869a08d 100644 --- a/forward_engineering/mappers/argumentDefaultValue.js +++ b/forward_engineering/mappers/argumentDefaultValue.js @@ -1,8 +1,10 @@ /** * Get the default value for the given type with proper formatting. - * @param {Object} args - getArgumentDefaultValue arguments object + * + * @param {object} args - GetArgumentDefaultValue arguments object * @param {string} args.type - GraphQL type - * @param {string|number|boolean} [args.defaultValue] - Default value from Properties pane Default field + * @param {string | number | boolean} [args.defaultValue] - Default value from Properties pane Default field + * @returns {string | number | boolean} - The default value */ const getArgumentDefaultValue = ({ type, defaultValue = '' }) => { switch (type) { diff --git a/forward_engineering/mappers/arguments.js b/forward_engineering/mappers/arguments.js index 94632ba..d664b4c 100644 --- a/forward_engineering/mappers/arguments.js +++ b/forward_engineering/mappers/arguments.js @@ -1,5 +1,5 @@ /** - * @import { Argument, IdToNameMap, FEStatement } from "../types/types" + * @import {Argument, ArgumentsResultStatement, IdToNameMap, FEStatement} from "../../shared/types/types" */ const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); @@ -14,10 +14,11 @@ const EMPTY_LIST = '[]'; /** * Gets the type of the argument with the required keyword. - * @param {Object} args - arguments object. + * + * @param {object} args - Arguments object. * @param {Argument} args.graphqlArgument - The argument to map. * @param {IdToNameMap} [args.idToNameMap] - The ID to name map of all available types in model. - * @returns {string} returns the type of the argument with the required keyword + * @returns {string} Returns the type of the argument with the required keyword */ const getArgumentType = ({ graphqlArgument, idToNameMap = {} }) => { let argumentType = idToNameMap[graphqlArgument.type] || getCheckedType({ type: graphqlArgument.type }) || ''; @@ -38,10 +39,11 @@ const getArgumentType = ({ graphqlArgument, idToNameMap = {} }) => { /** * Maps an argument to a string with all configured properties. - * @param {Object} args - arguments object. + * + * @param {object} args - Arguments object. * @param {Argument} args.graphqlArgument - The argument to map. * @param {IdToNameMap} [args.idToNameMap] - The ID to name map of all available types in model. - * @returns {FEStatement} returns the argument as a FEStatement + * @returns {FEStatement} Returns the argument as a FEStatement */ const mapArgument = ({ graphqlArgument, idToNameMap = {} }) => { const argumentName = `${graphqlArgument.name}:`; @@ -67,12 +69,12 @@ const mapArgument = ({ graphqlArgument, idToNameMap = {} }) => { /** * Maps an array of arguments to a formatted string with all configured properties. - * @param {Object} args - arguments object. + * + * @param {object} args - Arguments object. * @param {Argument[]} args.graphqlArguments - The arguments to map. * @param {IdToNameMap} [args.idToNameMap] - The ID to name map of all available types in model. - * @returns {Object} returns an object containing the arguments as a formatted string and a warning comment if any. - * @returns {string} returns.argumentsStatement - The formatted arguments string. - * @returns {string} returns.argumentsWarningComment - The warning comment if any argument is missing a type. + * @returns {ArgumentsResultStatement} Returns an object containing the arguments as a formatted string and a warning + * comment if any. */ const getArguments = ({ graphqlArguments, idToNameMap = {} }) => { if (!Array.isArray(graphqlArguments) || graphqlArguments.length === 0) { @@ -111,10 +113,20 @@ const getArguments = ({ graphqlArguments, idToNameMap = {} }) => { return { argumentsStatement, argumentsWarningComment: '' }; }; +/** + * @param {object} params + * @param {string} params.type + * @returns {string} + */ function getCheckedType({ type }) { return isUUID(type) ? '' : type; } +/** + * @param {object} params + * @param {string} params.type + * @returns {boolean} + */ function isTypeEmpty({ type }) { return !type || type === EMPTY_LIST || type === '!' || type === `${EMPTY_LIST}!`; } diff --git a/forward_engineering/mappers/customScalars.js b/forward_engineering/mappers/customScalars.js index ebdb62c..9fbf825 100644 --- a/forward_engineering/mappers/customScalars.js +++ b/forward_engineering/mappers/customScalars.js @@ -1,25 +1,25 @@ /** - * @import { FEStatement, DirectivePropertyData, IdToNameMap } from "../types/types" + * @import {FEStatement, DirectivePropertyData, IdToNameMap} from "../../shared/types/types" */ const { joinInlineStatements } = require('../helpers/feStatementJoinHelper'); const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); /** - * @typedef {Object} CustomScalar + * @typedef {object} CustomScalar * @property {string} description - The description of the custom scalar. * @property {boolean} isActivated - Indicates if the custom scalar is activated. * @property {DirectivePropertyData[]} typeDirectives - The directives of the custom scalar. */ /** - * @typedef {Object.} CustomScalars + * @typedef {Record} CustomScalars */ /** * Maps a custom scalar to an FEStatement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.name - The name of the custom scalar. * @param {CustomScalar} param0.customScalar - The custom scalar object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. @@ -42,7 +42,7 @@ function mapCustomScalar({ name, customScalar, definitionsIdToNameMap }) { /** * Gets the custom scalars as an array of FEStatements. * - * @param {Object} param0 + * @param {object} param0 * @param {CustomScalars} param0.customScalars - The custom scalars object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {FEStatement[]} diff --git a/forward_engineering/mappers/directiveUsageStatements.js b/forward_engineering/mappers/directiveUsageStatements.js index af65cc6..e8b1467 100644 --- a/forward_engineering/mappers/directiveUsageStatements.js +++ b/forward_engineering/mappers/directiveUsageStatements.js @@ -1,5 +1,5 @@ /** - * @import { DirectivePropertyData, IdToNameMap } from "../types/types" + * @import {DirectivePropertyData, IdToNameMap} from "../../shared/types/types" */ const { joinInlineStatements } = require('../helpers/feStatementJoinHelper'); @@ -8,7 +8,7 @@ const { isUUID } = require('../helpers/isUUID'); /** * Gets the directives usage statement by mapping directives to strings and joining them. * - * @param {Object} params + * @param {object} params * @param {DirectivePropertyData[]} params.directives - Array of directive definitions * @param {IdToNameMap} [params.definitionsIdToNameMap] - The definitions id to name map. * @returns {string} - The joined directive statements @@ -22,7 +22,8 @@ function getDirectivesUsageStatement({ directives = [], definitionsIdToNameMap = /** * Maps a single directive to its string representation with name and arguments. - * @param {Object} params - The parameters object + * + * @param {object} params - The parameters object * @param {DirectivePropertyData} params.directive - The directive to map * @param {IdToNameMap} [params.definitionsIdToNameMap] - The definitions id to name map. * @returns {string} - The directive statement or empty string if invalid @@ -45,9 +46,9 @@ function mapDirective({ directive, definitionsIdToNameMap }) { } /** - * Maps a directive's raw arguments to a formatted string. - * Handles adding parentheses and cleaning up newlines. - * @param {Object} params + * Maps a directive's raw arguments to a formatted string. Handles adding parentheses and cleaning up newlines. + * + * @param {object} params * @param {DirectivePropertyData} params.directive - The directive containing the arguments * @returns {string} - The formatted arguments string or empty string if no valid arguments */ @@ -67,7 +68,8 @@ function mapDirectiveRawArguments({ directive }) { /** * Resolves and formats a directive name, ensuring proper @ prefix. - * @param {Object} params + * + * @param {object} params * @param {string} params.directiveName - The raw directive name or ID * @param {IdToNameMap} [params.definitionsIdToNameMap] - The definitions id to name map. * @returns {string} - The formatted directive name or empty string if invalid @@ -85,7 +87,8 @@ function getDirectiveName({ directiveName, definitionsIdToNameMap }) { /** * Formats a raw directive string by trimming whitespace and normalizing newlines. - * @param {Object} params + * + * @param {object} params * @param {string} params.rawDirective - The raw directive string to format * @returns {string} - The formatted directive string or empty string if invalid */ diff --git a/forward_engineering/mappers/directives.js b/forward_engineering/mappers/directives.js index a3119c1..6d5d879 100644 --- a/forward_engineering/mappers/directives.js +++ b/forward_engineering/mappers/directives.js @@ -1,5 +1,5 @@ /** - * @import { DirectiveDefinitions, Directive, FEStatement, DirectiveLocations, IdToNameMap } from "../types/types" + * @import {DirectiveDefinitions, Directive, FEStatement, DirectiveLocations, IdToNameMap} from "../../shared/types/types" */ const { DIRECTIVE_LOCATIONS } = require('../constants/feScriptConstants'); @@ -10,9 +10,9 @@ const UNKNOWN_LOCATION = 'UNKNOWN_LOCATION'; /** * Map directive locations to a string. * - * @param {Object} args - The arguments object + * @param {object} args - The arguments object * @param {DirectiveLocations} [args.directiveLocations] - The directive locations object with all available locations - * @return {string} + * @returns {string} */ function mapDirectiveLocations({ directiveLocations = {} }) { const directiveLocationsString = Object.keys(directiveLocations) @@ -38,11 +38,12 @@ const getDirectiveName = name => (name.startsWith('@') ? name : `@${name}`); /** * Map a directive to an FEStatement object. * - * @param {Object} args - The arguments object + * @param {object} args - The arguments object * @param {string} args.name - The name of directive * @param {Directive} args.directive - The directive object - * @param {IdToNameMap} args.definitionsIdToNameMap - The ID to name map of all available types in model - needs for arguments - * @return {FEStatement} + * @param {IdToNameMap} args.definitionsIdToNameMap - The ID to name map of all available types in model - needs for + * arguments + * @returns {FEStatement} */ function mapDirective({ name, directive, definitionsIdToNameMap }) { const directiveName = getDirectiveName(name); @@ -63,8 +64,9 @@ function mapDirective({ name, directive, definitionsIdToNameMap }) { /** * Maps directives to an FEStatement objects. * - * @param {Object} args - The arguments object + * @param {object} args - The arguments object * @param {DirectiveDefinitions} args.definitionsIdToNameMap - The directives schema object + * @param {object} args.directives * @returns {FEStatement[]} */ function getDirectives({ definitionsIdToNameMap, directives = {} }) { diff --git a/forward_engineering/mappers/enums.js b/forward_engineering/mappers/enums.js index 9dfdc58..c960b58 100644 --- a/forward_engineering/mappers/enums.js +++ b/forward_engineering/mappers/enums.js @@ -1,19 +1,19 @@ /** - * @import { FEStatement, DirectivePropertyData, IdToNameMap } from "../types/types" + * @import {FEStatement, DirectivePropertyData, IdToNameMap} from "../../shared/types/types" */ const { joinInlineStatements } = require('../helpers/feStatementJoinHelper'); const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); /** - * @typedef {Object} EnumValue + * @typedef {object} EnumValue * @property {string} value - The name of the enum value. * @property {string} description - The description of the enum value. * @property {DirectivePropertyData[]} typeDirectives - The directives of the enum value. */ /** - * @typedef {Object} EnumDefinition + * @typedef {object} EnumDefinition * @property {string} description - The description of the enum. * @property {boolean} isActivated - Indicates if the enum is activated. * @property {DirectivePropertyData[]} typeDirectives - The directives of the enum. @@ -21,13 +21,13 @@ const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); */ /** - * @typedef {Object.} EnumDefinitions + * @typedef {Record} EnumDefinitions */ /** * Gets the enums as an array of FEStatements. * - * @param {Object} param0 + * @param {object} param0 * @param {EnumDefinitions} param0.enumsDefinitions - The enums object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {FEStatement[]} @@ -41,7 +41,7 @@ function getEnums({ enumsDefinitions, definitionsIdToNameMap }) { /** * Maps a enum to an FEStatement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.name - The name of the enum. * @param {EnumDefinition} param0.enumDefinition - The enum definition object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. @@ -65,7 +65,7 @@ function mapEnum({ name, enumDefinition, definitionsIdToNameMap }) { /** * Maps the enum values to an array of FEStatement. * - * @param {Object} param0 + * @param {object} param0 * @param {EnumValue[]} param0.enumValues - The enum values. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {FEStatement[]} diff --git a/forward_engineering/mappers/fieldDefaultValue.js b/forward_engineering/mappers/fieldDefaultValue.js index 43b7ec2..233bbdb 100644 --- a/forward_engineering/mappers/fieldDefaultValue.js +++ b/forward_engineering/mappers/fieldDefaultValue.js @@ -1,11 +1,11 @@ /** - * @import { FieldData } from "../types/types" + * @import {FieldData} from "../../shared/types/types" */ /** * Generates the default value statement for a field. * - * @param {Object} param0 + * @param {object} param0 * @param {FieldData} param0.field - The field object. * @returns {string} - The default value statement. */ @@ -24,7 +24,7 @@ function getFieldDefaultValueStatement({ field }) { /** * Formats the default value for a field. * - * @param {Object} param0 + * @param {object} param0 * @param {unknown} param0.defaultValue - The default value. * @param {string} param0.fieldType - The type of the field. * @returns {string} - The formatted default value. @@ -44,7 +44,7 @@ function formatFieldDefaultValue({ defaultValue, fieldType }) { /** * Formats the default value for a reference field. * - * @param {Object} param0 + * @param {object} param0 * @param {any} param0.defaultValue - The default value. * @returns {string} - The formatted default value. */ @@ -62,7 +62,7 @@ function formatRefFieldDefaultValue({ defaultValue }) { /** * Checks if the default value is complex (object or array). * - * @param {Object} param0 + * @param {object} param0 * @param {unknown} param0.defaultValue - The default value. * @returns {boolean} - True if the default value is complex, false otherwise. */ @@ -90,7 +90,7 @@ function isValuePresent(value) { /** * Prepares a complex default value by removing newlines. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.defaultValue - The default value. * @returns {string} - The prepared default value. */ diff --git a/forward_engineering/mappers/fields.js b/forward_engineering/mappers/fields.js index 41fd387..d42a45e 100644 --- a/forward_engineering/mappers/fields.js +++ b/forward_engineering/mappers/fields.js @@ -1,22 +1,22 @@ /** - * @import { FEStatement, DirectivePropertyData, FieldData, ArrayItem, IdToNameMap } from "../types/types" + * @import {FEStatement, FieldData, ArrayItem, IdToNameMap} from "../../shared/types/types" */ const { joinInlineStatements } = require('../helpers/feStatementJoinHelper'); -const { getDefinitionNameFromReferencePath } = require('../helpers/referencesHelper'); +const { getDefinitionNameFromReferencePath } = require('../helpers/referenceHelper'); const { getArguments } = require('./arguments'); const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); const { getFieldDefaultValueStatement } = require('./fieldDefaultValue'); const { addRequired } = require('../helpers/addRequiredHelper'); /** - * @typedef {Object.} FieldsData + * @typedef {Record} FieldsData */ /** * Gets the fields from the model definitions. * - * @param {Object} param0 + * @param {object} param0 * @param {FieldsData} param0.fields - The fields to get. * @param {string[]} param0.requiredFields - The required fields list. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. @@ -40,7 +40,7 @@ function getFields({ fields = [], requiredFields = [], definitionsIdToNameMap, a /** * Maps a field to an FEStatement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.name - The name of the field. * @param {FieldData} param0.fieldData - The field data object. * @param {boolean} param0.required - Indicates if the field is required. @@ -72,7 +72,7 @@ function mapField({ name, fieldData, required, definitionsIdToNameMap, addArgume /** * Gets the field type. * - * @param {Object} param0 + * @param {object} param0 * @param {FieldData} param0.field - The field data object. * @param {boolean} param0.required - Indicates if the field is required. * @returns {string} - The field type. @@ -97,7 +97,7 @@ function getFieldType({ field, required }) { /** * Gets the field from array items. * - * @param {Object} param0 + * @param {object} param0 * @param {FieldData['items']} param0.items - The array items. * @returns {ArrayItem} - The field. */ @@ -108,11 +108,17 @@ function getFieldFromArrayItems({ items }) { return items; } +// TODO: Add proper JSDoc comments for the functions that are exported module.exports = { + // eslint-disable-next-line jsdoc/require-jsdoc getObjectTypeFields: params => getFields({ ...params, addArguments: true, addDefaultValue: false }), + // eslint-disable-next-line jsdoc/require-jsdoc getInterfaceTypeFields: params => getFields({ ...params, addArguments: true, addDefaultValue: false }), + // eslint-disable-next-line jsdoc/require-jsdoc getInputTypeFields: params => getFields({ ...params, addArguments: false, addDefaultValue: true }), + // eslint-disable-next-line jsdoc/require-jsdoc getRootTypeFields: params => getFields({ ...params, addArguments: true, addDefaultValue: false }), + // exported only for tests: mapField, getFieldType, diff --git a/forward_engineering/mappers/implementsInterfaces.js b/forward_engineering/mappers/implementsInterfaces.js index 838b186..17d6a44 100644 --- a/forward_engineering/mappers/implementsInterfaces.js +++ b/forward_engineering/mappers/implementsInterfaces.js @@ -1,11 +1,11 @@ /** - * @import { IdToNameMap, ImplementsInterface } from "../types/types" + * @import {IdToNameMap, ImplementsInterface} from "../../shared/types/types" */ /** * Get implements interfaces statement * - * @param {Object} param0 + * @param {object} param0 * @param {ImplementsInterface[]} param0.interfaces - The interfaces to implement. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {string} - The implements interfaces statement. @@ -22,7 +22,7 @@ function getImplementsInterfacesStatement({ interfaces = [], definitionsIdToName /** * Get implemented interfaces list * - * @param {Object} param0 + * @param {object} param0 * @param {ImplementsInterface[]} param0.interfaces - The interfaces to implement. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {string[]} - The implemented interfaces list. diff --git a/forward_engineering/mappers/objectLikeType.js b/forward_engineering/mappers/objectLikeType.js index 7662452..45caf88 100644 --- a/forward_engineering/mappers/objectLikeType.js +++ b/forward_engineering/mappers/objectLikeType.js @@ -1,5 +1,5 @@ /** - * @import { FEStatement, DirectivePropertyData, ObjectLikeTypeDefinition, ObjectLikeTypeDefinitions, IdToNameMap, ImplementsInterface } from "../types/types" + * @import {FEStatement, ObjectLikeTypeDefinition, ObjectLikeTypeDefinitions, IdToNameMap} from "../../shared/types/types" */ const { joinInlineStatements } = require('../helpers/feStatementJoinHelper'); @@ -9,7 +9,7 @@ const { getImplementsInterfacesStatement } = require('./implementsInterfaces'); /** * Gets the object-like types from the model definitions. * - * @param {Object} param0 + * @param {object} param0 * @param {ObjectLikeTypeDefinitions} param0.objectTypes - The object-like types to get. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @param {string} param0.typeKeyword - The type keyword ("type", "interface", "input"). @@ -25,7 +25,7 @@ function getObjectLikeTypes({ objectTypes, definitionsIdToNameMap, typeKeyword, /** * Maps an object-like type to an FEStatement. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.name - The name of the object. * @param {ObjectLikeTypeDefinition} param0.objectType - The object-like type definition object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. diff --git a/forward_engineering/mappers/rootTypes.js b/forward_engineering/mappers/rootTypes.js index b205b16..70a380f 100644 --- a/forward_engineering/mappers/rootTypes.js +++ b/forward_engineering/mappers/rootTypes.js @@ -1,5 +1,5 @@ /** - * @import { FEStatement, IdToNameMap, RootTypeNamesParameter, EntityIdToJsonSchemaMap, EntityIdToPropertiesMap, ContainerDetails } from "../types/types" + * @import {FEStatement, IdToNameMap, RootTypeNamesParameter, EntityIdToJsonSchemaMap, EntityIdToPropertiesMap, ContainerDetails} from "../../shared/types/types" */ const { QUERY_ROOT_TYPE, MUTATION_ROOT_TYPE, SUBSCRIPTION_ROOT_TYPE } = require('../constants/feScriptConstants'); @@ -8,14 +8,14 @@ const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); const { getRootTypeFields } = require('./fields'); /** - * Gets the root schema statement. - * If all root types are empty, return null, to trigger validation error that we are referencing non-existing root types. - * If the root type is not present in the root types, do not include it in the root schema statement. + * Gets the root schema statement. If all root types are empty, return null, to trigger validation error that we are + * referencing non-existing root types. If the root type is not present in the root types, do not include it in the root + * schema statement. * - * @param {Object} param0 + * @param {object} param0 * @param {RootTypeNamesParameter} param0.rootTypeNames - The root type names. * @param {FEStatement[]} param0.rootTypeStatements - The root types. - * @param {ContainerDetails|undefined} param0.containerProperties - The container properties. + * @param {ContainerDetails | undefined} param0.containerProperties - The container properties. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {FEStatement | null} - The root schema statement or null if all root types have default values. */ @@ -52,11 +52,11 @@ function getRootSchemaStatement({ rootTypeNames, rootTypeStatements, containerPr } /** - * Gets the root type names. - * Return the default root type names or the custom root type names if they are present in the container properties. + * Gets the root type names. Return the default root type names or the custom root type names if they are present in the + * container properties. * - * @param {Object} param0 - * @param {ContainerDetails|undefined} param0.containerProperties - The container properties. + * @param {object} param0 + * @param {ContainerDetails | undefined} param0.containerProperties - The container properties. * @returns {RootTypeNamesParameter} - The root type names. */ function getRootTypeNames({ containerProperties }) { @@ -92,11 +92,10 @@ function getRootTypeNames({ containerProperties }) { } /** - * Gets the root types. - * Iterate over the entities and get the root types. - * For each root type, get the nested statements composed of the fields of the entities with the operation type equal to the root type. + * Gets the root types. Iterate over the entities and get the root types. For each root type, get the nested statements + * composed of the fields of the entities with the operation type equal to the root type. * - * @param {Object} param0 + * @param {object} param0 * @param {EntityIdToJsonSchemaMap} param0.entityIdToJsonSchemaMap - The entities JSON schema. * @param {EntityIdToPropertiesMap} param0.entityIdToPropertiesMap - The entity properties. * @param {RootTypeNamesParameter} param0.rootTypeNames - The root type names. @@ -134,18 +133,18 @@ function getRootTypes({ entityIdToJsonSchemaMap, entityIdToPropertiesMap, rootTy } /** - * Gets the root type. - * Iterate over the entities and get the root type. - * For each root type, get the nested statements composed of the fields of the entities with the operation type equal to the root type. - * If there are no entities with the operation type equal to the root type, return null. + * Gets the root type. Iterate over the entities and get the root type. For each root type, get the nested statements + * composed of the fields of the entities with the operation type equal to the root type. If there are no entities with + * the operation type equal to the root type, return null. * - * @param {Object} param0 + * @param {object} param0 * @param {EntityIdToJsonSchemaMap} param0.entityIdToJsonSchemaMap - The entities JSON schema. * @param {EntityIdToPropertiesMap} param0.entityIdToPropertiesMap - The entity properties. * @param {string} param0.rootTypeName - The root type name. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @param {string} param0.rootType - The root type. - * @returns {FEStatement | null} - The root type or null if there are no entities with the operation type equal to the root type. + * @returns {FEStatement | null} - The root type or null if there are no entities with the operation type equal to the + * root type. */ function getRootType({ entityIdToJsonSchemaMap, diff --git a/forward_engineering/mappers/schemaVersionHeader.js b/forward_engineering/mappers/schemaVersionHeader.js index 0f42200..0042732 100644 --- a/forward_engineering/mappers/schemaVersionHeader.js +++ b/forward_engineering/mappers/schemaVersionHeader.js @@ -1,11 +1,11 @@ /** - * @import { FEStatement } from "../types/types" + * @import {FEStatement} from "../../shared/types/types" */ /** * Generates a header containing the schema version and the generation date. * - * @param {Object} param0 + * @param {object} param0 * @param {string} param0.schemaVersion - The version of the schema. * @returns {FEStatement} - The header containing the schema version and generation date. */ diff --git a/forward_engineering/mappers/typeDefinitions.js b/forward_engineering/mappers/typeDefinitions.js index d7c0af1..4c90480 100644 --- a/forward_engineering/mappers/typeDefinitions.js +++ b/forward_engineering/mappers/typeDefinitions.js @@ -1,5 +1,5 @@ /** - * @import { IdToNameMap } from "../types/types" + * @import {IdToNameMap, FEStatement} from "../../shared/types/types" */ const { getCustomScalars } = require('./customScalars'); @@ -11,8 +11,8 @@ const { getObjectTypeFields, getInterfaceTypeFields, getInputTypeFields } = requ /** * Gets the type definition statements from model definitions. * - * @param {Object} param0 - * @param {Object} param0.modelDefinitions - The model definitions object. + * @param {object} param0 + * @param {object} param0.modelDefinitions - The model definitions object. * @param {IdToNameMap} param0.definitionsIdToNameMap - The definitions id to name map. * @returns {FEStatement[]} - The formatted type definition statements. */ @@ -51,10 +51,10 @@ function getTypeDefinitionStatements({ modelDefinitions, definitionsIdToNameMap /** * Gets the model definitions by parent's subtype, to not use definitions category name as it may change. * - * @param {Object} param0 - The parameter object. - * @param {Object} param0.modelDefinitions - The model definitions object. + * @param {object} param0 - The parameter object. + * @param {object} param0.modelDefinitions - The model definitions object. * @param {string} param0.subtype - The subtype to filter by. - * @returns {Object} - The model definitions found by parent's subtype. + * @returns {object} - The model definitions found by parent's subtype. */ function getModelDefinitionsBySubtype({ modelDefinitions, subtype }) { const subtypeDefinitions = Object.values(modelDefinitions.properties).find( diff --git a/forward_engineering/mappers/unions.js b/forward_engineering/mappers/unions.js index 03be952..2d78fa7 100644 --- a/forward_engineering/mappers/unions.js +++ b/forward_engineering/mappers/unions.js @@ -1,5 +1,5 @@ /** - * @import { UnionDefinitions, FEStatement, Union } from "../../types/types" + * @import {UnionDefinitions, FEStatement, Union, UnionMemberType} from "../../shared/types/types" */ const { getDefinitionNameFromReferencePath } = require('../helpers/referenceHelper'); @@ -9,9 +9,9 @@ const { getDirectivesUsageStatement } = require('./directiveUsageStatements'); /** * Map the union member types to a string. * - * @param {Object} args - The arguments - * @param {UnionMemberType[]} unionMemberTypes - The union member types with all properties - * @return {string} + * @param {object} params - The arguments + * @param {UnionMemberType[]} params.unionMemberTypes - The union member types with all properties + * @returns {string} */ const getUnionMemberTypes = ({ unionMemberTypes }) => { return unionMemberTypes @@ -27,7 +27,7 @@ const getUnionMemberTypes = ({ unionMemberTypes }) => { /** * Maps a union to an FEStatement. * - * @param {Object} args - The arguments + * @param {object} args - The arguments * @param {string} args.name - The name of the union. * @param {Union} args.union - The union object with all properties * @returns {FEStatement} @@ -44,9 +44,9 @@ const mapUnion = ({ name, union }) => { /** * Maps the union types to an array of FEStatement. * - * @param {Object} args - The arguments + * @param {object} args - The arguments * @param {UnionDefinitions} args.unions - The union types schema. - * @return {FEStatement[]} + * @returns {FEStatement[]} */ const getUnions = ({ unions }) => { return Object.entries(unions).map(([name, union]) => mapUnion({ name, union })); diff --git a/package-lock.json b/package-lock.json index f5ba916..e0de95f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,17 +14,21 @@ }, "devDependencies": { "@hackolade/hck-esbuild-plugins-pack": "0.0.1", + "@types/node": "22.13.10", "esbuild": "0.25.0", "esbuild-plugin-clean": "1.0.1", "eslint": "9.20.1", "eslint-config-prettier": "10.0.1", "eslint-plugin-import": "2.31.0", + "eslint-plugin-jsdoc": "50.6.8", "eslint-plugin-prettier": "5.2.3", "eslint-plugin-unused-imports": "4.1.4", "globals": "15.15.0", "lint-staged": "15.4.3", "prettier": "3.5.0", - "simple-git-hooks": "2.11.1" + "prettier-plugin-jsdoc": "1.3.2", + "simple-git-hooks": "2.11.1", + "typescript": "5.8.2" }, "engines": { "hackolade": "8.0.0", @@ -32,6 +36,21 @@ "node": ">=20.18.0" } }, + "node_modules/@es-joy/jsdoccomment": { + "version": "0.49.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.49.0.tgz", + "integrity": "sha512-xjZTSFgECpb9Ohuk5yMX5RhUEbfeQcuOp8IF60e+wyzWEF0M5xeSgqsfLtvPEX8BIyOX9saZqzuGPmZ8oWc+5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "comment-parser": "1.4.1", + "esquery": "^1.6.0", + "jsdoc-type-pratt-parser": "~4.1.0" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.0", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz", @@ -876,6 +895,16 @@ "node": ">=16.0.0" } }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -897,6 +926,40 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.13.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz", + "integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/acorn": { "version": "8.14.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", @@ -996,6 +1059,16 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", + "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1165,6 +1238,13 @@ "dev": true, "license": "MIT" }, + "node_modules/binary-searching": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/binary-searching/-/binary-searching-2.0.5.tgz", + "integrity": "sha512-v4N2l3RxL+m4zDxyxz3Ne2aTmiPn8ZUpKFpdPtO+ItW1NcTCXA7JeHG5GMBSvoKSkQZ9ycS+EouDVxYB9ufKWA==", + "dev": true, + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1266,6 +1346,17 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -1346,6 +1437,16 @@ "node": ">=18" } }, + "node_modules/comment-parser": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz", + "integrity": "sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1440,6 +1541,20 @@ } } }, + "node_modules/decode-named-character-reference": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.1.0.tgz", + "integrity": "sha512-Wy+JTSbFThEOXQIR2L6mxJvEs+veIzpmqD7ynWxMXGpnk3smkHQOp6forLdHsKpAMW9iJpaBBIxz285t1n1C3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1506,6 +1621,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -1653,6 +1792,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz", + "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", @@ -1948,6 +2094,45 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-jsdoc": { + "version": "50.6.8", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.6.8.tgz", + "integrity": "sha512-PPZVqhoXaalMQwDGzcQrJtPSPIPOYsSMtvkjYAdsIazOW20yhYtVX4+jLL+XznD4zYTXyZbPWPRKkNev4D4lyw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@es-joy/jsdoccomment": "~0.49.0", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.1", + "debug": "^4.3.6", + "escape-string-regexp": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.6.0", + "parse-imports": "^2.1.1", + "semver": "^7.6.3", + "spdx-expression-parse": "^4.0.0", + "synckit": "^0.9.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-plugin-prettier": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.3.tgz", @@ -3165,6 +3350,16 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdoc-type-pratt-parser": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.1.0.tgz", + "integrity": "sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -3407,6 +3602,45 @@ "node": ">= 0.4" } }, + "node_modules/mdast-util-from-markdown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", + "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -3424,6 +3658,469 @@ "node": ">= 8" } }, + "node_modules/micromark": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", + "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", + "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -3750,6 +4447,20 @@ "node": ">=6" } }, + "node_modules/parse-imports": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.2.1.tgz", + "integrity": "sha512-OL/zLggRp8mFhKL0rNORUTR4yBYujK/uU+xZL+/0Rgm2QE4nLO9v8PzEweSJEbMGKmDRjJE4R3IMJlL2di4JeQ==", + "dev": true, + "license": "Apache-2.0 AND MIT", + "dependencies": { + "es-module-lexer": "^1.5.3", + "slashes": "^3.0.12" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3872,6 +4583,24 @@ "node": ">=6.0.0" } }, + "node_modules/prettier-plugin-jsdoc": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-jsdoc/-/prettier-plugin-jsdoc-1.3.2.tgz", + "integrity": "sha512-LNi9eq0TjyZn/PUNf/SYQxxUvGg5FLK4alEbi3i/S+2JbMyTu790c/puFueXzx09KP44oWCJ+TaHRyM/a0rKJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-searching": "^2.0.5", + "comment-parser": "^1.4.0", + "mdast-util-from-markdown": "^2.0.0" + }, + "engines": { + "node": ">=14.13.1 || >=16.0.0" + }, + "peerDependencies": { + "prettier": "^3.0.0" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4317,6 +5046,13 @@ "node": ">=8" } }, + "node_modules/slashes": { + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/slashes/-/slashes-3.0.12.tgz", + "integrity": "sha512-Q9VME8WyGkc7pJf6QEkj3wE+2CnvZMI+XJhwdTPR8Z/kWQRXi7boAWLDibRPyHRTUTPx5FaU7MsyrjI3yLB4HA==", + "dev": true, + "license": "ISC" + }, "node_modules/slice-ansi": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", @@ -4347,6 +5083,31 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz", + "integrity": "sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.21", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz", + "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", @@ -4652,6 +5413,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typescript": { + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", @@ -4671,6 +5446,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", diff --git a/package.json b/package.json index 166c776..d112459 100644 --- a/package.json +++ b/package.json @@ -111,20 +111,25 @@ "lint": "eslint . --max-warnings=0", "test:unit": "node --experimental-test-module-mocks --test-reporter dot --test ./test", "package": "node esbuild.package.js", - "postinstall": "npx simple-git-hooks" + "postinstall": "npx simple-git-hooks", + "check:types": "tsc --noEmit" }, "devDependencies": { "@hackolade/hck-esbuild-plugins-pack": "0.0.1", + "@types/node": "22.13.10", "esbuild": "0.25.0", "esbuild-plugin-clean": "1.0.1", "eslint": "9.20.1", "eslint-config-prettier": "10.0.1", "eslint-plugin-import": "2.31.0", + "eslint-plugin-jsdoc": "50.6.8", "eslint-plugin-prettier": "5.2.3", "eslint-plugin-unused-imports": "4.1.4", "globals": "15.15.0", "lint-staged": "15.4.3", "prettier": "3.5.0", - "simple-git-hooks": "2.11.1" + "prettier-plugin-jsdoc": "1.3.2", + "simple-git-hooks": "2.11.1", + "typescript": "5.8.2" } } diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index ea918cf..faf0320 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -1,6 +1,5 @@ /** - * @import { FileREData, REFromFileCallback, TestConnectionInfo, TestConnectionCallback, DisconnectCallback, REConnectionInfo } from "./types/types" - * @import { Logger } from "../shared/types/types" + * @import {FileREData, REFromFileCallback, TestConnectionInfo, TestConnectionCallback, DisconnectCallback, REConnectionInfo, Logger} from "../shared/types/types" */ const { getFileName } = require('./helpers/getFileName'); @@ -13,16 +12,18 @@ const { convertIntrospectionSchemaToGraphQLSchema } = require('./helpers/convert module.exports = { /** * Common disconnect method - not needed for GraphQL API - * @param {null} connectionInfo - * @param {Logger} logger + * + * @param {REConnectionInfo} _connectionInfo + * @param {Logger} _logger * @param {DisconnectCallback} callback */ - disconnect(connectionInfo, logger, callback) { + disconnect(_connectionInfo, _logger, callback) { callback(); }, /** * Test a connection to the GraphQL server - executes introspection query + * * @param {TestConnectionInfo} connectionInfo * @param {Logger} logger * @param {TestConnectionCallback} callback @@ -39,10 +40,9 @@ module.exports = { }, /** - * * @param {REConnectionInfo} data - * @param {Logger} logger - * @param callback + * @param {Logger} logger - Logger instance + * @param {(err?: Error | null, data?: object[], modelLevel: object, relationships: object[]) => void} callback * @returns {Promise} */ async getDbCollectionsData(data, logger, callback) { @@ -86,6 +86,7 @@ module.exports = { /** * RE a GraphQL schema file and returns the mapped schema + * * @param {FileREData} data * @param {Logger} logger * @param {REFromFileCallback} callback @@ -97,7 +98,7 @@ module.exports = { const fileName = getFileName(data.filePath); const { parsedSchema /*validationErrors*/ } = parseSchema({ schemaContent: fileContent }); // TODO: validation warnings can be returned in modelData const mappedEntities = getMappedSchema({ - schemaItems: parsedSchema.definitions, + schemaItems: [...parsedSchema.definitions], graphName: fileName, logger, fieldsOrder, diff --git a/reverse_engineering/helpers/convertIntrospectionSchemaToGraphQLSchema.js b/reverse_engineering/helpers/convertIntrospectionSchemaToGraphQLSchema.js index b623507..b0d87e0 100644 --- a/reverse_engineering/helpers/convertIntrospectionSchemaToGraphQLSchema.js +++ b/reverse_engineering/helpers/convertIntrospectionSchemaToGraphQLSchema.js @@ -1,11 +1,12 @@ /** - * @import { IntrospectionQuery } from 'graphql'; + * @import {IntrospectionQuery} from 'graphql'; */ const { buildClientSchema, printSchema } = require('graphql/utilities'); /** * Convert introspection schema to GraphQL SDL schema + * * @param {IntrospectionQuery} introspectionSchema * @returns {string} */ diff --git a/reverse_engineering/helpers/fetchIntrospectionSchema.js b/reverse_engineering/helpers/fetchIntrospectionSchema.js index 28ae528..618a61d 100644 --- a/reverse_engineering/helpers/fetchIntrospectionSchema.js +++ b/reverse_engineering/helpers/fetchIntrospectionSchema.js @@ -1,6 +1,6 @@ /** - * @import { ConnectionSettings } from '../../types/types'; - * @import { IntrospectionQuery } from 'graphql'; + * @import {ConnectionSettings, AuthenticationType, Logger} from '../../shared/types/types'; + * @import {IntrospectionQuery} from 'graphql'; */ const { getIntrospectionQuery } = require('graphql'); @@ -8,20 +8,24 @@ const { hckFetch } = require('@hackolade/fetch'); /** * Encode credentials to base64 for base authorization purposes - * @param {string} userName - * @param {string} userPassword + * + * @param {string} [userName] + * @param {string} [userPassword] * @returns {string} */ -function encodeCredentials(userName, userPassword) { +function encodeCredentials(userName = '', userPassword = '') { return Buffer.from(`${userName}:${userPassword}`).toString('base64'); } /** * Build request headers for the fetch request - * @param {AuthenticationType} authType - * @param {string} [bearerToken] - * @param {string} [userName] - * @param {string} [userPassword] + * + * @param {object} params + * @param {AuthenticationType} params.authType + * @param {string} [params.bearerToken] + * @param {string} [params.userName] + * @param {string} [params.userPassword] + * @returns {Record} */ function buildRequestHeaders({ authType, bearerToken, userName, userPassword }) { const headers = { @@ -39,8 +43,10 @@ function buildRequestHeaders({ authType, bearerToken, userName, userPassword }) /** * Fetch introspection schema from the GraphQL server - * @param {ConnectionSettings} connectionInfo - * @param {Logger} logger + * + * @param {object} params + * @param {ConnectionSettings} params.connectionInfo + * @param {Logger} params.logger * @returns {Promise} */ async function fetchIntrospectionSchema({ connectionInfo, logger }) { diff --git a/reverse_engineering/helpers/findNodesByKind.js b/reverse_engineering/helpers/findNodesByKind.js index 0cd7ce3..a57e58b 100644 --- a/reverse_engineering/helpers/findNodesByKind.js +++ b/reverse_engineering/helpers/findNodesByKind.js @@ -1,19 +1,22 @@ /** - * @import { DocumentNode, Kind } from "graphql" + * @import {Kind, ASTNode, ASTKindToNode} from "graphql" */ /** - * Find nodes by kind - * @param {Object} options - * @param {Kind} options.kind - The kind of node to find - * @param {DocumentNode[]} options.nodes - The nodes to search - * @returns {DocumentNode[]} The found nodes + * Find nodes by kind with proper typing + * + * @template {Kind} K + * @param {object} options + * @param {K} options.kind - The kind of node to find + * @param {ASTNode[]} options.nodes - The nodes to search + * @returns {ASTKindToNode[K][]} The found nodes with proper type */ function findNodesByKind({ kind, nodes }) { if (!nodes || !Array.isArray(nodes)) { return []; } - return nodes.filter(node => node.kind === kind); + + return /** @type {ASTKindToNode[K][]} */ (nodes.filter(node => node.kind === kind)); } module.exports = { diff --git a/reverse_engineering/helpers/parseSchema.js b/reverse_engineering/helpers/parseSchema.js index 2a9b23a..8b201ff 100644 --- a/reverse_engineering/helpers/parseSchema.js +++ b/reverse_engineering/helpers/parseSchema.js @@ -1,17 +1,19 @@ /** - * @import { DocumentNode, GraphQLError } from "graphql" + * @import {DocumentNode, GraphQLError} from "graphql" */ const { parse } = require('graphql'); /** * Parses GraphQL schema content into AST and validates it - * @param {Object} params + * + * @param {object} params * @param {string} params.schemaContent - The GraphQL schema content to parse * @returns {{ - * parsedSchema: DocumentNode, - * validationErrors: GraphQLError[] - * }} The parsing result object containing parsed schema and validation errors + * parsedSchema: DocumentNode; + * validationErrors: GraphQLError[]; + * }} The parsing result object containing + * parsed schema and validation errors * @throws {GraphQLError} Throws if schema content cannot be parsed */ function parseSchema({ schemaContent }) { diff --git a/reverse_engineering/helpers/readFileContent.js b/reverse_engineering/helpers/readFileContent.js index fceb114..b829ebf 100644 --- a/reverse_engineering/helpers/readFileContent.js +++ b/reverse_engineering/helpers/readFileContent.js @@ -1,5 +1,12 @@ const fs = require('fs').promises; +/** + * Reads the content of a file + * + * @param {object} params + * @param {string} params.filePath + * @returns {Promise} + */ const readFileContent = async ({ filePath }) => { try { if (!filePath) { @@ -7,9 +14,10 @@ const readFileContent = async ({ filePath }) => { } const content = await fs.readFile(filePath, 'utf8'); - return content; + return content.toString(); } catch (error) { - throw new Error(`Failed to read GraphQL schema file: ${error.message}`); + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Failed to read GraphQL schema file: ${errorMessage}`); } }; diff --git a/reverse_engineering/helpers/sortByName.js b/reverse_engineering/helpers/sortByName.js index ef3b81e..1abe67b 100644 --- a/reverse_engineering/helpers/sortByName.js +++ b/reverse_engineering/helpers/sortByName.js @@ -1,13 +1,14 @@ /** - * @import { FieldsOrder } from "../types/types" + * @import {FieldsOrder} from "../../shared/types/types" */ /** * Sorts an array of objects by the name according to the fields order option - * @param {Object} params - * @param {Object[]} params.items - The items to sort + * + * @param {object} params + * @param {object[]} params.items - The items to sort * @param {FieldsOrder} params.fieldsOrder - The fields order - * @returns {Object[]} The sorted items + * @returns {object[]} The sorted items */ function sortByName({ items, fieldsOrder }) { if (!Array.isArray(items)) { diff --git a/reverse_engineering/mappers/directiveName.js b/reverse_engineering/mappers/directiveName.js index 8b53b1e..6f3b02a 100644 --- a/reverse_engineering/mappers/directiveName.js +++ b/reverse_engineering/mappers/directiveName.js @@ -1,6 +1,6 @@ /** - * @param {Object} params - * @param {String} params.name + * @param {object} params + * @param {string} params.name * @returns {string} The directive name with "@" prefix */ function getDirectiveName({ name }) { diff --git a/reverse_engineering/mappers/directiveUsage.js b/reverse_engineering/mappers/directiveUsage.js index 021e33c..180d7d0 100644 --- a/reverse_engineering/mappers/directiveUsage.js +++ b/reverse_engineering/mappers/directiveUsage.js @@ -1,16 +1,17 @@ +/** + * @import {DirectiveNode, ArgumentNode, ValueNode} from "graphql" + * @import {DirectiveUsage} from "../../shared/types/types" + */ + const { astNodeKind } = require('../constants/graphqlAST'); const { DIRECTIVE_FORMAT, ARGUMENT_VALUE_FORMAT } = require('../constants/properties'); const { getDirectiveName } = require('./directiveName'); -/** - * @import { DirectiveNode, ArgumentNode, ValueNode } from "graphql" - * @import { DirectiveUsage } from "../types/types" - */ - /** * Maps the directives usage - * @param {Object} params - * @param {DirectiveNode[]} params.directives - The directives + * + * @param {object} params + * @param {DirectiveNode[]} [params.directives] - The directives * @returns {DirectiveUsage[]} The mapped directives usage */ function mapDirectivesUsage({ directives = [] }) { @@ -19,15 +20,16 @@ function mapDirectivesUsage({ directives = [] }) { directiveFormat: DIRECTIVE_FORMAT.structured, directiveName: getDirectiveName({ name: directive.name.value }), argumentValueFormat: ARGUMENT_VALUE_FORMAT.raw, - rawArgumentValues: getRawArguments({ argumentNodes: directive.arguments }), + rawArgumentValues: getRawArguments({ argumentNodes: [...(directive.arguments || [])] }), }; }); } /** * Gets the raw arguments - * @param {Object} params - * @param {ArgumentNode[]} params.argumentNodes - The arguments + * + * @param {object} params + * @param {ArgumentNode[]} [params.argumentNodes] - The arguments * @returns {string} The raw arguments */ function getRawArguments({ argumentNodes = [] }) { @@ -36,6 +38,7 @@ function getRawArguments({ argumentNodes = [] }) { /** * Gets the string representation of an argument value + * * @param {ValueNode} value - The value node * @returns {string} The string representation of the value */ diff --git a/reverse_engineering/mappers/rootSchemaTypes.js b/reverse_engineering/mappers/rootSchemaTypes.js index 899ea69..4daf951 100644 --- a/reverse_engineering/mappers/rootSchemaTypes.js +++ b/reverse_engineering/mappers/rootSchemaTypes.js @@ -1,6 +1,6 @@ /** - * @import { SchemaDefinitionNode, OperationTypeDefinitionNode } from "graphql" - * @import { ContainerInfo, ContainerSchemaRootTypes } from "../types/types" + * @import {SchemaDefinitionNode, OperationTypeDefinitionNode} from "graphql" + * @import {ContainerInfo, ContainerSchemaRootTypes} from "../../shared/types/types" */ const { OperationTypeNode } = require('graphql'); @@ -10,7 +10,8 @@ const { mapDirectivesUsage } = require('./directiveUsage'); /** * Maps the root schema types to a container - * @param {Object} params + * + * @param {object} params * @param {SchemaDefinitionNode} params.rootSchemaNode - The root schema node * @param {string} params.graphName - The name of the graph * @returns {ContainerInfo} The mapped container @@ -23,14 +24,15 @@ function mapRootSchemaTypesToContainer({ rootSchemaNode, graphName = 'New Graph' return { name: graphName, description: mapStringValueNode({ node: rootSchemaNode.description }), - schemaRootTypes: mapSchemaRootTypes({ schemaRootTypes: rootSchemaNode.operationTypes }), - graphDirectives: mapDirectivesUsage({ directives: rootSchemaNode.directives }), + schemaRootTypes: mapSchemaRootTypes({ schemaRootTypes: [...rootSchemaNode.operationTypes] }), + graphDirectives: mapDirectivesUsage({ directives: [...(rootSchemaNode.directives || [])] }), }; } /** * Maps the schema root types - * @param {Object} params + * + * @param {object} params * @param {OperationTypeDefinitionNode[]} params.schemaRootTypes - The schema root types * @returns {ContainerSchemaRootTypes} The mapped schema root types */ diff --git a/reverse_engineering/mappers/schema.js b/reverse_engineering/mappers/schema.js index d0471a3..1d9989d 100644 --- a/reverse_engineering/mappers/schema.js +++ b/reverse_engineering/mappers/schema.js @@ -1,6 +1,6 @@ /** - * @import { DocumentNode } from "graphql" - * @import { Logger, FileREEntityResponseData, FieldsOrder } from "../types/types" + * @import {DefinitionNode} from "graphql" + * @import {Logger, FileREEntityResponseData, FieldsOrder} from "../../shared/types/types" */ const { Kind } = require('graphql'); @@ -10,8 +10,9 @@ const { getTypeDefinitions } = require('./typeDefinitions/typeDefinitions'); /** * Maps a GraphQL schema to a RE response - * @param {Object} params - * @param {DocumentNode[]} params.schemaItems - The schema items + * + * @param {object} params + * @param {DefinitionNode[]} params.schemaItems - The schema items * @param {string} params.graphName - The name of the graph to be mapped as the container name * @param {Logger} params.logger - The logger * @param {FieldsOrder} params.fieldsOrder - The fields order @@ -46,7 +47,8 @@ function getMappedSchema({ schemaItems, graphName, logger, fieldsOrder }) { ]; } catch (error) { logger.log('error', error, 'Failed to map GraphQL schema'); - throw new Error(`Failed to map GraphQL schema: ${error.message}`); + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Failed to map GraphQL schema: ${errorMessage}`); } } diff --git a/reverse_engineering/mappers/stringValue.js b/reverse_engineering/mappers/stringValue.js index e4e42da..7ea10f2 100644 --- a/reverse_engineering/mappers/stringValue.js +++ b/reverse_engineering/mappers/stringValue.js @@ -1,11 +1,12 @@ /** - * @import { StringValueNode } from "graphql" + * @import {StringValueNode} from "graphql" */ /** * Maps a string value node to a string - * @param {Object} params - * @param {StringValueNode} params.node - The string value node + * + * @param {object} params + * @param {StringValueNode} [params.node] - The string value node * @returns {string} The mapped string */ function mapStringValueNode({ node }) { diff --git a/reverse_engineering/mappers/typeDefinitions/customScalar.js b/reverse_engineering/mappers/typeDefinitions/customScalar.js index 09553df..5e321e6 100644 --- a/reverse_engineering/mappers/typeDefinitions/customScalar.js +++ b/reverse_engineering/mappers/typeDefinitions/customScalar.js @@ -1,13 +1,14 @@ /** - * @import { ScalarTypeDefinitionNode } from "graphql" - * @import { CustomScalarDefinition } from "../../types/types" + * @import {ScalarTypeDefinitionNode} from "graphql" + * @import {CustomScalarDefinition} from "../../../shared/types/types" */ const { mapDirectivesUsage } = require('../directiveUsage'); /** * Maps the custom scalar type definitions - * @param {Object} params + * + * @param {object} params * @param {ScalarTypeDefinitionNode[]} params.customScalars - The custom scalars * @returns {CustomScalarDefinition[]} The mapped custom scalar type definitions */ @@ -17,7 +18,8 @@ function getCustomScalarTypeDefinitions({ customScalars = [] }) { /** * Maps a single custom scalar definition - * @param {Object} params + * + * @param {object} params * @param {ScalarTypeDefinitionNode} params.scalar - The scalar to map * @returns {CustomScalarDefinition} The mapped custom scalar definition */ @@ -26,7 +28,7 @@ function mapCustomScalar({ scalar }) { type: 'scalar', name: scalar.name.value, description: scalar.description?.value || '', - typeDirectives: mapDirectivesUsage({ directives: scalar.directives }), + typeDirectives: mapDirectivesUsage({ directives: [...(scalar.directives || [])] }), }; } diff --git a/reverse_engineering/mappers/typeDefinitions/directive.js b/reverse_engineering/mappers/typeDefinitions/directive.js index 675f139..2c8c618 100644 --- a/reverse_engineering/mappers/typeDefinitions/directive.js +++ b/reverse_engineering/mappers/typeDefinitions/directive.js @@ -1,6 +1,6 @@ /** - * @import { DirectiveDefinitionNode } from "graphql" - * @import { DirectiveDefinition } from "../../types/types" + * @import {DirectiveDefinitionNode} from "graphql" + * @import {DirectiveDefinition} from "../../../shared/types/types" */ const { getDirectiveName } = require('../directiveName'); @@ -25,7 +25,8 @@ const locationMap = { /** * Maps the directive type definitions - * @param {Object} params + * + * @param {object} params * @param {DirectiveDefinitionNode[]} params.directives - The directives * @returns {DirectiveDefinition[]} The mapped directive type definitions */ @@ -35,7 +36,8 @@ function getDirectiveTypeDefinitions({ directives = [] }) { /** * Maps a single directive definition - * @param {Object} params + * + * @param {object} params * @param {DirectiveDefinitionNode} params.directive - The directive to map * @returns {DirectiveDefinition} The mapped directive definition */ diff --git a/reverse_engineering/mappers/typeDefinitions/typeDefinitions.js b/reverse_engineering/mappers/typeDefinitions/typeDefinitions.js index 0d50ab7..46c280f 100644 --- a/reverse_engineering/mappers/typeDefinitions/typeDefinitions.js +++ b/reverse_engineering/mappers/typeDefinitions/typeDefinitions.js @@ -1,19 +1,20 @@ +/** + * @import {DirectiveDefinition, FieldsOrder, CustomScalarDefinition} from "../../../shared/types/types" + */ + const { astNodeKind } = require('../../constants/graphqlAST'); const { findNodesByKind } = require('../../helpers/findNodesByKind'); const { sortByName } = require('../../helpers/sortByName'); const { getCustomScalarTypeDefinitions } = require('./customScalar'); const { getDirectiveTypeDefinitions } = require('./directive'); -/** - * @import { FieldsOrder, DirectiveDefinition, CustomScalarDefinition } from "../../types/types" - */ - /** * Gets the type definitions structure - * @param {Object} params - * @param {Object[]} params.typeDefinitions - The type definitions nodes + * + * @param {object} params + * @param {object[]} params.typeDefinitions - The type definitions nodes * @param {FieldsOrder} params.fieldsOrder - The fields order - * @returns {Object} The mapped type definitions + * @returns {object} The mapped type definitions */ function getTypeDefinitions({ typeDefinitions, fieldsOrder }) { const directives = getDirectiveTypeDefinitions({ @@ -30,11 +31,12 @@ function getTypeDefinitions({ typeDefinitions, fieldsOrder }) { /** * Creates the model definitions structure - * @param {Object} params + * + * @param {object} params * @param {FieldsOrder} params.fieldsOrder - The fields order * @param {DirectiveDefinition[]} params.directives - The directive definitions * @param {CustomScalarDefinition[]} params.customScalars - The custom scalar definitions - * @returns {Object} The type definitions structure + * @returns {object} The type definitions structure */ function getTypeDefinitionsStructure({ fieldsOrder, directives, customScalars }) { const definitions = { @@ -57,11 +59,12 @@ function getTypeDefinitionsStructure({ fieldsOrder, directives, customScalars }) /** * Creates a definition category structure - * @param {Object} params + * + * @param {object} params * @param {FieldsOrder} params.fieldsOrder - The fields order * @param {string} params.subtype - The subtype of the definition - * @param {Object[]} params.properties - The properties to structure - * @returns {Object} The definition category structure + * @param {object[]} params.properties - The properties to structure + * @returns {object} The definition category structure */ function getDefinitionCategoryStructure({ fieldsOrder, subtype, properties }) { const sortedFields = sortByName({ items: properties, fieldsOrder }); diff --git a/forward_engineering/types/types.d.ts b/shared/types/fe.d.ts similarity index 90% rename from forward_engineering/types/types.d.ts rename to shared/types/fe.d.ts index d5dbe64..696f183 100644 --- a/forward_engineering/types/types.d.ts +++ b/shared/types/fe.d.ts @@ -1,3 +1,5 @@ +import { DirectiveLocations } from './shared'; + export type FEStatement = { statement: string; description?: string; @@ -21,7 +23,7 @@ export type ObjectLikeTypeDefinition = { implementsInterfaces?: ImplementsInterface[]; // Interfaces that the object type implements typeDirectives?: DirectivePropertyData[]; // Directives for the type properties: Record; // Properties of the object type -} +}; // Field data type export type FieldData = RegularFieldData | ReferenceFieldData; @@ -34,7 +36,7 @@ type RegularFieldData = { items?: ArrayItem | ArrayItem[]; // Items of the List type arguments?: Argument[]; // Arguments of the field default?: unknown; // Default value of the field -} +}; type ReferenceFieldData = { $ref: string; // Reference path to the type definition @@ -43,7 +45,7 @@ type ReferenceFieldData = { fieldDirectives?: DirectivePropertyData[]; // Directives for the field arguments?: Argument[]; // Arguments of the field default?: unknown; // Default value of the reference -} +}; export type ArrayItem = FieldData & { required?: boolean; // If the array item is required @@ -53,7 +55,7 @@ export type ArrayItem = FieldData & { type ArgumentListItem = { type?: string; required?: boolean; -} +}; export type Argument = { id: string; @@ -66,25 +68,15 @@ export type Argument = { listItems?: ArgumentListItem[]; }; +export type ArgumentsResultStatement = { + argumentsStatement: string; // The formatted arguments string. + argumentsWarningComment: string; // The warning comment if any argument is missing a type. +} + // Directives -export type DirectiveLocations = { +export type FEDirectiveLocations = DirectiveLocations & { GUID: string; - argumentDefinition?: boolean; - enum?: boolean; - enumValue?: boolean; - field?: boolean; - fieldDefinition?: boolean; - inputFieldDefinition?: boolean; - inputObject?: boolean; - interface?: boolean; - mutation?: boolean; - object?: boolean; - query?: boolean; - scalar?: boolean; - schema?: boolean; - subscription?: boolean; - union?: boolean; -} +}; export type Directive = { GUID: string; @@ -95,11 +87,11 @@ export type Directive = { ignore_z_value: boolean; isActivated?: boolean; schemaType: string; - directiveLocations?: DirectiveLocations; + directiveLocations?: FEDirectiveLocations; arguments?: Argument[]; -} +}; -export type DirectiveDefinitions = Record +export type DirectiveDefinitions = Record; export type DirectivePropertyData = { directiveFormat: 'Structured' | 'Raw'; // Format of the directive @@ -125,13 +117,13 @@ type UnionMemberType = { GUID: string; displayName: string; isActivated: boolean; -} +}; type OneOfMeta = { choice: string; index: number; isActivated: boolean; -} +}; export type Union = { type: 'union'; @@ -146,16 +138,16 @@ export type Union = { oneOf_meta: OneOfMeta; schemaType: string; snippet: 'union'; -} +}; -export type UnionDefinitions = Record +export type UnionDefinitions = Record; // Root types export type RootTypeNamesParameter = { query: string; mutation: string; subscription: string; -} +}; export type EntityIdToJsonSchemaMap = Record; export type EntityIdToPropertiesMap = Record; @@ -167,7 +159,7 @@ type ModelDetails = { version: string; dbVendor: string; isLineageEnabled: boolean; -} +}; type LineageSource = { id: string; @@ -176,11 +168,11 @@ type LineageSource = { lineageSourceType: string; lineageSourceFormat: string; lineageFilePathName: string; -} +}; type Lineage = { sources: LineageSource[]; -} +}; export type ContainerDetails = { name: string; @@ -191,7 +183,7 @@ export type ContainerDetails = { businessName?: string; schemaRootTypes: RootTypeNamesParameter; graphDirectives: DirectivePropertyData[]; -} +}; export type ContainerLevelScriptFEData = { modelData: [ModelDetails, Lineage?]; // model level data @@ -204,7 +196,7 @@ export type ContainerLevelScriptFEData = { options: { additionalOptions: object[]; // additional options origin: string; // "ui" if the script is called from the forward engineering tab - } + }; }; export type GenerateContainerLevelScriptCallback = (error: Error | null, script?: string) => void; @@ -214,6 +206,6 @@ export type ValidationResponseItem = { label: string; // The label for the entity, typically indicating the location. title: string; // The title of the entity, typically the error message. context?: string; // The context of the entity, typically additional information. -} +}; export type ValidateScriptCallback = (error: Error | null, validationErrors?: ValidationResponseItem[]) => void; diff --git a/reverse_engineering/types/types.d.ts b/shared/types/re.d.ts similarity index 68% rename from reverse_engineering/types/types.d.ts rename to shared/types/re.d.ts index 442887f..010884d 100644 --- a/reverse_engineering/types/types.d.ts +++ b/shared/types/re.d.ts @@ -1,3 +1,5 @@ +import { DirectiveLocations } from './shared'; + type ContainerName = string; export type ContainerInfo = { @@ -17,13 +19,13 @@ export type FileREEntityResponseData = { jsonSchema: string; // entity JSON Schema objectNames: { collectionName: string; // collection name - } + }; doc: { collectionName: string; // collection name dbName: ContainerName; modelDefinitions: string; // model definitions JSON Schema bucketInfo: ContainerInfo; - } + }; }; export type FileREModelLevelResponseData = { @@ -40,24 +42,30 @@ export type FileREData = { }; }; -export type REFromFileCallback = (err: Error | null, entitiesData: FileREEntityResponseData[], modelData: FileREModelLevelResponseData) => void; +export type REFromFileCallback = ( + err: Error | null | unknown, + entitiesData?: FileREEntityResponseData[], + modelData?: FileREModelLevelResponseData | {}, + relationships?: object[], // no need in context in GraphQL + reType?: string, +) => void; -type ConnectionSourceType = 'database' | 'dataDictionary' | 'cloud' +type ConnectionSourceType = 'database' | 'dataDictionary' | 'cloud'; -export type AuthenticationType = 'none' | 'basic' | 'bearer' +export type AuthenticationType = 'none' | 'basic' | 'bearer'; -type RecordSamplingMode = 'absolute' | 'relative' +type RecordSamplingMode = 'absolute' | 'relative'; type RecordSamplingModeOptions = { - value: number -} + value: number; +}; type RecordSamplingSettings = { absolute: RecordSamplingModeOptions; relative: RecordSamplingModeOptions; active: RecordSamplingMode; maxValue: number; -} +}; export type ConnectionSettings = { id: string; @@ -69,7 +77,7 @@ export type ConnectionSettings = { userName?: string; userPassword?: string; target: 'GraphQL'; -} +}; type GeneralRESettings = { appVersion?: string; @@ -90,60 +98,40 @@ type GeneralRESettings = { probabilisticSchema?: boolean; fieldInference: { active: string; - } -} + }; +}; type PaginationSettings = { enabled: boolean; value: number; -} +}; export type TestConnectionInfo = ConnectionSettings & GeneralRESettings; export type REConnectionInfo = GeneralRESettings & { connectionSettings: ConnectionSettings; }; -export type REFromFileCallback = (err: Error | null, entitiesData: FileREEntityResponseData[], modelData: FileREModelLevelResponseData) => void; - export type DirectiveUsage = { - directiveFormat: 'Structured'; + directiveFormat: string; directiveName: string; - argumentValueFormat: 'Raw'; + argumentValueFormat: string; rawArgumentValues: string; }; -export type DirectiveLocations = { - schema: boolean; - query: boolean; - mutation: boolean; - subscription: boolean; - scalar: boolean; - enum: boolean; - enumValue: boolean; - object: boolean; - interface: boolean; - union: boolean; - inputObject: boolean; - field: boolean; - fieldDefinition: boolean; - inputFieldDefinition: boolean; - argumentDefinition: boolean; -}; - export type DirectiveDefinition = { type: 'directive'; - name: string; - description?: string; - arguments?: Object[]; // TODO: update when arguments are ready - directiveLocations: DirectiveLocations; -} + name: string; + description?: string; + arguments?: Object[]; // TODO: update when arguments are ready + directiveLocations: DirectiveLocations; +}; export type CustomScalarDefinition = { type: 'scalar'; - name: string; - description?: string; - typeDirectives?: DirectiveUsage[]; + name: string; + description?: string; + typeDirectives?: DirectiveUsage[]; } -export type TestConnectionCallback = (err: Error | null) => void; +export type TestConnectionCallback = (err?: Error | unknown) => void; export type DisconnectCallback = TestConnectionCallback; diff --git a/shared/types/shared.d.ts b/shared/types/shared.d.ts new file mode 100644 index 0000000..bf1cf33 --- /dev/null +++ b/shared/types/shared.d.ts @@ -0,0 +1,35 @@ +type LogType = 'info' | 'error'; + +type LogData = + | { + message?: string; + error?: Error; + } + | Error + | unknown; + +type LogTitle = string; + +export type Logger = { + log: (logType: LogType, logData: LogData, logTitle: LogTitle, hiddenKeys?: string[]) => void; + clear: () => void; + progress: (data: object) => void; +}; + +export type DirectiveLocations = { + argumentDefinition?: boolean; + enum?: boolean; + enumValue?: boolean; + field?: boolean; + fieldDefinition?: boolean; + inputFieldDefinition?: boolean; + inputObject?: boolean; + interface?: boolean; + mutation?: boolean; + object?: boolean; + query?: boolean; + scalar?: boolean; + schema?: boolean; + subscription?: boolean; + union?: boolean; +}; diff --git a/shared/types/types.d.ts b/shared/types/types.d.ts index ea47b6c..b1b88a7 100644 --- a/shared/types/types.d.ts +++ b/shared/types/types.d.ts @@ -1,14 +1,3 @@ -type LogType = 'info' | 'error'; - -type LogData = { - message?: string; - error?: Error; -} | Error; - -type LogTitle = string; - -export type Logger = { - log: (logType: LogType, logData: LogData, logTitle: LogTitle, hiddenKeys: string[]) => void; - clear: () => void; - progress: (data: object) => void; -}; +export type * from './shared.d.ts'; +export type * from './fe.d.ts'; +export type * from './re.d.ts'; diff --git a/snippets/union.json b/snippets/union.json index c5780fe..cc3a2c5 100644 --- a/snippets/union.json +++ b/snippets/union.json @@ -8,4 +8,4 @@ "choice": "oneOf" } ] -} \ No newline at end of file +} diff --git a/test/forward_engineering/mappers/fields.spec.js b/test/forward_engineering/mappers/fields.spec.js index edc5ff1..cfdb341 100644 --- a/test/forward_engineering/mappers/fields.spec.js +++ b/test/forward_engineering/mappers/fields.spec.js @@ -12,7 +12,7 @@ mock.module('../../../forward_engineering/helpers/feStatementJoinHelper', { joinInlineStatements: joinInlineStatementsMock, }, }); -mock.module('../../../forward_engineering/helpers/referencesHelper', { +mock.module('../../../forward_engineering/helpers/referenceHelper', { namedExports: { getDefinitionNameFromReferencePath: getDefinitionNameFromReferencePathMock, }, diff --git a/test/forward_engineering/mappers/objectLikeType.spec.js b/test/forward_engineering/mappers/objectLikeType.spec.js index d004ec6..4d19a84 100644 --- a/test/forward_engineering/mappers/objectLikeType.spec.js +++ b/test/forward_engineering/mappers/objectLikeType.spec.js @@ -56,6 +56,7 @@ describe('getObjectLikeTypes', () => { objectTypes, definitionsIdToNameMap, typeKeyword: 'type', + // eslint-disable-next-line jsdoc/require-jsdoc getFieldsFunction: ({ fields, requiredFields }) => Object.entries(fields).map(([name, fieldData]) => ({ statement: `${name}: ${fieldData.type}${requiredFields.includes(name) ? '!' : ''}`, @@ -98,6 +99,7 @@ describe('getObjectLikeTypes', () => { objectTypes: interfaceTypes, definitionsIdToNameMap, typeKeyword: 'interface', + // eslint-disable-next-line jsdoc/require-jsdoc getFieldsFunction: ({ fields, requiredFields }) => Object.entries(fields).map(([name, fieldData]) => ({ statement: `${name}: ${fieldData.type}${requiredFields.includes(name) ? '!' : ''}`, @@ -137,6 +139,7 @@ describe('getObjectLikeTypes', () => { objectTypes: inputTypes, definitionsIdToNameMap, typeKeyword: 'input', + // eslint-disable-next-line jsdoc/require-jsdoc getFieldsFunction: ({ fields, requiredFields }) => Object.entries(fields).map(([name, fieldData]) => ({ statement: `${name}: ${fieldData.type}${requiredFields.includes(name) ? '!' : ''}`, diff --git a/test/reverse_engineering/mappers/typeDefinitions/customScalars.spec.js b/test/reverse_engineering/mappers/typeDefinitions/customScalars.spec.js index 6bc67b0..c2f2dc3 100644 --- a/test/reverse_engineering/mappers/typeDefinitions/customScalars.spec.js +++ b/test/reverse_engineering/mappers/typeDefinitions/customScalars.spec.js @@ -149,6 +149,6 @@ describe('getCustomScalarTypeDefinitions', () => { const result = getCustomScalarTypeDefinitions({ customScalars: [mockScalar] }); assert.deepStrictEqual(result, expected); assert.strictEqual(mapDirectivesUsageMock.mock.calls.length, 1); - assert.strictEqual(mapDirectivesUsageMock.mock.calls[0].arguments[0].directives, undefined); + assert.deepStrictEqual(mapDirectivesUsageMock.mock.calls[0].arguments[0].directives, []); }); }); diff --git a/tsconfig.json b/tsconfig.json index c5275b0..8f67252 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "baseUrl": ".", "outDir": "./tscDist", "allowJs": true, - "checkJs": false, + "checkJs": true, "target": "ES2016", "lib": ["ESNext", "DOM"], "sourceMap": true, @@ -11,11 +11,11 @@ "moduleResolution": "node", "experimentalDecorators": true, "noUnusedParameters": true, - "noUnusedLocals": true, + "noUnusedLocals": false, "noImplicitThis": true, "noImplicitAny": false, "alwaysStrict": true, - "skipLibCheck": true, + "skipLibCheck": false, "module": "ESNext", "strict": true, "useUnknownInCatchVariables": true, @@ -24,7 +24,8 @@ "resolveJsonModule": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "typeRoots": ["./node_modules/@types", "./types"] + "typeRoots": ["./node_modules/@types", "./shared"], + "types": ["node"] }, "include": ["reverse_engineering", "forward_engineering"], "exclude": ["**/node_modules/**", "release/**/*"] diff --git a/types/Boolean.json b/types/Boolean.json index ea311ed..25f76ee 100644 --- a/types/Boolean.json +++ b/types/Boolean.json @@ -16,4 +16,4 @@ "sample": "", "nullable": false } -} \ No newline at end of file +} diff --git a/types/List.json b/types/List.json index a9797fd..710c2be 100644 --- a/types/List.json +++ b/types/List.json @@ -16,38 +16,12 @@ }, "subtypes": { "outputList": { - "childValueType": [ - "String", - "ID", - "Int", - "Float", - "Boolean", - "List", - "reference" - ], - "childReferenceValueType": [ - "object", - "interface", - "union", - "enum", - "scalar" - ] + "childValueType": ["String", "ID", "Int", "Float", "Boolean", "List", "reference"], + "childReferenceValueType": ["object", "interface", "union", "enum", "scalar"] }, "inputList": { - "childValueType": [ - "String", - "ID", - "Int", - "Float", - "Boolean", - "List", - "reference" - ], - "childReferenceValueType": [ - "input", - "enum", - "scalar" - ] + "childValueType": ["String", "ID", "Int", "Float", "Boolean", "List", "reference"], + "childReferenceValueType": ["input", "enum", "scalar"] } } } diff --git a/types/input.json b/types/input.json index 78f89fc..2aace55 100644 --- a/types/input.json +++ b/types/input.json @@ -19,20 +19,8 @@ }, "subtypes": { "snippetChildrenOnly": { - "childValueType": [ - "String", - "ID", - "Int", - "Float", - "Boolean", - "List", - "reference" - ], - "childReferenceValueType": [ - "input", - "enum", - "scalar" - ] + "childValueType": ["String", "ID", "Int", "Float", "Boolean", "List", "reference"], + "childReferenceValueType": ["input", "enum", "scalar"] } } } diff --git a/types/interface.json b/types/interface.json index ad8e6f6..cb51fbc 100644 --- a/types/interface.json +++ b/types/interface.json @@ -19,22 +19,8 @@ }, "subtypes": { "snippetChildrenOnly": { - "childValueType": [ - "String", - "ID", - "Int", - "Float", - "Boolean", - "List", - "reference" - ], - "childReferenceValueType": [ - "object", - "interface", - "union", - "enum", - "scalar" - ] + "childValueType": ["String", "ID", "Int", "Float", "Boolean", "List", "reference"], + "childReferenceValueType": ["object", "interface", "union", "enum", "scalar"] } } } diff --git a/types/object.json b/types/object.json index 6890db6..9bf4dce 100644 --- a/types/object.json +++ b/types/object.json @@ -19,22 +19,8 @@ }, "subtypes": { "snippetChildrenOnly": { - "childValueType": [ - "String", - "ID", - "Int", - "Float", - "Boolean", - "List", - "reference" - ], - "childReferenceValueType": [ - "object", - "interface", - "union", - "enum", - "scalar" - ] + "childValueType": ["String", "ID", "Int", "Float", "Boolean", "List", "reference"], + "childReferenceValueType": ["object", "interface", "union", "enum", "scalar"] } } } diff --git a/types/type.json b/types/type.json index ad583ca..1d5360d 100644 --- a/types/type.json +++ b/types/type.json @@ -31,46 +31,28 @@ "childValueType": {} }, "scalar": { - "childValueType": [ - "scalar" - ] + "childValueType": ["scalar"] }, "enum": { - "childValueType": [ - "enum" - ] + "childValueType": ["enum"] }, "object": { - "childValueType": [ - "object" - ] + "childValueType": ["object"] }, "interface": { - "childValueType": [ - "interface" - ] + "childValueType": ["interface"] }, "union": { - "childValueType": [ - "union" - ] + "childValueType": ["union"] }, "input": { - "childValueType": [ - "input" - ] + "childValueType": ["input"] }, "extend": { - "childValueType": [ - "object", - "interface", - "input" - ] + "childValueType": ["object", "interface", "input"] }, "directive": { - "childValueType": [ - "directive" - ] + "childValueType": ["directive"] } } } diff --git a/types/union.json b/types/union.json index bc00b14..e791231 100644 --- a/types/union.json +++ b/types/union.json @@ -20,12 +20,8 @@ }, "subtypes": { "snippetChildrenOnly": { - "childValueType": [ - "reference" - ], - "childReferenceValueType": [ - "object" - ] + "childValueType": ["reference"], + "childReferenceValueType": ["object"] } } }