@uptimizr/db 2.0.1 → 2.1.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 (171) hide show
  1. package/AGENTS.md +228 -3
  2. package/README.md +13 -0
  3. package/dist/duckdb/migrations.d.ts.map +1 -1
  4. package/dist/duckdb/migrations.js +169 -0
  5. package/dist/duckdb/migrations.js.map +1 -1
  6. package/dist/duckdb/panelSpecs.d.ts +29 -0
  7. package/dist/duckdb/panelSpecs.d.ts.map +1 -0
  8. package/dist/duckdb/panelSpecs.js +104 -0
  9. package/dist/duckdb/panelSpecs.js.map +1 -0
  10. package/dist/duckdb/projectMetadata.d.ts +43 -0
  11. package/dist/duckdb/projectMetadata.d.ts.map +1 -0
  12. package/dist/duckdb/projectMetadata.js +222 -0
  13. package/dist/duckdb/projectMetadata.js.map +1 -0
  14. package/dist/duckdb/subscriptions.d.ts +45 -0
  15. package/dist/duckdb/subscriptions.d.ts.map +1 -0
  16. package/dist/duckdb/subscriptions.js +202 -0
  17. package/dist/duckdb/subscriptions.js.map +1 -0
  18. package/dist/index.d.ts +18 -4
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +48 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/insights/anomalies.d.ts +213 -0
  23. package/dist/insights/anomalies.d.ts.map +1 -0
  24. package/dist/insights/anomalies.js +340 -0
  25. package/dist/insights/anomalies.js.map +1 -0
  26. package/dist/insights/baseline.d.ts +51 -0
  27. package/dist/insights/baseline.d.ts.map +1 -0
  28. package/dist/insights/baseline.js +48 -0
  29. package/dist/insights/baseline.js.map +1 -0
  30. package/dist/insights/buckets.d.ts +114 -0
  31. package/dist/insights/buckets.d.ts.map +1 -0
  32. package/dist/insights/buckets.js +220 -0
  33. package/dist/insights/buckets.js.map +1 -0
  34. package/dist/insights/changepoint.d.ts +130 -0
  35. package/dist/insights/changepoint.d.ts.map +1 -0
  36. package/dist/insights/changepoint.js +209 -0
  37. package/dist/insights/changepoint.js.map +1 -0
  38. package/dist/insights/evaluate.d.ts +63 -0
  39. package/dist/insights/evaluate.d.ts.map +1 -0
  40. package/dist/insights/evaluate.js +158 -0
  41. package/dist/insights/evaluate.js.map +1 -0
  42. package/dist/insights/health.d.ts +219 -0
  43. package/dist/insights/health.d.ts.map +1 -0
  44. package/dist/insights/health.js +349 -0
  45. package/dist/insights/health.js.map +1 -0
  46. package/dist/insights/index.d.ts +45 -0
  47. package/dist/insights/index.d.ts.map +1 -0
  48. package/dist/insights/index.js +40 -0
  49. package/dist/insights/index.js.map +1 -0
  50. package/dist/insights/measures.d.ts +222 -0
  51. package/dist/insights/measures.d.ts.map +1 -0
  52. package/dist/insights/measures.js +431 -0
  53. package/dist/insights/measures.js.map +1 -0
  54. package/dist/insights/movers.d.ts +123 -0
  55. package/dist/insights/movers.d.ts.map +1 -0
  56. package/dist/insights/movers.js +166 -0
  57. package/dist/insights/movers.js.map +1 -0
  58. package/dist/insights/significance.d.ts +221 -0
  59. package/dist/insights/significance.d.ts.map +1 -0
  60. package/dist/insights/significance.js +531 -0
  61. package/dist/insights/significance.js.map +1 -0
  62. package/dist/insights/stats.d.ts +104 -0
  63. package/dist/insights/stats.d.ts.map +1 -0
  64. package/dist/insights/stats.js +181 -0
  65. package/dist/insights/stats.js.map +1 -0
  66. package/dist/insights/windows.d.ts +95 -0
  67. package/dist/insights/windows.d.ts.map +1 -0
  68. package/dist/insights/windows.js +97 -0
  69. package/dist/insights/windows.js.map +1 -0
  70. package/dist/metadata.d.ts +178 -1
  71. package/dist/metadata.d.ts.map +1 -1
  72. package/dist/metadata.js +80 -0
  73. package/dist/metadata.js.map +1 -1
  74. package/dist/narrative/build.d.ts +78 -0
  75. package/dist/narrative/build.d.ts.map +1 -0
  76. package/dist/narrative/build.js +437 -0
  77. package/dist/narrative/build.js.map +1 -0
  78. package/dist/narrative/index.d.ts +14 -0
  79. package/dist/narrative/index.d.ts.map +1 -0
  80. package/dist/narrative/index.js +13 -0
  81. package/dist/narrative/index.js.map +1 -0
  82. package/dist/narrative/text.d.ts +25 -0
  83. package/dist/narrative/text.d.ts.map +1 -0
  84. package/dist/narrative/text.js +41 -0
  85. package/dist/narrative/text.js.map +1 -0
  86. package/dist/parity/cases.d.ts +3 -0
  87. package/dist/parity/cases.d.ts.map +1 -1
  88. package/dist/parity/cases.js +387 -7
  89. package/dist/parity/cases.js.map +1 -1
  90. package/dist/parity/compare.d.ts +19 -0
  91. package/dist/parity/compare.d.ts.map +1 -1
  92. package/dist/parity/compare.js +19 -0
  93. package/dist/parity/compare.js.map +1 -1
  94. package/dist/parity/fixtures.d.ts.map +1 -1
  95. package/dist/parity/fixtures.js +25 -0
  96. package/dist/parity/fixtures.js.map +1 -1
  97. package/dist/query/aggregations.d.ts +46 -1
  98. package/dist/query/aggregations.d.ts.map +1 -1
  99. package/dist/query/aggregations.js +86 -0
  100. package/dist/query/aggregations.js.map +1 -1
  101. package/dist/query/clickhouseDialect.d.ts.map +1 -1
  102. package/dist/query/clickhouseDialect.js +5 -1
  103. package/dist/query/clickhouseDialect.js.map +1 -1
  104. package/dist/query/customEventVocabulary.d.ts +46 -0
  105. package/dist/query/customEventVocabulary.d.ts.map +1 -0
  106. package/dist/query/customEventVocabulary.js +127 -0
  107. package/dist/query/customEventVocabulary.js.map +1 -0
  108. package/dist/query/dsl/builders.d.ts +38 -0
  109. package/dist/query/dsl/builders.d.ts.map +1 -0
  110. package/dist/query/dsl/builders.js +35 -0
  111. package/dist/query/dsl/builders.js.map +1 -0
  112. package/dist/query/dsl/compare.d.ts +167 -0
  113. package/dist/query/dsl/compare.d.ts.map +1 -0
  114. package/dist/query/dsl/compare.js +358 -0
  115. package/dist/query/dsl/compare.js.map +1 -0
  116. package/dist/query/dsl/compile.d.ts +89 -0
  117. package/dist/query/dsl/compile.d.ts.map +1 -0
  118. package/dist/query/dsl/compile.js +174 -0
  119. package/dist/query/dsl/compile.js.map +1 -0
  120. package/dist/query/dsl/explain.d.ts +115 -0
  121. package/dist/query/dsl/explain.d.ts.map +1 -0
  122. package/dist/query/dsl/explain.js +143 -0
  123. package/dist/query/dsl/explain.js.map +1 -0
  124. package/dist/query/dsl/generic.d.ts +127 -0
  125. package/dist/query/dsl/generic.d.ts.map +1 -0
  126. package/dist/query/dsl/generic.js +323 -0
  127. package/dist/query/dsl/generic.js.map +1 -0
  128. package/dist/query/dsl/index.d.ts +30 -0
  129. package/dist/query/dsl/index.d.ts.map +1 -0
  130. package/dist/query/dsl/index.js +23 -0
  131. package/dist/query/dsl/index.js.map +1 -0
  132. package/dist/query/dsl/order.d.ts +41 -0
  133. package/dist/query/dsl/order.d.ts.map +1 -0
  134. package/dist/query/dsl/order.js +55 -0
  135. package/dist/query/dsl/order.js.map +1 -0
  136. package/dist/query/dsl/significance.d.ts +130 -0
  137. package/dist/query/dsl/significance.d.ts.map +1 -0
  138. package/dist/query/dsl/significance.js +224 -0
  139. package/dist/query/dsl/significance.js.map +1 -0
  140. package/dist/query/index.d.ts +2 -0
  141. package/dist/query/index.d.ts.map +1 -1
  142. package/dist/query/index.js +8 -0
  143. package/dist/query/index.js.map +1 -1
  144. package/dist/query/summary/index.d.ts +4 -2
  145. package/dist/query/summary/index.d.ts.map +1 -1
  146. package/dist/query/summary/index.js +2 -1
  147. package/dist/query/summary/index.js.map +1 -1
  148. package/dist/query/summary/labels.d.ts +101 -0
  149. package/dist/query/summary/labels.d.ts.map +1 -0
  150. package/dist/query/summary/labels.js +261 -0
  151. package/dist/query/summary/labels.js.map +1 -0
  152. package/dist/query/summary/reading.d.ts.map +1 -1
  153. package/dist/query/summary/reading.js +21 -2
  154. package/dist/query/summary/reading.js.map +1 -1
  155. package/dist/query/summary/schema.d.ts +250 -20
  156. package/dist/query/summary/schema.d.ts.map +1 -1
  157. package/dist/query/summary/schema.js +135 -123
  158. package/dist/query/summary/schema.js.map +1 -1
  159. package/dist/query/summary/summarize.d.ts.map +1 -1
  160. package/dist/query/summary/summarize.js +91 -5
  161. package/dist/query/summary/summarize.js.map +1 -1
  162. package/dist/query/summary/types.d.ts +77 -2
  163. package/dist/query/summary/types.d.ts.map +1 -1
  164. package/dist/query/types.d.ts +47 -1
  165. package/dist/query/types.d.ts.map +1 -1
  166. package/dist/subscriptions.d.ts +208 -0
  167. package/dist/subscriptions.d.ts.map +1 -0
  168. package/dist/subscriptions.js +153 -0
  169. package/dist/subscriptions.js.map +1 -0
  170. package/llms.txt +9 -0
  171. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/insights/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,+EAA+E;AAC/E,eAAO,MAAM,YAAY,SAAS,CAAC;AAcnC,4EAA4E;AAC5E,wBAAgB,IAAI,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAM7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY5E;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAE/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAMhF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,GAAE,MAAyB,GACjC,MAAM,GAAG,IAAI,CAKf;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAI7F;AAED,4EAA4E;AAC5E,wBAAgB,GAAG,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAM5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,SAAI,GAAG,MAAM,GAAG,IAAI,CAIvE"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * **Insight statistics** (ADR 0051 §4, design sketch §D).
