From 04dbc12cf25fab4088c77b0aceeecc7cee2b2081 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Wed, 3 Sep 2025 17:56:20 +0200 Subject: [PATCH 01/11] 7.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f22babb0..73206ab3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@myunisoft/events", - "version": "7.0.6", + "version": "7.0.7", "description": "MyUnisoft Events validation", "main": "dist/index.js", "types": "dist/index.d.ts", From 4eb000a983ef5f603fb20426456f08fb66b00f3a Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Wed, 10 Sep 2025 17:40:31 +0200 Subject: [PATCH 02/11] feat(./types/events): MiscellaneousFlow as possible document kind --- src/schema/events/document.json | 2 +- src/types/events.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/schema/events/document.json b/src/schema/events/document.json index b409a3e8..87d4404c 100644 --- a/src/schema/events/document.json +++ b/src/schema/events/document.json @@ -8,7 +8,7 @@ "pattern": "^[0-9]+" }, "kind": { - "enum": ["AF", "PF", "DB", "ED"] + "enum": ["AF", "PF", "DB", "ED", "MF"] }, "name": { "type": "string" diff --git a/src/types/events.ts b/src/types/events.ts index 2fb8c39a..0730ddca 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -45,7 +45,8 @@ export enum DocumentKind { DossierAnnuel = "AF", DossierPermanent = "PF", BaseDocumentaire = "DB", - ExternalDocument = "ED" + ExternalDocument = "ED", + MiscellaneousFlow = "MF" } export interface Document { From a9b7c9ad8995390f987a514fd61a061339ae96bb Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Wed, 10 Sep 2025 17:41:08 +0200 Subject: [PATCH 03/11] doc(/docs/events): updated event doc with MiscellaneousFlow kind --- docs/events.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/events.md b/docs/events.md index 42ef8198..e628b24e 100644 --- a/docs/events.md +++ b/docs/events.md @@ -214,7 +214,8 @@ export enum DocumentKind { DossierAnnuel = "AF", DossierPermanent = "PF", BaseDocumentaire = "DB", - ExternalDocument = "ED" + ExternalDocument = "ED", + MiscellaneousFlow = "MF" } export interface Document { @@ -256,7 +257,7 @@ export interface Document { "type": "string" }, "kind": { - "enum": ["AF", "PF", "DB", "ED"] + "enum": ["AF", "PF", "DB", "ED", "MF"] }, "name": { "type": "string" From cea27e3ba95a69074d4868b1f48dc3df60372000 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 14:21:10 +0200 Subject: [PATCH 04/11] refactor(./tpyes/events.ts): use obj over enum --- src/types/events.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/types/events.ts b/src/types/events.ts index 0730ddca..c4a6838a 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -41,13 +41,13 @@ export interface AccountingFolder { }; } -export enum DocumentKind { - DossierAnnuel = "AF", - DossierPermanent = "PF", - BaseDocumentaire = "DB", - ExternalDocument = "ED", - MiscellaneousFlow = "MF" -} +export const DocumentKind = { + DossierAnnuel: "AF", + DossierPermanent: "PF", + BaseDocumentaire: "DB", + ExternalDocument: "ED", + MiscellaneousFlow: "MF" +} as const; export interface Document { name: "document"; @@ -55,7 +55,7 @@ export interface Document { operation: "CREATE"; data: { id: string; - kind: DocumentKind; + kind: typeof DocumentKind[keyof typeof DocumentKind]; name: string; } } From 8373aefb9f8052bd658d213dadb457b2666557f8 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 14:21:36 +0200 Subject: [PATCH 05/11] doc(/docs/events.md): updated type for Document --- docs/events.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/events.md b/docs/events.md index e628b24e..e6ef079a 100644 --- a/docs/events.md +++ b/docs/events.md @@ -210,13 +210,13 @@ export interface AccountingFolder { Event notifying the creation/addition of a document. ```ts -export enum DocumentKind { - DossierAnnuel = "AF", - DossierPermanent = "PF", - BaseDocumentaire = "DB", - ExternalDocument = "ED", - MiscellaneousFlow = "MF" -} +export const DocumentKind = { + DossierAnnuel: "AF", + DossierPermanent: "PF", + BaseDocumentaire: "DB", + ExternalDocument: "ED", + MiscellaneousFlow: "MF" +} as const; export interface Document { name: "document"; @@ -224,7 +224,7 @@ export interface Document { operation: "CREATE"; data: { id: string; - kind: DocumentKind; + kind: typeof DocumentKind[keyof typeof DocumentKind]; name: string; }; } From 57337c3266f521d78b62c7d42582bc926e746ff3 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 14:35:12 +0200 Subject: [PATCH 06/11] refactor(./types/events.ts): use Object.freeze over as const for mutability --- src/types/events.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/events.ts b/src/types/events.ts index c4a6838a..da2633be 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -41,13 +41,13 @@ export interface AccountingFolder { }; } -export const DocumentKind = { +export const DOCUMENT_KIND = Object.freeze({ DossierAnnuel: "AF", DossierPermanent: "PF", BaseDocumentaire: "DB", ExternalDocument: "ED", MiscellaneousFlow: "MF" -} as const; +}); export interface Document { name: "document"; @@ -55,7 +55,7 @@ export interface Document { operation: "CREATE"; data: { id: string; - kind: typeof DocumentKind[keyof typeof DocumentKind]; + kind: typeof DOCUMENT_KIND[keyof typeof DOCUMENT_KIND]; name: string; } } From d524b20ff8eb360c04051d37580edd645b45375e Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 14:35:30 +0200 Subject: [PATCH 07/11] doc(/docs/events.md): updated doc --- docs/events.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/events.md b/docs/events.md index e6ef079a..c0855f8b 100644 --- a/docs/events.md +++ b/docs/events.md @@ -210,13 +210,13 @@ export interface AccountingFolder { Event notifying the creation/addition of a document. ```ts -export const DocumentKind = { +export const DOCUMENT_KIND = Object.freeze({ DossierAnnuel: "AF", DossierPermanent: "PF", BaseDocumentaire: "DB", ExternalDocument: "ED", MiscellaneousFlow: "MF" -} as const; +}); export interface Document { name: "document"; @@ -224,7 +224,7 @@ export interface Document { operation: "CREATE"; data: { id: string; - kind: typeof DocumentKind[keyof typeof DocumentKind]; + kind: typeof DOCUMENT_KIND[keyof typeof DOCUMENT_KIND]; name: string; }; } From e6d97c2662cd0f2b3a7968b3880b2ef34b2e27fd Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 15:02:44 +0200 Subject: [PATCH 08/11] refactor(./types/events.ts): add export DocumentKind --- src/types/events.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/events.ts b/src/types/events.ts index da2633be..ffc94177 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -49,13 +49,15 @@ export const DOCUMENT_KIND = Object.freeze({ MiscellaneousFlow: "MF" }); +export type DocumentKind = typeof DOCUMENT_KIND[keyof typeof DOCUMENT_KIND]; + export interface Document { name: "document"; scope: Scope; operation: "CREATE"; data: { id: string; - kind: typeof DOCUMENT_KIND[keyof typeof DOCUMENT_KIND]; + kind: DocumentKind; name: string; } } From 357032a687d7d3beb3c4516c1ff6b9a96403f3db Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 15:03:00 +0200 Subject: [PATCH 09/11] doc(/docs/events.md): updated doc --- docs/events.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/events.md b/docs/events.md index c0855f8b..f09593ea 100644 --- a/docs/events.md +++ b/docs/events.md @@ -218,6 +218,8 @@ export const DOCUMENT_KIND = Object.freeze({ MiscellaneousFlow: "MF" }); +export type DocumentKind = typeof DOCUMENT_KIND[keyof typeof DOCUMENT_KIND]; + export interface Document { name: "document"; scope: Scope; From 91dc33e0775e09a7ba666e775d65c1c1f8b185f7 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 15:35:44 +0200 Subject: [PATCH 10/11] refacto(./class/incomer.class.ts): updated types --- src/class/incomer.class.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/class/incomer.class.ts b/src/class/incomer.class.ts index c3ed1aa0..c0069cb4 100644 --- a/src/class/incomer.class.ts +++ b/src/class/incomer.class.ts @@ -161,7 +161,7 @@ export class Incomer < #retryPublishLock = new Mutex({ concurrency: 1, keepReferencingTimers: false }); #registrationCbLock = new Mutex({ concurrency: 1, keepReferencingTimers: false }); - #lastActivity: number; + private lastActivity: number; #idleTime: number; #eventsValidationFn: Map> | NestedValidationFunctions> | undefined; #customValidationCbFn: ((event: T) => void) | undefined; @@ -232,7 +232,7 @@ export class Incomer < private async checkDispatcherState() { const date = Date.now(); - if ((Number(this.#lastActivity) + Number(this.#maxPingInterval)) < date) { + if ((Number(this.lastActivity) + Number(this.#maxPingInterval)) < date) { this.dispatcherConnectionState = false; return; @@ -341,7 +341,7 @@ export class Incomer < }); this.#checkDispatcherStateInterval = setInterval(() => { - if (!this.#lastActivity) { + if (!this.lastActivity) { return; } @@ -350,7 +350,7 @@ export class Incomer < }, this.#maxPingInterval).unref(); this.#checkTransactionsStateInterval = setInterval(() => { - if (!this.#lastActivity) { + if (!this.lastActivity) { return; } @@ -422,7 +422,7 @@ export class Incomer < }); this.#checkDispatcherStateInterval = setInterval(() => { - if (!this.#lastActivity) { + if (!this.lastActivity) { return; } @@ -431,7 +431,7 @@ export class Incomer < }, this.#maxPingInterval).unref(); this.#checkTransactionsStateInterval = setInterval(() => { - if (!this.#lastActivity) { + if (!this.lastActivity) { return; } @@ -439,7 +439,7 @@ export class Incomer < .catch((error) => this.logger.error({ error: error.stack }, "failed while retry publishing")); }, this.#publishInterval).unref(); - this.#lastActivity = Date.now(); + this.lastActivity = Date.now(); this.dispatcherConnectionState = true; this.logger.info(`Incomer registered with uuid ${this.providedUUID}`); @@ -715,7 +715,7 @@ export class Incomer < const { redisMetadata } = message; const { transactionId } = redisMetadata; - this.#lastActivity = Date.now(); + this.lastActivity = Date.now(); this.dispatcherConnectionState = true; const logData = { @@ -906,7 +906,7 @@ export class Incomer < await Promise.all(transactionToUpdate); - this.#lastActivity = Date.now(); + this.lastActivity = Date.now(); this.dispatcherConnectionState = true; this.emit("registered"); } From 97d0581e3280ff0970a45fcb42d1bba36c6b5511 Mon Sep 17 00:00:00 2001 From: Nicolas Hallaert Date: Tue, 16 Sep 2025 15:35:57 +0200 Subject: [PATCH 11/11] test(/test/UT/~): updated UT --- test/UT/class/dispatcher.spec.ts | 10 +- test/UT/class/events.spec.ts | 5 +- .../class/handle-inactive-no-backup.spec.ts | 4 +- .../class/handle-inactive-with-backup.spec.ts | 4 +- test/UT/class/incomer.spec.ts | 2 +- test/UT/class/registration.spec.ts | 10 +- test/UT/class/service/events.test.ts | 2 +- test/UT/class/transaction-handler.test.ts | 50 ++++---- test/UT/utils/eventsValidationFn.test.ts | 114 +++++++++--------- 9 files changed, 102 insertions(+), 99 deletions(-) diff --git a/test/UT/class/dispatcher.spec.ts b/test/UT/class/dispatcher.spec.ts index fcc9ea48..c8f09022 100644 --- a/test/UT/class/dispatcher.spec.ts +++ b/test/UT/class/dispatcher.spec.ts @@ -71,6 +71,7 @@ describe("Dispatcher", () => { await subscriber.initialize(); dispatcher = new Dispatcher({ + name: "foo", redis, subscriber, logger, @@ -161,7 +162,7 @@ describe("Dispatcher", () => { }); describe("Publishing a well formed register event but multiple times", () => { - let channel; + let channel: Channel; let incomerTransactionStore: TransactionStore<"incomer">; const event = { @@ -394,6 +395,7 @@ describe("Dispatcher", () => { } dispatcher = new Dispatcher({ + name: "foo", redis, subscriber, logger, @@ -659,11 +661,11 @@ describe("Dispatcher", () => { const secondIncomerName = "bar"; const secondUuid = randomUUID(); let firstIncomerProvidedUUID; - let secondIncomerProvidedUUID; + let secondIncomerProvidedUUID: string; let hasDistributedEvents = false; let firstIncomerTransactionStore: TransactionStore<"incomer">; let secondIncomerTransactionStore: TransactionStore<"incomer">; - let mainTransactionId; + let mainTransactionId: string | null | undefined; beforeAll(async() => { await subscriber.subscribe("dispatcher"); @@ -835,7 +837,7 @@ describe("Dispatcher", () => { test("it should have distributed the event & resolve the main transaction", async() => { await timers.setTimeout(10_000); - const transaction = await firstIncomerTransactionStore.getTransactionById(mainTransactionId); + const transaction = await firstIncomerTransactionStore.getTransactionById(mainTransactionId!); expect(transaction).toBeNull(); diff --git a/test/UT/class/events.spec.ts b/test/UT/class/events.spec.ts index 5489085e..2949ff5d 100644 --- a/test/UT/class/events.spec.ts +++ b/test/UT/class/events.spec.ts @@ -17,7 +17,7 @@ import { eventsValidationFn, type EventOptions, type Events, - DocumentKind + DOCUMENT_KIND } from "../../../src/index.js"; import { Transaction, @@ -64,6 +64,7 @@ async function initDispatcherInstance( const { pingInterval, checkTransactionInterval, idleTime, checkLastActivityInterval } = options; const dispatcher = new Dispatcher>({ + name: "foo", redis, subscriber, pingInterval, @@ -448,7 +449,7 @@ describe("event", () => { data: { id: "1", name: "foo", - kind: DocumentKind.DossierAnnuel + kind: DOCUMENT_KIND.DossierAnnuel }, scope: { schemaId: 1, diff --git a/test/UT/class/handle-inactive-no-backup.spec.ts b/test/UT/class/handle-inactive-no-backup.spec.ts index 6df4edf8..38e6231a 100644 --- a/test/UT/class/handle-inactive-no-backup.spec.ts +++ b/test/UT/class/handle-inactive-no-backup.spec.ts @@ -122,7 +122,7 @@ describe("Publishing/exploiting a custom event & inactive incomer", () => { Reflect.set(concernedIncomer, "newTransactionStore", firstIncomerTransactionStore); - concernedIncomer["lastPingDate"] = Date.now(); + concernedIncomer["lastActivity"] = Date.now(); concernedIncomer.emit("registered"); handleApprovementIndex++; @@ -146,7 +146,7 @@ describe("Publishing/exploiting a custom event & inactive incomer", () => { Reflect.set(secondConcernedIncomer, "newTransactionStore", secondIncomerTransactionStore); - secondConcernedIncomer["lastPingDate"] = Date.now(); + secondConcernedIncomer["lastActivity"] = Date.now(); secondConcernedIncomer.emit("registered"); } }); diff --git a/test/UT/class/handle-inactive-with-backup.spec.ts b/test/UT/class/handle-inactive-with-backup.spec.ts index 92e39555..0d3c0061 100644 --- a/test/UT/class/handle-inactive-with-backup.spec.ts +++ b/test/UT/class/handle-inactive-with-backup.spec.ts @@ -120,7 +120,7 @@ describe("Publishing/exploiting a custom event & inactive incomer", () => { Reflect.set(concernedIncomer, "newTransactionStore", firstIncomerTransactionStore); - concernedIncomer["lastPingDate"] = Date.now(); + concernedIncomer["lastActivity"] = Date.now(); concernedIncomer.emit("registered"); handleApprovementIndex++; @@ -144,7 +144,7 @@ describe("Publishing/exploiting a custom event & inactive incomer", () => { Reflect.set(secondConcernedIncomer, "newTransactionStore", secondIncomerTransactionStore); - secondConcernedIncomer["lastPingDate"] = Date.now(); + secondConcernedIncomer["lastActivity"] = Date.now(); secondConcernedIncomer.emit("registered"); } }); diff --git a/test/UT/class/incomer.spec.ts b/test/UT/class/incomer.spec.ts index 2c586982..d9195d5e 100644 --- a/test/UT/class/incomer.spec.ts +++ b/test/UT/class/incomer.spec.ts @@ -129,7 +129,7 @@ describe("Init Incomer with Dispatcher alive", () => { pingInterval: pingInterval, idleTime: kIdleTime, incomerUUID: dispatcherIncomer.baseUUID, - instanceName: "node:Pulsar" + name: "node:Pulsar" }); await dispatcher.initialize(); diff --git a/test/UT/class/registration.spec.ts b/test/UT/class/registration.spec.ts index 9801fa7b..9fa81f3a 100644 --- a/test/UT/class/registration.spec.ts +++ b/test/UT/class/registration.spec.ts @@ -63,8 +63,8 @@ describe("Registration", () => { } }; - function updateIncomerState(...args) { - incomer["lastPingDate"] = Date.now(); + function updateIncomerState(...args: any[]) { + incomer["lastActivity"] = Date.now(); incomer["dispatcherConnectionState"] = true; } @@ -95,10 +95,10 @@ describe("Registration", () => { }); describe("Initializing a new Incomer", () => { - let handlePingFn: (...any) => any; - let registerFn: (...any) => Promise; + let handlePingFn: (...arg0: any[]) => any; + let registerFn: (...arg0: any[]) => Promise; let incomerProvidedUUID: string; - let callLength; + let callLength: number; const eventComeBackHandler = jest.fn().mockImplementation(() => Ok({ status: "RESOLVED" })); diff --git a/test/UT/class/service/events.test.ts b/test/UT/class/service/events.test.ts index a2abd58b..334222e6 100644 --- a/test/UT/class/service/events.test.ts +++ b/test/UT/class/service/events.test.ts @@ -141,7 +141,7 @@ describe("EventsService", () => { test("Calling forceDispatcherTakeLead as the only dispatcher, it should stay alive", async() => { let incomers = await dispatcher.eventsService.getIncomers(); - dispatcher.eventsService.forceDispatcherTakeLead(incomers, incomers[0]); + dispatcher.eventsService.forceDispatcherTakeLead(incomers, [...incomers.values()][0]); await timers.setTimeout(2_000); diff --git a/test/UT/class/transaction-handler.test.ts b/test/UT/class/transaction-handler.test.ts index 268f56a4..1b3608be 100644 --- a/test/UT/class/transaction-handler.test.ts +++ b/test/UT/class/transaction-handler.test.ts @@ -137,7 +137,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -147,7 +147,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -157,7 +157,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -175,7 +175,7 @@ describe("transactionHandler", () => { instance: "incomer" }); - let resolvedEvent; + let resolvedEvent: { spreadTransaction: any; mainTransaction?: Transaction<"incomer">; }; before(async() => { await incomerStore.setIncomer(publisher, publisher.providedUUID); @@ -221,7 +221,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -231,7 +231,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -241,7 +241,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -251,7 +251,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -269,7 +269,7 @@ describe("transactionHandler", () => { instance: "incomer" }); - let resolvedEvent; + let resolvedEvent: { spreadTransaction: any; mainTransaction?: Transaction<"incomer">; }; before(async() => { await incomerStore.setIncomer(publisher, publisher.providedUUID); @@ -318,7 +318,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -328,7 +328,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -338,7 +338,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -356,7 +356,7 @@ describe("transactionHandler", () => { instance: "incomer" }); - let unResolved; + let unResolved: { spreadTransaction: any; mainTransaction?: Transaction<"incomer">; }; before(async() => { await incomerStore.setIncomer(publisher, publisher.providedUUID); @@ -402,7 +402,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -412,7 +412,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -422,7 +422,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -432,7 +432,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -450,7 +450,7 @@ describe("transactionHandler", () => { instance: "incomer" }); - let backupEvent; + let backupEvent: unknown; before(async() => { await incomerStore.setIncomer(publisher, publisher.providedUUID); @@ -503,7 +503,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -513,7 +513,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -523,7 +523,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -533,7 +533,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -604,7 +604,7 @@ describe("transactionHandler", () => { eventsCast: [connectorEvent.name], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -614,7 +614,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now @@ -624,7 +624,7 @@ describe("transactionHandler", () => { eventsCast: [], eventsSubscribe: [{ name: connectorEvent.name }], providedUUID: randomUUID(), - isDispatcherActiveInstance: false, + isDispatcherActiveInstance: "false", baseUUID: randomUUID(), lastActivity: now, aliveSince: now diff --git a/test/UT/utils/eventsValidationFn.test.ts b/test/UT/utils/eventsValidationFn.test.ts index 9d10f42d..b4e74195 100644 --- a/test/UT/utils/eventsValidationFn.test.ts +++ b/test/UT/utils/eventsValidationFn.test.ts @@ -3,7 +3,7 @@ import assert from "node:assert"; import { describe, before, test } from "node:test"; // Import Internal Dependencies -import { eventsValidationFn } from "../../../src/utils/index.js"; +import { eventsValidationFn, NestedValidationFunctions } from "../../../src/utils/index.js"; describe("eventsValidationFn", () => { @@ -12,7 +12,7 @@ describe("eventsValidationFn", () => { }); describe("connector", () => { - let connector; + let connector: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("connector")); @@ -21,18 +21,18 @@ describe("eventsValidationFn", () => { }); test("connector should have a validation function for \"create\", \"update\", \"delete\"", () => { - assert.ok(connector.has("create")); - assert.ok(connector.has("update")); - assert.ok(connector.has("delete")); + assert.ok(connector!.has("create")); + assert.ok(connector!.has("update")); + assert.ok(connector!.has("delete")); }); test("connector should not have a validation function for \"void\"", () => { - assert.ok(!connector.has("void")); + assert.ok(!connector!.has("void")); }); }); describe("accountingFolder", () => { - let accountingFolder; + let accountingFolder: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("accountingFolder")); @@ -41,19 +41,19 @@ describe("eventsValidationFn", () => { }); test("accountingFolder should have a validation function for \"create\", \"scope\"", () => { - assert.ok(accountingFolder.has("create")); - assert.ok(accountingFolder.has("scope")); + assert.ok(accountingFolder!.has("create")); + assert.ok(accountingFolder!.has("scope")); }); test("accountingFolder should not have a validation function for \"void\", \"update\", \"delete\"", () => { - assert.ok(!accountingFolder.has("void")); - assert.ok(!accountingFolder.has("update")); - assert.ok(!accountingFolder.has("delete")); + assert.ok(!accountingFolder!.has("void")); + assert.ok(!accountingFolder!.has("update")); + assert.ok(!accountingFolder!.has("delete")); }); }); describe("document", () => { - let document; + let document: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("document")); @@ -62,18 +62,18 @@ describe("eventsValidationFn", () => { }); test("document should have a validation function for \"create\"", () => { - assert.ok(document.has("create")); + assert.ok(document!.has("create")); }); test("document should not have a validation function for \"update\", \"void\", \"delete\"", () => { - assert.ok(!document.has("update")); - assert.ok(!document.has("delete")); - assert.ok(!document.has("void")); + assert.ok(!document!.has("update")); + assert.ok(!document!.has("delete")); + assert.ok(!document!.has("void")); }); }); describe("portfolio", () => { - let portfolio; + let portfolio: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("portfolio")); @@ -82,18 +82,18 @@ describe("eventsValidationFn", () => { }); test("portfolio should have a validation function for \"create\", \"delete\"", () => { - assert.ok(portfolio.has("create")); - assert.ok(portfolio.has("delete")); + assert.ok(portfolio!.has("create")); + assert.ok(portfolio!.has("delete")); }); test("portfolio should not have a validation function for \"update\", \"void\"", () => { - assert.ok(!portfolio.has("update")); - assert.ok(!portfolio.has("void")); + assert.ok(!portfolio!.has("update")); + assert.ok(!portfolio!.has("void")); }); }); describe("AccountingLineEntry", () => { - let accountingLineEntry; + let accountingLineEntry: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("accountingLineEntry")); @@ -102,18 +102,18 @@ describe("eventsValidationFn", () => { }); test("accountingLineEntry should have a validation function for \"create\"", () => { - assert.ok(accountingLineEntry.has("create")); + assert.ok(accountingLineEntry!.has("create")); }); test("accountingLineEntry should not have a validation function for \"update\", \"delete\", \"void\"", () => { - assert.ok(!accountingLineEntry.has("update")); - assert.ok(!accountingLineEntry.has("delete")); - assert.ok(!accountingLineEntry.has("void")); + assert.ok(!accountingLineEntry!.has("update")); + assert.ok(!accountingLineEntry!.has("delete")); + assert.ok(!accountingLineEntry!.has("void")); }); }); describe("AdminMessage", () => { - let adminMessage; + let adminMessage: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("adminMessage")); @@ -122,18 +122,18 @@ describe("eventsValidationFn", () => { }); test("adminMessage should have a validation function for \"void\"", () => { - assert.ok(adminMessage.has("void")); + assert.ok(adminMessage!.has("void")); }); test("adminMessage should not have a validation function for \"create\", \"update\", \"delete\"", () => { - assert.ok(!adminMessage.has("create")); - assert.ok(!adminMessage.has("update")); - assert.ok(!adminMessage.has("delete")); + assert.ok(!adminMessage!.has("create")); + assert.ok(!adminMessage!.has("update")); + assert.ok(!adminMessage!.has("delete")); }); }); describe("ThirdParty", () => { - let thirdParty; + let thirdParty: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("thirdParty")); @@ -142,18 +142,18 @@ describe("eventsValidationFn", () => { }); test("thirdParty should have a validation function for \"create\", \"update\", \"delete\"", () => { - assert.ok(thirdParty.has("create")); - assert.ok(thirdParty.has("update")); - assert.ok(thirdParty.has("delete")); + assert.ok(thirdParty!.has("create")); + assert.ok(thirdParty!.has("update")); + assert.ok(thirdParty!.has("delete")); }); test("thirdParty should not have a validation function for \"void\"", () => { - assert.ok(!thirdParty.has("void")); + assert.ok(!thirdParty!.has("void")); }); }); describe("AccountingEntryLettering", () => { - let accountingEntryLettering; + let accountingEntryLettering: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("accountingEntryLettering")); @@ -162,18 +162,18 @@ describe("eventsValidationFn", () => { }); test("accountingEntryLettering should have a validation function for \"create\", \"delete\"", () => { - assert.ok(accountingEntryLettering.has("create")); - assert.ok(accountingEntryLettering.has("delete")); + assert.ok(accountingEntryLettering!.has("create")); + assert.ok(accountingEntryLettering!.has("delete")); }); test("accountingEntryLettering should not have a validation function for \"update\", \"void\"", () => { - assert.ok(!accountingEntryLettering.has("update")); - assert.ok(!accountingEntryLettering.has("void")); + assert.ok(!accountingEntryLettering!.has("update")); + assert.ok(!accountingEntryLettering!.has("void")); }); }); describe("cloudDocument", () => { - let cloudDocument; + let cloudDocument: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("cloudDocument")); @@ -182,18 +182,18 @@ describe("eventsValidationFn", () => { }); test("cloudDocument should have a validation function for \"create\", \"update\"", () => { - assert.ok(cloudDocument.has("create")); - assert.ok(cloudDocument.has("update")); + assert.ok(cloudDocument!.has("create")); + assert.ok(cloudDocument!.has("update")); }); test("cloudDocument should not have a validation function for \"delete\", \"void\"", () => { - assert.ok(!cloudDocument.has("delete")); - assert.ok(!cloudDocument.has("void")); + assert.ok(!cloudDocument!.has("delete")); + assert.ok(!cloudDocument!.has("void")); }); }); describe("Exercice", () => { - let exercice; + let exercice: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("exercice")); @@ -202,18 +202,18 @@ describe("eventsValidationFn", () => { }); test("exercice should have a validation function for \"create\", \"update\", \"delete\"", () => { - assert.ok(exercice.has("create")); - assert.ok(exercice.has("update")); - assert.ok(exercice.has("delete")); + assert.ok(exercice!.has("create")); + assert.ok(exercice!.has("update")); + assert.ok(exercice!.has("delete")); }); test("exercice should not have a validation function for \"delete\", \"void\"", () => { - assert.ok(!exercice.has("void")); + assert.ok(!exercice!.has("void")); }); }); describe("visitedPage", () => { - let visitedPage; + let visitedPage: NestedValidationFunctions | undefined; before(() => { assert.ok(eventsValidationFn.has("visitedPage")); @@ -222,13 +222,13 @@ describe("eventsValidationFn", () => { }); test("exercice should have a validation function for \"void\"", () => { - assert.ok(visitedPage.has("void")); + assert.ok(visitedPage!.has("void")); }); test("exercice should not have a validation function for \"create\", \"update\", \"delete\"", () => { - assert.ok(!visitedPage.has("create")); - assert.ok(!visitedPage.has("update")); - assert.ok(!visitedPage.has("delete")); + assert.ok(!visitedPage!.has("create")); + assert.ok(!visitedPage!.has("update")); + assert.ok(!visitedPage!.has("delete")); }); }); });