@iveri/contracts 0.69.0 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/chat/chat-attachment-kind.enum.d.ts +6 -0
- package/dist/api/chat/chat-attachment-kind.enum.js +7 -0
- package/dist/api/chat/chat-attachment.type.d.ts +36 -0
- package/dist/api/chat/chat-attachment.type.js +1 -0
- package/dist/api/chat/chat-case-decision.enum.d.ts +8 -0
- package/dist/api/chat/chat-case-decision.enum.js +9 -0
- package/dist/api/chat/chat-case-status.enum.d.ts +5 -0
- package/dist/api/chat/chat-case-status.enum.js +6 -0
- package/dist/api/chat/chat-contact.type.d.ts +38 -0
- package/dist/api/chat/chat-contact.type.js +1 -0
- package/dist/api/chat/chat-conversation-kind.enum.d.ts +6 -0
- package/dist/api/chat/chat-conversation-kind.enum.js +7 -0
- package/dist/api/chat/chat-conversation.type.d.ts +120 -0
- package/dist/api/chat/chat-conversation.type.js +1 -0
- package/dist/api/chat/chat-device-platform.enum.d.ts +5 -0
- package/dist/api/chat/chat-device-platform.enum.js +6 -0
- package/dist/api/chat/chat-embed.type.d.ts +57 -0
- package/dist/api/chat/chat-embed.type.js +1 -0
- package/dist/api/chat/chat-limits.constant.d.ts +37 -0
- package/dist/api/chat/chat-limits.constant.js +37 -0
- package/dist/api/chat/chat-message-kind.enum.d.ts +8 -0
- package/dist/api/chat/chat-message-kind.enum.js +9 -0
- package/dist/api/chat/chat-message.type.d.ts +73 -0
- package/dist/api/chat/chat-message.type.js +1 -0
- package/dist/api/chat/chat-moderation.type.d.ts +107 -0
- package/dist/api/chat/chat-moderation.type.js +1 -0
- package/dist/api/chat/chat-participant-role.enum.d.ts +6 -0
- package/dist/api/chat/chat-participant-role.enum.js +7 -0
- package/dist/api/chat/chat-participant-status.enum.d.ts +7 -0
- package/dist/api/chat/chat-participant-status.enum.js +8 -0
- package/dist/api/chat/chat-person-status.enum.d.ts +6 -0
- package/dist/api/chat/chat-person-status.enum.js +7 -0
- package/dist/api/chat/chat-person.type.d.ts +52 -0
- package/dist/api/chat/chat-person.type.js +1 -0
- package/dist/api/chat/chat-realtime-event.enum.d.ts +6 -0
- package/dist/api/chat/chat-realtime-event.enum.js +7 -0
- package/dist/api/chat/chat-realtime.type.d.ts +20 -0
- package/dist/api/chat/chat-realtime.type.js +1 -0
- package/dist/api/chat/chat-refusal.enum.d.ts +19 -0
- package/dist/api/chat/chat-refusal.enum.js +20 -0
- package/dist/api/chat/chat-report-reason.enum.d.ts +12 -0
- package/dist/api/chat/chat-report-reason.enum.js +13 -0
- package/dist/api/chat/chat-report-target.enum.d.ts +5 -0
- package/dist/api/chat/chat-report-target.enum.js +6 -0
- package/dist/api/chat/index.d.ts +22 -0
- package/dist/api/chat/index.js +22 -0
- package/dist/api/hr/hr-announcement.type.d.ts +14 -0
- package/dist/api/hr/hr-announcement.type.js +1 -0
- package/dist/api/hr/hr-attendance.type.d.ts +111 -0
- package/dist/api/hr/hr-attendance.type.js +1 -0
- package/dist/api/hr/hr-document.type.d.ts +60 -0
- package/dist/api/hr/hr-document.type.js +1 -0
- package/dist/api/hr/hr-hiring.type.d.ts +99 -0
- package/dist/api/hr/hr-hiring.type.js +1 -0
- package/dist/api/hr/hr-onboarding.type.d.ts +53 -0
- package/dist/api/hr/hr-onboarding.type.js +1 -0
- package/dist/api/hr/hr-one-to-one-role.enum.d.ts +5 -0
- package/dist/api/hr/hr-one-to-one-role.enum.js +6 -0
- package/dist/api/hr/hr-organization.type.d.ts +10 -0
- package/dist/api/hr/hr-payroll.type.d.ts +66 -0
- package/dist/api/hr/hr-payroll.type.js +1 -0
- package/dist/api/hr/hr-performance.type.d.ts +148 -0
- package/dist/api/hr/hr-performance.type.js +1 -0
- package/dist/api/hr/hr-review-question-kind.enum.d.ts +5 -0
- package/dist/api/hr/hr-review-question-kind.enum.js +6 -0
- package/dist/api/hr/index.d.ts +9 -0
- package/dist/api/hr/index.js +9 -0
- package/dist/enum/user-permission.enum.d.ts +13 -1
- package/dist/enum/user-permission.enum.js +13 -0
- package/package.json +5 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What an upload became after it was checked. */
|
|
2
|
+
export var ChatAttachmentKind;
|
|
3
|
+
(function (ChatAttachmentKind) {
|
|
4
|
+
ChatAttachmentKind["PHOTO"] = "photo";
|
|
5
|
+
ChatAttachmentKind["FILE"] = "file";
|
|
6
|
+
ChatAttachmentKind["VOICE"] = "voice";
|
|
7
|
+
})(ChatAttachmentKind || (ChatAttachmentKind = {}));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
2
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
3
|
+
import type { ChatAttachmentKind } from './chat-attachment-kind.enum.js';
|
|
4
|
+
/** A photograph's two sizes. The addresses are signed for this reader and expire. */
|
|
5
|
+
export interface ChatImage {
|
|
6
|
+
url: string;
|
|
7
|
+
thumbnailUrl: string;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ChatAttachment {
|
|
12
|
+
id: UUID;
|
|
13
|
+
kind: ChatAttachmentKind;
|
|
14
|
+
/** Signed for this reader. A file is served as a download, never rendered inline. */
|
|
15
|
+
url: string;
|
|
16
|
+
/** A photograph's small size. */
|
|
17
|
+
thumbnailUrl: Nullable<string>;
|
|
18
|
+
fileName: string;
|
|
19
|
+
contentType: string;
|
|
20
|
+
sizeBytes: number;
|
|
21
|
+
width: Nullable<number>;
|
|
22
|
+
height: Nullable<number>;
|
|
23
|
+
/** A voice note's length. */
|
|
24
|
+
durationMs: Nullable<number>;
|
|
25
|
+
/** A voice note's shape, up to 64 levels between 0 and 100, computed by the recording client. */
|
|
26
|
+
waveform: Nullable<number[]>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* What `POST /attachments` takes besides the file. Voice-note fields are the client's measurements and
|
|
30
|
+
* are only used to draw the note; the server checks the length it can read from the file itself.
|
|
31
|
+
*/
|
|
32
|
+
export interface UploadChatAttachmentFields {
|
|
33
|
+
kind: ChatAttachmentKind;
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
waveform?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What a moderator decided. */
|
|
2
|
+
export var ChatCaseDecision;
|
|
3
|
+
(function (ChatCaseDecision) {
|
|
4
|
+
ChatCaseDecision["DISMISS"] = "dismiss";
|
|
5
|
+
ChatCaseDecision["REMOVE"] = "remove";
|
|
6
|
+
ChatCaseDecision["WARN"] = "warn";
|
|
7
|
+
ChatCaseDecision["SUSPEND"] = "suspend";
|
|
8
|
+
ChatCaseDecision["BAN"] = "ban";
|
|
9
|
+
})(ChatCaseDecision || (ChatCaseDecision = {}));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ChatConversationKind } from './chat-conversation-kind.enum.js';
|
|
5
|
+
import type { ChatPersonCard } from './chat-person.type.js';
|
|
6
|
+
export interface ChatContact {
|
|
7
|
+
person: ChatPersonCard;
|
|
8
|
+
addedAt: IsoDateTime;
|
|
9
|
+
}
|
|
10
|
+
export interface AddChatContactRequest {
|
|
11
|
+
userId: UUID;
|
|
12
|
+
}
|
|
13
|
+
export interface ChatBlock {
|
|
14
|
+
person: ChatPersonCard;
|
|
15
|
+
blockedAt: IsoDateTime;
|
|
16
|
+
}
|
|
17
|
+
/** What an invitation code leads to, shown before accepting it. */
|
|
18
|
+
export interface ChatInvitationPreview {
|
|
19
|
+
code: string;
|
|
20
|
+
kind: ChatConversationKind;
|
|
21
|
+
/** A person's invitation names them. */
|
|
22
|
+
person: Nullable<ChatPersonCard>;
|
|
23
|
+
/** A group's invitation names it. */
|
|
24
|
+
groupTitle: Nullable<string>;
|
|
25
|
+
memberCount: Nullable<number>;
|
|
26
|
+
}
|
|
27
|
+
export interface AcceptChatInvitationResponse {
|
|
28
|
+
conversationId: UUID;
|
|
29
|
+
}
|
|
30
|
+
export interface ChatMessageSearchHit {
|
|
31
|
+
conversationId: UUID;
|
|
32
|
+
conversationTitle: string;
|
|
33
|
+
messageId: UUID;
|
|
34
|
+
seq: number;
|
|
35
|
+
senderName: Nullable<string>;
|
|
36
|
+
excerpt: string;
|
|
37
|
+
sentAt: IsoDateTime;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What a conversation is. `context` is one a product opened about something of its own. */
|
|
2
|
+
export var ChatConversationKind;
|
|
3
|
+
(function (ChatConversationKind) {
|
|
4
|
+
ChatConversationKind["DIRECT"] = "direct";
|
|
5
|
+
ChatConversationKind["GROUP"] = "group";
|
|
6
|
+
ChatConversationKind["CONTEXT"] = "context";
|
|
7
|
+
})(ChatConversationKind || (ChatConversationKind = {}));
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ChatImage } from './chat-attachment.type.js';
|
|
5
|
+
import type { ChatConversationKind } from './chat-conversation-kind.enum.js';
|
|
6
|
+
import type { ChatMessageKind } from './chat-message-kind.enum.js';
|
|
7
|
+
import type { ChatParticipantRole } from './chat-participant-role.enum.js';
|
|
8
|
+
import type { ChatParticipantStatus } from './chat-participant-status.enum.js';
|
|
9
|
+
import type { ChatPersonCard } from './chat-person.type.js';
|
|
10
|
+
import type { ChatRefusal } from './chat-refusal.enum.js';
|
|
11
|
+
/** What an embedded conversation is about, in the product that opened it. */
|
|
12
|
+
export interface ChatContext {
|
|
13
|
+
/** The product's own name for itself: `taxi`, `social`, `commerce`. */
|
|
14
|
+
product: string;
|
|
15
|
+
/** What in that product: `ride`, `direct`, `order`. */
|
|
16
|
+
type: string;
|
|
17
|
+
/** The product's own id for it. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Where the product shows it, relative to the product's own site or app. */
|
|
20
|
+
link: Nullable<{
|
|
21
|
+
web: Nullable<string>;
|
|
22
|
+
app: Nullable<string>;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface ChatLastMessagePreview {
|
|
26
|
+
seq: number;
|
|
27
|
+
kind: ChatMessageKind;
|
|
28
|
+
/** Null when deleted, and for a system notice, whose key is given instead. */
|
|
29
|
+
excerpt: Nullable<string>;
|
|
30
|
+
systemKey: Nullable<string>;
|
|
31
|
+
senderName: Nullable<string>;
|
|
32
|
+
isOwn: boolean;
|
|
33
|
+
isDeleted: boolean;
|
|
34
|
+
sentAt: IsoDateTime;
|
|
35
|
+
}
|
|
36
|
+
/** One row of an inbox. */
|
|
37
|
+
export interface ChatConversationSummary {
|
|
38
|
+
id: UUID;
|
|
39
|
+
kind: ChatConversationKind;
|
|
40
|
+
/** A group's title, the other person's name in a one-to-one, the product's title in a context. */
|
|
41
|
+
title: string;
|
|
42
|
+
/** A line under the title, set by a product for a context conversation. */
|
|
43
|
+
subtitle: Nullable<string>;
|
|
44
|
+
avatar: Nullable<ChatImage>;
|
|
45
|
+
/** The other person in a one-to-one conversation. */
|
|
46
|
+
other: Nullable<ChatPersonCard>;
|
|
47
|
+
context: Nullable<ChatContext>;
|
|
48
|
+
memberCount: number;
|
|
49
|
+
lastMessage: Nullable<ChatLastMessagePreview>;
|
|
50
|
+
lastSeq: number;
|
|
51
|
+
unreadCount: number;
|
|
52
|
+
/** Waiting for me to accept it. */
|
|
53
|
+
isRequest: boolean;
|
|
54
|
+
mutedUntil: Nullable<IsoDateTime>;
|
|
55
|
+
isPinned: boolean;
|
|
56
|
+
isArchived: boolean;
|
|
57
|
+
/** Whether I can send here now. When false, `refusal` says why. */
|
|
58
|
+
canSend: boolean;
|
|
59
|
+
refusal: Nullable<ChatRefusal>;
|
|
60
|
+
updatedAt: IsoDateTime;
|
|
61
|
+
}
|
|
62
|
+
export interface ChatParticipant {
|
|
63
|
+
userId: UUID;
|
|
64
|
+
/** The name this conversation shows, which a product may set. */
|
|
65
|
+
displayName: string;
|
|
66
|
+
/** A product's label: "Driver", "Shop". */
|
|
67
|
+
label: Nullable<string>;
|
|
68
|
+
handle: Nullable<string>;
|
|
69
|
+
avatar: Nullable<ChatImage>;
|
|
70
|
+
role: ChatParticipantRole;
|
|
71
|
+
status: ChatParticipantStatus;
|
|
72
|
+
/** Up to where they have read. Null while a request is unanswered or when they hide read state. */
|
|
73
|
+
lastReadSeq: Nullable<number>;
|
|
74
|
+
lastActiveAt: Nullable<IsoDateTime>;
|
|
75
|
+
isMe: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface ChatConversation extends ChatConversationSummary {
|
|
78
|
+
participants: ChatParticipant[];
|
|
79
|
+
myRole: ChatParticipantRole;
|
|
80
|
+
myLastReadSeq: number;
|
|
81
|
+
writableUntil: Nullable<IsoDateTime>;
|
|
82
|
+
closedAt: Nullable<IsoDateTime>;
|
|
83
|
+
/** A group's invitation code, shown to its owner and admins. */
|
|
84
|
+
inviteCode: Nullable<string>;
|
|
85
|
+
}
|
|
86
|
+
export interface ChatInboxPage {
|
|
87
|
+
conversations: ChatConversationSummary[];
|
|
88
|
+
/** Pass back as `cursor` for the next page. */
|
|
89
|
+
nextCursor: Nullable<string>;
|
|
90
|
+
}
|
|
91
|
+
/** What `GET /conversations` can be narrowed to. */
|
|
92
|
+
export type ChatInboxFolder = 'inbox' | 'requests' | 'archived';
|
|
93
|
+
export interface StartDirectChatRequest {
|
|
94
|
+
userId: UUID;
|
|
95
|
+
}
|
|
96
|
+
export interface CreateGroupChatRequest {
|
|
97
|
+
title: string;
|
|
98
|
+
memberUserIds: UUID[];
|
|
99
|
+
}
|
|
100
|
+
export interface UpdateGroupChatRequest {
|
|
101
|
+
title?: string;
|
|
102
|
+
/** An uploaded photo attachment. `null` removes the photograph. */
|
|
103
|
+
avatarAttachmentId?: Nullable<UUID>;
|
|
104
|
+
}
|
|
105
|
+
export interface AddChatMembersRequest {
|
|
106
|
+
userIds: UUID[];
|
|
107
|
+
}
|
|
108
|
+
export interface UpdateChatMemberRequest {
|
|
109
|
+
role: ChatParticipantRole;
|
|
110
|
+
}
|
|
111
|
+
/** My own settings for one conversation. */
|
|
112
|
+
export interface UpdateMyChatSettingsRequest {
|
|
113
|
+
/** `null` unmutes. A date far in the future mutes until unmuted. */
|
|
114
|
+
mutedUntil?: Nullable<IsoDateTime>;
|
|
115
|
+
isPinned?: boolean;
|
|
116
|
+
isArchived?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface ChatTypingResponse {
|
|
119
|
+
accepted: boolean;
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
/**
|
|
5
|
+
* Somebody a product puts in a conversation. A user of the product's own tenant, named the way the
|
|
6
|
+
* product names them. There is deliberately no phone or email field: the other side never sees either.
|
|
7
|
+
*/
|
|
8
|
+
export interface EmbeddedChatParticipant {
|
|
9
|
+
userId: UUID;
|
|
10
|
+
displayName: string;
|
|
11
|
+
/** "Driver", "Passenger", "Shop". */
|
|
12
|
+
label?: Nullable<string>;
|
|
13
|
+
/** An address the product already serves publicly. */
|
|
14
|
+
avatarUrl?: Nullable<string>;
|
|
15
|
+
/** `request` puts it in their Requests until they accept, which is how Ezo's message requests work. */
|
|
16
|
+
asRequest?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `PUT /embed/conversations`, under `chat:embed:manage`. An upsert keyed on the context, so a retry,
|
|
20
|
+
* two replicas and a reassignment land on one conversation, and participants are reconciled.
|
|
21
|
+
*/
|
|
22
|
+
export interface OpenEmbeddedChatRequest {
|
|
23
|
+
context: {
|
|
24
|
+
product: string;
|
|
25
|
+
type: string;
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
title: string;
|
|
29
|
+
subtitle?: Nullable<string>;
|
|
30
|
+
participants: EmbeddedChatParticipant[];
|
|
31
|
+
/** Sending ends here and reading stays. Omitted means until closed. */
|
|
32
|
+
writableUntil?: Nullable<IsoDateTime>;
|
|
33
|
+
link?: Nullable<{
|
|
34
|
+
web?: Nullable<string>;
|
|
35
|
+
app?: Nullable<string>;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface OpenEmbeddedChatResponse {
|
|
39
|
+
conversationId: UUID;
|
|
40
|
+
created: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A notice from the product: a translation key in the `chat-kit` namespace and its variables. */
|
|
43
|
+
export interface PostEmbeddedSystemMessageRequest {
|
|
44
|
+
key: string;
|
|
45
|
+
variables?: Record<string, string>;
|
|
46
|
+
/** So a retried notice is posted once. */
|
|
47
|
+
idempotencyKey: UUID;
|
|
48
|
+
}
|
|
49
|
+
export interface EmbeddedChatReference {
|
|
50
|
+
conversationId: UUID;
|
|
51
|
+
context: {
|
|
52
|
+
product: string;
|
|
53
|
+
type: string;
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
closedAt: Nullable<IsoDateTime>;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The longest message text, in characters. */
|
|
2
|
+
export declare const CHAT_MESSAGE_MAX_LENGTH = 4000;
|
|
3
|
+
/** The most people a group can hold, its owner included. */
|
|
4
|
+
export declare const CHAT_GROUP_MAX_MEMBERS = 256;
|
|
5
|
+
/** The longest group title. */
|
|
6
|
+
export declare const CHAT_GROUP_TITLE_MAX_LENGTH = 80;
|
|
7
|
+
/** How long after sending a message its author may still change it. */
|
|
8
|
+
export declare const CHAT_EDIT_WINDOW_HOURS = 48;
|
|
9
|
+
/** How long after sending a message its author may still delete it for everyone. */
|
|
10
|
+
export declare const CHAT_DELETE_WINDOW_HOURS = 48;
|
|
11
|
+
/** How many conversations one person can pin. */
|
|
12
|
+
export declare const CHAT_PIN_LIMIT = 5;
|
|
13
|
+
/** How many attachments one message can carry. */
|
|
14
|
+
export declare const CHAT_ATTACHMENTS_PER_MESSAGE = 10;
|
|
15
|
+
/** The longest voice note, in seconds. */
|
|
16
|
+
export declare const CHAT_VOICE_MAX_SECONDS = 300;
|
|
17
|
+
/** The largest upload, in bytes. */
|
|
18
|
+
export declare const CHAT_ATTACHMENT_MAX_BYTES: number;
|
|
19
|
+
/** The reactions offered first. Any single emoji is accepted. */
|
|
20
|
+
export declare const CHAT_QUICK_REACTIONS: readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* A Baasi handle: Latin letters, digits, dots and underscores, 3 to 30 characters, lower case, never
|
|
23
|
+
* starting or ending with a dot. Latin only is what keeps a Cyrillic `а` from impersonating somebody.
|
|
24
|
+
*/
|
|
25
|
+
export declare const CHAT_HANDLE_PATTERN: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* The Socket.IO namespace of `chat-realtime`. `chat-api` emits into it through the Redis adapter, to
|
|
28
|
+
* the room `t:<tenantId>:p:<userId>` of each person a frame is for, so no credential is needed to act
|
|
29
|
+
* for the tenant a conversation belongs to.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CHAT_REALTIME_NAMESPACE = "/chat";
|
|
32
|
+
/** What `chat-realtime` says to a socket. */
|
|
33
|
+
export declare const CHAT_SOCKET_EVENT: {
|
|
34
|
+
readonly READY: "chat.ready";
|
|
35
|
+
readonly ERROR: "chat.error";
|
|
36
|
+
readonly FRAME: "chat.frame";
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The longest message text, in characters. */
|
|
2
|
+
export const CHAT_MESSAGE_MAX_LENGTH = 4000;
|
|
3
|
+
/** The most people a group can hold, its owner included. */
|
|
4
|
+
export const CHAT_GROUP_MAX_MEMBERS = 256;
|
|
5
|
+
/** The longest group title. */
|
|
6
|
+
export const CHAT_GROUP_TITLE_MAX_LENGTH = 80;
|
|
7
|
+
/** How long after sending a message its author may still change it. */
|
|
8
|
+
export const CHAT_EDIT_WINDOW_HOURS = 48;
|
|
9
|
+
/** How long after sending a message its author may still delete it for everyone. */
|
|
10
|
+
export const CHAT_DELETE_WINDOW_HOURS = 48;
|
|
11
|
+
/** How many conversations one person can pin. */
|
|
12
|
+
export const CHAT_PIN_LIMIT = 5;
|
|
13
|
+
/** How many attachments one message can carry. */
|
|
14
|
+
export const CHAT_ATTACHMENTS_PER_MESSAGE = 10;
|
|
15
|
+
/** The longest voice note, in seconds. */
|
|
16
|
+
export const CHAT_VOICE_MAX_SECONDS = 300;
|
|
17
|
+
/** The largest upload, in bytes. */
|
|
18
|
+
export const CHAT_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
19
|
+
/** The reactions offered first. Any single emoji is accepted. */
|
|
20
|
+
export const CHAT_QUICK_REACTIONS = ['👍', '❤️', '😂', '😮', '😢', '🙏'];
|
|
21
|
+
/**
|
|
22
|
+
* A Baasi handle: Latin letters, digits, dots and underscores, 3 to 30 characters, lower case, never
|
|
23
|
+
* starting or ending with a dot. Latin only is what keeps a Cyrillic `а` from impersonating somebody.
|
|
24
|
+
*/
|
|
25
|
+
export const CHAT_HANDLE_PATTERN = /^(?!\.)(?!.*\.$)[a-z0-9._]{3,30}$/;
|
|
26
|
+
/**
|
|
27
|
+
* The Socket.IO namespace of `chat-realtime`. `chat-api` emits into it through the Redis adapter, to
|
|
28
|
+
* the room `t:<tenantId>:p:<userId>` of each person a frame is for, so no credential is needed to act
|
|
29
|
+
* for the tenant a conversation belongs to.
|
|
30
|
+
*/
|
|
31
|
+
export const CHAT_REALTIME_NAMESPACE = '/chat';
|
|
32
|
+
/** What `chat-realtime` says to a socket. */
|
|
33
|
+
export const CHAT_SOCKET_EVENT = {
|
|
34
|
+
READY: 'chat.ready',
|
|
35
|
+
ERROR: 'chat.error',
|
|
36
|
+
FRAME: 'chat.frame',
|
|
37
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What a message carries. `system` is a notice written by a product or by Baasi itself, never by a person. */
|
|
2
|
+
export var ChatMessageKind;
|
|
3
|
+
(function (ChatMessageKind) {
|
|
4
|
+
ChatMessageKind["TEXT"] = "text";
|
|
5
|
+
ChatMessageKind["PHOTO"] = "photo";
|
|
6
|
+
ChatMessageKind["FILE"] = "file";
|
|
7
|
+
ChatMessageKind["VOICE"] = "voice";
|
|
8
|
+
ChatMessageKind["SYSTEM"] = "system";
|
|
9
|
+
})(ChatMessageKind || (ChatMessageKind = {}));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ChatAttachment, ChatImage } from './chat-attachment.type.js';
|
|
5
|
+
import type { ChatMessageKind } from './chat-message-kind.enum.js';
|
|
6
|
+
export interface ChatMessageSender {
|
|
7
|
+
userId: UUID;
|
|
8
|
+
/** The name this conversation shows: a product's label for an embedded one. */
|
|
9
|
+
displayName: string;
|
|
10
|
+
avatar: Nullable<ChatImage>;
|
|
11
|
+
}
|
|
12
|
+
/** The message a reply points at, enough to draw the quote above it. */
|
|
13
|
+
export interface ChatReplyPreview {
|
|
14
|
+
id: UUID;
|
|
15
|
+
seq: number;
|
|
16
|
+
senderName: Nullable<string>;
|
|
17
|
+
kind: ChatMessageKind;
|
|
18
|
+
excerpt: Nullable<string>;
|
|
19
|
+
isDeleted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ChatReactionSummary {
|
|
22
|
+
emoji: string;
|
|
23
|
+
count: number;
|
|
24
|
+
isMine: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ChatMessage {
|
|
27
|
+
id: UUID;
|
|
28
|
+
conversationId: UUID;
|
|
29
|
+
/** Consecutive within a conversation, so "everything after 41" misses nothing. */
|
|
30
|
+
seq: number;
|
|
31
|
+
/** The client's own id for this message, so a retry is recognised. */
|
|
32
|
+
clientMessageId: Nullable<UUID>;
|
|
33
|
+
/** Null for a system notice. */
|
|
34
|
+
sender: Nullable<ChatMessageSender>;
|
|
35
|
+
kind: ChatMessageKind;
|
|
36
|
+
/** Null once deleted for everyone, and for a system notice. */
|
|
37
|
+
body: Nullable<string>;
|
|
38
|
+
/** A system notice is a translation key with variables, never free text. */
|
|
39
|
+
systemKey: Nullable<string>;
|
|
40
|
+
systemVariables: Nullable<Record<string, string>>;
|
|
41
|
+
replyTo: Nullable<ChatReplyPreview>;
|
|
42
|
+
attachments: ChatAttachment[];
|
|
43
|
+
reactions: ChatReactionSummary[];
|
|
44
|
+
isOwn: boolean;
|
|
45
|
+
editedAt: Nullable<IsoDateTime>;
|
|
46
|
+
isDeleted: boolean;
|
|
47
|
+
sentAt: IsoDateTime;
|
|
48
|
+
}
|
|
49
|
+
/** A page of messages, oldest first. */
|
|
50
|
+
export interface ChatMessagePage {
|
|
51
|
+
messages: ChatMessage[];
|
|
52
|
+
/** Whether there is anything older than the first message on this page. */
|
|
53
|
+
hasOlder: boolean;
|
|
54
|
+
/** The conversation's newest sequence number when the page was read. */
|
|
55
|
+
lastSeq: number;
|
|
56
|
+
}
|
|
57
|
+
export interface SendChatMessageRequest {
|
|
58
|
+
/** Chosen by the client per message. A second send with the same id returns the first message. */
|
|
59
|
+
clientMessageId: UUID;
|
|
60
|
+
body?: Nullable<string>;
|
|
61
|
+
replyToMessageId?: Nullable<UUID>;
|
|
62
|
+
attachmentIds?: UUID[];
|
|
63
|
+
}
|
|
64
|
+
export interface EditChatMessageRequest {
|
|
65
|
+
body: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ReactToChatMessageRequest {
|
|
68
|
+
emoji: string;
|
|
69
|
+
}
|
|
70
|
+
export interface MarkChatReadRequest {
|
|
71
|
+
/** Everything up to and including this sequence number has been read. */
|
|
72
|
+
seq: number;
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ChatCaseDecision } from './chat-case-decision.enum.js';
|
|
5
|
+
import type { ChatCaseStatus } from './chat-case-status.enum.js';
|
|
6
|
+
import type { ChatMessageKind } from './chat-message-kind.enum.js';
|
|
7
|
+
import type { ChatPersonStatus } from './chat-person-status.enum.js';
|
|
8
|
+
import type { ChatReportReason } from './chat-report-reason.enum.js';
|
|
9
|
+
import type { ChatReportTarget } from './chat-report-target.enum.js';
|
|
10
|
+
export interface CreateChatReportRequest {
|
|
11
|
+
target: ChatReportTarget;
|
|
12
|
+
/** The message, for a message report. */
|
|
13
|
+
messageId?: UUID;
|
|
14
|
+
/** The person, for a person report. */
|
|
15
|
+
userId?: UUID;
|
|
16
|
+
reason: ChatReportReason;
|
|
17
|
+
note?: Nullable<string>;
|
|
18
|
+
}
|
|
19
|
+
/** A message as it was when reported. The author may have changed or deleted it since. */
|
|
20
|
+
export interface ChatCaseMessage {
|
|
21
|
+
messageId: UUID;
|
|
22
|
+
seq: number;
|
|
23
|
+
senderUserId: Nullable<UUID>;
|
|
24
|
+
senderName: Nullable<string>;
|
|
25
|
+
kind: ChatMessageKind;
|
|
26
|
+
body: Nullable<string>;
|
|
27
|
+
attachmentCount: number;
|
|
28
|
+
sentAt: IsoDateTime;
|
|
29
|
+
/** The reported one, as against the five before it. */
|
|
30
|
+
isReported: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface ChatCaseAction {
|
|
33
|
+
decision: ChatCaseDecision;
|
|
34
|
+
note: string;
|
|
35
|
+
decidedByUserId: UUID;
|
|
36
|
+
decidedAt: IsoDateTime;
|
|
37
|
+
suspendedUntil: Nullable<IsoDateTime>;
|
|
38
|
+
}
|
|
39
|
+
export interface ChatCaseSummary {
|
|
40
|
+
id: UUID;
|
|
41
|
+
status: ChatCaseStatus;
|
|
42
|
+
target: ChatReportTarget;
|
|
43
|
+
/** The most reported reason. */
|
|
44
|
+
reason: ChatReportReason;
|
|
45
|
+
reportCount: number;
|
|
46
|
+
reportedUserId: UUID;
|
|
47
|
+
reportedName: string;
|
|
48
|
+
/** Set for an embedded conversation, so staff know which product it came from. */
|
|
49
|
+
product: Nullable<string>;
|
|
50
|
+
/** Child safety goes to the top. */
|
|
51
|
+
priority: number;
|
|
52
|
+
claimedByUserId: Nullable<UUID>;
|
|
53
|
+
claimedUntil: Nullable<IsoDateTime>;
|
|
54
|
+
openedAt: IsoDateTime;
|
|
55
|
+
}
|
|
56
|
+
export interface ChatCase extends ChatCaseSummary {
|
|
57
|
+
reasons: {
|
|
58
|
+
reason: ChatReportReason;
|
|
59
|
+
count: number;
|
|
60
|
+
}[];
|
|
61
|
+
notes: string[];
|
|
62
|
+
/** Empty for a person report. Reading this is written to the access log. */
|
|
63
|
+
messages: ChatCaseMessage[];
|
|
64
|
+
actions: ChatCaseAction[];
|
|
65
|
+
reportedPersonStatus: ChatPersonStatus;
|
|
66
|
+
reportedPersonPriorActions: number;
|
|
67
|
+
}
|
|
68
|
+
export interface DecideChatCaseRequest {
|
|
69
|
+
decision: ChatCaseDecision;
|
|
70
|
+
/** Shown to the person in their language when they read why. */
|
|
71
|
+
note: string;
|
|
72
|
+
/** Required for a suspension. */
|
|
73
|
+
suspendedUntil?: Nullable<IsoDateTime>;
|
|
74
|
+
}
|
|
75
|
+
export interface ChatStaffPerson {
|
|
76
|
+
userId: UUID;
|
|
77
|
+
tenantId: UUID;
|
|
78
|
+
handle: Nullable<string>;
|
|
79
|
+
displayName: Nullable<string>;
|
|
80
|
+
status: ChatPersonStatus;
|
|
81
|
+
suspendedUntil: Nullable<IsoDateTime>;
|
|
82
|
+
conversationCount: number;
|
|
83
|
+
reportCount: number;
|
|
84
|
+
actionCount: number;
|
|
85
|
+
createdAt: IsoDateTime;
|
|
86
|
+
lastActiveAt: Nullable<IsoDateTime>;
|
|
87
|
+
}
|
|
88
|
+
export interface ChatStaffAccessEntry {
|
|
89
|
+
id: UUID;
|
|
90
|
+
staffUserId: UUID;
|
|
91
|
+
caseId: Nullable<UUID>;
|
|
92
|
+
action: string;
|
|
93
|
+
occurredAt: IsoDateTime;
|
|
94
|
+
}
|
|
95
|
+
export interface ChatStaffOverview {
|
|
96
|
+
people: number;
|
|
97
|
+
newPeopleThisWeek: number;
|
|
98
|
+
conversations: number;
|
|
99
|
+
messagesToday: number;
|
|
100
|
+
openCases: number;
|
|
101
|
+
childSafetyCases: number;
|
|
102
|
+
embeddedConversations: {
|
|
103
|
+
product: string;
|
|
104
|
+
open: number;
|
|
105
|
+
closed: number;
|
|
106
|
+
}[];
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What a participant may do to a group. A direct or context conversation has only members. */
|
|
2
|
+
export var ChatParticipantRole;
|
|
3
|
+
(function (ChatParticipantRole) {
|
|
4
|
+
ChatParticipantRole["OWNER"] = "owner";
|
|
5
|
+
ChatParticipantRole["ADMIN"] = "admin";
|
|
6
|
+
ChatParticipantRole["MEMBER"] = "member";
|
|
7
|
+
})(ChatParticipantRole || (ChatParticipantRole = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Where somebody stands in a conversation. `request` waits for them to accept it, and the sender cannot see whether it was read until they do. */
|
|
2
|
+
export declare enum ChatParticipantStatus {
|
|
3
|
+
ACTIVE = "active",
|
|
4
|
+
REQUEST = "request",
|
|
5
|
+
LEFT = "left",
|
|
6
|
+
REMOVED = "removed"
|
|
7
|
+
}
|