Commit 232ff81b authored by Edwise's avatar Edwise 🍷

Merge remote-tracking branch 'refs/remotes/origin/master'

parents 0c911729 b91211ab
No preview for this file type
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.cloud={})}(this,function(t){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function e(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var h=function(){return(h=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function r(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;0<=s;s--)(o=t[s])&&(a=(i<3?o(a):3<i?o(e,r,a):o(e,r))||a);return 3<i&&a&&Object.defineProperty(e,r,a),a}function p(t,a,s,c){return new(s=s||Promise)(function(r,e){function n(t){try{i(c.next(t))}catch(t){e(t)}}function o(t){try{i(c.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?r(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(n,o)}i((c=c.apply(t,a||[])).next())})}function k(r,n){var o,i,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&e[0]?i.return:e[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,e[1])).done)return a;switch(i=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,i=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=n.call(r,s)}catch(t){e=[6,t],i=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function o(){return function(t,e,r){var l=r.value;r.value=function(t){var e,r=t||{},n=r.success,o=void 0===n?null:n,i=r.fail,a=void 0===i?null:i,s=r.complete,c=void 0===s?null:s,u=!c&&!a&&!o;try{e=l.apply(this,arguments)}catch(t){return u?Promise.reject(t):(a&&a(t),void(c&&c(t)))}if(e=e.then?e:Promise.resolve(e),u)return e;e.then(function(t){try{o&&o(t),c&&c(t)}catch(t){throw t}}).catch(function(t){a&&a(t),c&&c(t)})}}}function T(t,e,r){Array.isArray(e)||(e=e.split("."));var n=e.reduce(function(t,e){return t?t[e]:null},t);return r?n||r:n}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var d,a,s=i(function(t,e){var r;t.exports=(r=r||function(l){var r=Object.create||function(t){var e;return n.prototype=t,e=new n,n.prototype=null,e};function n(){}var t={},e=t.lib={},o=e.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),(e.init.prototype=e).$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},p=e.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,o=t.sigBytes;if(this.clamp(),n%4)for(var i=0;i<o;i++){var a=r[i>>>2]>>>24-i%4*8&255;e[n+i>>>2]|=a<<24-(n+i)%4*8}else for(i=0;i<o;i+=4)e[n+i>>>2]=r[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=l.ceil(e/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e,r=[],n=function(e){e=e;var r=987654321,n=4294967295;return function(){var t=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return t/=4294967296,(t+=.5)*(.5<l.random()?1:-1)}},o=0;o<t;o+=4){var i=n(4294967296*(e||l.random()));e=987654071*i(),r.push(4294967296*i()|0)}return new p.init(r,t)}}),i=t.enc={},a=i.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new p.init(r,e/2)}},s=i.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new p.init(r,e)}},c=i.Utf8={stringify:function(t){try{return decodeURIComponent(escape(s.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return s.parse(unescape(encodeURIComponent(t)))}},u=e.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new p.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,r=e.words,n=e.sigBytes,o=this.blockSize,i=n/(4*o),a=(i=t?l.ceil(i):l.max((0|i)-this._minBufferSize,0))*o,s=l.min(4*a,n);if(a){for(var c=0;c<a;c+=o)this._doProcessBlock(r,c);var u=r.splice(0,a);e.sigBytes-=s}return new p.init(u,s)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),d=(e.Hasher=u.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(r){return function(t,e){return new r.init(e).finalize(t)}},_createHmacHelper:function(r){return function(t,e){return new d.HMAC.init(r,e).finalize(t)}}}),t.algo={});return t}(Math),r)}),c=(i(function(t,e){var c;t.exports=(c=s,function(o){var t=c,e=t.lib,r=e.WordArray,n=e.Hasher,i=t.algo,a=[],w=[];!function(){function t(t){for(var e=o.sqrt(t),r=2;r<=e;r++)if(!(t%r))return;return 1}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,n=0;n<64;)t(r)&&(n<8&&(a[n]=e(o.pow(r,.5))),w[n]=e(o.pow(r,1/3)),n++),r++}();var b=[],s=i.SHA256=n.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],a=r[3],s=r[4],c=r[5],u=r[6],l=r[7],p=0;p<64;p++){if(p<16)b[p]=0|t[e+p];else{var d=b[p-15],h=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,f=b[p-2],y=(f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10;b[p]=h+b[p-7]+y+b[p-16]}var v=n&o^n&i^o&i,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),g=l+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&c^~s&u)+w[p]+b[p];l=u,u=c,c=s,s=a+g|0,a=i,i=o,o=n,n=g+(m+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(64+n>>>9<<4)]=o.floor(r/4294967296),e[15+(64+n>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA256=n._createHelper(s),t.HmacSHA256=n._createHmacHelper(s)}(Math),c.SHA256)}),i(function(t,e){var r;t.exports=(r=s,void function(){var t=r.lib.Base,u=r.enc.Utf8;r.algo.HMAC=t.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=u.parse(e));var r=t.blockSize,n=4*r;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,s=i.words,c=0;c<r;c++)a[c]^=1549556828,s[c]^=909522486;o.sigBytes=i.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,r=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(r))}})}())}),i(function(t,e){t.exports=s.HmacSHA256})),u=i(function(t,e){var r;t.exports=(r=s,function(){var c=r.lib.WordArray;r.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp();for(var o=[],i=0;i<r;i+=3)for(var a=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)o.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var o=0;o<r.length;o++)n[r.charCodeAt(o)]=o}var i=r.charAt(64);if(i){var a=t.indexOf(i);-1!==a&&(e=a)}return function(t,e,r){for(var n=[],o=0,i=0;i<e;i++)if(i%4){var a=r[t.charCodeAt(i-1)]<<i%4*2,s=r[t.charCodeAt(i)]>>>6-i%4*2;n[o>>>2]|=(a|s)<<24-o%4*8,o++}return c.create(n,o)}(t,e,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}),l=i(function(t,e){var a;t.exports=(a=s,function(l){var t=a,e=t.lib,r=e.WordArray,n=e.Hasher,o=t.algo,S=[];!function(){for(var t=0;t<64;t++)S[t]=4294967296*l.abs(l.sin(t+1))|0}();var i=o.MD5=n.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,o=t[n];t[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,a=t[e+0],s=t[e+1],c=t[e+2],u=t[e+3],l=t[e+4],p=t[e+5],d=t[e+6],h=t[e+7],f=t[e+8],y=t[e+9],v=t[e+10],m=t[e+11],g=t[e+12],w=t[e+13],b=t[e+14],_=t[e+15],A=i[0],x=i[1],q=i[2],R=i[3];A=k(A,x,q,R,a,7,S[0]),R=k(R,A,x,q,s,12,S[1]),q=k(q,R,A,x,c,17,S[2]),x=k(x,q,R,A,u,22,S[3]),A=k(A,x,q,R,l,7,S[4]),R=k(R,A,x,q,p,12,S[5]),q=k(q,R,A,x,d,17,S[6]),x=k(x,q,R,A,h,22,S[7]),A=k(A,x,q,R,f,7,S[8]),R=k(R,A,x,q,y,12,S[9]),q=k(q,R,A,x,v,17,S[10]),x=k(x,q,R,A,m,22,S[11]),A=k(A,x,q,R,g,7,S[12]),R=k(R,A,x,q,w,12,S[13]),q=k(q,R,A,x,b,17,S[14]),A=T(A,x=k(x,q,R,A,_,22,S[15]),q,R,s,5,S[16]),R=T(R,A,x,q,d,9,S[17]),q=T(q,R,A,x,m,14,S[18]),x=T(x,q,R,A,a,20,S[19]),A=T(A,x,q,R,p,5,S[20]),R=T(R,A,x,q,v,9,S[21]),q=T(q,R,A,x,_,14,S[22]),x=T(x,q,R,A,l,20,S[23]),A=T(A,x,q,R,y,5,S[24]),R=T(R,A,x,q,b,9,S[25]),q=T(q,R,A,x,u,14,S[26]),x=T(x,q,R,A,f,20,S[27]),A=T(A,x,q,R,w,5,S[28]),R=T(R,A,x,q,c,9,S[29]),q=T(q,R,A,x,h,14,S[30]),A=M(A,x=T(x,q,R,A,g,20,S[31]),q,R,p,4,S[32]),R=M(R,A,x,q,f,11,S[33]),q=M(q,R,A,x,m,16,S[34]),x=M(x,q,R,A,b,23,S[35]),A=M(A,x,q,R,s,4,S[36]),R=M(R,A,x,q,l,11,S[37]),q=M(q,R,A,x,h,16,S[38]),x=M(x,q,R,A,v,23,S[39]),A=M(A,x,q,R,w,4,S[40]),R=M(R,A,x,q,a,11,S[41]),q=M(q,R,A,x,u,16,S[42]),x=M(x,q,R,A,d,23,S[43]),A=M(A,x,q,R,y,4,S[44]),R=M(R,A,x,q,g,11,S[45]),q=M(q,R,A,x,_,16,S[46]),A=E(A,x=M(x,q,R,A,c,23,S[47]),q,R,a,6,S[48]),R=E(R,A,x,q,h,10,S[49]),q=E(q,R,A,x,b,15,S[50]),x=E(x,q,R,A,p,21,S[51]),A=E(A,x,q,R,g,6,S[52]),R=E(R,A,x,q,u,10,S[53]),q=E(q,R,A,x,v,15,S[54]),x=E(x,q,R,A,s,21,S[55]),A=E(A,x,q,R,f,6,S[56]),R=E(R,A,x,q,_,10,S[57]),q=E(q,R,A,x,d,15,S[58]),x=E(x,q,R,A,w,21,S[59]),A=E(A,x,q,R,l,6,S[60]),R=E(R,A,x,q,m,10,S[61]),q=E(q,R,A,x,c,15,S[62]),x=E(x,q,R,A,y,21,S[63]),i[0]=i[0]+A|0,i[1]=i[1]+x|0,i[2]=i[2]+q|0,i[3]=i[3]+R|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32;var o=l.floor(r/4294967296),i=r;e[15+(64+n>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),e[14+(64+n>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process();for(var a=this._hash,s=a.words,c=0;c<4;c++){var u=s[c];s[c]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});function k(t,e,r,n,o,i,a){var s=t+(e&r|~e&n)+o+a;return(s<<i|s>>>32-i)+e}function T(t,e,r,n,o,i,a){var s=t+(e&n|r&~n)+o+a;return(s<<i|s>>>32-i)+e}function M(t,e,r,n,o,i,a){var s=t+(e^r^n)+o+a;return(s<<i|s>>>32-i)+e}function E(t,e,r,n,o,i,a){var s=t+(r^(e|~n))+o+a;return(s<<i|s>>>32-i)+e}t.MD5=n._createHelper(i),t.HmacMD5=n._createHmacHelper(i)}(Math),a.MD5)});(a=d=d||{})[a.MTOP=1]="MTOP",a[a.MY=2]="MY",a[a.GATEWAY=3]="GATEWAY";var f,y=(e(v,f=Error),v);function v(){return null!==f&&f.apply(this,arguments)||this}function m(t){this.options=t||{},this.options.dataProxyGatewayUrl=this.options.dataProxyGatewayUrl||this.options.gatewayUrl}var g=(w.prototype.init=function(e,r){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return this.options=h({},e),this.proxy=r,this.tasks=[],this.inited=!0,[4,this.listenNetworkChange()];case 1:return t.sent(),this.flushGatewayRequestQueue(),this.pauseExecTask=!1,[2]}})})},w.prototype.listenNetworkChange=function(){return p(this,void 0,void 0,function(){var e,r=this;return k(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.exec({url:"my.getNetworkType"})];case 1:return e=t.sent(),this.networkType=e.networkType,window.my&&window.my.onNetworkStatusChange&&window.my.onNetworkStatusChange(function(t){t&&t.networkType&&(r.networkType=t.networkType)}),[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}})})},w.getRequestType=function(t){return 0===t.indexOf("mtop.")?d.MTOP:0===t.indexOf("my.")?d.MY:d.GATEWAY},w.prototype.verifyResponse=function(e,r,n){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:if(T(n,"mc-code")||T(e,"errCode")||T(e,"error_response.code"),r.__is_retry_task__)return this.tryThrowError(e,n),[2,e];t.label=1;case 1:return t.trys.push([1,3,,4]),this.tryThrowError(e,n),[2,e];case 2:return[2,t.sent()];case 3:throw t.sent();case 4:return[2]}})})},w.prototype.tryThrowError=function(t,e){var r=T(e,"mc-msg")||T(t,"errMsg")||T(t,"error_response.msg"),n=T(e,"mc-code")||T(t,"errCode")||T(t,"error_response.code");if(n&&"200"!=n){var o=new y(n+":::"+r);throw o.code=n,o.msg=r,o}},w.prototype.sendGatewayRequest=function(n){return p(this,void 0,void 0,function(){var e,r=this;return k(this,function(t){switch(t.label){case 0:return this.pauseExecTask?[2,new Promise(function(t,e){r.tasks.push({detail:n,success:t,fail:e})})]:[3,1];case 1:return n=this.createGatewayRequest(n),[4,this.proxy.apply(h({},n),d.GATEWAY)];case 2:return e=t.sent(),[4,this.verifyResponse(T(e,"data"),n,T(e,"headers"))];case 3:return[2,t.sent()]}})})},w.prototype.flushGatewayRequestQueue=function(o){var i=this;void 0===o&&(o=!1),this.tasks.forEach(function(t){var e=t.detail,r=t.success,n=t.fail;if(o)return n("初始化失败");i.exec(e,d.GATEWAY).then(r).catch(n)}),this.tasks=[]},w.prototype.exec=function(e,r){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:if(r=r||w.getRequestType(e.url),!this.inited)throw new Error("请先调用cloud.init()");return r!==d.GATEWAY?[3,2]:[4,this.sendGatewayRequest(e)];case 1:return[2,t.sent()];case 2:return[4,this.proxy.apply(e,r)];case 3:return[2,t.sent()]}})})},w.prototype.getHttpRequestSign=function(t,e,r,n,o){if(this.options.signSecret){var i=o;delete n["mc-sign"];var a=e+"\n"+u.stringify(l(i))+"\napplication/json\n"+Object.keys(n).filter(function(t){return/^mc-/.test(t)}).sort().map(function(t){return t.toLowerCase()+":"+n[t]}).join("\n")+"\n"+t+(r?"?"+r:"");return u.stringify(c(a,this.options.signSecret))}},w.prototype.createGatewayRequest=function(t){var e=this.options,r=e.sessionKey,n=e.appKey,o=e.requestId,i=e.miniappId,a=e.openId,s=e.unionId,c=e.cloudId;t.method="POST";var u=h(h({},t.headers),{"Content-Type":"application/json","mc-timestamp":""+Date.now(),"mc-session":r});a&&(u["mc-open-id"]=a),c&&(u["mc-cloud-id"]=c),s&&(u["mc-union-id"]=s),n&&(u["mc-appKey"]=n),i&&(u["mc-miniapp-id"]=i),o&&(u["mc-request-id"]=o),t.env&&(u["mc-env"]=t.env),this.networkType&&(u["mc-network"]=this.networkType),u["mc-session"]||delete u["mc-session"],t.rawData=t.rawData||t.data,"object"==typeof t.data&&(t.data=JSON.stringify(t.data));var l=this.getHttpRequestSign(t.url,t.method,"",u,t.data);return h(h({},t),{url:""+t.url,headers:h(h({},u),{sign:l,"eagleeye-traceid":o})})},w);function w(){this.inited=!1,this.pauseExecTask=!1}function b(t,e){this.request=e,this.options=t}new g;var _,A=(e(x,_=b),x.prototype.invoke=function(e,r,n,o){return void 0===n&&(n="main"),p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.fcRequest({fcName:e,handler:n,data:r,options:o})];case 1:return[2,t.sent()]}})})},x.prototype.fcRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"fc",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],x.prototype,"invoke",null),x);function x(){return null!==_&&_.apply(this,arguments)||this}var q,M="mtop.taobao.miniapp.cloud.store.config.v2.get",E="mtop.taobao.miniapp.cloud.store.config.v2.seller.get",O="mtop.taobao.miniapp.cloud.store.file.v2.save",P="mtop.taobao.miniapp.cloud.store.file.v2.seller.save",R="mtop.taobao.miniapp.cloud.store.file.v2.delete",S="mtop.taobao.miniapp.cloud.store.file.v2.seller.delete",I="mtop.taobao.miniapp.cloud.store.file.v2.list",B="mtop.taobao.miniapp.cloud.store.file.v2.seller.list",H="other",C=(e(D,q=b),D.prototype.parseUploadResult=function(t,e){return this.parsePostUploadResult(t,e)},D.prototype.parsePostUploadResult=function(t,e){var r,n,o;try{var i=JSON.parse(e.data);n=i.fileId,r=i.url,o=i.message}catch(t){}return{imageUrl:r,specialId:n,message:o}},D.prototype.uploadFile=function(S){return p(this,void 0,void 0,function(){var e,r,n,o,i,a,s,c,u,l,p,d,h,f,y,v,m,g,w,b,_,A,x,q,R;return k(this,function(t){switch(t.label){case 0:e=S.filePath,r=S.fileType,n=void 0===r?H:r,o=S.fileName,i=void 0===o?"miniappfile":o,a=S.seller,s=void 0!==a&&a,c=S.dirId,t.label=1;case 1:return t.trys.push([1,3,,4]),l=s?E:M,[4,this.storageRequest(l,{newContainer:!0,cloudPath:i,fileType:n,sellerSpace:s,dirId:c})];case 2:return u=t.sent(),[3,4];case 3:throw p=t.sent(),new Error("获取配置错误"+(p.message||p.toString()));case 4:return d=T(u,["data","model",n],{}),h=d.url,f=void 0===h?"":h,y=d.formData,v=void 0===y?null:y,m=d.headers,(g={url:f,fileType:n,header:void 0===m?null:m,formData:v,filePath:e,fileName:"file"}).header&&g.header.Authorization&&(g.formData.Authorization=g.header.Authorization),i&&(g.formData.localFileName=Date.now()+"-"+function(t){if(!t)return"file";var e=t.lastIndexOf("/");return 0<=e?t.substr(e+1):t}(i)),g.header?"image"!==n&&(g.header.origin=g.header.origin||"https://miniapp-cloud.taobao.com",g.header.referer=g.header.referer||"https://miniapp-cloud.taobao.com"):delete g.header,g.formData||delete g.formData,[4,this.storageRequest("my.uploadFile",g)];case 5:if(w=t.sent(),b=this.parseUploadResult(n,w),_=b.imageUrl,A=b.specialId,x=b.message,!A)throw new Error(x||"upload exception:unknown error");return q={fileType:n,specialId:A,url:_,cloudPath:i,sellerSpace:s},[4,this.storageRequest(s?P:O,q)];case 6:if(!T(R=t.sent(),"data.model.fileId"))throw new Error(T(R,["result","msgInfo"],"上传文件失败"));return[2,T(R,"data.model")]}})})},D.prototype.deleteFile=function(c){return p(this,void 0,void 0,function(){var e,r,n,o,i,a,s;return k(this,function(t){switch(t.label){case 0:return e=c.fileId,r=c.fileType,n=void 0===r?H:r,o=c.seller,i=void 0!==o&&o,a=Array.isArray(e)?e:[e],a=JSON.stringify(a),[4,this.storageRequest(i?S:R,{fileType:n,fileIds:a,sellerSpace:i})];case 1:if(T(s=t.sent(),["data","model"]))return[2,!0];throw new Error(T(s,["data","msgInfo"]))}})})},D.prototype.getTempFileURL=function(s){return p(this,void 0,void 0,function(){var e,r,n,o,i,a;return k(this,function(t){switch(t.label){case 0:if(e=s.fileId,r=s.seller,n=void 0!==r&&r,!e)throw new Error("缺少fileId,请检查参数");return o=Array.isArray(e)?e:[e],o=JSON.stringify(o),[4,this.storageRequest(n?B:I,{fileIds:o,sellerSpace:n})];case 1:if(i=t.sent(),a=T(i,["data","model"]))return[2,a];throw new Error(T(i,["data","msgInfo"]))}})})},D.prototype.downloadByFileId=function(l){return p(this,void 0,void 0,function(){var e,r,n,o,i,a,s,c,u;return k(this,function(t){switch(t.label){case 0:if(e=l.fileId,r=l.cache,!e)throw new Error("缺少fileId,请检查参数");return n=Array.isArray(e)?e:[e],[4,this.storageRequest(I,{fileIds:JSON.stringify(n)})];case 1:o=t.sent(),i=T(o,["data","model"])||[],a=[],s=0,t.label=2;case 2:return s<i.length?(c=(i[s]||{}).url,[4,this._downloadByUrl(c,r)]):[3,5];case 3:(u=t.sent())&&a.push(u),t.label=4;case 4:return s++,[3,2];case 5:return[2,a]}})})},D.prototype.storageRequest=function(r,n,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e="test"===this.options.env?"test":"online",(n=n||{}).env=e,[4,this.request.exec({url:r,data:n},o)];case 1:return[2,t.sent()]}})})},D.prototype._downloadByUrl=function(n,o){return p(this,void 0,void 0,function(){var e,r;return k(this,function(t){switch(t.label){case 0:return n?o?[4,this.request.proxy.apply({url:"my.getStorage",data:{key:n}})]:[3,2]:[2,null];case 1:if(e=t.sent().data)return[2,e];t.label=2;case 2:return[4,this.request.exec({url:"my.downloadFile",data:{url:n}})];case 3:return r=t.sent().apFilePath,o?[4,this.request.exec({url:"my.setStorage",data:{key:n,data:r}})]:[3,5];case 4:t.sent(),t.label=5;case 5:return[2,r]}})})},r([o()],D.prototype,"uploadFile",null),r([o()],D.prototype,"deleteFile",null),r([o()],D.prototype,"getTempFileURL",null),r([o()],D.prototype,"downloadByFileId",null),D);function D(){return null!==q&&q.apply(this,arguments)||this}var j=(Object.defineProperty(G.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),G.prototype.aggregate=function(r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return Array.isArray(r)||(r=[r]),e={aggregate_pipelines:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.aggregate",e)];case 1:return[2,t.sent()]}})})},G.prototype.count=function(r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.count",e)];case 1:return[2,t.sent()]}})})},G.prototype.deleteMany=function(r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.remove",e)];case 1:return[2,t.sent()]}})})},G.prototype.find=function(r,n){return void 0===n&&(n={}),p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={displayed_fields:n.projection,order_by:n.sort,skip:n.skip,limit:n.limit,filter:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.get",e)];case 1:return[2,t.sent()]}})})},G.prototype.replaceOne=function(r,n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:r,new_record:n,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.replace",e)];case 1:return[2,t.sent()]}})})},G.prototype.insertOne=function(r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={record:r,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.add",e)];case 1:return[2,t.sent()]}})})},G.prototype.insertMany=function(r){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:if(e={records:r,collection_name:this._coll},!Array.isArray(r))throw new Error("带插入的数据只能为数组");return[4,this._db.dbRequest("miniapp.cloud.db.collection.addMany",e)];case 1:return[2,t.sent()]}})})},G.prototype.updateMany=function(r,n,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={filter:r,action:n,arrayFilters:o,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.collection.update",e)];case 1:return[2,t.sent()]}})})},G.prototype.createIndex=function(r,n,o){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={index_name:r,unique:n,fields:o,collection_name:this._coll},[4,this._db.dbRequest("miniapp.cloud.db.index.create",e)];case 1:return[2,t.sent()]}})})},r([o()],G.prototype,"aggregate",null),r([o()],G.prototype,"count",null),r([o()],G.prototype,"deleteMany",null),r([o()],G.prototype,"find",null),r([o()],G.prototype,"replaceOne",null),r([o()],G.prototype,"insertOne",null),r([o()],G.prototype,"insertMany",null),r([o()],G.prototype,"updateMany",null),r([o()],G.prototype,"createIndex",null),G);function G(t,e){this._db=t,this._coll=e}var U,N=(e(z,U=b),z.prototype.collection=function(t){if(!t)throw new Error("集合名称不能为空");return new j(this,t)},z.prototype.createCollection=function(r,t){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return e={collection_name:r},[4,this.dbRequest("miniapp.cloud.db.collection.create",e)];case 1:return[2,t.sent()]}})})},z.prototype.dbRequest=function(r,n){return p(this,void 0,void 0,function(){var e;return k(this,function(t){switch(t.label){case 0:return"test"!==(e=this.options.env)&&(e="online"),n=h(h({},n),{env:e}),[4,this.request.exec({env:e,url:"db/"+r,data:n},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],z.prototype,"createCollection",null),z);function z(){return null!==U&&U.apply(this,arguments)||this}var W,Y=(e(F,W=b),F.prototype.invoke=function(d){return p(this,void 0,void 0,function(){var e,i,a,s,c,u,l,p;return k(this,function(t){switch(t.label){case 0:return e=d.data,i=d.headers,a=d.authScope,s=d.api,e=e||{},Object.keys(e).forEach(function(t){e[t]="string"==typeof e[t]?e[t]:JSON.stringify(e[t])}),c={apiName:s,httpHeaders:i,data:e},[4,this.topRequest(c)];case 1:if(!T(u=t.sent(),"error_response"))return[2,u];if(l=T(u,"error_response.code"),(p=my&&my.canIUse("qn.cleanToken"))&&!a&&(a="*"),26!=l&&27!=l&&53!=l||!a)return[3,9];t.label=2;case 2:return t.trys.push([2,8,,9]),p?(console.log("call my.qn.cleanToken"),[4,my.qn.cleanToken()]):[3,4];case 3:t.sent(),t.label=4;case 4:return[4,(r=my.authorize,n={scopes:a},r?(n=n||{},new Promise(function(t,e){r.call(o||my,h(h({},n),{success:t,fail:e}))})):Promise.reject("未实现my.api"))];case 5:return[4,t.sent()];case 6:return t.sent(),[4,this.topRequest(c)];case 7:return T(u=t.sent(),"error_response")?[3,9]:[2,u];case 8:return t.sent(),[3,9];case 9:throw new Error(""+JSON.stringify(T(u,"error_response")))}var r,n,o})})},F.prototype.topRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"top",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],F.prototype,"invoke",null),F);function F(){return null!==W&&W.apply(this,arguments)||this}var J,K=(e(L,J=b),L.prototype.invoke=function(o){return p(this,void 0,void 0,function(){var e,r,n;return k(this,function(t){switch(t.label){case 0:return e=o.data,r=o.headers,n=o.api,[4,this.topRequest({apiName:n,httpHeaders:r,data:e})];case 1:return[2,t.sent()]}})})},L.prototype.topRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({url:"process",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],L.prototype,"invoke",null),L);function L(){return null!==J&&J.apply(this,arguments)||this}var Q,V=(e(X,Q=b),X.prototype.invoke=function(i){return p(this,void 0,void 0,function(){var e,r,n,o;return k(this,function(t){switch(t.label){case 0:return e=i.data,r=i.headers,n=i.api,o=i.targetAppKey,[4,this.qimenRequest({apiName:n,httpHeaders:r,targetAppKey:o,data:e})];case 1:return[2,t.sent()]}})})},X.prototype.qimenRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"qimen",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],X.prototype,"invoke",null),X);function X(){return null!==Q&&Q.apply(this,arguments)||this}var $,Z=(e(tt,$=b),tt.prototype.httpRequest=function(s){return p(this,void 0,void 0,function(){var e,r,n,o,i,a;return k(this,function(t){switch(t.label){case 0:return e=s.body,r=s.params,n=s.headers,o=s.path,i=s.method,a=s.exts,[4,this.innerRequest({path:o,headers:n,body:e,queryString:r,method:i,options:a})];case 1:return[2,t.sent()]}})})},tt.prototype.innerRequest=function(e){return p(this,void 0,void 0,function(){return k(this,function(t){switch(t.label){case 0:return[4,this.request.exec({env:this.options.env||"online",url:"cloudHttp",data:e},d.GATEWAY)];case 1:return[2,t.sent()]}})})},r([o()],tt.prototype,"httpRequest",null),tt);function tt(){return null!==$&&$.apply(this,arguments)||this}var et,rt=(e(nt,et=Error),nt.prototype.toString=function(){return(this.code||"")+" "+(this.message||"")},nt);function nt(){return null!==et&&et.apply(this,arguments)||this}var ot,it=(e(at,ot=m),at.getMtopErrorMsg=function(t){var e=new rt;if(!t)return e.code="500",e.message="客户端网络错误,请稍后重试",e;var r,n,o=t.ret&&t.ret[0]&&t.ret[0].split("::");if(t.data=t.data||T(t,["err","data"]),t.data&&t.data.errCode&&(r=t.data.errCode,n=t.data.errMessage||t.data.errMsg),t.data&&t.data.errorCode&&(r=t.data.errorCode),t.data&&t.data.errorMessage&&(n=t.data.errorMessage),t.data&&t.data.errorPage)try{if(my&&my.tb&&my.tb.showErrorView)return my.tb.showErrorView({reason:t.data.errorPage.reason,message:t.data.errorPage.message,action:t.data.errorPage.action,icon:t.data.errorPage.icon}),e;delete t.data.errorPage}catch(t){}return t.data&&t.data.success||o&&"SUCCESS"===o[0]&&!r?void 0:(r=r||(o&&"FAIL_SYS_SESSION_EXPIRED"===o[0]?"904":"500"),n=n||o&&o[1]||"客户端网络错误,请稍后重试",e.code=r,e.message=n,e)},at.GATEWAY_APIS={"db/miniapp.cloud.db.collection.create":"mtop.taobao.dataproxy.collection.create","db/miniapp.cloud.db.index.create":"mtop.taobao.dataproxy.index.create","db/miniapp.cloud.db.collection.aggregate":"mtop.taobao.dataproxy.record.aggregate","db/miniapp.cloud.db.collection.count":"mtop.taobao.dataproxy.record.count","db/miniapp.cloud.db.collection.remove":"mtop.taobao.dataproxy.record.delete","db/miniapp.cloud.db.collection.get":"mtop.taobao.dataproxy.record.select","db/miniapp.cloud.db.collection.replace":"mtop.taobao.dataproxy.record.replace","db/miniapp.cloud.db.collection.add":"mtop.taobao.dataproxy.record.insert","db/miniapp.cloud.db.collection.addMany":"mtop.taobao.dataproxy.record.batch.insert","db/miniapp.cloud.db.collection.update":"mtop.taobao.dataproxy.record.update",fc:"mtop.miniapp.cloud.invoke.fc",top:"mtop.miniapp.cloud.invoke.top",qimen:"mtop.miniapp.cloud.invoke.qimen.cloud",process:"mtop.miniapp.cloud.invoke.process",cloudHttp:"mtop.miniapp.cloud.application.request"},at);function at(){var t=null!==ot&&ot.apply(this,arguments)||this;return t.sendMtop=function(i,a,s){return p(t,void 0,void 0,function(){return k(this,function(t){return console.log("sendMtop",a),[2,new Promise(function(r,n){var e=1;if(1024e3<=a.length){var t=new rt;t.code="500",t.message="本次请求内容过长,请控制在1M以内",n(t)}else{var o=function(){my.sendMtop(h(h({api:i,v:"1.0",data:a,method:"POST",needLogin:!0,sessionOption:"AutoLoginAndManualLogin"},s),{success:function(t){var e=at.getMtopErrorMsg(t);e?n(e):r(t)},fail:function(t){if(console.log("sendMtop error",t),1===t.error_type&&0<e)return--e,o();n(at.getMtopErrorMsg(t))}}))};o()}})]})})},t.invokeMyApi=function(r,n){return p(t,void 0,void 0,function(){return k(this,function(t){return[2,new Promise(function(t,e){return r=r.replace(/^my\./,""),my[r](h(h({},n),{success:t,fail:e}))})]})})},t.sendHttpRequest=function(n,o,i,a){return p(t,void 0,void 0,function(){var e=this;return k(this,function(t){return[2,new Promise(function(r,t){my.httpRequest({url:e.options.gatewayUrl+"/"+n,data:o,dataType:"text",method:a,headers:i,success:function(e){try{r(h(h({},e),{data:JSON.parse(e.data)}))}catch(t){r(h(h({},e),{data:e.data}))}},fail:t})})]})})},t.apply=function(u,l){return p(t,void 0,void 0,function(){var e,r,n,o,i,a,s,c;return k(this,function(t){switch(t.label){case 0:return e=u.url,r=u.data,n=u.headers,o=u.mtopOptions,i=u.method,l!==d.MTOP?[3,2]:[4,this.sendMtop(e,r,o)];case 1:return[2,t.sent()];case 2:return l!==d.GATEWAY?[3,8]:this.options.gatewayUrl?[4,this.sendHttpRequest(e,r,n,i)]:[3,4];case 3:return[2,t.sent()];case 4:return t.trys.push([4,6,,7]),u.rawData&&Object.keys(u.rawData).forEach(function(t){"object"==typeof u.rawData[t]&&(u.rawData[t]=JSON.stringify(u.rawData[t]))}),[4,this.sendMtop(at.GATEWAY_APIS[e],h(h({},u.rawData),{protocols:JSON.stringify(n)}),o)];case 5:return a=t.sent(),(s=a&&a.data||{}).errCode?[2,{headers:{"mc-code":s.errCode,"mc-msg":s.errMessage},data:{}}]:[2,{headers:{"mc-code":200,"mc-msg":"请求成功"},data:T(s,["data"])||{}}];case 6:return(c=t.sent())&&c.code?[2,{headers:{"mc-code":c.code,"mc-msg":c.message}}]:[2,{headers:{"mc-code":500,"mc-msg":c.message||c}}];case 7:return[3,10];case 8:return[4,this.invokeMyApi(e,r)];case 9:return[2,t.sent()];case 10:return[2]}})})},t}var st=(ct.prototype.init=function(i,a){return p(this,void 0,void 0,function(){var r,n,o;return k(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=i.env,r="string"==typeof(e=e||"online")?{database:e,file:e,function:e,message:e}:(e.database=e.database||"online",e.file=e.file||"online",e.function=e.function||"online",e.message=e.message||"online",e),n=new g,this.db=new N({env:r.database},n),this.function=new A({env:r.function},n),this.file=new C({env:r.file},n),this.qimenApi=new V({env:r.database},n),this.topApi=new Y({env:r.database},n),this.processApi=new K({env:r.database},n),this.application=new Z({env:r.database},n),[4,n.init(h({},i),a||new it({gatewayUrl:i.__gatewayUrl}))];case 1:return t.sent(),[2,!0];case 2:return o=t.sent(),console.error("SDK初始化失败 ",o),[3,3];case 3:return[2,!1]}var e})})},ct);function ct(){}var ut=new st;t.Cloud=st,t.default=ut,Object.defineProperty(t,"__esModule",{value:!0})});
{
"_args": [
[
"@tbmp/mp-cloud-sdk@1.4.2",
"/Users/wanghongyuan/hello_canvas/dist"
]
],
"_from": "@tbmp/mp-cloud-sdk@1.4.2",
"_id": "@tbmp/mp-cloud-sdk@1.4.2",
"_inBundle": false,
"_integrity": "sha1-/49BtdDaNJ6H9+f9DDBMPgt/BbQ=",
"_location": "/@tbmp/mp-cloud-sdk",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@tbmp/mp-cloud-sdk@1.4.2",
"name": "@tbmp/mp-cloud-sdk",
"escapedName": "@tbmp%2fmp-cloud-sdk",
"scope": "@tbmp",
"rawSpec": "1.4.2",
"saveSpec": null,
"fetchSpec": "1.4.2"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npm.taobao.org/@tbmp/mp-cloud-sdk/download/@tbmp/mp-cloud-sdk-1.4.2.tgz",
"_spec": "1.4.2",
"_where": "/Users/wanghongyuan/hello_canvas/dist",
"author": "",
"description": "",
"gitHead": "c074f811312aea20c97a289aa9ac785e72de2368",
"license": "ISC",
"main": "index.js",
"name": "@tbmp/mp-cloud-sdk",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"types": "./types/platforms/mp/index.d.ts",
"version": "1.4.2"
}
import { Db } from "./db";
export interface IFindOptions {
/**
* 查询的文档数量限制
*/
limit?: number;
/**
* 跳过的文档数量
*/
skip?: number;
/**
* 排序规则
*/
sort?: object;
/**
* 查询后过滤的字段
*/
projection?: object;
}
export declare class CollectionReference {
/**
* 初始化
*
* @internal
*
* @param db - 数据库的引用
* @param coll - 集合名称
*/
private _db;
private _coll;
constructor(db: Db, coll: string);
/**
* 读取集合名字
*/
readonly name: string;
/**
* 对集合执行聚合查询
* @param pipeline 聚合查询对象
*/
aggregate(pipeline: object | object[]): Promise<any>;
/**
* 获取集合中复合条件的记录数量
* @param filter 过滤条件
*/
count(filter: object): Promise<any>;
/**
* 删除集合中的一批记录
* @param filter 过滤条件
*/
deleteMany(filter: object): Promise<any>;
/**
* 查找集合中符合条件的所有记录
* @param filter 过滤条件
* @param options 查询配置项
*/
find(filter: any, options?: IFindOptions): Promise<any>;
/**
* 替换一条数据
* @param filter 过滤条件
* @param data 新数据
*/
replaceOne(filter: object, data: object): Promise<any>;
/**
* 在集合中添加一条记录
* @param data 带插入的数据
*/
insertOne(data: object): Promise<any>;
/**
* 在集合中添加一批记录
* @param data 待插入的数据,只能为数组
*/
insertMany(data: object[]): Promise<any>;
/**
*
* @param filter 过滤条件
* @param data 更新规则
*
*/
updateMany(filter: object, data: object): Promise<any>;
}
import { CollectionReference } from "./collection";
import { IAsyncInvokeOptions } from "../../shared/types";
import { ICloudService } from "../interface/cloudService";
export declare class Db extends ICloudService {
/**
* 获取集合的引用
*
* @param collName - 集合名称
*/
collection(collName: string): CollectionReference;
/**
* 创建集合
*/
createCollection(name: string, options: {
collName: string;
} & IAsyncInvokeOptions): Promise<any>;
dbRequest(action?: string, params?: any): Promise<any>;
}
import { IAsyncInvokeOptions } from '../../shared/types';
import { ICloudService } from '../interface/cloudService';
export interface ICallFunctionOptions extends IAsyncInvokeOptions {
name: string;
data: any;
}
export interface IInvokeMethod {
(IAsyncInvokeOptions: any): void;
}
export default class CloudFunction extends ICloudService {
invoke(name: string, data?: object, handler?: string): Promise<any>;
private fcRequest;
}
import { Request } from "../../shared/request";
export interface ICloudServiceOptions {
env?: 'test' | 'online' | 'pre';
}
export declare abstract class ICloudService {
options: ICloudServiceOptions;
request: Request;
constructor(options: ICloudServiceOptions, request: Request);
init?(): void;
}
import Powermsg from '@ali/lib-powermsg-sdk';
import { Env } from '../../shared/types';
export default class Client {
env: Env;
pmg: Powermsg;
deviceId: string;
initing: boolean;
queue: (() => void)[];
config: any;
constructor(env: Env);
init: () => Promise<any>;
onMessage: (callback: any) => Promise<() => void>;
private createPwgInstance;
}
import { ICloudService, ICloudServiceOptions } from "../interface/cloudService";
import Client from './client';
import Server from './server';
export default class Message extends ICloudService {
server: Server;
client: Client;
constructor(options: ICloudServiceOptions);
}
import { Request } from '../../shared/request';
import { Env } from "../../../packages/mp-cloud-node-sdk/types/shared/types";
interface IPushOptions {
subType: number;
deviceId?: string;
data: object;
pushType: string;
}
export default class Server {
env: Env;
request: Request;
constructor(env: Env, request: Request);
push(options: IPushOptions): Promise<any>;
}
export {};
import {ICloudService} from "../../interface/cloudService";
export default class Application extends ICloudService {
httpRequest(options: {path: string, params?: any, body?: any, headers?: any, method?: string, exts?: any}): Promise<any>;
}
import {ICloudService} from "../../interface/cloudService";
export default class Process extends ICloudService {
invoke(options: { api: string, data?: any, headers?: any }): Promise<any>;
private topRequest;
}
import {ICloudService} from "../../interface/cloudService";
export default class Qimen extends ICloudService {
invoke(options: { api: string, data?: any, targetAppKey?: any, headers?: any }): Promise<any>;
private topRequest;
}
import {ICloudService} from "../../interface/cloudService";
export default class Top extends ICloudService {
invoke(options: { api: string, data?: any, headers?: any, authScope?: string }): Promise<any>;
private topRequest;
}
import { IAsyncInvokeOptions } from "../../shared/types";
import { ICloudService } from "../interface/cloudService";
export interface IUploadFileOptions extends IAsyncInvokeOptions {
/**
* 选择到的本地文件路径
*/
filePath: string;
/**
* 文件类型, image/audio/video
*/
fileType: FileTypes;
/**
* 云存储文件名可带路径, 如a/xxx.jpg
*/
fileName?: string;
/**
* web环境上传 file对象
*/
file?: any;
}
export interface IDownloadFileOptions extends IAsyncInvokeOptions {
fileType?: FileTypes;
fileId: string;
}
export interface ITempFileURLOptions extends IAsyncInvokeOptions {
fileList: string[];
}
export declare type IDeleteFileOptions = IDownloadFileOptions;
export declare type FileTypes = "image" | "video" | "audio";
export default class CloudStorage extends ICloudService {
private parseUploadResult;
private parsePostUploadResult;
private parseAusUploadResult;
/**
* 文件上传
* 1.获取上传配置
* 2.调用my.api上传
* 3.建立存储关系
* @param options
*/
uploadFile(options: IUploadFileOptions): Promise<any>;
/**
* 删除文件
* @param options
*/
deleteFile(options: IDeleteFileOptions): Promise<boolean>;
/**
* 根据文件id(cloud://)获取授权的url
* @param options
*/
getTempFileURL(options: IAsyncInvokeOptions & {
fileType: string;
fileId: string | string[];
}): Promise<any>;
/**
* 从服务端获取文件并在本地读取
* @param options
*/
readRemoteFile(options: IAsyncInvokeOptions & {
url: string;
}): Promise<ArrayBuffer>;
/**
* 存储的请求代理, 统一sdk环境和存储环境
* @param action
* @param data
* @param requestType
*/
private storageRequest;
}
import { Cloud } from '../mp';
declare const cloudInstance: Cloud;
export default cloudInstance;
import { Cloud as MpCloud } from '../mp';
import { ICloudOptions } from '../../shared/types';
import Client from '../../core/message/client';
import { IProxy } from '../../shared/request';
export declare class Cloud extends MpCloud {
message: {
client: Client;
};
init(options: ICloudOptions, proxy: IProxy): Promise<boolean>;
}
declare const _default: Cloud;
export default _default;
import {IProxy} from '../../shared/request';
import {ICloudOptions} from '../../shared/types';
import CloudFunction from '../../core/functions';
import CloudStorage from '../../core/storage';
import Db from '../../core/db';
import Top from '../../core/openApi/client/top';
import Qimen from '../../core/openApi/client/qimen';
import Process from '../../core/openApi/client/process';
import Application from '../../core/openApi/client/application';
export declare class Cloud {
function: CloudFunction;
file: CloudStorage;
db: Db;
topApi: Top;
qimenApi: Qimen;
processApi: Process;
application: Application;
init(options: ICloudOptions, proxy?: IProxy): Promise<boolean>;
}
declare const _default: Cloud;
export default _default;
import { IProxy, IRequestOptions } from '../../shared/request';
import { ICloudOptions } from '../../shared/types';
import CloudFunction from '../../core/functions';
import Database from '../../core/db';
import Server from '../../core/message/server';
import Top from '../../core/openApi/server/top';
export declare class Cloud {
private _options;
db: Database;
function: CloudFunction;
message: {
server: Server;
};
private request;
topApi: Top;
setEnv(env: any): void;
init(options: ICloudOptions & IRequestOptions, proxy: IProxy): void;
}
export declare function cloud(context: any, options: ICloudOptions): Cloud;
export declare const BASE_APIS: {
GET_SESSION: string;
GET_SECRET: string;
};
export declare const STORAGE_KEYS: {
SECRET: string;
};
export declare const ENV_CONFIG: {
pre: {
gw: string;
};
online: {
gw: string;
};
};
import { IAsyncInvokeOptions } from "./types";
export declare function invokeCallback(options: IAsyncInvokeOptions, asyncTask: Promise<any>): Promise<void>;
export declare function myApiPromisify(method: (options: any) => void, options?: any): Promise<any>;
export declare function getUserId(): Promise<string>;
export declare function noop(): void;
export declare function invokeTaskCallback(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export declare function safeAccess(props: any, keys: string[] | string, def?: any): any;
export declare function getValue(key: string): Promise<any>;
export declare function setValue(key: string, data: any): Promise<any>;
export interface IRequestOptions {
appKey?: string,
sourceAppKey?: string,
requestAppKey?:string,
miniappId?: string,
sourceMiniAppId?: string,
appOwnerOpenId?: string,
signSecret?: string;
sessionKey?: string;
requestId?: string;
cloudId?: string;
openId?: string;
unionId?: string;
userNick?: string,
mixNick?: string,
session?: string;
accessToken?: string;
env?: string;
}
export declare enum RequestTypes {
MTOP = 1,
MY = 2,
GATEWAY = 3
}
export interface IGatewayResponse {
error_response: {
code: string;
};
}
export interface IRequestDetail {
url: string;
data?: any;
rawData?: any;
method?: string;
headers?: any;
dataType?: string;
v?: string;
__is_retry_task__?: boolean;
env?: string;
mtopOptions?: any;
}
export interface IProxyOptions {
gatewayUrl?: string;
dataProxyGatewayUrl?: string;
}
export declare abstract class IProxy {
options: IProxyOptions;
abstract apply(task: IRequestDetail, requestType?: RequestTypes): Promise<any>;
constructor(options?: IProxyOptions);
}
export declare class Request {
networkType?: string;
options: IRequestOptions;
tasks: {
detail: IRequestDetail;
success?: (res: any) => void;
fail?: (res: any) => void;
}[];
proxy: IProxy;
inited: boolean;
pauseExecTask: boolean;
init(options: IRequestOptions, proxy: IProxy): Promise<void>;
listenNetworkChange(): Promise<void>;
static getRequestType(url: string): RequestTypes;
/**
* 验证响应结果, 特定情况下重试请求
* @param res
*/
private verifyResponse;
private tryThrowError;
private sendGatewayRequest;
flushGatewayRequestQueue(reject?: boolean): void;
exec(detail: IRequestDetail, requestType?: RequestTypes): Promise<any>;
/**
*
* @param url 网关请求
* @param method 请求方法
* @param queryString
* @param headers mc_开头的http header
* @param content json body
*/
private getHttpRequestSign;
/**
* 对网关请求签名
* @param detail
*/
private createGatewayRequest;
}
export declare const request: Request;
export interface ICallback {
(res: any): void;
}
export interface IHttpRequestOptions extends IAsyncInvokeOptions {
url: string;
method?: string;
headers?: any;
data?: any;
dataType?: string;
}
export declare type Env = 'test' | 'pre' | 'online';
export declare type Envs = {
database: Env;
file: Env;
function: Env;
message: Env;
};
export interface ICloudOptions {
env?: Env | Envs;
appKey?: string;
}
declare global {
interface Window {
}
var my: {
httpRequest: (options: IHttpRequestOptions) => void;
sendMtop: (options: any) => void;
alert: (options: {
title?: string;
content?: string;
}) => void;
};
var NODE_PLATFORM: boolean;
var SDK_VERSION: string;
}
export interface IAsyncInvokeOptions {
success?: ICallback;
fail?: ICallback;
complete?: ICallback;
}
export declare type AsyncInvokeResult = Promise<any> | void;
export declare type Constructor<T = {}> = new (...args: any[]) => T;
import { IAsyncInvokeOptions, Env, Envs } from "./types";
export declare function noop(): void;
export declare function invokeTaskCallback(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export declare function safeAccess(props: any, keys: string[] | string, def?: any): any;
export declare function invokeCallback(options: IAsyncInvokeOptions, asyncTask: Promise<any>): Promise<void>;
export declare function myApiPromisify(method: (options: any) => void, options?: any): Promise<any>;
export declare function getUserId(): Promise<string>;
export declare function getEnvs(env: Env | Envs): Envs;
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"_from": "fyge-tbmini@^1.3.7",
"_id": "fyge-tbmini@1.3.7",
"_inBundle": false,
"_integrity": "sha1-zp/KWSj+rRCGDOTrfo0BQxQxYqQ=",
"_location": "/fyge-tbmini",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "fyge-tbmini@^1.3.7",
"name": "fyge-tbmini",
"escapedName": "fyge-tbmini",
"rawSpec": "^1.3.7",
"saveSpec": null,
"fetchSpec": "^1.3.7"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npm.taobao.org/fyge-tbmini/download/fyge-tbmini-1.3.7.tgz",
"_shasum": "ce9fca5928fead10860ce4eb7e8d0143143162a4",
"_spec": "fyge-tbmini@^1.3.7",
"_where": "/Users/wanghongyuan/hello_canvas/dist",
"author": {
"name": "MrKwon"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "淘宝小程序canvas渲染引擎",
"devDependencies": {
"dts-bundle": "^0.7.3",
"glob": "^7.1.6",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.25.2",
"rollup-plugin-uglify": "^6.0.3",
"ts-loader": "^4.0.0",
"typescript": "^2.7.2",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.1.0",
"webpack-cli": "^3.3.2"
},
"keywords": [
"淘宝小程序,canvas,webgl"
],
"license": "ISC",
"main": "./build/fyge.min.js",
"name": "fyge-tbmini",
"scripts": {
"build": "webpack",
"declare": "node scripts/declare.js src/index.ts",
"dev": "webpack -w",
"dev1": "rollup -c -m -w",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch"
},
"types": "./build/FYGE.d.ts",
"version": "1.3.7"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment