@x12i/countex 1.0.0 → 1.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 +192 -3
- package/dist/backup/export.d.ts +2 -0
- package/dist/backup/export.d.ts.map +1 -1
- package/dist/backup/export.js +2 -0
- package/dist/backup/export.js.map +1 -1
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +190 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/buffer.d.ts +4 -3
- package/dist/core/buffer.d.ts.map +1 -1
- package/dist/core/buffer.js +65 -9
- package/dist/core/buffer.js.map +1 -1
- package/dist/core/countex.d.ts.map +1 -1
- package/dist/core/countex.js +30 -3
- package/dist/core/countex.js.map +1 -1
- package/dist/core/extraction.d.ts +14 -2
- package/dist/core/extraction.d.ts.map +1 -1
- package/dist/core/extraction.js +117 -1
- package/dist/core/extraction.js.map +1 -1
- package/dist/core/mapping.d.ts.map +1 -1
- package/dist/core/mapping.js +44 -1
- package/dist/core/mapping.js.map +1 -1
- package/dist/core/timeframe.d.ts +7 -0
- package/dist/core/timeframe.d.ts.map +1 -1
- package/dist/core/timeframe.js +88 -0
- package/dist/core/timeframe.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/insights/advisors/fanout-health.d.ts +3 -0
- package/dist/insights/advisors/fanout-health.d.ts.map +1 -0
- package/dist/insights/advisors/fanout-health.js +3 -0
- package/dist/insights/advisors/fanout-health.js.map +1 -0
- package/dist/insights/advisors/map-health.d.ts +6 -0
- package/dist/insights/advisors/map-health.d.ts.map +1 -0
- package/dist/insights/advisors/map-health.js +154 -0
- package/dist/insights/advisors/map-health.js.map +1 -0
- package/dist/insights/advisors/resource-advisor.d.ts +4 -0
- package/dist/insights/advisors/resource-advisor.d.ts.map +1 -0
- package/dist/insights/advisors/resource-advisor.js +102 -0
- package/dist/insights/advisors/resource-advisor.js.map +1 -0
- package/dist/insights/advisors/retention-advisor.d.ts +2 -0
- package/dist/insights/advisors/retention-advisor.d.ts.map +1 -0
- package/dist/insights/advisors/retention-advisor.js +6 -0
- package/dist/insights/advisors/retention-advisor.js.map +1 -0
- package/dist/insights/advisors-subpath.d.ts +4 -0
- package/dist/insights/advisors-subpath.d.ts.map +1 -0
- package/dist/insights/advisors-subpath.js +10 -0
- package/dist/insights/advisors-subpath.js.map +1 -0
- package/dist/insights/anomaly/baseline.d.ts +4 -0
- package/dist/insights/anomaly/baseline.d.ts.map +1 -0
- package/dist/insights/anomaly/baseline.js +54 -0
- package/dist/insights/anomaly/baseline.js.map +1 -0
- package/dist/insights/anomaly/detect-anomalies.d.ts +6 -0
- package/dist/insights/anomaly/detect-anomalies.d.ts.map +1 -0
- package/dist/insights/anomaly/detect-anomalies.js +245 -0
- package/dist/insights/anomaly/detect-anomalies.js.map +1 -0
- package/dist/insights/anomaly/ewma.d.ts +2 -0
- package/dist/insights/anomaly/ewma.d.ts.map +1 -0
- package/dist/insights/anomaly/ewma.js +15 -0
- package/dist/insights/anomaly/ewma.js.map +1 -0
- package/dist/insights/anomaly/missing-activity.d.ts +3 -0
- package/dist/insights/anomaly/missing-activity.d.ts.map +1 -0
- package/dist/insights/anomaly/missing-activity.js +8 -0
- package/dist/insights/anomaly/missing-activity.js.map +1 -0
- package/dist/insights/anomaly/robust-zscore.d.ts +2 -0
- package/dist/insights/anomaly/robust-zscore.d.ts.map +1 -0
- package/dist/insights/anomaly/robust-zscore.js +9 -0
- package/dist/insights/anomaly/robust-zscore.js.map +1 -0
- package/dist/insights/anomaly-subpath.d.ts +7 -0
- package/dist/insights/anomaly-subpath.d.ts.map +1 -0
- package/dist/insights/anomaly-subpath.js +20 -0
- package/dist/insights/anomaly-subpath.js.map +1 -0
- package/dist/insights/comparison/compare-periods.d.ts +5 -0
- package/dist/insights/comparison/compare-periods.d.ts.map +1 -0
- package/dist/insights/comparison/compare-periods.js +64 -0
- package/dist/insights/comparison/compare-periods.js.map +1 -0
- package/dist/insights/comparison/growth-rate.d.ts +3 -0
- package/dist/insights/comparison/growth-rate.d.ts.map +1 -0
- package/dist/insights/comparison/growth-rate.js +3 -0
- package/dist/insights/comparison/growth-rate.js.map +1 -0
- package/dist/insights/comparison/moving-average.d.ts +2 -0
- package/dist/insights/comparison/moving-average.d.ts.map +1 -0
- package/dist/insights/comparison/moving-average.js +6 -0
- package/dist/insights/comparison/moving-average.js.map +1 -0
- package/dist/insights/comparison/trend.d.ts +5 -0
- package/dist/insights/comparison/trend.d.ts.map +1 -0
- package/dist/insights/comparison/trend.js +84 -0
- package/dist/insights/comparison/trend.js.map +1 -0
- package/dist/insights/errors.d.ts +25 -0
- package/dist/insights/errors.d.ts.map +1 -0
- package/dist/insights/errors.js +54 -0
- package/dist/insights/errors.js.map +1 -0
- package/dist/insights/forecast/budget.d.ts +2 -0
- package/dist/insights/forecast/budget.d.ts.map +1 -0
- package/dist/insights/forecast/budget.js +6 -0
- package/dist/insights/forecast/budget.js.map +1 -0
- package/dist/insights/forecast/capacity.d.ts +2 -0
- package/dist/insights/forecast/capacity.d.ts.map +1 -0
- package/dist/insights/forecast/capacity.js +3 -0
- package/dist/insights/forecast/capacity.js.map +1 -0
- package/dist/insights/forecast/forecast.d.ts +5 -0
- package/dist/insights/forecast/forecast.d.ts.map +1 -0
- package/dist/insights/forecast/forecast.js +103 -0
- package/dist/insights/forecast/forecast.js.map +1 -0
- package/dist/insights/forecast/retention.d.ts +2 -0
- package/dist/insights/forecast/retention.d.ts.map +1 -0
- package/dist/insights/forecast/retention.js +3 -0
- package/dist/insights/forecast/retention.js.map +1 -0
- package/dist/insights/index.d.ts +4 -0
- package/dist/insights/index.d.ts.map +1 -0
- package/dist/insights/index.js +23 -0
- package/dist/insights/index.js.map +1 -0
- package/dist/insights/insights-client.d.ts +33 -0
- package/dist/insights/insights-client.d.ts.map +1 -0
- package/dist/insights/insights-client.js +344 -0
- package/dist/insights/insights-client.js.map +1 -0
- package/dist/insights/llm-subpath.d.ts +4 -0
- package/dist/insights/llm-subpath.d.ts.map +1 -0
- package/dist/insights/llm-subpath.js +10 -0
- package/dist/insights/llm-subpath.js.map +1 -0
- package/dist/insights/optimization/cost-optimizer.d.ts +6 -0
- package/dist/insights/optimization/cost-optimizer.d.ts.map +1 -0
- package/dist/insights/optimization/cost-optimizer.js +98 -0
- package/dist/insights/optimization/cost-optimizer.js.map +1 -0
- package/dist/insights/optimization/latency-optimizer.d.ts +3 -0
- package/dist/insights/optimization/latency-optimizer.d.ts.map +1 -0
- package/dist/insights/optimization/latency-optimizer.js +3 -0
- package/dist/insights/optimization/latency-optimizer.js.map +1 -0
- package/dist/insights/optimization/threshold-advisor.d.ts +2 -0
- package/dist/insights/optimization/threshold-advisor.d.ts.map +1 -0
- package/dist/insights/optimization/threshold-advisor.js +3 -0
- package/dist/insights/optimization/threshold-advisor.js.map +1 -0
- package/dist/insights/optimization/token-optimizer.d.ts +4 -0
- package/dist/insights/optimization/token-optimizer.d.ts.map +1 -0
- package/dist/insights/optimization/token-optimizer.js +133 -0
- package/dist/insights/optimization/token-optimizer.js.map +1 -0
- package/dist/insights/ranking/contribution.d.ts +2 -0
- package/dist/insights/ranking/contribution.d.ts.map +1 -0
- package/dist/insights/ranking/contribution.js +6 -0
- package/dist/insights/ranking/contribution.js.map +1 -0
- package/dist/insights/ranking/helpers.d.ts +22 -0
- package/dist/insights/ranking/helpers.d.ts.map +1 -0
- package/dist/insights/ranking/helpers.js +88 -0
- package/dist/insights/ranking/helpers.js.map +1 -0
- package/dist/insights/ranking/pareto.d.ts +2 -0
- package/dist/insights/ranking/pareto.d.ts.map +1 -0
- package/dist/insights/ranking/pareto.js +6 -0
- package/dist/insights/ranking/pareto.js.map +1 -0
- package/dist/insights/ranking/slices.d.ts +2 -0
- package/dist/insights/ranking/slices.d.ts.map +1 -0
- package/dist/insights/ranking/slices.js +6 -0
- package/dist/insights/ranking/slices.js.map +1 -0
- package/dist/insights/ranking/top-bottom.d.ts +2 -0
- package/dist/insights/ranking/top-bottom.d.ts.map +1 -0
- package/dist/insights/ranking/top-bottom.js +7 -0
- package/dist/insights/ranking/top-bottom.js.map +1 -0
- package/dist/insights/recommendations/evidence.d.ts +2 -0
- package/dist/insights/recommendations/evidence.d.ts.map +1 -0
- package/dist/insights/recommendations/evidence.js +3 -0
- package/dist/insights/recommendations/evidence.js.map +1 -0
- package/dist/insights/recommendations/recommendation.d.ts +6 -0
- package/dist/insights/recommendations/recommendation.d.ts.map +1 -0
- package/dist/insights/recommendations/recommendation.js +25 -0
- package/dist/insights/recommendations/recommendation.js.map +1 -0
- package/dist/insights/recommendations/severity.d.ts +2 -0
- package/dist/insights/recommendations/severity.d.ts.map +1 -0
- package/dist/insights/recommendations/severity.js +3 -0
- package/dist/insights/recommendations/severity.js.map +1 -0
- package/dist/insights/rules/evaluate-rules.d.ts +5 -0
- package/dist/insights/rules/evaluate-rules.d.ts.map +1 -0
- package/dist/insights/rules/evaluate-rules.js +156 -0
- package/dist/insights/rules/evaluate-rules.js.map +1 -0
- package/dist/insights/types.d.ts +405 -0
- package/dist/insights/types.d.ts.map +1 -0
- package/dist/insights/types.js +3 -0
- package/dist/insights/types.js.map +1 -0
- package/dist/insights/utils/formatting.d.ts +4 -0
- package/dist/insights/utils/formatting.d.ts.map +1 -0
- package/dist/insights/utils/formatting.js +21 -0
- package/dist/insights/utils/formatting.js.map +1 -0
- package/dist/insights/utils/grouping.d.ts +2 -0
- package/dist/insights/utils/grouping.d.ts.map +1 -0
- package/dist/insights/utils/grouping.js +8 -0
- package/dist/insights/utils/grouping.js.map +1 -0
- package/dist/insights/utils/query-builder.d.ts +21 -0
- package/dist/insights/utils/query-builder.d.ts.map +1 -0
- package/dist/insights/utils/query-builder.js +107 -0
- package/dist/insights/utils/query-builder.js.map +1 -0
- package/dist/insights/utils/row-value.d.ts +5 -0
- package/dist/insights/utils/row-value.d.ts.map +1 -0
- package/dist/insights/utils/row-value.js +36 -0
- package/dist/insights/utils/row-value.js.map +1 -0
- package/dist/insights/utils/stats.d.ts +28 -0
- package/dist/insights/utils/stats.d.ts.map +1 -0
- package/dist/insights/utils/stats.js +125 -0
- package/dist/insights/utils/stats.js.map +1 -0
- package/dist/query/formatter.d.ts.map +1 -1
- package/dist/query/formatter.js +202 -24
- package/dist/query/formatter.js.map +1 -1
- package/dist/query/planner.d.ts +10 -2
- package/dist/query/planner.d.ts.map +1 -1
- package/dist/query/planner.js +39 -2
- package/dist/query/planner.js.map +1 -1
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js +78 -4
- package/dist/storage/memory.js.map +1 -1
- package/dist/storage/mongo.d.ts.map +1 -1
- package/dist/storage/mongo.js +61 -16
- package/dist/storage/mongo.js.map +1 -1
- package/dist/storage/redis.d.ts +6 -7
- package/dist/storage/redis.d.ts.map +1 -1
- package/dist/storage/redis.js +108 -39
- package/dist/storage/redis.js.map +1 -1
- package/dist/types/index.d.ts +88 -4
- package/dist/types/index.d.ts.map +1 -1
- package/docs/INSIGHTS.md +59 -0
- package/docs/INSIGHTS_ANOMALY_DETECTION.md +33 -0
- package/docs/INSIGHTS_LLM_COST_AND_TOKENS.md +26 -0
- package/docs/INSIGHTS_RESOURCE_ADVISOR.md +31 -0
- package/docs/guides/README.md +29 -0
- package/docs/guides/adapter-memory.md +48 -0
- package/docs/guides/adapter-mongo.md +50 -0
- package/docs/guides/adapter-redis.md +47 -0
- package/docs/guides/backup-export.md +39 -0
- package/docs/guides/cardinality.md +50 -0
- package/docs/guides/cli.md +45 -0
- package/docs/guides/client-events.md +49 -0
- package/docs/guides/counter-maps.md +116 -0
- package/docs/guides/idempotency.md +39 -0
- package/docs/guides/ingestion-and-flush.md +67 -0
- package/docs/guides/insights-advisors-and-optimization.md +39 -0
- package/docs/guides/insights-anomalies-and-rules.md +48 -0
- package/docs/guides/insights-comparison-and-trends.md +47 -0
- package/docs/guides/insights-forecasting-and-budget.md +61 -0
- package/docs/guides/insights-overview.md +76 -0
- package/docs/guides/insights-ranking.md +81 -0
- package/docs/guides/measures.md +67 -0
- package/docs/guides/querying.md +79 -0
- package/docs/guides/timeframes-and-bucketing.md +55 -0
- package/docs/internals/README.md +20 -0
- package/docs/internals/internal-architecture-overview.md +65 -0
- package/docs/internals/internal-backup-stream.md +23 -0
- package/docs/internals/internal-buffer-merge-and-flush.md +51 -0
- package/docs/internals/internal-cardinality.md +30 -0
- package/docs/internals/internal-idempotency.md +36 -0
- package/docs/internals/internal-ingest-pipeline.md +52 -0
- package/docs/internals/internal-insights-layer.md +36 -0
- package/docs/internals/internal-mapping-validation-and-extraction.md +59 -0
- package/docs/internals/internal-measures-and-scales.md +35 -0
- package/docs/internals/internal-query-path.md +46 -0
- package/docs/internals/internal-storage-memory.md +13 -0
- package/docs/internals/internal-storage-mongo.md +24 -0
- package/docs/internals/internal-storage-redis.md +31 -0
- package/docs/internals/internal-timeframe-bucketing.md +33 -0
- package/package.json +45 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Generic sparse counter matrices for JSON events.
|
|
4
4
|
> Dynamic counting, aggregation, and retrieval from mapped JSON inputs.
|
|
5
5
|
|
|
6
|
-
`@x12i/countex` is a source-agnostic counting engine. You give it any JSON event, a declarative mapping config, and storage adapters; it projects events into sparse counter cells, batches deltas locally, and persists them atomically to a durable store (MongoDB) and a hot cache (Redis).
|
|
6
|
+
`@x12i/countex` is a **generic mapped-event counter**: a source-agnostic counting engine. You give it any JSON event, a declarative mapping config, and storage adapters; it projects events into sparse counter cells, batches deltas locally, and persists them atomically to a durable store (MongoDB) and a hot cache (Redis).
|
|
7
7
|
|
|
8
8
|
It does **not** know about users, organizations, documents, labels, or events. It only knows generic primitives: **scope, subject, metric, dimensions, timeframe, delta**. Whatever your domain calls those things — Countex doesn't care.
|
|
9
9
|
|
|
@@ -34,6 +34,28 @@ These guides are included in the published tarball under `docs/` and exposed as
|
|
|
34
34
|
|-------|-----------------|------|
|
|
35
35
|
| Release & production deployment | `@x12i/countex/docs/deployment` | `docs/DEPLOYMENT.md` |
|
|
36
36
|
| Tutorial — install → map → ingest → query | `@x12i/countex/docs/end-to-end-example` | `docs/END_TO_END_EXAMPLE.md` |
|
|
37
|
+
| Feature guides index | `@x12i/countex/docs/guides` | `docs/guides/README.md` |
|
|
38
|
+
| Counter maps | `@x12i/countex/docs/guides/counter-maps` | `docs/guides/counter-maps.md` |
|
|
39
|
+
| Ingestion & flush | `@x12i/countex/docs/guides/ingestion-and-flush` | `docs/guides/ingestion-and-flush.md` |
|
|
40
|
+
| Timeframes | `@x12i/countex/docs/guides/timeframes-and-bucketing` | `docs/guides/timeframes-and-bucketing.md` |
|
|
41
|
+
| Measures | `@x12i/countex/docs/guides/measures` | `docs/guides/measures.md` |
|
|
42
|
+
| Querying | `@x12i/countex/docs/guides/querying` | `docs/guides/querying.md` |
|
|
43
|
+
| Memory adapters | `@x12i/countex/docs/guides/adapter-memory` | `docs/guides/adapter-memory.md` |
|
|
44
|
+
| Mongo durable | `@x12i/countex/docs/guides/adapter-mongo` | `docs/guides/adapter-mongo.md` |
|
|
45
|
+
| Redis cache | `@x12i/countex/docs/guides/adapter-redis` | `docs/guides/adapter-redis.md` |
|
|
46
|
+
| Cardinality | `@x12i/countex/docs/guides/cardinality` | `docs/guides/cardinality.md` |
|
|
47
|
+
| Idempotency | `@x12i/countex/docs/guides/idempotency` | `docs/guides/idempotency.md` |
|
|
48
|
+
| Backup export | `@x12i/countex/docs/guides/backup-export` | `docs/guides/backup-export.md` |
|
|
49
|
+
| Client events | `@x12i/countex/docs/guides/client-events` | `docs/guides/client-events.md` |
|
|
50
|
+
| Insights overview | `@x12i/countex/docs/guides/insights-overview` | `docs/guides/insights-overview.md` |
|
|
51
|
+
| Insights ranking | `@x12i/countex/docs/guides/insights-ranking` | `docs/guides/insights-ranking.md` |
|
|
52
|
+
| Insights comparison & trends | `@x12i/countex/docs/guides/insights-comparison-and-trends` | `docs/guides/insights-comparison-and-trends.md` |
|
|
53
|
+
| Insights anomalies & rules | `@x12i/countex/docs/guides/insights-anomalies-and-rules` | `docs/guides/insights-anomalies-and-rules.md` |
|
|
54
|
+
| Insights forecasting & budget | `@x12i/countex/docs/guides/insights-forecasting-and-budget` | `docs/guides/insights-forecasting-and-budget.md` |
|
|
55
|
+
| Insights advisors | `@x12i/countex/docs/guides/insights-advisors-and-optimization` | `docs/guides/insights-advisors-and-optimization.md` |
|
|
56
|
+
| CLI | `@x12i/countex/docs/guides/cli` | `docs/guides/cli.md` |
|
|
57
|
+
|
|
58
|
+
**Internals** (how the engine works — diagrams and traces) live under `docs/internals/` in the tarball; browse [`docs/internals/README.md`](docs/internals/README.md).
|
|
37
59
|
|
|
38
60
|
After install: `node_modules/@x12i/countex/docs/`.
|
|
39
61
|
|
|
@@ -53,7 +75,7 @@ Each event can produce one or many cell increments. A counter increment is defin
|
|
|
53
75
|
|
|
54
76
|
- **scope** — your tenant / org / account boundary
|
|
55
77
|
- **counterId** — which counter family this is (e.g. `access_by_subject_metric`)
|
|
56
|
-
- **timeframe** — `day` / `week` / `month` / `quarter` / `year` / `all`
|
|
78
|
+
- **timeframe** — `minute` / `hour` / `day` / `week` / `month` / `quarter` / `year` / `all`
|
|
57
79
|
- **subject** — the thing being counted against (e.g. an actor or a target)
|
|
58
80
|
- **metric** — the count category / label
|
|
59
81
|
- **dimensions** — arbitrary additional breakdowns
|
|
@@ -61,6 +83,125 @@ Each event can produce one or many cell increments. A counter increment is defin
|
|
|
61
83
|
|
|
62
84
|
Countex buffers increments locally, flushes atomic deltas to durable + cache, and serves queries from cache with durable fallback.
|
|
63
85
|
|
|
86
|
+
### Measures and rates
|
|
87
|
+
|
|
88
|
+
Maps may declare optional **`measures`**: named numeric fields per event (cost, tokens, latency, …) with aggregations `sum`, `count`, `min`, and `max`. **`avg`** is computed at query time when both `sum` and `count` exist on the measure. Use **`scale`** on a measure for fixed-point storage (e.g. cents). Extracted values attach to each fan-out increment the same way as **`delta`** (see RFC-style docs for fan-out semantics).
|
|
89
|
+
|
|
90
|
+
Queries accept **`measures`** (explicit list or `"*"`), **`orderBy`** on a measure aggregation, and optional **`rate`** (count or a measure’s sum divided by elapsed time in the queried window; for `format: "timeseries"`, per bucket). **`rate`** is invalid for timeframe **`all`**.
|
|
91
|
+
|
|
92
|
+
**Redis cache** stores **sum** and **count** per measure only; **min** / **max** are durable-backed. If a query needs min/max (including `orderBy` on them, or requesting measures that maintain min/max when using `"*"`), the planner reads from **durable** first so cache cannot drift.
|
|
93
|
+
|
|
94
|
+
**`bucketRange`** caps at **10,000** buckets; at **`minute`** resolution that is about **6.94 days** — keep queries within that bound or narrow the range.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## What kinds of events Countex is for
|
|
99
|
+
|
|
100
|
+
Countex is not tied to one event source or domain. It is a **generic mapped-event counter**: any JSON-like input stream where useful aggregates can be produced from paths in the event.
|
|
101
|
+
|
|
102
|
+
Typical sources include:
|
|
103
|
+
|
|
104
|
+
| Source family | Examples | Common Countex projection |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| Audit and security logs | Microsoft 365 audit logs, Google Workspace logs, Okta logs, cloud audit logs | actor/resource/action/situation/severity |
|
|
107
|
+
| Product and user activity | Woopra, Segment, PostHog-style events, application activity logs | user/account/feature/event/page/funnel |
|
|
108
|
+
| Processing and workflow activity | ETL runs, background jobs, agent graphs, workflow engines, queue processors | job/task/node/status/error/runtime |
|
|
109
|
+
| LLM and AI service usage | Model gateway logs, OpenAI/Anthropic calls, internal LLM services | app/user/model/provider/tokens/cost/latency/result |
|
|
110
|
+
| Business/domain events | CRM, support tickets, payments, commerce, lifecycle events | customer/object/state/category/outcome |
|
|
111
|
+
|
|
112
|
+
Countex only needs a map. The map tells Countex where to find:
|
|
113
|
+
|
|
114
|
+
- the scope boundary
|
|
115
|
+
- the event time
|
|
116
|
+
- the subjects
|
|
117
|
+
- the metrics
|
|
118
|
+
- the dimensions
|
|
119
|
+
- the delta/count
|
|
120
|
+
- optional numeric measures such as cost, tokens, latency, or duration
|
|
121
|
+
|
|
122
|
+
The original event can come from a log, webhook, queue message, analytics event, system activity, processing trace, or generated test fixture. Countex does not care about the event source as long as the map can project it into generic counter primitives.
|
|
123
|
+
|
|
124
|
+
### Audit-log style event
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"tenant": { "id": "org_123" },
|
|
129
|
+
"event": {
|
|
130
|
+
"id": "audit_001",
|
|
131
|
+
"createdAt": "2026-05-08T14:33:00Z",
|
|
132
|
+
"operation": "FileAccessed",
|
|
133
|
+
"situation": "external"
|
|
134
|
+
},
|
|
135
|
+
"actor": { "id": "user_42", "type": "user" },
|
|
136
|
+
"resource": { "id": "file_99", "type": "document" },
|
|
137
|
+
"labels": ["PII", "Financial"]
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Counts:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
actor/resource × label × operation/situation/resourceType × timeframe
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Product-activity style event
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"account": { "id": "acct_123" },
|
|
152
|
+
"user": { "id": "user_42" },
|
|
153
|
+
"event": {
|
|
154
|
+
"name": "dashboard_viewed",
|
|
155
|
+
"createdAt": "2026-05-08T14:33:00Z"
|
|
156
|
+
},
|
|
157
|
+
"product": {
|
|
158
|
+
"feature": "risk_dashboard",
|
|
159
|
+
"plan": "enterprise"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Counts:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
user/account × activity metric × feature/plan × timeframe
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### LLM-processing style event
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"scope": { "id": "org_123" },
|
|
175
|
+
"request": {
|
|
176
|
+
"id": "llm_req_001",
|
|
177
|
+
"createdAt": "2026-05-08T14:33:00Z",
|
|
178
|
+
"status": "success"
|
|
179
|
+
},
|
|
180
|
+
"app": { "id": "graphs-studio" },
|
|
181
|
+
"model": {
|
|
182
|
+
"provider": "openai",
|
|
183
|
+
"name": "gpt-4.1"
|
|
184
|
+
},
|
|
185
|
+
"usage": {
|
|
186
|
+
"inputTokens": 1200,
|
|
187
|
+
"outputTokens": 350,
|
|
188
|
+
"costCents": 4,
|
|
189
|
+
"latencyMs": 1800
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Counts/measures:
|
|
195
|
+
|
|
196
|
+
```text
|
|
197
|
+
app/model/provider/status × timeframe
|
|
198
|
+
sum inputTokens
|
|
199
|
+
sum outputTokens
|
|
200
|
+
sum costCents
|
|
201
|
+
avg latencyMs
|
|
202
|
+
count requests
|
|
203
|
+
```
|
|
204
|
+
|
|
64
205
|
---
|
|
65
206
|
|
|
66
207
|
## Quick start
|
|
@@ -351,11 +492,59 @@ Result:
|
|
|
351
492
|
```
|
|
352
493
|
|
|
353
494
|
`groupBy` accepts:
|
|
354
|
-
- `"subject"`, `"metric"`, `"timeframeKey"`
|
|
495
|
+
- `"subject"`, `"subjectType"`, `"metric"`, `"timeframeKey"`
|
|
355
496
|
- `"dim:NAME"` — group by a dimension value
|
|
356
497
|
|
|
357
498
|
---
|
|
358
499
|
|
|
500
|
+
## Insights and advisors
|
|
501
|
+
|
|
502
|
+
Countex can optionally analyze stored counters and measures to produce higher-level insights. The core engine answers “what happened?” by maintaining sparse aggregate cells. The insights layer answers “what matters?” by ranking, comparing periods, detecting anomalies, forecasting usage, and emitting evidence-backed recommendations.
|
|
503
|
+
|
|
504
|
+
Typical uses:
|
|
505
|
+
|
|
506
|
+
- Top / bottom N subjects, metrics, or dimensions; top/bottom percent of groups; Pareto and contribution views
|
|
507
|
+
- Period-over-period comparison and simple trends on timeseries
|
|
508
|
+
- Explainable anomaly detection (robust z-score, thresholds, missing activity)
|
|
509
|
+
- Rule evaluation with normalized recommendations
|
|
510
|
+
- Cost / budget / max-token style advisors (generic measures only — no domain lock-in)
|
|
511
|
+
- Map and cardinality health when you pass the counter map into `createCountexInsights`
|
|
512
|
+
- Resource projections from observed cells via `estimateResourcesFromActuals` (requires the durable adapter reference)
|
|
513
|
+
|
|
514
|
+
**Safety:** Insights honor `maxBuckets` (aligned with the core 10,000 bucket cap) and `maxGroups`. Grouped queries load all matching cells for the timeframe before aggregation, so narrow filters when possible.
|
|
515
|
+
|
|
516
|
+
**Sparse counters:** Bottom-N style rankings omit zero rows by default; Countex only stores cells that received increments.
|
|
517
|
+
|
|
518
|
+
```ts
|
|
519
|
+
import { createCountexInsights } from "@x12i/countex/insights";
|
|
520
|
+
|
|
521
|
+
const insights = createCountexInsights({
|
|
522
|
+
countex,
|
|
523
|
+
durable, // optional; required for estimateResourcesFromActuals → streamCells
|
|
524
|
+
mapsByCounterId: new Map(maps.map((m) => [m.counterId, m])),
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
const topCostDrivers = await insights.topPercent({
|
|
528
|
+
scope: "org_123",
|
|
529
|
+
counterId: "llm_usage",
|
|
530
|
+
timeframe: { type: "month", from: "2026-05", to: "2026-05" },
|
|
531
|
+
groupBy: ["subject"],
|
|
532
|
+
measure: "costMicros.sum",
|
|
533
|
+
percent: 20,
|
|
534
|
+
});
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Further reading: [docs/INSIGHTS.md](docs/INSIGHTS.md), [docs/INSIGHTS_ANOMALY_DETECTION.md](docs/INSIGHTS_ANOMALY_DETECTION.md), [docs/INSIGHTS_LLM_COST_AND_TOKENS.md](docs/INSIGHTS_LLM_COST_AND_TOKENS.md), [docs/INSIGHTS_RESOURCE_ADVISOR.md](docs/INSIGHTS_RESOURCE_ADVISOR.md).
|
|
538
|
+
|
|
539
|
+
CLI (after `npm run build` / install):
|
|
540
|
+
|
|
541
|
+
```bash
|
|
542
|
+
npx countex insights:top ./path/to/insight-context.mjs --scope org_123 --counter my_counter
|
|
543
|
+
# TypeScript configs: node --import=tsx node_modules/@x12i/countex/dist/cli.js insights:pareto ./ctx.ts
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
359
548
|
## Events
|
|
360
549
|
|
|
361
550
|
The Countex client is an `EventEmitter`. Subscribe to observe what's happening:
|
package/dist/backup/export.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Both are bounded by the (scope, counterId, timeframe) filter the caller
|
|
8
8
|
* provides; we never iterate the entire collection.
|
|
9
|
+
*
|
|
10
|
+
* Streamed cells include optional `measures` when present on durable documents.
|
|
9
11
|
*/
|
|
10
12
|
import type { CacheStorage, CounterCell, DurableStorage, QuerySpec } from "../types/index.js";
|
|
11
13
|
export type ExportFilter = Pick<QuerySpec, "scope" | "counterId" | "timeframe">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/backup/export.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/backup/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC;AAEhF,wBAAgB,WAAW,CACzB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,aAAa,CAAC,WAAW,CAAC,CAE5B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACzD,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBlC"}
|
package/dist/backup/export.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Both are bounded by the (scope, counterId, timeframe) filter the caller
|
|
9
9
|
* provides; we never iterate the entire collection.
|
|
10
|
+
*
|
|
11
|
+
* Streamed cells include optional `measures` when present on durable documents.
|
|
10
12
|
*/
|
|
11
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
14
|
exports.exportCells = exportCells;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/backup/export.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/backup/export.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAWH,kCAMC;AAED,oCAyBC;AAjCD,SAAgB,WAAW,CACzB,OAAuB,EACvB,MAAoB,EACpB,MAAoB;IAEpB,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACtE,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,OAAuB,EACvB,KAAmB,EACnB,MAAoB,EACpB,UAAwD,EAAE;IAE1D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAC5C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,GAAkB,EAAE,CAAC;IAE9B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAErE,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;YACvB,KAAK,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Minimal CLI for insights. Loads an ESM/CJS module that default-exports or exports `createContext`.
|
|
4
|
+
*
|
|
5
|
+
* Config module should export:
|
|
6
|
+
* `export async function createContext()` → `{ insights: CountexInsights }`
|
|
7
|
+
* or `export default { insights }`.
|
|
8
|
+
*
|
|
9
|
+
* For TypeScript configs run with: `node --import=tsx node_modules/@x12i/countex/dist/cli.js ...`
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal CLI for insights. Loads an ESM/CJS module that default-exports or exports `createContext`.
|
|
5
|
+
*
|
|
6
|
+
* Config module should export:
|
|
7
|
+
* `export async function createContext()` → `{ insights: CountexInsights }`
|
|
8
|
+
* or `export default { insights }`.
|
|
9
|
+
*
|
|
10
|
+
* For TypeScript configs run with: `node --import=tsx node_modules/@x12i/countex/dist/cli.js ...`
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
50
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
51
|
+
const node_url_1 = require("node:url");
|
|
52
|
+
async function loadConfig(configPath) {
|
|
53
|
+
const abs = node_path_1.default.resolve(configPath);
|
|
54
|
+
if (!node_fs_1.default.existsSync(abs)) {
|
|
55
|
+
console.error(`Config not found: ${abs}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const href = (0, node_url_1.pathToFileURL)(abs).href;
|
|
59
|
+
const mod = (await Promise.resolve(`${href}`).then(s => __importStar(require(s))));
|
|
60
|
+
if (mod.createContext) {
|
|
61
|
+
return mod.createContext();
|
|
62
|
+
}
|
|
63
|
+
if (mod.default?.insights) {
|
|
64
|
+
return { insights: mod.default.insights };
|
|
65
|
+
}
|
|
66
|
+
if (mod.insights) {
|
|
67
|
+
return { insights: mod.insights };
|
|
68
|
+
}
|
|
69
|
+
console.error("Module must export createContext(), default.insights, or insights.");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
function formatMarkdown(title, body) {
|
|
73
|
+
return `# ${title}\n\n\`\`\`json\n${JSON.stringify(body, null, 2)}\n\`\`\`\n`;
|
|
74
|
+
}
|
|
75
|
+
async function main() {
|
|
76
|
+
const argv = process.argv.slice(2);
|
|
77
|
+
let format = "json";
|
|
78
|
+
const filtered = [];
|
|
79
|
+
for (let i = 0; i < argv.length; i++) {
|
|
80
|
+
if (argv[i] === "--format" && argv[i + 1]) {
|
|
81
|
+
format = argv[i + 1];
|
|
82
|
+
i++;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
filtered.push(argv[i]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const [cmd, configPath, ...rest] = filtered;
|
|
89
|
+
if (!cmd || !configPath) {
|
|
90
|
+
console.error(`Usage: countex insights:<command> <configfile> [--format json|markdown]
|
|
91
|
+
|
|
92
|
+
Commands:
|
|
93
|
+
insights:top insights:pareto insights:anomalies insights:cost insights:tokens
|
|
94
|
+
insights:map-health insights:resources
|
|
95
|
+
`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
const { insights } = await loadConfig(configPath);
|
|
99
|
+
const scopeFlag = (name) => {
|
|
100
|
+
const ix = rest.indexOf(name);
|
|
101
|
+
return ix >= 0 ? rest[ix + 1] : undefined;
|
|
102
|
+
};
|
|
103
|
+
const scope = scopeFlag("--scope") ?? "org_1";
|
|
104
|
+
const counter = scopeFlag("--counter") ?? "test_counter";
|
|
105
|
+
let result;
|
|
106
|
+
let title = cmd;
|
|
107
|
+
if (cmd === "insights:top" || cmd === "insights:pareto") {
|
|
108
|
+
const timeframe = { type: "day", from: "2026-05-01", to: "2026-05-03" };
|
|
109
|
+
if (cmd === "insights:top") {
|
|
110
|
+
result = await insights.topN({
|
|
111
|
+
scope,
|
|
112
|
+
counterId: counter,
|
|
113
|
+
timeframe,
|
|
114
|
+
groupBy: ["metric"],
|
|
115
|
+
measure: "count",
|
|
116
|
+
n: 10,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
result = await insights.pareto({
|
|
121
|
+
scope,
|
|
122
|
+
counterId: counter,
|
|
123
|
+
timeframe,
|
|
124
|
+
groupBy: ["metric"],
|
|
125
|
+
measure: "count",
|
|
126
|
+
targetShare: 0.8,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (cmd === "insights:anomalies") {
|
|
131
|
+
result = await insights.detectAnomalies({
|
|
132
|
+
scope,
|
|
133
|
+
counterId: counter,
|
|
134
|
+
timeframe: { type: "day", from: "2026-05-02", to: "2026-05-03" },
|
|
135
|
+
groupBy: [],
|
|
136
|
+
measure: "count",
|
|
137
|
+
baseline: { lookback: "7d", compareBy: "rolling" },
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else if (cmd === "insights:cost") {
|
|
141
|
+
result = await insights.costDrivers({
|
|
142
|
+
scope,
|
|
143
|
+
counterId: counter,
|
|
144
|
+
timeframe: { type: "month", from: "2026-05", to: "2026-05" },
|
|
145
|
+
groupBy: ["metric"],
|
|
146
|
+
costMeasure: "costMicros.sum",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else if (cmd === "insights:tokens") {
|
|
150
|
+
result = await insights.recommendMaxTokens({
|
|
151
|
+
scope,
|
|
152
|
+
counterId: counter,
|
|
153
|
+
timeframe: { type: "day", from: "2026-05-01", to: "2026-05-03" },
|
|
154
|
+
groupBy: ["metric"],
|
|
155
|
+
outputTokenMeasure: "outputTokens",
|
|
156
|
+
minCalls: 1,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else if (cmd === "insights:map-health") {
|
|
160
|
+
result = await insights.analyzeMapHealth({
|
|
161
|
+
scope,
|
|
162
|
+
counterId: counter,
|
|
163
|
+
timeframe: { type: "day", from: "2026-05-01", to: "2026-05-03" },
|
|
164
|
+
includeRecommendations: true,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else if (cmd === "insights:resources") {
|
|
168
|
+
result = await insights.estimateResourcesFromActuals({
|
|
169
|
+
scope,
|
|
170
|
+
counterId: counter,
|
|
171
|
+
sampleWindow: { type: "day", from: "2026-05-01", to: "2026-05-03" },
|
|
172
|
+
targetRetention: { day: 92 },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
console.error("Unknown command:", cmd);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
if (format === "markdown") {
|
|
180
|
+
console.log(formatMarkdown(title, result));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.log(JSON.stringify(result, null, 2));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
main().catch((e) => {
|
|
187
|
+
console.error(e);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAyB;AACzB,0DAA6B;AAC7B,uCAAyC;AAKzC,KAAK,UAAU,UAAU,CAAC,UAAkB;IAC1C,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACrC,MAAM,GAAG,GAAG,CAAC,yBAAa,IAAI,uCAAC,CAI9B,CAAC;IACF,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;QAC1B,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACpF,OA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EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE;YACnE,eAAe,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/core/buffer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* then forget those deltas. If the durable write fails, we merge the snapshot
|
|
7
7
|
* back into the buffer so no counts are lost.
|
|
8
8
|
*/
|
|
9
|
-
import type { CellIdentity, PendingDelta } from "../types/index.js";
|
|
9
|
+
import type { CellIdentity, PendingDelta, PendingMeasureDelta } from "../types/index.js";
|
|
10
10
|
export declare class DeltaBuffer {
|
|
11
11
|
private readonly map;
|
|
12
12
|
/** Number of source events accumulated since last flush (for flush triggers). */
|
|
@@ -14,8 +14,9 @@ export declare class DeltaBuffer {
|
|
|
14
14
|
size(): number;
|
|
15
15
|
eventCount(): number;
|
|
16
16
|
noteEvent(): void;
|
|
17
|
-
/** Add a delta to the cell identified by `identity`. */
|
|
18
|
-
add(identity: CellIdentity, delta: number): void;
|
|
17
|
+
/** Add a delta (and optional measure increments) to the cell identified by `identity`. */
|
|
18
|
+
add(identity: CellIdentity, delta: number, measures?: Record<string, PendingMeasureDelta>, measureScales?: Record<string, number>): void;
|
|
19
|
+
private maybeCancel;
|
|
19
20
|
/**
|
|
20
21
|
* Take the current contents as a flush snapshot. The buffer is cleared
|
|
21
22
|
* atomically — if you need to re-merge on failure, call `mergeBack`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAqDzF,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyC;IAC7D,iFAAiF;IACjF,OAAO,CAAC,MAAM,CAAK;IAEnB,IAAI,IAAI,MAAM;IAId,UAAU,IAAI,MAAM;IAIpB,SAAS,IAAI,IAAI;IAIjB,0FAA0F;IAC1F,GAAG,CACD,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC9C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,IAAI;IA0BP,OAAO,CAAC,WAAW;IAMnB;;;OAGG;IACH,KAAK,IAAI,YAAY,EAAE;IAoBvB,sFAAsF;IACtF,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI;CAK1C"}
|
package/dist/core/buffer.js
CHANGED
|
@@ -10,6 +10,40 @@
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.DeltaBuffer = void 0;
|
|
12
12
|
const hash_js_1 = require("../utils/hash.js");
|
|
13
|
+
function mergeMeasureDelta(cur, inc) {
|
|
14
|
+
const out = { ...cur };
|
|
15
|
+
if (inc.sum !== undefined)
|
|
16
|
+
out.sum = (out.sum ?? 0) + inc.sum;
|
|
17
|
+
if (inc.count !== undefined)
|
|
18
|
+
out.count = (out.count ?? 0) + inc.count;
|
|
19
|
+
if (inc.min !== undefined) {
|
|
20
|
+
out.min = out.min !== undefined ? Math.min(out.min, inc.min) : inc.min;
|
|
21
|
+
}
|
|
22
|
+
if (inc.max !== undefined) {
|
|
23
|
+
out.max = out.max !== undefined ? Math.max(out.max, inc.max) : inc.max;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function mergeMeasureMaps(cur, inc) {
|
|
28
|
+
const out = cur ? { ...cur } : {};
|
|
29
|
+
for (const [name, delta] of Object.entries(inc)) {
|
|
30
|
+
out[name] = mergeMeasureDelta(out[name], delta);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
function hasMeasures(entry) {
|
|
35
|
+
return !!(entry.measures && Object.keys(entry.measures).length > 0);
|
|
36
|
+
}
|
|
37
|
+
function mergeScales(cur, inc) {
|
|
38
|
+
if (!inc || Object.keys(inc).length === 0)
|
|
39
|
+
return cur;
|
|
40
|
+
const out = { ...cur };
|
|
41
|
+
for (const [k, v] of Object.entries(inc)) {
|
|
42
|
+
if (out[k] === undefined)
|
|
43
|
+
out[k] = v;
|
|
44
|
+
}
|
|
45
|
+
return Object.keys(out).length ? out : undefined;
|
|
46
|
+
}
|
|
13
47
|
class DeltaBuffer {
|
|
14
48
|
map = new Map();
|
|
15
49
|
/** Number of source events accumulated since last flush (for flush triggers). */
|
|
@@ -23,20 +57,36 @@ class DeltaBuffer {
|
|
|
23
57
|
noteEvent() {
|
|
24
58
|
this.events++;
|
|
25
59
|
}
|
|
26
|
-
/** Add a delta to the cell identified by `identity`. */
|
|
27
|
-
add(identity, delta) {
|
|
28
|
-
|
|
60
|
+
/** Add a delta (and optional measure increments) to the cell identified by `identity`. */
|
|
61
|
+
add(identity, delta, measures, measureScales) {
|
|
62
|
+
const incMeasures = measures && Object.keys(measures).length > 0 ? measures : undefined;
|
|
63
|
+
const incScales = measureScales && Object.keys(measureScales).length > 0 ? measureScales : undefined;
|
|
64
|
+
if (delta === 0 && !incMeasures)
|
|
29
65
|
return;
|
|
30
66
|
const key = (0, hash_js_1.cellKey)(identity);
|
|
31
67
|
const cur = this.map.get(key);
|
|
32
68
|
if (cur) {
|
|
33
69
|
cur.delta += delta;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
70
|
+
if (incMeasures) {
|
|
71
|
+
cur.measures = mergeMeasureMaps(cur.measures, incMeasures);
|
|
72
|
+
}
|
|
73
|
+
cur.measureScales = mergeScales(cur.measureScales, incScales);
|
|
74
|
+
this.maybeCancel(key, cur);
|
|
37
75
|
}
|
|
38
76
|
else {
|
|
39
|
-
|
|
77
|
+
const entry = {
|
|
78
|
+
identity,
|
|
79
|
+
delta,
|
|
80
|
+
measures: incMeasures ? mergeMeasureMaps(undefined, incMeasures) : undefined,
|
|
81
|
+
measureScales: incScales ? { ...incScales } : undefined,
|
|
82
|
+
};
|
|
83
|
+
this.map.set(key, entry);
|
|
84
|
+
this.maybeCancel(key, entry);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
maybeCancel(key, entry) {
|
|
88
|
+
if (!hasMeasures(entry) && entry.delta === 0) {
|
|
89
|
+
this.map.delete(key);
|
|
40
90
|
}
|
|
41
91
|
}
|
|
42
92
|
/**
|
|
@@ -46,7 +96,13 @@ class DeltaBuffer {
|
|
|
46
96
|
drain() {
|
|
47
97
|
const out = [];
|
|
48
98
|
for (const entry of this.map.values()) {
|
|
49
|
-
|
|
99
|
+
const measures = entry.measures && Object.keys(entry.measures).length > 0
|
|
100
|
+
? Object.fromEntries(Object.entries(entry.measures).map(([k, v]) => [k, { ...v }]))
|
|
101
|
+
: undefined;
|
|
102
|
+
const measureScales = entry.measureScales && Object.keys(entry.measureScales).length > 0
|
|
103
|
+
? { ...entry.measureScales }
|
|
104
|
+
: undefined;
|
|
105
|
+
out.push({ identity: entry.identity, delta: entry.delta, measures, measureScales });
|
|
50
106
|
}
|
|
51
107
|
this.map.clear();
|
|
52
108
|
this.events = 0;
|
|
@@ -55,7 +111,7 @@ class DeltaBuffer {
|
|
|
55
111
|
/** Re-merge a previously drained snapshot back into the buffer (failure recovery). */
|
|
56
112
|
mergeBack(snapshot) {
|
|
57
113
|
for (const d of snapshot) {
|
|
58
|
-
this.add(d.identity, d.delta);
|
|
114
|
+
this.add(d.identity, d.delta, d.measures, d.measureScales);
|
|
59
115
|
}
|
|
60
116
|
}
|
|
61
117
|
}
|
package/dist/core/buffer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAGH,8CAA2C;
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAGH,8CAA2C;AAS3C,SAAS,iBAAiB,CACxB,GAAoC,EACpC,GAAwB;IAExB,MAAM,GAAG,GAAwB,EAAE,GAAG,GAAG,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS;QAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;IAC9D,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,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