@jd-data-limited/easy-fm 3.2.8 → 4.0.1
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 +12 -9
- package/src/FMError.js +2 -2
- package/src/FMError.ts +2 -2
- package/src/connection/FMHost.d.ts +2 -1
- package/src/connection/FMHost.js +1 -2
- package/src/connection/FMHost.ts +4 -4
- 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 +10 -10
- package/src/connection/database.js +6 -17
- package/src/connection/database.ts +17 -27
- package/src/connection/databaseBase.d.ts +4 -4
- package/src/connection/databaseBase.js +1 -1
- package/src/connection/databaseBase.ts +4 -6
- 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 +3 -17
- package/src/layouts/layout.js +2 -20
- package/src/layouts/layout.ts +5 -27
- package/src/layouts/layoutBase.d.ts +4 -4
- package/src/layouts/layoutBase.js +1 -1
- package/src/layouts/layoutBase.ts +5 -6
- 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 +5 -9
- package/src/layouts/layoutRecordManager.ts +12 -16
- 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 +3 -3
- package/src/models/apiResults.js +1 -1
- package/src/models/apiResults.ts +2 -4
- package/src/records/field.d.ts +3 -23
- package/src/records/field.js +3 -152
- package/src/records/field.ts +4 -169
- 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 +142 -31
- package/src/records/getOperations/recordGetOperation.ts +172 -30
- package/src/records/layoutRecord.d.ts +14 -11
- package/src/records/layoutRecord.js +7 -8
- package/src/records/layoutRecord.ts +32 -22
- package/src/records/portal.d.ts +6 -5
- package/src/records/portal.js +1 -1
- package/src/records/portal.ts +10 -8
- 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 +12 -8
- package/src/records/portalRecord.js +6 -8
- package/src/records/portalRecord.ts +17 -16
- package/src/records/recordBase.d.ts +11 -15
- package/src/records/recordBase.js +9 -13
- package/src/records/recordBase.ts +17 -25
- package/src/types.d.ts +18 -15
- package/src/types.js +7 -1
- package/src/types.ts +20 -16
- package/src/records/getOperations/find.d.ts +0 -15
- package/src/records/getOperations/find.js +0 -70
- package/src/records/getOperations/find.ts +0 -77
- package/src/records/getOperations/recordGetRange.d.ts +0 -13
- package/src/records/getOperations/recordGetRange.js +0 -77
- package/src/records/getOperations/recordGetRange.ts +0 -77
- package/src/records/portalRecordBase.d.ts +0 -4
- package/src/records/portalRecordBase.js +0 -6
package/src/records/portal.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
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 {PortalRecord} from "./portalRecord.js";
|
|
6
|
-
import {RecordFieldsMap} from "../layouts/recordFieldsMap";
|
|
7
|
-
import {PortalBase} from "./portalBase";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import {RecordFieldsMap} from "../layouts/recordFieldsMap.js";
|
|
7
|
+
import {PortalBase} from "./portalBase.js";
|
|
8
|
+
import {LayoutRecord} from "./layoutRecord.js";
|
|
9
|
+
import {LayoutInterface} from "../layouts/layoutInterface.js";
|
|
10
10
|
|
|
11
11
|
export class Portal<T extends RecordFieldsMap> implements PortalBase<T> {
|
|
12
|
-
readonly record: LayoutRecord<
|
|
12
|
+
readonly record: LayoutRecord<LayoutInterface>;
|
|
13
13
|
readonly name: string;
|
|
14
14
|
public records: PortalRecord<T>[];
|
|
15
15
|
|
|
16
|
-
constructor(record: LayoutRecord<
|
|
16
|
+
constructor(record: LayoutRecord<LayoutInterface, any>, name: string) {
|
|
17
17
|
this.record = record
|
|
18
18
|
this.name = name
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
create() {
|
|
22
|
-
let fields
|
|
22
|
+
let fields: {
|
|
23
|
+
[key: string]: string
|
|
24
|
+
} = {}
|
|
23
25
|
for (let _field of this.record.layout.metadata.portalMetaData[this.name]) {
|
|
24
26
|
fields[_field.name] = ""
|
|
25
27
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { RecordFieldsMap } from "../layouts/recordFieldsMap";
|
|
2
|
-
import { RecordBase } from "./recordBase";
|
|
3
|
-
import { LayoutRecord } from "./layoutRecord";
|
|
1
|
+
import { RecordFieldsMap } from "../layouts/recordFieldsMap.js";
|
|
2
|
+
import { RecordBase } from "./recordBase.js";
|
|
3
|
+
import { LayoutRecord } from "./layoutRecord.js";
|
|
4
|
+
import { LayoutInterface } from "../layouts/layoutInterface.js";
|
|
4
5
|
export interface PortalBase<T extends RecordFieldsMap> {
|
|
5
|
-
readonly record: LayoutRecord<
|
|
6
|
+
readonly record: LayoutRecord<LayoutInterface>;
|
|
6
7
|
readonly name: string;
|
|
7
8
|
records: RecordBase<T>[];
|
|
8
9
|
}
|
|
@@ -1,14 +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
4
|
|
|
5
|
-
import {RecordFieldsMap} from "../layouts/recordFieldsMap";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import {RecordFieldsMap} from "../layouts/recordFieldsMap.js";
|
|
6
|
+
import {RecordBase} from "./recordBase.js";
|
|
7
|
+
import {LayoutRecord} from "./layoutRecord.js";
|
|
8
|
+
import {LayoutInterface} from "../layouts/layoutInterface.js";
|
|
9
9
|
|
|
10
10
|
export interface PortalBase<T extends RecordFieldsMap> {
|
|
11
|
-
readonly record: LayoutRecord<
|
|
11
|
+
readonly record: LayoutRecord<LayoutInterface>
|
|
12
12
|
readonly name: string
|
|
13
13
|
records: RecordBase<T>[]
|
|
14
14
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { RecordBase
|
|
2
|
-
import { extraBodyOptions } from "../types.js";
|
|
3
|
-
import { RecordFieldsMap } from "../layouts/recordFieldsMap";
|
|
4
|
-
import { PortalBase } from "./portalBase";
|
|
1
|
+
import { RecordBase } from "./recordBase.js";
|
|
2
|
+
import { extraBodyOptions, RecordTypes } from "../types.js";
|
|
3
|
+
import { RecordFieldsMap } from "../layouts/recordFieldsMap.js";
|
|
4
|
+
import { PortalBase } from "./portalBase.js";
|
|
5
|
+
import { FieldBase, FieldValue } from "./fieldBase.js";
|
|
5
6
|
export declare class PortalRecord<T extends RecordFieldsMap> extends RecordBase<T> {
|
|
6
7
|
readonly portal: PortalBase<T>;
|
|
7
8
|
readonly type = RecordTypes.PORTAL;
|
|
8
|
-
constructor(record: any
|
|
9
|
+
constructor(record: RecordBase<any>, portal: PortalBase<any>, recordId: number, modId?: number, fieldData?: {});
|
|
9
10
|
_onSave(): void;
|
|
10
|
-
commit(extraBody?: extraBodyOptions): Promise<import("./layoutRecord.js").LayoutRecord<
|
|
11
|
-
toObject(fieldFilter:
|
|
12
|
-
|
|
11
|
+
commit(extraBody?: extraBodyOptions): Promise<import("./layoutRecord.js").LayoutRecord<import("../index.js").LayoutInterface, string>>;
|
|
12
|
+
toObject(fieldFilter: (a: FieldBase<FieldValue>) => boolean): {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
modId: string;
|
|
15
|
+
recordId: string;
|
|
16
|
+
};
|
|
13
17
|
}
|
|
@@ -1,7 +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
|
-
import { RecordBase
|
|
4
|
+
import { RecordBase } from "./recordBase.js";
|
|
5
|
+
import { RecordTypes } from "../types.js";
|
|
5
6
|
export class PortalRecord extends RecordBase {
|
|
6
7
|
portal;
|
|
7
8
|
type = RecordTypes.PORTAL;
|
|
@@ -20,15 +21,12 @@ export class PortalRecord extends RecordBase {
|
|
|
20
21
|
toObject(fieldFilter) {
|
|
21
22
|
super.toObject();
|
|
22
23
|
let res = {
|
|
23
|
-
recordId: this.recordId === -1 ? undefined : this.recordId,
|
|
24
|
-
modId: this.modId === -1 ? undefined : this.modId
|
|
24
|
+
recordId: this.recordId === -1 ? undefined : this.recordId.toString(),
|
|
25
|
+
modId: this.modId === -1 ? undefined : this.modId.toString()
|
|
25
26
|
};
|
|
26
27
|
for (let field of this.fieldsArray.filter(a => fieldFilter(a)))
|
|
27
|
-
res[field.id] = field.value;
|
|
28
|
+
res[field.id] = field.value.toString();
|
|
28
29
|
// console.log(res)
|
|
29
30
|
return res;
|
|
30
31
|
}
|
|
31
|
-
getField(field) {
|
|
32
|
-
return this.fieldsArray.find(_field => _field.id === field) || this.fieldsArray.find(_field => _field.id === this.portal.name + "::" + field);
|
|
33
|
-
}
|
|
34
32
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
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 {RecordBase
|
|
6
|
-
import {extraBodyOptions,
|
|
5
|
+
import {RecordBase} from "./recordBase.js";
|
|
6
|
+
import {extraBodyOptions, RecordTypes} from "../types.js";
|
|
7
7
|
|
|
8
|
-
import {RecordFieldsMap} from "../layouts/recordFieldsMap";
|
|
9
|
-
import {PortalBase} from "./portalBase";
|
|
8
|
+
import {RecordFieldsMap} from "../layouts/recordFieldsMap.js";
|
|
9
|
+
import {PortalBase} from "./portalBase.js";
|
|
10
|
+
import {FieldBase, FieldValue} from "./fieldBase.js";
|
|
10
11
|
|
|
11
12
|
export class PortalRecord<T extends RecordFieldsMap> extends RecordBase<T> {
|
|
12
13
|
readonly portal: PortalBase<T>;
|
|
13
14
|
readonly type = RecordTypes.PORTAL
|
|
14
15
|
|
|
15
|
-
constructor(record
|
|
16
|
+
constructor(record: RecordBase<any>, portal: PortalBase<any>, recordId: number, modId = recordId, fieldData = {}) {
|
|
16
17
|
super(record.layout, recordId, modId);
|
|
17
18
|
|
|
18
19
|
this.portal = portal
|
|
@@ -28,18 +29,18 @@ export class PortalRecord<T extends RecordFieldsMap> extends RecordBase<T> {
|
|
|
28
29
|
return this.portal.record.commit(extraBody)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
toObject(fieldFilter
|
|
32
|
+
toObject(fieldFilter: (a: FieldBase<FieldValue>) => boolean) {
|
|
32
33
|
super.toObject()
|
|
33
|
-
let res
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
let res: {
|
|
35
|
+
"modId": string,
|
|
36
|
+
"recordId": string
|
|
37
|
+
[key: string]: string
|
|
38
|
+
} = {
|
|
39
|
+
recordId: this.recordId === -1 ? undefined : this.recordId.toString(),
|
|
40
|
+
modId: this.modId === -1 ? undefined : this.modId.toString()
|
|
41
|
+
}
|
|
42
|
+
for (let field of this.fieldsArray.filter(a => fieldFilter(a))) res[field.id] = field.value.toString()
|
|
38
43
|
// console.log(res)
|
|
39
44
|
return res
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
getField(field) {
|
|
43
|
-
return this.fieldsArray.find(_field => _field.id === field) || this.fieldsArray.find(_field => _field.id === this.portal.name + "::" + field)
|
|
44
|
-
}
|
|
45
46
|
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
UNKNOWN = 0,
|
|
9
|
-
LAYOUT = 1,
|
|
10
|
-
PORTAL = 2
|
|
11
|
-
}
|
|
3
|
+
import { FieldBase, FieldValue } from "./fieldBase.js";
|
|
4
|
+
import { RecordTypes } from "../types.js";
|
|
5
|
+
import { RecordFieldsMap } from "../layouts/recordFieldsMap.js";
|
|
6
|
+
import { LayoutBase } from "../layouts/layoutBase.js";
|
|
7
|
+
import { ApiFieldData, ApiRowDataDef } from "../models/apiResults.js";
|
|
12
8
|
export declare class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
|
|
13
|
-
readonly layout:
|
|
9
|
+
readonly layout: LayoutBase;
|
|
14
10
|
readonly type: RecordTypes;
|
|
15
11
|
recordId: number;
|
|
16
12
|
modId: number;
|
|
17
13
|
fields: T;
|
|
18
14
|
protected portalData: any[];
|
|
19
|
-
constructor(layout:
|
|
15
|
+
constructor(layout: LayoutBase, recordId: number, modId?: number);
|
|
20
16
|
get endpoint(): string;
|
|
21
17
|
get edited(): boolean;
|
|
22
|
-
get fieldsArray():
|
|
23
|
-
protected processFieldData(fieldData:
|
|
18
|
+
get fieldsArray(): FieldBase<FieldValue>[];
|
|
19
|
+
protected processFieldData(fieldData: ApiFieldData): T;
|
|
24
20
|
_onSave(): void;
|
|
25
|
-
toObject(filter?: (a:
|
|
21
|
+
toObject(filter?: (a: FieldBase<FieldValue>) => boolean): Partial<Omit<ApiRowDataDef, "portalDataInfo">>;
|
|
26
22
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
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
|
import { EventEmitter } from "events";
|
|
5
5
|
import * as moment from "moment";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
(function (RecordTypes) {
|
|
9
|
-
RecordTypes[RecordTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
10
|
-
RecordTypes[RecordTypes["LAYOUT"] = 1] = "LAYOUT";
|
|
11
|
-
RecordTypes[RecordTypes["PORTAL"] = 2] = "PORTAL";
|
|
12
|
-
})(RecordTypes || (RecordTypes = {}));
|
|
6
|
+
import { FieldBase } from "./fieldBase.js";
|
|
7
|
+
import { RecordTypes } from "../types.js";
|
|
13
8
|
export class RecordBase extends EventEmitter {
|
|
14
9
|
layout;
|
|
15
10
|
type = RecordTypes.UNKNOWN;
|
|
@@ -35,7 +30,7 @@ export class RecordBase extends EventEmitter {
|
|
|
35
30
|
processFieldData(fieldData) {
|
|
36
31
|
let fields = {};
|
|
37
32
|
for (let key of Object.keys(fieldData)) {
|
|
38
|
-
let _field = new
|
|
33
|
+
let _field = new FieldBase(this, key, fieldData[key]);
|
|
39
34
|
if (!!fieldData[key]) {
|
|
40
35
|
if (_field.metadata.result === "timeStamp") {
|
|
41
36
|
// @ts-ignore
|
|
@@ -72,9 +67,10 @@ export class RecordBase extends EventEmitter {
|
|
|
72
67
|
for (let field of this.fieldsArray)
|
|
73
68
|
field.edited = false;
|
|
74
69
|
}
|
|
75
|
-
toObject(filter = (a) => a.edited
|
|
70
|
+
toObject(filter = (a) => a.edited) {
|
|
76
71
|
let fields_processed = {};
|
|
77
|
-
|
|
72
|
+
let field;
|
|
73
|
+
for (field of this.fieldsArray.filter(field => filter(field))) {
|
|
78
74
|
let value = field.value;
|
|
79
75
|
if (value instanceof Date) {
|
|
80
76
|
// @ts-ignore
|
|
@@ -95,8 +91,8 @@ export class RecordBase extends EventEmitter {
|
|
|
95
91
|
fields_processed[field.id] = value;
|
|
96
92
|
}
|
|
97
93
|
let obj = {
|
|
98
|
-
"recordId": this.recordId,
|
|
99
|
-
"modId": this.modId,
|
|
94
|
+
"recordId": this.recordId.toString(),
|
|
95
|
+
"modId": this.modId.toString(),
|
|
100
96
|
"fieldData": fields_processed
|
|
101
97
|
};
|
|
102
98
|
return obj;
|
|
@@ -1,29 +1,24 @@
|
|
|
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 {EventEmitter} from "events";
|
|
6
6
|
import * as moment from "moment";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export enum RecordTypes {
|
|
13
|
-
UNKNOWN,
|
|
14
|
-
LAYOUT,
|
|
15
|
-
PORTAL
|
|
16
|
-
}
|
|
7
|
+
import {FieldBase, FieldValue} from "./fieldBase.js";
|
|
8
|
+
import {RecordTypes} from "../types.js";
|
|
9
|
+
import {RecordFieldsMap} from "../layouts/recordFieldsMap.js";
|
|
10
|
+
import {LayoutBase} from "../layouts/layoutBase.js";
|
|
11
|
+
import {ApiFieldData, ApiRowDataDef} from "../models/apiResults.js";
|
|
17
12
|
|
|
18
13
|
export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
|
|
19
|
-
readonly layout:
|
|
14
|
+
readonly layout: LayoutBase;
|
|
20
15
|
readonly type: RecordTypes = RecordTypes.UNKNOWN;
|
|
21
16
|
public recordId: number;
|
|
22
17
|
modId: number;
|
|
23
18
|
fields: T;
|
|
24
19
|
protected portalData: any[];
|
|
25
20
|
|
|
26
|
-
constructor(layout, recordId, modId = recordId) {
|
|
21
|
+
constructor(layout: LayoutBase, recordId: number, modId = recordId) {
|
|
27
22
|
super();
|
|
28
23
|
this.layout = layout
|
|
29
24
|
this.recordId = recordId
|
|
@@ -38,15 +33,15 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
|
|
|
38
33
|
return !!this.fieldsArray.find(i => i.edited)
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
get fieldsArray() {
|
|
36
|
+
get fieldsArray(): FieldBase<FieldValue>[] {
|
|
42
37
|
return Object.values(this.fields)
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
protected processFieldData(fieldData) {
|
|
40
|
+
protected processFieldData(fieldData: ApiFieldData) {
|
|
46
41
|
let fields: RecordFieldsMap = {}
|
|
47
42
|
|
|
48
43
|
for (let key of Object.keys(fieldData)) {
|
|
49
|
-
let _field = new
|
|
44
|
+
let _field = new FieldBase(this, key, fieldData[key])
|
|
50
45
|
if (!!fieldData[key]) {
|
|
51
46
|
if (_field.metadata.result === "timeStamp") {
|
|
52
47
|
// @ts-ignore
|
|
@@ -85,13 +80,10 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
|
|
|
85
80
|
for (let field of this.fieldsArray) field.edited = false
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
toObject(filter = (a) => a.edited,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
): recordObject {
|
|
93
|
-
let fields_processed = {}
|
|
94
|
-
for (let field of this.fieldsArray.filter(field => filter(field))) {
|
|
83
|
+
toObject(filter = (a: FieldBase<FieldValue>) => a.edited): Partial<Omit<ApiRowDataDef, "portalDataInfo">> {
|
|
84
|
+
let fields_processed: ApiFieldData = {}
|
|
85
|
+
let field: FieldBase<FieldValue>
|
|
86
|
+
for (field of this.fieldsArray.filter(field => filter(field))) {
|
|
95
87
|
let value = field.value
|
|
96
88
|
if (value instanceof Date) {
|
|
97
89
|
// @ts-ignore
|
|
@@ -114,8 +106,8 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
|
|
|
114
106
|
fields_processed[field.id] = value
|
|
115
107
|
}
|
|
116
108
|
let obj = {
|
|
117
|
-
"recordId": this.recordId,
|
|
118
|
-
"modId": this.modId,
|
|
109
|
+
"recordId": this.recordId.toString(),
|
|
110
|
+
"modId": this.modId.toString(),
|
|
119
111
|
"fieldData": fields_processed
|
|
120
112
|
}
|
|
121
113
|
return obj
|
package/src/types.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import * as http from "http";
|
|
4
4
|
import { FMError } from "./FMError.js";
|
|
5
|
-
import { LayoutInterface } from "./layouts/layoutInterface";
|
|
6
|
-
export interface DatabaseStructure {
|
|
7
|
-
layouts: {
|
|
8
|
-
[key: string]: LayoutInterface;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
5
|
export interface databaseOptionsBase {
|
|
12
6
|
database: string;
|
|
13
7
|
credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken;
|
|
@@ -39,17 +33,18 @@ export interface loginOptionsClaris {
|
|
|
39
33
|
fmid: string;
|
|
40
34
|
};
|
|
41
35
|
}
|
|
42
|
-
export interface
|
|
43
|
-
portalName:
|
|
36
|
+
export interface portalFetchData<T = string> {
|
|
37
|
+
portalName: T;
|
|
44
38
|
offset: number;
|
|
45
39
|
limit: number;
|
|
46
40
|
}
|
|
41
|
+
export type ScriptRequestData = {
|
|
42
|
+
prerequest?: Script;
|
|
43
|
+
presort?: Script;
|
|
44
|
+
after?: Script;
|
|
45
|
+
};
|
|
47
46
|
export interface extraBodyOptions {
|
|
48
|
-
scripts?:
|
|
49
|
-
prerequest?: Script;
|
|
50
|
-
presort?: Script;
|
|
51
|
-
after?: Script;
|
|
52
|
-
};
|
|
47
|
+
scripts?: ScriptRequestData;
|
|
53
48
|
}
|
|
54
49
|
export declare enum DOWNLOAD_MODES {
|
|
55
50
|
Stream = 0,
|
|
@@ -118,3 +113,11 @@ export interface AuthorizationHeadersOAuth {
|
|
|
118
113
|
"X-FM-Data-OAuth-RequestId": string;
|
|
119
114
|
"X-FM-Data-OAuth-Identifier": string;
|
|
120
115
|
}
|
|
116
|
+
export type RecordFetchOptions = {
|
|
117
|
+
readonly portals: readonly string[];
|
|
118
|
+
};
|
|
119
|
+
export declare enum RecordTypes {
|
|
120
|
+
UNKNOWN = 0,
|
|
121
|
+
LAYOUT = 1,
|
|
122
|
+
PORTAL = 2
|
|
123
|
+
}
|
package/src/types.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
export var DOWNLOAD_MODES;
|
|
5
5
|
(function (DOWNLOAD_MODES) {
|
|
6
6
|
DOWNLOAD_MODES[DOWNLOAD_MODES["Stream"] = 0] = "Stream";
|
|
7
7
|
DOWNLOAD_MODES[DOWNLOAD_MODES["Buffer"] = 1] = "Buffer";
|
|
8
8
|
})(DOWNLOAD_MODES || (DOWNLOAD_MODES = {}));
|
|
9
|
+
export var RecordTypes;
|
|
10
|
+
(function (RecordTypes) {
|
|
11
|
+
RecordTypes[RecordTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
12
|
+
RecordTypes[RecordTypes["LAYOUT"] = 1] = "LAYOUT";
|
|
13
|
+
RecordTypes[RecordTypes["PORTAL"] = 2] = "PORTAL";
|
|
14
|
+
})(RecordTypes || (RecordTypes = {}));
|
package/src/types.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
import * as http from "http";
|
|
8
8
|
import {FMError} from "./FMError.js";
|
|
9
|
-
import {LayoutInterface} from "./layouts/layoutInterface";
|
|
10
|
-
|
|
11
|
-
// import * as btoa from "btoa";
|
|
12
|
-
export interface DatabaseStructure {
|
|
13
|
-
layouts: {
|
|
14
|
-
[key: string]: LayoutInterface
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
9
|
|
|
18
10
|
export interface databaseOptionsBase {
|
|
19
11
|
database: string
|
|
@@ -52,18 +44,20 @@ export interface loginOptionsClaris {
|
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
export interface
|
|
56
|
-
portalName:
|
|
47
|
+
export interface portalFetchData<T = string> {
|
|
48
|
+
portalName: T,
|
|
57
49
|
offset: number,
|
|
58
50
|
limit: number
|
|
59
51
|
}
|
|
60
52
|
|
|
53
|
+
export type ScriptRequestData = {
|
|
54
|
+
prerequest?: Script,
|
|
55
|
+
presort?: Script,
|
|
56
|
+
after?: Script,
|
|
57
|
+
}
|
|
58
|
+
|
|
61
59
|
export interface extraBodyOptions {
|
|
62
|
-
scripts?:
|
|
63
|
-
prerequest?: Script,
|
|
64
|
-
presort?: Script,
|
|
65
|
-
after?: Script,
|
|
66
|
-
}
|
|
60
|
+
scripts?: ScriptRequestData
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
export enum DOWNLOAD_MODES {
|
|
@@ -147,4 +141,14 @@ export interface AuthorizationHeadersOAuth {
|
|
|
147
141
|
"Content-Type": "application/json"
|
|
148
142
|
"X-FM-Data-OAuth-RequestId": string,
|
|
149
143
|
"X-FM-Data-OAuth-Identifier": string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type RecordFetchOptions = {
|
|
147
|
+
readonly portals: readonly string[]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export enum RecordTypes {
|
|
151
|
+
UNKNOWN,
|
|
152
|
+
LAYOUT,
|
|
153
|
+
PORTAL
|
|
150
154
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { RecordGetOperation } from "./recordGetOperation.js";
|
|
2
|
-
import { LayoutRecord } from "../layoutRecord.js";
|
|
3
|
-
import { LayoutInterface } from "../../layouts/layoutInterface";
|
|
4
|
-
import { LayoutBase } from "../../layouts/layoutBase.js";
|
|
5
|
-
export declare class Find<T extends LayoutInterface> extends RecordGetOperation<T> {
|
|
6
|
-
protected queries: object[];
|
|
7
|
-
constructor(layout: LayoutBase, start?: number, limit?: number);
|
|
8
|
-
private toObject;
|
|
9
|
-
addRequests(...requests: any[]): this;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated in favour of .fetch()
|
|
12
|
-
*/
|
|
13
|
-
run(): Promise<LayoutRecord<T["fields"], T["portals"]>[]>;
|
|
14
|
-
fetch(): Promise<LayoutRecord<T["fields"], T["portals"]>[]>;
|
|
15
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023. See LICENSE file for more information
|
|
3
|
-
*/
|
|
4
|
-
import { RecordGetOperation } from "./recordGetOperation.js";
|
|
5
|
-
import { LayoutRecord } from "../layoutRecord.js";
|
|
6
|
-
import { FMError } from "../../FMError.js";
|
|
7
|
-
export class Find extends RecordGetOperation {
|
|
8
|
-
queries;
|
|
9
|
-
constructor(layout, start = 0, limit = 100) {
|
|
10
|
-
super(layout);
|
|
11
|
-
this.setOffset(start);
|
|
12
|
-
this.setLimit(limit);
|
|
13
|
-
this.queries = [];
|
|
14
|
-
}
|
|
15
|
-
toObject() {
|
|
16
|
-
let out = { query: this.queries, sort: undefined };
|
|
17
|
-
if (this.sort.length !== 0)
|
|
18
|
-
out.sort = this.sort;
|
|
19
|
-
for (let item of Object.keys(this.scripts)) {
|
|
20
|
-
if (this.scripts[item]) {
|
|
21
|
-
out[item] = this.scripts[item].name;
|
|
22
|
-
if (this.scripts[item].parameter)
|
|
23
|
-
out[item + ".param"] = this.scripts[item].parameter;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (this.limit !== 100)
|
|
27
|
-
out["limit"] = this.limit;
|
|
28
|
-
if (this.offset !== 0)
|
|
29
|
-
out["offset"] = this.offset;
|
|
30
|
-
if (this.limitPortals.length > 0) {
|
|
31
|
-
out["portal"] = this.limitPortals.map(p => p.portalName);
|
|
32
|
-
for (let item of this.limitPortals) {
|
|
33
|
-
out["offset." + item.portalName.replace(/[^0-9A-z]/g, "")] = item.offset;
|
|
34
|
-
out["limit." + item.portalName.replace(/[^0-9A-z]/g, "")] = item.limit;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
addRequests(...requests) {
|
|
40
|
-
for (let item of requests)
|
|
41
|
-
this.queries.push(item);
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated in favour of .fetch()
|
|
46
|
-
*/
|
|
47
|
-
run() {
|
|
48
|
-
return this.fetch();
|
|
49
|
-
}
|
|
50
|
-
async fetch() {
|
|
51
|
-
let trace = new Error();
|
|
52
|
-
await this.layout.getLayoutMeta();
|
|
53
|
-
let res = await this.layout.database.apiRequest(`${this.layout.endpoint}/_find`, {
|
|
54
|
-
port: 443,
|
|
55
|
-
method: "POST",
|
|
56
|
-
body: JSON.stringify(this.toObject())
|
|
57
|
-
});
|
|
58
|
-
if (res.messages[0].code === "0") {
|
|
59
|
-
// console.log("RESOLVING")
|
|
60
|
-
if (!this.layout.metadata)
|
|
61
|
-
await this.layout.getLayoutMeta();
|
|
62
|
-
return res.response.data.map(item => {
|
|
63
|
-
return new LayoutRecord(this.layout, item.recordId, item.modId, item.fieldData, item.portalData);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
throw new FMError(res.messages[0].code, res.httpStatus, res, trace);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|