contactstudiocstools 1.0.281 → 1.0.282

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@contactstudio/cstools",
3
3
  "configKey": "CSTools",
4
- "version": "1.0.281"
4
+ "version": "1.0.282"
5
5
  }
@@ -8,6 +8,7 @@ export declare function ChatMessageOptionDTO(primitive: any): IChatMessage;
8
8
  export declare function ChatMessageFileDTO(primitive: any): IChatMessage;
9
9
  export declare function ChatMessageContactDTO(primitive: any): IChatMessage;
10
10
  export declare function ChatMessageStickerDTO(primitive: any): IChatMessage;
11
+ export declare function ChatMessageTemplateDTO(primitive: any): IChatMessage;
11
12
  export declare function NodesManifestationDTO(primitives: any[]): INodes;
12
13
  export declare function NodesTabulationDTO(primitives: any[]): INodes;
13
14
  export declare function ChatContactsDTO({ primitives, identifier, message, date, }: any): IChatContacts;
@@ -57,7 +57,7 @@ function FieldSelectOptionsDTO(primitives) {
57
57
  return options;
58
58
  }
59
59
  export function ChatMessageDTO(primitive) {
60
- const { when, content, user_defined_fields } = primitive;
60
+ const { message_id, when, content, user_defined_fields, referenced_message } = primitive;
61
61
  const isRobot = content.who.type === "robot";
62
62
  return {
63
63
  type: EChatMessageTypes.text,
@@ -65,7 +65,15 @@ export function ChatMessageDTO(primitive) {
65
65
  date: new Date(when),
66
66
  primary: isRobot || !!user_defined_fields.agent,
67
67
  primitive,
68
- text: ""
68
+ text: "",
69
+ messageId: message_id,
70
+ referencedMessage: !referenced_message ? void 0 : {
71
+ isForwarded: referenced_message.is_forwarded,
72
+ isGone: referenced_message.is_gone,
73
+ roomId: referenced_message.room_id,
74
+ channelId: referenced_message.channel_id,
75
+ messageId: referenced_message.message_id
76
+ }
69
77
  };
70
78
  }
71
79
  export function ChatMessageTextDTO(primitive) {
@@ -100,6 +108,16 @@ export function ChatMessageStickerDTO(primitive) {
100
108
  message.url = primitive?.content?.message?.url;
101
109
  return message;
102
110
  }
111
+ export function ChatMessageTemplateDTO(primitive) {
112
+ const message = ChatMessageDTO(primitive);
113
+ message.type = EChatMessageTypes.template;
114
+ message.text = "";
115
+ message.status = "SENT";
116
+ message.template = {
117
+ contextNotes: primitive?.content?.message?.context_notes
118
+ };
119
+ return message;
120
+ }
103
121
  export function NodesManifestationDTO(primitives) {
104
122
  const nodes = [];
105
123
  if (!primitives)
@@ -159,8 +177,7 @@ export function ChatContactsDTO({
159
177
  date,
160
178
  message,
161
179
  nameCS: "",
162
- nameWhatsapp: "",
163
- tags: []
180
+ nameWhatsapp: ""
164
181
  });
165
182
  }
166
183
  return contacts;
@@ -27,6 +27,8 @@ export declare function chatInteractionIsEvent(primitive: any): boolean;
27
27
  export declare function eventTypeIsTyping(primitive: any): boolean;
28
28
  export declare function typingIsOn(primitive: any): boolean;
29
29
  export declare function chatInteractionIsCommand(primitive: any): boolean;
30
+ export declare function chatInteractionIsMessage(primitive: any): boolean;
31
+ export declare function chatInteractionIsError(primitive: any): boolean;
30
32
  export declare function treatChatMessage(primitive: any): IChatMessage;
31
33
  export declare function treatChatCallingEvent(primitive: any): IChatMessage;
32
34
  export declare function chatMessageIsText(primitive: any): boolean;
@@ -35,6 +37,7 @@ export declare function chatMessageIsOption(primitive: any): boolean;
35
37
  export declare function chatMessageIsFile(primitive: any): boolean;
36
38
  export declare function chatMessageIsContact(primitive: any): boolean;
37
39
  export declare function chatMessageIsSticker(primitive: any): boolean;
40
+ export declare function chatMessageIsTemplate(primitive: any): boolean;
38
41
  export declare function getContactByRoomID({ contacts, roomID }: any): IChatContact;
39
42
  export declare function newChatHistoryEvent({ company, roomID, nickname, name, }: any): any;
40
43
  export declare function newChatTextMessage({ company, roomID, nickname, name, text, }: any): any;
@@ -7,6 +7,7 @@ import {
7
7
  ChatMessageFileDTO,
8
8
  ChatMessageContactDTO,
9
9
  ChatMessageStickerDTO,
10
+ ChatMessageTemplateDTO,
10
11
  logger
11
12
  } from "./index.mjs";
12
13
  export class Persist {
@@ -194,6 +195,12 @@ export function typingIsOn(primitive) {
194
195
  export function chatInteractionIsCommand(primitive) {
195
196
  return primitive.interaction_type === "command";
196
197
  }
198
+ export function chatInteractionIsMessage(primitive) {
199
+ return primitive.interaction_type === "message";
200
+ }
201
+ export function chatInteractionIsError(primitive) {
202
+ return primitive.interaction_type === "error";
203
+ }
197
204
  export function treatChatMessage(primitive) {
198
205
  if (chatMessageIsText(primitive)) {
199
206
  return ChatMessageTextDTO(primitive);
@@ -213,6 +220,9 @@ export function treatChatMessage(primitive) {
213
220
  if (chatMessageIsSticker(primitive)) {
214
221
  return ChatMessageStickerDTO(primitive);
215
222
  }
223
+ if (chatMessageIsTemplate(primitive)) {
224
+ return ChatMessageTemplateDTO(primitive);
225
+ }
216
226
  return ChatMessageTextDTO(primitive);
217
227
  }
218
228
  export function treatChatCallingEvent(primitive) {
@@ -236,6 +246,9 @@ export function chatMessageIsContact(primitive) {
236
246
  export function chatMessageIsSticker(primitive) {
237
247
  return primitive.content.message_type === "sticker";
238
248
  }
249
+ export function chatMessageIsTemplate(primitive) {
250
+ return primitive.content.message_type === "template";
251
+ }
239
252
  export function getContactByRoomID({ contacts, roomID }) {
240
253
  return contacts.find(({ primitive }) => primitive.room_id === roomID);
241
254
  }
@@ -0,0 +1,141 @@
1
+ export declare enum EchatMarkerTypes {
2
+ history_begin = "history_begin",
3
+ history_end = "history_end"
4
+ }
5
+ export declare enum EChatMessageInteractionTypes {
6
+ readonly = "readonly",
7
+ text = "text",
8
+ input = "input",
9
+ options = "options",
10
+ file = "file",
11
+ location = "location",
12
+ template = "template",
13
+ contact = "contact",
14
+ sticker = "sticker",
15
+ reaction = "reaction"
16
+ }
17
+ export declare enum EChatInteractionTypes {
18
+ message = "message",
19
+ event = "event",
20
+ command = "command",
21
+ calling_action = "calling_action",
22
+ error = "error",
23
+ marker = "marker"
24
+ }
25
+ export declare enum EChatActionTypes {
26
+ connect = "connect",
27
+ accept = "accept",
28
+ pre_accept = "pre_accept",
29
+ reject = "reject",
30
+ terminate = "terminate"
31
+ }
32
+ export declare enum EChatEventTypes {
33
+ csw_opened = "csw_opened",
34
+ csw_waiting = "csw_waiting",
35
+ csw_renewed = "csw_renewed",
36
+ csw_warning = "csw_warning",
37
+ csw_closed = "csw_closed",
38
+ message_delivered = "message_delivered",
39
+ message_seen = "message_seen",
40
+ call_connected = "call_connected",
41
+ call_terminated = "call_terminated",
42
+ call_ringing = "call_ringing",
43
+ call_accepted = "call_accepted",
44
+ call_rejected = "call_rejected",
45
+ permission_granted = "permission_granted",
46
+ permission_denied = "permission_denied",
47
+ permission_waiting = "permission_waiting"
48
+ }
49
+ export declare enum EChatErrorTypes {
50
+ the_room_is_gone = "the_room_is_gone",
51
+ template_error = "template_error",
52
+ unknown = "unknown"
53
+ }
54
+ export declare enum EChatCommandTypes {
55
+ open_room = "open_room",
56
+ request_history = "request_history",
57
+ leave_the_room = "leave_the_room",
58
+ request_permissions = "request_permissions",
59
+ request_calling_permission = "request_calling_permission",
60
+ request_messaging_permission = "request_messaging_permission",
61
+ request_support_calling_permission = "request_support_calling_permission",
62
+ wakeup_visitor = "wakeup_visitor"
63
+ }
64
+ export declare enum EChatWhoType {
65
+ system = "system",
66
+ human = "human",
67
+ robot = "robot"
68
+ }
69
+ export interface IChatWho {
70
+ label: string;
71
+ type: EChatWhoType;
72
+ contact_point?: string;
73
+ }
74
+ interface IChatInteractionPrimitiveBase {
75
+ interaction_type: EChatInteractionTypes;
76
+ company: string;
77
+ room_id?: string;
78
+ channel_id?: string;
79
+ thread_id?: string;
80
+ chat_trunk_id?: string;
81
+ message_id: string;
82
+ criticality_level: string;
83
+ when: string;
84
+ content: any;
85
+ referenced_message?: {
86
+ is_forwarded?: boolean;
87
+ is_gone?: boolean;
88
+ room_id?: string;
89
+ channel_id?: string;
90
+ message_id?: string;
91
+ };
92
+ user_defined_fields?: any;
93
+ original_message?: {
94
+ participant_type?: string;
95
+ message_id?: string;
96
+ };
97
+ }
98
+ export interface IChatInteractionMessagePrimitive extends IChatInteractionPrimitiveBase {
99
+ content: {
100
+ message_type: EChatMessageInteractionTypes;
101
+ who: IChatWho;
102
+ message: any;
103
+ is_forwarded: boolean;
104
+ is_frequently_forwarded: boolean;
105
+ };
106
+ }
107
+ export interface IChatInteractionEventPrimitive extends IChatInteractionPrimitiveBase {
108
+ content: {
109
+ event_type: EChatEventTypes;
110
+ who: IChatWho;
111
+ event: any;
112
+ };
113
+ }
114
+ export interface IChatInteractionCommandPrimitive extends IChatInteractionPrimitiveBase {
115
+ content: {
116
+ command_type: EChatCommandTypes;
117
+ who: IChatWho;
118
+ };
119
+ }
120
+ export interface IChatInteractionCallingActionPrimitive extends IChatInteractionPrimitiveBase {
121
+ content: {
122
+ action_type: EChatActionTypes;
123
+ who: IChatWho;
124
+ sdp?: string;
125
+ call_id?: string;
126
+ contact_point?: string;
127
+ };
128
+ }
129
+ export interface IChatInteractionErrorPrimitive extends IChatInteractionPrimitiveBase {
130
+ content: {
131
+ error_type: EChatErrorTypes;
132
+ message?: string;
133
+ };
134
+ }
135
+ export interface IChatInteractionMarkerPrimitive extends IChatInteractionPrimitiveBase {
136
+ content: {
137
+ marker_type: EchatMarkerTypes;
138
+ };
139
+ }
140
+ export type IChatInteractionPrimitive = IChatInteractionMessagePrimitive | IChatInteractionEventPrimitive | IChatInteractionCommandPrimitive | IChatInteractionCallingActionPrimitive | IChatInteractionErrorPrimitive | IChatInteractionMarkerPrimitive;
141
+ export {};
@@ -0,0 +1,76 @@
1
+ export var EchatMarkerTypes = /* @__PURE__ */ ((EchatMarkerTypes2) => {
2
+ EchatMarkerTypes2["history_begin"] = "history_begin";
3
+ EchatMarkerTypes2["history_end"] = "history_end";
4
+ return EchatMarkerTypes2;
5
+ })(EchatMarkerTypes || {});
6
+ export var EChatMessageInteractionTypes = /* @__PURE__ */ ((EChatMessageInteractionTypes2) => {
7
+ EChatMessageInteractionTypes2["readonly"] = "readonly";
8
+ EChatMessageInteractionTypes2["text"] = "text";
9
+ EChatMessageInteractionTypes2["input"] = "input";
10
+ EChatMessageInteractionTypes2["options"] = "options";
11
+ EChatMessageInteractionTypes2["file"] = "file";
12
+ EChatMessageInteractionTypes2["location"] = "location";
13
+ EChatMessageInteractionTypes2["template"] = "template";
14
+ EChatMessageInteractionTypes2["contact"] = "contact";
15
+ EChatMessageInteractionTypes2["sticker"] = "sticker";
16
+ EChatMessageInteractionTypes2["reaction"] = "reaction";
17
+ return EChatMessageInteractionTypes2;
18
+ })(EChatMessageInteractionTypes || {});
19
+ export var EChatInteractionTypes = /* @__PURE__ */ ((EChatInteractionTypes2) => {
20
+ EChatInteractionTypes2["message"] = "message";
21
+ EChatInteractionTypes2["event"] = "event";
22
+ EChatInteractionTypes2["command"] = "command";
23
+ EChatInteractionTypes2["calling_action"] = "calling_action";
24
+ EChatInteractionTypes2["error"] = "error";
25
+ EChatInteractionTypes2["marker"] = "marker";
26
+ return EChatInteractionTypes2;
27
+ })(EChatInteractionTypes || {});
28
+ export var EChatActionTypes = /* @__PURE__ */ ((EChatActionTypes2) => {
29
+ EChatActionTypes2["connect"] = "connect";
30
+ EChatActionTypes2["accept"] = "accept";
31
+ EChatActionTypes2["pre_accept"] = "pre_accept";
32
+ EChatActionTypes2["reject"] = "reject";
33
+ EChatActionTypes2["terminate"] = "terminate";
34
+ return EChatActionTypes2;
35
+ })(EChatActionTypes || {});
36
+ export var EChatEventTypes = /* @__PURE__ */ ((EChatEventTypes2) => {
37
+ EChatEventTypes2["csw_opened"] = "csw_opened";
38
+ EChatEventTypes2["csw_waiting"] = "csw_waiting";
39
+ EChatEventTypes2["csw_renewed"] = "csw_renewed";
40
+ EChatEventTypes2["csw_warning"] = "csw_warning";
41
+ EChatEventTypes2["csw_closed"] = "csw_closed";
42
+ EChatEventTypes2["message_delivered"] = "message_delivered";
43
+ EChatEventTypes2["message_seen"] = "message_seen";
44
+ EChatEventTypes2["call_connected"] = "call_connected";
45
+ EChatEventTypes2["call_terminated"] = "call_terminated";
46
+ EChatEventTypes2["call_ringing"] = "call_ringing";
47
+ EChatEventTypes2["call_accepted"] = "call_accepted";
48
+ EChatEventTypes2["call_rejected"] = "call_rejected";
49
+ EChatEventTypes2["permission_granted"] = "permission_granted";
50
+ EChatEventTypes2["permission_denied"] = "permission_denied";
51
+ EChatEventTypes2["permission_waiting"] = "permission_waiting";
52
+ return EChatEventTypes2;
53
+ })(EChatEventTypes || {});
54
+ export var EChatErrorTypes = /* @__PURE__ */ ((EChatErrorTypes2) => {
55
+ EChatErrorTypes2["the_room_is_gone"] = "the_room_is_gone";
56
+ EChatErrorTypes2["template_error"] = "template_error";
57
+ EChatErrorTypes2["unknown"] = "unknown";
58
+ return EChatErrorTypes2;
59
+ })(EChatErrorTypes || {});
60
+ export var EChatCommandTypes = /* @__PURE__ */ ((EChatCommandTypes2) => {
61
+ EChatCommandTypes2["open_room"] = "open_room";
62
+ EChatCommandTypes2["request_history"] = "request_history";
63
+ EChatCommandTypes2["leave_the_room"] = "leave_the_room";
64
+ EChatCommandTypes2["request_permissions"] = "request_permissions";
65
+ EChatCommandTypes2["request_calling_permission"] = "request_calling_permission";
66
+ EChatCommandTypes2["request_messaging_permission"] = "request_messaging_permission";
67
+ EChatCommandTypes2["request_support_calling_permission"] = "request_support_calling_permission";
68
+ EChatCommandTypes2["wakeup_visitor"] = "wakeup_visitor";
69
+ return EChatCommandTypes2;
70
+ })(EChatCommandTypes || {});
71
+ export var EChatWhoType = /* @__PURE__ */ ((EChatWhoType2) => {
72
+ EChatWhoType2["system"] = "system";
73
+ EChatWhoType2["human"] = "human";
74
+ EChatWhoType2["robot"] = "robot";
75
+ return EChatWhoType2;
76
+ })(EChatWhoType || {});
@@ -1,3 +1,4 @@
1
+ export type { EchatMarkerTypes, EChatMessageInteractionTypes, EChatInteractionTypes, EChatActionTypes, EChatEventTypes, EChatErrorTypes, EChatCommandTypes, EChatWhoType, IChatWho, IChatInteractionMessagePrimitive, IChatInteractionEventPrimitive, IChatInteractionCommandPrimitive, IChatInteractionCallingActionPrimitive, IChatInteractionErrorPrimitive, IChatInteractionMarkerPrimitive, IChatInteractionPrimitive, } from "./im-channel-types";
1
2
  export interface ISelectTree {
2
3
  labels: string[];
3
4
  nodes: INodes;
@@ -140,7 +141,8 @@ export declare enum EChatMessageTypes {
140
141
  call_terminated = "call_terminated",
141
142
  permission_denied = "permission_denied",
142
143
  permission_granted = "permission_granted",
143
- permission_waiting = "permission_waiting"
144
+ permission_waiting = "permission_waiting",
145
+ template = "template"
144
146
  }
145
147
  export interface IChatMessage {
146
148
  date: Date;
@@ -153,6 +155,18 @@ export interface IChatMessage {
153
155
  seen?: Date;
154
156
  primitive?: any;
155
157
  url?: string;
158
+ messageId?: string;
159
+ referencedMessage?: {
160
+ isForwarded?: boolean;
161
+ isGone?: boolean;
162
+ roomId?: string;
163
+ channelId?: string;
164
+ messageId?: string;
165
+ };
166
+ status?: 'PROCESSING' | 'SENT' | 'ERROR';
167
+ template?: {
168
+ contextNotes?: string;
169
+ };
156
170
  }
157
171
  export interface IMessageSeen {
158
172
  messageId: string;
@@ -37,6 +37,7 @@ export var EChatMessageTypes = /* @__PURE__ */ ((EChatMessageTypes2) => {
37
37
  EChatMessageTypes2["permission_denied"] = "permission_denied";
38
38
  EChatMessageTypes2["permission_granted"] = "permission_granted";
39
39
  EChatMessageTypes2["permission_waiting"] = "permission_waiting";
40
+ EChatMessageTypes2["template"] = "template";
40
41
  return EChatMessageTypes2;
41
42
  })(EChatMessageTypes || {});
42
43
  export var EPhoneStatus = /* @__PURE__ */ ((EPhoneStatus2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contactstudiocstools",
3
- "version": "1.0.281",
3
+ "version": "1.0.282",
4
4
  "description": "Nuxt Tools Module for ContactStudio",
5
5
  "type": "module",
6
6
  "exports": {
@@ -43,7 +43,7 @@
43
43
  "dev": "nuxi dev playground --port 4000",
44
44
  "dev:build": "nuxi build playground",
45
45
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
46
- "release": "npm run lint && npm run test && npm run prepack && changelogen --release --no-tag && npm publish && git push --follow-tags",
46
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --release --no-tag && npm publish --tag v1 && git push --follow-tags",
47
47
  "lint": "eslint .",
48
48
  "test": "vitest run",
49
49
  "test:watch": "vitest watch",