Skip to content

Commit

Permalink
add typing to job endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Sep 24, 2024
1 parent b47def3 commit 0e49b1c
Show file tree
Hide file tree
Showing 9 changed files with 513 additions and 35 deletions.
2 changes: 1 addition & 1 deletion apps/webservice/src/app/api/v1/job/[jobId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const GET = async (
.where(eq(jobVariable.jobId, params.jobId));
const variable = Object.fromEntries(variabes.map((v) => [v.key, v.value]));

return NextResponse.json({ ...je, variable });
return NextResponse.json({ ...je.job, ...je, variable });
};

const bodySchema = updateJob;
Expand Down
70 changes: 66 additions & 4 deletions packages/node-sdk/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,84 @@ paths:
schema:
type: object
properties:
job:
type: object
id:
type: string
status:
type: string
enum:
[
completed,
cancelled,
skipped,
in_progress,
action_required,
pending,
failure,
invalid_job_agent,
invalid_integration,
external_run_not_found,
]

release:
type: object
properties:
id:
type: string
version:
type: string
required: [id, version]

deployment:
type: object
properties:
id:
type: string
name:
type: string
slug:
type: string
required: [id, version, slug]

runbook:
type: object
properties:
id:
type: string
name:
type: string
required: [id, name]

target:
type: object
properties:
id:
type: string
identifier:
type: string
kind:
type: string
version:
type: string
config:
type: object
required: [id, identifier, kind, version, config]

environment:
type: object
variable:
properties:
id:
type: string
name:
type: string
required: [id, name]

variables:
type: object
required:
- job
- id
- status
- createdAt
- updatedAt
- variable
patch:
summary: Update a job
Expand Down
5 changes: 4 additions & 1 deletion packages/node-sdk/src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.openapi-generator-ignore
apis/DefaultApi.ts
apis/index.ts
index.ts
models/AcknowledgeJob200Response.ts
models/GetAgentRunningJob200ResponseInner.ts
models/GetJob200Response.ts
models/GetJob200ResponseDeployment.ts
models/GetJob200ResponseRelease.ts
models/GetJob200ResponseRunbook.ts
models/GetJob200ResponseTarget.ts
models/GetNextJobs200Response.ts
models/GetNextJobs200ResponseJobsInner.ts
models/SetTargetProvidersTargetsRequest.ts
Expand Down
123 changes: 94 additions & 29 deletions packages/node-sdk/src/models/GetJob200Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,31 @@
* Do not edit the class manually.
*/

import type { GetJob200ResponseDeployment } from "./GetJob200ResponseDeployment";
import type { GetJob200ResponseRelease } from "./GetJob200ResponseRelease";
import type { GetJob200ResponseRunbook } from "./GetJob200ResponseRunbook";
import type { GetJob200ResponseTarget } from "./GetJob200ResponseTarget";
import { mapValues } from "../runtime";
import {
GetJob200ResponseDeploymentFromJSON,
GetJob200ResponseDeploymentFromJSONTyped,
GetJob200ResponseDeploymentToJSON,
} from "./GetJob200ResponseDeployment";
import {
GetJob200ResponseReleaseFromJSON,
GetJob200ResponseReleaseFromJSONTyped,
GetJob200ResponseReleaseToJSON,
} from "./GetJob200ResponseRelease";
import {
GetJob200ResponseRunbookFromJSON,
GetJob200ResponseRunbookFromJSONTyped,
GetJob200ResponseRunbookToJSON,
} from "./GetJob200ResponseRunbook";
import {
GetJob200ResponseTargetFromJSON,
GetJob200ResponseTargetFromJSONTyped,
GetJob200ResponseTargetToJSON,
} from "./GetJob200ResponseTarget";

/**
*
Expand All @@ -22,56 +46,80 @@ import { mapValues } from "../runtime";
export interface GetJob200Response {
/**
*
* @type {object}
* @type {string}
* @memberof GetJob200Response
*/
job: object;
id: string;
/**
*
* @type {object}
* @type {string}
* @memberof GetJob200Response
*/
release?: object;
status: GetJob200ResponseStatusEnum;
/**
*
* @type {object}
* @type {GetJob200ResponseRelease}
* @memberof GetJob200Response
*/
deployment?: object;
release?: GetJob200ResponseRelease;
/**
*
* @type {object}
* @type {GetJob200ResponseDeployment}
* @memberof GetJob200Response
*/
runbook?: object;
deployment?: GetJob200ResponseDeployment;
/**
*
* @type {object}
* @type {GetJob200ResponseRunbook}
* @memberof GetJob200Response
*/
target?: object;
runbook?: GetJob200ResponseRunbook;
/**
*
* @type {object}
* @type {GetJob200ResponseTarget}
* @memberof GetJob200Response
*/
target?: GetJob200ResponseTarget;
/**
*
* @type {GetJob200ResponseRunbook}
* @memberof GetJob200Response
*/
environment?: object;
environment?: GetJob200ResponseRunbook;
/**
*
* @type {object}
* @memberof GetJob200Response
*/
variable: object;
variables?: object;
}

