[QRQC_2] No explicit any in twenty-server (#12068)
# Introduction Added a no-explicit-any rule to the twenty-server, not applicable to tests and integration tests folder Related to https://github.com/twentyhq/core-team-issues/issues/975 Discussed with Charles ## In case of conflicts Until this is approved I won't rebased and handle conflict, just need to drop two latest commits and re run the scripts etc ## Legacy We decided not to handle the existing lint error occurrences and programmatically ignored them through a disable next line rule comment ## Open question We might wanna activate the [no-explicit-any](https://typescript-eslint.io/rules/no-explicit-any/) `ignoreRestArgs` for our use case ? ``` ignoreRestArgs?: boolean; ``` --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@ -2,12 +2,15 @@ import { isDefined } from 'class-validator';
|
||||
import { Plugin } from 'graphql-yoga';
|
||||
|
||||
export type CacheMetadataPluginConfig = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
cacheGetter: (key: string) => any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
cacheSetter: (key: string, value: any) => void;
|
||||
operationsToCache: string[];
|
||||
};
|
||||
|
||||
export function useCachedMetadata(config: CacheMetadataPluginConfig): Plugin {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const computeCacheKey = (serverContext: any) => {
|
||||
const workspaceId = serverContext.req.workspace?.id ?? 'anonymous';
|
||||
const workspaceMetadataVersion =
|
||||
@ -21,6 +24,7 @@ export function useCachedMetadata(config: CacheMetadataPluginConfig): Plugin {
|
||||
return `graphql:operations:${operationName}:${workspaceId}:${workspaceMetadataVersion}${localeCacheKey}`;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const getOperationName = (serverContext: any) =>
|
||||
serverContext?.req?.body?.operationName;
|
||||
|
||||
|
||||
@ -29,9 +29,11 @@ export class GraphqlQueryFilterConditionParser {
|
||||
}
|
||||
|
||||
public parse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
queryBuilder: SelectQueryBuilder<any>,
|
||||
objectNameSingular: string,
|
||||
filter: Partial<ObjectRecordFilter>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): SelectQueryBuilder<any> {
|
||||
if (!filter || Object.keys(filter).length === 0) {
|
||||
return queryBuilder;
|
||||
@ -50,6 +52,7 @@ export class GraphqlQueryFilterConditionParser {
|
||||
queryBuilder: WhereExpressionBuilder,
|
||||
objectNameSingular: string,
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
isFirst = false,
|
||||
): void {
|
||||
|
||||
@ -31,6 +31,7 @@ export class GraphqlQueryFilterFieldParser {
|
||||
queryBuilder: WhereExpressionBuilder,
|
||||
objectNameSingular: string,
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
filterValue: any,
|
||||
isFirst = false,
|
||||
): void {
|
||||
@ -81,6 +82,7 @@ export class GraphqlQueryFilterFieldParser {
|
||||
queryBuilder: WhereExpressionBuilder,
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
objectNameSingular: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fieldValue: any,
|
||||
isFirst = false,
|
||||
): void {
|
||||
@ -108,6 +110,7 @@ export class GraphqlQueryFilterFieldParser {
|
||||
const fullFieldName = `${fieldMetadata.name}${capitalize(subFieldKey)}`;
|
||||
|
||||
const [[operator, value]] = Object.entries(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
subFieldFilter as Record<string, any>,
|
||||
);
|
||||
|
||||
|
||||
@ -65,6 +65,7 @@ export class GraphqlQueryOrderFieldParser {
|
||||
|
||||
private parseCompositeFieldForOrder(
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
objectNameSingular: string,
|
||||
isForwardPagination = true,
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
|
||||
export class GraphqlQuerySelectedFieldsAggregateParser {
|
||||
parse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
fieldMetadataMapByName: Record<string, FieldMetadataInterface>,
|
||||
accumulator: GraphqlQuerySelectedFieldsResult,
|
||||
|
||||
@ -17,6 +17,7 @@ export class GraphqlQuerySelectedFieldsRelationParser {
|
||||
parseRelationField(
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
fieldKey: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fieldValue: any,
|
||||
accumulator: GraphqlQuerySelectedFieldsResult,
|
||||
): void {
|
||||
|
||||
@ -11,8 +11,11 @@ import { CompositeFieldMetadataType } from 'src/engine/metadata-modules/workspac
|
||||
import { isRelationFieldMetadataType } from 'src/engine/utils/is-relation-field-metadata-type.util';
|
||||
|
||||
export type GraphqlQuerySelectedFieldsResult = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
select: Record<string, any>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
relations: Record<string, any>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
aggregate: Record<string, any>;
|
||||
};
|
||||
|
||||
@ -27,6 +30,7 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
}
|
||||
|
||||
parse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
fieldMetadataMapByName: Record<string, FieldMetadataInterface>,
|
||||
): GraphqlQuerySelectedFieldsResult {
|
||||
@ -62,6 +66,7 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
}
|
||||
|
||||
private parseRecordField(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
fieldMetadataMapByName: Record<string, FieldMetadataInterface>,
|
||||
accumulator: GraphqlQuerySelectedFieldsResult,
|
||||
@ -96,6 +101,7 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
}
|
||||
|
||||
private parseConnectionField(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
fieldMetadataMapByName: Record<string, FieldMetadataInterface>,
|
||||
accumulator: GraphqlQuerySelectedFieldsResult,
|
||||
@ -112,6 +118,7 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
}
|
||||
|
||||
private isRootConnection(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
): boolean {
|
||||
return Object.keys(graphqlSelectedFields).includes('edges');
|
||||
@ -119,7 +126,9 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
|
||||
private parseCompositeField(
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fieldValue: any,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> {
|
||||
const compositeType = compositeTypeDefinitions.get(
|
||||
fieldMetadata.type as CompositeFieldMetadataType,
|
||||
@ -151,6 +160,7 @@ export class GraphqlQuerySelectedFieldsParser {
|
||||
|
||||
return acc;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
{} as Record<string, any>,
|
||||
);
|
||||
}
|
||||
|
||||
@ -50,9 +50,11 @@ export class GraphqlQueryParser {
|
||||
}
|
||||
|
||||
public applyFilterToBuilder(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
queryBuilder: SelectQueryBuilder<any>,
|
||||
objectNameSingular: string,
|
||||
recordFilter: Partial<ObjectRecordFilter>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): SelectQueryBuilder<any> {
|
||||
return this.filterConditionParser.parse(
|
||||
queryBuilder,
|
||||
@ -62,8 +64,10 @@ export class GraphqlQueryParser {
|
||||
}
|
||||
|
||||
public applyDeletedAtToBuilder(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
queryBuilder: SelectQueryBuilder<any>,
|
||||
recordFilter: Partial<ObjectRecordFilter>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): SelectQueryBuilder<any> {
|
||||
if (this.checkForDeletedAtFilter(recordFilter)) {
|
||||
queryBuilder.withDeleted();
|
||||
@ -99,10 +103,12 @@ export class GraphqlQueryParser {
|
||||
};
|
||||
|
||||
public applyOrderToBuilder(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
queryBuilder: SelectQueryBuilder<any>,
|
||||
orderBy: ObjectRecordOrderBy,
|
||||
objectNameSingular: string,
|
||||
isForwardPagination = true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): SelectQueryBuilder<any> {
|
||||
const parsedOrderBys = this.orderFieldParser.parse(
|
||||
orderBy,
|
||||
@ -115,6 +121,7 @@ export class GraphqlQueryParser {
|
||||
|
||||
public parseSelectedFields(
|
||||
parentObjectMetadata: ObjectMetadataItemWithFieldMaps,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphqlSelectedFields: Partial<Record<string, any>>,
|
||||
): GraphqlQuerySelectedFieldsResult {
|
||||
const parentFields = getObjectMetadataMapItemByNameSingular(
|
||||
|
||||
@ -46,7 +46,9 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
}: {
|
||||
objectRecords: T[];
|
||||
parentObjectRecord?: T;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
objectRecordsAggregatedValues?: Record<string, any>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
selectedAggregatedFields?: Record<string, any>;
|
||||
objectName: string;
|
||||
take: number;
|
||||
@ -95,6 +97,7 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
objectRecordsAggregatedValues,
|
||||
}: {
|
||||
selectedAggregatedFields: Record<string, AggregationField[]>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
objectRecordsAggregatedValues: Record<string, any>;
|
||||
}) => {
|
||||
if (!isDefined(objectRecordsAggregatedValues)) {
|
||||
@ -120,6 +123,7 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public processRecord<T extends Record<string, any>>({
|
||||
objectRecord,
|
||||
objectName,
|
||||
@ -132,7 +136,9 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
}: {
|
||||
objectRecord: T;
|
||||
objectName: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
objectRecordsAggregatedValues?: Record<string, any>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
selectedAggregatedFields?: Record<string, any>;
|
||||
take: number;
|
||||
totalCount: number;
|
||||
@ -158,6 +164,7 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const processedObjectRecord: Record<string, any> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(objectRecord)) {
|
||||
@ -229,7 +236,9 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
|
||||
private processCompositeField(
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fieldValue: any,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> {
|
||||
const compositeType = compositeTypeDefinitions.get(
|
||||
fieldMetadata.type as CompositeFieldMetadataType,
|
||||
@ -262,10 +271,12 @@ export class ObjectRecordsToGraphqlConnectionHelper {
|
||||
|
||||
return acc;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
{} as Record<string, any>,
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private formatFieldValue(value: any, fieldType: FieldMetadataType) {
|
||||
switch (fieldType) {
|
||||
case FieldMetadataType.RAW_JSON:
|
||||
|
||||
@ -14,6 +14,7 @@ export class ProcessAggregateHelper {
|
||||
queryBuilder,
|
||||
}: {
|
||||
selectedAggregatedFields: Record<string, AggregationField>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
queryBuilder: SelectQueryBuilder<any>;
|
||||
}) => {
|
||||
queryBuilder.select([]);
|
||||
|
||||
@ -47,6 +47,7 @@ export class ProcessNestedRelationsV2Helper {
|
||||
objectMetadataMaps: ObjectMetadataMaps;
|
||||
parentObjectMetadataItem: ObjectMetadataItemWithFieldMaps;
|
||||
parentObjectRecords: T[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parentObjectRecordsAggregatedValues?: Record<string, any>;
|
||||
relations: Record<string, FindOptionsRelations<ObjectLiteral>>;
|
||||
aggregate?: Record<string, AggregationField>;
|
||||
@ -94,6 +95,7 @@ export class ProcessNestedRelationsV2Helper {
|
||||
objectMetadataMaps: ObjectMetadataMaps;
|
||||
parentObjectMetadataItem: ObjectMetadataItemWithFieldMaps;
|
||||
parentObjectRecords: T[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parentObjectRecordsAggregatedValues: Record<string, any>;
|
||||
sourceFieldName: string;
|
||||
nestedRelations: FindOptionsRelations<ObjectLiteral>;
|
||||
@ -251,6 +253,7 @@ export class ProcessNestedRelationsV2Helper {
|
||||
}: {
|
||||
records: ObjectRecord[];
|
||||
idField: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}): any[] {
|
||||
return [...new Set(records.map((item) => item[idField]))];
|
||||
}
|
||||
@ -265,20 +268,26 @@ export class ProcessNestedRelationsV2Helper {
|
||||
aggregate,
|
||||
sourceFieldName,
|
||||
}: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
referenceQueryBuilder: SelectQueryBuilder<any>;
|
||||
column: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
ids: any[];
|
||||
limit: number;
|
||||
objectMetadataMaps: ObjectMetadataMaps;
|
||||
targetObjectMetadata: ObjectMetadataItemWithFieldMaps;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
aggregate: Record<string, any>;
|
||||
sourceFieldName: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}): Promise<{ relationResults: any[]; relationAggregatedFieldsResult: any }> {
|
||||
if (ids.length === 0) {
|
||||
return { relationResults: [], relationAggregatedFieldsResult: {} };
|
||||
}
|
||||
|
||||
const aggregateForRelation = aggregate[sourceFieldName];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let relationAggregatedFieldsResult: Record<string, any> = {};
|
||||
|
||||
if (aggregateForRelation) {
|
||||
@ -339,8 +348,11 @@ export class ProcessNestedRelationsV2Helper {
|
||||
relationType,
|
||||
}: {
|
||||
parentRecords: ObjectRecord[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parentObjectRecordsAggregatedValues: Record<string, any>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
relationResults: any[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
relationAggregatedFieldsResult: Record<string, any>;
|
||||
sourceFieldName: string;
|
||||
joinField: string;
|
||||
|
||||
@ -35,6 +35,7 @@ export class ProcessNestedRelationsHelper {
|
||||
objectMetadataMaps: ObjectMetadataMaps;
|
||||
parentObjectMetadataItem: ObjectMetadataItemWithFieldMaps;
|
||||
parentObjectRecords: T[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parentObjectRecordsAggregatedValues?: Record<string, any>;
|
||||
relations: Record<string, FindOptionsRelations<ObjectLiteral>>;
|
||||
aggregate?: Record<string, AggregationField>;
|
||||
|
||||
@ -199,6 +199,7 @@ export class GraphqlQueryCreateManyResolverService extends GraphqlQueryBaseResol
|
||||
fullPath: string;
|
||||
column: string;
|
||||
}[],
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> {
|
||||
const whereConditions = {};
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ export const computeWhereConditionParts = (
|
||||
operator: string,
|
||||
objectNameSingular: string,
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
): WhereConditionParts => {
|
||||
const uuid = Math.random().toString(36).slice(2, 7);
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
} from 'src/engine/api/graphql/graphql-query-runner/errors/graphql-query-runner.exception';
|
||||
|
||||
export interface CursorData {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
@ -28,6 +29,7 @@ export const encodeCursor = <T extends ObjectRecord = ObjectRecord>(
|
||||
objectRecord: T,
|
||||
order: ObjectRecordOrderBy | undefined,
|
||||
): string => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const orderByValues: Record<string, any> = {};
|
||||
|
||||
const orderBy = order?.reduce((acc, orderBy) => ({ ...acc, ...orderBy }), {});
|
||||
@ -47,7 +49,10 @@ export const encodeCursor = <T extends ObjectRecord = ObjectRecord>(
|
||||
};
|
||||
|
||||
export const getCursor = (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
args: FindManyResolverArgs<any, any>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> | undefined => {
|
||||
if (args.after) return decodeCursor(args.after);
|
||||
if (args.before) return decodeCursor(args.before);
|
||||
@ -56,6 +61,7 @@ export const getCursor = (
|
||||
};
|
||||
|
||||
export const getPaginationInfo = (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
objectRecords: any[],
|
||||
limit: number,
|
||||
isForwardPagination: boolean,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
export interface ObjectRecord {
|
||||
id: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[key: string]: any;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@ -7,6 +8,7 @@ export interface ObjectRecord {
|
||||
}
|
||||
|
||||
export type ObjectRecordFilter = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[Property in keyof ObjectRecord]: any;
|
||||
};
|
||||
|
||||
|
||||
@ -74,6 +74,7 @@ const parseValueNode = (
|
||||
export const getFieldArgumentsByKey = (
|
||||
info: GraphQLResolveInfo,
|
||||
fieldKey: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> => {
|
||||
// Start from the first top-level field node and search recursively
|
||||
const targetField = findFieldNode(info.fieldNodes[0].selectionSet, fieldKey);
|
||||
@ -84,6 +85,7 @@ export const getFieldArgumentsByKey = (
|
||||
}
|
||||
|
||||
// Extract the arguments from the field we've found
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const args: Record<string, any> = {};
|
||||
|
||||
if (targetField.arguments && targetField.arguments.length) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const stringifyWithoutKeyQuote = (obj: any) => {
|
||||
const jsonString = JSON.stringify(obj);
|
||||
const jsonWithoutQuotes = jsonString?.replace(/"(\w+)"\s*:/g, '$1:');
|
||||
|
||||
@ -5,6 +5,7 @@ import { FileService } from 'src/engine/core-modules/file/services/file.service'
|
||||
import { NoteWorkspaceEntity } from 'src/modules/note/standard-objects/note.workspace-entity';
|
||||
import { TaskWorkspaceEntity } from 'src/modules/task/standard-objects/task.workspace-entity';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type RichTextBlock = Record<string, any>;
|
||||
|
||||
type RichTextBody = RichTextBlock[];
|
||||
|
||||
@ -233,6 +233,7 @@ export class QueryResultGettersFactory {
|
||||
objectMetadataItem: ObjectMetadataInterface,
|
||||
workspaceId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Promise<any> {
|
||||
return await this.processQueryResultField(
|
||||
result,
|
||||
@ -245,6 +246,7 @@ export class QueryResultGettersFactory {
|
||||
private getHandler(objectType: string): QueryResultGetterHandlerInterface {
|
||||
return (
|
||||
this.handlers.get(objectType) || {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
handle: (result: any) => result,
|
||||
}
|
||||
);
|
||||
|
||||
@ -174,8 +174,10 @@ export class QueryRunnerArgsFactory {
|
||||
const workspaceId = options.authContext.workspace.id;
|
||||
let isFieldPositionPresent = false;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const createArgByArgKeyPromises: Promise<[string, any]>[] = Object.entries(
|
||||
data,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
).map(async ([key, value]): Promise<[string, any]> => {
|
||||
const fieldMetadata = fieldMetadataMapByNameByName[key];
|
||||
|
||||
@ -280,6 +282,7 @@ export class QueryRunnerArgsFactory {
|
||||
|
||||
private transformFilterValueByType(
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
fieldMetadataMapByName: FieldMetadataMap,
|
||||
) {
|
||||
@ -310,6 +313,7 @@ export class QueryRunnerArgsFactory {
|
||||
|
||||
private async overrideValueByFieldMetadata(
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
fieldMetadataMapByName: FieldMetadataMap,
|
||||
) {
|
||||
|
||||
@ -51,6 +51,7 @@ const pgGraphQLErrorMapping: PgGraphQLErrorMapping = {
|
||||
export const computePgGraphQLError = (
|
||||
command: string,
|
||||
objectName: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
errors: any[],
|
||||
pgGraphqlConfig: PgGraphQLConfig,
|
||||
) => {
|
||||
|
||||
@ -4,8 +4,10 @@ import {
|
||||
} from 'src/engine/api/graphql/workspace-query-builder/utils/composite-field-metadata.util';
|
||||
|
||||
export const handleCompositeKey = (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
result: any,
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
): void => {
|
||||
const parsedFieldKey = parseCompositeFieldKey(key);
|
||||
@ -22,6 +24,8 @@ export const handleCompositeKey = (
|
||||
result[parsedFieldKey.parentFieldName][parsedFieldKey.childFieldName] = value;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const parseResult = (obj: any): any => {
|
||||
if (obj === null || typeof obj !== 'object' || typeof obj === 'function') {
|
||||
return obj;
|
||||
@ -31,6 +35,7 @@ export const parseResult = (obj: any): any => {
|
||||
return obj.map((item) => parseResult(item));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const result: any = {};
|
||||
|
||||
for (const key in obj) {
|
||||
|
||||
@ -8,6 +8,9 @@ import {
|
||||
|
||||
import { workspaceResolverBuilderMethodNames } from 'src/engine/api/graphql/workspace-resolver-builder/factories/factories';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type Resolver<Args = any> = GraphQLFieldResolver<any, any, Args>;
|
||||
|
||||
export enum ResolverArgsType {
|
||||
@ -71,6 +74,7 @@ export interface UpdateOneResolverArgs<
|
||||
|
||||
export interface UpdateManyResolverArgs<
|
||||
Data extends Partial<ObjectRecord> = Partial<ObjectRecord>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
Filter = any,
|
||||
> {
|
||||
filter: Filter;
|
||||
@ -81,6 +85,7 @@ export interface DeleteOneResolverArgs {
|
||||
id: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface DeleteManyResolverArgs<Filter = any> {
|
||||
filter: Filter;
|
||||
}
|
||||
@ -89,6 +94,7 @@ export interface RestoreOneResolverArgs {
|
||||
id: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface RestoreManyResolverArgs<Filter = any> {
|
||||
filter: Filter;
|
||||
}
|
||||
@ -97,6 +103,7 @@ export interface DestroyOneResolverArgs {
|
||||
id: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface DestroyManyResolverArgs<Filter = any> {
|
||||
filter: Filter;
|
||||
}
|
||||
|
||||
@ -44,7 +44,11 @@ export class CompositeObjectTypeDefinitionFactory {
|
||||
compositeType: CompositeType,
|
||||
kind: ObjectTypeDefinitionKind,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): GraphQLFieldConfigMap<any, any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
|
||||
for (const property of compositeType.properties) {
|
||||
|
||||
@ -46,7 +46,11 @@ export class ConnectionTypeDefinitionFactory {
|
||||
private generateFields(
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): GraphQLFieldConfigMap<any, any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
|
||||
const aggregatedFields = this.aggregationTypeFactory.create(objectMetadata);
|
||||
|
||||
@ -42,7 +42,11 @@ export class EdgeTypeDefinitionFactory {
|
||||
private generateFields(
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): GraphQLFieldConfigMap<any, any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
|
||||
fields.node = {
|
||||
|
||||
@ -103,7 +103,11 @@ export class ExtendObjectTypeDefinitionV2Factory {
|
||||
private generateFields(
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): GraphQLFieldConfigMap<any, any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
|
||||
for (const fieldMetadata of objectMetadata.fields) {
|
||||
|
||||
@ -104,7 +104,11 @@ export class ExtendObjectTypeDefinitionFactory {
|
||||
private generateFields(
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): GraphQLFieldConfigMap<any, any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
|
||||
for (const fieldMetadata of objectMetadata.fields) {
|
||||
|
||||
@ -63,6 +63,8 @@ export class RootTypeFactory {
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private generateFields<T = any, U = any>(
|
||||
objectMetadataCollection: ObjectMetadataInterface[],
|
||||
workspaceResolverMethodNames: WorkspaceResolverBuilderMethodNames[],
|
||||
|
||||
@ -10,6 +10,7 @@ const isValidStringPosition = (value: string): boolean =>
|
||||
const isValidNumberPosition = (value: number): boolean =>
|
||||
typeof value === 'number';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const checkPosition = (value: any): PositionType => {
|
||||
if (isValidNumberPosition(value) || isValidStringPosition(value)) {
|
||||
return value;
|
||||
|
||||
@ -8,6 +8,7 @@ import { ValidationError } from 'src/engine/core-modules/graphql/utils/graphql-e
|
||||
const parseLiteral = (
|
||||
ast: ValueNode,
|
||||
variables?: Maybe<ObjMap<unknown>>,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): any => {
|
||||
switch (ast.kind) {
|
||||
case Kind.STRING:
|
||||
@ -17,8 +18,10 @@ const parseLiteral = (
|
||||
case Kind.FLOAT:
|
||||
return parseFloat(ast.value);
|
||||
case Kind.OBJECT:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return parseObject(ast as any, variables);
|
||||
case Kind.LIST:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (ast as any).values.map((n: ValueNode) =>
|
||||
parseLiteral(n, variables),
|
||||
);
|
||||
@ -40,6 +43,7 @@ const parseObject = (
|
||||
const value = Object.create(null);
|
||||
|
||||
if ('fields' in ast) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
ast.fields?.forEach((field: any) => {
|
||||
value[field.name.value] = parseLiteral(field.value, variables);
|
||||
});
|
||||
@ -48,6 +52,7 @@ const parseObject = (
|
||||
return value;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const stringify = (value: any): string => {
|
||||
return JSON.stringify(value);
|
||||
};
|
||||
|
||||
@ -3,6 +3,7 @@ import { validate as uuidValidate } from 'uuid';
|
||||
|
||||
import { ValidationError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const checkUUID = (value: any): string => {
|
||||
if (typeof value !== 'string') {
|
||||
throw new ValidationError('UUID must be a string');
|
||||
|
||||
@ -2,6 +2,7 @@ import { GraphQLScalarType } from 'graphql';
|
||||
|
||||
import { InputTypeDefinitionKind } from 'src/engine/api/graphql/workspace-schema-builder/factories/input-type-definition.factory';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface ArgMetadata<T = any> {
|
||||
kind?: InputTypeDefinitionKind;
|
||||
type?: GraphQLScalarType;
|
||||
|
||||
@ -40,6 +40,7 @@ import { RawJSONScalar } from 'src/engine/api/graphql/workspace-schema-builder/g
|
||||
import { getNumberFilterType } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-number-filter-type.util';
|
||||
import { getNumberScalarType } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-number-scalar-type.util';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface TypeOptions<T = any> {
|
||||
nullable?: boolean;
|
||||
isArray?: boolean;
|
||||
|
||||
@ -24,8 +24,10 @@ type TypeFactory<T extends InputTypeDefinitionKind | ObjectTypeDefinitionKind> =
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
additionalOptions: {
|
||||
nullable?: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
defaultValue?: any;
|
||||
isArray: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
settings: any;
|
||||
isIdField: boolean;
|
||||
},
|
||||
@ -43,7 +45,9 @@ export const generateFields = <
|
||||
typeFactory: TypeFactory<T>,
|
||||
): T extends InputTypeDefinitionKind
|
||||
? GraphQLInputFieldConfigMap
|
||||
: GraphQLFieldConfigMap<any, any> => {
|
||||
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
GraphQLFieldConfigMap<any, any> => {
|
||||
const fields = {};
|
||||
|
||||
for (const fieldMetadata of objectMetadata.fields) {
|
||||
|
||||
@ -21,6 +21,7 @@ export class RestApiCreateManyHandler extends RestApiBaseHandler {
|
||||
throw new BadRequestException('Input must not be empty');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const overriddenRecordsToCreate: Record<string, any>[] = [];
|
||||
|
||||
for (const recordToCreate of body) {
|
||||
|
||||
@ -121,6 +121,7 @@ export class RestApiFindDuplicatesHandler extends RestApiBaseHandler {
|
||||
startCursor,
|
||||
endCursor,
|
||||
}: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
finalRecords: any[];
|
||||
objectMetadataNameSingular: string;
|
||||
isForwardPagination: boolean;
|
||||
|
||||
@ -50,6 +50,7 @@ export class RestApiFindManyHandler extends RestApiBaseHandler {
|
||||
startCursor,
|
||||
endCursor,
|
||||
}: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
finalRecords: any[];
|
||||
objectMetadataNamePlural: string;
|
||||
isForwardPagination: boolean;
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const cleanGraphQLResponse = (input: any) => {
|
||||
if (!input) return null;
|
||||
const output = { data: {} }; // Initialize the output with a data key at the top level
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const isObject = (obj: any) => {
|
||||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cleanObject = (obj: any) => {
|
||||
const cleanedObj = {};
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ const computeOperator = (
|
||||
const validateAndGetOrderBy = (
|
||||
key: string,
|
||||
orderBy: ObjectRecordOrderBy,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> => {
|
||||
const keyOrderBy = orderBy.find((order) => key in order);
|
||||
|
||||
@ -51,6 +52,7 @@ const isAscendingOrder = (direction: OrderByDirection): boolean =>
|
||||
direction === OrderByDirection.AscNullsLast;
|
||||
|
||||
export const computeCursorArgFilter = (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
cursor: Record<string, any>,
|
||||
orderBy: ObjectRecordOrderBy,
|
||||
fieldMetadataMapByName: FieldMetadataMap,
|
||||
@ -99,11 +101,13 @@ export const computeCursorArgFilter = (
|
||||
|
||||
const buildWhereCondition = (
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
fieldMetadataMapByName: FieldMetadataMap,
|
||||
orderBy: ObjectRecordOrderBy,
|
||||
isForwardPagination: boolean,
|
||||
operator?: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> => {
|
||||
const fieldMetadata = fieldMetadataMapByName[key];
|
||||
|
||||
@ -138,11 +142,13 @@ const buildWhereCondition = (
|
||||
|
||||
const buildCompositeWhereCondition = (
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any,
|
||||
fieldType: FieldMetadataType,
|
||||
orderBy: ObjectRecordOrderBy,
|
||||
isForwardPagination: boolean,
|
||||
operator?: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Record<string, any> => {
|
||||
const compositeType = compositeTypeDefinitions.get(fieldType);
|
||||
|
||||
@ -154,6 +160,7 @@ const buildCompositeWhereCondition = (
|
||||
}
|
||||
|
||||
const keyOrderBy = validateAndGetOrderBy(key, orderBy);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const result: Record<string, any> = {};
|
||||
|
||||
compositeType.properties.forEach((property) => {
|
||||
|
||||
Reference in New Issue
Block a user