@twilio/conversations 2.2.1 → 3.0.0-canary.100

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.
Files changed (73) hide show
  1. package/README.md +2 -2
  2. package/builds/browser.js +888 -2159
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +18 -100
  5. package/builds/lib.js +888 -2159
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +24296 -26232
  8. package/builds/twilio-conversations.min.js +1 -1
  9. package/dist/client.js +56 -90
  10. package/dist/client.js.map +1 -1
  11. package/dist/command-executor.js +30 -12
  12. package/dist/command-executor.js.map +1 -1
  13. package/dist/conversation.js +44 -6
  14. package/dist/conversation.js.map +1 -1
  15. package/dist/data/conversations.js +4 -1
  16. package/dist/data/conversations.js.map +1 -1
  17. package/dist/data/messages.js +3 -13
  18. package/dist/data/messages.js.map +1 -1
  19. package/dist/data/participants.js +4 -2
  20. package/dist/data/participants.js.map +1 -1
  21. package/dist/data/users.js +4 -2
  22. package/dist/data/users.js.map +1 -1
  23. package/dist/message-builder.js.map +1 -1
  24. package/dist/message.js +1 -41
  25. package/dist/message.js.map +1 -1
  26. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  27. package/dist/packages/conversations/package.json.js +1 -1
  28. package/dist/participant.js.map +1 -1
  29. package/dist/services/network.js +38 -15
  30. package/dist/services/network.js.map +1 -1
  31. package/dist/services/typing-indicator.js +7 -5
  32. package/dist/services/typing-indicator.js.map +1 -1
  33. package/dist/unsent-message.js.map +1 -1
  34. package/dist/user.js.map +1 -1
  35. package/dist/util/index.js.map +1 -1
  36. package/package.json +15 -13
  37. package/CHANGELOG.md +0 -713
  38. package/docs/assets/css/main.css +0 -2660
  39. package/docs/assets/images/icons.png +0 -0
  40. package/docs/assets/images/icons@2x.png +0 -0
  41. package/docs/assets/images/widgets.png +0 -0
  42. package/docs/assets/images/widgets@2x.png +0 -0
  43. package/docs/assets/js/main.js +0 -248
  44. package/docs/assets/js/search.js +0 -1
  45. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  46. package/docs/classes/CancellablePromise.html +0 -3213
  47. package/docs/classes/Client.html +0 -4254
  48. package/docs/classes/Conversation.html +0 -4359
  49. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  50. package/docs/classes/Media.html +0 -3167
  51. package/docs/classes/Message.html +0 -3732
  52. package/docs/classes/MessageBuilder.html +0 -3277
  53. package/docs/classes/Participant.html +0 -3444
  54. package/docs/classes/PushNotification.html +0 -3130
  55. package/docs/classes/RestPaginator.html +0 -3160
  56. package/docs/classes/UnsentMessage.html +0 -3042
  57. package/docs/classes/User.html +0 -3349
  58. package/docs/index.html +0 -3513
  59. package/docs/interfaces/ClientOptions.html +0 -3034
  60. package/docs/interfaces/ConversationBindings.html +0 -3001
  61. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  62. package/docs/interfaces/ConversationLimits.html +0 -3098
  63. package/docs/interfaces/ConversationState.html +0 -3050
  64. package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
  65. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  66. package/docs/interfaces/LastMessage.html +0 -3050
  67. package/docs/interfaces/Paginator.html +0 -3141
  68. package/docs/interfaces/ParticipantBindings.html +0 -3001
  69. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  70. package/docs/interfaces/PushNotificationData.html +0 -3114
  71. package/docs/interfaces/SendEmailOptions.html +0 -3034
  72. package/docs/interfaces/SendMediaOptions.html +0 -3068
  73. package/docs/modules.html +0 -3514
package/builds/lib.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
3
3
  import { LogLevelDesc } from "loglevel";
4
- import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
5
- import { ConnectionState as TwilsockConnectionState } from "twilsock";
4
+ import { TwilsockClient, InitRegistration, HttpResponse } from "twilsock";
6
5
  import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
6
+ import { JSONValue } from "@twilio/shared";
7
7
  import { ChannelType, Notifications } from "@twilio/notifications";
8
8
  import { Notifications as NotificationClient } from "@twilio/notifications";
9
9
  import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
@@ -113,7 +113,7 @@ declare class Configuration {
113
113
  constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
114
114
  }
115
115
  interface CommandExecutorServices {
116
- transport: Transport;
116
+ transport: TwilsockClient;
117
117
  }
