@twilio/mcs-client 0.6.3-rc.4 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/builds/browser.js
CHANGED
package/builds/lib.js
CHANGED
|
@@ -45,4 +45,4 @@ this.Twilio=this.Twilio||{},this.Twilio.McsClient=function(t){"use strict";var e
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
*/
|
|
48
|
-
Object.defineProperty(ug,"__esModule",{value:!0});var jw=sb.exports,Tw=Rb.exports,Lw=hy.exports,_w=py.exports,Rw=vy.exports,Iw=gy.exports,Pw=by.exports;function Cw(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var Dw=Cw(my.exports),Mw=Cw(jw),Uw=Cw(Tw),Nw=Cw(Lw),Fw=Cw(_w),qw=Cw(Rw),Bw=Cw(Iw),$w=Cw(Pw),Gw=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return{checks:e}};function Ww(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return zw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return zw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function zw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Vw=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Gw((function(t){var r,n=!1,o=[],i=Ww(e);try{for(i.s();!(r=i.n()).done;){var a=r.value;"string"!=typeof a?(n=n||t instanceof a,o.push("an instance of ".concat(a.name))):(n=n||Dw.default(t)===a,o.push("of type ".concat(a)))}}catch(t){i.e(t)}finally{i.f()}return[n,o]}))};function Hw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return Yw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Yw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Yw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Jw(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=$w.default(t);if(e){var o=$w.default(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Bw.default(this,r)}}function Kw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return Xw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Xw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Zw=function(t,e){if(e.length>t.length)throw new Error("Expected at most ".concat(t.length," argument(s), but got ").concat(e.length));for(;e.length<t.length;)e.push(void 0);var r,n=Kw(e.entries());try{for(n.s();!(r=n.n()).done;){var o=Mw.default(r.value,2),i=o[0],a=o[1],u=rx(t[i],a),c=Mw.default(u,4),s=c[0],l=c[1],f=c[2],p=c[3];if(!s)throw new Error("Argument ".concat(i+1," is expected to be ").concat(f).concat(p," but got ").concat(l))}}catch(t){n.e(t)}finally{n.f()}},Qw=function(t){var e,r,n;(["undefined","boolean","number","bigint","string"].includes(Dw.default(t))&&(r="string"==typeof t?'"'.concat(t,'"'):"".concat(t)),"object"===Dw.default(t)&&"Object"!==(null==t||null===(e=t.constructor)||void 0===e?void 0:e.name))&&(r=null===t?"null":"instance of ".concat(null==t||null===(n=t.constructor)||void 0===n?void 0:n.name));return r||(r=Dw.default(t)),r},tx=function(t){var e,r=[],n=Kw(t);try{for(n.s();!(e=n.n()).done;){var o=e.value;r.push(ex(o))}}catch(t){n.e(t)}finally{n.f()}return r},ex=function(t){var e,r=[],n=Kw(Array.isArray(t)?t:[t]);try{for(n.s();!(e=n.n()).done;){var o=e.value;"string"!=typeof o&&"function"!=typeof o?r.push(o):r.push(Vw(o))}}catch(t){n.e(t)}finally{n.f()}return r},rx=function(t,e){var r,n,o=[],i=!1,a=Kw(t);try{for(a.s();!(n=a.n()).done;){var u,c=Kw(n.value.checks);try{for(c.s();!(u=c.n()).done;){var s=(0,u.value)(e),l=Mw.default(s,3),f=l[0],p=l[1],h=l[2];i=i||f,!r&&h&&(r=h),p&&(o=[].concat(Uw.default(o),"string"==typeof p?[p]:Uw.default(p)))}}catch(t){c.e(t)}finally{c.f()}}}catch(t){a.e(t)}finally{a.f()}if(i)return[!0];var d=r||Qw(e),v=o.length-1;return[!1,d,v>0?"".concat(o.slice(0,v).join(", ")," or ").concat(o[v]):o.join(", "),v>1?";":","]};function nx(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return ox(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ox(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ox(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var ix=Gw((function(t){return["string"==typeof t&&t.length>0,"a non-empty string"]})),ax=Gw((function(t){return["number"==typeof t&&Number.isInteger(t)&&t>=0,"a non-negative integer"]})),ux=Gw((function(t){return["object"===Dw.default(t)&&null!==t&&!Array.isArray(t),"a pure object (non-null and non-array)"]}));function cx(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return sx(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return sx(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function sx(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}ug.array=function(t,e){return Gw((function(r){if(!Array.isArray(r))return[!1,"an array of ".concat(t)];var n,o=cx(r.entries());try{for(o.s();!(n=o.n()).done;){var i=Mw.default(n.value,2),a=i[0],u=i[1],c=rx(ex(e),u),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"a valid array of ".concat(t," (index ").concat(a," should be ").concat(p,")"),"malformed array of ".concat(t," (index ").concat(a," is ").concat(f,")")]}}catch(t){o.e(t)}finally{o.f()}return[!0]}))},ug.custom=Gw;var lx=ug.literal=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Gw((function(t){var r,n=!1,o=[],i=Hw(e);try{for(i.s();!(r=i.n()).done;){var a=r.value;n=n||t===a,o.push("string"==typeof a?'"'.concat(a,'"'):"".concat(a))}}catch(t){i.e(t)}finally{i.f()}return[n,o]}))};ug.nonEmptyArray=function(t,e){return Gw((function(r){if(!Array.isArray(r)||r.length<1)return[!1,"a non-empty array of ".concat(t)];var n,o=nx(r.entries());try{for(o.s();!(n=o.n()).done;){var i=Mw.default(n.value,2),a=i[0],u=i[1],c=rx(ex(e),u),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"a valid non-empty array of ".concat(t," (index ").concat(a," should be ").concat(p,")"),"malformed array of ".concat(t," (index ").concat(a," is ").concat(f,")")]}}catch(t){o.e(t)}finally{o.f()}return[!0]}))};var fx=ug.nonEmptyString=ix;ug.nonNegativeInteger=ax,ug.objectSchema=function(t,e){return Gw((function(r){if("object"!==Dw.default(r)||null===r||Array.isArray(r))return[!1,"valid ".concat(t," (should be a pure object)")];for(var n=0,o=Object.entries(e);n<o.length;n++){var i=Mw.default(o[n],2),a=i[0],u=i[1],c=rx(ex(u),r[a]),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"valid ".concat(t,' (key "').concat(a,'" should be ').concat(p,")"),"malformed ".concat(t,' (key "').concat(a,'" is ').concat(f,")")]}return[!0]}))};var px=ug.pureObject=ux;ug.runtimeTypeValidation=Zw,ug.stringifyReceivedType=Qw,ug.type=Vw;var hx,dx=ug.validateConstructorTypes=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t){return function(t){qw.default(r,t);var e=Jw(r);function r(){Fw.default(this,r);for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return Zw(n,o),e.call.apply(e,[this].concat(o))}return Nw.default(r)}(t)}},vx=ug.validateTypes=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t,e,r){if("function"!=typeof r.value)throw new Error("The validateTypes decorator can only be applied to methods");var o=r.value;r.value=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Zw(n,e),o.apply(this,e)}}},yx=ug.validateTypesAsync=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t,e,r){if("function"!=typeof r.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var o=r.value;r.value=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];try{Zw(n,e)}catch(t){return Promise.reject(t)}return o.apply(this,e)}}},gx=bl.scope("");return t.default=(hx=class{constructor(t,e,r){var n,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.options=i,this.options.logLevel=null!==(n=this.options.logLevel)&&void 0!==n?n:"silent",this.config=new ql(t,e,r,this.options),gx.setLevel(this.options.logLevel),this.options.transport=null!==(o=this.options.transport)&&void 0!==o?o:new Dp,this.transport=this.options.transport,this.network=new ag(this.config,this.transport)}updateToken(t){gx.info("updateToken"),this.config.updateToken(t)}get(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(t)),i((()=>a.cancel())),r.prev=2,r.next=5,a;case 5:u=r.sent,n(new Bl(e.config,e.network,u.body)),r.next=12;break;case 9:r.prev=9,r.t0=r.catch(2),o(r.t0);case 12:case"end":return r.stop()}}),r,null,[[2,9]])})));return function(t,e,n){return r.apply(this,arguments)}}())}post(t,e,r,n){var o=this;return new Wc(function(){var i=Vc(Js.mark((function i(a,u,c){var s,l;return Js.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=o.network.post(o.config.mediaUrl,null!=r?r:"media",e,t,n),c((()=>s.cancel())),i.prev=2,i.next=5,s;case 5:l=i.sent,a(new Bl(o.config,o.network,l.body)),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),u(i.t0);case 12:case"end":return i.stop()}}),i,null,[[2,9]])})));return function(t,e,r){return i.apply(this,arguments)}}())}postFormData(t,e){var r=this;return new Wc(function(){var n=Vc(Js.mark((function n(o,i,a){var u,c;return Js.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=r.network.post(r.config.mediaUrl,null!=e?e:"media",t),a((()=>u.cancel())),n.prev=2,n.next=5,u;case 5:c=n.sent,o(new Bl(r.config,r.network,c.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(t,e,r){return n.apply(this,arguments)}}())}mediaSetGet(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u,c,s;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a={command:"get",list:t.map((t=>({media_sid:t})))},u=e.network.post("".concat(e.config.mediaSetUrl),null,a,"application/json"),i((()=>u.cancel())),r.prev=3,r.next=6,u;case 6:c=r.sent,s=c.body.map((t=>{if(200===t.code)return new Bl(e.config,e.network,t.media_record);o("Failed to obtain detailed information about Media items (failed SID ".concat(t.media_record.sid,")"))})),n(s),r.next=14;break;case 11:r.prev=11,r.t0=r.catch(3),o(r.t0);case 14:case"end":return r.stop()}}),r,null,[[3,11]])})));return function(t,e,n){return r.apply(this,arguments)}}())}mediaSetGetContentUrls(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u,c,s;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a={command:"get",list:t.map((t=>({media_sid:t})))},u=e.network.post("".concat(e.config.mediaSetUrl),null,a,"application/json"),i((()=>u.cancel())),r.prev=3,r.next=6,u;case 6:c=r.sent,s=new Map,c.body.forEach((t=>{200===t.code?s.set(t.media_record.sid,t.media_record.links.content_direct_temporary):o("Failed to obtain detailed information about Media items (failed SID ".concat(t.media_record.sid,")"))})),n(s),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(3),o(r.t0);case 15:case"end":return r.stop()}}),r,null,[[3,12]])})));return function(t,e,n){return r.apply(this,arguments)}}())}},r(hx,"version","0.6.3-rc.4"),hx),Ks([vx(fx),Xs("design:type",Function),Xs("design:paramtypes",[String]),Xs("design:returntype",void 0)],t.default.prototype,"updateToken",null),Ks([yx(fx),Xs("design:type",Function),Xs("design:paramtypes",[String]),Xs("design:returntype",Wc)],t.default.prototype,"get",null),t.default=Ks([dx(fx,fx,[fx,lx(null)],[px,"undefined"]),Xs("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=Wc,t.Client=t.default,t.McsClient=t.default,t.McsMedia=Bl,t.Media=Bl,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
48
|
+
Object.defineProperty(ug,"__esModule",{value:!0});var jw=sb.exports,Tw=Rb.exports,Lw=hy.exports,_w=py.exports,Rw=vy.exports,Iw=gy.exports,Pw=by.exports;function Cw(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var Dw=Cw(my.exports),Mw=Cw(jw),Uw=Cw(Tw),Nw=Cw(Lw),Fw=Cw(_w),qw=Cw(Rw),Bw=Cw(Iw),$w=Cw(Pw),Gw=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return{checks:e}};function Ww(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return zw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return zw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function zw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Vw=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Gw((function(t){var r,n=!1,o=[],i=Ww(e);try{for(i.s();!(r=i.n()).done;){var a=r.value;"string"!=typeof a?(n=n||t instanceof a,o.push("an instance of ".concat(a.name))):(n=n||Dw.default(t)===a,o.push("of type ".concat(a)))}}catch(t){i.e(t)}finally{i.f()}return[n,o]}))};function Hw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return Yw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Yw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Yw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Jw(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=$w.default(t);if(e){var o=$w.default(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Bw.default(this,r)}}function Kw(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return Xw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xw(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Xw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Zw=function(t,e){if(e.length>t.length)throw new Error("Expected at most ".concat(t.length," argument(s), but got ").concat(e.length));for(;e.length<t.length;)e.push(void 0);var r,n=Kw(e.entries());try{for(n.s();!(r=n.n()).done;){var o=Mw.default(r.value,2),i=o[0],a=o[1],u=rx(t[i],a),c=Mw.default(u,4),s=c[0],l=c[1],f=c[2],p=c[3];if(!s)throw new Error("Argument ".concat(i+1," is expected to be ").concat(f).concat(p," but got ").concat(l))}}catch(t){n.e(t)}finally{n.f()}},Qw=function(t){var e,r,n;(["undefined","boolean","number","bigint","string"].includes(Dw.default(t))&&(r="string"==typeof t?'"'.concat(t,'"'):"".concat(t)),"object"===Dw.default(t)&&"Object"!==(null==t||null===(e=t.constructor)||void 0===e?void 0:e.name))&&(r=null===t?"null":"instance of ".concat(null==t||null===(n=t.constructor)||void 0===n?void 0:n.name));return r||(r=Dw.default(t)),r},tx=function(t){var e,r=[],n=Kw(t);try{for(n.s();!(e=n.n()).done;){var o=e.value;r.push(ex(o))}}catch(t){n.e(t)}finally{n.f()}return r},ex=function(t){var e,r=[],n=Kw(Array.isArray(t)?t:[t]);try{for(n.s();!(e=n.n()).done;){var o=e.value;"string"!=typeof o&&"function"!=typeof o?r.push(o):r.push(Vw(o))}}catch(t){n.e(t)}finally{n.f()}return r},rx=function(t,e){var r,n,o=[],i=!1,a=Kw(t);try{for(a.s();!(n=a.n()).done;){var u,c=Kw(n.value.checks);try{for(c.s();!(u=c.n()).done;){var s=(0,u.value)(e),l=Mw.default(s,3),f=l[0],p=l[1],h=l[2];i=i||f,!r&&h&&(r=h),p&&(o=[].concat(Uw.default(o),"string"==typeof p?[p]:Uw.default(p)))}}catch(t){c.e(t)}finally{c.f()}}}catch(t){a.e(t)}finally{a.f()}if(i)return[!0];var d=r||Qw(e),v=o.length-1;return[!1,d,v>0?"".concat(o.slice(0,v).join(", ")," or ").concat(o[v]):o.join(", "),v>1?";":","]};function nx(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return ox(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ox(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ox(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var ix=Gw((function(t){return["string"==typeof t&&t.length>0,"a non-empty string"]})),ax=Gw((function(t){return["number"==typeof t&&Number.isInteger(t)&&t>=0,"a non-negative integer"]})),ux=Gw((function(t){return["object"===Dw.default(t)&&null!==t&&!Array.isArray(t),"a pure object (non-null and non-array)"]}));function cx(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return sx(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return sx(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function sx(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}ug.array=function(t,e){return Gw((function(r){if(!Array.isArray(r))return[!1,"an array of ".concat(t)];var n,o=cx(r.entries());try{for(o.s();!(n=o.n()).done;){var i=Mw.default(n.value,2),a=i[0],u=i[1],c=rx(ex(e),u),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"a valid array of ".concat(t," (index ").concat(a," should be ").concat(p,")"),"malformed array of ".concat(t," (index ").concat(a," is ").concat(f,")")]}}catch(t){o.e(t)}finally{o.f()}return[!0]}))},ug.custom=Gw;var lx=ug.literal=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Gw((function(t){var r,n=!1,o=[],i=Hw(e);try{for(i.s();!(r=i.n()).done;){var a=r.value;n=n||t===a,o.push("string"==typeof a?'"'.concat(a,'"'):"".concat(a))}}catch(t){i.e(t)}finally{i.f()}return[n,o]}))};ug.nonEmptyArray=function(t,e){return Gw((function(r){if(!Array.isArray(r)||r.length<1)return[!1,"a non-empty array of ".concat(t)];var n,o=nx(r.entries());try{for(o.s();!(n=o.n()).done;){var i=Mw.default(n.value,2),a=i[0],u=i[1],c=rx(ex(e),u),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"a valid non-empty array of ".concat(t," (index ").concat(a," should be ").concat(p,")"),"malformed array of ".concat(t," (index ").concat(a," is ").concat(f,")")]}}catch(t){o.e(t)}finally{o.f()}return[!0]}))};var fx=ug.nonEmptyString=ix;ug.nonNegativeInteger=ax,ug.objectSchema=function(t,e){return Gw((function(r){if("object"!==Dw.default(r)||null===r||Array.isArray(r))return[!1,"valid ".concat(t," (should be a pure object)")];for(var n=0,o=Object.entries(e);n<o.length;n++){var i=Mw.default(o[n],2),a=i[0],u=i[1],c=rx(ex(u),r[a]),s=Mw.default(c,3),l=s[0],f=s[1],p=s[2];if(!l)return[!1,"valid ".concat(t,' (key "').concat(a,'" should be ').concat(p,")"),"malformed ".concat(t,' (key "').concat(a,'" is ').concat(f,")")]}return[!0]}))};var px=ug.pureObject=ux;ug.runtimeTypeValidation=Zw,ug.stringifyReceivedType=Qw,ug.type=Vw;var hx,dx=ug.validateConstructorTypes=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t){return function(t){qw.default(r,t);var e=Jw(r);function r(){Fw.default(this,r);for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return Zw(n,o),e.call.apply(e,[this].concat(o))}return Nw.default(r)}(t)}},vx=ug.validateTypes=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t,e,r){if("function"!=typeof r.value)throw new Error("The validateTypes decorator can only be applied to methods");var o=r.value;r.value=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return Zw(n,e),o.apply(this,e)}}},yx=ug.validateTypesAsync=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=tx(e);return function(t,e,r){if("function"!=typeof r.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var o=r.value;r.value=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];try{Zw(n,e)}catch(t){return Promise.reject(t)}return o.apply(this,e)}}},gx=bl.scope("");return t.default=(hx=class{constructor(t,e,r){var n,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.options=i,this.options.logLevel=null!==(n=this.options.logLevel)&&void 0!==n?n:"silent",this.config=new ql(t,e,r,this.options),gx.setLevel(this.options.logLevel),this.options.transport=null!==(o=this.options.transport)&&void 0!==o?o:new Dp,this.transport=this.options.transport,this.network=new ag(this.config,this.transport)}updateToken(t){gx.info("updateToken"),this.config.updateToken(t)}get(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(t)),i((()=>a.cancel())),r.prev=2,r.next=5,a;case 5:u=r.sent,n(new Bl(e.config,e.network,u.body)),r.next=12;break;case 9:r.prev=9,r.t0=r.catch(2),o(r.t0);case 12:case"end":return r.stop()}}),r,null,[[2,9]])})));return function(t,e,n){return r.apply(this,arguments)}}())}post(t,e,r,n){var o=this;return new Wc(function(){var i=Vc(Js.mark((function i(a,u,c){var s,l;return Js.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=o.network.post(o.config.mediaUrl,null!=r?r:"media",e,t,n),c((()=>s.cancel())),i.prev=2,i.next=5,s;case 5:l=i.sent,a(new Bl(o.config,o.network,l.body)),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),u(i.t0);case 12:case"end":return i.stop()}}),i,null,[[2,9]])})));return function(t,e,r){return i.apply(this,arguments)}}())}postFormData(t,e){var r=this;return new Wc(function(){var n=Vc(Js.mark((function n(o,i,a){var u,c;return Js.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=r.network.post(r.config.mediaUrl,null!=e?e:"media",t),a((()=>u.cancel())),n.prev=2,n.next=5,u;case 5:c=n.sent,o(new Bl(r.config,r.network,c.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(t,e,r){return n.apply(this,arguments)}}())}mediaSetGet(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u,c,s;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a={command:"get",list:t.map((t=>({media_sid:t})))},u=e.network.post("".concat(e.config.mediaSetUrl),null,a,"application/json"),i((()=>u.cancel())),r.prev=3,r.next=6,u;case 6:c=r.sent,s=c.body.map((t=>{if(200===t.code)return new Bl(e.config,e.network,t.media_record);o("Failed to obtain detailed information about Media items (failed SID ".concat(t.media_record.sid,")"))})),n(s),r.next=14;break;case 11:r.prev=11,r.t0=r.catch(3),o(r.t0);case 14:case"end":return r.stop()}}),r,null,[[3,11]])})));return function(t,e,n){return r.apply(this,arguments)}}())}mediaSetGetContentUrls(t){var e=this;return new Wc(function(){var r=Vc(Js.mark((function r(n,o,i){var a,u,c,s;return Js.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a={command:"get",list:t.map((t=>({media_sid:t})))},u=e.network.post("".concat(e.config.mediaSetUrl),null,a,"application/json"),i((()=>u.cancel())),r.prev=3,r.next=6,u;case 6:c=r.sent,s=new Map,c.body.forEach((t=>{200===t.code?s.set(t.media_record.sid,t.media_record.links.content_direct_temporary):o("Failed to obtain detailed information about Media items (failed SID ".concat(t.media_record.sid,")"))})),n(s),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(3),o(r.t0);case 15:case"end":return r.stop()}}),r,null,[[3,12]])})));return function(t,e,n){return r.apply(this,arguments)}}())}},r(hx,"version","0.6.3"),hx),Ks([vx(fx),Xs("design:type",Function),Xs("design:paramtypes",[String]),Xs("design:returntype",void 0)],t.default.prototype,"updateToken",null),Ks([yx(fx),Xs("design:type",Function),Xs("design:paramtypes",[String]),Xs("design:returntype",Wc)],t.default.prototype,"get",null),t.default=Ks([dx(fx,fx,[fx,lx(null)],[px,"undefined"]),Xs("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=Wc,t.Client=t.default,t.McsClient=t.default,t.McsMedia=Bl,t.Media=Bl,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twilio/mcs-client",
|
|
3
|
-
"version": "0.6.3
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Twilio Media Content Service client library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Twilio",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.17.0",
|
|
37
|
-
"@twilio/declarative-type-validator": "^0.2.3
|
|
38
|
-
"@twilio/operation-retrier": "^4.0.11
|
|
37
|
+
"@twilio/declarative-type-validator": "^0.2.3",
|
|
38
|
+
"@twilio/operation-retrier": "^4.0.11",
|
|
39
39
|
"core-js": "^3.17.3",
|
|
40
40
|
"loglevel": "^1.8.0",
|
|
41
41
|
"xmlhttprequest": "^1.8.0"
|