@did-space/template 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.
@@ -1,2 +1 @@
1
- import axios from 'axios';
2
- export declare const api: axios.AxiosInstance;
1
+ export declare const api: import("axios").AxiosInstance;
@@ -1 +1,2 @@
1
+ export declare const AppUrlSchema: import("joi").StringSchema<string>;
1
2
  export declare const AppSchema: import("joi").ObjectSchema<any>;
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppSchema = void 0;
6
+ exports.AppSchema = exports.AppUrlSchema = void 0;
4
7
  const validator_1 = require("@arcblock/validator");
5
8
  const core_1 = require("@did-space/core");
6
- const app_backup_1 = require("./app-backup");
7
- const app_connected_1 = require("./app-connected");
8
- const app_restore_1 = require("./app-restore");
9
+ const is_url_1 = __importDefault(require("is-url"));
9
10
  const nanoid_1 = require("./nanoid");
10
- const app_disconnected_1 = require("./app-disconnected");
11
+ exports.AppUrlSchema = validator_1.Joi.string()
12
+ .allow('')
13
+ .required()
14
+ .custom((value, helper) => {
15
+ if (!(0, is_url_1.default)(value)) {
16
+ return helper.message(`appUrl(${value}) must be a http/https url`);
17
+ }
18
+ return value;
19
+ });
11
20
  exports.AppSchema = validator_1.Joi.object({
12
21
  id: nanoid_1.NanoidSchema,
13
22
  type: validator_1.Joi.string().valid(core_1.APP_TYPE).default(core_1.APP_TYPE),
14
23
  userDid: validator_1.Joi.DID().required(),
15
- connected: validator_1.Joi.array().items(app_connected_1.AppConnectedSchema).optional().default([]),
16
- backup: validator_1.Joi.array().items(app_backup_1.AppBackupSchema).optional().default([]),
17
- restore: validator_1.Joi.array().items(app_restore_1.AppRestoreSchema).optional().default([]),
18
- disconnected: validator_1.Joi.array().items(app_disconnected_1.AppDisconnectedSchema).optional().default([]),
19
24
  permissions: validator_1.Joi.object()
20
25
  .pattern(validator_1.Joi.string(), validator_1.Joi.object().pattern(validator_1.Joi.string(), validator_1.Joi.number()))
21
26
  .optional()
@@ -1,3 +1 @@
1
- export * from './app-connected';
2
- export * from './app-disconnected';
3
1
  export * from './app';
@@ -14,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./app-connected"), exports);
18
- __exportStar(require("./app-disconnected"), exports);
19
17
  __exportStar(require("./app"), exports);
@@ -1,4 +1,4 @@
1
- import { Space, App, AppBackup, AppRestore, AppConnected, AppDisconnected, type AppPermissions } from '@did-space/core';
1
+ import { Space, App, type AppPermissions } from '@did-space/core';
2
2
  export interface AppTemplateOptions {
3
3
  space: Space;
4
4
  appDid: string;
@@ -22,13 +22,6 @@ export declare class AppTemplate {
22
22
  get(): Promise<App | null>;
23
23
  set(app: App): Promise<App>;
24
24
  isConnected(url: string): Promise<boolean>;
25
- addAppConnected(appConnected: AppConnected): Promise<AppConnected>;
26
- addAppDisconnected(appDisconnected: AppDisconnected): Promise<AppDisconnected>;
27
- addAppBackup(appBackup: AppBackup): Promise<AppBackup>;
28
- destroyAppBackup(): Promise<void>;
29
- updateAppBackupById(id: string, appBackup: Omit<AppBackup, 'id'>): Promise<AppBackup>;
30
- addAppRestore(appRestore: AppRestore): Promise<AppRestore>;
31
- updateAppRestoreById(id: string, appRestore: Omit<AppRestore, 'id'>): Promise<AppRestore>;
32
25
  static readonly PermissionMap: {
33
26
  listable: string;
34
27
  readable: string;
@@ -19,8 +19,6 @@ const did_1 = require("@arcblock/did");
19
19
  const js_yaml_1 = __importDefault(require("js-yaml"));
20
20
  const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
21
21
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
22
- const last_1 = __importDefault(require("lodash/last"));
23
- const findLastIndex_1 = __importDefault(require("lodash/findLastIndex"));
24
22
  const path_1 = require("path");
25
23
  const schema_1 = require("../schema");
26
24
  const libs_1 = require("../libs");
@@ -104,75 +102,6 @@ class AppTemplate {
104
102
  }
105
103
  });
106
104
  }
107
- addAppConnected(appConnected) {
108
- return __awaiter(this, void 0, void 0, function* () {
109
- const app = yield this.get();
110
- if (!app.connected) {
111
- app.connected = [];
112
- }
113
- app.connected.push(Object.assign({}, appConnected));
114
- const latestApp = yield this.set(app);
115
- return (0, last_1.default)(latestApp.connected);
116
- });
117
- }
118
- addAppDisconnected(appDisconnected) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const app = yield this.get();
121
- if (!app.disconnected) {
122
- app.disconnected = [];
123
- }
124
- app.disconnected.push(Object.assign({}, appDisconnected));
125
- const latestApp = yield this.set(app);
126
- return (0, last_1.default)(latestApp.disconnected);
127
- });
128
- }
129
- addAppBackup(appBackup) {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- const app = yield this.get();
132
- app.backup.push(Object.assign({}, appBackup));
133
- const latestApp = yield this.set(app);
134
- return (0, last_1.default)(latestApp.backup);
135
- });
136
- }
137
- destroyAppBackup() {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- const app = yield this.get();
140
- app.backup = [];
141
- yield this.set(app);
142
- });
143
- }
144
- updateAppBackupById(id, appBackup) {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- const app = yield this.get();
147
- const index = (0, findLastIndex_1.default)(app.backup, (b) => b.id === id);
148
- if (index === -1) {
149
- throw new Error(`AppBackup with id(${id}) not found`);
150
- }
151
- app.backup[index] = Object.assign(Object.assign(Object.assign({}, app.backup[index]), appBackup), { updateAt: new Date().toISOString() });
152
- yield this.set(app);
153
- return app.backup[index];
154
- });
155
- }
156
- addAppRestore(appRestore) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- const app = yield this.get();
159
- app.restore.push(Object.assign({}, appRestore));
160
- const latestApp = yield this.set(app);
161
- return (0, last_1.default)(latestApp.restore);
162
- });
163
- }
164
- updateAppRestoreById(id, appRestore) {
165
- return __awaiter(this, void 0, void 0, function* () {
166
- const app = yield this.get();
167
- const index = (0, findLastIndex_1.default)(app.restore, (b) => b.id === id);
168
- if (index === -1) {
169
- throw new Error(`AppRestore with id(${id}) not found`);
170
- }
171
- app.restore[index] = Object.assign(Object.assign({}, app.restore[index]), appRestore);
172
- yield this.set(app);
173
- return app.restore[index];
174
- });
175
- }
176
105
  updateAppPermissions({ scope, authorizedAppDid, permission, }) {
177
106
  var _a, _b, _c;
178
107
  return __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-space/template",
3
- "version": "0.5.78",
3
+ "version": "0.5.79",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,10 +28,10 @@
28
28
  "verify": "npm run lint:fix && npm run test && npm run build"
29
29
  },
