mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-21 16:08:35 +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,
|
||||
organization_id: string,
|
||||
environmentId?: string,
|
||||
userId?: string
|
||||
user?: User
|
||||
): Promise<{
|
||||
service: any;
|
||||
sourceOptions: object;
|
||||
|
|
@ -32,5 +32,11 @@ export interface IDataQueriesUtilService {
|
|||
|
||||
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,
|
||||
environmentId
|
||||
);
|
||||
const userId = user ? user.id : null;
|
||||
dataSource.options = dataSourceOptions.options;
|
||||
|
||||
let { sourceOptions, parsedQueryOptions, service } = await this.fetchServiceAndParsedParams(
|
||||
|
|
@ -91,7 +90,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
queryOptions,
|
||||
organizationId,
|
||||
environmentId,
|
||||
userId
|
||||
user
|
||||
);
|
||||
|
||||
queryStatus.setOptions(parsedQueryOptions);
|
||||
|
|
@ -220,7 +219,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
queryOptions,
|
||||
organizationId,
|
||||
environmentId,
|
||||
userId
|
||||
user
|
||||
));
|
||||
queryStatus.setOptions(parsedQueryOptions);
|
||||
result = await service.run(
|
||||
|
|
@ -300,13 +299,13 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
queryOptions,
|
||||
organization_id,
|
||||
environmentId = undefined,
|
||||
userId = undefined
|
||||
user = undefined
|
||||
) {
|
||||
const sourceOptions = await this.dataSourceUtilService.parseSourceOptions(
|
||||
dataSource.options,
|
||||
organization_id,
|
||||
environmentId,
|
||||
userId
|
||||
user
|
||||
);
|
||||
|
||||
const parsedQueryOptions = await this.parseQueryOptions(
|
||||
|
|
@ -314,7 +313,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
queryOptions,
|
||||
organization_id,
|
||||
environmentId,
|
||||
userId
|
||||
user
|
||||
);
|
||||
|
||||
const service = await this.pluginsSelectorService.getService(dataSource.pluginId, dataSource.kind);
|
||||
|
|
@ -381,7 +380,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
options: object,
|
||||
organization_id: string,
|
||||
environmentId?: string,
|
||||
userId?: string
|
||||
user?: User
|
||||
): Promise<object> {
|
||||
const stack: any[] = [{ obj: object, key: null, parent: null }];
|
||||
|
||||
|
|
@ -426,7 +425,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
resolvedValue,
|
||||
organization_id,
|
||||
environmentId,
|
||||
userId
|
||||
user
|
||||
);
|
||||
resolvedValue = resolvingConstant;
|
||||
if (parent && key !== null) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export interface IDataSourcesUtilService {
|
|||
|
||||
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>;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { VersionRepository } from '@modules/versions/repository';
|
|||
import { AppsRepository } from '@modules/apps/repository';
|
||||
import { TooljetDbModule } from '@modules/tooljet-db/module';
|
||||
import { UsersModule } from '@modules/users/module';
|
||||
import { SessionModule } from '@modules/session/module';
|
||||
|
||||
export class DataSourcesModule {
|
||||
static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise<DynamicModule> {
|
||||
|
|
@ -30,6 +31,7 @@ export class DataSourcesModule {
|
|||
await InstanceSettingsModule.register(configs),
|
||||
await TooljetDbModule.register(configs),
|
||||
await UsersModule.register(configs),
|
||||
await SessionModule.register(configs),
|
||||
],
|
||||
providers: [
|
||||
DataSourcesService,
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
|||
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 matches = Array.from(str.matchAll(regex));
|
||||
|
|
@ -591,12 +591,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
|||
return options;
|
||||
}
|
||||
|
||||
async parseSourceOptions(
|
||||
options: any,
|
||||
organizationId: string,
|
||||
environmentId: string,
|
||||
userId?: string
|
||||
): Promise<object> {
|
||||
async parseSourceOptions(options: any, organizationId: string, environmentId: string, user?: User): Promise<object> {
|
||||
// For adhoc queries such as REST API queries, source options will be null
|
||||
if (!options) return {};
|
||||
const constantMatcher = /\{\{(constants|secrets|globals.server)\..*?\}\}/g;
|
||||
|
|
@ -615,7 +610,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
|||
constantMatcher.lastIndex = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -624,7 +619,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -639,7 +634,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService {
|
|||
const value = await this.credentialService.getValue(credentialId);
|
||||
|
||||
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;
|
||||
continue;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue