From 93d708d53d16e217a7be2cded5e8a84e194e4e62 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert <39910164+Rossb0b@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:49:38 +0200 Subject: [PATCH] Document delete operation (#220) * feat(/events/document): delete operation * doc(/events/document): delete operation * test(UT/utils/index): updated ut document delete operation --- docs/events.md | 2 +- docs/json-schema/events/document.md | 2 +- src/schema/events/document.json | 14 ++++++++++++++ src/types/events.ts | 2 +- test/UT/utils/index.spec.ts | 6 +++--- 5 files changed, 20 insertions(+), 6 deletions(-) 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); }); });