-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: redefine IFollowupModel to be only the model (collection) interface * chore: redefine FolloupInterface to be instance (document) interface * fix: make req.followup a folloupInterface * fix: mongoose Followup definition Note: inspired by : https://medium.com/@agentwhs/complete-guide-for-typescript-for-mongoose-for-node-js-8cc0a7e470c1 * fix: use FollowupInterface when needed * feat: arange interfaces * chore: fix simulation interfaces * chore: remove useless function * feat: rename simulations that were followups
- Loading branch information
Showing
11 changed files
with
103 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,23 @@ | ||
import mongoose, { Model, HydratedDocument } from "mongoose" | ||
import { Model, HydratedDocument } from "mongoose" | ||
import { FollowupInterface } from "@lib/types/followup.d.js" | ||
import { SimulationInterface } from "@lib/types/simulation.d.js" | ||
import { SurveyType } from "@lib/enums/survey.js" | ||
|
||
export interface MongooseLayout { | ||
[id: string]: any | ||
} | ||
|
||
export interface IFollowupMethods { | ||
postSimulationResultsEmail(messageId: string): void | ||
renderSimulationResultsEmail(): any | ||
sendSimulationResultsEmail(): Promise<void> | ||
renderSurveyEmail(surveyType: SurveyType): any | ||
addSurveyIfMissing(surveyType: SurveyType): Promise<any> | ||
sendSurvey(surveyType: SurveyType): Promise<any> | ||
|
||
updateSurvey(action: SurveyType, data?: any) | ||
|
||
save() | ||
interface FollowupStaticMethods { | ||
findByEmail(email: string): Promise<HydratedDocument<FollowupInterface[]>> | ||
} | ||
|
||
export interface IFollowupModel | ||
extends Model<FollowupInterface>, | ||
FollowupInterface, | ||
IFollowupMethods { | ||
findByEmail( | ||
email: string | ||
): Promise<HydratedDocument<FollowupInterface, IFollowupMethods>> | ||
emailRenderPath: string | ||
returnPath: string | ||
surveyPath: string | ||
tousABordNotificationCta: string | ||
surveyPathTracker: string | ||
wasUsefulPath: string | ||
wasNotUsefulPath: string | ||
} | ||
export interface IFollowup | ||
extends FollowupInterface, | ||
IFollowupMethods, | ||
IFollowupModel {} | ||
FollowupStaticMethods {} | ||
|
||
export interface SimulationModel extends Model<SimulationInterface> { | ||
_id: mongoose.Types.ObjectId | ||
cookieName: string | ||
token: string | ||
returnPath: string | ||
isAccessible(keychain: Record<string, string>): boolean | ||
getSituation(): any | ||
compute(): Promise<any> | ||
findById( | ||
simulationId: mongoose.Types.ObjectId | string, | ||
callback: (error: Error, simulation: SimulationModel) => void | ||
) | ||
interface SimulationStaticMethods { | ||
cookiePrefix(): string | ||
create( | ||
data: any, | ||
callback: (error: Error, simulation: SimulationModel) => void | ||
) | ||
hasFollowup: boolean | ||
save() | ||
} | ||
|
||
export interface SimulationModel | ||
extends Model<SimulationInterface>, | ||
SimulationStaticMethods {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.