@deveye/types 0.15.2 → 0.16.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 (73) hide show
  1. package/package.json +6 -6
  2. package/src/domain/device.ts +4 -29
  3. package/src/domain/featureRegistry.ts +40 -108
  4. package/src/domain/home.ts +40 -101
  5. package/src/domain/live.ts +36 -87
  6. package/src/domain/metrics.ts +10 -14
  7. package/src/domain/notifications.ts +39 -110
  8. package/src/domain/project.ts +3 -162
  9. package/src/domain/report.ts +46 -95
  10. package/src/domain/secrecy.ts +3 -5
  11. package/src/domain/sharing.ts +33 -70
  12. package/src/domain/syncProtocol.ts +5 -12
  13. package/src/domain/user.ts +8 -14
  14. package/src/domain/workspace.ts +0 -3
  15. package/src/domain/workspaceRole.ts +34 -82
  16. package/src/features/agent.ts +306 -0
  17. package/src/features/live.ts +17 -37
  18. package/src/features/notify.ts +19 -57
  19. package/src/features/registry.ts +7 -44
  20. package/src/features/secrecy.ts +4 -9
  21. package/src/features/sharing.ts +12 -26
  22. package/src/features/user.ts +6 -11
  23. package/src/features/workspace.ts +6 -11
  24. package/src/http/auth.ts +6 -13
  25. package/src/http/device.ts +13 -17
  26. package/src/http/status.ts +6 -10
  27. package/src/index.ts +29 -932
  28. package/src/protocol/agent.ts +40 -70
  29. package/src/protocol/envelope.ts +3 -10
  30. package/src/sdk/client-ambient.d.ts +228 -21
  31. package/src/sdk/client.ts +277 -17
  32. package/src/sdk/devb.ts +120 -0
  33. package/src/sdk/manifest.test.ts +0 -1
  34. package/src/sdk/manifest.ts +94 -25
  35. package/src/sdk/providers.ts +310 -5
  36. package/src/sdk/server.ts +483 -19
  37. package/src/sdk/testing.test.ts +2 -2
  38. package/src/sdk/testing.ts +302 -26
  39. package/src/utils/version.ts +5 -8
  40. package/src/domain/audience.ts +0 -549
  41. package/src/domain/backup.ts +0 -355
  42. package/src/domain/credential.ts +0 -55
  43. package/src/domain/database.ts +0 -467
  44. package/src/domain/deploy.ts +0 -231
  45. package/src/domain/finance.ts +0 -477
  46. package/src/domain/git.ts +0 -419
  47. package/src/domain/mail.ts +0 -394
  48. package/src/domain/note.ts +0 -202
  49. package/src/domain/password.ts +0 -36
  50. package/src/domain/projectBoard.ts +0 -130
  51. package/src/domain/projectChat.ts +0 -46
  52. package/src/domain/projectHistory.ts +0 -82
  53. package/src/domain/projectLink.ts +0 -87
  54. package/src/domain/projectPlan.ts +0 -68
  55. package/src/domain/sentinel.ts +0 -623
  56. package/src/domain/uptime.ts +0 -216
  57. package/src/features/audience.ts +0 -275
  58. package/src/features/backup.ts +0 -230
  59. package/src/features/database.ts +0 -461
  60. package/src/features/deploy.ts +0 -245
  61. package/src/features/device.ts +0 -292
  62. package/src/features/deviceFiles.ts +0 -83
  63. package/src/features/deviceLogs.ts +0 -36
  64. package/src/features/deviceTerminal.ts +0 -57
  65. package/src/features/finance.ts +0 -360
  66. package/src/features/git.ts +0 -368
  67. package/src/features/mail.ts +0 -374
  68. package/src/features/metrics.ts +0 -185
  69. package/src/features/note.ts +0 -189
  70. package/src/features/password.ts +0 -67
  71. package/src/features/project.ts +0 -709
  72. package/src/features/sentinel.ts +0 -233
  73. package/src/features/uptime.ts +0 -186
