@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.
Files changed (64) hide show
  1. package/package.json +16 -7
  2. package/src/FMError.d.ts +2 -2
  3. package/src/FMError.js +507 -508
  4. package/src/FMError.ts +510 -511
  5. package/src/connection/FMHost.d.ts +23 -5
  6. package/src/connection/FMHost.js +42 -26
  7. package/src/connection/FMHost.ts +63 -49
  8. package/src/connection/HostBase.d.ts +3 -3
  9. package/src/connection/HostBase.ts +5 -5
  10. package/src/connection/database.d.ts +53 -20
  11. package/src/connection/database.js +107 -90
  12. package/src/connection/database.ts +133 -121
  13. package/src/connection/databaseBase.d.ts +11 -7
  14. package/src/connection/databaseBase.ts +8 -8
  15. package/src/connection/generateAuthorizationHeaders.d.ts +1 -1
  16. package/src/connection/generateAuthorizationHeaders.js +10 -10
  17. package/src/connection/generateAuthorizationHeaders.ts +21 -21
  18. package/src/databaseStructure.d.ts +2 -4
  19. package/src/databaseStructure.ts +3 -5
  20. package/src/index.d.ts +17 -17
  21. package/src/index.js +13 -13
  22. package/src/index.ts +24 -24
  23. package/src/layouts/layout.d.ts +17 -6
  24. package/src/layouts/layout.js +19 -8
  25. package/src/layouts/layout.ts +33 -23
  26. package/src/layouts/layoutBase.d.ts +5 -5
  27. package/src/layouts/layoutBase.ts +6 -6
  28. package/src/layouts/layoutInterface.d.ts +3 -5
  29. package/src/layouts/layoutInterface.ts +4 -6
  30. package/src/layouts/layoutRecordManager.d.ts +29 -6
  31. package/src/layouts/layoutRecordManager.js +32 -9
  32. package/src/layouts/layoutRecordManager.ts +42 -19
  33. package/src/layouts/recordFieldsMap.d.ts +2 -4
  34. package/src/layouts/recordFieldsMap.ts +2 -4
  35. package/src/models/apiResults.d.ts +7 -13
  36. package/src/models/apiResults.ts +58 -58
  37. package/src/records/field.d.ts +39 -17
  38. package/src/records/field.js +248 -131
  39. package/src/records/field.ts +160 -82
  40. package/src/records/getOperations/recordGetOperation.d.ts +44 -24
  41. package/src/records/getOperations/recordGetOperation.js +88 -61
  42. package/src/records/getOperations/recordGetOperation.ts +128 -108
  43. package/src/records/layoutRecord.d.ts +28 -14
  44. package/src/records/layoutRecord.js +69 -60
  45. package/src/records/layoutRecord.ts +121 -119
  46. package/src/records/layoutRecordBase.d.ts +2 -2
  47. package/src/records/layoutRecordBase.ts +3 -3
  48. package/src/records/portal.d.ts +19 -5
  49. package/src/records/portal.js +19 -5
  50. package/src/records/portal.ts +28 -16
  51. package/src/records/portalBase.d.ts +5 -5
  52. package/src/records/portalBase.ts +6 -6
  53. package/src/records/portalRecord.d.ts +16 -8
  54. package/src/records/portalRecord.js +16 -6
  55. package/src/records/portalRecord.ts +29 -19
  56. package/src/records/recordBase.d.ts +18 -8
  57. package/src/records/recordBase.js +23 -16
  58. package/src/records/recordBase.ts +41 -37
  59. package/src/types.d.ts +23 -30
  60. package/src/types.js +0 -5
  61. package/src/types.ts +55 -64
  62. package/src/utils/query.d.ts +7 -7
  63. package/src/utils/query.js +10 -10
  64. package/src/utils/query.ts +19 -20
