@alipay/faas-web-sdk 1.1.25 → 1.1.26
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/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,16 @@ interface CallFunctionParam extends CallFunctionParam$1 {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
interface SignedUrlOptions$1 {
|
|
61
|
+
authorization?: string;
|
|
62
|
+
queryString?: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
declare class SSE {
|
|
65
|
+
private config;
|
|
66
|
+
constructor(config: CloudRunConfig);
|
|
67
|
+
signedURL(functionName: string, opts?: SignedUrlOptions$1): string;
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
interface SignedUrlOptions {
|
|
61
71
|
authorization?: string;
|
|
62
72
|
queryString?: Record<string, string>;
|
|
@@ -72,6 +82,7 @@ declare class Cloud {
|
|
|
72
82
|
private readonly config;
|
|
73
83
|
private storage;
|
|
74
84
|
private websocket;
|
|
85
|
+
private SSE;
|
|
75
86
|
constructor(config: CloudConfig);
|
|
76
87
|
init(): void;
|
|
77
88
|
callFunction(params: CallFunctionParam): Promise<_alipay_faas_common_sdk.CallFunctionResult<any>>;
|
|
@@ -81,6 +92,7 @@ declare class Cloud {
|
|
|
81
92
|
deleteFile(param: DeleteFileParam): Promise<DeleteFileResult>;
|
|
82
93
|
getTempFileURL(param: GetTempFileURLParam): Promise<GetTempFileURLResult>;
|
|
83
94
|
ws(): Websocket;
|
|
95
|
+
sse(): SSE;
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
export { Cloud };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};var r=function(){return r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var u,c,a,s,p,f,l=(u=function(t,n){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},u(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),h=function(t){function n(e,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=e,o.errorMessage=r,Object.setPrototypeOf(o,n.prototype),o}return l(n,t),Object.defineProperty(n.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),n.INVALID_PARAM_ERR=function(t,e){return new n(60001,'无效入参,参数 "'.concat(t,'" ').concat(e))},n.NOT_FOUND_ERR=function(t){return new n(60001,t)},n.SERVER_ERR=function(t,e,r,o){var i=new n(t,e);return i.requestID=r,i.httpStatus=o,i},n.STORAGE_ERR=function(t,e,r){var o=new n(t,e);return o.requestID=r,o},n.NETWORK_ERR=function(t,e){var r=new n(-1,t.toString());return r.requestID=e,r},n}(Error),y=function(t,n){return void 0===n&&(n=void 0),function(e){if(!((null==e?void 0:e.complete)||(null==e?void 0:e.success)||(null==e?void 0:e.fail)))return t.call(n,e);var r=e.complete,o=e.success,i=e.fail,u=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(e,["complete","success","fail"]);t.call(n,u).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}},d=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var n=t.data||{code:-1,message:"未知异常"},e=n.code,r=n.message;throw h.SERVER_ERR(e,r,t.requestID,t.status)}return t.data.data},t}(),v=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},w=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},g=function(){return g=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},g.apply(this,arguments)},m=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},b=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};!function(t){t.DESC="desc",t.ASC="asc"}(c||(c={})),function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(a||(a={})),function(t){t.update="update",t.findOneAndUpdate="findOneAndUpdate",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(s||(s={})),function(t){t.collection="collection",t.document="document"}(p||(p={})),function(t){t.addFields="$addFields",t.count="$count",t.match="$match",t.group="$group",t.project="$project",t.replaceRoot="$replaceRoot",t.sample="$sample",t.lookup="$lookup",t.sort="$sort",t.limit="$limit",t.skip="$skip",t.unwind="$unwind",t.geoNear="$geoNear",t.bucket="$bucket",t.bucketAuto="$bucketAuto",t.sortByCount="$sortByCount"}(f||(f={}));var _,O,A,j=(_=function(t,n){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},_(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}_(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),x=function(){},P=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(x),S=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(P),I=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(P),R=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(S),C=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(x),E=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),N=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),k=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),D=function(t){function n(n,e){var r=t.call(this)||this;return r.name="$"+n,r.value=e,r}return j(n,t),n.prototype.stringify=function(){var t;return(t={})[this.name]=this.value,t},n}(x),T=function(){function t(t){this.lastCmd=t}return t.unchain=function(n){return n instanceof t?n.lastCmd:n},t}(),q=(O=function(t,n){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},O(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}O(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});!function(t){t.INVALID_PARAM="INVALID_PARAM",t.INVALID_COMMAND="INVALID_COMMAND",t.SEMANTIC_ERROR="SEMANTIC_ERROR"}(A||(A={}));var $,F=function(t){function n(e){var r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return q(n,t),n.create=function(t,e){var r=new n(e);return r.code=t,r},n.invalidParam=function(t,e){return n.create(A.INVALID_PARAM,'无效入参,参数 "'.concat(t,'" ').concat(e))},n.invalidCommand=function(t){return n.create(A.INVALID_COMMAND,t)},n.semanticError=function(t){return n.create(A.SEMANTIC_ERROR,t)},n}(Error),B=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(this.data instanceof x){if(!(this.data instanceof D))throw F.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data||this.data instanceof Date)return this.data;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));switch(n(this.data)){case"number":case"boolean":case"string":case"bigint":case"undefined":return this.data;case"function":throw F.invalidParam(this.prefix,"不支持函数");case"symbol":throw F.invalidParam(this.prefix,"不支持 symbol");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i).stringify();void 0!==u&&(r[o]=u)}return r}},t.prototype.toJSON=function(){var t=this.stringify();if(void 0===t)throw F.invalidParam(this.prefix,"不支持 undefined");return t},t}(),L=($=function(t,n){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},$(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}$(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),M=function(t){function n(n,e){return t.call(this,n,new B(e).toJSON())||this}return L(n,t),n}(D),U=function(t){function n(n){return t.call(this,"abs",n)||this}return L(n,t),n}(M),H=function(t){function n(n){return t.call(this,"add",n)||this}return L(n,t),n}(M),W=function(t){function n(n){return t.call(this,"addToSet",n)||this}return L(n,t),n}(M),z=function(t){function n(n){return t.call(this,"and",n)||this}return L(n,t),n}(M),K=function(t){function n(n){return t.call(this,"arrayElemAt",n)||this}return L(n,t),n}(M),V=function(t){function n(n){return t.call(this,"avg",n)||this}return L(n,t),n}(M),J=function(t){function n(n){return t.call(this,"ceil",n)||this}return L(n,t),n}(M),G=function(t){function n(n){return t.call(this,"cmp",n)||this}return L(n,t),n}(M),Y=function(t){function n(n){return t.call(this,"concat",n)||this}return L(n,t),n}(M),Q=function(t){function n(n){var e=Array.isArray(n)?{if:n[0],then:n[1],else:n[2]}:n;return t.call(this,"cond",e)||this}return L(n,t),n}(M),X=function(t){function n(){return t.call(this,"count",{})||this}return L(n,t),n.prototype.stringify=function(){return{$sum:1}},n}(M),Z=function(t){function n(n){return t.call(this,"dateToString",n)||this}return L(n,t),n}(M),tt=function(t){function n(n){return t.call(this,"divide",n)||this}return L(n,t),n}(M),nt=function(t){function n(n){return t.call(this,"eq",n)||this}return L(n,t),n}(M),et=function(t){function n(n){return t.call(this,"exp",n)||this}return L(n,t),n}(M),rt=function(t){function n(n){return t.call(this,"first",n)||this}return L(n,t),n}(M),ot=function(t){function n(n){return t.call(this,"floor",n)||this}return L(n,t),n}(M),it=function(t){function n(n){return t.call(this,"gt",n)||this}return L(n,t),n}(M),ut=function(t){function n(n){return t.call(this,"gte",n)||this}return L(n,t),n}(M),ct=function(t){function n(n){return t.call(this,"ifNull",n)||this}return L(n,t),n}(M),at=function(t){function n(n){return t.call(this,"in",n)||this}return L(n,t),n}(M),st=function(t){function n(n){return t.call(this,"indexOfArray",n)||this}return L(n,t),n}(M),pt=function(t){function n(n){return t.call(this,"isArray",n)||this}return L(n,t),n}(M),ft=function(t){function n(n){return t.call(this,"isoWeek",n)||this}return L(n,t),n}(M),lt=function(t){function n(n){return t.call(this,"last",n)||this}return L(n,t),n}(M),ht=function(t){function n(n){return t.call(this,"let",n)||this}return L(n,t),n}(M),yt=function(t){function n(n){return t.call(this,"ln",n)||this}return L(n,t),n}(M),dt=function(t){function n(n){return t.call(this,"log",n)||this}return L(n,t),n}(M),vt=function(t){function n(n){return t.call(this,"log10",n)||this}return L(n,t),n}(M),wt=function(t){function n(n){return t.call(this,"lt",n)||this}return L(n,t),n}(M),gt=function(t){function n(n){return t.call(this,"lte",n)||this}return L(n,t),n}(M),mt=function(t){function n(n){return t.call(this,"map",n)||this}return L(n,t),n}(M),bt=function(t){function n(n){return t.call(this,"max",n)||this}return L(n,t),n}(M),_t=function(t){function n(n){return t.call(this,"mergeObjects",n)||this}return L(n,t),n}(M),Ot=function(t){function n(n){return t.call(this,"min",n)||this}return L(n,t),n}(M),At=function(t){function n(n){return t.call(this,"mod",n)||this}return L(n,t),n}(M),jt=function(t){function n(n){return t.call(this,"month",n)||this}return L(n,t),n}(M),xt=function(t){function n(n){return t.call(this,"multiply",n)||this}return L(n,t),n}(M),Pt=function(t){function n(n){return t.call(this,"ne",n)||this}return L(n,t),n}(M),St=function(t){function n(n){return t.call(this,"not",[n])||this}return L(n,t),n}(M),It=function(t){function n(n){return t.call(this,"or",n)||this}return L(n,t),n}(M),Rt=function(t){function n(n){return t.call(this,"pow",n)||this}return L(n,t),n}(M),Ct=function(t){function n(n){return t.call(this,"push",n)||this}return L(n,t),n}(M),Et=function(t){function n(n){return t.call(this,"size",n)||this}return L(n,t),n}(M),Nt=function(t){function n(n){return t.call(this,"slice",n)||this}return L(n,t),n}(M),kt=function(t){function n(n){return t.call(this,"split",n)||this}return L(n,t),n}(M),Dt=function(t){function n(n){return t.call(this,"sqrt",n)||this}return L(n,t),n}(M),Tt=function(t){function n(n){return t.call(this,"substr",n)||this}return L(n,t),n}(M),qt=function(t){function n(n){return t.call(this,"substrBytes",n)||this}return L(n,t),n}(M),$t=function(t){function n(n){return t.call(this,"subtract",n)||this}return L(n,t),n}(M),Ft=function(t){function n(n){return t.call(this,"sum",n)||this}return L(n,t),n}(M),Bt=function(t){function n(n){var e=n.branches.map((function(t){return Array.isArray(t)?{case:t[0],then:t[1]}:{case:t.case,then:t.then}}));return t.call(this,"switch",{branches:e,default:n.default})||this}return L(n,t),n}(M),Lt=function(t){function n(n){return t.call(this,"toLower",n)||this}return L(n,t),n}(M),Mt=function(t){function n(n){return t.call(this,"toUpper",n)||this}return L(n,t),n}(M),Ut=function(t){function n(n){return t.call(this,"trunc",n)||this}return L(n,t),n}(M),Ht=function(t){function n(n){return t.call(this,"week",n)||this}return L(n,t),n}(M),Wt=function(t){function n(n){return t.call(this,"year",n)||this}return L(n,t),n}(M),zt=function(t){function n(n){return t.call(this,"allElementsTrue",n)||this}return L(n,t),n}(M),Kt=function(t){function n(n){return t.call(this,"anyElementTrue",n)||this}return L(n,t),n}(M),Vt=function(t){function n(n){return t.call(this,"setDifference",n)||this}return L(n,t),n}(M),Jt=function(t){function n(n){return t.call(this,"setEquals",n)||this}return L(n,t),n}(M),Gt=function(t){function n(n){return t.call(this,"setIntersection",n)||this}return L(n,t),n}(M),Yt=function(t){function n(n){return t.call(this,"setIsSubset",n)||this}return L(n,t),n}(M),Qt=function(t){function n(n){return t.call(this,"setUnion",n)||this}return L(n,t),n}(M),Xt=function(t){function n(n){return t.call(this,"literal",n)||this}return L(n,t),n}(M),Zt=function(t){function n(n){return t.call(this,"arrayToObject",n)||this}return L(n,t),n}(M),tn=function(t){function n(n){return t.call(this,"concatArrays",n)||this}return L(n,t),n}(M),nn=function(t){function n(n){return t.call(this,"filter",n)||this}return L(n,t),n}(M),en=function(t){function n(n){return t.call(this,"objectToArray",n)||this}return L(n,t),n}(M),rn=function(t){function n(n){return t.call(this,"range",n)||this}return L(n,t),n}(M),on=function(t){function n(n){return t.call(this,"reduce",n)||this}return L(n,t),n}(M),un=function(t){function n(n){return t.call(this,"reverseArray",n)||this}return L(n,t),n}(M),cn=function(t){function n(n){return t.call(this,"zip",n)||this}return L(n,t),n}(M),an=function(t){function n(n){return t.call(this,"dateFromString",n)||this}return L(n,t),n}(M),sn=function(t){function n(n){return t.call(this,"indexOfBytes",n)||this}return L(n,t),n}(M),pn=function(t){function n(n){return t.call(this,"indexOfCP",n)||this}return L(n,t),n}(M),fn=function(t){function n(n){return t.call(this,"strLenBytes",n)||this}return L(n,t),n}(M),ln=function(t){function n(n){return t.call(this,"strLenCP",n)||this}return L(n,t),n}(M),hn=function(t){function n(n){return t.call(this,"strcasecmp",n)||this}return L(n,t),n}(M),yn=function(t){function n(n){return t.call(this,"substrCP",n)||this}return L(n,t),n}(M),dn=function(t){function n(n){return t.call(this,"stdDevPop",n)||this}return L(n,t),n}(M),vn=function(t){function n(n){return t.call(this,"stdDevSamp",n)||this}return L(n,t),n}(M),wn=function(t){function n(n){return t.call(this,"dateFromParts",n)||this}return L(n,t),n}(M),gn=function(t){function n(n){return t.call(this,"dayOfMonth",n)||this}return L(n,t),n}(M),mn=function(t){function n(n){return t.call(this,"dayOfWeek",n)||this}return L(n,t),n}(M),bn=function(t){function n(n){return t.call(this,"dayOfYear",n)||this}return L(n,t),n}(M),_n=function(t){function n(n){return t.call(this,"hour",n)||this}return L(n,t),n}(M),On=function(t){function n(n){return t.call(this,"isoDayOfWeek",n)||this}return L(n,t),n}(M),An=function(t){function n(n){return t.call(this,"isoWeekYear",n)||this}return L(n,t),n}(M),jn=function(t){function n(n){return t.call(this,"millisecond",n)||this}return L(n,t),n}(M),xn=function(t){function n(n){return t.call(this,"minute",n)||this}return L(n,t),n}(M),Pn=function(t){function n(n){return t.call(this,"second",n)||this}return L(n,t),n}(M),Sn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),In=function(){function t(t,n){this.type=t,this.coordinates=n}return t.prototype.toJSON=function(){return{type:this.type,coordinates:this.coordinates}},t}(),Rn=function(t){function n(n,e){var r=t.call(this,"Point",[n,e])||this;return r.longitude=n,r.latitude=e,r}return Sn(n,t),n}(In);!function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"LineString",r)||this).points=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"Polygon",r)||this).lines=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiPoint",r)||this).points=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiLineString",r)||this).lines=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiPolygon",r)||this).polygons=n,e}Sn(n,t)}(In);var Cn,En=function(){function t(t){this.regexp=t.regexp,this.options=t.options||""}return t.prototype.stringify=function(){return{$regex:this.regexp,$options:this.options}},t}(),Nn=function(){function t(){}return t.mergeTo=function(t,e){var r;for(var o in e)t[o]?Array.isArray(t[o])?(r=t[o]).push.apply(r,e[o]):"object"===n(t[o])&&"object"===n(e[o])?Object.assign(t[o],e[o]):t[o]=e[o]:t[o]=e[o]},t}(),kn=function(){function t(t,n,e){void 0===n&&(n=""),void 0===e&&(e=""),this.query=t,this.prefix=n,this.keyName=e}return t.prototype.stringify=function(){var e=this,r=T.unchain(this.query);if(r instanceof E)return r.stringifyWithKey(this.keyName);if(r instanceof C)return r.stringify();if(r instanceof En)return r.stringify();if(r instanceof RegExp)return r;if(r instanceof Date)return r;if(Array.isArray(r))return r.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));var o=n(r);return"object"!==o?this.stringifyBuiltInValue(r,o):null===r?r:this.stringifyObject(r)},t.prototype.stringifyWithKey=function(){var e,r,o,i,u,c,a,s=this,p=T.unchain(this.query);if(p instanceof E)return p.stringifyWithKey(this.keyName);if(p instanceof C)return p instanceof k?p.stringify():((e={})[this.keyName]=p.stringify(),e);if(p instanceof En)return(r={})[this.keyName]=p.stringify(),r;if(p instanceof RegExp)return(o={})[this.keyName]=p,o;if(p instanceof Date)return(i={})[this.keyName]=p,i;if(Array.isArray(p)){var f=p.map((function(n,e){return new t(n,"".concat(s.prefix,".$.").concat(e)).stringify()}));return(u={})[this.keyName]=f,u}var l=n(p);return"object"!==l?((c={})[this.keyName]=this.stringifyBuiltInValue(p,l),c):null===p?((a={})[this.keyName]=p,a):this.stringifyObject(p)},t.prototype.toJSON=function(){var t=this.stringify();if(void 0===t)throw F.invalidParam(this.prefix,"不支持 undefined");return t},t.prototype.stringifyBuiltInValue=function(t,n){switch(n){case"number":case"boolean":case"string":case"bigint":default:return t;case"function":throw F.invalidParam(this.prefix,"不支持函数");case"symbol":throw F.invalidParam(this.prefix,"不支持 symbol");case"undefined":return}},t.prototype.stringifyObject=function(n){var e,r={};for(var o in n){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=T.unchain(n[o]);if(u instanceof E){var c=u.stringifyWithKey(i);Nn.mergeTo(r,c)}else{var a=new t(u,i,o).stringify();void 0!==a&&Nn.mergeTo(r,((e={})[o]=a,e))}}return r},t}(),Dn=function(){return Dn=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Dn.apply(this,arguments)},Tn=function(){function t(){this.pipeline=[]}return t.prototype.addFields=function(t){return this.pushStage(f.addFields,t),this},t.prototype.count=function(t){return this.pushStage(f.count,t),this},t.prototype.match=function(t){return this.pushStage(f.match,t),this},t.prototype.group=function(t){return this.pushStage(f.group,t),this},t.prototype.project=function(t){return this.pushStage(f.project,t),this},t.prototype.replaceRoot=function(t){return this.pushStage(f.replaceRoot,t),this},t.prototype.sample=function(t){return this.pushStage(f.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(f.lookup,t),this},t.prototype.sort=function(t){return this.pushStage(f.sort,t),this},t.prototype.limit=function(t){return this.pushStage(f.limit,t),this},t.prototype.skip=function(t){return this.pushStage(f.skip,t),this},t.prototype.unwind=function(t){return this.pushStage(f.unwind,t),this},t.prototype.geoNear=function(t){return this.pushStage(f.geoNear,t),this},t.prototype.bucket=function(t){return this.pushStage(f.bucket,t),this},t.prototype.bucketAuto=function(t){return this.pushStage(f.bucketAuto,t),this},t.prototype.sortByCount=function(t){return this.pushStage(f.sortByCount,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var n,e;switch(t.name){case f.geoNear:var r=Dn({},t.param);return t.param.query&&(r.query=new kn(t.param.query).toJSON()),t.param.near instanceof Rn&&(r.near=t.param.near.toJSON()),{$geoNear:r};case f.match:return{$match:new kn(t.param).toJSON()};case f.count:case f.sample:case f.limit:case f.skip:case f.unwind:return(n={})[t.name]=t.param,n;case f.lookup:case f.addFields:case f.group:case f.sortByCount:case f.project:case f.bucket:case f.bucketAuto:case f.replaceRoot:return(e={})[t.name]=new B(t.param).toJSON(),e;case f.sort:return{$sort:Object.keys(t.param).reduce((function(n,e){var r;switch(t.param[e]){case c.DESC:r=-1;break;case c.ASC:case 1:r=1;break;case-1:r=-1;break;default:r=1}return n[e]=r,n}),{})};default:var o=t.name;throw F.invalidParam(o,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,n){this.pipeline.push({name:t,param:n})},t}(),qn=(Cn=function(t,n){return Cn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},Cn(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}Cn(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),$n=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return qn(n,t),n.prototype.stringify=function(){return{$all:this.val}},n}(C),Fn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Bn=function(t){function n(n){var e,r=t.call(this)||this;return r.commands=[],(e=r.commands).push.apply(e,n),r}return Fn(n,t),Object.defineProperty(n.prototype,"op",{get:function(){return"$".concat(this.name)},enumerable:!1,configurable:!0}),n.prototype.pushCommand=function(t){this.commands.push(t)},n.prototype.stringifyWithKey=function(t){var n,e=this.commands.map((function(n){return new kn(n,"",t).stringifyWithKey()}));return(n={})[this.op]=e,n},n.prototype.stringify=function(){return this.stringifyWithKey("")},n}(E),Ln=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="and",n}return Fn(n,t),n}(Bn),Mn=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="or",n}return Fn(n,t),n}(Bn),Un=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="nor",n}return Fn(n,t),n}(Bn),Hn=function(t){function n(n){var e=t.call(this)||this;return e.command=n,e}return Fn(n,t),n.prototype.stringifyWithKey=function(t){var n,e={$not:new kn(this.command,"",t).stringify()};return t?((n={})[t]=e,n):e},n.prototype.stringify=function(){return this.stringifyWithKey("")},n}(E),Wn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),zn=function(t){function n(n){var e=t.call(this)||this;return e.val=new kn(n).toJSON(),e}return Wn(n,t),n.prototype.stringify=function(){return{$elemMatch:this.val}},n}(C),Kn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Vn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Kn(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(C),Jn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Gn=function(t){function n(n){var e=t.call(this)||this;return e.exists=n,e}return Jn(n,t),n.prototype.stringify=function(){return{$exists:this.exists}},n}(C),Yn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Qn=function(t){function n(n){var e=t.call(this)||this;return e.commands=new B(n).toJSON(),e}return Yn(n,t),n.prototype.stringify=function(){return{$expr:this.commands}},n}(k),Xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Zn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Xn(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(C),te=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ne=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return te(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(C),ee=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),re=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ee(n,t),n.prototype.stringify=function(){return{$in:this.val}},n}(C),oe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ie=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return oe(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(C),ue=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ce=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ue(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(C),ae=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),se=function(t){function n(n,e){var r=t.call(this)||this;return r.divisor=n,r.remainder=e,r}return ae(n,t),n.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},n}(C),pe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),fe=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return pe(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(C),le=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),he=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return le(n,t),n.prototype.stringify=function(){return{$nin:this.val}},n}(C),ye=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),de=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return ye(n,t),n.prototype.appendCommand=function(t){return t=n.unchain(t),this.lastCmd instanceof Ln?this.lastCmd.pushCommand(t):this.lastCmd=new Ln([this.lastCmd,t]),this},n.prototype.and=function(t){return this.appendCommand(t)},n.prototype.or=function(t){return t=n.unchain(t),this.lastCmd instanceof Mn?this.lastCmd.pushCommand(t):this.lastCmd=new Mn([this.lastCmd,t]),this},n.prototype.not=function(t){return this.appendCommand(t)},n.prototype.nor=function(t){return this.appendCommand(t)},n.prototype.eq=function(t){return this.appendCommand(new Vn(t))},n.prototype.neq=function(t){return this.appendCommand(new fe(t))},n.prototype.lt=function(t){return this.appendCommand(new ie(t))},n.prototype.lte=function(t){return this.appendCommand(new ce(t))},n.prototype.gt=function(t){return this.appendCommand(new Zn(t))},n.prototype.gte=function(t){return this.appendCommand(new ne(t))},n.prototype.in=function(t){return this.appendCommand(new re(t))},n.prototype.nin=function(t){return this.appendCommand(new he(t))},n.prototype.exists=function(t){return this.appendCommand(new Gn(t))},n.prototype.mod=function(t,n){return this.appendCommand(new se(t,n))},n.prototype.all=function(t){return this.appendCommand(new $n(t))},n.prototype.elemMatch=function(t){return this.appendCommand(new zn(n.unchain(t)))},n.prototype.size=function(t){return this.appendCommand(t)},n}(T),ve=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),we=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ve(n,t),n.prototype.stringify=function(){return{$size:this.val}},n}(C),ge=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),me=function(t){function e(n){var e=t.call(this)||this;return e.value=n,e}return ge(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$addToSet"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return Array.isArray(this.value)?{$each:this.value}:"object"===n(this.value)&&this.value.hasOwnProperty("each")?{$each:this.value.each}:this.value},e}(I),be=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_e=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return be(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Oe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ae=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Oe(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$max"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),je=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),xe=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return je(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$min"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Pe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Se=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Pe(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$mul"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Ie=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Re=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Ie(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.value||1},n}(I),Ce=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ee=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Ce(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pull"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.stringifyWithKey("")},n.prototype.stringifyWithKey=function(t){var n;return new kn((n={},n[t]=this.value,n)).stringify()},n}(R),Ne=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ke=function(t){function n(n){var e=t.call(this)||this;return e.values=n,e}return Ne(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pullAll"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.values},n}(I),De=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Te=function(){return Te=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Te.apply(this,arguments)},qe=function(t){function e(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var i=t.call(this)||this;return"object"===n(i.value)&&i.value.hasOwnProperty("each")?i.value=e:(null==r?void 0:r.length)>0?i.value=[].concat.apply([],function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([e],r,!1)):i.value=e,i}return De(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){if(Array.isArray(this.value))return{$each:this.value};if("object"===n(this.value)&&this.value.hasOwnProperty("each")){var t=this.value,e={$each:t.each};return void 0!==t.position&&(e.$position=t.position),void 0!==t.slice&&(e.$slice=t.slice),void 0!==t.sort&&("string"==typeof t.sort?e.$sort=t.sort===c.DESC?-1:1:e.$sort=t.sort),e}return"object"===n(this.value)&&"string"==typeof this.value.$sort?Te(Te({},this.value),{$sort:this.value.$sort===c.DESC?-1:1}):this.value},e}(I),$e=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Fe=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return $e(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$unset"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return""},n}(P),Be=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Le=function(t){function n(n){var e=t.call(this)||this;return e.name=n,e}return Be(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$rename"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.name},n}(P),Me=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ue=function(t){function n(n){var e=t.call(this)||this;return e.data=n,e}return Me(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.data},n}(P),He=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),We=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return He(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.centerSphere&&(t.$centerSphere=this.val.centerSphere),void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),{$geoWithin:t}},n}(N),ze=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return He(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),void 0!==this.val.maxDistance&&(t.$maxDistance=this.val.maxDistance),void 0!==this.val.minDistance&&(t.$minDistance=this.val.minDistance),{$nearSphere:t}},n}(N),Ke=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return He(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),{$geoIntersects:t}},n}(N),Ve=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Je=function(t){function n(n){var e=t.call(this)||this;return Array.isArray(n)?e.val=n:e.val=[n],e}return Ve(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){var t={$each:this.val,$position:0};return t},n}(P),Ge=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ye=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return Ge(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return-1},n}(P),Qe=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},Xe=function(){function t(){}return t.prototype.pipeline=function(){return new Tn},t.prototype.avg=function(t){return new V(t)},t.prototype.count=function(){return new X},t.prototype.max=function(t){return new bt(t)},t.prototype.min=function(t){return new Ot(t)},t.prototype.sum=function(t){return new Ft(t)},t.prototype.and=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new z(r)},t.prototype.or=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new It(r)},t.prototype.not=function(t){return new St(t)},t.prototype.cmp=function(t,n){var e=Array.isArray(t)?t:[t,n];return new G(e)},t.prototype.eq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new nt(e)},t.prototype.neq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Pt(e)},t.prototype.lt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new wt(e)},t.prototype.lte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new gt(e)},t.prototype.gt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new it(e)},t.prototype.gte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ut(e)},t.prototype.addToSet=function(t){return new W(t)},t.prototype.arrayElemAt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new K(e)},t.prototype.indexOfArray=function(t,n,e,r){var o=Array.isArray(t)?t:[t,n,e,r].filter((function(t){return void 0!==t}));return new st(o)},t.prototype.isArray=function(t){return new pt(t)},t.prototype.size=function(t){return new Et(t)},t.prototype.in=function(t,n){var e=Array.isArray(t)?t:[t,n];return new at(e)},t.prototype.slice=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e].filter((function(t){return void 0!==t}));return new Nt(r)},t.prototype.map=function(t){return new mt(t)},t.prototype.ifNull=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ct(e)},t.prototype.cond=function(t){return new Q(t)},t.prototype.switch=function(t){return new Bt(t)},t.prototype.concat=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new Y(r)},t.prototype.dateToString=function(t){return new Z(t)},t.prototype.toLower=function(t){return new Lt(t)},t.prototype.toUpper=function(t){return new Mt(t)},t.prototype.split=function(t,n){var e=Array.isArray(t)?t:[t,n];return new kt(e)},t.prototype.substr=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new Tt(r)},t.prototype.substrBytes=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new qt(r)},t.prototype.first=function(t){return new rt(t)},t.prototype.last=function(t){return new lt(t)},t.prototype.push=function(t){return new Ct(t)},t.prototype.let=function(t){return new ht(t)},t.prototype.add=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new H(r)},t.prototype.subtract=function(t,n){var e=Array.isArray(t)?t:[t,n];return new $t(e)},t.prototype.multiply=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new xt(r)},t.prototype.divide=function(t,n){var e=Array.isArray(t)?t:[t,n];return new tt(e)},t.prototype.abs=function(t){return new U(t)},t.prototype.ceil=function(t){return new J(t)},t.prototype.exp=function(t){return new et(t)},t.prototype.floor=function(t){return new ot(t)},t.prototype.ln=function(t){return new yt(t)},t.prototype.log=function(t,n){var e=Array.isArray(t)?t:[t,n];return new dt(e)},t.prototype.log10=function(t){return new vt(t)},t.prototype.mod=function(t,n){var e=Array.isArray(t)?t:[t,n];return new At(e)},t.prototype.pow=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Rt(e)},t.prototype.sqrt=function(t){return new Dt(t)},t.prototype.trunc=function(t){return new Ut(t)},t.prototype.mergeObjects=function(t){return new _t(t)},t.prototype.month=function(t){return new jt(t)},t.prototype.year=function(t){return new Wt(t)},t.prototype.week=function(t){return new Ht(t)},t.prototype.isoWeek=function(t){return new ft(t)},t.prototype.arrayToObject=function(t){return new Zt(t)},t.prototype.concatArrays=function(t){return new tn(t)},t.prototype.filter=function(t){return new nn(t)},t.prototype.objectToArray=function(t){return new en(t)},t.prototype.range=function(t,n,e){var r=Array.isArray(t)?t:void 0!==e?[t,n,e]:[t,n];return new rn(r)},t.prototype.reduce=function(t){return new on(t)},t.prototype.reverseArray=function(t){return new un(t)},t.prototype.zip=function(t){return new cn(t)},t.prototype.dateFromString=function(t){return new an(t)},t.prototype.indexOfBytes=function(t){return new sn(t)},t.prototype.indexOfCP=function(t){return new pn(t)},t.prototype.strLenBytes=function(t){return new fn(t)},t.prototype.strLenCP=function(t){return new ln(t)},t.prototype.strcasecmp=function(t){return new hn(t)},t.prototype.substrCP=function(t){return new yn(t)},t.prototype.stdDevPop=function(t){return new dn(t)},t.prototype.stdDevSamp=function(t){return new vn(t)},t.prototype.allElementsTrue=function(t){return new zt(t)},t.prototype.anyElementTrue=function(t){return new Kt(t)},t.prototype.setDifference=function(t){return new Vt(t)},t.prototype.setEquals=function(t){return new Jt(t)},t.prototype.setIntersection=function(t){return new Gt(t)},t.prototype.setIsSubset=function(t){return new Yt(t)},t.prototype.setUnion=function(t){return new Qt(t)},t.prototype.literal=function(t){return new Xt(t)},t.prototype.dateFromParts=function(t){return new wn(t)},t.prototype.dayOfMonth=function(t){return new gn(t)},t.prototype.dayOfWeek=function(t){return new mn(t)},t.prototype.dayOfYear=function(t){return new bn(t)},t.prototype.hour=function(t){return new _n(t)},t.prototype.isoDayOfWeek=function(t){return new On(t)},t.prototype.isoWeekYear=function(t){return new An(t)},t.prototype.millisecond=function(t){return new jn(t)},t.prototype.minute=function(t){return new xn(t)},t.prototype.second=function(t){return new Pn(t)},t}(),Ze=function(){function t(){this.aggregate=new Xe,this.Sort=c}return t.prototype.addToSet=function(t){return new me(t)},t.prototype.inc=function(t){return new _e(t)},t.prototype.max=function(t){return new Ae(t)},t.prototype.min=function(t){return new xe(t)},t.prototype.mul=function(t){return new Se(t)},t.prototype.pop=function(t){return new Re(t)},t.prototype.pull=function(t){return new Ee(t)},t.prototype.pullAll=function(t){return new ke(t)},t.prototype.push=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return new(qe.bind.apply(qe,Qe([void 0,t],n,!1)))},t.prototype.remove=function(){return new Fe},t.prototype.rename=function(t){return new Le(t)},t.prototype.set=function(t){return new Ue(t)},t.prototype.expr=function(t){return new Qn(t)},t.prototype.geoWithin=function(t){return new We(t)},t.prototype.geoNear=function(t){return new ze(t)},t.prototype.geoIntersects=function(t){return new Ke(t)},t.prototype.unshift=function(t){return new Je(t)},t.prototype.shift=function(){return new Ye},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Ln(t.map(de.unchain));return new de(e)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Mn(t.map(de.unchain));return new de(e)},t.prototype.not=function(t){var n=new Hn(de.unchain(t));return new de(n)},t.prototype.nor=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Un(t.map(de.unchain));return new de(e)},t.prototype.eq=function(t){return new de(new Vn(t))},t.prototype.neq=function(t){return new de(new fe(t))},t.prototype.lt=function(t){return new de(new ie(t))},t.prototype.lte=function(t){return new de(new ce(t))},t.prototype.gt=function(t){return new de(new Zn(t))},t.prototype.gte=function(t){return new de(new ne(t))},t.prototype.in=function(t){return new de(new re(t))},t.prototype.nin=function(t){return new de(new he(t))},t.prototype.exists=function(t){return new de(new Gn(t))},t.prototype.mod=function(t,n){return new de(new se(t,n))},t.prototype.all=function(t){return new de(new $n(t))},t.prototype.elemMatch=function(t){return new de(new zn(de.unchain(t)))},t.prototype.size=function(t){return new de(new we(t))},t}(),tr=function(){function t(){}return t.buildCollectionAction=function(t,n){return{target:p.collection,action:t,collectionName:n}},t.buildCollectionListQueryAction=function(t){return{target:p.collection,action:a.queryList,options:t}},t.buildDocumentAction=function(t,n,e){return{target:p.document,action:t,collectionName:n,options:e}},t}(),nr=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),er=function(t){function n(n){var e=t.call(this)||this;return e.collectionName=n,e}return nr(n,t),n.prototype.end=function(){var t={$aggregate:this.done()};return tr.buildDocumentAction(s.aggregate,this.collectionName,t)},n}(Tn),rr=function(){function t(){this.res={}}return t.prototype.set=function(t,n){this.res.$set=this.res.$set||{},this.res.$set[t]=n},t.prototype.applyOperator=function(t,n,e){this.res[t]=this.res[t]||{},this.res[t][n]=e},t.prototype.mergeOperator=function(t,n){this.res[t]||(this.res[t]={}),Nn.mergeTo(this.res[t],n)},t.prototype.emit=function(){return this.res},t}(),or=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(e){for(var r in e=e||new rr,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],u=n(i);if(i instanceof x){if(!(i instanceof P))throw F.invalidCommand("Command 不是更新操作");i instanceof S?e.mergeOperator(i.operator,i.stringifyWithKey(o)):e.applyOperator(i.operator,o,i.stringify())}else if(i instanceof In)e.set(o,i.toJSON());else if(i instanceof Date)e.set(o,i);else if("number"===u)e.set(o,i);else if("boolean"===u)e.set(o,i);else if("string"===u)e.set(o,i);else if("bigint"===u)e.set(o,i);else{if("function"===u)throw F.invalidParam(o,"不支持函数");if("symbol"===u)throw F.invalidParam(o,"不支持 symbol");if("undefined"===u);else if(null===i)e.set(o,i);else if(Array.isArray(i))e.set(o,i);else{new t(i,o).stringify(e)}}}return e},t.prototype.toJSON=function(){return this.stringify().emit()},t}(),ir=function(){return ir=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ir.apply(this,arguments)},ur=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var e in t)t[e]?"object"!==n(t[e])&&(t[e]=1):t[e]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,n){return this.criteria.sort.push({field:t,sort:n}),this},t.prototype.update=function(t){return this.build(s.update,ir(ir({},this.baseOptions()),{$update:new or(t.data).toJSON()}))},t.prototype.updateAndReturn=function(t){var n=this.findOptions();return this.build(s.findOneAndUpdate,{$match:n.$match,$update:new or(t.data).toJSON(),$options:{$sort:n.$sort,$returnDocument:"after",$upsert:!1}})},t.prototype.set=function(t){return this.build(s.replace,ir(ir({},this.baseOptions()),{$replace:t.data,$upsert:!0}))},t.prototype.remove=function(){return this.build(s.delete,this.baseOptions())},t.prototype.get=function(){return this.build(s.queryList,ir({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(s.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var n=new kn(this.criteria.match);t.$match=n.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var n=0,e=this.criteria.sort;n<e.length;n++){var r=e[n];t.$sort[r.field]=r.sort===c.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,n){return tr.buildDocumentAction(t,this.collectionName,n)},t}(),cr=function(){function t(t,n){this.collectionName=t,this.id=n}return t.prototype.update=function(t){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new ur(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=s.query,t},t}(),ar=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));if(this.data instanceof In)return this.data.toJSON();if(null===this.data||this.data instanceof Date)return this.data;if("object"===n(this.data)){var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i).stringify();void 0!==u&&(r[o]=u)}return r}return this.data},t}(),sr=function(){return sr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},sr.apply(this,arguments)},pr=function(){function t(t,n){this.collectionName=t,this.options=sr({maxAddCount:200},n)}return t.prototype.add=function(t){if(!(null==t?void 0:t.data))throw F.invalidParam("data","不能为空");if(Array.isArray(t.data))return this.batchAdd(t);var n=new ar(t.data).stringify();return tr.buildDocumentAction(s.create,this.collectionName,n)},t.prototype.batchAdd=function(t){if(t.data.length<=0)throw F.invalidParam("data","不能为空数组");if(t.data.length>this.options.maxAddCount)throw F.invalidParam("data","最大长度 ".concat(this.options.maxAddCount));var n={$create:new ar(t.data).stringify()};return"boolean"==typeof t.ordered&&(n.$ordered=t.ordered),tr.buildDocumentAction(s.batchCreate,this.collectionName,n)},t.prototype.doc=function(t){return new cr(this.collectionName,t)},t.prototype.limit=function(t){return new ur(this.collectionName).limit(t)},t.prototype.skip=function(t){return new ur(this.collectionName).skip(t)},t.prototype.where=function(t){return new ur(this.collectionName).where(t)},t.prototype.projection=function(t){return new ur(this.collectionName).projection(t)},t.prototype.orderBy=function(t,n){return new ur(this.collectionName).orderBy(t,n)},t.prototype.aggregate=function(){return new er(this.collectionName)},t.prototype.get=function(){return new ur(this.collectionName).get()},t.prototype.count=function(){return new ur(this.collectionName).count()},t}(),fr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},lr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function hr(){return function(t,n,e){var r=e.value;e.value=function(t){return fr(this,void 0,void 0,(function(){return lr(this,(function(n){return[2,y(r,this)(t)]}))}))}}}var yr,dr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},vr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},wr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},gr=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new er(t)}return t.prototype.addFields=function(t){return this.builder.addFields(t),this},t.prototype.count=function(t){return this.builder.count(t),this},t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.project=function(t){return this.builder.project(t),this},t.prototype.replaceRoot=function(t){return this.builder.replaceRoot(t),this},t.prototype.sort=function(t){return this.builder.sort(t),this},t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.unwind=function(t){return this.builder.unwind(t),this},t.prototype.geoNear=function(t){return this.builder.geoNear(t),this},t.prototype.bucket=function(t){return this.builder.bucket(t),this},t.prototype.bucketAuto=function(t){return this.builder.bucketAuto(t),this},t.prototype.sortByCount=function(t){return this.builder.sortByCount(t),this},t.prototype.end=function(){return vr(this,void 0,void 0,(function(){var t,n,e;return wr(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,n="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:n,data:t})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);u>3&&c&&Object.defineProperty(e,r,c)}([hr(),dr("design:type",Function),dr("design:paramtypes",[]),dr("design:returntype",Promise)],t.prototype,"end",null),t}(),mr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},br=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_r=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Or=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ar=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new ur(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,n){return this.builder.orderBy(t,n),this},t.prototype.updateAndReturn=function(t){return _r(this,void 0,void 0,(function(){var n,e,r,o;return Or(this,(function(i){switch(i.label){case 0:return n="".concat(this.getCollectionPath(),"?findOneAndUpdate"),e=this.builder.updateAndReturn(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=i.sent(),[2,{updated:(o=d.handleResponse(r))?1:0,doc:o}]}}))}))},t.prototype.update=function(t){return _r(this,void 0,void 0,(function(){var n,e,r;return Or(this,(function(o){switch(o.label){case 0:return n="".concat(this.getCollectionPath(),"?update"),e=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.set=function(t){return _r(this,void 0,void 0,(function(){var n,e,r;return Or(this,(function(o){switch(o.label){case 0:return n="".concat(this.getCollectionPath(),"?replace"),e=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.remove=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?delete"),n=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.get=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?query"),n=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.count=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?count"),n=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,{total:d.handleResponse(e).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"updateAndReturn",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"update",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"set",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"remove",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"get",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"count",null),t}(),jr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},xr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Pr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Sr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ir=function(){function t(t,n,e){this.collectionName=t,this.id=n,this.options=e}return t.prototype.projection=function(t){return this.query.projection(t),this},t.prototype.field=function(t){return this.query.field(t),this},t.prototype.update=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Pr(this,void 0,void 0,(function(){var t,n;return Sr(this,(function(e){switch(e.label){case 0:return[4,this.query.get()];case 1:if(t=e.sent(),!(n=t[0])){if(this.options.throwOnNotFound)throw h.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,n]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return this._query||(this._query=new Ar(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)),this._query},enumerable:!1,configurable:!0}),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"update",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"updateAndReturn",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"set",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[]),xr("design:returntype",Promise)],t.prototype,"remove",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[]),xr("design:returntype",Promise)],t.prototype,"get",null),t}(),Rr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Cr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Er=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Nr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},kr=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new pr(t)}return t.prototype.add=function(t){return Er(this,void 0,void 0,(function(){var n,e,r;return Nr(this,(function(o){switch(o.label){case 0:return n=this.builder.add(t).options,e=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new Ir(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new Ar(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new Ar(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new Ar(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new Ar(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new Ar(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,n){return new Ar(this.collectionName,this.options).orderBy(t,n)},t.prototype.aggregate=function(){return new gr(this.collectionName,this.options)},t.prototype.update=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"add",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"update",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"set",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"remove",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"get",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"count",null),t}(),Dr=function(){return Dr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Dr.apply(this,arguments)},Tr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},qr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},$r=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){return Tr(this,arguments,void 0,(function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return qr(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:n,path:e,data:r,headers:Dr({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),Fr=function(){function t(t){this.command=new Ze,this.options=Dr(Dr({},t),{httpclient:new $r(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw h.INVALID_PARAM_ERR("collectionName","不能为空");return new kr(t,this.options)},t}(),Br=function(){return Br=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Br.apply(this,arguments)},Lr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Mr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ur=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var n=t.trim().replace(/^cloud:\/\//,""),e=n.indexOf("/");if(e<=0)throw h.INVALID_PARAM_ERR("fileID","不合法");var r=n.substring(0,e),o=n.substring(e+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.getUploadFileURL=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i;return Mr(this,(function(u){switch(u.label){case 0:if(n="string"==typeof t?t:t.cloudPath,e=this.checkCloudPath(n))throw h.INVALID_PARAM_ERR("cloudPath",e);return r=this.getUploadPath(n.trim()),[4,this.request({method:"GET",path:r})];case 1:return o=u.sent(),i=d.handleResponse(o),[2,{fileID:this.formatFileID(i.file_id),uploadURL:i.upload_url,requestID:o.requestID}]}}))}))},t.prototype.uploadFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i;return Mr(this,(function(u){switch(u.label){case 0:return[4,this.getUploadFileURL(t)];case 1:return n=u.sent(),e=n.fileID,r=n.uploadURL,o=n.requestID,[4,this.options.fileUploader.upload({fileID:e,uploadURL:r,fileContent:t.fileContent})];case 2:if(200!==(i=u.sent()).statusCode)throw h.STORAGE_ERR(60004,"上传文件 ".concat(r," 失败"),o);return[2,{fileID:e,statusCode:i.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u;return Mr(this,(function(c){switch(c.label){case 0:if(n=this.checkFileID(t.fileID))throw h.INVALID_PARAM_ERR("fileID",n);return e=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(e),[4,this.request({method:"GET",path:r})];case 1:return o=c.sent(),i=d.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(u=c.sent()).statusCode)throw h.STORAGE_ERR(60004,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,u]}}))}))},t.prototype.deleteFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return Mr(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw h.INVALID_PARAM_ERR("fileList","不能为空数组");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw h.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push(c)}return a=this.getBatchDeletePath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return Mr(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw h.INVALID_PARAM_ERR("fileList","不能为空数组");if(n.length>50)throw h.INVALID_PARAM_ERR("fileList","最大长度 50");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw h.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push({file_id:c,expire:600})}return a=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){return Lr(this,arguments,void 0,(function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return Mr(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:n,path:e,data:r,headers:Br({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),Hr=function(){function t(){}return t.createCallFunction=function(t){return function(t){var n=t.httpclient;return y((function(t){return m(void 0,void 0,void 0,(function(){var e,r,o,i,u;return b(this,(function(c){switch(c.label){case 0:if(!t.name)throw h.INVALID_PARAM_ERR("name","缺失");return e=g(g({},t.headers),{"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"}),t.async&&(e["x-function-invoke-type"]="async"),[4,n.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:e,responseDataType:t.resultDataType,timeout:t.timeout})];case 1:if(200!==(r=c.sent()).status)throw o=-1,i="",(u=r.data)&&(o=u.errCode,i=u.errMsg,u.errDetail&&(i+=",详情:".concat(u.errDetail))),h.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data,headers:r.headers}]}}))}))}))}(t)},t.createCallContainer=function(t){return function(t){return y((function(n){return v(void 0,void 0,void 0,(function(){return w(this,(function(e){throw new Error("not implemented in "+t.type+" with "+n)}))}))}))}(t)},t.createDatabase=function(t){return new Fr(t)},t.createStorage=function(t){return new Ur(t)},t}();!function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(yr||(yr={}));var Wr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function zr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kr={exports:{}};var Vr,Jr={exports:{}};function Gr(){return Vr||(Vr=1,function(t){var n;t.exports=(n=n||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==Wr&&Wr.crypto&&(e=Wr.crypto),!e)try{e=require("crypto")}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=u.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||p).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var u=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=u<<24-(r+i)%4*8}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),s=i.enc={},p=s.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},f=s.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},h=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,u=this.blockSize,c=i/(4*u),s=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*u,p=t.min(4*s,i);if(s){for(var f=0;f<s;f+=u)this._doProcessBlock(o,f);e=o.splice(0,s),r.sigBytes-=p}return new a.init(e,p)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=h.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new y.HMAC.init(t,e).finalize(n)}}});var y=i.algo={};return i}(Math),n)}(Jr)),Jr.exports}!function(t){t.exports=Gr().enc.Hex}(Kr);var Yr=zr(Kr.exports),Qr={exports:{}},Xr={exports:{}};!function(t){var n;t.exports=(n=Gr(),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,u=e.algo,c=[],a=[];!function(){function n(n){for(var e=t.sqrt(n),r=2;r<=e;r++)if(!(n%r))return!1;return!0}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)n(r)&&(o<8&&(c[o]=e(t.pow(r,.5))),a[o]=e(t.pow(r,1/3)),o++),r++}();var s=[],p=u.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(t,n){for(var e=this._hash.words,r=e[0],o=e[1],i=e[2],u=e[3],c=e[4],p=e[5],f=e[6],l=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[n+h];else{var y=s[h-15],d=(y<<25|y>>>7)^(y<<14|y>>>18)^y>>>3,v=s[h-2],w=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;s[h]=d+s[h-7]+w+s[h-16]}var g=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&p^~c&f)+a[h]+s[h];l=f,f=p,p=c,c=u+b|0,u=i,i=o,o=r,r=b+(m+g)|0}e[0]=e[0]+r|0,e[1]=e[1]+o|0,e[2]=e[2]+i|0,e[3]=e[3]+u|0,e[4]=e[4]+c|0,e[5]=e[5]+p|0,e[6]=e[6]+f|0,e[7]=e[7]+l|0},_doFinalize:function(){var n=this._data,e=n.words,r=8*this._nDataBytes,o=8*n.sigBytes;return e[o>>>5]|=128<<24-o%32,e[14+(o+64>>>9<<4)]=t.floor(r/4294967296),e[15+(o+64>>>9<<4)]=r,n.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(p),e.HmacSHA256=i._createHmacHelper(p)}(Math),n.SHA256)}(Xr);var Zr,to=Xr.exports,no=zr(to),eo={exports:{}};!function(t){var n;t.exports=(n=Gr(),Zr||(Zr=1,function(t){var n;t.exports=(n=Gr(),void function(){var t=n,e=t.lib.Base,r=t.enc.Utf8;t.algo.HMAC=e.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=r.parse(n));var e=t.blockSize,o=4*e;n.sigBytes>o&&(n=t.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),u=this._iKey=n.clone(),c=i.words,a=u.words,s=0;s<e;s++)c[s]^=1549556828,a[s]^=909522486;i.sigBytes=u.sigBytes=o,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var n=this._hasher,e=n.finalize(t);return n.reset(),n.finalize(this._oKey.clone().concat(e))}})}())}(eo)),n.HmacSHA256)}(Qr);var ro=zr(Qr.exports),oo=function(){function t(){}return t.sign=function(n){for(var e=n.signedHeaders.join(";"),r="",o=0,i=n.signedHeaders;o<i.length;o++){var u=i[o],c=n.headers[u];r+="".concat(u,":").concat(c,"\n")}var a=t.createHash(n.body||""),s=n.method.toUpperCase()+"\n"+n.path+"\n"+n.query+"\n"+r+"\n"+e+"\n"+a+"\n",p="HMAC-SHA256",f=t.createHash(s),l="".concat(p,"\n").concat(n.timestamp,"\n").concat(f,"\n"),h=t.createSha256(l,n.secretKey);return"".concat(p," Credential=").concat(n.secretId,", SignedHeaders=").concat(e,", Signature=").concat(h)},t.signWebSocket=function(n){var e=n.queryString,r=["accessKeyId","authorization","signatureNonce","timestamp"].concat(n.signedKeys||[]).sort().map((function(t){return e[t]?"".concat(t,"=").concat(e[t]):null})).filter(Boolean).join("&"),o="".concat(n.path,"\n").concat(r,"\nhost:").concat(n.host),i=t.createHash(o),u="".concat("HMAC-SHA256","\n").concat(i);return t.createSha256(u,n.secretKey)},t.createSha256=function(t,n){return void 0===n&&(n=""),ro(t,n).toString(Yr)},t.createHash=function(t){return no(t).toString(Yr)},t}(),io=function(){function t(){}return t.detectRuntime=function(){return"undefined"!=typeof process&&process.execPath?yr.WEB:window||void 0===("undefined"==typeof my?"undefined":n(my))?window||void 0===("undefined"==typeof wx?"undefined":n(wx))?yr.WEB:yr.WEICHAT_MINI:yr.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))},t.parseUrl=function(t,n){if(n===yr.WEB)return new URL(t);var e=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=e[1],o=e[2],i=e[3],u=e[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:u||""}},t}();var uo=function(){function t(t,n){this.req=t,this.config=n}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),co=function(){function t(){}return t.prototype.request=function(t,n){var e;return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=r({mode:"cors"},n),(null==n?void 0:n.timeout)&&(o.signal=AbortSignal.timeout(n.timeout)),[4,fetch(t,o)];case 1:return u=i.sent(),c={},u.headers.forEach((function(t,n){c[n]=t})),"json"!==(a=null!==(e=null==n?void 0:n.responseDataType)&&void 0!==e?e:"json")?[3,3]:[4,u.json()];case 2:return s=i.sent(),[3,12];case 3:return"text"!==a?[3,5]:[4,u.text()];case 4:return s=i.sent(),[3,12];case 5:return"arrayBuffer"!==a?[3,7]:[4,u.arrayBuffer()];case 6:return s=i.sent(),[3,12];case 7:return"blob"!==a?[3,9]:[4,u.blob()];case 8:return s=i.sent(),[3,12];case 9:return"formData"!==a?[3,11]:[4,u.formData()];case 10:return s=i.sent(),[3,12];case 11:s=u.body,i.label=12;case 12:return[2,{status:u.status,data:s,headers:c}]}}))}))},t}(),ao=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,headers:null==n?void 0:n.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw e=r.sent(),console.error(e),new Error("error: ".concat(e.error,", message: ").concat(e.errorMessage));case 3:return[2]}}))}))},t}(),so=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){wx.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,header:null==n?void 0:n.headers,dataType:"json",success:function(t){e({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),po=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case yr.ALIPAY_MINI:this.singleton=new ao;break;case yr.WEB:this.singleton=new co;break;case yr.WEICHAT_MINI:this.singleton=new so;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function fo(t,n){var e;return o(this,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n()];case 1:return i.sent(),r=t.config.fetch||po.default(t.config.runtime),o=t,[4,r.request(t.req.url,t.req.requestOptions)];case 2:return o.res=i.sent(),t.result={status:t.res.status,requestID:t.requestId||(null===(e=t.res.headers)||void 0===e?void 0:e["x-trace-id"]),headers:t.res.headers,data:t.res.data},[2]}}))}))}function lo(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:throw e=r.sent(),h.NETWORK_ERR(e,t.requestId);case 3:return[2]}}))}))}function ho(t){return function(n,e){return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),u=io.parseUrl(n.req.url,n.config.runtime),c={authorization:"","x-from-app-id":n.config.appId,"x-from-env-id":n.config.envId,"x-to-env-id":n.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":n.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var e,r=null===(e=n.req.requestOptions.headers)||void 0===e?void 0:e[t];r&&(c[t]=r)})),a=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:u.pathname,query:u.search.substring(1),secretId:n.config.secretId,secretKey:n.config.secretKey,method:n.req.requestOptions.method,headers:c,body:n.req.requestOptions.body,timestamp:o,signedHeaders:a},c.authorization=oo.sign(s),n.req.requestOptions.headers=r(r({},c),n.req.requestOptions.headers),[4,e()];case 1:return i.sent(),[2]}}))}))}}var yo=function(){function t(t,n){var e;this.config=t,this.handler=(e=n,function(t,n){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var u=e[i];if(i===e.length&&(u=n),!u)return Promise.resolve();try{return Promise.resolve(u(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){return o(this,void 0,void 0,(function(){var n,e,r,o,u;return i(this,(function(i){switch(i.label){case 0:return n=this.config.endpoint+t.path,e=t.data?JSON.stringify(t.data):t.data,r=io.generateUUID(),o=Object.assign({"x-alipay-callid":r,"x-request-id":r,"x-alipay-source":"web,web-sdk","content-type":"application/json"},t.headers),u=new uo({url:n,requestOptions:{method:t.method,body:e,headers:o,responseDataType:t.responseDataType,timeout:t.timeout}},this.config),[4,this.handler(u)];case 1:return i.sent(),[2,u.result]}}))}))},t.createFunctionHttpclient=function(n){return new t(n,[lo,ho(["x-to-function-name"]),fo])},t.createDatabaseHttpclient=function(n){return new t(n,[lo,ho(["x-data-api-type","x-expire-timestamp"]),fo])},t.createStorageHttpclient=function(n){return new t(n,[lo,ho(["x-data-api-type","x-expire-timestamp"]),fo])},t}(),vo=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n=t.uploadURL,e=t.fileContent,[4,fetch(n,{method:"PUT",mode:"cors",body:e})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),wo=function(t){function n(e){var r=yo.createStorageHttpclient(e),o=n.getFileUploader(e);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:e.envId})||this}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===yr.WEB)return vo.create();throw h.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},n}(Ur),go=function(){function t(t){this.config=t}return t.prototype.signedURL=function(t,n){var e="/ws/function/".concat(t),o=r(r({},null==n?void 0:n.queryString),{accessKeyId:this.config.secretId,signatureNonce:io.generateUUID(),timestamp:"".concat(Date.now())});(null==n?void 0:n.authorization)&&(o.authorization=n.authorization);var i=oo.signWebSocket({host:this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),path:e,queryString:o,secretId:this.config.secretId,secretKey:this.config.secretKey}),u=Object.entries(o).map((function(t){var n=t[0],e=t[1];return"".concat(n,"=").concat(encodeURIComponent(e))})).join("&");return"".concat(this.config.wsEndpoint).concat(e,"?").concat(u,"&signature=").concat(i)},t}(),mo=function(){function t(t){var n=t.resourceEnv||t.envId,e=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(n,".api-hz.cloudbasefunction.cn"),wsEndpoint:t.wsEndpoint||"wss://".concat(n,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:e,envId:n,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||io.detectRuntime(),functionName:""},this.websocket=new go(this.config)}return t.prototype.init=function(){},t.prototype.callFunction=function(t){var n;return o(this,void 0,void 0,(function(){var e,o;return i(this,(function(i){switch(i.label){case 0:return e=r(r({},this.config),{envId:(null===(n=t.config)||void 0===n?void 0:n.env)||this.config.envId,functionName:t.name}),o=yo.createFunctionHttpclient(e),[4,Hr.createCallFunction({type:"web",httpclient:o})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new wo(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.ws=function(){return this.websocket},t.RUNTIME=yr,t}();t.Cloud=mo}));
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};var r=function(){return r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var u,c,a,s,p,f,l=(u=function(t,n){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},u(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),h=function(t){function n(e,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=e,o.errorMessage=r,Object.setPrototypeOf(o,n.prototype),o}return l(n,t),Object.defineProperty(n.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),n.INVALID_PARAM_ERR=function(t,e){return new n(60001,'无效入参,参数 "'.concat(t,'" ').concat(e))},n.NOT_FOUND_ERR=function(t){return new n(60001,t)},n.SERVER_ERR=function(t,e,r,o){var i=new n(t,e);return i.requestID=r,i.httpStatus=o,i},n.STORAGE_ERR=function(t,e,r){var o=new n(t,e);return o.requestID=r,o},n.NETWORK_ERR=function(t,e){var r=new n(-1,t.toString());return r.requestID=e,r},n}(Error),y=function(t,n){return void 0===n&&(n=void 0),function(e){if(!((null==e?void 0:e.complete)||(null==e?void 0:e.success)||(null==e?void 0:e.fail)))return t.call(n,e);var r=e.complete,o=e.success,i=e.fail,u=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(e,["complete","success","fail"]);t.call(n,u).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}},d=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var n=t.data||{code:-1,message:"未知异常"},e=n.code,r=n.message;throw h.SERVER_ERR(e,r,t.requestID,t.status)}return t.data.data},t}(),v=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},w=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},g=function(){return g=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},g.apply(this,arguments)},m=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},b=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};!function(t){t.DESC="desc",t.ASC="asc"}(c||(c={})),function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(a||(a={})),function(t){t.update="update",t.findOneAndUpdate="findOneAndUpdate",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(s||(s={})),function(t){t.collection="collection",t.document="document"}(p||(p={})),function(t){t.addFields="$addFields",t.count="$count",t.match="$match",t.group="$group",t.project="$project",t.replaceRoot="$replaceRoot",t.sample="$sample",t.lookup="$lookup",t.sort="$sort",t.limit="$limit",t.skip="$skip",t.unwind="$unwind",t.geoNear="$geoNear",t.bucket="$bucket",t.bucketAuto="$bucketAuto",t.sortByCount="$sortByCount"}(f||(f={}));var _,O,A,j=(_=function(t,n){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},_(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}_(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),x=function(){},P=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(x),S=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(P),I=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(P),R=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(S),C=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(x),E=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),N=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),k=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return j(n,t),n}(C),D=function(t){function n(n,e){var r=t.call(this)||this;return r.name="$"+n,r.value=e,r}return j(n,t),n.prototype.stringify=function(){var t;return(t={})[this.name]=this.value,t},n}(x),T=function(){function t(t){this.lastCmd=t}return t.unchain=function(n){return n instanceof t?n.lastCmd:n},t}(),q=(O=function(t,n){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},O(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}O(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});!function(t){t.INVALID_PARAM="INVALID_PARAM",t.INVALID_COMMAND="INVALID_COMMAND",t.SEMANTIC_ERROR="SEMANTIC_ERROR"}(A||(A={}));var $,F=function(t){function n(e){var r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return q(n,t),n.create=function(t,e){var r=new n(e);return r.code=t,r},n.invalidParam=function(t,e){return n.create(A.INVALID_PARAM,'无效入参,参数 "'.concat(t,'" ').concat(e))},n.invalidCommand=function(t){return n.create(A.INVALID_COMMAND,t)},n.semanticError=function(t){return n.create(A.SEMANTIC_ERROR,t)},n}(Error),B=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(this.data instanceof x){if(!(this.data instanceof D))throw F.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data||this.data instanceof Date)return this.data;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));switch(n(this.data)){case"number":case"boolean":case"string":case"bigint":case"undefined":return this.data;case"function":throw F.invalidParam(this.prefix,"不支持函数");case"symbol":throw F.invalidParam(this.prefix,"不支持 symbol");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i).stringify();void 0!==u&&(r[o]=u)}return r}},t.prototype.toJSON=function(){var t=this.stringify();if(void 0===t)throw F.invalidParam(this.prefix,"不支持 undefined");return t},t}(),L=($=function(t,n){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},$(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}$(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),U=function(t){function n(n,e){return t.call(this,n,new B(e).toJSON())||this}return L(n,t),n}(D),M=function(t){function n(n){return t.call(this,"abs",n)||this}return L(n,t),n}(U),W=function(t){function n(n){return t.call(this,"add",n)||this}return L(n,t),n}(U),H=function(t){function n(n){return t.call(this,"addToSet",n)||this}return L(n,t),n}(U),z=function(t){function n(n){return t.call(this,"and",n)||this}return L(n,t),n}(U),K=function(t){function n(n){return t.call(this,"arrayElemAt",n)||this}return L(n,t),n}(U),V=function(t){function n(n){return t.call(this,"avg",n)||this}return L(n,t),n}(U),J=function(t){function n(n){return t.call(this,"ceil",n)||this}return L(n,t),n}(U),G=function(t){function n(n){return t.call(this,"cmp",n)||this}return L(n,t),n}(U),Y=function(t){function n(n){return t.call(this,"concat",n)||this}return L(n,t),n}(U),Q=function(t){function n(n){var e=Array.isArray(n)?{if:n[0],then:n[1],else:n[2]}:n;return t.call(this,"cond",e)||this}return L(n,t),n}(U),X=function(t){function n(){return t.call(this,"count",{})||this}return L(n,t),n.prototype.stringify=function(){return{$sum:1}},n}(U),Z=function(t){function n(n){return t.call(this,"dateToString",n)||this}return L(n,t),n}(U),tt=function(t){function n(n){return t.call(this,"divide",n)||this}return L(n,t),n}(U),nt=function(t){function n(n){return t.call(this,"eq",n)||this}return L(n,t),n}(U),et=function(t){function n(n){return t.call(this,"exp",n)||this}return L(n,t),n}(U),rt=function(t){function n(n){return t.call(this,"first",n)||this}return L(n,t),n}(U),ot=function(t){function n(n){return t.call(this,"floor",n)||this}return L(n,t),n}(U),it=function(t){function n(n){return t.call(this,"gt",n)||this}return L(n,t),n}(U),ut=function(t){function n(n){return t.call(this,"gte",n)||this}return L(n,t),n}(U),ct=function(t){function n(n){return t.call(this,"ifNull",n)||this}return L(n,t),n}(U),at=function(t){function n(n){return t.call(this,"in",n)||this}return L(n,t),n}(U),st=function(t){function n(n){return t.call(this,"indexOfArray",n)||this}return L(n,t),n}(U),pt=function(t){function n(n){return t.call(this,"isArray",n)||this}return L(n,t),n}(U),ft=function(t){function n(n){return t.call(this,"isoWeek",n)||this}return L(n,t),n}(U),lt=function(t){function n(n){return t.call(this,"last",n)||this}return L(n,t),n}(U),ht=function(t){function n(n){return t.call(this,"let",n)||this}return L(n,t),n}(U),yt=function(t){function n(n){return t.call(this,"ln",n)||this}return L(n,t),n}(U),dt=function(t){function n(n){return t.call(this,"log",n)||this}return L(n,t),n}(U),vt=function(t){function n(n){return t.call(this,"log10",n)||this}return L(n,t),n}(U),wt=function(t){function n(n){return t.call(this,"lt",n)||this}return L(n,t),n}(U),gt=function(t){function n(n){return t.call(this,"lte",n)||this}return L(n,t),n}(U),mt=function(t){function n(n){return t.call(this,"map",n)||this}return L(n,t),n}(U),bt=function(t){function n(n){return t.call(this,"max",n)||this}return L(n,t),n}(U),_t=function(t){function n(n){return t.call(this,"mergeObjects",n)||this}return L(n,t),n}(U),Ot=function(t){function n(n){return t.call(this,"min",n)||this}return L(n,t),n}(U),At=function(t){function n(n){return t.call(this,"mod",n)||this}return L(n,t),n}(U),jt=function(t){function n(n){return t.call(this,"month",n)||this}return L(n,t),n}(U),xt=function(t){function n(n){return t.call(this,"multiply",n)||this}return L(n,t),n}(U),Pt=function(t){function n(n){return t.call(this,"ne",n)||this}return L(n,t),n}(U),St=function(t){function n(n){return t.call(this,"not",[n])||this}return L(n,t),n}(U),It=function(t){function n(n){return t.call(this,"or",n)||this}return L(n,t),n}(U),Rt=function(t){function n(n){return t.call(this,"pow",n)||this}return L(n,t),n}(U),Ct=function(t){function n(n){return t.call(this,"push",n)||this}return L(n,t),n}(U),Et=function(t){function n(n){return t.call(this,"size",n)||this}return L(n,t),n}(U),Nt=function(t){function n(n){return t.call(this,"slice",n)||this}return L(n,t),n}(U),kt=function(t){function n(n){return t.call(this,"split",n)||this}return L(n,t),n}(U),Dt=function(t){function n(n){return t.call(this,"sqrt",n)||this}return L(n,t),n}(U),Tt=function(t){function n(n){return t.call(this,"substr",n)||this}return L(n,t),n}(U),qt=function(t){function n(n){return t.call(this,"substrBytes",n)||this}return L(n,t),n}(U),$t=function(t){function n(n){return t.call(this,"subtract",n)||this}return L(n,t),n}(U),Ft=function(t){function n(n){return t.call(this,"sum",n)||this}return L(n,t),n}(U),Bt=function(t){function n(n){var e=n.branches.map((function(t){return Array.isArray(t)?{case:t[0],then:t[1]}:{case:t.case,then:t.then}}));return t.call(this,"switch",{branches:e,default:n.default})||this}return L(n,t),n}(U),Lt=function(t){function n(n){return t.call(this,"toLower",n)||this}return L(n,t),n}(U),Ut=function(t){function n(n){return t.call(this,"toUpper",n)||this}return L(n,t),n}(U),Mt=function(t){function n(n){return t.call(this,"trunc",n)||this}return L(n,t),n}(U),Wt=function(t){function n(n){return t.call(this,"week",n)||this}return L(n,t),n}(U),Ht=function(t){function n(n){return t.call(this,"year",n)||this}return L(n,t),n}(U),zt=function(t){function n(n){return t.call(this,"allElementsTrue",n)||this}return L(n,t),n}(U),Kt=function(t){function n(n){return t.call(this,"anyElementTrue",n)||this}return L(n,t),n}(U),Vt=function(t){function n(n){return t.call(this,"setDifference",n)||this}return L(n,t),n}(U),Jt=function(t){function n(n){return t.call(this,"setEquals",n)||this}return L(n,t),n}(U),Gt=function(t){function n(n){return t.call(this,"setIntersection",n)||this}return L(n,t),n}(U),Yt=function(t){function n(n){return t.call(this,"setIsSubset",n)||this}return L(n,t),n}(U),Qt=function(t){function n(n){return t.call(this,"setUnion",n)||this}return L(n,t),n}(U),Xt=function(t){function n(n){return t.call(this,"literal",n)||this}return L(n,t),n}(U),Zt=function(t){function n(n){return t.call(this,"arrayToObject",n)||this}return L(n,t),n}(U),tn=function(t){function n(n){return t.call(this,"concatArrays",n)||this}return L(n,t),n}(U),nn=function(t){function n(n){return t.call(this,"filter",n)||this}return L(n,t),n}(U),en=function(t){function n(n){return t.call(this,"objectToArray",n)||this}return L(n,t),n}(U),rn=function(t){function n(n){return t.call(this,"range",n)||this}return L(n,t),n}(U),on=function(t){function n(n){return t.call(this,"reduce",n)||this}return L(n,t),n}(U),un=function(t){function n(n){return t.call(this,"reverseArray",n)||this}return L(n,t),n}(U),cn=function(t){function n(n){return t.call(this,"zip",n)||this}return L(n,t),n}(U),an=function(t){function n(n){return t.call(this,"dateFromString",n)||this}return L(n,t),n}(U),sn=function(t){function n(n){return t.call(this,"indexOfBytes",n)||this}return L(n,t),n}(U),pn=function(t){function n(n){return t.call(this,"indexOfCP",n)||this}return L(n,t),n}(U),fn=function(t){function n(n){return t.call(this,"strLenBytes",n)||this}return L(n,t),n}(U),ln=function(t){function n(n){return t.call(this,"strLenCP",n)||this}return L(n,t),n}(U),hn=function(t){function n(n){return t.call(this,"strcasecmp",n)||this}return L(n,t),n}(U),yn=function(t){function n(n){return t.call(this,"substrCP",n)||this}return L(n,t),n}(U),dn=function(t){function n(n){return t.call(this,"stdDevPop",n)||this}return L(n,t),n}(U),vn=function(t){function n(n){return t.call(this,"stdDevSamp",n)||this}return L(n,t),n}(U),wn=function(t){function n(n){return t.call(this,"dateFromParts",n)||this}return L(n,t),n}(U),gn=function(t){function n(n){return t.call(this,"dayOfMonth",n)||this}return L(n,t),n}(U),mn=function(t){function n(n){return t.call(this,"dayOfWeek",n)||this}return L(n,t),n}(U),bn=function(t){function n(n){return t.call(this,"dayOfYear",n)||this}return L(n,t),n}(U),_n=function(t){function n(n){return t.call(this,"hour",n)||this}return L(n,t),n}(U),On=function(t){function n(n){return t.call(this,"isoDayOfWeek",n)||this}return L(n,t),n}(U),An=function(t){function n(n){return t.call(this,"isoWeekYear",n)||this}return L(n,t),n}(U),jn=function(t){function n(n){return t.call(this,"millisecond",n)||this}return L(n,t),n}(U),xn=function(t){function n(n){return t.call(this,"minute",n)||this}return L(n,t),n}(U),Pn=function(t){function n(n){return t.call(this,"second",n)||this}return L(n,t),n}(U),Sn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),In=function(){function t(t,n){this.type=t,this.coordinates=n}return t.prototype.toJSON=function(){return{type:this.type,coordinates:this.coordinates}},t}(),Rn=function(t){function n(n,e){var r=t.call(this,"Point",[n,e])||this;return r.longitude=n,r.latitude=e,r}return Sn(n,t),n}(In);!function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"LineString",r)||this).points=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"Polygon",r)||this).lines=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiPoint",r)||this).points=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiLineString",r)||this).lines=n,e}Sn(n,t)}(In),function(t){function n(n){var e=this,r=n.map((function(t){return t.coordinates}));return(e=t.call(this,"MultiPolygon",r)||this).polygons=n,e}Sn(n,t)}(In);var Cn,En=function(){function t(t){this.regexp=t.regexp,this.options=t.options||""}return t.prototype.stringify=function(){return{$regex:this.regexp,$options:this.options}},t}(),Nn=function(){function t(){}return t.mergeTo=function(t,e){var r;for(var o in e)t[o]?Array.isArray(t[o])?(r=t[o]).push.apply(r,e[o]):"object"===n(t[o])&&"object"===n(e[o])?Object.assign(t[o],e[o]):t[o]=e[o]:t[o]=e[o]},t}(),kn=function(){function t(t,n,e){void 0===n&&(n=""),void 0===e&&(e=""),this.query=t,this.prefix=n,this.keyName=e}return t.prototype.stringify=function(){var e=this,r=T.unchain(this.query);if(r instanceof E)return r.stringifyWithKey(this.keyName);if(r instanceof C)return r.stringify();if(r instanceof En)return r.stringify();if(r instanceof RegExp)return r;if(r instanceof Date)return r;if(Array.isArray(r))return r.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));var o=n(r);return"object"!==o?this.stringifyBuiltInValue(r,o):null===r?r:this.stringifyObject(r)},t.prototype.stringifyWithKey=function(){var e,r,o,i,u,c,a,s=this,p=T.unchain(this.query);if(p instanceof E)return p.stringifyWithKey(this.keyName);if(p instanceof C)return p instanceof k?p.stringify():((e={})[this.keyName]=p.stringify(),e);if(p instanceof En)return(r={})[this.keyName]=p.stringify(),r;if(p instanceof RegExp)return(o={})[this.keyName]=p,o;if(p instanceof Date)return(i={})[this.keyName]=p,i;if(Array.isArray(p)){var f=p.map((function(n,e){return new t(n,"".concat(s.prefix,".$.").concat(e)).stringify()}));return(u={})[this.keyName]=f,u}var l=n(p);return"object"!==l?((c={})[this.keyName]=this.stringifyBuiltInValue(p,l),c):null===p?((a={})[this.keyName]=p,a):this.stringifyObject(p)},t.prototype.toJSON=function(){var t=this.stringify();if(void 0===t)throw F.invalidParam(this.prefix,"不支持 undefined");return t},t.prototype.stringifyBuiltInValue=function(t,n){switch(n){case"number":case"boolean":case"string":case"bigint":default:return t;case"function":throw F.invalidParam(this.prefix,"不支持函数");case"symbol":throw F.invalidParam(this.prefix,"不支持 symbol");case"undefined":return}},t.prototype.stringifyObject=function(n){var e,r={};for(var o in n){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=T.unchain(n[o]);if(u instanceof E){var c=u.stringifyWithKey(i);Nn.mergeTo(r,c)}else{var a=new t(u,i,o).stringify();void 0!==a&&Nn.mergeTo(r,((e={})[o]=a,e))}}return r},t}(),Dn=function(){return Dn=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Dn.apply(this,arguments)},Tn=function(){function t(){this.pipeline=[]}return t.prototype.addFields=function(t){return this.pushStage(f.addFields,t),this},t.prototype.count=function(t){return this.pushStage(f.count,t),this},t.prototype.match=function(t){return this.pushStage(f.match,t),this},t.prototype.group=function(t){return this.pushStage(f.group,t),this},t.prototype.project=function(t){return this.pushStage(f.project,t),this},t.prototype.replaceRoot=function(t){return this.pushStage(f.replaceRoot,t),this},t.prototype.sample=function(t){return this.pushStage(f.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(f.lookup,t),this},t.prototype.sort=function(t){return this.pushStage(f.sort,t),this},t.prototype.limit=function(t){return this.pushStage(f.limit,t),this},t.prototype.skip=function(t){return this.pushStage(f.skip,t),this},t.prototype.unwind=function(t){return this.pushStage(f.unwind,t),this},t.prototype.geoNear=function(t){return this.pushStage(f.geoNear,t),this},t.prototype.bucket=function(t){return this.pushStage(f.bucket,t),this},t.prototype.bucketAuto=function(t){return this.pushStage(f.bucketAuto,t),this},t.prototype.sortByCount=function(t){return this.pushStage(f.sortByCount,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var n,e;switch(t.name){case f.geoNear:var r=Dn({},t.param);return t.param.query&&(r.query=new kn(t.param.query).toJSON()),t.param.near instanceof Rn&&(r.near=t.param.near.toJSON()),{$geoNear:r};case f.match:return{$match:new kn(t.param).toJSON()};case f.count:case f.sample:case f.limit:case f.skip:case f.unwind:return(n={})[t.name]=t.param,n;case f.lookup:case f.addFields:case f.group:case f.sortByCount:case f.project:case f.bucket:case f.bucketAuto:case f.replaceRoot:return(e={})[t.name]=new B(t.param).toJSON(),e;case f.sort:return{$sort:Object.keys(t.param).reduce((function(n,e){var r;switch(t.param[e]){case c.DESC:r=-1;break;case c.ASC:case 1:r=1;break;case-1:r=-1;break;default:r=1}return n[e]=r,n}),{})};default:var o=t.name;throw F.invalidParam(o,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,n){this.pipeline.push({name:t,param:n})},t}(),qn=(Cn=function(t,n){return Cn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},Cn(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}Cn(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),$n=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return qn(n,t),n.prototype.stringify=function(){return{$all:this.val}},n}(C),Fn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Bn=function(t){function n(n){var e,r=t.call(this)||this;return r.commands=[],(e=r.commands).push.apply(e,n),r}return Fn(n,t),Object.defineProperty(n.prototype,"op",{get:function(){return"$".concat(this.name)},enumerable:!1,configurable:!0}),n.prototype.pushCommand=function(t){this.commands.push(t)},n.prototype.stringifyWithKey=function(t){var n,e=this.commands.map((function(n){return new kn(n,"",t).stringifyWithKey()}));return(n={})[this.op]=e,n},n.prototype.stringify=function(){return this.stringifyWithKey("")},n}(E),Ln=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="and",n}return Fn(n,t),n}(Bn),Un=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="or",n}return Fn(n,t),n}(Bn),Mn=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="nor",n}return Fn(n,t),n}(Bn),Wn=function(t){function n(n){var e=t.call(this)||this;return e.command=n,e}return Fn(n,t),n.prototype.stringifyWithKey=function(t){var n,e={$not:new kn(this.command,"",t).stringify()};return t?((n={})[t]=e,n):e},n.prototype.stringify=function(){return this.stringifyWithKey("")},n}(E),Hn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),zn=function(t){function n(n){var e=t.call(this)||this;return e.val=new kn(n).toJSON(),e}return Hn(n,t),n.prototype.stringify=function(){return{$elemMatch:this.val}},n}(C),Kn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Vn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Kn(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(C),Jn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Gn=function(t){function n(n){var e=t.call(this)||this;return e.exists=n,e}return Jn(n,t),n.prototype.stringify=function(){return{$exists:this.exists}},n}(C),Yn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Qn=function(t){function n(n){var e=t.call(this)||this;return e.commands=new B(n).toJSON(),e}return Yn(n,t),n.prototype.stringify=function(){return{$expr:this.commands}},n}(k),Xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Zn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Xn(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(C),te=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ne=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return te(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(C),ee=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),re=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ee(n,t),n.prototype.stringify=function(){return{$in:this.val}},n}(C),oe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ie=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return oe(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(C),ue=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ce=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ue(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(C),ae=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),se=function(t){function n(n,e){var r=t.call(this)||this;return r.divisor=n,r.remainder=e,r}return ae(n,t),n.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},n}(C),pe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),fe=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return pe(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(C),le=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),he=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return le(n,t),n.prototype.stringify=function(){return{$nin:this.val}},n}(C),ye=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),de=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return ye(n,t),n.prototype.appendCommand=function(t){return t=n.unchain(t),this.lastCmd instanceof Ln?this.lastCmd.pushCommand(t):this.lastCmd=new Ln([this.lastCmd,t]),this},n.prototype.and=function(t){return this.appendCommand(t)},n.prototype.or=function(t){return t=n.unchain(t),this.lastCmd instanceof Un?this.lastCmd.pushCommand(t):this.lastCmd=new Un([this.lastCmd,t]),this},n.prototype.not=function(t){return this.appendCommand(t)},n.prototype.nor=function(t){return this.appendCommand(t)},n.prototype.eq=function(t){return this.appendCommand(new Vn(t))},n.prototype.neq=function(t){return this.appendCommand(new fe(t))},n.prototype.lt=function(t){return this.appendCommand(new ie(t))},n.prototype.lte=function(t){return this.appendCommand(new ce(t))},n.prototype.gt=function(t){return this.appendCommand(new Zn(t))},n.prototype.gte=function(t){return this.appendCommand(new ne(t))},n.prototype.in=function(t){return this.appendCommand(new re(t))},n.prototype.nin=function(t){return this.appendCommand(new he(t))},n.prototype.exists=function(t){return this.appendCommand(new Gn(t))},n.prototype.mod=function(t,n){return this.appendCommand(new se(t,n))},n.prototype.all=function(t){return this.appendCommand(new $n(t))},n.prototype.elemMatch=function(t){return this.appendCommand(new zn(n.unchain(t)))},n.prototype.size=function(t){return this.appendCommand(t)},n}(T),ve=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),we=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ve(n,t),n.prototype.stringify=function(){return{$size:this.val}},n}(C),ge=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),me=function(t){function e(n){var e=t.call(this)||this;return e.value=n,e}return ge(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$addToSet"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return Array.isArray(this.value)?{$each:this.value}:"object"===n(this.value)&&this.value.hasOwnProperty("each")?{$each:this.value.each}:this.value},e}(I),be=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_e=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return be(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Oe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ae=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Oe(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$max"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),je=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),xe=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return je(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$min"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Pe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Se=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Pe(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$mul"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(P),Ie=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Re=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Ie(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.value||1},n}(I),Ce=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ee=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Ce(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pull"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.stringifyWithKey("")},n.prototype.stringifyWithKey=function(t){var n;return new kn((n={},n[t]=this.value,n)).stringify()},n}(R),Ne=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ke=function(t){function n(n){var e=t.call(this)||this;return e.values=n,e}return Ne(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pullAll"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.values},n}(I),De=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Te=function(){return Te=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Te.apply(this,arguments)},qe=function(t){function e(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var i=t.call(this)||this;return"object"===n(i.value)&&i.value.hasOwnProperty("each")?i.value=e:(null==r?void 0:r.length)>0?i.value=[].concat.apply([],function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([e],r,!1)):i.value=e,i}return De(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){if(Array.isArray(this.value))return{$each:this.value};if("object"===n(this.value)&&this.value.hasOwnProperty("each")){var t=this.value,e={$each:t.each};return void 0!==t.position&&(e.$position=t.position),void 0!==t.slice&&(e.$slice=t.slice),void 0!==t.sort&&("string"==typeof t.sort?e.$sort=t.sort===c.DESC?-1:1:e.$sort=t.sort),e}return"object"===n(this.value)&&"string"==typeof this.value.$sort?Te(Te({},this.value),{$sort:this.value.$sort===c.DESC?-1:1}):this.value},e}(I),$e=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Fe=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return $e(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$unset"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return""},n}(P),Be=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Le=function(t){function n(n){var e=t.call(this)||this;return e.name=n,e}return Be(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$rename"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.name},n}(P),Ue=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Me=function(t){function n(n){var e=t.call(this)||this;return e.data=n,e}return Ue(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.data},n}(P),We=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),He=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return We(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.centerSphere&&(t.$centerSphere=this.val.centerSphere),void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),{$geoWithin:t}},n}(N),ze=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return We(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),void 0!==this.val.maxDistance&&(t.$maxDistance=this.val.maxDistance),void 0!==this.val.minDistance&&(t.$minDistance=this.val.minDistance),{$nearSphere:t}},n}(N),Ke=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return We(n,t),n.prototype.stringify=function(){var t={};return void 0!==this.val.geometry&&(t.$geometry=this.val.geometry.toJSON()),{$geoIntersects:t}},n}(N),Ve=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Je=function(t){function n(n){var e=t.call(this)||this;return Array.isArray(n)?e.val=n:e.val=[n],e}return Ve(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){var t={$each:this.val,$position:0};return t},n}(P),Ge=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ye=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return Ge(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return-1},n}(P),Qe=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},Xe=function(){function t(){}return t.prototype.pipeline=function(){return new Tn},t.prototype.avg=function(t){return new V(t)},t.prototype.count=function(){return new X},t.prototype.max=function(t){return new bt(t)},t.prototype.min=function(t){return new Ot(t)},t.prototype.sum=function(t){return new Ft(t)},t.prototype.and=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new z(r)},t.prototype.or=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new It(r)},t.prototype.not=function(t){return new St(t)},t.prototype.cmp=function(t,n){var e=Array.isArray(t)?t:[t,n];return new G(e)},t.prototype.eq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new nt(e)},t.prototype.neq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Pt(e)},t.prototype.lt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new wt(e)},t.prototype.lte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new gt(e)},t.prototype.gt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new it(e)},t.prototype.gte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ut(e)},t.prototype.addToSet=function(t){return new H(t)},t.prototype.arrayElemAt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new K(e)},t.prototype.indexOfArray=function(t,n,e,r){var o=Array.isArray(t)?t:[t,n,e,r].filter((function(t){return void 0!==t}));return new st(o)},t.prototype.isArray=function(t){return new pt(t)},t.prototype.size=function(t){return new Et(t)},t.prototype.in=function(t,n){var e=Array.isArray(t)?t:[t,n];return new at(e)},t.prototype.slice=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e].filter((function(t){return void 0!==t}));return new Nt(r)},t.prototype.map=function(t){return new mt(t)},t.prototype.ifNull=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ct(e)},t.prototype.cond=function(t){return new Q(t)},t.prototype.switch=function(t){return new Bt(t)},t.prototype.concat=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new Y(r)},t.prototype.dateToString=function(t){return new Z(t)},t.prototype.toLower=function(t){return new Lt(t)},t.prototype.toUpper=function(t){return new Ut(t)},t.prototype.split=function(t,n){var e=Array.isArray(t)?t:[t,n];return new kt(e)},t.prototype.substr=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new Tt(r)},t.prototype.substrBytes=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new qt(r)},t.prototype.first=function(t){return new rt(t)},t.prototype.last=function(t){return new lt(t)},t.prototype.push=function(t){return new Ct(t)},t.prototype.let=function(t){return new ht(t)},t.prototype.add=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new W(r)},t.prototype.subtract=function(t,n){var e=Array.isArray(t)?t:[t,n];return new $t(e)},t.prototype.multiply=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:Qe([t],n,!0);return new xt(r)},t.prototype.divide=function(t,n){var e=Array.isArray(t)?t:[t,n];return new tt(e)},t.prototype.abs=function(t){return new M(t)},t.prototype.ceil=function(t){return new J(t)},t.prototype.exp=function(t){return new et(t)},t.prototype.floor=function(t){return new ot(t)},t.prototype.ln=function(t){return new yt(t)},t.prototype.log=function(t,n){var e=Array.isArray(t)?t:[t,n];return new dt(e)},t.prototype.log10=function(t){return new vt(t)},t.prototype.mod=function(t,n){var e=Array.isArray(t)?t:[t,n];return new At(e)},t.prototype.pow=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Rt(e)},t.prototype.sqrt=function(t){return new Dt(t)},t.prototype.trunc=function(t){return new Mt(t)},t.prototype.mergeObjects=function(t){return new _t(t)},t.prototype.month=function(t){return new jt(t)},t.prototype.year=function(t){return new Ht(t)},t.prototype.week=function(t){return new Wt(t)},t.prototype.isoWeek=function(t){return new ft(t)},t.prototype.arrayToObject=function(t){return new Zt(t)},t.prototype.concatArrays=function(t){return new tn(t)},t.prototype.filter=function(t){return new nn(t)},t.prototype.objectToArray=function(t){return new en(t)},t.prototype.range=function(t,n,e){var r=Array.isArray(t)?t:void 0!==e?[t,n,e]:[t,n];return new rn(r)},t.prototype.reduce=function(t){return new on(t)},t.prototype.reverseArray=function(t){return new un(t)},t.prototype.zip=function(t){return new cn(t)},t.prototype.dateFromString=function(t){return new an(t)},t.prototype.indexOfBytes=function(t){return new sn(t)},t.prototype.indexOfCP=function(t){return new pn(t)},t.prototype.strLenBytes=function(t){return new fn(t)},t.prototype.strLenCP=function(t){return new ln(t)},t.prototype.strcasecmp=function(t){return new hn(t)},t.prototype.substrCP=function(t){return new yn(t)},t.prototype.stdDevPop=function(t){return new dn(t)},t.prototype.stdDevSamp=function(t){return new vn(t)},t.prototype.allElementsTrue=function(t){return new zt(t)},t.prototype.anyElementTrue=function(t){return new Kt(t)},t.prototype.setDifference=function(t){return new Vt(t)},t.prototype.setEquals=function(t){return new Jt(t)},t.prototype.setIntersection=function(t){return new Gt(t)},t.prototype.setIsSubset=function(t){return new Yt(t)},t.prototype.setUnion=function(t){return new Qt(t)},t.prototype.literal=function(t){return new Xt(t)},t.prototype.dateFromParts=function(t){return new wn(t)},t.prototype.dayOfMonth=function(t){return new gn(t)},t.prototype.dayOfWeek=function(t){return new mn(t)},t.prototype.dayOfYear=function(t){return new bn(t)},t.prototype.hour=function(t){return new _n(t)},t.prototype.isoDayOfWeek=function(t){return new On(t)},t.prototype.isoWeekYear=function(t){return new An(t)},t.prototype.millisecond=function(t){return new jn(t)},t.prototype.minute=function(t){return new xn(t)},t.prototype.second=function(t){return new Pn(t)},t}(),Ze=function(){function t(){this.aggregate=new Xe,this.Sort=c}return t.prototype.addToSet=function(t){return new me(t)},t.prototype.inc=function(t){return new _e(t)},t.prototype.max=function(t){return new Ae(t)},t.prototype.min=function(t){return new xe(t)},t.prototype.mul=function(t){return new Se(t)},t.prototype.pop=function(t){return new Re(t)},t.prototype.pull=function(t){return new Ee(t)},t.prototype.pullAll=function(t){return new ke(t)},t.prototype.push=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return new(qe.bind.apply(qe,Qe([void 0,t],n,!1)))},t.prototype.remove=function(){return new Fe},t.prototype.rename=function(t){return new Le(t)},t.prototype.set=function(t){return new Me(t)},t.prototype.expr=function(t){return new Qn(t)},t.prototype.geoWithin=function(t){return new He(t)},t.prototype.geoNear=function(t){return new ze(t)},t.prototype.geoIntersects=function(t){return new Ke(t)},t.prototype.unshift=function(t){return new Je(t)},t.prototype.shift=function(){return new Ye},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Ln(t.map(de.unchain));return new de(e)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Un(t.map(de.unchain));return new de(e)},t.prototype.not=function(t){var n=new Wn(de.unchain(t));return new de(n)},t.prototype.nor=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Mn(t.map(de.unchain));return new de(e)},t.prototype.eq=function(t){return new de(new Vn(t))},t.prototype.neq=function(t){return new de(new fe(t))},t.prototype.lt=function(t){return new de(new ie(t))},t.prototype.lte=function(t){return new de(new ce(t))},t.prototype.gt=function(t){return new de(new Zn(t))},t.prototype.gte=function(t){return new de(new ne(t))},t.prototype.in=function(t){return new de(new re(t))},t.prototype.nin=function(t){return new de(new he(t))},t.prototype.exists=function(t){return new de(new Gn(t))},t.prototype.mod=function(t,n){return new de(new se(t,n))},t.prototype.all=function(t){return new de(new $n(t))},t.prototype.elemMatch=function(t){return new de(new zn(de.unchain(t)))},t.prototype.size=function(t){return new de(new we(t))},t}(),tr=function(){function t(){}return t.buildCollectionAction=function(t,n){return{target:p.collection,action:t,collectionName:n}},t.buildCollectionListQueryAction=function(t){return{target:p.collection,action:a.queryList,options:t}},t.buildDocumentAction=function(t,n,e){return{target:p.document,action:t,collectionName:n,options:e}},t}(),nr=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),er=function(t){function n(n){var e=t.call(this)||this;return e.collectionName=n,e}return nr(n,t),n.prototype.end=function(){var t={$aggregate:this.done()};return tr.buildDocumentAction(s.aggregate,this.collectionName,t)},n}(Tn),rr=function(){function t(){this.res={}}return t.prototype.set=function(t,n){this.res.$set=this.res.$set||{},this.res.$set[t]=n},t.prototype.applyOperator=function(t,n,e){this.res[t]=this.res[t]||{},this.res[t][n]=e},t.prototype.mergeOperator=function(t,n){this.res[t]||(this.res[t]={}),Nn.mergeTo(this.res[t],n)},t.prototype.emit=function(){return this.res},t}(),or=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(e){for(var r in e=e||new rr,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],u=n(i);if(i instanceof x){if(!(i instanceof P))throw F.invalidCommand("Command 不是更新操作");i instanceof S?e.mergeOperator(i.operator,i.stringifyWithKey(o)):e.applyOperator(i.operator,o,i.stringify())}else if(i instanceof In)e.set(o,i.toJSON());else if(i instanceof Date)e.set(o,i);else if("number"===u)e.set(o,i);else if("boolean"===u)e.set(o,i);else if("string"===u)e.set(o,i);else if("bigint"===u)e.set(o,i);else{if("function"===u)throw F.invalidParam(o,"不支持函数");if("symbol"===u)throw F.invalidParam(o,"不支持 symbol");if("undefined"===u);else if(null===i)e.set(o,i);else if(Array.isArray(i))e.set(o,i);else{new t(i,o).stringify(e)}}}return e},t.prototype.toJSON=function(){return this.stringify().emit()},t}(),ir=function(){return ir=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ir.apply(this,arguments)},ur=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var e in t)t[e]?"object"!==n(t[e])&&(t[e]=1):t[e]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,n){return this.criteria.sort.push({field:t,sort:n}),this},t.prototype.update=function(t){return this.build(s.update,ir(ir({},this.baseOptions()),{$update:new or(t.data).toJSON()}))},t.prototype.updateAndReturn=function(t){var n=this.findOptions();return this.build(s.findOneAndUpdate,{$match:n.$match,$update:new or(t.data).toJSON(),$options:{$sort:n.$sort,$returnDocument:"after",$upsert:!1}})},t.prototype.set=function(t){return this.build(s.replace,ir(ir({},this.baseOptions()),{$replace:t.data,$upsert:!0}))},t.prototype.remove=function(){return this.build(s.delete,this.baseOptions())},t.prototype.get=function(){return this.build(s.queryList,ir({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(s.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var n=new kn(this.criteria.match);t.$match=n.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var n=0,e=this.criteria.sort;n<e.length;n++){var r=e[n];t.$sort[r.field]=r.sort===c.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,n){return tr.buildDocumentAction(t,this.collectionName,n)},t}(),cr=function(){function t(t,n){this.collectionName=t,this.id=n}return t.prototype.update=function(t){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new ur(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new ur(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=s.query,t},t}(),ar=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));if(this.data instanceof In)return this.data.toJSON();if(null===this.data||this.data instanceof Date)return this.data;if("object"===n(this.data)){var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i).stringify();void 0!==u&&(r[o]=u)}return r}return this.data},t}(),sr=function(){return sr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},sr.apply(this,arguments)},pr=function(){function t(t,n){this.collectionName=t,this.options=sr({maxAddCount:200},n)}return t.prototype.add=function(t){if(!(null==t?void 0:t.data))throw F.invalidParam("data","不能为空");if(Array.isArray(t.data))return this.batchAdd(t);var n=new ar(t.data).stringify();return tr.buildDocumentAction(s.create,this.collectionName,n)},t.prototype.batchAdd=function(t){if(t.data.length<=0)throw F.invalidParam("data","不能为空数组");if(t.data.length>this.options.maxAddCount)throw F.invalidParam("data","最大长度 ".concat(this.options.maxAddCount));var n={$create:new ar(t.data).stringify()};return"boolean"==typeof t.ordered&&(n.$ordered=t.ordered),tr.buildDocumentAction(s.batchCreate,this.collectionName,n)},t.prototype.doc=function(t){return new cr(this.collectionName,t)},t.prototype.limit=function(t){return new ur(this.collectionName).limit(t)},t.prototype.skip=function(t){return new ur(this.collectionName).skip(t)},t.prototype.where=function(t){return new ur(this.collectionName).where(t)},t.prototype.projection=function(t){return new ur(this.collectionName).projection(t)},t.prototype.orderBy=function(t,n){return new ur(this.collectionName).orderBy(t,n)},t.prototype.aggregate=function(){return new er(this.collectionName)},t.prototype.get=function(){return new ur(this.collectionName).get()},t.prototype.count=function(){return new ur(this.collectionName).count()},t}(),fr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},lr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function hr(){return function(t,n,e){var r=e.value;e.value=function(t){return fr(this,void 0,void 0,(function(){return lr(this,(function(n){return[2,y(r,this)(t)]}))}))}}}var yr,dr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},vr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},wr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},gr=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new er(t)}return t.prototype.addFields=function(t){return this.builder.addFields(t),this},t.prototype.count=function(t){return this.builder.count(t),this},t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.project=function(t){return this.builder.project(t),this},t.prototype.replaceRoot=function(t){return this.builder.replaceRoot(t),this},t.prototype.sort=function(t){return this.builder.sort(t),this},t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.unwind=function(t){return this.builder.unwind(t),this},t.prototype.geoNear=function(t){return this.builder.geoNear(t),this},t.prototype.bucket=function(t){return this.builder.bucket(t),this},t.prototype.bucketAuto=function(t){return this.builder.bucketAuto(t),this},t.prototype.sortByCount=function(t){return this.builder.sortByCount(t),this},t.prototype.end=function(){return vr(this,void 0,void 0,(function(){var t,n,e;return wr(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,n="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:n,data:t})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);u>3&&c&&Object.defineProperty(e,r,c)}([hr(),dr("design:type",Function),dr("design:paramtypes",[]),dr("design:returntype",Promise)],t.prototype,"end",null),t}(),mr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},br=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_r=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Or=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ar=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new ur(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,n){return this.builder.orderBy(t,n),this},t.prototype.updateAndReturn=function(t){return _r(this,void 0,void 0,(function(){var n,e,r,o;return Or(this,(function(i){switch(i.label){case 0:return n="".concat(this.getCollectionPath(),"?findOneAndUpdate"),e=this.builder.updateAndReturn(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=i.sent(),[2,{updated:(o=d.handleResponse(r))?1:0,doc:o}]}}))}))},t.prototype.update=function(t){return _r(this,void 0,void 0,(function(){var n,e,r;return Or(this,(function(o){switch(o.label){case 0:return n="".concat(this.getCollectionPath(),"?update"),e=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.set=function(t){return _r(this,void 0,void 0,(function(){var n,e,r;return Or(this,(function(o){switch(o.label){case 0:return n="".concat(this.getCollectionPath(),"?replace"),e=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.remove=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?delete"),n=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.get=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?query"),n=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.count=function(){return _r(this,void 0,void 0,(function(){var t,n,e;return Or(this,(function(r){switch(r.label){case 0:return t="".concat(this.getCollectionPath(),"?count"),n=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,{total:d.handleResponse(e).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"updateAndReturn",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"update",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[Object]),br("design:returntype",Promise)],t.prototype,"set",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"remove",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"get",null),mr([hr(),br("design:type",Function),br("design:paramtypes",[]),br("design:returntype",Promise)],t.prototype,"count",null),t}(),jr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},xr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Pr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Sr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ir=function(){function t(t,n,e){this.collectionName=t,this.id=n,this.options=e}return t.prototype.projection=function(t){return this.query.projection(t),this},t.prototype.field=function(t){return this.query.field(t),this},t.prototype.update=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(n){switch(n.label){case 0:return[4,this.query.set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Pr(this,void 0,void 0,(function(){return Sr(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Pr(this,void 0,void 0,(function(){var t,n;return Sr(this,(function(e){switch(e.label){case 0:return[4,this.query.get()];case 1:if(t=e.sent(),!(n=t[0])){if(this.options.throwOnNotFound)throw h.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,n]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return this._query||(this._query=new Ar(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)),this._query},enumerable:!1,configurable:!0}),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"update",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"updateAndReturn",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[Object]),xr("design:returntype",Promise)],t.prototype,"set",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[]),xr("design:returntype",Promise)],t.prototype,"remove",null),jr([hr(),xr("design:type",Function),xr("design:paramtypes",[]),xr("design:returntype",Promise)],t.prototype,"get",null),t}(),Rr=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Cr=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Er=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Nr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},kr=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new pr(t)}return t.prototype.add=function(t){return Er(this,void 0,void 0,(function(){var n,e,r;return Nr(this,(function(o){switch(o.label){case 0:return n=this.builder.add(t).options,e=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new Ir(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new Ar(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new Ar(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new Ar(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new Ar(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new Ar(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,n){return new Ar(this.collectionName,this.options).orderBy(t,n)},t.prototype.aggregate=function(){return new gr(this.collectionName,this.options)},t.prototype.update=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Er(this,void 0,void 0,(function(){return Nr(this,(function(n){switch(n.label){case 0:return[4,new Ar(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Er(this,void 0,void 0,(function(){return Nr(this,(function(t){switch(t.label){case 0:return[4,new Ar(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"add",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"update",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",Promise)],t.prototype,"set",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"remove",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"get",null),Rr([hr(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],t.prototype,"count",null),t}(),Dr=function(){return Dr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Dr.apply(this,arguments)},Tr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},qr=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},$r=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){return Tr(this,arguments,void 0,(function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return qr(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:n,path:e,data:r,headers:Dr({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),Fr=function(){function t(t){this.command=new Ze,this.options=Dr(Dr({},t),{httpclient:new $r(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw h.INVALID_PARAM_ERR("collectionName","不能为空");return new kr(t,this.options)},t}(),Br=function(){return Br=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Br.apply(this,arguments)},Lr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ur=function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Mr=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var n=t.trim().replace(/^cloud:\/\//,""),e=n.indexOf("/");if(e<=0)throw h.INVALID_PARAM_ERR("fileID","不合法");var r=n.substring(0,e),o=n.substring(e+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.getUploadFileURL=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i;return Ur(this,(function(u){switch(u.label){case 0:if(n="string"==typeof t?t:t.cloudPath,e=this.checkCloudPath(n))throw h.INVALID_PARAM_ERR("cloudPath",e);return r=this.getUploadPath(n.trim()),[4,this.request({method:"GET",path:r})];case 1:return o=u.sent(),i=d.handleResponse(o),[2,{fileID:this.formatFileID(i.file_id),uploadURL:i.upload_url,requestID:o.requestID}]}}))}))},t.prototype.uploadFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i;return Ur(this,(function(u){switch(u.label){case 0:return[4,this.getUploadFileURL(t)];case 1:return n=u.sent(),e=n.fileID,r=n.uploadURL,o=n.requestID,[4,this.options.fileUploader.upload({fileID:e,uploadURL:r,fileContent:t.fileContent})];case 2:if(200!==(i=u.sent()).statusCode)throw h.STORAGE_ERR(60004,"上传文件 ".concat(r," 失败"),o);return[2,{fileID:e,statusCode:i.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u;return Ur(this,(function(c){switch(c.label){case 0:if(n=this.checkFileID(t.fileID))throw h.INVALID_PARAM_ERR("fileID",n);return e=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(e),[4,this.request({method:"GET",path:r})];case 1:return o=c.sent(),i=d.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(u=c.sent()).statusCode)throw h.STORAGE_ERR(60004,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,u]}}))}))},t.prototype.deleteFile=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return Ur(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw h.INVALID_PARAM_ERR("fileList","不能为空数组");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw h.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push(c)}return a=this.getBatchDeletePath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return Lr(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return Ur(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw h.INVALID_PARAM_ERR("fileList","不能为空数组");if(n.length>50)throw h.INVALID_PARAM_ERR("fileList","最大长度 50");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw h.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push({file_id:c,expire:600})}return a=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){return Lr(this,arguments,void 0,(function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return Ur(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:n,path:e,data:r,headers:Br({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),Wr=function(){function t(){}return t.createCallFunction=function(t){return function(t){var n=t.httpclient;return y((function(t){return m(void 0,void 0,void 0,(function(){var e,r,o,i,u;return b(this,(function(c){switch(c.label){case 0:if(!t.name)throw h.INVALID_PARAM_ERR("name","缺失");return e=g(g({},t.headers),{"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"}),t.async&&(e["x-function-invoke-type"]="async"),[4,n.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:e,responseDataType:t.resultDataType,timeout:t.timeout})];case 1:if(200!==(r=c.sent()).status)throw o=-1,i="",(u=r.data)&&(o=u.errCode,i=u.errMsg,u.errDetail&&(i+=",详情:".concat(u.errDetail))),h.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data,headers:r.headers}]}}))}))}))}(t)},t.createCallContainer=function(t){return function(t){return y((function(n){return v(void 0,void 0,void 0,(function(){return w(this,(function(e){throw new Error("not implemented in "+t.type+" with "+n)}))}))}))}(t)},t.createDatabase=function(t){return new Fr(t)},t.createStorage=function(t){return new Mr(t)},t}();!function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(yr||(yr={}));var Hr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function zr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kr={exports:{}};var Vr,Jr={exports:{}};function Gr(){return Vr||(Vr=1,function(t){var n;t.exports=(n=n||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==Hr&&Hr.crypto&&(e=Hr.crypto),!e)try{e=require("crypto")}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=u.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||p).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var u=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=u<<24-(r+i)%4*8}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),s=i.enc={},p=s.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},f=s.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},h=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,u=this.blockSize,c=i/(4*u),s=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*u,p=t.min(4*s,i);if(s){for(var f=0;f<s;f+=u)this._doProcessBlock(o,f);e=o.splice(0,s),r.sigBytes-=p}return new a.init(e,p)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=h.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new y.HMAC.init(t,e).finalize(n)}}});var y=i.algo={};return i}(Math),n)}(Jr)),Jr.exports}!function(t){t.exports=Gr().enc.Hex}(Kr);var Yr=zr(Kr.exports),Qr={exports:{}},Xr={exports:{}};!function(t){var n;t.exports=(n=Gr(),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,u=e.algo,c=[],a=[];!function(){function n(n){for(var e=t.sqrt(n),r=2;r<=e;r++)if(!(n%r))return!1;return!0}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)n(r)&&(o<8&&(c[o]=e(t.pow(r,.5))),a[o]=e(t.pow(r,1/3)),o++),r++}();var s=[],p=u.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(t,n){for(var e=this._hash.words,r=e[0],o=e[1],i=e[2],u=e[3],c=e[4],p=e[5],f=e[6],l=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[n+h];else{var y=s[h-15],d=(y<<25|y>>>7)^(y<<14|y>>>18)^y>>>3,v=s[h-2],w=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;s[h]=d+s[h-7]+w+s[h-16]}var g=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&p^~c&f)+a[h]+s[h];l=f,f=p,p=c,c=u+b|0,u=i,i=o,o=r,r=b+(m+g)|0}e[0]=e[0]+r|0,e[1]=e[1]+o|0,e[2]=e[2]+i|0,e[3]=e[3]+u|0,e[4]=e[4]+c|0,e[5]=e[5]+p|0,e[6]=e[6]+f|0,e[7]=e[7]+l|0},_doFinalize:function(){var n=this._data,e=n.words,r=8*this._nDataBytes,o=8*n.sigBytes;return e[o>>>5]|=128<<24-o%32,e[14+(o+64>>>9<<4)]=t.floor(r/4294967296),e[15+(o+64>>>9<<4)]=r,n.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(p),e.HmacSHA256=i._createHmacHelper(p)}(Math),n.SHA256)}(Xr);var Zr,to=Xr.exports,no=zr(to),eo={exports:{}};!function(t){var n;t.exports=(n=Gr(),Zr||(Zr=1,function(t){var n;t.exports=(n=Gr(),void function(){var t=n,e=t.lib.Base,r=t.enc.Utf8;t.algo.HMAC=e.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=r.parse(n));var e=t.blockSize,o=4*e;n.sigBytes>o&&(n=t.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),u=this._iKey=n.clone(),c=i.words,a=u.words,s=0;s<e;s++)c[s]^=1549556828,a[s]^=909522486;i.sigBytes=u.sigBytes=o,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var n=this._hasher,e=n.finalize(t);return n.reset(),n.finalize(this._oKey.clone().concat(e))}})}())}(eo)),n.HmacSHA256)}(Qr);var ro=zr(Qr.exports),oo=function(){function t(){}return t.sign=function(n){for(var e=n.signedHeaders.join(";"),r="",o=0,i=n.signedHeaders;o<i.length;o++){var u=i[o],c=n.headers[u];r+="".concat(u,":").concat(c,"\n")}var a=t.createHash(n.body||""),s=n.method.toUpperCase()+"\n"+n.path+"\n"+n.query+"\n"+r+"\n"+e+"\n"+a+"\n",p="HMAC-SHA256",f=t.createHash(s),l="".concat(p,"\n").concat(n.timestamp,"\n").concat(f,"\n"),h=t.createSha256(l,n.secretKey);return"".concat(p," Credential=").concat(n.secretId,", SignedHeaders=").concat(e,", Signature=").concat(h)},t.signWebSocket=function(n){var e=n.queryString,r=["accessKeyId","authorization","signatureNonce","timestamp"].concat(n.signedKeys||[]).sort().map((function(t){return e[t]?"".concat(t,"=").concat(e[t]):null})).filter(Boolean).join("&"),o="".concat(n.path,"\n").concat(r,"\nhost:").concat(n.host),i=t.createHash(o),u="".concat("HMAC-SHA256","\n").concat(i);return t.createSha256(u,n.secretKey)},t.createSha256=function(t,n){return void 0===n&&(n=""),ro(t,n).toString(Yr)},t.createHash=function(t){return no(t).toString(Yr)},t}(),io=function(){function t(){}return t.detectRuntime=function(){return"undefined"!=typeof process&&process.execPath?yr.WEB:window||void 0===("undefined"==typeof my?"undefined":n(my))?window||void 0===("undefined"==typeof wx?"undefined":n(wx))?yr.WEB:yr.WEICHAT_MINI:yr.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))},t.parseUrl=function(t,n){if(n===yr.WEB)return new URL(t);var e=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=e[1],o=e[2],i=e[3],u=e[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:u||""}},t}();var uo=function(){function t(t,n){this.req=t,this.config=n}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),co=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e,o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return e=r({mode:"cors"},n),(null==n?void 0:n.timeout)&&(e.signal=AbortSignal.timeout(n.timeout)),[4,fetch(t,e)];case 1:return o=i.sent(),u={},o.headers.forEach((function(t,n){u[n]=t})),"json"!==(c=null!==(s=null==n?void 0:n.responseDataType)&&void 0!==s?s:"json")?[3,3]:[4,o.json()];case 2:return a=i.sent(),[3,12];case 3:return"text"!==c?[3,5]:[4,o.text()];case 4:return a=i.sent(),[3,12];case 5:return"arrayBuffer"!==c?[3,7]:[4,o.arrayBuffer()];case 6:return a=i.sent(),[3,12];case 7:return"blob"!==c?[3,9]:[4,o.blob()];case 8:return a=i.sent(),[3,12];case 9:return"formData"!==c?[3,11]:[4,o.formData()];case 10:return a=i.sent(),[3,12];case 11:a=o.body,i.label=12;case 12:return[2,{status:o.status,data:a,headers:u}]}}))}))},t}(),ao=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,headers:null==n?void 0:n.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw e=r.sent(),console.error(e),new Error("error: ".concat(e.error,", message: ").concat(e.errorMessage));case 3:return[2]}}))}))},t}(),so=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){wx.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,header:null==n?void 0:n.headers,dataType:"json",success:function(t){e({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),po=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case yr.ALIPAY_MINI:this.singleton=new ao;break;case yr.WEB:this.singleton=new co;break;case yr.WEICHAT_MINI:this.singleton=new so;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function fo(t,n){return o(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n()];case 1:return i.sent(),e=t.config.fetch||po.default(t.config.runtime),r=t,[4,e.request(t.req.url,t.req.requestOptions)];case 2:return r.res=i.sent(),t.result={status:t.res.status,requestID:t.requestId||(null===(o=t.res.headers)||void 0===o?void 0:o["x-trace-id"]),headers:t.res.headers,data:t.res.data},[2]}}))}))}function lo(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:throw e=r.sent(),h.NETWORK_ERR(e,t.requestId);case 3:return[2]}}))}))}function ho(t){return function(n,e){return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),u=io.parseUrl(n.req.url,n.config.runtime),c={authorization:"","x-from-app-id":n.config.appId,"x-from-env-id":n.config.envId,"x-to-env-id":n.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":n.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var e,r=null===(e=n.req.requestOptions.headers)||void 0===e?void 0:e[t];r&&(c[t]=r)})),a=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:u.pathname,query:u.search.substring(1),secretId:n.config.secretId,secretKey:n.config.secretKey,method:n.req.requestOptions.method,headers:c,body:n.req.requestOptions.body,timestamp:o,signedHeaders:a},c.authorization=oo.sign(s),n.req.requestOptions.headers=r(r({},c),n.req.requestOptions.headers),[4,e()];case 1:return i.sent(),[2]}}))}))}}var yo=function(){function t(t,n){var e;this.config=t,this.handler=(e=n,function(t,n){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var u=e[i];if(i===e.length&&(u=n),!u)return Promise.resolve();try{return Promise.resolve(u(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){return o(this,void 0,void 0,(function(){var n,e,r,o,u;return i(this,(function(i){switch(i.label){case 0:return n=this.config.endpoint+t.path,e=t.data?JSON.stringify(t.data):t.data,r=io.generateUUID(),o=Object.assign({"x-alipay-callid":r,"x-request-id":r,"x-alipay-source":"web,web-sdk","content-type":"application/json"},t.headers),u=new uo({url:n,requestOptions:{method:t.method,body:e,headers:o,responseDataType:t.responseDataType,timeout:t.timeout}},this.config),[4,this.handler(u)];case 1:return i.sent(),[2,u.result]}}))}))},t.createFunctionHttpclient=function(n){return new t(n,[lo,ho(["x-to-function-name"]),fo])},t.createDatabaseHttpclient=function(n){return new t(n,[lo,ho(["x-data-api-type","x-expire-timestamp"]),fo])},t.createStorageHttpclient=function(n){return new t(n,[lo,ho(["x-data-api-type","x-expire-timestamp"]),fo])},t}(),vo=function(){function t(t){this.config=t}return t.prototype.signedURL=function(t,n){var e="/ws/sse/function/".concat(t),o=r(r({},null==n?void 0:n.queryString),{accessKeyId:this.config.secretId,signatureNonce:io.generateUUID(),timestamp:"".concat(Date.now())});(null==n?void 0:n.authorization)&&(o.authorization=n.authorization);var i=oo.signWebSocket({host:this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),path:e.replace("/ws",""),queryString:o,secretId:this.config.secretId,secretKey:this.config.secretKey}),u=Object.entries(o).map((function(t){var n=t[0],e=t[1];return"".concat(n,"=").concat(encodeURIComponent(e))})).join("&");return"".concat(this.config.endpoint).concat(e,"?").concat(u,"&signature=").concat(i)},t}(),wo=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n=t.uploadURL,e=t.fileContent,[4,fetch(n,{method:"PUT",mode:"cors",body:e})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),go=function(t){function n(e){var r=yo.createStorageHttpclient(e),o=n.getFileUploader(e);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:e.envId})||this}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===yr.WEB)return wo.create();throw h.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},n}(Mr),mo=function(){function t(t){this.config=t}return t.prototype.signedURL=function(t,n){var e="/ws/function/".concat(t),o=r(r({},null==n?void 0:n.queryString),{accessKeyId:this.config.secretId,signatureNonce:io.generateUUID(),timestamp:"".concat(Date.now())});(null==n?void 0:n.authorization)&&(o.authorization=n.authorization);var i=oo.signWebSocket({host:this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),path:e,queryString:o,secretId:this.config.secretId,secretKey:this.config.secretKey}),u=Object.entries(o).map((function(t){var n=t[0],e=t[1];return"".concat(n,"=").concat(encodeURIComponent(e))})).join("&");return"".concat(this.config.wsEndpoint).concat(e,"?").concat(u,"&signature=").concat(i)},t}(),bo=function(){function t(t){var n=t.resourceEnv||t.envId,e=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(n,".api-hz.cloudbasefunction.cn"),wsEndpoint:t.wsEndpoint||"wss://".concat(n,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:e,envId:n,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||io.detectRuntime(),functionName:""},this.websocket=new mo(this.config),this.SSE=new vo(this.config)}return t.prototype.init=function(){},t.prototype.callFunction=function(t){return o(this,void 0,void 0,(function(){var n,e,o;return i(this,(function(i){switch(i.label){case 0:return n=r(r({},this.config),{envId:(null===(o=t.config)||void 0===o?void 0:o.env)||this.config.envId,functionName:t.name}),e=yo.createFunctionHttpclient(n),[4,Wr.createCallFunction({type:"web",httpclient:e})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new go(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.ws=function(){return this.websocket},t.prototype.sse=function(){return this.SSE},t.RUNTIME=yr,t}();t.Cloud=bo}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alipay/faas-web-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.26",
|
|
4
4
|
"description": "云函数服务 web SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@alipay/faas-common-sdk": "^1.1.
|
|
23
|
+
"@alipay/faas-common-sdk": "^1.1.26",
|
|
24
24
|
"crypto-js": "^4.1.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|