@midwayjs/oss 3.3.1 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { OSSConfiguration as Configuration } from './configuration';
2
2
  export * from './manager';
3
+ export * from './interface';
3
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -18,4 +18,5 @@ exports.Configuration = void 0;
18
18
  var configuration_1 = require("./configuration");
19
19
  Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.OSSConfiguration; } });
20
20
  __exportStar(require("./manager"), exports);
21
+ __exportStar(require("./interface"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ import * as OSS from 'ali-oss';
2
+ export declare type Without<T, U> = {
3
+ [P in Exclude<keyof T, keyof U>]?: never;
4
+ };
5
+ export declare type XOR<T, U> = (Without<T, U> & U) | (Without<U, T> & T);
6
+ export interface MWOSSOptions extends OSS.Options {
7
+ }
8
+ export interface MWOSSClusterOptions extends OSS.ClusterOptions {
9
+ clusters: (OSS.ClusterType & {
10
+ endpoint: string;
11
+ })[];
12
+ timeout?: string;
13
+ }
14
+ export interface MWOSSSTSOptions extends OSS.STSOptions {
15
+ sts: boolean;
16
+ }
17
+ export declare type OSSServiceFactoryReturnType = XOR<XOR<OSS, OSS.STS>, OSS.ClusterClient>;
18
+ export declare type OSSServiceFactoryCreateClientConfigType = XOR<XOR<MWOSSOptions, MWOSSClusterOptions>, MWOSSSTSOptions>;
19
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interface.js.map
package/dist/manager.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as OSS from 'ali-oss';
2
2
  import { ServiceFactory } from '@midwayjs/core';
3
- export declare class OSSServiceFactory<T = OSS> extends ServiceFactory<T> {
4
- ossConfig: any;
3
+ import type { OSSServiceFactoryReturnType, OSSServiceFactoryCreateClientConfigType } from './interface';
4
+ export declare class OSSServiceFactory<T extends OSSServiceFactoryReturnType = OSSServiceFactoryReturnType> extends ServiceFactory<T> {
5
+ ossConfig: OSSServiceFactoryCreateClientConfigType;
5
6
  init(): Promise<void>;
6
- createClient(config: any): Promise<T>;
7
+ createClient(config: OSSServiceFactoryCreateClientConfigType): Promise<T>;
7
8
  getName(): string;
8
9
  }
9
10
  export declare class OSSService implements OSS {
package/dist/manager.js CHANGED
@@ -23,14 +23,20 @@ let OSSServiceFactory = class OSSServiceFactory extends core_1.ServiceFactory {
23
23
  await this.initClients(this.ossConfig);
24
24
  }
25
25
  async createClient(config) {
26
- if (config.cluster) {
27
- config.cluster.forEach(checkBucketConfig);
26
+ if (config['cluster'] && !config.clusters) {
27
+ config.clusters = config['cluster'];
28
+ }
29
+ if (config.clusters) {
30
+ config.clusters.forEach(checkBucketConfig);
31
+ // @ts-expect-error because this code can return the correct type, but TS still reports an error
28
32
  return new OSS.ClusterClient(config);
29
33
  }
30
34
  if (config.sts === true) {
35
+ // @ts-expect-error because this code can return the correct type, but TS still reports an error
31
36
  return new OSS.STS(config);
32
37
  }
33
38
  checkBucketConfig(config);
39
+ // @ts-expect-error because this code can return the correct type, but TS still reports an error
34
40
  return new OSS(config);
35
41
  }
36
42
  getName() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/oss",
3
3
  "description": "midway oss component",
4
- "version": "3.3.1",
4
+ "version": "3.3.5",
5
5
  "main": "dist/index",
6
6
  "typings": "index.d.ts",
7
7
  "files": [
@@ -10,9 +10,9 @@
10
10
  "index.d.ts"
11
11
  ],
12
12
  "devDependencies": {
13
- "@midwayjs/core": "^3.3.1",
14
- "@midwayjs/decorator": "^3.1.6",
15
- "@midwayjs/mock": "^3.3.1",
13
+ "@midwayjs/core": "^3.3.5",
14
+ "@midwayjs/decorator": "^3.3.4",
15
+ "@midwayjs/mock": "^3.3.5",
16
16
  "@types/ali-oss": "6.16.3",
17
17
  "dotenv": "16.0.0"
18
18
  },
@@ -39,5 +39,5 @@
39
39
  "type": "git",
40
40
  "url": "https://github.com/midwayjs/midway.git"
41
41
  },
42
- "gitHead": "f603b622b205ec126de628eeab59f90045a75dd2"
42
+ "gitHead": "5a835008aaa26e1b3c7d99c525f4a9fdaa3e41d1"
43
43
  }