@mastra/pg 1.12.1 → 1.13.0-alpha.1
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/CHANGELOG.md +91 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +2 -2
- package/dist/docs/references/reference-storage-composite.md +34 -2
- package/dist/docs/references/reference-storage-postgresql.md +1 -1
- package/dist/index.cjs +3837 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3836 -149
- package/dist/index.js.map +1 -1
- package/dist/{storage → shared}/pool-config.d.ts +10 -2
- package/dist/shared/pool-config.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/blobs/index.d.ts +1 -0
- package/dist/storage/domains/blobs/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts +2 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts +2 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/ddl.d.ts +55 -0
- package/dist/storage/domains/observability/v-next/ddl.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/discovery.d.ts +52 -0
- package/dist/storage/domains/observability/v-next/discovery.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/feedback.d.ts +17 -0
- package/dist/storage/domains/observability/v-next/feedback.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/filters.d.ts +29 -0
- package/dist/storage/domains/observability/v-next/filters.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/helpers.d.ts +33 -0
- package/dist/storage/domains/observability/v-next/helpers.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/index.d.ts +104 -0
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/listing.d.ts +53 -0
- package/dist/storage/domains/observability/v-next/listing.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/logs.d.ts +8 -0
- package/dist/storage/domains/observability/v-next/logs.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/metrics.d.ts +19 -0
- package/dist/storage/domains/observability/v-next/metrics.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/olap.d.ts +93 -0
- package/dist/storage/domains/observability/v-next/olap.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/partitioning.d.ts +76 -0
- package/dist/storage/domains/observability/v-next/partitioning.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/pg-errors.d.ts +25 -0
- package/dist/storage/domains/observability/v-next/pg-errors.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/polling.d.ts +28 -0
- package/dist/storage/domains/observability/v-next/polling.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/scores.d.ts +17 -0
- package/dist/storage/domains/observability/v-next/scores.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts +776 -0
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/sql.d.ts +31 -0
- package/dist/storage/domains/observability/v-next/sql.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/traces.d.ts +16 -0
- package/dist/storage/domains/observability/v-next/traces.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/tracing.d.ts +19 -0
- package/dist/storage/domains/observability/v-next/tracing.d.ts.map +1 -0
- package/dist/storage/domains/skills/index.d.ts +2 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/tool-provider-connections/index.d.ts +20 -0
- package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts +2 -0
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +89 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +9 -7
- package/dist/storage/pool-config.d.ts.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared OLAP helpers for the v-next Postgres observability domain.
|
|
3
|
+
*
|
|
4
|
+
* Translates ClickHouse-flavored OLAP idioms (the v-next spec) into Postgres:
|
|
5
|
+
*
|
|
6
|
+
* - `toStartOfInterval(ts, INTERVAL '5 MINUTE')` becomes a portable
|
|
7
|
+
* epoch-floor expression (`to_timestamp(floor(extract(epoch from ts) / N) * N)`)
|
|
8
|
+
* so arbitrary 1m / 5m / 15m / 1h / 1d buckets work without TimescaleDB.
|
|
9
|
+
* On a hypertable Postgres still uses chunk pruning over this expression.
|
|
10
|
+
* - `quantile(p)(value)` becomes `percentile_cont($p) WITHIN GROUP (ORDER BY value)`.
|
|
11
|
+
* - `argMax(value, ts)` ("last") becomes `(array_agg(value ORDER BY ts DESC))[1]`.
|
|
12
|
+
* - `sumIf` / `countDistinctIf` use SQL-standard `FILTER (WHERE …)` aggregates.
|
|
13
|
+
*
|
|
14
|
+
* GroupBy resolution mirrors the ClickHouse v-next behavior: typed columns
|
|
15
|
+
* are quoted directly; unknown keys are treated as label / metadata keys and
|
|
16
|
+
* accessed with `jsonb ->>`.
|
|
17
|
+
*/
|
|
18
|
+
import type { AggregationInterval, AggregationType, MetricDistinctColumn } from '@mastra/core/storage';
|
|
19
|
+
import type { FilterAccumulator } from './filters.js';
|
|
20
|
+
/** Subset of the ComparePeriod enum we react to. */
|
|
21
|
+
export type ComparePeriod = 'previous_period' | 'previous_day' | 'previous_week';
|
|
22
|
+
/** Time range slice we reuse from filter args. */
|
|
23
|
+
export interface PgDateRange {
|
|
24
|
+
start?: Date;
|
|
25
|
+
end?: Date;
|
|
26
|
+
startExclusive?: boolean;
|
|
27
|
+
endExclusive?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns a bucket expression that floors `column` to the start of the
|
|
31
|
+
* requested interval. The expression is portable across Postgres versions
|
|
32
|
+
* and works equally on a Timescale hypertable.
|
|
33
|
+
*
|
|
34
|
+
* Buckets are UTC-aligned (floor of Unix epoch). A `1d` bucket spans
|
|
35
|
+
* `00:00:00Z` → `23:59:59Z`, not local midnight. Charts that need
|
|
36
|
+
* local-day buckets should set the desired offset on the time-range filter
|
|
37
|
+
* rather than expect this helper to honor a session timezone.
|
|
38
|
+
*/
|
|
39
|
+
export declare function bucketSql(column: string, interval: AggregationInterval): string;
|
|
40
|
+
/** SQL aggregate for metric queries, including metric-specific distinct counts. */
|
|
41
|
+
export declare function metricAggregationSql(agg: AggregationType, measure: string, timestampColumn?: string, distinctColumn?: MetricDistinctColumn): string;
|
|
42
|
+
/** SQL aggregate for the standard agg types over a numeric column. */
|
|
43
|
+
export declare function aggregationSql(agg: AggregationType, measure: string, timestampColumn?: string): string;
|
|
44
|
+
export interface ResolvedGroupBy {
|
|
45
|
+
/** The key the caller asked for. Echoed back in dimensions. */
|
|
46
|
+
requestedKey: string;
|
|
47
|
+
/** SQL alias used for the column in SELECT / GROUP BY. */
|
|
48
|
+
alias: string;
|
|
49
|
+
/** The select expression (e.g. `"labels" ->> $1 AS group_by_0`). */
|
|
50
|
+
selectSql: string;
|
|
51
|
+
/** The bare SQL value expression (used in WHERE for label-exclusion). */
|
|
52
|
+
valueSql: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resolves a list of groupBy keys against the set of typed columns for a
|
|
56
|
+
* signal table. Unknown keys are treated as JSONB lookups against
|
|
57
|
+
* `labelsColumn` (default `"labels"`) — used by metrics breakdowns.
|
|
58
|
+
*
|
|
59
|
+
* Throws when a key is structurally invalid (not SQL-safe) or matches an
|
|
60
|
+
* excluded column type (jsonb / text[]).
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveGroupBy(acc: FilterAccumulator, groupBy: string[], options: {
|
|
63
|
+
typedColumns: Set<string>;
|
|
64
|
+
excludedColumns?: Set<string>;
|
|
65
|
+
labelsColumn?: string;
|
|
66
|
+
}): ResolvedGroupBy[];
|
|
67
|
+
/** Adds WHERE clauses that exclude rows missing a requested label key. */
|
|
68
|
+
export declare function pushLabelExclusions(acc: FilterAccumulator, resolved: ResolvedGroupBy[]): void;
|
|
69
|
+
export declare function dimensionsFromRow(row: Record<string, unknown>, resolved: ResolvedGroupBy[]): Record<string, string | null>;
|
|
70
|
+
export declare function seriesNameFromDimensions(values: unknown[]): string;
|
|
71
|
+
/** Compute the previous-period date range based on the comparePeriod selection. */
|
|
72
|
+
export declare function shiftRange(range: PgDateRange, period: ComparePeriod): PgDateRange | null;
|
|
73
|
+
export declare function changePercent(current: number | null, previous: number | null): number | null;
|
|
74
|
+
export declare function bucketDate(value: unknown): Date;
|
|
75
|
+
export declare function validatePercentiles(percentiles: readonly number[]): void;
|
|
76
|
+
export declare function percentileSelectSql(percentiles: readonly number[], measureSql: string): string;
|
|
77
|
+
export declare function percentileSeriesFromRows(rows: Record<string, unknown>[], percentiles: readonly number[]): {
|
|
78
|
+
percentile: number;
|
|
79
|
+
points: {
|
|
80
|
+
timestamp: Date;
|
|
81
|
+
value: number;
|
|
82
|
+
}[];
|
|
83
|
+
}[];
|
|
84
|
+
export declare function collectSeriesByDimensions<Row extends Record<string, unknown>, Entry>(rows: Row[], resolved: ResolvedGroupBy[], createEntry: (dimensionValues: unknown[]) => Entry, appendRow: (entry: Entry, row: Row, dimensionValues: unknown[]) => void): Entry[];
|
|
85
|
+
export interface CostSummary {
|
|
86
|
+
estimatedCost: number | null;
|
|
87
|
+
costUnit: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** SQL for the (estimatedCost, costUnit) pair embedded in metric OLAP responses. */
|
|
90
|
+
export declare const COST_SUMMARY_SELECT = "\n SUM(\"estimatedCost\") FILTER (WHERE \"estimatedCost\" IS NOT NULL) AS \"agg_estimatedCost\",\n CASE\n WHEN COUNT(DISTINCT \"costUnit\") FILTER (WHERE \"costUnit\" IS NOT NULL) = 1\n THEN MIN(\"costUnit\") FILTER (WHERE \"costUnit\" IS NOT NULL)\n ELSE NULL\n END AS \"agg_costUnit\"\n";
|
|
91
|
+
export declare function costSummaryFromRow(row: Record<string, unknown>): CostSummary;
|
|
92
|
+
export declare const COMPLEX_GROUP_BY_EXCLUDED: Set<string>;
|
|
93
|
+
//# sourceMappingURL=olap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"olap.d.ts","sourceRoot":"","sources":["../../../../../src/storage/domains/observability/v-next/olap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGvG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,cAAc,GAAG,eAAe,CAAC;AAEjF,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAcD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CAM/E;AAcD,mFAAmF;AACnF,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,EACf,eAAe,SAAc,EAC7B,cAAc,CAAC,EAAE,oBAAoB,GACpC,MAAM,CAKR;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,SAAc,GAAG,MAAM,CAkB3G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AED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI9F;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE;QAAE,SAAS,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,EAAE,CAQxE;AAED,wBAAgB,yBAAyB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAClF,IAAI,EAAE,GAAG,EAAE,EACX,QAAQ,EAAE,eAAe,EAAE,EAC3B,WAAW,EAAE,CAAC,eAAe,EAAE,OAAO,EAAE,KAAK,KAAK,EAClD,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,IAAI,GACtE,KAAK,EAAE,CAeT;AAMD,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,mTAO/B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAK5E;AAED,eAAO,MAAM,yBAAyB,aAepC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partition + extension management for the v-next Postgres observability domain.
|
|
3
|
+
*
|
|
4
|
+
* Three modes (auto-detected at init unless overridden by config):
|
|
5
|
+
*
|
|
6
|
+
* 1. TimescaleDB present → call `create_hypertable()` for each signal table.
|
|
7
|
+
* Chunks are created automatically; we never
|
|
8
|
+
* pre-create partitions and never call pg_partman.
|
|
9
|
+
*
|
|
10
|
+
* 2. pg_partman present → register each signal table as a daily-partitioned
|
|
11
|
+
* parent and let partman maintain future partitions.
|
|
12
|
+
*
|
|
13
|
+
* 3. Neither extension → pre-create a rolling window of daily partitions
|
|
14
|
+
* (yesterday + today + N future days). Future
|
|
15
|
+
* partitions can be extended by a separate Mastra
|
|
16
|
+
* CLI command, which is also the surface that will
|
|
17
|
+
* implement retention cleanup.
|
|
18
|
+
*
|
|
19
|
+
* This module deliberately does not implement retention deletes / drops.
|
|
20
|
+
* The goal here is to leave the schema in a shape that a follow-up
|
|
21
|
+
* `mastra retention` command can act on without further migrations.
|
|
22
|
+
*/
|
|
23
|
+
import type { DbClient } from '../../../client.js';
|
|
24
|
+
export type PartitionMode = 'timescale' | 'partman' | 'native';
|
|
25
|
+
export interface PartitioningOptions {
|
|
26
|
+
/** Override auto-detection. */
|
|
27
|
+
mode?: PartitionMode | 'auto';
|
|
28
|
+
/**
|
|
29
|
+
* Number of future daily partitions to pre-create when running in 'native'
|
|
30
|
+
* mode. Default 14. Has no effect in timescale or partman modes.
|
|
31
|
+
*/
|
|
32
|
+
futureDays?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to pre-create a partition for yesterday (covers small clock skew
|
|
35
|
+
* and late-arriving events). Default true.
|
|
36
|
+
*/
|
|
37
|
+
includeYesterday?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function detectTimescale(client: DbClient): Promise<boolean>;
|
|
40
|
+
export declare function detectPartman(client: DbClient): Promise<boolean>;
|
|
41
|
+
export declare function getPartmanVersion(client: DbClient): Promise<string | null>;
|
|
42
|
+
export declare function resolveMode(client: DbClient, options?: PartitioningOptions): Promise<PartitionMode>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates daily partition tables in [today - 1 day, today + futureDays].
|
|
45
|
+
* Idempotent: uses CREATE TABLE IF NOT EXISTS.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureNativePartitions(client: DbClient, schema: string, options?: PartitioningOptions): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Lists existing daily partitions for a signal table. Used by tests and the
|
|
50
|
+
* future `mastra retention` CLI command.
|
|
51
|
+
*/
|
|
52
|
+
export declare function listPartitions(client: DbClient, schema: string, table: string): Promise<string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Calls `create_hypertable()` for each signal table.
|
|
55
|
+
*
|
|
56
|
+
* Postgres declarative partitioning and Timescale hypertables are mutually
|
|
57
|
+
* exclusive, so the base DDL must have been generated with TableDDLMode
|
|
58
|
+
* 'timescale' (no `PARTITION BY` clause). `if_not_exists` makes this
|
|
59
|
+
* idempotent across re-inits.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ensureTimescaleHypertables(client: DbClient, schema: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Registers each signal table with pg_partman as a daily-interval parent and
|
|
64
|
+
* lets partman create the child partitions.
|
|
65
|
+
*
|
|
66
|
+
* Retention is intentionally NOT configured here — it stays opt-in via the
|
|
67
|
+
* future Mastra CLI surface.
|
|
68
|
+
*
|
|
69
|
+
* Prefers the pg_partman 5.x+ declarative API (`p_type := 'range'`) and keeps
|
|
70
|
+
* a 4.x fallback (`p_type := 'native'`) for older installs. That lets the
|
|
71
|
+
* adapter run against current arm64-friendly images without breaking existing
|
|
72
|
+
* 4.x deployments.
|
|
73
|
+
*/
|
|
74
|
+
export declare function ensurePartmanHypertables(client: DbClient, schema: string): Promise<void>;
|
|
75
|
+
export declare function setupPartitioning(client: DbClient, schema: string, options?: PartitioningOptions): Promise<PartitionMode>;
|
|
76
|
+
//# sourceMappingURL=partitioning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitioning.d.ts","sourceRoot":"","sources":["../../../../../src/storage/domains/observability/v-next/partitioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAA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AAI,CAAC,CAoE9F;AAMD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC,CAcxB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postgres error classifiers for the v-next observability adapter.
|
|
3
|
+
*
|
|
4
|
+
* `init()` runs `CREATE SCHEMA / TABLE / INDEX` and `ATTACH PARTITION`
|
|
5
|
+
* statements guarded by `IF NOT EXISTS`, but those checks aren't atomic
|
|
6
|
+
* against concurrent backends. Two callers racing past the existence probe
|
|
7
|
+
* can both reach the catalog insert; the loser sees a duplicate-object
|
|
8
|
+
* error. These helpers identify the exact codes we treat as "already exists
|
|
9
|
+
* by the time we look" so every other error surfaces normally.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* True when `error` says a relation with this name already exists in this
|
|
13
|
+
* schema. Covers `42P07` (clean case from `CREATE TABLE`) and `23505`
|
|
14
|
+
* unique-violation races on the relevant pg_catalog indexes, plus a final
|
|
15
|
+
* `/already exists/i` regex fallback for drivers that don't surface a code.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDuplicateRelationError(error: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* True when `error` says a schema with this name already exists. Covers
|
|
20
|
+
* `42P06` and the `23505` race on `pg_namespace_nspname_index`, plus a
|
|
21
|
+
* narrower regex fallback than `isDuplicateRelationError` so this helper
|
|
22
|
+
* only swallows schema-existence errors.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isDuplicateSchemaError(error: unknown): boolean;
|
|
25
|
+
//# sourceMappingURL=pg-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-errors.d.ts","sourceRoot":"","sources":["../../../../../src/storage/domains/observability/v-next/pg-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK9D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delta-polling helpers for the v-next Postgres observability domain.
|
|
3
|
+
*
|
|
4
|
+
* Cursor model
|
|
5
|
+
* ------------
|
|
6
|
+
* Each signal table stores both:
|
|
7
|
+
* - `xactId xid8 DEFAULT pg_current_xact_id()`
|
|
8
|
+
* - `cursorId bigserial`
|
|
9
|
+
*
|
|
10
|
+
* `bigserial` values are allocated before commit, so a later `cursorId` can
|
|
11
|
+
* become visible before an earlier one. Delta reads therefore order by the
|
|
12
|
+
* pair `(xactId, cursorId)` and cap reads at PostgreSQL's safe transaction
|
|
13
|
+
* horizon: `pg_snapshot_xmin(pg_current_snapshot())`. Rows with `xactId`
|
|
14
|
+
* below that horizon cannot still be in flight, so advancing the cursor there
|
|
15
|
+
* cannot skip a late-committing row.
|
|
16
|
+
*/
|
|
17
|
+
import type { DbClient } from '../../../client.js';
|
|
18
|
+
export declare const OBSERVABILITY_DELTA_POLLING_FEATURE = "observability-delta-polling";
|
|
19
|
+
export declare function deltaPollingFeatureEnabled(): boolean;
|
|
20
|
+
export declare function assertDeltaPollingEnabled(): void;
|
|
21
|
+
export interface DeltaCursorParts {
|
|
22
|
+
xactId: string;
|
|
23
|
+
cursorId: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function encodeDeltaCursor(xactId: unknown, cursorId?: unknown): string;
|
|
26
|
+
export declare function decodeDeltaCursor(cursor: string): DeltaCursorParts;
|
|
27
|
+
export declare function readSafeXactHorizon(client: DbClient): Promise<string>;
|
|
28
|
+
//# sourceMappingURL=polling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../../../../../src/storage/domains/observability/v-next/polling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAO,MAAM,mCAAmC,gCAAgC,CAAC;AAEjF,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAQhD;AASD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AA2BD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAE,OAAW,GAAG,MAAM,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CASlE;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Score operations for the v-next Postgres observability domain.
|
|
3
|
+
*
|
|
4
|
+
* Implements the full ObservabilityStorage score surface — write, list,
|
|
5
|
+
* aggregate, breakdown, time series, and percentiles.
|
|
6
|
+
*/
|
|
7
|
+
import type { BatchCreateScoresArgs, CreateScoreArgs, GetScoreAggregateArgs, GetScoreAggregateResponse, GetScoreBreakdownArgs, GetScoreBreakdownResponse, GetScorePercentilesArgs, GetScorePercentilesResponse, GetScoreTimeSeriesArgs, GetScoreTimeSeriesResponse, ListScoresArgs, ListScoresResponse, ScoreRecord } from '@mastra/core/storage';
|
|
8
|
+
import type { DbClient } from '../../../client.js';
|
|
9
|
+
export declare function createScore(client: DbClient, schema: string, args: CreateScoreArgs): Promise<void>;
|
|
10
|
+
export declare function batchCreateScores(client: DbClient, schema: string, args: BatchCreateScoresArgs): Promise<void>;
|
|
11
|
+
export declare function listScores(client: DbClient, schema: string, args: ListScoresArgs): Promise<ListScoresResponse>;
|
|
12
|
+
export declare function getScoreById(client: DbClient, schema: string, scoreId: string): Promise<ScoreRecord | null>;
|
|
13
|
+
export declare function getScoreAggregate(client: DbClient, schema: string, args: GetScoreAggregateArgs): Promise<GetScoreAggregateResponse>;
|
|
14
|
+
export declare function getScoreBreakdown(client: DbClient, schema: string, args: GetScoreBreakdownArgs): Promise<GetScoreBreakdownResponse>;
|
|
15
|
+
export declare function getScoreTimeSeries(client: DbClient, schema: string, args: GetScoreTimeSeriesArgs): Promise<GetScoreTimeSeriesResponse>;
|
|
16
|
+
export declare function getScorePercentiles(client: DbClient, schema: string, args: GetScorePercentilesArgs): Promise<GetScorePercentilesResponse>;
|
|
17
|
+
//# sourceMappingURL=scores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scores.d.ts","sourceRoot":"","sources":["../../../../../src/storage/domains/observability/v-next/scores.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AA0DhD,wBAAsB,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxG;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpH;AAMD,wBAAsB,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,kBA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