@qoder-ai/qmind-cli 2.0.0 → 3.1.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/CHANGELOG.md +37 -1
- package/CHANGELOG.zh-CN.md +80 -0
- package/README.md +43 -63
- package/README.zh-CN.md +90 -0
- package/dist/bot-gateway-Hzjl50zu.js +373 -0
- package/dist/cards-DsMbd-g1.js +132 -0
- package/dist/imports-B01ERZgD.js +126 -0
- package/dist/management-BIYQa9Al.js +313 -0
- package/dist/notes-BvucEfdi.js +128 -0
- package/dist/qmind.js +861 -1377
- package/dist/shared-BkQJzIZF.js +1155 -0
- package/dist/source-upload-DBm1Hyki.js +17 -0
- package/dist/transfers-F1ZLLBdU.js +237 -0
- package/package.json +7 -13
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { Y as timestampSchema, a as invalidArgument, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString } from "./shared-BkQJzIZF.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../sdk/src/operations/bot-gateway-codecs.ts
|
|
4
|
+
const botTimestamp = z.preprocess((value) => typeof value === "object" && value !== null && !Array.isArray(value) && !("seconds" in value) ? {
|
|
5
|
+
...value,
|
|
6
|
+
seconds: 0
|
|
7
|
+
} : value, timestampSchema).optional();
|
|
8
|
+
const jsonObject = z.record(z.string(), z.json());
|
|
9
|
+
const fields = {
|
|
10
|
+
id: z.string().min(1),
|
|
11
|
+
org_id: z.string().default(""),
|
|
12
|
+
platform: z.string().default(""),
|
|
13
|
+
is_active: z.boolean().default(false),
|
|
14
|
+
created_at: botTimestamp,
|
|
15
|
+
updated_at: botTimestamp
|
|
16
|
+
};
|
|
17
|
+
function base(value) {
|
|
18
|
+
return {
|
|
19
|
+
id: value.id,
|
|
20
|
+
orgId: value.org_id,
|
|
21
|
+
platform: value.platform,
|
|
22
|
+
isActive: value.is_active,
|
|
23
|
+
...value.created_at === void 0 ? {} : { createdAt: value.created_at },
|
|
24
|
+
...value.updated_at === void 0 ? {} : { updatedAt: value.updated_at }
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const platformAppSchema = z.object({
|
|
28
|
+
...fields,
|
|
29
|
+
app_name: z.string().default(""),
|
|
30
|
+
client_id: z.string().default("")
|
|
31
|
+
}).transform((value) => ({
|
|
32
|
+
...base(value),
|
|
33
|
+
appName: value.app_name,
|
|
34
|
+
clientId: value.client_id
|
|
35
|
+
}));
|
|
36
|
+
const expertBindingSchema = z.object({
|
|
37
|
+
...fields,
|
|
38
|
+
user_id: z.string().default(""),
|
|
39
|
+
platform_app_id: z.string().default(""),
|
|
40
|
+
external_union_id: z.string().default(""),
|
|
41
|
+
external_nickname: z.string().default("")
|
|
42
|
+
}).transform((value) => ({
|
|
43
|
+
...base(value),
|
|
44
|
+
userId: value.user_id,
|
|
45
|
+
platformAppId: value.platform_app_id,
|
|
46
|
+
externalUnionId: value.external_union_id,
|
|
47
|
+
externalNickname: value.external_nickname
|
|
48
|
+
}));
|
|
49
|
+
const groupBindingSchema = z.object({
|
|
50
|
+
...fields,
|
|
51
|
+
platform_app_id: z.string().default(""),
|
|
52
|
+
conversation_id: z.string().default(""),
|
|
53
|
+
conversation_name: z.string().default(""),
|
|
54
|
+
notebook_id: z.string().default(""),
|
|
55
|
+
context_window: z.int32().default(0),
|
|
56
|
+
writer_user_id: z.string().default(""),
|
|
57
|
+
instructions: jsonObject.nullish()
|
|
58
|
+
}).transform((value) => ({
|
|
59
|
+
...base(value),
|
|
60
|
+
platformAppId: value.platform_app_id,
|
|
61
|
+
conversationId: value.conversation_id,
|
|
62
|
+
conversationName: value.conversation_name,
|
|
63
|
+
notebookId: value.notebook_id,
|
|
64
|
+
contextWindow: value.context_window,
|
|
65
|
+
writerUserId: value.writer_user_id,
|
|
66
|
+
...value.instructions == null ? {} : { instructions: value.instructions }
|
|
67
|
+
}));
|
|
68
|
+
const pageInfoSchema = z.object({
|
|
69
|
+
current_page: z.int32().nonnegative().default(0),
|
|
70
|
+
last_page: z.int32().nonnegative().default(0),
|
|
71
|
+
next_page: z.int32().nonnegative().default(0),
|
|
72
|
+
prev_page: z.int32().nonnegative().default(0),
|
|
73
|
+
page_size: z.int32().nonnegative().default(0),
|
|
74
|
+
total_size: z.int32().nonnegative().default(0),
|
|
75
|
+
next_token: z.string().default("")
|
|
76
|
+
}).transform((value) => ({
|
|
77
|
+
currentPage: value.current_page,
|
|
78
|
+
lastPage: value.last_page,
|
|
79
|
+
nextPage: value.next_page,
|
|
80
|
+
previousPage: value.prev_page,
|
|
81
|
+
pageSize: value.page_size,
|
|
82
|
+
totalSize: value.total_size,
|
|
83
|
+
nextToken: value.next_token
|
|
84
|
+
}));
|
|
85
|
+
const platformAppListSchema = z.object({
|
|
86
|
+
apps: z.array(platformAppSchema).nullish(),
|
|
87
|
+
pages: pageInfoSchema.nullish()
|
|
88
|
+
}).transform((value) => ({
|
|
89
|
+
apps: value.apps ?? [],
|
|
90
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
91
|
+
}));
|
|
92
|
+
const expertBindingListSchema = z.object({
|
|
93
|
+
bindings: z.array(expertBindingSchema).nullish(),
|
|
94
|
+
pages: pageInfoSchema.nullish()
|
|
95
|
+
}).transform((value) => ({
|
|
96
|
+
bindings: value.bindings ?? [],
|
|
97
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
98
|
+
}));
|
|
99
|
+
const groupBindingListSchema = z.object({
|
|
100
|
+
bindings: z.array(groupBindingSchema).nullish(),
|
|
101
|
+
pages: pageInfoSchema.nullish()
|
|
102
|
+
}).transform((value) => ({
|
|
103
|
+
bindings: value.bindings ?? [],
|
|
104
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
105
|
+
}));
|
|
106
|
+
const publishDingTalkSchema = z.object({
|
|
107
|
+
binding_code: z.string().min(1),
|
|
108
|
+
bind_command: z.string().min(1),
|
|
109
|
+
group_binding: groupBindingSchema
|
|
110
|
+
}).transform((value) => ({
|
|
111
|
+
bindingCode: value.binding_code,
|
|
112
|
+
bindCommand: value.bind_command,
|
|
113
|
+
groupBinding: value.group_binding
|
|
114
|
+
}));
|
|
115
|
+
const inviteDingTalkSchema = z.object({
|
|
116
|
+
binding_code: z.string().min(1),
|
|
117
|
+
bind_command: z.string().min(1),
|
|
118
|
+
expert_binding: expertBindingSchema
|
|
119
|
+
}).transform((value) => ({
|
|
120
|
+
bindingCode: value.binding_code,
|
|
121
|
+
bindCommand: value.bind_command,
|
|
122
|
+
expertBinding: value.expert_binding
|
|
123
|
+
}));
|
|
124
|
+
const botDeleteSchema = z.object({}).transform(() => void 0);
|
|
125
|
+
function optionalInt32(value, field) {
|
|
126
|
+
if (value === void 0) return void 0;
|
|
127
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < -2147483648 || value > 2147483647) throw invalidArgument(`${field} must be an int32`, field);
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
function isJson(value, ancestors) {
|
|
131
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
132
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
133
|
+
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
134
|
+
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return false;
|
|
135
|
+
if (Object.getOwnPropertySymbols(value).length > 0) return false;
|
|
136
|
+
ancestors.add(value);
|
|
137
|
+
const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every((child) => isJson(child, ancestors));
|
|
138
|
+
ancestors.delete(value);
|
|
139
|
+
return valid;
|
|
140
|
+
}
|
|
141
|
+
function optionalInstructions(value) {
|
|
142
|
+
const object = optionalRecord(value, "instructions");
|
|
143
|
+
if (object === void 0) return void 0;
|
|
144
|
+
try {
|
|
145
|
+
if (isJson(object, /* @__PURE__ */ new Set())) return object;
|
|
146
|
+
} catch {}
|
|
147
|
+
throw invalidArgument("instructions must contain only JSON values", "instructions");
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ../sdk/src/operations/bot-gateway.ts
|
|
151
|
+
function groupFields(input) {
|
|
152
|
+
return compactUndefined({
|
|
153
|
+
conversation_name: optionalString(input?.conversationName, "conversationName"),
|
|
154
|
+
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
155
|
+
writer_user_id: optionalString(input?.writerUserId, "writerUserId"),
|
|
156
|
+
is_active: optionalBoolean(input?.isActive, "isActive"),
|
|
157
|
+
instructions: optionalInstructions(input?.instructions)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function patch(body) {
|
|
161
|
+
assertNonEmptyPatch(body, "input");
|
|
162
|
+
return body;
|
|
163
|
+
}
|
|
164
|
+
function createBotGatewayOperations(context) {
|
|
165
|
+
const path = (notebookId, ...segments) => context.profile.apiPath("notebooks", requiredString(notebookId, "notebookId"), "botgw", ...segments);
|
|
166
|
+
const listPath = (notebookId, resource, input = {}) => {
|
|
167
|
+
const page = pagination({
|
|
168
|
+
page: input.page ?? 1,
|
|
169
|
+
pageSize: input.pageSize ?? 20
|
|
170
|
+
});
|
|
171
|
+
const onlyActive = optionalBoolean(input.onlyActive, "onlyActive");
|
|
172
|
+
return queryPath(path(notebookId, resource), [
|
|
173
|
+
["page", optionalInt32(page.page, "page")],
|
|
174
|
+
["page_size", optionalInt32(page.pageSize, "pageSize")],
|
|
175
|
+
["platform", optionalTrimmedString(input.platform, "platform")],
|
|
176
|
+
["only_active", onlyActive === void 0 ? void 0 : String(onlyActive)],
|
|
177
|
+
["platform_app_id", resource === "platform-apps" ? void 0 : optionalTrimmedString(input.platformAppId, "platformAppId")],
|
|
178
|
+
["user_id", resource === "expert-bindings" ? optionalTrimmedString(input.userId, "userId") : void 0]
|
|
179
|
+
]);
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
async listPlatformApps(notebookId, input, options) {
|
|
183
|
+
return call(context, {
|
|
184
|
+
callOptions: options,
|
|
185
|
+
capability: "botGateway",
|
|
186
|
+
method: "GET",
|
|
187
|
+
idempotent: true,
|
|
188
|
+
operation: "botGateway.platformApps.list",
|
|
189
|
+
path: listPath(notebookId, "platform-apps", input),
|
|
190
|
+
schema: platformAppListSchema
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
async createPlatformApp(notebookId, input, options) {
|
|
194
|
+
const body = compactUndefined({
|
|
195
|
+
platform: requiredString(input?.platform, "platform"),
|
|
196
|
+
app_name: requiredString(input?.appName, "appName"),
|
|
197
|
+
client_id: requiredString(input?.clientId, "clientId"),
|
|
198
|
+
client_secret: requiredText(input?.clientSecret, "clientSecret"),
|
|
199
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
200
|
+
});
|
|
201
|
+
return call(context, {
|
|
202
|
+
body,
|
|
203
|
+
callOptions: options,
|
|
204
|
+
capability: "botGateway",
|
|
205
|
+
method: "POST",
|
|
206
|
+
idempotent: false,
|
|
207
|
+
operation: "botGateway.platformApps.create",
|
|
208
|
+
path: path(notebookId, "platform-apps"),
|
|
209
|
+
schema: platformAppSchema
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
async updatePlatformApp(notebookId, appId, input, options) {
|
|
213
|
+
const body = patch(compactUndefined({
|
|
214
|
+
app_name: optionalString(input?.appName, "appName"),
|
|
215
|
+
client_secret: optionalString(input?.clientSecret, "clientSecret"),
|
|
216
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
217
|
+
}));
|
|
218
|
+
return call(context, {
|
|
219
|
+
body,
|
|
220
|
+
callOptions: options,
|
|
221
|
+
capability: "botGateway",
|
|
222
|
+
method: "PATCH",
|
|
223
|
+
idempotent: false,
|
|
224
|
+
operation: "botGateway.platformApps.update",
|
|
225
|
+
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
226
|
+
schema: platformAppSchema
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
async deletePlatformApp(notebookId, appId, options) {
|
|
230
|
+
return call(context, {
|
|
231
|
+
callOptions: options,
|
|
232
|
+
capability: "botGateway",
|
|
233
|
+
method: "DELETE",
|
|
234
|
+
idempotent: false,
|
|
235
|
+
operation: "botGateway.platformApps.delete",
|
|
236
|
+
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
237
|
+
schema: botDeleteSchema
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
async listExpertBindings(notebookId, input, options) {
|
|
241
|
+
return call(context, {
|
|
242
|
+
callOptions: options,
|
|
243
|
+
capability: "botGateway",
|
|
244
|
+
method: "GET",
|
|
245
|
+
idempotent: true,
|
|
246
|
+
operation: "botGateway.expertBindings.list",
|
|
247
|
+
path: listPath(notebookId, "expert-bindings", input),
|
|
248
|
+
schema: expertBindingListSchema
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
async updateExpertBinding(notebookId, bindingId, input, options) {
|
|
252
|
+
const body = patch(compactUndefined({
|
|
253
|
+
external_nickname: optionalString(input?.externalNickname, "externalNickname"),
|
|
254
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
255
|
+
}));
|
|
256
|
+
return call(context, {
|
|
257
|
+
body,
|
|
258
|
+
callOptions: options,
|
|
259
|
+
capability: "botGateway",
|
|
260
|
+
method: "PATCH",
|
|
261
|
+
idempotent: false,
|
|
262
|
+
operation: "botGateway.expertBindings.update",
|
|
263
|
+
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
264
|
+
schema: expertBindingSchema
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
async deleteExpertBinding(notebookId, bindingId, options) {
|
|
268
|
+
return call(context, {
|
|
269
|
+
callOptions: options,
|
|
270
|
+
capability: "botGateway",
|
|
271
|
+
method: "DELETE",
|
|
272
|
+
idempotent: false,
|
|
273
|
+
operation: "botGateway.expertBindings.delete",
|
|
274
|
+
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
275
|
+
schema: botDeleteSchema
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
async listGroupBindings(notebookId, input, options) {
|
|
279
|
+
return call(context, {
|
|
280
|
+
callOptions: options,
|
|
281
|
+
capability: "botGateway",
|
|
282
|
+
method: "GET",
|
|
283
|
+
idempotent: true,
|
|
284
|
+
operation: "botGateway.groupBindings.list",
|
|
285
|
+
path: listPath(notebookId, "group-bindings", input),
|
|
286
|
+
schema: groupBindingListSchema
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
async createGroupBinding(notebookId, input, options) {
|
|
290
|
+
const body = {
|
|
291
|
+
...groupFields(input),
|
|
292
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
293
|
+
conversation_id: requiredString(input?.conversationId, "conversationId")
|
|
294
|
+
};
|
|
295
|
+
return call(context, {
|
|
296
|
+
body,
|
|
297
|
+
callOptions: options,
|
|
298
|
+
capability: "botGateway",
|
|
299
|
+
method: "POST",
|
|
300
|
+
idempotent: false,
|
|
301
|
+
operation: "botGateway.groupBindings.create",
|
|
302
|
+
path: path(notebookId, "group-bindings"),
|
|
303
|
+
schema: groupBindingSchema
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
async updateGroupBinding(notebookId, bindingId, input, options) {
|
|
307
|
+
const body = patch(compactUndefined({
|
|
308
|
+
...groupFields(input),
|
|
309
|
+
notebook_id: optionalString(input?.notebookId, "notebookId")
|
|
310
|
+
}));
|
|
311
|
+
return call(context, {
|
|
312
|
+
body,
|
|
313
|
+
callOptions: options,
|
|
314
|
+
capability: "botGateway",
|
|
315
|
+
method: "PATCH",
|
|
316
|
+
idempotent: false,
|
|
317
|
+
operation: "botGateway.groupBindings.update",
|
|
318
|
+
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
319
|
+
schema: groupBindingSchema
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
async deleteGroupBinding(notebookId, bindingId, options) {
|
|
323
|
+
return call(context, {
|
|
324
|
+
callOptions: options,
|
|
325
|
+
capability: "botGateway",
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
idempotent: false,
|
|
328
|
+
operation: "botGateway.groupBindings.delete",
|
|
329
|
+
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
330
|
+
schema: botDeleteSchema
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
async publishDingTalk(notebookId, input, options) {
|
|
334
|
+
const body = compactUndefined({
|
|
335
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
336
|
+
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
337
|
+
instructions: optionalInstructions(input?.instructions)
|
|
338
|
+
});
|
|
339
|
+
return call(context, {
|
|
340
|
+
body,
|
|
341
|
+
callOptions: options,
|
|
342
|
+
capability: "botGateway",
|
|
343
|
+
method: "POST",
|
|
344
|
+
idempotent: false,
|
|
345
|
+
operation: "botGateway.dingTalk.publish",
|
|
346
|
+
path: path(notebookId, "dingtalk", "publish"),
|
|
347
|
+
schema: publishDingTalkSchema
|
|
348
|
+
});
|
|
349
|
+
},
|
|
350
|
+
async inviteDingTalkExpert(notebookId, input, options) {
|
|
351
|
+
const userId = optionalTrimmedString(input?.userId, "userId");
|
|
352
|
+
const email = optionalTrimmedString(input?.email, "email");
|
|
353
|
+
if (userId === void 0 && email === void 0) throw invalidArgument("provide userId or email", "input");
|
|
354
|
+
const body = compactUndefined({
|
|
355
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
356
|
+
user_id: userId,
|
|
357
|
+
email
|
|
358
|
+
});
|
|
359
|
+
return call(context, {
|
|
360
|
+
body,
|
|
361
|
+
callOptions: options,
|
|
362
|
+
capability: "botGateway",
|
|
363
|
+
method: "POST",
|
|
364
|
+
idempotent: false,
|
|
365
|
+
operation: "botGateway.dingTalk.inviteExpert",
|
|
366
|
+
path: path(notebookId, "dingtalk", "experts", "invite"),
|
|
367
|
+
schema: inviteDingTalkSchema
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
export { createBotGatewayOperations };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { S as cardSchema, a as invalidArgument, c as optionalRecord, d as pagination, g as stringList, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, u as optionalTrimmedString, x as cardListSchema, y as batchMutationResultSchema } from "./shared-BkQJzIZF.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../sdk/src/operations/compilation-results.ts
|
|
4
|
+
function linksBody(value, field) {
|
|
5
|
+
if (value === void 0) return void 0;
|
|
6
|
+
if (!Array.isArray(value)) throw invalidArgument(`${field} must be an array`, field);
|
|
7
|
+
return value.map((value, index) => {
|
|
8
|
+
const name = `${field}[${index}]`;
|
|
9
|
+
const link = optionalRecord(value, name);
|
|
10
|
+
const targetId = optionalTrimmedString(link?.targetId, `${name}.targetId`);
|
|
11
|
+
const targetRef = optionalTrimmedString(link?.targetRef, `${name}.targetRef`);
|
|
12
|
+
if (targetId === void 0 && targetRef === void 0) throw invalidArgument(`${name} requires targetId or targetRef`, name);
|
|
13
|
+
return compactUndefined({
|
|
14
|
+
description: optionalString(link?.description, `${name}.description`),
|
|
15
|
+
linkType: optionalTrimmedString(link?.linkType, `${name}.linkType`),
|
|
16
|
+
targetId,
|
|
17
|
+
targetRef
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function compilationResultBody(value) {
|
|
22
|
+
if (!Array.isArray(value) || value.length === 0) throw invalidArgument("cards must be a non-empty array", "cards");
|
|
23
|
+
return { cards: value.map((value, index) => {
|
|
24
|
+
const name = `cards[${index}]`;
|
|
25
|
+
const card = optionalRecord(value, name);
|
|
26
|
+
return compactUndefined({
|
|
27
|
+
cardType: optionalTrimmedString(card?.cardType, `${name}.cardType`),
|
|
28
|
+
content: requiredText(card?.content, `${name}.content`),
|
|
29
|
+
id: optionalTrimmedString(card?.id, `${name}.id`),
|
|
30
|
+
keywords: card?.keywords === void 0 ? void 0 : stringList(card.keywords, `${name}.keywords`),
|
|
31
|
+
links: linksBody(card?.links, `${name}.links`),
|
|
32
|
+
refId: optionalTrimmedString(card?.refId, `${name}.refId`),
|
|
33
|
+
title: requiredString(card?.title, `${name}.title`)
|
|
34
|
+
});
|
|
35
|
+
}) };
|
|
36
|
+
}
|
|
37
|
+
const saveCompilationResultSchema = z.object({
|
|
38
|
+
cards: z.array(z.object({
|
|
39
|
+
id: z.string().min(1),
|
|
40
|
+
refId: z.string().optional()
|
|
41
|
+
})).nullish().transform((cards) => cards ?? []),
|
|
42
|
+
failureCount: z.number().int().nonnegative(),
|
|
43
|
+
successCount: z.number().int().nonnegative()
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../sdk/src/operations/cards.ts
|
|
47
|
+
function createCardOperations(context) {
|
|
48
|
+
const listCards = async (notebookId, input = {}, options, featured = false) => {
|
|
49
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
50
|
+
const normalizedPage = pagination({
|
|
51
|
+
page: input.page ?? 1,
|
|
52
|
+
pageSize: input.pageSize ?? 20
|
|
53
|
+
});
|
|
54
|
+
const category = optionalTrimmedString(input.category, "category");
|
|
55
|
+
const query = optionalTrimmedString(input.query, "query");
|
|
56
|
+
const root = context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "cards");
|
|
57
|
+
const path = queryPath(root, [
|
|
58
|
+
["category", category],
|
|
59
|
+
["query", query],
|
|
60
|
+
["page", normalizedPage.page],
|
|
61
|
+
["page_size", normalizedPage.pageSize]
|
|
62
|
+
]);
|
|
63
|
+
return call(context, {
|
|
64
|
+
callOptions: options,
|
|
65
|
+
capability: featured ? "featuredNotebooks.read" : "cards.read",
|
|
66
|
+
idempotent: true,
|
|
67
|
+
method: "GET",
|
|
68
|
+
operation: featured ? "featuredCards.list" : "cards.list",
|
|
69
|
+
path,
|
|
70
|
+
schema: cardListSchema
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
async saveCompilationResult(notebookId, input, options) {
|
|
75
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
76
|
+
return call(context, {
|
|
77
|
+
body: compilationResultBody(input?.cards),
|
|
78
|
+
callOptions: options,
|
|
79
|
+
capability: "cards.saveResults",
|
|
80
|
+
idempotent: false,
|
|
81
|
+
method: "POST",
|
|
82
|
+
operation: "cards.saveCompilationResult",
|
|
83
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", "save-compilation-result"),
|
|
84
|
+
schema: saveCompilationResultSchema
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
async batchDeleteCards(notebookId, cardIds, options) {
|
|
88
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
89
|
+
const ids = stringList(cardIds, "cardIds", { min: 1 });
|
|
90
|
+
return call(context, {
|
|
91
|
+
body: { cardIds: ids },
|
|
92
|
+
callOptions: options,
|
|
93
|
+
capability: "cards.write",
|
|
94
|
+
idempotent: false,
|
|
95
|
+
method: "POST",
|
|
96
|
+
operation: "cards.batchDelete",
|
|
97
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", "batch-delete"),
|
|
98
|
+
schema: batchMutationResultSchema
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
async deleteCard(notebookId, cardId, options) {
|
|
102
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
103
|
+
const card = requiredString(cardId, "cardId");
|
|
104
|
+
return call(context, {
|
|
105
|
+
callOptions: options,
|
|
106
|
+
capability: "cards.write",
|
|
107
|
+
idempotent: false,
|
|
108
|
+
method: "DELETE",
|
|
109
|
+
operation: "cards.delete",
|
|
110
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
111
|
+
schema: batchMutationResultSchema
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
async getCard(notebookId, cardId, options) {
|
|
115
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
116
|
+
const card = requiredString(cardId, "cardId");
|
|
117
|
+
return call(context, {
|
|
118
|
+
callOptions: options,
|
|
119
|
+
capability: "cards.read",
|
|
120
|
+
idempotent: true,
|
|
121
|
+
method: "GET",
|
|
122
|
+
operation: "cards.get",
|
|
123
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
124
|
+
schema: cardSchema
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
listCards: (notebookId, input, options) => listCards(notebookId, input, options),
|
|
128
|
+
listFeaturedCards: (notebookId, input, options) => listCards(notebookId, input, options, true)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { createCardOperations };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { O as importProvidersSchema, _ as aliDingImportRunItemListSchema, a as invalidArgument, d as pagination, et as assertCapability, m as requiredString, n as call, p as queryPath, v as aliDingImportRunSchema } from "./shared-BkQJzIZF.js";
|
|
2
|
+
//#region ../sdk/src/operations/imports.ts
|
|
3
|
+
const aliDingHost = "alidocs.dingtalk.com";
|
|
4
|
+
const requestIdPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
5
|
+
/**
|
|
6
|
+
* A canonical AliDing URL identifies exactly one node or knowledge base. Share links, short links,
|
|
7
|
+
* query strings and fragments are aliases, so they are rejected rather than silently trimmed.
|
|
8
|
+
*/
|
|
9
|
+
function canonicalAliDingUrl(value, scope) {
|
|
10
|
+
const raw = requiredString(value, "url");
|
|
11
|
+
let url;
|
|
12
|
+
try {
|
|
13
|
+
url = new URL(raw);
|
|
14
|
+
} catch (cause) {
|
|
15
|
+
throw invalidArgument("url must be a canonical AliDing HTTPS URL", "url", { cause });
|
|
16
|
+
}
|
|
17
|
+
if (url.origin !== `https://${aliDingHost}`) throw invalidArgument(`url must be an https://${aliDingHost} address`, "url");
|
|
18
|
+
if (url.search.length > 0 || url.hash.length > 0 || url.username.length > 0 || url.password.length > 0) throw invalidArgument("url must not carry a query, fragment or credentials", "url");
|
|
19
|
+
const prefix = scope === "nodeSubtree" ? "/i/nodes/" : "/i/spaces/";
|
|
20
|
+
if (!url.pathname.startsWith(prefix) || url.pathname === prefix) throw invalidArgument(`url must be an AliDing ${prefix} address for this import scope`, "url");
|
|
21
|
+
return url.toString();
|
|
22
|
+
}
|
|
23
|
+
function importRunBody(input, scope) {
|
|
24
|
+
const requestId = requiredString(input?.requestId, "requestId");
|
|
25
|
+
if (!requestIdPattern.test(requestId.toLowerCase())) throw invalidArgument("requestId must be a UUID", "requestId");
|
|
26
|
+
return {
|
|
27
|
+
requestId,
|
|
28
|
+
url: canonicalAliDingUrl(input?.url, scope)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function createImportOperations(context) {
|
|
32
|
+
return {
|
|
33
|
+
async getAliDingImportRun(notebookId, runId, options) {
|
|
34
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
35
|
+
const run = requiredString(runId, "runId");
|
|
36
|
+
assertCapability(context.profile, "imports.aliDing", "imports.aliDing.getRun");
|
|
37
|
+
return call(context, {
|
|
38
|
+
callOptions: options,
|
|
39
|
+
capability: "imports.aliDing",
|
|
40
|
+
idempotent: true,
|
|
41
|
+
method: "GET",
|
|
42
|
+
operation: "imports.aliDing.getRun",
|
|
43
|
+
path: context.profile.mindPath("notebooks", notebook, "aliding", "import-runs", run),
|
|
44
|
+
schema: aliDingImportRunSchema
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
async listAliDingImportRunItems(notebookId, runId, input = {}, options) {
|
|
48
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
49
|
+
const run = requiredString(runId, "runId");
|
|
50
|
+
const normalizedPage = pagination(input);
|
|
51
|
+
assertCapability(context.profile, "imports.aliDing", "imports.aliDing.listRunItems");
|
|
52
|
+
const base = context.profile.mindPath("notebooks", notebook, "aliding", "import-runs", run, "items");
|
|
53
|
+
return call(context, {
|
|
54
|
+
callOptions: options,
|
|
55
|
+
capability: "imports.aliDing",
|
|
56
|
+
idempotent: true,
|
|
57
|
+
method: "GET",
|
|
58
|
+
operation: "imports.aliDing.listRunItems",
|
|
59
|
+
path: queryPath(base, [
|
|
60
|
+
["pagination.currentPage", normalizedPage.page],
|
|
61
|
+
["pagination.pageSize", normalizedPage.pageSize],
|
|
62
|
+
["status", wireItemStatus(input.status)],
|
|
63
|
+
["contentStatus", wireContentStatus(input.contentStatus)],
|
|
64
|
+
["descendantsStatus", wireDescendantsStatus(input.descendantsStatus)]
|
|
65
|
+
]),
|
|
66
|
+
schema: aliDingImportRunItemListSchema
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
async listImportProviders(options) {
|
|
70
|
+
assertCapability(context.profile, "imports.discover", "imports.discover");
|
|
71
|
+
return call(context, {
|
|
72
|
+
callOptions: options,
|
|
73
|
+
capability: "imports.discover",
|
|
74
|
+
idempotent: true,
|
|
75
|
+
method: "GET",
|
|
76
|
+
operation: "imports.discover",
|
|
77
|
+
path: context.profile.mindPath("import-sources"),
|
|
78
|
+
schema: importProvidersSchema
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async startAliDingKnowledgeBaseImport(notebookId, input, options) {
|
|
82
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
83
|
+
const body = importRunBody(input, "knowledgeBase");
|
|
84
|
+
assertCapability(context.profile, "imports.aliDing", "imports.aliDing.createKnowledgeBaseRun");
|
|
85
|
+
return call(context, {
|
|
86
|
+
body,
|
|
87
|
+
callOptions: options,
|
|
88
|
+
capability: "imports.aliDing",
|
|
89
|
+
idempotent: false,
|
|
90
|
+
method: "POST",
|
|
91
|
+
operation: "imports.aliDing.createKnowledgeBaseRun",
|
|
92
|
+
path: context.profile.mindPath("notebooks", notebook, "aliding", "knowledge-base-import-runs"),
|
|
93
|
+
schema: aliDingImportRunSchema
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
async startAliDingNodeSubtreeImport(notebookId, input, options) {
|
|
97
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
98
|
+
const body = importRunBody(input, "nodeSubtree");
|
|
99
|
+
assertCapability(context.profile, "imports.aliDing", "imports.aliDing.createNodeSubtreeRun");
|
|
100
|
+
return call(context, {
|
|
101
|
+
body,
|
|
102
|
+
callOptions: options,
|
|
103
|
+
capability: "imports.aliDing",
|
|
104
|
+
idempotent: false,
|
|
105
|
+
method: "POST",
|
|
106
|
+
operation: "imports.aliDing.createNodeSubtreeRun",
|
|
107
|
+
path: context.profile.mindPath("notebooks", notebook, "aliding", "node-subtree-import-runs"),
|
|
108
|
+
schema: aliDingImportRunSchema
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function wireItemStatus(value) {
|
|
114
|
+
return value === void 0 ? void 0 : `ALI_DING_IMPORT_ITEM_STATUS_${screamingCase(value)}`;
|
|
115
|
+
}
|
|
116
|
+
function wireContentStatus(value) {
|
|
117
|
+
return value === void 0 ? void 0 : `ALI_DING_IMPORT_CONTENT_STATUS_${screamingCase(value)}`;
|
|
118
|
+
}
|
|
119
|
+
function wireDescendantsStatus(value) {
|
|
120
|
+
return value === void 0 ? void 0 : `ALI_DING_IMPORT_DESCENDANTS_STATUS_${screamingCase(value)}`;
|
|
121
|
+
}
|
|
122
|
+
function screamingCase(value) {
|
|
123
|
+
return value.replace(/([a-z0-9])([A-Z])/gu, "$1_$2").toUpperCase();
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { createImportOperations };
|