新增 release artifact URL workflow SDK API
This commit is contained in:
@@ -518,6 +518,162 @@ export function createProjectReleaseReadinessArtifactJsonWorkflow({ artifactJson
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadProjectReleaseReadinessArtifactUrlWorkflow({
|
||||
artifactUrl = "",
|
||||
fetchRef = globalThis.fetch,
|
||||
} = {}) {
|
||||
if (!artifactUrl || typeof fetchRef !== "function") {
|
||||
const jsonWorkflow = createProjectReleaseReadinessArtifactJsonWorkflow({ artifactJson: "" });
|
||||
const missing = [
|
||||
...(artifactUrl ? [] : ["artifact-url"]),
|
||||
...(typeof fetchRef === "function" ? [] : ["fetch"]),
|
||||
...jsonWorkflow.missing,
|
||||
];
|
||||
return {
|
||||
apiName: "project-release-readiness-artifact-url-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
artifactUrl,
|
||||
fetched: false,
|
||||
httpStatus: null,
|
||||
fetchError: null,
|
||||
jsonWorkflow,
|
||||
validation: jsonWorkflow.validation,
|
||||
summaryViewModel: jsonWorkflow.summaryViewModel,
|
||||
actionPlan: jsonWorkflow.actionPlan,
|
||||
missing,
|
||||
rows: [
|
||||
{
|
||||
id: "fetch",
|
||||
label: "Artifact URL fetch",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "json-workflow",
|
||||
label: "Artifact JSON workflow",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "next-command",
|
||||
label: "Next command",
|
||||
value: jsonWorkflow.actionPlan.nextCommand ?? "none",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetchRef(artifactUrl);
|
||||
const httpStatus = response?.status ?? null;
|
||||
if (!response?.ok) {
|
||||
const jsonWorkflow = createProjectReleaseReadinessArtifactJsonWorkflow({ artifactJson: "" });
|
||||
const fetchError = `artifact URL fetch failed${httpStatus ? `: ${httpStatus}` : ""}`;
|
||||
return {
|
||||
apiName: "project-release-readiness-artifact-url-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
artifactUrl,
|
||||
fetched: false,
|
||||
httpStatus,
|
||||
fetchError,
|
||||
jsonWorkflow,
|
||||
validation: jsonWorkflow.validation,
|
||||
summaryViewModel: jsonWorkflow.summaryViewModel,
|
||||
actionPlan: jsonWorkflow.actionPlan,
|
||||
missing: ["artifact-fetch", ...jsonWorkflow.missing],
|
||||
rows: [
|
||||
{
|
||||
id: "fetch",
|
||||
label: "Artifact URL fetch",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "json-workflow",
|
||||
label: "Artifact JSON workflow",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "next-command",
|
||||
label: "Next command",
|
||||
value: jsonWorkflow.actionPlan.nextCommand ?? "none",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const artifactJson = await response.text();
|
||||
const jsonWorkflow = createProjectReleaseReadinessArtifactJsonWorkflow({ artifactJson });
|
||||
return {
|
||||
apiName: "project-release-readiness-artifact-url-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: jsonWorkflow.ready === true ? "ready" : "blocked",
|
||||
ready: jsonWorkflow.ready === true,
|
||||
artifactUrl,
|
||||
fetched: true,
|
||||
httpStatus,
|
||||
fetchError: null,
|
||||
jsonWorkflow,
|
||||
validation: jsonWorkflow.validation,
|
||||
summaryViewModel: jsonWorkflow.summaryViewModel,
|
||||
actionPlan: jsonWorkflow.actionPlan,
|
||||
missing: jsonWorkflow.missing,
|
||||
rows: [
|
||||
{
|
||||
id: "fetch",
|
||||
label: "Artifact URL fetch",
|
||||
value: "ready",
|
||||
},
|
||||
{
|
||||
id: "json-workflow",
|
||||
label: "Artifact JSON workflow",
|
||||
value: jsonWorkflow.ready === true ? "ready" : "blocked",
|
||||
},
|
||||
{
|
||||
id: "next-command",
|
||||
label: "Next command",
|
||||
value: jsonWorkflow.actionPlan.nextCommand ?? "none",
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
const jsonWorkflow = createProjectReleaseReadinessArtifactJsonWorkflow({ artifactJson: "" });
|
||||
return {
|
||||
apiName: "project-release-readiness-artifact-url-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
artifactUrl,
|
||||
fetched: false,
|
||||
httpStatus: null,
|
||||
fetchError: error?.message ?? "artifact URL fetch error",
|
||||
jsonWorkflow,
|
||||
validation: jsonWorkflow.validation,
|
||||
summaryViewModel: jsonWorkflow.summaryViewModel,
|
||||
actionPlan: jsonWorkflow.actionPlan,
|
||||
missing: ["artifact-fetch", ...jsonWorkflow.missing],
|
||||
rows: [
|
||||
{
|
||||
id: "fetch",
|
||||
label: "Artifact URL fetch",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "json-workflow",
|
||||
label: "Artifact JSON workflow",
|
||||
value: "blocked",
|
||||
},
|
||||
{
|
||||
id: "next-command",
|
||||
label: "Next command",
|
||||
value: jsonWorkflow.actionPlan.nextCommand ?? "none",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createProjectReleaseReadinessArtifactValidation(artifact = {}) {
|
||||
const artifactObject = objectOrEmpty(artifact);
|
||||
const releaseGate = objectOrEmpty(artifactObject.releaseGate);
|
||||
|
||||
Reference in New Issue
Block a user