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 catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"schemaType": "JSON",
"protocol": "kafka",
"path": "kafka/notification.schema.json",
"producers": ["identity-service", "access-control-service"],
"producers": ["hr-service", "identity-service", "access-control-service"],
"consumers": ["notification-service"]
},
{
Expand Down
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.6.0",
"version": "3.7.0",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"exports": {
Expand Down
9 changes: 9 additions & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ export enum MessageTemplate {
ASSIGNMENT_REVOKED = "ASSIGNMENT_REVOKED",
REALM_EXCLUDED = "REALM_EXCLUDED",

// HR: approval and execution are separate lifecycle events
HR_APPROVAL_REQUIRED = "HR_APPROVAL_REQUIRED",
HR_APPROVAL_REASSIGNED = "HR_APPROVAL_REASSIGNED",
HR_REQUEST_RETURNED = "HR_REQUEST_RETURNED",
HR_REQUEST_REJECTED = "HR_REQUEST_REJECTED",
HR_REQUEST_APPROVED = "HR_REQUEST_APPROVED",
HR_REQUEST_APPLIED = "HR_REQUEST_APPLIED",
HR_REQUEST_FAILED = "HR_REQUEST_FAILED",

// identity: invites
INVITE_CANCELLED = "INVITE_CANCELLED",
INVITE_RECEIVED = "INVITE_RECEIVED",
Expand Down
156 changes: 147 additions & 9 deletions src/kafka/notification.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"organization-service",
"certificate-service",
"identity-service",
"template-service"
"template-service",
"hr-service"
]
},
"dedupKey": { "type": "string" },
Expand Down Expand Up @@ -83,7 +84,8 @@
"organization-service",
"certificate-service",
"identity-service",
"template-service"
"template-service",
"hr-service"
]
},
"dedupKey": { "type": "string" },
Expand Down Expand Up @@ -121,11 +123,61 @@
"ASSIGNMENT_REVOKED",
"REALM_EXCLUDED",
"INVITE_CANCELLED",
"INVITE_RECEIVED"
"INVITE_RECEIVED",
"HR_APPROVAL_REQUIRED",
"HR_APPROVAL_REASSIGNED",
"HR_REQUEST_RETURNED",
"HR_REQUEST_REJECTED",
"HR_REQUEST_APPROVED",
"HR_REQUEST_APPLIED",
"HR_REQUEST_FAILED"
]
},
"language": { "type": "string" }
}
},
"allOf": [
{
"if": {
"properties": {
"template": {
"enum": [
"HR_APPROVAL_REQUIRED",
"HR_APPROVAL_REASSIGNED",
"HR_REQUEST_RETURNED",
"HR_REQUEST_REJECTED",
"HR_REQUEST_APPROVED",
"HR_REQUEST_APPLIED",
"HR_REQUEST_FAILED"
]
}
}
},
"then": {
"required": ["dedupKey", "params"],
"properties": {
"sourceService": { "const": "hr-service" },
"params": {
"type": "object",
"additionalProperties": false,
"required": ["requestId", "requestType"],
"properties": {
"requestId": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
},
"requestType": {
"enum": [
"HIRE", "REHIRE", "TRANSFER", "CHANGE_TERMS", "TERMINATE",
"ABSENCE", "OVERTIME", "LEAVE_ADJUSTMENT", "CANCEL_REQUEST"
]
}
}
}
},
"not": { "required": ["delivery"] }
}
}
]
}
}
}
Expand Down Expand Up @@ -180,7 +232,8 @@
"organization-service",
"certificate-service",
"identity-service",
"template-service"
"template-service",
"hr-service"
]
},
"dedupKey": { "type": "string" },
Expand Down Expand Up @@ -226,7 +279,8 @@
"organization-service",
"certificate-service",
"identity-service",
"template-service"
"template-service",
"hr-service"
]
},
"dedupKey": { "type": "string" },
Expand Down Expand Up @@ -259,16 +313,66 @@
"ACCOUNT_VERIFICATION_OTP",
"RESET_PASSWORD_OTP",
"LOGIN_OTP",
"REAUTHENTICATION_OTP",
"REAUTHENTICATION_OTP",
"ASSIGNMENT_GRANTED",
"ASSIGNMENT_REVOKED",
"REALM_EXCLUDED",
"INVITE_CANCELLED",
"INVITE_RECEIVED"
"INVITE_RECEIVED",
"HR_APPROVAL_REQUIRED",
"HR_APPROVAL_REASSIGNED",
"HR_REQUEST_RETURNED",
"HR_REQUEST_REJECTED",
"HR_REQUEST_APPROVED",
"HR_REQUEST_APPLIED",
"HR_REQUEST_FAILED"
]
},
"language": { "type": "string" }
}
},
"allOf": [
{
"if": {
"properties": {
"template": {
"enum": [
"HR_APPROVAL_REQUIRED",
"HR_APPROVAL_REASSIGNED",
"HR_REQUEST_RETURNED",
"HR_REQUEST_REJECTED",
"HR_REQUEST_APPROVED",
"HR_REQUEST_APPLIED",
"HR_REQUEST_FAILED"
]
}
}
},
"then": {
"required": ["dedupKey", "params"],
"properties": {
"sourceService": { "const": "hr-service" },
"params": {
"type": "object",
"additionalProperties": false,
"required": ["requestId", "requestType"],
"properties": {
"requestId": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
},
"requestType": {
"enum": [
"HIRE", "REHIRE", "TRANSFER", "CHANGE_TERMS", "TERMINATE",
"ABSENCE", "OVERTIME", "LEAVE_ADJUSTMENT", "CANCEL_REQUEST"
]
}
}
}
},
"not": { "required": ["delivery"] }
}
}
]
}
}
}
Expand All @@ -279,6 +383,40 @@
}
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": ["actionType", "payload"],
"properties": {
"actionType": { "const": "CANCEL" },
"payload": {
"type": "object",
"additionalProperties": false,
"required": ["realm", "input"],
"properties": {
"actor": { "type": "string" },
"realm": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
},
"input": {
"type": "object",
"additionalProperties": false,
"required": ["invalidate", "recipient", "sourceService", "dedupKey"],
"properties": {
"invalidate": { "const": true },
"recipient": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
},
"sourceService": { "const": "hr-service" },
"dedupKey": { "type": "string", "minLength": 1 }
}
}
}
}
}
}
]
}
58 changes: 51 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,12 @@ declare global {
payload: {
actor?: string;
realm?: string;
input: {
override: NotificationSpec;
dedupKey: string;
};
input:
| {
override: NotificationSpec;
dedupKey: string;
}
| InvalidateInput;
};
};

