Cristal API
Last modified by Manuel Leduc on 2024/11/25 17:00
Developer
Storage
export interface Storage {
setWikiConfig(config: WikiConfig): void;
getWikiConfig(): WikiConfig;
getPageRestURL(page: string, syntax: string, revision?: string): string;
getPageFromViewURL(url: string): string | null;
getImageURL(page: string, image: string): string;
/**
*
* @param page - the id of the request page
* @param syntax - the syntax of the request page
* @param revision - the revision requested, undefined will default to latest
* @param requeue - optional param informing whether an asynchronous update of
* the page content is allowed (default is true)
* @returns a promise wrapping a page data, or undefined in case of page not
* found
* @since 0.8
*/
getPageContent(
page: string,
syntax: string,
revision?: string,
requeue?: boolean,
): Promise<PageData | undefined>;
/**
* @param page - the page to get the attachments from
* @returns a promise wrapping an array of attachments and an optional count, or undefined if the
* requested page is not found
*
* @since 0.9
*/
getAttachments(page: string): Promise<AttachmentsData | undefined>;
/**
* @param page - the attachment page name
* @param name - the attachment name
* @returns a promise wrapping the attachment data, or undefined if the requested attachment is not found
* @since 0.12
*/
getAttachment(
page: string,
name: string,
): Promise<PageAttachment | undefined>;
getPanelContent(
panel: string,
contextPage: string,
syntax: string,
): Promise<PageData>;
getEditField(jsonArticle: object, fieldName: string): Promise<string>;
isStorageReady(): Promise<boolean>;
/**
* Update the content of a given page with the provided content.
*
* @param page - the page to save
* @param content - the content of the page
* @param title - the page title
* @param syntax - the syntax of the page
* @returns a promise when the save is done
*
* @since 0.8
*/
save(
page: string,
title: string,
content: string,
syntax: string,
): Promise<unknown>;
/**
*
* @param page - the page where to save attachments at
* @param files - the files to save
*
* @since 0.9
*/
saveAttachments(page: string, files: File[]): Promise<unknown>;
/**
* Delete a page.
*
* @param page - the page to delete
* @returns true if the delete was successful, false with the reason otherwise
*
* @since 0.11
*/
delete(page: string): Promise<{ success: boolean; error?: string }>;
}
setWikiConfig(config: WikiConfig): void;
getWikiConfig(): WikiConfig;
getPageRestURL(page: string, syntax: string, revision?: string): string;
getPageFromViewURL(url: string): string | null;
getImageURL(page: string, image: string): string;
/**
*
* @param page - the id of the request page
* @param syntax - the syntax of the request page
* @param revision - the revision requested, undefined will default to latest
* @param requeue - optional param informing whether an asynchronous update of
* the page content is allowed (default is true)
* @returns a promise wrapping a page data, or undefined in case of page not
* found
* @since 0.8
*/
getPageContent(
page: string,
syntax: string,
revision?: string,
requeue?: boolean,
): Promise<PageData | undefined>;
/**
* @param page - the page to get the attachments from
* @returns a promise wrapping an array of attachments and an optional count, or undefined if the
* requested page is not found
*
* @since 0.9
*/
getAttachments(page: string): Promise<AttachmentsData | undefined>;
/**
* @param page - the attachment page name
* @param name - the attachment name
* @returns a promise wrapping the attachment data, or undefined if the requested attachment is not found
* @since 0.12
*/
getAttachment(
page: string,
name: string,
): Promise<PageAttachment | undefined>;
getPanelContent(
panel: string,
contextPage: string,
syntax: string,
): Promise<PageData>;
getEditField(jsonArticle: object, fieldName: string): Promise<string>;
isStorageReady(): Promise<boolean>;
/**
* Update the content of a given page with the provided content.
*
* @param page - the page to save
* @param content - the content of the page
* @param title - the page title
* @param syntax - the syntax of the page
* @returns a promise when the save is done
*
* @since 0.8
*/
save(
page: string,
title: string,
content: string,
syntax: string,
): Promise<unknown>;
/**
*
* @param page - the page where to save attachments at
* @param files - the files to save
*
* @since 0.9
*/
saveAttachments(page: string, files: File[]): Promise<unknown>;
/**
* Delete a page.
*
* @param page - the page to delete
* @returns true if the delete was successful, false with the reason otherwise
*
* @since 0.11
*/
delete(page: string): Promise<{ success: boolean; error?: string }>;
}