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