arlas-persistence-api
Version:
Persists data
370 lines (369 loc) • 10.9 kB
TypeScript
/// <reference path="custom.d.ts" />
import { Configuration } from "./configuration";
/**
*
* @export
*/
export declare const COLLECTION_FORMATS: {
csv: string;
ssv: string;
tsv: string;
pipes: string;
};
/**
*
* @export
* @interface FetchAPI
*/
export interface FetchAPI {
(url: string, init?: any): Promise<Response>;
}
/**
*
* @export
* @interface FetchArgs
*/
export interface FetchArgs {
url: string;
options: any;
}
/**
*
* @export
* @class BaseAPI
*/
export declare class BaseAPI {
protected basePath: string;
protected fetch: FetchAPI;
protected configuration: Configuration;
constructor(configuration?: Configuration, basePath?: string, fetch?: FetchAPI);
}
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export declare class RequiredError extends Error {
field: string;
name: "RequiredError";
constructor(field: string, msg?: string);
}
/**
*
* @export
* @interface DataResource
*/
export interface DataResource {
/**
*
* @type {number}
* @memberof DataResource
*/
count?: number;
/**
*
* @type {number}
* @memberof DataResource
*/
total?: number;
/**
*
* @type {{ [key: string]: Link; }}
* @memberof DataResource
*/
_links?: {
[key: string]: Link;
};
/**
*
* @type {Array<DataWithLinks>}
* @memberof DataResource
*/
data?: Array<DataWithLinks>;
}
/**
*
* @export
* @interface DataWithLinks
*/
export interface DataWithLinks {
/**
*
* @type {string}
* @memberof DataWithLinks
*/
id?: string;
/**
*
* @type {string}
* @memberof DataWithLinks
*/
doc_key: string;
/**
*
* @type {string}
* @memberof DataWithLinks
*/
doc_zone: string;
/**
*
* @type {Date}
* @memberof DataWithLinks
*/
last_update_date: Date;
/**
*
* @type {string}
* @memberof DataWithLinks
*/
doc_value: string;
/**
*
* @type {string}
* @memberof DataWithLinks
*/
doc_owner: string;
/**
*
* @type {string}
* @memberof DataWithLinks
*/
doc_organization: string;
/**
*
* @type {Array<string>}
* @memberof DataWithLinks
*/
doc_entities?: Array<string>;
/**
*
* @type {Array<string>}
* @memberof DataWithLinks
*/
doc_writers?: Array<string>;
/**
*
* @type {Array<string>}
* @memberof DataWithLinks
*/
doc_readers?: Array<string>;
/**
*
* @type {{ [key: string]: Link; }}
* @memberof DataWithLinks
*/
_links?: {
[key: string]: Link;
};
/**
*
* @type {boolean}
* @memberof DataWithLinks
*/
updatable?: boolean;
/**
*
* @type {boolean}
* @memberof DataWithLinks
*/
ispublic?: boolean;
}
/**
*
* @export
* @interface Exists
*/
export interface Exists {
/**
*
* @type {boolean}
* @memberof Exists
*/
exists?: boolean;
}
/**
*
* @export
* @interface Link
*/
export interface Link {
/**
*
* @type {string}
* @memberof Link
*/
relation: string;
/**
*
* @type {string}
* @memberof Link
*/
href: string;
/**
*
* @type {string}
* @memberof Link
*/
type: string;
/**
*
* @type {string}
* @memberof Link
*/
method: string;
}
/**
*
* @export
* @interface ModelError
*/
export interface ModelError {
/**
*
* @type {number}
* @memberof ModelError
*/
status?: number;
/**
*
* @type {string}
* @memberof ModelError
*/
message?: string;
/**
*
* @type {string}
* @memberof ModelError
*/
error?: string;
}
/**
* PersistApi - fetch parameter creator
* @export
*/
export declare const PersistApiFetchParamCreator: (configuration?: Configuration) => {
create(zone: string, key: string, value: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): FetchArgs;
deleteById(id: string, pretty?: boolean, options?: any): FetchArgs;
existsById(id: string, pretty?: boolean, options?: any): FetchArgs;
getById(id: string, pretty?: boolean, options?: any): FetchArgs;
getGroupsByZone(zone: string, pretty?: boolean, options?: any): FetchArgs;
list(zone: string, size?: number, page?: number, order?: string, pretty?: boolean, options?: any): FetchArgs;
update(id: string, value: string, last_update: number, key?: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): FetchArgs;
};
/**
* PersistApi - functional programming interface
* @export
*/
export declare const PersistApiFp: (configuration?: Configuration) => {
create(zone: string, key: string, value: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<DataWithLinks>;
deleteById(id: string, pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<DataWithLinks>;
existsById(id: string, pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Exists>;
getById(id: string, pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<DataWithLinks>;
getGroupsByZone(zone: string, pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<string[]>;
list(zone: string, size?: number, page?: number, order?: string, pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<DataResource>;
update(id: string, value: string, last_update: number, key?: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<DataWithLinks>;
};
/**
* PersistApi - factory interface
* @export
*/
export declare const PersistApiFactory: (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) => {
create(zone: string, key: string, value: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): Promise<DataWithLinks>;
deleteById(id: string, pretty?: boolean, options?: any): Promise<DataWithLinks>;
existsById(id: string, pretty?: boolean, options?: any): Promise<Exists>;
getById(id: string, pretty?: boolean, options?: any): Promise<DataWithLinks>;
getGroupsByZone(zone: string, pretty?: boolean, options?: any): Promise<string[]>;
list(zone: string, size?: number, page?: number, order?: string, pretty?: boolean, options?: any): Promise<DataResource>;
update(id: string, value: string, last_update: number, key?: string, readers?: string[], writers?: string[], pretty?: boolean, options?: any): Promise<DataWithLinks>;
};
/**
* PersistApi - object-oriented interface
* @export
* @class PersistApi
* @extends {BaseAPI}
*/
export declare class PersistApi extends BaseAPI {
/**
* Store a new piece of data for the provided zone and key (auto generate id).
* @summary Store a new piece of data for the provided zone and key (auto generate id).
* @param {} zone Zone of the document.
* @param {} key The key of the data.
* @param {} value Value to be persisted.
* @param {} [readers] Comma separated values of groups authorized to read the data.
* @param {} [writers] Comma separated values of groups authorized to modify the data.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
create(zone: string, key: string, value: string, readers?: Array<string>, writers?: Array<string>, pretty?: boolean, options?: any): Promise<DataWithLinks>;
/**
* Delete an entry given its key and id.
* @summary Delete an entry given its key and id.
* @param {} id The id of the data.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
deleteById(id: string, pretty?: boolean, options?: any): Promise<DataWithLinks>;
/**
* Check the existence of an entry given its id.
* @summary Check the existence of an entry given its id.
* @param {} id The id of the data.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
existsById(id: string, pretty?: boolean, options?: any): Promise<Exists>;
/**
* Fetch an entry given its id.
* @summary Fetch an entry given its id.
* @param {} id The id of the data.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
getById(id: string, pretty?: boolean, options?: any): Promise<DataWithLinks>;
/**
* Returns the users' groups allowed to interact with the given zone.
* @summary Returns the users' groups allowed to interact with the given zone.
* @param {} zone Zone of the document.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
getGroupsByZone(zone: string, pretty?: boolean, options?: any): Promise<string[]>;
/**
* Fetch a list of data related to a zone.
* @summary Fetch a list of data related to a zone.
* @param {} zone Zone of the document.
* @param {} [size] Page Size
* @param {} [page] Page ID
* @param {} [order] Date sort order
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
list(zone: string, size?: number, page?: number, order?: string, pretty?: boolean, options?: any): Promise<DataResource>;
/**
* Update an existing value.
* @summary Update an existing value.
* @param {} id The id of the data.
* @param {} value Value to be persisted.
* @param {} last_update Previous date value of last modification known by client.
* @param {} [key] The key of the data.
* @param {} [readers] Comma separated values of groups authorized to read the data.
* @param {} [writers] Comma separated values of groups authorized to modify the data.
* @param {} [pretty] Pretty print
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersistApi
*/
update(id: string, value: string, last_update: number, key?: string, readers?: Array<string>, writers?: Array<string>, pretty?: boolean, options?: any): Promise<DataWithLinks>;
}