@qoder-ai/qmind-cli 2.0.0 → 3.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.
@@ -0,0 +1,312 @@
1
+ import { J as voidResponseSchema, a as invalidArgument, c as optionalRecord, l as optionalString, m as requiredString, n as call, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch } from "./shared-DwycozMA.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 notebookMemberSchema = z.object({
11
+ addedBy: z.string().default(""),
12
+ createdAt: z.string().default(""),
13
+ email: z.string().optional(),
14
+ id: z.string().min(1),
15
+ notebookId: z.string().default(""),
16
+ permission: memberPermissionSchema,
17
+ updatedAt: z.string().default(""),
18
+ userId: z.string().default("")
19
+ });
20
+ const notebookMemberListSchema = z.object({ members: z.array(notebookMemberSchema).nullish().transform((members) => members ?? []) });
21
+ const scheduledTaskSceneSchema = z.enum([
22
+ "compilation",
23
+ "condensation",
24
+ "lint",
25
+ "source_refresh"
26
+ ]);
27
+ const scheduledTaskSchema = z.object({
28
+ config: z.record(z.string(), z.unknown()).default({}),
29
+ createdAt: z.string().default(""),
30
+ enabled: z.boolean().default(true),
31
+ id: z.string().min(1),
32
+ lastRunAt: z.string().default(""),
33
+ nextRunAt: z.string().default(""),
34
+ notebookId: z.string().default(""),
35
+ sceneType: scheduledTaskSceneSchema,
36
+ schedule: z.string().default(""),
37
+ updatedAt: z.string().default(""),
38
+ userId: z.string().default("")
39
+ });
40
+ const scheduledTaskListSchema = z.object({ tasks: z.array(scheduledTaskSchema).nullish().transform((tasks) => tasks ?? []) });
41
+ const compilationRunSchema = z.object({
42
+ compiledSourceCount: z.number().int().nonnegative().default(0),
43
+ createdAt: z.string().default(""),
44
+ finishedAt: z.string().default(""),
45
+ mode: z.enum([
46
+ "FULL",
47
+ "INCREMENTAL",
48
+ "REBUILD"
49
+ ]),
50
+ percent: z.number().min(0).max(100).default(0),
51
+ publishedCardCount: z.number().int().nonnegative().default(0),
52
+ runId: z.string().min(1),
53
+ stage: z.string().optional(),
54
+ startedAt: z.string().default(""),
55
+ status: z.enum([
56
+ "PENDING",
57
+ "RUNNING",
58
+ "SUCCESS",
59
+ "PARTIAL",
60
+ "FAILED",
61
+ "CANCELED"
62
+ ]),
63
+ templateId: z.string().default(""),
64
+ templateVersion: z.string().default(""),
65
+ trigger: z.enum([
66
+ "MANUAL",
67
+ "AUTO",
68
+ "SCHEDULED"
69
+ ])
70
+ });
71
+ const compilationSettingsSchema = z.object({
72
+ additionalPrompt: z.string().optional(),
73
+ autoCompile: z.object({
74
+ debounceMinutes: z.union([z.literal(1), z.literal(30)]),
75
+ enabled: z.boolean()
76
+ }),
77
+ customPrompt: z.string().optional(),
78
+ customPromptConfigured: z.boolean().default(false),
79
+ effectiveTemplateVersion: z.string().default(""),
80
+ requiresRebuild: z.boolean().default(false),
81
+ selectedTemplateId: z.string().default(""),
82
+ templates: z.array(z.record(z.string(), z.unknown())).optional()
83
+ });
84
+ const compilationSettingsResponseSchema = z.object({ compilation: compilationSettingsSchema });
85
+ const compilationRunResponseSchema = compilationRunSchema;
86
+ const compilationStatusSchema = z.object({
87
+ activeRun: compilationRunSchema.optional(),
88
+ displayState: z.enum([
89
+ "UNCOMPILED",
90
+ "COMPILING",
91
+ "PARTIALLY_STALE",
92
+ "FAILED",
93
+ "COMPILED"
94
+ ]),
95
+ effectiveEngine: z.string().default(""),
96
+ incrementalReady: z.boolean().default(false),
97
+ lastFailure: z.record(z.string(), z.unknown()).optional(),
98
+ lastSuccess: compilationRunSchema.optional(),
99
+ nextAutoCompileAt: z.string().default(""),
100
+ pendingChangeCount: z.number().int().nonnegative().default(0),
101
+ requiresRebuild: z.boolean().default(false)
102
+ });
103
+ //#endregion
104
+ //#region ../sdk/src/operations/management.ts
105
+ function memberPermission(value, field) {
106
+ if (value === "manage" || value === "edit" || value === "view") return value;
107
+ throw invalidArgument(`${field} must be manage, edit, or view`, field);
108
+ }
109
+ function scheduledTaskScene(value, field) {
110
+ if (value === "compilation" || value === "condensation" || value === "lint" || value === "source_refresh") return value;
111
+ throw invalidArgument(`${field} must be compilation, condensation, lint, or source_refresh`, field);
112
+ }
113
+ function compilationMode(value, field) {
114
+ if (value === "FULL" || value === "INCREMENTAL" || value === "REBUILD") return value;
115
+ throw invalidArgument(`${field} must be FULL, INCREMENTAL, or REBUILD`, field);
116
+ }
117
+ function autoCompilePatch(value) {
118
+ const record = optionalRecord(value, "compilation.autoCompile");
119
+ if (record === void 0) return void 0;
120
+ const enabled = optionalBoolean(record.enabled, "compilation.autoCompile.enabled");
121
+ const debounceMinutes = record.debounceMinutes;
122
+ if (debounceMinutes !== void 0 && debounceMinutes !== 1 && debounceMinutes !== 30) throw invalidArgument("compilation.autoCompile.debounceMinutes must be 1 or 30", "compilation.autoCompile.debounceMinutes");
123
+ const patch = compactUndefined({
124
+ debounceMinutes,
125
+ enabled
126
+ });
127
+ assertNonEmptyPatch(patch, "compilation.autoCompile");
128
+ return patch;
129
+ }
130
+ function createManagementOperations(context) {
131
+ return {
132
+ async addMember(notebookId, input, options) {
133
+ const notebook = requiredString(notebookId, "notebookId");
134
+ return call(context, {
135
+ body: {
136
+ email: requiredString(input?.email, "email"),
137
+ permission: memberPermission(input?.permission, "permission")
138
+ },
139
+ callOptions: options,
140
+ capability: "members",
141
+ idempotent: false,
142
+ method: "POST",
143
+ operation: "members.add",
144
+ path: context.profile.apiPath("notebooks", notebook, "members"),
145
+ schema: notebookMemberSchema
146
+ });
147
+ },
148
+ async createScheduledTask(notebookId, input, options) {
149
+ const notebook = requiredString(notebookId, "notebookId");
150
+ return call(context, {
151
+ body: compactUndefined({
152
+ config: optionalRecord(input?.config, "config"),
153
+ sceneType: scheduledTaskScene(input?.sceneType, "sceneType"),
154
+ schedule: requiredString(input?.schedule, "schedule")
155
+ }),
156
+ callOptions: options,
157
+ capability: "scheduledTasks",
158
+ idempotent: false,
159
+ method: "POST",
160
+ operation: "scheduledTasks.create",
161
+ path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks"),
162
+ schema: scheduledTaskSchema
163
+ });
164
+ },
165
+ async deleteScheduledTask(notebookId, taskId, options) {
166
+ const notebook = requiredString(notebookId, "notebookId");
167
+ const task = requiredString(taskId, "taskId");
168
+ return call(context, {
169
+ callOptions: options,
170
+ capability: "scheduledTasks",
171
+ idempotent: false,
172
+ method: "DELETE",
173
+ operation: "scheduledTasks.delete",
174
+ path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks", task),
175
+ schema: voidResponseSchema
176
+ });
177
+ },
178
+ async getCompilationSettings(notebookId, options) {
179
+ const notebook = requiredString(notebookId, "notebookId");
180
+ return call(context, {
181
+ callOptions: options,
182
+ capability: "compilation",
183
+ idempotent: true,
184
+ method: "GET",
185
+ operation: "compilation.settings.get",
186
+ path: context.profile.apiPath("notebooks", notebook, "compilation-settings"),
187
+ schema: compilationSettingsResponseSchema
188
+ });
189
+ },
190
+ async getCompilationStatus(notebookId, options) {
191
+ const notebook = requiredString(notebookId, "notebookId");
192
+ return call(context, {
193
+ callOptions: options,
194
+ capability: "compilation",
195
+ idempotent: true,
196
+ method: "GET",
197
+ operation: "compilation.status.get",
198
+ path: context.profile.apiPath("notebooks", notebook, "compilation-status"),
199
+ schema: compilationStatusSchema
200
+ });
201
+ },
202
+ async listMembers(notebookId, options) {
203
+ const notebook = requiredString(notebookId, "notebookId");
204
+ return call(context, {
205
+ callOptions: options,
206
+ capability: "members",
207
+ idempotent: true,
208
+ method: "GET",
209
+ operation: "members.list",
210
+ path: context.profile.apiPath("notebooks", notebook, "members"),
211
+ schema: notebookMemberListSchema
212
+ });
213
+ },
214
+ async listScheduledTasks(notebookId, options) {
215
+ const notebook = requiredString(notebookId, "notebookId");
216
+ return call(context, {
217
+ callOptions: options,
218
+ capability: "scheduledTasks",
219
+ idempotent: true,
220
+ method: "GET",
221
+ operation: "scheduledTasks.list",
222
+ path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks"),
223
+ schema: scheduledTaskListSchema
224
+ });
225
+ },
226
+ async removeMember(notebookId, memberId, options) {
227
+ const notebook = requiredString(notebookId, "notebookId");
228
+ const member = requiredString(memberId, "memberId");
229
+ return call(context, {
230
+ callOptions: options,
231
+ capability: "members",
232
+ idempotent: false,
233
+ method: "DELETE",
234
+ operation: "members.remove",
235
+ path: context.profile.apiPath("notebooks", notebook, "members", member),
236
+ schema: voidResponseSchema
237
+ });
238
+ },
239
+ async saveCompilationSettings(notebookId, input, options) {
240
+ const notebook = requiredString(notebookId, "notebookId");
241
+ const compilation = optionalRecord(input?.compilation, "compilation");
242
+ if (compilation === void 0) throw invalidArgument("compilation must be an object", "compilation");
243
+ const patch = compactUndefined({
244
+ additionalPrompt: optionalString(compilation.additionalPrompt, "compilation.additionalPrompt"),
245
+ autoCompile: autoCompilePatch(compilation.autoCompile),
246
+ clearCustomPrompt: optionalBoolean(compilation.clearCustomPrompt, "compilation.clearCustomPrompt"),
247
+ customPrompt: optionalString(compilation.customPrompt, "compilation.customPrompt"),
248
+ templateId: optionalString(compilation.templateId, "compilation.templateId")
249
+ });
250
+ assertNonEmptyPatch(patch, "compilation");
251
+ return call(context, {
252
+ body: { compilation: patch },
253
+ callOptions: options,
254
+ capability: "compilation",
255
+ idempotent: false,
256
+ method: "PATCH",
257
+ operation: "compilation.settings.save",
258
+ path: context.profile.apiPath("notebooks", notebook, "compilation-settings"),
259
+ schema: compilationSettingsResponseSchema
260
+ });
261
+ },
262
+ async startCompilation(notebookId, input, options) {
263
+ const notebook = requiredString(notebookId, "notebookId");
264
+ return call(context, {
265
+ body: { mode: compilationMode(input?.mode, "mode") },
266
+ callOptions: options,
267
+ capability: "compilation",
268
+ idempotent: false,
269
+ method: "POST",
270
+ operation: "compilation.start",
271
+ path: context.profile.apiPath("notebooks", notebook, "compilations"),
272
+ schema: compilationRunResponseSchema
273
+ });
274
+ },
275
+ async updateMemberPermission(notebookId, memberId, input, options) {
276
+ const notebook = requiredString(notebookId, "notebookId");
277
+ const member = requiredString(memberId, "memberId");
278
+ return call(context, {
279
+ body: { permission: memberPermission(input?.permission, "permission") },
280
+ callOptions: options,
281
+ capability: "members",
282
+ idempotent: false,
283
+ method: "PUT",
284
+ operation: "members.update",
285
+ path: context.profile.apiPath("notebooks", notebook, "members", member),
286
+ schema: notebookMemberSchema
287
+ });
288
+ },
289
+ async updateScheduledTask(notebookId, taskId, input, options) {
290
+ const notebook = requiredString(notebookId, "notebookId");
291
+ const task = requiredString(taskId, "taskId");
292
+ const patch = compactUndefined({
293
+ config: optionalRecord(input?.config, "config"),
294
+ enabled: optionalBoolean(input?.enabled, "enabled"),
295
+ schedule: optionalString(input?.schedule, "schedule")
296
+ });
297
+ assertNonEmptyPatch(patch, "scheduledTask");
298
+ return call(context, {
299
+ body: patch,
300
+ callOptions: options,
301
+ capability: "scheduledTasks",
302
+ idempotent: false,
303
+ method: "PUT",
304
+ operation: "scheduledTasks.update",
305
+ path: context.profile.apiPath("notebooks", notebook, "scheduled-tasks", task),
306
+ schema: scheduledTaskSchema
307
+ });
308
+ }
309
+ };
310
+ }
311
+ //#endregion
312
+ export { createManagementOperations };