From f97d2a5c781605221ce472c50f45cf52c94edea9 Mon Sep 17 00:00:00 2001 From: JGiter Date: Tue, 12 Nov 2024 11:29:27 +0200 Subject: [PATCH] fix: did_status_entity.document --- ...odules_did_didSyncStatus_entity.DidSyncStatusEntity.md | 2 +- ...DidSyncStatus.ts => 1731403701796-AddDIDSyncStatus.ts} | 8 ++++++-- src/modules/did/did.service.ts | 4 ++-- src/modules/did/didSyncStatus.entity.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) rename src/migrations/{1731053556839-AddDidSyncStatus.ts => 1731403701796-AddDIDSyncStatus.ts} (67%) diff --git a/docs/api/classes/modules_did_didSyncStatus_entity.DidSyncStatusEntity.md b/docs/api/classes/modules_did_didSyncStatus_entity.DidSyncStatusEntity.md index 25e07c9b..801f5093 100644 --- a/docs/api/classes/modules_did_didSyncStatus_entity.DidSyncStatusEntity.md +++ b/docs/api/classes/modules_did_didSyncStatus_entity.DidSyncStatusEntity.md @@ -31,7 +31,7 @@ ___ ### document -• **document**: `string` +• **document**: [`DIDDocumentEntity`](modules_did_did_entity.DIDDocumentEntity.md) ___ diff --git a/src/migrations/1731053556839-AddDidSyncStatus.ts b/src/migrations/1731403701796-AddDIDSyncStatus.ts similarity index 67% rename from src/migrations/1731053556839-AddDidSyncStatus.ts rename to src/migrations/1731403701796-AddDIDSyncStatus.ts index 7d98b75e..8cbe7584 100644 --- a/src/migrations/1731053556839-AddDidSyncStatus.ts +++ b/src/migrations/1731403701796-AddDIDSyncStatus.ts @@ -1,9 +1,12 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -export class AddDidSyncStatus1731053556839 implements MigrationInterface { - name = 'AddDidSyncStatus1731053556839'; +export class AddDIDSyncStatus1731403701796 implements MigrationInterface { + name = 'AddDIDSyncStatus1731403701796'; public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "did_document_entity" ("id" character varying NOT NULL, "service" jsonb NOT NULL, "authentication" jsonb NOT NULL, "created" character varying, "delegates" text array, "proof" jsonb, "publicKey" jsonb NOT NULL, "updated" character varying, "@context" character varying NOT NULL, "logs" character varying NOT NULL, CONSTRAINT "PK_d96048f4c93be203eeff05ef404" PRIMARY KEY ("id"))` + ); await queryRunner.query( `CREATE TYPE "public"."did_sync_status_entity_status_enum" AS ENUM('0', '1')` ); @@ -23,5 +26,6 @@ export class AddDidSyncStatus1731053556839 implements MigrationInterface { await queryRunner.query( `DROP TYPE "public"."did_sync_status_entity_status_enum"` ); + await queryRunner.query(`DROP TABLE "did_document_entity"`); } } diff --git a/src/modules/did/did.service.ts b/src/modules/did/did.service.ts index fd7849f9..17248436 100644 --- a/src/modules/did/did.service.ts +++ b/src/modules/did/did.service.ts @@ -227,7 +227,7 @@ export class DIDService implements OnModuleInit, OnModuleDestroy { const updated = await this.didRepository.save(updatedEntity); await this.didSyncStatusRepository.save({ - document: did, + document: updated, status: DidSyncStatus.Synced, }); return updated; @@ -378,7 +378,7 @@ export class DIDService implements OnModuleInit, OnModuleDestroy { await this.didSyncStatusRepository.find({ where: { status: DidSyncStatus.Stale }, }) - ).map((status) => status.document); + ).map((status) => status.document.id); this.logger.debug(`Beginning sync of DID Documents`); staleDIDs.forEach(async (did) => { this.logger.debug(`Synchronizing DID ${did}`); diff --git a/src/modules/did/didSyncStatus.entity.ts b/src/modules/did/didSyncStatus.entity.ts index eb29e33b..8ff08740 100644 --- a/src/modules/did/didSyncStatus.entity.ts +++ b/src/modules/did/didSyncStatus.entity.ts @@ -16,7 +16,7 @@ export class DidSyncStatusEntity { @OneToOne(() => DIDDocumentEntity, (document) => document.id) @JoinColumn() - document: string; + document: DIDDocumentEntity; @Column({ enum: DidSyncStatus, type: 'enum' }) status: DidSyncStatus;