@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,18 @@
|
|
|
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("./sync-base"), exports);
|
|
18
|
+
__exportStar(require("./sync-push"), exports);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import PQueue from 'p-queue';
|
|
3
|
+
import { IncrementalSyncBaseCommandInput, IncrementalSyncBaseCommandOutput, SyncFolderPullCommandOutput } from '../../meta';
|
|
4
|
+
import { BaseCommand } from '../base';
|
|
5
|
+
import { ObjectsMap, SyncObject } from '../sync';
|
|
6
|
+
import type { SpaceClientOptions } from '../../protocol';
|
|
7
|
+
/**
|
|
8
|
+
* @see s3 sync https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync
|
|
9
|
+
* @see Keep-alive 和连接重用的 NodeJS https://azureossd.github.io/2022/03/10/NodeJS-with-Keep-Alives-and-Connection-Reuse/index.html
|
|
10
|
+
* @export
|
|
11
|
+
* @class SyncFolderPushCommand
|
|
12
|
+
* @extends {BaseCommand<SyncFolderCommandInput, SyncFolderPushCommandOutput>}
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class IncrementalSyncBaseCommand<CommandInput extends IncrementalSyncBaseCommandInput, CommandOutput extends IncrementalSyncBaseCommandOutput> extends BaseCommand<CommandInput, CommandOutput> {
|
|
15
|
+
protected readonly queue: PQueue;
|
|
16
|
+
protected readonly startTime: number;
|
|
17
|
+
static readonly DEFAULT_RETRY_COUNT: number;
|
|
18
|
+
static readonly MAX_RETRY_COUNT: number;
|
|
19
|
+
static readonly DEFAULT_CONCURRENCY: number;
|
|
20
|
+
static readonly MAX_CONCURRENCY: number;
|
|
21
|
+
private retryCount;
|
|
22
|
+
constructor(input: IncrementalSyncBaseCommandInput, context?: SpaceClientOptions);
|
|
23
|
+
private initialize;
|
|
24
|
+
abstract getLocalObjectsMap(): Promise<ObjectsMap>;
|
|
25
|
+
abstract getRemoteObjectsMap(): Promise<ObjectsMap>;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @description 仅在开启调试模式时,输出调试信息,
|
|
29
|
+
* @protected
|
|
30
|
+
* @param {{
|
|
31
|
+
* completedCount: number;
|
|
32
|
+
* errorCount: number;
|
|
33
|
+
* totalCount: number;
|
|
34
|
+
* }} {
|
|
35
|
+
* completedCount,
|
|
36
|
+
* errorCount,
|
|
37
|
+
* totalCount,
|
|
38
|
+
* }
|
|
39
|
+
* @return {*} {Promise<void>}
|
|
40
|
+
* @memberof IncrementalSyncBaseCommand
|
|
41
|
+
*/
|
|
42
|
+
protected printDebugInfo({ direction, completedCount, errorCount, totalCount, }: {
|
|
43
|
+
direction: 'pull' | 'push';
|
|
44
|
+
completedCount: number;
|
|
45
|
+
errorCount: number;
|
|
46
|
+
totalCount: number;
|
|
47
|
+
}): void;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* @protected
|
|
52
|
+
* @param {(Error | AxiosError)} error
|
|
53
|
+
* @return {*} {Promise<void>}
|
|
54
|
+
* @memberof IncrementalSyncBaseCommand
|
|
55
|
+
*/
|
|
56
|
+
protected retryRequest(error: Error | AxiosError): Promise<SyncFolderPullCommandOutput>;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @description 比较双方的文件到底谁更新鲜,更新鲜的数据才需要被同步上去
|
|
60
|
+
* @protected
|
|
61
|
+
* @param {ObjectsMap} fromObjectsMap
|
|
62
|
+
* @param {ObjectsMap} toObjectsMap
|
|
63
|
+
* @return {*} {Promise<string[]>}
|
|
64
|
+
* @memberof IncrementalSyncBaseCommand
|
|
65
|
+
*/
|
|
66
|
+
protected getWaitSyncObjects(fromObjectsMap: ObjectsMap, toObjectsMap: ObjectsMap): Promise<SyncObject[]>;
|
|
67
|
+
/**
|
|
68
|
+
* @description 判断一个对象是否应该被备份
|
|
69
|
+
* @protected
|
|
70
|
+
* @param {string} absolutePath
|
|
71
|
+
* @return {*} {Promise<boolean>}
|
|
72
|
+
* @memberof IncrementalSyncBaseCommand
|
|
73
|
+
*/
|
|
74
|
+
protected shouldBeBackup(absolutePath: string): Promise<boolean>;
|
|
75
|
+
destroy(): Promise<void>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
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.IncrementalSyncBaseCommand = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
8
|
+
const core_1 = require("@did-space/core");
|
|
9
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
10
|
+
const isUndefined_1 = __importDefault(require("lodash/isUndefined"));
|
|
11
|
+
const keys_1 = __importDefault(require("lodash/keys"));
|
|
12
|
+
const p_queue_1 = __importDefault(require("p-queue"));
|
|
13
|
+
const debug_1 = __importDefault(require("debug"));
|
|
14
|
+
const fs_extra_1 = require("fs-extra");
|
|
15
|
+
const p_all_1 = __importDefault(require("p-all"));
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const os_1 = require("os");
|
|
18
|
+
const libs_1 = require("../../libs");
|
|
19
|
+
const logger_1 = require("../../libs/logger");
|
|
20
|
+
const base_1 = require("../base");
|
|
21
|
+
const sleep_1 = require("../../libs/sleep");
|
|
22
|
+
const { name, version } = require('../../../package.json');
|
|
23
|
+
const debug = (0, debug_1.default)(`${name}@${version}:IncrementalSyncBaseCommand`);
|
|
24
|
+
/**
|
|
25
|
+
* @see s3 sync https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync
|
|
26
|
+
* @see Keep-alive 和连接重用的 NodeJS https://azureossd.github.io/2022/03/10/NodeJS-with-Keep-Alives-and-Connection-Reuse/index.html
|
|
27
|
+
* @export
|
|
28
|
+
* @class SyncFolderPushCommand
|
|
29
|
+
* @extends {BaseCommand<SyncFolderCommandInput, SyncFolderPushCommandOutput>}
|
|
30
|
+
*/
|
|
31
|
+
class IncrementalSyncBaseCommand extends base_1.BaseCommand {
|
|
32
|
+
queue;
|
|
33
|
+
startTime = Date.now();
|
|
34
|
+
static DEFAULT_RETRY_COUNT = 3;
|
|
35
|
+
static MAX_RETRY_COUNT = 10;
|
|
36
|
+
static DEFAULT_CONCURRENCY = 4;
|
|
37
|
+
static MAX_CONCURRENCY = (0, os_1.cpus)().length;
|
|
38
|
+
retryCount = 0;
|
|
39
|
+
constructor(input, context) {
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
super(input, context);
|
|
42
|
+
this.initialize(input);
|
|
43
|
+
this.queue = new p_queue_1.default({ concurrency: this.input.concurrency });
|
|
44
|
+
}
|
|
45
|
+
initialize(input) {
|
|
46
|
+
if ((0, isUndefined_1.default)(input?.concurrency)) {
|
|
47
|
+
this.input.concurrency = IncrementalSyncBaseCommand.DEFAULT_CONCURRENCY;
|
|
48
|
+
}
|
|
49
|
+
else if (input.concurrency > IncrementalSyncBaseCommand.MAX_CONCURRENCY) {
|
|
50
|
+
this.input.concurrency = IncrementalSyncBaseCommand.MAX_CONCURRENCY;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.input.concurrency = input.concurrency;
|
|
54
|
+
}
|
|
55
|
+
if ((0, isUndefined_1.default)(input?.retryCount)) {
|
|
56
|
+
this.input.retryCount = IncrementalSyncBaseCommand.DEFAULT_RETRY_COUNT;
|
|
57
|
+
}
|
|
58
|
+
else if (input.retryCount > IncrementalSyncBaseCommand.MAX_RETRY_COUNT) {
|
|
59
|
+
this.input.retryCount = IncrementalSyncBaseCommand.MAX_RETRY_COUNT;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.input.retryCount = input.retryCount;
|
|
63
|
+
}
|
|
64
|
+
if (!this.input.target.endsWith('/')) {
|
|
65
|
+
this.input.target = (0, path_1.join)(this.input.target, '/');
|
|
66
|
+
}
|
|
67
|
+
if ((0, isEmpty_1.default)(this.input.tmpDir)) {
|
|
68
|
+
this.input.tmpDir = (0, path_1.join)(process.env.ABT_NODE_DATA_DIR, 'tmp', this.constructor.name, this.input.target);
|
|
69
|
+
(0, fs_extra_1.ensureDirSync)(this.input.tmpDir);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @description 仅在开启调试模式时,输出调试信息,
|
|
75
|
+
* @protected
|
|
76
|
+
* @param {{
|
|
77
|
+
* completedCount: number;
|
|
78
|
+
* errorCount: number;
|
|
79
|
+
* totalCount: number;
|
|
80
|
+
* }} {
|
|
81
|
+
* completedCount,
|
|
82
|
+
* errorCount,
|
|
83
|
+
* totalCount,
|
|
84
|
+
* }
|
|
85
|
+
* @return {*} {Promise<void>}
|
|
86
|
+
* @memberof IncrementalSyncBaseCommand
|
|
87
|
+
*/
|
|
88
|
+
printDebugInfo({ direction, completedCount, errorCount, totalCount, }) {
|
|
89
|
+
if (!this.input.debug) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const remaining = totalCount - errorCount - completedCount;
|
|
93
|
+
const progress = ((completedCount * 100) / totalCount).toFixed(2);
|
|
94
|
+
const duration = (Date.now() - this.startTime) / 1000;
|
|
95
|
+
logger_1.logger.info(`[${direction}] pending: ${this.queue.pending}, completed: ${completedCount}, error: ${errorCount}, remaining: ${remaining}, progress: ${progress}%, total: ${totalCount}, retryCount: ${this.input.retryCount}, duration: ${duration}(s)`);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
*
|
|
100
|
+
* @protected
|
|
101
|
+
* @param {(Error | AxiosError)} error
|
|
102
|
+
* @return {*} {Promise<void>}
|
|
103
|
+
* @memberof IncrementalSyncBaseCommand
|
|
104
|
+
*/
|
|
105
|
+
async retryRequest(error) {
|
|
106
|
+
// 减少重试次数
|
|
107
|
+
--this.input.retryCount;
|
|
108
|
+
// clear queue
|
|
109
|
+
this.queue.clear();
|
|
110
|
+
// 输出错误
|
|
111
|
+
const errorMessage = (0, libs_1.getErrorMessage)(error);
|
|
112
|
+
const statusCode = (0, libs_1.getErrorStatusCode)(error);
|
|
113
|
+
logger_1.logger.error('#retryRequest()', error);
|
|
114
|
+
logger_1.logger.error('#retryRequest()', {
|
|
115
|
+
input: this.input,
|
|
116
|
+
endpoint: this.context.endpoint,
|
|
117
|
+
errorMessage,
|
|
118
|
+
statusCode,
|
|
119
|
+
});
|
|
120
|
+
// FIXME: retryCount === 0 表示,重试次数刚好用完了,后续优化 server 显示错误的进度 @yejianchao
|
|
121
|
+
// 防呆控制,retryCount < 0 说明调用基础接口始终是失败的,遇到了预料之外的事情,因此需要停止运行
|
|
122
|
+
if (this.input.retryCount <= 0 || [400, 401, 403, 404, 413].includes(statusCode)) {
|
|
123
|
+
return {
|
|
124
|
+
statusCode,
|
|
125
|
+
statusMessage: (0, libs_1.getErrorMessage)(error),
|
|
126
|
+
stack: error.stack,
|
|
127
|
+
data: {
|
|
128
|
+
errorCount: -1,
|
|
129
|
+
count: -1,
|
|
130
|
+
duration: (Date.now() - this.startTime) / 1000,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// 目前我们的重试时间间隔是以 2 的指数增长的,第1次重试 1 s,第 2 次重试 2 s, 第 3 次重试间隔 4 s...
|
|
135
|
+
const retryDelayMs = 2 ** this.retryCount * 1000;
|
|
136
|
+
++this.retryCount;
|
|
137
|
+
await (0, sleep_1.sleep)(retryDelayMs);
|
|
138
|
+
return this.request();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
* @description 比较双方的文件到底谁更新鲜,更新鲜的数据才需要被同步上去
|
|
143
|
+
* @protected
|
|
144
|
+
* @param {ObjectsMap} fromObjectsMap
|
|
145
|
+
* @param {ObjectsMap} toObjectsMap
|
|
146
|
+
* @return {*} {Promise<string[]>}
|
|
147
|
+
* @memberof IncrementalSyncBaseCommand
|
|
148
|
+
*/
|
|
149
|
+
async getWaitSyncObjects(fromObjectsMap, toObjectsMap) {
|
|
150
|
+
const intersectionKeys = [...new Set((0, keys_1.default)(fromObjectsMap).concat((0, keys_1.default)(toObjectsMap)))];
|
|
151
|
+
const actions = intersectionKeys.map((key) => {
|
|
152
|
+
return async () => {
|
|
153
|
+
const fromObject = fromObjectsMap[key];
|
|
154
|
+
const toObject = toObjectsMap[key];
|
|
155
|
+
debug(`getWaitSyncObjects.$fromObjectsMap[${key}]`, fromObject);
|
|
156
|
+
debug(`getWaitSyncObjects.$toObjectsMap[${key}]`, toObject);
|
|
157
|
+
// 本地存在的文件 && 在远程不存在, 则修改远程的
|
|
158
|
+
if (fromObject && !toObject) {
|
|
159
|
+
return {
|
|
160
|
+
...fromObject,
|
|
161
|
+
action: 'PUT',
|
|
162
|
+
key,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// 本地不存在 && 远程存在, 则删除远程的
|
|
166
|
+
if (!fromObject && toObject) {
|
|
167
|
+
return {
|
|
168
|
+
...toObject,
|
|
169
|
+
action: 'DELETE',
|
|
170
|
+
key,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// 本地存在的文件 && 在远程存在 && 两者文件大小不一致, 则修改远程的
|
|
174
|
+
if (fromObject.size !== toObject.size) {
|
|
175
|
+
return {
|
|
176
|
+
...fromObject,
|
|
177
|
+
action: 'PUT',
|
|
178
|
+
key,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// 本地存在的文件 && 在远程存在 && 本地日期不新鲜,则无需修改
|
|
182
|
+
if (fromObject.lastModified <= toObject.lastModified) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (!fromObject.hash) {
|
|
186
|
+
if (!(await this.shouldBeBackup(fromObject.absolutePath))) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
// 此时计算 hash
|
|
190
|
+
fromObject.hash = await (0, core_1.getHash)((0, fs_extra_1.createReadStream)(fromObject.absolutePath));
|
|
191
|
+
}
|
|
192
|
+
// 本地存在的文件 && 在远程存在 && 两者文件内容不同, 则修改远程的
|
|
193
|
+
if (fromObject.hash !== toObject.hash) {
|
|
194
|
+
return {
|
|
195
|
+
...fromObject,
|
|
196
|
+
action: 'PUT',
|
|
197
|
+
key,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
const syncObjects = (await (0, p_all_1.default)(actions, { concurrency: this.input.concurrency })).filter(Boolean);
|
|
204
|
+
debug('getWaitSyncObjects.$syncObjects.length', syncObjects.length);
|
|
205
|
+
debug('getWaitSyncObjects.$syncObjects.slice(0, 3)', syncObjects.slice(0, 3));
|
|
206
|
+
return syncObjects;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @description 判断一个对象是否应该被备份
|
|
210
|
+
* @protected
|
|
211
|
+
* @param {string} absolutePath
|
|
212
|
+
* @return {*} {Promise<boolean>}
|
|
213
|
+
* @memberof IncrementalSyncBaseCommand
|
|
214
|
+
*/
|
|
215
|
+
// eslint-disable-next-line require-await
|
|
216
|
+
async shouldBeBackup(absolutePath) {
|
|
217
|
+
if (typeof absolutePath !== 'string' || (0, isEmpty_1.default)(absolutePath)) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
if (absolutePath.endsWith('~')) {
|
|
221
|
+
// 临时文件不备份,因为随时可能被删除,从而引发错误
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (!(await (0, fs_extra_1.pathExists)(absolutePath))) {
|
|
225
|
+
// 不存在的文件不备份
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
async destroy() {
|
|
231
|
+
if (await (0, fs_extra_1.pathExists)(this.input.tmpDir)) {
|
|
232
|
+
await (0, fs_extra_1.remove)(this.input.tmpDir);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.IncrementalSyncBaseCommand = IncrementalSyncBaseCommand;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Object } from '@did-space/core';
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import { IncrementalSyncPushCommandInput, IncrementalSyncPushCommandOutput } from '../../meta';
|
|
4
|
+
import { ObjectsMap, SyncObject } from '../sync';
|
|
5
|
+
import { IncrementalSyncBaseCommand } from './sync-base';
|
|
6
|
+
/**
|
|
7
|
+
* @see s3 sync https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync
|
|
8
|
+
* @see 具有 Keep-alive 和连接重用的 NodeJS https://azureossd.github.io/2022/03/10/NodeJS-with-Keep-Alives-and-Connection-Reuse/index.html
|
|
9
|
+
* @export
|
|
10
|
+
* @class SyncFolderPushCommand
|
|
11
|
+
* @extends {BaseCommand<SyncFolderCommandInput, IncrementalSyncPushCommandOutput>}
|
|
12
|
+
*/
|
|
13
|
+
export declare class IncrementalSyncPushCommand extends IncrementalSyncBaseCommand<IncrementalSyncPushCommandInput, IncrementalSyncPushCommandOutput> {
|
|
14
|
+
protected readonly startTime: number;
|
|
15
|
+
getAxiosRequestConfig(): Promise<AxiosRequestConfig<any>>;
|
|
16
|
+
request(): Promise<IncrementalSyncPushCommandOutput>;
|
|
17
|
+
getLocalObjectsMap(): Promise<ObjectsMap>;
|
|
18
|
+
getRemoteObjectsMap(): Promise<ObjectsMap>;
|
|
19
|
+
/**
|
|
20
|
+
* @see https://github.com/ArcBlock/did-spaces/issues/955#issuecomment-1873723050
|
|
21
|
+
* @description 备份的对象随时可能在进行写入操作,所以对于需要备份的文件,最佳实践是备份它们某一个时刻的副本,否则会引发错误 Error: Unexpected end of form
|
|
22
|
+
* @param {SyncObject[]} waitSyncObjects
|
|
23
|
+
* @return {*} {Promise<SyncObject[]>}
|
|
24
|
+
* @memberof IncrementalSyncPushCommand
|
|
25
|
+
*/
|
|
26
|
+
copyObjects(waitSyncObjects: SyncObject[]): Promise<SyncObject[]>;
|
|
27
|
+
getObject(absolutePath: string): Promise<Object>;
|
|
28
|
+
registerEvents(): void;
|
|
29
|
+
private sync;
|
|
30
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
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.IncrementalSyncPushCommand = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
8
|
+
const core_1 = require("@did-space/core");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const isFunction_1 = __importDefault(require("lodash/isFunction"));
|
|
12
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
13
|
+
const debug_1 = __importDefault(require("debug"));
|
|
14
|
+
const xbytes_1 = __importDefault(require("xbytes"));
|
|
15
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
16
|
+
const p_all_1 = __importDefault(require("p-all"));
|
|
17
|
+
const fs_extra_1 = require("fs-extra");
|
|
18
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
19
|
+
const promises_1 = require("stream/promises");
|
|
20
|
+
const object_1 = require("../object");
|
|
21
|
+
const logger_1 = require("../../libs/logger");
|
|
22
|
+
const delete_object_1 = require("../object/delete-object");
|
|
23
|
+
const sync_base_1 = require("./sync-base");
|
|
24
|
+
const { name, version } = require('../../../package.json');
|
|
25
|
+
const debug = (0, debug_1.default)(`${name}@${version}:sync-folder-push`);
|
|
26
|
+
/**
|
|
27
|
+
* @see s3 sync https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync
|
|
28
|
+
* @see 具有 Keep-alive 和连接重用的 NodeJS https://azureossd.github.io/2022/03/10/NodeJS-with-Keep-Alives-and-Connection-Reuse/index.html
|
|
29
|
+
* @export
|
|
30
|
+
* @class SyncFolderPushCommand
|
|
31
|
+
* @extends {BaseCommand<SyncFolderCommandInput, IncrementalSyncPushCommandOutput>}
|
|
32
|
+
*/
|
|
33
|
+
class IncrementalSyncPushCommand extends sync_base_1.IncrementalSyncBaseCommand {
|
|
34
|
+
startTime = Date.now();
|
|
35
|
+
getAxiosRequestConfig() {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
async request() {
|
|
39
|
+
try {
|
|
40
|
+
const localObjectsMap = await this.getLocalObjectsMap();
|
|
41
|
+
const remoteObjectsMap = await this.getRemoteObjectsMap();
|
|
42
|
+
const waitSyncObjects = await this.getWaitSyncObjects(localObjectsMap, remoteObjectsMap);
|
|
43
|
+
const syncObjects = await this.copyObjects(waitSyncObjects);
|
|
44
|
+
debug(`[${(0, logger_1.now)()}] [waitUpload] waitUploadCount=${syncObjects.length}`);
|
|
45
|
+
debug(`[${(0, logger_1.now)()}] [context]`, { input: this.input, context: (0, pick_1.default)(this.context, ['endpoint']) });
|
|
46
|
+
return await this.sync(syncObjects);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return this.retryRequest(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// eslint-disable-next-line require-await
|
|
53
|
+
async getLocalObjectsMap() {
|
|
54
|
+
// @note: 注意,此处不要先计算文件 hash
|
|
55
|
+
let objects = this.input.source;
|
|
56
|
+
if ((0, isFunction_1.default)(this.input.filter)) {
|
|
57
|
+
objects = objects.filter(this.input.filter);
|
|
58
|
+
}
|
|
59
|
+
const map = (0, keyBy_1.default)(objects, (object) => object.key);
|
|
60
|
+
return map;
|
|
61
|
+
}
|
|
62
|
+
async getRemoteObjectsMap() {
|
|
63
|
+
const { data: objects } = await new object_1.ListObjectsCommand({
|
|
64
|
+
key: this.input.target,
|
|
65
|
+
}, this.context).request();
|
|
66
|
+
const map = (0, keyBy_1.default)(objects, (object) => object.key);
|
|
67
|
+
return map;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @see https://github.com/ArcBlock/did-spaces/issues/955#issuecomment-1873723050
|
|
71
|
+
* @description 备份的对象随时可能在进行写入操作,所以对于需要备份的文件,最佳实践是备份它们某一个时刻的副本,否则会引发错误 Error: Unexpected end of form
|
|
72
|
+
* @param {SyncObject[]} waitSyncObjects
|
|
73
|
+
* @return {*} {Promise<SyncObject[]>}
|
|
74
|
+
* @memberof IncrementalSyncPushCommand
|
|
75
|
+
*/
|
|
76
|
+
async copyObjects(waitSyncObjects) {
|
|
77
|
+
await (0, p_all_1.default)(waitSyncObjects.map((x) => {
|
|
78
|
+
return async () => {
|
|
79
|
+
const source = x.absolutePath;
|
|
80
|
+
const target = (0, path_1.join)(this.input.tmpDir, x.key);
|
|
81
|
+
if (x.action !== 'PUT' || !(await (0, fs_extra_1.pathExists)(source))) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!(await (0, fs_extra_1.pathExists)(target))) {
|
|
85
|
+
await (0, fs_extra_1.ensureDir)((0, path_1.dirname)(target));
|
|
86
|
+
await (0, promises_1.pipeline)((0, fs_1.createReadStream)(source), (0, fs_1.createWriteStream)(target));
|
|
87
|
+
}
|
|
88
|
+
const targetObject = await this.getObject(target);
|
|
89
|
+
x.size = targetObject.size;
|
|
90
|
+
x.lastModified = targetObject.lastModified;
|
|
91
|
+
x.hash = await (0, core_1.getHash)((0, fs_1.createReadStream)(targetObject.absolutePath));
|
|
92
|
+
x.absolutePath = targetObject.absolutePath;
|
|
93
|
+
};
|
|
94
|
+
}), {
|
|
95
|
+
concurrency: this.input.concurrency,
|
|
96
|
+
});
|
|
97
|
+
return waitSyncObjects;
|
|
98
|
+
}
|
|
99
|
+
async getObject(absolutePath) {
|
|
100
|
+
const fileStat = await (0, fs_extra_1.stat)(absolutePath);
|
|
101
|
+
const objectName = (0, path_1.basename)(absolutePath);
|
|
102
|
+
const directorySuffixes = fileStat.isDirectory() ? '/' : '';
|
|
103
|
+
return {
|
|
104
|
+
key: absolutePath,
|
|
105
|
+
name: (0, path_1.join)(objectName, directorySuffixes),
|
|
106
|
+
isDir: fileStat.isDirectory(),
|
|
107
|
+
size: fileStat.size,
|
|
108
|
+
lastModified: new Date(fileStat.mtime).getTime(),
|
|
109
|
+
editable: false,
|
|
110
|
+
mimeType: mime_types_1.default.lookup(objectName) || 'unknown',
|
|
111
|
+
absolutePath,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
registerEvents() {
|
|
115
|
+
this.removeAllListeners();
|
|
116
|
+
this.on('sync.before', (input) => {
|
|
117
|
+
this.input?.onProgress?.(input);
|
|
118
|
+
});
|
|
119
|
+
this.on('sync.after', (input) => {
|
|
120
|
+
this.input?.onAfterUpload?.(input);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async sync(syncObjects) {
|
|
124
|
+
this.queue.removeAllListeners();
|
|
125
|
+
this.registerEvents();
|
|
126
|
+
let errorCount = 0;
|
|
127
|
+
let completedCount = 0;
|
|
128
|
+
const totalCount = syncObjects.length;
|
|
129
|
+
// @ts-expect-error
|
|
130
|
+
this.queue.on('error', async () => {
|
|
131
|
+
errorCount += 1;
|
|
132
|
+
await this.printDebugInfo({
|
|
133
|
+
direction: 'push',
|
|
134
|
+
completedCount,
|
|
135
|
+
errorCount,
|
|
136
|
+
totalCount,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
const actions = syncObjects.map((x) => {
|
|
140
|
+
return async () => {
|
|
141
|
+
const sourceKey = x.absolutePath;
|
|
142
|
+
const targetKey = (0, path_1.join)(this.input.target, x.key);
|
|
143
|
+
if (x.action === 'PUT' && !(await this.shouldBeBackup(sourceKey))) {
|
|
144
|
+
debug('sync.return', {
|
|
145
|
+
sourceKey,
|
|
146
|
+
[`$pathExists(${sourceKey})`]: false,
|
|
147
|
+
});
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.emit('sync.before', {
|
|
151
|
+
completed: completedCount,
|
|
152
|
+
total: totalCount,
|
|
153
|
+
key: sourceKey,
|
|
154
|
+
});
|
|
155
|
+
// 开始上传
|
|
156
|
+
debug(`[${(0, logger_1.now)()}] [sync:${x.action}.before] ${sourceKey} => ${targetKey} size=${(0, xbytes_1.default)(x.size, {
|
|
157
|
+
iec: true,
|
|
158
|
+
})} completed=${completedCount} total=${totalCount}`);
|
|
159
|
+
if (x.action === 'PUT') {
|
|
160
|
+
await new object_1.PutObjectCommand({
|
|
161
|
+
key: targetKey,
|
|
162
|
+
data: (0, fs_1.createReadStream)(sourceKey),
|
|
163
|
+
hash: x.hash,
|
|
164
|
+
}, this.context).request();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
await new delete_object_1.DeleteObjectCommand({
|
|
168
|
+
key: targetKey,
|
|
169
|
+
}, this.context).request();
|
|
170
|
+
}
|
|
171
|
+
// progress
|
|
172
|
+
++completedCount;
|
|
173
|
+
this.printDebugInfo({
|
|
174
|
+
direction: 'push',
|
|
175
|
+
completedCount,
|
|
176
|
+
errorCount,
|
|
177
|
+
totalCount,
|
|
178
|
+
});
|
|
179
|
+
this.emit('sync.after', {
|
|
180
|
+
completed: completedCount,
|
|
181
|
+
total: totalCount,
|
|
182
|
+
key: sourceKey,
|
|
183
|
+
});
|
|
184
|
+
// 结束上传
|
|
185
|
+
debug(`[${(0, logger_1.now)()}] [sync:${x.action}.after] ${sourceKey}=>${targetKey} size=${(0, xbytes_1.default)(x.size, {
|
|
186
|
+
iec: true,
|
|
187
|
+
})} completed=${completedCount} total=${totalCount}`);
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
await this.queue.addAll(actions);
|
|
191
|
+
await this.queue.onIdle();
|
|
192
|
+
return {
|
|
193
|
+
statusCode: 200,
|
|
194
|
+
data: {
|
|
195
|
+
count: actions.length,
|
|
196
|
+
errorCount,
|
|
197
|
+
duration: (Date.now() - this.startTime) / 1000,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.IncrementalSyncPushCommand = IncrementalSyncPushCommand;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './backup';
|
|
2
|
+
export * from './incremental-backup';
|
|
3
|
+
export * from './incremental-sync';
|
|
4
|
+
export * from './nft';
|
|
5
|
+
export * from './object';
|
|
6
|
+
export * from './restore';
|
|
7
|
+
export * from './space';
|
|
8
|
+
export * from './sync';
|
|
9
|
+
export * from './base';
|
|
@@ -0,0 +1,25 @@
|
|
|
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("./backup"), exports);
|
|
18
|
+
__exportStar(require("./incremental-backup"), exports);
|
|
19
|
+
__exportStar(require("./incremental-sync"), exports);
|
|
20
|
+
__exportStar(require("./nft"), exports);
|
|
21
|
+
__exportStar(require("./object"), exports);
|
|
22
|
+
__exportStar(require("./restore"), exports);
|
|
23
|
+
__exportStar(require("./space"), exports);
|
|
24
|
+
__exportStar(require("./sync"), exports);
|
|
25
|
+
__exportStar(require("./base"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './put-nft-object';
|
|
@@ -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("./put-nft-object"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { DidDocument } from '../../did-document';
|
|
5
|
+
import { BaseCommand } from '../base';
|
|
6
|
+
import { PutNftObjectCommandInput, type PutNftObjectCommandOutput } from '../../meta';
|
|
7
|
+
export declare class PutNftObjectCommand extends BaseCommand<PutNftObjectCommandInput, PutNftObjectCommandOutput> {
|
|
8
|
+
private readonly tempCacheObjectKey;
|
|
9
|
+
private tempCacheObjectHash;
|
|
10
|
+
constructor(input: PutNftObjectCommandInput);
|
|
11
|
+
getUrl(): Promise<string>;
|
|
12
|
+
getDisplayUrl(): Promise<string>;
|
|
13
|
+
getStreams(): Promise<{
|
|
14
|
+
streamForUpload: Readable;
|
|
15
|
+
streamForHash: Readable;
|
|
16
|
+
}>;
|
|
17
|
+
getDidDocument(streamForHash: Readable): Promise<DidDocument>;
|
|
18
|
+
getAxiosRequestConfig(): Promise<AxiosRequestConfig<any>>;
|
|
19
|
+
destroy(): Promise<void>;
|
|
20
|
+
}
|