Skip to content
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
68 changes: 63 additions & 5 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ export interface YepCodeApiConfig {

export interface CreateProcessInput {
name: string;
slug?: string;
description?: string;
readme?: string;
programmingLanguage?: "JAVASCRIPT" | "PYTHON";
sourceCode?: string;
parametersSchema?: string;
webhook?: WebhookInput;
manifest?: ProcessManifestInput;
settings?: SettingsInput;
script?: CreateScriptInput;
Expand Down Expand Up @@ -51,7 +56,15 @@ export interface Execution {
id: string;
processId: string;
scheduledId?: string;
status: "CREATED" | "RUNNING" | "FINISHED" | "KILLED" | "REJECTED" | "ERROR";
status:
| "CREATED"
| "QUEUED"
| "DEQUEUED"
| "RUNNING"
| "FINISHED"
| "KILLED"
| "REJECTED"
| "ERROR";
timeline?: ExecutionTimeline;
parameters?: {
[name: string]: {
Expand Down Expand Up @@ -85,7 +98,15 @@ export interface ExecutionTimeline {
events?: ExecutionTimelineEvent[];
}
export interface ExecutionTimelineEvent {
status: "CREATED" | "RUNNING" | "FINISHED" | "KILLED" | "REJECTED" | "ERROR";
status:
| "CREATED"
| "QUEUED"
| "DEQUEUED"
| "RUNNING"
| "FINISHED"
| "KILLED"
| "REJECTED"
| "ERROR";
timestamp: string;
explanation?: string;
}
Expand Down Expand Up @@ -226,10 +247,12 @@ export interface TeamVariablesPaginatedResult {
data?: TeamVariable[];
}
export interface UpdateProcessInput {
name: string;
slug: string;
name?: string;
slug?: string;
description?: string;
readme?: string;
sourceCode?: string;
parametersSchema?: string;
script?: UpdateScriptInput;
webhook?: WebhookInput;
settings?: SettingsInput;
Expand Down Expand Up @@ -313,6 +336,8 @@ export interface Module {

export interface CreateModuleInput {
name: string;
programmingLanguage?: "JAVASCRIPT" | "PYTHON";
sourceCode?: string;
script?: {
programmingLanguage?: string;
sourceCode?: string;
Expand All @@ -321,6 +346,7 @@ export interface CreateModuleInput {

export interface UpdateModuleInput {
name?: string;
sourceCode?: string;
script?: {
programmingLanguage?: string;
sourceCode?: string;
Expand Down Expand Up @@ -349,6 +375,10 @@ export interface VersionedModule {
export interface PublishModuleInput {
tag: string;
comment?: string;
sourceCode?: string;
script?: {
sourceCode?: string;
};
}

export interface VersionedModulesPaginatedResult {
Expand Down Expand Up @@ -392,10 +422,38 @@ export type StorageObject = {
contentType: string;
createdAt: string;
updatedAt: string;
link: URL;
link: string;
};

export type CreateStorageObjectInput = {
name: string;
file: File | Blob | Readable;
};

/**
* Auth
*/
export interface Token {
access_token: string;
expires_in: number;
token_type: string;
scope?: string;
}

export interface ServiceAccountInput {
name: string;
}

export interface ServiceAccount {
id: string;
createdAt: string;
updatedAt: string;
name: string;
clientId: string;
clientSecret: string;
}

export interface ServiceAccountsListResult {
total: number;
data: ServiceAccount[];
}
129 changes: 121 additions & 8 deletions src/api/yepcodeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import {
VersionedModuleAliasesPaginatedResult,
StorageObject,
CreateStorageObjectInput,
Token,
ServiceAccountInput,
ServiceAccount,
ServiceAccountsListResult,
} from "./types";
import { Readable } from "stream";

Expand Down Expand Up @@ -343,6 +347,23 @@ export class YepCodeApi {
return this.request("POST", `/processes/${processId}/versions`, { data });
}

async getProcessVersion(
processId: string,
versionId: string
): Promise<VersionedProcess> {
return this.request("GET", `/processes/${processId}/versions/${versionId}`);
}

async deleteProcessVersion(
processId: string,
versionId: string
): Promise<void> {
return this.request(
"DELETE",
`/processes/${processId}/versions/${versionId}`
);
}

async getProcessVersionAliases(
processId: string,
params: {
Expand All @@ -361,6 +382,30 @@ export class YepCodeApi {
return this.request("POST", `/processes/${processId}/aliases`, { data });
}

async getProcessVersionAlias(
processId: string,
aliasId: string
): Promise<VersionedProcessAlias> {
return this.request("GET", `/processes/${processId}/aliases/${aliasId}`);
}

async updateProcessVersionAlias(
processId: string,
aliasId: string,
data: VersionedProcessAliasInput
): Promise<VersionedProcessAlias> {
return this.request("PATCH", `/processes/${processId}/aliases/${aliasId}`, {
data,
});
}

async deleteProcessVersionAlias(
processId: string,
aliasId: string
): Promise<void> {
return this.request("DELETE", `/processes/${processId}/aliases/${aliasId}`);
}

async getProcesses(
params: {
keywords?: string;
Expand Down Expand Up @@ -439,6 +484,8 @@ export class YepCodeApi {
processId?: string;
status?:
| "CREATED"
| "QUEUED"
| "DEQUEUED"
| "RUNNING"
| "FINISHED"
| "KILLED"
Expand Down Expand Up @@ -509,6 +556,13 @@ export class YepCodeApi {
return this.request("PUT", `/schedules/${id}/resume`);
}

async updateSchedule(
id: string,
data: ScheduledProcessInput
): Promise<Schedule> {
return this.request("PATCH", `/schedules/${id}`, { data });
}

async getVariables(
params: {
page?: number;
Expand Down Expand Up @@ -580,6 +634,20 @@ export class YepCodeApi {
return this.request("POST", `/modules/${moduleId}/versions`, { data });
}

async getModuleVersion(
moduleId: string,
versionId: string
): Promise<VersionedModule> {
return this.request("GET", `/modules/${moduleId}/versions/${versionId}`);
}

async deleteModuleVersion(
moduleId: string,
versionId: string
): Promise<void> {
return this.request("DELETE", `/modules/${moduleId}/versions/${versionId}`);
}

async getModuleVersionAliases(
moduleId: string,
params: {
Expand All @@ -598,14 +666,36 @@ export class YepCodeApi {
return this.request("POST", `/modules/${moduleId}/aliases`, { data });
}

async getObjects(
params: { prefix?: string } = {}
): Promise<StorageObject[]> {
async getModuleVersionAlias(
moduleId: string,
aliasId: string
): Promise<VersionedModuleAlias> {
return this.request("GET", `/modules/${moduleId}/aliases/${aliasId}`);
}

async updateModuleVersionAlias(
moduleId: string,
aliasId: string,
data: VersionedModuleAliasInput
): Promise<VersionedModuleAlias> {
return this.request("PATCH", `/modules/${moduleId}/aliases/${aliasId}`, {
data,
});
}

async deleteModuleVersionAlias(
moduleId: string,
aliasId: string
): Promise<void> {
return this.request("DELETE", `/modules/${moduleId}/aliases/${aliasId}`);
}

async getObjects(params: { prefix?: string } = {}): Promise<StorageObject[]> {
return this.request("GET", "/storage/objects", { params });
}

async getObject(name: string): Promise<Readable> {
return this.request("GET", `/storage/objects/${name}`, {
async getObject(filename: string): Promise<Readable> {
return this.request("GET", `/storage/objects/${filename}`, {
responseType: "stream",
});
}
Expand Down Expand Up @@ -642,15 +732,38 @@ export class YepCodeApi {

return this.request(
"POST",
`/storage/objects?name=${encodeURIComponent(data.name)}`,
`/storage/objects?filename=${encodeURIComponent(data.name)}`,
options
);
}

async deleteObject(name: string): Promise<void> {
async deleteObject(filename: string): Promise<void> {
return this.request(
"DELETE",
`/storage/objects/${encodeURIComponent(name)}`
`/storage/objects/${encodeURIComponent(filename)}`
);
}

// Auth endpoints
async getToken(apiToken: string): Promise<Token> {
return this.request("POST", "/auth/token", {
headers: {
"x-api-token": apiToken,
},
});
}

async getAllServiceAccounts(): Promise<ServiceAccountsListResult> {
return this.request("GET", "/auth/service-accounts");
}

async createServiceAccount(
data: ServiceAccountInput
): Promise<ServiceAccount> {
return this.request("POST", "/auth/service-accounts", { data });
}

async deleteServiceAccount(id: string): Promise<void> {
return this.request("DELETE", `/auth/service-accounts/${id}`);
}
}
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface ExecutionData {

export type ExecutionStatus =
| "CREATED"
| "QUEUED"
| "DEQUEUED"
| "RUNNING"
| "FINISHED"
| "KILLED"
Expand Down