mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Instead of relying on the schema, we choose to use the Tooljet version as the determining factor for decoupling import flows
This commit is contained in:
parent
1936cc81c1
commit
b74e1b69b5
8 changed files with 48 additions and 14 deletions
2
.version
2
.version
|
|
@ -1 +1 @@
|
|||
2.22.0
|
||||
2.22.1
|
||||
|
|
@ -1 +1 @@
|
|||
2.22.0
|
||||
2.22.1
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.22.0
|
||||
2.22.1
|
||||
12
server/package-lock.json
generated
12
server/package-lock.json
generated
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<App> {
|
||||
async import(
|
||||
user: User,
|
||||
appParamsObj: any,
|
||||
appName: string,
|
||||
externalResourceMappings = {},
|
||||
tooljetVersion = ''
|
||||
): Promise<App> {
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ export class ImportExportResourcesService {
|
|||
appImportDto.appName,
|
||||
{
|
||||
tooljet_database: tableNameMapping,
|
||||
}
|
||||
},
|
||||
importResourcesDto.tooljet_version
|
||||
);
|
||||
imports.app.push({ id: createdApp.id, name: createdApp.name });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue