UNPKG

@webda/core

Version:

Expose API with Lambda

109 lines (108 loc) 3.56 kB
import { CoreModel } from "../models/coremodel.js"; import { WebContext } from "../utils/context.js"; import { Store, StoreEvents, StoreFindResult, StoreParameters } from "./store.js"; import { WebdaQL } from "./webdaql/query.js"; export declare class AbstractAliasStoreParameters extends StoreParameters { /** * Store to alias */ targetStore: string; constructor(params: any, store: Store); } /** * AliasStore allow to expose a Store as another route with another model * This is useful to store small collection in the registry * * The RegistryStore will default to a model, then specific models from the * target collection can be exposed via an endpoint like users * */ export declare abstract class AbstractAliasStore<T extends CoreModel, K extends AliasStoreParameters, E extends StoreEvents> extends Store<T, K, E> { _targetStore: Store<T>; /** * @override */ find(query: WebdaQL.Query): Promise<StoreFindResult<T>>; /** * @override */ _exists(uid: string): Promise<boolean>; /** * @override */ getAll(list?: string[]): Promise<T[]>; /** * @override */ _removeAttribute(uuid: string, attribute: string, itemWriteCondition?: any, itemWriteConditionField?: string): Promise<void>; /** * @override */ _save(object: T): Promise<any>; /** * @override */ _upsertItemToCollection(uid: string, prop: string, item: any, index: number, itemWriteCondition: any, itemWriteConditionField: string, updateDate: Date): Promise<any>; /** * @override */ abstract generateUuidFromPublicId(id: string): string; /** * @override */ _get(uid: string, raiseIfNotFound?: boolean | undefined): Promise<T>; /** * @override */ _delete(uid: string, writeCondition?: any, itemWriteConditionField?: string | undefined): Promise<void>; /** * @override */ _deleteItemFromCollection(uid: string, prop: string, index: number, itemWriteCondition: any, itemWriteConditionField: string, updateDate: Date): Promise<any>; /** * @override */ _incrementAttributes(uid: string, ...args: any[]): Promise<any>; /** * @override */ _patch(object: any, uid: string, itemWriteCondition?: any, itemWriteConditionField?: string | undefined): Promise<any>; /** * @override */ _update(object: any, uid: string, itemWriteCondition?: any, itemWriteConditionField?: string | undefined): Promise<any>; /** * @override */ httpGet(ctx: WebContext<any, any>): Promise<void>; /** * @override */ httpAction(ctx: WebContext<any, any>): Promise<void>; } export declare class AliasStoreParameters extends AbstractAliasStoreParameters { /** * Store to alias */ idTemplate: string; } /** * AliasStore allow to expose a Store as another route with another model * This is useful to store small collection in the registry * * The RegistryStore will default to a model, then specific models from the * target collection can be exposed via an endpoint like users * * @WebdaModda */ export declare class AliasStore<T extends CoreModel = CoreModel, K extends AliasStoreParameters = AliasStoreParameters, E extends StoreEvents = StoreEvents> extends AbstractAliasStore<T, K, E> { /** * @override */ loadParameters(params: any): StoreParameters; /** * Use the idTemplate parameter to generate uuid * @override */ generateUuidFromPublicId(id: string): string; }