@yaks/tracker 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/Histogram.js +71 -0
- package/Histogram.js.map +1 -0
- package/Histogram.ts +100 -0
- package/LICENSE +202 -0
- package/README.md +639 -2
- package/_dist/brief.d.ts +25 -0
- package/_dist/brief.d.ts.map +1 -0
- package/_dist/changes.d.ts +9 -0
- package/_dist/changes.d.ts.map +1 -0
- package/_dist/chart.d.ts +24 -0
- package/_dist/chart.d.ts.map +1 -0
- package/_dist/digest.d.ts +64 -0
- package/_dist/digest.d.ts.map +1 -0
- package/_dist/effects.d.ts +73 -0
- package/_dist/effects.d.ts.map +1 -0
- package/_dist/errors.d.ts +14 -0
- package/_dist/errors.d.ts.map +1 -0
- package/_dist/everywhere.d.ts +13 -0
- package/_dist/everywhere.d.ts.map +1 -0
- package/_dist/fault.d.ts +29 -0
- package/_dist/fault.d.ts.map +1 -0
- package/_dist/file.d.ts +6 -0
- package/_dist/file.d.ts.map +1 -0
- package/_dist/fixtime.d.ts +20 -0
- package/_dist/fixtime.d.ts.map +1 -0
- package/_dist/frames.d.ts +6 -0
- package/_dist/frames.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/group.d.ts +21 -0
- package/_dist/group.d.ts.map +1 -0
- package/_dist/instrument.d.ts +37 -0
- package/_dist/instrument.d.ts.map +1 -0
- package/_dist/intake.d.ts +21 -0
- package/_dist/intake.d.ts.map +1 -0
- package/_dist/merge.d.ts +11 -0
- package/_dist/merge.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/model.d.ts +20 -0
- package/_dist/model.d.ts.map +1 -0
- package/_dist/outage.d.ts +7 -0
- package/_dist/outage.d.ts.map +1 -0
- package/_dist/people.d.ts +3 -0
- package/_dist/people.d.ts.map +1 -0
- package/_dist/poll.d.ts +101 -0
- package/_dist/poll.d.ts.map +1 -0
- package/_dist/poll_thread.d.ts +8 -0
- package/_dist/poll_thread.d.ts.map +1 -0
- package/_dist/reading.d.ts +34 -0
- package/_dist/reading.d.ts.map +1 -0
- package/_dist/remote.d.ts +61 -0
- package/_dist/remote.d.ts.map +1 -0
- package/_dist/report.d.ts +324 -0
- package/_dist/report.d.ts.map +1 -0
- package/_dist/resolution.d.ts +22 -0
- package/_dist/resolution.d.ts.map +1 -0
- package/_dist/routes.d.ts +33 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/script.d.ts +8 -0
- package/_dist/script.d.ts.map +1 -0
- package/_dist/service.d.ts +30 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/sync_health.d.ts +4 -0
- package/_dist/sync_health.d.ts.map +1 -0
- package/_dist/ticket.d.ts +14 -0
- package/_dist/ticket.d.ts.map +1 -0
- package/_dist/tools.d.ts +39 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/trace-intake.d.ts +25 -0
- package/_dist/trace-intake.d.ts.map +1 -0
- package/_dist/views.d.ts +11 -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/box.json +51 -0
- package/brief.js +86 -0
- package/brief.js.map +1 -0
- package/brief.ts +120 -0
- package/changes.js +57 -0
- package/changes.js.map +1 -0
- package/changes.ts +70 -0
- package/chart.js +186 -0
- package/chart.js.map +1 -0
- package/chart.ts +193 -0
- package/deno.json +1 -0
- package/digest.js +329 -0
- package/digest.js.map +1 -0
- package/digest.ts +406 -0
- package/effects.js +136 -0
- package/effects.js.map +1 -0
- package/effects.ts +178 -0
- package/errors.js +130 -0
- package/errors.js.map +1 -0
- package/errors.ts +185 -0
- package/everywhere.js +46 -0
- package/everywhere.js.map +1 -0
- package/everywhere.ts +66 -0
- package/fault.js +65 -0
- package/fault.js.map +1 -0
- package/fault.ts +107 -0
- package/file.js +87 -0
- package/file.js.map +1 -0
- package/file.ts +93 -0
- package/fixtime.js +67 -0
- package/fixtime.js.map +1 -0
- package/fixtime.ts +86 -0
- package/frames.js +77 -0
- package/frames.js.map +1 -0
- package/frames.ts +69 -0
- package/graph.js +7 -0
- package/graph.js.map +1 -0
- package/graph.ts +8 -0
- package/group.js +444 -0
- package/group.js.map +1 -0
- package/group.ts +533 -0
- package/inspect.js +471 -0
- package/inspect.js.map +1 -0
- package/inspect.ts +693 -0
- package/instrument.js +69 -0
- package/instrument.js.map +1 -0
- package/instrument.ts +93 -0
- package/intake.js +43 -0
- package/intake.js.map +1 -0
- package/intake.ts +84 -0
- package/merge.js +126 -0
- package/merge.js.map +1 -0
- package/merge.ts +115 -0
- package/migrate.ts +36 -0
- package/mod.js +8 -0
- package/mod.js.map +1 -0
- package/mod.ts +19 -0
- package/model.js +8 -0
- package/model.js.map +1 -0
- package/model.ts +27 -0
- package/outage.js +129 -0
- package/outage.js.map +1 -0
- package/outage.ts +158 -0
- package/package.json +133 -4
- package/page.d.ts +2 -0
- package/page.js +905 -0
- package/people.js +51 -0
- package/people.js.map +1 -0
- package/people.ts +82 -0
- package/poll.js +277 -0
- package/poll.js.map +1 -0
- package/poll.ts +411 -0
- package/poll_thread.js +104 -0
- package/poll_thread.js.map +1 -0
- package/poll_thread.ts +126 -0
- package/poll_worker.ts +45 -0
- package/reading.js +122 -0
- package/reading.js.map +1 -0
- package/reading.ts +162 -0
- package/reconcile.js +113 -0
- package/reconcile.js.map +1 -0
- package/reconcile.ts +130 -0
- package/remote.js +312 -0
- package/remote.js.map +1 -0
- package/remote.ts +397 -0
- package/report.js +825 -0
- package/report.js.map +1 -0
- package/report.ts +944 -0
- package/resolution.js +114 -0
- package/resolution.js.map +1 -0
- package/resolution.ts +123 -0
- package/routes.js +130 -0
- package/routes.js.map +1 -0
- package/routes.ts +163 -0
- package/script.js +13 -0
- package/script.js.map +1 -0
- package/script.ts +16 -0
- package/service.js +174 -0
- package/service.js.map +1 -0
- package/service.ts +215 -0
- package/spread.js +94 -0
- package/spread.js.map +1 -0
- package/spread.ts +101 -0
- package/sync_health.js +36 -0
- package/sync_health.js.map +1 -0
- package/sync_health.ts +65 -0
- package/ticket.js +6 -0
- package/ticket.js.map +1 -0
- package/ticket.ts +24 -0
- package/tools.js +305 -0
- package/tools.js.map +1 -0
- package/tools.ts +411 -0
- package/trace-intake.js +164 -0
- package/trace-intake.js.map +1 -0
- package/trace-intake.ts +148 -0
- package/views.js +247 -0
- package/views.js.map +1 -0
- package/views.ts +254 -0
- package/vocab.js +20 -0
- package/vocab.js.map +1 -0
- package/vocab.json +834 -0
- package/vocab.ts +14 -0
- package/yak-tracker@.service +22 -0
package/_dist/poll.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import { type Remote } from "./remote.js";
|
|
3
|
+
import { type Read } from "./routes.js";
|
|
4
|
+
import type { Mark } from "./model.js";
|
|
5
|
+
import { type Clock } from "@yaks/fp";
|
|
6
|
+
import { pollThread } from "./poll_thread.js";
|
|
7
|
+
export { OUTAGE } from "./outage.js";
|
|
8
|
+
export { pollThread };
|
|
9
|
+
export { changes } from "./changes.js";
|
|
10
|
+
/** A polled answer of the platform tracker, with its mark door. */ export type Polled = {
|
|
11
|
+
/** the query each poll asks the Worker */ query: string;
|
|
12
|
+
/** the bugs it answered last */ readonly value: Bundle[];
|
|
13
|
+
/** a poll has answered and the latest one did not fail */ readonly ready: boolean;
|
|
14
|
+
/** called after each poll, answered or failed */ subscribe: (fn: (bundles: Bundle[]) => void) => () => void;
|
|
15
|
+
/** stop polling */ close: () => void;
|
|
16
|
+
/** send each bundle's `resolved`, `archived` or `taken` mark to the
|
|
17
|
+
* Worker. Its marks carry no precondition, so a bundle's `$was` is not
|
|
18
|
+
* checked. */ mutate: (bundles: Bundle[]) => Promise<Bundle[]>;
|
|
19
|
+
/** the bugs among `eids`, whatever the poll's query, asked once */ get: (eids: string[]) => Promise<Bundle[]>;
|
|
20
|
+
};
|
|
21
|
+
/** The Worker's doors a poll asks: a page of its bugs, and a mark. */ export type Doors = {
|
|
22
|
+
/** scopes whose bugs moved since the held tag, through the platform */ changes?: (tag?: string, signal?: AbortSignal) => Promise<Read>;
|
|
23
|
+
/** a page of the bugs `params` asks for (`limit`, `query`), or that
|
|
24
|
+
* nothing moved since `tag` */ bugs: (params: URLSearchParams, signal?: AbortSignal, tag?: string) => Promise<Read>;
|
|
25
|
+
/** a mark on one bug and what it says: a resolution's explanation, the
|
|
26
|
+
* fixer's `task` with `taken`; in the platform's tracker, or the space's
|
|
27
|
+
* `scope` names */ mark: (bug: string, name: Mark, said: Record<string, string>, scope?: string) => Promise<unknown>;
|
|
28
|
+
};
|
|
29
|
+
/** The Worker's doors over the signed transport (./remote.ts), through `go`. */ export declare let signed: (remote: Remote, go?: typeof fetch) => Doors;
|
|
30
|
+
/** `doors` asking the tracker of the space `scope` names, or as they ask
|
|
31
|
+
* without one: the platform's. */ export declare let scoped: (doors: Doors, scope?: string) => Doors;
|
|
32
|
+
export type PollOpts = {
|
|
33
|
+
/** A shared change feed's version of this scope. An unchanged version
|
|
34
|
+
* skips its bug read; a failed read never acknowledges the version. */ version?: (scope?: string) => Promise<string | undefined>;
|
|
35
|
+
/** time between polls, in ms (default 30000) */ every?: number;
|
|
36
|
+
/** how long one page of a poll may take before the poll counts as failed,
|
|
37
|
+
* in ms (default: the request's own bound, a minute), so every poll
|
|
38
|
+
* settles */ timeout?: number;
|
|
39
|
+
/** a failure to fix: a poll that failed other than by the tracker being
|
|
40
|
+
* out of reach, at once, and the tracker not answering for OUTAGE, once */ report?: (error: unknown) => void;
|
|
41
|
+
/** a poll the tracker could not answer, which the next one retries, and
|
|
42
|
+
* its answering again (default: `console.warn`) */ log?: (line: string) => void;
|
|
43
|
+
/** where it asks (default: signed doors on a dedicated worker event loop),
|
|
44
|
+
* which several polls may share */ doors?: Doors;
|
|
45
|
+
/** the global eid of the space whose tracker it polls; the platform's
|
|
46
|
+
* without one */ scope?: string;
|
|
47
|
+
/** what time it is, and how a wait is set — between polls, a hung poll's
|
|
48
|
+
* and a page's deadline (default: the runtime's), so a test can hold the
|
|
49
|
+
* clock */ clock?: Clock;
|
|
50
|
+
};
|
|
51
|
+
/** A page of the bugs `params` asks for, or that nothing moved since `tag`;
|
|
52
|
+
* a refusal throws. */ export type Page = (params: URLSearchParams, tag?: string) => Promise<Extract<Read, {
|
|
53
|
+
ok: true;
|
|
54
|
+
}>>;
|
|
55
|
+
/** The pages `doors` answers. A refusal throws, as `Unavailable` (./remote.ts)
|
|
56
|
+
* where the tracker could not answer for now: a 503 or 504 (./routes.ts
|
|
57
|
+
* `read`), or a page past its `timeout`; as `Misconfigured` where this side
|
|
58
|
+
* could not set the read up, a 500. A stop ends a page as itself, never
|
|
59
|
+
* as the read it cut short. */ export declare let pages: (doors: Doors, stop?: AbortSignal, _dts_1: never) => Page;
|
|
60
|
+
/** What brings an answer read at a tag up to date: the rows read, at the tag
|
|
61
|
+
* the tracker stands at now. With `moved`, they are the answer among those
|
|
62
|
+
* entities, which moved since; without, the whole answer. */ export type Fresh = {
|
|
63
|
+
rows: Bundle[];
|
|
64
|
+
tag?: string;
|
|
65
|
+
moved?: string[];
|
|
66
|
+
};
|
|
67
|
+
/** What brings the answer to `query` read at tag `held` up to date: nothing
|
|
68
|
+
* when nothing moved, the bugs among those that moved when the tracker names
|
|
69
|
+
* them, and otherwise, or with no tag held, the whole answer. */ export declare let since: (page: Page, query: string, held?: string) => Promise<Fresh | undefined>;
|
|
70
|
+
/** The answer `rows` brought up to date by `fresh`, in eid order.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { renewed } from '@yaks/tracker/poll'
|
|
74
|
+
* import { equal } from '@yaks/testing'
|
|
75
|
+
* let bug = (eid: string, fault = eid) => ({ entity: { eid }, bug: { fault } })
|
|
76
|
+
* let rows = [bug('a'), bug('b'), bug('c')]
|
|
77
|
+
* equal(
|
|
78
|
+
* renewed(rows, { rows: [bug('b', 'new'), bug('d')], moved: ['b', 'c', 'd'] }),
|
|
79
|
+
* [bug('a'), bug('b', 'new'), bug('d')],
|
|
80
|
+
* )
|
|
81
|
+
* equal(renewed(rows, { rows: [bug('e')] }), [bug('e')])
|
|
82
|
+
* ```
|
|
83
|
+
*/ export declare let renewed: (rows: Bundle[], fresh: Fresh) => Bundle[];
|
|
84
|
+
/**
|
|
85
|
+
* Poll the platform tracker's bugs, or a space tracker's, until closed.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { poll } from '@yaks/tracker/poll'
|
|
89
|
+
*
|
|
90
|
+
* // Supply doors for an in-memory example; omit them for the signed worker.
|
|
91
|
+
* let open = poll({ url: 'https://tracker.example' }, '.bug', {
|
|
92
|
+
* doors: {
|
|
93
|
+
* bugs: async () => ({ ok: true, value: [] }),
|
|
94
|
+
* mark: async () => {},
|
|
95
|
+
* },
|
|
96
|
+
* })
|
|
97
|
+
* open.ready // false: no poll has answered
|
|
98
|
+
* open.close()
|
|
99
|
+
* ```
|
|
100
|
+
*/ export declare let poll: (remote: Remote, query?: string, opts?: PollOpts) => Polled;
|
|
101
|
+
//# sourceMappingURL=poll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll.d.ts","sources":["../poll.ts"],"names":[],"mappings":"AAYA,cAAc,MAAM,2BAAgC;AAEpD,SAGE,KAAK,MAAM,sBAGO;AACpB,SAAS,KAAK,IAAI,sBAA2B;AAC7C,cAAc,IAAI,qBAAoB;AACtC,SAAS,KAAK,KAAK,wBAAqC;AAExD,SAAS,UAAU,2BAA0B;AAE7C,SAAS,MAAM,sBAAqB;AACpC,SAAS,UAAU,GAAE;AACrB,SAAS,OAAO,uBAAsB;AAEtC,iEAAiE,GACjE,YAAY;EACV,wCAAwC,GACxC,OAAO,MAAM;EACb,8BAA8B,YACrB,OAAO;EAChB,wDAAwD,YAC/C,OAAO,OAAO;EACvB,+CAA+C,GAC/C,YAAY,KAAK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AAO,MAAM,EACb,OAAO,MAAM,KACZ,QAAQ,QAAQ,SAAS,EAW3B;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,UAAW,MAAM,UAAU,OAAO,UAAQ,SAKpD;AAoBD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,OACT,QAAQ,QACR,gBACA,OAAM,aACL,OAqGF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Doors } from "./poll.js";
|
|
2
|
+
import type { Remote } from "./remote.js";
|
|
3
|
+
/** Signed poll doors with their own event loop. Close owns and terminates only
|
|
4
|
+
* this worker, rejecting outstanding reads and marks. A failed worker is
|
|
5
|
+
* replaced on the next poll, never by retrying an ambiguous mark here. */ export declare let pollThread: (remote: Remote) => Doors & {
|
|
6
|
+
close: () => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=poll_thread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll_thread.d.ts","sources":["../poll_thread.ts"],"names":[],"mappings":"AAGA,cAAc,KAAK,oBAAmB;AACtC,cAAc,MAAM,sBAAqB;AA4BzC;;wEAEwE,GACxE,OAAO,YAAI,aAAc,QAAQ,WAAS;EAAU,aAAa,IAAI;EA0FpE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import { type Built } from "@yaks/query";
|
|
3
|
+
/** Worst first is historical occurrence count, not the retained sample size. */ export declare let openBugs: Built;
|
|
4
|
+
/** A bug's retained occurrences, newest first, as the query line a page asks. */ export declare let occurrences: (eid: string) => Built;
|
|
5
|
+
/** The platform tracker's global eid: the scope a read names by default. */ export declare let platform: string;
|
|
6
|
+
/** A bug's page on the box's tracker web when it lives on another side (the
|
|
7
|
+
* platform tracker, `yaks.app`), read through by global eid. A space's
|
|
8
|
+
* tracker holds its own bugs, so its page names that tracker's `scope`; one
|
|
9
|
+
* of the bug's occurrences opens on the same page.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { assertEquals } from '@std/assert'
|
|
13
|
+
* assertEquals(
|
|
14
|
+
* remoteBug('yaks.app', 'b', { error: 'e' }),
|
|
15
|
+
* '/?.bug&side=yaks.app&bug=b&error=e',
|
|
16
|
+
* )
|
|
17
|
+
* assertEquals(
|
|
18
|
+
* remoteBug('yaks.app', 'b', { scope: 's' }),
|
|
19
|
+
* '/?.bug&side=yaks.app&scope=s&bug=b',
|
|
20
|
+
* )
|
|
21
|
+
* assertEquals(
|
|
22
|
+
* remoteBug('yaks.app', 'b', { scope: platform }),
|
|
23
|
+
* '/?.bug&side=yaks.app&bug=b',
|
|
24
|
+
* )
|
|
25
|
+
* ```
|
|
26
|
+
*/ export declare let remoteBug: (side: string, bug: string, _dts_1: never) => string;
|
|
27
|
+
/** The hit that reopened a bug, in a line: its message and the code it ran
|
|
28
|
+
* on. A bug reopened before its mark said so reads as its title. */ export declare let reopened: (bug: Bundle) => string;
|
|
29
|
+
/** Request identity is an exact association. Other context is a bounded time
|
|
30
|
+
* neighbour, not evidence that a trace contains or caused this error. */ export declare let relatedTraces: (e: Bundle) => {
|
|
31
|
+
query: string;
|
|
32
|
+
label: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
//# sourceMappingURL=reading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading.d.ts","sources":["../reading.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAAgC;AAEpD,SAGE,KAAK,KAAK,2BAMmB;AAI/B,8EAA8E,GAC9E,OAAO,YAAI,UAAU,MAAiD;AACtE,+EAA+E,GAC/E,OAAO,YAAI,cAAe,KAAK,MAAM,KAAG,MACI;AAa5C,0EAA0E,GAC1E,OAAO,YAAI,UAAU,MAAM,CAAiC;AAE5D;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,YACT,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,kBACC,MAAM,CAQL;AAYJ;kEACkE,GAClE,OAAO,YAAI,WAAY,KAAK,WAAS,MAAM,CAK1C;AA2CD;uEACuE,GACvE,OAAO,YAAI,gBACT,GAAG;EACA,OAAO,MAAM;EAAE,OAAO,MAAM;IAAK,SAAS,CAyB9C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Clock } from "@yaks/fp";
|
|
2
|
+
import type { Bundle } from "@yaks/graph";
|
|
3
|
+
import { platform } from "./reading.js";
|
|
4
|
+
export { platform };
|
|
5
|
+
export type Remote = {
|
|
6
|
+
url?: string;
|
|
7
|
+
secret?: string;
|
|
8
|
+
};
|
|
9
|
+
/** A sink whose delivery is always a promise, so a caller can wait for it and
|
|
10
|
+
* read why it failed. */ export type Delivery = (rows: Bundle[]) => Promise<void>;
|
|
11
|
+
/** A failure a timeout caused. It is named as one; any other failure names no
|
|
12
|
+
* cause, since a cause can carry the address or the upstream's body. */ export declare let late: (error: unknown) => any;
|
|
13
|
+
/** Whether an answer's status says the tracker cannot answer for now (it timed
|
|
14
|
+
* out, is busy, or failed on its side), which a later try can recover from;
|
|
15
|
+
* any other refusal is its answer to what was asked. */ export declare let unavailable: (status: number) => any;
|
|
16
|
+
/** A request the tracker could not answer for now, which a later try can
|
|
17
|
+
* recover from: no attempt was answered, or it answered a status `unavailable`
|
|
18
|
+
* names. Anything else that fails is a refusal of what was asked, or a failure
|
|
19
|
+
* on this side. */ export declare class Unavailable extends Error {
|
|
20
|
+
}
|
|
21
|
+
/** A refusal that says how long to wait, a 429 with `retry-after`: the
|
|
22
|
+
* tracker answered, stopped past its rows (@yaks/durable-object `Stopped`),
|
|
23
|
+
* and takes nothing until `retry.after` milliseconds have run. The stop was
|
|
24
|
+
* reported where it happened, as the runaway that caused it, so a caller
|
|
25
|
+
* waits it out and reports nothing. */ export declare class Stopped extends Unavailable {
|
|
26
|
+
name: string;
|
|
27
|
+
retry: {
|
|
28
|
+
after: number;
|
|
29
|
+
};
|
|
30
|
+
constructor(message: string, after: number);
|
|
31
|
+
}
|
|
32
|
+
/** The failure a refused answer is: `Stopped` where it says how long to
|
|
33
|
+
* wait, `Unavailable` where its status says the tracker cannot answer for
|
|
34
|
+
* now, else a refusal of what was asked. */ export declare let refused: (response: Response, refusal: string) => Error;
|
|
35
|
+
/** A request this side cannot set up: no address, no secret, or an address it
|
|
36
|
+
* does not send to. It is a failure to fix now, never the tracker being down;
|
|
37
|
+
* the remote is read at each use, so the request after a fix goes out. */ export declare class Misconfigured extends Error {
|
|
38
|
+
}
|
|
39
|
+
/** `error`, or the `Unavailable` it is when a timeout caused it. */ export declare let unanswered: (error: unknown) => unknown;
|
|
40
|
+
declare let doors: {
|
|
41
|
+
readonly resolved: string;
|
|
42
|
+
readonly archived: string;
|
|
43
|
+
readonly taken: string;
|
|
44
|
+
readonly reopened: string;
|
|
45
|
+
};
|
|
46
|
+
export declare let request: (remote: Remote, path: string, params: URLSearchParams, init?: RequestInit, go?: typeof fetch, clock?: Clock) => Promise<Response>;
|
|
47
|
+
export declare let delivery: (remote: Remote, go?: typeof fetch) => Delivery;
|
|
48
|
+
/** The Worker's door a mark goes to, and what it says there: the bug, and
|
|
49
|
+
* what the mark says (a resolution's explanation, a fixer's `task`). */ export declare let marking: (bug: string, name: keyof typeof doors, said?: Record<string, string>) => {
|
|
50
|
+
door: string;
|
|
51
|
+
body: string;
|
|
52
|
+
};
|
|
53
|
+
/** Mark a Worker copy, returning false when the Worker does not hold it. A
|
|
54
|
+
* resolution carries its explanation and `taken` the fixer's `task`. The
|
|
55
|
+
* copy is the platform tracker's, or the tracker of the space `scope` names. */ export declare let mark: (remote: Remote, bug: string, name: keyof typeof doors, go?: typeof fetch, said?: Record<string, string>, scope?: string) => Promise<boolean>;
|
|
56
|
+
/** The global eids of the spaces whose trackers the Worker has routed to,
|
|
57
|
+
* as the platform tracker lists them. A Worker whose deploy has not reached
|
|
58
|
+
* its object yet answers the list's door as no route: it lists none yet. */ export declare let spaces: (remote: Remote, go?: typeof fetch, populated?: boolean) => Promise<string[]>;
|
|
59
|
+
export declare let retry: (remote: Remote, of: string, go?: typeof fetch) => Promise<number>;
|
|
60
|
+
export declare let drop: (remote: Remote, of: string, go?: typeof fetch) => Promise<number>;
|
|
61
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sources":["../remote.ts"],"names":[],"mappings":"AAeA,SAAS,KAAK,KAAK,wBAA4C;AAC/D,cAAc,MAAM,2BAAgC;AACpD,SAAS,QAAQ,uBAAsB;AAGvC,SAAS,QAAQ,GAAE;AAEnB,YAAY;EAAW,MAAM,MAAM;EAAE,SAAS,MAAM;;AAEpD;uBACuB,GACvB,YAAY,YAAY,MAAM,aAAa,QAAQ,IAAI;AAMvD;sEACsE,GACtE,OAAO,YAAI,OAAQ,OAAO,OAAO,SAC8B;AAM/D;;sDAEsD,GACtD,OAAO,YAAI,cAAe,QAAQ,MAAM,SAC0B;AAElE;;;iBAGiB,GACjB,OAAO,cAAM,oBAAoB;AAAO;AAExC;;;;qCAIqC,GACrC,OAAO,cAAM,gBAAgB;EAClB,aAAgB;EACzB;IAAS,OAAO,MAAM;IAAE;EACxB,YAAY,SAAS,MAAM,EAAE,OAAO,MAAM;AAI5C;AAKA;;0CAE0C,GAC1C,OAAO,YAAI,UAAW,UAAU,UAAU,SAAS,MAAM,KAAG,MAQ3D;AAED;;wEAEwE,GACxE,OAAO,cAAM,sBAAsB;AAAO;AAI1C,kEAAkE,GAClE,OAAO,YAAI,aAAc,OAAO,OAAO,KAAG,OAAO,CAC+B;AAUhF,YAAI;WACF;WACA;WACA;WACA;;AAUF,OAAO,YAAI,UACT,QAAQ,QACR,MAAM,MAAM,EACZ,QAAQ,iBACR,OAAM,aACN,YAAW,OACX,QAAO,UACN,QAAQ,UAsGV;AACD,OAAO,YAAI,WACR,QAAQ,QAAQ,YAAW,UAAgB,SAqB3C;AAMH;sEACsE,GACtE,OAAO,YAAI,UACT,KAAK,MAAM,EACX,mBAAmB,OACnB,OAAM,OAAO,MAAM,EAAE,MAAM;EACxB,MAAM,MAAM;EAAE,MAAM,MAAM;EAG7B;AAEF;;8EAE8E,GAC9E,OAAO,YAAI,OACT,QAAQ,QACR,KAAK,MAAM,EACX,mBAAmB,OACnB,YAAW,OACX,OAAM,OAAO,MAAM,EAAE,MAAM,GAC3B,mBACC,QAAQ,OAAO,EAoCjB;AAED;;0EAE0E,GAC1E,OAAO,YAAI,SACT,QAAQ,QACR,YAAW,OACX,wBACC,QAAQ,MAAM,IA8BhB;AAqCD,OAAO,YAAI,QACT,QAAQ,QACR,IAAI,MAAM,EACV,YAAW,UACV,QAAQ,MAAM,EAAqC;AACtD,OAAO,YAAI,OACT,QAAQ,QACR,IAAI,MAAM,EACV,YAAW,UACV,QAAQ,MAAM,EAAoC"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import type { Actor, Bundle } from "@yaks/graph";
|
|
2
|
+
import { type Crumb, type Level } from "./model.js";
|
|
3
|
+
export { faultOf, normalize } from "./fault.js";
|
|
4
|
+
/** Browser request correlation, with only the shapes the page emits. */ export declare let pageAttempt: (id?: string | null, retry?: string | null) => {
|
|
5
|
+
page_request: string;
|
|
6
|
+
page_retry?: string;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export type Sink = (rows: Bundle[]) => void | Promise<void>;
|
|
9
|
+
export type Context = {
|
|
10
|
+
sink: Sink;
|
|
11
|
+
actor?: Actor;
|
|
12
|
+
eid?: string;
|
|
13
|
+
at?: string;
|
|
14
|
+
/** start of the observation window when a failure was measured over time */ windowStart?: string;
|
|
15
|
+
level?: Level;
|
|
16
|
+
/** the bug this files under; default the error's own `fault`, if it names
|
|
17
|
+
* one, else one derived from its kind, message and top frame */ fault?: string;
|
|
18
|
+
commit?: string;
|
|
19
|
+
version?: number;
|
|
20
|
+
environment?: 'production' | 'staging';
|
|
21
|
+
tags?: Record<string, unknown>;
|
|
22
|
+
during?: {
|
|
23
|
+
entity?: string;
|
|
24
|
+
kind?: string;
|
|
25
|
+
app?: string;
|
|
26
|
+
space?: string;
|
|
27
|
+
session?: string;
|
|
28
|
+
process?: string;
|
|
29
|
+
request?: string;
|
|
30
|
+
};
|
|
31
|
+
mechanism?: 'catch' | 'wrapper' | 'onerror' | 'onunhandledrejection' | 'console' | 'loading';
|
|
32
|
+
breadcrumbs?: Crumb[];
|
|
33
|
+
request?: Bundle;
|
|
34
|
+
fallback?: Sink;
|
|
35
|
+
};
|
|
36
|
+
/** Runtime provenance uses the same request association on every reporting path.
|
|
37
|
+
* Non-HTTP entries name their operation without inventing an HTTP request.
|
|
38
|
+
* A request naming its session in `x-via` is tagged `via`: one of our own
|
|
39
|
+
* agents made it. */ export declare let origin: (script: string, version: string | undefined, entrypoint: string, request?: Request, eid?: string) => Pick<Context, 'tags' | 'commit' | 'during' | 'request'>;
|
|
40
|
+
/** A caller that hung up, in the words of the Workers runtime.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { ok } from '@yaks/testing'
|
|
44
|
+
* import { disconnected } from '@yaks/tracker/report'
|
|
45
|
+
* ok(disconnected(new TypeError(
|
|
46
|
+
* "Can't read from request stream because client disconnected.",
|
|
47
|
+
* )))
|
|
48
|
+
* ok(disconnected(new DOMException('The client has disconnected', 'AbortError')))
|
|
49
|
+
* ok(!disconnected(new DOMException('The operation was aborted', 'AbortError')))
|
|
50
|
+
* ok(!disconnected(new TypeError('x is undefined')))
|
|
51
|
+
* ```
|
|
52
|
+
*/ export declare let disconnected: (error: unknown) => boolean;
|
|
53
|
+
/** Refusals are control flow, not tracked mistakes, and neither is a caller
|
|
54
|
+
* that hung up, nor a service that did not answer for now (@yaks/graph
|
|
55
|
+
* `unheard`), which is asked again: only one that stays slow is reported,
|
|
56
|
+
* by whoever watches it. Hosts can exclude their own accepted/deferred
|
|
57
|
+
* operation before calling caught. */ export declare let refused: (error: unknown) => boolean;
|
|
58
|
+
/** `text` with every credential an address in it carries out of sight. A
|
|
59
|
+
* failure quotes the addresses it asked, and the credential in one opens
|
|
60
|
+
* what it guards to whoever reads the bug.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { equal } from '@yaks/testing'
|
|
64
|
+
* import { redacted } from '@yaks/tracker/report'
|
|
65
|
+
*
|
|
66
|
+
* equal(
|
|
67
|
+
* redacted('/emberwild/~eyJhIjoxfQ.c2ln/trail: signal timed out'),
|
|
68
|
+
* '/emberwild/~token/trail: signal timed out',
|
|
69
|
+
* )
|
|
70
|
+
* equal(redacted('at https://ada.yaks.app/~abc.def/api/query'), 'at https://ada.yaks.app/~token/api/query')
|
|
71
|
+
* equal(redacted('/cookbook/_preview/t.mac/about'), '/cookbook/_preview/token/about')
|
|
72
|
+
* equal(redacted('GET https://bo:pw@host/x?page=2&access_token=s3'), 'GET https://redacted@host/x?page=2&access_token=redacted')
|
|
73
|
+
* equal(redacted('/b.js?X-Amz-Signature=f0&transform.bytecode=1'), '/b.js?X-Amz-Signature=redacted&transform.bytecode=1')
|
|
74
|
+
* equal(redacted('2 ~ 3, /home/ and /cookbook/_preview'), '2 ~ 3, /home/ and /cookbook/_preview')
|
|
75
|
+
* ```
|
|
76
|
+
*/ export declare let redacted: (text: string) => string;
|
|
77
|
+
/** `row` with every credential an address carries ({@link redacted}) out of
|
|
78
|
+
* each of its components: what capture keeps, and what a row captured
|
|
79
|
+
* before it kept them is scrubbed to. Its eid and stamps stand.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { equal } from '@yaks/testing'
|
|
83
|
+
* import { withheld } from '@yaks/tracker/report'
|
|
84
|
+
*
|
|
85
|
+
* equal(
|
|
86
|
+
* withheld({ entity: { eid: 'e' }, request: { url: 'https://a.test/x/~s.t/y' } }),
|
|
87
|
+
* { entity: { eid: 'e' }, request: { url: 'https://a.test/x/~token/y' } },
|
|
88
|
+
* )
|
|
89
|
+
* ```
|
|
90
|
+
*/ export declare let withheld: (row: Bundle) => Bundle;
|
|
91
|
+
/** No request query, headers, body, cookies, or console arguments leave, and
|
|
92
|
+
* no credential an address carries ({@link redacted}), in any component. */ export declare let scrub: (rows: Bundle[]) => Bundle[];
|
|
93
|
+
/** What a thrown value says it is. An Error says so itself. Any other object
|
|
94
|
+
* (a refusal's `{error, message}`, a plain `{code, …}`) says its own name and
|
|
95
|
+
* message, or its JSON, never `[object Object]`; it carries no stack, so the
|
|
96
|
+
* stack is where it was reported from. A string or number is its message.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { equal, ok } from '@yaks/testing'
|
|
100
|
+
* import { described } from '@yaks/tracker/report'
|
|
101
|
+
*
|
|
102
|
+
* equal(described({ error: 'Refused', message: 'no' })?.type, 'Refused')
|
|
103
|
+
* equal(described({ id: 7 })?.value, '{"id":7}')
|
|
104
|
+
* equal(described('broken'), undefined)
|
|
105
|
+
* let wrapped = new Error('could not take', { cause: new Error('refused') })
|
|
106
|
+
* ok(described(wrapped)?.cause?.startsWith('Error: refused'))
|
|
107
|
+
* let locked = Array.from({ length: 2 }, () => new Error('database is locked'))
|
|
108
|
+
* let many = new AggregateError([...locked, new Error('no such table')], '3 failed')
|
|
109
|
+
* equal(described(many)?.cause?.split('\nCaused by: ').map((c) => c.split('\n')[0]), [
|
|
110
|
+
* 'Error: database is locked',
|
|
111
|
+
* 'Error: no such table',
|
|
112
|
+
* ])
|
|
113
|
+
* let failed = Object.assign(new Error('no such table: t'), { statement: 'select 1 from t' })
|
|
114
|
+
* equal(described(failed)?.cause, 'Details: {"statement":"select 1 from t"}')
|
|
115
|
+
* ```
|
|
116
|
+
*/ export declare let described: (error: unknown) => {
|
|
117
|
+
type: string;
|
|
118
|
+
value: string;
|
|
119
|
+
stack?: string;
|
|
120
|
+
cause?: string;
|
|
121
|
+
} | undefined;
|
|
122
|
+
export declare let capture: (error: unknown, context: Context) => Bundle[];
|
|
123
|
+
export declare let report: (error: unknown, context: Context) => Promise<void>;
|
|
124
|
+
export declare let caught: (error: unknown, context: Context) => Promise<void>;
|
|
125
|
+
/** One break a page reported to its door: the page reporter's own body
|
|
126
|
+
* (./page), an entry the browser's Reporting API sent, or a native shell's,
|
|
127
|
+
* which names itself by `type` and says what it runs in its `tags`. */ export type Break = {
|
|
128
|
+
/** the page's release, when its reporter said which it loaded */ version: number | null;
|
|
129
|
+
/** the platform deployment that drew the page, when it named one */ deployment?: string;
|
|
130
|
+
/** `page /path`, or the Reporting API's type and the page's path */ request: string;
|
|
131
|
+
message: string;
|
|
132
|
+
stack: string;
|
|
133
|
+
/** what the error was wrapped around, down its `cause` chain */ cause?: string;
|
|
134
|
+
mechanism?: Mechanism;
|
|
135
|
+
breadcrumbs?: Crumb[];
|
|
136
|
+
/** the file the reporter named apart from its page: for a resource that
|
|
137
|
+
* failed to load, the one that was refused */ file?: string;
|
|
138
|
+
/** the browser that sent it, its user agent ({@link received}) */ agent?: string;
|
|
139
|
+
/** what its sender says of itself, which its door decides whether to keep:
|
|
140
|
+
* a native shell's variant and the update it runs */ tags?: Record<string, string>;
|
|
141
|
+
};
|
|
142
|
+
type Mechanism = NonNullable<Context['mechanism']>;
|
|
143
|
+
export { FILED } from "@yaks/api/refuse";
|
|
144
|
+
/** A no the page was answered on purpose: a 4xx status. */ export declare let meant: (_answer: string, status: number) => boolean;
|
|
145
|
+
/**
|
|
146
|
+
* The breaks a page's report door was sent, out of either body: the page
|
|
147
|
+
* reporter's `{message, stack?, cause?, url?, page?, line?, status?, answer?,
|
|
148
|
+
* mechanism?, version?, breadcrumbs?}`, or the Reporting API's array of `{type, url,
|
|
149
|
+
* body}`. A native shell sends the reporter's, naming itself as `type` and
|
|
150
|
+
* adding `tags` of its own. Junk answers with nothing: a malformed body is the sender's bug, not
|
|
151
|
+
* a break in the page. An answer the reporter saw that `refusal` calls a no
|
|
152
|
+
* somebody meant (default {@link meant}) is the page working, not a break,
|
|
153
|
+
* and so is a fetch of the page's own origin that had no answer, which an older
|
|
154
|
+
* reporter, in a tab left open or a copy reopened from the cache, still sends.
|
|
155
|
+
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { equal } from '@yaks/testing'
|
|
158
|
+
* import { broken } from '@yaks/tracker/report'
|
|
159
|
+
*
|
|
160
|
+
* let [one] = broken(JSON.stringify({
|
|
161
|
+
* message: 'x is undefined',
|
|
162
|
+
* url: 'https://box.test/T-9',
|
|
163
|
+
* mechanism: 'onerror',
|
|
164
|
+
* }))
|
|
165
|
+
* equal([one.request, one.message, one.mechanism], [
|
|
166
|
+
* 'page /T-9',
|
|
167
|
+
* 'x is undefined',
|
|
168
|
+
* 'onerror',
|
|
169
|
+
* ])
|
|
170
|
+
* let [missed] = broken(JSON.stringify({
|
|
171
|
+
* message: 'failed to load img https://box.test/a.webp',
|
|
172
|
+
* url: 'https://box.test/a.webp',
|
|
173
|
+
* page: 'https://box.test/T-9',
|
|
174
|
+
* }))
|
|
175
|
+
* equal([missed.request, missed.file], ['page /T-9', 'https://box.test/a.webp'])
|
|
176
|
+
* let [wrapped] = broken(JSON.stringify({
|
|
177
|
+
* message: 'live client — Dropped: wss://box.test/ws closed (1006)',
|
|
178
|
+
* cause: 'it has not reopened: 7 attempts',
|
|
179
|
+
* mechanism: 'console',
|
|
180
|
+
* }))
|
|
181
|
+
* equal(wrapped.cause, 'it has not reopened: 7 attempts')
|
|
182
|
+
* let [shell] = broken(JSON.stringify({
|
|
183
|
+
* type: 'shell',
|
|
184
|
+
* message: 'no store',
|
|
185
|
+
* page: 'https://yaks.app/manage/ada/operator',
|
|
186
|
+
* tags: { variant: 'yaks-app', update: 'u1', bad: 7 },
|
|
187
|
+
* }))
|
|
188
|
+
* equal([shell.request, shell.tags], [
|
|
189
|
+
* 'shell /manage/ada/operator',
|
|
190
|
+
* { variant: 'yaks-app', update: 'u1' },
|
|
191
|
+
* ])
|
|
192
|
+
* equal(broken(JSON.stringify({ message: '403 /apply', status: 403 })), [])
|
|
193
|
+
* equal(broken(JSON.stringify({ message: '502 /x', status: 502, filed: true })), [])
|
|
194
|
+
* let fetched = (message: string) =>
|
|
195
|
+
* broken(JSON.stringify({ message, url: 'https://box.test/app/' })).length
|
|
196
|
+
* equal([
|
|
197
|
+
* fetched('/app/api/release: Failed to fetch'),
|
|
198
|
+
* fetched('/app/api/release: Load failed'),
|
|
199
|
+
* fetched('/app/api/query: signal timed out'),
|
|
200
|
+
* ], [0, 0, 1])
|
|
201
|
+
* let logged = (asked: string) =>
|
|
202
|
+
* broken(JSON.stringify({
|
|
203
|
+
* message: 'Failed to fetch',
|
|
204
|
+
* mechanism: 'console',
|
|
205
|
+
* breadcrumbs: [{ at: '2026-10-31', category: 'fetch', message: asked }],
|
|
206
|
+
* })).length
|
|
207
|
+
* equal([
|
|
208
|
+
* logged('/app/api/query: Failed to fetch'),
|
|
209
|
+
* logged('200 /app/api/query'),
|
|
210
|
+
* ], [0, 1])
|
|
211
|
+
* let caught = (asked: string) =>
|
|
212
|
+
* broken(JSON.stringify({
|
|
213
|
+
* message: 'app page update: Failed to fetch',
|
|
214
|
+
* mechanism: 'catch',
|
|
215
|
+
* tags: { place: 'app page update' },
|
|
216
|
+
* breadcrumbs: [{ at: '2026-12-02', category: 'fetch', message: asked }],
|
|
217
|
+
* })).length
|
|
218
|
+
* equal([caught('/: Failed to fetch'), caught('200 /api/release')], [0, 1])
|
|
219
|
+
* equal(broken('not json'), [])
|
|
220
|
+
* ```
|
|
221
|
+
*/ export declare let broken: (body: string, refusal?: (answer: string, status: number) => boolean) => Break[];
|
|
222
|
+
/**
|
|
223
|
+
* The breaks a report door was sent ({@link broken}), each carrying the
|
|
224
|
+
* browser that sent them: its user agent, which tells one Safari from another.
|
|
225
|
+
*
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { equal } from '@yaks/testing'
|
|
228
|
+
* import { received } from '@yaks/tracker/report'
|
|
229
|
+
*
|
|
230
|
+
* let [one] = await received(
|
|
231
|
+
* new Request('https://box.test/api/report', {
|
|
232
|
+
* method: 'POST',
|
|
233
|
+
* body: JSON.stringify({ message: 'x is undefined' }),
|
|
234
|
+
* headers: { 'user-agent': 'Mozilla/5.0 Version/18.2 Safari/605.1.15' },
|
|
235
|
+
* }),
|
|
236
|
+
* )
|
|
237
|
+
* equal(one.agent, 'Mozilla/5.0 Version/18.2 Safari/605.1.15')
|
|
238
|
+
* ```
|
|
239
|
+
*/ export declare let received: (request: Request, refusal?: (answer: string, status: number) => boolean) => Promise<Break[]>;
|
|
240
|
+
/** Whether `key` has passed more than `rate` times this minute. A flood
|
|
241
|
+
* guard, not a quota: counted in this process and no further, so something
|
|
242
|
+
* looping cannot write a thousand entities a second, and a key spread over
|
|
243
|
+
* many isolates passing a few extra times is the harmless direction to err.
|
|
244
|
+
*
|
|
245
|
+
* ```ts
|
|
246
|
+
* import { equal } from '@yaks/testing'
|
|
247
|
+
* import { flood } from '@yaks/tracker/report'
|
|
248
|
+
*
|
|
249
|
+
* let over = flood(2)
|
|
250
|
+
* equal([over('a'), over('a'), over('a'), over('b')], [false, false, true, false])
|
|
251
|
+
* ```
|
|
252
|
+
*/ export declare let flood: (rate: number) => (key: string) => boolean;
|
|
253
|
+
/** What a report door ({@link door}) does with the breaks it was sent. */ export type Filing = {
|
|
254
|
+
/** files one break, which carries the release its page ran */ file: (broke: Break, index: number) => unknown;
|
|
255
|
+
/** a no somebody answered on purpose (default {@link meant}) */ refusal?: (answer: string, status: number) => boolean;
|
|
256
|
+
/** whether whoever this door files for has sent too many this minute
|
|
257
|
+
* ({@link flood}) */ flooding?: () => boolean;
|
|
258
|
+
/** the release being served, for a break whose page named none: an older
|
|
259
|
+
* reporter's, or the browser's own Reporting API's */ serving?: () => number | null | undefined | Promise<number | null | undefined>;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* A page's report door: anyone may post to it, since a break belongs to
|
|
263
|
+
* whoever was looking at the page, and asking a stranger to sign in first
|
|
264
|
+
* would lose exactly the breaks nobody sees. What a verified bot's render
|
|
265
|
+
* sends is dropped before the flood ceiling, so a bot never spends the
|
|
266
|
+
* reports a person's page may need; past the ceiling the door says stop; a
|
|
267
|
+
* no somebody meant is no break ({@link broken}); and each break is filed
|
|
268
|
+
* with the release its page ran, else the one serving.
|
|
269
|
+
*
|
|
270
|
+
* ```ts
|
|
271
|
+
* import { equal } from '@yaks/testing'
|
|
272
|
+
* import { door } from '@yaks/tracker/report'
|
|
273
|
+
*
|
|
274
|
+
* let filed: (number | null)[] = []
|
|
275
|
+
* let report = door({ file: (b) => filed.push(b.version), serving: () => 7 })
|
|
276
|
+
* let post = (body: unknown) =>
|
|
277
|
+
* report(new Request('https://box.test/api/report', {
|
|
278
|
+
* method: 'POST',
|
|
279
|
+
* body: JSON.stringify(body),
|
|
280
|
+
* }))
|
|
281
|
+
* equal((await post([{ message: 'a', version: 3 }, { message: 'b' }])).status, 204)
|
|
282
|
+
* await post({ message: '403 /apply', status: 403 })
|
|
283
|
+
* equal(filed, [3, 7])
|
|
284
|
+
* ```
|
|
285
|
+
*/ export declare let door: (filing: Filing) => any;
|
|
286
|
+
/** A break as the error and context a host's telemetry files it with
|
|
287
|
+
* (@yaks/host `Host.report`): thrown in a browser, by the release its page
|
|
288
|
+
* ran, with `tags` beside its own.
|
|
289
|
+
*
|
|
290
|
+
* ```ts
|
|
291
|
+
* import { equal } from '@yaks/testing'
|
|
292
|
+
* import { thrown } from '@yaks/tracker/report'
|
|
293
|
+
*
|
|
294
|
+
* let [error, context] = thrown(
|
|
295
|
+
* { version: 3, request: 'page /', message: 'boom', stack: 'at x' },
|
|
296
|
+
* { user_id: 'ada' },
|
|
297
|
+
* )
|
|
298
|
+
* equal([error.message, error.stack, context.version], ['boom', 'at x', 3])
|
|
299
|
+
* equal(context.tags, {
|
|
300
|
+
* entrypoint: 'browser report',
|
|
301
|
+
* request: 'page /',
|
|
302
|
+
* user_id: 'ada',
|
|
303
|
+
* })
|
|
304
|
+
* ```
|
|
305
|
+
*/ export declare let thrown: (b: Break, tags?: Record<string, string>) => [Error, Partial<Context>];
|
|
306
|
+
export declare let queue: (binding: {
|
|
307
|
+
send: (body: Bundle[]) => Promise<void>;
|
|
308
|
+
}) => Sink;
|
|
309
|
+
export declare let spool: (append: (line: string) => void | Promise<void>) => Sink;
|
|
310
|
+
export declare let post: (url: string, send?: typeof fetch) => Sink;
|
|
311
|
+
export type WindowClock = {
|
|
312
|
+
now: () => number;
|
|
313
|
+
after: (ms: number, run: () => Promise<void>) => () => void;
|
|
314
|
+
};
|
|
315
|
+
export type Coalesced = Sink & {
|
|
316
|
+
flush: () => Promise<void>;
|
|
317
|
+
close: () => Promise<void>;
|
|
318
|
+
};
|
|
319
|
+
/** First samples leave immediately. Each app/fault window keeps only its latest
|
|
320
|
+
* repeat sample, whose hits count reaches every sink and downstream grouping. */ export declare let coalesce: (sink: Sink, options?: {
|
|
321
|
+
window?: number;
|
|
322
|
+
clock?: WindowClock;
|
|
323
|
+
}) => Coalesced;
|
|
324
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sources":["../report.ts"],"names":[],"mappings":"AAGA,cAAc,KAAK,EAAE,MAAM,2BAAgC;AAE3D,SAAe,KAAK,KAAK,EAAE,KAAK,KAAK,qBAAyB;AAE9D,SAAS,OAAO,EAAE,SAAS,qBAAoB;AAM/C,sEAAsE,GACtE,OAAO,YAAI,cACT,KAAK,MAAM,GAAG,IAAI,EAClB,QAAQ,MAAM,GAAG,IAAI;EAClB,cAAc,MAAM;EAAE,aAAa,MAAM;IAAK,SAAS,CAM7C;AAEf,YAAY,QAAQ,MAAM,aAAa,IAAI,GAAG,QAAQ,IAAI;AAC1D,YAAY;EACV,MAAM;EACN,QAAQ;EACR,MAAM,MAAM;EACZ,KAAK,MAAM;EACX,0EAA0E,GAC1E,cAAc,MAAM;EACpB,QAAQ;EACR;gEAC8D,GAC9D,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,cAAc,eAAe;EAC7B,OAAO,OAAO,MAAM,EAAE,OAAO;EAC7B;IACE,SAAS,M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T,GAAG,OACH,OAAM,OAAO,MAAM,EAAE,MAAM,OACzB,OAAO,QAAQ,UAqBlB;AAED,OAAO,YAAI,QACR;EAAW,OAAO,MAAM,aAAa,QAAQ,IAAI;MAAM,KACpC;AACtB,OAAO,YAAI,QACR,SAAS,MAAM,MAAM,KAAK,IAAI,GAAG,QAAQ,IAAI,MAAI,KACb;AACvC,OAAO,YAAI,OACR,KAAK,MAAM,EAAE,cAAa,UAAgB,KAQ1C;AAEH,YAAY;EACV,WAAW,MAAM;EACjB,QAAQ,IAAI,MAAM,EAAE,WAAW,QAAQ,IAAI,YAAY,IAAI;;AAE7D,YAAY,YAAY;EACtB,aAAa,QAAQ,IAAI;EACzB,aAAa,QAAQ,IAAI;;AAU3B;+EAC+E,GAC/E,OAAO,YAAI,WACT,MAAM,MACN;EAAW,SAAS,MAAM;EAAE,QAAQ;MACnC,UAiEF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Bundle, Comp, Plugin } from "@yaks/graph";
|
|
2
|
+
import { type Hook } from "@yaks/graph/plugin";
|
|
3
|
+
/** What a resolver says about a bug: the part of `resolved` it writes. */ export type Explanation = {
|
|
4
|
+
/** what broke and whom it reached, in plain words */ broke?: string;
|
|
5
|
+
/** why it broke */ cause: string;
|
|
6
|
+
/** the full sha of the commit that introduced it, when known */ since?: string;
|
|
7
|
+
/** the full sha of the commit that fixed it */ fix?: string;
|
|
8
|
+
/** when the fix went live */ live?: string;
|
|
9
|
+
/** whether it can happen again, and why */ recur: string;
|
|
10
|
+
};
|
|
11
|
+
/** The explanation a call or a body carries, and nothing else it says. */ export declare let explanation: (args: Record<string, unknown>) => Partial<Explanation>;
|
|
12
|
+
/** What a resolution lacks: its cause and recur, and a full sha for each
|
|
13
|
+
* commit it names. */ export declare let unexplained: (r: Comp) => string[];
|
|
14
|
+
/** The precondition: each bug a batch resolves is explained, counting what
|
|
15
|
+
* its mark already holds. */ export declare let explaining: Hook;
|
|
16
|
+
/** How a resolved bug was fixed, as its resolver explained it: a label and what
|
|
17
|
+
* it says, for each thing said, as a letter, a page and `yak admin errors`
|
|
18
|
+
* read it. What broke falls back to the bug's headline; `commit` writes a
|
|
19
|
+
* sha. Empty for a bug that is not resolved, or that was resolved before
|
|
20
|
+
* explanations were kept. */ export declare let explained: (e: Bundle, commit?: (sha: string) => string) => [string, string][];
|
|
21
|
+
/** The tracker's graph plugin: the precondition that explains resolutions. */ export declare let resolutions: () => Plugin;
|
|
22
|
+
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sources":["../resolution.ts"],"names":[],"mappings":"AASA,cAAc,MAAM,EAAE,IAAI,EAAE,MAAM,2BAAgC;AAElE,SAAS,KAAK,IAAI,kCAA6C;AAK/D,wEAAwE,GACxE,YAAY;EACV,mDAAmD,GACnD,QAAQ,MAAM;EACd,iBAAiB,GACjB,OAAO,MAAM;EACb,8DAA8D,GAC9D,QAAQ,MAAM;EACd,6CAA6C,GAC7C,MAAM,MAAM;EACZ,2BAA2B,GAC3B,OAAO,MAAM;EACb,yCAAyC,GACzC,OAAO,MAAM;;AAOf,wEAAwE,GACxE,OAAO,YAAI,cACT,MAAM,OAAO,MAAM,EAAE,OAAO,MAC3B,QAAQ,aAGR;AAIH;oBACoB,GACpB,OAAO,YAAI,cAAe,GAAG,SAAO,MAAM,GAGzC;AAUD;2BAC2B,GAC3B,OAAO,YAAI,YAAY,KA2BtB;AAMD;;;;2BAI2B,GAC3B,OAAO,YAAI,YACT,GAAG,QACH,UAAS,KAAK,MAAM,KAAK,MAAM,MAC7B,MAAM,EAAE,MAAM,IAYjB;AAED,4EAA4E,GAC5E,OAAO,YAAI,mBAAkB,OAG3B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Read-through doors to the independent tracker Worker. Options are read for
|
|
2
|
+
* every request so the CLI's vault-backed secret can rotate without a restart.
|
|
3
|
+
* Remote bundles are never applied to the box's graph. */ import type { Route } from "@yaks/api";
|
|
4
|
+
import { type Remote } from "./remote.js";
|
|
5
|
+
export type Options = {
|
|
6
|
+
remote?: Remote;
|
|
7
|
+
};
|
|
8
|
+
/** What a read answered: its value and the tag it was read at, or that
|
|
9
|
+
* nothing moved since the tag it was asked with, or the refusal and the
|
|
10
|
+
* status it is: 500 where this side cannot set the read up (./remote.ts
|
|
11
|
+
* `Misconfigured`), 503 where the tracker is out of reach or cannot answer
|
|
12
|
+
* for now, 504 where it did not answer in time, 400 with the tracker's reason
|
|
13
|
+
* where it refused what was asked, and 502 or 404 where it refused otherwise. */ export type Read = {
|
|
14
|
+
ok: true;
|
|
15
|
+
value: unknown;
|
|
16
|
+
tag?: string;
|
|
17
|
+
unchanged?: false;
|
|
18
|
+
} | {
|
|
19
|
+
ok: true;
|
|
20
|
+
value?: undefined;
|
|
21
|
+
tag: string;
|
|
22
|
+
unchanged: true;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
error: string;
|
|
26
|
+
status: number;
|
|
27
|
+
};
|
|
28
|
+
/** One bounded remote read, shared by the HTTP door and graph tools. */ export declare let read: (options: Options, path: 'bugs' | 'trace' | 'traces' | 'changes' | 'scopes', query: URLSearchParams, signal?: AbortSignal, go?: typeof fetch, /** the tag of the answer the caller holds: a remote with nothing moved
|
|
29
|
+
* since answers that, reading nothing */ tag?: string) => Promise<Read>;
|
|
30
|
+
/** Only bug and bounded trace reads leave the box. */ export declare let routes: (host: {
|
|
31
|
+
fetch?: typeof fetch;
|
|
32
|
+
}, options?: Options, go?: typeof fetch) => Route[];
|
|
33
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sources":["../routes.ts"],"names":[],"mappings":"AAAA;;wDAEwD,GACxD,cAAc,KAAK,yBAA8B;AAEjD,SAGE,KAAK,MAAM,sBAGO;AAEpB,YAAY;EAAY,SAAS;;AAGjC;;;;;+EAK+E,GAC/E,YAAY;EACN,IAAI,IAAI;EAAE,OAAO,OAAO;EAAE,MAAM,MAAM;EAAE,YAAY,KAAK;;EACzD,IAAI,IAAI;EAAE,QAAQ,SAAS;EAAE,KAAK,MAAM;EAAE,WAAW,IAAI;;EACzD,IAAI,KAAK;EAAE,OAAO,MAAM;EAAE,QAAQ,MAAM;;AAO9C,sEAAsE,GACtE,OAAO,YAAI,OACT,SAAS,SACT,MAAM,SAAS,UAAU,WAAW,YAAY,UAChD,OAAO,iBACP,SAAS,aACT,YAAW,OACX;yCACuC,GACvC,MAAM,MAAM,KACX,QAAQ,MA+FV;AAED,oDAAoD,GACpD,OAAO,YAAI,SACT;EAAQ,eAAe;GACvB,UAAS,SACT,YAAW,UACV,QAkBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sources":["../script.ts"],"names":[],"mappings":"AAOA;;;;;;CAMC,GACD,OAAO,YAAI,cAAa,QAAQ,MAAM,EACO"}
|