package/src/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import * as http from "http";
4
- import { FMError } from "./FMError.js";
5
- import { LayoutInterface } from "./layouts/layoutInterface.js";
6
- export type PickPortals<LAYOUT extends LayoutInterface, PORTALS extends string | number | symbol = ""> = Omit<LAYOUT, "portals"> & {
7
- portals: Pick<LAYOUT["portals"], PORTALS>;
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import type * as http from 'http';
4
+ import { type FMError } from './FMError.js';
5
+ import { type LayoutInterface } from './layouts/layoutInterface.js';
6
+ export type PickPortals<LAYOUT extends LayoutInterface, PORTALS extends string | number | symbol = ''> = Omit<LAYOUT, 'portals'> & {
7
+ portals: Pick<LAYOUT['portals'], PORTALS>;
8
8
  };
9
9
  export interface databaseOptionsBase {
10
10
  database: string;
@@ -13,27 +13,28 @@ export interface databaseOptionsBase {
13
13
  }
14
14
  export interface databaseOptionsWithExternalSources extends databaseOptionsBase {
15
15
  database: string;
16
+ debug?: boolean;
16
17
  credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken;
17
18
  externalSources: databaseOptionsBase[];
18
19
  }
19
20
  export interface loginOptionsToken {
20
- method: "token";
21
+ method: 'token';
21
22
  token: string;
22
23
  }
23
24
  export interface loginOptionsOAuth {
24
- method: "oauth";
25
+ method: 'oauth';
25
26
  oauth: {
26
27
  requestId: string;
27
28
  requestIdentifier: string;
28
29
  };
29
30
  }
30
31
  export interface loginOptionsFileMaker {
31
- method: "filemaker";
32
+ method: 'filemaker';
32
33
  username: string;
33
34
  password: string;
34
35
  }
35
36
  export interface loginOptionsClaris {
36
- method: "claris";
37
+ method: 'claris';
37
38
  claris: {
38
39
  fmid: string;
39
40
  };
@@ -43,18 +44,14 @@ export interface portalFetchData<T = string> {
43
44
  offset: number;
44
45
  limit: number;
45
46
  }
46
- export type ScriptRequestData = {
47
+ export interface ScriptRequestData {
47
48
  prerequest?: Script;
48
49
  presort?: Script;
49
50
  after?: Script;
50
- };
51
+ }
51
52
  export interface extraBodyOptions {
52
53
  scripts?: ScriptRequestData;
53
54
  }
54
- export declare enum DownloadModes {
55
- Stream = 0,
56
- Buffer = 1
57
- }
58
55
  export interface Script {
59
56
  name: string;
60
57
  parameter: string;
@@ -65,9 +62,7 @@ export interface recordObject {
65
62
  fieldData: any;
66
63
  portalData?: portalDataObject;
67
64
  }
68
- export interface portalDataObject {
69
- [key: string]: recordObject;
70
- }
65
+ export type portalDataObject = Record<string, recordObject>;
71
66
  export interface FieldMetaData {
72
67
  name: string;
73
68
  type: string;
@@ -86,9 +81,7 @@ export interface FieldMetaData {
86
81
  }
87
82
  export interface LayoutMetaData {
88
83
  fieldMetaData: FieldMetaData[];
89
- portalMetaData?: {
90
- [key: string]: FieldMetaData[];
91
- };
84
+ portalMetaData?: Record<string, FieldMetaData[]>;
92
85
  }
93
86
  export interface FMHostMetadata {
94
87
  productInfo: {
@@ -106,21 +99,21 @@ export interface ScriptResult {
106
99
  }
107
100
  export interface ContainerBufferResult {
108
101
  buffer: Buffer;
109
- mime: string;
102
+ mime?: string;
110
103
  request: http.IncomingMessage;
111
104
  }
112
105
  export interface AuthorizationHeaders {
113
- "Content-Type": "application/json";
106
+ 'Content-Type': 'application/json';
114
107
  Authorization: string;
115
108
  }
116
109
  export interface AuthorizationHeadersOAuth {
117
- "Content-Type": "application/json";
118
- "X-FM-Data-OAuth-RequestId": string;
119
- "X-FM-Data-OAuth-Identifier": string;
110
+ 'Content-Type': 'application/json';
111
+ 'X-FM-Data-OAuth-RequestId': string;
112
+ 'X-FM-Data-OAuth-Identifier': string;
120
113
  }
121
- export type RecordFetchOptions = {
114
+ export interface RecordFetchOptions {
122
115
  readonly portals: readonly string[];
123
- };
116
+ }
124
117
  export declare enum RecordTypes {
125
118
  UNKNOWN = 0,
126
119
  LAYOUT = 1,
package/src/types.js CHANGED
@@ -1,11 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2022-2024. See LICENSE file for more information
3
3
  */
4
- export var DownloadModes;
5
- (function (DownloadModes) {
6
- DownloadModes[DownloadModes["Stream"] = 0] = "Stream";
7
- DownloadModes[DownloadModes["Buffer"] = 1] = "Buffer";
8
- })(DownloadModes || (DownloadModes = {}));
9
4
  export var RecordTypes;
10
5
  (function (RecordTypes) {
11
6
  RecordTypes[RecordTypes["UNKNOWN"] = 0] = "UNKNOWN";
package/src/types.ts CHANGED
@@ -3,73 +3,68 @@
3
3
  */
4
4
 
5
5
  // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
6
- // @ts-ignore
7
- import * as http from "http";
8
- import {FMError} from "./FMError.js";
9
- import {LayoutInterface} from "./layouts/layoutInterface.js";
6
+ import type * as http from 'http'
7
+ import {type FMError} from './FMError.js'
8
+ import {type LayoutInterface} from './layouts/layoutInterface.js'
10
9
 
11
- export type PickPortals<LAYOUT extends LayoutInterface, PORTALS extends string | number | symbol = ""> =
12
- Omit<LAYOUT, "portals"> & { portals: Pick<LAYOUT["portals"], PORTALS> }
10
+ export type PickPortals<LAYOUT extends LayoutInterface, PORTALS extends string | number | symbol = ''> =
11
+ Omit<LAYOUT, 'portals'> & { portals: Pick<LAYOUT['portals'], PORTALS> }
13
12
 
14
13
  export interface databaseOptionsBase {
15
- database: string,
16
- debug?: boolean,
17
- credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken,
14
+ database: string
15
+ debug?: boolean
16
+ credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken
18
17
  }
19
18
 
20
19
  export interface databaseOptionsWithExternalSources extends databaseOptionsBase {
21
20
  database: string
22
- credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken,
21
+ debug?: boolean
22
+ credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken
23
23
  externalSources: databaseOptionsBase[]
24
24
  }
25
25
 
26
26
  export interface loginOptionsToken {
27
- method: "token"
27
+ method: 'token'
28
28
  token: string
29
29
  }
30
30
 
31
31
  export interface loginOptionsOAuth {
32
- method: "oauth"
32
+ method: 'oauth'
33
33
  oauth: {
34
- requestId: string,
34
+ requestId: string
35
35
  requestIdentifier: string
36
36
  }
37
37
  }
38
38
 
39
39
  export interface loginOptionsFileMaker {
40
- method: "filemaker"
41
- username: string,
42
- password: string,
40
+ method: 'filemaker'
41
+ username: string
42
+ password: string
43
43
  }
44
44
 
45
45
  export interface loginOptionsClaris {
46
- method: "claris"
46
+ method: 'claris'
47
47
  claris: {
48
48
  fmid: string
49
49
  }
50
50
  }
51
51
 
52
52
  export interface portalFetchData<T = string> {
53
- portalName: T,
54
- offset: number,
53
+ portalName: T
54
+ offset: number
55
55
  limit: number
56
56
  }
57
57
 
58
- export type ScriptRequestData = {
59
- prerequest?: Script,
60
- presort?: Script,
61
- after?: Script,
58
+ export interface ScriptRequestData {
59
+ prerequest?: Script
60
+ presort?: Script
61
+ after?: Script
62
62
  }
63
63
 
64
64
  export interface extraBodyOptions {
65
65
  scripts?: ScriptRequestData
66
66
  }
67
67
 
68
- export enum DownloadModes {
69
- Stream,
70
- Buffer
71
- }
72
-
73
68
  export interface Script {
74
69
  name: string
75
70
  parameter: string
@@ -77,58 +72,54 @@ export interface Script {
77
72
 
78
73
  export interface recordObject {
79
74
  recordId: number
80
- modId: number,
81
- fieldData: any,
75
+ modId: number
76
+ fieldData: any
82
77
  portalData?: portalDataObject
83
78
  }
84
79
 
85
- export interface portalDataObject {
86
- [key: string]: recordObject
87
- }
80
+ export type portalDataObject = Record<string, recordObject>
88
81
 
89
82
  export interface FieldMetaData {
90
- name: string,
91
- type: string,
92
- displayType: string,
93
- result: string,
94
- global: boolean,
95
- autoEnter: boolean,
96
- fourDigitYear: boolean,
97
- maxRepeat: number,
98
- maxCharacters: number,
99
- notEmpty: boolean,
100
- numeric: boolean,
101
- timeOfDay: false,
102
- repetitionStart: number,
83
+ name: string
84
+ type: string
85
+ displayType: string
86
+ result: string
87
+ global: boolean
88
+ autoEnter: boolean
89
+ fourDigitYear: boolean
90
+ maxRepeat: number
91
+ maxCharacters: number
92
+ notEmpty: boolean
93
+ numeric: boolean
94
+ timeOfDay: false
95
+ repetitionStart: number
103
96
  repetitionEnd: number
104
97
  }
105
98
 
106
99
  export interface LayoutMetaData {
107
- fieldMetaData: FieldMetaData[],
108
- portalMetaData?: {
109
- [key: string]: FieldMetaData[]
110
- }
100
+ fieldMetaData: FieldMetaData[]
101
+ portalMetaData?: Record<string, FieldMetaData[]>
111
102
  }
112
103
 
113
104
  export interface FMHostMetadata {
114
105
  productInfo: {
115
- buildDate: Date,
116
- name: string,
117
- version: string,
118
- dateFormat: string,
119
- timeFormat: string,
106
+ buildDate: Date
107
+ name: string
108
+ version: string
109
+ dateFormat: string
110
+ timeFormat: string
120
111
  timeStampFormat: string
121
112
  }
122
113
  }
123
114
 
124
115
  export interface ScriptResult {
125
- scriptError?: FMError,
116
+ scriptError?: FMError
126
117
  scriptResult?: string
127
118
  }
128
119
 
129
120
  export interface ContainerBufferResult {
130
- buffer: Buffer,
131
- mime: string,
121
+ buffer: Buffer
122
+ mime?: string
132
123
  request: http.IncomingMessage
133
124
  }
134
125
 
@@ -138,17 +129,17 @@ export interface ContainerBufferResult {
138
129
  // }
139
130
 
140
131
  export interface AuthorizationHeaders {
141
- "Content-Type": "application/json"
132
+ 'Content-Type': 'application/json'
142
133
  Authorization: string
143
134
  }
144
135
 
145
136
  export interface AuthorizationHeadersOAuth {
146
- "Content-Type": "application/json"
147
- "X-FM-Data-OAuth-RequestId": string,
148
- "X-FM-Data-OAuth-Identifier": string
137
+ 'Content-Type': 'application/json'
138
+ 'X-FM-Data-OAuth-RequestId': string
139
+ 'X-FM-Data-OAuth-Identifier': string
149
140
  }
150
141
 
151
- export type RecordFetchOptions = {
142
+ export interface RecordFetchOptions {
152
143
  readonly portals: readonly string[]
153
144
  }
154
145
 
@@ -156,4 +147,4 @@ export enum RecordTypes {
156
147
  UNKNOWN,
157
148
  LAYOUT,
158
149
  PORTAL
159
- }
150
+ }
@@ -1,13 +1,13 @@
1
- import { Moment } from "moment";
1
+ import { type Moment } from 'moment';
2
2
  export declare const FindRequestSymbol: unique symbol;
3
- export type TimestampType = {
4
- type: "date" | "time" | "timestamp";
3
+ export interface TimestampType {
4
+ type: 'date' | 'time' | 'timestamp';
5
5
  moment: Moment;
6
- };
6
+ }
7
7
  type QueryParameter = string | number | TimestampType;
8
- export type Query = {
9
- [FindRequestSymbol]: (string | TimestampType)[];
10
- };
8
+ export interface Query {
9
+ [FindRequestSymbol]: Array<string | TimestampType>;
10
+ }
11
11
  export declare function queryEscape(str: string): string;
12
12
  export declare function query(strings: TemplateStringsArray, ...args: QueryParameter[]): Query;
13
13
  export declare function asDate(date: Date | Moment): TimestampType;
@@ -1,21 +1,21 @@
1
1
  /*
2
2
  * Copyright (c) 2024. See LICENSE file for more information
3
3
  */
4
- import moment from "moment";
5
- export const FindRequestSymbol = Symbol("easyfm-findrequest");
6
- const SPECIAL_CHARACTERS = ["\\", "=", "<", "≤", "≥", ">", "…", "...", "//", "@", "#", "*", "\"", "~"];
4
+ import moment from 'moment';
5
+ export const FindRequestSymbol = Symbol('easyfm-findrequest');
6
+ const SPECIAL_CHARACTERS = ['\\', '=', '<', '≤', '≥', '>', '…', '...', '//', '@', '#', '*', '"', '~'];
7
7
  export function queryEscape(str) {
8
- for (let char of SPECIAL_CHARACTERS) {
8
+ for (const char of SPECIAL_CHARACTERS) {
9
9
  str = str.replace(char, `\\${char}`);
10
10
  }
11
11
  return str;
12
12
  }
13
13
  export function query(strings, ...args) {
14
- let argStrings = args.map(item => {
15
- if (typeof item === "number") {
14
+ const argStrings = args.map(item => {
15
+ if (typeof item === 'number') {
16
16
  return queryEscape(item.toString());
17
17
  }
18
- else if (typeof item === "string")
18
+ else if (typeof item === 'string')
19
19
  return queryEscape(item);
20
20
  else
21
21
  return item;
@@ -28,19 +28,19 @@ export function query(strings, ...args) {
28
28
  }
29
29
  export function asDate(date) {
30
30
  return {
31
- type: "date",
31
+ type: 'date',
32
32
  moment: moment(date)
33
33
  };
34
34
  }
35
35
  export function asTime(date) {
36
36
  return {
37
- type: "time",
37
+ type: 'time',
38
38
  moment: moment(date)
39
39
  };
40
40
  }
41
41
  export function asTimestamp(date) {
42
42
  return {
43
- type: "timestamp",
43
+ type: 'timestamp',
44
44
  moment: moment(date)
45
45
  };
46
46
  }
@@ -2,30 +2,29 @@
2
2
  * Copyright (c) 2024. See LICENSE file for more information
3
3
  */
4
4
 
5
- import moment, {Moment} from "moment";
5
+ import moment, {type Moment} from 'moment'
6
6
 
7
- export const FindRequestSymbol = Symbol("easyfm-findrequest");
8
- const SPECIAL_CHARACTERS = ["\\", "=", "<", "≤", "≥", ">", "…", "...", "//", "@", "#", "*", "\"", "~"]
9
- export type TimestampType = {
10
- type: "date" | "time" | "timestamp",
7
+ export const FindRequestSymbol = Symbol('easyfm-findrequest')
8
+ const SPECIAL_CHARACTERS = ['\\', '=', '<', '≤', '≥', '>', '…', '...', '//', '@', '#', '*', '"', '~']
9
+ export interface TimestampType {
10
+ type: 'date' | 'time' | 'timestamp'
11
11
  moment: Moment
12
12
  }
13
13
  type QueryParameter = string | number | TimestampType
14
- export type Query = {[FindRequestSymbol]: (string | TimestampType)[]}
14
+ export interface Query { [FindRequestSymbol]: Array<string | TimestampType> }
15
15
 
16
- export function queryEscape(str: string) {
17
- for (let char of SPECIAL_CHARACTERS) {
16
+ export function queryEscape (str: string) {
17
+ for (const char of SPECIAL_CHARACTERS) {
18
18
  str = str.replace(char, `\\${char}`)
19
19
  }
20
20
  return str
21
21
  }
22
22
 
23
- export function query(strings: TemplateStringsArray, ...args: QueryParameter[]): Query {
24
- let argStrings = args.map(item => {
25
- if (typeof item === "number") {
23
+ export function query (strings: TemplateStringsArray, ...args: QueryParameter[]): Query {
24
+ const argStrings = args.map(item => {
25
+ if (typeof item === 'number') {
26
26
  return queryEscape(item.toString())
27
- }
28
- else if (typeof item === "string") return queryEscape(item)
27
+ } else if (typeof item === 'string') return queryEscape(item)
29
28
  else return item
30
29
  })
31
30
 
@@ -36,25 +35,25 @@ export function query(strings: TemplateStringsArray, ...args: QueryParameter[]):
36
35
  return {[FindRequestSymbol]: query}
37
36
  }
38
37
 
39
- export function asDate(date: Date | Moment): TimestampType {
38
+ export function asDate (date: Date | Moment): TimestampType {
40
39
  return {
41
- type: "date",
40
+ type: 'date',
42
41
  moment: moment(date)
43
42
  }
44
43
  }
45
44
 
46
- export function asTime(date: Date | Moment): TimestampType {
45
+ export function asTime (date: Date | Moment): TimestampType {
47
46
  return {
48
- type: "time",
47
+ type: 'time',
49
48
  moment: moment(date)
50
49
  }
51
50
  }
52
51
 
53
- export function asTimestamp(date: Date | Moment): TimestampType {
52
+ export function asTimestamp (date: Date | Moment): TimestampType {
54
53
  return {
55
- type: "timestamp",
54
+ type: 'timestamp',
56
55
  moment: moment(date)
57
56
  }
58
57
  }
59
58
 
60
- query
59
+ query