Fix flat entity maps date serialization (#16420)

Changes:
- as we store date in redis as serialized, let's make all flatEntity
dates as string. This requires changing FlatEntity types and making sure
that entity are converted to flatEntity and flatEntity to dtos
This commit is contained in:
Charles Bochet
2025-12-09 16:41:50 +01:00
committed by GitHub
parent 608e5751a9
commit a18203934c
94 changed files with 357 additions and 204 deletions
@@ -20,7 +20,7 @@ export const fromFlatAgentWithRoleIdToAgentDto = ({
workspaceId,
roleId,
}: FlatAgentWithRoleId): AgentDTO => ({
createdAt,
createdAt: new Date(createdAt),
description: description ?? undefined,
evaluationInputs,
id,
@@ -32,7 +32,7 @@ export const fromFlatAgentWithRoleIdToAgentDto = ({
prompt,
responseFormat,
standardId,
updatedAt,
updatedAt: new Date(updatedAt),
workspaceId,
applicationId: applicationId ?? undefined,
icon: icon ?? undefined,
@@ -5,9 +5,9 @@ export const transformAgentEntityToFlatAgent = (
agentEntity: AgentEntity,
): FlatAgent => {
return {
createdAt: agentEntity.createdAt,
deletedAt: agentEntity.deletedAt,
updatedAt: agentEntity.updatedAt,
createdAt: agentEntity.createdAt.toISOString(),
deletedAt: agentEntity.deletedAt?.toISOString() ?? null,
updatedAt: agentEntity.updatedAt.toISOString(),
id: agentEntity.id,
standardId: agentEntity.standardId,
name: agentEntity.name,
@@ -21,13 +21,13 @@ export const transformStandardAgentDefinitionToFlatAgent = ({
outputStrategy: _outputStrategy,
...agentData
} = standardAgentDefinition;
const createdAt = new Date();
const createdAt = new Date().toISOString();
return {
id: existingAgentEntity?.id ?? v4(),
createdAt: existingAgentEntity?.createdAt ?? createdAt,
updatedAt: existingAgentEntity?.updatedAt ?? createdAt,
deletedAt: existingAgentEntity?.deletedAt ?? null,
createdAt: existingAgentEntity?.createdAt?.toISOString() ?? createdAt,
updatedAt: existingAgentEntity?.updatedAt?.toISOString() ?? createdAt,
deletedAt: existingAgentEntity?.deletedAt?.toISOString() ?? null,
...agentData,
workspaceId,
universalIdentifier: standardAgentDefinition.standardId,