@did-space/core 1.1.9 → 1.1.11
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/cjs/space/object-space.js +25 -21
- package/dist/es/space/object-space.js +27 -15
- package/package.json +3 -3
|
@@ -213,10 +213,7 @@ class ObjectSpace extends events_1.default {
|
|
|
213
213
|
}
|
|
214
214
|
debug('listsOneLevel.$parentTree', JSON.stringify(parentTree, null, 2));
|
|
215
215
|
const trees = yield this.options.treeRepository.findAll({
|
|
216
|
-
where: {
|
|
217
|
-
spaceDid: this.options.spaceDid,
|
|
218
|
-
parentId: parentTree.id,
|
|
219
|
-
},
|
|
216
|
+
where: Object.assign({ spaceDid: this.options.spaceDid, parentId: parentTree.id }, (options.ignoreDirectories ? { type: model_1.TreeModelType.FILE } : {})),
|
|
220
217
|
include: this.options.objectRepository,
|
|
221
218
|
});
|
|
222
219
|
return Promise.all(trees.map((x) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -253,18 +250,29 @@ class ObjectSpace extends events_1.default {
|
|
|
253
250
|
listsRecursiveAsOwner(options) {
|
|
254
251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
252
|
debug('listsRecursiveAsOwner.before', JSON.stringify(options));
|
|
256
|
-
const where = {
|
|
257
|
-
spaceDid: this.options.spaceDid,
|
|
258
|
-
key: {
|
|
253
|
+
const where = Object.assign({ spaceDid: this.options.spaceDid, key: {
|
|
259
254
|
[sequelize_1.Op.like]: `${options.key}%`,
|
|
260
|
-
},
|
|
261
|
-
type: model_1.TreeModelType.FILE,
|
|
262
|
-
};
|
|
255
|
+
} }, (options.ignoreDirectories ? { type: model_1.TreeModelType.FILE } : {}));
|
|
263
256
|
const trees = yield this.options.treeRepository.findAll({
|
|
264
257
|
where,
|
|
265
258
|
include: this.options.objectRepository,
|
|
266
259
|
});
|
|
267
|
-
return trees.map((x) => {
|
|
260
|
+
return Promise.all(trees.map((x) => __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
const absolutePath = (0, path_1.join)(x.spaceDid, x.key);
|
|
262
|
+
if (x.type === model_1.TreeModelType.FOLDER) {
|
|
263
|
+
const { size, lastModified } = yield this.getStatusAsOwner(x.key);
|
|
264
|
+
return {
|
|
265
|
+
key: x.key,
|
|
266
|
+
name: (0, path_1.basename)(x.key),
|
|
267
|
+
isDir: true,
|
|
268
|
+
size,
|
|
269
|
+
lastModified: lastModified || new Date(x.updatedAt).getTime(),
|
|
270
|
+
editable: true,
|
|
271
|
+
mimeType: null,
|
|
272
|
+
absolutePath,
|
|
273
|
+
metadata: x.meta,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
268
276
|
return {
|
|
269
277
|
key: x.key,
|
|
270
278
|
name: (0, path_1.basename)(x.key),
|
|
@@ -274,10 +282,10 @@ class ObjectSpace extends events_1.default {
|
|
|
274
282
|
editable: true,
|
|
275
283
|
mimeType: x.Object.meta.mimeType,
|
|
276
284
|
hash: x.objectId,
|
|
277
|
-
absolutePath
|
|
285
|
+
absolutePath,
|
|
278
286
|
metadata: x.meta,
|
|
279
287
|
};
|
|
280
|
-
});
|
|
288
|
+
})));
|
|
281
289
|
});
|
|
282
290
|
}
|
|
283
291
|
/**
|
|
@@ -296,14 +304,10 @@ class ObjectSpace extends events_1.default {
|
|
|
296
304
|
if (!options.recursive) {
|
|
297
305
|
return this.listsOneLevelAsOwner(options);
|
|
298
306
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
debug('lists.after', JSON.stringify(options));
|
|
306
|
-
throw new Error(`Filter methods not yet supported:\n ${JSON.stringify(options, null, 2)}`);
|
|
307
|
+
const objects = yield this.listsRecursiveAsOwner(options);
|
|
308
|
+
return objects.map((x) => {
|
|
309
|
+
return Object.assign(Object.assign({}, x), { key: x.key.replace(options.key, '/') });
|
|
310
|
+
});
|
|
307
311
|
});
|
|
308
312
|
}
|
|
309
313
|
/**
|
|
@@ -182,6 +182,7 @@ export class ObjectSpace extends EventEmitter {
|
|
|
182
182
|
where: {
|
|
183
183
|
spaceDid: this.options.spaceDid,
|
|
184
184
|
parentId: parentTree.id,
|
|
185
|
+
...(options.ignoreDirectories ? { type: TreeModelType.FILE } : {}),
|
|
185
186
|
},
|
|
186
187
|
include: this.options.objectRepository,
|
|
187
188
|
});
|
|
@@ -222,13 +223,28 @@ export class ObjectSpace extends EventEmitter {
|
|
|
222
223
|
key: {
|
|
223
224
|
[Op.like]: `${options.key}%`,
|
|
224
225
|
},
|
|
225
|
-
type: TreeModelType.FILE,
|
|
226
|
+
...(options.ignoreDirectories ? { type: TreeModelType.FILE } : {}),
|
|
226
227
|
};
|
|
227
228
|
const trees = await this.options.treeRepository.findAll({
|
|
228
229
|
where,
|
|
229
230
|
include: this.options.objectRepository,
|
|
230
231
|
});
|
|
231
|
-
return trees.map((x) => {
|
|
232
|
+
return Promise.all(trees.map(async (x) => {
|
|
233
|
+
const absolutePath = join(x.spaceDid, x.key);
|
|
234
|
+
if (x.type === TreeModelType.FOLDER) {
|
|
235
|
+
const { size, lastModified } = await this.getStatusAsOwner(x.key);
|
|
236
|
+
return {
|
|
237
|
+
key: x.key,
|
|
238
|
+
name: basename(x.key),
|
|
239
|
+
isDir: true,
|
|
240
|
+
size,
|
|
241
|
+
lastModified: lastModified || new Date(x.updatedAt).getTime(),
|
|
242
|
+
editable: true,
|
|
243
|
+
mimeType: null,
|
|
244
|
+
absolutePath,
|
|
245
|
+
metadata: x.meta,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
232
248
|
return {
|
|
233
249
|
key: x.key,
|
|
234
250
|
name: basename(x.key),
|
|
@@ -238,10 +254,10 @@ export class ObjectSpace extends EventEmitter {
|
|
|
238
254
|
editable: true,
|
|
239
255
|
mimeType: x.Object.meta.mimeType,
|
|
240
256
|
hash: x.objectId,
|
|
241
|
-
absolutePath
|
|
257
|
+
absolutePath,
|
|
242
258
|
metadata: x.meta,
|
|
243
259
|
};
|
|
244
|
-
});
|
|
260
|
+
}));
|
|
245
261
|
}
|
|
246
262
|
/**
|
|
247
263
|
* @description 后续改名为 listsAsOwner 更合适
|
|
@@ -258,17 +274,13 @@ export class ObjectSpace extends EventEmitter {
|
|
|
258
274
|
if (!options.recursive) {
|
|
259
275
|
return this.listsOneLevelAsOwner(options);
|
|
260
276
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
debug('lists.after', JSON.stringify(options));
|
|
271
|
-
throw new Error(`Filter methods not yet supported:\n ${JSON.stringify(options, null, 2)}`);
|
|
277
|
+
const objects = await this.listsRecursiveAsOwner(options);
|
|
278
|
+
return objects.map((x) => {
|
|
279
|
+
return {
|
|
280
|
+
...x,
|
|
281
|
+
key: x.key.replace(options.key, '/'),
|
|
282
|
+
};
|
|
283
|
+
});
|
|
272
284
|
}
|
|
273
285
|
/**
|
|
274
286
|
* @FIXME: 接口的功能实际应该是 listAsOwner 实现的,属于技术债 @jianchao
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-space/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"@arcblock/did": "^1.21.0",
|
|
112
112
|
"@arcblock/ipfs-only-hash": "^0.0.2",
|
|
113
113
|
"@arcblock/validator": "^1.21.0",
|
|
114
|
-
"@did-space/constants": "^1.1.
|
|
114
|
+
"@did-space/constants": "^1.1.11",
|
|
115
115
|
"dayjs": "^1.11.13",
|
|
116
116
|
"debug": "^4.4.1",
|
|
117
117
|
"destroy": "^1.2.0",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"vite": "^7.0.0",
|
|
143
143
|
"vitest": "^3.2.4"
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "15de6ef2b864293e7aabfa115637e8bfafe62ee4"
|
|
146
146
|
}
|