diff --git a/docs/events.md b/docs/events.md index a1d4284a..5f3430e8 100644 --- a/docs/events.md +++ b/docs/events.md @@ -76,7 +76,7 @@ Event notifying the creation/addition of a document. ```ts export type DocumentOperation = Operation[ - keyof Pick + keyof Pick ]; export type DocumentScope = Scope; diff --git a/docs/json-schema/events/document.md b/docs/json-schema/events/document.md index ff0460de..06c030e7 100644 --- a/docs/json-schema/events/document.md +++ b/docs/json-schema/events/document.md @@ -10,7 +10,7 @@ "operation": { "type": "string", "description": "Operation operated next to the event", - "enum": ["CREATE"] + "enum": ["CREATE", "DELETE"] }, "scope": { "$ref": "Scope" diff --git a/src/schema/events/document.json b/src/schema/events/document.json index 9826e0dc..733035ff 100644 --- a/src/schema/events/document.json +++ b/src/schema/events/document.json @@ -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 } } } diff --git a/src/types/events.ts b/src/types/events.ts index b6eb20d5..cac7558d 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -48,7 +48,7 @@ export interface AccountingFolder { } export type DocumentOperation = Operation[ - keyof Pick + keyof Pick ]; export type DocumentScope = Scope; diff --git a/test/UT/utils/index.spec.ts b/test/UT/utils/index.spec.ts index a96f13ea..2a4f70da 100644 --- a/test/UT/utils/index.spec.ts +++ b/test/UT/utils/index.spec.ts @@ -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); }); });