@intentius/sql-yodeler 0.13.1 → 0.13.3
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/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/chant/apply.js +3 -1
- package/dist/chant/apply.js.map +1 -1
- package/dist/chant/build.js +3 -1
- package/dist/chant/build.js.map +1 -1
- package/dist/chant/confirm.d.ts +20 -20
- package/dist/chant/confirm.js +14 -27
- package/dist/chant/confirm.js.map +1 -1
- package/dist/chant/drift.d.ts +13 -49
- package/dist/chant/drift.js +25 -138
- package/dist/chant/drift.js.map +1 -1
- package/dist/chant/sql-types.d.ts +4 -5
- package/dist/chant/sql-types.js +9 -10
- package/dist/chant/sql-types.js.map +1 -1
- package/dist/ci/render.d.ts +61 -18
- package/dist/ci/render.js +212 -132
- package/dist/ci/render.js.map +1 -1
- package/dist/ci-words.d.ts +10 -0
- package/dist/ci-words.js +10 -0
- package/dist/ci-words.js.map +1 -1
- package/dist/commands/approve.d.ts +1 -1
- package/dist/commands/approve.js +6 -7
- package/dist/commands/approve.js.map +1 -1
- package/dist/commands/chant.d.ts +1 -1
- package/dist/commands/chant.js +2 -2
- package/dist/commands/chant.js.map +1 -1
- package/dist/commands/ci.js +32 -19
- package/dist/commands/ci.js.map +1 -1
- package/dist/commands/create.d.ts +2 -2
- package/dist/commands/create.js +2 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/drift.d.ts +1 -1
- package/dist/commands/drift.js +6 -42
- package/dist/commands/drift.js.map +1 -1
- package/dist/commands/emulator.d.ts +2 -2
- package/dist/commands/emulator.js +2 -2
- package/dist/commands/emulator.js.map +1 -1
- package/dist/commands/override.js +2 -2
- package/dist/commands/override.js.map +1 -1
- package/dist/commands/plan.js +79 -80
- package/dist/commands/plan.js.map +1 -1
- package/dist/config/define.d.ts +29 -0
- package/dist/config/define.js.map +1 -1
- package/dist/config/load.js +20 -3
- package/dist/config/load.js.map +1 -1
- package/dist/declarative/plan.d.ts +2 -2
- package/dist/declarative/plan.js +2 -2
- package/dist/mcp/tools.js +2 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/notify/index.d.ts +4 -0
- package/dist/notify/index.js +3 -1
- package/dist/notify/index.js.map +1 -1
- package/dist/pr/forge.d.ts +1 -1
- package/dist/pr/forge.js +1 -1
- package/dist/pr/issue.d.ts +10 -5
- package/dist/pr/issue.js +26 -13
- package/dist/pr/issue.js.map +1 -1
- package/dist/pr/model.d.ts +1 -5
- package/dist/pr/model.js +2 -7
- package/dist/pr/model.js.map +1 -1
- package/dist/pr/note.d.ts +25 -9
- package/dist/pr/note.js +56 -21
- package/dist/pr/note.js.map +1 -1
- package/dist/pr/render.d.ts +4 -6
- package/dist/pr/render.js +4 -10
- package/dist/pr/render.js.map +1 -1
- package/dist/versioned/explain.d.ts +1 -9
- package/dist/versioned/explain.js +1 -20
- package/dist/versioned/explain.js.map +1 -1
- package/dist/versioned/op.js +3 -1
- package/dist/versioned/op.js.map +1 -1
- package/package.json +7 -7
- package/schemas/drift.schema.json +9 -5
- package/schemas/plan.schema.json +1 -1
- package/dist/chant/process.d.ts +0 -34
- package/dist/chant/process.js +0 -74
- package/dist/chant/process.js.map +0 -1
- package/dist/chant/resolve-fallback.d.ts +0 -35
- package/dist/chant/resolve-fallback.js +0 -89
- package/dist/chant/resolve-fallback.js.map +0 -1
- package/dist/pr/overdue.d.ts +0 -41
- package/dist/pr/overdue.js +0 -46
- package/dist/pr/overdue.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// chant.config.ts and *.op.ts in this process. Register tsx's loader before
|
|
5
5
|
// anything imports them, the way chant's own bin runs under tsx.
|
|
6
6
|
import { register } from "tsx/esm/api";
|
|
7
|
-
import {
|
|
7
|
+
import { installResolveFallback } from "@intentius/chant/chant-install";
|
|
8
8
|
register();
|
|
9
9
|
// A project with no node_modules of its own, such as chant's commit job's worktree of the head, takes yodel's (#312).
|
|
10
|
-
|
|
10
|
+
installResolveFallback();
|
|
11
11
|
const { main } = await import("./cli.js");
|
|
12
12
|
const terminal = process.stdin.isTTY && process.stderr.isTTY;
|
|
13
13
|
const code = await main(process.argv.slice(2), {
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,wEAAwE;AACxE,4EAA4E;AAC5E,iEAAiE;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,wEAAwE;AACxE,4EAA4E;AAC5E,iEAAiE;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,QAAQ,EAAE,CAAC;AACX,sHAAsH;AACtH,sBAAsB,EAAE,CAAC;AACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AAE1C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;AAC7D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC7C,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACzC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACzC,GAAG,CAAC,QAAQ;QACV,CAAC,CAAC;YACE,GAAG,EAAE,KAAK,EAAE,QAAgB,EAA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13
13
|
import { approveCommand } from "../approval-mode/index.js";
|
|
14
|
-
import { runChant } from "
|
|
14
|
+
import { runChant } from "@intentius/chant/chant-install";
|
|
15
15
|
import { EXIT_WAITING } from "../exit.js";
|
|
16
16
|
const steps = (config) => config.phases.flatMap((p) => p.steps);
|
|
17
17
|
/** The environment and target a `nativeApply` step applies, when the Op has one. */
|
|
@@ -130,6 +130,8 @@ export function gatedCommands(run, env, mode = "ledger") {
|
|
|
130
130
|
export async function runApplyOp(project, op, options = {}) {
|
|
131
131
|
const result = await runChant(["run", op.name, "--gated-exit", String(EXIT_WAITING)], {
|
|
132
132
|
cwd: project.dir,
|
|
133
|
+
noColor: true,
|
|
134
|
+
resolveFallback: true,
|
|
133
135
|
...(options.env ? { env: options.env } : {}),
|
|
134
136
|
...(options.onOutput ? { onStdout: options.onOutput, onStderr: options.onOutput } : {}),
|
|
135
137
|
});
|
package/dist/chant/apply.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/chant/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAmD,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/chant/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAmD,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,C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AAM,MAAM,GAAG,MAAM,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE;QACpF,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,IAAI;QACrB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxF,CAAC,CAAC;IACH,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACzE,CAAC"}
|
package/dist/chant/build.js
CHANGED
|
@@ -7,7 +7,7 @@ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { YodelError } from "../project.js";
|
|
10
|
-
import { runChant } from "
|
|
10
|
+
import { runChant } from "@intentius/chant/chant-install";
|
|
11
11
|
import { checkOwnership, duplicateExport, syncSources } from "../sources/index.js";
|
|
12
12
|
/**
|
|
13
13
|
* Builds the project's declared schema. Writes to `out` when given, else to
|
|
@@ -29,6 +29,8 @@ export async function buildSchema(project, options = {}) {
|
|
|
29
29
|
// `src` is a directory of the caller's own (yodel check's server snapshot); without it chant builds sourceDir.
|
|
30
30
|
const result = await runChant(["build", ...(options.src ? [options.src] : []), "--lexicon", "sql", "--root-only", "-o", path], {
|
|
31
31
|
cwd: project.dir,
|
|
32
|
+
noColor: true,
|
|
33
|
+
resolveFallback: true,
|
|
32
34
|
...(options.env ? { env: options.env } : {}),
|
|
33
35
|
});
|
|
34
36
|
if (result.code !== 0) {
|
package/dist/chant/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/chant/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAiC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/chant/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAiC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAyBnF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAgB,EAAE,UAAoF,EAAE;IACxI,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;IAClF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE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
|
|
1
|
+
/**
|
|
2
|
+
* The type-the-name confirmation of `yodel approve` (#295), in chant core
|
|
3
|
+
* (ruling F on #285, chant#4575). yodel approve asks through chant's
|
|
4
|
+
* `confirmApproval`: chant shows the gate, its pending fact and the stored
|
|
5
|
+
* plan the fact cites, and asks for the target's name, the environment (or
|
|
6
|
+
* tenant set) yodel names. A wrong answer, or the end of input, records
|
|
7
|
+
* nothing and exits 8, as chant approve does for every product. yodel asks
|
|
8
|
+
* its own question only with YODEL_OWN_CONFIRM=1, or when chant has nothing
|
|
9
|
+
* to show (no ledger to read yet).
|
|
10
|
+
*
|
|
11
|
+
* yodel still refuses with no terminal before anything is read, and still
|
|
12
|
+
* reads its plan again after the answer, so what is approved is what the
|
|
13
|
+
* person saw. chant's `approve` child then records with no terminal of its
|
|
14
|
+
* own, so the person is asked once.
|
|
15
|
+
*/
|
|
16
|
+
import { confirmApproval as chantConfirmApproval } from "@intentius/chant/cli/handlers/approve-confirm";
|
|
1
17
|
import type { Io } from "../command.js";
|
|
2
18
|
/** The parts of chant's `cli/handlers/approve-confirm` yodel calls. */
|
|
3
19
|
export interface ChantConfirm {
|
|
4
|
-
confirmApproval
|
|
5
|
-
plan?: string;
|
|
6
|
-
environment?: string;
|
|
7
|
-
cwd?: string;
|
|
8
|
-
ask?: (q: string) => Promise<string | null>;
|
|
9
|
-
out?: (t: string) => void;
|
|
10
|
-
err?: (t: string) => void;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
status: "skipped";
|
|
13
|
-
} | {
|
|
14
|
-
status: "confirmed";
|
|
15
|
-
plan: string;
|
|
16
|
-
target: string;
|
|
17
|
-
} | {
|
|
18
|
-
status: "refused";
|
|
19
|
-
code: number;
|
|
20
|
-
}>;
|
|
20
|
+
confirmApproval: typeof chantConfirmApproval;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
export declare function
|
|
22
|
+
/** True when chant asks the question; false with YODEL_OWN_CONFIRM=1, when yodel asks its own. */
|
|
23
|
+
export declare function chantConfirms(env?: NodeJS.ProcessEnv): boolean;
|
|
24
24
|
/** What one confirmation asks about. */
|
|
25
25
|
export interface Confirmation {
|
|
26
26
|
io: Io;
|
|
@@ -32,7 +32,7 @@ export interface Confirmation {
|
|
|
32
32
|
digest: string;
|
|
33
33
|
/** The name the person types: the environment, the tenant set. */
|
|
34
34
|
target: string;
|
|
35
|
-
/** yodel's own question,
|
|
35
|
+
/** yodel's own question, for YODEL_OWN_CONFIRM=1 and when chant has nothing to show. */
|
|
36
36
|
question: string;
|
|
37
37
|
}
|
|
38
38
|
/**
|
package/dist/chant/confirm.js
CHANGED
|
@@ -1,50 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The type-the-name confirmation of `yodel approve` (#295), in chant core
|
|
3
|
-
* (ruling F on #285, chant#4575).
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
3
|
+
* (ruling F on #285, chant#4575). yodel approve asks through chant's
|
|
4
|
+
* `confirmApproval`: chant shows the gate, its pending fact and the stored
|
|
5
|
+
* plan the fact cites, and asks for the target's name, the environment (or
|
|
6
|
+
* tenant set) yodel names. A wrong answer, or the end of input, records
|
|
7
|
+
* nothing and exits 8, as chant approve does for every product. yodel asks
|
|
8
|
+
* its own question only with YODEL_OWN_CONFIRM=1, or when chant has nothing
|
|
9
|
+
* to show (no ledger to read yet).
|
|
10
10
|
*
|
|
11
11
|
* yodel still refuses with no terminal before anything is read, and still
|
|
12
12
|
* reads its plan again after the answer, so what is approved is what the
|
|
13
13
|
* person saw. chant's `approve` child then records with no terminal of its
|
|
14
14
|
* own, so the person is asked once.
|
|
15
15
|
*/
|
|
16
|
+
import { confirmApproval as chantConfirmApproval } from "@intentius/chant/cli/handlers/approve-confirm";
|
|
16
17
|
import { EXIT_DECLINED } from "../exit.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (env.YODEL_OWN_CONFIRM === "1")
|
|
21
|
-
return Promise.resolve(undefined);
|
|
22
|
-
api ??= (async () => {
|
|
23
|
-
const specifier = "@intentius/chant/cli/handlers/approve-confirm";
|
|
24
|
-
try {
|
|
25
|
-
const m = (await import(specifier));
|
|
26
|
-
return typeof m.confirmApproval === "function" ? m : undefined;
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
})();
|
|
32
|
-
return api;
|
|
18
|
+
/** True when chant asks the question; false with YODEL_OWN_CONFIRM=1, when yodel asks its own. */
|
|
19
|
+
export function chantConfirms(env = process.env) {
|
|
20
|
+
return env.YODEL_OWN_CONFIRM !== "1";
|
|
33
21
|
}
|
|
34
22
|
/**
|
|
35
23
|
* Ask the person to confirm. Undefined when they typed the target's name;
|
|
36
24
|
* else the exit code: 8 for a wrong answer or the end of input, or chant's
|
|
37
25
|
* code for a plan that moved while they were asked.
|
|
38
26
|
*/
|
|
39
|
-
export async function confirmApproval(c, chant) {
|
|
40
|
-
|
|
41
|
-
if (!confirm)
|
|
27
|
+
export async function confirmApproval(c, chant = { confirmApproval: chantConfirmApproval }) {
|
|
28
|
+
if (!chantConfirms())
|
|
42
29
|
return ownPrompt(c);
|
|
43
30
|
const before = process.cwd();
|
|
44
31
|
process.chdir(c.dir);
|
|
45
32
|
let answered;
|
|
46
33
|
try {
|
|
47
|
-
answered = await
|
|
34
|
+
answered = await chant.confirmApproval(c.op, c.gate, {
|
|
48
35
|
plan: c.digest,
|
|
49
36
|
environment: c.target,
|
|
50
37
|
cwd: c.dir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../src/chant/confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../src/chant/confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OA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,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IACxD,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;IACrG,kFAAkF;IAClF,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,4BAA4B;AAC5B,KAAK,UAAU,SAAS,CAAC,CAAe;IACtC,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,IAAI,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC1C,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAC5D,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/chant/drift.d.ts
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
* --json`, the sql lexicon's section of it:
|
|
5
5
|
*
|
|
6
6
|
* - `deep.drifted[].changes[]`: a declared object whose live definition
|
|
7
|
-
* differs, property by property, declared against live;
|
|
7
|
+
* differs, property by property, declared against live; a column is
|
|
8
|
+
* addressed by its name (`columns[#country].default.expr`), and a
|
|
9
|
+
* ClickHouse grant declared and not held is `absent` on its grant;
|
|
10
|
+
* - `deep.pending`: a change on no one object's properties, which an apply
|
|
11
|
+
* would undo: a column the server has and the declaration does not, a
|
|
12
|
+
* privilege granted by hand (chant issue 4944);
|
|
8
13
|
* - `resources.missing`: a declared object the server does not have;
|
|
9
14
|
* - `resources.unobserved` and `deep.unobserved`: a declared object chant
|
|
10
15
|
* could not read (no credentials, a kind it cannot observe). Not drift, and
|
|
@@ -14,10 +19,11 @@
|
|
|
14
19
|
* what the project declares, and only touches what carries its marker.
|
|
15
20
|
*/
|
|
16
21
|
import type { LiveDiffResult, UnobservedResource } from "@intentius/chant/lifecycle/live-diff";
|
|
17
|
-
import type { DeepDiffResult, DeepEntityDrift
|
|
22
|
+
import type { DeepDiffResult, DeepEntityDrift } from "@intentius/chant/lifecycle/deep-diff";
|
|
23
|
+
import type { DeepPendingChange } from "@intentius/chant/deep-observation";
|
|
18
24
|
import { type Environment, type Project } from "../project.js";
|
|
19
25
|
import { type ServerInfo } from "../server.js";
|
|
20
|
-
import type {
|
|
26
|
+
import type { BuildOutput } from "./build.js";
|
|
21
27
|
/** The `lexicons.sql` section of `chant lifecycle diff --live --json`. */
|
|
22
28
|
export interface SqlLiveDiff {
|
|
23
29
|
resources?: LiveDiffResult;
|
|
@@ -29,12 +35,12 @@ export interface Drift {
|
|
|
29
35
|
changed: DeepEntityDrift[];
|
|
30
36
|
/** Declared objects the server does not have. */
|
|
31
37
|
missing: string[];
|
|
38
|
+
/** Changes on no one object's properties that an apply would undo, such as a column or a privilege added by hand. Absent when there are none. */
|
|
39
|
+
pending?: DeepPendingChange[];
|
|
32
40
|
/** Declared objects chant could not read. */
|
|
33
41
|
unobserved: UnobservedResource[];
|
|
34
42
|
/** Postgres: a read gave up at the lock timeout, and what it waited on (#18). */
|
|
35
43
|
lockWait?: string | undefined;
|
|
36
|
-
/** Each changed table's declared column names, by position, so `columns[3]` reads as the column's name (#19). */
|
|
37
|
-
columns?: Record<string, string[]>;
|
|
38
44
|
/** What the server was compared with (#49): `src/`, or the schema the newest applied migration records. */
|
|
39
45
|
against?: DriftAgainst;
|
|
40
46
|
/** Objects on the server of a kind yodel cannot declare (#251), as `<kind> <name>`: unmanaged, never drift. */
|
|
@@ -51,14 +57,6 @@ export type DriftAgainst = {
|
|
|
51
57
|
source: "history";
|
|
52
58
|
migration: string | null;
|
|
53
59
|
};
|
|
54
|
-
/**
|
|
55
|
-
* A stable fingerprint of the drift: the environment and what drifted
|
|
56
|
-
* (each changed object's changes, declared and live, and the objects gone),
|
|
57
|
-
* order-free, so two reads of the same drift give the same one and a
|
|
58
|
-
* tracking issue updated with it changes only when the drift does. Objects
|
|
59
|
-
* that could not be read are not drift and are left out.
|
|
60
|
-
*/
|
|
61
|
-
export declare function driftFingerprint(drift: Drift): string;
|
|
62
60
|
/**
|
|
63
61
|
* The recorded schema as declarations chant can build: one file, written
|
|
64
62
|
* by the sql lexicon's import generator from each object's DDL, each named
|
|
@@ -77,51 +75,17 @@ export declare function recordedAccessSource(objects: ReadonlyArray<{
|
|
|
77
75
|
type?: string;
|
|
78
76
|
ddl: string;
|
|
79
77
|
}>): string;
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
* grant is compared as part of its grantee's grants): yodel plans `build`
|
|
83
|
-
* against the environment and reads each `grants <grantee>` change as drift.
|
|
84
|
-
* A grant declared and not held is `absent`; one held and not declared
|
|
85
|
-
* (granted by hand, which the next apply revokes) is `changed`, declared
|
|
86
|
-
* nothing. A grantee the server does not have is gone. The grant
|
|
87
|
-
* declarations come off `unobserved`, since they were compared.
|
|
88
|
-
*/
|
|
89
|
-
export declare function withClickHouseGrants(drift: Drift, project: Project, env: Environment, build: Build): Promise<Drift>;
|
|
78
|
+
/** Whether the drift has anything an apply would change: an object changed or gone, or a pending change. */
|
|
79
|
+
export declare const hasDrift: (drift: Drift) => boolean;
|
|
90
80
|
/** `2` on drift; `1` when there is none but part of the environment could not be read; `0` when clean. */
|
|
91
81
|
export declare function driftExitCode(drift: Drift): number;
|
|
92
82
|
/** The drift in a parsed `chant lifecycle diff --live --json` document. */
|
|
93
83
|
export declare function driftFromLifecycle(environment: string, doc: unknown): Drift;
|
|
94
|
-
/**
|
|
95
|
-
* Columns on the server that a declared table does not declare (#273), as
|
|
96
|
-
* drift: `column <name>`, declared none, live its type. chant reports a live
|
|
97
|
-
* column past the declared ones as unclaimed fields `columns[N].*`, which it
|
|
98
|
-
* does not count as drift, since nothing in src/ set them. A group with its
|
|
99
|
-
* own `name` is a whole column; a field of a declared column that src/ does
|
|
100
|
-
* not set (`columns[2].default`) has no name of its own and stays unclaimed.
|
|
101
|
-
*/
|
|
102
|
-
export declare function extraColumns(unclaimed: readonly DeepEntityUnclaimed[]): DeepEntityDrift[];
|
|
103
84
|
/** Runs `chant lifecycle diff <env> --live --json` in the project and reads the drift from it. */
|
|
104
85
|
export declare function readDrift(project: Project, env: Environment, options?: {
|
|
105
86
|
env?: NodeJS.ProcessEnv;
|
|
106
87
|
src?: string;
|
|
107
88
|
}): Promise<Drift>;
|
|
108
|
-
/**
|
|
109
|
-
* The declared column names of each changed object whose drift is named by
|
|
110
|
-
* column position (chant's ClickHouse tables keep columns as a list, so a
|
|
111
|
-
* change reads `columns[3].default.expr`). Read from the project's build,
|
|
112
|
-
* with the dialect's own tag, the way chant reads the declaration.
|
|
113
|
-
*/
|
|
114
|
-
export declare function declaredColumns(project: Project, drift: Drift, build: () => Promise<{
|
|
115
|
-
output: {
|
|
116
|
-
objects: Array<{
|
|
117
|
-
export: string;
|
|
118
|
-
ddl: string;
|
|
119
|
-
}>;
|
|
120
|
-
};
|
|
121
|
-
dispose: () => void;
|
|
122
|
-
}>): Promise<Record<string, string[]>>;
|
|
123
|
-
/** `columns[3].default.expr` as `column country: default.expr`, when the declaration names column 3. */
|
|
124
|
-
export declare function describePath(path: string, columns: readonly string[] | undefined): string;
|
|
125
89
|
/** What the server was compared with, in words. */
|
|
126
90
|
export declare function describeAgainst(against: DriftAgainst | undefined): string | undefined;
|
|
127
91
|
/** The drift as text. */
|
package/dist/chant/drift.js
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
* --json`, the sql lexicon's section of it:
|
|
5
5
|
*
|
|
6
6
|
* - `deep.drifted[].changes[]`: a declared object whose live definition
|
|
7
|
-
* differs, property by property, declared against live;
|
|
7
|
+
* differs, property by property, declared against live; a column is
|
|
8
|
+
* addressed by its name (`columns[#country].default.expr`), and a
|
|
9
|
+
* ClickHouse grant declared and not held is `absent` on its grant;
|
|
10
|
+
* - `deep.pending`: a change on no one object's properties, which an apply
|
|
11
|
+
* would undo: a column the server has and the declaration does not, a
|
|
12
|
+
* privilege granted by hand (chant issue 4944);
|
|
8
13
|
* - `resources.missing`: a declared object the server does not have;
|
|
9
14
|
* - `resources.unobserved` and `deep.unobserved`: a declared object chant
|
|
10
15
|
* could not read (no credentials, a kind it cannot observe). Not drift, and
|
|
@@ -13,33 +18,13 @@
|
|
|
13
18
|
* An object the project does not declare is never reported: chant only reads
|
|
14
19
|
* what the project declares, and only touches what carries its marker.
|
|
15
20
|
*/
|
|
16
|
-
import { createHash } from "node:crypto";
|
|
17
21
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
18
22
|
import { dirname, join } from "node:path";
|
|
19
23
|
import { YodelError } from "../project.js";
|
|
20
|
-
import {
|
|
24
|
+
import { runChant } from "@intentius/chant/chant-install";
|
|
21
25
|
import { describeServer } from "../server.js";
|
|
22
26
|
import { CH_ACCESS_TYPES } from "./access.js";
|
|
23
|
-
import { planEnvironment } from "./plan.js";
|
|
24
27
|
import { EXIT_DRIFT } from "../exit.js";
|
|
25
|
-
/**
|
|
26
|
-
* A stable fingerprint of the drift: the environment and what drifted
|
|
27
|
-
* (each changed object's changes, declared and live, and the objects gone),
|
|
28
|
-
* order-free, so two reads of the same drift give the same one and a
|
|
29
|
-
* tracking issue updated with it changes only when the drift does. Objects
|
|
30
|
-
* that could not be read are not drift and are left out.
|
|
31
|
-
*/
|
|
32
|
-
export function driftFingerprint(drift) {
|
|
33
|
-
const changed = drift.changed
|
|
34
|
-
.map((e) => ({
|
|
35
|
-
name: e.name,
|
|
36
|
-
type: e.type,
|
|
37
|
-
changes: e.changes.map((c) => ({ path: c.path, kind: c.kind, declared: c.declared ?? null, live: c.live ?? null })).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))),
|
|
38
|
-
}))
|
|
39
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
40
|
-
const subject = JSON.stringify({ environment: drift.environment, changed, missing: [...drift.missing].sort() });
|
|
41
|
-
return `sha256:${createHash("sha256").update(subject, "utf8").digest("hex")}`;
|
|
42
|
-
}
|
|
43
28
|
export async function writeRecordedSource(projectDir, schema) {
|
|
44
29
|
const { sqlTemplateGenerator } = await import("@intentius/chant-lexicon-sql/import-generator");
|
|
45
30
|
// chant's ClickHouse generator writes no user, role, row policy or grant (#46); those go in a file of their own, each its recorded DDL.
|
|
@@ -77,46 +62,11 @@ export function recordedAccessSource(objects) {
|
|
|
77
62
|
lines.push(`export const ${o.export} = ${CH_ACCESS_TAG[o.type ?? ""] ?? "grant"}\`${o.ddl.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}\`;`);
|
|
78
63
|
return `${lines.join("\n")}\n`;
|
|
79
64
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
* grant is compared as part of its grantee's grants): yodel plans `build`
|
|
83
|
-
* against the environment and reads each `grants <grantee>` change as drift.
|
|
84
|
-
* A grant declared and not held is `absent`; one held and not declared
|
|
85
|
-
* (granted by hand, which the next apply revokes) is `changed`, declared
|
|
86
|
-
* nothing. A grantee the server does not have is gone. The grant
|
|
87
|
-
* declarations come off `unobserved`, since they were compared.
|
|
88
|
-
*/
|
|
89
|
-
export async function withClickHouseGrants(drift, project, env, build) {
|
|
90
|
-
const grants = build.output.objects.filter((o) => o.type === "ClickHouse::Grant");
|
|
91
|
-
if (grants.length === 0)
|
|
92
|
-
return drift;
|
|
93
|
-
const plan = await planEnvironment(project, env, build);
|
|
94
|
-
const byGrantee = new Map();
|
|
95
|
-
const missing = [];
|
|
96
|
-
for (const c of plan.diff.changes) {
|
|
97
|
-
if (!c.object.startsWith("grants "))
|
|
98
|
-
continue;
|
|
99
|
-
if (c.rule === "SQLCH200") {
|
|
100
|
-
missing.push(c.object);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (c.rule !== "SQLCH273" && c.rule !== "SQLCH274")
|
|
104
|
-
continue;
|
|
105
|
-
const e = byGrantee.get(c.object) ?? { name: c.object, type: "ClickHouse::Grant", changes: [] };
|
|
106
|
-
e.changes.push(c.rule === "SQLCH273" ? { path: c.field, kind: "absent", declared: c.after } : { path: c.field, kind: "changed", live: c.before });
|
|
107
|
-
byGrantee.set(c.object, e);
|
|
108
|
-
}
|
|
109
|
-
const compared = new Set(grants.map((o) => o.export));
|
|
110
|
-
return {
|
|
111
|
-
...drift,
|
|
112
|
-
changed: [...drift.changed, ...byGrantee.values()],
|
|
113
|
-
missing: [...drift.missing, ...missing].sort(),
|
|
114
|
-
unobserved: drift.unobserved.filter((u) => !compared.has(u.name)),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
65
|
+
/** Whether the drift has anything an apply would change: an object changed or gone, or a pending change. */
|
|
66
|
+
export const hasDrift = (drift) => drift.changed.length > 0 || drift.missing.length > 0 || (drift.pending?.length ?? 0) > 0;
|
|
117
67
|
/** `2` on drift; `1` when there is none but part of the environment could not be read; `0` when clean. */
|
|
118
68
|
export function driftExitCode(drift) {
|
|
119
|
-
if (drift
|
|
69
|
+
if (hasDrift(drift))
|
|
120
70
|
return EXIT_DRIFT;
|
|
121
71
|
return drift.unobserved.length > 0 ? 1 : 0;
|
|
122
72
|
}
|
|
@@ -136,106 +86,37 @@ export function driftFromLifecycle(environment, doc) {
|
|
|
136
86
|
unobserved.set(u.name, u);
|
|
137
87
|
}
|
|
138
88
|
const changed = new Map();
|
|
139
|
-
for (const d of
|
|
89
|
+
for (const d of sql.deep?.drifted ?? []) {
|
|
140
90
|
if (d.changes.length === 0)
|
|
141
91
|
continue;
|
|
142
92
|
const had = changed.get(d.name);
|
|
143
93
|
changed.set(d.name, had ? { ...had, changes: [...had.changes, ...d.changes] } : d);
|
|
144
94
|
}
|
|
95
|
+
const pending = sql.deep?.pending ?? [];
|
|
145
96
|
return {
|
|
146
97
|
environment,
|
|
147
98
|
changed: [...changed.values()],
|
|
148
99
|
missing: [...(sql.resources?.missing ?? [])].sort(),
|
|
100
|
+
...(pending.length > 0 ? { pending: [...pending] } : {}),
|
|
149
101
|
unobserved: [...unobserved.values()].sort((a, b) => a.name.localeCompare(b.name)),
|
|
150
102
|
};
|
|
151
103
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Columns on the server that a declared table does not declare (#273), as
|
|
154
|
-
* drift: `column <name>`, declared none, live its type. chant reports a live
|
|
155
|
-
* column past the declared ones as unclaimed fields `columns[N].*`, which it
|
|
156
|
-
* does not count as drift, since nothing in src/ set them. A group with its
|
|
157
|
-
* own `name` is a whole column; a field of a declared column that src/ does
|
|
158
|
-
* not set (`columns[2].default`) has no name of its own and stays unclaimed.
|
|
159
|
-
*/
|
|
160
|
-
export function extraColumns(unclaimed) {
|
|
161
|
-
const out = [];
|
|
162
|
-
for (const u of unclaimed) {
|
|
163
|
-
const byIndex = new Map();
|
|
164
|
-
for (const f of u.fields) {
|
|
165
|
-
const m = /^columns\[(\d+)\]\.(.+)$/.exec(f.path);
|
|
166
|
-
if (!m?.[1] || !m[2])
|
|
167
|
-
continue;
|
|
168
|
-
const column = byIndex.get(m[1]) ?? {};
|
|
169
|
-
column[m[2]] = f.live;
|
|
170
|
-
byIndex.set(m[1], column);
|
|
171
|
-
}
|
|
172
|
-
const changes = [...byIndex.values()]
|
|
173
|
-
.filter((c) => typeof c.name === "string")
|
|
174
|
-
.map((c) => ({ path: `column ${String(c.name)}`, kind: "changed", live: c.type ?? null }));
|
|
175
|
-
if (changes.length > 0)
|
|
176
|
-
out.push({ name: u.name, type: u.type, changes });
|
|
177
|
-
}
|
|
178
|
-
return out;
|
|
179
|
-
}
|
|
180
104
|
/** Runs `chant lifecycle diff <env> --live --json` in the project and reads the drift from it. */
|
|
181
105
|
export async function readDrift(project, env, options = {}) {
|
|
182
106
|
// chant scopes the build to sourceDir (chant issue 4794); `src` is a directory the caller names.
|
|
183
107
|
const result = await runChant(["lifecycle", "diff", env.name, "--live", "--json", ...(options.src ? ["--src", options.src] : [])], {
|
|
184
108
|
cwd: project.dir,
|
|
109
|
+
noColor: true,
|
|
110
|
+
resolveFallback: true,
|
|
185
111
|
...(options.env ? { env: options.env } : {}),
|
|
186
112
|
});
|
|
187
|
-
const doc =
|
|
113
|
+
const doc = result.json;
|
|
188
114
|
if (result.code !== 0 || doc === undefined) {
|
|
189
115
|
const detail = (result.stderr || result.stdout).trim();
|
|
190
116
|
throw new YodelError(`chant lifecycle diff ${env.name} --live failed (exit ${String(result.code)})${detail ? `:\n${detail}` : ""}`);
|
|
191
117
|
}
|
|
192
118
|
return driftFromLifecycle(env.name, doc);
|
|
193
119
|
}
|
|
194
|
-
const COLUMN_PATH = /^columns\[(\d+)\]/;
|
|
195
|
-
/**
|
|
196
|
-
* The declared column names of each changed object whose drift is named by
|
|
197
|
-
* column position (chant's ClickHouse tables keep columns as a list, so a
|
|
198
|
-
* change reads `columns[3].default.expr`). Read from the project's build,
|
|
199
|
-
* with the dialect's own tag, the way chant reads the declaration.
|
|
200
|
-
*/
|
|
201
|
-
export async function declaredColumns(project, drift, build) {
|
|
202
|
-
const wanted = new Set(drift.changed.filter((e) => e.changes.some((c) => COLUMN_PATH.test(c.path))).map((e) => e.name));
|
|
203
|
-
if (wanted.size === 0)
|
|
204
|
-
return {};
|
|
205
|
-
const b = await build();
|
|
206
|
-
try {
|
|
207
|
-
const tag = project.dialect === "postgres"
|
|
208
|
-
? (await import("@intentius/chant-lexicon-sql/postgres/entities")).table
|
|
209
|
-
: (await import("@intentius/chant-lexicon-sql/clickhouse/entities")).table;
|
|
210
|
-
const out = {};
|
|
211
|
-
for (const o of b.output.objects) {
|
|
212
|
-
if (!wanted.has(o.export))
|
|
213
|
-
continue;
|
|
214
|
-
try {
|
|
215
|
-
const strings = Object.assign([o.ddl], { raw: [o.ddl] });
|
|
216
|
-
const columns = tag(strings).props.columns;
|
|
217
|
-
if (Array.isArray(columns))
|
|
218
|
-
out[o.export] = columns.map((c) => { const n = c.name; return typeof n === "string" ? n : ""; });
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
// Not a table this tag reads: its paths stay as chant gives them.
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return out;
|
|
225
|
-
}
|
|
226
|
-
finally {
|
|
227
|
-
b.dispose();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
/** `columns[3].default.expr` as `column country: default.expr`, when the declaration names column 3. */
|
|
231
|
-
export function describePath(path, columns) {
|
|
232
|
-
const m = COLUMN_PATH.exec(path);
|
|
233
|
-
const name = m && columns ? columns[Number(m[1])] : undefined;
|
|
234
|
-
if (!m || !name)
|
|
235
|
-
return path;
|
|
236
|
-
const rest = path.slice(m[0].length).replace(/^\./, "");
|
|
237
|
-
return `column ${name}${rest ? ` ${rest}` : ""}`;
|
|
238
|
-
}
|
|
239
120
|
const show = (v) => (v === undefined ? "(none)" : typeof v === "string" ? v : JSON.stringify(v));
|
|
240
121
|
/** What the server was compared with, in words. */
|
|
241
122
|
export function describeAgainst(against) {
|
|
@@ -253,7 +134,7 @@ export function renderDrift(drift, server) {
|
|
|
253
134
|
const against = describeAgainst(drift.against);
|
|
254
135
|
if (against)
|
|
255
136
|
lines.push(against, "");
|
|
256
|
-
if (drift
|
|
137
|
+
if (!hasDrift(drift)) {
|
|
257
138
|
lines.push(drift.unobserved.length > 0 ? "No drift in the declared objects that could be read." : "No drift: every declared object matches the server.");
|
|
258
139
|
}
|
|
259
140
|
if (drift.changed.length > 0) {
|
|
@@ -261,8 +142,7 @@ export function renderDrift(drift, server) {
|
|
|
261
142
|
for (const e of drift.changed) {
|
|
262
143
|
lines.push(` ${e.name} (${e.type})`);
|
|
263
144
|
for (const c of e.changes) {
|
|
264
|
-
|
|
265
|
-
lines.push(c.kind === "absent" ? ` ${path}: declared ${show(c.declared)}, absent live` : ` ${path}: declared ${show(c.declared)}, live ${show(c.live)}`);
|
|
145
|
+
lines.push(c.kind === "absent" ? ` ${c.path}: declared ${show(c.declared)}, absent live` : ` ${c.path}: declared ${show(c.declared)}, live ${show(c.live)}`);
|
|
266
146
|
}
|
|
267
147
|
}
|
|
268
148
|
}
|
|
@@ -273,6 +153,13 @@ export function renderDrift(drift, server) {
|
|
|
273
153
|
for (const name of drift.missing)
|
|
274
154
|
lines.push(` ${name}`);
|
|
275
155
|
}
|
|
156
|
+
if (drift.pending?.length) {
|
|
157
|
+
if (drift.changed.length > 0 || drift.missing.length > 0)
|
|
158
|
+
lines.push("");
|
|
159
|
+
lines.push("Added on the server, which the next apply undoes:");
|
|
160
|
+
for (const p of drift.pending)
|
|
161
|
+
lines.push(` ${p.subject}: ${p.change}`);
|
|
162
|
+
}
|
|
276
163
|
if (drift.unobserved.length > 0) {
|
|
277
164
|
lines.push("", "Could not be read, so their state is unknown:");
|
|
278
165
|
for (const u of drift.unobserved)
|