@webda/aws 4.0.0-beta.1 → 4.0.0-beta.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 (126) hide show
  1. package/README.md +64 -7
  2. package/lib/index.d.ts +1 -0
  3. package/lib/index.d.ts.map +1 -0
  4. package/lib/index.js.map +1 -1
  5. package/lib/services/aws-parameters.d.ts +33 -0
  6. package/lib/services/aws-parameters.d.ts.map +1 -0
  7. package/lib/services/aws-parameters.js +18 -0
  8. package/lib/services/aws-parameters.js.map +1 -0
  9. package/lib/services/awscommands.service.d.ts +39 -0
  10. package/lib/services/awscommands.service.d.ts.map +1 -0
  11. package/lib/services/awscommands.service.js +127 -0
  12. package/lib/services/awscommands.service.js.map +1 -0
  13. package/lib/services/cloudwatchlogger.service.d.ts +131 -0
  14. package/lib/services/cloudwatchlogger.service.d.ts.map +1 -0
  15. package/lib/services/{cloudwatchlogger.js → cloudwatchlogger.service.js} +66 -34
  16. package/lib/services/cloudwatchlogger.service.js.map +1 -0
  17. package/lib/services/contributors.d.ts +37 -0
  18. package/lib/services/contributors.d.ts.map +1 -0
  19. package/lib/services/contributors.js +2 -0
  20. package/lib/services/contributors.js.map +1 -0
  21. package/lib/services/dynamodb.service.d.ts +297 -0
  22. package/lib/services/dynamodb.service.d.ts.map +1 -0
  23. package/lib/services/dynamodb.service.js +985 -0
  24. package/lib/services/dynamodb.service.js.map +1 -0
  25. package/lib/services/index.d.ts +12 -31
  26. package/lib/services/index.d.ts.map +1 -0
  27. package/lib/services/index.js +11 -8
  28. package/lib/services/index.js.map +1 -1
  29. package/lib/services/lambdacaller.service.d.ts +81 -0
  30. package/lib/services/lambdacaller.service.d.ts.map +1 -0
  31. package/lib/services/lambdacaller.service.js +75 -0
  32. package/lib/services/lambdacaller.service.js.map +1 -0
  33. package/lib/services/lambdaserver.service.d.ts +127 -0
  34. package/lib/services/lambdaserver.service.d.ts.map +1 -0
  35. package/lib/services/lambdaserver.service.js +294 -0
  36. package/lib/services/lambdaserver.service.js.map +1 -0
  37. package/lib/services/{route53.d.ts → route53.service.d.ts} +21 -11
  38. package/lib/services/route53.service.d.ts.map +1 -0
  39. package/lib/services/{route53.js → route53.service.js} +35 -38
  40. package/lib/services/route53.service.js.map +1 -0
  41. package/lib/services/s3binary.service.d.ts +215 -0
  42. package/lib/services/s3binary.service.d.ts.map +1 -0
  43. package/lib/services/{s3binary.js → s3binary.service.js} +113 -74
  44. package/lib/services/s3binary.service.js.map +1 -0
  45. package/lib/services/secretsmanager.service.d.ts +102 -0
  46. package/lib/services/secretsmanager.service.d.ts.map +1 -0
  47. package/lib/services/{secretsmanager.js → secretsmanager.service.js} +42 -24
  48. package/lib/services/secretsmanager.service.js.map +1 -0
  49. package/lib/services/{sqsqueue.d.ts → sqsqueue.service.d.ts} +60 -34
  50. package/lib/services/sqsqueue.service.d.ts.map +1 -0
  51. package/lib/services/{sqsqueue.js → sqsqueue.service.js} +60 -35
  52. package/lib/services/sqsqueue.service.js.map +1 -0
  53. package/package.json +59 -65
  54. package/webda.module.json +738 -377
  55. package/lib/deployers/cloudformation.d.ts +0 -316
  56. package/lib/deployers/cloudformation.js +0 -837
  57. package/lib/deployers/cloudformation.js.map +0 -1
  58. package/lib/deployers/cloudformation.spec.d.ts +0 -1
  59. package/lib/deployers/cloudformation.spec.js +0 -530
  60. package/lib/deployers/cloudformation.spec.js.map +0 -1
  61. package/lib/deployers/index.d.ts +0 -254
  62. package/lib/deployers/index.js +0 -543
  63. package/lib/deployers/index.js.map +0 -1
  64. package/lib/deployers/index.spec.d.ts +0 -8
  65. package/lib/deployers/index.spec.js +0 -595
  66. package/lib/deployers/index.spec.js.map +0 -1
  67. package/lib/deployers/lambda-entrypoint.d.ts +0 -1
  68. package/lib/deployers/lambda-entrypoint.js +0 -11
  69. package/lib/deployers/lambda-entrypoint.js.map +0 -1
  70. package/lib/deployers/lambdapackager.d.ts +0 -27
  71. package/lib/deployers/lambdapackager.js +0 -26
  72. package/lib/deployers/lambdapackager.js.map +0 -1
  73. package/lib/deployers/lambdapackager.spec.d.ts +0 -1
  74. package/lib/deployers/lambdapackager.spec.js +0 -44
  75. package/lib/deployers/lambdapackager.spec.js.map +0 -1
  76. package/lib/index.spec.d.ts +0 -10
  77. package/lib/index.spec.js +0 -42
  78. package/lib/index.spec.js.map +0 -1
  79. package/lib/services/aws-mixin.d.ts +0 -24
  80. package/lib/services/aws-mixin.js +0 -18
  81. package/lib/services/aws-mixin.js.map +0 -1
  82. package/lib/services/cloudwatchlogger.d.ts +0 -81
  83. package/lib/services/cloudwatchlogger.js.map +0 -1
  84. package/lib/services/cloudwatchlogger.spec.d.ts +0 -1
  85. package/lib/services/cloudwatchlogger.spec.js +0 -104
  86. package/lib/services/cloudwatchlogger.spec.js.map +0 -1
  87. package/lib/services/dynamodb.d.ts +0 -173
  88. package/lib/services/dynamodb.js +0 -711
  89. package/lib/services/dynamodb.js.map +0 -1
  90. package/lib/services/dynamodb.spec.d.ts +0 -23
  91. package/lib/services/dynamodb.spec.js +0 -339
  92. package/lib/services/dynamodb.spec.js.map +0 -1
  93. package/lib/services/lambdacaller.d.ts +0 -68
  94. package/lib/services/lambdacaller.js +0 -63
  95. package/lib/services/lambdacaller.js.map +0 -1
  96. package/lib/services/lambdacaller.spec.d.ts +0 -1
  97. package/lib/services/lambdacaller.spec.js +0 -70
  98. package/lib/services/lambdacaller.spec.js.map +0 -1
  99. package/lib/services/lambdaserver.d.ts +0 -86
  100. package/lib/services/lambdaserver.js +0 -264
  101. package/lib/services/lambdaserver.js.map +0 -1
  102. package/lib/services/lambdaserver.spec.d.ts +0 -1
  103. package/lib/services/lambdaserver.spec.js +0 -417
  104. package/lib/services/lambdaserver.spec.js.map +0 -1
  105. package/lib/services/route53.js.map +0 -1
  106. package/lib/services/route53.spec.d.ts +0 -1
  107. package/lib/services/route53.spec.js +0 -102
  108. package/lib/services/route53.spec.js.map +0 -1
  109. package/lib/services/s3binary.d.ts +0 -162
  110. package/lib/services/s3binary.js.map +0 -1
  111. package/lib/services/s3binary.spec.d.ts +0 -1
  112. package/lib/services/s3binary.spec.js +0 -269
  113. package/lib/services/s3binary.spec.js.map +0 -1
  114. package/lib/services/secretsmanager.d.ts +0 -80
  115. package/lib/services/secretsmanager.js.map +0 -1
  116. package/lib/services/secretsmanager.spec.d.ts +0 -1
  117. package/lib/services/secretsmanager.spec.js +0 -66
  118. package/lib/services/secretsmanager.spec.js.map +0 -1
  119. package/lib/services/sqsqueue.js.map +0 -1
  120. package/lib/services/sqsqueue.spec.d.ts +0 -1
  121. package/lib/services/sqsqueue.spec.js +0 -152
  122. package/lib/services/sqsqueue.spec.js.map +0 -1
  123. package/lib/shell.d.ts +0 -12
  124. package/lib/shell.js +0 -42
  125. package/lib/shell.js.map +0 -1
  126. package/webda.shell.json +0 -11
