@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
package/src/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="node"
|
|
2
|
-
/// <reference types="node"
|
|
3
|
-
import * as http from
|
|
4
|
-
import { FMError } from
|
|
5
|
-
import { LayoutInterface } from
|
|
6
|
-
export type PickPortals<LAYOUT extends LayoutInterface, PORTALS extends string | number | symbol =
|
|
7
|
-
portals: Pick<LAYOUT[
|
|
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:
|
|
21
|
+
method: 'token';
|
|
21
22
|
token: string;
|
|
22
23
|
}
|
|
23
24
|
export interface loginOptionsOAuth {
|
|
24
|
-
method:
|
|
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:
|
|
32
|
+
method: 'filemaker';
|
|
32
33
|
username: string;
|
|
33
34
|
password: string;
|
|
34
35
|
}
|
|
35
36
|
export interface loginOptionsClaris {
|
|
36
|
-
method:
|
|
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
|
|
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
|
|
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
|
|
102
|
+
mime?: string;
|
|
110
103
|
request: http.IncomingMessage;
|
|
111
104
|
}
|
|
112
105
|
export interface AuthorizationHeaders {
|
|
113
|
-
|
|
106
|
+
'Content-Type': 'application/json';
|
|
114
107
|
Authorization: string;
|
|
115
108
|
}
|
|
116
109
|
export interface AuthorizationHeadersOAuth {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
'Content-Type': 'application/json';
|
|
111
|
+
'X-FM-Data-OAuth-RequestId': string;
|
|
112
|
+
'X-FM-Data-OAuth-Identifier': string;
|
|
120
113
|
}
|
|
121
|
-
export
|
|
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
|
-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
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,
|
|
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
|
-
|
|
21
|
+
debug?: boolean
|
|
22
|
+
credentials: loginOptionsOAuth | loginOptionsFileMaker | loginOptionsClaris | loginOptionsToken
|
|
23
23
|
externalSources: databaseOptionsBase[]
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface loginOptionsToken {
|
|
27
|
-
method:
|
|
27
|
+
method: 'token'
|
|
28
28
|
token: string
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface loginOptionsOAuth {
|
|
32
|
-
method:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
132
|
+
'Content-Type': 'application/json'
|
|
142
133
|
Authorization: string
|
|
143
134
|
}
|
|
144
135
|
|
|
145
136
|
export interface AuthorizationHeadersOAuth {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
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
|
+
}
|
package/src/utils/query.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Moment } from
|
|
1
|
+
import { type Moment } from 'moment';
|
|
2
2
|
export declare const FindRequestSymbol: unique symbol;
|
|
3
|
-
export
|
|
4
|
-
type:
|
|
3
|
+
export interface TimestampType {
|
|
4
|
+
type: 'date' | 'time' | 'timestamp';
|
|
5
5
|
moment: Moment;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
type QueryParameter = string | number | TimestampType;
|
|
8
|
-
export
|
|
9
|
-
[FindRequestSymbol]:
|
|
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;
|
package/src/utils/query.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
|
-
import moment from
|
|
5
|
-
export const FindRequestSymbol = Symbol(
|
|
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 (
|
|
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
|
-
|
|
15
|
-
if (typeof item ===
|
|
14
|
+
const argStrings = args.map(item => {
|
|
15
|
+
if (typeof item === 'number') {
|
|
16
16
|
return queryEscape(item.toString());
|
|
17
17
|
}
|
|
18
|
-
else if (typeof item ===
|
|
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:
|
|
31
|
+
type: 'date',
|
|
32
32
|
moment: moment(date)
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
export function asTime(date) {
|
|
36
36
|
return {
|
|
37
|
-
type:
|
|
37
|
+
type: 'time',
|
|
38
38
|
moment: moment(date)
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export function asTimestamp(date) {
|
|
42
42
|
return {
|
|
43
|
-
type:
|
|
43
|
+
type: 'timestamp',
|
|
44
44
|
moment: moment(date)
|
|
45
45
|
};
|
|
46
46
|
}
|
package/src/utils/query.ts
CHANGED
|
@@ -2,30 +2,29 @@
|
|
|
2
2
|
* Copyright (c) 2024. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import moment, {Moment} from
|
|
5
|
+
import moment, {type Moment} from 'moment'
|
|
6
6
|
|
|
7
|
-
export const FindRequestSymbol = Symbol(
|
|
8
|
-
const SPECIAL_CHARACTERS = [
|
|
9
|
-
export
|
|
10
|
-
type:
|
|
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
|
|
14
|
+
export interface Query { [FindRequestSymbol]: Array<string | TimestampType> }
|
|
15
15
|
|
|
16
|
-
export function queryEscape(str: string) {
|
|
17
|
-
for (
|
|
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
|
-
|
|
25
|
-
if (typeof item ===
|
|
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:
|
|
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:
|
|
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:
|
|
54
|
+
type: 'timestamp',
|
|
56
55
|
moment: moment(date)
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
query
|
|
59
|
+
query
|