Expand All @@ -642,6 +644,29 @@ declare global {
address: string;
};

type InvalidateInput = {
invalidate: true;
recipient: string;
sourceService: PlatformService.HR_SERVICE;
dedupKey: string;
};

type HRRequestType =
| "HIRE"
| "REHIRE"
| "TRANSFER"
| "CHANGE_TERMS"
| "TERMINATE"
| "ABSENCE"
| "OVERTIME"
| "LEAVE_ADJUSTMENT"
| "CANCEL_REQUEST";

type HRTemplateParams = {
requestId: string;
requestType: HRRequestType;
};

type BaseInput = {
delivery?: Delivery;
category: NotificationCategory;
Expand All @@ -657,12 +682,31 @@ declare global {
text: string;
};

type HRTemplate =
| MessageTemplate.HR_APPROVAL_REASSIGNED
| MessageTemplate.HR_APPROVAL_REQUIRED
| MessageTemplate.HR_REQUEST_RETURNED
| MessageTemplate.HR_REQUEST_REJECTED
| MessageTemplate.HR_REQUEST_APPROVED
| MessageTemplate.HR_REQUEST_APPLIED
| MessageTemplate.HR_REQUEST_FAILED;

type TemplateInput = BaseInput & {
kind: NotificationContentKind.TEMPLATE;
params?: Record<string, string>;
template: MessageTemplate;
language?: string;
};
} & (
| {
template: Exclude<MessageTemplate, HRTemplate>;
params?: Record<string, string>;
}
| {
sourceService: PlatformService.HR_SERVICE;
params: HRTemplateParams;
template: HRTemplate;
dedupKey: string;
delivery?: never;
}
);
}

namespace MessageDispatch {
Expand Down
Loading