@imenam/mcp-organizer 1.0.39 → 1.0.41
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 +3 -2
- package/dist/shared/logic/checkboxes.d.ts +32 -0
- package/dist/shared/logic/checkboxes.js +58 -0
- package/dist/shared/schemas/agent-tools.schema.d.ts +21 -0
- package/dist/shared/schemas/agent-tools.schema.js +12 -2
- package/dist/shared/schemas/api.schema.d.ts +6 -0
- package/dist/shared/schemas/api.schema.js +4 -0
- package/dist/shared/schemas/entities.schema.d.ts +2 -2
- package/dist/shared/schemas/entities.schema.js +2 -2
- package/dist/shared/schemas/tasks-api.schema.d.ts +12 -2
- package/dist/shared/schemas/tasks-api.schema.js +13 -5
- package/dist/src/agent-api/checklist.d.ts +5 -1
- package/dist/src/agent-api/checklist.js +17 -13
- package/dist/src/agent-api/questions.js +4 -2
- package/dist/src/agent-api/tasks.js +6 -11
- package/dist/src/core/agent.d.ts +2 -0
- package/dist/src/core/agent.js +7 -1
- package/dist/src/core/history.d.ts +14 -1
- package/dist/src/core/history.js +123 -1
- package/dist/src/core/notes.d.ts +3 -0
- package/dist/src/core/notes.js +13 -1
- package/dist/src/core/requests.d.ts +14 -4
- package/dist/src/core/requests.js +43 -18
- package/dist/src/core/spaces.js +17 -7
- package/dist/src/core/store.d.ts +21 -9
- package/dist/src/core/store.js +83 -28
- package/dist/src/core/tasks.d.ts +5 -0
- package/dist/src/core/tasks.js +25 -2
- package/dist/src/core/test-tasks.js +7 -14
- package/dist/src/gui-api.js +17 -6
- package/dist/src/mcp/start.d.ts +1 -1
- package/dist/src/mcp/start.js +3 -2
- package/dist/src/mcp/tools.js +11 -6
- package/gui/dist/assets/index-BqD-wglW.js +144 -0
- package/gui/dist/assets/index-e6E6S5zV.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-CB0X_FZW.css +0 -1
- package/gui/dist/assets/index-xC5hAFk-.js +0 -122
|
@@ -3,7 +3,8 @@ import { type AgentAction, type TaskSnapshot } from "../../shared/schemas/entiti
|
|
|
3
3
|
/**
|
|
4
4
|
* Retour à un état antérieur : annulation d'une action de l'agent, après
|
|
5
5
|
* comparaison de l'état courant de l'entité avec celui que l'action a
|
|
6
|
-
* laissé,
|
|
6
|
+
* laissé, rétablissement d'une action annulée, après comparaison avec l'état
|
|
7
|
+
* que l'annulation a laissé, et restauration des champs d'une version de tâche.
|
|
7
8
|
*/
|
|
8
9
|
/** Champs d'une tâche comparés et restaurés par l'historique. */
|
|
9
10
|
declare const TASK_FIELDS: readonly ["title", "description", "status", "priority", "type", "parentId", "testedTaskId"];
|
|
@@ -17,6 +18,18 @@ declare const TASK_FIELDS: readonly ["title", "description", "status", "priority
|
|
|
17
18
|
* efface une fois la mutation validée ; null sinon.
|
|
18
19
|
*/
|
|
19
20
|
export declare function undoAgentAction(tx: Mutation, action: AgentAction): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Rétablit une action de l'agent annulée, dans la mutation `tx` (acteur
|
|
23
|
+
* utilisateur) : refait à l'identique ce que l'action avait fait. L'état
|
|
24
|
+
* courant de l'entité doit être celui que l'annulation a laissé ; sinon le
|
|
25
|
+
* refus nomme l'auteur de la modification. Ce que l'annulation a supprimé
|
|
26
|
+
* est recréé avec ses identifiants (une pièce jointe seulement si son
|
|
27
|
+
* fichier existe encore, selon `hasFile`), ce qu'elle a recréé est supprimé,
|
|
28
|
+
* ce qu'elle a ramené à l'état d'avant reprend l'état laissé par l'action.
|
|
29
|
+
* Renvoie le chemin du fichier d'une pièce jointe supprimée, que l'appelant
|
|
30
|
+
* efface une fois la mutation validée ; null sinon.
|
|
31
|
+
*/
|
|
32
|
+
export declare function redoAgentAction(tx: Mutation, action: AgentAction, hasFile: (storagePath: string) => boolean): string | null;
|
|
20
33
|
/** Libellés français des champs restaurables d'une tâche ; « position » est le rang dans une même colonne. */
|
|
21
34
|
export declare const TASK_FIELD_LABELS: Record<(typeof TASK_FIELDS)[number] | "position" | "assigneeIds" | "tagIds", string>;
|
|
22
35
|
/**
|
package/dist/src/core/history.js
CHANGED
|
@@ -4,7 +4,8 @@ import { BoardViewSchema, ChecklistItemSchema, FollowUpSchema, QuestionSnapshotS
|
|
|
4
4
|
/**
|
|
5
5
|
* Retour à un état antérieur : annulation d'une action de l'agent, après
|
|
6
6
|
* comparaison de l'état courant de l'entité avec celui que l'action a
|
|
7
|
-
* laissé,
|
|
7
|
+
* laissé, rétablissement d'une action annulée, après comparaison avec l'état
|
|
8
|
+
* que l'annulation a laissé, et restauration des champs d'une version de tâche.
|
|
8
9
|
*/
|
|
9
10
|
/** Champs d'une tâche comparés et restaurés par l'historique. */
|
|
10
11
|
const TASK_FIELDS = ["title", "description", "status", "priority", "type", "parentId", "testedTaskId"];
|
|
@@ -161,6 +162,127 @@ export function undoAgentAction(tx, action) {
|
|
|
161
162
|
tx.markAgentActionUndone(action.id, taskIdOfAction(action));
|
|
162
163
|
return removedFile;
|
|
163
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Rétablit une action de l'agent annulée, dans la mutation `tx` (acteur
|
|
167
|
+
* utilisateur) : refait à l'identique ce que l'action avait fait. L'état
|
|
168
|
+
* courant de l'entité doit être celui que l'annulation a laissé ; sinon le
|
|
169
|
+
* refus nomme l'auteur de la modification. Ce que l'annulation a supprimé
|
|
170
|
+
* est recréé avec ses identifiants (une pièce jointe seulement si son
|
|
171
|
+
* fichier existe encore, selon `hasFile`), ce qu'elle a recréé est supprimé,
|
|
172
|
+
* ce qu'elle a ramené à l'état d'avant reprend l'état laissé par l'action.
|
|
173
|
+
* Renvoie le chemin du fichier d'une pièce jointe supprimée, que l'appelant
|
|
174
|
+
* efface une fois la mutation validée ; null sinon.
|
|
175
|
+
*/
|
|
176
|
+
export function redoAgentAction(tx, action, hasFile) {
|
|
177
|
+
if (action.undoneAt === null)
|
|
178
|
+
throw new InvariantError("Cette action n'est pas annulée.");
|
|
179
|
+
if (!isTracked(action.entityType))
|
|
180
|
+
throw new InvariantError(`Une action sur ${action.entityType} ne se rétablit pas.`);
|
|
181
|
+
const entityType = action.entityType;
|
|
182
|
+
const store = tx.store;
|
|
183
|
+
if (entityType === "board_view")
|
|
184
|
+
requireViewOwner(tx, BoardViewSchema.parse(action.after ?? action.before));
|
|
185
|
+
if (entityType === "time_session")
|
|
186
|
+
requireTimerOwner(tx, TimeSessionSchema.parse(action.after ?? action.before));
|
|
187
|
+
const current = snapshotOf(store, entityType, action.entityId);
|
|
188
|
+
let removedFile = null;
|
|
189
|
+
if (action.before === null) {
|
|
190
|
+
const { label } = describe(store, entityType, action.after);
|
|
191
|
+
if (current !== null)
|
|
192
|
+
throw new InvariantError(`${label} existe de nouveau : rien à rétablir.`);
|
|
193
|
+
recreateCreated(tx, entityType, action.after, label, hasFile);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const { label, feminine } = describe(store, entityType, current ?? action.before);
|
|
197
|
+
const agreement = feminine ? "e" : "";
|
|
198
|
+
if (current === null) {
|
|
199
|
+
throw new InvariantError(`${label} a été supprimé${agreement} depuis par ${lastModifier(store, entityType, action.entityId, action)} : rétablissement impossible.`);
|
|
200
|
+
}
|
|
201
|
+
if (!sameState(entityType, current, action.before, action.after)) {
|
|
202
|
+
throw new InvariantError(`${label} a été modifié${agreement} depuis par ${lastModifier(store, entityType, action.entityId, action)} : le rétablissement écraserait cette modification.`);
|
|
203
|
+
}
|
|
204
|
+
if (action.after === null)
|
|
205
|
+
removedFile = remove(tx, entityType, current, label);
|
|
206
|
+
else
|
|
207
|
+
restore(tx, entityType, action.entityId, action.after);
|
|
208
|
+
}
|
|
209
|
+
tx.markAgentActionRedone(action.id, taskIdOfAction(action));
|
|
210
|
+
return removedFile;
|
|
211
|
+
}
|
|
212
|
+
/** Recrée, avec ses identifiants, une entité que l'agent avait créée et que l'annulation a supprimée. */
|
|
213
|
+
function recreateCreated(tx, entityType, after, label, hasFile) {
|
|
214
|
+
const store = tx.store;
|
|
215
|
+
const requireTask = (taskId) => {
|
|
216
|
+
if (!store.findTask(taskId))
|
|
217
|
+
throw new InvariantError(`${label} appartenait à une tâche qui n'existe plus : rétablissement impossible.`);
|
|
218
|
+
};
|
|
219
|
+
switch (entityType) {
|
|
220
|
+
case "task": {
|
|
221
|
+
const task = TaskSnapshotSchema.parse(after);
|
|
222
|
+
if (task.parentId !== null && !store.findTask(task.parentId))
|
|
223
|
+
throw new InvariantError(`La tâche parente de ${label.toLowerCase()} n'existe plus : rétablissement impossible.`);
|
|
224
|
+
tx.restoreTask(task);
|
|
225
|
+
const assignees = task.assigneeIds.filter((userId) => store.isMember(task.spaceId, userId));
|
|
226
|
+
if (assignees.length > 0)
|
|
227
|
+
tx.setAssignees(task.id, assignees, false);
|
|
228
|
+
const tags = task.tagIds.flatMap((tagId) => store.findTag(tagId)?.name ?? []);
|
|
229
|
+
if (tags.length > 0)
|
|
230
|
+
tx.setTags(task.id, tags);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
case "checklist_item": {
|
|
234
|
+
const item = ChecklistItemSchema.parse(after);
|
|
235
|
+
requireTask(item.taskId);
|
|
236
|
+
tx.restoreChecklistItem(item);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
case "task_question": {
|
|
240
|
+
const question = QuestionSnapshotSchema.parse(after);
|
|
241
|
+
requireTask(question.taskId);
|
|
242
|
+
tx.restoreQuestion(question);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
case "test_checkpoint": {
|
|
246
|
+
const { results, ...fields } = CheckpointSnapshotSchema.parse(after);
|
|
247
|
+
requireTask(fields.taskId);
|
|
248
|
+
tx.restoreCheckpoint(fields, results);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
case "comment": {
|
|
252
|
+
const comment = CommentSchema.parse(after);
|
|
253
|
+
requireTask(comment.taskId);
|
|
254
|
+
tx.restoreComment(comment);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
case "attachment": {
|
|
258
|
+
const attachment = AttachmentSchema.parse(after);
|
|
259
|
+
requireTask(attachment.taskId);
|
|
260
|
+
if (!hasFile(attachment.storagePath))
|
|
261
|
+
throw new InvariantError(`Le fichier de ${label.toLowerCase()} a été effacé : rétablissement impossible.`);
|
|
262
|
+
tx.restoreAttachment(attachment);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
case "idea":
|
|
266
|
+
tx.restoreIdea(IdeaSchema.parse(after));
|
|
267
|
+
return;
|
|
268
|
+
case "board_view": {
|
|
269
|
+
const view = BoardViewSchema.parse(after);
|
|
270
|
+
if (!store.isMember(view.spaceId, view.userId))
|
|
271
|
+
throw new InvariantError(`Le propriétaire de la vue « ${view.name} » n'est plus membre de l'espace : rétablissement impossible.`);
|
|
272
|
+
requireViewAssignees(tx, view);
|
|
273
|
+
tx.restoreBoardView(view);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
case "time_session": {
|
|
277
|
+
const session = TimeSessionSchema.parse(after);
|
|
278
|
+
requireTask(session.taskId);
|
|
279
|
+
tx.restoreTimeSession(session);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
case "follow_up":
|
|
283
|
+
throw new InvariantError(`${label} ne se recrée pas : rétablissement impossible.`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
164
286
|
/** Seul le membre à qui appartient une vue annule les changements que l'agent y a faits. */
|
|
165
287
|
function requireViewOwner(tx, view) {
|
|
166
288
|
if (tx.actor.type === "user" && tx.actor.userId === view.userId)
|
package/dist/src/core/notes.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CheckboxTarget } from "../../shared/logic/checkboxes.js";
|
|
1
2
|
import type { Store } from "./store.js";
|
|
2
3
|
import type { CreateNoteRequest, NoteListResponse, NoteView, SendNoteResponse, UpdateNoteRequest } from "../../shared/schemas/notes-api.schema.js";
|
|
3
4
|
/**
|
|
@@ -14,6 +15,8 @@ export declare function listNotes(store: Store, userId: string, spaceId: string)
|
|
|
14
15
|
export declare function getNote(store: Store, userId: string, noteId: string): NoteView;
|
|
15
16
|
export declare function createNote(store: Store, userId: string, spaceId: string, input: CreateNoteRequest): NoteView;
|
|
16
17
|
export declare function updateNote(store: Store, userId: string, noteId: string, patch: UpdateNoteRequest): NoteView;
|
|
18
|
+
/** Coche ou décoche une case du contenu d'une note. */
|
|
19
|
+
export declare function toggleNoteCheckbox(store: Store, userId: string, noteId: string, target: CheckboxTarget): NoteView;
|
|
17
20
|
export declare function deleteNote(store: Store, userId: string, noteId: string): void;
|
|
18
21
|
/**
|
|
19
22
|
* Confie une note à l'agent : un message dans la file de l'espace de la note,
|
package/dist/src/core/notes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NotFoundError } from "./errors.js";
|
|
1
|
+
import { InvariantError, NotFoundError } from "./errors.js";
|
|
2
|
+
import { CHECKBOX_CONFLICT, toggleCheckbox } from "../../shared/logic/checkboxes.js";
|
|
2
3
|
import { requireMember } from "./spaces.js";
|
|
3
4
|
import { noteLinkMarkdown } from "../../shared/logic/notes.js";
|
|
4
5
|
/**
|
|
@@ -57,6 +58,17 @@ export function updateNote(store, userId, noteId, patch) {
|
|
|
57
58
|
});
|
|
58
59
|
return noteView(store, note);
|
|
59
60
|
}
|
|
61
|
+
/** Coche ou décoche une case du contenu d'une note. */
|
|
62
|
+
export function toggleNoteCheckbox(store, userId, noteId, target) {
|
|
63
|
+
const note = store.mutate(asUser(userId), (tx) => {
|
|
64
|
+
const current = requireNote(tx.store, noteId, userId);
|
|
65
|
+
const body = toggleCheckbox(current.body, target);
|
|
66
|
+
if (body === null)
|
|
67
|
+
throw new InvariantError(CHECKBOX_CONFLICT);
|
|
68
|
+
return body === current.body ? current : tx.updateNote(noteId, { body });
|
|
69
|
+
});
|
|
70
|
+
return noteView(store, note);
|
|
71
|
+
}
|
|
60
72
|
export function deleteNote(store, userId, noteId) {
|
|
61
73
|
store.mutate(asUser(userId), (tx) => {
|
|
62
74
|
requireNote(tx.store, noteId, userId);
|
|
@@ -78,11 +78,21 @@ export declare function listRequests(store: Store, userId: string, spaceId: stri
|
|
|
78
78
|
startedAt: string;
|
|
79
79
|
} | null;
|
|
80
80
|
}, now?: Date): RequestListResponse;
|
|
81
|
-
/**
|
|
82
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Annule une action de l'agent. Le fichier d'une pièce jointe ainsi
|
|
83
|
+
* supprimée est gardé, pour qu'un rétablissement la remette.
|
|
84
|
+
*/
|
|
85
|
+
export declare function undoAction(store: Store, userId: string, actionId: string): RequestView;
|
|
83
86
|
/**
|
|
84
87
|
* Annule toutes les actions non annulées d'un lot, de la plus récente à la
|
|
85
88
|
* plus ancienne : tout le lot ou rien. Les fichiers des pièces jointes
|
|
86
|
-
* supprimées sont
|
|
89
|
+
* supprimées sont gardés, pour qu'un rétablissement les remette.
|
|
90
|
+
*/
|
|
91
|
+
export declare function undoRequest(store: Store, userId: string, requestId: string): RequestView;
|
|
92
|
+
/** Rétablit une action de l'agent annulée ; les mêmes membres que pour l'annuler le peuvent. */
|
|
93
|
+
export declare function redoAction(store: Store, storage: AttachmentStorage, userId: string, actionId: string): RequestView;
|
|
94
|
+
/**
|
|
95
|
+
* Rétablit toutes les actions annulées d'un lot, de la plus ancienne à la
|
|
96
|
+
* plus récente : tout le lot ou rien.
|
|
87
97
|
*/
|
|
88
|
-
export declare function
|
|
98
|
+
export declare function redoRequest(store: Store, storage: AttachmentStorage, userId: string, requestId: string): RequestView;
|
|
@@ -2,7 +2,7 @@ import { ForbiddenError, InvariantError, NotFoundError, OrganizerError } from ".
|
|
|
2
2
|
import { stoppedByReason } from "./admin.js";
|
|
3
3
|
import { requireMember } from "./spaces.js";
|
|
4
4
|
import { requireTask } from "./tasks.js";
|
|
5
|
-
import { undoAgentAction } from "./history.js";
|
|
5
|
+
import { redoAgentAction, undoAgentAction } from "./history.js";
|
|
6
6
|
import { actionTaskKey } from "./agent.js";
|
|
7
7
|
import { taskIdOfAction } from "./snapshots.js";
|
|
8
8
|
import { tokenState } from "./agent-tokens.js";
|
|
@@ -324,40 +324,65 @@ function requireUndoableRequest(request) {
|
|
|
324
324
|
if (request.status === "processing")
|
|
325
325
|
throw new InvariantError("L'agent traite encore cette demande : attendez qu'il ait terminé pour annuler ses actions.");
|
|
326
326
|
}
|
|
327
|
-
/**
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Annule une action de l'agent. Le fichier d'une pièce jointe ainsi
|
|
329
|
+
* supprimée est gardé, pour qu'un rétablissement la remette.
|
|
330
|
+
*/
|
|
331
|
+
export function undoAction(store, userId, actionId) {
|
|
332
|
+
const requestId = store.mutate(asUser(userId), (tx) => {
|
|
330
333
|
const action = tx.store.findAgentAction(actionId);
|
|
331
334
|
if (!action)
|
|
332
335
|
throw new NotFoundError("Action introuvable.");
|
|
333
336
|
const request = requireVisibleRequest(tx.store, userId, action.requestId);
|
|
334
337
|
requireUndoableRequest(request);
|
|
335
|
-
|
|
338
|
+
undoAgentAction(tx, action);
|
|
339
|
+
return request.id;
|
|
336
340
|
});
|
|
337
|
-
if (removedFile !== null)
|
|
338
|
-
storage.remove([removedFile]);
|
|
339
341
|
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
340
342
|
}
|
|
341
343
|
/**
|
|
342
344
|
* Annule toutes les actions non annulées d'un lot, de la plus récente à la
|
|
343
345
|
* plus ancienne : tout le lot ou rien. Les fichiers des pièces jointes
|
|
344
|
-
* supprimées sont
|
|
346
|
+
* supprimées sont gardés, pour qu'un rétablissement les remette.
|
|
345
347
|
*/
|
|
346
|
-
export function undoRequest(store,
|
|
347
|
-
|
|
348
|
+
export function undoRequest(store, userId, requestId) {
|
|
349
|
+
store.mutate(asUser(userId), (tx) => {
|
|
348
350
|
const request = requireVisibleRequest(tx.store, userId, requestId);
|
|
349
351
|
requireUndoableRequest(request);
|
|
350
352
|
const remaining = tx.store.listAgentActions(requestId).filter((action) => action.undoneAt === null);
|
|
351
353
|
if (remaining.length === 0)
|
|
352
354
|
throw new InvariantError("Toutes les actions de ce lot sont déjà annulées.");
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
for (const action of remaining.reverse())
|
|
356
|
+
undoAgentAction(tx, tx.store.getAgentAction(action.id));
|
|
357
|
+
});
|
|
358
|
+
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
359
|
+
}
|
|
360
|
+
/** Rétablit une action de l'agent annulée ; les mêmes membres que pour l'annuler le peuvent. */
|
|
361
|
+
export function redoAction(store, storage, userId, actionId) {
|
|
362
|
+
const requestId = store.mutate(asUser(userId), (tx) => {
|
|
363
|
+
const action = tx.store.findAgentAction(actionId);
|
|
364
|
+
if (!action)
|
|
365
|
+
throw new NotFoundError("Action introuvable.");
|
|
366
|
+
const request = requireVisibleRequest(tx.store, userId, action.requestId);
|
|
367
|
+
requireUndoableRequest(request);
|
|
368
|
+
redoAgentAction(tx, action, (path) => storage.exists(path));
|
|
369
|
+
return request.id;
|
|
370
|
+
});
|
|
371
|
+
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Rétablit toutes les actions annulées d'un lot, de la plus ancienne à la
|
|
375
|
+
* plus récente : tout le lot ou rien.
|
|
376
|
+
*/
|
|
377
|
+
export function redoRequest(store, storage, userId, requestId) {
|
|
378
|
+
store.mutate(asUser(userId), (tx) => {
|
|
379
|
+
const request = requireVisibleRequest(tx.store, userId, requestId);
|
|
380
|
+
requireUndoableRequest(request);
|
|
381
|
+
const undone = tx.store.listAgentActions(requestId).filter((action) => action.undoneAt !== null);
|
|
382
|
+
if (undone.length === 0)
|
|
383
|
+
throw new InvariantError("Aucune action de ce lot n'est annulée : rien à rétablir.");
|
|
384
|
+
for (const action of undone)
|
|
385
|
+
redoAgentAction(tx, tx.store.getAgentAction(action.id), (path) => storage.exists(path));
|
|
360
386
|
});
|
|
361
|
-
storage.remove(removedFiles);
|
|
362
387
|
return requestView(store, userId, store.getAgentRequest(requestId));
|
|
363
388
|
}
|
package/dist/src/core/spaces.js
CHANGED
|
@@ -21,8 +21,18 @@ export function requireOwner(store, spaceId, userId, action) {
|
|
|
21
21
|
return space;
|
|
22
22
|
}
|
|
23
23
|
// --- Vues -----------------------------------------------------------------------
|
|
24
|
-
function summary(space, membership) {
|
|
25
|
-
return {
|
|
24
|
+
function summary(store, space, membership) {
|
|
25
|
+
return {
|
|
26
|
+
id: space.id,
|
|
27
|
+
name: space.name,
|
|
28
|
+
emoji: space.emoji,
|
|
29
|
+
kind: space.kind,
|
|
30
|
+
keyPrefix: space.keyPrefix,
|
|
31
|
+
ownerId: space.ownerId,
|
|
32
|
+
role: membership.role,
|
|
33
|
+
pendingCount: store.countPendingRequestsOfSpace(space.id),
|
|
34
|
+
waitingCount: store.countWaitingRequestsOfSpace(space.id),
|
|
35
|
+
};
|
|
26
36
|
}
|
|
27
37
|
function memberView(store, user, membership) {
|
|
28
38
|
return {
|
|
@@ -54,13 +64,13 @@ function userName(user) {
|
|
|
54
64
|
// --- Espaces --------------------------------------------------------------------
|
|
55
65
|
/** Espaces de l'utilisateur : son espace personnel d'abord, puis les espaces communs par nom. */
|
|
56
66
|
export function listSpaces(store, userId) {
|
|
57
|
-
return store.listSpacesOf(userId).map((space) => summary(space, store.findMembership(space.id, userId)));
|
|
67
|
+
return store.listSpacesOf(userId).map((space) => summary(store, space, store.findMembership(space.id, userId)));
|
|
58
68
|
}
|
|
59
69
|
/** Crée un espace commun dont l'utilisateur est propriétaire ; le préfixe est dérivé du nom s'il est omis. */
|
|
60
70
|
export function createSharedSpace(store, userId, input) {
|
|
61
71
|
return store.mutate({ type: "user", userId }, (tx) => {
|
|
62
72
|
const space = tx.createSpace({ name: input.name, kind: "shared", ownerId: userId, keyPrefix: input.keyPrefix ?? deriveKeyPrefix(input.name) });
|
|
63
|
-
return summary(space, tx.store.findMembership(space.id, userId));
|
|
73
|
+
return summary(tx.store, space, tx.store.findMembership(space.id, userId));
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
/**
|
|
@@ -79,7 +89,7 @@ export function updateSpace(store, userId, spaceId, patch) {
|
|
|
79
89
|
throw new ForbiddenError(`Seul le propriétaire de l'espace « ${space.name} » peut changer son emoji.`);
|
|
80
90
|
tx.setSpaceEmoji(spaceId, patch.emoji);
|
|
81
91
|
}
|
|
82
|
-
return summary(tx.store.getSpace(spaceId), tx.store.findMembership(spaceId, userId));
|
|
92
|
+
return summary(tx.store, tx.store.getSpace(spaceId), tx.store.findMembership(spaceId, userId));
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
95
|
/** Supprime un espace commun, son contenu et les fichiers de ses pièces jointes et de ses documents. */
|
|
@@ -101,7 +111,7 @@ export function listMembers(store, userId, spaceId, now = new Date()) {
|
|
|
101
111
|
.map((m) => memberView(store, store.getUser(m.userId), m))
|
|
102
112
|
.sort((a, b) => (a.role === b.role ? 0 : a.role === "owner" ? -1 : 1));
|
|
103
113
|
const invitations = store.listOpenInvitations(spaceId).map((invitation) => invitationView(invitation, now));
|
|
104
|
-
return { space: summary(space, membership), members, invitations };
|
|
114
|
+
return { space: summary(store, space, membership), members, invitations };
|
|
105
115
|
}
|
|
106
116
|
/**
|
|
107
117
|
* Comptes actifs que le propriétaire peut ajouter sans connaître leur adresse :
|
|
@@ -296,7 +306,7 @@ export function acceptReceivedInvitation(store, userId, invitationId, now = new
|
|
|
296
306
|
throw new InvariantError(`Cette invitation a expiré : demandez à ${userName(tx.store.findUser(invitation.invitedBy))} de vous la renvoyer.`);
|
|
297
307
|
}
|
|
298
308
|
joinInvitedSpace(tx, userId, invitation.id);
|
|
299
|
-
return summary(tx.store.getSpace(invitation.spaceId), tx.store.findMembership(invitation.spaceId, userId));
|
|
309
|
+
return summary(tx.store, tx.store.getSpace(invitation.spaceId), tx.store.findMembership(invitation.spaceId, userId));
|
|
300
310
|
});
|
|
301
311
|
}
|
|
302
312
|
/** L'utilisateur refuse une invitation qui lui est adressée. */
|
package/dist/src/core/store.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare class Store {
|
|
|
149
149
|
questionSnapshot(id: string): QuestionSnapshot;
|
|
150
150
|
findCheckpoint(id: string): TestCheckpoint | null;
|
|
151
151
|
getCheckpoint(id: string): TestCheckpoint;
|
|
152
|
-
/** Points de vérification d'une tâche
|
|
152
|
+
/** Points de vérification d'une tâche, dans l'ordre. */
|
|
153
153
|
listCheckpoints(taskId: string): TestCheckpoint[];
|
|
154
154
|
/** Résultats saisis sur les points d'une tâche, tous testeurs confondus. */
|
|
155
155
|
listTestResults(taskId: string): TestResult[];
|
|
@@ -644,7 +644,7 @@ export declare class Mutation {
|
|
|
644
644
|
multiple: boolean;
|
|
645
645
|
options: readonly QuestionOptionInput[];
|
|
646
646
|
}): QuestionSnapshot;
|
|
647
|
-
/** Change le texte d'une question ou son type de choix ; un choix unique n'accepte qu'une
|
|
647
|
+
/** Change le texte d'une question ou son type de choix ; un choix unique n'accepte qu'une proposition. */
|
|
648
648
|
updateQuestion(id: string, patch: {
|
|
649
649
|
text?: string;
|
|
650
650
|
multiple?: boolean;
|
|
@@ -672,12 +672,12 @@ export declare class Mutation {
|
|
|
672
672
|
replaceQuestion(snapshot: QuestionSnapshot): void;
|
|
673
673
|
private insertQuestion;
|
|
674
674
|
private insertQuestionOption;
|
|
675
|
-
/** Un choix unique
|
|
675
|
+
/** Un choix unique retient au plus une proposition ; la réponse libre peut l'accompagner. */
|
|
676
676
|
private requireSingleAnswer;
|
|
677
677
|
private touchQuestion;
|
|
678
678
|
/**
|
|
679
|
-
* Ajoute un élément à la checklist d'une tâche
|
|
680
|
-
*
|
|
679
|
+
* Ajoute un élément à la checklist d'une tâche : juste après `afterId`
|
|
680
|
+
* (null : en tête), en fin de liste sans `afterId`.
|
|
681
681
|
*/
|
|
682
682
|
addChecklistItem(taskId: string, text: string, afterId?: string | null): ChecklistItem;
|
|
683
683
|
updateChecklistItem(id: string, patch: {
|
|
@@ -698,12 +698,10 @@ export declare class Mutation {
|
|
|
698
698
|
* reçoit les identifiants dans l'ordre et leur donne les rangs 1, 2, 3…
|
|
699
699
|
*/
|
|
700
700
|
private slotAfter;
|
|
701
|
-
/** Tâche
|
|
702
|
-
private testTask;
|
|
703
|
-
/** Tâche de test dont l'utilisateur acteur est testeur (assigné). */
|
|
701
|
+
/** Tâche dont l'utilisateur acteur est testeur (assigné). */
|
|
704
702
|
private testedTask;
|
|
705
703
|
/**
|
|
706
|
-
* Ajoute un point de vérification à une tâche
|
|
704
|
+
* Ajoute un point de vérification à une tâche : juste après
|
|
707
705
|
* `afterId` (null : en tête), en fin de liste sans `afterId`.
|
|
708
706
|
*/
|
|
709
707
|
addCheckpoint(taskId: string, text: string, afterId?: string | null): TestCheckpoint;
|
|
@@ -744,6 +742,8 @@ export declare class Mutation {
|
|
|
744
742
|
deleteComment(id: string): void;
|
|
745
743
|
/** Supprime un commentaire écrit par l'agent, quel que soit l'utilisateur acteur : annulation de l'action qui l'a créé. */
|
|
746
744
|
deleteAgentComment(id: string): void;
|
|
745
|
+
/** Recrée un commentaire de l'agent supprimé, avec son identifiant ; sa réponse à un commentaire disparu depuis est oubliée. */
|
|
746
|
+
restoreComment(snapshot: Comment): Comment;
|
|
747
747
|
private authoredComment;
|
|
748
748
|
/** Enregistre une pièce jointe dont le fichier est déjà écrit sous `storagePath`. */
|
|
749
749
|
createAttachment(input: {
|
|
@@ -756,6 +756,8 @@ export declare class Mutation {
|
|
|
756
756
|
}): Attachment;
|
|
757
757
|
/** Supprime l'enregistrement d'une pièce jointe et le renvoie ; son fichier reste à effacer. */
|
|
758
758
|
deleteAttachment(id: string): Attachment;
|
|
759
|
+
/** Recrée l'enregistrement d'une pièce jointe supprimée, avec son identifiant ; son fichier doit encore exister sous `storagePath`. */
|
|
760
|
+
restoreAttachment(snapshot: Attachment): Attachment;
|
|
759
761
|
/** Enregistre une image de demande, encore rattachée à aucune demande, dont le fichier est déjà écrit sous `storagePath`. */
|
|
760
762
|
createRequestAttachment(input: {
|
|
761
763
|
id: string;
|
|
@@ -785,6 +787,8 @@ export declare class Mutation {
|
|
|
785
787
|
createIdea(input: CreateIdeaInput): Idea;
|
|
786
788
|
updateIdea(id: string, patch: UpdateIdeaInput): Idea;
|
|
787
789
|
/** Supprime une idée ; sa version de suppression a un instantané nul. */
|
|
790
|
+
/** Recrée une idée supprimée, avec son identifiant ; sa tâche issue de l'idée est oubliée si elle n'existe plus. */
|
|
791
|
+
restoreIdea(snapshot: Idea): Idea;
|
|
788
792
|
deleteIdea(id: string): void;
|
|
789
793
|
createNote(input: CreateNoteInput): Note;
|
|
790
794
|
updateNote(id: string, patch: UpdateNoteInput): Note;
|
|
@@ -874,6 +878,8 @@ export declare class Mutation {
|
|
|
874
878
|
recordAgentAction(input: AgentActionInput): AgentAction;
|
|
875
879
|
/** Marque annulée une action de l'agent, par l'utilisateur acteur. */
|
|
876
880
|
markAgentActionUndone(id: string, taskId: string | null): AgentAction;
|
|
881
|
+
/** Marque rétablie une action de l'agent annulée, par l'utilisateur acteur : elle redevient active. */
|
|
882
|
+
markAgentActionRedone(id: string, taskId: string | null): AgentAction;
|
|
877
883
|
/**
|
|
878
884
|
* Démarre une session de chrono d'un membre sur une tâche, en marche dès
|
|
879
885
|
* `at`. Le membre n'a qu'une session active par tâche, et une seule en
|
|
@@ -898,6 +904,12 @@ export declare class Mutation {
|
|
|
898
904
|
* tâche, ou tourne alors que l'état visé est en marche.
|
|
899
905
|
*/
|
|
900
906
|
restoreTimeSessionState(id: string, state: Pick<TimeSession, "runningSince" | "elapsedMs" | "endedAt">): TimeSession;
|
|
907
|
+
/**
|
|
908
|
+
* Recrée une session de chrono supprimée, avec son identifiant ; refusé
|
|
909
|
+
* quand une autre session du membre occupe désormais la tâche, ou tourne
|
|
910
|
+
* alors que la session recréée est en marche.
|
|
911
|
+
*/
|
|
912
|
+
restoreTimeSession(snapshot: TimeSession): TimeSession;
|
|
901
913
|
deleteTimeSession(id: string): void;
|
|
902
914
|
private insertTimeSession;
|
|
903
915
|
private writeTimeSessionState;
|