@alipay/faas-common-sdk
Advanced tools
Comparing version 1.1.22 to 1.1.23-alpha.1
@@ -1,1 +0,1 @@ | ||
var h=function(u,c,e,l){function r(t){return t instanceof e?t:new e(function(a){a(t)})}return new(e||(e=Promise))(function(t,a){function f(i){try{n(l.next(i))}catch(s){a(s)}}function o(i){try{n(l["throw"](i))}catch(s){a(s)}}function n(i){i.done?t(i.value):r(i.value).then(f,o)}n((l=l.apply(u,c||[])).next())})};var w=function(u,c){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},l,r,t,a;return a={next:f(0),"throw":f(1),"return":f(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function f(n){return function(i){return o([n,i])}}function o(n){if(l)throw new TypeError("Generator is already executing.");while(a&&(a=0,n[0]&&(e=0)),e)try{if(l=1,r&&(t=n[0]&2?r["return"]:n[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,n[1])).done)return t;if(r=0,t)n=[n[0]&2,t.value];switch(n[0]){case 0:case 1:t=n;break;case 4:e.label++;return{value:n[1],done:false};case 5:e.label++;r=n[1];n=[0];continue;case 7:n=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(n[0]===6||n[0]===2)){e=0;continue}if(n[0]===3&&(!t||n[1]>t[0]&&n[1]<t[3])){e.label=n[1];break}if(n[0]===6&&e.label<t[1]){e.label=t[1];t=n;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(n);break}if(t[2])e.ops.pop();e.trys.pop();continue}n=c.call(u,e)}catch(i){n=[6,i];r=0}finally{l=t=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{wrapCallback as b}from"./utils";export var createCallContainer=function(u){var c=function(e){return h(void 0,void 0,void 0,function(){return w(this,function(l){throw new Error("not implemented in "+u.type+" with "+e)})})};return b(c)}; | ||
var h=function(u,l,n,c){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function o(a){try{e(c.next(a))}catch(s){i(s)}}function f(a){try{e(c["throw"](a))}catch(s){i(s)}}function e(a){a.done?t(a.value):r(a.value).then(o,f)}e((c=c.apply(u,l||[])).next())})};var b=function(u,l){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},c,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=o(0),i["throw"]=o(1),i["return"]=o(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(e){return function(a){return f([e,a])}}function f(e){if(c)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(c=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=l.call(u,n)}catch(a){e=[6,a];r=0}finally{c=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};import{wrapCallback as y}from"./utils";export var createCallContainer=function(u){var l=function(n){return h(void 0,void 0,void 0,function(){return b(this,function(c){throw new Error("not implemented in "+u.type+" with "+n)})})};return y(l)}; |
@@ -1,1 +0,1 @@ | ||
var h=function(){h=Object.assign||function(o){for(var s,n=1,a=arguments.length;n<a;n++){s=arguments[n];for(var r in s)if(Object.prototype.hasOwnProperty.call(s,r))o[r]=s[r]}return o};return h.apply(this,arguments)};var y=function(o,s,n,a){function r(e){return e instanceof n?e:new n(function(c){c(e)})}return new(n||(n=Promise))(function(e,c){function u(i){try{t(a.next(i))}catch(f){c(f)}}function l(i){try{t(a["throw"](i))}catch(f){c(f)}}function t(i){i.done?e(i.value):r(i.value).then(u,l)}t((a=a.apply(o,s||[])).next())})};var v=function(o,s){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:u(0),"throw":u(1),"return":u(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(t){return function(i){return l([t,i])}}function l(t){if(a)throw new TypeError("Generator is already executing.");while(c&&(c=0,t[0]&&(n=0)),n)try{if(a=1,r&&(e=t[0]&2?r["return"]:t[0]?r["throw"]||((e=r["return"])&&e.call(r),0):r.next)&&!(e=e.call(r,t[1])).done)return e;if(r=0,e)t=[t[0]&2,e.value];switch(t[0]){case 0:case 1:e=t;break;case 4:n.label++;return{value:t[1],done:false};case 5:n.label++;r=t[1];t=[0];continue;case 7:t=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(t[0]===6||t[0]===2)){n=0;continue}if(t[0]===3&&(!e||t[1]>e[0]&&t[1]<e[3])){n.label=t[1];break}if(t[0]===6&&n.label<e[1]){n.label=e[1];e=t;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(t);break}if(e[2])n.ops.pop();n.trys.pop();continue}t=s.call(o,n)}catch(i){t=[6,i];r=0}finally{a=e=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:true}}};import{FaasError as d}from"./error";import{wrapCallback as b}from"./utils";export var createCallFunction=function(o){var s=o.httpclient;var n=function(a){return y(void 0,void 0,void 0,function(){var r,e,c,u,l,t,i;return v(this,function(f){switch(f.label){case 0:if(!a.name){throw d.INVALID_PARAM_ERR("name","\u7F3A\u5931")}r=h(h({},a.headers),{"x-to-function-name":a.name,"x-alipay-cloud-mode":"function"});if(a.async){r["x-function-invoke-type"]="async"}e="POST";c="/functions/invokeFunction";return[4,s.request({method:e,path:c,data:a.data,headers:r,responseDataType:a.resultDataType,timeout:a.timeout})];case 1:u=f.sent();if(u.status!==200){l=-1;t="";i=u.data;if(i){l=i.errCode,t=i.errMsg;if(i.errDetail){t+="\uFF0C\u8BE6\u60C5\uFF1A".concat(i.errDetail)}}throw d.SERVER_ERR(l,t,u.requestID,u.status)}return[2,{requestID:u.requestID,result:u.data,headers:u.headers}]}})})};return b(n)}; | ||
var h=function(){h=Object.assign||function(s){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var r in o)if(Object.prototype.hasOwnProperty.call(o,r))s[r]=o[r]}return s};return h.apply(this,arguments)};var y=function(s,o,n,a){function r(e){return e instanceof n?e:new n(function(u){u(e)})}return new(n||(n=Promise))(function(e,u){function c(i){try{t(a.next(i))}catch(f){u(f)}}function l(i){try{t(a["throw"](i))}catch(f){u(f)}}function t(i){i.done?e(i.value):r(i.value).then(c,l)}t((a=a.apply(s,o||[])).next())})};var b=function(s,o){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=c(0),u["throw"]=c(1),u["return"]=c(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(t){return function(i){return l([t,i])}}function l(t){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,t[0]&&(n=0)),n)try{if(a=1,r&&(e=t[0]&2?r["return"]:t[0]?r["throw"]||((e=r["return"])&&e.call(r),0):r.next)&&!(e=e.call(r,t[1])).done)return e;if(r=0,e)t=[t[0]&2,e.value];switch(t[0]){case 0:case 1:e=t;break;case 4:n.label++;return{value:t[1],done:false};case 5:n.label++;r=t[1];t=[0];continue;case 7:t=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(t[0]===6||t[0]===2)){n=0;continue}if(t[0]===3&&(!e||t[1]>e[0]&&t[1]<e[3])){n.label=t[1];break}if(t[0]===6&&n.label<e[1]){n.label=e[1];e=t;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(t);break}if(e[2])n.ops.pop();n.trys.pop();continue}t=o.call(s,n)}catch(i){t=[6,i];r=0}finally{a=e=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:true}}};import{FaasError as d}from"./error";import{wrapCallback as v}from"./utils";export var createCallFunction=function(s){var o=s.httpclient;var n=function(a){return y(void 0,void 0,void 0,function(){var r,e,u,c,l,t,i;return b(this,function(f){switch(f.label){case 0:if(!a.name){throw d.INVALID_PARAM_ERR("name","\u7F3A\u5931")}r=h(h({},a.headers),{"x-to-function-name":a.name,"x-alipay-cloud-mode":"function"});if(a.async){r["x-function-invoke-type"]="async"}e="POST";u="/functions/invokeFunction";return[4,o.request({method:e,path:u,data:a.data,headers:r,responseDataType:a.resultDataType,timeout:a.timeout})];case 1:c=f.sent();if(c.status!==200){l=-1;t="";i=c.data;if(i){l=i.errCode,t=i.errMsg;if(i.errDetail){t+="\uFF0C\u8BE6\u60C5\uFF1A".concat(i.errDetail)}}throw d.SERVER_ERR(l,t,c.requestID,c.status)}return[2,{requestID:c.requestID,result:c.data,headers:c.headers}]}})})};return v(n)}; |
@@ -1,1 +0,1 @@ | ||
var p=function(i,t,n,u){var o=arguments.length,e=o<3?t:u===null?u=Object.getOwnPropertyDescriptor(t,n):u,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,n,u);else for(var a=i.length-1;a>=0;a--)if(s=i[a])e=(o<3?s(e):o>3?s(t,n,e):s(t,n))||e;return o>3&&e&&Object.defineProperty(t,n,e),e};var f=function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var d=function(i,t,n,u){function o(e){return e instanceof n?e:new n(function(s){s(e)})}return new(n||(n=Promise))(function(e,s){function a(c){try{r(u.next(c))}catch(h){s(h)}}function l(c){try{r(u["throw"](c))}catch(h){s(h)}}function r(c){c.done?e(c.value):o(c.value).then(a,l)}r((u=u.apply(i,t||[])).next())})};var b=function(i,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,o,e,s;return s={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(r){return function(c){return l([r,c])}}function l(r){if(u)throw new TypeError("Generator is already executing.");while(s&&(s=0,r[0]&&(n=0)),n)try{if(u=1,o&&(e=r[0]&2?o["return"]:r[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,r[1])).done)return e;if(o=0,e)r=[r[0]&2,e.value];switch(r[0]){case 0:case 1:e=r;break;case 4:n.label++;return{value:r[1],done:false};case 5:n.label++;o=r[1];r=[0];continue;case 7:r=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(r[0]===6||r[0]===2)){n=0;continue}if(r[0]===3&&(!e||r[1]>e[0]&&r[1]<e[3])){n.label=r[1];break}if(r[0]===6&&n.label<e[1]){n.label=e[1];e=r;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(r);break}if(e[2])n.ops.pop();n.trys.pop();continue}r=t.call(i,n)}catch(c){r=[6,c];o=0}finally{u=e=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{AggregateBuilder as y}from"@alipay/faas-db-builder";import{WrapCallback as m}from"../decorator";import{ResponseUtil as g}from"../utils";var w=function(){function i(t,n){this.collectionName=t;this.options=n;this.builder=new y(t)}i.prototype.addFields=function(t){this.builder.addFields(t);return this};i.prototype.count=function(t){this.builder.count(t);return this};i.prototype.match=function(t){this.builder.match(t);return this};i.prototype.group=function(t){this.builder.group(t);return this};i.prototype.sample=function(t){this.builder.sample(t);return this};i.prototype.lookup=function(t){this.builder.lookup(t);return this};i.prototype.project=function(t){this.builder.project(t);return this};i.prototype.replaceRoot=function(t){this.builder.replaceRoot(t);return this};i.prototype.sort=function(t){this.builder.sort(t);return this};i.prototype.limit=function(t){this.builder.limit(t);return this};i.prototype.skip=function(t){this.builder.skip(t);return this};i.prototype.unwind=function(t){this.builder.unwind(t);return this};i.prototype.geoNear=function(t){this.builder.geoNear(t);return this};i.prototype.bucket=function(t){this.builder.bucket(t);return this};i.prototype.bucketAuto=function(t){this.builder.bucketAuto(t);return this};i.prototype.sortByCount=function(t){this.builder.sortByCount(t);return this};i.prototype.end=function(){return d(this,void 0,void 0,function(){var t,n,u,o;return b(this,function(e){switch(e.label){case 0:t=this.builder.end().options;n="POST";u="".concat(this.getCollectionPath(),"?aggregate");return[4,this.options.httpclient.request({method:n,path:u,data:t})];case 1:o=e.sent();return[2,g.handleResponse(o)]}})})};i.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};p([m(),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",Promise)],i.prototype,"end",null);return i}();export{w as Aggregate}; | ||
var p=function(i,t,n,c){var o=arguments.length,e=o<3?t:c===null?c=Object.getOwnPropertyDescriptor(t,n):c,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,n,c);else for(var a=i.length-1;a>=0;a--)if(u=i[a])e=(o<3?u(e):o>3?u(t,n,e):u(t,n))||e;return o>3&&e&&Object.defineProperty(t,n,e),e};var h=function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var d=function(i,t,n,c){function o(e){return e instanceof n?e:new n(function(u){u(e)})}return new(n||(n=Promise))(function(e,u){function a(s){try{r(c.next(s))}catch(f){u(f)}}function l(s){try{r(c["throw"](s))}catch(f){u(f)}}function r(s){s.done?e(s.value):o(s.value).then(a,l)}r((c=c.apply(i,t||[])).next())})};var b=function(i,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},c,o,e,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=a(0),u["throw"]=a(1),u["return"]=a(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(r){return function(s){return l([r,s])}}function l(r){if(c)throw new TypeError("Generator is already executing.");while(u&&(u=0,r[0]&&(n=0)),n)try{if(c=1,o&&(e=r[0]&2?o["return"]:r[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,r[1])).done)return e;if(o=0,e)r=[r[0]&2,e.value];switch(r[0]){case 0:case 1:e=r;break;case 4:n.label++;return{value:r[1],done:false};case 5:n.label++;o=r[1];r=[0];continue;case 7:r=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(r[0]===6||r[0]===2)){n=0;continue}if(r[0]===3&&(!e||r[1]>e[0]&&r[1]<e[3])){n.label=r[1];break}if(r[0]===6&&n.label<e[1]){n.label=e[1];e=r;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(r);break}if(e[2])n.ops.pop();n.trys.pop();continue}r=t.call(i,n)}catch(s){r=[6,s];o=0}finally{c=e=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{AggregateBuilder as y}from"@alipay/faas-db-builder";import{WrapCallback as m}from"../decorator";import{ResponseUtil as g}from"../utils";var w=function(){function i(t,n){this.collectionName=t;this.options=n;this.builder=new y(t)}i.prototype.addFields=function(t){this.builder.addFields(t);return this};i.prototype.count=function(t){this.builder.count(t);return this};i.prototype.match=function(t){this.builder.match(t);return this};i.prototype.group=function(t){this.builder.group(t);return this};i.prototype.sample=function(t){this.builder.sample(t);return this};i.prototype.lookup=function(t){this.builder.lookup(t);return this};i.prototype.project=function(t){this.builder.project(t);return this};i.prototype.replaceRoot=function(t){this.builder.replaceRoot(t);return this};i.prototype.sort=function(t){this.builder.sort(t);return this};i.prototype.limit=function(t){this.builder.limit(t);return this};i.prototype.skip=function(t){this.builder.skip(t);return this};i.prototype.unwind=function(t){this.builder.unwind(t);return this};i.prototype.geoNear=function(t){this.builder.geoNear(t);return this};i.prototype.bucket=function(t){this.builder.bucket(t);return this};i.prototype.bucketAuto=function(t){this.builder.bucketAuto(t);return this};i.prototype.sortByCount=function(t){this.builder.sortByCount(t);return this};i.prototype.end=function(){return d(this,void 0,void 0,function(){var t,n,c,o;return b(this,function(e){switch(e.label){case 0:t=this.builder.end().options;n="POST";c="".concat(this.getCollectionPath(),"?aggregate");return[4,this.options.httpclient.request({method:n,path:c,data:t})];case 1:o=e.sent();return[2,g.handleResponse(o)]}})})};i.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};p([m(),h("design:type",Function),h("design:paramtypes",[]),h("design:returntype",Promise)],i.prototype,"end",null);return i}();export{w as Aggregate}; |
@@ -1,1 +0,1 @@ | ||
var h=function(i,t,n,u){var s=arguments.length,e=s<3?t:u===null?u=Object.getOwnPropertyDescriptor(t,n):u,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,n,u);else for(var p=i.length-1;p>=0;p--)if(c=i[p])e=(s<3?c(e):s>3?c(t,n,e):c(t,n))||e;return s>3&&e&&Object.defineProperty(t,n,e),e};var r=function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var f=function(i,t,n,u){function s(e){return e instanceof n?e:new n(function(c){c(e)})}return new(n||(n=Promise))(function(e,c){function p(l){try{o(u.next(l))}catch(w){c(w)}}function m(l){try{o(u["throw"](l))}catch(w){c(w)}}function o(l){l.done?e(l.value):s(l.value).then(p,m)}o((u=u.apply(i,t||[])).next())})};var d=function(i,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,s,e,c;return c={next:p(0),"throw":p(1),"return":p(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function p(o){return function(l){return m([o,l])}}function m(o){if(u)throw new TypeError("Generator is already executing.");while(c&&(c=0,o[0]&&(n=0)),n)try{if(u=1,s&&(e=o[0]&2?s["return"]:o[0]?s["throw"]||((e=s["return"])&&e.call(s),0):s.next)&&!(e=e.call(s,o[1])).done)return e;if(s=0,e)o=[o[0]&2,e.value];switch(o[0]){case 0:case 1:e=o;break;case 4:n.label++;return{value:o[1],done:false};case 5:n.label++;s=o[1];o=[0];continue;case 7:o=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!e||o[1]>e[0]&&o[1]<e[3])){n.label=o[1];break}if(o[0]===6&&n.label<e[1]){n.label=e[1];e=o;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(o);break}if(e[2])n.ops.pop();n.trys.pop();continue}o=t.call(i,n)}catch(l){o=[6,l];s=0}finally{u=e=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{CollectionBuilder as b}from"@alipay/faas-db-builder";import{WrapCallback as y}from"../decorator";import{ResponseUtil as g}from"../utils";import{Aggregate as v}from"./Aggregate";import{Document as N}from"./Document";import{Query as a}from"./Query";var _=function(){function i(t,n){this.collectionName=t;this.options=n;this.builder=new b(t)}i.prototype.add=function(t){return f(this,void 0,void 0,function(){var n,u,s,e;return d(this,function(c){switch(c.label){case 0:n=this.builder.add(t).options;u="POST";s=this.getDocumentPath(t.data._id);return[4,this.options.httpclient.request({method:u,path:s,data:n})];case 1:e=c.sent();return[2,g.handleResponse(e)]}})})};i.prototype.doc=function(t){return new N(this.collectionName,t,this.options)};i.prototype.limit=function(t){return new a(this.collectionName,this.options).limit(t)};i.prototype.skip=function(t){return new a(this.collectionName,this.options).skip(t)};i.prototype.where=function(t){return new a(this.collectionName,this.options).where(t)};i.prototype.projection=function(t){return new a(this.collectionName,this.options).projection(t)};i.prototype.field=function(t){return new a(this.collectionName,this.options).field(t)};i.prototype.orderBy=function(t,n){return new a(this.collectionName,this.options).orderBy(t,n)};i.prototype.aggregate=function(){return new v(this.collectionName,this.options)};i.prototype.update=function(t){return f(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}})})};i.prototype.updateAndReturn=function(t){return f(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}})})};i.prototype.set=function(t){return f(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}})})};i.prototype.remove=function(){return f(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}})})};i.prototype.get=function(){return f(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}})})};i.prototype.count=function(){return f(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}})})};i.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")};h([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"add",null);h([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"update",null);h([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"updateAndReturn",null);h([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"set",null);h([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"remove",null);h([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"get",null);h([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"count",null);return i}();export{_ as Collection}; | ||
var f=function(i,t,n,u){var s=arguments.length,e=s<3?t:u===null?u=Object.getOwnPropertyDescriptor(t,n):u,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,n,u);else for(var p=i.length-1;p>=0;p--)if(c=i[p])e=(s<3?c(e):s>3?c(t,n,e):c(t,n))||e;return s>3&&e&&Object.defineProperty(t,n,e),e};var r=function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var h=function(i,t,n,u){function s(e){return e instanceof n?e:new n(function(c){c(e)})}return new(n||(n=Promise))(function(e,c){function p(l){try{o(u.next(l))}catch(w){c(w)}}function m(l){try{o(u["throw"](l))}catch(w){c(w)}}function o(l){l.done?e(l.value):s(l.value).then(p,m)}o((u=u.apply(i,t||[])).next())})};var d=function(i,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,s,e,c=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return c.next=p(0),c["throw"]=p(1),c["return"]=p(2),typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function p(o){return function(l){return m([o,l])}}function m(o){if(u)throw new TypeError("Generator is already executing.");while(c&&(c=0,o[0]&&(n=0)),n)try{if(u=1,s&&(e=o[0]&2?s["return"]:o[0]?s["throw"]||((e=s["return"])&&e.call(s),0):s.next)&&!(e=e.call(s,o[1])).done)return e;if(s=0,e)o=[o[0]&2,e.value];switch(o[0]){case 0:case 1:e=o;break;case 4:n.label++;return{value:o[1],done:false};case 5:n.label++;s=o[1];o=[0];continue;case 7:o=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!e||o[1]>e[0]&&o[1]<e[3])){n.label=o[1];break}if(o[0]===6&&n.label<e[1]){n.label=e[1];e=o;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(o);break}if(e[2])n.ops.pop();n.trys.pop();continue}o=t.call(i,n)}catch(l){o=[6,l];s=0}finally{u=e=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{CollectionBuilder as b}from"@alipay/faas-db-builder";import{WrapCallback as y}from"../decorator";import{ResponseUtil as g}from"../utils";import{Aggregate as v}from"./Aggregate";import{Document as N}from"./Document";import{Query as a}from"./Query";var j=function(){function i(t,n){this.collectionName=t;this.options=n;this.builder=new b(t)}i.prototype.add=function(t){return h(this,void 0,void 0,function(){var n,u,s,e;return d(this,function(c){switch(c.label){case 0:n=this.builder.add(t).options;u="POST";s=this.getDocumentPath(t.data._id);return[4,this.options.httpclient.request({method:u,path:s,data:n})];case 1:e=c.sent();return[2,g.handleResponse(e)]}})})};i.prototype.doc=function(t){return new N(this.collectionName,t,this.options)};i.prototype.limit=function(t){return new a(this.collectionName,this.options).limit(t)};i.prototype.skip=function(t){return new a(this.collectionName,this.options).skip(t)};i.prototype.where=function(t){return new a(this.collectionName,this.options).where(t)};i.prototype.projection=function(t){return new a(this.collectionName,this.options).projection(t)};i.prototype.field=function(t){return new a(this.collectionName,this.options).field(t)};i.prototype.orderBy=function(t,n){return new a(this.collectionName,this.options).orderBy(t,n)};i.prototype.aggregate=function(){return new v(this.collectionName,this.options)};i.prototype.update=function(t){return h(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}})})};i.prototype.updateAndReturn=function(t){return h(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}})})};i.prototype.set=function(t){return h(this,void 0,void 0,function(){return d(this,function(n){switch(n.label){case 0:return[4,new a(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}})})};i.prototype.remove=function(){return h(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}})})};i.prototype.get=function(){return h(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}})})};i.prototype.count=function(){return h(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,new a(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}})})};i.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")};f([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"add",null);f([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"update",null);f([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"updateAndReturn",null);f([y(),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",Promise)],i.prototype,"set",null);f([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"remove",null);f([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"get",null);f([y(),r("design:type",Function),r("design:paramtypes",[]),r("design:returntype",Promise)],i.prototype,"count",null);return i}();export{j as Collection}; |
@@ -1,1 +0,1 @@ | ||
var l=function(i,r,t,u){var o=arguments.length,e=o<3?r:u===null?u=Object.getOwnPropertyDescriptor(r,t):u,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,r,t,u);else for(var f=i.length-1;f>=0;f--)if(s=i[f])e=(o<3?s(e):o>3?s(r,t,e):s(r,t))||e;return o>3&&e&&Object.defineProperty(r,t,e),e};var c=function(i,r){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,r)};var h=function(i,r,t,u){function o(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function f(a){try{n(u.next(a))}catch(m){s(m)}}function y(a){try{n(u["throw"](a))}catch(m){s(m)}}function n(a){a.done?e(a.value):o(a.value).then(f,y)}n((u=u.apply(i,r||[])).next())})};var p=function(i,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,o,e,s;return s={next:f(0),"throw":f(1),"return":f(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function f(n){return function(a){return y([n,a])}}function y(n){if(u)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(t=0)),t)try{if(u=1,o&&(e=n[0]&2?o["return"]:n[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,n[1])).done)return e;if(o=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;o=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(i,t)}catch(a){n=[6,a];o=0}finally{u=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{WrapCallback as d}from"../decorator";import{FaasError as b}from"../error";import{Query as v}from"./Query";var g=function(){function i(r,t,u){this.collectionName=r;this.id=t;this.options=u}i.prototype.projection=function(r){this.query.projection(r);return this};i.prototype.field=function(r){this.query.field(r);return this};i.prototype.update=function(r){return h(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.query.update(r)];case 1:return[2,t.sent()]}})})};i.prototype.updateAndReturn=function(r){return h(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.query.updateAndReturn(r)];case 1:return[2,t.sent()]}})})};i.prototype.set=function(r){return h(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.query.set(r)];case 1:return[2,t.sent()]}})})};i.prototype.remove=function(){return h(this,void 0,void 0,function(){return p(this,function(r){switch(r.label){case 0:return[4,this.query.remove()];case 1:return[2,r.sent()]}})})};i.prototype.get=function(){return h(this,void 0,void 0,function(){var r,t;return p(this,function(u){switch(u.label){case 0:return[4,this.query.get()];case 1:r=u.sent();t=r[0];if(!t){if(this.options.throwOnNotFound){throw b.NOT_FOUND_ERR("\u4E0D\u5B58\u5728_id \u4E3A ".concat(this.id," \u7684\u6587\u6863"))}return[2,null]}return[2,t]}})})};Object.defineProperty(i.prototype,"query",{get:function(){if(!this._query){this._query=new v(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)}return this._query},enumerable:false,configurable:true});l([d(),c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],i.prototype,"update",null);l([d(),c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],i.prototype,"updateAndReturn",null);l([d(),c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],i.prototype,"set",null);l([d(),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",Promise)],i.prototype,"remove",null);l([d(),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",Promise)],i.prototype,"get",null);return i}();export{g as Document}; | ||
var l=function(i,r,t,o){var u=arguments.length,e=u<3?r:o===null?o=Object.getOwnPropertyDescriptor(r,t):o,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,r,t,o);else for(var f=i.length-1;f>=0;f--)if(c=i[f])e=(u<3?c(e):u>3?c(r,t,e):c(r,t))||e;return u>3&&e&&Object.defineProperty(r,t,e),e};var s=function(i,r){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,r)};var p=function(i,r,t,o){function u(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function f(a){try{n(o.next(a))}catch(b){c(b)}}function y(a){try{n(o["throw"](a))}catch(b){c(b)}}function n(a){a.done?e(a.value):u(a.value).then(f,y)}n((o=o.apply(i,r||[])).next())})};var h=function(i,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,u,e,c=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return c.next=f(0),c["throw"]=f(1),c["return"]=f(2),typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(n){return function(a){return y([n,a])}}function y(n){if(o)throw new TypeError("Generator is already executing.");while(c&&(c=0,n[0]&&(t=0)),t)try{if(o=1,u&&(e=n[0]&2?u["return"]:n[0]?u["throw"]||((e=u["return"])&&e.call(u),0):u.next)&&!(e=e.call(u,n[1])).done)return e;if(u=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;u=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(i,t)}catch(a){n=[6,a];u=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{WrapCallback as d}from"../decorator";import{FaasError as m}from"../error";import{Query as v}from"./Query";var g=function(){function i(r,t,o){this.collectionName=r;this.id=t;this.options=o}i.prototype.projection=function(r){this.query.projection(r);return this};i.prototype.field=function(r){this.query.field(r);return this};i.prototype.update=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.update(r)];case 1:return[2,t.sent()]}})})};i.prototype.updateAndReturn=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.updateAndReturn(r)];case 1:return[2,t.sent()]}})})};i.prototype.set=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.set(r)];case 1:return[2,t.sent()]}})})};i.prototype.remove=function(){return p(this,void 0,void 0,function(){return h(this,function(r){switch(r.label){case 0:return[4,this.query.remove()];case 1:return[2,r.sent()]}})})};i.prototype.get=function(){return p(this,void 0,void 0,function(){var r,t;return h(this,function(o){switch(o.label){case 0:return[4,this.query.get()];case 1:r=o.sent();t=r[0];if(!t){if(this.options.throwOnNotFound){throw m.NOT_FOUND_ERR("\u4E0D\u5B58\u5728_id \u4E3A ".concat(this.id," \u7684\u6587\u6863"))}return[2,null]}return[2,t]}})})};Object.defineProperty(i.prototype,"query",{get:function(){if(!this._query){this._query=new v(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)}return this._query},enumerable:false,configurable:true});l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"update",null);l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"updateAndReturn",null);l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"set",null);l([d(),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],i.prototype,"remove",null);l([d(),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],i.prototype,"get",null);return i}();export{g as Document}; |
@@ -1,1 +0,1 @@ | ||
var l=function(){l=Object.assign||function(i){for(var a,n=1,o=arguments.length;n<o;n++){a=arguments[n];for(var r in a)if(Object.prototype.hasOwnProperty.call(a,r))i[r]=a[r]}return i};return l.apply(this,arguments)};var d=function(i,a,n,o){function r(t){return t instanceof n?t:new n(function(c){c(t)})}return new(n||(n=Promise))(function(t,c){function s(u){try{e(o.next(u))}catch(h){c(h)}}function f(u){try{e(o["throw"](u))}catch(h){c(h)}}function e(u){u.done?t(u.value):r(u.value).then(s,f)}e((o=o.apply(i,a||[])).next())})};var m=function(i,a){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,r,t,c;return c={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function s(e){return function(u){return f([e,u])}}function f(e){if(o)throw new TypeError("Generator is already executing.");while(c&&(c=0,e[0]&&(n=0)),n)try{if(o=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=a.call(i,n)}catch(u){e=[6,u];r=0}finally{o=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};import{Command as y}from"@alipay/faas-db-builder";import{FaasError as p}from"../error";import{Collection as w}from"./Collection";var b=function(){function i(a){this.httpclient=a}i.prototype.request=function(a){return d(this,arguments,void 0,function(n){var o=n.method,r=n.path,t=n.data,c=n.headers;return m(this,function(s){switch(s.label){case 0:return[4,this.httpclient.request({method:o,path:r,data:t,headers:l({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},c)})];case 1:return[2,s.sent()]}})})};return i}();var v=function(){function i(a){this.command=new y;this.options=l(l({},a),{httpclient:new b(a.httpclient)})}i.prototype.collection=function(a){if(!a){throw p.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new w(a,this.options)};return i}();export{v as Database}; | ||
var l=function(){l=Object.assign||function(o){for(var a,n=1,c=arguments.length;n<c;n++){a=arguments[n];for(var r in a)if(Object.prototype.hasOwnProperty.call(a,r))o[r]=a[r]}return o};return l.apply(this,arguments)};var d=function(o,a,n,c){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function s(u){try{e(c.next(u))}catch(h){i(h)}}function f(u){try{e(c["throw"](u))}catch(h){i(h)}}function e(u){u.done?t(u.value):r(u.value).then(s,f)}e((c=c.apply(o,a||[])).next())})};var m=function(o,a){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},c,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=s(0),i["throw"]=s(1),i["return"]=s(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(u){return f([e,u])}}function f(e){if(c)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(c=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=a.call(o,n)}catch(u){e=[6,u];r=0}finally{c=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};import{Command as y}from"@alipay/faas-db-builder";import{FaasError as p}from"../error";import{Collection as b}from"./Collection";var w=function(){function o(a){this.httpclient=a}o.prototype.request=function(a){return d(this,arguments,void 0,function(n){var c=n.method,r=n.path,t=n.data,i=n.headers;return m(this,function(s){switch(s.label){case 0:return[4,this.httpclient.request({method:c,path:r,data:t,headers:l({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},i)})];case 1:return[2,s.sent()]}})})};return o}();var v=function(){function o(a){this.command=new y;this.options=l(l({},a),{httpclient:new w(a.httpclient)})}o.prototype.collection=function(a){if(!a){throw p.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new b(a,this.options)};return o}();export{v as Database}; |
@@ -1,1 +0,1 @@ | ||
var h=function(s,n,e,o){var i=arguments.length,t=i<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,e):o,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")t=Reflect.decorate(s,n,e,o);else for(var c=s.length-1;c>=0;c--)if(u=s[c])t=(i<3?u(t):i>3?u(n,e,t):u(n,e))||t;return i>3&&t&&Object.defineProperty(n,e,t),t};var a=function(s,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(s,n)};var l=function(s,n,e,o){function i(t){return t instanceof e?t:new e(function(u){u(t)})}return new(e||(e=Promise))(function(t,u){function c(p){try{r(o.next(p))}catch(b){u(b)}}function m(p){try{r(o["throw"](p))}catch(b){u(b)}}function r(p){p.done?t(p.value):i(p.value).then(c,m)}r((o=o.apply(s,n||[])).next())})};var d=function(s,n){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,i,t,u;return u={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(r){return function(p){return m([r,p])}}function m(r){if(o)throw new TypeError("Generator is already executing.");while(u&&(u=0,r[0]&&(e=0)),e)try{if(o=1,i&&(t=r[0]&2?i["return"]:r[0]?i["throw"]||((t=i["return"])&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;if(i=0,t)r=[r[0]&2,t.value];switch(r[0]){case 0:case 1:t=r;break;case 4:e.label++;return{value:r[1],done:false};case 5:e.label++;i=r[1];r=[0];continue;case 7:r=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(r[0]===6||r[0]===2)){e=0;continue}if(r[0]===3&&(!t||r[1]>t[0]&&r[1]<t[3])){e.label=r[1];break}if(r[0]===6&&e.label<t[1]){e.label=t[1];t=r;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(r);break}if(t[2])e.ops.pop();e.trys.pop();continue}r=n.call(s,e)}catch(p){r=[6,p];i=0}finally{o=t=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{QueryBuilder as v}from"@alipay/faas-db-builder";import{WrapCallback as f}from"../decorator";import{ResponseUtil as y}from"../utils";var g=function(){function s(n,e){this.collectionName=n;this.options=e;this.builder=new v(n)}s.prototype.limit=function(n){this.builder.limit(n);return this};s.prototype.skip=function(n){this.builder.skip(n);return this};s.prototype.where=function(n){this.builder.where(n);return this};s.prototype.projection=function(n){this.builder.projection(n);return this};s.prototype.field=function(n){this.builder.projection(n);return this};s.prototype.orderBy=function(n,e){this.builder.orderBy(n,e);return this};s.prototype.updateAndReturn=function(n){return l(this,void 0,void 0,function(){var e,o,i,t,u;return d(this,function(c){switch(c.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?findOneAndUpdate");i=this.builder.updateAndReturn(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=c.sent();u=y.handleResponse(t);return[2,{updated:u?1:0,doc:u}]}})})};s.prototype.update=function(n){return l(this,void 0,void 0,function(){var e,o,i,t;return d(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?update");i=this.builder.update(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=u.sent();return[2,y.handleResponse(t)]}})})};s.prototype.set=function(n){return l(this,void 0,void 0,function(){var e,o,i,t;return d(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?replace");i=this.builder.set(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=u.sent();return[2,y.handleResponse(t)]}})})};s.prototype.remove=function(){return l(this,void 0,void 0,function(){var n,e,o,i;return d(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?delete");o=this.builder.remove().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=t.sent();return[2,y.handleResponse(i)]}})})};s.prototype.get=function(){return l(this,void 0,void 0,function(){var n,e,o,i;return d(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?query");o=this.builder.get().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=t.sent();return[2,y.handleResponse(i)]}})})};s.prototype.count=function(){return l(this,void 0,void 0,function(){var n,e,o,i,t;return d(this,function(u){switch(u.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?count");o=this.builder.count().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=u.sent();t=y.handleResponse(i);return[2,{total:t.count}]}})})};s.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"updateAndReturn",null);h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"update",null);h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"set",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"remove",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"get",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"count",null);return s}();export{g as Query}; | ||
var h=function(s,n,e,o){var i=arguments.length,t=i<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,e):o,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")t=Reflect.decorate(s,n,e,o);else for(var c=s.length-1;c>=0;c--)if(u=s[c])t=(i<3?u(t):i>3?u(n,e,t):u(n,e))||t;return i>3&&t&&Object.defineProperty(n,e,t),t};var a=function(s,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(s,n)};var l=function(s,n,e,o){function i(t){return t instanceof e?t:new e(function(u){u(t)})}return new(e||(e=Promise))(function(t,u){function c(p){try{r(o.next(p))}catch(m){u(m)}}function b(p){try{r(o["throw"](p))}catch(m){u(m)}}function r(p){p.done?t(p.value):i(p.value).then(c,b)}r((o=o.apply(s,n||[])).next())})};var d=function(s,n){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,i,t,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=c(0),u["throw"]=c(1),u["return"]=c(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(r){return function(p){return b([r,p])}}function b(r){if(o)throw new TypeError("Generator is already executing.");while(u&&(u=0,r[0]&&(e=0)),e)try{if(o=1,i&&(t=r[0]&2?i["return"]:r[0]?i["throw"]||((t=i["return"])&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;if(i=0,t)r=[r[0]&2,t.value];switch(r[0]){case 0:case 1:t=r;break;case 4:e.label++;return{value:r[1],done:false};case 5:e.label++;i=r[1];r=[0];continue;case 7:r=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(r[0]===6||r[0]===2)){e=0;continue}if(r[0]===3&&(!t||r[1]>t[0]&&r[1]<t[3])){e.label=r[1];break}if(r[0]===6&&e.label<t[1]){e.label=t[1];t=r;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(r);break}if(t[2])e.ops.pop();e.trys.pop();continue}r=n.call(s,e)}catch(p){r=[6,p];i=0}finally{o=t=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{QueryBuilder as v}from"@alipay/faas-db-builder";import{WrapCallback as f}from"../decorator";import{ResponseUtil as y}from"../utils";var g=function(){function s(n,e){this.collectionName=n;this.options=e;this.builder=new v(n)}s.prototype.limit=function(n){this.builder.limit(n);return this};s.prototype.skip=function(n){this.builder.skip(n);return this};s.prototype.where=function(n){this.builder.where(n);return this};s.prototype.projection=function(n){this.builder.projection(n);return this};s.prototype.field=function(n){this.builder.projection(n);return this};s.prototype.orderBy=function(n,e){this.builder.orderBy(n,e);return this};s.prototype.updateAndReturn=function(n){return l(this,void 0,void 0,function(){var e,o,i,t,u;return d(this,function(c){switch(c.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?findOneAndUpdate");i=this.builder.updateAndReturn(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=c.sent();u=y.handleResponse(t);return[2,{updated:u?1:0,doc:u}]}})})};s.prototype.update=function(n){return l(this,void 0,void 0,function(){var e,o,i,t;return d(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?update");i=this.builder.update(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=u.sent();return[2,y.handleResponse(t)]}})})};s.prototype.set=function(n){return l(this,void 0,void 0,function(){var e,o,i,t;return d(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?replace");i=this.builder.set(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:i})];case 1:t=u.sent();return[2,y.handleResponse(t)]}})})};s.prototype.remove=function(){return l(this,void 0,void 0,function(){var n,e,o,i;return d(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?delete");o=this.builder.remove().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=t.sent();return[2,y.handleResponse(i)]}})})};s.prototype.get=function(){return l(this,void 0,void 0,function(){var n,e,o,i;return d(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?query");o=this.builder.get().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=t.sent();return[2,y.handleResponse(i)]}})})};s.prototype.count=function(){return l(this,void 0,void 0,function(){var n,e,o,i,t;return d(this,function(u){switch(u.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?count");o=this.builder.count().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:i=u.sent();t=y.handleResponse(i);return[2,{total:t.count}]}})})};s.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"updateAndReturn",null);h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"update",null);h([f(),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],s.prototype,"set",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"remove",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"get",null);h([f(),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],s.prototype,"count",null);return s}();export{g as Query}; |
@@ -1,1 +0,1 @@ | ||
var h=function(c,f,e,a){function r(t){return t instanceof e?t:new e(function(u){u(t)})}return new(e||(e=Promise))(function(t,u){function l(i){try{n(a.next(i))}catch(s){u(s)}}function o(i){try{n(a["throw"](i))}catch(s){u(s)}}function n(i){i.done?t(i.value):r(i.value).then(l,o)}n((a=a.apply(c,f||[])).next())})};var b=function(c,f){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,r,t,u;return u={next:l(0),"throw":l(1),"return":l(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function l(n){return function(i){return o([n,i])}}function o(n){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,n[0]&&(e=0)),e)try{if(a=1,r&&(t=n[0]&2?r["return"]:n[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,n[1])).done)return t;if(r=0,t)n=[n[0]&2,t.value];switch(n[0]){case 0:case 1:t=n;break;case 4:e.label++;return{value:n[1],done:false};case 5:e.label++;r=n[1];n=[0];continue;case 7:n=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(n[0]===6||n[0]===2)){e=0;continue}if(n[0]===3&&(!t||n[1]>t[0]&&n[1]<t[3])){e.label=n[1];break}if(n[0]===6&&e.label<t[1]){e.label=t[1];t=n;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(n);break}if(t[2])e.ops.pop();e.trys.pop();continue}n=f.call(c,e)}catch(i){n=[6,i];r=0}finally{a=t=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{wrapCallback as y}from"./utils";export function WrapCallback(){return function(c,f,e){var a=e.value;e.value=function(r){return h(this,void 0,void 0,function(){return b(this,function(t){return[2,y(a,this)(r)]})})}}} | ||
var h=function(l,f,n,u){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function c(a){try{e(u.next(a))}catch(s){i(s)}}function o(a){try{e(u["throw"](a))}catch(s){i(s)}}function e(a){a.done?t(a.value):r(a.value).then(c,o)}e((u=u.apply(l,f||[])).next())})};var b=function(l,f){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},u,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=c(0),i["throw"]=c(1),i["return"]=c(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(e){return function(a){return o([e,a])}}function o(e){if(u)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(u=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=f.call(l,n)}catch(a){e=[6,a];r=0}finally{u=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};import{wrapCallback as y}from"./utils";export function WrapCallback(){return function(l,f,n){var u=n.value;n.value=function(r){return h(this,void 0,void 0,function(){return b(this,function(t){return[2,y(u,this)(r)]})})}}} |
@@ -1,1 +0,1 @@ | ||
var w=function(){w=Object.assign||function(l){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i))l[i]=r[i]}return l};return w.apply(this,arguments)};var p=function(l,r,t,o){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function a(u){try{n(o.next(u))}catch(d){s(d)}}function h(u){try{n(o["throw"](u))}catch(d){s(d)}}function n(u){u.done?e(u.value):i(u.value).then(a,h)}n((o=o.apply(l,r||[])).next())})};var I=function(l,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,i,e,s;return s={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(u){return h([n,u])}}function h(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(t=0)),t)try{if(o=1,i&&(e=n[0]&2?i["return"]:n[0]?i["throw"]||((e=i["return"])&&e.call(i),0):i.next)&&!(e=e.call(i,n[1])).done)return e;if(i=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;i=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(l,t)}catch(u){n=[6,u];i=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{FaasError as c}from"./error";import{ResponseUtil as D}from"./utils";var y=function(){function l(r){this.options=r}l.prototype.getUploadPath=function(r){return"/".concat(r,"?upload_url")};l.prototype.getDownloadPath=function(r){return"/".concat(r,"?download_url&expire=3600")};l.prototype.getBatchDeletePath=function(){return"/?delete"};l.prototype.getBatchDownloadPath=function(){return"/?download_url"};l.prototype.checkCloudPath=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(r.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(r.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(r.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};l.prototype.checkFileID=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};l.prototype.formatFileID=function(r){return"cloud://".concat(this.options.toEnvId,"/").concat(r.replace(/^\/+/,""))};l.prototype.getCloudPathFromFileID=function(r){var t=r.trim().replace(/^cloud:\/\//,"");var o=t.indexOf("/");if(o<=0){throw c.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=t.substring(0,o);var e=t.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(r," does not belong to env ").concat(this.options.toEnvId))}return e};l.prototype.getUploadFileURL=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a;return I(this,function(h){switch(h.label){case 0:t=typeof r==="string"?r:r.cloudPath;o=this.checkCloudPath(t);if(o){throw c.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(t.trim());return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=D.handleResponse(e);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:e.requestID}]}})})};l.prototype.uploadFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s;return I(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(r)];case 1:t=a.sent(),o=t.fileID,i=t.uploadURL,e=t.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:r.fileContent})];case 2:s=a.sent();if(s.statusCode!==200){throw c.STORAGE_ERR(60004,"\u4E0A\u4F20\u6587\u4EF6 ".concat(i," \u5931\u8D25"),e)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};l.prototype.downloadFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a;return I(this,function(h){switch(h.label){case 0:t=this.checkFileID(r.fileID);if(t){throw c.INVALID_PARAM_ERR("fileID",t)}o=this.getCloudPathFromFileID(r.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=D.handleResponse(e);return[4,this.options.fileUploader.download({fileID:r.fileID,downloadURL:s.download_url})];case 2:a=h.sent();if(a.statusCode!==200){throw c.STORAGE_ERR(60004,"\u4E0B\u8F7D\u6587\u4EF6 ".concat(s.download_url," \u5931\u8D25"),e.requestID)}return[2,a]}})})};l.prototype.deleteFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,u,d;var g=this;return I(this,function(R){switch(R.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw c.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw c.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push(h)}n=this.getBatchDeletePath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:u=R.sent();d=D.handleResponse(u);return[2,{fileList:d.file_list.map(function(f){return{fileID:g.formatFileID(f.file_id),status:f.status?0:-1,errMsg:f.status?"ok":f.result_message}})}]}})})};l.prototype.getTempFileURL=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,u,d;var g=this;return I(this,function(R){switch(R.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw c.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(t.length>50){throw c.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw c.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push({file_id:h,expire:600})}n=this.getBatchDownloadPath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:u=R.sent();d=D.handleResponse(u);return[2,{fileList:d.file_list.map(function(f){return{fileID:g.formatFileID(f.file_id),tempFileURL:f.download_url,status:f.status?0:-1,errMsg:f.status?"ok":f.result_message}})}]}})})};l.prototype.request=function(r){return p(this,arguments,void 0,function(t){var o=t.method,i=t.path,e=t.data,s=t.headers;return I(this,function(a){switch(a.label){case 0:return[4,this.options.httpclient.request({method:o,path:i,data:e,headers:w({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},s)})];case 1:return[2,a.sent()]}})})};return l}();export{y as Storage}; | ||
var y=function(){y=Object.assign||function(u){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i))u[i]=r[i]}return u};return y.apply(this,arguments)};var p=function(u,r,t,o){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function a(l){try{n(o.next(l))}catch(d){s(d)}}function h(l){try{n(o["throw"](l))}catch(d){s(d)}}function n(l){l.done?e(l.value):i(l.value).then(a,h)}n((o=o.apply(u,r||[])).next())})};var I=function(u,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,i,e,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=a(0),s["throw"]=a(1),s["return"]=a(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(l){return h([n,l])}}function h(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(t=0)),t)try{if(o=1,i&&(e=n[0]&2?i["return"]:n[0]?i["throw"]||((e=i["return"])&&e.call(i),0):i.next)&&!(e=e.call(i,n[1])).done)return e;if(i=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;i=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(u,t)}catch(l){n=[6,l];i=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{FaasError as f}from"./error";import{ResponseUtil as D}from"./utils";var w=function(){function u(r){this.options=r}u.prototype.getUploadPath=function(r){return"/".concat(r,"?upload_url")};u.prototype.getDownloadPath=function(r){return"/".concat(r,"?download_url&expire=3600")};u.prototype.getBatchDeletePath=function(){return"/?delete"};u.prototype.getBatchDownloadPath=function(){return"/?download_url"};u.prototype.checkCloudPath=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(r.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(r.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(r.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};u.prototype.checkFileID=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};u.prototype.formatFileID=function(r){return"cloud://".concat(this.options.toEnvId,"/").concat(r.replace(/^\/+/,""))};u.prototype.getCloudPathFromFileID=function(r){var t=r.trim().replace(/^cloud:\/\//,"");var o=t.indexOf("/");if(o<=0){throw f.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=t.substring(0,o);var e=t.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(r," does not belong to env ").concat(this.options.toEnvId))}return e};u.prototype.getUploadFileURL=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a;return I(this,function(h){switch(h.label){case 0:t=typeof r==="string"?r:r.cloudPath;o=this.checkCloudPath(t);if(o){throw f.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(t.trim());return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=D.handleResponse(e);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:e.requestID}]}})})};u.prototype.uploadFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s;return I(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(r)];case 1:t=a.sent(),o=t.fileID,i=t.uploadURL,e=t.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:r.fileContent})];case 2:s=a.sent();if(s.statusCode!==200){throw f.STORAGE_ERR(60004,"\u4E0A\u4F20\u6587\u4EF6 ".concat(i," \u5931\u8D25"),e)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};u.prototype.downloadFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a;return I(this,function(h){switch(h.label){case 0:t=this.checkFileID(r.fileID);if(t){throw f.INVALID_PARAM_ERR("fileID",t)}o=this.getCloudPathFromFileID(r.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=D.handleResponse(e);return[4,this.options.fileUploader.download({fileID:r.fileID,downloadURL:s.download_url})];case 2:a=h.sent();if(a.statusCode!==200){throw f.STORAGE_ERR(60004,"\u4E0B\u8F7D\u6587\u4EF6 ".concat(s.download_url," \u5931\u8D25"),e.requestID)}return[2,a]}})})};u.prototype.deleteFile=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,d;var g=this;return I(this,function(R){switch(R.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw f.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw f.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push(h)}n=this.getBatchDeletePath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=R.sent();d=D.handleResponse(l);return[2,{fileList:d.file_list.map(function(c){return{fileID:g.formatFileID(c.file_id),status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.getTempFileURL=function(r){return p(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,d;var g=this;return I(this,function(R){switch(R.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw f.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(t.length>50){throw f.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw f.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push({file_id:h,expire:600})}n=this.getBatchDownloadPath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=R.sent();d=D.handleResponse(l);return[2,{fileList:d.file_list.map(function(c){return{fileID:g.formatFileID(c.file_id),tempFileURL:c.download_url,status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.request=function(r){return p(this,arguments,void 0,function(t){var o=t.method,i=t.path,e=t.data,s=t.headers;return I(this,function(a){switch(a.label){case 0:return[4,this.options.httpclient.request({method:o,path:i,data:e,headers:y({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},s)})];case 1:return[2,a.sent()]}})})};return u}();export{w as Storage}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __awaiter=this&&this.__awaiter||function(u,c,n,l){function r(e){return e instanceof n?e:new n(function(a){a(e)})}return new(n||(n=Promise))(function(e,a){function o(i){try{t(l.next(i))}catch(s){a(s)}}function f(i){try{t(l["throw"](i))}catch(s){a(s)}}function t(i){i.done?e(i.value):r(i.value).then(o,f)}t((l=l.apply(u,c||[])).next())})};var __generator=this&&this.__generator||function(u,c){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},l,r,e,a;return a={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(t){return function(i){return f([t,i])}}function f(t){if(l)throw new TypeError("Generator is already executing.");while(a&&(a=0,t[0]&&(n=0)),n)try{if(l=1,r&&(e=t[0]&2?r["return"]:t[0]?r["throw"]||((e=r["return"])&&e.call(r),0):r.next)&&!(e=e.call(r,t[1])).done)return e;if(r=0,e)t=[t[0]&2,e.value];switch(t[0]){case 0:case 1:e=t;break;case 4:n.label++;return{value:t[1],done:false};case 5:n.label++;r=t[1];t=[0];continue;case 7:t=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(t[0]===6||t[0]===2)){n=0;continue}if(t[0]===3&&(!e||t[1]>e[0]&&t[1]<e[3])){n.label=t[1];break}if(t[0]===6&&n.label<e[1]){n.label=e[1];e=t;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(t);break}if(e[2])n.ops.pop();n.trys.pop();continue}t=c.call(u,n)}catch(i){t=[6,i];r=0}finally{l=e=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.createCallContainer=void 0;var utils_1=require("./utils");var createCallContainer=function(u){var c=function(n){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(l){throw new Error("not implemented in "+u.type+" with "+n)})})};return(0,utils_1.wrapCallback)(c)};exports.createCallContainer=createCallContainer; | ||
"use strict";var __awaiter=this&&this.__awaiter||function(u,c,n,l){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function o(a){try{e(l.next(a))}catch(s){i(s)}}function f(a){try{e(l["throw"](a))}catch(s){i(s)}}function e(a){a.done?t(a.value):r(a.value).then(o,f)}e((l=l.apply(u,c||[])).next())})};var __generator=this&&this.__generator||function(u,c){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},l,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=o(0),i["throw"]=o(1),i["return"]=o(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(e){return function(a){return f([e,a])}}function f(e){if(l)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(l=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=c.call(u,n)}catch(a){e=[6,a];r=0}finally{l=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.createCallContainer=void 0;var utils_1=require("./utils");var createCallContainer=function(u){var c=function(n){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(l){throw new Error("not implemented in "+u.type+" with "+n)})})};return(0,utils_1.wrapCallback)(c)};exports.createCallContainer=createCallContainer; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(o){for(var c,r=1,a=arguments.length;r<a;r++){c=arguments[r];for(var n in c)if(Object.prototype.hasOwnProperty.call(c,n))o[n]=c[n]}return o};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(o,c,r,a){function n(t){return t instanceof r?t:new r(function(s){s(t)})}return new(r||(r=Promise))(function(t,s){function u(i){try{e(a.next(i))}catch(f){s(f)}}function l(i){try{e(a["throw"](i))}catch(f){s(f)}}function e(i){i.done?t(i.value):n(i.value).then(u,l)}e((a=a.apply(o,c||[])).next())})};var __generator=this&&this.__generator||function(o,c){var r={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,n,t,s;return s={next:u(0),"throw":u(1),"return":u(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(e){return function(i){return l([e,i])}}function l(e){if(a)throw new TypeError("Generator is already executing.");while(s&&(s=0,e[0]&&(r=0)),r)try{if(a=1,n&&(t=e[0]&2?n["return"]:e[0]?n["throw"]||((t=n["return"])&&t.call(n),0):n.next)&&!(t=t.call(n,e[1])).done)return t;if(n=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:r.label++;return{value:e[1],done:false};case 5:r.label++;n=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(t=r.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){r.label=e[1];break}if(e[0]===6&&r.label<t[1]){r.label=t[1];t=e;break}if(t&&r.label<t[2]){r.label=t[2];r.ops.push(e);break}if(t[2])r.ops.pop();r.trys.pop();continue}e=c.call(o,r)}catch(i){e=[6,i];n=0}finally{a=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.createCallFunction=void 0;var error_1=require("./error");var utils_1=require("./utils");var createCallFunction=function(o){var c=o.httpclient;var r=function(a){return __awaiter(void 0,void 0,void 0,function(){var n,t,s,u,l,e,i;return __generator(this,function(f){switch(f.label){case 0:if(!a.name){throw error_1.FaasError.INVALID_PARAM_ERR("name","\u7F3A\u5931")}n=__assign(__assign({},a.headers),{"x-to-function-name":a.name,"x-alipay-cloud-mode":"function"});if(a.async){n["x-function-invoke-type"]="async"}t="POST";s="/functions/invokeFunction";return[4,c.request({method:t,path:s,data:a.data,headers:n,responseDataType:a.resultDataType,timeout:a.timeout})];case 1:u=f.sent();if(u.status!==200){l=-1;e="";i=u.data;if(i){l=i.errCode,e=i.errMsg;if(i.errDetail){e+="\uFF0C\u8BE6\u60C5\uFF1A".concat(i.errDetail)}}throw error_1.FaasError.SERVER_ERR(l,e,u.requestID,u.status)}return[2,{requestID:u.requestID,result:u.data,headers:u.headers}]}})})};return(0,utils_1.wrapCallback)(r)};exports.createCallFunction=createCallFunction; | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(s){for(var o,r=1,a=arguments.length;r<a;r++){o=arguments[r];for(var n in o)if(Object.prototype.hasOwnProperty.call(o,n))s[n]=o[n]}return s};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(s,o,r,a){function n(t){return t instanceof r?t:new r(function(u){u(t)})}return new(r||(r=Promise))(function(t,u){function c(i){try{e(a.next(i))}catch(f){u(f)}}function l(i){try{e(a["throw"](i))}catch(f){u(f)}}function e(i){i.done?t(i.value):n(i.value).then(c,l)}e((a=a.apply(s,o||[])).next())})};var __generator=this&&this.__generator||function(s,o){var r={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,n,t,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=c(0),u["throw"]=c(1),u["return"]=c(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(e){return function(i){return l([e,i])}}function l(e){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,e[0]&&(r=0)),r)try{if(a=1,n&&(t=e[0]&2?n["return"]:e[0]?n["throw"]||((t=n["return"])&&t.call(n),0):n.next)&&!(t=t.call(n,e[1])).done)return t;if(n=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:r.label++;return{value:e[1],done:false};case 5:r.label++;n=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(t=r.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){r.label=e[1];break}if(e[0]===6&&r.label<t[1]){r.label=t[1];t=e;break}if(t&&r.label<t[2]){r.label=t[2];r.ops.push(e);break}if(t[2])r.ops.pop();r.trys.pop();continue}e=o.call(s,r)}catch(i){e=[6,i];n=0}finally{a=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.createCallFunction=void 0;var error_1=require("./error");var utils_1=require("./utils");var createCallFunction=function(s){var o=s.httpclient;var r=function(a){return __awaiter(void 0,void 0,void 0,function(){var n,t,u,c,l,e,i;return __generator(this,function(f){switch(f.label){case 0:if(!a.name){throw error_1.FaasError.INVALID_PARAM_ERR("name","\u7F3A\u5931")}n=__assign(__assign({},a.headers),{"x-to-function-name":a.name,"x-alipay-cloud-mode":"function"});if(a.async){n["x-function-invoke-type"]="async"}t="POST";u="/functions/invokeFunction";return[4,o.request({method:t,path:u,data:a.data,headers:n,responseDataType:a.resultDataType,timeout:a.timeout})];case 1:c=f.sent();if(c.status!==200){l=-1;e="";i=c.data;if(i){l=i.errCode,e=i.errMsg;if(i.errDetail){e+="\uFF0C\u8BE6\u60C5\uFF1A".concat(i.errDetail)}}throw error_1.FaasError.SERVER_ERR(l,e,c.requestID,c.status)}return[2,{requestID:c.requestID,result:c.data,headers:c.headers}]}})})};return(0,utils_1.wrapCallback)(r)};exports.createCallFunction=createCallFunction; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __decorate=this&&this.__decorate||function(i,t,r,u){var o=arguments.length,e=o<3?t:u===null?u=Object.getOwnPropertyDescriptor(t,r):u,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,r,u);else for(var c=i.length-1;c>=0;c--)if(a=i[c])e=(o<3?a(e):o>3?a(t,r,e):a(t,r))||e;return o>3&&e&&Object.defineProperty(t,r,e),e};var __metadata=this&&this.__metadata||function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var __awaiter=this&&this.__awaiter||function(i,t,r,u){function o(e){return e instanceof r?e:new r(function(a){a(e)})}return new(r||(r=Promise))(function(e,a){function c(s){try{n(u.next(s))}catch(h){a(h)}}function l(s){try{n(u["throw"](s))}catch(h){a(h)}}function n(s){s.done?e(s.value):o(s.value).then(c,l)}n((u=u.apply(i,t||[])).next())})};var __generator=this&&this.__generator||function(i,t){var r={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,o,e,a;return a={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(n){return function(s){return l([n,s])}}function l(n){if(u)throw new TypeError("Generator is already executing.");while(a&&(a=0,n[0]&&(r=0)),r)try{if(u=1,o&&(e=n[0]&2?o["return"]:n[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,n[1])).done)return e;if(o=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:r.label++;return{value:n[1],done:false};case 5:r.label++;o=n[1];n=[0];continue;case 7:n=r.ops.pop();r.trys.pop();continue;default:if(!(e=r.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){r=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){r.label=n[1];break}if(n[0]===6&&r.label<e[1]){r.label=e[1];e=n;break}if(e&&r.label<e[2]){r.label=e[2];r.ops.push(n);break}if(e[2])r.ops.pop();r.trys.pop();continue}n=t.call(i,r)}catch(s){n=[6,s];o=0}finally{u=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Aggregate=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Aggregate=function(){function i(t,r){this.collectionName=t;this.options=r;this.builder=new faas_db_builder_1.AggregateBuilder(t)}i.prototype.addFields=function(t){this.builder.addFields(t);return this};i.prototype.count=function(t){this.builder.count(t);return this};i.prototype.match=function(t){this.builder.match(t);return this};i.prototype.group=function(t){this.builder.group(t);return this};i.prototype.sample=function(t){this.builder.sample(t);return this};i.prototype.lookup=function(t){this.builder.lookup(t);return this};i.prototype.project=function(t){this.builder.project(t);return this};i.prototype.replaceRoot=function(t){this.builder.replaceRoot(t);return this};i.prototype.sort=function(t){this.builder.sort(t);return this};i.prototype.limit=function(t){this.builder.limit(t);return this};i.prototype.skip=function(t){this.builder.skip(t);return this};i.prototype.unwind=function(t){this.builder.unwind(t);return this};i.prototype.geoNear=function(t){this.builder.geoNear(t);return this};i.prototype.bucket=function(t){this.builder.bucket(t);return this};i.prototype.bucketAuto=function(t){this.builder.bucketAuto(t);return this};i.prototype.sortByCount=function(t){this.builder.sortByCount(t);return this};i.prototype.end=function(){return __awaiter(this,void 0,void 0,function(){var t,r,u,o;return __generator(this,function(e){switch(e.label){case 0:t=this.builder.end().options;r="POST";u="".concat(this.getCollectionPath(),"?aggregate");return[4,this.options.httpclient.request({method:r,path:u,data:t})];case 1:o=e.sent();return[2,utils_1.ResponseUtil.handleResponse(o)]}})})};i.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"end",null);return i}();exports.Aggregate=Aggregate; | ||
"use strict";var __decorate=this&&this.__decorate||function(i,t,r,a){var o=arguments.length,e=o<3?t:a===null?a=Object.getOwnPropertyDescriptor(t,r):a,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,t,r,a);else for(var c=i.length-1;c>=0;c--)if(u=i[c])e=(o<3?u(e):o>3?u(t,r,e):u(t,r))||e;return o>3&&e&&Object.defineProperty(t,r,e),e};var __metadata=this&&this.__metadata||function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};var __awaiter=this&&this.__awaiter||function(i,t,r,a){function o(e){return e instanceof r?e:new r(function(u){u(e)})}return new(r||(r=Promise))(function(e,u){function c(s){try{n(a.next(s))}catch(f){u(f)}}function l(s){try{n(a["throw"](s))}catch(f){u(f)}}function n(s){s.done?e(s.value):o(s.value).then(c,l)}n((a=a.apply(i,t||[])).next())})};var __generator=this&&this.__generator||function(i,t){var r={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,o,e,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=c(0),u["throw"]=c(1),u["return"]=c(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(n){return function(s){return l([n,s])}}function l(n){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,n[0]&&(r=0)),r)try{if(a=1,o&&(e=n[0]&2?o["return"]:n[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,n[1])).done)return e;if(o=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:r.label++;return{value:n[1],done:false};case 5:r.label++;o=n[1];n=[0];continue;case 7:n=r.ops.pop();r.trys.pop();continue;default:if(!(e=r.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){r=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){r.label=n[1];break}if(n[0]===6&&r.label<e[1]){r.label=e[1];e=n;break}if(e&&r.label<e[2]){r.label=e[2];r.ops.push(n);break}if(e[2])r.ops.pop();r.trys.pop();continue}n=t.call(i,r)}catch(s){n=[6,s];o=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Aggregate=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Aggregate=function(){function i(t,r){this.collectionName=t;this.options=r;this.builder=new faas_db_builder_1.AggregateBuilder(t)}i.prototype.addFields=function(t){this.builder.addFields(t);return this};i.prototype.count=function(t){this.builder.count(t);return this};i.prototype.match=function(t){this.builder.match(t);return this};i.prototype.group=function(t){this.builder.group(t);return this};i.prototype.sample=function(t){this.builder.sample(t);return this};i.prototype.lookup=function(t){this.builder.lookup(t);return this};i.prototype.project=function(t){this.builder.project(t);return this};i.prototype.replaceRoot=function(t){this.builder.replaceRoot(t);return this};i.prototype.sort=function(t){this.builder.sort(t);return this};i.prototype.limit=function(t){this.builder.limit(t);return this};i.prototype.skip=function(t){this.builder.skip(t);return this};i.prototype.unwind=function(t){this.builder.unwind(t);return this};i.prototype.geoNear=function(t){this.builder.geoNear(t);return this};i.prototype.bucket=function(t){this.builder.bucket(t);return this};i.prototype.bucketAuto=function(t){this.builder.bucketAuto(t);return this};i.prototype.sortByCount=function(t){this.builder.sortByCount(t);return this};i.prototype.end=function(){return __awaiter(this,void 0,void 0,function(){var t,r,a,o;return __generator(this,function(e){switch(e.label){case 0:t=this.builder.end().options;r="POST";a="".concat(this.getCollectionPath(),"?aggregate");return[4,this.options.httpclient.request({method:r,path:a,data:t})];case 1:o=e.sent();return[2,utils_1.ResponseUtil.handleResponse(o)]}})})};i.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"end",null);return i}();exports.Aggregate=Aggregate; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __decorate=this&&this.__decorate||function(r,t,n,s){var o=arguments.length,e=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(r,t,n,s);else for(var a=r.length-1;a>=0;a--)if(u=r[a])e=(o<3?u(e):o>3?u(t,n,e):u(t,n))||e;return o>3&&e&&Object.defineProperty(t,n,e),e};var __metadata=this&&this.__metadata||function(r,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(r,t)};var __awaiter=this&&this.__awaiter||function(r,t,n,s){function o(e){return e instanceof n?e:new n(function(u){u(e)})}return new(n||(n=Promise))(function(e,u){function a(c){try{i(s.next(c))}catch(p){u(p)}}function l(c){try{i(s["throw"](c))}catch(p){u(p)}}function i(c){c.done?e(c.value):o(c.value).then(a,l)}i((s=s.apply(r,t||[])).next())})};var __generator=this&&this.__generator||function(r,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},s,o,e,u;return u={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(i){return function(c){return l([i,c])}}function l(i){if(s)throw new TypeError("Generator is already executing.");while(u&&(u=0,i[0]&&(n=0)),n)try{if(s=1,o&&(e=i[0]&2?o["return"]:i[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,i[1])).done)return e;if(o=0,e)i=[i[0]&2,e.value];switch(i[0]){case 0:case 1:e=i;break;case 4:n.label++;return{value:i[1],done:false};case 5:n.label++;o=i[1];i=[0];continue;case 7:i=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(i[0]===6||i[0]===2)){n=0;continue}if(i[0]===3&&(!e||i[1]>e[0]&&i[1]<e[3])){n.label=i[1];break}if(i[0]===6&&n.label<e[1]){n.label=e[1];e=i;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(i);break}if(e[2])n.ops.pop();n.trys.pop();continue}i=t.call(r,n)}catch(c){i=[6,c];o=0}finally{s=e=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Collection=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Aggregate_1=require("./Aggregate");var Document_1=require("./Document");var Query_1=require("./Query");var Collection=function(){function r(t,n){this.collectionName=t;this.options=n;this.builder=new faas_db_builder_1.CollectionBuilder(t)}r.prototype.add=function(t){return __awaiter(this,void 0,void 0,function(){var n,s,o,e;return __generator(this,function(u){switch(u.label){case 0:n=this.builder.add(t).options;s="POST";o=this.getDocumentPath(t.data._id);return[4,this.options.httpclient.request({method:s,path:o,data:n})];case 1:e=u.sent();return[2,utils_1.ResponseUtil.handleResponse(e)]}})})};r.prototype.doc=function(t){return new Document_1.Document(this.collectionName,t,this.options)};r.prototype.limit=function(t){return new Query_1.Query(this.collectionName,this.options).limit(t)};r.prototype.skip=function(t){return new Query_1.Query(this.collectionName,this.options).skip(t)};r.prototype.where=function(t){return new Query_1.Query(this.collectionName,this.options).where(t)};r.prototype.projection=function(t){return new Query_1.Query(this.collectionName,this.options).projection(t)};r.prototype.field=function(t){return new Query_1.Query(this.collectionName,this.options).field(t)};r.prototype.orderBy=function(t,n){return new Query_1.Query(this.collectionName,this.options).orderBy(t,n)};r.prototype.aggregate=function(){return new Aggregate_1.Aggregate(this.collectionName,this.options)};r.prototype.update=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}})})};r.prototype.updateAndReturn=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}})})};r.prototype.set=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}})})};r.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}})})};r.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}})})};r.prototype.count=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}})})};r.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"add",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"get",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"count",null);return r}();exports.Collection=Collection; | ||
"use strict";var __decorate=this&&this.__decorate||function(r,t,n,c){var o=arguments.length,e=o<3?t:c===null?c=Object.getOwnPropertyDescriptor(t,n):c,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(r,t,n,c);else for(var a=r.length-1;a>=0;a--)if(u=r[a])e=(o<3?u(e):o>3?u(t,n,e):u(t,n))||e;return o>3&&e&&Object.defineProperty(t,n,e),e};var __metadata=this&&this.__metadata||function(r,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(r,t)};var __awaiter=this&&this.__awaiter||function(r,t,n,c){function o(e){return e instanceof n?e:new n(function(u){u(e)})}return new(n||(n=Promise))(function(e,u){function a(s){try{i(c.next(s))}catch(p){u(p)}}function l(s){try{i(c["throw"](s))}catch(p){u(p)}}function i(s){s.done?e(s.value):o(s.value).then(a,l)}i((c=c.apply(r,t||[])).next())})};var __generator=this&&this.__generator||function(r,t){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},c,o,e,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=a(0),u["throw"]=a(1),u["return"]=a(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(i){return function(s){return l([i,s])}}function l(i){if(c)throw new TypeError("Generator is already executing.");while(u&&(u=0,i[0]&&(n=0)),n)try{if(c=1,o&&(e=i[0]&2?o["return"]:i[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,i[1])).done)return e;if(o=0,e)i=[i[0]&2,e.value];switch(i[0]){case 0:case 1:e=i;break;case 4:n.label++;return{value:i[1],done:false};case 5:n.label++;o=i[1];i=[0];continue;case 7:i=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(i[0]===6||i[0]===2)){n=0;continue}if(i[0]===3&&(!e||i[1]>e[0]&&i[1]<e[3])){n.label=i[1];break}if(i[0]===6&&n.label<e[1]){n.label=e[1];e=i;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(i);break}if(e[2])n.ops.pop();n.trys.pop();continue}i=t.call(r,n)}catch(s){i=[6,s];o=0}finally{c=e=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Collection=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Aggregate_1=require("./Aggregate");var Document_1=require("./Document");var Query_1=require("./Query");var Collection=function(){function r(t,n){this.collectionName=t;this.options=n;this.builder=new faas_db_builder_1.CollectionBuilder(t)}r.prototype.add=function(t){return __awaiter(this,void 0,void 0,function(){var n,c,o,e;return __generator(this,function(u){switch(u.label){case 0:n=this.builder.add(t).options;c="POST";o=this.getDocumentPath(t.data._id);return[4,this.options.httpclient.request({method:c,path:o,data:n})];case 1:e=u.sent();return[2,utils_1.ResponseUtil.handleResponse(e)]}})})};r.prototype.doc=function(t){return new Document_1.Document(this.collectionName,t,this.options)};r.prototype.limit=function(t){return new Query_1.Query(this.collectionName,this.options).limit(t)};r.prototype.skip=function(t){return new Query_1.Query(this.collectionName,this.options).skip(t)};r.prototype.where=function(t){return new Query_1.Query(this.collectionName,this.options).where(t)};r.prototype.projection=function(t){return new Query_1.Query(this.collectionName,this.options).projection(t)};r.prototype.field=function(t){return new Query_1.Query(this.collectionName,this.options).field(t)};r.prototype.orderBy=function(t,n){return new Query_1.Query(this.collectionName,this.options).orderBy(t,n)};r.prototype.aggregate=function(){return new Aggregate_1.Aggregate(this.collectionName,this.options)};r.prototype.update=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}})})};r.prototype.updateAndReturn=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}})})};r.prototype.set=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}})})};r.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}})})};r.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}})})};r.prototype.count=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,new Query_1.Query(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}})})};r.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"add",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],r.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"get",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],r.prototype,"count",null);return r}();exports.Collection=Collection; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __decorate=this&&this.__decorate||function(i,n,t,u){var o=arguments.length,e=o<3?n:u===null?u=Object.getOwnPropertyDescriptor(n,t):u,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,n,t,u);else for(var a=i.length-1;a>=0;a--)if(c=i[a])e=(o<3?c(e):o>3?c(n,t,e):c(n,t))||e;return o>3&&e&&Object.defineProperty(n,t,e),e};var __metadata=this&&this.__metadata||function(i,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,n)};var __awaiter=this&&this.__awaiter||function(i,n,t,u){function o(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function a(s){try{r(u.next(s))}catch(f){c(f)}}function l(s){try{r(u["throw"](s))}catch(f){c(f)}}function r(s){s.done?e(s.value):o(s.value).then(a,l)}r((u=u.apply(i,n||[])).next())})};var __generator=this&&this.__generator||function(i,n){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,o,e,c;return c={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(r){return function(s){return l([r,s])}}function l(r){if(u)throw new TypeError("Generator is already executing.");while(c&&(c=0,r[0]&&(t=0)),t)try{if(u=1,o&&(e=r[0]&2?o["return"]:r[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,r[1])).done)return e;if(o=0,e)r=[r[0]&2,e.value];switch(r[0]){case 0:case 1:e=r;break;case 4:t.label++;return{value:r[1],done:false};case 5:t.label++;o=r[1];r=[0];continue;case 7:r=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(r[0]===6||r[0]===2)){t=0;continue}if(r[0]===3&&(!e||r[1]>e[0]&&r[1]<e[3])){t.label=r[1];break}if(r[0]===6&&t.label<e[1]){t.label=e[1];e=r;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(r);break}if(e[2])t.ops.pop();t.trys.pop();continue}r=n.call(i,t)}catch(s){r=[6,s];o=0}finally{u=e=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Document=void 0;var decorator_1=require("../decorator");var error_1=require("../error");var Query_1=require("./Query");var Document=function(){function i(n,t,u){this.collectionName=n;this.id=t;this.options=u}i.prototype.projection=function(n){this.query.projection(n);return this};i.prototype.field=function(n){this.query.field(n);return this};i.prototype.update=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.update(n)];case 1:return[2,t.sent()]}})})};i.prototype.updateAndReturn=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.updateAndReturn(n)];case 1:return[2,t.sent()]}})})};i.prototype.set=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.set(n)];case 1:return[2,t.sent()]}})})};i.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,this.query.remove()];case 1:return[2,n.sent()]}})})};i.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){var n,t;return __generator(this,function(u){switch(u.label){case 0:return[4,this.query.get()];case 1:n=u.sent();t=n[0];if(!t){if(this.options.throwOnNotFound){throw error_1.FaasError.NOT_FOUND_ERR("\u4E0D\u5B58\u5728_id \u4E3A ".concat(this.id," \u7684\u6587\u6863"))}return[2,null]}return[2,t]}})})};Object.defineProperty(i.prototype,"query",{get:function(){if(!this._query){this._query=new Query_1.Query(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)}return this._query},enumerable:false,configurable:true});__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"get",null);return i}();exports.Document=Document; | ||
"use strict";var __decorate=this&&this.__decorate||function(i,n,t,u){var o=arguments.length,e=o<3?n:u===null?u=Object.getOwnPropertyDescriptor(n,t):u,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,n,t,u);else for(var a=i.length-1;a>=0;a--)if(c=i[a])e=(o<3?c(e):o>3?c(n,t,e):c(n,t))||e;return o>3&&e&&Object.defineProperty(n,t,e),e};var __metadata=this&&this.__metadata||function(i,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,n)};var __awaiter=this&&this.__awaiter||function(i,n,t,u){function o(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function a(s){try{r(u.next(s))}catch(f){c(f)}}function l(s){try{r(u["throw"](s))}catch(f){c(f)}}function r(s){s.done?e(s.value):o(s.value).then(a,l)}r((u=u.apply(i,n||[])).next())})};var __generator=this&&this.__generator||function(i,n){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},u,o,e,c=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return c.next=a(0),c["throw"]=a(1),c["return"]=a(2),typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(r){return function(s){return l([r,s])}}function l(r){if(u)throw new TypeError("Generator is already executing.");while(c&&(c=0,r[0]&&(t=0)),t)try{if(u=1,o&&(e=r[0]&2?o["return"]:r[0]?o["throw"]||((e=o["return"])&&e.call(o),0):o.next)&&!(e=e.call(o,r[1])).done)return e;if(o=0,e)r=[r[0]&2,e.value];switch(r[0]){case 0:case 1:e=r;break;case 4:t.label++;return{value:r[1],done:false};case 5:t.label++;o=r[1];r=[0];continue;case 7:r=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(r[0]===6||r[0]===2)){t=0;continue}if(r[0]===3&&(!e||r[1]>e[0]&&r[1]<e[3])){t.label=r[1];break}if(r[0]===6&&t.label<e[1]){t.label=e[1];e=r;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(r);break}if(e[2])t.ops.pop();t.trys.pop();continue}r=n.call(i,t)}catch(s){r=[6,s];o=0}finally{u=e=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Document=void 0;var decorator_1=require("../decorator");var error_1=require("../error");var Query_1=require("./Query");var Document=function(){function i(n,t,u){this.collectionName=n;this.id=t;this.options=u}i.prototype.projection=function(n){this.query.projection(n);return this};i.prototype.field=function(n){this.query.field(n);return this};i.prototype.update=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.update(n)];case 1:return[2,t.sent()]}})})};i.prototype.updateAndReturn=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.updateAndReturn(n)];case 1:return[2,t.sent()]}})})};i.prototype.set=function(n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.query.set(n)];case 1:return[2,t.sent()]}})})};i.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,this.query.remove()];case 1:return[2,n.sent()]}})})};i.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){var n,t;return __generator(this,function(u){switch(u.label){case 0:return[4,this.query.get()];case 1:n=u.sent();t=n[0];if(!t){if(this.options.throwOnNotFound){throw error_1.FaasError.NOT_FOUND_ERR("\u4E0D\u5B58\u5728_id \u4E3A ".concat(this.id," \u7684\u6587\u6863"))}return[2,null]}return[2,t]}})})};Object.defineProperty(i.prototype,"query",{get:function(){if(!this._query){this._query=new Query_1.Query(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)}return this._query},enumerable:false,configurable:true});__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],i.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],i.prototype,"get",null);return i}();exports.Document=Document; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(i){for(var a,n=1,o=arguments.length;n<o;n++){a=arguments[n];for(var r in a)if(Object.prototype.hasOwnProperty.call(a,r))i[r]=a[r]}return i};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(i,a,n,o){function r(t){return t instanceof n?t:new n(function(u){u(t)})}return new(n||(n=Promise))(function(t,u){function c(s){try{e(o.next(s))}catch(f){u(f)}}function l(s){try{e(o["throw"](s))}catch(f){u(f)}}function e(s){s.done?t(s.value):r(s.value).then(c,l)}e((o=o.apply(i,a||[])).next())})};var __generator=this&&this.__generator||function(i,a){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,r,t,u;return u={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(e){return function(s){return l([e,s])}}function l(e){if(o)throw new TypeError("Generator is already executing.");while(u&&(u=0,e[0]&&(n=0)),n)try{if(o=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=a.call(i,n)}catch(s){e=[6,s];r=0}finally{o=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Database=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var error_1=require("../error");var Collection_1=require("./Collection");var DatabaseHttpclient=function(){function i(a){this.httpclient=a}i.prototype.request=function(a){return __awaiter(this,arguments,void 0,function(n){var o=n.method,r=n.path,t=n.data,u=n.headers;return __generator(this,function(c){switch(c.label){case 0:return[4,this.httpclient.request({method:o,path:r,data:t,headers:__assign({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},u)})];case 1:return[2,c.sent()]}})})};return i}();var Database=function(){function i(a){this.command=new faas_db_builder_1.Command;this.options=__assign(__assign({},a),{httpclient:new DatabaseHttpclient(a.httpclient)})}i.prototype.collection=function(a){if(!a){throw error_1.FaasError.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new Collection_1.Collection(a,this.options)};return i}();exports.Database=Database; | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(o){for(var a,n=1,u=arguments.length;n<u;n++){a=arguments[n];for(var r in a)if(Object.prototype.hasOwnProperty.call(a,r))o[r]=a[r]}return o};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(o,a,n,u){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function s(c){try{e(u.next(c))}catch(f){i(f)}}function l(c){try{e(u["throw"](c))}catch(f){i(f)}}function e(c){c.done?t(c.value):r(c.value).then(s,l)}e((u=u.apply(o,a||[])).next())})};var __generator=this&&this.__generator||function(o,a){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},u,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=s(0),i["throw"]=s(1),i["return"]=s(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(c){return l([e,c])}}function l(e){if(u)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(u=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=a.call(o,n)}catch(c){e=[6,c];r=0}finally{u=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Database=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var error_1=require("../error");var Collection_1=require("./Collection");var DatabaseHttpclient=function(){function o(a){this.httpclient=a}o.prototype.request=function(a){return __awaiter(this,arguments,void 0,function(n){var u=n.method,r=n.path,t=n.data,i=n.headers;return __generator(this,function(s){switch(s.label){case 0:return[4,this.httpclient.request({method:u,path:r,data:t,headers:__assign({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},i)})];case 1:return[2,s.sent()]}})})};return o}();var Database=function(){function o(a){this.command=new faas_db_builder_1.Command;this.options=__assign(__assign({},a),{httpclient:new DatabaseHttpclient(a.httpclient)})}o.prototype.collection=function(a){if(!a){throw error_1.FaasError.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new Collection_1.Collection(a,this.options)};return o}();exports.Database=Database; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __decorate=this&&this.__decorate||function(s,n,e,o){var r=arguments.length,t=r<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,e):o,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")t=Reflect.decorate(s,n,e,o);else for(var u=s.length-1;u>=0;u--)if(a=s[u])t=(r<3?a(t):r>3?a(n,e,t):a(n,e))||t;return r>3&&t&&Object.defineProperty(n,e,t),t};var __metadata=this&&this.__metadata||function(s,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(s,n)};var __awaiter=this&&this.__awaiter||function(s,n,e,o){function r(t){return t instanceof e?t:new e(function(a){a(t)})}return new(e||(e=Promise))(function(t,a){function u(c){try{i(o.next(c))}catch(p){a(p)}}function l(c){try{i(o["throw"](c))}catch(p){a(p)}}function i(c){c.done?t(c.value):r(c.value).then(u,l)}i((o=o.apply(s,n||[])).next())})};var __generator=this&&this.__generator||function(s,n){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,r,t,a;return a={next:u(0),"throw":u(1),"return":u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(i){return function(c){return l([i,c])}}function l(i){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,i[0]&&(e=0)),e)try{if(o=1,r&&(t=i[0]&2?r["return"]:i[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,i[1])).done)return t;if(r=0,t)i=[i[0]&2,t.value];switch(i[0]){case 0:case 1:t=i;break;case 4:e.label++;return{value:i[1],done:false};case 5:e.label++;r=i[1];i=[0];continue;case 7:i=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(i[0]===6||i[0]===2)){e=0;continue}if(i[0]===3&&(!t||i[1]>t[0]&&i[1]<t[3])){e.label=i[1];break}if(i[0]===6&&e.label<t[1]){e.label=t[1];t=i;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(i);break}if(t[2])e.ops.pop();e.trys.pop();continue}i=n.call(s,e)}catch(c){i=[6,c];r=0}finally{o=t=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Query=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Query=function(){function s(n,e){this.collectionName=n;this.options=e;this.builder=new faas_db_builder_1.QueryBuilder(n)}s.prototype.limit=function(n){this.builder.limit(n);return this};s.prototype.skip=function(n){this.builder.skip(n);return this};s.prototype.where=function(n){this.builder.where(n);return this};s.prototype.projection=function(n){this.builder.projection(n);return this};s.prototype.field=function(n){this.builder.projection(n);return this};s.prototype.orderBy=function(n,e){this.builder.orderBy(n,e);return this};s.prototype.updateAndReturn=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t,a;return __generator(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?findOneAndUpdate");r=this.builder.updateAndReturn(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=u.sent();a=utils_1.ResponseUtil.handleResponse(t);return[2,{updated:a?1:0,doc:a}]}})})};s.prototype.update=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?update");r=this.builder.update(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=a.sent();return[2,utils_1.ResponseUtil.handleResponse(t)]}})})};s.prototype.set=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?replace");r=this.builder.set(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=a.sent();return[2,utils_1.ResponseUtil.handleResponse(t)]}})})};s.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r;return __generator(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?delete");o=this.builder.remove().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=t.sent();return[2,utils_1.ResponseUtil.handleResponse(r)]}})})};s.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r;return __generator(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?query");o=this.builder.get().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=t.sent();return[2,utils_1.ResponseUtil.handleResponse(r)]}})})};s.prototype.count=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?count");o=this.builder.count().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=a.sent();t=utils_1.ResponseUtil.handleResponse(r);return[2,{total:t.count}]}})})};s.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"get",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"count",null);return s}();exports.Query=Query; | ||
"use strict";var __decorate=this&&this.__decorate||function(s,n,e,o){var r=arguments.length,t=r<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,e):o,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")t=Reflect.decorate(s,n,e,o);else for(var u=s.length-1;u>=0;u--)if(a=s[u])t=(r<3?a(t):r>3?a(n,e,t):a(n,e))||t;return r>3&&t&&Object.defineProperty(n,e,t),t};var __metadata=this&&this.__metadata||function(s,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(s,n)};var __awaiter=this&&this.__awaiter||function(s,n,e,o){function r(t){return t instanceof e?t:new e(function(a){a(t)})}return new(e||(e=Promise))(function(t,a){function u(c){try{i(o.next(c))}catch(p){a(p)}}function l(c){try{i(o["throw"](c))}catch(p){a(p)}}function i(c){c.done?t(c.value):r(c.value).then(u,l)}i((o=o.apply(s,n||[])).next())})};var __generator=this&&this.__generator||function(s,n){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,r,t,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(i){return function(c){return l([i,c])}}function l(i){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,i[0]&&(e=0)),e)try{if(o=1,r&&(t=i[0]&2?r["return"]:i[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,i[1])).done)return t;if(r=0,t)i=[i[0]&2,t.value];switch(i[0]){case 0:case 1:t=i;break;case 4:e.label++;return{value:i[1],done:false};case 5:e.label++;r=i[1];i=[0];continue;case 7:i=e.ops.pop();e.trys.pop();continue;default:if(!(t=e.trys,t=t.length>0&&t[t.length-1])&&(i[0]===6||i[0]===2)){e=0;continue}if(i[0]===3&&(!t||i[1]>t[0]&&i[1]<t[3])){e.label=i[1];break}if(i[0]===6&&e.label<t[1]){e.label=t[1];t=i;break}if(t&&e.label<t[2]){e.label=t[2];e.ops.push(i);break}if(t[2])e.ops.pop();e.trys.pop();continue}i=n.call(s,e)}catch(c){i=[6,c];r=0}finally{o=t=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Query=void 0;var faas_db_builder_1=require("@alipay/faas-db-builder");var decorator_1=require("../decorator");var utils_1=require("../utils");var Query=function(){function s(n,e){this.collectionName=n;this.options=e;this.builder=new faas_db_builder_1.QueryBuilder(n)}s.prototype.limit=function(n){this.builder.limit(n);return this};s.prototype.skip=function(n){this.builder.skip(n);return this};s.prototype.where=function(n){this.builder.where(n);return this};s.prototype.projection=function(n){this.builder.projection(n);return this};s.prototype.field=function(n){this.builder.projection(n);return this};s.prototype.orderBy=function(n,e){this.builder.orderBy(n,e);return this};s.prototype.updateAndReturn=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t,a;return __generator(this,function(u){switch(u.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?findOneAndUpdate");r=this.builder.updateAndReturn(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=u.sent();a=utils_1.ResponseUtil.handleResponse(t);return[2,{updated:a?1:0,doc:a}]}})})};s.prototype.update=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?update");r=this.builder.update(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=a.sent();return[2,utils_1.ResponseUtil.handleResponse(t)]}})})};s.prototype.set=function(n){return __awaiter(this,void 0,void 0,function(){var e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:e="POST";o="".concat(this.getCollectionPath(),"?replace");r=this.builder.set(n).options;return[4,this.options.httpclient.request({method:e,path:o,data:r})];case 1:t=a.sent();return[2,utils_1.ResponseUtil.handleResponse(t)]}})})};s.prototype.remove=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r;return __generator(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?delete");o=this.builder.remove().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=t.sent();return[2,utils_1.ResponseUtil.handleResponse(r)]}})})};s.prototype.get=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r;return __generator(this,function(t){switch(t.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?query");o=this.builder.get().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=t.sent();return[2,utils_1.ResponseUtil.handleResponse(r)]}})})};s.prototype.count=function(){return __awaiter(this,void 0,void 0,function(){var n,e,o,r,t;return __generator(this,function(a){switch(a.label){case 0:n="POST";e="".concat(this.getCollectionPath(),"?count");o=this.builder.count().options;return[4,this.options.httpclient.request({method:n,path:e,data:o})];case 1:r=a.sent();t=utils_1.ResponseUtil.handleResponse(r);return[2,{total:t.count}]}})})};s.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)};__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"updateAndReturn",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"update",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],s.prototype,"set",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"remove",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"get",null);__decorate([(0,decorator_1.WrapCallback)(),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",Promise)],s.prototype,"count",null);return s}();exports.Query=Query; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __awaiter=this&&this.__awaiter||function(c,f,n,a){function r(t){return t instanceof n?t:new n(function(u){u(t)})}return new(n||(n=Promise))(function(t,u){function l(i){try{e(a.next(i))}catch(o){u(o)}}function s(i){try{e(a["throw"](i))}catch(o){u(o)}}function e(i){i.done?t(i.value):r(i.value).then(l,s)}e((a=a.apply(c,f||[])).next())})};var __generator=this&&this.__generator||function(c,f){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,r,t,u;return u={next:l(0),"throw":l(1),"return":l(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function l(e){return function(i){return s([e,i])}}function s(e){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,e[0]&&(n=0)),n)try{if(a=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=f.call(c,n)}catch(i){e=[6,i];r=0}finally{a=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.WrapCallback=WrapCallback;var utils_1=require("./utils");function WrapCallback(){return function(c,f,n){var a=n.value;n.value=function(r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,(0,utils_1.wrapCallback)(a,this)(r)]})})}}} | ||
"use strict";var __awaiter=this&&this.__awaiter||function(c,f,n,u){function r(t){return t instanceof n?t:new n(function(i){i(t)})}return new(n||(n=Promise))(function(t,i){function l(a){try{e(u.next(a))}catch(s){i(s)}}function o(a){try{e(u["throw"](a))}catch(s){i(s)}}function e(a){a.done?t(a.value):r(a.value).then(l,o)}e((u=u.apply(c,f||[])).next())})};var __generator=this&&this.__generator||function(c,f){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},u,r,t,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=l(0),i["throw"]=l(1),i["return"]=l(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(e){return function(a){return o([e,a])}}function o(e){if(u)throw new TypeError("Generator is already executing.");while(i&&(i=0,e[0]&&(n=0)),n)try{if(u=1,r&&(t=e[0]&2?r["return"]:e[0]?r["throw"]||((t=r["return"])&&t.call(r),0):r.next)&&!(t=t.call(r,e[1])).done)return t;if(r=0,t)e=[e[0]&2,t.value];switch(e[0]){case 0:case 1:t=e;break;case 4:n.label++;return{value:e[1],done:false};case 5:n.label++;r=e[1];e=[0];continue;case 7:e=n.ops.pop();n.trys.pop();continue;default:if(!(t=n.trys,t=t.length>0&&t[t.length-1])&&(e[0]===6||e[0]===2)){n=0;continue}if(e[0]===3&&(!t||e[1]>t[0]&&e[1]<t[3])){n.label=e[1];break}if(e[0]===6&&n.label<t[1]){n.label=t[1];t=e;break}if(t&&n.label<t[2]){n.label=t[2];n.ops.push(e);break}if(t[2])n.ops.pop();n.trys.pop();continue}e=f.call(c,n)}catch(a){e=[6,a];r=0}finally{u=t=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.WrapCallback=WrapCallback;var utils_1=require("./utils");function WrapCallback(){return function(c,f,n){var u=n.value;n.value=function(r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,(0,utils_1.wrapCallback)(u,this)(r)]})})}}} |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(u){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i))u[i]=r[i]}return u};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(u,r,t,o){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function a(l){try{n(o.next(l))}catch(f){s(f)}}function h(l){try{n(o["throw"](l))}catch(f){s(f)}}function n(l){l.done?e(l.value):i(l.value).then(a,h)}n((o=o.apply(u,r||[])).next())})};var __generator=this&&this.__generator||function(u,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,i,e,s;return s={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(l){return h([n,l])}}function h(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(t=0)),t)try{if(o=1,i&&(e=n[0]&2?i["return"]:n[0]?i["throw"]||((e=i["return"])&&e.call(i),0):i.next)&&!(e=e.call(i,n[1])).done)return e;if(i=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;i=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(u,t)}catch(l){n=[6,l];i=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Storage=void 0;var error_1=require("./error");var utils_1=require("./utils");var Storage=function(){function u(r){this.options=r}u.prototype.getUploadPath=function(r){return"/".concat(r,"?upload_url")};u.prototype.getDownloadPath=function(r){return"/".concat(r,"?download_url&expire=3600")};u.prototype.getBatchDeletePath=function(){return"/?delete"};u.prototype.getBatchDownloadPath=function(){return"/?download_url"};u.prototype.checkCloudPath=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(r.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(r.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(r.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};u.prototype.checkFileID=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};u.prototype.formatFileID=function(r){return"cloud://".concat(this.options.toEnvId,"/").concat(r.replace(/^\/+/,""))};u.prototype.getCloudPathFromFileID=function(r){var t=r.trim().replace(/^cloud:\/\//,"");var o=t.indexOf("/");if(o<=0){throw error_1.FaasError.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=t.substring(0,o);var e=t.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(r," does not belong to env ").concat(this.options.toEnvId))}return e};u.prototype.getUploadFileURL=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a;return __generator(this,function(h){switch(h.label){case 0:t=typeof r==="string"?r:r.cloudPath;o=this.checkCloudPath(t);if(o){throw error_1.FaasError.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(t.trim());return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=utils_1.ResponseUtil.handleResponse(e);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:e.requestID}]}})})};u.prototype.uploadFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s;return __generator(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(r)];case 1:t=a.sent(),o=t.fileID,i=t.uploadURL,e=t.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:r.fileContent})];case 2:s=a.sent();if(s.statusCode!==200){throw error_1.FaasError.STORAGE_ERR(60004,"\u4E0A\u4F20\u6587\u4EF6 ".concat(i," \u5931\u8D25"),e)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};u.prototype.downloadFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a;return __generator(this,function(h){switch(h.label){case 0:t=this.checkFileID(r.fileID);if(t){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",t)}o=this.getCloudPathFromFileID(r.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=utils_1.ResponseUtil.handleResponse(e);return[4,this.options.fileUploader.download({fileID:r.fileID,downloadURL:s.download_url})];case 2:a=h.sent();if(a.statusCode!==200){throw error_1.FaasError.STORAGE_ERR(60004,"\u4E0B\u8F7D\u6587\u4EF6 ".concat(s.download_url," \u5931\u8D25"),e.requestID)}return[2,a]}})})};u.prototype.deleteFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push(h)}n=this.getBatchDeletePath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=d.sent();f=utils_1.ResponseUtil.handleResponse(l);return[2,{fileList:f.file_list.map(function(c){return{fileID:p.formatFileID(c.file_id),status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.getTempFileURL=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(t.length>50){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push({file_id:h,expire:600})}n=this.getBatchDownloadPath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=d.sent();f=utils_1.ResponseUtil.handleResponse(l);return[2,{fileList:f.file_list.map(function(c){return{fileID:p.formatFileID(c.file_id),tempFileURL:c.download_url,status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.request=function(r){return __awaiter(this,arguments,void 0,function(t){var o=t.method,i=t.path,e=t.data,s=t.headers;return __generator(this,function(a){switch(a.label){case 0:return[4,this.options.httpclient.request({method:o,path:i,data:e,headers:__assign({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},s)})];case 1:return[2,a.sent()]}})})};return u}();exports.Storage=Storage; | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(u){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i))u[i]=r[i]}return u};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(u,r,t,o){function i(e){return e instanceof t?e:new t(function(s){s(e)})}return new(t||(t=Promise))(function(e,s){function a(l){try{n(o.next(l))}catch(f){s(f)}}function h(l){try{n(o["throw"](l))}catch(f){s(f)}}function n(l){l.done?e(l.value):i(l.value).then(a,h)}n((o=o.apply(u,r||[])).next())})};var __generator=this&&this.__generator||function(u,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,i,e,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=a(0),s["throw"]=a(1),s["return"]=a(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(n){return function(l){return h([n,l])}}function h(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(t=0)),t)try{if(o=1,i&&(e=n[0]&2?i["return"]:n[0]?i["throw"]||((e=i["return"])&&e.call(i),0):i.next)&&!(e=e.call(i,n[1])).done)return e;if(i=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;i=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(u,t)}catch(l){n=[6,l];i=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.Storage=void 0;var error_1=require("./error");var utils_1=require("./utils");var Storage=function(){function u(r){this.options=r}u.prototype.getUploadPath=function(r){return"/".concat(r,"?upload_url")};u.prototype.getDownloadPath=function(r){return"/".concat(r,"?download_url&expire=3600")};u.prototype.getBatchDeletePath=function(){return"/?delete"};u.prototype.getBatchDownloadPath=function(){return"/?download_url"};u.prototype.checkCloudPath=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(r.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(r.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(r.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};u.prototype.checkFileID=function(r){if(typeof r!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";r=r.trim();if(!r)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};u.prototype.formatFileID=function(r){return"cloud://".concat(this.options.toEnvId,"/").concat(r.replace(/^\/+/,""))};u.prototype.getCloudPathFromFileID=function(r){var t=r.trim().replace(/^cloud:\/\//,"");var o=t.indexOf("/");if(o<=0){throw error_1.FaasError.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=t.substring(0,o);var e=t.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(r," does not belong to env ").concat(this.options.toEnvId))}return e};u.prototype.getUploadFileURL=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a;return __generator(this,function(h){switch(h.label){case 0:t=typeof r==="string"?r:r.cloudPath;o=this.checkCloudPath(t);if(o){throw error_1.FaasError.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(t.trim());return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=utils_1.ResponseUtil.handleResponse(e);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:e.requestID}]}})})};u.prototype.uploadFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s;return __generator(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(r)];case 1:t=a.sent(),o=t.fileID,i=t.uploadURL,e=t.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:r.fileContent})];case 2:s=a.sent();if(s.statusCode!==200){throw error_1.FaasError.STORAGE_ERR(60004,"\u4E0A\u4F20\u6587\u4EF6 ".concat(i," \u5931\u8D25"),e)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};u.prototype.downloadFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a;return __generator(this,function(h){switch(h.label){case 0:t=this.checkFileID(r.fileID);if(t){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",t)}o=this.getCloudPathFromFileID(r.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:e=h.sent();s=utils_1.ResponseUtil.handleResponse(e);return[4,this.options.fileUploader.download({fileID:r.fileID,downloadURL:s.download_url})];case 2:a=h.sent();if(a.statusCode!==200){throw error_1.FaasError.STORAGE_ERR(60004,"\u4E0B\u8F7D\u6587\u4EF6 ".concat(s.download_url," \u5931\u8D25"),e.requestID)}return[2,a]}})})};u.prototype.deleteFile=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push(h)}n=this.getBatchDeletePath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=d.sent();f=utils_1.ResponseUtil.handleResponse(l);return[2,{fileList:f.file_list.map(function(c){return{fileID:p.formatFileID(c.file_id),status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.getTempFileURL=function(r){return __awaiter(this,void 0,void 0,function(){var t,o,i,e,s,a,h,n,l,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:t=Array.isArray(r)?r:r.fileList;if(!Array.isArray(t)||t.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(t.length>50){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,e=t;i<e.length;i++){s=e[i];a=this.checkFileID(s);if(a){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",a)}h=this.getCloudPathFromFileID(s);o.push({file_id:h,expire:600})}n=this.getBatchDownloadPath();return[4,this.request({method:"POST",path:n,data:{file_list:o}})];case 1:l=d.sent();f=utils_1.ResponseUtil.handleResponse(l);return[2,{fileList:f.file_list.map(function(c){return{fileID:p.formatFileID(c.file_id),tempFileURL:c.download_url,status:c.status?0:-1,errMsg:c.status?"ok":c.result_message}})}]}})})};u.prototype.request=function(r){return __awaiter(this,arguments,void 0,function(t){var o=t.method,i=t.path,e=t.data,s=t.headers;return __generator(this,function(a){switch(a.label){case 0:return[4,this.options.httpclient.request({method:o,path:i,data:e,headers:__assign({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},s)})];case 1:return[2,a.sent()]}})})};return u}();exports.Storage=Storage; |
{ | ||
"name": "@alipay/faas-common-sdk", | ||
"version": "1.1.22", | ||
"version": "1.1.23-alpha.1", | ||
"description": "云函数服务通用 SDK", | ||
@@ -33,3 +33,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@alipay/faas-db-builder": "^1.1.22" | ||
"@alipay/faas-db-builder": "^1.1.23-alpha.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114327
14