2023-10-18 18:54:03 +01:00
|
|
|
// AUTOGENERATED BY private/apigen
|
|
|
|
// DO NOT EDIT.
|
|
|
|
import { Time, UUID } from '@/types/common';
|
|
|
|
|
|
|
|
export class DocsGetResponseItem {
|
|
|
|
id: UUID;
|
|
|
|
path: string;
|
|
|
|
date: Time;
|
|
|
|
metadata: Metadata;
|
|
|
|
last_retrievals?: DocsGetResponseItemLastRetrievals;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DocsGetResponseItemLastRetrievalsItem {
|
|
|
|
user: string;
|
|
|
|
when: Time;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DocsUpdateContentRequest {
|
|
|
|
content: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DocsUpdateContentResponse {
|
|
|
|
id: UUID;
|
|
|
|
date: Time;
|
|
|
|
pathParam: string;
|
|
|
|
body: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Document {
|
|
|
|
id: UUID;
|
|
|
|
date: Time;
|
|
|
|
pathParam: string;
|
|
|
|
body: string;
|
|
|
|
version: Version;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Metadata {
|
|
|
|
owner: string;
|
|
|
|
tags?: string[][];
|
|
|
|
}
|
|
|
|
|
2023-11-02 12:46:35 +00:00
|
|
|
export class UsersGetResponseItem {
|
2023-10-18 18:54:03 +01:00
|
|
|
name: string;
|
|
|
|
surname: string;
|
|
|
|
email: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Version {
|
|
|
|
date: Time;
|
|
|
|
number: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type DocsGetResponse = Array<DocsGetResponseItem>
|
|
|
|
|
|
|
|
export type DocsGetResponseItemLastRetrievals = Array<DocsGetResponseItemLastRetrievalsItem>
|
|
|
|
|
2023-11-02 12:46:35 +00:00
|
|
|
export type UsersCreateRequest = Array<UsersGetResponseItem>
|
2023-10-18 18:54:03 +01:00
|
|
|
|
2023-11-02 12:46:35 +00:00
|
|
|
export type UsersGetResponse = Array<UsersGetResponseItem>
|
2023-10-18 18:54:03 +01:00
|
|
|
|
|
|
|
class APIError extends Error {
|
|
|
|
constructor(
|
|
|
|
public readonly msg: string,
|
|
|
|
public readonly responseStatusCode?: number,
|
|
|
|
) {
|
|
|
|
super(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DocumentsHttpApiV0 {
|
|
|
|
public readonly respStatusCode: number;
|
|
|
|
|
|
|
|
// When respStatuscode is passed, the client throws an APIError on each method call
|
|
|
|
// with respStatusCode as HTTP status code.
|
|
|
|
// respStatuscode must be equal or greater than 400
|
|
|
|
constructor(respStatusCode?: number) {
|
|
|
|
if (typeof respStatusCode === 'undefined') {
|
|
|
|
this.respStatusCode = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (respStatusCode < 400) {
|
|
|
|
throw new Error('invalid response status code for API Error, it must be greater or equal than 400');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.respStatusCode = respStatusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async get(): Promise<DocsGetResponse> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-15 07:37:10 +00:00
|
|
|
return JSON.parse('[{"id":"00000000-0000-0000-0000-000000000000","path":"/workspace/notes.md","date":"0001-01-01T00:00:00Z","metadata":{"owner":"Storj","tags":[["category","general"]]},"last_retrievals":[{"user":"Storj","when":"2001-02-03T03:05:06.000000007Z"}]}]') as DocsGetResponse;
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async getOne(path: string): Promise<Document> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-15 07:37:10 +00:00
|
|
|
return JSON.parse('{"id":"00000000-0000-0000-0000-000000000000","date":"2001-02-02T04:05:06.000000007Z","pathParam":"ID","body":"## Notes","version":{"date":"2001-02-03T03:35:06.000000007Z","number":1}}') as Document;
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async getTag(path: string, tagName: string): Promise<string[]> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-02 12:46:35 +00:00
|
|
|
return JSON.parse('["category","notes"]') as string[];
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async getVersions(path: string): Promise<Version[]> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-15 07:37:10 +00:00
|
|
|
return JSON.parse('[{"date":"2001-01-19T04:05:06.000000007Z","number":1},{"date":"2001-02-02T23:05:06.000000007Z","number":2}]') as Version[];
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async updateContent(request: DocsUpdateContentRequest, path: string, id: UUID, date: Time): Promise<DocsUpdateContentResponse> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-15 07:37:10 +00:00
|
|
|
return JSON.parse('{"id":"00000000-0000-0000-0000-000000000000","date":"2001-02-03T04:05:06.000000007Z","pathParam":"ID","body":"## Notes\n### General"}') as DocsUpdateContentResponse;
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class UsersHttpApiV0 {
|
|
|
|
public readonly respStatusCode: number;
|
|
|
|
|
|
|
|
// When respStatuscode is passed, the client throws an APIError on each method call
|
|
|
|
// with respStatusCode as HTTP status code.
|
|
|
|
// respStatuscode must be equal or greater than 400
|
|
|
|
constructor(respStatusCode?: number) {
|
|
|
|
if (typeof respStatusCode === 'undefined') {
|
|
|
|
this.respStatusCode = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (respStatusCode < 400) {
|
|
|
|
throw new Error('invalid response status code for API Error, it must be greater or equal than 400');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.respStatusCode = respStatusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async get(): Promise<UsersGetResponse> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
2023-11-02 12:46:35 +00:00
|
|
|
return JSON.parse('[{"name":"Storj","surname":"Labs","email":"storj@storj.test"},{"name":"Test1","surname":"Testing","email":"test1@example.test"},{"name":"Test2","surname":"Testing","email":"test2@example.test"}]') as UsersGetResponse;
|
2023-10-18 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async create(request: UsersCreateRequest): Promise<void> {
|
2023-11-02 12:46:35 +00:00
|
|
|
if (this.respStatusCode !== 0) {
|
2023-10-18 18:54:03 +01:00
|
|
|
throw new APIError('mock error message: ' + this.respStatusCode, this.respStatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|