@deveye/types 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/package.json +68 -0
  4. package/src/domain/audience.ts +549 -0
  5. package/src/domain/backup.ts +355 -0
  6. package/src/domain/credential.ts +55 -0
  7. package/src/domain/database.ts +467 -0
  8. package/src/domain/deploy.ts +231 -0
  9. package/src/domain/device.ts +172 -0
  10. package/src/domain/deviceFiles.ts +84 -0
  11. package/src/domain/deviceLogs.ts +82 -0
  12. package/src/domain/featureRegistry.ts +392 -0
  13. package/src/domain/finance.ts +477 -0
  14. package/src/domain/git.ts +419 -0
  15. package/src/domain/home.ts +314 -0
  16. package/src/domain/live.ts +272 -0
  17. package/src/domain/logs.ts +117 -0
  18. package/src/domain/mail.ts +394 -0
  19. package/src/domain/metrics.ts +127 -0
  20. package/src/domain/note.ts +202 -0
  21. package/src/domain/notifications.ts +268 -0
  22. package/src/domain/packages.ts +35 -0
  23. package/src/domain/password.ts +36 -0
  24. package/src/domain/presence.ts +21 -0
  25. package/src/domain/project.ts +168 -0
  26. package/src/domain/projectBoard.ts +130 -0
  27. package/src/domain/projectChat.ts +46 -0
  28. package/src/domain/projectHistory.ts +82 -0
  29. package/src/domain/projectLink.ts +87 -0
  30. package/src/domain/projectPlan.ts +68 -0
  31. package/src/domain/report.ts +492 -0
  32. package/src/domain/role.ts +8 -0
  33. package/src/domain/secrecy.ts +66 -0
  34. package/src/domain/sentinel.ts +623 -0
  35. package/src/domain/sharing.ts +186 -0
  36. package/src/domain/syncProtocol.ts +116 -0
  37. package/src/domain/twoFactor.ts +40 -0
  38. package/src/domain/uptime.ts +216 -0
  39. package/src/domain/user.ts +141 -0
  40. package/src/domain/workspace.ts +56 -0
  41. package/src/domain/workspaceRole.ts +251 -0
  42. package/src/features/admin.ts +112 -0
  43. package/src/features/audience.ts +275 -0
  44. package/src/features/backup.ts +230 -0
  45. package/src/features/database.ts +461 -0
  46. package/src/features/deploy.ts +245 -0
  47. package/src/features/device.ts +292 -0
  48. package/src/features/deviceFiles.ts +83 -0
  49. package/src/features/deviceLogs.ts +36 -0
  50. package/src/features/deviceTerminal.ts +57 -0
  51. package/src/features/finance.ts +360 -0
  52. package/src/features/git.ts +368 -0
  53. package/src/features/home.ts +32 -0
  54. package/src/features/live.ts +113 -0
  55. package/src/features/logs.ts +86 -0
  56. package/src/features/mail.ts +374 -0
  57. package/src/features/metrics.ts +185 -0
  58. package/src/features/note.ts +189 -0
  59. package/src/features/notify.ts +164 -0
  60. package/src/features/password.ts +67 -0
  61. package/src/features/project.ts +709 -0
  62. package/src/features/registry.ts +103 -0
  63. package/src/features/secrecy.ts +120 -0
  64. package/src/features/sentinel.ts +233 -0
  65. package/src/features/sharing.ts +79 -0
  66. package/src/features/twoFactor.ts +47 -0
  67. package/src/features/uptime.ts +186 -0
  68. package/src/features/user.ts +91 -0
  69. package/src/features/workspace.ts +200 -0
  70. package/src/http/auth.ts +94 -0
  71. package/src/http/device.ts +222 -0
  72. package/src/http/status.ts +45 -0
  73. package/src/index.ts +1700 -0
  74. package/src/protocol/agent.ts +1171 -0
  75. package/src/protocol/envelope.ts +46 -0
  76. package/src/protocol/error.ts +27 -0
  77. package/src/protocol/result.ts +17 -0
  78. package/src/protocol/version.ts +6 -0
  79. package/src/sdk/client-ambient.d.ts +238 -0
  80. package/src/sdk/client.ts +66 -0
  81. package/src/sdk/ids.ts +25 -0
  82. package/src/sdk/index.ts +11 -0
  83. package/src/sdk/manifest.ts +326 -0
  84. package/src/sdk/providers.ts +48 -0
  85. package/src/sdk/server.ts +378 -0
  86. package/src/sdk/testing.ts +179 -0
  87. package/src/utils/version.ts +28 -0