118
118
  declare class CommandExecutor {
119
119
  private _serviceUrl;
@@ -125,20 +125,6 @@ declare class CommandExecutor {
125
125
  fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
126
126
  mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
127
127
  }
128
- /**
129
- * Represents a JSON value.
130
- */
131
- type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
132
- /**
133
- * Represents a JSON object.
134
- */
135
- type JSONObject = {
136
- [x: string]: JSONValue;
137
- };
138
- /**
139
- * Represents a JSON array.
140
- */
141
- type JSONArray = JSONValue[];
142
128
  type UserEvents = {
143
129
  updated: (data: {
144
130
  user: User;
@@ -270,7 +256,7 @@ declare class Network {
270
256
  private cleanupCache;
271
257
  pokeTimer(): void;
272
258
  private executeWithRetry;
273
- get<T>(url: string): Promise<TransportResult<T>>;
259
+ get<T>(url: string): Promise<HttpResponse>;
274
260
  }
275
261
  type UsersEvents = {
276
262
  userUpdated: (data: {
@@ -491,26 +477,6 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
491
477
  */
492
478
  updateAttributes(attributes: JSONValue): Promise<Participant>;
493
479
  }
494
- interface ParticipantResponse {
495
- account_sid: string;
496
- chat_service_sid: string;
497
- conversation_sid: string;
498
- role_sid: string;
499
- sid: string;
500
- attributes: string;
501
- date_created: string;
502
- date_updated: string;
503
- identity: string;
504
- messaging_binding: {
505
- type: "chat" | "sms" | "whatsapp" | "email";
506
- address: string;
507
- proxy_address: string;
508
- } | null;
509
- url: string;
510
- links: {
511
- conversation: string;
512
- };
513
- }
514
480
  interface ParticipantBindingOptions {
515
481
  email?: ParticipantEmailBinding;
516
482
  }
@@ -752,8 +718,8 @@ interface MessageData {
752
718
  attributes?: JSONValue;
753
719
  dateUpdated: string;
754
720
  timestamp?: string;
755
- medias?: Media[];
756
- media?: Media;
721
+ medias: MediaState[] | null;
722
+ media: MediaState | null;
757
723
  memberSid?: string;
758
724
  delivery?: AggregatedDeliveryDescriptor;
759
725
  }
@@ -848,14 +814,6 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
848
814
  * Aggregated information about the message delivery statuses across all participants of a conversation..
849
815
  */
850
816
  get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
851
- /**
852
- * @deprecated
853
- * Return a (possibly empty) array of media matching a specific set of categories.
854
- * Allowed category is so far only 'media'.
855
- * @param categories Array of categories to match.
856
- * @returns Array of media descriptors matching given categories.
857
- */
858
- getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
859
817
  /**
860
818
  * Return a (possibly empty) array of media matching a specific set of categories.
861
819
  * Allowed category is so far only 'media'.
@@ -898,12 +856,6 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
898
856
  * @param attributes New attributes.
899
857
  */
900
858
  updateAttributes(attributes: JSONValue): Promise<Message>;
901
- /**
902
- * @deprecated
903
- * Get content URLs for all media attachments in the given set using a single operation.
904
- * @param contentSet Set of media attachments to query content URLs.
905
- */
906
- attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
907
859
  /**
908
860
  * Get content URLs for all media attachments in the given set using a single operation.
909
861
  * @param contentSet Set of media attachments to query content URLs.
@@ -1060,6 +1012,7 @@ interface MessageResponse {
1060
1012
  media: {
1061
1013
  sid: string;
1062
1014
  size: string;
1015
+ category: string;
1063
1016
  content_type: string;
1064
1017
  filename: string;
1065
1018
  }[] | null;
@@ -1129,7 +1082,7 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1129
1082
  */
1130
1083
  getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
1131
1084
  private _wrapPaginator;
1132
- private _upsertMessage;
1085
+ _upsertMessage(index: number, value: MessageData): Message;
1133
1086
  /**
1134
1087
  * Returns last messages from conversation
1135
1088
  * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
@@ -1629,7 +1582,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1629
1582
  * @param attributes Attributes to be attached to the participant.
1630
1583
  * @returns The added participant.
1631
1584
  */
1632
- add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1585
+ add(identity: string, attributes?: JSONValue): Promise<Participant>;
1633
1586
  /**
1634
1587
  * Add a non-chat participant to the conversation.
1635
1588
  * @param proxyAddress Proxy (Twilio) address of the participant.
@@ -1639,7 +1592,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1639
1592
  * CC/To level.
1640
1593
  * @returns The added participant.
1641
1594
  */
1642
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1595
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
1643
1596
  /**
1644
1597
  * Advance the conversation's last read message index to the current read
1645
1598
  * horizon. Rejects if the user is not a participant of the conversation. Last
@@ -1754,7 +1707,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1754
1707
  * @param emailOptions Email options for the message.
1755
1708
  * @return Index of the new message.
1756
1709
  */
1757
- sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1710
+ sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<Message>;
1758
1711
  /**
1759
1712
  * New interface to prepare for sending a message.
1760
1713
  * Use this instead of {@link Message.sendMessage}.
@@ -1972,12 +1925,11 @@ type ClientEvents = {
1972
1925
  user: User;
1973
1926
  updateReasons: UserUpdateReason[];
1974
1927
  }) => void;
1975
- stateChanged: (state: State) => void;
1976
1928
  initialized: () => void;
1977
1929
  initFailed: ({ error }: {
1978
1930
  error?: ConnectionError;
1979
1931
  }) => void;
1980
- connectionStateChanged: (state: TwilsockConnectionState) => void;
1932
+ connectionStateChanged: (state: ConnectionState) => void;
1981
1933
  connectionError: (data: ConnectionError) => void;
1982
1934
  };
1983
1935
  /**
@@ -1990,7 +1942,7 @@ type ClientEvents = {
1990
1942
  * * `'denied'` - client connection is denied because of invalid JWT access
1991
1943
  * token. User must refresh token in order to proceed
1992
1944
  */
1993
- type ConnectionState = TwilsockConnectionState;
1945
+ type ConnectionState = "disconnected" | "connecting" | "connected";
1994
1946
  /**
1995
1947
  * State of the client. Possible values are as follows:
1996
1948
  * * `'failed'` - the client failed to initialize
@@ -2018,7 +1970,7 @@ interface ClientOptions {
2018
1970
  region?: string;
2019
1971
  productId?: string;
2020
1972
  twilsockClient?: TwilsockClient;
2021
- transport?: Transport;
1973
+ transport?: TwilsockClient;
2022
1974
  notificationsClient?: NotificationClient;
2023
1975
  syncClient?: SyncClient;
2024
1976
  typingIndicatorTimeoutOverride?: number;
@@ -2233,15 +2185,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2233
2185
  * @event
2234
2186
  */
2235
2187
  static readonly userUpdated = "userUpdated";
2236
- /**
2237
- * @deprecated Use initialized or initFailed events instead
2238
- * Fired when the state of the client has been changed.
2239
- *
2240
- * Parameters:
2241
- * 1. {@link State} `state` - the new client state
2242
- * @event
2243
- */
2244
- static readonly stateChanged = "stateChanged";
2245
2188
  /**
2246
2189
  * Fired when the client has completed initialization successfully.
2247
2190
  * @event
@@ -2301,7 +2244,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2301
2244
  /**
2302
2245
  * Client connection state.
2303
2246
  */
2304
- connectionState: ConnectionState;
2247
+ connectionState: ConnectionState | "unknown";
2305
2248
  /**
2306
2249
  * Promise that resolves on successful initialization.
2307
2250
  */
@@ -2365,32 +2308,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2365
2308
  * initialization was completed.
2366
2309
  */
2367
2310
  get reachabilityEnabled(): boolean;
2368
- /**
2369
- * @deprecated
2370
- * Current token.
2371
- * @internal
2372
- */
2373
- get token(): string;
2374
- /**
2375
- * @deprecated Call constructor directly.
2376
- *
2377
- * Factory method to create a Conversations client instance.
2378
- *
2379
- * The factory method will automatically trigger connection.
2380
- * Do not use it if you need finer-grained control.
2381
- *
2382
- * Since this method returns an already-initialized client, some of the events
2383
- * will be lost because they happen *before* the initialization. It is
2384
- * recommended that `client.onWithReplay` is used as opposed to `client.on`
2385
- * for subscribing to client events. The `client.onWithReplay` will re-emit
2386
- * the most recent value for a given event if it emitted before the
2387
- * subscription.
2388
- *
2389
- * @param token Access token.
2390
- * @param options Options to customize the client.
2391
- * @returns Returns a fully initialized client.
2392
- */
2393
- static create(token: string, options?: ClientOptions | null): Promise<Client>;
2394
2311
  /**
2395
2312
  * Static method for push notification payload parsing. Returns parsed push as
2396
2313
  * a {@link PushNotification} object.
@@ -2426,7 +2343,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2426
2343
  * @param conversationSid Conversation sid
2427
2344
  * @internal
2428
2345
  */
2429
- peekConversationBySid(conversationSid: string): Promise<Conversation>;
2346
+ private peekConversationBySid;
2430
2347
  /**
2431
2348
  * Get a known conversation by its unique identifier name.
2432
2349
  * @param uniqueName The unique identifier name of the conversation.
@@ -2526,4 +2443,5 @@ declare class NotificationTypes {
2526
2443
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
2527
2444
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
2528
2445
  }
2529
- export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray, CancellablePromise };
2446
+ export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, CancellablePromise };
2447
+ export { JSONValue, JSONObject, JSONArray } from "@twilio/shared";