90dc-core 1.17.0 → 1.18.1

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.
Files changed (43) hide show
  1. package/dist/index.d.ts +5 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/clients/EmailClient.d.ts +15 -34
  6. package/dist/lib/clients/EmailClient.d.ts.map +1 -1
  7. package/dist/lib/clients/EmailClient.js +41 -7
  8. package/dist/lib/clients/EmailClient.js.map +1 -1
  9. package/dist/lib/clients/ImagesClient.d.ts +17 -0
  10. package/dist/lib/clients/ImagesClient.d.ts.map +1 -0
  11. package/dist/lib/clients/ImagesClient.js +116 -0
  12. package/dist/lib/clients/ImagesClient.js.map +1 -0
  13. package/dist/lib/clients/MailingClient.d.ts +21 -0
  14. package/dist/lib/clients/MailingClient.d.ts.map +1 -0
  15. package/dist/lib/clients/MailingClient.js +84 -0
  16. package/dist/lib/clients/MailingClient.js.map +1 -0
  17. package/dist/lib/clients/types/email.types.d.ts +41 -0
  18. package/dist/lib/clients/types/email.types.d.ts.map +1 -0
  19. package/dist/lib/clients/types/email.types.js +3 -0
  20. package/dist/lib/clients/types/email.types.js.map +1 -0
  21. package/dist/lib/clients/types/images.types.d.ts +21 -0
  22. package/dist/lib/clients/types/images.types.d.ts.map +1 -0
  23. package/dist/lib/clients/types/images.types.js +3 -0
  24. package/dist/lib/clients/types/images.types.js.map +1 -0
  25. package/dist/lib/clients/types/mailing.types.d.ts +10 -0
  26. package/dist/lib/clients/types/mailing.types.d.ts.map +1 -0
  27. package/dist/lib/clients/types/mailing.types.js +3 -0
  28. package/dist/lib/clients/types/mailing.types.js.map +1 -0
  29. package/dist/lib/dbmodels/diet/Recipe.d.ts +2 -0
  30. package/dist/lib/dbmodels/diet/Recipe.d.ts.map +1 -1
  31. package/dist/lib/dbmodels/diet/Recipe.js.map +1 -1
  32. package/dist/lib/dbmodels/program/CircularProgramDraft.d.ts +1 -0
  33. package/dist/lib/dbmodels/program/CircularProgramDraft.d.ts.map +1 -1
  34. package/dist/lib/dbmodels/program/CircularProgramDraft.js.map +1 -1
  35. package/dist/lib/scripts/verify-indexes.d.ts +13 -0
  36. package/dist/lib/scripts/verify-indexes.d.ts.map +1 -0
  37. package/dist/lib/scripts/verify-indexes.js +94 -0
  38. package/dist/lib/scripts/verify-indexes.js.map +1 -0
  39. package/dist/lib/utils/NotificationClient.d.ts +7 -0
  40. package/dist/lib/utils/NotificationClient.d.ts.map +1 -1
  41. package/dist/lib/utils/NotificationClient.js +23 -0
  42. package/dist/lib/utils/NotificationClient.js.map +1 -1
  43. package/package.json +2 -1
package/dist/index.d.ts CHANGED
@@ -5,9 +5,13 @@ export * from "./lib/models/UserInterfaces.js";
5
5
  export * from "./lib/models/NotificationInterfaces.js";
6
6
  export * from "./lib/dbmodels/index.js";
7
7
  export { EmailClient } from "./lib/clients/EmailClient.js";
8
+ export { ImagesClient } from "./lib/clients/ImagesClient.js";
9
+ export { MailingClient } from "./lib/clients/MailingClient.js";
8
10
  export { PushNotificationClient } from "./lib/clients/PushNotificationClient.js";
9
11
  export { FirebasePushNotificationClient } from "./lib/clients/FirebasePushNotificationClient.js";
10
- export type { SendTemplateEmailRequest, BatchTemplateEmailRequest, EmailResponse, } from "./lib/clients/EmailClient.js";
12
+ export * as EmailTypes from "./lib/clients/types/email.types.js";
13
+ export * as ImagesTypes from "./lib/clients/types/images.types.js";
14
+ export * as MailingTypes from "./lib/clients/types/mailing.types.js";
11
15
  export type { NotificationPayload } from "./lib/clients/PushNotificationClient.js";
12
16
  export { AuthenticationUtil } from "./lib/utils/AuthenticationUtil.js";
13
17
  export { NotificationsUtil } from "./lib/utils/NotificationsUtil.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cA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AAY,EACZ,kBAAkB,EAClB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EACL,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,UAAU,EACX,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EACL,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAG5F,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAGvF,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAC,cAAc,EAAE,KAAK,cAAc,EAAC,MAAM,2BAA2B,CAAA"}
package/dist/index.js CHANGED
@@ -8,8 +8,14 @@ export * from "./lib/models/NotificationInterfaces.js";
8
8
  export * from "./lib/dbmodels/index.js";
9
9
  //Clients
10
10
  export { EmailClient } from "./lib/clients/EmailClient.js";
11
+ export { ImagesClient } from "./lib/clients/ImagesClient.js";
12
+ export { MailingClient } from "./lib/clients/MailingClient.js";
11
13
  export { PushNotificationClient } from "./lib/clients/PushNotificationClient.js";
12
14
  export { FirebasePushNotificationClient } from "./lib/clients/FirebasePushNotificationClient.js";
15
+ //Client Types (namespace imports)
16
+ export * as EmailTypes from "./lib/clients/types/email.types.js";
17
+ export * as ImagesTypes from "./lib/clients/types/images.types.js";
18
+ export * as MailingTypes from "./lib/clients/types/mailing.types.js";
13
19
  //Utils
14
20
  export { AuthenticationUtil } from "./lib/utils/AuthenticationUtil.js";
