@twilio/conversations 3.0.0-canary.100 → 3.0.0-canary.2
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/builds/browser.js +599 -436
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +6 -2
- package/builds/lib.js +599 -436
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +3599 -2598
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/client.js +6 -7
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +16 -9
- package/dist/command-executor.js.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +1 -4
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/users.js +1 -3
- package/dist/data/users.js.map +1 -1
- package/dist/message.js +0 -1
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +33 -33
- package/dist/participant.js.map +1 -1
- package/dist/rest-paginator.js +11 -11
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +95 -26
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +12 -6
- package/dist/services/typing-indicator.js.map +1 -1
- package/package.json +10 -10
@@ -132,6 +132,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
132
132
|
|
133
133
|
var logger = require('../logger.js');
|
134
134
|
var notificationTypes = require('../interfaces/notification-types.js');
|
135
|
+
var twilsock = require('twilsock');
|
135
136
|
|
136
137
|
const log = logger.Logger.scope("TypingIndicator");
|
137
138
|
/**
|
@@ -172,7 +173,7 @@ class TypingIndicator {
|
|
172
173
|
// this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
|
173
174
|
this.services.notificationClient.on("message", async (type, message) => {
|
174
175
|
if (type === notificationTypes.NotificationTypes.TYPING_INDICATOR) {
|
175
|
-
await this._handleRemoteTyping(message);
|
176
|
+
await this._handleRemoteTyping(JSON.parse(message));
|
176
177
|
}
|
177
178
|
});
|
178
179
|
}
|
@@ -219,10 +220,15 @@ class TypingIndicator {
|
|
219
220
|
const headers = {
|
220
221
|
"Content-Type": "application/x-www-form-urlencoded",
|
221
222
|
};
|
222
|
-
const
|
223
|
-
return
|
224
|
-
.
|
225
|
-
|
223
|
+
const payload = `ChannelSid=${conversationSid}`;
|
224
|
+
return this.services.twilsockClient
|
225
|
+
.sendRequest(new twilsock.HttpRequest({
|
226
|
+
method: "POST",
|
227
|
+
url,
|
228
|
+
headers,
|
229
|
+
payload,
|
230
|
+
grant: this.configuration.productId,
|
231
|
+
}))
|
226
232
|
.then((response) => {
|
227
233
|
const body = JSON.parse(response.payload);
|
228
234
|
if (body.hasOwnProperty("typing_timeout")) {
|
@@ -232,7 +238,7 @@ class TypingIndicator {
|
|
232
238
|
.catch((err) => {
|
233
239
|
log.error("Failed to send typing indicator:", err);
|
234
240
|
throw err;
|
235
|
-
})
|
241
|
+
});
|
236
242
|
}
|
237
243
|
}
|
238
244
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"typing-indicator.js","sources":["../../src/services/typing-indicator.ts"],"sourcesContent":["import { Logger } from \"../logger\";\n\nimport { Notifications } from \"@twilio/notifications\";\n\nimport { NotificationTypes } from \"../interfaces/notification-types\";\nimport { TwilsockClient } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\nimport { Conversation } from \"../conversation\";\n\nconst log = Logger.scope(\"TypingIndicator\");\n\nexport interface TypingIndicatorServices {\n twilsockClient: TwilsockClient;\n notificationClient: Notifications;\n}\n\n/**\n * An important note in regards to typing timeout timers. There are two places that the SDK can get the \"typing_timeout\" attribute from. The first\n * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the\n * \"typing_timeout\" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a\n * notification of type \"twilio.ipmsg.typing_indicator\". In this case, the \"typing_timeout\" value will be +1 of that in the console. This\n * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,\n * the timeout returned from the notification should be used as the timeout for the \"typingEnded\" event, +1 is to account for latency.\n *\n * @private\n */\n\n/**\n * @class TypingIndicator\n *\n * @constructor\n * @private\n */\nclass TypingIndicator {\n private readonly services: TypingIndicatorServices;\n private readonly configuration: Configuration;\n\n private sentUpdates: Map<string, number>;\n private getConversation: (conversationSid: string) => Promise<Conversation>;\n private serviceTypingTimeout;\n\n constructor(\n getConversation: (conversationSid: string) => Promise<Conversation>,\n config: Configuration,\n services: TypingIndicatorServices\n ) {\n this.configuration = config;\n this.services = services;\n this.getConversation = getConversation;\n\n this.serviceTypingTimeout = null;\n this.sentUpdates = new Map();\n }\n\n public get typingTimeout(): number {\n return (\n this.configuration.typingIndicatorTimeoutOverride ||\n this.serviceTypingTimeout ||\n this.configuration.typingIndicatorTimeoutDefault\n );\n }\n\n /**\n * Initialize TypingIndicator controller\n * Registers for needed message types and sets listeners\n * @private\n */\n initialize(): void {\n // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');\n this.services.notificationClient.on(\"message\", async (type, message) => {\n if (type === NotificationTypes.TYPING_INDICATOR) {\n await this._handleRemoteTyping(message);\n }\n });\n }\n\n /**\n * Remote participants typing events handler\n */\n private async _handleRemoteTyping(message) {\n log.trace(\"Got new typing indicator \", message);\n\n this.getConversation(message.channel_sid)\n .then((conversation) => {\n if (!conversation) {\n return;\n }\n\n conversation._participants.forEach((participant) => {\n if (participant.identity !== message.identity) {\n return;\n }\n\n const timeout = this.configuration.typingIndicatorTimeoutOverride\n ? this.configuration.typingIndicatorTimeoutOverride + 1000\n : message.typing_timeout * 1000;\n participant._startTyping(timeout);\n });\n })\n .catch((err) => {\n log.error(err);\n throw err;\n });\n }\n\n /**\n * Send typing event for the given conversation sid\n * @param {String} conversationSid\n */\n send(conversationSid: string) {\n const lastUpdate = this.sentUpdates.get(conversationSid);\n if (lastUpdate && lastUpdate > Date.now() - this.typingTimeout) {\n return Promise.resolve();\n }\n\n this.sentUpdates.set(conversationSid, Date.now());\n return this._send(conversationSid);\n }\n\n private _send(conversationSid: string) {\n log.trace(\"Sending typing indicator\");\n\n const url = this.configuration.links.typing;\n const headers = {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n };\n const
|
1
|
+
{"version":3,"file":"typing-indicator.js","sources":["../../src/services/typing-indicator.ts"],"sourcesContent":["import { Logger } from \"../logger\";\n\nimport { Notifications } from \"@twilio/notifications\";\n\nimport { NotificationTypes } from \"../interfaces/notification-types\";\nimport { HttpRequest, TwilsockClient } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\nimport { Conversation } from \"../conversation\";\n\nconst log = Logger.scope(\"TypingIndicator\");\n\nexport interface TypingIndicatorServices {\n twilsockClient: TwilsockClient;\n notificationClient: Notifications;\n}\n\n/**\n * An important note in regards to typing timeout timers. There are two places that the SDK can get the \"typing_timeout\" attribute from. The first\n * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the\n * \"typing_timeout\" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a\n * notification of type \"twilio.ipmsg.typing_indicator\". In this case, the \"typing_timeout\" value will be +1 of that in the console. This\n * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,\n * the timeout returned from the notification should be used as the timeout for the \"typingEnded\" event, +1 is to account for latency.\n *\n * @private\n */\n\n/**\n * @class TypingIndicator\n *\n * @constructor\n * @private\n */\nclass TypingIndicator {\n private readonly services: TypingIndicatorServices;\n private readonly configuration: Configuration;\n\n private sentUpdates: Map<string, number>;\n private getConversation: (conversationSid: string) => Promise<Conversation>;\n private serviceTypingTimeout;\n\n constructor(\n getConversation: (conversationSid: string) => Promise<Conversation>,\n config: Configuration,\n services: TypingIndicatorServices\n ) {\n this.configuration = config;\n this.services = services;\n this.getConversation = getConversation;\n\n this.serviceTypingTimeout = null;\n this.sentUpdates = new Map();\n }\n\n public get typingTimeout(): number {\n return (\n this.configuration.typingIndicatorTimeoutOverride ||\n this.serviceTypingTimeout ||\n this.configuration.typingIndicatorTimeoutDefault\n );\n }\n\n /**\n * Initialize TypingIndicator controller\n * Registers for needed message types and sets listeners\n * @private\n */\n initialize(): void {\n // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');\n this.services.notificationClient.on(\"message\", async (type, message) => {\n if (type === NotificationTypes.TYPING_INDICATOR) {\n await this._handleRemoteTyping(JSON.parse(message));\n }\n });\n }\n\n /**\n * Remote participants typing events handler\n */\n private async _handleRemoteTyping(message) {\n log.trace(\"Got new typing indicator \", message);\n\n this.getConversation(message.channel_sid)\n .then((conversation) => {\n if (!conversation) {\n return;\n }\n\n conversation._participants.forEach((participant) => {\n if (participant.identity !== message.identity) {\n return;\n }\n\n const timeout = this.configuration.typingIndicatorTimeoutOverride\n ? this.configuration.typingIndicatorTimeoutOverride + 1000\n : message.typing_timeout * 1000;\n participant._startTyping(timeout);\n });\n })\n .catch((err) => {\n log.error(err);\n throw err;\n });\n }\n\n /**\n * Send typing event for the given conversation sid\n * @param {String} conversationSid\n */\n send(conversationSid: string) {\n const lastUpdate = this.sentUpdates.get(conversationSid);\n if (lastUpdate && lastUpdate > Date.now() - this.typingTimeout) {\n return Promise.resolve();\n }\n\n this.sentUpdates.set(conversationSid, Date.now());\n return this._send(conversationSid);\n }\n\n private _send(conversationSid: string) {\n log.trace(\"Sending typing indicator\");\n\n const url = this.configuration.links.typing;\n const headers = {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n };\n const payload = `ChannelSid=${conversationSid}`;\n\n return this.services.twilsockClient\n .sendRequest(\n new HttpRequest({\n method: \"POST\",\n url,\n headers,\n payload,\n grant: this.configuration.productId,\n })\n )\n .then((response) => {\n const body = JSON.parse(response.payload);\n if (body.hasOwnProperty(\"typing_timeout\")) {\n this.serviceTypingTimeout = body.typing_timeout * 1000;\n }\n })\n .catch((err) => {\n log.error(\"Failed to send typing indicator:\", err);\n throw err;\n });\n }\n}\n\nexport { TypingIndicator };\n"],"names":["Logger","NotificationTypes","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,EAAA;AACnC,QAAA,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAEtC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;AAC5C,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,cAAc,EAAE,mCAAmC;SACpD,CAAC;AACF,QAAA,MAAM,OAAO,GAAG,CAAc,WAAA,EAAA,eAAe,EAAE,CAAC;AAEhD,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc;aAChC,WAAW,CACV,IAAIC,oBAAW,CAAC;AACd,YAAA,MAAM,EAAE,MAAM;YACd,GAAG;YACH,OAAO;YACP,OAAO;AACP,YAAA,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS;AACpC,SAAA,CAAC,CACH;AACA,aAAA,IAAI,CAAC,CAAC,QAAQ,KAAI;YACjB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC1C,YAAA,IAAI,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE;gBACzC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;AACxD,aAAA;AACH,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,GAAG,KAAI;AACb,YAAA,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;AACnD,YAAA,MAAM,GAAG,CAAC;AACZ,SAAC,CAAC,CAAC;KACN;AACF;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@twilio/conversations",
|
3
|
-
"version": "3.0.0-canary.
|
3
|
+
"version": "3.0.0-canary.2+d4f97895",
|
4
4
|
"description": "Twilio Conversations client library",
|
5
5
|
"main": "./builds/lib.js",
|
6
6
|
"browser": "./builds/browser.js",
|
@@ -36,13 +36,13 @@
|
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"@babel/runtime": "^7.17.0",
|
39
|
-
"@twilio/declarative-type-validator": "~0.2.1",
|
39
|
+
"@twilio/declarative-type-validator": "~0.2.2-rc.1",
|
40
40
|
"@twilio/deprecation-decorator": "^0.2.0",
|
41
|
-
"@twilio/mcs-client": "~0.6.1",
|
42
|
-
"@twilio/notifications": "~
|
43
|
-
"@twilio/operation-retrier": "~4.0.
|
44
|
-
"@twilio/replay-event-emitter": "~0.3.1",
|
45
|
-
"@twilio/shared": "~0.0.1",
|
41
|
+
"@twilio/mcs-client": "~0.6.2-rc.1",
|
42
|
+
"@twilio/notifications": "~3.0.0-canary.2+d4f97895",
|
43
|
+
"@twilio/operation-retrier": "~4.0.10-rc.1",
|
44
|
+
"@twilio/replay-event-emitter": "~0.3.2-rc.1",
|
45
|
+
"@twilio/shared": "~0.1.0-rc.1",
|
46
46
|
"core-js": "^3.17.3",
|
47
47
|
"iso8601-duration": "=1.2.0",
|
48
48
|
"isomorphic-form-data": "^2.0.0",
|
@@ -50,8 +50,8 @@
|
|
50
50
|
"loglevel": "^1.8.0",
|
51
51
|
"nanoid": "^3.3.4",
|
52
52
|
"platform": "^1.3.6",
|
53
|
-
"twilio-sync": "~
|
54
|
-
"twilsock": "~0.
|
53
|
+
"twilio-sync": "~4.0.0-canary.2+d4f97895",
|
54
|
+
"twilsock": "~1.0.0-canary.2+d4f97895"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
57
|
"@babel/core": "^7.17.0",
|
@@ -122,5 +122,5 @@
|
|
122
122
|
"last 2 Samsung versions",
|
123
123
|
"last 2 UCAndroid versions"
|
124
124
|
],
|
125
|
-
"gitHead": "
|
125
|
+
"gitHead": "d4f97895167fc357381daa23dba19a2c5429db87"
|
126
126
|
}
|