@qoder-ai/qmind-cli 4.3.0 → 5.0.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.
@@ -1,387 +0,0 @@
1
- import { I as voidResponseSchema } from "./schemas-DG7vaJMR.js";
2
- import { a as invalidArgument, c as optionalRecord, f as positiveInteger, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch } from "./shared-CbvrtGyv.js";
3
- import { z } from "zod";
4
- //#region ../sdk/src/operations/management-schemas.ts
5
- const memberPermissionSchema = z.enum([
6
- "owner",
7
- "manage",
8
- "edit",
9
- "view"
10
- ]);
11
- const resolvedMemberCandidateSchema = z.object({ candidate: z.object({
12
- userId: z.string().min(1),
13
- name: z.string(),
14
- email: z.string(),
15
- avatar: z.string().optional(),
16
- alreadyMember: z.boolean(),
17
- matchedBy: z.enum(["email", "userId"])
18
- }).nullable() });
19
- const notebookMemberSchema = z.object({
20
- addedBy: z.string().default(""),
21
- createdAt: z.string().default(""),
22
- email: z.string().optional(),
23
- id: z.string().min(1),
24
- notebookId: z.string().default(""),
25
- permission: memberPermissionSchema,
26
- updatedAt: z.string().default(""),
27
- userId: z.string().default("")
28
- });
29
- const notebookMemberListSchema = z.object({ members: z.array(notebookMemberSchema).nullish().transform((members) => members ?? []) });
30
- const memberCandidateListSchema = z.object({
31
- candidates: z.array(z.object({
32
- userId: z.string().min(1),
33
- name: z.string(),
34
- email: z.string(),
35
- avatar: z.string().optional(),
36
- alreadyMember: z.boolean(),
37
- matchedBy: z.enum(["email", "name"])
38
- })).nullish().transform((candidates) => candidates ?? []),
39
- currentPage: z.number().int().positive(),
40
- pageSize: z.number().int().positive().max(50),
41
- totalSize: z.number().int().nonnegative()
42
- });
43
- const scheduledTaskSceneSchema = z.enum([
44
- "compilation",
45
- "condensation",
46
- "lint",
47
- "source_refresh",
48
- "source_binding_sync"
49
- ]);
50
- const scheduledTaskWireSchema = z.object({
51
- config: z.record(z.string(), z.unknown()).default({}),
52
- createdAt: z.string().default(""),
53
- enabled: z.boolean().default(true),
54
- id: z.string().min(1),
55
- lastRunAt: z.string().default(""),
56
- nextRunAt: z.string().default(""),
57
- notebookId: z.string().default(""),
58
- sceneType: scheduledTaskSceneSchema,
59
- schedule: z.string().default(""),
60
- updatedAt: z.string().default(""),
61
- userId: z.string().default("")
62
- });
63
- const scheduledTaskSchema = scheduledTaskWireSchema;
64
- const confirmedScheduledTaskSchema = scheduledTaskWireSchema.extend({
65
- config: z.record(z.string(), z.unknown()).nullish().transform((config) => config ?? {}),
66
- notebookId: z.string().min(1),
67
- schedule: z.string().min(1),
68
- enabled: z.boolean()
69
- });
70
- const sashScheduledTaskDeletionSchema = z.union([z.object({}).strict(), z.undefined()]).transform(() => void 0);
71
- const dashboardScheduledTaskDeletionSchema = z.union([z.object({ status: z.literal("ok") }).strict(), z.undefined()]).transform(() => void 0);
72
- const sashScheduledTaskListSchema = z.object({ tasks: z.array(confirmedScheduledTaskSchema).nullable().transform((tasks) => tasks ?? []) });
73
- const scheduledTaskListSchema = z.object({ tasks: z.array(scheduledTaskSchema).nullish().transform((tasks) => tasks ?? []) });
74
- const compilationRunSchema = z.object({
75
- compiledSourceCount: z.number().int().nonnegative().default(0),
76
- createdAt: z.string().default(""),
77
- finishedAt: z.string().default(""),
78
- mode: z.enum([
79
- "FULL",
80
- "INCREMENTAL",
81
- "REBUILD"
82
- ]),
83
- percent: z.number().min(0).max(100).default(0),
84
- runId: z.string().min(1),
85
- stage: z.string().optional(),
86
- startedAt: z.string().default(""),
87
- status: z.enum([
88
- "PENDING",
89
- "RUNNING",
90
- "SUCCESS",
91
- "PARTIAL",
92
- "FAILED",
93
- "CANCELED"
94
- ]),
95
- templateId: z.string().default(""),
96
- templateVersion: z.string().default(""),
97
- trigger: z.enum([
98
- "MANUAL",
99
- "AUTO",
100
- "SCHEDULED"
101
- ])
102
- });
103
- const compilationSettingsSchema = z.object({
104
- additionalPrompt: z.string().optional(),
105
- autoCompile: z.object({
106
- debounceMinutes: z.union([z.literal(1), z.literal(30)]),
107
- enabled: z.boolean()
108
- }),
109
- customPrompt: z.string().optional(),
110
- customPromptConfigured: z.boolean().default(false),
111
- effectiveTemplateVersion: z.string().default(""),
112
- requiresRebuild: z.boolean().default(false),
113
- selectedTemplateId: z.string().default(""),
114
- templates: z.array(z.record(z.string(), z.unknown())).optional()
115
- });
116
- const compilationSettingsResponseSchema = z.object({ compilation: compilationSettingsSchema });
117
- const compilationRunResponseSchema = compilationRunSchema;
118
- const compilationStatusSchema = z.object({
119
- activeRun: compilationRunSchema.optional(),
120
- displayState: z.enum([
121
- "UNCOMPILED",
122
- "COMPILING",
123
- "PARTIALLY_STALE",
124
- "FAILED",
125
- "COMPILED"
126
- ]),
127
- effectiveEngine: z.string().default(""),
128
- incrementalReady: z.boolean().default(false),
129
- lastFailure: z.record(z.string(), z.unknown()).optional(),
130
- lastSuccess: compilationRunSchema.optional(),
131
- nextAutoCompileAt: z.string().default(""),
132
- pendingChangeCount: z.number().int().nonnegative().default(0),
133
- requiresRebuild: z.boolean().default(false)
134
- });
135
- //#endregion
136
- //#region ../sdk/src/operations/management.ts
137
- function memberPermission(value, field) {
138
- if (value === "manage" || value === "edit" || value === "view") return value;
139
- throw invalidArgument(`${field} must be manage, edit, or view`, field);
140
- }
141
- function scheduledTaskScene(value, field) {
142
- if (value === "compilation" || value === "condensation" || value === "lint" || value === "source_refresh" || value === "source_binding_sync") return value;
143
- throw invalidArgument(`${field} must be compilation, condensation, lint, source_refresh, or source_binding_sync`, field);
144
- }
145
- function compilationMode(value, field) {
146
- if (value === "FULL" || value === "INCREMENTAL" || value === "REBUILD") return value;
147
- throw invalidArgument(`${field} must be FULL, INCREMENTAL, or REBUILD`, field);
148
- }
149
- function autoCompilePatch(value) {
150
- const record = optionalRecord(value, "compilation.autoCompile");
151
- if (record === void 0) return void 0;
152
- const enabled = optionalBoolean(record.enabled, "compilation.autoCompile.enabled");
153
- const debounceMinutes = record.debounceMinutes;
154
- if (debounceMinutes !== void 0 && debounceMinutes !== 1 && debounceMinutes !== 30) throw invalidArgument("compilation.autoCompile.debounceMinutes must be 1 or 30", "compilation.autoCompile.debounceMinutes");
155
- const patch = compactUndefined({
156
- debounceMinutes,
157
- enabled
158
- });
159
- assertNonEmptyPatch(patch, "compilation.autoCompile");
160
- return patch;
161
- }
162
- function createManagementOperations(context) {
163
- return {
164
- async resolveMemberCandidate(notebookId, input, options) {
165
- const notebook = requiredString(notebookId, "notebookId");
166
- const hasUserId = input?.userId !== void 0;
167
- if (hasUserId === (input?.email !== void 0)) throw invalidArgument("exactly one of email or userId is required", "member");
168
- const value = requiredString(hasUserId ? input.userId : input.email, hasUserId ? "userId" : "email");
169
- if (hasUserId ? !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(value) : !/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(value)) throw invalidArgument("a complete email or UUID is required", hasUserId ? "userId" : "email");
170
- return call(context, {
171
- body: hasUserId ? { userId: value } : { email: value },
172
- callOptions: options,
173
- capability: "members.resolve",
174
- idempotent: true,
175
- method: "POST",
176
- operation: "members.resolve",
177
- path: context.profile.apiPath("notebooks", notebook, "member-candidates", "resolve"),
178
- schema: resolvedMemberCandidateSchema
179
- });
180
- },
181
- async addMember(notebookId, input, options) {
182
- const notebook = requiredString(notebookId, "notebookId");
183
- const hasUserId = input?.userId !== void 0;
184
- if (hasUserId === (input?.email !== void 0)) throw invalidArgument("exactly one of email or userId is required", "member");
185
- const identity = hasUserId ? { userId: requiredString(input.userId, "userId") } : { email: requiredString(input.email, "email") };
186
- return call(context, {
187
- body: {
188
- ...identity,
189
- permission: memberPermission(input?.permission, "permission")
190
- },
191
- callOptions: options,
192
- capability: "members",
193
- idempotent: false,
194
- method: "POST",
195
- operation: "members.add",
196
- path: context.profile.apiPath("notebooks", notebook, "members"),
197
- schema: notebookMemberSchema
198
- });
199
- },
200
- async searchMemberCandidates(input, options) {
201
- const notebook = requiredString(input?.notebookId, "notebookId");
202
- const query = requiredString(input?.query, "query");
203
- if (Array.from(query).length > 100) throw invalidArgument("query must contain at most 100 Unicode characters", "query");
204
- const page = positiveInteger(input?.page, "page") ?? 1;
205
- const pageSize = positiveInteger(input?.pageSize, "pageSize") ?? 20;
206
- if (page > 2147483647) throw invalidArgument("page must not exceed 2147483647", "page");
207
- if (pageSize > 50) throw invalidArgument("pageSize must not exceed 50", "pageSize");
208
- if ((page - 1) * pageSize > 2147483647) throw invalidArgument("pagination offset exceeds the supported range", "page");
209
- return call(context, {
210
- callOptions: options,
211
- capability: "members.search",
212
- idempotent: true,
213
- method: "GET",
214
- operation: "members.search",
215
- path: queryPath(context.profile.apiPath("notebooks", notebook, "member-candidates"), [
216
- ["query", query],
217
- ["page", page],
218
- ["page_size", pageSize]
219
- ]),
220
- schema: memberCandidateListSchema
221
- });
222
- },
223
- async createScheduledTask(notebookId, input, options) {
224
- const notebook = requiredString(notebookId, "notebookId");
225
- return call(context, {
226
- body: compactUndefined({
227
- config: optionalRecord(input?.config, "config"),
228
- sceneType: scheduledTaskScene(input?.sceneType, "sceneType"),
229
- schedule: requiredString(input?.schedule, "schedule")
230
- }),
231
- callOptions: options,
232
- capability: "scheduledTasks",
233
- idempotent: false,
234
- method: "POST",
235
- operation: "scheduledTasks.create",
236
- path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks"),
237
- schema: confirmedScheduledTaskSchema
238
- });
239
- },
240
- async deleteScheduledTask(notebookId, taskId, options) {
241
- const notebook = requiredString(notebookId, "notebookId");
242
- const task = requiredString(taskId, "taskId");
243
- return call(context, {
244
- callOptions: options,
245
- capability: "scheduledTasks",
246
- idempotent: false,
247
- method: "DELETE",
248
- operation: "scheduledTasks.delete",
249
- path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks", task),
250
- schema: context.profile.access === "sash" ? sashScheduledTaskDeletionSchema : dashboardScheduledTaskDeletionSchema
251
- });
252
- },
253
- async getCompilationSettings(notebookId, options) {
254
- const notebook = requiredString(notebookId, "notebookId");
255
- return call(context, {
256
- callOptions: options,
257
- capability: "compilation",
258
- idempotent: true,
259
- method: "GET",
260
- operation: "compilation.settings.get",
261
- path: context.profile.apiPath("notebooks", notebook, "compilation-settings"),
262
- schema: compilationSettingsResponseSchema
263
- });
264
- },
265
- async getCompilationStatus(notebookId, options) {
266
- const notebook = requiredString(notebookId, "notebookId");
267
- return call(context, {
268
- callOptions: options,
269
- capability: "compilation",
270
- idempotent: true,
271
- method: "GET",
272
- operation: "compilation.status.get",
273
- path: context.profile.apiPath("notebooks", notebook, "compilation-status"),
274
- schema: compilationStatusSchema
275
- });
276
- },
277
- async listMembers(notebookId, options) {
278
- const notebook = requiredString(notebookId, "notebookId");
279
- return call(context, {
280
- callOptions: options,
281
- capability: "members",
282
- idempotent: true,
283
- method: "GET",
284
- operation: "members.list",
285
- path: context.profile.apiPath("notebooks", notebook, "members"),
286
- schema: notebookMemberListSchema
287
- });
288
- },
289
- async listScheduledTasks(notebookId, options) {
290
- const notebook = requiredString(notebookId, "notebookId");
291
- return call(context, {
292
- callOptions: options,
293
- capability: "scheduledTasks",
294
- idempotent: true,
295
- method: "GET",
296
- operation: "scheduledTasks.list",
297
- path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks"),
298
- schema: context.profile.access === "sash" ? sashScheduledTaskListSchema : scheduledTaskListSchema
299
- });
300
- },
301
- async removeMember(notebookId, memberId, options) {
302
- const notebook = requiredString(notebookId, "notebookId");
303
- const member = requiredString(memberId, "memberId");
304
- return call(context, {
305
- callOptions: options,
306
- capability: "members",
307
- idempotent: false,
308
- method: "DELETE",
309
- operation: "members.remove",
310
- path: context.profile.apiPath("notebooks", notebook, "members", member),
311
- schema: voidResponseSchema
312
- });
313
- },
314
- async saveCompilationSettings(notebookId, input, options) {
315
- const notebook = requiredString(notebookId, "notebookId");
316
- const compilation = optionalRecord(input?.compilation, "compilation");
317
- if (compilation === void 0) throw invalidArgument("compilation must be an object", "compilation");
318
- const patch = compactUndefined({
319
- additionalPrompt: optionalString(compilation.additionalPrompt, "compilation.additionalPrompt"),
320
- autoCompile: autoCompilePatch(compilation.autoCompile),
321
- clearCustomPrompt: optionalBoolean(compilation.clearCustomPrompt, "compilation.clearCustomPrompt"),
322
- customPrompt: optionalString(compilation.customPrompt, "compilation.customPrompt"),
323
- templateId: optionalString(compilation.templateId, "compilation.templateId")
324
- });
325
- assertNonEmptyPatch(patch, "compilation");
326
- return call(context, {
327
- body: { compilation: patch },
328
- callOptions: options,
329
- capability: "compilation",
330
- idempotent: false,
331
- method: "PATCH",
332
- operation: "compilation.settings.save",
333
- path: context.profile.apiPath("notebooks", notebook, "compilation-settings"),
334
- schema: compilationSettingsResponseSchema
335
- });
336
- },
337
- async startCompilation(notebookId, input, options) {
338
- const notebook = requiredString(notebookId, "notebookId");
339
- return call(context, {
340
- body: { mode: compilationMode(input?.mode, "mode") },
341
- callOptions: options,
342
- capability: "compilation",
343
- idempotent: false,
344
- method: "POST",
345
- operation: "compilation.start",
346
- path: context.profile.apiPath("notebooks", notebook, "compilations"),
347
- schema: compilationRunResponseSchema
348
- });
349
- },
350
- async updateMemberPermission(notebookId, memberId, input, options) {
351
- const notebook = requiredString(notebookId, "notebookId");
352
- const member = requiredString(memberId, "memberId");
353
- return call(context, {
354
- body: { permission: memberPermission(input?.permission, "permission") },
355
- callOptions: options,
356
- capability: "members",
357
- idempotent: false,
358
- method: "PUT",
359
- operation: "members.update",
360
- path: context.profile.apiPath("notebooks", notebook, "members", member),
361
- schema: notebookMemberSchema
362
- });
363
- },
364
- async updateScheduledTask(notebookId, taskId, input, options) {
365
- const notebook = requiredString(notebookId, "notebookId");
366
- const task = requiredString(taskId, "taskId");
367
- const patch = compactUndefined({
368
- config: optionalRecord(input?.config, "config"),
369
- enabled: optionalBoolean(input?.enabled, "enabled"),
370
- schedule: optionalString(input?.schedule, "schedule")
371
- });
372
- assertNonEmptyPatch(patch, "scheduledTask");
373
- return call(context, {
374
- body: patch,
375
- callOptions: options,
376
- capability: "scheduledTasks",
377
- idempotent: false,
378
- method: "PUT",
379
- operation: "scheduledTasks.update",
380
- path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks", task),
381
- schema: confirmedScheduledTaskSchema
382
- });
383
- }
384
- };
385
- }
386
- //#endregion
387
- export { createManagementOperations };