@@ -0,0 +1,360 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ FINANCE_COUNTERPARTY_MAX_LENGTH,
4
+ FINANCE_LABEL_MAX_LENGTH,
5
+ FINANCE_NAME_MAX_LENGTH,
6
+ FINANCE_NOTE_MAX_LENGTH,
7
+ financeAccountKindSchema,
8
+ financeAccountSchema,
9
+ financeAmountSchema,
10
+ financeBalanceSchema,
11
+ financeBudgetPeriodSchema,
12
+ financeBudgetSchema,
13
+ financeCategorySchema,
14
+ financeColorSchema,
15
+ financeConfigSchema,
16
+ financeDateSchema,
17
+ financeFlowSchema,
18
+ financeFrequencySchema,
19
+ financeOverviewSchema,
20
+ financeRangeSchema,
21
+ financeRecurringSchema,
22
+ financeSummarySchema,
23
+ financeTransactionKindSchema,
24
+ financeTransactionSchema
25
+ } from '../domain/finance';
26
+ /**
27
+ * Commandes des finances de l'espace.
28
+ *
29
+ * L'espace visé n'apparaît dans aucune entrée: il voyage sur l'enveloppe WS
30
+ * (voir `protocol/envelope`) et le dispatcheur le résout avant le handler.
31
+ *
32
+ * ⚠️ Préfixe unique `finance.` et verbes en camelCase, comme `git`, `database`
33
+ * et `audience`: le filet `MUTATION_VERB` de `_topics.ts` ne voit **aucune** de
34
+ * ces commandes, donc les `mutates` du serveur se relisent à la main. Les huit
35
+ * lectures sont `config`, `summary`, `accountList`, `categoryList`,
36
+ * `transactionList`, `budgetList`, `recurringList` et `overview`; tout le reste
37
+ * écrit.
38
+ */
39
+ const accountId = z.number().int().positive();
40
+ const categoryId = z.number().int().positive();
41
+ const transactionId = z.number().int().positive();
42
+ const budgetId = z.number().int().positive();
43
+ const recurringId = z.number().int().positive();
44
+ /* ------------------------------------------------------------------ *
45
+ * Réglages
46
+ * ------------------------------------------------------------------ */
47
+ /**
48
+ * Les réglages de l'espace. Jamais gardés derrière un droit d'écriture: toute
49
+ * lecture en a besoin (ne serait-ce que pour formater un montant), et la
50
+ * première ouverture de la feature crée la ligne par défaut si elle manque.
51
+ */
52
+ export const financeConfig = {
53
+ command: 'finance.config' as const,
54
+ input: z.object({}),
55
+ output: z.object({ config: financeConfigSchema })
56
+ };
57
+ export const financeConfigUpdate = {
58
+ command: 'finance.configUpdate' as const,
59
+ input: z.object({ config: financeConfigSchema }),
60
+ output: z.object({ config: financeConfigSchema })
61
+ };
62
+ /** Ce que lit la carte de l'accueil, et rien de plus. */
63
+ export const financeSummary = {
64
+ command: 'finance.summary' as const,
65
+ input: z.object({}),
66
+ output: z.object({ summary: financeSummarySchema })
67
+ };
68
+ /* ------------------------------------------------------------------ *
69
+ * Comptes
70
+ * ------------------------------------------------------------------ */
71
+ const accountDraftSchema = z.object({
72
+ name: z.string().min(1).max(FINANCE_NAME_MAX_LENGTH),
73
+ kind: financeAccountKindSchema,
74
+ color: financeColorSchema,
75
+ initialBalance: financeBalanceSchema,
76
+ note: z.string().max(FINANCE_NOTE_MAX_LENGTH),
77
+ archived: z.boolean()
78
+ });
79
+ /**
80
+ * Les comptes de l'espace, soldes compris. `archived` inclut ceux qu'on a mis
81
+ * de côté; sans lui la liste ne rend que les comptes vivants, ce dont ont besoin
82
+ * tous les sélecteurs.
83
+ */
84
+ export const financeAccountList = {
85
+ command: 'finance.accountList' as const,
86
+ input: z.object({ archived: z.boolean().optional() }),
87
+ output: z.object({ accounts: z.array(financeAccountSchema) })
88
+ };
89
+ export const financeAccountAdd = {
90
+ command: 'finance.accountAdd' as const,
91
+ input: z.object({ account: accountDraftSchema }),
92
+ output: z.object({ account: financeAccountSchema })
93
+ };
94
+ export const financeAccountUpdate = {
95
+ command: 'finance.accountUpdate' as const,
96
+ input: z.object({ accountId, account: accountDraftSchema }),
97
+ output: z.object({ account: financeAccountSchema })
98
+ };
99
+ /**
100
+ * Supprime un compte. Refusé (`conflict`) tant qu'il porte des opérations: les
101
+ * effacer avec lui ferait disparaître de l'argent d'un livre de comptes sans
102
+ * autre trace, et le seul geste réversible existe déjà (l'archivage).
103
+ */
104
+ export const financeAccountRemove = {
105
+ command: 'finance.accountRemove' as const,
106
+ input: z.object({ accountId }),
107
+ output: z.object({ accountId })
108
+ };
109
+ export const financeAccountReorder = {
110
+ command: 'finance.accountReorder' as const,
111
+ input: z.object({ accountIds: z.array(accountId).min(1) }),
112
+ output: z.object({ accountIds: z.array(accountId) })
113
+ };
114
+ /* ------------------------------------------------------------------ *
115
+ * Catégories
116
+ * ------------------------------------------------------------------ */
117
+ const categoryDraftSchema = z.object({
118
+ name: z.string().min(1).max(FINANCE_NAME_MAX_LENGTH),
119
+ flow: financeFlowSchema,
120
+ color: financeColorSchema,
121
+ icon: z.string().max(40)
122
+ });
123
+ export const financeCategoryList = {
124
+ command: 'finance.categoryList' as const,
125
+ input: z.object({}),
126
+ output: z.object({ categories: z.array(financeCategorySchema) })
127
+ };
128
+ export const financeCategoryAdd = {
129
+ command: 'finance.categoryAdd' as const,
130
+ input: z.object({ category: categoryDraftSchema }),
131
+ output: z.object({ category: financeCategorySchema })
132
+ };
133
+ export const financeCategoryUpdate = {
134
+ command: 'finance.categoryUpdate' as const,
135
+ input: z.object({ categoryId, category: categoryDraftSchema }),
136
+ output: z.object({ category: financeCategorySchema })
137
+ };
138
+ /**
139
+ * Supprime une catégorie. Les opérations qu'elle classait ne sont pas touchées:
140
+ * elles retombent simplement dans « Sans catégorie » (`ON DELETE SET NULL`).
141
+ * Les budgets posés dessus, eux, disparaissent avec elle: une enveloppe sans
142
+ * catégorie ne veut plus rien dire.
143
+ */
144
+ export const financeCategoryRemove = {
145
+ command: 'finance.categoryRemove' as const,
146
+ input: z.object({ categoryId }),
147
+ output: z.object({ categoryId })
148
+ };
149
+ export const financeCategoryReorder = {
150
+ command: 'finance.categoryReorder' as const,
151
+ input: z.object({ categoryIds: z.array(categoryId).min(1) }),
152
+ output: z.object({ categoryIds: z.array(categoryId) })
153
+ };
154
+ /* ------------------------------------------------------------------ *
155
+ * Opérations
156
+ * ------------------------------------------------------------------ */
157
+ const transactionDraftSchema = z.object({
158
+ accountId,
159
+ kind: financeTransactionKindSchema,
160
+ amount: financeAmountSchema,
161
+ date: financeDateSchema,
162
+ label: z.string().max(FINANCE_LABEL_MAX_LENGTH),
163
+ categoryId: categoryId.nullable(),
164
+ transferAccountId: accountId.nullable(),
165
+ counterparty: z.string().max(FINANCE_COUNTERPARTY_MAX_LENGTH),
166
+ note: z.string().max(FINANCE_NOTE_MAX_LENGTH),
167
+ vatAmount: financeAmountSchema.nullable(),
168
+ cleared: z.boolean()
169
+ });
170
+ /**
171
+ * Le journal, filtré et paginé.
172
+ *
173
+ * Toute la sélection est faite en SQL sur des colonnes en clair. La **recherche
174
+ * textuelle** n'y figure pas et ne peut pas y figurer: l'intitulé et le tiers
175
+ * sont chiffrés, donc aucun `LIKE` ne les atteint. Le client filtre ce qu'il a
176
+ * chargé, ce qui est honnête tant que la fenêtre est bornée par une période.
177
+ *
178
+ * `totals` porte les sommes de l'**ensemble** du filtre, pas de la page: sans
179
+ * ça, un total qui ne compte que 50 lignes sur 300 induit en erreur.
180
+ */
181
+ export const financeTransactionList = {
182
+ command: 'finance.transactionList' as const,
183
+ input: z.object({
184
+ accountId: accountId.optional(),
185
+ categoryId: categoryId.optional(),
186
+ kind: financeTransactionKindSchema.optional(),
187
+ /** Premier jour compris. */
188
+ from: financeDateSchema.optional(),
189
+ /** Dernier jour compris. */
190
+ to: financeDateSchema.optional(),
191
+ /** Ne rendre que les non pointées, ou que les pointées. */
192
+ cleared: z.boolean().optional(),
193
+ limit: z.number().int().positive().max(500).optional(),
194
+ offset: z.number().int().nonnegative().optional()
195
+ }),
196
+ output: z.object({
197
+ transactions: z.array(financeTransactionSchema),
198
+ /** Nombre total de lignes correspondant au filtre, toutes pages confondues. */
199
+ total: z.number().int().nonnegative(),
200
+ totals: z.object({
201
+ income: financeAmountSchema,
202
+ expense: financeAmountSchema,
203
+ net: financeBalanceSchema
204
+ })
205
+ })
206
+ };
207
+ export const financeTransactionAdd = {
208
+ command: 'finance.transactionAdd' as const,
209
+ input: z.object({ transaction: transactionDraftSchema }),
210
+ output: z.object({ transaction: financeTransactionSchema })
211
+ };
212
+ export const financeTransactionUpdate = {
213
+ command: 'finance.transactionUpdate' as const,
214
+ input: z.object({ transactionId, transaction: transactionDraftSchema }),
215
+ output: z.object({ transaction: financeTransactionSchema })
216
+ };
217
+ export const financeTransactionRemove = {
218
+ command: 'finance.transactionRemove' as const,
219
+ input: z.object({ transactionId }),
220
+ output: z.object({ transactionId })
221
+ };
222
+ /**
223
+ * Pointe ou dépointe une opération, sans toucher au reste.
224
+ *
225
+ * Commande à part plutôt qu'un passage par `transactionUpdate`: pointer est un
226
+ * clic sur une ligne, répété des dizaines de fois d'affilée au moment du
227
+ * rapprochement bancaire. Le faire passer par la modification complète
228
+ * imposerait de déchiffrer puis rechiffrer le contenu à chaque clic, pour un
229
+ * booléen qui est en clair.
230
+ */
231
+ export const financeTransactionSetCleared = {
232
+ command: 'finance.transactionSetCleared' as const,
233
+ input: z.object({
234
+ transactionIds: z.array(transactionId).min(1).max(500),
235
+ cleared: z.boolean()
236
+ }),
237
+ output: z.object({ transactionIds: z.array(transactionId), cleared: z.boolean() })
238
+ };
239
+ /* ------------------------------------------------------------------ *
240
+ * Budgets
241
+ * ------------------------------------------------------------------ */
242
+ export const financeBudgetList = {
243
+ command: 'finance.budgetList' as const,
244
+ input: z.object({}),
245
+ output: z.object({ budgets: z.array(financeBudgetSchema) })
246
+ };
247
+ /**
248
+ * Pose ou remplace l'enveloppe d'une catégorie. Une seule par catégorie, d'où
249
+ * un `budgetSet` plutôt qu'un couple ajout / modification: deux enveloppes sur
250
+ * la même catégorie n'auraient aucun sens et il faudrait ensuite les départager.
251
+ */
252
+ export const financeBudgetSet = {
253
+ command: 'finance.budgetSet' as const,
254
+ input: z.object({ categoryId, amount: financeAmountSchema, period: financeBudgetPeriodSchema }),
255
+ output: z.object({ budget: financeBudgetSchema })
256
+ };
257
+ export const financeBudgetRemove = {
258
+ command: 'finance.budgetRemove' as const,
259
+ input: z.object({ budgetId }),
260
+ output: z.object({ budgetId })
261
+ };
262
+ /* ------------------------------------------------------------------ *
263
+ * Échéances
264
+ * ------------------------------------------------------------------ */
265
+ const recurringDraftSchema = z.object({
266
+ accountId,
267
+ kind: financeTransactionKindSchema,
268
+ amount: financeAmountSchema,
269
+ label: z.string().max(FINANCE_LABEL_MAX_LENGTH),
270
+ categoryId: categoryId.nullable(),
271
+ transferAccountId: accountId.nullable(),
272
+ counterparty: z.string().max(FINANCE_COUNTERPARTY_MAX_LENGTH),
273
+ note: z.string().max(FINANCE_NOTE_MAX_LENGTH),
274
+ vatAmount: financeAmountSchema.nullable(),
275
+ frequency: financeFrequencySchema,
276
+ interval: z.number().int().positive().max(60),
277
+ nextDate: financeDateSchema,
278
+ endDate: financeDateSchema.nullable(),
279
+ automatic: z.boolean(),
280
+ active: z.boolean()
281
+ });
282
+ export const financeRecurringList = {
283
+ command: 'finance.recurringList' as const,
284
+ input: z.object({}),
285
+ output: z.object({ recurrings: z.array(financeRecurringSchema) })
286
+ };
287
+ export const financeRecurringAdd = {
288
+ command: 'finance.recurringAdd' as const,
289
+ input: z.object({ recurring: recurringDraftSchema }),
290
+ output: z.object({ recurring: financeRecurringSchema })
291
+ };
292
+ export const financeRecurringUpdate = {
293
+ command: 'finance.recurringUpdate' as const,
294
+ input: z.object({ recurringId, recurring: recurringDraftSchema }),
295
+ output: z.object({ recurring: financeRecurringSchema })
296
+ };
297
+ /**
298
+ * Supprime l'échéance. Les opérations déjà écrites par elle restent: elles ont
299
+ * eu lieu. Elles perdent seulement leur rattachement (`ON DELETE SET NULL`).
300
+ */
301
+ export const financeRecurringRemove = {
302
+ command: 'finance.recurringRemove' as const,
303
+ input: z.object({ recurringId }),
304
+ output: z.object({ recurringId })
305
+ };
306
+ /**
307
+ * Écrit maintenant l'occurrence attendue, et avance la date de la suivante.
308
+ * C'est le clic que réclame une échéance non automatique. `amount` permet de
309
+ * corriger au passage le montant d'une facture qui varie, sans toucher au
310
+ * modèle lui-même.
311
+ */
312
+ export const financeRecurringPost = {
313
+ command: 'finance.recurringPost' as const,
314
+ input: z.object({ recurringId, amount: financeAmountSchema.optional() }),
315
+ output: z.object({ transaction: financeTransactionSchema, recurring: financeRecurringSchema })
316
+ };
317
+ /** Passe l'occurrence attendue sans rien écrire, et avance à la suivante. */
318
+ export const financeRecurringSkip = {
319
+ command: 'finance.recurringSkip' as const,
320
+ input: z.object({ recurringId }),
321
+ output: z.object({ recurring: financeRecurringSchema })
322
+ };
323
+ /* ------------------------------------------------------------------ *
324
+ * Tableau de bord
325
+ * ------------------------------------------------------------------ */
326
+ export const financeOverview = {
327
+ command: 'finance.overview' as const,
328
+ input: z.object({ range: financeRangeSchema }),
329
+ output: z.object({ overview: financeOverviewSchema })
330
+ };
331
+ export const financeCommands = [
332
+ financeConfig,
333
+ financeConfigUpdate,
334
+ financeSummary,
335
+ financeAccountList,
336
+ financeAccountAdd,
337
+ financeAccountUpdate,
338
+ financeAccountRemove,
339
+ financeAccountReorder,
340
+ financeCategoryList,
341
+ financeCategoryAdd,
342
+ financeCategoryUpdate,
343
+ financeCategoryRemove,
344
+ financeCategoryReorder,
345
+ financeTransactionList,
346
+ financeTransactionAdd,
347
+ financeTransactionUpdate,
348
+ financeTransactionRemove,
349
+ financeTransactionSetCleared,
350
+ financeBudgetList,
351
+ financeBudgetSet,
352
+ financeBudgetRemove,
353
+ financeRecurringList,
354
+ financeRecurringAdd,
355
+ financeRecurringUpdate,
356
+ financeRecurringRemove,
357
+ financeRecurringPost,
358
+ financeRecurringSkip,
359
+ financeOverview
360
+ ] as const;