@imenam/mcp-organizer 0.0.0-stage → 1.0.2

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.
Files changed (165) hide show
  1. package/README.md +548 -3
  2. package/dist/shared/logic/first-account.d.ts +13 -0
  3. package/dist/shared/logic/first-account.js +15 -0
  4. package/dist/shared/logic/labels.d.ts +5 -0
  5. package/dist/shared/logic/labels.js +17 -0
  6. package/dist/shared/logic/positions.d.ts +9 -0
  7. package/dist/shared/logic/positions.js +19 -0
  8. package/dist/shared/logic/spaces.d.ts +13 -0
  9. package/dist/shared/logic/spaces.js +48 -0
  10. package/dist/shared/logic/test-summary.d.ts +28 -0
  11. package/dist/shared/logic/test-summary.js +35 -0
  12. package/dist/shared/schemas/agent-api.schema.d.ts +269 -0
  13. package/dist/shared/schemas/agent-api.schema.js +97 -0
  14. package/dist/shared/schemas/agent-tools.schema.d.ts +818 -0
  15. package/dist/shared/schemas/agent-tools.schema.js +198 -0
  16. package/dist/shared/schemas/api.schema.d.ts +249 -0
  17. package/dist/shared/schemas/api.schema.js +116 -0
  18. package/dist/shared/schemas/entities.schema.d.ts +472 -0
  19. package/dist/shared/schemas/entities.schema.js +262 -0
  20. package/dist/shared/schemas/enums.schema.d.ts +135 -0
  21. package/dist/shared/schemas/enums.schema.js +58 -0
  22. package/dist/shared/schemas/gui-api.schema.d.ts +53 -0
  23. package/dist/shared/schemas/gui-api.schema.js +20 -0
  24. package/dist/shared/schemas/ideas-api.schema.d.ts +81 -0
  25. package/dist/shared/schemas/ideas-api.schema.js +40 -0
  26. package/dist/shared/schemas/notifications-api.schema.d.ts +87 -0
  27. package/dist/shared/schemas/notifications-api.schema.js +58 -0
  28. package/dist/shared/schemas/tasks-api.schema.d.ts +675 -0
  29. package/dist/shared/schemas/tasks-api.schema.js +225 -0
  30. package/dist/shared/schemas/tokens-api.schema.d.ts +106 -0
  31. package/dist/shared/schemas/tokens-api.schema.js +42 -0
  32. package/dist/shared/schemas/transcription-api.schema.d.ts +15 -0
  33. package/dist/shared/schemas/transcription-api.schema.js +12 -0
  34. package/dist/src/agent-api/checklist.d.ts +3 -0
  35. package/dist/src/agent-api/checklist.js +127 -0
  36. package/dist/src/agent-api/ideas.d.ts +3 -0
  37. package/dist/src/agent-api/ideas.js +93 -0
  38. package/dist/src/agent-api/notifications.d.ts +16 -0
  39. package/dist/src/agent-api/notifications.js +91 -0
  40. package/dist/src/agent-api/requests.d.ts +3 -0
  41. package/dist/src/agent-api/requests.js +60 -0
  42. package/dist/src/agent-api/router.d.ts +3 -0
  43. package/dist/src/agent-api/router.js +41 -0
  44. package/dist/src/agent-api/tasks.d.ts +2 -0
  45. package/dist/src/agent-api/tasks.js +290 -0
  46. package/dist/src/agent-api/types.d.ts +41 -0
  47. package/dist/src/agent-api/types.js +14 -0
  48. package/dist/src/cli/backup.d.ts +12 -0
  49. package/dist/src/cli/backup.js +126 -0
  50. package/dist/src/cli/prompt.d.ts +7 -0
  51. package/dist/src/cli/prompt.js +40 -0
  52. package/dist/src/cli/set-user.d.ts +2 -0
  53. package/dist/src/cli/set-user.js +114 -0
  54. package/dist/src/cli/setup-mcp.d.ts +10 -0
  55. package/dist/src/cli/setup-mcp.js +110 -0
  56. package/dist/src/cli/setup.d.ts +39 -0
  57. package/dist/src/cli/setup.js +626 -0
  58. package/dist/src/cli/watch.d.ts +4 -0
  59. package/dist/src/cli/watch.js +62 -0
  60. package/dist/src/core/accounts.d.ts +129 -0
  61. package/dist/src/core/accounts.js +284 -0
  62. package/dist/src/core/agent-tokens.d.ts +31 -0
  63. package/dist/src/core/agent-tokens.js +120 -0
  64. package/dist/src/core/agent.d.ts +71 -0
  65. package/dist/src/core/agent.js +358 -0
  66. package/dist/src/core/attachments.d.ts +21 -0
  67. package/dist/src/core/attachments.js +44 -0
  68. package/dist/src/core/data-dir.d.ts +5 -0
  69. package/dist/src/core/data-dir.js +11 -0
  70. package/dist/src/core/db.d.ts +13 -0
  71. package/dist/src/core/db.js +38 -0
  72. package/dist/src/core/env-file.d.ts +11 -0
  73. package/dist/src/core/env-file.js +36 -0
  74. package/dist/src/core/errors.d.ts +24 -0
  75. package/dist/src/core/errors.js +42 -0
  76. package/dist/src/core/history.d.ts +34 -0
  77. package/dist/src/core/history.js +279 -0
  78. package/dist/src/core/ideas.d.ts +16 -0
  79. package/dist/src/core/ideas.js +100 -0
  80. package/dist/src/core/ids.d.ts +2 -0
  81. package/dist/src/core/ids.js +5 -0
  82. package/dist/src/core/log-dir.d.ts +2 -0
  83. package/dist/src/core/log-dir.js +9 -0
  84. package/dist/src/core/logger.d.ts +14 -0
  85. package/dist/src/core/logger.js +37 -0
  86. package/dist/src/core/mail.d.ts +43 -0
  87. package/dist/src/core/mail.js +44 -0
  88. package/dist/src/core/mcp-entry.d.ts +20 -0
  89. package/dist/src/core/mcp-entry.js +15 -0
  90. package/dist/src/core/migrations.d.ts +18 -0
  91. package/dist/src/core/migrations.js +404 -0
  92. package/dist/src/core/native-sqlite.d.ts +2 -0
  93. package/dist/src/core/native-sqlite.js +23 -0
  94. package/dist/src/core/notifications.d.ts +46 -0
  95. package/dist/src/core/notifications.js +173 -0
  96. package/dist/src/core/project-root.d.ts +2 -0
  97. package/dist/src/core/project-root.js +13 -0
  98. package/dist/src/core/requests.d.ts +50 -0
  99. package/dist/src/core/requests.js +240 -0
  100. package/dist/src/core/snapshots.d.ts +32 -0
  101. package/dist/src/core/snapshots.js +35 -0
  102. package/dist/src/core/spaces.d.ts +66 -0
  103. package/dist/src/core/spaces.js +252 -0
  104. package/dist/src/core/store.d.ts +577 -0
  105. package/dist/src/core/store.js +2119 -0
  106. package/dist/src/core/task-history.d.ts +7 -0
  107. package/dist/src/core/task-history.js +41 -0
  108. package/dist/src/core/tasks.d.ts +58 -0
  109. package/dist/src/core/tasks.js +389 -0
  110. package/dist/src/core/test-tasks.d.ts +19 -0
  111. package/dist/src/core/test-tasks.js +135 -0
  112. package/dist/src/core/transcription.d.ts +45 -0
  113. package/dist/src/core/transcription.js +92 -0
  114. package/dist/src/core/watchers.d.ts +30 -0
  115. package/dist/src/core/watchers.js +50 -0
  116. package/dist/src/deploy/env-render.d.ts +26 -0
  117. package/dist/src/deploy/env-render.js +98 -0
  118. package/dist/src/deploy/templates.d.ts +38 -0
  119. package/dist/src/deploy/templates.js +130 -0
  120. package/dist/src/gui-api.d.ts +37 -0
  121. package/dist/src/gui-api.js +383 -0
  122. package/dist/src/index.d.ts +2 -0
  123. package/dist/src/index.js +110 -0
  124. package/dist/src/mcp/client.d.ts +38 -0
  125. package/dist/src/mcp/client.js +106 -0
  126. package/dist/src/mcp/notifications.d.ts +13 -0
  127. package/dist/src/mcp/notifications.js +54 -0
  128. package/dist/src/mcp/start.d.ts +14 -0
  129. package/dist/src/mcp/start.js +123 -0
  130. package/dist/src/mcp/tools.d.ts +46 -0
  131. package/dist/src/mcp/tools.js +348 -0
  132. package/dist/src/mcp/watch-handoff.d.ts +35 -0
  133. package/dist/src/mcp/watch-handoff.js +91 -0
  134. package/dist/src/server/app.d.ts +25 -0
  135. package/dist/src/server/app.js +305 -0
  136. package/dist/src/server/config.d.ts +23 -0
  137. package/dist/src/server/config.js +75 -0
  138. package/dist/src/server/limits.d.ts +2 -0
  139. package/dist/src/server/limits.js +4 -0
  140. package/dist/src/server/login-limiter.d.ts +36 -0
  141. package/dist/src/server/login-limiter.js +81 -0
  142. package/dist/src/server/start.d.ts +5 -0
  143. package/dist/src/server/start.js +88 -0
  144. package/dist/src/version.d.ts +1 -0
  145. package/dist/src/version.js +16 -0
  146. package/gui/dist/assets/index-BVN0agCc.css +1 -0
  147. package/gui/dist/assets/index-DI1_kr81.js +70 -0
  148. package/gui/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  149. package/gui/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  150. package/gui/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  151. package/gui/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  152. package/gui/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  153. package/gui/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  154. package/gui/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  155. package/gui/dist/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  156. package/gui/dist/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  157. package/gui/dist/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  158. package/gui/dist/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  159. package/gui/dist/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  160. package/gui/dist/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  161. package/gui/dist/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  162. package/gui/dist/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  163. package/gui/dist/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  164. package/gui/dist/index.html +13 -0
  165. package/package.json +66 -4
