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