diff --git a/migrations/1719410008992-seedNotificationTypeForOnboardingGuide.ts b/migrations/1719410008992-seedNotificationTypeForOnboardingGuide.ts new file mode 100644 index 0000000..4e07f60 --- /dev/null +++ b/migrations/1719410008992-seedNotificationTypeForOnboardingGuide.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm" +import { NotificationType, SCHEMA_VALIDATORS_NAMES } from '../src/entities/notificationType'; +import { NOTIFICATION_CATEGORY, NOTIFICATION_TYPE_NAMES } from '../src/types/general'; +import { MICRO_SERVICES } from '../src/utils/utils'; + +const OnboardingNotificationType = [ + { + name: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, + description: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, + microService: MICRO_SERVICES.givethio, + category: NOTIFICATION_CATEGORY.ORTTO, + schemaValidator: SCHEMA_VALIDATORS_NAMES.SUBSCRIBE_ONBOARDING, + } +] + +export class seedNotificationTypeForOnboardingGuide1719410008992 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.manager.save(NotificationType, OnboardingNotificationType); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `DELETE FROM notification_type WHERE "name" = 'Subscribe onboarding';`, + ); + } +} diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 888600d..db6bd83 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -17,6 +17,7 @@ import { NotificationSetting } from './notificationSetting'; // Export Object with Schemas to N1 lookup export const SCHEMA_VALIDATORS_NAMES = { CREATE_ORTTO_PROFILE: 'createOrttoProfile', + SUBSCRIBE_ONBOARDING: 'subscribeOnboarding', SUPERFLUID: 'userSuperTokensCritical', ADMIN_MESSAGE: 'adminMessage', RAW_HTML_BROADCAST: 'rawHtmlBroadcast', diff --git a/src/types/general.ts b/src/types/general.ts index 62516a5..83b5a09 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -51,5 +51,6 @@ export enum NOTIFICATION_TYPE_NAMES { PROJECT_HAS_A_NEW_RANK = 'Your project has a new rank', PROJECT_HAS_RISEN_IN_THE_RANK = 'Your Project has risen in the rank', YOUR_PROJECT_GOT_A_RANK = 'Your project got a rank', + SUBSCRIBE_ONBOARDING = 'Subscribe onboarding', CREATE_ORTTO_PROFILE = 'Create Ortto profile', } diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index c932ca1..3009976 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -159,6 +159,10 @@ const superFluidTokenSegmentSchema = Joi.object({ isEnded: Joi.boolean(), }); +const subscribeOnboardingSchema = Joi.object({ + email: Joi.string().required(), +}) + const createOrttoProfileSegmentSchema = Joi.object({ email: Joi.string().required(), firstName: Joi.string().required(), @@ -176,6 +180,10 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { segment: createOrttoProfileSegmentSchema, metadata: null }, + subscribeOnboarding: { + segment: subscribeOnboardingSchema, + metadata: null + }, userSuperTokensCritical: { metadata: superFluidTokenMetadataSchema, segment: superFluidTokenSegmentSchema,