@jd-data-limited/easy-fm 3.2.6 → 3.2.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.
- package/package.json +10 -6
- package/src/FMError.d.ts +1 -1
- package/src/FMError.js +5 -0
- package/src/FMError.ts +1 -1
- package/src/connection/FMHost.d.ts +1 -1
- package/src/connection/FMHost.js +36 -45
- package/src/connection/FMHost.ts +3 -3
- package/src/connection/database.d.ts +5 -3
- package/src/connection/database.js +90 -112
- package/src/connection/database.ts +70 -82
- package/src/connection/databaseBase.d.ts +4 -1
- package/src/connection/databaseBase.ts +4 -1
- package/src/layouts/layout.d.ts +3 -3
- package/src/layouts/layout.js +26 -50
- package/src/layouts/layout.ts +22 -39
- package/src/layouts/layoutBase.d.ts +2 -2
- package/src/layouts/layoutBase.ts +2 -1
- package/src/layouts/layoutRecordManager.d.ts +1 -1
- package/src/layouts/layoutRecordManager.js +16 -31
- package/src/layouts/layoutRecordManager.ts +14 -30
- 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 -2
- package/src/records/field.js +44 -68
- package/src/records/field.ts +46 -64
- package/src/records/getOperations/find.js +18 -38
- package/src/records/getOperations/find.ts +17 -28
- package/src/records/getOperations/recordGetOperation.js +7 -4
- package/src/records/getOperations/recordGetOperation.ts +1 -1
- package/src/records/getOperations/recordGetRange.js +16 -34
- package/src/records/getOperations/recordGetRange.ts +17 -24
- package/src/records/layoutRecord.js +103 -151
- package/src/records/layoutRecord.ts +101 -133
- package/src/records/portal.js +3 -0
- package/src/records/portalRecord.js +2 -1
- package/src/records/recordBase.js +6 -1
- package/src/types.d.ts +0 -4
- package/src/types.ts +1 -7
- 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/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
|
@@ -10,6 +10,7 @@ import {PortalInterface} from "../layouts/layoutInterface.js";
|
|
|
10
10
|
import {FMError} from "../FMError.js";
|
|
11
11
|
import {RecordFieldsMap} from "../layouts/recordFieldsMap";
|
|
12
12
|
import {LayoutRecordBase} from "./layoutRecordBase";
|
|
13
|
+
import {ApiRecordResponseObj, ApiResultSetObj} from "../models/apiResults";
|
|
13
14
|
|
|
14
15
|
export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface> extends RecordBase<T> implements LayoutRecordBase {
|
|
15
16
|
// @ts-ignore
|
|
@@ -27,77 +28,68 @@ export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface>
|
|
|
27
28
|
return Object.values(this.portals)
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
commit(extraBody: extraBodyOptions = {}): Promise<this> {
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
delete data.recordId
|
|
35
|
-
delete data.modId
|
|
36
|
-
|
|
37
|
-
if (extraBody.scripts?.after) {
|
|
38
|
-
data["script"] = extraBody.scripts.after.name
|
|
39
|
-
if (extraBody.scripts.after.parameter) data["script.param"] = extraBody.scripts.after.parameter
|
|
40
|
-
}
|
|
41
|
-
if (extraBody.scripts?.prerequest) {
|
|
42
|
-
data["script.prerequest"] = extraBody.scripts.after.name
|
|
43
|
-
if (extraBody.scripts.prerequest.parameter) data["script.prerequest.param"] = extraBody.scripts.prerequest.parameter
|
|
44
|
-
}
|
|
45
|
-
if (extraBody.scripts?.presort) {
|
|
46
|
-
data["script.presort"] = extraBody.scripts.presort.name
|
|
47
|
-
if (extraBody.scripts.presort.parameter) data["script.presort.param"] = extraBody.scripts.presort.parameter
|
|
48
|
-
}
|
|
31
|
+
async commit(extraBody: extraBodyOptions = {}): Promise<this> {
|
|
32
|
+
let data = this.toObject()
|
|
33
|
+
delete data.recordId
|
|
34
|
+
delete data.modId
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
if (extraBody.scripts?.after) {
|
|
37
|
+
data["script"] = extraBody.scripts.after.name
|
|
38
|
+
if (extraBody.scripts.after.parameter) data["script.param"] = extraBody.scripts.after.parameter
|
|
39
|
+
}
|
|
40
|
+
if (extraBody.scripts?.prerequest) {
|
|
41
|
+
data["script.prerequest"] = extraBody.scripts.after.name
|
|
42
|
+
if (extraBody.scripts.prerequest.parameter) data["script.prerequest.param"] = extraBody.scripts.prerequest.parameter
|
|
43
|
+
}
|
|
44
|
+
if (extraBody.scripts?.presort) {
|
|
45
|
+
data["script.presort"] = extraBody.scripts.presort.name
|
|
46
|
+
if (extraBody.scripts.presort.parameter) data["script.presort.param"] = extraBody.scripts.presort.parameter
|
|
47
|
+
}
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
if (this.recordId === -1) {
|
|
50
|
+
// This is a new LayoutRecord
|
|
51
|
+
let res = await this.layout.database.apiRequest<{ recordId: string, modId: string }>(`${this.layout.endpoint}/records`, {
|
|
54
52
|
port: 443,
|
|
55
53
|
method: "POST",
|
|
56
54
|
body: JSON.stringify(data)
|
|
57
55
|
})
|
|
58
|
-
.then(res => {
|
|
59
|
-
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
60
|
-
reject(new FMError(res.response.scriptError, res.status, res, trace))
|
|
61
|
-
}
|
|
62
|
-
else if (res.messages[0].code === "0") {
|
|
63
|
-
this.recordId = parseInt(res.response.recordId)
|
|
64
|
-
this.modId = parseInt(res.response.modId)
|
|
65
|
-
resolve(this)
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace))
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.catch(e => {
|
|
72
|
-
reject(e)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
57
|
+
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
58
|
+
throw new FMError(res.response.scriptError, res.httpStatus, res)
|
|
59
|
+
}
|
|
60
|
+
else if (res.messages[0].code === "0") {
|
|
61
|
+
this.recordId = parseInt(res.response.recordId)
|
|
62
|
+
this.modId = parseInt(res.response.modId)
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new FMError(res.messages[0].code, res.httpStatus, res)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// for (let item of Object.keys(data)) extraBody[item] = data[item]
|
|
71
|
+
let res = await this.layout.database.apiRequest<{
|
|
72
|
+
modId: string, newPortalRecordInfo: {
|
|
73
|
+
tableName: string,
|
|
74
|
+
recordId: string,
|
|
75
|
+
modId: string
|
|
76
|
+
}[]
|
|
77
|
+
}>(this.endpoint, {
|
|
78
|
+
port: 443,
|
|
79
|
+
method: "PATCH",
|
|
80
|
+
body: JSON.stringify(data)
|
|
100
81
|
})
|
|
82
|
+
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
83
|
+
throw new FMError(res.response.scriptError, res.httpStatus, res)
|
|
84
|
+
}
|
|
85
|
+
else if (res.messages[0].code === "0") {
|
|
86
|
+
this.modId = +res.response.modId
|
|
87
|
+
this._onSave()
|
|
88
|
+
return this
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new FMError(res.messages[0].code, res.httpStatus, res)
|
|
92
|
+
}
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
protected processPortalData(portalData): void {
|
|
@@ -115,92 +107,68 @@ export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface>
|
|
|
115
107
|
}
|
|
116
108
|
}
|
|
117
109
|
|
|
118
|
-
get(): Promise<this> {
|
|
110
|
+
async get(): Promise<this> {
|
|
119
111
|
let trace = new Error()
|
|
120
112
|
if (this.recordId === -1) {
|
|
121
113
|
throw "Cannot get this RecordBase until a commit() is done."
|
|
122
114
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
port: 443,
|
|
128
|
-
method: "GET"
|
|
129
|
-
})
|
|
130
|
-
.then(res => {
|
|
131
|
-
if (res.messages[0].code === "0") {
|
|
132
|
-
// console.log(res, res.response.data)
|
|
133
|
-
this.modId = res.response.data[0].modId
|
|
134
|
-
this.processFieldData(res.response.data[0].fieldData)
|
|
135
|
-
this.portalData = []
|
|
136
|
-
if (res.response.data[0].portalData) this.processPortalData(res.response.data[0].portalData)
|
|
137
|
-
resolve(this)
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace))
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
.catch(e => {
|
|
144
|
-
reject(e)
|
|
145
|
-
})
|
|
115
|
+
if (!this.layout.metadata) await this.layout.getLayoutMeta()
|
|
116
|
+
let res = await this.layout.database.apiRequest<ApiRecordResponseObj>(this.endpoint, {
|
|
117
|
+
port: 443,
|
|
118
|
+
method: "GET"
|
|
146
119
|
})
|
|
120
|
+
|
|
121
|
+
if (res.messages[0].code === "0") {
|
|
122
|
+
// console.log(res, res.response.data)
|
|
123
|
+
this.modId = +res.response.data[0].modId
|
|
124
|
+
this.processFieldData(res.response.data[0].fieldData)
|
|
125
|
+
this.portalData = []
|
|
126
|
+
if (res.response.data[0].portalData) this.processPortalData(res.response.data[0].portalData)
|
|
127
|
+
return this
|
|
128
|
+
}
|
|
147
129
|
}
|
|
148
130
|
|
|
149
131
|
getPortal(portal) {
|
|
150
132
|
return this.portalsArray.find(p => p.name === portal)
|
|
151
133
|
}
|
|
152
134
|
|
|
153
|
-
duplicate(): Promise<LayoutRecord<T,P>> {
|
|
135
|
+
async duplicate(): Promise<LayoutRecord<T, P>> {
|
|
154
136
|
let trace = new Error()
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
method: "POST"
|
|
159
|
-
})
|
|
160
|
-
.then(res => {
|
|
161
|
-
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
162
|
-
reject(new FMError(res.response.scriptError, res.status, res, trace))
|
|
163
|
-
}
|
|
164
|
-
else if (res.messages[0].code === "0") {
|
|
165
|
-
let data = this.toObject((a) => true, (a) => true, (a) => false, (a) => false)
|
|
166
|
-
let _res = new LayoutRecord<T,P>(this.layout, res.response.recordId, res.response.modId, data.fieldData, data.portalData)
|
|
167
|
-
|
|
168
|
-
this.emit("duplicated")
|
|
169
|
-
resolve(_res)
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace))
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
.catch(e => {
|
|
176
|
-
reject(e)
|
|
177
|
-
})
|
|
137
|
+
let res = await this.layout.database.apiRequest<{recordId: string, modId: string}>(this.endpoint, {
|
|
138
|
+
port: 443,
|
|
139
|
+
method: "POST"
|
|
178
140
|
})
|
|
141
|
+
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
142
|
+
throw new FMError(res.response.scriptError, res.httpStatus, res, trace)
|
|
143
|
+
}
|
|
144
|
+
else if (res.messages[0].code === "0") {
|
|
145
|
+
let data = this.toObject((a) => true, (a) => true, (a) => false, (a) => false)
|
|
146
|
+
let _res = new LayoutRecord<T, P>(this.layout, res.response.recordId, res.response.modId, data.fieldData, data.portalData)
|
|
147
|
+
|
|
148
|
+
this.emit("duplicated")
|
|
149
|
+
return _res
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw new FMError(res.messages[0].code, res.httpStatus, res, trace)
|
|
153
|
+
}
|
|
179
154
|
}
|
|
180
155
|
|
|
181
|
-
delete(): Promise<void> {
|
|
182
|
-
let
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
port: 443,
|
|
186
|
-
method: "DELETE"
|
|
187
|
-
})
|
|
188
|
-
.then(res => {
|
|
189
|
-
if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
|
|
190
|
-
reject(new FMError(res.response.scriptError, res.status, res, trace))
|
|
191
|
-
}
|
|
192
|
-
else if (res.messages[0].code === "0") {
|
|
193
|
-
this.emit("deleted")
|
|
194
|
-
resolve()
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
reject(new FMError(res.messages[0].code, res.status, res, trace))
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
.catch(e => {
|
|
201
|
-
reject(e)
|
|
202
|
-
})
|
|
156
|
+
async delete(): Promise<void> {
|
|
157
|
+
let res = await this.layout.database.apiRequest(this.endpoint, {
|
|
158
|
+
port: 443,
|
|
159
|
+
method: "DELETE"
|
|
203
160
|
})
|
|
161
|
+
console.log(res)
|
|
162
|
+
if (typeof res.response?.scriptError !== "undefined" && res.response?.scriptError !== '0') {
|
|
163
|
+
throw new FMError(res.response.scriptError, res.httpStatus, res)
|
|
164
|
+
}
|
|
165
|
+
else if (res.messages[0].code === "0") {
|
|
166
|
+
this.emit("deleted")
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
throw new FMError(res.messages[0].code, res.httpStatus, res)
|
|
171
|
+
}
|
|
204
172
|
}
|
|
205
173
|
|
|
206
174
|
toObject(filter: (a) => any = (a) => a.edited, portalFilter: (a) => any = (a) => a.records.find(record => record.edited), portalRowFilter: (a) => any = (a) => a.edited, portalFieldFilter: (a) => any = (a) => a.edited): recordObject {
|
package/src/records/portal.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { RecordBase, RecordTypes } from "./recordBase.js";
|
|
5
5
|
export class PortalRecord extends RecordBase {
|
|
6
|
+
portal;
|
|
7
|
+
type = RecordTypes.PORTAL;
|
|
6
8
|
constructor(record, portal, recordId, modId = recordId, fieldData = {}) {
|
|
7
9
|
super(record.layout, recordId, modId);
|
|
8
|
-
this.type = RecordTypes.PORTAL;
|
|
9
10
|
this.portal = portal;
|
|
10
11
|
this.processFieldData(fieldData);
|
|
11
12
|
}
|
|
@@ -11,9 +11,14 @@ export var RecordTypes;
|
|
|
11
11
|
RecordTypes[RecordTypes["PORTAL"] = 2] = "PORTAL";
|
|
12
12
|
})(RecordTypes || (RecordTypes = {}));
|
|
13
13
|
export class RecordBase extends EventEmitter {
|
|
14
|
+
layout;
|
|
15
|
+
type = RecordTypes.UNKNOWN;
|
|
16
|
+
recordId;
|
|
17
|
+
modId;
|
|
18
|
+
fields;
|
|
19
|
+
portalData;
|
|
14
20
|
constructor(layout, recordId, modId = recordId) {
|
|
15
21
|
super();
|
|
16
|
-
this.type = RecordTypes.UNKNOWN;
|
|
17
22
|
this.layout = layout;
|
|
18
23
|
this.recordId = recordId;
|
|
19
24
|
this.modId = modId;
|
package/src/types.d.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -83,11 +83,6 @@ export interface recordObject {
|
|
|
83
83
|
portalData?: portalDataObject
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export interface fileMakerResponse {
|
|
87
|
-
response: any,
|
|
88
|
-
messages: any[]
|
|
89
|
-
}
|
|
90
|
-
|
|
91
86
|
export interface portalDataObject {
|
|
92
87
|
[key: string]: recordObject
|
|
93
88
|
}
|
|
@@ -152,5 +147,4 @@ export interface AuthorizationHeadersOAuth {
|
|
|
152
147
|
"Content-Type": "application/json"
|
|
153
148
|
"X-FM-Data-OAuth-RequestId": string,
|
|
154
149
|
"X-FM-Data-OAuth-Identifier": string
|
|
155
|
-
}
|
|
156
|
-
|
|
150
|
+
}
|
package/.expo/README.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
> Why do I have a folder named ".expo" in my project?
|
|
2
|
-
|
|
3
|
-
The ".expo" folder is created when an Expo project is started using "expo start" command.
|
|
4
|
-
|
|
5
|
-
> What do the files contain?
|
|
6
|
-
|
|
7
|
-
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
|
|
8
|
-
- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
|
|
9
|
-
- "settings.json": contains the server configuration that is used to serve the application manifest.
|
|
10
|
-
|
|
11
|
-
> Should I commit the ".expo" folder?
|
|
12
|
-
|
|
13
|
-
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
|
|
14
|
-
|
|
15
|
-
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
|
package/.expo/settings.json
DELETED
package/.idea/compiler.xml
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<component name="CopyrightManager">
|
|
2
|
-
<copyright>
|
|
3
|
-
<option name="notice" value="Copyright (c) &#36;originalComment.match("Copyright \(c\) (\d+)", 1, "-", "&#36;today.year")&#36;today.year. See LICENSE file for more information" />
|
|
4
|
-
<option name="myName" value="JD-Data" />
|
|
5
|
-
</copyright>
|
|
6
|
-
</component>
|
package/.idea/discord.xml
DELETED
package/.idea/easy-fm.iml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$" />
|
|
5
|
-
<orderEntry type="inheritedJdk" />
|
|
6
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
-
</component>
|
|
8
|
-
</module>
|
package/.idea/modules.xml
DELETED
package/.idea/php.xml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="MessDetectorOptionsConfiguration">
|
|
4
|
-
<option name="transferred" value="true" />
|
|
5
|
-
</component>
|
|
6
|
-
<component name="PHPCSFixerOptionsConfiguration">
|
|
7
|
-
<option name="transferred" value="true" />
|
|
8
|
-
</component>
|
|
9
|
-
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
10
|
-
<option name="transferred" value="true" />
|
|
11
|
-
</component>
|
|
12
|
-
<component name="PhpStanOptionsConfiguration">
|
|
13
|
-
<option name="transferred" value="true" />
|
|
14
|
-
</component>
|
|
15
|
-
<component name="PsalmOptionsConfiguration">
|
|
16
|
-
<option name="transferred" value="true" />
|
|
17
|
-
</component>
|
|
18
|
-
</project>
|
package/.idea/vcs.xml
DELETED