@xnestjs/storage 0.10.0 → 1.0.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.
- package/cjs/index.js +0 -1
- package/cjs/providers/s3-storage-connection.js +5 -4
- package/cjs/storage-core.module.js +39 -37
- package/cjs/storage.constants.js +2 -2
- package/cjs/storage.module.js +3 -1
- package/cjs/storage.utils.js +5 -17
- package/esm/index.js +0 -1
- package/esm/providers/s3-storage-connection.js +5 -4
- package/esm/storage-core.module.js +40 -38
- package/esm/storage.constants.js +1 -1
- package/esm/storage.module.js +3 -1
- package/esm/storage.utils.js +5 -16
- package/package.json +3 -4
- package/types/index.d.cts +0 -1
- package/types/index.d.ts +0 -1
- package/types/interfaces/storage.interfaces.d.ts +22 -19
- package/types/providers/s3-storage-connection.d.ts +4 -2
- package/types/services/storage-connection.d.ts +3 -0
- package/types/storage-core.module.d.ts +2 -5
- package/types/storage.constants.d.ts +1 -1
- package/types/storage.utils.d.ts +2 -3
- package/cjs/storage.decorators.js +0 -7
- package/esm/storage.decorators.js +0 -3
- package/types/storage.decorators.d.ts +0 -1
package/cjs/index.js
CHANGED
|
@@ -6,5 +6,4 @@ tslib_1.__exportStar(require("./interfaces/storage.interfaces.js"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./services/storage-bucket.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./services/storage-connection.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./storage.constants.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./storage.decorators.js"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./storage.module.js"), exports);
|
|
@@ -5,11 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const Minio = tslib_1.__importStar(require("minio"));
|
|
6
6
|
const storage_connection_js_1 = require("../services/storage-connection.js");
|
|
7
7
|
class S3StorageConnection extends storage_connection_js_1.StorageConnection {
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(config) {
|
|
9
9
|
super();
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
this._client
|
|
10
|
+
this.provider = 's3';
|
|
11
|
+
this.config = config;
|
|
12
|
+
this._client = new Minio.Client(config);
|
|
13
|
+
this._client.setRequestOptions({ rejectUnauthorized: config.rejectUnauthorized });
|
|
13
14
|
}
|
|
14
15
|
async putObject(bucketName, objectName, source, options) {
|
|
15
16
|
const meta = options ? updateMetadata(options?.metadata, options) : {};
|
|
@@ -4,61 +4,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.StorageCoreModule = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
|
+
const storage_connection_js_1 = require("./services/storage-connection.js");
|
|
8
|
+
const storage_constants_js_1 = require("./storage.constants.js");
|
|
7
9
|
const storage_utils_js_1 = require("./storage.utils.js");
|
|
8
10
|
let StorageCoreModule = StorageCoreModule_1 = class StorageCoreModule {
|
|
9
11
|
static register(options) {
|
|
10
12
|
const connectionProvider = {
|
|
11
|
-
provide:
|
|
13
|
+
provide: options.token || storage_connection_js_1.StorageConnection,
|
|
12
14
|
useValue: (0, storage_utils_js_1.createConnection)(options),
|
|
13
15
|
};
|
|
14
16
|
return {
|
|
15
17
|
module: StorageCoreModule_1,
|
|
16
18
|
providers: [connectionProvider],
|
|
17
19
|
exports: [connectionProvider],
|
|
20
|
+
global: options.global,
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
|
-
static
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
module: StorageCoreModule_1,
|
|
24
|
-
imports: asyncOptions.imports || [],
|
|
25
|
-
providers,
|
|
26
|
-
exports: providers,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
static createAsyncProviders(asyncOptions) {
|
|
30
|
-
if (asyncOptions.useFactory || asyncOptions.useExisting)
|
|
31
|
-
return [this.createAsyncOptionsProvider(asyncOptions)];
|
|
32
|
-
if (asyncOptions.useClass) {
|
|
33
|
-
return [
|
|
34
|
-
this.createAsyncOptionsProvider(asyncOptions),
|
|
35
|
-
{ provide: asyncOptions.useClass, useClass: asyncOptions.useClass },
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
39
|
-
}
|
|
40
|
-
static createAsyncOptionsProvider(asyncOptions) {
|
|
23
|
+
static registerAsync(asyncOptions) {
|
|
24
|
+
let optionsProvider;
|
|
41
25
|
if (asyncOptions.useFactory) {
|
|
42
|
-
|
|
43
|
-
provide:
|
|
44
|
-
useFactory: this.createFactoryWrapper(asyncOptions.useFactory),
|
|
26
|
+
optionsProvider = {
|
|
27
|
+
provide: storage_constants_js_1.STORAGE_OPTIONS,
|
|
45
28
|
inject: asyncOptions.inject || [],
|
|
29
|
+
useFactory: asyncOptions.useFactory,
|
|
46
30
|
};
|
|
47
31
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
useFactory: this.createFactoryWrapper((optionsFactory) => optionsFactory.getOptions()),
|
|
53
|
-
inject: [useClass],
|
|
32
|
+
else if (asyncOptions.useExisting) {
|
|
33
|
+
optionsProvider = {
|
|
34
|
+
provide: storage_constants_js_1.STORAGE_OPTIONS,
|
|
35
|
+
useExisting: asyncOptions.useExisting,
|
|
54
36
|
};
|
|
55
37
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
38
|
+
else if (asyncOptions.useClass) {
|
|
39
|
+
optionsProvider = {
|
|
40
|
+
provide: storage_constants_js_1.STORAGE_OPTIONS,
|
|
41
|
+
useClass: asyncOptions.useClass,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
46
|
+
}
|
|
47
|
+
const storageToken = asyncOptions.token || storage_connection_js_1.StorageConnection;
|
|
48
|
+
const providers = [
|
|
49
|
+
optionsProvider,
|
|
50
|
+
{
|
|
51
|
+
provide: storageToken,
|
|
52
|
+
inject: [storage_constants_js_1.STORAGE_OPTIONS],
|
|
53
|
+
useFactory: (options) => (0, storage_utils_js_1.createConnection)(options),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
if (asyncOptions.providers)
|
|
57
|
+
providers.push(...asyncOptions.providers);
|
|
58
|
+
return {
|
|
59
|
+
module: StorageCoreModule_1,
|
|
60
|
+
imports: asyncOptions.imports || [],
|
|
61
|
+
exports: [storageToken, ...(asyncOptions.exports || [])],
|
|
62
|
+
providers,
|
|
63
|
+
global: asyncOptions.global,
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
};
|
package/cjs/storage.constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.STORAGE_OPTIONS = void 0;
|
|
4
|
+
exports.STORAGE_OPTIONS = Symbol('STORAGE_OPTIONS');
|
package/cjs/storage.module.js
CHANGED
|
@@ -10,12 +10,14 @@ let StorageModule = StorageModule_1 = class StorageModule {
|
|
|
10
10
|
return {
|
|
11
11
|
module: StorageModule_1,
|
|
12
12
|
imports: [storage_core_module_js_1.StorageCoreModule.register(options)],
|
|
13
|
+
global: options.global,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
static registerAsync(options) {
|
|
16
17
|
return {
|
|
17
18
|
module: StorageModule_1,
|
|
18
|
-
imports: [storage_core_module_js_1.StorageCoreModule.
|
|
19
|
+
imports: [storage_core_module_js_1.StorageCoreModule.registerAsync(options)],
|
|
20
|
+
global: options.global,
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
};
|
package/cjs/storage.utils.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStorageConnectionToken = getStorageConnectionToken;
|
|
4
3
|
exports.createConnection = createConnection;
|
|
5
4
|
const s3_storage_connection_js_1 = require("./providers/s3-storage-connection.js");
|
|
6
|
-
const storage_connection_js_1 = require("./services/storage-connection.js");
|
|
7
|
-
function getStorageConnectionToken(name) {
|
|
8
|
-
if (!name)
|
|
9
|
-
return storage_connection_js_1.StorageConnection;
|
|
10
|
-
// noinspection SuspiciousTypeOfGuard
|
|
11
|
-
if (typeof name === 'symbol' || typeof name === 'function')
|
|
12
|
-
return name;
|
|
13
|
-
return `${name}_StorageConnection`;
|
|
14
|
-
}
|
|
15
5
|
function createConnection(options) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return new s3_storage_connection_js_1.S3StorageConnection(options.config);
|
|
21
|
-
default:
|
|
22
|
-
throw new Error(`Unknown Storage provider type ${options.type}`);
|
|
6
|
+
if (options.provider === 's3') {
|
|
7
|
+
if (!options.s3)
|
|
8
|
+
throw new Error('You must provide S3 config');
|
|
9
|
+
return new s3_storage_connection_js_1.S3StorageConnection(options.s3);
|
|
23
10
|
}
|
|
11
|
+
throw new Error(`Unknown Storage provider (${options.provider})`);
|
|
24
12
|
}
|
package/esm/index.js
CHANGED
|
@@ -3,5 +3,4 @@ export * from './interfaces/storage.interfaces.js';
|
|
|
3
3
|
export * from './services/storage-bucket.js';
|
|
4
4
|
export * from './services/storage-connection.js';
|
|
5
5
|
export * from './storage.constants.js';
|
|
6
|
-
export * from './storage.decorators.js';
|
|
7
6
|
export * from './storage.module.js';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as Minio from 'minio';
|
|
2
2
|
import { StorageConnection } from '../services/storage-connection.js';
|
|
3
3
|
export class S3StorageConnection extends StorageConnection {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(config) {
|
|
5
5
|
super();
|
|
6
|
-
this.
|
|
7
|
-
|
|
8
|
-
this._client
|
|
6
|
+
this.provider = 's3';
|
|
7
|
+
this.config = config;
|
|
8
|
+
this._client = new Minio.Client(config);
|
|
9
|
+
this._client.setRequestOptions({ rejectUnauthorized: config.rejectUnauthorized });
|
|
9
10
|
}
|
|
10
11
|
async putObject(bucketName, objectName, source, options) {
|
|
11
12
|
const meta = options ? updateMetadata(options?.metadata, options) : {};
|
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
var StorageCoreModule_1;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
3
|
import { Global, Module } from '@nestjs/common';
|
|
4
|
-
import {
|
|
4
|
+
import { StorageConnection } from './services/storage-connection.js';
|
|
5
|
+
import { STORAGE_OPTIONS } from './storage.constants.js';
|
|
6
|
+
import { createConnection } from './storage.utils.js';
|
|
5
7
|
let StorageCoreModule = StorageCoreModule_1 = class StorageCoreModule {
|
|
6
8
|
static register(options) {
|
|
7
9
|
const connectionProvider = {
|
|
8
|
-
provide:
|
|
10
|
+
provide: options.token || StorageConnection,
|
|
9
11
|
useValue: createConnection(options),
|
|
10
12
|
};
|
|
11
13
|
return {
|
|
12
14
|
module: StorageCoreModule_1,
|
|
13
15
|
providers: [connectionProvider],
|
|
14
16
|
exports: [connectionProvider],
|
|
17
|
+
global: options.global,
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
module: StorageCoreModule_1,
|
|
21
|
-
imports: asyncOptions.imports || [],
|
|
22
|
-
providers,
|
|
23
|
-
exports: providers,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
static createAsyncProviders(asyncOptions) {
|
|
27
|
-
if (asyncOptions.useFactory || asyncOptions.useExisting)
|
|
28
|
-
return [this.createAsyncOptionsProvider(asyncOptions)];
|
|
29
|
-
if (asyncOptions.useClass) {
|
|
30
|
-
return [
|
|
31
|
-
this.createAsyncOptionsProvider(asyncOptions),
|
|
32
|
-
{ provide: asyncOptions.useClass, useClass: asyncOptions.useClass },
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
36
|
-
}
|
|
37
|
-
static createAsyncOptionsProvider(asyncOptions) {
|
|
20
|
+
static registerAsync(asyncOptions) {
|
|
21
|
+
let optionsProvider;
|
|
38
22
|
if (asyncOptions.useFactory) {
|
|
39
|
-
|
|
40
|
-
provide:
|
|
41
|
-
useFactory: this.createFactoryWrapper(asyncOptions.useFactory),
|
|
23
|
+
optionsProvider = {
|
|
24
|
+
provide: STORAGE_OPTIONS,
|
|
42
25
|
inject: asyncOptions.inject || [],
|
|
26
|
+
useFactory: asyncOptions.useFactory,
|
|
43
27
|
};
|
|
44
28
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
useFactory: this.createFactoryWrapper((optionsFactory) => optionsFactory.getOptions()),
|
|
50
|
-
inject: [useClass],
|
|
29
|
+
else if (asyncOptions.useExisting) {
|
|
30
|
+
optionsProvider = {
|
|
31
|
+
provide: STORAGE_OPTIONS,
|
|
32
|
+
useExisting: asyncOptions.useExisting,
|
|
51
33
|
};
|
|
52
34
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
else if (asyncOptions.useClass) {
|
|
36
|
+
optionsProvider = {
|
|
37
|
+
provide: STORAGE_OPTIONS,
|
|
38
|
+
useClass: asyncOptions.useClass,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
43
|
+
}
|
|
44
|
+
const storageToken = asyncOptions.token || StorageConnection;
|
|
45
|
+
const providers = [
|
|
46
|
+
optionsProvider,
|
|
47
|
+
{
|
|
48
|
+
provide: storageToken,
|
|
49
|
+
inject: [STORAGE_OPTIONS],
|
|
50
|
+
useFactory: (options) => createConnection(options),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
if (asyncOptions.providers)
|
|
54
|
+
providers.push(...asyncOptions.providers);
|
|
55
|
+
return {
|
|
56
|
+
module: StorageCoreModule_1,
|
|
57
|
+
imports: asyncOptions.imports || [],
|
|
58
|
+
exports: [storageToken, ...(asyncOptions.exports || [])],
|
|
59
|
+
providers,
|
|
60
|
+
global: asyncOptions.global,
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
};
|
package/esm/storage.constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const STORAGE_OPTIONS = Symbol('STORAGE_OPTIONS');
|
package/esm/storage.module.js
CHANGED
|
@@ -7,12 +7,14 @@ let StorageModule = StorageModule_1 = class StorageModule {
|
|
|
7
7
|
return {
|
|
8
8
|
module: StorageModule_1,
|
|
9
9
|
imports: [StorageCoreModule.register(options)],
|
|
10
|
+
global: options.global,
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
static registerAsync(options) {
|
|
13
14
|
return {
|
|
14
15
|
module: StorageModule_1,
|
|
15
|
-
imports: [StorageCoreModule.
|
|
16
|
+
imports: [StorageCoreModule.registerAsync(options)],
|
|
17
|
+
global: options.global,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
};
|
package/esm/storage.utils.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import { S3StorageConnection } from './providers/s3-storage-connection.js';
|
|
2
|
-
import { StorageConnection } from './services/storage-connection.js';
|
|
3
|
-
export function getStorageConnectionToken(name) {
|
|
4
|
-
if (!name)
|
|
5
|
-
return StorageConnection;
|
|
6
|
-
// noinspection SuspiciousTypeOfGuard
|
|
7
|
-
if (typeof name === 'symbol' || typeof name === 'function')
|
|
8
|
-
return name;
|
|
9
|
-
return `${name}_StorageConnection`;
|
|
10
|
-
}
|
|
11
2
|
export function createConnection(options) {
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return new S3StorageConnection(options.config);
|
|
17
|
-
default:
|
|
18
|
-
throw new Error(`Unknown Storage provider type ${options.type}`);
|
|
3
|
+
if (options.provider === 's3') {
|
|
4
|
+
if (!options.s3)
|
|
5
|
+
throw new Error('You must provide S3 config');
|
|
6
|
+
return new S3StorageConnection(options.s3);
|
|
19
7
|
}
|
|
8
|
+
throw new Error(`Unknown Storage provider (${options.provider})`);
|
|
20
9
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "NestJS extension library for Storage solutions (S3,GS)",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@nestjs/common": "^10.4.
|
|
8
|
+
"@nestjs/common": "^10.4.7"
|
|
9
9
|
},
|
|
10
10
|
"optionalDependencies": {
|
|
11
|
-
"minio": "^8.0.
|
|
11
|
+
"minio": "^8.0.2"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"npm": ">=7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
|
-
"bin/",
|
|
41
40
|
"cjs/",
|
|
42
41
|
"esm/",
|
|
43
42
|
"types/",
|
package/types/index.d.cts
CHANGED
|
@@ -3,5 +3,4 @@ export * from './interfaces/storage.interfaces.js';
|
|
|
3
3
|
export * from './services/storage-bucket.js';
|
|
4
4
|
export * from './services/storage-connection.js';
|
|
5
5
|
export * from './storage.constants.js';
|
|
6
|
-
export * from './storage.decorators.js';
|
|
7
6
|
export * from './storage.module.js';
|
package/types/index.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export * from './interfaces/storage.interfaces.js';
|
|
|
3
3
|
export * from './services/storage-bucket.js';
|
|
4
4
|
export * from './services/storage-connection.js';
|
|
5
5
|
export * from './storage.constants.js';
|
|
6
|
-
export * from './storage.decorators.js';
|
|
7
6
|
export * from './storage.module.js';
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
|
3
|
-
import * as minio from 'minio';
|
|
4
|
-
export type
|
|
5
|
-
rejectUnauthorized
|
|
1
|
+
import type { InjectionToken } from '@nestjs/common';
|
|
2
|
+
import type { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
|
3
|
+
import type * as minio from 'minio';
|
|
4
|
+
export type S3Config = minio.ClientOptions & {
|
|
5
|
+
rejectUnauthorized?: boolean;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export type StorageProvider = 's3' | 'gs';
|
|
8
|
+
export interface S3StorageOptions {
|
|
9
|
+
provider: StorageProvider;
|
|
10
|
+
s3: S3Config;
|
|
11
11
|
}
|
|
12
|
+
export interface GSStorageOptions {
|
|
13
|
+
provider: StorageProvider;
|
|
14
|
+
gs: {};
|
|
15
|
+
}
|
|
16
|
+
export type StorageOptions = S3StorageOptions | GSStorageOptions;
|
|
12
17
|
export type StorageModuleOptions = StorageOptions & {
|
|
13
|
-
|
|
18
|
+
token?: InjectionToken;
|
|
19
|
+
global?: boolean;
|
|
14
20
|
};
|
|
15
|
-
export interface
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export interface StorageModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
19
|
-
name?: string;
|
|
21
|
+
export interface StorageModuleAsyncOptions extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
|
|
22
|
+
token?: InjectionToken;
|
|
20
23
|
inject?: any[];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
global?: boolean;
|
|
25
|
+
useClass?: Type<StorageOptions>;
|
|
26
|
+
useExisting?: InjectionToken;
|
|
27
|
+
useFactory?: (...args: any[]) => Promise<StorageOptions> | StorageOptions;
|
|
25
28
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { GetObjectSignedUrlOptions, ObjectInfo, PutObjectOptions } from '../interfaces/connection.interfaces.js';
|
|
4
|
-
import {
|
|
4
|
+
import { S3Config } from '../interfaces/storage.interfaces.js';
|
|
5
5
|
import { StorageConnection } from '../services/storage-connection.js';
|
|
6
6
|
export declare class S3StorageConnection extends StorageConnection {
|
|
7
|
+
readonly provider = "s3";
|
|
8
|
+
readonly config: S3Config;
|
|
7
9
|
private _client;
|
|
8
|
-
constructor(
|
|
10
|
+
constructor(config: S3Config);
|
|
9
11
|
putObject(bucketName: string, objectName: string, source: Buffer | Readable | string, options?: PutObjectOptions): Promise<void>;
|
|
10
12
|
getObjectInfo(bucketName: string, objectName: string): Promise<ObjectInfo>;
|
|
11
13
|
removeObject(bucketName: string, objectName: string): Promise<void>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Buffer } from 'buffer';
|
|
2
2
|
import type { Readable } from 'stream';
|
|
3
3
|
import type { GetObjectSignedUrlOptions, ObjectInfo, PutObjectOptions } from '../interfaces/connection.interfaces.js';
|
|
4
|
+
import type { StorageProvider } from '../interfaces/storage.interfaces.js';
|
|
4
5
|
import { StorageBucket } from './storage-bucket.js';
|
|
5
6
|
export declare abstract class StorageConnection {
|
|
7
|
+
abstract readonly provider: StorageProvider;
|
|
8
|
+
abstract readonly config: any;
|
|
6
9
|
getBucket(bucketName: string): StorageBucket;
|
|
7
10
|
abstract putObject(bucketName: string, objectName: string, buffer: Buffer, options?: PutObjectOptions): Promise<void>;
|
|
8
11
|
abstract putObject(bucketName: string, objectName: string, stream: Readable, options?: PutObjectOptions): Promise<void>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { DynamicModule
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { StorageModuleAsyncOptions, StorageModuleOptions } from './interfaces/storage.interfaces.js';
|
|
3
3
|
export declare class StorageCoreModule {
|
|
4
4
|
static register(options: StorageModuleOptions): DynamicModule;
|
|
5
|
-
static
|
|
6
|
-
static createAsyncProviders(asyncOptions: StorageModuleAsyncOptions): Provider[];
|
|
7
|
-
static createAsyncOptionsProvider(asyncOptions: StorageModuleAsyncOptions): Provider;
|
|
8
|
-
private static createFactoryWrapper;
|
|
5
|
+
static registerAsync(asyncOptions: StorageModuleAsyncOptions): DynamicModule;
|
|
9
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const STORAGE_OPTIONS: unique symbol;
|
package/types/storage.utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageOptions } from './interfaces/storage.interfaces.js';
|
|
2
2
|
import { StorageConnection } from './services/storage-connection.js';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function createConnection(options: StorageModuleOptions): StorageConnection;
|
|
3
|
+
export declare function createConnection(options: StorageOptions): StorageConnection;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectStorage = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const storage_utils_js_1 = require("./storage.utils.js");
|
|
6
|
-
const InjectStorage = (connection) => (0, common_1.Inject)((0, storage_utils_js_1.getStorageConnectionToken)(connection));
|
|
7
|
-
exports.InjectStorage = InjectStorage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const InjectStorage: (connection?: string) => ParameterDecorator;
|