@f5-sales-demo/xcsh 23.3.3 → 23.3.4
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/package.json +8 -8
- package/src/internal-urls/api-catalog-index.generated.ts +25301 -25301
- package/src/internal-urls/api-catalog-qmd-index.generated.ts +2 -2
- package/src/internal-urls/api-catalog-resolve.ts +4 -0
- package/src/internal-urls/api-spec-index.generated.ts +1 -1
- package/src/internal-urls/api-spec-resolve.ts +7 -1
- package/src/internal-urls/build-info.generated.ts +9 -9
- package/src/internal-urls/immutable-selection.ts +178 -0
- package/src/internal-urls/public-citation-destinations.generated.ts +1 -1
- package/src/internal-urls/terraform-documentation-assets.generated.ts +24 -24
- package/src/internal-urls/terraform-index.generated.ts +1 -1
- package/src/internal-urls/terraform-provider-pin.generated.ts +1 -1
- package/src/prompts/tools/xcsh-api.md +2 -0
- package/src/tools/xcsh-api-renderer.ts +16 -0
- package/src/tools/xcsh-api-replacement.ts +524 -0
- package/src/tools/xcsh-api.ts +61 -0
|
@@ -14,7 +14,9 @@ import type {
|
|
|
14
14
|
ApiCatalogIndex,
|
|
15
15
|
ApiCatalogOperation,
|
|
16
16
|
} from "./api-catalog-types";
|
|
17
|
+
import { API_SPEC_DATA } from "./api-spec-index.generated";
|
|
17
18
|
import type { ApiSpecDomainResource, ApiSpecIndex } from "./api-spec-types";
|
|
19
|
+
import { formatImmutableGroups, mutationContract } from "./immutable-selection";
|
|
18
20
|
import { formatMapConstraints, type MapConstraints } from "./map-constraints";
|
|
19
21
|
import { PUBLIC_CITATION_SOURCES } from "./public-citation-destinations.generated";
|
|
20
22
|
import { citationLine, publicCitationForApiOperation, publicCitationForInternalUri } from "./public-citations";
|
|
@@ -432,6 +434,8 @@ function renderCatalogDetail(cat: ApiCatalogCategory, options?: { compact?: bool
|
|
|
432
434
|
}
|
|
433
435
|
}
|
|
434
436
|
|
|
437
|
+
const contract = mutationContract(API_SPEC_DATA, "PUT", normalizeApiPath(op.path));
|
|
438
|
+
if (contract) sections.push("", formatImmutableGroups(contract.groups), "");
|
|
435
439
|
// OneOf Groups — combined recommendations + available variants
|
|
436
440
|
const hasRecs = op.oneOfRecommendations && Object.keys(op.oneOfRecommendations).length > 0;
|
|
437
441
|
const hasVariants = op.oneOfVariants && Object.keys(op.oneOfVariants).length > 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/src/internal-urls/api-spec-index.generated.ts
|
|
3
3
|
size: 41998054 bytes
|
|
4
|
-
sha256:
|
|
4
|
+
sha256: 923fbda51724fe4d8f3fb7a0769cd61b3fba7fbc2c33efa375235db79ba57dc8
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
OpenAPIPathOperation,
|
|
10
10
|
OpenAPISpec,
|
|
11
11
|
} from "./api-spec-types";
|
|
12
|
+
import { formatImmutableGroups, immutableGroups } from "./immutable-selection";
|
|
12
13
|
import { formatMapConstraints, type MapConstraints } from "./map-constraints";
|
|
13
14
|
import { PUBLIC_CITATION_SOURCES } from "./public-citation-destinations.generated";
|
|
14
15
|
import { citationLine, publicCitationForInternalUri } from "./public-citations";
|
|
@@ -1098,7 +1099,12 @@ function renderSchemaAsTable(
|
|
|
1098
1099
|
const required = (resolved.required as string[]) ?? [];
|
|
1099
1100
|
const rows: string[] = [];
|
|
1100
1101
|
|
|
1101
|
-
const oneOfStr =
|
|
1102
|
+
const oneOfStr = [
|
|
1103
|
+
renderOneOfGroups(resolved, schemaRecommended),
|
|
1104
|
+
formatImmutableGroups(immutableGroups(resolved, spec, prefix ? prefix.split(".") : [])),
|
|
1105
|
+
]
|
|
1106
|
+
.filter(Boolean)
|
|
1107
|
+
.join("\n");
|
|
1102
1108
|
if (depth === 0) {
|
|
1103
1109
|
if (oneOfStr) rows.push(oneOfStr);
|
|
1104
1110
|
rows.push("| Field | Type | Required | Default | Constraints | Example | Description |");
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "23.3.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
23
|
-
"branch": "
|
|
24
|
-
"tag": "v23.3.
|
|
25
|
-
"commitDate": "2026-10-
|
|
26
|
-
"buildDate": "2026-10-
|
|
20
|
+
"version": "23.3.4",
|
|
21
|
+
"commit": "44ddc5e33ac2f46a9ad91a8dc296d2d1c998a799",
|
|
22
|
+
"shortCommit": "44ddc5e",
|
|
23
|
+
"branch": "unknown",
|
|
24
|
+
"tag": "v23.3.4",
|
|
25
|
+
"commitDate": "2026-10-13T21:05:45Z",
|
|
26
|
+
"buildDate": "2026-10-14T02:04:09.220Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v23.3.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/44ddc5e33ac2f46a9ad91a8dc296d2d1c998a799",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v23.3.4"
|
|
33
33
|
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { OpenAPISpec } from "./api-spec-types";
|
|
2
|
+
|
|
3
|
+
type ObjectValue = Record<string, unknown>;
|
|
4
|
+
export interface ImmutableGroup {
|
|
5
|
+
path: string[];
|
|
6
|
+
name: string;
|
|
7
|
+
members: string[];
|
|
8
|
+
}
|
|
9
|
+
export function objectValue(value: unknown): ObjectValue {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Expected a JSON object");
|
|
11
|
+
return value as ObjectValue;
|
|
12
|
+
}
|
|
13
|
+
export function resolveSchema(schema: ObjectValue, spec: OpenAPISpec, seen = new Set<string>()): ObjectValue {
|
|
14
|
+
const ref = schema.$ref;
|
|
15
|
+
let result = { ...schema };
|
|
16
|
+
if (typeof ref === "string") {
|
|
17
|
+
if (!ref.startsWith("#/components/schemas/") || seen.has(ref)) return {};
|
|
18
|
+
const target = spec.components?.schemas?.[ref.slice("#/components/schemas/".length)];
|
|
19
|
+
if (!target) throw new Error(`Missing schema ${ref}`);
|
|
20
|
+
result = { ...resolveSchema(target, spec, new Set([...seen, ref])), ...schema };
|
|
21
|
+
}
|
|
22
|
+
for (const child of (schema.allOf as ObjectValue[] | undefined) ?? []) {
|
|
23
|
+
const resolved = resolveSchema(child, spec, seen);
|
|
24
|
+
result = {
|
|
25
|
+
...result,
|
|
26
|
+
...resolved,
|
|
27
|
+
properties: { ...(result.properties as ObjectValue), ...(resolved.properties as ObjectValue) },
|
|
28
|
+
required: [...new Set([...((result.required as string[]) ?? []), ...((resolved.required as string[]) ?? [])])],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
export function immutableGroups(
|
|
34
|
+
schema: ObjectValue,
|
|
35
|
+
spec: OpenAPISpec,
|
|
36
|
+
path: string[] = [],
|
|
37
|
+
seen = new Set<string>(),
|
|
38
|
+
): ImmutableGroup[] {
|
|
39
|
+
if (typeof schema.$ref === "string" && seen.has(schema.$ref)) return [];
|
|
40
|
+
const next = new Set(seen);
|
|
41
|
+
if (typeof schema.$ref === "string") next.add(schema.$ref);
|
|
42
|
+
const resolved = resolveSchema(schema, spec);
|
|
43
|
+
const groups: ImmutableGroup[] = [];
|
|
44
|
+
for (const [name, members] of Object.entries((resolved["x-f5xc-immutable-oneof-groups"] as ObjectValue) ?? {})) {
|
|
45
|
+
if (!Array.isArray(members) || members.length < 2 || !members.every(m => typeof m === "string"))
|
|
46
|
+
throw new Error(`Invalid immutable group ${name}`);
|
|
47
|
+
groups.push({ path, name, members });
|
|
48
|
+
}
|
|
49
|
+
for (const [name, child] of Object.entries((resolved.properties as ObjectValue) ?? {}))
|
|
50
|
+
groups.push(...immutableGroups(objectValue(child), spec, [...path, name], next));
|
|
51
|
+
return groups;
|
|
52
|
+
}
|
|
53
|
+
export function valueAt(value: ObjectValue, path: string[]): ObjectValue {
|
|
54
|
+
let result = value;
|
|
55
|
+
for (const key of path) result = objectValue(result[key]);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
export function selectedMember(value: ObjectValue, group: ImmutableGroup): string {
|
|
59
|
+
const owner = valueAt(value, group.path);
|
|
60
|
+
const selected = group.members.filter(member => owner[member] !== undefined && owner[member] !== null);
|
|
61
|
+
if (selected.length !== 1)
|
|
62
|
+
throw new Error(`${[...group.path, group.name].join(".")} requires exactly one of ${group.members.join(", ")}`);
|
|
63
|
+
objectValue(owner[selected[0]!]);
|
|
64
|
+
return selected[0]!;
|
|
65
|
+
}
|
|
66
|
+
export function formatImmutableGroups(groups: ImmutableGroup[]): string {
|
|
67
|
+
return groups
|
|
68
|
+
.map(
|
|
69
|
+
g =>
|
|
70
|
+
`Immutable selection ${[...g.path, g.name].join(".")}: ${g.members.join(" | ")}. Changing the selected member requires DELETE then POST; child settings remain mutable.`,
|
|
71
|
+
)
|
|
72
|
+
.join("\n");
|
|
73
|
+
}
|
|
74
|
+
export function createBody(value: unknown, schema: ObjectValue, spec: OpenAPISpec): unknown {
|
|
75
|
+
const s = resolveSchema(schema, spec);
|
|
76
|
+
if (value === null || value === undefined || s.readOnly === true || s["x-field-mutability"] === "read-only")
|
|
77
|
+
return undefined;
|
|
78
|
+
if (Array.isArray(value)) return value.map(v => createBody(v, objectValue(s.items ?? {}), spec));
|
|
79
|
+
if (typeof value !== "object") return value;
|
|
80
|
+
const props = s.properties as ObjectValue | undefined;
|
|
81
|
+
const out: ObjectValue = {};
|
|
82
|
+
const input = { ...(value as ObjectValue) };
|
|
83
|
+
if (
|
|
84
|
+
props?.response_body_encoded &&
|
|
85
|
+
typeof input.response_body === "string" &&
|
|
86
|
+
input.response_body &&
|
|
87
|
+
!input.response_body_encoded
|
|
88
|
+
)
|
|
89
|
+
input.response_body_encoded = `string:///${Buffer.from(input.response_body).toString("base64")}`;
|
|
90
|
+
for (const [key, child] of Object.entries(input)) {
|
|
91
|
+
if (props && !(key in props)) continue;
|
|
92
|
+
const childSchema = props?.[key] ?? (typeof s.additionalProperties === "object" ? s.additionalProperties : {});
|
|
93
|
+
const projected = createBody(child, objectValue(childSchema), spec);
|
|
94
|
+
if (projected !== undefined) out[key] = projected;
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
export function validateBody(value: unknown, schema: ObjectValue, spec: OpenAPISpec, path = "body"): string[] {
|
|
99
|
+
const s = resolveSchema(schema, spec);
|
|
100
|
+
const errors: string[] = [];
|
|
101
|
+
if (value === undefined || value === null) return errors;
|
|
102
|
+
const type = Array.isArray(value) ? "array" : typeof value;
|
|
103
|
+
if (
|
|
104
|
+
typeof s.type === "string" &&
|
|
105
|
+
s.type !== type &&
|
|
106
|
+
!(s.type === "integer" && typeof value === "number" && Number.isInteger(value))
|
|
107
|
+
)
|
|
108
|
+
return [`${path}: expected ${s.type}`];
|
|
109
|
+
if (Array.isArray(s.enum) && !s.enum.includes(value)) errors.push(`${path}: invalid enum value`);
|
|
110
|
+
if (typeof value === "number") {
|
|
111
|
+
if (typeof s.minimum === "number" && value < s.minimum) errors.push(`${path}: below minimum`);
|
|
112
|
+
if (typeof s.maximum === "number" && value > s.maximum) errors.push(`${path}: above maximum`);
|
|
113
|
+
}
|
|
114
|
+
if (typeof value === "string") {
|
|
115
|
+
if (typeof s.minLength === "number" && value.length < s.minLength) errors.push(`${path}: too short`);
|
|
116
|
+
if (typeof s.maxLength === "number" && value.length > s.maxLength) errors.push(`${path}: too long`);
|
|
117
|
+
if (typeof s.pattern === "string" && !new RegExp(s.pattern).test(value)) errors.push(`${path}: pattern mismatch`);
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
if (typeof s.minItems === "number" && value.length < s.minItems) errors.push(`${path}: too few items`);
|
|
121
|
+
if (typeof s.maxItems === "number" && value.length > s.maxItems) errors.push(`${path}: too many items`);
|
|
122
|
+
value.forEach((v, i) => {
|
|
123
|
+
errors.push(...validateBody(v, objectValue(s.items ?? {}), spec, `${path}[${i}]`));
|
|
124
|
+
});
|
|
125
|
+
} else if (typeof value === "object") {
|
|
126
|
+
const o = objectValue(value);
|
|
127
|
+
for (const key of (s.required as string[] | undefined) ?? [])
|
|
128
|
+
if (o[key] === undefined || o[key] === null) errors.push(`${path}.${key}: required`);
|
|
129
|
+
for (const [key, child] of Object.entries(o)) {
|
|
130
|
+
const p = (s.properties as ObjectValue)?.[key];
|
|
131
|
+
if (p) errors.push(...validateBody(child, objectValue(p), spec, `${path}.${key}`));
|
|
132
|
+
}
|
|
133
|
+
for (const [key, members] of Object.entries(s))
|
|
134
|
+
if (key.startsWith("x-ves-oneof-field-")) {
|
|
135
|
+
const choices = typeof members === "string" ? JSON.parse(members) : members;
|
|
136
|
+
if (Array.isArray(choices) && choices.filter(k => o[k] !== undefined && o[k] !== null).length > 1)
|
|
137
|
+
errors.push(`${path}.${key}: mutually exclusive members`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return errors;
|
|
141
|
+
}
|
|
142
|
+
export interface MutationContract {
|
|
143
|
+
spec: OpenAPISpec;
|
|
144
|
+
schema: ObjectValue;
|
|
145
|
+
createSchema: ObjectValue;
|
|
146
|
+
groups: ImmutableGroup[];
|
|
147
|
+
collection: string;
|
|
148
|
+
}
|
|
149
|
+
export function mutationContract(
|
|
150
|
+
data: Readonly<Record<string, unknown>>,
|
|
151
|
+
method: string,
|
|
152
|
+
path: string,
|
|
153
|
+
): MutationContract | undefined {
|
|
154
|
+
for (const raw of Object.values(data)) {
|
|
155
|
+
const spec = raw as OpenAPISpec;
|
|
156
|
+
for (const [template, operations] of Object.entries(spec.paths)) {
|
|
157
|
+
const parts = template.split("/");
|
|
158
|
+
const actual = path.split("/");
|
|
159
|
+
if (parts.length !== actual.length || !parts.every((p, i) => /^\{[^}]+\}$/.test(p) || p === actual[i]))
|
|
160
|
+
continue;
|
|
161
|
+
const op = operations[method.toLowerCase()];
|
|
162
|
+
if (!op?.requestBody) continue;
|
|
163
|
+
const schema = ((op.requestBody.content as ObjectValue)?.["application/json"] as ObjectValue)
|
|
164
|
+
?.schema as ObjectValue;
|
|
165
|
+
if (!schema) continue;
|
|
166
|
+
const groups = immutableGroups(schema, spec);
|
|
167
|
+
if (!groups.length) continue;
|
|
168
|
+
const collection = path.slice(0, path.lastIndexOf("/"));
|
|
169
|
+
const createTemplate = template.slice(0, template.lastIndexOf("/"));
|
|
170
|
+
const create = (
|
|
171
|
+
(spec.paths[createTemplate]?.post?.requestBody?.content as ObjectValue)?.["application/json"] as ObjectValue
|
|
172
|
+
)?.schema as ObjectValue;
|
|
173
|
+
if (!create) throw new Error("Immutable mutation has no create schema");
|
|
174
|
+
return { spec, schema, createSchema: create, groups, collection };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|