@@ -0,0 +1,215 @@
1
+ import { HeadObjectCommandOutput, S3 } from "@aws-sdk/client-s3";
2
+ import { BinaryFile, BinaryFileInfo, BinaryMap, CloudBinary, CloudBinaryParameters, CoreModel, OperationContext } from "@webda/core";
3
+ import { Readable } from "node:stream";
4
+ import { AWSServiceParameters } from "./aws-parameters.js";
5
+ import type { CloudFormationContributor, CloudFormationDeployerInfo } from "./contributors.js";
6
+ /**
7
+ * S3Binary parameters
8
+ */
9
+ export declare class S3BinaryParameters extends CloudBinaryParameters implements AWSServiceParameters {
10
+ /**
11
+ * Custom endpoint (localstack, minio, ...)
12
+ */
13
+ endpoint?: string;
14
+ /**
15
+ * Static credentials, default to the AWS environment variables
16
+ */
17
+ credentials?: {
18
+ accessKeyId: string;
19
+ secretAccessKey: string;
20
+ sessionToken?: string;
21
+ };
22
+ /**
23
+ * AWS region
24
+ * @default "us-east-1"
25
+ */
26
+ region?: string;
27
+ /**
28
+ * Use path style url (required by localstack/minio)
29
+ * @default false
30
+ */
31
+ forcePathStyle?: boolean;
32
+ /**
33
+ * Bucket to store the binaries in
34
+ */
35
+ bucket: string;
36
+ /**
37
+ * CloudFormation customization
38
+ */
39
+ CloudFormation?: any;
40
+ /**
41
+ * Skip CloudFormation on deploy
42
+ */
43
+ CloudFormationSkip?: boolean;
44
+ /**
45
+ * @override
46
+ * @param params - raw parameters
47
+ * @returns this
48
+ */
49
+ load(params?: any): this;
50
+ }
51
+ /**
52
+ * S3Binary handles the storage of binary on a S3 bucket
53
+ *
54
+ * The structure used for now is
55
+ * /{hash}/data
56
+ * /{hash}/{targetStore}_{uuid}
57
+ * The challenge is stored on the metadata of the data object
58
+ *
59
+ * It takes parameters
60
+ * bucket: "bucketName"
61
+ * accessKeyId: ""
62
+ * secretAccessKey: ""
63
+ * region: ""
64
+ *
65
+ * See Binary the general interface
66
+ *
67
+ * We can register on S3 Event to get info when /data is pushed
68
+ *
69
+ * @WebdaModda
70
+ */
71
+ export declare class S3Binary<T extends S3BinaryParameters = S3BinaryParameters> extends CloudBinary<T> implements CloudFormationContributor {
72
+ _s3: S3;
73
+ /**
74
+ * Create the S3 client
75
+ * @override
76
+ */
77
+ computeParameters(): void;
78
+ /**
79
+ * Return a signed PUT url if the binary is not yet stored
80
+ *
81
+ * @param object - the model owning the binary
82
+ * @param property - the binary attribute
83
+ * @param body - the binary information (hash and challenge)
84
+ * @param context - the operation context
85
+ * @returns the url to upload to, or undefined if the binary is already stored
86
+ */
87
+ putRedirectUrl(object: CoreModel, property: string, body?: BinaryFileInfo, context?: OperationContext<BinaryFileInfo>): Promise<{
88
+ url: string;
89
+ method: string;
90
+ headers: {
91
+ [key: string]: string;
92
+ };
93
+ }>;
94
+ /**
95
+ * Put an empty marker object next to the binary data
96
+ * @param hash - the binary hash
97
+ * @param suffix - the marker name
98
+ * @param storeName - the model identifier using the binary
99
+ * @returns the putObject result
100
+ */
101
+ putMarker(hash: string, suffix: string, storeName: string): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
102
+ /**
103
+ * Return a signed url to an object
104
+ *
105
+ * @param key to the object
106
+ * @param action to perform
107
+ * @param params - additional command parameters
108
+ * @returns the signed url
109
+ */
110
+ getSignedUrl(key: string, action?: "getObject" | "putObject", params?: any): Promise<string>;
111
+ /**
112
+ * @override
113
+ * @param binaryMap - the binary to download
114
+ * @param expire - url validity in seconds
115
+ * @param _context - the operation context
116
+ * @returns the signed url
117
+ */
118
+ getSignedUrlFromMap(binaryMap: BinaryMap, expire: number, _context: OperationContext): Promise<string>;
119
+ /**
120
+ * @override
121
+ * @param info - the binary to retrieve
122
+ * @returns the binary content stream
123
+ */
124
+ _get(info: BinaryMap): Promise<Readable>;
125
+ /**
126
+ * Check if an object exists on S3
127
+ * @param Key - the object key
128
+ * @param Bucket - the bucket, default to the configured one
129
+ * @returns the head result or null if not found
130
+ */
131
+ exists(Key: string, Bucket?: string): Promise<HeadObjectCommandOutput | null>;
132
+ /**
133
+ * @override
134
+ * @param hash - the binary hash
135
+ * @returns the number of objects using the binary
136
+ */
137
+ getUsageCount(hash: string): Promise<number>;
138
+ /**
139
+ * Delete the binary data and all its markers
140
+ * @param hash - the binary hash
141
+ */
142
+ _cleanHash(hash: string): Promise<void>;
143
+ /**
144
+ * @override
145
+ * @param hash - the binary hash
146
+ * @param uuid - the object uuid
147
+ * @param attribute - the binary attribute, if undefined clean the whole binary
148
+ */
149
+ _cleanUsage(hash: string, uuid: string, attribute?: string): Promise<void>;
150
+ /**
151
+ * Check if the binary data exists
152
+ * @param hash - the binary hash
153
+ * @returns true if it exists
154
+ */
155
+ _exists(hash: string): Promise<boolean>;
156
+ /**
157
+ * Get a head object
158
+ * @param hash - the binary hash
159
+ * @returns the head result or undefined if not found
160
+ */
161
+ _getS3(hash: string): Promise<HeadObjectCommandOutput>;
162
+ /**
163
+ * Get an object from s3 bucket
164
+ *
165
+ * @param key to get
166
+ * @param bucket to retrieve from or default bucket
167
+ * @returns the object content stream
168
+ */
169
+ getObject(key: string, bucket?: string): Promise<Readable>;
170
+ /**
171
+ *
172
+ * Iterate over the files of a bucket
173
+ *
174
+ * @param Bucket to iterate on
175
+ * @param callback to execute with each key
176
+ * @param Prefix to use
177
+ * @param filter regexp to execute on the key
178
+ */
179
+ forEachFile(Bucket: string, callback: (Key: string, page: number) => Promise<void>, Prefix?: string, filter?: RegExp): Promise<void>;
180
+ /**
181
+ * Add an object to S3 bucket
182
+ *
183
+ * @param key to add to
184
+ * @param body content of the object
185
+ * @param metadatas to put along the object
186
+ * @param bucket to use
187
+ */
188
+ putObject(key: string, body: Buffer | Blob | string | ReadableStream, metadatas?: {}, bucket?: string): Promise<void>;
189
+ /**
190
+ * @override
191
+ * @param object - the model owning the binary
192
+ * @param property - the binary attribute
193
+ * @param file - the binary to store
194
+ */
195
+ store(object: CoreModel, property: string, file: BinaryFile): Promise<void>;
196
+ /**
197
+ * IAM policy required by the service
198
+ * @param _accountId - AWS account id
199
+ * @returns the policy statement
200
+ */
201
+ getARNPolicy(_accountId: string): {
202
+ Sid: string;
203
+ Effect: string;
204
+ Action: string[];
205
+ Resource: string[];
206
+ };
207
+ /**
208
+ * CloudFormation resources for the bucket
209
+ * @param deployer - the deployer requesting the resources
210
+ * @returns the resources
211
+ */
212
+ getCloudFormation(deployer: CloudFormationDeployerInfo): {};
213
+ }
214
+ export default S3Binary;
215
+ //# sourceMappingURL=s3binary.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3binary.service.d.ts","sourceRoot":"","sources":["../../src/services/s3binary.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,uBAAuB,EAAoB,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAErG,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAqB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/F;;GAEG;AACH,qBAAa,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;IACG,SAAS,CACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,cAAc,EAC7C,SAAS,KAAK,EACd,MAAM,GAAE,MAA+B,iBASxC;IAED;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhF;IAED;;;;OAIG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM;QAE3B,GAAG;QACH,MAAM;QACN,MAAM;QAqBN,QAAQ;MAEX;IAED;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,0BAA0B,MAiBrD;CACF;eAEc,QAAQ"}
@@ -1,17 +1,25 @@
1
1
  // Load the AWS SDK for Node.js
