@digipair/skill-s3 0.90.0 → 0.91.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/.swcrc ADDED
@@ -0,0 +1,28 @@
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 ADDED
@@ -0,0 +1,7 @@
1
+ # mylib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build mylib` to build the library.
@@ -0,0 +1,22 @@
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/package.json CHANGED
@@ -1,14 +1,28 @@
1
1
  {
2
2
  "name": "@digipair/skill-s3",
3
- "version": "0.90.0",
3
+ "version": "0.91.0-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
+ },
4
17
  "keywords": [
5
18
  "digipair",
6
- "service",
7
- "tool"
19
+ "tool",
20
+ "service"
8
21
  ],
9
- "dependencies": {
10
- "@aws-sdk/client-s3": "^3.787.0"
22
+ "nx": {
23
+ "name": "skill-s3"
11
24
  },
12
- "main": "./index.cjs.js",
13
- "module": "./index.esm.js"
14
- }
25
+ "dependencies": {
26
+ "@digipair/engine": "0.91.0-0"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
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
+ );
@@ -0,0 +1,7 @@
1
+ import { skillS3 } from './skill-s3';
2
+
3
+ describe('skillS3', () => {
4
+ it('should work', () => {
5
+ expect(skillS3()).toEqual('skill-s3');
6
+ });
7
+ });
@@ -0,0 +1,86 @@
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 ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
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
+ }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.cjs.js DELETED
@@ -1,72 +0,0 @@
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 DELETED
@@ -1,65 +0,0 @@
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 };
@@ -1,5 +0,0 @@
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>;
File without changes
File without changes
File without changes
File without changes