@did-space/core 0.3.7 → 0.3.9
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.
|
@@ -49,7 +49,7 @@ class GlobalSpace {
|
|
|
49
49
|
// @note: 注意此处必须存储到全局存储区
|
|
50
50
|
// eslint-disable-next-line no-param-reassign
|
|
51
51
|
options = (0, lodash_1.merge)(options, { useGlobal: true });
|
|
52
|
-
debug('add.before', JSON.stringify({ key, options }));
|
|
52
|
+
debug('add.before', JSON.stringify({ key, options: (0, lodash_1.omit)(options, 'data') }));
|
|
53
53
|
const { error } = schemas_1.WriteAsOwnerOptionsSchema.validate(Object.assign(Object.assign({}, options), { key,
|
|
54
54
|
data }), { allowUnknown: true, stripUnknown: true });
|
|
55
55
|
if (error) {
|
|
@@ -51,7 +51,7 @@ class ObjectSpace {
|
|
|
51
51
|
createSpace(spaceConfig) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
debug('createSpace.before', JSON.stringify(spaceConfig));
|
|
54
|
-
yield this.writeAsOwner('/', null
|
|
54
|
+
yield this.writeAsOwner('/', null);
|
|
55
55
|
yield this.createConfig(spaceConfig);
|
|
56
56
|
debug('createSpace.after', JSON.stringify(spaceConfig));
|
|
57
57
|
});
|
|
@@ -122,8 +122,12 @@ class ObjectSpace {
|
|
|
122
122
|
var _a, _b;
|
|
123
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
124
|
debug('verifySpace.before', { size });
|
|
125
|
+
// 创建的时候怎么做空间大小检测呢?目前是跳过检测的
|
|
126
|
+
if (!(yield this.isSpaceCreated())) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
125
129
|
const [did, capacity, usedCapacity] = yield Promise.all([
|
|
126
|
-
this.
|
|
130
|
+
this.spaceDid,
|
|
127
131
|
this.get('size'),
|
|
128
132
|
this.getSpaceSize(),
|
|
129
133
|
]);
|
|
@@ -149,7 +153,7 @@ class ObjectSpace {
|
|
|
149
153
|
}
|
|
150
154
|
// @note: 只有新增的时候才会触发检测
|
|
151
155
|
if (!(yield this.exists(options))) {
|
|
152
|
-
yield this.verifySpace(options.size);
|
|
156
|
+
yield this.verifySpace(options === null || options === void 0 ? void 0 : options.size);
|
|
153
157
|
}
|
|
154
158
|
const key = (0, path_1.join)(yield this.getAppSpacePath(options), options.key);
|
|
155
159
|
// @ts-expect-error
|
|
@@ -192,7 +196,7 @@ class ObjectSpace {
|
|
|
192
196
|
}
|
|
193
197
|
exists(options) {
|
|
194
198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
debug('exists.before', JSON.stringify({ options }));
|
|
199
|
+
debug('exists.before', JSON.stringify({ options: (0, lodash_1.omit)(options, 'data') }));
|
|
196
200
|
const key = (0, path_1.join)(yield this.getAppSpacePath(options), options.key);
|
|
197
201
|
return this.existsAsOwner(key);
|
|
198
202
|
});
|
|
@@ -403,7 +407,7 @@ class ObjectSpace {
|
|
|
403
407
|
* @return {*} {Promise<void>}
|
|
404
408
|
* @memberof ObjectSpace
|
|
405
409
|
*/
|
|
406
|
-
writeAsOwner(key, data, options = { hash: null, size:
|
|
410
|
+
writeAsOwner(key, data, options = { hash: null, size: 0 }) {
|
|
407
411
|
return __awaiter(this, void 0, void 0, function* () {
|
|
408
412
|
debug('writeAsOwner.before', JSON.stringify({ key, options: (0, lodash_1.omit)(options, 'data') }));
|
|
409
413
|
const { error } = schemas_1.WriteAsOwnerOptionsSchema.validate(Object.assign(Object.assign({}, options), { key,
|
|
@@ -429,7 +433,7 @@ class ObjectSpace {
|
|
|
429
433
|
}
|
|
430
434
|
else {
|
|
431
435
|
// @note: 只有新增的时候才会触发检测
|
|
432
|
-
yield this.verifySpace(options.size);
|
|
436
|
+
yield this.verifySpace(options === null || options === void 0 ? void 0 : options.size);
|
|
433
437
|
// 添加新对象
|
|
434
438
|
yield this._createAsOwner(key, data, options);
|
|
435
439
|
}
|
|
@@ -557,12 +561,13 @@ class ObjectSpace {
|
|
|
557
561
|
}
|
|
558
562
|
createConfig(spaceConfig) {
|
|
559
563
|
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
+
debug('createConfig.before', { spaceConfig });
|
|
560
565
|
const data = js_yaml_1.default.dump(spaceConfig);
|
|
561
566
|
const hash = yield (0, utils_1.getHash)(data);
|
|
562
567
|
const size = (0, utils_1.getSize)(data);
|
|
563
|
-
debug('
|
|
564
|
-
debug('
|
|
565
|
-
debug('
|
|
568
|
+
debug('createConfig.$data', data);
|
|
569
|
+
debug('createConfig.$hash', hash);
|
|
570
|
+
debug('createConfig.$size', size);
|
|
566
571
|
yield this.writeAsOwner('/config.yml', data, {
|
|
567
572
|
hash,
|
|
568
573
|
size,
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-space/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "Decentralized file space managed by DID",
|
|
8
|
-
"author":
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "arcblock",
|
|
10
|
+
"email": "blocklet@arcblock.io",
|
|
11
|
+
"url": "https://github.com/blocklet"
|
|
12
|
+
},
|
|
9
13
|
"homepage": "",
|
|
10
14
|
"license": "ISC",
|
|
11
15
|
"main": "dist/index.js",
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
]
|
|
33
37
|
},
|
|
34
38
|
"dependencies": {
|
|
35
|
-
"@arcblock/validator": "^1.18.
|
|
39
|
+
"@arcblock/validator": "^1.18.91",
|
|
36
40
|
"debug": "^4.3.4",
|
|
37
41
|
"hasha": "^5.2.2",
|
|
38
42
|
"ipfs-only-hash": "^4.0.0",
|
|
@@ -56,5 +60,5 @@
|
|
|
56
60
|
"ts-jest": "^28.0.6",
|
|
57
61
|
"typescript": "^4.9.5"
|
|
58
62
|
},
|
|
59
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "82db55693ead83d0185ae410b0660a53f996a6e9"
|
|
60
64
|
}
|