Skip to content

Commit

Permalink
Add extra field to formatOperation (#195)
Browse files Browse the repository at this point in the history
* Add extra field to formatOperation

* Fix type
  • Loading branch information
Sergey-weber authored Oct 29, 2024
1 parent 5dfd8d8 commit eabfd63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/services/new/formatters/format-operation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
interface OperationError<D = any> {
code: number;
details: D;
message?: string;
}

type ResultError = {
error?: {
code: number;
Expand All @@ -24,6 +30,8 @@ export type Operation = {
metadata?: {};
done: boolean;
result?: ResultError | ResultResponse;
response?: string;
error?: OperationError;
};

export const formatOperation = (operation: Operation) => {
Expand All @@ -36,5 +44,7 @@ export const formatOperation = (operation: Operation) => {
metadata: {},
done: operation.done ?? true,
...(operation.result ? {result: operation.result} : {}),
...(operation.response ? {response: operation.response} : {}),
...(operation.error ? {error: operation.error} : {}),
};
};

0 comments on commit eabfd63

Please sign in to comment.