New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

testing-farm

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testing-farm - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

8

dist/index.d.ts

@@ -1,5 +0,11 @@

export type {} from './schema';
import type { About, Composes, NewRequest, NewRequestResponse, Ranch, Request } from './schema';
export type { Ranch, NewRequest, NewRequestResponse, Request, Composes, About };
export default class TestingFarmAPI {
private readonly link;
constructor(instance: string);
newRequest(request: NewRequest): Promise<NewRequestResponse>;
requestDetails(requestId: string): Promise<Request>;
composes(): Promise<Composes>;
ranchComposes(ranch: Ranch): Promise<Composes>;
about(): Promise<About>;
}

@@ -1,4 +0,3 @@

// import type {} from './schema';
import { PublicLink } from './link';
import { urlSchema } from './schema';
import { composesSchema, aboutSchema, urlSchema, ranchSchema, newRequestResponseSchema, newRequestSchema, requestIdSchema, requestSchema, } from './schema';
export default class TestingFarmAPI {

@@ -8,3 +7,21 @@ constructor(instance) {

}
async newRequest(request) {
const data = newRequestSchema.parse(request);
return this.link.post('requests', newRequestResponseSchema, data);
}
async requestDetails(requestId) {
const data = requestIdSchema.parse(requestId);
return this.link.get('requests', requestSchema, data);
}
async composes() {
return this.link.get('composes', composesSchema);
}
async ranchComposes(ranch) {
const requestedRanch = ranchSchema.parse(ranch);
return this.link.get(`composes/${requestedRanch}`, composesSchema);
}
async about() {
return this.link.get('about', aboutSchema);
}
}
//# sourceMappingURL=index.js.map

4

dist/link.d.ts

@@ -15,4 +15,4 @@ /// <reference types="node" />

protected buildURL(path: string): URL;
get<TSchema extends ZodSchema, KValues extends z.infer<TSchema>>(path: string, schema: TSchema): Promise<KValues>;
post<R, TSchema extends ZodSchema, KValues extends z.infer<TSchema>>(path: string, schema: TSchema, content: R): Promise<KValues>;
get<TSchema extends ZodSchema, KValues extends z.infer<TSchema>, D>(path: string, schema: TSchema, data?: D): Promise<KValues>;
post<R, TSchema extends ZodSchema, KValues extends z.infer<TSchema>>(path: string, schema: TSchema, data: R): Promise<KValues>;
}

