@blocklet/did-space-js 0.5.58
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/README.md +77 -0
- package/dist/client/index.d.ts +40 -0
- package/dist/client/index.js +110 -0
- package/dist/commands/backup/backup-blocklet.d.ts +14 -0
- package/dist/commands/backup/backup-blocklet.js +83 -0
- package/dist/commands/backup/index.d.ts +3 -0
- package/dist/commands/backup/index.js +19 -0
- package/dist/commands/backup/post-app-backup.d.ts +9 -0
- package/dist/commands/backup/post-app-backup.js +49 -0
- package/dist/commands/backup/put-app-backup.d.ts +9 -0
- package/dist/commands/backup/put-app-backup.js +49 -0
- package/dist/commands/base.d.ts +21 -0
- package/dist/commands/base.js +47 -0
- package/dist/commands/incremental-backup/backup-blocklet.d.ts +14 -0
- package/dist/commands/incremental-backup/backup-blocklet.js +90 -0
- package/dist/commands/incremental-backup/index.d.ts +1 -0
- package/dist/commands/incremental-backup/index.js +17 -0
- package/dist/commands/incremental-sync/index.d.ts +2 -0
- package/dist/commands/incremental-sync/index.js +18 -0
- package/dist/commands/incremental-sync/sync-base.d.ts +76 -0
- package/dist/commands/incremental-sync/sync-base.js +236 -0
- package/dist/commands/incremental-sync/sync-push.d.ts +30 -0
- package/dist/commands/incremental-sync/sync-push.js +202 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +25 -0
- package/dist/commands/nft/index.d.ts +1 -0
- package/dist/commands/nft/index.js +17 -0
- package/dist/commands/nft/put-nft-object.d.ts +20 -0
- package/dist/commands/nft/put-nft-object.js +143 -0
- package/dist/commands/object/delete-object.d.ts +7 -0
- package/dist/commands/object/delete-object.js +38 -0
- package/dist/commands/object/get-object.d.ts +7 -0
- package/dist/commands/object/get-object.js +43 -0
- package/dist/commands/object/index.d.ts +5 -0
- package/dist/commands/object/index.js +21 -0
- package/dist/commands/object/list-object.d.ts +7 -0
- package/dist/commands/object/list-object.js +31 -0
- package/dist/commands/object/list-objects.d.ts +7 -0
- package/dist/commands/object/list-objects.js +44 -0
- package/dist/commands/object/put-object.d.ts +7 -0
- package/dist/commands/object/put-object.js +61 -0
- package/dist/commands/restore/index.d.ts +3 -0
- package/dist/commands/restore/index.js +19 -0
- package/dist/commands/restore/post-app-restore.d.ts +7 -0
- package/dist/commands/restore/post-app-restore.js +45 -0
- package/dist/commands/restore/put-app-restore.d.ts +9 -0
- package/dist/commands/restore/put-app-restore.js +49 -0
- package/dist/commands/restore/restore-blocklet.d.ts +14 -0
- package/dist/commands/restore/restore-blocklet.js +80 -0
- package/dist/commands/space/head.d.ts +8 -0
- package/dist/commands/space/head.js +52 -0
- package/dist/commands/space/index.d.ts +1 -0
- package/dist/commands/space/index.js +17 -0
- package/dist/commands/sync/index.d.ts +3 -0
- package/dist/commands/sync/index.js +19 -0
- package/dist/commands/sync/sync-folder-base.d.ts +105 -0
- package/dist/commands/sync/sync-folder-base.js +319 -0
- package/dist/commands/sync/sync-folder-pull.d.ts +13 -0
- package/dist/commands/sync/sync-folder-pull.js +151 -0
- package/dist/commands/sync/sync-folder-push.d.ts +20 -0
- package/dist/commands/sync/sync-folder-push.js +166 -0
- package/dist/did-document/did-document.d.ts +29 -0
- package/dist/did-document/did-document.js +2 -0
- package/dist/did-document/index.d.ts +3 -0
- package/dist/did-document/index.js +19 -0
- package/dist/did-document/sign-document.d.ts +3 -0
- package/dist/did-document/sign-document.js +13 -0
- package/dist/did-document/verify-document.d.ts +10 -0
- package/dist/did-document/verify-document.js +35 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/libs/api.d.ts +3 -0
- package/dist/libs/api.js +65 -0
- package/dist/libs/did.d.ts +9 -0
- package/dist/libs/did.js +34 -0
- package/dist/libs/encoding.d.ts +7 -0
- package/dist/libs/encoding.js +17 -0
- package/dist/libs/error.d.ts +4 -0
- package/dist/libs/error.js +27 -0
- package/dist/libs/hash.d.ts +1 -0
- package/dist/libs/hash.js +5 -0
- package/dist/libs/index.d.ts +11 -0
- package/dist/libs/index.js +27 -0
- package/dist/libs/logger.d.ts +2 -0
- package/dist/libs/logger.js +12 -0
- package/dist/libs/object-integrality.d.ts +1 -0
- package/dist/libs/object-integrality.js +13 -0
- package/dist/libs/performance.d.ts +7 -0
- package/dist/libs/performance.js +13 -0
- package/dist/libs/sleep.d.ts +1 -0
- package/dist/libs/sleep.js +9 -0
- package/dist/libs/space.d.ts +16 -0
- package/dist/libs/space.js +56 -0
- package/dist/libs/stream.d.ts +3 -0
- package/dist/libs/stream.js +10 -0
- package/dist/meta/backup/backup-blocklet-command.d.ts +50 -0
- package/dist/meta/backup/backup-blocklet-command.js +2 -0
- package/dist/meta/backup/index.d.ts +3 -0
- package/dist/meta/backup/index.js +19 -0
- package/dist/meta/backup/post-app-backup-command.d.ts +8 -0
- package/dist/meta/backup/post-app-backup-command.js +16 -0
- package/dist/meta/backup/put-app-backup-command.d.ts +7 -0
- package/dist/meta/backup/put-app-backup-command.js +18 -0
- package/dist/meta/incremental-backup/backup-blocklet-command.d.ts +50 -0
- package/dist/meta/incremental-backup/backup-blocklet-command.js +2 -0
- package/dist/meta/incremental-backup/index.d.ts +1 -0
- package/dist/meta/incremental-backup/index.js +17 -0
- package/dist/meta/index.d.ts +7 -0
- package/dist/meta/index.js +23 -0
- package/dist/meta/nft/index.d.ts +1 -0
- package/dist/meta/nft/index.js +17 -0
- package/dist/meta/nft/put-nft-object-command.d.ts +51 -0
- package/dist/meta/nft/put-nft-object-command.js +2 -0
- package/dist/meta/object/delete-object-command.d.ts +6 -0
- package/dist/meta/object/delete-object-command.js +2 -0
- package/dist/meta/object/get-object-command.d.ts +10 -0
- package/dist/meta/object/get-object-command.js +2 -0
- package/dist/meta/object/head-object-command.d.ts +13 -0
- package/dist/meta/object/head-object-command.js +2 -0
- package/dist/meta/object/index.d.ts +5 -0
- package/dist/meta/object/index.js +21 -0
- package/dist/meta/object/list-object-command.d.ts +6 -0
- package/dist/meta/object/list-object-command.js +2 -0
- package/dist/meta/object/list-objects-command.d.ts +8 -0
- package/dist/meta/object/list-objects-command.js +2 -0
- package/dist/meta/object/put-object-command.d.ts +29 -0
- package/dist/meta/object/put-object-command.js +2 -0
- package/dist/meta/restore/index.d.ts +3 -0
- package/dist/meta/restore/index.js +19 -0
- package/dist/meta/restore/post-app-restore-command.d.ts +8 -0
- package/dist/meta/restore/post-app-restore-command.js +13 -0
- package/dist/meta/restore/put-app-restore-command.d.ts +7 -0
- package/dist/meta/restore/put-app-restore-command.js +18 -0
- package/dist/meta/restore/restore-blocklet-command.d.ts +28 -0
- package/dist/meta/restore/restore-blocklet-command.js +2 -0
- package/dist/meta/spaces-client-options.d.ts +5 -0
- package/dist/meta/spaces-client-options.js +2 -0
- package/dist/meta/sync/incremental-sync-base-command.d.ts +7 -0
- package/dist/meta/sync/incremental-sync-base-command.js +2 -0
- package/dist/meta/sync/incremental-sync-push-command.d.ts +8 -0
- package/dist/meta/sync/incremental-sync-push-command.js +2 -0
- package/dist/meta/sync/index.d.ts +6 -0
- package/dist/meta/sync/index.js +22 -0
- package/dist/meta/sync/sync-base-command.d.ts +121 -0
- package/dist/meta/sync/sync-base-command.js +2 -0
- package/dist/meta/sync/sync-folder-base-command.d.ts +12 -0
- package/dist/meta/sync/sync-folder-base-command.js +2 -0
- package/dist/meta/sync/sync-folder-pull-command.d.ts +5 -0
- package/dist/meta/sync/sync-folder-pull-command.js +2 -0
- package/dist/meta/sync/sync-folder-push-command.d.ts +7 -0
- package/dist/meta/sync/sync-folder-push-command.js +2 -0
- package/dist/protocol/command.protocol.d.ts +68 -0
- package/dist/protocol/command.protocol.js +2 -0
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +17 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +17 -0
- package/dist/security/request-signature.d.ts +32 -0
- package/dist/security/request-signature.js +140 -0
- package/package.json +78 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Object } from '@did-space/core';
|
|
2
|
+
import { CommandOutput } from '../../protocol';
|
|
3
|
+
export interface ListObjectsCommandInput {
|
|
4
|
+
key: string;
|
|
5
|
+
recursive?: false | true;
|
|
6
|
+
ignoreDirectories?: false | true;
|
|
7
|
+
}
|
|
8
|
+
export type ListObjectsCommandOutput = CommandOutput<Object[]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Data } from '@did-space/core';
|
|
2
|
+
import type { CommandOutput } from '../../protocol';
|
|
3
|
+
export interface PutObjectCommandInput {
|
|
4
|
+
/**
|
|
5
|
+
* @description 可以是一个文件名或者文件夹
|
|
6
|
+
* @type {string}
|
|
7
|
+
* @memberof PutObjectCommandInput
|
|
8
|
+
*/
|
|
9
|
+
key: string;
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* @type {Data}
|
|
13
|
+
* @memberof PutObjectCommandInput
|
|
14
|
+
*/
|
|
15
|
+
data?: Data;
|
|
16
|
+
/**
|
|
17
|
+
* @description 对象的 hash 值,我们期望它是 ipfs v1 的 hash
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof PutObjectCommandInput
|
|
20
|
+
*/
|
|
21
|
+
hash?: string;
|
|
22
|
+
/**
|
|
23
|
+
* @description 存储文件夹或者文件的元数据
|
|
24
|
+
* @type {Record<string, any>}
|
|
25
|
+
* @memberof PutObjectCommandInput
|
|
26
|
+
*/
|
|
27
|
+
metadata?: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
export type PutObjectCommandOutput = CommandOutput<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./post-app-restore-command"), exports);
|
|
18
|
+
__exportStar(require("./put-app-restore-command"), exports);
|
|
19
|
+
__exportStar(require("./restore-blocklet-command"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppRestore } from '@did-space/core';
|
|
2
|
+
import type { ObjectSchema } from 'joi';
|
|
3
|
+
import { CommandOutput } from '../../protocol/command.protocol';
|
|
4
|
+
export declare const PostAppRestoreCommandInputSchema: ObjectSchema<any>;
|
|
5
|
+
export interface PostAppRestoreCommandInput extends Pick<AppRestore, 'userDid' | 'referrer' | 'serverDid'> {
|
|
6
|
+
}
|
|
7
|
+
export interface PostAppRestoreCommandOutput extends CommandOutput<Required<AppRestore>> {
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostAppRestoreCommandInputSchema = void 0;
|
|
4
|
+
const validator_1 = require("@arcblock/validator");
|
|
5
|
+
exports.PostAppRestoreCommandInputSchema = validator_1.Joi.object({
|
|
6
|
+
userDid: validator_1.Joi.DID(),
|
|
7
|
+
referrer: validator_1.Joi.string()
|
|
8
|
+
.uri({
|
|
9
|
+
scheme: ['http', 'https'],
|
|
10
|
+
})
|
|
11
|
+
.required(),
|
|
12
|
+
serverDid: validator_1.Joi.string().optional().allow('').default(''),
|
|
13
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppRestore } from '@did-space/core';
|
|
2
|
+
import type { ObjectSchema } from 'joi';
|
|
3
|
+
import type { CommandOutput } from '../../protocol';
|
|
4
|
+
export declare const PutAppRestoreCommandInputSchema: ObjectSchema<any>;
|
|
5
|
+
export type PutAppRestoreCommandInput = Required<Pick<AppRestore, 'id'>> & Partial<AppRestore>;
|
|
6
|
+
export interface PutAppRestoreCommandOutput extends CommandOutput<Required<AppRestore>> {
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PutAppRestoreCommandInputSchema = void 0;
|
|
4
|
+
const validator_1 = require("@arcblock/validator");
|
|
5
|
+
const core_1 = require("@did-space/core");
|
|
6
|
+
exports.PutAppRestoreCommandInputSchema = validator_1.Joi.object({
|
|
7
|
+
id: validator_1.Joi.string().required(),
|
|
8
|
+
updateAt: validator_1.Joi.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.default(() => new Date().toISOString()),
|
|
11
|
+
// 默认是 APP_BACKUP_STATUS.DEFAULT 是因为我要兼容以前的旧版本的数据
|
|
12
|
+
status: validator_1.Joi.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.allow('')
|
|
15
|
+
.valid(...Object.values(core_1.APP_BACKUP_STATUS))
|
|
16
|
+
.default(core_1.APP_BACKUP_STATUS.DEFAULT),
|
|
17
|
+
message: validator_1.Joi.string().optional().allow('').default(''),
|
|
18
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SyncFolderBaseCommandInput, SyncFolderBaseCommandOutput } from '../sync/sync-folder-base-command';
|
|
2
|
+
export interface RestoreBlockletCommandInput extends Omit<SyncFolderBaseCommandInput, 'source'> {
|
|
3
|
+
appDid: string;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @description 备份人员的 userDid
|
|
7
|
+
* @type {string}
|
|
8
|
+
* @memberof RestoreBlockletCommandInput
|
|
9
|
+
*/
|
|
10
|
+
userDid: string;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @description 用户当时在什么页面备份的呢?
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @memberof RestoreBlockletCommandInput
|
|
16
|
+
*/
|
|
17
|
+
referrer: string;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @description 指向 server 的 did 地址
|
|
21
|
+
* @default ""
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @memberof RestoreBlockletCommandInput
|
|
24
|
+
*/
|
|
25
|
+
serverDid: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RestoreBlockletCommandOutput extends SyncFolderBaseCommandOutput {
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Object } from '@did-space/core';
|
|
2
|
+
import { SyncBaseCommandInput, SyncBaseCommandOutput } from './sync-base-command';
|
|
3
|
+
export interface IncrementalSyncBaseCommandInput extends SyncBaseCommandInput {
|
|
4
|
+
source: Object[];
|
|
5
|
+
}
|
|
6
|
+
export interface IncrementalSyncBaseCommandOutput extends SyncBaseCommandOutput {
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Object, type ObjectMetadata } from '@did-space/core';
|
|
2
|
+
import { SyncBaseCommandInput, SyncBaseCommandOutput } from './sync-base-command';
|
|
3
|
+
export interface IncrementalSyncPushCommandInput extends SyncBaseCommandInput {
|
|
4
|
+
source: Object[];
|
|
5
|
+
metadata?: ObjectMetadata;
|
|
6
|
+
}
|
|
7
|
+
export interface IncrementalSyncPushCommandOutput extends SyncBaseCommandOutput {
|
|
8
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './incremental-sync-push-command';
|
|
2
|
+
export * from './incremental-sync-base-command';
|
|
3
|
+
export * from './sync-base-command';
|
|
4
|
+
export * from './sync-folder-base-command';
|
|
5
|
+
export * from './sync-folder-pull-command';
|
|
6
|
+
export * from './sync-folder-push-command';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./incremental-sync-push-command"), exports);
|
|
18
|
+
__exportStar(require("./incremental-sync-base-command"), exports);
|
|
19
|
+
__exportStar(require("./sync-base-command"), exports);
|
|
20
|
+
__exportStar(require("./sync-folder-base-command"), exports);
|
|
21
|
+
__exportStar(require("./sync-folder-pull-command"), exports);
|
|
22
|
+
__exportStar(require("./sync-folder-push-command"), exports);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Object } from '@did-space/core';
|
|
2
|
+
import type { CommandOutput } from '../../protocol';
|
|
3
|
+
export interface OnProgressInput {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @description 已完成的任务数
|
|
7
|
+
* @type {number}
|
|
8
|
+
* @memberof OnProgressInput
|
|
9
|
+
*/
|
|
10
|
+
completed: number;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @description 总任务数
|
|
14
|
+
* @type {number}
|
|
15
|
+
* @memberof OnProgressInput
|
|
16
|
+
*/
|
|
17
|
+
total: number;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @description 文件的key
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @memberof OnProgressInput
|
|
23
|
+
*/
|
|
24
|
+
key: string;
|
|
25
|
+
}
|
|
26
|
+
export interface OnAfterUploadInput {
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @description 已完成的任务数
|
|
30
|
+
* @type {number}
|
|
31
|
+
* @memberof OnProgressInput
|
|
32
|
+
*/
|
|
33
|
+
completed: number;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @description 总任务数
|
|
37
|
+
* @type {number}
|
|
38
|
+
* @memberof OnProgressInput
|
|
39
|
+
*/
|
|
40
|
+
total: number;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @description 文件的key
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @memberof OnProgressInput
|
|
46
|
+
*/
|
|
47
|
+
key: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SyncBaseCommandInput {
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @description 将 source 同步到 target, 文件夹请添加尾杠 /
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @memberof SyncFolderBaseCommandInput
|
|
55
|
+
*/
|
|
56
|
+
target: string;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @description 并发数,默认为 256
|
|
60
|
+
* @default 256
|
|
61
|
+
* @type {number}
|
|
62
|
+
* @memberof SyncFolderBaseCommandInput
|
|
63
|
+
*/
|
|
64
|
+
concurrency?: number;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @description 同步失败后重试次数,默认重试 3 次
|
|
68
|
+
* @default 3
|
|
69
|
+
* @type {number}
|
|
70
|
+
* @memberof SyncFolderPushCommandInput
|
|
71
|
+
*/
|
|
72
|
+
retryCount?: number;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @description 是否输出 debug 信息
|
|
76
|
+
* @default false
|
|
77
|
+
* @type {boolean}
|
|
78
|
+
* @memberof SyncFolderPushCommandInput
|
|
79
|
+
*/
|
|
80
|
+
debug?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @description 过滤函数,可用于过滤掉某些目录或者文件,需要 sync 请返回 true, 不需要 sync 请返回 false
|
|
84
|
+
* @default 默认同步所有文件,不过滤
|
|
85
|
+
* @memberof SyncFolderBaseCommandInput
|
|
86
|
+
*/
|
|
87
|
+
filter?: (object: Object, index: number, objects: Object[]) => boolean;
|
|
88
|
+
onProgress?: (input: OnProgressInput) => Promise<void>;
|
|
89
|
+
onAfterUpload?: (input: OnAfterUploadInput) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* @description 可以临时存放文件的一个目录,可不填写,但运行时一定有值
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @memberof SyncBaseCommandInput
|
|
94
|
+
*/
|
|
95
|
+
tmpDir?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface SyncBaseCommandOutputData {
|
|
98
|
+
/**
|
|
99
|
+
* @description 发生错误的任务数
|
|
100
|
+
* @type {number}
|
|
101
|
+
* @memberof SyncFolderBaseCommandOutput
|
|
102
|
+
*/
|
|
103
|
+
errorCount: number;
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @description 总任务数
|
|
107
|
+
* @type {number}
|
|
108
|
+
* @memberof SyncFolderBaseCommandOutput
|
|
109
|
+
*/
|
|
110
|
+
count: number;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @description 花了多少秒才处理完成呢?
|
|
114
|
+
* @unit 秒(s)
|
|
115
|
+
* @type {number}
|
|
116
|
+
* @memberof SyncFolderBaseCommandOutput
|
|
117
|
+
*/
|
|
118
|
+
duration: number;
|
|
119
|
+
}
|
|
120
|
+
export interface SyncBaseCommandOutput extends CommandOutput<SyncBaseCommandOutputData> {
|
|
121
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SyncBaseCommandInput, SyncBaseCommandOutput } from './sync-base-command';
|
|
2
|
+
export interface SyncFolderBaseCommandInput extends SyncBaseCommandInput {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @description 需要被同步的 source, 文件夹请添加尾杠 /
|
|
6
|
+
* @type {string}
|
|
7
|
+
* @memberof SyncFolderBaseCommandInput
|
|
8
|
+
*/
|
|
9
|
+
source: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SyncFolderBaseCommandOutput extends SyncBaseCommandOutput {
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SyncFolderBaseCommandInput, SyncFolderBaseCommandOutput } from './sync-folder-base-command';
|
|
2
|
+
export interface SyncFolderPullCommandInput extends SyncFolderBaseCommandInput {
|
|
3
|
+
}
|
|
4
|
+
export interface SyncFolderPullCommandOutput extends SyncFolderBaseCommandOutput {
|
|
5
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ObjectMetadata } from '@did-space/core';
|
|
2
|
+
import { SyncFolderBaseCommandInput, SyncFolderBaseCommandOutput } from './sync-folder-base-command';
|
|
3
|
+
export interface SyncFolderPushCommandInput extends SyncFolderBaseCommandInput {
|
|
4
|
+
metadata?: ObjectMetadata;
|
|
5
|
+
}
|
|
6
|
+
export interface SyncFolderPushCommandOutput extends SyncFolderBaseCommandOutput {
|
|
7
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { WalletObject } from '@ocap/wallet';
|
|
2
|
+
import type { Response } from 'got';
|
|
3
|
+
export interface CommandInput {
|
|
4
|
+
}
|
|
5
|
+
export interface CommandOutput<D = any> {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* @type {string}
|
|
10
|
+
* @memberof CommandOutput
|
|
11
|
+
*/
|
|
12
|
+
statusCode: number;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @description 一般来说,发生错误的时候才会有值
|
|
16
|
+
* @type {string}
|
|
17
|
+
* @memberof CommandOutput
|
|
18
|
+
*/
|
|
19
|
+
statusMessage?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @memberof CommandOutput
|
|
24
|
+
*/
|
|
25
|
+
stack?: string;
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* @type {D}
|
|
29
|
+
* @memberof CommandOutput
|
|
30
|
+
*/
|
|
31
|
+
data: D;
|
|
32
|
+
response?: Response;
|
|
33
|
+
}
|
|
34
|
+
export interface SpaceClientOptions {
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @default blocklet wallet
|
|
38
|
+
* @type {WalletObject}
|
|
39
|
+
* @memberof SpaceClientOptions
|
|
40
|
+
*/
|
|
41
|
+
wallet: WalletObject;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @description spaces endpoint
|
|
45
|
+
* @example https://cedcaa27-znkomkclejcfbjaxw9knzzebmzmqrxjnn9bb.did.abtnet.io/api/space/z3T6EHN7sLhH5cty1PshDeSipeG7JNxEVaRFS/app/zNKabhhwdvVmXjtRTtSHk2YQz4pdDPStV289/
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof SpaceClientOptions
|
|
48
|
+
*/
|
|
49
|
+
endpoint: string;
|
|
50
|
+
/**
|
|
51
|
+
* A jwt token that certifies the requester is authorized to access the space
|
|
52
|
+
* @description delegation token
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @memberof SpaceClientOptions
|
|
55
|
+
*/
|
|
56
|
+
delegation?: string;
|
|
57
|
+
/**
|
|
58
|
+
* @description
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @memberof SpaceClientOptions
|
|
61
|
+
*/
|
|
62
|
+
componentDid?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface CommandProtocol<Input extends CommandInput, Output extends CommandOutput> {
|
|
65
|
+
input: Input;
|
|
66
|
+
context: SpaceClientOptions;
|
|
67
|
+
request(...args: any[]): Promise<Output>;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './command.protocol';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./command.protocol"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './request-signature';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./request-signature"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletObject } from '@ocap/wallet';
|
|
2
|
+
type Method = import('got/dist/source').Method;
|
|
3
|
+
type Headers = {
|
|
4
|
+
'x-app-did': string;
|
|
5
|
+
'x-app-pk': string;
|
|
6
|
+
'x-app-token': string;
|
|
7
|
+
'x-app-delegation': string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
declare function verifyDelegation(delegation: string, delegatee: WalletObject): string;
|
|
11
|
+
declare function signRequest({ url, method, data, headers, wallet, delegation, }: {
|
|
12
|
+
url: string;
|
|
13
|
+
method: Method;
|
|
14
|
+
data: any;
|
|
15
|
+
headers: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
wallet: WalletObject;
|
|
19
|
+
delegation?: string;
|
|
20
|
+
}): {
|
|
21
|
+
url: string;
|
|
22
|
+
method: Method;
|
|
23
|
+
data: any;
|
|
24
|
+
headers: Headers;
|
|
25
|
+
};
|
|
26
|
+
declare function verifyRequest({ url, method, data, headers, }: {
|
|
27
|
+
url: string;
|
|
28
|
+
method: Method;
|
|
29
|
+
data: any;
|
|
30
|
+
headers: Headers;
|
|
31
|
+
}): string;
|
|
32
|
+
export { signRequest, verifyRequest, verifyDelegation };
|