@alipay/faas-web-sdk 1.1.8-alpha.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,8 +15,8 @@ $ npm install @alipay/faas-web-sdk
15
15
  const cloud = require('@alipay/faas-web-sdk');
16
16
 
17
17
  const sdk = new cloud.Cloud({
18
- // 网关地址
19
- endpoint: 'https://{env}.api-hz.cloudbasefunction.cn', // 控制台,环境管理 - 环境概览中,网关地址
18
+ // 网关地址,可不填,默认通过 envId 拼接为 https://{envId}.api-hz.cloudbasefunction.cn
19
+ endpoint: 'https://{envId}.api-hz.cloudbasefunction.cn', // 控制台,环境管理 - 环境概览中,网关地址
20
20
  // AK
21
21
  secretId: '', // 控制台,环境管理 - 环境概览中,AK
22
22
  // SK
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).cloud={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof h?t:h,o=Object.create(a.prototype),u=new O(r||[]);return i(o,"_invoke",{value:C(e,n,u)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function h(){}function v(){}function p(){}var m={};c(m,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(P([])));g&&g!==t&&n.call(g,o)&&(m=g);var w=p.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,o,u){var s=f(e[i],e,a);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(l).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function C(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return j()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var u=_(o,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=f(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}function _(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,_(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return v.prototype=p,i(w,"constructor",{value:p,configurable:!0}),i(p,"constructor",{value:v,configurable:!0}),v.displayName=c(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,c(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(l(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},b(w),c(w,s,"Generator"),c(w,o,(function(){return this})),c(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=P,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(e,t,n,r,i,a,o){try{var u=e[a](o),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,s,"next",e)}function s(e){a(o,r,i,u,s,"throw",e)}u(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,n){return p=v()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&h(i,n.prototype),i},p.apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},m(e)}function y(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){var t=v();return function(){var n,r=d(e);if(t){var i=d(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}(this,n)}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(u)throw a}}}}function C(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function _(e,t){return function(e,t){if(t.get)return t.get.call(e);return t.value}(e,x(e,t,"get"))}function A(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,x(e,t,"set"),n),n}function x(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function O(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function P(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function j(e,t,n){P(e,t),t.set(e,n)}function S(e,t){P(e,t),t.add(e)}var M=function(){return M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},M.apply(this,arguments)};function E(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{s(r.next(e))}catch(e){a(e)}}function u(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,u)}s((r=r.apply(e,t||[])).next())}))}function R(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}"function"==typeof SuppressedError&&SuppressedError;var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var B={},I={},N={},Q={},L={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.FaasError=void 0;var t=function(e){f(n,e);var t=w(n);function n(e,r){var i;return u(this,n),l(g(i=t.call(this,r)),"httpStatus",void 0),l(g(i),"error",void 0),l(g(i),"errorMessage",void 0),l(g(i),"requestID",void 0),i.error=e,i.errorMessage=r,i}return c(n,[{key:"errCode",get:function(){return this.error}},{key:"errMsg",get:function(){return this.message}}],[{key:"INVALID_PARAM_ERR",value:function(e,t){return new n(60001,"无效入参,参数 ".concat(e," ").concat(t))}},{key:"NOT_FOUND_ERR",value:function(e){return new n(70001,e)}},{key:"SERVER_ERR",value:function(e,t,r,i){var a=new n(e,t);return a.requestID=r,a.httpStatus=i,a}},{key:"STORAGE_ERR",value:function(e,t,r){var i=new n(e,t);return i.requestID=r,i}},{key:"NETWORK_ERR",value:function(e,t){var r=new n(-1,e.toString());return r.requestID=t,r}}]),n}(m(Error));e.FaasError=t}(L);var U=["complete","success","fail"];!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ResponseUtil=e.wrapCallback=void 0;var t=L;e.wrapCallback=function(e){return function(t){if(!(null!=t&&t.complete||null!=t&&t.success||null!=t&&t.fail))return e(t);var n=t.complete,r=t.success,i=t.fail,a=y(t,U);e(a).then((function(e){return null!=r&&r(e),e}),(function(e){return null!=i&&i(e),e})).then((function(e){null==n||n(e)}))}};var n=function(){function e(){u(this,e)}return c(e,null,[{key:"handleResponse",value:function(e){if(200!==e.status){var n=e.data||{code:-1,message:"未知异常"},r=n.code,i=n.message;throw t.FaasError.SERVER_ERR(r,i,e.requestID,e.status)}return e.data.data}}]),e}();e.ResponseUtil=n}(Q),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createCallContainer=void 0;var t=Q;e.createCallContainer=function(e){var n=function(){var t=o(r().mark((function t(n){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("not implemented in "+e.type+" with "+n);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return(0,t.wrapCallback)(n)}}(N);var $={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createCallFunction=void 0;var t=L,n=Q;e.createCallFunction=function(e){var i=e.httpclient,a=function(){var e=o(r().mark((function e(n){var a,o,u,s,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.name){e.next=2;break}throw t.FaasError.INVALID_PARAM_ERR("name","缺失");case 2:return a={"x-to-function-name":n.name,"x-alipay-cloud-mode":"function"},"POST","/functions/invokeFunction",e.next=7,i.request({method:"POST",path:"/functions/invokeFunction",data:n.data,headers:a});case 7:if(200===(o=e.sent).status){e.next=12;break}throw u=-1,s="",(c=o.data)&&(u=c.errCode,s=c.errMsg,c.errDetail&&(s+=",详情:".concat(c.errDetail))),t.FaasError.SERVER_ERR(u,s,o.requestID,o.status);case 12:return e.abrupt("return",{requestID:o.requestID,result:o.data});case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(0,n.wrapCallback)(a)}}($);var W={},T={},F={},H={};Object.defineProperty(H,"__esModule",{value:!0});var G={},z={},V={},J={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateCommand=e.QueryCommand=e.UpdateCommand=e.AbstractCommand=void 0;var t=c((function e(){u(this,e)}));e.AbstractCommand=t;var n=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return c(n)}(t);e.UpdateCommand=n;var r=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return c(n)}(t);e.QueryCommand=r;var i=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return c(n)}(t);e.AggregateCommand=i}(J);var K={},Y={};!function(e){var t,n;Object.defineProperty(e,"__esModule",{value:!0}),e.DbBuildError=e.ErrorCode=void 0,(n=t||(e.ErrorCode=t={})).INVALID_PARAM="INVALID_PARAM",n.INVALID_COMMAND="INVALID_COMMAND";var r=function(e){f(r,e);var n=w(r);function r(){var e;u(this,r);for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];return l(g(e=n.call.apply(n,[this].concat(i))),"code",void 0),e}return c(r,null,[{key:"create",value:function(e,t){var n=new r(t);return n.code=e,n}},{key:"invalidParam",value:function(e,n){return r.create(t.INVALID_PARAM,'无效入参 "'.concat(e,'", ').concat(n))}},{key:"invalidCommand",value:function(e){return r.create(t.INVALID_COMMAND,e)}}]),r}(m(Error));e.DbBuildError=r}(Y),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateRequest=void 0;var t=Y,n=J,r=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"data",void 0),l(this,"prefix",void 0),this.data=t,this.prefix=n}return c(e,[{key:"stringify",value:function(){var r=this;if(this.data instanceof n.AbstractCommand){if(!(this.data instanceof n.AggregateCommand))throw t.DbBuildError.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(t,n){return new e(t,"".concat(r.prefix,".$.").concat(n)).stringify()}));switch(i(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw t.DbBuildError.invalidParam(this.prefix,"不支持函数");case"symbol":throw t.DbBuildError.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw t.DbBuildError.invalidParam(this.prefix,"不支持 undefined");default:var a={};for(var o in this.data){var u=this.prefix?"".concat(this.prefix,".").concat(o):o,s=new e(this.data[o],u);a[o]=s.stringify()}return a}}},{key:"toJSON",value:function(){return this.stringify()}}]),e}();e.AggregateRequest=r}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AndAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=e.map((function(e){return new t.AggregateRequest(e).toJSON()})),i}return c(r,[{key:"pushCommand",value:function(e){this.commands.push(new t.AggregateRequest(e).toJSON())}},{key:"stringify",value:function(){return{$and:this.commands}}}]),r}(J.AggregateCommand);e.AndAggregateCommand=n}(V);var X={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AvgAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return c(r,[{key:"stringify",value:function(){return{$avg:this.val}}}]),r}(J.AggregateCommand);e.AvgAggregateCommand=n}(X);var Z={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CountAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return c(n,[{key:"stringify",value:function(){return{$count:{}}}}]),n}(J.AggregateCommand);e.CountAggregateCommand=t}(Z);var ee={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.EqAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$eq:this.val}}}]),n}(J.AggregateCommand);e.EqAggregateCommand=t}(ee);var te,ne={},re={},ie={},ae={},oe={};function ue(){return te||(te=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AndCommand=void 0;var t=J,n=Se(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return c(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$and:this.commands}}}]),r}(t.QueryCommand);e.AndCommand=r}(oe)),oe}var se,ce={};function le(){return se||(se=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.OrCommand=void 0;var t=J,n=Se(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return c(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$or:this.commands}}}]),r}(t.QueryCommand);e.OrCommand=r}(ce)),ce}var fe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.EqCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$eq:this.val}}}]),n}(J.QueryCommand);e.EqCommand=t}(fe);var de={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NeqCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$ne:this.val}}}]),n}(J.QueryCommand);e.NeqCommand=t}(de);var he={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LtCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$lt:this.val}}}]),n}(J.QueryCommand);e.LtCommand=t}(he);var ve={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LteCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$lte:this.val}}}]),n}(J.QueryCommand);e.LteCommand=t}(ve);var pe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GtCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$gt:this.val}}}]),n}(J.QueryCommand);e.GtCommand=t}(pe);var me={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GteCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$gte:this.val}}}]),n}(J.QueryCommand);e.GteCommand=t}(me);var ye={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.InCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$in:this.val}}}]),n}(J.QueryCommand);e.InCommand=t}(ye);var ge={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NinCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$nin:this.val}}}]),n}(J.QueryCommand);e.NinCommand=t}(ge);var we={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExistsCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"exists",void 0),r.exists=e,r}return c(n,[{key:"stringify",value:function(){return{$exists:this.exists}}}]),n}(J.QueryCommand);e.ExistsCommand=t}(we);var be={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ModCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e,r){var i;return u(this,n),l(g(i=t.call(this)),"divisor",void 0),l(g(i),"remainder",void 0),i.divisor=e,i.remainder=r,i}return c(n,[{key:"stringify",value:function(){return{$mod:[this.divisor,this.remainder]}}}]),n}(J.QueryCommand);e.ModCommand=t}(be);var ke={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AllCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$all:this.val}}}]),n}(J.QueryCommand);e.AllCommand=t}(ke);var Ce,_e,Ae,xe,Oe={};function Pe(){return Ce||(Ce=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ElemMatchCommand=void 0;var t=J,n=Se(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"val",void 0),i.val=n.CommandUtils.stringify(e),i}return c(r,[{key:"stringify",value:function(){return{$elemMatch:this.val}}}]),r}(t.QueryCommand);e.ElemMatchCommand=r}(Oe)),Oe}function je(){return _e||(_e=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryChain=void 0;var t=ue(),n=le(),r=fe,i=de,a=he,o=ve,s=pe,f=me,d=ye,h=ge,v=we,p=be,m=ke,y=Pe(),g=Se(),w=new WeakSet,b=function(){function e(t){u(this,e),S(this,w),l(this,"lastCmd",void 0),this.lastCmd=t}return c(e,[{key:"and",value:function(e){return O(this,w,k).call(this,e)}},{key:"or",value:function(e){return e=g.CommandUtils.unchain(e),this.lastCmd instanceof n.OrCommand?this.lastCmd.pushCommand(e):this.lastCmd=new n.OrCommand([this.lastCmd,e]),this}},{key:"not",value:function(e){return O(this,w,k).call(this,e)}},{key:"nor",value:function(e){return O(this,w,k).call(this,e)}},{key:"eq",value:function(e){return O(this,w,k).call(this,new r.EqCommand(e))}},{key:"neq",value:function(e){return O(this,w,k).call(this,new i.NeqCommand(e))}},{key:"lt",value:function(e){return O(this,w,k).call(this,new a.LtCommand(e))}},{key:"lte",value:function(e){return O(this,w,k).call(this,new o.LteCommand(e))}},{key:"gt",value:function(e){return O(this,w,k).call(this,new s.GtCommand(e))}},{key:"gte",value:function(e){return O(this,w,k).call(this,new f.GteCommand(e))}},{key:"in",value:function(e){return O(this,w,k).call(this,new d.InCommand(e))}},{key:"nin",value:function(e){return O(this,w,k).call(this,new h.NinCommand(e))}},{key:"exists",value:function(e){return O(this,w,k).call(this,new v.ExistsCommand(e))}},{key:"mod",value:function(e,t){return O(this,w,k).call(this,new p.ModCommand(e,t))}},{key:"all",value:function(e){return O(this,w,k).call(this,new m.AllCommand(e))}},{key:"elemMatch",value:function(e){return O(this,w,k).call(this,new y.ElemMatchCommand(g.CommandUtils.unchain(e)))}},{key:"size",value:function(e){return O(this,w,k).call(this,e)}}]),e}();function k(e){return e=g.CommandUtils.unchain(e),this.lastCmd instanceof t.AndCommand?this.lastCmd.pushCommand(e):this.lastCmd=new t.AndCommand([this.lastCmd,e]),this}e.QueryChain=b}(ae)),ae}function Se(){return Ae||(Ae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CommandUtils=void 0;var t=J,n=Me(),r=je(),i=function(){function e(){u(this,e)}return c(e,null,[{key:"stringify",value:function(r){return(r=e.unchain(r))instanceof t.QueryCommand?r.stringify():new n.QueryRequest(r).toJSON()}},{key:"unchain",value:function(e){return e instanceof r.QueryChain?e.lastCmd:e}}]),e}();e.CommandUtils=i}(ie)),ie}function Me(){return xe||(xe=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryRequest=void 0;var t=J,n=Y,r=Se(),a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"query",void 0),l(this,"prefix",void 0),this.query=t,this.prefix=n}return c(e,[{key:"stringify",value:function(){var a=this,o={},u=r.CommandUtils.unchain(this.query),s=i(u);if(u instanceof t.QueryCommand)return u.stringify();if(Array.isArray(u))return u.map((function(t,n){return new e(t,"".concat(a.prefix,".$.").concat(n)).stringify()}));if("number"===s)return u;if("boolean"===s)return u;if("string"===s)return u;if("bigint"===s)return u;if("function"===s)throw n.DbBuildError.invalidParam(this.prefix,"不支持函数");if("symbol"===s)throw n.DbBuildError.invalidParam(this.prefix,"不支持 symbol");if("undefined"===s)throw n.DbBuildError.invalidParam(this.prefix,"不支持 undefined");if(null===u)return u;for(var c in u){var l=this.prefix?"".concat(this.prefix,".").concat(c):c,f=new e(u[c],l);o[c]=f.stringify()}return o}},{key:"toJSON",value:function(){return this.stringify()}}]),e}();e.QueryRequest=a}(re)),re}var Ee={};!function(e){var t,n,r,i,a,o;Object.defineProperty(e,"__esModule",{value:!0}),e.PipelineStageName=e.Target=e.DocumentAction=e.CollectionAction=e.Sort=void 0,(n=t||(e.Sort=t={})).DESC="desc",n.ASC="asc",function(e){e.update="update",e.delete="delete",e.query="query",e.queryList="queryList",e.create="create"}(r||(e.CollectionAction=r={})),function(e){e.update="update",e.replace="replace",e.delete="delete",e.query="query",e.queryList="queryList",e.create="create",e.batchCreate="batchCreate",e.count="count",e.aggregate="aggregate"}(i||(e.DocumentAction=i={})),function(e){e.collection="collection",e.document="document"}(a||(e.Target=a={})),function(e){e.match="$match",e.group="$group",e.sample="$sample",e.lookup="$lookup"}(o||(e.PipelineStageName=o={}))}(Ee),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregatePipeline=void 0;var t=K,n=Me(),r=Ee,i=Y,a=new WeakMap,o=new WeakSet,s=function(){function e(){u(this,e),S(this,o),j(this,a,{writable:!0,value:void 0}),A(this,a,[])}return c(e,[{key:"match",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.match,e),this}},{key:"group",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.group,e),this}},{key:"sample",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.sample,e),this}},{key:"lookup",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.lookup,e),this}},{key:"done",value:function(){return _(this,a).map((function(e){switch(e.name){case r.PipelineStageName.match:return{$match:new n.QueryRequest(e.param).toJSON()};case r.PipelineStageName.sample:case r.PipelineStageName.lookup:return l({},e.name,e.param);case r.PipelineStageName.group:return{$group:new t.AggregateRequest(e.param).toJSON()};default:var a=e.name;throw i.DbBuildError.invalidParam(a,"不支持的 aggregate 操作")}}))}}]),e}();function f(e,t){_(this,a).push({name:e,param:t})}e.AggregatePipeline=s}(ne);var Re={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExprCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=new t.AggregateRequest(e).toJSON(),i}return c(r,[{key:"stringify",value:function(){return{$expr:this.commands}}}]),r}(J.QueryCommand);e.ExprCommand=n}(Re);var De={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GtAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$gt:this.val}}}]),n}(J.AggregateCommand);e.GtAggregateCommand=t}(De);var qe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GteAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$gte:this.val}}}]),n}(J.AggregateCommand);e.GteAggregateCommand=t}(qe);var Be={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LtAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$lt:this.val}}}]),n}(J.AggregateCommand);e.LtAggregateCommand=t}(Be);var Ie={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LteAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$lte:this.val}}}]),n}(J.AggregateCommand);e.LteAggregateCommand=t}(Ie);var Ne={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MaxAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return c(r,[{key:"stringify",value:function(){return{$max:this.val}}}]),r}(J.AggregateCommand);e.MaxAggregateCommand=n}(Ne);var Qe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MinAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return c(r,[{key:"stringify",value:function(){return{$min:this.val}}}]),r}(J.AggregateCommand);e.MinAggregateCommand=n}(Qe);var Le={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NeqAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$ne:this.val}}}]),n}(J.AggregateCommand);e.NeqAggregateCommand=t}(Le);var Ue={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.OrAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=e.map((function(e){return new t.AggregateRequest(e).toJSON()})),i}return c(r,[{key:"pushCommand",value:function(e){this.commands.push(new t.AggregateRequest(e).toJSON())}},{key:"stringify",value:function(){return{$or:this.commands}}}]),r}(J.AggregateCommand);e.OrAggregateCommand=n}(Ue);var $e={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SumAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return c(r,[{key:"stringify",value:function(){return{$sum:this.val}}}]),r}(J.AggregateCommand);e.SumAggregateCommand=n}($e);var We={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SetCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"data",void 0),r.data=e,r}return c(n,[{key:"operator",get:function(){return"$set"}},{key:"stringify",value:function(){return this.data}}]),n}(J.UpdateCommand);e.SetCommand=t}(We);var Te={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.IncCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"num",void 0),r.num=e,r}return c(n,[{key:"operator",get:function(){return"$inc"}},{key:"stringify",value:function(){return this.num}}]),n}(J.UpdateCommand);e.IncCommand=t}(Te);var Fe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NotCommand=void 0;var t=J,n=Se(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"command",void 0),i.command=n.CommandUtils.stringify(e),i}return c(r,[{key:"stringify",value:function(){return{$not:this.command.stringify()}}}]),r}(t.QueryCommand);e.NotCommand=r}(Fe);var He={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NorCommand=void 0;var t=J,n=Se(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return c(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$nor:this.commands}}}]),r}(t.QueryCommand);e.NorCommand=r}(He);var Ge={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SizeCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return c(n,[{key:"stringify",value:function(){return{$size:this.val}}}]),n}(J.QueryCommand);e.SizeCommand=t}(Ge),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Command=e.AggregateCommandFactory=void 0;var t=V,n=X,r=Z,i=ee,a=ne,o=Re,s=De,f=qe,d=Be,h=Ie,v=Ne,p=Qe,m=Le,y=Ue,g=$e,w=We,b=Te,k=je(),C=le(),_=ue(),A=Se(),x=Fe,O=He,P=fe,j=de,S=he,M=ve,E=pe,R=me,D=ye,q=ge,B=we,I=be,N=ke,Q=Pe(),L=Ge,U=function(){function e(){u(this,e)}return c(e,[{key:"pipeline",value:function(){return new a.AggregatePipeline}},{key:"avg",value:function(e){return new n.AvgAggregateCommand(e)}},{key:"count",value:function(){return new r.CountAggregateCommand}},{key:"max",value:function(e){return new v.MaxAggregateCommand(e)}},{key:"min",value:function(e){return new p.MinAggregateCommand(e)}},{key:"sum",value:function(e){return new g.SumAggregateCommand(e)}},{key:"and",value:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n=Array.isArray(n[0])?n[0]:n,new t.AndAggregateCommand(n)}},{key:"or",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new y.OrAggregateCommand(t)}},{key:"eq",value:function(e){return new i.EqAggregateCommand(e)}},{key:"neq",value:function(e){return new m.NeqAggregateCommand(e)}},{key:"lt",value:function(e){return new d.LtAggregateCommand(e)}},{key:"lte",value:function(e){return new h.LteAggregateCommand(e)}},{key:"gt",value:function(e){return new s.GtAggregateCommand(e)}},{key:"gte",value:function(e){return new f.GteAggregateCommand(e)}}]),e}();e.AggregateCommandFactory=U;var $=function(){function e(){u(this,e),l(this,"aggregate",void 0),this.aggregate=new U}return c(e,[{key:"set",value:function(e){return new w.SetCommand(e)}},{key:"inc",value:function(e){return new b.IncCommand(e)}},{key:"expr",value:function(e){return new o.ExprCommand(e)}},{key:"and",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new _.AndCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"or",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new C.OrCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"not",value:function(e){var t=new x.NotCommand(A.CommandUtils.unchain(e));return new k.QueryChain(t)}},{key:"nor",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new O.NorCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"eq",value:function(e){return new k.QueryChain(new P.EqCommand(e))}},{key:"neq",value:function(e){return new k.QueryChain(new j.NeqCommand(e))}},{key:"lt",value:function(e){return new k.QueryChain(new S.LtCommand(e))}},{key:"lte",value:function(e){return new k.QueryChain(new M.LteCommand(e))}},{key:"gt",value:function(e){return new k.QueryChain(new E.GtCommand(e))}},{key:"gte",value:function(e){return new k.QueryChain(new R.GteCommand(e))}},{key:"in",value:function(e){return new k.QueryChain(new D.InCommand(e))}},{key:"nin",value:function(e){return new k.QueryChain(new q.NinCommand(e))}},{key:"exists",value:function(e){return new k.QueryChain(new B.ExistsCommand(e))}},{key:"mod",value:function(e,t){return new k.QueryChain(new I.ModCommand(e,t))}},{key:"all",value:function(e){return new k.QueryChain(new N.AllCommand(e))}},{key:"elemMatch",value:function(e){return new k.QueryChain(new Q.ElemMatchCommand(A.CommandUtils.unchain(e)))}},{key:"size",value:function(e){return new k.QueryChain(new L.SizeCommand(e))}}]),e}();e.Command=$}(z);var ze={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ActionBuilder=void 0;var t=Ee,n=function(){function e(){u(this,e)}return c(e,null,[{key:"buildCollectionAction",value:function(e,n){return{target:t.Target.collection,action:e,collectionName:n}}},{key:"buildCollectionListQueryAction",value:function(e){return{target:t.Target.collection,action:t.CollectionAction.queryList,options:e}}},{key:"buildDocumentAction",value:function(e,n,r){return{target:t.Target.document,action:e,collectionName:n,options:r}}}]),e}();e.ActionBuilder=n}(ze);var Ve={},Je={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateBuilder=void 0;var t=ne,n=Ee,r=ze,i=new WeakMap,a=function(e){f(a,e);var t=w(a);function a(e){var n;return u(this,a),j(g(n=t.call(this)),i,{writable:!0,value:void 0}),A(g(n),i,e),n}return c(a,[{key:"end",value:function(){var e={$aggregate:this.done()};return r.ActionBuilder.buildDocumentAction(n.DocumentAction.aggregate,_(this,i),e)}}]),a}(t.AggregatePipeline);e.AggregateBuilder=a}(Je);var Ke={},Ye={},Xe={},Ze={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Operator=void 0;var t=function(){function e(){u(this,e),l(this,"res",void 0),this.res={}}return c(e,[{key:"set",value:function(e,t){this.res.$set=this.res.$set||{},this.res.$set[e]=t}},{key:"applyOperator",value:function(e,t,n){this.res[e]=this.res[e]||{},this.res[e][t]=n}},{key:"emit",value:function(){return this.res}}]),e}();e.Operator=t}(Ze),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateRequest=void 0;var t=Y,n=J,r=Ze,a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"data",void 0),l(this,"prefix",void 0),this.data=t,this.prefix=n}return c(e,[{key:"stringify",value:function(a){for(var o in a=a||new r.Operator,this.data){var u=this.prefix?"".concat(this.prefix,".").concat(o):o,s=this.data[o],c=i(s);if(s instanceof n.AbstractCommand){if(!(s instanceof n.UpdateCommand))throw t.DbBuildError.invalidCommand("Command 不是更新操作");a.applyOperator(s.operator,u,s.stringify())}else if("number"===c)a.set(u,s);else if("boolean"===c)a.set(u,s);else if("string"===c)a.set(u,s);else if("bigint"===c)a.set(u,s);else{if("function"===c)throw t.DbBuildError.invalidParam(u,"不支持函数");if("symbol"===c)throw t.DbBuildError.invalidParam(u,"不支持 symbol");if("undefined"===c)throw t.DbBuildError.invalidParam(u,"不支持 undefined");null===s||Array.isArray(s)?a.set(u,s):new e(s,u).stringify(a)}}return a}},{key:"toJSON",value:function(){return this.stringify().emit()}}]),e}();e.UpdateRequest=a}(Xe),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryBuilder=void 0;var t=Me(),r=Xe,a=Ee,o=ze,s=new WeakMap,l=new WeakMap,f=new WeakMap,d=new WeakMap,h=new WeakMap,v=new WeakMap,p=new WeakSet,m=new WeakSet,y=new WeakSet,g=function(){function e(t){u(this,e),S(this,y),S(this,m),S(this,p),j(this,s,{writable:!0,value:void 0}),j(this,l,{writable:!0,value:void 0}),j(this,f,{writable:!0,value:void 0}),j(this,d,{writable:!0,value:void 0}),j(this,h,{writable:!0,value:void 0}),j(this,v,{writable:!0,value:void 0}),A(this,v,t),A(this,d,[])}return c(e,[{key:"limit",value:function(e){return A(this,l,e),this}},{key:"skip",value:function(e){return A(this,f,e),this}},{key:"where",value:function(e){return A(this,s,e),this}},{key:"projection",value:function(e){for(var t in e)e[t]?"object"!=i(e[t])&&(e[t]=1):e[t]=0;return A(this,h,e),this}},{key:"orderBy",value:function(e,t){return _(this,d).push({field:e,sort:t}),this}},{key:"update",value:function(e){return O(this,y,C).call(this,a.DocumentAction.update,n(n({},O(this,p,w).call(this)),{},{$update:new r.UpdateRequest(e.data).toJSON()}))}},{key:"set",value:function(e){return O(this,y,C).call(this,a.DocumentAction.replace,n(n({},O(this,p,w).call(this)),{},{$replace:e.data}))}},{key:"remove",value:function(){return O(this,y,C).call(this,a.DocumentAction.delete,O(this,p,w).call(this))}},{key:"get",value:function(){return O(this,y,C).call(this,a.DocumentAction.queryList,n({$limit:100},O(this,m,b).call(this)))}},{key:"count",value:function(){return O(this,y,C).call(this,a.DocumentAction.count,O(this,p,w).call(this))}}]),e}();function w(){var e={};if(i(_(this,s))<"u"){var n=new t.QueryRequest(_(this,s));e.$match=n.toJSON()}return i(_(this,l))<"u"&&(e.$limit=_(this,l)),e}function b(){var e=O(this,p,w).call(this);if(i(_(this,h))<"u"&&(e.$project=_(this,h)),i(_(this,d))<"u"){e.$sort={};var t,n=k(_(this,d));try{for(n.s();!(t=n.n()).done;){var r=t.value;e.$sort[r.field]=r.sort===a.Sort.DESC?-1:1}}catch(e){n.e(e)}finally{n.f()}}return i(_(this,f))<"u"&&(e.$skip=_(this,f)),e}function C(e,t){return o.ActionBuilder.buildDocumentAction(e,_(this,v),t)}e.QueryBuilder=g}(Ye),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DocumentBuilder=void 0;var t=Ee,n=Ye,r=new WeakMap,i=new WeakMap,a=function(){function e(t,n){u(this,e),j(this,r,{writable:!0,value:void 0}),j(this,i,{writable:!0,value:void 0}),A(this,i,t),A(this,r,n)}return c(e,[{key:"update",value:function(e){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).update(e)}},{key:"set",value:function(e){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).set(e)}},{key:"remove",value:function(){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).remove()}},{key:"get",value:function(){var e=new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).get();return e.action=t.DocumentAction.query,e}}]),e}();e.DocumentBuilder=a}(Ke),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CollectionBuilder=void 0;var t=Ee,n=Y,r=ze,i=Je,a=Ke,o=Ye,s=new WeakMap,l=function(){function e(t){u(this,e),j(this,s,{writable:!0,value:void 0}),A(this,s,t)}return c(e,[{key:"add",value:function(e){return Array.isArray(e.data)?this.batchAdd(e):r.ActionBuilder.buildDocumentAction(t.DocumentAction.create,_(this,s),e.data)}},{key:"batchAdd",value:function(e){if(e.data.length>200)throw n.DbBuildError.invalidParam("data","最大长度 200");var i={$create:e.data};return"boolean"==typeof e.ordered&&(i.$ordered=e.ordered),r.ActionBuilder.buildDocumentAction(t.DocumentAction.batchCreate,_(this,s),i)}},{key:"doc",value:function(e){return new a.DocumentBuilder(_(this,s),e)}},{key:"limit",value:function(e){return new o.QueryBuilder(_(this,s)).limit(e)}},{key:"skip",value:function(e){return new o.QueryBuilder(_(this,s)).skip(e)}},{key:"where",value:function(e){return new o.QueryBuilder(_(this,s)).where(e)}},{key:"projection",value:function(e){return new o.QueryBuilder(_(this,s)).projection(e)}},{key:"orderBy",value:function(e,t){return new o.QueryBuilder(_(this,s)).orderBy(e,t)}},{key:"aggregate",value:function(){return new i.AggregateBuilder(_(this,s))}},{key:"get",value:function(){return new o.QueryBuilder(_(this,s)).get()}},{key:"count",value:function(){return new o.QueryBuilder(_(this,s)).count()}}]),e}();e.CollectionBuilder=l}(Ve),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MongoBuilder=void 0;var t=z,n=Ee,r=ze,i=Ve,a=function(){function e(){u(this,e),l(this,"command",void 0),this.command=new t.Command}return c(e,[{key:"collection",value:function(e){return new i.CollectionBuilder(e)}},{key:"createCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.create,e)}},{key:"getCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.query,e)}},{key:"listCollection",value:function(e,t){return r.ActionBuilder.buildCollectionListQueryAction({$limit:null!=e?e:10,$skip:null!=t?t:0})}},{key:"deleteCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.delete,e)}}]),e}();e.MongoBuilder=a}(G),function(e){var t=D&&D.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=D&&D.__exportStar||function(e,n){for(var r in e)"default"!==r&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.DbBuildError=e.CommandUtils=e.Command=e.AggregateRequest=e.UpdateRequest=e.QueryRequest=e.AggregateBuilder=e.QueryBuilder=e.DocumentBuilder=e.CollectionBuilder=e.MongoBuilder=void 0,n(H,e);var r=G;Object.defineProperty(e,"MongoBuilder",{enumerable:!0,get:function(){return r.MongoBuilder}});var i=Ve;Object.defineProperty(e,"CollectionBuilder",{enumerable:!0,get:function(){return i.CollectionBuilder}});var a=Ke;Object.defineProperty(e,"DocumentBuilder",{enumerable:!0,get:function(){return a.DocumentBuilder}});var o=Ye;Object.defineProperty(e,"QueryBuilder",{enumerable:!0,get:function(){return o.QueryBuilder}});var u=Je;Object.defineProperty(e,"AggregateBuilder",{enumerable:!0,get:function(){return u.AggregateBuilder}});var s=Me();Object.defineProperty(e,"QueryRequest",{enumerable:!0,get:function(){return s.QueryRequest}});var c=Xe;Object.defineProperty(e,"UpdateRequest",{enumerable:!0,get:function(){return c.UpdateRequest}});var l=K;Object.defineProperty(e,"AggregateRequest",{enumerable:!0,get:function(){return l.AggregateRequest}});var f=z;Object.defineProperty(e,"Command",{enumerable:!0,get:function(){return f.Command}});var d=Se();Object.defineProperty(e,"CommandUtils",{enumerable:!0,get:function(){return d.CommandUtils}});var h=Y;Object.defineProperty(e,"DbBuildError",{enumerable:!0,get:function(){return h.DbBuildError}}),n(Ee,e)}(F);var et={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Aggregate=void 0;var t=F,n=Q,i=new WeakMap,a=new WeakMap,s=new WeakMap,l=new WeakSet,f=function(){function e(n,r){u(this,e),S(this,l),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,s,{writable:!0,value:void 0}),A(this,a,n),A(this,i,r),A(this,s,new t.AggregateBuilder(n))}var f;return c(e,[{key:"match",value:function(e){return _(this,s).match(e),this}},{key:"group",value:function(e){return _(this,s).group(e),this}},{key:"sample",value:function(e){return _(this,s).sample(e),this}},{key:"lookup",value:function(e){return _(this,s).lookup(e),this}},{key:"end",value:(f=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=_(this,s).end(),a=t.options,o="".concat(O(this,l,d).call(this),"?aggregate"),e.next=6,_(this,i).httpclient.request({method:"POST",path:o,data:a});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})}]),e}();function d(){return"/".concat(_(this,i).databaseName||"faas","/").concat(_(this,a))}e.Aggregate=f}(et);var tt={},nt={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Query=void 0;var t=F,n=Q,i=new WeakMap,a=new WeakMap,s=new WeakMap,l=new WeakSet,f=function(){function e(n,r){u(this,e),S(this,l),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,s,{writable:!0,value:void 0}),A(this,a,n),A(this,i,r),A(this,s,new t.QueryBuilder(n))}var f,h,v,p,m;return c(e,[{key:"limit",value:function(e){return _(this,s).limit(e),this}},{key:"skip",value:function(e){return _(this,s).skip(e),this}},{key:"where",value:function(e){return _(this,s).where(e),this}},{key:"projection",value:function(e){return _(this,s).projection(e),this}},{key:"field",value:function(e){return _(this,s).projection(e),this}},{key:"orderBy",value:function(e,t){return _(this,s).orderBy(e,t),this}},{key:"update",value:(m=o(r().mark((function e(t){var a,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a="".concat(O(this,l,d).call(this),"?update"),o=_(this,s).update(t),u=o.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:a,data:u});case 6:return c=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(c));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"set",value:(p=o(r().mark((function e(t){var a,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a="".concat(O(this,l,d).call(this),"?replace"),o=_(this,s).set(t),u=o.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:a,data:u});case 6:return c=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(c));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"remove",value:(v=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?delete"),a=_(this,s).remove(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"get",value:(h=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?query"),a=_(this,s).get(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"count",value:(f=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?count"),a=_(this,s).count(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",{total:n.ResponseUtil.handleResponse(u).count});case 8:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})}]),e}();function d(){return"/".concat(_(this,i).databaseName||"faas","/").concat(_(this,a))}e.Query=f}(nt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Document=void 0;var t=L,n=nt,i=new WeakMap,a=new WeakMap,s=new WeakMap,l=new WeakMap,f=function(){function e(t,n,r){u(this,e),j(this,l,{get:d,set:void 0}),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,s,{writable:!0,value:void 0}),A(this,a,t),A(this,s,n),A(this,i,r)}var n,f,h,v;return c(e,[{key:"update",value:(v=o(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).update(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"set",value:(h=o(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).set(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"remove",value:(f=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).remove();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"get",value:(n=o(r().mark((function e(){var n;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).get();case 2:if(n=e.sent[0]){e.next=7;break}if(!_(this,i).throwOnNotFound){e.next=6;break}throw t.FaasError.NOT_FOUND_ERR("不存在_id 为 ".concat(_(this,s)," 的文档"));case 6:return e.abrupt("return",null);case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})}]),e}();function d(){return new n.Query(_(this,a),_(this,i)).where({_id:String(_(this,s))}).limit(1)}e.Document=f}(tt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Collection=void 0;var t=F,n=Q,i=et,a=tt,s=nt,f=new WeakMap,d=new WeakMap,h=new WeakSet,v=function(){function e(n,r){u(this,e),S(this,h),j(this,f,{writable:!0,value:void 0}),j(this,d,{writable:!0,value:void 0}),l(this,"builder",void 0),A(this,d,n),A(this,f,r),this.builder=new t.CollectionBuilder(n)}var v,m,y;return c(e,[{key:"add",value:(y=o(r().mark((function e(t){var i,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.builder.add(t),a=i.options,o=O(this,h,p).call(this,t.data._id),e.next=6,_(this,f).httpclient.request({method:"POST",path:o,data:a});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"doc",value:function(e){return new a.Document(_(this,d),e,_(this,f))}},{key:"limit",value:function(e){return new s.Query(_(this,d),_(this,f)).limit(e)}},{key:"skip",value:function(e){return new s.Query(_(this,d),_(this,f)).skip(e)}},{key:"where",value:function(e){return new s.Query(_(this,d),_(this,f)).where(e)}},{key:"projection",value:function(e){return new s.Query(_(this,d),_(this,f)).projection(e)}},{key:"field",value:function(e){return new s.Query(_(this,d),_(this,f)).field(e)}},{key:"orderBy",value:function(e,t){return new s.Query(_(this,d),_(this,f)).orderBy(e,t)}},{key:"aggregate",value:function(){return new i.Aggregate(_(this,d),_(this,f))}},{key:"get",value:(m=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new s.Query(_(this,d),_(this,f)).get();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"count",value:(v=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new s.Query(_(this,d),_(this,f)).count();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})}]),e}();function p(e){return"/".concat(_(this,f).databaseName||"faas","/").concat(_(this,d),"?_id=").concat(e||"")}e.Collection=v}(T),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Database=void 0;var t=T,i=new WeakMap,a=function(){function e(t){u(this,e),j(this,i,{writable:!0,value:void 0}),A(this,i,t)}var t;return c(e,[{key:"request",value:(t=o(r().mark((function e(t){var a,o,u,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.method,o=t.path,u=t.data,s=t.headers,e.next=3,_(this,i).request({method:a,path:o,data:u,headers:n({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},s)});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),s=new WeakMap,f=function(){function e(t){u(this,e),j(this,s,{writable:!0,value:void 0}),l(this,"command",void 0),A(this,s,n(n({},t),{},{httpclient:new a(t.httpclient)}))}return c(e,[{key:"collection",value:function(e){return new t.Collection(e,_(this,s))}}]),e}();e.Database=f}(W);var rt={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Storage=void 0;var t=L,i=Q,a=new WeakMap,s=new WeakSet,l=new WeakSet,f=new WeakSet,d=new WeakSet,h=new WeakSet,v=new WeakSet,p=new WeakSet,m=new WeakSet,y=new WeakSet,g=function(){function e(t){u(this,e),S(this,y),S(this,m),S(this,p),S(this,v),S(this,h),S(this,d),S(this,f),S(this,l),S(this,s),j(this,a,{writable:!0,value:void 0}),A(this,a,t)}var n,g,q,B;return c(e,[{key:"uploadFile",value:(B=o(r().mark((function e(n){var o,u,c,l,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=O(this,h,P).call(this,n.cloudPath))){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("cloudPath",o);case 3:return u=O(this,s,w).call(this,n.cloudPath.trim()),e.next=6,O(this,y,D).call(this,{method:"GET",path:u});case 6:return c=e.sent,l=i.ResponseUtil.handleResponse(c),f=O(this,p,E).call(this,l.file_id),e.next=11,_(this,a).fileUploader.upload({fileID:f,uploadURL:l.upload_url,fileContent:n.fileContent});case 11:if(200===(d=e.sent).statusCode){e.next=14;break}throw t.FaasError.STORAGE_ERR(-1,"文件下载失败",c.requestID);case 14:return e.abrupt("return",{fileID:f,statusCode:d.statusCode});case 15:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"downloadFile",value:(q=o(r().mark((function e(n){var o,u,s,c,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=O(this,v,M).call(this,n.fileID))){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",o);case 3:return u=O(this,m,R).call(this,n.fileID),s=O(this,l,b).call(this,u),e.next=7,O(this,y,D).call(this,{method:"GET",path:s});case 7:return c=e.sent,f=i.ResponseUtil.handleResponse(c),e.next=11,_(this,a).fileUploader.download({fileID:n.fileID,downloadURL:f.download_url});case 11:if(200===(d=e.sent).statusCode){e.next=14;break}throw t.FaasError.STORAGE_ERR(-1,"文件下载失败",c.requestID);case 14:return e.abrupt("return",d);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"deleteFile",value:(g=o(r().mark((function e(n){var a,o,u,s,c,l,d,h,g,w=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Array.isArray(n)?n:n.fileList,Array.isArray(a)&&0!==a.length){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");case 3:o=[],u=k(a),e.prev=5,u.s();case 7:if((s=u.n()).done){e.next=16;break}if(c=s.value,!(l=O(this,v,M).call(this,c))){e.next=12;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",l);case 12:d=O(this,m,R).call(this,c),o.push(d);case 14:e.next=7;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(5),u.e(e.t0);case 21:return e.prev=21,u.f(),e.finish(21);case 24:return h=O(this,f,C).call(this),e.next=27,O(this,y,D).call(this,{method:"POST",path:h,data:{file_list:o}});case 27:return g=e.sent,e.abrupt("return",{fileList:i.ResponseUtil.handleResponse(g).file_list.map((function(e){return{fileID:O(w,p,E).call(w,e.file_id),status:e.status?0:-1,errMsg:e.status?"ok":e.result_message}}))});case 29:case"end":return e.stop()}}),e,this,[[5,18,21,24]])}))),function(e){return g.apply(this,arguments)})},{key:"getTempFileURL",value:(n=o(r().mark((function e(n){var a,o,u,s,c,l,f,h,g,w=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Array.isArray(n)?n:n.fileList,Array.isArray(a)&&0!==a.length){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");case 3:if(!(a.length>50)){e.next=5;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","最大长度 50");case 5:o=[],u=k(a),e.prev=7,u.s();case 9:if((s=u.n()).done){e.next=18;break}if(c=s.value,!(l=O(this,v,M).call(this,c))){e.next=14;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",l);case 14:f=O(this,m,R).call(this,c),o.push({file_id:f,expire:600});case 16:e.next=9;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(7),u.e(e.t0);case 23:return e.prev=23,u.f(),e.finish(23);case 26:return h=O(this,d,x).call(this),e.next=29,O(this,y,D).call(this,{method:"POST",path:h,data:{file_list:o}});case 29:return g=e.sent,e.abrupt("return",{fileList:i.ResponseUtil.handleResponse(g).file_list.map((function(e){return{fileID:O(w,p,E).call(w,e.file_id),tempFileURL:e.download_url,status:e.status?0:-1,errMsg:e.status?"ok":e.result_message}}))});case 31:case"end":return e.stop()}}),e,this,[[7,20,23,26]])}))),function(e){return n.apply(this,arguments)})}]),e}();function w(e){return"/".concat(e,"?upload_url")}function b(e){return"/".concat(e,"?download_url&expire=3600")}function C(){return"/?delete"}function x(){return"/?download_url"}function P(e){return"string"!=typeof e?"必须为字符串":(e=e.trim())?e.startsWith("/")?"不能以 / 开头":e.includes("//")?"不能包含连续的 /":e.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"}function M(e){return"string"!=typeof e?"必须为字符串":(e=e.trim())?void 0:"不能为空字符串"}function E(e){return"cloud://".concat(_(this,a).toEnvId,"/").concat(e.replace(/^\/+/,""))}function R(e){var n=e.trim().replace(/^cloud:\/\//,""),r=n.indexOf("/");if(r<=0)throw t.FaasError.INVALID_PARAM_ERR("fileID","不合法");var i=n.substring(0,r),o=n.substring(r+1);return i!==_(this,a).toEnvId&&console.warn("file ".concat(e," does not belong to env ").concat(_(this,a).toEnvId)),o}function D(e){return q.apply(this,arguments)}function q(){return(q=o(r().mark((function e(t){var i,o,u,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.method,o=t.path,u=t.data,s=t.headers,e.next=3,_(this,a).httpclient.request({method:i,path:o,data:u,headers:n({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},s)});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}e.Storage=g}(rt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WebSDK=void 0;var t=N,n=$,r=W,i=rt,a=function(){function e(){u(this,e)}return c(e,null,[{key:"createCallFunction",value:function(e){return(0,n.createCallFunction)(e)}},{key:"createCallContainer",value:function(e){return(0,t.createCallContainer)(e)}},{key:"createDatabase",value:function(e){return new r.Database(e)}},{key:"createStorage",value:function(e){return new i.Storage(e)}}]),e}();e.WebSDK=a}(I);var it={};Object.defineProperty(it,"__esModule",{value:!0}),function(e){var t=D&&D.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=D&&D.__exportStar||function(e,n){for(var r in e)"default"!==r&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.ResponseUtil=e.FaasError=e.Query=e.Aggregate=e.Collection=e.Document=e.Database=e.Storage=e.WebSDK=void 0;var r=I;Object.defineProperty(e,"WebSDK",{enumerable:!0,get:function(){return r.WebSDK}});var i=rt;Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return i.Storage}});var a=W;Object.defineProperty(e,"Database",{enumerable:!0,get:function(){return a.Database}});var o=tt;Object.defineProperty(e,"Document",{enumerable:!0,get:function(){return o.Document}});var u=T;Object.defineProperty(e,"Collection",{enumerable:!0,get:function(){return u.Collection}});var s=et;Object.defineProperty(e,"Aggregate",{enumerable:!0,get:function(){return s.Aggregate}});var c=nt;Object.defineProperty(e,"Query",{enumerable:!0,get:function(){return c.Query}});var l=L;Object.defineProperty(e,"FaasError",{enumerable:!0,get:function(){return l.FaasError}});var f=Q;Object.defineProperty(e,"ResponseUtil",{enumerable:!0,get:function(){return f.ResponseUtil}}),n(it,e)}(B);var at={exports:{}};var ot,ut={exports:{}};function st(){return ot||(ot=1,function(e,t){var n;e.exports=(n=n||function(e,t){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!==D&&D.crypto&&(n=D.crypto),!n)try{n=require("crypto")}catch(e){}var r=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},o=a.lib={},u=o.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=u.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var a=0;a<i;a++){var o=n[a>>>2]>>>24-a%4*8&255;t[r+a>>>2]|=o<<24-(r+a)%4*8}else for(var u=0;u<i;u+=4)t[r+u>>>2]=n[u>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new s.init(t,e)}}),c=a.enc={},l=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push((a>>>4).toString(16)),r.push((15&a).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},f=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},d=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,a=r.sigBytes,o=this.blockSize,u=a/(4*o),c=(u=t?e.ceil(u):e.max((0|u)-this._minBufferSize,0))*o,l=e.min(4*c,a);if(c){for(var f=0;f<c;f+=o)this._doProcessBlock(i,f);n=i.splice(0,c),r.sigBytes-=l}return new s.init(n,l)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=h.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new v.HMAC.init(e,n).finalize(t)}}});var v=a.algo={};return a}(Math),n)}(ut)),ut.exports}!function(e,t){e.exports=st().enc.Hex}(at);var ct=q(at.exports),lt={exports:{}},ft={exports:{}};!function(e,t){var n;e.exports=(n=st(),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,u=[],s=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(u[i]=n(e.pow(r,.5))),s[i]=n(e.pow(r,1/3)),i++),r++}();var c=[],l=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(u.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],l=n[5],f=n[6],d=n[7],h=0;h<64;h++){if(h<16)c[h]=0|e[t+h];else{var v=c[h-15],p=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,m=c[h-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;c[h]=p+c[h-7]+y+c[h-16]}var g=r&i^r&a^i&a,w=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=d+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&f)+s[h]+c[h];d=f,f=l,l=u,u=o+b|0,o=a,a=i,i=r,r=b+(w+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+d|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(l),t.HmacSHA256=a._createHmacHelper(l)}(Math),n.SHA256)}(ft);var dt,ht=ft.exports,vt=q(ht),pt={exports:{}};!function(e,t){var n;e.exports=(n=st(),dt||(dt=1,function(e,t){var n,r,i;e.exports=(r=(n=st()).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var a=this._oKey=t.clone(),o=this._iKey=t.clone(),u=a.words,s=o.words,c=0;c<n;c++)u[c]^=1549556828,s[c]^=909522486;a.sigBytes=o.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))}(pt)),n.HmacSHA256)}(lt);var mt=q(lt.exports),yt=function(){function e(){}return e.sign=function(t){for(var n=t.signedHeaders.join(";"),r="",i=0,a=t.signedHeaders;i<a.length;i++){var o=a[i],u=t.headers[o];r+="".concat(o,":").concat(u,"\n")}var s=e.createHash(t.body||""),c=t.method.toUpperCase()+"\n"+t.path+"\n"+t.query+"\n"+r+"\n"+n+"\n"+s+"\n",l="HMAC-SHA256",f=e.createHash(c),d="".concat(l,"\n").concat(t.timestamp,"\n").concat(f,"\n"),h=e.createSha256(d,t.secretKey);return"".concat(l," Credential=").concat(t.secretId,", SignedHeaders=").concat(n,", Signature=").concat(h)},e.createSha256=function(e,t){return void 0===t&&(t=""),mt(e,t).toString(ct)},e.createHash=function(e){return vt(e).toString(ct)},e}(),gt=function(){function e(){}return e.where=function(){return window||void 0===("undefined"==typeof my?"undefined":i(my))?"browser":"alipay-mini"},e.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},e.parseUrl=function(t){if("browser"===e.where())return new URL(t);var n=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=n[1],i=n[2],a=n[3],o=n[4];return{protocol:r||"",host:i||"",pathname:"".concat(a||""),search:o||""}},e}();var wt=function(){function e(e,t){this.req=e,this.config=t}return Object.defineProperty(e.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),e}(),bt=function(){function e(){}return e.prototype.request=function(e,t){return E(this,void 0,void 0,(function(){var n,r,i;return R(this,(function(a){switch(a.label){case 0:return[4,fetch(e,M({mode:"cors"},t))];case 1:return n=a.sent(),r={},n.headers.forEach((function(e,t){r[t]=e})),i={status:n.status},[4,n.json()];case 2:return[2,(i.data=a.sent(),i.headers=r,i)]}}))}))},e}(),kt=function(){function e(){}return e.prototype.request=function(e,t){return E(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:e,method:(null==t?void 0:t.method)||"GET",data:null==t?void 0:t.body,headers:null==t?void 0:t.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]}}))}))},e}(),Ct=function(){function e(){}return e.default=function(){if(!this.singleton){var e=gt.where();this.singleton="alipay-mini"===e?new kt:new bt}return this.singleton},e}();function _t(e,t){return E(this,void 0,void 0,(function(){var n,r;return R(this,(function(i){switch(i.label){case 0:return[4,t()];case 1:return i.sent(),n=e.config.fetch||Ct.default(),r=e,[4,n.request(e.req.url,e.req.requestOptions)];case 2:return r.res=i.sent(),e.result={status:e.res.status,requestID:e.requestId,headers:e.res.headers,data:e.res.data},[2]}}))}))}function At(e,t){return E(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t()];case 1:return r.sent(),[3,3];case 2:throw n=r.sent(),B.FaasError.NETWORK_ERR(n,e.requestId);case 3:return[2]}}))}))}function xt(e){return function(t,n){return E(this,void 0,void 0,(function(){var r,i,a,o,u;return R(this,(function(s){switch(s.label){case 0:return r=Date.now(),i=gt.parseUrl(t.req.url),a={authorization:"","x-from-app-id":t.config.appId,"x-from-env-id":t.config.envId,"x-to-env-id":t.config.envId,"x-from-instance-id":"".concat(r),"x-from-function-name":t.config.functionName,"x-client-timestamp":"".concat(r)},e.length>0&&e.forEach((function(e){var n,r=null===(n=t.req.requestOptions.headers)||void 0===n?void 0:n[e];r&&(a[e]=r)})),o=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],e,!0).sort(),u={path:i.pathname,query:i.search.substring(1),secretId:t.config.secretId,secretKey:t.config.secretKey,method:t.req.requestOptions.method,headers:a,body:t.req.requestOptions.body,timestamp:r,signedHeaders:o},a.authorization=yt.sign(u),t.req.requestOptions.headers=M(M({},a),t.req.requestOptions.headers),[4,n()];case 1:return s.sent(),[2]}}))}))}}var Ot=function(){function e(e,t){var n;this.config=e,this.handler=(n=t,function(e,t){var r=-1;return function i(a){if(a<=r)return Promise.reject(new Error("next() called multiple times"));r=a;var o=n[a];if(a===n.length&&(o=t),!o)return Promise.resolve();try{return Promise.resolve(o(e,i.bind(null,a+1)))}catch(e){return Promise.reject(e)}}(0)})}return e.prototype.request=function(e){var t=e.method,n=e.path,r=e.data,i=e.headers;return E(this,void 0,void 0,(function(){var e,a,o,u;return R(this,(function(s){switch(s.label){case 0:return e=this.config.endpoint+n,a=r?JSON.stringify(r):r,o=gt.generateUUID(),i=Object.assign({"x-alipay-callid":o,"x-request-id":o,"x-alipay-source":"web,web-sdk","content-type":"application/json"},i),u=new wt({url:e,requestOptions:{method:t,body:a,headers:i}},this.config),[4,this.handler(u)];case 1:return s.sent(),[2,u.result]}}))}))},e.createFunctionHttpclient=function(t){return new e(t,[At,xt(["x-to-function-name"]),_t])},e}(),Pt=function(){function e(e){this.config=e}return e.prototype.init=function(){},e.prototype.callFunction=function(e){return E(this,void 0,void 0,(function(){var t,n;return R(this,(function(r){switch(r.label){case 0:return t=M(M({},this.config),{functionName:e.name}),n=Ot.createFunctionHttpclient(t),[4,B.WebSDK.createCallFunction({type:"web",httpclient:n})(e)];case 1:return[2,r.sent()]}}))}))},e}();e.Cloud=Pt}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).cloud={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof h?t:h,o=Object.create(a.prototype),u=new O(r||[]);return i(o,"_invoke",{value:C(e,n,u)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function h(){}function v(){}function p(){}var m={};s(m,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(P([])));g&&g!==t&&n.call(g,o)&&(m=g);var w=p.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,o,u){var c=f(e[i],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(l).then((function(e){s.value=e,o(s)}),(function(e){return r("throw",e,o,u)}))}u(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function C(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return j()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var u=_(o,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function _(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,_(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return v.prototype=p,i(w,"constructor",{value:p,configurable:!0}),i(p,"constructor",{value:v,configurable:!0}),v.displayName=s(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(k.prototype),s(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(l(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},b(w),s(w,c,"Generator"),s(w,o,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=P,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(e,t,n,r,i,a,o){try{var u=e[a](o),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,c,"next",e)}function c(e){a(o,r,i,u,c,"throw",e)}u(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,C(r.key),r)}}function s(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,n){return p=v()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&h(i,n.prototype),i},p.apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},m(e)}function y(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){var t=v();return function(){var n,r=d(e);if(t){var i=d(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}(this,n)}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(u)throw a}}}}function C(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function _(e,t){return function(e,t){if(t.get)return t.get.call(e);return t.value}(e,x(e,t,"get"))}function A(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,x(e,t,"set"),n),n}function x(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function O(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function P(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function j(e,t,n){P(e,t),t.set(e,n)}function M(e,t){P(e,t),t.add(e)}var E=function(){return E=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},E.apply(this,arguments)};function S(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,u)}c((r=r.apply(e,t||[])).next())}))}function R(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=i=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 q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function D(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I={},B={},N={},L={},Q={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.FaasError=void 0;var t=function(e){f(n,e);var t=w(n);function n(e,r){var i;return u(this,n),l(g(i=t.call(this,r)),"httpStatus",void 0),l(g(i),"error",void 0),l(g(i),"errorMessage",void 0),l(g(i),"requestID",void 0),i.error=e,i.errorMessage=r,i}return s(n,[{key:"errCode",get:function(){return this.error}},{key:"errMsg",get:function(){return this.message}}],[{key:"INVALID_PARAM_ERR",value:function(e,t){return new n(60001,"无效入参,参数 ".concat(e," ").concat(t))}},{key:"NOT_FOUND_ERR",value:function(e){return new n(70001,e)}},{key:"SERVER_ERR",value:function(e,t,r,i){var a=new n(e,t);return a.requestID=r,a.httpStatus=i,a}},{key:"STORAGE_ERR",value:function(e,t,r){var i=new n(e,t);return i.requestID=r,i}},{key:"NETWORK_ERR",value:function(e,t){var r=new n(-1,e.toString());return r.requestID=t,r}}]),n}(m(Error));e.FaasError=t}(Q);var U=["complete","success","fail"];!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ResponseUtil=e.wrapCallback=void 0;var t=Q;e.wrapCallback=function(e){return function(t){if(!(null!=t&&t.complete||null!=t&&t.success||null!=t&&t.fail))return e(t);var n=t.complete,r=t.success,i=t.fail,a=y(t,U);e(a).then((function(e){return null!=r&&r(e),e}),(function(e){return null!=i&&i(e),e})).then((function(e){null==n||n(e)}))}};var n=function(){function e(){u(this,e)}return s(e,null,[{key:"handleResponse",value:function(e){if(200!==e.status){var n=e.data||{code:-1,message:"未知异常"},r=n.code,i=n.message;throw t.FaasError.SERVER_ERR(r,i,e.requestID,e.status)}return e.data.data}}]),e}();e.ResponseUtil=n}(L),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createCallContainer=void 0;var t=L;e.createCallContainer=function(e){var n=function(){var t=o(r().mark((function t(n){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("not implemented in "+e.type+" with "+n);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return(0,t.wrapCallback)(n)}}(N);var W={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createCallFunction=void 0;var t=Q,n=L;e.createCallFunction=function(e){var i=e.httpclient,a=function(){var e=o(r().mark((function e(n){var a,o,u,c,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.name){e.next=2;break}throw t.FaasError.INVALID_PARAM_ERR("name","缺失");case 2:return a={"x-to-function-name":n.name,"x-alipay-cloud-mode":"function"},"POST","/functions/invokeFunction",e.next=7,i.request({method:"POST",path:"/functions/invokeFunction",data:n.data,headers:a});case 7:if(200===(o=e.sent).status){e.next=12;break}throw u=-1,c="",(s=o.data)&&(u=s.errCode,c=s.errMsg,s.errDetail&&(c+=",详情:".concat(s.errDetail))),t.FaasError.SERVER_ERR(u,c,o.requestID,o.status);case 12:return e.abrupt("return",{requestID:o.requestID,result:o.data});case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(0,n.wrapCallback)(a)}}(W);var $={},T={},F={},H={};Object.defineProperty(H,"__esModule",{value:!0});var G={},z={},V={},J={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateCommand=e.QueryCommand=e.UpdateCommand=e.AbstractCommand=void 0;var t=s((function e(){u(this,e)}));e.AbstractCommand=t;var n=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return s(n)}(t);e.UpdateCommand=n;var r=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return s(n)}(t);e.QueryCommand=r;var i=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return s(n)}(t);e.AggregateCommand=i}(J);var K={},Y={};!function(e){var t,n;Object.defineProperty(e,"__esModule",{value:!0}),e.DbBuildError=e.ErrorCode=void 0,(n=t||(e.ErrorCode=t={})).INVALID_PARAM="INVALID_PARAM",n.INVALID_COMMAND="INVALID_COMMAND";var r=function(e){f(r,e);var n=w(r);function r(){var e;u(this,r);for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];return l(g(e=n.call.apply(n,[this].concat(i))),"code",void 0),e}return s(r,null,[{key:"create",value:function(e,t){var n=new r(t);return n.code=e,n}},{key:"invalidParam",value:function(e,n){return r.create(t.INVALID_PARAM,'无效入参 "'.concat(e,'", ').concat(n))}},{key:"invalidCommand",value:function(e){return r.create(t.INVALID_COMMAND,e)}}]),r}(m(Error));e.DbBuildError=r}(Y),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateRequest=void 0;var t=Y,n=J,r=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"data",void 0),l(this,"prefix",void 0),this.data=t,this.prefix=n}return s(e,[{key:"stringify",value:function(){var r=this;if(this.data instanceof n.AbstractCommand){if(!(this.data instanceof n.AggregateCommand))throw t.DbBuildError.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(t,n){return new e(t,"".concat(r.prefix,".$.").concat(n)).stringify()}));switch(i(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw t.DbBuildError.invalidParam(this.prefix,"不支持函数");case"symbol":throw t.DbBuildError.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw t.DbBuildError.invalidParam(this.prefix,"不支持 undefined");default:var a={};for(var o in this.data){var u=this.prefix?"".concat(this.prefix,".").concat(o):o,c=new e(this.data[o],u);a[o]=c.stringify()}return a}}},{key:"toJSON",value:function(){return this.stringify()}}]),e}();e.AggregateRequest=r}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AndAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=e.map((function(e){return new t.AggregateRequest(e).toJSON()})),i}return s(r,[{key:"pushCommand",value:function(e){this.commands.push(new t.AggregateRequest(e).toJSON())}},{key:"stringify",value:function(){return{$and:this.commands}}}]),r}(J.AggregateCommand);e.AndAggregateCommand=n}(V);var X={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AvgAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return s(r,[{key:"stringify",value:function(){return{$avg:this.val}}}]),r}(J.AggregateCommand);e.AvgAggregateCommand=n}(X);var Z={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CountAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(){return u(this,n),t.apply(this,arguments)}return s(n,[{key:"stringify",value:function(){return{$count:{}}}}]),n}(J.AggregateCommand);e.CountAggregateCommand=t}(Z);var ee={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.EqAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$eq:this.val}}}]),n}(J.AggregateCommand);e.EqAggregateCommand=t}(ee);var te,ne={},re={},ie={},ae={},oe={};function ue(){return te||(te=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AndCommand=void 0;var t=J,n=Me(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return s(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$and:this.commands}}}]),r}(t.QueryCommand);e.AndCommand=r}(oe)),oe}var ce,se={};function le(){return ce||(ce=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.OrCommand=void 0;var t=J,n=Me(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return s(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$or:this.commands}}}]),r}(t.QueryCommand);e.OrCommand=r}(se)),se}var fe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.EqCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$eq:this.val}}}]),n}(J.QueryCommand);e.EqCommand=t}(fe);var de={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NeqCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$ne:this.val}}}]),n}(J.QueryCommand);e.NeqCommand=t}(de);var he={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LtCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$lt:this.val}}}]),n}(J.QueryCommand);e.LtCommand=t}(he);var ve={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LteCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$lte:this.val}}}]),n}(J.QueryCommand);e.LteCommand=t}(ve);var pe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GtCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$gt:this.val}}}]),n}(J.QueryCommand);e.GtCommand=t}(pe);var me={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GteCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$gte:this.val}}}]),n}(J.QueryCommand);e.GteCommand=t}(me);var ye={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.InCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$in:this.val}}}]),n}(J.QueryCommand);e.InCommand=t}(ye);var ge={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NinCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$nin:this.val}}}]),n}(J.QueryCommand);e.NinCommand=t}(ge);var we={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExistsCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"exists",void 0),r.exists=e,r}return s(n,[{key:"stringify",value:function(){return{$exists:this.exists}}}]),n}(J.QueryCommand);e.ExistsCommand=t}(we);var be={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ModCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e,r){var i;return u(this,n),l(g(i=t.call(this)),"divisor",void 0),l(g(i),"remainder",void 0),i.divisor=e,i.remainder=r,i}return s(n,[{key:"stringify",value:function(){return{$mod:[this.divisor,this.remainder]}}}]),n}(J.QueryCommand);e.ModCommand=t}(be);var ke={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AllCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$all:this.val}}}]),n}(J.QueryCommand);e.AllCommand=t}(ke);var Ce,_e,Ae,xe,Oe={};function Pe(){return Ce||(Ce=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ElemMatchCommand=void 0;var t=J,n=Me(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"val",void 0),i.val=n.CommandUtils.stringify(e),i}return s(r,[{key:"stringify",value:function(){return{$elemMatch:this.val}}}]),r}(t.QueryCommand);e.ElemMatchCommand=r}(Oe)),Oe}function je(){return _e||(_e=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryChain=void 0;var t=ue(),n=le(),r=fe,i=de,a=he,o=ve,c=pe,f=me,d=ye,h=ge,v=we,p=be,m=ke,y=Pe(),g=Me(),w=new WeakSet,b=function(){function e(t){u(this,e),M(this,w),l(this,"lastCmd",void 0),this.lastCmd=t}return s(e,[{key:"and",value:function(e){return O(this,w,k).call(this,e)}},{key:"or",value:function(e){return e=g.CommandUtils.unchain(e),this.lastCmd instanceof n.OrCommand?this.lastCmd.pushCommand(e):this.lastCmd=new n.OrCommand([this.lastCmd,e]),this}},{key:"not",value:function(e){return O(this,w,k).call(this,e)}},{key:"nor",value:function(e){return O(this,w,k).call(this,e)}},{key:"eq",value:function(e){return O(this,w,k).call(this,new r.EqCommand(e))}},{key:"neq",value:function(e){return O(this,w,k).call(this,new i.NeqCommand(e))}},{key:"lt",value:function(e){return O(this,w,k).call(this,new a.LtCommand(e))}},{key:"lte",value:function(e){return O(this,w,k).call(this,new o.LteCommand(e))}},{key:"gt",value:function(e){return O(this,w,k).call(this,new c.GtCommand(e))}},{key:"gte",value:function(e){return O(this,w,k).call(this,new f.GteCommand(e))}},{key:"in",value:function(e){return O(this,w,k).call(this,new d.InCommand(e))}},{key:"nin",value:function(e){return O(this,w,k).call(this,new h.NinCommand(e))}},{key:"exists",value:function(e){return O(this,w,k).call(this,new v.ExistsCommand(e))}},{key:"mod",value:function(e,t){return O(this,w,k).call(this,new p.ModCommand(e,t))}},{key:"all",value:function(e){return O(this,w,k).call(this,new m.AllCommand(e))}},{key:"elemMatch",value:function(e){return O(this,w,k).call(this,new y.ElemMatchCommand(g.CommandUtils.unchain(e)))}},{key:"size",value:function(e){return O(this,w,k).call(this,e)}}]),e}();function k(e){return e=g.CommandUtils.unchain(e),this.lastCmd instanceof t.AndCommand?this.lastCmd.pushCommand(e):this.lastCmd=new t.AndCommand([this.lastCmd,e]),this}e.QueryChain=b}(ae)),ae}function Me(){return Ae||(Ae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CommandUtils=void 0;var t=J,n=Ee(),r=je(),i=function(){function e(){u(this,e)}return s(e,null,[{key:"stringify",value:function(r){return(r=e.unchain(r))instanceof t.QueryCommand?r.stringify():new n.QueryRequest(r).toJSON()}},{key:"unchain",value:function(e){return e instanceof r.QueryChain?e.lastCmd:e}}]),e}();e.CommandUtils=i}(ie)),ie}function Ee(){return xe||(xe=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryRequest=void 0;var t=J,n=Y,r=Me(),a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"query",void 0),l(this,"prefix",void 0),this.query=t,this.prefix=n}return s(e,[{key:"stringify",value:function(){var a=this,o={},u=r.CommandUtils.unchain(this.query),c=i(u);if(u instanceof t.QueryCommand)return u.stringify();if(Array.isArray(u))return u.map((function(t,n){return new e(t,"".concat(a.prefix,".$.").concat(n)).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,f=new e(u[s],l);o[s]=f.stringify()}return o}},{key:"toJSON",value:function(){return this.stringify()}}]),e}();e.QueryRequest=a}(re)),re}var Se={};!function(e){var t,n,r,i,a,o;Object.defineProperty(e,"__esModule",{value:!0}),e.PipelineStageName=e.Target=e.DocumentAction=e.CollectionAction=e.Sort=void 0,(n=t||(e.Sort=t={})).DESC="desc",n.ASC="asc",function(e){e.update="update",e.delete="delete",e.query="query",e.queryList="queryList",e.create="create"}(r||(e.CollectionAction=r={})),function(e){e.update="update",e.replace="replace",e.delete="delete",e.query="query",e.queryList="queryList",e.create="create",e.batchCreate="batchCreate",e.count="count",e.aggregate="aggregate"}(i||(e.DocumentAction=i={})),function(e){e.collection="collection",e.document="document"}(a||(e.Target=a={})),function(e){e.match="$match",e.group="$group",e.sample="$sample",e.lookup="$lookup"}(o||(e.PipelineStageName=o={}))}(Se),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregatePipeline=void 0;var t=K,n=Ee(),r=Se,i=Y,a=new WeakMap,o=new WeakSet,c=function(){function e(){u(this,e),M(this,o),j(this,a,{writable:!0,value:void 0}),A(this,a,[])}return s(e,[{key:"match",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.match,e),this}},{key:"group",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.group,e),this}},{key:"sample",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.sample,e),this}},{key:"lookup",value:function(e){return O(this,o,f).call(this,r.PipelineStageName.lookup,e),this}},{key:"done",value:function(){return _(this,a).map((function(e){switch(e.name){case r.PipelineStageName.match:return{$match:new n.QueryRequest(e.param).toJSON()};case r.PipelineStageName.sample:case r.PipelineStageName.lookup:return l({},e.name,e.param);case r.PipelineStageName.group:return{$group:new t.AggregateRequest(e.param).toJSON()};default:var a=e.name;throw i.DbBuildError.invalidParam(a,"不支持的 aggregate 操作")}}))}}]),e}();function f(e,t){_(this,a).push({name:e,param:t})}e.AggregatePipeline=c}(ne);var Re={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExprCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=new t.AggregateRequest(e).toJSON(),i}return s(r,[{key:"stringify",value:function(){return{$expr:this.commands}}}]),r}(J.QueryCommand);e.ExprCommand=n}(Re);var qe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GtAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$gt:this.val}}}]),n}(J.AggregateCommand);e.GtAggregateCommand=t}(qe);var De={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GteAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$gte:this.val}}}]),n}(J.AggregateCommand);e.GteAggregateCommand=t}(De);var Ie={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LtAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$lt:this.val}}}]),n}(J.AggregateCommand);e.LtAggregateCommand=t}(Ie);var Be={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LteAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$lte:this.val}}}]),n}(J.AggregateCommand);e.LteAggregateCommand=t}(Be);var Ne={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MaxAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return s(r,[{key:"stringify",value:function(){return{$max:this.val}}}]),r}(J.AggregateCommand);e.MaxAggregateCommand=n}(Ne);var Le={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MinAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return s(r,[{key:"stringify",value:function(){return{$min:this.val}}}]),r}(J.AggregateCommand);e.MinAggregateCommand=n}(Le);var Qe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NeqAggregateCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$ne:this.val}}}]),n}(J.AggregateCommand);e.NeqAggregateCommand=t}(Qe);var Ue={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.OrAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"commands",void 0),i.commands=e.map((function(e){return new t.AggregateRequest(e).toJSON()})),i}return s(r,[{key:"pushCommand",value:function(e){this.commands.push(new t.AggregateRequest(e).toJSON())}},{key:"stringify",value:function(){return{$or:this.commands}}}]),r}(J.AggregateCommand);e.OrAggregateCommand=n}(Ue);var We={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SumAggregateCommand=void 0;var t=K,n=function(e){f(r,e);var n=w(r);function r(e){var i;return u(this,r),l(g(i=n.call(this)),"val",void 0),i.val=new t.AggregateRequest(e).toJSON(),i}return s(r,[{key:"stringify",value:function(){return{$sum:this.val}}}]),r}(J.AggregateCommand);e.SumAggregateCommand=n}(We);var $e={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SetCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"data",void 0),r.data=e,r}return s(n,[{key:"operator",get:function(){return"$set"}},{key:"stringify",value:function(){return this.data}}]),n}(J.UpdateCommand);e.SetCommand=t}($e);var Te={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.IncCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"num",void 0),r.num=e,r}return s(n,[{key:"operator",get:function(){return"$inc"}},{key:"stringify",value:function(){return this.num}}]),n}(J.UpdateCommand);e.IncCommand=t}(Te);var Fe={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NotCommand=void 0;var t=J,n=Me(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"command",void 0),i.command=n.CommandUtils.stringify(e),i}return s(r,[{key:"stringify",value:function(){return{$not:this.command.stringify()}}}]),r}(t.QueryCommand);e.NotCommand=r}(Fe);var He={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NorCommand=void 0;var t=J,n=Me(),r=function(e){f(r,e);var t=w(r);function r(e){var i;return u(this,r),l(g(i=t.call(this)),"commands",void 0),i.commands=e.map(n.CommandUtils.stringify),i}return s(r,[{key:"pushCommand",value:function(e){this.commands.push(n.CommandUtils.stringify(e))}},{key:"stringify",value:function(){return{$nor:this.commands}}}]),r}(t.QueryCommand);e.NorCommand=r}(He);var Ge={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SizeCommand=void 0;var t=function(e){f(n,e);var t=w(n);function n(e){var r;return u(this,n),l(g(r=t.call(this)),"val",void 0),r.val=e,r}return s(n,[{key:"stringify",value:function(){return{$size:this.val}}}]),n}(J.QueryCommand);e.SizeCommand=t}(Ge),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Command=e.AggregateCommandFactory=void 0;var t=V,n=X,r=Z,i=ee,a=ne,o=Re,c=qe,f=De,d=Ie,h=Be,v=Ne,p=Le,m=Qe,y=Ue,g=We,w=$e,b=Te,k=je(),C=le(),_=ue(),A=Me(),x=Fe,O=He,P=fe,j=de,M=he,E=ve,S=pe,R=me,q=ye,D=ge,I=we,B=be,N=ke,L=Pe(),Q=Ge,U=function(){function e(){u(this,e)}return s(e,[{key:"pipeline",value:function(){return new a.AggregatePipeline}},{key:"avg",value:function(e){return new n.AvgAggregateCommand(e)}},{key:"count",value:function(){return new r.CountAggregateCommand}},{key:"max",value:function(e){return new v.MaxAggregateCommand(e)}},{key:"min",value:function(e){return new p.MinAggregateCommand(e)}},{key:"sum",value:function(e){return new g.SumAggregateCommand(e)}},{key:"and",value:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n=Array.isArray(n[0])?n[0]:n,new t.AndAggregateCommand(n)}},{key:"or",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new y.OrAggregateCommand(t)}},{key:"eq",value:function(e){return new i.EqAggregateCommand(e)}},{key:"neq",value:function(e){return new m.NeqAggregateCommand(e)}},{key:"lt",value:function(e){return new d.LtAggregateCommand(e)}},{key:"lte",value:function(e){return new h.LteAggregateCommand(e)}},{key:"gt",value:function(e){return new c.GtAggregateCommand(e)}},{key:"gte",value:function(e){return new f.GteAggregateCommand(e)}}]),e}();e.AggregateCommandFactory=U;var W=function(){function e(){u(this,e),l(this,"aggregate",void 0),this.aggregate=new U}return s(e,[{key:"set",value:function(e){return new w.SetCommand(e)}},{key:"inc",value:function(e){return new b.IncCommand(e)}},{key:"expr",value:function(e){return new o.ExprCommand(e)}},{key:"and",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new _.AndCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"or",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new C.OrCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"not",value:function(e){var t=new x.NotCommand(A.CommandUtils.unchain(e));return new k.QueryChain(t)}},{key:"nor",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var r=new O.NorCommand(t.map(A.CommandUtils.unchain));return new k.QueryChain(r)}},{key:"eq",value:function(e){return new k.QueryChain(new P.EqCommand(e))}},{key:"neq",value:function(e){return new k.QueryChain(new j.NeqCommand(e))}},{key:"lt",value:function(e){return new k.QueryChain(new M.LtCommand(e))}},{key:"lte",value:function(e){return new k.QueryChain(new E.LteCommand(e))}},{key:"gt",value:function(e){return new k.QueryChain(new S.GtCommand(e))}},{key:"gte",value:function(e){return new k.QueryChain(new R.GteCommand(e))}},{key:"in",value:function(e){return new k.QueryChain(new q.InCommand(e))}},{key:"nin",value:function(e){return new k.QueryChain(new D.NinCommand(e))}},{key:"exists",value:function(e){return new k.QueryChain(new I.ExistsCommand(e))}},{key:"mod",value:function(e,t){return new k.QueryChain(new B.ModCommand(e,t))}},{key:"all",value:function(e){return new k.QueryChain(new N.AllCommand(e))}},{key:"elemMatch",value:function(e){return new k.QueryChain(new L.ElemMatchCommand(A.CommandUtils.unchain(e)))}},{key:"size",value:function(e){return new k.QueryChain(new Q.SizeCommand(e))}}]),e}();e.Command=W}(z);var ze={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ActionBuilder=void 0;var t=Se,n=function(){function e(){u(this,e)}return s(e,null,[{key:"buildCollectionAction",value:function(e,n){return{target:t.Target.collection,action:e,collectionName:n}}},{key:"buildCollectionListQueryAction",value:function(e){return{target:t.Target.collection,action:t.CollectionAction.queryList,options:e}}},{key:"buildDocumentAction",value:function(e,n,r){return{target:t.Target.document,action:e,collectionName:n,options:r}}}]),e}();e.ActionBuilder=n}(ze);var Ve={},Je={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AggregateBuilder=void 0;var t=ne,n=Se,r=ze,i=new WeakMap,a=function(e){f(a,e);var t=w(a);function a(e){var n;return u(this,a),j(g(n=t.call(this)),i,{writable:!0,value:void 0}),A(g(n),i,e),n}return s(a,[{key:"end",value:function(){var e={$aggregate:this.done()};return r.ActionBuilder.buildDocumentAction(n.DocumentAction.aggregate,_(this,i),e)}}]),a}(t.AggregatePipeline);e.AggregateBuilder=a}(Je);var Ke={},Ye={},Xe={},Ze={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Operator=void 0;var t=function(){function e(){u(this,e),l(this,"res",void 0),this.res={}}return s(e,[{key:"set",value:function(e,t){this.res.$set=this.res.$set||{},this.res.$set[e]=t}},{key:"applyOperator",value:function(e,t,n){this.res[e]=this.res[e]||{},this.res[e][t]=n}},{key:"emit",value:function(){return this.res}}]),e}();e.Operator=t}(Ze),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateRequest=void 0;var t=Y,n=J,r=Ze,a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";u(this,e),l(this,"data",void 0),l(this,"prefix",void 0),this.data=t,this.prefix=n}return s(e,[{key:"stringify",value:function(a){for(var o in a=a||new r.Operator,this.data){var u=this.prefix?"".concat(this.prefix,".").concat(o):o,c=this.data[o],s=i(c);if(c instanceof n.AbstractCommand){if(!(c instanceof n.UpdateCommand))throw t.DbBuildError.invalidCommand("Command 不是更新操作");a.applyOperator(c.operator,u,c.stringify())}else if("number"===s)a.set(u,c);else if("boolean"===s)a.set(u,c);else if("string"===s)a.set(u,c);else if("bigint"===s)a.set(u,c);else{if("function"===s)throw t.DbBuildError.invalidParam(u,"不支持函数");if("symbol"===s)throw t.DbBuildError.invalidParam(u,"不支持 symbol");if("undefined"===s)throw t.DbBuildError.invalidParam(u,"不支持 undefined");null===c||Array.isArray(c)?a.set(u,c):new e(c,u).stringify(a)}}return a}},{key:"toJSON",value:function(){return this.stringify().emit()}}]),e}();e.UpdateRequest=a}(Xe),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.QueryBuilder=void 0;var t=Ee(),r=Xe,a=Se,o=ze,c=new WeakMap,l=new WeakMap,f=new WeakMap,d=new WeakMap,h=new WeakMap,v=new WeakMap,p=new WeakSet,m=new WeakSet,y=new WeakSet,g=function(){function e(t){u(this,e),M(this,y),M(this,m),M(this,p),j(this,c,{writable:!0,value:void 0}),j(this,l,{writable:!0,value:void 0}),j(this,f,{writable:!0,value:void 0}),j(this,d,{writable:!0,value:void 0}),j(this,h,{writable:!0,value:void 0}),j(this,v,{writable:!0,value:void 0}),A(this,v,t),A(this,d,[])}return s(e,[{key:"limit",value:function(e){return A(this,l,e),this}},{key:"skip",value:function(e){return A(this,f,e),this}},{key:"where",value:function(e){return A(this,c,e),this}},{key:"projection",value:function(e){for(var t in e)e[t]?"object"!=i(e[t])&&(e[t]=1):e[t]=0;return A(this,h,e),this}},{key:"orderBy",value:function(e,t){return _(this,d).push({field:e,sort:t}),this}},{key:"update",value:function(e){return O(this,y,C).call(this,a.DocumentAction.update,n(n({},O(this,p,w).call(this)),{},{$update:new r.UpdateRequest(e.data).toJSON()}))}},{key:"set",value:function(e){return O(this,y,C).call(this,a.DocumentAction.replace,n(n({},O(this,p,w).call(this)),{},{$replace:e.data}))}},{key:"remove",value:function(){return O(this,y,C).call(this,a.DocumentAction.delete,O(this,p,w).call(this))}},{key:"get",value:function(){return O(this,y,C).call(this,a.DocumentAction.queryList,n({$limit:100},O(this,m,b).call(this)))}},{key:"count",value:function(){return O(this,y,C).call(this,a.DocumentAction.count,O(this,p,w).call(this))}}]),e}();function w(){var e={};if(i(_(this,c))<"u"){var n=new t.QueryRequest(_(this,c));e.$match=n.toJSON()}return i(_(this,l))<"u"&&(e.$limit=_(this,l)),e}function b(){var e=O(this,p,w).call(this);if(i(_(this,h))<"u"&&(e.$project=_(this,h)),i(_(this,d))<"u"){e.$sort={};var t,n=k(_(this,d));try{for(n.s();!(t=n.n()).done;){var r=t.value;e.$sort[r.field]=r.sort===a.Sort.DESC?-1:1}}catch(e){n.e(e)}finally{n.f()}}return i(_(this,f))<"u"&&(e.$skip=_(this,f)),e}function C(e,t){return o.ActionBuilder.buildDocumentAction(e,_(this,v),t)}e.QueryBuilder=g}(Ye),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DocumentBuilder=void 0;var t=Se,n=Ye,r=new WeakMap,i=new WeakMap,a=function(){function e(t,n){u(this,e),j(this,r,{writable:!0,value:void 0}),j(this,i,{writable:!0,value:void 0}),A(this,i,t),A(this,r,n)}return s(e,[{key:"update",value:function(e){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).update(e)}},{key:"set",value:function(e){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).set(e)}},{key:"remove",value:function(){return new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).remove()}},{key:"get",value:function(){var e=new n.QueryBuilder(_(this,i)).where({_id:String(_(this,r))}).limit(1).get();return e.action=t.DocumentAction.query,e}}]),e}();e.DocumentBuilder=a}(Ke),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CollectionBuilder=void 0;var t=Se,n=Y,r=ze,i=Je,a=Ke,o=Ye,c=new WeakMap,l=function(){function e(t){u(this,e),j(this,c,{writable:!0,value:void 0}),A(this,c,t)}return s(e,[{key:"add",value:function(e){return Array.isArray(e.data)?this.batchAdd(e):r.ActionBuilder.buildDocumentAction(t.DocumentAction.create,_(this,c),e.data)}},{key:"batchAdd",value:function(e){if(e.data.length>200)throw n.DbBuildError.invalidParam("data","最大长度 200");var i={$create:e.data};return"boolean"==typeof e.ordered&&(i.$ordered=e.ordered),r.ActionBuilder.buildDocumentAction(t.DocumentAction.batchCreate,_(this,c),i)}},{key:"doc",value:function(e){return new a.DocumentBuilder(_(this,c),e)}},{key:"limit",value:function(e){return new o.QueryBuilder(_(this,c)).limit(e)}},{key:"skip",value:function(e){return new o.QueryBuilder(_(this,c)).skip(e)}},{key:"where",value:function(e){return new o.QueryBuilder(_(this,c)).where(e)}},{key:"projection",value:function(e){return new o.QueryBuilder(_(this,c)).projection(e)}},{key:"orderBy",value:function(e,t){return new o.QueryBuilder(_(this,c)).orderBy(e,t)}},{key:"aggregate",value:function(){return new i.AggregateBuilder(_(this,c))}},{key:"get",value:function(){return new o.QueryBuilder(_(this,c)).get()}},{key:"count",value:function(){return new o.QueryBuilder(_(this,c)).count()}}]),e}();e.CollectionBuilder=l}(Ve),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MongoBuilder=void 0;var t=z,n=Se,r=ze,i=Ve,a=function(){function e(){u(this,e),l(this,"command",void 0),this.command=new t.Command}return s(e,[{key:"collection",value:function(e){return new i.CollectionBuilder(e)}},{key:"createCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.create,e)}},{key:"getCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.query,e)}},{key:"listCollection",value:function(e,t){return r.ActionBuilder.buildCollectionListQueryAction({$limit:null!=e?e:10,$skip:null!=t?t:0})}},{key:"deleteCollection",value:function(e){return r.ActionBuilder.buildCollectionAction(n.CollectionAction.delete,e)}}]),e}();e.MongoBuilder=a}(G),function(e){var t=q&&q.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=q&&q.__exportStar||function(e,n){for(var r in e)"default"!==r&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.DbBuildError=e.CommandUtils=e.Command=e.AggregateRequest=e.UpdateRequest=e.QueryRequest=e.AggregateBuilder=e.QueryBuilder=e.DocumentBuilder=e.CollectionBuilder=e.MongoBuilder=void 0,n(H,e);var r=G;Object.defineProperty(e,"MongoBuilder",{enumerable:!0,get:function(){return r.MongoBuilder}});var i=Ve;Object.defineProperty(e,"CollectionBuilder",{enumerable:!0,get:function(){return i.CollectionBuilder}});var a=Ke;Object.defineProperty(e,"DocumentBuilder",{enumerable:!0,get:function(){return a.DocumentBuilder}});var o=Ye;Object.defineProperty(e,"QueryBuilder",{enumerable:!0,get:function(){return o.QueryBuilder}});var u=Je;Object.defineProperty(e,"AggregateBuilder",{enumerable:!0,get:function(){return u.AggregateBuilder}});var c=Ee();Object.defineProperty(e,"QueryRequest",{enumerable:!0,get:function(){return c.QueryRequest}});var s=Xe;Object.defineProperty(e,"UpdateRequest",{enumerable:!0,get:function(){return s.UpdateRequest}});var l=K;Object.defineProperty(e,"AggregateRequest",{enumerable:!0,get:function(){return l.AggregateRequest}});var f=z;Object.defineProperty(e,"Command",{enumerable:!0,get:function(){return f.Command}});var d=Me();Object.defineProperty(e,"CommandUtils",{enumerable:!0,get:function(){return d.CommandUtils}});var h=Y;Object.defineProperty(e,"DbBuildError",{enumerable:!0,get:function(){return h.DbBuildError}}),n(Se,e)}(F);var et={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Aggregate=void 0;var t=F,n=L,i=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakSet,f=function(){function e(n,r){u(this,e),M(this,l),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,c,{writable:!0,value:void 0}),A(this,a,n),A(this,i,r),A(this,c,new t.AggregateBuilder(n))}var f;return s(e,[{key:"match",value:function(e){return _(this,c).match(e),this}},{key:"group",value:function(e){return _(this,c).group(e),this}},{key:"sample",value:function(e){return _(this,c).sample(e),this}},{key:"lookup",value:function(e){return _(this,c).lookup(e),this}},{key:"end",value:(f=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=_(this,c).end(),a=t.options,o="".concat(O(this,l,d).call(this),"?aggregate"),e.next=6,_(this,i).httpclient.request({method:"POST",path:o,data:a});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})}]),e}();function d(){return"/".concat(_(this,i).databaseName||"faas","/").concat(_(this,a))}e.Aggregate=f}(et);var tt={},nt={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Query=void 0;var t=F,n=L,i=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakSet,f=function(){function e(n,r){u(this,e),M(this,l),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,c,{writable:!0,value:void 0}),A(this,a,n),A(this,i,r),A(this,c,new t.QueryBuilder(n))}var f,h,v,p,m;return s(e,[{key:"limit",value:function(e){return _(this,c).limit(e),this}},{key:"skip",value:function(e){return _(this,c).skip(e),this}},{key:"where",value:function(e){return _(this,c).where(e),this}},{key:"projection",value:function(e){return _(this,c).projection(e),this}},{key:"field",value:function(e){return _(this,c).projection(e),this}},{key:"orderBy",value:function(e,t){return _(this,c).orderBy(e,t),this}},{key:"update",value:(m=o(r().mark((function e(t){var a,o,u,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a="".concat(O(this,l,d).call(this),"?update"),o=_(this,c).update(t),u=o.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:a,data:u});case 6:return s=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(s));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"set",value:(p=o(r().mark((function e(t){var a,o,u,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a="".concat(O(this,l,d).call(this),"?replace"),o=_(this,c).set(t),u=o.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:a,data:u});case 6:return s=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(s));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"remove",value:(v=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?delete"),a=_(this,c).remove(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"get",value:(h=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?query"),a=_(this,c).get(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"count",value:(f=o(r().mark((function e(){var t,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="".concat(O(this,l,d).call(this),"?count"),a=_(this,c).count(),o=a.options,e.next=6,_(this,i).httpclient.request({method:"POST",path:t,data:o});case 6:return u=e.sent,e.abrupt("return",{total:n.ResponseUtil.handleResponse(u).count});case 8:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})}]),e}();function d(){return"/".concat(_(this,i).databaseName||"faas","/").concat(_(this,a))}e.Query=f}(nt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Document=void 0;var t=Q,n=nt,i=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakMap,f=function(){function e(t,n,r){u(this,e),j(this,l,{get:d,set:void 0}),j(this,i,{writable:!0,value:void 0}),j(this,a,{writable:!0,value:void 0}),j(this,c,{writable:!0,value:void 0}),A(this,a,t),A(this,c,n),A(this,i,r)}var n,f,h,v;return s(e,[{key:"update",value:(v=o(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).update(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"set",value:(h=o(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).set(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"remove",value:(f=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).remove();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"get",value:(n=o(r().mark((function e(){var n;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(this,l).get();case 2:if(n=e.sent[0]){e.next=7;break}if(!_(this,i).throwOnNotFound){e.next=6;break}throw t.FaasError.NOT_FOUND_ERR("不存在_id 为 ".concat(_(this,c)," 的文档"));case 6:return e.abrupt("return",null);case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})}]),e}();function d(){return new n.Query(_(this,a),_(this,i)).where({_id:String(_(this,c))}).limit(1)}e.Document=f}(tt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Collection=void 0;var t=F,n=L,i=et,a=tt,c=nt,f=new WeakMap,d=new WeakMap,h=new WeakSet,v=function(){function e(n,r){u(this,e),M(this,h),j(this,f,{writable:!0,value:void 0}),j(this,d,{writable:!0,value:void 0}),l(this,"builder",void 0),A(this,d,n),A(this,f,r),this.builder=new t.CollectionBuilder(n)}var v,m,y;return s(e,[{key:"add",value:(y=o(r().mark((function e(t){var i,a,o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.builder.add(t),a=i.options,o=O(this,h,p).call(this,t.data._id),e.next=6,_(this,f).httpclient.request({method:"POST",path:o,data:a});case 6:return u=e.sent,e.abrupt("return",n.ResponseUtil.handleResponse(u));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"doc",value:function(e){return new a.Document(_(this,d),e,_(this,f))}},{key:"limit",value:function(e){return new c.Query(_(this,d),_(this,f)).limit(e)}},{key:"skip",value:function(e){return new c.Query(_(this,d),_(this,f)).skip(e)}},{key:"where",value:function(e){return new c.Query(_(this,d),_(this,f)).where(e)}},{key:"projection",value:function(e){return new c.Query(_(this,d),_(this,f)).projection(e)}},{key:"field",value:function(e){return new c.Query(_(this,d),_(this,f)).field(e)}},{key:"orderBy",value:function(e,t){return new c.Query(_(this,d),_(this,f)).orderBy(e,t)}},{key:"aggregate",value:function(){return new i.Aggregate(_(this,d),_(this,f))}},{key:"get",value:(m=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new c.Query(_(this,d),_(this,f)).get();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"count",value:(v=o(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new c.Query(_(this,d),_(this,f)).count();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})}]),e}();function p(e){return"/".concat(_(this,f).databaseName||"faas","/").concat(_(this,d),"?_id=").concat(e||"")}e.Collection=v}(T),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Database=void 0;var t=T,i=new WeakMap,a=function(){function e(t){u(this,e),j(this,i,{writable:!0,value:void 0}),A(this,i,t)}var t;return s(e,[{key:"request",value:(t=o(r().mark((function e(t){var a,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.method,o=t.path,u=t.data,c=t.headers,e.next=3,_(this,i).request({method:a,path:o,data:u,headers:n({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},c)});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),c=new WeakMap,f=function(){function e(t){u(this,e),j(this,c,{writable:!0,value:void 0}),l(this,"command",void 0),A(this,c,n(n({},t),{},{httpclient:new a(t.httpclient)}))}return s(e,[{key:"collection",value:function(e){return new t.Collection(e,_(this,c))}}]),e}();e.Database=f}($);var rt={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Storage=void 0;var t=Q,i=L,a=new WeakMap,c=new WeakSet,l=new WeakSet,f=new WeakSet,d=new WeakSet,h=new WeakSet,v=new WeakSet,p=new WeakSet,m=new WeakSet,y=new WeakSet,g=function(){function e(t){u(this,e),M(this,y),M(this,m),M(this,p),M(this,v),M(this,h),M(this,d),M(this,f),M(this,l),M(this,c),j(this,a,{writable:!0,value:void 0}),A(this,a,t)}var n,g,D,I;return s(e,[{key:"uploadFile",value:(I=o(r().mark((function e(n){var o,u,s,l,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=O(this,h,P).call(this,n.cloudPath))){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("cloudPath",o);case 3:return u=O(this,c,w).call(this,n.cloudPath.trim()),e.next=6,O(this,y,q).call(this,{method:"GET",path:u});case 6:return s=e.sent,l=i.ResponseUtil.handleResponse(s),f=O(this,p,S).call(this,l.file_id),e.next=11,_(this,a).fileUploader.upload({fileID:f,uploadURL:l.upload_url,fileContent:n.fileContent});case 11:if(200===(d=e.sent).statusCode){e.next=14;break}throw t.FaasError.STORAGE_ERR(-1,"文件下载失败",s.requestID);case 14:return e.abrupt("return",{fileID:f,statusCode:d.statusCode});case 15:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"downloadFile",value:(D=o(r().mark((function e(n){var o,u,c,s,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=O(this,v,E).call(this,n.fileID))){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",o);case 3:return u=O(this,m,R).call(this,n.fileID),c=O(this,l,b).call(this,u),e.next=7,O(this,y,q).call(this,{method:"GET",path:c});case 7:return s=e.sent,f=i.ResponseUtil.handleResponse(s),e.next=11,_(this,a).fileUploader.download({fileID:n.fileID,downloadURL:f.download_url});case 11:if(200===(d=e.sent).statusCode){e.next=14;break}throw t.FaasError.STORAGE_ERR(-1,"文件下载失败",s.requestID);case 14:return e.abrupt("return",d);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"deleteFile",value:(g=o(r().mark((function e(n){var a,o,u,c,s,l,d,h,g,w=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Array.isArray(n)?n:n.fileList,Array.isArray(a)&&0!==a.length){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");case 3:o=[],u=k(a),e.prev=5,u.s();case 7:if((c=u.n()).done){e.next=16;break}if(s=c.value,!(l=O(this,v,E).call(this,s))){e.next=12;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",l);case 12:d=O(this,m,R).call(this,s),o.push(d);case 14:e.next=7;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(5),u.e(e.t0);case 21:return e.prev=21,u.f(),e.finish(21);case 24:return h=O(this,f,C).call(this),e.next=27,O(this,y,q).call(this,{method:"POST",path:h,data:{file_list:o}});case 27:return g=e.sent,e.abrupt("return",{fileList:i.ResponseUtil.handleResponse(g).file_list.map((function(e){return{fileID:O(w,p,S).call(w,e.file_id),status:e.status?0:-1,errMsg:e.status?"ok":e.result_message}}))});case 29:case"end":return e.stop()}}),e,this,[[5,18,21,24]])}))),function(e){return g.apply(this,arguments)})},{key:"getTempFileURL",value:(n=o(r().mark((function e(n){var a,o,u,c,s,l,f,h,g,w=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Array.isArray(n)?n:n.fileList,Array.isArray(a)&&0!==a.length){e.next=3;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","不能为空数组");case 3:if(!(a.length>50)){e.next=5;break}throw t.FaasError.INVALID_PARAM_ERR("fileList","最大长度 50");case 5:o=[],u=k(a),e.prev=7,u.s();case 9:if((c=u.n()).done){e.next=18;break}if(s=c.value,!(l=O(this,v,E).call(this,s))){e.next=14;break}throw t.FaasError.INVALID_PARAM_ERR("fileID",l);case 14:f=O(this,m,R).call(this,s),o.push({file_id:f,expire:600});case 16:e.next=9;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(7),u.e(e.t0);case 23:return e.prev=23,u.f(),e.finish(23);case 26:return h=O(this,d,x).call(this),e.next=29,O(this,y,q).call(this,{method:"POST",path:h,data:{file_list:o}});case 29:return g=e.sent,e.abrupt("return",{fileList:i.ResponseUtil.handleResponse(g).file_list.map((function(e){return{fileID:O(w,p,S).call(w,e.file_id),tempFileURL:e.download_url,status:e.status?0:-1,errMsg:e.status?"ok":e.result_message}}))});case 31:case"end":return e.stop()}}),e,this,[[7,20,23,26]])}))),function(e){return n.apply(this,arguments)})}]),e}();function w(e){return"/".concat(e,"?upload_url")}function b(e){return"/".concat(e,"?download_url&expire=3600")}function C(){return"/?delete"}function x(){return"/?download_url"}function P(e){return"string"!=typeof e?"必须为字符串":(e=e.trim())?e.startsWith("/")?"不能以 / 开头":e.includes("//")?"不能包含连续的 /":e.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"}function E(e){return"string"!=typeof e?"必须为字符串":(e=e.trim())?void 0:"不能为空字符串"}function S(e){return"cloud://".concat(_(this,a).toEnvId,"/").concat(e.replace(/^\/+/,""))}function R(e){var n=e.trim().replace(/^cloud:\/\//,""),r=n.indexOf("/");if(r<=0)throw t.FaasError.INVALID_PARAM_ERR("fileID","不合法");var i=n.substring(0,r),o=n.substring(r+1);return i!==_(this,a).toEnvId&&console.warn("file ".concat(e," does not belong to env ").concat(_(this,a).toEnvId)),o}function q(e){return D.apply(this,arguments)}function D(){return(D=o(r().mark((function e(t){var i,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.method,o=t.path,u=t.data,c=t.headers,e.next=3,_(this,a).httpclient.request({method:i,path:o,data:u,headers:n({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},c)});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}e.Storage=g}(rt),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WebSDK=void 0;var t=N,n=W,r=$,i=rt,a=function(){function e(){u(this,e)}return s(e,null,[{key:"createCallFunction",value:function(e){return(0,n.createCallFunction)(e)}},{key:"createCallContainer",value:function(e){return(0,t.createCallContainer)(e)}},{key:"createDatabase",value:function(e){return new r.Database(e)}},{key:"createStorage",value:function(e){return new i.Storage(e)}}]),e}();e.WebSDK=a}(B);var it={};Object.defineProperty(it,"__esModule",{value:!0}),function(e){var t=q&&q.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=q&&q.__exportStar||function(e,n){for(var r in e)"default"!==r&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.ResponseUtil=e.FaasError=e.Query=e.Aggregate=e.Collection=e.Document=e.Database=e.Storage=e.WebSDK=void 0;var r=B;Object.defineProperty(e,"WebSDK",{enumerable:!0,get:function(){return r.WebSDK}});var i=rt;Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return i.Storage}});var a=$;Object.defineProperty(e,"Database",{enumerable:!0,get:function(){return a.Database}});var o=tt;Object.defineProperty(e,"Document",{enumerable:!0,get:function(){return o.Document}});var u=T;Object.defineProperty(e,"Collection",{enumerable:!0,get:function(){return u.Collection}});var c=et;Object.defineProperty(e,"Aggregate",{enumerable:!0,get:function(){return c.Aggregate}});var s=nt;Object.defineProperty(e,"Query",{enumerable:!0,get:function(){return s.Query}});var l=Q;Object.defineProperty(e,"FaasError",{enumerable:!0,get:function(){return l.FaasError}});var f=L;Object.defineProperty(e,"ResponseUtil",{enumerable:!0,get:function(){return f.ResponseUtil}}),n(it,e)}(I);var at={exports:{}};var ot,ut={exports:{}};function ct(){return ot||(ot=1,function(e,t){var n;e.exports=(n=n||function(e,t){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!==q&&q.crypto&&(n=q.crypto),!n)try{n=require("crypto")}catch(e){}var r=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},o=a.lib={},u=o.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=o.WordArray=u.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var a=0;a<i;a++){var o=n[a>>>2]>>>24-a%4*8&255;t[r+a>>>2]|=o<<24-(r+a)%4*8}else for(var u=0;u<i;u+=4)t[r+u>>>2]=n[u>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new c.init(t,e)}}),s=a.enc={},l=s.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push((a>>>4).toString(16)),r.push((15&a).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},f=s.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},d=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,a=r.sigBytes,o=this.blockSize,u=a/(4*o),s=(u=t?e.ceil(u):e.max((0|u)-this._minBufferSize,0))*o,l=e.min(4*s,a);if(s){for(var f=0;f<s;f+=o)this._doProcessBlock(i,f);n=i.splice(0,s),r.sigBytes-=l}return new c.init(n,l)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=h.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new v.HMAC.init(e,n).finalize(t)}}});var v=a.algo={};return a}(Math),n)}(ut)),ut.exports}!function(e,t){e.exports=ct().enc.Hex}(at);var st=D(at.exports),lt={exports:{}},ft={exports:{}};!function(e,t){var n;e.exports=(n=ct(),function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,u=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(u[i]=n(e.pow(r,.5))),c[i]=n(e.pow(r,1/3)),i++),r++}();var s=[],l=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(u.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],u=n[4],l=n[5],f=n[6],d=n[7],h=0;h<64;h++){if(h<16)s[h]=0|e[t+h];else{var v=s[h-15],p=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,m=s[h-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;s[h]=p+s[h-7]+y+s[h-16]}var g=r&i^r&a^i&a,w=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=d+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&f)+c[h]+s[h];d=f,f=l,l=u,u=o+b|0,o=a,a=i,i=r,r=b+(w+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+d|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(l),t.HmacSHA256=a._createHmacHelper(l)}(Math),n.SHA256)}(ft);var dt,ht=ft.exports,vt=D(ht),pt={exports:{}};!function(e,t){var n;e.exports=(n=ct(),dt||(dt=1,function(e,t){var n,r,i;e.exports=(r=(n=ct()).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var a=this._oKey=t.clone(),o=this._iKey=t.clone(),u=a.words,c=o.words,s=0;s<n;s++)u[s]^=1549556828,c[s]^=909522486;a.sigBytes=o.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))}(pt)),n.HmacSHA256)}(lt);var mt,yt=D(lt.exports);!function(e){e.WEB="WEB",e.ALIPAY_MINI="ALIPAY_MINI",e.WEICHAT_MINI="WEICHAT_MINI"}(mt||(mt={}));var gt=function(){function e(){}return e.sign=function(t){for(var n=t.signedHeaders.join(";"),r="",i=0,a=t.signedHeaders;i<a.length;i++){var o=a[i],u=t.headers[o];r+="".concat(o,":").concat(u,"\n")}var c=e.createHash(t.body||""),s=t.method.toUpperCase()+"\n"+t.path+"\n"+t.query+"\n"+r+"\n"+n+"\n"+c+"\n",l="HMAC-SHA256",f=e.createHash(s),d="".concat(l,"\n").concat(t.timestamp,"\n").concat(f,"\n"),h=e.createSha256(d,t.secretKey);return"".concat(l," Credential=").concat(t.secretId,", SignedHeaders=").concat(n,", Signature=").concat(h)},e.createSha256=function(e,t){return void 0===t&&(t=""),yt(e,t).toString(st)},e.createHash=function(e){return vt(e).toString(st)},e}(),wt=function(){function e(){}return e.detectRuntime=function(){return window||void 0===("undefined"==typeof my?"undefined":i(my))?window||void 0===("undefined"==typeof wx?"undefined":i(wx))?mt.WEB:mt.WEICHAT_MINI:mt.ALIPAY_MINI},e.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},e.parseUrl=function(e,t){if(t===mt.WEB)return new URL(e);var n=e.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=n[1],i=n[2],a=n[3],o=n[4];return{protocol:r||"",host:i||"",pathname:"".concat(a||""),search:o||""}},e}();var bt=function(){function e(e,t){this.req=e,this.config=t}return Object.defineProperty(e.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),e}(),kt=function(){function e(){}return e.prototype.request=function(e,t){return S(this,void 0,void 0,(function(){var n,r,i;return R(this,(function(a){switch(a.label){case 0:return[4,fetch(e,E({mode:"cors"},t))];case 1:return n=a.sent(),r={},n.headers.forEach((function(e,t){r[t]=e})),i={status:n.status},[4,n.json()];case 2:return[2,(i.data=a.sent(),i.headers=r,i)]}}))}))},e}(),Ct=function(){function e(){}return e.prototype.request=function(e,t){return S(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:e,method:(null==t?void 0:t.method)||"GET",data:null==t?void 0:t.body,headers:null==t?void 0:t.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]}}))}))},e}(),_t=function(){function e(){}return e.prototype.request=function(e,t){return S(this,void 0,void 0,(function(){return R(this,(function(n){return[2,new Promise((function(n,r){wx.request({url:e,method:(null==t?void 0:t.method)||"GET",data:null==t?void 0:t.body,header:null==t?void 0:t.headers,dataType:"json",success:function(e){n({status:e.statusCode,data:e.data,headers:e.header})},reject:function(e){r(new Error("error: ".concat(e.errno,", message: ").concat(e.errMsg)))}})}))]}))}))},e}(),At=function(){function e(){}return e.default=function(e){if(!this.singleton)switch(e){case mt.ALIPAY_MINI:this.singleton=new Ct;break;case mt.WEB:this.singleton=new kt;break;case mt.WEICHAT_MINI:this.singleton=new _t;break;default:throw new Error("未知运行环境".concat(e))}return this.singleton},e}();function xt(e,t){return S(this,void 0,void 0,(function(){var n,r;return R(this,(function(i){switch(i.label){case 0:return[4,t()];case 1:return i.sent(),n=e.config.fetch||At.default(e.config.runtime),r=e,[4,n.request(e.req.url,e.req.requestOptions)];case 2:return r.res=i.sent(),e.result={status:e.res.status,requestID:e.requestId,headers:e.res.headers,data:e.res.data},[2]}}))}))}function Ot(e,t){return S(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t()];case 1:return r.sent(),[3,3];case 2:throw n=r.sent(),I.FaasError.NETWORK_ERR(n,e.requestId);case 3:return[2]}}))}))}function Pt(e){return function(t,n){return S(this,void 0,void 0,(function(){var r,i,a,o,u;return R(this,(function(c){switch(c.label){case 0:return r=Date.now(),i=wt.parseUrl(t.req.url,t.config.runtime),a={authorization:"","x-from-app-id":t.config.appId,"x-from-env-id":t.config.envId,"x-to-env-id":t.config.envId,"x-from-instance-id":"".concat(r),"x-from-function-name":t.config.functionName,"x-client-timestamp":"".concat(r)},e.length>0&&e.forEach((function(e){var n,r=null===(n=t.req.requestOptions.headers)||void 0===n?void 0:n[e];r&&(a[e]=r)})),o=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],e,!0).sort(),u={path:i.pathname,query:i.search.substring(1),secretId:t.config.secretId,secretKey:t.config.secretKey,method:t.req.requestOptions.method,headers:a,body:t.req.requestOptions.body,timestamp:r,signedHeaders:o},a.authorization=gt.sign(u),t.req.requestOptions.headers=E(E({},a),t.req.requestOptions.headers),[4,n()];case 1:return c.sent(),[2]}}))}))}}var jt=function(){function e(e,t){var n;this.config=e,this.handler=(n=t,function(e,t){var r=-1;return function i(a){if(a<=r)return Promise.reject(new Error("next() called multiple times"));r=a;var o=n[a];if(a===n.length&&(o=t),!o)return Promise.resolve();try{return Promise.resolve(o(e,i.bind(null,a+1)))}catch(e){return Promise.reject(e)}}(0)})}return e.prototype.request=function(e){var t=e.method,n=e.path,r=e.data,i=e.headers;return S(this,void 0,void 0,(function(){var e,a,o,u;return R(this,(function(c){switch(c.label){case 0:return e=this.config.endpoint+n,a=r?JSON.stringify(r):r,o=wt.generateUUID(),i=Object.assign({"x-alipay-callid":o,"x-request-id":o,"x-alipay-source":"web,web-sdk","content-type":"application/json"},i),u=new bt({url:e,requestOptions:{method:t,body:a,headers:i}},this.config),[4,this.handler(u)];case 1:return c.sent(),[2,u.result]}}))}))},e.createFunctionHttpclient=function(t){return new e(t,[Ot,Pt(["x-to-function-name"]),xt])},e}(),Mt=function(){function e(e){var t=e.resourceEnv||e.envId,n=e.resourceAppid||e.appId;this.config={endpoint:e.endpoint||"https://".concat(t,".api-hz.cloudbasefunction.cn"),secretId:e.secretId,secretKey:e.secretKey,appId:n,envId:t,fetch:e.fetch,runtime:e.runtime||wt.detectRuntime(),functionName:""}}return e.prototype.init=function(){},e.prototype.callFunction=function(e){var t;return S(this,void 0,void 0,(function(){var n,r;return R(this,(function(i){switch(i.label){case 0:return n=E(E({},this.config),{envId:(null===(t=e.config)||void 0===t?void 0:t.env)||this.config.envId,functionName:e.name}),r=jt.createFunctionHttpclient(n),[4,I.WebSDK.createCallFunction({type:"web",httpclient:r})(e)];case 1:return[2,i.sent()]}}))}))},e}();e.Cloud=Mt}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/faas-web-sdk",
3
- "version": "1.1.8-alpha.6",
3
+ "version": "1.1.8",
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.8-alpha.6",
21
+ "@alipay/faas-common-sdk": "^1.1.8",
22
22
  "crypto-js": "^4.1.1"
23
23
  },
24
24
  "devDependencies": {