diff --git a/.version b/.version index f48f82fa2c..b534a7f2c4 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.22.0 +2.22.1 \ No newline at end of file diff --git a/frontend/.version b/frontend/.version index f48f82fa2c..d93847fab5 100644 --- a/frontend/.version +++ b/frontend/.version @@ -1 +1 @@ -2.22.0 +2.22.1 diff --git a/server/.version b/server/.version index f48f82fa2c..b534a7f2c4 100644 --- a/server/.version +++ b/server/.version @@ -1 +1 @@ -2.22.0 +2.22.1 \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index 9b6d518c17..9c849e112f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -55,7 +55,7 @@ "request-ip": "^3.3.0", "rxjs": "^7.2.0", "sanitize-html": "^2.7.0", - "semver": "^7.3.5", + "semver": "^7.5.4", "ts-node": "^10.0.0", "tsconfig-paths": "^3.10.1", "typeorm": "^0.2.38", @@ -11858,8 +11858,9 @@ } }, "node_modules/semver": { - "version": "7.3.5", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -22603,8 +22604,9 @@ } }, "semver": { - "version": "7.3.5", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" } diff --git a/server/package.json b/server/package.json index 327c6c4b02..7b977b5f82 100644 --- a/server/package.json +++ b/server/package.json @@ -80,7 +80,7 @@ "request-ip": "^3.3.0", "rxjs": "^7.2.0", "sanitize-html": "^2.7.0", - "semver": "^7.3.5", + "semver": "^7.5.4", "ts-node": "^10.0.0", "tsconfig-paths": "^3.10.1", "typeorm": "^0.2.38", diff --git a/server/src/helpers/utils.helper.ts b/server/src/helpers/utils.helper.ts index 1796ae8b13..988e55fa35 100644 --- a/server/src/helpers/utils.helper.ts +++ b/server/src/helpers/utils.helper.ts @@ -5,6 +5,7 @@ import { isEmpty } from 'lodash'; import { ConflictException } from '@nestjs/common'; import { DataBaseConstraints } from './db_constraints.constants'; const protobuf = require('protobufjs'); +const semver = require('semver'); export function maybeSetSubPath(path) { const hasSubPath = process.env.SUB_PATH !== undefined; @@ -216,3 +217,21 @@ export const generateOrgInviteURL = (organizationToken: string, organizationId?: organizationId ? `?oid=${organizationId}` : '' }`; }; + +export function extractMajorVersion(version) { + return semver.valid(semver.coerce(version)); +} + +/** + * Checks if a given Tooljet version is compatible with normalized app definition schemas. + * + * This function uses the 'semver' library to compare the provided version with a minimum version requirement + * for normalized app definition schemas (2.22.1). It returns true if the version is greater than or equal to + * the required version, indicating compatibility. + * + * @param {string} version - The Tooljet version to check. + * @returns {boolean} - True if the version is compatible, false otherwise. + */ +export function isTooljetVersionWithNormalizedAppDefinitionSchem(version) { + return semver.satisfies(semver.coerce(version), '>= 2.22.1'); +} diff --git a/server/src/services/app_import_export.service.ts b/server/src/services/app_import_export.service.ts index 0d5d38d47d..eef2d1282a 100644 --- a/server/src/services/app_import_export.service.ts +++ b/server/src/services/app_import_export.service.ts @@ -11,7 +11,13 @@ import { GroupPermission } from 'src/entities/group_permission.entity'; import { User } from 'src/entities/user.entity'; import { EntityManager } from 'typeorm'; import { DataSourcesService } from './data_sources.service'; -import { dbTransactionWrap, defaultAppEnvironments, catchDbException } from 'src/helpers/utils.helper'; +import { + dbTransactionWrap, + defaultAppEnvironments, + catchDbException, + extractMajorVersion, + isTooljetVersionWithNormalizedAppDefinitionSchem, +} from 'src/helpers/utils.helper'; import { AppEnvironmentService } from './app_environments.service'; import { convertAppDefinitionFromSinglePageToMultiPage } from '../../lib/single-page-to-and-from-multipage-definition-conversion'; import { DataSourceScopes, DataSourceTypes } from 'src/helpers/data_source.constants'; @@ -181,14 +187,19 @@ export class AppImportExportService { multiPages: true, multiEnv: true, globalDataSources: true, - normalizedAppDefinitionSchema: true, }; return { appV2: appToExport }; }); } - async import(user: User, appParamsObj: any, appName: string, externalResourceMappings = {}): Promise { + async import( + user: User, + appParamsObj: any, + appName: string, + externalResourceMappings = {}, + tooljetVersion = '' + ): Promise { if (typeof appParamsObj !== 'object') { throw new BadRequestException('Invalid params for app import'); } @@ -208,7 +219,8 @@ export class AppImportExportService { : convertSinglePageSchemaToMultiPageSchema(appParams); schemaUnifiedAppParams.name = appName; - const isNormalizedAppDefinitionSchema = appParams?.schemaDetails?.normalizedAppDefinitionSchema; + const importedAppTooljetVersion = extractMajorVersion(tooljetVersion); + const isNormalizedAppDefinitionSchema = isTooljetVersionWithNormalizedAppDefinitionSchem(importedAppTooljetVersion); const importedApp = await this.createImportedAppForUser(this.entityManager, schemaUnifiedAppParams, user); await this.setupImportedAppAssociations( diff --git a/server/src/services/import_export_resources.service.ts b/server/src/services/import_export_resources.service.ts index 30e6740064..3fcc396c24 100644 --- a/server/src/services/import_export_resources.service.ts +++ b/server/src/services/import_export_resources.service.ts @@ -67,7 +67,8 @@ export class ImportExportResourcesService { appImportDto.appName, { tooljet_database: tableNameMapping, - } + }, + importResourcesDto.tooljet_version ); imports.app.push({ id: createdApp.id, name: createdApp.name }); }