@@ -0,0 +1,198 @@
1
+ import { z } from "zod";
2
+ import { MemberRoleSchema, REQUEST_STATUSES, RequestKindSchema, RequestStatusSchema, SpaceKindSchema, TASK_PRIORITIES, TASK_STATUSES, TASK_TYPES, TaskPrioritySchema, TaskStatusSchema, TaskTypeSchema, TestResultValueSchema, } from "./enums.schema.js";
3
+ import { IdSchema, TimestampSchema } from "./entities.schema.js";
4
+ import { MAX_TAG_LENGTH, MAX_TASK_TITLE_LENGTH } from "./tasks-api.schema.js";
5
+ /**
6
+ * API des agents (`/api/agent/*`), partagée par le site et le mode MCP :
7
+ * paramètres et corps des requêtes (noms des arguments des outils), et
8
+ * réponses. Chaque réponse porte `text`, le résultat rédigé pour l'agent, et
9
+ * `data`, les mêmes informations structurées. Une erreur est `{ error }`.
10
+ */
11
+ export const MAX_REQUEST_LIST_LIMIT = 100;
12
+ export const MAX_SEARCH_LIMIT = 100;
13
+ export const MAX_REPLY_LENGTH = 5_000;
14
+ export const MAX_REASON_LENGTH = 2_000;
15
+ export const MAX_COMMENT_LENGTH = 10_000;
16
+ export const MAX_IDEA_LENGTH = 5_000;
17
+ export const MAX_CHECKLIST_ITEM_LENGTH = 500;
18
+ export const MAX_CHECKLIST_OPERATIONS = 50;
19
+ const RequestIdSchema = z.string().min(1);
20
+ const RefSchema = z.string().min(1);
21
+ // --- Paramètres et corps -----------------------------------------------------------
22
+ /** `GET requests` : statut à lister (`all` : tous) et nombre maximal. */
23
+ export const ListRequestsQuerySchema = z
24
+ .object({
25
+ status: z.enum([...REQUEST_STATUSES, "all"]).default("pending"),
26
+ limit: z.coerce.number().int().min(1).max(MAX_REQUEST_LIST_LIMIT).default(20),
27
+ })
28
+ .strict();
29
+ /** Durée maximale d'une attente longue de `GET requests/wait`, en secondes. */
30
+ export const MAX_WAIT_SECONDS = 50;
31
+ /**
32
+ * `GET requests/wait` : durée de l'attente ; `since`, curseur rendu par
33
+ * l'attente précédente (les demandes passées en attente depuis sont rendues
34
+ * aussitôt) ; `watcher=true` pour un veilleur de notifications.
35
+ */
36
+ export const WaitRequestsQuerySchema = z
37
+ .object({
38
+ timeout_seconds: z.coerce.number().int().min(1).max(MAX_WAIT_SECONDS).default(30),
39
+ since: TimestampSchema.optional(),
40
+ watcher: z.enum(["true"]).optional(),
41
+ })
42
+ .strict();
43
+ /** `POST requests/:id/claim` : sans corps. */
44
+ export const ClaimRequestBodySchema = z.object({}).strict();
45
+ export const CompleteRequestBodySchema = z.object({ reply: z.string().max(MAX_REPLY_LENGTH) }).strict();
46
+ export const FailRequestBodySchema = z.object({ reason: z.string().max(MAX_REASON_LENGTH) }).strict();
47
+ /** `GET tasks` : recherche par mots et filtres. */
48
+ export const SearchTasksQuerySchema = z
49
+ .object({
50
+ query: z.string().optional(),
51
+ status: z.enum(TASK_STATUSES).optional(),
52
+ priority: z.enum(TASK_PRIORITIES).optional(),
53
+ type: z.enum(TASK_TYPES).optional(),
54
+ assignee: z.string().min(1).optional(),
55
+ limit: z.coerce.number().int().min(1).max(MAX_SEARCH_LIMIT).default(30),
56
+ })
57
+ .strict();
58
+ /** `GET tasks/:ref` et `GET context` : sans paramètre. */
59
+ export const NoQuerySchema = z.object({}).strict();
60
+ export const CreateTaskBodySchema = z
61
+ .object({
62
+ request_id: RequestIdSchema,
63
+ title: z.string().max(MAX_TASK_TITLE_LENGTH),
64
+ description: z.string().optional(),
65
+ type: z.enum(TASK_TYPES).optional(),
66
+ priority: z.enum(TASK_PRIORITIES).optional(),
67
+ status: z.enum(TASK_STATUSES).optional(),
68
+ parent: RefSchema.optional(),
69
+ })
70
+ .strict();
71
+ export const UpdateTaskBodySchema = z
72
+ .object({
73
+ request_id: RequestIdSchema,
74
+ title: z.string().max(MAX_TASK_TITLE_LENGTH).optional(),
75
+ description: z.string().optional(),
76
+ status: z.enum(TASK_STATUSES).optional(),
77
+ priority: z.enum(TASK_PRIORITIES).optional(),
78
+ type: z.enum(TASK_TYPES).optional(),
79
+ parent: RefSchema.nullable().optional(),
80
+ after_task: RefSchema.nullable().optional(),
81
+ tested_task_id: RefSchema.nullable().optional(),
82
+ })
83
+ .strict();
84
+ export const SetAssigneesBodySchema = z.object({ request_id: RequestIdSchema, assignees: z.array(z.string().min(1)) }).strict();
85
+ export const SetTagsBodySchema = z.object({ request_id: RequestIdSchema, tags: z.array(z.string().trim().min(1).max(MAX_TAG_LENGTH)) }).strict();
86
+ const ChecklistTextSchema = z.string().trim().min(1).max(MAX_CHECKLIST_ITEM_LENGTH);
87
+ export const ChecklistOperationSchema = z.discriminatedUnion("action", [
88
+ z.object({ action: z.literal("add"), text: ChecklistTextSchema }).strict(),
89
+ z.object({ action: z.literal("update"), item_id: z.string().min(1), text: ChecklistTextSchema.optional(), done: z.boolean().optional() }).strict(),
90
+ z.object({ action: z.literal("delete"), item_id: z.string().min(1) }).strict(),
91
+ ]);
92
+ export const EditChecklistBodySchema = z
93
+ .object({ request_id: RequestIdSchema, operations: z.array(ChecklistOperationSchema).min(1).max(MAX_CHECKLIST_OPERATIONS) })
94
+ .strict();
95
+ export const AddCommentBodySchema = z.object({ request_id: RequestIdSchema, body: z.string().max(MAX_COMMENT_LENGTH) }).strict();
96
+ export const CreateIdeaBodySchema = z.object({ request_id: RequestIdSchema, text: z.string().max(MAX_IDEA_LENGTH) }).strict();
97
+ export const UpdateIdeaBodySchema = z
98
+ .object({ request_id: RequestIdSchema, text: z.string().max(MAX_IDEA_LENGTH).optional(), archived: z.boolean().optional() })
99
+ .strict();
100
+ export const PromoteIdeaBodySchema = z
101
+ .object({
102
+ request_id: RequestIdSchema,
103
+ title: z.string().max(MAX_TASK_TITLE_LENGTH),
104
+ description: z.string().optional(),
105
+ type: z.enum(TASK_TYPES).optional(),
106
+ priority: z.enum(TASK_PRIORITIES).optional(),
107
+ parent: RefSchema.optional(),
108
+ })
109
+ .strict();
110
+ // --- Réponses ---------------------------------------------------------------------
111
+ /** Enveloppe de toute réponse réussie : texte pour l'agent et données structurées. */
112
+ export const AgentEnvelopeSchema = z.object({ text: z.string(), data: z.unknown() });
113
+ /** Réponse d'erreur : le message dit à l'agent quoi faire. */
114
+ export const AgentErrorSchema = z.object({ error: z.string() });
115
+ export const AgentSpaceSchema = z.object({ id: IdSchema, name: z.string(), kind: SpaceKindSchema, keyPrefix: z.string() });
116
+ export const AgentMemberSchema = z.object({ id: IdSchema, name: z.string(), email: z.string(), role: MemberRoleSchema });
117
+ export const AgentTaskSummarySchema = z.object({
118
+ id: IdSchema,
119
+ key: z.string(),
120
+ title: z.string(),
121
+ type: TaskTypeSchema,
122
+ status: TaskStatusSchema,
123
+ priority: TaskPrioritySchema,
124
+ depth: z.number().int().min(0),
125
+ parentKey: z.string().nullable(),
126
+ assigneeIds: z.array(IdSchema),
127
+ tags: z.array(z.string()),
128
+ });
129
+ export const AgentRequestSummarySchema = z.object({
130
+ id: IdSchema,
131
+ kind: RequestKindSchema,
132
+ status: RequestStatusSchema,
133
+ text: z.string(),
134
+ author: z.object({ id: IdSchema, name: z.string(), email: z.string() }),
135
+ contextTask: z.object({ id: IdSchema, key: z.string(), title: z.string() }).nullable(),
136
+ contextIdeaId: IdSchema.nullable(),
137
+ createdAt: TimestampSchema,
138
+ claimedAt: TimestampSchema.nullable(),
139
+ /** Vrai si la demande est prise par le jeton qui appelle. */
140
+ claimedByThisToken: z.boolean(),
141
+ reply: z.string().nullable(),
142
+ failureReason: z.string().nullable(),
143
+ });
144
+ export const AgentIdeaSchema = z.object({ id: IdSchema, text: z.string(), archived: z.boolean(), promotedTaskKey: z.string().nullable(), createdAt: TimestampSchema });
145
+ export const ListRequestsDataSchema = z.object({ space: AgentSpaceSchema, requests: z.array(AgentRequestSummarySchema) });
146
+ export const ClaimRequestDataSchema = z.object({
147
+ request: AgentRequestSummarySchema,
148
+ space: AgentSpaceSchema,
149
+ members: z.array(AgentMemberSchema),
150
+ tasks: z.array(AgentTaskSummarySchema),
151
+ ideas: z.array(AgentIdeaSchema),
152
+ });
153
+ export const FinishRequestDataSchema = z.object({ request: AgentRequestSummarySchema, actionCount: z.number().int().min(0) });
154
+ export const ContextDataSchema = z.object({
155
+ space: AgentSpaceSchema,
156
+ members: z.array(AgentMemberSchema),
157
+ tasks: z.array(AgentTaskSummarySchema),
158
+ ideas: z.array(AgentIdeaSchema),
159
+ });
160
+ export const TaskDataSchema = z.object({ task: AgentTaskSummarySchema });
161
+ export const TaskDetailDataSchema = z.object({
162
+ task: AgentTaskSummarySchema,
163
+ description: z.string(),
164
+ testedTaskKey: z.string().nullable(),
165
+ checklist: z.array(z.object({ id: IdSchema, text: z.string(), done: z.boolean() })),
166
+ checkpoints: z.array(z.object({ id: IdSchema, text: z.string(), result: TestResultValueSchema })),
167
+ children: z.array(AgentTaskSummarySchema),
168
+ comments: z.array(z.object({ id: IdSchema, authorName: z.string(), byAgent: z.boolean(), body: z.string(), createdAt: TimestampSchema })),
169
+ attachments: z.array(z.string()),
170
+ });
171
+ export const SearchTasksDataSchema = z.object({ tasks: z.array(AgentTaskSummarySchema), total: z.number().int().min(0) });
172
+ export const ChecklistDataSchema = z.object({
173
+ task: AgentTaskSummarySchema,
174
+ /** Éléments de la checklist (tâche standard, `done` renseigné) ou points de vérification (tâche de test, `done` nul). */
175
+ items: z.array(z.object({ id: IdSchema, text: z.string(), done: z.boolean().nullable() })),
176
+ });
177
+ export const CommentDataSchema = z.object({ task: AgentTaskSummarySchema, commentId: IdSchema });
178
+ export const IdeaDataSchema = z.object({ idea: AgentIdeaSchema });
179
+ export const PromoteIdeaDataSchema = z.object({ idea: AgentIdeaSchema, task: AgentTaskSummarySchema });
180
+ /** Présence d'un veilleur de notifications pour le jeton. */
181
+ export const AgentWatcherSchema = z.object({ armed: z.boolean(), since: TimestampSchema.nullable(), lastSeen: TimestampSchema.nullable() });
182
+ /** `GET notifications` : jeton et espace de l'agent, demandes en attente et veilleur du jeton. */
183
+ export const NotificationsDataSchema = z.object({
184
+ token: z.object({ id: IdSchema, name: z.string() }),
185
+ space: AgentSpaceSchema,
186
+ pendingCount: z.number().int().min(0),
187
+ watcher: AgentWatcherSchema,
188
+ });
189
+ /**
190
+ * `GET requests/wait` : demandes passées en attente (vide à l'expiration) et
191
+ * curseur à repasser en `since` à l'attente suivante.
192
+ */
193
+ export const WaitRequestsDataSchema = z.object({
194
+ space: AgentSpaceSchema,
195
+ requests: z.array(AgentRequestSummarySchema),
196
+ cursor: TimestampSchema,
197
+ timedOut: z.boolean(),
198
+ });
@@ -0,0 +1,249 @@
1
+ import { z } from "zod";
2
+ /** Corps des requêtes et des réponses de l'API `/api/*` de la GUI. */
3
+ /** Longueur minimale d'un mot de passe. */
4
+ export declare const MIN_PASSWORD_LENGTH = 8;
5
+ /** Longueur maximale d'un nom affiché ou d'un nom d'espace. */
6
+ export declare const MAX_NAME_LENGTH = 80;
7
+ export declare const PasswordSchema: z.ZodString;
8
+ export declare const DisplayNameSchema: z.ZodString;
9
+ export declare const SpaceNameSchema: z.ZodString;
10
+ /** Utilisateur tel que la GUI le voit : jamais de hash de mot de passe. */
11
+ export declare const PublicUserSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
14
+ displayName: z.ZodNullable<z.ZodString>;
15
+ status: z.ZodEnum<{
16
+ active: "active";
17
+ disabled: "disabled";
18
+ invited: "invited";
19
+ }>;
20
+ }, z.core.$strip>;
21
+ export type PublicUser = z.infer<typeof PublicUserSchema>;
22
+ export declare const LoginRequestSchema: z.ZodObject<{
23
+ email: z.ZodString;
24
+ password: z.ZodString;
25
+ }, z.core.$strip>;
26
+ export type LoginRequest = z.infer<typeof LoginRequestSchema>;
27
+ export declare const MeResponseSchema: z.ZodObject<{
28
+ user: z.ZodObject<{
29
+ id: z.ZodString;
30
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
31
+ displayName: z.ZodNullable<z.ZodString>;
32
+ status: z.ZodEnum<{
33
+ active: "active";
34
+ disabled: "disabled";
35
+ invited: "invited";
36
+ }>;
37
+ }, z.core.$strip>;
38
+ }, z.core.$strip>;
39
+ export type MeResponse = z.infer<typeof MeResponseSchema>;
40
+ /** Lien d'accès valide : compte concerné et objet du lien. */
41
+ export declare const AccessLinkInfoSchema: z.ZodObject<{
42
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
43
+ purpose: z.ZodEnum<{
44
+ invite: "invite";
45
+ reset: "reset";
46
+ }>;
47
+ displayName: z.ZodNullable<z.ZodString>;
48
+ expiresAt: z.ZodISODateTime;
49
+ }, z.core.$strip>;
50
+ export type AccessLinkInfo = z.infer<typeof AccessLinkInfoSchema>;
51
+ export declare const ActivateRequestSchema: z.ZodObject<{
52
+ displayName: z.ZodString;
53
+ password: z.ZodString;
54
+ }, z.core.$strip>;
55
+ export type ActivateRequest = z.infer<typeof ActivateRequestSchema>;
56
+ /** Profil : nouveau nom affiché. */
57
+ export declare const UpdateProfileRequestSchema: z.ZodObject<{
58
+ displayName: z.ZodString;
59
+ }, z.core.$strip>;
60
+ export type UpdateProfileRequest = z.infer<typeof UpdateProfileRequestSchema>;
61
+ /** Profil : changement de mot de passe, avec l'ancien. */
62
+ export declare const ChangePasswordRequestSchema: z.ZodObject<{
63
+ currentPassword: z.ZodString;
64
+ newPassword: z.ZodString;
65
+ }, z.core.$strip>;
66
+ export type ChangePasswordRequest = z.infer<typeof ChangePasswordRequestSchema>;
67
+ export declare const OkResponseSchema: z.ZodObject<{
68
+ ok: z.ZodLiteral<true>;
69
+ }, z.core.$strip>;
70
+ export type OkResponse = z.infer<typeof OkResponseSchema>;
71
+ /** Espace vu par un de ses membres, avec son rôle. */
72
+ export declare const SpaceSummarySchema: z.ZodObject<{
73
+ id: z.ZodString;
74
+ name: z.ZodString;
75
+ kind: z.ZodEnum<{
76
+ personal: "personal";
77
+ shared: "shared";
78
+ }>;
79
+ keyPrefix: z.ZodString;
80
+ ownerId: z.ZodString;
81
+ role: z.ZodEnum<{
82
+ member: "member";
83
+ owner: "owner";
84
+ }>;
85
+ }, z.core.$strip>;
86
+ export type SpaceSummary = z.infer<typeof SpaceSummarySchema>;
87
+ export declare const SpaceListResponseSchema: z.ZodObject<{
88
+ spaces: z.ZodArray<z.ZodObject<{
89
+ id: z.ZodString;
90
+ name: z.ZodString;
91
+ kind: z.ZodEnum<{
92
+ personal: "personal";
93
+ shared: "shared";
94
+ }>;
95
+ keyPrefix: z.ZodString;
96
+ ownerId: z.ZodString;
97
+ role: z.ZodEnum<{
98
+ member: "member";
99
+ owner: "owner";
100
+ }>;
101
+ }, z.core.$strip>>;
102
+ }, z.core.$strip>;
103
+ export type SpaceListResponse = z.infer<typeof SpaceListResponseSchema>;
104
+ export declare const CreateSpaceRequestSchema: z.ZodObject<{
105
+ name: z.ZodString;
106
+ keyPrefix: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
107
+ }, z.core.$strip>;
108
+ export type CreateSpaceRequest = z.infer<typeof CreateSpaceRequestSchema>;
109
+ export declare const RenameSpaceRequestSchema: z.ZodObject<{
110
+ name: z.ZodString;
111
+ }, z.core.$strip>;
112
+ export type RenameSpaceRequest = z.infer<typeof RenameSpaceRequestSchema>;
113
+ export declare const MemberViewSchema: z.ZodObject<{
114
+ userId: z.ZodString;
115
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
116
+ displayName: z.ZodNullable<z.ZodString>;
117
+ role: z.ZodEnum<{
118
+ member: "member";
119
+ owner: "owner";
120
+ }>;
121
+ }, z.core.$strip>;
122
+ export type MemberView = z.infer<typeof MemberViewSchema>;
123
+ export declare const PendingInvitationViewSchema: z.ZodObject<{
124
+ id: z.ZodString;
125
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
126
+ createdAt: z.ZodISODateTime;
127
+ expiresAt: z.ZodISODateTime;
128
+ expired: z.ZodBoolean;
129
+ }, z.core.$strip>;
130
+ export type PendingInvitationView = z.infer<typeof PendingInvitationViewSchema>;
131
+ export declare const MembersResponseSchema: z.ZodObject<{
132
+ space: z.ZodObject<{
133
+ id: z.ZodString;
134
+ name: z.ZodString;
135
+ kind: z.ZodEnum<{
136
+ personal: "personal";
137
+ shared: "shared";
138
+ }>;
139
+ keyPrefix: z.ZodString;
140
+ ownerId: z.ZodString;
141
+ role: z.ZodEnum<{
142
+ member: "member";
143
+ owner: "owner";
144
+ }>;
145
+ }, z.core.$strip>;
146
+ members: z.ZodArray<z.ZodObject<{
147
+ userId: z.ZodString;
148
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
149
+ displayName: z.ZodNullable<z.ZodString>;
150
+ role: z.ZodEnum<{
151
+ member: "member";
152
+ owner: "owner";
153
+ }>;
154
+ }, z.core.$strip>>;
155
+ invitations: z.ZodArray<z.ZodObject<{
156
+ id: z.ZodString;
157
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
158
+ createdAt: z.ZodISODateTime;
159
+ expiresAt: z.ZodISODateTime;
160
+ expired: z.ZodBoolean;
161
+ }, z.core.$strip>>;
162
+ }, z.core.$strip>;
163
+ export type MembersResponse = z.infer<typeof MembersResponseSchema>;
164
+ export declare const InviteRequestSchema: z.ZodObject<{
165
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
166
+ }, z.core.$strip>;
167
+ export type InviteRequest = z.infer<typeof InviteRequestSchema>;
168
+ /** Lien d'activation d'un compte invité. `path` est relatif à la GUI, qui en forme l'adresse complète. */
169
+ export declare const InvitationLinkSchema: z.ZodObject<{
170
+ path: z.ZodString;
171
+ expiresAt: z.ZodISODateTime;
172
+ }, z.core.$strip>;
173
+ export type InvitationLink = z.infer<typeof InvitationLinkSchema>;
174
+ /** Envoi de l'e-mail d'invitation : `reason` explique un envoi qui n'a pas eu lieu. */
175
+ export declare const EmailOutcomeSchema: z.ZodObject<{
176
+ emailSent: z.ZodBoolean;
177
+ reason: z.ZodNullable<z.ZodString>;
178
+ }, z.core.$strip>;
179
+ export type EmailOutcome = z.infer<typeof EmailOutcomeSchema>;
180
+ export declare const InviteResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
181
+ outcome: z.ZodLiteral<"member_added">;
182
+ member: z.ZodObject<{
183
+ userId: z.ZodString;
184
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
185
+ displayName: z.ZodNullable<z.ZodString>;
186
+ role: z.ZodEnum<{
187
+ member: "member";
188
+ owner: "owner";
189
+ }>;
190
+ }, z.core.$strip>;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ outcome: z.ZodLiteral<"invited">;
193
+ invitation: z.ZodObject<{
194
+ id: z.ZodString;
195
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
196
+ createdAt: z.ZodISODateTime;
197
+ expiresAt: z.ZodISODateTime;
198
+ expired: z.ZodBoolean;
199
+ }, z.core.$strip>;
200
+ link: z.ZodObject<{
201
+ path: z.ZodString;
202
+ expiresAt: z.ZodISODateTime;
203
+ }, z.core.$strip>;
204
+ email: z.ZodObject<{
205
+ emailSent: z.ZodBoolean;
206
+ reason: z.ZodNullable<z.ZodString>;
207
+ }, z.core.$strip>;
208
+ }, z.core.$strip>], "outcome">;
209
+ export type InviteResponse = z.infer<typeof InviteResponseSchema>;
210
+ /** Invitation renvoyée : nouvelle échéance, et nouveau lien d'activation pour un compte encore à activer (null pour un compte actif). */
211
+ export declare const ResendInvitationResponseSchema: z.ZodObject<{
212
+ invitation: z.ZodObject<{
213
+ id: z.ZodString;
214
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
215
+ createdAt: z.ZodISODateTime;
216
+ expiresAt: z.ZodISODateTime;
217
+ expired: z.ZodBoolean;
218
+ }, z.core.$strip>;
219
+ link: z.ZodNullable<z.ZodObject<{
220
+ path: z.ZodString;
221
+ expiresAt: z.ZodISODateTime;
222
+ }, z.core.$strip>>;
223
+ email: z.ZodObject<{
224
+ emailSent: z.ZodBoolean;
225
+ reason: z.ZodNullable<z.ZodString>;
226
+ }, z.core.$strip>;
227
+ }, z.core.$strip>;
228
+ export type ResendInvitationResponse = z.infer<typeof ResendInvitationResponseSchema>;
229
+ /** Invitation en attente reçue par l'utilisateur connecté. */
230
+ export declare const ReceivedInvitationViewSchema: z.ZodObject<{
231
+ id: z.ZodString;
232
+ spaceId: z.ZodString;
233
+ spaceName: z.ZodString;
234
+ invitedByName: z.ZodString;
235
+ createdAt: z.ZodISODateTime;
236
+ expiresAt: z.ZodISODateTime;
237
+ }, z.core.$strip>;
238
+ export type ReceivedInvitationView = z.infer<typeof ReceivedInvitationViewSchema>;
239
+ export declare const ReceivedInvitationsResponseSchema: z.ZodObject<{
240
+ invitations: z.ZodArray<z.ZodObject<{
241
+ id: z.ZodString;
242
+ spaceId: z.ZodString;
243
+ spaceName: z.ZodString;
244
+ invitedByName: z.ZodString;
245
+ createdAt: z.ZodISODateTime;
246
+ expiresAt: z.ZodISODateTime;
247
+ }, z.core.$strip>>;
248
+ }, z.core.$strip>;
249
+ export type ReceivedInvitationsResponse = z.infer<typeof ReceivedInvitationsResponseSchema>;
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ import { AccessLinkPurposeSchema, MemberRoleSchema, SpaceKindSchema, UserStatusSchema } from "./enums.schema.js";
3
+ import { EmailSchema, IdSchema, KeyPrefixSchema, TimestampSchema } from "./entities.schema.js";
4
+ /** Corps des requêtes et des réponses de l'API `/api/*` de la GUI. */
5
+ /** Longueur minimale d'un mot de passe. */
6
+ export const MIN_PASSWORD_LENGTH = 8;
7
+ /** Longueur maximale d'un nom affiché ou d'un nom d'espace. */
8
+ export const MAX_NAME_LENGTH = 80;
9
+ export const PasswordSchema = z.string().min(MIN_PASSWORD_LENGTH, `Le mot de passe doit faire au moins ${MIN_PASSWORD_LENGTH} caractères.`);
10
+ export const DisplayNameSchema = z.string().trim().min(1, "Le nom affiché est requis.").max(MAX_NAME_LENGTH);
11
+ export const SpaceNameSchema = z.string().trim().min(1, "Le nom de l'espace est requis.").max(MAX_NAME_LENGTH);
12
+ /** Utilisateur tel que la GUI le voit : jamais de hash de mot de passe. */
13
+ export const PublicUserSchema = z.object({
14
+ id: IdSchema,
15
+ email: EmailSchema,
16
+ displayName: z.string().nullable(),
17
+ status: UserStatusSchema,
18
+ });
19
+ // --- Authentification ---
20
+ export const LoginRequestSchema = z.object({
21
+ email: z.string().trim().min(1, "L'adresse e-mail est requise."),
22
+ password: z.string().min(1, "Le mot de passe est requis."),
23
+ });
24
+ export const MeResponseSchema = z.object({ user: PublicUserSchema });
25
+ /** Lien d'accès valide : compte concerné et objet du lien. */
26
+ export const AccessLinkInfoSchema = z.object({
27
+ email: EmailSchema,
28
+ purpose: AccessLinkPurposeSchema,
29
+ displayName: z.string().nullable(),
30
+ expiresAt: TimestampSchema,
31
+ });
32
+ export const ActivateRequestSchema = z.object({
33
+ displayName: DisplayNameSchema,
34
+ password: PasswordSchema,
35
+ });
36
+ /** Profil : nouveau nom affiché. */
37
+ export const UpdateProfileRequestSchema = z.object({ displayName: DisplayNameSchema });
38
+ /** Profil : changement de mot de passe, avec l'ancien. */
39
+ export const ChangePasswordRequestSchema = z.object({
40
+ currentPassword: z.string().min(1, "Le mot de passe actuel est requis."),
41
+ newPassword: PasswordSchema,
42
+ });
43
+ export const OkResponseSchema = z.object({ ok: z.literal(true) });
44
+ // --- Espaces ---
45
+ /** Espace vu par un de ses membres, avec son rôle. */
46
+ export const SpaceSummarySchema = z.object({
47
+ id: IdSchema,
48
+ name: z.string(),
49
+ kind: SpaceKindSchema,
50
+ keyPrefix: KeyPrefixSchema,
51
+ ownerId: IdSchema,
52
+ role: MemberRoleSchema,
53
+ });
54
+ export const SpaceListResponseSchema = z.object({ spaces: z.array(SpaceSummarySchema) });
55
+ export const CreateSpaceRequestSchema = z.object({
56
+ name: SpaceNameSchema,
57
+ /** Préfixe des numéros de tâche ; dérivé du nom s'il est omis. */
58
+ keyPrefix: z.string().trim().toUpperCase().pipe(KeyPrefixSchema).optional(),
59
+ });
60
+ export const RenameSpaceRequestSchema = z.object({ name: SpaceNameSchema });
61
+ export const MemberViewSchema = z.object({
62
+ userId: IdSchema,
63
+ email: EmailSchema,
64
+ displayName: z.string().nullable(),
65
+ role: MemberRoleSchema,
66
+ });
67
+ export const PendingInvitationViewSchema = z.object({
68
+ id: IdSchema,
69
+ email: EmailSchema,
70
+ createdAt: TimestampSchema,
71
+ expiresAt: TimestampSchema,
72
+ expired: z.boolean(),
73
+ });
74
+ export const MembersResponseSchema = z.object({
75
+ space: SpaceSummarySchema,
76
+ members: z.array(MemberViewSchema),
77
+ invitations: z.array(PendingInvitationViewSchema),
78
+ });
79
+ export const InviteRequestSchema = z.object({
80
+ email: z.string().trim().toLowerCase().min(1, "L'adresse e-mail est requise.").pipe(z.email("Adresse e-mail invalide.")),
81
+ });
82
+ /** Lien d'activation d'un compte invité. `path` est relatif à la GUI, qui en forme l'adresse complète. */
83
+ export const InvitationLinkSchema = z.object({
84
+ path: z.string().min(1),
85
+ expiresAt: TimestampSchema,
86
+ });
87
+ /** Envoi de l'e-mail d'invitation : `reason` explique un envoi qui n'a pas eu lieu. */
88
+ export const EmailOutcomeSchema = z.object({
89
+ emailSent: z.boolean(),
90
+ reason: z.string().nullable(),
91
+ });
92
+ export const InviteResponseSchema = z.discriminatedUnion("outcome", [
93
+ z.object({ outcome: z.literal("member_added"), member: MemberViewSchema }),
94
+ z.object({
95
+ outcome: z.literal("invited"),
96
+ invitation: PendingInvitationViewSchema,
97
+ link: InvitationLinkSchema,
98
+ email: EmailOutcomeSchema,
99
+ }),
100
+ ]);
101
+ /** Invitation renvoyée : nouvelle échéance, et nouveau lien d'activation pour un compte encore à activer (null pour un compte actif). */
102
+ export const ResendInvitationResponseSchema = z.object({
103
+ invitation: PendingInvitationViewSchema,
104
+ link: InvitationLinkSchema.nullable(),
105
+ email: EmailOutcomeSchema,
106
+ });
107
+ /** Invitation en attente reçue par l'utilisateur connecté. */
108
+ export const ReceivedInvitationViewSchema = z.object({
109
+ id: IdSchema,
110
+ spaceId: IdSchema,
111
+ spaceName: z.string(),
112
+ invitedByName: z.string(),
113
+ createdAt: TimestampSchema,
114
+ expiresAt: TimestampSchema,
115
+ });
116
+ export const ReceivedInvitationsResponseSchema = z.object({ invitations: z.array(ReceivedInvitationViewSchema) });