@did-space/core 0.5.78 → 0.5.80
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 → cjs/constants}/index.d.ts +0 -6
- package/dist/{constants → cjs/constants}/index.js +1 -9
- package/dist/{meta → cjs/meta}/template/app.d.ts +0 -8
- package/dist/cjs/meta/template/index.d.ts +2 -0
- package/dist/cjs/meta/template/index.js +18 -0
- package/dist/{model → cjs/model}/app-space-apply.d.ts +1 -1
- package/dist/cjs/model/audit-log.d.ts +527 -0
- package/dist/cjs/model/audit-log.js +72 -0
- package/dist/{model → cjs/model}/did-object-mapping.d.ts +1 -1
- package/dist/{model → cjs/model}/index.d.ts +1 -0
- package/dist/{model → cjs/model}/index.js +1 -0
- package/dist/{model → cjs/model}/object-collection.d.ts +1 -1
- package/dist/{model → cjs/model}/object.d.ts +1 -1
- package/dist/{model → cjs/model}/space.d.ts +1 -1
- package/dist/{model → cjs/model}/tree.d.ts +2 -2
- package/dist/cjs/model/tree.js +9 -0
- package/dist/cjs/protocols/driver.js +2 -0
- package/dist/cjs/protocols/space-config.js +2 -0
- package/dist/cjs/protocols/space-operator.js +2 -0
- package/dist/cjs/protocols/space-owner-operator.js +2 -0
- package/dist/cjs/protocols/space.js +2 -0
- package/dist/es/configuration/index.d.ts +1 -0
- package/dist/es/configuration/index.js +1 -0
- package/dist/es/configuration/space-config.d.ts +23 -0
- package/dist/es/configuration/space-config.js +5 -0
- package/dist/es/constants/index.d.ts +30 -0
- package/dist/es/constants/index.js +35 -0
- package/dist/es/drivers/base.d.ts +40 -0
- package/dist/es/drivers/base.js +113 -0
- package/dist/es/drivers/index.d.ts +1 -0
- package/dist/es/drivers/index.js +1 -0
- package/dist/es/index.d.ts +9 -0
- package/dist/es/index.js +9 -0
- package/dist/es/meta/data.d.ts +4 -0
- package/dist/es/meta/data.js +1 -0
- package/dist/es/meta/index.d.ts +3 -0
- package/dist/es/meta/index.js +3 -0
- package/dist/es/meta/object.d.ts +70 -0
- package/dist/es/meta/object.js +1 -0
- package/dist/es/meta/template/app.d.ts +27 -0
- package/dist/es/meta/template/app.js +1 -0
- package/dist/es/meta/template/index.d.ts +2 -0
- package/dist/es/meta/template/index.js +2 -0
- package/dist/es/meta/template/preview/base.d.ts +13 -0
- package/dist/es/meta/template/preview/base.js +12 -0
- package/dist/es/meta/template/preview/default.d.ts +75 -0
- package/dist/es/meta/template/preview/default.js +9 -0
- package/dist/es/meta/template/preview/index.d.ts +5 -0
- package/dist/es/meta/template/preview/index.js +5 -0
- package/dist/es/meta/template/preview/nft.d.ts +23 -0
- package/dist/es/meta/template/preview/nft.js +8 -0
- package/dist/es/meta/template/preview/passport.d.ts +35 -0
- package/dist/es/meta/template/preview/passport.js +19 -0
- package/dist/es/meta/template/preview/profile.d.ts +23 -0
- package/dist/es/meta/template/preview/profile.js +8 -0
- package/dist/es/model/app-space-apply.d.ts +75 -0
- package/dist/es/model/app-space-apply.js +1 -0
- package/dist/es/model/audit-log.d.ts +527 -0
- package/dist/es/model/audit-log.js +69 -0
- package/dist/es/model/did-object-mapping.d.ts +8 -0
- package/dist/es/model/did-object-mapping.js +1 -0
- package/dist/es/model/index.d.ts +5 -0
- package/dist/es/model/index.js +5 -0
- package/dist/es/model/object-collection.d.ts +42 -0
- package/dist/es/model/object-collection.js +1 -0
- package/dist/es/model/object.d.ts +59 -0
- package/dist/es/model/object.js +1 -0
- package/dist/es/model/space.d.ts +21 -0
- package/dist/es/model/space.js +1 -0
- package/dist/es/model/tree.d.ts +96 -0
- package/dist/es/model/tree.js +6 -0
- package/dist/es/protocols/base-space.d.ts +4 -0
- package/dist/es/protocols/base-space.js +1 -0
- package/dist/es/protocols/driver.d.ts +7 -0
- package/dist/es/protocols/driver.js +1 -0
- package/dist/es/protocols/index.d.ts +5 -0
- package/dist/es/protocols/index.js +5 -0
- package/dist/es/protocols/space-config.d.ts +17 -0
- package/dist/es/protocols/space-config.js +1 -0
- package/dist/es/protocols/space-operator.d.ts +63 -0
- package/dist/es/protocols/space-operator.js +1 -0
- package/dist/es/protocols/space-owner-operator.d.ts +43 -0
- package/dist/es/protocols/space-owner-operator.js +1 -0
- package/dist/es/protocols/space.d.ts +7 -0
- package/dist/es/protocols/space.js +1 -0
- package/dist/es/schemas/global-space.d.ts +2 -0
- package/dist/es/schemas/global-space.js +19 -0
- package/dist/es/schemas/index.d.ts +3 -0
- package/dist/es/schemas/index.js +3 -0
- package/dist/es/schemas/object-space.d.ts +6 -0
- package/dist/es/schemas/object-space.js +44 -0
- package/dist/es/schemas/space-configuration.d.ts +4 -0
- package/dist/es/schemas/space-configuration.js +22 -0
- package/dist/es/schemas/space-options.d.ts +1 -0
- package/dist/es/schemas/space-options.js +4 -0
- package/dist/es/space/global-space.d.ts +43 -0
- package/dist/es/space/global-space.js +169 -0
- package/dist/es/space/index.d.ts +3 -0
- package/dist/es/space/index.js +3 -0
- package/dist/es/space/object-space.d.ts +123 -0
- package/dist/es/space/object-space.js +684 -0
- package/dist/es/space/space.d.ts +47 -0
- package/dist/es/space/space.js +172 -0
- package/dist/es/utils/common.d.ts +5 -0
- package/dist/es/utils/common.js +38 -0
- package/dist/es/utils/hash.d.ts +31 -0
- package/dist/es/utils/hash.js +64 -0
- package/dist/es/utils/index.d.ts +4 -0
- package/dist/es/utils/index.js +4 -0
- package/dist/es/utils/logger.d.ts +2 -0
- package/dist/es/utils/logger.js +2 -0
- package/dist/es/utils/stream.d.ts +11 -0
- package/dist/es/utils/stream.js +18 -0
- package/package.json +98 -9
- package/dist/meta/template/app-backup.d.ts +0 -55
- package/dist/meta/template/app-backup.js +0 -4
- package/dist/meta/template/app-connected.d.ts +0 -49
- package/dist/meta/template/app-connected.js +0 -4
- package/dist/meta/template/app-disconnected.d.ts +0 -20
- package/dist/meta/template/app-disconnected.js +0 -4
- package/dist/meta/template/app-restore.d.ts +0 -40
- package/dist/meta/template/app-restore.js +0 -4
- package/dist/meta/template/index.d.ts +0 -6
- package/dist/meta/template/index.js +0 -22
- package/dist/model/app-space-apply.js +0 -7
- package/dist/model/did-object-mapping.js +0 -8
- package/dist/model/object-collection.js +0 -7
- package/dist/model/object.js +0 -7
- package/dist/model/space.js +0 -7
- package/dist/model/tree.js +0 -18
- /package/dist/{configuration → cjs/configuration}/index.d.ts +0 -0
- /package/dist/{configuration → cjs/configuration}/index.js +0 -0
- /package/dist/{configuration → cjs/configuration}/space-config.d.ts +0 -0
- /package/dist/{configuration → cjs/configuration}/space-config.js +0 -0
- /package/dist/{drivers → cjs/drivers}/base.d.ts +0 -0
- /package/dist/{drivers → cjs/drivers}/base.js +0 -0
- /package/dist/{drivers → cjs/drivers}/index.d.ts +0 -0
- /package/dist/{drivers → cjs/drivers}/index.js +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{meta → cjs/meta}/data.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/data.js +0 -0
- /package/dist/{meta → cjs/meta}/index.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/index.js +0 -0
- /package/dist/{meta → cjs/meta}/object.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/object.js +0 -0
- /package/dist/{meta → cjs/meta}/template/app.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/base.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/base.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/default.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/default.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/index.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/index.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/nft.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/nft.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/passport.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/passport.js +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/profile.d.ts +0 -0
- /package/dist/{meta → cjs/meta}/template/preview/profile.js +0 -0
- /package/dist/{protocols/base-space.js → cjs/model/app-space-apply.js} +0 -0
- /package/dist/{protocols/driver.js → cjs/model/did-object-mapping.js} +0 -0
- /package/dist/{protocols/space-config.js → cjs/model/object-collection.js} +0 -0
- /package/dist/{protocols/space-operator.js → cjs/model/object.js} +0 -0
- /package/dist/{protocols → cjs/model}/space.js +0 -0
- /package/dist/{protocols → cjs/protocols}/base-space.d.ts +0 -0
- /package/dist/{protocols/space-owner-operator.js → cjs/protocols/base-space.js} +0 -0
- /package/dist/{protocols → cjs/protocols}/driver.d.ts +0 -0
- /package/dist/{protocols → cjs/protocols}/index.d.ts +0 -0
- /package/dist/{protocols → cjs/protocols}/index.js +0 -0
- /package/dist/{protocols → cjs/protocols}/space-config.d.ts +0 -0
- /package/dist/{protocols → cjs/protocols}/space-operator.d.ts +0 -0
- /package/dist/{protocols → cjs/protocols}/space-owner-operator.d.ts +0 -0
- /package/dist/{protocols → cjs/protocols}/space.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/global-space.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/global-space.js +0 -0
- /package/dist/{schemas → cjs/schemas}/index.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/index.js +0 -0
- /package/dist/{schemas → cjs/schemas}/object-space.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/object-space.js +0 -0
- /package/dist/{schemas → cjs/schemas}/space-configuration.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/space-configuration.js +0 -0
- /package/dist/{schemas → cjs/schemas}/space-options.d.ts +0 -0
- /package/dist/{schemas → cjs/schemas}/space-options.js +0 -0
- /package/dist/{space → cjs/space}/global-space.d.ts +0 -0
- /package/dist/{space → cjs/space}/global-space.js +0 -0
- /package/dist/{space → cjs/space}/index.d.ts +0 -0
- /package/dist/{space → cjs/space}/index.js +0 -0
- /package/dist/{space → cjs/space}/object-space.d.ts +0 -0
- /package/dist/{space → cjs/space}/object-space.js +0 -0
- /package/dist/{space → cjs/space}/space.d.ts +0 -0
- /package/dist/{space → cjs/space}/space.js +0 -0
- /package/dist/{utils → cjs/utils}/common.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/common.js +0 -0
- /package/dist/{utils → cjs/utils}/hash.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/hash.js +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/index.js +0 -0
- /package/dist/{utils → cjs/utils}/logger.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/logger.js +0 -0
- /package/dist/{utils → cjs/utils}/stream.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/stream.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TreeModelDefaultMeta = exports.TreeModelType = void 0;
|
|
4
|
+
var TreeModelType;
|
|
5
|
+
(function (TreeModelType) {
|
|
6
|
+
TreeModelType[TreeModelType["FOLDER"] = 0] = "FOLDER";
|
|
7
|
+
TreeModelType[TreeModelType["FILE"] = 1] = "FILE";
|
|
8
|
+
})(TreeModelType = exports.TreeModelType || (exports.TreeModelType = {}));
|
|
9
|
+
exports.TreeModelDefaultMeta = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './space-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './space-config';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SpaceConfig {
|
|
2
|
+
did: string;
|
|
3
|
+
drive?: 'fs' | 's3';
|
|
4
|
+
type?: 'buy' | 'default';
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
assetDid: string;
|
|
9
|
+
createAt: string;
|
|
10
|
+
updateAt: string;
|
|
11
|
+
expireAt: string;
|
|
12
|
+
ownerDid: string;
|
|
13
|
+
permissions?: Permissions;
|
|
14
|
+
}
|
|
15
|
+
export interface Permissions {
|
|
16
|
+
[fromAppDid: string]: {
|
|
17
|
+
[toAppDid: string]: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type Scope = 'list:object' | 'read:object' | 'write:object';
|
|
21
|
+
export declare const Scopes: {
|
|
22
|
+
[key in Scope]: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const APPS = "apps";
|
|
2
|
+
export declare const DID_OBJECTS = ".did-objects";
|
|
3
|
+
export declare const HEADERS: {
|
|
4
|
+
X_HASH: string;
|
|
5
|
+
X_SIGNATURE_VERSION: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const APP: {
|
|
8
|
+
FOLDER_PREFIX: string;
|
|
9
|
+
COMPONENT: {
|
|
10
|
+
FOLDER_PREFIX: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const SPACE_CONNECT_ERROR_CODE: {
|
|
14
|
+
/** 网络错误 */
|
|
15
|
+
NETWORK_ERROR: number;
|
|
16
|
+
/** 未授权 */
|
|
17
|
+
UNAUTHORIZED: number;
|
|
18
|
+
/** 订阅过期 */
|
|
19
|
+
EXPIRED: number;
|
|
20
|
+
/** 订阅逾期 */
|
|
21
|
+
PAST_DUE: number;
|
|
22
|
+
/** 订阅状态异常 */
|
|
23
|
+
INVALID: number;
|
|
24
|
+
/** 用量不足 */
|
|
25
|
+
UNIT_LIMIT: number;
|
|
26
|
+
/** 跨域限制 */
|
|
27
|
+
CORS_BLOCKED: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const GLOBAL_SPACE_ROOT = "__GLOBAL__";
|
|
30
|
+
export declare const STORAGE_BUILT_IN_OBJECTS: string[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const APPS = 'apps';
|
|
2
|
+
export const DID_OBJECTS = '.did-objects';
|
|
3
|
+
export const HEADERS = {
|
|
4
|
+
X_HASH: 'x-hash',
|
|
5
|
+
// 取值范围 undefined | "2"
|
|
6
|
+
// (默认)取值为 undefined,表示 url 未使用任何编码方式。
|
|
7
|
+
// 取值为 2,表示 url 使用了 base64url 编码的方式
|
|
8
|
+
X_SIGNATURE_VERSION: 'x-signature-version',
|
|
9
|
+
};
|
|
10
|
+
export const APP = {
|
|
11
|
+
// @example: /${spaceDid}/apps/${appDid}
|
|
12
|
+
FOLDER_PREFIX: 'apps',
|
|
13
|
+
COMPONENT: {
|
|
14
|
+
// @example: /${spaceDid}/apps/${appDid}/.components/${componentDid}
|
|
15
|
+
FOLDER_PREFIX: '.components',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const SPACE_CONNECT_ERROR_CODE = {
|
|
19
|
+
/** 网络错误 */
|
|
20
|
+
NETWORK_ERROR: 1001,
|
|
21
|
+
/** 未授权 */
|
|
22
|
+
UNAUTHORIZED: 1002,
|
|
23
|
+
/** 订阅过期 */
|
|
24
|
+
EXPIRED: 1003,
|
|
25
|
+
/** 订阅逾期 */
|
|
26
|
+
PAST_DUE: 1004,
|
|
27
|
+
/** 订阅状态异常 */
|
|
28
|
+
INVALID: 1005,
|
|
29
|
+
/** 用量不足 */
|
|
30
|
+
UNIT_LIMIT: 1006,
|
|
31
|
+
/** 跨域限制 */
|
|
32
|
+
CORS_BLOCKED: 1007,
|
|
33
|
+
};
|
|
34
|
+
export const GLOBAL_SPACE_ROOT = '__GLOBAL__';
|
|
35
|
+
export const STORAGE_BUILT_IN_OBJECTS = ['/config.yml', '/apps/', '/.meta/'];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Stream } from 'stream';
|
|
3
|
+
import { SpaceConfig } from '../configuration';
|
|
4
|
+
import { Data, Object } from '../meta';
|
|
5
|
+
import { AppSpaceOptions, DeleteOptions, DriverOptions, DriverProtocol, ExistsAsOwnerOptions, GetHashOptions, KeyStatus, ListOptions, ListsOptions, PermissionOptions, ReadAsOwnerOptions, ReadOptions, SpaceConfigProtocol, SpaceOperatorProtocol, WriteAsOwnerOptions, WriteOptions } from '../protocols';
|
|
6
|
+
export declare abstract class BaseDriver implements DriverProtocol {
|
|
7
|
+
readonly options: DriverOptions;
|
|
8
|
+
constructor(options: DriverOptions);
|
|
9
|
+
abstract get spaceOperator(): SpaceOperatorProtocol;
|
|
10
|
+
abstract get spaceConfig(): SpaceConfigProtocol;
|
|
11
|
+
createSpace(spaceConfig: SpaceConfig): Promise<void>;
|
|
12
|
+
destroySpace(): Promise<void>;
|
|
13
|
+
isSpaceCreated(): Promise<boolean>;
|
|
14
|
+
getSpaceSize(): Promise<number>;
|
|
15
|
+
createAppSpace(options: AppSpaceOptions): Promise<void>;
|
|
16
|
+
destroyAppSpace(options: AppSpaceOptions): Promise<void>;
|
|
17
|
+
getAppSpacePath(options: AppSpaceOptions): Promise<string>;
|
|
18
|
+
createConfig(spaceConfig: SpaceConfig): Promise<void>;
|
|
19
|
+
destroyConfig(): Promise<void>;
|
|
20
|
+
set<T = any>(key: string, value: T): Promise<void>;
|
|
21
|
+
get<T = any>(key: string): Promise<T>;
|
|
22
|
+
setListable(options: PermissionOptions, value: boolean): Promise<void>;
|
|
23
|
+
setReadable(options: PermissionOptions, value: boolean): Promise<void>;
|
|
24
|
+
setWritable(options: PermissionOptions, value: boolean): Promise<void>;
|
|
25
|
+
isListable(options: PermissionOptions): Promise<boolean>;
|
|
26
|
+
isReadable(options: PermissionOptions): Promise<boolean>;
|
|
27
|
+
isWritable(options: PermissionOptions): Promise<boolean>;
|
|
28
|
+
write(options: WriteOptions): Promise<void>;
|
|
29
|
+
delete(options: DeleteOptions): Promise<void>;
|
|
30
|
+
read(options: ReadOptions): Promise<Stream>;
|
|
31
|
+
getHash(options: GetHashOptions): Promise<string>;
|
|
32
|
+
exists(options: ReadOptions): Promise<boolean>;
|
|
33
|
+
lists(options: ListsOptions): Promise<Object[]>;
|
|
34
|
+
list(options: ListOptions): Promise<Object | null>;
|
|
35
|
+
writeAsOwner(key: string, data: Data, options?: WriteAsOwnerOptions): Promise<void>;
|
|
36
|
+
deleteAsOwner(key: string, options?: ReadAsOwnerOptions): Promise<void>;
|
|
37
|
+
readAsOwner(key: string, options?: ReadAsOwnerOptions): Promise<Stream>;
|
|
38
|
+
existsAsOwner(key: string, options?: ExistsAsOwnerOptions): Promise<boolean>;
|
|
39
|
+
getStatusAsOwner(key: string): Promise<KeyStatus>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export class BaseDriver {
|
|
2
|
+
options;
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
async createSpace(spaceConfig) {
|
|
7
|
+
await this.spaceConfig.createConfig(spaceConfig);
|
|
8
|
+
await this.spaceOperator.createSpace(spaceConfig);
|
|
9
|
+
}
|
|
10
|
+
async destroySpace() {
|
|
11
|
+
await this.spaceConfig.destroyConfig();
|
|
12
|
+
await this.spaceOperator.destroySpace();
|
|
13
|
+
}
|
|
14
|
+
isSpaceCreated() {
|
|
15
|
+
return this.spaceOperator.isSpaceCreated();
|
|
16
|
+
}
|
|
17
|
+
getSpaceSize() {
|
|
18
|
+
return this.spaceOperator.getSpaceSize();
|
|
19
|
+
}
|
|
20
|
+
async createAppSpace(options) {
|
|
21
|
+
await this.spaceOperator.createAppSpace(options);
|
|
22
|
+
}
|
|
23
|
+
async destroyAppSpace(options) {
|
|
24
|
+
await this.spaceOperator.destroyAppSpace(options);
|
|
25
|
+
}
|
|
26
|
+
getAppSpacePath(options) {
|
|
27
|
+
return this.spaceOperator.getAppSpacePath(options);
|
|
28
|
+
}
|
|
29
|
+
async createConfig(spaceConfig) {
|
|
30
|
+
await this.spaceConfig.createConfig(spaceConfig);
|
|
31
|
+
}
|
|
32
|
+
async destroyConfig() {
|
|
33
|
+
await this.spaceConfig.destroyConfig();
|
|
34
|
+
}
|
|
35
|
+
async set(key, value) {
|
|
36
|
+
await this.spaceConfig.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
get(key) {
|
|
39
|
+
return this.spaceConfig.get(key);
|
|
40
|
+
}
|
|
41
|
+
async setListable(options, value) {
|
|
42
|
+
await this.spaceConfig.setListable(options, value);
|
|
43
|
+
}
|
|
44
|
+
async setReadable(options, value) {
|
|
45
|
+
await this.spaceConfig.setReadable(options, value);
|
|
46
|
+
}
|
|
47
|
+
async setWritable(options, value) {
|
|
48
|
+
await this.spaceConfig.setWritable(options, value);
|
|
49
|
+
}
|
|
50
|
+
isListable(options) {
|
|
51
|
+
return this.spaceConfig.isListable(options);
|
|
52
|
+
}
|
|
53
|
+
isReadable(options) {
|
|
54
|
+
return this.spaceConfig.isReadable(options);
|
|
55
|
+
}
|
|
56
|
+
isWritable(options) {
|
|
57
|
+
return this.spaceConfig.isWritable(options);
|
|
58
|
+
}
|
|
59
|
+
async write(options) {
|
|
60
|
+
if (!(await this.spaceConfig.isWritable({
|
|
61
|
+
fromAppDid: options.appDid,
|
|
62
|
+
toAppDid: options.appDid,
|
|
63
|
+
}))) {
|
|
64
|
+
throw new Error('Unable to write object with insufficient permissions');
|
|
65
|
+
}
|
|
66
|
+
await this.spaceOperator.write(options);
|
|
67
|
+
}
|
|
68
|
+
async delete(options) {
|
|
69
|
+
await this.spaceOperator.delete(options);
|
|
70
|
+
}
|
|
71
|
+
async read(options) {
|
|
72
|
+
if (!(await this.spaceConfig.isReadable({
|
|
73
|
+
fromAppDid: options.appDid,
|
|
74
|
+
toAppDid: options.appDid,
|
|
75
|
+
}))) {
|
|
76
|
+
throw new Error('Unable to read object with insufficient permissions');
|
|
77
|
+
}
|
|
78
|
+
return this.spaceOperator.read(options);
|
|
79
|
+
}
|
|
80
|
+
getHash(options) {
|
|
81
|
+
return this.spaceOperator.getHash(options);
|
|
82
|
+
}
|
|
83
|
+
async exists(options) {
|
|
84
|
+
if (!(await this.spaceConfig.isListable({
|
|
85
|
+
fromAppDid: options.appDid,
|
|
86
|
+
toAppDid: options.appDid,
|
|
87
|
+
}))) {
|
|
88
|
+
throw new Error('Unable to list object with insufficient permissions');
|
|
89
|
+
}
|
|
90
|
+
return this.spaceOperator.exists(options);
|
|
91
|
+
}
|
|
92
|
+
lists(options) {
|
|
93
|
+
return this.spaceOperator.lists(options);
|
|
94
|
+
}
|
|
95
|
+
list(options) {
|
|
96
|
+
return this.spaceOperator.list(options);
|
|
97
|
+
}
|
|
98
|
+
writeAsOwner(key, data, options) {
|
|
99
|
+
return this.spaceOperator.writeAsOwner(key, data, options);
|
|
100
|
+
}
|
|
101
|
+
deleteAsOwner(key, options) {
|
|
102
|
+
return this.spaceOperator.deleteAsOwner(key, options);
|
|
103
|
+
}
|
|
104
|
+
readAsOwner(key, options) {
|
|
105
|
+
return this.spaceOperator.readAsOwner(key, options);
|
|
106
|
+
}
|
|
107
|
+
existsAsOwner(key, options) {
|
|
108
|
+
return this.spaceOperator.existsAsOwner(key, options);
|
|
109
|
+
}
|
|
110
|
+
getStatusAsOwner(key) {
|
|
111
|
+
return this.spaceOperator.getStatusAsOwner(key);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ObjectMetadata } from '../protocols';
|
|
2
|
+
export interface Object {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* @tips 约定好 key 的第一个字符是 /
|
|
7
|
+
* @example /demo/index.html
|
|
8
|
+
* @type {string}
|
|
9
|
+
* @memberof Object
|
|
10
|
+
*/
|
|
11
|
+
key: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 文件名
|
|
14
|
+
* @example index.html
|
|
15
|
+
* @type {string}
|
|
16
|
+
* @memberof Object
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
* @memberof Object
|
|
23
|
+
*/
|
|
24
|
+
isDir: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description 文件的大小
|
|
27
|
+
* @type {number}
|
|
28
|
+
* @memberof Object
|
|
29
|
+
*/
|
|
30
|
+
size: number;
|
|
31
|
+
/**
|
|
32
|
+
* @description
|
|
33
|
+
* @type {number}
|
|
34
|
+
* @memberof Object
|
|
35
|
+
*/
|
|
36
|
+
lastModified: number;
|
|
37
|
+
/**
|
|
38
|
+
* @description
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
* @memberof Object
|
|
41
|
+
*/
|
|
42
|
+
editable: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @description 如果是一个文件夹,则为 null
|
|
45
|
+
* @example video/mp4
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof Object
|
|
48
|
+
*/
|
|
49
|
+
mimeType: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* @description
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof Object
|
|
54
|
+
*/
|
|
55
|
+
absolutePath: string;
|
|
56
|
+
/**
|
|
57
|
+
* @description 对象的 hash 值(ipfs CID v1)
|
|
58
|
+
* @type {string}
|
|
59
|
+
* @memberof Object
|
|
60
|
+
*/
|
|
61
|
+
hash?: string;
|
|
62
|
+
/**
|
|
63
|
+
* @description 存储 metadata 信息
|
|
64
|
+
* @default {{}}
|
|
65
|
+
* @type {ObjectMetadata}
|
|
66
|
+
* @memberof Object
|
|
67
|
+
*/
|
|
68
|
+
metadata?: ObjectMetadata;
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const APP_TYPE = "app";
|
|
2
|
+
export interface AppPermissions {
|
|
3
|
+
[scope: string]: {
|
|
4
|
+
[authorizedAppDid: string]: number;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @description 此文件存储的位置在 ${spaceDid}/apps/${appDid}/.meta/config.yml
|
|
10
|
+
* @export
|
|
11
|
+
* @interface AppMeta
|
|
12
|
+
*/
|
|
13
|
+
export interface App {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @description uid
|
|
17
|
+
* @link https://www.npmjs.com/package/nanoid?activeTab=readme
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof App
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
type: 'app';
|
|
23
|
+
userDid: string;
|
|
24
|
+
permissions: AppPermissions;
|
|
25
|
+
createAt: string;
|
|
26
|
+
updateAt: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const APP_TYPE = 'app';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DidSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
3
|
+
export declare const BasePreviewTemplateSchema: z.ZodObject<{
|
|
4
|
+
template: z.ZodString;
|
|
5
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
template: string;
|
|
8
|
+
did: string;
|
|
9
|
+
}, {
|
|
10
|
+
template: string;
|
|
11
|
+
did: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type BasePreviewTemplate = z.infer<typeof BasePreviewTemplateSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isValid } from '@arcblock/did';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const DidSchema = z.string().refine((value) => isValid(value), (value) => {
|
|
4
|
+
return {
|
|
5
|
+
code: z.ZodIssueCode.custom,
|
|
6
|
+
message: `${value} is not a valid DID`,
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
export const BasePreviewTemplateSchema = z.object({
|
|
10
|
+
template: z.string().min(1),
|
|
11
|
+
did: DidSchema,
|
|
12
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const PreviewTemplateSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
template: z.ZodString;
|
|
4
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
+
}, {
|
|
6
|
+
template: z.ZodLiteral<"nft">;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
image: z.ZodString;
|
|
9
|
+
chainHost: z.ZodString;
|
|
10
|
+
}>, "strip", z.ZodTypeAny, {
|
|
11
|
+
template: "nft";
|
|
12
|
+
did: string;
|
|
13
|
+
name: string;
|
|
14
|
+
image: string;
|
|
15
|
+
chainHost: string;
|
|
16
|
+
}, {
|
|
17
|
+
template: "nft";
|
|
18
|
+
did: string;
|
|
19
|
+
name: string;
|
|
20
|
+
image: string;
|
|
21
|
+
chainHost: string;
|
|
22
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
23
|
+
template: z.ZodString;
|
|
24
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
25
|
+
}, {
|
|
26
|
+
template: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"profile">>>;
|
|
27
|
+
avatar: z.ZodString;
|
|
28
|
+
fullname: z.ZodString;
|
|
29
|
+
email: z.ZodString;
|
|
30
|
+
}>, "strip", z.ZodTypeAny, {
|
|
31
|
+
template: "profile";
|
|
32
|
+
did: string;
|
|
33
|
+
avatar: string;
|
|
34
|
+
fullname: string;
|
|
35
|
+
email: string;
|
|
36
|
+
}, {
|
|
37
|
+
did: string;
|
|
38
|
+
avatar: string;
|
|
39
|
+
fullname: string;
|
|
40
|
+
email: string;
|
|
41
|
+
template?: "profile" | undefined;
|
|
42
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
43
|
+
template: z.ZodString;
|
|
44
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
45
|
+
}, {
|
|
46
|
+
template: z.ZodLiteral<"passport">;
|
|
47
|
+
image: z.ZodString;
|
|
48
|
+
type: z.ZodArray<z.ZodString, "many">;
|
|
49
|
+
issuerDid: z.ZodEffects<z.ZodString, string, string>;
|
|
50
|
+
issuerName: z.ZodString;
|
|
51
|
+
issuedAt: z.ZodString;
|
|
52
|
+
issuedTo: z.ZodString;
|
|
53
|
+
verified: z.ZodBoolean;
|
|
54
|
+
}>, "strip", z.ZodTypeAny, {
|
|
55
|
+
type: string[];
|
|
56
|
+
template: "passport";
|
|
57
|
+
did: string;
|
|
58
|
+
image: string;
|
|
59
|
+
issuerDid: string;
|
|
60
|
+
issuerName: string;
|
|
61
|
+
issuedAt: string;
|
|
62
|
+
issuedTo: string;
|
|
63
|
+
verified: boolean;
|
|
64
|
+
}, {
|
|
65
|
+
type: string[];
|
|
66
|
+
template: "passport";
|
|
67
|
+
did: string;
|
|
68
|
+
image: string;
|
|
69
|
+
issuerDid: string;
|
|
70
|
+
issuerName: string;
|
|
71
|
+
issuedAt: string;
|
|
72
|
+
issuedTo: string;
|
|
73
|
+
verified: boolean;
|
|
74
|
+
}>]>;
|
|
75
|
+
export type PreviewTemplate = z.infer<typeof PreviewTemplateSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { NftPreviewTemplateSchema } from './nft';
|
|
3
|
+
import { ProfilePreviewTemplateSchema } from './profile';
|
|
4
|
+
import { PassportPreviewTemplateSchema } from './passport';
|
|
5
|
+
export const PreviewTemplateSchema = z.union([
|
|
6
|
+
NftPreviewTemplateSchema,
|
|
7
|
+
ProfilePreviewTemplateSchema,
|
|
8
|
+
PassportPreviewTemplateSchema,
|
|
9
|
+
]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const NftPreviewTemplateSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
template: z.ZodString;
|
|
4
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
+
}, {
|
|
6
|
+
template: z.ZodLiteral<"nft">;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
image: z.ZodString;
|
|
9
|
+
chainHost: z.ZodString;
|
|
10
|
+
}>, "strip", z.ZodTypeAny, {
|
|
11
|
+
template: "nft";
|
|
12
|
+
did: string;
|
|
13
|
+
name: string;
|
|
14
|
+
image: string;
|
|
15
|
+
chainHost: string;
|
|
16
|
+
}, {
|
|
17
|
+
template: "nft";
|
|
18
|
+
did: string;
|
|
19
|
+
name: string;
|
|
20
|
+
image: string;
|
|
21
|
+
chainHost: string;
|
|
22
|
+
}>;
|
|
23
|
+
export type NftPreviewTemplate = z.infer<typeof NftPreviewTemplateSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { BasePreviewTemplateSchema } from './base';
|
|
3
|
+
export const NftPreviewTemplateSchema = BasePreviewTemplateSchema.extend({
|
|
4
|
+
template: z.literal('nft'),
|
|
5
|
+
name: z.string().min(1),
|
|
6
|
+
image: z.string().min(1),
|
|
7
|
+
chainHost: z.string().min(1).startsWith('http').url(),
|
|
8
|
+
});
|