@datalayer/core
Version:
[](https://datalayer.io)
156 lines (155 loc) • 4.41 kB
TypeScript
import type { DatalayerClient } from '../index';
import { ItemDTO } from './ItemDTO';
/**
* Represents a Lexical document (rich text editor)
* @interface Lexical
*/
export interface LexicalData {
id: string;
uid: string;
name?: string;
name_t?: string;
content?: any;
space_id?: string;
owner_id?: string;
creator_uid?: string;
creator_handle_s?: string;
created_at?: string;
creation_ts_dt?: string;
updated_at?: string;
last_update_ts_dt?: string;
cdn_url_s: string;
type_s?: string;
public_b?: boolean;
description_t?: string;
document_name_s?: string;
document_extension_s: string;
document_format_s?: string;
content_length_i?: number;
content_type_s?: string;
mime_type_s?: string;
s3_path_s?: string;
s3_url_s?: string;
model_s?: string;
}
/**
* Request payload for creating a Lexical document
* @interface CreateLexicalRequest
*/
export interface CreateLexicalRequest {
spaceId: string;
documentType: string;
name: string;
description: string;
file?: File | Blob;
}
/**
* Response from creating a Lexical document
* @interface CreateLexicalResponse
*/
export interface CreateLexicalResponse {
success: boolean;
message: string;
document?: LexicalData;
}
/**
* Response from getting a Lexical document
* @interface GetLexicalResponse
*/
export interface GetLexicalResponse {
success: boolean;
message: string;
document?: LexicalData;
}
/**
* Request payload for updating a Lexical document
* @interface UpdateLexicalRequest
*/
export interface UpdateLexicalRequest {
name?: string;
description?: string;
}
/**
* Response from updating a Lexical document
* @interface UpdateLexicalResponse
*/
export interface UpdateLexicalResponse {
success: boolean;
message: string;
document: LexicalData;
}
/**
* Stable public interface for Lexical data.
* This is the contract that SDK consumers can rely on.
* The raw API may change, but this interface remains stable.
*/
export interface LexicalJSON {
/** Unique identifier for the lexical document */
uid: string;
/** Unique identifier for the lexical document */
id: string;
/** Name of the lexical document */
name: string;
/** Description of the lexical document */
description: string;
/** Type of lexical document */
type: string;
/** File extension of the lexical document */
extension: string;
/** ISO 8601 timestamp when the document was created */
createdAt: string;
/** ISO 8601 timestamp when the document was last updated */
updatedAt: string;
/** CDN URL for accessing the document */
cdnUrl: string;
}
/**
* Lexical domain model that extends the base Item class.
* Provides lexical document functionality for managing rich text documents.
*
* @example
* ```typescript
* const lexical = await sdk.createLexical(formData);
* await lexical.update({ name: 'Updated Documentation' });
* ```
*/
export declare class LexicalDTO extends ItemDTO<LexicalData> {
/**
* Create a Lexical instance.
*
* @param data - Lexical data from API
* @param sdk - SDK instance
*/
constructor(data: LexicalData, sdk: DatalayerClient);
/** Document type identifier. */
get type(): string;
/** The cached name of the document. */
get name(): string;
/** Get the current name of the document from API. */
getName(): Promise<string>;
/** The cached content. */
get content(): any;
/** Description of the lexical document. */
get description(): string;
/** Get the document extension. */
get extension(): string;
/** Get when the document was last updated from API. */
getUpdatedAt(): Promise<Date>;
/** Update the document. */
update(name?: string, description?: string): Promise<this>;
/**
* Get lexical document data in camelCase format.
* Returns only the core fields that consumers need.
* This provides a stable interface regardless of API changes.
*
* @returns Core lexical data with camelCase properties
*/
toJSON(): LexicalJSON;
/**
* Get the raw lexical data exactly as received from the API.
* This preserves the original snake_case naming from the API response.
*
* @returns Raw lexical data from API
*/
rawData(): LexicalData;
}