@did-space/fs-driver 0.2.117 → 0.2.119

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.
@@ -36,9 +36,7 @@ class FsSpaceConfig {
36
36
  });
37
37
  }
38
38
  destroyConfig() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return fs_extra_1.default.remove(this.key);
41
- });
39
+ return fs_extra_1.default.remove(this.key);
42
40
  }
43
41
  // FIXME: @yejianchao 待实现,可以把key对应的Value的类型也带出来?我想到了一种方法,但是我觉得太粗糙了
44
42
  set(key, value) {
@@ -85,19 +83,13 @@ class FsSpaceConfig {
85
83
  });
86
84
  }
87
85
  setListable(options, status) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- return this.setPermission(options, core_1.Scopes['list:object'], status);
90
- });
86
+ return this.setPermission(options, core_1.Scopes['list:object'], status);
91
87
  }
92
88
  setReadable(options, status) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- return this.setPermission(options, core_1.Scopes['read:object'], status);
95
- });
89
+ return this.setPermission(options, core_1.Scopes['read:object'], status);
96
90
  }
97
91
  setWritable(options, status) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- return this.setPermission(options, core_1.Scopes['write:object'], status);
100
- });
92
+ return this.setPermission(options, core_1.Scopes['write:object'], status);
101
93
  }
102
94
  isListable(options) {
103
95
  return __awaiter(this, void 0, void 0, function* () {
@@ -29,19 +29,14 @@ class FsSpaceOperator {
29
29
  }
30
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
31
  createSpace(_spaceConfig) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return fs_extra_1.default.ensureDir(this.options.root);
34
- });
32
+ return fs_extra_1.default.ensureDir(this.options.root);
35
33
  }
36
34
  destroySpace() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return fs_extra_1.default.remove(this.options.root);
39
- });
35
+ return fs_extra_1.default.remove(this.options.root);
40
36
  }
41
37
  isSpaceCreated() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- return fs_extra_1.default.existsSync(this.options.root);
44
- });
38
+ // @ts-expect-error
39
+ return fs_extra_1.default.existsSync(this.options.root);
45
40
  }
46
41
  getSpaceSize() {
47
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -50,23 +45,22 @@ class FsSpaceOperator {
50
45
  });
51
46
  }
52
47
  getPathStatus(path) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const files = filehound_1.default.create()
55
- .paths(path)
56
- .includeFileStats()
57
- .findSync();
58
- const pathStatus = files.reduce((_pathStatus, file) => {
59
- _pathStatus.size += file.stats.size;
60
- _pathStatus.objects++;
61
- _pathStatus.lastModified = Math.max(new Date(file.stats.mtime).getTime(), _pathStatus.lastModified);
62
- return _pathStatus;
63
- }, {
64
- size: 0,
65
- objects: 0,
66
- lastModified: 0,
67
- });
68
- return pathStatus;
69
- });
48
+ const files = filehound_1.default.create()
49
+ .paths(path)
50
+ .includeFileStats()
51
+ .findSync();
52
+ const pathStatus = files.reduce((_pathStatus, file) => {
53
+ _pathStatus.size += file.stats.size;
54
+ _pathStatus.objects++;
55
+ _pathStatus.lastModified = Math.max(new Date(file.stats.mtime).getTime(), _pathStatus.lastModified);
56
+ return _pathStatus;
57
+ }, {
58
+ size: 0,
59
+ objects: 0,
60
+ lastModified: 0,
61
+ });
62
+ // @ts-expect-error
63
+ return pathStatus;
70
64
  }
71
65
  createAppSpace(options) {
72
66
  return __awaiter(this, void 0, void 0, function* () {
@@ -79,9 +73,8 @@ class FsSpaceOperator {
79
73
  });
80
74
  }
81
75
  getAppSpacePath(options) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- return (0, path_1.join)(this.options.root, FsSpaceOperator.APPS, options.appDid);
84
- });
76
+ // @ts-expect-error
77
+ return (0, path_1.join)(this.options.root, FsSpaceOperator.APPS, options.appDid);
85
78
  }
