@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
63 lines (62 loc) • 2 kB
TypeScript
import { RecordTypes } from '../types.js';
import { type ApiFieldMetadata } from '../models/apiResults.js';
import { type LayoutBase } from '../layouts/layoutBase.js';
import { type Moment } from 'moment';
export type FieldValue = string | number | Moment | Container;
export type Container = null;
export interface Parentable {
layout: LayoutBase;
type: RecordTypes;
endpoint: string;
portal?: {
name: string;
};
}
/**
* A class representing a field in a record.
*
* @template T - The type of the field value.
*/
export declare class Field<T extends FieldValue> {
#private;
parent: Parentable;
id: string;
protected _value: T | null;
static firstContainerDownload: Promise<any> | null;
constructor(record: Parentable, id: string, originalContents: T);
get edited(): boolean;
/**
* Resets the 'edited' state of this field, without changing its value
*/
updateOriginalContents(): void;
/**
* Sets the value of the field.
*
* @param {T | null} content - The new content value to be set. Can be either the type T or null.
* @throws {Error} Cannot set container value using set(). Use upload() instead, if the result is a 'container'.
*/
set(content: T | null): void;
get metadata(): ApiFieldMetadata;
get value(): T | null;
set value(value: T);
get string(): string;
/**
* Uploads a file to the container field.
*
* @param {Buffer} file - The file content as a buffer.
*
* @throws {Error} - Cannot upload a file to the field if it's not a container field.
* @throws {Error} - Upload failed with HTTP error.
*
* @returns {Promise<void>} - A promise that resolves when the file is successfully uploaded.
*/
upload(file: File): Promise<void>;
stream(): Promise<{
data: NodeJS.ReadableStream;
mime: string;
}>;
arrayBuffer(): Promise<{
data: ArrayBuffer;
mime: string;
}>;
}