@twilio/conversations 3.0.0-rc.8 → 3.0.1-rc.1
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/README.md +38 -28
- package/builds/browser.js +4327 -7903
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +629 -102
- package/builds/lib.js +4319 -7904
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +27540 -41958
- package/builds/twilio-conversations.min.js +200 -1
- package/dist/aggregated-delivery-receipt.js +10 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +192 -0
- package/dist/channel-metadata-client.js.map +1 -0
- package/dist/client.js +75 -123
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +81 -20
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +14 -3
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +184 -0
- package/dist/content-client.js.map +1 -0
- package/dist/content-template.js +310 -0
- package/dist/content-template.js.map +1 -0
- package/dist/conversation.js +105 -22
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +43 -5
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +26 -19
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +15 -4
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +11 -2
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +9 -0
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +9 -0
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/{attributes.js → rules.js} +26 -7
- package/dist/interfaces/rules.js.map +1 -0
- package/dist/logger.js +9 -0
- package/dist/logger.js.map +1 -1
- package/dist/media.js +9 -0
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +77 -6
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +115 -22
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +265 -0
- package/dist/node_modules/quick-lru/index.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +9 -0
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +10 -1
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +45 -36
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +9 -0
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +20 -11
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +110 -11
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +22 -5
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -0
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +20 -3
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +9 -0
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +9 -0
- package/dist/util/index.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +113 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1279 -0
- package/docs/classes/AggregatedDeliveryReceipt.html +144 -3182
- package/docs/classes/CancellablePromise.html +224 -3209
- package/docs/classes/CancellationError.html +112 -0
- package/docs/classes/ChannelMetadata.html +67 -0
- package/docs/classes/Client.html +701 -4237
- package/docs/classes/ContentTemplate.html +97 -0
- package/docs/classes/ContentTemplateVariable.html +90 -0
- package/docs/classes/Conversation.html +768 -4352
- package/docs/classes/DetailedDeliveryReceipt.html +116 -3162
- package/docs/classes/Media.html +119 -3165
- package/docs/classes/Message.html +417 -3730
- package/docs/classes/MessageBuilder.html +208 -3274
- package/docs/classes/Participant.html +258 -3442
- package/docs/classes/PushNotification.html +101 -3129
- package/docs/classes/RestPaginator.html +120 -3158
- package/docs/classes/UnsentMessage.html +63 -3040
- package/docs/classes/User.html +209 -3347
- package/docs/index.html +146 -3502
- package/docs/interfaces/ClientOptions.html +66 -3033
- package/docs/interfaces/ConversationBindings.html +109 -3000
- package/docs/interfaces/ConversationEmailBinding.html +109 -3000
- package/docs/interfaces/ConversationLimits.html +87 -3097
- package/docs/interfaces/ConversationState.html +66 -3049
- package/docs/interfaces/ConversationUpdatedEventArgs.html +109 -3000
- package/docs/interfaces/CreateConversationOptions.html +73 -3065
- package/docs/interfaces/LastMessage.html +66 -3049
- package/docs/interfaces/Paginator.html +110 -3139
- package/docs/interfaces/ParticipantBindingOptions.html +110 -0
- package/docs/interfaces/ParticipantBindings.html +109 -3000
- package/docs/interfaces/ParticipantEmailBinding.html +109 -3000
- package/docs/interfaces/PushNotificationData.html +94 -3113
- package/docs/interfaces/SendEmailOptions.html +59 -3033
- package/docs/interfaces/SendMediaOptions.html +75 -3067
- package/docs/modules.html +180 -3509
- package/docs/types/ChannelType.html +106 -0
- package/docs/types/ConnectionState.html +115 -0
- package/docs/types/ContentData.html +106 -0
- package/docs/types/ContentDataAction.html +107 -0
- package/docs/types/ContentDataActionOther.html +121 -0
- package/docs/types/ContentDataActionPhone.html +128 -0
- package/docs/types/ContentDataActionReply.html +133 -0
- package/docs/types/ContentDataActionUrl.html +128 -0
- package/docs/types/ContentDataCallToAction.html +131 -0
- package/docs/types/ContentDataCard.html +137 -0
- package/docs/types/ContentDataListItem.html +121 -0
- package/docs/types/ContentDataListPicker.html +134 -0
- package/docs/types/ContentDataLocation.html +134 -0
- package/docs/types/ContentDataMedia.html +129 -0
- package/docs/types/ContentDataOther.html +121 -0
- package/docs/types/ContentDataQuickReply.html +131 -0
- package/docs/types/ContentDataReply.html +119 -0
- package/docs/types/ContentDataText.html +125 -0
- package/docs/types/ConversationStatus.html +107 -0
- package/docs/types/ConversationUpdateReason.html +106 -0
- package/docs/types/DeliveryAmount.html +106 -0
- package/docs/types/DeliveryStatus.html +106 -0
- package/docs/types/JSONArray.html +106 -0
- package/docs/types/JSONObject.html +111 -0
- package/docs/types/JSONValue.html +106 -0
- package/docs/types/LogLevel.html +106 -0
- package/docs/types/MediaCategory.html +106 -0
- package/docs/types/MessageType.html +106 -0
- package/docs/types/MessageUpdateReason.html +106 -0
- package/docs/types/NotificationLevel.html +109 -0
- package/docs/types/NotificationsChannelType.html +110 -0
- package/docs/types/ParticipantEmailLevel.html +108 -0
- package/docs/types/ParticipantType.html +107 -0
- package/docs/types/ParticipantUpdateReason.html +106 -0
- package/docs/types/PushNotificationType.html +106 -0
- package/docs/types/State.html +110 -0
- package/docs/types/UserUpdateReason.html +106 -0
- package/package.json +22 -17
- package/CHANGELOG.md +0 -501
- package/dist/interfaces/attributes.js.map +0 -1
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
package/dist/client.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import { Logger } from \"./logger\";\nimport { Configuration } from \"./configuration\";\n\nimport { User, UserUpdatedEventArgs, UserUpdateReason } from \"./user\";\nimport { Network } from \"./services/network\";\n\nimport { NotificationTypes } from \"./interfaces/notification-types\";\n\nimport {\n TwilsockClient,\n InitRegistration,\n ConnectionState as TwilsockConnectionState,\n Transport,\n ConnectionError,\n} from \"twilsock\";\nimport {\n ChannelType,\n Notifications as NotificationClient,\n} from \"@twilio/notifications\";\nimport { SyncClient } from \"twilio-sync\";\nimport { McsClient } from \"@twilio/mcs-client\";\n\nimport {\n Conversation,\n Conversations,\n Conversations as ConversationsEntity,\n} from \"./data/conversations\";\n\nimport { Users } from \"./data/users\";\nimport { TypingIndicator } from \"./services/typing-indicator\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { PushNotification } from \"./push-notification\";\nimport { deepClone, parseToNumber } from \"./util\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport { TelemetryEventDescription, TelemetryPoint } from \"twilsock\";\nimport {\n validateTypesAsync,\n validateTypes,\n literal,\n nonEmptyString,\n pureObject,\n objectSchema,\n validateConstructorTypes,\n nonEmptyArray,\n} from \"@twilio/declarative-type-validator\";\nimport { version as sdkVersion } from \"../package.json\";\nimport {\n ConversationUpdatedEventArgs,\n ConversationUpdateReason,\n} from \"./conversation\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { JSONValue } from \"./types\";\nimport { Media } from \"./media\";\nimport { CancellablePromise } from \"@twilio/mcs-client\";\n\n/**\n * Client events.\n */\ntype ClientEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n tokenAboutToExpire: () => void;\n tokenExpired: () => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n pushNotification: (pushNotification: PushNotification) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n stateChanged: ({\n state,\n error,\n }: {\n state: State;\n error?: ConnectionError;\n }) => void;\n connectionStateChanged: (state: TwilsockConnectionState) => void;\n connectionError: (data: ConnectionError) => void;\n};\n\n/**\n * Connection state of the client. Possible values are as follows:\n * * `'connecting'` - client is offline and connection attempt is in process\n * * `'connected'` - client is online and ready\n * * `'disconnecting'` - client is going offline as disconnection is in process\n * * `'disconnected'` - client is offline and no connection attempt is in\n * process\n * * `'denied'` - client connection is denied because of invalid JWT access\n * token. User must refresh token in order to proceed\n */\ntype ConnectionState = TwilsockConnectionState;\n\n/**\n * State of the client. Possible values are as follows:\n * * `'failed'` - the client failed to initialize\n * * `'initialized'` - the client successfully initialized\n */\ntype State = \"failed\" | \"initialized\";\n\n/**\n * Notifications channel type. Possible values are as follows:\n * * `'fcm'`\n * * `'apn'`\n */\ntype NotificationsChannelType = ChannelType;\n\n/**\n * Level of logging.\n */\ntype LogLevel = \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" | \"silent\";\n\n/**\n * Conversations client options.\n */\ninterface ClientOptions {\n /**\n * The level of logging to enable.\n */\n logLevel?: LogLevel;\n\n region?: string;\n productId?: string;\n twilsockClient?: TwilsockClient;\n transport?: Transport;\n notificationsClient?: NotificationClient;\n syncClient?: SyncClient;\n typingIndicatorTimeoutOverride?: number;\n consumptionReportIntervalOverride?: string;\n httpCacheIntervalOverride?: string;\n userInfosToSubscribeOverride?: number;\n retryWhenThrottledOverride?: boolean;\n backoffConfigOverride?: Record<string, unknown>;\n Chat?: ClientOptions;\n IPMessaging?: ClientOptions;\n Sync?: Record<string, unknown>;\n Notification?: Record<string, unknown>;\n Twilsock?: Record<string, unknown>;\n clientMetadata?: Record<string, unknown>;\n initRegistrations?: InitRegistration[];\n disableDeepClone?: boolean;\n typingUri?: string;\n apiUri?: string;\n}\n\n/**\n * Options for {@link Client.createConversation}.\n */\ninterface CreateConversationOptions {\n /**\n * Any custom attributes to attach to the conversation.\n */\n attributes?: JSONValue;\n\n /**\n * A non-unique display name of the conversation.\n */\n friendlyName?: string;\n\n /**\n * A unique identifier of the conversation.\n */\n uniqueName?: string;\n}\n\n/**\n * Client services.\n */\nclass ClientServices {\n commandExecutor!: CommandExecutor;\n twilsockClient!: TwilsockClient;\n users!: Users;\n notificationClient!: NotificationClient;\n network!: Network;\n typingIndicator!: TypingIndicator;\n syncClient!: SyncClient;\n mcsClient!: McsClient;\n transport!: Transport;\n}\n\n/**\n * A client is the starting point to the Twilio Conversations functionality.\n */\n@validateConstructorTypes(nonEmptyString, [pureObject, \"undefined\"])\nclass Client extends ReplayEventEmitter<ClientEvents> {\n /**\n * Fired when a conversation becomes visible to the client. The event is also\n * triggered when the client creates a new conversation.\n * Fired for all conversations that the client has joined.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationAdded = \"conversationAdded\";\n\n /**\n * Fired when the client joins a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationJoined = \"conversationJoined\";\n\n /**\n * Fired when the client leaves a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationLeft = \"conversationLeft\";\n\n /**\n * Fired when a conversation is no longer visible to the client.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationRemoved = \"conversationRemoved\";\n\n /**\n * Fired when the attributes or the metadata of a conversation have been\n * updated. During conversation's creation and initialization, this event\n * might be fired multiple times for same joined or created conversation as\n * new data is arriving from different sources.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Conversation} `conversation` - the conversation in question\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly conversationUpdated = \"conversationUpdated\";\n\n /**\n * Fired when a participant has joined a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when a participant's fields have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Participant} `participant` - the participant in question\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation on the server.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n public static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when a message is removed from the message list of a conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n public static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when the fields of an existing message are updated with new values.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Message} `message` - the message in question\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for\n * the update\n * @event\n */\n public static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when the token is about to expire and needs to be updated.\n * @event\n */\n public static readonly tokenAboutToExpire = \"tokenAboutToExpire\";\n\n /**\n * Fired when the token has expired.\n * @event\n */\n public static readonly tokenExpired = \"tokenExpired\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the client has received (and parsed) a push notification via one\n * of the push channels (apn or fcm).\n *\n * Parameters:\n * 1. {@link PushNotification} `pushNotification` - the push notification in\n * question\n * @event\n */\n public static readonly pushNotification = \"pushNotification\";\n\n /**\n * Fired when the client has subscribed to a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public static readonly userSubscribed = \"userSubscribed\";\n\n /**\n * Fired when the client has unsubscribed from a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public static readonly userUnsubscribed = \"userUnsubscribed\";\n\n /**\n * Fired when the properties or the reachability status of a user have been\n * updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the\n * update\n * @event\n */\n public static readonly userUpdated = \"userUpdated\";\n\n /**\n * Fired when the state of the client has been changed.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link State} `state` - the new client state\n * * Error? `error` - the initialization error if present\n * @event\n */\n public static readonly stateChanged = \"stateChanged\";\n\n /**\n * Fired when the connection state of the client has been changed.\n *\n * Parameters:\n * 1. {@link ConnectionState} `state` - the new connection state\n * @event\n */\n public static readonly connectionStateChanged = \"connectionStateChanged\";\n\n /**\n * Fired when the connection is interrupted for an unexpected reason.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * boolean `terminal` - Twilsock will stop connection attempts if true\n * * string `message` - the error message of the root cause\n * * number? `httpStatusCode` - http status code if available\n * * number? `errorCode` - Twilio public error code if available\n * @event\n */\n public static readonly connectionError = \"connectionError\";\n\n /**\n * Current version of the Conversations client.\n */\n public static readonly version: string = sdkVersion;\n\n /**\n * Logger instance.\n */\n private static readonly _logger = Logger.scope(\"Client\");\n\n /**\n * Supported push notification channels.\n */\n private static readonly _supportedPushChannels: NotificationsChannelType[] = [\n \"fcm\",\n \"apn\",\n ];\n\n /**\n * Supported push data fields.\n */\n private static readonly _supportedPushDataFields = {\n conversation_sid: \"conversationSid\", // string\n conversation_title: \"conversationTitle\", // string\n message_sid: \"messageSid\", // string\n message_index: \"messageIndex\", // integer\n media_count: \"mediaCount\", // integer\n media: \"media\", // object\n };\n\n /**\n * Current version of the Conversations client.\n */\n public readonly version: string = sdkVersion;\n\n /**\n * Client connection state.\n */\n public connectionState: ConnectionState = \"unknown\";\n\n /**\n * Promise that resolves on successful initialization.\n */\n private readonly _ensureReady!: Promise<void>;\n\n /**\n * Options passed to the client.\n */\n private readonly _options: Partial<ClientOptions>;\n\n /**\n * Client service objects.\n */\n private readonly _services: ClientServices;\n\n /**\n * The user of the client.\n */\n private readonly _myself: User;\n\n /**\n * Resolves the {@link Client._ensureReady} promise.\n */\n private _resolveEnsureReady!: () => void;\n\n /**\n * Rejects the {@link Client._ensureReady} promise.\n */\n private _rejectEnsureReady!: (err?: ConnectionError) => void;\n\n /**\n * The current token of the client.\n */\n private _fpaToken: string;\n\n /**\n * The constructed configuration object.\n */\n private _configuration!: Configuration;\n\n /**\n * The Conversations entity.\n */\n private _conversationsEntity!: Conversations;\n\n /**\n * Promise that resolves when initial conversations are fetched.\n */\n private _conversationsPromise!: Promise<Conversations>;\n\n /**\n * Returned Conversations instance is not yet fully initialized. Calling any\n * operations will block until it is. Use connection events to monitor when\n * client becomes fully available (connectionStateChanged with state\n * 'connected') or not available (connectionStateChange with state 'denied',\n * event tokenExpired, event connectionError).\n *\n * @param fpaToken Access token\n * @param options Options to customize the Client\n * @returns A not yet fully-initialized client.\n */\n public constructor(fpaToken: string, options: ClientOptions | null = {}) {\n super();\n\n this._fpaToken = fpaToken ?? \"\";\n this._options = options ?? {};\n\n if (!this._options.disableDeepClone) {\n let options: Partial<ClientOptions> = {\n ...this._options,\n transport: undefined,\n twilsockClient: undefined,\n };\n\n options = deepClone(options);\n options.transport = this._options.transport;\n options.twilsockClient = this._options.twilsockClient;\n\n this._options = options;\n }\n\n this._options.logLevel = this._options.logLevel ?? \"silent\";\n Client._logger.setLevel(this._options.logLevel);\n\n const productId = (this._options.productId = \"ip_messaging\");\n\n // Filling ClientMetadata\n this._options.clientMetadata = this._options.clientMetadata || {};\n\n if (!this._options.clientMetadata.hasOwnProperty(\"type\")) {\n this._options.clientMetadata.type = \"conversations\";\n }\n\n if (!this._options.clientMetadata.hasOwnProperty(\"sdk\")) {\n this._options.clientMetadata.sdk = \"JS\";\n this._options.clientMetadata.sdkv = sdkVersion;\n }\n\n // Enable session local storage for Sync\n this._options.Sync = this._options.Sync || {};\n\n if (typeof this._options.Sync.enableSessionStorage === \"undefined\") {\n this._options.Sync.enableSessionStorage = true;\n }\n\n if (this._options.region) {\n this._options.Sync.region = this._options.region;\n }\n\n if (!fpaToken) {\n throw new Error(\"A valid Twilio token should be provided\");\n }\n\n this._services = new ClientServices();\n\n this._myself = new User(\"\", \"\", null, this._services);\n\n const startTwilsock = !this._options.twilsockClient;\n\n // Create default init registrations if none were provided.\n // Otherwise, the outside party have to list all the init registrations they\n // need.\n // Init registrations passed to the Conversations client will be passed down\n // to the Sync client as well.\n if (!this._options.initRegistrations) {\n const initRegistration = new InitRegistration(productId);\n Client.populateInitRegistrations(initRegistration);\n this._options.initRegistrations = [initRegistration];\n }\n\n this._services.twilsockClient = this._options.twilsockClient =\n this._options.twilsockClient ??\n new TwilsockClient(fpaToken, productId, this._options);\n\n this._services.twilsockClient.on(\"tokenAboutToExpire\", () =>\n this.emit(\"tokenAboutToExpire\")\n );\n this._services.twilsockClient.on(\"tokenExpired\", () =>\n this.emit(\"tokenExpired\")\n );\n this._services.twilsockClient.on(\"connectionError\", (error) =>\n this.emit(\"connectionError\", error)\n );\n this._services.twilsockClient.on(\n \"stateChanged\",\n (state: ConnectionState) => {\n Client._logger.debug(\n `Handling stateChanged for ConversationsClient: new state ${state}`\n );\n if (state !== this.connectionState) {\n this.connectionState = state;\n this.emit(\"connectionStateChanged\", this.connectionState);\n }\n }\n );\n\n this._services.transport = this._options.transport = (this._options\n .transport ?? this._options.twilsockClient) as Transport;\n this._services.notificationClient = this._options.notificationsClient =\n this._options.notificationsClient ??\n new NotificationClient(fpaToken, this._options);\n this._services.syncClient = this._options.syncClient =\n this._options.syncClient ?? new SyncClient(fpaToken, this._options);\n\n const configurationOptions =\n options?.Chat || options?.IPMessaging || options || {};\n const region = configurationOptions.region || options?.region;\n const baseUrl: string =\n configurationOptions.apiUri ||\n configurationOptions.typingUri ||\n `https://aim.${region || \"us1\"}.twilio.com`;\n\n this._services.commandExecutor = new CommandExecutor(\n baseUrl,\n { transport: this._options.transport },\n productId\n );\n\n const emitFailed = (error?: ConnectionError): void => {\n this._rejectEnsureReady(error);\n this.emit(\"stateChanged\", { state: \"failed\", error });\n };\n\n const emitDisconnected = () => {\n emitFailed({\n terminal: true,\n message: \"Twilsock has disconnected.\",\n });\n };\n\n this._services.twilsockClient.onceWithReplay(\"connectionError\", emitFailed);\n this._services.twilsockClient.onceWithReplay(\n \"disconnected\",\n emitDisconnected\n );\n this._services.twilsockClient.onceWithReplay(\"connected\", async () => {\n Client._logger.debug(`ConversationsClient started INITIALIZING`);\n this._services.twilsockClient.off(\"connectionError\", emitFailed);\n this._services.twilsockClient.off(\"disconnected\", emitDisconnected);\n try {\n const startupEvent = \"conversations.client.startup\";\n\n this._services.twilsockClient.addPartialTelemetryEvent(\n new TelemetryEventDescription(\n startupEvent,\n \"Conversations client startup\",\n new Date()\n ),\n startupEvent,\n TelemetryPoint.Start\n );\n\n await this._initialize();\n\n this._services.twilsockClient.addPartialTelemetryEvent(\n new TelemetryEventDescription(\"\", \"\", new Date()),\n startupEvent,\n TelemetryPoint.End\n );\n } catch (err) {\n // Fail ChatClient if initialization is incomplete\n const connectionError = {\n terminal: true,\n message: err.message,\n };\n this._rejectEnsureReady(connectionError);\n this.emit(\"stateChanged\", { state: \"failed\", error: connectionError });\n }\n });\n\n this._ensureReady = new Promise<void>((resolve, reject) => {\n this._resolveEnsureReady = resolve;\n this._rejectEnsureReady = reject;\n }).catch(() => void 0); // @todo How to process unhandled rejection here?\n\n if (startTwilsock) {\n this._services.twilsockClient.connect();\n }\n }\n\n /**\n * Information of the logged-in user. Before client initialization, returns an\n * uninitialized user. Will trigger a {@link Client.userUpdated} event after\n * initialization.\n */\n public get user(): User {\n return this._myself;\n }\n\n /**\n * Client reachability state. Throws an error if accessed before the client\n * initialization was completed.\n */\n public get reachabilityEnabled(): boolean {\n if (!this._configuration) {\n throw new Error(\n \"Reachability information could not yet be accessed as the client \" +\n \"has not yet been initialized. Subscribe to the 'stateChanged' event \" +\n \"to properly react to the client initialization.\"\n );\n }\n\n return this._configuration.reachabilityEnabled;\n }\n\n /**\n * @deprecated Call constructor directly.\n *\n * Factory method to create a Conversations client instance.\n *\n * The factory method will automatically trigger connection.\n * Do not use it if you need finer-grained control.\n *\n * Since this method returns an already-initialized client, some of the events\n * will be lost because they happen *before* the initialization. It is\n * recommended that `client.onWithReplay` is used as opposed to `client.on`\n * for subscribing to client events. The `client.onWithReplay` will re-emit\n * the most recent value for a given event if it emitted before the\n * subscription.\n *\n * @param token Access token.\n * @param options Options to customize the client.\n * @returns Returns a fully initialized client.\n */\n @validateTypesAsync(\"string\", [\"undefined\", pureObject])\n public static async create(\n token: string,\n options?: ClientOptions | null\n ): Promise<Client> {\n // The logic is as follows:\n // - If twilsock is not passed in, then the ConversationsClient constructor will call twilsock.connect() by itself\n // and we do not need to do it here.\n // - If twilsock was passed in from the outside, but customer called ConversationsClient.create() then they are\n // using an obsolete workflow and the startup sequence will never complete.\n if (options?.twilsockClient) {\n throw new Error(\n \"Obsolete usage of ConversationsClient.create() \" +\n \"factory method: if you pass twilsock from the outside then you must \" +\n \"use ConversationsClient constructor and be prepared to work with \" +\n \"uninitialized client.\"\n );\n }\n\n const client = new Client(token, options);\n await client._ensureReady;\n\n return client;\n }\n\n /**\n * Static method for push notification payload parsing. Returns parsed push as\n * a {@link PushNotification} object.\n * @param notificationPayload Push notification payload.\n */\n @validateTypes(pureObject)\n public static parsePushNotification(notificationPayload): PushNotification {\n Client._logger.debug(\n \"parsePushNotification, notificationPayload=\",\n notificationPayload\n );\n\n // APNS specifics\n if (typeof notificationPayload.aps !== \"undefined\") {\n if (!notificationPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client._parsePushNotificationChatData(notificationPayload);\n\n const apsPayload = notificationPayload.aps;\n let body: string | null;\n let title: string | null = null;\n if (typeof apsPayload.alert === \"string\") {\n body = apsPayload.alert || null;\n } else {\n body = apsPayload.alert?.body || null;\n title = apsPayload.alert?.title || null;\n }\n\n return new PushNotification({\n title,\n body,\n sound: apsPayload.sound || null,\n badge: apsPayload.badge || null,\n action: apsPayload.category || null,\n type: notificationPayload.twi_message_type,\n data: data,\n });\n }\n\n // FCM specifics\n if (typeof notificationPayload.data !== \"undefined\") {\n const dataPayload = notificationPayload.data;\n if (!dataPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client._parsePushNotificationChatData(\n notificationPayload.data\n );\n return new PushNotification({\n title: dataPayload.twi_title || null,\n body: dataPayload.twi_body || null,\n sound: dataPayload.twi_sound || null,\n badge: null,\n action: dataPayload.twi_action || null,\n type: dataPayload.twi_message_type,\n data: data,\n });\n }\n\n throw new Error(\n \"Provided push notification payload is not Programmable Chat notification\"\n );\n }\n\n /**\n * Static method for parsing push notification chat data.\n * @param data Data to parse\n */\n private static _parsePushNotificationChatData(\n data: Record<string, unknown>\n ): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const key in Client._supportedPushDataFields) {\n const value = data[key];\n if (typeof value === \"undefined\" || value === null) {\n continue;\n }\n\n if (key === \"message_index\" || key === \"media_count\") {\n const number = parseToNumber(value);\n if (number !== null) {\n result[Client._supportedPushDataFields[key]] = number;\n }\n continue;\n }\n\n if (key === \"media\") {\n if (typeof value === \"string\") {\n try {\n result[Client._supportedPushDataFields[key]] = JSON.parse(value);\n } catch {\n Client._logger.debug(\"Media message notification parsing error\");\n }\n }\n continue;\n }\n\n result[Client._supportedPushDataFields[key]] = value;\n }\n\n return result;\n }\n\n /**\n * Populate the client with init registrations.\n * @param reg The init registration to populate.\n */\n public static populateInitRegistrations(reg: InitRegistration) {\n reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);\n SyncClient.populateInitRegistrations(reg);\n }\n\n /**\n * Gracefully shut down the client.\n */\n public async shutdown(): Promise<void> {\n await this._ensureReady;\n await this._services.twilsockClient.disconnect();\n }\n\n /**\n * Update the token used by the client and re-register with the Conversations services.\n * @param token New access token.\n */\n @validateTypesAsync(nonEmptyString)\n public async updateToken(token: string): Promise<Client> {\n await this._ensureReady;\n Client._logger.info(\"updateToken\");\n\n if (this._fpaToken === token) {\n return this;\n }\n\n await this._services.twilsockClient.updateToken(token);\n await this._services.notificationClient.updateToken(token);\n await this._services.mcsClient.updateToken(token);\n this._fpaToken = token;\n\n return this;\n }\n\n /**\n * Get a known conversation by its SID.\n * @param conversationSid Conversation sid\n */\n @validateTypesAsync(nonEmptyString)\n public async getConversationBySid(\n conversationSid: string\n ): Promise<Conversation> {\n await this._ensureReady;\n await this._conversationsEntity.myConversationsRead.promise;\n\n const conversation = await this._conversationsEntity.getConversation(\n conversationSid\n );\n\n if (!conversation) {\n throw new Error(\n `Conversation with SID ${conversationSid} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Peek a conversation by its SID.\n * @param conversationSid Conversation sid\n * @internal\n */\n @validateTypesAsync(nonEmptyString)\n public async peekConversationBySid(\n conversationSid: string\n ): Promise<Conversation> {\n await this._ensureReady;\n\n const conversation = await this._conversationsEntity.peekConversation(\n conversationSid\n );\n\n if (!conversation) {\n throw new Error(\n `Conversation with SID ${conversationSid} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Get a known conversation by its unique identifier name.\n * @param uniqueName The unique identifier name of the conversation.\n */\n @validateTypesAsync(nonEmptyString)\n public async getConversationByUniqueName(\n uniqueName: string\n ): Promise<Conversation> {\n await this._ensureReady;\n await this._conversationsEntity.myConversationsRead.promise;\n const conversation =\n await this._conversationsEntity.getConversationByUniqueName(uniqueName);\n\n if (!conversation) {\n throw new Error(\n `Conversation with unique name ${uniqueName} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Get the current list of all the subscribed conversations.\n */\n public async getSubscribedConversations(): Promise<Paginator<Conversation>> {\n await this._ensureReady;\n return this._conversationsPromise.then((conversations) =>\n conversations.getConversations()\n );\n }\n\n /**\n * Create a conversation on the server and subscribe to its events.\n * The default is a conversation with an empty friendly name.\n * @param options Options for the conversation.\n */\n @validateTypesAsync([\n \"undefined\",\n objectSchema(\"conversation options\", {\n friendlyName: [\"string\", \"undefined\"],\n isPrivate: [\"boolean\", \"undefined\"],\n uniqueName: [\"string\", \"undefined\"],\n }),\n ])\n public async createConversation(\n options?: CreateConversationOptions\n ): Promise<Conversation> {\n await this._ensureReady;\n options = options || {};\n return this._conversationsPromise.then((conversationsEntity) =>\n conversationsEntity.addConversation(options)\n );\n }\n\n /**\n * Register for push notifications.\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service\n * on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), \"string\")\n public async setPushRegistrationId(\n channelType: NotificationsChannelType,\n registrationId: string\n ): Promise<void> {\n await this._ensureReady;\n this._subscribeToPushNotifications(channelType);\n this._services.notificationClient.setPushRegistrationId(\n channelType,\n registrationId\n );\n await this._services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id\n }\n\n /**\n * Unregister from push notifications.\n * @param channelType Channel type.\n * @deprecated Use removePushRegistrations() instead.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"))\n public async unsetPushRegistrationId(\n channelType: NotificationsChannelType\n ): Promise<void> {\n await this._ensureReady;\n this._unsubscribeFromPushNotifications(channelType);\n await this._services.notificationClient.commitChanges();\n }\n\n /**\n * Clear existing registrations directly using provided device token.\n * This is useful to ensure stopped subscriptions without resubscribing.\n *\n * This function goes completely beside the state machine and removes all\n * registrations.\n * Use with caution: if it races with current state machine operations,\n * madness will ensue.\n *\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service\n * on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), nonEmptyString)\n public async removePushRegistrations(\n channelType: ChannelType,\n registrationId: string\n ): Promise<void> {\n // do not await this._ensureReady() here - it could be called at any moment\n await this._services.notificationClient.removeRegistrations(\n channelType,\n registrationId\n );\n }\n\n /**\n * Current version of the Conversations client.\n */\n public parsePushNotification = Client.parsePushNotification;\n\n /**\n * Handle push notification payload parsing and emit the\n * {@link Client.pushNotification} event on this {@link Client} instance.\n * @param notificationPayload Push notification payload\n */\n @validateTypesAsync(pureObject)\n public async handlePushNotification(notificationPayload): Promise<void> {\n await this._ensureReady;\n Client._logger.debug(\n \"handlePushNotification, notificationPayload=\",\n notificationPayload\n );\n this.emit(\n \"pushNotification\",\n Client.parsePushNotification(notificationPayload)\n );\n }\n\n /**\n * Gets a user with the given identity. If it's in the subscribed list, then\n * return the user object from it;\n * if not, then subscribe and add user to the subscribed list.\n * @param identity Identity of the user.\n * @returns A fully initialized user.\n */\n @validateTypesAsync(nonEmptyString)\n public async getUser(identity: string): Promise<User> {\n await this._ensureReady;\n return this._services.users.getUser(identity);\n }\n\n /**\n * Get a list of subscribed user objects.\n */\n public async getSubscribedUsers(): Promise<Array<User>> {\n await this._ensureReady;\n return this._services.users.getSubscribedUsers();\n }\n\n /**\n * Get content URLs for all media attachments in the given set of media sids\n * using a single operation.\n * @param mediaSids Set of media sids to query for the content URL.\n */\n @validateTypesAsync(nonEmptyArray(\"strings\", \"string\"))\n public getTemporaryContentUrlsForMediaSids(\n mediaSids: string[]\n ): CancellablePromise<Map<string, string>> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n if (!this._services.mcsClient || !mediaSids) {\n reject(new Error(\"Media Content Service is unavailable\"));\n return;\n }\n\n const request =\n this._services.mcsClient.mediaSetGetContentUrls(mediaSids);\n\n onCancel(() => {\n request.cancel();\n });\n\n try {\n const urls = await request;\n resolve(urls);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Get content URLs for all media attachments in the given set using a single\n * operation.\n * @param contentSet Set of media attachments to query content URLs.\n */\n @validateTypesAsync(nonEmptyArray(\"media\", Media))\n public getTemporaryContentUrlsForMedia(\n contentSet: Media[]\n ): CancellablePromise<Map<string, string>> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead, we just collect their sids and pull new descriptors from a\n // mediaSet GET endpoint.\n const sids = contentSet.map((m) => m.sid);\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n /**\n * Initialize the client.\n */\n private async _initialize() {\n const configurationResponse =\n await this._services.commandExecutor.fetchResource<\n void,\n ConfigurationResponse\n >(\"Client/v2/Configuration\");\n\n this._configuration = new Configuration(\n this._options as ClientOptions,\n configurationResponse,\n Client._logger\n );\n\n this._myself._resolveInitialization(\n this._configuration,\n this._configuration.userIdentity,\n this._configuration.userInfo,\n true\n );\n\n this._services.typingIndicator = new TypingIndicator(\n this.getConversationBySid.bind(this),\n this._configuration,\n this._services\n );\n this._services.network = new Network(this._configuration, this._services);\n\n this._services.users = new Users(\n this._myself,\n this._configuration,\n this._services\n );\n this._services.users.on(\"userSubscribed\", (user) => {\n this.emit(\"userSubscribed\", user);\n });\n this._services.users.on(\"userUpdated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this._services.users.on(\"userUnsubscribed\", (user) => {\n this.emit(\"userUnsubscribed\", user);\n });\n\n this._conversationsEntity = new ConversationsEntity(\n this._configuration,\n this._services\n );\n\n this._conversationsEntity.on(\"conversationAdded\", (conversation) => {\n this.emit(\"conversationAdded\", conversation);\n });\n this._conversationsEntity.on(\"conversationRemoved\", (conversation) => {\n this.emit(\"conversationRemoved\", conversation);\n });\n this._conversationsEntity.on(\"conversationJoined\", (conversation) => {\n this.emit(\"conversationJoined\", conversation);\n });\n this._conversationsEntity.on(\"conversationLeft\", (conversation) => {\n this.emit(\"conversationLeft\", conversation);\n });\n this._conversationsEntity.on(\n \"conversationUpdated\",\n (args: ConversationUpdatedEventArgs) =>\n this.emit(\"conversationUpdated\", args)\n );\n\n this._conversationsEntity.on(\"participantJoined\", (participant) => {\n this.emit(\"participantJoined\", participant);\n });\n this._conversationsEntity.on(\"participantLeft\", (participant) => {\n this.emit(\"participantLeft\", participant);\n });\n this._conversationsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this._conversationsEntity.on(\"messageAdded\", (message) =>\n this.emit(\"messageAdded\", message)\n );\n this._conversationsEntity.on(\n \"messageUpdated\",\n (args: MessageUpdatedEventArgs) => this.emit(\"messageUpdated\", args)\n );\n this._conversationsEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n\n this._conversationsEntity.on(\"typingStarted\", (participant) =>\n this.emit(\"typingStarted\", participant)\n );\n this._conversationsEntity.on(\"typingEnded\", (participant) =>\n this.emit(\"typingEnded\", participant)\n );\n\n this._conversationsPromise = this._conversationsEntity\n .fetchConversations()\n .then(() => this._conversationsEntity)\n .catch((error) => {\n throw error;\n });\n\n await this._services.users.myself._ensureFetched();\n\n Client._supportedPushChannels.forEach((channelType) =>\n this._subscribeToPushNotifications(channelType)\n );\n this._services.typingIndicator.initialize();\n\n this._services.mcsClient = new McsClient(\n this._fpaToken,\n this._configuration.links.mediaService,\n this._configuration.links.mediaSetService,\n {\n ...this._options,\n transport: undefined,\n }\n );\n\n this._resolveEnsureReady();\n this.emit(\"stateChanged\", { state: \"initialized\" });\n }\n\n /**\n * Subscribe to push notifications.\n * @param channelType The channel type to subscribe to.\n */\n private _subscribeToPushNotifications(channelType: NotificationsChannelType) {\n [\n NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE,\n ].forEach((messageType) => {\n this._services.notificationClient.subscribe(channelType, messageType);\n });\n }\n\n /**\n * Unsubscribe from push notifications.\n * @param channelType The channel type to unsubscribe from.\n */\n private _unsubscribeFromPushNotifications(\n channelType: NotificationsChannelType\n ) {\n [\n NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE,\n ].forEach((messageType) => {\n this._services.notificationClient.unsubscribe(channelType, messageType);\n });\n }\n}\n\nexport {\n Client,\n State,\n ConnectionState,\n NotificationsChannelType,\n LogLevel,\n ClientOptions,\n CreateConversationOptions,\n};\n"],"names":["Client","ReplayEventEmitter","sdkVersion","deepClone","User","InitRegistration","TwilsockClient","NotificationClient","SyncClient","CommandExecutor","TelemetryEventDescription","TelemetryPoint","PushNotification","parseToNumber","NotificationTypes","CancellablePromise","Configuration","TypingIndicator","Network","Users","ConversationsEntity","McsClient","Logger","__decorate","validateTypesAsync","nonEmptyString","objectSchema","literal","pureObject","nonEmptyArray","Media","validateTypes","validateConstructorTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoMA;;AAEG;AACH,MAAM,cAAc,CAAA;AAUnB,CAAA;AAED;;AAEG;AAEGA,cAAM,GAAA,QAAA,GAAZ,MAAM,MAAO,SAAQC,qCAAgC,CAAA;AA2TnD;;;;;;;;;;AAUG;IACH,WAAmB,CAAA,QAAgB,EAAE,OAAA,GAAgC,EAAE,EAAA;;AACrE,QAAA,KAAK,EAAE,CAAC;AAxEV;;AAEG;QACa,IAAO,CAAA,OAAA,GAAWC,gBAAU,CAAC;AAE7C;;AAEG;QACI,IAAe,CAAA,eAAA,GAAoB,SAAS,CAAC;AA8mBpD;;AAEG;AACI,QAAA,IAAA,CAAA,qBAAqB,GAAG,QAAM,CAAC,qBAAqB,CAAC;QA/iB1D,IAAI,CAAC,SAAS,GAAG,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAR,KAAA,CAA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A,CAAA;AAUDuB,oBAAA,CAAA;IADCC,2CAAkB,CAACC,uCAAc,CAAC;;;;AAIlC,CAAA,EAAAzB,cAAA,CAAA,SAAA,EAAA,SAAA,EAAA,IAAA,CAAA,CAAA;AAgBDuB,oBAAA,CAAA;AADC,IAAAC,2CAAkB,CAACK,sCAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;;;8CAGpDd,4BAAkB,CAAA;AAqBpB,CAAA,EAAAf,cAAA,CAAA,SAAA,EAAA,qCAAA,EAAA,IAAA,CAAA,CAAA;AAQDuB,oBAAA,CAAA;AADC,IAAAC,2CAAkB,CAACK,sCAAa,CAAC,OAAO,EAAEC,WAAK,CAAC,CAAC;;;8CAG/Cf,4BAAkB,CAAA;AAMpB,CAAA,EAAAf,cAAA,CAAA,SAAA,EAAA,iCAAA,EAAA,IAAA,CAAA,CAAA;AAxaDuB,oBAAA,CAAA;IADCC,2CAAkB,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAEI,mCAAU,CAAC,CAAC;;;;AAuBvD,CAAA,EAAA5B,cAAA,EAAA,QAAA,EAAA,IAAA,CAAA,CAAA;AAQDuB,oBAAA,CAAA;IADCQ,sCAAa,CAACH,mCAAU,CAAC;;;8CACgChB,iCAAgB,CAAA;AA+DzE,CAAA,EAAAZ,cAAA,EAAA,uBAAA,EAAA,IAAA,CAAA,CAAA;AAnoBGA,cAAM,GAAA,QAAA,GAAAuB,oBAAA,CAAA;IADXS,iDAAwB,CAACP,uCAAc,EAAE,CAACG,mCAAU,EAAE,WAAW,CAAC,CAAC;;AAC9D,CAAA,EAAA5B,cAAM,CA+mCX;;"}
|
1
|
+
{"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import { Logger } from \"./logger\";\nimport { Configuration } from \"./configuration\";\n\nimport { User, UserUpdatedEventArgs, UserUpdateReason } from \"./user\";\nimport { Network } from \"./services/network\";\n\nimport { NotificationTypes } from \"./interfaces/notification-types\";\n\nimport { TwilsockClient } from \"twilsock\";\nimport {\n ChannelType,\n Notifications as NotificationClient,\n} from \"@twilio/notifications\";\nimport { SyncClient } from \"twilio-sync\";\nimport { McsClient } from \"@twilio/mcs-client\";\n\nimport {\n Conversation,\n Conversations,\n Conversations as ConversationsEntity,\n} from \"./data/conversations\";\n\nimport { Users } from \"./data/users\";\nimport { TypingIndicator } from \"./services/typing-indicator\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { PushNotification } from \"./push-notification\";\nimport { deepClone, parseToNumber } from \"./util\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport {\n validateTypesAsync,\n validateTypes,\n literal,\n nonEmptyString,\n pureObject,\n objectSchema,\n validateConstructorTypes,\n nonEmptyArray,\n} from \"@twilio/declarative-type-validator\";\nimport { version as sdkVersion } from \"../package.json\";\nimport {\n ConversationUpdatedEventArgs,\n ConversationUpdateReason,\n} from \"./conversation\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { ErrorInfo, JSONValue } from \"@twilio/shared\";\nimport { Media } from \"./media\";\nimport { CancellablePromise } from \"@twilio/mcs-client\";\nimport { ContentTemplate } from \"./content-template\";\nimport { ContentClient } from \"./content-client\";\nimport { ChannelMetadataClient } from \"./channel-metadata-client\";\n\n/**\n * Client events.\n */\ntype ClientEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n tokenAboutToExpire: () => void;\n tokenExpired: () => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n pushNotification: (pushNotification: PushNotification) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n initialized: () => void;\n initFailed: ({ error }: { error?: ConnectionError }) => void;\n connectionStateChanged: (state: ConnectionState) => void;\n connectionError: (data: ConnectionError) => void;\n};\n\n/**\n * Connection state of the client. Possible values are as follows:\n * * `'connecting'` - client is offline and connection attempt is in process\n * * `'connected'` - client is online and ready\n * * `'disconnecting'` - client is going offline as disconnection is in process\n * * `'disconnected'` - client is offline and no connection attempt is in\n * process\n * * `'denied'` - client connection is denied because of invalid JWT access\n * token. User must refresh token in order to proceed\n */\ntype ConnectionState = \"disconnected\" | \"connecting\" | \"connected\";\n\n/**\n * State of the client. Possible values are as follows:\n * * `'failed'` - the client failed to initialize\n * * `'initialized'` - the client successfully initialized\n */\ntype State = \"failed\" | \"initialized\";\n\n/**\n * Notifications channel type. Possible values are as follows:\n * * `'fcm'`\n * * `'apn'`\n */\ntype NotificationsChannelType = ChannelType;\n\n/**\n * Level of logging.\n */\ntype LogLevel = \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" | \"silent\";\n\n/**\n * Conversations client options.\n */\ninterface ClientOptions {\n /**\n * The level of logging to enable.\n */\n logLevel?: LogLevel;\n\n /**\n * The cache capacity for channel metadata.\n */\n channelMetadataCacheCapacity?: number;\n\n region?: string;\n productId?: string;\n twilsockClient?: TwilsockClient;\n transport?: TwilsockClient;\n notificationsClient?: NotificationClient;\n syncClient?: SyncClient;\n typingIndicatorTimeoutOverride?: number;\n consumptionReportIntervalOverride?: string;\n httpCacheIntervalOverride?: string;\n userInfosToSubscribeOverride?: number;\n retryWhenThrottledOverride?: boolean;\n backoffConfigOverride?: Record<string, unknown>;\n Chat?: ClientOptions;\n IPMessaging?: ClientOptions;\n Sync?: Record<string, unknown>;\n Notification?: Record<string, unknown>;\n Twilsock?: Record<string, unknown>;\n clientMetadata?: Record<string, unknown>;\n disableDeepClone?: boolean;\n typingUri?: string;\n apiUri?: string;\n}\n\ntype ConnectionError = {\n terminal: boolean;\n message: string;\n};\n\n/**\n * Options for {@link Client.createConversation}.\n */\ninterface CreateConversationOptions {\n /**\n * Any custom attributes to attach to the conversation.\n */\n attributes?: JSONValue;\n\n /**\n * A non-unique display name of the conversation.\n */\n friendlyName?: string;\n\n /**\n * A unique identifier of the conversation.\n */\n uniqueName?: string;\n}\n\n/**\n * Client services.\n */\nclass ClientServices {\n commandExecutor!: CommandExecutor;\n twilsockClient!: TwilsockClient;\n users!: Users;\n notificationClient!: NotificationClient;\n network!: Network;\n typingIndicator!: TypingIndicator;\n syncClient!: SyncClient;\n mcsClient!: McsClient;\n transport!: TwilsockClient;\n contentClient!: ContentClient;\n channelMetadataClient!: ChannelMetadataClient;\n}\n\n/**\n * A client is the starting point to the Twilio Conversations functionality.\n */\n@validateConstructorTypes(nonEmptyString, [pureObject, \"undefined\"])\nclass Client extends ReplayEventEmitter<ClientEvents> {\n /**\n * Fired when a conversation becomes visible to the client. The event is also\n * triggered when the client creates a new conversation.\n * Fired for all conversations that the client has joined.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationAdded = \"conversationAdded\";\n\n /**\n * Fired when the client joins a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationJoined = \"conversationJoined\";\n\n /**\n * Fired when the client leaves a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationLeft = \"conversationLeft\";\n\n /**\n * Fired when a conversation is no longer visible to the client.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n public static readonly conversationRemoved = \"conversationRemoved\";\n\n /**\n * Fired when the attributes or the metadata of a conversation have been\n * updated. During conversation's creation and initialization, this event\n * might be fired multiple times for same joined or created conversation as\n * new data is arriving from different sources.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Conversation} `conversation` - the conversation in question\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly conversationUpdated = \"conversationUpdated\";\n\n /**\n * Fired when a participant has joined a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when a participant's fields have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Participant} `participant` - the participant in question\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation on the server.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n public static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when a message is removed from the message list of a conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n public static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when the fields of an existing message are updated with new values.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Message} `message` - the message in question\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for\n * the update\n * @event\n */\n public static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when the token is about to expire and needs to be updated.\n * @event\n */\n public static readonly tokenAboutToExpire = \"tokenAboutToExpire\";\n\n /**\n * Fired when the token has expired.\n * @event\n */\n public static readonly tokenExpired = \"tokenExpired\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n public static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the client has received (and parsed) a push notification via one\n * of the push channels (apn or fcm).\n *\n * Parameters:\n * 1. {@link PushNotification} `pushNotification` - the push notification in\n * question\n * @event\n */\n public static readonly pushNotification = \"pushNotification\";\n\n /**\n * Fired when the client has subscribed to a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public static readonly userSubscribed = \"userSubscribed\";\n\n /**\n * Fired when the client has unsubscribed from a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public static readonly userUnsubscribed = \"userUnsubscribed\";\n\n /**\n * Fired when the properties or the reachability status of a user have been\n * updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the\n * update\n * @event\n */\n public static readonly userUpdated = \"userUpdated\";\n\n /**\n * Fired when the client has completed initialization successfully.\n * @event\n */\n public static readonly initialized = \"initialized\";\n\n /**\n * Fired when the client initialization failed.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following property:\n * * Error? `error` - the initialization error if present\n * @event\n */\n public static readonly initFailed = \"initFailed\";\n\n /**\n * Fired when the connection state of the client has been changed.\n *\n * Parameters:\n * 1. {@link ConnectionState} `state` - the new connection state\n * @event\n */\n public static readonly connectionStateChanged = \"connectionStateChanged\";\n\n /**\n * Fired when the connection is interrupted for an unexpected reason.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * boolean `terminal` - Twilsock will stop connection attempts if true\n * * string `message` - the error message of the root cause\n * * number? `httpStatusCode` - http status code if available\n * * number? `errorCode` - Twilio public error code if available\n * @event\n */\n public static readonly connectionError = \"connectionError\";\n\n /**\n * Current version of the Conversations client.\n */\n public static readonly version: string = sdkVersion;\n\n /**\n * Logger instance.\n */\n private static readonly _logger = Logger.scope(\"Client\");\n\n /**\n * Supported push notification channels.\n */\n private static readonly _supportedPushChannels: NotificationsChannelType[] = [\n \"fcm\",\n \"apn\",\n ];\n\n /**\n * Supported push data fields.\n */\n private static readonly _supportedPushDataFields = {\n conversation_sid: \"conversationSid\", // string\n conversation_title: \"conversationTitle\", // string\n message_sid: \"messageSid\", // string\n message_index: \"messageIndex\", // integer\n media_count: \"mediaCount\", // integer\n media: \"media\", // object\n };\n\n /**\n * Current version of the Conversations client.\n */\n public readonly version: string = sdkVersion;\n\n /**\n * Client connection state.\n */\n public connectionState: ConnectionState | \"unknown\" = \"unknown\";\n\n /**\n * Promise that resolves on successful initialization.\n */\n private readonly _ensureReady!: Promise<void>;\n\n /**\n * Options passed to the client.\n */\n private readonly _options: Partial<ClientOptions>;\n\n /**\n * Client service objects.\n */\n private readonly _services: ClientServices;\n\n /**\n * The user of the client.\n */\n private readonly _myself: User;\n\n /**\n * Resolves the {@link Client._ensureReady} promise.\n */\n private _resolveEnsureReady!: () => void;\n\n /**\n * Rejects the {@link Client._ensureReady} promise.\n */\n private _rejectEnsureReady!: (err?: ConnectionError) => void;\n\n /**\n * The current token of the client.\n */\n private _fpaToken: string;\n\n /**\n * The constructed configuration object.\n */\n private _configuration!: Configuration;\n\n /**\n * The Conversations entity.\n */\n private _conversationsEntity!: Conversations;\n\n /**\n * Promise that resolves when initial conversations are fetched.\n */\n private _conversationsPromise!: Promise<Conversations>;\n\n /**\n * Returned Conversations instance is not yet fully initialized. Calling any\n * operations will block until it is. Use connection events to monitor when\n * client becomes fully available (connectionStateChanged with state\n * 'connected') or not available (connectionStateChange with state 'denied',\n * event tokenExpired, event connectionError).\n *\n * @param fpaToken Access token\n * @param options Options to customize the Client\n * @returns A not yet fully-initialized client.\n */\n public constructor(fpaToken: string, options: ClientOptions | null = {}) {\n super();\n\n this._fpaToken = fpaToken ?? \"\";\n this._options = options ?? {};\n\n if (!this._options.disableDeepClone) {\n let options: Partial<ClientOptions> = {\n ...this._options,\n transport: undefined,\n twilsockClient: undefined,\n };\n\n options = deepClone(options);\n options.transport = this._options.transport;\n options.twilsockClient = this._options.twilsockClient;\n\n this._options = options;\n }\n\n this._options.logLevel = this._options.logLevel ?? \"silent\";\n Client._logger.setLevel(this._options.logLevel);\n\n const productId = (this._options.productId = \"ip_messaging\");\n\n // Filling ClientMetadata\n this._options.clientMetadata = this._options.clientMetadata || {};\n\n if (!this._options.clientMetadata.hasOwnProperty(\"type\")) {\n this._options.clientMetadata.type = \"conversations\";\n }\n\n if (!this._options.clientMetadata.hasOwnProperty(\"sdk\")) {\n this._options.clientMetadata.sdk = \"JS\";\n this._options.clientMetadata.sdkv = sdkVersion;\n }\n\n // Enable session local storage for Sync\n this._options.Sync = this._options.Sync || {};\n\n if (typeof this._options.Sync.enableSessionStorage === \"undefined\") {\n this._options.Sync.enableSessionStorage = true;\n }\n\n if (this._options.region) {\n this._options.Sync.region = this._options.region;\n }\n\n if (!fpaToken) {\n throw new Error(\"A valid Twilio token should be provided\");\n }\n\n this._services = new ClientServices();\n\n this._myself = new User(\"\", \"\", null, this._services);\n\n const startTwilsock = !this._options.twilsockClient;\n\n this._services.twilsockClient = this._options.twilsockClient =\n this._options.twilsockClient ??\n // todo: remove any after the release of new Twilsock\n new TwilsockClient(fpaToken, productId, this._options as any);\n\n this._services.twilsockClient.populateInitRegistrations(\n new Set([NotificationTypes.TYPING_INDICATOR])\n );\n\n this._services.twilsockClient.on(\"tokenAboutToExpire\", () =>\n this.emit(\"tokenAboutToExpire\")\n );\n this._services.twilsockClient.on(\"tokenExpired\", () =>\n this.emit(\"tokenExpired\")\n );\n this._services.twilsockClient.on(\"disconnected\", () => {\n Client._logger.debug(\n `Handling stateChanged for ConversationsClient: new state disconnected`\n );\n if (\"disconnected\" !== this.connectionState) {\n this.connectionState = \"disconnected\";\n this.emit(\"connectionStateChanged\", this.connectionState);\n }\n });\n this._services.twilsockClient.on(\"connecting\", () => {\n Client._logger.debug(\n `Handling stateChanged for ConversationsClient: new state connecting`\n );\n if (\"connecting\" !== this.connectionState) {\n this.connectionState = \"connecting\";\n this.emit(\"connectionStateChanged\", this.connectionState);\n }\n });\n this._services.twilsockClient.on(\"connected\", () => {\n Client._logger.debug(\n `Handling stateChanged for ConversationsClient: new state connected`\n );\n if (\"connected\" !== this.connectionState) {\n this.connectionState = \"connected\";\n this.emit(\"connectionStateChanged\", this.connectionState);\n }\n });\n\n this._services.transport = this._options.transport = (this._options\n .transport ?? this._options.twilsockClient) as TwilsockClient;\n this._services.notificationClient = this._options.notificationsClient =\n this._options.notificationsClient ??\n new NotificationClient(fpaToken, this._options);\n this._services.syncClient = this._options.syncClient =\n this._options.syncClient ?? new SyncClient(fpaToken, this._options);\n\n const configurationOptions =\n options?.Chat || options?.IPMessaging || options || {};\n const region = configurationOptions.region || options?.region;\n const baseUrl: string =\n configurationOptions.apiUri ||\n configurationOptions.typingUri ||\n `https://aim.${region || \"us1\"}.twilio.com`;\n\n this._services.commandExecutor = new CommandExecutor(\n baseUrl,\n { transport: this._options.transport },\n productId\n );\n this._services.contentClient = new ContentClient(this._services);\n\n const unsubscribeFatalError = this._services.twilsockClient.onceWithReplay(\n \"fatalError\",\n (errorInfo: ErrorInfo) => {\n const error = {\n terminal: true,\n message: errorInfo.description,\n };\n this._rejectEnsureReady(error);\n this.emit(\"initFailed\", { error });\n }\n );\n\n this._services.twilsockClient.onceWithReplay(\"connected\", async () => {\n Client._logger.debug(`ConversationsClient started INITIALIZING`);\n unsubscribeFatalError();\n\n try {\n await this._initialize();\n } catch (err) {\n // Fail ChatClient if initialization is incomplete\n const connectionError = {\n terminal: true,\n message: err.message,\n };\n this._rejectEnsureReady(connectionError);\n this.emit(\"initFailed\", {\n error: connectionError,\n });\n }\n });\n\n this._ensureReady = new Promise<void>((resolve, reject) => {\n this._resolveEnsureReady = resolve;\n this._rejectEnsureReady = reject;\n }).catch((e) => {\n Client._logger.error(e);\n });\n\n if (startTwilsock) {\n this._services.twilsockClient.connect();\n }\n }\n\n /**\n * Information of the logged-in user. Before client initialization, returns an\n * uninitialized user. Will trigger a {@link Client.userUpdated} event after\n * initialization.\n */\n public get user(): User {\n return this._myself;\n }\n\n /**\n * Client reachability state. Throws an error if accessed before the client\n * initialization was completed.\n */\n public get reachabilityEnabled(): boolean {\n if (!this._configuration) {\n throw new Error(\n \"Reachability information could not yet be accessed as the client \" +\n \"has not yet been initialized. Subscribe to 'initialized' and \" +\n \"'initFailed' events to properly react to the client initialization.\"\n );\n }\n\n return this._configuration.reachabilityEnabled;\n }\n\n /**\n * Static method for push notification payload parsing. Returns parsed push as\n * a {@link PushNotification} object.\n * @param notificationPayload Push notification payload.\n */\n @validateTypes(pureObject)\n public static parsePushNotification(notificationPayload): PushNotification {\n Client._logger.debug(\n \"parsePushNotification, notificationPayload=\",\n notificationPayload\n );\n\n // APNS specifics\n if (typeof notificationPayload.aps !== \"undefined\") {\n if (!notificationPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client._parsePushNotificationChatData(notificationPayload);\n\n const apsPayload = notificationPayload.aps;\n let body: string | null;\n let title: string | null = null;\n if (typeof apsPayload.alert === \"string\") {\n body = apsPayload.alert || null;\n } else {\n body = apsPayload.alert?.body || null;\n title = apsPayload.alert?.title || null;\n }\n\n return new PushNotification({\n title,\n body,\n sound: apsPayload.sound || null,\n badge: apsPayload.badge || null,\n action: apsPayload.category || null,\n type: notificationPayload.twi_message_type,\n data: data,\n });\n }\n\n // FCM specifics\n if (typeof notificationPayload.data !== \"undefined\") {\n const dataPayload = notificationPayload.data;\n if (!dataPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client._parsePushNotificationChatData(\n notificationPayload.data\n );\n return new PushNotification({\n title: dataPayload.twi_title || null,\n body: dataPayload.twi_body || null,\n sound: dataPayload.twi_sound || null,\n badge: null,\n action: dataPayload.twi_action || null,\n type: dataPayload.twi_message_type,\n data: data,\n });\n }\n\n throw new Error(\n \"Provided push notification payload is not Programmable Chat notification\"\n );\n }\n\n /**\n * Static method for parsing push notification chat data.\n * @param data Data to parse\n */\n private static _parsePushNotificationChatData(\n data: Record<string, unknown>\n ): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const key in Client._supportedPushDataFields) {\n const value = data[key];\n if (typeof value === \"undefined\" || value === null) {\n continue;\n }\n\n if (key === \"message_index\" || key === \"media_count\") {\n const number = parseToNumber(value);\n if (number !== null) {\n result[Client._supportedPushDataFields[key]] = number;\n }\n continue;\n }\n\n if (key === \"media\") {\n if (typeof value === \"string\") {\n try {\n result[Client._supportedPushDataFields[key]] = JSON.parse(value);\n } catch {\n Client._logger.debug(\"Media message notification parsing error\");\n }\n }\n continue;\n }\n\n result[Client._supportedPushDataFields[key]] = value;\n }\n\n return result;\n }\n\n /**\n * Gracefully shut down the client.\n */\n public async shutdown(): Promise<void> {\n await this._ensureReady;\n await this._services.network?.disconnect();\n }\n\n /**\n * Update the token used by the client and re-register with the Conversations services.\n * @param token New access token.\n */\n @validateTypesAsync(nonEmptyString)\n public async updateToken(token: string): Promise<Client> {\n await this._ensureReady;\n Client._logger.info(\"updateToken\");\n\n if (this._fpaToken === token) {\n return this;\n }\n\n await this._services.twilsockClient.updateToken(token);\n await this._services.notificationClient.updateToken(token);\n await this._services.mcsClient.updateToken(token);\n this._fpaToken = token;\n\n return this;\n }\n\n /**\n * Get a known conversation by its SID.\n * @param conversationSid Conversation sid\n */\n @validateTypesAsync(nonEmptyString)\n public async getConversationBySid(\n conversationSid: string\n ): Promise<Conversation> {\n await this._ensureReady;\n await this._conversationsEntity.myConversationsRead.promise;\n\n const conversation = await this._conversationsEntity.getConversation(\n conversationSid\n );\n\n if (!conversation) {\n throw new Error(\n `Conversation with SID ${conversationSid} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Peek a conversation by its SID.\n * @param conversationSid Conversation sid\n * @internal\n */\n @validateTypesAsync(nonEmptyString)\n public async peekConversationBySid(\n conversationSid: string\n ): Promise<Conversation> {\n await this._ensureReady;\n\n const conversation = await this._conversationsEntity.peekConversation(\n conversationSid\n );\n\n if (!conversation) {\n throw new Error(\n `Conversation with SID ${conversationSid} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Get a known conversation by its unique identifier name.\n * @param uniqueName The unique identifier name of the conversation.\n */\n @validateTypesAsync(nonEmptyString)\n public async getConversationByUniqueName(\n uniqueName: string\n ): Promise<Conversation> {\n await this._ensureReady;\n await this._conversationsEntity.myConversationsRead.promise;\n const conversation =\n await this._conversationsEntity.getConversationByUniqueName(uniqueName);\n\n if (!conversation) {\n throw new Error(\n `Conversation with unique name ${uniqueName} was not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Get the current list of all the subscribed conversations.\n */\n public async getSubscribedConversations(): Promise<Paginator<Conversation>> {\n await this._ensureReady;\n const conversations = await this._conversationsPromise;\n return await conversations.getConversations();\n }\n\n /**\n * Create a conversation on the server and subscribe to its events.\n * The default is a conversation with an empty friendly name.\n * @param options Options for the conversation.\n */\n @validateTypesAsync([\n \"undefined\",\n objectSchema(\"conversation options\", {\n friendlyName: [\"string\", \"undefined\"],\n isPrivate: [\"boolean\", \"undefined\"],\n uniqueName: [\"string\", \"undefined\"],\n }),\n ])\n public async createConversation(\n options?: CreateConversationOptions\n ): Promise<Conversation> {\n await this._ensureReady;\n options = options || {};\n return this._conversationsPromise.then((conversationsEntity) =>\n conversationsEntity.addConversation(options)\n );\n }\n\n /**\n * Register for push notifications.\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service\n * on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), \"string\")\n public async setPushRegistrationId(\n channelType: NotificationsChannelType,\n registrationId: string\n ): Promise<void> {\n await this._ensureReady;\n this._subscribeToPushNotifications(channelType);\n this._services.notificationClient.setPushRegistrationId(\n channelType,\n registrationId\n );\n await this._services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id\n }\n\n /**\n * Clear existing registrations directly using provided device token.\n * This is useful to ensure stopped subscriptions without resubscribing.\n *\n * This function goes completely beside the state machine and removes all\n * registrations.\n * Use with caution: if it races with current state machine operations,\n * madness will ensue.\n *\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service\n * on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), nonEmptyString)\n public async removePushRegistrations(\n channelType: ChannelType,\n registrationId: string\n ): Promise<void> {\n // do not await this._ensureReady() here - it could be called at any moment\n await this._services.notificationClient.removeRegistrations(\n channelType,\n registrationId\n );\n }\n\n /**\n * Current version of the Conversations client.\n */\n public parsePushNotification = Client.parsePushNotification;\n\n /**\n * Handle push notification payload parsing and emit the\n * {@link Client.pushNotification} event on this {@link Client} instance.\n * @param notificationPayload Push notification payload\n */\n @validateTypesAsync(pureObject)\n public async handlePushNotification(notificationPayload): Promise<void> {\n await this._ensureReady;\n Client._logger.debug(\n \"handlePushNotification, notificationPayload=\",\n notificationPayload\n );\n this.emit(\n \"pushNotification\",\n Client.parsePushNotification(notificationPayload)\n );\n }\n\n /**\n * Gets a user with the given identity. If it's in the subscribed list, then\n * return the user object from it;\n * if not, then subscribe and add user to the subscribed list.\n * @param identity Identity of the user.\n * @returns A fully initialized user.\n */\n @validateTypesAsync(nonEmptyString)\n public async getUser(identity: string): Promise<User> {\n await this._ensureReady;\n return this._services.users.getUser(identity);\n }\n\n /**\n * Get a list of subscribed user objects.\n */\n public async getSubscribedUsers(): Promise<Array<User>> {\n await this._ensureReady;\n return this._services.users.getSubscribedUsers();\n }\n\n /**\n * Get content URLs for all media attachments in the given set of media sids\n * using a single operation.\n * @param mediaSids Set of media sids to query for the content URL.\n */\n @validateTypesAsync(nonEmptyArray(\"strings\", \"string\"))\n public getTemporaryContentUrlsForMediaSids(\n mediaSids: string[]\n ): CancellablePromise<Map<string, string>> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n if (!this._services.mcsClient || !mediaSids) {\n reject(new Error(\"Media Content Service is unavailable\"));\n return;\n }\n\n const request =\n this._services.mcsClient.mediaSetGetContentUrls(mediaSids);\n\n onCancel(() => {\n request.cancel();\n });\n\n try {\n const urls = await request;\n resolve(urls);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Get content URLs for all media attachments in the given set using a single\n * operation.\n * @param contentSet Set of media attachments to query content URLs.\n */\n @validateTypesAsync(nonEmptyArray(\"media\", Media))\n public getTemporaryContentUrlsForMedia(\n contentSet: Media[]\n ): CancellablePromise<Map<string, string>> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead, we just collect their sids and pull new descriptors from a\n // mediaSet GET endpoint.\n const sids = contentSet.map((m) => m.sid);\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n /**\n * Returns rich content templates belonging to the account. Rich content\n * templates can be created via the Twilio console or the REST API.\n */\n public async getContentTemplates(): Promise<Readonly<ContentTemplate[]>> {\n await this._ensureReady;\n return await this._services.contentClient.getContentTemplates();\n }\n\n /**\n * Initialize the client.\n */\n private async _initialize() {\n const configurationResponse =\n await this._services.commandExecutor.fetchResource<\n void,\n ConfigurationResponse\n >(\"Client/v2/Configuration\");\n\n this._configuration = new Configuration(\n this._options as ClientOptions,\n configurationResponse,\n Client._logger\n );\n\n this._services.channelMetadataClient = new ChannelMetadataClient(\n this._services,\n this._configuration\n );\n\n this._myself._resolveInitialization(\n this._configuration,\n this._configuration.userIdentity,\n this._configuration.userInfo,\n true\n );\n\n this._services.typingIndicator = new TypingIndicator(\n this.getConversationBySid.bind(this),\n this._configuration,\n this._services\n );\n this._services.network = new Network(this._configuration, this._services);\n\n this._services.users = new Users(\n this._myself,\n this._configuration,\n this._services\n );\n this._services.users.on(\"userSubscribed\", (user) => {\n this.emit(\"userSubscribed\", user);\n });\n this._services.users.on(\"userUpdated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this._services.users.on(\"userUnsubscribed\", (user) => {\n this.emit(\"userUnsubscribed\", user);\n });\n\n this._conversationsEntity = new ConversationsEntity(\n this._configuration,\n this._services\n );\n\n this._conversationsEntity.on(\"conversationAdded\", (conversation) => {\n this.emit(\"conversationAdded\", conversation);\n });\n this._conversationsEntity.on(\"conversationRemoved\", (conversation) => {\n this.emit(\"conversationRemoved\", conversation);\n });\n this._conversationsEntity.on(\"conversationJoined\", (conversation) => {\n this.emit(\"conversationJoined\", conversation);\n });\n this._conversationsEntity.on(\"conversationLeft\", (conversation) => {\n this.emit(\"conversationLeft\", conversation);\n });\n this._conversationsEntity.on(\n \"conversationUpdated\",\n (args: ConversationUpdatedEventArgs) =>\n this.emit(\"conversationUpdated\", args)\n );\n\n this._conversationsEntity.on(\"participantJoined\", (participant) => {\n this.emit(\"participantJoined\", participant);\n });\n this._conversationsEntity.on(\"participantLeft\", (participant) => {\n this.emit(\"participantLeft\", participant);\n });\n this._conversationsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this._conversationsEntity.on(\"messageAdded\", (message) =>\n this.emit(\"messageAdded\", message)\n );\n this._conversationsEntity.on(\n \"messageUpdated\",\n (args: MessageUpdatedEventArgs) => this.emit(\"messageUpdated\", args)\n );\n this._conversationsEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n\n this._conversationsEntity.on(\"typingStarted\", (participant) =>\n this.emit(\"typingStarted\", participant)\n );\n this._conversationsEntity.on(\"typingEnded\", (participant) =>\n this.emit(\"typingEnded\", participant)\n );\n\n this._conversationsPromise = this._conversationsEntity\n .fetchConversations()\n .then(() => this._conversationsEntity)\n .catch((error) => {\n if (error.message === \"Client has been shut down.\") {\n return this._conversationsEntity;\n }\n\n throw error;\n });\n\n await this._services.users.myself._ensureFetched();\n\n Client._supportedPushChannels.forEach((channelType) =>\n this._subscribeToPushNotifications(channelType)\n );\n this._services.typingIndicator.initialize();\n\n this._services.mcsClient = new McsClient(\n this._fpaToken,\n this._configuration.links.mediaService,\n this._configuration.links.mediaSetService,\n {\n ...this._options,\n transport: undefined,\n }\n );\n\n this._resolveEnsureReady();\n this.emit(\"initialized\");\n }\n\n /**\n * Subscribe to push notifications.\n * @param channelType The channel type to subscribe to.\n */\n private _subscribeToPushNotifications(channelType: NotificationsChannelType) {\n [\n NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE,\n ].forEach((messageType) => {\n this._services.notificationClient.subscribe(channelType, messageType);\n });\n }\n}\n\nexport {\n Client,\n State,\n ConnectionState,\n NotificationsChannelType,\n LogLevel,\n ClientOptions,\n CreateConversationOptions,\n};\n"],"names":["Client","ReplayEventEmitter","sdkVersion","deepClone","User","TwilsockClient","NotificationTypes","NotificationClient","SyncClient","CommandExecutor","ContentClient","PushNotification","parseToNumber","CancellablePromise","Configuration","ChannelMetadataClient","TypingIndicator","Network","Users","ConversationsEntity","McsClient","Logger","__decorate","validateTypesAsync","nonEmptyString","objectSchema","literal","pureObject","nonEmptyArray","Media","validateTypes","validateConstructorTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoMA;;AAEG;AACH,MAAM,cAAc,CAAA;AAYnB,CAAA;AAED;;AAEG;AAEGA,cAAM,GAAA,QAAA,GADZ,MACM,MAAO,SAAQC,qCAAgC,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ADbQ,sCAAa,CAACH,mCAAU,CAAC;;;8CACgChB,iCAAgB,CAAA;AA+DzE,CAAA,EAAAX,cAAA,EAAA,uBAAA,EAAA,IAAA,CAAA,CAAA;AAhlBGA,cAAM,GAAA,QAAA,GAAAsB,oBAAA,CAAA;IADXS,iDAAwB,CAACP,uCAAc,EAAE,CAACG,mCAAU,EAAE,WAAW,CAAC,CAAC;;AAC9D,CAAA,EAAA3B,cAAM,CAoiCX;;"}
|
package/dist/command-executor.js
CHANGED
@@ -128,13 +128,28 @@ This software includes platform.js under the following license.
|
|
128
128
|
*/
|
129
129
|
'use strict';
|
130
130
|
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
131
140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
141
|
|
133
|
-
var
|
142
|
+
var twilsock = require('twilsock');
|
134
143
|
var operationRetrier = require('@twilio/operation-retrier');
|
144
|
+
var nanoid = require('nanoid');
|
135
145
|
|
136
146
|
const trimSlashes = (url) => url.replace(/(^\/+|\/+$)/g, "");
|
137
|
-
const isMutationConflictResponse = (response) => response.
|
147
|
+
const isMutationConflictResponse = (response) => response.statusCode === 202;
|
148
|
+
class ChannelMetadataNotFoundError extends Error {
|
149
|
+
constructor(message) {
|
150
|
+
super(message);
|
151
|
+
}
|
152
|
+
}
|
138
153
|
class CommandExecutor {
|
139
154
|
constructor(_serviceUrl, _services, _productId) {
|
140
155
|
this._serviceUrl = _serviceUrl;
|
@@ -159,47 +174,93 @@ class CommandExecutor {
|
|
159
174
|
getUrl +=
|
160
175
|
"?" +
|
161
176
|
Object.entries(requestBody)
|
162
|
-
.map((entry) => entry
|
177
|
+
.map((entry) => entry
|
178
|
+
.map((component) => encodeURIComponent(String(component)))
|
179
|
+
.join("="))
|
163
180
|
.join("&");
|
164
181
|
}
|
165
|
-
response = await this._services.transport.
|
182
|
+
response = await this._services.transport.sendRequest(new twilsock.HttpRequest({
|
183
|
+
url: getUrl,
|
184
|
+
headers: finalHeaders,
|
185
|
+
grant: this._productId,
|
186
|
+
}));
|
166
187
|
break;
|
167
188
|
case "post":
|
168
|
-
response = await this._services.transport.
|
189
|
+
response = await this._services.transport.sendRequest(new twilsock.HttpRequest({
|
190
|
+
method: "POST",
|
191
|
+
url: preProcessedUrl,
|
192
|
+
headers: finalHeaders,
|
193
|
+
payload: JSON.stringify(requestBody),
|
194
|
+
grant: this._productId,
|
195
|
+
}));
|
169
196
|
break;
|
170
197
|
case "delete":
|
171
|
-
response = await this._services.transport.
|
198
|
+
response = await this._services.transport.sendRequest(new twilsock.HttpRequest({
|
199
|
+
method: "DELETE",
|
200
|
+
url: preProcessedUrl,
|
201
|
+
headers: finalHeaders,
|
202
|
+
grant: this._productId,
|
203
|
+
}));
|
172
204
|
break;
|
173
205
|
}
|
174
|
-
if (response.status.code < 200 || response.status.code >= 300) {
|
175
|
-
throw new Error(`Request responded with a non-success code ${response.status.code}`);
|
176
|
-
}
|
177
206
|
return response;
|
178
207
|
}
|
179
208
|
async fetchResource(url, requestBody) {
|
180
209
|
const maxAttemptsCount = 6;
|
210
|
+
const retrier = new operationRetrier.AsyncRetrier({
|
211
|
+
min: 50,
|
212
|
+
max: 1600,
|
213
|
+
maxAttemptsCount,
|
214
|
+
});
|
215
|
+
let resolution;
|
181
216
|
try {
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
217
|
+
resolution = await retrier.run(async () => {
|
218
|
+
const response = await this._makeRequest("get", url, requestBody);
|
219
|
+
const payload = JSON.parse(response.payload);
|
220
|
+
if (response.statusCode === 404 && payload.code === 50530) {
|
221
|
+
// No metadata
|
222
|
+
return {
|
223
|
+
type: "noMetadata",
|
224
|
+
};
|
225
|
+
}
|
226
|
+
if (response.statusCode >= 400) {
|
227
|
+
// Retry on other error codes combinations
|
228
|
+
throw new Error(payload.message);
|
229
|
+
}
|
230
|
+
// Success
|
231
|
+
return {
|
232
|
+
type: "success",
|
233
|
+
data: payload,
|
234
|
+
};
|
235
|
+
});
|
236
|
+
}
|
237
|
+
catch (e) {
|
238
|
+
throw new Error(`Fetch resource from "${url}" failed. ${(e === null || e === void 0 ? void 0 : e.message) ? e.message : ""}`);
|
188
239
|
}
|
189
|
-
|
190
|
-
throw new
|
240
|
+
if (resolution.type === "noMetadata") {
|
241
|
+
throw new ChannelMetadataNotFoundError("No metadata found.");
|
191
242
|
}
|
243
|
+
return resolution.data;
|
192
244
|
}
|
193
245
|
async mutateResource(method, url, requestBody) {
|
194
246
|
const result = await this._makeRequest(method, url, requestBody, {
|
195
|
-
"X-Twilio-Mutation-Id":
|
247
|
+
"X-Twilio-Mutation-Id": nanoid.nanoid(),
|
196
248
|
});
|
249
|
+
let parsedPayload = {};
|
250
|
+
try {
|
251
|
+
parsedPayload = JSON.parse(result.payload);
|
252
|
+
}
|
253
|
+
catch (_a) { }
|
197
254
|
if (isMutationConflictResponse(result)) {
|
198
|
-
return await this.fetchResource(
|
255
|
+
return await this.fetchResource(parsedPayload.resource_url);
|
256
|
+
}
|
257
|
+
if (result.statusCode < 200 || result.statusCode >= 300) {
|
258
|
+
throw new Error(`Mutation resulted with a non-success code ${result.statusCode}`);
|
199
259
|
}
|
200
|
-
return
|
260
|
+
return parsedPayload;
|
201
261
|
}
|
202
262
|
}
|
203
263
|
|
264
|
+
exports.ChannelMetadataNotFoundError = ChannelMetadataNotFoundError;
|
204
265
|
exports.CommandExecutor = CommandExecutor;
|
205
266
|
//# sourceMappingURL=command-executor.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"command-executor.js","sources":["../src/command-executor.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"file":"command-executor.js","sources":["../src/command-executor.ts"],"sourcesContent":["import { TwilsockClient, HttpResponse, HttpRequest } from \"twilsock\";\nimport { AsyncRetrier } from \"@twilio/operation-retrier\";\nimport { nanoid } from \"nanoid\";\n\nexport interface CommandExecutorServices {\n transport: TwilsockClient;\n}\n\nconst trimSlashes = (url: string): string => url.replace(/(^\\/+|\\/+$)/g, \"\");\n\nconst isMutationConflictResponse = (response: HttpResponse): boolean =>\n response.statusCode === 202;\n\n/**\n * Reason for why retrier in `CommandExecutor.fetchResource` resolved. If the\n * retrier resolved with type of `\"noMetadata\"`, that means the retrier got\n * preemptively stopped, as there is no point in retrying to receive metadata\n * for a message after it was confirmed to not exist. If the retrier resolved\n * with type `\"success\"`, it means that the retrier resolved with a normal\n * response.\n */\ntype RetrierResolution<T> =\n | {\n type: \"success\";\n data: T;\n }\n | {\n type: \"noMetadata\";\n };\n\nclass ChannelMetadataNotFoundError extends Error {\n public constructor(message: string) {\n super(message);\n }\n}\n\nclass CommandExecutor {\n constructor(\n private _serviceUrl: string,\n private _services: CommandExecutorServices,\n private _productId?: string\n ) {}\n\n private _preProcessUrl(url: string): string {\n const trimmedUrl = trimSlashes(url);\n\n if (/^https?:\\/\\//.test(url)) {\n return trimmedUrl;\n }\n\n return `${trimSlashes(this._serviceUrl)}/${trimmedUrl}`;\n }\n\n private async _makeRequest<Request = void, Response = void>(\n method: \"get\" | \"post\" | \"delete\",\n url: string,\n requestBody?: Request,\n headers?: Record<string, string>\n ): Promise<HttpResponse> {\n const preProcessedUrl = this._preProcessUrl(url);\n const finalHeaders = {\n \"Content-Type\": \"application/json; charset=utf-8\",\n ...(headers || {}),\n };\n let response: HttpResponse;\n\n switch (method) {\n case \"get\":\n let getUrl = preProcessedUrl;\n\n if (requestBody) {\n getUrl +=\n \"?\" +\n Object.entries(requestBody)\n .map((entry) =>\n entry\n .map((component) => encodeURIComponent(String(component)))\n .join(\"=\")\n )\n .join(\"&\");\n }\n\n response = await this._services.transport.sendRequest(\n new HttpRequest({\n url: getUrl,\n headers: finalHeaders,\n grant: this._productId,\n })\n );\n break;\n case \"post\":\n response = await this._services.transport.sendRequest(\n new HttpRequest({\n method: \"POST\",\n url: preProcessedUrl,\n headers: finalHeaders,\n payload: JSON.stringify(requestBody),\n grant: this._productId,\n })\n );\n break;\n case \"delete\":\n response = await this._services.transport.sendRequest(\n new HttpRequest({\n method: \"DELETE\",\n url: preProcessedUrl,\n headers: finalHeaders,\n grant: this._productId,\n })\n );\n break;\n }\n\n return response;\n }\n\n public async fetchResource<Request = void, Response = void>(\n url: string,\n requestBody?: Request\n ): Promise<Response> {\n const maxAttemptsCount = 6;\n const retrier = new AsyncRetrier({\n min: 50,\n max: 1600,\n maxAttemptsCount,\n });\n\n let resolution: RetrierResolution<Response>;\n\n try {\n resolution = await retrier.run<RetrierResolution<Response>>(async () => {\n const response = await this._makeRequest<Request, Response>(\n \"get\",\n url,\n requestBody\n );\n const payload = JSON.parse(response.payload);\n\n if (response.statusCode === 404 && payload.code === 50530) {\n // No metadata\n return {\n type: \"noMetadata\",\n };\n }\n\n if (response.statusCode >= 400) {\n // Retry on other error codes combinations\n throw new Error(payload.message);\n }\n\n // Success\n return {\n type: \"success\",\n data: payload,\n };\n });\n } catch (e) {\n throw new Error(\n `Fetch resource from \"${url}\" failed. ${e?.message ? e.message : \"\"}`\n );\n }\n\n if (resolution.type === \"noMetadata\") {\n throw new ChannelMetadataNotFoundError(\"No metadata found.\");\n }\n\n return resolution.data;\n }\n\n public async mutateResource<Request = void, Response = void>(\n method: \"post\" | \"delete\",\n url: string,\n requestBody?: Request\n ): Promise<Response> {\n const result = await this._makeRequest<Request, Response>(\n method,\n url,\n requestBody,\n {\n \"X-Twilio-Mutation-Id\": nanoid(),\n }\n );\n\n let parsedPayload: any = {};\n try {\n parsedPayload = JSON.parse(result.payload);\n } catch {}\n\n if (isMutationConflictResponse(result)) {\n return await this.fetchResource<undefined, Response>(\n parsedPayload.resource_url\n );\n }\n\n if (result.statusCode < 200 || result.statusCode >= 300) {\n throw new Error(\n `Mutation resulted with a non-success code ${result.statusCode}`\n );\n }\n\n return parsedPayload;\n }\n}\n\nexport { CommandExecutor, ChannelMetad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ACV,MAAM,IAAI,KAAK,CACb,CAAwB,qBAAA,EAAA,GAAG,CAAa,UAAA,EAAA,CAAA,CAAC,KAAA,IAAA,IAAD,CAAC,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAD,CAAC,CAAE,OAAO,IAAG,CAAC,CAAC,OAAO,GAAG,EAAE,CAAE,CAAA,CACtE,CAAC;AACH,SAAA;AAED,QAAA,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY,EAAE;AACpC,YAAA,MAAM,IAAI,4BAA4B,CAAC,oBAAoB,CAAC,CAAC;AAC9D,SAAA;QAED,OAAO,UAAU,CAAC,IAAI,CAAC;KACxB;AAEM,IAAA,MAAM,cAAc,CACzB,MAAyB,EACzB,GAAW,EACX,WAAqB,EAAA;AAErB,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CACpC,MAAM,EACN,GAAG,EACH,WAAW,EACX;YACE,sBAAsB,EAAEC,aAAM,EAAE;AACjC,SAAA,CACF,CAAC;QAEF,IAAI,aAAa,GAAQ,EAAE,CAAC;QAC5B,IAAI;YACF,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,SAAA;AAAC,QAAA,OAAA,EAAA,EAAM,GAAE;AAEV,QAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE;YACtC,OAAO,MAAM,IAAI,CAAC,aAAa,CAC7B,aAAa,CAAC,YAAY,CAC3B,CAAC;AACH,SAAA;QAED,IAAI,MAAM,CAAC,UAAU,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,EAAE;YACvD,MAAM,IAAI,KAAK,CACb,CAAA,0CAAA,EAA6C,MAAM,CAAC,UAAU,CAAE,CAAA,CACjE,CAAC;AACH,SAAA;AAED,QAAA,OAAO,aAAa,CAAC;KACtB;AACF;;;;;"}
|
package/dist/configuration.js
CHANGED
@@ -128,6 +128,15 @@ This software includes platform.js under the following license.
|
|
128
128
|
*/
|
129
129
|
'use strict';
|
130
130
|
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
131
140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
141
|
|
133
142
|
var iso8601Duration = require('iso8601-duration');
|
@@ -142,7 +151,7 @@ const MAXIMUM_ATTEMPTS_COUNT = 3;
|
|
142
151
|
const RETRY_WHEN_THROTTLED = true;
|
143
152
|
class Configuration {
|
144
153
|
constructor(options = {}, configurationResponse, logger) {
|
145
|
-
var _a, _b, _c, _d, _e, _f;
|
154
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
146
155
|
this.typingIndicatorTimeoutDefault = TYPING_TIMEOUT * 1000;
|
147
156
|
const constructorOptions = options.Chat || options.IPMessaging || options || {};
|
148
157
|
this.productId = constructorOptions.productId;
|
@@ -181,7 +190,7 @@ class Configuration {
|
|
181
190
|
try {
|
182
191
|
this.httpCacheInterval = iso8601Duration.toSeconds(iso8601Duration.parse(httpCacheInterval));
|
183
192
|
}
|
184
|
-
catch (
|
193
|
+
catch (_h) {
|
185
194
|
logger.error(`Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`);
|
186
195
|
this.httpCacheInterval = iso8601Duration.toSeconds(iso8601Duration.parse(HTTP_CACHE_LIFETIME));
|
187
196
|
}
|
@@ -189,10 +198,12 @@ class Configuration {
|
|
189
198
|
try {
|
190
199
|
this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(consumptionReportInterval));
|
191
200
|
}
|
192
|
-
catch (
|
201
|
+
catch (_j) {
|
193
202
|
logger.error(`Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`);
|
194
203
|
this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
195
204
|
}
|
205
|
+
this.channelMetadataCacheCapacity =
|
206
|
+
(_g = options.channelMetadataCacheCapacity) !== null && _g !== void 0 ? _g : 100;
|
196
207
|
}
|
197
208
|
}
|
198
209
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { parse as parseDuration, toSeconds } from \"iso8601-duration\";\nimport { Logger } from \"./logger\";\nimport { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { ClientOptions } from \"./client\";\n\nconst TYPING_TIMEOUT = 5;\nconst HTTP_CACHE_LIFETIME = \"PT5S\";\nconst CONSUMPTION_HORIZON_SENDING_INTERVAL = \"PT5S\";\nconst USER_INFOS_TO_SUBSCRIBE = 100;\n\nconst MINIMUM_RETRY_DELAY = 1000;\nconst MAXIMUM_RETRY_DELAY = 4000;\nconst MAXIMUM_ATTEMPTS_COUNT = 3;\nconst RETRY_WHEN_THROTTLED = true;\n\ninterface BackoffConfiguration {\n min: number;\n max: number;\n maxAttemptsCount: number;\n}\n\nclass Configuration {\n public readonly links: {\n myConversations: string;\n conversations: string;\n users: string;\n currentUser: string;\n typing: string;\n mediaService: string;\n mediaSetService: string;\n messagesReceipts: string;\n };\n\n public readonly limits: ConversationLimits;\n\n public readonly productId?: string;\n\n public readonly typingIndicatorTimeoutOverride?: number;\n public readonly typingIndicatorTimeoutDefault: number = TYPING_TIMEOUT * 1000;\n public readonly backoffConfiguration: BackoffConfiguration;\n public readonly retryWhenThrottled: boolean;\n\n public readonly consumptionReportInterval: number;\n public readonly userInfosToSubscribe: number;\n public readonly httpCacheInterval: number;\n public readonly reachabilityEnabled: boolean;\n\n public readonly userIdentity: string;\n public readonly userInfo: string;\n public readonly myConversations: string;\n\n constructor(\n options: ClientOptions = {},\n configurationResponse: ConfigurationResponse,\n logger: Logger\n ) {\n const constructorOptions =\n options.Chat || options.IPMessaging || options || {};\n\n this.productId = constructorOptions.productId;\n\n this.links = {\n myConversations: configurationResponse.links.my_conversations,\n conversations: configurationResponse.links.conversations,\n users: configurationResponse.links.users,\n currentUser: configurationResponse.links.current_user,\n typing: configurationResponse.links.typing,\n mediaService: configurationResponse.links.media_service,\n mediaSetService: configurationResponse.links.media_set_service,\n messagesReceipts: configurationResponse.links.messages_receipts,\n };\n\n this.limits = {\n mediaAttachmentsCountLimit:\n configurationResponse.options.media_attachments_count_limit,\n mediaAttachmentSizeLimitInMb:\n configurationResponse.options.media_attachment_size_limit_in_mb,\n mediaAttachmentsTotalSizeLimitInMb:\n configurationResponse.options.media_attachments_total_size_limit_in_mb,\n emailHistoriesAllowedContentTypes:\n configurationResponse.options.email_histories_allowed_mime_types,\n emailBodiesAllowedContentTypes:\n configurationResponse.options.email_bodies_allowed_mime_types,\n };\n\n this.typingIndicatorTimeoutOverride =\n constructorOptions.typingIndicatorTimeoutOverride;\n this.backoffConfiguration = {\n min: MINIMUM_RETRY_DELAY,\n max: MAXIMUM_RETRY_DELAY,\n maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT,\n ...constructorOptions.backoffConfigOverride,\n };\n this.retryWhenThrottled =\n constructorOptions.retryWhenThrottledOverride !== undefined\n ? constructorOptions.retryWhenThrottledOverride\n : RETRY_WHEN_THROTTLED;\n this.userInfosToSubscribe =\n constructorOptions.userInfosToSubscribeOverride ??\n configurationResponse.options.user_infos_to_subscribe ??\n USER_INFOS_TO_SUBSCRIBE;\n this.reachabilityEnabled =\n configurationResponse.options.reachability_enabled;\n this.userIdentity = configurationResponse.identity;\n this.userInfo = configurationResponse.sync_objects.my_user_info;\n this.myConversations = configurationResponse.sync_objects.my_conversations;\n\n const httpCacheInterval =\n constructorOptions.httpCacheIntervalOverride ??\n configurationResponse.options.http_cache_interval ??\n HTTP_CACHE_LIFETIME;\n\n try {\n this.httpCacheInterval = toSeconds(parseDuration(httpCacheInterval));\n } catch {\n logger.error(\n `Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`\n );\n this.httpCacheInterval = toSeconds(parseDuration(HTTP_CACHE_LIFETIME));\n }\n\n const consumptionReportInterval =\n constructorOptions.consumptionReportIntervalOverride ??\n configurationResponse.options.consumption_report_interval ??\n CONSUMPTION_HORIZON_SENDING_INTERVAL;\n\n try {\n this.consumptionReportInterval = toSeconds(\n parseDuration(consumptionReportInterval)\n );\n } catch {\n logger.error(\n `Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`\n );\n this.consumptionReportInterval = toSeconds(\n parseDuration(CONSUMPTION_HORIZON_SENDING_INTERVAL)\n );\n }\n }\n}\n\nexport { Configuration };\n"],"names":["toSeconds","parseDuration"],"mappings":"
|
1
|
+
{"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { parse as parseDuration, toSeconds } from \"iso8601-duration\";\nimport { Logger } from \"./logger\";\nimport { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { ClientOptions } from \"./client\";\n\nconst TYPING_TIMEOUT = 5;\nconst HTTP_CACHE_LIFETIME = \"PT5S\";\nconst CONSUMPTION_HORIZON_SENDING_INTERVAL = \"PT5S\";\nconst USER_INFOS_TO_SUBSCRIBE = 100;\n\nconst MINIMUM_RETRY_DELAY = 1000;\nconst MAXIMUM_RETRY_DELAY = 4000;\nconst MAXIMUM_ATTEMPTS_COUNT = 3;\nconst RETRY_WHEN_THROTTLED = true;\n\ninterface BackoffConfiguration {\n min: number;\n max: number;\n maxAttemptsCount: number;\n}\n\nclass Configuration {\n public readonly links: {\n myConversations: string;\n conversations: string;\n users: string;\n currentUser: string;\n typing: string;\n mediaService: string;\n mediaSetService: string;\n messagesReceipts: string;\n };\n\n public readonly limits: ConversationLimits;\n\n public readonly productId?: string;\n\n public readonly typingIndicatorTimeoutOverride?: number;\n public readonly typingIndicatorTimeoutDefault: number = TYPING_TIMEOUT * 1000;\n public readonly backoffConfiguration: BackoffConfiguration;\n public readonly retryWhenThrottled: boolean;\n\n public readonly consumptionReportInterval: number;\n public readonly userInfosToSubscribe: number;\n public readonly httpCacheInterval: number;\n public readonly reachabilityEnabled: boolean;\n\n public readonly userIdentity: string;\n public readonly userInfo: string;\n public readonly myConversations: string;\n\n public readonly channelMetadataCacheCapacity: number;\n\n constructor(\n options: ClientOptions = {},\n configurationResponse: ConfigurationResponse,\n logger: Logger\n ) {\n const constructorOptions =\n options.Chat || options.IPMessaging || options || {};\n\n this.productId = constructorOptions.productId;\n\n this.links = {\n myConversations: configurationResponse.links.my_conversations,\n conversations: configurationResponse.links.conversations,\n users: configurationResponse.links.users,\n currentUser: configurationResponse.links.current_user,\n typing: configurationResponse.links.typing,\n mediaService: configurationResponse.links.media_service,\n mediaSetService: configurationResponse.links.media_set_service,\n messagesReceipts: configurationResponse.links.messages_receipts,\n };\n\n this.limits = {\n mediaAttachmentsCountLimit:\n configurationResponse.options.media_attachments_count_limit,\n mediaAttachmentSizeLimitInMb:\n configurationResponse.options.media_attachment_size_limit_in_mb,\n mediaAttachmentsTotalSizeLimitInMb:\n configurationResponse.options.media_attachments_total_size_limit_in_mb,\n emailHistoriesAllowedContentTypes:\n configurationResponse.options.email_histories_allowed_mime_types,\n emailBodiesAllowedContentTypes:\n configurationResponse.options.email_bodies_allowed_mime_types,\n };\n\n this.typingIndicatorTimeoutOverride =\n constructorOptions.typingIndicatorTimeoutOverride;\n this.backoffConfiguration = {\n min: MINIMUM_RETRY_DELAY,\n max: MAXIMUM_RETRY_DELAY,\n maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT,\n ...constructorOptions.backoffConfigOverride,\n };\n this.retryWhenThrottled =\n constructorOptions.retryWhenThrottledOverride !== undefined\n ? constructorOptions.retryWhenThrottledOverride\n : RETRY_WHEN_THROTTLED;\n this.userInfosToSubscribe =\n constructorOptions.userInfosToSubscribeOverride ??\n configurationResponse.options.user_infos_to_subscribe ??\n USER_INFOS_TO_SUBSCRIBE;\n this.reachabilityEnabled =\n configurationResponse.options.reachability_enabled;\n this.userIdentity = configurationResponse.identity;\n this.userInfo = configurationResponse.sync_objects.my_user_info;\n this.myConversations = configurationResponse.sync_objects.my_conversations;\n\n const httpCacheInterval =\n constructorOptions.httpCacheIntervalOverride ??\n configurationResponse.options.http_cache_interval ??\n HTTP_CACHE_LIFETIME;\n\n try {\n this.httpCacheInterval = toSeconds(parseDuration(httpCacheInterval));\n } catch {\n logger.error(\n `Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`\n );\n this.httpCacheInterval = toSeconds(parseDuration(HTTP_CACHE_LIFETIME));\n }\n\n const consumptionReportInterval =\n constructorOptions.consumptionReportIntervalOverride ??\n configurationResponse.options.consumption_report_interval ??\n CONSUMPTION_HORIZON_SENDING_INTERVAL;\n\n try {\n this.consumptionReportInterval = toSeconds(\n parseDuration(consumptionReportInterval)\n );\n } catch {\n logger.error(\n `Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`\n );\n this.consumptionReportInterval = toSeconds(\n parseDuration(CONSUMPTION_HORIZON_SENDING_INTERVAL)\n );\n }\n\n this.channelMetadataCacheCapacity =\n options.channelMetadataCacheCapacity ?? 100;\n }\n}\n\nexport { Configuration };\n"],"names":["toSeconds","parseDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,mBAAmB,GAAG,IA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