@query-doctor/core 0.10.9 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci/policy.cjs +73 -0
- package/dist/ci/policy.cjs.map +1 -0
- package/dist/ci/policy.d.cts +57 -0
- package/dist/ci/policy.d.cts.map +1 -0
- package/dist/ci/policy.d.mts +57 -0
- package/dist/ci/policy.d.mts.map +1 -0
- package/dist/ci/policy.mjs +70 -0
- package/dist/ci/policy.mjs.map +1 -0
- package/dist/ci/taxonomy.cjs +28 -0
- package/dist/ci/taxonomy.cjs.map +1 -0
- package/dist/ci/taxonomy.d.cts +22 -0
- package/dist/ci/taxonomy.d.cts.map +1 -0
- package/dist/ci/taxonomy.d.mts +22 -0
- package/dist/ci/taxonomy.d.mts.map +1 -0
- package/dist/ci/taxonomy.mjs +26 -0
- package/dist/ci/taxonomy.mjs.map +1 -0
- package/dist/ci/verdict.cjs +117 -0
- package/dist/ci/verdict.cjs.map +1 -0
- package/dist/ci/verdict.d.cts +120 -0
- package/dist/ci/verdict.d.cts.map +1 -0
- package/dist/ci/verdict.d.mts +120 -0
- package/dist/ci/verdict.d.mts.map +1 -0
- package/dist/ci/verdict.mjs +109 -0
- package/dist/ci/verdict.mjs.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +4 -1
- package/dist/schema.cjs +2 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +4 -0
- package/dist/schema.d.cts.map +1 -1
- package/dist/schema.d.mts +4 -0
- package/dist/schema.d.mts.map +1 -1
- package/dist/schema.mjs +2 -0
- package/dist/schema.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/ci/verdict.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The versioned, shared verdict contract (#3497) — the cohesion mechanism for
|
|
8
|
+
* the CI⇄MCP verdict loop (epic #3493). One condition's outcome on a CI run,
|
|
9
|
+
* structured so an agent can *route* it (fix / add a test / escalate) without
|
|
10
|
+
* scraping a build log. Every future condition — coverage gaps, regressions,
|
|
11
|
+
* schema drift, nudges — emits this same shape, so no condition grows its own
|
|
12
|
+
* red/green or its own remediation UX.
|
|
13
|
+
*
|
|
14
|
+
* The same payload is meant to render to the PR comment and to surface in the
|
|
15
|
+
* MCP run object; the surfacing itself is owned by #3106/#3105, so this module
|
|
16
|
+
* defines and validates the contract they consume, plus a reference renderer.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Bump only on a *breaking* change to the shape below, so a consumer can refuse
|
|
20
|
+
* a payload it doesn't understand. Additive, backward-compatible fields do not
|
|
21
|
+
* require a bump.
|
|
22
|
+
*/
|
|
23
|
+
declare const VERDICT_CONTRACT_VERSION = 1;
|
|
24
|
+
/**
|
|
25
|
+
* How honest the run can be about a condition. `pass` is the only clean
|
|
26
|
+
* outcome; every other class is a non-pass the loop must route.
|
|
27
|
+
* `uncertain-conservative-flag` is the deliberate "we could not check this, so
|
|
28
|
+
* we're flagging to be safe" state — kept distinct so the tool's blindness is
|
|
29
|
+
* never dressed up as either a clean pass or a hard failure.
|
|
30
|
+
*/
|
|
31
|
+
declare const VerdictClass: z.ZodEnum<{
|
|
32
|
+
pass: "pass";
|
|
33
|
+
"coverage-gap": "coverage-gap";
|
|
34
|
+
finding: "finding";
|
|
35
|
+
"infra-error": "infra-error";
|
|
36
|
+
"setup-broken": "setup-broken";
|
|
37
|
+
"uncertain-conservative-flag": "uncertain-conservative-flag";
|
|
38
|
+
}>;
|
|
39
|
+
type VerdictClass = z.infer<typeof VerdictClass>;
|
|
40
|
+
/**
|
|
41
|
+
* The kind of action a verdict routes to. The ceiling is `auto-fix`; the floor
|
|
42
|
+
* is `notify-human` — escalate-to-human-with-context, a designed success state
|
|
43
|
+
* rather than a gap. `none` is only for a clean pass.
|
|
44
|
+
*/
|
|
45
|
+
declare const VerdictActionKind: z.ZodEnum<{
|
|
46
|
+
"auto-fix": "auto-fix";
|
|
47
|
+
"add-test": "add-test";
|
|
48
|
+
triage: "triage";
|
|
49
|
+
"notify-human": "notify-human";
|
|
50
|
+
none: "none";
|
|
51
|
+
}>;
|
|
52
|
+
type VerdictActionKind = z.infer<typeof VerdictActionKind>;
|
|
53
|
+
/**
|
|
54
|
+
* A routable next action. `detail` always carries the human- and
|
|
55
|
+
* machine-readable specifics: the fix instruction, the test to add, or — for
|
|
56
|
+
* `notify-human` — the context handed to the person. Modeling "notify human
|
|
57
|
+
* (with context)" as a first-class value, not an absent field, is the point:
|
|
58
|
+
* the escalate-to-human floor is always well-formed, never an absence.
|
|
59
|
+
*/
|
|
60
|
+
declare const VerdictAction: z.ZodObject<{
|
|
61
|
+
kind: z.ZodEnum<{
|
|
62
|
+
"auto-fix": "auto-fix";
|
|
63
|
+
"add-test": "add-test";
|
|
64
|
+
triage: "triage";
|
|
65
|
+
"notify-human": "notify-human";
|
|
66
|
+
none: "none";
|
|
67
|
+
}>;
|
|
68
|
+
detail: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
type VerdictAction = z.infer<typeof VerdictAction>;
|
|
71
|
+
/** A next step / triage action that escalates to a human, carrying context. */
|
|
72
|
+
declare function notifyHuman(context: string): VerdictAction;
|
|
73
|
+
/** The "nothing to do" action, for a clean pass. */
|
|
74
|
+
declare const NO_ACTION: VerdictAction;
|
|
75
|
+
declare const CiVerdict: z.ZodObject<{
|
|
76
|
+
version: z.ZodLiteral<1>;
|
|
77
|
+
condition: z.ZodString;
|
|
78
|
+
verdictClass: z.ZodEnum<{
|
|
79
|
+
pass: "pass";
|
|
80
|
+
"coverage-gap": "coverage-gap";
|
|
81
|
+
finding: "finding";
|
|
82
|
+
"infra-error": "infra-error";
|
|
83
|
+
"setup-broken": "setup-broken";
|
|
84
|
+
"uncertain-conservative-flag": "uncertain-conservative-flag";
|
|
85
|
+
}>;
|
|
86
|
+
reason: z.ZodString;
|
|
87
|
+
nextStep: z.ZodObject<{
|
|
88
|
+
kind: z.ZodEnum<{
|
|
89
|
+
"auto-fix": "auto-fix";
|
|
90
|
+
"add-test": "add-test";
|
|
91
|
+
triage: "triage";
|
|
92
|
+
"notify-human": "notify-human";
|
|
93
|
+
none: "none";
|
|
94
|
+
}>;
|
|
95
|
+
detail: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
triageAction: z.ZodObject<{
|
|
98
|
+
kind: z.ZodEnum<{
|
|
99
|
+
"auto-fix": "auto-fix";
|
|
100
|
+
"add-test": "add-test";
|
|
101
|
+
triage: "triage";
|
|
102
|
+
"notify-human": "notify-human";
|
|
103
|
+
none: "none";
|
|
104
|
+
}>;
|
|
105
|
+
detail: z.ZodString;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
docsUrl: z.ZodOptional<z.ZodString>;
|
|
108
|
+
suggestedMcpTools: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
type CiVerdict = z.infer<typeof CiVerdict>;
|
|
111
|
+
/**
|
|
112
|
+
* Render a verdict to Markdown for a PR comment. Intentionally presentation
|
|
113
|
+
* only: it shows the fields, it does not decide pass/fail (that mapping is the
|
|
114
|
+
* failure taxonomy, #3498). Kept alongside the contract so "the comment renders
|
|
115
|
+
* from the contract" is demonstrably true and ready for the analyzer to import.
|
|
116
|
+
*/
|
|
117
|
+
declare function renderVerdictMarkdown(verdict: CiVerdict): string;
|
|
118
|
+
//#endregion
|
|
119
|
+
export { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown };
|
|
120
|
+
//# sourceMappingURL=verdict.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.d.cts","names":[],"sources":["../../src/ci/verdict.ts"],"mappings":";;;;;;;;AAoBA;;;;;AASA;;;;;;;;;cATa,wBAAA;;;;;AAiBb;;;cARa,YAAA,EAAY,CAAA,CAAA,OAAA;;;;;;;;KAQb,YAAA,GAAe,CAAA,CAAE,KAAA,QAAa,YAAA;;;;;;cAO7B,iBAAA,EAAiB,CAAA,CAAA,OAAA;;;;;;;KAOlB,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,iBAAA;;;;;;;AAS/C;cAAa,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;;;KAId,aAAA,GAAgB,CAAA,CAAE,KAAA,QAAa,aAAA;;iBAG3B,WAAA,CAAY,OAAA,WAAkB,aAAA;;cAKjC,SAAA,EAAW,aAAA;AAAA,cAEX,SAAA,EAAS,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBV,SAAA,GAAY,CAAA,CAAE,KAAA,QAAa,SAAA;;;;;;;iBAgBvB,qBAAA,CAAsB,OAAA,EAAS,SAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/ci/verdict.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The versioned, shared verdict contract (#3497) — the cohesion mechanism for
|
|
8
|
+
* the CI⇄MCP verdict loop (epic #3493). One condition's outcome on a CI run,
|
|
9
|
+
* structured so an agent can *route* it (fix / add a test / escalate) without
|
|
10
|
+
* scraping a build log. Every future condition — coverage gaps, regressions,
|
|
11
|
+
* schema drift, nudges — emits this same shape, so no condition grows its own
|
|
12
|
+
* red/green or its own remediation UX.
|
|
13
|
+
*
|
|
14
|
+
* The same payload is meant to render to the PR comment and to surface in the
|
|
15
|
+
* MCP run object; the surfacing itself is owned by #3106/#3105, so this module
|
|
16
|
+
* defines and validates the contract they consume, plus a reference renderer.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Bump only on a *breaking* change to the shape below, so a consumer can refuse
|
|
20
|
+
* a payload it doesn't understand. Additive, backward-compatible fields do not
|
|
21
|
+
* require a bump.
|
|
22
|
+
*/
|
|
23
|
+
declare const VERDICT_CONTRACT_VERSION = 1;
|
|
24
|
+
/**
|
|
25
|
+
* How honest the run can be about a condition. `pass` is the only clean
|
|
26
|
+
* outcome; every other class is a non-pass the loop must route.
|
|
27
|
+
* `uncertain-conservative-flag` is the deliberate "we could not check this, so
|
|
28
|
+
* we're flagging to be safe" state — kept distinct so the tool's blindness is
|
|
29
|
+
* never dressed up as either a clean pass or a hard failure.
|
|
30
|
+
*/
|
|
31
|
+
declare const VerdictClass: z.ZodEnum<{
|
|
32
|
+
pass: "pass";
|
|
33
|
+
"coverage-gap": "coverage-gap";
|
|
34
|
+
finding: "finding";
|
|
35
|
+
"infra-error": "infra-error";
|
|
36
|
+
"setup-broken": "setup-broken";
|
|
37
|
+
"uncertain-conservative-flag": "uncertain-conservative-flag";
|
|
38
|
+
}>;
|
|
39
|
+
type VerdictClass = z.infer<typeof VerdictClass>;
|
|
40
|
+
/**
|
|
41
|
+
* The kind of action a verdict routes to. The ceiling is `auto-fix`; the floor
|
|
42
|
+
* is `notify-human` — escalate-to-human-with-context, a designed success state
|
|
43
|
+
* rather than a gap. `none` is only for a clean pass.
|
|
44
|
+
*/
|
|
45
|
+
declare const VerdictActionKind: z.ZodEnum<{
|
|
46
|
+
"auto-fix": "auto-fix";
|
|
47
|
+
"add-test": "add-test";
|
|
48
|
+
triage: "triage";
|
|
49
|
+
"notify-human": "notify-human";
|
|
50
|
+
none: "none";
|
|
51
|
+
}>;
|
|
52
|
+
type VerdictActionKind = z.infer<typeof VerdictActionKind>;
|
|
53
|
+
/**
|
|
54
|
+
* A routable next action. `detail` always carries the human- and
|
|
55
|
+
* machine-readable specifics: the fix instruction, the test to add, or — for
|
|
56
|
+
* `notify-human` — the context handed to the person. Modeling "notify human
|
|
57
|
+
* (with context)" as a first-class value, not an absent field, is the point:
|
|
58
|
+
* the escalate-to-human floor is always well-formed, never an absence.
|
|
59
|
+
*/
|
|
60
|
+
declare const VerdictAction: z.ZodObject<{
|
|
61
|
+
kind: z.ZodEnum<{
|
|
62
|
+
"auto-fix": "auto-fix";
|
|
63
|
+
"add-test": "add-test";
|
|
64
|
+
triage: "triage";
|
|
65
|
+
"notify-human": "notify-human";
|
|
66
|
+
none: "none";
|
|
67
|
+
}>;
|
|
68
|
+
detail: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
type VerdictAction = z.infer<typeof VerdictAction>;
|
|
71
|
+
/** A next step / triage action that escalates to a human, carrying context. */
|
|
72
|
+
declare function notifyHuman(context: string): VerdictAction;
|
|
73
|
+
/** The "nothing to do" action, for a clean pass. */
|
|
74
|
+
declare const NO_ACTION: VerdictAction;
|
|
75
|
+
declare const CiVerdict: z.ZodObject<{
|
|
76
|
+
version: z.ZodLiteral<1>;
|
|
77
|
+
condition: z.ZodString;
|
|
78
|
+
verdictClass: z.ZodEnum<{
|
|
79
|
+
pass: "pass";
|
|
80
|
+
"coverage-gap": "coverage-gap";
|
|
81
|
+
finding: "finding";
|
|
82
|
+
"infra-error": "infra-error";
|
|
83
|
+
"setup-broken": "setup-broken";
|
|
84
|
+
"uncertain-conservative-flag": "uncertain-conservative-flag";
|
|
85
|
+
}>;
|
|
86
|
+
reason: z.ZodString;
|
|
87
|
+
nextStep: z.ZodObject<{
|
|
88
|
+
kind: z.ZodEnum<{
|
|
89
|
+
"auto-fix": "auto-fix";
|
|
90
|
+
"add-test": "add-test";
|
|
91
|
+
triage: "triage";
|
|
92
|
+
"notify-human": "notify-human";
|
|
93
|
+
none: "none";
|
|
94
|
+
}>;
|
|
95
|
+
detail: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
triageAction: z.ZodObject<{
|
|
98
|
+
kind: z.ZodEnum<{
|
|
99
|
+
"auto-fix": "auto-fix";
|
|
100
|
+
"add-test": "add-test";
|
|
101
|
+
triage: "triage";
|
|
102
|
+
"notify-human": "notify-human";
|
|
103
|
+
none: "none";
|
|
104
|
+
}>;
|
|
105
|
+
detail: z.ZodString;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
docsUrl: z.ZodOptional<z.ZodString>;
|
|
108
|
+
suggestedMcpTools: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
type CiVerdict = z.infer<typeof CiVerdict>;
|
|
111
|
+
/**
|
|
112
|
+
* Render a verdict to Markdown for a PR comment. Intentionally presentation
|
|
113
|
+
* only: it shows the fields, it does not decide pass/fail (that mapping is the
|
|
114
|
+
* failure taxonomy, #3498). Kept alongside the contract so "the comment renders
|
|
115
|
+
* from the contract" is demonstrably true and ready for the analyzer to import.
|
|
116
|
+
*/
|
|
117
|
+
declare function renderVerdictMarkdown(verdict: CiVerdict): string;
|
|
118
|
+
//#endregion
|
|
119
|
+
export { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown };
|
|
120
|
+
//# sourceMappingURL=verdict.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.d.mts","names":[],"sources":["../../src/ci/verdict.ts"],"mappings":";;;;;;;;AAoBA;;;;;AASA;;;;;;;;;cATa,wBAAA;;;;;AAiBb;;;cARa,YAAA,EAAY,CAAA,CAAA,OAAA;;;;;;;;KAQb,YAAA,GAAe,CAAA,CAAE,KAAA,QAAa,YAAA;;;;;;cAO7B,iBAAA,EAAiB,CAAA,CAAA,OAAA;;;;;;;KAOlB,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,iBAAA;;;;;;;AAS/C;cAAa,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;;;KAId,aAAA,GAAgB,CAAA,CAAE,KAAA,QAAa,aAAA;;iBAG3B,WAAA,CAAY,OAAA,WAAkB,aAAA;;cAKjC,SAAA,EAAW,aAAA;AAAA,cAEX,SAAA,EAAS,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBV,SAAA,GAAY,CAAA,CAAE,KAAA,QAAa,SAAA;;;;;;;iBAgBvB,qBAAA,CAAsB,OAAA,EAAS,SAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/ci/verdict.ts
|
|
4
|
+
/**
|
|
5
|
+
* The versioned, shared verdict contract (#3497) — the cohesion mechanism for
|
|
6
|
+
* the CI⇄MCP verdict loop (epic #3493). One condition's outcome on a CI run,
|
|
7
|
+
* structured so an agent can *route* it (fix / add a test / escalate) without
|
|
8
|
+
* scraping a build log. Every future condition — coverage gaps, regressions,
|
|
9
|
+
* schema drift, nudges — emits this same shape, so no condition grows its own
|
|
10
|
+
* red/green or its own remediation UX.
|
|
11
|
+
*
|
|
12
|
+
* The same payload is meant to render to the PR comment and to surface in the
|
|
13
|
+
* MCP run object; the surfacing itself is owned by #3106/#3105, so this module
|
|
14
|
+
* defines and validates the contract they consume, plus a reference renderer.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Bump only on a *breaking* change to the shape below, so a consumer can refuse
|
|
18
|
+
* a payload it doesn't understand. Additive, backward-compatible fields do not
|
|
19
|
+
* require a bump.
|
|
20
|
+
*/
|
|
21
|
+
const VERDICT_CONTRACT_VERSION = 1;
|
|
22
|
+
/**
|
|
23
|
+
* How honest the run can be about a condition. `pass` is the only clean
|
|
24
|
+
* outcome; every other class is a non-pass the loop must route.
|
|
25
|
+
* `uncertain-conservative-flag` is the deliberate "we could not check this, so
|
|
26
|
+
* we're flagging to be safe" state — kept distinct so the tool's blindness is
|
|
27
|
+
* never dressed up as either a clean pass or a hard failure.
|
|
28
|
+
*/
|
|
29
|
+
const VerdictClass = z.enum([
|
|
30
|
+
"pass",
|
|
31
|
+
"coverage-gap",
|
|
32
|
+
"finding",
|
|
33
|
+
"infra-error",
|
|
34
|
+
"setup-broken",
|
|
35
|
+
"uncertain-conservative-flag"
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* The kind of action a verdict routes to. The ceiling is `auto-fix`; the floor
|
|
39
|
+
* is `notify-human` — escalate-to-human-with-context, a designed success state
|
|
40
|
+
* rather than a gap. `none` is only for a clean pass.
|
|
41
|
+
*/
|
|
42
|
+
const VerdictActionKind = z.enum([
|
|
43
|
+
"auto-fix",
|
|
44
|
+
"add-test",
|
|
45
|
+
"triage",
|
|
46
|
+
"notify-human",
|
|
47
|
+
"none"
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* A routable next action. `detail` always carries the human- and
|
|
51
|
+
* machine-readable specifics: the fix instruction, the test to add, or — for
|
|
52
|
+
* `notify-human` — the context handed to the person. Modeling "notify human
|
|
53
|
+
* (with context)" as a first-class value, not an absent field, is the point:
|
|
54
|
+
* the escalate-to-human floor is always well-formed, never an absence.
|
|
55
|
+
*/
|
|
56
|
+
const VerdictAction = z.object({
|
|
57
|
+
kind: VerdictActionKind,
|
|
58
|
+
detail: z.string()
|
|
59
|
+
});
|
|
60
|
+
/** A next step / triage action that escalates to a human, carrying context. */
|
|
61
|
+
function notifyHuman(context) {
|
|
62
|
+
return {
|
|
63
|
+
kind: "notify-human",
|
|
64
|
+
detail: context
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** The "nothing to do" action, for a clean pass. */
|
|
68
|
+
const NO_ACTION = {
|
|
69
|
+
kind: "none",
|
|
70
|
+
detail: ""
|
|
71
|
+
};
|
|
72
|
+
const CiVerdict = z.object({
|
|
73
|
+
version: z.literal(1),
|
|
74
|
+
condition: z.string().min(1),
|
|
75
|
+
verdictClass: VerdictClass,
|
|
76
|
+
reason: z.string().min(1),
|
|
77
|
+
nextStep: VerdictAction,
|
|
78
|
+
triageAction: VerdictAction,
|
|
79
|
+
docsUrl: z.string().url().optional(),
|
|
80
|
+
suggestedMcpTools: z.array(z.string()).default([])
|
|
81
|
+
});
|
|
82
|
+
const ACTION_LABEL = {
|
|
83
|
+
"auto-fix": "Fix",
|
|
84
|
+
"add-test": "Add a test",
|
|
85
|
+
triage: "Triage",
|
|
86
|
+
"notify-human": "Notify a human",
|
|
87
|
+
none: "No action"
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Render a verdict to Markdown for a PR comment. Intentionally presentation
|
|
91
|
+
* only: it shows the fields, it does not decide pass/fail (that mapping is the
|
|
92
|
+
* failure taxonomy, #3498). Kept alongside the contract so "the comment renders
|
|
93
|
+
* from the contract" is demonstrably true and ready for the analyzer to import.
|
|
94
|
+
*/
|
|
95
|
+
function renderVerdictMarkdown(verdict) {
|
|
96
|
+
const parts = [`**${verdict.condition}** — ${verdict.reason}`];
|
|
97
|
+
if (verdict.nextStep.kind !== "none") parts.push(`**Next step (${ACTION_LABEL[verdict.nextStep.kind]}):** ${verdict.nextStep.detail}`);
|
|
98
|
+
if (verdict.triageAction.kind !== "none") parts.push(`**Triage (${ACTION_LABEL[verdict.triageAction.kind]}):** ${verdict.triageAction.detail}`);
|
|
99
|
+
if (verdict.suggestedMcpTools.length > 0) {
|
|
100
|
+
const tools = verdict.suggestedMcpTools.map((t) => `\`${t}\``).join(", ");
|
|
101
|
+
parts.push(`**MCP tools:** ${tools}`);
|
|
102
|
+
}
|
|
103
|
+
if (verdict.docsUrl) parts.push(`[Learn more](${verdict.docsUrl})`);
|
|
104
|
+
return parts.join("\n\n");
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=verdict.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.mjs","names":[],"sources":["../../src/ci/verdict.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * The versioned, shared verdict contract (#3497) — the cohesion mechanism for\n * the CI⇄MCP verdict loop (epic #3493). One condition's outcome on a CI run,\n * structured so an agent can *route* it (fix / add a test / escalate) without\n * scraping a build log. Every future condition — coverage gaps, regressions,\n * schema drift, nudges — emits this same shape, so no condition grows its own\n * red/green or its own remediation UX.\n *\n * The same payload is meant to render to the PR comment and to surface in the\n * MCP run object; the surfacing itself is owned by #3106/#3105, so this module\n * defines and validates the contract they consume, plus a reference renderer.\n */\n\n/**\n * Bump only on a *breaking* change to the shape below, so a consumer can refuse\n * a payload it doesn't understand. Additive, backward-compatible fields do not\n * require a bump.\n */\nexport const VERDICT_CONTRACT_VERSION = 1;\n\n/**\n * How honest the run can be about a condition. `pass` is the only clean\n * outcome; every other class is a non-pass the loop must route.\n * `uncertain-conservative-flag` is the deliberate \"we could not check this, so\n * we're flagging to be safe\" state — kept distinct so the tool's blindness is\n * never dressed up as either a clean pass or a hard failure.\n */\nexport const VerdictClass = z.enum([\n \"pass\",\n \"coverage-gap\",\n \"finding\",\n \"infra-error\",\n \"setup-broken\",\n \"uncertain-conservative-flag\",\n]);\nexport type VerdictClass = z.infer<typeof VerdictClass>;\n\n/**\n * The kind of action a verdict routes to. The ceiling is `auto-fix`; the floor\n * is `notify-human` — escalate-to-human-with-context, a designed success state\n * rather than a gap. `none` is only for a clean pass.\n */\nexport const VerdictActionKind = z.enum([\n \"auto-fix\",\n \"add-test\",\n \"triage\",\n \"notify-human\",\n \"none\",\n]);\nexport type VerdictActionKind = z.infer<typeof VerdictActionKind>;\n\n/**\n * A routable next action. `detail` always carries the human- and\n * machine-readable specifics: the fix instruction, the test to add, or — for\n * `notify-human` — the context handed to the person. Modeling \"notify human\n * (with context)\" as a first-class value, not an absent field, is the point:\n * the escalate-to-human floor is always well-formed, never an absence.\n */\nexport const VerdictAction = z.object({\n kind: VerdictActionKind,\n detail: z.string(),\n});\nexport type VerdictAction = z.infer<typeof VerdictAction>;\n\n/** A next step / triage action that escalates to a human, carrying context. */\nexport function notifyHuman(context: string): VerdictAction {\n return { kind: \"notify-human\", detail: context };\n}\n\n/** The \"nothing to do\" action, for a clean pass. */\nexport const NO_ACTION: VerdictAction = { kind: \"none\", detail: \"\" };\n\nexport const CiVerdict = z.object({\n version: z.literal(VERDICT_CONTRACT_VERSION),\n /** The condition evaluated, e.g. \"untested-data-access\", \"regression-beyond-threshold\". */\n condition: z.string().min(1),\n verdictClass: VerdictClass,\n /** Plain-language why, honest about the tool's epistemic state. */\n reason: z.string().min(1),\n /** The best-available next step; `notify-human` is a valid, well-formed value. */\n nextStep: VerdictAction,\n /** The non-fix exit — triage/acknowledge, or escalate to a human. */\n triageAction: VerdictAction,\n /** Deep link to the relevant guide, when one applies. */\n docsUrl: z.string().url().optional(),\n /** MCP tools an agent should reach for to act on this verdict. */\n suggestedMcpTools: z.array(z.string()).default([]),\n});\nexport type CiVerdict = z.infer<typeof CiVerdict>;\n\nconst ACTION_LABEL: Record<VerdictActionKind, string> = {\n \"auto-fix\": \"Fix\",\n \"add-test\": \"Add a test\",\n triage: \"Triage\",\n \"notify-human\": \"Notify a human\",\n none: \"No action\",\n};\n\n/**\n * Render a verdict to Markdown for a PR comment. Intentionally presentation\n * only: it shows the fields, it does not decide pass/fail (that mapping is the\n * failure taxonomy, #3498). Kept alongside the contract so \"the comment renders\n * from the contract\" is demonstrably true and ready for the analyzer to import.\n */\nexport function renderVerdictMarkdown(verdict: CiVerdict): string {\n const parts: string[] = [`**${verdict.condition}** — ${verdict.reason}`];\n if (verdict.nextStep.kind !== \"none\") {\n parts.push(\n `**Next step (${ACTION_LABEL[verdict.nextStep.kind]}):** ${verdict.nextStep.detail}`,\n );\n }\n if (verdict.triageAction.kind !== \"none\") {\n parts.push(\n `**Triage (${ACTION_LABEL[verdict.triageAction.kind]}):** ${verdict.triageAction.detail}`,\n );\n }\n if (verdict.suggestedMcpTools.length > 0) {\n const tools = verdict.suggestedMcpTools.map((t) => `\\`${t}\\``).join(\",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aAAa,MAAM,OAAO,QAAQ,aAAa,SAClF;AAEH,KAAI,QAAQ,kBAAkB,SAAS,GAAG;EACxC,MAAM,QAAQ,QAAQ,kBAAkB,KAAK,MAAM,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK;AACzE,QAAM,KAAK,kBAAkB,QAAQ;;AAEvC,KAAI,QAAQ,QACV,OAAM,KAAK,gBAAgB,QAAQ,QAAQ,GAAG;AAEhD,QAAO,MAAM,KAAK,OAAO"}
|
package/dist/index.cjs
CHANGED
|
@@ -20,11 +20,16 @@ const require_build_action_plan = require("./action-plan/build-action-plan.cjs")
|
|
|
20
20
|
const require_sentry = require("./sentry.cjs");
|
|
21
21
|
const require_query = require("./query.cjs");
|
|
22
22
|
const require_query_findings = require("./findings/query-findings.cjs");
|
|
23
|
+
const require_verdict = require("./ci/verdict.cjs");
|
|
24
|
+
const require_taxonomy = require("./ci/taxonomy.cjs");
|
|
25
|
+
const require_policy = require("./ci/policy.cjs");
|
|
23
26
|
exports.Analyzer = require_analyzer.Analyzer;
|
|
27
|
+
exports.CiVerdict = require_verdict.CiVerdict;
|
|
24
28
|
exports.CombinedExport = require_dump.CombinedExport;
|
|
25
29
|
exports.ComputedColumnStats = require_statistics.ComputedColumnStats;
|
|
26
30
|
exports.ComputedReltuples = require_statistics.ComputedReltuples;
|
|
27
31
|
exports.ComputedStats = require_statistics.ComputedStats;
|
|
32
|
+
exports.DEFAULT_CONDITION_POLICIES = require_policy.DEFAULT_CONDITION_POLICIES;
|
|
28
33
|
exports.DUMP_STATS_SQL = require_statistics.DUMP_STATS_SQL;
|
|
29
34
|
exports.ExportedQuery = require_dump.ExportedQuery;
|
|
30
35
|
exports.ExportedStats = require_statistics.ExportedStats;
|
|
@@ -32,6 +37,7 @@ exports.ExportedStatsColumns = require_statistics.ExportedStatsColumns;
|
|
|
32
37
|
exports.ExportedStatsIndex = require_statistics.ExportedStatsIndex;
|
|
33
38
|
exports.ExportedStatsStatistics = require_statistics.ExportedStatsStatistics;
|
|
34
39
|
exports.ExportedStatsV1 = require_statistics.ExportedStatsV1;
|
|
40
|
+
exports.FALLBACK_POLICY = require_policy.FALLBACK_POLICY;
|
|
35
41
|
exports.FullSchema = require_schema.FullSchema;
|
|
36
42
|
exports.FullSchemaColumn = require_schema.FullSchemaColumn;
|
|
37
43
|
exports.FullSchemaCompositeAttribute = require_schema.FullSchemaCompositeAttribute;
|
|
@@ -47,6 +53,7 @@ exports.FullSchemaType = require_schema.FullSchemaType;
|
|
|
47
53
|
exports.FullSchemaTypeConstraint = require_schema.FullSchemaTypeConstraint;
|
|
48
54
|
exports.FullSchemaView = require_schema.FullSchemaView;
|
|
49
55
|
exports.IndexOptimizer = require_genalgo.IndexOptimizer;
|
|
56
|
+
exports.NO_ACTION = require_verdict.NO_ACTION;
|
|
50
57
|
exports.OptimizedQuery = require_query.OptimizedQuery;
|
|
51
58
|
exports.PROCEED = require_genalgo.PROCEED;
|
|
52
59
|
exports.PgIdentifier = require_pg_identifier.PgIdentifier;
|
|
@@ -59,22 +66,33 @@ exports.SKIP = require_genalgo.SKIP;
|
|
|
59
66
|
exports.Statistics = require_statistics.Statistics;
|
|
60
67
|
exports.StatisticsMode = require_statistics.StatisticsMode;
|
|
61
68
|
exports.StatisticsSource = require_statistics.StatisticsSource;
|
|
69
|
+
exports.VERDICT_CONTRACT_VERSION = require_verdict.VERDICT_CONTRACT_VERSION;
|
|
70
|
+
exports.VerdictAction = require_verdict.VerdictAction;
|
|
71
|
+
exports.VerdictActionKind = require_verdict.VerdictActionKind;
|
|
72
|
+
exports.VerdictClass = require_verdict.VerdictClass;
|
|
62
73
|
exports.aggregateIndexRecommendations = require_aggregate_index_recommendations.aggregateIndexRecommendations;
|
|
63
74
|
exports.analyzeQueryFindings = require_query_findings.analyzeQueryFindings;
|
|
64
75
|
exports.buildActionPlan = require_build_action_plan.buildActionPlan;
|
|
65
76
|
exports.combinedDumpSql = require_dump.combinedDumpSql;
|
|
66
77
|
exports.compactSelectList = require_display_query.compactSelectList;
|
|
78
|
+
exports.conclusionForVerdict = require_taxonomy.conclusionForVerdict;
|
|
79
|
+
exports.conclusionForVerdictClass = require_taxonomy.conclusionForVerdictClass;
|
|
67
80
|
exports.deriveSentryEnvironment = require_sentry.deriveSentryEnvironment;
|
|
68
81
|
exports.dropIndex = require_database.dropIndex;
|
|
69
82
|
exports.dumpQueriesSql = require_dump.dumpQueriesSql;
|
|
70
83
|
exports.dumpSchema = require_schema.dumpSchema;
|
|
84
|
+
exports.evaluateRun = require_policy.evaluateRun;
|
|
71
85
|
exports.groupDuplicateIndexes = require_indexes.groupDuplicateIndexes;
|
|
72
86
|
exports.groupIndexesByCoverage = require_index_coverage.groupIndexesByCoverage;
|
|
73
87
|
exports.ignoredIdentifier = require_analyzer.ignoredIdentifier;
|
|
74
88
|
exports.indexCovers = require_index_coverage.indexCovers;
|
|
89
|
+
exports.isBlocking = require_taxonomy.isBlocking;
|
|
75
90
|
exports.isIndexProbablyDroppable = require_indexes.isIndexProbablyDroppable;
|
|
76
91
|
exports.isIndexSupported = require_indexes.isIndexSupported;
|
|
77
92
|
exports.isTestFilePath = require_test_origin.isTestFilePath;
|
|
78
93
|
exports.isTestOriginQuery = require_test_origin.isTestOriginQuery;
|
|
79
94
|
exports.normalizedFingerprint = require_normalized_fingerprint.normalizedFingerprint;
|
|
95
|
+
exports.notifyHuman = require_verdict.notifyHuman;
|
|
80
96
|
exports.parseNudges = require_nudges.parseNudges;
|
|
97
|
+
exports.policyFor = require_policy.policyFor;
|
|
98
|
+
exports.renderVerdictMarkdown = require_verdict.renderVerdictMarkdown;
|
package/dist/index.d.cts
CHANGED
|
@@ -21,4 +21,7 @@ import { ActionPlanNudgeQuery, ActionableStep, AffectedQueryCost, CostReduction,
|
|
|
21
21
|
import { deriveSentryEnvironment } from "./sentry.cjs";
|
|
22
22
|
import { ClientApi, ConnectionMode, ExtensionPresence, IndexDefinition, RepoConfig, ServerApi, UnauthenticatedServerApi } from "./websocket-server.cjs";
|
|
23
23
|
import { QueryFinding, QueryFindingCode, QueryFindingSeverity, analyzeQueryFindings } from "./findings/query-findings.cjs";
|
|
24
|
-
|
|
24
|
+
import { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown } from "./ci/verdict.cjs";
|
|
25
|
+
import { CiConclusion, conclusionForVerdict, conclusionForVerdictClass, isBlocking } from "./ci/taxonomy.cjs";
|
|
26
|
+
import { ConditionPolicy, ConditionResult, DEFAULT_CONDITION_POLICIES, FALLBACK_POLICY, RepoPolicyConfig, ResolvedCondition, RunEvaluation, evaluateRun, policyFor } from "./ci/policy.cjs";
|
|
27
|
+
export { ActionPlanNudgeQuery, ActionPlanQuery, ActionableStep, AffectedQueryCost, AggregatedIndexRecommendation, AnalysisResult, Analyzer, CiConclusion, CiVerdict, ClientApi, ColumnMetadata, CombinedExport, CompactSelectListOptions, ComputedColumnStats, ComputedReltuples, ComputedStats, ConditionPolicy, ConditionResult, ConnectionMode, CostReduction, DEFAULT_CONDITION_POLICIES, DUMP_STATS_SQL, DatabaseDriver, DiscoveredColumnReference, DomainLabel, DuplicateIndexGroup, ExportedQuery, ExportedStats, ExportedStatsColumns, ExportedStatsIndex, ExportedStatsStatistics, ExportedStatsV1, ExtensionPresence, FALLBACK_POLICY, FingerprintFn, FullSchema, FullSchemaColumn, FullSchemaCompositeAttribute, FullSchemaConstraint, FullSchemaExtension, FullSchemaFunction, FullSchemaIncludedColumn, FullSchemaIndex, FullSchemaKeyColumn, FullSchemaTable, FullSchemaTrigger, FullSchemaType, FullSchemaTypeConstraint, FullSchemaView, IndexAction, IndexDefinition, IndexGroup, IndexIdentifier, IndexOptimizer, IndexRecommendation, IndexToCreate, JsonbOperator, LiveQueryOptimization, NO_ACTION, Nudge, NudgeFinding, OptimizationResult, OptimizeResult, OptimizedQuery, PROCEED, Parameter, Parser, Path, PermutedIndexCandidate, PgIdentifier, Postgres, PostgresConnectionInput, PostgresExplainResult, PostgresExplainStage, PostgresExplainStageCommon, PostgresExplainStageSchema, PostgresFactory, PostgresQueryBuilder, PostgresQueryBuilderCommand, PostgresStage, PostgresStageId, PostgresTransaction, PostgresVersion, PssRewriter, QueryFinding, QueryFindingCode, QueryFindingSeverity, QueryHash, QuerySource, RecentQuery, RegressionBreach, RepoConfig, RepoPolicyConfig, ResolvedCondition, RootIndexCandidate, RunEvaluation, SKIP, SQLCommenterExtraction, SQLCommenterTag, SerializeResult, ServerApi, SortContext, StatementType, Statistics, StatisticsMode, StatisticsSource, TableMetadata, TableReference, TableStats, UnauthenticatedServerApi, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, aggregateIndexRecommendations, analyzeQueryFindings, buildActionPlan, combinedDumpSql, compactSelectList, conclusionForVerdict, conclusionForVerdictClass, deriveSentryEnvironment, dropIndex, dumpQueriesSql, dumpSchema, evaluateRun, groupDuplicateIndexes, groupIndexesByCoverage, ignoredIdentifier, indexCovers, isBlocking, isIndexProbablyDroppable, isIndexSupported, isTestFilePath, isTestOriginQuery, normalizedFingerprint, notifyHuman, parseNudges, policyFor, renderVerdictMarkdown };
|
package/dist/index.d.mts
CHANGED
|
@@ -21,4 +21,7 @@ import { ActionPlanNudgeQuery, ActionableStep, AffectedQueryCost, CostReduction,
|
|
|
21
21
|
import { deriveSentryEnvironment } from "./sentry.mjs";
|
|
22
22
|
import { ClientApi, ConnectionMode, ExtensionPresence, IndexDefinition, RepoConfig, ServerApi, UnauthenticatedServerApi } from "./websocket-server.mjs";
|
|
23
23
|
import { QueryFinding, QueryFindingCode, QueryFindingSeverity, analyzeQueryFindings } from "./findings/query-findings.mjs";
|
|
24
|
-
|
|
24
|
+
import { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown } from "./ci/verdict.mjs";
|
|
25
|
+
import { CiConclusion, conclusionForVerdict, conclusionForVerdictClass, isBlocking } from "./ci/taxonomy.mjs";
|
|
26
|
+
import { ConditionPolicy, ConditionResult, DEFAULT_CONDITION_POLICIES, FALLBACK_POLICY, RepoPolicyConfig, ResolvedCondition, RunEvaluation, evaluateRun, policyFor } from "./ci/policy.mjs";
|
|
27
|
+
export { ActionPlanNudgeQuery, ActionPlanQuery, ActionableStep, AffectedQueryCost, AggregatedIndexRecommendation, AnalysisResult, Analyzer, CiConclusion, CiVerdict, ClientApi, ColumnMetadata, CombinedExport, CompactSelectListOptions, ComputedColumnStats, ComputedReltuples, ComputedStats, ConditionPolicy, ConditionResult, ConnectionMode, CostReduction, DEFAULT_CONDITION_POLICIES, DUMP_STATS_SQL, DatabaseDriver, DiscoveredColumnReference, DomainLabel, DuplicateIndexGroup, ExportedQuery, ExportedStats, ExportedStatsColumns, ExportedStatsIndex, ExportedStatsStatistics, ExportedStatsV1, ExtensionPresence, FALLBACK_POLICY, FingerprintFn, FullSchema, FullSchemaColumn, FullSchemaCompositeAttribute, FullSchemaConstraint, FullSchemaExtension, FullSchemaFunction, FullSchemaIncludedColumn, FullSchemaIndex, FullSchemaKeyColumn, FullSchemaTable, FullSchemaTrigger, FullSchemaType, FullSchemaTypeConstraint, FullSchemaView, IndexAction, IndexDefinition, IndexGroup, IndexIdentifier, IndexOptimizer, IndexRecommendation, IndexToCreate, JsonbOperator, LiveQueryOptimization, NO_ACTION, Nudge, NudgeFinding, OptimizationResult, OptimizeResult, OptimizedQuery, PROCEED, Parameter, Parser, Path, PermutedIndexCandidate, PgIdentifier, Postgres, PostgresConnectionInput, PostgresExplainResult, PostgresExplainStage, PostgresExplainStageCommon, PostgresExplainStageSchema, PostgresFactory, PostgresQueryBuilder, PostgresQueryBuilderCommand, PostgresStage, PostgresStageId, PostgresTransaction, PostgresVersion, PssRewriter, QueryFinding, QueryFindingCode, QueryFindingSeverity, QueryHash, QuerySource, RecentQuery, RegressionBreach, RepoConfig, RepoPolicyConfig, ResolvedCondition, RootIndexCandidate, RunEvaluation, SKIP, SQLCommenterExtraction, SQLCommenterTag, SerializeResult, ServerApi, SortContext, StatementType, Statistics, StatisticsMode, StatisticsSource, TableMetadata, TableReference, TableStats, UnauthenticatedServerApi, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, aggregateIndexRecommendations, analyzeQueryFindings, buildActionPlan, combinedDumpSql, compactSelectList, conclusionForVerdict, conclusionForVerdictClass, deriveSentryEnvironment, dropIndex, dumpQueriesSql, dumpSchema, evaluateRun, groupDuplicateIndexes, groupIndexesByCoverage, ignoredIdentifier, indexCovers, isBlocking, isIndexProbablyDroppable, isIndexSupported, isTestFilePath, isTestOriginQuery, normalizedFingerprint, notifyHuman, parseNudges, policyFor, renderVerdictMarkdown };
|
package/dist/index.mjs
CHANGED
|
@@ -19,4 +19,7 @@ import { buildActionPlan } from "./action-plan/build-action-plan.mjs";
|
|
|
19
19
|
import { deriveSentryEnvironment } from "./sentry.mjs";
|
|
20
20
|
import { OptimizedQuery, RecentQuery } from "./query.mjs";
|
|
21
21
|
import { analyzeQueryFindings } from "./findings/query-findings.mjs";
|
|
22
|
-
|
|
22
|
+
import { CiVerdict, NO_ACTION, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, notifyHuman, renderVerdictMarkdown } from "./ci/verdict.mjs";
|
|
23
|
+
import { conclusionForVerdict, conclusionForVerdictClass, isBlocking } from "./ci/taxonomy.mjs";
|
|
24
|
+
import { DEFAULT_CONDITION_POLICIES, FALLBACK_POLICY, evaluateRun, policyFor } from "./ci/policy.mjs";
|
|
25
|
+
export { Analyzer, CiVerdict, CombinedExport, ComputedColumnStats, ComputedReltuples, ComputedStats, DEFAULT_CONDITION_POLICIES, DUMP_STATS_SQL, ExportedQuery, ExportedStats, ExportedStatsColumns, ExportedStatsIndex, ExportedStatsStatistics, ExportedStatsV1, FALLBACK_POLICY, FullSchema, FullSchemaColumn, FullSchemaCompositeAttribute, FullSchemaConstraint, FullSchemaExtension, FullSchemaFunction, FullSchemaIncludedColumn, FullSchemaIndex, FullSchemaKeyColumn, FullSchemaTable, FullSchemaTrigger, FullSchemaType, FullSchemaTypeConstraint, FullSchemaView, IndexOptimizer, NO_ACTION, OptimizedQuery, PROCEED, PgIdentifier, PostgresExplainStageSchema, PostgresQueryBuilder, PostgresVersion, PssRewriter, RecentQuery, SKIP, Statistics, StatisticsMode, StatisticsSource, VERDICT_CONTRACT_VERSION, VerdictAction, VerdictActionKind, VerdictClass, aggregateIndexRecommendations, analyzeQueryFindings, buildActionPlan, combinedDumpSql, compactSelectList, conclusionForVerdict, conclusionForVerdictClass, deriveSentryEnvironment, dropIndex, dumpQueriesSql, dumpSchema, evaluateRun, groupDuplicateIndexes, groupIndexesByCoverage, ignoredIdentifier, indexCovers, isBlocking, isIndexProbablyDroppable, isIndexSupported, isTestFilePath, isTestOriginQuery, normalizedFingerprint, notifyHuman, parseNudges, policyFor, renderVerdictMarkdown };
|
package/dist/schema.cjs
CHANGED
|
@@ -93,6 +93,7 @@ const FullSchemaFunction = zod.z.object({
|
|
|
93
93
|
definition: zod.z.string()
|
|
94
94
|
});
|
|
95
95
|
const FullSchemaExtension = zod.z.object({
|
|
96
|
+
type: zod.z.literal("extension"),
|
|
96
97
|
extensionName: zod.z.string(),
|
|
97
98
|
version: zod.z.string(),
|
|
98
99
|
schemaName: Identifier
|
|
@@ -132,6 +133,7 @@ const FullSchemaType = zod.z.object({
|
|
|
132
133
|
compositeAttributes: zod.z.array(FullSchemaCompositeAttribute).optional()
|
|
133
134
|
});
|
|
134
135
|
const FullSchemaTrigger = zod.z.object({
|
|
136
|
+
type: zod.z.literal("trigger"),
|
|
135
137
|
schemaName: Identifier,
|
|
136
138
|
tableName: Identifier,
|
|
137
139
|
triggerName: Identifier,
|
package/dist/schema.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","names":["z","PgIdentifier","SCHEMA_DUMP_SQL"],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { SCHEMA_DUMP_SQL } from \"./schema-dump.js\";\nimport type { Postgres } from \"./sql/database.js\";\nimport { PgIdentifier } from \"./sql/pg-identifier.js\";\n\nconst Identifier = z.codec(z.string(), z.custom<PgIdentifier>(), {\n encode: (v) => v.toString(),\n decode: (v) => PgIdentifier.fromString(v),\n});\n\nexport const FullSchemaKeyColumn = z.object({\n type: z.literal(\"indexColumn\"),\n name: Identifier,\n order: z.enum([\"ASC\", \"DESC\"]).optional(),\n nulls: z.enum([\"FIRST\", \"LAST\"]).optional(),\n opclass: z.string().optional(),\n collation: z.string().optional(),\n});\n\nexport type FullSchemaKeyColumn = z.infer<typeof FullSchemaKeyColumn>;\n\nexport const FullSchemaIncludedColumn = z.object({\n name: Identifier,\n});\n\nexport type FullSchemaIncludedColumn = z.infer<typeof FullSchemaIncludedColumn>;\n\nexport const FullSchemaIndex = z.object({\n type: z.literal(\"index\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n indexName: Identifier,\n indexType: z.string(),\n isUnique: z.boolean(),\n isPrimary: z.boolean(),\n isClustered: z.boolean(),\n wherePredicate: z.string().optional(),\n tablespace: z.string().optional(),\n keyColumns: z.array(FullSchemaKeyColumn),\n includedColumns: z.array(FullSchemaIncludedColumn).optional(),\n});\n\nexport type FullSchemaIndex = z.infer<typeof FullSchemaIndex>;\n\nexport const FullSchemaColumn = z.object({\n type: z.literal(\"column\"),\n name: Identifier,\n order: z.number(),\n columnType: z.string(),\n isNullable: z.boolean(),\n defaultValue: z.string().optional(),\n dropped: z.boolean(),\n collation: z.string().optional(),\n storage: z.enum([\"plain\", \"main\", \"external\", \"extended\"]).optional(),\n isIdentity: z.enum([\"always\", \"by default\"]).optional(),\n});\n\nexport type FullSchemaColumn = z.infer<typeof FullSchemaColumn>;\n\nexport const FullSchemaTable = z.object({\n type: z.literal(\"table\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n tablespace: z.string().optional(),\n partitionKeyDef: z.string().optional(),\n columns: z.array(FullSchemaColumn).default([]),\n});\n\nexport type FullSchemaTable = z.infer<typeof FullSchemaTable>;\n\nexport const FullSchemaConstraint = z.object({\n type: z.literal(\"constraint\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n constraintName: Identifier,\n constraintType: z\n .enum([\n \"check\",\n \"foreign_key\",\n \"not_null\",\n \"primary_key\",\n \"unique\",\n \"trigger\",\n \"exclusion\",\n ])\n .or(z.string()),\n definition: z.string(),\n isDeferrable: z.boolean().optional(),\n isInitiallyDeferred: z.boolean().optional(),\n isValidated: z.boolean().optional(),\n backingIndexOid: z.number().optional(),\n});\n\nexport type FullSchemaConstraint = z.infer<typeof FullSchemaConstraint>;\n\nexport const FullSchemaFunction = z.object({\n type: z.literal(\"function\"),\n schemaName: Identifier,\n objectName: Identifier,\n objectType: z.enum([\"function\", \"procedure\", \"aggregate\", \"window function\"]),\n identityArguments: z.string().optional(),\n definition: z.string(),\n});\n\nexport type FullSchemaFunction = z.infer<typeof FullSchemaFunction>;\n\nexport const FullSchemaExtension = z.object({\n extensionName: z.string(),\n version: z.string(),\n schemaName: Identifier,\n});\n\nexport type FullSchemaExtension = z.infer<typeof FullSchemaExtension>;\n\nexport const FullSchemaView = z.object({\n type: z.literal(\"view\"),\n schemaName: Identifier,\n viewName: Identifier,\n objectType: z.enum([\"view\", \"materialized_view\"]),\n definition: z.string(),\n tablespace: z.string().optional(),\n});\n\nexport type FullSchemaView = z.infer<typeof FullSchemaView>;\n\nexport const FullSchemaTypeConstraint = z.object({\n name: Identifier,\n definition: z.string(),\n});\n\nexport type FullSchemaTypeConstraint = z.infer<typeof FullSchemaTypeConstraint>;\n\nexport const FullSchemaCompositeAttribute = z.object({\n type: z.literal(\"compositeAttribute\"),\n name: Identifier,\n attributeType: z.string(),\n collation: Identifier.optional(),\n});\n\nexport type FullSchemaCompositeAttribute = z.infer<\n typeof FullSchemaCompositeAttribute\n>;\n\nexport const FullSchemaType = z.object({\n type: z.literal(\"type\"),\n schemaName: Identifier,\n typeName: Identifier,\n typeCategory: z.enum([\"enum\", \"domain\", \"composite\"]),\n enumLabels: z.array(z.string()).optional(),\n domainBaseType: z.string().optional(),\n domainIsNotNull: z.boolean().optional(),\n domainDefault: z.string().optional(),\n domainConstraints: z.array(FullSchemaTypeConstraint).optional(),\n compositeAttributes: z.array(FullSchemaCompositeAttribute).optional(),\n});\n\nexport type FullSchemaType = z.infer<typeof FullSchemaType>;\n\nexport const FullSchemaTrigger = z.object({\n schemaName: Identifier,\n tableName: Identifier,\n triggerName: Identifier,\n definition: z.string(),\n enabledMode: z.string(),\n});\n\nexport type FullSchemaTrigger = z.infer<typeof FullSchemaTrigger>;\n\nexport const FullSchema = z.object({\n indexes: z.array(FullSchemaIndex).default([]),\n tables: z.array(FullSchemaTable).default([]),\n constraints: z.array(FullSchemaConstraint).default([]),\n functions: z.array(FullSchemaFunction).default([]),\n extensions: z.array(FullSchemaExtension).default([]),\n views: z.array(FullSchemaView).default([]),\n types: z.array(FullSchemaType).default([]),\n triggers: z.array(FullSchemaTrigger).default([]),\n});\n\nexport type FullSchema = z.infer<typeof FullSchema>;\n\nexport async function dumpSchema(db: Postgres): Promise<FullSchema> {\n const rows = await db.exec<{ result: FullSchema }>(SCHEMA_DUMP_SQL);\n return FullSchema.parse(rows[0]?.result ?? {});\n}\n"],"mappings":";;;;;;AAKA,MAAM,aAAaA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAsB,EAAE;CAC/D,SAAS,MAAM,EAAE,UAAU;CAC3B,SAAS,MAAMC,sBAAAA,aAAa,WAAW,EAAE;CAC1C,CAAC;AAEF,MAAa,sBAAsBD,IAAAA,EAAE,OAAO;CAC1C,MAAMA,IAAAA,EAAE,QAAQ,cAAc;CAC9B,MAAM;CACN,OAAOA,IAAAA,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC,UAAU;CACzC,OAAOA,IAAAA,EAAE,KAAK,CAAC,SAAS,OAAO,CAAC,CAA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CAC5C,aAAaA,IAAAA,EAAE,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC;CACtD,WAAWA,IAAAA,EAAE,MAAM,mBAAmB,CAAC,QAAQ,EAAE,CAAC;CAClD,YAAYA,IAAAA,EAAE,MAAM,oBAAoB,CAAC,QAAQ,EAAE,CAAC;CACpD,OAAOA,IAAAA,EAAE,MAAM,eAAe,CAAC,QAAQ,EAAE,CAAC;CAC1C,OAAOA,IAAAA,EAAE,MAAM,eAAe,CAAC,QAAQ,EAAE,CAAC;CAC1C,UAAUA,IAAAA,EAAE,MAAM,kBAAkB,CAAC,QAAQ,EAAE,CAAC;CACjD,CAAC;AAIF,eAAsB,WAAW,IAAmC;CAClE,MAAM,OAAO,MAAM,GAAG,KAA6BE,oBAAAA,gBAAgB;AACnE,QAAO,WAAW,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.cjs","names":["z","PgIdentifier","SCHEMA_DUMP_SQL"],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { SCHEMA_DUMP_SQL } from \"./schema-dump.js\";\nimport type { Postgres } from \"./sql/database.js\";\nimport { PgIdentifier } from \"./sql/pg-identifier.js\";\n\nconst Identifier = z.codec(z.string(), z.custom<PgIdentifier>(), {\n encode: (v) => v.toString(),\n decode: (v) => PgIdentifier.fromString(v),\n});\n\nexport const FullSchemaKeyColumn = z.object({\n type: z.literal(\"indexColumn\"),\n name: Identifier,\n order: z.enum([\"ASC\", \"DESC\"]).optional(),\n nulls: z.enum([\"FIRST\", \"LAST\"]).optional(),\n opclass: z.string().optional(),\n collation: z.string().optional(),\n});\n\nexport type FullSchemaKeyColumn = z.infer<typeof FullSchemaKeyColumn>;\n\nexport const FullSchemaIncludedColumn = z.object({\n name: Identifier,\n});\n\nexport type FullSchemaIncludedColumn = z.infer<typeof FullSchemaIncludedColumn>;\n\nexport const FullSchemaIndex = z.object({\n type: z.literal(\"index\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n indexName: Identifier,\n indexType: z.string(),\n isUnique: z.boolean(),\n isPrimary: z.boolean(),\n isClustered: z.boolean(),\n wherePredicate: z.string().optional(),\n tablespace: z.string().optional(),\n keyColumns: z.array(FullSchemaKeyColumn),\n includedColumns: z.array(FullSchemaIncludedColumn).optional(),\n});\n\nexport type FullSchemaIndex = z.infer<typeof FullSchemaIndex>;\n\nexport const FullSchemaColumn = z.object({\n type: z.literal(\"column\"),\n name: Identifier,\n order: z.number(),\n columnType: z.string(),\n isNullable: z.boolean(),\n defaultValue: z.string().optional(),\n dropped: z.boolean(),\n collation: z.string().optional(),\n storage: z.enum([\"plain\", \"main\", \"external\", \"extended\"]).optional(),\n isIdentity: z.enum([\"always\", \"by default\"]).optional(),\n});\n\nexport type FullSchemaColumn = z.infer<typeof FullSchemaColumn>;\n\nexport const FullSchemaTable = z.object({\n type: z.literal(\"table\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n tablespace: z.string().optional(),\n partitionKeyDef: z.string().optional(),\n columns: z.array(FullSchemaColumn).default([]),\n});\n\nexport type FullSchemaTable = z.infer<typeof FullSchemaTable>;\n\nexport const FullSchemaConstraint = z.object({\n type: z.literal(\"constraint\"),\n oid: z.number(),\n schemaName: Identifier,\n tableName: Identifier,\n constraintName: Identifier,\n constraintType: z\n .enum([\n \"check\",\n \"foreign_key\",\n \"not_null\",\n \"primary_key\",\n \"unique\",\n \"trigger\",\n \"exclusion\",\n ])\n .or(z.string()),\n definition: z.string(),\n isDeferrable: z.boolean().optional(),\n isInitiallyDeferred: z.boolean().optional(),\n isValidated: z.boolean().optional(),\n backingIndexOid: z.number().optional(),\n});\n\nexport type FullSchemaConstraint = z.infer<typeof FullSchemaConstraint>;\n\nexport const FullSchemaFunction = z.object({\n type: z.literal(\"function\"),\n schemaName: Identifier,\n objectName: Identifier,\n objectType: z.enum([\"function\", \"procedure\", \"aggregate\", \"window function\"]),\n identityArguments: z.string().optional(),\n definition: z.string(),\n});\n\nexport type FullSchemaFunction = z.infer<typeof FullSchemaFunction>;\n\nexport const FullSchemaExtension = z.object({\n type: z.literal(\"extension\"),\n extensionName: z.string(),\n version: z.string(),\n schemaName: Identifier,\n});\n\nexport type FullSchemaExtension = z.infer<typeof FullSchemaExtension>;\n\nexport const FullSchemaView = z.object({\n type: z.literal(\"view\"),\n schemaName: Identifier,\n viewName: Identifier,\n objectType: z.enum([\"view\", \"materialized_view\"]),\n definition: z.string(),\n tablespace: z.string().optional(),\n});\n\nexport type FullSchemaView = z.infer<typeof FullSchemaView>;\n\nexport const FullSchemaTypeConstraint = z.object({\n name: Identifier,\n definition: z.string(),\n});\n\nexport type FullSchemaTypeConstraint = z.infer<typeof FullSchemaTypeConstraint>;\n\nexport const FullSchemaCompositeAttribute = z.object({\n type: z.literal(\"compositeAttribute\"),\n name: Identifier,\n attributeType: z.string(),\n collation: Identifier.optional(),\n});\n\nexport type FullSchemaCompositeAttribute = z.infer<\n typeof FullSchemaCompositeAttribute\n>;\n\nexport const FullSchemaType = z.object({\n type: z.literal(\"type\"),\n schemaName: Identifier,\n typeName: Identifier,\n typeCategory: z.enum([\"enum\", \"domain\", \"composite\"]),\n enumLabels: z.array(z.string()).optional(),\n domainBaseType: z.string().optional(),\n domainIsNotNull: z.boolean().optional(),\n domainDefault: z.string().optional(),\n domainConstraints: z.array(FullSchemaTypeConstraint).optional(),\n compositeAttributes: z.array(FullSchemaCompositeAttribute).optional(),\n});\n\nexport type FullSchemaType = z.infer<typeof FullSchemaType>;\n\nexport const FullSchemaTrigger = z.object({\n type: z.literal(\"trigger\"),\n schemaName: Identifier,\n tableName: Identifier,\n triggerName: Identifier,\n definition: z.string(),\n enabledMode: z.string(),\n});\n\nexport type FullSchemaTrigger = z.infer<typeof FullSchemaTrigger>;\n\nexport const FullSchema = z.object({\n indexes: z.array(FullSchemaIndex).default([]),\n tables: z.array(FullSchemaTable).default([]),\n constraints: z.array(FullSchemaConstraint).default([]),\n functions: z.array(FullSchemaFunction).default([]),\n extensions: z.array(FullSchemaExtension).default([]),\n views: z.array(FullSchemaView).default([]),\n types: z.array(FullSchemaType).default([]),\n triggers: z.array(FullSchemaTrigger).default([]),\n});\n\nexport type FullSchema = z.infer<typeof FullSchema>;\n\nexport async function dumpSchema(db: Postgres): Promise<FullSchema> {\n const rows = await db.exec<{ result: FullSchema }>(SCHEMA_DUMP_SQL);\n return FullSchema.parse(rows[0]?.result ?? {});\n}\n"],"mappings":";;;;;;AAKA,MAAM,aAAaA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAsB,EAAE;CAC/D,SAAS,MAAM,EAAE,UAAU;CAC3B,SAAS,MAAMC,sBAAAA,aAAa,WAAW,EAAE;CAC1C,CAAC;AAEF,MAAa,sBAAsBD,IAAAA,EAAE,OAAO;CAC1C,MAAMA,IAAAA,EAAE,QAAQ,cAAc;CAC9B,MAAM;CACN,OAAOA,IAAAA,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC,UAAU;CACzC,OAAOA,IAAAA,EAAE,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,UAAU;CAC3C,SAASA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC9B,WAAWA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC;AAIF,MAAa,2BAA2BA,IAAAA,EAAE,OAAO,EAC/C,MAAM,YACP,CAAC;AAIF,MAAa,kBAAkBA,IAAAA,EAAE,OAAO;CACtC,MAAMA,IAAAA,EAAE,QAAQ,QAAQ;CACxB,KAAKA,IAAAA,EAAE,QAAQ;CACf,YAAY;CACZ,WAAW;CACX,WAAW;CACX,WAAWA,IAAAA,EAAE,QAAQ;CACrB,UAAUA,IAAAA,EAAE,SAAS;CACrB,WAAWA,IAAAA,EAAE,SAAS;CACtB,aAAaA,IAAAA,EAAE,SAAS;CACxB,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACrC,YAAYA,IAAA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AAM,OAAO,MAAM,GAAG,KAA6BE,oBAAAA,gBAAgB;AACnE,QAAO,WAAW,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC"}
|
package/dist/schema.d.cts
CHANGED
|
@@ -142,6 +142,7 @@ declare const FullSchemaFunction: z.ZodObject<{
|
|
|
142
142
|
}, z.core.$strip>;
|
|
143
143
|
type FullSchemaFunction = z.infer<typeof FullSchemaFunction>;
|
|
144
144
|
declare const FullSchemaExtension: z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"extension">;
|
|
145
146
|
extensionName: z.ZodString;
|
|
146
147
|
version: z.ZodString;
|
|
147
148
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -197,6 +198,7 @@ declare const FullSchemaType: z.ZodObject<{
|
|
|
197
198
|
}, z.core.$strip>;
|
|
198
199
|
type FullSchemaType = z.infer<typeof FullSchemaType>;
|
|
199
200
|
declare const FullSchemaTrigger: z.ZodObject<{
|
|
201
|
+
type: z.ZodLiteral<"trigger">;
|
|
200
202
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
201
203
|
tableName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
202
204
|
triggerName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -298,6 +300,7 @@ declare const FullSchema: z.ZodObject<{
|
|
|
298
300
|
definition: z.ZodString;
|
|
299
301
|
}, z.core.$strip>>>;
|
|
300
302
|
extensions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
303
|
+
type: z.ZodLiteral<"extension">;
|
|
301
304
|
extensionName: z.ZodString;
|
|
302
305
|
version: z.ZodString;
|
|
303
306
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -338,6 +341,7 @@ declare const FullSchema: z.ZodObject<{
|
|
|
338
341
|
}, z.core.$strip>>>;
|
|
339
342
|
}, z.core.$strip>>>;
|
|
340
343
|
triggers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
344
|
+
type: z.ZodLiteral<"trigger">;
|
|
341
345
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
342
346
|
tableName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
343
347
|
triggerName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
package/dist/schema.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../src/schema.ts"],"mappings":";;;;;;;cAUa,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;KASpB,mBAAA,GAAsB,CAAA,CAAE,KAAA,QAAa,mBAAA;AAAA,cAEpC,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;KAIzB,wBAAA,GAA2B,CAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,cAEzC,eAAA,EAAe,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,eAAA;AAAA,cAEhC,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;KAajB,gBAAA,GAAmB,CAAA,CAAE,KAAA,QAAa,gBAAA;AAAA,cAEjC,eAAA,EAAe,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAUhB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,eAAA;AAAA,cAEhC,oBAAA,EAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;KAwBrB,oBAAA,GAAuB,CAAA,CAAE,KAAA,QAAa,oBAAA;AAAA,cAErC,kBAAA,EAAkB,CAAA,CAAA,SAAA;;;;;;;;;;;;;KASn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AAA;;;;KAKzB,wBAAA,GAA2B,CAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,cAEzC,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;;;KAO7B,4BAAA,GAA+B,CAAA,CAAE,KAAA,QACpC,4BAAA;AAAA,cAGI,cAAA,EAAc,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;KAaf,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,cAAA;AAAA,cAE/B,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;;KASlB,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,cAElC,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAWX,UAAA,GAAa,CAAA,CAAE,KAAA,QAAa,UAAA;AAAA,iBAElB,UAAA,CAAW,EAAA,EAAI,QAAA,GAAW,OAAA,CAAQ,UAAA"}
|
package/dist/schema.d.mts
CHANGED
|
@@ -142,6 +142,7 @@ declare const FullSchemaFunction: z.ZodObject<{
|
|
|
142
142
|
}, z.core.$strip>;
|
|
143
143
|
type FullSchemaFunction = z.infer<typeof FullSchemaFunction>;
|
|
144
144
|
declare const FullSchemaExtension: z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"extension">;
|
|
145
146
|
extensionName: z.ZodString;
|
|
146
147
|
version: z.ZodString;
|
|
147
148
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -197,6 +198,7 @@ declare const FullSchemaType: z.ZodObject<{
|
|
|
197
198
|
}, z.core.$strip>;
|
|
198
199
|
type FullSchemaType = z.infer<typeof FullSchemaType>;
|
|
199
200
|
declare const FullSchemaTrigger: z.ZodObject<{
|
|
201
|
+
type: z.ZodLiteral<"trigger">;
|
|
200
202
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
201
203
|
tableName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
202
204
|
triggerName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -298,6 +300,7 @@ declare const FullSchema: z.ZodObject<{
|
|
|
298
300
|
definition: z.ZodString;
|
|
299
301
|
}, z.core.$strip>>>;
|
|
300
302
|
extensions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
303
|
+
type: z.ZodLiteral<"extension">;
|
|
301
304
|
extensionName: z.ZodString;
|
|
302
305
|
version: z.ZodString;
|
|
303
306
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
@@ -338,6 +341,7 @@ declare const FullSchema: z.ZodObject<{
|
|
|
338
341
|
}, z.core.$strip>>>;
|
|
339
342
|
}, z.core.$strip>>>;
|
|
340
343
|
triggers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
344
|
+
type: z.ZodLiteral<"trigger">;
|
|
341
345
|
schemaName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
342
346
|
tableName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|
|
343
347
|
triggerName: z.ZodCodec<z.ZodString, z.ZodCustom<PgIdentifier, PgIdentifier>>;
|