@digipair/skill-s3 0.91.0-0 → 0.91.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/index.cjs.d.ts +1 -0
- package/index.cjs.js +72 -0
- package/index.esm.js +65 -0
- package/libs/skill-s3/src/lib/skill-s3.d.ts +5 -0
- package/package.json +8 -22
- package/.swcrc +0 -28
- package/README.md +0 -7
- package/eslint.config.mjs +0 -22
- package/rollup.config.cjs +0 -28
- package/src/lib/skill-s3.spec.ts +0 -7
- package/src/lib/skill-s3.ts +0 -86
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- /package/{src/index.d.ts → index.d.ts} +0 -0
- /package/{src/index.ts → libs/skill-s3/src/index.d.ts} +0 -0
- /package/{src/schema.fr.json → schema.fr.json} +0 -0
- /package/{src/schema.json → schema.json} +0 -0
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var clientS3 = require('@aws-sdk/client-s3');
|
|
6
|
+
|
|
7
|
+
let S3Service = class S3Service {
|
|
8
|
+
getClient(config) {
|
|
9
|
+
return new clientS3.S3Client(config);
|
|
10
|
+
}
|
|
11
|
+
async upload(params, _pinsSettingsList, context) {
|
|
12
|
+
const { bucket, key, content, config = context.privates.S3_CONFIG } = params;
|
|
13
|
+
const client = this.getClient(config);
|
|
14
|
+
const match = content.match(/^data:(.*?);base64,/);
|
|
15
|
+
const contentType = match[1];
|
|
16
|
+
const command = new clientS3.PutObjectCommand({
|
|
17
|
+
Bucket: bucket,
|
|
18
|
+
Key: key,
|
|
19
|
+
Body: Buffer.from(content.replace(/^data:.*;base64,/, ''), 'base64'),
|
|
20
|
+
ContentType: contentType
|
|
21
|
+
});
|
|
22
|
+
return await client.send(command);
|
|
23
|
+
}
|
|
24
|
+
async download(params, _pinsSettingsList, context) {
|
|
25
|
+
const { bucket, key, range, config = context.privates.S3_CONFIG } = params;
|
|
26
|
+
const client = this.getClient(config);
|
|
27
|
+
const command = new clientS3.GetObjectCommand({
|
|
28
|
+
Bucket: bucket,
|
|
29
|
+
Key: key,
|
|
30
|
+
Range: range
|
|
31
|
+
});
|
|
32
|
+
const response = await client.send(command);
|
|
33
|
+
const stream = response.Body;
|
|
34
|
+
const chunks = [];
|
|
35
|
+
for await (const chunk of stream){
|
|
36
|
+
chunks.push(chunk);
|
|
37
|
+
}
|
|
38
|
+
const buffer = Buffer.concat(chunks);
|
|
39
|
+
const base64 = buffer.toString('base64');
|
|
40
|
+
return `data:${response.ContentType};base64,${base64}`;
|
|
41
|
+
}
|
|
42
|
+
async delete(params, _pinsSettingsList, context) {
|
|
43
|
+
const { bucket, key, config = context.privates.S3_CONFIG } = params;
|
|
44
|
+
const client = this.getClient(config);
|
|
45
|
+
const command = new clientS3.DeleteObjectCommand({
|
|
46
|
+
Bucket: bucket,
|
|
47
|
+
Key: key
|
|
48
|
+
});
|
|
49
|
+
await client.send(command);
|
|
50
|
+
return client.send(command);
|
|
51
|
+
}
|
|
52
|
+
async list(params, _pinsSettingsList, context) {
|
|
53
|
+
const { bucket, prefix = '', config = context.privates.S3_CONFIG } = params;
|
|
54
|
+
const client = this.getClient(config);
|
|
55
|
+
const command = new clientS3.ListObjectsV2Command({
|
|
56
|
+
Bucket: bucket,
|
|
57
|
+
Prefix: prefix
|
|
58
|
+
});
|
|
59
|
+
return await client.send(command);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Export helpers
|
|
63
|
+
const service = new S3Service();
|
|
64
|
+
const upload = (params, pinsSettingsList, context)=>service.upload(params, pinsSettingsList, context);
|
|
65
|
+
const download = (params, pinsSettingsList, context)=>service.download(params, pinsSettingsList, context);
|
|
66
|
+
const remove = (params, pinsSettingsList, context)=>service.delete(params, pinsSettingsList, context);
|
|
67
|
+
const list = (params, pinsSettingsList, context)=>service.list(params, pinsSettingsList, context);
|
|
68
|
+
|
|
69
|
+
exports.download = download;
|
|
70
|
+
exports.list = list;
|
|
71
|
+
exports.remove = remove;
|
|
72
|
+
exports.upload = upload;
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
|
|
2
|
+
|
|
3
|
+
let S3Service = class S3Service {
|
|
4
|
+
getClient(config) {
|
|
5
|
+
return new S3Client(config);
|
|
6
|
+
}
|
|
7
|
+
async upload(params, _pinsSettingsList, context) {
|
|
8
|
+
const { bucket, key, content, config = context.privates.S3_CONFIG } = params;
|
|
9
|
+
const client = this.getClient(config);
|
|
10
|
+
const match = content.match(/^data:(.*?);base64,/);
|
|
11
|
+
const contentType = match[1];
|
|
12
|
+
const command = new PutObjectCommand({
|
|
13
|
+
Bucket: bucket,
|
|
14
|
+
Key: key,
|
|
15
|
+
Body: Buffer.from(content.replace(/^data:.*;base64,/, ''), 'base64'),
|
|
16
|
+
ContentType: contentType
|
|
17
|
+
});
|
|
18
|
+
return await client.send(command);
|
|
19
|
+
}
|
|
20
|
+
async download(params, _pinsSettingsList, context) {
|
|
21
|
+
const { bucket, key, range, config = context.privates.S3_CONFIG } = params;
|
|
22
|
+
const client = this.getClient(config);
|
|
23
|
+
const command = new GetObjectCommand({
|
|
24
|
+
Bucket: bucket,
|
|
25
|
+
Key: key,
|
|
26
|
+
Range: range
|
|
27
|
+
});
|
|
28
|
+
const response = await client.send(command);
|
|
29
|
+
const stream = response.Body;
|
|
30
|
+
const chunks = [];
|
|
31
|
+
for await (const chunk of stream){
|
|
32
|
+
chunks.push(chunk);
|
|
33
|
+
}
|
|
34
|
+
const buffer = Buffer.concat(chunks);
|
|
35
|
+
const base64 = buffer.toString('base64');
|
|
36
|
+
return `data:${response.ContentType};base64,${base64}`;
|
|
37
|
+
}
|
|
38
|
+
async delete(params, _pinsSettingsList, context) {
|
|
39
|
+
const { bucket, key, config = context.privates.S3_CONFIG } = params;
|
|
40
|
+
const client = this.getClient(config);
|
|
41
|
+
const command = new DeleteObjectCommand({
|
|
42
|
+
Bucket: bucket,
|
|
43
|
+
Key: key
|
|
44
|
+
});
|
|
45
|
+
await client.send(command);
|
|
46
|
+
return client.send(command);
|
|
47
|
+
}
|
|
48
|
+
async list(params, _pinsSettingsList, context) {
|
|
49
|
+
const { bucket, prefix = '', config = context.privates.S3_CONFIG } = params;
|
|
50
|
+
const client = this.getClient(config);
|
|
51
|
+
const command = new ListObjectsV2Command({
|
|
52
|
+
Bucket: bucket,
|
|
53
|
+
Prefix: prefix
|
|
54
|
+
});
|
|
55
|
+
return await client.send(command);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// Export helpers
|
|
59
|
+
const service = new S3Service();
|
|
60
|
+
const upload = (params, pinsSettingsList, context)=>service.upload(params, pinsSettingsList, context);
|
|
61
|
+
const download = (params, pinsSettingsList, context)=>service.download(params, pinsSettingsList, context);
|
|
62
|
+
const remove = (params, pinsSettingsList, context)=>service.delete(params, pinsSettingsList, context);
|
|
63
|
+
const list = (params, pinsSettingsList, context)=>service.list(params, pinsSettingsList, context);
|
|
64
|
+
|
|
65
|
+
export { download, list, remove, upload };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PinsSettings } from '@digipair/engine';
|
|
2
|
+
export declare const upload: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
|
|
3
|
+
export declare const download: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string>;
|
|
4
|
+
export declare const remove: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@aws-sdk/client-s3").DeleteObjectCommandOutput>;
|
|
5
|
+
export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@aws-sdk/client-s3").ListObjectsV2CommandOutput>;
|
package/package.json
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digipair/skill-s3",
|
|
3
|
-
"version": "0.91.0
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/libs/skill-s3/index.cjs.js",
|
|
6
|
-
"module": "dist/libs/skill-s3/index.esm.js",
|
|
7
|
-
"types": "dist/libs/skill-s3/index.esm.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./libs/skill-s3/package.json",
|
|
10
|
-
".": {
|
|
11
|
-
"development": "./dist/libs/skill-s3/src/index.ts",
|
|
12
|
-
"types": "./dist/libs/skill-s3/index.esm.d.ts",
|
|
13
|
-
"import": "./dist/libs/skill-s3/index.esm.js",
|
|
14
|
-
"default": "./dist/libs/skill-s3/index.cjs.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
3
|
+
"version": "0.91.0",
|
|
17
4
|
"keywords": [
|
|
18
5
|
"digipair",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
6
|
+
"service",
|
|
7
|
+
"tool"
|
|
21
8
|
],
|
|
22
|
-
"nx": {
|
|
23
|
-
"name": "skill-s3"
|
|
24
|
-
},
|
|
25
9
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
}
|
|
28
|
-
|
|
10
|
+
"@aws-sdk/client-s3": "^3.787.0"
|
|
11
|
+
},
|
|
12
|
+
"main": "./index.cjs.js",
|
|
13
|
+
"module": "./index.esm.js"
|
|
14
|
+
}
|
package/.swcrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"jsc": {
|
|
3
|
-
"target": "es2017",
|
|
4
|
-
"parser": {
|
|
5
|
-
"syntax": "typescript",
|
|
6
|
-
"decorators": true,
|
|
7
|
-
"dynamicImport": true
|
|
8
|
-
},
|
|
9
|
-
"transform": {
|
|
10
|
-
"decoratorMetadata": true,
|
|
11
|
-
"legacyDecorator": true
|
|
12
|
-
},
|
|
13
|
-
"keepClassNames": true,
|
|
14
|
-
"externalHelpers": true,
|
|
15
|
-
"loose": true
|
|
16
|
-
},
|
|
17
|
-
"module": {
|
|
18
|
-
"type": "es6"
|
|
19
|
-
},
|
|
20
|
-
"sourceMaps": true,
|
|
21
|
-
"exclude": [
|
|
22
|
-
"jest.config.ts",
|
|
23
|
-
".*\\.spec.tsx?$",
|
|
24
|
-
".*\\.test.tsx?$",
|
|
25
|
-
"./src/jest-setup.ts$",
|
|
26
|
-
"./**/jest-setup.ts$"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/README.md
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser: await import('jsonc-eslint-parser'),
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/rollup.config.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
-
|
|
3
|
-
module.exports = withNx(
|
|
4
|
-
{
|
|
5
|
-
main: 'libs/skill-s3/src/index.ts',
|
|
6
|
-
outputPath: 'dist/libs/skill-s3',
|
|
7
|
-
tsConfig: 'libs/skill-s3/tsconfig.lib.json',
|
|
8
|
-
compiler: 'swc',
|
|
9
|
-
format: ['esm', "cjs"],
|
|
10
|
-
assets: [
|
|
11
|
-
{
|
|
12
|
-
input: 'libs/skill-s3/',
|
|
13
|
-
glob: 'package.json',
|
|
14
|
-
output: '.'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
input: 'libs/skill-s3/src/',
|
|
18
|
-
glob: '*.json',
|
|
19
|
-
output: '.'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
25
|
-
// e.g.
|
|
26
|
-
// output: { sourcemap: true },
|
|
27
|
-
}
|
|
28
|
-
);
|
package/src/lib/skill-s3.spec.ts
DELETED
package/src/lib/skill-s3.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { PinsSettings } from '@digipair/engine';
|
|
3
|
-
import {
|
|
4
|
-
S3Client,
|
|
5
|
-
PutObjectCommand,
|
|
6
|
-
GetObjectCommand,
|
|
7
|
-
DeleteObjectCommand,
|
|
8
|
-
ListObjectsV2Command,
|
|
9
|
-
} from '@aws-sdk/client-s3';
|
|
10
|
-
import { Readable } from 'stream';
|
|
11
|
-
|
|
12
|
-
class S3Service {
|
|
13
|
-
private getClient(config: any) {
|
|
14
|
-
return new S3Client(config);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async upload(params: any, _pinsSettingsList: PinsSettings[], context: any) {
|
|
18
|
-
const { bucket, key, content, config = context.privates.S3_CONFIG } = params;
|
|
19
|
-
|
|
20
|
-
const client = this.getClient(config);
|
|
21
|
-
const match = content.match(/^data:(.*?);base64,/);
|
|
22
|
-
const contentType = match[1];
|
|
23
|
-
|
|
24
|
-
const command = new PutObjectCommand({
|
|
25
|
-
Bucket: bucket,
|
|
26
|
-
Key: key,
|
|
27
|
-
Body: Buffer.from(content.replace(/^data:.*;base64,/, ''), 'base64'),
|
|
28
|
-
ContentType: contentType,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return await client.send(command);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async download(params: any, _pinsSettingsList: PinsSettings[], context: any) {
|
|
35
|
-
const { bucket, key, range, config = context.privates.S3_CONFIG } = params;
|
|
36
|
-
|
|
37
|
-
const client = this.getClient(config);
|
|
38
|
-
|
|
39
|
-
const command = new GetObjectCommand({ Bucket: bucket, Key: key, Range: range });
|
|
40
|
-
const response = await client.send(command);
|
|
41
|
-
const stream = response.Body as Readable;
|
|
42
|
-
|
|
43
|
-
const chunks: Uint8Array[] = [];
|
|
44
|
-
for await (const chunk of stream) {
|
|
45
|
-
chunks.push(chunk);
|
|
46
|
-
}
|
|
47
|
-
const buffer = Buffer.concat(chunks);
|
|
48
|
-
const base64 = buffer.toString('base64');
|
|
49
|
-
|
|
50
|
-
return `data:${response.ContentType};base64,${base64}`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async delete(params: any, _pinsSettingsList: PinsSettings[], context: any) {
|
|
54
|
-
const { bucket, key, config = context.privates.S3_CONFIG } = params;
|
|
55
|
-
|
|
56
|
-
const client = this.getClient(config);
|
|
57
|
-
|
|
58
|
-
const command = new DeleteObjectCommand({ Bucket: bucket, Key: key });
|
|
59
|
-
await client.send(command);
|
|
60
|
-
|
|
61
|
-
return client.send(command);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async list(params: any, _pinsSettingsList: PinsSettings[], context: any) {
|
|
65
|
-
const { bucket, prefix = '', config = context.privates.S3_CONFIG } = params;
|
|
66
|
-
const client = this.getClient(config);
|
|
67
|
-
const command = new ListObjectsV2Command({ Bucket: bucket, Prefix: prefix });
|
|
68
|
-
|
|
69
|
-
return await client.send(command);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Export helpers
|
|
74
|
-
const service = new S3Service();
|
|
75
|
-
|
|
76
|
-
export const upload = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
77
|
-
service.upload(params, pinsSettingsList, context);
|
|
78
|
-
|
|
79
|
-
export const download = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
80
|
-
service.download(params, pinsSettingsList, context);
|
|
81
|
-
|
|
82
|
-
export const remove = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
83
|
-
service.delete(params, pinsSettingsList, context);
|
|
84
|
-
|
|
85
|
-
export const list = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
86
|
-
service.list(params, pinsSettingsList, context);
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
7
|
-
"emitDeclarationOnly": true,
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"types": ["node"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*.ts"],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": "../engine/tsconfig.lib.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|