From 57b2239b26ec56f2d3d4b7affbcb398564bd1dc5 Mon Sep 17 00:00:00 2001 From: Estela Silva Date: Fri, 26 Apr 2024 15:08:12 -0300 Subject: [PATCH] wip: incremental id to history table --- src/models/history.model.ts | 1 + src/schema/types/historyVersion.type.ts | 8 +++++++- src/utils/history/recordHistory.ts | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/models/history.model.ts b/src/models/history.model.ts index 72eceee8a..93d5fff03 100644 --- a/src/models/history.model.ts +++ b/src/models/history.model.ts @@ -14,6 +14,7 @@ export type RecordHistory = { createdBy: string; changes: Change[]; version?: Version; + incrementalId?: string; }[]; export type RecordHistoryMeta = { diff --git a/src/schema/types/historyVersion.type.ts b/src/schema/types/historyVersion.type.ts index 32aee1df4..201d053f3 100644 --- a/src/schema/types/historyVersion.type.ts +++ b/src/schema/types/historyVersion.type.ts @@ -1,4 +1,9 @@ -import { GraphQLObjectType, GraphQLString, GraphQLList } from 'graphql'; +import { + GraphQLObjectType, + GraphQLString, + GraphQLList, + GraphQLID, +} from 'graphql'; import { GraphQLDateTime } from 'graphql-scalars'; import { VersionType } from './version.type'; @@ -27,5 +32,6 @@ export const HistoryVersionType = new GraphQLObjectType({ createdBy: { type: GraphQLString }, changes: { type: new GraphQLList(changeType) }, version: { type: VersionType }, + incrementalId: { type: GraphQLID }, }), }); diff --git a/src/utils/history/recordHistory.ts b/src/utils/history/recordHistory.ts index fb417f387..cffb97b05 100644 --- a/src/utils/history/recordHistory.ts +++ b/src/utils/history/recordHistory.ts @@ -252,6 +252,7 @@ export class RecordHistory { res.push({ createdAt: this.record.createdAt, createdBy: this.record._createdBy?.user?.name, + incrementalId: this.record.incrementalId, changes, }); @@ -263,6 +264,7 @@ export class RecordHistory { createdAt: versions[0].createdAt, createdBy: this.record._createdBy?.user?.name, changes, + incrementalId: this.record.incrementalId, version: versions[0], }); @@ -272,6 +274,7 @@ export class RecordHistory { createdAt: versions[i].createdAt, createdBy: versions[i - 1].createdBy?.name, changes, + incrementalId: this.record.incrementalId, version: versions[i], }); } @@ -282,6 +285,7 @@ export class RecordHistory { res.push({ createdAt: this.record.modifiedAt, createdBy: versions[versions.length - 1].createdBy?.name, + incrementalId: this.record.incrementalId, changes, });