@jd-data-limited/easy-fm 3.2.8 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +36 -24
  2. package/package.json +12 -9
  3. package/src/FMError.js +2 -2
  4. package/src/FMError.ts +2 -2
  5. package/src/connection/FMHost.d.ts +2 -1
  6. package/src/connection/FMHost.js +1 -2
  7. package/src/connection/FMHost.ts +4 -4
  8. package/src/connection/HostBase.d.ts +1 -1
  9. package/src/connection/HostBase.js +1 -1
  10. package/src/connection/HostBase.ts +2 -4
  11. package/src/connection/database.d.ts +10 -10
  12. package/src/connection/database.js +6 -17
  13. package/src/connection/database.ts +17 -27
  14. package/src/connection/databaseBase.d.ts +4 -4
  15. package/src/connection/databaseBase.js +1 -1
  16. package/src/connection/databaseBase.ts +4 -6
  17. package/src/databaseStructure.d.ts +6 -0
  18. package/src/databaseStructure.js +4 -0
  19. package/src/databaseStructure.ts +12 -0
  20. package/src/index.d.ts +3 -6
  21. package/src/index.js +3 -5
  22. package/src/index.ts +4 -9
  23. package/src/layouts/layout.d.ts +3 -17
  24. package/src/layouts/layout.js +2 -20
  25. package/src/layouts/layout.ts +5 -27
  26. package/src/layouts/layoutBase.d.ts +4 -4
  27. package/src/layouts/layoutBase.js +1 -1
  28. package/src/layouts/layoutBase.ts +5 -6
  29. package/src/layouts/layoutInterface.d.ts +1 -1
  30. package/src/layouts/layoutInterface.js +1 -1
  31. package/src/layouts/layoutInterface.ts +2 -2
  32. package/src/layouts/layoutRecordManager.d.ts +5 -6
  33. package/src/layouts/layoutRecordManager.js +5 -9
  34. package/src/layouts/layoutRecordManager.ts +12 -16
  35. package/src/layouts/recordFieldsMap.d.ts +2 -2
  36. package/src/layouts/recordFieldsMap.js +1 -1
  37. package/src/layouts/recordFieldsMap.ts +3 -3
  38. package/src/models/apiResults.d.ts +3 -3
  39. package/src/models/apiResults.js +1 -1
  40. package/src/models/apiResults.ts +2 -4
  41. package/src/records/field.d.ts +3 -23
  42. package/src/records/field.js +3 -152
  43. package/src/records/field.ts +4 -169
  44. package/src/records/fieldBase.d.ts +30 -0
  45. package/src/records/fieldBase.js +154 -0
  46. package/src/records/fieldBase.ts +174 -0
  47. package/src/records/getOperations/recordGetOperation.d.ts +47 -11
  48. package/src/records/getOperations/recordGetOperation.js +142 -31
  49. package/src/records/getOperations/recordGetOperation.ts +172 -30
  50. package/src/records/layoutRecord.d.ts +14 -11
  51. package/src/records/layoutRecord.js +7 -8
  52. package/src/records/layoutRecord.ts +32 -22
  53. package/src/records/portal.d.ts +6 -5
  54. package/src/records/portal.js +1 -1
  55. package/src/records/portal.ts +10 -8
  56. package/src/records/portalBase.d.ts +5 -4
  57. package/src/records/portalBase.js +1 -1
  58. package/src/records/portalBase.ts +6 -6
  59. package/src/records/portalRecord.d.ts +12 -8
  60. package/src/records/portalRecord.js +6 -8
  61. package/src/records/portalRecord.ts +17 -16
  62. package/src/records/recordBase.d.ts +11 -15
  63. package/src/records/recordBase.js +9 -13
  64. package/src/records/recordBase.ts +17 -25
  65. package/src/types.d.ts +18 -15
  66. package/src/types.js +7 -1
  67. package/src/types.ts +20 -16
  68. package/src/records/getOperations/find.d.ts +0 -15
  69. package/src/records/getOperations/find.js +0 -70
  70. package/src/records/getOperations/find.ts +0 -77
  71. package/src/records/getOperations/recordGetRange.d.ts +0 -13
  72. package/src/records/getOperations/recordGetRange.js +0 -77
  73. package/src/records/getOperations/recordGetRange.ts +0 -77
  74. package/src/records/portalRecordBase.d.ts +0 -4
  75. package/src/records/portalRecordBase.js +0 -6
