@did-space/core 0.5.78 → 0.5.79

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.
Files changed (201) hide show
  1. package/dist/{constants → cjs/constants}/index.d.ts +0 -6
  2. package/dist/{constants → cjs/constants}/index.js +1 -9
  3. package/dist/{meta → cjs/meta}/template/app.d.ts +0 -8
  4. package/dist/cjs/meta/template/index.d.ts +2 -0
  5. package/dist/cjs/meta/template/index.js +18 -0
  6. package/dist/{model → cjs/model}/app-space-apply.d.ts +1 -1
  7. package/dist/cjs/model/audit-log.d.ts +527 -0
  8. package/dist/cjs/model/audit-log.js +72 -0
  9. package/dist/{model → cjs/model}/did-object-mapping.d.ts +1 -1
  10. package/dist/{model → cjs/model}/index.d.ts +1 -0
  11. package/dist/{model → cjs/model}/index.js +1 -0
  12. package/dist/{model → cjs/model}/object-collection.d.ts +1 -1
  13. package/dist/{model → cjs/model}/object.d.ts +1 -1
  14. package/dist/{model → cjs/model}/space.d.ts +1 -1
  15. package/dist/{model → cjs/model}/tree.d.ts +2 -2
  16. package/dist/cjs/model/tree.js +9 -0
  17. package/dist/cjs/protocols/driver.js +2 -0
  18. package/dist/cjs/protocols/space-config.js +2 -0
  19. package/dist/cjs/protocols/space-operator.js +2 -0
  20. package/dist/cjs/protocols/space-owner-operator.js +2 -0
  21. package/dist/cjs/protocols/space.js +2 -0
  22. package/dist/es/configuration/index.d.ts +1 -0
  23. package/dist/es/configuration/index.js +1 -0
  24. package/dist/es/configuration/space-config.d.ts +23 -0
  25. package/dist/es/configuration/space-config.js +5 -0
  26. package/dist/es/constants/index.d.ts +30 -0
  27. package/dist/es/constants/index.js +35 -0
  28. package/dist/es/drivers/base.d.ts +40 -0
  29. package/dist/es/drivers/base.js +113 -0
  30. package/dist/es/drivers/index.d.ts +1 -0
  31. package/dist/es/drivers/index.js +1 -0
  32. package/dist/es/index.d.ts +9 -0
  33. package/dist/es/index.js +9 -0
  34. package/dist/es/meta/data.d.ts +4 -0
  35. package/dist/es/meta/data.js +1 -0
  36. package/dist/es/meta/index.d.ts +3 -0
  37. package/dist/es/meta/index.js +3 -0
  38. package/dist/es/meta/object.d.ts +70 -0
  39. package/dist/es/meta/object.js +1 -0
  40. package/dist/es/meta/template/app.d.ts +27 -0
  41. package/dist/es/meta/template/app.js +1 -0
  42. package/dist/es/meta/template/index.d.ts +2 -0
  43. package/dist/es/meta/template/index.js +2 -0
  44. package/dist/es/meta/template/preview/base.d.ts +13 -0
  45. package/dist/es/meta/template/preview/base.js +12 -0
  46. package/dist/es/meta/template/preview/default.d.ts +75 -0
  47. package/dist/es/meta/template/preview/default.js +9 -0
  48. package/dist/es/meta/template/preview/index.d.ts +5 -0
  49. package/dist/es/meta/template/preview/index.js +5 -0
  50. package/dist/es/meta/template/preview/nft.d.ts +23 -0
  51. package/dist/es/meta/template/preview/nft.js +8 -0
  52. package/dist/es/meta/template/preview/passport.d.ts +35 -0
  53. package/dist/es/meta/template/preview/passport.js +19 -0
  54. package/dist/es/meta/template/preview/profile.d.ts +23 -0
  55. package/dist/es/meta/template/preview/profile.js +8 -0
  56. package/dist/es/model/app-space-apply.d.ts +75 -0
  57. package/dist/es/model/app-space-apply.js +1 -0
  58. package/dist/es/model/audit-log.d.ts +527 -0
  59. package/dist/es/model/audit-log.js +69 -0
  60. package/dist/es/model/did-object-mapping.d.ts +8 -0
  61. package/dist/es/model/did-object-mapping.js +1 -0
  62. package/dist/es/model/index.d.ts +5 -0
  63. package/dist/es/model/index.js +5 -0
  64. package/dist/es/model/object-collection.d.ts +42 -0
  65. package/dist/es/model/object-collection.js +1 -0
  66. package/dist/es/model/object.d.ts +59 -0
  67. package/dist/es/model/object.js +1 -0
  68. package/dist/es/model/space.d.ts +21 -0
  69. package/dist/es/model/space.js +1 -0
  70. package/dist/es/model/tree.d.ts +96 -0
  71. package/dist/es/model/tree.js +6 -0
  72. package/dist/es/protocols/base-space.d.ts +4 -0
  73. package/dist/es/protocols/base-space.js +1 -0
  74. package/dist/es/protocols/driver.d.ts +7 -0
  75. package/dist/es/protocols/driver.js +1 -0
  76. package/dist/es/protocols/index.d.ts +5 -0
  77. package/dist/es/protocols/index.js +5 -0
  78. package/dist/es/protocols/space-config.d.ts +17 -0
  79. package/dist/es/protocols/space-config.js +1 -0
  80. package/dist/es/protocols/space-operator.d.ts +63 -0
  81. package/dist/es/protocols/space-operator.js +1 -0
  82. package/dist/es/protocols/space-owner-operator.d.ts +43 -0
  83. package/dist/es/protocols/space-owner-operator.js +1 -0
  84. package/dist/es/protocols/space.d.ts +7 -0
  85. package/dist/es/protocols/space.js +1 -0
  86. package/dist/es/schemas/global-space.d.ts +2 -0
  87. package/dist/es/schemas/global-space.js +19 -0
  88. package/dist/es/schemas/index.d.ts +3 -0
  89. package/dist/es/schemas/index.js +3 -0
  90. package/dist/es/schemas/object-space.d.ts +6 -0
  91. package/dist/es/schemas/object-space.js +44 -0
  92. package/dist/es/schemas/space-configuration.d.ts +4 -0
  93. package/dist/es/schemas/space-configuration.js +22 -0
  94. package/dist/es/schemas/space-options.d.ts +1 -0
  95. package/dist/es/schemas/space-options.js +4 -0
  96. package/dist/es/space/global-space.d.ts +43 -0
  97. package/dist/es/space/global-space.js +169 -0
  98. package/dist/es/space/index.d.ts +3 -0
  99. package/dist/es/space/index.js +3 -0
  100. package/dist/es/space/object-space.d.ts +123 -0
  101. package/dist/es/space/object-space.js +684 -0
  102. package/dist/es/space/space.d.ts +47 -0
  103. package/dist/es/space/space.js +172 -0
  104. package/dist/es/utils/common.d.ts +5 -0
  105. package/dist/es/utils/common.js +38 -0
  106. package/dist/es/utils/hash.d.ts +31 -0
  107. package/dist/es/utils/hash.js +64 -0
  108. package/dist/es/utils/index.d.ts +4 -0
  109. package/dist/es/utils/index.js +4 -0
  110. package/dist/es/utils/logger.d.ts +2 -0
  111. package/dist/es/utils/logger.js +2 -0
  112. package/dist/es/utils/stream.d.ts +11 -0
  113. package/dist/es/utils/stream.js +18 -0
  114. package/package.json +98 -9
  115. package/dist/meta/template/app-backup.d.ts +0 -55
  116. package/dist/meta/template/app-backup.js +0 -4
  117. package/dist/meta/template/app-connected.d.ts +0 -49
  118. package/dist/meta/template/app-connected.js +0 -4
  119. package/dist/meta/template/app-disconnected.d.ts +0 -20
  120. package/dist/meta/template/app-disconnected.js +0 -4
  121. package/dist/meta/template/app-restore.d.ts +0 -40
  122. package/dist/meta/template/app-restore.js +0 -4
  123. package/dist/meta/template/index.d.ts +0 -6
  124. package/dist/meta/template/index.js +0 -22
  125. package/dist/model/app-space-apply.js +0 -7
  126. package/dist/model/did-object-mapping.js +0 -8
  127. package/dist/model/object-collection.js +0 -7
  128. package/dist/model/object.js +0 -7
  129. package/dist/model/space.js +0 -7
  130. package/dist/model/tree.js +0 -18
  131. /package/dist/{configuration → cjs/configuration}/index.d.ts +0 -0
  132. /package/dist/{configuration → cjs/configuration}/index.js +0 -0
  133. /package/dist/{configuration → cjs/configuration}/space-config.d.ts +0 -0
  134. /package/dist/{configuration → cjs/configuration}/space-config.js +0 -0
  135. /package/dist/{drivers → cjs/drivers}/base.d.ts +0 -0
  136. /package/dist/{drivers → cjs/drivers}/base.js +0 -0
  137. /package/dist/{drivers → cjs/drivers}/index.d.ts +0 -0
  138. /package/dist/{drivers → cjs/drivers}/index.js +0 -0
  139. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  140. /package/dist/{index.js → cjs/index.js} +0 -0
  141. /package/dist/{meta → cjs/meta}/data.d.ts +0 -0
  142. /package/dist/{meta → cjs/meta}/data.js +0 -0
  143. /package/dist/{meta → cjs/meta}/index.d.ts +0 -0
  144. /package/dist/{meta → cjs/meta}/index.js +0 -0
  145. /package/dist/{meta → cjs/meta}/object.d.ts +0 -0
  146. /package/dist/{meta → cjs/meta}/object.js +0 -0
  147. /package/dist/{meta → cjs/meta}/template/app.js +0 -0
  148. /package/dist/{meta → cjs/meta}/template/preview/base.d.ts +0 -0
  149. /package/dist/{meta → cjs/meta}/template/preview/base.js +0 -0
  150. /package/dist/{meta → cjs/meta}/template/preview/default.d.ts +0 -0
  151. /package/dist/{meta → cjs/meta}/template/preview/default.js +0 -0
  152. /package/dist/{meta → cjs/meta}/template/preview/index.d.ts +0 -0
  153. /package/dist/{meta → cjs/meta}/template/preview/index.js +0 -0
  154. /package/dist/{meta → cjs/meta}/template/preview/nft.d.ts +0 -0
  155. /package/dist/{meta → cjs/meta}/template/preview/nft.js +0 -0
  156. /package/dist/{meta → cjs/meta}/template/preview/passport.d.ts +0 -0
  157. /package/dist/{meta → cjs/meta}/template/preview/passport.js +0 -0
  158. /package/dist/{meta → cjs/meta}/template/preview/profile.d.ts +0 -0
  159. /package/dist/{meta → cjs/meta}/template/preview/profile.js +0 -0
  160. /package/dist/{protocols/base-space.js → cjs/model/app-space-apply.js} +0 -0
  161. /package/dist/{protocols/driver.js → cjs/model/did-object-mapping.js} +0 -0
  162. /package/dist/{protocols/space-config.js → cjs/model/object-collection.js} +0 -0
  163. /package/dist/{protocols/space-operator.js → cjs/model/object.js} +0 -0
  164. /package/dist/{protocols → cjs/model}/space.js +0 -0
  165. /package/dist/{protocols → cjs/protocols}/base-space.d.ts +0 -0
  166. /package/dist/{protocols/space-owner-operator.js → cjs/protocols/base-space.js} +0 -0
  167. /package/dist/{protocols → cjs/protocols}/driver.d.ts +0 -0
  168. /package/dist/{protocols → cjs/protocols}/index.d.ts +0 -0
  169. /package/dist/{protocols → cjs/protocols}/index.js +0 -0
  170. /package/dist/{protocols → cjs/protocols}/space-config.d.ts +0 -0
  171. /package/dist/{protocols → cjs/protocols}/space-operator.d.ts +0 -0
  172. /package/dist/{protocols → cjs/protocols}/space-owner-operator.d.ts +0 -0
  173. /package/dist/{protocols → cjs/protocols}/space.d.ts +0 -0
  174. /package/dist/{schemas → cjs/schemas}/global-space.d.ts +0 -0
  175. /package/dist/{schemas → cjs/schemas}/global-space.js +0 -0
  176. /package/dist/{schemas → cjs/schemas}/index.d.ts +0 -0
  177. /package/dist/{schemas → cjs/schemas}/index.js +0 -0
  178. /package/dist/{schemas → cjs/schemas}/object-space.d.ts +0 -0
  179. /package/dist/{schemas → cjs/schemas}/object-space.js +0 -0
  180. /package/dist/{schemas → cjs/schemas}/space-configuration.d.ts +0 -0
  181. /package/dist/{schemas → cjs/schemas}/space-configuration.js +0 -0
  182. /package/dist/{schemas → cjs/schemas}/space-options.d.ts +0 -0
  183. /package/dist/{schemas → cjs/schemas}/space-options.js +0 -0
  184. /package/dist/{space → cjs/space}/global-space.d.ts +0 -0
  185. /package/dist/{space → cjs/space}/global-space.js +0 -0
  186. /package/dist/{space → cjs/space}/index.d.ts +0 -0
  187. /package/dist/{space → cjs/space}/index.js +0 -0
  188. /package/dist/{space → cjs/space}/object-space.d.ts +0 -0
  189. /package/dist/{space → cjs/space}/object-space.js +0 -0
  190. /package/dist/{space → cjs/space}/space.d.ts +0 -0
  191. /package/dist/{space → cjs/space}/space.js +0 -0
  192. /package/dist/{utils → cjs/utils}/common.d.ts +0 -0
  193. /package/dist/{utils → cjs/utils}/common.js +0 -0
  194. /package/dist/{utils → cjs/utils}/hash.d.ts +0 -0
  195. /package/dist/{utils → cjs/utils}/hash.js +0 -0
  196. /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
  197. /package/dist/{utils → cjs/utils}/index.js +0 -0
  198. /package/dist/{utils → cjs/utils}/logger.d.ts +0 -0
  199. /package/dist/{utils → cjs/utils}/logger.js +0 -0
  200. /package/dist/{utils → cjs/utils}/stream.d.ts +0 -0
  201. /package/dist/{utils → cjs/utils}/stream.js +0 -0