/**
* @export
*/
export const GetJob200ResponseStatusEnum = {
Completed: "completed",
Cancelled: "cancelled",
Skipped: "skipped",
InProgress: "in_progress",
ActionRequired: "action_required",
Pending: "pending",
Failure: "failure",
InvalidJobAgent: "invalid_job_agent",
InvalidIntegration: "invalid_integration",
ExternalRunNotFound: "external_run_not_found",
} as const;
export type GetJob200ResponseStatusEnum =
(typeof GetJob200ResponseStatusEnum)[keyof typeof GetJob200ResponseStatusEnum];

/**
* Check if a given object implements the GetJob200Response interface.
*/
export function instanceOfGetJob200Response(
value: object,
): value is GetJob200Response {
if (!("job" in value) || value["job"] === undefined) return false;
if (!("variable" in value) || value["variable"] === undefined) return false;
if (!("id" in value) || value["id"] === undefined) return false;
if (!("status" in value) || value["status"] === undefined) return false;
return true;
}

Expand All @@ -87,13 +135,29 @@ export function GetJob200ResponseFromJSONTyped(
return json;
}
return {
job: json["job"],
release: json["release"] == null ? undefined : json["release"],
deployment: json["deployment"] == null ? undefined : json["deployment"],
runbook: json["runbook"] == null ? undefined : json["runbook"],
target: json["target"] == null ? undefined : json["target"],
environment: json["environment"] == null ? undefined : json["environment"],
variable: json["variable"],
id: json["id"],
status: json["status"],
release:
json["release"] == null
? undefined
: GetJob200ResponseReleaseFromJSON(json["release"]),
deployment:
json["deployment"] == null
? undefined
: GetJob200ResponseDeploymentFromJSON(json["deployment"]),
runbook:
json["runbook"] == null
? undefined
: GetJob200ResponseRunbookFromJSON(json["runbook"]),
target:
json["target"] == null
? undefined
: GetJob200ResponseTargetFromJSON(json["target"]),
environment:
json["environment"] == null
? undefined
: GetJob200ResponseRunbookFromJSON(json["environment"]),
variables: json["variables"] == null ? undefined : json["variables"],
};
}

Expand All @@ -102,12 +166,13 @@ export function GetJob200ResponseToJSON(value?: GetJob200Response | null): any {
return value;
}
return {
job: value["job"],
release: value["release"],
deployment: value["deployment"],
runbook: value["runbook"],
target: value["target"],
environment: value["environment"],
variable: value["variable"],
id: value["id"],
status: value["status"],
release: GetJob200ResponseReleaseToJSON(value["release"]),
deployment: GetJob200ResponseDeploymentToJSON(value["deployment"]),
runbook: GetJob200ResponseRunbookToJSON(value["runbook"]),
target: GetJob200ResponseTargetToJSON(value["target"]),
environment: GetJob200ResponseRunbookToJSON(value["environment"]),
variables: value["variables"],
};
}
85 changes: 85 additions & 0 deletions packages/node-sdk/src/models/GetJob200ResponseDeployment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* tslint:disable */
/* eslint-disable */
/**
* Ctrlplane API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { mapValues } from "../runtime";

/**
*
* @export
* @interface GetJob200ResponseDeployment
*/
export interface GetJob200ResponseDeployment {
/**
*
* @type {string}
* @memberof GetJob200ResponseDeployment
*/
id: string;
/**
*
* @type {string}
* @memberof GetJob200ResponseDeployment
*/
name?: string;
/**
*
* @type {string}
* @memberof GetJob200ResponseDeployment
*/
slug: string;
}

/**
* Check if a given object implements the GetJob200ResponseDeployment interface.
*/
export function instanceOfGetJob200ResponseDeployment(
value: object,
): value is GetJob200ResponseDeployment {
if (!("id" in value) || value["id"] === undefined) return false;
if (!("slug" in value) || value["slug"] === undefined) return false;
return true;
}

export function GetJob200ResponseDeploymentFromJSON(
json: any,
): GetJob200ResponseDeployment {
return GetJob200ResponseDeploymentFromJSONTyped(json, false);
}

export function GetJob200ResponseDeploymentFromJSONTyped(
json: any,
ignoreDiscriminator: boolean,
): GetJob200ResponseDeployment {
if (json == null) {
return json;
}
return {
id: json["id"],
name: json["name"] == null ? undefined : json["name"],
slug: json["slug"],
};
}

export function GetJob200ResponseDeploymentToJSON(
value?: GetJob200ResponseDeployment | null,
): any {
if (value == null) {
return value;
}
return {
id: value["id"],
name: value["name"],
slug: value["slug"],
};
}
Loading

0 comments on commit 0e49b1c

Please sign in to comment.