From eab8f84c6cb08ed124c0a500ac34a02c0c1b578f Mon Sep 17 00:00:00 2001 From: George Enciu Date: Sat, 8 Jul 2023 21:55:27 +0200 Subject: [PATCH] training event types #1 --- libs/training-events-types/.eslintrc.json | 18 ++ libs/training-events-types/README.md | 11 ++ libs/training-events-types/package.json | 5 + libs/training-events-types/project.json | 31 ++++ .../training-events-types/src/events/index.ts | 18 ++ .../src/events/training-completed.ts | 16 ++ .../src/events/training-cpt-performed.ts | 17 ++ .../src/events/training-cpt-requested.ts | 15 ++ .../src/events/training-cpt-scheduled.ts | 15 ++ .../training-intent-confirmation-expired.ts | 13 ++ .../training-intent-confirmation-rejected.ts | 12 ++ .../training-intent-confirmation-requested.ts | 13 ++ .../training-intent-confirmation-responded.ts | 13 ++ .../src/events/training-intent.ts | 17 ++ .../src/events/training-mentor-assigned.ts | 15 ++ .../src/events/training-mentor-reassigned.ts | 15 ++ .../src/events/training-session-performed.ts | 16 ++ .../src/events/training-session-scheduled.ts | 15 ++ .../src/events/training-solo-performed.ts | 17 ++ .../src/events/training-solo-requested.ts | 15 ++ .../src/events/training-solo-scheduled.ts | 15 ++ .../src/events/training-test-assigned.ts | 15 ++ .../src/events/training-test-completed.ts | 16 ++ libs/training-events-types/src/index.ts | 2 + libs/training-events-types/src/types.ts | 158 ++++++++++++++++++ libs/training-events-types/tsconfig.json | 23 +++ libs/training-events-types/tsconfig.lib.json | 10 ++ libs/training-events-types/tsconfig.spec.json | 19 +++ libs/training-events-types/vite.config.ts | 58 +++++++ 29 files changed, 623 insertions(+) create mode 100644 libs/training-events-types/.eslintrc.json create mode 100644 libs/training-events-types/README.md create mode 100644 libs/training-events-types/package.json create mode 100644 libs/training-events-types/project.json create mode 100644 libs/training-events-types/src/events/index.ts create mode 100644 libs/training-events-types/src/events/training-completed.ts create mode 100644 libs/training-events-types/src/events/training-cpt-performed.ts create mode 100644 libs/training-events-types/src/events/training-cpt-requested.ts create mode 100644 libs/training-events-types/src/events/training-cpt-scheduled.ts create mode 100644 libs/training-events-types/src/events/training-intent-confirmation-expired.ts create mode 100644 libs/training-events-types/src/events/training-intent-confirmation-rejected.ts create mode 100644 libs/training-events-types/src/events/training-intent-confirmation-requested.ts create mode 100644 libs/training-events-types/src/events/training-intent-confirmation-responded.ts create mode 100644 libs/training-events-types/src/events/training-intent.ts create mode 100644 libs/training-events-types/src/events/training-mentor-assigned.ts create mode 100644 libs/training-events-types/src/events/training-mentor-reassigned.ts create mode 100644 libs/training-events-types/src/events/training-session-performed.ts create mode 100644 libs/training-events-types/src/events/training-session-scheduled.ts create mode 100644 libs/training-events-types/src/events/training-solo-performed.ts create mode 100644 libs/training-events-types/src/events/training-solo-requested.ts create mode 100644 libs/training-events-types/src/events/training-solo-scheduled.ts create mode 100644 libs/training-events-types/src/events/training-test-assigned.ts create mode 100644 libs/training-events-types/src/events/training-test-completed.ts create mode 100644 libs/training-events-types/src/index.ts create mode 100644 libs/training-events-types/src/types.ts create mode 100644 libs/training-events-types/tsconfig.json create mode 100644 libs/training-events-types/tsconfig.lib.json create mode 100644 libs/training-events-types/tsconfig.spec.json create mode 100644 libs/training-events-types/vite.config.ts diff --git a/libs/training-events-types/.eslintrc.json b/libs/training-events-types/.eslintrc.json new file mode 100644 index 0000000..9d9c0db --- /dev/null +++ b/libs/training-events-types/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/training-events-types/README.md b/libs/training-events-types/README.md new file mode 100644 index 0000000..e0a2e1c --- /dev/null +++ b/libs/training-events-types/README.md @@ -0,0 +1,11 @@ +# training-events-types + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build training-events-types` to build the library. + +## Running unit tests + +Run `nx test training-events-types` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/training-events-types/package.json b/libs/training-events-types/package.json new file mode 100644 index 0000000..6776b27 --- /dev/null +++ b/libs/training-events-types/package.json @@ -0,0 +1,5 @@ +{ + "name": "@rovacc/training-events-types", + "version": "0.0.1", + "type": "commonjs" +} diff --git a/libs/training-events-types/project.json b/libs/training-events-types/project.json new file mode 100644 index 0000000..aaf5b2f --- /dev/null +++ b/libs/training-events-types/project.json @@ -0,0 +1,31 @@ +{ + "name": "training-events-types", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/training-events-types/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/vite:build", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/training-events-types" + } + }, + "test": { + "executor": "@nx/vite:test", + "outputs": ["coverage/libs/training-events-types"], + "options": { + "passWithNoTests": true, + "reportsDirectory": "../../coverage/libs/training-events-types" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/training-events-types/**/*.ts"] + } + } + }, + "tags": [] +} diff --git a/libs/training-events-types/src/events/index.ts b/libs/training-events-types/src/events/index.ts new file mode 100644 index 0000000..4213ede --- /dev/null +++ b/libs/training-events-types/src/events/index.ts @@ -0,0 +1,18 @@ +export { TrainingCompletedEvent, TrainingCompletedEventData } from "./training-completed" +export { TrainingCptPerformedEvent, TrainingCptPerformedEventData } from "./training-cpt-performed" +export { TrainingCptRequestedEvent, TrainingCptRequestedEventData } from "./training-cpt-requested" +export { TrainingCptScheduledEvent, TrainingCptScheduledEventData } from "./training-cpt-scheduled" +export { TrainingIntentConfirmationExpiredEvent, TrainingIntentConfirmationExpiredEventData } from "./training-intent-confirmation-expired" +export { TrainingIntentConfirmationRejectedEvent, TrainingIntentConfirmationRejectedEventData } from "./training-intent-confirmation-rejected" +export { TrainingIntentConfirmationRequestedEvent, TrainingIntentConfirmationRequestedEventData } from "./training-intent-confirmation-requested" +export { TrainingIntentConfirmationRespondedEvent, TrainingIntentConfirmationRespondedEventData } from "./training-intent-confirmation-responded" +export { TrainingIntentEvent, TrainingIntentEventData } from "./training-intent" +export { TrainingMentorAssignedEvent, TrainingMentorAssignedEventData } from "./training-mentor-assigned" +export { TrainingMentorReassignedEvent, TrainingMentorReassignedEventData } from "./training-mentor-reassigned" +export { TrainingSessionPerformedEvent, TrainingSessionPerformedEventData } from "./training-session-performed" +export { TrainingSessionScheduledEvent, TrainingSessionScheduledEventData } from "./training-session-scheduled" +export { TrainingSoloPerformedEvent, TrainingSoloPerformedEventData } from "./training-solo-performed" +export { TrainingSoloRequestedEvent, TrainingSoloRequestedEventData } from "./training-solo-requested" +export { TrainingSoloScheduledEvent, TrainingSoloScheduledEventData } from "./training-solo-scheduled" +export { TrainingTestAssignedEvent, TrainingTestAssignedEventData } from "./training-test-assigned" +export { TrainingTestCompletedEvent, TrainingTestCompletedEventData } from "./training-test-completed" diff --git a/libs/training-events-types/src/events/training-completed.ts b/libs/training-events-types/src/events/training-completed.ts new file mode 100644 index 0000000..f56503b --- /dev/null +++ b/libs/training-events-types/src/events/training-completed.ts @@ -0,0 +1,16 @@ + +import { OutcomeReason, OutcomeReasonDetailed, TrainingEventMetadata } from "../types"; + +const name = 'training-completed' + +export type TrainingCompletedEventData = { + trainingId: string, + name: typeof name + payload: { + reason: OutcomeReason + reasonDetailed: OutcomeReasonDetailed + } +} + +export type TrainingCompletedEvent = TrainingEventMetadata & TrainingCompletedEventData + diff --git a/libs/training-events-types/src/events/training-cpt-performed.ts b/libs/training-events-types/src/events/training-cpt-performed.ts new file mode 100644 index 0000000..a909b9c --- /dev/null +++ b/libs/training-events-types/src/events/training-cpt-performed.ts @@ -0,0 +1,17 @@ + +import { Member, TrainingEventMetadata, TrainingReport } from "../types"; + +const name = 'training-cpt-performed' + +export type TrainingCptPerformedEventData = { + trainingId: string, + name: typeof name + payload: { + assessedBy: Member + report: TrainingReport + passed: boolean + } +} + +export type TrainingCptPerformedEvent = TrainingEventMetadata & TrainingCptPerformedEventData + diff --git a/libs/training-events-types/src/events/training-cpt-requested.ts b/libs/training-events-types/src/events/training-cpt-requested.ts new file mode 100644 index 0000000..c567545 --- /dev/null +++ b/libs/training-events-types/src/events/training-cpt-requested.ts @@ -0,0 +1,15 @@ + +import { Member, TrainingEventMetadata } from "../types"; + +const name = 'training-cpt-requested' + +export type TrainingCptRequestedEventData = { + trainingId: string, + name: typeof name + payload: { + requestedBy: Member + } +} + +export type TrainingCptRequestedEvent = TrainingEventMetadata & TrainingCptRequestedEventData + diff --git a/libs/training-events-types/src/events/training-cpt-scheduled.ts b/libs/training-events-types/src/events/training-cpt-scheduled.ts new file mode 100644 index 0000000..b8a404b --- /dev/null +++ b/libs/training-events-types/src/events/training-cpt-scheduled.ts @@ -0,0 +1,15 @@ + +import { TrainingEventMetadata } from "../types"; + +const name = 'training-cpt-scheduled' + +export type TrainingCptScheduledEventData = { + trainingId: string, + name: typeof name + payload: { + scheduledAt: Date + } +} + +export type TrainingCptScheduledEvent = TrainingEventMetadata & TrainingCptScheduledEventData + diff --git a/libs/training-events-types/src/events/training-intent-confirmation-expired.ts b/libs/training-events-types/src/events/training-intent-confirmation-expired.ts new file mode 100644 index 0000000..67e047c --- /dev/null +++ b/libs/training-events-types/src/events/training-intent-confirmation-expired.ts @@ -0,0 +1,13 @@ + +import { TrainingEventMetadata } from "../types"; + +const name = 'training-intent-confirmation-expired'; + +export type TrainingIntentConfirmationExpiredEventData = { + name: typeof name + trainingId: string + payload: Record +} + +export type TrainingIntentConfirmationExpiredEvent = TrainingEventMetadata & TrainingIntentConfirmationExpiredEventData + diff --git a/libs/training-events-types/src/events/training-intent-confirmation-rejected.ts b/libs/training-events-types/src/events/training-intent-confirmation-rejected.ts new file mode 100644 index 0000000..b27a381 --- /dev/null +++ b/libs/training-events-types/src/events/training-intent-confirmation-rejected.ts @@ -0,0 +1,12 @@ +import { TrainingEventMetadata } from "../types"; + +const name = 'training-intent-confirmation-rejected'; + +export type TrainingIntentConfirmationRejectedEventData = { + name: typeof name + trainingId: string + payload: Record +} + +export type TrainingIntentConfirmationRejectedEvent = TrainingEventMetadata & TrainingIntentConfirmationRejectedEventData + diff --git a/libs/training-events-types/src/events/training-intent-confirmation-requested.ts b/libs/training-events-types/src/events/training-intent-confirmation-requested.ts new file mode 100644 index 0000000..529356b --- /dev/null +++ b/libs/training-events-types/src/events/training-intent-confirmation-requested.ts @@ -0,0 +1,13 @@ + +import { TrainingEventMetadata } from "../types"; + +const name = 'training-intent-confirmation-requested'; + +export type TrainingIntentConfirmationRequestedEventData = { + name: typeof name + trainingId: string + payload: Record +} + +export type TrainingIntentConfirmationRequestedEvent = TrainingEventMetadata & TrainingIntentConfirmationRequestedEventData + diff --git a/libs/training-events-types/src/events/training-intent-confirmation-responded.ts b/libs/training-events-types/src/events/training-intent-confirmation-responded.ts new file mode 100644 index 0000000..0a000d2 --- /dev/null +++ b/libs/training-events-types/src/events/training-intent-confirmation-responded.ts @@ -0,0 +1,13 @@ + +import { TrainingEventMetadata } from "../types"; + +const name = 'training-intent-confirmation-responded'; + +export type TrainingIntentConfirmationRespondedEventData = { + name: typeof name + trainingId: string + payload: Record +} + +export type TrainingIntentConfirmationRespondedEvent = TrainingEventMetadata & TrainingIntentConfirmationRespondedEventData + diff --git a/libs/training-events-types/src/events/training-intent.ts b/libs/training-events-types/src/events/training-intent.ts new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/libs/training-events-types/src/events/training-intent.ts @@ -0,0 +1,17 @@ + +import { TrainingEventMetadata, TrainingPurpose } from "../types"; + +const name = 'training-intent'; + +export type TrainingIntentEventData = { + trainingId: string, + name: typeof name + payload: { + student: number + rating: number + purpose: TrainingPurpose + } +} + +export type TrainingIntentEvent = TrainingEventMetadata & TrainingIntentEventData + diff --git a/libs/training-events-types/src/events/training-mentor-assigned.ts b/libs/training-events-types/src/events/training-mentor-assigned.ts new file mode 100644 index 0000000..6f756a8 --- /dev/null +++ b/libs/training-events-types/src/events/training-mentor-assigned.ts @@ -0,0 +1,15 @@ +import { Member, TrainingEventMetadata } from "../types"; + +const name = 'training-mentor-assigned' + +export type TrainingMentorAssignedEventData = { + name: typeof name + trainingId: string + payload: { + mentor: Member + assignedBy: Member + } +} + +export type TrainingMentorAssignedEvent = TrainingEventMetadata & TrainingMentorAssignedEventData + diff --git a/libs/training-events-types/src/events/training-mentor-reassigned.ts b/libs/training-events-types/src/events/training-mentor-reassigned.ts new file mode 100644 index 0000000..2a81aa2 --- /dev/null +++ b/libs/training-events-types/src/events/training-mentor-reassigned.ts @@ -0,0 +1,15 @@ +import { Member, TrainingEventMetadata } from "../types"; + +const name = 'training-mentor-reassigned' + +export type TrainingMentorReassignedEventData = { + name: typeof name + trainingId: string + payload: { + mentor: Member + assignedBy: Member + } +} + +export type TrainingMentorReassignedEvent = TrainingEventMetadata & TrainingMentorReassignedEventData + diff --git a/libs/training-events-types/src/events/training-session-performed.ts b/libs/training-events-types/src/events/training-session-performed.ts new file mode 100644 index 0000000..094775d --- /dev/null +++ b/libs/training-events-types/src/events/training-session-performed.ts @@ -0,0 +1,16 @@ +import { Member, TrainingEventMetadata, TrainingReport } from "../types"; + +const name = 'training-session-performed' + +export type TrainingSessionPerformedEventData = { + name: typeof name + trainingId: string + payload: { + sessionId: string + mentor: Member, + report: TrainingReport + } +} + +export type TrainingSessionPerformedEvent = TrainingEventMetadata & TrainingSessionPerformedEventData + diff --git a/libs/training-events-types/src/events/training-session-scheduled.ts b/libs/training-events-types/src/events/training-session-scheduled.ts new file mode 100644 index 0000000..94ab674 --- /dev/null +++ b/libs/training-events-types/src/events/training-session-scheduled.ts @@ -0,0 +1,15 @@ +import { TrainingEventMetadata } from "../types"; + +const name = 'training-session-scheduled' + +export type TrainingSessionScheduledEventData = { + name: typeof name + trainingId: string + payload: { + sessionId: string + scheduledAt: Date + } +} + +export type TrainingSessionScheduledEvent = TrainingEventMetadata & TrainingSessionScheduledEventData + diff --git a/libs/training-events-types/src/events/training-solo-performed.ts b/libs/training-events-types/src/events/training-solo-performed.ts new file mode 100644 index 0000000..f0c28d1 --- /dev/null +++ b/libs/training-events-types/src/events/training-solo-performed.ts @@ -0,0 +1,17 @@ + +import { Member, TrainingEventMetadata, TrainingReport } from "../types"; + +const name = 'training-solo-performed' + +export type TrainingSoloPerformedEventData = { + trainingId: string, + name: typeof name + payload: { + requestedBy: Member + passed: boolean + report: TrainingReport + } +} + +export type TrainingSoloPerformedEvent = TrainingEventMetadata & TrainingSoloPerformedEventData + diff --git a/libs/training-events-types/src/events/training-solo-requested.ts b/libs/training-events-types/src/events/training-solo-requested.ts new file mode 100644 index 0000000..a605036 --- /dev/null +++ b/libs/training-events-types/src/events/training-solo-requested.ts @@ -0,0 +1,15 @@ + +import { Member, TrainingEventMetadata } from "../types"; + +const name = 'training-solo-requested' + +export type TrainingSoloRequestedEventData = { + trainingId: string, + name: typeof name + payload: { + requestedBy: Member + } +} + +export type TrainingSoloRequestedEvent = TrainingEventMetadata & TrainingSoloRequestedEventData + diff --git a/libs/training-events-types/src/events/training-solo-scheduled.ts b/libs/training-events-types/src/events/training-solo-scheduled.ts new file mode 100644 index 0000000..d53a183 --- /dev/null +++ b/libs/training-events-types/src/events/training-solo-scheduled.ts @@ -0,0 +1,15 @@ + +import { TrainingEventMetadata } from "../types"; + +const name = 'training-solo-scheduled' + +export type TrainingSoloScheduledEventData = { + trainingId: string, + name: typeof name + payload: { + scheduledAt: Date + } +} + +export type TrainingSoloScheduledEvent = TrainingEventMetadata & TrainingSoloScheduledEventData + diff --git a/libs/training-events-types/src/events/training-test-assigned.ts b/libs/training-events-types/src/events/training-test-assigned.ts new file mode 100644 index 0000000..af414bf --- /dev/null +++ b/libs/training-events-types/src/events/training-test-assigned.ts @@ -0,0 +1,15 @@ + +import { Member, TrainingEventMetadata } from "../types"; + +const name = 'training-test-assigned' + +export type TrainingTestAssignedEventData = { + trainingId: string, + name: typeof name + payload: { + assignedBy: Member + } +} + +export type TrainingTestAssignedEvent = TrainingEventMetadata & TrainingTestAssignedEventData + diff --git a/libs/training-events-types/src/events/training-test-completed.ts b/libs/training-events-types/src/events/training-test-completed.ts new file mode 100644 index 0000000..d5162e6 --- /dev/null +++ b/libs/training-events-types/src/events/training-test-completed.ts @@ -0,0 +1,16 @@ +import { TestResult, TrainingEventMetadata } from "../types"; + +const name = 'training-test-completed' + +export type TrainingTestCompletedEventData = { + trainingId: string, + name: typeof name + payload: { + passed: boolean + result: TestResult + willExpireAt?: Date + } +} + +export type TrainingTestCompletedEvent = TrainingEventMetadata & TrainingTestCompletedEventData + diff --git a/libs/training-events-types/src/index.ts b/libs/training-events-types/src/index.ts new file mode 100644 index 0000000..3697a17 --- /dev/null +++ b/libs/training-events-types/src/index.ts @@ -0,0 +1,2 @@ +export * from './types' +export * from './events' diff --git a/libs/training-events-types/src/types.ts b/libs/training-events-types/src/types.ts new file mode 100644 index 0000000..9f52975 --- /dev/null +++ b/libs/training-events-types/src/types.ts @@ -0,0 +1,158 @@ +import { TrainingCompletedEvent, TrainingCompletedEventData } from "./events/training-completed" +import { TrainingCptPerformedEvent, TrainingCptPerformedEventData } from "./events/training-cpt-performed" +import { TrainingCptRequestedEvent, TrainingCptRequestedEventData } from "./events/training-cpt-requested" +import { TrainingCptScheduledEvent, TrainingCptScheduledEventData } from "./events/training-cpt-scheduled" +import { TrainingIntentConfirmationExpiredEvent, TrainingIntentConfirmationExpiredEventData } from "./events/training-intent-confirmation-expired" +import { TrainingIntentConfirmationRejectedEvent, TrainingIntentConfirmationRejectedEventData } from "./events/training-intent-confirmation-rejected" +import { TrainingIntentConfirmationRequestedEvent, TrainingIntentConfirmationRequestedEventData } from "./events/training-intent-confirmation-requested" +import { TrainingIntentConfirmationRespondedEvent, TrainingIntentConfirmationRespondedEventData } from "./events/training-intent-confirmation-responded" +import { TrainingIntentEvent, TrainingIntentEventData } from "./events/training-intent" +import { TrainingMentorAssignedEvent, TrainingMentorAssignedEventData } from "./events/training-mentor-assigned" +import { TrainingMentorReassignedEvent, TrainingMentorReassignedEventData } from "./events/training-mentor-reassigned" +import { TrainingSessionPerformedEvent, TrainingSessionPerformedEventData } from "./events/training-session-performed" +import { TrainingSessionScheduledEvent, TrainingSessionScheduledEventData } from "./events/training-session-scheduled" +import { TrainingSoloPerformedEvent, TrainingSoloPerformedEventData } from "./events/training-solo-performed" +import { TrainingSoloRequestedEvent, TrainingSoloRequestedEventData } from "./events/training-solo-requested" +import { TrainingSoloScheduledEvent, TrainingSoloScheduledEventData } from "./events/training-solo-scheduled" +import { TrainingTestAssignedEvent, TrainingTestAssignedEventData } from "./events/training-test-assigned" +import { TrainingTestCompletedEvent, TrainingTestCompletedEventData } from "./events/training-test-completed" + +export type TrainingEvent = + | TrainingCompletedEvent + | TrainingCptPerformedEvent + | TrainingCptScheduledEvent + | TrainingIntentConfirmationExpiredEvent + | TrainingIntentConfirmationRejectedEvent + | TrainingIntentConfirmationRequestedEvent + | TrainingIntentConfirmationRespondedEvent + | TrainingIntentEvent + | TrainingMentorAssignedEvent + | TrainingMentorReassignedEvent + | TrainingSessionPerformedEvent + | TrainingSessionScheduledEvent + | TrainingSoloPerformedEvent + | TrainingSoloRequestedEvent + | TrainingSoloScheduledEvent + | TrainingTestAssignedEvent + | TrainingTestCompletedEvent + | TrainingCptRequestedEvent + +export type TrainingEventData = + | TrainingCompletedEventData + | TrainingCptPerformedEventData + | TrainingCptScheduledEventData + | TrainingIntentConfirmationExpiredEventData + | TrainingIntentConfirmationRejectedEventData + | TrainingIntentConfirmationRequestedEventData + | TrainingIntentConfirmationRespondedEventData + | TrainingIntentEventData + | TrainingMentorAssignedEventData + | TrainingMentorReassignedEventData + | TrainingSessionPerformedEventData + | TrainingSessionScheduledEventData + | TrainingSoloPerformedEventData + | TrainingSoloRequestedEventData + | TrainingSoloScheduledEventData + | TrainingTestAssignedEventData + | TrainingTestCompletedEventData + | TrainingCptRequestedEventData + +export type Member = { + id: number + name: string +} + +export type TrainingStatus = + | "QUEUED" + | "STARTED" + | "AWAITING_TEST" + | "IN_PROGRESS" + | "AWAITING_SOLO" + | "SOLO" + | "AWAITING_CPT" + | "COMPLETED" + | "TERMINATED" + +export type TrainingPurpose = "acquire_rating" | "revalidate_rating" | "visiting" +export type TestResult = "passed" | "failed" +export type TrainingReport = { + purpose: "cpt_ots" | "revalidation" | "training" | "sim_session" + workload: "light" | 'moderate' | 'heavy' + complexity: "routine" | "occasionally_difficult" | "mostly_difficult" | "very_difficult" + traffic: "light" | "medium" | "heavy" + comments: string +} + +export type TrainingSessions = { + scheduledAt?: Date + mentor?: Member, + report?: TrainingReport +} + +export type OutcomeReason = + | "completed" + | "terminated" + +export type OutcomeReasonDetailed = + | "rating_upgraded" + | "student_did_not_confirm_intent" + | "student_cancelled_training" + | "atsimtest_expired" + +export type Training = { + trainingId: string + status: TrainingStatus, + requestedAt?: Date + student?: number + rating?: number + purpose?: TrainingPurpose + mentor?: { + member: Member + assignedBy: Member + assignedAt: Date + } + intentConfirmation?: { + requestedAt?: Date + respondedAt?: Date + rejectedAt?: Date + expiredAt?: Date + } + test?: { + assignedAt?: Date + assignedBy?: Member + completedAt?: Date + result?: TestResult + willExpireAt?: Date + passed?: boolean + } + sessions?: Record + solo?: { + requestedAt?: Date + requestedBy?: Member + scheduledAt?: Date + performedBy?: Member + report?: TrainingReport + passed?: boolean + } + cpt?: { + requestedAt?: Date + scheduledAt?: Date + assessedBy?: Member + report?: TrainingReport + passed?: boolean + } + completedAt?: Date + outcome?: OutcomeReason + outcomeDetailed?: OutcomeReasonDetailed +} + +export type Reducer = (training: Training | null, event: T) => Training +export type IsEmitted = (training: Training | null, event: T) => boolean + +export type TrainingEventMetadata = { + eventId: string + emittedAt: Date + system: string + correlationId: string +} + diff --git a/libs/training-events-types/tsconfig.json b/libs/training-events-types/tsconfig.json new file mode 100644 index 0000000..bdf594c --- /dev/null +++ b/libs/training-events-types/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/training-events-types/tsconfig.lib.json b/libs/training-events-types/tsconfig.lib.json new file mode 100644 index 0000000..33eca2c --- /dev/null +++ b/libs/training-events-types/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/libs/training-events-types/tsconfig.spec.json b/libs/training-events-types/tsconfig.spec.json new file mode 100644 index 0000000..6d3be74 --- /dev/null +++ b/libs/training-events-types/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/libs/training-events-types/vite.config.ts b/libs/training-events-types/vite.config.ts new file mode 100644 index 0000000..ed48bf4 --- /dev/null +++ b/libs/training-events-types/vite.config.ts @@ -0,0 +1,58 @@ +/// +import { defineConfig } from 'vite'; + +import viteTsConfigPaths from 'vite-tsconfig-paths'; +import dts from 'vite-plugin-dts'; +import { joinPathFragments } from '@nx/devkit'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/training-events-types', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + + viteTsConfigPaths({ + root: '../../', + }), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ + // viteTsConfigPaths({ + // root: '../../', + // }), + // ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'training-events-types', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forgot to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: { + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + environment: 'jsdom', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + }, +});