Skip to content

Commit

Permalink
Document delete operation (#220)
Browse files Browse the repository at this point in the history
* feat(/events/document): delete operation

* doc(/events/document): delete operation

* test(UT/utils/index): updated ut document delete operation
  • Loading branch information
Rossb0b authored Apr 2, 2024
1 parent dc0efe2 commit 93d708d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Event notifying the creation/addition of a document.

```ts
export type DocumentOperation = Operation[
keyof Pick<Operation, "create">
keyof Pick<Operation, "create" | "delete">
];

export type DocumentScope = Scope;
Expand Down
2 changes: 1 addition & 1 deletion docs/json-schema/events/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"operation": {
"type": "string",
"description": "Operation operated next to the event",
"enum": ["CREATE"]
"enum": ["CREATE", "DELETE"]
},
"scope": {
"$ref": "Scope"
Expand Down
14 changes: 14 additions & 0 deletions src/schema/events/document.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
},
"required": ["id", "kind"],
"additionalProperties": false
},
"delete": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^[0-9]+"
},
"kind": {
"enum": ["AF", "PF", "DB", "ED"]
}
},
"required": ["id", "kind"],
"additionalProperties": false
}
}
}
2 changes: 1 addition & 1 deletion src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface AccountingFolder {
}

export type DocumentOperation = Operation[
keyof Pick<Operation, "create">
keyof Pick<Operation, "create" | "delete">
];

export type DocumentScope = Scope;
Expand Down
6 changes: 3 additions & 3 deletions test/UT/utils/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ describe("eventsValidationFn", () => {
document = eventsValidationFn.get("document");
});

test("document should have a validation function for \"create\"", () => {
test("document should have a validation function for \"create\", \"delete\"", () => {
expect(document.has("create")).toBe(true);
expect(document.has("delete")).toBe(true);
});

test("document should not have a validation function for \"update\", \"delete\", \"void\"", () => {
test("document should not have a validation function for \"update\", \"void\"", () => {
expect(document.has("update")).toBe(false);
expect(document.has("delete")).toBe(false);
expect(document.has("void")).toBe(false);
});
});
Expand Down

0 comments on commit 93d708d

Please sign in to comment.