3
+ *
4
+ * The descriptive statistics the insight primitives are built from, in pure
5
+ * TypeScript: no SQL, no dialect, no I/O. That is the whole design rule of
6
+ * `src/insights/` — the *series* is portable (one dialect-authored bucket query,
7
+ * parity-tested on all four engines) and the *statistics over it* are computed
8
+ * once, here, so DuckDB, ClickHouse, Postgres and SQL Server cannot disagree
9
+ * about what "the median" or "the MAD" means.
10
+ *
11
+ * Every function is total and deterministic:
12
+ *
13
+ * - it takes a plain `readonly number[]` and returns a `number` or `null`;
14
+ * - `null` always means *"not defined for this input"* (an empty series, a
15
+ * single point where a slope needs two), never `0` — a zero mean is a claim
16
+ * about the data, absence is not (the same rule the registry row schemas
17
+ * follow);
18
+ * - non-finite inputs are rejected up front rather than silently poisoning a
19
+ * result with `NaN`.
20
+ *
21
+ * Robust statistics (median, MAD) are used rather than mean/standard deviation
22
+ * wherever a value is ranked or compared, because a scene's bucket series is
23
+ * routinely dominated by one outlier day — a launch, a bot sweep, a broken
24
+ * deploy — and a standard deviation computed across it makes every subsequent
25
+ * change look insignificant.
26
+ */
27
+ // `leastSquaresSlope` is the same statistic the `format=summary` series envelope
28
+ // already reports (design sketch §B.1), so it is reused rather than re-derived:
29
+ // `baseline.slope` and a `format=summary` trend on the same series must agree to
30
+ // the last bit, and the only way to guarantee that is to run the same code.
31
+ export { leastSquaresSlope, trendOf } from "../query/summary/stats.js";
32
+ /**
33
+ * Floor added to the MAD in the denominator of {@link robustZ}.
34
+ *
35
+ * A reference window that never varied has `mad = 0`, and dividing by it would
36
+ * be `Infinity`/`NaN`. Adding a small epsilon keeps the score finite and keeps
37
+ * its *ordering* meaningful: against a perfectly flat reference, any change at
38
+ * all is genuinely unprecedented and should rank above a change of the same size
39
+ * against a noisy one. What stops that from flooding the top of a `movers` list
40
+ * is the `minSample` gate, not the epsilon — a flat-zero series with two events
41
+ * behind it reports `aboveMinSample: false` and is ranked below every gated
42
+ * mover (see `movers.ts`).
43
+ */
44
+ export const ROBUST_Z_EPSILON = 1e-9;
45
+ /** Scale factor making the MAD a consistent estimator of σ for normal data. */
46
+ export const MAD_TO_SIGMA = 1.4826;
47
+ /** The finite values of `values`, in a fresh array. */
48
+ function finite(values) {
49
+ const out = [];
50
+ for (const value of values)
51
+ if (Number.isFinite(value))
52
+ out.push(value);
53
+ return out;
54
+ }
55
+ /** The finite values of `values`, ascending, in a fresh array. */
56
+ function sortedFinite(values) {
57
+ return finite(values).sort((a, b) => a - b);
58
+ }
59
+ /** The arithmetic mean of the finite values; `null` when there are none. */
60
+ export function mean(values) {
61
+ const sample = finite(values);
62
+ if (sample.length === 0)
63
+ return null;
64
+ let total = 0;
65
+ for (const value of sample)
66
+ total += value;
67
+ return total / sample.length;
68
+ }
69
+ /**
70
+ * The `q`-quantile (`0..1`) by **linear interpolation between order statistics**
71
+ * — the "R type 7" / `numpy.percentile` default, and the same definition the
72
+ * dialects' own `quantile()` uses closely enough for the tolerances the parity
73
+ * harness applies.
74
+ *
75
+ * `null` when the series is empty or `q` is outside `0..1`. `q = 0` and `q = 1`
76
+ * return the min and max exactly.
77
+ */
78
+ export function quantile(values, q) {
79
+ if (!Number.isFinite(q) || q < 0 || q > 1)
80
+ return null;
81
+ const sample = sortedFinite(values);
82
+ if (sample.length === 0)
83
+ return null;
84
+ if (sample.length === 1)
85
+ return sample[0];
86
+ const position = q * (sample.length - 1);
87
+ const lower = Math.floor(position);
88
+ const upper = Math.ceil(position);
89
+ const low = sample[lower];
90
+ if (lower === upper)
91
+ return low;
92
+ const high = sample[upper];
93
+ return low + (high - low) * (position - lower);
94
+ }
95
+ /** The median (the 0.5 quantile); `null` on an empty series. */
96
+ export function median(values) {
97
+ return quantile(values, 0.5);
98
+ }
99
+ /**
100
+ * The **median absolute deviation**: `median(|x − median(x)|)`.
101
+ *
102
+ * The robust counterpart of the standard deviation, and the spread every
103
+ * insight primitive compares against. Unlike σ it has a breakdown point of 50%,
104
+ * so a single catastrophic day in a 28-day window widens it by nothing at all
105
+ * instead of tripling it. Reported **unscaled** (raw median deviation, not
106
+ * multiplied by {@link MAD_TO_SIGMA}) because it is used as a denominator for a
107
+ * *ranking* score rather than as a σ estimate; a caller that wants σ multiplies.
108
+ *
109
+ * `null` on an empty series; `0` on a constant one, which is a true statement
110
+ * about the data rather than a missing value.
111
+ */
112
+ export function medianAbsoluteDeviation(values) {
113
+ const sample = finite(values);
114
+ if (sample.length === 0)
115
+ return null;
116
+ const centre = median(sample);
117
+ if (centre == null)
118
+ return null;
119
+ return median(sample.map((value) => Math.abs(value - centre)));
120
+ }
121
+ /**
122
+ * The **robust z-score** of a change: `delta / (mad + ε)`.
123
+ *
124
+ * "How many typical bucket-to-bucket deviations is this move?" — the ranking
125
+ * score for `movers` (design sketch §D). Returns `0` for a zero delta whatever
126
+ * the spread (nothing moved, so nothing is surprising), and `null` when `delta`
127
+ * or `mad` is missing or non-finite, so a metric with no reference series is
128
+ * reported as unranked rather than as a confident zero.
129
+ *
130
+ * A negative `mad` is impossible by construction and is treated as missing.
131
+ */
132
+ export function robustZ(delta, mad, epsilon = ROBUST_Z_EPSILON) {
133
+ if (delta == null || !Number.isFinite(delta))
134
+ return null;
135
+ if (mad == null || !Number.isFinite(mad) || mad < 0)
136
+ return null;
137
+ if (delta === 0)
138
+ return 0;
139
+ return delta / (mad + epsilon);
140
+ }
141
+ /**
142
+ * Relative change from `previous` to `current`, as a ratio (`0.25` is +25%).
143
+ *
144
+ * `null` when either side is missing or when `previous` is zero — a percentage
145
+ * change from nothing is undefined, and reporting `Infinity` (or, worse,
146
+ * `100%`) would be a claim the data does not support. The absolute `delta` is
147
+ * always available alongside it, which is the honest number in that case.
148
+ */
149
+ export function relativeChange(current, previous) {
150
+ if (current == null || previous == null)
151
+ return null;
152
+ if (!Number.isFinite(current) || !Number.isFinite(previous) || previous === 0)
153
+ return null;
154
+ return (current - previous) / Math.abs(previous);
155
+ }
156
+ /** The sum of the finite values; `null` when there are none (never `0`). */
157
+ export function sum(values) {
158
+ const sample = finite(values);
159
+ if (sample.length === 0)
160
+ return null;
161
+ let total = 0;
162
+ for (const value of sample)
163
+ total += value;
164
+ return total;
165
+ }
166
+ /**
167
+ * Round a computed statistic to a fixed number of decimals.
168
+ *
169
+ * Applied at the API edge only. Two engines can differ in the last bits of a
170
+ * floating-point division, and an agent comparing a `z` of `3.0000000000000004`
171
+ * with one of `3` should not see a difference — so every derived number the
172
+ * insight endpoints emit is rounded to a declared precision, which also keeps
173
+ * the JSON (and the tokens an agent pays for it) small.
174
+ */
175
+ export function round(value, decimals = 6) {
176
+ if (value == null || !Number.isFinite(value))
177
+ return null;
178
+ const factor = 10 ** decimals;
179
+ return Math.round(value * factor) / factor;
180
+ }
181
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/insights/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,iFAAiF;AACjF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AAEn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M,CAAC,GAAG,MAAM,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * **Window resolution** for the insight primitives (ADR 0051 §4, sketch §D).
3
+ *
4
+ * Both primitives take a time range the way the rest of the query surface does
5
+ * (`since` / `until`, epoch ms, lower-inclusive and upper-exclusive) and both
6
+ * add a shorthand on top — `window` days for `baseline`, an implicit "previous
7
+ * equal window" reference for `movers`. This module is the single place those
8
+ * shorthands become concrete milliseconds, so the route stays thin and the rules
9
+ * are unit-testable without a server.
10
+ *
11
+ * ## Windows are snapped to bucket boundaries
12
+ *
13
+ * Every resolved bound is floored to the bucket grain. Two reasons, and both are
14
+ * about not lying to the reader:
15
+ *
16
+ * 1. **No partial buckets.** A range ending "now" would otherwise end mid-day,
17
+ * and today's third-of-a-day of traffic would be compared against whole days
18
+ * — which reads as a collapse in every count metric, every morning. Flooring
19
+ * `until` ends the window at the last *complete* bucket instead.
20
+ * 2. **Exact attribution.** A bucket is attributed to the window its **start**
21
+ * falls in. With snapped bounds that is exact: every bucket lies wholly
22
+ * inside one window, so no event is counted twice or split.
23
+ *
24
+ * The snapped bounds are echoed back in the response envelope (`format=table`
25
+ * and `format=summary` both carry `range`), so a caller can always see the
26
+ * window that was actually measured.
27
+ */
28
+ import { type BucketGrain } from "./measures.js";
29
+ /** Milliseconds in a day — the unit `baseline`'s `window` parameter counts in. */
30
+ export declare const DAY_MS = 86400000;
31
+ /** Default `baseline` window, in days. */
32
+ export declare const DEFAULT_BASELINE_WINDOW_DAYS = 28;
33
+ /** Largest `baseline` window a caller may ask for, in days. */
34
+ export declare const MAX_BASELINE_WINDOW_DAYS = 365;
35
+ /** Default `movers` range when the caller gives none, in days. */
36
+ export declare const DEFAULT_MOVERS_RANGE_DAYS = 7;
37
+ /** A resolved, bucket-aligned half-open window `[since, until)`. */
38
+ export interface ResolvedWindow {
39
+ since: number;
40
+ until: number;
41
+ }
42
+ /** Floor an epoch-ms instant to the start of its bucket. */
43
+ export declare function floorToBucket(epochMs: number, bucket: BucketGrain): number;
44
+ /**
45
+ * Resolve `baseline`'s window.
46
+ *
47
+ * `until` defaults to the last complete bucket before `now`; `since` defaults to
48
+ * `window` days before that. An explicit `since` wins over `window` — the
49
+ * shorthand only fills in a bound the caller left out, so the two can never
50
+ * disagree about what was measured.
51
+ *
52
+ * The result is always non-empty: a range whose snapped bounds collapse (a
53
+ * `window` shorter than one bucket, or an inverted pair) is widened to the
54
+ * single bucket ending at `until`, so `baseline` answers with one bucket rather
55
+ * than with nothing.
56
+ */
57
+ export declare function resolveBaselineWindow(opts: {
58
+ since?: number;
59
+ until?: number;
60
+ windowDays?: number;
61
+ bucket: BucketGrain;
62
+ now: number;
63
+ }): ResolvedWindow;
64
+ /**
65
+ * Resolve `movers`' current range and its reference.
66
+ *
67
+ * The range defaults to the last {@link DEFAULT_MOVERS_RANGE_DAYS} complete
68
+ * days. The reference defaults to **the equal window immediately before it**,
69
+ * which is what makes "what changed this week" mean week-on-week without the
70
+ * caller having to do date arithmetic. Either reference bound may be pinned
71
+ * explicitly; `refUntil` alone still implies an equal-length reference ending
72
+ * there.
73
+ */
74
+ export declare function resolveMoversWindows(opts: {
75
+ since?: number;
76
+ until?: number;
77
+ refSince?: number;
78
+ refUntil?: number;
79
+ bucket: BucketGrain;
80
+ now: number;
81
+ }): {
82
+ range: ResolvedWindow;
83
+ reference: ResolvedWindow;
84
+ };
85
+ /**
86
+ * The single range a bucket query has to cover to serve both windows.
87
+ *
88
+ * `movers` issues **one** bucket scan per metric rather than two, and splits the
89
+ * rows in TypeScript — halving the query count, and guaranteeing that both
90
+ * windows saw the same snapshot of the data even if events land mid-request.
91
+ */
92
+ export declare function spanningWindow(a: ResolvedWindow, b: ResolvedWindow): ResolvedWindow;
93
+ /** Whether a bucket start falls inside a half-open window. */
94
+ export declare function inWindow(bucketStart: number, window: ResolvedWindow): boolean;
95
+ //# sourceMappingURL=windows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windows.d.ts","s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E,CAAC,EAAE,cAAc,GAAG,cAAc,CAEnF;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAE7E"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * **Window resolution** for the insight primitives (ADR 0051 §4, sketch §D).
3
+ *
4
+ * Both primitives take a time range the way the rest of the query surface does
5
+ * (`since` / `until`, epoch ms, lower-inclusive and upper-exclusive) and both
6
+ * add a shorthand on top — `window` days for `baseline`, an implicit "previous
7
+ * equal window" reference for `movers`. This module is the single place those
8
+ * shorthands become concrete milliseconds, so the route stays thin and the rules
9
+ * are unit-testable without a server.
10
+ *
11
+ * ## Windows are snapped to bucket boundaries
12
+ *
13
+ * Every resolved bound is floored to the bucket grain. Two reasons, and both are
14
+ * about not lying to the reader:
15
+ *
16
+ * 1. **No partial buckets.** A range ending "now" would otherwise end mid-day,
17
+ * and today's third-of-a-day of traffic would be compared against whole days
18
+ * — which reads as a collapse in every count metric, every morning. Flooring
19
+ * `until` ends the window at the last *complete* bucket instead.
20
+ * 2. **Exact attribution.** A bucket is attributed to the window its **start**
21
+ * falls in. With snapped bounds that is exact: every bucket lies wholly
22
+ * inside one window, so no event is counted twice or split.
23
+ *
24
+ * The snapped bounds are echoed back in the response envelope (`format=table`
25
+ * and `format=summary` both carry `range`), so a caller can always see the
26
+ * window that was actually measured.
27
+ */
28
+ import { BUCKET_SECONDS } from "./measures.js";
29
+ /** Milliseconds in a day — the unit `baseline`'s `window` parameter counts in. */
30
+ export const DAY_MS = 86_400_000;
31
+ /** Default `baseline` window, in days. */
32
+ export const DEFAULT_BASELINE_WINDOW_DAYS = 28;
33
+ /** Largest `baseline` window a caller may ask for, in days. */
34
+ export const MAX_BASELINE_WINDOW_DAYS = 365;
35
+ /** Default `movers` range when the caller gives none, in days. */
36
+ export const DEFAULT_MOVERS_RANGE_DAYS = 7;
37
+ /** Floor an epoch-ms instant to the start of its bucket. */
38
+ export function floorToBucket(epochMs, bucket) {
39
+ const width = BUCKET_SECONDS[bucket] * 1000;
40
+ return Math.floor(epochMs / width) * width;
41
+ }
42
+ /**
43
+ * Resolve `baseline`'s window.
44
+ *
45
+ * `until` defaults to the last complete bucket before `now`; `since` defaults to
46
+ * `window` days before that. An explicit `since` wins over `window` — the
47
+ * shorthand only fills in a bound the caller left out, so the two can never
48
+ * disagree about what was measured.
49
+ *
50
+ * The result is always non-empty: a range whose snapped bounds collapse (a
51
+ * `window` shorter than one bucket, or an inverted pair) is widened to the
52
+ * single bucket ending at `until`, so `baseline` answers with one bucket rather
53
+ * than with nothing.
54
+ */
55
+ export function resolveBaselineWindow(opts) {
56
+ const width = BUCKET_SECONDS[opts.bucket] * 1000;
57
+ const until = floorToBucket(opts.until ?? opts.now, opts.bucket);
58
+ const days = opts.windowDays ?? DEFAULT_BASELINE_WINDOW_DAYS;
59
+ const since = floorToBucket(opts.since ?? until - days * DAY_MS, opts.bucket);
60
+ return since >= until ? { since: until - width, until } : { since, until };
61
+ }
62
+ /**
63
+ * Resolve `movers`' current range and its reference.
64
+ *
65
+ * The range defaults to the last {@link DEFAULT_MOVERS_RANGE_DAYS} complete
66
+ * days. The reference defaults to **the equal window immediately before it**,
67
+ * which is what makes "what changed this week" mean week-on-week without the
68
+ * caller having to do date arithmetic. Either reference bound may be pinned
69
+ * explicitly; `refUntil` alone still implies an equal-length reference ending
70
+ * there.
71
+ */
72
+ export function resolveMoversWindows(opts) {
73
+ const width = BUCKET_SECONDS[opts.bucket] * 1000;
74
+ const until = floorToBucket(opts.until ?? opts.now, opts.bucket);
75
+ const sinceRaw = floorToBucket(opts.since ?? until - DEFAULT_MOVERS_RANGE_DAYS * DAY_MS, opts.bucket);
76
+ const since = sinceRaw >= until ? until - width : sinceRaw;
77
+ const span = until - since;
78
+ const refUntil = floorToBucket(opts.refUntil ?? since, opts.bucket);
79
+ const refSinceRaw = floorToBucket(opts.refSince ?? refUntil - span, opts.bucket);
80
+ const refSince = refSinceRaw >= refUntil ? refUntil - width : refSinceRaw;
81
+ return { range: { since, until }, reference: { since: refSince, until: refUntil } };
82
+ }
83
+ /**
84
+ * The single range a bucket query has to cover to serve both windows.
85
+ *
86
+ * `movers` issues **one** bucket scan per metric rather than two, and splits the
87
+ * rows in TypeScript — halving the query count, and guaranteeing that both
88
+ * windows saw the same snapshot of the data even if events land mid-request.
89
+ */
90
+ export function spanningWindow(a, b) {
91
+ return { since: Math.min(a.since, b.since), until: Math.max(a.until, b.until) };
92
+ }
93
+ /** Whether a bucket start falls inside a half-open window. */
94
+ export function inWindow(bucketStart, window) {
95
+ return bucketStart >= window.since && bucketStart < window.until;
96
+ }
97
+ //# sourceMappingURL=windows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windows.js","sourceRoot":"","sources":["../../src/insights/windows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAC;AAEjE,kFAAkF;AAClF,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC;AAEjC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,kEAAkE;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAQ3C,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,MAAmB;IAChE,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAMrC;IACC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAA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,CAAC,MAAM,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,WAAW,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC;IAE1E,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;AACtF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,CAAiB,EAAE,CAAiB;IACjE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;AAClF,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,QAAQ,CAAC,WAAmB,EAAE,MAAsB;IAClE,OAAO,WAAW,IAAI,MAAM,CAAC,KAAK,IAAI,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;AACnE,CAAC"}
@@ -6,7 +6,7 @@
6
6
  * the scale-tier Postgres metadata clients reuse these, so the type contracts live
