UNPKG

@mnfst/sdk

Version:

Manifest JavaScript SDK

68 lines (67 loc) 1.86 kB
/** * The base class for all SDKs. */ export declare class BaseSDK { /** * The slug of the entity to query. */ slug: string; /** * A flag to determine if the entity is a single entity or a collection. */ isSingleEntity: boolean; /** * The query parameters of the request. */ queryParams: { [key: string]: string; }; /** * Set the slug of the entity to query. * * @param slug The slug of the entity to query. * * @returns The current instance of the client. * @example client.from('cats').find(); */ from(slug: string): this; /** * * Adds a where clause to the query. * * @param whereClause The where clause to add. * * @returns The current instance of the client. * @example client.from('cats').where('age = 10').find(); */ where(whereClause: string): this; /** * Adds a where clause to the query. * * @param whereClause * @returns The current instance of the client. * @example client.from('cats').andWhere('age = 10').find(); */ andWhere(whereClause: string): this; /** * Adds an order by clause to the query. * * @param propName The property name to order by. * @param order The order of the property (ASC or DESC). Default ASC * * @returns The current instance of the client. * @example client.from('cats').orderBy('age', { desc: true }).find(); */ orderBy(propName: string, order?: { desc: boolean; }): this; /** * Loads the relations of the entity. * * @param relations The relations to load. * * @returns The current instance of the client. * @example client.from('cats').with(['owner', 'owner.company']).find(); */ with(relations: string[]): this; }