@did-space/core 0.5.50 → 0.5.51
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/constants/index.d.ts +1 -0
- package/dist/constants/index.js +2 -1
- package/dist/model/app-space-apply.d.ts +13 -0
- package/dist/model/app-space-apply.js +5 -0
- package/dist/model/did-object-mapping.d.ts +8 -0
- package/dist/model/did-object-mapping.js +8 -0
- package/dist/schemas/object-space.js +2 -1
- package/dist/space/object-space.d.ts +4 -1
- package/dist/space/object-space.js +20 -5
- package/package.json +4 -4
package/dist/constants/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APP = exports.HEADERS = exports.APP_BACKUP_STATUS = exports.DID_OBJECTS = exports.APPS = void 0;
|
|
3
|
+
exports.GLOBAL_SPACE_ROOT = exports.APP = exports.HEADERS = exports.APP_BACKUP_STATUS = exports.DID_OBJECTS = exports.APPS = void 0;
|
|
4
4
|
exports.APPS = 'apps';
|
|
5
5
|
exports.DID_OBJECTS = '.did-objects';
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -26,3 +26,4 @@ exports.APP = {
|
|
|
26
26
|
FOLDER_PREFIX: '.components',
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
+
exports.GLOBAL_SPACE_ROOT = '__GLOBAL__';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Model } from 'sequelize';
|
|
1
2
|
import type { AppPermissions } from '../meta';
|
|
2
3
|
export interface AppSpaceApplyModel {
|
|
3
4
|
/**
|
|
@@ -60,3 +61,15 @@ export interface AppSpaceApplyModel {
|
|
|
60
61
|
*/
|
|
61
62
|
export interface CreationAppSpaceApplyModel extends Omit<AppSpaceApplyModel, 'id'> {
|
|
62
63
|
}
|
|
64
|
+
export declare class AppSpaceApplyRepository extends Model<AppSpaceApplyModel, CreationAppSpaceApplyModel> {
|
|
65
|
+
id: string;
|
|
66
|
+
storageDid: string;
|
|
67
|
+
assetDid: string;
|
|
68
|
+
ownerDid: string;
|
|
69
|
+
appDid: string;
|
|
70
|
+
appName: string;
|
|
71
|
+
appDescription: string | null;
|
|
72
|
+
metadata: Record<string, unknown>;
|
|
73
|
+
createAt: Date;
|
|
74
|
+
updateAt: Date;
|
|
75
|
+
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppSpaceApplyRepository = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
class AppSpaceApplyRepository extends sequelize_1.Model {
|
|
6
|
+
}
|
|
7
|
+
exports.AppSpaceApplyRepository = AppSpaceApplyRepository;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Model, type InferAttributes } from 'sequelize';
|
|
2
|
+
export declare class DidObjectMappingRepository extends Model<InferAttributes<DidObjectMappingRepository>, InferAttributes<DidObjectMappingRepository>> {
|
|
3
|
+
did: string;
|
|
4
|
+
spaceDid: string;
|
|
5
|
+
appDid: string;
|
|
6
|
+
key: string;
|
|
7
|
+
metadata: Record<string, string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DidObjectMappingRepository = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
5
|
+
const sequelize_1 = require("sequelize");
|
|
6
|
+
class DidObjectMappingRepository extends sequelize_1.Model {
|
|
7
|
+
}
|
|
8
|
+
exports.DidObjectMappingRepository = DidObjectMappingRepository;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetHashOptionsSchema = exports.WriteOptionsSchema = exports.DeleteAsOwnerOptionsSchema = exports.ObjectSpaceOptionsSchema = exports.WriteAsOwnerOptionsSchema = exports.OwnerOperatorKeySchema = void 0;
|
|
4
4
|
const validator_1 = require("@arcblock/validator");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
5
6
|
exports.OwnerOperatorKeySchema = validator_1.Joi.string().regex(/^\//).required();
|
|
6
7
|
const WriteAsOwnerOptionsByFolderSchema = {
|
|
7
8
|
is: validator_1.Joi.string().regex(/\/$/),
|
|
@@ -24,7 +25,7 @@ exports.WriteAsOwnerOptionsSchema = validator_1.Joi.object({
|
|
|
24
25
|
});
|
|
25
26
|
exports.ObjectSpaceOptionsSchema = validator_1.Joi.object({
|
|
26
27
|
driver: validator_1.Joi.any().required(),
|
|
27
|
-
spaceDid: validator_1.Joi.DID().required(),
|
|
28
|
+
spaceDid: validator_1.Joi.alternatives().try(validator_1.Joi.DID(), validator_1.Joi.string().valid(constants_1.GLOBAL_SPACE_ROOT)).required(),
|
|
28
29
|
treeRepository: validator_1.Joi.any().required(),
|
|
29
30
|
objectRepository: validator_1.Joi.any().required(),
|
|
30
31
|
objectCollectionRepository: validator_1.Joi.any().required(),
|
|
@@ -5,9 +5,10 @@ import EventEmitter from 'events';
|
|
|
5
5
|
import { SpaceConfig } from '../configuration';
|
|
6
6
|
import type { Object, Data } from '../meta';
|
|
7
7
|
import { AppSpaceOptions, DeleteOptions, DriverProtocol, GetHashOptions, KeyStatus, ListOptions, ListsOptions, PermissionOptions, ReadAsOwnerOptions, ReadOptions, SpaceProtocol, WriteAsOwnerOptions, WriteOptions } from '../protocols';
|
|
8
|
-
import { ObjectCollectionRepository, ObjectRepository, TreeRepository } from '../model';
|
|
8
|
+
import { ObjectCollectionRepository, ObjectRepository, TreeRepository, type AppSpaceApplyRepository } from '../model';
|
|
9
9
|
import { GlobalSpace } from './global-space';
|
|
10
10
|
import type { SpaceRepository } from '../model/space';
|
|
11
|
+
import type { DidObjectMappingRepository } from '../model/did-object-mapping';
|
|
11
12
|
export type ObjectSpaceOptions = {
|
|
12
13
|
driver: DriverProtocol;
|
|
13
14
|
spaceDid: string;
|
|
@@ -15,6 +16,8 @@ export type ObjectSpaceOptions = {
|
|
|
15
16
|
objectRepository: ObjectRepository;
|
|
16
17
|
objectCollectionRepository: ObjectCollectionRepository;
|
|
17
18
|
spaceRepository: SpaceRepository;
|
|
19
|
+
appSpaceApplyRepository: typeof AppSpaceApplyRepository;
|
|
20
|
+
didObjectMappingRepository: typeof DidObjectMappingRepository;
|
|
18
21
|
/**
|
|
19
22
|
* @description 忽略存储容量限制吗?
|
|
20
23
|
* @type {(false | true)}
|
|
@@ -78,6 +78,22 @@ class ObjectSpace extends events_1.default {
|
|
|
78
78
|
destroySpace() {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
yield this.deleteAsOwner('/');
|
|
81
|
+
const { spaceDid } = this.options;
|
|
82
|
+
yield this.options.appSpaceApplyRepository.destroy({
|
|
83
|
+
where: {
|
|
84
|
+
storageDid: spaceDid,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
yield this.options.didObjectMappingRepository.destroy({
|
|
88
|
+
where: {
|
|
89
|
+
spaceDid,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
yield this.options.spaceRepository.destroy({
|
|
93
|
+
where: {
|
|
94
|
+
did: spaceDid,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
81
97
|
});
|
|
82
98
|
}
|
|
83
99
|
getSpaceSize() {
|
|
@@ -500,15 +516,14 @@ class ObjectSpace extends events_1.default {
|
|
|
500
516
|
},
|
|
501
517
|
};
|
|
502
518
|
debug('deleteAsOwner.$whereForDeleteFolder', JSON.stringify(whereForDeleteFolder));
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
519
|
+
yield this.options.objectCollectionRepository.sequelize.query(`INSERT OR REPLACE INTO ${this.options.objectCollectionRepository.tableName} (id, createdAt)
|
|
520
|
+
SELECT distinct objectId, strftime('%Y-%m-%d %H:%M:%f +00:00',DATETIME('now'))
|
|
521
|
+
FROM ${this.options.treeRepository.tableName} where spaceDid = '${this.options.spaceDid}' and type = ${model_1.TreeModelType.FILE} and key like '${key}%';`, {
|
|
522
|
+
type: sequelize_1.QueryTypes.INSERT,
|
|
507
523
|
});
|
|
508
524
|
yield this.options.treeRepository.destroy({
|
|
509
525
|
where: whereForDeleteFolder,
|
|
510
526
|
});
|
|
511
|
-
yield this.globalSpace.mark(...trees.map((x) => x.objectId));
|
|
512
527
|
}
|
|
513
528
|
else {
|
|
514
529
|
const where = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-space/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.51",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"mime-types": "^2.1.35",
|
|
40
40
|
"multiformats": "9",
|
|
41
41
|
"p-all": "3.0.0",
|
|
42
|
-
"sequelize": "^6.37.
|
|
42
|
+
"sequelize": "^6.37.4",
|
|
43
43
|
"xbytes": "^1.9.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"ts-jest": "^28.0.8",
|
|
54
54
|
"typescript": "^4.9.5",
|
|
55
55
|
"vite": "^5.4.8",
|
|
56
|
-
"vitest": "^2.1.
|
|
56
|
+
"vitest": "^2.1.2"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4da54f9ce03611dc3bdf1ae9e63496dd1d0fe813"
|
|
59
59
|
}
|