UNPKG

@datalayer/core

Version:

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

75 lines (74 loc) 2.45 kB
/** * Abstract base class for all Datalayer content items. * * @module models/ItemDTO */ import type { DatalayerClient } from '../index'; /** * Abstract base class for all Datalayer content items. * Provides common functionality for content management including lifecycle tracking. * * @template TData - Raw data type from API * @template TUpdateRequest - Update request type for API */ export declare abstract class ItemDTO<TData> { protected _data: TData; private _sdk; private _deleted; /** * Create an Item instance. * @param data - Item data from API * @param sdk - SDK instance */ constructor(data: TData, sdk: DatalayerClient); /** Check if this item has been deleted. */ get isDeleted(): boolean; /** * Check if this item has been deleted and throw error if so. * @throws Error if deleted */ protected _checkDeleted(): void; /** Item ID. */ get id(): string; /** Unique identifier for the item. */ get uid(): string; /** Parent space ID. */ get spaceId(): string; /** Owner user ID. */ get ownerId(): string; /** When the item was created. */ get createdAt(): Date; /** The cached update time. */ get updatedAt(): Date; /** Get the item type identifier. */ abstract get type(): string; /** The cached name. */ abstract get name(): string; /** Get the current name from API. */ abstract getName(): Promise<string>; /** The cached content. */ abstract get content(): any; /** Get when the item was last updated from API. */ abstract getUpdatedAt(): Promise<Date>; /** Update the item. */ abstract update(...args: any[]): Promise<this>; /** * Delete this item permanently. * After deletion, all subsequent method calls will throw errors. */ delete(): Promise<void>; /** Get the document content from API. */ getContent(): Promise<any>; /** Get raw item data object. */ rawData(): TData; /** Convert to JSON representation - must be implemented by subclasses. */ abstract toJSON(): any; /** String representation of the item. */ toString(): string; /** Get SDK token for API calls. */ protected _getToken(): string; /** Get spacer API URL for API calls. */ protected _getSpacerRunUrl(): string; /** Update internal data after API call. */ protected _updateData(newData: TData): void; }