@jd-data-limited/easy-fm 4.1.15 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -196
- package/dist/bin/generateTypes.js +3 -3
- package/dist/bin/stressSearch.d.ts +2 -0
- package/dist/bin/stressSearch.js +243 -0
- package/dist/connection/CookieJar.d.ts +19 -0
- package/dist/connection/CookieJar.js +99 -0
- package/dist/connection/FMHost.d.ts +25 -11
- package/dist/connection/FMHost.js +29 -11
- package/dist/connection/HostBase.d.ts +4 -4
- package/dist/connection/Session.d.ts +34 -0
- package/dist/connection/Session.js +109 -0
- package/dist/connection/database.d.ts +34 -31
- package/dist/connection/database.js +72 -133
- package/dist/connection/databaseBase.d.ts +22 -10
- package/dist/connection/databaseConstantSession.d.ts +15 -0
- package/dist/connection/databaseConstantSession.js +70 -0
- package/dist/connection/databaseSessionPool.d.ts +14 -0
- package/dist/connection/databaseSessionPool.js +148 -0
- package/dist/index.d.ts +24 -4
- package/dist/index.js +15 -1
- package/dist/layouts/layout.d.ts +5 -3
- package/dist/layouts/layout.js +11 -15
- package/dist/layouts/layoutBase.d.ts +3 -2
- package/dist/layouts/layoutInterface.d.ts +2 -1
- package/dist/layouts/layoutRecordManager.d.ts +6 -15
- package/dist/layouts/layoutRecordManager.js +6 -15
- package/dist/models/apiResults.d.ts +209 -93
- package/dist/models/apiResults.js +95 -25
- package/dist/records/field.d.ts +17 -2
- package/dist/records/field.js +161 -237
- package/dist/records/fields/baseField.d.ts +57 -0
- package/dist/records/fields/baseField.js +59 -0
- package/dist/records/fields/containerField.d.ts +35 -0
- package/dist/records/fields/containerField.js +78 -0
- package/dist/records/fields/field.d.ts +3 -0
- package/dist/records/fields/field.js +1 -0
- package/dist/records/fields/valueField.d.ts +41 -0
- package/dist/records/fields/valueField.js +108 -0
- package/dist/records/getOperations/recordGetOperation.d.ts +7 -4
- package/dist/records/getOperations/recordGetOperation.js +22 -26
- package/dist/records/layoutRecord.d.ts +27 -9
- package/dist/records/layoutRecord.js +84 -97
- package/dist/records/portal.d.ts +1 -5
- package/dist/records/portal.js +0 -4
- package/dist/records/portalBase.d.ts +1 -2
- package/dist/records/portalRecord.d.ts +7 -4
- package/dist/records/portalRecord.js +12 -0
- package/dist/records/recordBase.d.ts +8 -6
- package/dist/records/recordBase.js +32 -33
- package/dist/types.d.ts +42 -18
- package/dist/types.js +12 -0
- package/dist/utils/addHeaders.d.ts +5 -0
- package/dist/utils/addHeaders.js +24 -0
- package/dist/utils/query.d.ts +24 -8
- package/dist/utils/query.js +60 -20
- package/dist/utils/temporal.d.ts +9 -0
- package/dist/utils/temporal.js +110 -0
- package/package.json +35 -31
package/dist/layouts/layout.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LayoutRecordManager } from './layoutRecordManager.js';
|
|
5
5
|
import { FMError } from '../FMError.js';
|
|
6
|
+
import { ApiLayoutMetadata, ApiScriptResult } from '../models/apiResults.js';
|
|
6
7
|
export class Layout {
|
|
7
8
|
database;
|
|
8
9
|
name;
|
|
@@ -12,6 +13,7 @@ export class Layout {
|
|
|
12
13
|
this.database = database;
|
|
13
14
|
this.name = name;
|
|
14
15
|
}
|
|
16
|
+
/** Base endpoint for this layout on FileMaker Data API. */
|
|
15
17
|
get endpoint() {
|
|
16
18
|
return `${this.database.endpoint}/layouts/${this.name}`;
|
|
17
19
|
}
|
|
@@ -24,19 +26,15 @@ export class Layout {
|
|
|
24
26
|
let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`;
|
|
25
27
|
if (script.parameter)
|
|
26
28
|
url += '?script.param=' + encodeURIComponent(script.parameter);
|
|
27
|
-
const res = await this.database.
|
|
29
|
+
const res = await this.database.fetchJSON(url, {
|
|
30
|
+
type: ApiScriptResult,
|
|
28
31
|
method: 'GET'
|
|
29
32
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
throw new FMError(res.messages[0].code, res.httpStatus, res);
|
|
39
|
-
}
|
|
33
|
+
const error = parseInt(res.scriptError);
|
|
34
|
+
return {
|
|
35
|
+
scriptError: error ? new FMError(error, 200, res) : undefined,
|
|
36
|
+
scriptResult: res.scriptResult
|
|
37
|
+
};
|
|
40
38
|
}
|
|
41
39
|
/**
|
|
42
40
|
* Retrieves the layout metadata
|
|
@@ -48,10 +46,8 @@ export class Layout {
|
|
|
48
46
|
if (this.metadata) {
|
|
49
47
|
return this.metadata;
|
|
50
48
|
}
|
|
51
|
-
const res = await this.database.
|
|
52
|
-
|
|
53
|
-
throw new FMError(res.messages[0].code, res.httpStatus, res);
|
|
54
|
-
this.metadata = res.response;
|
|
49
|
+
const res = await this.database.fetchJSON(this.endpoint, { type: ApiLayoutMetadata });
|
|
50
|
+
this.metadata = res;
|
|
55
51
|
return this.metadata;
|
|
56
52
|
}
|
|
57
53
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type Script, type ScriptResult } from '../types.js';
|
|
2
2
|
import { type DatabaseBase } from '../connection/databaseBase.js';
|
|
3
3
|
import { type ApiLayoutMetadata } from '../models/apiResults.js';
|
|
4
|
+
import { type z } from 'zod';
|
|
4
5
|
export interface LayoutBase {
|
|
5
6
|
readonly name: string;
|
|
6
|
-
metadata: ApiLayoutMetadata | null;
|
|
7
|
+
metadata: z.infer<typeof ApiLayoutMetadata> | null;
|
|
7
8
|
endpoint: string;
|
|
8
9
|
runScript: (script: Script) => Promise<ScriptResult>;
|
|
9
|
-
getLayoutMeta: () => Promise<ApiLayoutMetadata
|
|
10
|
+
getLayoutMeta: () => Promise<z.infer<typeof ApiLayoutMetadata>>;
|
|
10
11
|
database: DatabaseBase;
|
|
11
12
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Portal } from '../records/portal.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Field } from '../records/fields/field.js';
|
|
3
3
|
export interface LayoutInterface {
|
|
4
4
|
fields: RecordFieldsMap;
|
|
5
5
|
portals: PortalInterface;
|
|
6
6
|
}
|
|
7
|
+
export type RecordFieldsMap = Record<string, Field>;
|
|
7
8
|
export type PortalInterface = Record<string | number | symbol, Portal<RecordFieldsMap>>;
|
|
@@ -3,33 +3,24 @@ import { type LayoutInterface } from './layoutInterface.js';
|
|
|
3
3
|
import { type LayoutBase } from './layoutBase.js';
|
|
4
4
|
import { type GetOperationOptions, RecordGetOperation } from '../records/getOperations/recordGetOperation.js';
|
|
5
5
|
import { type PickPortals, type RecordFetchOptions } from '../types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Manager class for handling layout records.
|
|
8
|
-
*/
|
|
6
|
+
/** Provides the `layout.records.*` methods for a Layout. */
|
|
9
7
|
export declare class LayoutRecordManager<T extends LayoutInterface> {
|
|
10
8
|
readonly layout: LayoutBase;
|
|
11
9
|
constructor(layout: LayoutBase);
|
|
12
10
|
/**
|
|
13
|
-
* Creates a new
|
|
11
|
+
* Creates a new unsaved record for this layout.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
* @return {Promise<LayoutRecord<PickPortals<T, OPTIONS['portals'][number]>>>}
|
|
17
|
-
* The newly created layout record.
|
|
13
|
+
* Set field values, then call `commit()` to save it.
|
|
18
14
|
*/
|
|
19
15
|
create<OPTIONS extends RecordFetchOptions>(options: OPTIONS): Promise<LayoutRecord<PickPortals<T, OPTIONS['portals'][number]>>>;
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
17
|
+
* Returns one record by FileMaker `recordId`.
|
|
22
18
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @returns {Promise<LayoutRecord<PickPortals<T, never>>>} - A Promise that resolves with the retrieved layout record.
|
|
19
|
+
* Prefer a normal find when you have a business field you can search by.
|
|
26
20
|
*/
|
|
27
21
|
get(recordId: number): Promise<LayoutRecord<PickPortals<T, never>>>;
|
|
28
22
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param {Array} options - An array of options for the operation.
|
|
32
|
-
* @return {RecordGetOperation} - A new instance of RecordGetOperation.
|
|
23
|
+
* Starts a list or find request for this layout.
|
|
33
24
|
*/
|
|
34
25
|
list<OPTIONS extends GetOperationOptions<T>>(options: OPTIONS): RecordGetOperation<T, OPTIONS>;
|
|
35
26
|
}
|
|
@@ -3,20 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LayoutRecord } from '../records/layoutRecord.js';
|
|
5
5
|
import { RecordGetOperation } from '../records/getOperations/recordGetOperation.js';
|
|
6
|
-
/**
|
|
7
|
-
* Manager class for handling layout records.
|
|
8
|
-
*/
|
|
6
|
+
/** Provides the `layout.records.*` methods for a Layout. */
|
|
9
7
|
export class LayoutRecordManager {
|
|
10
8
|
layout;
|
|
11
9
|
constructor(layout) {
|
|
12
10
|
this.layout = layout;
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
|
-
* Creates a new
|
|
13
|
+
* Creates a new unsaved record for this layout.
|
|
16
14
|
*
|
|
17
|
-
*
|
|
18
|
-
* @return {Promise<LayoutRecord<PickPortals<T, OPTIONS['portals'][number]>>>}
|
|
19
|
-
* The newly created layout record.
|
|
15
|
+
* Set field values, then call `commit()` to save it.
|
|
20
16
|
*/
|
|
21
17
|
async create(options) {
|
|
22
18
|
const metadata = await this.layout.getLayoutMeta();
|
|
@@ -30,11 +26,9 @@ export class LayoutRecordManager {
|
|
|
30
26
|
return new LayoutRecord(this.layout, -1, 0, fields, portals);
|
|
31
27
|
}
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {number} recordId - The identifier of the record to retrieve.
|
|
29
|
+
* Returns one record by FileMaker `recordId`.
|
|
36
30
|
*
|
|
37
|
-
*
|
|
31
|
+
* Prefer a normal find when you have a business field you can search by.
|
|
38
32
|
*/
|
|
39
33
|
async get(recordId) {
|
|
40
34
|
await this.layout.getLayoutMeta();
|
|
@@ -43,10 +37,7 @@ export class LayoutRecordManager {
|
|
|
43
37
|
return record;
|
|
44
38
|
}
|
|
45
39
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @param {Array} options - An array of options for the operation.
|
|
49
|
-
* @return {RecordGetOperation} - A new instance of RecordGetOperation.
|
|
40
|
+
* Starts a list or find request for this layout.
|
|
50
41
|
*/
|
|
51
42
|
list(options) {
|
|
52
43
|
return new RecordGetOperation(this.layout, options);
|
|
@@ -1,97 +1,213 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ApiFieldTypes: {
|
|
3
|
+
readonly NORMAL: "normal";
|
|
4
|
+
readonly CALCULATION: "calculation";
|
|
5
|
+
readonly SUMMARY: "summary";
|
|
6
|
+
};
|
|
7
|
+
export declare const ApiFieldDisplayTypes: {
|
|
8
|
+
readonly EDIT_TEXT: "editText";
|
|
9
|
+
readonly POPUP_LIST: "popupList";
|
|
10
|
+
readonly CHECKBOX: "checkBox";
|
|
11
|
+
readonly RADIO_BUTTONS: "radioButtons";
|
|
12
|
+
readonly SELECTION_LIST: "selectionList";
|
|
13
|
+
readonly CALENDAR: "calendar";
|
|
14
|
+
readonly SECURE_TEXT: "secureText";
|
|
15
|
+
};
|
|
16
|
+
export declare const ApiFieldResultTypes: {
|
|
17
|
+
readonly TEXT: "text";
|
|
18
|
+
readonly NUMBER: "number";
|
|
19
|
+
readonly DATE: "date";
|
|
20
|
+
readonly TIME: "time";
|
|
21
|
+
readonly TIMESTAMP: "timeStamp";
|
|
22
|
+
readonly CONTAINER: "container";
|
|
23
|
+
};
|
|
24
|
+
export type FieldResultTypes = z.infer<typeof ApiFieldResultTypes>;
|
|
25
|
+
export declare const ApiMessage: z.ZodObject<{
|
|
26
|
+
code: z.ZodCoercedNumber<unknown>;
|
|
27
|
+
message: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const ApiResults: z.ZodObject<{
|
|
30
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
31
|
+
code: z.ZodCoercedNumber<unknown>;
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const ApiLayout: z.ZodType<{
|
|
35
36
|
name: string;
|
|
36
37
|
isFolder?: boolean;
|
|
37
|
-
folderLayoutNames?: ApiLayout
|
|
38
|
-
}
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
notEmpty: boolean;
|
|
55
|
-
numeric: boolean;
|
|
56
|
-
repetitions: number;
|
|
57
|
-
timeOfDay: boolean;
|
|
58
|
-
valueList: string;
|
|
59
|
-
}
|
|
60
|
-
export interface ApiValueList {
|
|
61
|
-
name: string;
|
|
62
|
-
type: string;
|
|
63
|
-
values: Array<{
|
|
64
|
-
value: string;
|
|
65
|
-
displayName: string;
|
|
38
|
+
folderLayoutNames?: Array<z.infer<typeof ApiLayout>>;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const ApiFieldMetadata: z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
type: z.ZodEnum<{
|
|
43
|
+
readonly NORMAL: "normal";
|
|
44
|
+
readonly CALCULATION: "calculation";
|
|
45
|
+
readonly SUMMARY: "summary";
|
|
46
|
+
}>;
|
|
47
|
+
displayType: z.ZodEnum<{
|
|
48
|
+
readonly EDIT_TEXT: "editText";
|
|
49
|
+
readonly POPUP_LIST: "popupList";
|
|
50
|
+
readonly CHECKBOX: "checkBox";
|
|
51
|
+
readonly RADIO_BUTTONS: "radioButtons";
|
|
52
|
+
readonly SELECTION_LIST: "selectionList";
|
|
53
|
+
readonly CALENDAR: "calendar";
|
|
54
|
+
readonly SECURE_TEXT: "secureText";
|
|
66
55
|
}>;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
dataInfo: ApiResultSetObj;
|
|
75
|
-
}
|
|
76
|
-
export type ApiFieldData = Record<string, string | number>;
|
|
77
|
-
export type ApiPortalData = Record<string, ApiFieldData[]>;
|
|
78
|
-
export interface ApiResultSetObj {
|
|
79
|
-
database: string;
|
|
80
|
-
layout: string;
|
|
81
|
-
table: string;
|
|
82
|
-
totalRecordCount: number;
|
|
83
|
-
foundCount: number;
|
|
84
|
-
returnedCount: number;
|
|
85
|
-
}
|
|
86
|
-
export interface ApiRowDataDef {
|
|
87
|
-
fieldData: ApiFieldData;
|
|
88
|
-
portalData: ApiPortalData;
|
|
89
|
-
modId: string;
|
|
90
|
-
recordId: string;
|
|
91
|
-
portalDataInfo?: Array<{
|
|
92
|
-
database: string;
|
|
93
|
-
table: string;
|
|
94
|
-
foundCount: number;
|
|
95
|
-
returnedCount: number;
|
|
56
|
+
result: z.ZodEnum<{
|
|
57
|
+
readonly TEXT: "text";
|
|
58
|
+
readonly NUMBER: "number";
|
|
59
|
+
readonly DATE: "date";
|
|
60
|
+
readonly TIME: "time";
|
|
61
|
+
readonly TIMESTAMP: "timeStamp";
|
|
62
|
+
readonly CONTAINER: "container";
|
|
96
63
|
}>;
|
|
97
|
-
|
|
64
|
+
global: z.ZodBoolean;
|
|
65
|
+
autoEnter: z.ZodBoolean;
|
|
66
|
+
fourDigitYear: z.ZodBoolean;
|
|
67
|
+
maxRepeat: z.ZodCoercedNumber<unknown>;
|
|
68
|
+
maxCharacters: z.ZodCoercedNumber<unknown>;
|
|
69
|
+
notEmpty: z.ZodBoolean;
|
|
70
|
+
numeric: z.ZodBoolean;
|
|
71
|
+
repetitionStart: z.ZodCoercedNumber<unknown>;
|
|
72
|
+
repetitionEnd: z.ZodCoercedNumber<unknown>;
|
|
73
|
+
timeOfDay: z.ZodBoolean;
|
|
74
|
+
valueList: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export declare const ApiValueList: z.ZodObject<{
|
|
77
|
+
name: z.ZodString;
|
|
78
|
+
type: z.ZodString;
|
|
79
|
+
values: z.ZodArray<z.ZodObject<{
|
|
80
|
+
value: z.ZodString;
|
|
81
|
+
displayName: z.ZodString;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export declare const ApiLayoutMetadata: z.ZodObject<{
|
|
85
|
+
fieldMetaData: z.ZodArray<z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<{
|
|
88
|
+
readonly NORMAL: "normal";
|
|
89
|
+
readonly CALCULATION: "calculation";
|
|
90
|
+
readonly SUMMARY: "summary";
|
|
91
|
+
}>;
|
|
92
|
+
displayType: z.ZodEnum<{
|
|
93
|
+
readonly EDIT_TEXT: "editText";
|
|
94
|
+
readonly POPUP_LIST: "popupList";
|
|
95
|
+
readonly CHECKBOX: "checkBox";
|
|
96
|
+
readonly RADIO_BUTTONS: "radioButtons";
|
|
97
|
+
readonly SELECTION_LIST: "selectionList";
|
|
98
|
+
readonly CALENDAR: "calendar";
|
|
99
|
+
readonly SECURE_TEXT: "secureText";
|
|
100
|
+
}>;
|
|
101
|
+
result: z.ZodEnum<{
|
|
102
|
+
readonly TEXT: "text";
|
|
103
|
+
readonly NUMBER: "number";
|
|
104
|
+
readonly DATE: "date";
|
|
105
|
+
readonly TIME: "time";
|
|
106
|
+
readonly TIMESTAMP: "timeStamp";
|
|
107
|
+
readonly CONTAINER: "container";
|
|
108
|
+
}>;
|
|
109
|
+
global: z.ZodBoolean;
|
|
110
|
+
autoEnter: z.ZodBoolean;
|
|
111
|
+
fourDigitYear: z.ZodBoolean;
|
|
112
|
+
maxRepeat: z.ZodCoercedNumber<unknown>;
|
|
113
|
+
maxCharacters: z.ZodCoercedNumber<unknown>;
|
|
114
|
+
notEmpty: z.ZodBoolean;
|
|
115
|
+
numeric: z.ZodBoolean;
|
|
116
|
+
repetitionStart: z.ZodCoercedNumber<unknown>;
|
|
117
|
+
repetitionEnd: z.ZodCoercedNumber<unknown>;
|
|
118
|
+
timeOfDay: z.ZodBoolean;
|
|
119
|
+
valueList: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
portalMetaData: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
122
|
+
name: z.ZodString;
|
|
123
|
+
type: z.ZodEnum<{
|
|
124
|
+
readonly NORMAL: "normal";
|
|
125
|
+
readonly CALCULATION: "calculation";
|
|
126
|
+
readonly SUMMARY: "summary";
|
|
127
|
+
}>;
|
|
128
|
+
displayType: z.ZodEnum<{
|
|
129
|
+
readonly EDIT_TEXT: "editText";
|
|
130
|
+
readonly POPUP_LIST: "popupList";
|
|
131
|
+
readonly CHECKBOX: "checkBox";
|
|
132
|
+
readonly RADIO_BUTTONS: "radioButtons";
|
|
133
|
+
readonly SELECTION_LIST: "selectionList";
|
|
134
|
+
readonly CALENDAR: "calendar";
|
|
135
|
+
readonly SECURE_TEXT: "secureText";
|
|
136
|
+
}>;
|
|
137
|
+
result: z.ZodEnum<{
|
|
138
|
+
readonly TEXT: "text";
|
|
139
|
+
readonly NUMBER: "number";
|
|
140
|
+
readonly DATE: "date";
|
|
141
|
+
readonly TIME: "time";
|
|
142
|
+
readonly TIMESTAMP: "timeStamp";
|
|
143
|
+
readonly CONTAINER: "container";
|
|
144
|
+
}>;
|
|
145
|
+
global: z.ZodBoolean;
|
|
146
|
+
autoEnter: z.ZodBoolean;
|
|
147
|
+
fourDigitYear: z.ZodBoolean;
|
|
148
|
+
maxRepeat: z.ZodCoercedNumber<unknown>;
|
|
149
|
+
maxCharacters: z.ZodCoercedNumber<unknown>;
|
|
150
|
+
notEmpty: z.ZodBoolean;
|
|
151
|
+
numeric: z.ZodBoolean;
|
|
152
|
+
repetitionStart: z.ZodCoercedNumber<unknown>;
|
|
153
|
+
repetitionEnd: z.ZodCoercedNumber<unknown>;
|
|
154
|
+
timeOfDay: z.ZodBoolean;
|
|
155
|
+
valueList: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strip>>>;
|
|
157
|
+
valueLists: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
158
|
+
name: z.ZodString;
|
|
159
|
+
type: z.ZodString;
|
|
160
|
+
values: z.ZodArray<z.ZodObject<{
|
|
161
|
+
value: z.ZodString;
|
|
162
|
+
displayName: z.ZodString;
|
|
163
|
+
}, z.core.$strip>>;
|
|
164
|
+
}, z.core.$strip>>>;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
export declare const ApiScriptResult: z.ZodObject<{
|
|
167
|
+
scriptError: z.ZodString;
|
|
168
|
+
scriptResult: z.ZodOptional<z.ZodString>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
export declare const ApiFieldData: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
171
|
+
export declare const ApiResultSetObj: z.ZodObject<{
|
|
172
|
+
database: z.ZodString;
|
|
173
|
+
layout: z.ZodString;
|
|
174
|
+
table: z.ZodString;
|
|
175
|
+
totalRecordCount: z.ZodNumber;
|
|
176
|
+
foundCount: z.ZodNumber;
|
|
177
|
+
returnedCount: z.ZodNumber;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
export declare const ApiPortalData: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
|
|
180
|
+
export declare const ApiRowDataDef: z.ZodObject<{
|
|
181
|
+
fieldData: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
182
|
+
portalData: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
|
|
183
|
+
modId: z.ZodString;
|
|
184
|
+
recordId: z.ZodString;
|
|
185
|
+
portalDataInfo: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
186
|
+
database: z.ZodString;
|
|
187
|
+
table: z.ZodString;
|
|
188
|
+
foundCount: z.ZodNumber;
|
|
189
|
+
returnedCount: z.ZodNumber;
|
|
190
|
+
}, z.core.$strip>>>;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
export declare const ApiRecordResponseObj: z.ZodObject<{
|
|
193
|
+
data: z.ZodArray<z.ZodObject<{
|
|
194
|
+
fieldData: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
195
|
+
portalData: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>>;
|
|
196
|
+
modId: z.ZodString;
|
|
197
|
+
recordId: z.ZodString;
|
|
198
|
+
portalDataInfo: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
199
|
+
database: z.ZodString;
|
|
200
|
+
table: z.ZodString;
|
|
201
|
+
foundCount: z.ZodNumber;
|
|
202
|
+
returnedCount: z.ZodNumber;
|
|
203
|
+
}, z.core.$strip>>>;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
dataInfo: z.ZodObject<{
|
|
206
|
+
database: z.ZodString;
|
|
207
|
+
layout: z.ZodString;
|
|
208
|
+
table: z.ZodString;
|
|
209
|
+
totalRecordCount: z.ZodNumber;
|
|
210
|
+
foundCount: z.ZodNumber;
|
|
211
|
+
returnedCount: z.ZodNumber;
|
|
212
|
+
}, z.core.$strip>;
|
|
213
|
+
}, z.core.$strip>;
|
|
@@ -1,28 +1,98 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2023-2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export const ApiFieldTypes = {
|
|
6
|
+
NORMAL: 'normal',
|
|
7
|
+
CALCULATION: 'calculation',
|
|
8
|
+
SUMMARY: 'summary'
|
|
9
|
+
};
|
|
10
|
+
export const ApiFieldDisplayTypes = {
|
|
11
|
+
EDIT_TEXT: 'editText',
|
|
12
|
+
POPUP_LIST: 'popupList',
|
|
13
|
+
CHECKBOX: 'checkBox',
|
|
14
|
+
RADIO_BUTTONS: 'radioButtons',
|
|
15
|
+
SELECTION_LIST: 'selectionList',
|
|
16
|
+
CALENDAR: 'calendar',
|
|
17
|
+
SECURE_TEXT: 'secureText'
|
|
18
|
+
};
|
|
19
|
+
export const ApiFieldResultTypes = {
|
|
20
|
+
TEXT: 'text',
|
|
21
|
+
NUMBER: 'number',
|
|
22
|
+
DATE: 'date',
|
|
23
|
+
TIME: 'time',
|
|
24
|
+
TIMESTAMP: 'timeStamp',
|
|
25
|
+
CONTAINER: 'container'
|
|
26
|
+
};
|
|
27
|
+
export const ApiMessage = z.object({
|
|
28
|
+
code: z.coerce.number(),
|
|
29
|
+
message: z.string()
|
|
30
|
+
});
|
|
31
|
+
export const ApiResults = z.object({
|
|
32
|
+
messages: z.array(ApiMessage)
|
|
33
|
+
});
|
|
34
|
+
export const ApiLayout = z.lazy(() => z.object({
|
|
35
|
+
name: z.string(),
|
|
36
|
+
isFolder: z.boolean().optional(),
|
|
37
|
+
folderLayoutNames: z.array(ApiLayout).optional(),
|
|
38
|
+
}));
|
|
39
|
+
export const ApiFieldMetadata = z.object({
|
|
40
|
+
name: z.string(),
|
|
41
|
+
type: z.enum(ApiFieldTypes),
|
|
42
|
+
displayType: z.enum(ApiFieldDisplayTypes),
|
|
43
|
+
result: z.enum(ApiFieldResultTypes),
|
|
44
|
+
global: z.boolean(),
|
|
45
|
+
autoEnter: z.boolean(),
|
|
46
|
+
fourDigitYear: z.boolean(),
|
|
47
|
+
maxRepeat: z.coerce.number(),
|
|
48
|
+
maxCharacters: z.coerce.number(),
|
|
49
|
+
notEmpty: z.boolean(),
|
|
50
|
+
numeric: z.boolean(),
|
|
51
|
+
repetitionStart: z.coerce.number(),
|
|
52
|
+
repetitionEnd: z.coerce.number(),
|
|
53
|
+
timeOfDay: z.boolean(),
|
|
54
|
+
valueList: z.string().optional()
|
|
55
|
+
});
|
|
56
|
+
export const ApiValueList = z.object({
|
|
57
|
+
name: z.string(),
|
|
58
|
+
type: z.string(),
|
|
59
|
+
values: z.array(z.object({
|
|
60
|
+
value: z.string(),
|
|
61
|
+
displayName: z.string()
|
|
62
|
+
}))
|
|
63
|
+
});
|
|
64
|
+
export const ApiLayoutMetadata = z.object({
|
|
65
|
+
fieldMetaData: z.array(ApiFieldMetadata),
|
|
66
|
+
portalMetaData: z.record(z.string(), z.array(ApiFieldMetadata)),
|
|
67
|
+
valueLists: z.array(ApiValueList).optional()
|
|
68
|
+
});
|
|
69
|
+
export const ApiScriptResult = z.object({
|
|
70
|
+
scriptError: z.string(),
|
|
71
|
+
scriptResult: z.string().optional()
|
|
72
|
+
});
|
|
73
|
+
export const ApiFieldData = z.record(z.string(), z.union([z.string(), z.number(), z.null()]));
|
|
74
|
+
export const ApiResultSetObj = z.object({
|
|
75
|
+
database: z.string(),
|
|
76
|
+
layout: z.string(),
|
|
77
|
+
table: z.string(),
|
|
78
|
+
totalRecordCount: z.number(),
|
|
79
|
+
foundCount: z.number(),
|
|
80
|
+
returnedCount: z.number()
|
|
81
|
+
});
|
|
82
|
+
export const ApiPortalData = z.record(z.string(), z.array(ApiFieldData));
|
|
83
|
+
export const ApiRowDataDef = z.object({
|
|
84
|
+
fieldData: ApiFieldData,
|
|
85
|
+
portalData: ApiPortalData,
|
|
86
|
+
modId: z.string(),
|
|
87
|
+
recordId: z.string(),
|
|
88
|
+
portalDataInfo: z.array(z.object({
|
|
89
|
+
database: z.string(),
|
|
90
|
+
table: z.string(),
|
|
91
|
+
foundCount: z.number(),
|
|
92
|
+
returnedCount: z.number()
|
|
93
|
+
})).optional()
|
|
94
|
+
});
|
|
95
|
+
export const ApiRecordResponseObj = z.object({
|
|
96
|
+
data: z.array(ApiRowDataDef),
|
|
97
|
+
dataInfo: ApiResultSetObj
|
|
98
|
+
});
|
package/dist/records/field.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { RecordTypes } from '../types.js';
|
|
|
2
2
|
import { type ApiFieldMetadata } from '../models/apiResults.js';
|
|
3
3
|
import { type LayoutBase } from '../layouts/layoutBase.js';
|
|
4
4
|
import { type Moment } from 'moment';
|
|
5
|
+
import { Readable } from 'node:stream';
|
|
6
|
+
import { type z } from 'zod';
|
|
5
7
|
export type FieldValue = string | number | Moment | Container;
|
|
6
8
|
export type Container = null;
|
|
7
9
|
export interface Parentable {
|
|
@@ -12,6 +14,9 @@ export interface Parentable {
|
|
|
12
14
|
name: string;
|
|
13
15
|
};
|
|
14
16
|
}
|
|
17
|
+
interface StreamOptions {
|
|
18
|
+
abortSignal?: AbortSignal;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* A class representing a field in a record.
|
|
17
22
|
*
|
|
@@ -24,6 +29,7 @@ export declare class Field<T extends FieldValue> {
|
|
|
24
29
|
protected _value: T | null;
|
|
25
30
|
static firstContainerDownload: Promise<any> | null;
|
|
26
31
|
constructor(record: Parentable, id: string, originalContents: T);
|
|
32
|
+
/** `true` if this field has changed since it was last loaded or saved. */
|
|
27
33
|
get edited(): boolean;
|
|
28
34
|
/**
|
|
29
35
|
* Resets the 'edited' state of this field, without changing its value
|
|
@@ -36,9 +42,12 @@ export declare class Field<T extends FieldValue> {
|
|
|
36
42
|
* @throws {Error} Cannot set container value using set(). Use upload() instead, if the result is a 'container'.
|
|
37
43
|
*/
|
|
38
44
|
set(content: T | null): void;
|
|
39
|
-
|
|
45
|
+
/** Returns the FileMaker metadata for this field. */
|
|
46
|
+
get metadata(): z.infer<typeof ApiFieldMetadata>;
|
|
47
|
+
/** Gets or sets the current field value. */
|
|
40
48
|
get value(): T | null;
|
|
41
49
|
set value(value: T);
|
|
50
|
+
/** Returns this field value as a string. Throws if the value is not a string. */
|
|
42
51
|
get string(): string;
|
|
43
52
|
/**
|
|
44
53
|
* Uploads a file to the container field.
|
|
@@ -52,11 +61,17 @@ export declare class Field<T extends FieldValue> {
|
|
|
52
61
|
*/
|
|
53
62
|
upload(file: File): Promise<void>;
|
|
54
63
|
stream(): Promise<{
|
|
55
|
-
data:
|
|
64
|
+
data: Readable;
|
|
56
65
|
mime: string;
|
|
57
66
|
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the container download as a Web `Response`.
|
|
69
|
+
*/
|
|
70
|
+
webStream(options: StreamOptions): Promise<Response>;
|
|
71
|
+
/** Downloads the full container contents into memory. */
|
|
58
72
|
arrayBuffer(): Promise<{
|
|
59
73
|
data: ArrayBuffer;
|
|
60
74
|
mime: string;
|
|
61
75
|
}>;
|
|
62
76
|
}
|
|
77
|
+
export {};
|