@cloudbase/js-sdk 2.11.0 → 2.12.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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_model",[],t):"object"==typeof exports?exports.cloudbase_model=t():e.cloudbase_model=t()}("undefined"!=typeof window?window:this,(()=>(()=>{var e={530:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(679),t)},276:function(e,t){!function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(t,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,i)}c((r=r.apply(e,[])).next())}))}function o(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var a=function(e){function n(t,n){var r=e.call(this,t)||this;return r.name="WxCloudSDKError",r.code=null==n?void 0:n.code,r.requestId=null==n?void 0:n.requestId,r.originError=null==n?void 0:n.originError,r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,e),n}(Error);function i(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function c(){try{var e=i();if(!e)return;return"undefined"==typeof wx?i().location.href:e.__wxRoute}catch(e){}}var s=function(e){var t=e.dataSourceName,n=e.methodName,s=e.params,u=e.realMethodName,l=e.callFunction,d=e.envType,f=void 0===d?"prod":d,p=e.mode;return r(void 0,0,void 0,(function(){var e,r,d,h,y,v;return o(this,(function(o){switch(o.label){case 0:e={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:n,params:s,userAgent:(b=i(),(null==b?void 0:b.navigator)?b.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:c(),"x-sdk-version":"1.5.0",envType:f,mode:p}})];case 2:if(r=o.sent(),d=(null===(y=null==r?void 0:r.result)||void 0===y?void 0:y.requestId)||(null==r?void 0:r.requestId)||(null==r?void 0:r.requestID),null==r?void 0:r.result.code)throw new a("【错误】".concat(null==r?void 0:r.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(u,"\n【错误码】").concat(null==r?void 0:r.result.code,"\n【请求ID】").concat(d||"N/A"),{code:null==r?void 0:r.result.code,requestId:d});return e.data=(null===(v=null==r?void 0:r.result)||void 0===v?void 0:v.data)||{},e.requestId=d,[3,4];case 3:throw"WxCloudSDKError"===(h=o.sent()).name?h:(console.log(h),new a("【错误】".concat(h.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(u,"\n 【请求ID】N/A"),{code:"UnknownError",originError:h}));case 4:return[2,e]}var m,b}))}))},u=function(e){var t=e.sql,n=e.params,a=e.config,i=e.callFunction,c=e.unsafe,u=void 0!==c&&c;return r(void 0,0,void 0,(function(){return o(this,(function(e){return[2,s({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:a,parameter:u?"":Object.entries(n||{}).reduce((function(e,t){var n=t[0],r=t[1];if(void 0!==r){var o="OBJECT";switch(typeof r){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(r)?"ARRAY":"OBJECT"}e.push({key:n,type:o,value:"STRING"===o?r:JSON.stringify(r)})}return e}),[])||[]}},callFunction:i,mode:"sdk"})]}))}))},l=function(e){return{$runSQL:function(t,a,i){return r(this,0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,u({sql:t,params:a,config:n(n({},i),{preparedStatements:!0}),callFunction:e})];case 1:return[2,r.sent()]}}))}))},$runSQLRaw:function(t,a){return r(this,0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,u({sql:t,params:[],config:n(n({},a),{preparedStatements:!1}),callFunction:e})];case 1:return[2,r.sent()]}}))}))}}},d={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},f=function(e){var t=l(e);return new Proxy({},{get:function(i,c){if("string"==typeof c)return Object.prototype.hasOwnProperty.call(t,c)?t[c]:function(e,t){return new Proxy({},{get:function(i,c){var u=d[c];if(!u){var l=new Error("不支持的操作: ".concat(c));throw new a(l.message||"Unknown error occurred",{originError:l,code:"NotSupported",requestId:"N/A"})}return function(a){return r(void 0,0,void 0,(function(){var r,i,l,d,f;return o(this,(function(o){switch(o.label){case 0:return r=n(n({},u.defaultParams||{}),a||{}),[4,s({callFunction:t,dataSourceName:e,methodName:u.methodName,realMethodName:c,params:r,envType:null==a?void 0:a.envType})];case 1:return i=o.sent(),l={data:{}},d=u.responseKey,l.data=d?null===(f=null==i?void 0:i.data)||void 0===f?void 0:f[d]:null==i?void 0:i.data,[2,l]}}))}))}}})}(c,e)}})},p={filter:{where:{}},select:{$master:!0}};function h(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var y={get:n(n({},h("get")),{defaultParams:n({},p)}),list:n(n({},h("list")),{defaultParams:n({},p)}),create:h("create"),createMany:h("createMany"),update:n(n({},h("update")),{method:"put"}),updateMany:n(n({},h("updateMany")),{method:"put"}),upsert:h("upsert"),delete:h("delete"),deleteMany:h("deleteMany")},v="Unknown error occurred",m="NotSupported",b=function(e,t,n,r){var o=l(e);return new Proxy({},{get:function(e,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(o,a)?o[a]:g(n,a,t,r)}})},w=function(e,t,n,r,o){return new a("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(n,"\n【错误码】").concat(r,"\n【请求ID】").concat(o),{code:r,requestId:o})},g=function(e,t,i,c){return new Proxy({},{get:function(s,u){if("runSQLTemplate"!==u){var l=y[u];if(!l){var d=new Error("不支持的操作: ".concat(u));throw new a(d.message||v,{originError:d,code:m,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),r(void 0,0,void 0,(function(){var r,c,s,d,f,p,h,y,m,b;return o(this,(function(o){switch(o.label){case 0:r=l.getUrl,c=l.method,s=l.defaultParams,d=void 0===s?{}:s,f=Object.assign({},d,n),p="pre"===f.envType?"pre":"prod",h=[e,p,r(t)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i({url:h,body:JSON.stringify(f),method:c})];case 2:if((y=o.sent()).code)throw w(null==y?void 0:y.message,t,u,null==y?void 0:y.code,null==y?void 0:y.requestId);return"get"===u&&Object.assign(y,{data:null!==(b=y.data.record)&&void 0!==b?b:y.data}),[2,y];case 3:throw m=o.sent(),new a((null==m?void 0:m.message)||v,{originError:m});case 4:return[2]}}))}))}}if(!(null==c?void 0:c.sqlBaseUrl))throw d=new Error("不支持的操作: ".concat(u)),new a(d.message||v,{originError:d,code:m,requestId:"N/A"});return function(e){return r(void 0,0,void 0,(function(){var r,s,l,d,f,p,h,y,m,b,g,O,S,j,_,E;return o(this,(function(o){switch(o.label){case 0:r=e.params,s=e.templateName,l=e.envType,d="pre"===l?"pre":"prod",f=[c.sqlBaseUrl,d,s,"run"].join("/"),p=Object.entries(r||{}).reduce((function(e,t){var n=t[0],r=t[1];if(void 0!==r){var o="OBJECT";switch(typeof r){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(r)?"ARRAY":"OBJECT"}e.push({key:n,type:o,value:"STRING"===o?r:JSON.stringify(r)})}return e}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i({url:f,body:JSON.stringify({parameter:p}),method:"POST"})];case 2:if(h=o.sent(),null===(m=null==h?void 0:h.Response)||void 0===m?void 0:m.Error)throw w(null===(g=null===(b=null==h?void 0:h.Response)||void 0===b?void 0:b.Error)||void 0===g?void 0:g.Message,t,u,null===(S=null===(O=null==h?void 0:h.Response)||void 0===O?void 0:O.Error)||void 0===S?void 0:S.Code,null===(j=null==h?void 0:h.Response)||void 0===j?void 0:j.RequestId);return[2,n(n({},null!==(_=null==h?void 0:h.Response)&&void 0!==_?_:{}),{data:null===(E=null==h?void 0:h.Response)||void 0===E?void 0:E.Data})];case 3:throw y=o.sent(),new a((null==y?void 0:y.message)||v,{originError:y});case 4:return[2]}}))}))}}})};function O(e){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var t=f(e.callFunction.bind(e));return e.models=t,e}var S={init:O,generateHTTPClient:b};e.default=S,e.generateHTTPClient=b,e.init=O,Object.defineProperty(e,"__esModule",{value:!0})}(t)},679:(e,t,n)=>{"use strict";n.r(t),n.d(t,{lazyGetEntity:()=>f,registerModel:()=>v});var r=n(276),o=n(19),a={};for(const e in r)["default","lazyGetEntity","registerModel"].indexOf(e)<0&&(a[e]=()=>r[e]);n.d(t,a);var i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},c=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},s=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},u=o.U3.yE,l="models",d=new WeakMap;function f(e){return new Proxy({},{get:function(t,n){var o=d.get(e);return o||(o=function(e){var t=this,n=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),a=e.getEndPointWithKey("GATEWAY"),u=a.BASE_URL,l=a.PROTOCOL,d="".concat(l).concat(u,"/model"),f="".concat(l).concat(u,"/sql"),p=(0,r.generateHTTPClient)(n,(function(e){return c(t,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,o(i(i({},e),{headers:i({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}}))}))}),d,{sqlBaseUrl:f});return p}(e),d.set(e,o)),o[n]}})}var p="cloudbase_init",h=new u;h.on(p,(function(e){var t=e.data;Object.assign(t,{models:f(t)})}));var y={name:l,namespace:l,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:h,events:[p]}};try{cloudbase.registerComponent(y)}catch(e){}function v(e){try{e.registerComponent(y)}catch(e){console.warn(e)}}},19:(e,t,n)=>{"use strict";n.d(t,{U3:()=>r});var r={};n.r(r),n.d(r,{yE:()=>j});var o="@cloudbase/js-sdk";function a(){return o}var i,c="INVALID_OPERATION",s="OPERATION_FAIL";!function(e){e.local="local",e.none="none",e.session="session"}(i||(i={}));function u(e,t){console.warn("[".concat(a(),"][").concat(e,"]:").concat(t))}var l,d,f=(l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},l(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},p.apply(this,arguments)},h=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},y=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};!function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,a=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=a||["get","post","upload","download"],n}f(t,e),t.prototype.get=function(e){return this.request(p(p({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(p(p({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(p(p({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=e.method,a=e.headers,i=void 0===a?{}:a,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===c?(Object.keys(t).forEach((function(e){s.append(e,t[e])})),s.append("key",r),s.append("file",n),this.request(p(p({},e),{data:s,method:c}),this.restrictedMethods.includes("upload"))):this.request(p(p({},e),{method:"put",headers:i,body:n}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return h(this,void 0,void 0,(function(){var t,n,r,o;return y(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(p(p({},e),{headers:{},responseType:"blob"}))];case 1:return t=a.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return h(this,void 0,void 0,(function(){var n,r,o,a,i,c,s,u,l,d=this;return y(this,(function(f){switch(f.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,a=void 0!==o&&o,i=e.stream,c=void 0!==i&&i,(s=e.signal)&&(s.aborted&&n.abort(),s.addEventListener("abort",(function(){return n.abort()}))),u=null,a&&this.timeout&&(u=setTimeout((function(){console.warn(d.timeoutMsg),n.abort(new Error(d.timeoutMsg))}),this.timeout)),[4,fetch(r,p(p({},e),{signal:n.signal})).then((function(e){return h(d,void 0,void 0,(function(){var t,n,r;return y(this,(function(o){switch(o.label){case 0:return clearTimeout(u),e.ok?(t=e,[3,3]):[3,1];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t]}}))}))})).catch((function(e){return clearTimeout(u),Promise.reject(e)}))];case 1:return l=f.sent(),[2,{data:c?l.body:(null===(t=l.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?l.json():l.text(),statusCode:l.status,header:l.headers}]}}))}))},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var a,i,c,s=e.url,u=e.headers,l=void 0===u?{}:u,d=e.data,f=e.responseType,p=e.withCredentials,h=e.body,y=e.onUploadProgress,v=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach((function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}("https:",s,"get"===r?d:{}),m=new XMLHttpRequest;m.open(r,v),f&&(m.responseType=f),Object.keys(l).forEach((function(e){m.setRequestHeader(e,l[e])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=m.status;try{e.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===f?m.response:m.responseText}clearTimeout(a),o(e)}},t&&n.timeout&&(a=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),c=d,i="[object FormData]"===Object.prototype.toString.call(c)?d:"application/x-www-form-urlencoded"===l["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))})),t.join("&")}(d):h||(d?JSON.stringify(d):void 0),p&&(m.withCredentials=!0),m.send(i)}))}}((function(){})),function(e){e.WEB="web",e.WX_MP="wx_mp"}(d||(d={}));var v=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},b=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},w=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return v(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}((function(){}));!function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,a=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(u("INVALID_PARAMS","localStorage is not supported on current platform"),new w(t.root));case"none":return new w(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=a)}Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:s,msg:"[".concat(a(),"][").concat(s,"]setStore failed"),info:e}))}}else u(c,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return m(this,void 0,void 0,(function(){var r;return b(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}u(c,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return m(this,void 0,void 0,(function(){var r;return b(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):u(c,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return m(this,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var g=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(e,t){this.data=t||null,this.name=e},S=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return g(t,e),t}(O),j=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(e instanceof S)return console.error(e.error),this;var n="string"==typeof e?new O(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,a=this.listeners[r]?function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],this.listeners[r],!0):[];o<a.length;o++)a[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();function _(e){this.message=e}function E(e){this.message=e}new j,"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),_.prototype=new Error,_.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),E.prototype=new Error,E.prototype.name="InvalidTokenError"}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(530)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_model",[],t):"object"==typeof exports?exports.cloudbase_model=t():e.cloudbase_model=t()}("undefined"!=typeof window?window:this,(()=>(()=>{var e={530:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(679),t)},276:function(e,t){!function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(t,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,i)}c((r=r.apply(e,[])).next())}))}function o(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var a=function(e){function n(t,n){var r=e.call(this,t)||this;return r.name="WxCloudSDKError",r.code=null==n?void 0:n.code,r.requestId=null==n?void 0:n.requestId,r.originError=null==n?void 0:n.originError,r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,e),n}(Error);function i(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function c(){try{var e=i();if(!e)return;return"undefined"==typeof wx?i().location.href:e.__wxRoute}catch(e){}}var s=function(e){var t=e.dataSourceName,n=e.methodName,s=e.params,u=e.realMethodName,l=e.callFunction,d=e.envType,f=void 0===d?"prod":d,p=e.mode;return r(void 0,0,void 0,(function(){var e,r,d,h,y,v;return o(this,(function(o){switch(o.label){case 0:e={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:n,params:s,userAgent:(b=i(),(null==b?void 0:b.navigator)?b.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:c(),"x-sdk-version":"1.5.0",envType:f,mode:p}})];case 2:if(r=o.sent(),d=(null===(y=null==r?void 0:r.result)||void 0===y?void 0:y.requestId)||(null==r?void 0:r.requestId)||(null==r?void 0:r.requestID),null==r?void 0:r.result.code)throw new a("【错误】".concat(null==r?void 0:r.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(u,"\n【错误码】").concat(null==r?void 0:r.result.code,"\n【请求ID】").concat(d||"N/A"),{code:null==r?void 0:r.result.code,requestId:d});return e.data=(null===(v=null==r?void 0:r.result)||void 0===v?void 0:v.data)||{},e.requestId=d,[3,4];case 3:throw"WxCloudSDKError"===(h=o.sent()).name?h:(console.log(h),new a("【错误】".concat(h.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(u,"\n 【请求ID】N/A"),{code:"UnknownError",originError:h}));case 4:return[2,e]}var m,b}))}))},u=function(e){var t=e.sql,n=e.params,a=e.config,i=e.callFunction,c=e.unsafe,u=void 0!==c&&c;return r(void 0,0,void 0,(function(){return o(this,(function(e){return[2,s({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:a,parameter:u?"":Object.entries(n||{}).reduce((function(e,t){var n=t[0],r=t[1];if(void 0!==r){var o="OBJECT";switch(typeof r){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(r)?"ARRAY":"OBJECT"}e.push({key:n,type:o,value:"STRING"===o?r:JSON.stringify(r)})}return e}),[])||[]}},callFunction:i,mode:"sdk"})]}))}))},l=function(e){return{$runSQL:function(t,a,i){return r(this,0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,u({sql:t,params:a,config:n(n({},i),{preparedStatements:!0}),callFunction:e})];case 1:return[2,r.sent()]}}))}))},$runSQLRaw:function(t,a){return r(this,0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,u({sql:t,params:[],config:n(n({},a),{preparedStatements:!1}),callFunction:e})];case 1:return[2,r.sent()]}}))}))}}},d={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},f=function(e){var t=l(e);return new Proxy({},{get:function(i,c){if("string"==typeof c)return Object.prototype.hasOwnProperty.call(t,c)?t[c]:function(e,t){return new Proxy({},{get:function(i,c){var u=d[c];if(!u){var l=new Error("不支持的操作: ".concat(c));throw new a(l.message||"Unknown error occurred",{originError:l,code:"NotSupported",requestId:"N/A"})}return function(a){return r(void 0,0,void 0,(function(){var r,i,l,d,f;return o(this,(function(o){switch(o.label){case 0:return r=n(n({},u.defaultParams||{}),a||{}),[4,s({callFunction:t,dataSourceName:e,methodName:u.methodName,realMethodName:c,params:r,envType:null==a?void 0:a.envType})];case 1:return i=o.sent(),l={data:{}},d=u.responseKey,l.data=d?null===(f=null==i?void 0:i.data)||void 0===f?void 0:f[d]:null==i?void 0:i.data,[2,l]}}))}))}}})}(c,e)}})},p={filter:{where:{}},select:{$master:!0}};function h(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var y={get:n(n({},h("get")),{defaultParams:n({},p)}),list:n(n({},h("list")),{defaultParams:n({},p)}),create:h("create"),createMany:h("createMany"),update:n(n({},h("update")),{method:"put"}),updateMany:n(n({},h("updateMany")),{method:"put"}),upsert:h("upsert"),delete:h("delete"),deleteMany:h("deleteMany")},v="Unknown error occurred",m="NotSupported",b=function(e,t,n,r){var o=l(e);return new Proxy({},{get:function(e,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(o,a)?o[a]:g(n,a,t,r)}})},w=function(e,t,n,r,o){return new a("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(n,"\n【错误码】").concat(r,"\n【请求ID】").concat(o),{code:r,requestId:o})},g=function(e,t,i,c){return new Proxy({},{get:function(s,u){if("runSQLTemplate"!==u){var l=y[u];if(!l){var d=new Error("不支持的操作: ".concat(u));throw new a(d.message||v,{originError:d,code:m,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),r(void 0,0,void 0,(function(){var r,c,s,d,f,p,h,y,m,b;return o(this,(function(o){switch(o.label){case 0:r=l.getUrl,c=l.method,s=l.defaultParams,d=void 0===s?{}:s,f=Object.assign({},d,n),p="pre"===f.envType?"pre":"prod",h=[e,p,r(t)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i({url:h,body:JSON.stringify(f),method:c})];case 2:if((y=o.sent()).code)throw w(null==y?void 0:y.message,t,u,null==y?void 0:y.code,null==y?void 0:y.requestId);return"get"===u&&Object.assign(y,{data:null!==(b=y.data.record)&&void 0!==b?b:y.data}),[2,y];case 3:throw m=o.sent(),new a((null==m?void 0:m.message)||v,{originError:m});case 4:return[2]}}))}))}}if(!(null==c?void 0:c.sqlBaseUrl))throw d=new Error("不支持的操作: ".concat(u)),new a(d.message||v,{originError:d,code:m,requestId:"N/A"});return function(e){return r(void 0,0,void 0,(function(){var r,s,l,d,f,p,h,y,m,b,g,O,S,j,_,E;return o(this,(function(o){switch(o.label){case 0:r=e.params,s=e.templateName,l=e.envType,d="pre"===l?"pre":"prod",f=[c.sqlBaseUrl,d,s,"run"].join("/"),p=Object.entries(r||{}).reduce((function(e,t){var n=t[0],r=t[1];if(void 0!==r){var o="OBJECT";switch(typeof r){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(r)?"ARRAY":"OBJECT"}e.push({key:n,type:o,value:"STRING"===o?r:JSON.stringify(r)})}return e}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i({url:f,body:JSON.stringify({parameter:p}),method:"POST"})];case 2:if(h=o.sent(),null===(m=null==h?void 0:h.Response)||void 0===m?void 0:m.Error)throw w(null===(g=null===(b=null==h?void 0:h.Response)||void 0===b?void 0:b.Error)||void 0===g?void 0:g.Message,t,u,null===(S=null===(O=null==h?void 0:h.Response)||void 0===O?void 0:O.Error)||void 0===S?void 0:S.Code,null===(j=null==h?void 0:h.Response)||void 0===j?void 0:j.RequestId);return[2,n(n({},null!==(_=null==h?void 0:h.Response)&&void 0!==_?_:{}),{data:null===(E=null==h?void 0:h.Response)||void 0===E?void 0:E.Data})];case 3:throw y=o.sent(),new a((null==y?void 0:y.message)||v,{originError:y});case 4:return[2]}}))}))}}})};function O(e){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var t=f(e.callFunction.bind(e));return e.models=t,e}var S={init:O,generateHTTPClient:b};e.default=S,e.generateHTTPClient=b,e.init=O,Object.defineProperty(e,"__esModule",{value:!0})}(t)},679:(e,t,n)=>{"use strict";n.r(t),n.d(t,{lazyGetEntity:()=>f,registerModel:()=>v});var r=n(276),o=n(19),a={};for(const e in r)["default","lazyGetEntity","registerModel"].indexOf(e)<0&&(a[e]=()=>r[e]);n.d(t,a);var i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},c=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},s=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},u=o.U3.yE,l="models",d=new WeakMap;function f(e){return new Proxy({},{get:function(t,n){var o=d.get(e);return o||(o=function(e){var t=this,n=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),a=e.getEndPointWithKey("GATEWAY"),u=a.BASE_URL,l=a.PROTOCOL,d="".concat(l).concat(u,"/model"),f="".concat(l).concat(u,"/sql"),p=(0,r.generateHTTPClient)(n,(function(e){return c(t,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,o(i(i({},e),{headers:i({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}}))}))}),d,{sqlBaseUrl:f});return p}(e),d.set(e,o)),o[n]}})}var p="cloudbase_init",h=new u;h.on(p,(function(e){var t=e.data;Object.assign(t,{models:f(t)})}));var y={name:l,namespace:l,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:h,events:[p]}};try{cloudbase.registerComponent(y)}catch(e){}function v(e){try{e.registerComponent(y)}catch(e){console.warn(e)}}},19:(e,t,n)=>{"use strict";n.d(t,{U3:()=>r});var r={};n.r(r),n.d(r,{yE:()=>j});var o="@cloudbase/js-sdk";function a(){return o}var i,c="INVALID_OPERATION",s="OPERATION_FAIL";!function(e){e.local="local",e.none="none",e.session="session"}(i||(i={}));function u(e,t){console.warn("[".concat(a(),"][").concat(e,"]:").concat(t))}var l,d,f=(l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},l(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},p.apply(this,arguments)},h=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},y=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};!function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,a=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=a||["get","post","upload","download"],n}f(t,e),t.prototype.get=function(e){return this.request(p(p({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(p(p({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(p(p({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=e.method,a=e.headers,i=void 0===a?{}:a,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===c?(Object.keys(t).forEach((function(e){s.append(e,t[e])})),s.append("key",r),s.append("file",n),this.request(p(p({},e),{data:s,method:c}),this.restrictedMethods.includes("upload"))):this.request(p(p({},e),{method:"put",headers:i,body:n}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return h(this,void 0,void 0,(function(){var t,n,r,o;return y(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(p(p({},e),{headers:{},responseType:"blob"}))];case 1:return t=a.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return h(this,void 0,void 0,(function(){var n,r,o,a,i,c,s,u,l,d,f,v=this;return y(this,(function(m){switch(m.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,a=void 0!==o&&o,i=e.stream,c=void 0!==i&&i,s=e.signal,u=e.timeout,l=null!=u?u:this.timeout,s&&(s.aborted&&n.abort(),s.addEventListener("abort",(function(){return n.abort()}))),d=null,a&&l&&(d=setTimeout((function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))}),l)),[4,fetch(r,p(p({},e),{signal:n.signal})).then((function(e){return h(v,void 0,void 0,(function(){var t,n,r;return y(this,(function(o){switch(o.label){case 0:return clearTimeout(d),e.ok?(t=e,[3,3]):[3,1];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t]}}))}))})).catch((function(e){return clearTimeout(d),Promise.reject(e)}))];case 1:return f=m.sent(),[2,{data:c?f.body:(null===(t=f.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?f.json():f.text(),statusCode:f.status,header:f.headers}]}}))}))},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var a,i,c,s=e.url,u=e.headers,l=void 0===u?{}:u,d=e.data,f=e.responseType,p=e.withCredentials,h=e.body,y=e.onUploadProgress,v=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach((function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}("https:",s,"get"===r?d:{}),m=new XMLHttpRequest;m.open(r,v),f&&(m.responseType=f),Object.keys(l).forEach((function(e){m.setRequestHeader(e,l[e])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=m.status;try{e.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===f?m.response:m.responseText}clearTimeout(a),o(e)}},t&&n.timeout&&(a=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),c=d,i="[object FormData]"===Object.prototype.toString.call(c)?d:"application/x-www-form-urlencoded"===l["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))})),t.join("&")}(d):h||(d?JSON.stringify(d):void 0),p&&(m.withCredentials=!0),m.send(i)}))}}((function(){})),function(e){e.WEB="web",e.WX_MP="wx_mp"}(d||(d={}));var v=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))},b=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},w=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return v(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}((function(){}));!function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,a=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(u("INVALID_PARAMS","localStorage is not supported on current platform"),new w(t.root));case"none":return new w(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=a)}Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:s,msg:"[".concat(a(),"][").concat(s,"]setStore failed"),info:e}))}}else u(c,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return m(this,void 0,void 0,(function(){var r;return b(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}u(c,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return m(this,void 0,void 0,(function(){var r;return b(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):u(c,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return m(this,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var g=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(e,t){this.data=t||null,this.name=e},S=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return g(t,e),t}(O),j=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(e instanceof S)return console.error(e.error),this;var n="string"==typeof e?new O(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,a=this.listeners[r]?function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],this.listeners[r],!0):[];o<a.length;o++)a[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();function _(e){this.message=e}function E(e){this.message=e}new j,"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),_.prototype=new Error,_.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),E.prototype=new Error,E.prototype.name="InvalidTokenError"}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(530)})()));
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_storage",[],e):"object"==typeof exports?exports.cloudbase_storage=e():t.cloudbase_storage=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={864:(t,e,o)=>{o.r(e),o.d(e,{registerStorage:()=>q});var n="@cloudbase/js-sdk";function r(){return n}var i,s={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};!function(t){t.local="local",t.none="none",t.session="session"}(i||(i={}));function a(t){return"string"==typeof t}function c(t,e){console.warn("[".concat(r(),"][").concat(t,"]:").concat(e))}var u,l,p=(u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},u(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),f=function(){return f=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},f.apply(this,arguments)},d=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},h=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};!function(t){function e(e){var o=t.call(this)||this,n=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return o.timeout=n||0,o.timeoutMsg=r||"请求超时",o.restrictedMethods=i||["get","post","upload","download"],o}p(e,t),e.prototype.get=function(t){return this.request(f(f({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(f(f({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(f(f({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,o=t.file,n=t.name,r=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",o),this.request(f(f({},t),{data:c,method:a}),this.restrictedMethods.includes("upload"))):this.request(f(f({},t),{method:"put",headers:s,body:o}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return d(this,void 0,void 0,(function(){var e,o,n,r;return h(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(f(f({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,o=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=o,r.setAttribute("download",n),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(o),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return d(this,void 0,void 0,(function(){var o,n,r,i,s,a,c,u,l,p=this;return h(this,(function(y){switch(y.label){case 0:return o=new AbortController,n=t.url,r=t.enableAbort,i=void 0!==r&&r,s=t.stream,a=void 0!==s&&s,(c=t.signal)&&(c.aborted&&o.abort(),c.addEventListener("abort",(function(){return o.abort()}))),u=null,i&&this.timeout&&(u=setTimeout((function(){console.warn(p.timeoutMsg),o.abort(new Error(p.timeoutMsg))}),this.timeout)),[4,fetch(n,f(f({},t),{signal:o.signal})).then((function(t){return d(p,void 0,void 0,(function(){var e,o,n;return h(this,(function(r){switch(r.label){case 0:return clearTimeout(u),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(o=Promise).reject,[4,t.json()];case 2:e=n.apply(o,[r.sent()]),r.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(u),Promise.reject(t)}))];case 1:return l=y.sent(),[2,{data:a?l.body:(null===(e=l.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?l.json():l.text(),statusCode:l.status,header:l.headers}]}}))}))},e.prototype.request=function(t,e){var o=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(r){var i,s,a,c=t.url,u=t.headers,l=void 0===u?{}:u,p=t.data,f=t.responseType,d=t.withCredentials,h=t.body,y=t.onUploadProgress,m=function(t,e,o){void 0===o&&(o={});var n=/\?/.test(e),r="";return Object.keys(o).forEach((function(t){""===r?!n&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(o[t]))})),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}("https:",c,"get"===n?p:{}),g=new XMLHttpRequest;g.open(n,m),f&&(g.responseType=f),Object.keys(l).forEach((function(t){g.setRequestHeader(t,l[t])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),o={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),r=e.join(": ");o[n]=r})),t.header=o,t.statusCode=g.status;try{t.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===f?g.response:g.responseText}clearTimeout(i),r(t)}},e&&o.timeout&&(i=setTimeout((function(){console.warn(o.timeoutMsg),g.abort()}),o.timeout)),a=p,s="[object FormData]"===Object.prototype.toString.call(a)?p:"application/x-www-form-urlencoded"===l["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(o){e.push("".concat(o,"=").concat(encodeURIComponent(t[o])))})),e.join("&")}(p):h||(p?JSON.stringify(p):void 0),d&&(g.withCredentials=!0),g.send(s)}))}}((function(){})),function(t){t.WEB="web",t.WX_MP="wx_mp"}(l||(l={}));var y=function(){var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}(),m=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},g=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},b=function(t){function e(e){var o=t.call(this)||this;return o.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),o}return y(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}((function(){}));!function(){function t(t){this.keys={};var e=t.persistence,o=t.platformInfo,n=void 0===o?{}:o,r=t.keys,i=void 0===r?{}:r;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(c(s.INVALID_PARAMS,"localStorage is not supported on current platform"),new b(e.root));case"none":return new b(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,o){if("async"!==this.mode){if(this.storage)try{var n={version:o||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:s.OPERATION_FAIL,msg:"[".concat(r(),"][").concat(s.OPERATION_FAIL,"]setStore failed"),info:t}))}}else c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,o){return m(this,void 0,void 0,(function(){var n;return g(this,(function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),n={version:o||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var o;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(o=process.env)||void 0===o?void 0:o.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var o;return m(this,void 0,void 0,(function(){var n;return g(this,(function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(o=process.env)||void 0===o?void 0:o.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=r.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return m(this,void 0,void 0,(function(){return g(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var v=function(){var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}(),w=function(t,e){this.data=e||null,this.name=t},O=function(t){function e(e,o){var n=t.call(this,"error",{error:e,data:o})||this;return n.error=e,n}return v(e,t),e}(w);function I(t){this.message=t}function A(t){this.message=t}new(function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,o){o[t]=o[t]||[],o[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,o){if(null==o?void 0:o[t]){var n=o[t].indexOf(e);-1!==n&&o[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof O)return console.error(t.error),this;var o=a(t)?new w(t,e||{}):t,n=o.name;if(this.listens(n)){o.target=this;for(var r=0,i=this.listeners[n]?function(t,e,o){if(o||2===arguments.length)for(var n,r=0,i=e.length;r<i;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];r<i.length;r++)i[r].call(this,o)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}()),"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),I.prototype=new Error,I.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),A.prototype=new Error,A.prototype.name="InvalidTokenError";var _,S=function(){return S=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},S.apply(this,arguments)},R=function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s},j=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},N=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},P=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};!function(t){t.put="put",t.post="post"}(_||(_={}));var L=r,F=s,E="https://support.qq.com/products/148793",T=function(t){return"[object Array]"===Object.prototype.toString.call(t)},x=a,C=function(t,e,o){if(void 0===o&&(o=null),t&&"function"==typeof t)return t(e,o);if(e)throw e;return o},M=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,o){}},U="storage",k=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a,c,u,l,p,f,d,h,y,m,g,b,v,w,O,I,A,R,j,N;return P(this,(function(P){switch(P.label){case 0:if(o=t.cloudPath,n=t.filePath,r=t.onUploadProgress,i=t.method,s=void 0===i?"put":i,a=t.headers,c=void 0===a?{}:a,!x(o)||!n)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".uploadFile] invalid params")}));return u={put:_.put,post:_.post}[s.toLocaleLowerCase()]||_.put,l=this.request,p={path:o,method:u},u===_.put&&(p.headers=c),[4,l.send("storage.getUploadMetadata",p)];case 1:return f=P.sent(),d=f.data,h=d.url,y=d.authorization,m=d.token,g=d.fileId,b=d.cosFileId,v=d.download_url,w=f.requestId,I=S(S({},O={url:h,file:n,name:o,onUploadProgress:r}),{method:_.put,headers:S(S({},c),{authorization:y,"x-cos-meta-fileid":b,"x-cos-security-token":m})}),A=S(S({},O),{method:_.post,data:{key:o,signature:y,"x-cos-meta-fileid":b,success_action_status:"201","x-cos-security-token":m}}),(N={})[_.put]={params:I,isSuccess:function(t){return t>=200&&t<300}},N[_.post]={params:A,isSuccess:function(t){return 201===t}},R=N,[4,l.upload(R[u].params)];case 2:return j=P.sent(),R[u].isSuccess(j.statusCode)?[2,C(e,null,{fileID:g,download_url:v,requestId:w})]:[2,C(e,new Error("[".concat(L(),"][").concat(F.OPERATION_FAIL,"][").concat(U,"]:").concat(j.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s;return P(this,(function(a){switch(a.label){case 0:if(o=t.cloudPath,!x(o))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getUploadMetadata] invalid cloudPath")}));n=this.request,r="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.send(r,{path:o})];case 2:return i=a.sent(),[2,C(e,null,i)];case 3:return s=a.sent(),[2,C(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(!(o=t.fileList)||!T(o)||0===o.length)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".deleteFile] fileList must not be empty")}));for(n=0,r=o;n<r.length;n++)if(!(i=r[n])||!x(i))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:o})];case 1:return(s=c.sent()).code?[2,C(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,C(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(!(o=t.fileList)||!T(o)||0===o.length)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] fileList must not be empty")}));for(n=[],r=0,i=o;r<i.length;r++)if(s=i[r],u=s,"[object Object]"===Object.prototype.toString.call(u)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] file info must include fileID and maxAge")}));n.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!x(s))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:n})];case 1:return(a=c.sent()).code?[2,C(e,null,a)]:[2,C(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}var u}))}))},t.prototype.downloadFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(o=t.fileID,!x(o))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:o,maxAge:600}]})];case 1:return n=c.sent(),"SUCCESS"!==(r=n.fileList[0]).code?[2,C(e,r)]:(i=this.request,s=encodeURI(r.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,C(e,null,a)]}}))}))},R([M({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"uploadFile",null),R([M({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),R([M({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"deleteFile",null),R([M({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"getTempFileURL",null),R([M({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),D={name:U,entity:{uploadFile:k.uploadFile,deleteFile:k.deleteFile,getTempFileURL:k.getTempFileURL,downloadFile:k.downloadFile,getUploadMetadata:k.getUploadMetadata}};try{cloudbase.registerComponent(D)}catch(I){}function q(t){try{t.registerComponent(D)}catch(t){console.warn(t)}}}},e={};function o(n){var r=e[n];if(void 0!==r)return r.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,o),i.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=void 0;var e=o(864);t.registerStorage=e.registerStorage})(),n})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_storage",[],e):"object"==typeof exports?exports.cloudbase_storage=e():t.cloudbase_storage=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={864:(t,e,o)=>{o.r(e),o.d(e,{registerStorage:()=>q});var n="@cloudbase/js-sdk";function r(){return n}var i,s={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};!function(t){t.local="local",t.none="none",t.session="session"}(i||(i={}));function a(t){return"string"==typeof t}function c(t,e){console.warn("[".concat(r(),"][").concat(t,"]:").concat(e))}var u,l,p=(u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},u(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),f=function(){return f=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},f.apply(this,arguments)},d=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},h=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};!function(t){function e(e){var o=t.call(this)||this,n=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return o.timeout=n||0,o.timeoutMsg=r||"请求超时",o.restrictedMethods=i||["get","post","upload","download"],o}p(e,t),e.prototype.get=function(t){return this.request(f(f({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(f(f({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(f(f({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,o=t.file,n=t.name,r=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",o),this.request(f(f({},t),{data:c,method:a}),this.restrictedMethods.includes("upload"))):this.request(f(f({},t),{method:"put",headers:s,body:o}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return d(this,void 0,void 0,(function(){var e,o,n,r;return h(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(f(f({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,o=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=o,r.setAttribute("download",n),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(o),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return d(this,void 0,void 0,(function(){var o,n,r,i,s,a,c,u,l,p,y,m=this;return h(this,(function(g){switch(g.label){case 0:return o=new AbortController,n=t.url,r=t.enableAbort,i=void 0!==r&&r,s=t.stream,a=void 0!==s&&s,c=t.signal,u=t.timeout,l=null!=u?u:this.timeout,c&&(c.aborted&&o.abort(),c.addEventListener("abort",(function(){return o.abort()}))),p=null,i&&l&&(p=setTimeout((function(){console.warn(m.timeoutMsg),o.abort(new Error(m.timeoutMsg))}),l)),[4,fetch(n,f(f({},t),{signal:o.signal})).then((function(t){return d(m,void 0,void 0,(function(){var e,o,n;return h(this,(function(r){switch(r.label){case 0:return clearTimeout(p),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(o=Promise).reject,[4,t.json()];case 2:e=n.apply(o,[r.sent()]),r.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(p),Promise.reject(t)}))];case 1:return y=g.sent(),[2,{data:a?y.body:(null===(e=y.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers}]}}))}))},e.prototype.request=function(t,e){var o=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(r){var i,s,a,c=t.url,u=t.headers,l=void 0===u?{}:u,p=t.data,f=t.responseType,d=t.withCredentials,h=t.body,y=t.onUploadProgress,m=function(t,e,o){void 0===o&&(o={});var n=/\?/.test(e),r="";return Object.keys(o).forEach((function(t){""===r?!n&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(o[t]))})),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}("https:",c,"get"===n?p:{}),g=new XMLHttpRequest;g.open(n,m),f&&(g.responseType=f),Object.keys(l).forEach((function(t){g.setRequestHeader(t,l[t])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),o={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),r=e.join(": ");o[n]=r})),t.header=o,t.statusCode=g.status;try{t.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===f?g.response:g.responseText}clearTimeout(i),r(t)}},e&&o.timeout&&(i=setTimeout((function(){console.warn(o.timeoutMsg),g.abort()}),o.timeout)),a=p,s="[object FormData]"===Object.prototype.toString.call(a)?p:"application/x-www-form-urlencoded"===l["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(o){e.push("".concat(o,"=").concat(encodeURIComponent(t[o])))})),e.join("&")}(p):h||(p?JSON.stringify(p):void 0),d&&(g.withCredentials=!0),g.send(s)}))}}((function(){})),function(t){t.WEB="web",t.WX_MP="wx_mp"}(l||(l={}));var y=function(){var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}(),m=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},g=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},b=function(t){function e(e){var o=t.call(this)||this;return o.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),o}return y(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}((function(){}));!function(){function t(t){this.keys={};var e=t.persistence,o=t.platformInfo,n=void 0===o?{}:o,r=t.keys,i=void 0===r?{}:r;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(c(s.INVALID_PARAMS,"localStorage is not supported on current platform"),new b(e.root));case"none":return new b(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,o){if("async"!==this.mode){if(this.storage)try{var n={version:o||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:s.OPERATION_FAIL,msg:"[".concat(r(),"][").concat(s.OPERATION_FAIL,"]setStore failed"),info:t}))}}else c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,o){return m(this,void 0,void 0,(function(){var n;return g(this,(function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),n={version:o||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var o;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(o=process.env)||void 0===o?void 0:o.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var o;return m(this,void 0,void 0,(function(){var n;return g(this,(function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(o=process.env)||void 0===o?void 0:o.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=r.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):c(s.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return m(this,void 0,void 0,(function(){return g(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var v=function(){var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}(),w=function(t,e){this.data=e||null,this.name=t},O=function(t){function e(e,o){var n=t.call(this,"error",{error:e,data:o})||this;return n.error=e,n}return v(e,t),e}(w);function I(t){this.message=t}function A(t){this.message=t}new(function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,o){o[t]=o[t]||[],o[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,o){if(null==o?void 0:o[t]){var n=o[t].indexOf(e);-1!==n&&o[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof O)return console.error(t.error),this;var o=a(t)?new w(t,e||{}):t,n=o.name;if(this.listens(n)){o.target=this;for(var r=0,i=this.listeners[n]?function(t,e,o){if(o||2===arguments.length)for(var n,r=0,i=e.length;r<i;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];r<i.length;r++)i[r].call(this,o)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}()),"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),I.prototype=new Error,I.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),A.prototype=new Error,A.prototype.name="InvalidTokenError";var _,S=function(){return S=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},S.apply(this,arguments)},R=function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s},j=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},N=function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},P=function(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};!function(t){t.put="put",t.post="post"}(_||(_={}));var L=r,F=s,E="https://support.qq.com/products/148793",T=function(t){return"[object Array]"===Object.prototype.toString.call(t)},x=a,C=function(t,e,o){if(void 0===o&&(o=null),t&&"function"==typeof t)return t(e,o);if(e)throw e;return o},M=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,o){}},U="storage",k=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a,c,u,l,p,f,d,h,y,m,g,b,v,w,O,I,A,R,j,N;return P(this,(function(P){switch(P.label){case 0:if(o=t.cloudPath,n=t.filePath,r=t.onUploadProgress,i=t.method,s=void 0===i?"put":i,a=t.headers,c=void 0===a?{}:a,!x(o)||!n)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".uploadFile] invalid params")}));return u={put:_.put,post:_.post}[s.toLocaleLowerCase()]||_.put,l=this.request,p={path:o,method:u},u===_.put&&(p.headers=c),[4,l.send("storage.getUploadMetadata",p)];case 1:return f=P.sent(),d=f.data,h=d.url,y=d.authorization,m=d.token,g=d.fileId,b=d.cosFileId,v=d.download_url,w=f.requestId,I=S(S({},O={url:h,file:n,name:o,onUploadProgress:r}),{method:_.put,headers:S(S({},c),{authorization:y,"x-cos-meta-fileid":b,"x-cos-security-token":m})}),A=S(S({},O),{method:_.post,data:{key:o,signature:y,"x-cos-meta-fileid":b,success_action_status:"201","x-cos-security-token":m}}),(N={})[_.put]={params:I,isSuccess:function(t){return t>=200&&t<300}},N[_.post]={params:A,isSuccess:function(t){return 201===t}},R=N,[4,l.upload(R[u].params)];case 2:return j=P.sent(),R[u].isSuccess(j.statusCode)?[2,C(e,null,{fileID:g,download_url:v,requestId:w})]:[2,C(e,new Error("[".concat(L(),"][").concat(F.OPERATION_FAIL,"][").concat(U,"]:").concat(j.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s;return P(this,(function(a){switch(a.label){case 0:if(o=t.cloudPath,!x(o))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getUploadMetadata] invalid cloudPath")}));n=this.request,r="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.send(r,{path:o})];case 2:return i=a.sent(),[2,C(e,null,i)];case 3:return s=a.sent(),[2,C(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(!(o=t.fileList)||!T(o)||0===o.length)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".deleteFile] fileList must not be empty")}));for(n=0,r=o;n<r.length;n++)if(!(i=r[n])||!x(i))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:o})];case 1:return(s=c.sent()).code?[2,C(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,C(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(!(o=t.fileList)||!T(o)||0===o.length)throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] fileList must not be empty")}));for(n=[],r=0,i=o;r<i.length;r++)if(s=i[r],u=s,"[object Object]"===Object.prototype.toString.call(u)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] file info must include fileID and maxAge")}));n.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!x(s))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:n})];case 1:return(a=c.sent()).code?[2,C(e,null,a)]:[2,C(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}var u}))}))},t.prototype.downloadFile=function(t,e){return N(this,void 0,void 0,(function(){var o,n,r,i,s,a;return P(this,(function(c){switch(c.label){case 0:if(o=t.fileID,!x(o))throw new Error(JSON.stringify({code:F.INVALID_PARAMS,msg:"[".concat(U,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:o,maxAge:600}]})];case 1:return n=c.sent(),"SUCCESS"!==(r=n.fileList[0]).code?[2,C(e,r)]:(i=this.request,s=encodeURI(r.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,C(e,null,a)]}}))}))},R([M({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"uploadFile",null),R([M({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),R([M({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"deleteFile",null),R([M({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"getTempFileURL",null),R([M({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),j("design:type",Function),j("design:paramtypes",[Object,Function]),j("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),D={name:U,entity:{uploadFile:k.uploadFile,deleteFile:k.deleteFile,getTempFileURL:k.getTempFileURL,downloadFile:k.downloadFile,getUploadMetadata:k.getUploadMetadata}};try{cloudbase.registerComponent(D)}catch(I){}function q(t){try{t.registerComponent(D)}catch(t){console.warn(t)}}}},e={};function o(n){var r=e[n];if(void 0!==r)return r.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,o),i.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=void 0;var e=o(864);t.registerStorage=e.registerStorage})(),n})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/js-sdk",
3
- "version": "2.11.0",
3
+ "version": "2.12.1",
4
4
  "description": "cloudbase javascript sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -45,24 +45,24 @@
45
45
  "author": "",
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
- "@cloudbase/adapter-interface": "^0.6.0",
49
- "@cloudbase/ai": "^2.11.0",
50
- "@cloudbase/analytics": "^2.11.0",
51
- "@cloudbase/app": "^2.11.0",
52
- "@cloudbase/auth": "^2.11.0",
53
- "@cloudbase/cloudrun": "^2.11.0",
48
+ "@cloudbase/adapter-interface": "^0.7.0",
49
+ "@cloudbase/ai": "^2.12.1",
50
+ "@cloudbase/analytics": "^2.12.1",
51
+ "@cloudbase/app": "^2.12.1",
52
+ "@cloudbase/auth": "^2.12.1",
53
+ "@cloudbase/cloudrun": "^2.12.1",
54
54
  "@cloudbase/database": "0.9.21",
55
- "@cloudbase/functions": "^2.11.0",
56
- "@cloudbase/model": "^2.11.0",
57
- "@cloudbase/realtime": "^2.11.0",
58
- "@cloudbase/storage": "^2.11.0",
59
- "@cloudbase/types": "^2.11.0",
60
- "@cloudbase/utilities": "^2.11.0"
55
+ "@cloudbase/functions": "^2.12.1",
56
+ "@cloudbase/model": "^2.12.1",
57
+ "@cloudbase/realtime": "^2.12.1",
58
+ "@cloudbase/storage": "^2.12.1",
59
+ "@cloudbase/types": "^2.12.1",
60
+ "@cloudbase/utilities": "^2.12.1"
61
61
  },
62
62
  "browserslist": [
63
63
  "last 2 version",
64
64
  "> 1%",
65
65
  "chrome 53"
66
66
  ],
67
- "gitHead": "9f5a5b1534dbf400711bd5909f153f6f2f7f84e4"
67
+ "gitHead": "3600dc3d57f6ce0da1a1e2ea29a5df956411c837"
68
68
  }