@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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/package.json +68 -0
- package/src/domain/audience.ts +549 -0
- package/src/domain/backup.ts +355 -0
- package/src/domain/credential.ts +55 -0
- package/src/domain/database.ts +467 -0
- package/src/domain/deploy.ts +231 -0
- package/src/domain/device.ts +172 -0
- package/src/domain/deviceFiles.ts +84 -0
- package/src/domain/deviceLogs.ts +82 -0
- package/src/domain/featureRegistry.ts +392 -0
- package/src/domain/finance.ts +477 -0
- package/src/domain/git.ts +419 -0
- package/src/domain/home.ts +314 -0
- package/src/domain/live.ts +272 -0
- package/src/domain/logs.ts +117 -0
- package/src/domain/mail.ts +394 -0
- package/src/domain/metrics.ts +127 -0
- package/src/domain/note.ts +202 -0
- package/src/domain/notifications.ts +268 -0
- package/src/domain/packages.ts +35 -0
- package/src/domain/password.ts +36 -0
- package/src/domain/presence.ts +21 -0
- package/src/domain/project.ts +168 -0
- package/src/domain/projectBoard.ts +130 -0
- package/src/domain/projectChat.ts +46 -0
- package/src/domain/projectHistory.ts +82 -0
- package/src/domain/projectLink.ts +87 -0
- package/src/domain/projectPlan.ts +68 -0
- package/src/domain/report.ts +492 -0
- package/src/domain/role.ts +8 -0
- package/src/domain/secrecy.ts +66 -0
- package/src/domain/sentinel.ts +623 -0
- package/src/domain/sharing.ts +186 -0
- package/src/domain/syncProtocol.ts +116 -0
- package/src/domain/twoFactor.ts +40 -0
- package/src/domain/uptime.ts +216 -0
- package/src/domain/user.ts +141 -0
- package/src/domain/workspace.ts +56 -0
- package/src/domain/workspaceRole.ts +251 -0
- package/src/features/admin.ts +112 -0
- package/src/features/audience.ts +275 -0
- package/src/features/backup.ts +230 -0
- package/src/features/database.ts +461 -0
- package/src/features/deploy.ts +245 -0
- package/src/features/device.ts +292 -0
- package/src/features/deviceFiles.ts +83 -0
- package/src/features/deviceLogs.ts +36 -0
- package/src/features/deviceTerminal.ts +57 -0
- package/src/features/finance.ts +360 -0
- package/src/features/git.ts +368 -0
- package/src/features/home.ts +32 -0
- package/src/features/live.ts +113 -0
- package/src/features/logs.ts +86 -0
- package/src/features/mail.ts +374 -0
- package/src/features/metrics.ts +185 -0
- package/src/features/note.ts +189 -0
- package/src/features/notify.ts +164 -0
- package/src/features/password.ts +67 -0
- package/src/features/project.ts +709 -0
- package/src/features/registry.ts +103 -0
- package/src/features/secrecy.ts +120 -0
- package/src/features/sentinel.ts +233 -0
- package/src/features/sharing.ts +79 -0
- package/src/features/twoFactor.ts +47 -0
- package/src/features/uptime.ts +186 -0
- package/src/features/user.ts +91 -0
- package/src/features/workspace.ts +200 -0
- package/src/http/auth.ts +94 -0
- package/src/http/device.ts +222 -0
- package/src/http/status.ts +45 -0
- package/src/index.ts +1700 -0
- package/src/protocol/agent.ts +1171 -0
- package/src/protocol/envelope.ts +46 -0
- package/src/protocol/error.ts +27 -0
- package/src/protocol/result.ts +17 -0
- package/src/protocol/version.ts +6 -0
- package/src/sdk/client-ambient.d.ts +238 -0
- package/src/sdk/client.ts +66 -0
- package/src/sdk/ids.ts +25 -0
- package/src/sdk/index.ts +11 -0
- package/src/sdk/manifest.ts +326 -0
- package/src/sdk/providers.ts +48 -0
- package/src/sdk/server.ts +378 -0
- package/src/sdk/testing.ts +179 -0
- package/src/utils/version.ts +28 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { devicePlatformSchema, deviceSchema } from '../domain/device';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Device linking & enrollment (HTTP, distinct from the user feature protocol).
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. A logged-in user requests a short-lived link code (web UI).
|
|
9
|
+
* 2. The agent posts the code + machine fingerprint + public key to enroll.
|
|
10
|
+
* 3. The server creates a `pending` device and returns a device token (JWT).
|
|
11
|
+
* 4. The user confirms the device in the Clients page to activate it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Hard cap on a custom code lifetime (30 days), to bound never-pruned rows. */
|
|
15
|
+
export const LINK_CODE_TTL_MAX_SECONDS = 30 * 24 * 60 * 60;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Request a new link code. `ttlSeconds`:
|
|
19
|
+
* - omitted → server default lifetime,
|
|
20
|
+
* - `null` → no expiry (valid until used or deleted),
|
|
21
|
+
* - a number → custom lifetime in seconds.
|
|
22
|
+
*/
|
|
23
|
+
export const linkCodeRequestSchema = z.object({
|
|
24
|
+
ttlSeconds: z.number().int().positive().max(LINK_CODE_TTL_MAX_SECONDS).nullable().optional(),
|
|
25
|
+
/**
|
|
26
|
+
* Approve the device automatically the moment it enrols with this code,
|
|
27
|
+
* instead of leaving it `pending` for manual approval. Defaults to `false`
|
|
28
|
+
* (manual approval stays the safe default).
|
|
29
|
+
*/
|
|
30
|
+
autoApprove: z.boolean().default(false),
|
|
31
|
+
/**
|
|
32
|
+
* Espace dans lequel la machine sera rangée à l'enrôlement. Omis → l'espace
|
|
33
|
+
* personnel de l'émetteur. L'émetteur doit en être membre : appairer une
|
|
34
|
+
* machine dans un espace où l'on n'entre pas n'aurait aucun sens.
|
|
35
|
+
*/
|
|
36
|
+
workspaceId: z.number().int().positive().optional()
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type LinkCodeRequest = z.infer<typeof linkCodeRequestSchema>;
|
|
40
|
+
|
|
41
|
+
export const linkCodeResponseSchema = z.object({
|
|
42
|
+
/** Short human-typable code (e.g. shown in the UI, entered on the agent). */
|
|
43
|
+
code: z.string().min(6).max(32),
|
|
44
|
+
/** Unix seconds when the code expires; `null` means it never expires. */
|
|
45
|
+
expiresAt: z.number().int().positive().nullable(),
|
|
46
|
+
/** Whether a device enrolling with this code is approved automatically. */
|
|
47
|
+
autoApprove: z.boolean()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export type LinkCodeResponse = z.infer<typeof linkCodeResponseSchema>;
|
|
51
|
+
|
|
52
|
+
/** Toggle the auto-approval of an existing (still-active) link code. */
|
|
53
|
+
export const linkCodeUpdateSchema = z.object({
|
|
54
|
+
autoApprove: z.boolean()
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type LinkCodeUpdate = z.infer<typeof linkCodeUpdateSchema>;
|
|
58
|
+
|
|
59
|
+
/** Currently-active (unconsumed, unexpired) link codes for the caller. */
|
|
60
|
+
export const linkCodesListResponseSchema = z.object({
|
|
61
|
+
codes: z.array(linkCodeResponseSchema)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export type LinkCodesListResponse = z.infer<typeof linkCodesListResponseSchema>;
|
|
65
|
+
|
|
66
|
+
export const enrollDeviceRequestSchema = z.object({
|
|
67
|
+
code: z.string().min(6).max(32),
|
|
68
|
+
name: z.string().min(1).max(128),
|
|
69
|
+
fingerprint: z.string().min(1).max(128),
|
|
70
|
+
platform: devicePlatformSchema.default('linux'),
|
|
71
|
+
/** X25519 public key (base64) for command signature verification. */
|
|
72
|
+
publicKey: z.string().min(1).max(256)
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type EnrollDeviceRequest = z.infer<typeof enrollDeviceRequestSchema>;
|
|
76
|
+
|
|
77
|
+
export const enrollDeviceResponseSchema = z.object({
|
|
78
|
+
deviceId: z.uuid(),
|
|
79
|
+
/** Long-lived device token (JWT). Stored only on the agent. */
|
|
80
|
+
deviceToken: z.string().min(1),
|
|
81
|
+
device: deviceSchema
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export type EnrollDeviceResponse = z.infer<typeof enrollDeviceResponseSchema>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Agent download matrix — the **single source of truth** for the set of
|
|
88
|
+
* platform binaries shipped with a release. Consumed by:
|
|
89
|
+
* - the web UI (the "Télécharger l'agent" two-step picker), and
|
|
90
|
+
* - the server (validates the `:target` param and resolves the file on disk).
|
|
91
|
+
*
|
|
92
|
+
* The CI release workflow and `agent/build-all.sh` mirror the same labels (they
|
|
93
|
+
* can't import TS) — keep all three in sync when adding/removing a target.
|
|
94
|
+
*/
|
|
95
|
+
export const agentTargetSchema = z.enum([
|
|
96
|
+
'linux-x86_64',
|
|
97
|
+
'linux-aarch64',
|
|
98
|
+
'linux-armv7',
|
|
99
|
+
'macos-x86_64',
|
|
100
|
+
'macos-arm64',
|
|
101
|
+
'windows-x86_64',
|
|
102
|
+
'windows-x86',
|
|
103
|
+
'windows-arm64'
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
export type AgentTarget = z.infer<typeof agentTargetSchema>;
|
|
107
|
+
|
|
108
|
+
/** Coarse OS family, used to group targets in the picker (Apple / Linux / Windows). */
|
|
109
|
+
export type AgentOs = 'linux' | 'macos' | 'windows';
|
|
110
|
+
|
|
111
|
+
export interface AgentTargetMeta {
|
|
112
|
+
/** Stable id used in the URL and as the download key. */
|
|
113
|
+
id: AgentTarget;
|
|
114
|
+
/** OS family the target belongs to (drives the first picker step). */
|
|
115
|
+
os: AgentOs;
|
|
116
|
+
/** Human-readable architecture label (shown in the second picker step). */
|
|
117
|
+
label: string;
|
|
118
|
+
/** Asset/file name served from `AGENT_DIST_DIR` (Windows carries `.exe`). */
|
|
119
|
+
filename: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Ordered metadata for every shippable target (drives the picker + file lookup). */
|
|
123
|
+
export const AGENT_TARGETS: readonly AgentTargetMeta[] = [
|
|
124
|
+
{
|
|
125
|
+
id: 'macos-arm64',
|
|
126
|
+
os: 'macos',
|
|
127
|
+
label: 'Apple Silicon',
|
|
128
|
+
filename: 'deveye-agent-macos-arm64'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'macos-x86_64',
|
|
132
|
+
os: 'macos',
|
|
133
|
+
label: 'Apple Intel',
|
|
134
|
+
filename: 'deveye-agent-macos-x86_64'
|
|
135
|
+
},
|
|
136
|
+
{ id: 'linux-x86_64', os: 'linux', label: 'Linux x64', filename: 'deveye-agent-linux-x86_64' },
|
|
137
|
+
{
|
|
138
|
+
id: 'linux-aarch64',
|
|
139
|
+
os: 'linux',
|
|
140
|
+
label: 'Linux ARM64',
|
|
141
|
+
filename: 'deveye-agent-linux-aarch64'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'linux-armv7',
|
|
145
|
+
os: 'linux',
|
|
146
|
+
label: 'Linux ARM 32-bit (Raspberry Pi)',
|
|
147
|
+
filename: 'deveye-agent-linux-armv7'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: 'windows-x86_64',
|
|
151
|
+
os: 'windows',
|
|
152
|
+
label: 'Windows x64',
|
|
153
|
+
filename: 'deveye-agent-windows-x86_64.exe'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: 'windows-x86',
|
|
157
|
+
os: 'windows',
|
|
158
|
+
label: 'Windows x86 (32-bit)',
|
|
159
|
+
filename: 'deveye-agent-windows-x86.exe'
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'windows-arm64',
|
|
163
|
+
os: 'windows',
|
|
164
|
+
label: 'Windows ARM64',
|
|
165
|
+
filename: 'deveye-agent-windows-arm64.exe'
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
/** One target's availability, as reported by `GET /api/agent/targets`. */
|
|
170
|
+
export const agentTargetStatusSchema = z.object({
|
|
171
|
+
id: agentTargetSchema,
|
|
172
|
+
os: z.enum(['linux', 'macos', 'windows']),
|
|
173
|
+
label: z.string(),
|
|
174
|
+
/** Whether the binary is present on the server (greys it out in the UI). */
|
|
175
|
+
available: z.boolean(),
|
|
176
|
+
/** Size in bytes when available, else `null`. */
|
|
177
|
+
sizeBytes: z.number().int().nonnegative().nullable()
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export type AgentTargetStatus = z.infer<typeof agentTargetStatusSchema>;
|
|
181
|
+
|
|
182
|
+
export const agentTargetsResponseSchema = z.object({
|
|
183
|
+
/**
|
|
184
|
+
* DevEye version the served binaries were built from (from the synced
|
|
185
|
+
* manifest), or `null` if nothing has been synced yet. The UI warns when it
|
|
186
|
+
* differs from its own build version (`__APP_VERSION__`).
|
|
187
|
+
*/
|
|
188
|
+
agentVersion: z.string().nullable(),
|
|
189
|
+
targets: z.array(agentTargetStatusSchema)
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export type AgentTargetsResponse = z.infer<typeof agentTargetsResponseSchema>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Manifest published alongside the agent binaries on the rolling release. It is
|
|
196
|
+
* the contract between the CI build and the server's boot-time reconciler: the
|
|
197
|
+
* server compares each target's `sha256` to what's on disk and downloads only
|
|
198
|
+
* the diff. `version` is the DevEye version the binaries were built from.
|
|
199
|
+
*/
|
|
200
|
+
export const agentManifestTargetSchema = z.object({
|
|
201
|
+
id: agentTargetSchema,
|
|
202
|
+
filename: z.string(),
|
|
203
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
204
|
+
size: z.number().int().nonnegative(),
|
|
205
|
+
/**
|
|
206
|
+
* Base64 ed25519 signature over the 32 raw bytes of `sha256`, produced by the
|
|
207
|
+
* CI release with the dedicated update-signing key. The agent verifies it with
|
|
208
|
+
* its embedded public key before self-replacing. **Optional**: a target with no
|
|
209
|
+
* signature stays manually downloadable but can never drive a self-update — so a
|
|
210
|
+
* pre-signing build degrades cleanly instead of being rejected outright.
|
|
211
|
+
*/
|
|
212
|
+
signature: z.string().min(1).optional()
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
export type AgentManifestTarget = z.infer<typeof agentManifestTargetSchema>;
|
|
216
|
+
|
|
217
|
+
export const agentManifestSchema = z.object({
|
|
218
|
+
version: z.string(),
|
|
219
|
+
targets: z.array(agentManifestTargetSchema)
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
export type AgentManifest = z.infer<typeof agentManifestSchema>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Server readiness / boot status (HTTP, `GET /api/status`).
|
|
5
|
+
*
|
|
6
|
+
* Surfaces the deployment/startup tasks the server runs before it is "100%
|
|
7
|
+
* ready" — today just the agent-binary reconcile, but the shape is a generic
|
|
8
|
+
* task list so more steps can be added later. The web client shows a discreet
|
|
9
|
+
* topbar zone while `ready` is false, then hides it for good.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `warning` is a terminal-but-visible outcome: the step finished without fully
|
|
14
|
+
* succeeding, yet the app is usable (e.g. the agent reconcile served an older set
|
|
15
|
+
* because this deploy's build never landed). It keeps the topbar zone shown — like
|
|
16
|
+
* `error` — but reads as a non-blocking caution rather than a hard failure.
|
|
17
|
+
*/
|
|
18
|
+
export const bootTaskStateSchema = z.enum(['pending', 'running', 'done', 'warning', 'error']);
|
|
19
|
+
export type BootTaskState = z.infer<typeof bootTaskStateSchema>;
|
|
20
|
+
|
|
21
|
+
export const bootTaskSchema = z.object({
|
|
22
|
+
/** Stable id (e.g. `agent-sync`). */
|
|
23
|
+
id: z.string(),
|
|
24
|
+
/** Human-readable label shown in the topbar zone. */
|
|
25
|
+
label: z.string(),
|
|
26
|
+
state: bootTaskStateSchema,
|
|
27
|
+
/** 0..1 when known (e.g. binaries downloaded / total), else `null`. */
|
|
28
|
+
progress: z.number().min(0).max(1).nullable(),
|
|
29
|
+
/** Short live detail (e.g. "3/8 binaires"), else `null`. */
|
|
30
|
+
detail: z.string().nullable(),
|
|
31
|
+
/** Error message when `state === 'error'`, else `null`. */
|
|
32
|
+
error: z.string().nullable()
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type BootTask = z.infer<typeof bootTaskSchema>;
|
|
36
|
+
|
|
37
|
+
export const serverStatusSchema = z.object({
|
|
38
|
+
/** True once every task is `done` (or there are none): nothing more to show. */
|
|
39
|
+
ready: z.boolean(),
|
|
40
|
+
/** DevEye server version (its `package.json`). */
|
|
41
|
+
version: z.string(),
|
|
42
|
+
tasks: z.array(bootTaskSchema)
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export type ServerStatus = z.infer<typeof serverStatusSchema>;
|