@jd-data-limited/easy-fm 3.1.6 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/package.json +1 -1
- package/src/connection/database.d.ts +2 -0
- package/src/connection/database.ts +6 -2
package/README.md
CHANGED
|
@@ -7,7 +7,21 @@ a [FileMaker database](https://www.claris.com/filemaker/) stored on
|
|
|
7
7
|
a [FileMaker server](https://www.claris.com/filemaker/server/)
|
|
8
8
|
or [FileMaker Cloud](https://store.claris.com/filemaker-cloud). This module interacts with your server using the
|
|
9
9
|
[FileMaker Data API](https://help.claris.com/en/data-api-guide/content/index.html).
|
|
10
|
-
|
|
10
|
+
<!-- TOC -->
|
|
11
|
+
* [easy-fm](#easy-fm)
|
|
12
|
+
* [FileMaker setup instructions](#filemaker-setup-instructions)
|
|
13
|
+
* [Before you begin](#before-you-begin)
|
|
14
|
+
* [Connecting to a database](#connecting-to-a-database)
|
|
15
|
+
* [Getting records](#getting-records)
|
|
16
|
+
* [Fetch a range of records](#fetch-a-range-of-records)
|
|
17
|
+
* [Searching for records](#searching-for-records)
|
|
18
|
+
* [Fetch a record using its record ID (NOT RECOMMENDED)](#fetch-a-record-using-its-record-id-not-recommended)
|
|
19
|
+
* [Create a record](#create-a-record)
|
|
20
|
+
* [Modify a record](#modify-a-record)
|
|
21
|
+
* [Field names](#field-names)
|
|
22
|
+
* [Portal names](#portal-names)
|
|
23
|
+
* [Typescript Implementation](#typescript-implementation)
|
|
24
|
+
<!-- TOC -->
|
|
11
25
|
## FileMaker setup instructions
|
|
12
26
|
|
|
13
27
|
1. Enable the FileMaker Data API from the server's admin console. This setting is located
|
|
@@ -20,7 +34,7 @@ or [FileMaker Cloud](https://store.claris.com/filemaker-cloud). This module inte
|
|
|
20
34
|
## Before you begin
|
|
21
35
|
|
|
22
36
|
- You need to know what your server's UTC time offset (in minutes) is.
|
|
23
|
-
- Running `0 - (new Date()).getTimezoneOffset()` in javascript will the UTC time offset for your current timezone.
|
|
37
|
+
- Running `0 - (new Date()).getTimezoneOffset()` in javascript will give you the UTC time offset for your current timezone.
|
|
24
38
|
|
|
25
39
|
## Connecting to a database
|
|
26
40
|
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { EventEmitter } from "events";
|
|
4
4
|
import { Request } from "node-fetch";
|
|
5
|
+
import { LayoutInterface } from "../layouts/layoutInterface.js";
|
|
5
6
|
import { Layout } from "../layouts/layout.js";
|
|
6
7
|
import * as http from "http";
|
|
7
8
|
import { databaseOptionsWithExternalSources, DatabaseStructure, Script } from "../types.js";
|
|
@@ -21,6 +22,7 @@ export declare class Database<T extends DatabaseStructure> extends EventEmitter
|
|
|
21
22
|
get endpoint(): string;
|
|
22
23
|
apiRequest<T = any>(url: string | Request, options?: any, autoRelogin?: boolean): Promise<T>;
|
|
23
24
|
getLayout<R extends string>(name: R): Layout<T["layouts"][R]>;
|
|
25
|
+
getLayout<R extends LayoutInterface>(name: string): Layout<R>;
|
|
24
26
|
setGlobals(globalFields: any): Promise<void>;
|
|
25
27
|
script(name: any, parameter?: string): Script;
|
|
26
28
|
_tokenExpired(): void;
|
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
import {HostBase} from "./HostBase.js"
|
|
22
22
|
import {DatabaseBase} from "./databaseBase";
|
|
23
23
|
|
|
24
|
+
type GetLayoutReturnType<T extends DatabaseStructure, R extends LayoutInterface | string> = R extends string ? T["layouts"][R] : R
|
|
25
|
+
|
|
24
26
|
export class Database<T extends DatabaseStructure> extends EventEmitter implements DatabaseBase {
|
|
25
27
|
private _token: any;
|
|
26
28
|
readonly host: HostBase;
|
|
@@ -143,8 +145,10 @@ export class Database<T extends DatabaseStructure> extends EventEmitter implemen
|
|
|
143
145
|
return (data as any)
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
getLayout<R extends string>(name: R): Layout<T["layouts"][R]>
|
|
147
|
-
|
|
148
|
+
getLayout<R extends string>(name: R): Layout<T["layouts"][R]>
|
|
149
|
+
getLayout<R extends LayoutInterface>(name: string): Layout<R>
|
|
150
|
+
getLayout(name: string): Layout<LayoutInterface> {
|
|
151
|
+
return new Layout<LayoutInterface>(this, name)
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
setGlobals(globalFields): Promise<void> {
|