86
79
  getObjectKey(options) {
87
80
  return __awaiter(this, void 0, void 0, function* () {
@@ -196,25 +189,24 @@ class FsSpaceOperator {
196
189
  });
197
190
  }
198
191
  list(options) {
199
- return __awaiter(this, void 0, void 0, function* () {
200
- const objectKey = (0, path_1.join)(this.options.root, options.key);
201
- if (!fs_extra_1.default.existsSync(objectKey)) {
202
- return null;
203
- }
204
- const fileStat = fs_extra_1.default.statSync(objectKey);
205
- const objectName = (0, path_1.basename)(objectKey);
206
- const directorySuffixes = fileStat.isDirectory() ? '/' : '';
207
- const key = (0, path_1.join)(options.key, directorySuffixes);
208
- return {
209
- key,
210
- name: (0, path_1.join)(objectName, directorySuffixes),
211
- isDir: fileStat.isDirectory(),
212
- size: fileStat.size,
213
- lastModified: new Date(fileStat.mtime).getTime(),
214
- editable: core_1.Space.editable(key),
215
- mimeType: mime_types_1.default.lookup(objectName) || 'unknown',
216
- };
217
- });
192
+ const objectKey = (0, path_1.join)(this.options.root, options.key);
193
+ if (!fs_extra_1.default.existsSync(objectKey)) {
194
+ return null;
195
+ }
196
+ const fileStat = fs_extra_1.default.statSync(objectKey);
197
+ const objectName = (0, path_1.basename)(objectKey);
198
+ const directorySuffixes = fileStat.isDirectory() ? '/' : '';
199
+ const key = (0, path_1.join)(options.key, directorySuffixes);
200
+ return {
201
+ // @ts-expect-error
202
+ key,
203
+ name: (0, path_1.join)(objectName, directorySuffixes),
204
+ isDir: fileStat.isDirectory(),
205
+ size: fileStat.size,
206
+ lastModified: new Date(fileStat.mtime).getTime(),
207
+ editable: core_1.Space.editable(key),
208
+ mimeType: mime_types_1.default.lookup(objectName) || 'unknown',
209
+ };
218
210
  }
219
211
  writeAsOwner(key, data) {
220
212
  return __awaiter(this, void 0, void 0, function* () {
@@ -236,20 +228,15 @@ class FsSpaceOperator {
236
228
  });
237
229
  }
238
230
  deleteAsOwner(key) {
239
- return __awaiter(this, void 0, void 0, function* () {
240
- return fs_extra_1.default.remove((0, path_1.join)(this.options.root, key));
241
- });
231
+ return fs_extra_1.default.remove((0, path_1.join)(this.options.root, key));
242
232
  }
243
233
  readAsOwner(key) {
244
- return __awaiter(this, void 0, void 0, function* () {
245
- // FIXME: @yejianchao 应该可以refactor,但是我还需要测试一下
246
- return fs_extra_1.default.readFile((0, path_1.join)(this.options.root, key)).then((data) => stream_1.Readable.from(data));
247
- });
234
+ // FIXME: @yejianchao 应该可以refactor,但是我还需要测试一下
235
+ return fs_extra_1.default.readFile((0, path_1.join)(this.options.root, key)).then((data) => stream_1.Readable.from(data));
248
236
  }
249
237
  existsAsOwner(key) {
250
- return __awaiter(this, void 0, void 0, function* () {
251
- return fs_extra_1.default.existsSync((0, path_1.join)(this.options.root, key));
252
- });
238
+ // @ts-expect-error
239
+ return fs_extra_1.default.existsSync((0, path_1.join)(this.options.root, key));
253
240
  }
254
241
  }
255
242
  exports.FsSpaceOperator = FsSpaceOperator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-space/fs-driver",
3
- "version": "0.2.117",
3
+ "version": "0.2.119",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,7 +32,7 @@
32
32
  ]
33
33
  },
34
34
  "dependencies": {
35
- "@did-space/core": "0.2.117",
35
+ "@did-space/core": "0.2.119",
36
36
  "filehound": "^1.17.6",
37
37
  "fs-extra": "^10.1.0",
38
38
  "hasha": "^5.2.2",
@@ -42,7 +42,7 @@
42
42
  "url-join": "4"
43
43
  },
44
44
  "devDependencies": {
45
- "@arcblock/eslint-config-ts": "^0.2.3",
45
+ "@arcblock/eslint-config-ts": "^0.2.4",
46
46
  "@types/fs-extra": "^9.0.13",
47
47
  "@types/jest": "^28.1.5",
48
48
  "@types/js-yaml": "^4.0.5",
@@ -55,5 +55,5 @@
55
55
  "ts-jest": "^28.0.6",
56
56
  "typescript": "^4.9.5"
57
57
  },
58
- "gitHead": "7f3de10d1715d6dba780f616b7d1234f65bb449b"
58
+ "gitHead": "4c9699445ad354540b197e14e663b9c564cba0c2"
59
59
  }