@alipay/faas-common-sdk 1.1.19 → 1.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var l=function(){l=Object.assign||function(o){for(var r,n=1,c=arguments.length;n<c;n++){r=arguments[n];for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a))o[a]=r[a]}return o};return l.apply(this,arguments)};var d=function(o,r,n,c){function a(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):a(u.value).then(s,f)}e((c=c.apply(o,r||[])).next())})};var m=function(o,r){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},c,a,t,i;return i={next:s(0),"throw":s(1),"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,a&&(t=e[0]&2?a["return"]:e[0]?a["throw"]||((t=a["return"])&&t.call(a),0):a.next)&&!(t=t.call(a,e[1])).done)return t;if(a=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++;a=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=r.call(o,n)}catch(u){e=[6,u];a=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 b}from"../error";import{Collection as p}from"./Collection";var w=function(){function o(r){this.httpclient=r}o.prototype.request=function(r){var n=r.method,c=r.path,a=r.data,t=r.headers;return d(this,void 0,void 0,function(){return m(this,function(i){switch(i.label){case 0:return[4,this.httpclient.request({method:n,path:c,data:a,headers:l({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},t)})];case 1:return[2,i.sent()]}})})};return o}();var v=function(){function o(r){this.command=new y;this.options=l(l({},r),{httpclient:new w(r.httpclient)})}o.prototype.collection=function(r){if(!r){throw b.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new p(r,this.options)};return o}();export{v as Database};
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};
package/esm/Storage.js CHANGED
@@ -1 +1 @@
1
- var w=function(){w=Object.assign||function(l){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i))l[i]=e[i]}return l};return w.apply(this,arguments)};var p=function(l,e,r,o){function i(t){return t instanceof r?t:new r(function(s){s(t)})}return new(r||(r=Promise))(function(t,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?t(u.value):i(u.value).then(a,h)}n((o=o.apply(l,e||[])).next())})};var I=function(l,e){var r={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,i,t,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]&&(r=0)),r)try{if(o=1,i&&(t=n[0]&2?i["return"]:n[0]?i["throw"]||((t=i["return"])&&t.call(i),0):i.next)&&!(t=t.call(i,n[1])).done)return t;if(i=0,t)n=[n[0]&2,t.value];switch(n[0]){case 0:case 1:t=n;break;case 4:r.label++;return{value:n[1],done:false};case 5:r.label++;i=n[1];n=[0];continue;case 7:n=r.ops.pop();r.trys.pop();continue;default:if(!(t=r.trys,t=t.length>0&&t[t.length-1])&&(n[0]===6||n[0]===2)){r=0;continue}if(n[0]===3&&(!t||n[1]>t[0]&&n[1]<t[3])){r.label=n[1];break}if(n[0]===6&&r.label<t[1]){r.label=t[1];t=n;break}if(t&&r.label<t[2]){r.label=t[2];r.ops.push(n);break}if(t[2])r.ops.pop();r.trys.pop();continue}n=e.call(l,r)}catch(u){n=[6,u];i=0}finally{o=t=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(e){this.options=e}l.prototype.getUploadPath=function(e){return"/".concat(e,"?upload_url")};l.prototype.getDownloadPath=function(e){return"/".concat(e,"?download_url&expire=3600")};l.prototype.getBatchDeletePath=function(){return"/?delete"};l.prototype.getBatchDownloadPath=function(){return"/?download_url"};l.prototype.checkCloudPath=function(e){if(typeof e!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";e=e.trim();if(!e)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(e.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(e.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(e.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};l.prototype.checkFileID=function(e){if(typeof e!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";e=e.trim();if(!e)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};l.prototype.formatFileID=function(e){return"cloud://".concat(this.options.toEnvId,"/").concat(e.replace(/^\/+/,""))};l.prototype.getCloudPathFromFileID=function(e){var r=e.trim().replace(/^cloud:\/\//,"");var o=r.indexOf("/");if(o<=0){throw c.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=r.substring(0,o);var t=r.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(e," does not belong to env ").concat(this.options.toEnvId))}return t};l.prototype.getUploadFileURL=function(e){return p(this,void 0,void 0,function(){var r,o,i,t,s,a;return I(this,function(h){switch(h.label){case 0:r=typeof e==="string"?e:e.cloudPath;o=this.checkCloudPath(r);if(o){throw c.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(r.trim());return[4,this.request({method:"GET",path:i})];case 1:t=h.sent();s=D.handleResponse(t);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:t.requestID}]}})})};l.prototype.uploadFile=function(e){return p(this,void 0,void 0,function(){var r,o,i,t,s;return I(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(e)];case 1:r=a.sent(),o=r.fileID,i=r.uploadURL,t=r.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:e.fileContent})];case 2:s=a.sent();if(s.statusCode!==200){throw c.STORAGE_ERR(60004,"\u4E0A\u4F20\u6587\u4EF6 ".concat(i," \u5931\u8D25"),t)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};l.prototype.downloadFile=function(e){return p(this,void 0,void 0,function(){var r,o,i,t,s,a;return I(this,function(h){switch(h.label){case 0:r=this.checkFileID(e.fileID);if(r){throw c.INVALID_PARAM_ERR("fileID",r)}o=this.getCloudPathFromFileID(e.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:t=h.sent();s=D.handleResponse(t);return[4,this.options.fileUploader.download({fileID:e.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"),t.requestID)}return[2,a]}})})};l.prototype.deleteFile=function(e){return p(this,void 0,void 0,function(){var r,o,i,t,s,a,h,n,u,d;var g=this;return I(this,function(R){switch(R.label){case 0:r=Array.isArray(e)?e:e.fileList;if(!Array.isArray(r)||r.length===0){throw c.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,t=r;i<t.length;i++){s=t[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(e){return p(this,void 0,void 0,function(){var r,o,i,t,s,a,h,n,u,d;var g=this;return I(this,function(R){switch(R.label){case 0:r=Array.isArray(e)?e:e.fileList;if(!Array.isArray(r)||r.length===0){throw c.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(r.length>50){throw c.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,t=r;i<t.length;i++){s=t[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(e){var r=e.method,o=e.path,i=e.data,t=e.headers;return p(this,void 0,void 0,function(){return I(this,function(s){switch(s.label){case 0:return[4,this.options.httpclient.request({method:r,path:o,data:i,headers:w({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},t)})];case 1:return[2,s.sent()]}})})};return l}();export{y as Storage};
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};
@@ -1 +1 @@
1
- "use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(o){for(var r,n=1,u=arguments.length;n<u;n++){r=arguments[n];for(var a in r)if(Object.prototype.hasOwnProperty.call(r,a))o[a]=r[a]}return o};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(o,r,n,u){function a(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):a(c.value).then(s,l)}e((u=u.apply(o,r||[])).next())})};var __generator=this&&this.__generator||function(o,r){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},u,a,t,i;return i={next:s(0),"throw":s(1),"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,a&&(t=e[0]&2?a["return"]:e[0]?a["throw"]||((t=a["return"])&&t.call(a),0):a.next)&&!(t=t.call(a,e[1])).done)return t;if(a=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++;a=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=r.call(o,n)}catch(c){e=[6,c];a=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(r){this.httpclient=r}o.prototype.request=function(r){var n=r.method,u=r.path,a=r.data,t=r.headers;return __awaiter(this,void 0,void 0,function(){return __generator(this,function(i){switch(i.label){case 0:return[4,this.httpclient.request({method:n,path:u,data:a,headers:__assign({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},t)})];case 1:return[2,i.sent()]}})})};return o}();var Database=function(){function o(r){this.command=new faas_db_builder_1.Command;this.options=__assign(__assign({},r),{httpclient:new DatabaseHttpclient(r.httpclient)})}o.prototype.collection=function(r){if(!r){throw error_1.FaasError.INVALID_PARAM_ERR("collectionName","\u4E0D\u80FD\u4E3A\u7A7A")}return new Collection_1.Collection(r,this.options)};return o}();exports.Database=Database;
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;
package/lib/Storage.js CHANGED
@@ -1 +1 @@
1
- "use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(l){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i))l[i]=e[i]}return l};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(l,e,r,o){function i(t){return t instanceof r?t:new r(function(s){s(t)})}return new(r||(r=Promise))(function(t,s){function a(u){try{n(o.next(u))}catch(f){s(f)}}function h(u){try{n(o["throw"](u))}catch(f){s(f)}}function n(u){u.done?t(u.value):i(u.value).then(a,h)}n((o=o.apply(l,e||[])).next())})};var __generator=this&&this.__generator||function(l,e){var r={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},o,i,t,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]&&(r=0)),r)try{if(o=1,i&&(t=n[0]&2?i["return"]:n[0]?i["throw"]||((t=i["return"])&&t.call(i),0):i.next)&&!(t=t.call(i,n[1])).done)return t;if(i=0,t)n=[n[0]&2,t.value];switch(n[0]){case 0:case 1:t=n;break;case 4:r.label++;return{value:n[1],done:false};case 5:r.label++;i=n[1];n=[0];continue;case 7:n=r.ops.pop();r.trys.pop();continue;default:if(!(t=r.trys,t=t.length>0&&t[t.length-1])&&(n[0]===6||n[0]===2)){r=0;continue}if(n[0]===3&&(!t||n[1]>t[0]&&n[1]<t[3])){r.label=n[1];break}if(n[0]===6&&r.label<t[1]){r.label=t[1];t=n;break}if(t&&r.label<t[2]){r.label=t[2];r.ops.push(n);break}if(t[2])r.ops.pop();r.trys.pop();continue}n=e.call(l,r)}catch(u){n=[6,u];i=0}finally{o=t=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 l(e){this.options=e}l.prototype.getUploadPath=function(e){return"/".concat(e,"?upload_url")};l.prototype.getDownloadPath=function(e){return"/".concat(e,"?download_url&expire=3600")};l.prototype.getBatchDeletePath=function(){return"/?delete"};l.prototype.getBatchDownloadPath=function(){return"/?download_url"};l.prototype.checkCloudPath=function(e){if(typeof e!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";e=e.trim();if(!e)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32";if(e.startsWith("/"))return"\u4E0D\u80FD\u4EE5 / \u5F00\u5934";if(e.includes("//"))return"\u4E0D\u80FD\u5305\u542B\u8FDE\u7EED\u7684 /";if(e.length>850)return"\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 850 \u5B57\u8282"};l.prototype.checkFileID=function(e){if(typeof e!=="string")return"\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32";e=e.trim();if(!e)return"\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32"};l.prototype.formatFileID=function(e){return"cloud://".concat(this.options.toEnvId,"/").concat(e.replace(/^\/+/,""))};l.prototype.getCloudPathFromFileID=function(e){var r=e.trim().replace(/^cloud:\/\//,"");var o=r.indexOf("/");if(o<=0){throw error_1.FaasError.INVALID_PARAM_ERR("fileID","\u4E0D\u5408\u6CD5")}var i=r.substring(0,o);var t=r.substring(o+1);if(i!==this.options.toEnvId){console.warn("file ".concat(e," does not belong to env ").concat(this.options.toEnvId))}return t};l.prototype.getUploadFileURL=function(e){return __awaiter(this,void 0,void 0,function(){var r,o,i,t,s,a;return __generator(this,function(h){switch(h.label){case 0:r=typeof e==="string"?e:e.cloudPath;o=this.checkCloudPath(r);if(o){throw error_1.FaasError.INVALID_PARAM_ERR("cloudPath",o)}i=this.getUploadPath(r.trim());return[4,this.request({method:"GET",path:i})];case 1:t=h.sent();s=utils_1.ResponseUtil.handleResponse(t);a=this.formatFileID(s.file_id);return[2,{fileID:a,uploadURL:s.upload_url,requestID:t.requestID}]}})})};l.prototype.uploadFile=function(e){return __awaiter(this,void 0,void 0,function(){var r,o,i,t,s;return __generator(this,function(a){switch(a.label){case 0:return[4,this.getUploadFileURL(e)];case 1:r=a.sent(),o=r.fileID,i=r.uploadURL,t=r.requestID;return[4,this.options.fileUploader.upload({fileID:o,uploadURL:i,fileContent:e.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"),t)}return[2,{fileID:o,statusCode:s.statusCode}]}})})};l.prototype.downloadFile=function(e){return __awaiter(this,void 0,void 0,function(){var r,o,i,t,s,a;return __generator(this,function(h){switch(h.label){case 0:r=this.checkFileID(e.fileID);if(r){throw error_1.FaasError.INVALID_PARAM_ERR("fileID",r)}o=this.getCloudPathFromFileID(e.fileID);i=this.getDownloadPath(o);return[4,this.request({method:"GET",path:i})];case 1:t=h.sent();s=utils_1.ResponseUtil.handleResponse(t);return[4,this.options.fileUploader.download({fileID:e.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"),t.requestID)}return[2,a]}})})};l.prototype.deleteFile=function(e){return __awaiter(this,void 0,void 0,function(){var r,o,i,t,s,a,h,n,u,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:r=Array.isArray(e)?e:e.fileList;if(!Array.isArray(r)||r.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}o=[];for(i=0,t=r;i<t.length;i++){s=t[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:u=d.sent();f=utils_1.ResponseUtil.handleResponse(u);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}})}]}})})};l.prototype.getTempFileURL=function(e){return __awaiter(this,void 0,void 0,function(){var r,o,i,t,s,a,h,n,u,f;var p=this;return __generator(this,function(d){switch(d.label){case 0:r=Array.isArray(e)?e:e.fileList;if(!Array.isArray(r)||r.length===0){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(r.length>50){throw error_1.FaasError.INVALID_PARAM_ERR("fileList","\u6700\u5927\u957F\u5EA6 50")}o=[];for(i=0,t=r;i<t.length;i++){s=t[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:u=d.sent();f=utils_1.ResponseUtil.handleResponse(u);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}})}]}})})};l.prototype.request=function(e){var r=e.method,o=e.path,i=e.data,t=e.headers;return __awaiter(this,void 0,void 0,function(){return __generator(this,function(s){switch(s.label){case 0:return[4,this.options.httpclient.request({method:r,path:o,data:i,headers:__assign({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},t)})];case 1:return[2,s.sent()]}})})};return l}();exports.Storage=Storage;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/faas-common-sdk",
3
- "version": "1.1.19",
3
+ "version": "1.2.0-alpha.0",
4
4
  "description": "云函数服务通用 SDK",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -30,7 +30,7 @@
30
30
  "typescript": "^5.0.4"
31
31
  },
32
32
  "dependencies": {
33
- "@alipay/faas-db-builder": "^1.1.19"
33
+ "@alipay/faas-db-builder": "^1.2.0-alpha.0"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">= 14.0.0"