mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Resolved comments
This commit is contained in:
parent
9632939bea
commit
abde48b5e0
5 changed files with 23 additions and 21 deletions
|
|
@ -23,7 +23,7 @@ export interface IDataQueriesUtilService {
|
||||||
queryOptions: object,
|
queryOptions: object,
|
||||||
organization_id: string,
|
organization_id: string,
|
||||||
environmentId?: string,
|
environmentId?: string,
|
||||||
userId?: string
|
user?: User
|
||||||
): Promise<{
|
): Promise<{
|
||||||
service: any;
|
service: any;
|
||||||
sourceOptions: object;
|
sourceOptions: object;
|
||||||
|
|
@ -32,5 +32,11 @@ export interface IDataQueriesUtilService {
|
||||||
|
|
||||||
setCookiesBackToClient(response: Response, responseHeaders: any): void;
|
setCookiesBackToClient(response: Response, responseHeaders: any): void;
|
||||||
|
|
||||||
parseQueryOptions(object: any, options: object, organization_id: string, environmentId?: string): Promise<object>;
|
parseQueryOptions(
|
||||||
|
object: any,
|
||||||
|
options: object,
|
||||||
|
organization_id: string,
|
||||||
|
environmentId?: string,
|
||||||
|
user?: User
|
||||||
|
): Promise<object>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
organizationId,
|
organizationId,
|
||||||
environmentId
|
environmentId
|
||||||
);
|
);
|
||||||
const userId = user ? user.id : null;
|
|
||||||
dataSource.options = dataSourceOptions.options;
|
dataSource.options = dataSourceOptions.options;
|
||||||
|
|
||||||
let { sourceOptions, parsedQueryOptions, service } = await this.fetchServiceAndParsedParams(
|
let { sourceOptions, parsedQueryOptions, service } = await this.fetchServiceAndParsedParams(
|
||||||
|
|
@ -91,7 +90,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
queryOptions,
|
queryOptions,
|
||||||
organizationId,
|
organizationId,
|
||||||
environmentId,
|
environmentId,
|
||||||
userId
|
user
|
||||||
);
|
);
|
||||||
|
|
||||||
queryStatus.setOptions(parsedQueryOptions);
|
queryStatus.setOptions(parsedQueryOptions);
|
||||||
|
|
@ -220,7 +219,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
queryOptions,
|
queryOptions,
|
||||||
organizationId,
|
organizationId,
|
||||||
environmentId,
|
environmentId,
|
||||||
userId
|
user
|
||||||
));
|
));
|
||||||
queryStatus.setOptions(parsedQueryOptions);
|
queryStatus.setOptions(parsedQueryOptions);
|
||||||
result = await service.run(
|
result = await service.run(
|
||||||
|
|
@ -300,13 +299,13 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
queryOptions,
|
queryOptions,
|
||||||
organization_id,
|
organization_id,
|
||||||
environmentId = undefined,
|
environmentId = undefined,
|
||||||
userId = undefined
|
user = undefined
|
||||||
) {
|
) {
|
||||||
const sourceOptions = await this.dataSourceUtilService.parseSourceOptions(
|
const sourceOptions = await this.dataSourceUtilService.parseSourceOptions(
|
||||||
dataSource.options,
|
dataSource.options,
|
||||||
organization_id,
|
organization_id,
|
||||||
environmentId,
|
environmentId,
|
||||||
userId
|
user
|
||||||
);
|
);
|
||||||
|
|
||||||
const parsedQueryOptions = await this.parseQueryOptions(
|
const parsedQueryOptions = await this.parseQueryOptions(
|
||||||
|
|
@ -314,7 +313,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
queryOptions,
|
queryOptions,
|
||||||
organization_id,
|
organization_id,
|
||||||
environmentId,
|
environmentId,
|
||||||
userId
|
user
|
||||||
);
|
);
|
||||||
|
|
||||||
const service = await this.pluginsSelectorService.getService(dataSource.pluginId, dataSource.kind);
|
const service = await this.pluginsSelectorService.getService(dataSource.pluginId, dataSource.kind);
|
||||||
|
|
@ -381,7 +380,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
options: object,
|
options: object,
|
||||||
organization_id: string,
|
organization_id: string,
|
||||||
environmentId?: string,
|
environmentId?: string,
|
||||||
userId?: string
|
user?: User
|
||||||
): Promise<object> {
|
): Promise<object> {
|
||||||
const stack: any[] = [{ obj: object, key: null, parent: null }];
|
const stack: any[] = [{ obj: object, key: null, parent: null }];
|
||||||
|
|
||||||
|
|
@ -426,7 +425,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
||||||
resolvedValue,
|
resolvedValue,
|
||||||
organization_id,
|
organization_id,
|
||||||
environmentId,
|
environmentId,
|
||||||
userId
|
user
|
||||||
);
|
);
|
||||||
resolvedValue = resolvingConstant;
|
resolvedValue = resolvingConstant;
|
||||||
if (parent && key !== null) {
|
if (parent && key !== null) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export interface IDataSourcesUtilService {
|
||||||
|
|
||||||
parseOptionsForOauthDataSource(options: Array<object>, resetSecureData?: boolean): Promise<Array<object>>;
|
parseOptionsForOauthDataSource(options: Array<object>, resetSecureData?: boolean): Promise<Array<object>>;
|
||||||
|
|
||||||
resolveConstants(value: string, organizationId: string, environmentId: string, userId?: string): Promise<string>;
|
resolveConstants(value: string, organizationId: string, environmentId: string, user?: User): Promise<string>;
|
||||||
|
|
||||||
resolveKeyValuePair(element: any, organizationId: string, environmentId: string): Promise<any>;
|
resolveKeyValuePair(element: any, organizationId: string, environmentId: string): Promise<any>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { VersionRepository } from '@modules/versions/repository';
|
||||||
import { AppsRepository } from '@modules/apps/repository';
|
import { AppsRepository } from '@modules/apps/repository';
|
||||||
import { TooljetDbModule } from '@modules/tooljet-db/module';
|
import { TooljetDbModule } from '@modules/tooljet-db/module';
|
||||||
import { UsersModule } from '@modules/users/module';
|
import { UsersModule } from '@modules/users/module';
|
||||||
|
import { SessionModule } from '@modules/session/module';
|
||||||
|
|
||||||
export class DataSourcesModule {
|
export class DataSourcesModule {
|
||||||
static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise<DynamicModule> {
|
static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise<DynamicModule> {
|
||||||
|
|
@ -30,6 +31,7 @@ export class DataSourcesModule {
|
||||||
await InstanceSettingsModule.register(configs),
|
await InstanceSettingsModule.register(configs),
|
||||||
await TooljetDbModule.register(configs),
|
await TooljetDbModule.register(configs),
|
||||||
await UsersModule.register(configs),
|
await UsersModule.register(configs),
|
||||||
|
await SessionModule.register(configs),
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DataSourcesService,
|
DataSourcesService,
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolveConstants(str: string, organizationId: string, environmentId: string, userId?: string): Promise<string> {
|
async resolveConstants(str: string, organizationId: string, environmentId: string, user?: User): Promise<string> {
|
||||||
const regex = /\{\{(constants|secrets)\.(.*?)\}\}/g;
|
const regex = /\{\{(constants|secrets)\.(.*?)\}\}/g;
|
||||||
|
|
||||||
const matches = Array.from(str.matchAll(regex));
|
const matches = Array.from(str.matchAll(regex));
|
||||||
|
|
@ -591,12 +591,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseSourceOptions(
|
async parseSourceOptions(options: any, organizationId: string, environmentId: string, user?: User): Promise<object> {
|
||||||
options: any,
|
|
||||||
organizationId: string,
|
|
||||||
environmentId: string,
|
|
||||||
userId?: string
|
|
||||||
): Promise<object> {
|
|
||||||
// For adhoc queries such as REST API queries, source options will be null
|
// For adhoc queries such as REST API queries, source options will be null
|
||||||
if (!options) return {};
|
if (!options) return {};
|
||||||
const constantMatcher = /\{\{(constants|secrets|globals.server)\..*?\}\}/g;
|
const constantMatcher = /\{\{(constants|secrets|globals.server)\..*?\}\}/g;
|
||||||
|
|
@ -615,7 +610,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
||||||
constantMatcher.lastIndex = 0;
|
constantMatcher.lastIndex = 0;
|
||||||
|
|
||||||
if (constantMatcher.test(inner)) {
|
if (constantMatcher.test(inner)) {
|
||||||
const resolved = await this.resolveConstants(inner, organizationId, environmentId, userId);
|
const resolved = await this.resolveConstants(inner, organizationId, environmentId, user);
|
||||||
curr[j] = resolved;
|
curr[j] = resolved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -624,7 +619,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constantMatcher.test(currentOption)) {
|
if (constantMatcher.test(currentOption)) {
|
||||||
const resolved = await this.resolveConstants(currentOption, organizationId, environmentId, userId);
|
const resolved = await this.resolveConstants(currentOption, organizationId, environmentId, user);
|
||||||
options[key]['value'] = resolved;
|
options[key]['value'] = resolved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -639,7 +634,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
||||||
const value = await this.credentialService.getValue(credentialId);
|
const value = await this.credentialService.getValue(credentialId);
|
||||||
|
|
||||||
if (value.includes('{{constants') || value.includes('{{secrets')) {
|
if (value.includes('{{constants') || value.includes('{{secrets')) {
|
||||||
const resolved = await this.resolveConstants(value, organizationId, environmentId, userId);
|
const resolved = await this.resolveConstants(value, organizationId, environmentId, user);
|
||||||
parsedOptions[key] = resolved;
|
parsedOptions[key] = resolved;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue