@deveye/types 0.25.1 → 0.25.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deveye/types",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "Shared contracts (types + zod schemas) for DevEye apps",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -957,13 +957,20 @@ declare module 'deveye-sdk-client' {
957
957
  kind: PathExclusionKind;
958
958
  pattern: string;
959
959
  }
960
+ /** A name found in the walked folder, with what it weighs there, ready to show ("2,1 Go, 3 dossiers"). */
961
+ export interface PathExclusionFound {
962
+ name: string;
963
+ detail: string;
964
+ }
960
965
  /**
961
966
  * The exclusions of a walked folder (a CloudSync share, a backed-up
962
967
  * folder): exact path, component name or regex, relative to its root,
963
968
  * validated the way the agent will run them. `onAdd` gets a rule already
964
969
  * validated; `false` or a rejection keeps what was typed (say why where
965
970
  * you show your errors). `scope` ends the suggestions' tooltip ("le
966
- * partage", "le dossier").
971
+ * partage", "le dossier"). `found` lists names found in the folder, first
972
+ * among the suggestions with their weight; `onAddFound` takes their click
973
+ * (by default `onAdd`, as a name rule).
967
974
  */
968
975
  export const PathExclusionsEditor: ComponentType<{
969
976
  items: readonly PathExclusionItem[];
@@ -972,6 +979,8 @@ declare module 'deveye-sdk-client' {
972
979
  canWrite: boolean;
973
980
  scope: string;
974
981
  disabled?: boolean;
982
+ found?: readonly PathExclusionFound[];
983
+ onAddFound?: (name: string) => boolean | Promise<boolean>;
975
984
  }>;
976
985
  /**
977
986
  * The workspace's enrolled devices, live: what the Devices module offers
@@ -203,7 +203,14 @@ test('validateManifest checks quotas and the account entry', () => {
203
203
  { quotas: [{ key: 'monitors', label: 'm', stock: true, perOperation: true }] },
204
204
  'a per-operation limit is no stock'
205
205
  );
206
- rejects({ accountOnly: true }, 'accountOnly requires accountEntry');
206
+ rejects({ accountOnly: true }, 'accountOnly requires accountEntry or adminTabs');
207
+ assert.doesNotThrow(() =>
208
+ validateManifest({
209
+ ...base,
210
+ accountOnly: true,
211
+ adminTabs: [{ id: 'rules', label: 'Rules', moderation: true }]
212
+ })
213
+ );
207
214
  rejects({ accountOnly: true, accountEntry: { label: 'S' }, tile: {} }, 'no tile');
208
215
  rejects({ accountEntry: { label: ' ' } }, 'requires a label');
209
216
  });
@@ -384,9 +384,11 @@ export interface FeatureManifest<Id extends FeatureId = FeatureId> {
384
384
  */
385
385
  adminTabs?: readonly AdminTabSpec[];
386
386
  /**
387
- * The module lives in the user menu only: no card, no row in the roles
388
- * screen, `Widget` and `Full` not required. Requires `accountEntry`, no
389
- * items, and every command scoped to the account (`access.scope`).
387
+ * The module has no card and no row in the roles screen, and `Widget` and
388
+ * `Full` are not required: it lives in the user menu (`accountEntry`), or
389
+ * in the feature administration popup only (`adminTabs`, a module that
390
+ * serves the instance rather than its members). Requires one of the two,
391
+ * no items, and every command scoped to the account (`access.scope`).
390
392
  */
391
393
  accountOnly?: boolean;
392
394
 
@@ -551,7 +553,9 @@ export function validateManifest(m: FeatureManifest): void {
551
553
  if (!tab.label.trim()) fail(m.id, `admin tab « ${tab.id} »: empty label`);
552
554
  }
553
555
  if (m.accountOnly) {
554
- if (!m.accountEntry) fail(m.id, 'accountOnly requires accountEntry');
556
+ if (!m.accountEntry && (m.adminTabs ?? []).length === 0) {
557
+ fail(m.id, 'accountOnly requires accountEntry or adminTabs');
558
+ }
555
559
  if (m.hasItems) fail(m.id, 'accountOnly modules own no items');
556
560
  if (m.tile || m.topbarWidget || m.settings) {
557
561
  fail(m.id, 'accountOnly modules have no tile, topbar widget or settings');
package/src/sdk/net.ts CHANGED
@@ -159,6 +159,8 @@ export interface SafeFetchOptions {
159
159
  contentType?: string;
160
160
  accept?: string;
161
161
  userAgent?: string;
162
+ /** Extra request headers (an API key the service expects); `accept` and `user-agent` above win. */
163
+ headers?: Readonly<Record<string, string>>;
162
164
  }
163
165
 
164
166
  /**
@@ -183,6 +185,7 @@ export async function safeFetchText(raw: string, options: SafeFetchOptions): Pro
183
185
  redirect: 'manual',
184
186
  signal: AbortSignal.timeout(options.timeoutMs),
185
187
  headers: {
188
+ ...options.headers,
186
189
  accept: options.accept ?? 'text/plain, */*',
187
190
  'user-agent': options.userAgent ?? 'DevEye/1.0'
188
191
  }
@@ -936,3 +936,79 @@ export interface AccountPlanProvider {
936
936
  /** `fresh`: never from a cache, the host is about to pause or resume on the answer. */
937
937
  planFor(userId: number, opts?: { fresh?: boolean }): Promise<AccountPlan>;
938
938
  }
939
+
940
+ /**
941
+ * Key under `FeatureService.providers` of the automatic moderation: the
942
+ * instance's lists of banned content (file fingerprints and name patterns),
943
+ * kept by the moderation module and consulted by every feature that stores or
944
+ * publishes files (Hosting, CloudSync). Absent (module not installed), nothing
945
+ * is checked and the features behave as before: the caller degrades to
946
+ * "no hit".
947
+ */
948
+ export const MODERATION_PROVIDER = 'moderation.check' as const;
949
+
950
+ /** Why a content is banned, in the vocabulary of the public report forms. */
951
+ export const MODERATION_REASONS = [
952
+ 'illegal',
953
+ 'copyright',
954
+ 'malware',
955
+ 'privacy',
956
+ 'minors',
957
+ 'other'
958
+ ] as const;
959
+ export type ModerationReason = (typeof MODERATION_REASONS)[number];
960
+
961
+ /**
962
+ * Where the content goes: `public` when anyone with an address can download it
963
+ * (a Hosting folder), `private` when it stays with its owner and their devices
964
+ * (a CloudSync share). A rule says which exposures it covers.
965
+ */
966
+ export type ModerationExposure = 'public' | 'private';
967
+
968
+ export interface ModerationSubject {
969
+ /** The lowercase hex SHA-256 of the plaintext; `null` when the host cannot compute it (end-to-end encrypted content). */
970
+ sha256: string | null;
971
+ /** The file name as the user named it, without its folders. */
972
+ name: string;
973
+ exposure: ModerationExposure;
974
+ /** For the moderators' journal: who sent what, and where. */
975
+ origin: {
976
+ /** The feature's id (`x-hosting`, `cloudsync`). */
977
+ feature: string;
978
+ workspaceId: number | null;
979
+ /** `null` for a transfer a device drives without a session. */
980
+ userId: number | null;
981
+ /** The item the file belongs to (a folder's name, a share's name), as the moderators read it. */
982
+ context: string;
983
+ };
984
+ size?: number;
985
+ }
986
+
987
+ export interface ModerationHit {
988
+ ruleId: number;
989
+ kind: 'fingerprint' | 'name';
990
+ reason: ModerationReason;
991
+ /** What the user is told, one sentence: "Logiciel malveillant connu". */
992
+ label: string;
993
+ }
994
+
995
+ export interface ModerationProvider {
996
+ /**
997
+ * `null` when nothing matches. A hit is recorded for the moderators
998
+ * (feature, context, name, account) before it is returned; the caller
999
+ * decides what becomes of the content: hold it, refuse it.
1000
+ */
1001
+ check(subject: ModerationSubject): Promise<ModerationHit | null>;
1002
+ /**
1003
+ * Bans these fingerprints from now on (after a takedown): the ones already
1004
+ * banned are left as they are. Returns how many were added. Nothing already
1005
+ * stored is re-examined.
1006
+ */
1007
+ ban(input: {
1008
+ fingerprints: readonly string[];
1009
+ reason: ModerationReason;
1010
+ label: string;
1011
+ /** The moderator's account, `null` for the instance. */
1012
+ by: number | null;
1013
+ }): Promise<number>;
1014
+ }