@jam-overture/loom 0.2.0 → 0.3.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.
Files changed (194) hide show
  1. package/dist/audience/compose.d.ts +112 -0
  2. package/dist/audience/compose.js +134 -0
  3. package/dist/audience/memory.d.ts +14 -0
  4. package/dist/audience/memory.js +71 -0
  5. package/dist/audience/overlay-store.d.ts +343 -0
  6. package/dist/audience/overlay-store.js +217 -0
  7. package/dist/audience/rule.d.ts +121 -0
  8. package/dist/audience/rule.js +78 -0
  9. package/dist/cli/index.d.ts +3 -4
  10. package/dist/cli/index.js +3 -4
  11. package/dist/data/adapter.d.ts +9 -1
  12. package/dist/data/adapter.js +2 -0
  13. package/dist/data/resolve.d.ts +1 -1
  14. package/dist/interpretation/anthropic.d.ts +1 -1
  15. package/dist/interpretation/anthropic.js +2 -22
  16. package/dist/interpretation/client.d.ts +1 -1
  17. package/dist/interpretation/materialize.js +67 -22
  18. package/dist/interpretation/openai-compatible.d.ts +36 -0
  19. package/dist/interpretation/openai-compatible.js +79 -0
  20. package/dist/interpretation/status.d.ts +19 -0
  21. package/dist/interpretation/status.js +26 -0
  22. package/dist/live/index.d.ts +73 -0
  23. package/dist/live/index.js +73 -0
  24. package/dist/live/pages.d.ts +187 -0
  25. package/dist/live/pages.js +161 -0
  26. package/dist/live/pull.d.ts +147 -0
  27. package/dist/live/pull.js +398 -0
  28. package/dist/live/pulling.d.ts +79 -0
  29. package/dist/live/pulling.js +117 -0
  30. package/dist/live/window.d.ts +129 -0
  31. package/dist/live/window.js +132 -0
  32. package/dist/render/addressed.d.ts +35 -0
  33. package/dist/render/addressed.js +79 -0
  34. package/dist/render/document-theme.d.ts +70 -0
  35. package/dist/render/document-theme.js +139 -0
  36. package/dist/render/editable.d.ts +15 -1
  37. package/dist/render/editable.js +13 -1
  38. package/dist/render/expected.d.ts +98 -0
  39. package/dist/render/expected.js +88 -0
  40. package/dist/render/index.d.ts +2 -0
  41. package/dist/render/index.js +2 -0
  42. package/dist/render/render.d.ts +11 -0
  43. package/dist/render/render.js +192 -46
  44. package/dist/render/request.d.ts +8 -1
  45. package/dist/render/request.js +1 -0
  46. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  47. package/dist/runtime/auto-apply-ceiling.js +66 -0
  48. package/dist/runtime/gate.js +69 -10
  49. package/dist/runtime/index.d.ts +1 -0
  50. package/dist/runtime/index.js +1 -0
  51. package/dist/runtime/nesting.d.ts +13 -1
  52. package/dist/runtime/nesting.js +41 -24
  53. package/dist/runtime/policy-change.js +8 -2
  54. package/dist/runtime/policy-log.d.ts +5 -5
  55. package/dist/runtime/policy.d.ts +8 -6
  56. package/dist/runtime/policy.js +5 -2
  57. package/dist/runtime/repointing.js +0 -0
  58. package/dist/sdk/definition.d.ts +65 -6
  59. package/dist/sdk/definition.js +44 -0
  60. package/dist/sdk/registry.d.ts +17 -1
  61. package/dist/sdk/registry.js +39 -0
  62. package/dist/signals/acted.contract.d.ts +21 -0
  63. package/dist/signals/acted.contract.js +236 -0
  64. package/dist/signals/acted.d.ts +359 -0
  65. package/dist/signals/acted.js +135 -0
  66. package/dist/signals/agenda.d.ts +585 -0
  67. package/dist/signals/agenda.js +295 -0
  68. package/dist/signals/arrivals.contract.d.ts +21 -0
  69. package/dist/signals/arrivals.contract.js +180 -0
  70. package/dist/signals/arrivals.d.ts +375 -0
  71. package/dist/signals/arrivals.js +254 -0
  72. package/dist/signals/broadcast.d.ts +25 -15
  73. package/dist/signals/broadcast.js +209 -36
  74. package/dist/signals/collect.d.ts +137 -43
  75. package/dist/signals/collect.js +103 -36
  76. package/dist/signals/conversion.d.ts +348 -0
  77. package/dist/signals/conversion.js +235 -0
  78. package/dist/signals/correlated.contract.d.ts +24 -0
  79. package/dist/signals/correlated.contract.js +94 -0
  80. package/dist/signals/counters.d.ts +51 -0
  81. package/dist/signals/counters.js +58 -0
  82. package/dist/signals/deployment-change.d.ts +28 -4
  83. package/dist/signals/deployment-change.js +57 -16
  84. package/dist/signals/deployment.d.ts +18 -5
  85. package/dist/signals/deployment.js +37 -11
  86. package/dist/signals/door.d.ts +34 -12
  87. package/dist/signals/door.js +37 -13
  88. package/dist/signals/expire.d.ts +192 -0
  89. package/dist/signals/expire.js +213 -0
  90. package/dist/signals/frontier.d.ts +268 -0
  91. package/dist/signals/frontier.js +145 -0
  92. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  93. package/dist/signals/funnel-hours.contract.js +221 -0
  94. package/dist/signals/funnel-hours.d.ts +293 -0
  95. package/dist/signals/funnel-hours.js +99 -0
  96. package/dist/signals/funnel.d.ts +60 -0
  97. package/dist/signals/funnel.js +35 -20
  98. package/dist/signals/health.d.ts +201 -4
  99. package/dist/signals/health.js +214 -2
  100. package/dist/signals/index.d.ts +19 -0
  101. package/dist/signals/index.js +19 -0
  102. package/dist/signals/inside.d.ts +190 -0
  103. package/dist/signals/inside.js +263 -0
  104. package/dist/signals/join.d.ts +56 -0
  105. package/dist/signals/join.js +60 -0
  106. package/dist/signals/journal.d.ts +112 -9
  107. package/dist/signals/kept.contract.d.ts +22 -0
  108. package/dist/signals/kept.contract.js +111 -0
  109. package/dist/signals/library-agenda-change.d.ts +324 -0
  110. package/dist/signals/library-agenda-change.js +199 -0
  111. package/dist/signals/library-agenda.d.ts +258 -0
  112. package/dist/signals/library-agenda.js +167 -0
  113. package/dist/signals/library-reach-change.d.ts +10 -0
  114. package/dist/signals/library-reach-change.js +11 -3
  115. package/dist/signals/library-senders-change.d.ts +457 -0
  116. package/dist/signals/library-senders-change.js +367 -0
  117. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  118. package/dist/signals/library-senders-reach-change.js +538 -0
  119. package/dist/signals/library-senders-reach.d.ts +340 -0
  120. package/dist/signals/library-senders-reach.js +252 -0
  121. package/dist/signals/library-senders.d.ts +271 -0
  122. package/dist/signals/library-senders.js +180 -0
  123. package/dist/signals/library-word-reach-change.js +2 -6
  124. package/dist/signals/memory.js +142 -1
  125. package/dist/signals/migrate.d.ts +6 -5
  126. package/dist/signals/migrate.js +150 -6
  127. package/dist/signals/notice.d.ts +88 -33
  128. package/dist/signals/notice.js +38 -16
  129. package/dist/signals/part-pace.d.ts +378 -0
  130. package/dist/signals/part-pace.js +333 -0
  131. package/dist/signals/parts.d.ts +25 -15
  132. package/dist/signals/parts.js +32 -73
  133. package/dist/signals/postgres.js +400 -26
  134. package/dist/signals/region.d.ts +1 -1
  135. package/dist/signals/retention.d.ts +43 -21
  136. package/dist/signals/retention.js +25 -8
  137. package/dist/signals/rhythm.d.ts +302 -0
  138. package/dist/signals/rhythm.js +262 -0
  139. package/dist/signals/rollup.d.ts +127 -1
  140. package/dist/signals/rollup.js +211 -24
  141. package/dist/signals/schema.d.ts +640 -3
  142. package/dist/signals/schema.js +239 -3
  143. package/dist/signals/silences.d.ts +310 -11
  144. package/dist/signals/silences.js +243 -0
  145. package/dist/signals/subtrees.d.ts +123 -0
  146. package/dist/signals/subtrees.js +102 -0
  147. package/dist/signals/tally.d.ts +125 -4
  148. package/dist/signals/unread.d.ts +292 -0
  149. package/dist/signals/unread.js +137 -0
  150. package/dist/signals/window-agenda.d.ts +276 -0
  151. package/dist/signals/window-agenda.js +83 -0
  152. package/dist/signals/window-funnels.d.ts +88 -0
  153. package/dist/signals/window-funnels.js +47 -0
  154. package/dist/store/cache.d.ts +101 -0
  155. package/dist/store/cache.js +149 -0
  156. package/dist/store/history.d.ts +82 -0
  157. package/dist/store/history.js +36 -0
  158. package/dist/store/index.d.ts +11 -0
  159. package/dist/store/index.js +11 -0
  160. package/dist/store/migrate.d.ts +26 -0
  161. package/dist/store/migrate.js +64 -0
  162. package/dist/store/postgres-audience.d.ts +14 -0
  163. package/dist/store/postgres-audience.js +272 -0
  164. package/dist/store/postgres.d.ts +1 -0
  165. package/dist/store/postgres.js +1 -0
  166. package/dist/store/schema.d.ts +312 -0
  167. package/dist/store/schema.js +77 -0
  168. package/dist/store/source.d.ts +57 -1
  169. package/dist/store/source.js +65 -1
  170. package/dist/submit/resolve.d.ts +1 -1
  171. package/dist/telemetry/index.d.ts +1 -0
  172. package/dist/telemetry/index.js +1 -0
  173. package/dist/telemetry/journal.d.ts +32 -0
  174. package/dist/telemetry/memory.js +10 -1
  175. package/dist/telemetry/postgres.js +18 -2
  176. package/dist/telemetry/window.d.ts +135 -0
  177. package/dist/telemetry/window.js +101 -0
  178. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  179. package/dist/testing/audience-overlay-contract.js +354 -0
  180. package/dist/testing/contracts.d.ts +1 -0
  181. package/dist/testing/contracts.js +1 -0
  182. package/dist/testing/journal-contract.js +158 -5
  183. package/dist/theme/contrast.d.ts +19 -14
  184. package/dist/theme/contrast.js +181 -17
  185. package/dist/tree/apply.js +13 -0
  186. package/dist/tree/mutation.d.ts +18 -0
  187. package/dist/tree/mutation.js +24 -12
  188. package/dist/tree/navigation.d.ts +5 -0
  189. package/dist/tree/navigation.js +32 -10
  190. package/dist/tree/outline.d.ts +7 -0
  191. package/dist/tree/outline.js +9 -5
  192. package/package.json +39 -96
  193. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  194. package/dist/runtime/inverse-interpreter.js +0 -56
