@jd-data-limited/easy-fm 3.2.7 → 4.0.0
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 +36 -24
- package/package.json +15 -8
- package/src/FMError.d.ts +1 -1
- package/src/FMError.js +7 -2
- package/src/FMError.ts +3 -3
- package/src/connection/FMHost.d.ts +3 -2
- package/src/connection/FMHost.js +37 -47
- package/src/connection/FMHost.ts +6 -6
- package/src/connection/HostBase.d.ts +1 -1
- package/src/connection/HostBase.js +1 -1
- package/src/connection/HostBase.ts +2 -4
- package/src/connection/database.d.ts +12 -9
- package/src/connection/database.js +93 -116
- package/src/connection/database.ts +79 -90
- package/src/connection/databaseBase.d.ts +5 -2
- package/src/connection/databaseBase.js +1 -1
- package/src/connection/databaseBase.ts +5 -4
- package/src/databaseStructure.d.ts +6 -0
- package/src/databaseStructure.js +4 -0
- package/src/databaseStructure.ts +12 -0
- package/src/index.d.ts +3 -6
- package/src/index.js +3 -5
- package/src/index.ts +4 -9
- package/src/layouts/layout.d.ts +5 -19
- package/src/layouts/layout.js +27 -69
- package/src/layouts/layout.ts +26 -65
- package/src/layouts/layoutBase.d.ts +4 -4
- package/src/layouts/layoutBase.js +1 -1
- package/src/layouts/layoutBase.ts +5 -5
- package/src/layouts/layoutInterface.d.ts +1 -1
- package/src/layouts/layoutInterface.js +1 -1
- package/src/layouts/layoutInterface.ts +2 -2
- package/src/layouts/layoutRecordManager.d.ts +5 -6
- package/src/layouts/layoutRecordManager.js +20 -39
- package/src/layouts/layoutRecordManager.ts +20 -41
- package/src/layouts/recordFieldsMap.d.ts +2 -2
- package/src/layouts/recordFieldsMap.js +1 -1
- package/src/layouts/recordFieldsMap.ts +3 -3
- package/src/models/apiResults.d.ts +103 -0
- package/src/models/apiResults.js +28 -0
- package/src/models/apiResults.ts +112 -0
- package/src/records/field.d.ts +3 -22
- package/src/records/field.js +4 -177
- package/src/records/field.ts +4 -187
- package/src/records/fieldBase.d.ts +30 -0
- package/src/records/fieldBase.js +154 -0
- package/src/records/fieldBase.ts +174 -0
- package/src/records/getOperations/recordGetOperation.d.ts +47 -11
- package/src/records/getOperations/recordGetOperation.js +144 -30
- package/src/records/getOperations/recordGetOperation.ts +172 -30
- package/src/records/layoutRecord.d.ts +8 -7
- package/src/records/layoutRecord.js +107 -153
- package/src/records/layoutRecord.ts +117 -141
- package/src/records/portal.d.ts +6 -5
- package/src/records/portal.js +4 -1
- package/src/records/portal.ts +7 -7
- package/src/records/portalBase.d.ts +5 -4
- package/src/records/portalBase.js +1 -1
- package/src/records/portalBase.ts +6 -6
- package/src/records/portalRecord.d.ts +6 -6
- package/src/records/portalRecord.js +5 -3
- package/src/records/portalRecord.ts +5 -5
- package/src/records/recordBase.d.ts +7 -12
- package/src/records/recordBase.js +12 -11
- package/src/records/recordBase.ts +10 -15
- package/src/types.d.ts +18 -19
- package/src/types.js +7 -1
- package/src/types.ts +20 -21
- package/.expo/README.md +0 -15
- package/.expo/settings.json +0 -8
- package/.idea/compiler.xml +0 -7
- package/.idea/copyright/JD_Data.xml +0 -6
- package/.idea/copyright/profiles_settings.xml +0 -7
- package/.idea/discord.xml +0 -7
- package/.idea/easy-fm.iml +0 -8
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -18
- package/.idea/vcs.xml +0 -6
- package/decs.d.ts +0 -7
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.LICENSE.txt +0 -3
- package/docs/classes/FileMakerConnection.md +0 -86
- package/docs/classes/layout.md +0 -0
- package/examples/test.js +0 -7
- package/fmErrors.json +0 -1010
- package/img.png +0 -0
- package/src/records/getOperations/find.d.ts +0 -15
- package/src/records/getOperations/find.js +0 -90
- package/src/records/getOperations/find.ts +0 -88
- package/src/records/getOperations/recordGetRange.d.ts +0 -13
- package/src/records/getOperations/recordGetRange.js +0 -95
- package/src/records/getOperations/recordGetRange.ts +0 -84
- package/src/records/portalRecordBase.d.ts +0 -4
- package/src/records/portalRecordBase.js +0 -6
- package/test.d.ts +0 -2
- package/test.js +0 -30
- package/test.ts +0 -33
- package/test2.d.ts +0 -1
- package/test2.js +0 -15
- package/tsconfig.json +0 -16
- package/webpack.config.cjs +0 -20
package/README.md
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
# easy-fm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [FileMaker Data API](https://help.claris.com/en/data-api-guide/content/index.html) client for NodeJS
|
|
4
4
|
|
|
5
5
|
easy-fm is a Node.js module that allows you to interact with
|
|
6
|
-
a [FileMaker database](https://www.claris.com/filemaker/) stored on
|
|
7
|
-
a [FileMaker server](https://www.claris.com/filemaker/server/)
|
|
6
|
+
a [FileMaker database](https://www.claris.com/filemaker/) stored on a [FileMaker server](https://www.claris.com/filemaker/server/)
|
|
8
7
|
or [FileMaker Cloud](https://store.claris.com/filemaker-cloud). This module interacts with your server using the
|
|
9
8
|
[FileMaker Data API](https://help.claris.com/en/data-api-guide/content/index.html).
|
|
10
9
|
<!-- TOC -->
|
|
10
|
+
|
|
11
11
|
* [easy-fm](#easy-fm)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
21
|
* [Field names](#field-names)
|
|
22
22
|
* [Portal names](#portal-names)
|
|
23
23
|
* [Typescript Implementation](#typescript-implementation)
|
|
24
|
+
|
|
24
25
|
<!-- TOC -->
|
|
26
|
+
|
|
25
27
|
## FileMaker setup instructions
|
|
26
28
|
|
|
27
29
|
1. Enable the FileMaker Data API from the server's admin console. This setting is located
|
|
@@ -34,7 +36,8 @@ or [FileMaker Cloud](https://store.claris.com/filemaker-cloud). This module inte
|
|
|
34
36
|
## Before you begin
|
|
35
37
|
|
|
36
38
|
- You need to know what your server's UTC time offset (in minutes) is.
|
|
37
|
-
- Running `0 - (new Date()).getTimezoneOffset()` in javascript will give you the UTC time offset for your current
|
|
39
|
+
- Running `0 - (new Date()).getTimezoneOffset()` in javascript will give you the UTC time offset for your current
|
|
40
|
+
timezone.
|
|
38
41
|
|
|
39
42
|
## Connecting to a database
|
|
40
43
|
|
|
@@ -77,26 +80,34 @@ One of (if not the) most common interactions you'll need to use is fetching reco
|
|
|
77
80
|
|
|
78
81
|
```javascript
|
|
79
82
|
let layout = database.getLayout("Your layout name")
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
let query = layout.records.list({
|
|
84
|
+
portals: {
|
|
85
|
+
test: {limit: 10, offset: 1} // Include results from the 'test' portal
|
|
86
|
+
},
|
|
87
|
+
limit: 10, // Limit result set to 10 records...
|
|
88
|
+
offset: 30 // ...starting from the 30th record
|
|
89
|
+
})
|
|
84
90
|
|
|
85
|
-
let records = await
|
|
91
|
+
let records = await query.fetch()
|
|
86
92
|
console.log(records)
|
|
87
93
|
```
|
|
88
94
|
|
|
89
95
|
### Searching for records
|
|
96
|
+
Searching for records uses the same syntax as above, but with additional steps to add your search parameters.
|
|
90
97
|
|
|
91
98
|
```javascript
|
|
92
99
|
let layout = database.getLayout("Your layout name")
|
|
93
|
-
let
|
|
100
|
+
let query = layout.records.list({
|
|
101
|
+
portals: {
|
|
102
|
+
test: {limit: 10, offset: 1} // Include results from the 'test' portal
|
|
103
|
+
},
|
|
104
|
+
limit: 10, // Limit result set to 10 records...
|
|
105
|
+
offset: 30 // ...starting from the 30th record
|
|
106
|
+
})
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
find_request.setOffset(30) // Starting from the 30th matching record
|
|
97
|
-
find_request.setLimit(10) // Fetch only 10 records
|
|
108
|
+
query.addRequest({"GroupID": "=abc"}) // Add a filter
|
|
98
109
|
|
|
99
|
-
let records = await
|
|
110
|
+
let records = await query.fetch()
|
|
100
111
|
console.log(records)
|
|
101
112
|
```
|
|
102
113
|
|
|
@@ -152,7 +163,8 @@ When interacting with FileMaker, it is important to remember how FileMaker field
|
|
|
152
163
|
|
|
153
164
|
> Please read this section carefully if you are working with portals
|
|
154
165
|
|
|
155
|
-
It is important to note that a portal's name **is not** the same as the name of the table that it links to. The name of
|
|
166
|
+
It is important to note that a portal's name **is not** the same as the name of the table that it links to. The name of
|
|
167
|
+
a
|
|
156
168
|
portal matches the object name it was assigned in FileMaker's layout editor.
|
|
157
169
|
|
|
158
170
|
> **NOTE**: When no name has been manually assigned to it, it will default to the name of the related table.
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jd-data-limited/easy-fm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"moment": "^2.29.4",
|
|
8
|
-
"node-fetch": "3.2.8",
|
|
9
|
-
"typescript": "^5.2.2",
|
|
10
|
-
"ytdl-core": "^4.11.4"
|
|
5
|
+
"follow-redirects": "^1.15.5",
|
|
6
|
+
"moment": "^2.29.4"
|
|
11
7
|
},
|
|
12
8
|
"type": "module",
|
|
13
9
|
"main": "src/index.js",
|
|
@@ -16,8 +12,11 @@
|
|
|
16
12
|
"url": "https://github.com/JD-Data-Limited/easy-fm",
|
|
17
13
|
"license": "SEE LICENSE IN LICENSE",
|
|
18
14
|
"description": "easy-fm is a Node.js module that allows you to interact with\r a [FileMaker database stored](https://www.claris.com/filemaker/) on\r a [FileMaker server](https://www.claris.com/filemaker/server/). This module interacts with your server using the\r [FileMaker Data API](https://help.claris.com/en/data-api-guide/content/index.html).",
|
|
15
|
+
"files": [
|
|
16
|
+
"./src/**/*"
|
|
17
|
+
],
|
|
19
18
|
"scripts": {
|
|
20
|
-
"test": "
|
|
19
|
+
"test": "node --test tests/login.js",
|
|
21
20
|
"build": "webpack"
|
|
22
21
|
},
|
|
23
22
|
"repository": {
|
|
@@ -34,7 +33,15 @@
|
|
|
34
33
|
"url": "https://github.com/JD-Data-Limited/easy-fm/issues"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
36
|
+
"@types/btoa": "^1.2.3",
|
|
37
|
+
"@types/events": "^3.0.0",
|
|
38
|
+
"@types/follow-redirects": "^1.14.4",
|
|
39
|
+
"dotenv": "^16.3.1",
|
|
40
|
+
"typescript": "^5.3.3",
|
|
37
41
|
"webpack": "^5.81.0",
|
|
38
42
|
"webpack-cli": "^5.0.2"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20.9.0"
|
|
39
46
|
}
|
|
40
47
|
}
|
package/src/FMError.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare class FMError extends Error {
|
|
|
8
8
|
readonly code: number;
|
|
9
9
|
readonly message: string;
|
|
10
10
|
readonly messages: string;
|
|
11
|
-
constructor(code:
|
|
11
|
+
constructor(code: string | number, httpStatus: number, res: any, trace?: Error);
|
|
12
12
|
}
|
package/src/FMError.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
2
|
+
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
export const errs = [
|
|
@@ -1013,10 +1013,15 @@ export const errs = [
|
|
|
1013
1013
|
}
|
|
1014
1014
|
];
|
|
1015
1015
|
export class FMError extends Error {
|
|
1016
|
+
httpStatus;
|
|
1017
|
+
res;
|
|
1018
|
+
code;
|
|
1019
|
+
message;
|
|
1020
|
+
messages;
|
|
1016
1021
|
constructor(code, httpStatus, res, trace) {
|
|
1017
1022
|
if (typeof code === "string")
|
|
1018
1023
|
code = parseInt(code);
|
|
1019
|
-
super(errs.find(err => err.e === code)
|
|
1024
|
+
super(errs.find(err => err.e === code)?.d || "Unknown error");
|
|
1020
1025
|
this.httpStatus = httpStatus;
|
|
1021
1026
|
this.res = res;
|
|
1022
1027
|
this.messages = res.messages;
|
package/src/FMError.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
2
|
+
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
@@ -1021,9 +1021,9 @@ export class FMError extends Error {
|
|
|
1021
1021
|
readonly message: string
|
|
1022
1022
|
readonly messages: string
|
|
1023
1023
|
|
|
1024
|
-
constructor(code, httpStatus, res, trace?: Error) {
|
|
1024
|
+
constructor(code: string | number, httpStatus: number, res: any, trace?: Error) {
|
|
1025
1025
|
if (typeof code === "string") code = parseInt(code)
|
|
1026
|
-
super(errs.find(err => err.e === code)
|
|
1026
|
+
super(errs.find(err => err.e === code)?.d || "Unknown error");
|
|
1027
1027
|
this.httpStatus = httpStatus
|
|
1028
1028
|
this.res = res
|
|
1029
1029
|
this.messages = res.messages
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Database } from "./database.js";
|
|
2
2
|
import { HostBase } from "./HostBase.js";
|
|
3
|
-
import { databaseOptionsWithExternalSources,
|
|
3
|
+
import { databaseOptionsWithExternalSources, FMHostMetadata, loginOptionsClaris, loginOptionsFileMaker, loginOptionsOAuth } from "../types.js";
|
|
4
|
+
import { DatabaseStructure } from "../databaseStructure.js";
|
|
4
5
|
export default class FMHost implements HostBase {
|
|
5
6
|
readonly hostname: string;
|
|
6
7
|
readonly timezoneOffset: number;
|
|
@@ -9,5 +10,5 @@ export default class FMHost implements HostBase {
|
|
|
9
10
|
constructor(_hostname: string, timezoneOffset?: number, verify?: boolean);
|
|
10
11
|
listDatabases(credentials?: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris): Promise<any>;
|
|
11
12
|
database<T extends DatabaseStructure>(data: databaseOptionsWithExternalSources): Database<T>;
|
|
12
|
-
getMetadata(): Promise<
|
|
13
|
+
getMetadata(): Promise<FMHostMetadata>;
|
|
13
14
|
}
|
package/src/connection/FMHost.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
2
|
+
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
4
|
import { generateAuthorizationHeaders } from "./generateAuthorizationHeaders.js";
|
|
14
|
-
import fetch from "node-fetch";
|
|
15
5
|
import { FMError } from "../FMError.js";
|
|
16
6
|
import { Database } from "./database.js";
|
|
17
7
|
export default class FMHost {
|
|
8
|
+
hostname;
|
|
9
|
+
timezoneOffset;
|
|
10
|
+
verify;
|
|
11
|
+
metadata;
|
|
18
12
|
constructor(_hostname, timezoneOffset = 0 - (new Date()).getTimezoneOffset(), verify = true) {
|
|
19
13
|
if (!(/^https?:\/\//).test(_hostname))
|
|
20
14
|
throw "hostname MUST begin with either http:// or https://";
|
|
@@ -22,47 +16,43 @@ export default class FMHost {
|
|
|
22
16
|
this.timezoneOffset = timezoneOffset;
|
|
23
17
|
this.verify = verify;
|
|
24
18
|
}
|
|
25
|
-
listDatabases(credentials) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
headers
|
|
34
|
-
});
|
|
35
|
-
let data = yield _fetch.json();
|
|
36
|
-
// console.log(data.messages[0])
|
|
37
|
-
if (data.messages[0].code === "0") {
|
|
38
|
-
return data.response.databases;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
throw new FMError(data.messages[0].code, data.status, data);
|
|
43
|
-
}
|
|
19
|
+
async listDatabases(credentials) {
|
|
20
|
+
let headers = {};
|
|
21
|
+
if (credentials) {
|
|
22
|
+
headers = generateAuthorizationHeaders(credentials);
|
|
23
|
+
}
|
|
24
|
+
let _fetch = await fetch(`${this.hostname}/fmi/data/v2/databases`, {
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers
|
|
44
27
|
});
|
|
28
|
+
let data = await _fetch.json();
|
|
29
|
+
// console.log(data.messages[0])
|
|
30
|
+
if (data.messages[0].code === "0") {
|
|
31
|
+
return data.response.databases;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
throw new FMError(data.messages[0].code, data.status, data);
|
|
36
|
+
}
|
|
45
37
|
}
|
|
46
38
|
database(data) {
|
|
47
39
|
return new Database(this, data);
|
|
48
40
|
}
|
|
49
|
-
getMetadata() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
method: "GET",
|
|
55
|
-
});
|
|
56
|
-
let data = yield _fetch.json();
|
|
57
|
-
// console.log(data.messages[0])
|
|
58
|
-
if (data.messages[0].code === "0") {
|
|
59
|
-
this.metadata = data.response;
|
|
60
|
-
return data.response;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
throw new FMError(data.messages[0].code, data.status, data);
|
|
65
|
-
}
|
|
41
|
+
async getMetadata() {
|
|
42
|
+
if (this.metadata)
|
|
43
|
+
return this.metadata;
|
|
44
|
+
let _fetch = await fetch(`${this.hostname}/fmi/data/v2/productInfo`, {
|
|
45
|
+
method: "GET",
|
|
66
46
|
});
|
|
47
|
+
let data = await _fetch.json();
|
|
48
|
+
// console.log(data.messages[0])
|
|
49
|
+
if (data.messages[0].code === "0") {
|
|
50
|
+
this.metadata = data.response;
|
|
51
|
+
return data.response;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
throw new FMError(data.messages[0].code, data.status, data);
|
|
56
|
+
}
|
|
67
57
|
}
|
|
68
58
|
}
|
package/src/connection/FMHost.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
2
|
+
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {generateAuthorizationHeaders} from "./generateAuthorizationHeaders.js";
|
|
6
|
-
import fetch from "node-fetch";
|
|
7
6
|
import {FMError} from "../FMError.js";
|
|
8
7
|
import {Database} from "./database.js";
|
|
9
8
|
import {HostBase} from "./HostBase.js"
|
|
10
9
|
import {
|
|
11
|
-
databaseOptionsWithExternalSources,
|
|
12
|
-
fileMakerResponse,
|
|
10
|
+
databaseOptionsWithExternalSources,
|
|
13
11
|
FMHostMetadata,
|
|
14
12
|
loginOptionsClaris,
|
|
15
13
|
loginOptionsFileMaker,
|
|
16
14
|
loginOptionsOAuth
|
|
17
15
|
} from "../types.js";
|
|
16
|
+
import {ApiResults} from "../models/apiResults.js";
|
|
17
|
+
import {DatabaseStructure} from "../databaseStructure.js";
|
|
18
18
|
|
|
19
19
|
export default class FMHost implements HostBase {
|
|
20
20
|
readonly hostname: string
|
|
@@ -39,7 +39,7 @@ export default class FMHost implements HostBase {
|
|
|
39
39
|
method: "GET",
|
|
40
40
|
headers
|
|
41
41
|
})
|
|
42
|
-
let data = await _fetch.json() as
|
|
42
|
+
let data = await _fetch.json() as ApiResults<{databases: any}>
|
|
43
43
|
// console.log(data.messages[0])
|
|
44
44
|
|
|
45
45
|
if (data.messages[0].code === "0") {
|
|
@@ -61,7 +61,7 @@ export default class FMHost implements HostBase {
|
|
|
61
61
|
let _fetch = await fetch(`${this.hostname}/fmi/data/v2/productInfo`, {
|
|
62
62
|
method: "GET",
|
|
63
63
|
})
|
|
64
|
-
let data = await _fetch.json() as
|
|
64
|
+
let data = await _fetch.json() as ApiResults<FMHostMetadata>
|
|
65
65
|
// console.log(data.messages[0])
|
|
66
66
|
|
|
67
67
|
if (data.messages[0].code === "0") {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
2
|
+
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
FMHostMetadata
|
|
7
|
-
} from "../types";
|
|
5
|
+
import {FMHostMetadata} from "../types.js";
|
|
8
6
|
|
|
9
7
|
export interface HostBase {
|
|
10
8
|
readonly hostname: string
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
3
|
import { EventEmitter } from "events";
|
|
3
|
-
import { Request } from "node-fetch";
|
|
4
4
|
import { LayoutInterface } from "../layouts/layoutInterface.js";
|
|
5
5
|
import { Layout } from "../layouts/layout.js";
|
|
6
|
-
import
|
|
7
|
-
import { databaseOptionsWithExternalSources, DatabaseStructure, Script } from "../types.js";
|
|
6
|
+
import { databaseOptionsWithExternalSources, Script } from "../types.js";
|
|
8
7
|
import { HostBase } from "./HostBase.js";
|
|
9
|
-
import { DatabaseBase } from "./databaseBase";
|
|
8
|
+
import { DatabaseBase } from "./databaseBase.js";
|
|
9
|
+
import { ApiResults } from "../models/apiResults.js";
|
|
10
|
+
import { DatabaseStructure } from "../databaseStructure.js";
|
|
11
|
+
import { IncomingMessage } from "http";
|
|
10
12
|
export declare class Database<T extends DatabaseStructure> extends EventEmitter implements DatabaseBase {
|
|
11
13
|
private _token;
|
|
12
14
|
readonly host: HostBase;
|
|
@@ -16,14 +18,15 @@ export declare class Database<T extends DatabaseStructure> extends EventEmitter
|
|
|
16
18
|
constructor(host: HostBase, conn: databaseOptionsWithExternalSources);
|
|
17
19
|
private generateExternalSourceLogin;
|
|
18
20
|
logout(): Promise<void>;
|
|
19
|
-
login(): Promise<
|
|
21
|
+
login(): Promise<any>;
|
|
20
22
|
get token(): any;
|
|
21
23
|
get endpoint(): string;
|
|
22
|
-
apiRequest<T = any>(url: string | Request, options?: any, autoRelogin?: boolean): Promise<T
|
|
23
|
-
|
|
24
|
+
apiRequest<T = any>(url: string | Request, options?: any, autoRelogin?: boolean): Promise<ApiResults<T>>;
|
|
25
|
+
listLayouts(): Promise<Layout<LayoutInterface>[]>;
|
|
26
|
+
getLayout<R extends keyof T["layouts"]>(name: R): Layout<T["layouts"][R]>;
|
|
24
27
|
getLayout<R extends LayoutInterface>(name: string): Layout<R>;
|
|
25
28
|
setGlobals(globalFields: any): Promise<void>;
|
|
26
29
|
script(name: any, parameter?: string): Script;
|
|
27
30
|
_tokenExpired(): void;
|
|
28
|
-
|
|
31
|
+
streamURL(url: string): Promise<IncomingMessage>;
|
|
29
32
|
}
|