@deveye/types 0.26.1 → 0.27.1
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 +1 -1
- package/src/domain/featureRegistry.ts +25 -3
- package/src/domain/home.ts +2 -1
- package/src/domain/live.ts +1 -0
- package/src/domain/maintenance.ts +8 -3
- package/src/domain/notifications.ts +3 -1
- package/src/domain/task.test.ts +74 -0
- package/src/domain/task.ts +64 -0
- package/src/domain/workspaceRole.ts +14 -1
- package/src/features/debug.ts +19 -0
- package/src/features/notify.ts +37 -1
- package/src/features/registry.ts +2 -0
- package/src/features/task.ts +44 -0
- package/src/features/workspace.ts +27 -1
- package/src/http/auth.ts +46 -1
- package/src/index.ts +40 -1
- package/src/protocol/agent.ts +39 -0
- package/src/protocol/envelope.test.ts +44 -0
- package/src/protocol/envelope.ts +36 -0
- package/src/sdk/client-ambient.d.ts +154 -12
- package/src/sdk/client.ts +37 -0
- package/src/sdk/manifest.ts +1 -1
- package/src/sdk/providers.ts +168 -38
- package/src/sdk/server.ts +68 -1
- package/src/sdk/testing.test.ts +18 -0
- package/src/sdk/testing.ts +97 -10
package/package.json
CHANGED
|
@@ -296,9 +296,12 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
296
296
|
id: 'cve',
|
|
297
297
|
label: 'Veille CVE',
|
|
298
298
|
description:
|
|
299
|
-
'Lecture : le fil des vulnérabilités et la recherche. Écriture : épingler, et poser la clé du NVD.',
|
|
299
|
+
'Lecture : ce qui touche l’espace, l’inventaire, le fil des vulnérabilités et la recherche. Écriture : ignorer un constat, relire ou sortir un élément de la veille, régler la détection, épingler, et poser la clé du NVD.',
|
|
300
300
|
icon: 'bug',
|
|
301
|
-
notifies:
|
|
301
|
+
notifies: true,
|
|
302
|
+
notifications: {
|
|
303
|
+
hint: 'Envoyées quand une faille publiée touche ce que l’espace fait tourner : un dépôt, et ce qu’il emploie. Une alerte par faille, qui nomme les éléments touchés ; chaque genre d’alerte se coupe dans l’onglet Détection.'
|
|
304
|
+
},
|
|
302
305
|
hasItems: false,
|
|
303
306
|
shareTier: 'never',
|
|
304
307
|
sources: {
|
|
@@ -383,6 +386,24 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
383
386
|
hasItems: true,
|
|
384
387
|
itemNoun: 'tableau',
|
|
385
388
|
shareTier: 'open'
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: 'appstores',
|
|
392
|
+
label: 'Stores',
|
|
393
|
+
description:
|
|
394
|
+
'Lecture : les téléchargements, les notes et les avis des apps. Écriture : suivre une app, relier un compte de store, répondre aux avis. Les revenus demandent leur propre permission.',
|
|
395
|
+
icon: 'appstores',
|
|
396
|
+
notifies: true,
|
|
397
|
+
notifications: {
|
|
398
|
+
hint: 'Envoyées à l’arrivée de nouveaux avis, quand Apple change l’état d’une version, quand le taux de plantage d’une app franchit le seuil de Google Play, et quand un compte de store refuse sa clé puis l’accepte de nouveau.'
|
|
399
|
+
},
|
|
400
|
+
hasItems: true,
|
|
401
|
+
itemNoun: 'app',
|
|
402
|
+
itemNounGender: 'f',
|
|
403
|
+
sources: {
|
|
404
|
+
hint: 'Les comptes App Store Connect et Google Play de l’espace, chacun avec sa clé. Chaque app choisit le sien pour chaque store ; ses chiffres et ses avis arrivent alors seuls.'
|
|
405
|
+
},
|
|
406
|
+
shareTier: 'open'
|
|
386
407
|
}
|
|
387
408
|
];
|
|
388
409
|
|
|
@@ -518,7 +539,8 @@ export const PROJECT_LINKED_FEATURES: readonly FeatureId[] = [
|
|
|
518
539
|
'deploy',
|
|
519
540
|
'uptime',
|
|
520
541
|
'x-hosting',
|
|
521
|
-
'whiteboard'
|
|
542
|
+
'whiteboard',
|
|
543
|
+
'appstores'
|
|
522
544
|
];
|
|
523
545
|
|
|
524
546
|
/** Les fonctionnalités qui savent prévenir, dans l'ordre du registre. */
|
package/src/domain/home.ts
CHANGED
package/src/domain/live.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
import { taskRosterSchema } from './task';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Maintenance, site-wide or per feature, set by the global admin (or by the
|
|
5
7
|
* database and the `MAINTENANCE` variable when the interface is out of reach).
|
|
@@ -50,12 +52,15 @@ export const MAINTENANCE_MESSAGE_MAX = 1000;
|
|
|
50
52
|
/**
|
|
51
53
|
* The `session` frame that opens every socket. `version` is the server's app
|
|
52
54
|
* version, which a client compares with its own bundle to reload after an
|
|
53
|
-
* update. `
|
|
54
|
-
*
|
|
55
|
+
* update. `tasks` is what the operations area of the account shows, so a page
|
|
56
|
+
* that reloads finds its long operations again. `version`, `maintenance` and
|
|
57
|
+
* `tasks` are optional: a remote instance on an older version does not send
|
|
58
|
+
* them.
|
|
55
59
|
*/
|
|
56
60
|
export const sessionFrameSchema = z.object({
|
|
57
61
|
userId: z.number().int().positive(),
|
|
58
62
|
version: z.string().optional(),
|
|
59
|
-
maintenance: maintenanceStateSchema.optional()
|
|
63
|
+
maintenance: maintenanceStateSchema.optional(),
|
|
64
|
+
tasks: taskRosterSchema.optional()
|
|
60
65
|
});
|
|
61
66
|
export type SessionFrame = z.infer<typeof sessionFrameSchema>;
|
|
@@ -45,7 +45,9 @@ export const nativeNotificationFeatureSchema = z.enum([
|
|
|
45
45
|
'convert',
|
|
46
46
|
'invoicing',
|
|
47
47
|
'finance',
|
|
48
|
-
'shortlinks'
|
|
48
|
+
'shortlinks',
|
|
49
|
+
'cve',
|
|
50
|
+
'appstores'
|
|
49
51
|
]);
|
|
50
52
|
export type NativeNotificationFeature = z.infer<typeof nativeNotificationFeatureSchema>;
|
|
51
53
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { sessionFrameSchema } from './maintenance';
|
|
5
|
+
import { taskRemovedSchema, taskRosterSchema, taskSchema } from './task';
|
|
6
|
+
|
|
7
|
+
const ID = '0b6f5e0a-2a57-4a55-9a56-0d7c1d2a3b4c';
|
|
8
|
+
|
|
9
|
+
const running = {
|
|
10
|
+
id: ID,
|
|
11
|
+
state: 'running',
|
|
12
|
+
title: 'Suppression du point de restauration',
|
|
13
|
+
subject: 'Documents',
|
|
14
|
+
feature: 'cloudsync',
|
|
15
|
+
itemId: '12',
|
|
16
|
+
key: 'snapshot.delete',
|
|
17
|
+
workspaceId: 3,
|
|
18
|
+
startedAt: 1_794_000_000_000,
|
|
19
|
+
endedAt: null,
|
|
20
|
+
progress: { done: 2, total: 8, step: 'Libération' },
|
|
21
|
+
cancellable: false,
|
|
22
|
+
done: 'Point de restauration supprimé.',
|
|
23
|
+
failed: 'Suppression impossible.',
|
|
24
|
+
error: null
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('taskSchema', () => {
|
|
28
|
+
it('reads a running operation, measured or not', () => {
|
|
29
|
+
assert.equal(taskSchema.parse(running).progress?.done, 2);
|
|
30
|
+
assert.equal(taskSchema.parse({ ...running, progress: null }).progress, null);
|
|
31
|
+
assert.equal(taskSchema.parse({ ...running, progress: {} }).progress?.total, undefined);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('carries the code and the sentence of a failure, nothing else', () => {
|
|
35
|
+
const failed = taskSchema.parse({
|
|
36
|
+
...running,
|
|
37
|
+
state: 'failed',
|
|
38
|
+
endedAt: 1_794_000_009_000,
|
|
39
|
+
error: { code: 'conflict', message: 'Déjà en cours.', details: { input: 'secret' } }
|
|
40
|
+
});
|
|
41
|
+
assert.deepEqual(failed.error, { code: 'conflict', message: 'Déjà en cours.' });
|
|
42
|
+
assert.equal(
|
|
43
|
+
taskSchema.safeParse({
|
|
44
|
+
...running,
|
|
45
|
+
state: 'failed',
|
|
46
|
+
error: { code: 'nope', message: 'x' }
|
|
47
|
+
}).success,
|
|
48
|
+
false
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('refuses a state the area does not know and an operation without a workspace', () => {
|
|
53
|
+
assert.equal(taskSchema.safeParse({ ...running, state: 'lost' }).success, false);
|
|
54
|
+
assert.equal(taskSchema.safeParse({ ...running, workspaceId: 0 }).success, false);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('the roster of the session frame', () => {
|
|
59
|
+
it('travels with the frame, which stays valid without it', () => {
|
|
60
|
+
const frame = { userId: 1, version: '0.26.1' };
|
|
61
|
+
assert.equal(sessionFrameSchema.parse(frame).tasks, undefined);
|
|
62
|
+
const withTasks = sessionFrameSchema.parse({
|
|
63
|
+
...frame,
|
|
64
|
+
tasks: { epoch: 'a', list: [running] }
|
|
65
|
+
});
|
|
66
|
+
assert.equal(withTasks.tasks?.list[0]?.id, ID);
|
|
67
|
+
assert.equal(taskRosterSchema.safeParse({ epoch: '', list: [] }).success, false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('names the operations a dismissal removes', () => {
|
|
71
|
+
assert.deepEqual(taskRemovedSchema.parse({ ids: [ID] }).ids, [ID]);
|
|
72
|
+
assert.equal(taskRemovedSchema.safeParse({ ids: ['../x'] }).success, false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TASK_TEXT_MAX,
|
|
5
|
+
TASK_TITLE_MAX,
|
|
6
|
+
requestProgressSchema,
|
|
7
|
+
taskIdSchema
|
|
8
|
+
} from '../protocol/envelope';
|
|
9
|
+
import { ErrorCodeSchema } from '../protocol/error';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A long operation, as the server follows it and as the operations area of the
|
|
13
|
+
* top bar shows it: a command a client tagged, or the work a service runs for
|
|
14
|
+
* an account. It belongs to the account that started it and is never shown to
|
|
15
|
+
* the other members of the workspace.
|
|
16
|
+
*
|
|
17
|
+
* The server keeps it in memory only: a restart forgets every operation, and
|
|
18
|
+
* the `epoch` of the roster tells a client that it happened.
|
|
19
|
+
*/
|
|
20
|
+
export const taskStateSchema = z.enum(['running', 'done', 'failed']);
|
|
21
|
+
export type TaskState = z.infer<typeof taskStateSchema>;
|
|
22
|
+
|
|
23
|
+
export const taskSchema = z.object({
|
|
24
|
+
id: taskIdSchema,
|
|
25
|
+
state: taskStateSchema,
|
|
26
|
+
title: z.string().max(TASK_TITLE_MAX),
|
|
27
|
+
subject: z.string().max(TASK_TEXT_MAX).nullable(),
|
|
28
|
+
feature: z.string().max(64).nullable(),
|
|
29
|
+
itemId: z.string().max(64).nullable(),
|
|
30
|
+
key: z.string().max(64).nullable(),
|
|
31
|
+
/** The workspace the command ran in. */
|
|
32
|
+
workspaceId: z.number().int().positive(),
|
|
33
|
+
/** Milliseconds since the epoch. */
|
|
34
|
+
startedAt: z.number().int(),
|
|
35
|
+
endedAt: z.number().int().nullable(),
|
|
36
|
+
progress: requestProgressSchema.omit({ requestId: true }).nullable(),
|
|
37
|
+
/** The account may ask it to stop (`task.cancel`): an operation a service runs and knows how to stop. */
|
|
38
|
+
cancellable: z.boolean(),
|
|
39
|
+
/** The caller's sentences, for a tab that did not start the operation. */
|
|
40
|
+
done: z.string().max(TASK_TEXT_MAX).nullable(),
|
|
41
|
+
failed: z.string().max(TASK_TEXT_MAX).nullable(),
|
|
42
|
+
/** Why it failed. Never the `details` of the refusal: they may quote the input. */
|
|
43
|
+
error: z.object({ code: ErrorCodeSchema, message: z.string().max(500) }).nullable()
|
|
44
|
+
});
|
|
45
|
+
export type TaskSnapshot = z.infer<typeof taskSchema>;
|
|
46
|
+
|
|
47
|
+
/** An operation appeared, moved on or ended. Payload: {@link taskSchema}. */
|
|
48
|
+
export const TASK_UPDATE_EVENT = 'task.update' as const;
|
|
49
|
+
|
|
50
|
+
/** Operations were dismissed, here or in another tab. */
|
|
51
|
+
export const TASK_REMOVED_EVENT = 'task.removed' as const;
|
|
52
|
+
export const taskRemovedSchema = z.object({ ids: z.array(taskIdSchema).max(200) });
|
|
53
|
+
export type TaskRemoved = z.infer<typeof taskRemovedSchema>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The operations of the account when a socket opens, carried by the `session`
|
|
57
|
+
* frame. `epoch` changes with every start of the server: an operation a client
|
|
58
|
+
* still shows as running and that a new epoch does not list was interrupted.
|
|
59
|
+
*/
|
|
60
|
+
export const taskRosterSchema = z.object({
|
|
61
|
+
epoch: z.string().min(1).max(64),
|
|
62
|
+
list: z.array(taskSchema).max(200)
|
|
63
|
+
});
|
|
64
|
+
export type TaskRoster = z.infer<typeof taskRosterSchema>;
|
|
@@ -125,7 +125,13 @@ export const workspaceFeatureIdSchema = z.enum([
|
|
|
125
125
|
* dessine, `write` = créer un tableau, dessiner, y coller des images, le
|
|
126
126
|
* renommer, le supprimer.
|
|
127
127
|
*/
|
|
128
|
-
'whiteboard'
|
|
128
|
+
'whiteboard',
|
|
129
|
+
/**
|
|
130
|
+
* Stores. `read` = consulter les chiffres, les notes et les avis des apps,
|
|
131
|
+
* `write` = suivre une app, relier un compte de store et sa clé, répondre
|
|
132
|
+
* aux avis. Les revenus sont une permission propre du module.
|
|
133
|
+
*/
|
|
134
|
+
'appstores'
|
|
129
135
|
]);
|
|
130
136
|
|
|
131
137
|
export type WorkspaceFeatureId = z.infer<typeof workspaceFeatureIdSchema>;
|
|
@@ -218,6 +224,12 @@ export const workspaceRoleSchema = z.object({
|
|
|
218
224
|
position: z.number().int().nonnegative(),
|
|
219
225
|
capabilities: z.array(workspaceCapabilitySchema),
|
|
220
226
|
features: z.array(workspaceFeatureGrantSchema),
|
|
227
|
+
/**
|
|
228
|
+
* Écriture et tous les réglages sur chaque fonctionnalité, celles installées
|
|
229
|
+
* plus tard comprises : `features` est alors ignoré. Les capacités restent
|
|
230
|
+
* celles du rôle.
|
|
231
|
+
*/
|
|
232
|
+
allFeatures: z.boolean(),
|
|
221
233
|
/** Attribué d'office à qui rejoint l'espace. */
|
|
222
234
|
isDefault: z.boolean(),
|
|
223
235
|
memberCount: z.number().int().nonnegative()
|
|
@@ -236,6 +248,7 @@ export interface WorkspaceRoleRow {
|
|
|
236
248
|
capabilities: string;
|
|
237
249
|
/** Tableau JSON de `WorkspaceFeatureGrant`. */
|
|
238
250
|
features: string;
|
|
251
|
+
all_features: number;
|
|
239
252
|
is_default: number;
|
|
240
253
|
created: number;
|
|
241
254
|
}
|
package/src/features/debug.ts
CHANGED
|
@@ -263,6 +263,24 @@ export const debugE2eSweep = {
|
|
|
263
263
|
output: z.object({ accounts: z.number().int().nonnegative() })
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
+
/**
|
|
267
|
+
* A slow command that reports its progress, then succeeds or fails on demand:
|
|
268
|
+
* what the gallery runs to show a long operation the server follows. `quiet`
|
|
269
|
+
* keeps it silent until the end, like a handler that reports nothing.
|
|
270
|
+
* `background` answers at once and lets the work go on as an operation a
|
|
271
|
+
* service runs, which the area can cancel.
|
|
272
|
+
*/
|
|
273
|
+
export const debugTaskSample = {
|
|
274
|
+
command: 'debug.taskSample' as const,
|
|
275
|
+
input: z.object({
|
|
276
|
+
seconds: z.number().int().min(1).max(120),
|
|
277
|
+
fail: z.boolean().optional(),
|
|
278
|
+
quiet: z.boolean().optional(),
|
|
279
|
+
background: z.boolean().optional()
|
|
280
|
+
}),
|
|
281
|
+
output: z.object({ steps: z.number().int().nonnegative() })
|
|
282
|
+
};
|
|
283
|
+
|
|
266
284
|
export const debugProbeSchema = z.object({
|
|
267
285
|
id: z.string(),
|
|
268
286
|
label: z.string(),
|
|
@@ -486,6 +504,7 @@ export const debugCommands = [
|
|
|
486
504
|
debugE2eCatalog,
|
|
487
505
|
debugE2eStart,
|
|
488
506
|
debugE2eSweep,
|
|
507
|
+
debugTaskSample,
|
|
489
508
|
debugBenchCatalog,
|
|
490
509
|
debugBenchStart,
|
|
491
510
|
debugPing,
|
package/src/features/notify.ts
CHANGED
|
@@ -112,6 +112,38 @@ export const notifyRouteTest = {
|
|
|
112
112
|
output: notificationTestSchema
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* The "nothing would be sent" notice of one page, as the caller left it: a
|
|
117
|
+
* feature's list in the envelope's workspace (no `itemId`), or an item's
|
|
118
|
+
* sheet. Hidden for that account only, until it brings them all back.
|
|
119
|
+
*/
|
|
120
|
+
export const notifyNoticeGet = {
|
|
121
|
+
command: 'notify.noticeGet' as const,
|
|
122
|
+
input: notificationRouteTargetSchema,
|
|
123
|
+
output: z.object({ hidden: z.boolean() })
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** Hides that notice for the caller, on that page only. */
|
|
127
|
+
export const notifyNoticeHide = {
|
|
128
|
+
command: 'notify.noticeHide' as const,
|
|
129
|
+
input: notificationRouteTargetSchema,
|
|
130
|
+
output: z.object({})
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** How many pages the account hid the notice on, every workspace included. */
|
|
134
|
+
export const notifyNoticeCount = {
|
|
135
|
+
command: 'notify.noticeCount' as const,
|
|
136
|
+
input: z.object({}),
|
|
137
|
+
output: z.object({ count: z.number().int().nonnegative() })
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** Brings the notice back on every page the account hid it on. */
|
|
141
|
+
export const notifyNoticeReset = {
|
|
142
|
+
command: 'notify.noticeReset' as const,
|
|
143
|
+
input: z.object({}),
|
|
144
|
+
output: z.object({})
|
|
145
|
+
};
|
|
146
|
+
|
|
115
147
|
export const notifyCommands = [
|
|
116
148
|
notifyChannelList,
|
|
117
149
|
notifyChannelAdd,
|
|
@@ -122,5 +154,9 @@ export const notifyCommands = [
|
|
|
122
154
|
notifyChannelTest,
|
|
123
155
|
notifyRouteGet,
|
|
124
156
|
notifyRouteSet,
|
|
125
|
-
notifyRouteTest
|
|
157
|
+
notifyRouteTest,
|
|
158
|
+
notifyNoticeGet,
|
|
159
|
+
notifyNoticeHide,
|
|
160
|
+
notifyNoticeCount,
|
|
161
|
+
notifyNoticeReset
|
|
126
162
|
] as const;
|
package/src/features/registry.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { sharingCommands } from './sharing';
|
|
|
12
12
|
import { secrecyCommands } from './secrecy';
|
|
13
13
|
import { loginChecksCommands } from './loginChecks';
|
|
14
14
|
import { stepUpCommands } from './stepUp';
|
|
15
|
+
import { taskCommands } from './task';
|
|
15
16
|
import { twoFactorCommands } from './twoFactor';
|
|
16
17
|
import { userCommands } from './user';
|
|
17
18
|
import { adminCommands } from './admin';
|
|
@@ -33,6 +34,7 @@ export const featureCommands = [
|
|
|
33
34
|
...agentCommands,
|
|
34
35
|
...twoFactorCommands,
|
|
35
36
|
...stepUpCommands,
|
|
37
|
+
...taskCommands,
|
|
36
38
|
...loginChecksCommands,
|
|
37
39
|
...secrecyCommands,
|
|
38
40
|
...logsCommands,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { taskIdSchema } from '../protocol/envelope';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Claims the operations whose request this page still awaits, after its socket
|
|
6
|
+
* came back: the server sends their answer to this socket when they end, or at
|
|
7
|
+
* once when they already have. `lost`: the ones it no longer knows (it
|
|
8
|
+
* restarted, the answer expired) or that this page did not start.
|
|
9
|
+
*/
|
|
10
|
+
export const taskAttach = {
|
|
11
|
+
command: 'task.attach' as const,
|
|
12
|
+
input: z.object({
|
|
13
|
+
claims: z
|
|
14
|
+
.array(z.object({ id: taskIdSchema, requestId: z.string().min(1).max(64) }))
|
|
15
|
+
.min(1)
|
|
16
|
+
.max(50)
|
|
17
|
+
}),
|
|
18
|
+
output: z.object({ lost: z.array(taskIdSchema) })
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Removes operations from the account's area, in every tab. On one that still
|
|
23
|
+
* runs it only stops following it: the command goes on. Unknown ids are
|
|
24
|
+
* ignored; the answer lists the ones removed.
|
|
25
|
+
*/
|
|
26
|
+
export const taskDismiss = {
|
|
27
|
+
command: 'task.dismiss' as const,
|
|
28
|
+
input: z.object({ ids: z.array(taskIdSchema).min(1).max(50) }),
|
|
29
|
+
output: z.object({ ids: z.array(taskIdSchema) })
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Asks a running operation to stop: one a service runs and declared it can
|
|
34
|
+
* stop. `accepted` is false when it cannot (not cancellable, already ended,
|
|
35
|
+
* the account lost the feature); the operation leaves the area when the
|
|
36
|
+
* service has actually stopped.
|
|
37
|
+
*/
|
|
38
|
+
export const taskCancel = {
|
|
39
|
+
command: 'task.cancel' as const,
|
|
40
|
+
input: z.object({ id: taskIdSchema }),
|
|
41
|
+
output: z.object({ accepted: z.boolean() })
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const taskCommands = [taskAttach, taskDismiss, taskCancel] as const;
|
|
@@ -3,6 +3,8 @@ import { homeLayoutSchema } from '../domain/home';
|
|
|
3
3
|
import { workspaceSchema } from '../domain/workspace';
|
|
4
4
|
import {
|
|
5
5
|
WORKSPACE_ROLE_NAME_MAX,
|
|
6
|
+
featureAccessSchema,
|
|
7
|
+
featureIdSchema,
|
|
6
8
|
workspaceCapabilitySchema,
|
|
7
9
|
workspaceFeatureGrantSchema,
|
|
8
10
|
workspacePermissionsSchema,
|
|
@@ -140,7 +142,8 @@ const roleDraftSchema = z.object({
|
|
|
140
142
|
name: z.string().min(1).max(WORKSPACE_ROLE_NAME_MAX),
|
|
141
143
|
color: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
|
142
144
|
capabilities: z.array(workspaceCapabilitySchema),
|
|
143
|
-
features: z.array(workspaceFeatureGrantSchema)
|
|
145
|
+
features: z.array(workspaceFeatureGrantSchema),
|
|
146
|
+
allFeatures: z.boolean()
|
|
144
147
|
});
|
|
145
148
|
|
|
146
149
|
export const workspaceRoleList = {
|
|
@@ -186,6 +189,28 @@ export const workspaceRoleSetDefault = {
|
|
|
186
189
|
output: z.object({ roleId: z.number().int().positive() })
|
|
187
190
|
};
|
|
188
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Ouvre une fonctionnalité à des rôles, en un geste : l'étape d'accès qui suit
|
|
194
|
+
* l'ajout de sa tuile. Un grant neuf ne porte que le niveau ; un grant existant
|
|
195
|
+
* garde ses réglages et ne fait que monter. Un rôle `allFeatures` est ignoré.
|
|
196
|
+
*/
|
|
197
|
+
export const workspaceFeatureAccessSet = {
|
|
198
|
+
command: 'workspace.featureAccessSet' as const,
|
|
199
|
+
input: z.object({
|
|
200
|
+
feature: featureIdSchema,
|
|
201
|
+
grants: z
|
|
202
|
+
.array(
|
|
203
|
+
z.object({
|
|
204
|
+
roleId: z.number().int().positive(),
|
|
205
|
+
access: featureAccessSchema
|
|
206
|
+
})
|
|
207
|
+
)
|
|
208
|
+
.min(1)
|
|
209
|
+
.max(100)
|
|
210
|
+
}),
|
|
211
|
+
output: z.object({ roleIds: z.array(z.number().int().positive()) })
|
|
212
|
+
};
|
|
213
|
+
|
|
189
214
|
/** Attribue un rôle à un membre. `null` le laisse sans aucun droit. */
|
|
190
215
|
export const workspaceAssignRole = {
|
|
191
216
|
command: 'workspace.assignRole' as const,
|
|
@@ -205,6 +230,7 @@ export const workspaceCommands = [
|
|
|
205
230
|
workspaceRoleUpdate,
|
|
206
231
|
workspaceRoleDelete,
|
|
207
232
|
workspaceRoleSetDefault,
|
|
233
|
+
workspaceFeatureAccessSet,
|
|
208
234
|
workspaceAssignRole,
|
|
209
235
|
workspaceRename,
|
|
210
236
|
workspaceLeave,
|
package/src/http/auth.ts
CHANGED
|
@@ -45,7 +45,8 @@ export const sessionBundleSchema = z.object({
|
|
|
45
45
|
export type SessionBundle = z.infer<typeof sessionBundleSchema>;
|
|
46
46
|
|
|
47
47
|
export const loginRequestSchema = z.object({
|
|
48
|
-
|
|
48
|
+
/** The account name, or its email address (a name never holds an "@"). */
|
|
49
|
+
username: z.string().min(1).max(320),
|
|
49
50
|
password: z.string().min(1).max(512),
|
|
50
51
|
/** A federated page's trusted-browser token for this account; a same-origin page holds a cookie instead. */
|
|
51
52
|
trustToken: z.string().max(256).optional()
|
|
@@ -234,3 +235,47 @@ export const signupCompleteResponseSchema = sessionBundleSchema.extend({
|
|
|
234
235
|
});
|
|
235
236
|
|
|
236
237
|
export type SignupCompleteResponse = z.infer<typeof signupCompleteResponseSchema>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Forgotten password, in three steps: ask with the account's email
|
|
241
|
+
* (`/password-reset`), open the mailed link (`/password-reset/verify`), choose
|
|
242
|
+
* a new password (`/password-reset/complete`). The first step answers the same
|
|
243
|
+
* whether the address has an account or not. No session is opened at the end:
|
|
244
|
+
* the person signs in again, second factors included.
|
|
245
|
+
*/
|
|
246
|
+
export const passwordResetStartRequestSchema = z.object({ email: z.string().email().max(320) });
|
|
247
|
+
|
|
248
|
+
export type PasswordResetStartRequest = z.infer<typeof passwordResetStartRequestSchema>;
|
|
249
|
+
|
|
250
|
+
export const passwordResetVerifyRequestSchema = z.object({ token: z.string().min(1).max(128) });
|
|
251
|
+
|
|
252
|
+
export type PasswordResetVerifyRequest = z.infer<typeof passwordResetVerifyRequestSchema>;
|
|
253
|
+
|
|
254
|
+
export const passwordResetVerifyResponseSchema = z.object({
|
|
255
|
+
username: z.string(),
|
|
256
|
+
/**
|
|
257
|
+
* The account's data is encrypted under its password: the recovery code
|
|
258
|
+
* chosen at activation must come with the new password, or that data
|
|
259
|
+
* would be lost.
|
|
260
|
+
*/
|
|
261
|
+
recoveryRequired: z.boolean()
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
export type PasswordResetVerifyResponse = z.infer<typeof passwordResetVerifyResponseSchema>;
|
|
265
|
+
|
|
266
|
+
export const passwordResetCompleteRequestSchema = z.object({
|
|
267
|
+
token: z.string().min(1).max(128),
|
|
268
|
+
password: passwordSchema,
|
|
269
|
+
/** Required when `recoveryRequired`, ignored otherwise. */
|
|
270
|
+
recoveryCode: z.string().max(64).optional()
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
export type PasswordResetCompleteRequest = z.infer<typeof passwordResetCompleteRequestSchema>;
|
|
274
|
+
|
|
275
|
+
export const passwordResetCompleteResponseSchema = z.object({
|
|
276
|
+
username: z.string(),
|
|
277
|
+
/** The recovery code that replaces the one just used, shown once. `null` when none was needed. */
|
|
278
|
+
recoveryCode: z.string().nullable()
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
export type PasswordResetCompleteResponse = z.infer<typeof passwordResetCompleteResponseSchema>;
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
export {
|
|
2
2
|
clientMessageSchema,
|
|
3
|
+
commandTaskSchema,
|
|
3
4
|
REQUEST_PROGRESS_EVENT,
|
|
4
5
|
requestProgressSchema,
|
|
5
|
-
serverMessageSchema
|
|
6
|
+
serverMessageSchema,
|
|
7
|
+
TASK_TEXT_MAX,
|
|
8
|
+
TASK_TITLE_MAX,
|
|
9
|
+
taskIdSchema
|
|
6
10
|
} from './protocol/envelope';
|
|
7
11
|
export type {
|
|
8
12
|
ClientMessage,
|
|
13
|
+
CommandTask,
|
|
9
14
|
ConnectionState,
|
|
10
15
|
RequestProgress,
|
|
11
16
|
ServerMessage
|
|
12
17
|
} from './protocol/envelope';
|
|
18
|
+
export {
|
|
19
|
+
TASK_REMOVED_EVENT,
|
|
20
|
+
TASK_UPDATE_EVENT,
|
|
21
|
+
taskRemovedSchema,
|
|
22
|
+
taskRosterSchema,
|
|
23
|
+
taskSchema,
|
|
24
|
+
taskStateSchema
|
|
25
|
+
} from './domain/task';
|
|
26
|
+
export type { TaskRemoved, TaskRoster, TaskSnapshot, TaskState } from './domain/task';
|
|
13
27
|
export { ErrorCodeSchema, ProtocolErrorSchema } from './protocol/error';
|
|
14
28
|
export type { ErrorCode, ProtocolError } from './protocol/error';
|
|
15
29
|
export { err, ok, resultSchema } from './protocol/result';
|
|
@@ -53,6 +67,12 @@ export {
|
|
|
53
67
|
AGENT_DOCKER_DONE,
|
|
54
68
|
AGENT_DOCKER_INVENTORY,
|
|
55
69
|
AGENT_DOCKER_INVENTORY_RESULT,
|
|
70
|
+
AGENT_PKG_INVENTORY,
|
|
71
|
+
AGENT_PKG_INVENTORY_PROBE,
|
|
72
|
+
AGENT_PKG_INVENTORY_RESULT,
|
|
73
|
+
agentPkgInventoryResultPayloadSchema,
|
|
74
|
+
installedPackageSchema,
|
|
75
|
+
packageInventorySchema,
|
|
56
76
|
AGENT_DOCKER_PROGRESS,
|
|
57
77
|
AGENT_DOCKER_STATS,
|
|
58
78
|
AGENT_DOCKER_STATS_RESULT,
|
|
@@ -326,8 +346,10 @@ export type {
|
|
|
326
346
|
DeviceTermExitPush,
|
|
327
347
|
DeviceTermOutputPush,
|
|
328
348
|
MetricsPush,
|
|
349
|
+
InstalledPackage,
|
|
329
350
|
PackageCountPush,
|
|
330
351
|
PackageDonePush,
|
|
352
|
+
PackageInventory,
|
|
331
353
|
PackageListPush,
|
|
332
354
|
PackageProgressPush,
|
|
333
355
|
PackageStartedPush,
|
|
@@ -1015,6 +1037,7 @@ export {
|
|
|
1015
1037
|
debugRunList,
|
|
1016
1038
|
debugRunSchema,
|
|
1017
1039
|
debugRunStatusSchema,
|
|
1040
|
+
debugTaskSample,
|
|
1018
1041
|
debugStepStatusSchema,
|
|
1019
1042
|
debugTrackingClear,
|
|
1020
1043
|
debugTrackingCompanionSchema,
|
|
@@ -1062,6 +1085,7 @@ export {
|
|
|
1062
1085
|
workspaceAcceptInvite,
|
|
1063
1086
|
workspaceDeclineInvite,
|
|
1064
1087
|
workspaceAssignRole,
|
|
1088
|
+
workspaceFeatureAccessSet,
|
|
1065
1089
|
workspaceRename,
|
|
1066
1090
|
workspaceRoleCreate,
|
|
1067
1091
|
workspaceRoleDelete,
|
|
@@ -1137,11 +1161,16 @@ export {
|
|
|
1137
1161
|
notifyChannelUpdate,
|
|
1138
1162
|
notifyChannelUsage,
|
|
1139
1163
|
notifyCommands,
|
|
1164
|
+
notifyNoticeCount,
|
|
1165
|
+
notifyNoticeGet,
|
|
1166
|
+
notifyNoticeHide,
|
|
1167
|
+
notifyNoticeReset,
|
|
1140
1168
|
notifyRouteGet,
|
|
1141
1169
|
notifyRouteSet,
|
|
1142
1170
|
notifyRouteTest
|
|
1143
1171
|
} from './features/notify';
|
|
1144
1172
|
export { stepUpCommands, stepUpConfirm, stepUpSetInterval, stepUpStatus } from './features/stepUp';
|
|
1173
|
+
export { taskAttach, taskCancel, taskCommands, taskDismiss } from './features/task';
|
|
1145
1174
|
export {
|
|
1146
1175
|
loginChecksCommands,
|
|
1147
1176
|
loginChecksForgetBrowser,
|
|
@@ -1209,6 +1238,11 @@ export {
|
|
|
1209
1238
|
loginStepSchema,
|
|
1210
1239
|
loginVerifyRequestSchema,
|
|
1211
1240
|
meResponseSchema,
|
|
1241
|
+
passwordResetCompleteRequestSchema,
|
|
1242
|
+
passwordResetCompleteResponseSchema,
|
|
1243
|
+
passwordResetStartRequestSchema,
|
|
1244
|
+
passwordResetVerifyRequestSchema,
|
|
1245
|
+
passwordResetVerifyResponseSchema,
|
|
1212
1246
|
passwordSchema,
|
|
1213
1247
|
refreshRequestSchema,
|
|
1214
1248
|
refreshResponseSchema,
|
|
@@ -1234,6 +1268,11 @@ export type {
|
|
|
1234
1268
|
LoginStep,
|
|
1235
1269
|
LoginVerifyRequest,
|
|
1236
1270
|
MeResponse,
|
|
1271
|
+
PasswordResetCompleteRequest,
|
|
1272
|
+
PasswordResetCompleteResponse,
|
|
1273
|
+
PasswordResetStartRequest,
|
|
1274
|
+
PasswordResetVerifyRequest,
|
|
1275
|
+
PasswordResetVerifyResponse,
|
|
1237
1276
|
RefreshRequest,
|
|
1238
1277
|
RefreshResponse,
|
|
1239
1278
|
SessionBundle,
|