Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ok boolean to DWNResponseStatus #959

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/agent/src/types/dwn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export type DwnResponseStatus = {

/** Descriptive detail about the status or error. */
detail: string;
ok: boolean;
};
};

Expand Down
10 changes: 10 additions & 0 deletions packages/api/src/dwn-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ export class DwnApi {

const { reply: { status } } = agentResponse;

status.ok = (200 <= 200 && status.code <= 299);

return { status };
},
/**
Expand Down Expand Up @@ -706,6 +708,8 @@ export class DwnApi {
return record;
});

status.ok = (200 <= 200 && status.code <= 299);

return { records, status, cursor };
},

Expand Down Expand Up @@ -767,6 +771,8 @@ export class DwnApi {

const { reply: { entry, status } } = agentResponse;

status.ok = (200 <= 200 && status.code <= 299);
Toheeb-Ojuolape marked this conversation as resolved.
Show resolved Hide resolved

let record: Record;
if (200 <= status.code && status.code <= 299) {
const recordOptions = {
Expand Down Expand Up @@ -874,6 +880,8 @@ export class DwnApi {
const reply = agentResponse.reply;
const { status, subscription } = reply;

status.ok = (200 <= 200 && status.code <= 299);

return { status, subscription };
},

Expand Down Expand Up @@ -923,6 +931,8 @@ export class DwnApi {

const { message: responseMessage, reply: { status } } = agentResponse;

status.ok = (status.code === 202);

let record: Record;
if (200 <= status.code && status.code <= 299) {
const recordOptions = {
Expand Down