@@ -0,0 +1,135 @@
1
+ import { arrivalRangeBefore, hourlySeriesOf, readReaderArrivals, } from "./arrivals.js";
2
+ import { ratioOf } from "./ratios.js";
3
+ import { ok } from "../result.js";
4
+ import { DELEGATED_READER_SIGNAL_KINDS } from "./kinds.js";
5
+ export const ACTED_KINDS = DELEGATED_READER_SIGNAL_KINDS;
6
+ /** Whether a signal kind is one this counter holds. */
7
+ export const isActedKind = (kind) => ACTED_KINDS.includes(kind);
8
+ /**
9
+ * The counter a kind is counted in.
10
+ *
11
+ * `disclosed` is openings, which is the same choice the portal's goal figure
12
+ * makes (0350 clause 4) — published here so the rule is spelled once, in the
13
+ * lane that owns the counters, rather than in each surface that reads them.
14
+ *
15
+ * It takes the counters rather than a row, so the one spelling serves a stored
16
+ * hour and a sum of them alike.
17
+ */
18
+ export const actedCountOf = (counts, kind) => {
19
+ switch (kind) {
20
+ case "activated":
21
+ return counts.activations;
22
+ case "disclosed":
23
+ return counts.opens;
24
+ case "completed":
25
+ return counts.completions;
26
+ }
27
+ };
28
+ /**
29
+ * The hours of a range, as the counter answers for them.
30
+ *
31
+ * Rows are summed into their hour, so a scope holding several revisions or
32
+ * parts adds — **occurrences add** (unlike the distinct counts this table
33
+ * deliberately does not hold). A caller wanting one part asks the store for
34
+ * one.
35
+ *
36
+ * Rows outside the range are ignored rather than refused, for the reason
37
+ * `arrivalSeriesOf` ignores them: a wider read is what {@link actedChangeOf}
38
+ * narrows twice.
39
+ */
40
+ export const actedSeriesOf = (stored, range, options = {}) => {
41
+ const kind = options.kind ?? "activated";
42
+ const filled = hourlySeriesOf(stored.hours, stored.begins, range, (row) => actedCountOf(row, kind), options);
43
+ return {
44
+ range,
45
+ kind,
46
+ hours: filled.hours,
47
+ count: filled.total,
48
+ ...(stored.begins === undefined ? {} : { begins: stored.begins }),
49
+ clipped: filled.clipped,
50
+ };
51
+ };
52
+ /**
53
+ * Both figures and the quotient, from one read spanning both periods.
54
+ *
55
+ * The read has to span both, which is what {@link readReaderActed} is for: the
56
+ * obvious caller reads the range on the screen and reports an earlier period
57
+ * that is empty **because it was not read** (0356).
58
+ */
59
+ export const actedChangeOf = (stored, range, options = {}) => {
60
+ const before = arrivalRangeBefore(range);
61
+ const now = actedSeriesOf(stored, range, options);
62
+ const earlier = actedSeriesOf(stored, before, options);
63
+ const was = stored.begins === undefined || stored.begins > before.from ? null : earlier.count;
64
+ return {
65
+ range,
66
+ before,
67
+ kind: now.kind,
68
+ count: now.count,
69
+ was,
70
+ ratio: ratioOf(was, now.count),
71
+ };
72
+ };
73
+ /**
74
+ * The chart, the range's figure and the change on the period before it, in one
75
+ * call against a counter handle.
76
+ *
77
+ * It exists for the reason `readReaderArrivals` does: the composition has a
78
+ * wrong version that type-checks, and it reads as *every press you have is new*
79
+ * on a screen, from a store that holds the right answer. The store handle is
80
+ * narrowed to the one method, so a reading cannot reach a counter it was not
81
+ * asked about.
82
+ */
83
+ export const readReaderActed = async (store, request) => {
84
+ const { range, now, kind, ...narrowing } = request;
85
+ const read = await store.acted({
86
+ ...narrowing,
87
+ from: arrivalRangeBefore(range).from,
88
+ to: range.to,
89
+ });
90
+ if (!read.ok)
91
+ return read;
92
+ const options = {
93
+ ...(now === undefined ? {} : { now }),
94
+ ...(kind === undefined ? {} : { kind }),
95
+ };
96
+ return ok({
97
+ series: actedSeriesOf(read.value, range, options),
98
+ change: actedChangeOf(read.value, range, options),
99
+ });
100
+ };
101
+ /**
102
+ * Per hundred, with the multiplication first: `(count / views) * 100` of seven
103
+ * in two hundred is 3.5000000000000004, and a figure a surface rounds is still
104
+ * a figure a test has to spell that way.
105
+ */
106
+ const per100 = (count, views) => views === null || views === 0 ? null : (count * 100) / views;
107
+ /**
108
+ * The figure, the chart, the denominator and the trend, from two reads of one
109
+ * store over one range.
110
+ *
111
+ * **One range, taken once, passed to both halves.** A caller composing this
112
+ * itself has to get the same range into two reads and the same period before it
113
+ * into two comparisons; the failure is a rate whose numerator and denominator
114
+ * describe different stretches of time, which is a number nobody can tell is
115
+ * wrong by looking at it.
116
+ */
117
+ export const readReaderActedRate = async (store, request) => {
118
+ const acted = await readReaderActed(store, request);
119
+ if (!acted.ok)
120
+ return acted;
121
+ const { kind: _kind, nodeId: _nodeId, ...arrivalRequest } = request;
122
+ const arrivals = await readReaderArrivals(store, arrivalRequest);
123
+ if (!arrivals.ok)
124
+ return arrivals;
125
+ const now = per100(acted.value.change.count, arrivals.value.change.views);
126
+ const was = acted.value.change.was === null
127
+ ? null
128
+ : per100(acted.value.change.was, arrivals.value.change.was);
129
+ return ok({
130
+ acted: acted.value,
131
+ arrivals: arrivals.value,
132
+ rate: { per100: now, was, ratio: ratioOf(was, now) },
133
+ });
134
+ };
135
+ //# sourceMappingURL=acted.js.map