Added isAuditLogged column to object-metadata-entity (#4898)
Added isAuditLogged column to object-metadata-entity.ts This is my first open source pull request. Please do let me know if made any mistake. I will be greatfull. Thank u --------- Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddIsAuditLogged1712923480448 implements MigrationInterface {
|
||||
name = 'AddIsAuditLogged1712923480448';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" ADD "isAuditLogged" boolean NOT NULL DEFAULT true`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" DROP COLUMN "isAuditLogged"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ export class EntityEventsToDbListener {
|
||||
payload: ObjectRecordCreateEvent<any>,
|
||||
operation: string,
|
||||
) {
|
||||
if (payload.objectMetadata.isSystem) {
|
||||
if (!payload.objectMetadata.isAuditLogged) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -16,4 +16,5 @@ export interface ObjectMetadataInterface {
|
||||
isCustom: boolean;
|
||||
isActive: boolean;
|
||||
isRemote: boolean;
|
||||
isAuditLogged: boolean;
|
||||
}
|
||||
|
||||
@ -64,6 +64,9 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
|
||||
@Column({ default: false })
|
||||
isSystem: boolean;
|
||||
|
||||
@Column({ default: true })
|
||||
isAuditLogged: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
labelIdentifierFieldMetadataId?: string;
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
import { TypedReflect } from 'src/utils/typed-reflect';
|
||||
|
||||
export function IsNotAuditLogged() {
|
||||
return function (target: object) {
|
||||
TypedReflect.defineMetadata('isAuditLogged', false, target);
|
||||
};
|
||||
}
|
||||
@ -8,6 +8,8 @@ export function ObjectMetadata(
|
||||
): ClassDecorator {
|
||||
return (target) => {
|
||||
const isSystem = TypedReflect.getMetadata('isSystem', target) ?? false;
|
||||
const isAuditLogged =
|
||||
TypedReflect.getMetadata('isAuditLogged', target) ?? true;
|
||||
const gate = TypedReflect.getMetadata('gate', target);
|
||||
const objectName = convertClassNameToObjectMetadataName(target.name);
|
||||
|
||||
@ -20,6 +22,7 @@ export function ObjectMetadata(
|
||||
isSystem,
|
||||
isCustom: false,
|
||||
isRemote: false,
|
||||
isAuditLogged,
|
||||
description: params.description,
|
||||
icon: params.icon,
|
||||
gate,
|
||||
|
||||
@ -15,5 +15,6 @@ export interface ReflectObjectMetadata extends ObjectMetadataDecoratorParams {
|
||||
isSystem: boolean;
|
||||
isCustom: boolean;
|
||||
isRemote: boolean;
|
||||
isAuditLogged: boolean;
|
||||
gate?: GateDecoratorParams;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { standardObjectIds } from 'src/engine/workspace-manager/workspace-sync-m
|
||||
import { CustomObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/custom-objects/custom.object-metadata';
|
||||
import { DynamicRelationFieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/dynamic-field-metadata.interface';
|
||||
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
|
||||
import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-not-audit-logged.decorator';
|
||||
import { IsNullable } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-nullable.decorator';
|
||||
import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-system.decorator';
|
||||
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
|
||||
@ -22,6 +23,7 @@ import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/stan
|
||||
icon: 'IconJson',
|
||||
})
|
||||
@IsSystem()
|
||||
@IsNotAuditLogged()
|
||||
export class EventObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: eventStandardFieldIds.properties,
|
||||
|
||||
@ -16,6 +16,7 @@ export interface ReflectMetadataTypeMap {
|
||||
gate: GateDecoratorParams;
|
||||
isNullable: true;
|
||||
isSystem: true;
|
||||
isAuditLogged: false;
|
||||
}
|
||||
|
||||
export class TypedReflect {
|
||||
|
||||
Reference in New Issue
Block a user