@twilio/mcs-client 1.0.0-rc.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/builds/browser.js +1344 -523
  2. package/builds/browser.js.map +1 -1
  3. package/builds/lib.d.ts +56 -5
  4. package/builds/lib.js +1319 -523
  5. package/builds/lib.js.map +1 -1
  6. package/builds/twilio-mcs-client.js +10387 -1828
  7. package/builds/twilio-mcs-client.min.js +1 -44
  8. package/dist/_virtual/rng-browser.js +34 -0
  9. package/dist/_virtual/rng-browser.js.map +1 -0
  10. package/dist/cancellable-promise.js +98 -0
  11. package/dist/cancellable-promise.js.map +1 -0
  12. package/dist/client.js +7 -7
  13. package/dist/client.js.map +1 -1
  14. package/dist/index.js +2 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/logger.js +6 -2
  17. package/dist/logger.js.map +1 -1
  18. package/dist/media.js +16 -2
  19. package/dist/media.js.map +1 -1
  20. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  21. package/dist/node_modules/uuid/index.js +44 -0
  22. package/dist/node_modules/uuid/index.js.map +1 -0
  23. package/dist/node_modules/uuid/lib/bytesToUuid.js +60 -0
  24. package/dist/node_modules/uuid/lib/bytesToUuid.js.map +1 -0
  25. package/dist/node_modules/uuid/lib/rng-browser.js +65 -0
  26. package/dist/node_modules/uuid/lib/rng-browser.js.map +1 -0
  27. package/dist/node_modules/uuid/v1.js +146 -0
  28. package/dist/node_modules/uuid/v1.js.map +1 -0
  29. package/dist/node_modules/uuid/v4.js +66 -0
  30. package/dist/node_modules/uuid/v4.js.map +1 -0
  31. package/dist/packages/mcs-client/package.json.js +1 -1
  32. package/dist/services/network.js +4 -4
  33. package/dist/services/network.js.map +1 -1
  34. package/dist/services/transport.js +3 -4
  35. package/dist/services/transport.js.map +1 -1
  36. package/package.json +12 -14
package/builds/lib.d.ts CHANGED
@@ -1,7 +1,46 @@
1
1
  /// <reference types="node" />
2
2
  import * as log from "loglevel";
3
3
  import * as loglevel from "loglevel";
4
- import { CancellablePromise } from "@twilio/shared";
4
+ /**
5
+ * Cancellable promise. Extends the functionality of the native Promise to include the cancel method.
6
+ *
7
+ * Example:
8
+ *
9
+ * ```ts
10
+ *
11
+ * const cancellableFetchPromise = new CancellablePromise(async (resolve, reject, onCancel) => {
12
+ * const request = fetch("https://example.com/");
13
+ *
14
+ * onCancel(() => request.cancel());
15
+ *
16
+ * try {
17
+ * const response = await request;
18
+ * resolve(response);
19
+ * } catch (err) {
20
+ * reject(err);
21
+ * }
22
+ * });
23
+ *
24
+ * cancellableFetchPromise.cancel();
25
+ * ```
26
+ */
27
+ declare class CancellablePromise<T> extends Promise<T> {
28
+ private readonly id;
29
+ private rejectPromise?;
30
+ private static readonly cancellationMap;
31
+ /**
32
+ * Creates a new CancellablePromise.
33
+ * @param executor A callback used to initialize the promise. This callback is passed three arguments:
34
+ * a resolve callback used to resolve the promise with a value or the result of another promise,
35
+ * a reject callback used to reject the promise with a provided reason or error,
36
+ * and an onCancel callback used to define behavior of cancellation.
37
+ */
38
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: string | Error) => void, onCancel: (cancellationFunction: () => void) => void) => void);
39
+ /**
40
+ * Cancels the promise and invokes the cancellation callback if it was defined during instantiation. Cancellation will result in the promise being rejected.
41
+ */
42
+ cancel(): this;
43
+ }
5
44
  type Headers = {
6
45
  [id: string]: string;
7
46
  };
@@ -64,10 +103,18 @@ declare class Network {
64
103
  get(url: string): CancellablePromise<any>;
65
104
  post(url: string, category: MediaCategory | null, media: string | Buffer | Blob | FormData | Record<string, unknown>, contentType?: string, filename?: string): CancellablePromise<any>;
66
105
  }
106
+ type MediaCategory = "media" | "body" | "history";
67
107
  /**
68
- * Media category.
108
+ * @internal
109
+ * A subset of MediaRecord for Conversation-specific purposes.
69
110
  */
70
- type MediaCategory = "media" | "body" | "history";
111
+ interface MediaState {
112
+ sid: string;
113
+ category: MediaCategory;
114
+ filename: string | null;
115
+ contentType: string;
116
+ size: number;
117
+ }
71
118
  interface Links {
72
119
  content: string;
73
120
  content_direct_temporary?: string;
@@ -125,6 +172,11 @@ declare class Media {
125
172
  */
126
173
  getContentUrl(): CancellablePromise<string | null>;
127
174
  private _update;
175
+ /**
176
+ * @internal
177
+ * This payload is compatible with Conversations' media object _state().
178
+ */
179
+ _state(): MediaState;
128
180
  }
129
181
  interface Options$0 {
130
182
  region?: string;
@@ -194,5 +246,4 @@ declare class Client {
194
246
  */
195
247
  mediaSetGetContentUrls(mediaSids: string[]): CancellablePromise<Map<string, string>>;
196
248
  }
197
- export { CancellablePromise } from "@twilio/shared";
198
- export { Client, Client as McsClient, Client as default, Media, Media as McsMedia, MediaCategory, MediaCategory as McsMediaCategory };
249
+ export { CancellablePromise, Client, Client as McsClient, Client as default, Media, Media as McsMedia, MediaCategory, MediaCategory as McsMediaCategory, MediaState, MediaState as McsMediaState };