[QRQC_2] No implicitAny in twenty-server (#12075)
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
This commit is contained in:
@ -31,6 +31,7 @@ export const actorCompositeType: CompositeType = {
|
||||
(key, index) =>
|
||||
({
|
||||
id: v4(),
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
label: `${FieldActorSource[key].toLowerCase()}`,
|
||||
value: key,
|
||||
position: index,
|
||||
|
||||
@ -124,6 +124,7 @@ export class FieldMetadataValidationService<
|
||||
if (
|
||||
enumOptions &&
|
||||
(enumOptions.includes(formattedDefaultValue) ||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
enumOptions.some((option) => option.to === formattedDefaultValue))
|
||||
) {
|
||||
return;
|
||||
|
||||
@ -699,6 +699,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
}
|
||||
|
||||
const translationValue =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
fieldMetadata.standardOverrides?.translations?.[locale]?.[labelKey];
|
||||
|
||||
if (isDefined(translationValue)) {
|
||||
|
||||
@ -29,6 +29,7 @@ export const unserializeDefaultValue = (
|
||||
if (typeof serializedDefaultValue === 'object') {
|
||||
return Object.entries(serializedDefaultValue).reduce(
|
||||
(acc, [key, value]) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[key] = unserializeDefaultValue(value);
|
||||
|
||||
return acc;
|
||||
|
||||
@ -73,6 +73,7 @@ export const validateDefaultValueForType = (
|
||||
};
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const validators = defaultValueValidatorsMap[type] as any[];
|
||||
|
||||
|
||||
@ -31,10 +31,12 @@ export class IsFieldMetadataDefaultValue
|
||||
args: ValidationArguments,
|
||||
): Promise<boolean> {
|
||||
// Try to extract type value from the object
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
let type: FieldMetadataType | null = args.object['type'];
|
||||
|
||||
if (!type) {
|
||||
// Extract id value from the instance, should happen only when updating
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const id: string | undefined = args.instance?.['id'];
|
||||
|
||||
if (!id) {
|
||||
|
||||
@ -25,10 +25,12 @@ export class IsFieldMetadataOptions {
|
||||
args: ValidationArguments,
|
||||
): Promise<boolean> {
|
||||
// Try to extract type value from the object
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
let type: FieldMetadataType | null = args.object['type'];
|
||||
|
||||
if (!type) {
|
||||
// Extract id value from the instance, should happen only when updating
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const id: string | undefined = args.instance?.['id'];
|
||||
|
||||
if (!id) {
|
||||
|
||||
@ -474,6 +474,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
acc[object.standardId ?? ''] = {
|
||||
id: object.id,
|
||||
fields: object.fields.reduce((acc, field) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[field.standardId ?? ''] = field.id;
|
||||
|
||||
return acc;
|
||||
@ -608,6 +609,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
}
|
||||
|
||||
const translationValue =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
objectMetadata.standardOverrides?.translations?.[locale]?.[labelKey];
|
||||
|
||||
if (isDefined(translationValue)) {
|
||||
|
||||
@ -160,6 +160,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
standardId: createRelationDeterministicUuid({
|
||||
objectId: sourceObjectMetadata.id,
|
||||
standardId:
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
STANDARD_OBJECT_FIELD_IDS[targetObjectMetadata.nameSingular].custom,
|
||||
}),
|
||||
objectMetadataId: targetObjectMetadata.id,
|
||||
@ -192,6 +193,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
const sourceFieldMetadataToUpdate =
|
||||
await this.fieldMetadataRepository.findOneByOrFail({
|
||||
standardId:
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
CUSTOM_OBJECT_STANDARD_FIELD_IDS[targetObjectMetadata.namePlural],
|
||||
objectMetadataId: sourceObjectMetadata.id,
|
||||
workspaceId: workspaceId,
|
||||
@ -239,6 +241,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
return {
|
||||
id: uuidV4(),
|
||||
standardId:
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
CUSTOM_OBJECT_STANDARD_FIELD_IDS[relationObjectMetadataNamePlural],
|
||||
objectMetadataId: sourceObjectMetadata.id,
|
||||
workspaceId: workspaceId,
|
||||
@ -250,6 +253,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
label: capitalize(relationObjectMetadataNamePlural),
|
||||
description,
|
||||
icon:
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
STANDARD_OBJECT_ICONS[targetObjectMetadata.nameSingular] ||
|
||||
'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
@ -280,6 +284,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
targetObjectMetadata: ObjectMetadataEntity,
|
||||
): Partial<FieldMetadataEntity<FieldMetadataType.RELATION>> {
|
||||
const customStandardFieldId =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
STANDARD_OBJECT_FIELD_IDS[targetObjectMetadata.nameSingular].custom;
|
||||
|
||||
if (!customStandardFieldId) {
|
||||
@ -318,6 +323,7 @@ export class ObjectMetadataFieldRelationService {
|
||||
targetObjectMetadata: ObjectMetadataEntity,
|
||||
) {
|
||||
const customStandardFieldId =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
STANDARD_OBJECT_FIELD_IDS[targetObjectMetadata.nameSingular].custom;
|
||||
|
||||
if (!customStandardFieldId) {
|
||||
|
||||
@ -96,6 +96,7 @@ export class DistantTableService {
|
||||
await entityManager.query(`DROP SCHEMA "${tmpSchemaName}" CASCADE`);
|
||||
|
||||
return createdForeignTableNames.reduce(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
(acc, { table_name, column_name, data_type, udt_name }) => {
|
||||
if (!acc[table_name]) {
|
||||
acc[table_name] = [];
|
||||
|
||||
@ -41,11 +41,15 @@ export class ForeignTableService {
|
||||
await this.workspaceDataSourceService.connectToMainDataSource();
|
||||
|
||||
return (
|
||||
await mainDataSource.query(
|
||||
`SELECT foreign_table_name, foreign_server_name FROM information_schema.foreign_tables WHERE foreign_server_name = $1`,
|
||||
[foreignDataWrapperId],
|
||||
(
|
||||
await mainDataSource.query(
|
||||
`SELECT foreign_table_name, foreign_server_name FROM information_schema.foreign_tables WHERE foreign_server_name = $1`,
|
||||
[foreignDataWrapperId],
|
||||
)
|
||||
)
|
||||
).map((foreignTable) => foreignTable.foreign_table_name);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
.map((foreignTable) => foreignTable.foreign_table_name)
|
||||
);
|
||||
}
|
||||
|
||||
public async createForeignTable(
|
||||
|
||||
@ -62,6 +62,7 @@ export class RemoteTableSchemaUpdateService {
|
||||
const tableName = remoteTable.distantTableName;
|
||||
|
||||
if (!distantTable) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
updates[tableName] = [DistantTableUpdate.TABLE_DELETED];
|
||||
continue;
|
||||
}
|
||||
@ -78,13 +79,17 @@ export class RemoteTableSchemaUpdateService {
|
||||
);
|
||||
|
||||
if (columnsAdded.length > 0) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
updates[tableName] = [
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
...(updates[tableName] || []),
|
||||
DistantTableUpdate.COLUMNS_ADDED,
|
||||
];
|
||||
}
|
||||
if (columnsDeleted.length > 0) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
updates[tableName] = [
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
...(updates[tableName] || []),
|
||||
DistantTableUpdate.COLUMNS_DELETED,
|
||||
];
|
||||
|
||||
@ -16,6 +16,7 @@ export const fetchTableColumns = async (
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return res.map((column) => ({
|
||||
columnName: column.column_name,
|
||||
dataType: column.data_type,
|
||||
|
||||
@ -44,10 +44,12 @@ export const buildUpdateRemoteServerRawQuery = (
|
||||
}
|
||||
|
||||
if (remoteServerToUpdate.schema) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
options.push(`"schema" = $${parametersPositions['schema']}`);
|
||||
}
|
||||
|
||||
if (remoteServerToUpdate.label) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
options.push(`"label" = $${parametersPositions['label']}`);
|
||||
}
|
||||
|
||||
@ -78,6 +80,7 @@ const buildParametersAndPositions = (
|
||||
Object.entries(remoteServerToUpdate.userMappingOptions).forEach(
|
||||
([key, value]) => {
|
||||
parameters.push(value);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
parametersPositions[key] = parameters.length;
|
||||
},
|
||||
);
|
||||
@ -87,6 +90,7 @@ const buildParametersAndPositions = (
|
||||
Object.entries(remoteServerToUpdate.foreignDataWrapperOptions).forEach(
|
||||
([key, value]) => {
|
||||
parameters.push(value);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
parametersPositions[key] = parameters.length;
|
||||
},
|
||||
);
|
||||
@ -94,11 +98,13 @@ const buildParametersAndPositions = (
|
||||
|
||||
if (remoteServerToUpdate.schema) {
|
||||
parameters.push(remoteServerToUpdate.schema);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
parametersPositions['schema'] = parameters.length;
|
||||
}
|
||||
|
||||
if (remoteServerToUpdate.label) {
|
||||
parameters.push(remoteServerToUpdate.label);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
parametersPositions['label'] = parameters.length;
|
||||
}
|
||||
|
||||
@ -119,9 +125,11 @@ const buildJsonRawQuery = (
|
||||
): string => {
|
||||
const [[firstKey, _], ...followingOptions] = Object.entries(opts);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
let query = `jsonb_set("${objectName}", '{${firstKey}}', to_jsonb($${parametersPositions[firstKey]}::text))`;
|
||||
|
||||
followingOptions.forEach(([key, _]) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
query = `jsonb_set(${query}, '{${key}}', to_jsonb($${parametersPositions[key]}::text))`;
|
||||
});
|
||||
|
||||
|
||||
@ -266,6 +266,7 @@ export class RoleService {
|
||||
isArgDefinedIfProvidedOrThrow({
|
||||
input,
|
||||
key,
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
value: input[key],
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@ -51,6 +51,7 @@ export class ServerlessFunctionService {
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
) {}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
async findManyServerlessFunctions(where) {
|
||||
return this.serverlessFunctionRepository.findBy(where);
|
||||
}
|
||||
@ -276,6 +277,7 @@ export class ServerlessFunctionService {
|
||||
|
||||
for (const key of Object.keys(serverlessFunctionInput.code)) {
|
||||
await this.fileStorageService.write({
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
file: serverlessFunctionInput.code[key],
|
||||
name: basename(key),
|
||||
mimeType: undefined,
|
||||
@ -306,6 +308,7 @@ export class ServerlessFunctionService {
|
||||
const packageName = match[1].split('@', 1)[0];
|
||||
const version = match[2];
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
if (packageJson.dependencies[packageName]) {
|
||||
versions[packageName] = version;
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ export class CompositeColumnActionFactory extends ColumnActionAbstractFactory<Co
|
||||
}
|
||||
|
||||
const columnName = computeCompositeColumnName(fieldMetadata, property);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const defaultValue = fieldMetadata.defaultValue?.[property.name];
|
||||
const serializedDefaultValue = serializeDefaultValue(defaultValue);
|
||||
const enumOptions = property.options
|
||||
@ -139,6 +140,7 @@ export class CompositeColumnActionFactory extends ColumnActionAbstractFactory<Co
|
||||
alteredProperty,
|
||||
);
|
||||
const defaultValue =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
alteredFieldMetadata.defaultValue?.[alteredProperty.name];
|
||||
const serializedDefaultValue = serializeDefaultValue(defaultValue);
|
||||
const enumOptions = alteredProperty.options
|
||||
@ -173,6 +175,7 @@ export class CompositeColumnActionFactory extends ColumnActionAbstractFactory<Co
|
||||
currentFieldMetadata.isNullable || !currentProperty.isRequired,
|
||||
isUnique: currentFieldMetadata.isUnique ?? false,
|
||||
defaultValue: serializeDefaultValue(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
currentFieldMetadata.defaultValue?.[currentProperty.name],
|
||||
),
|
||||
isArray:
|
||||
|
||||
@ -224,6 +224,7 @@ export class WorkspacePermissionsCacheService {
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return userWorkspaceRoleMap[userWorkspaceId];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user