importer-storage 1.0.28 → 1.0.29
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/dist/index.cjs +22 -6
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.global.js +22 -6
- package/dist/index.js +22 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,20 @@ var s3 = new import_client_s3.S3Client(
|
|
|
86
86
|
}
|
|
87
87
|
} : {}
|
|
88
88
|
);
|
|
89
|
+
var getS3Client = (regionName) => {
|
|
90
|
+
if (regionName && regionName === process.env.AWS_REGION) {
|
|
91
|
+
return s3;
|
|
92
|
+
}
|
|
93
|
+
return new import_client_s3.S3Client(
|
|
94
|
+
!process.env.AWS_EXECUTION_ENV && process.env.AWS_ACCESS_KEY_ID && process.env.AWS_ACCESS_KEY && regionName ? {
|
|
95
|
+
region: regionName,
|
|
96
|
+
credentials: {
|
|
97
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
98
|
+
secretAccessKey: process.env.AWS_ACCESS_KEY
|
|
99
|
+
}
|
|
100
|
+
} : {}
|
|
101
|
+
);
|
|
102
|
+
};
|
|
89
103
|
var BUCKET_NAME = process.env.AWS_BUCKET_NAME;
|
|
90
104
|
if (!BUCKET_NAME) {
|
|
91
105
|
throw new Error("'AWS_BUCKET_NAME' name not set");
|
|
@@ -245,8 +259,9 @@ var S3Storage = class {
|
|
|
245
259
|
return __async(this, null, function* () {
|
|
246
260
|
var _a;
|
|
247
261
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
262
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
248
263
|
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
249
|
-
const list = yield
|
|
264
|
+
const list = yield s3Client.send(
|
|
250
265
|
new import_client_s3.ListObjectsCommand({
|
|
251
266
|
Bucket,
|
|
252
267
|
Prefix: savePath + "/",
|
|
@@ -258,7 +273,7 @@ var S3Storage = class {
|
|
|
258
273
|
}
|
|
259
274
|
for (const obj of list.Contents) {
|
|
260
275
|
if (!obj.Key) continue;
|
|
261
|
-
const currentTags = yield
|
|
276
|
+
const currentTags = yield s3Client.send(
|
|
262
277
|
new import_client_s3.GetObjectTaggingCommand({
|
|
263
278
|
Bucket,
|
|
264
279
|
Key: obj.Key
|
|
@@ -267,7 +282,7 @@ var S3Storage = class {
|
|
|
267
282
|
const filteredTags = ((_a = currentTags.TagSet) == null ? void 0 : _a.filter(
|
|
268
283
|
(t) => !tags.includes(`${t.Key}:${t.Value}`)
|
|
269
284
|
)) || [];
|
|
270
|
-
yield
|
|
285
|
+
yield s3Client.send(
|
|
271
286
|
new import_client_s3.PutObjectTaggingCommand({
|
|
272
287
|
Bucket,
|
|
273
288
|
Key: obj.Key,
|
|
@@ -284,9 +299,10 @@ var S3Storage = class {
|
|
|
284
299
|
if (!tags.length) {
|
|
285
300
|
return false;
|
|
286
301
|
}
|
|
302
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
287
303
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
288
304
|
console.info(`addTag to bucket ${Bucket}`);
|
|
289
|
-
const list = yield
|
|
305
|
+
const list = yield s3Client.send(
|
|
290
306
|
new import_client_s3.ListObjectsCommand({
|
|
291
307
|
Bucket,
|
|
292
308
|
Prefix: savePath + "/",
|
|
@@ -306,7 +322,7 @@ var S3Storage = class {
|
|
|
306
322
|
}
|
|
307
323
|
for (const obj of list.Contents) {
|
|
308
324
|
if (!obj.Key) continue;
|
|
309
|
-
const currentTags = yield
|
|
325
|
+
const currentTags = yield s3Client.send(
|
|
310
326
|
new import_client_s3.GetObjectTaggingCommand({
|
|
311
327
|
Bucket,
|
|
312
328
|
Key: obj.Key
|
|
@@ -325,7 +341,7 @@ var S3Storage = class {
|
|
|
325
341
|
Key,
|
|
326
342
|
Value
|
|
327
343
|
}));
|
|
328
|
-
yield
|
|
344
|
+
yield s3Client.send(
|
|
329
345
|
new import_client_s3.PutObjectTaggingCommand({
|
|
330
346
|
Bucket,
|
|
331
347
|
Key: obj.Key,
|
package/dist/index.d.cts
CHANGED
|
@@ -56,9 +56,11 @@ declare class S3Storage implements IStorage {
|
|
|
56
56
|
}>;
|
|
57
57
|
removeTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
58
58
|
bucketName: string;
|
|
59
|
+
region: string;
|
|
59
60
|
}): Promise<boolean>;
|
|
60
61
|
addTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
61
62
|
bucketName: string;
|
|
63
|
+
region: string;
|
|
62
64
|
}): Promise<boolean>;
|
|
63
65
|
}
|
|
64
66
|
|
package/dist/index.d.ts
CHANGED
|
@@ -56,9 +56,11 @@ declare class S3Storage implements IStorage {
|
|
|
56
56
|
}>;
|
|
57
57
|
removeTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
58
58
|
bucketName: string;
|
|
59
|
+
region: string;
|
|
59
60
|
}): Promise<boolean>;
|
|
60
61
|
addTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
61
62
|
bucketName: string;
|
|
63
|
+
region: string;
|
|
62
64
|
}): Promise<boolean>;
|
|
63
65
|
}
|
|
64
66
|
|
package/dist/index.global.js
CHANGED
|
@@ -76896,6 +76896,20 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
76896
76896
|
}
|
|
76897
76897
|
} : {}
|
|
76898
76898
|
);
|
|
76899
|
+
var getS3Client = (regionName) => {
|
|
76900
|
+
if (regionName && regionName === process.env.AWS_REGION) {
|
|
76901
|
+
return s32;
|
|
76902
|
+
}
|
|
76903
|
+
return new S3Client(
|
|
76904
|
+
!process.env.AWS_EXECUTION_ENV && process.env.AWS_ACCESS_KEY_ID && process.env.AWS_ACCESS_KEY && regionName ? {
|
|
76905
|
+
region: regionName,
|
|
76906
|
+
credentials: {
|
|
76907
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
76908
|
+
secretAccessKey: process.env.AWS_ACCESS_KEY
|
|
76909
|
+
}
|
|
76910
|
+
} : {}
|
|
76911
|
+
);
|
|
76912
|
+
};
|
|
76899
76913
|
var BUCKET_NAME = process.env.AWS_BUCKET_NAME;
|
|
76900
76914
|
if (!BUCKET_NAME) {
|
|
76901
76915
|
throw new Error("'AWS_BUCKET_NAME' name not set");
|
|
@@ -77055,8 +77069,9 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77055
77069
|
return __async(this, null, function* () {
|
|
77056
77070
|
var _a2;
|
|
77057
77071
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
77072
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
77058
77073
|
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
77059
|
-
const list = yield
|
|
77074
|
+
const list = yield s3Client.send(
|
|
77060
77075
|
new ListObjectsCommand({
|
|
77061
77076
|
Bucket,
|
|
77062
77077
|
Prefix: savePath + "/",
|
|
@@ -77068,7 +77083,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77068
77083
|
}
|
|
77069
77084
|
for (const obj of list.Contents) {
|
|
77070
77085
|
if (!obj.Key) continue;
|
|
77071
|
-
const currentTags = yield
|
|
77086
|
+
const currentTags = yield s3Client.send(
|
|
77072
77087
|
new GetObjectTaggingCommand({
|
|
77073
77088
|
Bucket,
|
|
77074
77089
|
Key: obj.Key
|
|
@@ -77077,7 +77092,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77077
77092
|
const filteredTags = ((_a2 = currentTags.TagSet) == null ? void 0 : _a2.filter(
|
|
77078
77093
|
(t5) => !tags.includes(`${t5.Key}:${t5.Value}`)
|
|
77079
77094
|
)) || [];
|
|
77080
|
-
yield
|
|
77095
|
+
yield s3Client.send(
|
|
77081
77096
|
new PutObjectTaggingCommand({
|
|
77082
77097
|
Bucket,
|
|
77083
77098
|
Key: obj.Key,
|
|
@@ -77094,9 +77109,10 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77094
77109
|
if (!tags.length) {
|
|
77095
77110
|
return false;
|
|
77096
77111
|
}
|
|
77112
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
77097
77113
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
77098
77114
|
console.info(`addTag to bucket ${Bucket}`);
|
|
77099
|
-
const list = yield
|
|
77115
|
+
const list = yield s3Client.send(
|
|
77100
77116
|
new ListObjectsCommand({
|
|
77101
77117
|
Bucket,
|
|
77102
77118
|
Prefix: savePath + "/",
|
|
@@ -77116,7 +77132,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77116
77132
|
}
|
|
77117
77133
|
for (const obj of list.Contents) {
|
|
77118
77134
|
if (!obj.Key) continue;
|
|
77119
|
-
const currentTags = yield
|
|
77135
|
+
const currentTags = yield s3Client.send(
|
|
77120
77136
|
new GetObjectTaggingCommand({
|
|
77121
77137
|
Bucket,
|
|
77122
77138
|
Key: obj.Key
|
|
@@ -77135,7 +77151,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77135
77151
|
Key,
|
|
77136
77152
|
Value
|
|
77137
77153
|
}));
|
|
77138
|
-
yield
|
|
77154
|
+
yield s3Client.send(
|
|
77139
77155
|
new PutObjectTaggingCommand({
|
|
77140
77156
|
Bucket,
|
|
77141
77157
|
Key: obj.Key,
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,20 @@ var s3 = new S3Client(
|
|
|
57
57
|
}
|
|
58
58
|
} : {}
|
|
59
59
|
);
|
|
60
|
+
var getS3Client = (regionName) => {
|
|
61
|
+
if (regionName && regionName === process.env.AWS_REGION) {
|
|
62
|
+
return s3;
|
|
63
|
+
}
|
|
64
|
+
return new S3Client(
|
|
65
|
+
!process.env.AWS_EXECUTION_ENV && process.env.AWS_ACCESS_KEY_ID && process.env.AWS_ACCESS_KEY && regionName ? {
|
|
66
|
+
region: regionName,
|
|
67
|
+
credentials: {
|
|
68
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
69
|
+
secretAccessKey: process.env.AWS_ACCESS_KEY
|
|
70
|
+
}
|
|
71
|
+
} : {}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
60
74
|
var BUCKET_NAME = process.env.AWS_BUCKET_NAME;
|
|
61
75
|
if (!BUCKET_NAME) {
|
|
62
76
|
throw new Error("'AWS_BUCKET_NAME' name not set");
|
|
@@ -216,8 +230,9 @@ var S3Storage = class {
|
|
|
216
230
|
return __async(this, null, function* () {
|
|
217
231
|
var _a;
|
|
218
232
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
233
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
219
234
|
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
220
|
-
const list = yield
|
|
235
|
+
const list = yield s3Client.send(
|
|
221
236
|
new ListObjectsCommand({
|
|
222
237
|
Bucket,
|
|
223
238
|
Prefix: savePath + "/",
|
|
@@ -229,7 +244,7 @@ var S3Storage = class {
|
|
|
229
244
|
}
|
|
230
245
|
for (const obj of list.Contents) {
|
|
231
246
|
if (!obj.Key) continue;
|
|
232
|
-
const currentTags = yield
|
|
247
|
+
const currentTags = yield s3Client.send(
|
|
233
248
|
new GetObjectTaggingCommand({
|
|
234
249
|
Bucket,
|
|
235
250
|
Key: obj.Key
|
|
@@ -238,7 +253,7 @@ var S3Storage = class {
|
|
|
238
253
|
const filteredTags = ((_a = currentTags.TagSet) == null ? void 0 : _a.filter(
|
|
239
254
|
(t) => !tags.includes(`${t.Key}:${t.Value}`)
|
|
240
255
|
)) || [];
|
|
241
|
-
yield
|
|
256
|
+
yield s3Client.send(
|
|
242
257
|
new PutObjectTaggingCommand({
|
|
243
258
|
Bucket,
|
|
244
259
|
Key: obj.Key,
|
|
@@ -255,9 +270,10 @@ var S3Storage = class {
|
|
|
255
270
|
if (!tags.length) {
|
|
256
271
|
return false;
|
|
257
272
|
}
|
|
273
|
+
const s3Client = getS3Client(options == null ? void 0 : options.region);
|
|
258
274
|
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
259
275
|
console.info(`addTag to bucket ${Bucket}`);
|
|
260
|
-
const list = yield
|
|
276
|
+
const list = yield s3Client.send(
|
|
261
277
|
new ListObjectsCommand({
|
|
262
278
|
Bucket,
|
|
263
279
|
Prefix: savePath + "/",
|
|
@@ -277,7 +293,7 @@ var S3Storage = class {
|
|
|
277
293
|
}
|
|
278
294
|
for (const obj of list.Contents) {
|
|
279
295
|
if (!obj.Key) continue;
|
|
280
|
-
const currentTags = yield
|
|
296
|
+
const currentTags = yield s3Client.send(
|
|
281
297
|
new GetObjectTaggingCommand({
|
|
282
298
|
Bucket,
|
|
283
299
|
Key: obj.Key
|
|
@@ -296,7 +312,7 @@ var S3Storage = class {
|
|
|
296
312
|
Key,
|
|
297
313
|
Value
|
|
298
314
|
}));
|
|
299
|
-
yield
|
|
315
|
+
yield s3Client.send(
|
|
300
316
|
new PutObjectTaggingCommand({
|
|
301
317
|
Bucket,
|
|
302
318
|
Key: obj.Key,
|