@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
68 lines (67 loc) • 3 kB
TypeScript
import { EventEmitter } from 'events';
import { type LayoutInterface } from '../layouts/layoutInterface.js';
import { Layout } from '../layouts/layout.js';
import { type databaseOptionsWithExternalSources, type Script } from '../types.js';
import { type HostBase } from './HostBase.js';
import { type DatabaseBase } from './databaseBase.js';
import { type ApiResults } from '../models/apiResults.js';
import { type DatabaseStructure } from '../databaseStructure.js';
import { type RequestInfo, type RequestInit, type Response } from 'node-fetch';
/**
* Represents a database connection.
* @template T - The structure of the database.
*/
export declare class Database<T extends DatabaseStructure> extends EventEmitter implements DatabaseBase {
#private;
private _token;
readonly host: HostBase;
private readonly connection_details;
private cookies;
readonly name: string;
readonly debug: boolean;
constructor(host: HostBase, conn: databaseOptionsWithExternalSources);
private generateExternalSourceLogin;
/**
* Logs out the user by deleting the current session token.
* Throws an error if the user is not logged in.
*
* @returns {Promise<void>} A promise that resolves with no value once the logout is successful.
* @throws {Error} Throws an error if the user is not logged in.
*/
logout(): Promise<void>;
/**
* Logs in to the database. Not required, as this is often done automatically
*
* @param {boolean} [forceLogin=false] - Whether to force login even if already logged in.
* @throws {Error} - Throws an error if already logged in and forceLogin is false.
* @throws {FMError} - Throws an FMError if login fails.
* @return {Promise<string>} - Returns a promise that resolves to the access token upon successful login.
*/
login(forceLogin?: boolean): Promise<string | undefined>;
get token(): string;
/**
* Returns the endpoint URL for the database connection.
*
* @returns {string} The endpoint URL.
*/
get endpoint(): string;
_apiRequestRaw(url: URL | RequestInfo, options?: RequestInit & {
headers?: Record<string, string>;
useCookieJar?: boolean;
retries?: number;
}, autoRelogin?: boolean): Promise<Response>;
_apiRequestJSON<T = any>(url: URL | RequestInfo, options?: RequestInit & {
headers?: Record<string, string>;
}): Promise<ApiResults<T>>;
/**
* Retrieves a list of layouts in the current FileMaker database.
*
* @returns {Promise<Layout[]>} A promise that resolves to an array of Layout objects.
* @throws {FMError} If there was an error retrieving the layouts.
*/
listLayouts(page?: number): Promise<Layout<LayoutInterface>[]>;
layout<R extends keyof T['layouts']>(name: R): Layout<T['layouts'][R]>;
layout<R extends LayoutInterface>(name: string): Layout<R>;
clearLayoutCache(): void;
script(name: string, parameter?: string): Script;
}