@intentius/sql-yodeler 0.12.1 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/bin.js +3 -0
- package/dist/bin.js.map +1 -1
- package/dist/chant/build.d.ts +4 -2
- package/dist/chant/build.js +5 -3
- package/dist/chant/build.js.map +1 -1
- package/dist/chant/drift.d.ts +0 -9
- package/dist/chant/drift.js +2 -42
- package/dist/chant/drift.js.map +1 -1
- package/dist/chant/gated-request.d.ts +4 -8
- package/dist/chant/gated-request.js +5 -20
- package/dist/chant/gated-request.js.map +1 -1
- package/dist/chant/ledger-fetch.d.ts +46 -0
- package/dist/chant/ledger-fetch.js +42 -0
- package/dist/chant/ledger-fetch.js.map +1 -0
- package/dist/chant/process.d.ts +7 -19
- package/dist/chant/process.js +12 -30
- package/dist/chant/process.js.map +1 -1
- package/dist/chant/resolve-fallback.d.ts +35 -0
- package/dist/chant/resolve-fallback.js +89 -0
- package/dist/chant/resolve-fallback.js.map +1 -0
- package/dist/chant/sql-types.js +2 -1
- package/dist/chant/sql-types.js.map +1 -1
- package/dist/chant-floor-version.d.ts +4 -11
- package/dist/chant-floor-version.js +4 -11
- package/dist/chant-floor-version.js.map +1 -1
- package/dist/chant-floor.d.ts +5 -36
- package/dist/chant-floor.js +5 -65
- package/dist/chant-floor.js.map +1 -1
- package/dist/check/run.js +1 -1
- package/dist/check/run.js.map +1 -1
- package/dist/ci/check-hooks.d.ts +2 -2
- package/dist/ci/check-hooks.js +4 -17
- package/dist/ci/check-hooks.js.map +1 -1
- package/dist/ci/commit.d.ts +106 -0
- package/dist/ci/commit.js +115 -0
- package/dist/ci/commit.js.map +1 -0
- package/dist/ci/login.d.ts +17 -12
- package/dist/ci/login.js +32 -41
- package/dist/ci/login.js.map +1 -1
- package/dist/ci/render.d.ts +75 -47
- package/dist/ci/render.js +209 -284
- package/dist/ci/render.js.map +1 -1
- package/dist/ci-words.d.ts +18 -19
- package/dist/ci-words.js +16 -30
- package/dist/ci-words.js.map +1 -1
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/chant.d.ts +6 -0
- package/dist/commands/chant.js +14 -1
- package/dist/commands/chant.js.map +1 -1
- package/dist/commands/ci.js +15 -4
- package/dist/commands/ci.js.map +1 -1
- package/dist/commands/drift.js +6 -16
- package/dist/commands/drift.js.map +1 -1
- package/dist/commands/init.js +3 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.js +29 -3
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/new.d.ts +7 -0
- package/dist/commands/new.js +156 -22
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/plan.js +7 -4
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/upgrade.d.ts +2 -2
- package/dist/commands/upgrade.js +12 -36
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/config/define.d.ts +37 -0
- package/dist/config/define.js +4 -0
- package/dist/config/define.js.map +1 -1
- package/dist/config/load.js +22 -4
- package/dist/config/load.js.map +1 -1
- package/dist/declarative/plan.d.ts +1 -0
- package/dist/declarative/plan.js +5 -3
- package/dist/declarative/plan.js.map +1 -1
- package/dist/exit.d.ts +15 -37
- package/dist/exit.js +23 -79
- package/dist/exit.js.map +1 -1
- package/dist/init/adopt.d.ts +1 -1
- package/dist/init/adopt.js +3 -2
- package/dist/init/adopt.js.map +1 -1
- package/dist/lint/rules.d.ts +3 -1
- package/dist/lint/rules.js +3 -1
- package/dist/lint/rules.js.map +1 -1
- package/dist/lint/unmigrated.d.ts +18 -0
- package/dist/lint/unmigrated.js +62 -0
- package/dist/lint/unmigrated.js.map +1 -0
- package/dist/mcp/chant-hook.d.ts +1 -2
- package/dist/mcp/chant-hook.js +4 -12
- package/dist/mcp/chant-hook.js.map +1 -1
- package/dist/notify/index.d.ts +11 -4
- package/dist/notify/index.js +18 -16
- package/dist/notify/index.js.map +1 -1
- package/dist/pr/forge.d.ts +7 -6
- package/dist/pr/forge.js +19 -56
- package/dist/pr/forge.js.map +1 -1
- package/dist/pr/issue.d.ts +27 -19
- package/dist/pr/issue.js +60 -11
- package/dist/pr/issue.js.map +1 -1
- package/dist/pr/note.d.ts +4 -2
- package/dist/pr/note.js +21 -16
- package/dist/pr/note.js.map +1 -1
- package/dist/pr/overdue.d.ts +5 -12
- package/dist/pr/overdue.js +7 -49
- package/dist/pr/overdue.js.map +1 -1
- package/dist/pr/render.d.ts +0 -2
- package/dist/pr/render.js +0 -2
- package/dist/pr/render.js.map +1 -1
- package/dist/pr/tenants.d.ts +1 -0
- package/dist/pr/tenants.js +6 -4
- package/dist/pr/tenants.js.map +1 -1
- package/dist/project.d.ts +1 -1
- package/dist/project.js +3 -2
- package/dist/project.js.map +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/sources/index.js +2 -1
- package/dist/sources/index.js.map +1 -1
- package/dist/versioned/op.js +6 -3
- package/dist/versioned/op.js.map +1 -1
- package/package.json +9 -8
- package/schemas/event.schema.json +17 -2
package/dist/lint/rules.d.ts
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
*
|
|
24
24
|
* The rest (`refused-step`, `pg-routine-in-use`, `migration-sql`,
|
|
25
25
|
* `silence`) say a migration will not apply as written or a silence is
|
|
26
|
-
* wrong.
|
|
26
|
+
* wrong, and `unmigrated` (a warning, `./unmigrated.ts`) that the declared
|
|
27
|
+
* schema is ahead of the newest migration. Their level can be
|
|
27
28
|
* changed in `yodel.config.ts`, but they cannot be silenced.
|
|
28
29
|
*/
|
|
29
30
|
export type LintLevel = "error" | "warning";
|
|
@@ -89,6 +90,7 @@ export declare const LINT_RULES: {
|
|
|
89
90
|
readonly "ch-access": LintRule;
|
|
90
91
|
readonly "refused-step": LintRule;
|
|
91
92
|
readonly "migration-sql": LintRule;
|
|
93
|
+
readonly unmigrated: LintRule;
|
|
92
94
|
readonly silence: LintRule;
|
|
93
95
|
};
|
|
94
96
|
export type LintRuleId = keyof typeof LINT_RULES;
|
package/dist/lint/rules.js
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
*
|
|
24
24
|
* The rest (`refused-step`, `pg-routine-in-use`, `migration-sql`,
|
|
25
25
|
* `silence`) say a migration will not apply as written or a silence is
|
|
26
|
-
* wrong.
|
|
26
|
+
* wrong, and `unmigrated` (a warning, `./unmigrated.ts`) that the declared
|
|
27
|
+
* schema is ahead of the newest migration. Their level can be
|
|
27
28
|
* changed in `yodel.config.ts`, but they cannot be silenced.
|
|
28
29
|
*/
|
|
29
30
|
import { SCHEMA_RULES } from "./schema-checks.js";
|
|
@@ -50,6 +51,7 @@ export const LINT_RULES = {
|
|
|
50
51
|
"ch-access": statement("ch-access", "ClickHouse: takes access away: a privilege or role revoked from a user or role (SQLCH274)", "clickhouse"),
|
|
51
52
|
"refused-step": shape("refused-step", "a step yodel apply refuses to run: a manual step, or an Op step it does not run"),
|
|
52
53
|
"migration-sql": shape("migration-sql", "migration.sql does not hold a statement as migration.json records it; apply runs migration.json's"),
|
|
54
|
+
unmigrated: shape("unmigrated", "the declared schema has a change no migration records: yodel new would write one (a warning)", "warning"),
|
|
53
55
|
silence: shape("silence", "a yodel:allow line that is malformed, names a rule no statement can silence, has no reason, or silences nothing"),
|
|
54
56
|
};
|
|
55
57
|
export const ruleIds = Object.keys(LINT_RULES);
|
package/dist/lint/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/lint/rules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/lint/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAoBlD,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,OAAe,EAAY,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KA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AC,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAoB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAExF,wGAAwG;AACxG,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAa,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `unmigrated` rule (#311): the declared schema in the source directory
|
|
3
|
+
* has a change no migration records, so `yodel new` would write one. It is
|
|
4
|
+
* the finding chant's commit job reads on its check trigger to start
|
|
5
|
+
* `/yodel new` (the sql lexicon's `YODEL_COMMIT_FINDINGS`).
|
|
6
|
+
*
|
|
7
|
+
* It builds the declared schema, offline, and diffs the newest migration's
|
|
8
|
+
* recorded schema against it, as `yodel new` does. It reports nothing when
|
|
9
|
+
* the directory is not one chain (`fork` and `directory` say why, and a
|
|
10
|
+
* rebase comes first), when the project names no source directory, or when
|
|
11
|
+
* the build fails: chant's own build and lint report that, and a finding
|
|
12
|
+
* here would start a `yodel new` that fails the same way. A warning unless
|
|
13
|
+
* `lint.rules.unmigrated` sets another level.
|
|
14
|
+
*/
|
|
15
|
+
import type { Project } from "../project.js";
|
|
16
|
+
import type { ProjectRule } from "./check.js";
|
|
17
|
+
/** The rule over `project`; `note` gets the reason it did not run, for standard error. */
|
|
18
|
+
export declare function unmigratedRule(project: Project, note?: (text: string) => void): ProjectRule;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `unmigrated` rule (#311): the declared schema in the source directory
|
|
3
|
+
* has a change no migration records, so `yodel new` would write one. It is
|
|
4
|
+
* the finding chant's commit job reads on its check trigger to start
|
|
5
|
+
* `/yodel new` (the sql lexicon's `YODEL_COMMIT_FINDINGS`).
|
|
6
|
+
*
|
|
7
|
+
* It builds the declared schema, offline, and diffs the newest migration's
|
|
8
|
+
* recorded schema against it, as `yodel new` does. It reports nothing when
|
|
9
|
+
* the directory is not one chain (`fork` and `directory` say why, and a
|
|
10
|
+
* rebase comes first), when the project names no source directory, or when
|
|
11
|
+
* the build fails: chant's own build and lint report that, and a finding
|
|
12
|
+
* here would start a `yodel new` that fails the same way. A warning unless
|
|
13
|
+
* `lint.rules.unmigrated` sets another level.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { buildSchema } from "../chant/build.js";
|
|
17
|
+
import { createMigration, newestMigration } from "../migrations/index.js";
|
|
18
|
+
import { resolveSourceDir } from "@intentius/chant/config";
|
|
19
|
+
import { LINT_RULES } from "./rules.js";
|
|
20
|
+
/** Whether the project names a directory its schema is declared in: a `sourceDir` that exists. */
|
|
21
|
+
const declares = (project) => project.config.sourceDir !== undefined && existsSync(resolveSourceDir(project.dir, project.config));
|
|
22
|
+
/** The rule over `project`; `note` gets the reason it did not run, for standard error. */
|
|
23
|
+
export function unmigratedRule(project, note = () => { }) {
|
|
24
|
+
return {
|
|
25
|
+
rule: LINT_RULES.unmigrated,
|
|
26
|
+
check: async (ctx) => {
|
|
27
|
+
const ordered = ctx.scan.ordered;
|
|
28
|
+
if (!ordered || !declares(project))
|
|
29
|
+
return [];
|
|
30
|
+
const newest = newestMigration(ordered);
|
|
31
|
+
let build;
|
|
32
|
+
try {
|
|
33
|
+
build = await buildSchema(project, { empty: true });
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
note(`the declared schema did not build, so it is not compared with the newest migration (rule unmigrated): ${(e instanceof Error ? e.message : String(e)).split("\n")[0] ?? ""}`);
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const made = createMigration({ name: "unmigrated", build: build.output, previous: newest });
|
|
41
|
+
if (made.id === undefined)
|
|
42
|
+
return [];
|
|
43
|
+
const n = made.statements.steps.length;
|
|
44
|
+
const from = newest ? `${newest.id}'s recorded schema` : "an empty schema";
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
rule: LINT_RULES.unmigrated.id,
|
|
48
|
+
message: `the declared schema in ${project.sourceDir} is ahead of ${from} by ${String(n)} step${n === 1 ? "" : "s"} no migration records; write them with yodel new <name>`,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
note(`the declared schema could not be compared with the newest migration (rule unmigrated): ${(e instanceof Error ? e.message : String(e)).split("\n")[0] ?? ""}`);
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
build.dispose();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=unmigrated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmigrated.js","sourceRoot":"","sources":["../../src/lint/unmigrated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,kGAAkG;AAClG,MAAM,QAAQ,GAAG,CAAC,OAAgB,EAAW,EAAE,CAC5C,OAAO,CAAC,MAAkC,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnI,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,OA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,UAAU,CAAC,EAAE;wBAC9B,OAAO,EAAE,0BAA0B,OAAO,CAAC,SAAS,gBAAgB,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,yDAAyD;qBAC5K;iBACF,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,0FAA0F,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACpK,OAAO,EAAE,CAAC;YACZ,CAAC;oBAAS,CAAC;gBACT,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/mcp/chant-hook.d.ts
CHANGED
|
@@ -28,9 +28,8 @@ export interface ChantHooks {
|
|
|
28
28
|
configureOtlp: (opts: {
|
|
29
29
|
prefix: string;
|
|
30
30
|
}) => unknown;
|
|
31
|
-
PRODUCT_MCP_HOOK_FLOOR: string;
|
|
32
31
|
}
|
|
33
|
-
/** chant's product tool hook and OTLP exporter (chant#4555), once
|
|
32
|
+
/** chant's product tool hook and OTLP exporter (chant#4555), once. */
|
|
34
33
|
export declare function chantHooks(): Promise<ChantHooks>;
|
|
35
34
|
/** One of yodel's tools as chant's contribution: the same handler, read-only. */
|
|
36
35
|
export declare function asChantTool(t: YodelTool): ChantMcpTool;
|
package/dist/mcp/chant-hook.js
CHANGED
|
@@ -17,27 +17,19 @@
|
|
|
17
17
|
* that `yodel chant run wave` runs sends its trace with `yodel.*`
|
|
18
18
|
* attributes. Without the exporter nothing is sent, as before.
|
|
19
19
|
*
|
|
20
|
-
* Both are imported
|
|
21
|
-
*
|
|
20
|
+
* Both are imported on first use, so a yodel command that serves nothing
|
|
21
|
+
* does not load chant's server.
|
|
22
22
|
*/
|
|
23
23
|
import { YODEL_WORDS } from "../ci-words.js";
|
|
24
|
-
import { CHANT_CI_FLOOR, installLine } from "../chant-floor-version.js";
|
|
25
|
-
import { YodelError } from "../project.js";
|
|
26
24
|
import { assertReadOnly, yodelTools } from "./tools.js";
|
|
27
25
|
/** What the server tells an agent it serves, and what is a person's to do. */
|
|
28
26
|
export const INSTRUCTIONS = "Read-only tools over a SQL Yodeler project: status, plan, lint, drift, history and explain. Each result is an envelope whose results follow the JSON Schema named in resultsSchema. " +
|
|
29
27
|
"Nothing here applies, approves, overrides a policy rule, repairs, rebases or writes a migration. A plan carries the commands that are a person's (approve, override) in forPerson: show them to the person, and never run them. " +
|
|
30
28
|
"Never run `yodel apply` against a shared environment, never run `chant approve`, `yodel approve` or `yodel override`, never edit the `chant/lifecycle` branch or `.chant/allowed_signers`, never merge; approvals and applies belong to people.";
|
|
31
29
|
let hooks;
|
|
32
|
-
/** chant's product tool hook and OTLP exporter (chant#4555), once
|
|
30
|
+
/** chant's product tool hook and OTLP exporter (chant#4555), once. */
|
|
33
31
|
export function chantHooks() {
|
|
34
|
-
hooks ??= (
|
|
35
|
-
const specifier = "@intentius/chant/ci-product";
|
|
36
|
-
const m = (await import(specifier).catch(() => ({})));
|
|
37
|
-
if (typeof m.runChantInProcess === "function" && typeof m.configureOtlp === "function" && typeof m.PRODUCT_MCP_HOOK_FLOOR === "string")
|
|
38
|
-
return m;
|
|
39
|
-
throw new YodelError(`the installed chant has no product tool hook (chant serve mcp with yodel's tools), which yodel mcp serves on from chant ${CHANT_CI_FLOOR}. Install it:\n ${installLine()}`);
|
|
40
|
-
})();
|
|
32
|
+
hooks ??= import("@intentius/chant/ci-product").then((m) => m);
|
|
41
33
|
return hooks;
|
|
42
34
|
}
|
|
43
35
|
/** One of yodel's tools as chant's contribution: the same handler, read-only. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chant-hook.js","sourceRoot":"","sources":["../../src/mcp/chant-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"chant-hook.js","sourceRoot":"","sources":["../../src/mcp/chant-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAExE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GACvB,sLAAsL;IACtL,kOAAkO;IAClO,iPAAiP,CAAC;AAyBpP,IAAI,KAAsC,CAAC;AAE3C,sEAAsE;AACtE,MAAM,UAAU,UAAU;IACxB,KAAK,KAAK,MAAM,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAA0B,CAAC,CAAC;IACxF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,CAAY;IACtC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChK,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAA8B,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_EVENTS, makeNotifyEvent, notifyConfigProblem, slackMessage, webhookRequest } from "@intentius/chant/notify";
|
|
23
23
|
export type { NotifyConfig, NotifyDelivery, NotifyEvent, NotifyEventKind, NotifyFields } from "@intentius/chant/notify";
|
|
24
|
-
/** The product name events carry in `source`. */
|
|
25
|
-
export declare const SOURCE
|
|
26
|
-
/** What yodel says on top of chant's event: the command that sent it, in `detail
|
|
24
|
+
/** The product name events carry in `source`: the words' `notify.source`. */
|
|
25
|
+
export declare const SOURCE: string;
|
|
26
|
+
/** What yodel says on top of chant's event: the command that sent it, in `detail`, and for drift the objects that drifted. */
|
|
27
27
|
export type YodelFields = NotifyFields & {
|
|
28
28
|
detail: {
|
|
29
29
|
command: "apply" | "plan" | "drift";
|
|
30
|
+
changed?: string[];
|
|
31
|
+
missing?: string[];
|
|
30
32
|
};
|
|
31
33
|
};
|
|
32
34
|
/**
|
|
@@ -34,7 +36,12 @@ export type YodelFields = NotifyFields & {
|
|
|
34
36
|
* or undefined when the outcome is not one an event is sent for.
|
|
35
37
|
*/
|
|
36
38
|
export declare function eventFromRun(command: "apply" | "plan", doc: Record<string, unknown>): YodelFields | undefined;
|
|
37
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* The event for what `yodel drift --json` printed, or undefined when nothing
|
|
41
|
+
* drifted: chant's drift event (`driftNotifyFields`) under yodel's words, so
|
|
42
|
+
* `drift.changed` and `targets` name the environment, as every product on
|
|
43
|
+
* chant names its members, and `detail` the objects that changed or are gone.
|
|
44
|
+
*/
|
|
38
45
|
export declare function eventFromDrift(doc: {
|
|
39
46
|
environment?: string;
|
|
40
47
|
drifted?: boolean;
|
package/dist/notify/index.js
CHANGED
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
* command's exit code: the event is news about the run, not part of it.
|
|
18
18
|
*/
|
|
19
19
|
import { makeNotifyEvent, sendNotify } from "@intentius/chant/notify";
|
|
20
|
-
import {
|
|
20
|
+
import { driftNotifyFields, productNotifySource, productSendOptions } from "@intentius/chant/notify-product";
|
|
21
|
+
import { assertProductWords } from "@intentius/chant/ci-product-words";
|
|
22
|
+
import { YODEL_WORDS } from "../ci-words.js";
|
|
21
23
|
export * from "./verify.js";
|
|
22
24
|
export { NOTIFY_EVENTS, makeNotifyEvent, notifyConfigProblem, slackMessage, webhookRequest } from "@intentius/chant/notify";
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
+
/** yodel's words, which give the event's `source`, the header prefix and a drift summary's nouns (chant's notify-product, #319). */
|
|
26
|
+
const WORDS = assertProductWords(YODEL_WORDS);
|
|
27
|
+
/** The product name events carry in `source`: the words' `notify.source`. */
|
|
28
|
+
export const SOURCE = productNotifySource(WORDS);
|
|
25
29
|
const ids = (list) => (Array.isArray(list) ? list.flatMap((p) => (typeof p === "object" && p !== null && typeof p.id === "string" ? [p.id] : [])) : []);
|
|
26
30
|
const str = (v) => (typeof v === "string" && v !== "" ? v : undefined);
|
|
27
31
|
const firstLine = (s) => s.split("\n")[0] ?? s;
|
|
@@ -66,22 +70,21 @@ export function eventFromRun(command, doc) {
|
|
|
66
70
|
}
|
|
67
71
|
return undefined;
|
|
68
72
|
}
|
|
69
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* The event for what `yodel drift --json` printed, or undefined when nothing
|
|
75
|
+
* drifted: chant's drift event (`driftNotifyFields`) under yodel's words, so
|
|
76
|
+
* `drift.changed` and `targets` name the environment, as every product on
|
|
77
|
+
* chant names its members, and `detail` the objects that changed or are gone.
|
|
78
|
+
*/
|
|
70
79
|
export function eventFromDrift(doc) {
|
|
71
80
|
if (!doc.drifted)
|
|
72
81
|
return undefined;
|
|
73
82
|
const changed = (doc.changed ?? []).map((c) => c.name);
|
|
74
83
|
const missing = doc.missing ?? [];
|
|
75
84
|
const environment = doc.environment ?? "";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
environment,
|
|
80
|
-
status: "drifted",
|
|
81
|
-
detail: { command: "drift" },
|
|
82
|
-
summary: `${environment} drifted: ${[changed.length > 0 ? `${changed.join(", ")} changed` : "", missing.length > 0 ? `${missing.join(", ")} missing` : ""].filter(Boolean).join("; ")}`,
|
|
83
|
-
drift: { changed, missing, ...(doc.fingerprint ? { fingerprint: doc.fingerprint } : {}) },
|
|
84
|
-
};
|
|
85
|
+
const fields = driftNotifyFields(WORDS, { changed: [environment], environment, ...(doc.fingerprint ? { fingerprint: doc.fingerprint } : {}) });
|
|
86
|
+
const objects = [changed.length > 0 ? `${changed.join(", ")} changed` : "", missing.length > 0 ? `${missing.join(", ")} missing` : ""].filter(Boolean).join("; ");
|
|
87
|
+
return { ...fields, status: "drifted", summary: objects ? `${fields.summary} (${objects})` : fields.summary, detail: { command: "drift", changed, missing } };
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
87
90
|
* Sends the event to what `config` names, through chant's notify under
|
|
@@ -93,15 +96,14 @@ export async function sendEvent(config, fields, options) {
|
|
|
93
96
|
if (!config || !fields)
|
|
94
97
|
return [];
|
|
95
98
|
const env = options.env ?? process.env;
|
|
96
|
-
return sendNotify(config, makeNotifyEvent(fields, { env }), {
|
|
99
|
+
return sendNotify(config, makeNotifyEvent(fields, { env }), productSendOptions(WORDS, {
|
|
97
100
|
env,
|
|
98
|
-
prefix: HEADER_PREFIX,
|
|
99
101
|
userAgent: SOURCE,
|
|
100
102
|
log: (line) => {
|
|
101
103
|
options.io.err(`yodel ${options.verb}: ${line}\n`);
|
|
102
104
|
},
|
|
103
105
|
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
104
106
|
...(options.attempts !== undefined ? { attempts: options.attempts } : {}),
|
|
105
|
-
});
|
|
107
|
+
}));
|
|
106
108
|
}
|
|
107
109
|
//# sourceMappingURL=index.js.map
|
package/dist/notify/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notify/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,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AC,EAChC,kBAAkB,CAAC,KAAK,EAAE;QACxB,GAAG;QACH,SAAS,EAAE,MAAM;QACjB,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/pr/forge.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Where `yodel plan <env> --comment` and `yodel drift <env> --issue` post:
|
|
3
3
|
* chant's forge client (`@intentius/chant/pr-forge`, #210) for the CI job's
|
|
4
4
|
* forge, repository, pull (merge) request and token, each overridden by a
|
|
5
|
-
* flag. chant reads the job's environment and
|
|
6
|
-
*
|
|
5
|
+
* flag. chant reads the job's environment and the flags
|
|
6
|
+
* (`@intentius/chant/forge-flags`, chant issue 4800) and makes every REST
|
|
7
|
+
* call; yodel keeps the bodies.
|
|
7
8
|
*
|
|
8
9
|
* - GitHub Actions: `GITHUB_ACTIONS=true`. `GITHUB_REPOSITORY`, the PR number
|
|
9
10
|
* from the event payload (`GITHUB_EVENT_PATH`) or `refs/pull/<n>/merge` in
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
*/
|
|
27
28
|
import type { ForgeFetch, ForgeKind, ForgeTarget, PrForge } from "@intentius/chant/pr-forge";
|
|
28
29
|
export type { ForgeKind, ForgeTarget, PrForge };
|
|
29
|
-
export declare const FORGES: readonly ForgeKind[];
|
|
30
30
|
export interface ForgeFlags {
|
|
31
31
|
forge?: string | undefined;
|
|
32
32
|
repo?: string | undefined;
|
|
@@ -40,9 +40,10 @@ export interface Forge {
|
|
|
40
40
|
client: PrForge;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* chant's forge client for `--comment` (`
|
|
44
|
-
* `--issue`, from flags and the environment
|
|
45
|
-
*
|
|
43
|
+
* chant's forge client for `--comment` (`requirePr`: the pull request too)
|
|
44
|
+
* or `--issue`, from flags and the environment by chant's
|
|
45
|
+
* `forgeTargetFromFlags`, or a YodelError saying what is missing and which
|
|
46
|
+
* flags supply it (`forgeFlagHints`). `what` names the option, for messages.
|
|
46
47
|
*/
|
|
47
48
|
export declare function resolveForge(flags: ForgeFlags, env: NodeJS.ProcessEnv, what: "--comment" | "--issue", fetchImpl?: ForgeFetch): Promise<Forge>;
|
|
48
49
|
/** `github acme/db`, for messages. */
|
package/dist/pr/forge.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Where `yodel plan <env> --comment` and `yodel drift <env> --issue` post:
|
|
3
3
|
* chant's forge client (`@intentius/chant/pr-forge`, #210) for the CI job's
|
|
4
4
|
* forge, repository, pull (merge) request and token, each overridden by a
|
|
5
|
-
* flag. chant reads the job's environment and
|
|
6
|
-
*
|
|
5
|
+
* flag. chant reads the job's environment and the flags
|
|
6
|
+
* (`@intentius/chant/forge-flags`, chant issue 4800) and makes every REST
|
|
7
|
+
* call; yodel keeps the bodies.
|
|
7
8
|
*
|
|
8
9
|
* - GitHub Actions: `GITHUB_ACTIONS=true`. `GITHUB_REPOSITORY`, the PR number
|
|
9
10
|
* from the event payload (`GITHUB_EVENT_PATH`) or `refs/pull/<n>/merge` in
|
|
@@ -25,72 +26,34 @@
|
|
|
25
26
|
* and never put in an error.
|
|
26
27
|
*/
|
|
27
28
|
import { YodelError } from "../project.js";
|
|
28
|
-
export const FORGES = ["github", "gitlab", "forgejo"];
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
function withFlags(kind, flags, env) {
|
|
35
|
-
const out = { ...env };
|
|
36
|
-
if (kind === "gitlab") {
|
|
37
|
-
if (flags.repo !== undefined) {
|
|
38
|
-
out.CI_MERGE_REQUEST_PROJECT_ID = flags.repo;
|
|
39
|
-
out.CI_PROJECT_ID = flags.repo;
|
|
40
|
-
}
|
|
41
|
-
if (flags.pr !== undefined)
|
|
42
|
-
out.CI_MERGE_REQUEST_IID = flags.pr;
|
|
43
|
-
if (flags.apiUrl !== undefined)
|
|
44
|
-
out.CI_API_V4_URL = flags.apiUrl;
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
|
-
// A Forgejo job reads FORGEJO_* before GITHUB_*, so a flag sets both.
|
|
48
|
-
const set = (name, value) => {
|
|
49
|
-
out[`GITHUB_${name}`] = value;
|
|
50
|
-
out[`FORGEJO_${name}`] = value;
|
|
51
|
-
};
|
|
52
|
-
if (flags.repo !== undefined)
|
|
53
|
-
set("REPOSITORY", flags.repo);
|
|
54
|
-
if (flags.apiUrl !== undefined)
|
|
55
|
-
set("API_URL", flags.apiUrl);
|
|
56
|
-
if (flags.pr !== undefined) {
|
|
57
|
-
// The event payload names the pull request before the ref does.
|
|
58
|
-
set("EVENT_PATH", undefined);
|
|
59
|
-
set("REF", `refs/pull/${flags.pr}/merge`);
|
|
60
|
-
}
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* chant's forge client for `--comment` (`withPr`: the pull request too) or
|
|
65
|
-
* `--issue`, from flags and the environment, or a YodelError saying what is
|
|
66
|
-
* missing. `what` names the option, for messages.
|
|
30
|
+
* chant's forge client for `--comment` (`requirePr`: the pull request too)
|
|
31
|
+
* or `--issue`, from flags and the environment by chant's
|
|
32
|
+
* `forgeTargetFromFlags`, or a YodelError saying what is missing and which
|
|
33
|
+
* flags supply it (`forgeFlagHints`). `what` names the option, for messages.
|
|
67
34
|
*/
|
|
68
35
|
export async function resolveForge(flags, env, what, fetchImpl) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (flags.pr !== undefined && !/^[1-9]\d*$/.test(flags.pr))
|
|
73
|
-
throw new YodelError(`--pr must be a pull request number, got ${JSON.stringify(flags.pr)}`);
|
|
74
|
-
const { detectForge, forgeTargetFromEnv, forgeClient, ForgeEnvironmentError } = await import("@intentius/chant/pr-forge");
|
|
75
|
-
const kind = flags.forge ?? detectForge(env);
|
|
76
|
-
if (!kind)
|
|
77
|
-
throw new YodelError(`${what} cannot tell the forge: not a GitHub Actions, GitLab CI or Forgejo Actions job; pass --forge github|gitlab|forgejo with --repo${withPr ? ", --pr" : ""} and --api-url`);
|
|
36
|
+
const requirePr = what === "--comment";
|
|
37
|
+
const { forgeClient, ForgeEnvironmentError } = await import("@intentius/chant/pr-forge");
|
|
38
|
+
const { forgeTargetFromFlags, forgeFlagHints, ForgeFlagError } = await import("@intentius/chant/forge-flags");
|
|
78
39
|
let target;
|
|
79
40
|
try {
|
|
80
|
-
target =
|
|
41
|
+
target = forgeTargetFromFlags(chantFlags(flags), env, { requirePr });
|
|
81
42
|
}
|
|
82
43
|
catch (e) {
|
|
44
|
+
if (e instanceof ForgeFlagError)
|
|
45
|
+
throw new YodelError(e.message);
|
|
83
46
|
if (!(e instanceof ForgeEnvironmentError))
|
|
84
47
|
throw e;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
];
|
|
90
|
-
throw new YodelError(`${what} on ${kind} needs ${e.missing.join(", ")}${hints.length ? `; ${hints.join("; ")}` : ""}`);
|
|
48
|
+
if (e.kind === undefined)
|
|
49
|
+
throw new YodelError(`${what} cannot tell the forge: not a GitHub Actions, GitLab CI or Forgejo Actions job; pass --forge github|gitlab|forgejo with --repo${requirePr ? ", --pr" : ""} and --api-url`);
|
|
50
|
+
const hints = forgeFlagHints(e, { requirePr, tokenEnv: flags.tokenEnv !== undefined });
|
|
51
|
+
throw new YodelError(`${what} on ${e.kind} needs ${e.missing.join(", ")}${hints.length ? `; ${hints.join("; ")}` : ""}`);
|
|
91
52
|
}
|
|
92
53
|
return { target, client: forgeClient(target, fetchImpl) };
|
|
93
54
|
}
|
|
55
|
+
/** The flags as chant's `ForgeFlags`, leaving out each one not given. */
|
|
56
|
+
const chantFlags = (flags) => Object.fromEntries(Object.entries(flags).filter((e) => typeof e[1] === "string"));
|
|
94
57
|
/** `github acme/db`, for messages. */
|
|
95
58
|
export const describeForge = (t) => `${t.kind} ${t.repo}`;
|
|
96
59
|
//# sourceMappingURL=forge.js.map
|
package/dist/pr/forge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forge.js","sourceRoot":"","sources":["../../src/pr/forge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"forge.js","sourceRoot":"","sources":["../../src/pr/forge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkB3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAiB,EAAE,GAAsB,EAAE,IAA6B,EAAE,SAAsB;IACjI,MAAM,SAAS,GAAG,IAAI,KAAK,WAAW,CAAC;IACvC,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;IACzF,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;IAC9G,IAAI,MAAmB,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACvE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY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36 +2,25 @@
|
|
|
2
2
|
* The drift watch's tracking issue (#49): one open issue per project and
|
|
3
3
|
* environment, found by its marker, opened when drift is found, updated
|
|
4
4
|
* while it lasts, and closed, with a comment, when it is gone. chant's
|
|
5
|
-
* `
|
|
6
|
-
* the
|
|
5
|
+
* `keepDriftIssue` (`@intentius/chant/drift-issue`, chant issue 4790)
|
|
6
|
+
* decides, writes the body and fingerprints the drift; yodel gives its words,
|
|
7
|
+
* its marker and the run's drift as chant's drift records.
|
|
7
8
|
*
|
|
8
9
|
* Only open issues are read, so a closed one is never reopened: drift found
|
|
9
10
|
* again after a close opens a new issue. The issue counts as current while
|
|
10
11
|
* its title is the same and its body carries the drift's fingerprint, so a
|
|
11
12
|
* body that names a new run does not edit it on every scheduled run.
|
|
12
13
|
*/
|
|
14
|
+
import type { DriftIssueRecord, DriftIssueWords } from "@intentius/chant/drift-issue";
|
|
13
15
|
import type { PrForge } from "@intentius/chant/pr-forge";
|
|
16
|
+
import { type Drift } from "../chant/drift.js";
|
|
17
|
+
import { type ServerInfo } from "../server.js";
|
|
14
18
|
/**
|
|
15
19
|
* The marker an environment's tracking issue carries, so the next run finds
|
|
16
20
|
* it. Keyed by the project's directory in its repository (`.` at the root),
|
|
17
21
|
* so two projects in one repository keep their own issues.
|
|
18
22
|
*/
|
|
19
23
|
export declare function driftIssueMarker(project: string, environment: string): string;
|
|
20
|
-
/** What the run found, as the tracking issue needs it. */
|
|
21
|
-
export type DriftOutcome = {
|
|
22
|
-
kind: "drift";
|
|
23
|
-
title: string;
|
|
24
|
-
body: string;
|
|
25
|
-
fingerprint: string;
|
|
26
|
-
} | {
|
|
27
|
-
kind: "clean";
|
|
28
|
-
comment: string;
|
|
29
|
-
}
|
|
30
|
-
/** The drift could not be read, or part of the environment could not: the issue is left as it is. */
|
|
31
|
-
| {
|
|
32
|
-
kind: "unknown";
|
|
33
|
-
why: string;
|
|
34
|
-
};
|
|
35
24
|
/** The tracking issue a run touched. */
|
|
36
25
|
export interface TrackedIssue {
|
|
37
26
|
number: number;
|
|
@@ -47,5 +36,24 @@ export type IssueAction = {
|
|
|
47
36
|
why: string;
|
|
48
37
|
issue?: TrackedIssue;
|
|
49
38
|
};
|
|
50
|
-
/**
|
|
51
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The drift as chant's records: the changed objects through chant's
|
|
41
|
+
* `deepDiffDriftRecords` (declared before, live after; a column by its
|
|
42
|
+
* name), laid over `liveDiffDriftRecords` for the objects gone (`pending`
|
|
43
|
+
* in a read with no snapshot) and those that could not be read.
|
|
44
|
+
*/
|
|
45
|
+
export declare function driftRecords(drift: Drift, observedAt: string): Promise<DriftIssueRecord[]>;
|
|
46
|
+
/** yodel's words for chant's drift issue, for one run's drift and server. */
|
|
47
|
+
export declare function driftIssueWords(drift: Drift, server: ServerInfo | undefined): DriftIssueWords;
|
|
48
|
+
/**
|
|
49
|
+
* Brings the environment's tracking issue in line with the run: chant's
|
|
50
|
+
* `keepDriftIssue` over the drift's records. `unknown` is why the drift
|
|
51
|
+
* could not be read, which leaves the issue as it is.
|
|
52
|
+
*/
|
|
53
|
+
export declare function trackDrift(forge: Pick<PrForge, "trackIssue">, marker: string, run: {
|
|
54
|
+
drift: Drift;
|
|
55
|
+
server?: ServerInfo | undefined;
|
|
56
|
+
runUrl?: string | undefined;
|
|
57
|
+
unknown?: string | undefined;
|
|
58
|
+
now?: string;
|
|
59
|
+
}): Promise<IssueAction>;
|