Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.0",
"version": "3.3.0",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"exports": {
Expand Down
9 changes: 6 additions & 3 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ export enum NotificationTopicAction {

export enum AccountTopicAction {
/* eslint-disable prettier/prettier */
CREATE = "CREATE",
VERIFY = "VERIFY",
PURGE = "PURGE",
EMAIL_VERIFIED = "EMAIL_VERIFIED",
EMAIL_SELECTED = "EMAIL_SELECTED",
EMAIL_PURGED = "EMAIL_PURGED",
CREATE = "CREATE",
VERIFY = "VERIFY",
PURGE = "PURGE",
/* eslint-enable prettier/prettier */
}

Expand Down
36 changes: 35 additions & 1 deletion src/kafka/account.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"properties": {
"actionType": {
"type": "string",
"enum": ["CREATE", "VERIFY", "PURGE"]
"enum": ["CREATE", "VERIFY", "PURGE", "EMAIL_VERIFIED", "EMAIL_SELECTED", "EMAIL_PURGED"]
},
"payload": {
"type": "object",
Expand Down Expand Up @@ -36,6 +36,9 @@
}
}
},
"replacement": {
"$ref": "#/properties/payload/properties/identifier"
},
"otp": {
"type": "string",
"minLength": 1
Expand Down Expand Up @@ -77,6 +80,37 @@
}
}
}
},
{
"if": {
"properties": {
"actionType": { "enum": ["EMAIL_VERIFIED", "EMAIL_SELECTED", "EMAIL_PURGED"] }
}
},
"then": {
"properties": {
"payload": {
"required": ["account", "identifier"],
"properties": {
"identifier": { "properties": { "type": { "const": "email" } } },
"replacement": { "properties": { "type": { "const": "email" } } }
},
"not": { "required": ["otp"] }
}
}
}
},
{
"if": {
"properties": {
"actionType": { "not": { "const": "EMAIL_PURGED" } }
}
},
"then": {
"properties": {
"payload": { "not": { "required": ["replacement"] } }
}
}
}
]
}
35 changes: 34 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,40 @@ declare global {
payload: { account: string };
};

type Message = CreateMessage | VerifyMessage | PurgeMessage;
type EmailIdentifier = Identifier & { type: "email" };

type EmailVerifiedMessage = {
actionType: AccountTopicAction.EMAIL_VERIFIED;
payload: {
identifier: EmailIdentifier;
account: string;
};
};

type EmailSelectedMessage = {
actionType: AccountTopicAction.EMAIL_SELECTED;
payload: {
identifier: EmailIdentifier;
account: string;
};
};

type EmailPurgedMessage = {
actionType: AccountTopicAction.EMAIL_PURGED;
payload: {
replacement?: EmailIdentifier;
identifier: EmailIdentifier;
account: string;
};
};

type Message =
| EmailVerifiedMessage
| EmailSelectedMessage
| EmailPurgedMessage
| CreateMessage
| VerifyMessage
| PurgeMessage;
}

namespace Notification {
Expand Down
Loading