diff --git a/package.json b/package.json index 33406ad..d889d4d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Shared Kafka/gRPC contracts and common enums between MonadIAM services", "author": "Daniil Egorov (https://github.com/Lambdius)", "license": "UNLICENSED", - "version": "3.1.4", + "version": "3.1.5", "types": "dist/index.d.ts", "main": "dist/index.js", "exports": { diff --git a/src/enums.ts b/src/enums.ts index 17b7a6e..b1888d6 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -99,6 +99,14 @@ export enum InvalidationScope { /* eslint-enable prettier/prettier */ } +export enum ChannelType { + /* eslint-disable prettier/prettier */ + IN_APP = "IN_APP", + EMAIL = "EMAIL", + SMS = "SMS", + /* eslint-enable prettier/prettier */ +} + export enum NotificationContentKind { /* eslint-disable prettier/prettier */ TEMPLATE = "TEMPLATE", diff --git a/src/kafka/notification.schema.json b/src/kafka/notification.schema.json index cb62368..078fffe 100644 --- a/src/kafka/notification.schema.json +++ b/src/kafka/notification.schema.json @@ -41,6 +41,15 @@ ] }, "dedupKey": { "type": "string" }, + "delivery": { + "type": "object", + "additionalProperties": false, + "required": ["channelType", "address"], + "properties": { + "channelType": { "type": "string", "enum": ["EMAIL", "SMS"] }, + "address": { "type": "string", "minLength": 1 } + } + }, "language": { "type": "string", "minLength": 1 }, "title": { "type": "string" }, "text": { "type": "string" } @@ -58,7 +67,7 @@ "input": { "type": "object", "additionalProperties": false, - "required": ["kind", "recipient", "category", "sourceService", "template", "language"], + "required": ["kind", "recipient", "category", "sourceService", "template"], "properties": { "kind": { "const": "TEMPLATE" }, "recipient": { "type": "string" }, @@ -78,6 +87,15 @@ ] }, "dedupKey": { "type": "string" }, + "delivery": { + "type": "object", + "additionalProperties": false, + "required": ["channelType", "address"], + "properties": { + "channelType": { "type": "string", "enum": ["EMAIL", "SMS"] }, + "address": { "type": "string", "minLength": 1 } + } + }, "params": { "type": "object", "additionalProperties": { "type": "string" } @@ -164,6 +182,15 @@ ] }, "dedupKey": { "type": "string" }, + "delivery": { + "type": "object", + "additionalProperties": false, + "required": ["channelType", "address"], + "properties": { + "channelType": { "type": "string", "enum": ["EMAIL", "SMS"] }, + "address": { "type": "string", "minLength": 1 } + } + }, "language": { "type": "string", "minLength": 1 }, "title": { "type": "string" }, "text": { "type": "string" } @@ -181,7 +208,7 @@ "input": { "type": "object", "additionalProperties": false, - "required": ["kind", "recipient", "category", "sourceService", "template", "language"], + "required": ["kind", "recipient", "category", "sourceService", "template"], "properties": { "kind": { "const": "TEMPLATE" }, "recipient": { "type": "string" }, @@ -201,6 +228,15 @@ ] }, "dedupKey": { "type": "string" }, + "delivery": { + "type": "object", + "additionalProperties": false, + "required": ["channelType", "address"], + "properties": { + "channelType": { "type": "string", "enum": ["EMAIL", "SMS"] }, + "address": { "type": "string", "minLength": 1 } + } + }, "params": { "type": "object", "additionalProperties": { "type": "string" } diff --git a/src/types.ts b/src/types.ts index 8282af1..40d765e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,6 +17,7 @@ import { MessageTemplate, PlatformService, PrivilegeScope, + ChannelType, RealmType, } from "./enums"; @@ -513,7 +514,13 @@ declare global { realm?: string; }; + type Delivery = { + channelType: ChannelType.EMAIL | ChannelType.SMS; + address: string; + }; + type BaseInput = { + delivery?: Delivery; category: NotificationCategory; sourceService: PlatformService; recipient: string; @@ -531,7 +538,7 @@ declare global { kind: NotificationContentKind.TEMPLATE; params?: Record; template: MessageTemplate; - language: string; + language?: string; }; }