nuxt-filer 0.0.13 → 0.0.14
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/module.json
CHANGED
|
@@ -3,9 +3,10 @@ export function createS3Provider(options) {
|
|
|
3
3
|
const prefix = options.prefix ? options.prefix.replace(/\/+$/, "") + "/" : "";
|
|
4
4
|
let clientPromise;
|
|
5
5
|
const getClient = () => clientPromise ??= options.client ? Promise.resolve(options.client) : createAwsS3Client(options);
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const seg = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
7
|
+
const dataKey = (groupId, id) => `${prefix}${seg(groupId)}/data/${seg(id)}`;
|
|
8
|
+
const metaKey = (groupId, id) => `${prefix}${seg(groupId)}/meta/${seg(id)}`;
|
|
9
|
+
const metaPrefix = (groupId) => `${prefix}${seg(groupId)}/meta/`;
|
|
9
10
|
const groupIdFromMetaKey = (key) => {
|
|
10
11
|
const rel = key.slice(prefix.length);
|
|
11
12
|
return rel.slice(0, rel.lastIndexOf("/meta/"));
|
|
@@ -99,7 +100,7 @@ export function createS3Provider(options) {
|
|
|
99
100
|
},
|
|
100
101
|
async clear(groupId) {
|
|
101
102
|
const client = await getClient();
|
|
102
|
-
for await (const key of client.listKeys(`${prefix}${groupId}/`)) {
|
|
103
|
+
for await (const key of client.listKeys(`${prefix}${seg(groupId)}/`)) {
|
|
103
104
|
await client.delete(key);
|
|
104
105
|
}
|
|
105
106
|
},
|
package/package.json
CHANGED
|
@@ -56,9 +56,13 @@ export function createS3Provider(options: S3ProviderOptions): FileStorageProvide
|
|
|
56
56
|
? Promise.resolve(options.client)
|
|
57
57
|
: createAwsS3Client(options));
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
// Strip leading/trailing slashes so callers can pass `studio` or `/studio`
|
|
60
|
+
// interchangeably (the IPX integration hands group ids through with a leading
|
|
61
|
+
// slash). Without this, keys like `/studio/data/x` miss the stored object.
|
|
62
|
+
const seg = (value: string) => value.replace(/^\/+|\/+$/g, '');
|
|
63
|
+
const dataKey = (groupId: string, id: string) => `${prefix}${seg(groupId)}/data/${seg(id)}`;
|
|
64
|
+
const metaKey = (groupId: string, id: string) => `${prefix}${seg(groupId)}/meta/${seg(id)}`;
|
|
65
|
+
const metaPrefix = (groupId: string) => `${prefix}${seg(groupId)}/meta/`;
|
|
62
66
|
|
|
63
67
|
/** `${prefix}${groupId}/meta/${id}` → groupId (groups may contain '/'). */
|
|
64
68
|
const groupIdFromMetaKey = (key: string) => {
|
|
@@ -175,7 +179,7 @@ export function createS3Provider(options: S3ProviderOptions): FileStorageProvide
|
|
|
175
179
|
|
|
176
180
|
async clear(groupId) {
|
|
177
181
|
const client = await getClient();
|
|
178
|
-
for await (const key of client.listKeys(`${prefix}${groupId}/`)) {
|
|
182
|
+
for await (const key of client.listKeys(`${prefix}${seg(groupId)}/`)) {
|
|
179
183
|
await client.delete(key);
|
|
180
184
|
}
|
|
181
185
|
},
|