@jd-data-limited/easy-fm 4.1.5 → 4.1.8

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.
Files changed (86) hide show
  1. package/dist/bin/cli.js +17 -0
  2. package/dist/bin/generateTypes.js +161 -0
  3. package/{src → dist}/connection/FMHost.js +3 -2
  4. package/{src → dist}/connection/database.d.ts +0 -1
  5. package/{src → dist}/connection/database.js +22 -39
  6. package/dist/index.d.ts +18 -0
  7. package/dist/index.js +16 -0
  8. package/{src → dist}/records/field.d.ts +0 -1
  9. package/{src → dist}/records/getOperations/recordGetOperation.d.ts +6 -2
  10. package/{src → dist}/records/getOperations/recordGetOperation.js +9 -5
  11. package/{src → dist}/records/layoutRecord.d.ts +1 -1
  12. package/{src → dist}/records/layoutRecord.js +9 -7
  13. package/{src → dist}/records/recordBase.d.ts +0 -1
  14. package/{src → dist}/types.d.ts +12 -2
  15. package/package.json +23 -12
  16. package/src/FMError.ts +0 -1033
  17. package/src/bin/cli.js +0 -17
  18. package/src/bin/cli.ts +0 -22
  19. package/src/bin/generateTypes.d.ts +0 -1
  20. package/src/bin/generateTypes.js +0 -161
  21. package/src/bin/generateTypes.ts +0 -189
  22. package/src/connection/FMHost.ts +0 -123
  23. package/src/connection/HostBase.ts +0 -18
  24. package/src/connection/database.ts +0 -257
  25. package/src/connection/databaseBase.ts +0 -19
  26. package/src/connection/generateAuthorizationHeaders.ts +0 -32
  27. package/src/connection/requestHoldable.d.ts +0 -10
  28. package/src/connection/requestHoldable.js +0 -44
  29. package/src/databaseStructure.ts +0 -10
  30. package/src/index.d.ts +0 -18
  31. package/src/index.js +0 -18
  32. package/src/index.ts +0 -47
  33. package/src/layouts/layout.ts +0 -66
  34. package/src/layouts/layoutBase.ts +0 -16
  35. package/src/layouts/layoutInterface.ts +0 -13
  36. package/src/layouts/layoutRecordManager.ts +0 -66
  37. package/src/layouts/recordFieldsMap.ts +0 -7
  38. package/src/models/apiResults.ts +0 -110
  39. package/src/records/field.ts +0 -235
  40. package/src/records/getOperations/recordGetOperation.ts +0 -268
  41. package/src/records/layoutRecord.ts +0 -246
  42. package/src/records/layoutRecordBase.ts +0 -10
  43. package/src/records/portal.ts +0 -43
  44. package/src/records/portalBase.ts +0 -14
  45. package/src/records/portalRecord.ts +0 -52
  46. package/src/records/recordBase.ts +0 -91
  47. package/src/types.ts +0 -150
  48. package/src/utils/query.ts +0 -59
  49. /package/{src → dist}/FMError.d.ts +0 -0
  50. /package/{src → dist}/FMError.js +0 -0
  51. /package/{src → dist}/bin/cli.d.ts +0 -0
  52. /package/{src/bin/dist → dist}/bin/generateTypes.d.ts +0 -0
  53. /package/{src → dist}/connection/FMHost.d.ts +0 -0
  54. /package/{src → dist}/connection/HostBase.d.ts +0 -0
  55. /package/{src → dist}/connection/HostBase.js +0 -0
  56. /package/{src → dist}/connection/databaseBase.d.ts +0 -0
  57. /package/{src → dist}/connection/databaseBase.js +0 -0
  58. /package/{src → dist}/connection/generateAuthorizationHeaders.d.ts +0 -0
  59. /package/{src → dist}/connection/generateAuthorizationHeaders.js +0 -0
  60. /package/{src → dist}/databaseStructure.d.ts +0 -0
  61. /package/{src → dist}/databaseStructure.js +0 -0
  62. /package/{src → dist}/layouts/layout.d.ts +0 -0
  63. /package/{src → dist}/layouts/layout.js +0 -0
  64. /package/{src → dist}/layouts/layoutBase.d.ts +0 -0
  65. /package/{src → dist}/layouts/layoutBase.js +0 -0
  66. /package/{src → dist}/layouts/layoutInterface.d.ts +0 -0
  67. /package/{src → dist}/layouts/layoutInterface.js +0 -0
  68. /package/{src → dist}/layouts/layoutRecordManager.d.ts +0 -0
  69. /package/{src → dist}/layouts/layoutRecordManager.js +0 -0
  70. /package/{src → dist}/layouts/recordFieldsMap.d.ts +0 -0
  71. /package/{src → dist}/layouts/recordFieldsMap.js +0 -0
  72. /package/{src → dist}/models/apiResults.d.ts +0 -0
  73. /package/{src → dist}/models/apiResults.js +0 -0
  74. /package/{src → dist}/records/field.js +0 -0
  75. /package/{src → dist}/records/layoutRecordBase.d.ts +0 -0
  76. /package/{src → dist}/records/layoutRecordBase.js +0 -0
  77. /package/{src → dist}/records/portal.d.ts +0 -0
  78. /package/{src → dist}/records/portal.js +0 -0
  79. /package/{src → dist}/records/portalBase.d.ts +0 -0
  80. /package/{src → dist}/records/portalBase.js +0 -0
  81. /package/{src → dist}/records/portalRecord.d.ts +0 -0
  82. /package/{src → dist}/records/portalRecord.js +0 -0
  83. /package/{src → dist}/records/recordBase.js +0 -0
  84. /package/{src → dist}/types.js +0 -0
  85. /package/{src → dist}/utils/query.d.ts +0 -0
  86. /package/{src → dist}/utils/query.js +0 -0
