@johnoscott/isometric-engine 0.0.0-stage → 0.10.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/EDITOR-GUIDE.md +355 -0
- package/LICENSE +21 -0
- package/LICENSES/ajv.txt +22 -0
- package/LICENSES/lucide-static.txt +43 -0
- package/LICENSES/yaml.txt +13 -0
- package/README.md +62 -2
- package/assets/app.css +269 -0
- package/assets/default-theme.yaml +99 -0
- package/assets/icons.svg +1 -0
- package/assets/marks.css +39 -0
- package/assets/skin.css +181 -0
- package/iso-editor.d.ts +4 -0
- package/iso-editor.js +550 -0
- package/iso-render.d.ts +3 -0
- package/iso-render.js +388 -0
- package/iso-systems.d.ts +4 -0
- package/iso-systems.js +389 -0
- package/js/iso-core/compile-schema.js +22 -0
- package/js/iso-core/depth.js +55 -0
- package/js/iso-core/errors.js +65 -0
- package/js/iso-core/glyphs.js +100 -0
- package/js/iso-core/index.js +55 -0
- package/js/iso-core/kernel.js +158 -0
- package/js/iso-core/metrics.json +1 -0
- package/js/iso-core/package.json +6 -0
- package/js/iso-core/parse.js +79 -0
- package/js/iso-core/schema-errors.js +170 -0
- package/js/iso-core/shims/crypto.js +125 -0
- package/js/iso-core/shims/path.js +49 -0
- package/js/iso-core/svg-dom.js +144 -0
- package/js/iso-core/theme.js +48 -0
- package/js/iso-core/vdom.js +48 -0
- package/js/iso-editor/adapter.js +0 -0
- package/js/iso-editor/clipboard.js +152 -0
- package/js/iso-editor/commands.js +173 -0
- package/js/iso-editor/complete.js +55 -0
- package/js/iso-editor/doc.js +182 -0
- package/js/iso-editor/index.js +105 -0
- package/js/iso-editor/model.js +210 -0
- package/js/iso-editor/outline.js +111 -0
- package/js/iso-editor/package.json +6 -0
- package/js/iso-editor/path.js +19 -0
- package/js/iso-editor/providers.js +96 -0
- package/js/iso-editor/schema-nav.js +117 -0
- package/js/iso-editor/splice.js +443 -0
- package/js/iso-editor/storage-keys.js +6 -0
- package/js/iso-editor/ui/actions.js +116 -0
- package/js/iso-editor/ui/canvas-layer.js +0 -0
- package/js/iso-editor/ui/canvas.js +1403 -0
- package/js/iso-editor/ui/clip.js +133 -0
- package/js/iso-editor/ui/dialog.js +26 -0
- package/js/iso-editor/ui/flat-canvas.js +54 -0
- package/js/iso-editor/ui/icons.js +15 -0
- package/js/iso-editor/ui/keys.js +26 -0
- package/js/iso-editor/ui/later.js +28 -0
- package/js/iso-editor/ui/layer.js +11 -0
- package/js/iso-editor/ui/menu.js +105 -0
- package/js/iso-editor/ui/monaco-entry.js +2 -0
- package/js/iso-editor/ui/mount-kit.js +0 -0
- package/js/iso-editor/ui/mount.js +767 -0
- package/js/iso-editor/ui/pane.js +0 -0
- package/js/iso-editor/ui/part.js +0 -0
- package/js/iso-editor/ui/plain-icons.js +34 -0
- package/js/iso-editor/ui/props.js +314 -0
- package/js/iso-editor/ui/scope-css.js +81 -0
- package/js/iso-editor/ui/setup.js +149 -0
- package/js/iso-editor/ui/text.js +323 -0
- package/js/iso-editor/ui/tree.js +728 -0
- package/js/iso-editor/validate.js +33 -0
- package/js/iso-editor/window/protocol.js +8 -0
- package/js/iso-objects/assemble.js +43 -0
- package/js/iso-objects/assets.js +88 -0
- package/js/iso-objects/board.js +162 -0
- package/js/iso-objects/compile.js +60 -0
- package/js/iso-objects/css.js +154 -0
- package/js/iso-objects/flat.js +696 -0
- package/js/iso-objects/focus.js +16 -0
- package/js/iso-objects/geometry.js +76 -0
- package/js/iso-objects/index.js +93 -0
- package/js/iso-objects/kinds.js +12 -0
- package/js/iso-objects/labels.js +325 -0
- package/js/iso-objects/package.json +6 -0
- package/js/iso-objects/place.js +347 -0
- package/js/iso-objects/route.js +461 -0
- package/js/iso-objects/scene.js +350 -0
- package/js/iso-objects/steps.js +246 -0
- package/js/iso-objects/types.js +0 -0
- package/js/iso-systems/catalog.js +42 -0
- package/js/iso-systems/compile.js +34 -0
- package/js/iso-systems/css.js +8 -0
- package/js/iso-systems/index.js +16 -0
- package/js/iso-systems/nodes.js +124 -0
- package/js/iso-systems/package.json +6 -0
- package/js/iso-systems/schema.json +311 -0
- package/js/iso-systems/validate.js +35 -0
- package/js/iso-viewer/bundle.js +20 -0
- package/js/iso-viewer/card-motion.js +228 -0
- package/js/iso-viewer/dom.js +14 -0
- package/js/iso-viewer/dual-view.js +212 -0
- package/js/iso-viewer/flat-view.js +124 -0
- package/js/iso-viewer/history.js +990 -0
- package/js/iso-viewer/index.js +98 -0
- package/js/iso-viewer/morph.js +192 -0
- package/js/iso-viewer/overlay.js +199 -0
- package/js/iso-viewer/package.json +6 -0
- package/js/iso-viewer/page.js +138 -0
- package/js/iso-viewer/player.js +409 -0
- package/js/iso-viewer/still.js +81 -0
- package/js/iso-viewer/timeline-contract.js +14 -0
- package/js/iso-viewer/timeline-engine.js +475 -0
- package/js/iso-viewer/timeline-export.js +36 -0
- package/js/iso-viewer/timeline-scale.js +116 -0
- package/js/iso-viewer/timeline-scope.js +58 -0
- package/js/iso-viewer/timeline-search.js +216 -0
- package/js/iso-viewer/timeline-time.js +55 -0
- package/js/iso-viewer/view-css.js +68 -0
- package/js/iso-viewer/viewport.js +177 -0
- package/package.json +511 -4
- package/src/iso-core/compile-schema.ts +23 -0
- package/src/iso-core/depth.ts +56 -0
- package/src/iso-core/errors.ts +73 -0
- package/src/iso-core/glyphs.ts +108 -0
- package/src/iso-core/index.ts +27 -0
- package/src/iso-core/kernel.ts +163 -0
- package/src/iso-core/metrics.json +1 -0
- package/src/iso-core/package.json +6 -0
- package/src/iso-core/parse.ts +91 -0
- package/src/iso-core/schema-errors.ts +163 -0
- package/src/iso-core/shims/crypto.ts +37 -0
- package/src/iso-core/shims/path.ts +24 -0
- package/src/iso-core/svg-dom.ts +103 -0
- package/src/iso-core/theme.ts +64 -0
- package/src/iso-core/vdom.ts +41 -0
- package/src/iso-editor/adapter.ts +147 -0
- package/src/iso-editor/clipboard.ts +163 -0
- package/src/iso-editor/commands.ts +191 -0
- package/src/iso-editor/complete.ts +73 -0
- package/src/iso-editor/doc.ts +207 -0
- package/src/iso-editor/index.ts +67 -0
- package/src/iso-editor/model.ts +234 -0
- package/src/iso-editor/outline.ts +126 -0
- package/src/iso-editor/package.json +6 -0
- package/src/iso-editor/path.ts +18 -0
- package/src/iso-editor/providers.ts +113 -0
- package/src/iso-editor/schema-nav.ts +129 -0
- package/src/iso-editor/splice.ts +477 -0
- package/src/iso-editor/storage-keys.ts +6 -0
- package/src/iso-editor/ui/actions.ts +119 -0
- package/src/iso-editor/ui/app.css +230 -0
- package/src/iso-editor/ui/canvas-layer.ts +56 -0
- package/src/iso-editor/ui/canvas.ts +1227 -0
- package/src/iso-editor/ui/clip.ts +97 -0
- package/src/iso-editor/ui/dialog.ts +25 -0
- package/src/iso-editor/ui/flat-canvas.ts +51 -0
- package/src/iso-editor/ui/icons.ts +21 -0
- package/src/iso-editor/ui/keys.ts +30 -0
- package/src/iso-editor/ui/later.ts +22 -0
- package/src/iso-editor/ui/layer.ts +7 -0
- package/src/iso-editor/ui/marks.css +39 -0
- package/src/iso-editor/ui/menu.ts +67 -0
- package/src/iso-editor/ui/monaco-entry.ts +6 -0
- package/src/iso-editor/ui/mount-kit.ts +35 -0
- package/src/iso-editor/ui/mount.ts +684 -0
- package/src/iso-editor/ui/pane.ts +45 -0
- package/src/iso-editor/ui/part.ts +45 -0
- package/src/iso-editor/ui/plain-icons.ts +83 -0
- package/src/iso-editor/ui/props.ts +347 -0
- package/src/iso-editor/ui/scope-css.ts +65 -0
- package/src/iso-editor/ui/setup.ts +153 -0
- package/src/iso-editor/ui/skin.css +181 -0
- package/src/iso-editor/ui/text.ts +262 -0
- package/src/iso-editor/ui/tree.ts +657 -0
- package/src/iso-editor/validate.ts +62 -0
- package/src/iso-editor/window/protocol.ts +33 -0
- package/src/iso-objects/assemble.ts +57 -0
- package/src/iso-objects/assets.ts +122 -0
- package/src/iso-objects/board.ts +169 -0
- package/src/iso-objects/compile.ts +76 -0
- package/src/iso-objects/css.ts +163 -0
- package/src/iso-objects/flat.ts +653 -0
- package/src/iso-objects/focus.ts +14 -0
- package/src/iso-objects/geometry.ts +86 -0
- package/src/iso-objects/index.ts +33 -0
- package/src/iso-objects/kinds.ts +56 -0
- package/src/iso-objects/labels.ts +310 -0
- package/src/iso-objects/package.json +6 -0
- package/src/iso-objects/place.ts +318 -0
- package/src/iso-objects/route.ts +444 -0
- package/src/iso-objects/scene.ts +376 -0
- package/src/iso-objects/steps.ts +234 -0
- package/src/iso-objects/types.ts +68 -0
- package/src/iso-systems/catalog.ts +31 -0
- package/src/iso-systems/compile.ts +39 -0
- package/src/iso-systems/css.ts +9 -0
- package/src/iso-systems/index.ts +12 -0
- package/src/iso-systems/nodes.ts +126 -0
- package/src/iso-systems/package.json +6 -0
- package/src/iso-systems/schema.json +311 -0
- package/src/iso-systems/validate.ts +34 -0
- package/src/iso-viewer/bundle.ts +15 -0
- package/src/iso-viewer/card-motion.ts +237 -0
- package/src/iso-viewer/dom.ts +13 -0
- package/src/iso-viewer/dual-view.ts +212 -0
- package/src/iso-viewer/flat-view.ts +127 -0
- package/src/iso-viewer/history.ts +781 -0
- package/src/iso-viewer/index.ts +40 -0
- package/src/iso-viewer/morph.ts +191 -0
- package/src/iso-viewer/overlay.ts +212 -0
- package/src/iso-viewer/package.json +6 -0
- package/src/iso-viewer/page.ts +150 -0
- package/src/iso-viewer/player.ts +321 -0
- package/src/iso-viewer/still.ts +74 -0
- package/src/iso-viewer/timeline-contract.ts +342 -0
- package/src/iso-viewer/timeline-engine.ts +420 -0
- package/src/iso-viewer/timeline-export.ts +31 -0
- package/src/iso-viewer/timeline-scale.ts +129 -0
- package/src/iso-viewer/timeline-scope.ts +56 -0
- package/src/iso-viewer/timeline-search.ts +198 -0
- package/src/iso-viewer/timeline-time.ts +54 -0
- package/src/iso-viewer/view-css.ts +59 -0
- package/src/iso-viewer/viewport.ts +142 -0
- package/types/iso-core/compile-schema.d.ts +11 -0
- package/types/iso-core/depth.d.ts +6 -0
- package/types/iso-core/errors.d.ts +24 -0
- package/types/iso-core/glyphs.d.ts +19 -0
- package/types/iso-core/index.d.ts +17 -0
- package/types/iso-core/kernel.d.ts +130 -0
- package/types/iso-core/metrics.json +1 -0
- package/types/iso-core/parse.d.ts +18 -0
- package/types/iso-core/schema-errors.d.ts +14 -0
- package/types/iso-core/shims/crypto.d.ts +9 -0
- package/types/iso-core/svg-dom.d.ts +15 -0
- package/types/iso-core/theme.d.ts +38 -0
- package/types/iso-core/vdom.d.ts +26 -0
- package/types/iso-editor/adapter.d.ts +178 -0
- package/types/iso-editor/clipboard.d.ts +23 -0
- package/types/iso-editor/commands.d.ts +32 -0
- package/types/iso-editor/complete.d.ts +25 -0
- package/types/iso-editor/doc.d.ts +50 -0
- package/types/iso-editor/index.d.ts +57 -0
- package/types/iso-editor/model.d.ts +96 -0
- package/types/iso-editor/outline.d.ts +28 -0
- package/types/iso-editor/path.d.ts +7 -0
- package/types/iso-editor/providers.d.ts +43 -0
- package/types/iso-editor/schema-nav.d.ts +34 -0
- package/types/iso-editor/splice.d.ts +53 -0
- package/types/iso-editor/storage-keys.d.ts +5 -0
- package/types/iso-editor/ui/actions.d.ts +23 -0
- package/types/iso-editor/ui/canvas-layer.d.ts +65 -0
- package/types/iso-editor/ui/canvas.d.ts +307 -0
- package/types/iso-editor/ui/clip.d.ts +14 -0
- package/types/iso-editor/ui/dialog.d.ts +7 -0
- package/types/iso-editor/ui/flat-canvas.d.ts +2 -0
- package/types/iso-editor/ui/icons.d.ts +5 -0
- package/types/iso-editor/ui/keys.d.ts +7 -0
- package/types/iso-editor/ui/later.d.ts +12 -0
- package/types/iso-editor/ui/layer.d.ts +2 -0
- package/types/iso-editor/ui/menu.d.ts +21 -0
- package/types/iso-editor/ui/mount-kit.d.ts +31 -0
- package/types/iso-editor/ui/mount.d.ts +146 -0
- package/types/iso-editor/ui/pane.d.ts +60 -0
- package/types/iso-editor/ui/part.d.ts +40 -0
- package/types/iso-editor/ui/plain-icons.d.ts +10 -0
- package/types/iso-editor/ui/props.d.ts +57 -0
- package/types/iso-editor/ui/scope-css.d.ts +5 -0
- package/types/iso-editor/ui/setup.d.ts +49 -0
- package/types/iso-editor/ui/text.d.ts +19 -0
- package/types/iso-editor/ui/tree.d.ts +100 -0
- package/types/iso-editor/validate.d.ts +36 -0
- package/types/iso-editor/window/protocol.d.ts +60 -0
- package/types/iso-objects/assemble.d.ts +35 -0
- package/types/iso-objects/assets.d.ts +49 -0
- package/types/iso-objects/board.d.ts +36 -0
- package/types/iso-objects/compile.d.ts +35 -0
- package/types/iso-objects/css.d.ts +16 -0
- package/types/iso-objects/flat.d.ts +130 -0
- package/types/iso-objects/focus.d.ts +1 -0
- package/types/iso-objects/geometry.d.ts +59 -0
- package/types/iso-objects/index.d.ts +26 -0
- package/types/iso-objects/kinds.d.ts +53 -0
- package/types/iso-objects/labels.d.ts +92 -0
- package/types/iso-objects/place.d.ts +25 -0
- package/types/iso-objects/route.d.ts +67 -0
- package/types/iso-objects/scene.d.ts +63 -0
- package/types/iso-objects/steps.d.ts +90 -0
- package/types/iso-objects/types.d.ts +140 -0
- package/types/iso-systems/catalog.d.ts +4 -0
- package/types/iso-systems/compile.d.ts +6 -0
- package/types/iso-systems/css.d.ts +3 -0
- package/types/iso-systems/index.d.ts +5 -0
- package/types/iso-systems/nodes.d.ts +3 -0
- package/types/iso-viewer/card-motion.d.ts +56 -0
- package/types/iso-viewer/dom.d.ts +1 -0
- package/types/iso-viewer/dual-view.d.ts +44 -0
- package/types/iso-viewer/flat-view.d.ts +25 -0
- package/types/iso-viewer/history.d.ts +91 -0
- package/types/iso-viewer/index.d.ts +31 -0
- package/types/iso-viewer/morph.d.ts +28 -0
- package/types/iso-viewer/overlay.d.ts +135 -0
- package/types/iso-viewer/page.d.ts +13 -0
- package/types/iso-viewer/still.d.ts +26 -0
- package/types/iso-viewer/timeline-contract.d.ts +345 -0
- package/types/iso-viewer/timeline-engine.d.ts +20 -0
- package/types/iso-viewer/timeline-export.d.ts +5 -0
- package/types/iso-viewer/timeline-scale.d.ts +44 -0
- package/types/iso-viewer/timeline-scope.d.ts +33 -0
- package/types/iso-viewer/timeline-search.d.ts +52 -0
- package/types/iso-viewer/timeline-time.d.ts +8 -0
- package/types/iso-viewer/view-css.d.ts +7 -0
- package/types/iso-viewer/viewport.d.ts +50 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// The timeline's contract, version 1 (docs/timeline/README.md), generic: what a host's history looks like to the
|
|
2
|
+
// timeline component, from a whole machine down to the smallest scope it records. A host gives query() and subscribe()
|
|
3
|
+
// over its own records; the component never knows which host, or whether the records are a fixture or a simulation.
|
|
4
|
+
//
|
|
5
|
+
// A domain fills in four things (TimelineTypes): its scope kinds, the state a recorded frame holds (what a canvas
|
|
6
|
+
// draws at the playhead), the flags a scope's name and row may carry, and the links an event may have. Its catalogue
|
|
7
|
+
// (TimelineCatalog) says the same at run time: which kinds may sit in which, the flags, and how its links search. The
|
|
8
|
+
// domain's own module gives the contract's names narrowed to it.
|
|
9
|
+
//
|
|
10
|
+
// The rule for every field: no message text, no prompts, no tokens or secrets, no real hostnames, no folders.
|
|
11
|
+
|
|
12
|
+
export const TIMELINE_VERSION = 1;
|
|
13
|
+
|
|
14
|
+
/** what a domain fills in */
|
|
15
|
+
export interface TimelineTypes {
|
|
16
|
+
/** its scope kinds */
|
|
17
|
+
kind: string;
|
|
18
|
+
/** what a recorded frame holds */
|
|
19
|
+
state: unknown;
|
|
20
|
+
/** the boolean flags a scope's name (and its row) may carry */
|
|
21
|
+
flag: string;
|
|
22
|
+
/** the links an event may carry: each an id, never a text */
|
|
23
|
+
links: object;
|
|
24
|
+
}
|
|
25
|
+
/** any domain's (the generic code's own view) */
|
|
26
|
+
export interface AnyTimeline extends TimelineTypes { kind: string; state: unknown; flag: never; links: Record<string, string | undefined> }
|
|
27
|
+
|
|
28
|
+
// ---------- scopes: a path from the fleet down ----------
|
|
29
|
+
|
|
30
|
+
/** a scope path: "kind:name" segments, outermost first, joined by "/"; the fleet is "" */
|
|
31
|
+
export type Scope = string;
|
|
32
|
+
/** a segment's name: no "/", ":", "%" or whitespace, except %-escaped (%2F, %3A, %25, %20) */
|
|
33
|
+
export const SEGMENT_NAME = '(?:[^/:%\\s]|%[0-9A-F]{2})+';
|
|
34
|
+
|
|
35
|
+
// ---------- events ----------
|
|
36
|
+
|
|
37
|
+
export const SEVERITIES = ['debug', 'info', 'notice', 'warning', 'error'] as const;
|
|
38
|
+
export type Severity = typeof SEVERITIES[number];
|
|
39
|
+
|
|
40
|
+
/** an attribute's value: a scalar, never an object; a string is one short line */
|
|
41
|
+
export type AttrValue = string | number | boolean | null;
|
|
42
|
+
|
|
43
|
+
/** One thing that happened, at t (or over [t, t + dur) for a span). */
|
|
44
|
+
export interface TimelineEvent<T extends TimelineTypes = AnyTimeline> {
|
|
45
|
+
/** unique within its source and stable: the same record, the same id (a later batch with this id replaces it) */
|
|
46
|
+
id: string;
|
|
47
|
+
/** when, in ms since 1970-01-01T00:00:00Z */
|
|
48
|
+
t: number;
|
|
49
|
+
/** a span's length in ms (so far, while open); absent for a mark */
|
|
50
|
+
dur?: number;
|
|
51
|
+
/** an ongoing span: it lasts to now (its dur, if any, is so far); a later batch gives its end */
|
|
52
|
+
open?: true;
|
|
53
|
+
scope: Scope;
|
|
54
|
+
/** one of the catalogue's sources */
|
|
55
|
+
source: string;
|
|
56
|
+
/** one of its source's kinds */
|
|
57
|
+
kind: string;
|
|
58
|
+
severity: Severity;
|
|
59
|
+
/** one line a person reads (at most 200 characters): never a message's text, a prompt, a secret, a real hostname, a
|
|
60
|
+
* folder, or a sensitive attr's value */
|
|
61
|
+
summary: string;
|
|
62
|
+
/** a flat map of scalars; the source's catalogue entry names the keys it may carry and which are sensitive */
|
|
63
|
+
attrs: Record<string, AttrValue>;
|
|
64
|
+
links: T['links'];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ---------- metrics ----------
|
|
68
|
+
|
|
69
|
+
export const BINS = ['1m', '1h', '1d'] as const;
|
|
70
|
+
export type Bin = typeof BINS[number];
|
|
71
|
+
/** a bin's nominal width (a local day may be 23 or 25 hours long) */
|
|
72
|
+
export const BIN_MS: Record<Bin, number> = { '1m': 60_000, '1h': 3_600_000, '1d': 86_400_000 };
|
|
73
|
+
|
|
74
|
+
/** one sample of a series, at t (a later batch with the same series, scope and t replaces it) */
|
|
75
|
+
export interface MetricPoint { series: string; scope: Scope; t: number; value: number }
|
|
76
|
+
/** a series over one bin [t, t + bin): what a coarser bin is made of (min of mins, max of maxes, sums of sums and counts) */
|
|
77
|
+
export interface MetricRollup { series: string; scope: Scope; t: number; bin: Bin; min: number; max: number; sum: number; count: number }
|
|
78
|
+
|
|
79
|
+
/** events over one bin, on one row: how the zoomed-out view draws count bars and heat strips */
|
|
80
|
+
export interface EventBin {
|
|
81
|
+
/** the row's scope */
|
|
82
|
+
scope: Scope;
|
|
83
|
+
t: number;
|
|
84
|
+
bin: Bin;
|
|
85
|
+
count: number;
|
|
86
|
+
/** count by severity (absent keys are 0) */
|
|
87
|
+
severity: Partial<Record<Severity, number>>;
|
|
88
|
+
/** count by kind, for the kinds present (a host may give only the top few, and say so with kindsTruncated: then the
|
|
89
|
+
* kind counts of a coarser bin can't be made from it) */
|
|
90
|
+
kinds?: Record<string, number>;
|
|
91
|
+
kindsTruncated?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------- search: the component parses; the query carries the parse ----------
|
|
95
|
+
|
|
96
|
+
/** one test of an event */
|
|
97
|
+
export type Match<T extends TimelineTypes = AnyTimeline> =
|
|
98
|
+
| { field: 'text'; value: string } // summary, kind, source, scope, non-sensitive string attrs; no case
|
|
99
|
+
| { field: 'kind' | 'source'; value: string; prefix?: true } // exact, or a prefix (kind:action.*)
|
|
100
|
+
| { field: 'severity'; op: 'eq' | 'ge' | 'gt' | 'le' | 'lt'; value: Severity }
|
|
101
|
+
| { field: 'scope'; value: Scope; from: 'top' | 'segments' } // top: that scope and under; segments: those segments in a row, anywhere
|
|
102
|
+
| { field: 'link'; link: keyof T['links']; value: string } // a link's id (the domain may match more: see TimelineCatalog)
|
|
103
|
+
| { field: 'attr'; key: string; value: string }; // a string attr's value, no case (a sensitive attr only this way)
|
|
104
|
+
/** a term: any of its matches (the same field twice ORs), or none of them when not */
|
|
105
|
+
export interface AstTerm<T extends TimelineTypes = AnyTimeline> { not?: true; any: Match<T>[] }
|
|
106
|
+
/** every term (different fields AND); since: and before: aren't here: they narrow the query's from and to */
|
|
107
|
+
export interface SearchAst<T extends TimelineTypes = AnyTimeline> { all: AstTerm<T>[] }
|
|
108
|
+
|
|
109
|
+
// ---------- the catalogue: what a host keeps ----------
|
|
110
|
+
|
|
111
|
+
/** days kept; null: kept until the user deletes it */
|
|
112
|
+
export type Days = number | null;
|
|
113
|
+
export interface Retention {
|
|
114
|
+
/** single events (and raw metric points) */
|
|
115
|
+
events: Days;
|
|
116
|
+
/** rollups, by bin */
|
|
117
|
+
rollups: Record<Bin, Days>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface SeriesInfo<T extends TimelineTypes = AnyTimeline> {
|
|
121
|
+
name: string;
|
|
122
|
+
/** e.g. "count", "bytes", "ms", "%" */
|
|
123
|
+
unit: string;
|
|
124
|
+
/** counter: a count per sample, shown as sums only (its mean is meaningless); gauge: a level, shown as its min/max
|
|
125
|
+
* band and mean */
|
|
126
|
+
type: 'counter' | 'gauge';
|
|
127
|
+
/** the scope kind a series is recorded at */
|
|
128
|
+
at: T['kind'];
|
|
129
|
+
title: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface KindInfo {
|
|
133
|
+
name: string;
|
|
134
|
+
title: string;
|
|
135
|
+
/** a span (it has a dur, or is open) */
|
|
136
|
+
span?: boolean;
|
|
137
|
+
/** named, not yet recorded */
|
|
138
|
+
notYet?: boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface SourceInfo<T extends TimelineTypes = AnyTimeline> {
|
|
142
|
+
name: string;
|
|
143
|
+
title: string;
|
|
144
|
+
/** kept: the host records it today; not-yet: named in the contract, not yet recorded (the UI lists it, greyed) */
|
|
145
|
+
status: 'kept' | 'not-yet';
|
|
146
|
+
/** the scope kinds its events and series are recorded at */
|
|
147
|
+
at: T['kind'][];
|
|
148
|
+
kinds: KindInfo[];
|
|
149
|
+
/** kinds taken verbatim from the host's own names: any kind matching this (the listed kinds are the known ones) */
|
|
150
|
+
kindPattern?: string;
|
|
151
|
+
series: SeriesInfo<T>[];
|
|
152
|
+
/** the attrs its events may carry */
|
|
153
|
+
attrs: string[];
|
|
154
|
+
/** attrs that can name something sensitive (a remote host, a folder, free text): hidden until asked for, never in free
|
|
155
|
+
* text search, a summary or a rollup */
|
|
156
|
+
sensitive?: string[];
|
|
157
|
+
/** attrs naming a person: the viewer's own name is written "you" */
|
|
158
|
+
people?: string[];
|
|
159
|
+
/** what the contract suggests; a host may choose otherwise */
|
|
160
|
+
defaultRetention: Retention;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The effective retention, per source, as the user set it: the UI says "kept 30 days" and greys out what's gone. */
|
|
164
|
+
export interface EffectiveRetention extends Retention {
|
|
165
|
+
source: string;
|
|
166
|
+
/** user: set by the user; default: the host's default */
|
|
167
|
+
setBy: 'user' | 'default';
|
|
168
|
+
/** the earliest t still kept, for single events and for each bin (absent: nothing kept yet) */
|
|
169
|
+
keptFrom: { events?: number; rollups: Partial<Record<Bin, number>> };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** A scope's display: its label, the domain's flags, and the scopes it was known as before a rename (their history
|
|
173
|
+
* shows on its row). */
|
|
174
|
+
export type ScopeName<T extends TimelineTypes = AnyTimeline> = { scope: Scope; label: string; aliases?: Scope[] } & { [F in T['flag']]?: boolean };
|
|
175
|
+
|
|
176
|
+
export interface Catalog<T extends TimelineTypes = AnyTimeline> {
|
|
177
|
+
timeline: 1;
|
|
178
|
+
type: 'catalog';
|
|
179
|
+
/** display names, chosen by the host per machine, %-escaped in a scope: never a real hostname */
|
|
180
|
+
hosts: string[];
|
|
181
|
+
sources: SourceInfo<T>[];
|
|
182
|
+
retention: EffectiveRetention[];
|
|
183
|
+
/** labels, flags and renames */
|
|
184
|
+
names?: ScopeName<T>[];
|
|
185
|
+
/** the host's now: the live edge */
|
|
186
|
+
now: number;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ---------- queries ----------
|
|
190
|
+
|
|
191
|
+
export interface Filters {
|
|
192
|
+
source?: string[];
|
|
193
|
+
kind?: string[];
|
|
194
|
+
severity?: Severity[];
|
|
195
|
+
/** scope prefixes (segment-wise: a prefix matches it and everything under it) */
|
|
196
|
+
scope?: Scope[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface Query<T extends TimelineTypes = AnyTimeline> {
|
|
200
|
+
timeline: 1;
|
|
201
|
+
type: 'query';
|
|
202
|
+
scope: Scope;
|
|
203
|
+
/** rows: the scopes this many levels below scope (0: one row, the scope itself) */
|
|
204
|
+
depth: number;
|
|
205
|
+
/** [from, to), ms; since: and before: already applied */
|
|
206
|
+
from: number;
|
|
207
|
+
to: number;
|
|
208
|
+
/** binned: bins and rollups; absent: single events and points */
|
|
209
|
+
bin?: Bin;
|
|
210
|
+
/** the owner's time zone (IANA, e.g. "Australia/Sydney"): 1d bins start at its midnight, and 1h bins on its hour
|
|
211
|
+
* where its offset isn't whole hours; absent: UTC */
|
|
212
|
+
tz?: string;
|
|
213
|
+
/** the search, parsed by the component: what a host applies (ANDed with filters) */
|
|
214
|
+
where?: SearchAst<T>;
|
|
215
|
+
/** the search as typed: for display and saved views only; a host never needs to read it */
|
|
216
|
+
q?: string;
|
|
217
|
+
filters?: Filters;
|
|
218
|
+
/** series to return (absent: every series recorded at or under the rows; empty: none) */
|
|
219
|
+
series?: string[];
|
|
220
|
+
/** single events per page (default 2000, at most 10000) */
|
|
221
|
+
limit?: number;
|
|
222
|
+
/** from a result's next: the same query, the next page */
|
|
223
|
+
cursor?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** A row the component draws: one scope at the query's depth, with its name's flags. Events at a shallower scope than
|
|
227
|
+
* the rows go on their own scope's row, marked own. */
|
|
228
|
+
export type Row<T extends TimelineTypes = AnyTimeline> = {
|
|
229
|
+
scope: Scope;
|
|
230
|
+
/** the last segment's name, or the catalogue's label */
|
|
231
|
+
label: string;
|
|
232
|
+
kind: T['kind'] | 'fleet';
|
|
233
|
+
/** levels below the query's scope */
|
|
234
|
+
depth: number;
|
|
235
|
+
own?: boolean;
|
|
236
|
+
/** scopes one level below this row (the component offers to drill in when > 0) */
|
|
237
|
+
children: number;
|
|
238
|
+
/** events in the range, after search and filters */
|
|
239
|
+
count: number;
|
|
240
|
+
first?: number;
|
|
241
|
+
last?: number;
|
|
242
|
+
} & { [F in T['flag']]?: boolean };
|
|
243
|
+
|
|
244
|
+
export interface Result<T extends TimelineTypes = AnyTimeline> {
|
|
245
|
+
timeline: 1;
|
|
246
|
+
type: 'result';
|
|
247
|
+
rows: Row<T>[];
|
|
248
|
+
/** unbinned: single events, by (t, id); spans overlapping the range are included */
|
|
249
|
+
events?: TimelineEvent<T>[];
|
|
250
|
+
/** binned: counts per row and bin, an event counted in the bin of its t */
|
|
251
|
+
bins?: EventBin[];
|
|
252
|
+
/** binned: the spans at least one bin long, so they still draw zoomed out */
|
|
253
|
+
spans?: TimelineEvent<T>[];
|
|
254
|
+
/** points unbinned, rollups binned (attributed to rows: sums and counts add, min of mins, max of maxes) */
|
|
255
|
+
metrics: (MetricPoint | MetricRollup)[];
|
|
256
|
+
/** all matching events in the range (or an estimate, said so) */
|
|
257
|
+
total: number;
|
|
258
|
+
totalEstimated?: boolean;
|
|
259
|
+
retention: EffectiveRetention[];
|
|
260
|
+
/** what of the search couldn't be read, and was searched as text (the component's parse says so; a host may add) */
|
|
261
|
+
warnings?: string[];
|
|
262
|
+
/** more single events: pass as cursor */
|
|
263
|
+
next?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** What subscribe() pushes: what's new or changed since the last batch, for a live query (to moves with the host's
|
|
267
|
+
* now). An event with an id already given replaces it (an open span's end, a late field); a point with a series, scope
|
|
268
|
+
* and t already given replaces it (a minute's counters grow after the minute). On the wire, one Batch per SSE event. */
|
|
269
|
+
export interface Batch<T extends TimelineTypes = AnyTimeline> {
|
|
270
|
+
timeline: 1;
|
|
271
|
+
type: 'batch';
|
|
272
|
+
events: TimelineEvent<T>[];
|
|
273
|
+
metrics: (MetricPoint | MetricRollup)[];
|
|
274
|
+
/** rows that appeared */
|
|
275
|
+
rows?: Row<T>[];
|
|
276
|
+
/** the host's now: everything up to here is in */
|
|
277
|
+
now: number;
|
|
278
|
+
retention?: EffectiveRetention[];
|
|
279
|
+
/** resume from here after a dropped connection (the SSE event's id) */
|
|
280
|
+
resume?: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A saved view: what the URL holds, with a name (the host stores it). */
|
|
284
|
+
export interface View {
|
|
285
|
+
timeline: 1;
|
|
286
|
+
type: 'view';
|
|
287
|
+
name: string;
|
|
288
|
+
scope: Scope;
|
|
289
|
+
depth: number;
|
|
290
|
+
/** a fixed range, or a quick one (15m, 1h, 1d, 1w, run) ending at now */
|
|
291
|
+
range: { from: number; to: number } | { last: '15m' | '1h' | '1d' | '1w' | 'run' };
|
|
292
|
+
q?: string;
|
|
293
|
+
filters?: Filters;
|
|
294
|
+
live?: boolean;
|
|
295
|
+
/** time breaks off (they are on unless this says false) */
|
|
296
|
+
collapseGaps?: boolean;
|
|
297
|
+
/** the rows with nothing in the range shown (they are hidden unless this says true) */
|
|
298
|
+
quietRows?: boolean;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** A recorded history in one file: a fixture, or an export. */
|
|
302
|
+
export interface Recording<T extends TimelineTypes = AnyTimeline> {
|
|
303
|
+
timeline: 1;
|
|
304
|
+
type: 'recording';
|
|
305
|
+
catalog: Catalog<T>;
|
|
306
|
+
events: TimelineEvent<T>[];
|
|
307
|
+
metrics: (MetricPoint | MetricRollup)[];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ---------- the host's side ----------
|
|
311
|
+
|
|
312
|
+
/** What a host gives the timeline component. A fixture source reads a Recording; a simulation is one more source. */
|
|
313
|
+
export interface TimelineSource<T extends TimelineTypes = AnyTimeline> {
|
|
314
|
+
catalog(): Promise<Catalog<T>>;
|
|
315
|
+
query(q: Query<T>): Promise<Result<T>>;
|
|
316
|
+
/** live: batches for this query as they happen; returns unsubscribe (on the wire: SSE, §8) */
|
|
317
|
+
subscribe?(q: Query<T>, onBatch: (b: Batch<T>) => void): () => void;
|
|
318
|
+
/** the state recorded at t, where one was (a frame): a canvas follows the playhead */
|
|
319
|
+
stateAt?(scope: Scope, t: number): Promise<T['state'] | undefined>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// ---------- the domain's catalogue, at run time ----------
|
|
323
|
+
|
|
324
|
+
/** What the generic code needs to know of a domain's timeline. */
|
|
325
|
+
export interface TimelineCatalog {
|
|
326
|
+
/** its scope kinds, and what each may sit in ('' is the fleet) */
|
|
327
|
+
kinds: readonly string[];
|
|
328
|
+
parents: Readonly<Record<string, readonly string[]>>;
|
|
329
|
+
/** the flags a scope's name may carry, copied to its row; a flagged row is labelled by its first flag, not its kind */
|
|
330
|
+
flags: readonly string[];
|
|
331
|
+
/** the search's link fields (name:value), in the order the language lists them */
|
|
332
|
+
links: readonly string[];
|
|
333
|
+
/** a link the domain matches its own way as well (a link's value also found in an event's scope); undefined: only
|
|
334
|
+
* equal ids match */
|
|
335
|
+
linkMatch?(link: string, value: string, e: TimelineEvent): boolean | undefined;
|
|
336
|
+
/** a scope: search value starting with one of these kinds is anchored at the top (else it is segments anywhere) */
|
|
337
|
+
topKinds: readonly string[];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** the pattern a scope path of this catalogue's kinds matches */
|
|
341
|
+
export const scopePattern = (cat: Pick<TimelineCatalog, 'kinds'>) =>
|
|
342
|
+
`^(?:(?:${cat.kinds.join('|')}):(?:${SEGMENT_NAME})(?:/(?:${cat.kinds.join('|')}):(?:${SEGMENT_NAME}))*)?$`;
|