@@ -19,0 +19,0 @@ export declare class PublicLink extends TestingFarmLink {

@@ -40,12 +40,20 @@ import { URL } from 'url';

}
async get(path, schema) {
return this.request({
async get(path, schema, data) {
const config = {
url: this.buildURL(path).toString(),
}, schema);
method: 'GET',
};
if (data) {
config.data = data;
config.headers = {
'Content-Type': 'application/json',
};
}
return this.request(config, schema);
}
async post(path, schema, content) {
async post(path, schema, data) {
return this.request({
url: this.buildURL(path).toString(),
method: 'POST',
data: JSON.stringify(content),
data: JSON.stringify(data),
headers: {

@@ -52,0 +60,0 @@ 'Content-Type': 'application/json',

import { z } from 'zod';
export declare const urlSchema: z.ZodString;
export declare const requestIdSchema: z.ZodString;
export declare const newRequestSchema: z.ZodObject<{
api_key: z.ZodString;
test: z.ZodObject<{
fmf: z.ZodOptional<z.ZodObject<{
url: z.ZodString;
ref: z.ZodOptional<z.ZodString>;
merge_sha: z.ZodOptional<z.ZodString>;
path: z.ZodOptional<z.ZodString>;
name: z.ZodOptional<z.ZodString>;
settings: z.ZodOptional<z.ZodObject<{
'recognize-errors': z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
'recognize-errors': boolean;
}, {
'recognize-errors': boolean;
}>>;
}, "strip", z.ZodTypeAny, {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
}, {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
}>>;
sti: z.ZodOptional<z.ZodObject<{
url: z.ZodString;
ref: z.ZodString;
merge_sha: z.ZodOptional<z.ZodString>;
playbooks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
extra_variables: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
}, {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
fmf?: {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
} | undefined;
sti?: {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
} | undefined;
}, {
fmf?: {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
} | undefined;
sti?: {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
} | undefined;
}>;
environments: z.ZodOptional<z.ZodArray<z.ZodObject<{
arch: z.ZodString;
os: z.ZodOptional<z.ZodObject<{
compose: z.ZodString;
}, "strip", z.ZodTypeAny, {
compose: string;
}, {
compose: string;
}>>;
pool: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
secrets: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
type: z.ZodString;
packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
packages?: string[] | undefined;
}, {
type: string;
id: string;
packages?: string[] | undefined;
}>, "many">>;
hardware: z.ZodOptional<z.ZodObject<{
hostname: z.ZodString;
disk: z.ZodObject<{
size: z.ZodString;
}, "strip", z.ZodTypeAny, {
size: string;
}, {
size: string;
}>;
}, "strip", z.ZodTypeAny, {
hostname: string;
disk: {
size: string;
};
}, {
hostname: string;
disk: {
size: string;
};
}>>;
settings: z.ZodOptional<z.ZodObject<{
pipeline: z.ZodOptional<z.ZodObject<{
skip_guest_setup: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
skip_guest_setup?: boolean | undefined;
}, {
skip_guest_setup?: boolean | undefined;
}>>;
provisioning: z.ZodOptional<z.ZodObject<{
post_install_script: z.ZodOptional<z.ZodString>;
tags: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
post_install_script?: string | undefined;
tags?: {} | undefined;
}, {
post_install_script?: string | undefined;
tags?: {} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
}, {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
}>>;
tmt: z.ZodOptional<z.ZodObject<{
context: z.ZodOptional<z.ZodObject<{
distro: z.ZodString;
arch: z.ZodString;
trigger: z.ZodString;
}, "strip", z.ZodTypeAny, {
arch: string;
distro: string;
trigger: string;
}, {
arch: string;
distro: string;
trigger: string;
}>>;
}, "strip", z.ZodTypeAny, {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
}, {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
arch: string;
os?: {
compose: string;
} | undefined;
pool?: string | undefined;
variables?: {} | undefined;
secrets?: {} | undefined;
artifacts?: {
type: string;
id: string;
packages?: string[] | undefined;
}[] | undefined;
hardware?: {
hostname: string;
disk: {
size: string;
};
} | undefined;
settings?: {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
} | undefined;
tmt?: {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
} | undefined;
}, {
arch: string;
os?: {
compose: string;
} | undefined;
pool?: string | undefined;
variables?: {} | undefined;
secrets?: {} | undefined;
artifacts?: {
type: string;
id: string;
packages?: string[] | undefined;
}[] | undefined;
hardware?: {
hostname: string;
disk: {
size: string;
};
} | undefined;
settings?: {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
} | undefined;
tmt?: {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
} | undefined;
}>, "many">>;
notification: z.ZodOptional<z.ZodObject<{
webhook: z.ZodOptional<z.ZodObject<{
url: z.ZodString;
token: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
url: string;
token?: string | undefined;
}, {
url: string;
token?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
webhook?: {
url: string;
token?: string | undefined;
} | undefined;
}, {
webhook?: {
url: string;
token?: string | undefined;
} | undefined;
}>>;
settings: z.ZodOptional<z.ZodObject<{
worker: z.ZodOptional<z.ZodObject<{
image: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
image?: string | undefined;
}, {
image?: string | undefined;
}>>;
pipeline: z.ZodOptional<z.ZodObject<{
timeout: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
timeout?: number | undefined;
}, {
timeout?: number | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
worker?: {
image?: string | undefined;
} | undefined;
pipeline?: {
timeout?: number | undefined;
} | undefined;
}, {
worker?: {
image?: string | undefined;
} | undefined;
pipeline?: {
timeout?: number | undefined;
} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
api_key: string;
test: {
fmf?: {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
} | undefined;
sti?: {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
} | undefined;
};
environments?: {
arch: string;
os?: {
compose: string;
} | undefined;
pool?: string | undefined;
variables?: {} | undefined;
secrets?: {} | undefined;
artifacts?: {
type: string;
id: string;
packages?: string[] | undefined;
}[] | undefined;
hardware?: {
hostname: string;
disk: {
size: string;
};
} | undefined;
settings?: {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
} | undefined;
tmt?: {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
} | undefined;
}[] | undefined;
notification?: {
webhook?: {
url: string;
token?: string | undefined;
} | undefined;
} | undefined;
settings?: {
worker?: {
image?: string | undefined;
} | undefined;
pipeline?: {
timeout?: number | undefined;
} | undefined;
} | undefined;
}, {
api_key: string;
test: {
fmf?: {
url: string;
ref?: string | undefined;
merge_sha?: string | undefined;
path?: string | undefined;
name?: string | undefined;
settings?: {
'recognize-errors': boolean;
} | undefined;
} | undefined;
sti?: {
url: string;
ref: string;
merge_sha?: string | undefined;
playbooks?: string[] | undefined;
extra_variables?: {} | undefined;
} | undefined;
};
environments?: {
arch: string;
os?: {
compose: string;
} | undefined;
pool?: string | undefined;
variables?: {} | undefined;
secrets?: {} | undefined;
artifacts?: {
type: string;
id: string;
packages?: string[] | undefined;
}[] | undefined;
hardware?: {
hostname: string;
disk: {
size: string;
};
} | undefined;
settings?: {
pipeline?: {
skip_guest_setup?: boolean | undefined;
} | undefined;
provisioning?: {
post_install_script?: string | undefined;
tags?: {} | undefined;
} | undefined;
} | undefined;
tmt?: {
context?: {
arch: string;
distro: string;
trigger: string;
} | undefined;
} | undefined;
}[] | undefined;
notification?: {
webhook?: {
url: string;
token?: string | undefined;
} | undefined;
} | undefined;
settings?: {
worker?: {
image?: string | undefined;
} | undefined;
pipeline?: {
timeout?: number | undefined;
} | undefined;
} | undefined;
}>;
export type NewRequest = z.infer<typeof newRequestSchema>;
export declare const newRequestResponseSchema: z.ZodObject<{
id: z.ZodString;
created: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
created: string;
}, {
id: string;
created: string;
}>;
export type NewRequestResponse = z.infer<typeof newRequestResponseSchema>;
export declare const requestSchema: z.ZodObject<{
id: z.ZodString;
created: z.ZodString;
updated: z.ZodString;
environments: z.ZodArray<z.ZodObject<{
arch: z.ZodString;
os: z.ZodObject<{
compose: z.ZodString;
}, "strip", z.ZodTypeAny, {
compose: string;
}, {
compose: string;
}>;
pool: z.ZodString;
variables: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
}, "strip", z.ZodTypeAny, {
arch: string;
os: {
compose: string;
};
pool: string;
variables: {};
}, {
arch: string;
os: {
compose: string;
};
pool: string;
variables: {};
}>, "many">;
state: z.ZodString;
notes: z.ZodArray<z.ZodObject<{
level: z.ZodString;
message: z.ZodString;
}, "strip", z.ZodTypeAny, {
message: string;
level: string;
}, {
message: string;
level: string;
}>, "many">;
result: z.ZodObject<{
summary: z.ZodString;
overall: z.ZodString;
xunit: z.ZodString;
}, "strip", z.ZodTypeAny, {
summary: string;
overall: string;
xunit: string;
}, {
summary: string;
overall: string;
xunit: string;
}>;
run: z.ZodObject<{
console: z.ZodString;
stages: z.ZodArray<z.ZodObject<{
name: z.ZodString;
notes: z.ZodArray<z.ZodObject<{
level: z.ZodString;
message: z.ZodString;
}, "strip", z.ZodTypeAny, {
message: string;
level: string;
}, {
message: string;
level: string;
}>, "many">;
result: z.ZodString;
log: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}, {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}>, "many">;
artifacts: z.ZodString;
}, "strip", z.ZodTypeAny, {
artifacts: string;
console: string;
stages: {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}[];
}, {
artifacts: string;
console: string;
stages: {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}[];
}>;
}, "strip", z.ZodTypeAny, {
id: string;
environments: {
arch: string;
os: {
compose: string;
};
pool: string;
variables: {};
}[];
created: string;
updated: string;
state: string;
notes: {
message: string;
level: string;
}[];
result: {
summary: string;
overall: string;
xunit: string;
};
run: {
artifacts: string;
console: string;
stages: {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}[];
};
}, {
id: string;
environments: {
arch: string;
os: {
compose: string;
};
pool: string;
variables: {};
}[];
created: string;
updated: string;
state: string;
notes: {
message: string;
level: string;
}[];
result: {
summary: string;
overall: string;
xunit: string;
};
run: {
artifacts: string;
console: string;
stages: {
name: string;
notes: {
message: string;
level: string;
}[];
result: string;
log: string;
}[];
};
}>;
export type Request = z.infer<typeof requestSchema>;
export declare const ranchSchema: z.ZodUnion<[z.ZodLiteral<"public">, z.ZodLiteral<"redhat">]>;
export type Ranch = z.infer<typeof ranchSchema>;
export declare const composeSchema: z.ZodObject<{
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>;
export type Compose = z.infer<typeof composeSchema>;
export declare const composesSchema: z.ZodObject<{
composes: z.ZodArray<z.ZodObject<{
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
composes: {
name: string;
}[];
}, {
composes: {
name: string;
}[];
}>;
export type Composes = z.infer<typeof composesSchema>;
export declare const aboutSchema: z.ZodObject<{
api_version: z.ZodString;
}, "strip", z.ZodTypeAny, {
api_version: string;
}, {
api_version: string;
}>;
export type About = z.infer<typeof aboutSchema>;
import { z } from 'zod';
export const urlSchema = z.string().url();
export const requestIdSchema = z.string();
const testObjectSchema = z.object({
fmf: z
.object({
url: urlSchema,
ref: z.string().min(1).optional(),
merge_sha: z.string().min(1).optional(),
path: z.string().min(1).optional(),
name: z.string().min(1).optional(),
settings: z
.object({
'recognize-errors': z.boolean(),
})
.optional(),
})
.optional(),
sti: z
.object({
url: urlSchema,
ref: z.string().min(1),
merge_sha: z.string().min(1).optional(),
playbooks: z.array(z.string().min(1)).optional(),
extra_variables: z
.object({
// [key: string]: string;
})
.optional(),
})
.optional(),
});
const environmentSchema = z.object({
arch: z.string().min(1),
os: z
.object({
compose: z.string().min(1),
})
.optional(),
pool: z.string().min(1).optional(),
variables: z
.object({
// [key: string]: string;
})
.optional(),
secrets: z
.object({
// [key: string]: string;
})
.optional(),
artifacts: z
.array(z.object({
id: z.string().min(1),
type: z.string().min(1),
packages: z.array(z.string().min(1)).optional(),
}))
.optional(),
hardware: z
.object({
hostname: z.string().min(1),
disk: z.object({
size: z.string().min(1),
}),
})
.optional(),
settings: z
.object({
pipeline: z
.object({
skip_guest_setup: z.boolean().optional(),
})
.optional(),
provisioning: z
.object({
post_install_script: z.string().min(1).optional(),
tags: z
.object({
// [key: string]: string;
})
.optional(),
})
.optional(),
})
.optional(),
tmt: z
.object({
context: z
.object({
distro: z.string().min(1),
arch: z.string().min(1),
trigger: z.string().min(1),
})
.optional(),
})
.optional(),
});
const notificationSchema = z.object({
webhook: z
.object({
url: urlSchema,
token: z.string().min(1).optional(),
})
.optional(),
});
const settingsSchema = z.object({
worker: z
.object({
image: z.string().min(1).optional(),
})
.optional(),
pipeline: z
.object({
timeout: z.number().min(1).optional(),
})
.optional(),
});
export const newRequestSchema = z.object({
api_key: z.string().min(1),
test: testObjectSchema,
environments: z.array(environmentSchema).optional(),
notification: notificationSchema.optional(),
settings: settingsSchema.optional(),
});
export const newRequestResponseSchema = z.object({
id: requestIdSchema,
created: z.string().datetime(),
});
const noteSchema = z.object({
level: z.string(),
message: z.string(),
});
export const requestSchema = z.object({
id: requestIdSchema,
created: z.string(),
updated: z.string(),
environments: z.array(z.object({
arch: z.string(),
os: z.object({
compose: z.string(),
}),
pool: z.string(),
variables: z.object({
// [key: string]: string
}),
})),
state: z.string(),
notes: z.array(noteSchema),
result: z.object({
summary: z.string(),
overall: z.string(),
xunit: z.string(),
}),
run: z.object({
console: urlSchema,
stages: z.array(z.object({
name: z.string(),
notes: z.array(noteSchema),
result: z.string(),
log: urlSchema,
})),
artifacts: urlSchema,
}),
});
export const ranchSchema = z.union([z.literal('public'), z.literal('redhat')]);
export const composeSchema = z.object({
name: z.string(),
});
export const composesSchema = z.object({
composes: z.array(composeSchema),
});
export const aboutSchema = z.object({
api_version: z.string(),
});
//# sourceMappingURL=schema.js.map
{
"name": "testing-farm",
"version": "0.1.0",
"version": "1.0.0",
"description": "A NodeJS module to access Testing Farm instances through the REST API.",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/jamacku/testing-farm.git"
"url": "git+https://github.com/redhat-plumbers-in-action/testing-farm.git"
},

@@ -29,5 +29,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/jamacku/testing-farm/issues"
"url": "https://github.com/redhat-plumbers-in-action/testing-farm/issues"
},
"homepage": "https://github.com/jamacku/testing-farm#readme",
"homepage": "https://github.com/redhat-plumbers-in-action/testing-farm#readme",
"devDependencies": {

@@ -34,0 +34,0 @@ "@types/node": "18.15.0",

@@ -1,1 +0,56 @@

# testing-farm
# Testing Farm
Typesafe access to [Testing Farm's REST API](https://testing-farm.gitlab.io/api/).
## API
### Creating the API instance
```typescript
import TestingFarmAPI from "testing-farm";
const api = new TestingFarmAPI("https://api.dev.testing-farm.io/v0.1");
await api.about();
```
### Request a New Test
documentation of - [`POST /requests`](https://testing-farm.gitlab.io/api/#operation/requestsPost)
```typescript
const request = { /* https://testing-farm.gitlab.io/api/#operation/requestsPost */ }
const response = await api.newRequest(request);
```
### Test Request Details
documentation of - [`GET /requests`](https://testing-farm.gitlab.io/api/#operation/requestsGet)
```typescript
const details = await api.requestDetails('test-id');
```
### Composes Public Ranch
documentation of - [`GET /composes`](https://testing-farm.gitlab.io/api/#operation/composesGetPublic)
```typescript
const composes = await api.composes();
```
### Composes
documentation of - [`GET /composes/{ranch}`](https://testing-farm.gitlab.io/api/#operation/composesGet)
```typescript
const composes = await api.ranchComposes('public');
```
### About Testing Farm
documentation of - [`GET /about`](https://testing-farm.gitlab.io/api/#operation/aboutGet)
```typescript
const about = await api.about();
```

@@ -1,7 +0,22 @@

// import type {} from './schema';
import { PublicLink } from './link';
import { urlSchema } from './schema';
import type {
About,
Composes,
NewRequest,
NewRequestResponse,
Ranch,
Request,
} from './schema';
import {
composesSchema,
aboutSchema,
urlSchema,
ranchSchema,
newRequestResponseSchema,
newRequestSchema,
requestIdSchema,
requestSchema,
} from './schema';
export type {} from './schema';
export type { Ranch, NewRequest, NewRequestResponse, Request, Composes, About };

@@ -15,21 +30,24 @@ export default class TestingFarmAPI {

// newRequest(data: NewRequest): Promise<Request> {
// return this.link.post('requests', data);
// }
async newRequest(request: NewRequest): Promise<NewRequestResponse> {
const data = newRequestSchema.parse(request);
return this.link.post('requests', newRequestResponseSchema, data);
}
// requestDetails(requestId: string): Promise<Request> {
// return this.link.get('requests', requestId);
// }
async requestDetails(requestId: string): Promise<Request> {
const data = requestIdSchema.parse(requestId);
return this.link.get('requests', requestSchema, data);
}
// composes(): Promise<Compose[]> {
// return this.link.get('composes');
// }
async composes(): Promise<Composes> {
return this.link.get('composes', composesSchema);
}
// ranchComposes(ranch: unknown): Promise<Compose[]> {
// return this.link.get('composes', data);
// }
async ranchComposes(ranch: Ranch): Promise<Composes> {
const requestedRanch = ranchSchema.parse(ranch);
return this.link.get(`composes/${requestedRanch}`, composesSchema);
}
// about(): Promise<About> {
// return this.link.get('about');
// }
async about(): Promise<About> {
return this.link.get('about', aboutSchema);
}
}

@@ -67,12 +67,20 @@ import { URL } from 'url';

async get<TSchema extends ZodSchema, KValues extends z.infer<TSchema>>(
async get<TSchema extends ZodSchema, KValues extends z.infer<TSchema>, D>(
path: string,
schema: TSchema
schema: TSchema,
data?: D
): Promise<KValues> {
return this.request(
{
url: this.buildURL(path).toString(),
},
schema
);
const config: AxiosRequestConfig<D> = {
url: this.buildURL(path).toString(),
method: 'GET',
};
if (data) {
config.data = data;
config.headers = {
'Content-Type': 'application/json',
};
}
return this.request(config, schema);
}

@@ -83,3 +91,3 @@

schema: TSchema,
content: R
data: R
): Promise<KValues> {

@@ -90,3 +98,3 @@ return this.request(

method: 'POST',
data: JSON.stringify(content),
data: JSON.stringify(data),
headers: {

@@ -93,0 +101,0 @@ 'Content-Type': 'application/json',

import { z } from 'zod';
export const urlSchema = z.string().url();
export const requestIdSchema = z.string();
const testObjectSchema = z.object({
fmf: z
.object({
url: urlSchema,
ref: z.string().min(1).optional(),
merge_sha: z.string().min(1).optional(),
path: z.string().min(1).optional(),
name: z.string().min(1).optional(),
settings: z
.object({
'recognize-errors': z.boolean(),
})
.optional(),
})
.optional(),
sti: z
.object({
url: urlSchema,
ref: z.string().min(1),
merge_sha: z.string().min(1).optional(),
playbooks: z.array(z.string().min(1)).optional(),
extra_variables: z
.object({
// [key: string]: string;
})
.optional(),
})
.optional(),
});
const environmentSchema = z.object({
arch: z.string().min(1),
os: z
.object({
compose: z.string().min(1),
})
.optional(),
pool: z.string().min(1).optional(),
variables: z
.object({
// [key: string]: string;
})
.optional(),
secrets: z
.object({
// [key: string]: string;
})
.optional(),
artifacts: z
.array(
z.object({
id: z.string().min(1),
type: z.string().min(1),
packages: z.array(z.string().min(1)).optional(),
})
)
.optional(),
hardware: z
.object({
hostname: z.string().min(1),
disk: z.object({
size: z.string().min(1),
}),
})
.optional(),
settings: z
.object({
pipeline: z
.object({
skip_guest_setup: z.boolean().optional(),
})
.optional(),
provisioning: z
.object({
post_install_script: z.string().min(1).optional(),
tags: z
.object({
// [key: string]: string;
})
.optional(),
})
.optional(),
})
.optional(),
tmt: z
.object({
context: z
.object({
distro: z.string().min(1),
arch: z.string().min(1),
trigger: z.string().min(1),
})
.optional(),
})
.optional(),
});
const notificationSchema = z.object({
webhook: z
.object({
url: urlSchema,
token: z.string().min(1).optional(),
})
.optional(),
});
const settingsSchema = z.object({
worker: z
.object({
image: z.string().min(1).optional(),
})
.optional(),
pipeline: z
.object({
timeout: z.number().min(1).optional(),
})
.optional(),
});
export const newRequestSchema = z.object({
api_key: z.string().min(1),
test: testObjectSchema,
environments: z.array(environmentSchema).optional(),
notification: notificationSchema.optional(),
settings: settingsSchema.optional(),
});
export type NewRequest = z.infer<typeof newRequestSchema>;
export const newRequestResponseSchema = z.object({
id: requestIdSchema,
created: z.string().datetime(),
});
export type NewRequestResponse = z.infer<typeof newRequestResponseSchema>;
const noteSchema = z.object({
level: z.string(),
message: z.string(),
});
export const requestSchema = z.object({
id: requestIdSchema,
created: z.string(),
updated: z.string(),
environments: z.array(
z.object({
arch: z.string(),
os: z.object({
compose: z.string(),
}),
pool: z.string(),
variables: z.object({
// [key: string]: string
}),
})
),
state: z.string(),
notes: z.array(noteSchema),
result: z.object({
summary: z.string(),
overall: z.string(),
xunit: z.string(),
}),
run: z.object({
console: urlSchema,
stages: z.array(
z.object({
name: z.string(),
notes: z.array(noteSchema),
result: z.string(),
log: urlSchema,
})
),
artifacts: urlSchema,
}),
});
export type Request = z.infer<typeof requestSchema>;
export const ranchSchema = z.union([z.literal('public'), z.literal('redhat')]);
export type Ranch = z.infer<typeof ranchSchema>;
export const composeSchema = z.object({
name: z.string(),
});
export type Compose = z.infer<typeof composeSchema>;
export const composesSchema = z.object({
composes: z.array(composeSchema),
});
export type Composes = z.infer<typeof composesSchema>;
export const aboutSchema = z.object({
api_version: z.string(),
});
export type About = z.infer<typeof aboutSchema>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc