@intentius/chant-lexicon-azure 0.15.1 → 0.15.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/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/dist/op/activities/floci-az.d.ts +44 -0
- package/dist/op/activities/floci-az.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +2 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/op/activities/floci-az.test.ts +29 -0
- package/src/op/activities/floci-az.ts +123 -0
- package/src/op/activities/index.ts +13 -0
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "ced8d5e5edae01dc34ff156822445fbbbf17a261ae78abbc35933c7928fd158e",
|
|
5
5
|
"meta.json": "4b9c0be734f8b4a5fbba3136e14aaa1ea73ff0ee93f2aa480db83e476ce727b5",
|
|
6
6
|
"types/index.d.ts": "d62c0fd7947ddf04a9126cc8bf44a9f4437f21cf8647fc812c022398f2c00d57",
|
|
7
7
|
"rules/hardcoded-location.ts": "a9b1d1cec93f2ca9c5206641f53fc9621cefcfd2c00b3ab89c194b30a75fa949",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"skills/chant-azure-patterns.md": "1a3bacfac612826b77332d2692a59195638db9f1b5e8ea2eda7579621d25f603",
|
|
34
34
|
"skills/chant-azure-aks.md": "2d4e0098c1a22b54ffadd410564d9df0f3a04cb4eb7c6261f20ae33106e7aca8"
|
|
35
35
|
},
|
|
36
|
-
"composite": "
|
|
36
|
+
"composite": "c80fc2a2f5a20f60437c862601204ad4d5ce4029b9f067653a8be31faf13023a"
|
|
37
37
|
}
|
package/dist/manifest.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface FlociAzUpArgs {
|
|
2
|
+
/** Container name. Default: `chant-floci-az`. */
|
|
3
|
+
name?: string;
|
|
4
|
+
/** Host port mapped to the emulator's `:4577`. Default: `4577`. */
|
|
5
|
+
port?: number;
|
|
6
|
+
/** Image. Default: `floci/floci-az:latest`. */
|
|
7
|
+
image?: string;
|
|
8
|
+
/** Readiness timeout in ms. Default: `60000`. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Health poll interval in ms. Default: `2000`. */
|
|
11
|
+
intervalMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface FlociAzDownArgs {
|
|
14
|
+
/** Container name to remove. Default: `chant-floci-az`. */
|
|
15
|
+
name?: string;
|
|
16
|
+
}
|
|
17
|
+
/** `docker ps -q -f name=<name>` — non-empty stdout means the container is running. */
|
|
18
|
+
export declare function flociAzExistsCommand(name: string): string;
|
|
19
|
+
/** Build the `docker run` command that boots floci-az. */
|
|
20
|
+
export declare function flociAzRunCommand(args: FlociAzUpArgs): string;
|
|
21
|
+
/** Build the `docker rm -f` command. */
|
|
22
|
+
export declare function flociAzRmCommand(name: string): string;
|
|
23
|
+
/** The floci-az health endpoint URL for a host port. */
|
|
24
|
+
export declare function flociAzHealthUrl(port: number): string;
|
|
25
|
+
/** The ARM endpoint URL (what `azApply`'s `endpoint` should point at). */
|
|
26
|
+
export declare function flociAzEndpoint(port: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Boot a local floci-az (Azure emulator) in Docker and return its ARM endpoint.
|
|
29
|
+
*
|
|
30
|
+
* Idempotent: reuses a running container of the same name. Waits for the health
|
|
31
|
+
* endpoint to answer, then returns `{ endpoint }` for `azApply({ endpoint })`.
|
|
32
|
+
* The typed twin of the AWS `flociUp` — replaces a raw `docker run` shell step so
|
|
33
|
+
* the emulator lifecycle is modeled, not scripted. Uses longInfra profile — 20m
|
|
34
|
+
* timeout, heartbeat every poll (the image may pull).
|
|
35
|
+
*/
|
|
36
|
+
export declare function flociAzUp(args: FlociAzUpArgs, signal?: AbortSignal): Promise<{
|
|
37
|
+
endpoint: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Stop and remove the local floci-az container. A no-op success when the
|
|
41
|
+
* container is already gone. Uses fastIdempotent profile — 5m timeout.
|
|
42
|
+
*/
|
|
43
|
+
export declare function flociAzDown(args: FlociAzDownArgs, signal?: AbortSignal): Promise<void>;
|
|
44
|
+
//# sourceMappingURL=floci-az.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floci-az.d.ts","sourceRoot":"","sources":["../../../src/op/activities/floci-az.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAK7D;AAED,wCAAwC;AACxC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4CxG;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAO5F"}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { azGroupEnsure, azGroupDelete, azGroupEnsureCommand, azGroupDeleteCommand } from "./azure.js";
|
|
7
7
|
export type { AzGroupEnsureArgs, AzGroupDeleteArgs } from "./azure.js";
|
|
8
|
+
export { flociAzUp, flociAzDown, flociAzRunCommand, flociAzRmCommand, flociAzExistsCommand, flociAzHealthUrl, flociAzEndpoint, } from "./floci-az.js";
|
|
9
|
+
export type { FlociAzUpArgs, FlociAzDownArgs } from "./floci-az.js";
|
|
8
10
|
export { azApply, azDelete, pruneArmOrphans, deleteArmResource, listGroupResources, chantOwnershipTags, isChantOwned, evalArm, evalArmString, armResourceUrl, armResourceBody, armDependencies, orderArmResources, } from "./az-apply.js";
|
|
9
11
|
export type { AzApplyArgs, ArmEvalCtx, ArmResource, ArmListItem, AzHttp } from "./az-apply.js";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACnG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACnG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,EACL,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-azure",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "Azure lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"typescript": "^5.9.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@intentius/chant": "^0.15.
|
|
77
|
+
"@intentius/chant": "^0.15.3"
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
flociAzRunCommand,
|
|
4
|
+
flociAzRmCommand,
|
|
5
|
+
flociAzExistsCommand,
|
|
6
|
+
flociAzHealthUrl,
|
|
7
|
+
flociAzEndpoint,
|
|
8
|
+
} from "./floci-az";
|
|
9
|
+
|
|
10
|
+
describe("floci-az lifecycle commands (typed emulator, not shell)", () => {
|
|
11
|
+
test("run command uses defaults and maps the port", () => {
|
|
12
|
+
expect(flociAzRunCommand({})).toBe(
|
|
13
|
+
"docker run -d --rm --name chant-floci-az -p 4577:4577 floci/floci-az:latest",
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("run command honors name/port/image overrides", () => {
|
|
18
|
+
expect(flociAzRunCommand({ name: "az2", port: 4599, image: "floci/floci-az:0.8.0" })).toBe(
|
|
19
|
+
"docker run -d --rm --name az2 -p 4599:4577 floci/floci-az:0.8.0",
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("rm / exists / health / endpoint", () => {
|
|
24
|
+
expect(flociAzRmCommand("az2")).toBe("docker rm -f az2");
|
|
25
|
+
expect(flociAzExistsCommand("az2")).toBe("docker ps -q -f name=az2");
|
|
26
|
+
expect(flociAzHealthUrl(4577)).toBe("http://localhost:4577/_floci/health");
|
|
27
|
+
expect(flociAzEndpoint(4577)).toBe("http://localhost:4577");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { safeHeartbeat, sleep } from "@intentius/chant/op";
|
|
4
|
+
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
|
|
7
|
+
const DEFAULT_NAME = "chant-floci-az";
|
|
8
|
+
const DEFAULT_PORT = 4577;
|
|
9
|
+
const DEFAULT_IMAGE = "floci/floci-az:latest";
|
|
10
|
+
|
|
11
|
+
export interface FlociAzUpArgs {
|
|
12
|
+
/** Container name. Default: `chant-floci-az`. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Host port mapped to the emulator's `:4577`. Default: `4577`. */
|
|
15
|
+
port?: number;
|
|
16
|
+
/** Image. Default: `floci/floci-az:latest`. */
|
|
17
|
+
image?: string;
|
|
18
|
+
/** Readiness timeout in ms. Default: `60000`. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
/** Health poll interval in ms. Default: `2000`. */
|
|
21
|
+
intervalMs?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FlociAzDownArgs {
|
|
25
|
+
/** Container name to remove. Default: `chant-floci-az`. */
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** `docker ps -q -f name=<name>` — non-empty stdout means the container is running. */
|
|
30
|
+
export function flociAzExistsCommand(name: string): string {
|
|
31
|
+
return `docker ps -q -f name=${name}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Build the `docker run` command that boots floci-az. */
|
|
35
|
+
export function flociAzRunCommand(args: FlociAzUpArgs): string {
|
|
36
|
+
const name = args.name ?? DEFAULT_NAME;
|
|
37
|
+
const port = args.port ?? DEFAULT_PORT;
|
|
38
|
+
const image = args.image ?? DEFAULT_IMAGE;
|
|
39
|
+
return ["docker", "run", "-d", "--rm", "--name", name, "-p", `${port}:4577`, image].join(" ");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Build the `docker rm -f` command. */
|
|
43
|
+
export function flociAzRmCommand(name: string): string {
|
|
44
|
+
return `docker rm -f ${name}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The floci-az health endpoint URL for a host port. */
|
|
48
|
+
export function flociAzHealthUrl(port: number): string {
|
|
49
|
+
return `http://localhost:${port}/_floci/health`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The ARM endpoint URL (what `azApply`'s `endpoint` should point at). */
|
|
53
|
+
export function flociAzEndpoint(port: number): string {
|
|
54
|
+
return `http://localhost:${port}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Boot a local floci-az (Azure emulator) in Docker and return its ARM endpoint.
|
|
59
|
+
*
|
|
60
|
+
* Idempotent: reuses a running container of the same name. Waits for the health
|
|
61
|
+
* endpoint to answer, then returns `{ endpoint }` for `azApply({ endpoint })`.
|
|
62
|
+
* The typed twin of the AWS `flociUp` — replaces a raw `docker run` shell step so
|
|
63
|
+
* the emulator lifecycle is modeled, not scripted. Uses longInfra profile — 20m
|
|
64
|
+
* timeout, heartbeat every poll (the image may pull).
|
|
65
|
+
*/
|
|
66
|
+
export async function flociAzUp(args: FlociAzUpArgs, signal?: AbortSignal): Promise<{ endpoint: string }> {
|
|
67
|
+
const name = args.name ?? DEFAULT_NAME;
|
|
68
|
+
const port = args.port ?? DEFAULT_PORT;
|
|
69
|
+
const timeoutMs = args.timeoutMs ?? 60_000;
|
|
70
|
+
const intervalMs = args.intervalMs ?? 2_000;
|
|
71
|
+
|
|
72
|
+
let running = false;
|
|
73
|
+
try {
|
|
74
|
+
const { stdout } = await execAsync(flociAzExistsCommand(name), { signal });
|
|
75
|
+
running = Boolean(stdout.trim());
|
|
76
|
+
} catch {
|
|
77
|
+
// `docker ps` failed — assume not running and try to start it.
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (running) {
|
|
81
|
+
console.log(`floci-az container "${name}" already running — reusing`);
|
|
82
|
+
} else {
|
|
83
|
+
await execAsync(flociAzRunCommand({ ...args, name, port }), { signal });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const url = flociAzHealthUrl(port);
|
|
87
|
+
const deadline = Date.now() + timeoutMs;
|
|
88
|
+
let ready = false;
|
|
89
|
+
while (Date.now() < deadline) {
|
|
90
|
+
if (signal?.aborted) throw new Error("flociAzUp aborted");
|
|
91
|
+
safeHeartbeat({ step: "flociAzUp", container: name });
|
|
92
|
+
try {
|
|
93
|
+
const res = await fetch(url, { signal });
|
|
94
|
+
if (res.ok) {
|
|
95
|
+
ready = true;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
// Not up yet (connection refused / non-2xx) — retry.
|
|
100
|
+
}
|
|
101
|
+
await sleep(intervalMs, signal);
|
|
102
|
+
}
|
|
103
|
+
if (!ready) {
|
|
104
|
+
throw new Error(`floci-az "${name}" did not become ready within ${timeoutMs}ms`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const endpoint = flociAzEndpoint(port);
|
|
108
|
+
console.log(`floci-az ready on ${endpoint}`);
|
|
109
|
+
return { endpoint };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Stop and remove the local floci-az container. A no-op success when the
|
|
114
|
+
* container is already gone. Uses fastIdempotent profile — 5m timeout.
|
|
115
|
+
*/
|
|
116
|
+
export async function flociAzDown(args: FlociAzDownArgs, signal?: AbortSignal): Promise<void> {
|
|
117
|
+
const name = args.name ?? DEFAULT_NAME;
|
|
118
|
+
try {
|
|
119
|
+
await execAsync(flociAzRmCommand(name), { signal });
|
|
120
|
+
} catch {
|
|
121
|
+
// Already removed (`--rm` on exit, or never started) — treat as success.
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
export { azGroupEnsure, azGroupDelete, azGroupEnsureCommand, azGroupDeleteCommand } from "./azure";
|
|
7
7
|
export type { AzGroupEnsureArgs, AzGroupDeleteArgs } from "./azure";
|
|
8
8
|
|
|
9
|
+
// floci-az (Azure emulator) lifecycle — the typed twin of aws's flociUp/Down, so
|
|
10
|
+
// the trio's Azure op boots/tears down the emulator as a modeled step, not a shell.
|
|
11
|
+
export {
|
|
12
|
+
flociAzUp,
|
|
13
|
+
flociAzDown,
|
|
14
|
+
flociAzRunCommand,
|
|
15
|
+
flociAzRmCommand,
|
|
16
|
+
flociAzExistsCommand,
|
|
17
|
+
flociAzHealthUrl,
|
|
18
|
+
flociAzEndpoint,
|
|
19
|
+
} from "./floci-az";
|
|
20
|
+
export type { FlociAzUpArgs, FlociAzDownArgs } from "./floci-az";
|
|
21
|
+
|
|
9
22
|
export {
|
|
10
23
|
azApply,
|
|
11
24
|
azDelete,
|