From 4601bed03eb80fc1e7b96b59f0fba9f623f318cd Mon Sep 17 00:00:00 2001 From: Frank Hinek Date: Thu, 14 Mar 2024 11:30:38 -0400 Subject: [PATCH] Rename ResponseStatus detail to message Signed-off-by: Frank Hinek --- packages/agent/src/did-api.ts | 6 +++--- packages/agent/src/types/agent.ts | 7 ++++--- packages/api/src/protocol.ts | 4 ++-- packages/api/tests/did-api.spec.ts | 2 +- packages/proxy-agent/tests/proxy-agent.spec.ts | 4 ++-- packages/user-agent/tests/user-agent.spec.ts | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/agent/src/did-api.ts b/packages/agent/src/did-api.ts index 83cd05175..169964063 100644 --- a/packages/agent/src/did-api.ts +++ b/packages/agent/src/did-api.ts @@ -282,14 +282,14 @@ export class AgentDidApi metadata : bearerDid.metadata, }, ok : true, - status : { code: 201, detail: 'Created' } + status : { code: 201, message: 'Created' } }; return response; } catch (error: any) { return { ok : false, - status : { code: 500, detail: error.message ?? 'Unknown error occurred' } + status : { code: 500, message: error.message ?? 'Unknown error occurred' } }; } } @@ -301,7 +301,7 @@ export class AgentDidApi const response: DidResponse = { result : resolutionResult, ok : true, - status : { code: 200, detail: 'OK' } + status : { code: 200, message: 'OK' } }; return response; } diff --git a/packages/agent/src/types/agent.ts b/packages/agent/src/types/agent.ts index 0873a4e6f..1d99c1f2b 100644 --- a/packages/agent/src/types/agent.ts +++ b/packages/agent/src/types/agent.ts @@ -42,12 +42,13 @@ export type ResponseStatus = { code: number; /** - * A descriptive string providing additional information about the operation's result. + * A descriptive message corresponding to the status code that provides additional information + * about the operation's result. * - * This detail is particularly useful for logging, debugging, or displaying contextual messages + * This message is particularly useful for logging, debugging, or displaying contextual messages * to the end-user, offering insights into why an operation succeeded or failed. */ - detail: string; + message: string; }; }; diff --git a/packages/api/src/protocol.ts b/packages/api/src/protocol.ts index 3f1a40b7d..98985fdd3 100644 --- a/packages/api/src/protocol.ts +++ b/packages/api/src/protocol.ts @@ -1,4 +1,4 @@ -import type { DwnMessage, Web5Agent } from '@web5/agent'; +import type { DwnMessage, DwnResponseStatus, Web5Agent } from '@web5/agent'; import { DwnInterface } from '@web5/agent'; @@ -68,7 +68,7 @@ export class Protocol { * @param target - The DID of the target DWN to which the protocol configuration will be installed. * @returns A promise that resolves to an object containing the status of the send operation. */ - async send(target: string) { + async send(target: string): Promise { const { reply } = await this._agent.sendDwnRequest({ author : this._metadata.author, messageCid : this._metadata.messageCid, diff --git a/packages/api/tests/did-api.spec.ts b/packages/api/tests/did-api.spec.ts index de804da03..e4e84a790 100644 --- a/packages/api/tests/did-api.spec.ts +++ b/packages/api/tests/did-api.spec.ts @@ -42,7 +42,7 @@ describe('DidApi', () => { expect(didCreateResponse).to.have.property('ok', true); expect(didCreateResponse).to.have.property('status'); expect(didCreateResponse.status).to.have.property('code', 201); - expect(didCreateResponse.status).to.have.property('detail', 'Created'); + expect(didCreateResponse.status).to.have.property('message', 'Created'); expect(didCreateResponse).to.have.property('did'); expect(didCreateResponse.did).to.have.property('uri'); expect(didCreateResponse.did).to.have.property('document'); diff --git a/packages/proxy-agent/tests/proxy-agent.spec.ts b/packages/proxy-agent/tests/proxy-agent.spec.ts index a236ed664..580a42949 100644 --- a/packages/proxy-agent/tests/proxy-agent.spec.ts +++ b/packages/proxy-agent/tests/proxy-agent.spec.ts @@ -127,7 +127,7 @@ describe('Web5ProxyAgent', () => { expect(didCreateResponse).to.have.property('ok', true); expect(didCreateResponse).to.have.property('status'); expect(didCreateResponse.status).to.have.property('code', 201); - expect(didCreateResponse.status).to.have.property('detail', 'Created'); + expect(didCreateResponse.status).to.have.property('message', 'Created'); expect(didCreateResponse).to.have.property('result'); expect(didCreateResponse.result).to.have.property('uri'); expect(didCreateResponse.result).to.have.property('document'); @@ -144,7 +144,7 @@ describe('Web5ProxyAgent', () => { expect(didResolveResponse).to.have.property('ok', true); expect(didResolveResponse).to.have.property('status'); expect(didResolveResponse.status).to.have.property('code', 200); - expect(didResolveResponse.status).to.have.property('detail', 'OK'); + expect(didResolveResponse.status).to.have.property('message', 'OK'); expect(didResolveResponse).to.have.property('result'); expect(didResolveResponse.result).to.have.property('didDocument'); expect(didResolveResponse.result).to.have.property('didDocumentMetadata'); diff --git a/packages/user-agent/tests/user-agent.spec.ts b/packages/user-agent/tests/user-agent.spec.ts index 805edfc3d..dca016fa7 100644 --- a/packages/user-agent/tests/user-agent.spec.ts +++ b/packages/user-agent/tests/user-agent.spec.ts @@ -127,7 +127,7 @@ describe('Web5UserAgent', () => { expect(didCreateResponse).to.have.property('ok', true); expect(didCreateResponse).to.have.property('status'); expect(didCreateResponse.status).to.have.property('code', 201); - expect(didCreateResponse.status).to.have.property('detail', 'Created'); + expect(didCreateResponse.status).to.have.property('message', 'Created'); expect(didCreateResponse).to.have.property('result'); expect(didCreateResponse.result).to.have.property('uri'); expect(didCreateResponse.result).to.have.property('document'); @@ -144,7 +144,7 @@ describe('Web5UserAgent', () => { expect(didResolveResponse).to.have.property('ok', true); expect(didResolveResponse).to.have.property('status'); expect(didResolveResponse.status).to.have.property('code', 200); - expect(didResolveResponse.status).to.have.property('detail', 'OK'); + expect(didResolveResponse.status).to.have.property('message', 'OK'); expect(didResolveResponse).to.have.property('result'); expect(didResolveResponse.result).to.have.property('didDocument'); expect(didResolveResponse.result).to.have.property('didDocumentMetadata');