@idm-plugin/aliclient2 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ try {
10
10
  } catch {
11
11
  } finally {
12
12
  }
13
- class I {
13
+ class A {
14
14
  /**
15
15
  * 创建阿里云OSS客户端
16
16
  * @param region enum [tk, hz]
@@ -39,7 +39,7 @@ class I {
39
39
  bucket: "idm-hz",
40
40
  internal: r,
41
41
  cname: !0,
42
- endpoint: "https://osshz.idmwx.com"
42
+ endpoint: "https://ossimg.ormwx.com"
43
43
  });
44
44
  }
45
45
  async putObjects(c, i, e = {}) {
@@ -47,7 +47,7 @@ class I {
47
47
  var n, l;
48
48
  let a = `${c}/${t.name}`.replaceAll(/\/\//g, "/");
49
49
  a = a.startsWith("/") ? a.substring(1) : a;
50
- const u = this.region === "tk" ? `https://oss.idmwx.com/${a}` : `https://osshz.idmwx.com/${a}`, h = this.region === "tk" ? `https://img.idmwx.com/${a}` : `https://osshz.idmwx.com/${a}`, d = e.headers || {};
50
+ const u = this.region === "tk" ? `https://oss.idmwx.com/${a}` : `https://ossimg.ormwx.com/${a}`, h = this.region === "tk" ? `https://img.idmwx.com/${a}` : `https://ossimg.ormwx.com/${a}`, d = e.headers || {};
51
51
  return t.stream instanceof y ? await ((n = this.client) == null ? void 0 : n.putStream(a, t.stream)) : await ((l = this.client) == null ? void 0 : l.put(a, t.stream, { headers: d })), { url: u, name: t.name, aliSign: !0, external: h };
52
52
  });
53
53
  return await Promise.all(r).then((t) => (s.info("[%s] upload to oss success, url: %j", e.requestId, t), t)).catch((t) => (s.error("[%s] upload to oss failed: %j-%s", e.requestId, t), []));
@@ -116,5 +116,5 @@ class I {
116
116
  }
117
117
  }
118
118
  export {
119
- I as AliOssClient
119
+ A as AliOssClient
120
120
  };
@@ -1 +1 @@
1
- (function(r,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@log4js-node/log4js-api"),require("ali-oss"),require("fs")):typeof define=="function"&&define.amd?define(["exports","@log4js-node/log4js-api","ali-oss","fs"],c):(r=typeof globalThis<"u"?globalThis:r||self,c(r["idm-plugin-aliclient"]={},r["@log4js-node/log4js-api"],r.OSS,r.fs))})(this,function(r,c,d,b){"use strict";var q=Object.defineProperty;var $=(r,c,d)=>c in r?q(r,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[c]=d;var j=(r,c,d)=>($(r,typeof c!="symbol"?c+"":c,d),d);let s;try{s=c.getLogger("ali-client")}catch{}finally{}class w{constructor(u,l,t,i,e=!0){j(this,"client");j(this,"region");this.region=u,u==="tk"?this.client=new d({secure:!0,region:"oss-ap-northeast-1",accessKeyId:l,accessKeySecret:t,bucket:"idm-wx",internal:i,cname:e,endpoint:e?"https://img.idmwx.com":void 0}):this.client=new d({secure:!0,region:"oss-cn-hangzhou",accessKeyId:l,accessKeySecret:t,bucket:"idm-hz",internal:i,cname:!0,endpoint:"https://osshz.idmwx.com"})}async putObjects(u,l,t={}){const i=l.map(async e=>{var n,o;let a=`${u}/${e.name}`.replaceAll(/\/\//g,"/");a=a.startsWith("/")?a.substring(1):a;const h=this.region==="tk"?`https://oss.idmwx.com/${a}`:`https://osshz.idmwx.com/${a}`,f=this.region==="tk"?`https://img.idmwx.com/${a}`:`https://osshz.idmwx.com/${a}`,m=t.headers||{};return e.stream instanceof b.ReadStream?await((n=this.client)==null?void 0:n.putStream(a,e.stream)):await((o=this.client)==null?void 0:o.put(a,e.stream,{headers:m})),{url:h,name:e.name,aliSign:!0,external:f}});return await Promise.all(i).then(e=>(s.info("[%s] upload to oss success, url: %j",t.requestId,e),e)).catch(e=>(s.error("[%s] upload to oss failed: %j-%s",t.requestId,e),[]))}async deleteObject(u,l={}){var i;let t=`${u}`.replaceAll(/\/\//g,"/");t=t.startsWith("/")?t.substring(1):t;try{const e=await((i=this.client)==null?void 0:i.delete(t));return s==null||s.info("[%s] delete oss object success: %s",l.requestId,t),e}catch(e){return s==null||s.error("[%s] delete oss object failed: %s - %j",l.requestId,t,e),null}}async deleteObjects(u,l,t={}){var f,m;let i=`${u}`.replaceAll(/\/\//g,"/");i=i.startsWith("/")?i.substring(1):i,i&&!i.endsWith("/")&&(i+="/");let e=[];if(Array.isArray(l)&&l.length>0)e=l.map(n=>`${i}${n}`.replaceAll(/\/\//g,"/").replace(/^\//,""));else{let n;try{do{const o=await((f=this.client)==null?void 0:f.list({prefix:i,marker:n,"max-keys":1e3})),p=(o==null?void 0:o.objects)||[];e.push(...p.map(x=>x.name)),n=o==null?void 0:o.nextMarker}while(n)}catch(o){return s==null||s.error("[%s] list oss objects failed: %s - %j",t.requestId,i,o),[]}}if(e.length===0)return s==null||s.info("[%s] no objects to delete for prefix: %s",t.requestId,i),[];const a=1e3,h=[];try{for(let n=0;n<e.length;n+=a){const o=e.slice(n,n+a),p=await((m=this.client)==null?void 0:m.deleteMulti(o,{quiet:!0}));h.push(p)}return s==null||s.info("[%s] delete oss objects success, count: %d",t.requestId,e.length),h}catch(n){return s==null||s.error("[%s] delete oss objects failed: %s - %j",t.requestId,i,n),[]}}async signature(u,l=60){var t;return(t=this.client)==null?void 0:t.signatureUrl(u,{expires:l})}}r.AliOssClient=w,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
1
+ (function(r,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@log4js-node/log4js-api"),require("ali-oss"),require("fs")):typeof define=="function"&&define.amd?define(["exports","@log4js-node/log4js-api","ali-oss","fs"],c):(r=typeof globalThis<"u"?globalThis:r||self,c(r["idm-plugin-aliclient"]={},r["@log4js-node/log4js-api"],r.OSS,r.fs))})(this,function(r,c,d,b){"use strict";var g=Object.defineProperty;var q=(r,c,d)=>c in r?g(r,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[c]=d;var j=(r,c,d)=>(q(r,typeof c!="symbol"?c+"":c,d),d);let s;try{s=c.getLogger("ali-client")}catch{}finally{}class w{constructor(u,l,t,i,e=!0){j(this,"client");j(this,"region");this.region=u,u==="tk"?this.client=new d({secure:!0,region:"oss-ap-northeast-1",accessKeyId:l,accessKeySecret:t,bucket:"idm-wx",internal:i,cname:e,endpoint:e?"https://img.idmwx.com":void 0}):this.client=new d({secure:!0,region:"oss-cn-hangzhou",accessKeyId:l,accessKeySecret:t,bucket:"idm-hz",internal:i,cname:!0,endpoint:"https://ossimg.ormwx.com"})}async putObjects(u,l,t={}){const i=l.map(async e=>{var n,a;let o=`${u}/${e.name}`.replaceAll(/\/\//g,"/");o=o.startsWith("/")?o.substring(1):o;const h=this.region==="tk"?`https://oss.idmwx.com/${o}`:`https://ossimg.ormwx.com/${o}`,f=this.region==="tk"?`https://img.idmwx.com/${o}`:`https://ossimg.ormwx.com/${o}`,m=t.headers||{};return e.stream instanceof b.ReadStream?await((n=this.client)==null?void 0:n.putStream(o,e.stream)):await((a=this.client)==null?void 0:a.put(o,e.stream,{headers:m})),{url:h,name:e.name,aliSign:!0,external:f}});return await Promise.all(i).then(e=>(s.info("[%s] upload to oss success, url: %j",t.requestId,e),e)).catch(e=>(s.error("[%s] upload to oss failed: %j-%s",t.requestId,e),[]))}async deleteObject(u,l={}){var i;let t=`${u}`.replaceAll(/\/\//g,"/");t=t.startsWith("/")?t.substring(1):t;try{const e=await((i=this.client)==null?void 0:i.delete(t));return s==null||s.info("[%s] delete oss object success: %s",l.requestId,t),e}catch(e){return s==null||s.error("[%s] delete oss object failed: %s - %j",l.requestId,t,e),null}}async deleteObjects(u,l,t={}){var f,m;let i=`${u}`.replaceAll(/\/\//g,"/");i=i.startsWith("/")?i.substring(1):i,i&&!i.endsWith("/")&&(i+="/");let e=[];if(Array.isArray(l)&&l.length>0)e=l.map(n=>`${i}${n}`.replaceAll(/\/\//g,"/").replace(/^\//,""));else{let n;try{do{const a=await((f=this.client)==null?void 0:f.list({prefix:i,marker:n,"max-keys":1e3})),p=(a==null?void 0:a.objects)||[];e.push(...p.map(x=>x.name)),n=a==null?void 0:a.nextMarker}while(n)}catch(a){return s==null||s.error("[%s] list oss objects failed: %s - %j",t.requestId,i,a),[]}}if(e.length===0)return s==null||s.info("[%s] no objects to delete for prefix: %s",t.requestId,i),[];const o=1e3,h=[];try{for(let n=0;n<e.length;n+=o){const a=e.slice(n,n+o),p=await((m=this.client)==null?void 0:m.deleteMulti(a,{quiet:!0}));h.push(p)}return s==null||s.info("[%s] delete oss objects success, count: %d",t.requestId,e.length),h}catch(n){return s==null||s.error("[%s] delete oss objects failed: %s - %j",t.requestId,i,n),[]}}async signature(u,l=60){var t;return(t=this.client)==null?void 0:t.signatureUrl(u,{expires:l})}}r.AliOssClient=w,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idm-plugin/aliclient2",
3
3
  "private": false,
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "description": "idm plugin for ali used in backend",
6
6
  "type": "module",
7
7
  "keywords": [
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "main": "./dist/index.umd.cjs",
20
20
  "module": "./dist/index.js",
21
- "types": "index.d.ts",
21
+ "types": "./dist/index.d.ts",
22
22
  "scripts": {
23
23
  "dev": "vite --config ./build/base.config.ts",
24
24
  "build": "vite build --config ./build/lib.config.ts",