@alipay/faas-web-sdk 1.1.13-alpha.2 → 1.1.13-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function o(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,s={},l={},p={},f={},d={},y=a&&a.__extends||(c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(d,"__esModule",{value:!0}),d.FaasError=void 0;var h=function(t){function e(n,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=n,o.errorMessage=r,Object.setPrototypeOf(o,e.prototype),o}return y(e,t),Object.defineProperty(e.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),e.INVALID_PARAM_ERR=function(t,n){return new e(60001,"无效入参,参数 ".concat(t," ").concat(n))},e.NOT_FOUND_ERR=function(t){return new e(60001,t)},e.SERVER_ERR=function(t,n,r,o){var i=new e(t,n);return i.requestID=r,i.httpStatus=o,i},e.STORAGE_ERR=function(t,n,r){var o=new e(t,n);return o.requestID=r,o},e.NETWORK_ERR=function(t,n){var r=new e(-1,t.toString());return r.requestID=n,r},e}(Error);d.FaasError=h;var m=a&&a.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(f,"__esModule",{value:!0}),f.ResponseUtil=f.wrapCallback=void 0;var v=d;f.wrapCallback=function(t,e){return void 0===e&&(e=void 0),function(n){if(!((null==n?void 0:n.complete)||(null==n?void 0:n.success)||(null==n?void 0:n.fail)))return t.call(e,n);var r=n.complete,o=n.success,i=n.fail,a=m(n,["complete","success","fail"]);t.call(e,a).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}};var g=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var e=t.data||{code:-1,message:"未知异常"},n=e.code,r=e.message;throw v.FaasError.SERVER_ERR(n,r,t.requestID,t.status)}return t.data.data},t}();f.ResponseUtil=g;var _=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},b=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(p,"__esModule",{value:!0}),p.createCallContainer=void 0;var w=f;p.createCallContainer=function(t){return(0,w.wrapCallback)((function(e){return _(void 0,void 0,void 0,(function(){return b(this,(function(n){throw new Error("not implemented in "+t.type+" with "+e)}))}))}))};var O={},C=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},P=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(O,"__esModule",{value:!0}),O.createCallFunction=void 0;var A=d,j=f;O.createCallFunction=function(t){var e=t.httpclient;return(0,j.wrapCallback)((function(t){return C(void 0,void 0,void 0,(function(){var n,r,o,i,a;return P(this,(function(u){switch(u.label){case 0:if(!t.name)throw A.FaasError.INVALID_PARAM_ERR("name","缺失");return n={"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"},"POST","/functions/invokeFunction",[4,e.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:n})];case 1:if(200!==(r=u.sent()).status)throw o=-1,i="",(a=r.data)&&(o=a.errCode,i=a.errMsg,a.errDetail&&(i+=",详情:".concat(a.errDetail))),A.FaasError.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data}]}}))}))}))};var x={},S={},E={};Object.defineProperty(E,"__esModule",{value:!0});var R,D={},M={},I={},N={},q=a&&a.__extends||(R=function(t,e){return(R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}R(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(N,"__esModule",{value:!0}),N.AggregateCommand=N.QueryCommand=N.UpdateCommand=N.AbstractCommand=void 0;var B=function(){};N.AbstractCommand=B;var T=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return q(e,t),e}(B);N.UpdateCommand=T;var k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return q(e,t),e}(B);N.QueryCommand=k;var U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return q(e,t),e}(B);N.AggregateCommand=U;var F,Q,L,$={},H={},W=a&&a.__extends||(F=function(t,e){return(F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}F(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(H,"__esModule",{value:!0}),H.DbBuildError=H.ErrorCode=void 0,(L=Q||(H.ErrorCode=Q={})).INVALID_PARAM="INVALID_PARAM",L.INVALID_COMMAND="INVALID_COMMAND";var G=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return W(e,t),e.create=function(t,n){var r=new e(n);return r.code=t,r},e.invalidParam=function(t,n){return e.create(Q.INVALID_PARAM,'无效入参 "'.concat(t,'", ').concat(n))},e.invalidCommand=function(t){return e.create(Q.INVALID_COMMAND,t)},e}(Error);H.DbBuildError=G,Object.defineProperty($,"__esModule",{value:!0}),$.AggregateRequest=void 0;var z=H,V=N,J=function(){function t(t,e){void 0===e&&(e=""),this.data=t,this.prefix=e}return t.prototype.stringify=function(){var n=this;if(this.data instanceof V.AbstractCommand){if(!(this.data instanceof V.AggregateCommand))throw z.DbBuildError.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(e,r){return new t(e,"".concat(n.prefix,".$.").concat(r)).stringify()}));switch(e(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw z.DbBuildError.invalidParam(this.prefix,"不支持函数");case"symbol":throw z.DbBuildError.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw z.DbBuildError.invalidParam(this.prefix,"不支持 undefined");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,a=new t(this.data[o],i);r[o]=a.stringify()}return r}},t.prototype.toJSON=function(){return this.stringify()},t}();$.AggregateRequest=J;var K,Y=a&&a.__extends||(K=function(t,e){return(K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}K(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(I,"__esModule",{value:!0}),I.AndAggregateCommand=void 0;var X=$,Z=function(t){function e(e){var n=t.call(this)||this;return n.commands=e.map((function(t){return new X.AggregateRequest(t).toJSON()})),n}return Y(e,t),e.prototype.pushCommand=function(t){this.commands.push(new X.AggregateRequest(t).toJSON())},e.prototype.stringify=function(){return{$and:this.commands}},e}(N.AggregateCommand);I.AndAggregateCommand=Z;var tt,et={},nt=a&&a.__extends||(tt=function(t,e){return(tt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}tt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(et,"__esModule",{value:!0}),et.AvgAggregateCommand=void 0;var rt=$,ot=function(t){function e(e){var n=t.call(this)||this;return n.val=new rt.AggregateRequest(e).toJSON(),n}return nt(e,t),e.prototype.stringify=function(){return{$avg:this.val}},e}(N.AggregateCommand);et.AvgAggregateCommand=ot;var it={},at=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(it,"__esModule",{value:!0}),it.CountAggregateCommand=void 0;var ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return at(e,t),e.prototype.stringify=function(){return{$count:{}}},e}(N.AggregateCommand);it.CountAggregateCommand=ut;var ct={},st=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(ct,"__esModule",{value:!0}),ct.EqAggregateCommand=void 0;var lt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return st(e,t),e.prototype.stringify=function(){return{$eq:this.val}},e}(N.AggregateCommand);ct.EqAggregateCommand=lt;var pt,ft={},dt={},yt={},ht={},mt={};function vt(){if(pt)return mt;pt=1;var t,e=a&&a.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)},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)});Object.defineProperty(mt,"__esModule",{value:!0}),mt.AndCommand=void 0;var n=N,r=ue(),o=function(t){function n(e){var n=t.call(this)||this;return n.commands=e.map(r.CommandUtils.stringify),n}return e(n,t),n.prototype.pushCommand=function(t){this.commands.push(r.CommandUtils.stringify(t))},n.prototype.stringify=function(){return{$and:this.commands}},n}(n.QueryCommand);return mt.AndCommand=o,mt}var gt,_t={};function bt(){if(gt)return _t;gt=1;var t=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(_t,"__esModule",{value:!0}),_t.OrCommand=void 0;var e=N,n=ue(),r=function(e){function r(t){var r=e.call(this)||this;return r.commands=t.map(n.CommandUtils.stringify),r}return t(r,e),r.prototype.pushCommand=function(t){this.commands.push(n.CommandUtils.stringify(t))},r.prototype.stringify=function(){return{$or:this.commands}},r}(e.QueryCommand);return _t.OrCommand=r,_t}var wt={},Ot=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(wt,"__esModule",{value:!0}),wt.EqCommand=void 0;var Ct=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Ot(e,t),e.prototype.stringify=function(){return{$eq:this.val}},e}(N.QueryCommand);wt.EqCommand=Ct;var Pt={},At=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.NeqCommand=void 0;var jt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return At(e,t),e.prototype.stringify=function(){return{$ne:this.val}},e}(N.QueryCommand);Pt.NeqCommand=jt;var xt={},St=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(xt,"__esModule",{value:!0}),xt.LtCommand=void 0;var Et=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return St(e,t),e.prototype.stringify=function(){return{$lt:this.val}},e}(N.QueryCommand);xt.LtCommand=Et;var Rt={},Dt=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.LteCommand=void 0;var Mt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Dt(e,t),e.prototype.stringify=function(){return{$lte:this.val}},e}(N.QueryCommand);Rt.LteCommand=Mt;var It={},Nt=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(It,"__esModule",{value:!0}),It.GtCommand=void 0;var qt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Nt(e,t),e.prototype.stringify=function(){return{$gt:this.val}},e}(N.QueryCommand);It.GtCommand=qt;var Bt={},Tt=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.GteCommand=void 0;var kt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Tt(e,t),e.prototype.stringify=function(){return{$gte:this.val}},e}(N.QueryCommand);Bt.GteCommand=kt;var Ut={},Ft=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.InCommand=void 0;var Qt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Ft(e,t),e.prototype.stringify=function(){return{$in:this.val}},e}(N.QueryCommand);Ut.InCommand=Qt;var Lt={},$t=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.NinCommand=void 0;var Ht=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return $t(e,t),e.prototype.stringify=function(){return{$nin:this.val}},e}(N.QueryCommand);Lt.NinCommand=Ht;var Wt={},Gt=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.ExistsCommand=void 0;var zt=function(t){function e(e){var n=t.call(this)||this;return n.exists=e,n}return Gt(e,t),e.prototype.stringify=function(){return{$exists:this.exists}},e}(N.QueryCommand);Wt.ExistsCommand=zt;var Vt={},Jt=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.ModCommand=void 0;var Kt=function(t){function e(e,n){var r=t.call(this)||this;return r.divisor=e,r.remainder=n,r}return Jt(e,t),e.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},e}(N.QueryCommand);Vt.ModCommand=Kt;var Yt={},Xt=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.AllCommand=void 0;var Zt=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Xt(e,t),e.prototype.stringify=function(){return{$all:this.val}},e}(N.QueryCommand);Yt.AllCommand=Zt;var te,ee,ne,re,oe={};function ie(){if(te)return oe;te=1;var t=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(oe,"__esModule",{value:!0}),oe.ElemMatchCommand=void 0;var e=N,n=ue(),r=function(e){function r(t){var r=e.call(this)||this;return r.val=n.CommandUtils.stringify(t),r}return t(r,e),r.prototype.stringify=function(){return{$elemMatch:this.val}},r}(e.QueryCommand);return oe.ElemMatchCommand=r,oe}function ae(){if(ee)return ht;ee=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.QueryChain=void 0;var t=vt(),e=bt(),n=wt,r=Pt,o=xt,i=Rt,a=It,u=Bt,c=Ut,s=Lt,l=Wt,p=Vt,f=Yt,d=ie(),y=ue(),h=function(){function h(t){this.lastCmd=t}return h.prototype.appendCommand=function(e){return e=y.CommandUtils.unchain(e),this.lastCmd instanceof t.AndCommand?this.lastCmd.pushCommand(e):this.lastCmd=new t.AndCommand([this.lastCmd,e]),this},h.prototype.and=function(t){return this.appendCommand(t)},h.prototype.or=function(t){return t=y.CommandUtils.unchain(t),this.lastCmd instanceof e.OrCommand?this.lastCmd.pushCommand(t):this.lastCmd=new e.OrCommand([this.lastCmd,t]),this},h.prototype.not=function(t){return this.appendCommand(t)},h.prototype.nor=function(t){return this.appendCommand(t)},h.prototype.eq=function(t){return this.appendCommand(new n.EqCommand(t))},h.prototype.neq=function(t){return this.appendCommand(new r.NeqCommand(t))},h.prototype.lt=function(t){return this.appendCommand(new o.LtCommand(t))},h.prototype.lte=function(t){return this.appendCommand(new i.LteCommand(t))},h.prototype.gt=function(t){return this.appendCommand(new a.GtCommand(t))},h.prototype.gte=function(t){return this.appendCommand(new u.GteCommand(t))},h.prototype.in=function(t){return this.appendCommand(new c.InCommand(t))},h.prototype.nin=function(t){return this.appendCommand(new s.NinCommand(t))},h.prototype.exists=function(t){return this.appendCommand(new l.ExistsCommand(t))},h.prototype.mod=function(t,e){return this.appendCommand(new p.ModCommand(t,e))},h.prototype.all=function(t){return this.appendCommand(new f.AllCommand(t))},h.prototype.elemMatch=function(t){return this.appendCommand(new d.ElemMatchCommand(y.CommandUtils.unchain(t)))},h.prototype.size=function(t){return this.appendCommand(t)},h}();return ht.QueryChain=h,ht}function ue(){if(ne)return yt;ne=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.CommandUtils=void 0;var t=N,e=ce(),n=ae(),r=function(){function r(){}return r.stringify=function(n){return(n=r.unchain(n))instanceof t.QueryCommand?n.stringify():new e.QueryRequest(n).toJSON()},r.unchain=function(t){return t instanceof n.QueryChain?t.lastCmd:t},r}();return yt.CommandUtils=r,yt}function ce(){if(re)return dt;re=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.QueryRequest=void 0;var t=N,n=H,r=ue(),o=function(){function o(t,e){void 0===e&&(e=""),this.query=t,this.prefix=e}return o.prototype.stringify=function(){var i=this,a={},u=r.CommandUtils.unchain(this.query),c=e(u);if(u instanceof t.QueryCommand)return u.stringify();if(Array.isArray(u))return u.map((function(t,e){return new o(t,"".concat(i.prefix,".$.").concat(e)).stringify()}));if("number"===c)return u;if("boolean"===c)return u;if("string"===c)return u;if("bigint"===c)return u;if("function"===c)throw n.DbBuildError.invalidParam(this.prefix,"不支持函数");if("symbol"===c)throw n.DbBuildError.invalidParam(this.prefix,"不支持 symbol");if("undefined"===c)throw n.DbBuildError.invalidParam(this.prefix,"不支持 undefined");if(null===u)return u;for(var s in u){var l=this.prefix?"".concat(this.prefix,".").concat(s):s,p=new o(u[s],l);a[s]=p.stringify()}return a},o.prototype.toJSON=function(){return this.stringify()},o}();return dt.QueryRequest=o,dt}var se,le,pe,fe,de,ye={};Object.defineProperty(ye,"__esModule",{value:!0}),ye.PipelineStageName=ye.Target=ye.DocumentAction=ye.CollectionAction=ye.Sort=void 0,function(t){t.DESC="desc",t.ASC="asc"}(se||(ye.Sort=se={})),function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(le||(ye.CollectionAction=le={})),function(t){t.update="update",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(pe||(ye.DocumentAction=pe={})),function(t){t.collection="collection",t.document="document"}(fe||(ye.Target=fe={})),function(t){t.match="$match",t.group="$group",t.sample="$sample",t.lookup="$lookup"}(de||(ye.PipelineStageName=de={})),Object.defineProperty(ft,"__esModule",{value:!0}),ft.AggregatePipeline=void 0;var he=$,me=ce(),ve=ye,ge=H,_e=function(){function t(){this.pipeline=[]}return t.prototype.match=function(t){return this.pushStage(ve.PipelineStageName.match,t),this},t.prototype.group=function(t){return this.pushStage(ve.PipelineStageName.group,t),this},t.prototype.sample=function(t){return this.pushStage(ve.PipelineStageName.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(ve.PipelineStageName.lookup,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var e;switch(t.name){case ve.PipelineStageName.match:return{$match:new me.QueryRequest(t.param).toJSON()};case ve.PipelineStageName.sample:case ve.PipelineStageName.lookup:return(e={})[t.name]=t.param,e;case ve.PipelineStageName.group:return{$group:new he.AggregateRequest(t.param).toJSON()};default:var n=t.name;throw ge.DbBuildError.invalidParam(n,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,e){this.pipeline.push({name:t,param:e})},t}();ft.AggregatePipeline=_e;var be={},we=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(be,"__esModule",{value:!0}),be.ExprCommand=void 0;var Oe=$,Ce=function(t){function e(e){var n=t.call(this)||this;return n.commands=new Oe.AggregateRequest(e).toJSON(),n}return we(e,t),e.prototype.stringify=function(){return{$expr:this.commands}},e}(N.QueryCommand);be.ExprCommand=Ce;var Pe={},Ae=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.GtAggregateCommand=void 0;var je=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Ae(e,t),e.prototype.stringify=function(){return{$gt:this.val}},e}(N.AggregateCommand);Pe.GtAggregateCommand=je;var xe={},Se=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(xe,"__esModule",{value:!0}),xe.GteAggregateCommand=void 0;var Ee=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Se(e,t),e.prototype.stringify=function(){return{$gte:this.val}},e}(N.AggregateCommand);xe.GteAggregateCommand=Ee;var Re={},De=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(Re,"__esModule",{value:!0}),Re.LtAggregateCommand=void 0;var Me=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return De(e,t),e.prototype.stringify=function(){return{$lt:this.val}},e}(N.AggregateCommand);Re.LtAggregateCommand=Me;var Ie={},Ne=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.LteAggregateCommand=void 0;var qe=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return Ne(e,t),e.prototype.stringify=function(){return{$lte:this.val}},e}(N.AggregateCommand);Ie.LteAggregateCommand=qe;var Be={},Te=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Be,"__esModule",{value:!0}),Be.MaxAggregateCommand=void 0;var ke=$,Ue=function(t){function e(e){var n=t.call(this)||this;return n.val=new ke.AggregateRequest(e).toJSON(),n}return Te(e,t),e.prototype.stringify=function(){return{$max:this.val}},e}(N.AggregateCommand);Be.MaxAggregateCommand=Ue;var Fe={},Qe=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.MinAggregateCommand=void 0;var Le=$,$e=function(t){function e(e){var n=t.call(this)||this;return n.val=new Le.AggregateRequest(e).toJSON(),n}return Qe(e,t),e.prototype.stringify=function(){return{$min:this.val}},e}(N.AggregateCommand);Fe.MinAggregateCommand=$e;var He={},We=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(He,"__esModule",{value:!0}),He.NeqAggregateCommand=void 0;var Ge=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return We(e,t),e.prototype.stringify=function(){return{$ne:this.val}},e}(N.AggregateCommand);He.NeqAggregateCommand=Ge;var ze={},Ve=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(ze,"__esModule",{value:!0}),ze.OrAggregateCommand=void 0;var Je=$,Ke=function(t){function e(e){var n=t.call(this)||this;return n.commands=e.map((function(t){return new Je.AggregateRequest(t).toJSON()})),n}return Ve(e,t),e.prototype.pushCommand=function(t){this.commands.push(new Je.AggregateRequest(t).toJSON())},e.prototype.stringify=function(){return{$or:this.commands}},e}(N.AggregateCommand);ze.OrAggregateCommand=Ke;var Ye={},Xe=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.SumAggregateCommand=void 0;var Ze=$,tn=function(t){function e(e){var n=t.call(this)||this;return n.val=new Ze.AggregateRequest(e).toJSON(),n}return Xe(e,t),e.prototype.stringify=function(){return{$sum:this.val}},e}(N.AggregateCommand);Ye.SumAggregateCommand=tn;var en={},nn=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(en,"__esModule",{value:!0}),en.SetCommand=void 0;var rn=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return nn(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return this.data},e}(N.UpdateCommand);en.SetCommand=rn;var on={},an=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(on,"__esModule",{value:!0}),on.IncCommand=void 0;var un=function(t){function e(e){var n=t.call(this)||this;return n.num=e,n}return an(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return this.num},e}(N.UpdateCommand);on.IncCommand=un;var cn,sn={},ln=a&&a.__extends||(cn=function(t,e){return cn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},cn(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 n(){this.constructor=t}cn(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(sn,"__esModule",{value:!0}),sn.NotCommand=void 0;var pn=N,fn=ue(),dn=function(t){function e(e){var n=t.call(this)||this;return n.command=fn.CommandUtils.stringify(e),n}return ln(e,t),e.prototype.stringify=function(){return{$not:this.command.stringify()}},e}(pn.QueryCommand);sn.NotCommand=dn;var yn={},hn=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(yn,"__esModule",{value:!0}),yn.NorCommand=void 0;var mn=N,vn=ue(),gn=function(t){function e(e){var n=t.call(this)||this;return n.commands=e.map(vn.CommandUtils.stringify),n}return hn(e,t),e.prototype.pushCommand=function(t){this.commands.push(vn.CommandUtils.stringify(t))},e.prototype.stringify=function(){return{$nor:this.commands}},e}(mn.QueryCommand);yn.NorCommand=gn;var _n={},bn=a&&a.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};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)}}();Object.defineProperty(_n,"__esModule",{value:!0}),_n.SizeCommand=void 0;var wn=function(t){function e(e){var n=t.call(this)||this;return n.val=e,n}return bn(e,t),e.prototype.stringify=function(){return{$size:this.val}},e}(N.QueryCommand);_n.SizeCommand=wn,Object.defineProperty(M,"__esModule",{value:!0}),M.Command=M.AggregateCommandFactory=void 0;var On=I,Cn=et,Pn=it,An=ct,jn=ft,xn=be,Sn=Pe,En=xe,Rn=Re,Dn=Ie,Mn=Be,In=Fe,Nn=He,qn=ze,Bn=Ye,Tn=en,kn=on,Un=ae(),Fn=bt(),Qn=vt(),Ln=ue(),$n=sn,Hn=yn,Wn=wt,Gn=Pt,zn=xt,Vn=Rt,Jn=It,Kn=Bt,Yn=Ut,Xn=Lt,Zn=Wt,tr=Vt,er=Yt,nr=ie(),rr=_n,or=function(){function t(){}return t.prototype.pipeline=function(){return new jn.AggregatePipeline},t.prototype.avg=function(t){return new Cn.AvgAggregateCommand(t)},t.prototype.count=function(){return new Pn.CountAggregateCommand},t.prototype.max=function(t){return new Mn.MaxAggregateCommand(t)},t.prototype.min=function(t){return new In.MinAggregateCommand(t)},t.prototype.sum=function(t){return new Bn.SumAggregateCommand(t)},t.prototype.and=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t=Array.isArray(t[0])?t[0]:t,new On.AndAggregateCommand(t)},t.prototype.or=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t=Array.isArray(t[0])?t[0]:t,new qn.OrAggregateCommand(t)},t.prototype.eq=function(t){return new An.EqAggregateCommand(t)},t.prototype.neq=function(t){return new Nn.NeqAggregateCommand(t)},t.prototype.lt=function(t){return new Rn.LtAggregateCommand(t)},t.prototype.lte=function(t){return new Dn.LteAggregateCommand(t)},t.prototype.gt=function(t){return new Sn.GtAggregateCommand(t)},t.prototype.gte=function(t){return new En.GteAggregateCommand(t)},t}();M.AggregateCommandFactory=or;var ir=function(){function t(){this.aggregate=new or}return t.prototype.set=function(t){return new Tn.SetCommand(t)},t.prototype.inc=function(t){return new kn.IncCommand(t)},t.prototype.expr=function(t){return new xn.ExprCommand(t)},t.prototype.and=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=Array.isArray(t[0])?t[0]:t;var n=new Qn.AndCommand(t.map(Ln.CommandUtils.unchain));return new Un.QueryChain(n)},t.prototype.or=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=Array.isArray(t[0])?t[0]:t;var n=new Fn.OrCommand(t.map(Ln.CommandUtils.unchain));return new Un.QueryChain(n)},t.prototype.not=function(t){var e=new $n.NotCommand(Ln.CommandUtils.unchain(t));return new Un.QueryChain(e)},t.prototype.nor=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=Array.isArray(t[0])?t[0]:t;var n=new Hn.NorCommand(t.map(Ln.CommandUtils.unchain));return new Un.QueryChain(n)},t.prototype.eq=function(t){return new Un.QueryChain(new Wn.EqCommand(t))},t.prototype.neq=function(t){return new Un.QueryChain(new Gn.NeqCommand(t))},t.prototype.lt=function(t){return new Un.QueryChain(new zn.LtCommand(t))},t.prototype.lte=function(t){return new Un.QueryChain(new Vn.LteCommand(t))},t.prototype.gt=function(t){return new Un.QueryChain(new Jn.GtCommand(t))},t.prototype.gte=function(t){return new Un.QueryChain(new Kn.GteCommand(t))},t.prototype.in=function(t){return new Un.QueryChain(new Yn.InCommand(t))},t.prototype.nin=function(t){return new Un.QueryChain(new Xn.NinCommand(t))},t.prototype.exists=function(t){return new Un.QueryChain(new Zn.ExistsCommand(t))},t.prototype.mod=function(t,e){return new Un.QueryChain(new tr.ModCommand(t,e))},t.prototype.all=function(t){return new Un.QueryChain(new er.AllCommand(t))},t.prototype.elemMatch=function(t){return new Un.QueryChain(new nr.ElemMatchCommand(Ln.CommandUtils.unchain(t)))},t.prototype.size=function(t){return new Un.QueryChain(new rr.SizeCommand(t))},t}();M.Command=ir;var ar={};Object.defineProperty(ar,"__esModule",{value:!0}),ar.ActionBuilder=void 0;var ur=ye,cr=function(){function t(){}return t.buildCollectionAction=function(t,e){return{target:ur.Target.collection,action:t,collectionName:e}},t.buildCollectionListQueryAction=function(t){return{target:ur.Target.collection,action:ur.CollectionAction.queryList,options:t}},t.buildDocumentAction=function(t,e,n){return{target:ur.Target.document,action:t,collectionName:e,options:n}},t}();ar.ActionBuilder=cr;var sr={},lr={},pr=a&&a.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};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)}}();Object.defineProperty(lr,"__esModule",{value:!0}),lr.AggregateBuilder=void 0;var fr=ye,dr=ar,yr=function(t){function e(e){var n=t.call(this)||this;return n.collectionName=e,n}return pr(e,t),e.prototype.end=function(){var t={$aggregate:this.done()};return dr.ActionBuilder.buildDocumentAction(fr.DocumentAction.aggregate,this.collectionName,t)},e}(ft.AggregatePipeline);lr.AggregateBuilder=yr;var hr={},mr={},vr={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.Operator=void 0;var _r=function(){function t(){this.res={}}return t.prototype.set=function(t,e){this.res.$set=this.res.$set||{},this.res.$set[t]=e},t.prototype.applyOperator=function(t,e,n){this.res[t]=this.res[t]||{},this.res[t][e]=n},t.prototype.emit=function(){return this.res},t}();gr.Operator=_r,Object.defineProperty(vr,"__esModule",{value:!0}),vr.UpdateRequest=void 0;var br=H,wr=N,Or=gr,Cr=function(){function t(t,e){void 0===e&&(e=""),this.data=t,this.prefix=e}return t.prototype.stringify=function(n){for(var r in n=n||new Or.Operator,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],a=e(i);if(i instanceof wr.AbstractCommand){if(!(i instanceof wr.UpdateCommand))throw br.DbBuildError.invalidCommand("Command 不是更新操作");n.applyOperator(i.operator,o,i.stringify())}else if("number"===a)n.set(o,i);else if("boolean"===a)n.set(o,i);else if("string"===a)n.set(o,i);else if("bigint"===a)n.set(o,i);else{if("function"===a)throw br.DbBuildError.invalidParam(o,"不支持函数");if("symbol"===a)throw br.DbBuildError.invalidParam(o,"不支持 symbol");if("undefined"===a)throw br.DbBuildError.invalidParam(o,"不支持 undefined");if(null===i)n.set(o,i);else if(Array.isArray(i))n.set(o,i);else{new t(i,o).stringify(n)}}}return n},t.prototype.toJSON=function(){return this.stringify().emit()},t}();vr.UpdateRequest=Cr;var Pr=a&&a.__assign||function(){return Pr=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Pr.apply(this,arguments)};Object.defineProperty(mr,"__esModule",{value:!0}),mr.QueryBuilder=void 0;var Ar=ce(),jr=vr,xr=ye,Sr=ar,Er=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var n in t)t[n]?"object"!==e(t[n])&&(t[n]=1):t[n]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,e){return this.criteria.sort.push({field:t,sort:e}),this},t.prototype.update=function(t){return this.build(xr.DocumentAction.update,Pr(Pr({},this.baseOptions()),{$update:new jr.UpdateRequest(t.data).toJSON()}))},t.prototype.set=function(t){return this.build(xr.DocumentAction.replace,Pr(Pr({},this.baseOptions()),{$replace:t.data}))},t.prototype.remove=function(){return this.build(xr.DocumentAction.delete,this.baseOptions())},t.prototype.get=function(){return this.build(xr.DocumentAction.queryList,Pr({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(xr.DocumentAction.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var e=new Ar.QueryRequest(this.criteria.match);t.$match=e.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var e=0,n=this.criteria.sort;e<n.length;e++){var r=n[e];t.$sort[r.field]=r.sort===xr.Sort.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,e){return Sr.ActionBuilder.buildDocumentAction(t,this.collectionName,e)},t}();mr.QueryBuilder=Er,Object.defineProperty(hr,"__esModule",{value:!0}),hr.DocumentBuilder=void 0;var Rr=ye,Dr=mr,Mr=function(){function t(t,e){this.collectionName=t,this.id=e}return t.prototype.update=function(t){return new Dr.QueryBuilder(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new Dr.QueryBuilder(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new Dr.QueryBuilder(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new Dr.QueryBuilder(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=Rr.DocumentAction.query,t},t}();hr.DocumentBuilder=Mr,Object.defineProperty(sr,"__esModule",{value:!0}),sr.CollectionBuilder=void 0;var Ir=ye,Nr=H,qr=ar,Br=lr,Tr=hr,kr=mr,Ur=function(){function t(t){this.collectionName=t}return t.prototype.add=function(t){return Array.isArray(t.data)?this.batchAdd(t):qr.ActionBuilder.buildDocumentAction(Ir.DocumentAction.create,this.collectionName,t.data)},t.prototype.batchAdd=function(t){if(t.data.length>200)throw Nr.DbBuildError.invalidParam("data","最大长度 200");var e={$create:t.data};return"boolean"==typeof t.ordered&&(e.$ordered=t.ordered),qr.ActionBuilder.buildDocumentAction(Ir.DocumentAction.batchCreate,this.collectionName,e)},t.prototype.doc=function(t){return new Tr.DocumentBuilder(this.collectionName,t)},t.prototype.limit=function(t){return new kr.QueryBuilder(this.collectionName).limit(t)},t.prototype.skip=function(t){return new kr.QueryBuilder(this.collectionName).skip(t)},t.prototype.where=function(t){return new kr.QueryBuilder(this.collectionName).where(t)},t.prototype.projection=function(t){return new kr.QueryBuilder(this.collectionName).projection(t)},t.prototype.orderBy=function(t,e){return new kr.QueryBuilder(this.collectionName).orderBy(t,e)},t.prototype.aggregate=function(){return new Br.AggregateBuilder(this.collectionName)},t.prototype.get=function(){return new kr.QueryBuilder(this.collectionName).get()},t.prototype.count=function(){return new kr.QueryBuilder(this.collectionName).count()},t}();sr.CollectionBuilder=Ur,Object.defineProperty(D,"__esModule",{value:!0}),D.MongoBuilder=void 0;var Fr=M,Qr=ye,Lr=ar,$r=sr,Hr=function(){function t(){this.command=new Fr.Command}return t.prototype.collection=function(t){return new $r.CollectionBuilder(t)},t.prototype.createCollection=function(t){return Lr.ActionBuilder.buildCollectionAction(Qr.CollectionAction.create,t)},t.prototype.getCollection=function(t){return Lr.ActionBuilder.buildCollectionAction(Qr.CollectionAction.query,t)},t.prototype.listCollection=function(t,e){return Lr.ActionBuilder.buildCollectionListQueryAction({$limit:null!=t?t:10,$skip:null!=e?e:0})},t.prototype.deleteCollection=function(t){return Lr.ActionBuilder.buildCollectionAction(Qr.CollectionAction.delete,t)},t}();D.MongoBuilder=Hr,function(t){var e=a&&a.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),n=a&&a.__exportStar||function(t,n){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||e(n,t,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.DbBuildError=t.CommandUtils=t.Command=t.AggregateRequest=t.UpdateRequest=t.QueryRequest=t.AggregateBuilder=t.QueryBuilder=t.DocumentBuilder=t.CollectionBuilder=t.MongoBuilder=void 0,n(E,t);var r=D;Object.defineProperty(t,"MongoBuilder",{enumerable:!0,get:function(){return r.MongoBuilder}});var o=sr;Object.defineProperty(t,"CollectionBuilder",{enumerable:!0,get:function(){return o.CollectionBuilder}});var i=hr;Object.defineProperty(t,"DocumentBuilder",{enumerable:!0,get:function(){return i.DocumentBuilder}});var u=mr;Object.defineProperty(t,"QueryBuilder",{enumerable:!0,get:function(){return u.QueryBuilder}});var c=lr;Object.defineProperty(t,"AggregateBuilder",{enumerable:!0,get:function(){return c.AggregateBuilder}});var s=ce();Object.defineProperty(t,"QueryRequest",{enumerable:!0,get:function(){return s.QueryRequest}});var l=vr;Object.defineProperty(t,"UpdateRequest",{enumerable:!0,get:function(){return l.UpdateRequest}});var p=$;Object.defineProperty(t,"AggregateRequest",{enumerable:!0,get:function(){return p.AggregateRequest}});var f=M;Object.defineProperty(t,"Command",{enumerable:!0,get:function(){return f.Command}});var d=ue();Object.defineProperty(t,"CommandUtils",{enumerable:!0,get:function(){return d.CommandUtils}});var y=H;Object.defineProperty(t,"DbBuildError",{enumerable:!0,get:function(){return y.DbBuildError}}),n(ye,t)}(S);var Wr={},Gr={},zr=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Vr=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.WrapCallback=void 0;var Jr=f;Gr.WrapCallback=function(){return function(t,e,n){var r=n.value;n.value=function(t){return zr(this,void 0,void 0,(function(){return Vr(this,(function(e){return[2,(0,Jr.wrapCallback)(r,this)(t)]}))}))}}};var Kr={},Yr=a&&a.__decorate||function(t,n,r,o){var i,a=arguments.length,u=a<3?n:null===o?o=Object.getOwnPropertyDescriptor(n,r):o;if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,r,o);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(u=(a<3?i(u):a>3?i(n,r,u):i(n,r))||u);return a>3&&u&&Object.defineProperty(n,r,u),u},Xr=a&&a.__metadata||function(t,n){if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,n)},Zr=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},to=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.Aggregate=void 0;var eo=S,no=Gr,ro=f;Kr.Aggregate=function(){function t(t,e){this.collectionName=t,this.options=e,this.builder=new eo.AggregateBuilder(t)}return t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.end=function(){return Zr(this,void 0,void 0,(function(){var t,e,n;return to(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,"POST",e="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:e,data:t})];case 1:return n=r.sent(),[2,ro.ResponseUtil.handleResponse(n)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},Yr([(0,no.WrapCallback)(),Xr("design:type",Function),Xr("design:paramtypes",[]),Xr("design:returntype",Promise)],t.prototype,"end",null),t}();var oo={},io={},ao=a&&a.__decorate||function(t,n,r,o){var i,a=arguments.length,u=a<3?n:null===o?o=Object.getOwnPropertyDescriptor(n,r):o;if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,r,o);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(u=(a<3?i(u):a>3?i(n,r,u):i(n,r))||u);return a>3&&u&&Object.defineProperty(n,r,u),u},uo=a&&a.__metadata||function(t,n){if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,n)},co=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},so=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(io,"__esModule",{value:!0}),io.Query=void 0;var lo=S,po=Gr,fo=f;io.Query=function(){function t(t,e){this.collectionName=t,this.options=e,this.builder=new lo.QueryBuilder(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,e){return this.builder.orderBy(t,e),this},t.prototype.update=function(t){return co(this,void 0,void 0,(function(){var e,n,r;return so(this,(function(o){switch(o.label){case 0:return"POST",e="".concat(this.getCollectionPath(),"?update"),n=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,fo.ResponseUtil.handleResponse(r)]}}))}))},t.prototype.set=function(t){return co(this,void 0,void 0,(function(){var e,n,r;return so(this,(function(o){switch(o.label){case 0:return"POST",e="".concat(this.getCollectionPath(),"?replace"),n=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,fo.ResponseUtil.handleResponse(r)]}}))}))},t.prototype.remove=function(){return co(this,void 0,void 0,(function(){var t,e,n;return so(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?delete"),e=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:e})];case 1:return n=r.sent(),[2,fo.ResponseUtil.handleResponse(n)]}}))}))},t.prototype.get=function(){return co(this,void 0,void 0,(function(){var t,e,n;return so(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?query"),e=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:e})];case 1:return n=r.sent(),[2,fo.ResponseUtil.handleResponse(n)]}}))}))},t.prototype.count=function(){return co(this,void 0,void 0,(function(){var t,e,n;return so(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?count"),e=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:e})];case 1:return n=r.sent(),[2,{total:fo.ResponseUtil.handleResponse(n).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},ao([(0,po.WrapCallback)(),uo("design:type",Function),uo("design:paramtypes",[Object]),uo("design:returntype",Promise)],t.prototype,"update",null),ao([(0,po.WrapCallback)(),uo("design:type",Function),uo("design:paramtypes",[Object]),uo("design:returntype",Promise)],t.prototype,"set",null),ao([(0,po.WrapCallback)(),uo("design:type",Function),uo("design:paramtypes",[]),uo("design:returntype",Promise)],t.prototype,"remove",null),ao([(0,po.WrapCallback)(),uo("design:type",Function),uo("design:paramtypes",[]),uo("design:returntype",Promise)],t.prototype,"get",null),ao([(0,po.WrapCallback)(),uo("design:type",Function),uo("design:paramtypes",[]),uo("design:returntype",Promise)],t.prototype,"count",null),t}();var yo=a&&a.__decorate||function(t,n,r,o){var i,a=arguments.length,u=a<3?n:null===o?o=Object.getOwnPropertyDescriptor(n,r):o;if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,r,o);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(u=(a<3?i(u):a>3?i(n,r,u):i(n,r))||u);return a>3&&u&&Object.defineProperty(n,r,u),u},ho=a&&a.__metadata||function(t,n){if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,n)},mo=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},vo=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(oo,"__esModule",{value:!0}),oo.Document=void 0;var go=Gr,_o=d,bo=io;oo.Document=function(){function t(t,e,n){this.collectionName=t,this.id=e,this.options=n}return t.prototype.update=function(t){return mo(this,void 0,void 0,(function(){return vo(this,(function(e){switch(e.label){case 0:return[4,this.query.update(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.set=function(t){return mo(this,void 0,void 0,(function(){return vo(this,(function(e){switch(e.label){case 0:return[4,this.query.set(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.remove=function(){return mo(this,void 0,void 0,(function(){return vo(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return mo(this,void 0,void 0,(function(){var t,e;return vo(this,(function(n){switch(n.label){case 0:return[4,this.query.get()];case 1:if(t=n.sent(),!(e=t[0])){if(this.options.throwOnNotFound)throw _o.FaasError.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,e]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new bo.Query(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)},enumerable:!1,configurable:!0}),yo([(0,go.WrapCallback)(),ho("design:type",Function),ho("design:paramtypes",[Object]),ho("design:returntype",Promise)],t.prototype,"update",null),yo([(0,go.WrapCallback)(),ho("design:type",Function),ho("design:paramtypes",[Object]),ho("design:returntype",Promise)],t.prototype,"set",null),yo([(0,go.WrapCallback)(),ho("design:type",Function),ho("design:paramtypes",[]),ho("design:returntype",Promise)],t.prototype,"remove",null),yo([(0,go.WrapCallback)(),ho("design:type",Function),ho("design:paramtypes",[]),ho("design:returntype",Promise)],t.prototype,"get",null),t}();var wo=a&&a.__decorate||function(t,n,r,o){var i,a=arguments.length,u=a<3?n:null===o?o=Object.getOwnPropertyDescriptor(n,r):o;if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,r,o);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(u=(a<3?i(u):a>3?i(n,r,u):i(n,r))||u);return a>3&&u&&Object.defineProperty(n,r,u),u},Oo=a&&a.__metadata||function(t,n){if("object"===("undefined"==typeof Reflect?"undefined":e(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,n)},Co=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Po=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.Collection=void 0;var Ao=S,jo=Gr,xo=f,So=Kr,Eo=oo,Ro=io;Wr.Collection=function(){function t(t,e){this.collectionName=t,this.options=e,this.builder=new Ao.CollectionBuilder(t)}return t.prototype.add=function(t){return Co(this,void 0,void 0,(function(){var e,n,r;return Po(this,(function(o){switch(o.label){case 0:return e=this.builder.add(t).options,"POST",n=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,xo.ResponseUtil.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new Eo.Document(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new Ro.Query(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new Ro.Query(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new Ro.Query(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new Ro.Query(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new Ro.Query(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,e){return new Ro.Query(this.collectionName,this.options).orderBy(t,e)},t.prototype.aggregate=function(){return new So.Aggregate(this.collectionName,this.options)},t.prototype.get=function(){return Co(this,void 0,void 0,(function(){return Po(this,(function(t){switch(t.label){case 0:return[4,new Ro.Query(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Co(this,void 0,void 0,(function(){return Po(this,(function(t){switch(t.label){case 0:return[4,new Ro.Query(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},wo([(0,jo.WrapCallback)(),Oo("design:type",Function),Oo("design:paramtypes",[Object]),Oo("design:returntype",Promise)],t.prototype,"add",null),wo([(0,jo.WrapCallback)(),Oo("design:type",Function),Oo("design:paramtypes",[]),Oo("design:returntype",Promise)],t.prototype,"get",null),wo([(0,jo.WrapCallback)(),Oo("design:type",Function),Oo("design:paramtypes",[]),Oo("design:returntype",Promise)],t.prototype,"count",null),t}();var Do=a&&a.__assign||function(){return Do=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Do.apply(this,arguments)},Mo=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Io=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(x,"__esModule",{value:!0}),x.Database=void 0;var No=S,qo=d,Bo=Wr,To=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){var e=t.method,n=t.path,r=t.data,o=t.headers;return Mo(this,void 0,void 0,(function(){return Io(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:e,path:n,data:r,headers:Do({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),ko=function(){function t(t){this.command=new No.Command,this.options=Do(Do({},t),{httpclient:new To(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw qo.FaasError.INVALID_PARAM_ERR("collectionName","不能为空");return new Bo.Collection(t,this.options)},t}();x.Database=ko;var Uo={},Fo=a&&a.__assign||function(){return Fo=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Fo.apply(this,arguments)},Qo=a&&a.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(a,u)}c((r=r.apply(t,e||[])).next())}))},Lo=a&&a.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(Uo,"__esModule",{value:!0}),Uo.Storage=void 0;var $o=d,Ho=f,Wo=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var e=t.trim().replace(/^cloud:\/\//,""),n=e.indexOf("/");if(n<=0)throw $o.FaasError.INVALID_PARAM_ERR("fileID","不合法");var r=e.substring(0,n),o=e.substring(n+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.uploadFile=function(t){return Qo(this,void 0,void 0,(function(){var e,n,r,o,i,a;return Lo(this,(function(u){switch(u.label){case 0:if(e=this.checkCloudPath(t.cloudPath))throw $o.FaasError.INVALID_PARAM_ERR("cloudPath",e);return n=this.getUploadPath(t.cloudPath.trim()),[4,this.request({method:"GET",path:n})];case 1:return r=u.sent(),o=Ho.ResponseUtil.handleResponse(r),i=this.formatFileID(o.file_id),[4,this.options.fileUploader.upload({fileID:i,uploadURL:o.upload_url,fileContent:t.fileContent})];case 2:if(200!==(a=u.sent()).statusCode)throw $o.FaasError.STORAGE_ERR(-1,"上传文件 ".concat(o.upload_url," 失败"),r.requestID);return[2,{fileID:i,statusCode:a.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return Qo(this,void 0,void 0,(function(){var e,n,r,o,i,a;return Lo(this,(function(u){switch(u.label){case 0:if(e=this.checkFileID(t.fileID))throw $o.FaasError.INVALID_PARAM_ERR("fileID",e);return n=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(n),[4,this.request({method:"GET",path:r})];case 1:return o=u.sent(),i=Ho.ResponseUtil.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(a=u.sent()).statusCode)throw $o.FaasError.STORAGE_ERR(-1,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,a]}}))}))},t.prototype.deleteFile=function(t){return Qo(this,void 0,void 0,(function(){var e,n,r,o,i,a,u,c,s,l=this;return Lo(this,(function(p){switch(p.label){case 0:if(e=Array.isArray(t)?t:t.fileList,!Array.isArray(e)||0===e.length)throw $o.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");for(n=[],r=0,o=e;r<o.length;r++){if(i=o[r],a=this.checkFileID(i))throw $o.FaasError.INVALID_PARAM_ERR("fileID",a);u=this.getCloudPathFromFileID(i),n.push(u)}return c=this.getBatchDeletePath(),[4,this.request({method:"POST",path:c,data:{file_list:n}})];case 1:return s=p.sent(),[2,{fileList:Ho.ResponseUtil.handleResponse(s).file_list.map((function(t){return{fileID:l.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return Qo(this,void 0,void 0,(function(){var e,n,r,o,i,a,u,c,s,l=this;return Lo(this,(function(p){switch(p.label){case 0:if(e=Array.isArray(t)?t:t.fileList,!Array.isArray(e)||0===e.length)throw $o.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");if(e.length>50)throw $o.FaasError.INVALID_PARAM_ERR("fileList","最大长度 50");for(n=[],r=0,o=e;r<o.length;r++){if(i=o[r],a=this.checkFileID(i))throw $o.FaasError.INVALID_PARAM_ERR("fileID",a);u=this.getCloudPathFromFileID(i),n.push({file_id:u,expire:600})}return c=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:c,data:{file_list:n}})];case 1:return s=p.sent(),[2,{fileList:Ho.ResponseUtil.handleResponse(s).file_list.map((function(t){return{fileID:l.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){var e=t.method,n=t.path,r=t.data,o=t.headers;return Qo(this,void 0,void 0,(function(){return Lo(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:e,path:n,data:r,headers:Fo({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}();Uo.Storage=Wo,Object.defineProperty(l,"__esModule",{value:!0}),l.WebSDK=void 0;var Go=p,zo=O,Vo=x,Jo=Uo,Ko=function(){function t(){}return t.createCallFunction=function(t){return(0,zo.createCallFunction)(t)},t.createCallContainer=function(t){return(0,Go.createCallContainer)(t)},t.createDatabase=function(t){return new Vo.Database(t)},t.createStorage=function(t){return new Jo.Storage(t)},t}();l.WebSDK=Ko;var Yo,Xo={};Object.defineProperty(Xo,"__esModule",{value:!0}),function(t){var e=a&&a.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),n=a&&a.__exportStar||function(t,n){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||e(n,t,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.ResponseUtil=t.FaasError=t.Query=t.Aggregate=t.Collection=t.Document=t.Database=t.Storage=t.WebSDK=void 0;var r=l;Object.defineProperty(t,"WebSDK",{enumerable:!0,get:function(){return r.WebSDK}});var o=Uo;Object.defineProperty(t,"Storage",{enumerable:!0,get:function(){return o.Storage}});var i=x;Object.defineProperty(t,"Database",{enumerable:!0,get:function(){return i.Database}});var u=oo;Object.defineProperty(t,"Document",{enumerable:!0,get:function(){return u.Document}});var c=Wr;Object.defineProperty(t,"Collection",{enumerable:!0,get:function(){return c.Collection}});var s=Kr;Object.defineProperty(t,"Aggregate",{enumerable:!0,get:function(){return s.Aggregate}});var p=io;Object.defineProperty(t,"Query",{enumerable:!0,get:function(){return p.Query}});var y=d;Object.defineProperty(t,"FaasError",{enumerable:!0,get:function(){return y.FaasError}});var h=f;Object.defineProperty(t,"ResponseUtil",{enumerable:!0,get:function(){return h.ResponseUtil}}),n(Xo,t)}(s),function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(Yo||(Yo={}));var Zo={exports:{}};var ti,ei={exports:{}};function ni(){return ti||(ti=1,function(t,e){var n;t.exports=(n=n||function(t,e){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==a&&a.crypto&&(n=a.crypto),!n)try{n=require("crypto")}catch(t){}var r=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var e=o(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=u.WordArray=c.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:4*t.length},toString:function(t){return(t||p).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var a=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var u=0;u<o;u+=4)e[r+u>>>2]=n[u>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(r());return new s.init(e,t)}}),l=i.enc={},p=l.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new s.init(n,e/2)}},f=l.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new s.init(n,e)}},d=l.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},y=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,a=this.blockSize,u=i/(4*a),c=(u=e?t.ceil(u):t.max((0|u)-this._minBufferSize,0))*a,l=t.min(4*c,i);if(c){for(var p=0;p<c;p+=a)this._doProcessBlock(o,p);n=o.splice(0,c),r.sigBytes-=l}return new s.init(n,l)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=y.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new h.HMAC.init(t,n).finalize(e)}}});var h=i.algo={};return i}(Math),n)}(ei)),ei.exports}!function(t,e){t.exports=ni().enc.Hex}(Zo);var ri=u(Zo.exports),oi={exports:{}},ii={exports:{}};!function(t,e){var n;t.exports=(n=ni(),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,a=e.algo,u=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(u[o]=n(t.pow(r,.5))),c[o]=n(t.pow(r,1/3)),o++),r++}();var s=[],l=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(u.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],u=n[4],l=n[5],p=n[6],f=n[7],d=0;d<64;d++){if(d<16)s[d]=0|t[e+d];else{var y=s[d-15],h=(y<<25|y>>>7)^(y<<14|y>>>18)^y>>>3,m=s[d-2],v=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;s[d]=h+s[d-7]+v+s[d-16]}var g=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&p)+c[d]+s[d];f=p,p=l,l=u,u=a+b|0,a=i,i=o,o=r,r=b+(_+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+p|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(l),e.HmacSHA256=i._createHmacHelper(l)}(Math),n.SHA256)}(ii);var ai,ui=ii.exports,ci=u(ui),si={exports:{}};!function(t,e){var n;t.exports=(n=ni(),ai||(ai=1,function(t,e){var n,r,o;t.exports=(r=(n=ni()).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=o.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),a=this._iKey=e.clone(),u=i.words,c=a.words,s=0;s<n;s++)u[s]^=1549556828,c[s]^=909522486;i.sigBytes=a.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))}(si)),n.HmacSHA256)}(oi);var li=u(oi.exports),pi=function(){function t(){}return t.sign=function(e){for(var n=e.signedHeaders.join(";"),r="",o=0,i=e.signedHeaders;o<i.length;o++){var a=i[o],u=e.headers[a];r+="".concat(a,":").concat(u,"\n")}var c=t.createHash(e.body||""),s=e.method.toUpperCase()+"\n"+e.path+"\n"+e.query+"\n"+r+"\n"+n+"\n"+c+"\n",l="HMAC-SHA256",p=t.createHash(s),f="".concat(l,"\n").concat(e.timestamp,"\n").concat(p,"\n"),d=t.createSha256(f,e.secretKey);return"".concat(l," Credential=").concat(e.secretId,", SignedHeaders=").concat(n,", Signature=").concat(d)},t.createSha256=function(t,e){return void 0===e&&(e=""),li(t,e).toString(ri)},t.createHash=function(t){return ci(t).toString(ri)},t}(),fi=function(){function t(){}return t.detectRuntime=function(){return window||void 0===("undefined"==typeof my?"undefined":e(my))?window||void 0===("undefined"==typeof wx?"undefined":e(wx))?Yo.WEB:Yo.WEICHAT_MINI:Yo.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},t.parseUrl=function(t,e){if(e===Yo.WEB)return new URL(t);var n=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=n[1],o=n[2],i=n[3],a=n[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:a||""}},t}();var di=function(){function t(t,e){this.req=t,this.config=e}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),yi=function(){function t(){}return t.prototype.request=function(t,e){return o(this,void 0,void 0,(function(){var n,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,fetch(t,r({mode:"cors"},e))];case 1:return n=i.sent(),o={},n.headers.forEach((function(t,e){o[e]=t})),a={status:n.status},[4,n.json()];case 2:return[2,(a.data=i.sent(),a.headers=o,a)]}}))}))},t}(),hi=function(){function t(){}return t.prototype.request=function(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==e?void 0:e.method)||"GET",data:null==e?void 0:e.body,headers:null==e?void 0:e.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw n=r.sent(),console.error(n),new Error("error: ".concat(n.error,", message: ").concat(n.errorMessage));case 3:return[2]}}))}))},t}(),mi=function(){function t(){}return t.prototype.request=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,new Promise((function(n,r){wx.request({url:t,method:(null==e?void 0:e.method)||"GET",data:null==e?void 0:e.body,header:null==e?void 0:e.headers,dataType:"json",success:function(t){n({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),vi=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case Yo.ALIPAY_MINI:this.singleton=new hi;break;case Yo.WEB:this.singleton=new yi;break;case Yo.WEICHAT_MINI:this.singleton=new mi;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function gi(t,e){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return[4,e()];case 1:return o.sent(),n=t.config.fetch||vi.default(t.config.runtime),r=t,[4,n.request(t.req.url,t.req.requestOptions)];case 2:return r.res=o.sent(),t.result={status:t.res.status,requestID:t.requestId,headers:t.res.headers,data:t.res.data},[2]}}))}))}function _i(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e()];case 1:return r.sent(),[3,3];case 2:throw n=r.sent(),s.FaasError.NETWORK_ERR(n,t.requestId);case 3:return[2]}}))}))}function bi(t){return function(e,n){return o(this,void 0,void 0,(function(){var o,a,u,c,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),a=fi.parseUrl(e.req.url,e.config.runtime),u={authorization:"","x-from-app-id":e.config.appId,"x-from-env-id":e.config.envId,"x-to-env-id":e.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":e.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var n,r=null===(n=e.req.requestOptions.headers)||void 0===n?void 0:n[t];r&&(u[t]=r)})),c=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:a.pathname,query:a.search.substring(1),secretId:e.config.secretId,secretKey:e.config.secretKey,method:e.req.requestOptions.method,headers:u,body:e.req.requestOptions.body,timestamp:o,signedHeaders:c},u.authorization=pi.sign(s),e.req.requestOptions.headers=r(r({},u),e.req.requestOptions.headers),[4,n()];case 1:return i.sent(),[2]}}))}))}}var wi=function(){function t(t,e){var n;this.config=t,this.handler=(n=e,function(t,e){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var a=n[i];if(i===n.length&&(a=e),!a)return Promise.resolve();try{return Promise.resolve(a(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){var e=t.method,n=t.path,r=t.data,a=t.headers;return o(this,void 0,void 0,(function(){var t,o,u,c;return i(this,(function(i){switch(i.label){case 0:return t=this.config.endpoint+n,o=r?JSON.stringify(r):r,u=fi.generateUUID(),a=Object.assign({"x-alipay-callid":u,"x-request-id":u,"x-alipay-source":"web,web-sdk","content-type":"application/json"},a),c=new di({url:t,requestOptions:{method:e,body:o,headers:a}},this.config),[4,this.handler(c)];case 1:return i.sent(),[2,c.result]}}))}))},t.createFunctionHttpclient=function(e){return new t(e,[_i,bi(["x-to-function-name"]),gi])},t.createDatabaseHttpclient=function(e){return new t(e,[_i,bi(["x-data-api-type","x-expire-timestamp"]),gi])},t.createStorageHttpclient=function(e){return new t(e,[_i,bi(["x-data-api-type","x-expire-timestamp"]),gi])},t}(),Oi=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return e=t.uploadURL,n=t.fileContent,[4,fetch(e,{method:"PUT",mode:"cors",body:n})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),Ci=function(t){function e(n){var r=wi.createStorageHttpclient(n),o=e.getFileUploader(n);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:n.envId})||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===Yo.WEB)return Oi.create();throw s.FaasError.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},e}(s.Storage),Pi=function(){function t(t){var e=t.resourceEnv||t.envId,n=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(e,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:n,envId:e,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||fi.detectRuntime(),functionName:""}}return t.prototype.init=function(){},t.prototype.callFunction=function(t){var e;return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r(r({},this.config),{envId:(null===(e=t.config)||void 0===e?void 0:e.env)||this.config.envId,functionName:t.name}),o=wi.createFunctionHttpclient(n),[4,s.WebSDK.createCallFunction({type:"web",httpclient:o})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new Ci(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,e.sent()]}}))}))},t.RUNTIME=Yo,t}();t.Cloud=Pi}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};var r=function(){return r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var u,c,a,s,f,p=(u=function(t,n){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},u(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),l=function(t){function n(e,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=e,o.errorMessage=r,Object.setPrototypeOf(o,n.prototype),o}return p(n,t),Object.defineProperty(n.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),n.INVALID_PARAM_ERR=function(t,e){return new n(60001,"无效入参,参数 ".concat(t," ").concat(e))},n.NOT_FOUND_ERR=function(t){return new n(60001,t)},n.SERVER_ERR=function(t,e,r,o){var i=new n(t,e);return i.requestID=r,i.httpStatus=o,i},n.STORAGE_ERR=function(t,e,r){var o=new n(t,e);return o.requestID=r,o},n.NETWORK_ERR=function(t,e){var r=new n(-1,t.toString());return r.requestID=e,r},n}(Error),h=function(t,n){return void 0===n&&(n=void 0),function(e){if(!((null==e?void 0:e.complete)||(null==e?void 0:e.success)||(null==e?void 0:e.fail)))return t.call(n,e);var r=e.complete,o=e.success,i=e.fail,u=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(e,["complete","success","fail"]);t.call(n,u).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}},y=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var n=t.data||{code:-1,message:"未知异常"},e=n.code,r=n.message;throw l.SERVER_ERR(e,r,t.requestID,t.status)}return t.data.data},t}(),d=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},w=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},v=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},m=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},b=(c=function(t,n){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},c(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}c(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),g=function(){},_=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return b(n,t),n}(g),O=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return b(n,t),n}(g),x=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return b(n,t),n}(g),P=(a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},a(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});(f=s||(s={})).INVALID_PARAM="INVALID_PARAM",f.INVALID_COMMAND="INVALID_COMMAND";var j,A,S,C,R,I,E,N=function(t){function n(e){var r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return P(n,t),n.create=function(t,e){var r=new n(e);return r.code=t,r},n.invalidParam=function(t,e){return n.create(s.INVALID_PARAM,'无效入参 "'.concat(t,'", ').concat(e))},n.invalidCommand=function(t){return n.create(s.INVALID_COMMAND,t)},n}(Error),T=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(this.data instanceof g){if(!(this.data instanceof x))throw N.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));switch(n(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw N.invalidParam(this.prefix,"不支持函数");case"symbol":throw N.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw N.invalidParam(this.prefix,"不支持 undefined");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i);r[o]=u.stringify()}return r}},t.prototype.toJSON=function(){return this.stringify()},t}(),D=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),q=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map((function(t){return new T(t).toJSON()})),e}return D(n,t),n.prototype.pushCommand=function(t){this.commands.push(new T(t).toJSON())},n.prototype.stringify=function(){return{$and:this.commands}},n}(x),k=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),$=function(t){function n(n){var e=t.call(this)||this;return e.val=new T(n).toJSON(),e}return k(n,t),n.prototype.stringify=function(){return{$avg:this.val}},n}(x),F=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),M=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return F(n,t),n.prototype.stringify=function(){return{$count:{}}},n}(x),L=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),B=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return L(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(x),U=(j=function(t,n){return j=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},j(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}j(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),H=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vt.stringify),e}return U(n,t),n.prototype.pushCommand=function(t){this.commands.push(vt.stringify(t))},n.prototype.stringify=function(){return{$and:this.commands}},n}(O),V=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),z=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vt.stringify),e}return V(n,t),n.prototype.pushCommand=function(t){this.commands.push(vt.stringify(t))},n.prototype.stringify=function(){return{$or:this.commands}},n}(O),J=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),G=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return J(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(O),W=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),K=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return W(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(O),Y=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Q=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Y(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(O),X=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Z=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return X(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(O),tt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),nt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return tt(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(O),et=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),rt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return et(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(O),ot=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),it=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ot(n,t),n.prototype.stringify=function(){return{$in:this.val}},n}(O),ut=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ct=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ut(n,t),n.prototype.stringify=function(){return{$nin:this.val}},n}(O),at=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),st=function(t){function n(n){var e=t.call(this)||this;return e.exists=n,e}return at(n,t),n.prototype.stringify=function(){return{$exists:this.exists}},n}(O),ft=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),pt=function(t){function n(n,e){var r=t.call(this)||this;return r.divisor=n,r.remainder=e,r}return ft(n,t),n.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},n}(O),lt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ht=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return lt(n,t),n.prototype.stringify=function(){return{$all:this.val}},n}(O),yt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),dt=function(t){function n(n){var e=t.call(this)||this;return e.val=vt.stringify(n),e}return yt(n,t),n.prototype.stringify=function(){return{$elemMatch:this.val}},n}(O),wt=function(){function t(t){this.lastCmd=t}return t.prototype.appendCommand=function(t){return t=vt.unchain(t),this.lastCmd instanceof H?this.lastCmd.pushCommand(t):this.lastCmd=new H([this.lastCmd,t]),this},t.prototype.and=function(t){return this.appendCommand(t)},t.prototype.or=function(t){return t=vt.unchain(t),this.lastCmd instanceof z?this.lastCmd.pushCommand(t):this.lastCmd=new z([this.lastCmd,t]),this},t.prototype.not=function(t){return this.appendCommand(t)},t.prototype.nor=function(t){return this.appendCommand(t)},t.prototype.eq=function(t){return this.appendCommand(new G(t))},t.prototype.neq=function(t){return this.appendCommand(new K(t))},t.prototype.lt=function(t){return this.appendCommand(new Q(t))},t.prototype.lte=function(t){return this.appendCommand(new Z(t))},t.prototype.gt=function(t){return this.appendCommand(new nt(t))},t.prototype.gte=function(t){return this.appendCommand(new rt(t))},t.prototype.in=function(t){return this.appendCommand(new it(t))},t.prototype.nin=function(t){return this.appendCommand(new ct(t))},t.prototype.exists=function(t){return this.appendCommand(new st(t))},t.prototype.mod=function(t,n){return this.appendCommand(new pt(t,n))},t.prototype.all=function(t){return this.appendCommand(new ht(t))},t.prototype.elemMatch=function(t){return this.appendCommand(new dt(vt.unchain(t)))},t.prototype.size=function(t){return this.appendCommand(t)},t}(),vt=function(){function t(){}return t.stringify=function(n){return(n=t.unchain(n))instanceof O?n.stringify():new mt(n).toJSON()},t.unchain=function(t){return t instanceof wt?t.lastCmd:t},t}(),mt=function(){function t(t,n){void 0===n&&(n=""),this.query=t,this.prefix=n}return t.prototype.stringify=function(){var e=this,r={},o=vt.unchain(this.query),i=n(o);if(o instanceof O)return o.stringify();if(Array.isArray(o))return o.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));if("number"===i)return o;if("boolean"===i)return o;if("string"===i)return o;if("bigint"===i)return o;if("function"===i)throw N.invalidParam(this.prefix,"不支持函数");if("symbol"===i)throw N.invalidParam(this.prefix,"不支持 symbol");if("undefined"===i)throw N.invalidParam(this.prefix,"不支持 undefined");if(null===o)return o;for(var u in o){var c=this.prefix?"".concat(this.prefix,".").concat(u):u,a=new t(o[u],c);r[u]=a.stringify()}return r},t.prototype.toJSON=function(){return this.stringify()},t}();(S=A||(A={})).DESC="desc",S.ASC="asc",function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(C||(C={})),function(t){t.update="update",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(R||(R={})),function(t){t.collection="collection",t.document="document"}(I||(I={})),function(t){t.match="$match",t.group="$group",t.sample="$sample",t.lookup="$lookup"}(E||(E={}));var bt=function(){function t(){this.pipeline=[]}return t.prototype.match=function(t){return this.pushStage(E.match,t),this},t.prototype.group=function(t){return this.pushStage(E.group,t),this},t.prototype.sample=function(t){return this.pushStage(E.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(E.lookup,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var n;switch(t.name){case E.match:return{$match:new mt(t.param).toJSON()};case E.sample:case E.lookup:return(n={})[t.name]=t.param,n;case E.group:return{$group:new T(t.param).toJSON()};default:var e=t.name;throw N.invalidParam(e,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,n){this.pipeline.push({name:t,param:n})},t}(),gt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_t=function(t){function n(n){var e=t.call(this)||this;return e.commands=new T(n).toJSON(),e}return gt(n,t),n.prototype.stringify=function(){return{$expr:this.commands}},n}(O),Ot=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),xt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Ot(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(x),Pt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),jt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Pt(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(x),At=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),St=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return At(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(x),Ct=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Rt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Ct(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(x),It=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Et=function(t){function n(n){var e=t.call(this)||this;return e.val=new T(n).toJSON(),e}return It(n,t),n.prototype.stringify=function(){return{$max:this.val}},n}(x),Nt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Tt=function(t){function n(n){var e=t.call(this)||this;return e.val=new T(n).toJSON(),e}return Nt(n,t),n.prototype.stringify=function(){return{$min:this.val}},n}(x),Dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),qt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Dt(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(x),kt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),$t=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map((function(t){return new T(t).toJSON()})),e}return kt(n,t),n.prototype.pushCommand=function(t){this.commands.push(new T(t).toJSON())},n.prototype.stringify=function(){return{$or:this.commands}},n}(x),Ft=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Mt=function(t){function n(n){var e=t.call(this)||this;return e.val=new T(n).toJSON(),e}return Ft(n,t),n.prototype.stringify=function(){return{$sum:this.val}},n}(x),Lt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Bt=function(t){function n(n){var e=t.call(this)||this;return e.data=n,e}return Lt(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.data},n}(_),Ut=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ht=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Ut(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(_),Vt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),zt=function(t){function n(n){var e=t.call(this)||this;return e.command=vt.stringify(n),e}return Vt(n,t),n.prototype.stringify=function(){return{$not:this.command.stringify()}},n}(O),Jt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Gt=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vt.stringify),e}return Jt(n,t),n.prototype.pushCommand=function(t){this.commands.push(vt.stringify(t))},n.prototype.stringify=function(){return{$nor:this.commands}},n}(O),Wt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Kt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Wt(n,t),n.prototype.stringify=function(){return{$size:this.val}},n}(O),Yt=function(){function t(){}return t.prototype.pipeline=function(){return new bt},t.prototype.avg=function(t){return new $(t)},t.prototype.count=function(){return new M},t.prototype.max=function(t){return new Et(t)},t.prototype.min=function(t){return new Tt(t)},t.prototype.sum=function(t){return new Mt(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new q(t)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new $t(t)},t.prototype.eq=function(t){return new B(t)},t.prototype.neq=function(t){return new qt(t)},t.prototype.lt=function(t){return new St(t)},t.prototype.lte=function(t){return new Rt(t)},t.prototype.gt=function(t){return new xt(t)},t.prototype.gte=function(t){return new jt(t)},t}(),Qt=function(){function t(){this.aggregate=new Yt}return t.prototype.set=function(t){return new Bt(t)},t.prototype.inc=function(t){return new Ht(t)},t.prototype.expr=function(t){return new _t(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new H(t.map(vt.unchain));return new wt(e)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new z(t.map(vt.unchain));return new wt(e)},t.prototype.not=function(t){var n=new zt(vt.unchain(t));return new wt(n)},t.prototype.nor=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Gt(t.map(vt.unchain));return new wt(e)},t.prototype.eq=function(t){return new wt(new G(t))},t.prototype.neq=function(t){return new wt(new K(t))},t.prototype.lt=function(t){return new wt(new Q(t))},t.prototype.lte=function(t){return new wt(new Z(t))},t.prototype.gt=function(t){return new wt(new nt(t))},t.prototype.gte=function(t){return new wt(new rt(t))},t.prototype.in=function(t){return new wt(new it(t))},t.prototype.nin=function(t){return new wt(new ct(t))},t.prototype.exists=function(t){return new wt(new st(t))},t.prototype.mod=function(t,n){return new wt(new pt(t,n))},t.prototype.all=function(t){return new wt(new ht(t))},t.prototype.elemMatch=function(t){return new wt(new dt(vt.unchain(t)))},t.prototype.size=function(t){return new wt(new Kt(t))},t}(),Xt=function(){function t(){}return t.buildCollectionAction=function(t,n){return{target:I.collection,action:t,collectionName:n}},t.buildCollectionListQueryAction=function(t){return{target:I.collection,action:C.queryList,options:t}},t.buildDocumentAction=function(t,n,e){return{target:I.document,action:t,collectionName:n,options:e}},t}(),Zt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),tn=function(t){function n(n){var e=t.call(this)||this;return e.collectionName=n,e}return Zt(n,t),n.prototype.end=function(){var t={$aggregate:this.done()};return Xt.buildDocumentAction(R.aggregate,this.collectionName,t)},n}(bt),nn=function(){function t(){this.res={}}return t.prototype.set=function(t,n){this.res.$set=this.res.$set||{},this.res.$set[t]=n},t.prototype.applyOperator=function(t,n,e){this.res[t]=this.res[t]||{},this.res[t][n]=e},t.prototype.emit=function(){return this.res},t}(),en=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(e){for(var r in e=e||new nn,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],u=n(i);if(i instanceof g){if(!(i instanceof _))throw N.invalidCommand("Command 不是更新操作");e.applyOperator(i.operator,o,i.stringify())}else if("number"===u)e.set(o,i);else if("boolean"===u)e.set(o,i);else if("string"===u)e.set(o,i);else if("bigint"===u)e.set(o,i);else{if("function"===u)throw N.invalidParam(o,"不支持函数");if("symbol"===u)throw N.invalidParam(o,"不支持 symbol");if("undefined"===u)throw N.invalidParam(o,"不支持 undefined");if(null===i)e.set(o,i);else if(Array.isArray(i))e.set(o,i);else{new t(i,o).stringify(e)}}}return e},t.prototype.toJSON=function(){return this.stringify().emit()},t}(),rn=function(){return rn=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},rn.apply(this,arguments)},on=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var e in t)t[e]?"object"!==n(t[e])&&(t[e]=1):t[e]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,n){return this.criteria.sort.push({field:t,sort:n}),this},t.prototype.update=function(t){return this.build(R.update,rn(rn({},this.baseOptions()),{$update:new en(t.data).toJSON()}))},t.prototype.set=function(t){return this.build(R.replace,rn(rn({},this.baseOptions()),{$replace:t.data}))},t.prototype.remove=function(){return this.build(R.delete,this.baseOptions())},t.prototype.get=function(){return this.build(R.queryList,rn({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(R.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var n=new mt(this.criteria.match);t.$match=n.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var n=0,e=this.criteria.sort;n<e.length;n++){var r=e[n];t.$sort[r.field]=r.sort===A.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,n){return Xt.buildDocumentAction(t,this.collectionName,n)},t}(),un=function(){function t(t,n){this.collectionName=t,this.id=n}return t.prototype.update=function(t){return new on(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new on(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new on(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new on(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=R.query,t},t}(),cn=function(){function t(t){this.collectionName=t}return t.prototype.add=function(t){if(!(null==t?void 0:t.data))throw N.invalidParam("data","不能为空");return Array.isArray(t.data)?this.batchAdd(t):Xt.buildDocumentAction(R.create,this.collectionName,t.data)},t.prototype.batchAdd=function(t){if(t.data.length<=0)throw N.invalidParam("data","不能为空数组");if(t.data.length>200)throw N.invalidParam("data","最大长度 200");var n={$create:t.data};return"boolean"==typeof t.ordered&&(n.$ordered=t.ordered),Xt.buildDocumentAction(R.batchCreate,this.collectionName,n)},t.prototype.doc=function(t){return new un(this.collectionName,t)},t.prototype.limit=function(t){return new on(this.collectionName).limit(t)},t.prototype.skip=function(t){return new on(this.collectionName).skip(t)},t.prototype.where=function(t){return new on(this.collectionName).where(t)},t.prototype.projection=function(t){return new on(this.collectionName).projection(t)},t.prototype.orderBy=function(t,n){return new on(this.collectionName).orderBy(t,n)},t.prototype.aggregate=function(){return new tn(this.collectionName)},t.prototype.get=function(){return new on(this.collectionName).get()},t.prototype.count=function(){return new on(this.collectionName).count()},t}(),an=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},sn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function fn(){return function(t,n,e){var r=e.value;e.value=function(t){return an(this,void 0,void 0,(function(){return sn(this,(function(n){return[2,h(r,this)(t)]}))}))}}}var pn,ln=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},hn=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},yn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},dn=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new tn(t)}return t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.end=function(){return hn(this,void 0,void 0,(function(){var t,n,e;return yn(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,"POST",n="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:n,data:t})];case 1:return e=r.sent(),[2,y.handleResponse(e)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);u>3&&c&&Object.defineProperty(e,r,c)}([fn(),ln("design:type",Function),ln("design:paramtypes",[]),ln("design:returntype",Promise)],t.prototype,"end",null),t}(),wn=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},vn=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},mn=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},bn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},gn=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new on(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,n){return this.builder.orderBy(t,n),this},t.prototype.update=function(t){return mn(this,void 0,void 0,(function(){var n,e,r;return bn(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?update"),e=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,y.handleResponse(r)]}}))}))},t.prototype.set=function(t){return mn(this,void 0,void 0,(function(){var n,e,r;return bn(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?replace"),e=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,y.handleResponse(r)]}}))}))},t.prototype.remove=function(){return mn(this,void 0,void 0,(function(){var t,n,e;return bn(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?delete"),n=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,y.handleResponse(e)]}}))}))},t.prototype.get=function(){return mn(this,void 0,void 0,(function(){var t,n,e;return bn(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?query"),n=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,y.handleResponse(e)]}}))}))},t.prototype.count=function(){return mn(this,void 0,void 0,(function(){var t,n,e;return bn(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?count"),n=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,{total:y.handleResponse(e).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},wn([fn(),vn("design:type",Function),vn("design:paramtypes",[Object]),vn("design:returntype",Promise)],t.prototype,"update",null),wn([fn(),vn("design:type",Function),vn("design:paramtypes",[Object]),vn("design:returntype",Promise)],t.prototype,"set",null),wn([fn(),vn("design:type",Function),vn("design:paramtypes",[]),vn("design:returntype",Promise)],t.prototype,"remove",null),wn([fn(),vn("design:type",Function),vn("design:paramtypes",[]),vn("design:returntype",Promise)],t.prototype,"get",null),wn([fn(),vn("design:type",Function),vn("design:paramtypes",[]),vn("design:returntype",Promise)],t.prototype,"count",null),t}(),_n=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},On=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},xn=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Pn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},jn=function(){function t(t,n,e){this.collectionName=t,this.id=n,this.options=e}return t.prototype.update=function(t){return xn(this,void 0,void 0,(function(){return Pn(this,(function(n){switch(n.label){case 0:return[4,this.query.update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return xn(this,void 0,void 0,(function(){return Pn(this,(function(n){switch(n.label){case 0:return[4,this.query.set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return xn(this,void 0,void 0,(function(){return Pn(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return xn(this,void 0,void 0,(function(){var t,n;return Pn(this,(function(e){switch(e.label){case 0:return[4,this.query.get()];case 1:if(t=e.sent(),!(n=t[0])){if(this.options.throwOnNotFound)throw l.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,n]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new gn(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)},enumerable:!1,configurable:!0}),_n([fn(),On("design:type",Function),On("design:paramtypes",[Object]),On("design:returntype",Promise)],t.prototype,"update",null),_n([fn(),On("design:type",Function),On("design:paramtypes",[Object]),On("design:returntype",Promise)],t.prototype,"set",null),_n([fn(),On("design:type",Function),On("design:paramtypes",[]),On("design:returntype",Promise)],t.prototype,"remove",null),_n([fn(),On("design:type",Function),On("design:paramtypes",[]),On("design:returntype",Promise)],t.prototype,"get",null),t}(),An=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Sn=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Cn=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Rn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},In=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new cn(t)}return t.prototype.add=function(t){return Cn(this,void 0,void 0,(function(){var n,e,r;return Rn(this,(function(o){switch(o.label){case 0:return n=this.builder.add(t).options,"POST",e=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,y.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new jn(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new gn(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new gn(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new gn(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new gn(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new gn(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,n){return new gn(this.collectionName,this.options).orderBy(t,n)},t.prototype.aggregate=function(){return new dn(this.collectionName,this.options)},t.prototype.get=function(){return Cn(this,void 0,void 0,(function(){return Rn(this,(function(t){switch(t.label){case 0:return[4,new gn(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Cn(this,void 0,void 0,(function(){return Rn(this,(function(t){switch(t.label){case 0:return[4,new gn(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},An([fn(),Sn("design:type",Function),Sn("design:paramtypes",[Object]),Sn("design:returntype",Promise)],t.prototype,"add",null),An([fn(),Sn("design:type",Function),Sn("design:paramtypes",[]),Sn("design:returntype",Promise)],t.prototype,"get",null),An([fn(),Sn("design:type",Function),Sn("design:paramtypes",[]),Sn("design:returntype",Promise)],t.prototype,"count",null),t}(),En=function(){return En=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},En.apply(this,arguments)},Nn=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Tn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Dn=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return Nn(this,void 0,void 0,(function(){return Tn(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:n,path:e,data:r,headers:En({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),qn=function(){function t(t){this.command=new Qt,this.options=En(En({},t),{httpclient:new Dn(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw l.INVALID_PARAM_ERR("collectionName","不能为空");return new In(t,this.options)},t}(),kn=function(){return kn=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},kn.apply(this,arguments)},$n=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Fn=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Mn=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var n=t.trim().replace(/^cloud:\/\//,""),e=n.indexOf("/");if(e<=0)throw l.INVALID_PARAM_ERR("fileID","不合法");var r=n.substring(0,e),o=n.substring(e+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.uploadFile=function(t){return $n(this,void 0,void 0,(function(){var n,e,r,o,i,u;return Fn(this,(function(c){switch(c.label){case 0:if(n=this.checkCloudPath(t.cloudPath))throw l.INVALID_PARAM_ERR("cloudPath",n);return e=this.getUploadPath(t.cloudPath.trim()),[4,this.request({method:"GET",path:e})];case 1:return r=c.sent(),o=y.handleResponse(r),i=this.formatFileID(o.file_id),[4,this.options.fileUploader.upload({fileID:i,uploadURL:o.upload_url,fileContent:t.fileContent})];case 2:if(200!==(u=c.sent()).statusCode)throw l.STORAGE_ERR(-1,"上传文件 ".concat(o.upload_url," 失败"),r.requestID);return[2,{fileID:i,statusCode:u.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return $n(this,void 0,void 0,(function(){var n,e,r,o,i,u;return Fn(this,(function(c){switch(c.label){case 0:if(n=this.checkFileID(t.fileID))throw l.INVALID_PARAM_ERR("fileID",n);return e=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(e),[4,this.request({method:"GET",path:r})];case 1:return o=c.sent(),i=y.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(u=c.sent()).statusCode)throw l.STORAGE_ERR(-1,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,u]}}))}))},t.prototype.deleteFile=function(t){return $n(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,f=this;return Fn(this,(function(p){switch(p.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw l.INVALID_PARAM_ERR("fileList","不能为空数组");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw l.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push(c)}return a=this.getBatchDeletePath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=p.sent(),[2,{fileList:y.handleResponse(s).file_list.map((function(t){return{fileID:f.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return $n(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,f=this;return Fn(this,(function(p){switch(p.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw l.INVALID_PARAM_ERR("fileList","不能为空数组");if(n.length>50)throw l.INVALID_PARAM_ERR("fileList","最大长度 50");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw l.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push({file_id:c,expire:600})}return a=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=p.sent(),[2,{fileList:y.handleResponse(s).file_list.map((function(t){return{fileID:f.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return $n(this,void 0,void 0,(function(){return Fn(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:n,path:e,data:r,headers:kn({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),Ln=function(){function t(){}return t.createCallFunction=function(t){return function(t){var n=t.httpclient;return h((function(t){return v(void 0,void 0,void 0,(function(){var e,r,o,i,u;return m(this,(function(c){switch(c.label){case 0:if(!t.name)throw l.INVALID_PARAM_ERR("name","缺失");return e={"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"},[4,n.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:e})];case 1:if(200!==(r=c.sent()).status)throw o=-1,i="",(u=r.data)&&(o=u.errCode,i=u.errMsg,u.errDetail&&(i+=",详情:".concat(u.errDetail))),l.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data}]}}))}))}))}(t)},t.createCallContainer=function(t){return function(t){return h((function(n){return d(void 0,void 0,void 0,(function(){return w(this,(function(e){throw new Error("not implemented in "+t.type+" with "+n)}))}))}))}(t)},t.createDatabase=function(t){return new qn(t)},t.createStorage=function(t){return new Mn(t)},t}();!function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(pn||(pn={}));var Bn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Un(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}};var Vn,zn={exports:{}};function Jn(){return Vn||(Vn=1,function(t,n){var e;t.exports=(e=e||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==Bn&&Bn.crypto&&(e=Bn.crypto),!e)try{e=require("crypto")}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=u.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||f).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var u=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=u<<24-(r+i)%4*8}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),s=i.enc={},f=s.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},p=s.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},h=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,u=this.blockSize,c=i/(4*u),s=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*u,f=t.min(4*s,i);if(s){for(var p=0;p<s;p+=u)this._doProcessBlock(o,p);e=o.splice(0,s),r.sigBytes-=f}return new a.init(e,f)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=h.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new y.HMAC.init(t,e).finalize(n)}}});var y=i.algo={};return i}(Math),e)}(zn)),zn.exports}!function(t,n){t.exports=Jn().enc.Hex}(Hn);var Gn=Un(Hn.exports),Wn={exports:{}},Kn={exports:{}};!function(t,n){var e;t.exports=(e=Jn(),function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,u=n.algo,c=[],a=[];!function(){function n(n){for(var e=t.sqrt(n),r=2;r<=e;r++)if(!(n%r))return!1;return!0}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)n(r)&&(o<8&&(c[o]=e(t.pow(r,.5))),a[o]=e(t.pow(r,1/3)),o++),r++}();var s=[],f=u.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(t,n){for(var e=this._hash.words,r=e[0],o=e[1],i=e[2],u=e[3],c=e[4],f=e[5],p=e[6],l=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[n+h];else{var y=s[h-15],d=(y<<25|y>>>7)^(y<<14|y>>>18)^y>>>3,w=s[h-2],v=(w<<15|w>>>17)^(w<<13|w>>>19)^w>>>10;s[h]=d+s[h-7]+v+s[h-16]}var m=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),g=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&f^~c&p)+a[h]+s[h];l=p,p=f,f=c,c=u+g|0,u=i,i=o,o=r,r=g+(b+m)|0}e[0]=e[0]+r|0,e[1]=e[1]+o|0,e[2]=e[2]+i|0,e[3]=e[3]+u|0,e[4]=e[4]+c|0,e[5]=e[5]+f|0,e[6]=e[6]+p|0,e[7]=e[7]+l|0},_doFinalize:function(){var n=this._data,e=n.words,r=8*this._nDataBytes,o=8*n.sigBytes;return e[o>>>5]|=128<<24-o%32,e[14+(o+64>>>9<<4)]=t.floor(r/4294967296),e[15+(o+64>>>9<<4)]=r,n.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=i._createHelper(f),n.HmacSHA256=i._createHmacHelper(f)}(Math),e.SHA256)}(Kn);var Yn,Qn=Kn.exports,Xn=Un(Qn),Zn={exports:{}};!function(t,n){var e;t.exports=(e=Jn(),Yn||(Yn=1,function(t,n){var e,r,o;t.exports=(r=(e=Jn()).lib.Base,o=e.enc.Utf8,void(e.algo.HMAC=r.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=o.parse(n));var e=t.blockSize,r=4*e;n.sigBytes>r&&(n=t.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),u=this._iKey=n.clone(),c=i.words,a=u.words,s=0;s<e;s++)c[s]^=1549556828,a[s]^=909522486;i.sigBytes=u.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var n=this._hasher,e=n.finalize(t);return n.reset(),n.finalize(this._oKey.clone().concat(e))}})))}(Zn)),e.HmacSHA256)}(Wn);var te=Un(Wn.exports),ne=function(){function t(){}return t.sign=function(n){for(var e=n.signedHeaders.join(";"),r="",o=0,i=n.signedHeaders;o<i.length;o++){var u=i[o],c=n.headers[u];r+="".concat(u,":").concat(c,"\n")}var a=t.createHash(n.body||""),s=n.method.toUpperCase()+"\n"+n.path+"\n"+n.query+"\n"+r+"\n"+e+"\n"+a+"\n",f="HMAC-SHA256",p=t.createHash(s),l="".concat(f,"\n").concat(n.timestamp,"\n").concat(p,"\n"),h=t.createSha256(l,n.secretKey);return"".concat(f," Credential=").concat(n.secretId,", SignedHeaders=").concat(e,", Signature=").concat(h)},t.createSha256=function(t,n){return void 0===n&&(n=""),te(t,n).toString(Gn)},t.createHash=function(t){return Xn(t).toString(Gn)},t}(),ee=function(){function t(){}return t.detectRuntime=function(){return window||void 0===("undefined"==typeof my?"undefined":n(my))?window||void 0===("undefined"==typeof wx?"undefined":n(wx))?pn.WEB:pn.WEICHAT_MINI:pn.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))},t.parseUrl=function(t,n){if(n===pn.WEB)return new URL(t);var e=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=e[1],o=e[2],i=e[3],u=e[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:u||""}},t}();var re=function(){function t(t,n){this.req=t,this.config=n}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),oe=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e,o,u;return i(this,(function(i){switch(i.label){case 0:return[4,fetch(t,r({mode:"cors"},n))];case 1:return e=i.sent(),o={},e.headers.forEach((function(t,n){o[n]=t})),u={status:e.status},[4,e.json()];case 2:return[2,(u.data=i.sent(),u.headers=o,u)]}}))}))},t}(),ie=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,headers:null==n?void 0:n.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw e=r.sent(),console.error(e),new Error("error: ".concat(e.error,", message: ").concat(e.errorMessage));case 3:return[2]}}))}))},t}(),ue=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){wx.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,header:null==n?void 0:n.headers,dataType:"json",success:function(t){e({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),ce=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case pn.ALIPAY_MINI:this.singleton=new ie;break;case pn.WEB:this.singleton=new oe;break;case pn.WEICHAT_MINI:this.singleton=new ue;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function ae(t,n){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return[4,n()];case 1:return o.sent(),e=t.config.fetch||ce.default(t.config.runtime),r=t,[4,e.request(t.req.url,t.req.requestOptions)];case 2:return r.res=o.sent(),t.result={status:t.res.status,requestID:t.requestId,headers:t.res.headers,data:t.res.data},[2]}}))}))}function se(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:throw e=r.sent(),l.NETWORK_ERR(e,t.requestId);case 3:return[2]}}))}))}function fe(t){return function(n,e){return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),u=ee.parseUrl(n.req.url,n.config.runtime),c={authorization:"","x-from-app-id":n.config.appId,"x-from-env-id":n.config.envId,"x-to-env-id":n.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":n.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var e,r=null===(e=n.req.requestOptions.headers)||void 0===e?void 0:e[t];r&&(c[t]=r)})),a=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:u.pathname,query:u.search.substring(1),secretId:n.config.secretId,secretKey:n.config.secretKey,method:n.req.requestOptions.method,headers:c,body:n.req.requestOptions.body,timestamp:o,signedHeaders:a},c.authorization=ne.sign(s),n.req.requestOptions.headers=r(r({},c),n.req.requestOptions.headers),[4,e()];case 1:return i.sent(),[2]}}))}))}}var pe=function(){function t(t,n){var e;this.config=t,this.handler=(e=n,function(t,n){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var u=e[i];if(i===e.length&&(u=n),!u)return Promise.resolve();try{return Promise.resolve(u(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,u=t.headers;return o(this,void 0,void 0,(function(){var t,o,c,a;return i(this,(function(i){switch(i.label){case 0:return t=this.config.endpoint+e,o=r?JSON.stringify(r):r,c=ee.generateUUID(),u=Object.assign({"x-alipay-callid":c,"x-request-id":c,"x-alipay-source":"web,web-sdk","content-type":"application/json"},u),a=new re({url:t,requestOptions:{method:n,body:o,headers:u}},this.config),[4,this.handler(a)];case 1:return i.sent(),[2,a.result]}}))}))},t.createFunctionHttpclient=function(n){return new t(n,[se,fe(["x-to-function-name"]),ae])},t.createDatabaseHttpclient=function(n){return new t(n,[se,fe(["x-data-api-type","x-expire-timestamp"]),ae])},t.createStorageHttpclient=function(n){return new t(n,[se,fe(["x-data-api-type","x-expire-timestamp"]),ae])},t}(),le=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n=t.uploadURL,e=t.fileContent,[4,fetch(n,{method:"PUT",mode:"cors",body:e})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),he=function(t){function n(e){var r=pe.createStorageHttpclient(e),o=n.getFileUploader(e);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:e.envId})||this}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)}(n,t),n.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===pn.WEB)return le.create();throw l.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},n}(Mn),ye=function(){function t(t){var n=t.resourceEnv||t.envId,e=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(n,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:e,envId:n,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||ee.detectRuntime(),functionName:""}}return t.prototype.init=function(){},t.prototype.callFunction=function(t){var n;return o(this,void 0,void 0,(function(){var e,o;return i(this,(function(i){switch(i.label){case 0:return e=r(r({},this.config),{envId:(null===(n=t.config)||void 0===n?void 0:n.env)||this.config.envId,functionName:t.name}),o=pe.createFunctionHttpclient(e),[4,Ln.createCallFunction({type:"web",httpclient:o})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new he(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,n.sent()]}}))}))},t.RUNTIME=pn,t}();t.Cloud=ye}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/faas-web-sdk",
3
- "version": "1.1.13-alpha.2",
3
+ "version": "1.1.13-alpha.4",
4
4
  "description": "云函数服务 web SDK",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -18,7 +18,7 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@alipay/faas-common-sdk": "^1.1.13-alpha.2",
21
+ "@alipay/faas-common-sdk": "^1.1.13-alpha.4",
22
22
  "crypto-js": "^4.1.1"
23
23
  },
24
24
  "devDependencies": {