2
2
  import { GetObjectCommand, PutObjectCommand, S3 } from "@aws-sdk/client-s3";
3
3
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
4
- import { BinaryParameters, CloudBinary, WebdaError } from "@webda/core";
5
- import bluebird from "bluebird";
6
- import { AWSServiceParameters } from "./aws-mixin.js";
7
- export class S3BinaryParameters extends AWSServiceParameters(BinaryParameters) {
8
- constructor(params, service) {
9
- super(params, service);
4
+ import { CloudBinary, CloudBinaryParameters, useModelId, WebdaError } from "@webda/core";
5
+ import { loadAWSParameters } from "./aws-parameters.js";
6
+ /**
7
+ * S3Binary parameters
8
+ */
9
+ export class S3BinaryParameters extends CloudBinaryParameters {
10
+ /**
11
+ * @override
12
+ * @param params - raw parameters
13
+ * @returns this
14
+ */
15
+ load(params = {}) {
16
+ super.load(params);
17
+ loadAWSParameters(this);
10
18
  if (!this.bucket) {
11
19
  throw new WebdaError.CodeError("S3BUCKET_PARAMETER_REQUIRED", "Need to define a bucket at least");
12
20
  }
13
21
  this.forcePathStyle ?? (this.forcePathStyle = false);
14
- this.prefix = "";
22
+ return this;
15
23
  }
16
24
  }
17
25
  /**
@@ -34,45 +42,44 @@ export class S3BinaryParameters extends AWSServiceParameters(BinaryParameters) {
34
42
  *
35
43
  * @WebdaModda
36
44
  */
37
- export default class S3Binary extends CloudBinary {
38
- /**
39
- * Load the parameters
40
- *
41
- * @param params
42
- */
43
- loadParameters(params) {
44
- return new S3BinaryParameters(params, this);
45
- }
45
+ export class S3Binary extends CloudBinary {
46
46
  /**
47
- * @inheritdoc
47
+ * Create the S3 client
48
+ * @override
48
49
  */
49
50
  computeParameters() {
51
+ super.computeParameters();
50
52
  this._s3 = new S3(this.parameters);
51
53
  }
52
54
  /**
53
- * @inheritdoc
55
+ * Return a signed PUT url if the binary is not yet stored
56
+ *
57
+ * @param object - the model owning the binary
58
+ * @param property - the binary attribute
59
+ * @param body - the binary information (hash and challenge)
60
+ * @param context - the operation context
61
+ * @returns the url to upload to, or undefined if the binary is already stored
54
62
  */
55
- async putRedirectUrl(ctx) {
56
- let body = await ctx.getRequestBody();
57
- const { uuid, store, property } = ctx.getParameters();
58
- let targetStore = this._verifyMapAndStore(ctx);
59
- let object = await targetStore.get(uuid);
60
- let base64String = Buffer.from(body.hash, "hex").toString("base64");
61
- let params = {
63
+ async putRedirectUrl(object, property, body, context) {
64
+ body ?? (body = await context.getInput());
65
+ const uuid = object.getUUID();
66
+ const store = useModelId(object.constructor);
67
+ const base64String = Buffer.from(body.hash, "hex").toString("base64");
68
+ const params = {
62
69
  Bucket: this.parameters.bucket,
63
70
  Key: this._getKey(body.hash),
64
71
  ContentType: "application/octet-stream",
65
72
  ContentMD5: base64String
66
73
  };
67
74
  // List bucket
68
- let data = await this._s3.listObjectsV2({
75
+ const data = await this._s3.listObjectsV2({
69
76
  Bucket: this.parameters.bucket,
70
77
  Prefix: this._getKey(body.hash, "")
71
78
  });
72
79
  let foundMap = false;
73
80
  let foundData = false;
74
81
  let challenge;
75
- for (let i in data.Contents) {
82
+ for (const i in data.Contents) {
76
83
  if (data.Contents[i].Key.endsWith("data"))
77
84
  foundData = true;
78
85
  if (data.Contents[i].Key.endsWith(`${property}_${uuid}`))
@@ -116,10 +123,14 @@ export default class S3Binary extends CloudBinary {
116
123
  };
117
124
  }
118
125
  /**
119
- * @inheritdoc
126
+ * Put an empty marker object next to the binary data
127
+ * @param hash - the binary hash
128
+ * @param suffix - the marker name
129
+ * @param storeName - the model identifier using the binary
130
+ * @returns the putObject result
120
131
  */
121
132
  putMarker(hash, suffix, storeName) {
122
- let s3obj = new S3(this.parameters);
133
+ const s3obj = new S3(this.parameters);
123
134
  return s3obj.putObject({
124
135
  Bucket: this.parameters.bucket,
125
136
  Key: this._getKey(hash, suffix),
@@ -133,8 +144,8 @@ export default class S3Binary extends CloudBinary {
133
144
  *
134
145
  * @param key to the object
135
146
  * @param action to perform
136
- * @param params
137
- * @returns
147
+ * @param params - additional command parameters
148
+ * @returns the signed url
138
149
  */
139
150
  async getSignedUrl(key, action = "getObject", params = {}) {
140
151
  params.Bucket = params.Bucket || this.parameters.bucket;
@@ -151,9 +162,13 @@ export default class S3Binary extends CloudBinary {
151
162
  }
152
163
  /**
153
164
  * @override
165
+ * @param binaryMap - the binary to download
166
+ * @param expire - url validity in seconds
167
+ * @param _context - the operation context
168
+ * @returns the signed url
154
169
  */
155
170
  async getSignedUrlFromMap(binaryMap, expire, _context) {
156
- let params = {};
171
+ const params = {};
157
172
  params.Expires = expire; // A get should not take more than 30s
158
173
  params.ResponseContentDisposition = `attachment; filename=${binaryMap.name || binaryMap.originalname}`;
159
174
  params.ResponseContentType = binaryMap.mimetype;
@@ -162,6 +177,8 @@ export default class S3Binary extends CloudBinary {
162
177
  }
163
178
  /**
164
179
  * @override
180
+ * @param info - the binary to retrieve
181
+ * @returns the binary content stream
165
182
  */
166
183
  async _get(info) {
167
184
  return (await this._s3.getObject({
@@ -171,8 +188,9 @@ export default class S3Binary extends CloudBinary {
171
188
  }
172
189
  /**
173
190
  * Check if an object exists on S3
174
- * @param key
175
- * @param bucket
191
+ * @param Key - the object key
192
+ * @param Bucket - the bucket, default to the configured one
193
+ * @returns the head result or null if not found
176
194
  */
177
195
  async exists(Key, Bucket = this.parameters.bucket) {
178
196
  try {
@@ -189,11 +207,13 @@ export default class S3Binary extends CloudBinary {
189
207
  }
190
208
  }
191
209
  /**
192
- * @inheritdoc
210
+ * @override
211
+ * @param hash - the binary hash
212
+ * @returns the number of objects using the binary
193
213
  */
194
214
  async getUsageCount(hash) {
195
215
  // Not efficient if more than 1000 docs
196
- let data = await this._s3.listObjects({
216
+ const data = await this._s3.listObjects({
197
217
  Bucket: this.parameters.bucket,
198
218
  Prefix: this._getKey(hash, "")
199
219
  });
@@ -201,36 +221,45 @@ export default class S3Binary extends CloudBinary {
201
221
  return data.Contents.filter(k => !(k.Key.includes("data") || k.Key.includes("challenge"))).length;
202
222
  }
203
223
  /**
204
- * @inheritdoc
224
+ * Delete the binary data and all its markers
225
+ * @param hash - the binary hash
205
226
  */
206
227
  async _cleanHash(hash) {
207
- let files = (await this._s3.listObjectsV2({
208
- Bucket: this.parameters.bucket,
209
- Prefix: this._getKey(hash, "")
210
- })).Contents;
211
- await bluebird.map(files, file => this._s3.deleteObject({
212
- Bucket: this.parameters.bucket,
213
- Key: file.Key
214
- }), {
215
- concurrency: 5
216
- });
228
+ const files = [
229
+ ...((await this._s3.listObjectsV2({
230
+ Bucket: this.parameters.bucket,
231
+ Prefix: this._getKey(hash, "")
232
+ })).Contents ?? [])
233
+ ];
234
+ // Delete with a concurrency of 5
235
+ while (files.length) {
236
+ await Promise.all(files.splice(0, 5).map(file => this._s3.deleteObject({
237
+ Bucket: this.parameters.bucket,
238
+ Key: file.Key
239
+ })));
240
+ }
217
241
  }
218
242
  /**
219
- * @inheritdoc
243
+ * @override
244
+ * @param hash - the binary hash
245
+ * @param uuid - the object uuid
246
+ * @param attribute - the binary attribute, if undefined clean the whole binary
220
247
  */
221
248
  async _cleanUsage(hash, uuid, attribute) {
222
249
  if (!attribute) {
223
250
  return this._cleanHash(hash);
224
251
  }
225
252
  // Dont clean data for now
226
- let params = {
253
+ const params = {
227
254
  Bucket: this.parameters.bucket,
228
255
  Key: this._getKey(hash, `${attribute}_${uuid}`)
229
256
  };
230
257
  await this._s3.deleteObject(params);
231
258
  }
232
259
  /**
233
- * @inheritdoc
260
+ * Check if the binary data exists
261
+ * @param hash - the binary hash
262
+ * @returns true if it exists
234
263
  */
235
264
  async _exists(hash) {
236
265
  try {
@@ -249,8 +278,8 @@ export default class S3Binary extends CloudBinary {
249
278
  }
250
279
  /**
251
280
  * Get a head object
252
- * @param hash
253
- * @returns
281
+ * @param hash - the binary hash
282
+ * @returns the head result or undefined if not found
254
283
  */
255
284
  async _getS3(hash) {
256
285
  try {
@@ -270,32 +299,34 @@ export default class S3Binary extends CloudBinary {
270
299
  *
271
300
  * @param key to get
272
301
  * @param bucket to retrieve from or default bucket
273
- * @returns
302
+ * @returns the object content stream
274
303
  */
275
304
  async getObject(key, bucket) {
276
305
  bucket = bucket || this.parameters.bucket;
277
- let s3obj = new S3(this.parameters);
306
+ const s3obj = new S3(this.parameters);
278
307
  return (await s3obj.getObject({
279
308
  Bucket: bucket,
280
309
  Key: key
281
310
  })).Body;
282
311
  }
283
312
  /**
313
+ *
314
+ * Iterate over the files of a bucket
284
315
  *
285
316
  * @param Bucket to iterate on
286
- * @param Prefix to use
287
317
  * @param callback to execute with each key
318
+ * @param Prefix to use
288
319
  * @param filter regexp to execute on the key
289
320
  */
290
321
  async forEachFile(Bucket, callback, Prefix = "", filter = undefined) {
291
- let params = { Bucket, Prefix };
322
+ const params = { Bucket, Prefix };
292
323
  let page = 0;
293
- let s3 = new S3(this.parameters);
324
+ const s3 = new S3(this.parameters);
294
325
  do {
295
326
  await s3.listObjectsV2(params).then(async ({ Contents, NextContinuationToken }) => {
296
327
  params.ContinuationToken = NextContinuationToken;
297
- for (let f in Contents) {
298
- let { Key } = Contents[f];
328
+ for (const f in Contents) {
329
+ const { Key } = Contents[f];
299
330
  if (filter && filter.exec(Key) === null) {
300
331
  continue;
301
332
  }
@@ -314,7 +345,7 @@ export default class S3Binary extends CloudBinary {
314
345
  * @param bucket to use
315
346
  */
316
347
  async putObject(key, body, metadatas = {}, bucket = this.parameters.bucket) {
317
- let s3obj = new S3(this.parameters);
348
+ const s3obj = new S3(this.parameters);
318
349
  await s3obj.putObject({
319
350
  Bucket: bucket,
320
351
  Key: key,
@@ -323,34 +354,40 @@ export default class S3Binary extends CloudBinary {
323
354
  });
324
355
  }
325
356
  /**
326
- * @inheritdoc
357
+ * @override
358
+ * @param object - the model owning the binary
359
+ * @param property - the binary attribute
360
+ * @param file - the binary to store
327
361
  */
328
362
  async store(object, property, file) {
329
363
  this.checkMap(object, property);
330
364
  await file.getHashes();
331
- let data = await this._getS3(file.hash);
365
+ const data = await this._getS3(file.hash);
332
366
  if (data === undefined) {
333
- let s3metas = {};
367
+ const s3metas = {};
334
368
  s3metas["x-amz-meta-challenge"] = file.challenge;
335
- let s3obj = new S3(this.parameters);
369
+ const s3obj = new S3(this.parameters);
336
370
  await s3obj.putObject({
337
371
  Bucket: this.parameters.bucket,
338
372
  Key: this._getKey(file.hash),
339
373
  Metadata: s3metas,
340
- Body: await file.get()
374
+ Body: await file.get(),
375
+ ContentLength: file.size
341
376
  });
342
377
  }
343
378
  // Set challenge aside for now
344
379
  await this.putMarker(file.hash, `challenge_${file.challenge}`, "challenge");
345
- await this.putMarker(file.hash, `${property}_${object.getUuid()}`, object.getStore().getName());
346
- await this.uploadSuccess(object, property, file);
380
+ await this.putMarker(file.hash, `${property}_${object.getUUID()}`, useModelId(object.constructor));
381
+ await this.uploadSuccess(object, property, file.toBinaryFileInfo());
347
382
  }
348
383
  /**
349
- * @inheritdoc
384
+ * IAM policy required by the service
385
+ * @param _accountId - AWS account id
386
+ * @returns the policy statement
350
387
  */
351
388
  getARNPolicy(_accountId) {
352
389
  return {
353
- Sid: this.constructor.name + this._name,
390
+ Sid: this.constructor.name + this.getName(),
354
391
  Effect: "Allow",
355
392
  Action: [
356
393
  "s3:AbortMultipartUpload",
@@ -377,16 +414,18 @@ export default class S3Binary extends CloudBinary {
377
414
  };
378
415
  }
379
416
  /**
380
- * @inheritdoc
417
+ * CloudFormation resources for the bucket
418
+ * @param deployer - the deployer requesting the resources
419
+ * @returns the resources
381
420
  */
382
421
  getCloudFormation(deployer) {
383
422
  if (this.parameters.CloudFormationSkip) {
384
423
  return {};
385
424
  }
386
- let resources = {};
425
+ const resources = {};
387
426
  this.parameters.CloudFormation = this.parameters.CloudFormation || {};
388
427
  this.parameters.CloudFormation.Bucket = this.parameters.CloudFormation.Bucket || {};
389
- resources[this._name + "Bucket"] = {
428
+ resources[this.getName() + "Bucket"] = {
390
429
  Type: "AWS::S3::Bucket",
391
430
  Properties: {
392
431
  ...this.parameters.CloudFormation.Bucket,
@@ -398,5 +437,5 @@ export default class S3Binary extends CloudBinary {
398
437
  return resources;
399
438
  }
400
439
  }
401
- export { S3Binary };
402
- //# sourceMappingURL=s3binary.js.map
440
+ export default S3Binary;
441
+ //# sourceMappingURL=s3binary.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3binary.service.js","sourceRoot":"","sources":["../../src/services/s3binary.service.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAA2B,gBAAgB,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAIL,WAAW,EACX,qBAAqB,EAGrB,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAwB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG9E;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,qBAAqB;IAiC3D;;;;OAIG;IACH,IAAI,CAAC,MAAM,GAAQ,EAAE;QACnB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAA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