diff --git a/package.json b/package.json index 865d675..9b54e1e 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.5.0", + "version": "3.6.0", "types": "dist/index.d.ts", "main": "dist/index.js", "exports": { diff --git a/src/enums.ts b/src/enums.ts index 4283e99..441f1ca 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -156,6 +156,9 @@ export enum RealmType { export enum RealmTopicAction { /* eslint-disable prettier/prettier */ + MEMBERSHIP_ENSURE_REQUESTED = "MEMBERSHIP_ENSURE_REQUESTED", + MEMBERSHIP_ENSURE_CONFIRMED = "MEMBERSHIP_ENSURE_CONFIRMED", + MEMBERSHIP_ENSURE_REJECTED = "MEMBERSHIP_ENSURE_REJECTED", MEMBERSHIP_JOIN_REQUESTED = "MEMBERSHIP_JOIN_REQUESTED", MEMBERSHIP_JOIN_CONFIRMED = "MEMBERSHIP_JOIN_CONFIRMED", MEMBERSHIP_JOIN_REJECTED = "MEMBERSHIP_JOIN_REJECTED", diff --git a/src/kafka/realm.schema.json b/src/kafka/realm.schema.json index dee51b1..0e52dc8 100644 --- a/src/kafka/realm.schema.json +++ b/src/kafka/realm.schema.json @@ -3,6 +3,126 @@ "$id": "https://schemas.monadiam.local/kafka/realm-value.json", "title": "RealmValue", "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["actionType", "payload"], + "properties": { + "actionType": { + "const": "MEMBERSHIP_ENSURE_REQUESTED" + }, + "payload": { + "type": "object", + "additionalProperties": false, + "required": ["actor", "realm", "input"], + "properties": { + "actor": { + "type": "string" + }, + "realm": { + "type": "string" + }, + "input": { + "type": "object", + "additionalProperties": false, + "required": ["organization", "process", "account"], + "properties": { + "organization": { + "type": "string" + }, + "process": { + "type": "string" + }, + "account": { + "type": "string" + } + } + } + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["actionType", "payload"], + "properties": { + "actionType": { + "const": "MEMBERSHIP_ENSURE_CONFIRMED" + }, + "payload": { + "type": "object", + "additionalProperties": false, + "required": ["actor", "realm", "input"], + "properties": { + "actor": { + "type": "string" + }, + "realm": { + "type": "string" + }, + "input": { + "type": "object", + "additionalProperties": false, + "required": ["organization", "process", "account"], + "properties": { + "organization": { + "type": "string" + }, + "process": { + "type": "string" + }, + "account": { + "type": "string" + } + } + } + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["actionType", "payload"], + "properties": { + "actionType": { + "const": "MEMBERSHIP_ENSURE_REJECTED" + }, + "payload": { + "type": "object", + "additionalProperties": false, + "required": ["actor", "realm", "input"], + "properties": { + "actor": { + "type": "string" + }, + "realm": { + "type": "string" + }, + "input": { + "type": "object", + "additionalProperties": false, + "required": ["organization", "process", "account", "reason"], + "properties": { + "organization": { + "type": "string" + }, + "process": { + "type": "string" + }, + "account": { + "type": "string" + }, + "reason": { + "type": "string" + } + } + } + } + } + } + }, { "type": "object", "additionalProperties": false, @@ -39,6 +159,9 @@ "account": { "type": "string" }, + "hrRequest": { + "type": "string" + }, "invite": { "type": "string" }, @@ -95,6 +218,9 @@ "account": { "type": "string" }, + "hrRequest": { + "type": "string" + }, "invite": { "type": "string" }, @@ -155,6 +281,9 @@ "account": { "type": "string" }, + "hrRequest": { + "type": "string" + }, "invite": { "type": "string" }, diff --git a/src/types.ts b/src/types.ts index 0c6806f..a0bd276 100644 --- a/src/types.ts +++ b/src/types.ts @@ -252,6 +252,9 @@ declare global { namespace Realm { type Message = + | MembershipEnsureRequestedMessage + | MembershipEnsureConfirmedMessage + | MembershipEnsureRejectedMessage | MembershipJoinRequestedMessage | MembershipJoinConfirmedMessage | MembershipJoinRejectedMessage @@ -269,6 +272,46 @@ declare global { | AccountAccessMessage | LifecycleMessage; + type MembershipEnsureRequestedMessage = { + actionType: RealmTopicAction.MEMBERSHIP_ENSURE_REQUESTED; + payload: { + actor: string; + realm: string; + input: { + organization: string; + process: string; + account: string; + }; + }; + }; + + type MembershipEnsureConfirmedMessage = { + actionType: RealmTopicAction.MEMBERSHIP_ENSURE_CONFIRMED; + payload: { + actor: string; + realm: string; + input: { + organization: string; + process: string; + account: string; + }; + }; + }; + + type MembershipEnsureRejectedMessage = { + actionType: RealmTopicAction.MEMBERSHIP_ENSURE_REJECTED; + payload: { + actor: string; + realm: string; + input: { + organization: string; + process: string; + account: string; + reason: string; + }; + }; + }; + type MembershipJoinRequestedMessage = { actionType: RealmTopicAction.MEMBERSHIP_JOIN_REQUESTED; payload: { @@ -278,6 +321,7 @@ declare global { process: string; command: string; membership: string; + hrRequest?: string; account: string; invite?: string; role?: string; @@ -292,6 +336,7 @@ declare global { realm: string; input: { membership: string; + hrRequest?: string; assignment: string; joinedAt: number; process: string; @@ -310,6 +355,7 @@ declare global { realm: string; input: { membership: string; + hrRequest?: string; process: string; command: string; account: string;