@blocklet/did-space-js 0.5.74 → 0.5.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/index.js +2 -1
- package/dist/commands/object/index.d.ts +1 -1
- package/dist/commands/object/index.js +1 -1
- package/dist/commands/preview/delete-preview-object.d.ts +7 -0
- package/dist/commands/preview/delete-preview-object.js +43 -0
- package/dist/commands/preview/get-preview-object.d.ts +7 -0
- package/dist/commands/preview/get-preview-object.js +47 -0
- package/dist/commands/preview/index.d.ts +3 -0
- package/dist/commands/preview/index.js +19 -0
- package/dist/commands/preview/put-preview-object.d.ts +8 -0
- package/dist/commands/preview/put-preview-object.js +77 -0
- package/dist/meta/object/index.d.ts +2 -0
- package/dist/meta/object/index.js +2 -0
- package/dist/meta/object/preview-object-command.d.ts +204 -0
- package/dist/meta/object/preview-object-command.js +34 -0
- package/dist/meta/object/put-object-command.d.ts +19 -13
- package/dist/meta/object/put-object-command.js +20 -0
- package/package.json +7 -5
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './backup';
|
|
2
|
+
export * from './base';
|
|
2
3
|
export * from './incremental-backup';
|
|
3
4
|
export * from './incremental-sync';
|
|
4
5
|
export * from './nft';
|
|
5
6
|
export * from './object';
|
|
7
|
+
export * from './preview';
|
|
6
8
|
export * from './restore';
|
|
7
9
|
export * from './space';
|
|
8
10
|
export * from './sync';
|
|
9
|
-
export * from './base';
|
package/dist/commands/index.js
CHANGED
|
@@ -15,11 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./backup"), exports);
|
|
18
|
+
__exportStar(require("./base"), exports);
|
|
18
19
|
__exportStar(require("./incremental-backup"), exports);
|
|
19
20
|
__exportStar(require("./incremental-sync"), exports);
|
|
20
21
|
__exportStar(require("./nft"), exports);
|
|
21
22
|
__exportStar(require("./object"), exports);
|
|
23
|
+
__exportStar(require("./preview"), exports);
|
|
22
24
|
__exportStar(require("./restore"), exports);
|
|
23
25
|
__exportStar(require("./space"), exports);
|
|
24
26
|
__exportStar(require("./sync"), exports);
|
|
25
|
-
__exportStar(require("./base"), exports);
|
|
@@ -14,8 +14,8 @@ 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("./delete-object"), exports);
|
|
17
18
|
__exportStar(require("./get-object"), exports);
|
|
18
19
|
__exportStar(require("./list-object"), exports);
|
|
19
20
|
__exportStar(require("./list-objects"), exports);
|
|
20
21
|
__exportStar(require("./put-object"), exports);
|
|
21
|
-
__exportStar(require("./delete-object"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { type DeletePreviewObjectCommandInput, type DeletePreviewObjectCommandOutput } from '../../meta';
|
|
3
|
+
import { BaseCommand } from '../base';
|
|
4
|
+
export declare class DeletePreviewObjectCommand extends BaseCommand<DeletePreviewObjectCommandInput, DeletePreviewObjectCommandOutput> {
|
|
5
|
+
getAxiosRequestConfig(): Promise<AxiosRequestConfig<any>>;
|
|
6
|
+
resolveMiddleware(): Promise<DeletePreviewObjectCommandOutput>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeletePreviewObjectCommand = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const ufo_1 = require("ufo");
|
|
6
|
+
const core_1 = require("@did-space/core");
|
|
7
|
+
const meta_1 = require("../../meta");
|
|
8
|
+
const base_1 = require("../base");
|
|
9
|
+
const security_1 = require("../../security");
|
|
10
|
+
const libs_1 = require("../../libs");
|
|
11
|
+
class DeletePreviewObjectCommand extends base_1.BaseCommand {
|
|
12
|
+
getAxiosRequestConfig() {
|
|
13
|
+
return Promise.resolve(null);
|
|
14
|
+
}
|
|
15
|
+
async resolveMiddleware() {
|
|
16
|
+
this.input = await meta_1.GetPreviewObjectCommandInputSchema.parseAsync(this.input);
|
|
17
|
+
const url = (0, ufo_1.joinURL)(this.context.endpoint, 'object', this.getKey((0, path_1.join)(this.input.key, '.meta/preview.yml')));
|
|
18
|
+
const method = 'DELETE';
|
|
19
|
+
const { headers } = (0, security_1.signRequest)({
|
|
20
|
+
url,
|
|
21
|
+
method,
|
|
22
|
+
data: {},
|
|
23
|
+
headers: {
|
|
24
|
+
[core_1.HEADERS.X_SIGNATURE_VERSION]: '2',
|
|
25
|
+
},
|
|
26
|
+
wallet: this.context.wallet,
|
|
27
|
+
delegation: this.context.delegation,
|
|
28
|
+
});
|
|
29
|
+
const optionsOfTextResponseBody = {
|
|
30
|
+
method,
|
|
31
|
+
headers: {
|
|
32
|
+
...headers,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const response = await (0, libs_1.gotApi)(url, optionsOfTextResponseBody);
|
|
36
|
+
return {
|
|
37
|
+
statusCode: response.statusCode,
|
|
38
|
+
statusMessage: response.statusMessage,
|
|
39
|
+
data: undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.DeletePreviewObjectCommand = DeletePreviewObjectCommand;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { GetPreviewObjectCommandInput, GetPreviewObjectCommandOutput } from '../../meta';
|
|
3
|
+
import { BaseCommand } from '../base';
|
|
4
|
+
export declare class GetPreviewObjectCommand extends BaseCommand<GetPreviewObjectCommandInput, GetPreviewObjectCommandOutput> {
|
|
5
|
+
getAxiosRequestConfig(): Promise<AxiosRequestConfig<any>>;
|
|
6
|
+
resolveMiddleware(): Promise<GetPreviewObjectCommandOutput>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.GetPreviewObjectCommand = void 0;
|
|
7
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const ufo_1 = require("ufo");
|
|
10
|
+
const core_1 = require("@did-space/core");
|
|
11
|
+
const meta_1 = require("../../meta");
|
|
12
|
+
const base_1 = require("../base");
|
|
13
|
+
const security_1 = require("../../security");
|
|
14
|
+
const libs_1 = require("../../libs");
|
|
15
|
+
class GetPreviewObjectCommand extends base_1.BaseCommand {
|
|
16
|
+
getAxiosRequestConfig() {
|
|
17
|
+
return Promise.resolve(null);
|
|
18
|
+
}
|
|
19
|
+
async resolveMiddleware() {
|
|
20
|
+
this.input = await meta_1.GetPreviewObjectCommandInputSchema.parseAsync(this.input);
|
|
21
|
+
const url = (0, ufo_1.joinURL)(this.context.endpoint, 'object', this.getKey((0, path_1.join)(this.input.key, '.meta/preview.yml')));
|
|
22
|
+
const method = 'GET';
|
|
23
|
+
const { headers } = (0, security_1.signRequest)({
|
|
24
|
+
url,
|
|
25
|
+
method,
|
|
26
|
+
data: {},
|
|
27
|
+
headers: {
|
|
28
|
+
[core_1.HEADERS.X_SIGNATURE_VERSION]: '2',
|
|
29
|
+
},
|
|
30
|
+
wallet: this.context.wallet,
|
|
31
|
+
delegation: this.context.delegation,
|
|
32
|
+
});
|
|
33
|
+
const optionsOfTextResponseBody = {
|
|
34
|
+
method,
|
|
35
|
+
headers: {
|
|
36
|
+
...headers,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const response = await (0, libs_1.gotApi)(url, optionsOfTextResponseBody);
|
|
40
|
+
return {
|
|
41
|
+
statusCode: response.statusCode,
|
|
42
|
+
statusMessage: response.statusMessage,
|
|
43
|
+
data: js_yaml_1.default.load(response.body),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.GetPreviewObjectCommand = GetPreviewObjectCommand;
|
|
@@ -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("./delete-preview-object"), exports);
|
|
18
|
+
__exportStar(require("./get-preview-object"), exports);
|
|
19
|
+
__exportStar(require("./put-preview-object"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { PutPreviewObjectCommandInput, PutPreviewObjectCommandOutput } from '../../meta';
|
|
3
|
+
import { BaseCommand } from '../base';
|
|
4
|
+
export declare class PutPreviewObjectCommand extends BaseCommand<PutPreviewObjectCommandInput, PutPreviewObjectCommandOutput> {
|
|
5
|
+
getAxiosRequestConfig(): Promise<AxiosRequestConfig<any>>;
|
|
6
|
+
normalize(): Promise<void>;
|
|
7
|
+
resolveMiddleware(): Promise<PutPreviewObjectCommandOutput>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.PutPreviewObjectCommand = void 0;
|
|
7
|
+
const core_1 = require("@did-space/core");
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
10
|
+
const ufo_1 = require("ufo");
|
|
11
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const p_all_1 = __importDefault(require("p-all"));
|
|
14
|
+
const libs_1 = require("../../libs");
|
|
15
|
+
const meta_1 = require("../../meta");
|
|
16
|
+
const security_1 = require("../../security");
|
|
17
|
+
const base_1 = require("../base");
|
|
18
|
+
const object_1 = require("../object");
|
|
19
|
+
class PutPreviewObjectCommand extends base_1.BaseCommand {
|
|
20
|
+
getAxiosRequestConfig() {
|
|
21
|
+
return Promise.resolve(null);
|
|
22
|
+
}
|
|
23
|
+
async normalize() {
|
|
24
|
+
this.input = await meta_1.PutPreviewObjectCommandInputSchema.parseAsync(this.input);
|
|
25
|
+
for (const resource of this.input.resources) {
|
|
26
|
+
if (!resource.key.startsWith(this.input.key)) {
|
|
27
|
+
console.error(`Resource key(${resource.key}) must start with ${this.input.key}`, { resource });
|
|
28
|
+
throw new Error(`Resource key(${resource.key}) must start with ${this.input.key}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async resolveMiddleware() {
|
|
33
|
+
await this.normalize();
|
|
34
|
+
const url = (0, ufo_1.joinURL)(this.context.endpoint, 'object', this.getKey((0, path_1.join)(this.input.key, '.meta/preview.yml')));
|
|
35
|
+
const method = 'PUT';
|
|
36
|
+
const data = new form_data_1.default();
|
|
37
|
+
// @see: https://stackoverflow.com/a/43914175
|
|
38
|
+
data.append('data', js_yaml_1.default.dump(this.input.data), {
|
|
39
|
+
filename: this.input.key,
|
|
40
|
+
});
|
|
41
|
+
if (!(0, isEmpty_1.default)(this.input.metadata)) {
|
|
42
|
+
data.append('metadata', JSON.stringify(this.input.metadata));
|
|
43
|
+
}
|
|
44
|
+
const { headers } = (0, security_1.signRequest)({
|
|
45
|
+
url,
|
|
46
|
+
method,
|
|
47
|
+
data,
|
|
48
|
+
headers: {
|
|
49
|
+
[core_1.HEADERS.X_SIGNATURE_VERSION]: '2',
|
|
50
|
+
},
|
|
51
|
+
wallet: this.context.wallet,
|
|
52
|
+
delegation: this.context.delegation,
|
|
53
|
+
});
|
|
54
|
+
const optionsOfTextResponseBody = {
|
|
55
|
+
method,
|
|
56
|
+
body: data,
|
|
57
|
+
headers: {
|
|
58
|
+
...headers,
|
|
59
|
+
'x-hash': this.input.hash,
|
|
60
|
+
'Content-Type': 'multipart/form-data',
|
|
61
|
+
...data.getHeaders(),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const response = await (0, libs_1.gotApi)(url, optionsOfTextResponseBody);
|
|
65
|
+
await (0, p_all_1.default)(this.input.resources.map((resource) => () => {
|
|
66
|
+
return new object_1.PutObjectCommand(resource, this.context).request();
|
|
67
|
+
}), {
|
|
68
|
+
concurrency: 4,
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
statusCode: response.statusCode,
|
|
72
|
+
statusMessage: response.statusMessage,
|
|
73
|
+
data: undefined,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.PutPreviewObjectCommand = PutPreviewObjectCommand;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './delete-object-command';
|
|
2
2
|
export * from './get-object-command';
|
|
3
|
+
export * from './head-object-command';
|
|
3
4
|
export * from './list-object-command';
|
|
4
5
|
export * from './list-objects-command';
|
|
6
|
+
export * from './preview-object-command';
|
|
5
7
|
export * from './put-object-command';
|
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./delete-object-command"), exports);
|
|
18
18
|
__exportStar(require("./get-object-command"), exports);
|
|
19
|
+
__exportStar(require("./head-object-command"), exports);
|
|
19
20
|
__exportStar(require("./list-object-command"), exports);
|
|
20
21
|
__exportStar(require("./list-objects-command"), exports);
|
|
22
|
+
__exportStar(require("./preview-object-command"), exports);
|
|
21
23
|
__exportStar(require("./put-object-command"), exports);
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { PreviewTemplate } from '@did-space/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { CommandOutput } from '../../protocol';
|
|
4
|
+
export declare const PutPreviewObjectCommandInputSchema: z.ZodObject<{
|
|
5
|
+
/**
|
|
6
|
+
* @description 文件夹的路径,必须以 / 结尾
|
|
7
|
+
*/
|
|
8
|
+
key: z.ZodString;
|
|
9
|
+
/**
|
|
10
|
+
* @description 预览模板的数据
|
|
11
|
+
*/
|
|
12
|
+
data: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
13
|
+
template: z.ZodString;
|
|
14
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
+
}, {
|
|
16
|
+
template: z.ZodLiteral<"nft">;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
image: z.ZodString;
|
|
19
|
+
/**
|
|
20
|
+
* @description 文件夹的路径,必须以 / 结尾
|
|
21
|
+
*/
|
|
22
|
+
chainHost: z.ZodString;
|
|
23
|
+
}>, "strip", z.ZodTypeAny, {
|
|
24
|
+
template: "nft";
|
|
25
|
+
did: string;
|
|
26
|
+
name: string;
|
|
27
|
+
image: string;
|
|
28
|
+
chainHost: string;
|
|
29
|
+
}, {
|
|
30
|
+
template: "nft";
|
|
31
|
+
did: string;
|
|
32
|
+
name: string;
|
|
33
|
+
image: string;
|
|
34
|
+
chainHost: string;
|
|
35
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
36
|
+
template: z.ZodString;
|
|
37
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
38
|
+
}, {
|
|
39
|
+
template: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"profile">>>;
|
|
40
|
+
avatar: z.ZodString;
|
|
41
|
+
fullname: z.ZodString;
|
|
42
|
+
email: z.ZodString;
|
|
43
|
+
}>, "strip", z.ZodTypeAny, {
|
|
44
|
+
template: "profile";
|
|
45
|
+
did: string;
|
|
46
|
+
avatar: string;
|
|
47
|
+
fullname: string;
|
|
48
|
+
email: string;
|
|
49
|
+
}, {
|
|
50
|
+
did: string;
|
|
51
|
+
avatar: string;
|
|
52
|
+
fullname: string;
|
|
53
|
+
email: string;
|
|
54
|
+
template?: "profile";
|
|
55
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
56
|
+
template: z.ZodString;
|
|
57
|
+
did: z.ZodEffects<z.ZodString, string, string>;
|
|
58
|
+
}, {
|
|
59
|
+
template: z.ZodLiteral<"passport">;
|
|
60
|
+
image: z.ZodString;
|
|
61
|
+
type: z.ZodArray<z.ZodString, "many">;
|
|
62
|
+
issuerDid: z.ZodEffects<z.ZodString, string, string>;
|
|
63
|
+
issuerName: z.ZodString;
|
|
64
|
+
issuedAt: z.ZodString;
|
|
65
|
+
issuedTo: z.ZodString;
|
|
66
|
+
verified: z.ZodBoolean;
|
|
67
|
+
}>, "strip", z.ZodTypeAny, {
|
|
68
|
+
type: string[];
|
|
69
|
+
template: "passport";
|
|
70
|
+
did: string;
|
|
71
|
+
image: string;
|
|
72
|
+
issuerDid: string;
|
|
73
|
+
issuerName: string;
|
|
74
|
+
issuedAt: string;
|
|
75
|
+
issuedTo: string;
|
|
76
|
+
verified: boolean;
|
|
77
|
+
}, {
|
|
78
|
+
type: string[];
|
|
79
|
+
template: "passport";
|
|
80
|
+
did: string;
|
|
81
|
+
image: string;
|
|
82
|
+
issuerDid: string;
|
|
83
|
+
issuerName: string;
|
|
84
|
+
issuedAt: string;
|
|
85
|
+
issuedTo: string;
|
|
86
|
+
verified: boolean;
|
|
87
|
+
}>]>;
|
|
88
|
+
/**
|
|
89
|
+
* @description 存储元数据
|
|
90
|
+
*/
|
|
91
|
+
metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
92
|
+
/**
|
|
93
|
+
* @description 对象的 hash 值,它是 ipfs cid v1 的 hash
|
|
94
|
+
*/
|
|
95
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
96
|
+
/**
|
|
97
|
+
* @description 资源列表
|
|
98
|
+
*/
|
|
99
|
+
resources: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
100
|
+
key: z.ZodString;
|
|
101
|
+
data: z.ZodOptional<z.ZodAny>;
|
|
102
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
103
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
key?: string;
|
|
106
|
+
data?: any;
|
|
107
|
+
hash?: string;
|
|
108
|
+
metadata?: Record<string, any>;
|
|
109
|
+
}, {
|
|
110
|
+
key?: string;
|
|
111
|
+
data?: any;
|
|
112
|
+
hash?: string;
|
|
113
|
+
metadata?: Record<string, any>;
|
|
114
|
+
}>, "many">>>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
key?: string;
|
|
117
|
+
data?: {
|
|
118
|
+
template: "nft";
|
|
119
|
+
did: string;
|
|
120
|
+
name: string;
|
|
121
|
+
image: string;
|
|
122
|
+
chainHost: string;
|
|
123
|
+
} | {
|
|
124
|
+
template: "profile";
|
|
125
|
+
did: string;
|
|
126
|
+
avatar: string;
|
|
127
|
+
fullname: string;
|
|
128
|
+
email: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: string[];
|
|
131
|
+
template: "passport";
|
|
132
|
+
did: string;
|
|
133
|
+
image: string;
|
|
134
|
+
issuerDid: string;
|
|
135
|
+
issuerName: string;
|
|
136
|
+
issuedAt: string;
|
|
137
|
+
issuedTo: string;
|
|
138
|
+
verified: boolean;
|
|
139
|
+
};
|
|
140
|
+
hash?: string;
|
|
141
|
+
metadata?: Record<string, any>;
|
|
142
|
+
resources?: {
|
|
143
|
+
key?: string;
|
|
144
|
+
data?: any;
|
|
145
|
+
hash?: string;
|
|
146
|
+
metadata?: Record<string, any>;
|
|
147
|
+
}[];
|
|
148
|
+
}, {
|
|
149
|
+
key?: string;
|
|
150
|
+
data?: {
|
|
151
|
+
template: "nft";
|
|
152
|
+
did: string;
|
|
153
|
+
name: string;
|
|
154
|
+
image: string;
|
|
155
|
+
chainHost: string;
|
|
156
|
+
} | {
|
|
157
|
+
did: string;
|
|
158
|
+
avatar: string;
|
|
159
|
+
fullname: string;
|
|
160
|
+
email: string;
|
|
161
|
+
template?: "profile";
|
|
162
|
+
} | {
|
|
163
|
+
type: string[];
|
|
164
|
+
template: "passport";
|
|
165
|
+
did: string;
|
|
166
|
+
image: string;
|
|
167
|
+
issuerDid: string;
|
|
168
|
+
issuerName: string;
|
|
169
|
+
issuedAt: string;
|
|
170
|
+
issuedTo: string;
|
|
171
|
+
verified: boolean;
|
|
172
|
+
};
|
|
173
|
+
hash?: string;
|
|
174
|
+
metadata?: Record<string, any>;
|
|
175
|
+
resources?: {
|
|
176
|
+
key?: string;
|
|
177
|
+
data?: any;
|
|
178
|
+
hash?: string;
|
|
179
|
+
metadata?: Record<string, any>;
|
|
180
|
+
}[];
|
|
181
|
+
}>;
|
|
182
|
+
export interface PutPreviewObjectCommandInput extends z.infer<typeof PutPreviewObjectCommandInputSchema> {
|
|
183
|
+
}
|
|
184
|
+
export type PutPreviewObjectCommandOutput = CommandOutput<void>;
|
|
185
|
+
export declare const GetPreviewObjectCommandInputSchema: z.ZodObject<{
|
|
186
|
+
key: z.ZodString;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
key?: string;
|
|
189
|
+
}, {
|
|
190
|
+
key?: string;
|
|
191
|
+
}>;
|
|
192
|
+
export interface GetPreviewObjectCommandInput extends z.infer<typeof GetPreviewObjectCommandInputSchema> {
|
|
193
|
+
}
|
|
194
|
+
export type GetPreviewObjectCommandOutput = CommandOutput<PreviewTemplate>;
|
|
195
|
+
export declare const DeletePreviewObjectCommandInputSchema: z.ZodObject<{
|
|
196
|
+
key: z.ZodString;
|
|
197
|
+
}, "strip", z.ZodTypeAny, {
|
|
198
|
+
key?: string;
|
|
199
|
+
}, {
|
|
200
|
+
key?: string;
|
|
201
|
+
}>;
|
|
202
|
+
export interface DeletePreviewObjectCommandInput extends z.infer<typeof DeletePreviewObjectCommandInputSchema> {
|
|
203
|
+
}
|
|
204
|
+
export type DeletePreviewObjectCommandOutput = CommandOutput<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeletePreviewObjectCommandInputSchema = exports.GetPreviewObjectCommandInputSchema = exports.PutPreviewObjectCommandInputSchema = void 0;
|
|
4
|
+
const core_1 = require("@did-space/core");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const put_object_command_1 = require("./put-object-command");
|
|
7
|
+
exports.PutPreviewObjectCommandInputSchema = zod_1.z.object({
|
|
8
|
+
/**
|
|
9
|
+
* @description 文件夹的路径,必须以 / 结尾
|
|
10
|
+
*/
|
|
11
|
+
key: zod_1.z.string().endsWith('/'),
|
|
12
|
+
/**
|
|
13
|
+
* @description 预览模板的数据
|
|
14
|
+
*/
|
|
15
|
+
data: core_1.PreviewTemplateSchema,
|
|
16
|
+
/**
|
|
17
|
+
* @description 存储元数据
|
|
18
|
+
*/
|
|
19
|
+
metadata: zod_1.z.record(zod_1.z.any()).optional().default({}),
|
|
20
|
+
/**
|
|
21
|
+
* @description 对象的 hash 值,它是 ipfs cid v1 的 hash
|
|
22
|
+
*/
|
|
23
|
+
hash: zod_1.z.string().optional(),
|
|
24
|
+
/**
|
|
25
|
+
* @description 资源列表
|
|
26
|
+
*/
|
|
27
|
+
resources: zod_1.z.array(put_object_command_1.PutObjectCommandInputSchema).optional().default([]),
|
|
28
|
+
});
|
|
29
|
+
exports.GetPreviewObjectCommandInputSchema = zod_1.z.object({
|
|
30
|
+
key: zod_1.z.string().endsWith('/'),
|
|
31
|
+
});
|
|
32
|
+
exports.DeletePreviewObjectCommandInputSchema = zod_1.z.object({
|
|
33
|
+
key: zod_1.z.string().endsWith('/'),
|
|
34
|
+
});
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
import { Data } from '@did-space/core';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import type { CommandOutput } from '../../protocol';
|
|
3
|
-
export
|
|
4
|
+
export declare const PutObjectCommandInputSchema: z.ZodObject<{
|
|
4
5
|
/**
|
|
5
6
|
* @description 可以是一个文件名或者文件夹
|
|
6
|
-
* @type {string}
|
|
7
|
-
* @memberof PutObjectCommandInput
|
|
8
7
|
*/
|
|
9
|
-
key:
|
|
8
|
+
key: z.ZodString;
|
|
10
9
|
/**
|
|
11
|
-
* @description
|
|
12
|
-
* @type {Data}
|
|
13
|
-
* @memberof PutObjectCommandInput
|
|
10
|
+
* @description 存储文件夹或者文件的内容
|
|
14
11
|
*/
|
|
15
|
-
data
|
|
12
|
+
data: z.ZodOptional<z.ZodAny>;
|
|
16
13
|
/**
|
|
17
14
|
* @description 对象的 hash 值,我们期望它是 ipfs v1 的 hash
|
|
18
|
-
* @type {string}
|
|
19
|
-
* @memberof PutObjectCommandInput
|
|
20
15
|
*/
|
|
21
|
-
hash
|
|
16
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
22
17
|
/**
|
|
23
18
|
* @description 存储文件夹或者文件的元数据
|
|
24
|
-
* @type {Record<string, any>}
|
|
25
|
-
* @memberof PutObjectCommandInput
|
|
26
19
|
*/
|
|
20
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
key?: string;
|
|
23
|
+
data?: any;
|
|
24
|
+
hash?: string;
|
|
27
25
|
metadata?: Record<string, any>;
|
|
26
|
+
}, {
|
|
27
|
+
key?: string;
|
|
28
|
+
data?: any;
|
|
29
|
+
hash?: string;
|
|
30
|
+
metadata?: Record<string, any>;
|
|
31
|
+
}>;
|
|
32
|
+
export interface PutObjectCommandInput extends z.infer<typeof PutObjectCommandInputSchema> {
|
|
33
|
+
data?: Data;
|
|
28
34
|
}
|
|
29
35
|
export type PutObjectCommandOutput = CommandOutput<void>;
|
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PutObjectCommandInputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.PutObjectCommandInputSchema = zod_1.z.object({
|
|
6
|
+
/**
|
|
7
|
+
* @description 可以是一个文件名或者文件夹
|
|
8
|
+
*/
|
|
9
|
+
key: zod_1.z.string(),
|
|
10
|
+
/**
|
|
11
|
+
* @description 存储文件夹或者文件的内容
|
|
12
|
+
*/
|
|
13
|
+
data: zod_1.z.any().optional(),
|
|
14
|
+
/**
|
|
15
|
+
* @description 对象的 hash 值,我们期望它是 ipfs v1 的 hash
|
|
16
|
+
*/
|
|
17
|
+
hash: zod_1.z.string().optional(),
|
|
18
|
+
/**
|
|
19
|
+
* @description 存储文件夹或者文件的元数据
|
|
20
|
+
*/
|
|
21
|
+
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/did-space-js",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.75",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@arcblock/did": "^1.18.152",
|
|
33
33
|
"@arcblock/jwt": "^1.18.152",
|
|
34
34
|
"@arcblock/validator": "^1.18.152",
|
|
35
|
-
"@blocklet/env": "1.16.
|
|
36
|
-
"@did-space/core": "0.5.
|
|
35
|
+
"@blocklet/env": "^1.16.34-beta-20241129-100152-679bd732",
|
|
36
|
+
"@did-space/core": "^0.5.75",
|
|
37
37
|
"@ocap/mcrypto": "^1.18.152",
|
|
38
38
|
"@ocap/util": "^1.18.152",
|
|
39
39
|
"@ocap/wallet": "^1.18.152",
|
|
@@ -49,13 +49,15 @@
|
|
|
49
49
|
"hasha": "^5.2.2",
|
|
50
50
|
"is-url": "^1.2.4",
|
|
51
51
|
"joi": "^17.13.3",
|
|
52
|
+
"js-yaml": "^4.1.0",
|
|
52
53
|
"json-stable-stringify": "^1.1.1",
|
|
53
54
|
"lodash": "^4.17.21",
|
|
54
55
|
"mime-types": "^2.1.35",
|
|
55
56
|
"p-all": "3.0.0",
|
|
56
57
|
"p-queue": "6.6.2",
|
|
57
58
|
"ufo": "^1.5.4",
|
|
58
|
-
"xbytes": "^1.9.1"
|
|
59
|
+
"xbytes": "^1.9.1",
|
|
60
|
+
"zod": "^3.23.8"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
@@ -74,5 +76,5 @@
|
|
|
74
76
|
"ts-jest": "^28.0.8",
|
|
75
77
|
"typescript": "^4.9.5"
|
|
76
78
|
},
|
|
77
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a500b9034f7625e4a91ae42ac21bca4d3862b6e9"
|
|
78
80
|
}
|