importer-storage 1.0.21 → 1.0.26
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 +57 -4
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.global.js +57 -4
- package/dist/index.js +57 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -241,12 +241,14 @@ var S3Storage = class {
|
|
|
241
241
|
return { result, errored };
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
removeTag(savePath, tags) {
|
|
244
|
+
removeTag(savePath, tags, options) {
|
|
245
245
|
return __async(this, null, function* () {
|
|
246
246
|
var _a;
|
|
247
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
248
|
+
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
247
249
|
const list = yield s3.send(
|
|
248
250
|
new import_client_s3.ListObjectsCommand({
|
|
249
|
-
Bucket
|
|
251
|
+
Bucket,
|
|
250
252
|
Prefix: savePath + "/",
|
|
251
253
|
MaxKeys: 1e3
|
|
252
254
|
})
|
|
@@ -256,7 +258,7 @@ var S3Storage = class {
|
|
|
256
258
|
if (!obj.Key) continue;
|
|
257
259
|
const currentTags = yield s3.send(
|
|
258
260
|
new import_client_s3.GetObjectTaggingCommand({
|
|
259
|
-
Bucket
|
|
261
|
+
Bucket,
|
|
260
262
|
Key: obj.Key
|
|
261
263
|
})
|
|
262
264
|
);
|
|
@@ -265,7 +267,7 @@ var S3Storage = class {
|
|
|
265
267
|
)) || [];
|
|
266
268
|
yield s3.send(
|
|
267
269
|
new import_client_s3.PutObjectTaggingCommand({
|
|
268
|
-
Bucket
|
|
270
|
+
Bucket,
|
|
269
271
|
Key: obj.Key,
|
|
270
272
|
Tagging: { TagSet: filteredTags }
|
|
271
273
|
})
|
|
@@ -273,6 +275,57 @@ var S3Storage = class {
|
|
|
273
275
|
}
|
|
274
276
|
});
|
|
275
277
|
}
|
|
278
|
+
addTag(savePath, tags, options) {
|
|
279
|
+
return __async(this, null, function* () {
|
|
280
|
+
var _a;
|
|
281
|
+
if (!tags.length) return;
|
|
282
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
283
|
+
console.info(`addTag to bucket ${Bucket}`);
|
|
284
|
+
const list = yield s3.send(
|
|
285
|
+
new import_client_s3.ListObjectsCommand({
|
|
286
|
+
Bucket,
|
|
287
|
+
Prefix: savePath + "/",
|
|
288
|
+
MaxKeys: 1e3
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
if (!list.Contents) return;
|
|
292
|
+
const tagsToAdd = tags.map((tag) => {
|
|
293
|
+
const [key, value] = tag.split(":");
|
|
294
|
+
if (!key || value === void 0) return null;
|
|
295
|
+
return { Key: key, Value: value };
|
|
296
|
+
}).filter((t) => t !== null);
|
|
297
|
+
if (!tagsToAdd.length) return;
|
|
298
|
+
for (const obj of list.Contents) {
|
|
299
|
+
if (!obj.Key) continue;
|
|
300
|
+
const currentTags = yield s3.send(
|
|
301
|
+
new import_client_s3.GetObjectTaggingCommand({
|
|
302
|
+
Bucket,
|
|
303
|
+
Key: obj.Key
|
|
304
|
+
})
|
|
305
|
+
);
|
|
306
|
+
const existing = (_a = currentTags.TagSet) != null ? _a : [];
|
|
307
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
308
|
+
for (const t of existing) {
|
|
309
|
+
if (!t.Key || t.Value === void 0) continue;
|
|
310
|
+
tagMap.set(t.Key, t.Value);
|
|
311
|
+
}
|
|
312
|
+
for (const t of tagsToAdd) {
|
|
313
|
+
tagMap.set(t.Key, t.Value);
|
|
314
|
+
}
|
|
315
|
+
const mergedTags = Array.from(tagMap.entries()).map(([Key, Value]) => ({
|
|
316
|
+
Key,
|
|
317
|
+
Value
|
|
318
|
+
}));
|
|
319
|
+
yield s3.send(
|
|
320
|
+
new import_client_s3.PutObjectTaggingCommand({
|
|
321
|
+
Bucket,
|
|
322
|
+
Key: obj.Key,
|
|
323
|
+
Tagging: { TagSet: mergedTags }
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
276
329
|
};
|
|
277
330
|
|
|
278
331
|
// src/index.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type StorageTag = "delete:60d" | "delete:1d";
|
|
1
|
+
type StorageTag = "delete:60d" | "delete:1d" | "voted";
|
|
2
2
|
|
|
3
3
|
interface IStorage {
|
|
4
4
|
saveFiles(keys: Array<{
|
|
@@ -49,7 +49,12 @@ declare class S3Storage implements IStorage {
|
|
|
49
49
|
message: string;
|
|
50
50
|
}[];
|
|
51
51
|
}>;
|
|
52
|
-
removeTag(savePath: string, tags: Array<StorageTag
|
|
52
|
+
removeTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
53
|
+
bucketName: string;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
addTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
56
|
+
bucketName: string;
|
|
57
|
+
}): Promise<void>;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
declare const Storage: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type StorageTag = "delete:60d" | "delete:1d";
|
|
1
|
+
type StorageTag = "delete:60d" | "delete:1d" | "voted";
|
|
2
2
|
|
|
3
3
|
interface IStorage {
|
|
4
4
|
saveFiles(keys: Array<{
|
|
@@ -49,7 +49,12 @@ declare class S3Storage implements IStorage {
|
|
|
49
49
|
message: string;
|
|
50
50
|
}[];
|
|
51
51
|
}>;
|
|
52
|
-
removeTag(savePath: string, tags: Array<StorageTag
|
|
52
|
+
removeTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
53
|
+
bucketName: string;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
addTag(savePath: string, tags: Array<StorageTag>, options?: {
|
|
56
|
+
bucketName: string;
|
|
57
|
+
}): Promise<void>;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
declare const Storage: {
|
package/dist/index.global.js
CHANGED
|
@@ -77051,12 +77051,14 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77051
77051
|
return { result, errored };
|
|
77052
77052
|
});
|
|
77053
77053
|
}
|
|
77054
|
-
removeTag(savePath, tags) {
|
|
77054
|
+
removeTag(savePath, tags, options) {
|
|
77055
77055
|
return __async(this, null, function* () {
|
|
77056
77056
|
var _a2;
|
|
77057
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
77058
|
+
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
77057
77059
|
const list = yield s32.send(
|
|
77058
77060
|
new ListObjectsCommand({
|
|
77059
|
-
Bucket
|
|
77061
|
+
Bucket,
|
|
77060
77062
|
Prefix: savePath + "/",
|
|
77061
77063
|
MaxKeys: 1e3
|
|
77062
77064
|
})
|
|
@@ -77066,7 +77068,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77066
77068
|
if (!obj.Key) continue;
|
|
77067
77069
|
const currentTags = yield s32.send(
|
|
77068
77070
|
new GetObjectTaggingCommand({
|
|
77069
|
-
Bucket
|
|
77071
|
+
Bucket,
|
|
77070
77072
|
Key: obj.Key
|
|
77071
77073
|
})
|
|
77072
77074
|
);
|
|
@@ -77075,7 +77077,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77075
77077
|
)) || [];
|
|
77076
77078
|
yield s32.send(
|
|
77077
77079
|
new PutObjectTaggingCommand({
|
|
77078
|
-
Bucket
|
|
77080
|
+
Bucket,
|
|
77079
77081
|
Key: obj.Key,
|
|
77080
77082
|
Tagging: { TagSet: filteredTags }
|
|
77081
77083
|
})
|
|
@@ -77083,6 +77085,57 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
|
|
|
77083
77085
|
}
|
|
77084
77086
|
});
|
|
77085
77087
|
}
|
|
77088
|
+
addTag(savePath, tags, options) {
|
|
77089
|
+
return __async(this, null, function* () {
|
|
77090
|
+
var _a2;
|
|
77091
|
+
if (!tags.length) return;
|
|
77092
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
77093
|
+
console.info(`addTag to bucket ${Bucket}`);
|
|
77094
|
+
const list = yield s32.send(
|
|
77095
|
+
new ListObjectsCommand({
|
|
77096
|
+
Bucket,
|
|
77097
|
+
Prefix: savePath + "/",
|
|
77098
|
+
MaxKeys: 1e3
|
|
77099
|
+
})
|
|
77100
|
+
);
|
|
77101
|
+
if (!list.Contents) return;
|
|
77102
|
+
const tagsToAdd = tags.map((tag) => {
|
|
77103
|
+
const [key, value] = tag.split(":");
|
|
77104
|
+
if (!key || value === void 0) return null;
|
|
77105
|
+
return { Key: key, Value: value };
|
|
77106
|
+
}).filter((t5) => t5 !== null);
|
|
77107
|
+
if (!tagsToAdd.length) return;
|
|
77108
|
+
for (const obj of list.Contents) {
|
|
77109
|
+
if (!obj.Key) continue;
|
|
77110
|
+
const currentTags = yield s32.send(
|
|
77111
|
+
new GetObjectTaggingCommand({
|
|
77112
|
+
Bucket,
|
|
77113
|
+
Key: obj.Key
|
|
77114
|
+
})
|
|
77115
|
+
);
|
|
77116
|
+
const existing = (_a2 = currentTags.TagSet) != null ? _a2 : [];
|
|
77117
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
77118
|
+
for (const t5 of existing) {
|
|
77119
|
+
if (!t5.Key || t5.Value === void 0) continue;
|
|
77120
|
+
tagMap.set(t5.Key, t5.Value);
|
|
77121
|
+
}
|
|
77122
|
+
for (const t5 of tagsToAdd) {
|
|
77123
|
+
tagMap.set(t5.Key, t5.Value);
|
|
77124
|
+
}
|
|
77125
|
+
const mergedTags = Array.from(tagMap.entries()).map(([Key, Value]) => ({
|
|
77126
|
+
Key,
|
|
77127
|
+
Value
|
|
77128
|
+
}));
|
|
77129
|
+
yield s32.send(
|
|
77130
|
+
new PutObjectTaggingCommand({
|
|
77131
|
+
Bucket,
|
|
77132
|
+
Key: obj.Key,
|
|
77133
|
+
Tagging: { TagSet: mergedTags }
|
|
77134
|
+
})
|
|
77135
|
+
);
|
|
77136
|
+
}
|
|
77137
|
+
});
|
|
77138
|
+
}
|
|
77086
77139
|
};
|
|
77087
77140
|
|
|
77088
77141
|
// src/index.ts
|
package/dist/index.js
CHANGED
|
@@ -212,12 +212,14 @@ var S3Storage = class {
|
|
|
212
212
|
return { result, errored };
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
|
-
removeTag(savePath, tags) {
|
|
215
|
+
removeTag(savePath, tags, options) {
|
|
216
216
|
return __async(this, null, function* () {
|
|
217
217
|
var _a;
|
|
218
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
219
|
+
console.info(`RemoveTag to bucket ${Bucket}`);
|
|
218
220
|
const list = yield s3.send(
|
|
219
221
|
new ListObjectsCommand({
|
|
220
|
-
Bucket
|
|
222
|
+
Bucket,
|
|
221
223
|
Prefix: savePath + "/",
|
|
222
224
|
MaxKeys: 1e3
|
|
223
225
|
})
|
|
@@ -227,7 +229,7 @@ var S3Storage = class {
|
|
|
227
229
|
if (!obj.Key) continue;
|
|
228
230
|
const currentTags = yield s3.send(
|
|
229
231
|
new GetObjectTaggingCommand({
|
|
230
|
-
Bucket
|
|
232
|
+
Bucket,
|
|
231
233
|
Key: obj.Key
|
|
232
234
|
})
|
|
233
235
|
);
|
|
@@ -236,7 +238,7 @@ var S3Storage = class {
|
|
|
236
238
|
)) || [];
|
|
237
239
|
yield s3.send(
|
|
238
240
|
new PutObjectTaggingCommand({
|
|
239
|
-
Bucket
|
|
241
|
+
Bucket,
|
|
240
242
|
Key: obj.Key,
|
|
241
243
|
Tagging: { TagSet: filteredTags }
|
|
242
244
|
})
|
|
@@ -244,6 +246,57 @@ var S3Storage = class {
|
|
|
244
246
|
}
|
|
245
247
|
});
|
|
246
248
|
}
|
|
249
|
+
addTag(savePath, tags, options) {
|
|
250
|
+
return __async(this, null, function* () {
|
|
251
|
+
var _a;
|
|
252
|
+
if (!tags.length) return;
|
|
253
|
+
const Bucket = (options == null ? void 0 : options.bucketName) || BUCKET_NAME;
|
|
254
|
+
console.info(`addTag to bucket ${Bucket}`);
|
|
255
|
+
const list = yield s3.send(
|
|
256
|
+
new ListObjectsCommand({
|
|
257
|
+
Bucket,
|
|
258
|
+
Prefix: savePath + "/",
|
|
259
|
+
MaxKeys: 1e3
|
|
260
|
+
})
|
|
261
|
+
);
|
|
262
|
+
if (!list.Contents) return;
|
|
263
|
+
const tagsToAdd = tags.map((tag) => {
|
|
264
|
+
const [key, value] = tag.split(":");
|
|
265
|
+
if (!key || value === void 0) return null;
|
|
266
|
+
return { Key: key, Value: value };
|
|
267
|
+
}).filter((t) => t !== null);
|
|
268
|
+
if (!tagsToAdd.length) return;
|
|
269
|
+
for (const obj of list.Contents) {
|
|
270
|
+
if (!obj.Key) continue;
|
|
271
|
+
const currentTags = yield s3.send(
|
|
272
|
+
new GetObjectTaggingCommand({
|
|
273
|
+
Bucket,
|
|
274
|
+
Key: obj.Key
|
|
275
|
+
})
|
|
276
|
+
);
|
|
277
|
+
const existing = (_a = currentTags.TagSet) != null ? _a : [];
|
|
278
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
279
|
+
for (const t of existing) {
|
|
280
|
+
if (!t.Key || t.Value === void 0) continue;
|
|
281
|
+
tagMap.set(t.Key, t.Value);
|
|
282
|
+
}
|
|
283
|
+
for (const t of tagsToAdd) {
|
|
284
|
+
tagMap.set(t.Key, t.Value);
|
|
285
|
+
}
|
|
286
|
+
const mergedTags = Array.from(tagMap.entries()).map(([Key, Value]) => ({
|
|
287
|
+
Key,
|
|
288
|
+
Value
|
|
289
|
+
}));
|
|
290
|
+
yield s3.send(
|
|
291
|
+
new PutObjectTaggingCommand({
|
|
292
|
+
Bucket,
|
|
293
|
+
Key: obj.Key,
|
|
294
|
+
Tagging: { TagSet: mergedTags }
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
247
300
|
};
|
|
248
301
|
|
|
249
302
|
// src/index.ts
|