@digipair/skill-s3 0.94.0-1 → 0.94.0-3

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.
Files changed (47) hide show
  1. package/index.cjs.js +72 -0
  2. package/index.d.ts +1 -0
  3. package/index.esm.js +65 -0
  4. package/libs/skill-s3/src/index.d.ts +1 -0
  5. package/{dist → libs/skill-s3}/src/lib/skill-s3.d.ts +0 -1
  6. package/package.json +6 -20
  7. package/README.md +0 -7
  8. package/dist/index.cjs.js +0 -22
  9. package/dist/index.cjs10.js +0 -1581
  10. package/dist/index.cjs11.js +0 -2639
  11. package/dist/index.cjs2.js +0 -25
  12. package/dist/index.cjs3.js +0 -39239
  13. package/dist/index.cjs4.js +0 -450
  14. package/dist/index.cjs5.js +0 -3698
  15. package/dist/index.cjs6.js +0 -433
  16. package/dist/index.cjs7.js +0 -706
  17. package/dist/index.cjs8.js +0 -1691
  18. package/dist/index.cjs9.js +0 -1515
  19. package/dist/index.esm.js +0 -13
  20. package/dist/index.esm10.js +0 -1577
  21. package/dist/index.esm11.js +0 -2619
  22. package/dist/index.esm2.js +0 -13
  23. package/dist/index.esm3.js +0 -39118
  24. package/dist/index.esm4.js +0 -447
  25. package/dist/index.esm5.js +0 -3676
  26. package/dist/index.esm6.js +0 -431
  27. package/dist/index.esm7.js +0 -704
  28. package/dist/index.esm8.js +0 -1689
  29. package/dist/index.esm9.js +0 -1504
  30. package/dist/loadSso.cjs.js +0 -2092
  31. package/dist/loadSso.esm.js +0 -2089
  32. package/dist/noAuth.cjs.js +0 -167
  33. package/dist/noAuth.esm.js +0 -165
  34. package/dist/package.cjs.js +0 -187
  35. package/dist/package.esm.js +0 -184
  36. package/dist/parseJsonBody.cjs.js +0 -257
  37. package/dist/parseJsonBody.esm.js +0 -252
  38. package/dist/parseKnownFiles.cjs.js +0 -250
  39. package/dist/parseKnownFiles.esm.js +0 -248
  40. package/dist/src/index.d.ts +0 -2
  41. package/dist/src/index.d.ts.map +0 -1
  42. package/dist/src/lib/skill-s3.d.ts.map +0 -1
  43. package/dist/src/lib/skill-s3.spec.d.ts +0 -2
  44. package/dist/src/lib/skill-s3.spec.d.ts.map +0 -1
  45. /package/{dist/index.d.ts → index.cjs.d.ts} +0 -0
  46. /package/{dist/schema.fr.json → schema.fr.json} +0 -0
  47. /package/{dist/schema.json → schema.json} +0 -0
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.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './libs/skill-s3/src/index';
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 @@
1
+ export * from './lib/skill-s3';
@@ -3,4 +3,3 @@ export declare const upload: (params: any, pinsSettingsList: PinsSettings[], con
3
3
  export declare const download: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string>;
4
4
  export declare const remove: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@aws-sdk/client-s3").DeleteObjectCommandOutput>;
5
5
  export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@aws-sdk/client-s3").ListObjectsV2CommandOutput>;
6
- //# sourceMappingURL=skill-s3.d.ts.map
package/package.json CHANGED
@@ -1,28 +1,14 @@
1
1
  {
2
2
  "name": "@digipair/skill-s3",
3
- "version": "0.94.0-1",
4
- "main": "./dist/index.cjs.js",
5
- "module": "./dist/index.esm.js",
6
- "types": "./dist/index.d.ts",
3
+ "version": "0.94.0-3",
7
4
  "keywords": [
8
5
  "digipair",
9
6
  "service",
10
7
  "tool"
11
8
  ],
12
- "exports": {
13
- "./package.json": "./package.json",
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.esm.js",
17
- "default": "./dist/index.cjs.js"
18
- }
9
+ "dependencies": {
10
+ "@aws-sdk/client-s3": "^3.787.0"
19
11
  },
20
- "files": [
21
- "dist",
22
- "!**/*.tsbuildinfo"
23
- ],
24
- "nx": {
25
- "name": "skill-s3"
26
- },
27
- "dependencies": {}
28
- }
12
+ "main": "./index.cjs.js",
13
+ "module": "./index.esm.js"
14
+ }
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # skill-test
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build skill-s3` to build the library.
package/dist/index.cjs.js DELETED
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index.cjs3.js');
4
- require('buffer');
5
- require('stream');
6
- require('node:stream');
7
- require('http');
8
- require('https');
9
- require('http2');
10
- require('zlib');
11
- require('os');
12
- require('path');
13
- require('crypto');
14
- require('fs');
15
- require('process');
16
-
17
-
18
-
19
- exports.download = index.download;
20
- exports.list = index.list;
21
- exports.remove = index.remove;
22
- exports.upload = index.upload;