@vibeorm/runtime 1.3.0 → 2.0.0-alpha.10
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 +50 -107
- package/dist/adapter.d.ts +250 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/bulk-upsert.d.ts +282 -0
- package/dist/bulk-upsert.d.ts.map +1 -0
- package/dist/client.d.ts +200 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/codecs.d.ts +170 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/computed.d.ts +43 -0
- package/dist/computed.d.ts.map +1 -0
- package/dist/db-now.d.ts +41 -0
- package/dist/db-now.d.ts.map +1 -0
- package/dist/diagnostics/index.d.ts +12 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/insight.d.ts +63 -0
- package/dist/diagnostics/insight.d.ts.map +1 -0
- package/dist/diagnostics/plan.d.ts +88 -0
- package/dist/diagnostics/plan.d.ts.map +1 -0
- package/dist/diagnostics/preview.d.ts +43 -0
- package/dist/diagnostics/preview.d.ts.map +1 -0
- package/dist/diagnostics/types.d.ts +223 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/workload.d.ts +32 -0
- package/dist/diagnostics/workload.d.ts.map +1 -0
- package/dist/extensions.d.ts +102 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13070 -0
- package/dist/index.js.map +43 -0
- package/dist/keyset-iterator.d.ts +73 -0
- package/dist/keyset-iterator.d.ts.map +1 -0
- package/dist/keyset.d.ts +121 -0
- package/dist/keyset.d.ts.map +1 -0
- package/dist/model-meta.d.ts +200 -0
- package/dist/model-meta.d.ts.map +1 -0
- package/dist/nested-writes.d.ts +67 -0
- package/dist/nested-writes.d.ts.map +1 -0
- package/dist/policy-operation.d.ts +14 -0
- package/dist/policy-operation.d.ts.map +1 -0
- package/dist/policy.d.ts +17 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/query-builder.d.ts +271 -0
- package/dist/query-builder.d.ts.map +1 -0
- package/dist/relation-key.d.ts +23 -0
- package/dist/relation-key.d.ts.map +1 -0
- package/dist/relation-loader.d.ts +46 -0
- package/dist/relation-loader.d.ts.map +1 -0
- package/dist/relation-plan.d.ts +141 -0
- package/dist/relation-plan.d.ts.map +1 -0
- package/dist/render-cache.d.ts +48 -0
- package/dist/render-cache.d.ts.map +1 -0
- package/dist/rls-context.d.ts +14 -0
- package/dist/rls-context.d.ts.map +1 -0
- package/dist/rls-readiness.d.ts +114 -0
- package/dist/rls-readiness.d.ts.map +1 -0
- package/dist/scoped.d.ts +104 -0
- package/dist/scoped.d.ts.map +1 -0
- package/dist/strict-args.d.ts +47 -0
- package/dist/strict-args.d.ts.map +1 -0
- package/dist/telemetry/collector.d.ts +53 -0
- package/dist/telemetry/collector.d.ts.map +1 -0
- package/dist/telemetry/config.d.ts +53 -0
- package/dist/telemetry/config.d.ts.map +1 -0
- package/dist/telemetry/fingerprint.d.ts +38 -0
- package/dist/telemetry/fingerprint.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/recorder.d.ts +93 -0
- package/dist/telemetry/recorder.d.ts.map +1 -0
- package/dist/telemetry/statement.d.ts +53 -0
- package/dist/telemetry/statement.d.ts.map +1 -0
- package/dist/telemetry/types.d.ts +265 -0
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/validators.d.ts +61 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/views.d.ts +97 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/write-scope.d.ts +14 -0
- package/dist/write-scope.d.ts.map +1 -0
- package/package.json +33 -26
- package/src/adapter.ts +0 -146
- package/src/client.ts +0 -2172
- package/src/coerce.ts +0 -184
- package/src/count-loader.ts +0 -152
- package/src/errors.ts +0 -492
- package/src/id-generators.ts +0 -151
- package/src/index.ts +0 -55
- package/src/lateral-join-builder.ts +0 -1053
- package/src/query-builder.ts +0 -1832
- package/src/relation-loader.ts +0 -534
- package/src/retry.ts +0 -183
- package/src/types.ts +0 -317
- package/src/view.ts +0 -629
- package/src/where-builder.ts +0 -772
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI1E,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,WAAW,CAInF;AA8ED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAWnG;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAYnG;AAoCD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;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M,EAAE,OAAO,CAAC,EAAE,CAI5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,6FAA6F;IAC7F,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAkB5B;AA2CD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACjC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAkB5B;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAgBV"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime side of computed fields (config-declared derived result properties).
|
|
3
|
+
*
|
|
4
|
+
* The runtime stays config-AGNOSTIC the same way it is extension-agnostic:
|
|
5
|
+
* `createClient({ computed })` receives the live spec object plus the baked
|
|
6
|
+
* manifest from the generated client, verifies them against each other
|
|
7
|
+
* (VIBE_STALE_CLIENT before the first query), folds the specs into the model
|
|
8
|
+
* metadata, and `applyComputedFields` runs the compute functions at every row
|
|
9
|
+
* materialization point — top-level rows, mutation returns, and relation-loaded
|
|
10
|
+
* children on BOTH strategies (the codec lesson from LEARNINGS, applied to
|
|
11
|
+
* computes).
|
|
12
|
+
*/
|
|
13
|
+
import type { ComputedConfig, ComputedManifestEntry } from "@vibeorm/schema";
|
|
14
|
+
import type { ModelMeta } from "./model-meta.ts";
|
|
15
|
+
/** Computed-field wiring accepted by `createClient`. */
|
|
16
|
+
export type ClientComputedOptions = {
|
|
17
|
+
/** The live spec object (`vibeorm.config.ts`'s `computed`) — provides the compute functions. */
|
|
18
|
+
readonly specs?: ComputedConfig;
|
|
19
|
+
/** Manifest baked by the generator — presence turns on the staleness check. */
|
|
20
|
+
readonly manifest?: readonly ComputedManifestEntry[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Compare the generated client's baked computed manifest against the live
|
|
24
|
+
* config. Any drift — missing, added, type or needs change — throws
|
|
25
|
+
* `VIBE_STALE_CLIENT` at construction instead of an untyped (or missing)
|
|
26
|
+
* property surprise at query time.
|
|
27
|
+
*/
|
|
28
|
+
export declare function assertComputedManifest(params: {
|
|
29
|
+
manifest: readonly ComputedManifestEntry[];
|
|
30
|
+
specs: ComputedConfig | undefined;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Attach the named computed fields to each row, in place. Runs BEFORE
|
|
34
|
+
* projection narrows rows to `resultFields`, so `needs` scalars are present
|
|
35
|
+
* even when the caller did not select them. `names` is always a concrete list
|
|
36
|
+
* (the builder resolves "all" at plan time); `null` means nothing to do.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyComputedFields(params: {
|
|
39
|
+
model: ModelMeta;
|
|
40
|
+
rows: readonly Record<string, unknown>[];
|
|
41
|
+
names: readonly string[] | null;
|
|
42
|
+
}): void;
|
|
43
|
+
//# sourceMappingURL=computed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../src/computed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,wDAAwD;AACxD,MAAM,MAAM,qBAAqB,GAAG;IAClC,gGAAgG;IAChG,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACtD,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC3C,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;CACnC,GAAG,IAAI,CAqCP;AAID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACzC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,GAAG,IAAI,CAWP"}
|
package/dist/db-now.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dbNow()` — the DATABASE clock as a value.
|
|
3
|
+
*
|
|
4
|
+
* Leases, TTLs and expiry comparisons must trust the database's clock, never
|
|
5
|
+
* the process's ("a process that slept past its own expiry cannot argue with
|
|
6
|
+
* this comparison"). The sentinel rides DateTime positions:
|
|
7
|
+
*
|
|
8
|
+
* - create/update data values: `data: { expiresAt: dbNow({ plusSeconds: 30 }) }`
|
|
9
|
+
* - DateTime filters: `where: { expiresAt: { lt: dbNow() } }`
|
|
10
|
+
*
|
|
11
|
+
* and compiles to the dialect's own expression (`now()`, `NOW(6)`, an
|
|
12
|
+
* ISO-8601 `strftime` on sqlite) — the offset binds as a parameter, the
|
|
13
|
+
* expression is never string-built from caller input.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately NOT a generic SQL escape hatch: the closed shape keeps every
|
|
16
|
+
* rendering reviewable in the SQL catalog (constitution rule 3).
|
|
17
|
+
*/
|
|
18
|
+
/** The database-clock sentinel produced by {@link dbNow}. */
|
|
19
|
+
export type DbNow = {
|
|
20
|
+
readonly __vibeDbNow: true;
|
|
21
|
+
/** Seconds added to the database's now() (fractional OK; negative = past). */
|
|
22
|
+
readonly offsetSeconds: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Build a database-clock sentinel for DateTime data values and filters.
|
|
26
|
+
*
|
|
27
|
+
* @example Lease acquisition on the database's clock
|
|
28
|
+
* ```ts
|
|
29
|
+
* await tx.lease.update({
|
|
30
|
+
* where: { id },
|
|
31
|
+
* data: { expiresAt: dbNow({ plusSeconds: 30 }) },
|
|
32
|
+
* });
|
|
33
|
+
* const expired = await db.lease.findMany({ where: { expiresAt: { lt: dbNow() } } });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function dbNow(options?: {
|
|
37
|
+
readonly plusSeconds?: number;
|
|
38
|
+
}): DbNow;
|
|
39
|
+
/** Narrow a value to the {@link dbNow} sentinel (exact two-key shape). */
|
|
40
|
+
export declare function isDbNow(value: unknown): value is DbNow;
|
|
41
|
+
//# sourceMappingURL=db-now.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-now.d.ts","sourceRoot":"","sources":["../src/db-now.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,6DAA6D;AAC7D,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAUxE;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAYtD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@vibeorm/runtime` diagnostics (EPIC 5): SQL preview, PostgreSQL plan
|
|
3
|
+
* inspection, read-only workload statistics and deterministic evidence reading.
|
|
4
|
+
*
|
|
5
|
+
* Module barrel — the package's root barrel re-exports from here.
|
|
6
|
+
*/
|
|
7
|
+
export { parameterTypeTag, previewOperation } from "./preview.ts";
|
|
8
|
+
export { PLAN_DEFAULTS, explainOperation, explainSql, parsePostgresPlan } from "./plan.ts";
|
|
9
|
+
export { readWorkloadStatistics } from "./workload.ts";
|
|
10
|
+
export { DIAGNOSTIC_THRESHOLDS, analyzeOperationTelemetry, recommendFromPlan } from "./insight.ts";
|
|
11
|
+
export type { DiagnosticFinding, DiagnosticFindingCode, ExplainMode, IndexCandidate, IndexFacts, OperationPreview, ParsedPlan, PlanContext, PlanNode, PreviewLimitation, PreviewLimitationCode, PreviewStatement, QueryPlanReport, SlowOperation, SuspectedPattern, TableFacts, TelemetryDiagnosticReport, WorkloadAvailability, WorkloadReport, WorkloadStatement, } from "./types.ts";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnG,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,yBAAyB,EACzB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic reading of evidence (EPIC 5): repeated-statement patterns from
|
|
3
|
+
* EPIC 1's operation telemetry, and plan findings from an actual plan.
|
|
4
|
+
*
|
|
5
|
+
* Every claim here is bounded, reproducible and traceable to a number that was
|
|
6
|
+
* measured. What it deliberately does NOT do:
|
|
7
|
+
*
|
|
8
|
+
* - it never calls a repeated statement an N+1 defect. Repetition is a
|
|
9
|
+
* SUSPECTED pattern; a deliberate batch is normal work, and one batched
|
|
10
|
+
* statement with a big `IN` list is never flagged.
|
|
11
|
+
* - it never calls a sequential scan an index defect on its own. On a small
|
|
12
|
+
* table a sequential scan is the correct plan, and it says so.
|
|
13
|
+
* - it never claims to explain a pool wait or a lock wait. Neither is visible
|
|
14
|
+
* in a plan, estimated or actual.
|
|
15
|
+
* - it never creates, ranks or auto-applies an index. A missing-index note is
|
|
16
|
+
* a CANDIDATE, carrying the predicate context, the indexes that already
|
|
17
|
+
* exist and the write/storage cost a human has to weigh.
|
|
18
|
+
*/
|
|
19
|
+
import type { TelemetryOperationEvent } from "../telemetry/types.ts";
|
|
20
|
+
import type { DiagnosticFinding, IndexFacts, QueryPlanReport, TableFacts, TelemetryDiagnosticReport } from "./types.ts";
|
|
21
|
+
/** Every window and threshold, in one frozen table. All are bounded. */
|
|
22
|
+
export declare const DIAGNOSTIC_THRESHOLDS: {
|
|
23
|
+
readonly repeatThreshold: number;
|
|
24
|
+
readonly minRepeatThreshold: number;
|
|
25
|
+
readonly maxRepeatThreshold: number;
|
|
26
|
+
readonly slowOperationMs: number;
|
|
27
|
+
readonly maxOperations: number;
|
|
28
|
+
readonly maxFindings: number;
|
|
29
|
+
readonly smallTableRows: number;
|
|
30
|
+
readonly filterDiscardRatio: number;
|
|
31
|
+
readonly estimateErrorFactor: number;
|
|
32
|
+
readonly highLoopCount: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Read a bounded window of operation events for repeated statements and slow
|
|
36
|
+
* operations. Findings are labelled SUSPECTED — this is evidence for a human,
|
|
37
|
+
* not a verdict.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* analyzeOperationTelemetry({ operations: collector.operations, repeatThreshold: 5 });
|
|
41
|
+
*/
|
|
42
|
+
export declare function analyzeOperationTelemetry(params: {
|
|
43
|
+
operations: readonly TelemetryOperationEvent[];
|
|
44
|
+
repeatThreshold?: number;
|
|
45
|
+
slowOperationMs?: number;
|
|
46
|
+
maxOperations?: number;
|
|
47
|
+
maxFindings?: number;
|
|
48
|
+
}): TelemetryDiagnosticReport;
|
|
49
|
+
/**
|
|
50
|
+
* Turn one plan (plus the table facts a plan cannot supply) into deterministic
|
|
51
|
+
* findings. Order is the plan's own walk order, so the same plan always
|
|
52
|
+
* produces the same list.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* recommendFromPlan({ report, tables: [{ table: "User", estimatedRows: 5_000_000 }], indexes });
|
|
56
|
+
*/
|
|
57
|
+
export declare function recommendFromPlan(params: {
|
|
58
|
+
report: QueryPlanReport;
|
|
59
|
+
tables?: readonly TableFacts[];
|
|
60
|
+
indexes?: readonly IndexFacts[];
|
|
61
|
+
maxFindings?: number;
|
|
62
|
+
}): readonly DiagnosticFinding[];
|
|
63
|
+
//# sourceMappingURL=insight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insight.d.ts","sourceRoot":"","sources":["../../src/diagnostics/insight.ts"],"names":[],"mappings":"AAAA;;;;;;;;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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL plan inspection (EPIC 5).
|
|
3
|
+
*
|
|
4
|
+
* Two modes, deliberately far apart:
|
|
5
|
+
*
|
|
6
|
+
* - `estimate` renders `EXPLAIN (FORMAT JSON)`, which does NOT run the
|
|
7
|
+
* statement. It still takes planning locks and still parses and plans, so it
|
|
8
|
+
* is not free and it is not zero-risk on a busy table.
|
|
9
|
+
* - `analyze` renders `EXPLAIN (ANALYZE, FORMAT JSON, BUFFERS)`, which RUNS
|
|
10
|
+
* the statement. It is gated behind an explicit confirmation and trusted
|
|
11
|
+
* input, refuses writes and multi-statement text, and runs inside a
|
|
12
|
+
* read-only transaction. None of that is a proof of safety: a SELECT can
|
|
13
|
+
* call a function with side effects, and a keyword check cannot see that.
|
|
14
|
+
* Never point it at production, and never replay a slow production query
|
|
15
|
+
* automatically.
|
|
16
|
+
*
|
|
17
|
+
* The plan's own numbers are kept in their own units: planner cost units are
|
|
18
|
+
* not milliseconds, and estimated rows are not observed rows.
|
|
19
|
+
*/
|
|
20
|
+
import type { Dialect, SchemaIR } from "@vibeorm/schema";
|
|
21
|
+
import type { SqlExecutor } from "../adapter.ts";
|
|
22
|
+
import type { BuilderClientOptions, QueryMethod, RelationStrategy } from "../query-builder.ts";
|
|
23
|
+
import type { ExplainMode, ParsedPlan, QueryPlanReport } from "./types.ts";
|
|
24
|
+
/** Defaults for plan inspection; every one of them is a bound, not a preference. */
|
|
25
|
+
export declare const PLAN_DEFAULTS: {
|
|
26
|
+
readonly maxNodes: number;
|
|
27
|
+
readonly maxConditionLength: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Parse one `EXPLAIN (FORMAT JSON)` payload into a bounded node tree.
|
|
31
|
+
*
|
|
32
|
+
* Accepts what the drivers actually hand back: a parsed array, a single object,
|
|
33
|
+
* or the JSON text (bun:sql and pglite differ from node-postgres here).
|
|
34
|
+
*/
|
|
35
|
+
export declare function parsePostgresPlan(params: {
|
|
36
|
+
payload: unknown;
|
|
37
|
+
mode: ExplainMode;
|
|
38
|
+
maxNodes?: number;
|
|
39
|
+
includeLiterals?: boolean;
|
|
40
|
+
}): ParsedPlan;
|
|
41
|
+
/**
|
|
42
|
+
* Take a plan for already-rendered SQL.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* await explainSql({ executor, dialect: "postgres",
|
|
46
|
+
* sql: { text: 'SELECT "id" FROM "User" WHERE "email" = $1', values: ["a@b.test"] } });
|
|
47
|
+
*/
|
|
48
|
+
export declare function explainSql(params: {
|
|
49
|
+
executor: SqlExecutor;
|
|
50
|
+
dialect: Dialect;
|
|
51
|
+
sql: {
|
|
52
|
+
readonly text: string;
|
|
53
|
+
readonly values: readonly unknown[];
|
|
54
|
+
};
|
|
55
|
+
mode?: ExplainMode;
|
|
56
|
+
/** REQUIRED for `analyze`: that mode executes the statement. */
|
|
57
|
+
confirmExecute?: boolean;
|
|
58
|
+
/** REQUIRED for `analyze`: the caller vouches that this SQL is its own, not a user's. */
|
|
59
|
+
trustedInput?: boolean;
|
|
60
|
+
/** Transaction-local settings, bound exactly as the client binds them. */
|
|
61
|
+
rlsContext?: Readonly<Record<string, unknown>>;
|
|
62
|
+
/** Refuse instead of labelling when the role is not representative. */
|
|
63
|
+
requireRepresentativeContext?: boolean;
|
|
64
|
+
maxNodes?: number;
|
|
65
|
+
includeLiterals?: boolean;
|
|
66
|
+
}): Promise<QueryPlanReport>;
|
|
67
|
+
/**
|
|
68
|
+
* Take a plan for one ORM operation, built through the same pure planning path
|
|
69
|
+
* `previewOperation` uses. Multi-statement and data-dependent flows are refused
|
|
70
|
+
* in the executing mode rather than half-explained.
|
|
71
|
+
*/
|
|
72
|
+
export declare function explainOperation(params: {
|
|
73
|
+
executor: SqlExecutor;
|
|
74
|
+
schema: SchemaIR;
|
|
75
|
+
dialect: Dialect;
|
|
76
|
+
model: string;
|
|
77
|
+
method: QueryMethod;
|
|
78
|
+
args?: Record<string, unknown>;
|
|
79
|
+
mode?: ExplainMode;
|
|
80
|
+
confirmExecute?: boolean;
|
|
81
|
+
rlsContext?: Readonly<Record<string, unknown>>;
|
|
82
|
+
requireRepresentativeContext?: boolean;
|
|
83
|
+
relationStrategy?: RelationStrategy;
|
|
84
|
+
clientOptions?: BuilderClientOptions;
|
|
85
|
+
maxNodes?: number;
|
|
86
|
+
includeLiterals?: boolean;
|
|
87
|
+
}): Promise<QueryPlanReport>;
|
|
88
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/diagnostics/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG/F,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAyB,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlG,oFAAoF;AACpF,eAAO,MAAM,aAAa,EAAE;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACwB,CAAC;AAyD/D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,UAAU,CA+Eb;AA4ED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE;IACvC,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO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|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQL preview: what an operation WOULD send, without sending it (EPIC 5).
|
|
3
|
+
*
|
|
4
|
+
* Preview takes an explicit `{ schema, model, method, args }` input and runs
|
|
5
|
+
* the pure planning path (`buildQuery` → `renderStatement`). It never touches a
|
|
6
|
+
* delegate, so there is no lazy query promise to start, and it needs no
|
|
7
|
+
* database, no adapter and no connection.
|
|
8
|
+
*
|
|
9
|
+
* What it refuses to do: invent a parameter it does not have, or present one
|
|
10
|
+
* statement as the whole operation. A flow whose later statements depend on
|
|
11
|
+
* rows that do not exist yet is REPORTED as such, with the statements that are
|
|
12
|
+
* knowable shown in full and the rest named as a limitation.
|
|
13
|
+
*/
|
|
14
|
+
import type { Dialect, SchemaIR } from "@vibeorm/schema";
|
|
15
|
+
import type { BuilderClientOptions, QueryMethod, RelationStrategy } from "../query-builder.ts";
|
|
16
|
+
import type { OperationPreview } from "./types.ts";
|
|
17
|
+
/**
|
|
18
|
+
* A redacted description of one parameter: its transport shape, never its
|
|
19
|
+
* value. `previewOperation({ includeParameterValues: true })` opts out.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parameterTypeTag(params: {
|
|
22
|
+
value: unknown;
|
|
23
|
+
}): string;
|
|
24
|
+
/**
|
|
25
|
+
* Describe the SQL of one operation without executing anything.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* previewOperation({ schema, dialect: "postgres", model: "User", method: "findMany",
|
|
29
|
+
* args: { where: { email: "a@b.test" } } });
|
|
30
|
+
* // → one SELECT with `$1`, parameters reported as ["string"]
|
|
31
|
+
*/
|
|
32
|
+
export declare function previewOperation(params: {
|
|
33
|
+
schema: SchemaIR;
|
|
34
|
+
dialect: Dialect;
|
|
35
|
+
model: string;
|
|
36
|
+
method: QueryMethod;
|
|
37
|
+
args?: Record<string, unknown>;
|
|
38
|
+
relationStrategy?: RelationStrategy;
|
|
39
|
+
clientOptions?: BuilderClientOptions;
|
|
40
|
+
/** Show real parameter values. OFF by default: a preview is not public telemetry. */
|
|
41
|
+
includeParameterValues?: boolean;
|
|
42
|
+
}): OperationPreview;
|
|
43
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/diagnostics/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK1G,OAAO,KAAK,EAAE,gBAAgB,EAAuC,MAAM,YAAY,CAAC;AAKxF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CASnE;AA4CD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,qFAAqF;IACrF,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,GAAG,gBAAgB,CA6HnB"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public shapes for SQL preview and PostgreSQL query diagnostics (EPIC 5).
|
|
3
|
+
*
|
|
4
|
+
* Two invariants run through every type here:
|
|
5
|
+
*
|
|
6
|
+
* - **Cost units are not milliseconds.** `estimatedTotalCost` is the planner's
|
|
7
|
+
* own abstract cost; `actualTotalTimeMs`, `planningTimeMs` and
|
|
8
|
+
* `executionTimeMs` are milliseconds and exist only where the server
|
|
9
|
+
* measured them. Estimated rows and observed rows are likewise separate
|
|
10
|
+
* fields, never merged.
|
|
11
|
+
* - **Nothing here is public telemetry.** Parameters are type tags unless the
|
|
12
|
+
* caller asks for values, and plan conditions are redacted by default —
|
|
13
|
+
* PostgreSQL substitutes literal values into `Index Cond` and `Filter` even
|
|
14
|
+
* when the statement was parameterized.
|
|
15
|
+
*/
|
|
16
|
+
import type { Dialect } from "@vibeorm/schema";
|
|
17
|
+
import type { QueryMethod, RelationStrategy } from "../query-builder.ts";
|
|
18
|
+
/** Why a preview cannot claim to be the whole operation. */
|
|
19
|
+
export type PreviewLimitationCode = "relation-statements-data-dependent" | "nested-writes-data-dependent" | "upsert-fallback-flow" | "batched-statements" | "client-side-post-processing";
|
|
20
|
+
/** One named limitation, with the reason spelled out for a human. */
|
|
21
|
+
export type PreviewLimitation = {
|
|
22
|
+
readonly code: PreviewLimitationCode;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
};
|
|
25
|
+
/** One statement a preview can show in full. */
|
|
26
|
+
export type PreviewStatement = {
|
|
27
|
+
readonly index: number;
|
|
28
|
+
/** `primary` is the statement the operation leads with; `batch` are its known siblings. */
|
|
29
|
+
readonly role: "primary" | "batch";
|
|
30
|
+
readonly kind: string;
|
|
31
|
+
readonly sql: string;
|
|
32
|
+
readonly parameterCount: number;
|
|
33
|
+
/** Redacted type tags (`"string"`, `"date"`, …) unless values were explicitly requested. */
|
|
34
|
+
readonly parameters: readonly string[];
|
|
35
|
+
/** EPIC 1's `queryFingerprint` — the same grouping key telemetry reports. */
|
|
36
|
+
readonly fingerprint: string;
|
|
37
|
+
};
|
|
38
|
+
/** What an operation would send, and what about it cannot be known without data. */
|
|
39
|
+
export type OperationPreview = {
|
|
40
|
+
readonly model: string;
|
|
41
|
+
readonly method: QueryMethod;
|
|
42
|
+
readonly dialect: Dialect;
|
|
43
|
+
readonly statements: readonly PreviewStatement[];
|
|
44
|
+
/** False ⇒ further statements run whose shape or count only the data decides. */
|
|
45
|
+
readonly complete: boolean;
|
|
46
|
+
readonly limitations: readonly PreviewLimitation[];
|
|
47
|
+
readonly relationStrategy: RelationStrategy | null;
|
|
48
|
+
/** Relations this operation loads with their own follow-up statements. */
|
|
49
|
+
readonly relationsLoadedSeparately: readonly string[];
|
|
50
|
+
};
|
|
51
|
+
/** `estimate` is non-executing `EXPLAIN`; `analyze` EXECUTES the statement. */
|
|
52
|
+
export type ExplainMode = "estimate" | "analyze";
|
|
53
|
+
/** One node of a PostgreSQL plan, with estimates and observations kept apart. */
|
|
54
|
+
export type PlanNode = {
|
|
55
|
+
readonly nodeType: string;
|
|
56
|
+
readonly relation?: string;
|
|
57
|
+
readonly alias?: string;
|
|
58
|
+
readonly indexName?: string;
|
|
59
|
+
readonly parentRelationship?: string;
|
|
60
|
+
/** Planner cost units — NOT milliseconds and not comparable across servers. */
|
|
61
|
+
readonly estimatedStartupCost: number;
|
|
62
|
+
readonly estimatedTotalCost: number;
|
|
63
|
+
readonly estimatedRows: number;
|
|
64
|
+
readonly planWidth: number;
|
|
65
|
+
/** Observed, `analyze` only. */
|
|
66
|
+
readonly actualTotalTimeMs?: number;
|
|
67
|
+
readonly actualRows?: number;
|
|
68
|
+
readonly actualLoops?: number;
|
|
69
|
+
readonly rowsRemovedByFilter?: number;
|
|
70
|
+
readonly sharedBlocksHit?: number;
|
|
71
|
+
readonly sharedBlocksRead?: number;
|
|
72
|
+
readonly tempBlocksRead?: number;
|
|
73
|
+
readonly tempBlocksWritten?: number;
|
|
74
|
+
readonly sortMethod?: string;
|
|
75
|
+
/** `Index Cond`, `Filter`, `Sort Key`… — redacted unless literals were requested. */
|
|
76
|
+
readonly conditions: Readonly<Record<string, string>>;
|
|
77
|
+
readonly children: readonly PlanNode[];
|
|
78
|
+
};
|
|
79
|
+
/** The parse result of one `EXPLAIN (FORMAT JSON)` payload. */
|
|
80
|
+
export type ParsedPlan = {
|
|
81
|
+
readonly root: PlanNode;
|
|
82
|
+
readonly nodeCount: number;
|
|
83
|
+
readonly truncated: boolean;
|
|
84
|
+
readonly planningTimeMs?: number;
|
|
85
|
+
readonly executionTimeMs?: number;
|
|
86
|
+
};
|
|
87
|
+
/** The identity a plan was taken under — the difference between a plan and a representative plan. */
|
|
88
|
+
export type PlanContext = {
|
|
89
|
+
readonly currentUser: string;
|
|
90
|
+
readonly sessionUser: string;
|
|
91
|
+
readonly superuser: boolean;
|
|
92
|
+
readonly bypassRls: boolean;
|
|
93
|
+
readonly serverVersionNum: number;
|
|
94
|
+
/** Keys of the row-level-security context bound for this plan (never the values). */
|
|
95
|
+
readonly rlsContextKeys: readonly string[];
|
|
96
|
+
/** False ⇒ this plan is not what a runtime role would see. */
|
|
97
|
+
readonly representative: boolean;
|
|
98
|
+
readonly reason?: string;
|
|
99
|
+
};
|
|
100
|
+
/** A parsed plan plus the context and caveats a reader needs to judge it. */
|
|
101
|
+
export type QueryPlanReport = {
|
|
102
|
+
readonly mode: ExplainMode;
|
|
103
|
+
readonly root: PlanNode;
|
|
104
|
+
readonly nodeCount: number;
|
|
105
|
+
readonly truncated: boolean;
|
|
106
|
+
/** Planner cost units for the whole plan. Never milliseconds. */
|
|
107
|
+
readonly estimatedTotalCostUnits: number;
|
|
108
|
+
readonly planningTimeMs?: number;
|
|
109
|
+
readonly executionTimeMs?: number;
|
|
110
|
+
readonly literalsRedacted: boolean;
|
|
111
|
+
readonly context: PlanContext;
|
|
112
|
+
readonly warnings: readonly string[];
|
|
113
|
+
};
|
|
114
|
+
/** Whether `pg_stat_statements` can be read at all, and by whom. */
|
|
115
|
+
export type WorkloadAvailability = {
|
|
116
|
+
readonly available: boolean;
|
|
117
|
+
readonly installed: boolean;
|
|
118
|
+
readonly schema: string | null;
|
|
119
|
+
readonly installedVersion: string | null;
|
|
120
|
+
readonly serverVersionNum: number;
|
|
121
|
+
/** False ⇒ other roles' statement text reads as `<insufficient privilege>`. */
|
|
122
|
+
readonly readAllStats: boolean;
|
|
123
|
+
readonly reason?: string;
|
|
124
|
+
};
|
|
125
|
+
/** One statement shape's cumulative totals since the collection window opened. */
|
|
126
|
+
export type WorkloadStatement = {
|
|
127
|
+
/** PostgreSQL's own query id. NOT an application fingerprint. */
|
|
128
|
+
readonly queryId: string | null;
|
|
129
|
+
readonly statement: string;
|
|
130
|
+
readonly redacted: boolean;
|
|
131
|
+
readonly calls: number;
|
|
132
|
+
readonly totalExecTimeMs: number;
|
|
133
|
+
readonly meanExecTimeMs: number;
|
|
134
|
+
readonly minExecTimeMs: number;
|
|
135
|
+
readonly maxExecTimeMs: number;
|
|
136
|
+
readonly rows: number;
|
|
137
|
+
readonly sharedBlocksHit: number;
|
|
138
|
+
readonly sharedBlocksRead: number;
|
|
139
|
+
readonly tempBlocksRead: number;
|
|
140
|
+
readonly tempBlocksWritten: number;
|
|
141
|
+
};
|
|
142
|
+
/** A read-only workload snapshot and everything it cannot tell you. */
|
|
143
|
+
export type WorkloadReport = {
|
|
144
|
+
readonly source: "pg_stat_statements";
|
|
145
|
+
readonly availability: WorkloadAvailability;
|
|
146
|
+
readonly collectionWindow: {
|
|
147
|
+
readonly statsReset: string | null;
|
|
148
|
+
readonly known: boolean;
|
|
149
|
+
};
|
|
150
|
+
readonly statements: readonly WorkloadStatement[];
|
|
151
|
+
/** Always `"none"`: no verified correlation between a query id and a fingerprint. */
|
|
152
|
+
readonly correlation: "none";
|
|
153
|
+
readonly notes: readonly string[];
|
|
154
|
+
};
|
|
155
|
+
/** A repeated-statement observation. Suspected, never asserted. */
|
|
156
|
+
export type SuspectedPattern = {
|
|
157
|
+
readonly kind: "suspected-n-plus-one" | "repeated-statement";
|
|
158
|
+
readonly fingerprint: string;
|
|
159
|
+
readonly count: number;
|
|
160
|
+
readonly operationId: string;
|
|
161
|
+
readonly model: string | null;
|
|
162
|
+
readonly method: string;
|
|
163
|
+
readonly totalDurationMs: number;
|
|
164
|
+
readonly evidence: string;
|
|
165
|
+
readonly suspected: true;
|
|
166
|
+
};
|
|
167
|
+
/** One slow operation, straight from EPIC 1's operation events. */
|
|
168
|
+
export type SlowOperation = {
|
|
169
|
+
readonly operationId: string;
|
|
170
|
+
readonly model: string | null;
|
|
171
|
+
readonly method: string;
|
|
172
|
+
readonly durationMs: number;
|
|
173
|
+
readonly statementCount: number;
|
|
174
|
+
};
|
|
175
|
+
/** What a bounded window of operation telemetry suggests. */
|
|
176
|
+
export type TelemetryDiagnosticReport = {
|
|
177
|
+
readonly window: {
|
|
178
|
+
readonly operations: number;
|
|
179
|
+
readonly statements: number;
|
|
180
|
+
readonly bounded: boolean;
|
|
181
|
+
};
|
|
182
|
+
readonly slowOperations: readonly SlowOperation[];
|
|
183
|
+
readonly repeatedStatements: readonly SuspectedPattern[];
|
|
184
|
+
readonly suspectedNPlusOne: readonly SuspectedPattern[];
|
|
185
|
+
};
|
|
186
|
+
/** Facts about one table that a plan alone cannot supply. */
|
|
187
|
+
export type TableFacts = {
|
|
188
|
+
readonly table: string;
|
|
189
|
+
readonly estimatedRows: number;
|
|
190
|
+
readonly tableBytes?: number;
|
|
191
|
+
readonly rlsEnabled?: boolean;
|
|
192
|
+
readonly lastAnalyze?: string | null;
|
|
193
|
+
};
|
|
194
|
+
/** One index that already exists. */
|
|
195
|
+
export type IndexFacts = {
|
|
196
|
+
readonly table: string;
|
|
197
|
+
readonly index: string;
|
|
198
|
+
readonly definition?: string;
|
|
199
|
+
readonly unique?: boolean;
|
|
200
|
+
readonly primary?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/** The closed set of things the analysis is prepared to claim. */
|
|
203
|
+
export type DiagnosticFindingCode = "sequential-scan-on-large-table" | "sequential-scan-on-small-table-not-a-defect" | "row-estimate-off" | "expensive-sort-spilled-to-disk" | "nested-loop-high-loop-count" | "filter-discards-most-rows" | "cannot-explain-waits";
|
|
204
|
+
/** An index a HUMAN may want to review. Never created, never ranked. */
|
|
205
|
+
export type IndexCandidate = {
|
|
206
|
+
readonly table: string;
|
|
207
|
+
readonly predicateContext: string;
|
|
208
|
+
readonly orderContext?: string;
|
|
209
|
+
readonly existingIndexes: readonly string[];
|
|
210
|
+
readonly tradeoff: string;
|
|
211
|
+
};
|
|
212
|
+
/** One deterministic finding, with the measurement it came from. */
|
|
213
|
+
export type DiagnosticFinding = {
|
|
214
|
+
readonly code: DiagnosticFindingCode;
|
|
215
|
+
readonly severity: "info" | "warn";
|
|
216
|
+
readonly node: string;
|
|
217
|
+
readonly relation: string | null;
|
|
218
|
+
readonly evidence: string;
|
|
219
|
+
/** True ⇒ a suggestion for human review, not a conclusion. */
|
|
220
|
+
readonly candidate: boolean;
|
|
221
|
+
readonly indexCandidate?: IndexCandidate;
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/diagnostics/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIzE,4DAA4D;AAC5D,MAAM,MAAM,qBAAqB,GAC7B,oCAAoC,GACpC,8BAA8B,GAC9B,sBAAsB,GACtB,oBAAoB,GACpB,6BAA6B,CAAC;AAElC,qEAAqE;AACrE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAA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AAc,CAAC,EAAE,cAAc,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional PostgreSQL workload statistics from `pg_stat_statements` (EPIC 5).
|
|
3
|
+
*
|
|
4
|
+
* Strictly read-only and strictly gated. This module cannot install the
|
|
5
|
+
* extension, cannot change a server setting, cannot restart anything and cannot
|
|
6
|
+
* reset statistics — the SQL to do any of that does not exist in
|
|
7
|
+
* `@vibeorm/sql`. An absent extension is REPORTED, never provisioned.
|
|
8
|
+
*
|
|
9
|
+
* What this source is not: it has no per-call percentiles (its totals are
|
|
10
|
+
* cumulative since the last reset — percentiles come from EPIC 1's operation
|
|
11
|
+
* histograms), and its `queryid` is PostgreSQL's own normalization, which is
|
|
12
|
+
* NOT the application fingerprint. The two are reported side by side with the
|
|
13
|
+
* uncertainty stated, never joined.
|
|
14
|
+
*/
|
|
15
|
+
import type { Dialect } from "@vibeorm/schema";
|
|
16
|
+
import type { SqlExecutor } from "../adapter.ts";
|
|
17
|
+
import type { WorkloadReport } from "./types.ts";
|
|
18
|
+
/**
|
|
19
|
+
* Read a bounded, read-only snapshot of the database's statement workload.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const report = await readWorkloadStatistics({ executor, dialect: "postgres", limit: 20 });
|
|
23
|
+
* report.availability.installed; // false ⇒ statements is [] and the reason says why
|
|
24
|
+
*/
|
|
25
|
+
export declare function readWorkloadStatistics(params: {
|
|
26
|
+
executor: SqlExecutor;
|
|
27
|
+
dialect: Dialect;
|
|
28
|
+
limit?: number;
|
|
29
|
+
/** Include statement text (still normalized). Off by default. */
|
|
30
|
+
includeStatementText?: boolean;
|
|
31
|
+
}): Promise<WorkloadReport>;
|
|
32
|
+
//# sourceMappingURL=workload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workload.d.ts","sourceRoot":"","sources":["../../src/diagnostics/workload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAwB,cAAc,EAAqB,MAAM,YAAY,CAAC;AA+C1F;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GAAG,OAAO,CAAC,cAAc,CAAC,CAkF1B"}
|