@cfour-hi/dsh-plugin-devicex 0.0.0-stage → 1.5.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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Device X cleanup — platform dispatcher.
3
+ *
4
+ * The cleanup API is identical on every supported platform; this module only
5
+ * picks the implementation:
6
+ *
7
+ * - `darwin` → `cleanup-darwin.js` (macOS cache/log/trash/developer roots)
8
+ * - `win32` → `cleanup-win32.js` (Windows temp/update/thumbnail roots and the
9
+ * Recycle Bin)
10
+ *
11
+ * `dsh.bundle.platforms` limits installation to those two hosts; the darwin
12
+ * branch is the safe fallback for anything else (every root then fails into
13
+ * the item's `error` string instead of throwing).
14
+ *
15
+ * Deletion never accepts a path from the caller: `deleteCleanup(ids)` maps ids
16
+ * to the fixed absolute allowlist entries and refuses everything else.
17
+ *
18
+ * @module @cfour-hi/dsh-plugin-devicex/host/cleanup
19
+ */
20
+ import * as darwin from './cleanup-darwin.js';
21
+ import * as win32 from './cleanup-win32.js';
22
+
23
+ /** Host platform. */
24
+ export const PLATFORM = process.platform;
25
+
26
+ const impl = process.platform === 'win32' ? win32 : darwin;
27
+
28
+ /**
29
+ * Scan every allowlisted cleanup location. Cached for 60 s.
30
+ * @param {{fresh?: boolean}} [options]
31
+ * @returns {Promise<object>} the cleanup scan document.
32
+ */
33
+ export function scanCleanup(options = {}) {
34
+ return impl.scanCleanup(options);
35
+ }
36
+
37
+ /**
38
+ * Delete the contents of allowlisted cleanup items (ids only, never paths).
39
+ * @param {unknown} ids cleanup item ids (array or comma separated string).
40
+ * @returns {Promise<object>} `{ok, message, data:{deletedBytes, items}}`.
41
+ */
42
+ export function deleteCleanup(ids) {
43
+ return impl.deleteCleanup(ids);
44
+ }
45
+
46
+ /**
47
+ * The cleanup allowlist as public metadata (ids, labels, categories, fixed
48
+ * paths). Used by the action validator, tests and client labelling.
49
+ * @returns {Array<{id: string, label: string, category: string,
50
+ * requiresAdmin: boolean, path: string|null}>}
51
+ */
52
+ export function cleanupItems() {
53
+ return impl.cleanupItems();
54
+ }
55
+
56
+ /** Test seam exposing the selected implementation for offline verification. */
57
+ export const __test = {
58
+ platform: impl.PLATFORM,
59
+ hostPlatform: PLATFORM,
60
+ darwin,
61
+ win32,
62
+ };