@@ -1,233 +0,0 @@
1
- import { z } from 'zod';
2
- import {
3
- allowEntrySchema,
4
- allowScopeSchema,
5
- baselineEntrySchema,
6
- baselineKindSchema,
7
- devicePostureSchema,
8
- deviceSentinelStateSchema,
9
- findingSchema,
10
- findingSeveritySchema,
11
- findingStateSchema,
12
- SENTINEL_INTEGRITY_MINUTES_MAX,
13
- SENTINEL_INTEGRITY_MINUTES_MIN,
14
- SENTINEL_LEARNING_DAYS_MAX,
15
- SENTINEL_LEARNING_DAYS_MIN,
16
- sentinelRuleIdSchema,
17
- severityCountsSchema
18
- } from '../domain/sentinel';
19
-
20
- const deviceId = z.uuid();
21
- const findingId = z.number().int().positive();
22
-
23
- /** Plafond d'une page de constats. Au-delà, on filtre plutôt qu'on déroule. */
24
- export const SENTINEL_PAGE_MAX = 200;
25
-
26
- /**
27
- * L'état de la flotte en une réponse : de quoi peindre la carte d'accueil et
28
- * l'en-tête de la vue plein écran sans second aller-retour.
29
- */
30
- export const sentinelOverview = {
31
- command: 'sentinel.overview' as const,
32
- input: z.object({}),
33
- output: z.object({
34
- /** Constats ouverts de tout l'espace, par gravité. */
35
- open: severityCountsSchema,
36
- /**
37
- * Score de posture de la flotte : moyenne des scores concluants. `null`
38
- * quand aucune machine n'a encore de posture mesurable — et non `0`, qui
39
- * se lirait comme une flotte en ruine.
40
- */
41
- fleetScore: z.number().int().min(0).max(100).nullable(),
42
- devices: z.array(deviceSentinelStateSchema).max(500)
43
- })
44
- };
45
-
46
- /**
47
- * Le décompte seul, pour la carte de grille et la pastille de Monitoring.
48
- *
49
- * Séparé d'`overview` parce qu'il se rafraîchit à chaque changement et qu'il
50
- * n'a besoin d'aucune jointure : deux `COUNT` indexés contre un balayage de
51
- * toute la flotte.
52
- */
53
- export const sentinelCount = {
54
- command: 'sentinel.count' as const,
55
- input: z.object({}),
56
- output: z.object({
57
- open: severityCountsSchema,
58
- /** Appareils sur lesquels Sentinelle est active. */
59
- watched: z.number().int().nonnegative()
60
- })
61
- };
62
-
63
- /** Les constats, filtrables. Tri imposé : gravité décroissante puis fraîcheur. */
64
- export const sentinelFindings = {
65
- command: 'sentinel.findings' as const,
66
- input: z.object({
67
- deviceId: deviceId.nullable().default(null),
68
- state: findingStateSchema.nullable().default(null),
69
- minSeverity: findingSeveritySchema.nullable().default(null),
70
- rule: sentinelRuleIdSchema.nullable().default(null),
71
- limit: z.number().int().min(1).max(SENTINEL_PAGE_MAX).default(50),
72
- offset: z.number().int().nonnegative().default(0)
73
- }),
74
- output: z.object({
75
- findings: z.array(findingSchema).max(SENTINEL_PAGE_MAX),
76
- /** Total correspondant au filtre, pour paginer sans deviner. */
77
- total: z.number().int().nonnegative()
78
- })
79
- };
80
-
81
- /** L'inventaire appris d'une machine, par nature. */
82
- export const sentinelBaseline = {
83
- command: 'sentinel.baseline' as const,
84
- input: z.object({
85
- deviceId,
86
- kind: baselineKindSchema.nullable().default(null),
87
- limit: z.number().int().min(1).max(1000).default(500)
88
- }),
89
- output: z.object({
90
- deviceId,
91
- entries: z.array(baselineEntrySchema).max(1000),
92
- total: z.number().int().nonnegative()
93
- })
94
- };
95
-
96
- /** Le détail de posture d'une machine, contrôle par contrôle. */
97
- export const sentinelPosture = {
98
- command: 'sentinel.posture' as const,
99
- input: z.object({ deviceId }),
100
- output: z.object({ posture: devicePostureSchema })
101
- };
102
-
103
- /**
104
- * « Ceci est légitime. »
105
- *
106
- * Écrit une autorisation **et** résout le constat, dans cet ordre : si l'écriture
107
- * échoue, le constat reste ouvert plutôt que de disparaître sans qu'aucune règle
108
- * ne l'en empêche de revenir. En portée `fleet`, l'autorisation vaut pour tout
109
- * l'espace, y compris les machines qui le rejoindront ensuite.
110
- */
111
- export const sentinelAcknowledge = {
112
- command: 'sentinel.acknowledge' as const,
113
- input: z.object({
114
- findingId,
115
- scope: allowScopeSchema.default('device'),
116
- reason: z.string().max(255).nullable().default(null)
117
- }),
118
- output: z.object({
119
- finding: findingSchema,
120
- allow: allowEntrySchema
121
- })
122
- };
123
-
124
- /**
125
- * « C'est réglé. »
126
- *
127
- * Ferme le constat **sans** écrire d'autorisation : la situation a cessé, elle
128
- * n'a pas été jugée normale. La distinction n'est pas cosmétique — un constat
129
- * acquitté ne rouvrira plus jamais, un constat réglé rouvre au premier relevé
130
- * qui le revoit, et c'est précisément ce qu'on veut d'une correction.
131
- *
132
- * Le moteur résout tout seul ce qu'il sait rejouer (les règles d'instant). Restent
133
- * les constats d'**événement** — une authentification, une entrée de persistance :
134
- * ils décrivent quelque chose qui a eu lieu, donc rien ne cessera de les
135
- * déclencher, et sans cette commande la seule sortie était de les déclarer
136
- * légitimes. C'est-à-dire de mentir pour faire le ménage.
137
- */
138
- export const sentinelResolve = {
139
- command: 'sentinel.resolve' as const,
140
- input: z.object({ findingId }),
141
- output: z.object({ finding: findingSchema })
142
- };
143
-
144
- /** Annule un acquittement ou une résolution : retire l'autorisation et rouvre le constat. */
145
- export const sentinelReopen = {
146
- command: 'sentinel.reopen' as const,
147
- input: z.object({ findingId }),
148
- output: z.object({ finding: findingSchema })
149
- };
150
-
151
- /** Les décisions humaines en vigueur dans l'espace. */
152
- export const sentinelAllowlist = {
153
- command: 'sentinel.allowlist' as const,
154
- input: z.object({ deviceId: deviceId.nullable().default(null) }),
155
- output: z.object({ entries: z.array(allowEntrySchema).max(1000) })
156
- };
157
-
158
- /** Retire une autorisation. Le constat correspondant pourra rouvrir. */
159
- export const sentinelRemoveAllow = {
160
- command: 'sentinel.removeAllow' as const,
161
- input: z.object({ allowId: z.number().int().positive() }),
162
- output: z.object({ removed: z.boolean() })
163
- };
164
-
165
- /**
166
- * Active Sentinelle sur une machine et règle ses cadences.
167
- *
168
- * Activer (re)part une fenêtre d'apprentissage de `learningDays` : sans elle, le
169
- * premier jour produirait des centaines de constats « nouveau programme » et la
170
- * liste deviendrait illisible avant d'avoir servi.
171
- */
172
- export const sentinelSetConfig = {
173
- command: 'sentinel.setConfig' as const,
174
- input: z.object({
175
- deviceId,
176
- enabled: z.boolean(),
177
- learningDays: z
178
- .number()
179
- .int()
180
- .min(SENTINEL_LEARNING_DAYS_MIN)
181
- .max(SENTINEL_LEARNING_DAYS_MAX)
182
- .nullable()
183
- .default(null),
184
- integrityMinutes: z
185
- .number()
186
- .int()
187
- .min(SENTINEL_INTEGRITY_MINUTES_MIN)
188
- .max(SENTINEL_INTEGRITY_MINUTES_MAX)
189
- .nullable()
190
- .default(null),
191
- authEvents: z.boolean().nullable().default(null)
192
- }),
193
- output: z.object({ device: deviceSentinelStateSchema })
194
- };
195
-
196
- /** Demande un relevé de persistance + authentification immédiat. */
197
- export const sentinelScanNow = {
198
- command: 'sentinel.scanNow' as const,
199
- input: z.object({ deviceId }),
200
- /** `requested` est faux quand l'agent n'est pas connecté. */
201
- output: z.object({ deviceId, requested: z.boolean() })
202
- };
203
-
204
- /**
205
- * Efface la ligne de base d'une machine et relance l'apprentissage.
206
- *
207
- * Le geste à faire après une montée de version d'agent qui change ce qui est
208
- * observé — typiquement l'arrivée des chemins d'exécutables, qui redéfinit la
209
- * clé d'un programme. **Les autorisations survivent** : ce sont des décisions,
210
- * pas des observations, et les réclamer une seconde fois serait une punition
211
- * pour avoir mis l'agent à jour.
212
- */
213
- export const sentinelResetBaseline = {
214
- command: 'sentinel.resetBaseline' as const,
215
- input: z.object({ deviceId }),
216
- output: z.object({ deviceId, cleared: z.number().int().nonnegative() })
217
- };
218
-
219
- export const sentinelCommands = [
220
- sentinelOverview,
221
- sentinelCount,
222
- sentinelFindings,
223
- sentinelBaseline,
224
- sentinelPosture,
225
- sentinelAcknowledge,
226
- sentinelResolve,
227
- sentinelReopen,
228
- sentinelAllowlist,
229
- sentinelRemoveAllow,
230
- sentinelSetConfig,
231
- sentinelScanNow,
232
- sentinelResetBaseline
233
- ] as const;
@@ -1,186 +0,0 @@
1
- import { z } from 'zod';
2
- import {
3
- UPTIME_INTERVAL_MAX,
4
- UPTIME_INTERVAL_MIN,
5
- UPTIME_KEYWORD_MAX_LENGTH,
6
- UPTIME_NAME_MAX_LENGTH,
7
- UPTIME_THRESHOLD_MAX,
8
- UPTIME_TIMEOUT_MAX,
9
- UPTIME_TIMEOUT_MIN,
10
- UPTIME_URL_MAX_LENGTH,
11
- uptimeCheckSchema,
12
- uptimeCheckStatsSchema,
13
- uptimeIncidentSchema,
14
- uptimeMethodSchema,
15
- uptimePointSchema,
16
- uptimeRangeSchema,
17
- uptimeResolutionSchema,
18
- uptimeRetentionSchema,
19
- uptimeServiceSchema
20
- } from '../domain/uptime';
21
-
22
- const serviceId = z.number().int().positive();
23
-
24
- /** Everything the user may set on a service. */
25
- const uptimeDraftSchema = z.object({
26
- name: z.string().min(1).max(UPTIME_NAME_MAX_LENGTH),
27
- url: z.string().url().max(UPTIME_URL_MAX_LENGTH),
28
- method: uptimeMethodSchema,
29
- expectedStatus: z.number().int().min(100).max(599).nullable(),
30
- keyword: z.string().max(UPTIME_KEYWORD_MAX_LENGTH).nullable(),
31
- intervalSeconds: z.number().int().min(UPTIME_INTERVAL_MIN).max(UPTIME_INTERVAL_MAX),
32
- timeoutSeconds: z.number().int().min(UPTIME_TIMEOUT_MIN).max(UPTIME_TIMEOUT_MAX),
33
- failureThreshold: z.number().int().min(1).max(UPTIME_THRESHOLD_MAX),
34
- retentionDays: uptimeRetentionSchema,
35
- enabled: z.boolean()
36
- });
37
-
38
- /**
39
- * List the workspace's services in the user's own order, each carrying its live
40
- * state and its 24 h / 7 d / 30 d ratios. Never gated: uptime data lives in the
41
- * open tier, so the feature opens with no password prompt.
42
- */
43
- export const uptimeList = {
44
- command: 'uptime.list' as const,
45
- input: z.object({}),
46
- output: z.object({ services: z.array(uptimeServiceSchema) })
47
- };
48
-
49
- /**
50
- * "N services up out of M" — the only thing the home card and the navbar widget
51
- * need. Pure clear metadata, so it costs one indexed count. Paused services are
52
- * excluded entirely, and `up + down` may be **below** `total`: one awaiting its
53
- * first probe is neither, and must not be reported as a failure.
54
- */
55
- export const uptimeCount = {
56
- command: 'uptime.count' as const,
57
- input: z.object({}),
58
- output: z.object({
59
- total: z.number().int().nonnegative(),
60
- up: z.number().int().nonnegative(),
61
- down: z.number().int().nonnegative()
62
- })
63
- };
64
-
65
- export const uptimeAdd = {
66
- command: 'uptime.add' as const,
67
- input: z.object({ service: uptimeDraftSchema }),
68
- output: z.object({ service: uptimeServiceSchema })
69
- };
70
-
71
- /** Replace a service's whole configuration. History and incidents are kept. */
72
- export const uptimeUpdate = {
73
- command: 'uptime.update' as const,
74
- input: z.object({ id: serviceId, service: uptimeDraftSchema }),
75
- output: z.object({ service: uptimeServiceSchema })
76
- };
77
-
78
- /**
79
- * Pause or resume probing without touching the rest of the configuration — a
80
- * paused service keeps its history and simply stops being scheduled.
81
- */
82
- export const uptimeSetEnabled = {
83
- command: 'uptime.setEnabled' as const,
84
- input: z.object({ id: serviceId, enabled: z.boolean() }),
85
- output: z.object({ service: uptimeServiceSchema })
86
- };
87
-
88
- /** Destroy a service **and its whole history** — there is no archive here. */
89
- export const uptimeRemove = {
90
- command: 'uptime.remove' as const,
91
- input: z.object({ id: serviceId }),
92
- output: z.object({ id: serviceId })
93
- };
94
-
95
- /**
96
- * Lay out the workspace's services: `ids` is the **complete** list in its final
97
- * order (lower index first). Nothing else positions a service — new ones are
98
- * appended — so the order is entirely the user's, as it is for notes. Touches no
99
- * probe state, so reordering never disturbs monitoring.
100
- */
101
- export const uptimeReorder = {
102
- command: 'uptime.reorder' as const,
103
- input: z.object({ ids: z.array(serviceId).min(1) }),
104
- output: z.object({ ids: z.array(serviceId) })
105
- };
106
-
107
- /** Probe a service right now instead of waiting for its next tick. */
108
- export const uptimeCheckNow = {
109
- command: 'uptime.checkNow' as const,
110
- input: z.object({ id: serviceId }),
111
- output: z.object({ service: uptimeServiceSchema })
112
- };
113
-
114
- /**
115
- * Chart series over a window. The server picks the bucket size from the range
116
- * (`raw` up to 24 h, hourly up to 30 d, daily beyond) and reads the long ranges
117
- * from the daily rollup, which is never pruned.
118
- */
119
- export const uptimeHistory = {
120
- command: 'uptime.history' as const,
121
- input: z.object({ id: serviceId, range: uptimeRangeSchema }),
122
- output: z.object({
123
- resolution: uptimeResolutionSchema,
124
- points: z.array(uptimePointSchema)
125
- })
126
- };
127
-
128
- /**
129
- * Which pings a journal query is about. Shared by {@link uptimeChecks} and
130
- * {@link uptimeCheckStats} so a page and its aggregates always describe the
131
- * exact same selection.
132
- */
133
- const checkFilterSchema = z.object({
134
- /** Keep only probes at or after this epoch second; `null` = the whole history. */
135
- since: z.number().int().nonnegative().nullable(),
136
- /** Restrict to failed probes. */
137
- failuresOnly: z.boolean()
138
- });
139
-
140
- /**
141
- * Raw ping journal, most recent first. `before` pages backwards through time
142
- * (exclusive upper bound, epoch seconds).
143
- */
144
- export const uptimeChecks = {
145
- command: 'uptime.checks' as const,
146
- input: z.object({
147
- id: serviceId,
148
- limit: z.number().int().min(1).max(200),
149
- before: z.number().int().nonnegative().optional(),
150
- filter: checkFilterSchema
151
- }),
152
- output: z.object({ checks: z.array(uptimeCheckSchema) })
153
- };
154
-
155
- /**
156
- * Aggregates over the same selection {@link uptimeChecks} pages through. Kept a
157
- * separate command on purpose: it scans the whole filtered range, so the short
158
- * "last few measures" list on the detail view never pays for it.
159
- */
160
- export const uptimeCheckStats = {
161
- command: 'uptime.checkStats' as const,
162
- input: z.object({ id: serviceId, filter: checkFilterSchema }),
163
- output: z.object({ stats: uptimeCheckStatsSchema })
164
- };
165
-
166
- /** Outage history, most recent first; the ongoing one (if any) comes back too. */
167
- export const uptimeIncidents = {
168
- command: 'uptime.incidents' as const,
169
- input: z.object({ id: serviceId, limit: z.number().int().min(1).max(100) }),
170
- output: z.object({ incidents: z.array(uptimeIncidentSchema) })
171
- };
172
-
173
- export const uptimeCommands = [
174
- uptimeList,
175
- uptimeCount,
176
- uptimeAdd,
177
- uptimeUpdate,
178
- uptimeSetEnabled,
179
- uptimeRemove,
180
- uptimeReorder,
181
- uptimeCheckNow,
182
- uptimeHistory,
183
- uptimeChecks,
184
- uptimeCheckStats,
185
- uptimeIncidents
186
- ] as const;