15
21
  export { NotificationsUtil } from "./lib/utils/NotificationsUtil.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["//Interfaces\nexport * from \"./lib/models/ProgramInterfaces.js\";\nexport * from \"./lib/models/ExerciseInterfaces.js\";\nexport * from \"./lib/models/WorkoutInterfaces.js\";\nexport * from \"./lib/models/UserInterfaces.js\";\nexport * from \"./lib/models/NotificationInterfaces.js\";\n\n//DB Models - Export all models and model arrays\nexport * from \"./lib/dbmodels/index.js\"\n\n//Clients\nexport { EmailClient } from \"./lib/clients/EmailClient.js\"\nexport { PushNotificationClient } from \"./lib/clients/PushNotificationClient.js\"\nexport { FirebasePushNotificationClient } from \"./lib/clients/FirebasePushNotificationClient.js\"\nexport type {\n SendTemplateEmailRequest,\n BatchTemplateEmailRequest,\n EmailResponse,\n} from \"./lib/clients/EmailClient.js\"\nexport type { NotificationPayload } from \"./lib/clients/PushNotificationClient.js\"\n\n//Utils\nexport {AuthenticationUtil} from \"./lib/utils/AuthenticationUtil.js\"\nexport {NotificationsUtil} from \"./lib/utils/NotificationsUtil.js\"\nexport {NotificationClient} from \"./lib/utils/NotificationClient.js\"\nexport {Log} from \"./lib/utils/Logger.js\"\nexport {SecretManager} from \"./lib/utils/SecretManager.js\"\nexport {\n initializeSentry,\n isSentryEnabled,\n scrubObject,\n captureRequestBody,\n extractUserContext,\n buildRequestContext,\n buildResponseContext,\n reportErrorToSentry,\n reportMessageToSentry,\n type ErrorReportOptions,\n type SeverityLevel,\n} from \"./lib/utils/SentryUtil.js\"\n\n//Testing Utilities\nexport {\n createMockContext,\n createMockUser,\n createAuthenticatedContext,\n mockDatabase,\n flushPromises,\n assertions,\n executeRoute,\n type BaseContext,\n type AuthenticatedContext,\n type RouterContext,\n type RouterMiddleware,\n type RouterLayer,\n type RouterLike,\n type SequelizeModelMethods,\n} from \"./lib/testing/testHelpers.js\"\n\n// Testing Fixtures\nexport {\n TEST_UUIDS,\n TEST_DATES,\n TEST_DATA,\n isValidUUID,\n generateTestEmail,\n createTestUser,\n createTestCoach,\n createTestHeadCoach,\n createTestFinanceUser,\n createTestAdmin,\n createTestClient,\n wait,\n freezeTime,\n testAssertions,\n mockResponses,\n isObject,\n isArray,\n} from \"./lib/testing/testFixtures.js\"\n\n//Config\nexport {\n ConfigValidator,\n BaseConfigSchema,\n CommonSchemas,\n createConfig,\n ConfigurationError,\n type BaseConfig\n} from \"./lib/config/ConfigValidator.js\"\n\n//Errors\nexport {\n AppError,\n ValidationError,\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ConflictError,\n UnprocessableEntityError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n DatabaseError,\n ExternalAPIError,\n isAppError,\n isOperationalError,\n toAppError\n} from \"./lib/Errors/AppError.js\"\n\n//Middlewares\nexport {\n ErrorMiddleware,\n} from \"./lib/middlewares/ErrorMiddleware.js\"\nexport { validate, type ValidationConfig } from \"./lib/middlewares/ValidationMiddleware.js\";\n\n//Controllers\nexport { BaseController, type RouteConfig } from \"./lib/controllers/BaseController.js\";\n\n\nexport {RedisClient} from \"./lib/classes/Redis.js\"\nexport {DatabaseClient, type DatabaseConfig} from \"./lib/classes/Database.js\""],"names":["EmailClient","PushNotificationClient","FirebasePushNotificationClient","AuthenticationUtil","NotificationsUtil","NotificationClient","Log","SecretManager","initializeSentry","isSentryEnabled","scrubObject","captureRequestBody","extractUserContext","buildRequestContext","buildResponseContext","reportErrorToSentry","reportMessageToSentry","createMockContext","createMockUser","createAuthenticatedContext","mockDatabase","flushPromises","assertions","executeRoute","TEST_UUIDS","TEST_DATES","TEST_DATA","isValidUUID","generateTestEmail","createTestUser","createTestCoach","createTestHeadCoach","createTestFinanceUser","createTestAdmin","createTestClient","wait","freezeTime","testAssertions","mockResponses","isObject","isArray","ConfigValidator","BaseConfigSchema","CommonSchemas","createConfig","ConfigurationError","AppError","ValidationError","AuthenticationError","ForbiddenError","NotFoundError","ConflictError","UnprocessableEntityError","RateLimitError","InternalServerError","ServiceUnavailableError","DatabaseError","ExternalAPIError","isAppError","isOperationalError","toAppError","ErrorMiddleware","validate","BaseController","RedisClient","DatabaseClient"],"mappings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B,EACnBC,uBAAuB,EACvBC,aAAa,EACbC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,UAAU,QACL,2BAA0B;AAEjC,aAAa;AACb,SACEC,eAAe,QACV,uCAAsC;AAC7C,SAASC,QAAQ,QAA+B,4CAA4C;AAE5F,aAAa;AACb,SAASC,cAAc,QAA0B,sCAAsC;AAGvF,SAAQC,WAAW,QAAO,yBAAwB;AAClD,SAAQC,cAAc,QAA4B,4BAA2B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["//Interfaces\nexport * from \"./lib/models/ProgramInterfaces.js\";\nexport * from \"./lib/models/ExerciseInterfaces.js\";\nexport * from \"./lib/models/WorkoutInterfaces.js\";\nexport * from \"./lib/models/UserInterfaces.js\";\nexport * from \"./lib/models/NotificationInterfaces.js\";\n\n//DB Models - Export all models and model arrays\nexport * from \"./lib/dbmodels/index.js\"\n\n//Clients\nexport { EmailClient } from \"./lib/clients/EmailClient.js\"\nexport { ImagesClient } from \"./lib/clients/ImagesClient.js\"\nexport { MailingClient } from \"./lib/clients/MailingClient.js\"\nexport { PushNotificationClient } from \"./lib/clients/PushNotificationClient.js\"\nexport { FirebasePushNotificationClient } from \"./lib/clients/FirebasePushNotificationClient.js\"\n\n//Client Types (namespace imports)\nexport * as EmailTypes from \"./lib/clients/types/email.types.js\"\nexport * as ImagesTypes from \"./lib/clients/types/images.types.js\"\nexport * as MailingTypes from \"./lib/clients/types/mailing.types.js\"\nexport type { NotificationPayload } from \"./lib/clients/PushNotificationClient.js\"\n\n//Utils\nexport {AuthenticationUtil} from \"./lib/utils/AuthenticationUtil.js\"\nexport {NotificationsUtil} from \"./lib/utils/NotificationsUtil.js\"\nexport {NotificationClient} from \"./lib/utils/NotificationClient.js\"\nexport {Log} from \"./lib/utils/Logger.js\"\nexport {SecretManager} from \"./lib/utils/SecretManager.js\"\nexport {\n initializeSentry,\n isSentryEnabled,\n scrubObject,\n captureRequestBody,\n extractUserContext,\n buildRequestContext,\n buildResponseContext,\n reportErrorToSentry,\n reportMessageToSentry,\n type ErrorReportOptions,\n type SeverityLevel,\n} from \"./lib/utils/SentryUtil.js\"\n\n//Testing Utilities\nexport {\n createMockContext,\n createMockUser,\n createAuthenticatedContext,\n mockDatabase,\n flushPromises,\n assertions,\n executeRoute,\n type BaseContext,\n type AuthenticatedContext,\n type RouterContext,\n type RouterMiddleware,\n type RouterLayer,\n type RouterLike,\n type SequelizeModelMethods,\n} from \"./lib/testing/testHelpers.js\"\n\n// Testing Fixtures\nexport {\n TEST_UUIDS,\n TEST_DATES,\n TEST_DATA,\n isValidUUID,\n generateTestEmail,\n createTestUser,\n createTestCoach,\n createTestHeadCoach,\n createTestFinanceUser,\n createTestAdmin,\n createTestClient,\n wait,\n freezeTime,\n testAssertions,\n mockResponses,\n isObject,\n isArray,\n} from \"./lib/testing/testFixtures.js\"\n\n//Config\nexport {\n ConfigValidator,\n BaseConfigSchema,\n CommonSchemas,\n createConfig,\n ConfigurationError,\n type BaseConfig\n} from \"./lib/config/ConfigValidator.js\"\n\n//Errors\nexport {\n AppError,\n ValidationError,\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ConflictError,\n UnprocessableEntityError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n DatabaseError,\n ExternalAPIError,\n isAppError,\n isOperationalError,\n toAppError\n} from \"./lib/Errors/AppError.js\"\n\n//Middlewares\nexport {\n ErrorMiddleware,\n} from \"./lib/middlewares/ErrorMiddleware.js\"\nexport { validate, type ValidationConfig } from \"./lib/middlewares/ValidationMiddleware.js\";\n\n//Controllers\nexport { BaseController, type RouteConfig } from \"./lib/controllers/BaseController.js\";\n\n\nexport {RedisClient} from \"./lib/classes/Redis.js\"\nexport {DatabaseClient, type DatabaseConfig} from \"./lib/classes/Database.js\""],"names":["EmailClient","ImagesClient","MailingClient","PushNotificationClient","FirebasePushNotificationClient","EmailTypes","ImagesTypes","MailingTypes","AuthenticationUtil","NotificationsUtil","NotificationClient","Log","SecretManager","initializeSentry","isSentryEnabled","scrubObject","captureRequestBody","extractUserContext","buildRequestContext","buildResponseContext","reportErrorToSentry","reportMessageToSentry","createMockContext","createMockUser","createAuthenticatedContext","mockDatabase","flushPromises","assertions","executeRoute","TEST_UUIDS","TEST_DATES","TEST_DATA","isValidUUID","generateTestEmail","createTestUser","createTestCoach","createTestHeadCoach","createTestFinanceUser","createTestAdmin","createTestClient","wait","freezeTime","testAssertions","mockResponses","isObject","isArray","ConfigValidator","BaseConfigSchema","CommonSchemas","createConfig","ConfigurationError","AppError","ValidationError","AuthenticationError","ForbiddenError","NotFoundError","ConflictError","UnprocessableEntityError","RateLimitError","InternalServerError","ServiceUnavailableError","DatabaseError","ExternalAPIError","isAppError","isOperationalError","toAppError","ErrorMiddleware","validate","BaseController","RedisClient","DatabaseClient"],"mappings":"AAAA,YAAY;AACZ,cAAc,oCAAoC;AAClD,cAAc,qCAAqC;AACnD,cAAc,oCAAoC;AAClD,cAAc,iCAAiC;AAC/C,cAAc,yCAAyC;AAEvD,gDAAgD;AAChD,cAAc,iBAAyB;AAEvC,SAAS;AACT,SAASA,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,8BAA8B,QAAQ,kDAAiD;AAEhG,kCAAkC;AAClC,OAAO,KAAKC,UAAU,MAAM,qCAAoC;AAChE,OAAO,KAAKC,WAAW,MAAM,sCAAqC;AAClE,OAAO,KAAKC,YAAY,MAAM,uCAAsC;AAGpE,OAAO;AACP,SAAQC,kBAAkB,QAAO,oCAAmC;AACpE,SAAQC,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,kBAAkB,QAAO,oCAAmC;AACpE,SAAQC,GAAG,QAAO,wBAAuB;AACzC,SAAQC,aAAa,QAAO,+BAA8B;AAC1D,SACEC,gBAAgB,EAChBC,eAAe,EACfC,WAAW,EACXC,kBAAkB,EAClBC,kBAAkB,EAClBC,mBAAmB,EACnBC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB,QAGhB,4BAA2B;AAElC,mBAAmB;AACnB,SACEC,iBAAiB,EACjBC,cAAc,EACdC,0BAA0B,EAC1BC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,YAAY,QAQP,+BAA8B;AAErC,mBAAmB;AACnB,SACEC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,WAAW,EACXC,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,mBAAmB,EACnBC,qBAAqB,EACrBC,eAAe,EACfC,gBAAgB,EAChBC,IAAI,EACJC,UAAU,EACVC,cAAc,EACdC,aAAa,EACbC,QAAQ,EACRC,OAAO,QACF,gCAA+B;AAEtC,QAAQ;AACR,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,YAAY,EACZC,kBAAkB,QAEb,kCAAiC;AAExC,QAAQ;AACR,SACEC,QAAQ,EACRC,eAAe,EACfC,mBAAmB,EACnBC,cAAc,EACdC,aAAa,EACbC,aAAa,EACbC,wBAAwB,EACxBC,cAAc,EACdC,mBAAmB,EACnBC,uBAAuB,EACvBC,aAAa,EACbC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,UAAU,QACL,2BAA0B;AAEjC,aAAa;AACb,SACEC,eAAe,QACV,uCAAsC;AAC7C,SAASC,QAAQ,QAA+B,4CAA4C;AAE5F,aAAa;AACb,SAASC,cAAc,QAA0B,sCAAsC;AAGvF,SAAQC,WAAW,QAAO,yBAAwB;AAClD,SAAQC,cAAc,QAA4B,4BAA2B"}
@@ -1,44 +1,25 @@
1
- export interface SendTemplateEmailRequest {
2
- to: string | string[];
3
- templateAlias: string | number;
4
- templateModel: Record<string, any>;
5
- cc?: string | string[];
6
- bcc?: string | string[];
7
- replyTo?: string;
8
- tag?: string;
9
- metadata?: Record<string, string>;
10
- trackOpens?: boolean;
11
- trackLinks?: "None" | "HtmlAndText" | "HtmlOnly" | "TextOnly";
12
- }
13
- export interface BatchTemplateEmailRequest {
14
- emails: Array<{
15
- to: string;
16
- templateAlias: string | number;
17
- templateModel: Record<string, any>;
18
- tag?: string;
19
- metadata?: Record<string, string>;
20
- }>;
21
- }
22
- export interface EmailResponse {
23
- messageId: string;
24
- to: string;
25
- submittedAt: string;
26
- errorCode?: number;
27
- message?: string;
28
- }
1
+ import type * as t from "./types/email.types.js";
29
2
  export declare class EmailClient {
30
3
  private static instance;
31
4
  private client;
32
5
  private config;
33
6
  private logger;
34
- private constructor();
7
+ constructor(config: t.Config);
8
+ /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */
35
9
  static getInstance(): EmailClient;
10
+ /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */
36
11
  static resetInstance(): void;
37
- sendWithTemplate(request: SendTemplateEmailRequest): Promise<EmailResponse>;
38
- sendBatchWithTemplate(request: BatchTemplateEmailRequest): Promise<EmailResponse[]>;
39
- sendPasswordReset(to: string, resetToken: string, userName: string): Promise<EmailResponse>;
40
- sendEmailConfirmation(to: string, confirmToken: string, userName: string): Promise<EmailResponse>;
41
- sendWelcome(to: string, userName: string): Promise<EmailResponse>;
12
+ sendWithTemplate(request: t.SendTemplateEmailRequest): Promise<t.EmailResponse>;
13
+ /** Currently unused across all services. */
14
+ sendBatchWithTemplate(request: t.BatchTemplateEmailRequest): Promise<t.EmailResponse[]>;
15
+ /** Currently unused across all services. Duplicates MailingClient methods. */
16
+ sendPasswordReset(to: string, resetToken: string, userName: string): Promise<t.EmailResponse>;
17
+ /** Currently unused across all services. Duplicates MailingClient methods. */
18
+ sendEmailConfirmation(to: string, confirmToken: string, userName: string): Promise<t.EmailResponse>;
19
+ /** Currently unused across all services. Duplicates MailingClient methods. */
20
+ sendWelcome(to: string, userName: string): Promise<t.EmailResponse>;
21
+ /** Currently unused. Added for MailingClient.sendExportsEmail() (plain text email via Postmark /email endpoint). */
22
+ sendEmail(request: t.SendEmailRequest): Promise<t.EmailResponse>;
42
23
  private handleError;
43
24
  }
