diff --git a/src/api/types.ts b/src/api/types.ts index 96df877..5853059 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -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; @@ -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]: { @@ -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; } @@ -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; @@ -313,6 +336,8 @@ export interface Module { export interface CreateModuleInput { name: string; + programmingLanguage?: "JAVASCRIPT" | "PYTHON"; + sourceCode?: string; script?: { programmingLanguage?: string; sourceCode?: string; @@ -321,6 +346,7 @@ export interface CreateModuleInput { export interface UpdateModuleInput { name?: string; + sourceCode?: string; script?: { programmingLanguage?: string; sourceCode?: string; @@ -349,6 +375,10 @@ export interface VersionedModule { export interface PublishModuleInput { tag: string; comment?: string; + sourceCode?: string; + script?: { + sourceCode?: string; + }; } export interface VersionedModulesPaginatedResult { @@ -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[]; +} diff --git a/src/api/yepcodeApi.ts b/src/api/yepcodeApi.ts index 10b2064..3b6074d 100644 --- a/src/api/yepcodeApi.ts +++ b/src/api/yepcodeApi.ts @@ -33,6 +33,10 @@ import { VersionedModuleAliasesPaginatedResult, StorageObject, CreateStorageObjectInput, + Token, + ServiceAccountInput, + ServiceAccount, + ServiceAccountsListResult, } from "./types"; import { Readable } from "stream"; @@ -343,6 +347,23 @@ export class YepCodeApi { return this.request("POST", `/processes/${processId}/versions`, { data }); } + async getProcessVersion( + processId: string, + versionId: string + ): Promise { + return this.request("GET", `/processes/${processId}/versions/${versionId}`); + } + + async deleteProcessVersion( + processId: string, + versionId: string + ): Promise { + return this.request( + "DELETE", + `/processes/${processId}/versions/${versionId}` + ); + } + async getProcessVersionAliases( processId: string, params: { @@ -361,6 +382,30 @@ export class YepCodeApi { return this.request("POST", `/processes/${processId}/aliases`, { data }); } + async getProcessVersionAlias( + processId: string, + aliasId: string + ): Promise { + return this.request("GET", `/processes/${processId}/aliases/${aliasId}`); + } + + async updateProcessVersionAlias( + processId: string, + aliasId: string, + data: VersionedProcessAliasInput + ): Promise { + return this.request("PATCH", `/processes/${processId}/aliases/${aliasId}`, { + data, + }); + } + + async deleteProcessVersionAlias( + processId: string, + aliasId: string + ): Promise { + return this.request("DELETE", `/processes/${processId}/aliases/${aliasId}`); + } + async getProcesses( params: { keywords?: string; @@ -439,6 +484,8 @@ export class YepCodeApi { processId?: string; status?: | "CREATED" + | "QUEUED" + | "DEQUEUED" | "RUNNING" | "FINISHED" | "KILLED" @@ -509,6 +556,13 @@ export class YepCodeApi { return this.request("PUT", `/schedules/${id}/resume`); } + async updateSchedule( + id: string, + data: ScheduledProcessInput + ): Promise { + return this.request("PATCH", `/schedules/${id}`, { data }); + } + async getVariables( params: { page?: number; @@ -580,6 +634,20 @@ export class YepCodeApi { return this.request("POST", `/modules/${moduleId}/versions`, { data }); } + async getModuleVersion( + moduleId: string, + versionId: string + ): Promise { + return this.request("GET", `/modules/${moduleId}/versions/${versionId}`); + } + + async deleteModuleVersion( + moduleId: string, + versionId: string + ): Promise { + return this.request("DELETE", `/modules/${moduleId}/versions/${versionId}`); + } + async getModuleVersionAliases( moduleId: string, params: { @@ -598,14 +666,36 @@ export class YepCodeApi { return this.request("POST", `/modules/${moduleId}/aliases`, { data }); } - async getObjects( - params: { prefix?: string } = {} - ): Promise { + async getModuleVersionAlias( + moduleId: string, + aliasId: string + ): Promise { + return this.request("GET", `/modules/${moduleId}/aliases/${aliasId}`); + } + + async updateModuleVersionAlias( + moduleId: string, + aliasId: string, + data: VersionedModuleAliasInput + ): Promise { + return this.request("PATCH", `/modules/${moduleId}/aliases/${aliasId}`, { + data, + }); + } + + async deleteModuleVersionAlias( + moduleId: string, + aliasId: string + ): Promise { + return this.request("DELETE", `/modules/${moduleId}/aliases/${aliasId}`); + } + + async getObjects(params: { prefix?: string } = {}): Promise { return this.request("GET", "/storage/objects", { params }); } - async getObject(name: string): Promise { - return this.request("GET", `/storage/objects/${name}`, { + async getObject(filename: string): Promise { + return this.request("GET", `/storage/objects/${filename}`, { responseType: "stream", }); } @@ -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 { + async deleteObject(filename: string): Promise { return this.request( "DELETE", - `/storage/objects/${encodeURIComponent(name)}` + `/storage/objects/${encodeURIComponent(filename)}` ); } + + // Auth endpoints + async getToken(apiToken: string): Promise { + return this.request("POST", "/auth/token", { + headers: { + "x-api-token": apiToken, + }, + }); + } + + async getAllServiceAccounts(): Promise { + return this.request("GET", "/auth/service-accounts"); + } + + async createServiceAccount( + data: ServiceAccountInput + ): Promise { + return this.request("POST", "/auth/service-accounts", { data }); + } + + async deleteServiceAccount(id: string): Promise { + return this.request("DELETE", `/auth/service-accounts/${id}`); + } } diff --git a/src/types/index.ts b/src/types/index.ts index 7c68c7c..895f8cc 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -43,6 +43,8 @@ export interface ExecutionData { export type ExecutionStatus = | "CREATED" + | "QUEUED" + | "DEQUEUED" | "RUNNING" | "FINISHED" | "KILLED"