@jam-overture/loom 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/cli/templates.js +19 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +30 -3
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.js +102 -7
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +22 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +299 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +65 -0
- package/dist/sdk/definition.js +22 -0
- package/dist/sdk/registry.d.ts +29 -2
- package/dist/sdk/registry.js +63 -1
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +8 -2
- package/dist/signals/broadcast.js +58 -8
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +41 -0
- package/dist/signals/collect.js +88 -7
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/counters.d.ts +46 -0
- package/dist/signals/counters.js +102 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +371 -0
- package/dist/signals/deployment-change.js +268 -0
- package/dist/signals/deployment.d.ts +265 -0
- package/dist/signals/deployment.js +152 -0
- package/dist/signals/door.d.ts +92 -0
- package/dist/signals/door.js +53 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel.d.ts +532 -0
- package/dist/signals/funnel.js +216 -0
- package/dist/signals/health.d.ts +497 -0
- package/dist/signals/health.js +361 -0
- package/dist/signals/index.d.ts +41 -0
- package/dist/signals/index.js +41 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/journal.d.ts +11 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +636 -0
- package/dist/signals/library-reach-change.js +534 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +568 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +105 -14
- package/dist/signals/migrate.d.ts +17 -2
- package/dist/signals/migrate.js +122 -5
- package/dist/signals/notice.d.ts +334 -0
- package/dist/signals/notice.js +228 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/parts.d.ts +344 -0
- package/dist/signals/parts.js +273 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +390 -87
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +141 -0
- package/dist/signals/retention.js +58 -0
- package/dist/signals/rollup.d.ts +67 -3
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +432 -1
- package/dist/signals/schema.js +157 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +848 -0
- package/dist/signals/silences.js +753 -0
- package/dist/signals/tally.d.ts +140 -11
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.js +19 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +80 -0
- package/dist/store/migrate.js +259 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +16 -1
- package/dist/store/postgres.js +59 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +450 -2
- package/dist/store/schema.js +141 -5
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +72 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +23 -0
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +172 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/contracts.d.ts +12 -7
- package/dist/testing/contracts.js +12 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +140 -2
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +98 -19
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
import { DEFAULT_READER_SIGNAL_WINDOW_MS } from "./collect.js";
|
|
3
|
+
import { regionFloorOf } from "./region.js";
|
|
4
|
+
import { READER_SIGNAL_KINDS, } from "./signal.js";
|
|
5
|
+
/**
|
|
6
|
+
* The closed set, for a surface grouping a notice by what its fields are about.
|
|
7
|
+
*
|
|
8
|
+
* **There is deliberately no member for the reader.** Every field of every
|
|
9
|
+
* batch is about one of these five things, which is rule 1 stated as a type
|
|
10
|
+
* rather than as a sentence: a field that needed a sixth member would be a
|
|
11
|
+
* field about a person, and adding one is a decision record and not a
|
|
12
|
+
* judgement call inside a pull request.
|
|
13
|
+
*/
|
|
14
|
+
export const FIELD_SUBJECTS = everyMemberOf()([
|
|
15
|
+
"part",
|
|
16
|
+
"page",
|
|
17
|
+
"observation",
|
|
18
|
+
"page-view",
|
|
19
|
+
"delivery",
|
|
20
|
+
]);
|
|
21
|
+
/** One line per subject, addressed to the reader, for a surface grouping a notice. */
|
|
22
|
+
export const describeFieldSubject = (subject) => {
|
|
23
|
+
switch (subject) {
|
|
24
|
+
case "part":
|
|
25
|
+
return "which part of the page it is about";
|
|
26
|
+
case "page":
|
|
27
|
+
return "which page you were reading, and which version of it";
|
|
28
|
+
case "observation":
|
|
29
|
+
return "what was observed about that part";
|
|
30
|
+
case "page-view":
|
|
31
|
+
return "this one visit to this one page, and nothing outside it";
|
|
32
|
+
case "delivery":
|
|
33
|
+
return "the delivery itself";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const fieldsOf = (table) => Object.entries(table).map(([field, note]) => ({ field, ...note }));
|
|
37
|
+
/** The three fields every kind carries: which kind it is, and which part it is about. */
|
|
38
|
+
const ADDRESS_FIELDS = {
|
|
39
|
+
kind: {
|
|
40
|
+
subject: "observation",
|
|
41
|
+
says: "which of the five kinds of observation this is, and nothing beyond the five",
|
|
42
|
+
},
|
|
43
|
+
nodeId: {
|
|
44
|
+
subject: "part",
|
|
45
|
+
says: "which part of the page this is about, as the page's own name for that part",
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
subject: "part",
|
|
49
|
+
says: "what kind of part it is — a section, a card, a link — and never what it says",
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const AT = {
|
|
53
|
+
subject: "observation",
|
|
54
|
+
says: "when it happened, to the millisecond, by your browser's clock",
|
|
55
|
+
};
|
|
56
|
+
const WITHIN = {
|
|
57
|
+
subject: "part",
|
|
58
|
+
says: "the parts of the page it happened inside, named the same way — so that a press can be counted" +
|
|
59
|
+
" against the section it was in and not only against the button",
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Every kind's fields.
|
|
63
|
+
*
|
|
64
|
+
* Spread from {@link ADDRESS_FIELDS} rather than written five times, with the
|
|
65
|
+
* per-kind annotation doing the checking: the three shared entries plus
|
|
66
|
+
* whatever that kind adds has to be exactly the fields the schema gives it.
|
|
67
|
+
*/
|
|
68
|
+
export const SIGNAL_FIELDS = {
|
|
69
|
+
viewed: { ...ADDRESS_FIELDS, at: AT },
|
|
70
|
+
dwelled: {
|
|
71
|
+
...ADDRESS_FIELDS,
|
|
72
|
+
ms: {
|
|
73
|
+
subject: "observation",
|
|
74
|
+
says: "how long it was on your screen since the last delivery, in milliseconds",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
activated: { ...ADDRESS_FIELDS, at: AT, within: WITHIN },
|
|
78
|
+
disclosed: {
|
|
79
|
+
...ADDRESS_FIELDS,
|
|
80
|
+
open: { subject: "observation", says: "whether it was opened or closed" },
|
|
81
|
+
at: AT,
|
|
82
|
+
within: WITHIN,
|
|
83
|
+
},
|
|
84
|
+
completed: { ...ADDRESS_FIELDS, at: AT, within: WITHIN },
|
|
85
|
+
};
|
|
86
|
+
/** What travels with a delivery, whatever observations are in it. */
|
|
87
|
+
export const DELIVERY_FIELDS = {
|
|
88
|
+
treeId: { subject: "page", says: "which page it was" },
|
|
89
|
+
revision: {
|
|
90
|
+
subject: "page",
|
|
91
|
+
says: "which revision of that page you were served, so that an observation keeps its meaning after the page changes",
|
|
92
|
+
},
|
|
93
|
+
sentAt: { subject: "delivery", says: "when the delivery left your browser" },
|
|
94
|
+
audience: {
|
|
95
|
+
subject: "page",
|
|
96
|
+
says: "which form of the page you were served, by the name the deployment gave that form — a name for a group," +
|
|
97
|
+
" never a name for you, and nothing about why you matched it",
|
|
98
|
+
},
|
|
99
|
+
view: {
|
|
100
|
+
subject: "page-view",
|
|
101
|
+
says: "a random key that ties this delivery to the others from the same visit to this page, so that steps can be" +
|
|
102
|
+
" counted in order; it is tied to nothing else, it is never stored beside the counters, and it is gone when" +
|
|
103
|
+
" the delivery is",
|
|
104
|
+
},
|
|
105
|
+
first: {
|
|
106
|
+
subject: "page-view",
|
|
107
|
+
says: "whether this was the opening delivery of the visit, which is how arrivals are counted once rather than once per delivery",
|
|
108
|
+
},
|
|
109
|
+
signals: { subject: "delivery", says: "the observations themselves" },
|
|
110
|
+
};
|
|
111
|
+
/** The closed set, for a surface listing what is refused. */
|
|
112
|
+
export const REFUSALS = everyMemberOf()([
|
|
113
|
+
"no-identifier",
|
|
114
|
+
"no-fingerprint",
|
|
115
|
+
"no-content",
|
|
116
|
+
"no-pointer-path",
|
|
117
|
+
"no-stitching",
|
|
118
|
+
"no-address",
|
|
119
|
+
]);
|
|
120
|
+
/** One line per refusal, addressed to the reader. */
|
|
121
|
+
export const describeRefusal = (refusal) => {
|
|
122
|
+
switch (refusal) {
|
|
123
|
+
case "no-identifier":
|
|
124
|
+
return "nothing that identifies you: no account, no visitor id, no device id, and nothing derived from your browser to stand in for one";
|
|
125
|
+
case "no-fingerprint":
|
|
126
|
+
return "nothing about your device, your browser or your settings, and so nothing that could be combined into a signature for you";
|
|
127
|
+
case "no-content":
|
|
128
|
+
return "nothing the page showed you and nothing you typed into it: no text, no link target, no form value";
|
|
129
|
+
case "no-pointer-path":
|
|
130
|
+
return "no cursor positions, no scroll trace, and no recording of your session";
|
|
131
|
+
case "no-stitching":
|
|
132
|
+
return "nothing that joins this visit to another one, here or on any other page, so there is no history of you to hold";
|
|
133
|
+
case "no-address":
|
|
134
|
+
return "nothing derived from the address your request arrived from outlives the request, and the address itself is never stored";
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/** One or two sentences about where readers are counted from, addressed to the reader. */
|
|
138
|
+
export const describeRegionNotice = (notice) => notice.floor === null
|
|
139
|
+
? "nothing about where you are is read, not even your country"
|
|
140
|
+
: `the country your request arrives from is counted, and nothing finer than the country; a country is published only once at least ${notice.floor} visits are counted in it, and the address it was read from is never stored`;
|
|
141
|
+
/** What each kind observes, in the reader's own terms rather than the browser's. */
|
|
142
|
+
const OBSERVES = {
|
|
143
|
+
viewed: "that a part of the page came onto your screen",
|
|
144
|
+
dwelled: "how long a part of the page stayed on your screen",
|
|
145
|
+
activated: "that you used a link, a button or a field, and which part of the page it was in",
|
|
146
|
+
disclosed: "that you opened or closed a part of the page",
|
|
147
|
+
completed: "that a form you filled in was submitted — that it left your browser, and never what was in it",
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* A length of time as a notice says it.
|
|
151
|
+
*
|
|
152
|
+
* Minutes above a minute and seconds below it, because the one number here a
|
|
153
|
+
* deployment can set low is the buffer and `collect.ts` floors it at a minute
|
|
154
|
+
* — so a notice reading *0 minutes* would be reporting a window the collector
|
|
155
|
+
* would refuse to run on.
|
|
156
|
+
*/
|
|
157
|
+
const inWords = (ms) => {
|
|
158
|
+
if (ms < 60_000) {
|
|
159
|
+
const seconds = Math.round(ms / 1000);
|
|
160
|
+
return seconds === 1 ? "a second" : `${seconds} seconds`;
|
|
161
|
+
}
|
|
162
|
+
const minutes = Math.round(ms / 60_000);
|
|
163
|
+
return minutes === 1 ? "a minute" : `${minutes} minutes`;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* How long a delivery lives, addressed to the reader.
|
|
167
|
+
*
|
|
168
|
+
* It takes the retention whole, because the age is the half the framework knows
|
|
169
|
+
* and the sweep is the half it cannot promise, and a notice that published the
|
|
170
|
+
* first without the second said *a delivery is kept until it is 60 minutes old*
|
|
171
|
+
* to a reader who had no way of hearing *…or for ever, if nobody runs the
|
|
172
|
+
* sweep*. Where a schedule was stated the sentence ends on a ceiling a reader
|
|
173
|
+
* can hold the deployment to; where none was, it says that in as many words
|
|
174
|
+
* rather than leaving the age to be read as a promise.
|
|
175
|
+
*/
|
|
176
|
+
export const describeBuffer = (retention) => {
|
|
177
|
+
const ripens = `a delivery is kept until it is ${inWords(retention.bufferMs)} old, and this deployment's own sweep is what then counts it into totals and deletes it`;
|
|
178
|
+
const totals = "the totals it leaves behind have nobody in them, and they are kept";
|
|
179
|
+
return retention.sweep.state === "stated"
|
|
180
|
+
? `${ripens}; that sweep runs at least every ${inWords(retention.sweep.everyMs)}, so a delivery is gone within ${inWords(retention.sweep.goneWithinMs)} of arriving — the key tying one visit together exists until then and nowhere else; ${totals}`
|
|
181
|
+
: `${ripens}; this deployment has not said how often that sweep runs, so nothing here promises when a ripe delivery actually goes — the key tying one visit together exists until the sweep takes it and nowhere else; ${totals}`;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* What a stated interval becomes on a notice.
|
|
185
|
+
*
|
|
186
|
+
* The ceiling is derived here and nowhere else, so that a surface cannot print
|
|
187
|
+
* a number that disagrees with the age beside it: it is the ripeness window
|
|
188
|
+
* plus one sweep, which is the same addition the stall check asks a deployment
|
|
189
|
+
* for in one number (0274).
|
|
190
|
+
*
|
|
191
|
+
* **Anything that is not a positive, finite interval is `unstated`** rather
|
|
192
|
+
* than an error or a nought. A nought would publish *gone within 60 minutes* on
|
|
193
|
+
* a deployment that sweeps when somebody remembers to, and this module's one
|
|
194
|
+
* standing rule is that it may overstate what is collected and may never
|
|
195
|
+
* overstate what is deleted.
|
|
196
|
+
*/
|
|
197
|
+
const sweepNoticeOf = (everyMs, bufferMs) => everyMs === undefined || !Number.isFinite(everyMs) || everyMs <= 0
|
|
198
|
+
? { state: "unstated" }
|
|
199
|
+
: { state: "stated", everyMs, goneWithinMs: bufferMs + everyMs };
|
|
200
|
+
/**
|
|
201
|
+
* What a page broadcast with these options reports, as a deployment may publish
|
|
202
|
+
* it.
|
|
203
|
+
*
|
|
204
|
+
* Pure, and allocation-per-call: no store, no clock, no DOM.
|
|
205
|
+
*
|
|
206
|
+
* The kinds come out in the vocabulary's order and each appears once, whatever
|
|
207
|
+
* order a configuration names them in and however often — a notice is read by
|
|
208
|
+
* somebody who did not write the configuration, and *dwelled, dwelled, viewed*
|
|
209
|
+
* is a leak of how the options were typed rather than a fact about the page.
|
|
210
|
+
*/
|
|
211
|
+
export const collectionNoticeOf = (request = {}) => {
|
|
212
|
+
const asked = request.page?.kinds;
|
|
213
|
+
const bufferMs = request.windowMs ?? DEFAULT_READER_SIGNAL_WINDOW_MS;
|
|
214
|
+
const collects = READER_SIGNAL_KINDS.filter((kind) => asked === undefined || asked.includes(kind)).map((kind) => ({
|
|
215
|
+
kind,
|
|
216
|
+
observes: OBSERVES[kind],
|
|
217
|
+
carries: fieldsOf(SIGNAL_FIELDS[kind]),
|
|
218
|
+
}));
|
|
219
|
+
return {
|
|
220
|
+
collects,
|
|
221
|
+
delivery: fieldsOf(DELIVERY_FIELDS),
|
|
222
|
+
refuses: REFUSALS,
|
|
223
|
+
region: { floor: request.region === undefined ? null : regionFloorOf(request.region.floor) },
|
|
224
|
+
bufferMs,
|
|
225
|
+
sweep: sweepNoticeOf(request.sweep?.everyMs, bufferMs),
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=notice.js.map
|