Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contract types for API v7 #57

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/release/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const MAX_CONCURRENT_REQUESTS = 5;
export interface Request {
/**
* An instance of PineJS, appropriately authenticated and configured for the
* API server to use. The compatible API versions are v5 and v6, so make sure to
* API server to use. The only compatible API version is v7, so make sure to
* configure `apiPrefix` appropriately.
*
* ```
* import Pine from 'pinejs-client-fetch';
* const client = new Pine({
* apiPrefix: 'https://api.balena-cloud.com/v6',
* apiPrefix: 'https://api.balena-cloud.com/v7',
* passthrough: {
* headers: {
* Authorization: `Bearer ${authToken}`,
Expand Down Expand Up @@ -67,8 +67,8 @@ export interface Request {
*/
semver?: string;

/** 'balena.yml' contract contents (stringified JSON) */
contract?: string;
/** 'balena.yml' contract contents */
contract?: models.JsonType;
}

export interface Response {
Expand All @@ -79,7 +79,7 @@ export interface Response {
/**
* This is the entry point for deploying a docker-compose.yml to devices.
*/
export async function create(req: Request): Promise<Response> {
export async function create(req: Request) {
const api = req.client;

// Ensure that the user and app exist and the user has access to them.
Expand Down Expand Up @@ -222,7 +222,7 @@ async function getOrCreateService(
async function createRelease(
api: PinejsClientCore<unknown>,
body: models.ReleaseAttributes,
): Promise<models.ReleaseModel> {
) {
return (await api
.post({
resource: 'release',
Expand Down
10 changes: 8 additions & 2 deletions lib/release/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import * as errors from './errors';

// These interfaces declare all model attributes except relations.

interface AnyObject {
[index: string]: any;
}

export type JsonType = AnyObject;

interface ServiceAttributesBase {
service_name: string;
}
Expand All @@ -15,7 +21,7 @@ interface ReleaseAttributesBase {
source: string;
start_timestamp: Date;
end_timestamp?: Date;
contract?: string;
contract?: JsonType;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand All @@ -27,7 +33,7 @@ interface ImageAttributesBase {
start_timestamp: Date;
end_timestamp?: Date;
dockerfile?: string;
image_size?: number;
image_size?: string;
project_type?: string;
error_message?: string;
build_log?: string;
Expand Down
Loading