@@ -1,4 +1,4 @@
1
- import { Model } from 'sequelize';
1
+ import type { Model } from 'sequelize';
2
2
  /**
3
3
  * @description 存储的是对象的信息,不保存结构,创建之初就确定了,只能增加,删除
4
4
  * @export
@@ -1,4 +1,4 @@
1
- import { Model, CreationOptional } from 'sequelize';
1
+ import type { Model, CreationOptional } from 'sequelize';
2
2
  /**
3
3
  * @description 存储的是对象的信息,不保存结构,创建之初就确定了,只能增加,删除
4
4
  * @export
@@ -1,4 +1,4 @@
1
- import { Model } from 'sequelize';
1
+ import type { Model } from 'sequelize';
2
2
  import type { LiteralUnion } from 'type-fest';
3
3
  export declare class SpaceRepositoryClass extends Model<SpaceRepositoryClass, SpaceRepositoryClass> {
4
4
  id: string;
@@ -1,5 +1,5 @@
1
- import { Model } from 'sequelize';
2
- import { ObjectModel } from './object';
1
+ import type { Model } from 'sequelize';
2
+ import type { ObjectModel } from './object';
3
3
  export interface TreeModel {
4
4
  /**
5
5
  * @description uuidv4
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,5 @@
1
+ export const Scopes = {
2
+ 'list:object': 1,
3
+ 'read:object': 2,
4
+ 'write:object': 4,
5
+ };
@@ -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';
@@ -0,0 +1,9 @@
1
+ export * from './configuration';
2
+ export * from './constants';
3
+ export * from './drivers';
4
+ export * from './meta';
5
+ export * from './model';
6
+ export * from './protocols';
7
+ export * from './schemas';
8
+ export * from './space';
9
+ export * from './utils';
@@ -0,0 +1,9 @@
1
+ export * from './configuration';
2
+ export * from './constants';
3
+ export * from './drivers';
4
+ export * from './meta';
5
+ export * from './model';
6
+ export * from './protocols';
7
+ export * from './schemas';
8
+ export * from './space';
9
+ export * from './utils';
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Readable } from 'stream';
4
+ export type Data = Readable | ReadableStream | string | Buffer | ReadableStream<any> | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './template';
2
+ export * from './data';
3
+ export * from './object';
@@ -0,0 +1,3 @@
1
+ export * from './template';
2
+ export * from './data';
3
+ export * from './object';
@@ -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,2 @@
1
+ export * from './app';
2
+ export * from './preview';
@@ -0,0 +1,2 @@
1
+ export * from './app';
2
+ export * from './preview';
@@ -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,5 @@
1
+ export * from './base';
2
+ export * from './default';
3
+ export * from './nft';
4
+ export * from './passport';
5
+ export * from './profile';
@@ -0,0 +1,5 @@
1
+ export * from './base';
2
+ export * from './default';
3
+ export * from './nft';
4
+ export * from './passport';
5
+ export * from './profile';
@@ -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
+ });