@proofgeist/fmdapi
Version:
FileMaker Data API client
219 lines • 11.2 kB
TypeScript
import { z } from "zod";
import type { Adapter } from "./adapters/core.js";
import type { CreateResponse, DeleteResponse, FMRecord, FieldData, GenericPortalData, GetResponse, GetResponseOne, ListParams, Query, UpdateResponse } from "./client-types.js";
export type ClientObjectProps = {
/**
* The layout to use by default for all requests. Can be overrridden on each request.
*/
layout?: string;
zodValidators?: {
fieldData: z.AnyZodObject;
portalData?: z.AnyZodObject;
};
};
type WithLayout = {
/**
* The layout to use for the request.
*/
layout: string;
};
type FetchOptions = {
fetch?: RequestInit;
};
declare function DataApi<Opts extends ClientObjectProps = ClientObjectProps, Td extends FieldData = FieldData, Ud extends GenericPortalData = GenericPortalData, Adp extends Adapter = Adapter>(options: Opts & {
adapter: Adp;
}): Omit<Adp, "find" | "create" | "delete" | "get" | "list" | "update" | "layoutMetadata" | "containerUpload"> & {
layout: Opts["layout"];
list: {
(): Promise<GetResponse<Td, Ud>>;
<T extends FieldData = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? ListParams<T, U> & Partial<WithLayout> & FetchOptions : ListParams<T, U> & WithLayout & FetchOptions): Promise<GetResponse<T, U>>;
};
listAll: {
<T extends FieldData = Td, U extends Ud = Ud>(): Promise<FMRecord<T, U>[]>;
<T extends FieldData = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? ListParams<T, U> & Partial<WithLayout> & FetchOptions : ListParams<T, U> & WithLayout & FetchOptions): Promise<FMRecord<T, U>[]>;
};
create: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & {
portalData?: import("./client-types.js").UpdatePortalsWithIds<U> | undefined;
} & {
fieldData: Partial<T>;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & {
portalData?: import("./client-types.js").UpdatePortalsWithIds<U> | undefined;
} & {
fieldData: Partial<T>;
}) & WithLayout & FetchOptions) => Promise<CreateResponse>;
get: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & {
recordId: number | string;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & {
recordId: number | string;
}) & WithLayout & FetchOptions) => Promise<GetResponse<T, U>>;
update: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & {
portalData?: import("./client-types.js").UpdatePortalsWithIds<U> | undefined;
} & {
modId?: number;
} & {
fieldData: Partial<T>;
recordId: number | string;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & {
portalData?: import("./client-types.js").UpdatePortalsWithIds<U> | undefined;
} & {
modId?: number;
} & {
fieldData: Partial<T>;
recordId: number | string;
}) & WithLayout & FetchOptions) => Promise<UpdateResponse>;
delete: (args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & {
recordId: number | string;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & {
recordId: number | string;
}) & WithLayout & FetchOptions) => Promise<DeleteResponse>;
find: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & WithLayout & FetchOptions) => Promise<GetResponse<T, U>>;
findOne: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & WithLayout & FetchOptions) => Promise<GetResponseOne<T, U>>;
findFirst: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & WithLayout & FetchOptions) => Promise<GetResponseOne<T, U>>;
maybeFindFirst: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & {
/**
* If true, a find that returns no results will retun an empty array instead of throwing an error.
* @default false
*/
ignoreEmptyResult?: boolean;
} & WithLayout & FetchOptions) => Promise<GetResponseOne<T, U> | null>;
findAll: <T extends Td = Td, U extends Ud = Ud>(args: Opts["layout"] extends string ? (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & Partial<WithLayout> & FetchOptions : (import("./client-types.js").ScriptParams & import("./client-types.js").PortalRangesParams<U> & {
"layout.response"?: string;
dateformats?: "US" | "file_locale" | "ISO8601";
} & import("./client-types.js").RangeParams & {
sort?: import("./client-types.js").Sort<T> | import("./client-types.js").Sort<T>[] | undefined;
} & {
query: Query<T> | Query<T>[];
timeout?: number;
}) & WithLayout & FetchOptions) => Promise<FMRecord<T, U>[]>;
layoutMetadata: (args?: Opts["layout"] extends string ? {
timeout?: number;
} & Partial<WithLayout> & FetchOptions : {
timeout?: number;
} & WithLayout & FetchOptions) => Promise<import("./client-types.js").LayoutMetadataResponse>;
containerUpload: <T extends Td = Td>(args: Opts["layout"] extends string ? {
containerFieldName: keyof T;
containerFieldRepetition?: string | number;
file: Blob;
recordId: number | string;
modId?: number;
timeout?: number;
} & Partial<WithLayout> & FetchOptions : {
containerFieldName: keyof T;
containerFieldRepetition?: string | number;
file: Blob;
recordId: number | string;
modId?: number;
timeout?: number;
} & WithLayout & FetchOptions) => Promise<void>;
};
export default DataApi;
export { DataApi };
//# sourceMappingURL=client.d.ts.map