@jd-data-limited/easy-fm
Version:
easy-fm is a Node.js module that allows you to interact with a [FileMaker database stored](https://www.claris.com/filemaker/) on a [FileMaker server](https://www.claris.com/filemaker/server/). This module interacts with your server using the [FileMaker
86 lines (85 loc) • 3.21 kB
TypeScript
import { type LayoutInterface } from '../../layouts/layoutInterface.js';
import { type PickPortals, type ScriptRequestData } from '../../types.js';
import { type LayoutBase } from '../../layouts/layoutBase.js';
import { LayoutRecord } from '../layoutRecord.js';
import { type Query } from '../../utils/query.js';
export type SortOrder = 'ascend' | 'descend';
export type FindRequestRaw = Record<string, string>;
export type FindRequest = Record<string, Query>;
export interface PortalRequest {
name: string;
}
type PortalData<T extends LayoutInterface> = {
[key in keyof T['portals']]: {
limit: number;
offset: number;
};
};
export interface GetOperationOptions<T extends LayoutInterface> {
portals: Partial<PortalData<T>>;
requests?: Array<{
req: FindRequest;
omit?: boolean;
}>;
limit?: number;
offset?: number;
}
export declare class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOperationOptions<T>> {
protected layout: LayoutBase;
protected limit: number;
protected scriptData: ScriptRequestData;
protected sortData: Array<{
fieldName: string;
sortOrder: SortOrder;
}>;
protected portals: Partial<PortalData<T>>;
protected offset: number;
protected requests: Array<{
req: FindRequestRaw;
omit?: boolean;
}>;
constructor(layout: LayoutBase, options: OPTIONS);
get isFindRequest(): boolean;
private formatQueries;
protected generateParamsBody(offset: number, limit: number): Record<string, any>;
protected generateParamsURL(offset: number, limit: number): URLSearchParams;
/**
* Configures any FileMaker scripts to be run as a part of the request
*
* @param {ScriptRequestData} scripts - The script request data to set.
* @return {this} - The current instance of the class.
*/
scripts(scripts: ScriptRequestData): this;
/**
* Sorts the data based on the given field name and sort order.
*
* @param {string} fieldName - The name of the field by which the data should be sorted.
* @param {SortOrder} sortOrder - The sort order to be applied (either "asc" for ascending or "desc" for descending).
*
* @return {this} - Returns the current instance of the object.
*/
sort(fieldName: string, sortOrder: SortOrder): this;
private parseFindRequest;
/**
* Adds a new request/query to the list of queries.
*
* @param {FindRequest} query - The find request to be added.
* @param {boolean} [omit=false] - Flag to indicate if the find request should be omitted.
* @return {Object} - The current object instance.
*/
addRequest(query: FindRequest, omit?: boolean): this;
/**
* Perform a fetch operation.
*
* @returns {Promise} A promise that resolves with the result of the fetch operation.
*/
fetch(): Promise<LayoutRecord<PickPortals<T, keyof OPTIONS["portals"]>>[]>;
private performFind;
[Symbol.asyncIterator](): {
next: () => Promise<{
done: boolean;
value: LayoutRecord<PickPortals<T, keyof OPTIONS["portals"]>> | undefined;
}>;
};
}
export {};