@jd-data-limited/easy-fm 4.0.16 → 4.1.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/package.json +16 -7
- package/src/FMError.d.ts +2 -2
- package/src/FMError.js +507 -508
- package/src/FMError.ts +510 -511
- package/src/connection/FMHost.d.ts +23 -5
- package/src/connection/FMHost.js +42 -26
- package/src/connection/FMHost.ts +63 -49
- package/src/connection/HostBase.d.ts +3 -3
- package/src/connection/HostBase.ts +5 -5
- package/src/connection/database.d.ts +53 -20
- package/src/connection/database.js +107 -90
- package/src/connection/database.ts +133 -121
- package/src/connection/databaseBase.d.ts +11 -7
- package/src/connection/databaseBase.ts +8 -8
- package/src/connection/generateAuthorizationHeaders.d.ts +1 -1
- package/src/connection/generateAuthorizationHeaders.js +10 -10
- package/src/connection/generateAuthorizationHeaders.ts +21 -21
- package/src/databaseStructure.d.ts +2 -4
- package/src/databaseStructure.ts +3 -5
- package/src/index.d.ts +17 -17
- package/src/index.js +13 -13
- package/src/index.ts +24 -24
- package/src/layouts/layout.d.ts +17 -6
- package/src/layouts/layout.js +19 -8
- package/src/layouts/layout.ts +33 -23
- package/src/layouts/layoutBase.d.ts +5 -5
- package/src/layouts/layoutBase.ts +6 -6
- package/src/layouts/layoutInterface.d.ts +3 -5
- package/src/layouts/layoutInterface.ts +4 -6
- package/src/layouts/layoutRecordManager.d.ts +29 -6
- package/src/layouts/layoutRecordManager.js +32 -9
- package/src/layouts/layoutRecordManager.ts +42 -19
- package/src/layouts/recordFieldsMap.d.ts +2 -4
- package/src/layouts/recordFieldsMap.ts +2 -4
- package/src/models/apiResults.d.ts +7 -13
- package/src/models/apiResults.ts +58 -58
- package/src/records/field.d.ts +39 -17
- package/src/records/field.js +248 -131
- package/src/records/field.ts +160 -82
- package/src/records/getOperations/recordGetOperation.d.ts +44 -24
- package/src/records/getOperations/recordGetOperation.js +88 -61
- package/src/records/getOperations/recordGetOperation.ts +128 -108
- package/src/records/layoutRecord.d.ts +28 -14
- package/src/records/layoutRecord.js +69 -60
- package/src/records/layoutRecord.ts +121 -119
- package/src/records/layoutRecordBase.d.ts +2 -2
- package/src/records/layoutRecordBase.ts +3 -3
- package/src/records/portal.d.ts +19 -5
- package/src/records/portal.js +19 -5
- package/src/records/portal.ts +28 -16
- package/src/records/portalBase.d.ts +5 -5
- package/src/records/portalBase.ts +6 -6
- package/src/records/portalRecord.d.ts +16 -8
- package/src/records/portalRecord.js +16 -6
- package/src/records/portalRecord.ts +29 -19
- package/src/records/recordBase.d.ts +18 -8
- package/src/records/recordBase.js +23 -16
- package/src/records/recordBase.ts +41 -37
- package/src/types.d.ts +23 -30
- package/src/types.js +0 -5
- package/src/types.ts +55 -64
- package/src/utils/query.d.ts +7 -7
- package/src/utils/query.js +10 -10
- package/src/utils/query.ts +19 -20
|
@@ -2,35 +2,31 @@
|
|
|
2
2
|
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {LayoutInterface} from
|
|
6
|
-
import {PickPortals, ScriptRequestData} from
|
|
7
|
-
import {LayoutBase} from
|
|
8
|
-
import {LayoutRecord} from
|
|
9
|
-
import {ApiRecordResponseObj} from
|
|
10
|
-
import {FMError} from
|
|
11
|
-
import {FindRequestSymbol, Query} from
|
|
12
|
-
|
|
13
|
-
export type SortOrder =
|
|
14
|
-
export type FindRequestRaw =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type PortalRequest = {
|
|
22
|
-
name: string,
|
|
5
|
+
import {type LayoutInterface} from '../../layouts/layoutInterface.js'
|
|
6
|
+
import {type PickPortals, type ScriptRequestData} from '../../types.js'
|
|
7
|
+
import {type LayoutBase} from '../../layouts/layoutBase.js'
|
|
8
|
+
import {LayoutRecord} from '../layoutRecord.js'
|
|
9
|
+
import {type ApiRecordResponseObj} from '../../models/apiResults.js'
|
|
10
|
+
import {FMError} from '../../FMError.js'
|
|
11
|
+
import {FindRequestSymbol, type Query} from '../../utils/query.js'
|
|
12
|
+
|
|
13
|
+
export type SortOrder = 'ascend' | 'descend'
|
|
14
|
+
export type FindRequestRaw = Record<string, string>
|
|
15
|
+
export type FindRequest = Record<string, Query>
|
|
16
|
+
|
|
17
|
+
export interface PortalRequest {
|
|
18
|
+
name: string
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
type PortalData<T extends LayoutInterface> = {
|
|
26
|
-
[key in keyof T[
|
|
27
|
-
limit: number
|
|
22
|
+
[key in keyof T['portals']]: {
|
|
23
|
+
limit: number
|
|
28
24
|
offset: number
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
export
|
|
32
|
-
portals: Partial<PortalData<T
|
|
33
|
-
limit?: number
|
|
27
|
+
export interface GetOperationOptions<T extends LayoutInterface> {
|
|
28
|
+
portals: Partial<PortalData<T>>
|
|
29
|
+
limit?: number
|
|
34
30
|
offset?: number
|
|
35
31
|
}
|
|
36
32
|
|
|
@@ -38,61 +34,60 @@ export class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOp
|
|
|
38
34
|
protected layout: LayoutBase
|
|
39
35
|
protected limit: number = 100
|
|
40
36
|
protected scriptData: ScriptRequestData = {}
|
|
41
|
-
protected sortData: { fieldName: string, sortOrder: SortOrder }
|
|
37
|
+
protected sortData: Array<{ fieldName: string, sortOrder: SortOrder }> = []
|
|
42
38
|
protected portals: Partial<PortalData<T>>
|
|
43
39
|
protected offset: number = 1
|
|
44
|
-
protected queries: { req: FindRequestRaw, omit: boolean }
|
|
40
|
+
protected queries: Array<{ req: FindRequestRaw, omit: boolean }> = []
|
|
45
41
|
|
|
46
|
-
constructor(layout: LayoutBase, options: OPTIONS) {
|
|
42
|
+
constructor (layout: LayoutBase, options: OPTIONS) {
|
|
47
43
|
this.layout = layout
|
|
48
44
|
this.sortData = []
|
|
49
45
|
this.portals = options.portals
|
|
50
|
-
this.offset = options.offset
|
|
51
|
-
this.limit = options.limit
|
|
46
|
+
this.offset = options.offset ?? 1 // Offset refers to the starting record. offset 1 is the same as no offset.
|
|
47
|
+
this.limit = options.limit ?? 100
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
get isFindRequest() {
|
|
50
|
+
get isFindRequest () {
|
|
55
51
|
return this.queries.length !== 0
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
private formatQueries() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
for (
|
|
54
|
+
private formatQueries () {
|
|
55
|
+
const test = this.queries.map(query => {
|
|
56
|
+
const out: any = {}
|
|
57
|
+
for (const key of Object.keys(query.req)) {
|
|
62
58
|
if (query.req[key]) out[key] = query.req[key]
|
|
63
59
|
else {
|
|
64
60
|
out[key] = query.req[key]
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
|
-
if (query.omit) out.omit =
|
|
63
|
+
if (query.omit) out.omit = 'true'
|
|
68
64
|
return out
|
|
69
65
|
})
|
|
70
66
|
return test
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
protected generateParamsBody(offset: number, limit: number) {
|
|
74
|
-
const params:
|
|
69
|
+
protected generateParamsBody (offset: number, limit: number) {
|
|
70
|
+
const params: Record<string, any> = {
|
|
75
71
|
limit: limit.toString(),
|
|
76
72
|
offset: offset.toString(),
|
|
77
73
|
dateformats: 2 // Ensure dates are received in ISO8601 format
|
|
78
74
|
}
|
|
79
75
|
if (this.sortData.length !== 0) params.sort = this.sortData
|
|
80
76
|
|
|
77
|
+
if (this.scriptData.after) params.script = this.scriptData.after.name
|
|
78
|
+
if (this.scriptData.after?.parameter) params['script.param'] = this.scriptData.after.parameter
|
|
81
79
|
|
|
82
|
-
if (this.scriptData.
|
|
83
|
-
if (this.scriptData.
|
|
80
|
+
if (this.scriptData.presort) params['script.presort'] = this.scriptData.presort.name
|
|
81
|
+
if (this.scriptData.presort?.parameter) params['script.presort.param'] = this.scriptData.presort.parameter
|
|
84
82
|
|
|
85
|
-
if (this.scriptData.
|
|
86
|
-
if (this.scriptData.
|
|
83
|
+
if (this.scriptData.prerequest) params['script.prerequest'] = this.scriptData.prerequest.name
|
|
84
|
+
if (this.scriptData.prerequest?.parameter) params['script.prerequest.param'] = this.scriptData.prerequest.parameter
|
|
87
85
|
|
|
88
|
-
if (this.
|
|
89
|
-
if (this.scriptData.prerequest?.parameter) params["script.prerequest.param"] = this.scriptData.prerequest.parameter
|
|
86
|
+
if (this.queries.length !== 0) params.query = this.formatQueries()
|
|
90
87
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
params["portal"] = portals
|
|
95
|
-
for (let portal of portals) {
|
|
88
|
+
const portals: Array<keyof typeof this.portals> = Object.keys(this.portals)
|
|
89
|
+
params.portal = portals
|
|
90
|
+
for (const portal of portals) {
|
|
96
91
|
params[`offset.${portal.toString()}`] = this.portals[portal]?.offset
|
|
97
92
|
params[`limit.${portal.toString()}`] = this.portals[portal]?.limit
|
|
98
93
|
}
|
|
@@ -100,48 +95,62 @@ export class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOp
|
|
|
100
95
|
return params
|
|
101
96
|
}
|
|
102
97
|
|
|
103
|
-
protected generateParamsURL(offset: number, limit: number) {
|
|
98
|
+
protected generateParamsURL (offset: number, limit: number) {
|
|
104
99
|
const params = new URLSearchParams({
|
|
105
100
|
_limit: limit.toString(),
|
|
106
101
|
_offset: offset.toString(),
|
|
107
|
-
dateformats:
|
|
102
|
+
dateformats: '2' // Ensure dates are received in ISO8601 format
|
|
108
103
|
})
|
|
109
|
-
if (this.sortData.length !== 0) params.set(
|
|
104
|
+
if (this.sortData.length !== 0) params.set('_sort', JSON.stringify(this.sortData))
|
|
110
105
|
|
|
111
|
-
if (this.scriptData.after) params.set(
|
|
112
|
-
if (this.scriptData.after?.parameter) params.set(
|
|
106
|
+
if (this.scriptData.after) params.set('script', this.scriptData.after.name)
|
|
107
|
+
if (this.scriptData.after?.parameter) params.set('script.param', this.scriptData.after.parameter)
|
|
113
108
|
|
|
114
|
-
if (this.scriptData.presort) params.set(
|
|
115
|
-
if (this.scriptData.presort?.parameter) params.set(
|
|
109
|
+
if (this.scriptData.presort) params.set('script.presort', this.scriptData.presort.name)
|
|
110
|
+
if (this.scriptData.presort?.parameter) params.set('script.presort.param', this.scriptData.presort.parameter)
|
|
116
111
|
|
|
117
|
-
if (this.scriptData.prerequest) params.set(
|
|
118
|
-
if (this.scriptData.prerequest?.parameter) params.set(
|
|
112
|
+
if (this.scriptData.prerequest) params.set('script.prerequest', this.scriptData.prerequest.name)
|
|
113
|
+
if (this.scriptData.prerequest?.parameter) params.set('script.prerequest.param', this.scriptData.prerequest.parameter)
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
for (
|
|
122
|
-
params.set(`_offset.${portal.toString()}`, (this.portals[portal]?.limit
|
|
123
|
-
params.set(`_offset.${portal.toString()}`, (this.portals[portal]?.offset
|
|
115
|
+
const portals: Array<keyof typeof this.portals> = Object.keys(this.portals)
|
|
116
|
+
for (const portal of portals) {
|
|
117
|
+
params.set(`_offset.${portal.toString()}`, (this.portals[portal]?.limit ?? '').toString())
|
|
118
|
+
params.set(`_offset.${portal.toString()}`, (this.portals[portal]?.offset ?? '').toString())
|
|
124
119
|
}
|
|
125
120
|
params.set('portal', JSON.stringify(portals))
|
|
126
121
|
|
|
127
122
|
return params
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Configures any FileMaker scripts to be run as a part of the request
|
|
127
|
+
*
|
|
128
|
+
* @param {ScriptRequestData} scripts - The script request data to set.
|
|
129
|
+
* @return {this} - The current instance of the class.
|
|
130
|
+
*/
|
|
131
|
+
scripts (scripts: ScriptRequestData) {
|
|
132
|
+
this.scriptData = scripts
|
|
132
133
|
return this
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Sorts the data based on the given field name and sort order.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} fieldName - The name of the field by which the data should be sorted.
|
|
140
|
+
* @param {SortOrder} sortOrder - The sort order to be applied (either "asc" for ascending or "desc" for descending).
|
|
141
|
+
*
|
|
142
|
+
* @return {this} - Returns the current instance of the object.
|
|
143
|
+
*/
|
|
144
|
+
sort (fieldName: string, sortOrder: SortOrder) {
|
|
136
145
|
this.sortData.push({fieldName, sortOrder})
|
|
137
146
|
return this
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
private parseFindRequest<I extends FindRequest>(query: I): { [key in keyof I]: string } {
|
|
141
|
-
|
|
142
|
-
for (
|
|
150
|
+
const out: any = {}
|
|
151
|
+
for (const key of Object.keys(query)) {
|
|
143
152
|
out[key] = query[key][FindRequestSymbol].map(item => {
|
|
144
|
-
if (typeof item ===
|
|
153
|
+
if (typeof item === 'string') return item
|
|
145
154
|
|
|
146
155
|
// Re-write date into correct format
|
|
147
156
|
return item
|
|
@@ -149,54 +158,66 @@ export class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOp
|
|
|
149
158
|
.clone()
|
|
150
159
|
.utcOffset(this.layout.database.host.timezoneOffsetFunc(item.moment))
|
|
151
160
|
.format(
|
|
152
|
-
item.type ===
|
|
153
|
-
this.layout.database.host.dateFormat
|
|
154
|
-
item.type ==
|
|
155
|
-
this.layout.database.host.timeFormat
|
|
156
|
-
this.layout.database.host.timeStampFormat
|
|
161
|
+
item.type === 'date'
|
|
162
|
+
? this.layout.database.host.dateFormat
|
|
163
|
+
: item.type == 'time'
|
|
164
|
+
? this.layout.database.host.timeFormat
|
|
165
|
+
: this.layout.database.host.timeStampFormat
|
|
157
166
|
)
|
|
158
|
-
}).join(
|
|
167
|
+
}).join('')
|
|
168
|
+
console.log(this.layout.database.host.timeStampFormat, out[key])
|
|
159
169
|
}
|
|
160
170
|
return out
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Adds a new request/query to the list of queries.
|
|
175
|
+
*
|
|
176
|
+
* @param {FindRequest} query - The find request to be added.
|
|
177
|
+
* @param {boolean} [omit=false] - Flag to indicate if the find request should be omitted.
|
|
178
|
+
* @return {Object} - The current object instance.
|
|
179
|
+
*/
|
|
180
|
+
addRequest (query: FindRequest, omit = false) {
|
|
164
181
|
this.queries.push({req: this.parseFindRequest(query), omit})
|
|
165
182
|
return this
|
|
166
183
|
}
|
|
167
184
|
|
|
168
|
-
|
|
169
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Perform a fetch operation.
|
|
187
|
+
*
|
|
188
|
+
* @returns {Promise} A promise that resolves with the result of the fetch operation.
|
|
189
|
+
*/
|
|
190
|
+
async fetch () {
|
|
191
|
+
return await this.performFind(this.offset, this.limit)
|
|
170
192
|
}
|
|
171
193
|
|
|
172
|
-
private async performFind(offset: number, limit: number): Promise<LayoutRecord<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
194
|
+
private async performFind (offset: number, limit: number): Promise<Array<LayoutRecord<
|
|
195
|
+
PickPortals<T, keyof OPTIONS['portals']>
|
|
196
|
+
>>> {
|
|
197
|
+
const trace = new Error()
|
|
176
198
|
await this.layout.getLayoutMeta()
|
|
177
199
|
|
|
178
|
-
const
|
|
179
|
-
let endpoint = this.layout.endpoint + (
|
|
180
|
-
if (!
|
|
200
|
+
const isFind = this.isFindRequest
|
|
201
|
+
let endpoint = this.layout.endpoint + (isFind ? '/_find' : '/records')
|
|
202
|
+
if (!isFind) endpoint += '?' + new URLSearchParams(this.generateParamsURL(offset, limit)).toString()
|
|
181
203
|
const reqData = {
|
|
182
204
|
// port: 443,
|
|
183
|
-
method:
|
|
184
|
-
body:
|
|
205
|
+
method: isFind ? 'POST' : 'GET',
|
|
206
|
+
body: isFind ? JSON.stringify(this.generateParamsBody(offset, limit)) : undefined
|
|
185
207
|
}
|
|
186
208
|
|
|
187
209
|
try {
|
|
188
|
-
|
|
210
|
+
const res = await this.layout.database._apiRequestJSON<ApiRecordResponseObj>(
|
|
189
211
|
endpoint,
|
|
190
212
|
reqData
|
|
191
213
|
)
|
|
192
|
-
if (res.messages[0].code ===
|
|
214
|
+
if (res.messages[0].code === '0' && res.response) {
|
|
193
215
|
// console.log("RESOLVING")
|
|
194
216
|
if (!this.layout.metadata) await this.layout.getLayoutMeta()
|
|
195
217
|
return res.response.data.map(item => {
|
|
196
218
|
return new LayoutRecord(this.layout, item.recordId, item.modId, item.fieldData, item.portalData)
|
|
197
219
|
})
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
220
|
+
} else {
|
|
200
221
|
throw new FMError(res.messages[0].code, res.httpStatus, res, trace)
|
|
201
222
|
}
|
|
202
223
|
} catch (e) {
|
|
@@ -210,40 +231,39 @@ export class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOp
|
|
|
210
231
|
}
|
|
211
232
|
}
|
|
212
233
|
|
|
213
|
-
[Symbol.asyncIterator]() {
|
|
234
|
+
[Symbol.asyncIterator] () {
|
|
214
235
|
let nextOffset = this.offset
|
|
215
|
-
|
|
216
|
-
|
|
236
|
+
const startOffset: number = JSON.parse(JSON.stringify(this.offset))
|
|
237
|
+
const limit = this.limit
|
|
217
238
|
|
|
218
|
-
let
|
|
219
|
-
let records: LayoutRecord<PickPortals<T, keyof OPTIONS[
|
|
239
|
+
let exitAfterLastRecord = false
|
|
240
|
+
let records: Array<LayoutRecord<PickPortals<T, keyof OPTIONS['portals']>>> = []
|
|
220
241
|
|
|
221
242
|
const fetch = async () => {
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
|
|
243
|
+
const theoreticalLimit = (limit - nextOffset) + startOffset
|
|
244
|
+
if (theoreticalLimit === 0) {
|
|
245
|
+
exitAfterLastRecord = true
|
|
225
246
|
records = []
|
|
226
247
|
return
|
|
227
248
|
}
|
|
228
|
-
records = await this.performFind(nextOffset,
|
|
229
|
-
nextOffset += 100
|
|
230
|
-
if (records.length < 100)
|
|
249
|
+
records = await this.performFind(nextOffset, theoreticalLimit < 100 ? theoreticalLimit : 100)
|
|
250
|
+
nextOffset += 100
|
|
251
|
+
if (records.length < 100) exitAfterLastRecord = true
|
|
231
252
|
}
|
|
232
253
|
|
|
233
254
|
return {
|
|
234
255
|
next: async () => {
|
|
235
|
-
if (records.length === 0 && !
|
|
236
|
-
await fetch()
|
|
256
|
+
if (records.length === 0 && !exitAfterLastRecord) {
|
|
257
|
+
await fetch()
|
|
237
258
|
}
|
|
238
259
|
|
|
239
|
-
if (records.length === 0 &&
|
|
240
|
-
return {done: true, value: undefined}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
260
|
+
if (records.length === 0 && exitAfterLastRecord) {
|
|
261
|
+
return {done: true, value: undefined}
|
|
262
|
+
} else {
|
|
243
263
|
const record = records.shift()
|
|
244
|
-
return {done: false, value: record}
|
|
264
|
+
return {done: false, value: record}
|
|
245
265
|
}
|
|
246
266
|
}
|
|
247
|
-
}
|
|
267
|
+
}
|
|
248
268
|
}
|
|
249
|
-
}
|
|
269
|
+
}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import { extraBodyOptions } from
|
|
2
|
-
import { RecordBase } from
|
|
3
|
-
import { PortalRecord } from
|
|
4
|
-
import { Portal } from
|
|
5
|
-
import { LayoutInterface } from
|
|
6
|
-
import { LayoutRecordBase } from
|
|
7
|
-
import { ApiPortalData, ApiRowDataDef } from
|
|
8
|
-
import { LayoutBase } from
|
|
9
|
-
import { Field, FieldValue } from
|
|
10
|
-
export declare class LayoutRecord<LAYOUT extends LayoutInterface> extends RecordBase<LAYOUT[
|
|
11
|
-
portals: LAYOUT[
|
|
1
|
+
import { type extraBodyOptions } from '../types.js';
|
|
2
|
+
import { RecordBase } from './recordBase.js';
|
|
3
|
+
import { PortalRecord } from './portalRecord.js';
|
|
4
|
+
import { Portal } from './portal.js';
|
|
5
|
+
import { type LayoutInterface } from '../layouts/layoutInterface.js';
|
|
6
|
+
import { type LayoutRecordBase } from './layoutRecordBase.js';
|
|
7
|
+
import { type ApiPortalData, type ApiRowDataDef } from '../models/apiResults.js';
|
|
8
|
+
import { type LayoutBase } from '../layouts/layoutBase.js';
|
|
9
|
+
import { type Field, type FieldValue } from './field.js';
|
|
10
|
+
export declare class LayoutRecord<LAYOUT extends LayoutInterface> extends RecordBase<LAYOUT['fields']> implements LayoutRecordBase {
|
|
11
|
+
portals: LAYOUT['portals'];
|
|
12
12
|
private readonly portalsToInclude;
|
|
13
|
-
constructor(layout: LayoutBase, recordId: number | string, modId?: string | number, fieldData?: Record<string, string | number>, portalData?: ApiPortalData | null, portalsToInclude?:
|
|
14
|
-
get portalsArray(): Portal<any
|
|
13
|
+
constructor(layout: LayoutBase, recordId: number | string, modId?: string | number, fieldData?: Record<string, string | number>, portalData?: ApiPortalData | null, portalsToInclude?: Array<keyof LAYOUT['portals']>);
|
|
14
|
+
get portalsArray(): Array<Portal<any>>;
|
|
15
|
+
/**
|
|
16
|
+
* Asynchronously commits the changes made to the current record.
|
|
17
|
+
* @param {extraBodyOptions} extraBody - The options for the extra body elements.
|
|
18
|
+
* @returns {Promise<this>} - A promise that resolves with the modified object.
|
|
19
|
+
* @throws {FMError} - If an error occurs during the commit process.
|
|
20
|
+
*/
|
|
15
21
|
commit(extraBody?: extraBodyOptions): Promise<this>;
|
|
16
22
|
protected processPortalData(portalData: ApiPortalData): void;
|
|
23
|
+
/**
|
|
24
|
+
* Re-fetches the current record from the database server.
|
|
25
|
+
* Throws an error if commit() has not been called.
|
|
26
|
+
*
|
|
27
|
+
* @return {Promise<this>} A Promise that resolves to this RecordBase instance if the record is successfully retrieved.
|
|
28
|
+
* @throws {Error} If commit() has not been called.
|
|
29
|
+
* @throws {FMError} If the retrieval fails.
|
|
30
|
+
*/
|
|
17
31
|
get(): Promise<this>;
|
|
18
32
|
duplicate(): Promise<LayoutRecord<LAYOUT>>;
|
|
19
33
|
delete(): Promise<void>;
|
|
20
|
-
fieldsToObject(filter?: (a: Field<FieldValue>) => boolean): Omit<ApiRowDataDef,
|
|
34
|
+
fieldsToObject(filter?: (a: Field<FieldValue>) => boolean): Omit<ApiRowDataDef, 'portalData'>;
|
|
21
35
|
toObject(filter?: (a: Field<FieldValue>) => any, portalFilter?: (a: Portal<any>) => any, portalRowFilter?: (a: PortalRecord<never>) => any, portalFieldFilter?: (a: Field<FieldValue>) => any): ApiRowDataDef;
|
|
22
36
|
}
|