@servicenow/glide 27.0.2 → 27.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicenow/glide",
3
- "version": "27.0.2",
3
+ "version": "27.0.4",
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 = never> = IGlideAggregate<T>;
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 = never> {
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 keyof Tables[T]>(field: F, value: Tables[T][F]): void;
20
- addNotNullQuery<F extends keyof Tables[T]>(
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 keyof Tables[T]>(fieldName: F): GlideQueryCondition<T>;
24
- addQuery<F extends keyof Tables[T], V extends keyof Tables[T][F]>(
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 keyof Tables[T], V extends keyof Tables[T][F]>(
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 keyof Tables[T], V extends keyof Tables[T][F]>(
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,11 @@ interface IGlideAggregate<T extends keyof Tables = never> {
45
52
  */
46
53
  next(): boolean;
47
54
  hasNext(): boolean;
48
- query<F extends keyof Tables[T]>(field: F, value: Tables[T][F]): void;
55
+ query<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
56
+ field: F,
57
+ value: V
58
+ ): void;
59
+ query(): void;
49
60
 
50
61
  // GlideAggregate
51
62
 
@@ -53,11 +64,11 @@ interface IGlideAggregate<T extends keyof Tables = never> {
53
64
  * Adds an aggregate
54
65
  */
55
66
  addAggregate(agg: string, name: string): void;
56
- addBizCalendarTrend<F extends keyof Tables[T]>(
67
+ addBizCalendarTrend<F extends SafeTableFieldKey<T & string>>(
57
68
  fieldName: F,
58
69
  bizCalendarSysId: string
59
70
  ): void;
60
- addBizCalendarTrendBase<F extends keyof Tables[T]>(
71
+ addBizCalendarTrendBase<F extends SafeTableFieldKey<T & string>>(
61
72
  fieldName: F,
62
73
  bizCalendarSysId: string
63
74
  ): void;
@@ -72,23 +83,23 @@ interface IGlideAggregate<T extends keyof Tables = never> {
72
83
  addEncodedQuery(query: string, enforceFieldACLs: any): void;
73
84
  getEncodedQuery(): string;
74
85
  addHaving(arg1: string, arg2: string, arg3: string, arg4: string): void;
75
- addSystemOrderBy<F extends keyof Tables[T]>(name: F): void;
86
+ addSystemOrderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
76
87
 
77
88
  /**
78
89
  * Sorts the aggregates into descending order based on the specified field
79
90
  */
80
- addSystemOrderByDesc<F extends keyof Tables[T]>(name: F): void;
81
- addTrend<F extends keyof Tables[T]>(
91
+ addSystemOrderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
92
+ addTrend<F extends SafeTableFieldKey<T & string>>(
82
93
  fieldName: F,
83
94
  timeInterval: string,
84
95
  numUnits: number
85
96
  ): void;
86
- addUserOrderBy<F extends keyof Tables[T]>(name: F): void;
97
+ addUserOrderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
87
98
 
88
99
  /**
89
100
  * Sorts the aggregates into descending order based on the specified field
90
101
  */
91
- addUserOrderByDesc<F extends keyof Tables[T]>(name: F): void;
102
+ addUserOrderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
92
103
  /**
93
104
  * Gets the value of the specified aggregate
94
105
  */
@@ -105,19 +116,19 @@ interface IGlideAggregate<T extends keyof Tables = never> {
105
116
  /**
106
117
  * Gets the value of a field
107
118
  */
108
- getValue<F extends keyof Tables[T]>(name: F): string;
119
+ getValue<F extends SafeTableFieldKey<T & string>>(name: F): string;
109
120
 
110
121
  /**
111
122
  * Provides the name of a field to use in grouping the aggregates. May be called numerous times to set multiple
112
123
  * group fields
113
124
  */
114
- groupBy<F extends keyof Tables[T]>(name: F): void;
125
+ groupBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
115
126
  isBizCalendarTrendFillGap(): boolean;
116
127
 
117
128
  /**
118
129
  * Orders the aggregates using the value of the specified field. The field will also be added to the group-by list
119
130
  */
120
- orderBy<F extends keyof Tables[T]>(name: F): void;
131
+ orderBy<F extends SafeTableFieldKey<T & string>>(name: F): void;
121
132
 
122
133
  /**
123
134
  * Sorts the aggregates based on the specified aggregate and field
@@ -127,7 +138,7 @@ interface IGlideAggregate<T extends keyof Tables = never> {
127
138
  /**
128
139
  * Sorts the aggregates into descending order based on the specified field
129
140
  */
130
- orderByDesc<F extends keyof Tables[T]>(name: F): void;
141
+ orderByDesc<F extends SafeTableFieldKey<T & string>>(name: F): void;
131
142
  setAggregateWindow(firstRowWanted: number, lastRowWanted: number): void;
132
143
  setBizCalendarTrendFillGap(b: boolean): void;
133
144
 
@@ -156,7 +167,10 @@ interface IGlideAggregate<T extends keyof Tables = never> {
156
167
  enableSessionLanguageJoin(): void;
157
168
 
158
169
  // GlideRecord
159
- _get<F extends keyof Tables[T]>(name: F, value: Tables[T][F]): boolean;
170
+ _get<F extends SafeTableFieldKey<T & string>, V extends SafeTableField<T & string, F & string>>(
171
+ name: F,
172
+ value: V
173
+ ): boolean;
160
174
  getTableName(): string;
161
175
  getRowCount(): number;
162
176
  }
@@ -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 = never> {
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 = never> {
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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 keyof Tables[T], V extends Tables[T][F]>(
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
  */
@@ -205,6 +206,7 @@ type IGlideRecord<T extends keyof Tables | string = string> = {
205
206
  field: F,
206
207
  value: V
207
208
  ): void;
209
+ query(): void;
208
210
  /*
209
211
  * Defines a GlideRecord based on the specified expression of name = value
210
212
  */
@@ -216,8 +218,8 @@ type IGlideRecord<T extends keyof Tables | string = string> = {
216
218
  /*
217
219
  * Updates the current GlideRecord with any changes that have been made
218
220
  */
219
- update(reason: any): string | null;
220
- updateWithReferences(reason: any): string | null;
221
+ update(reason?: any): string | null;
222
+ updateWithReferences(reason?: any): string | null;
221
223
  /*
222
224
  * Updates each GlideRecord in the list with any changes that have been made
223
225
  */
@@ -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 = never> =
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 = never> = {
14
- [key in keyof Tables[T]]: GlideElement;
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>;