package/src/bin/cli.js DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * Copyright (c) 2024. See LICENSE file for more information
4
- */
5
- import { Command } from "commander";
6
- import { generateTypesCLI } from "./generateTypes.js";
7
- const program = new Command();
8
- program
9
- .name("easyfm")
10
- .description("A NodeJS wrapper for the FileMaker Data CLI");
11
- program
12
- .command("generate-types")
13
- .description("Automatically generate layout interfaces from your database")
14
- .action(() => {
15
- generateTypesCLI();
16
- });
17
- program.parse(process.argv);
package/src/bin/cli.ts DELETED
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * Copyright (c) 2024. See LICENSE file for more information
4
- */
5
-
6
- import {Command} from "commander"
7
- import {generateTypesCLI} from "./generateTypes.js";
8
-
9
- const program = new Command()
10
-
11
- program
12
- .name("easyfm")
13
- .description("A NodeJS wrapper for the FileMaker Data CLI")
14
-
15
- program
16
- .command("generate-types")
17
- .description("Automatically generate layout interfaces from your database")
18
- .action(() => {
19
- generateTypesCLI()
20
- })
21
-
22
- program.parse(process.argv)
@@ -1 +0,0 @@
1
- export declare function generateTypesCLI(): Promise<void>;
@@ -1,161 +0,0 @@
1
- /*
2
- * Copyright (c) 2024. See LICENSE file for more information
3
- */
4
- import { ApiFieldResultTypes } from "../models/apiResults.js";
5
- import inquirer from 'inquirer';
6
- import FMHost from "../connection/FMHost.js";
7
- import * as fs from "fs";
8
- function sub(str) {
9
- return str
10
- .replace(/[^a-zA-Z0-9_]/g, "") // Remove non-alphanumeric characters
11
- .replace(/^[0-9]+/g, ''); // Removing leading numbers
12
- }
13
- function generateFieldType(field) {
14
- switch (field.result) {
15
- case ApiFieldResultTypes.TEXT:
16
- return "Field<string>";
17
- case ApiFieldResultTypes.CONTAINER:
18
- return "Field<Container>";
19
- case ApiFieldResultTypes.DATE:
20
- return "Field<Date>";
21
- case ApiFieldResultTypes.NUMBER:
22
- return "Field<number>";
23
- case ApiFieldResultTypes.TIME:
24
- return "Field<Date>";
25
- case ApiFieldResultTypes.TIMESTAMP:
26
- return "Field<Date>";
27
- }
28
- }
29
- function processFieldsChunk(fields) {
30
- let existing_fields = [];
31
- fields = fields.filter(field => {
32
- if (existing_fields.includes(field.name))
33
- return false;
34
- existing_fields.push(field.name);
35
- return true;
36
- });
37
- return fields.map(field => {
38
- return JSON.stringify(field.name) + ": " + generateFieldType(field);
39
- });
40
- }
41
- function camelToSnakeCase(str) {
42
- return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
43
- }
44
- function safeStringInjection(str, ...args) {
45
- let result = "";
46
- for (let i = 0; i < str.length; i++) {
47
- result += str[i];
48
- if (i < args.length) {
49
- result += JSON.stringify(args[i].toString());
50
- }
51
- }
52
- return result;
53
- }
54
- export async function generateTypesCLI() {
55
- process.stdout.write('\x1Bc');
56
- console.log("For this tool to work, you are required to have access to an account on the target database.\n" +
57
- "This account must have the fmrest extended privilege enabled.\n" +
58
- "This tool can only export type interfaces for layouts that the given account has access to.");
59
- console.log("\n");
60
- const data = await inquirer.prompt([
61
- {
62
- type: "input",
63
- name: "hostname",
64
- message: "The IP address/domain of your FileMaker server (must start with either http:// or https://)",
65
- validate(input) {
66
- return input.startsWith("http://") || input.startsWith("https://") || "Please enter a valid IP address/domain starting with http:// or https://";
67
- }
68
- },
69
- {
70
- type: "number",
71
- name: "timezoneOffset",
72
- message: "Server timezone offset (minutes)",
73
- default: 0 - (new Date()).getTimezoneOffset()
74
- },
75
- {
76
- type: "confirm",
77
- name: "verify",
78
- default: true,
79
- message: "Verify your server's identity",
80
- when(previousAnswers) {
81
- return previousAnswers.hostname.startsWith("https://");
82
- }
83
- },
84
- {
85
- type: "input",
86
- name: "database",
87
- message: "Database filename"
88
- },
89
- {
90
- type: "input",
91
- name: "username",
92
- message: "Database username"
93
- },
94
- {
95
- type: "password",
96
- name: "password",
97
- message: "Database password",
98
- mask: "*"
99
- }
100
- ]);
101
- const HOST = new FMHost(data.hostname, data.timezoneOffset, data.verify);
102
- const DATABASE = HOST.database({
103
- database: data.database,
104
- credentials: {
105
- method: "filemaker",
106
- username: data.username,
107
- password: data.password
108
- },
109
- externalSources: []
110
- });
111
- await DATABASE.login();
112
- // Create file write stream
113
- const stream = fs.createWriteStream("./types.ts");
114
- let layouts = await DATABASE.listLayouts();
115
- stream.write(`import FMHost, {Container, FieldBase, LayoutInterface, Portal} from "@jd-data-limited/easy-fm";\n`);
116
- stream.write("// " + layouts.length + " layouts found\n\n");
117
- let layoutInterfaces = new Map();
118
- for (let layout of layouts) {
119
- let substituteName = sub(layout.name);
120
- if (!substituteName)
121
- continue;
122
- console.log(substituteName);
123
- let metadata = await layout.getLayoutMeta();
124
- let fields = processFieldsChunk(metadata.fieldMetaData);
125
- let portals = metadata.portalMetaData;
126
- let portalsProcessed = Object.keys(portals).map(portalName => {
127
- return `${JSON.stringify(portalName)}: Portal<{${processFieldsChunk(portals[portalName])}}>`;
128
- });
129
- let interfaceName = substituteName + "LayoutInterface";
130
- layoutInterfaces.set(layout.name, {
131
- interfaceName,
132
- interface: `export interface ${interfaceName} extends LayoutInterface {
133
- fields: {${fields.join(",\n ")}},
134
- portals: {${portalsProcessed.join(",\n ")}}
135
- }`
136
- });
137
- }
138
- let layoutInterfaceLinks = [];
139
- for (let layout of layoutInterfaces) {
140
- layoutInterfaceLinks.push([
141
- `${JSON.stringify(layout[0])}: ${layout[1].interfaceName}`,
142
- `${sub(camelToSnakeCase(layout[0]).toUpperCase().replace(" ", "_"))}: HOST.getLayout<${layout[1].interfaceName}>(${JSON.stringify(layout[0])})`
143
- ]);
144
- }
145
- stream.write(safeStringInjection `const HOST = new FMHost(${data.hostname}, ${data.timezoneOffset}, ${data.verify});`);
146
- stream.write(`HOST.database<{layouts:{${layoutInterfaceLinks.map(i => i[0]).join(",")}}}>();`);
147
- stream.write("\n\n");
148
- stream.write(`const LAYOUTS = {${layoutInterfaceLinks.map(i => i[1]).join(",")}};`);
149
- for (let layout of layoutInterfaces) {
150
- stream.write("\n\n");
151
- stream.write(layout[1].interface + ";");
152
- }
153
- // StructureKind
154
- //
155
- // const project = new Project({
156
- // tsConfigFilePath: "../tsconfig.json"
157
- // })
158
- // project.resolveSourceFileDependencies()
159
- await DATABASE.logout();
160
- console.log("DONE! Wrote database types to ./types.ts");
161
- }
@@ -1,189 +0,0 @@
1
- /*
2
- * Copyright (c) 2024. See LICENSE file for more information
3
- */
4
-
5
- import {ApiFieldMetadata, ApiFieldResultTypes} from "../models/apiResults.js";
6
- import inquirer from 'inquirer';
7
- import FMHost from "../connection/FMHost.js";
8
- import * as fs from "fs";
9
-
10
- function sub(str: string) {
11
- return str
12
- .replace(/[^a-zA-Z0-9_]/g, "") // Remove non-alphanumeric characters
13
- .replace(/^[0-9]+/g, '') // Removing leading numbers
14
- }
15
-
16
- function generateFieldType(field: ApiFieldMetadata) {
17
- switch (field.result) {
18
- case ApiFieldResultTypes.TEXT:
19
- return "Field<string>"
20
- case ApiFieldResultTypes.CONTAINER:
21
- return "Field<Container>"
22
- case ApiFieldResultTypes.DATE:
23
- return "Field<Date>"
24
- case ApiFieldResultTypes.NUMBER:
25
- return "Field<number>"
26
- case ApiFieldResultTypes.TIME:
27
- return "Field<Date>"
28
- case ApiFieldResultTypes.TIMESTAMP:
29
- return "Field<Date>"
30
- }
31
- }
32
-
33
- function processFieldsChunk(fields: ApiFieldMetadata[]) {
34
- let existing_fields: string[] = []
35
- fields = fields.filter(field => {
36
- if (existing_fields.includes(field.name)) return false
37
- existing_fields.push(field.name)
38
- return true
39
- })
40
-
41
- return fields.map(field => {
42
- return JSON.stringify(field.name) + ": " + generateFieldType(field)
43
- })
44
- }
45
-
46
- function camelToSnakeCase(str: string) {
47
- return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
48
- }
49
-
50
- function safeStringInjection(str: TemplateStringsArray, ...args: {toString(): string}[]) {
51
- let result = "";
52
- for (let i = 0; i < str.length; i++) {
53
- result += str[i];
54
- if (i < args.length) {
55
- result += JSON.stringify(args[i].toString());
56
- }
57
- }
58
- return result;
59
- }
60
-
61
- export async function generateTypesCLI() {
62
- process.stdout.write('\x1Bc');
63
- console.log("For this tool to work, you are required to have access to an account on the target database.\n" +
64
- "This account must have the fmrest extended privilege enabled.\n" +
65
- "This tool can only export type interfaces for layouts that the given account has access to.")
66
- console.log("\n")
67
-
68
- const data = await inquirer.prompt([
69
- {
70
- type: "input",
71
- name: "hostname",
72
- message: "The IP address/domain of your FileMaker server (must start with either http:// or https://)",
73
- validate(input: any): boolean | string | Promise<boolean | string> {
74
- return input.startsWith("http://") || input.startsWith("https://") || "Please enter a valid IP address/domain starting with http:// or https://";
75
- }
76
- },
77
- {
78
- type: "number",
79
- name: "timezoneOffset",
80
- message: "Server timezone offset (minutes)",
81
- default: 0 - (new Date()).getTimezoneOffset()
82
- },
83
- {
84
- type: "confirm",
85
- name: "verify",
86
- default: true,
87
- message: "Verify your server's identity",
88
- when(previousAnswers) {
89
- return previousAnswers.hostname.startsWith("https://")
90
- }
91
- },
92
- {
93
- type: "input",
94
- name: "database",
95
- message: "Database filename"
96
- },
97
- {
98
- type: "input",
99
- name: "username",
100
- message: "Database username"
101
- },
102
- {
103
- type: "password",
104
- name: "password",
105
- message: "Database password",
106
- mask: "*"
107
- }
108
- ])
109
-
110
- const HOST = new FMHost(data.hostname, data.timezoneOffset, data.verify)
111
- const DATABASE = HOST.database({
112
- database: data.database,
113
- credentials: {
114
- method: "filemaker",
115
- username: data.username,
116
- password: data.password
117
- },
118
- externalSources: []
119
- })
120
-
121
- await DATABASE.login()
122
- // Create file write stream
123
- const stream = fs.createWriteStream("./types.ts")
124
- let layouts = await DATABASE.listLayouts()
125
-
126
- stream.write(`import FMHost, {Container, FieldBase, LayoutInterface, Portal} from "@jd-data-limited/easy-fm";\n`)
127
- stream.write("// " + layouts.length + " layouts found\n\n")
128
-
129
- let layoutInterfaces = new Map<string, {
130
- interfaceName: string,
131
- interface: string
132
- }>()
133
- for (let layout of layouts) {
134
- let substituteName = sub(layout.name)
135
- if (!substituteName) continue
136
- console.log(substituteName)
137
- let metadata = await layout.getLayoutMeta()
138
- let fields = processFieldsChunk(metadata.fieldMetaData)
139
-
140
- let portals = metadata.portalMetaData
141
- let portalsProcessed = Object.keys(portals).map(portalName => {
142
- return `${JSON.stringify(portalName)}: Portal<{${processFieldsChunk(
143
- portals[portalName]
144
- )}}>`
145
- })
146
-
147
- let interfaceName = substituteName + "LayoutInterface"
148
- layoutInterfaces.set(layout.name, {
149
- interfaceName,
150
- interface: `export interface ${interfaceName} extends LayoutInterface {
151
- fields: {${fields.join(",\n ")}},
152
- portals: {${portalsProcessed.join(",\n ")}}
153
- }`
154
- })
155
- }
156
-
157
- let layoutInterfaceLinks: [string, string][] = []
158
- for (let layout of layoutInterfaces) {
159
- layoutInterfaceLinks.push([
160
- `${JSON.stringify(layout[0])}: ${layout[1].interfaceName}`,
161
- `${sub(camelToSnakeCase(layout[0]).toUpperCase().replace(" ", "_"))}: HOST.getLayout<${layout[1].interfaceName}>(${JSON.stringify(layout[0])})`
162
- ])
163
- }
164
-
165
- stream.write(safeStringInjection`const HOST = new FMHost(${data.hostname}, ${data.timezoneOffset}, ${data.verify});`)
166
- stream.write(`HOST.database<{layouts:{${
167
- layoutInterfaceLinks.map(i => i[0]).join(",")
168
- }}}>();`)
169
-
170
- stream.write("\n\n")
171
- stream.write(`const LAYOUTS = {${
172
- layoutInterfaceLinks.map(i => i[1]).join(",")
173
- }};`)
174
-
175
- for (let layout of layoutInterfaces) {
176
- stream.write("\n\n")
177
- stream.write(layout[1].interface + ";")
178
- }
179
-
180
- // StructureKind
181
- //
182
- // const project = new Project({
183
- // tsConfigFilePath: "../tsconfig.json"
184
- // })
185
- // project.resolveSourceFileDependencies()
186
-
187
- await DATABASE.logout()
188
- console.log("DONE! Wrote database types to ./types.ts")
189
- }
@@ -1,123 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2024. See LICENSE file for more information
3
- */
4
-
5
- import {generateAuthorizationHeaders} from './generateAuthorizationHeaders.js'
6
- import {FMError} from '../FMError.js'
7
- import {Database} from './database.js'
8
- import {type HostBase} from './HostBase.js'
9
- import {
10
- type databaseOptionsWithExternalSources,
11
- type FMHostMetadata,
12
- type loginOptionsClaris,
13
- type loginOptionsFileMaker,
14
- type loginOptionsOAuth
15
- } from '../types.js'
16
- import {type ApiResults} from '../models/apiResults.js'
17
- import {type DatabaseStructure} from '../databaseStructure.js'
18
- import {type Moment} from 'moment'
19
-
20
- /**
21
- * Represents a FileMaker host.
22
- * @implements {HostBase}
23
- */
24
- export default class FMHost implements HostBase {
25
- readonly hostname: string
26
- readonly timezoneOffsetFunc: (moment: Moment) => number
27
- readonly verify: boolean
28
- readonly protocol: 'http:' | 'https:'
29
- _metadata: FMHostMetadata | null = null
30
-
31
- constructor (
32
- _hostname: string,
33
- timezoneOffset = (moment: Moment) => 0 - (new Date()).getTimezoneOffset(),
34
- verify = true
35
- ) {
36
- if (!(/^https?:\/\//).test(_hostname)) throw new Error('hostname MUST begin with either http:// or https://')
37
- this.protocol = _hostname.startsWith('https:') ? 'https:' : 'http:'
38
- this.hostname = _hostname.split('//')[1]
39
- this.timezoneOffsetFunc = timezoneOffset
40
- this.verify = verify
41
- }
42
-
43
- get metadata (): FMHostMetadata {
44
- return this._metadata ?? {
45
- productInfo: {
46
- buildDate: new Date(),
47
- name: '',
48
- version: '',
49
- dateFormat: 'MM/dd/yyyy',
50
- timeFormat: 'HH:mm:ss',
51
- timeStampFormat: 'MM/dd/yyyy HH:mm:ss'
52
- }
53
- }
54
- }
55
-
56
- get dateFormat () {
57
- return this.metadata.productInfo.dateFormat
58
- .replace('dd', 'DD')
59
- .replace('yyyy', 'YYYY')
60
- }
61
-
62
- get timeFormat () { return this.metadata.productInfo.timeFormat }
63
- get timeStampFormat () {
64
- return this.metadata.productInfo.timeStampFormat
65
- .replace('dd', 'DD')
66
- .replace('yyyy', 'YYYY')
67
- }
68
-
69
- /**
70
- * Retrieves a list of databases from the FileMaker Server.
71
- *
72
- * @param {loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris} [credentials] - Optional credentials required for authentication.
73
- * @throws {FMError} If the request to the FileMaker Server fails or if the response contains an error.
74
- * @returns {Promise<any[]>} A promise that resolves to an array of database objects if successful.
75
- */
76
- async listDatabases (credentials?: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris) {
77
- let headers = {}
78
- if (credentials) {
79
- headers = generateAuthorizationHeaders(credentials)
80
- }
81
-
82
- const _fetch = await fetch(`${this.hostname}/fmi/data/v2/databases`, {
83
- method: 'GET',
84
- headers
85
- })
86
- const data = await _fetch.json() as ApiResults<{ databases: any }>
87
- // console.log(data.messages[0])
88
-
89
- if (data.messages[0].code === '0' && data.response) {
90
- return data.response.databases
91
- } else {
92
- throw new FMError(data.messages[0].code, _fetch.status, data)
93
- }
94
- }
95
-
96
- /**
97
- * Creates a new database connection with the specified options.
98
- *
99
- * @template T - The type of the database structure.
100
- * @param {databaseOptionsWithExternalSources} data - The options for the database, including external sources.
101
- * @return {Database<T>} A new Database instance.
102
- */
103
- database<T extends DatabaseStructure>(data: databaseOptionsWithExternalSources) {
104
- return new Database<T>(this, data)
105
- }
106
-
107
- async getMetadata () {
108
- if (this._metadata) return this._metadata
109
-
110
- const _fetch = await fetch(`${this.protocol}//${this.hostname}/fmi/data/v2/productInfo`, {
111
- method: 'GET'
112
- })
113
- const data = await _fetch.json() as ApiResults<FMHostMetadata>
114
- // console.log(data.messages[0])
115
-
116
- if (data.messages[0].code === '0' && data.response) {
117
- this._metadata = data.response
118
- return data.response
119
- } else {
120
- throw new FMError(data.messages[0].code, _fetch.status, data)
121
- }
122
- }
123
- }
@@ -1,18 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2024. See LICENSE file for more information
3
- */
4
-
5
- import {type FMHostMetadata} from '../types.js'
6
- import {type Moment} from 'moment'
7
-
8
- export interface HostBase {
9
- readonly hostname: string
10
- readonly protocol: string
11
- readonly timezoneOffsetFunc: (moment: Moment) => number
12
- readonly verify: boolean
13
- metadata: FMHostMetadata
14
- getMetadata: () => PromiseLike<any>
15
- timeFormat: string
16
- dateFormat: string
17
- timeStampFormat: string
18
- }