@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/src/layouts/layout.d.ts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
import { LayoutRecordManager } from "./layoutRecordManager.js";
|
|
2
|
-
import { LayoutRecord } from "../records/layoutRecord.js";
|
|
3
2
|
import { Script, ScriptResult } from "../types.js";
|
|
4
3
|
import { LayoutInterface } from "./layoutInterface.js";
|
|
5
|
-
import { Find } from "../records/getOperations/find.js";
|
|
6
|
-
import { FMError } from "../FMError.js";
|
|
7
4
|
import { LayoutBase } from "./layoutBase.js";
|
|
8
|
-
import { DatabaseBase } from "../connection/databaseBase";
|
|
5
|
+
import { DatabaseBase } from "../connection/databaseBase.js";
|
|
6
|
+
import { ApiLayoutMetadata } from "../models/apiResults.js";
|
|
9
7
|
export declare class Layout<T extends LayoutInterface> implements LayoutBase {
|
|
10
8
|
readonly database: DatabaseBase;
|
|
11
|
-
readonly records: LayoutRecordManager<T>;
|
|
12
9
|
readonly name: string;
|
|
13
|
-
|
|
10
|
+
readonly records: LayoutRecordManager<T>;
|
|
11
|
+
metadata: ApiLayoutMetadata;
|
|
14
12
|
constructor(database: DatabaseBase, name: string);
|
|
15
13
|
get endpoint(): string;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated use layout.records.create() instead
|
|
18
|
-
*/
|
|
19
|
-
createRecord(): Promise<LayoutRecord<T["fields"], T["portals"]>>;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated use layout.records.get() instead
|
|
22
|
-
*/
|
|
23
|
-
getRecord(recordId: any): Promise<LayoutRecord<T["fields"], T["portals"]>>;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated use layout.records.find() instead
|
|
26
|
-
*/
|
|
27
|
-
newFind(): Find<T>;
|
|
28
14
|
runScript(script: Script): Promise<ScriptResult>;
|
|
29
|
-
getLayoutMeta(): Promise<
|
|
15
|
+
getLayoutMeta(): Promise<ApiLayoutMetadata>;
|
|
30
16
|
}
|
package/src/layouts/layout.js
CHANGED
|
@@ -1,84 +1,42 @@
|
|
|
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 { LayoutRecordManager } from "./layoutRecordManager.js";
|
|
14
5
|
import { FMError } from "../FMError.js";
|
|
15
6
|
export class Layout {
|
|
7
|
+
database;
|
|
8
|
+
name;
|
|
9
|
+
records = new LayoutRecordManager(this);
|
|
10
|
+
metadata;
|
|
16
11
|
constructor(database, name) {
|
|
17
|
-
this.records = new LayoutRecordManager(this);
|
|
18
12
|
this.database = database;
|
|
19
13
|
this.name = name;
|
|
20
14
|
}
|
|
21
15
|
get endpoint() {
|
|
22
16
|
return `${this.database.endpoint}/layouts/${this.name}`;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @deprecated use layout.records.get() instead
|
|
32
|
-
*/
|
|
33
|
-
getRecord(recordId) {
|
|
34
|
-
return this.records.get(recordId);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated use layout.records.find() instead
|
|
38
|
-
*/
|
|
39
|
-
newFind() {
|
|
40
|
-
return this.records.find();
|
|
41
|
-
}
|
|
42
|
-
runScript(script) {
|
|
43
|
-
let trace = new Error();
|
|
44
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`;
|
|
46
|
-
if (script.parameter)
|
|
47
|
-
url += "?script.param=" + encodeURIComponent(script.parameter);
|
|
48
|
-
this.database.apiRequest(url, {
|
|
49
|
-
port: 443,
|
|
50
|
-
method: "GET"
|
|
51
|
-
})
|
|
52
|
-
.then(res => {
|
|
53
|
-
if (res.messages[0].code === "0") {
|
|
54
|
-
let error = parseInt(res.response.scriptError);
|
|
55
|
-
let msg = {
|
|
56
|
-
scriptError: error ? new FMError(error, 200, res, trace) : undefined,
|
|
57
|
-
scriptResult: res.response.scriptResult
|
|
58
|
-
};
|
|
59
|
-
resolve(msg);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// console.log(res)
|
|
63
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace));
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
.catch(e => {
|
|
67
|
-
reject(e);
|
|
68
|
-
});
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
getLayoutMeta() {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
if (this.metadata) {
|
|
74
|
-
resolve(this.metadata);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
this.database.apiRequest(this.endpoint).then(res => {
|
|
78
|
-
this.metadata = res.response;
|
|
79
|
-
resolve(this);
|
|
80
|
-
})
|
|
81
|
-
.catch(e => reject(e));
|
|
18
|
+
async runScript(script) {
|
|
19
|
+
let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`;
|
|
20
|
+
if (script.parameter)
|
|
21
|
+
url += "?script.param=" + encodeURIComponent(script.parameter);
|
|
22
|
+
let res = await this.database.apiRequest(url, {
|
|
23
|
+
port: 443,
|
|
24
|
+
method: "GET"
|
|
82
25
|
});
|
|
26
|
+
if (res.messages[0].code === "0") {
|
|
27
|
+
let error = parseInt(res.response.scriptError);
|
|
28
|
+
return {
|
|
29
|
+
scriptError: error ? new FMError(error, 200, res) : undefined,
|
|
30
|
+
scriptResult: res.response.scriptResult
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async getLayoutMeta() {
|
|
35
|
+
if (this.metadata) {
|
|
36
|
+
return this.metadata;
|
|
37
|
+
}
|
|
38
|
+
let res = await this.database.apiRequest(this.endpoint);
|
|
39
|
+
this.metadata = res.response;
|
|
40
|
+
return this.metadata;
|
|
83
41
|
}
|
|
84
42
|
}
|
package/src/layouts/layout.ts
CHANGED
|
@@ -1,93 +1,54 @@
|
|
|
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 {LayoutRecordManager} from "./layoutRecordManager.js";
|
|
6
|
-
import {LayoutRecord} from "../records/layoutRecord.js";
|
|
7
6
|
import {Script, ScriptResult} from "../types.js";
|
|
8
7
|
import {LayoutInterface} from "./layoutInterface.js";
|
|
9
|
-
import {Find} from "../records/getOperations/find.js";
|
|
10
8
|
import {FMError} from "../FMError.js";
|
|
11
9
|
import {LayoutBase} from "./layoutBase.js"
|
|
12
|
-
import {DatabaseBase} from "../connection/databaseBase";
|
|
10
|
+
import {DatabaseBase} from "../connection/databaseBase.js";
|
|
11
|
+
import {ApiLayoutMetadata, ApiScriptResult} from "../models/apiResults.js";
|
|
13
12
|
|
|
14
13
|
export class Layout<T extends LayoutInterface> implements LayoutBase {
|
|
15
14
|
readonly database: DatabaseBase;
|
|
16
|
-
readonly records = new LayoutRecordManager<T>(this)
|
|
17
15
|
readonly name: string;
|
|
18
|
-
|
|
16
|
+
readonly records = new LayoutRecordManager<T>(this)
|
|
17
|
+
metadata: ApiLayoutMetadata;
|
|
19
18
|
|
|
20
19
|
constructor(database: DatabaseBase, name: string) {
|
|
21
20
|
this.database = database
|
|
22
21
|
this.name = name
|
|
23
22
|
}
|
|
24
23
|
|
|
24
|
+
|
|
25
25
|
get endpoint() {
|
|
26
26
|
return `${this.database.endpoint}/layouts/${this.name}`
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated use layout.records.get() instead
|
|
38
|
-
*/
|
|
39
|
-
getRecord(recordId): Promise<LayoutRecord<T["fields"], T["portals"]>> {
|
|
40
|
-
return this.records.get(recordId)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use layout.records.find() instead
|
|
45
|
-
*/
|
|
46
|
-
newFind(): Find<T> {
|
|
47
|
-
return this.records.find()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
runScript(script: Script): Promise<ScriptResult> {
|
|
51
|
-
let trace = new Error()
|
|
52
|
-
return new Promise(async (resolve, reject) => {
|
|
53
|
-
let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`
|
|
54
|
-
if (script.parameter) url += "?script.param=" + encodeURIComponent(script.parameter)
|
|
55
|
-
this.database.apiRequest(url, {
|
|
56
|
-
port: 443,
|
|
57
|
-
method: "GET"
|
|
58
|
-
})
|
|
59
|
-
.then(res => {
|
|
60
|
-
if (res.messages[0].code === "0") {
|
|
61
|
-
let error = parseInt(res.response.scriptError)
|
|
62
|
-
let msg: ScriptResult = {
|
|
63
|
-
scriptError: error ? new FMError(error, 200, res, trace) : undefined,
|
|
64
|
-
scriptResult: res.response.scriptResult
|
|
65
|
-
}
|
|
66
|
-
resolve(msg)
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// console.log(res)
|
|
70
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace))
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
.catch(e => {
|
|
74
|
-
reject(e)
|
|
75
|
-
})
|
|
29
|
+
async runScript(script: Script): Promise<ScriptResult> {
|
|
30
|
+
let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`
|
|
31
|
+
if (script.parameter) url += "?script.param=" + encodeURIComponent(script.parameter)
|
|
32
|
+
let res = await this.database.apiRequest<ApiScriptResult>(url, {
|
|
33
|
+
port: 443,
|
|
34
|
+
method: "GET"
|
|
76
35
|
})
|
|
36
|
+
if (res.messages[0].code === "0") {
|
|
37
|
+
let error = parseInt(res.response.scriptError)
|
|
38
|
+
return {
|
|
39
|
+
scriptError: error ? new FMError(error, 200, res) : undefined,
|
|
40
|
+
scriptResult: res.response.scriptResult
|
|
41
|
+
}
|
|
42
|
+
}
|
|
77
43
|
}
|
|
78
44
|
|
|
79
|
-
public getLayoutMeta(): Promise<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
}
|
|
45
|
+
public async getLayoutMeta(): Promise<ApiLayoutMetadata> {
|
|
46
|
+
if (this.metadata) {
|
|
47
|
+
return this.metadata
|
|
48
|
+
}
|
|
85
49
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
.catch(e => reject(e))
|
|
91
|
-
})
|
|
50
|
+
let res = await this.database.apiRequest<ApiLayoutMetadata>(this.endpoint)
|
|
51
|
+
this.metadata = res.response
|
|
52
|
+
return this.metadata
|
|
92
53
|
}
|
|
93
54
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Script, ScriptResult } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Script, ScriptResult } from "../types.js";
|
|
2
|
+
import { DatabaseBase } from "../connection/databaseBase.js";
|
|
3
|
+
import { ApiLayoutMetadata } from "../models/apiResults.js";
|
|
4
4
|
export interface LayoutBase {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
metadata: any;
|
|
7
7
|
endpoint: string;
|
|
8
8
|
runScript(script: Script): Promise<ScriptResult>;
|
|
9
|
-
getLayoutMeta(): Promise<
|
|
9
|
+
getLayoutMeta(): Promise<ApiLayoutMetadata>;
|
|
10
10
|
database: DatabaseBase;
|
|
11
11
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
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 {Script, ScriptResult} from "../types";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import {Script, ScriptResult} from "../types.js";
|
|
6
|
+
import {DatabaseBase} from "../connection/databaseBase.js";
|
|
7
|
+
import {ApiLayoutMetadata} from "../models/apiResults.js";
|
|
8
8
|
|
|
9
9
|
export interface LayoutBase {
|
|
10
10
|
readonly name: string
|
|
11
11
|
metadata: any
|
|
12
12
|
endpoint: string
|
|
13
13
|
runScript(script: Script): Promise<ScriptResult>
|
|
14
|
-
getLayoutMeta(): Promise<
|
|
14
|
+
getLayoutMeta(): Promise<ApiLayoutMetadata>
|
|
15
15
|
database: DatabaseBase
|
|
16
16
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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 {Portal} from "../records/portal.js";
|
|
6
|
-
import {RecordFieldsMap} from "./recordFieldsMap";
|
|
6
|
+
import {RecordFieldsMap} from "./recordFieldsMap.js";
|
|
7
7
|
|
|
8
8
|
export interface LayoutInterface {
|
|
9
9
|
fields: RecordFieldsMap,
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { LayoutRecord } from "../records/layoutRecord.js";
|
|
2
2
|
import { LayoutInterface } from "./layoutInterface.js";
|
|
3
|
-
import { RecordGetRange } from "../records/getOperations/recordGetRange.js";
|
|
4
|
-
import { Find } from "../records/getOperations/find.js";
|
|
5
3
|
import { LayoutBase } from "./layoutBase.js";
|
|
4
|
+
import { GetOperationOptions, RecordGetOperation } from "../records/getOperations/recordGetOperation.js";
|
|
5
|
+
import { RecordFetchOptions } from "../types.js";
|
|
6
6
|
export declare class LayoutRecordManager<T extends LayoutInterface> {
|
|
7
7
|
readonly layout: LayoutBase;
|
|
8
8
|
constructor(layout: LayoutBase);
|
|
9
|
-
create(): Promise<LayoutRecord<T
|
|
10
|
-
get(recordId:
|
|
11
|
-
|
|
12
|
-
find(start?: number, limit?: number): Find<T>;
|
|
9
|
+
create<OPTIONS extends RecordFetchOptions>(options: OPTIONS): Promise<LayoutRecord<T, OPTIONS["portals"][number]>>;
|
|
10
|
+
get(recordId: number): Promise<LayoutRecord<T>>;
|
|
11
|
+
list<OPTIONS extends GetOperationOptions<T>>(options: OPTIONS): RecordGetOperation<T, OPTIONS>;
|
|
13
12
|
}
|
|
@@ -1,50 +1,31 @@
|
|
|
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 { LayoutRecord } from "../records/layoutRecord.js";
|
|
5
|
-
import {
|
|
6
|
-
import { Find } from "../records/getOperations/find.js";
|
|
5
|
+
import { RecordGetOperation } from "../records/getOperations/recordGetOperation.js";
|
|
7
6
|
export class LayoutRecordManager {
|
|
7
|
+
layout;
|
|
8
8
|
constructor(layout) {
|
|
9
9
|
this.layout = layout;
|
|
10
10
|
}
|
|
11
|
-
create() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
portals[_portal] = [];
|
|
22
|
-
resolve(new LayoutRecord(this.layout, -1, 0, fields, portals));
|
|
23
|
-
}).catch(e => {
|
|
24
|
-
reject(e);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
11
|
+
async create(options) {
|
|
12
|
+
await this.layout.getLayoutMeta();
|
|
13
|
+
let fields = {};
|
|
14
|
+
for (let _field of this.layout.metadata.fieldMetaData) {
|
|
15
|
+
fields[_field.name] = "";
|
|
16
|
+
}
|
|
17
|
+
let portals = {};
|
|
18
|
+
for (let _portal of Object.keys(this.layout.metadata.portalMetaData))
|
|
19
|
+
portals[_portal] = [];
|
|
20
|
+
return new LayoutRecord(this.layout, -1, 0, fields, portals);
|
|
27
21
|
}
|
|
28
|
-
get(recordId) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
record = new LayoutRecord(this.layout, recordId);
|
|
34
|
-
return record.get();
|
|
35
|
-
})
|
|
36
|
-
.then(() => {
|
|
37
|
-
resolve(record);
|
|
38
|
-
})
|
|
39
|
-
.catch(e => {
|
|
40
|
-
reject(e);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
22
|
+
async get(recordId) {
|
|
23
|
+
await this.layout.getLayoutMeta();
|
|
24
|
+
let record = new LayoutRecord(this.layout, recordId);
|
|
25
|
+
await record.get();
|
|
26
|
+
return record;
|
|
43
27
|
}
|
|
44
|
-
|
|
45
|
-
return new
|
|
46
|
-
}
|
|
47
|
-
find(start = 0, limit = 100) {
|
|
48
|
-
return new Find(this.layout, start, limit);
|
|
28
|
+
list(options) {
|
|
29
|
+
return new RecordGetOperation(this.layout, options);
|
|
49
30
|
}
|
|
50
31
|
}
|
|
@@ -1,59 +1,38 @@
|
|
|
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 {LayoutRecord} from "../records/layoutRecord.js";
|
|
6
6
|
import {LayoutInterface} from "./layoutInterface.js";
|
|
7
|
-
import {RecordGetRange} from "../records/getOperations/recordGetRange.js";
|
|
8
|
-
import {Find} from "../records/getOperations/find.js";
|
|
9
7
|
import {LayoutBase} from "./layoutBase.js"
|
|
8
|
+
import {GetOperationOptions, RecordGetOperation} from "../records/getOperations/recordGetOperation.js";
|
|
9
|
+
import {RecordFetchOptions} from "../types.js";
|
|
10
10
|
|
|
11
11
|
export class LayoutRecordManager<T extends LayoutInterface> {
|
|
12
|
-
readonly layout: LayoutBase
|
|
13
|
-
|
|
12
|
+
readonly layout: LayoutBase;
|
|
14
13
|
constructor(layout: LayoutBase) {
|
|
15
14
|
this.layout = layout
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
create(): Promise<LayoutRecord<T
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (let _portal of Object.keys(this.layout.metadata.portalMetaData)) portals[_portal] = []
|
|
28
|
-
resolve(new LayoutRecord(this.layout, -1, 0, fields, portals))
|
|
29
|
-
}).catch(e => {
|
|
30
|
-
reject(e)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get(recordId): Promise<LayoutRecord<T["fields"], T["portals"]>> {
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
let record
|
|
38
|
-
this.layout.getLayoutMeta()
|
|
39
|
-
.then(layout => {
|
|
40
|
-
record = new LayoutRecord(this.layout, recordId)
|
|
41
|
-
return record.get()
|
|
42
|
-
})
|
|
43
|
-
.then(() => {
|
|
44
|
-
resolve(record)
|
|
45
|
-
})
|
|
46
|
-
.catch(e => {
|
|
47
|
-
reject(e)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
17
|
+
async create<OPTIONS extends RecordFetchOptions>(options: OPTIONS): Promise<LayoutRecord<T, OPTIONS["portals"][number]>> {
|
|
18
|
+
await this.layout.getLayoutMeta()
|
|
19
|
+
let fields = {}
|
|
20
|
+
for (let _field of this.layout.metadata.fieldMetaData) {
|
|
21
|
+
fields[_field.name] = ""
|
|
22
|
+
}
|
|
23
|
+
let portals = {}
|
|
24
|
+
for (let _portal of Object.keys(this.layout.metadata.portalMetaData)) portals[_portal] = []
|
|
25
|
+
return new LayoutRecord(this.layout, -1, 0, fields, portals)
|
|
50
26
|
}
|
|
51
27
|
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
async get(recordId: number): Promise<LayoutRecord<T>> {
|
|
29
|
+
await this.layout.getLayoutMeta()
|
|
30
|
+
let record = new LayoutRecord<T>(this.layout, recordId)
|
|
31
|
+
await record.get()
|
|
32
|
+
return record
|
|
54
33
|
}
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
return new
|
|
35
|
+
list<OPTIONS extends GetOperationOptions<T>>(options: OPTIONS) {
|
|
36
|
+
return new RecordGetOperation<T, OPTIONS>(this.layout, options)
|
|
58
37
|
}
|
|
59
38
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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 {
|
|
5
|
+
import {FieldBase, FieldValue} from "../records/fieldBase.js";
|
|
6
6
|
|
|
7
7
|
export interface RecordFieldsMap {
|
|
8
|
-
[fieldName: string]:
|
|
8
|
+
[fieldName: string]: FieldBase<FieldValue>
|
|
9
9
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export declare enum ApiFieldTypes {
|
|
2
|
+
NORMAL = "normal",
|
|
3
|
+
CALCULATION = "calculation",
|
|
4
|
+
SUMMARY = "summary"
|
|
5
|
+
}
|
|
6
|
+
export declare enum ApiFieldDisplayTypes {
|
|
7
|
+
EDIT_TEXT = "editText",
|
|
8
|
+
POPUP_LIST = "popupList",
|
|
9
|
+
CHECKBOX = "checkBox",
|
|
10
|
+
RADIO_BUTTONS = "radioButtons",
|
|
11
|
+
SELECTION_LIST = "selectionList",
|
|
12
|
+
CALENDAR = "calendar",
|
|
13
|
+
SECURE_TEXT = "secureText"
|
|
14
|
+
}
|
|
15
|
+
export declare enum ApiFieldResultTypes {
|
|
16
|
+
TEXT = "text",
|
|
17
|
+
NUMBER = "number",
|
|
18
|
+
DATE = "date",
|
|
19
|
+
TIME = "time",
|
|
20
|
+
TIMESTAMP = "timeStamp",
|
|
21
|
+
CONTAINER = "container"
|
|
22
|
+
}
|
|
23
|
+
export interface ApiMessage {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ApiResults<T = unknown> {
|
|
28
|
+
response?: null | T & {
|
|
29
|
+
scriptError?: string;
|
|
30
|
+
};
|
|
31
|
+
messages: ApiMessage[];
|
|
32
|
+
httpStatus: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ApiLayout {
|
|
35
|
+
name: string;
|
|
36
|
+
isFolder: boolean;
|
|
37
|
+
folderLayoutNames: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface ApiLayoutMetadata {
|
|
40
|
+
fieldMetaData: ApiFieldMetadata[];
|
|
41
|
+
portalMetaData: {
|
|
42
|
+
[key: string]: ApiFieldMetadata[];
|
|
43
|
+
};
|
|
44
|
+
valueLists: ApiValueList[];
|
|
45
|
+
}
|
|
46
|
+
export interface ApiFieldMetadata {
|
|
47
|
+
name: string;
|
|
48
|
+
type: ApiFieldTypes;
|
|
49
|
+
displayType: ApiFieldDisplayTypes;
|
|
50
|
+
result: ApiFieldResultTypes;
|
|
51
|
+
global: boolean;
|
|
52
|
+
autoEnter: boolean;
|
|
53
|
+
fourDigitYear: boolean;
|
|
54
|
+
maxRepeat: number;
|
|
55
|
+
maxCharacters: number;
|
|
56
|
+
notEmpty: boolean;
|
|
57
|
+
numeric: boolean;
|
|
58
|
+
repetitions: number;
|
|
59
|
+
timeOfDay: boolean;
|
|
60
|
+
valueList: string;
|
|
61
|
+
}
|
|
62
|
+
export interface ApiValueList {
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
values: {
|
|
66
|
+
value: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
}[];
|
|
69
|
+
}
|
|
70
|
+
export interface ApiScriptResult {
|
|
71
|
+
scriptError: string;
|
|
72
|
+
scriptResult?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ApiRecordResponseObj {
|
|
75
|
+
data: ApiRowDataDef[];
|
|
76
|
+
dataInfo: ApiResultSetObj;
|
|
77
|
+
}
|
|
78
|
+
export interface ApiFieldData {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
}
|
|
81
|
+
export interface ApiPortalData {
|
|
82
|
+
[key: string]: ApiFieldData[];
|
|
83
|
+
}
|
|
84
|
+
export interface ApiResultSetObj {
|
|
85
|
+
database: string;
|
|
86
|
+
layout: string;
|
|
87
|
+
table: string;
|
|
88
|
+
totalRecordCount: number;
|
|
89
|
+
foundCount: number;
|
|
90
|
+
returnedCount: number;
|
|
91
|
+
}
|
|
92
|
+
export interface ApiRowDataDef {
|
|
93
|
+
fieldData: ApiFieldData;
|
|
94
|
+
portalData: ApiPortalData;
|
|
95
|
+
modId: string;
|
|
96
|
+
recordId: string;
|
|
97
|
+
portalDataInfo: {
|
|
98
|
+
database: string;
|
|
99
|
+
table: string;
|
|
100
|
+
foundCount: number;
|
|
101
|
+
returnedCount: number;
|
|
102
|
+
}[];
|
|
103
|
+
}
|