@deveye/types 0.26.1 → 0.27.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 +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 +7 -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/index.ts +29 -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 +149 -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
|
@@ -25,6 +25,7 @@ declare module 'deveye-sdk-client' {
|
|
|
25
25
|
PointerEvent as ReactPointerEvent
|
|
26
26
|
} from 'react';
|
|
27
27
|
import type {
|
|
28
|
+
CommandTask,
|
|
28
29
|
FeatureAccess,
|
|
29
30
|
FeatureDomain,
|
|
30
31
|
FeatureId,
|
|
@@ -137,22 +138,130 @@ declare module 'deveye-sdk-client' {
|
|
|
137
138
|
className?: string;
|
|
138
139
|
}
|
|
139
140
|
export const ProgressBar: ComponentType<ProgressBarProps>;
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
|
|
142
|
+
// ── Long operations ────────────────────────────────────────────────────
|
|
143
|
+
/** A running operation, as a screen reads it. */
|
|
144
|
+
export interface Task {
|
|
145
|
+
id: string;
|
|
146
|
+
feature: string;
|
|
147
|
+
itemId?: string;
|
|
148
|
+
key?: string;
|
|
142
149
|
title: string;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
/** See {@link ProgressBarProps.value}. */
|
|
150
|
+
subject?: string;
|
|
151
|
+
/** From 0 to 1 when the progress is measured. */
|
|
146
152
|
value?: number;
|
|
147
|
-
/** The current step, under the bar. */
|
|
148
153
|
step?: string;
|
|
154
|
+
startedAt: number;
|
|
155
|
+
}
|
|
156
|
+
export interface TaskOptions<T = unknown> {
|
|
157
|
+
/** Your feature id (`manifest.id`): the icon, the name and the "Ouvrir" of its row. */
|
|
158
|
+
feature: string;
|
|
159
|
+
/** What is being done, as a noun phrase: "Suppression du point de restauration". */
|
|
160
|
+
title: string;
|
|
161
|
+
/** The fallback sentence of a failure, or the function that returns the whole note. */
|
|
162
|
+
failed: string | ((error: unknown) => ErrorNoteInput);
|
|
163
|
+
/** The item it targets: "Ouvrir" leads there, `useTasks` filters on it. */
|
|
164
|
+
itemId?: string | number;
|
|
165
|
+
/**
|
|
166
|
+
* The kind of operation. Two operations with the same feature,
|
|
167
|
+
* workspace, item and key never run together: the second one rejects
|
|
168
|
+
* with `TaskError` `conflict`, `run` is not called.
|
|
169
|
+
*/
|
|
170
|
+
key?: string;
|
|
171
|
+
/** What it acts on (a name), to tell two rows with the same title apart. */
|
|
172
|
+
subject?: string;
|
|
173
|
+
/** Why it is worth the wait: shown in the dialog only. */
|
|
174
|
+
description?: string;
|
|
175
|
+
/** The success sentence of the operations panel; "Terminé." without it. */
|
|
176
|
+
done?: string | ((result: T) => string);
|
|
177
|
+
/** `false`: no dialog, the operation goes straight to the panel and your screen draws the progress. Default true. */
|
|
178
|
+
dialog?: boolean;
|
|
179
|
+
/** `false`: the dialog cannot be minimized, for a step whose follow-up needs the person (a question, a navigation). Default true. */
|
|
180
|
+
minimizable?: boolean;
|
|
181
|
+
/** The work runs in this tab, not on the server: closing the tab asks first. Default false. */
|
|
182
|
+
local?: boolean;
|
|
183
|
+
/** Offers "Annuler"; the operation leaves when `run` then rejects. */
|
|
184
|
+
cancel?: () => void;
|
|
185
|
+
/** Called once, the first time the dialog is minimized: close the sheet of an item that is going away. */
|
|
186
|
+
onDetach?: () => void;
|
|
187
|
+
}
|
|
188
|
+
export interface TaskContext {
|
|
189
|
+
/** The id of the operation, the one `useTasks` returns. */
|
|
190
|
+
id: string;
|
|
191
|
+
/**
|
|
192
|
+
* For THE command that does the work: the server follows it, its
|
|
193
|
+
* progress feeds the operation, and it runs in the workspace the
|
|
194
|
+
* operation started in.
|
|
195
|
+
*/
|
|
196
|
+
sendOptions: SendOptions;
|
|
197
|
+
/** The progress of work done in the tab; `null` clears the value. */
|
|
198
|
+
report(update: { value?: number | null; step?: string | null }): void;
|
|
199
|
+
/** Brings the dialog back to the front, before a prompt that needs the person. */
|
|
200
|
+
raise(): void;
|
|
201
|
+
/** Where the operation started: `instanceId` is `null` for this instance. */
|
|
202
|
+
origin: { instanceId: number | null; workspaceId: number | null };
|
|
149
203
|
}
|
|
150
204
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
205
|
+
* Runs a long operation behind a dialog the person can minimize; it then
|
|
206
|
+
* lives in the operations area of the top bar, with its progress and its
|
|
207
|
+
* outcome. The promise resolves and rejects like `run`, so a screen that
|
|
208
|
+
* is still mounted keeps its own logic; one that is gone leaves the
|
|
209
|
+
* outcome to the panel.
|
|
210
|
+
*
|
|
211
|
+
* One command per operation: pass `task.sendOptions` to it. The server
|
|
212
|
+
* follows that command: a dropped socket or a reload does not lose it,
|
|
213
|
+
* and the account's other tabs show it in their own area. When the
|
|
214
|
+
* command could not leave, or when the server no longer knows the
|
|
215
|
+
* operation (it restarted), the promise rejects with a {@link TaskError}
|
|
216
|
+
* whose message already says what to do. A sequence of commands driven by
|
|
217
|
+
* the browser is a `local` operation that reports through `task.report`,
|
|
218
|
+
* and dies with its tab.
|
|
219
|
+
*/
|
|
220
|
+
export function runTask<T>(
|
|
221
|
+
options: TaskOptions<T>,
|
|
222
|
+
run: (task: TaskContext) => Promise<T>
|
|
223
|
+
): Promise<T>;
|
|
224
|
+
/**
|
|
225
|
+
* `runTask` for a wait your screen draws itself (a busy button, a bar in
|
|
226
|
+
* place): no dialog, and nothing in the operations area while the screen
|
|
227
|
+
* is there. If it unmounts before the end, the operation moves to the
|
|
228
|
+
* area, which then carries the outcome in its place. Options `dialog` and
|
|
229
|
+
* `minimizable` do not apply.
|
|
230
|
+
*/
|
|
231
|
+
export function useTaskRunner(): <T>(
|
|
232
|
+
options: TaskOptions<T>,
|
|
233
|
+
run: (task: TaskContext) => Promise<T>
|
|
234
|
+
) => Promise<T>;
|
|
235
|
+
/**
|
|
236
|
+
* The running operations of a feature in the active workspace, whichever
|
|
237
|
+
* screen started them, in this tab or in another one of the account:
|
|
238
|
+
* disable the conflicting actions, draw the progress in place, even after
|
|
239
|
+
* a remount or a reload.
|
|
240
|
+
*/
|
|
241
|
+
export function useTasks(filter: {
|
|
242
|
+
feature: string;
|
|
243
|
+
itemId?: string | number;
|
|
244
|
+
key?: string;
|
|
245
|
+
}): readonly Task[];
|
|
246
|
+
/** The rejection an operation writes itself: `errorNote` keeps its message. */
|
|
247
|
+
export class TaskError extends Error {
|
|
248
|
+
constructor(
|
|
249
|
+
code: 'closed' | 'timeout' | 'lost' | 'conflict' | 'cancelled',
|
|
250
|
+
message: string
|
|
251
|
+
);
|
|
252
|
+
readonly code: 'closed' | 'timeout' | 'lost' | 'conflict' | 'cancelled';
|
|
253
|
+
}
|
|
254
|
+
export interface TaskProgressProps {
|
|
255
|
+
task: Task;
|
|
256
|
+
className?: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The progress of an operation drawn in the screen that started it: title,
|
|
260
|
+
* bar, step, and "Afficher" to bring its dialog back when this page holds
|
|
261
|
+
* it. The top bar sits under the veil of any open dialog, so a screen
|
|
262
|
+
* living in one shows this.
|
|
154
263
|
*/
|
|
155
|
-
export const
|
|
264
|
+
export const TaskProgress: ComponentType<TaskProgressProps>;
|
|
156
265
|
export interface LogOutputProps {
|
|
157
266
|
/** The raw log, ANSI sequences included: the component cleans it. */
|
|
158
267
|
text: string;
|
|
@@ -409,8 +518,14 @@ declare module 'deveye-sdk-client' {
|
|
|
409
518
|
/** The height follows the content up to the viewport, then the body scrolls. */
|
|
410
519
|
fill?: boolean;
|
|
411
520
|
holdSecrecy?: boolean;
|
|
412
|
-
/** Without the close button
|
|
521
|
+
/** Without the close button: the dialog only leaves through its own actions. Default true. */
|
|
413
522
|
closeButton?: boolean;
|
|
523
|
+
/**
|
|
524
|
+
* The box and its veil only appear after this delay, so shorter work
|
|
525
|
+
* never flickers. The layer is there from the opening: the screen
|
|
526
|
+
* underneath takes no click meanwhile.
|
|
527
|
+
*/
|
|
528
|
+
appearDelayMs?: number;
|
|
414
529
|
}>;
|
|
415
530
|
/** The "Annuler" button of a Dialog footer: closes through the guarded close. */
|
|
416
531
|
export const DialogCancelButton: ComponentType<
|
|
@@ -592,6 +707,21 @@ declare module 'deveye-sdk-client' {
|
|
|
592
707
|
* cannot be projected) keeps its own wording.
|
|
593
708
|
*/
|
|
594
709
|
export const ReadOnlyNotice: ComponentType<{ children: ReactNode }>;
|
|
710
|
+
/**
|
|
711
|
+
* The notice above a feature's list, or atop an item's sheet, when nothing
|
|
712
|
+
* would be sent: no channel declared for the feature, none checked for the
|
|
713
|
+
* item (or, for a feature that notifies in its own name, none checked for
|
|
714
|
+
* it). Its button opens the Notifications tab at that scale. Renders
|
|
715
|
+
* nothing while loading, for a reader who could not fix it, and when the
|
|
716
|
+
* scope has no Notifications tab. Its close button hides it for that
|
|
717
|
+
* reader on that page only (this list in this workspace, or this item's
|
|
718
|
+
* sheet), until they bring it back from their Profile.
|
|
719
|
+
*/
|
|
720
|
+
export const NotificationsNotice: ComponentType<{
|
|
721
|
+
scope:
|
|
722
|
+
| { kind: 'feature'; feature: FeatureId }
|
|
723
|
+
| { kind: 'item'; feature: FeatureId; itemId: string; itemLabel: string };
|
|
724
|
+
}>;
|
|
595
725
|
export interface ErrorNoteInput {
|
|
596
726
|
message: string;
|
|
597
727
|
/** The failure's code, `null` when it carries none: it decides whether a report is offered. */
|
|
@@ -819,7 +949,8 @@ declare module 'deveye-sdk-client' {
|
|
|
819
949
|
/**
|
|
820
950
|
* How long the command may stay silent, 15 s by default: stretch it for
|
|
821
951
|
* a command that queries a slow third party. With `onProgress`, each
|
|
822
|
-
* update restarts the count.
|
|
952
|
+
* update restarts the count. A command with `task` never times out
|
|
953
|
+
* once sent.
|
|
823
954
|
*/
|
|
824
955
|
timeoutMs?: number;
|
|
825
956
|
/** The updates the handler reports through `ctx.progress`, as they arrive. */
|
|
@@ -830,6 +961,12 @@ declare module 'deveye-sdk-client' {
|
|
|
830
961
|
* across. The server checks membership and rights there as usual.
|
|
831
962
|
*/
|
|
832
963
|
workspaceId?: number;
|
|
964
|
+
/**
|
|
965
|
+
* Marks the command as the one of a long operation, which the server
|
|
966
|
+
* then follows: it survives a reload or a dropped socket. Set by
|
|
967
|
+
* `runTask` in `task.sendOptions`; never build it yourself.
|
|
968
|
+
*/
|
|
969
|
+
task?: CommandTask;
|
|
833
970
|
}
|
|
834
971
|
/**
|
|
835
972
|
* The typed sender of any list of contracts (`featureApi` is it on a
|
package/src/sdk/client.ts
CHANGED
|
@@ -519,6 +519,43 @@ export interface WhiteboardClientProvider {
|
|
|
519
519
|
}>;
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
+
/** An app of the workspace, as the Stores client provider lists it for a project's picker. */
|
|
523
|
+
export interface AppStoresLinkedCandidate {
|
|
524
|
+
id: number;
|
|
525
|
+
name: string;
|
|
526
|
+
/** Projected here from another workspace. */
|
|
527
|
+
foreign?: boolean;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* What the Stores module offers the host's screens under
|
|
532
|
+
* `APPSTORES_CLIENT_PROVIDER`: the workspace's apps, a linked app shown inside
|
|
533
|
+
* a project's tab, and the feature's own app dialog.
|
|
534
|
+
*/
|
|
535
|
+
export interface AppStoresClientProvider {
|
|
536
|
+
/** The workspace's apps, in the module's own order. */
|
|
537
|
+
listApps(): Promise<readonly AppStoresLinkedCandidate[]>;
|
|
538
|
+
/**
|
|
539
|
+
* The given apps, summarised for a project's dashboard tile, in ONE round
|
|
540
|
+
* trip. An id the caller cannot read, or that is gone, comes back
|
|
541
|
+
* `unavailable`, never as a throw. Never carries an amount of money: the
|
|
542
|
+
* module's revenue has a permission of its own.
|
|
543
|
+
*/
|
|
544
|
+
summarize(appIds: readonly number[]): Promise<readonly SdkTileSummary[]>;
|
|
545
|
+
/**
|
|
546
|
+
* An app linked to a project: its stores, its downloads and ratings over
|
|
547
|
+
* the last days. Loads itself, follows the feature's invalidations, and
|
|
548
|
+
* renders the host's "unlink" as its trailing action.
|
|
549
|
+
*/
|
|
550
|
+
LinkedApp: ComponentType<{ appId: number; canWrite: boolean; onUnlink: () => void }>;
|
|
551
|
+
/** The feature's app form, to follow a new app from a project. */
|
|
552
|
+
AppDialog: ComponentType<{
|
|
553
|
+
open: boolean;
|
|
554
|
+
onClose: () => void;
|
|
555
|
+
onSaved: (appId: number) => void;
|
|
556
|
+
}>;
|
|
557
|
+
}
|
|
558
|
+
|
|
522
559
|
/**
|
|
523
560
|
* What the Invoicing module offers other screens under
|
|
524
561
|
* `INVOICING_CLIENT_PROVIDER`. It sends Invoicing's own command under the
|
package/src/sdk/manifest.ts
CHANGED
|
@@ -258,7 +258,7 @@ export interface FeatureLink {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
/** Hard cap on `links`: the "About" card stays a card. */
|
|
261
|
-
export const MAX_FEATURE_LINKS =
|
|
261
|
+
export const MAX_FEATURE_LINKS = 8;
|
|
262
262
|
|
|
263
263
|
export interface FeatureManifest<Id extends FeatureId = FeatureId> {
|
|
264
264
|
/** External modules: `x-<slug>`. Native features keep their enum id. */
|
package/src/sdk/providers.ts
CHANGED
|
@@ -216,6 +216,21 @@ export interface DatabaseMeasureProvider {
|
|
|
216
216
|
|
|
217
217
|
export const DATABASE_ITEMS_PROVIDER = 'database.items' as const;
|
|
218
218
|
|
|
219
|
+
/** A database at home in one of the workspaces asked for, as `listHome` lists it. */
|
|
220
|
+
export interface DatabaseHomeItem {
|
|
221
|
+
id: number;
|
|
222
|
+
workspaceId: number;
|
|
223
|
+
/** The label the workspace gave it. */
|
|
224
|
+
name: string;
|
|
225
|
+
engine: 'mysql' | 'postgres';
|
|
226
|
+
/** What the server answered to `SELECT VERSION()` at the last check, raw; `null` before any. */
|
|
227
|
+
serverVersion: string | null;
|
|
228
|
+
/** When that check ran, epoch seconds. */
|
|
229
|
+
checkedAt: number | null;
|
|
230
|
+
/** Held over the plan's limit: the feature does not check it, and a consumer leaves it alone too. */
|
|
231
|
+
paused: boolean;
|
|
232
|
+
}
|
|
233
|
+
|
|
219
234
|
export interface DatabaseItemsProvider {
|
|
220
235
|
/** Is this database visible from this workspace: its home, or one it is projected into? */
|
|
221
236
|
exists(databaseId: number, workspaceId: number): Promise<boolean>;
|
|
@@ -227,6 +242,10 @@ export interface DatabaseItemsProvider {
|
|
|
227
242
|
* an id.
|
|
228
243
|
*/
|
|
229
244
|
labelOf(databaseId: number, workspaceId: number): Promise<string | null>;
|
|
245
|
+
/** Every database whose HOME is one of `workspaceIds`, with what its last check saw of the server. */
|
|
246
|
+
listHome(workspaceIds: readonly number[]): Promise<readonly DatabaseHomeItem[]>;
|
|
247
|
+
/** May this member read the database? The rule of the feature's screens, the item's override included. */
|
|
248
|
+
authorize(databaseId: number, workspaceId: number, userId: number): Promise<SdkAccessVerdict>;
|
|
230
249
|
}
|
|
231
250
|
|
|
232
251
|
/**
|
|
@@ -422,8 +441,48 @@ export interface GitHomeRepo {
|
|
|
422
441
|
headSha: string | null;
|
|
423
442
|
/** When that head was read at the forge (epoch seconds): a consumer that cloned later knows better. */
|
|
424
443
|
headSeenAt: number | null;
|
|
444
|
+
/** Held over the plan's limit: Git does not sync it, and a consumer leaves it alone too. */
|
|
445
|
+
paused: boolean;
|
|
425
446
|
}
|
|
426
447
|
|
|
448
|
+
/** What `GitItemsProvider.readFiles` reads, and how much of it. */
|
|
449
|
+
export interface GitFilesRequest {
|
|
450
|
+
/** The commit, branch or tag to read; `null` reads whatever the forge's HEAD points to. */
|
|
451
|
+
ref: string | null;
|
|
452
|
+
/** The tree the caller read last time: when the ref still points to it, no file is fetched. */
|
|
453
|
+
knownTree: string | null;
|
|
454
|
+
/** Which files to read, by their full path in the tree. */
|
|
455
|
+
wants(path: string): boolean;
|
|
456
|
+
/** At most this many files; the rest is reported through `truncated`. */
|
|
457
|
+
maxFiles: number;
|
|
458
|
+
/** A file above this size is not fetched, and is reported through `skipped`. */
|
|
459
|
+
maxFileBytes: number;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface GitRepoFile {
|
|
463
|
+
path: string;
|
|
464
|
+
text: string;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export type GitFilesResult =
|
|
468
|
+
| { status: 'unchanged'; tree: string }
|
|
469
|
+
| {
|
|
470
|
+
status: 'ok';
|
|
471
|
+
/** The tree that was read: hand it back as `knownTree` next time. */
|
|
472
|
+
tree: string;
|
|
473
|
+
files: readonly GitRepoFile[];
|
|
474
|
+
/** The forge cut the tree short, or `maxFiles` was reached: some wanted files were never seen. */
|
|
475
|
+
truncated: boolean;
|
|
476
|
+
/** Wanted files left out for their size. */
|
|
477
|
+
skipped: readonly string[];
|
|
478
|
+
}
|
|
479
|
+
| {
|
|
480
|
+
status: 'error';
|
|
481
|
+
error: string;
|
|
482
|
+
/** The failure comes from the repository's side (its token, its rights, its quota), not from the instance. */
|
|
483
|
+
userSide: boolean;
|
|
484
|
+
};
|
|
485
|
+
|
|
427
486
|
/** A repository as read from its home: its name, where it lives, its default branch. */
|
|
428
487
|
export interface GitRepoDescription {
|
|
429
488
|
workspaceId: number;
|
|
@@ -479,58 +538,70 @@ export interface GitItemsProvider {
|
|
|
479
538
|
* the right to read them answers through `error`, never by throwing.
|
|
480
539
|
*/
|
|
481
540
|
activity(repoId: number, workspaceId: number, since: number): Promise<DeployActivity>;
|
|
541
|
+
/**
|
|
542
|
+
* Selected files of the repository, read at the forge without a clone
|
|
543
|
+
* (one request for the tree, one per file kept), with the repository's
|
|
544
|
+
* token when it has one. Sessionless; `null` when the repository is gone
|
|
545
|
+
* from that workspace. A refusal answers through `status: 'error'`,
|
|
546
|
+
* never by throwing.
|
|
547
|
+
*/
|
|
548
|
+
readFiles(
|
|
549
|
+
repoId: number,
|
|
550
|
+
workspaceId: number,
|
|
551
|
+
request: GitFilesRequest
|
|
552
|
+
): Promise<GitFilesResult | null>;
|
|
482
553
|
}
|
|
483
554
|
|
|
484
555
|
/**
|
|
485
|
-
* Key under `FeatureService.providers` for the CVE
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* the
|
|
489
|
-
* to the NVD's quota.
|
|
556
|
+
* Key under `FeatureService.providers` for what the CVE feature's watch finds
|
|
557
|
+
* in one item of another feature: the vulnerable packages and tools of a Git
|
|
558
|
+
* repository, read from the watch's own inventory. Nothing is fetched on the
|
|
559
|
+
* spot: the watch reads the item on its own cadence, and answers from there.
|
|
490
560
|
*/
|
|
491
|
-
export const
|
|
492
|
-
|
|
493
|
-
/** A product as the NVD's CPE names it: `f5` / `nginx`, `nodejs` / `node.js`. */
|
|
494
|
-
export interface CveProductRef {
|
|
495
|
-
vendor: string;
|
|
496
|
-
product: string;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
export interface CveLookupItem extends CveProductRef {
|
|
500
|
-
/** An exact version (`1.25.3`). A floating one (`1.25`) compares to nothing. */
|
|
501
|
-
version: string;
|
|
502
|
-
}
|
|
561
|
+
export const CVE_EXPOSURE_PROVIDER = 'cve.exposure' as const;
|
|
503
562
|
|
|
504
|
-
|
|
505
|
-
|
|
563
|
+
/** One finding of the watch on an item, with what in the item it touches. */
|
|
564
|
+
export interface CveItemFinding {
|
|
565
|
+
/** The finding's id in the CVE feature. */
|
|
566
|
+
id: number;
|
|
567
|
+
kind: 'vuln' | 'eol' | 'deprecated' | 'outdated';
|
|
568
|
+
/** `ignored`: a member of the workspace decided it does not apply. */
|
|
569
|
+
state: 'open' | 'ignored';
|
|
570
|
+
/** The public id: the CVE when there is one, the advisory otherwise. */
|
|
571
|
+
advisoryId: string | null;
|
|
506
572
|
severity: 'none' | 'low' | 'medium' | 'high' | 'critical';
|
|
507
573
|
score: number | null;
|
|
574
|
+
title: string;
|
|
508
575
|
summary: string;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
576
|
+
component: { kind: 'package' | 'product'; ecosystem: string; name: string; version: string };
|
|
577
|
+
path: string | null;
|
|
578
|
+
line: number | null;
|
|
579
|
+
/** The versions that fix it, when the advisory names some. */
|
|
580
|
+
fixed: readonly string[];
|
|
581
|
+
reference: string | null;
|
|
513
582
|
}
|
|
514
583
|
|
|
515
|
-
export interface
|
|
516
|
-
/**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
584
|
+
export interface CveItemExposure {
|
|
585
|
+
/** `pending`: not read yet. `error`: the last read failed, `findings` is what the read before it found. */
|
|
586
|
+
status: 'pending' | 'ok' | 'error' | 'excluded';
|
|
587
|
+
/** The last full read of the item, epoch seconds. */
|
|
588
|
+
scannedAt: number | null;
|
|
589
|
+
/** What the item's source announced at that read (a repository's head commit). */
|
|
590
|
+
revision: string | null;
|
|
591
|
+
error: string | null;
|
|
592
|
+
findings: readonly CveItemFinding[];
|
|
524
593
|
}
|
|
525
594
|
|
|
526
|
-
export interface
|
|
595
|
+
export interface CveExposureProvider {
|
|
527
596
|
/**
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
597
|
+
* What the watch holds for this item, `null` when it does not follow it.
|
|
598
|
+
* Sessionless and unfiltered: the caller has checked that its member may
|
|
599
|
+
* see the item.
|
|
531
600
|
*/
|
|
532
|
-
|
|
533
|
-
|
|
601
|
+
ofItem(
|
|
602
|
+
workspaceId: number,
|
|
603
|
+
item: { feature: 'git'; itemId: number }
|
|
604
|
+
): Promise<CveItemExposure | null>;
|
|
534
605
|
}
|
|
535
606
|
|
|
536
607
|
/**
|
|
@@ -548,6 +619,27 @@ export const GIT_CLIENT_PROVIDER = 'git.client' as const;
|
|
|
548
619
|
*/
|
|
549
620
|
export const DEPLOY_ITEMS_PROVIDER = 'deploy.items' as const;
|
|
550
621
|
|
|
622
|
+
/** A deploy target at home in one of the workspaces asked for, as `listHome` lists it. */
|
|
623
|
+
export interface DeployHomeTarget {
|
|
624
|
+
id: number;
|
|
625
|
+
workspaceId: number;
|
|
626
|
+
name: string;
|
|
627
|
+
provider: 'dokploy' | 'github' | 'agent';
|
|
628
|
+
/** Held over the plan's limit: the feature does not sync it, and a consumer leaves it alone too. */
|
|
629
|
+
paused: boolean;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* What a target runs, as its provider describes it: the image it pulls, the
|
|
634
|
+
* compose file it starts. Only what names software, nothing of the
|
|
635
|
+
* provider's own settings (credentials, environment).
|
|
636
|
+
*/
|
|
637
|
+
export interface DeployInventory {
|
|
638
|
+
/** `repository:tag` references. */
|
|
639
|
+
images: readonly string[];
|
|
640
|
+
composeFiles: readonly { path: string; text: string }[];
|
|
641
|
+
}
|
|
642
|
+
|
|
551
643
|
export interface DeployItemsProvider {
|
|
552
644
|
/** Is this target visible from this workspace: its home, or one it is projected into? */
|
|
553
645
|
exists(targetId: number, workspaceId: number): Promise<boolean>;
|
|
@@ -569,6 +661,18 @@ export interface DeployItemsProvider {
|
|
|
569
661
|
* provider first, so a deployment that just ended is not missed.
|
|
570
662
|
*/
|
|
571
663
|
activity(targetId: number, workspaceId: number, since: number): Promise<DeployActivity>;
|
|
664
|
+
/** Every target whose HOME is one of `workspaceIds`. */
|
|
665
|
+
listHome(workspaceIds: readonly number[]): Promise<readonly DeployHomeTarget[]>;
|
|
666
|
+
/**
|
|
667
|
+
* What the target runs, asked of its provider on the spot. `null` for a
|
|
668
|
+
* target the provider cannot describe that way (a workflow, a machine's
|
|
669
|
+
* service: the repository and the device say it already), or one gone.
|
|
670
|
+
* A refusal answers through `error`, never by throwing.
|
|
671
|
+
*/
|
|
672
|
+
inventoryOf(
|
|
673
|
+
targetId: number,
|
|
674
|
+
workspaceId: number
|
|
675
|
+
): Promise<{ inventory: DeployInventory | null; error: string | null } | null>;
|
|
572
676
|
}
|
|
573
677
|
|
|
574
678
|
/** An item of another feature, as a picker lists it. */
|
|
@@ -664,6 +768,32 @@ export interface WhiteboardItemsProvider {
|
|
|
664
768
|
*/
|
|
665
769
|
export const WHITEBOARD_CLIENT_PROVIDER = 'whiteboard.client' as const;
|
|
666
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Key under `FeatureService.providers` for the apps the app's Projects feature
|
|
773
|
+
* links to: same shape and same reason as `UPTIME_ITEMS_PROVIDER`
|
|
774
|
+
* (`ft_projects_appstores_links` is Projects' table).
|
|
775
|
+
*/
|
|
776
|
+
export const APPSTORES_ITEMS_PROVIDER = 'appstores.items' as const;
|
|
777
|
+
|
|
778
|
+
export interface AppStoresItemsProvider {
|
|
779
|
+
/** Is this app visible from this workspace: its home, or one it is projected into? */
|
|
780
|
+
exists(appId: number, workspaceId: number): Promise<boolean>;
|
|
781
|
+
/**
|
|
782
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
783
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
784
|
+
* OPEN cipher itself. `null` when it is gone or unreadable.
|
|
785
|
+
*/
|
|
786
|
+
labelOf(appId: number, workspaceId: number): Promise<string | null>;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Key under `FeatureClient.providers` for the Stores pieces the app's Projects
|
|
791
|
+
* screens compose: the list of the workspace's apps, a linked app shown inside
|
|
792
|
+
* a project's tab, and the feature's own app dialog.
|
|
793
|
+
* The contract types live in `@deveye/types/sdk/client`.
|
|
794
|
+
*/
|
|
795
|
+
export const APPSTORES_CLIENT_PROVIDER = 'appstores.client' as const;
|
|
796
|
+
|
|
667
797
|
/**
|
|
668
798
|
* Key of what Projects knows about the items of OTHER features: the projects
|
|
669
799
|
* of the workspace that link them (a module's list shows how many projects use
|
package/src/sdk/server.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { LogLevelName } from '../domain/logs';
|
|
|
9
9
|
import type { ItemAccess } from '../domain/sharing';
|
|
10
10
|
import type { AuthWindow, DeviceReport, IntegrityReport, ReportProcess } from '../domain/report';
|
|
11
11
|
import type { ContainerEngine, DockerAction, DockerInventory } from '../domain/deviceDocker';
|
|
12
|
+
import type { PackageInventory } from '../protocol/agent';
|
|
12
13
|
import type { PathExclusion } from '../domain/pathExclusions';
|
|
13
14
|
import type { AgentManifest } from '../http/device';
|
|
14
15
|
import type { MetricSnapshot } from '../domain/metrics';
|
|
@@ -769,6 +770,11 @@ export interface AgentsFacade {
|
|
|
769
770
|
): Promise<{ ok: boolean; error?: string }>;
|
|
770
771
|
/** The device's containers, images and volumes; `null` when its agent does not answer in time. */
|
|
771
772
|
dockerInventory(deviceId: string, timeoutMs?: number): Promise<DockerInventory | null>;
|
|
773
|
+
/**
|
|
774
|
+
* The system packages installed on the device; `null` when its agent does
|
|
775
|
+
* not answer in time, or is older than `AGENT_PKG_INVENTORY_PROBE`.
|
|
776
|
+
*/
|
|
777
|
+
packageInventory(deviceId: string, timeoutMs?: number): Promise<PackageInventory | null>;
|
|
772
778
|
/**
|
|
773
779
|
* The `.tar.gz` of one of the device's folders, built by its agent and
|
|
774
780
|
* pulled at the consumer's pace: the agent sends no more than the
|
|
@@ -1096,6 +1102,63 @@ export interface SdkSharing {
|
|
|
1096
1102
|
setOrder(itemId: string, order: number): Promise<void>;
|
|
1097
1103
|
}
|
|
1098
1104
|
|
|
1105
|
+
/** What a service says of a long operation when it opens it. */
|
|
1106
|
+
export interface SdkTaskOpening {
|
|
1107
|
+
/** The account the operation runs for: the member who asked for it. Only that account sees it. */
|
|
1108
|
+
userId: number;
|
|
1109
|
+
workspaceId: number;
|
|
1110
|
+
/** What is being done, as a noun phrase: "Sauvegarde", "Conversion". */
|
|
1111
|
+
title: string;
|
|
1112
|
+
/** What it acts on (a name), to tell two operations with the same title apart. */
|
|
1113
|
+
subject?: string;
|
|
1114
|
+
/** The item it targets: "Ouvrir" leads there, and the screens of your feature filter on it. */
|
|
1115
|
+
itemId?: string | number;
|
|
1116
|
+
/**
|
|
1117
|
+
* The kind of operation. With a `key`, opening the same
|
|
1118
|
+
* `(workspaceId, itemId, key)` again for the same account returns the
|
|
1119
|
+
* operation already running instead of a second one: call `open` each
|
|
1120
|
+
* time you find the work again (a queue you poll, a restart).
|
|
1121
|
+
*/
|
|
1122
|
+
key?: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* Offers "Annuler" in the account's area. Called once, when the person
|
|
1125
|
+
* asks; stop the work, then call `cancelled()`.
|
|
1126
|
+
*/
|
|
1127
|
+
cancel?: () => void | Promise<void>;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/** A long operation a service runs, see {@link SdkTasks}. Every call after the first ending is ignored. */
|
|
1131
|
+
export interface SdkTask {
|
|
1132
|
+
readonly id: string;
|
|
1133
|
+
/** How far it is: at most four updates a second leave, the last one always. */
|
|
1134
|
+
progress(update: CommandProgress): void;
|
|
1135
|
+
/** It succeeded; `note` is the sentence of the outcome ("Terminé." without it). */
|
|
1136
|
+
done(note?: string): void;
|
|
1137
|
+
/**
|
|
1138
|
+
* It failed; `message` is the sentence to show. `code` decides whether the
|
|
1139
|
+
* person is offered to report it: `internal` (the default) for what the
|
|
1140
|
+
* instance must fix, `conflict` for what their side explains.
|
|
1141
|
+
*/
|
|
1142
|
+
fail(message: string, code?: ErrorCode): void;
|
|
1143
|
+
/** It stopped because the person asked: it leaves the area without an outcome. */
|
|
1144
|
+
cancelled(): void;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* The operations area of an account, from a service: the work a member
|
|
1149
|
+
* launched and that goes on without their command (a backup, a deployment, a
|
|
1150
|
+
* conversion). The host stamps your feature and shows the operation to that
|
|
1151
|
+
* account only, in every tab, once it has checked the account still reads
|
|
1152
|
+
* your feature in that workspace; a restart of the server forgets it, so open
|
|
1153
|
+
* it again when your service resumes the work.
|
|
1154
|
+
*
|
|
1155
|
+
* Not for what runs on its own (a schedule, a reconciliation): nobody asked
|
|
1156
|
+
* for it, so it belongs to your screens, not to someone's area.
|
|
1157
|
+
*/
|
|
1158
|
+
export interface SdkTasks {
|
|
1159
|
+
open(opening: SdkTaskOpening): SdkTask;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1099
1162
|
/** Live invalidation from a background service, which writes without a command. */
|
|
1100
1163
|
export interface SdkLive {
|
|
1101
1164
|
/**
|
|
@@ -1327,7 +1390,9 @@ export interface SdkFeatureContext<Repo = unknown> {
|
|
|
1327
1390
|
* Report how far this command has got, to its caller only. Best effort, at
|
|
1328
1391
|
* most 4 frames a second (the last one always goes out); each frame re-arms
|
|
1329
1392
|
* the caller's timeout, so a long command that keeps reporting never times
|
|
1330
|
-
* out. Steps are user-facing sentences
|
|
1393
|
+
* out. Steps are user-facing sentences: when the caller runs the command
|
|
1394
|
+
* as a long operation (`runTask`), they also show in the operations area of
|
|
1395
|
+
* the account, in every tab.
|
|
1331
1396
|
*/
|
|
1332
1397
|
progress(update: CommandProgress): void;
|
|
1333
1398
|
/** The server key derivations, the same `keys` a service gets. */
|
|
@@ -1713,6 +1778,8 @@ export interface FeatureServiceDeps<Repo = unknown> {
|
|
|
1713
1778
|
geo: SdkGeo;
|
|
1714
1779
|
/** Live invalidation of your feature's resources, from a service. */
|
|
1715
1780
|
live: SdkLive;
|
|
1781
|
+
/** The long operations a member launched and your service runs. */
|
|
1782
|
+
tasks: SdkTasks;
|
|
1716
1783
|
/**
|
|
1717
1784
|
* Audit line recorded as the SYSTEM (no session). `userId` attributes the
|
|
1718
1785
|
* line to a user when the work concerns their data.
|
package/src/sdk/testing.test.ts
CHANGED
|
@@ -39,6 +39,24 @@ test('createTestContext follows the manifest for extras, and records what handle
|
|
|
39
39
|
assert.equal(member.store.rows.get('k')?.mode, 'private');
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
test('notify refuses, as the host does, a manifest without the capability', async () => {
|
|
43
|
+
const manifest = { nativeCapabilities: ['members.read' as const] };
|
|
44
|
+
const ctx = createTestContext({ manifest });
|
|
45
|
+
await assert.rejects(ctx.deveye.notify.send({ subject: 's', body: 'b' }), {
|
|
46
|
+
code: 'forbidden'
|
|
47
|
+
});
|
|
48
|
+
await assert.rejects(ctx.deveye.notify.hasRoute(), { code: 'forbidden' });
|
|
49
|
+
assert.deepEqual(ctx.recorded.notifications, []);
|
|
50
|
+
|
|
51
|
+
const deps = createTestServiceDeps({ manifest });
|
|
52
|
+
await assert.rejects(deps.deveyeFor(1).notify.send({ subject: 's', body: 'b' }), {
|
|
53
|
+
code: 'forbidden'
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const declared = createTestContext({ manifest: { nativeCapabilities: ['notify' as const] } });
|
|
57
|
+
assert.equal(await declared.deveye.notify.send({ subject: 's', body: 'b' }), true);
|
|
58
|
+
});
|
|
59
|
+
|
|
42
60
|
test('createTestServiceDeps: one store per workspace, hand-driven tickers, a wrapper that round-trips', async () => {
|
|
43
61
|
const deps = createTestServiceDeps({
|
|
44
62
|
workspaceIds: [1, 2],
|