@substrate/playground-client
Advanced tools
Comparing version 1.8.3 to 1.8.4
@@ -0,1 +1,4 @@ | ||
// Helper methods to get access to authentication tokens. Can then be used with `Client.login`. | ||
// See https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps | ||
// | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -2,0 +5,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
@@ -13,46 +13,46 @@ import { Playground, Pool, Workspace, WorkspaceConfiguration, WorkspaceUpdateConfiguration, User, UserConfiguration, UserUpdateConfiguration, Repository, RepositoryConfiguration, RepositoryUpdateConfiguration, RepositoryVersion, RepositoryVersionConfiguration, SessionConfiguration, Session, SessionUpdateConfiguration, Template } from './types'; | ||
private readonly base; | ||
private readonly timeout; | ||
private readonly defaultTimeout; | ||
private readonly defaultInit; | ||
constructor(base: string, timeout?: number, defaultInit?: RequestInit); | ||
login(bearer: string, init?: RequestInit): Promise<void>; | ||
logout(init?: RequestInit): Promise<void>; | ||
constructor(base: string, defaultTimeout?: number, defaultInit?: RequestInit); | ||
login(bearer: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
logout(timeout?: number, init?: RequestInit): Promise<void>; | ||
path(...resources: string[]): string; | ||
loginPath(queryParams?: string): string; | ||
get(init?: RequestInit): Promise<Playground>; | ||
getCurrentUser(init?: RequestInit): Promise<User>; | ||
getUser(id: User['id'], init?: RequestInit): Promise<User | null>; | ||
listUsers(init?: RequestInit): Promise<User[]>; | ||
createUser(id: User['id'], conf: UserConfiguration, init?: RequestInit): Promise<void>; | ||
updateUser(id: User['id'], conf: UserUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteUser(id: User['id'], init?: RequestInit): Promise<void>; | ||
getCurrentWorkspace(init?: RequestInit): Promise<Workspace | null>; | ||
createCurrentWorkspace(conf: WorkspaceConfiguration, init?: RequestInit): Promise<void>; | ||
updateCurrentWorkspace(conf: WorkspaceUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteCurrentWorkspace(init?: RequestInit): Promise<void>; | ||
getWorkspace(id: Workspace['id'], init?: RequestInit): Promise<Workspace | null>; | ||
listWorkspaces(init?: RequestInit): Promise<Workspace[]>; | ||
createWorkspace(id: Workspace['id'], conf: WorkspaceConfiguration, init?: RequestInit): Promise<void>; | ||
updateWorkspace(id: Workspace['id'], conf: WorkspaceUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteWorkspace(id: Workspace['id'], init?: RequestInit): Promise<void>; | ||
getCurrentSession(init?: RequestInit): Promise<Session | null>; | ||
createCurrentSession(conf: SessionConfiguration, init?: RequestInit): Promise<void>; | ||
updateCurrentSession(conf: SessionUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteCurrentSession(init?: RequestInit): Promise<void>; | ||
getSession(id: string, init?: RequestInit): Promise<Session | null>; | ||
listSessions(init?: RequestInit): Promise<Session[]>; | ||
createSession(id: string, conf: SessionConfiguration, init?: RequestInit): Promise<void>; | ||
updateSession(id: string, conf: SessionUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteSession(id: string, init?: RequestInit): Promise<void>; | ||
getRepository(id: Repository['id'], init?: RequestInit): Promise<Repository | null>; | ||
listRepositories(init?: RequestInit): Promise<Repository[]>; | ||
createRepository(id: Repository['id'], conf: RepositoryConfiguration, init?: RequestInit): Promise<void>; | ||
updateRepository(id: Repository['id'], conf: RepositoryUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteRepository(id: Repository['id'], init?: RequestInit): Promise<void>; | ||
getRepositoryVersion(id: Repository['id'], version: string, init?: RequestInit): Promise<RepositoryVersion | null>; | ||
listRepositoryVersions(id: Repository['id'], init?: RequestInit): Promise<RepositoryVersion[]>; | ||
createRepositoryVersion(id: Repository['id'], version: string, conf: RepositoryVersionConfiguration, init?: RequestInit): Promise<void>; | ||
deleteRepositoryVersion(id: Repository['id'], version: string, init?: RequestInit): Promise<void>; | ||
listTemplates(init?: RequestInit): Promise<Template[]>; | ||
getPool(id: Pool['id'], init?: RequestInit): Promise<Pool | null>; | ||
listPools(init?: RequestInit): Promise<Pool[]>; | ||
get(timeout?: number, init?: RequestInit): Promise<Playground>; | ||
getCurrentUser(timeout?: number, init?: RequestInit): Promise<User>; | ||
getUser(id: User['id'], timeout?: number, init?: RequestInit): Promise<User | null>; | ||
listUsers(timeout?: number, init?: RequestInit): Promise<User[]>; | ||
createUser(id: User['id'], conf: UserConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateUser(id: User['id'], conf: UserUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteUser(id: User['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getCurrentWorkspace(timeout?: number, init?: RequestInit): Promise<Workspace | null>; | ||
createCurrentWorkspace(conf: WorkspaceConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateCurrentWorkspace(conf: WorkspaceUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteCurrentWorkspace(timeout?: number, init?: RequestInit): Promise<void>; | ||
getWorkspace(id: Workspace['id'], timeout?: number, init?: RequestInit): Promise<Workspace | null>; | ||
listWorkspaces(timeout?: number, init?: RequestInit): Promise<Workspace[]>; | ||
createWorkspace(id: Workspace['id'], conf: WorkspaceConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateWorkspace(id: Workspace['id'], conf: WorkspaceUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteWorkspace(id: Workspace['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getCurrentSession(timeout?: number, init?: RequestInit): Promise<Session | null>; | ||
createCurrentSession(conf: SessionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateCurrentSession(conf: SessionUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteCurrentSession(timeout?: number, init?: RequestInit): Promise<void>; | ||
getSession(id: string, timeout?: number, init?: RequestInit): Promise<Session | null>; | ||
listSessions(timeout?: number, init?: RequestInit): Promise<Session[]>; | ||
createSession(id: string, conf: SessionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateSession(id: string, conf: SessionUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteSession(id: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
getRepository(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<Repository | null>; | ||
listRepositories(timeout?: number, init?: RequestInit): Promise<Repository[]>; | ||
createRepository(id: Repository['id'], conf: RepositoryConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateRepository(id: Repository['id'], conf: RepositoryUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteRepository(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getRepositoryVersion(id: Repository['id'], version: string, timeout?: number, init?: RequestInit): Promise<RepositoryVersion | null>; | ||
listRepositoryVersions(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<RepositoryVersion[]>; | ||
createRepositoryVersion(id: Repository['id'], version: string, conf: RepositoryVersionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteRepositoryVersion(id: Repository['id'], version: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
listTemplates(timeout?: number, init?: RequestInit): Promise<Template[]>; | ||
getPool(id: Pool['id'], timeout?: number, init?: RequestInit): Promise<Pool | null>; | ||
listPools(timeout?: number, init?: RequestInit): Promise<Pool[]>; | ||
} | ||
@@ -59,0 +59,0 @@ export * from "./auth"; |
@@ -12,27 +12,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export class Client { | ||
constructor(base, timeout = 10000, defaultInit) { | ||
constructor(base, defaultTimeout = 10000, defaultInit = {}) { | ||
this.base = base; | ||
this.defaultInit = defaultInit; | ||
this.timeout = timeout; | ||
this.defaultTimeout = defaultTimeout; | ||
} | ||
// Login | ||
login(bearer, init = this.defaultInit) { | ||
login(bearer, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetchWithTimeout(`${this.path('login')}?bearer=${bearer}`, init, this.timeout); | ||
const headers = this.defaultInit.headers || new Headers(); | ||
if (!(headers instanceof Headers)) { | ||
const response = yield fetchWithTimeout(`${this.path('login')}?bearer=${bearer}`, init, timeout); | ||
const headers = this.defaultInit.headers; | ||
if (headers instanceof Headers) { | ||
throw Error('Unsupported headers type'); | ||
} | ||
headers.set('cookie', response.headers.get('set-cookie')); | ||
this.defaultInit.headers = headers; | ||
this.defaultInit.headers = Object.assign({ cookie: response.headers.get('set-cookie') }, headers); | ||
}); | ||
} | ||
logout(init = this.defaultInit) { | ||
logout(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield fetchWithTimeout(this.path('logout'), init, this.timeout); | ||
const headers = this.defaultInit.headers || new Headers(); | ||
if (!(headers instanceof Headers)) { | ||
yield fetchWithTimeout(this.path('logout'), init, timeout); | ||
const headers = this.defaultInit.headers; | ||
if (headers instanceof Headers) { | ||
throw Error('Unsupported headers type'); | ||
} | ||
headers.delete('cookie'); | ||
delete headers['cookie']; | ||
this.defaultInit.headers = headers; | ||
@@ -47,194 +46,194 @@ }); | ||
} | ||
get(init = this.defaultInit) { | ||
get(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(""), init, this.timeout); | ||
return rpc(this.path(""), init, timeout); | ||
}); | ||
} | ||
// Current User | ||
getCurrentUser(init = this.defaultInit) { | ||
getCurrentUser(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.userResource), Object.assign({}, init), this.timeout); | ||
return rpc(this.path(Client.userResource), Object.assign({}, init), timeout); | ||
}); | ||
} | ||
// Users | ||
getUser(id, init = this.defaultInit) { | ||
getUser(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.usersResource, id), init, this.timeout); | ||
return rpc(this.path(Client.usersResource, id), init, timeout); | ||
}); | ||
} | ||
listUsers(init = this.defaultInit) { | ||
listUsers(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.usersResource), init, this.timeout); | ||
return rpc(this.path(Client.usersResource), init, timeout); | ||
}); | ||
} | ||
createUser(id, conf, init = this.defaultInit) { | ||
createUser(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateUser(id, conf, init = this.defaultInit) { | ||
updateUser(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteUser(id, init = this.defaultInit) { | ||
deleteUser(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.usersResource, id), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Current Workspace | ||
getCurrentWorkspace(init = this.defaultInit) { | ||
getCurrentWorkspace(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspaceResource), init, this.timeout); | ||
return rpc(this.path(Client.workspaceResource), init, timeout); | ||
}); | ||
} | ||
createCurrentWorkspace(conf, init = this.defaultInit) { | ||
createCurrentWorkspace(conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateCurrentWorkspace(conf, init = this.defaultInit) { | ||
updateCurrentWorkspace(conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteCurrentWorkspace(init = this.defaultInit) { | ||
deleteCurrentWorkspace(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.workspaceResource), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Workspaces | ||
getWorkspace(id, init = this.defaultInit) { | ||
getWorkspace(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspacesResource, id), init, this.timeout); | ||
return rpc(this.path(Client.workspacesResource, id), init, timeout); | ||
}); | ||
} | ||
listWorkspaces(init = this.defaultInit) { | ||
listWorkspaces(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspacesResource), init, this.timeout); | ||
return rpc(this.path(Client.workspacesResource), init, timeout); | ||
}); | ||
} | ||
createWorkspace(id, conf, init = this.defaultInit) { | ||
createWorkspace(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateWorkspace(id, conf, init = this.defaultInit) { | ||
updateWorkspace(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteWorkspace(id, init = this.defaultInit) { | ||
deleteWorkspace(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.workspacesResource, id), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Current Session | ||
getCurrentSession(init = this.defaultInit) { | ||
getCurrentSession(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionResource), init, this.timeout); | ||
return rpc(this.path(Client.sessionResource), init, timeout); | ||
}); | ||
} | ||
createCurrentSession(conf, init = this.defaultInit) { | ||
createCurrentSession(conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateCurrentSession(conf, init = this.defaultInit) { | ||
updateCurrentSession(conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteCurrentSession(init = this.defaultInit) { | ||
deleteCurrentSession(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.sessionResource), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Sessions | ||
getSession(id, init = this.defaultInit) { | ||
getSession(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionsResource, id), init, this.timeout); | ||
return rpc(this.path(Client.sessionsResource, id), init, timeout); | ||
}); | ||
} | ||
listSessions(init = this.defaultInit) { | ||
listSessions(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionsResource), init, this.timeout); | ||
return rpc(this.path(Client.sessionsResource), init, timeout); | ||
}); | ||
} | ||
createSession(id, conf, init = this.defaultInit) { | ||
createSession(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateSession(id, conf, init = this.defaultInit) { | ||
updateSession(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteSession(id, init = this.defaultInit) { | ||
deleteSession(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.sessionsResource, id), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Repositories | ||
getRepository(id, init = this.defaultInit) { | ||
getRepository(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id), init, this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id), init, timeout); | ||
}); | ||
} | ||
listRepositories(init = this.defaultInit) { | ||
listRepositories(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource), init, this.timeout); | ||
return rpc(this.path(Client.repositoriesResource), init, timeout); | ||
}); | ||
} | ||
createRepository(id, conf, init = this.defaultInit) { | ||
createRepository(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
updateRepository(id, conf, init = this.defaultInit) { | ||
updateRepository(id, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteRepository(id, init = this.defaultInit) { | ||
deleteRepository(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
getRepositoryVersion(id, version, init = this.defaultInit) { | ||
getRepositoryVersion(id, version, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), init, this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), init, timeout); | ||
}); | ||
} | ||
listRepositoryVersions(id, init = this.defaultInit) { | ||
listRepositoryVersions(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions'), init, this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions'), init, timeout); | ||
}); | ||
} | ||
createRepositoryVersion(id, version, conf, init = this.defaultInit) { | ||
createRepositoryVersion(id, version, conf, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), Object.assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout); | ||
}); | ||
} | ||
deleteRepositoryVersion(id, version, init = this.defaultInit) { | ||
deleteRepositoryVersion(id, version, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), Object.assign({ method: 'DELETE' }, init), this.timeout); | ||
return rpc(this.path(Client.repositoriesResource, id, 'versions', version), Object.assign({ method: 'DELETE' }, init), timeout); | ||
}); | ||
} | ||
// Templates | ||
listTemplates(init = this.defaultInit) { | ||
listTemplates(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.templatesResource), init, this.timeout); | ||
return rpc(this.path(Client.templatesResource), init, timeout); | ||
}); | ||
} | ||
// Pools | ||
getPool(id, init = this.defaultInit) { | ||
getPool(id, timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.poolsResource, id), init, this.timeout); | ||
return rpc(this.path(Client.poolsResource, id), init, timeout); | ||
}); | ||
} | ||
listPools(init = this.defaultInit) { | ||
listPools(timeout = this.defaultTimeout, init = this.defaultInit) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rpc(this.path(Client.poolsResource), init, this.timeout); | ||
return rpc(this.path(Client.poolsResource), init, timeout); | ||
}); | ||
@@ -241,0 +240,0 @@ } |
@@ -6,2 +6,3 @@ export declare enum EnvironmentType { | ||
} | ||
export declare function environmentTypeFromString(s: string): EnvironmentType; | ||
export declare function playgroundBaseURL(env: EnvironmentType): "http://playground-dev.substrate.test/api" | "https://playground-staging.substrate.dev/api" | "https://playground.substrate.dev/api"; |
@@ -7,2 +7,14 @@ export var EnvironmentType; | ||
})(EnvironmentType || (EnvironmentType = {})); | ||
export function environmentTypeFromString(s) { | ||
switch (s) { | ||
case "dev": | ||
return EnvironmentType.dev; | ||
case "staging": | ||
return EnvironmentType.staging; | ||
case "production": | ||
return EnvironmentType.production; | ||
default: | ||
throw new Error(`Unrecognized env ${s}`); | ||
} | ||
} | ||
export function playgroundBaseURL(env) { | ||
@@ -9,0 +21,0 @@ switch (env) { |
"use strict"; | ||
// Helper methods to get access to authentication tokens. Can then be used with `Client.login`. | ||
// See https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps | ||
// | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -3,0 +6,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
@@ -13,46 +13,46 @@ import { Playground, Pool, Workspace, WorkspaceConfiguration, WorkspaceUpdateConfiguration, User, UserConfiguration, UserUpdateConfiguration, Repository, RepositoryConfiguration, RepositoryUpdateConfiguration, RepositoryVersion, RepositoryVersionConfiguration, SessionConfiguration, Session, SessionUpdateConfiguration, Template } from './types'; | ||
private readonly base; | ||
private readonly timeout; | ||
private readonly defaultTimeout; | ||
private readonly defaultInit; | ||
constructor(base: string, timeout?: number, defaultInit?: RequestInit); | ||
login(bearer: string, init?: RequestInit): Promise<void>; | ||
logout(init?: RequestInit): Promise<void>; | ||
constructor(base: string, defaultTimeout?: number, defaultInit?: RequestInit); | ||
login(bearer: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
logout(timeout?: number, init?: RequestInit): Promise<void>; | ||
path(...resources: string[]): string; | ||
loginPath(queryParams?: string): string; | ||
get(init?: RequestInit): Promise<Playground>; | ||
getCurrentUser(init?: RequestInit): Promise<User>; | ||
getUser(id: User['id'], init?: RequestInit): Promise<User | null>; | ||
listUsers(init?: RequestInit): Promise<User[]>; | ||
createUser(id: User['id'], conf: UserConfiguration, init?: RequestInit): Promise<void>; | ||
updateUser(id: User['id'], conf: UserUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteUser(id: User['id'], init?: RequestInit): Promise<void>; | ||
getCurrentWorkspace(init?: RequestInit): Promise<Workspace | null>; | ||
createCurrentWorkspace(conf: WorkspaceConfiguration, init?: RequestInit): Promise<void>; | ||
updateCurrentWorkspace(conf: WorkspaceUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteCurrentWorkspace(init?: RequestInit): Promise<void>; | ||
getWorkspace(id: Workspace['id'], init?: RequestInit): Promise<Workspace | null>; | ||
listWorkspaces(init?: RequestInit): Promise<Workspace[]>; | ||
createWorkspace(id: Workspace['id'], conf: WorkspaceConfiguration, init?: RequestInit): Promise<void>; | ||
updateWorkspace(id: Workspace['id'], conf: WorkspaceUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteWorkspace(id: Workspace['id'], init?: RequestInit): Promise<void>; | ||
getCurrentSession(init?: RequestInit): Promise<Session | null>; | ||
createCurrentSession(conf: SessionConfiguration, init?: RequestInit): Promise<void>; | ||
updateCurrentSession(conf: SessionUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteCurrentSession(init?: RequestInit): Promise<void>; | ||
getSession(id: string, init?: RequestInit): Promise<Session | null>; | ||
listSessions(init?: RequestInit): Promise<Session[]>; | ||
createSession(id: string, conf: SessionConfiguration, init?: RequestInit): Promise<void>; | ||
updateSession(id: string, conf: SessionUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteSession(id: string, init?: RequestInit): Promise<void>; | ||
getRepository(id: Repository['id'], init?: RequestInit): Promise<Repository | null>; | ||
listRepositories(init?: RequestInit): Promise<Repository[]>; | ||
createRepository(id: Repository['id'], conf: RepositoryConfiguration, init?: RequestInit): Promise<void>; | ||
updateRepository(id: Repository['id'], conf: RepositoryUpdateConfiguration, init?: RequestInit): Promise<void>; | ||
deleteRepository(id: Repository['id'], init?: RequestInit): Promise<void>; | ||
getRepositoryVersion(id: Repository['id'], version: string, init?: RequestInit): Promise<RepositoryVersion | null>; | ||
listRepositoryVersions(id: Repository['id'], init?: RequestInit): Promise<RepositoryVersion[]>; | ||
createRepositoryVersion(id: Repository['id'], version: string, conf: RepositoryVersionConfiguration, init?: RequestInit): Promise<void>; | ||
deleteRepositoryVersion(id: Repository['id'], version: string, init?: RequestInit): Promise<void>; | ||
listTemplates(init?: RequestInit): Promise<Template[]>; | ||
getPool(id: Pool['id'], init?: RequestInit): Promise<Pool | null>; | ||
listPools(init?: RequestInit): Promise<Pool[]>; | ||
get(timeout?: number, init?: RequestInit): Promise<Playground>; | ||
getCurrentUser(timeout?: number, init?: RequestInit): Promise<User>; | ||
getUser(id: User['id'], timeout?: number, init?: RequestInit): Promise<User | null>; | ||
listUsers(timeout?: number, init?: RequestInit): Promise<User[]>; | ||
createUser(id: User['id'], conf: UserConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateUser(id: User['id'], conf: UserUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteUser(id: User['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getCurrentWorkspace(timeout?: number, init?: RequestInit): Promise<Workspace | null>; | ||
createCurrentWorkspace(conf: WorkspaceConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateCurrentWorkspace(conf: WorkspaceUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteCurrentWorkspace(timeout?: number, init?: RequestInit): Promise<void>; | ||
getWorkspace(id: Workspace['id'], timeout?: number, init?: RequestInit): Promise<Workspace | null>; | ||
listWorkspaces(timeout?: number, init?: RequestInit): Promise<Workspace[]>; | ||
createWorkspace(id: Workspace['id'], conf: WorkspaceConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateWorkspace(id: Workspace['id'], conf: WorkspaceUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteWorkspace(id: Workspace['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getCurrentSession(timeout?: number, init?: RequestInit): Promise<Session | null>; | ||
createCurrentSession(conf: SessionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateCurrentSession(conf: SessionUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteCurrentSession(timeout?: number, init?: RequestInit): Promise<void>; | ||
getSession(id: string, timeout?: number, init?: RequestInit): Promise<Session | null>; | ||
listSessions(timeout?: number, init?: RequestInit): Promise<Session[]>; | ||
createSession(id: string, conf: SessionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateSession(id: string, conf: SessionUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteSession(id: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
getRepository(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<Repository | null>; | ||
listRepositories(timeout?: number, init?: RequestInit): Promise<Repository[]>; | ||
createRepository(id: Repository['id'], conf: RepositoryConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
updateRepository(id: Repository['id'], conf: RepositoryUpdateConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteRepository(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<void>; | ||
getRepositoryVersion(id: Repository['id'], version: string, timeout?: number, init?: RequestInit): Promise<RepositoryVersion | null>; | ||
listRepositoryVersions(id: Repository['id'], timeout?: number, init?: RequestInit): Promise<RepositoryVersion[]>; | ||
createRepositoryVersion(id: Repository['id'], version: string, conf: RepositoryVersionConfiguration, timeout?: number, init?: RequestInit): Promise<void>; | ||
deleteRepositoryVersion(id: Repository['id'], version: string, timeout?: number, init?: RequestInit): Promise<void>; | ||
listTemplates(timeout?: number, init?: RequestInit): Promise<Template[]>; | ||
getPool(id: Pool['id'], timeout?: number, init?: RequestInit): Promise<Pool | null>; | ||
listPools(timeout?: number, init?: RequestInit): Promise<Pool[]>; | ||
} | ||
@@ -59,0 +59,0 @@ export * from "./auth"; |
@@ -72,10 +72,12 @@ "use strict"; | ||
var Client = /** @class */ (function () { | ||
function Client(base, timeout, defaultInit) { | ||
if (timeout === void 0) { timeout = 10000; } | ||
function Client(base, defaultTimeout, defaultInit) { | ||
if (defaultTimeout === void 0) { defaultTimeout = 10000; } | ||
if (defaultInit === void 0) { defaultInit = {}; } | ||
this.base = base; | ||
this.defaultInit = defaultInit; | ||
this.timeout = timeout; | ||
this.defaultTimeout = defaultTimeout; | ||
} | ||
// Login | ||
Client.prototype.login = function (bearer, init) { | ||
Client.prototype.login = function (bearer, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
@@ -86,11 +88,10 @@ return __awaiter(this, void 0, void 0, function () { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, rpc_1.fetchWithTimeout)("".concat(this.path('login'), "?bearer=").concat(bearer), init, this.timeout)]; | ||
case 0: return [4 /*yield*/, (0, rpc_1.fetchWithTimeout)("".concat(this.path('login'), "?bearer=").concat(bearer), init, timeout)]; | ||
case 1: | ||
response = _a.sent(); | ||
headers = this.defaultInit.headers || new Headers(); | ||
if (!(headers instanceof Headers)) { | ||
headers = this.defaultInit.headers; | ||
if (headers instanceof Headers) { | ||
throw Error('Unsupported headers type'); | ||
} | ||
headers.set('cookie', response.headers.get('set-cookie')); | ||
this.defaultInit.headers = headers; | ||
this.defaultInit.headers = __assign({ cookie: response.headers.get('set-cookie') }, headers); | ||
return [2 /*return*/]; | ||
@@ -101,3 +102,4 @@ } | ||
}; | ||
Client.prototype.logout = function (init) { | ||
Client.prototype.logout = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
@@ -108,10 +110,10 @@ return __awaiter(this, void 0, void 0, function () { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, rpc_1.fetchWithTimeout)(this.path('logout'), init, this.timeout)]; | ||
case 0: return [4 /*yield*/, (0, rpc_1.fetchWithTimeout)(this.path('logout'), init, timeout)]; | ||
case 1: | ||
_a.sent(); | ||
headers = this.defaultInit.headers || new Headers(); | ||
if (!(headers instanceof Headers)) { | ||
headers = this.defaultInit.headers; | ||
if (headers instanceof Headers) { | ||
throw Error('Unsupported headers type'); | ||
} | ||
headers.delete('cookie'); | ||
delete headers['cookie']; | ||
this.defaultInit.headers = headers; | ||
@@ -134,7 +136,8 @@ return [2 /*return*/]; | ||
}; | ||
Client.prototype.get = function (init) { | ||
Client.prototype.get = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(""), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(""), init, timeout)]; | ||
}); | ||
@@ -144,7 +147,8 @@ }); | ||
// Current User | ||
Client.prototype.getCurrentUser = function (init) { | ||
Client.prototype.getCurrentUser = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.userResource), __assign({}, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.userResource), __assign({}, init), timeout)]; | ||
}); | ||
@@ -154,39 +158,44 @@ }); | ||
// Users | ||
Client.prototype.getUser = function (id, init) { | ||
Client.prototype.getUser = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listUsers = function (init) { | ||
Client.prototype.listUsers = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createUser = function (id, conf, init) { | ||
Client.prototype.createUser = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateUser = function (id, conf, init) { | ||
Client.prototype.updateUser = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteUser = function (id, init) { | ||
Client.prototype.deleteUser = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.usersResource, id), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -196,31 +205,35 @@ }); | ||
// Current Workspace | ||
Client.prototype.getCurrentWorkspace = function (init) { | ||
Client.prototype.getCurrentWorkspace = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createCurrentWorkspace = function (conf, init) { | ||
Client.prototype.createCurrentWorkspace = function (conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateCurrentWorkspace = function (conf, init) { | ||
Client.prototype.updateCurrentWorkspace = function (conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteCurrentWorkspace = function (init) { | ||
Client.prototype.deleteCurrentWorkspace = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspaceResource), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -230,39 +243,44 @@ }); | ||
// Workspaces | ||
Client.prototype.getWorkspace = function (id, init) { | ||
Client.prototype.getWorkspace = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listWorkspaces = function (init) { | ||
Client.prototype.listWorkspaces = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createWorkspace = function (id, conf, init) { | ||
Client.prototype.createWorkspace = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateWorkspace = function (id, conf, init) { | ||
Client.prototype.updateWorkspace = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteWorkspace = function (id, init) { | ||
Client.prototype.deleteWorkspace = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.workspacesResource, id), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -272,31 +290,35 @@ }); | ||
// Current Session | ||
Client.prototype.getCurrentSession = function (init) { | ||
Client.prototype.getCurrentSession = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createCurrentSession = function (conf, init) { | ||
Client.prototype.createCurrentSession = function (conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateCurrentSession = function (conf, init) { | ||
Client.prototype.updateCurrentSession = function (conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteCurrentSession = function (init) { | ||
Client.prototype.deleteCurrentSession = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionResource), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -306,39 +328,44 @@ }); | ||
// Sessions | ||
Client.prototype.getSession = function (id, init) { | ||
Client.prototype.getSession = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listSessions = function (init) { | ||
Client.prototype.listSessions = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createSession = function (id, conf, init) { | ||
Client.prototype.createSession = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateSession = function (id, conf, init) { | ||
Client.prototype.updateSession = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteSession = function (id, init) { | ||
Client.prototype.deleteSession = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.sessionsResource, id), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -348,71 +375,80 @@ }); | ||
// Repositories | ||
Client.prototype.getRepository = function (id, init) { | ||
Client.prototype.getRepository = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listRepositories = function (init) { | ||
Client.prototype.listRepositories = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createRepository = function (id, conf, init) { | ||
Client.prototype.createRepository = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.updateRepository = function (id, conf, init) { | ||
Client.prototype.updateRepository = function (id, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'PATCH', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteRepository = function (id, init) { | ||
Client.prototype.deleteRepository = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.getRepositoryVersion = function (id, version, init) { | ||
Client.prototype.getRepositoryVersion = function (id, version, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listRepositoryVersions = function (id, init) { | ||
Client.prototype.listRepositoryVersions = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions'), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions'), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.createRepositoryVersion = function (id, version, conf, init) { | ||
Client.prototype.createRepositoryVersion = function (id, version, conf, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), __assign({ method: 'PUT', body: JSON.stringify(conf) }, init), timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.deleteRepositoryVersion = function (id, version, init) { | ||
Client.prototype.deleteRepositoryVersion = function (id, version, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), __assign({ method: 'DELETE' }, init), this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.repositoriesResource, id, 'versions', version), __assign({ method: 'DELETE' }, init), timeout)]; | ||
}); | ||
@@ -422,7 +458,8 @@ }); | ||
// Templates | ||
Client.prototype.listTemplates = function (init) { | ||
Client.prototype.listTemplates = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.templatesResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.templatesResource), init, timeout)]; | ||
}); | ||
@@ -432,15 +469,17 @@ }); | ||
// Pools | ||
Client.prototype.getPool = function (id, init) { | ||
Client.prototype.getPool = function (id, timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.poolsResource, id), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.poolsResource, id), init, timeout)]; | ||
}); | ||
}); | ||
}; | ||
Client.prototype.listPools = function (init) { | ||
Client.prototype.listPools = function (timeout, init) { | ||
if (timeout === void 0) { timeout = this.defaultTimeout; } | ||
if (init === void 0) { init = this.defaultInit; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.poolsResource), init, this.timeout)]; | ||
return [2 /*return*/, (0, rpc_1.rpc)(this.path(Client.poolsResource), init, timeout)]; | ||
}); | ||
@@ -447,0 +486,0 @@ }); |
@@ -6,2 +6,3 @@ export declare enum EnvironmentType { | ||
} | ||
export declare function environmentTypeFromString(s: string): EnvironmentType; | ||
export declare function playgroundBaseURL(env: EnvironmentType): "http://playground-dev.substrate.test/api" | "https://playground-staging.substrate.dev/api" | "https://playground.substrate.dev/api"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.playgroundBaseURL = exports.EnvironmentType = void 0; | ||
exports.playgroundBaseURL = exports.environmentTypeFromString = exports.EnvironmentType = void 0; | ||
var EnvironmentType; | ||
@@ -10,2 +10,15 @@ (function (EnvironmentType) { | ||
})(EnvironmentType = exports.EnvironmentType || (exports.EnvironmentType = {})); | ||
function environmentTypeFromString(s) { | ||
switch (s) { | ||
case "dev": | ||
return EnvironmentType.dev; | ||
case "staging": | ||
return EnvironmentType.staging; | ||
case "production": | ||
return EnvironmentType.production; | ||
default: | ||
throw new Error("Unrecognized env ".concat(s)); | ||
} | ||
} | ||
exports.environmentTypeFromString = environmentTypeFromString; | ||
function playgroundBaseURL(env) { | ||
@@ -12,0 +25,0 @@ switch (env) { |
{ | ||
"name": "@substrate/playground-client", | ||
"version": "1.8.3", | ||
"version": "1.8.4", | ||
"description": "An isomorphic client for Substrate Playground", | ||
@@ -5,0 +5,0 @@ "main": "dist/main/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94109
1974