@@ -1,175 +1,10 @@
1
1
  /*
2
- * Copyright (c) 2023. See LICENSE file for more information
2
+ * Copyright (c) 2024. See LICENSE file for more information
3
3
  */
4
4
 
5
- import {RecordBase, RecordTypes} from "./recordBase.js";
6
- import fetch, {File, FormData} from "node-fetch";
7
- import * as http from "http";
8
- import {ContainerBufferResult, DOWNLOAD_MODES, FieldMetaData} from "../types.js";
9
- import {FMError} from "../FMError.js";
10
- import {ApiFieldDisplayTypes, ApiFieldMetadata, ApiFieldResultTypes, ApiFieldTypes} from "../models/apiResults.js";
5
+ import {RecordBase} from "./recordBase";
6
+ import {FieldBase, FieldValue} from "./fieldBase";
11
7
 
12
- export type FieldValue = string | number | Date | Container
13
- export type Container = null
14
-
15
- export class Field<T extends FieldValue> {
8
+ export class Field<T extends FieldValue> extends FieldBase<T> {
16
9
  record: RecordBase<any>;
17
- id: string;
18
- protected _value: T;
19
- edited: boolean;
20
-
21
- constructor(record, id, contents) {
22
- this.record = record
23
- this.id = id
24
- this._value = contents
25
- this.edited = false
26
- }
27
-
28
- set(content: string | number | Date | undefined | null) {
29
- if (this.metadata.result === "container") throw "Cannot set container value using set(). Use upload() instead."
30
- if (
31
- (this.metadata.result === "timeStamp" ||
32
- this.metadata.result === "date" ||
33
- this.metadata.result === "time")
34
- && !(content instanceof Date) && !!content
35
- ) {
36
- throw "Value was not an instance of Date: " + content
37
- }
38
- // @ts-ignore
39
- if (!content) this._value = ""
40
- // @ts-ignore
41
- else this._value = content
42
- this.edited = true
43
- }
44
-
45
- get metadata(): ApiFieldMetadata {
46
- if (!this.record.layout.metadata) {
47
- // Default to a regular text field
48
- return {
49
- name: this.id.toString(),
50
- type: ApiFieldTypes.NORMAL,
51
- displayType: ApiFieldDisplayTypes.EDIT_TEXT,
52
- result: ApiFieldResultTypes.TEXT,
53
- global: false,
54
- autoEnter: true,
55
- fourDigitYear: false,
56
- maxRepeat: 1,
57
- maxCharacters: 0,
58
- notEmpty: false,
59
- numeric: false,
60
- timeOfDay: false,
61
- repetitions: 1,
62
- valueList: ""
63
- }
64
- }
65
- if (this.record.type === RecordTypes.PORTAL) {
66
- // @ts-ignore
67
- return this.record.layout.metadata.portalMetaData[this.record.portal.name || "portal not attached"].find(i => i.name === this.id) as FieldMetaData || {
68
- name: this.id.toString(),
69
- type: 'normal',
70
- displayType: 'editText',
71
- result: 'text',
72
- global: false,
73
- autoEnter: true,
74
- fourDigitYear: false,
75
- maxRepeat: 1,
76
- maxCharacters: 0,
77
- notEmpty: false,
78
- numeric: false,
79
- timeOfDay: false,
80
- repetitionStart: 1,
81
- repetitionEnd: 1
82
- } as FieldMetaData
83
- }
84
- else {
85
- return this.record.layout.metadata.fieldMetaData.find(i => i.name === this.id) || {
86
- name: this.id.toString(),
87
- type: ApiFieldTypes.NORMAL,
88
- displayType: ApiFieldDisplayTypes.EDIT_TEXT,
89
- result: ApiFieldResultTypes.TEXT,
90
- global: false,
91
- autoEnter: true,
92
- fourDigitYear: false,
93
- maxRepeat: 1,
94
- maxCharacters: 0,
95
- notEmpty: false,
96
- numeric: false,
97
- timeOfDay: false,
98
- repetitions: 1,
99
- valueList: ""
100
- }
101
- }
102
- }
103
-
104
- get value(): T {
105
- // if (this.metadata.result === "container") throw "Use await field.stream() to get the contents of a container field, instead of field.value"
106
- return this._value
107
- }
108
-
109
- set value(value: T) {
110
- this._value = value
111
- }
112
-
113
- get string(): string {
114
- if (typeof this._value === "string") {
115
- return this._value
116
- }
117
- throw "Field value is not a string"
118
- }
119
-
120
- get date(): Date {
121
- if (this._value instanceof Date) {
122
- return this._value
123
- }
124
- throw "Field value is not a date"
125
- }
126
-
127
- get number(): number {
128
- if (typeof this._value === "number") {
129
- return this._value
130
- }
131
- throw "Field value is not a number"
132
- }
133
-
134
- async upload(buffer: Buffer, filename: string, mime: string): Promise<void> {
135
- let trace = new Error()
136
- if (this.metadata.result !== "container") throw "Cannot upload a file to the field; " + this.id + " (not a container field)"
137
- let form = new FormData()
138
- form.append("upload", new File([buffer], filename, {type: mime}))
139
-
140
- await this.record.layout.database.apiRequest<null>(`${this.record.endpoint}/containers/${this.id}/1`, {
141
- method: "POST",
142
- // @ts-ignore
143
- headers: {"Authorization": "Bearer " + this.record.layout.database.token},
144
- body: form
145
- })
146
- }
147
-
148
- download(mode: DOWNLOAD_MODES.Stream): Promise<http.IncomingMessage>
149
- download(mode: DOWNLOAD_MODES.Buffer): Promise<ContainerBufferResult>
150
- async download(mode: DOWNLOAD_MODES = DOWNLOAD_MODES.Stream): Promise<http.IncomingMessage | ContainerBufferResult> {
151
- if (this.metadata.result !== ApiFieldResultTypes.CONTAINER) throw new Error("Cannot perform download() on a non-container field")
152
-
153
- let stream = await this.record.layout.database.streamURL(this.string)
154
- if (mode === DOWNLOAD_MODES.Stream) {
155
- return stream
156
- }
157
-
158
- let body = []
159
- return new Promise((resolve, reject) => {
160
- stream.on("data", chunk => {
161
- body.push(chunk)
162
- })
163
- stream.on("error", (e) => {
164
- reject(e)
165
- })
166
- stream.on("end", () => {
167
- resolve({
168
- buffer: Buffer.concat(body),
169
- mime: stream.headers["content-type"],
170
- request: stream
171
- } as ContainerBufferResult)
172
- })
173
- })
174
- }
175
10
  }
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import * as http from "http";
4
+ import { ContainerBufferResult, DOWNLOAD_MODES, RecordTypes } from "../types.js";
5
+ import { ApiFieldMetadata } from "../models/apiResults.js";
6
+ import { LayoutBase } from "../layouts/layoutBase.js";
7
+ export type FieldValue = string | number | Date | Container;
8
+ export type Container = null;
9
+ export type Parentable = {
10
+ layout: LayoutBase;
11
+ type: RecordTypes;
12
+ endpoint: string;
13
+ };
14
+ export declare class FieldBase<T extends FieldValue> {
15
+ parent: Parentable;
16
+ id: string;
17
+ protected _value: T;
18
+ edited: boolean;
19
+ constructor(record: Parentable, id: string, contents: T);
20
+ set(content: string | number | Date | undefined | null): void;
21
+ get metadata(): ApiFieldMetadata;
22
+ get value(): T;
23
+ set value(value: T);
24
+ get string(): string;
25
+ get date(): Date;
26
+ get number(): number;
27
+ upload(buffer: Buffer, filename: string, mime: string): Promise<void>;
28
+ download(mode: DOWNLOAD_MODES.Stream): Promise<http.IncomingMessage>;
29
+ download(mode: DOWNLOAD_MODES.Buffer): Promise<ContainerBufferResult>;
30
+ }
@@ -0,0 +1,154 @@
1
+ /*
2
+ * Copyright (c) 2023-2024. See LICENSE file for more information
3
+ */
4
+ import { DOWNLOAD_MODES, RecordTypes } from "../types.js";
5
+ import { ApiFieldDisplayTypes, ApiFieldResultTypes, ApiFieldTypes } from "../models/apiResults.js";
6
+ export class FieldBase {
7
+ parent;
8
+ id;
9
+ _value;
10
+ edited;
11
+ constructor(record, id, contents) {
12
+ this.parent = record;
13
+ this.id = id;
14
+ this._value = contents;
15
+ this.edited = false;
16
+ }
17
+ set(content) {
18
+ if (this.metadata.result === "container")
19
+ throw "Cannot set container value using set(). Use upload() instead.";
20
+ if ((this.metadata.result === "timeStamp" ||
21
+ this.metadata.result === "date" ||
22
+ this.metadata.result === "time")
23
+ && !(content instanceof Date) && !!content) {
24
+ throw "Value was not an instance of Date: " + content;
25
+ }
26
+ // @ts-ignore
27
+ if (!content)
28
+ this._value = "";
29
+ // @ts-ignore
30
+ else
31
+ this._value = content;
32
+ this.edited = true;
33
+ }
34
+ get metadata() {
35
+ if (!this.parent.layout.metadata) {
36
+ // Default to a regular text field
37
+ return {
38
+ name: this.id.toString(),
39
+ type: ApiFieldTypes.NORMAL,
40
+ displayType: ApiFieldDisplayTypes.EDIT_TEXT,
41
+ result: ApiFieldResultTypes.TEXT,
42
+ global: false,
43
+ autoEnter: true,
44
+ fourDigitYear: false,
45
+ maxRepeat: 1,
46
+ maxCharacters: 0,
47
+ notEmpty: false,
48
+ numeric: false,
49
+ timeOfDay: false,
50
+ repetitions: 1,
51
+ valueList: ""
52
+ };
53
+ }
54
+ if (this.parent.type === RecordTypes.PORTAL) {
55
+ // @ts-ignore
56
+ return this.parent.layout.metadata.portalMetaData[this.parent.portal.name || "portal not attached"].find(i => i.name === this.id) || {
57
+ name: this.id.toString(),
58
+ type: 'normal',
59
+ displayType: 'editText',
60
+ result: 'text',
61
+ global: false,
62
+ autoEnter: true,
63
+ fourDigitYear: false,
64
+ maxRepeat: 1,
65
+ maxCharacters: 0,
66
+ notEmpty: false,
67
+ numeric: false,
68
+ timeOfDay: false,
69
+ repetitionStart: 1,
70
+ repetitionEnd: 1
71
+ };
72
+ }
73
+ else {
74
+ return this.parent.layout.metadata.fieldMetaData.find(i => i.name === this.id) || {
75
+ name: this.id.toString(),
76
+ type: ApiFieldTypes.NORMAL,
77
+ displayType: ApiFieldDisplayTypes.EDIT_TEXT,
78
+ result: ApiFieldResultTypes.TEXT,
79
+ global: false,
80
+ autoEnter: true,
81
+ fourDigitYear: false,
82
+ maxRepeat: 1,
83
+ maxCharacters: 0,
84
+ notEmpty: false,
85
+ numeric: false,
86
+ timeOfDay: false,
87
+ repetitions: 1,
88
+ valueList: ""
89
+ };
90
+ }
91
+ }
92
+ get value() {
93
+ // if (this.metadata.result === "container") throw "Use await field.stream() to get the contents of a container field, instead of field.value"
94
+ return this._value;
95
+ }
96
+ set value(value) {
97
+ this._value = value;
98
+ }
99
+ get string() {
100
+ if (typeof this._value === "string") {
101
+ return this._value;
102
+ }
103
+ throw "Field value is not a string";
104
+ }
105
+ get date() {
106
+ if (this._value instanceof Date) {
107
+ return this._value;
108
+ }
109
+ throw "Field value is not a date";
110
+ }
111
+ get number() {
112
+ if (typeof this._value === "number") {
113
+ return this._value;
114
+ }
115
+ throw "Field value is not a number";
116
+ }
117
+ async upload(buffer, filename, mime) {
118
+ let trace = new Error();
119
+ if (this.metadata.result !== "container")
120
+ throw "Cannot upload a file to the field; " + this.id + " (not a container field)";
121
+ let form = new FormData();
122
+ form.append("upload", new File([buffer], filename, { type: mime }));
123
+ await this.parent.layout.database.apiRequest(`${this.parent.endpoint}/containers/${this.id}/1`, {
124
+ method: "POST",
125
+ // @ts-ignore
126
+ headers: { "Authorization": "Bearer " + this.parent.layout.database.token },
127
+ body: form
128
+ });
129
+ }
130
+ async download(mode = DOWNLOAD_MODES.Stream) {
131
+ if (this.metadata.result !== ApiFieldResultTypes.CONTAINER)
132
+ throw new Error("Cannot perform download() on a non-container field");
133
+ let stream = await this.parent.layout.database.streamURL(this.string);
134
+ if (mode === DOWNLOAD_MODES.Stream) {
135
+ return stream;
136
+ }
137
+ let body = [];
138
+ return new Promise((resolve, reject) => {
139
+ stream.on("data", chunk => {
140
+ body.push(chunk);
141
+ });
142
+ stream.on("error", (e) => {
143
+ reject(e);
144
+ });
145
+ stream.on("end", () => {
146
+ resolve({
147
+ buffer: Buffer.concat(body),
148
+ mime: stream.headers["content-type"],
149
+ request: stream
150
+ });
151
+ });
152
+ });
153
+ }
154
+ }
@@ -0,0 +1,174 @@
1
+ /*
2
+ * Copyright (c) 2023-2024. See LICENSE file for more information
3
+ */
4
+
5
+ import * as http from "http";
6
+ import {ContainerBufferResult, DOWNLOAD_MODES, FieldMetaData, RecordTypes} from "../types.js";
7
+ import {ApiFieldDisplayTypes, ApiFieldMetadata, ApiFieldResultTypes, ApiFieldTypes} from "../models/apiResults.js";
8
+ import {LayoutBase} from "../layouts/layoutBase.js";
9
+
10
+ export type FieldValue = string | number | Date | Container
11
+ export type Container = null
12
+
13
+ export type Parentable = {layout: LayoutBase, type: RecordTypes, endpoint: string}
14
+ export class FieldBase<T extends FieldValue> {
15
+ parent: Parentable;
16
+ id: string;
17
+ protected _value: T;
18
+ edited: boolean;
19
+
20
+ constructor(record: Parentable, id: string, contents: T) {
21
+ this.parent = record
22
+ this.id = id
23
+ this._value = contents
24
+ this.edited = false
25
+ }
26
+
27
+ set(content: string | number | Date | undefined | null) {
28
+ if (this.metadata.result === "container") throw "Cannot set container value using set(). Use upload() instead."
29
+ if (
30
+ (this.metadata.result === "timeStamp" ||
31
+ this.metadata.result === "date" ||
32
+ this.metadata.result === "time")
33
+ && !(content instanceof Date) && !!content
34
+ ) {
35
+ throw "Value was not an instance of Date: " + content
36
+ }
37
+ // @ts-ignore
38
+ if (!content) this._value = ""
39
+ // @ts-ignore
40
+ else this._value = content
41
+ this.edited = true
42
+ }
43
+
44
+ get metadata(): ApiFieldMetadata {
45
+ if (!this.parent.layout.metadata) {
46
+ // Default to a regular text field
47
+ return {
48
+ name: this.id.toString(),
49
+ type: ApiFieldTypes.NORMAL,
50
+ displayType: ApiFieldDisplayTypes.EDIT_TEXT,
51
+ result: ApiFieldResultTypes.TEXT,
52
+ global: false,
53
+ autoEnter: true,
54
+ fourDigitYear: false,
55
+ maxRepeat: 1,
56
+ maxCharacters: 0,
57
+ notEmpty: false,
58
+ numeric: false,
59
+ timeOfDay: false,
60
+ repetitions: 1,
61
+ valueList: ""
62
+ }
63
+ }
64
+ if (this.parent.type === RecordTypes.PORTAL) {
65
+ // @ts-ignore
66
+ return this.parent.layout.metadata.portalMetaData[this.parent.portal.name || "portal not attached"].find(i => i.name === this.id) as FieldMetaData || {
67
+ name: this.id.toString(),
68
+ type: 'normal',
69
+ displayType: 'editText',
70
+ result: 'text',
71
+ global: false,
72
+ autoEnter: true,
73
+ fourDigitYear: false,
74
+ maxRepeat: 1,
75
+ maxCharacters: 0,
76
+ notEmpty: false,
77
+ numeric: false,
78
+ timeOfDay: false,
79
+ repetitionStart: 1,
80
+ repetitionEnd: 1
81
+ } as FieldMetaData
82
+ }
83
+ else {
84
+ return this.parent.layout.metadata.fieldMetaData.find(i => i.name === this.id) || {
85
+ name: this.id.toString(),
86
+ type: ApiFieldTypes.NORMAL,
87
+ displayType: ApiFieldDisplayTypes.EDIT_TEXT,
88
+ result: ApiFieldResultTypes.TEXT,
89
+ global: false,
90
+ autoEnter: true,
91
+ fourDigitYear: false,
92
+ maxRepeat: 1,
93
+ maxCharacters: 0,
94
+ notEmpty: false,
95
+ numeric: false,
96
+ timeOfDay: false,
97
+ repetitions: 1,
98
+ valueList: ""
99
+ }
100
+ }
101
+ }
102
+
103
+ get value(): T {
104
+ // if (this.metadata.result === "container") throw "Use await field.stream() to get the contents of a container field, instead of field.value"
105
+ return this._value
106
+ }
107
+
108
+ set value(value: T) {
109
+ this._value = value
110
+ }
111
+
112
+ get string(): string {
113
+ if (typeof this._value === "string") {
114
+ return this._value
115
+ }
116
+ throw "Field value is not a string"
117
+ }
118
+
119
+ get date(): Date {
120
+ if (this._value instanceof Date) {
121
+ return this._value
122
+ }
123
+ throw "Field value is not a date"
124
+ }
125
+
126
+ get number(): number {
127
+ if (typeof this._value === "number") {
128
+ return this._value
129
+ }
130
+ throw "Field value is not a number"
131
+ }
132
+
133
+ async upload(buffer: Buffer, filename: string, mime: string): Promise<void> {
134
+ let trace = new Error()
135
+ if (this.metadata.result !== "container") throw "Cannot upload a file to the field; " + this.id + " (not a container field)"
136
+ let form = new FormData()
137
+ form.append("upload", new File([buffer], filename, {type: mime}))
138
+
139
+ await this.parent.layout.database.apiRequest<null>(`${this.parent.endpoint}/containers/${this.id}/1`, {
140
+ method: "POST",
141
+ // @ts-ignore
142
+ headers: {"Authorization": "Bearer " + this.parent.layout.database.token},
143
+ body: form
144
+ })
145
+ }
146
+
147
+ download(mode: DOWNLOAD_MODES.Stream): Promise<http.IncomingMessage>
148
+ download(mode: DOWNLOAD_MODES.Buffer): Promise<ContainerBufferResult>
149
+ async download(mode: DOWNLOAD_MODES = DOWNLOAD_MODES.Stream): Promise<http.IncomingMessage | ContainerBufferResult> {
150
+ if (this.metadata.result !== ApiFieldResultTypes.CONTAINER) throw new Error("Cannot perform download() on a non-container field")
151
+
152
+ let stream = await this.parent.layout.database.streamURL(this.string)
153
+ if (mode === DOWNLOAD_MODES.Stream) {
154
+ return stream
155
+ }
156
+
157
+ let body: Uint8Array[] = []
158
+ return new Promise((resolve, reject) => {
159
+ stream.on("data", chunk => {
160
+ body.push(chunk)
161
+ })
162
+ stream.on("error", (e) => {
163
+ reject(e)
164
+ })
165
+ stream.on("end", () => {
166
+ resolve({
167
+ buffer: Buffer.concat(body),
168
+ mime: stream.headers["content-type"],
169
+ request: stream
170
+ } as ContainerBufferResult)
171
+ })
172
+ })
173
+ }
174
+ }
@@ -1,17 +1,53 @@
1
1
  import { LayoutInterface } from "../../layouts/layoutInterface.js";
2
- import { Portal } from "../portal.js";
3
- import { limitPortalsInterface } from "../../types.js";
2
+ import { ScriptRequestData } from "../../types.js";
4
3
  import { LayoutBase } from "../../layouts/layoutBase.js";
5
- export declare class RecordGetOperation<T extends LayoutInterface> {
4
+ import { LayoutRecord } from "../layoutRecord.js";
5
+ export type SortOrder = "ascend" | "descend";
6
+ export type FindRequest = {
7
+ [key: string]: string;
8
+ omit?: "true" | "false";
9
+ };
10
+ export type PortalRequest = {
11
+ name: string;
12
+ };
13
+ type PortalData<T extends LayoutInterface> = {
14
+ [key in keyof T["portals"]]: {
15
+ limit: number;
16
+ offset: number;
17
+ };
18
+ };
19
+ export type GetOperationOptions<T extends LayoutInterface> = {
20
+ portals: Partial<PortalData<T>>;
21
+ limit?: number;
22
+ offset?: number;
23
+ };
24
+ export declare class RecordGetOperation<T extends LayoutInterface, OPTIONS extends GetOperationOptions<T>> {
6
25
  protected layout: LayoutBase;
7
26
  protected limit: number;
8
- protected scripts: object;
9
- protected sort: object[];
10
- protected limitPortals: limitPortalsInterface[];
27
+ protected scriptData: ScriptRequestData;
28
+ protected sortData: {
29
+ fieldName: string;
30
+ sortOrder: SortOrder;
31
+ }[];
32
+ protected portals: Partial<PortalData<T>>;
11
33
  protected offset: number;
12
- constructor(layout: LayoutBase);
13
- addToPortalLimit(portal: Portal<any>, offset?: number, limit?: number): this;
14
- setLimit(limit: number): this;
15
- addSort(fieldName: any, sortOrder: any): this;
16
- setOffset(offset: number): this;
34
+ protected queries: FindRequest[];
35
+ constructor(layout: LayoutBase, options: OPTIONS);
36
+ get isFindRequest(): boolean;
37
+ protected generateParamsBody(offset: number, limit: number): {
38
+ [key: string]: any;
39
+ };
40
+ protected generateParamsURL(offset: number, limit: number): URLSearchParams;
41
+ scripts(scripts: ScriptRequestData): this;
42
+ sort(fieldName: string, sortOrder: SortOrder): this;
43
+ addRequest(query: FindRequest): this;
44
+ fetch(): Promise<LayoutRecord<T, keyof OPTIONS["portals"]>[]>;
45
+ private performFind;
46
+ [Symbol.asyncIterator](): {
47
+ next: () => Promise<{
48
+ done: boolean;
49
+ value: LayoutRecord<T, keyof OPTIONS["portals"]>;
50
+ }>;
51
+ };
17
52
  }
53
+ export {};