@imenam/mcp-organizer 1.0.31 → 1.0.33
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 +40 -26
- package/dist/shared/logic/notes.d.ts +3 -2
- package/dist/shared/logic/notes.js +4 -3
- package/dist/shared/schemas/agent-tools.schema.d.ts +2 -0
- package/dist/shared/schemas/agent-tools.schema.js +6 -2
- package/dist/shared/schemas/api.schema.d.ts +9 -4
- package/dist/shared/schemas/api.schema.js +8 -2
- package/dist/shared/schemas/entities.schema.d.ts +46 -0
- package/dist/shared/schemas/entities.schema.js +39 -0
- package/dist/shared/schemas/notifications-api.schema.d.ts +20 -0
- package/dist/shared/schemas/notifications-api.schema.js +10 -1
- package/dist/shared/schemas/views-api.schema.d.ts +5 -0
- package/dist/shared/schemas/views-api.schema.js +2 -0
- package/dist/src/agent-api/views.js +21 -6
- package/dist/src/core/board-views.d.ts +6 -1
- package/dist/src/core/board-views.js +14 -0
- package/dist/src/core/history.js +2 -0
- package/dist/src/core/migrations.js +17 -0
- package/dist/src/core/notifications.d.ts +20 -4
- package/dist/src/core/notifications.js +144 -30
- package/dist/src/core/spaces.d.ts +8 -1
- package/dist/src/core/spaces.js +17 -4
- package/dist/src/core/store.d.ts +15 -1
- package/dist/src/core/store.js +56 -8
- package/dist/src/gui-api.js +8 -6
- package/dist/src/mcp/tools.js +7 -3
- package/gui/dist/assets/index-CLW9PAC7.js +104 -0
- package/gui/dist/assets/index-kNRY_0Gs.css +1 -0
- package/gui/dist/assets/organizer-logo-D0O_mXwN.svg +12 -0
- package/gui/dist/index.html +3 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-D4I3h65z.css +0 -1
- package/gui/dist/assets/index-F67zTtnA.js +0 -104
|
@@ -65,6 +65,22 @@ export const AgentTokenSchema = z.object({
|
|
|
65
65
|
export const MIN_ASSISTANT_HISTORY = 5;
|
|
66
66
|
export const MAX_ASSISTANT_HISTORY = 20;
|
|
67
67
|
export const AssistantHistorySchema = z.number().int().min(MIN_ASSISTANT_HISTORY).max(MAX_ASSISTANT_HISTORY);
|
|
68
|
+
/** Périodes proposées pour le résumé des e-mails de notification, en minutes. */
|
|
69
|
+
export const EMAIL_DIGEST_MINUTES = [5, 15, 30, 60, 120];
|
|
70
|
+
/** Période du résumé des e-mails de notification, en minutes ; null : un e-mail part à chaque notification. */
|
|
71
|
+
export const EmailDigestSchema = z.literal(EMAIL_DIGEST_MINUTES).nullable();
|
|
72
|
+
/**
|
|
73
|
+
* Affichage de la barre latérale sur grand écran : toujours visible, masquée
|
|
74
|
+
* et ouverte au survol du bord gauche, ou repliée en colonne d'icônes.
|
|
75
|
+
*/
|
|
76
|
+
export const SIDEBAR_MODES = ["pinned", "hover", "collapsed"];
|
|
77
|
+
export const SidebarModeSchema = z.enum(SIDEBAR_MODES);
|
|
78
|
+
/**
|
|
79
|
+
* Ouverture d'une tâche par un clic simple sur sa carte, sur grand écran : en
|
|
80
|
+
* pleine page, ou dans l'aperçu latéral à côté du tableau.
|
|
81
|
+
*/
|
|
82
|
+
export const TASK_OPEN_MODES = ["page", "preview"];
|
|
83
|
+
export const TaskOpenModeSchema = z.enum(TASK_OPEN_MODES);
|
|
68
84
|
/** Préférences de notification : assignation et commentaire, dans l'application et par e-mail. */
|
|
69
85
|
export const NotificationPreferencesSchema = z.object({
|
|
70
86
|
notifyAssignApp: z.boolean(),
|
|
@@ -87,15 +103,38 @@ export const UserSettingsSchema = NotificationPreferencesSchema.extend({
|
|
|
87
103
|
assistantHistory: AssistantHistorySchema,
|
|
88
104
|
/** Réglages pomodoro proposés au démarrage d'un chrono. */
|
|
89
105
|
pomodoro: PomodoroSettingsSchema,
|
|
106
|
+
/** Période du résumé des e-mails de notification, valable dans tous les espaces. */
|
|
107
|
+
emailDigestMinutes: EmailDigestSchema,
|
|
108
|
+
/** Affichage de la barre latérale, sur tous les appareils de l'utilisateur. */
|
|
109
|
+
sidebarMode: SidebarModeSchema,
|
|
110
|
+
/** Ouverture d'une tâche par un clic simple sur sa carte, sur tous les appareils de l'utilisateur. */
|
|
111
|
+
taskOpenMode: TaskOpenModeSchema,
|
|
90
112
|
});
|
|
91
113
|
/** Préférences de notification d'un utilisateur propres à un espace ; elles remplacent celles du compte dans cet espace. */
|
|
92
114
|
export const SpaceNotificationSettingsSchema = NotificationPreferencesSchema.extend({
|
|
93
115
|
userId: IdSchema,
|
|
94
116
|
spaceId: IdSchema,
|
|
95
117
|
});
|
|
118
|
+
/**
|
|
119
|
+
* Emoji d'un espace : un pictogramme (avec ses variantes, ses tons de peau et
|
|
120
|
+
* ses séquences jointes), ou un drapeau ; ni lettre ni espace.
|
|
121
|
+
*/
|
|
122
|
+
export const SpaceEmojiSchema = z
|
|
123
|
+
.string()
|
|
124
|
+
.trim()
|
|
125
|
+
.min(1, "Choisissez un emoji.")
|
|
126
|
+
.max(32, "Un seul emoji par espace.")
|
|
127
|
+
.refine((value) => /\p{Extended_Pictographic}|\p{Regional_Indicator}/u.test(value) && !/[\p{L}\s]/u.test(value), "Choisissez un emoji.")
|
|
128
|
+
.refine((value) => [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(value)].length === 1, "Un seul emoji par espace.");
|
|
129
|
+
/** Emoji de l'espace personnel, à sa création. */
|
|
130
|
+
export const PERSONAL_SPACE_EMOJI = "🏠";
|
|
131
|
+
/** Emojis parmi lesquels un espace commun reçoit le sien à sa création. */
|
|
132
|
+
export const SHARED_SPACE_EMOJIS = ["🚀", "🌱", "🎯", "🧩", "🛠️", "📚", "🎨", "🔭", "⚡", "🌊", "🔥", "🍀", "🎙️", "💡", "🧪", "🗺️"];
|
|
96
133
|
export const SpaceSchema = z.object({
|
|
97
134
|
id: IdSchema,
|
|
98
135
|
name: z.string().trim().min(1),
|
|
136
|
+
/** Emoji qui distingue l'espace (onglets du navigateur, sélecteur d'espace) ; null : aucun. */
|
|
137
|
+
emoji: SpaceEmojiSchema.nullable(),
|
|
99
138
|
kind: SpaceKindSchema,
|
|
100
139
|
ownerId: IdSchema,
|
|
101
140
|
keyPrefix: KeyPrefixSchema,
|
|
@@ -91,6 +91,16 @@ export declare const SettingsResponseSchema: z.ZodObject<{
|
|
|
91
91
|
longBreakMinutes: z.ZodNumber;
|
|
92
92
|
cycles: z.ZodNumber;
|
|
93
93
|
}, z.core.$strip>;
|
|
94
|
+
emailDigestMinutes: z.ZodNullable<z.ZodLiteral<5 | 15 | 30 | 60 | 120>>;
|
|
95
|
+
sidebarMode: z.ZodEnum<{
|
|
96
|
+
collapsed: "collapsed";
|
|
97
|
+
hover: "hover";
|
|
98
|
+
pinned: "pinned";
|
|
99
|
+
}>;
|
|
100
|
+
taskOpenMode: z.ZodEnum<{
|
|
101
|
+
page: "page";
|
|
102
|
+
preview: "preview";
|
|
103
|
+
}>;
|
|
94
104
|
email: z.ZodObject<{
|
|
95
105
|
enabled: z.ZodBoolean;
|
|
96
106
|
reason: z.ZodNullable<z.ZodString>;
|
|
@@ -115,6 +125,16 @@ export declare const UpdateSettingsRequestSchema: z.ZodObject<{
|
|
|
115
125
|
longBreakMinutes: z.ZodNumber;
|
|
116
126
|
cycles: z.ZodNumber;
|
|
117
127
|
}, z.core.$strip>>;
|
|
128
|
+
emailDigestMinutes: z.ZodOptional<z.ZodNullable<z.ZodLiteral<5 | 15 | 30 | 60 | 120>>>;
|
|
129
|
+
sidebarMode: z.ZodOptional<z.ZodEnum<{
|
|
130
|
+
collapsed: "collapsed";
|
|
131
|
+
hover: "hover";
|
|
132
|
+
pinned: "pinned";
|
|
133
|
+
}>>;
|
|
134
|
+
taskOpenMode: z.ZodOptional<z.ZodEnum<{
|
|
135
|
+
page: "page";
|
|
136
|
+
preview: "preview";
|
|
137
|
+
}>>;
|
|
118
138
|
}, z.core.$strict>;
|
|
119
139
|
export type UpdateSettingsRequest = z.infer<typeof UpdateSettingsRequestSchema>;
|
|
120
140
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ActorTypeSchema, NotificationTypeSchema } from "./enums.schema.js";
|
|
3
|
-
import { AssistantHistorySchema, IdSchema, NotificationPreferencesSchema, PomodoroSettingsSchema, TimestampSchema } from "./entities.schema.js";
|
|
3
|
+
import { AssistantHistorySchema, EmailDigestSchema, IdSchema, NotificationPreferencesSchema, PomodoroSettingsSchema, SidebarModeSchema, TaskOpenModeSchema, TimestampSchema } from "./entities.schema.js";
|
|
4
4
|
/** Corps des requêtes et des réponses des notifications et des paramètres de la GUI. */
|
|
5
5
|
/** Nombre de notifications renvoyées par défaut, et au plus, par page. */
|
|
6
6
|
export const NOTIFICATIONS_PAGE_SIZE = 20;
|
|
@@ -59,6 +59,12 @@ export const SettingsResponseSchema = z.object({
|
|
|
59
59
|
assistantHistory: AssistantHistorySchema,
|
|
60
60
|
/** Réglages pomodoro proposés au démarrage d'un chrono. */
|
|
61
61
|
pomodoro: PomodoroSettingsSchema,
|
|
62
|
+
/** Période du résumé des e-mails de notification, en minutes ; null : un e-mail par notification. */
|
|
63
|
+
emailDigestMinutes: EmailDigestSchema,
|
|
64
|
+
/** Affichage de la barre latérale : toujours visible, au survol, ou repliée en icônes. */
|
|
65
|
+
sidebarMode: SidebarModeSchema,
|
|
66
|
+
/** Ouverture d'une tâche par un clic simple sur sa carte : en pleine page ou dans l'aperçu latéral. */
|
|
67
|
+
taskOpenMode: TaskOpenModeSchema,
|
|
62
68
|
/** Envoi des e-mails de notification : `reason` dit pourquoi il n'a pas lieu. */
|
|
63
69
|
email: z.object({ enabled: z.boolean(), reason: z.string().nullable() }),
|
|
64
70
|
/** Dictée vocale : `reason` dit pourquoi elle est indisponible. */
|
|
@@ -74,6 +80,9 @@ export const UpdateSettingsRequestSchema = z
|
|
|
74
80
|
notifyFollowUpEmail: z.boolean().optional(),
|
|
75
81
|
assistantHistory: AssistantHistorySchema.optional(),
|
|
76
82
|
pomodoro: PomodoroSettingsSchema.optional(),
|
|
83
|
+
emailDigestMinutes: EmailDigestSchema.optional(),
|
|
84
|
+
sidebarMode: SidebarModeSchema.optional(),
|
|
85
|
+
taskOpenMode: TaskOpenModeSchema.optional(),
|
|
77
86
|
})
|
|
78
87
|
.strict()
|
|
79
88
|
.refine((patch) => Object.values(patch).some((value) => value !== undefined), "Aucune modification demandée.");
|
|
@@ -125,6 +125,11 @@ export declare const CreateBoardViewRequestSchema: z.ZodObject<{
|
|
|
125
125
|
}>>;
|
|
126
126
|
}, z.core.$strict>;
|
|
127
127
|
export type CreateBoardViewRequest = z.infer<typeof CreateBoardViewRequestSchema>;
|
|
128
|
+
/** Place de la vue parmi les onglets : juste après la vue `afterId`, ou en tête avec null (vue ouverte à l'arrivée sur l'espace). */
|
|
129
|
+
export declare const MoveBoardViewRequestSchema: z.ZodObject<{
|
|
130
|
+
afterId: z.ZodNullable<z.ZodString>;
|
|
131
|
+
}, z.core.$strict>;
|
|
132
|
+
export type MoveBoardViewRequest = z.infer<typeof MoveBoardViewRequestSchema>;
|
|
128
133
|
/** Réglages à changer ; la vue obtenue doit rester valide. */
|
|
129
134
|
export declare const UpdateBoardViewRequestSchema: z.ZodObject<{
|
|
130
135
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -35,6 +35,8 @@ export const BoardViewViewSchema = BoardViewSettingsSchema.extend({ id: IdSchema
|
|
|
35
35
|
export const BoardViewListResponseSchema = z.object({ views: z.array(BoardViewViewSchema) });
|
|
36
36
|
/** Les réglages d'une vue sont validés par le serveur, qui dit quel regroupement manque ou ne convient pas. */
|
|
37
37
|
export const CreateBoardViewRequestSchema = BoardViewSettingsSchema.strict();
|
|
38
|
+
/** Place de la vue parmi les onglets : juste après la vue `afterId`, ou en tête avec null (vue ouverte à l'arrivée sur l'espace). */
|
|
39
|
+
export const MoveBoardViewRequestSchema = z.object({ afterId: IdSchema.nullable() }).strict();
|
|
38
40
|
/** Réglages à changer ; la vue obtenue doit rester valide. */
|
|
39
41
|
export const UpdateBoardViewRequestSchema = BoardViewSettingsSchema.partial()
|
|
40
42
|
.strict()
|
|
@@ -93,8 +93,19 @@ function settingsPatch(store, space, input) {
|
|
|
93
93
|
types: input.types,
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
+
/** Place une vue de l'auteur juste après une autre de ses vues (`after_view`), ou en tête avec null. */
|
|
97
|
+
function placeView(tx, author, space, view, afterView) {
|
|
98
|
+
const after = afterView === null ? null : resolveView(tx.store, author, space, afterView);
|
|
99
|
+
return tx.moveBoardView(view.id, after?.id ?? null);
|
|
100
|
+
}
|
|
101
|
+
/** Place d'une vue dans les onglets de son membre, en français : « en tête », « après « Liste » ». */
|
|
102
|
+
function placeLabel(store, view) {
|
|
103
|
+
const views = store.listBoardViews(view.spaceId, view.userId);
|
|
104
|
+
const index = views.findIndex((other) => other.id === view.id);
|
|
105
|
+
return index <= 0 ? "placée en tête (ouverte par défaut)" : `placée après ${quote(views[index - 1].name)}`;
|
|
106
|
+
}
|
|
96
107
|
/** Résumé français des réglages changés d'une vue. */
|
|
97
|
-
function viewUpdateSummary(before, after) {
|
|
108
|
+
function viewUpdateSummary(store, before, after) {
|
|
98
109
|
const parts = [];
|
|
99
110
|
if (before.name !== after.name)
|
|
100
111
|
parts.push(`Renommée ${quote(after.name)}`);
|
|
@@ -118,6 +129,8 @@ function viewUpdateSummary(before, after) {
|
|
|
118
129
|
if (JSON.stringify(before.types) !== JSON.stringify(after.types)) {
|
|
119
130
|
parts.push(`Types : ${after.types.length > 0 ? after.types.map((type) => TYPE_LABELS[type]).join(", ") : "tous"}`);
|
|
120
131
|
}
|
|
132
|
+
if (before.position !== after.position)
|
|
133
|
+
parts.push(placeLabel(store, after));
|
|
121
134
|
return `Vue ${quote(before.name)} : ${parts.join(" · ") || "inchangée"}`;
|
|
122
135
|
}
|
|
123
136
|
export const viewRoutes = [
|
|
@@ -128,7 +141,7 @@ export const viewRoutes = [
|
|
|
128
141
|
const input = parseInput(ListViewsQuerySchema, query);
|
|
129
142
|
const { author, space } = requestAuthor(store, agent, input.request_id, "views");
|
|
130
143
|
const views = store.listBoardViews(space.id, author.id);
|
|
131
|
-
const header = `Board views of ${userLabel(author)} <${author.email}> in "${space.name}", in the order of their tabs:`;
|
|
144
|
+
const header = `Board views of ${userLabel(author)} <${author.email}> in "${space.name}", in the order of their tabs (the first one opens when they arrive in the space):`;
|
|
132
145
|
const lines = views.length > 0 ? views.map((view) => viewLine(store, view)) : ["(none yet: they get the default views \"Tableau\" and \"Liste\" when they open the board, or when you create a view)"];
|
|
133
146
|
return respond(ViewsDataSchema, [header, ...lines].join("\n"), { owner: ownerData(author), views: views.map((view) => viewData(store, view)) });
|
|
134
147
|
},
|
|
@@ -158,14 +171,15 @@ export const viewRoutes = [
|
|
|
158
171
|
};
|
|
159
172
|
requireGroupings(settings);
|
|
160
173
|
ensureBoardViews(tx, space.id, author.id);
|
|
161
|
-
const
|
|
174
|
+
const created = tx.createBoardView(space.id, author.id, settings);
|
|
175
|
+
const view = input.after_view === undefined ? created : placeView(tx, author, space, created, input.after_view);
|
|
162
176
|
tx.recordAgentAction({
|
|
163
177
|
entityType: "board_view",
|
|
164
178
|
entityId: view.id,
|
|
165
179
|
operation: "create",
|
|
166
180
|
before: null,
|
|
167
181
|
after: view,
|
|
168
|
-
summary: `Vue ${quote(view.name)} créée pour ${userLabel(author)}`,
|
|
182
|
+
summary: `Vue ${quote(view.name)} créée pour ${userLabel(author)}${input.after_view === undefined ? "" : `, ${placeLabel(tx.store, view)}`}`,
|
|
169
183
|
taskId: null,
|
|
170
184
|
});
|
|
171
185
|
return view;
|
|
@@ -189,8 +203,9 @@ export const viewRoutes = [
|
|
|
189
203
|
const view = resolveView(tx.store, author, space, params.viewId);
|
|
190
204
|
const patch = settingsPatch(tx.store, space, input);
|
|
191
205
|
requireGroupings({ layout: patch.layout ?? view.layout, groupBy: patch.groupBy ?? view.groupBy, thenBy: patch.thenBy ?? view.thenBy });
|
|
192
|
-
const
|
|
193
|
-
|
|
206
|
+
const changed = tx.updateBoardView(view.id, patch);
|
|
207
|
+
const updated = input.after_view === undefined ? changed : placeView(tx, author, space, changed, input.after_view);
|
|
208
|
+
tx.recordAgentAction({ entityType: "board_view", entityId: view.id, operation: "update", before: view, after: updated, summary: viewUpdateSummary(tx.store, view, updated), taskId: null });
|
|
194
209
|
return updated;
|
|
195
210
|
});
|
|
196
211
|
return respond(ViewDataSchema, `Updated view ${updated.id} of ${userLabel(author)}; their open dashboard switches to it.\n${viewLine(store, updated)}`, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoardViewSettings, Mutation, Store } from "./store.js";
|
|
2
|
-
import type { BoardViewListResponse, BoardViewView, CreateBoardViewRequest, UpdateBoardViewRequest } from "../../shared/schemas/views-api.schema.js";
|
|
2
|
+
import type { BoardViewListResponse, BoardViewView, CreateBoardViewRequest, MoveBoardViewRequest, UpdateBoardViewRequest } from "../../shared/schemas/views-api.schema.js";
|
|
3
3
|
/** Vues créées pour un membre qui n'en a aucune : le Kanban et la liste par statut, sans filtre. */
|
|
4
4
|
export declare const DEFAULT_BOARD_VIEWS: readonly BoardViewSettings[];
|
|
5
5
|
/** Réglages de regroupement refusés par une disposition. */
|
|
@@ -18,5 +18,10 @@ export declare function listBoardViews(store: Store, userId: string, spaceId: st
|
|
|
18
18
|
export declare function createBoardView(store: Store, userId: string, spaceId: string, input: CreateBoardViewRequest): BoardViewView;
|
|
19
19
|
/** Change les réglages d'une vue. */
|
|
20
20
|
export declare function updateBoardView(store: Store, userId: string, viewId: string, patch: UpdateBoardViewRequest): BoardViewView;
|
|
21
|
+
/**
|
|
22
|
+
* Déplace une vue parmi les onglets de l'utilisateur dans l'espace, juste
|
|
23
|
+
* après une autre ou en tête ; renvoie ses vues dans le nouvel ordre.
|
|
24
|
+
*/
|
|
25
|
+
export declare function moveBoardView(store: Store, userId: string, viewId: string, input: MoveBoardViewRequest): BoardViewListResponse;
|
|
21
26
|
/** Supprime une vue, sauf la dernière de l'utilisateur dans l'espace. */
|
|
22
27
|
export declare function deleteBoardView(store: Store, userId: string, viewId: string): void;
|
|
@@ -104,6 +104,20 @@ export function updateBoardView(store, userId, viewId, patch) {
|
|
|
104
104
|
});
|
|
105
105
|
return viewOf(view);
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Déplace une vue parmi les onglets de l'utilisateur dans l'espace, juste
|
|
109
|
+
* après une autre ou en tête ; renvoie ses vues dans le nouvel ordre.
|
|
110
|
+
*/
|
|
111
|
+
export function moveBoardView(store, userId, viewId, input) {
|
|
112
|
+
const spaceId = store.mutate(asUser(userId), (tx) => {
|
|
113
|
+
const view = requireOwnView(tx.store, viewId, userId);
|
|
114
|
+
if (input.afterId !== null)
|
|
115
|
+
requireOwnView(tx.store, input.afterId, userId);
|
|
116
|
+
tx.moveBoardView(view.id, input.afterId);
|
|
117
|
+
return view.spaceId;
|
|
118
|
+
});
|
|
119
|
+
return { views: store.listBoardViews(spaceId, userId).map(viewOf) };
|
|
120
|
+
}
|
|
107
121
|
/** Supprime une vue, sauf la dernière de l'utilisateur dans l'espace. */
|
|
108
122
|
export function deleteBoardView(store, userId, viewId) {
|
|
109
123
|
store.mutate(asUser(userId), (tx) => {
|
package/dist/src/core/history.js
CHANGED
|
@@ -321,6 +321,8 @@ function restore(tx, entityType, entityId, before) {
|
|
|
321
321
|
const view = BoardViewSchema.parse(before);
|
|
322
322
|
requireViewAssignees(tx, view);
|
|
323
323
|
tx.updateBoardView(entityId, viewSettings(view));
|
|
324
|
+
if (tx.store.getBoardView(entityId).position !== view.position)
|
|
325
|
+
tx.setBoardViewPosition(entityId, view.position);
|
|
324
326
|
return;
|
|
325
327
|
}
|
|
326
328
|
case "follow_up": {
|
|
@@ -774,6 +774,23 @@ export const MIGRATIONS = [
|
|
|
774
774
|
user_id TEXT NOT NULL REFERENCES users(id),
|
|
775
775
|
PRIMARY KEY (session_id, user_id)
|
|
776
776
|
);
|
|
777
|
+
`,
|
|
778
|
+
// Résumé périodique des e-mails de notification : période en minutes, NULL pour un e-mail par notification.
|
|
779
|
+
`
|
|
780
|
+
ALTER TABLE user_settings ADD COLUMN email_digest_minutes INTEGER CHECK (email_digest_minutes IN (5, 15, 30, 60, 120));
|
|
781
|
+
`,
|
|
782
|
+
// Affichage de la barre latérale : toujours visible, au survol du bord gauche, ou repliée en icônes.
|
|
783
|
+
`
|
|
784
|
+
ALTER TABLE user_settings ADD COLUMN sidebar_mode TEXT NOT NULL DEFAULT 'pinned' CHECK (sidebar_mode IN ('pinned', 'hover', 'collapsed'));
|
|
785
|
+
`,
|
|
786
|
+
// Emoji de chaque espace : la maison pour les espaces personnels, aucun pour les espaces communs existants.
|
|
787
|
+
`
|
|
788
|
+
ALTER TABLE spaces ADD COLUMN emoji TEXT;
|
|
789
|
+
UPDATE spaces SET emoji = '🏠' WHERE kind = 'personal';
|
|
790
|
+
`,
|
|
791
|
+
// Ouverture d'une tâche par un clic simple sur sa carte : en pleine page ou dans l'aperçu latéral.
|
|
792
|
+
`
|
|
793
|
+
ALTER TABLE user_settings ADD COLUMN task_open_mode TEXT NOT NULL DEFAULT 'page' CHECK (task_open_mode IN ('page', 'preview'));
|
|
777
794
|
`,
|
|
778
795
|
];
|
|
779
796
|
/** Version du schéma attendue par ce code. */
|
|
@@ -18,13 +18,19 @@ export interface NotificationMailDeps {
|
|
|
18
18
|
}
|
|
19
19
|
/** Raison pour laquelle les e-mails de notification ne partent pas, ou null s'ils peuvent partir. */
|
|
20
20
|
export declare function notificationEmailBlocker(deps: Pick<NotificationMailDeps, "mailer" | "publicUrl">): string | null;
|
|
21
|
+
/** Fin de la période de `minutes` minutes, alignée sur l'heure, qui contient l'instant `at`. */
|
|
22
|
+
export declare function digestPeriodEnd(at: number, minutes: number): number;
|
|
21
23
|
/**
|
|
22
24
|
* Envoi des e-mails de notification. Le store marque en base les
|
|
23
25
|
* notifications à envoyer par e-mail ; après chaque mutation qui peut en
|
|
24
|
-
* rendre prêtes, au démarrage et à l'échéance du prochain
|
|
25
|
-
* parcourt celles en attente
|
|
26
|
+
* rendre prêtes, au démarrage et à l'échéance du prochain envoi, l'envoi
|
|
27
|
+
* parcourt celles en attente. Pour un destinataire qui reçoit un résumé
|
|
28
|
+
* périodique (`emailDigestMinutes`), toutes ses notifications en attente
|
|
29
|
+
* partent dans un seul e-mail à la fin de la période, alignée sur l'heure, qui
|
|
30
|
+
* contient la plus ancienne. Pour les autres :
|
|
26
31
|
*
|
|
27
|
-
* -
|
|
32
|
+
* - celles des actions des utilisateurs partent aussitôt, dans un seul e-mail
|
|
33
|
+
* quand plusieurs sont prêtes en même temps ;
|
|
28
34
|
* - celles de l'agent sont regroupées par destinataire et par lot (la demande
|
|
29
35
|
* pour laquelle il agit) : un seul e-mail part quand la demande quitte
|
|
30
36
|
* `processing` (traitée, échouée, libérée), ou au plus tard `maxDelayMs`
|
|
@@ -55,7 +61,9 @@ export declare class NotificationMailer {
|
|
|
55
61
|
/** Envoie les e-mails prêts à partir et programme l'échéance du prochain lot en attente. */
|
|
56
62
|
sweep(): void;
|
|
57
63
|
private clearTimer;
|
|
58
|
-
/**
|
|
64
|
+
/** Répartit les notifications en attente, les plus anciennes d'abord, en e-mails. */
|
|
65
|
+
private group;
|
|
66
|
+
/** Vrai si le groupe peut partir : échéance atteinte, ou lot de l'agent dont la demande est close. */
|
|
59
67
|
private ready;
|
|
60
68
|
private enqueue;
|
|
61
69
|
/** Envoie un e-mail pour les notifications `ids`, d'un même destinataire, et enregistre son issue sur chacune. */
|
|
@@ -70,11 +78,19 @@ export declare class NotificationMailer {
|
|
|
70
78
|
* les points à traiter laissés à l'auteur de la demande.
|
|
71
79
|
*/
|
|
72
80
|
private digest;
|
|
81
|
+
/**
|
|
82
|
+
* E-mail qui regroupe des notifications quelconques d'un destinataire, d'un
|
|
83
|
+
* ou de plusieurs espaces : chaque tâche concernée avec ce qui la touche,
|
|
84
|
+
* qui l'a fait et son lien, puis chaque demande traitée avec les points
|
|
85
|
+
* laissés à son auteur.
|
|
86
|
+
*/
|
|
87
|
+
private summary;
|
|
73
88
|
/** E-mail de notification rendu dans le gabarit, avec les liens de l'espace et celui des préférences. */
|
|
74
89
|
private mail;
|
|
75
90
|
/** Textes des points encore ouverts d'une demande. */
|
|
76
91
|
private openPoints;
|
|
77
92
|
private taskUrl;
|
|
93
|
+
/** Adresse de la demande dans la page Agent de son espace. */
|
|
78
94
|
private requestUrl;
|
|
79
95
|
}
|
|
80
96
|
/** Notifications de l'utilisateur, non lues d'abord, par page. */
|
|
@@ -53,13 +53,22 @@ function userName(store, userId) {
|
|
|
53
53
|
function batched(notification) {
|
|
54
54
|
return notification.actorType === "agent" && notification.requestId !== null;
|
|
55
55
|
}
|
|
56
|
+
/** Fin de la période de `minutes` minutes, alignée sur l'heure, qui contient l'instant `at`. */
|
|
57
|
+
export function digestPeriodEnd(at, minutes) {
|
|
58
|
+
const period = minutes * 60_000;
|
|
59
|
+
return (Math.floor(at / period) + 1) * period;
|
|
60
|
+
}
|
|
56
61
|
/**
|
|
57
62
|
* Envoi des e-mails de notification. Le store marque en base les
|
|
58
63
|
* notifications à envoyer par e-mail ; après chaque mutation qui peut en
|
|
59
|
-
* rendre prêtes, au démarrage et à l'échéance du prochain
|
|
60
|
-
* parcourt celles en attente
|
|
64
|
+
* rendre prêtes, au démarrage et à l'échéance du prochain envoi, l'envoi
|
|
65
|
+
* parcourt celles en attente. Pour un destinataire qui reçoit un résumé
|
|
66
|
+
* périodique (`emailDigestMinutes`), toutes ses notifications en attente
|
|
67
|
+
* partent dans un seul e-mail à la fin de la période, alignée sur l'heure, qui
|
|
68
|
+
* contient la plus ancienne. Pour les autres :
|
|
61
69
|
*
|
|
62
|
-
* -
|
|
70
|
+
* - celles des actions des utilisateurs partent aussitôt, dans un seul e-mail
|
|
71
|
+
* quand plusieurs sont prêtes en même temps ;
|
|
63
72
|
* - celles de l'agent sont regroupées par destinataire et par lot (la demande
|
|
64
73
|
* pour laquelle il agit) : un seul e-mail part quand la demande quitte
|
|
65
74
|
* `processing` (traitée, échouée, libérée), ou au plus tard `maxDelayMs`
|
|
@@ -115,24 +124,20 @@ export class NotificationMailer {
|
|
|
115
124
|
this.deps.logError(`Listing the pending notification e-mails failed: ${err?.stack ?? err}`);
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
group.push(notification);
|
|
126
|
-
else
|
|
127
|
-
groups.set(key, [notification]);
|
|
127
|
+
let groups;
|
|
128
|
+
try {
|
|
129
|
+
groups = this.group(pending.filter((notification) => !this.sending.has(notification.id) && !this.abandoned.has(notification.id)));
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
this.deps.logError(`Grouping the pending notification e-mails failed: ${err?.stack ?? err}`);
|
|
133
|
+
return;
|
|
128
134
|
}
|
|
129
135
|
let next = Infinity;
|
|
130
|
-
for (const group of groups
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.enqueue(group.map((notification) => notification.id));
|
|
136
|
+
for (const group of groups) {
|
|
137
|
+
if (this.ready(group))
|
|
138
|
+
this.enqueue(group.kind, group.notifications.map((notification) => notification.id));
|
|
134
139
|
else
|
|
135
|
-
next = Math.min(next, deadline);
|
|
140
|
+
next = Math.min(next, group.deadline);
|
|
136
141
|
}
|
|
137
142
|
if (next < Infinity) {
|
|
138
143
|
this.timer = setTimeout(() => this.sweep(), Math.max(0, next - this.now()));
|
|
@@ -144,17 +149,42 @@ export class NotificationMailer {
|
|
|
144
149
|
clearTimeout(this.timer);
|
|
145
150
|
this.timer = null;
|
|
146
151
|
}
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
/** Répartit les notifications en attente, les plus anciennes d'abord, en e-mails. */
|
|
153
|
+
group(pending) {
|
|
154
|
+
const periods = new Map();
|
|
155
|
+
const groups = new Map();
|
|
156
|
+
for (const notification of pending) {
|
|
157
|
+
const { userId } = notification;
|
|
158
|
+
if (!periods.has(userId))
|
|
159
|
+
periods.set(userId, this.store.getUserSettings(userId).emailDigestMinutes);
|
|
160
|
+
const period = periods.get(userId);
|
|
161
|
+
const createdAt = Date.parse(notification.createdAt);
|
|
162
|
+
const [key, kind, deadline] = period !== null
|
|
163
|
+
? [`digest ${userId}`, "summary", digestPeriodEnd(createdAt, period)]
|
|
164
|
+
: batched(notification)
|
|
165
|
+
? [`batch ${userId} ${notification.requestId}`, "batch", createdAt + this.maxDelayMs]
|
|
166
|
+
: [`now ${userId}`, "summary", createdAt];
|
|
167
|
+
const group = groups.get(key);
|
|
168
|
+
if (group)
|
|
169
|
+
group.notifications.push(notification);
|
|
170
|
+
else
|
|
171
|
+
groups.set(key, { kind, notifications: [notification], deadline });
|
|
172
|
+
}
|
|
173
|
+
return [...groups.values()];
|
|
174
|
+
}
|
|
175
|
+
/** Vrai si le groupe peut partir : échéance atteinte, ou lot de l'agent dont la demande est close. */
|
|
176
|
+
ready(group) {
|
|
177
|
+
if (this.now() >= group.deadline)
|
|
150
178
|
return true;
|
|
151
|
-
|
|
179
|
+
if (group.kind !== "batch")
|
|
180
|
+
return false;
|
|
181
|
+
const request = this.store.findAgentRequest(group.notifications[0].requestId);
|
|
152
182
|
return request === null || request.status !== "processing";
|
|
153
183
|
}
|
|
154
|
-
enqueue(ids) {
|
|
184
|
+
enqueue(kind, ids) {
|
|
155
185
|
for (const id of ids)
|
|
156
186
|
this.sending.add(id);
|
|
157
|
-
const delivery = this.deliver(ids).finally(() => {
|
|
187
|
+
const delivery = this.deliver(kind, ids).finally(() => {
|
|
158
188
|
for (const id of ids)
|
|
159
189
|
this.sending.delete(id);
|
|
160
190
|
this.inFlight.delete(delivery);
|
|
@@ -162,12 +192,12 @@ export class NotificationMailer {
|
|
|
162
192
|
this.inFlight.add(delivery);
|
|
163
193
|
}
|
|
164
194
|
/** Envoie un e-mail pour les notifications `ids`, d'un même destinataire, et enregistre son issue sur chacune. */
|
|
165
|
-
async deliver(ids) {
|
|
195
|
+
async deliver(kind, ids) {
|
|
166
196
|
try {
|
|
167
197
|
const notifications = this.existing(ids);
|
|
168
198
|
if (notifications.length === 0)
|
|
169
199
|
return;
|
|
170
|
-
const outcome = await this.send(notifications);
|
|
200
|
+
const outcome = await this.send(kind, notifications);
|
|
171
201
|
// Une notification disparaît avec sa tâche ou son commentaire, éventuellement supprimés pendant l'envoi.
|
|
172
202
|
this.record(this.existing(ids), outcome);
|
|
173
203
|
}
|
|
@@ -194,12 +224,16 @@ export class NotificationMailer {
|
|
|
194
224
|
tx.recordNotificationEmail(notification.id, outcome);
|
|
195
225
|
});
|
|
196
226
|
}
|
|
197
|
-
async send(notifications) {
|
|
227
|
+
async send(kind, notifications) {
|
|
198
228
|
const blocker = notificationEmailBlocker(this.deps);
|
|
199
229
|
if (blocker)
|
|
200
230
|
return { sent: false, reason: blocker };
|
|
201
231
|
const recipient = this.store.getUser(notifications[0].userId);
|
|
202
|
-
const message = notifications.length === 1
|
|
232
|
+
const message = notifications.length === 1
|
|
233
|
+
? this.message(notifications[0], recipient.email)
|
|
234
|
+
: kind === "batch"
|
|
235
|
+
? this.digest(notifications, recipient.email)
|
|
236
|
+
: this.summary(notifications, recipient.email);
|
|
203
237
|
const outcome = await this.deps.mailer.send(message);
|
|
204
238
|
return outcome.sent ? { sent: true } : { sent: false, reason: outcome.reason };
|
|
205
239
|
}
|
|
@@ -307,6 +341,77 @@ export class NotificationMailer {
|
|
|
307
341
|
action: request ? { label: "Voir la demande", url: this.requestUrl(request.id) } : undefined,
|
|
308
342
|
});
|
|
309
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* E-mail qui regroupe des notifications quelconques d'un destinataire, d'un
|
|
346
|
+
* ou de plusieurs espaces : chaque tâche concernée avec ce qui la touche,
|
|
347
|
+
* qui l'a fait et son lien, puis chaque demande traitée avec les points
|
|
348
|
+
* laissés à son auteur.
|
|
349
|
+
*/
|
|
350
|
+
summary(notifications, to) {
|
|
351
|
+
const byTask = new Map();
|
|
352
|
+
const requestIds = new Set();
|
|
353
|
+
for (const notification of notifications) {
|
|
354
|
+
if (notification.taskId === null) {
|
|
355
|
+
requestIds.add(notification.requestId);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const list = byTask.get(notification.taskId);
|
|
359
|
+
if (list)
|
|
360
|
+
list.push(notification);
|
|
361
|
+
else
|
|
362
|
+
byTask.set(notification.taskId, [notification]);
|
|
363
|
+
}
|
|
364
|
+
const tasks = [...byTask.keys()].map((taskId) => this.store.getTask(taskId));
|
|
365
|
+
const requests = [...requestIds].map((requestId) => this.store.getAgentRequest(requestId));
|
|
366
|
+
const spaces = new Map();
|
|
367
|
+
for (const spaceId of [...tasks.map((task) => task.spaceId), ...requests.map((request) => request.targetSpaceId)]) {
|
|
368
|
+
if (!spaces.has(spaceId))
|
|
369
|
+
spaces.set(spaceId, this.store.getSpace(spaceId));
|
|
370
|
+
}
|
|
371
|
+
const single = spaces.size === 1 ? [...spaces.values()][0] : null;
|
|
372
|
+
const where = single ? `dans l'espace « ${single.name} »` : `dans ${spaces.size} espaces`;
|
|
373
|
+
const blocks = [{ type: "paragraph", content: [`${capitalize(notificationsLabel(notifications.length))} ${where}.`] }];
|
|
374
|
+
for (const task of tasks) {
|
|
375
|
+
const space = spaces.get(task.spaceId);
|
|
376
|
+
const taskUrl = this.taskUrl(task.id);
|
|
377
|
+
const items = byTask.get(task.id).map((notification) => {
|
|
378
|
+
const who = actorName(this.store, notification) ?? AGENT_NAME;
|
|
379
|
+
if (notification.type === "assigned")
|
|
380
|
+
return { label: `${who} vous a assigné cette tâche` };
|
|
381
|
+
const comment = notification.commentId === null ? null : this.store.findComment(notification.commentId);
|
|
382
|
+
const body = (comment?.body ?? "").trim();
|
|
383
|
+
return body ? { label: `${who} a commenté`, markdown: body } : { label: `${who} a commenté` };
|
|
384
|
+
});
|
|
385
|
+
blocks.push({
|
|
386
|
+
type: "section",
|
|
387
|
+
title: [{ strong: `${space.keyPrefix}-${task.number} « ${task.title} »` }, ...(single ? [] : [` · ${space.name}`])],
|
|
388
|
+
items,
|
|
389
|
+
link: { label: "Ouvrir la tâche", url: taskUrl },
|
|
390
|
+
links: { attachmentUrl: taskUrl, keyPrefixes: [space.keyPrefix], spaceId: space.id },
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
for (const request of requests) {
|
|
394
|
+
const space = spaces.get(request.targetSpaceId);
|
|
395
|
+
const requestUrl = this.requestUrl(request.id);
|
|
396
|
+
blocks.push({
|
|
397
|
+
type: "section",
|
|
398
|
+
title: [`${AGENT_NAME} a traité ta demande « ${requestExcerpt(request.text)} »${single ? "" : ` · ${space.name}`} : ${POINTS_TITLE.toLowerCase()}`],
|
|
399
|
+
items: this.openPoints(request.id).map((point) => ({ markdown: point })),
|
|
400
|
+
link: { label: "Voir la demande", url: requestUrl },
|
|
401
|
+
links: { attachmentUrl: requestUrl, keyPrefixes: [space.keyPrefix], spaceId: space.id },
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
const baseUrl = publicBase(this.deps.publicUrl);
|
|
405
|
+
const rendered = renderEmail({
|
|
406
|
+
subject: `Résumé : ${notificationsLabel(notifications.length)} ${where}`,
|
|
407
|
+
space: single?.name ?? null,
|
|
408
|
+
blocks,
|
|
409
|
+
footnote: UNSUBSCRIBE,
|
|
410
|
+
preferencesUrl: `${baseUrl}/#/parametres`,
|
|
411
|
+
links: { baseUrl, keyPrefixes: [...spaces.values()].map((space) => space.keyPrefix), spaceId: single?.id ?? null },
|
|
412
|
+
});
|
|
413
|
+
return { to, ...rendered };
|
|
414
|
+
}
|
|
310
415
|
/** E-mail de notification rendu dans le gabarit, avec les liens de l'espace et celui des préférences. */
|
|
311
416
|
mail(to, space, content) {
|
|
312
417
|
const baseUrl = publicBase(this.deps.publicUrl);
|
|
@@ -329,14 +434,20 @@ export class NotificationMailer {
|
|
|
329
434
|
taskUrl(taskId) {
|
|
330
435
|
return `${publicBase(this.deps.publicUrl)}/#/task/${encodeURIComponent(taskId)}`;
|
|
331
436
|
}
|
|
437
|
+
/** Adresse de la demande dans la page Agent de son espace. */
|
|
332
438
|
requestUrl(requestId) {
|
|
333
|
-
|
|
439
|
+
const { targetSpaceId } = this.store.getAgentRequest(requestId);
|
|
440
|
+
return `${publicBase(this.deps.publicUrl)}/#/espaces/${encodeURIComponent(targetSpaceId)}/agent/demande/${encodeURIComponent(requestId)}`;
|
|
334
441
|
}
|
|
335
442
|
}
|
|
336
443
|
/** « 1 notification », « 3 notifications ». */
|
|
337
444
|
function notificationsLabel(count) {
|
|
338
445
|
return `${count} notification${count > 1 ? "s" : ""}`;
|
|
339
446
|
}
|
|
447
|
+
/** Texte avec une majuscule initiale. */
|
|
448
|
+
function capitalize(text) {
|
|
449
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
450
|
+
}
|
|
340
451
|
/** « 1 point », « 3 points ». */
|
|
341
452
|
function pointsLabel(count) {
|
|
342
453
|
return `${count} point${count > 1 ? "s" : ""}`;
|
|
@@ -392,7 +503,7 @@ export function markAllNotificationsRead(store, userId) {
|
|
|
392
503
|
return unreadCount(store, userId);
|
|
393
504
|
}
|
|
394
505
|
function settingsView(store, deps, userId) {
|
|
395
|
-
const { notifyAssignApp, notifyAssignEmail, notifyCommentApp, notifyCommentEmail, notifyFollowUpApp, notifyFollowUpEmail, assistantHistory, pomodoro } = store.getUserSettings(userId);
|
|
506
|
+
const { notifyAssignApp, notifyAssignEmail, notifyCommentApp, notifyCommentEmail, notifyFollowUpApp, notifyFollowUpEmail, assistantHistory, pomodoro, emailDigestMinutes, sidebarMode, taskOpenMode, } = store.getUserSettings(userId);
|
|
396
507
|
const reason = notificationEmailBlocker(deps);
|
|
397
508
|
return {
|
|
398
509
|
notifyAssignApp,
|
|
@@ -403,6 +514,9 @@ function settingsView(store, deps, userId) {
|
|
|
403
514
|
notifyFollowUpEmail,
|
|
404
515
|
assistantHistory,
|
|
405
516
|
pomodoro,
|
|
517
|
+
emailDigestMinutes,
|
|
518
|
+
sidebarMode,
|
|
519
|
+
taskOpenMode,
|
|
406
520
|
email: { enabled: reason === null, reason },
|
|
407
521
|
transcription: { enabled: deps.transcriber.enabled, reason: deps.transcriber.disabledReason },
|
|
408
522
|
};
|
|
@@ -31,7 +31,14 @@ export declare function createSharedSpace(store: Store, userId: string, input: {
|
|
|
31
31
|
name: string;
|
|
32
32
|
keyPrefix?: string;
|
|
33
33
|
}): SpaceSummary;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Change le nom d'un espace commun ou l'emoji d'un espace, ce que seul son
|
|
36
|
+
* propriétaire peut faire ; l'emoji de l'espace personnel appartient à son titulaire.
|
|
37
|
+
*/
|
|
38
|
+
export declare function updateSpace(store: Store, userId: string, spaceId: string, patch: {
|
|
39
|
+
name?: string;
|
|
40
|
+
emoji?: string | null;
|
|
41
|
+
}): SpaceSummary;
|
|
35
42
|
/** Supprime un espace commun, son contenu et les fichiers de ses pièces jointes et de ses documents. */
|
|
36
43
|
export declare function deleteSpace(store: Store, storage: AttachmentStorage, userId: string, spaceId: string): void;
|
|
37
44
|
/** Membres (propriétaire d'abord) et invitations en attente d'un espace, pour un de ses membres. */
|