Skip to content

Commit

Permalink
Rename ResponseStatus detail to message
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek committed Mar 14, 2024
1 parent 1e04553 commit 97c4d3c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/agent/src/did-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ export class AgentDidApi<TKeyManager extends AgentKeyManager = AgentKeyManager>
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' }
};
}
}
Expand All @@ -301,7 +301,7 @@ export class AgentDidApi<TKeyManager extends AgentKeyManager = AgentKeyManager>
const response: DidResponse<typeof request.messageType> = {
result : resolutionResult,
ok : true,
status : { code: 200, detail: 'OK' }
status : { code: 200, message: 'OK' }
};
return response;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/agent/src/types/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DwnMessage, Web5Agent } from '@web5/agent';
import type { DwnMessage, DwnResponseStatus, Web5Agent } from '@web5/agent';

import { DwnInterface } from '@web5/agent';

Expand Down Expand Up @@ -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<DwnResponseStatus> {
const { reply } = await this._agent.sendDwnRequest({
author : this._metadata.author,
messageCid : this._metadata.messageCid,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/tests/did-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/proxy-agent/tests/proxy-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/user-agent/tests/user-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit 97c4d3c

Please sign in to comment.