@intentius/chant-lexicon-k3s 0.49.0 → 0.50.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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { k3sInstall, k3sUninstall } from "./op/builders.js";
1
2
  export { k3sPlugin } from "./plugin.js";
2
3
  export { k3sSerializer } from "./serializer.js";
3
4
  export * from "./generated/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Typed step-builder wrappers for this lexicon's activities (chant #1288
3
+ * Stage 2). See `lexicons/k8s/src/op/builders.ts`'s module doc for why these
4
+ * live beside their `*Args` interfaces rather than in core or the temporal
5
+ * barrel. `opts`'s type in each wrapper below IS the activity's own `*Args`
6
+ * interface (via `Omit`/`WithStepRefs`) — never restated. `core`'s own
7
+ * `k3sInstall`/`k3sUninstall` are unchanged and produce byte-identical
8
+ * `ActivityStep` output; these are purely additive.
9
+ */
10
+ import { type ActivityStep, type NamedActivityStep, type WithStepRefs } from "@intentius/chant/op";
11
+ import type { K3sInstallArgs, K3sUninstallArgs, K3sRole } from "./activities/k3s.js";
12
+ /** Extra opts every wrapper below accepts alongside its activity's own fields. */
13
+ type StepOpts = {
14
+ profile?: ActivityStep["profile"];
15
+ id?: string;
16
+ };
17
+ /**
18
+ * Run the pinned k3s installer against a reachable host — the fully typed
19
+ * twin of core's `k3sInstall`. `opts` is {@link K3sInstallArgs} itself,
20
+ * minus the positional `role` (`configFile` remains required). Defaults to
21
+ * the `longInfra` profile.
22
+ */
23
+ export declare const k3sInstall: (role: K3sRole, opts: WithStepRefs<Omit<K3sInstallArgs, "role">> & StepOpts) => NamedActivityStep;
24
+ /**
25
+ * Uninstall k3s from a reachable host — the fully typed twin of core's
26
+ * `k3sUninstall`. `opts` is {@link K3sUninstallArgs} itself, minus the
27
+ * positional `role`. Defaults to the `fastIdempotent` profile.
28
+ */
29
+ export declare const k3sUninstall: (role: K3sRole, opts?: WithStepRefs<Omit<K3sUninstallArgs, "role">> & StepOpts) => NamedActivityStep;
30
+ export {};
31
+ //# sourceMappingURL=builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../src/op/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElF,kFAAkF;AAClF,KAAK,QAAQ,GAAG;IAAE,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,OAAO,EACb,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,KAC1D,iBAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,OAAO,EACb,OAAO,YAAY,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,KAC7D,iBAGF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-k3s",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "peerDependencies": {
53
- "@intentius/chant": "^0.49.0",
53
+ "@intentius/chant": "^0.50.0",
54
54
  "typescript": "^5.9.3"
55
55
  },
56
56
  "description": "k3s lexicon for chant — the k3s distro's host configuration as declarable data",
package/src/index.ts CHANGED
@@ -1,3 +1,10 @@
1
+ // Typed Op step-builder wrappers (chant #1288 Stage 2) — k3sInstall/
2
+ // k3sUninstall with authoring-time types derived from this lexicon's own
3
+ // *Args interfaces (see ./op/builders.ts's module doc). Opt-in:
4
+ // `@intentius/chant-lexicon-temporal`'s same-named exports are core's
5
+ // original untyped builders, unchanged.
6
+ export { k3sInstall, k3sUninstall } from "./op/builders";
7
+
1
8
  // Plugin
2
9
  export { k3sPlugin } from "./plugin";