7
7
  * once and OSS carries no Postgres dependency.
8
8
  */
9
- import type { Aabb, SceneProxy } from "@uptimizr/schema";
9
+ import type { Aabb, Annotation, AnnotationTargetKind, GlossaryEntry, MetadataAuthorKind, PanelSpecV1, SavedAnalysis, SavedAnalysisQuery, SceneProxy } from "@uptimizr/schema";
10
10
  /** SHA-256 hash of an API key. Only the hash is ever stored (never plaintext). */
11
11
  export declare function hashApiKey(plaintext: string): string;
12
12
  /** Display prefix used to identify a key without revealing it. */
@@ -267,4 +267,181 @@ export interface SceneRepresentationSummary {
267
267
  capturedAt: Date | null;
268
268
  updatedAt: Date;
269
269
  }
270
+ /**
271
+ * The storage projections of `@uptimizr/schema`'s metadata contracts
272
+ * (sketch §E.2). The wire shapes live once, in the schema package; these add
273
+ * only what the *row* knows and the client cannot set — the generated id, who
274
+ * wrote it, and when.
275
+ *
276
+ * Every one of these tables is **project-scoped, bounded and audited**. They
277
+ * are the only writable surface besides ingestion, they never touch the events
278
+ * tables, and the `annotate` capability gates each write (ADR 0051 §7/§9).
279
+ */
280
+ /** Who wrote a metadata row — derived by the collector, never by the payload. */
281
+ export type { MetadataAuthorKind };
282
+ /** What an annotation is about — re-exported so stores need one import. */
283
+ export type { AnnotationTargetKind };
284
+ /**
285
+ * Attribution attached to every metadata write: the kind of author the
286
+ * collector decided on, and the id of the API key that carried the request
287
+ * (never the key or its hash — ADR 0003). `authorKeyId` is null only for rows
288
+ * written by a store's own tooling (seeding, tests).
289
+ */
290
+ export interface MetadataAuthor {
291
+ authorKind: MetadataAuthorKind;
292
+ authorKeyId: string | null;
293
+ }
294
+ /** One stored annotation. */
295
+ export interface AnnotationRecord extends MetadataAuthor {
296
+ id: string;
297
+ projectId: string;
298
+ targetKind: AnnotationTargetKind;
299
+ targetId: string | null;
300
+ /** Start of the annotated period, or null for a standing note. */
301
+ since: Date | null;
302
+ /** End of the annotated period, or null for an open-ended / instant note. */
303
+ until: Date | null;
304
+ text: string;
305
+ createdAt: Date;
306
+ updatedAt: Date;
307
+ }
308
+ /** What a caller supplies to create an annotation; the store fills id and times. */
309
+ export interface CreateAnnotationInput extends MetadataAuthor {
310
+ annotation: Annotation;
311
+ }
312
+ /**
313
+ * Filters for the annotation read path. All optional: the unfiltered call is
314
+ * "the project's recent annotations", which is what the dashboard time axis and
315
+ * the project context document both ask for.
316
+ */
317
+ export interface ListAnnotationsOptions {
318
+ /** Only annotations about this kind of thing. */
319
+ targetKind?: AnnotationTargetKind;
320
+ /** Only annotations about this specific scene/mesh/region/metric. */
321
+ targetId?: string;
322
+ /**
323
+ * Overlap filter, epoch ms: keep annotations whose period intersects
324
+ * `[since, until)`. A standing note (no period) always matches — it is about
325
+ * the project as a whole, not about a moment.
326
+ */
327
+ since?: number;
328
+ until?: number;
329
+ limit?: number;
330
+ }
331
+ /** One stored glossary entry. Identity is `(projectId, term)`. */
332
+ export interface GlossaryEntryRecord {
333
+ projectId: string;
334
+ term: string;
335
+ meaning: string;
336
+ updatedAt: Date;
337
+ }
338
+ /** What a caller supplies to upsert a glossary entry. */
339
+ export interface PutGlossaryEntryInput {
340
+ entry: GlossaryEntry;
341
+ }
342
+ /** One stored saved analysis. */
343
+ export interface SavedAnalysisRecord extends MetadataAuthor {
344
+ id: string;
345
+ projectId: string;
346
+ title: string;
347
+ /** The stored question, parsed back from its JSON column. */
348
+ query: SavedAnalysisQuery;
349
+ conclusion: string | null;
350
+ createdAt: Date;
351
+ }
352
+ /** What a caller supplies to create a saved analysis. */
353
+ export interface CreateSavedAnalysisInput extends MetadataAuthor {
354
+ analysis: SavedAnalysis;
355
+ }
356
+ /** Row cap for a list read, shared by every metadata list endpoint. */
357
+ export interface MetadataListOptions {
358
+ limit?: number;
359
+ }
360
+ /**
361
+ * Per-project row caps (ADR 0051 §5). Metadata is a curated set of notes, so
362
+ * every store refuses the write that would exceed its table's cap rather than
363
+ * silently growing. The numbers live in `@uptimizr/schema`'s `LIMITS` with the
364
+ * rest of the wire bounds; this is the storage-side view of them.
365
+ */
366
+ export declare const METADATA_LIMITS: {
367
+ readonly annotations: 500;
368
+ readonly glossary: 200;
369
+ readonly savedAnalyses: 200;
370
+ readonly panelSpecs: 50;
371
+ };
372
+ /** Which metadata table a {@link MetadataLimitError} is about. */
373
+ export type MetadataTable = keyof typeof METADATA_LIMITS;
374
+ /**
375
+ * Thrown by a store when a write would take a project past the table's cap.
376
+ * The collector maps it to `409 Conflict` — the request was well-formed, the
377
+ * project is simply full, and the caller fixes it by deleting something.
378
+ */
379
+ export declare class MetadataLimitError extends Error {
380
+ readonly table: MetadataTable;
381
+ readonly limit: number;
382
+ constructor(table: MetadataTable, limit: number);
383
+ }
384
+ /**
385
+ * Clamp a caller-supplied `limit` into `[1, max]`, defaulting when absent.
386
+ * Shared by every store so one engine cannot quietly return more rows than
387
+ * another for the same request.
388
+ */
389
+ export declare function clampMetadataLimit(limit: number | undefined, fallback?: number, max?: number): number;
390
+ /**
391
+ * Parse a stored `query` JSON column back into an object. A row written by this
392
+ * collector always parses; a hand-edited or truncated one degrades to `{}`
393
+ * rather than failing the whole listing.
394
+ */
395
+ export declare function parseSavedAnalysisQuery(json: string): SavedAnalysisQuery;
396
+ /**
397
+ * One stored panel spec: what the dashboard draws, who pinned it, and when.
398
+ *
399
+ * The spec itself lives in a single JSON `spec` column, for the same reason a
400
+ * subscription's declaration does: it is a closed document validated at the
401
+ * request boundary (`panelSpecV1Schema` for the shape, `validatePanelSpec` for
402
+ * the vocabulary) and never queried *into*. The columns beside it are exactly
403
+ * what the store must filter (`project_id`), order (`created_at`) and address
404
+ * (`id`) — nothing about the chart or the query is promoted, because no read
405
+ * path asks a database about it.
406
+ */
407
+ export interface PanelSpecRecord extends MetadataAuthor {
408
+ id: string;
409
+ projectId: string;
410
+ /** The stored spec, parsed back from its JSON column. */
411
+ spec: PanelSpecV1;
412
+ createdAt: Date;
413
+ updatedAt: Date;
414
+ }
415
+ /** What a caller supplies to pin a panel; the store fills id and timestamps. */
416
+ export interface CreatePanelSpecInput extends MetadataAuthor {
417
+ spec: PanelSpecV1;
418
+ }
419
+ /**
420
+ * What a caller supplies to replace a pinned panel's spec.
421
+ *
422
+ * Authorship is deliberately **not** part of an update: the row keeps the
423
+ * `authorKind` / `authorKeyId` it was created with. Who pinned a panel is a
424
+ * fact about when it appeared on somebody's dashboard, and an edit does not
425
+ * change that — mirroring how the annotation rows keep their original author
426
+ * across an edit of the note.
427
+ */
428
+ export interface UpdatePanelSpecInput {
429
+ spec: PanelSpecV1;
430
+ }
431
+ /**
432
+ * Parse a stored `spec` JSON column back into a document.
433
+ *
434
+ * Returns `null` rather than a partial object when the text is not a JSON
435
+ * object at all: unlike a saved analysis' opaque `query` — which degrades to
436
+ * `{}` because it is stored but never interpreted — a panel spec is *rendered*,
437
+ * so a row that cannot be one is better skipped than drawn. The listing drops
438
+ * it and the rest of the grid is unaffected, which is the same posture
439
+ * `loadSpecPanels` takes in `@uptimizr/react`.
440
+ *
441
+ * The result is typed as the wire shape but **not** re-validated here: a store
442
+ * is not the boundary, and re-running Zod on every row of every listing would
443
+ * pay the validation cost on the read path for a document the write path
444
+ * already checked. The renderer validates what it is about to draw.
445
+ */
446
+ export declare function parsePanelSpec(json: string): PanelSpecV1 | null;
270
447
  //# sourceMappingURL=metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAIzD,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;AAE7E,kDAAkD;AAClD,eAAO,MAAM,oBAAoB,EAAE,SAAS,gBAAgB,EAKlD,CAAC;AAEX,qEAAqE;AACrE,eAAO,MAAM,4BAA4B,EAAE,SAAS,gBAAgB,EAAuB,CAAC;AAE5F,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,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