@weiyentan/opencode-plugin-awx 0.2.0 → 0.3.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/README.md +122 -9
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +4 -4
- package/dist/auth.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/contracts/inventory-detail.d.ts +46 -0
- package/dist/contracts/inventory-detail.d.ts.map +1 -0
- package/dist/contracts/inventory-detail.js +22 -0
- package/dist/contracts/inventory-detail.js.map +1 -0
- package/dist/contracts/job-detail.d.ts +50 -116
- package/dist/contracts/job-detail.d.ts.map +1 -1
- package/dist/contracts/job-detail.js +1 -73
- package/dist/contracts/job-detail.js.map +1 -1
- package/dist/contracts/project-detail.d.ts +58 -0
- package/dist/contracts/project-detail.d.ts.map +1 -0
- package/dist/contracts/project-detail.js +23 -0
- package/dist/contracts/project-detail.js.map +1 -0
- package/dist/contracts/sync-project.d.ts +9 -14
- package/dist/contracts/sync-project.d.ts.map +1 -1
- package/dist/contracts/sync-project.js +1 -14
- package/dist/contracts/sync-project.js.map +1 -1
- package/dist/contracts/template-detail.d.ts +55 -0
- package/dist/contracts/template-detail.d.ts.map +1 -0
- package/dist/contracts/template-detail.js +22 -0
- package/dist/contracts/template-detail.js.map +1 -0
- package/dist/get-resource.d.ts +49 -0
- package/dist/get-resource.d.ts.map +1 -0
- package/dist/get-resource.js +49 -0
- package/dist/get-resource.js.map +1 -0
- package/dist/index.d.ts +12 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +276 -78
- package/dist/index.js.map +1 -1
- package/dist/list-projects.d.ts +8 -1
- package/dist/list-projects.d.ts.map +1 -1
- package/dist/list-projects.js +22 -3
- package/dist/list-projects.js.map +1 -1
- package/dist/list-templates.d.ts +8 -1
- package/dist/list-templates.d.ts.map +1 -1
- package/dist/list-templates.js +22 -5
- package/dist/list-templates.js.map +1 -1
- package/dist/mappers/map-inventory.d.ts +34 -0
- package/dist/mappers/map-inventory.d.ts.map +1 -0
- package/dist/mappers/map-inventory.js +35 -0
- package/dist/mappers/map-inventory.js.map +1 -0
- package/dist/mappers/map-project.d.ts +35 -0
- package/dist/mappers/map-project.d.ts.map +1 -0
- package/dist/mappers/map-project.js +42 -0
- package/dist/mappers/map-project.js.map +1 -0
- package/dist/mappers/map-template.d.ts +34 -0
- package/dist/mappers/map-template.d.ts.map +1 -0
- package/dist/mappers/map-template.js +45 -0
- package/dist/mappers/map-template.js.map +1 -0
- package/package.json +2 -3
package/dist/list-projects.js
CHANGED
|
@@ -13,13 +13,32 @@
|
|
|
13
13
|
export function calcPageBudget(totalTimeout, maxPages) {
|
|
14
14
|
return Math.floor(totalTimeout / (maxPages + 1));
|
|
15
15
|
}
|
|
16
|
+
/* ── URL builder ────────────────────────────────────────────────── */
|
|
17
|
+
/**
|
|
18
|
+
* Build the request URL with pagination parameters and optional filters.
|
|
19
|
+
* Filter strings are split on the first `=` to form query parameters.
|
|
20
|
+
*/
|
|
21
|
+
function buildProjectsUrl(page, pageSize, filters) {
|
|
22
|
+
const params = new URLSearchParams();
|
|
23
|
+
params.set("page", String(page));
|
|
24
|
+
params.set("page_size", String(pageSize));
|
|
25
|
+
if (filters) {
|
|
26
|
+
for (const f of filters) {
|
|
27
|
+
const eqIdx = f.indexOf("=");
|
|
28
|
+
if (eqIdx > 0) {
|
|
29
|
+
params.set(f.slice(0, eqIdx), f.slice(eqIdx + 1));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return `/api/v2/projects/?${params.toString()}`;
|
|
34
|
+
}
|
|
16
35
|
/* ── Pagination logic ───────────────────────────────────────────── */
|
|
17
36
|
/**
|
|
18
37
|
* Fetch paginated projects from the AWX API, consolidate results,
|
|
19
38
|
* and return them sorted by name.
|
|
20
39
|
*
|
|
21
40
|
* @param client The AWX HTTP client
|
|
22
|
-
* @param options Pagination and
|
|
41
|
+
* @param options Pagination, timeout, and filter options
|
|
23
42
|
* @returns Consolidated, sorted list of projects
|
|
24
43
|
*/
|
|
25
44
|
export async function listProjects(client, options) {
|
|
@@ -48,8 +67,8 @@ export async function listProjects(client, options) {
|
|
|
48
67
|
toolAbortSignal.addEventListener("abort", abortHandler, { once: true });
|
|
49
68
|
}
|
|
50
69
|
try {
|
|
51
|
-
// Build request path with pagination parameters
|
|
52
|
-
const path =
|
|
70
|
+
// Build request path with pagination parameters and optional filters
|
|
71
|
+
const path = buildProjectsUrl(page, pageSize, options?.filters);
|
|
53
72
|
const response = await client.request("awx-list-projects", path, { headers: { "Content-Type": "application/json" } }, pageController.signal);
|
|
54
73
|
if (!response.ok) {
|
|
55
74
|
throw new Error(`Failed to fetch projects: ${response.status} ${response.statusText}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-projects.js","sourceRoot":"","sources":["../src/list-projects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-projects.js","sourceRoot":"","sources":["../src/list-projects.ts"],"names":[],"mappings":"AAuDA,uEAAuE;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB,EAAE,QAAgB;IACnE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,uEAAuE;AAEvE;;;GAGG;AACH,SAAS,gBAAgB,CAAC,IAAY,EAAE,QAAgB,EAAE,OAAkB;IAC1E,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,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AAC,CAAC;YACxB,IAAI,eAAe,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;gBAChD,eAAe,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC7D,CAAC;YACD,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,yCAAyC;QACnE,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAuB;QACjC,KAAK,EAAE,WAAW,CAAC,MAAM;QACzB,OAAO,EAAE,WAAW;KACrB,CAAC;IAEF,8DAA8D;IAC9D,IAAI,IAAI,GAAG,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,MAAM,CAAC,OAAO,GAAG,uDAAuD,CAAC;IAC3E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/list-templates.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ export interface ListTemplatesOptions {
|
|
|
40
40
|
* Default: 5 (5 pages × 50 items = 250 max).
|
|
41
41
|
*/
|
|
42
42
|
maxPages?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Optional filter strings for server-side filtering.
|
|
45
|
+
* Each string should be in the format "field__operator=value"
|
|
46
|
+
* (e.g., "name__icontains=workspace"). These are passed as
|
|
47
|
+
* query parameters to the AWX API.
|
|
48
|
+
*/
|
|
49
|
+
filters?: string[];
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* List AWX job templates with pagination consolidation.
|
|
@@ -52,7 +59,7 @@ export interface ListTemplatesOptions {
|
|
|
52
59
|
*
|
|
53
60
|
* @param client The AWX HTTP client
|
|
54
61
|
* @param toolTimeoutMs Tool-level timeout in ms (used for per-page budget)
|
|
55
|
-
* @param options Optional: pageSize, maxPages
|
|
62
|
+
* @param options Optional: pageSize, maxPages, filters
|
|
56
63
|
* @param abortSignal Optional tool context abort signal for cancellation
|
|
57
64
|
* @returns Consolidated, sorted template list with count and optional warning
|
|
58
65
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-templates.d.ts","sourceRoot":"","sources":["../src/list-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gCAAgC;AAChC,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"list-templates.d.ts","sourceRoot":"","sources":["../src/list-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gCAAgC;AAChC,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAoGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAiE9B"}
|
package/dist/list-templates.js
CHANGED
|
@@ -53,6 +53,23 @@ function mapTemplate(item) {
|
|
|
53
53
|
description: item.description ?? "",
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Build the request URL with page size and optional server-side filters.
|
|
58
|
+
* Filter strings are split on the first `=` to form query parameters.
|
|
59
|
+
*/
|
|
60
|
+
function buildTemplatesUrl(pageSize, filters) {
|
|
61
|
+
const params = new URLSearchParams();
|
|
62
|
+
params.set("page_size", String(pageSize));
|
|
63
|
+
if (filters) {
|
|
64
|
+
for (const f of filters) {
|
|
65
|
+
const eqIdx = f.indexOf("=");
|
|
66
|
+
if (eqIdx > 0) {
|
|
67
|
+
params.set(f.slice(0, eqIdx), f.slice(eqIdx + 1));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return `/api/v2/job_templates/?${params.toString()}`;
|
|
72
|
+
}
|
|
56
73
|
// ── Core Logic ────────────────────────────────────────────────────
|
|
57
74
|
/**
|
|
58
75
|
* List AWX job templates with pagination consolidation.
|
|
@@ -65,7 +82,7 @@ function mapTemplate(item) {
|
|
|
65
82
|
*
|
|
66
83
|
* @param client The AWX HTTP client
|
|
67
84
|
* @param toolTimeoutMs Tool-level timeout in ms (used for per-page budget)
|
|
68
|
-
* @param options Optional: pageSize, maxPages
|
|
85
|
+
* @param options Optional: pageSize, maxPages, filters
|
|
69
86
|
* @param abortSignal Optional tool context abort signal for cancellation
|
|
70
87
|
* @returns Consolidated, sorted template list with count and optional warning
|
|
71
88
|
*/
|
|
@@ -75,18 +92,18 @@ export async function listTemplates(client, toolTimeoutMs, options, abortSignal)
|
|
|
75
92
|
// Per-page timeout budget: divide tool timeout by (maxPages + 1).
|
|
76
93
|
// The +1 provides a safety margin for tool overhead after the last page.
|
|
77
94
|
const effectiveMaxPages = Math.max(1, maxPages);
|
|
78
|
-
const perPageBudget = Math.floor(toolTimeoutMs / (effectiveMaxPages + 1));
|
|
95
|
+
const perPageBudget = Math.floor((toolTimeoutMs || 30_000) / ((effectiveMaxPages || 5) + 1));
|
|
79
96
|
const allResults = [];
|
|
80
97
|
let nextPage = null;
|
|
81
98
|
let pagesFetched = 0;
|
|
82
99
|
do {
|
|
83
100
|
pagesFetched++;
|
|
84
|
-
// Build URL for current page
|
|
101
|
+
// Build URL for current page (with optional filters on first request)
|
|
85
102
|
const path = nextPage
|
|
86
103
|
? extractPath(nextPage)
|
|
87
|
-
:
|
|
104
|
+
: buildTemplatesUrl(pageSize, options?.filters);
|
|
88
105
|
// Fetch this page with per-page timeout
|
|
89
|
-
const { signal: pageSignal, clear: clearTimeout_ } = createTimeoutSignal(perPageBudget);
|
|
106
|
+
const { signal: pageSignal, clear: clearTimeout_ } = createTimeoutSignal(Math.max(1, perPageBudget || 1000));
|
|
90
107
|
const combinedSignal = abortSignal
|
|
91
108
|
? anyAbortSignal([abortSignal, pageSignal])
|
|
92
109
|
: pageSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-templates.js","sourceRoot":"","sources":["../src/list-templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-templates.js","sourceRoot":"","sources":["../src/list-templates.ts"],"names":[],"mappings":"AAwEA,qEAAqE;AAErE;;;GAGG;AACH,SAAS,cAAc,CAAC,OAAsB;IAC5C,IAAI,OAAO,WAAW,CAAC,GAAG,KAAK,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AAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;YAClD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,aAAa,EAAE,CAAC;QAClB,CAAC;QAED,gDAAgD;QAChD,4CAA4C;IAC9C,CAAC,QAAQ,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,YAAY,GAAG,QAAQ,CAAC,EAAE;IAE1E,qEAAqE;IACrE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD,MAAM,MAAM,GAAwB;QAClC,KAAK,EAAE,UAAU,CAAC,MAAM;QACxB,OAAO,EAAE,UAAU;KACpB,CAAC;IAEF,6DAA6D;IAC7D,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,GAAG,CAAC,IAAI,YAAY,IAAI,QAAQ,EAAE,CAAC;QAClE,MAAM,CAAC,OAAO,GAAG,eAAe,QAAQ,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,wCAAwC,CAAC;IACpH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* map-inventory.ts — AWX Inventory Detail Mapper
|
|
3
|
+
*
|
|
4
|
+
* Pure function that transforms a raw AWX API inventory response
|
|
5
|
+
* (from GET /api/v2/inventories/<id>/) into the structured
|
|
6
|
+
* InventoryDetailOutput contract format.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Transformations
|
|
9
|
+
*
|
|
10
|
+
* - **Organization name**: Extracts organization_name from AWX
|
|
11
|
+
* `summary_fields` rather than raw ID.
|
|
12
|
+
* - **Kind**: Preserves the inventory kind ("smart", "", etc.)
|
|
13
|
+
* - **Envelope**: Wraps output in `{ schema_version, resource_type, id, data }`.
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const response = await fetch(client, "GET", "/api/v2/inventories/12/");
|
|
19
|
+
* const raw = await response.json();
|
|
20
|
+
* const output = mapInventory(raw);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { InventoryDetailOutput } from "../contracts/inventory-detail.js";
|
|
24
|
+
/**
|
|
25
|
+
* Transform a raw AWX API inventory response into the
|
|
26
|
+
* InventoryDetailOutput v1.0 contract format.
|
|
27
|
+
*
|
|
28
|
+
* Pure function — no side effects, no HTTP calls.
|
|
29
|
+
*
|
|
30
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/inventories/<id>/
|
|
31
|
+
* @returns An InventoryDetailOutput matching the v1.0 contract
|
|
32
|
+
*/
|
|
33
|
+
export declare function mapInventory(raw: unknown): InventoryDetailOutput;
|
|
34
|
+
//# sourceMappingURL=map-inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-inventory.d.ts","sourceRoot":"","sources":["../../src/mappers/map-inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAiB,MAAM,kCAAkC,CAAC;AAqB7F;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,CA0BhE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform a raw AWX API inventory response into the
|
|
3
|
+
* InventoryDetailOutput v1.0 contract format.
|
|
4
|
+
*
|
|
5
|
+
* Pure function — no side effects, no HTTP calls.
|
|
6
|
+
*
|
|
7
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/inventories/<id>/
|
|
8
|
+
* @returns An InventoryDetailOutput matching the v1.0 contract
|
|
9
|
+
*/
|
|
10
|
+
export function mapInventory(raw) {
|
|
11
|
+
if (!raw || typeof raw !== "object" || !("id" in raw) || raw.id == null) {
|
|
12
|
+
throw new Error(`mapInventory: raw response is missing or has no id — ${JSON.stringify(raw)}`);
|
|
13
|
+
}
|
|
14
|
+
const inv = raw;
|
|
15
|
+
const sf = inv.summary_fields ?? {};
|
|
16
|
+
const data = {
|
|
17
|
+
id: inv.id ?? 0,
|
|
18
|
+
name: inv.name ?? "",
|
|
19
|
+
description: inv.description ?? "",
|
|
20
|
+
kind: inv.kind ?? "",
|
|
21
|
+
host_count: inv.host_count ?? 0,
|
|
22
|
+
total_groups: inv.total_groups ?? 0,
|
|
23
|
+
has_inventory_sources: inv.has_inventory_sources ?? false,
|
|
24
|
+
total_inventory_sources: inv.total_inventory_sources ?? 0,
|
|
25
|
+
organization_name: sf.organization?.name ?? "",
|
|
26
|
+
variables: inv.variables ?? "",
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
schema_version: "1.0",
|
|
30
|
+
resource_type: "inventory",
|
|
31
|
+
id: inv.id ?? 0,
|
|
32
|
+
data,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=map-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-inventory.js","sourceRoot":"","sources":["../../src/mappers/map-inventory.ts"],"names":[],"mappings":"AA2CA;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAK,GAA+B,CAAC,IAAK,GAA+B,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;QAClI,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,MAAM,GAAG,GAAG,GAAsB,CAAC;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;IAEpC,MAAM,IAAI,GAAkB;QAC1B,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QACf,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;QACpB,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE;QAClC,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;QACpB,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC;QAC/B,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,CAAC;QACnC,qBAAqB,EAAE,GAAG,CAAC,qBAAqB,IAAI,KAAK;QACzD,uBAAuB,EAAE,GAAG,CAAC,uBAAuB,IAAI,CAAC;QACzD,iBAAiB,EAAE,EAAE,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;QAC9C,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE;KAC/B,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,WAAW;QAC1B,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QACf,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* map-project.ts — AWX Project Detail Mapper
|
|
3
|
+
*
|
|
4
|
+
* Pure function that transforms a raw AWX API project response
|
|
5
|
+
* (from GET /api/v2/projects/<id>/) into the structured
|
|
6
|
+
* ProjectDetailOutput contract format.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Transformations
|
|
9
|
+
*
|
|
10
|
+
* - **Related names**: Extracts organization_name and created_by from
|
|
11
|
+
* AWX `summary_fields` rather than raw IDs.
|
|
12
|
+
* - **Derived flags**: Computes is_successful and is_failed from the
|
|
13
|
+
* raw `status` field.
|
|
14
|
+
* - **Envelope**: Wraps output in `{ schema_version, resource_type, id, data }`.
|
|
15
|
+
*
|
|
16
|
+
* ## Usage
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const response = await fetch(client, "GET", "/api/v2/projects/5/");
|
|
20
|
+
* const raw = await response.json();
|
|
21
|
+
* const output = mapProject(raw);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { ProjectDetailOutput } from "../contracts/project-detail.js";
|
|
25
|
+
/**
|
|
26
|
+
* Transform a raw AWX API project response into the
|
|
27
|
+
* ProjectDetailOutput v1.0 contract format.
|
|
28
|
+
*
|
|
29
|
+
* Pure function — no side effects, no HTTP calls.
|
|
30
|
+
*
|
|
31
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/projects/<id>/
|
|
32
|
+
* @returns A ProjectDetailOutput matching the v1.0 contract
|
|
33
|
+
*/
|
|
34
|
+
export declare function mapProject(raw: unknown): ProjectDetailOutput;
|
|
35
|
+
//# sourceMappingURL=map-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-project.d.ts","sourceRoot":"","sources":["../../src/mappers/map-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,gCAAgC,CAAC;AAuBvF;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAkC5D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform a raw AWX API project response into the
|
|
3
|
+
* ProjectDetailOutput v1.0 contract format.
|
|
4
|
+
*
|
|
5
|
+
* Pure function — no side effects, no HTTP calls.
|
|
6
|
+
*
|
|
7
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/projects/<id>/
|
|
8
|
+
* @returns A ProjectDetailOutput matching the v1.0 contract
|
|
9
|
+
*/
|
|
10
|
+
export function mapProject(raw) {
|
|
11
|
+
if (!raw || typeof raw !== "object" || !("id" in raw) || raw.id == null) {
|
|
12
|
+
throw new Error(`mapProject: raw response is missing or has no id — ${JSON.stringify(raw)}`);
|
|
13
|
+
}
|
|
14
|
+
const p = raw;
|
|
15
|
+
const sf = p.summary_fields ?? {};
|
|
16
|
+
const status = p.status ?? "";
|
|
17
|
+
const data = {
|
|
18
|
+
id: p.id ?? 0,
|
|
19
|
+
name: p.name ?? "",
|
|
20
|
+
description: p.description ?? "",
|
|
21
|
+
scm_type: p.scm_type ?? "",
|
|
22
|
+
scm_url: p.scm_url ?? "",
|
|
23
|
+
scm_branch: p.scm_branch ?? "",
|
|
24
|
+
status,
|
|
25
|
+
last_updated: p.last_updated ?? null,
|
|
26
|
+
created: p.created ?? "",
|
|
27
|
+
modified: p.modified ?? "",
|
|
28
|
+
organization_name: sf.organization?.name ?? "",
|
|
29
|
+
created_by: sf.created_by?.username ?? "",
|
|
30
|
+
is_successful: status === "successful",
|
|
31
|
+
is_failed: status === "failed",
|
|
32
|
+
warnings: [],
|
|
33
|
+
errors: [],
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
schema_version: "1.0",
|
|
37
|
+
resource_type: "project",
|
|
38
|
+
id: p.id ?? 0,
|
|
39
|
+
data,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=map-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-project.js","sourceRoot":"","sources":["../../src/mappers/map-project.ts"],"names":[],"mappings":"AA8CA;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY;IACrC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAK,GAA+B,CAAC,IAAK,GAA+B,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;QAClI,MAAM,IAAI,KAAK,CAAC,sDAAsD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,CAAC,GAAG,GAAoB,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,CAAC,cAAc,IAAI,EAAE,CAAC;IAElC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;IAE9B,MAAM,IAAI,GAAgB;QACxB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE;QAClB,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE;QAChC,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE;QAC1B,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;QACxB,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,EAAE;QAC9B,MAAM;QACN,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,IAAI;QACpC,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;QACxB,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE;QAC1B,iBAAiB,EAAE,EAAE,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;QAC9C,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,IAAI,EAAE;QACzC,aAAa,EAAE,MAAM,KAAK,YAAY;QACtC,SAAS,EAAE,MAAM,KAAK,QAAQ;QAC9B,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,SAAS;QACxB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACb,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* map-template.ts — AWX Template Detail Mapper
|
|
3
|
+
*
|
|
4
|
+
* Pure function that transforms a raw AWX API job template response
|
|
5
|
+
* (from GET /api/v2/job_templates/<id>/) into the structured
|
|
6
|
+
* TemplateDetailOutput contract format.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Transformations
|
|
9
|
+
*
|
|
10
|
+
* - **Related names**: Extracts inventory_name, project_name, and
|
|
11
|
+
* organization_name from AWX `summary_fields` rather than raw IDs.
|
|
12
|
+
* - **Labels**: Extracts label names from `summary_fields.labels.results`.
|
|
13
|
+
* - **Envelope**: Wraps output in `{ schema_version, resource_type, id, data }`.
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const response = await fetch(client, "GET", "/api/v2/job_templates/7/");
|
|
19
|
+
* const raw = await response.json();
|
|
20
|
+
* const output = mapTemplate(raw);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { TemplateDetailOutput } from "../contracts/template-detail.js";
|
|
24
|
+
/**
|
|
25
|
+
* Transform a raw AWX API job template response into the
|
|
26
|
+
* TemplateDetailOutput v1.0 contract format.
|
|
27
|
+
*
|
|
28
|
+
* Pure function — no side effects, no HTTP calls.
|
|
29
|
+
*
|
|
30
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/job_templates/<id>/
|
|
31
|
+
* @returns A TemplateDetailOutput matching the v1.0 contract
|
|
32
|
+
*/
|
|
33
|
+
export declare function mapTemplate(raw: unknown): TemplateDetailOutput;
|
|
34
|
+
//# sourceMappingURL=map-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-template.d.ts","sourceRoot":"","sources":["../../src/mappers/map-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,iCAAiC,CAAC;AA6B1F;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAoC9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform a raw AWX API job template response into the
|
|
3
|
+
* TemplateDetailOutput v1.0 contract format.
|
|
4
|
+
*
|
|
5
|
+
* Pure function — no side effects, no HTTP calls.
|
|
6
|
+
*
|
|
7
|
+
* @param raw Raw JSON-decoded AWX API response from /api/v2/job_templates/<id>/
|
|
8
|
+
* @returns A TemplateDetailOutput matching the v1.0 contract
|
|
9
|
+
*/
|
|
10
|
+
export function mapTemplate(raw) {
|
|
11
|
+
if (!raw || typeof raw !== "object" || !("id" in raw) || raw.id == null) {
|
|
12
|
+
throw new Error(`mapTemplate: raw response is missing or has no id — ${JSON.stringify(raw)}`);
|
|
13
|
+
}
|
|
14
|
+
const t = raw;
|
|
15
|
+
const sf = t.summary_fields ?? {};
|
|
16
|
+
const data = {
|
|
17
|
+
id: t.id ?? 0,
|
|
18
|
+
name: t.name ?? "",
|
|
19
|
+
description: t.description ?? "",
|
|
20
|
+
job_type: t.job_type ?? "",
|
|
21
|
+
inventory_name: sf.inventory?.name ?? "",
|
|
22
|
+
project_name: sf.project?.name ?? "",
|
|
23
|
+
organization_name: sf.organization?.name ?? "",
|
|
24
|
+
playbook: t.playbook ?? "",
|
|
25
|
+
verbosity: t.verbosity ?? 0,
|
|
26
|
+
ask_variables_on_launch: t.ask_variables_on_launch ?? false,
|
|
27
|
+
ask_inventory_on_launch: t.ask_inventory_on_launch ?? false,
|
|
28
|
+
ask_limit_on_launch: t.ask_limit_on_launch ?? false,
|
|
29
|
+
last_job_run: t.last_job_run ?? null,
|
|
30
|
+
status: t.status ?? "",
|
|
31
|
+
next_schedule: typeof t.next_schedule === "string"
|
|
32
|
+
? t.next_schedule
|
|
33
|
+
: (t.next_schedule && typeof t.next_schedule === "object"
|
|
34
|
+
? t.next_schedule.name ?? null
|
|
35
|
+
: null),
|
|
36
|
+
labels: sf.labels?.results?.map((l) => l.name ?? "").filter(Boolean) ?? [],
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
schema_version: "1.0",
|
|
40
|
+
resource_type: "template",
|
|
41
|
+
id: t.id ?? 0,
|
|
42
|
+
data,
|
|
43
|
+
};
|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AY,EAAE,CAAC,CAAC,YAAY,IAAI,IAAI;QACpC,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;QACtB,aAAa,EAAE,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ;YAChD,CAAC,CAAC,CAAC,CAAC,aAAa;YACjB,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ;gBACvD,CAAC,CAAE,CAAC,CAAC,aAAmC,CAAC,IAAI,IAAI,IAAI;gBACrD,CAAC,CAAC,IAAI,CAAC;QACX,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;KAC3E,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,UAAU;QACzB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;QACb,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weiyentan/opencode-plugin-awx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "OpenCode plugin for AWX / Ansible Automation Platform — native tool access to job templates, projects, and job lifecycle operations.",
|
|
6
6
|
"type": "module",
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@opencode-ai/plugin": "^1.17.8"
|
|
26
|
-
"zod": "4.1.8"
|
|
25
|
+
"@opencode-ai/plugin": "^1.17.8"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@types/node": "^24.12.2",
|