@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.
Files changed (102) hide show
  1. package/README.md +36 -24
  2. package/package.json +15 -8
  3. package/src/FMError.d.ts +1 -1
  4. package/src/FMError.js +7 -2
  5. package/src/FMError.ts +3 -3
  6. package/src/connection/FMHost.d.ts +3 -2
  7. package/src/connection/FMHost.js +37 -47
  8. package/src/connection/FMHost.ts +6 -6
  9. package/src/connection/HostBase.d.ts +1 -1
  10. package/src/connection/HostBase.js +1 -1
  11. package/src/connection/HostBase.ts +2 -4
  12. package/src/connection/database.d.ts +12 -9
  13. package/src/connection/database.js +93 -116
  14. package/src/connection/database.ts +79 -90
  15. package/src/connection/databaseBase.d.ts +5 -2
  16. package/src/connection/databaseBase.js +1 -1
  17. package/src/connection/databaseBase.ts +5 -4
  18. package/src/databaseStructure.d.ts +6 -0
  19. package/src/databaseStructure.js +4 -0
  20. package/src/databaseStructure.ts +12 -0
  21. package/src/index.d.ts +3 -6
  22. package/src/index.js +3 -5
  23. package/src/index.ts +4 -9
  24. package/src/layouts/layout.d.ts +5 -19
  25. package/src/layouts/layout.js +27 -69
  26. package/src/layouts/layout.ts +26 -65
  27. package/src/layouts/layoutBase.d.ts +4 -4
  28. package/src/layouts/layoutBase.js +1 -1
  29. package/src/layouts/layoutBase.ts +5 -5
  30. package/src/layouts/layoutInterface.d.ts +1 -1
  31. package/src/layouts/layoutInterface.js +1 -1
  32. package/src/layouts/layoutInterface.ts +2 -2
  33. package/src/layouts/layoutRecordManager.d.ts +5 -6
  34. package/src/layouts/layoutRecordManager.js +20 -39
  35. package/src/layouts/layoutRecordManager.ts +20 -41
  36. package/src/layouts/recordFieldsMap.d.ts +2 -2
  37. package/src/layouts/recordFieldsMap.js +1 -1
  38. package/src/layouts/recordFieldsMap.ts +3 -3
  39. package/src/models/apiResults.d.ts +103 -0
  40. package/src/models/apiResults.js +28 -0
  41. package/src/models/apiResults.ts +112 -0
  42. package/src/records/field.d.ts +3 -22
  43. package/src/records/field.js +4 -177
  44. package/src/records/field.ts +4 -187
  45. package/src/records/fieldBase.d.ts +30 -0
  46. package/src/records/fieldBase.js +154 -0
  47. package/src/records/fieldBase.ts +174 -0
  48. package/src/records/getOperations/recordGetOperation.d.ts +47 -11
  49. package/src/records/getOperations/recordGetOperation.js +144 -30
  50. package/src/records/getOperations/recordGetOperation.ts +172 -30
  51. package/src/records/layoutRecord.d.ts +8 -7
  52. package/src/records/layoutRecord.js +107 -153
  53. package/src/records/layoutRecord.ts +117 -141
  54. package/src/records/portal.d.ts +6 -5
  55. package/src/records/portal.js +4 -1
  56. package/src/records/portal.ts +7 -7
  57. package/src/records/portalBase.d.ts +5 -4
  58. package/src/records/portalBase.js +1 -1
  59. package/src/records/portalBase.ts +6 -6
  60. package/src/records/portalRecord.d.ts +6 -6
  61. package/src/records/portalRecord.js +5 -3
  62. package/src/records/portalRecord.ts +5 -5
  63. package/src/records/recordBase.d.ts +7 -12
  64. package/src/records/recordBase.js +12 -11
  65. package/src/records/recordBase.ts +10 -15
  66. package/src/types.d.ts +18 -19
  67. package/src/types.js +7 -1
  68. package/src/types.ts +20 -21
  69. package/.expo/README.md +0 -15
  70. package/.expo/settings.json +0 -8
  71. package/.idea/compiler.xml +0 -7
  72. package/.idea/copyright/JD_Data.xml +0 -6
  73. package/.idea/copyright/profiles_settings.xml +0 -7
  74. package/.idea/discord.xml +0 -7
  75. package/.idea/easy-fm.iml +0 -8
  76. package/.idea/jsLibraryMappings.xml +0 -6
  77. package/.idea/modules.xml +0 -8
  78. package/.idea/php.xml +0 -18
  79. package/.idea/vcs.xml +0 -6
  80. package/decs.d.ts +0 -7
  81. package/dist/index.min.js +0 -2
  82. package/dist/index.min.js.LICENSE.txt +0 -3
  83. package/docs/classes/FileMakerConnection.md +0 -86
  84. package/docs/classes/layout.md +0 -0
  85. package/examples/test.js +0 -7
  86. package/fmErrors.json +0 -1010
  87. package/img.png +0 -0
  88. package/src/records/getOperations/find.d.ts +0 -15
  89. package/src/records/getOperations/find.js +0 -90
  90. package/src/records/getOperations/find.ts +0 -88
  91. package/src/records/getOperations/recordGetRange.d.ts +0 -13
  92. package/src/records/getOperations/recordGetRange.js +0 -95
  93. package/src/records/getOperations/recordGetRange.ts +0 -84
  94. package/src/records/portalRecordBase.d.ts +0 -4
  95. package/src/records/portalRecordBase.js +0 -6
  96. package/test.d.ts +0 -2
  97. package/test.js +0 -30
  98. package/test.ts +0 -33
  99. package/test2.d.ts +0 -1
  100. package/test2.js +0 -15
  101. package/tsconfig.json +0 -16
  102. package/webpack.config.cjs +0 -20
