@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.
- package/package.json +6 -6
- package/src/domain/device.ts +4 -29
- package/src/domain/featureRegistry.ts +40 -108
- package/src/domain/home.ts +40 -101
- package/src/domain/live.ts +36 -87
- package/src/domain/metrics.ts +10 -14
- package/src/domain/notifications.ts +39 -110
- package/src/domain/project.ts +3 -162
- package/src/domain/report.ts +46 -95
- package/src/domain/secrecy.ts +3 -5
- package/src/domain/sharing.ts +33 -70
- package/src/domain/syncProtocol.ts +5 -12
- package/src/domain/user.ts +8 -14
- package/src/domain/workspace.ts +0 -3
- package/src/domain/workspaceRole.ts +34 -82
- package/src/features/agent.ts +306 -0
- package/src/features/live.ts +17 -37
- package/src/features/notify.ts +19 -57
- package/src/features/registry.ts +7 -44
- package/src/features/secrecy.ts +4 -9
- package/src/features/sharing.ts +12 -26
- package/src/features/user.ts +6 -11
- package/src/features/workspace.ts +6 -11
- package/src/http/auth.ts +6 -13
- package/src/http/device.ts +13 -17
- package/src/http/status.ts +6 -10
- package/src/index.ts +29 -932
- package/src/protocol/agent.ts +40 -70
- package/src/protocol/envelope.ts +3 -10
- package/src/sdk/client-ambient.d.ts +228 -21
- package/src/sdk/client.ts +277 -17
- package/src/sdk/devb.ts +120 -0
- package/src/sdk/manifest.test.ts +0 -1
- package/src/sdk/manifest.ts +94 -25
- package/src/sdk/providers.ts +310 -5
- package/src/sdk/server.ts +483 -19
- package/src/sdk/testing.test.ts +2 -2
- package/src/sdk/testing.ts +302 -26
- package/src/utils/version.ts +5 -8
- package/src/domain/audience.ts +0 -549
- package/src/domain/backup.ts +0 -355
- package/src/domain/credential.ts +0 -55
- package/src/domain/database.ts +0 -467
- package/src/domain/deploy.ts +0 -231
- package/src/domain/finance.ts +0 -477
- package/src/domain/git.ts +0 -419
- package/src/domain/mail.ts +0 -394
- package/src/domain/note.ts +0 -202
- package/src/domain/password.ts +0 -36
- package/src/domain/projectBoard.ts +0 -130
- package/src/domain/projectChat.ts +0 -46
- package/src/domain/projectHistory.ts +0 -82
- package/src/domain/projectLink.ts +0 -87
- package/src/domain/projectPlan.ts +0 -68
- package/src/domain/sentinel.ts +0 -623
- package/src/domain/uptime.ts +0 -216
- package/src/features/audience.ts +0 -275
- package/src/features/backup.ts +0 -230
- package/src/features/database.ts +0 -461
- package/src/features/deploy.ts +0 -245
- package/src/features/device.ts +0 -292
- package/src/features/deviceFiles.ts +0 -83
- package/src/features/deviceLogs.ts +0 -36
- package/src/features/deviceTerminal.ts +0 -57
- package/src/features/finance.ts +0 -360
- package/src/features/git.ts +0 -368
- package/src/features/mail.ts +0 -374
- package/src/features/metrics.ts +0 -185
- package/src/features/note.ts +0 -189
- package/src/features/password.ts +0 -67
- package/src/features/project.ts +0 -709
- package/src/features/sentinel.ts +0 -233
- package/src/features/uptime.ts +0 -186
package/src/features/deploy.ts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
CREDENTIAL_LABEL_MAX_LENGTH,
|
|
4
|
-
CREDENTIAL_SECRET_MAX_LENGTH,
|
|
5
|
-
credentialSchema
|
|
6
|
-
} from '../domain/credential';
|
|
7
|
-
import {
|
|
8
|
-
DEPLOY_DESCRIPTION_MAX_LENGTH,
|
|
9
|
-
DEPLOY_EXTERNAL_ID_MAX_LENGTH,
|
|
10
|
-
DEPLOY_TARGET_NAME_MAX_LENGTH,
|
|
11
|
-
DEPLOY_TITLE_MAX_LENGTH,
|
|
12
|
-
deployCandidateSchema,
|
|
13
|
-
deployHistoryEntrySchema,
|
|
14
|
-
deployTargetKindSchema,
|
|
15
|
-
deployTargetSchema,
|
|
16
|
-
deploymentSchema
|
|
17
|
-
} from '../domain/deploy';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Commandes du déploiement.
|
|
21
|
-
*
|
|
22
|
-
* Feature d'espace de premier rang, sur le modèle de Git : une cible appartient
|
|
23
|
-
* à l'espace, un projet n'y **pointe** (voir `project.deployLink`). Tout est à
|
|
24
|
-
* l'étage ouvert, donc aucune de ces commandes ne demande de session
|
|
25
|
-
* déverrouillée.
|
|
26
|
-
*
|
|
27
|
-
* Les clés d'API Dokploy vivent ici et non plus dans la feature Git, où elles
|
|
28
|
-
* n'avaient atterri que faute de module pour les accueillir : poser la clé qui
|
|
29
|
-
* déploie relève de `deploy`, pas de `git`.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
const targetId = z.number().int().positive();
|
|
33
|
-
const credentialId = z.number().int().positive();
|
|
34
|
-
|
|
35
|
-
/** Les cibles de l'espace, dans l'ordre choisi par l'utilisateur. */
|
|
36
|
-
export const deployList = {
|
|
37
|
-
command: 'deploy.list' as const,
|
|
38
|
-
input: z.object({}),
|
|
39
|
-
output: z.object({ targets: z.array(deployTargetSchema) })
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Compte les cibles. Métadonnée en clair pure : la tuile d'accueil affiche
|
|
44
|
-
* toujours un nombre, même session verrouillée.
|
|
45
|
-
*/
|
|
46
|
-
export const deployCount = {
|
|
47
|
-
command: 'deploy.count' as const,
|
|
48
|
-
input: z.object({}),
|
|
49
|
-
output: z.object({ count: z.number().int().nonnegative() })
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** Une cible et son historique de déclenchements, du plus récent au plus ancien. */
|
|
53
|
-
export const deployGet = {
|
|
54
|
-
command: 'deploy.get' as const,
|
|
55
|
-
input: z.object({ targetId, limit: z.number().int().positive().max(50).optional() }),
|
|
56
|
-
output: z.object({
|
|
57
|
-
target: deployTargetSchema,
|
|
58
|
-
deployments: z.array(deploymentSchema),
|
|
59
|
-
/** Les projets qui la déploient, pour que la fiche sache où elle sert. */
|
|
60
|
-
projectIds: z.array(z.number().int().positive())
|
|
61
|
-
})
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Déclare une cible. **Idempotente** sur (jeton, identifiant externe) : la même
|
|
66
|
-
* application déclarée deux fois est la même cible, et la seconde déclaration
|
|
67
|
-
* met simplement son intitulé à jour.
|
|
68
|
-
*/
|
|
69
|
-
export const deployAdd = {
|
|
70
|
-
command: 'deploy.add' as const,
|
|
71
|
-
input: z.object({
|
|
72
|
-
credentialId,
|
|
73
|
-
kind: deployTargetKindSchema,
|
|
74
|
-
externalId: z.string().min(1).max(DEPLOY_EXTERNAL_ID_MAX_LENGTH),
|
|
75
|
-
name: z.string().min(1).max(DEPLOY_TARGET_NAME_MAX_LENGTH)
|
|
76
|
-
}),
|
|
77
|
-
output: z.object({ target: deployTargetSchema })
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** Change le jeton, le type ou l'intitulé d'une cible. */
|
|
81
|
-
export const deployUpdate = {
|
|
82
|
-
command: 'deploy.update' as const,
|
|
83
|
-
input: z.object({
|
|
84
|
-
targetId,
|
|
85
|
-
credentialId: credentialId.nullable(),
|
|
86
|
-
kind: deployTargetKindSchema,
|
|
87
|
-
externalId: z.string().min(1).max(DEPLOY_EXTERNAL_ID_MAX_LENGTH),
|
|
88
|
-
name: z.string().min(1).max(DEPLOY_TARGET_NAME_MAX_LENGTH)
|
|
89
|
-
}),
|
|
90
|
-
output: z.object({ target: deployTargetSchema })
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Supprime une cible, **et son historique avec elle**.
|
|
95
|
-
*
|
|
96
|
-
* L'application chez le fournisseur n'est pas touchée : DevEye ne fait que la
|
|
97
|
-
* pointer. Les projets qui la déployaient perdent leur liaison, rien d'autre.
|
|
98
|
-
*/
|
|
99
|
-
export const deployRemove = {
|
|
100
|
-
command: 'deploy.remove' as const,
|
|
101
|
-
input: z.object({ targetId }),
|
|
102
|
-
output: z.object({ targetId })
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/** Range la liste : `targetIds` en est le contenu complet, dans son ordre final. */
|
|
106
|
-
export const deployReorder = {
|
|
107
|
-
command: 'deploy.reorder' as const,
|
|
108
|
-
input: z.object({ targetIds: z.array(targetId).min(1) }),
|
|
109
|
-
output: z.object({ targetIds: z.array(targetId) })
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Les applications proposées par l'instance, pour en choisir une.
|
|
114
|
-
*
|
|
115
|
-
* Seule commande du module qui appelle un service externe en direct : elle sert
|
|
116
|
-
* à remplir un sélecteur, et attendre le prochain tour d'un ordonnanceur pour
|
|
117
|
-
* voir apparaître la liste n'aurait aucun sens.
|
|
118
|
-
*/
|
|
119
|
-
export const deployCandidates = {
|
|
120
|
-
command: 'deploy.candidates' as const,
|
|
121
|
-
input: z.object({ credentialId }),
|
|
122
|
-
output: z.object({ candidates: z.array(deployCandidateSchema) })
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Déclenche un déploiement.
|
|
127
|
-
*
|
|
128
|
-
* Toujours audité en `warn` : c'est la seule action du module qui produise un
|
|
129
|
-
* effet **hors** de DevEye, et savoir qui a poussé quoi en production compte
|
|
130
|
-
* plus que le reste.
|
|
131
|
-
*
|
|
132
|
-
* `projectId` est facultatif et ne sert qu'à la frise du projet : déclenché
|
|
133
|
-
* depuis l'onglet d'un projet, l'événement y est inscrit ; déclenché depuis la
|
|
134
|
-
* feature, il n'appartient à aucun projet en particulier.
|
|
135
|
-
*/
|
|
136
|
-
export const deployTrigger = {
|
|
137
|
-
command: 'deploy.trigger' as const,
|
|
138
|
-
input: z.object({
|
|
139
|
-
targetId,
|
|
140
|
-
title: z.string().max(DEPLOY_TITLE_MAX_LENGTH),
|
|
141
|
-
description: z.string().max(DEPLOY_DESCRIPTION_MAX_LENGTH),
|
|
142
|
-
projectId: z.number().int().positive().optional()
|
|
143
|
-
}),
|
|
144
|
-
output: z.object({ deployment: deploymentSchema })
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* L'historique complet d'une cible, **tel que Dokploy le rend** — pas
|
|
149
|
-
* seulement ce que DevEye a déclenché : un déploiement lancé depuis
|
|
150
|
-
* l'interface de Dokploy ou une CI y apparaît aussi.
|
|
151
|
-
*
|
|
152
|
-
* Distincte de `deployGet`, qui reste le suivi local (léger, toujours
|
|
153
|
-
* disponible sans réseau vers le fournisseur) : celle-ci interroge Dokploy en
|
|
154
|
-
* direct à chaque appel, coûte une requête externe, et n'a donc de sens que
|
|
155
|
-
* là où on la demande explicitement — la fiche d'une cible dans la feature,
|
|
156
|
-
* pas l'onglet d'un projet qui en reliste plusieurs.
|
|
157
|
-
*/
|
|
158
|
-
export const deployHistory = {
|
|
159
|
-
command: 'deploy.history' as const,
|
|
160
|
-
input: z.object({ targetId }),
|
|
161
|
-
output: z.object({ entries: z.array(deployHistoryEntrySchema) })
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Le journal complet d'un déploiement, tel que Dokploy l'a produit.
|
|
166
|
-
*
|
|
167
|
-
* `externalId` vient d'une ligne de `deployHistory` : c'est la seule façon dont
|
|
168
|
-
* le client connaît un déploiement dont DevEye n'a pas forcément la ligne
|
|
169
|
-
* locale. Repose sur un point d'entrée de Dokploy sans procédure tRPC dédiée
|
|
170
|
-
* (voir l'adaptateur `dokploy.ts`) : peut échouer sur une instance qui
|
|
171
|
-
* l'authentifie autrement, ou pas du tout — l'appelant le traite alors comme
|
|
172
|
-
* n'importe quelle autre panne réseau.
|
|
173
|
-
*/
|
|
174
|
-
export const deployLog = {
|
|
175
|
-
command: 'deploy.log' as const,
|
|
176
|
-
input: z.object({ targetId, externalId: z.string().min(1) }),
|
|
177
|
-
output: z.object({ log: z.string() })
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// ------------------------------------------------------------------ jetons
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Les clés d'API Dokploy de l'espace.
|
|
184
|
-
*
|
|
185
|
-
* Quatre commandes jumelles de `git.credential*` : même table, même forme, mais
|
|
186
|
-
* chaque feature n'expose que les jetons de ses fournisseurs et les garde
|
|
187
|
-
* derrière son propre droit. Le secret n'est jamais rendu.
|
|
188
|
-
*/
|
|
189
|
-
export const deployCredentialList = {
|
|
190
|
-
command: 'deploy.credentialList' as const,
|
|
191
|
-
input: z.object({}),
|
|
192
|
-
output: z.object({ credentials: z.array(credentialSchema) })
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
/** Une instance Dokploy exige son adresse : sans elle, rien n'est adressable. */
|
|
196
|
-
export const deployCredentialAdd = {
|
|
197
|
-
command: 'deploy.credentialAdd' as const,
|
|
198
|
-
input: z.object({
|
|
199
|
-
label: z.string().min(1).max(CREDENTIAL_LABEL_MAX_LENGTH),
|
|
200
|
-
baseUrl: z.string().min(1).max(255),
|
|
201
|
-
secret: z.string().min(1).max(CREDENTIAL_SECRET_MAX_LENGTH)
|
|
202
|
-
}),
|
|
203
|
-
output: z.object({ credential: credentialSchema })
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
/** `secret` omis = inchangé : le serveur ne l'a jamais rendu, on ne le réécrit pas. */
|
|
207
|
-
export const deployCredentialUpdate = {
|
|
208
|
-
command: 'deploy.credentialUpdate' as const,
|
|
209
|
-
input: z.object({
|
|
210
|
-
credentialId,
|
|
211
|
-
label: z.string().min(1).max(CREDENTIAL_LABEL_MAX_LENGTH),
|
|
212
|
-
baseUrl: z.string().min(1).max(255),
|
|
213
|
-
secret: z.string().min(1).max(CREDENTIAL_SECRET_MAX_LENGTH).optional()
|
|
214
|
-
}),
|
|
215
|
-
output: z.object({ credential: credentialSchema })
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Retire un jeton. Les cibles qui s'en servaient **restent**, sans jeton
|
|
220
|
-
* (`ON DELETE SET NULL`) : elles cessent d'être déployables et le disent, plutôt
|
|
221
|
-
* que de disparaître avec leur clé.
|
|
222
|
-
*/
|
|
223
|
-
export const deployCredentialRemove = {
|
|
224
|
-
command: 'deploy.credentialRemove' as const,
|
|
225
|
-
input: z.object({ credentialId }),
|
|
226
|
-
output: z.object({ credentialId })
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const deployCommands = [
|
|
230
|
-
deployList,
|
|
231
|
-
deployCount,
|
|
232
|
-
deployGet,
|
|
233
|
-
deployAdd,
|
|
234
|
-
deployUpdate,
|
|
235
|
-
deployRemove,
|
|
236
|
-
deployReorder,
|
|
237
|
-
deployCandidates,
|
|
238
|
-
deployTrigger,
|
|
239
|
-
deployHistory,
|
|
240
|
-
deployLog,
|
|
241
|
-
deployCredentialList,
|
|
242
|
-
deployCredentialAdd,
|
|
243
|
-
deployCredentialUpdate,
|
|
244
|
-
deployCredentialRemove
|
|
245
|
-
] as const;
|
package/src/features/device.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { deviceSchema } from '../domain/device';
|
|
3
|
-
import { packageManagerIdSchema } from '../domain/packages';
|
|
4
|
-
import { agentLifecycleActionSchema, agentPowerActionSchema } from '../protocol/agent';
|
|
5
|
-
import { processCaptureSchema } from '../domain/report';
|
|
6
|
-
import { workspaceKindSchema } from '../domain/workspace';
|
|
7
|
-
|
|
8
|
-
const deviceId = z.uuid();
|
|
9
|
-
|
|
10
|
-
/** List devices visible to the caller (own devices; all devices for admins). */
|
|
11
|
-
export const deviceList = {
|
|
12
|
-
command: 'device.list' as const,
|
|
13
|
-
input: z.object({
|
|
14
|
-
/**
|
|
15
|
-
* `workspace` (défaut) : les appareils de l'espace actif — ce qu'affichent
|
|
16
|
-
* l'accueil, la topbar et Monitoring.
|
|
17
|
-
* `fleet` : toute la flotte, tous espaces confondus. Réservé aux
|
|
18
|
-
* administrateurs, pour la page Appareils.
|
|
19
|
-
*/
|
|
20
|
-
scope: z.enum(['workspace', 'fleet']).optional()
|
|
21
|
-
}),
|
|
22
|
-
output: z.object({ devices: z.array(deviceSchema) })
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** Confirm a `pending` device, moving it to `active`. */
|
|
26
|
-
export const deviceConfirm = {
|
|
27
|
-
command: 'device.confirm' as const,
|
|
28
|
-
input: z.object({ deviceId }),
|
|
29
|
-
output: z.object({ device: deviceSchema })
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/** Revoke a device: its token is rejected and it can no longer push metrics. */
|
|
33
|
-
export const deviceRevoke = {
|
|
34
|
-
command: 'device.revoke' as const,
|
|
35
|
-
input: z.object({ deviceId }),
|
|
36
|
-
output: z.object({ device: deviceSchema })
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Lay out the workspace's devices: `ids` is the **complete** list in its final
|
|
41
|
-
* order (lower index first). New devices are appended, so the order is entirely
|
|
42
|
-
* the user's — as it is for monitored services, repositories and notes.
|
|
43
|
-
*
|
|
44
|
-
* Scoped to the active workspace, and gated on `devices: write` rather than on
|
|
45
|
-
* `admin: true` like the rest of this module: arranging a list one's own
|
|
46
|
-
* workspace displays is not fleet management. Touches no agent state.
|
|
47
|
-
*/
|
|
48
|
-
export const deviceReorder = {
|
|
49
|
-
command: 'device.reorder' as const,
|
|
50
|
-
input: z.object({ ids: z.array(deviceId).min(1) }),
|
|
51
|
-
output: z.object({ ids: z.array(deviceId) })
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const deviceRename = {
|
|
55
|
-
command: 'device.rename' as const,
|
|
56
|
-
input: z.object({ deviceId, name: z.string().min(1).max(128) }),
|
|
57
|
-
output: z.object({ device: deviceSchema })
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Update a device's collection config. Every field is optional; only the
|
|
62
|
-
* provided ones change. `null` resets a field to the server default. Interval
|
|
63
|
-
* or capture changes are pushed live to a connected agent.
|
|
64
|
-
*/
|
|
65
|
-
export const deviceSetConfig = {
|
|
66
|
-
command: 'device.setConfig' as const,
|
|
67
|
-
input: z
|
|
68
|
-
.object({
|
|
69
|
-
deviceId,
|
|
70
|
-
/** Collection interval in seconds — metrics *and* processes (5s–1h). */
|
|
71
|
-
metricIntervalSeconds: z.number().int().min(5).max(3600).nullable().optional(),
|
|
72
|
-
processCapture: processCaptureSchema.nullable().optional(),
|
|
73
|
-
/** Conservation de l'historique — métriques, présence et processus. */
|
|
74
|
-
retentionDays: z.number().int().positive().max(3650).nullable().optional()
|
|
75
|
-
})
|
|
76
|
-
.refine(
|
|
77
|
-
(v) =>
|
|
78
|
-
v.metricIntervalSeconds !== undefined ||
|
|
79
|
-
v.processCapture !== undefined ||
|
|
80
|
-
v.retentionDays !== undefined,
|
|
81
|
-
{ message: 'No config field provided' }
|
|
82
|
-
),
|
|
83
|
-
output: z.object({ device: deviceSchema })
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/** Un espace candidat au partage d'un appareil, tel que l'affiche la popup. */
|
|
87
|
-
export const deviceShareTargetSchema = z.object({
|
|
88
|
-
id: z.number().int().positive(),
|
|
89
|
-
name: z.string(),
|
|
90
|
-
kind: workspaceKindSchema,
|
|
91
|
-
/** L'espace a-t-il accès à cet appareil ? */
|
|
92
|
-
shared: z.boolean()
|
|
93
|
-
});
|
|
94
|
-
export type DeviceShareTarget = z.infer<typeof deviceShareTargetSchema>;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Les espaces avec lesquels un appareil peut être partagé, et lesquels le sont.
|
|
98
|
-
*
|
|
99
|
-
* Réservé aux administrateurs : c'est la seule commande qui énumère des espaces
|
|
100
|
-
* dont l'appelant n'est pas membre, et elle n'existe que pour la page Appareils.
|
|
101
|
-
*/
|
|
102
|
-
export const deviceWorkspaceList = {
|
|
103
|
-
command: 'device.workspaceList' as const,
|
|
104
|
-
input: z.object({ deviceId }),
|
|
105
|
-
output: z.object({
|
|
106
|
-
/**
|
|
107
|
-
* Espace d'appairage : toujours partagé, jamais retirable. `null` si cet
|
|
108
|
-
* espace a été supprimé depuis — l'appareil n'a alors plus d'origine et
|
|
109
|
-
* tous ses partages sont révocables.
|
|
110
|
-
*/
|
|
111
|
-
originWorkspaceId: z.number().int().positive().nullable(),
|
|
112
|
-
workspaces: z.array(deviceShareTargetSchema)
|
|
113
|
-
})
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Fixe l'ensemble des espaces ayant accès à un appareil. La liste est complète :
|
|
118
|
-
* un espace absent perd l'accès. L'espace d'appairage est réintégré d'office.
|
|
119
|
-
*/
|
|
120
|
-
export const deviceSetWorkspaces = {
|
|
121
|
-
command: 'device.setWorkspaces' as const,
|
|
122
|
-
input: z.object({
|
|
123
|
-
deviceId,
|
|
124
|
-
workspaceIds: z.array(z.number().int().positive())
|
|
125
|
-
}),
|
|
126
|
-
output: z.object({ device: deviceSchema })
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/** Reactivate a revoked device, moving it back to `active`. */
|
|
130
|
-
export const deviceReactivate = {
|
|
131
|
-
command: 'device.reactivate' as const,
|
|
132
|
-
input: z.object({ deviceId }),
|
|
133
|
-
output: z.object({ device: deviceSchema })
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Push a self-update to a connected device's agent: the server resolves the newer
|
|
138
|
-
* signed binary for the device's build target and sends `agent.update`. Admin-only
|
|
139
|
-
* (Appareils page). Fails if the agent is offline, has no known target, the binary
|
|
140
|
-
* is missing/unsigned, or it's already up to date.
|
|
141
|
-
*/
|
|
142
|
-
export const deviceUpdateAgent = {
|
|
143
|
-
command: 'device.updateAgent' as const,
|
|
144
|
-
input: z.object({ deviceId }),
|
|
145
|
-
output: z.object({ device: deviceSchema })
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Enable/disable the agent's per-user autostart (survives reboot, no privilege).
|
|
150
|
-
* Pushes `agent.service` to the connected agent (`install-user`/`uninstall-user`).
|
|
151
|
-
*/
|
|
152
|
-
export const deviceSetAutostart = {
|
|
153
|
-
command: 'device.setAutostart' as const,
|
|
154
|
-
input: z.object({ deviceId, enabled: z.boolean() }),
|
|
155
|
-
output: z.object({ device: deviceSchema })
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Ask the agent to become a root/system service. Hybrid: the agent pops an OS auth
|
|
160
|
-
* prompt if it has an interactive session, else replies `needsManualCommand` and the
|
|
161
|
-
* UI shows `manualCommand` (always returned, deterministic per platform) to run on
|
|
162
|
-
* the device. The new privilege/scope is observed on the agent's next report.
|
|
163
|
-
*/
|
|
164
|
-
export const deviceElevate = {
|
|
165
|
-
command: 'device.elevate' as const,
|
|
166
|
-
input: z.object({ deviceId }),
|
|
167
|
-
output: z.object({ device: deviceSchema, manualCommand: z.string() })
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/** Ask a root/system agent to drop back to a per-user service. */
|
|
171
|
-
export const deviceDropPrivileges = {
|
|
172
|
-
command: 'device.dropPrivileges' as const,
|
|
173
|
-
input: z.object({ deviceId }),
|
|
174
|
-
output: z.object({ device: deviceSchema, manualCommand: z.string() })
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Ask the agent to enumerate its package managers + pending updates. The result
|
|
179
|
-
* arrives asynchronously as a `package.list` push event (the caller must be
|
|
180
|
-
* subscribed to the device). The command itself only acknowledges the request.
|
|
181
|
-
*/
|
|
182
|
-
export const deviceListPackages = {
|
|
183
|
-
command: 'device.listPackages' as const,
|
|
184
|
-
input: z.object({ deviceId }),
|
|
185
|
-
output: z.object({ ok: z.boolean() })
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Apply all pending updates of one manager. Progress streams as `package.progress`
|
|
190
|
-
* events, ending with `package.done`. Fails if the agent is offline or the manager
|
|
191
|
-
* needs root and the agent isn't privileged (elevate it first — see device.elevate).
|
|
192
|
-
*/
|
|
193
|
-
export const deviceUpgradePackages = {
|
|
194
|
-
command: 'device.upgradePackages' as const,
|
|
195
|
-
input: z.object({ deviceId, manager: packageManagerIdSchema }),
|
|
196
|
-
output: z.object({ ok: z.boolean() })
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Run a system power action on the device (shutdown / reboot / suspend / hibernate
|
|
201
|
-
* / lock). Owner-or-admin; the agent must be online. The command only acknowledges
|
|
202
|
-
* the request — the agent applies it best-effort and the outcome streams back as a
|
|
203
|
-
* `device.powerResult` push event (the caller must be subscribed to the device).
|
|
204
|
-
*/
|
|
205
|
-
export const devicePower = {
|
|
206
|
-
command: 'device.power' as const,
|
|
207
|
-
input: z.object({ deviceId, action: agentPowerActionSchema }),
|
|
208
|
-
output: z.object({ ok: z.boolean() })
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Stop or cleanly restart the agent *process* on the device (not the machine).
|
|
213
|
-
* - `stop`: the agent exits. With autostart (supervised service) the manager
|
|
214
|
-
* relaunches it within seconds; standalone, the device stays offline — and
|
|
215
|
-
* unmanageable remotely — until someone relaunches it on the machine.
|
|
216
|
-
* - `restart`: exit-and-relaunch (manager or self-respawn), e.g. to pick up a
|
|
217
|
-
* clean state.
|
|
218
|
-
* Owner-or-admin; the agent must be online. Fire-and-forget: the command only
|
|
219
|
-
* acknowledges the push — the outcome is observed through presence.
|
|
220
|
-
*/
|
|
221
|
-
export const deviceAgentLifecycle = {
|
|
222
|
-
command: 'device.agentLifecycle' as const,
|
|
223
|
-
input: z.object({ deviceId, action: agentLifecycleActionSchema }),
|
|
224
|
-
output: z.object({ ok: z.boolean() })
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Request a managed deletion (from the Appareils page). The device moves to
|
|
229
|
-
* `pending_deletion`: on its next connection the agent is told to self-destruct
|
|
230
|
-
* (wipe its local config + binary), after which the device is archived — its
|
|
231
|
-
* monitoring history is kept and stays browsable, but it's gone from management.
|
|
232
|
-
* If the agent is online the destroy signal is sent immediately.
|
|
233
|
-
*/
|
|
234
|
-
export const deviceRequestDelete = {
|
|
235
|
-
command: 'device.requestDelete' as const,
|
|
236
|
-
input: z.object({ deviceId }),
|
|
237
|
-
output: z.object({ device: deviceSchema })
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/** Cancel a `pending_deletion` (only effective while the agent hasn't reconnected). */
|
|
241
|
-
export const deviceCancelDelete = {
|
|
242
|
-
command: 'device.cancelDelete' as const,
|
|
243
|
-
input: z.object({ deviceId }),
|
|
244
|
-
output: z.object({ device: deviceSchema })
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Finalise a deletion immediately: archive the device now without waiting for the
|
|
249
|
-
* agent to self-destruct (use when the agent is gone, or you don't care if it
|
|
250
|
-
* cleans itself up). A still-connected agent is told to self-destruct best-effort,
|
|
251
|
-
* but the device is archived regardless; if it ever reconnects it's refused.
|
|
252
|
-
*/
|
|
253
|
-
export const deviceForceDelete = {
|
|
254
|
-
command: 'device.forceDelete' as const,
|
|
255
|
-
input: z.object({ deviceId }),
|
|
256
|
-
output: z.object({ device: deviceSchema })
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Hard-purge a device and ALL its monitoring history (used by the Monitoring
|
|
261
|
-
* page to remove an archived — or any — device and reset its data). Works
|
|
262
|
-
* whether the agent is online or not; it does not self-destruct the agent.
|
|
263
|
-
*/
|
|
264
|
-
export const deviceDelete = {
|
|
265
|
-
command: 'device.delete' as const,
|
|
266
|
-
input: z.object({ deviceId }),
|
|
267
|
-
output: z.object({ deviceId })
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export const deviceCommands = [
|
|
271
|
-
deviceList,
|
|
272
|
-
deviceConfirm,
|
|
273
|
-
deviceRevoke,
|
|
274
|
-
deviceReactivate,
|
|
275
|
-
deviceRename,
|
|
276
|
-
deviceReorder,
|
|
277
|
-
deviceSetConfig,
|
|
278
|
-
deviceWorkspaceList,
|
|
279
|
-
deviceSetWorkspaces,
|
|
280
|
-
deviceUpdateAgent,
|
|
281
|
-
deviceSetAutostart,
|
|
282
|
-
deviceElevate,
|
|
283
|
-
deviceDropPrivileges,
|
|
284
|
-
deviceListPackages,
|
|
285
|
-
deviceUpgradePackages,
|
|
286
|
-
devicePower,
|
|
287
|
-
deviceAgentLifecycle,
|
|
288
|
-
deviceRequestDelete,
|
|
289
|
-
deviceCancelDelete,
|
|
290
|
-
deviceForceDelete,
|
|
291
|
-
deviceDelete
|
|
292
|
-
] as const;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { fileMutateOpSchema, fileSearchFilterSchema } from '../domain/deviceFiles';
|
|
3
|
-
|
|
4
|
-
const deviceId = z.uuid();
|
|
5
|
-
/** Correlates a request to its streamed result (results carry no requestId). */
|
|
6
|
-
const opId = z.string().min(1).max(64);
|
|
7
|
-
const path = z.string().min(1).max(4096);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* List a directory. Owner-or-admin + agent online. The listing arrives as a
|
|
11
|
-
* `device.filesListing` push event keyed by `opId` (the caller must be subscribed).
|
|
12
|
-
*/
|
|
13
|
-
export const deviceFilesList = {
|
|
14
|
-
command: 'device.filesList' as const,
|
|
15
|
-
input: z.object({ deviceId, opId, path }),
|
|
16
|
-
output: z.object({ ok: z.boolean() })
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Analyse a directory's recursive disk usage (ncdu-style): the total size of each
|
|
21
|
-
* immediate child. Result arrives as a `device.filesUsage` push event.
|
|
22
|
-
*/
|
|
23
|
-
export const deviceFilesAnalyze = {
|
|
24
|
-
command: 'device.filesAnalyze' as const,
|
|
25
|
-
input: z.object({ deviceId, opId, path }),
|
|
26
|
-
output: z.object({ ok: z.boolean() })
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Recursively search a directory with an advanced filter (name/extension/content,
|
|
31
|
-
* date & size windows). Matches arrive as a `device.filesMatches` push event.
|
|
32
|
-
*/
|
|
33
|
-
export const deviceFilesSearch = {
|
|
34
|
-
command: 'device.filesSearch' as const,
|
|
35
|
-
input: z.object({ deviceId, opId, path, filter: fileSearchFilterSchema }),
|
|
36
|
-
output: z.object({ ok: z.boolean() })
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Mutate the filesystem: `delete` (file or directory, recursive), `mkdir`, or
|
|
41
|
-
* `rename` (needs `dest`). The outcome arrives as a `device.filesOp` push event.
|
|
42
|
-
*/
|
|
43
|
-
export const deviceFilesMutate = {
|
|
44
|
-
command: 'device.filesMutate' as const,
|
|
45
|
-
input: z.object({ deviceId, opId, op: fileMutateOpSchema, path, dest: path.optional() }),
|
|
46
|
-
output: z.object({ ok: z.boolean() })
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Download a file. Bytes stream back as `device.filesChunk` push events keyed by
|
|
51
|
-
* `opId` (base64, the last with `done: true`); the client reassembles them.
|
|
52
|
-
*/
|
|
53
|
-
export const deviceFilesDownload = {
|
|
54
|
-
command: 'device.filesDownload' as const,
|
|
55
|
-
input: z.object({ deviceId, opId, path }),
|
|
56
|
-
output: z.object({ ok: z.boolean() })
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Upload one chunk of a file at `offset` (0 truncates/creates it). The completion
|
|
61
|
-
* (on `done`) arrives as a `device.filesOp` push event (op `upload`).
|
|
62
|
-
*/
|
|
63
|
-
export const deviceFilesUpload = {
|
|
64
|
-
command: 'device.filesUpload' as const,
|
|
65
|
-
input: z.object({
|
|
66
|
-
deviceId,
|
|
67
|
-
opId,
|
|
68
|
-
path,
|
|
69
|
-
offset: z.number().int().nonnegative(),
|
|
70
|
-
data: z.string().max(1_400_000),
|
|
71
|
-
done: z.boolean()
|
|
72
|
-
}),
|
|
73
|
-
output: z.object({ ok: z.boolean() })
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const deviceFilesCommands = [
|
|
77
|
-
deviceFilesList,
|
|
78
|
-
deviceFilesAnalyze,
|
|
79
|
-
deviceFilesSearch,
|
|
80
|
-
deviceFilesMutate,
|
|
81
|
-
deviceFilesDownload,
|
|
82
|
-
deviceFilesUpload
|
|
83
|
-
] as const;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { deviceLogFilterSchema, DEVICE_LOG_PAGE_MAX } from '../domain/deviceLogs';
|
|
3
|
-
|
|
4
|
-
const deviceId = z.uuid();
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Ask the agent to enumerate the log sources present on the device (system journal,
|
|
8
|
-
* Docker containers, log files…). Owner-or-admin + agent online. The command only
|
|
9
|
-
* acknowledges; the list arrives as a `device.logSources` push event (the caller
|
|
10
|
-
* must be subscribed to the device).
|
|
11
|
-
*/
|
|
12
|
-
export const deviceLogSources = {
|
|
13
|
-
command: 'device.logSources' as const,
|
|
14
|
-
input: z.object({ deviceId }),
|
|
15
|
-
output: z.object({ ok: z.boolean() })
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Query one source with an advanced filter. `queryId` correlates the streamed
|
|
20
|
-
* result back to this request (results have no requestId). Lines arrive as one or
|
|
21
|
-
* more `device.logLines` push events, the last carrying `done: true`.
|
|
22
|
-
*/
|
|
23
|
-
export const deviceLogQuery = {
|
|
24
|
-
command: 'device.logQuery' as const,
|
|
25
|
-
input: z.object({
|
|
26
|
-
deviceId,
|
|
27
|
-
sourceId: z.string().min(1).max(512),
|
|
28
|
-
/** Client-generated id echoed back on every `device.logLines` for this query. */
|
|
29
|
-
queryId: z.string().min(1).max(64),
|
|
30
|
-
filter: deviceLogFilterSchema.optional(),
|
|
31
|
-
limit: z.number().int().positive().max(DEVICE_LOG_PAGE_MAX).optional()
|
|
32
|
-
}),
|
|
33
|
-
output: z.object({ ok: z.boolean() })
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const deviceLogCommands = [deviceLogSources, deviceLogQuery] as const;
|