@imenam/mcp-organizer 1.0.40 → 1.0.42
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/README.md +4 -1
- package/dist/shared/schemas/agent-api.schema.d.ts +3 -0
- package/dist/shared/schemas/api.schema.d.ts +60 -0
- package/dist/shared/schemas/api.schema.js +32 -2
- package/dist/shared/schemas/entities.schema.d.ts +22 -0
- package/dist/shared/schemas/entities.schema.js +18 -0
- package/dist/shared/schemas/enums.schema.d.ts +2 -1
- package/dist/shared/schemas/enums.schema.js +1 -0
- package/dist/shared/schemas/tasks-api.schema.d.ts +1 -0
- package/dist/src/core/migrations.js +22 -0
- package/dist/src/core/space-categories.d.ts +20 -0
- package/dist/src/core/space-categories.js +98 -0
- package/dist/src/core/spaces.js +17 -7
- package/dist/src/core/store.d.ts +23 -1
- package/dist/src/core/store.js +114 -1
- package/dist/src/gui-api.js +17 -2
- package/gui/dist/assets/index-DRRMjg-Q.js +144 -0
- package/gui/dist/assets/index-pP-Dvqvt.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-CAbA-qhx.css +0 -1
- package/gui/dist/assets/index-Da_vH9jg.js +0 -144
package/dist/src/core/store.js
CHANGED
|
@@ -5,7 +5,7 @@ import { newId } from "./ids.js";
|
|
|
5
5
|
import { WatcherRegistry } from "./watchers.js";
|
|
6
6
|
import { isVisibleVersion, VERSION_SNAPSHOT_SCHEMAS, versionSnapshot } from "./versions.js";
|
|
7
7
|
import { MAX_TASK_DEPTH, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES, VERSIONED_ENTITY_TYPES, } from "../../shared/schemas/enums.schema.js";
|
|
8
|
-
import { PERSONAL_SPACE_EMOJI, SHARED_SPACE_EMOJIS, AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, RequestAttachmentSchema, BoardViewSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, MAX_QUESTION_OPTIONS, QuestionOptionSchema, TaskQuestionSchema, EntityVersionSchema, FollowUpSchema, IdeaSchema, InvitationSchema, NoteSchema, SpaceDocumentSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, TimeSessionSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, } from "../../shared/schemas/entities.schema.js";
|
|
8
|
+
import { PERSONAL_SPACE_EMOJI, SHARED_SPACE_EMOJIS, AccessLinkSchema, AgentActionSchema, AgentInstructionsSchema, AgentTokenSchema, AgentRequestSchema, AttachmentSchema, RequestAttachmentSchema, BoardViewSchema, ChangeSchema, ChecklistItemSchema, CommentSchema, MAX_QUESTION_OPTIONS, QuestionOptionSchema, TaskQuestionSchema, EntityVersionSchema, FollowUpSchema, IdeaSchema, InvitationSchema, NoteSchema, SpaceDocumentSchema, MembershipSchema, NotificationSchema, SessionSchema, SpaceSchema, TagSchema, TaskSchema, TaskSnapshotSchema, TestCheckpointSchema, TestResultSchema, TestReviewSchema, TimeSessionSchema, UserSchema, UserSettingsSchema, SpaceNotificationSettingsSchema, SpaceCategorySchema, SpacePlacementSchema, } from "../../shared/schemas/entities.schema.js";
|
|
9
9
|
import { ClaudeConnectionSchema, NewRunnerSessionSchema, RunnerSessionRecordSchema, RunnerSettingsSchema, } from "../../shared/schemas/admin-api.schema.js";
|
|
10
10
|
import { BroadcastRecordSchema, NewBroadcastSchema } from "../../shared/schemas/broadcast-api.schema.js";
|
|
11
11
|
/** Valide `value` avec `schema` ; une donnée invalide est une erreur métier qui liste les champs fautifs. */
|
|
@@ -227,6 +227,19 @@ function documentFromRow(row) {
|
|
|
227
227
|
updatedAt: row.updated_at,
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
+
function spaceCategoryFromRow(row) {
|
|
231
|
+
return SpaceCategorySchema.parse({
|
|
232
|
+
id: row.id,
|
|
233
|
+
userId: row.user_id,
|
|
234
|
+
name: row.name,
|
|
235
|
+
position: row.position,
|
|
236
|
+
createdAt: row.created_at,
|
|
237
|
+
updatedAt: row.updated_at,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function spacePlacementFromRow(row) {
|
|
241
|
+
return SpacePlacementSchema.parse({ userId: row.user_id, spaceId: row.space_id, categoryId: row.category_id, position: row.position });
|
|
242
|
+
}
|
|
230
243
|
function boardViewFromRow(row) {
|
|
231
244
|
return BoardViewSchema.parse({
|
|
232
245
|
id: row.id,
|
|
@@ -1087,6 +1100,26 @@ export class Store {
|
|
|
1087
1100
|
const rows = this.db.prepare("SELECT * FROM board_views WHERE space_id = ? AND user_id = ? ORDER BY position, id").all(spaceId, userId);
|
|
1088
1101
|
return rows.map(boardViewFromRow);
|
|
1089
1102
|
}
|
|
1103
|
+
findSpaceCategory(id) {
|
|
1104
|
+
const row = this.db.prepare("SELECT * FROM space_categories WHERE id = ?").get(id);
|
|
1105
|
+
return row ? spaceCategoryFromRow(row) : null;
|
|
1106
|
+
}
|
|
1107
|
+
getSpaceCategory(id) {
|
|
1108
|
+
const category = this.findSpaceCategory(id);
|
|
1109
|
+
if (!category)
|
|
1110
|
+
throw new NotFoundError(`Space category ${id} not found.`);
|
|
1111
|
+
return category;
|
|
1112
|
+
}
|
|
1113
|
+
/** Catégories d'espaces d'un utilisateur, dans son ordre. */
|
|
1114
|
+
listSpaceCategories(userId) {
|
|
1115
|
+
const rows = this.db.prepare("SELECT * FROM space_categories WHERE user_id = ? ORDER BY position, id").all(userId);
|
|
1116
|
+
return rows.map(spaceCategoryFromRow);
|
|
1117
|
+
}
|
|
1118
|
+
/** Places des espaces d'un utilisateur, par rang. */
|
|
1119
|
+
listSpacePlacements(userId) {
|
|
1120
|
+
const rows = this.db.prepare("SELECT * FROM space_placements WHERE user_id = ? ORDER BY position, space_id").all(userId);
|
|
1121
|
+
return rows.map(spacePlacementFromRow);
|
|
1122
|
+
}
|
|
1090
1123
|
/** Tâches de test qui vérifient une tâche. */
|
|
1091
1124
|
listTestsOf(taskId) {
|
|
1092
1125
|
const rows = this.db.prepare("SELECT * FROM tasks WHERE tested_task_id = ? ORDER BY number").all(taskId);
|
|
@@ -1805,6 +1838,9 @@ export class Mutation {
|
|
|
1805
1838
|
this.db.prepare("DELETE FROM memberships WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1806
1839
|
this.db.prepare("DELETE FROM space_notification_settings WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1807
1840
|
this.db.prepare("DELETE FROM board_views WHERE space_id = ? AND user_id = ?").run(spaceId, userId);
|
|
1841
|
+
if (this.db.prepare("DELETE FROM space_placements WHERE space_id = ? AND user_id = ?").run(spaceId, userId).changes > 0) {
|
|
1842
|
+
this.touch("space_category", spaceId, null, userId);
|
|
1843
|
+
}
|
|
1808
1844
|
const filtering = this.db.prepare("SELECT * FROM board_views WHERE space_id = ?").all(spaceId);
|
|
1809
1845
|
for (const view of filtering.map(boardViewFromRow).filter((view) => view.assigneeIds.includes(userId))) {
|
|
1810
1846
|
this.updateBoardView(view.id, { assigneeIds: view.assigneeIds.filter((id) => id !== userId) });
|
|
@@ -2747,6 +2783,83 @@ export class Mutation {
|
|
|
2747
2783
|
this.db.prepare("DELETE FROM board_views WHERE id = ?").run(id);
|
|
2748
2784
|
this.touch("board_view", id, null, view.userId, null, view.spaceId);
|
|
2749
2785
|
}
|
|
2786
|
+
// --- Catégories d'espaces ---
|
|
2787
|
+
/** Ajoute une catégorie à celles d'un utilisateur, après la dernière. */
|
|
2788
|
+
createSpaceCategory(userId, name) {
|
|
2789
|
+
const last = this.db.prepare("SELECT MAX(position) AS max FROM space_categories WHERE user_id = ?").get(userId);
|
|
2790
|
+
const category = validate(SpaceCategorySchema, { id: newId(), userId, name, position: last.max === null ? 1 : Math.floor(last.max) + 1, createdAt: this.now, updatedAt: this.now }, "space category");
|
|
2791
|
+
this.db
|
|
2792
|
+
.prepare("INSERT INTO space_categories (id, user_id, name, position, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)")
|
|
2793
|
+
.run(category.id, category.userId, category.name, category.position, category.createdAt, category.updatedAt);
|
|
2794
|
+
this.touch("space_category", category.id, null, userId);
|
|
2795
|
+
return category;
|
|
2796
|
+
}
|
|
2797
|
+
renameSpaceCategory(id, name) {
|
|
2798
|
+
const current = this.store.getSpaceCategory(id);
|
|
2799
|
+
const category = validate(SpaceCategorySchema, { ...current, name, updatedAt: this.now }, "space category");
|
|
2800
|
+
this.db.prepare("UPDATE space_categories SET name = ?, updated_at = ? WHERE id = ?").run(category.name, category.updatedAt, id);
|
|
2801
|
+
this.touch("space_category", id, null, category.userId);
|
|
2802
|
+
return category;
|
|
2803
|
+
}
|
|
2804
|
+
/** Place une catégorie juste après `afterId` parmi celles de son utilisateur, ou en tête avec null. */
|
|
2805
|
+
moveSpaceCategory(id, afterId) {
|
|
2806
|
+
const category = this.store.getSpaceCategory(id);
|
|
2807
|
+
if (afterId === id)
|
|
2808
|
+
return category;
|
|
2809
|
+
const others = this.store.listSpaceCategories(category.userId).filter((other) => other.id !== id);
|
|
2810
|
+
const position = this.slotAfter(others, afterId, `Category ${afterId} is not a space category of this user`, (ids) => {
|
|
2811
|
+
const update = this.db.prepare("UPDATE space_categories SET position = ? WHERE id = ?");
|
|
2812
|
+
ids.forEach((otherId, index) => update.run(index + 1, otherId));
|
|
2813
|
+
});
|
|
2814
|
+
this.db.prepare("UPDATE space_categories SET position = ?, updated_at = ? WHERE id = ?").run(position, this.now, id);
|
|
2815
|
+
this.touch("space_category", id, null, category.userId);
|
|
2816
|
+
return { ...category, position, updatedAt: this.now };
|
|
2817
|
+
}
|
|
2818
|
+
/** Supprime une catégorie ; ses espaces passent à la fin des « Autres espaces », dans leur ordre. */
|
|
2819
|
+
deleteSpaceCategory(id) {
|
|
2820
|
+
const category = this.store.getSpaceCategory(id);
|
|
2821
|
+
for (const placement of this.store.listSpacePlacements(category.userId).filter((p) => p.categoryId === id)) {
|
|
2822
|
+
this.placeSpace(category.userId, placement.spaceId, null, undefined);
|
|
2823
|
+
}
|
|
2824
|
+
this.db.prepare("DELETE FROM space_categories WHERE id = ?").run(id);
|
|
2825
|
+
this.touch("space_category", id, null, category.userId);
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Range un espace de l'utilisateur dans une catégorie (null : « Autres
|
|
2829
|
+
* espaces »), juste après `afterSpaceId`, en tête avec null, à la fin avec
|
|
2830
|
+
* undefined. Les espaces encore sans place en reçoivent une d'abord, à la
|
|
2831
|
+
* fin des « Autres espaces », dans l'ordre par défaut du sélecteur.
|
|
2832
|
+
*/
|
|
2833
|
+
placeSpace(userId, spaceId, categoryId, afterSpaceId) {
|
|
2834
|
+
if (!this.store.findMembership(spaceId, userId))
|
|
2835
|
+
throw new NotFoundError(`User ${userId} is not a member of space ${spaceId}.`);
|
|
2836
|
+
if (categoryId !== null && this.store.getSpaceCategory(categoryId).userId !== userId)
|
|
2837
|
+
throw new NotFoundError(`Space category ${categoryId} not found.`);
|
|
2838
|
+
this.ensureSpacePlacements(userId);
|
|
2839
|
+
const group = this.store.listSpacePlacements(userId).filter((p) => p.categoryId === categoryId && p.spaceId !== spaceId);
|
|
2840
|
+
const items = group.map((p) => ({ id: p.spaceId, position: p.position }));
|
|
2841
|
+
const after = afterSpaceId === undefined ? (items.at(-1)?.id ?? null) : afterSpaceId === spaceId ? null : afterSpaceId;
|
|
2842
|
+
const position = this.slotAfter(items, after, `Space ${afterSpaceId} is not in this category`, (ids) => {
|
|
2843
|
+
const update = this.db.prepare("UPDATE space_placements SET position = ? WHERE user_id = ? AND space_id = ?");
|
|
2844
|
+
ids.forEach((otherId, index) => update.run(index + 1, userId, otherId));
|
|
2845
|
+
});
|
|
2846
|
+
const placement = validate(SpacePlacementSchema, { userId, spaceId, categoryId, position }, "space placement");
|
|
2847
|
+
this.db.prepare("UPDATE space_placements SET category_id = ?, position = ? WHERE user_id = ? AND space_id = ?").run(categoryId, position, userId, spaceId);
|
|
2848
|
+
this.touch("space_category", spaceId, null, userId);
|
|
2849
|
+
return placement;
|
|
2850
|
+
}
|
|
2851
|
+
/** Donne une place, à la fin des « Autres espaces », à chaque espace de l'utilisateur qui n'en a pas. */
|
|
2852
|
+
ensureSpacePlacements(userId) {
|
|
2853
|
+
const placed = new Set(this.store.listSpacePlacements(userId).map((p) => p.spaceId));
|
|
2854
|
+
const missing = this.store.listSpacesOf(userId).filter((space) => !placed.has(space.id));
|
|
2855
|
+
if (missing.length === 0)
|
|
2856
|
+
return;
|
|
2857
|
+
const last = this.db.prepare("SELECT MAX(position) AS max FROM space_placements WHERE user_id = ? AND category_id IS NULL").get(userId);
|
|
2858
|
+
let position = last.max === null ? 0 : Math.floor(last.max);
|
|
2859
|
+
const insert = this.db.prepare("INSERT INTO space_placements (user_id, space_id, category_id, position) VALUES (?, ?, NULL, ?)");
|
|
2860
|
+
for (const space of missing)
|
|
2861
|
+
insert.run(userId, space.id, ++position);
|
|
2862
|
+
}
|
|
2750
2863
|
// --- Demandes ---
|
|
2751
2864
|
/** Dépose une demande `pending` de l'utilisateur acteur. */
|
|
2752
2865
|
createAgentRequest(input) {
|
package/dist/src/gui-api.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ActivateRequestSchema, ChangePasswordRequestSchema, CreateSpaceRequestSchema, InviteRequestSchema, LoginRequestSchema, PasswordResetRequestSchema, UpdateSpaceRequestSchema, UpdateProfileRequestSchema, } from "../shared/schemas/api.schema.js";
|
|
1
|
+
import { ActivateRequestSchema, ChangePasswordRequestSchema, CreateSpaceCategoryRequestSchema, CreateSpaceRequestSchema, InviteRequestSchema, LoginRequestSchema, MoveSpaceCategoryRequestSchema, PasswordResetRequestSchema, PlaceSpaceRequestSchema, RenameSpaceCategoryRequestSchema, UpdateSpaceRequestSchema, UpdateProfileRequestSchema, } from "../shared/schemas/api.schema.js";
|
|
2
2
|
import { ForbiddenError, InvariantError, NotFoundError, OrganizerError, UnauthorizedError } from "./core/errors.js";
|
|
3
3
|
import { authenticate, changePassword, login, logout, redeemAccessLink, resolveAccessLink, updateDisplayName } from "./core/accounts.js";
|
|
4
4
|
import { acceptReceivedInvitation, createSharedSpace, declineReceivedInvitation, deleteSpace, inviteToSpace, leaveSpace, listMembers, listMemberSuggestions, listReceivedInvitations, listSpaces, removeMember, updateSpace, resendInvitation, revokeInvitation, } from "./core/spaces.js";
|
|
5
|
+
import { createSpaceCategory, deleteSpaceCategory, moveSpaceCategory, placeSpace, renameSpaceCategory, spaceOrganization } from "./core/space-categories.js";
|
|
5
6
|
import { addChecklistItem, addComment, createTask, deleteAttachment, deleteChecklistItem, deleteComment, deleteTask, downloadAttachment, getBoard, getTaskDetail, listChanges, moveChecklistItem, moveTask, resolveTaskKey, setAssignees, setTags, updateChecklistItem, updateComment, updateTask, toggleCommentCheckbox, toggleDescriptionCheckbox, uploadAttachment, } from "./core/tasks.js";
|
|
6
7
|
import { answerQuestion } from "./core/questions.js";
|
|
7
8
|
import { listTimers, pauseTimer, resumeTimer, startTimer, stopTimer } from "./core/timers.js";
|
|
@@ -182,9 +183,23 @@ route("POST", "/profile/password", async (ctx, { user, request }) => {
|
|
|
182
183
|
return { body: ok };
|
|
183
184
|
});
|
|
184
185
|
route("GET", "/spaces", (ctx, { user }) => {
|
|
185
|
-
const body = { spaces: listSpaces(ctx.store, user.id) };
|
|
186
|
+
const body = { spaces: listSpaces(ctx.store, user.id), organization: spaceOrganization(ctx.store, user.id) };
|
|
186
187
|
return { body };
|
|
187
188
|
});
|
|
189
|
+
// --- Catégories du sélecteur d'espaces ------------------------------------------------
|
|
190
|
+
route("POST", "/space-categories", (ctx, { user, request }) => ({
|
|
191
|
+
body: createSpaceCategory(ctx.store, user.id, parseBody(CreateSpaceCategoryRequestSchema, request.body)),
|
|
192
|
+
}));
|
|
193
|
+
route("PATCH", "/space-categories/:categoryId", (ctx, { user, request, params }) => ({
|
|
194
|
+
body: renameSpaceCategory(ctx.store, user.id, params.categoryId, parseBody(RenameSpaceCategoryRequestSchema, request.body).name),
|
|
195
|
+
}));
|
|
196
|
+
route("POST", "/space-categories/:categoryId/move", (ctx, { user, request, params }) => ({
|
|
197
|
+
body: moveSpaceCategory(ctx.store, user.id, params.categoryId, parseBody(MoveSpaceCategoryRequestSchema, request.body)),
|
|
198
|
+
}));
|
|
199
|
+
route("DELETE", "/space-categories/:categoryId", (ctx, { user, params }) => ({ body: deleteSpaceCategory(ctx.store, user.id, params.categoryId) }));
|
|
200
|
+
route("POST", "/spaces/:spaceId/placement", (ctx, { user, request, params }) => ({
|
|
201
|
+
body: placeSpace(ctx.store, user.id, params.spaceId, parseBody(PlaceSpaceRequestSchema, request.body)),
|
|
202
|
+
}));
|
|
188
203
|
route("POST", "/spaces", (ctx, { user, request }) => {
|
|
189
204
|
const input = parseBody(CreateSpaceRequestSchema, request.body);
|
|
190
205
|
return { body: createSharedSpace(ctx.store, user.id, input) };
|