@@ -1,23 +1,32 @@
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 {extraBodyOptions, recordObject} from "../types.js";
6
6
  import {RecordBase} from "./recordBase.js";
7
7
  import {PortalRecord} from "./portalRecord.js";
8
8
  import {Portal} from "./portal.js";
9
- import {PortalInterface} from "../layouts/layoutInterface.js";
9
+ import {LayoutInterface} from "../layouts/layoutInterface.js";
10
10
  import {FMError} from "../FMError.js";
11
- import {RecordFieldsMap} from "../layouts/recordFieldsMap";
12
- import {LayoutRecordBase} from "./layoutRecordBase";
11
+ import {LayoutRecordBase} from "./layoutRecordBase.js";
12
+ import {ApiRecordResponseObj} from "../models/apiResults.js";
13
+ import {LayoutBase} from "../layouts/layoutBase.js"
13
14
 
14
- export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface> extends RecordBase<T> implements LayoutRecordBase {
15
+ export class LayoutRecord<LAYOUT extends LayoutInterface, PORTALS_TO_INCLUDE = string> extends RecordBase<LAYOUT["fields"]> implements LayoutRecordBase {
15
16
  // @ts-ignore
16
- portals: P = {}
17
-
18
- constructor(layout, recordId, modId = recordId, fieldData = {}, portalData = null) {
17
+ portals: Pick<LAYOUT["portals"], PORTALS_TO_INCLUDE> = {}
18
+ private readonly portalsToInclude: PORTALS_TO_INCLUDE[]
19
+
20
+ constructor(
21
+ layout: LayoutBase,
22
+ recordId: number | string,
23
+ modId = recordId,
24
+ fieldData: Record<string, string | number> = {},
25
+ portalData = null, portalsToInclude: PORTALS_TO_INCLUDE[] = [])
26
+ {
19
27
  super(layout, recordId, modId);
20
28
  this.processFieldData(fieldData)
29
+ this.portalsToInclude = portalsToInclude
21
30
  if (portalData) {
22
31
  this.processPortalData(portalData)
23
32
  }
@@ -27,77 +36,68 @@ export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface>
27
36
  return Object.values(this.portals)
28
37
  }
29
38
 
30
- commit(extraBody: extraBodyOptions = {}): Promise<this> {
31
- let trace = new Error()
32
- return new Promise(async (resolve, reject) => {
33
- let data = this.toObject()
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
- }
39
+ async commit(extraBody: extraBodyOptions = {}): Promise<this> {
40
+ let data = this.toObject()
41
+ delete data.recordId
42
+ delete data.modId
49
43
 
50
- if (this.recordId === -1) {
51
- // This is a new LayoutRecord
44
+ if (extraBody.scripts?.after) {
45
+ data["script"] = extraBody.scripts.after.name
46
+ if (extraBody.scripts.after.parameter) data["script.param"] = extraBody.scripts.after.parameter
47
+ }
48
+ if (extraBody.scripts?.prerequest) {
49
+ data["script.prerequest"] = extraBody.scripts.after.name
50
+ if (extraBody.scripts.prerequest.parameter) data["script.prerequest.param"] = extraBody.scripts.prerequest.parameter
51
+ }
52
+ if (extraBody.scripts?.presort) {
53
+ data["script.presort"] = extraBody.scripts.presort.name
54
+ if (extraBody.scripts.presort.parameter) data["script.presort.param"] = extraBody.scripts.presort.parameter
55
+ }
52
56
 
53
- this.layout.database.apiRequest(`${this.layout.endpoint}/records`, {
57
+ if (this.recordId === -1) {
58
+ // This is a new LayoutRecord
59
+ let res = await this.layout.database.apiRequest<{ recordId: string, modId: string }>(`${this.layout.endpoint}/records`, {
54
60
  port: 443,
55
61
  method: "POST",
56
62
  body: JSON.stringify(data)
57
63
  })
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
64
 
78
- // for (let item of Object.keys(data)) extraBody[item] = data[item]
79
- this.layout.database.apiRequest(this.endpoint, {
80
- port: 443,
81
- method: "PATCH",
82
- body: JSON.stringify(data)
83
- })
84
- .then(res => {
85
- if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
86
- reject(new FMError(res.response.scriptError, res.status, res, trace))
87
- }
88
- else if (res.messages[0].code === "0") {
89
- this.modId = res.response.modId
90
- this._onSave()
91
- resolve(this)
92
- }
93
- else {
94
- reject(new FMError(res.messages[0].code, res.status, res, trace))
95
- }
96
- })
97
- .catch(e => {
98
- reject(e)
99
- })
65
+ if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
66
+ throw new FMError(res.response.scriptError, res.httpStatus, res)
67
+ }
68
+ else if (res.messages[0].code === "0") {
69
+ this.recordId = parseInt(res.response.recordId)
70
+ this.modId = parseInt(res.response.modId)
71
+ return this
72
+ }
73
+ else {
74
+ throw new FMError(res.messages[0].code, res.httpStatus, res)
75
+ }
76
+ }
77
+
78
+ // for (let item of Object.keys(data)) extraBody[item] = data[item]
79
+ let res = await this.layout.database.apiRequest<{
80
+ modId: string, newPortalRecordInfo: {
81
+ tableName: string,
82
+ recordId: string,
83
+ modId: string
84
+ }[]
85
+ }>(this.endpoint, {
86
+ port: 443,
87
+ method: "PATCH",
88
+ body: JSON.stringify(data)
100
89
  })
90
+ if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
91
+ throw new FMError(res.response.scriptError, res.httpStatus, res)
92
+ }
93
+ else if (res.messages[0].code === "0") {
94
+ this.modId = +res.response.modId
95
+ this._onSave()
96
+ return this
97
+ }
98
+ else {
99
+ throw new FMError(res.messages[0].code, res.httpStatus, res)
100
+ }
101
101
  }
102
102
 
103
103
  protected processPortalData(portalData): void {
@@ -115,92 +115,68 @@ export class LayoutRecord<T extends RecordFieldsMap, P extends PortalInterface>
115
115
  }
116
116
  }
117
117
 
118
- get(): Promise<this> {
118
+ async get(): Promise<this> {
119
119
  let trace = new Error()
120
120
  if (this.recordId === -1) {
121
121
  throw "Cannot get this RecordBase until a commit() is done."
122
122
  }
123
- return new Promise(async (resolve, reject) => {
124
- if (!this.layout.metadata) await this.layout.getLayoutMeta()
125
-
126
- this.layout.database.apiRequest(this.endpoint, {
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
- })
123
+ if (!this.layout.metadata) await this.layout.getLayoutMeta()
124
+ let res = await this.layout.database.apiRequest<ApiRecordResponseObj>(this.endpoint, {
125
+ port: 443,
126
+ method: "GET"
146
127
  })
128
+
129
+ if (res.messages[0].code === "0") {
130
+ // console.log(res, res.response.data)
131
+ this.modId = +res.response.data[0].modId
132
+ this.processFieldData(res.response.data[0].fieldData)
133
+ this.portalData = []
134
+ if (res.response.data[0].portalData) this.processPortalData(res.response.data[0].portalData)
135
+ return this
136
+ }
147
137
  }
148
138
 
149
139
  getPortal(portal) {
150
140
  return this.portalsArray.find(p => p.name === portal)
151
141
  }
152
142
 
153
- duplicate(): Promise<LayoutRecord<T,P>> {
143
+ async duplicate(): Promise<LayoutRecord<LAYOUT>> {
154
144
  let trace = new Error()
155
- return new Promise(async (resolve, reject) => {
156
- this.layout.database.apiRequest(this.endpoint, {
157
- port: 443,
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
- })
145
+ let res = await this.layout.database.apiRequest<{recordId: string, modId: string}>(this.endpoint, {
146
+ port: 443,
147
+ method: "POST"
178
148
  })
149
+ if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
150
+ throw new FMError(res.response.scriptError, res.httpStatus, res, trace)
151
+ }
152
+ else if (res.messages[0].code === "0") {
153
+ let data = this.toObject((a) => true, (a) => true, (a) => false, (a) => false)
154
+ let _res = new LayoutRecord<LAYOUT>(this.layout, res.response.recordId, res.response.modId, data.fieldData, data.portalData)
155
+
156
+ this.emit("duplicated")
157
+ return _res
158
+ }
159
+ else {
160
+ throw new FMError(res.messages[0].code, res.httpStatus, res, trace)
161
+ }
179
162
  }
180
163
 
181
- delete(): Promise<void> {
182
- let trace = new Error()
183
- return new Promise(async (resolve, reject) => {
184
- this.layout.database.apiRequest(this.endpoint, {
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
- })
164
+ async delete(): Promise<void> {
165
+ let res = await this.layout.database.apiRequest(this.endpoint, {
166
+ port: 443,
167
+ method: "DELETE"
203
168
  })
169
+ console.log(res)
170
+ if (typeof res.response?.scriptError !== "undefined" && res.response?.scriptError !== '0') {
171
+ throw new FMError(res.response.scriptError, res.httpStatus, res)
172
+ }
173
+ else if (res.messages[0].code === "0") {
174
+ this.emit("deleted")
175
+ return
176
+ }
177
+ else {
178
+ throw new FMError(res.messages[0].code, res.httpStatus, res)
179
+ }
204
180
  }
205
181
 
206
182
  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 {
@@ -1,11 +1,12 @@
1
1
  import { PortalRecord } from "./portalRecord.js";
2
- import { RecordFieldsMap } from "../layouts/recordFieldsMap";
3
- import { PortalBase } from "./portalBase";
4
- import { LayoutRecord } from "./layoutRecord";
2
+ import { RecordFieldsMap } from "../layouts/recordFieldsMap.js";
3
+ import { PortalBase } from "./portalBase.js";
4
+ import { LayoutRecord } from "./layoutRecord.js";
5
+ import { LayoutInterface } from "../layouts/layoutInterface.js";
5
6
  export declare class Portal<T extends RecordFieldsMap> implements PortalBase<T> {
6
- readonly record: LayoutRecord<any, any>;
7
+ readonly record: LayoutRecord<LayoutInterface>;
7
8
  readonly name: string;
8
9
  records: PortalRecord<T>[];
9
- constructor(record: LayoutRecord<any, any>, name: string);
10
+ constructor(record: LayoutRecord<LayoutInterface, any>, name: string);
10
11
  create(): PortalRecord<T>;
11
12
  }
@@ -1,8 +1,11 @@
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 { PortalRecord } from "./portalRecord.js";
5
5
  export class Portal {
6
+ record;
7
+ name;
8
+ records;
6
9
  constructor(record, name) {
7
10
  this.record = record;
8
11
  this.name = name;
@@ -1,19 +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
5
  import {PortalRecord} from "./portalRecord.js";
6
- import {RecordFieldsMap} from "../layouts/recordFieldsMap";
7
- import {PortalBase} from "./portalBase";
8
- import {LayoutRecordBase} from "./layoutRecordBase";
9
- import {LayoutRecord} from "./layoutRecord";
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<any, any>;
12
+ readonly record: LayoutRecord<LayoutInterface>;
13
13
  readonly name: string;
14
14
  public records: PortalRecord<T>[];
15
15
 
16
- constructor(record: LayoutRecord<any, any>, name: string) {
16
+ constructor(record: LayoutRecord<LayoutInterface, any>, name: string) {
17
17
  this.record = record
18
18
  this.name = name
19
19
  }
@@ -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<any, any>;
6
+ readonly record: LayoutRecord<LayoutInterface>;
6
7
  readonly name: string;
7
8
  records: RecordBase<T>[];
8
9
  }
@@ -1,4 +1,4 @@
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
  export {};
@@ -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 {LayoutRecordBase} from "./layoutRecordBase";
7
- import {RecordBase} from "./recordBase";
8
- import {LayoutRecord} from "./layoutRecord";
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<any, any>
11
+ readonly record: LayoutRecord<LayoutInterface>
12
12
  readonly name: string
13
13
  records: RecordBase<T>[]
14
14
  }
@@ -1,13 +1,13 @@
1
- import { RecordBase, RecordTypes } from "./recordBase.js";
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
5
  export declare class PortalRecord<T extends RecordFieldsMap> extends RecordBase<T> {
6
6
  readonly portal: PortalBase<T>;
7
7
  readonly type = RecordTypes.PORTAL;
8
8
  constructor(record: any, portal: any, recordId: any, modId?: any, fieldData?: {});
9
9
  _onSave(): void;
10
- commit(extraBody?: extraBodyOptions): Promise<import("./layoutRecord.js").LayoutRecord<any, any>>;
10
+ commit(extraBody?: extraBodyOptions): Promise<import("./layoutRecord.js").LayoutRecord<import("../index.js").LayoutInterface, string>>;
11
11
  toObject(fieldFilter: any): any;
12
- getField(field: any): import("./field.js").Field<import("./field.js").FieldValue>;
12
+ getField(field: any): import("./fieldBase.js").FieldBase<import("./fieldBase.js").FieldValue>;
13
13
  }
@@ -1,11 +1,13 @@
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, RecordTypes } from "./recordBase.js";
4
+ import { RecordBase } from "./recordBase.js";
5
+ import { RecordTypes } from "../types.js";
5
6
  export class PortalRecord extends RecordBase {
7
+ portal;
8
+ type = RecordTypes.PORTAL;
6
9
  constructor(record, portal, recordId, modId = recordId, fieldData = {}) {
7
10
  super(record.layout, recordId, modId);
8
- this.type = RecordTypes.PORTAL;
9
11
  this.portal = portal;
10
12
  this.processFieldData(fieldData);
11
13
  }
@@ -1,12 +1,12 @@
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, RecordTypes} from "./recordBase.js";
6
- import {extraBodyOptions, recordObject} from "../types.js";
5
+ import {RecordBase} from "./recordBase.js";
6
+ import {extraBodyOptions, recordObject, 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
10
 
11
11
  export class PortalRecord<T extends RecordFieldsMap> extends RecordBase<T> {
12
12
  readonly portal: PortalBase<T>;
@@ -1,16 +1,11 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { EventEmitter } from "events";
3
- import { Field } from "./field.js";
4
- import { Layout } from "../layouts/layout.js";
5
- import { recordObject } from "../types.js";
6
- import { RecordFieldsMap } from "../layouts/recordFieldsMap";
7
- export declare enum RecordTypes {
8
- UNKNOWN = 0,
9
- LAYOUT = 1,
10
- PORTAL = 2
11
- }
3
+ import { FieldBase, FieldValue } from "./fieldBase.js";
4
+ import { recordObject, RecordTypes } from "../types.js";
5
+ import { RecordFieldsMap } from "../layouts/recordFieldsMap.js";
6
+ import { LayoutBase } from "../layouts/layoutBase.js";
12
7
  export declare class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
13
- readonly layout: Layout<any>;
8
+ readonly layout: LayoutBase;
14
9
  readonly type: RecordTypes;
15
10
  recordId: number;
16
11
  modId: number;
@@ -19,7 +14,7 @@ export declare class RecordBase<T extends RecordFieldsMap> extends EventEmitter
19
14
  constructor(layout: any, recordId: any, modId?: any);
20
15
  get endpoint(): string;
21
16
  get edited(): boolean;
22
- get fieldsArray(): Field<import("./field.js").FieldValue>[];
17
+ get fieldsArray(): FieldBase<FieldValue>[];
23
18
  protected processFieldData(fieldData: any): T;
24
19
  _onSave(): void;
25
20
  toObject(filter?: (a: any) => any, portalFilter?: (a: any) => any, portalRowFilter?: (a: any) => any, portalFieldFilter?: (a: any) => any): recordObject;
@@ -1,19 +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
  import { EventEmitter } from "events";
5
5
  import * as moment from "moment";
6
- import { Field } from "./field.js";
7
- export var RecordTypes;
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 {
9
+ layout;
10
+ type = RecordTypes.UNKNOWN;
11
+ recordId;
12
+ modId;
13
+ fields;
14
+ portalData;
14
15
  constructor(layout, recordId, modId = recordId) {
15
16
  super();
16
- this.type = RecordTypes.UNKNOWN;
17
17
  this.layout = layout;
18
18
  this.recordId = recordId;
19
19
  this.modId = modId;
@@ -30,7 +30,7 @@ export class RecordBase extends EventEmitter {
30
30
  processFieldData(fieldData) {
31
31
  let fields = {};
32
32
  for (let key of Object.keys(fieldData)) {
33
- let _field = new Field(this, key, fieldData[key]);
33
+ let _field = new FieldBase(this, key, fieldData[key]);
34
34
  if (!!fieldData[key]) {
35
35
  if (_field.metadata.result === "timeStamp") {
36
36
  // @ts-ignore
@@ -69,7 +69,8 @@ export class RecordBase extends EventEmitter {
69
69
  }
70
70
  toObject(filter = (a) => a.edited, portalFilter = (a) => a.records.find(record => record.edited), portalRowFilter = (a) => a.edited, portalFieldFilter = (a) => a.edited) {
71
71
  let fields_processed = {};
72
- for (let field of this.fieldsArray.filter(field => filter(field))) {
72
+ let field;
73
+ for (field of this.fieldsArray.filter(field => filter(field))) {
73
74
  let value = field.value;
74
75
  if (value instanceof Date) {
75
76
  // @ts-ignore
@@ -1,22 +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
5
  import {EventEmitter} from "events";
6
6
  import * as moment from "moment";
7
- import {Field} from "./field.js";
8
- import {Layout} from "../layouts/layout.js";
9
- import {recordObject} from "../types.js";
10
- import {RecordFieldsMap} from "../layouts/recordFieldsMap";
11
-
12
- export enum RecordTypes {
13
- UNKNOWN,
14
- LAYOUT,
15
- PORTAL
16
- }
7
+ import {FieldBase, FieldValue} from "./fieldBase.js";
8
+ import {recordObject, RecordTypes} from "../types.js";
9
+ import {RecordFieldsMap} from "../layouts/recordFieldsMap.js";
10
+ import {LayoutBase} from "../layouts/layoutBase.js";
17
11
 
18
12
  export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
19
- readonly layout: Layout<any>;
13
+ readonly layout: LayoutBase;
20
14
  readonly type: RecordTypes = RecordTypes.UNKNOWN;
21
15
  public recordId: number;
22
16
  modId: number;
@@ -38,7 +32,7 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
38
32
  return !!this.fieldsArray.find(i => i.edited)
39
33
  }
40
34
 
41
- get fieldsArray() {
35
+ get fieldsArray(): FieldBase<FieldValue>[] {
42
36
  return Object.values(this.fields)
43
37
  }
44
38
 
@@ -46,7 +40,7 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
46
40
  let fields: RecordFieldsMap = {}
47
41
 
48
42
  for (let key of Object.keys(fieldData)) {
49
- let _field = new Field(this, key, fieldData[key])
43
+ let _field = new FieldBase(this, key, fieldData[key])
50
44
  if (!!fieldData[key]) {
51
45
  if (_field.metadata.result === "timeStamp") {
52
46
  // @ts-ignore
@@ -91,7 +85,8 @@ export class RecordBase<T extends RecordFieldsMap> extends EventEmitter {
91
85
  portalFieldFilter = (a) => a.edited
92
86
  ): recordObject {
93
87
  let fields_processed = {}
94
- for (let field of this.fieldsArray.filter(field => filter(field))) {
88
+ let field: FieldBase<FieldValue>
89
+ for (field of this.fieldsArray.filter(field => filter(field))) {
95
90
  let value = field.value
96
91
  if (value instanceof Date) {
97
92
  // @ts-ignore