30
30
  "dependencies": {
31
- "@arcblock/did": "^1.18.152",
32
- "@arcblock/validator": "^1.18.152",
33
- "@did-space/core": "0.5.66",
34
- "axios": "^1.7.8",
31
+ "@arcblock/did": "^1.18.160",
32
+ "@arcblock/validator": "^1.18.160",
33
+ "@did-space/core": "^0.5.79",
34
+ "axios": "^1.7.9",
35
35
  "is-url": "^1.2.4",
36
36
  "joi": "^17.13.3",
37
37
  "js-yaml": "^4.1.0",
@@ -54,5 +54,5 @@
54
54
  "ts-jest": "^28.0.8",
55
55
  "typescript": "^4.9.5"
56
56
  },
57
- "gitHead": "a78e40b323dff7d1dd378b6b2ef8fd805df4df4d"
57
+ "gitHead": "5961ad5182992541aedf083537cf33abed98ba4f"
58
58
  }
@@ -1,2 +0,0 @@
1
- import type { ObjectSchema } from 'joi';
2
- export declare const AppBackupSchema: ObjectSchema<any>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppBackupSchema = void 0;
4
- const validator_1 = require("@arcblock/validator");
5
- const core_1 = require("@did-space/core");
6
- const constants_1 = require("@did-space/core/dist/constants");
7
- const app_connected_1 = require("./app-connected");
8
- const nanoid_1 = require("./nanoid");
9
- exports.AppBackupSchema = validator_1.Joi.object({
10
- id: nanoid_1.NanoidSchema,
11
- type: validator_1.Joi.string().valid(core_1.APP_BACKUP_TYPE).default(core_1.APP_BACKUP_TYPE),
12
- userDid: validator_1.Joi.DID().required(),
13
- referrer: app_connected_1.AppUrlSchema,
14
- // 目前指向的是 server 的 did 地址
15
- serverDid: validator_1.Joi.string().optional().allow('').default(''),
16
- // 本质上是始终指向最新的 appDid,目前主要是 rotate 的 blocklet 在还原的时候会用到这个参数
17
- signerDid: validator_1.Joi.DID().optional().allow('').default(''),
18
- appName: validator_1.Joi.string().optional().allow('').default(''),
19
- appDescription: validator_1.Joi.string().optional().allow('').default(''),
20
- // 默认是 APP_BACKUP_STATUS.DEFAULT 是因为我要兼容以前的旧版本的数据
21
- status: validator_1.Joi.string()
22
- .optional()
23
- .allow('')
24
- .valid(...Object.values(constants_1.APP_BACKUP_STATUS))
25
- .default(constants_1.APP_BACKUP_STATUS.DEFAULT),
26
- message: validator_1.Joi.string().optional().allow('').default(''),
27
- createAt: validator_1.Joi.string()
28
- .optional()
29
- .default(() => new Date().toISOString()),
30
- updateAt: validator_1.Joi.string()
31
- .optional()
32
- .allow('')
33
- .default(() => new Date().toISOString()),
34
- });
@@ -1,5 +0,0 @@
1
- export declare const AppUrlSchema: import("joi").StringSchema<string>;
2
- /**
3
- * @link My Data 准备工作 之 交互设计 && 实现 https://team.arcblock.io/comment/discussions/594accd7-9379-4700-87a4-9fd5ef5b0bee
4
- */
5
- export declare const AppConnectedSchema: import("joi").ObjectSchema<any>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AppConnectedSchema = exports.AppUrlSchema = void 0;
7
- const validator_1 = require("@arcblock/validator");
8
- const is_url_1 = __importDefault(require("is-url"));
9
- const core_1 = require("@did-space/core");
10
- const nanoid_1 = require("./nanoid");
11
- exports.AppUrlSchema = validator_1.Joi.string()
12
- .allow('')
13
- .required()
14
- .custom((value, helper) => {
15
- if (!(0, is_url_1.default)(value)) {
16
- return helper.message(`appUrl(${value}) must be a http/https url`);
17
- }
18
- return value;
19
- });
20
- /**
21
- * @link My Data 准备工作 之 交互设计 && 实现 https://team.arcblock.io/comment/discussions/594accd7-9379-4700-87a4-9fd5ef5b0bee
22
- */
23
- exports.AppConnectedSchema = validator_1.Joi.object({
24
- id: nanoid_1.NanoidSchema,
25
- type: validator_1.Joi.string().valid(core_1.APP_CONNECT_TYPE).default(core_1.APP_CONNECT_TYPE),
26
- userDid: validator_1.Joi.DID().required(),
27
- spaceDid: validator_1.Joi.DID().required(),
28
- appDid: validator_1.Joi.DID().required(),
29
- appName: validator_1.Joi.string().required(),
30
- appDescription: validator_1.Joi.string().optional().allow('').default(''),
31
- scopes: validator_1.Joi.string().required(),
32
- appUrl: exports.AppUrlSchema,
33
- referrer: exports.AppUrlSchema,
34
- createAt: validator_1.Joi.string()
35
- .optional()
36
- .default(() => new Date().toISOString()),
37
- updateAt: validator_1.Joi.string()
38
- .optional()
39
- .default(() => new Date().toISOString()),
40
- });
@@ -1,4 +0,0 @@
1
- /**
2
- * @link My Data 准备工作 之 交互设计 && 实现 https://team.arcblock.io/comment/discussions/594accd7-9379-4700-87a4-9fd5ef5b0bee
3
- */
4
- export declare const AppDisconnectedSchema: import("joi").ObjectSchema<any>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppDisconnectedSchema = void 0;
4
- const validator_1 = require("@arcblock/validator");
5
- const core_1 = require("@did-space/core");
6
- const nanoid_1 = require("./nanoid");
7
- /**
8
- * @link My Data 准备工作 之 交互设计 && 实现 https://team.arcblock.io/comment/discussions/594accd7-9379-4700-87a4-9fd5ef5b0bee
9
- */
10
- exports.AppDisconnectedSchema = validator_1.Joi.object({
11
- id: nanoid_1.NanoidSchema,
12
- type: validator_1.Joi.string().valid(core_1.APP_DISCONNECT_TYPE).default(core_1.APP_DISCONNECT_TYPE),
13
- createAt: validator_1.Joi.string()
14
- .optional()
15
- .default(() => new Date().toISOString()),
16
- updateAt: validator_1.Joi.string()
17
- .optional()
18
- .default(() => new Date().toISOString()),
19
- });
@@ -1,2 +0,0 @@
1
- import type { ObjectSchema } from 'joi';
2
- export declare const AppRestoreSchema: ObjectSchema<any>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppRestoreSchema = void 0;
4
- const validator_1 = require("@arcblock/validator");
5
- const core_1 = require("@did-space/core");
6
- const app_connected_1 = require("./app-connected");
7
- const nanoid_1 = require("./nanoid");
8
- exports.AppRestoreSchema = validator_1.Joi.object({
9
- id: nanoid_1.NanoidSchema,
10
- type: validator_1.Joi.string().valid(core_1.APP_RESTORE_TYPE).default(core_1.APP_RESTORE_TYPE),
11
- userDid: validator_1.Joi.DID().required(),
12
- referrer: app_connected_1.AppUrlSchema,
13
- // 目前指向的是 server 的 did 地址
14
- serverDid: validator_1.Joi.string().optional().allow('').default(''),
15
- appName: validator_1.Joi.string().optional().allow('').default(''),
16
- appDescription: validator_1.Joi.string().optional().allow('').default(''),
17
- // 默认是 APP_BACKUP_STATUS.DEFAULT 是因为我要兼容以前的旧版本的数据
18
- status: validator_1.Joi.string()
19
- .optional()
20
- .allow('')
21
- .valid(...Object.values(core_1.APP_BACKUP_STATUS))
22
- .default(core_1.APP_BACKUP_STATUS.DEFAULT),
23
- message: validator_1.Joi.string().optional().allow('').default(''),
24
- createAt: validator_1.Joi.string()
25
- .optional()
26
- .default(() => new Date().toISOString()),
27
- updateAt: validator_1.Joi.string().optional().allow('').default(''),
28
- });