@yaks/file 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +121 -2
- package/_dist/blobs.d.ts +16 -0
- package/_dist/blobs.d.ts.map +1 -0
- package/_dist/io.d.ts +148 -0
- package/_dist/io.d.ts.map +1 -0
- package/_dist/local.d.ts +18 -0
- package/_dist/local.d.ts.map +1 -0
- package/_dist/mod.d.ts +27 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/occupancy.d.ts +207 -0
- package/_dist/occupancy.d.ts.map +1 -0
- package/_dist/service.d.ts +31 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/views.d.ts +24 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +9 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/blobs.js +47 -0
- package/blobs.js.map +1 -0
- package/blobs.ts +52 -0
- package/deno.json +1 -0
- package/io.js +361 -0
- package/io.js.map +1 -0
- package/io.ts +528 -0
- package/local.js +105 -0
- package/local.js.map +1 -0
- package/local.ts +91 -0
- package/measure.js +88 -0
- package/measure.js.map +1 -0
- package/measure.ts +109 -0
- package/mod.js +86 -0
- package/mod.js.map +1 -0
- package/mod.ts +84 -0
- package/occupancy.js +256 -0
- package/occupancy.js.map +1 -0
- package/occupancy.ts +341 -0
- package/package.json +54 -4
- package/page.js +296 -0
- package/page.js.map +1 -0
- package/page.ts +444 -0
- package/service.js +116 -0
- package/service.js.map +1 -0
- package/service.ts +155 -0
- package/upkeep.js +52 -0
- package/upkeep.js.map +1 -0
- package/upkeep.ts +78 -0
- package/views.js +27 -0
- package/views.js.map +1 -0
- package/views.ts +25 -0
- package/vocab.js +19 -0
- package/vocab.js.map +1 -0
- package/vocab.json +163 -0
- package/vocab.ts +20 -0
package/service.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What fills this computer's disks, as a duty: the module a server imports at
|
|
3
|
+
* `@yaks/file/service`. Each pass reads the computer's disks, and walks
|
|
4
|
+
* each one whose day has no look yet (one filesystem at a time through the
|
|
5
|
+
* file API) into the day's `occupancy` row. A walk lstats every file on the
|
|
6
|
+
* disk, about a CPU for minutes on a box of agents' checkouts, so a disk is
|
|
7
|
+
* walked once a day, never more. The Disks page reads only those rows (./page.ts),
|
|
8
|
+
* so opening it measures nothing.
|
|
9
|
+
*
|
|
10
|
+
* A walk stops when the process winds down, and the next process
|
|
11
|
+
* walks again from its first pass; what an earlier walk read is still in the
|
|
12
|
+
* kernel's cache, so the next goes faster.
|
|
13
|
+
*
|
|
14
|
+
* Each pass also tells the host of a disk newly below its floor, and every
|
|
15
|
+
* `AGAIN` prunes the configured mirror caches (./upkeep.ts).
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { disksAt, paced, walk } from './measure.js'
|
|
20
|
+
import { homedir } from './io.js'
|
|
21
|
+
import type { Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
22
|
+
import { sleep } from '@yaks/fp'
|
|
23
|
+
import { volumeOf } from './mod.js'
|
|
24
|
+
import { here } from './local.js'
|
|
25
|
+
import { lows, prune } from './upkeep.js'
|
|
26
|
+
import {
|
|
27
|
+
type Disk,
|
|
28
|
+
listed,
|
|
29
|
+
occupancyIn,
|
|
30
|
+
occupancyOf,
|
|
31
|
+
type Walk,
|
|
32
|
+
} from './occupancy.js'
|
|
33
|
+
|
|
34
|
+
/** How long a pass waits for the next, in milliseconds: five minutes, so a
|
|
35
|
+
* disk running low is told within them. A walk still waits for the next day. */
|
|
36
|
+
export let EVERY = 5 * 60 * 1000
|
|
37
|
+
|
|
38
|
+
/** How often the mirror caches are pruned: an hour. */
|
|
39
|
+
export let AGAIN = 60 * 60 * 1000
|
|
40
|
+
|
|
41
|
+
/** How a computer is looked at: its disks, and a walk of one. */
|
|
42
|
+
export type Looking = {
|
|
43
|
+
disks: () => Promise<Disk[]>
|
|
44
|
+
/** what a walk of the filesystem at `mount` counted, listing each path of
|
|
45
|
+
* at least `least` bytes; undefined once `signal` aborts */
|
|
46
|
+
walk: (
|
|
47
|
+
mount: string,
|
|
48
|
+
least: number,
|
|
49
|
+
signal?: AbortSignal,
|
|
50
|
+
) => Promise<Walk | undefined>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** This computer, measured through the file API: the disks holding its root
|
|
54
|
+
* and the home directory. */
|
|
55
|
+
export let computer: Looking = {
|
|
56
|
+
disks: () => disksAt(['/', homedir()]),
|
|
57
|
+
// A quarter of one CPU at most: unpaced, a walk held a whole CPU for over
|
|
58
|
+
// ten minutes beside agents' test runs (bug 60286e2677).
|
|
59
|
+
walk: (mount, least, signal) =>
|
|
60
|
+
walk(mount, least, signal, undefined, paced()),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** One pass: walk each of this computer's disks whose day has no look yet,
|
|
64
|
+
* into its day's row. */
|
|
65
|
+
export let pass = async (
|
|
66
|
+
g: Graph,
|
|
67
|
+
look: Looking = computer,
|
|
68
|
+
now: number = Date.now(),
|
|
69
|
+
signal?: AbortSignal,
|
|
70
|
+
): Promise<void> => {
|
|
71
|
+
let machine = await here(g)
|
|
72
|
+
let day = new Date(now).toISOString().slice(0, 10)
|
|
73
|
+
for (let disk of await look.disks()) {
|
|
74
|
+
let volume = volumeOf(machine, disk.mount)
|
|
75
|
+
let eid = occupancyOf(volume, day)
|
|
76
|
+
let held = await g.get([eid, volume], ['occupancy', 'volume'])
|
|
77
|
+
let had = held.find((b) => b.entity.eid == eid)
|
|
78
|
+
let known = held.find((b) => b.entity.eid == volume)
|
|
79
|
+
if (occupancyIn(had)) continue
|
|
80
|
+
let walk = await look.walk(disk.mount, listed(disk.size), signal)
|
|
81
|
+
if (!walk) return
|
|
82
|
+
// The filesystem's figures as the walk ends, so they and it agree.
|
|
83
|
+
let { size, used, free } = (await look.disks()).find((d) =>
|
|
84
|
+
d.mount == disk.mount
|
|
85
|
+
) ?? disk
|
|
86
|
+
await g.apply([
|
|
87
|
+
...known?.volume
|
|
88
|
+
? []
|
|
89
|
+
: [{ entity: { eid: volume }, volume: { machine, mount: disk.mount } }],
|
|
90
|
+
{
|
|
91
|
+
entity: { eid },
|
|
92
|
+
occupancy: {
|
|
93
|
+
volume,
|
|
94
|
+
day,
|
|
95
|
+
at: new Date().toISOString(),
|
|
96
|
+
size,
|
|
97
|
+
used,
|
|
98
|
+
free,
|
|
99
|
+
...walk,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
], { trusted: true })
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type Options = {
|
|
107
|
+
/** milliseconds between passes (default {@link EVERY}) */
|
|
108
|
+
every?: number
|
|
109
|
+
/** the free bytes each disk is kept above; below it the host is told once
|
|
110
|
+
* a spell (default a tenth of the disk) */
|
|
111
|
+
floor?: number
|
|
112
|
+
/** caches laid out by the absolute paths of the files they were made from,
|
|
113
|
+
* such as Deno's `gen/file`, pruned of directories whose files are gone
|
|
114
|
+
* every `AGAIN` */
|
|
115
|
+
mirrors?: string[]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Look, then look again every `every`, until the signal aborts. An already
|
|
119
|
+
* aborted signal is one pass. Each pass tells the host of a disk newly below
|
|
120
|
+
* its floor, as a failure: a full disk fails every write on it. */
|
|
121
|
+
export let service = async (
|
|
122
|
+
host: {
|
|
123
|
+
graph: Graph
|
|
124
|
+
report?: (
|
|
125
|
+
error: unknown,
|
|
126
|
+
context?: { tags?: Record<string, string> },
|
|
127
|
+
) => unknown
|
|
128
|
+
},
|
|
129
|
+
options: Options = {},
|
|
130
|
+
signal: AbortSignal = AbortSignal.abort(),
|
|
131
|
+
): Promise<void> => {
|
|
132
|
+
let report = (e: unknown, step: string) =>
|
|
133
|
+
(host.report ?? console.error)(e, { tags: { step } })
|
|
134
|
+
let told = new Set<string>()
|
|
135
|
+
let pruned = 0
|
|
136
|
+
for (;;) {
|
|
137
|
+
let stopping = signal.aborted ? undefined : signal
|
|
138
|
+
// Each step that failed is told, and the next pass tries it again.
|
|
139
|
+
await computer.disks()
|
|
140
|
+
.then((disks) => lows(disks, told, options.floor))
|
|
141
|
+
.then((low) => low.forEach((e) => report(e, 'disk space')))
|
|
142
|
+
.catch((e) => report(e, 'disk space'))
|
|
143
|
+
if (Date.now() - pruned >= AGAIN) {
|
|
144
|
+
pruned = Date.now()
|
|
145
|
+
for (let mirror of options.mirrors ?? []) {
|
|
146
|
+
await prune(mirror, stopping).catch((e) => report(e, 'cache prune'))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
await pass(host.graph, computer, Date.now(), stopping)
|
|
150
|
+
.catch((e) => report(e, 'disk look'))
|
|
151
|
+
if (signal.aborted) return
|
|
152
|
+
await sleep(options.every ?? EVERY, signal)
|
|
153
|
+
if (signal.aborted) return
|
|
154
|
+
}
|
|
155
|
+
}
|
package/upkeep.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Keeping a disk clear of full: telling when one runs low, taking back
|
|
2
|
+
* what a mirror cache keeps for files that are gone. */ import * as disk from "./io.js";
|
|
3
|
+
/// floorOf({ mount: '/', size: 1000, used: 0, free: 1000 }) -> 100
|
|
4
|
+
/// floorOf({ mount: '/', size: 1000, used: 0, free: 1000 }, 300) -> 300
|
|
5
|
+
/** The free bytes a disk is kept above: `floor` where the config sets one,
|
|
6
|
+
* and a tenth of the disk otherwise. */ export let floorOf = (d, floor)=>floor ?? d.size / 10;
|
|
7
|
+
/// gb(6_900_000_000) -> '6.9 GB'
|
|
8
|
+
export let gb = (bytes)=>`${(bytes / 1e9).toFixed(1)} GB`;
|
|
9
|
+
/** The disks newly below their floor, as errors to report. `told` holds the
|
|
10
|
+
* mounts already reported in their present spell; a disk back above its floor
|
|
11
|
+
* leaves it, so the next spell is reported again. */ export let lows = (disks, told, floor)=>disks.flatMap((d)=>{
|
|
12
|
+
let least = floorOf(d, floor);
|
|
13
|
+
if (d.free >= least) return told.delete(d.mount), [];
|
|
14
|
+
if (told.has(d.mount)) return [];
|
|
15
|
+
told.add(d.mount);
|
|
16
|
+
return [
|
|
17
|
+
new Error(`${d.mount} has ${gb(d.free)} free of ${gb(d.size)}, below its floor ` + `of ${gb(least)}`)
|
|
18
|
+
];
|
|
19
|
+
});
|
|
20
|
+
/** Remove each directory of `mirror`, a cache laid out by the absolute paths
|
|
21
|
+
* of the files it was made from (Deno's emit cache, `gen/file`), whose own
|
|
22
|
+
* directory is gone: nothing can read what it keeps again. Returns the
|
|
23
|
+
* directories removed. A path that cannot be read is kept, and the walk stops
|
|
24
|
+
* when `signal` aborts. */ export let prune = async (mirror, signal, fs = disk)=>{
|
|
25
|
+
let base = mirror.replace(/\/+$/, '');
|
|
26
|
+
let removed = 0;
|
|
27
|
+
let visit = async (path)=>{
|
|
28
|
+
let entries;
|
|
29
|
+
try {
|
|
30
|
+
entries = await Array.fromAsync(fs.readDir(base + path));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (disk.isNotFound(error) || disk.isPermissionDenied(error)) return;
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
for (let entry of entries){
|
|
36
|
+
if (signal?.aborted) return;
|
|
37
|
+
if (!entry.isDirectory) continue;
|
|
38
|
+
let source = path + '/' + entry.name;
|
|
39
|
+
let stat = await fs.lstat(source).then((s)=>s, (error)=>disk.isNotFound(error) ? null : undefined);
|
|
40
|
+
if (stat === null) {
|
|
41
|
+
await fs.remove(base + source, {
|
|
42
|
+
recursive: true
|
|
43
|
+
}).then(()=>removed++, (error)=>{
|
|
44
|
+
if (!disk.isNotFound(error)) throw error;
|
|
45
|
+
});
|
|
46
|
+
} else if (stat?.isDirectory) await visit(source);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
await visit('');
|
|
50
|
+
return removed;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=upkeep.js.map
|
package/upkeep.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upkeep.js","sources":["./upkeep.ts"],"names":[],"mappings":"AAAA;sDACsD,GACtD,YAAY,oBAAmB;AAK/B,mEAAmE;AACnE,wEAAwE;AACxE;sCACsC,GACtC,OAAO,IAAI,UAAU,CAAC,GAAS,QAA2B,SAAS,EAAE,IAAI,GAAG,GAAE;AAE9E,iCAAiC;AACjC,OAAO,IAAI,KAAK,CAAC,QAA0B,GAAG,CAAC,QAAQ,GAAG,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC,CAAA;AAE3E;;mDAEmD,GACnD,OAAO,IAAI,OAAO,CAChB,OACA,MACA,QAEA,MAAM,OAAO,CAAC,CAAC;IACb,IAAI,QAAQ,QAAQ,GAAG;IACvB,IAAI,EAAE,IAAI,IAAI,OAAO,OAAO,KAAK,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE;IACpD,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,EAAE;IAChC,KAAK,GAAG,CAAC,EAAE,KAAK;IAChB,OAAO;MACL,IAAI,MACF,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,kBAAkB,CAAC,GACpE,CAAC,GAAG,EAAE,GAAG,QAAQ;KAEtB;EACH,GAAE;AAEJ;;;;yBAIyB,GACzB,OAAO,IAAI,QAAQ,OACjB,QACA,QACA,KAAc,IAAI;EAElB,IAAI,OAAO,OAAO,OAAO,CAAC,QAAQ;EAClC,IAAI,UAAU;EACd,IAAI,QAAQ,OAAO;IACjB,IAAI;IACJ,IAAI;MACF,UAAU,MAAM,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO;IACpD,EAAE,OAAO,OAAO;MACd,IAAI,KAAK,UAAU,CAAC,UAAU,KAAK,kBAAkB,CAAC,QAAQ;MAC9D,MAAM;IACR;IACA,KAAK,IAAI,SAAS,QAAS;MACzB,IAAI,QAAQ,SAAS;MACrB,IAAI,CAAC,MAAM,WAAW,EAAE;MACxB,IAAI,SAAS,OAAO,MAAM,MAAM,IAAI;MACpC,IAAI,OAAO,MAAM,GAAG,KAAK,CAAC,QAAQ,IAAI,CACpC,CAAC,IAAM,GACP,CAAC,QAAU,KAAK,UAAU,CAAC,SAAS,OAAO;MAE7C,IAAI,SAAS,MAAM;QACjB,MAAM,GAAG,MAAM,CAAC,OAAO,QAAQ;UAAE,WAAW;QAAK,GAAG,IAAI,CACtD,IAAM,WACN,CAAC;UACC,IAAI,CAAC,KAAK,UAAU,CAAC,QAAQ,MAAM;QACrC;MAEJ,OAAO,IAAI,MAAM,aAAa,MAAM,MAAM;IAC5C;EACF;EACA,MAAM,MAAM;EACZ,OAAO;AACT,EAAC"}
|
package/upkeep.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Keeping a disk clear of full: telling when one runs low, taking back
|
|
2
|
+
* what a mirror cache keeps for files that are gone. */
|
|
3
|
+
import * as disk from './io.js'
|
|
4
|
+
import type { Disk } from './occupancy.ts'
|
|
5
|
+
|
|
6
|
+
export type Pruning = Pick<typeof disk, 'lstat' | 'readDir' | 'remove'>
|
|
7
|
+
|
|
8
|
+
/// floorOf({ mount: '/', size: 1000, used: 0, free: 1000 }) -> 100
|
|
9
|
+
/// floorOf({ mount: '/', size: 1000, used: 0, free: 1000 }, 300) -> 300
|
|
10
|
+
/** The free bytes a disk is kept above: `floor` where the config sets one,
|
|
11
|
+
* and a tenth of the disk otherwise. */
|
|
12
|
+
export let floorOf = (d: Disk, floor?: number): number => floor ?? d.size / 10
|
|
13
|
+
|
|
14
|
+
/// gb(6_900_000_000) -> '6.9 GB'
|
|
15
|
+
export let gb = (bytes: number): string => `${(bytes / 1e9).toFixed(1)} GB`
|
|
16
|
+
|
|
17
|
+
/** The disks newly below their floor, as errors to report. `told` holds the
|
|
18
|
+
* mounts already reported in their present spell; a disk back above its floor
|
|
19
|
+
* leaves it, so the next spell is reported again. */
|
|
20
|
+
export let lows = (
|
|
21
|
+
disks: Disk[],
|
|
22
|
+
told: Set<string>,
|
|
23
|
+
floor?: number,
|
|
24
|
+
): Error[] =>
|
|
25
|
+
disks.flatMap((d) => {
|
|
26
|
+
let least = floorOf(d, floor)
|
|
27
|
+
if (d.free >= least) return told.delete(d.mount), []
|
|
28
|
+
if (told.has(d.mount)) return []
|
|
29
|
+
told.add(d.mount)
|
|
30
|
+
return [
|
|
31
|
+
new Error(
|
|
32
|
+
`${d.mount} has ${gb(d.free)} free of ${gb(d.size)}, below its floor ` +
|
|
33
|
+
`of ${gb(least)}`,
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
/** Remove each directory of `mirror`, a cache laid out by the absolute paths
|
|
39
|
+
* of the files it was made from (Deno's emit cache, `gen/file`), whose own
|
|
40
|
+
* directory is gone: nothing can read what it keeps again. Returns the
|
|
41
|
+
* directories removed. A path that cannot be read is kept, and the walk stops
|
|
42
|
+
* when `signal` aborts. */
|
|
43
|
+
export let prune = async (
|
|
44
|
+
mirror: string,
|
|
45
|
+
signal?: AbortSignal,
|
|
46
|
+
fs: Pruning = disk,
|
|
47
|
+
): Promise<number> => {
|
|
48
|
+
let base = mirror.replace(/\/+$/, '')
|
|
49
|
+
let removed = 0
|
|
50
|
+
let visit = async (path: string): Promise<void> => {
|
|
51
|
+
let entries
|
|
52
|
+
try {
|
|
53
|
+
entries = await Array.fromAsync(fs.readDir(base + path))
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (disk.isNotFound(error) || disk.isPermissionDenied(error)) return
|
|
56
|
+
throw error
|
|
57
|
+
}
|
|
58
|
+
for (let entry of entries) {
|
|
59
|
+
if (signal?.aborted) return
|
|
60
|
+
if (!entry.isDirectory) continue
|
|
61
|
+
let source = path + '/' + entry.name
|
|
62
|
+
let stat = await fs.lstat(source).then(
|
|
63
|
+
(s) => s,
|
|
64
|
+
(error) => disk.isNotFound(error) ? null : undefined,
|
|
65
|
+
)
|
|
66
|
+
if (stat === null) {
|
|
67
|
+
await fs.remove(base + source, { recursive: true }).then(
|
|
68
|
+
() => removed++,
|
|
69
|
+
(error) => {
|
|
70
|
+
if (!disk.isNotFound(error)) throw error
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
} else if (stat?.isDirectory) await visit(source)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
await visit('')
|
|
77
|
+
return removed
|
|
78
|
+
}
|
package/views.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the browsing app draws from this package: a machine's disks, the tab a
|
|
3
|
+
* machine or a volume opens on, and the Disks page the sidebar offers, every
|
|
4
|
+
* disk looked at. The page is loaded when first drawn (./page.ts).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/ // @ts-types="@yaks/ui/lucide"
|
|
8
|
+
import HardDrive from "lucide/dist/esm/icons/hard-drive.mjs";
|
|
9
|
+
/** The page and the tab, loaded when first drawn. */ export let inspectViews = ()=>import("./page.js").then((m)=>m.inspectViews);
|
|
10
|
+
/** The tab a machine or a volume opens on: its disks. */ export let tabs = [
|
|
11
|
+
{
|
|
12
|
+
view: 'Disks',
|
|
13
|
+
icon: 'hard-drive'
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
/** The page the sidebar offers: every disk looked at, by machine. */ export let destinations = [
|
|
17
|
+
{
|
|
18
|
+
key: 'disks',
|
|
19
|
+
name: 'Disks',
|
|
20
|
+
icon: 'hard-drive',
|
|
21
|
+
view: 'Disks.Page'
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
/** The glyph it wears there. */ export let icons = {
|
|
25
|
+
'hard-drive': HardDrive
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=views.js.map
|
package/views.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sources":["./views.ts"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAED,8BAA8B;AAC9B,OAAO,sDAAgE;AAEvE,mDAAmD,GACnD,OAAO,IAAI,eAAe,IACxB,MAAM,CAAC,aAAa,IAAI,CAAC,CAAC,IAAM,EAAE,YAAY,EAAC;AAEjD,uDAAuD,GACvD,OAAO,IAAI,OAAO;EAAC;IAAE,MAAM;IAAS,MAAM;EAAa;CAAE,CAAA;AAEzD,mEAAmE,GACnE,OAAO,IAAI,eAAe;EACxB;IAAE,KAAK;IAAS,MAAM;IAAS,MAAM;IAAc,MAAM;EAAa;CACvE,CAAA;AAED,8BAA8B,GAC9B,OAAO,IAAI,QAAQ;EAAE,cAAc;AAAU,EAAC"}
|
package/views.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the browsing app draws from this package: a machine's disks, the tab a
|
|
3
|
+
* machine or a volume opens on, and the Disks page the sidebar offers, every
|
|
4
|
+
* disk looked at. The page is loaded when first drawn (./page.ts).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { View } from 'jsr:@yaks/inspect@0.2.36'
|
|
9
|
+
// @ts-types="@yaks/ui/lucide"
|
|
10
|
+
import HardDrive from 'lucide/dist/esm/icons/hard-drive.mjs'
|
|
11
|
+
|
|
12
|
+
/** The page and the tab, loaded when first drawn. */
|
|
13
|
+
export let inspectViews = (): Promise<View[]> =>
|
|
14
|
+
import('./page.js').then((m) => m.inspectViews)
|
|
15
|
+
|
|
16
|
+
/** The tab a machine or a volume opens on: its disks. */
|
|
17
|
+
export let tabs = [{ view: 'Disks', icon: 'hard-drive' }]
|
|
18
|
+
|
|
19
|
+
/** The page the sidebar offers: every disk looked at, by machine. */
|
|
20
|
+
export let destinations = [
|
|
21
|
+
{ key: 'disks', name: 'Disks', icon: 'hard-drive', view: 'Disks.Page' },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
/** The glyph it wears there. */
|
|
25
|
+
export let icons = { 'hard-drive': HardDrive }
|
package/vocab.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The component declarations, and nothing else: the module a server or a
|
|
2
|
+
// browser page imports at `@yaks/file/vocab`. It reaches no storage and no
|
|
3
|
+
// runtime.
|
|
4
|
+
import doc from './vocab.json' with {
|
|
5
|
+
type: 'json'
|
|
6
|
+
};
|
|
7
|
+
import manifest from './package.json' with {
|
|
8
|
+
type: 'json'
|
|
9
|
+
};
|
|
10
|
+
/** The file vocabulary: `file{path, root}`, `lines{file, start, end}`,
|
|
11
|
+
* `volume{machine, mount}` and
|
|
12
|
+
* `occupancy{volume, day, at, size, used, free, counted, paths}`, in the form
|
|
13
|
+
* `loadVocab` accepts. */ export let fileDoc = doc;
|
|
14
|
+
/** What this package is: its manifest's description, the one place it is
|
|
15
|
+
* written, which a host stamps on each document here. */ export let description = manifest.description;
|
|
16
|
+
/** Every document this package declares. */ export let docs = [
|
|
17
|
+
fileDoc
|
|
18
|
+
];
|
|
19
|
+
//# sourceMappingURL=vocab.js.map
|
package/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,WAAW;AAGX,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D;;;wBAGwB,GACxB,OAAO,IAAI,UAAoB,IAAe;AAE9C;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,0CAA0C,GAC1C,OAAO,IAAI,OAAmB;EAAC;CAAQ,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:1c8dcb0e-55e7-4a02-8ea4-c399495fa792",
|
|
3
|
+
"$vocabulary": {
|
|
4
|
+
"https://yak.sh/vocab/core": true
|
|
5
|
+
},
|
|
6
|
+
"title": "file",
|
|
7
|
+
"$defs": {
|
|
8
|
+
"file": {
|
|
9
|
+
"$id": "urn:uuid:440c1876-e66c-46ad-af19-99a679f0b9ed",
|
|
10
|
+
"component": true,
|
|
11
|
+
"journal": false,
|
|
12
|
+
"type": "object",
|
|
13
|
+
"identity": [
|
|
14
|
+
"path",
|
|
15
|
+
"root"
|
|
16
|
+
],
|
|
17
|
+
"description": "a file, as a path read in a root, so anything in the graph can refer to one; its entity id is derived from the path and the root. It carries its contents as `content.body` where the graph keeps them, and goes without where the bytes are kept elsewhere",
|
|
18
|
+
"properties": {
|
|
19
|
+
"path": {
|
|
20
|
+
"$id": "urn:uuid:da3f25b0-cbab-4a52-87a3-49e4a2b70604",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "the path from the root, `/`-separated and with no leading `/`: as Git spells it in a repository, from the mount on a volume"
|
|
23
|
+
},
|
|
24
|
+
"root": {
|
|
25
|
+
"$id": "urn:uuid:b9534748-31da-45a8-b6c6-ae37af22921f",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"ref": "entity",
|
|
28
|
+
"death": "keep",
|
|
29
|
+
"description": "what the path is read in: a `repository`, whose files are a path in its tree at any commit and on no disk, or a `volume`, whose files are bytes on a filesystem a machine mounts"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"lines": {
|
|
34
|
+
"$id": "urn:uuid:fdae8002-a72f-48f2-b587-e25c7b3ac2dc",
|
|
35
|
+
"component": true,
|
|
36
|
+
"journal": false,
|
|
37
|
+
"type": "object",
|
|
38
|
+
"description": "where in a file this entity sits: lines `start` through `end`. An entry read from a transcript wears the line it was read from; a citation of some lines is a `cites` edge to an entity wearing them, with the text it quoted as `content.body`",
|
|
39
|
+
"properties": {
|
|
40
|
+
"file": {
|
|
41
|
+
"$id": "urn:uuid:e9708e6f-e3c8-4dec-8433-99a9ec83fdbe",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"ref": "file",
|
|
44
|
+
"death": "keep",
|
|
45
|
+
"description": "the file"
|
|
46
|
+
},
|
|
47
|
+
"start": {
|
|
48
|
+
"$id": "urn:uuid:90469e2e-0d2b-4cb2-894d-86c6e70a9919",
|
|
49
|
+
"type": "number",
|
|
50
|
+
"description": "the first line, counting from 1"
|
|
51
|
+
},
|
|
52
|
+
"end": {
|
|
53
|
+
"$id": "urn:uuid:44393591-2804-43c9-974c-25e33e375b97",
|
|
54
|
+
"type": "number",
|
|
55
|
+
"description": "the last line, inclusive; absent when it is the first line alone"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"volume": {
|
|
60
|
+
"$id": "urn:uuid:8d7d701a-aee8-432f-b7de-0e1529f617c1",
|
|
61
|
+
"component": true,
|
|
62
|
+
"journal": false,
|
|
63
|
+
"type": "object",
|
|
64
|
+
"embed": false,
|
|
65
|
+
"identity": [
|
|
66
|
+
"machine",
|
|
67
|
+
"mount"
|
|
68
|
+
],
|
|
69
|
+
"description": "a filesystem as a machine mounts it, and the root of the files on it; a path on the machine sits on the volume with the longest mount that contains it. Its entity id is derived from the machine and the mount, so the same disk mounted by another machine is another volume",
|
|
70
|
+
"properties": {
|
|
71
|
+
"machine": {
|
|
72
|
+
"$id": "urn:uuid:967a4457-5219-4d3e-a8ae-3165e349d7f3",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"ref": "machine",
|
|
75
|
+
"death": "keep",
|
|
76
|
+
"description": "the computer that mounts it"
|
|
77
|
+
},
|
|
78
|
+
"mount": {
|
|
79
|
+
"$id": "urn:uuid:83967747-6ea3-4953-9104-0ad7ef996c1d",
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "the absolute directory the machine mounts it at, such as `/`"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"occupancy": {
|
|
86
|
+
"$id": "urn:uuid:dbe3a12a-ac98-4b53-ac92-0258fb69b799",
|
|
87
|
+
"component": true,
|
|
88
|
+
"journal": false,
|
|
89
|
+
"wire": false,
|
|
90
|
+
"embed": false,
|
|
91
|
+
"type": "object",
|
|
92
|
+
"identity": [
|
|
93
|
+
"volume",
|
|
94
|
+
"day"
|
|
95
|
+
],
|
|
96
|
+
"description": "how full a volume was on one UTC day and what filled it, from that day's latest look: the filesystem's bytes, used and free, the bytes a walk of it could read, and the bytes each directory and file on it that takes at least a thousandth of it holds. A later look that day replaces the earlier, so a run of days is how it is trending",
|
|
97
|
+
"properties": {
|
|
98
|
+
"volume": {
|
|
99
|
+
"$id": "urn:uuid:560583bc-8196-4d9b-bcdc-402529ec7715",
|
|
100
|
+
"type": "string",
|
|
101
|
+
"ref": "volume",
|
|
102
|
+
"death": "cascade",
|
|
103
|
+
"description": "the volume looked at"
|
|
104
|
+
},
|
|
105
|
+
"day": {
|
|
106
|
+
"$id": "urn:uuid:8051c8f9-9df5-41df-a143-55a7602e9d39",
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "the UTC day, `2026-10-21`"
|
|
109
|
+
},
|
|
110
|
+
"at": {
|
|
111
|
+
"$id": "urn:uuid:dd32e975-0b56-4350-bda7-6fdde7d915b3",
|
|
112
|
+
"type": "string",
|
|
113
|
+
"format": "date-time",
|
|
114
|
+
"stamped": true,
|
|
115
|
+
"description": "when it was looked at"
|
|
116
|
+
},
|
|
117
|
+
"size": {
|
|
118
|
+
"$id": "urn:uuid:ac56a259-4d2f-402e-b167-c0d8e0b9e75d",
|
|
119
|
+
"type": "integer",
|
|
120
|
+
"stamped": true,
|
|
121
|
+
"description": "the filesystem's bytes"
|
|
122
|
+
},
|
|
123
|
+
"used": {
|
|
124
|
+
"$id": "urn:uuid:03e7e229-be21-4607-8c9f-afceb9025cbd",
|
|
125
|
+
"type": "integer",
|
|
126
|
+
"stamped": true,
|
|
127
|
+
"description": "the bytes in use"
|
|
128
|
+
},
|
|
129
|
+
"free": {
|
|
130
|
+
"$id": "urn:uuid:562729e3-c4f7-4d37-9580-709c09de945d",
|
|
131
|
+
"type": "integer",
|
|
132
|
+
"stamped": true,
|
|
133
|
+
"description": "the bytes still free to write; a filesystem may keep more back for its administrator"
|
|
134
|
+
},
|
|
135
|
+
"counted": {
|
|
136
|
+
"$id": "urn:uuid:1f5c0c7d-e141-4bd7-a29d-ebce3be44c5f",
|
|
137
|
+
"type": "integer",
|
|
138
|
+
"stamped": true,
|
|
139
|
+
"description": "the bytes the walk could read under the mount; the rest of `used` is in directories it could not read, or kept by the filesystem itself"
|
|
140
|
+
},
|
|
141
|
+
"paths": {
|
|
142
|
+
"$id": "urn:uuid:cfd4ef44-277e-4170-8995-e4d1223ad5c1",
|
|
143
|
+
"type": "object",
|
|
144
|
+
"additionalProperties": {
|
|
145
|
+
"type": "integer"
|
|
146
|
+
},
|
|
147
|
+
"stamped": true,
|
|
148
|
+
"description": "the bytes each directory and file taking at least a thousandth of the volume holds, by its path from the mount; a directory's path ends in `/`. A directory listed holds everything listed under it"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"kinds": {
|
|
154
|
+
"file": {
|
|
155
|
+
"$id": "urn:uuid:440c1876-e66c-46ad-af19-99a679f0b9ed",
|
|
156
|
+
"description": "a file, as a path read in a root, so anything in the graph can refer to one; its entity id is derived from the path and the root. It carries its contents as `content.body` where the graph keeps them, and goes without where the bytes are kept elsewhere"
|
|
157
|
+
},
|
|
158
|
+
"volume": {
|
|
159
|
+
"$id": "urn:uuid:8d7d701a-aee8-432f-b7de-0e1529f617c1",
|
|
160
|
+
"description": "a filesystem as a machine mounts it, and the root of the files on it; a path on the machine sits on the volume with the longest mount that contains it. Its entity id is derived from the machine and the mount, so the same disk mounted by another machine is another volume"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The component declarations, and nothing else: the module a server or a
|
|
2
|
+
// browser page imports at `@yaks/file/vocab`. It reaches no storage and no
|
|
3
|
+
// runtime.
|
|
4
|
+
|
|
5
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
6
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
7
|
+
import manifest from './package.json' with { type: 'json' }
|
|
8
|
+
|
|
9
|
+
/** The file vocabulary: `file{path, root}`, `lines{file, start, end}`,
|
|
10
|
+
* `volume{machine, mount}` and
|
|
11
|
+
* `occupancy{volume, day, at, size, used, free, counted, paths}`, in the form
|
|
12
|
+
* `loadVocab` accepts. */
|
|
13
|
+
export let fileDoc: VocabDoc = doc as VocabDoc
|
|
14
|
+
|
|
15
|
+
/** What this package is: its manifest's description, the one place it is
|
|
16
|
+
* written, which a host stamps on each document here. */
|
|
17
|
+
export let description: string = manifest.description
|
|
18
|
+
|
|
19
|
+
/** Every document this package declares. */
|
|
20
|
+
export let docs: VocabDoc[] = [fileDoc]
|