@servicenow/glide 27.0.2 → 27.0.3
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 +5 -3
- package/src/types/GlideAggregate.d.ts +35 -22
- package/src/types/GlideQuery.d.ts +1 -1
- package/src/types/GlideQueryCondition.d.ts +15 -10
- package/src/types/GlideRecord.d.ts +1 -0
- package/src/types/GlideRecordSecure.d.ts +9 -14
- package/src/util/index.d.ts +1606 -0
- package/src/util/index.js +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicenow/glide",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.3",
|
|
4
4
|
"description": "Contains type declaration for Glide Scriptable APIs",
|
|
5
5
|
"homepage": "https://www.servicenow.com/docs/csh?topicname=servicenow-sdk-landing&version=latest",
|
|
6
6
|
"keywords": [
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"prebuild": "tsx ./exports.ts",
|
|
14
|
+
"build": "tsc",
|
|
14
15
|
"create-index": "ctix create -a ./src --noBackup --overwrite",
|
|
15
|
-
"test": "jest",
|
|
16
|
+
"test": "npm run build && jest",
|
|
16
17
|
"ci": "npm ci"
|
|
17
18
|
},
|
|
18
19
|
"types": "./src/index.d.ts",
|
|
19
20
|
"files": [
|
|
20
|
-
"src"
|
|
21
|
+
"src",
|
|
22
|
+
"!src/util/index.ts"
|
|
21
23
|
],
|
|
22
24
|
"exports": {
|
|
23
25
|
".": "./src/types/index.js",
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { GlideQueryCondition } from "./GlideQueryCondition";
|
|
2
|
+
import {
|
|
3
|
+
SafeTableField,
|
|
4
|
+
SafeTableFieldKey,
|
|
5
|
+
} from "./_GlideRecordHelpers/SafeTableTypes";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* The scoped GlideAggregate class is an extension of GlideRecord and allows database aggregation (COUNT, SUM, MIN, MAX,
|
|
@@ -7,33 +11,36 @@ import { GlideQueryCondition } from "./GlideQueryCondition";
|
|
|
7
11
|
* GlideAggregate class on currency fields
|
|
8
12
|
*/
|
|
9
13
|
|
|
10
|
-
export type GlideAggregate<T extends keyof Tables =
|
|
14
|
+
export type GlideAggregate<T extends keyof Tables | string = string> = IGlideAggregate<T>;
|
|
11
15
|
export declare const GlideAggregate: IGlideAggregate;
|
|
12
16
|
|
|
13
|
-
interface IGlideAggregate<T extends keyof Tables =
|
|
17
|
+
interface IGlideAggregate<T extends keyof Tables | string = string> {
|
|
14
18
|
// Construction and table setup
|
|
15
|
-
new <T extends keyof Tables>(tableName: T): GlideAggregate<T>;
|
|
19
|
+
new <T extends keyof Tables | string>(tableName: T): GlideAggregate<T>;
|
|
16
20
|
|
|
17
21
|
// ScopedGlideAggregate
|
|
18
22
|
_next(): boolean;
|
|
19
|
-
_query<F extends
|
|
20
|
-
|
|
23
|
+
_query<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
24
|
+
field: F,
|
|
25
|
+
value: V
|
|
26
|
+
): void;
|
|
27
|
+
addNotNullQuery<F extends SafeTableFieldKey<T & string>>(
|
|
21
28
|
fieldName: F
|
|
22
29
|
): GlideQueryCondition<T>;
|
|
23
|
-
addNullQuery<F extends
|
|
24
|
-
addQuery<F extends
|
|
30
|
+
addNullQuery<F extends SafeTableFieldKey<T & string>>(fieldName: F): GlideQueryCondition<T>;
|
|
31
|
+
addQuery<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
25
32
|
name: F,
|
|
26
33
|
operator: any,
|
|
27
34
|
value: V
|
|
28
35
|
): GlideQueryCondition<T>;
|
|
29
36
|
addSystemEncodedQuery(query: string): void;
|
|
30
|
-
addSystemQuery<F extends
|
|
37
|
+
addSystemQuery<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
31
38
|
name: F,
|
|
32
39
|
operator: any,
|
|
33
40
|
value: V
|
|
34
41
|
): GlideQueryCondition<T>;
|
|
35
42
|
addUserEncodedQuery(query: string): void;
|
|
36
|
-
addUserQuery<F extends
|
|
43
|
+
addUserQuery<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
37
44
|
name: F,
|
|
38
45
|
operator: any,
|
|
39
46
|
value: V
|
|
@@ -45,7 +52,10 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
45
52
|
*/
|
|
46
53
|
next(): boolean;
|
|
47
54
|
hasNext(): boolean;
|
|
48
|
-
query<F extends
|
|
55
|
+
query<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
56
|
+
field: F,
|
|
57
|
+
value: V
|
|
58
|
+
): void;
|
|
49
59
|
|
|
50
60
|
// GlideAggregate
|
|
51
61
|
|
|
@@ -53,11 +63,11 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
53
63
|
* Adds an aggregate
|
|
54
64
|
*/
|
|
55
65
|
addAggregate(agg: string, name: string): void;
|
|
56
|
-
addBizCalendarTrend<F extends
|
|
66
|
+
addBizCalendarTrend<F extends SafeTableFieldKey<T & string>>(
|
|
57
67
|
fieldName: F,
|
|
58
68
|
bizCalendarSysId: string
|
|
59
69
|
): void;
|
|
60
|
-
addBizCalendarTrendBase<F extends
|
|
70
|
+
addBizCalendarTrendBase<F extends SafeTableFieldKey<T & string>>(
|
|
61
71
|
fieldName: F,
|
|
62
72
|
bizCalendarSysId: string
|
|
63
73
|
): void;
|
|
@@ -72,23 +82,23 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
72
82
|
addEncodedQuery(query: string, enforceFieldACLs: any): void;
|
|
73
83
|
getEncodedQuery(): string;
|
|
74
84
|
addHaving(arg1: string, arg2: string, arg3: string, arg4: string): void;
|
|
75
|
-
addSystemOrderBy<F extends
|
|
85
|
+
addSystemOrderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
76
86
|
|
|
77
87
|
/**
|
|
78
88
|
* Sorts the aggregates into descending order based on the specified field
|
|
79
89
|
*/
|
|
80
|
-
addSystemOrderByDesc<F extends
|
|
81
|
-
addTrend<F extends
|
|
90
|
+
addSystemOrderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
91
|
+
addTrend<F extends SafeTableFieldKey<T & string>>(
|
|
82
92
|
fieldName: F,
|
|
83
93
|
timeInterval: string,
|
|
84
94
|
numUnits: number
|
|
85
95
|
): void;
|
|
86
|
-
addUserOrderBy<F extends
|
|
96
|
+
addUserOrderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
87
97
|
|
|
88
98
|
/**
|
|
89
99
|
* Sorts the aggregates into descending order based on the specified field
|
|
90
100
|
*/
|
|
91
|
-
addUserOrderByDesc<F extends
|
|
101
|
+
addUserOrderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
92
102
|
/**
|
|
93
103
|
* Gets the value of the specified aggregate
|
|
94
104
|
*/
|
|
@@ -105,19 +115,19 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
105
115
|
/**
|
|
106
116
|
* Gets the value of a field
|
|
107
117
|
*/
|
|
108
|
-
getValue<F extends
|
|
118
|
+
getValue<F extends SafeTableFieldKey<T & string>>(name: F): string;
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
121
|
* Provides the name of a field to use in grouping the aggregates. May be called numerous times to set multiple
|
|
112
122
|
* group fields
|
|
113
123
|
*/
|
|
114
|
-
groupBy<F extends
|
|
124
|
+
groupBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
115
125
|
isBizCalendarTrendFillGap(): boolean;
|
|
116
126
|
|
|
117
127
|
/**
|
|
118
128
|
* Orders the aggregates using the value of the specified field. The field will also be added to the group-by list
|
|
119
129
|
*/
|
|
120
|
-
orderBy<F extends
|
|
130
|
+
orderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
121
131
|
|
|
122
132
|
/**
|
|
123
133
|
* Sorts the aggregates based on the specified aggregate and field
|
|
@@ -127,7 +137,7 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
127
137
|
/**
|
|
128
138
|
* Sorts the aggregates into descending order based on the specified field
|
|
129
139
|
*/
|
|
130
|
-
orderByDesc<F extends
|
|
140
|
+
orderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
|
|
131
141
|
setAggregateWindow(firstRowWanted: number, lastRowWanted: number): void;
|
|
132
142
|
setBizCalendarTrendFillGap(b: boolean): void;
|
|
133
143
|
|
|
@@ -156,7 +166,10 @@ interface IGlideAggregate<T extends keyof Tables = never> {
|
|
|
156
166
|
enableSessionLanguageJoin(): void;
|
|
157
167
|
|
|
158
168
|
// GlideRecord
|
|
159
|
-
_get<F extends
|
|
169
|
+
_get<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
170
|
+
name: F,
|
|
171
|
+
value: V
|
|
172
|
+
): boolean;
|
|
160
173
|
getTableName(): string;
|
|
161
174
|
getRowCount(): number;
|
|
162
175
|
}
|
|
@@ -170,7 +170,7 @@ interface UpdateMultipleResult {
|
|
|
170
170
|
* @example
|
|
171
171
|
* var query = new GlideQuery('sys_user');
|
|
172
172
|
*/
|
|
173
|
-
export declare class GlideQuery<T extends keyof Tables =
|
|
173
|
+
export declare class GlideQuery<T extends keyof Tables | string = string> {
|
|
174
174
|
/**
|
|
175
175
|
* Creates a new GlideQuery instance
|
|
176
176
|
*
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SafeTableField,
|
|
3
|
+
SafeTableFieldKey,
|
|
4
|
+
} from "./_GlideRecordHelpers/SafeTableTypes";
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* The scoped QueryCondition API provides additional AND or OR conditions that can be added to the current condition,
|
|
3
8
|
* allowing you to build complex queries such as: category='hardware' OR category='software' AND priority='2' AND
|
|
4
9
|
* priority='1'
|
|
5
10
|
*/
|
|
6
|
-
export declare class GlideQueryCondition<T extends keyof Tables =
|
|
11
|
+
export declare class GlideQueryCondition<T extends keyof Tables | string = string> {
|
|
7
12
|
constructor();
|
|
8
13
|
|
|
9
14
|
/**
|
|
@@ -14,7 +19,7 @@ export declare class GlideQueryCondition<T extends keyof Tables = never> {
|
|
|
14
19
|
/**
|
|
15
20
|
* Adds an OR condition to the current condition.
|
|
16
21
|
*/
|
|
17
|
-
addOrCondition<F extends
|
|
22
|
+
addOrCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
18
23
|
name: F,
|
|
19
24
|
value: V
|
|
20
25
|
): GlideQueryCondition<T>;
|
|
@@ -22,17 +27,17 @@ export declare class GlideQueryCondition<T extends keyof Tables = never> {
|
|
|
22
27
|
/**
|
|
23
28
|
* Adds an OR condition to the current condition.
|
|
24
29
|
*/
|
|
25
|
-
addOrCondition<F extends
|
|
30
|
+
addOrCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
26
31
|
name: F,
|
|
27
32
|
operator: any,
|
|
28
33
|
value: V
|
|
29
34
|
): GlideQueryCondition<T>;
|
|
30
|
-
addSystemOrCondition<F extends
|
|
35
|
+
addSystemOrCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
31
36
|
name: F,
|
|
32
37
|
operator: any,
|
|
33
38
|
value: V
|
|
34
39
|
): GlideQueryCondition<T>;
|
|
35
|
-
addUserOrCondition<F extends
|
|
40
|
+
addUserOrCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
36
41
|
name: F,
|
|
37
42
|
operator: any,
|
|
38
43
|
value: V
|
|
@@ -46,7 +51,7 @@ export declare class GlideQueryCondition<T extends keyof Tables = never> {
|
|
|
46
51
|
/**
|
|
47
52
|
* Adds an AND condition to the current condition.
|
|
48
53
|
*/
|
|
49
|
-
addCondition<F extends
|
|
54
|
+
addCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
50
55
|
name: F,
|
|
51
56
|
value: V
|
|
52
57
|
): GlideQueryCondition<T>;
|
|
@@ -54,24 +59,24 @@ export declare class GlideQueryCondition<T extends keyof Tables = never> {
|
|
|
54
59
|
/**
|
|
55
60
|
* Adds an AND condition to the current condition.
|
|
56
61
|
*/
|
|
57
|
-
addCondition<F extends
|
|
62
|
+
addCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
58
63
|
name: F,
|
|
59
64
|
oper: string,
|
|
60
65
|
value: V
|
|
61
66
|
): GlideQueryCondition<T>;
|
|
62
67
|
|
|
63
|
-
addCondition<F extends
|
|
68
|
+
addCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
64
69
|
name: F,
|
|
65
70
|
operator: any,
|
|
66
71
|
value: V
|
|
67
72
|
): GlideQueryCondition<T>;
|
|
68
|
-
addSystemCondition<F extends
|
|
73
|
+
addSystemCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
69
74
|
name: F,
|
|
70
75
|
operator: any,
|
|
71
76
|
value: V
|
|
72
77
|
): GlideQueryCondition<T>;
|
|
73
78
|
|
|
74
|
-
addUserCondition<F extends
|
|
79
|
+
addUserCondition<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
|
|
75
80
|
name: F,
|
|
76
81
|
operator: any,
|
|
77
82
|
value: V
|
|
@@ -198,6 +198,7 @@ type IGlideRecord<T extends keyof Tables | string = string> = {
|
|
|
198
198
|
* Insert a new record using the field values that have been set for the current record
|
|
199
199
|
*/
|
|
200
200
|
insert(): string | null;
|
|
201
|
+
insertWithReferences(): string;
|
|
201
202
|
/*
|
|
202
203
|
* Runs the query against the table based on the specified filters by addQuery and addEncodedQuery
|
|
203
204
|
*/
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { GlideElement } from "./GlideElement";
|
|
2
2
|
import { GlideRecord } from "./GlideRecord";
|
|
3
|
+
import {
|
|
4
|
+
SafeTableFields,
|
|
5
|
+
SafeTableFieldKey,
|
|
6
|
+
} from "./_GlideRecordHelpers/SafeTableTypes";
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* GlideRecordSecure is a class inherited from GlideRecord that performs the same functions as GlideRecord, and also
|
|
6
10
|
* enforces ACLs
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
export type GlideRecordSecure<T extends keyof Tables =
|
|
10
|
-
IGlideRecordSecure<T>;
|
|
13
|
+
export type GlideRecordSecure<T extends keyof Tables | string = string> =
|
|
14
|
+
IGlideRecordSecure<T> & SafeTableFields<T>;
|
|
11
15
|
export declare const GlideRecordSecure: IGlideRecordSecure;
|
|
12
16
|
|
|
13
|
-
type IGlideRecordSecure<T extends keyof Tables =
|
|
14
|
-
[key in
|
|
17
|
+
type IGlideRecordSecure<T extends keyof Tables | string = string> = {
|
|
18
|
+
[key in SafeTableFieldKey<T & string>]: GlideElement<T>;
|
|
15
19
|
} & {
|
|
16
20
|
// Construction and table setup
|
|
17
|
-
new <T extends keyof Tables>(tableName: T): GlideRecordSecure<T>;
|
|
18
|
-
deleteMultiple(): void;
|
|
19
|
-
disableSecurityFeature(feature: string): void;
|
|
20
|
-
enableSecurityFeature(feature: string): void;
|
|
21
|
-
getElements(): GlideElement[];
|
|
22
|
-
getValue<F extends keyof Tables[T]>(name: F): string;
|
|
23
|
-
insertOrUpdate(keyField: string): string;
|
|
24
|
-
insertWithReferences(): string;
|
|
25
|
-
query<F extends keyof Tables[T]>(field: F, value: Tables[T][F]): void;
|
|
26
|
-
updateWithReferences(reason: any): string;
|
|
21
|
+
new <T extends keyof Tables | string>(tableName: T): GlideRecordSecure<T>;
|
|
27
22
|
} & GlideRecord<T>;
|