3
10
 
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Typed step-builder wrappers (chant #1288 Stage 2) — see
3
+ * `lexicons/k8s/src/op/builders.test.ts`'s module doc for what's asserted
4
+ * and why.
5
+ */
6
+
7
+ import { describe, test, expect } from "vitest";
8
+ import { k3sInstall as k3sInstallOld, k3sUninstall as k3sUninstallOld, stepOutput, type StepOutputRef } from "@intentius/chant/op";
9
+ import { k3sInstall, k3sUninstall } from "./builders";
10
+
11
+ describe("k3s typed step builders (#1288 Stage 2)", () => {
12
+ test("k3sInstall: identical ActivityStep to core's original", () => {
13
+ const opts = { configFile: "dist/config.yaml" };
14
+ expect(k3sInstall("server", opts)).toEqual(k3sInstallOld("server", opts));
15
+ const optsWithVersion = { configFile: "dist/config.yaml", version: "v1.31.4+k3s1", tokenFile: "/etc/k3s-token" };
16
+ expect(k3sInstall("agent", optsWithVersion)).toEqual(k3sInstallOld("agent", optsWithVersion));
17
+ });
18
+
19
+ test("k3sUninstall: identical ActivityStep to core's original", () => {
20
+ expect(k3sUninstall("server")).toEqual(k3sUninstallOld("server"));
21
+ });
22
+
23
+ test("k3sInstall: accepts a StepOutputRef in a typed slot", () => {
24
+ const ref = stepOutput("write-config", "path");
25
+ const step = k3sInstall("server", { configFile: ref });
26
+ expect(step.args?.configFile).toBe(ref);
27
+ });
28
+
29
+ test("k3sInstall: .out is reachable when an id is given", () => {
30
+ const step = k3sInstall("server", { configFile: "dist/config.yaml", id: "install" });
31
+ const ref: StepOutputRef = step.out.version;
32
+ expect(ref.step).toBe("install");
33
+ expect(ref.path).toBe("version");
34
+ });
35
+ });
36
+
37
+ // ── Compile-time-only: authoring-time type errors (never executed) ──────────
38
+ function _typeChecksOnly(): void {
39
+ // @ts-expect-error — configFile is required (the activity fails without
40
+ // it); omitting opts entirely is no longer a way around that.
41
+ k3sInstall("server");
42
+
43
+ // @ts-expect-error — "configfile" (wrong case) is not a key of K3sInstallArgs.
44
+ k3sInstall("server", { configfile: "dist/config.yaml" });
45
+
46
+ // @ts-expect-error — role must be "server" | "agent", not an arbitrary string.
47
+ k3sInstall("controller", { configFile: "dist/config.yaml" });
48
+ }
49
+ void _typeChecksOnly;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Typed step-builder wrappers for this lexicon's activities (chant #1288
3
+ * Stage 2). See `lexicons/k8s/src/op/builders.ts`'s module doc for why these
4
+ * live beside their `*Args` interfaces rather than in core or the temporal
5
+ * barrel. `opts`'s type in each wrapper below IS the activity's own `*Args`
6
+ * interface (via `Omit`/`WithStepRefs`) — never restated. `core`'s own
7
+ * `k3sInstall`/`k3sUninstall` are unchanged and produce byte-identical
8
+ * `ActivityStep` output; these are purely additive.
9
+ */
10
+
11
+ import {
12
+ activity,
13
+ takeProfileAndId,
14
+ type ActivityStep,
15
+ type NamedActivityStep,
16
+ type WithStepRefs,
17
+ } from "@intentius/chant/op";
18
+ import type { K3sInstallArgs, K3sUninstallArgs, K3sRole } from "./activities/k3s";
19
+
20
+ /** Extra opts every wrapper below accepts alongside its activity's own fields. */
21
+ type StepOpts = { profile?: ActivityStep["profile"]; id?: string };
22
+
23
+ /**
24
+ * Run the pinned k3s installer against a reachable host — the fully typed
25
+ * twin of core's `k3sInstall`. `opts` is {@link K3sInstallArgs} itself,
26
+ * minus the positional `role` (`configFile` remains required). Defaults to
27
+ * the `longInfra` profile.
28
+ */
29
+ export const k3sInstall = (
30
+ role: K3sRole,
31
+ opts: WithStepRefs<Omit<K3sInstallArgs, "role">> & StepOpts,
32
+ ): NamedActivityStep => {
33
+ const { args, profile, id } = takeProfileAndId(opts as Record<string, unknown> | undefined);
34
+ return activity("k3sInstall", { role, ...args }, { profile: profile ?? "longInfra", ...(id ? { id } : {}) });
35
+ };
36
+
37
+ /**
38
+ * Uninstall k3s from a reachable host — the fully typed twin of core's
39
+ * `k3sUninstall`. `opts` is {@link K3sUninstallArgs} itself, minus the
40
+ * positional `role`. Defaults to the `fastIdempotent` profile.
41
+ */
42
+ export const k3sUninstall = (
43
+ role: K3sRole,
44
+ opts?: WithStepRefs<Omit<K3sUninstallArgs, "role">> & StepOpts,
45
+ ): NamedActivityStep => {
46
+ const { args, profile, id } = takeProfileAndId(opts as Record<string, unknown> | undefined);
47
+ return activity("k3sUninstall", { role, ...args }, { profile: profile ?? "fastIdempotent", ...(id ? { id } : {}) });
48
+ };