pi-mega-compact 0.20.79 → 0.20.81
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/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +1 -0
- package/dist/extensions/mega-config.js +2 -0
- package/dist/extensions/mega-events/agent-handlers/turnEndHandler/recordTurnRow.js +17 -0
- package/dist/extensions/mega-events/analytics-handler.js +169 -0
- package/dist/extensions/mega-events/register.js +3 -0
- package/dist/src/store/analytics/connection.js +114 -0
- package/dist/src/store/analytics/contract-compliance.test/_helpers.js +39 -0
- package/dist/src/store/analytics/index.js +25 -0
- package/dist/src/store/analytics/memory-store.js +111 -0
- package/dist/src/store/analytics/schema.js +108 -0
- package/dist/src/store/analytics/sqlite-store/admin.js +84 -0
- package/dist/src/store/analytics/sqlite-store/ctx.js +1 -0
- package/dist/src/store/analytics/sqlite-store/read.js +25 -0
- package/dist/src/store/analytics/sqlite-store/rows.js +44 -0
- package/dist/src/store/analytics/sqlite-store/write.js +90 -0
- package/dist/src/store/analytics/sqlite-store.js +79 -0
- package/dist/src/store/analytics/types.js +17 -0
- package/extensions/dashboard-client/dist/assets/{AdminTab-BsA8-_bX.js → AdminTab-BTCZLMCc.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AdminTab-BsA8-_bX.js.map → AdminTab-BTCZLMCc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-BRHEfWhc.js → AreaChart-BTMI0QnR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-BRHEfWhc.js.map → AreaChart-BTMI0QnR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-C-M0LaFc.js → BarChart-C1F8wLM3.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-C-M0LaFc.js.map → BarChart-C1F8wLM3.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-Cj3n59U3.js → CacheTab-ORjrhSbZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-Cj3n59U3.js.map → CacheTab-ORjrhSbZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ConfigTab-C016XTNC.js → ConfigTab-CtXVSxD_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-C016XTNC.js.map → ConfigTab-CtXVSxD_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DE29fuqe.js → EventsTab-DQdwa9IB.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DE29fuqe.js.map → EventsTab-DQdwa9IB.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-D4eVI8ar.js → HealthTab-BpVO7BeO.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-D4eVI8ar.js.map → HealthTab-BpVO7BeO.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-4fJ7M4S4.js → MaintenanceTab-Cl9mWaR8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-4fJ7M4S4.js.map → MaintenanceTab-Cl9mWaR8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CDbcK9e4.js → MemoryMapTab-D3kIPeCy.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CDbcK9e4.js.map → MemoryMapTab-D3kIPeCy.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsCards-VUEcgGzo.js → MetricsCards-Cu1zDkfm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsCards-VUEcgGzo.js.map → MetricsCards-Cu1zDkfm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-BAvMzWuF.js +2 -0
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CKqJ0Zl-.js.map → MetricsTab-BAvMzWuF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-CouEq0qi.js +16 -0
- package/extensions/dashboard-client/dist/assets/OverviewTab-CouEq0qi.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{ReposTab-C4iveqrP.js → ReposTab-BUESjauJ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-C4iveqrP.js.map → ReposTab-BUESjauJ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DSEwkMQm.js → SessionsTab-DyJmQ_78.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DSEwkMQm.js.map → SessionsTab-DyJmQ_78.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-CCyWgy4O.js → SetupTab-q8wYL5A-.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-CCyWgy4O.js.map → SetupTab-q8wYL5A-.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-CyD8e_e_.js → TimeSavedCard-DIRH1Pq7.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-CyD8e_e_.js.map → TimeSavedCard-DIRH1Pq7.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-5tLbWkRv.js → TurnMemoryView-CrYSOcZX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-5tLbWkRv.js.map → TurnMemoryView-CrYSOcZX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-C0jARSvU.js +2 -0
- package/extensions/dashboard-client/dist/assets/{TurnsTab-C7pm92Hg.js.map → TurnsTab-C0jARSvU.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-ObhcIyfN.js → VcStatusBadge-D83Fz939.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-ObhcIyfN.js.map → VcStatusBadge-D83Fz939.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-BtHZb7o7.js → VectorCortexTab-BFXh5Nu7.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-BtHZb7o7.js.map → VectorCortexTab-BFXh5Nu7.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-lQ4l3QIK.js → WikiTab-CEdJXkou.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-lQ4l3QIK.js.map → WikiTab-CEdJXkou.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-DhQQAJGm.js → button-BlRKWQsj.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-DhQQAJGm.js.map → button-BlRKWQsj.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-Cfhz9X31.js → card-Cx6WA_2T.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-Cfhz9X31.js.map → card-Cx6WA_2T.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-CKNOGEz_.js → client-extra-BRFScIiK.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-CKNOGEz_.js.map → client-extra-BRFScIiK.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-JKjK9_cB.js → generateCategoricalChart-DrkPNaOf.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-JKjK9_cB.js.map → generateCategoricalChart-DrkPNaOf.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-iuxgtzEW.js → index-DUnKr3wN.js} +6 -6
- package/extensions/dashboard-client/dist/assets/index-DUnKr3wN.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{switch-7EHEQMSP.js → switch-Wr0u4HKw.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-7EHEQMSP.js.map → switch-Wr0u4HKw.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-z1lWY4UM.js → toggle-C_eSNeMT.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-z1lWY4UM.js.map → toggle-C_eSNeMT.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-sctOZuRM.js → useSSE-C_oFqrwF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-sctOZuRM.js.map → useSSE-C_oFqrwF.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/App.tsx +11 -1
- package/extensions/dashboard-client/src/components/RepoContextStack.tsx +28 -21
- package/extensions/dashboard-client/src/tabs/dashHashRouter.ts +31 -1
- package/extensions/dashboard-server/routes-rag-settings-helpers.ts +6 -0
- package/extensions/mega-config-types.ts +3 -0
- package/extensions/mega-config.ts +2 -0
- package/extensions/mega-events/agent-handlers/turnEndHandler/recordTurnRow.ts +17 -0
- package/extensions/mega-events/analytics-handler.ts +236 -0
- package/extensions/mega-events/register.ts +3 -0
- package/package.json +1 -1
- package/src/store/analytics/connection.ts +128 -0
- package/src/store/analytics/contract-compliance.test/_helpers.ts +47 -0
- package/src/store/analytics/index.ts +61 -0
- package/src/store/analytics/memory-store.ts +161 -0
- package/src/store/analytics/schema.ts +132 -0
- package/src/store/analytics/sqlite-store/admin.ts +96 -0
- package/src/store/analytics/sqlite-store/ctx.ts +9 -0
- package/src/store/analytics/sqlite-store/read.ts +46 -0
- package/src/store/analytics/sqlite-store/rows.ts +58 -0
- package/src/store/analytics/sqlite-store/write.ts +111 -0
- package/src/store/analytics/sqlite-store.ts +119 -0
- package/src/store/analytics/types.ts +202 -0
- package/extensions/dashboard-client/dist/assets/MetricsTab-CKqJ0Zl-.js +0 -2
- package/extensions/dashboard-client/dist/assets/OverviewTab-9Kxo79mi.js +0 -16
- package/extensions/dashboard-client/dist/assets/OverviewTab-9Kxo79mi.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-C7pm92Hg.js +0 -2
- package/extensions/dashboard-client/dist/assets/index-iuxgtzEW.js.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin.ts — AnalyticsAdmin delegate bodies for the SQLite backend.
|
|
3
|
+
* Destructive/maintenance operations: prune, vacuum, integrityCheck, backup, clear, close.
|
|
4
|
+
*/
|
|
5
|
+
import { copyFileSync, existsSync } from "node:fs";
|
|
6
|
+
import { withTx } from "../connection.js";
|
|
7
|
+
import { analyticsDbPath } from "../connection.js";
|
|
8
|
+
export function prune(ctx, policy) {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
const eventCutoff = now - policy.maxEventAgeMs;
|
|
11
|
+
const measCutoff = now - policy.maxMeasurementAgeMs;
|
|
12
|
+
const delEvents = ctx.db
|
|
13
|
+
.prepare("DELETE FROM request_events WHERE observed_at < ?")
|
|
14
|
+
.run(eventCutoff);
|
|
15
|
+
const delMeas = ctx.db
|
|
16
|
+
.prepare("DELETE FROM measurement_samples WHERE observed_at < ?")
|
|
17
|
+
.run(measCutoff);
|
|
18
|
+
// Identity observations are not age-pruned (they're low-volume snapshots).
|
|
19
|
+
if (policy.vacuumAfterPrune) {
|
|
20
|
+
try {
|
|
21
|
+
ctx.db.exec("VACUUM");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
/* non-fatal */
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
eventsRemoved: delEvents.changes ?? 0,
|
|
29
|
+
measurementsRemoved: delMeas.changes ?? 0,
|
|
30
|
+
identitiesRemoved: 0,
|
|
31
|
+
freedBytes: 0,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function vacuum(ctx) {
|
|
35
|
+
try {
|
|
36
|
+
ctx.db.exec("VACUUM");
|
|
37
|
+
return { ok: true, detail: "VACUUM completed" };
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return { ok: false, detail: String(e) };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function integrityCheck(ctx) {
|
|
44
|
+
try {
|
|
45
|
+
const row = ctx.db.prepare("PRAGMA integrity_check").get();
|
|
46
|
+
const result = row?.integrity_check ?? "ok";
|
|
47
|
+
return { ok: result === "ok", detail: result };
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return { ok: false, detail: String(e) };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function backup(ctx) {
|
|
54
|
+
if (ctx.opts.inMemory) {
|
|
55
|
+
return { ok: false, detail: "Cannot backup an in-memory database" };
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
// WAL-safe checkpoint before copy.
|
|
59
|
+
ctx.db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
60
|
+
const src = analyticsDbPath(ctx.stateDir);
|
|
61
|
+
if (!existsSync(src))
|
|
62
|
+
return { ok: false, detail: "analytics.db not found" };
|
|
63
|
+
const dest = `${src}.bak-${Date.now()}`;
|
|
64
|
+
copyFileSync(src, dest);
|
|
65
|
+
return { ok: true, path: dest, detail: `Backup written to ${dest}` };
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
return { ok: false, detail: String(e) };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function clear(ctx) {
|
|
72
|
+
withTx(ctx.db, () => {
|
|
73
|
+
ctx.db.exec("DELETE FROM request_events");
|
|
74
|
+
ctx.db.exec("DELETE FROM measurement_samples");
|
|
75
|
+
ctx.db.exec("DELETE FROM identity_observations");
|
|
76
|
+
// Reset AUTOINCREMENT sequences for measurement_samples + identity_observations.
|
|
77
|
+
try {
|
|
78
|
+
ctx.db.exec("DELETE FROM sqlite_sequence WHERE name IN ('measurement_samples', 'identity_observations')");
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
/* non-fatal: sqlite_sequence may not exist yet */
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getAnalyticsSchemaVersion } from "../schema.js";
|
|
2
|
+
export function status(ctx) {
|
|
3
|
+
const eventCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM request_events").get().c;
|
|
4
|
+
const measurementCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM measurement_samples").get().c;
|
|
5
|
+
const identityCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM identity_observations").get().c;
|
|
6
|
+
// Freshness: the most recent observed_at across all three fact tables.
|
|
7
|
+
const lastEvent = ctx.db
|
|
8
|
+
.prepare("SELECT MAX(observed_at) AS mx FROM request_events")
|
|
9
|
+
.get().mx;
|
|
10
|
+
const lastMeas = ctx.db
|
|
11
|
+
.prepare("SELECT MAX(observed_at) AS mx FROM measurement_samples")
|
|
12
|
+
.get().mx;
|
|
13
|
+
const lastId = ctx.db
|
|
14
|
+
.prepare("SELECT MAX(observed_at) AS mx FROM identity_observations")
|
|
15
|
+
.get().mx;
|
|
16
|
+
const freshThrough = Math.max(lastEvent ?? 0, lastMeas ?? 0, lastId ?? 0) || null;
|
|
17
|
+
return {
|
|
18
|
+
enabled: true,
|
|
19
|
+
schemaVersion: getAnalyticsSchemaVersion(),
|
|
20
|
+
requestEventCount: eventCount,
|
|
21
|
+
measurementCount,
|
|
22
|
+
identityCount,
|
|
23
|
+
freshThrough,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function rowToRequestEvent(r) {
|
|
2
|
+
return {
|
|
3
|
+
id: r.id,
|
|
4
|
+
correlationId: r.correlation_id ?? undefined,
|
|
5
|
+
sessionId: r.session_id ?? undefined,
|
|
6
|
+
repoId: r.repo_id ?? undefined,
|
|
7
|
+
turnId: r.turn_id ?? undefined,
|
|
8
|
+
eventKind: r.event_kind,
|
|
9
|
+
observedAt: r.observed_at,
|
|
10
|
+
provider: r.provider ?? undefined,
|
|
11
|
+
model: r.model ?? undefined,
|
|
12
|
+
status: r.status ?? undefined,
|
|
13
|
+
inputTokens: r.input_tokens ?? undefined,
|
|
14
|
+
outputTokens: r.output_tokens ?? undefined,
|
|
15
|
+
cacheReadTokens: r.cache_read_tokens ?? undefined,
|
|
16
|
+
cacheWriteTokens: r.cache_write_tokens ?? undefined,
|
|
17
|
+
durationMs: r.duration_ms ?? undefined,
|
|
18
|
+
ttftMs: r.ttft_ms ?? undefined,
|
|
19
|
+
source: r.source,
|
|
20
|
+
quality: JSON.parse(r.quality_json ?? "{}"),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function rowToMeasurement(r) {
|
|
24
|
+
return {
|
|
25
|
+
observedAt: r.observed_at,
|
|
26
|
+
sampleKind: r.sample_kind,
|
|
27
|
+
provider: r.provider ?? undefined,
|
|
28
|
+
model: r.model ?? undefined,
|
|
29
|
+
value: r.value,
|
|
30
|
+
unit: r.unit,
|
|
31
|
+
correlationId: r.correlation_id ?? undefined,
|
|
32
|
+
source: r.source,
|
|
33
|
+
quality: JSON.parse(r.quality_json ?? "{}"),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function rowToIdentity(r) {
|
|
37
|
+
return {
|
|
38
|
+
observedAt: r.observed_at,
|
|
39
|
+
provider: r.provider ?? undefined,
|
|
40
|
+
model: r.model ?? undefined,
|
|
41
|
+
source: r.source,
|
|
42
|
+
metadata: JSON.parse(r.metadata_json ?? "{}"),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export function appendRequestEvent(ctx, fact) {
|
|
2
|
+
try {
|
|
3
|
+
const res = ctx.db
|
|
4
|
+
.prepare(`INSERT OR IGNORE INTO request_events (
|
|
5
|
+
id, correlation_id, session_id, repo_id, turn_id, event_kind,
|
|
6
|
+
observed_at, provider, model, status,
|
|
7
|
+
input_tokens, output_tokens, cache_read_tokens, cache_write_tokens,
|
|
8
|
+
duration_ms, ttft_ms, source, quality_json
|
|
9
|
+
) VALUES (
|
|
10
|
+
@id, @correlation_id, @session_id, @repo_id, @turn_id, @event_kind,
|
|
11
|
+
@observed_at, @provider, @model, @status,
|
|
12
|
+
@input_tokens, @output_tokens, @cache_read_tokens, @cache_write_tokens,
|
|
13
|
+
@duration_ms, @ttft_ms, @source, @quality_json
|
|
14
|
+
)`)
|
|
15
|
+
.run({
|
|
16
|
+
"@id": fact.id,
|
|
17
|
+
"@correlation_id": fact.correlationId ?? null,
|
|
18
|
+
"@session_id": fact.sessionId ?? null,
|
|
19
|
+
"@repo_id": fact.repoId ?? null,
|
|
20
|
+
"@turn_id": fact.turnId ?? null,
|
|
21
|
+
"@event_kind": fact.eventKind,
|
|
22
|
+
"@observed_at": fact.observedAt,
|
|
23
|
+
"@provider": fact.provider ?? null,
|
|
24
|
+
"@model": fact.model ?? null,
|
|
25
|
+
"@status": fact.status ?? null,
|
|
26
|
+
"@input_tokens": fact.inputTokens ?? null,
|
|
27
|
+
"@output_tokens": fact.outputTokens ?? null,
|
|
28
|
+
"@cache_read_tokens": fact.cacheReadTokens ?? null,
|
|
29
|
+
"@cache_write_tokens": fact.cacheWriteTokens ?? null,
|
|
30
|
+
"@duration_ms": fact.durationMs ?? null,
|
|
31
|
+
"@ttft_ms": fact.ttftMs ?? null,
|
|
32
|
+
"@source": fact.source,
|
|
33
|
+
"@quality_json": JSON.stringify(fact.quality ?? {}),
|
|
34
|
+
});
|
|
35
|
+
return (res.changes ?? 0) > 0
|
|
36
|
+
? { status: "accepted", id: fact.id }
|
|
37
|
+
: { status: "duplicate", id: fact.id };
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return { status: "failed", error: String(e) };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function appendMeasurement(ctx, fact) {
|
|
44
|
+
try {
|
|
45
|
+
const res = ctx.db
|
|
46
|
+
.prepare(`INSERT INTO measurement_samples (
|
|
47
|
+
observed_at, sample_kind, provider, model, value, unit,
|
|
48
|
+
correlation_id, source, quality_json
|
|
49
|
+
) VALUES (
|
|
50
|
+
@observed_at, @sample_kind, @provider, @model, @value, @unit,
|
|
51
|
+
@correlation_id, @source, @quality_json
|
|
52
|
+
)`)
|
|
53
|
+
.run({
|
|
54
|
+
"@observed_at": fact.observedAt,
|
|
55
|
+
"@sample_kind": fact.sampleKind,
|
|
56
|
+
"@provider": fact.provider ?? null,
|
|
57
|
+
"@model": fact.model ?? null,
|
|
58
|
+
"@value": fact.value,
|
|
59
|
+
"@unit": fact.unit,
|
|
60
|
+
"@correlation_id": fact.correlationId ?? null,
|
|
61
|
+
"@source": fact.source,
|
|
62
|
+
"@quality_json": JSON.stringify(fact.quality ?? {}),
|
|
63
|
+
});
|
|
64
|
+
return { status: "accepted", id: Number(res.lastInsertRowid ?? 0) };
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return { status: "failed", error: String(e) };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function appendIdentity(ctx, obs) {
|
|
71
|
+
try {
|
|
72
|
+
const res = ctx.db
|
|
73
|
+
.prepare(`INSERT INTO identity_observations (
|
|
74
|
+
observed_at, provider, model, source, metadata_json
|
|
75
|
+
) VALUES (
|
|
76
|
+
@observed_at, @provider, @model, @source, @metadata_json
|
|
77
|
+
)`)
|
|
78
|
+
.run({
|
|
79
|
+
"@observed_at": obs.observedAt,
|
|
80
|
+
"@provider": obs.provider ?? null,
|
|
81
|
+
"@model": obs.model ?? null,
|
|
82
|
+
"@source": obs.source,
|
|
83
|
+
"@metadata_json": JSON.stringify(obs.metadata ?? {}),
|
|
84
|
+
});
|
|
85
|
+
return { status: "accepted", id: Number(res.lastInsertRowid ?? 0) };
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
return { status: "failed", error: String(e) };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { openAnalyticsDb, closeAnalyticsDb } from "./connection.js";
|
|
2
|
+
import * as read from "./sqlite-store/read.js";
|
|
3
|
+
import * as write from "./sqlite-store/write.js";
|
|
4
|
+
import * as admin from "./sqlite-store/admin.js";
|
|
5
|
+
export class SqliteAnalyticsStore {
|
|
6
|
+
db;
|
|
7
|
+
stateDir;
|
|
8
|
+
opts;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.opts = options;
|
|
11
|
+
this.stateDir = options.stateDir;
|
|
12
|
+
this.db = openAnalyticsDb(options.stateDir, {
|
|
13
|
+
dbPath: options.dbPath,
|
|
14
|
+
inMemory: options.inMemory,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
ctx() {
|
|
18
|
+
return { db: this.db, stateDir: this.stateDir, opts: this.opts };
|
|
19
|
+
}
|
|
20
|
+
// ── AnalyticsReader ───────────────────────────────────────────────
|
|
21
|
+
status() {
|
|
22
|
+
return read.status(this.ctx());
|
|
23
|
+
}
|
|
24
|
+
// ── AnalyticsWriter ───────────────────────────────────────────────
|
|
25
|
+
appendRequestEvent(fact) {
|
|
26
|
+
return write.appendRequestEvent(this.ctx(), fact);
|
|
27
|
+
}
|
|
28
|
+
appendMeasurement(sample) {
|
|
29
|
+
return write.appendMeasurement(this.ctx(), sample);
|
|
30
|
+
}
|
|
31
|
+
appendIdentity(observation) {
|
|
32
|
+
return write.appendIdentity(this.ctx(), observation);
|
|
33
|
+
}
|
|
34
|
+
// ── AnalyticsAdmin ────────────────────────────────────────────────
|
|
35
|
+
prune(policy) {
|
|
36
|
+
return admin.prune(this.ctx(), policy);
|
|
37
|
+
}
|
|
38
|
+
vacuum() {
|
|
39
|
+
return admin.vacuum(this.ctx());
|
|
40
|
+
}
|
|
41
|
+
integrityCheck() {
|
|
42
|
+
return admin.integrityCheck(this.ctx());
|
|
43
|
+
}
|
|
44
|
+
backup() {
|
|
45
|
+
return admin.backup(this.ctx());
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
admin.clear(this.ctx());
|
|
49
|
+
}
|
|
50
|
+
close() {
|
|
51
|
+
closeAnalyticsDb(this.stateDir, {
|
|
52
|
+
dbPath: this.opts.dbPath,
|
|
53
|
+
inMemory: this.opts.inMemory,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// ── Capability views ──────────────────────────────────────────────
|
|
57
|
+
asReader() {
|
|
58
|
+
return {
|
|
59
|
+
status: () => this.status(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
asWriter() {
|
|
63
|
+
return {
|
|
64
|
+
appendRequestEvent: (f) => this.appendRequestEvent(f),
|
|
65
|
+
appendMeasurement: (s) => this.appendMeasurement(s),
|
|
66
|
+
appendIdentity: (o) => this.appendIdentity(o),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
asAdmin() {
|
|
70
|
+
return {
|
|
71
|
+
prune: (p) => this.prune(p),
|
|
72
|
+
vacuum: () => this.vacuum(),
|
|
73
|
+
integrityCheck: () => this.integrityCheck(),
|
|
74
|
+
backup: () => this.backup(),
|
|
75
|
+
clear: () => this.clear(),
|
|
76
|
+
close: () => this.close(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* types.ts — PMA-1 contract module for the Provider/Model Analytics store.
|
|
3
|
+
*
|
|
4
|
+
* The source of truth. Every implementation (SQLite, in-memory) must satisfy
|
|
5
|
+
* these interfaces. SQL schemas are private to implementations.
|
|
6
|
+
*
|
|
7
|
+
* Design principles (from docs/specs/provider-model-analytics-program.md):
|
|
8
|
+
* 1. Contract-first — the interface IS the spec.
|
|
9
|
+
* 2. Append-only — AnalyticsWriter.append* are the only write methods; no UPDATE.
|
|
10
|
+
* 3. Capability-gated — asReader/asWriter/asAdmin return subset views.
|
|
11
|
+
* 4. Host push/store pull — the host supplies facts; the store never initiates.
|
|
12
|
+
* 5. Best effort — AppendResult identifies accepted/duplicate/failed without
|
|
13
|
+
* throwing into the host; analytics never interrupts the agent loop.
|
|
14
|
+
*
|
|
15
|
+
* PREVENT-PI-004: zero network. PREVENT-002: no SQL here (private to impls).
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
package/extensions/dashboard-client/dist/assets/{AdminTab-BsA8-_bX.js → AdminTab-BTCZLMCc.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,u as o,e as c,j as e}from"./index-
|
|
2
|
-
//# sourceMappingURL=AdminTab-
|
|
1
|
+
import{r as s,u as o,e as c,j as e}from"./index-DUnKr3wN.js";import{T as i}from"./toggle-C_eSNeMT.js";import r from"./MaintenanceTab-Cl9mWaR8.js";import{C as l}from"./ConfigTab-CtXVSxD_.js";import"./card-Cx6WA_2T.js";import"./button-BlRKWQsj.js";import"./switch-Wr0u4HKw.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
|
|
2
|
+
//# sourceMappingURL=AdminTab-BTCZLMCc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminTab-
|
|
1
|
+
{"version":3,"file":"AdminTab-BTCZLMCc.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
|
package/extensions/dashboard-client/dist/assets/{AreaChart-BRHEfWhc.js → AreaChart-BTMI0QnR.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-JKjK9_cB.js";import{R as p,J as ee,r as ve}from"./index-iuxgtzEW.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
|
|
2
|
-
//# sourceMappingURL=AreaChart-
|
|
1
|
+
import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-DrkPNaOf.js";import{R as p,J as ee,r as ve}from"./index-DUnKr3wN.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
|
|
2
|
+
//# sourceMappingURL=AreaChart-BTMI0QnR.js.map
|