kloudy-mcp 0.1.0-beta.0
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 +35 -0
- package/dist/api-x/client.d.ts +96 -0
- package/dist/api-x/client.js +549 -0
- package/dist/api-x/client.js.map +1 -0
- package/dist/api-x/projections.d.ts +42 -0
- package/dist/api-x/projections.js +790 -0
- package/dist/api-x/projections.js.map +1 -0
- package/dist/api-x/types.d.ts +432 -0
- package/dist/api-x/types.js +2 -0
- package/dist/api-x/types.js.map +1 -0
- package/dist/browser-login.d.ts +3 -0
- package/dist/browser-login.js +135 -0
- package/dist/browser-login.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +66 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +43 -0
- package/dist/config.js.map +1 -0
- package/dist/mcp-server.d.ts +3 -0
- package/dist/mcp-server.js +10 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/state-store.d.ts +39 -0
- package/dist/state-store.js +58 -0
- package/dist/state-store.js.map +1 -0
- package/dist/tools/account.d.ts +3 -0
- package/dist/tools/account.js +13 -0
- package/dist/tools/account.js.map +1 -0
- package/dist/tools/archive.d.ts +3 -0
- package/dist/tools/archive.js +27 -0
- package/dist/tools/archive.js.map +1 -0
- package/dist/tools/blog.d.ts +3 -0
- package/dist/tools/blog.js +34 -0
- package/dist/tools/blog.js.map +1 -0
- package/dist/tools/catalog.d.ts +133 -0
- package/dist/tools/catalog.js +136 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/characters.d.ts +5 -0
- package/dist/tools/characters.js +20 -0
- package/dist/tools/characters.js.map +1 -0
- package/dist/tools/community.d.ts +3 -0
- package/dist/tools/community.js +25 -0
- package/dist/tools/community.js.map +1 -0
- package/dist/tools/documents.d.ts +3 -0
- package/dist/tools/documents.js +30 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/links.d.ts +3 -0
- package/dist/tools/links.js +15 -0
- package/dist/tools/links.js.map +1 -0
- package/dist/tools/registry.d.ts +3 -0
- package/dist/tools/registry.js +21 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/shared.d.ts +23 -0
- package/dist/tools/shared.js +64 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/taxonomy.d.ts +3 -0
- package/dist/tools/taxonomy.js +26 -0
- package/dist/tools/taxonomy.js.map +1 -0
- package/dist/tools/wiki.d.ts +3 -0
- package/dist/tools/wiki.js +47 -0
- package/dist/tools/wiki.js.map +1 -0
- package/package.json +22 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const translatedTextSchema = z.record(z.string()).catch({});
|
|
3
|
+
const optionalString = z.string().optional();
|
|
4
|
+
const optionalNumber = z.number().optional();
|
|
5
|
+
const paginationSchema = z.object({
|
|
6
|
+
total: z.number().int().nonnegative(),
|
|
7
|
+
currentPage: z.number().int().positive(),
|
|
8
|
+
pageSize: z.number().int().positive(),
|
|
9
|
+
totalPages: z.number().int().nonnegative(),
|
|
10
|
+
});
|
|
11
|
+
const movieSchema = z.object({
|
|
12
|
+
movieId: z.string().min(1),
|
|
13
|
+
title: optionalString,
|
|
14
|
+
titleI18n: translatedTextSchema.optional().default({}),
|
|
15
|
+
introI18n: translatedTextSchema.optional().default({}),
|
|
16
|
+
coverUrl: optionalString,
|
|
17
|
+
rate: optionalNumber,
|
|
18
|
+
publishDate: optionalString,
|
|
19
|
+
type: optionalString,
|
|
20
|
+
region: optionalString,
|
|
21
|
+
});
|
|
22
|
+
const gameSchema = z.object({
|
|
23
|
+
gameId: z.string().min(1),
|
|
24
|
+
title: optionalString,
|
|
25
|
+
titleI18n: translatedTextSchema.optional().default({}),
|
|
26
|
+
introI18n: translatedTextSchema.optional().default({}),
|
|
27
|
+
coverUrl: optionalString,
|
|
28
|
+
rate: optionalNumber,
|
|
29
|
+
publishDate: optionalString,
|
|
30
|
+
region: optionalString,
|
|
31
|
+
gameplay: optionalString,
|
|
32
|
+
});
|
|
33
|
+
function projectPagination(value) {
|
|
34
|
+
return paginationSchema.parse(value);
|
|
35
|
+
}
|
|
36
|
+
function projectMovieSummary(value) {
|
|
37
|
+
const item = movieSchema.parse(value);
|
|
38
|
+
const projected = {
|
|
39
|
+
movieId: item.movieId,
|
|
40
|
+
titleI18n: item.titleI18n,
|
|
41
|
+
};
|
|
42
|
+
if (item.title !== undefined)
|
|
43
|
+
projected.title = item.title;
|
|
44
|
+
if (item.coverUrl !== undefined)
|
|
45
|
+
projected.coverUrl = item.coverUrl;
|
|
46
|
+
if (item.rate !== undefined)
|
|
47
|
+
projected.rate = item.rate;
|
|
48
|
+
if (item.publishDate !== undefined)
|
|
49
|
+
projected.publishDate = item.publishDate;
|
|
50
|
+
if (item.type !== undefined)
|
|
51
|
+
projected.type = item.type;
|
|
52
|
+
if (item.region !== undefined)
|
|
53
|
+
projected.region = item.region;
|
|
54
|
+
return projected;
|
|
55
|
+
}
|
|
56
|
+
export function projectMovieDetail(value) {
|
|
57
|
+
const item = movieSchema.parse(value);
|
|
58
|
+
return { ...projectMovieSummary(item), introI18n: item.introI18n };
|
|
59
|
+
}
|
|
60
|
+
function projectGameSummary(value) {
|
|
61
|
+
const item = gameSchema.parse(value);
|
|
62
|
+
const projected = {
|
|
63
|
+
gameId: item.gameId,
|
|
64
|
+
titleI18n: item.titleI18n,
|
|
65
|
+
};
|
|
66
|
+
if (item.title !== undefined)
|
|
67
|
+
projected.title = item.title;
|
|
68
|
+
if (item.coverUrl !== undefined)
|
|
69
|
+
projected.coverUrl = item.coverUrl;
|
|
70
|
+
if (item.rate !== undefined)
|
|
71
|
+
projected.rate = item.rate;
|
|
72
|
+
if (item.publishDate !== undefined)
|
|
73
|
+
projected.publishDate = item.publishDate;
|
|
74
|
+
if (item.region !== undefined)
|
|
75
|
+
projected.region = item.region;
|
|
76
|
+
if (item.gameplay !== undefined)
|
|
77
|
+
projected.gameplay = item.gameplay;
|
|
78
|
+
return projected;
|
|
79
|
+
}
|
|
80
|
+
export function projectGameDetail(value) {
|
|
81
|
+
const item = gameSchema.parse(value);
|
|
82
|
+
return { ...projectGameSummary(item), introI18n: item.introI18n };
|
|
83
|
+
}
|
|
84
|
+
export function projectMovieSearch(value) {
|
|
85
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
86
|
+
return { list: response.list.map(projectMovieSummary), pagination: projectPagination(response.pagination) };
|
|
87
|
+
}
|
|
88
|
+
export function projectGameSearch(value) {
|
|
89
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
90
|
+
return { list: response.list.map(projectGameSummary), pagination: projectPagination(response.pagination) };
|
|
91
|
+
}
|
|
92
|
+
const actorCharacterSchema = z.object({
|
|
93
|
+
characterId: z.string().min(1),
|
|
94
|
+
characterType: z.string().min(1),
|
|
95
|
+
name: z.string().nullish(),
|
|
96
|
+
});
|
|
97
|
+
const capabilitiesSchema = z.object({
|
|
98
|
+
contractVersion: z.number().int().positive(),
|
|
99
|
+
actor: z.object({
|
|
100
|
+
authType: z.enum(['visitor', 'guest', 'user']),
|
|
101
|
+
permissionLevel: z.number().int().nonnegative(),
|
|
102
|
+
permission: z.enum(['visitor', 'guest', 'user', 'admin']),
|
|
103
|
+
character: actorCharacterSchema.nullable(),
|
|
104
|
+
}),
|
|
105
|
+
availableModules: z.array(z.string()),
|
|
106
|
+
availableArchiveTypes: z.array(z.enum(['movie', 'game', 'song', 'activity', 'product'])),
|
|
107
|
+
permissions: z.record(z.boolean()),
|
|
108
|
+
featureFlags: z.record(z.boolean()),
|
|
109
|
+
});
|
|
110
|
+
export function projectCapabilities(value) {
|
|
111
|
+
const parsed = capabilitiesSchema.parse(value);
|
|
112
|
+
return {
|
|
113
|
+
...parsed,
|
|
114
|
+
actor: {
|
|
115
|
+
...parsed.actor,
|
|
116
|
+
character: parsed.actor.character
|
|
117
|
+
? {
|
|
118
|
+
characterId: parsed.actor.character.characterId,
|
|
119
|
+
characterType: parsed.actor.character.characterType,
|
|
120
|
+
...(parsed.actor.character.name ? { name: parsed.actor.character.name } : {}),
|
|
121
|
+
}
|
|
122
|
+
: null,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const accountContextSchema = z.object({
|
|
127
|
+
authType: z.enum(['visitor', 'guest', 'user']).optional().default('visitor'),
|
|
128
|
+
permissionLevel: z.number().int().nonnegative(),
|
|
129
|
+
user: z.object({ userId: z.string().min(1) }).nullish(),
|
|
130
|
+
character: z
|
|
131
|
+
.object({
|
|
132
|
+
characterId: z.string().min(1),
|
|
133
|
+
characterType: z.string().min(1),
|
|
134
|
+
name: z.string().nullish(),
|
|
135
|
+
avatarUrl: z.string().nullish(),
|
|
136
|
+
})
|
|
137
|
+
.nullish(),
|
|
138
|
+
});
|
|
139
|
+
export function projectAccountContext(value) {
|
|
140
|
+
const parsed = accountContextSchema.parse(value);
|
|
141
|
+
return {
|
|
142
|
+
authType: parsed.authType,
|
|
143
|
+
permissionLevel: parsed.permissionLevel,
|
|
144
|
+
user: parsed.user ? { userId: parsed.user.userId } : null,
|
|
145
|
+
character: parsed.character
|
|
146
|
+
? {
|
|
147
|
+
characterId: parsed.character.characterId,
|
|
148
|
+
characterType: parsed.character.characterType,
|
|
149
|
+
...(parsed.character.name ? { name: parsed.character.name } : {}),
|
|
150
|
+
...(parsed.character.avatarUrl ? { avatarUrl: parsed.character.avatarUrl } : {}),
|
|
151
|
+
}
|
|
152
|
+
: null,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const ownedCharacterSchema = z.object({
|
|
156
|
+
characterId: z.string().min(1),
|
|
157
|
+
characterType: z.string().min(1),
|
|
158
|
+
name: z.string().nullish(),
|
|
159
|
+
avatarUrl: z.string().nullish(),
|
|
160
|
+
});
|
|
161
|
+
export function projectOwnedCharacters(value) {
|
|
162
|
+
return z.array(ownedCharacterSchema).parse(value).map((character) => ({
|
|
163
|
+
characterId: character.characterId,
|
|
164
|
+
characterType: character.characterType,
|
|
165
|
+
...(character.name ? { name: character.name } : {}),
|
|
166
|
+
...(character.avatarUrl ? { avatarUrl: character.avatarUrl } : {}),
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
const assetOverviewSchema = z.object({
|
|
170
|
+
points: z.object({
|
|
171
|
+
balance: z.number().int(),
|
|
172
|
+
totalEarned: z.number().int(),
|
|
173
|
+
totalSpent: z.number().int(),
|
|
174
|
+
}),
|
|
175
|
+
medalCount: z.number().int().nonnegative(),
|
|
176
|
+
assetCount: z.number().int().nonnegative(),
|
|
177
|
+
});
|
|
178
|
+
export function projectAssetOverview(value) {
|
|
179
|
+
return assetOverviewSchema.parse(value);
|
|
180
|
+
}
|
|
181
|
+
const ownedAssetSchema = z.object({
|
|
182
|
+
assetId: z.string().min(1),
|
|
183
|
+
assetType: z.string().min(1),
|
|
184
|
+
name: z.string(),
|
|
185
|
+
description: z.string().nullish(),
|
|
186
|
+
iconUrl: z.string().nullish(),
|
|
187
|
+
quantity: z.number().int(),
|
|
188
|
+
expireAt: z.string().nullish(),
|
|
189
|
+
createTime: z.string().nullish(),
|
|
190
|
+
updateTime: z.string().nullish(),
|
|
191
|
+
});
|
|
192
|
+
export function projectOwnedAssets(value) {
|
|
193
|
+
const response = z.object({ list: z.array(ownedAssetSchema), pagination: z.unknown() }).parse(value);
|
|
194
|
+
return {
|
|
195
|
+
list: response.list.map((asset) => ({
|
|
196
|
+
assetId: asset.assetId,
|
|
197
|
+
assetType: asset.assetType,
|
|
198
|
+
name: asset.name,
|
|
199
|
+
...(asset.description ? { description: asset.description } : {}),
|
|
200
|
+
...(asset.iconUrl ? { iconUrl: asset.iconUrl } : {}),
|
|
201
|
+
quantity: asset.quantity,
|
|
202
|
+
...(asset.expireAt ? { expireAt: asset.expireAt } : {}),
|
|
203
|
+
...(asset.createTime ? { createTime: asset.createTime } : {}),
|
|
204
|
+
...(asset.updateTime ? { updateTime: asset.updateTime } : {}),
|
|
205
|
+
})),
|
|
206
|
+
pagination: projectPagination(response.pagination),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const publicCharacterSchema = z.object({
|
|
210
|
+
characterId: z.string().min(1),
|
|
211
|
+
characterType: z.string().min(1),
|
|
212
|
+
name: z.string().nullish(),
|
|
213
|
+
avatarUrl: z.string().nullish(),
|
|
214
|
+
intro: z.string().nullish(),
|
|
215
|
+
birthday: z.string().nullish(),
|
|
216
|
+
color: z.string().nullish(),
|
|
217
|
+
websiteUrl: z.string().nullish(),
|
|
218
|
+
profileVisibility: z.string().nullish(),
|
|
219
|
+
visibleModules: z.array(z.string()).optional().default([]),
|
|
220
|
+
createTime: z.string().nullish(),
|
|
221
|
+
updateTime: z.string().nullish(),
|
|
222
|
+
});
|
|
223
|
+
function projectPublicCharacterValue(value) {
|
|
224
|
+
const character = publicCharacterSchema.parse(value);
|
|
225
|
+
return {
|
|
226
|
+
characterId: character.characterId,
|
|
227
|
+
characterType: character.characterType,
|
|
228
|
+
...(character.name ? { name: character.name } : {}),
|
|
229
|
+
...(character.avatarUrl ? { avatarUrl: character.avatarUrl } : {}),
|
|
230
|
+
...(character.intro ? { intro: character.intro } : {}),
|
|
231
|
+
...(character.birthday ? { birthday: character.birthday } : {}),
|
|
232
|
+
...(character.color ? { color: character.color } : {}),
|
|
233
|
+
...(character.websiteUrl ? { websiteUrl: character.websiteUrl } : {}),
|
|
234
|
+
...(character.profileVisibility ? { profileVisibility: character.profileVisibility } : {}),
|
|
235
|
+
visibleModules: character.visibleModules,
|
|
236
|
+
...(character.createTime ? { createTime: character.createTime } : {}),
|
|
237
|
+
...(character.updateTime ? { updateTime: character.updateTime } : {}),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export function projectCharacterSearch(value) {
|
|
241
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
242
|
+
return {
|
|
243
|
+
list: response.list.map(projectPublicCharacterValue),
|
|
244
|
+
pagination: projectPagination(response.pagination),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
export function projectCharacter(value) {
|
|
248
|
+
return projectPublicCharacterValue(value);
|
|
249
|
+
}
|
|
250
|
+
const tagAttributeSchema = z.object({
|
|
251
|
+
attr_id: z.string().min(1),
|
|
252
|
+
category: z.string().nullish(),
|
|
253
|
+
weight: z.number().optional().default(0),
|
|
254
|
+
name: z.string().min(1),
|
|
255
|
+
name_i18n: translatedTextSchema.optional().default({}),
|
|
256
|
+
description_i18n: translatedTextSchema.optional().default({}),
|
|
257
|
+
});
|
|
258
|
+
function projectTagAttributeValue(value) {
|
|
259
|
+
const attribute = tagAttributeSchema.parse(value);
|
|
260
|
+
return {
|
|
261
|
+
attributeId: attribute.attr_id,
|
|
262
|
+
...(attribute.category ? { category: attribute.category } : {}),
|
|
263
|
+
weight: attribute.weight,
|
|
264
|
+
name: attribute.name,
|
|
265
|
+
nameI18n: attribute.name_i18n,
|
|
266
|
+
descriptionI18n: attribute.description_i18n,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
export function projectTagAttributes(value) {
|
|
270
|
+
return z.array(z.unknown()).parse(value).map(projectTagAttributeValue);
|
|
271
|
+
}
|
|
272
|
+
export function projectTagAttribute(value) {
|
|
273
|
+
return value === null ? null : projectTagAttributeValue(value);
|
|
274
|
+
}
|
|
275
|
+
const tagDefinitionSchema = z.object({
|
|
276
|
+
tag_id: z.string().min(1),
|
|
277
|
+
attr_id: z.string().min(1),
|
|
278
|
+
tag_name: z.string().min(1),
|
|
279
|
+
tag_name_i18n: translatedTextSchema.optional().default({}),
|
|
280
|
+
tag_description_i18n: translatedTextSchema.optional().default({}),
|
|
281
|
+
attr_name: z.string().min(1),
|
|
282
|
+
attr_name_i18n: translatedTextSchema.optional().default({}),
|
|
283
|
+
color: z.string().nullish(),
|
|
284
|
+
weight: z.number().optional().default(0),
|
|
285
|
+
tag_weight: z.number().optional(),
|
|
286
|
+
});
|
|
287
|
+
function projectTagDefinitionValue(value) {
|
|
288
|
+
const tag = tagDefinitionSchema.parse(value);
|
|
289
|
+
return {
|
|
290
|
+
tagKey: tag.tag_id,
|
|
291
|
+
attributeId: tag.attr_id,
|
|
292
|
+
name: tag.tag_name,
|
|
293
|
+
nameI18n: tag.tag_name_i18n,
|
|
294
|
+
descriptionI18n: tag.tag_description_i18n,
|
|
295
|
+
attributeName: tag.attr_name,
|
|
296
|
+
attributeNameI18n: tag.attr_name_i18n,
|
|
297
|
+
...(tag.color ? { color: tag.color } : {}),
|
|
298
|
+
tagWeight: tag.tag_weight ?? tag.weight,
|
|
299
|
+
...(tag.tag_weight !== undefined ? { resourceWeight: tag.weight } : {}),
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
export function projectTags(value) {
|
|
303
|
+
return z.array(z.unknown()).parse(value).map(projectTagDefinitionValue);
|
|
304
|
+
}
|
|
305
|
+
export function projectTag(value) {
|
|
306
|
+
return value === null ? null : projectTagDefinitionValue(value);
|
|
307
|
+
}
|
|
308
|
+
const metadataFieldSchema = z.object({
|
|
309
|
+
field_id: z.string().min(1),
|
|
310
|
+
field_type: z.string().min(1),
|
|
311
|
+
category: z.string().nullish(),
|
|
312
|
+
icon: z.string().nullish(),
|
|
313
|
+
name: z.string().min(1),
|
|
314
|
+
name_i18n: translatedTextSchema.optional().default({}),
|
|
315
|
+
description: z.string().nullish(),
|
|
316
|
+
description_i18n: translatedTextSchema.optional().default({}),
|
|
317
|
+
weight: z.number().optional().default(0),
|
|
318
|
+
});
|
|
319
|
+
function projectMetadataFieldValue(value) {
|
|
320
|
+
const field = metadataFieldSchema.parse(value);
|
|
321
|
+
return {
|
|
322
|
+
fieldId: field.field_id,
|
|
323
|
+
fieldType: field.field_type,
|
|
324
|
+
...(field.category ? { category: field.category } : {}),
|
|
325
|
+
...(field.icon ? { icon: field.icon } : {}),
|
|
326
|
+
name: field.name,
|
|
327
|
+
nameI18n: field.name_i18n,
|
|
328
|
+
...(field.description ? { description: field.description } : {}),
|
|
329
|
+
descriptionI18n: field.description_i18n,
|
|
330
|
+
weight: field.weight,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
export function projectMetadataFields(value) {
|
|
334
|
+
return z.array(z.unknown()).parse(value).map(projectMetadataFieldValue);
|
|
335
|
+
}
|
|
336
|
+
const resourceMetadataSchema = z.object({
|
|
337
|
+
field_id: z.string().min(1),
|
|
338
|
+
field_type: z.string().min(1),
|
|
339
|
+
field_name: z.string().min(1),
|
|
340
|
+
field_name_i18n: translatedTextSchema.optional().default({}),
|
|
341
|
+
category: z.string().nullish(),
|
|
342
|
+
icon: z.string().nullish(),
|
|
343
|
+
value: z.string(),
|
|
344
|
+
parsed_value: z.unknown(),
|
|
345
|
+
});
|
|
346
|
+
export function projectResourceMetadata(value) {
|
|
347
|
+
return z.array(resourceMetadataSchema).parse(value).map((item) => ({
|
|
348
|
+
fieldId: item.field_id,
|
|
349
|
+
fieldType: item.field_type,
|
|
350
|
+
fieldName: item.field_name,
|
|
351
|
+
fieldNameI18n: item.field_name_i18n,
|
|
352
|
+
...(item.category ? { category: item.category } : {}),
|
|
353
|
+
...(item.icon ? { icon: item.icon } : {}),
|
|
354
|
+
value: item.value,
|
|
355
|
+
parsedValue: item.parsed_value,
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
export function projectRelationRoles(value) {
|
|
359
|
+
return z
|
|
360
|
+
.array(z.object({ role_id: z.string().min(1), category: z.string().min(1) }))
|
|
361
|
+
.parse(value)
|
|
362
|
+
.map((role) => ({ roleId: role.role_id, category: role.category }));
|
|
363
|
+
}
|
|
364
|
+
const publicLinkSchema = z.object({
|
|
365
|
+
linkSn: z.string().min(1),
|
|
366
|
+
classId: z.string().nullish(),
|
|
367
|
+
weight: z.number().nullish(),
|
|
368
|
+
disabled: z.number().int().nullish(),
|
|
369
|
+
title: z.string().nullish(),
|
|
370
|
+
intro: z.string().nullish(),
|
|
371
|
+
icon: z.string().nullish(),
|
|
372
|
+
url: z.string().nullish(),
|
|
373
|
+
createTime: z.string().nullish(),
|
|
374
|
+
updateTime: z.string().nullish(),
|
|
375
|
+
});
|
|
376
|
+
export function projectPublicLinks(value) {
|
|
377
|
+
return z.array(publicLinkSchema).parse(value).map((item) => ({
|
|
378
|
+
linkSn: item.linkSn,
|
|
379
|
+
...(item.classId ? { classId: item.classId } : {}),
|
|
380
|
+
...(item.weight !== null && item.weight !== undefined ? { weight: item.weight } : {}),
|
|
381
|
+
disabled: item.disabled !== null && item.disabled !== undefined ? item.disabled > 0 : false,
|
|
382
|
+
...(item.title ? { title: item.title } : {}),
|
|
383
|
+
...(item.intro ? { intro: item.intro } : {}),
|
|
384
|
+
...(item.icon ? { icon: item.icon } : {}),
|
|
385
|
+
...(item.url ? { url: item.url } : {}),
|
|
386
|
+
...(item.createTime ? { createTime: item.createTime } : {}),
|
|
387
|
+
...(item.updateTime ? { updateTime: item.updateTime } : {}),
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
const archiveCarouselSchema = z.object({
|
|
391
|
+
title: z.string(),
|
|
392
|
+
subtitle: z.string(),
|
|
393
|
+
imageUrl: z.string(),
|
|
394
|
+
isDark: z.number().int(),
|
|
395
|
+
link: z.string(),
|
|
396
|
+
});
|
|
397
|
+
export function projectArchiveCarousel(value) {
|
|
398
|
+
return z.array(archiveCarouselSchema).parse(value).map((item) => ({
|
|
399
|
+
title: item.title,
|
|
400
|
+
subtitle: item.subtitle,
|
|
401
|
+
imageUrl: item.imageUrl,
|
|
402
|
+
isDark: item.isDark > 0,
|
|
403
|
+
link: item.link,
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
const documentSpaceSchema = z.object({
|
|
407
|
+
spaceId: z.string().min(1),
|
|
408
|
+
spaceType: z.string().min(1),
|
|
409
|
+
ownerCharacterId: z.string().nullish(),
|
|
410
|
+
name: z.string().nullish(),
|
|
411
|
+
accessType: z.enum(['public', 'owner']),
|
|
412
|
+
createTime: z.string().nullish(),
|
|
413
|
+
updateTime: z.string().nullish(),
|
|
414
|
+
});
|
|
415
|
+
export function projectDocumentSpace(value) {
|
|
416
|
+
const space = documentSpaceSchema.parse(value);
|
|
417
|
+
return {
|
|
418
|
+
spaceId: space.spaceId,
|
|
419
|
+
spaceType: space.spaceType,
|
|
420
|
+
accessType: space.accessType,
|
|
421
|
+
...(space.ownerCharacterId ? { ownerCharacterId: space.ownerCharacterId } : {}),
|
|
422
|
+
...(space.name ? { name: space.name } : {}),
|
|
423
|
+
...(space.createTime ? { createTime: space.createTime } : {}),
|
|
424
|
+
...(space.updateTime ? { updateTime: space.updateTime } : {}),
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
export function projectDocumentSpaces(value) {
|
|
428
|
+
return z.array(z.unknown()).parse(value).map(projectDocumentSpace);
|
|
429
|
+
}
|
|
430
|
+
export function projectDocumentDirectory(value) {
|
|
431
|
+
const directory = z
|
|
432
|
+
.object({
|
|
433
|
+
name: z.string(),
|
|
434
|
+
type: z.literal('directory'),
|
|
435
|
+
children: z
|
|
436
|
+
.array(z.object({
|
|
437
|
+
path: z.string().min(1),
|
|
438
|
+
type: z.enum(['file', 'directory']),
|
|
439
|
+
size: z.number().int().nonnegative().optional(),
|
|
440
|
+
}))
|
|
441
|
+
.optional()
|
|
442
|
+
.default([]),
|
|
443
|
+
})
|
|
444
|
+
.parse(value);
|
|
445
|
+
return {
|
|
446
|
+
name: directory.name,
|
|
447
|
+
children: directory.children.map((entry) => ({
|
|
448
|
+
path: entry.path,
|
|
449
|
+
type: entry.type,
|
|
450
|
+
...(entry.size !== undefined ? { size: entry.size } : {}),
|
|
451
|
+
})),
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
const communityPostSchema = z.object({
|
|
455
|
+
postId: z.string().min(1),
|
|
456
|
+
postLink: z.string().min(1),
|
|
457
|
+
title: z.string().nullish(),
|
|
458
|
+
createTime: z.string().nullish(),
|
|
459
|
+
updateTime: z.string().nullish(),
|
|
460
|
+
});
|
|
461
|
+
function projectCommunityPostValue(value) {
|
|
462
|
+
const post = communityPostSchema.parse(value);
|
|
463
|
+
return {
|
|
464
|
+
postId: post.postId,
|
|
465
|
+
postLink: post.postLink,
|
|
466
|
+
...(post.title ? { title: post.title } : {}),
|
|
467
|
+
...(post.createTime ? { createTime: post.createTime } : {}),
|
|
468
|
+
...(post.updateTime ? { updateTime: post.updateTime } : {}),
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
export function projectCommunityPost(value) {
|
|
472
|
+
return value === null ? null : projectCommunityPostValue(value);
|
|
473
|
+
}
|
|
474
|
+
export function projectCommunityPosts(value) {
|
|
475
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
476
|
+
return {
|
|
477
|
+
list: response.list.map(projectCommunityPostValue),
|
|
478
|
+
pagination: projectPagination(response.pagination),
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const communityCharacterSchema = z.object({
|
|
482
|
+
characterId: z.string().nullish(),
|
|
483
|
+
characterType: z.string().nullish(),
|
|
484
|
+
name: z.string().nullish(),
|
|
485
|
+
avatarUrl: z.string().nullish(),
|
|
486
|
+
});
|
|
487
|
+
const communityCommentSchema = z.lazy(() => z.object({
|
|
488
|
+
commentSn: z.string().min(1),
|
|
489
|
+
content: z.string().nullish(),
|
|
490
|
+
md: z.number().nullish(),
|
|
491
|
+
character: communityCharacterSchema.nullish(),
|
|
492
|
+
post: z.unknown().optional(),
|
|
493
|
+
parent: communityCommentSchema.optional(),
|
|
494
|
+
children: z.array(communityCommentSchema).optional(),
|
|
495
|
+
isMine: z.boolean(),
|
|
496
|
+
canDelete: z.boolean(),
|
|
497
|
+
createTime: z.string().nullish(),
|
|
498
|
+
updateTime: z.string().nullish(),
|
|
499
|
+
}));
|
|
500
|
+
function projectCommunityComment(value) {
|
|
501
|
+
const comment = communityCommentSchema.parse(value);
|
|
502
|
+
return {
|
|
503
|
+
commentSn: comment.commentSn,
|
|
504
|
+
...(comment.content !== undefined && comment.content !== null ? { content: comment.content } : {}),
|
|
505
|
+
...(comment.md !== undefined && comment.md !== null ? { md: comment.md } : {}),
|
|
506
|
+
...(comment.character
|
|
507
|
+
? {
|
|
508
|
+
character: {
|
|
509
|
+
...(comment.character.characterId ? { characterId: comment.character.characterId } : {}),
|
|
510
|
+
...(comment.character.characterType ? { characterType: comment.character.characterType } : {}),
|
|
511
|
+
...(comment.character.name ? { name: comment.character.name } : {}),
|
|
512
|
+
...(comment.character.avatarUrl ? { avatarUrl: comment.character.avatarUrl } : {}),
|
|
513
|
+
},
|
|
514
|
+
}
|
|
515
|
+
: {}),
|
|
516
|
+
...(comment.post ? { post: projectCommunityPostValue(comment.post) } : {}),
|
|
517
|
+
...(comment.parent ? { parent: projectCommunityComment(comment.parent) } : {}),
|
|
518
|
+
...(comment.children ? { children: comment.children.map(projectCommunityComment) } : {}),
|
|
519
|
+
isMine: comment.isMine,
|
|
520
|
+
canDelete: comment.canDelete,
|
|
521
|
+
...(comment.createTime ? { createTime: comment.createTime } : {}),
|
|
522
|
+
...(comment.updateTime ? { updateTime: comment.updateTime } : {}),
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
export function projectCommunityComments(value) {
|
|
526
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
527
|
+
return {
|
|
528
|
+
list: response.list.map(projectCommunityComment),
|
|
529
|
+
pagination: projectPagination(response.pagination),
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
const communityMessageSchema = z.object({
|
|
533
|
+
messageSn: z.string().min(1),
|
|
534
|
+
isRead: z.number().nullish(),
|
|
535
|
+
msgType: z.string().nullish(),
|
|
536
|
+
msgTitle: z.string(),
|
|
537
|
+
msgContent: z.string().nullish(),
|
|
538
|
+
contentType: z.string().nullish(),
|
|
539
|
+
msgLink: z.string().nullish(),
|
|
540
|
+
createTime: z.string().nullish(),
|
|
541
|
+
updateTime: z.string().nullish(),
|
|
542
|
+
});
|
|
543
|
+
export function projectCommunityMessages(value) {
|
|
544
|
+
const response = z.object({ list: z.array(communityMessageSchema), pagination: z.unknown() }).parse(value);
|
|
545
|
+
return {
|
|
546
|
+
list: response.list.map((message) => ({
|
|
547
|
+
messageSn: message.messageSn,
|
|
548
|
+
...(message.isRead !== undefined && message.isRead !== null ? { isRead: message.isRead } : {}),
|
|
549
|
+
...(message.msgType ? { messageType: message.msgType } : {}),
|
|
550
|
+
title: message.msgTitle,
|
|
551
|
+
...(message.msgContent ? { content: message.msgContent } : {}),
|
|
552
|
+
...(message.contentType ? { contentType: message.contentType } : {}),
|
|
553
|
+
...(message.msgLink ? { link: message.msgLink } : {}),
|
|
554
|
+
...(message.createTime ? { createTime: message.createTime } : {}),
|
|
555
|
+
...(message.updateTime ? { updateTime: message.updateTime } : {}),
|
|
556
|
+
})),
|
|
557
|
+
pagination: projectPagination(response.pagination),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
export function projectCommunityMessageCount(value) {
|
|
561
|
+
return z.number().int().nonnegative().parse(value);
|
|
562
|
+
}
|
|
563
|
+
export function projectCommunityCommentCreate(value) {
|
|
564
|
+
const result = z.object({ commentSn: z.string().regex(/^[A-Za-z0-9]{9}$/) }).parse(value);
|
|
565
|
+
return { commentSn: result.commentSn };
|
|
566
|
+
}
|
|
567
|
+
export function projectBooleanMutation(value) {
|
|
568
|
+
return z.boolean().parse(value);
|
|
569
|
+
}
|
|
570
|
+
const genericArchiveSchema = z.object({
|
|
571
|
+
movieId: z.string().min(1).optional(),
|
|
572
|
+
gameId: z.string().min(1).optional(),
|
|
573
|
+
songId: z.string().min(1).optional(),
|
|
574
|
+
activityId: z.string().min(1).optional(),
|
|
575
|
+
productId: z.string().min(1).optional(),
|
|
576
|
+
title: z.string().nullish(),
|
|
577
|
+
intro: z.string().nullish(),
|
|
578
|
+
titleI18n: translatedTextSchema.optional().default({}),
|
|
579
|
+
introI18n: translatedTextSchema.optional().default({}),
|
|
580
|
+
coverUrl: z.string().nullish(),
|
|
581
|
+
rate: z.number().nullish(),
|
|
582
|
+
publishDate: z.string().nullish(),
|
|
583
|
+
releaseDate: z.string().nullish(),
|
|
584
|
+
region: z.string().nullish(),
|
|
585
|
+
gameplay: z.string().nullish(),
|
|
586
|
+
brand: z.string().nullish(),
|
|
587
|
+
category: z.string().nullish(),
|
|
588
|
+
activityType: z.string().nullish(),
|
|
589
|
+
location: z.string().nullish(),
|
|
590
|
+
city: z.string().nullish(),
|
|
591
|
+
startDate: z.string().nullish(),
|
|
592
|
+
endDate: z.string().nullish(),
|
|
593
|
+
});
|
|
594
|
+
function archiveIdForType(item, resourceType) {
|
|
595
|
+
const itemId = {
|
|
596
|
+
movie: item.movieId,
|
|
597
|
+
game: item.gameId,
|
|
598
|
+
song: item.songId,
|
|
599
|
+
activity: item.activityId,
|
|
600
|
+
product: item.productId,
|
|
601
|
+
}[resourceType];
|
|
602
|
+
if (!itemId)
|
|
603
|
+
throw new z.ZodError([]);
|
|
604
|
+
return itemId;
|
|
605
|
+
}
|
|
606
|
+
function projectArchiveItem(resourceType, value, includeIntro) {
|
|
607
|
+
const item = genericArchiveSchema.parse(value);
|
|
608
|
+
const projected = {
|
|
609
|
+
resourceType,
|
|
610
|
+
itemId: archiveIdForType(item, resourceType),
|
|
611
|
+
titleI18n: item.titleI18n,
|
|
612
|
+
};
|
|
613
|
+
const stringFields = [
|
|
614
|
+
'title',
|
|
615
|
+
'coverUrl',
|
|
616
|
+
'publishDate',
|
|
617
|
+
'releaseDate',
|
|
618
|
+
'region',
|
|
619
|
+
'gameplay',
|
|
620
|
+
'brand',
|
|
621
|
+
'category',
|
|
622
|
+
'activityType',
|
|
623
|
+
'location',
|
|
624
|
+
'city',
|
|
625
|
+
'startDate',
|
|
626
|
+
'endDate',
|
|
627
|
+
];
|
|
628
|
+
for (const field of stringFields) {
|
|
629
|
+
const fieldValue = item[field];
|
|
630
|
+
if (typeof fieldValue === 'string')
|
|
631
|
+
projected[field] = fieldValue;
|
|
632
|
+
}
|
|
633
|
+
if (typeof item.rate === 'number')
|
|
634
|
+
projected.rate = item.rate;
|
|
635
|
+
if (includeIntro) {
|
|
636
|
+
if (typeof item.intro === 'string')
|
|
637
|
+
projected.intro = item.intro;
|
|
638
|
+
projected.introI18n = item.introI18n;
|
|
639
|
+
}
|
|
640
|
+
return projected;
|
|
641
|
+
}
|
|
642
|
+
export function projectArchiveSearch(resourceType, value) {
|
|
643
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
644
|
+
return {
|
|
645
|
+
list: response.list.map((item) => projectArchiveItem(resourceType, item, false)),
|
|
646
|
+
pagination: projectPagination(response.pagination),
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
export function projectArchiveDetail(resourceType, value) {
|
|
650
|
+
return projectArchiveItem(resourceType, value, true);
|
|
651
|
+
}
|
|
652
|
+
const blogCharacterSchema = z.object({
|
|
653
|
+
characterId: z.string().min(1),
|
|
654
|
+
characterType: z.string().nullish(),
|
|
655
|
+
name: z.string().nullish(),
|
|
656
|
+
avatarUrl: z.string().nullish(),
|
|
657
|
+
});
|
|
658
|
+
const blogArticleSchema = z.object({
|
|
659
|
+
articleId: z.string().min(1),
|
|
660
|
+
title: z.string().nullish(),
|
|
661
|
+
intro: z.string().nullish(),
|
|
662
|
+
coverUrl: z.string().nullish(),
|
|
663
|
+
articleType: z.string().nullish(),
|
|
664
|
+
category: z.string().nullish(),
|
|
665
|
+
createTime: z.string().nullish(),
|
|
666
|
+
updateTime: z.string().nullish(),
|
|
667
|
+
content: z.string().optional(),
|
|
668
|
+
assetBaseUrl: z.string().optional(),
|
|
669
|
+
character: blogCharacterSchema.optional(),
|
|
670
|
+
children: z.array(z.unknown()).optional(),
|
|
671
|
+
});
|
|
672
|
+
function projectBlogArticle(value) {
|
|
673
|
+
const article = blogArticleSchema.parse(value);
|
|
674
|
+
return {
|
|
675
|
+
articleId: article.articleId,
|
|
676
|
+
...(article.title ? { title: article.title } : {}),
|
|
677
|
+
...(article.intro ? { intro: article.intro } : {}),
|
|
678
|
+
...(article.coverUrl ? { coverUrl: article.coverUrl } : {}),
|
|
679
|
+
...(article.articleType ? { articleType: article.articleType } : {}),
|
|
680
|
+
...(article.category ? { category: article.category } : {}),
|
|
681
|
+
...(article.createTime ? { createTime: article.createTime } : {}),
|
|
682
|
+
...(article.updateTime ? { updateTime: article.updateTime } : {}),
|
|
683
|
+
...(article.content !== undefined ? { content: article.content } : {}),
|
|
684
|
+
...(article.assetBaseUrl !== undefined ? { assetBaseUrl: article.assetBaseUrl } : {}),
|
|
685
|
+
...(article.character
|
|
686
|
+
? {
|
|
687
|
+
character: {
|
|
688
|
+
characterId: article.character.characterId,
|
|
689
|
+
...(article.character.characterType ? { characterType: article.character.characterType } : {}),
|
|
690
|
+
...(article.character.name ? { name: article.character.name } : {}),
|
|
691
|
+
...(article.character.avatarUrl ? { avatarUrl: article.character.avatarUrl } : {}),
|
|
692
|
+
},
|
|
693
|
+
}
|
|
694
|
+
: {}),
|
|
695
|
+
...(article.children ? { children: article.children.map(projectBlogArticle) } : {}),
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
export function projectBlogList(value) {
|
|
699
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
700
|
+
return { list: response.list.map(projectBlogArticle), pagination: projectPagination(response.pagination) };
|
|
701
|
+
}
|
|
702
|
+
export function projectBlogDetail(value) {
|
|
703
|
+
return projectBlogArticle(value);
|
|
704
|
+
}
|
|
705
|
+
const blogHeadlineSchema = z.object({
|
|
706
|
+
title: z.string().nullish(),
|
|
707
|
+
subtitle: z.string().nullish(),
|
|
708
|
+
intro: z.string().nullish(),
|
|
709
|
+
color: z.string().nullish(),
|
|
710
|
+
img: z.string().nullish(),
|
|
711
|
+
title_img: z.string().nullish(),
|
|
712
|
+
dark_mode: z.enum(['auto', 'dark', 'light', '']).nullish(),
|
|
713
|
+
gray: z.number().int().nullish(),
|
|
714
|
+
v_align: z.number().int().nullish(),
|
|
715
|
+
h_align: z.number().int().nullish(),
|
|
716
|
+
create_time: z.string().nullish(),
|
|
717
|
+
update_time: z.string().nullish(),
|
|
718
|
+
});
|
|
719
|
+
export function projectBlogHeadlines(value) {
|
|
720
|
+
return z.array(blogHeadlineSchema).parse(value).map((item) => ({
|
|
721
|
+
...(item.title ? { title: item.title } : {}),
|
|
722
|
+
...(item.subtitle ? { subtitle: item.subtitle } : {}),
|
|
723
|
+
...(item.intro ? { intro: item.intro } : {}),
|
|
724
|
+
...(item.color ? { color: item.color } : {}),
|
|
725
|
+
...(item.img ? { imageUrl: item.img } : {}),
|
|
726
|
+
...(item.title_img ? { titleImageUrl: item.title_img } : {}),
|
|
727
|
+
...(item.dark_mode !== null && item.dark_mode !== undefined ? { darkMode: item.dark_mode } : {}),
|
|
728
|
+
grayscale: item.gray !== null && item.gray !== undefined ? item.gray > 0 : false,
|
|
729
|
+
...(item.v_align !== null && item.v_align !== undefined ? { verticalAlign: item.v_align } : {}),
|
|
730
|
+
...(item.h_align !== null && item.h_align !== undefined ? { horizontalAlign: item.h_align } : {}),
|
|
731
|
+
...(item.create_time ? { createTime: item.create_time } : {}),
|
|
732
|
+
...(item.update_time ? { updateTime: item.update_time } : {}),
|
|
733
|
+
}));
|
|
734
|
+
}
|
|
735
|
+
const ownedBlogArticleSchema = z.object({
|
|
736
|
+
articleId: z.string().min(1),
|
|
737
|
+
title: z.string().nullish(),
|
|
738
|
+
intro: z.string().nullish(),
|
|
739
|
+
coverUrl: z.string().nullish(),
|
|
740
|
+
articleType: z.string().nullish(),
|
|
741
|
+
category: z.string().nullish(),
|
|
742
|
+
isPublished: z.number().int().min(0).max(1).optional().default(0),
|
|
743
|
+
createTime: z.string().nullish(),
|
|
744
|
+
updateTime: z.string().nullish(),
|
|
745
|
+
});
|
|
746
|
+
function projectOwnedBlogArticle(value) {
|
|
747
|
+
const article = ownedBlogArticleSchema.parse(value);
|
|
748
|
+
return {
|
|
749
|
+
articleId: article.articleId,
|
|
750
|
+
...(article.title ? { title: article.title } : {}),
|
|
751
|
+
...(article.intro ? { intro: article.intro } : {}),
|
|
752
|
+
...(article.coverUrl ? { coverUrl: article.coverUrl } : {}),
|
|
753
|
+
...(article.articleType ? { articleType: article.articleType } : {}),
|
|
754
|
+
...(article.category ? { category: article.category } : {}),
|
|
755
|
+
isPublished: article.isPublished === 1,
|
|
756
|
+
...(article.createTime ? { createTime: article.createTime } : {}),
|
|
757
|
+
...(article.updateTime ? { updateTime: article.updateTime } : {}),
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
export function projectOwnedBlogArticles(value) {
|
|
761
|
+
const response = z.object({ list: z.array(z.unknown()), pagination: z.unknown() }).parse(value);
|
|
762
|
+
return {
|
|
763
|
+
list: response.list.map(projectOwnedBlogArticle),
|
|
764
|
+
pagination: projectPagination(response.pagination),
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
export function projectBlogDraft(value) {
|
|
768
|
+
const draft = z
|
|
769
|
+
.object({
|
|
770
|
+
article: z.unknown(),
|
|
771
|
+
content: z.string(),
|
|
772
|
+
formalContent: z.string(),
|
|
773
|
+
draftContent: z.string(),
|
|
774
|
+
hasDraft: z.boolean(),
|
|
775
|
+
canEditDraft: z.boolean(),
|
|
776
|
+
})
|
|
777
|
+
.parse(value);
|
|
778
|
+
return {
|
|
779
|
+
article: { ...projectOwnedBlogArticle(draft.article), canEditDraft: draft.canEditDraft },
|
|
780
|
+
content: draft.content,
|
|
781
|
+
formalContent: draft.formalContent,
|
|
782
|
+
draftContent: draft.draftContent,
|
|
783
|
+
hasDraft: draft.hasDraft,
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
export function projectBlogDraftContent(value) {
|
|
787
|
+
const content = z.object({ articleId: z.string().min(1), content: z.string() }).parse(value);
|
|
788
|
+
return { articleId: content.articleId, content: content.content };
|
|
789
|
+
}
|
|
790
|
+
//# sourceMappingURL=projections.js.map
|