fsd-oss 0.13.2 → 0.13.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.
package/lib/index.js CHANGED
@@ -204,8 +204,10 @@ class OSSAdapter {
204
204
  }
205
205
  const { root } = this._options;
206
206
  let p = slash(Path.join(root, path)).substring(1);
207
- let results = [];
207
+ let results = Object.create(null);
208
208
  let continuationToken = '';
209
+ let hasContents = false;
210
+ let hasCommonPrefixes = false;
209
211
  do {
210
212
  let list = await this._oss.list({
211
213
  prefix: p,
@@ -216,6 +218,7 @@ class OSSAdapter {
216
218
  debug('list: %O', list);
217
219
  continuationToken = list.NextContinuationToken;
218
220
  if (list.Contents) {
221
+ hasContents = true;
219
222
  list.Contents.forEach((object) => {
220
223
  let relative = slash(Path.relative(p, object.Key));
221
224
  if (!relative)
@@ -224,17 +227,34 @@ class OSSAdapter {
224
227
  relative += '/';
225
228
  if (pattern && pattern !== '**/*' && !minimatch(relative, pattern))
226
229
  return;
227
- results.push({
230
+ results[relative] = {
228
231
  name: relative,
229
232
  metadata: {
230
233
  size: object.Size,
231
234
  lastModified: new Date(object.LastModified)
232
235
  }
233
- });
236
+ };
237
+ });
238
+ }
239
+ if (list.CommonPrefixes) {
240
+ hasCommonPrefixes = true;
241
+ list.CommonPrefixes.forEach((prefix) => {
242
+ let relative = slash(Path.relative(p, prefix.Prefix));
243
+ if (!relative)
244
+ return;
245
+ relative += '/';
246
+ results[relative] = {
247
+ name: relative
248
+ };
234
249
  });
235
250
  }
236
251
  } while (continuationToken);
237
- return results;
252
+ if (hasContents && hasCommonPrefixes) {
253
+ return Object.keys(results)
254
+ .sort()
255
+ .map((key) => results[key]);
256
+ }
257
+ return Object.values(results);
238
258
  }
239
259
  async createUrl(path, options) {
240
260
  debug('createUrl %s', path);
@@ -86,6 +86,10 @@ class SimpleOSSClient {
86
86
  content.Size = parseInt(content.Size);
87
87
  });
88
88
  }
89
+ if (res.CommonPrefixes) {
90
+ if (!Array.isArray(res.CommonPrefixes))
91
+ res.CommonPrefixes = [res.CommonPrefixes];
92
+ }
89
93
  return res;
90
94
  }
91
95
  del(name, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fsd-oss",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Aliyun OSS adapter for fsd",
5
5
  "main": "lib/index.js",
6
6
  "types": "index.d.ts",
@@ -15,12 +15,12 @@
15
15
  "@alicloud/pop-core": "^1.7.13",
16
16
  "akita": "^1.0.4",
17
17
  "async": "*",
18
- "crypto-js": "^4.1.1",
18
+ "crypto-js": "^4.2.0",
19
19
  "debug": "^4.3.4",
20
20
  "mime-types": "^2.1.35",
21
21
  "minimatch": "^3.1.2",
22
22
  "slash": "^3.0.0",
23
23
  "xml2js": "^0.6.2"
24
24
  },
25
- "gitHead": "f5aaaca713f514d3a8fb65bc2eecd1e8df8fd5c8"
25
+ "gitHead": "035c0e59b51166498ce13f66fc1316099fe77566"
26
26
  }
@@ -105,6 +105,7 @@ export interface ListResult extends Result {
105
105
  KeyCount: number;
106
106
  NextContinuationToken?: string;
107
107
  Contents: ListResultContent[];
108
+ CommonPrefixes: ListResultCommonPrefixes[];
108
109
  }
109
110
 
110
111
  export interface ListResultContent {
@@ -119,6 +120,10 @@ export interface ListResultContent {
119
120
  };
120
121
  }
121
122
 
123
+ export interface ListResultCommonPrefixes {
124
+ Prefix: string;
125
+ }
126
+
122
127
  export interface DeleteMultiOptions extends RequestOptions {
123
128
  quiet?: boolean;
124
129
  }