44
25
  //# sourceMappingURL=EmailClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmailClient.d.ts","sourceRoot":"","sources":["../../../src/lib/clients/EmailClient.ts"],"names":[],"mappings":"AAQA,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,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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C,aAAa,CAAC;IAyC5F,4CAA4C;IAC/B,qBAAqB,CAAC,OAAO,EAAE,CAAC,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAsCpG,8EAA8E;IACjE,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;IAa1G,8EAA8E;IACjE,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;IAahH,8EAA8E;IACjE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;IAShF,oHAAoH;IACvG,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;IAuC7E,OAAO,CAAC,WAAW;CAwBpB"}
@@ -19,14 +19,14 @@ export class EmailClient {
19
19
  }
20
20
  });
21
21
  }
22
- static getInstance() {
22
+ /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */ static getInstance() {
23
23
  if (!EmailClient.instance) {
24
24
  const config = CommonSchemas.postmark.parse(process.env);
25
25
  EmailClient.instance = new EmailClient(config);
26
26
  }
27
27
  return EmailClient.instance;
28
28
  }
29
- static resetInstance() {
29
+ /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */ static resetInstance() {
30
30
  EmailClient.instance = undefined;
31
31
  }
32
32
  async sendWithTemplate(request) {
@@ -65,7 +65,7 @@ export class EmailClient {
65
65
  this.handleError(error, "sendWithTemplate");
66
66
  }
67
67
  }
68
- async sendBatchWithTemplate(request) {
68
+ /** Currently unused across all services. */ async sendBatchWithTemplate(request) {
69
69
  try {
70
70
  this.logger.info("Sending batch templated emails", {
71
71
  count: request.emails.length
@@ -74,7 +74,7 @@ export class EmailClient {
74
74
  Messages: request.emails.map((email)=>({
75
75
  From: this.config.POSTMARK_FROM_EMAIL,
76
76
  To: email.to,
77
- TemplateAlies: email.templateAlias,
77
+ TemplateAlias: email.templateAlias,
78
78
  TemplateModel: email.templateModel,
79
79
  ReplyTo: this.config.POSTMARK_REPLY_TO_EMAIL,
80
80
  Tag: email.tag,
@@ -98,7 +98,7 @@ export class EmailClient {
98
98
  this.handleError(error, "sendBatchWithTemplate");
99
99
  }
100
100
  }
101
- async sendPasswordReset(to, resetToken, userName) {
101
+ /** Currently unused across all services. Duplicates MailingClient methods. */ async sendPasswordReset(to, resetToken, userName) {
102
102
  return this.sendWithTemplate({
103
103
  to,
104
104
  templateAlias: "password-reset",
@@ -110,7 +110,7 @@ export class EmailClient {
110
110
  tag: "password-reset"
111
111
  });
112
112
  }
113
- async sendEmailConfirmation(to, confirmToken, userName) {
113
+ /** Currently unused across all services. Duplicates MailingClient methods. */ async sendEmailConfirmation(to, confirmToken, userName) {
114
114
  return this.sendWithTemplate({
115
115
  to,
116
116
  templateAlias: "email-confirmation",
@@ -122,7 +122,7 @@ export class EmailClient {
122
122
  tag: "email-confirmation"
123
123
  });
124
124
  }
125
- async sendWelcome(to, userName) {
125
+ /** Currently unused across all services. Duplicates MailingClient methods. */ async sendWelcome(to, userName) {
126
126
  return this.sendWithTemplate({
127
127
  to,
128
128
  templateAlias: "welcome",
@@ -132,6 +132,40 @@ export class EmailClient {
132
132
  tag: "welcome"
133
133
  });
134
134
  }
135
+ /** Currently unused. Added for MailingClient.sendExportsEmail() (plain text email via Postmark /email endpoint). */ async sendEmail(request) {
136
+ try {
137
+ this.logger.info("Sending plain email", {
138
+ to: request.to,
139
+ subject: request.subject
140
+ });
141
+ const payload = {
142
+ From: this.config.POSTMARK_FROM_EMAIL,
143
+ To: request.to,
144
+ Subject: request.subject,
145
+ TextBody: request.textBody,
146
+ HtmlBody: request.htmlBody,
147
+ ReplyTo: request.replyTo || this.config.POSTMARK_REPLY_TO_EMAIL,
148
+ Tag: request.tag,
149
+ Metadata: request.metadata,
150
+ TrackOpens: true,
151
+ TrackLinks: "HtmlAndText"
152
+ };
153
+ const response = await this.client.post("/email", payload);
154
+ this.logger.info("Plain email sent successfully", {
155
+ messageId: response.data.MessageID,
156
+ to: response.data.To
157
+ });
158
+ return {
159
+ messageId: response.data.MessageID,
160
+ to: response.data.To,
161
+ submittedAt: response.data.SubmittedAt,
162
+ errorCode: response.data.ErrorCode,
163
+ message: response.data.Message
164
+ };
165
+ } catch (error) {
166
+ this.handleError(error, "sendEmail");
167
+ }
168
+ }
135
169
  handleError(error, method) {
136
170
  if (axios.isAxiosError(error)) {
137
171
  const status = error.response?.status;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/clients/EmailClient.ts"],"sourcesContent":["import axios, { type AxiosInstance } from \"axios\";\nimport { z } from \"zod\";\nimport { CommonSchemas } from \"../config/ConfigValidator.js\";\nimport { ExternalAPIError } from \"../Errors/AppError.js\";\nimport { Log } from \"../utils/Logger.js\";\n\ntype PostmarkConfig = 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 EmailResponse {\n messageId: string;\n to: string;\n submittedAt: string;\n errorCode?: number;\n message?: string;\n}\n\nexport class EmailClient {\n private static instance: EmailClient;\n private client: AxiosInstance;\n private config: PostmarkConfig;\n private logger = Log.getInstance().extend(\"email-client\");\n\n private constructor(config: PostmarkConfig) {\n this.config = config;\n this.client = axios.create({\n baseURL: \"https://api.postmarkapp.com\",\n timeout: config.POSTMARK_TIMEOUT_MS,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"X-Postmark-Server-Token\": config.POSTMARK_API_KEY,\n },\n });\n }\n\n public static getInstance(): EmailClient {\n if (!EmailClient.instance) {\n const config = CommonSchemas.postmark.parse(process.env);\n EmailClient.instance = new EmailClient(config);\n }\n return EmailClient.instance;\n }\n\n public static resetInstance(): void {\n EmailClient.instance = undefined as any;\n }\n\n public async sendWithTemplate(request: SendTemplateEmailRequest): Promise<EmailResponse> {\n try {\n this.logger.info(\"Sending templated email\", {\n to: request.to,\n templateAlias: request.templateAlias,\n tag: request.tag,\n });\n\n const payload = {\n From: this.config.POSTMARK_FROM_EMAIL,\n To: Array.isArray(request.to) ? request.to.join(\",\") : request.to,\n TemplateAlias: request.templateAlias,\n TemplateModel: request.templateModel,\n Cc: request.cc ? (Array.isArray(request.cc) ? request.cc.join(\",\") : request.cc) : undefined,\n Bcc: request.bcc ? (Array.isArray(request.bcc) ? request.bcc.join(\",\") : request.bcc) : undefined,\n ReplyTo: request.replyTo || this.config.POSTMARK_REPLY_TO_EMAIL,\n Tag: request.tag,\n Metadata: request.metadata,\n TrackOpens: request.trackOpens ?? true,\n TrackLinks: request.trackLinks ?? \"HtmlAndText\",\n };\n\n const response = await this.client.post(\"/email/withTemplate\", payload);\n\n this.logger.info(\"Email sent successfully\", {\n messageId: response.data.MessageID,\n to: response.data.To,\n });\n\n return {\n messageId: response.data.MessageID,\n to: response.data.To,\n submittedAt: response.data.SubmittedAt,\n errorCode: response.data.ErrorCode,\n message: response.data.Message,\n };\n } catch (error) {\n this.handleError(error, \"sendWithTemplate\");\n }\n }\n\n public async sendBatchWithTemplate(request: BatchTemplateEmailRequest): Promise<EmailResponse[]> {\n try {\n this.logger.info(\"Sending batch templated emails\", {\n count: request.emails.length,\n });\n\n const payload = {\n Messages: request.emails.map((email) => ({\n From: this.config.POSTMARK_FROM_EMAIL,\n To: email.to,\n TemplateAlies: email.templateAlias,\n TemplateModel: email.templateModel,\n ReplyTo: this.config.POSTMARK_REPLY_TO_EMAIL,\n Tag: email.tag,\n Metadata: email.metadata,\n TrackOpens: true,\n TrackLinks: \"HtmlAndText\",\n })),\n };\n\n const response = await this.client.post(\"/email/batchWithTemplates\", payload);\n\n this.logger.info(\"Batch emails sent\", {\n count: response.data.length,\n });\n\n return response.data.map((item: any) => ({\n messageId: item.MessageID,\n to: item.To,\n submittedAt: item.SubmittedAt,\n errorCode: item.ErrorCode,\n message: item.Message,\n }));\n } catch (error) {\n this.handleError(error, \"sendBatchWithTemplate\");\n }\n }\n\n public async sendPasswordReset(to: string, resetToken: string, userName: string): Promise<EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"password-reset\",\n templateModel: {\n userName,\n resetToken,\n resetLink: `https://yourapp.com/reset/${resetToken}`,\n },\n tag: \"password-reset\",\n });\n }\n\n public async sendEmailConfirmation(to: string, confirmToken: string, userName: string): Promise<EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"email-confirmation\",\n templateModel: {\n userName,\n confirmToken,\n confirmLink: `https://yourapp.com/confirm/${confirmToken}`,\n },\n tag: \"email-confirmation\",\n });\n }\n\n public async sendWelcome(to: string, userName: string): Promise<EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"welcome\",\n templateModel: { userName },\n tag: \"welcome\",\n });\n }\n\n private handleError(error: unknown, method: string): never {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const data = error.response?.data;\n\n this.logger.error(`Postmark API error in ${method}`, {\n status,\n errorCode: data?.ErrorCode,\n message: data?.Message,\n requestUrl: error.config?.url,\n });\n\n throw new ExternalAPIError(\n `Postmark API error: ${data?.Message || error.message}`,\n `Service: Postmark, Method: ${method}, Status: ${status}, ErrorCode: ${data?.ErrorCode}`\n );\n }\n\n this.logger.error(`Unexpected error in ${method}`, { error });\n throw new ExternalAPIError(\n `Email sending failed: ${error}`,\n `Service: Postmark, Method: ${method}`\n );\n }\n}\n"],"names":["axios","CommonSchemas","ExternalAPIError","Log","EmailClient","instance","client","config","logger","getInstance","extend","create","baseURL","timeout","POSTMARK_TIMEOUT_MS","headers","Accept","POSTMARK_API_KEY","postmark","parse","process","env","resetInstance","undefined","sendWithTemplate","request","info","to","templateAlias","tag","payload","From","POSTMARK_FROM_EMAIL","To","Array","isArray","join","TemplateAlias","TemplateModel","templateModel","Cc","cc","Bcc","bcc","ReplyTo","replyTo","POSTMARK_REPLY_TO_EMAIL","Tag","Metadata","metadata","TrackOpens","trackOpens","TrackLinks","trackLinks","response","post","messageId","data","MessageID","submittedAt","SubmittedAt","errorCode","ErrorCode","message","Message","error","handleError","sendBatchWithTemplate","count","emails","length","Messages","map","email","TemplateAlies","item","sendPasswordReset","resetToken","userName","resetLink","sendEmailConfirmation","confirmToken","confirmLink","sendWelcome","method","isAxiosError","status","requestUrl","url"],"mappings":"AAAA,OAAOA,WAAmC,QAAQ;AAElD,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,GAAG,QAAQ,qBAAqB;AAmCzC,OAAO,MAAMC;IACX,OAAeC,SAAsB;IAC7BC,OAAsB;IACtBC,OAAuB;IACvBC,SAASL,IAAIM,WAAW,GAAGC,MAAM,CAAC,gBAAgB;IAE1D,YAAoBH,MAAsB,CAAE;QAC1C,IAAI,CAACA,MAAM,GAAGA;QACd,IAAI,CAACD,MAAM,GAAGN,MAAMW,MAAM,CAAC;YACzBC,SAAS;YACTC,SAASN,OAAOO,mBAAmB;YACnCC,SAAS;gBACPC,QAAQ;gBACR,gBAAgB;gBAChB,2BAA2BT,OAAOU,gBAAgB;YACpD;QACF;IACF;IAEA,OAAcR,cAA2B;QACvC,IAAI,CAACL,YAAYC,QAAQ,EAAE;YACzB,MAAME,SAASN,cAAciB,QAAQ,CAACC,KAA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,2BAA2B,EAAEqB,OAAO,UAAU,EAAEE,OAAO,aAAa,EAAE7B,MAAMK,WAAW;QAE5F;QAEA,IAAI,CAACtD,MAAM,CAACyD,KAAK,CAAC,CAAC,oBAAoB,EAAEmB,QAAQ,EAAE;YAAEnB;QAAM;QAC3D,MAAM,IAAI/D,iBACR,CAAC,sBAAsB,EAAE+D,OAAO,EAChC,CAAC,2BAA2B,EAAEmB,QAAQ;IAE1C;AACF"}
1
+ {"version":3,"sources":["../../../src/lib/clients/EmailClient.ts"],"sourcesContent":["import axios, { type AxiosInstance } from \"axios\";\nimport { CommonSchemas } from \"../config/ConfigValidator.js\";\nimport { ExternalAPIError } from \"../Errors/AppError.js\";\nimport { Log } from \"../utils/Logger.js\";\nimport type * as t from \"./types/email.types.js\";\n\nexport class EmailClient {\n private static instance: EmailClient;\n private client: AxiosInstance;\n private config: t.Config;\n private logger = Log.getInstance().extend(\"email-client\");\n\n\n constructor(config: t.Config) {\n this.config = config;\n this.client = axios.create({\n baseURL: \"https://api.postmarkapp.com\",\n timeout: config.POSTMARK_TIMEOUT_MS,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"X-Postmark-Server-Token\": config.POSTMARK_API_KEY,\n },\n });\n }\n\n /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */\n public static getInstance(): EmailClient {\n if (!EmailClient.instance) {\n const config = CommonSchemas.postmark.parse(process.env);\n EmailClient.instance = new EmailClient(config);\n }\n return EmailClient.instance;\n }\n\n /** @deprecated Use `new EmailClient(config)` instead. Still used in 90dc-coaching (WebhookService). */\n public static resetInstance(): void {\n EmailClient.instance = undefined as any;\n }\n\n public async sendWithTemplate(request: t.SendTemplateEmailRequest): Promise<t.EmailResponse> {\n try {\n this.logger.info(\"Sending templated email\", {\n to: request.to,\n templateAlias: request.templateAlias,\n tag: request.tag,\n });\n\n const payload = {\n From: this.config.POSTMARK_FROM_EMAIL,\n To: Array.isArray(request.to) ? request.to.join(\",\") : request.to,\n TemplateAlias: request.templateAlias,\n TemplateModel: request.templateModel,\n Cc: request.cc ? (Array.isArray(request.cc) ? request.cc.join(\",\") : request.cc) : undefined,\n Bcc: request.bcc ? (Array.isArray(request.bcc) ? request.bcc.join(\",\") : request.bcc) : undefined,\n ReplyTo: request.replyTo || this.config.POSTMARK_REPLY_TO_EMAIL,\n Tag: request.tag,\n Metadata: request.metadata,\n TrackOpens: request.trackOpens ?? true,\n TrackLinks: request.trackLinks ?? \"HtmlAndText\",\n };\n\n const response = await this.client.post(\"/email/withTemplate\", payload);\n\n this.logger.info(\"Email sent successfully\", {\n messageId: response.data.MessageID,\n to: response.data.To,\n });\n\n return {\n messageId: response.data.MessageID,\n to: response.data.To,\n submittedAt: response.data.SubmittedAt,\n errorCode: response.data.ErrorCode,\n message: response.data.Message,\n };\n } catch (error) {\n this.handleError(error, \"sendWithTemplate\");\n }\n }\n\n /** Currently unused across all services. */\n public async sendBatchWithTemplate(request: t.BatchTemplateEmailRequest): Promise<t.EmailResponse[]> {\n try {\n this.logger.info(\"Sending batch templated emails\", {\n count: request.emails.length,\n });\n\n const payload = {\n Messages: request.emails.map((email) => ({\n From: this.config.POSTMARK_FROM_EMAIL,\n To: email.to,\n TemplateAlias: email.templateAlias,\n TemplateModel: email.templateModel,\n ReplyTo: this.config.POSTMARK_REPLY_TO_EMAIL,\n Tag: email.tag,\n Metadata: email.metadata,\n TrackOpens: true,\n TrackLinks: \"HtmlAndText\",\n })),\n };\n\n const response = await this.client.post(\"/email/batchWithTemplates\", payload);\n\n this.logger.info(\"Batch emails sent\", {\n count: response.data.length,\n });\n\n return response.data.map((item: any) => ({\n messageId: item.MessageID,\n to: item.To,\n submittedAt: item.SubmittedAt,\n errorCode: item.ErrorCode,\n message: item.Message,\n }));\n } catch (error) {\n this.handleError(error, \"sendBatchWithTemplate\");\n }\n }\n\n /** Currently unused across all services. Duplicates MailingClient methods. */\n public async sendPasswordReset(to: string, resetToken: string, userName: string): Promise<t.EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"password-reset\",\n templateModel: {\n userName,\n resetToken,\n resetLink: `https://yourapp.com/reset/${resetToken}`,\n },\n tag: \"password-reset\",\n });\n }\n\n /** Currently unused across all services. Duplicates MailingClient methods. */\n public async sendEmailConfirmation(to: string, confirmToken: string, userName: string): Promise<t.EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"email-confirmation\",\n templateModel: {\n userName,\n confirmToken,\n confirmLink: `https://yourapp.com/confirm/${confirmToken}`,\n },\n tag: \"email-confirmation\",\n });\n }\n\n /** Currently unused across all services. Duplicates MailingClient methods. */\n public async sendWelcome(to: string, userName: string): Promise<t.EmailResponse> {\n return this.sendWithTemplate({\n to,\n templateAlias: \"welcome\",\n templateModel: { userName },\n tag: \"welcome\",\n });\n }\n\n /** Currently unused. Added for MailingClient.sendExportsEmail() (plain text email via Postmark /email endpoint). */\n public async sendEmail(request: t.SendEmailRequest): Promise<t.EmailResponse> {\n try {\n this.logger.info(\"Sending plain email\", {\n to: request.to,\n subject: request.subject,\n });\n\n const payload = {\n From: this.config.POSTMARK_FROM_EMAIL,\n To: request.to,\n Subject: request.subject,\n TextBody: request.textBody,\n HtmlBody: request.htmlBody,\n ReplyTo: request.replyTo || this.config.POSTMARK_REPLY_TO_EMAIL,\n Tag: request.tag,\n Metadata: request.metadata,\n TrackOpens: true,\n TrackLinks: \"HtmlAndText\",\n };\n\n const response = await this.client.post(\"/email\", payload);\n\n this.logger.info(\"Plain email sent successfully\", {\n messageId: response.data.MessageID,\n to: response.data.To,\n });\n\n return {\n messageId: response.data.MessageID,\n to: response.data.To,\n submittedAt: response.data.SubmittedAt,\n errorCode: response.data.ErrorCode,\n message: response.data.Message,\n };\n } catch (error) {\n this.handleError(error, \"sendEmail\");\n }\n }\n\n private handleError(error: unknown, method: string): never {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const data = error.response?.data;\n\n this.logger.error(`Postmark API error in ${method}`, {\n status,\n errorCode: data?.ErrorCode,\n message: data?.Message,\n requestUrl: error.config?.url,\n });\n\n throw new ExternalAPIError(\n `Postmark API error: ${data?.Message || error.message}`,\n `Service: Postmark, Method: ${method}, Status: ${status}, ErrorCode: ${data?.ErrorCode}`\n );\n }\n\n this.logger.error(`Unexpected error in ${method}`, { error });\n throw new ExternalAPIError(\n `Email sending failed: ${error}`,\n `Service: Postmark, Method: ${method}`\n );\n }\n}\n"],"names":["axios","CommonSchemas","ExternalAPIError","Log","EmailClient","instance","client","config","logger","getInstance","extend","create","baseURL","timeout","POSTMARK_TIMEOUT_MS","headers","Accept","POSTMARK_API_KEY","postmark","parse","process","env","resetInstance","undefined","sendWithTemplate","request","info","to","templateAlias","tag","payload","From","POSTMARK_FROM_EMAIL","To","Array","isArray","join","TemplateAlias","TemplateModel","templateModel","Cc","cc","Bcc","bcc","ReplyTo","replyTo","POSTMARK_REPLY_TO_EMAIL","Tag","Metadata","metadata","TrackOpens","trackOpens","TrackLinks","trackLinks","response","post","messageId","data","MessageID","submittedAt","SubmittedAt","errorCode","ErrorCode","message","Message","error","handleError","sendBatchWithTemplate","count","emails","length","Messages","map","email","item","sendPasswordReset","resetToken","userName","resetLink","sendEmailConfirmation","confirmToken","confirmLink","sendWelcome","sendEmail","subject","Subject","TextBody","textBody","HtmlBody","htmlBody","method","isAxiosError","status","requestUrl","url"],"mappings":"AAAA,OAAOA,WAAmC,QAAQ;AAClD,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,GAAG,QAAQ,qBAAqB;AAGzC,OAAO,MAAMC;IACX,OAAeC,SAAsB;IAC7BC,OAAsB;IACtBC,OAAiB;IACjBC,SAASL,IAAIM,WAAW,GAAGC,MAAM,CAAC,gBAAgB;IAG1D,YAAYH,MAAgB,CAAE;QAC5B,IAAI,CAACA,MAAM,GAAGA;QACd,IAAI,CAACD,MAAM,GAAGN,MAAMW,MAAM,CAAC;YACzBC,SAAS;YACTC,SAAS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AY5B,MAAM1D,MAAM,EAAEuF;YAC5B;YAEA,MAAM,IAAI5F,iBACR,CAAC,oBAAoB,EAAEuD,MAAMO,WAAWC,MAAMF,OAAO,EAAE,EACvD,CAAC,2BAA2B,EAAE2B,OAAO,UAAU,EAAEE,OAAO,aAAa,EAAEnC,MAAMK,WAAW;QAE5F;QAEA,IAAI,CAACtD,MAAM,CAACyD,KAAK,CAAC,CAAC,oBAAoB,EAAEyB,QAAQ,EAAE;YAAEzB;QAAM;QAC3D,MAAM,IAAI/D,iBACR,CAAC,sBAAsB,EAAE+D,OAAO,EAChC,CAAC,2BAA2B,EAAEyB,QAAQ;IAE1C;AACF"}
@@ -0,0 +1,17 @@
1
+ import type * as t from "./types/images.types.js";
2
+ export declare class ImagesClient {
3
+ private bucket;
4
+ private logger;
5
+ constructor(config: t.Config);
6
+ saveImage(base64: string, name: string): Promise<void>;
7
+ getImage(name: string): Promise<string | undefined>;
8
+ saveAvatar(userUuid: string, base64: string): Promise<void>;
9
+ getAvatar(userUuid: string): Promise<string | undefined>;
10
+ saveProgressPhoto(userUuid: string, day: number, programId: string, base64: string): Promise<void>;
11
+ getProgressPhotos(userUuid: string, programId: string): Promise<t.ProgressPhoto[]>;
12
+ saveRecipePhotos(input: t.SaveRecipePhotosInput): Promise<void>;
13
+ getRecipePhotos(recipeUuid: string): Promise<t.RecipePhotos | undefined>;
14
+ private base64ToBuffer;
15
+ private handleError;
16
+ }
17
+ //# sourceMappingURL=ImagesClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImagesClient.d.ts","sourceRoot":"","sources":["../../../src/lib/clients/ImagesClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,CAAC,MAAM,yBAAyB,CAAC;AAalD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAA6C;gBAE/C,MAAM,EAAE,CAAC,CAAC,MAAM;IAKf,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IActD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAkBnD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIxD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAalF,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,GAAG,SAAS,CAAC;IAiBrF,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,WAAW;CAOpB"}
@@ -0,0 +1,116 @@
1
+ import admin from "firebase-admin";
2
+ import { ExternalAPIError } from "../Errors/AppError.js";
3
+ import { Log } from "../utils/Logger.js";
4
+ const PROGRESS_DAYS = [
5
+ 1,
6
+ 30,
7
+ 60,
8
+ 90
9
+ ];
10
+ const RECIPE_PHOTO_TYPES = [
11
+ "ingredients",
12
+ "cover",
13
+ "method"
14
+ ];
15
+ const imageName = {
16
+ avatar: (userUuid)=>`${userUuid}--avatar.png`,
17
+ progress: (userUuid, day, programId)=>`${userUuid}--${day}day--${programId}.png`,
18
+ recipe: (recipeUuid, type)=>`${recipeUuid}--${type}.png`
19
+ };
20
+ export class ImagesClient {
21
+ bucket;
22
+ logger = Log.getInstance().extend("images-client");
23
+ constructor(config){
24
+ const app = config.firebaseApp ?? admin.app();
25
+ this.bucket = app.storage().bucket(config.storageBucket);
26
+ }
27
+ async saveImage(base64, name) {
28
+ try {
29
+ this.logger.info("Saving image", {
30
+ name
31
+ });
32
+ const buffer = this.base64ToBuffer(base64);
33
+ const file = this.bucket.file(name);
34
+ await file.save(buffer, {
35
+ contentType: "image/png"
36
+ });
37
+ this.logger.info("Image saved successfully", {
38
+ name
39
+ });
40
+ } catch (error) {
41
+ this.handleError(error, "saveImage");
42
+ }
43
+ }
44
+ async getImage(name) {
45
+ try {
46
+ this.logger.info("Getting image", {
47
+ name
48
+ });
49
+ const file = this.bucket.file(name);
50
+ const [exists] = await file.exists();
51
+ if (!exists) {
52
+ return undefined;
53
+ }
54
+ const [contents] = await file.download();
55
+ return "data:image/jpeg;base64," + contents.toString("base64");
56
+ } catch (error) {
57
+ this.logger.error(`Failed to get image: ${name}`, {
58
+ error
59
+ });
60
+ return undefined;
61
+ }
62
+ }
63
+ async saveAvatar(userUuid, base64) {
64
+ await this.saveImage(base64, imageName.avatar(userUuid));
65
+ }
66
+ async getAvatar(userUuid) {
67
+ return this.getImage(imageName.avatar(userUuid));
68
+ }
69
+ async saveProgressPhoto(userUuid, day, programId, base64) {
70
+ await this.saveImage(base64, imageName.progress(userUuid, day, programId));
71
+ }
72
+ async getProgressPhotos(userUuid, programId) {
73
+ const photos = [];
74
+ for (const day of PROGRESS_DAYS){
75
+ const base64 = await this.getImage(imageName.progress(userUuid, day, programId));
76
+ if (base64) {
77
+ photos.push({
78
+ day,
79
+ base64
80
+ });
81
+ }
82
+ }
83
+ return photos;
84
+ }
85
+ async saveRecipePhotos(input) {
86
+ await Promise.all([
87
+ this.saveImage(input.ingredientBase64, imageName.recipe(input.recipeUuid, "ingredients")),
88
+ this.saveImage(input.coverBase64, imageName.recipe(input.recipeUuid, "cover")),
89
+ this.saveImage(input.methodBase64, imageName.recipe(input.recipeUuid, "method"))
90
+ ]);
91
+ }
92
+ async getRecipePhotos(recipeUuid) {
93
+ const results = await Promise.all(RECIPE_PHOTO_TYPES.map((type)=>this.getImage(imageName.recipe(recipeUuid, type))));
94
+ if (results.every((r)=>!r)) {
95
+ return undefined;
96
+ }
97
+ // BUG: cover/method swapped — preserved from original ImageController.ts to keep backward compat with frontend
98
+ return {
99
+ ingredientBase64: results[0] ?? "",
100
+ methodBase64: results[1] ?? "",
101
+ coverBase64: results[2] ?? ""
102
+ };
103
+ }
104
+ base64ToBuffer(base64) {
105
+ const data = base64.includes(",") ? base64.split(",")[1] : base64;
106
+ return Buffer.from(data, "base64");
107
+ }
108
+ handleError(error, method) {
109
+ this.logger.error(`Firebase Storage error in ${method}`, {
110
+ error
111
+ });
112
+ throw new ExternalAPIError(`Firebase Storage error: ${error instanceof Error ? error.message : String(error)}`, `Service: Firebase Storage, Method: ${method}`);
113
+ }
114
+ }
115
+
116
+ //# sourceMappingURL=ImagesClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/clients/ImagesClient.ts"],"sourcesContent":["import admin from \"firebase-admin\";\nimport { Bucket } from \"@google-cloud/storage\";\nimport { ExternalAPIError } from \"../Errors/AppError.js\";\nimport { Log } from \"../utils/Logger.js\";\nimport type * as t from \"./types/images.types.js\";\n\nconst PROGRESS_DAYS = [1, 30, 60, 90];\n\ntype RecipePhotoType = \"ingredients\" | \"cover\" | \"method\";\nconst RECIPE_PHOTO_TYPES: RecipePhotoType[] = [\"ingredients\", \"cover\", \"method\"];\n\nconst imageName = {\n avatar: (userUuid: string) => `${userUuid}--avatar.png`,\n progress: (userUuid: string, day: number, programId: string) => `${userUuid}--${day}day--${programId}.png`,\n recipe: (recipeUuid: string, type: RecipePhotoType) => `${recipeUuid}--${type}.png`,\n};\n\nexport class ImagesClient {\n private bucket: Bucket;\n private logger = Log.getInstance().extend(\"images-client\");\n\n constructor(config: t.Config) {\n const app = config.firebaseApp ?? admin.app();\n this.bucket = app.storage().bucket(config.storageBucket);\n }\n\n public async saveImage(base64: string, name: string): Promise<void> {\n try {\n this.logger.info(\"Saving image\", { name });\n\n const buffer = this.base64ToBuffer(base64);\n const file = this.bucket.file(name);\n await file.save(buffer, { contentType: \"image/png\" });\n\n this.logger.info(\"Image saved successfully\", { name });\n } catch (error) {\n this.handleError(error, \"saveImage\");\n }\n }\n\n public async getImage(name: string): Promise<string | undefined> {\n try {\n this.logger.info(\"Getting image\", { name });\n\n const file = this.bucket.file(name);\n const [exists] = await file.exists();\n if (!exists) {\n return undefined;\n }\n\n const [contents] = await file.download();\n return \"data:image/jpeg;base64,\" + contents.toString(\"base64\");\n } catch (error) {\n this.logger.error(`Failed to get image: ${name}`, { error });\n return undefined;\n }\n }\n\n public async saveAvatar(userUuid: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.avatar(userUuid));\n }\n\n public async getAvatar(userUuid: string): Promise<string | undefined> {\n return this.getImage(imageName.avatar(userUuid));\n }\n\n public async saveProgressPhoto(userUuid: string, day: number, programId: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.progress(userUuid, day, programId));\n }\n\n public async getProgressPhotos(userUuid: string, programId: string): Promise<t.ProgressPhoto[]> {\n const photos: t.ProgressPhoto[] = [];\n\n for (const day of PROGRESS_DAYS) {\n const base64 = await this.getImage(imageName.progress(userUuid, day, programId));\n if (base64) {\n photos.push({ day, base64 });\n }\n }\n\n return photos;\n }\n\n public async saveRecipePhotos(input: t.SaveRecipePhotosInput): Promise<void> {\n await Promise.all([\n this.saveImage(input.ingredientBase64, imageName.recipe(input.recipeUuid, \"ingredients\")),\n this.saveImage(input.coverBase64, imageName.recipe(input.recipeUuid, \"cover\")),\n this.saveImage(input.methodBase64, imageName.recipe(input.recipeUuid, \"method\")),\n ]);\n }\n\n public async getRecipePhotos(recipeUuid: string): Promise<t.RecipePhotos | undefined> {\n const results = await Promise.all(\n RECIPE_PHOTO_TYPES.map((type) => this.getImage(imageName.recipe(recipeUuid, type)))\n );\n\n if (results.every((r) => !r)) {\n return undefined;\n }\n\n // BUG: cover/method swapped — preserved from original ImageController.ts to keep backward compat with frontend\n return {\n ingredientBase64: results[0] ?? \"\",\n methodBase64: results[1] ?? \"\",\n coverBase64: results[2] ?? \"\",\n };\n }\n\n private base64ToBuffer(base64: string): Buffer {\n const data = base64.includes(\",\") ? base64.split(\",\")[1]! : base64;\n return Buffer.from(data, \"base64\");\n }\n\n private handleError(error: unknown, method: string): never {\n this.logger.error(`Firebase Storage error in ${method}`, { error });\n throw new ExternalAPIError(\n `Firebase Storage error: ${error instanceof Error ? error.message : String(error)}`,\n `Service: Firebase Storage, Method: ${method}`\n );\n }\n}\n"],"names":["admin","ExternalAPIError","Log","PROGRESS_DAYS","RECIPE_PHOTO_TYPES","imageName","avatar","userUuid","progress","day","programId","recipe","recipeUuid","type","ImagesClient","bucket","logger","getInstance","extend","config","app","firebaseApp","storage","storageBucket","saveImage","base64","name","info","buffer","base64ToBuffer","file","save","contentType","error","handleError","getImage","exists","undefined","contents","download","toString","saveAvatar","getAvatar","saveProgressPhoto","getProgressPhotos","photos","push","saveRecipePhotos","input","Promise","all","ingredientBase64","coverBase64","methodBase64","getRecipePhotos","results","map","every","r","data","includes","split","Buffer","from","method","Error","message","String"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AAEnC,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,GAAG,QAAQ,qBAAqB;AAGzC,MAAMC,gBAAgB;IAAC;IAAG;IAAI;IAAI;CAAG;AAGrC,MAAMC,qBAAwC;IAAC;IAAe;IAAS;CAAS;AAEhF,MAAMC,YAAY;IAChBC,QAAQ,CAACC,WAAqB,GAAGA,SAAS,YAAY,CAAC;IACvDC,UAAU,CAACD,UAAkBE,KAAaC,YAAsB,GAAGH,SAAS,EAAE,EAAEE,IAAI,KAAK,EAAEC,UAAU,IAAI,CAAC;IAC1GC,QAAQ,CAACC,YAAoBC,OAA0B,GAAGD,WAAW,EAAE,EAAEC,KAAK,IAAI,CAAC;AACrF;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IAAM,CAACA,IAAI;YAC5B,OAAOrB;QACT;QAEA,+GAA+G;QAC/G,OAAO;YACLc,kBAAkBI,OAAO,CAAC,EAAE,IAAI;YAChCF,cAAcE,OAAO,CAAC,EAAE,IAAI;YAC5BH,aAAaG,OAAO,CAAC,EAAE,IAAI;QAC7B;IACF;IAEQ1B,eAAeJ,MAAc,EAAU;QAC7C,MAAMkC,OAAOlC,OAAOmC,QAAQ,CAAC,OAAOnC,OAAOoC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAIpC;QAC5D,OAAOqC,OAAOC,IAAI,CAACJ,MAAM;IAC3B;IAEQzB,YAAYD,KAAc,EAAE+B,MAAc,EAAS;QACzD,IAAI,CAAChD,MAAM,CAACiB,KAAK,CAAC,CAAC,0BAA0B,EAAE+B,QAAQ,EAAE;YAAE/B;QAAM;QACjE,MAAM,IAAIhC,iBACR,CAAC,wBAAwB,EAAEgC,iBAAiBgC,QAAQhC,MAAMiC,OAAO,GAAGC,OAAOlC,QAAQ,EACnF,CAAC,mCAAmC,EAAE+B,QAAQ;IAElD;AACF"}
@@ -0,0 +1,21 @@
1
+ import type * as t from "./types/mailing.types.js";
2
+ export declare class MailingClient {
3
+ private emailClient;
4
+ private receiverEmail;
5
+ private logger;
6
+ constructor(config: t.Config);
7
+ private send;
8
+ sendEmailConfirmation(email: string, token: string): Promise<void>;
9
+ sendPasswordRecovery(email: string, token: string): Promise<void>;
10
+ sendPasswordRecoveryForPlatform(email: string, token: string): Promise<void>;
11
+ sendPasswordChange(email: string, token: string): Promise<void>;
12
+ sendEmailReminder(email: string, templateAlias: string): Promise<void>;
13
+ sendChallengeEmail(email: string, name: string): Promise<void>;
14
+ sendDeleteAccountEmail(email: string, token: string): Promise<void>;
15
+ sendExportsEmail(subject: string, textBody: string): Promise<void>;
16
+ sendShopifyEmail(input: t.ShopifyEmailInput): Promise<void>;
17
+ sendAndroidFreeTrialEmail(email: string): Promise<void>;
18
+ sendAppleFreeTrialEmail(email: string): Promise<void>;
19
+ static generateDiscountCode(email: string): string;
20
+ }
21
+ //# sourceMappingURL=MailingClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MailingClient.d.ts","sourceRoot":"","sources":["../../../src/lib/clients/MailingClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,CAAC,MAAM,0BAA0B,CAAC;AAEnD,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,MAAM,CAA8C;gBAEhD,MAAM,EAAE,CAAC,CAAC,MAAM;YAKd,IAAI;IAKX,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIlD,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIjD,+BAA+B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAI5D,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAI/C,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IAItD,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI9C,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAI7C,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,iBAAiB;IAI3C,yBAAyB,CAAC,KAAK,EAAE,MAAM;IAIvC,uBAAuB,CAAC,KAAK,EAAE,MAAM;WAI9B,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAM1D"}
@@ -0,0 +1,84 @@
1
+ import { createHash } from "node:crypto";
2
+ import { Log } from "../utils/Logger.js";
3
+ export class MailingClient {
4
+ emailClient;
5
+ receiverEmail;
6
+ logger = Log.getInstance().extend("mailing-client");
7
+ constructor(config){
8
+ this.emailClient = config.emailClient;
9
+ this.receiverEmail = config.receiverEmail;
10
+ }
11
+ async send(email, templateAlias, templateModel, tag) {
12
+ await this.emailClient.sendWithTemplate({
13
+ to: email,
14
+ templateAlias,
15
+ templateModel,
16
+ tag
17
+ });
18
+ this.logger.info(`Sent ${tag} email to ${email}`);
19
+ }
20
+ sendEmailConfirmation(email, token) {
21
+ return this.send(email, "confirm-email", {
22
+ token
23
+ }, "confirm-email");
24
+ }
25
+ sendPasswordRecovery(email, token) {
26
+ return this.send(email, "restore-password", {
27
+ token
28
+ }, "restore-password");
29
+ }
30
+ sendPasswordRecoveryForPlatform(email, token) {
31
+ return this.send(email, "recover-password-platform", {
32
+ token
33
+ }, "recover-password-platform");
34
+ }
35
+ sendPasswordChange(email, token) {
36
+ return this.send(email, "change-password", {
37
+ token
38
+ }, "change-password");
39
+ }
40
+ sendEmailReminder(email, templateAlias) {
41
+ return this.send(email, templateAlias, {
42
+ discount: MailingClient.generateDiscountCode(email)
43
+ }, "email-reminder");
44
+ }
45
+ sendChallengeEmail(email, name) {
46
+ return this.send(email, "accept-challenge", {
47
+ name
48
+ }, "accept-challenge");
49
+ }
50
+ sendDeleteAccountEmail(email, token) {
51
+ return this.send(email, "delete-account", {
52
+ token
53
+ }, "delete-account");
54
+ }
55
+ async sendExportsEmail(subject, textBody) {
56
+ await this.emailClient.sendEmail({
57
+ to: this.receiverEmail,
58
+ subject,
59
+ textBody,
60
+ tag: "exports"
61
+ });
62
+ this.logger.info(`Sent exports email to ${this.receiverEmail}`);
63
+ }
64
+ sendShopifyEmail(input) {
65
+ return this.send(input.email, "shopify-welcome", {
66
+ email: input.email,
67
+ password: input.password
68
+ }, "shopify-welcome");
69
+ }
70
+ sendAndroidFreeTrialEmail(email) {
71
+ return this.send(email, "AndroidFreeTrialExtention", {}, "android-free-trial");
72
+ }
73
+ sendAppleFreeTrialEmail(email) {
74
+ return this.send(email, "IosFreeTrialExtention", {}, "apple-free-trial");
75
+ }
76
+ static generateDiscountCode(email) {
77
+ const hash = createHash("sha256").update(email).digest("hex").toUpperCase();
78
+ const letters = hash.replace(/[^A-Z]/g, "").substring(0, 4);
79
+ const digits = hash.replace(/[^0-9]/g, "").substring(0, 2);
80
+ return (letters + digits).substring(0, 6);
81
+ }
82
+ }
83
+
84
+ //# sourceMappingURL=MailingClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/clients/MailingClient.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { Log } from \"../utils/Logger.js\";\nimport type { EmailClient } from \"./EmailClient.js\";\nimport type * as t from \"./types/mailing.types.js\";\n\nexport class MailingClient {\n private emailClient: EmailClient;\n private receiverEmail: string;\n private logger = Log.getInstance().extend(\"mailing-client\");\n\n constructor(config: t.Config) {\n this.emailClient = config.emailClient;\n this.receiverEmail = config.receiverEmail;\n }\n\n private async send(email: string, templateAlias: string, templateModel: Record<string, any>, tag: string): Promise<void> {\n await this.emailClient.sendWithTemplate({ to: email, templateAlias, templateModel, tag });\n this.logger.info(`Sent ${tag} email to ${email}`);\n }\n\n public sendEmailConfirmation(email: string, token: string) {\n return this.send(email, \"confirm-email\", { token }, \"confirm-email\");\n }\n\n public sendPasswordRecovery(email: string, token: string) {\n return this.send(email, \"restore-password\", { token }, \"restore-password\");\n }\n\n public sendPasswordRecoveryForPlatform(email: string, token: string) {\n return this.send(email, \"recover-password-platform\", { token }, \"recover-password-platform\");\n }\n\n public sendPasswordChange(email: string, token: string) {\n return this.send(email, \"change-password\", { token }, \"change-password\");\n }\n\n public sendEmailReminder(email: string, templateAlias: string) {\n return this.send(email, templateAlias, { discount: MailingClient.generateDiscountCode(email) }, \"email-reminder\");\n }\n\n public sendChallengeEmail(email: string, name: string) {\n return this.send(email, \"accept-challenge\", { name }, \"accept-challenge\");\n }\n\n public sendDeleteAccountEmail(email: string, token: string) {\n return this.send(email, \"delete-account\", { token }, \"delete-account\");\n }\n\n public async sendExportsEmail(subject: string, textBody: string): Promise<void> {\n await this.emailClient.sendEmail({\n to: this.receiverEmail,\n subject,\n textBody,\n tag: \"exports\",\n });\n this.logger.info(`Sent exports email to ${this.receiverEmail}`);\n }\n\n public sendShopifyEmail(input: t.ShopifyEmailInput) {\n return this.send(input.email, \"shopify-welcome\", { email: input.email, password: input.password }, \"shopify-welcome\");\n }\n\n public sendAndroidFreeTrialEmail(email: string) {\n return this.send(email, \"AndroidFreeTrialExtention\", {}, \"android-free-trial\");\n }\n\n public sendAppleFreeTrialEmail(email: string) {\n return this.send(email, \"IosFreeTrialExtention\", {}, \"apple-free-trial\");\n }\n\n public static generateDiscountCode(email: string): string {\n const hash = createHash(\"sha256\").update(email).digest(\"hex\").toUpperCase();\n const letters = hash.replace(/[^A-Z]/g, \"\").substring(0, 4);\n const digits = hash.replace(/[^0-9]/g, \"\").substring(0, 2);\n return (letters + digits).substring(0, 6);\n }\n}\n"],"names":["createHash","Log","MailingClient","emailClient","receiverEmail","logger","getInstance","extend","config","send","email","templateAlias","templateModel","tag","sendWithTemplate","to","info","sendEmailConfirmation","token","sendPasswordRecovery","sendPasswordRecoveryForPlatform","sendPasswordChange","sendEmailReminder","discount","generateDiscountCode","sendChallengeEmail","name","sendDeleteAccountEmail","sendExportsEmail","subject","textBody","sendEmail","sendShopifyEmail","input","password","sendAndroidFreeTrialEmail","sendAppleFreeTrialEmail","hash","update","digest","toUpperCase","letters","replace","substring","digits"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,GAAG,QAAQ,qBAAqB;AAIzC,OAAO,MAAMC;IACHC,YAAyB;IACzBC,cAAsB;IACtBC,SAASJ,IAAIK,WAAW,GAAGC,MAAM,CAAC,kBAAkB;IAE5D,YAAYC,MAAgB,CAAE;QAC5B,IAAI,CAACL,WAAW,GAAGK,OAAOL,WAAW;QACrC,IAAI,CAACC,aAAa,GAAGI,OAAOJ,aAAa;IAC3C;IAEA,MAAcK,KAAKC,KAAa,EAA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I,CAACX,aAAa;YACtByB;YACAC;YACAjB,KAAK;QACP;QACA,IAAI,CAACR,MAAM,CAACW,IAAI,CAAC,CAAC,sBAAsB,EAAE,IAAI,CAACZ,aAAa,EAAE;IAChE;IAEO4B,iBAAiBC,KAA0B,EAAE;QAClD,OAAO,IAAI,CAACxB,IAAI,CAACwB,MAAMvB,KAAK,EAAE,mBAAmB;YAAEA,OAAOuB,MAAMvB,KAAK;YAAEwB,UAAUD,MAAMC,QAAQ;QAAC,GAAG;IACrG;IAEOC,0BAA0BzB,KAAa,EAAE;QAC9C,OAAO,IAAI,CAACD,IAAI,CAACC,OAAO,6BAA6B,CAAC,GAAG;IAC3D;IAEO0B,wBAAwB1B,KAAa,EAAE;QAC5C,OAAO,IAAI,CAACD,IAAI,CAACC,OAAO,yBAAyB,CAAC,GAAG;IACvD;IAEA,OAAcc,qBAAqBd,KAAa,EAAU;QACxD,MAAM2B,OAAOrC,WAAW,UAAUsC,MAAM,CAAC5B,OAAO6B,MAAM,CAAC,OAAOC,WAAW;QACzE,MAAMC,UAAUJ,KAAKK,OAAO,CAAC,WAAW,IAAIC,SAAS,CAAC,GAAG;QACzD,MAAMC,SAASP,KAAKK,OAAO,CAAC,WAAW,IAAIC,SAAS,CAAC,GAAG;QACxD,OAAO,AAACF,CAAAA,UAAUG,MAAK,EAAGD,SAAS,CAAC,GAAG;IACzC;AACF"}
@@ -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,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=email.types.js.map
@@ -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,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=images.types.js.map
@@ -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,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=mailing.types.js.map
@@ -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"}
@@ -28,6 +28,8 @@ export interface RecipeAttributes {
28
28
  imageUploadedAt?: Date | null;
29
29
  createdAt?: Date;
30
30
  updatedAt?: Date;
31
+ translatedRecipes?: TranslatedRecipe[];
32
+ tags?: RecipeTag[];
31
33
  }
32
34
  export interface RecipeCreationAttributes extends Optional<RecipeAttributes, "uuid" | "createdBy" | "createdAt" | "updatedAt" | "coverImageUrl" | "ingredientsImageUrl" | "methodImageUrl" | "imageUploadedAt"> {
33
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Recipe.d.ts","sourceRoot":"","sources":["../../../../src/lib/dbmodels/diet/Recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,EAEN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,OAA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,EAAE,MAAM,CAAC;IAGd,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGpC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG/B,eAAe,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAG9B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAGtC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAGtC,OAAO,EAAE,aAAa,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/dbmodels/diet/Recipe.ts"],"sourcesContent":["import {\n BelongsTo,\n BelongsToMany,\n Column,\n DataType,\n Default,\n ForeignKey,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport type { Optional } from \"sequelize\";\nimport { TranslatedRecipe } from \"./TranslatedRecipe.js\";\nimport { RecipeTag } from \"./RecipeTag.js\";\nimport { RecipeTags } from \"./RecipeTags.js\";\nimport { RecipeIngredient } from \"./RecipeIngredient.js\";\nimport { PersistedUser } from \"../user/PersistedUser.js\";\n\nexport interface RecipeAttributes {\n uuid: string;\n createdBy?: string | null;\n title: string;\n duration: string;\n content: string;\n kcal: string;\n fat: string;\n carbs: string;\n protein: string;\n ingredients: string;\n method: string;\n tipsAndTricks: string;\n ShowForFreeVersion: boolean;\n LockForFreeVersion: boolean;\n isCoachingRecipe: boolean;\n isPublic: boolean;\n order: number;\n coverImageUrl?: string | null;\n ingredientsImageUrl?: string | null;\n methodImageUrl?: string | null;\n imageUploadedAt?: Date | null;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface RecipeCreationAttributes extends Optional<RecipeAttributes, \"uuid\" | \"createdBy\" | \"createdAt\" | \"updatedAt\" | \"coverImageUrl\" | \"ingredientsImageUrl\" | \"methodImageUrl\" | \"imageUploadedAt\"> {\n}\n\n@Table\nexport class Recipe extends Model<RecipeAttributes, RecipeCreationAttributes> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare uuid: string;\n\n @ForeignKey(() => PersistedUser)\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare createdBy: string | null;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare title: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare duration: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare content: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare kcal: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare fat: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare carbs: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare protein: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare ingredients: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare method: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare tipsAndTricks: string;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare ShowForFreeVersion: boolean;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare LockForFreeVersion: boolean;\n\n @Default(true)\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare isCoachingRecipe: boolean;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare isPublic: boolean;\n\n @BelongsToMany(() => RecipeTag, { through: () => RecipeTags, as: \"tags\" })\n declare tags: RecipeTag[];\n\n @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0 })\n declare order: number;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare coverImageUrl?: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare ingredientsImageUrl?: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare methodImageUrl?: string | null;\n\n @Column({ type: DataType.DATE, allowNull: true })\n declare imageUploadedAt?: Date | null;\n\n @HasMany(() => TranslatedRecipe)\n declare translatedRecipes: TranslatedRecipe[];\n\n @HasMany(() => RecipeIngredient, { foreignKey: \"recipeUuid\", onDelete: \"CASCADE\" })\n declare recipeIngredients: RecipeIngredient[];\n\n @BelongsTo(() => PersistedUser)\n declare creator: PersistedUser;\n}\n"],"names":["BelongsTo","BelongsToMany","Column","DataType","Default","ForeignKey","HasMany","Model","Table","TranslatedRecipe","RecipeTag","RecipeTags","RecipeIngredient","PersistedUser","Recipe","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","BOOLEAN","through","as","INTEGER","STRING","DATE","foreignKey","onDelete"],"mappings":";;;;;;AAAA,SACEA,SAAS,EACTC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAE9B,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,aAAa,QAAQ,2BAA2B;AAgCzD,OAAO,MAAMC,eAAeP;AAsF5B;;qBArFoBQ;;QAEhBC,MAAMb,SAASc,IAAI;QACnBC,cAAcf,SAASc,IAAI;QAC3BE,WAAW;QACXC,YAAY;;;;mBAIIP;;QAEhBG,MAAMb,SAASc,IAAI;QACnBE,WAAW;;;;;QAIHH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASkB,IAAI;QAAEF,WAAW;;;;;QAGhCH,MAAMb,SAASmB,OAAO;QAAEH,WAAW;QAAOD,cAAc;;;;;QAGxDF,MAAMb,SAASmB,OAAO;QAAEH,WAAW;QAAOD,cAAc;;;;;;QAIxDF,MAAMb,SAASmB,OAAO;QAAEH,WAAW;QAAOD,cAAc;;;;;QAGxDF,MAAMb,SAASmB,OAAO;QAAEH,WAAW;QAAOD,cAAc;;;;sBAG7CR;QAAaa,SAAS,IAAMZ;QAAYa,IAAI;;;;;QAGvDR,MAAMb,SAASsB,OAAO;QAAEN,WAAW;QAAOD,cAAc;;;;;QAGxDF,MAAMb,SAASuB,MAAM,CAAC;QAAMP,WAAW;;;;;QAGvCH,MAAMb,SAASuB,MAAM,CAAC;QAAMP,WAAW;;;;;QAGvCH,MAAMb,SAASuB,MAAM,CAAC;QAAMP,WAAW;;;;;QAGvCH,MAAMb,SAASwB,IAAI;QAAER,WAAW;;;;gBAG3BV;;;gBAGAG;QAAoBgB,YAAY;QAAcC,UAAU;;;;kBAGtDhB"}
1
+ {"version":3,"sources":["../../../../src/lib/dbmodels/diet/Recipe.ts"],"sourcesContent":["import {\n BelongsTo,\n BelongsToMany,\n Column,\n DataType,\n Default,\n ForeignKey,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport type { Optional } from \"sequelize\";\nimport { TranslatedRecipe } from \"./TranslatedRecipe.js\";\nimport { RecipeTag } from \"./RecipeTag.js\";\nimport { RecipeTags } from \"./RecipeTags.js\";\nimport { RecipeIngredient } from \"./RecipeIngredient.js\";\nimport { PersistedUser } from \"../user/PersistedUser.js\";\n\nexport interface RecipeAttributes {\n uuid: string;\n createdBy?: string | null;\n title: string;\n duration: string;\n content: string;\n kcal: string;\n fat: string;\n carbs: string;\n protein: string;\n ingredients: string;\n method: string;\n tipsAndTricks: string;\n ShowForFreeVersion: boolean;\n LockForFreeVersion: boolean;\n isCoachingRecipe: boolean;\n isPublic: boolean;\n order: number;\n coverImageUrl?: string | null;\n ingredientsImageUrl?: string | null;\n methodImageUrl?: string | null;\n imageUploadedAt?: Date | null;\n createdAt?: Date;\n updatedAt?: Date;\n translatedRecipes?: TranslatedRecipe[];\n tags?: RecipeTag[];\n}\n\nexport interface RecipeCreationAttributes extends Optional<RecipeAttributes, \"uuid\" | \"createdBy\" | \"createdAt\" | \"updatedAt\" | \"coverImageUrl\" | \"ingredientsImageUrl\" | \"methodImageUrl\" | \"imageUploadedAt\"> {\n}\n\n@Table\nexport class Recipe extends Model<RecipeAttributes, RecipeCreationAttributes> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare uuid: string;\n\n @ForeignKey(() => PersistedUser)\n @Column({\n type: DataType.UUID,\n allowNull: true,\n })\n declare createdBy: string | null;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare title: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare duration: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare content: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare kcal: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare fat: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare carbs: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare protein: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare ingredients: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare method: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare tipsAndTricks: string;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare ShowForFreeVersion: boolean;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare LockForFreeVersion: boolean;\n\n @Default(true)\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare isCoachingRecipe: boolean;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })\n declare isPublic: boolean;\n\n @BelongsToMany(() => RecipeTag, { through: () => RecipeTags, as: \"tags\" })\n declare tags: RecipeTag[];\n\n @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0 })\n declare order: number;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare coverImageUrl?: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare ingredientsImageUrl?: string | null;\n\n @Column({ type: DataType.STRING(500), allowNull: true })\n declare methodImageUrl?: string | null;\n\n @Column({ type: DataType.DATE, allowNull: true })\n declare imageUploadedAt?: Date | null;\n\n @HasMany(() => TranslatedRecipe)\n declare translatedRecipes: TranslatedRecipe[];\n\n @HasMany(() => RecipeIngredient, { foreignKey: \"recipeUuid\", onDelete: \"CASCADE\" })\n declare recipeIngredients: RecipeIngredient[];\n\n @BelongsTo(() => PersistedUser)\n declare creator: PersistedUser;\n}\n"],"names":["BelongsTo","BelongsToMany","Column","DataType","Default","ForeignKey","HasMany","Model","Table","TranslatedRecipe","RecipeTag","RecipeTags","RecipeIngredient","PersistedUser","Recipe","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","BOOLEAN","through","as","INTEGER","STRING","DATE","foreignKey","onDelete"],"mappings":";;;;;;AAAA,SACEA,SAAS,EACTC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAE9B,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,aAAa,QAAQ,2BAA2B;AAkCzD,OAAO,MAAMC,eAAeP;AAsF5B;;qBArFoBQ;;QAEhB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8,7 @@ export interface DraftExercise {
8
8
  sets: number;
9
9
  reps: string;
10
10
  order: number;
11
+ exerciseModelUuid: string;
11
12
  restTime?: string | number | null;
12
13
  supersetUuid?: string | null;
13
14
  thumbnailUrl?: string | null;
@@ -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,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,CAAC;CAClD;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,SAAS,EAAE,aAAa,EAAE,C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ACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAG3B,oBAAoB,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAGnD,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAED,qBACa,oBAAqB,SAAQ,KAAK;IAOrC,IAAI,EAAE,MAAM,CAAC;IAOb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAQ7B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAOlC,QAAQ,EAAE,MAAM,CAAC;IAOjB,kBAAkB,EAAE,MAAM,CAAC;IAM3B,SAAS,EAAE,wBAAwB,CAAC;IAQpC,MAAM,EAAE,WAAW,CAAC;IAMpB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAGzB,SAAS,EAAE,sBAAsB,CAAC;IAGlC,gBAAgB,EAAE,OAAO,CAAC;CACnC"}
@@ -1 +1 @@
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 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;AAyFrE,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"}
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"}
@@ -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;YACZhB,Q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f;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,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MA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AG,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,IAAI,CAACd,MAAM,CAACQ,IAAI,CAAC,+BAA+B;gBACrEI;gBACAC;YACF;YACA,OAAOC,SAASC,IAAI,CAACC,SAAS;QAChC,EAAE,OAAOP,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,uCAAuCD;YACxD,MAAMA;QACR;IACF;IAEA;;;;;;;;;;;;;GAaC,GACD,MAAMQ,YACJC,SAAmB,EACnBL,YAAiC,EAClB;QACf,IAAI;YACF,MAAM,IAAI,CAACb,MAAM,CAACQ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C,OAAO7B,SAASC,IAAI;QACtB,EAAE,OAAON,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,+BAA+BD;YAChD,MAAMA;QACR;IACF;IAEA;;;;;GAKC,GACD,MAAMoC,mBAAmBT,IAAY,EAAEM,QAAiB,EAAiB;QACvE,IAAI;YACF,MAAMR,SAASQ,WAAW;gBAAEA;YAAS,IAAI,CAAC;YAC1C,MAAM,IAAI,CAAC1C,MAAM,CAAC8C,MAAM,CAAC,CAAC,oCAAoC,EAAEV,MAAM,EAAE;gBACtEF;YACF;QACF,EAAE,OAAOzB,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,iCAAiCD;QACpD;IACF;IAEA,2DAA2D;IAE3D;;GAEC,GACD,AAAQC,YAAYqC,OAAe,EAAEtC,KAAc,EAAQ;QACzD,IAAIX,MAAMkD,YAAY,CAACvC,QAAQ;YAC7B,MAAMwC,aAAaxC;YACnB,MAAMyC,SAASD,WAAWnC,QAAQ,EAAEoC;YACpC,MAAMnC,OAAOkC,WAAWnC,QAAQ,EAAEC;YAElCoC,QAAQ1C,KAAK,CAAC,CAAC,qBAAqB,EAAEsC,QAAQ,CAAC,CAAC,EAAE;gBAChDG;gBACAH,SAASE,WAAWF,OAAO;gBAC3BhC;YACF;YAEA,MAAM,IAAIqC,MACR,GAAGL,QAAQ,EAAE,EAAEG,SAAS,CAAC,KAAK,EAAEA,QAAQ,GAAGD,WAAWF,OAAO,EAAE;QAEnE;QAEAI,QAAQ1C,KAAK,CAAC,CAAC,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,MAAMC,WAAW,MAAM,IAAI,CAACd,MAAM,CAACQ,IAAI,CAAC,+BAA+B;gBACrEI;gBACAC;YACF;YACA,OAAOC,SAASC,IAAI,CAACC,SAAS;QAChC,EAAE,OAAOP,OAAO;YACd,IAAI,CAACC,WAAW,CAAC,uCAAuCD;YACxD,MAAMA;QACR;IACF;IAEA;;;;;;;;;;;;;GAaC,GACD,MAAMQ,YACJC,SAAmB,EACnBL,YAAiC,EAClB;QACf,IAAI;YACF,MAAM,IAAI,CAAC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,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.17.0",
3
+ "version": "1.18.1",
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",