90dc-core 1.16.27 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clients/EmailClient.d.ts +15 -34
- package/dist/lib/clients/EmailClient.d.ts.map +1 -1
- package/dist/lib/clients/EmailClient.js +41 -7
- package/dist/lib/clients/EmailClient.js.map +1 -1
- package/dist/lib/clients/ImagesClient.d.ts +17 -0
- package/dist/lib/clients/ImagesClient.d.ts.map +1 -0
- package/dist/lib/clients/ImagesClient.js +116 -0
- package/dist/lib/clients/ImagesClient.js.map +1 -0
- package/dist/lib/clients/MailingClient.d.ts +21 -0
- package/dist/lib/clients/MailingClient.d.ts.map +1 -0
- package/dist/lib/clients/MailingClient.js +84 -0
- package/dist/lib/clients/MailingClient.js.map +1 -0
- package/dist/lib/clients/types/email.types.d.ts +41 -0
- package/dist/lib/clients/types/email.types.d.ts.map +1 -0
- package/dist/lib/clients/types/email.types.js +3 -0
- package/dist/lib/clients/types/email.types.js.map +1 -0
- package/dist/lib/clients/types/images.types.d.ts +21 -0
- package/dist/lib/clients/types/images.types.d.ts.map +1 -0
- package/dist/lib/clients/types/images.types.js +3 -0
- package/dist/lib/clients/types/images.types.js.map +1 -0
- package/dist/lib/clients/types/mailing.types.d.ts +10 -0
- package/dist/lib/clients/types/mailing.types.d.ts.map +1 -0
- package/dist/lib/clients/types/mailing.types.js +3 -0
- package/dist/lib/clients/types/mailing.types.js.map +1 -0
- package/dist/lib/dbmodels/program/CircularProgramDraft.d.ts +1 -0
- package/dist/lib/dbmodels/program/CircularProgramDraft.d.ts.map +1 -1
- package/dist/lib/dbmodels/program/CircularProgramDraft.js.map +1 -1
- package/dist/lib/dbmodels/program/Exercise.d.ts +1 -0
- package/dist/lib/dbmodels/program/Exercise.d.ts.map +1 -1
- package/dist/lib/dbmodels/program/Exercise.js +7 -0
- package/dist/lib/dbmodels/program/Exercise.js.map +1 -1
- package/dist/lib/dbmodels/program/ProgressEntry.d.ts +1 -0
- package/dist/lib/dbmodels/program/ProgressEntry.d.ts.map +1 -1
- package/dist/lib/dbmodels/program/ProgressEntry.js +7 -0
- package/dist/lib/dbmodels/program/ProgressEntry.js.map +1 -1
- package/dist/lib/scripts/sequelize.config.cjs +2 -1
- package/dist/lib/scripts/verify-indexes.d.ts +13 -0
- package/dist/lib/scripts/verify-indexes.d.ts.map +1 -0
- package/dist/lib/scripts/verify-indexes.js +94 -0
- package/dist/lib/scripts/verify-indexes.js.map +1 -0
- package/dist/lib/utils/NotificationClient.d.ts +7 -0
- package/dist/lib/utils/NotificationClient.d.ts.map +1 -1
- package/dist/lib/utils/NotificationClient.js +23 -0
- package/dist/lib/utils/NotificationClient.js.map +1 -1
- package/package.json +2 -1
- package/dist/lib/scripts/migrations/20250117000001-create-extensions.js +0 -21
- package/dist/lib/scripts/migrations/20250117000001-create-extensions.js.map +0 -1
- package/dist/lib/scripts/migrations/20250126000001-add-index-exercises-supersetUuid.js +0 -41
- package/dist/lib/scripts/migrations/20250126000001-add-index-exercises-supersetUuid.js.map +0 -1
- package/dist/lib/scripts/migrations/20260115000000-add-workout-session-unique-constraint.js +0 -45
- package/dist/lib/scripts/migrations/20260115000000-add-workout-session-unique-constraint.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { CommonSchemas } from "../../config/ConfigValidator.js";
|
|
3
|
+
export type Config = z.infer<typeof CommonSchemas.postmark>;
|
|
4
|
+
export interface SendTemplateEmailRequest {
|
|
5
|
+
to: string | string[];
|
|
6
|
+
templateAlias: string | number;
|
|
7
|
+
templateModel: Record<string, any>;
|
|
8
|
+
cc?: string | string[];
|
|
9
|
+
bcc?: string | string[];
|
|
10
|
+
replyTo?: string;
|
|
11
|
+
tag?: string;
|
|
12
|
+
metadata?: Record<string, string>;
|
|
13
|
+
trackOpens?: boolean;
|
|
14
|
+
trackLinks?: "None" | "HtmlAndText" | "HtmlOnly" | "TextOnly";
|
|
15
|
+
}
|
|
16
|
+
export interface BatchTemplateEmailRequest {
|
|
17
|
+
emails: Array<{
|
|
18
|
+
to: string;
|
|
19
|
+
templateAlias: string | number;
|
|
20
|
+
templateModel: Record<string, any>;
|
|
21
|
+
tag?: string;
|
|
22
|
+
metadata?: Record<string, string>;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface SendEmailRequest {
|
|
26
|
+
to: string;
|
|
27
|
+
subject: string;
|
|
28
|
+
textBody: string;
|
|
29
|
+
htmlBody?: string;
|
|
30
|
+
tag?: string;
|
|
31
|
+
metadata?: Record<string, string>;
|
|
32
|
+
replyTo?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface EmailResponse {
|
|
35
|
+
messageId: string;
|
|
36
|
+
to: string;
|
|
37
|
+
submittedAt: string;
|
|
38
|
+
errorCode?: number;
|
|
39
|
+
message?: string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=email.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/clients/types/email.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;CAC/D;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;QAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/clients/types/email.types.ts"],"sourcesContent":["import type { z } from \"zod\";\nimport type { CommonSchemas } from \"../../config/ConfigValidator.js\";\n\nexport type Config = z.infer<typeof CommonSchemas.postmark>;\n\nexport interface SendTemplateEmailRequest {\n to: string | string[];\n templateAlias: string | number;\n templateModel: Record<string, any>;\n cc?: string | string[];\n bcc?: string | string[];\n replyTo?: string;\n tag?: string;\n metadata?: Record<string, string>;\n trackOpens?: boolean;\n trackLinks?: \"None\" | \"HtmlAndText\" | \"HtmlOnly\" | \"TextOnly\";\n}\n\nexport interface BatchTemplateEmailRequest {\n emails: Array<{\n to: string;\n templateAlias: string | number;\n templateModel: Record<string, any>;\n tag?: string;\n metadata?: Record<string, string>;\n }>;\n}\n\nexport interface SendEmailRequest {\n to: string;\n subject: string;\n textBody: string;\n htmlBody?: string;\n tag?: string;\n metadata?: Record<string, string>;\n replyTo?: string;\n}\n\nexport interface EmailResponse {\n messageId: string;\n to: string;\n submittedAt: string;\n errorCode?: number;\n message?: string;\n}\n"],"names":[],"mappings":"AAsCA,WAMC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type admin from "firebase-admin";
|
|
2
|
+
export interface Config {
|
|
3
|
+
storageBucket: string;
|
|
4
|
+
firebaseApp?: admin.app.App;
|
|
5
|
+
}
|
|
6
|
+
export interface ProgressPhoto {
|
|
7
|
+
day: number;
|
|
8
|
+
base64: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RecipePhotos {
|
|
11
|
+
ingredientBase64: string;
|
|
12
|
+
coverBase64: string;
|
|
13
|
+
methodBase64: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SaveRecipePhotosInput {
|
|
16
|
+
recipeUuid: string;
|
|
17
|
+
ingredientBase64: string;
|
|
18
|
+
coverBase64: string;
|
|
19
|
+
methodBase64: string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=images.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/clients/types/images.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,MAAM;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/clients/types/images.types.ts"],"sourcesContent":["import type admin from \"firebase-admin\";\n\nexport interface Config {\n storageBucket: string;\n firebaseApp?: admin.app.App;\n}\n\nexport interface ProgressPhoto {\n day: number;\n base64: string;\n}\n\nexport interface RecipePhotos {\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n\nexport interface SaveRecipePhotosInput {\n recipeUuid: string;\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n"],"names":[],"mappings":"AAkBA,WAKC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EmailClient } from "../EmailClient.js";
|
|
2
|
+
export interface Config {
|
|
3
|
+
emailClient: EmailClient;
|
|
4
|
+
receiverEmail: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ShopifyEmailInput {
|
|
7
|
+
email: string;
|
|
8
|
+
password: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=mailing.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailing.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/clients/types/mailing.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,MAAM;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/clients/types/mailing.types.ts"],"sourcesContent":["import type { EmailClient } from \"../EmailClient.js\";\n\nexport interface Config {\n emailClient: EmailClient;\n receiverEmail: string;\n}\n\nexport interface ShopifyEmailInput {\n email: string;\n password: string;\n}\n"],"names":[],"mappings":"AAOA,WAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircularProgramDraft.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/program/CircularProgramDraft.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EAMN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,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ircularProgramDraft.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n Default,\n ForeignKey,\n Index,\n BelongsTo,\n} from \"sequelize-typescript\";\nimport { Program } from \"./Program.js\";\nimport { CustomProgramBlueprint } from \"./CustomProgramBlueprint.js\";\n\nexport type DraftStatus = \"draft\" | \"published\" | \"archived\";\n\nexport interface DraftExercise {\n uuid: string;\n name: string;\n sets: number;\n reps: string;\n order: number;\n restTime?: string | number | null;\n supersetUuid?: string | null;\n thumbnailUrl?: string | null;\n coachNote?: string | null;\n}\n\nexport interface DraftSuperset {\n uuid: string;\n startPosition: number;\n exercises: Omit<DraftExercise, \"supersetUuid\">[];\n}\n\nexport interface DraftWorkout {\n uuid: string;\n title: string;\n duration: string;\n order: number;\n exercises: DraftExercise[];\n supersets: DraftSuperset[];\n}\n\nexport interface DraftRestDay {\n uuid: string;\n order: number;\n}\n\nexport interface DraftStrengthTestExercise {\n uuid: string;\n title: string;\n url: string;\n pointer: string;\n timerTime: string;\n order: number;\n}\n\nexport interface DraftStrengthTest {\n uuid: string;\n type: string;\n order: number;\n exercises: DraftStrengthTestExercise[];\n}\n\nexport interface DraftChallenge {\n uuid: string;\n title: string;\n order: number;\n progress: any[];\n}\n\n// Individual day types for internal use\nexport interface DraftDay {\n uuid: string;\n type: \"Workout\" | \"ActiveRestDay\" | \"StrengthTest\" | \"Challenge\";\n templateIndex: number; // order in the program sequence\n isFinished?: boolean;\n\n // Workout-specific fields\n title?: string;\n duration?: string;\n order?: number; // workout order (same as templateIndex)\n programId?: string; // reference to program\n exercise?: DraftExercise[];\n superset?: DraftSuperset[];\n\n // StrengthTest-specific fields\n strengthTestExercise?: DraftStrengthTestExercise[];\n\n // Challenge-specific fields\n progress?: any[];\n restDayUuid?: string;\n}\n\n// Main draft data structure - matches getUniqueProgram format\nexport interface CircularProgramDraftData {\n startDate: string;\n days: DraftDay[]; // Flat array of all days, sorted by templateIndex\n}\n\n@Table({ tableName: \"CircularProgramDrafts\", timestamps: true })\nexport class CircularProgramDraft extends Model {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n allowNull: false,\n })\n declare uuid: string;\n\n @ForeignKey(() => CustomProgramBlueprint)\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare blueprintUuid: string | null;\n\n @ForeignKey(() => Program)\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare publishedProgramId: string | null;\n\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare userUuid: string;\n\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare createdByCoachUuid: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n declare draftData: CircularProgramDraftData;\n\n @Index\n @Column({\n type: DataType.ENUM(\"draft\", \"published\", \"archived\"),\n allowNull: false,\n defaultValue: \"draft\",\n })\n declare status: DraftStatus;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare publishedAt: Date | null;\n\n @BelongsTo(() => CustomProgramBlueprint)\n declare blueprint: CustomProgramBlueprint;\n\n @BelongsTo(() => Program)\n declare publishedProgram: Program;\n}\n"],"names":["Table","Column","Model","DataType","Default","ForeignKey","Index","BelongsTo","Program","CustomProgramBlueprint","CircularProgramDraft","UUIDV4","type","UUID","primaryKey","allowNull","JSONB","ENUM","defaultValue","DATE","tableName","timestamps"],"mappings":";;;;;;AAAA,SACEA,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,SAAS,QACJ,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,sBAAsB,QAAQ,8BAA8B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/dbmodels/program/CircularProgramDraft.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n Default,\n ForeignKey,\n Index,\n BelongsTo,\n} from \"sequelize-typescript\";\nimport { Program } from \"./Program.js\";\nimport { CustomProgramBlueprint } from \"./CustomProgramBlueprint.js\";\n\nexport type DraftStatus = \"draft\" | \"published\" | \"archived\";\n\nexport interface DraftExercise {\n uuid: string;\n name: string;\n sets: number;\n reps: string;\n order: number;\n exerciseModelUuid: string;\n restTime?: string | number | null;\n supersetUuid?: string | null;\n thumbnailUrl?: string | null;\n coachNote?: string | null;\n}\n\nexport interface DraftSuperset {\n uuid: string;\n startPosition: number;\n exercises: Omit<DraftExercise, \"supersetUuid\">[];\n}\n\nexport interface DraftWorkout {\n uuid: string;\n title: string;\n duration: string;\n order: number;\n exercises: DraftExercise[];\n supersets: DraftSuperset[];\n}\n\nexport interface DraftRestDay {\n uuid: string;\n order: number;\n}\n\nexport interface DraftStrengthTestExercise {\n uuid: string;\n title: string;\n url: string;\n pointer: string;\n timerTime: string;\n order: number;\n}\n\nexport interface DraftStrengthTest {\n uuid: string;\n type: string;\n order: number;\n exercises: DraftStrengthTestExercise[];\n}\n\nexport interface DraftChallenge {\n uuid: string;\n title: string;\n order: number;\n progress: any[];\n}\n\n// Individual day types for internal use\nexport interface DraftDay {\n uuid: string;\n type: \"Workout\" | \"ActiveRestDay\" | \"StrengthTest\" | \"Challenge\";\n templateIndex: number; // order in the program sequence\n isFinished?: boolean;\n\n // Workout-specific fields\n title?: string;\n duration?: string;\n order?: number; // workout order (same as templateIndex)\n programId?: string; // reference to program\n exercise?: DraftExercise[];\n superset?: DraftSuperset[];\n\n // StrengthTest-specific fields\n strengthTestExercise?: DraftStrengthTestExercise[];\n\n // Challenge-specific fields\n progress?: any[];\n restDayUuid?: string;\n}\n\n// Main draft data structure - matches getUniqueProgram format\nexport interface CircularProgramDraftData {\n startDate: string;\n days: DraftDay[]; // Flat array of all days, sorted by templateIndex\n}\n\n@Table({ tableName: \"CircularProgramDrafts\", timestamps: true })\nexport class CircularProgramDraft extends Model {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n allowNull: false,\n })\n declare uuid: string;\n\n @ForeignKey(() => CustomProgramBlueprint)\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare blueprintUuid: string | null;\n\n @ForeignKey(() => Program)\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare publishedProgramId: string | null;\n\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare userUuid: string;\n\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare createdByCoachUuid: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n declare draftData: CircularProgramDraftData;\n\n @Index\n @Column({\n type: DataType.ENUM(\"draft\", \"published\", \"archived\"),\n allowNull: false,\n defaultValue: \"draft\",\n })\n declare status: DraftStatus;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare publishedAt: Date | null;\n\n @BelongsTo(() => CustomProgramBlueprint)\n declare blueprint: CustomProgramBlueprint;\n\n @BelongsTo(() => Program)\n declare publishedProgram: Program;\n}\n"],"names":["Table","Column","Model","DataType","Default","ForeignKey","Index","BelongsTo","Program","CustomProgramBlueprint","CircularProgramDraft","UUIDV4","type","UUID","primaryKey","allowNull","JSONB","ENUM","defaultValue","DATE","tableName","timestamps"],"mappings":";;;;;;AAAA,SACEA,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,SAAS,QACJ,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,sBAAsB,QAAQ,8BAA8B;AA0FrE,OAAO,MAAMC,6BAA6BR;AA+D1C;;qBA9DoBS;;QAEhBC,MAAMT,SAASU,IAAI;QACnBC,YAAY;QACZC,WAAW;;;;mBAIKN;;QAEhBG,MAAMT,SAASU,IAAI;QACnBE,WAAW;;;;mBAIKP;;;QAGhBI,MAAMT,SAASU,IAAI;QACnBE,WAAW;;;;;;QAMXH,MAAMT,SAASU,IAAI;QACnBE,WAAW;;;;;;QAMXH,MAAMT,SAASU,IAAI;QACnBE,WAAW;;;;;QAKXH,MAAMT,SAASa,KAAK;QACpBD,WAAW;;;;;;QAMXH,MAAMT,SAASc,IAAI,CAAC,SAAS,aAAa;QAC1CF,WAAW;QACXG,cAAc;;;;;QAKdN,MAAMT,SAASgB,IAAI;QACnBJ,WAAW;;;;kBAIIN;;;kBAGAD;;;;QA9DVY,WAAW;QAAyBC,YAAY"}
|
|
@@ -5,6 +5,7 @@ import { ProgressEntry } from './ProgressEntry.js';
|
|
|
5
5
|
import type { Progress } from '../../models/ExerciseInterfaces.js';
|
|
6
6
|
export declare class Exercise extends Model<Exercise> {
|
|
7
7
|
uuid: string;
|
|
8
|
+
exerciseModelUuid?: string;
|
|
8
9
|
name: string;
|
|
9
10
|
order: number;
|
|
10
11
|
progress: Progress[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Exercise.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/program/Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAA4D,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAEnE,qBACa,QAAS,SAAQ,KAAK,CAAC,QAAQ,CAAC;IAMnC,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Exercise.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/program/Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAA4D,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAEnE,qBACa,QAAS,SAAQ,KAAK,CAAC,QAAQ,CAAC;IAMnC,IAAI,EAAE,MAAM,CAAC;IAKb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAId,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAGrB,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,MAAM,CAAC;IAGjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAK5B,WAAW,EAAE,MAAM,CAAC;IAKpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,eAAe,EAAE,aAAa,EAAE,CAAC;IAGjC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE1B,OAAO,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -17,6 +17,13 @@ _ts_decorate([
|
|
|
17
17
|
primaryKey: true
|
|
18
18
|
})
|
|
19
19
|
], Exercise.prototype, "uuid", void 0);
|
|
20
|
+
_ts_decorate([
|
|
21
|
+
Index,
|
|
22
|
+
Column({
|
|
23
|
+
type: DataType.UUID,
|
|
24
|
+
allowNull: true
|
|
25
|
+
})
|
|
26
|
+
], Exercise.prototype, "exerciseModelUuid", void 0);
|
|
20
27
|
_ts_decorate([
|
|
21
28
|
Column({
|
|
22
29
|
type: DataType.STRING,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/dbmodels/program/Exercise.ts"],"sourcesContent":["import { Table, Column, Model, ForeignKey, Index, DataType, Default, HasMany, BelongsTo } from 'sequelize-typescript';\nimport { Workout } from './Workout.js';\nimport { Superset } from './Superset.js';\nimport { ProgressEntry } from './ProgressEntry.js';\nimport type { Progress } from '../../models/ExerciseInterfaces.js';\n\n@Table\nexport class Exercise extends Model<Exercise> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n })\n declare uuid: string;\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare name: string;\n\n @Column({ type: DataType.INTEGER, allowNull: false })\n declare order: number;\n\n // DEPRECATED: Keep for backward compatibility during migration\n @Column({ type: DataType.ARRAY(DataType.JSONB), allowNull: true })\n declare progress: Progress[];\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare reps: string;\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare sets: string;\n\n @Column({ type: DataType.STRING, allowNull: true })\n declare restTime: string;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare coachNote: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare thumbnailUrl: string | null;\n\n @Index\n @ForeignKey(() => Workout)\n @Column({ type: DataType.UUID, allowNull: false })\n declare workoutUuid: string;\n\n @Index\n @ForeignKey(() => Superset)\n @Column({ type: DataType.UUID, allowNull: true })\n declare supersetUuid: string | null;\n\n @HasMany(() => ProgressEntry)\n declare progressEntries: ProgressEntry[];\n\n @BelongsTo(() => Superset)\n declare superset: Superset | null;\n\n declare workout: Workout;\n}\n"],"names":["Table","Column","Model","ForeignKey","Index","DataType","Default","HasMany","BelongsTo","Workout","Superset","ProgressEntry","Exercise","UUIDV4","type","UUID","primaryKey","
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/dbmodels/program/Exercise.ts"],"sourcesContent":["import { Table, Column, Model, ForeignKey, Index, DataType, Default, HasMany, BelongsTo } from 'sequelize-typescript';\nimport { Workout } from './Workout.js';\nimport { Superset } from './Superset.js';\nimport { ProgressEntry } from './ProgressEntry.js';\nimport type { Progress } from '../../models/ExerciseInterfaces.js';\n\n@Table\nexport class Exercise extends Model<Exercise> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n })\n declare uuid: string;\n\n // Programs v2: Reference to ExerciseModel for latest video/instructions\n @Index\n @Column({ type: DataType.UUID, allowNull: true })\n declare exerciseModelUuid?: string;\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare name: string;\n\n @Column({ type: DataType.INTEGER, allowNull: false })\n declare order: number;\n\n // DEPRECATED: Keep for backward compatibility during migration\n @Column({ type: DataType.ARRAY(DataType.JSONB), allowNull: true })\n declare progress: Progress[];\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare reps: string;\n\n @Column({ type: DataType.STRING, allowNull: false })\n declare sets: string;\n\n @Column({ type: DataType.STRING, allowNull: true })\n declare restTime: string;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare coachNote: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare thumbnailUrl: string | null;\n\n @Index\n @ForeignKey(() => Workout)\n @Column({ type: DataType.UUID, allowNull: false })\n declare workoutUuid: string;\n\n @Index\n @ForeignKey(() => Superset)\n @Column({ type: DataType.UUID, allowNull: true })\n declare supersetUuid: string | null;\n\n @HasMany(() => ProgressEntry)\n declare progressEntries: ProgressEntry[];\n\n @BelongsTo(() => Superset)\n declare superset: Superset | null;\n\n declare workout: Workout;\n}\n"],"names":["Table","Column","Model","ForeignKey","Index","DataType","Default","HasMany","BelongsTo","Workout","Superset","ProgressEntry","Exercise","UUIDV4","type","UUID","primaryKey","allowNull","STRING","INTEGER","ARRAY","JSONB","TEXT"],"mappings":";;;;;;AAAA,SAASA,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,SAAS,QAAQ,uBAAuB;AACtH,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,aAAa,QAAQ,qBAAqB;AAInD,OAAO,MAAMC,iBAAiBV;AAuD9B;;qBAtDoBW;;QAEhBC,MAAMT,SAASU,IAAI;QACnBC,YAAY;;;;;;QAMJF,MAAMT,SAASU,IAAI;QAAEE,WAAW;;;;;QAGhCH,MAAMT,SAASa,MAAM;QAAED,WAAW;;;;;QAGlCH,MAAMT,SAASc,OAAO;QAAEF,WAAW;;;;;QAInCH,MAAMT,SAASe,KAAK,CAACf,SAASgB,KAAK;QAAGJ,WAAW;;;;;QAGjDH,MAAMT,SAASa,MAAM;QAAED,WAAW;;;;;QAGlCH,MAAMT,SAASa,MAAM;QAAED,WAAW;;;;;QAGlCH,MAAMT,SAASa,MAAM;QAAED,WAAW;;;;;QAGlCH,MAAMT,SAASiB,IAAI;QAAEL,WAAW;;;;;QAGhCH,MAAMT,SAASa,MAAM,CAAC;QAAMD,WAAW;;;;;mBAI/BR;;QACRK,MAAMT,SAASU,IAAI;QAAEE,WAAW;;;;;mBAIxBP;;QACRI,MAAMT,SAASU,IAAI;QAAEE,WAAW;;;;gBAG3BN;;;kBAGED"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressEntry.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/program/ProgressEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAkD,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC,oBAAY,iBAAiB;IACzB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACtB;AAED,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,qBACa,aAAc,SAAQ,KAAK,CAAC,aAAa,CAAC;IAM3C,IAAI,EAAE,MAAM,CAAC;IAQb,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressEntry.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/program/ProgressEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAkD,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC,oBAAY,iBAAiB;IACzB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACtB;AAED,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,qBACa,aAAc,SAAQ,KAAK,CAAC,aAAa,CAAC;IAM3C,IAAI,EAAE,MAAM,CAAC;IAQb,YAAY,EAAE,MAAM,CAAC;IAQrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,UAAU,EAAE,IAAI,CAAC;IAOjB,SAAS,EAAE,MAAM,CAAC;IAOlB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAM7B,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC;IAG5C,QAAQ,EAAE,QAAQ,CAAC;CAC9B"}
|
|
@@ -31,6 +31,13 @@ _ts_decorate([
|
|
|
31
31
|
allowNull: false
|
|
32
32
|
})
|
|
33
33
|
], ProgressEntry.prototype, "exerciseUuid", void 0);
|
|
34
|
+
_ts_decorate([
|
|
35
|
+
Index,
|
|
36
|
+
Column({
|
|
37
|
+
type: DataType.UUID,
|
|
38
|
+
allowNull: true
|
|
39
|
+
})
|
|
40
|
+
], ProgressEntry.prototype, "exerciseModelUuid", void 0);
|
|
34
41
|
_ts_decorate([
|
|
35
42
|
Index,
|
|
36
43
|
Column({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/dbmodels/program/ProgressEntry.ts"],"sourcesContent":["import {Table, Column, Model, ForeignKey, Index, DataType, Default, BelongsTo} from 'sequelize-typescript';\nimport {Exercise} from \"./Exercise.js\";\n\nexport enum ProgressFieldType {\n NUMBER = 'number',\n TEXT = 'text',\n SELECT = 'select',\n TIME = 'time',\n BOOLEAN = 'boolean'\n}\n\nexport interface ProgressFieldValue {\n fieldName: string;\n fieldType: ProgressFieldType;\n value: string | number | boolean;\n options?: string[];\n}\n\n@Table({ timestamps: true })\nexport class ProgressEntry extends Model<ProgressEntry> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n })\n declare uuid: string;\n\n @Index\n @ForeignKey(() => Exercise)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare exerciseUuid: string;\n\n @Index\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare recordedAt: Date;\n\n @Column({\n type: DataType.INTEGER,\n allowNull: false,\n defaultValue: 1,\n })\n declare setNumber: number;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: [],\n })\n declare fields: ProgressFieldValue[];\n\n @Column({\n type: DataType.STRING,\n allowNull: true,\n })\n declare metricSystem?: 'Metric' | 'Imperial' | null;\n\n @BelongsTo(() => Exercise)\n declare exercise: Exercise;\n}\n"],"names":["Table","Column","Model","ForeignKey","Index","DataType","Default","BelongsTo","Exercise","ProgressFieldType","ProgressEntry","UUIDV4","type","UUID","primaryKey","allowNull","DATE","INTEGER","defaultValue","JSONB","STRING","timestamps"],"mappings":";;;;;;AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAO,uBAAuB;AAC3G,SAAQC,QAAQ,QAAO,gBAAgB;AAEvC,OAAO,IAAA,AAAKC,2CAAAA;;;;;;WAAAA;MAMX;AAUD,OAAO,MAAMC,sBAAsBR;
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/dbmodels/program/ProgressEntry.ts"],"sourcesContent":["import {Table, Column, Model, ForeignKey, Index, DataType, Default, BelongsTo} from 'sequelize-typescript';\nimport {Exercise} from \"./Exercise.js\";\n\nexport enum ProgressFieldType {\n NUMBER = 'number',\n TEXT = 'text',\n SELECT = 'select',\n TIME = 'time',\n BOOLEAN = 'boolean'\n}\n\nexport interface ProgressFieldValue {\n fieldName: string;\n fieldType: ProgressFieldType;\n value: string | number | boolean;\n options?: string[];\n}\n\n@Table({ timestamps: true })\nexport class ProgressEntry extends Model<ProgressEntry> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n primaryKey: true,\n })\n declare uuid: string;\n\n @Index\n @ForeignKey(() => Exercise)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare exerciseUuid: string;\n\n // Programs v2: Reference to ExerciseModel for historical aggregation\n @Index\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare exerciseModelUuid?: string;\n\n @Index\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare recordedAt: Date;\n\n @Column({\n type: DataType.INTEGER,\n allowNull: false,\n defaultValue: 1,\n })\n declare setNumber: number;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: [],\n })\n declare fields: ProgressFieldValue[];\n\n @Column({\n type: DataType.STRING,\n allowNull: true,\n })\n declare metricSystem?: 'Metric' | 'Imperial' | null;\n\n @BelongsTo(() => Exercise)\n declare exercise: Exercise;\n}\n"],"names":["Table","Column","Model","ForeignKey","Index","DataType","Default","BelongsTo","Exercise","ProgressFieldType","ProgressEntry","UUIDV4","type","UUID","primaryKey","allowNull","DATE","INTEGER","defaultValue","JSONB","STRING","timestamps"],"mappings":";;;;;;AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAO,uBAAuB;AAC3G,SAAQC,QAAQ,QAAO,gBAAgB;AAEvC,OAAO,IAAA,AAAKC,2CAAAA;;;;;;WAAAA;MAMX;AAUD,OAAO,MAAMC,sBAAsBR;AAqDnC;;qBApDsBS;;QAEdC,MAAMP,SAASQ,IAAI;QACnBC,YAAY;;;;;mBAKEN;;QAEdI,MAAMP,SAASQ,IAAI;QACnBE,WAAW;;;;;;QAOXH,MAAMP,SAASQ,IAAI;QACnBE,WAAW;;;;;;QAMXH,MAAMP,SAASW,IAAI;QACnBD,WAAW;;;;;QAKXH,MAAMP,SAASY,OAAO;QACtBF,WAAW;QACXG,cAAc;;;;;QAKdN,MAAMP,SAASc,KAAK;QACpBJ,WAAW;QACXG,cAAc,EAAE;;;;;QAKhBN,MAAMP,SAASe,MAAM;QACrBL,WAAW;;;;kBAIEP;;;;QApDZa,YAAY"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Sequelize CLI Configuration for Migrations and Seeders
|
|
2
2
|
// This config is used by sequelize-cli for running migrations and seeders
|
|
3
3
|
|
|
4
|
-
require('
|
|
4
|
+
const path = require('path');
|
|
5
|
+
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
7
8
|
development: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verification Script: Check if exerciseModelUuid indexes exist
|
|
3
|
+
*
|
|
4
|
+
* Purpose: Verify that the indexes from migrations 20260312000001 and 20260312000002 have been applied
|
|
5
|
+
*
|
|
6
|
+
* Expected Indexes:
|
|
7
|
+
* 1. exercises_exercise_model_uuid_idx on Exercises(exerciseModelUuid)
|
|
8
|
+
* 2. progress_entries_exercise_model_uuid_recorded_at_idx on ProgressEntries(exerciseModelUuid, recordedAt)
|
|
9
|
+
*
|
|
10
|
+
* Run: npx tsx src/lib/scripts/verify-indexes.ts
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=verify-indexes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-indexes.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/verify-indexes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verification Script: Check if exerciseModelUuid indexes exist
|
|
3
|
+
*
|
|
4
|
+
* Purpose: Verify that the indexes from migrations 20260312000001 and 20260312000002 have been applied
|
|
5
|
+
*
|
|
6
|
+
* Expected Indexes:
|
|
7
|
+
* 1. exercises_exercise_model_uuid_idx on Exercises(exerciseModelUuid)
|
|
8
|
+
* 2. progress_entries_exercise_model_uuid_recorded_at_idx on ProgressEntries(exerciseModelUuid, recordedAt)
|
|
9
|
+
*
|
|
10
|
+
* Run: npx tsx src/lib/scripts/verify-indexes.ts
|
|
11
|
+
*/ import { Sequelize } from "sequelize";
|
|
12
|
+
import dotenv from "dotenv";
|
|
13
|
+
import path from "path";
|
|
14
|
+
import { fileURLToPath } from "url";
|
|
15
|
+
// ES module __dirname workaround
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
// Load environment variables
|
|
19
|
+
dotenv.config({
|
|
20
|
+
path: path.resolve(__dirname, '../../../.env')
|
|
21
|
+
});
|
|
22
|
+
const sequelize = new Sequelize({
|
|
23
|
+
username: process.env.DB_USER || 'postgres',
|
|
24
|
+
password: process.env.DB_PASSWORD || 'password',
|
|
25
|
+
database: process.env.DB_NAME || '90dc',
|
|
26
|
+
host: process.env.DB_HOST || 'localhost',
|
|
27
|
+
port: Number(process.env.DB_PORT) || 5432,
|
|
28
|
+
dialect: 'postgres',
|
|
29
|
+
logging: false
|
|
30
|
+
});
|
|
31
|
+
async function verifyIndexes() {
|
|
32
|
+
try {
|
|
33
|
+
console.log('🔍 Checking exerciseModelUuid indexes...\n');
|
|
34
|
+
// Query to get all indexes on Exercises and ProgressEntries tables
|
|
35
|
+
const query = `
|
|
36
|
+
SELECT
|
|
37
|
+
tablename,
|
|
38
|
+
indexname,
|
|
39
|
+
indexdef
|
|
40
|
+
FROM pg_indexes
|
|
41
|
+
WHERE tablename IN ('Exercises', 'ProgressEntries')
|
|
42
|
+
AND indexname LIKE '%exercise_model_uuid%'
|
|
43
|
+
ORDER BY tablename, indexname;
|
|
44
|
+
`;
|
|
45
|
+
const indexes = await sequelize.query(query, {
|
|
46
|
+
type: 'SELECT'
|
|
47
|
+
});
|
|
48
|
+
if (indexes.length === 0) {
|
|
49
|
+
console.log('❌ NO exerciseModelUuid INDEXES FOUND');
|
|
50
|
+
console.log('\nRequired migrations have NOT been applied.');
|
|
51
|
+
console.log('Run: npm run db:migrate\n');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
console.log(`✅ Found ${indexes.length} exerciseModelUuid index(es):\n`);
|
|
55
|
+
const expectedIndexes = {
|
|
56
|
+
exercises_exercise_model_uuid_idx: false,
|
|
57
|
+
progress_entries_exercise_model_uuid_recorded_at_idx: false
|
|
58
|
+
};
|
|
59
|
+
for (const index of indexes){
|
|
60
|
+
console.log(` 📊 ${index.tablename}:`);
|
|
61
|
+
console.log(` Index: ${index.indexname}`);
|
|
62
|
+
console.log(` Definition: ${index.indexdef}`);
|
|
63
|
+
console.log('');
|
|
64
|
+
// Mark expected indexes as found
|
|
65
|
+
if (index.indexname in expectedIndexes) {
|
|
66
|
+
expectedIndexes[index.indexname] = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Check if all expected indexes exist
|
|
70
|
+
const missingIndexes = Object.entries(expectedIndexes).filter(([_, exists])=>!exists).map(([name])=>name);
|
|
71
|
+
if (missingIndexes.length > 0) {
|
|
72
|
+
console.log('⚠️ MISSING INDEXES:');
|
|
73
|
+
missingIndexes.forEach((name)=>{
|
|
74
|
+
console.log(` - ${name}`);
|
|
75
|
+
});
|
|
76
|
+
console.log('\nRun: npm run db:migrate\n');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
console.log('✅ ALL REQUIRED INDEXES EXIST');
|
|
80
|
+
console.log('\nPerformance optimization: COMPLETE');
|
|
81
|
+
console.log('Expected query performance:');
|
|
82
|
+
console.log(' - Progress by exerciseModelUuid: ~5ms (was ~5000ms)');
|
|
83
|
+
console.log(' - Exercise lookups: ~2ms (was ~200ms)');
|
|
84
|
+
await sequelize.close();
|
|
85
|
+
process.exit(0);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('❌ Error checking indexes:', error);
|
|
88
|
+
await sequelize.close();
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
verifyIndexes();
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=verify-indexes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/scripts/verify-indexes.ts"],"sourcesContent":["/**\n * Verification Script: Check if exerciseModelUuid indexes exist\n *\n * Purpose: Verify that the indexes from migrations 20260312000001 and 20260312000002 have been applied\n *\n * Expected Indexes:\n * 1. exercises_exercise_model_uuid_idx on Exercises(exerciseModelUuid)\n * 2. progress_entries_exercise_model_uuid_recorded_at_idx on ProgressEntries(exerciseModelUuid, recordedAt)\n *\n * Run: npx tsx src/lib/scripts/verify-indexes.ts\n */\n\nimport { Sequelize } from 'sequelize';\nimport dotenv from 'dotenv';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\n// ES module __dirname workaround\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Load environment variables\ndotenv.config({ path: path.resolve(__dirname, '../../../.env') });\n\nconst sequelize = new Sequelize({\n username: process.env.DB_USER || 'postgres',\n password: process.env.DB_PASSWORD || 'password',\n database: process.env.DB_NAME || '90dc',\n host: process.env.DB_HOST || 'localhost',\n port: Number(process.env.DB_PORT) || 5432,\n dialect: 'postgres',\n logging: false,\n});\n\ninterface IndexInfo {\n tablename: string;\n indexname: string;\n indexdef: string;\n}\n\nasync function verifyIndexes() {\n try {\n console.log('🔍 Checking exerciseModelUuid indexes...\\n');\n\n // Query to get all indexes on Exercises and ProgressEntries tables\n const query = `\n SELECT\n tablename,\n indexname,\n indexdef\n FROM pg_indexes\n WHERE tablename IN ('Exercises', 'ProgressEntries')\n AND indexname LIKE '%exercise_model_uuid%'\n ORDER BY tablename, indexname;\n `;\n\n const indexes = await sequelize.query(query, {\n type: 'SELECT',\n }) as IndexInfo[];\n\n if (indexes.length === 0) {\n console.log('❌ NO exerciseModelUuid INDEXES FOUND');\n console.log('\\nRequired migrations have NOT been applied.');\n console.log('Run: npm run db:migrate\\n');\n process.exit(1);\n }\n\n console.log(`✅ Found ${indexes.length} exerciseModelUuid index(es):\\n`);\n\n const expectedIndexes = {\n exercises_exercise_model_uuid_idx: false,\n progress_entries_exercise_model_uuid_recorded_at_idx: false,\n };\n\n for (const index of indexes) {\n console.log(` 📊 ${index.tablename}:`);\n console.log(` Index: ${index.indexname}`);\n console.log(` Definition: ${index.indexdef}`);\n console.log('');\n\n // Mark expected indexes as found\n if (index.indexname in expectedIndexes) {\n expectedIndexes[index.indexname as keyof typeof expectedIndexes] = true;\n }\n }\n\n // Check if all expected indexes exist\n const missingIndexes = Object.entries(expectedIndexes)\n .filter(([_, exists]) => !exists)\n .map(([name]) => name);\n\n if (missingIndexes.length > 0) {\n console.log('⚠️ MISSING INDEXES:');\n missingIndexes.forEach((name) => {\n console.log(` - ${name}`);\n });\n console.log('\\nRun: npm run db:migrate\\n');\n process.exit(1);\n }\n\n console.log('✅ ALL REQUIRED INDEXES EXIST');\n console.log('\\nPerformance optimization: COMPLETE');\n console.log('Expected query performance:');\n console.log(' - Progress by exerciseModelUuid: ~5ms (was ~5000ms)');\n console.log(' - Exercise lookups: ~2ms (was ~200ms)');\n\n await sequelize.close();\n process.exit(0);\n } catch (error) {\n console.error('❌ Error checking indexes:', error);\n await sequelize.close();\n process.exit(1);\n }\n}\n\nverifyIndexes();\n"],"names":["Sequelize","dotenv","path","fileURLToPath","__filename","url","__dirname","dirname","config","resolve","sequelize","username","process","env","DB_USER","password","DB_PASSWORD","database","DB_NAME","host","DB_HOST","port","Number","DB_PORT","dialect","logging","verifyIndexes","console","log","query","indexes","type","length","exit","expectedIndexes","exercises_exercise_model_uuid_idx","progress_entries_exercise_model_uuid_recorded_at_idx","index","tablename","indexname","indexdef","missingIndexes","Object","entries","filter","_","exists","map","name","forEach","close","error"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,SAASA,SAAS,QAAQ,YAAY;AACtC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,QAAQ,MAAM;AAEpC,iCAAiC;AACjC,MAAMC,aAAaD,cAAc,YAAYE,GAAG;AAChD,MAAMC,YAAYJ,KAAKK,OAAO,CAACH;AAE/B,6BAA6B;AAC7BH,OAAOO,MAAM,CAAC;IAAEN,MAAMA,KAAKO,OAAO,CAACH,WAAW;AAAiB;AAE/D,MAAMI,YAAY,IAAIV,UAAU;IAC9BW,UAAUC,QAAQC,GAAG,CAACC,OAAO,IAAI;IACjCC,UAAUH,QAAQC,GAAG,CAACG,WAAW,IAAI;IACrCC,UAAUL,QAAQC,GAAG,CAACK,OAAO,IAAI;IACjCC,MAAMP,QAAQC,GAAG,CAACO,OAAO,IAAI;IAC7BC,MAAMC,OAAOV,QAAQC,GAAG,CAACU,OAAO,KAAK;IACrCC,SAAS;IACTC,SAAS;AACX;AAQA,eAAeC;IACb,IAAI;QACFC,QAAQC,GAAG,CAAC;QAEZ,mEAAmE;QACnE,MAAMC,QAAQ,CAAC;;;;;;;;;IASf,CAAC;QAED,MAAMC,UAAU,MAAMpB,UAAUmB,KAAK,CAACA,OAAO;YAC3CE,MAAM;QACR;QAEA,IAAID,QAAQE,MAAM,KAAK,GAAG;YACxBL,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;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CAAC;IACf;AACF;AAEAP"}
|
|
@@ -232,6 +232,13 @@ export declare class NotificationClient {
|
|
|
232
232
|
* @param language - Optional language code to delete only translation
|
|
233
233
|
*/
|
|
234
234
|
deleteNotification(uuid: string, language?: string): Promise<void>;
|
|
235
|
+
scheduleCheckinReminder(params: {
|
|
236
|
+
userUuid: string;
|
|
237
|
+
name: string;
|
|
238
|
+
reminderType: string;
|
|
239
|
+
delayMs: number;
|
|
240
|
+
}, authToken?: string): Promise<void>;
|
|
241
|
+
cancelCheckinReminder(userUuid: string, authToken?: string): Promise<void>;
|
|
235
242
|
/**
|
|
236
243
|
* Handle and format errors from notification service
|
|
237
244
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationClient.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/NotificationClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,8BAA8B,EAC/B,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE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E,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjB;;;;;OAKG;IACG,kBAAkB,CACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC;IAalB;;;;OAIG;IACG,6BAA6B,CACjC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;OAIG;IACG,kBAAkB,CACtB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;OAIG;IACG,6BAA6B,CACjC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;OAKG;IACG,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAazD;;;;;OAKG;IACG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAalE,uBAAuB,CAC3B,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,EACD,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAcV,qBAAqB,CACzB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAehB;;OAEG;IACH,OAAO,CAAC,WAAW;CAoBpB"}
|
|
@@ -325,6 +325,29 @@ import axios from "axios";
|
|
|
325
325
|
this.handleError("Failed to delete notification", error);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
+
// ==================== Coaching Reminder Methods ====================
|
|
329
|
+
async scheduleCheckinReminder(params, authToken) {
|
|
330
|
+
try {
|
|
331
|
+
await this.client.post("/schedule", params, authToken ? {
|
|
332
|
+
headers: {
|
|
333
|
+
Authorization: `Bearer ${authToken}`
|
|
334
|
+
}
|
|
335
|
+
} : {});
|
|
336
|
+
} catch (error) {
|
|
337
|
+
this.handleError("Failed to schedule check-in reminder", error);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async cancelCheckinReminder(userUuid, authToken) {
|
|
341
|
+
try {
|
|
342
|
+
await this.client.delete(`/schedule/weekly-checkin/${userUuid}`, authToken ? {
|
|
343
|
+
headers: {
|
|
344
|
+
Authorization: `Bearer ${authToken}`
|
|
345
|
+
}
|
|
346
|
+
} : {});
|
|
347
|
+
} catch (error) {
|
|
348
|
+
this.handleError("Failed to cancel check-in reminder", error);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
328
351
|
// ==================== Error Handling ====================
|
|
329
352
|
/**
|
|
330
353
|
* Handle and format errors from notification service
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/NotificationClient.ts"],"sourcesContent":["import axios from \"axios\";\nimport type { AxiosInstance, AxiosError } from \"axios\";\nimport type {\n NotificationPayload,\n EmailReminderPayload,\n GroupNotificationRequest,\n NotificationRequest,\n CreateNotificationRequest,\n NotificationTranslationRequest,\n} from '../models/NotificationInterfaces.js';\n\nexport interface NotificationClientConfig {\n baseURL: string;\n timeout?: number;\n headers?: Record<string, string>;\n}\n\n/**\n * Abandoned cart notification payload\n */\nexport interface AbandonedCartPayload {\n email: string;\n}\n\n/**\n * Password restoration types\n */\nexport type PasswordRestorationType = \"change\" | \"reset\" | \"platform-reset\";\n\n/**\n * Password restoration request\n */\nexport interface PasswordRestorationRequest {\n email: string;\n type: PasswordRestorationType;\n}\n\n/**\n * Email confirmation request\n */\nexport interface EmailConfirmationRequest {\n type: \"main\" | \"utility\";\n}\n\n/**\n * Shopify email request\n */\nexport interface ShopifyEmailRequest {\n email: string;\n name: string;\n orderNumber: string;\n items: Array<{\n name: string;\n quantity: number;\n price: number;\n }>;\n}\n\n/**\n * Challenge friend email request\n */\nexport interface ChallengeFriendRequest {\n friendsEmail: string;\n name: string;\n}\n\n/**\n * NotificationClient\n *\n * Provides methods to interact with the notification service via HTTP API.\n * This allows services to send notifications without direct database access\n * or code duplication.\n */\nexport class NotificationClient {\n private client: AxiosInstance;\n\n /**\n * Create a new notification client\n *\n * @param config - Client configuration with base URL and optional settings\n *\n * @example\n * ```typescript\n * const notificationClient = new NotificationClient({\n * baseURL: 'http://localhost:3037',\n * timeout: 5000\n * });\n * ```\n */\n constructor(config: NotificationClientConfig) {\n this.client = axios.create({\n baseURL: config.baseURL,\n timeout: config.timeout || 10000,\n headers: {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n },\n });\n }\n\n // ==================== Push Notification Methods ====================\n\n /**\n * Schedule a push notification for a specific user\n *\n * @param payload - Notification details including user UUID and notification type\n *\n * @example\n * ```typescript\n * await client.scheduleNotification({\n * userUuid: '123e4567-e89b-12d3-a456-426614174000',\n * name: 'workout_reminder'\n * });\n * ```\n */\n async scheduleNotification(payload: NotificationPayload): Promise<void> {\n try {\n await this.client.post(\"/notifications/save-job\", payload);\n } catch (error) {\n this.handleError(\"Failed to schedule notification\", error);\n }\n }\n\n async sendToUser(\n userUuid: string,\n notification: NotificationRequest\n ): Promise<string> {\n try {\n const response = await this.client.post(\"/notifications/send-to-user\", {\n userUuid,\n notification,\n });\n return response.data.messageId;\n } catch (error) {\n this.handleError(\"Failed to send notification to user\", error);\n throw error;\n }\n }\n\n /**\n * Send notification to multiple users in batch\n *\n * @param userUuids - Array of user UUIDs\n * @param notification - Notification content\n *\n * @example\n * ```typescript\n * await client.sendToUsers(['uuid1', 'uuid2'], {\n * title: 'New Feature',\n * body: 'Check out what's new!'\n * });\n * ```\n */\n async sendToUsers(\n userUuids: string[],\n notification: NotificationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/notifications/send-to-users\", {\n userUuids,\n notification,\n });\n } catch (error) {\n this.handleError(\"Failed to send batch notification\", error);\n }\n }\n\n /**\n * Send notification to all users\n *\n * @param notification - Notification content\n * @returns Total number of users notified\n *\n * @example\n * ```typescript\n * const totalSent = await client.sendToAllUsers({\n * title: 'System Update',\n * body: 'App will be updated soon'\n * });\n * ```\n */\n async sendToAllUsers(notification: NotificationRequest): Promise<number> {\n try {\n const response = await this.client.post(\"/notifications/send-to-all\", {\n notification,\n });\n return response.data.totalSent;\n } catch (error) {\n this.handleError(\"Failed to send to all users\", error);\n throw error;\n }\n }\n\n /**\n * Send a push notification to a specific group of users\n *\n * @param request - Group notification request with target group and message\n *\n * @example\n * ```typescript\n * await client.sendGroupNotification({\n * group: NotificationGroups.PREMIUM,\n * notification: {\n * title: 'New Feature!',\n * body: 'Check out our new workout plans'\n * }\n * });\n * ```\n */\n async sendGroupNotification(\n request: GroupNotificationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/notifications/send-group\", request);\n } catch (error) {\n this.handleError(\"Failed to send group notification\", error);\n }\n }\n\n // ==================== Email Methods ====================\n\n /**\n * Schedule an email checkout reminder\n *\n * @param payload - Email reminder details\n */\n async scheduleEmailReminder(payload: EmailReminderPayload): Promise<void> {\n try {\n await this.client.post(\n \"/notifications/save-email-checkout-reminder\",\n payload\n );\n } catch (error) {\n this.handleError(\"Failed to schedule email reminder\", error);\n }\n }\n\n /**\n * Send abandoned cart notification\n *\n * @param payload - Abandoned cart details with user email\n */\n async sendAbandonedCart(payload: AbandonedCartPayload): Promise<void> {\n try {\n await this.client.post(\"/notifications/abandoned-cart\", payload);\n } catch (error) {\n this.handleError(\"Failed to send abandoned cart notification\", error);\n }\n }\n\n /**\n * Send password restoration email\n *\n * @param request - Password restoration request\n */\n async sendPasswordRestoration(\n request: PasswordRestorationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-password-restoration\", request);\n } catch (error) {\n this.handleError(\"Failed to send password restoration email\", error);\n }\n }\n\n /**\n * Send email confirmation\n *\n * @param request - Email confirmation request\n * @param authToken - User authentication token (required)\n */\n async sendEmailConfirmation(\n request: EmailConfirmationRequest,\n authToken: string\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-confirmation\", request, {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n });\n } catch (error) {\n this.handleError(\"Failed to send email confirmation\", error);\n }\n }\n\n /**\n * Send Shopify email\n *\n * @param request - Shopify email details\n */\n async sendShopifyEmail(request: ShopifyEmailRequest): Promise<void> {\n try {\n await this.client.post(\"/mail/send-shopify-email\", request);\n } catch (error) {\n this.handleError(\"Failed to send Shopify email\", error);\n }\n }\n\n /**\n * Send challenge friend invitation email\n *\n * @param request - Challenge friend request\n */\n async sendChallengeFriendEmail(\n request: ChallengeFriendRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-challenge-email\", request);\n } catch (error) {\n this.handleError(\"Failed to send challenge email\", error);\n }\n }\n\n /**\n * Send account deletion email\n *\n * @param authToken - User authentication token (required)\n */\n async sendDeleteAccountEmail(authToken: string): Promise<void> {\n try {\n await this.client.post(\n \"/mail/send-delete-email\",\n {},\n {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n }\n );\n } catch (error) {\n this.handleError(\"Failed to send delete account email\", error);\n }\n }\n\n /**\n * Send export finished email\n *\n * @param authToken - User authentication token (required)\n */\n async sendExportFinishedEmail(authToken: string): Promise<void> {\n try {\n await this.client.post(\n \"/mail/send-export-finished-email\",\n {},\n {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n }\n );\n } catch (error) {\n this.handleError(\"Failed to send export finished email\", error);\n }\n }\n\n /**\n * Send student questionnaire response to coach\n *\n * @param to - Coach email address\n * @param subject - Email subject line\n * @param html - HTML content of the email\n */\n async sendStudentResponseToCoach(params: {\n to: string;\n subject: string;\n html: string;\n }): Promise<void> {\n try {\n await this.client.post(\"/mail/send-student-response-to-coach\", params);\n } catch (error) {\n this.handleError(\"Failed to send student response to coach\", error);\n }\n }\n\n // ==================== Notification Management Methods ====================\n\n /**\n * Create a new notification template\n *\n * @param request - Notification template details\n * @returns The created notification UUID\n */\n async createNotification(\n request: CreateNotificationRequest\n ): Promise<string> {\n try {\n const response = await this.client.post(\n \"/notifications/create-notification\",\n request\n );\n return response.data.uuid;\n } catch (error) {\n this.handleError(\"Failed to create notification\", error);\n throw error;\n }\n }\n\n /**\n * Create a notification translation\n *\n * @param request - Translation details\n */\n async createNotificationTranslation(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.post(\n \"/notifications/create-notification-translation\",\n request\n );\n } catch (error) {\n this.handleError(\"Failed to create notification translation\", error);\n }\n }\n\n /**\n * Update a notification template\n *\n * @param request - Updated notification details\n */\n async updateNotification(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.put(\"/notifications/update-notification\", request);\n } catch (error) {\n this.handleError(\"Failed to update notification\", error);\n }\n }\n\n /**\n * Update a notification translation\n *\n * @param request - Updated translation details\n */\n async updateNotificationTranslation(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.put(\n \"/notifications/update-notification-translation\",\n request\n );\n } catch (error) {\n this.handleError(\"Failed to update notification translation\", error);\n }\n }\n\n /**\n * Get all notifications, optionally filtered by language\n *\n * @param language - Optional language code to filter translations\n * @returns Array of notifications with translations\n */\n async getNotifications(language?: string): Promise<any[]> {\n try {\n const url = language\n ? `/notifications/get-notifications/${language}`\n : \"/notifications/get-notifications\";\n const response = await this.client.get(url);\n return response.data;\n } catch (error) {\n this.handleError(\"Failed to get notifications\", error);\n throw error;\n }\n }\n\n /**\n * Delete a notification or translation\n *\n * @param uuid - Notification UUID\n * @param language - Optional language code to delete only translation\n */\n async deleteNotification(uuid: string, language?: string): Promise<void> {\n try {\n const params = language ? { language } : {};\n await this.client.delete(`/notifications/delete-notifications/${uuid}`, {\n params,\n });\n } catch (error) {\n this.handleError(\"Failed to delete notification\", error);\n }\n }\n\n // ==================== Error Handling ====================\n\n /**\n * Handle and format errors from notification service\n */\n private handleError(message: string, error: unknown): void {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const status = axiosError.response?.status;\n const data = axiosError.response?.data;\n\n console.error(`[NotificationClient] ${message}:`, {\n status,\n message: axiosError.message,\n data,\n });\n\n throw new Error(\n `${message}: ${status ? `HTTP ${status}` : axiosError.message}`\n );\n }\n\n console.error(`[NotificationClient] ${message}:`, error);\n throw new Error(`${message}: ${error}`);\n }\n}\n"],"names":["axios","NotificationClient","client","config","create","baseURL","timeout","headers","scheduleNotification","payload","post","error","handleError","sendToUser","userUuid","notification","response","data","messageId","sendToUsers","userUuids","sendToAllUsers","totalSent","sendGroupNotification","request","scheduleEmailReminder","sendAbandonedCart","sendPasswordRestoration","sendEmailConfirmation","authToken","Authorization","sendShopifyEmail","sendChallengeFriendEmail","sendDeleteAccountEmail","sendExportFinishedEmail","sendStudentResponseToCoach","params","createNotification","uuid","createNotificationTranslation","updateNotification","put","updateNotificationTranslation","getNotifications","language","url","get","deleteNotification","delete","message","isAxiosError","axiosError","status","console","Error"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAkE1B;;;;;;CAMC,GACD,OAAO,MAAMC;IACHC,OAAsB;IAE9B;;;;;;;;;;;;GAYC,GACD,YAAYC,MAAgC,CAAE;QAC5C,IAAI,CAACD,MAAM,GAAGF,MAAMI,MAAM,CAAC;YACzBC,SAASF,OAAOE,OAAO;YACvBC,SAASH,OAAOG,OAAO,IAAI;YAC3BC,SAAS;gBACP,gBAAgB;gBAChB,GAAGJ,OAAOI,OAAO;YACnB;QACF;IACF;IAEA,sEAAsE;IAEtE;;;;;;;;;;;;GAYC,GACD,MAAMC,qBAAqBC,OAA4B,EAAiB;QACtE,IAAI;YACF,MAAM,IAAI,CAACP,MAAM,CAACQ,IAAI,CAAC,2BAA2BD;QACpD,EAAE,OAAOE,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,mCAAmCD;QACtD;IACF;IAEA,MAAME,WACJC,QAAgB,EAChBC,YAAiC,EAChB;QACjB,IAAI;YACF,MAAMC,WAAW,MAAM,I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AAC,qBAAqB,EAAEsC,QAAQ,CAAC,CAAC,EAAEtC;QAClD,MAAM,IAAI2C,MAAM,GAAGL,QAAQ,EAAE,EAAEtC,OAAO;IACxC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/NotificationClient.ts"],"sourcesContent":["import axios from \"axios\";\nimport type { AxiosInstance, AxiosError } from \"axios\";\nimport type {\n NotificationPayload,\n EmailReminderPayload,\n GroupNotificationRequest,\n NotificationRequest,\n CreateNotificationRequest,\n NotificationTranslationRequest,\n} from '../models/NotificationInterfaces.js';\n\nexport interface NotificationClientConfig {\n baseURL: string;\n timeout?: number;\n headers?: Record<string, string>;\n}\n\n/**\n * Abandoned cart notification payload\n */\nexport interface AbandonedCartPayload {\n email: string;\n}\n\n/**\n * Password restoration types\n */\nexport type PasswordRestorationType = \"change\" | \"reset\" | \"platform-reset\";\n\n/**\n * Password restoration request\n */\nexport interface PasswordRestorationRequest {\n email: string;\n type: PasswordRestorationType;\n}\n\n/**\n * Email confirmation request\n */\nexport interface EmailConfirmationRequest {\n type: \"main\" | \"utility\";\n}\n\n/**\n * Shopify email request\n */\nexport interface ShopifyEmailRequest {\n email: string;\n name: string;\n orderNumber: string;\n items: Array<{\n name: string;\n quantity: number;\n price: number;\n }>;\n}\n\n/**\n * Challenge friend email request\n */\nexport interface ChallengeFriendRequest {\n friendsEmail: string;\n name: string;\n}\n\n/**\n * NotificationClient\n *\n * Provides methods to interact with the notification service via HTTP API.\n * This allows services to send notifications without direct database access\n * or code duplication.\n */\nexport class NotificationClient {\n private client: AxiosInstance;\n\n /**\n * Create a new notification client\n *\n * @param config - Client configuration with base URL and optional settings\n *\n * @example\n * ```typescript\n * const notificationClient = new NotificationClient({\n * baseURL: 'http://localhost:3037',\n * timeout: 5000\n * });\n * ```\n */\n constructor(config: NotificationClientConfig) {\n this.client = axios.create({\n baseURL: config.baseURL,\n timeout: config.timeout || 10000,\n headers: {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n },\n });\n }\n\n // ==================== Push Notification Methods ====================\n\n /**\n * Schedule a push notification for a specific user\n *\n * @param payload - Notification details including user UUID and notification type\n *\n * @example\n * ```typescript\n * await client.scheduleNotification({\n * userUuid: '123e4567-e89b-12d3-a456-426614174000',\n * name: 'workout_reminder'\n * });\n * ```\n */\n async scheduleNotification(payload: NotificationPayload): Promise<void> {\n try {\n await this.client.post(\"/notifications/save-job\", payload);\n } catch (error) {\n this.handleError(\"Failed to schedule notification\", error);\n }\n }\n\n async sendToUser(\n userUuid: string,\n notification: NotificationRequest\n ): Promise<string> {\n try {\n const response = await this.client.post(\"/notifications/send-to-user\", {\n userUuid,\n notification,\n });\n return response.data.messageId;\n } catch (error) {\n this.handleError(\"Failed to send notification to user\", error);\n throw error;\n }\n }\n\n /**\n * Send notification to multiple users in batch\n *\n * @param userUuids - Array of user UUIDs\n * @param notification - Notification content\n *\n * @example\n * ```typescript\n * await client.sendToUsers(['uuid1', 'uuid2'], {\n * title: 'New Feature',\n * body: 'Check out what's new!'\n * });\n * ```\n */\n async sendToUsers(\n userUuids: string[],\n notification: NotificationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/notifications/send-to-users\", {\n userUuids,\n notification,\n });\n } catch (error) {\n this.handleError(\"Failed to send batch notification\", error);\n }\n }\n\n /**\n * Send notification to all users\n *\n * @param notification - Notification content\n * @returns Total number of users notified\n *\n * @example\n * ```typescript\n * const totalSent = await client.sendToAllUsers({\n * title: 'System Update',\n * body: 'App will be updated soon'\n * });\n * ```\n */\n async sendToAllUsers(notification: NotificationRequest): Promise<number> {\n try {\n const response = await this.client.post(\"/notifications/send-to-all\", {\n notification,\n });\n return response.data.totalSent;\n } catch (error) {\n this.handleError(\"Failed to send to all users\", error);\n throw error;\n }\n }\n\n /**\n * Send a push notification to a specific group of users\n *\n * @param request - Group notification request with target group and message\n *\n * @example\n * ```typescript\n * await client.sendGroupNotification({\n * group: NotificationGroups.PREMIUM,\n * notification: {\n * title: 'New Feature!',\n * body: 'Check out our new workout plans'\n * }\n * });\n * ```\n */\n async sendGroupNotification(\n request: GroupNotificationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/notifications/send-group\", request);\n } catch (error) {\n this.handleError(\"Failed to send group notification\", error);\n }\n }\n\n // ==================== Email Methods ====================\n\n /**\n * Schedule an email checkout reminder\n *\n * @param payload - Email reminder details\n */\n async scheduleEmailReminder(payload: EmailReminderPayload): Promise<void> {\n try {\n await this.client.post(\n \"/notifications/save-email-checkout-reminder\",\n payload\n );\n } catch (error) {\n this.handleError(\"Failed to schedule email reminder\", error);\n }\n }\n\n /**\n * Send abandoned cart notification\n *\n * @param payload - Abandoned cart details with user email\n */\n async sendAbandonedCart(payload: AbandonedCartPayload): Promise<void> {\n try {\n await this.client.post(\"/notifications/abandoned-cart\", payload);\n } catch (error) {\n this.handleError(\"Failed to send abandoned cart notification\", error);\n }\n }\n\n /**\n * Send password restoration email\n *\n * @param request - Password restoration request\n */\n async sendPasswordRestoration(\n request: PasswordRestorationRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-password-restoration\", request);\n } catch (error) {\n this.handleError(\"Failed to send password restoration email\", error);\n }\n }\n\n /**\n * Send email confirmation\n *\n * @param request - Email confirmation request\n * @param authToken - User authentication token (required)\n */\n async sendEmailConfirmation(\n request: EmailConfirmationRequest,\n authToken: string\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-confirmation\", request, {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n });\n } catch (error) {\n this.handleError(\"Failed to send email confirmation\", error);\n }\n }\n\n /**\n * Send Shopify email\n *\n * @param request - Shopify email details\n */\n async sendShopifyEmail(request: ShopifyEmailRequest): Promise<void> {\n try {\n await this.client.post(\"/mail/send-shopify-email\", request);\n } catch (error) {\n this.handleError(\"Failed to send Shopify email\", error);\n }\n }\n\n /**\n * Send challenge friend invitation email\n *\n * @param request - Challenge friend request\n */\n async sendChallengeFriendEmail(\n request: ChallengeFriendRequest\n ): Promise<void> {\n try {\n await this.client.post(\"/mail/send-challenge-email\", request);\n } catch (error) {\n this.handleError(\"Failed to send challenge email\", error);\n }\n }\n\n /**\n * Send account deletion email\n *\n * @param authToken - User authentication token (required)\n */\n async sendDeleteAccountEmail(authToken: string): Promise<void> {\n try {\n await this.client.post(\n \"/mail/send-delete-email\",\n {},\n {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n }\n );\n } catch (error) {\n this.handleError(\"Failed to send delete account email\", error);\n }\n }\n\n /**\n * Send export finished email\n *\n * @param authToken - User authentication token (required)\n */\n async sendExportFinishedEmail(authToken: string): Promise<void> {\n try {\n await this.client.post(\n \"/mail/send-export-finished-email\",\n {},\n {\n headers: {\n Authorization: `Bearer ${authToken}`,\n },\n }\n );\n } catch (error) {\n this.handleError(\"Failed to send export finished email\", error);\n }\n }\n\n /**\n * Send student questionnaire response to coach\n *\n * @param to - Coach email address\n * @param subject - Email subject line\n * @param html - HTML content of the email\n */\n async sendStudentResponseToCoach(params: {\n to: string;\n subject: string;\n html: string;\n }): Promise<void> {\n try {\n await this.client.post(\"/mail/send-student-response-to-coach\", params);\n } catch (error) {\n this.handleError(\"Failed to send student response to coach\", error);\n }\n }\n\n // ==================== Notification Management Methods ====================\n\n /**\n * Create a new notification template\n *\n * @param request - Notification template details\n * @returns The created notification UUID\n */\n async createNotification(\n request: CreateNotificationRequest\n ): Promise<string> {\n try {\n const response = await this.client.post(\n \"/notifications/create-notification\",\n request\n );\n return response.data.uuid;\n } catch (error) {\n this.handleError(\"Failed to create notification\", error);\n throw error;\n }\n }\n\n /**\n * Create a notification translation\n *\n * @param request - Translation details\n */\n async createNotificationTranslation(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.post(\n \"/notifications/create-notification-translation\",\n request\n );\n } catch (error) {\n this.handleError(\"Failed to create notification translation\", error);\n }\n }\n\n /**\n * Update a notification template\n *\n * @param request - Updated notification details\n */\n async updateNotification(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.put(\"/notifications/update-notification\", request);\n } catch (error) {\n this.handleError(\"Failed to update notification\", error);\n }\n }\n\n /**\n * Update a notification translation\n *\n * @param request - Updated translation details\n */\n async updateNotificationTranslation(\n request: NotificationTranslationRequest\n ): Promise<void> {\n try {\n await this.client.put(\n \"/notifications/update-notification-translation\",\n request\n );\n } catch (error) {\n this.handleError(\"Failed to update notification translation\", error);\n }\n }\n\n /**\n * Get all notifications, optionally filtered by language\n *\n * @param language - Optional language code to filter translations\n * @returns Array of notifications with translations\n */\n async getNotifications(language?: string): Promise<any[]> {\n try {\n const url = language\n ? `/notifications/get-notifications/${language}`\n : \"/notifications/get-notifications\";\n const response = await this.client.get(url);\n return response.data;\n } catch (error) {\n this.handleError(\"Failed to get notifications\", error);\n throw error;\n }\n }\n\n /**\n * Delete a notification or translation\n *\n * @param uuid - Notification UUID\n * @param language - Optional language code to delete only translation\n */\n async deleteNotification(uuid: string, language?: string): Promise<void> {\n try {\n const params = language ? { language } : {};\n await this.client.delete(`/notifications/delete-notifications/${uuid}`, {\n params,\n });\n } catch (error) {\n this.handleError(\"Failed to delete notification\", error);\n }\n }\n\n // ==================== Coaching Reminder Methods ====================\n\n async scheduleCheckinReminder(\n params: {\n userUuid: string;\n name: string;\n reminderType: string;\n delayMs: number;\n },\n authToken?: string\n ): Promise<void> {\n try {\n await this.client.post(\n \"/schedule\",\n params,\n authToken\n ? { headers: { Authorization: `Bearer ${authToken}` } }\n : {}\n );\n } catch (error) {\n this.handleError(\"Failed to schedule check-in reminder\", error);\n }\n }\n\n async cancelCheckinReminder(\n userUuid: string,\n authToken?: string\n ): Promise<void> {\n try {\n await this.client.delete(\n `/schedule/weekly-checkin/${userUuid}`,\n authToken\n ? { headers: { Authorization: `Bearer ${authToken}` } }\n : {}\n );\n } catch (error) {\n this.handleError(\"Failed to cancel check-in reminder\", error);\n }\n }\n\n // ==================== Error Handling ====================\n\n /**\n * Handle and format errors from notification service\n */\n private handleError(message: string, error: unknown): void {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const status = axiosError.response?.status;\n const data = axiosError.response?.data;\n\n console.error(`[NotificationClient] ${message}:`, {\n status,\n message: axiosError.message,\n data,\n });\n\n throw new Error(\n `${message}: ${status ? `HTTP ${status}` : axiosError.message}`\n );\n }\n\n console.error(`[NotificationClient] ${message}:`, error);\n throw new Error(`${message}: ${error}`);\n }\n}\n"],"names":["axios","NotificationClient","client","config","create","baseURL","timeout","headers","scheduleNotification","payload","post","error","handleError","sendToUser","userUuid","notification","response","data","messageId","sendToUsers","userUuids","sendToAllUsers","totalSent","sendGroupNotification","request","scheduleEmailReminder","sendAbandonedCart","sendPasswordRestoration","sendEmailConfirmation","authToken","Authorization","sendShopifyEmail","sendChallengeFriendEmail","sendDeleteAccountEmail","sendExportFinishedEmail","sendStudentResponseToCoach","params","createNotification","uuid","createNotificationTranslation","updateNotification","put","updateNotificationTranslation","getNotifications","language","url","get","deleteNotification","delete","scheduleCheckinReminder","cancelCheckinReminder","message","isAxiosError","axiosError","status","console","Error"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAkE1B;;;;;;CAMC,GACD,OAAO,MAAMC;IACHC,OAAsB;IAE9B;;;;;;;;;;;;GAYC,GACD,YAAYC,MAAgC,CAAE;QAC5C,IAAI,CAACD,MAAM,GAAGF,MAAMI,MAAM,CAAC;YACzBC,SAASF,OAAOE,OAAO;YACvBC,SAASH,OAAOG,OAAO,IAAI;YAC3BC,SAAS;gBACP,gBAAgB;gBAChB,GAAGJ,OAAOI,OAAO;YACnB;QACF;IACF;IAEA,sEAAsE;IAEtE;;;;;;;;;;;;GAYC,GACD,MAAMC,qBAAqBC,OAA4B,EAAiB;QACtE,IAAI;YACF,MAAM,IAAI,CAACP,MAAM,CAACQ,IAAI,CAAC,2BAA2BD;QACpD,EAAE,OAAOE,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,mCAAmCD;QACtD;IACF;IAEA,MAAME,WACJC,QAAgB,EAChBC,YAAiC,EAChB;QACjB,IAAI;YACF,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,EAAED,WAAW;gBAAC;YAAE,IACpD,CAAC;QAET,EAAE,OAAOlB,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,sCAAsCD;QACzD;IACF;IAEA,2DAA2D;IAE3D;;GAEC,GACD,AAAQC,YAAYuC,OAAe,EAAExC,KAAc,EAAQ;QACzD,IAAIX,MAAMoD,YAAY,CAACzC,QAAQ;YAC7B,MAAM0C,aAAa1C;YACnB,MAAM2C,SAASD,WAAWrC,QAAQ,EAAEsC;YACpC,MAAMrC,OAAOoC,WAAWrC,QAAQ,EAAEC;YAElCsC,QAAQ5C,KAAK,CAAC,CAAC,qBAAqB,EAAEwC,QAAQ,CAAC,CAAC,EAAE;gBAChDG;gBACAH,SAASE,WAAWF,OAAO;gBAC3BlC;YACF;YAEA,MAAM,IAAIuC,MACR,GAAGL,QAAQ,EAAE,EAAEG,SAAS,CAAC,KAAK,EAAEA,QAAQ,GAAGD,WAAWF,OAAO,EAAE;QAEnE;QAEAI,QAAQ5C,KAAK,CAAC,CAAC,qBAAqB,EAAEwC,QAAQ,CAAC,CAAC,EAAExC;QAClD,MAAM,IAAI6C,MAAM,GAAGL,QAAQ,EAAE,EAAExC,OAAO;IACxC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "90dc-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@google-cloud/secret-manager": "^6.1.1",
|
|
36
|
+
"@google-cloud/storage": "^7.19.0",
|
|
36
37
|
"@koa/router": "^15.3.0",
|
|
37
38
|
"@sentry/integrations": "^7.114.0",
|
|
38
39
|
"@sentry/node": "^7.120.4",
|