@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
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
* Canonical TypeScript representation of the `awx_job_detail.py` v1.0 output schema.
|
|
5
5
|
* Every job-related tool MUST return output matching this contract.
|
|
6
6
|
*
|
|
7
|
-
* This file provides **both**:
|
|
8
|
-
* - Zod schemas for runtime validation (e.g., API response parsing)
|
|
9
|
-
* - Inferred TypeScript types for static type checking
|
|
10
|
-
*
|
|
11
|
-
* The contract has been verified against fixture snapshots in `tests/contracts/__snapshots__/`.
|
|
12
|
-
*
|
|
13
7
|
* ## Schema Fields
|
|
14
8
|
*
|
|
15
9
|
* - **schema_version**: Always "1.0"
|
|
@@ -27,72 +21,6 @@
|
|
|
27
21
|
* - Use `derived` — NOT `extra_vars_summary`
|
|
28
22
|
* - `related` fields are resolved names, not raw URLs
|
|
29
23
|
* - `job.limit` is the AWX job limit (host pattern), not a pagination value
|
|
30
|
-
*
|
|
31
|
-
* ## Snapshot Testing
|
|
32
|
-
*
|
|
33
|
-
* Fixture JSON files in `tests/fixtures/` serve as contract snapshots.
|
|
34
|
-
* When the Python `awx_job_detail.py` v1.0 output contract changes,
|
|
35
|
-
* regenerate the fixtures (see README.md for instructions) and re-run
|
|
36
|
-
* tests to verify schema compatibility.
|
|
37
|
-
*
|
|
38
|
-
* ## Regeneration
|
|
39
|
-
*
|
|
40
|
-
* To regenerate the contract snapshots after fixture changes:
|
|
41
|
-
* ```bash
|
|
42
|
-
* python3 scripts/generate-snapshots.py
|
|
43
|
-
* ```
|
|
44
24
|
*/
|
|
45
|
-
|
|
46
|
-
// ─── Sub-schemas ───────────────────────────────────────────
|
|
47
|
-
export const JobCoreSchema = z.object({
|
|
48
|
-
id: z.number().int().positive(),
|
|
49
|
-
name: z.string(),
|
|
50
|
-
status: z.string(),
|
|
51
|
-
failed: z.boolean(),
|
|
52
|
-
job_type: z.string(),
|
|
53
|
-
playbook: z.string(),
|
|
54
|
-
created: z.string(),
|
|
55
|
-
started: z.string().nullable(),
|
|
56
|
-
finished: z.string().nullable(),
|
|
57
|
-
elapsed: z.number().nullable(),
|
|
58
|
-
execution_node: z.string(),
|
|
59
|
-
controller_node: z.string(),
|
|
60
|
-
scm_branch: z.string(),
|
|
61
|
-
verbosity: z.number().int().min(0),
|
|
62
|
-
forks: z.number().int().min(0).nullable(),
|
|
63
|
-
limit: z.string(),
|
|
64
|
-
});
|
|
65
|
-
export const RelatedSchema = z.object({
|
|
66
|
-
inventory_name: z.string(),
|
|
67
|
-
project_name: z.string(),
|
|
68
|
-
job_template_name: z.string(),
|
|
69
|
-
instance_group_name: z.string(),
|
|
70
|
-
created_by: z.string(),
|
|
71
|
-
credential_names: z.array(z.string()),
|
|
72
|
-
label_names: z.array(z.string()),
|
|
73
|
-
});
|
|
74
|
-
export const HostStatusCountsSchema = z.object({
|
|
75
|
-
ok: z.number().int().min(0),
|
|
76
|
-
failed: z.number().int().min(0),
|
|
77
|
-
skipped: z.number().int().min(0),
|
|
78
|
-
changed: z.number().int().min(0),
|
|
79
|
-
unreachable: z.number().int().min(0),
|
|
80
|
-
});
|
|
81
|
-
export const DerivedSchema = z.object({
|
|
82
|
-
is_successful: z.boolean(),
|
|
83
|
-
is_failed: z.boolean(),
|
|
84
|
-
has_unreachable_hosts: z.boolean(),
|
|
85
|
-
});
|
|
86
|
-
// ─── Top-level schema ──────────────────────────────────────
|
|
87
|
-
export const JobDetailOutputSchema = z.object({
|
|
88
|
-
schema_version: z.literal("1.0"),
|
|
89
|
-
job: JobCoreSchema,
|
|
90
|
-
related: RelatedSchema,
|
|
91
|
-
host_status_counts: HostStatusCountsSchema,
|
|
92
|
-
derived: DerivedSchema,
|
|
93
|
-
warnings: z.array(z.string()),
|
|
94
|
-
errors: z.array(z.string()),
|
|
95
|
-
stdout: z.string().optional(),
|
|
96
|
-
raw_events: z.array(z.unknown()).optional(),
|
|
97
|
-
});
|
|
25
|
+
export {};
|
|
98
26
|
//# sourceMappingURL=job-detail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job-detail.js","sourceRoot":"","sources":["../../src/contracts/job-detail.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"job-detail.js","sourceRoot":"","sources":["../../src/contracts/job-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWX Project Detail Output Contract — v1.0
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interface defining the structured output for project detail
|
|
5
|
+
* requests. Used by `mapProject()` to shape raw AWX API responses into
|
|
6
|
+
* the canonical format.
|
|
7
|
+
*
|
|
8
|
+
* ## Schema Fields
|
|
9
|
+
*
|
|
10
|
+
* - **schema_version**: Always "1.0"
|
|
11
|
+
* - **resource_type**: Always "project"
|
|
12
|
+
* - **id**: The numeric resource ID
|
|
13
|
+
* - **data**: Core project data with resolved related names and derived flags
|
|
14
|
+
*
|
|
15
|
+
* ## Field Naming Convention
|
|
16
|
+
*
|
|
17
|
+
* - Related resource names are resolved from `summary_fields` (not raw IDs)
|
|
18
|
+
* - `scm_type` is the SCM provider (e.g., "git", "svn", "")
|
|
19
|
+
* - `last_updated` may be null for never-updated projects
|
|
20
|
+
* - `created_by` is resolved from summary_fields.created_by.username
|
|
21
|
+
*/
|
|
22
|
+
export interface ProjectRelated {
|
|
23
|
+
organization_name: string;
|
|
24
|
+
created_by: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ProjectDerived {
|
|
27
|
+
is_successful: boolean;
|
|
28
|
+
is_failed: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ProjectData {
|
|
31
|
+
id: number;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
scm_type: string;
|
|
35
|
+
scm_url: string;
|
|
36
|
+
scm_branch: string;
|
|
37
|
+
status: string;
|
|
38
|
+
last_updated: string | null;
|
|
39
|
+
created: string;
|
|
40
|
+
modified: string;
|
|
41
|
+
/** Resolved from summary_fields.organization.name */
|
|
42
|
+
organization_name: string;
|
|
43
|
+
/** Resolved from summary_fields.created_by.username */
|
|
44
|
+
created_by: string;
|
|
45
|
+
/** Whether the project is in a successful state */
|
|
46
|
+
is_successful: boolean;
|
|
47
|
+
/** Whether the project is in a failed state */
|
|
48
|
+
is_failed: boolean;
|
|
49
|
+
warnings: string[];
|
|
50
|
+
errors: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface ProjectDetailOutput {
|
|
53
|
+
schema_version: "1.0";
|
|
54
|
+
resource_type: "project";
|
|
55
|
+
id: number;
|
|
56
|
+
data: ProjectData;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=project-detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-detail.d.ts","sourceRoot":"","sources":["../../src/contracts/project-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,aAAa,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAID,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,KAAK,CAAC;IACtB,aAAa,EAAE,SAAS,CAAC;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWX Project Detail Output Contract — v1.0
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interface defining the structured output for project detail
|
|
5
|
+
* requests. Used by `mapProject()` to shape raw AWX API responses into
|
|
6
|
+
* the canonical format.
|
|
7
|
+
*
|
|
8
|
+
* ## Schema Fields
|
|
9
|
+
*
|
|
10
|
+
* - **schema_version**: Always "1.0"
|
|
11
|
+
* - **resource_type**: Always "project"
|
|
12
|
+
* - **id**: The numeric resource ID
|
|
13
|
+
* - **data**: Core project data with resolved related names and derived flags
|
|
14
|
+
*
|
|
15
|
+
* ## Field Naming Convention
|
|
16
|
+
*
|
|
17
|
+
* - Related resource names are resolved from `summary_fields` (not raw IDs)
|
|
18
|
+
* - `scm_type` is the SCM provider (e.g., "git", "svn", "")
|
|
19
|
+
* - `last_updated` may be null for never-updated projects
|
|
20
|
+
* - `created_by` is resolved from summary_fields.created_by.username
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=project-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-detail.js","sourceRoot":"","sources":["../../src/contracts/project-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Sync Project Output Contract
|
|
3
3
|
*
|
|
4
4
|
* Canonical schema for the `awx-sync-project` tool's return value.
|
|
5
|
-
* Defines both:
|
|
6
|
-
* - Zod schema for runtime validation
|
|
7
|
-
* - Inferred TypeScript types for static type checking
|
|
8
5
|
*
|
|
9
6
|
* ## Schema Fields
|
|
10
7
|
*
|
|
@@ -16,16 +13,14 @@
|
|
|
16
13
|
* - **scm_type**: SCM type (e.g., "git", "svn")
|
|
17
14
|
* - **last_updated**: Timestamp of last project update
|
|
18
15
|
*/
|
|
19
|
-
import { z } from "zod";
|
|
20
|
-
export declare const ProjectSyncOutputSchema: z.ZodObject<{
|
|
21
|
-
project_update_id: z.ZodNumber;
|
|
22
|
-
status: z.ZodString;
|
|
23
|
-
project_name: z.ZodString;
|
|
24
|
-
project_id: z.ZodNumber;
|
|
25
|
-
url: z.ZodString;
|
|
26
|
-
scm_type: z.ZodString;
|
|
27
|
-
last_updated: z.ZodString;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
16
|
/** Structured output returned by the awx-sync-project tool */
|
|
30
|
-
export
|
|
17
|
+
export interface ProjectSyncOutput {
|
|
18
|
+
project_update_id: number;
|
|
19
|
+
status: string;
|
|
20
|
+
project_name: string;
|
|
21
|
+
project_id: number;
|
|
22
|
+
url: string;
|
|
23
|
+
scm_type: string;
|
|
24
|
+
last_updated: string;
|
|
25
|
+
}
|
|
31
26
|
//# sourceMappingURL=sync-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-project.d.ts","sourceRoot":"","sources":["../../src/contracts/sync-project.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-project.d.ts","sourceRoot":"","sources":["../../src/contracts/sync-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Sync Project Output Contract
|
|
3
3
|
*
|
|
4
4
|
* Canonical schema for the `awx-sync-project` tool's return value.
|
|
5
|
-
* Defines both:
|
|
6
|
-
* - Zod schema for runtime validation
|
|
7
|
-
* - Inferred TypeScript types for static type checking
|
|
8
5
|
*
|
|
9
6
|
* ## Schema Fields
|
|
10
7
|
*
|
|
@@ -16,15 +13,5 @@
|
|
|
16
13
|
* - **scm_type**: SCM type (e.g., "git", "svn")
|
|
17
14
|
* - **last_updated**: Timestamp of last project update
|
|
18
15
|
*/
|
|
19
|
-
|
|
20
|
-
// ─── Top-level schema ──────────────────────────────────────
|
|
21
|
-
export const ProjectSyncOutputSchema = z.object({
|
|
22
|
-
project_update_id: z.number().int().positive(),
|
|
23
|
-
status: z.string(),
|
|
24
|
-
project_name: z.string(),
|
|
25
|
-
project_id: z.number().int().positive(),
|
|
26
|
-
url: z.string(),
|
|
27
|
-
scm_type: z.string(),
|
|
28
|
-
last_updated: z.string(),
|
|
29
|
-
});
|
|
16
|
+
export {};
|
|
30
17
|
//# sourceMappingURL=sync-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-project.js","sourceRoot":"","sources":["../../src/contracts/sync-project.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-project.js","sourceRoot":"","sources":["../../src/contracts/sync-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWX Template Detail Output Contract — v1.0
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interface defining the structured output for job template
|
|
5
|
+
* detail requests. Used by `mapTemplate()` to shape raw AWX API responses
|
|
6
|
+
* into the canonical format.
|
|
7
|
+
*
|
|
8
|
+
* ## Schema Fields
|
|
9
|
+
*
|
|
10
|
+
* - **schema_version**: Always "1.0"
|
|
11
|
+
* - **resource_type**: Always "template"
|
|
12
|
+
* - **id**: The numeric resource ID
|
|
13
|
+
* - **data**: Core template data with resolved related names
|
|
14
|
+
*
|
|
15
|
+
* ## Field Naming Convention
|
|
16
|
+
*
|
|
17
|
+
* - Related resource names are resolved from `summary_fields` (not raw IDs)
|
|
18
|
+
* - `ask_*` fields are boolean launch-time prompts
|
|
19
|
+
* - `last_job_run` and `next_schedule` may be null
|
|
20
|
+
*/
|
|
21
|
+
export interface TemplateData {
|
|
22
|
+
id: number;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
job_type: string;
|
|
26
|
+
/** Resolved from summary_fields.inventory.name */
|
|
27
|
+
inventory_name: string;
|
|
28
|
+
/** Resolved from summary_fields.project.name */
|
|
29
|
+
project_name: string;
|
|
30
|
+
/** Resolved from summary_fields.organization.name */
|
|
31
|
+
organization_name: string;
|
|
32
|
+
playbook: string;
|
|
33
|
+
verbosity: number;
|
|
34
|
+
/** Whether the template prompts for variables on launch */
|
|
35
|
+
ask_variables_on_launch: boolean;
|
|
36
|
+
/** Whether the template prompts for inventory on launch */
|
|
37
|
+
ask_inventory_on_launch: boolean;
|
|
38
|
+
/** Whether the template prompts for a host limit on launch */
|
|
39
|
+
ask_limit_on_launch: boolean;
|
|
40
|
+
/** ISO 8601 timestamp of the most recent job launch, or null */
|
|
41
|
+
last_job_run: string | null;
|
|
42
|
+
/** Current template status (e.g. "successful", "never updated") */
|
|
43
|
+
status: string;
|
|
44
|
+
/** Name of the next scheduled run, or null */
|
|
45
|
+
next_schedule: string | null;
|
|
46
|
+
/** Resolved label names from summary_fields.labels.results */
|
|
47
|
+
labels: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface TemplateDetailOutput {
|
|
50
|
+
schema_version: "1.0";
|
|
51
|
+
resource_type: "template";
|
|
52
|
+
id: number;
|
|
53
|
+
data: TemplateData;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=template-detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-detail.d.ts","sourceRoot":"","sources":["../../src/contracts/template-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,uBAAuB,EAAE,OAAO,CAAC;IACjC,2DAA2D;IAC3D,uBAAuB,EAAE,OAAO,CAAC;IACjC,8DAA8D;IAC9D,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gEAAgE;IAChE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAID,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,KAAK,CAAC;IACtB,aAAa,EAAE,UAAU,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;CACpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWX Template Detail Output Contract — v1.0
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interface defining the structured output for job template
|
|
5
|
+
* detail requests. Used by `mapTemplate()` to shape raw AWX API responses
|
|
6
|
+
* into the canonical format.
|
|
7
|
+
*
|
|
8
|
+
* ## Schema Fields
|
|
9
|
+
*
|
|
10
|
+
* - **schema_version**: Always "1.0"
|
|
11
|
+
* - **resource_type**: Always "template"
|
|
12
|
+
* - **id**: The numeric resource ID
|
|
13
|
+
* - **data**: Core template data with resolved related names
|
|
14
|
+
*
|
|
15
|
+
* ## Field Naming Convention
|
|
16
|
+
*
|
|
17
|
+
* - Related resource names are resolved from `summary_fields` (not raw IDs)
|
|
18
|
+
* - `ask_*` fields are boolean launch-time prompts
|
|
19
|
+
* - `last_job_run` and `next_schedule` may be null
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=template-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-detail.js","sourceRoot":"","sources":["../../src/contracts/template-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get-resource.ts — AWX Resource Detail Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Generalized individual resource detail getter. Maps { type, id } to
|
|
5
|
+
* an AWX API endpoint, fetches the resource, and delegates to a
|
|
6
|
+
* per-type mapper to produce the structured output envelope.
|
|
7
|
+
*
|
|
8
|
+
* ## Design
|
|
9
|
+
*
|
|
10
|
+
* - **Registry**: `RESOURCE_REGISTRY` maps type strings to AWX API
|
|
11
|
+
* endpoints and mapper functions.
|
|
12
|
+
* - **Dispatch**: `getResource()` looks up the registry, fetches from
|
|
13
|
+
* AWX, maps the response, and returns a typed output.
|
|
14
|
+
* - **Error handling**: Unknown types throw with a clear message.
|
|
15
|
+
* Non-2xx API responses throw with status and body details.
|
|
16
|
+
* Abort errors propagate through.
|
|
17
|
+
*
|
|
18
|
+
* ## Adding a new resource type
|
|
19
|
+
*
|
|
20
|
+
* 1. Define a contract in `contracts/<resource>-detail.ts`
|
|
21
|
+
* 2. Write a mapper in `mappers/map-<resource>.ts`
|
|
22
|
+
* 3. Register it in `RESOURCE_REGISTRY` below
|
|
23
|
+
* 4. Optionally add the type to the Zod schema in `index.ts`
|
|
24
|
+
*/
|
|
25
|
+
import type { AwxClient } from "./client.js";
|
|
26
|
+
import type { TemplateDetailOutput } from "./contracts/template-detail.js";
|
|
27
|
+
import type { ProjectDetailOutput } from "./contracts/project-detail.js";
|
|
28
|
+
import type { InventoryDetailOutput } from "./contracts/inventory-detail.js";
|
|
29
|
+
/**
|
|
30
|
+
* Union of all supported resource detail output types.
|
|
31
|
+
* Extend this when adding new resource types.
|
|
32
|
+
*/
|
|
33
|
+
export type ResourceDetailOutput = TemplateDetailOutput | ProjectDetailOutput | InventoryDetailOutput;
|
|
34
|
+
/**
|
|
35
|
+
* Supported resource type keys (used by the tool args Zod schema).
|
|
36
|
+
*/
|
|
37
|
+
export type ResourceType = "template" | "project" | "inventory";
|
|
38
|
+
/**
|
|
39
|
+
* Fetch and map a single AWX resource by type and ID.
|
|
40
|
+
*
|
|
41
|
+
* @param client The AWX HTTP client
|
|
42
|
+
* @param type Resource type (e.g., "template")
|
|
43
|
+
* @param id Numeric resource ID
|
|
44
|
+
* @param abortSignal Optional AbortSignal for cancellation
|
|
45
|
+
* @returns Mapped resource output (e.g., TemplateDetailOutput)
|
|
46
|
+
* @throws If type is unsupported or the API returns an error
|
|
47
|
+
*/
|
|
48
|
+
export declare function getResource(client: AwxClient, type: ResourceType, id: number, abortSignal?: AbortSignal): Promise<ResourceDetailOutput>;
|
|
49
|
+
//# sourceMappingURL=get-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resource.d.ts","sourceRoot":"","sources":["../src/get-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAEtG;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AAkChE;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,YAAY,EAClB,EAAE,EAAE,MAAM,EACV,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,oBAAoB,CAAC,CA6B/B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { mapTemplate } from "./mappers/map-template.js";
|
|
2
|
+
import { mapProject } from "./mappers/map-project.js";
|
|
3
|
+
import { mapInventory } from "./mappers/map-inventory.js";
|
|
4
|
+
/**
|
|
5
|
+
* Type→endpoint+mapper registry.
|
|
6
|
+
*
|
|
7
|
+
* Each entry maps a resource type string to:
|
|
8
|
+
* - `path`: AWX API endpoint with `{id}` placeholder
|
|
9
|
+
* - `mapper`: pure function that transforms the raw API response
|
|
10
|
+
*/
|
|
11
|
+
const RESOURCE_REGISTRY = {
|
|
12
|
+
template: {
|
|
13
|
+
path: "/api/v2/job_templates/{id}/",
|
|
14
|
+
mapper: mapTemplate,
|
|
15
|
+
},
|
|
16
|
+
project: {
|
|
17
|
+
path: "/api/v2/projects/{id}/",
|
|
18
|
+
mapper: mapProject,
|
|
19
|
+
},
|
|
20
|
+
inventory: {
|
|
21
|
+
path: "/api/v2/inventories/{id}/",
|
|
22
|
+
mapper: mapInventory,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Fetch and map a single AWX resource by type and ID.
|
|
27
|
+
*
|
|
28
|
+
* @param client The AWX HTTP client
|
|
29
|
+
* @param type Resource type (e.g., "template")
|
|
30
|
+
* @param id Numeric resource ID
|
|
31
|
+
* @param abortSignal Optional AbortSignal for cancellation
|
|
32
|
+
* @returns Mapped resource output (e.g., TemplateDetailOutput)
|
|
33
|
+
* @throws If type is unsupported or the API returns an error
|
|
34
|
+
*/
|
|
35
|
+
export async function getResource(client, type, id, abortSignal) {
|
|
36
|
+
const entry = RESOURCE_REGISTRY[type];
|
|
37
|
+
if (!entry) {
|
|
38
|
+
throw new Error(`Unsupported resource type: "${type}". Supported types: ${Object.keys(RESOURCE_REGISTRY).join(", ")}`);
|
|
39
|
+
}
|
|
40
|
+
const path = entry.path.replace("{id}", String(id));
|
|
41
|
+
const response = await client.request("awx-get-resource", path, undefined, abortSignal);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const errorBody = await response.text().catch(() => "");
|
|
44
|
+
throw new Error(`AWX API error (${response.status}): ${errorBody || response.statusText}`);
|
|
45
|
+
}
|
|
46
|
+
const raw = (await response.json());
|
|
47
|
+
return entry.mapper(raw);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=get-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resource.js","sourceRoot":"","sources":["../src/get-resource.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AA0B1D;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAwC;IAC7D,QAAQ,EAAE;QACR,IAAI,EAAE,6BAA6B;QACnC,MAAM,EAAE,WAAW;KACpB;IACD,OAAO,EAAE;QACP,IAAI,EAAE,wBAAwB;QAC9B,MAAM,EAAE,UAAU;KACnB;IACD,SAAS,EAAE;QACT,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,YAAY;KACrB;CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAiB,EACjB,IAAkB,EAClB,EAAU,EACV,WAAyB;IAEzB,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,uBACjC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAC1C,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,kBAAkB,EAClB,IAAI,EACJ,SAAS,EACT,WAAW,CACZ,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,IAAI,KAAK,CACb,kBAAkB,QAAQ,CAAC,MAAM,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAC1E,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAY,CAAC;IAC/C,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAyB,CAAC;AACnD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Plugin-specific configuration from opencode.jsonc */
|
|
3
|
-
export interface AwxPluginOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Base URL of the AAP/AWX instance.
|
|
6
|
-
* Must include protocol (https://) and hostname.
|
|
7
|
-
* Example: "https://example.com"
|
|
8
|
-
*/
|
|
9
|
-
baseUrl?: string;
|
|
10
|
-
}
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin";
|
|
11
2
|
/**
|
|
12
|
-
* Plugin
|
|
3
|
+
* AWX Plugin — the named async export consumed by the OpenCode plugin server.
|
|
4
|
+
*
|
|
5
|
+
* Registered in opencode.jsonc as a string-only plugin entry:
|
|
6
|
+
* ```jsonc
|
|
7
|
+
* { "plugin": ["@weiyentan/opencode-plugin-awx"] }
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Configuration is read from environment variables:
|
|
11
|
+
* - `AWX_BASE_URL`: Base URL of the AAP/AWX instance (e.g. "https://example.com")
|
|
13
12
|
*/
|
|
14
|
-
declare const
|
|
15
|
-
export default
|
|
13
|
+
export declare const AwxPlugin: Plugin;
|
|
14
|
+
export default AwxPlugin;
|
|
16
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAsB,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAsgCtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,MAAe,CAAC;AACxC,eAAe,SAAS,CAAC"}
|