Skip to content

Commit 9b27640

Browse files
committed
unifying M2M types
1 parent 226ca00 commit 9b27640

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

server/chat-bot/chat-bot.machine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createMachine, interpret } from "xstate";
22
import * as actions from "./chat-bot-actions";
33
import { VerificationRequestStateMachineService } from "../verification-request/state-machine/verification-request.state-machine.service";
4-
import { M2M } from "../entities/m2m.entity";
54

65
export interface ChatBotContext {
76
verificationRequest: string;
@@ -15,7 +14,7 @@ export const createChatBotMachine = (
1514
verificationRequestStateMachineService: VerificationRequestStateMachineService,
1615
value?,
1716
context?,
18-
M2MUser?: M2M,
17+
M2MUser?,
1918
) => {
2019
const chatBotMachine = createMachine<ChatBotContext>(
2120
{

server/chat-bot/chat-bot.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ConfigService } from "@nestjs/config";
88
import { ChatBotStateService } from "../chat-bot-state/chat-bot-state.service";
99
import { VerificationRequestStateMachineService } from "../verification-request/state-machine/verification-request.state-machine.service";
1010
import { Roles } from "../auth/ability/ability.factory";
11+
import { M2M } from "../entities/m2m.entity";
1112

1213
const diacriticsRegex = /[\u0300-\u036f]/g;
1314
const MESSAGE_MAP = {
@@ -23,7 +24,7 @@ interface ChatBotContext {
2324
sourceChannel?: string;
2425
}
2526

26-
function M2MUser(clientId) {
27+
function M2MUser(clientId): M2M {
2728
return {
2829
isM2M: true,
2930
clientId,

server/entities/m2m.entity.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import { Roles } from "../auth/ability/ability.factory";
12
export class M2M {
2-
isM2M: boolean;
3-
role: {
4-
main: string;
5-
};
6-
scopes: string[];
3+
isM2M: boolean;
4+
clientId: string;
5+
subject: string;
6+
scopes: string[];
7+
role: {
8+
main: Roles.Integration;
9+
};
10+
namespace: string;
711
}

server/history/types/history.interfaces.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Roles } from "../../auth/ability/ability.factory";
1+
import { M2M } from "../../entities/m2m.entity";
22
import { HistoryType, TargetModel } from "../schema/history.schema";
33
import { Types } from "mongoose";
44

@@ -33,16 +33,6 @@ interface HistoryItem {
3333
}
3434

3535
type PerformedBy = Types.ObjectId[] | M2M | string | null;
36-
interface M2M {
37-
isM2M: boolean;
38-
clientId: string;
39-
subject: string;
40-
scopes: string[];
41-
role: {
42-
main: Roles.Integration;
43-
};
44-
namespace: string;
45-
}
4636
interface HistoryDetails {
4737
after: AfterAndBeforeType;
4838
before?: AfterAndBeforeType | null;

src/types/User.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export type User = {
1212
};
1313

1414
export class M2M {
15-
isM2M: boolean;
16-
subject: string;
17-
role: {
18-
main: string;
19-
};
20-
scopes: string[];
15+
isM2M: boolean;
16+
clientId: string;
17+
subject: string;
18+
scopes: string[];
19+
role: {
20+
main: Roles.Integration;
21+
};
22+
namespace: string;
2123
}

src/types/enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum Roles {
1616
Reviewer = "reviewer",
1717
Admin = "admin",
1818
SuperAdmin = "super-admin",
19+
Integration = "integration",
1920
}
2021

2122
enum Status {

0 commit comments

Comments
 (0)