@slickgrid-universal/graphql 5.0.1 → 5.2.0
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/dist/cjs/services/graphql.service.js +89 -56
- package/dist/cjs/services/graphql.service.js.map +1 -1
- package/dist/cjs/services/graphqlQueryBuilder.js.map +1 -1
- package/dist/esm/services/graphql.service.js +89 -56
- package/dist/esm/services/graphql.service.js.map +1 -1
- package/dist/esm/services/graphqlQueryBuilder.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/interfaces/graphqlFilteringOption.interface.d.ts +8 -0
- package/dist/types/interfaces/graphqlFilteringOption.interface.d.ts.map +1 -1
- package/dist/types/interfaces/graphqlServiceOption.interface.d.ts +4 -2
- package/dist/types/interfaces/graphqlServiceOption.interface.d.ts.map +1 -1
- package/dist/types/services/graphql.service.d.ts +2 -2
- package/dist/types/services/graphql.service.d.ts.map +1 -1
- package/dist/types/services/graphqlQueryBuilder.d.ts +1 -1
- package/dist/types/services/graphqlQueryBuilder.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/interfaces/graphqlFilteringOption.interface.ts +11 -0
- package/src/interfaces/graphqlServiceOption.interface.ts +5 -2
- package/src/services/graphql.service.ts +104 -69
- package/src/services/graphqlQueryBuilder.ts +7 -7
|
@@ -7,4 +7,12 @@ export interface GraphqlFilteringOption {
|
|
|
7
7
|
/** Value to use when filtering */
|
|
8
8
|
value: any | any[];
|
|
9
9
|
}
|
|
10
|
+
export interface GraphqlCustomFilteringOption {
|
|
11
|
+
/** Field name to use when filtering */
|
|
12
|
+
field: string;
|
|
13
|
+
/** Custom Operator to use when filtering. Please note that any new Custom Operator must be implemented in your GraphQL Schema. */
|
|
14
|
+
operator: any;
|
|
15
|
+
/** Value to use when filtering */
|
|
16
|
+
value: any | any[];
|
|
17
|
+
}
|
|
10
18
|
//# sourceMappingURL=graphqlFilteringOption.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlFilteringOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlFilteringOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,QAAQ,EAAE,YAAY,GAAG,cAAc,CAAC;IAExC,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"graphqlFilteringOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlFilteringOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,QAAQ,EAAE,YAAY,GAAG,cAAc,CAAC;IAExC,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd,kIAAkI;IAClI,QAAQ,EAAE,GAAG,CAAC;IAEd,kCAAkC;IAClC,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;CACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BackendServiceOption } from '@slickgrid-universal/common';
|
|
2
|
-
import type { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
1
|
+
import type { BackendServiceOption, BackendServiceFilterQueryOverrideArgs } from '@slickgrid-universal/common';
|
|
2
|
+
import type { GraphqlCustomFilteringOption, GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
3
3
|
import type { GraphqlSortingOption } from './graphqlSortingOption.interface';
|
|
4
4
|
import type { GraphqlCursorPaginationOption } from './graphqlCursorPaginationOption.interface';
|
|
5
5
|
import type { GraphqlPaginationOption } from './graphqlPaginationOption.interface';
|
|
@@ -22,6 +22,8 @@ export interface GraphqlServiceOption extends BackendServiceOption {
|
|
|
22
22
|
extraQueryArguments?: QueryArgument[];
|
|
23
23
|
/** array of Filtering Options, ex.: { field: name, operator: EQ, value: "John" } */
|
|
24
24
|
filteringOptions?: GraphqlFilteringOption[];
|
|
25
|
+
/** An optional predicate function to overide the built-in filter construction */
|
|
26
|
+
filterQueryOverride?: (args: BackendServiceFilterQueryOverrideArgs) => GraphqlCustomFilteringOption | undefined;
|
|
25
27
|
/** What are the pagination options? ex.: (first, last, offset) */
|
|
26
28
|
paginationOptions?: GraphqlPaginationOption | GraphqlCursorPaginationOption;
|
|
27
29
|
/** array of Filtering Options, ex.: { field: name, direction: DESC } */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlServiceOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlServiceOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"graphqlServiceOption.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/graphqlServiceOption.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AAE/G,OAAO,KAAK,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IAEpB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;IAEtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAE5C,kFAAkF;IAClF,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,qCAAqC,KAAK,4BAA4B,GAAG,SAAS,CAAC;IAEhH,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,uBAAuB,GAAG,6BAA6B,CAAC;IAE5E,yEAAyE;IACzE,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAExC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAC;IAExC,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC"}
|
|
@@ -5,14 +5,14 @@ export declare class GraphqlService implements BackendService {
|
|
|
5
5
|
protected _currentFilters: ColumnFilters | CurrentFilter[];
|
|
6
6
|
protected _currentPagination: CurrentPagination | null;
|
|
7
7
|
protected _currentSorters: CurrentSorter[];
|
|
8
|
-
protected _columnDefinitions?: Column[];
|
|
8
|
+
protected _columnDefinitions?: Column[] | undefined;
|
|
9
9
|
protected _grid: SlickGrid | undefined;
|
|
10
10
|
protected _datasetIdPropName: string;
|
|
11
11
|
options: GraphqlServiceOption | undefined;
|
|
12
12
|
pagination: Pagination | undefined;
|
|
13
13
|
defaultPaginationOptions: GraphqlPaginationOption;
|
|
14
14
|
/** Getter for the Column Definitions */
|
|
15
|
-
get columnDefinitions(): Column
|
|
15
|
+
get columnDefinitions(): Column[] | undefined;
|
|
16
16
|
/** Getter for the Grid Options pulled through the Grid Object */
|
|
17
17
|
protected get _gridOptions(): GridOption;
|
|
18
18
|
/** Initialization of the service, which acts as a constructor */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.service.d.ts","sourceRoot":"","sources":["../../../src/services/graphql.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EAEN,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAChB,SAAS,EAEV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,SAAS,EAMV,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"graphql.service.d.ts","sourceRoot":"","sources":["../../../src/services/graphql.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -13,7 +13,7 @@ export default class GraphqlQueryBuilder {
|
|
|
13
13
|
alias: string | Function;
|
|
14
14
|
head: any[];
|
|
15
15
|
body: any;
|
|
16
|
-
constructor(queryFnName: string, aliasOrFilter?: string | object);
|
|
16
|
+
constructor(queryFnName: string, aliasOrFilter?: string | object | undefined);
|
|
17
17
|
/**
|
|
18
18
|
* The parameters to run the query against.
|
|
19
19
|
* @param filters An object mapping attribute to values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlQueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/graphqlQueryBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAM1B,SAAS,CAAC,WAAW,EAAE,MAAM;IALzC,KAAK,EAAG,MAAM,GAAG,QAAQ,CAAC;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAM;IACjB,IAAI,EAAE,GAAG,CAAC;gBAGY,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"graphqlQueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/graphqlQueryBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAM1B,SAAS,CAAC,WAAW,EAAE,MAAM;IALzC,KAAK,EAAG,MAAM,GAAG,QAAQ,CAAC;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAM;IACjB,IAAI,EAAE,GAAG,CAAC;gBAGY,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAYtF;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAc1B;;;OAGG;IACH,IAAI,CAAC,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI;IAW9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAYlB,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM;IA4B3C,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;IAgB1C,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG;CAWlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slickgrid-universal/graphql",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "GraphQL Service to sync a grid with a GraphQL backend server",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"not dead"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@slickgrid-universal/common": "~5.0
|
|
42
|
-
"@slickgrid-universal/utils": "~5.
|
|
41
|
+
"@slickgrid-universal/common": "~5.2.0",
|
|
42
|
+
"@slickgrid-universal/utils": "~5.2.0"
|
|
43
43
|
},
|
|
44
44
|
"funding": {
|
|
45
45
|
"type": "ko_fi",
|
|
46
46
|
"url": "https://ko-fi.com/ghiscoding"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d7de27ab3ac3c7e2d48302603ac76aaf794e66a2"
|
|
49
49
|
}
|
|
@@ -10,3 +10,14 @@ export interface GraphqlFilteringOption {
|
|
|
10
10
|
/** Value to use when filtering */
|
|
11
11
|
value: any | any[];
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
export interface GraphqlCustomFilteringOption {
|
|
15
|
+
/** Field name to use when filtering */
|
|
16
|
+
field: string;
|
|
17
|
+
|
|
18
|
+
/** Custom Operator to use when filtering. Please note that any new Custom Operator must be implemented in your GraphQL Schema. */
|
|
19
|
+
operator: any;
|
|
20
|
+
|
|
21
|
+
/** Value to use when filtering */
|
|
22
|
+
value: any | any[];
|
|
23
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BackendServiceOption } from '@slickgrid-universal/common';
|
|
1
|
+
import type { BackendServiceOption, BackendServiceFilterQueryOverrideArgs } from '@slickgrid-universal/common';
|
|
2
2
|
|
|
3
|
-
import type { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
3
|
+
import type { GraphqlCustomFilteringOption, GraphqlFilteringOption } from './graphqlFilteringOption.interface';
|
|
4
4
|
import type { GraphqlSortingOption } from './graphqlSortingOption.interface';
|
|
5
5
|
import type { GraphqlCursorPaginationOption } from './graphqlCursorPaginationOption.interface';
|
|
6
6
|
import type { GraphqlPaginationOption } from './graphqlPaginationOption.interface';
|
|
@@ -29,6 +29,9 @@ export interface GraphqlServiceOption extends BackendServiceOption {
|
|
|
29
29
|
/** array of Filtering Options, ex.: { field: name, operator: EQ, value: "John" } */
|
|
30
30
|
filteringOptions?: GraphqlFilteringOption[];
|
|
31
31
|
|
|
32
|
+
/** An optional predicate function to overide the built-in filter construction */
|
|
33
|
+
filterQueryOverride?: (args: BackendServiceFilterQueryOverrideArgs) => GraphqlCustomFilteringOption | undefined;
|
|
34
|
+
|
|
32
35
|
/** What are the pagination options? ex.: (first, last, offset) */
|
|
33
36
|
paginationOptions?: GraphqlPaginationOption | GraphqlCursorPaginationOption;
|
|
34
37
|
|
|
@@ -31,6 +31,7 @@ import { getHtmlStringOutput, stripTags } from '@slickgrid-universal/utils';
|
|
|
31
31
|
|
|
32
32
|
import type {
|
|
33
33
|
GraphqlCursorPaginationOption,
|
|
34
|
+
GraphqlCustomFilteringOption,
|
|
34
35
|
GraphqlDatasetFilter,
|
|
35
36
|
GraphqlFilteringOption,
|
|
36
37
|
GraphqlPaginationOption,
|
|
@@ -47,7 +48,7 @@ export class GraphqlService implements BackendService {
|
|
|
47
48
|
protected _currentFilters: ColumnFilters | CurrentFilter[] = [];
|
|
48
49
|
protected _currentPagination: CurrentPagination | null = null;
|
|
49
50
|
protected _currentSorters: CurrentSorter[] = [];
|
|
50
|
-
protected _columnDefinitions?: Column[];
|
|
51
|
+
protected _columnDefinitions?: Column[] | undefined;
|
|
51
52
|
protected _grid: SlickGrid | undefined;
|
|
52
53
|
protected _datasetIdPropName = 'id';
|
|
53
54
|
options: GraphqlServiceOption | undefined;
|
|
@@ -58,7 +59,7 @@ export class GraphqlService implements BackendService {
|
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
/** Getter for the Column Definitions */
|
|
61
|
-
get columnDefinitions() {
|
|
62
|
+
get columnDefinitions(): Column[] | undefined {
|
|
62
63
|
return this._columnDefinitions;
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -83,7 +84,7 @@ export class GraphqlService implements BackendService {
|
|
|
83
84
|
* Build the GraphQL query, since the service include/exclude cursor, the output query will be different.
|
|
84
85
|
* @param serviceOptions GraphqlServiceOption
|
|
85
86
|
*/
|
|
86
|
-
buildQuery() {
|
|
87
|
+
buildQuery(): string {
|
|
87
88
|
if (!this.options || !this.options.datasetName || !Array.isArray(this._columnDefinitions)) {
|
|
88
89
|
throw new Error('GraphQL Service requires the "datasetName" property to properly build the GraphQL query');
|
|
89
90
|
}
|
|
@@ -197,7 +198,7 @@ export class GraphqlService implements BackendService {
|
|
|
197
198
|
* firstName, lastName, billing{address{street, zip}}
|
|
198
199
|
* @param inputArray
|
|
199
200
|
*/
|
|
200
|
-
buildFilterQuery(inputArray: string[]) {
|
|
201
|
+
buildFilterQuery(inputArray: string[]): string {
|
|
201
202
|
|
|
202
203
|
const set = (o: any = {}, a: any) => {
|
|
203
204
|
const k = a.shift();
|
|
@@ -213,12 +214,12 @@ export class GraphqlService implements BackendService {
|
|
|
213
214
|
.replace(/\}$/, '');
|
|
214
215
|
}
|
|
215
216
|
|
|
216
|
-
clearFilters() {
|
|
217
|
+
clearFilters(): void {
|
|
217
218
|
this._currentFilters = [];
|
|
218
219
|
this.updateOptions({ filteringOptions: [] });
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
clearSorters() {
|
|
222
|
+
clearSorters(): void {
|
|
222
223
|
this._currentSorters = [];
|
|
223
224
|
this.updateOptions({ sortingOptions: [] });
|
|
224
225
|
}
|
|
@@ -257,7 +258,7 @@ export class GraphqlService implements BackendService {
|
|
|
257
258
|
/*
|
|
258
259
|
* Reset the pagination options
|
|
259
260
|
*/
|
|
260
|
-
resetPaginationOptions() {
|
|
261
|
+
resetPaginationOptions(): void {
|
|
261
262
|
let paginationOptions: GraphqlPaginationOption | GraphqlCursorPaginationOption;
|
|
262
263
|
|
|
263
264
|
if (this.options?.useCursor) {
|
|
@@ -280,7 +281,7 @@ export class GraphqlService implements BackendService {
|
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
283
|
|
|
283
|
-
updateOptions(serviceOptions?: Partial<GraphqlServiceOption>) {
|
|
284
|
+
updateOptions(serviceOptions?: Partial<GraphqlServiceOption>): void {
|
|
284
285
|
this.options = { ...this.options, ...serviceOptions } as GraphqlServiceOption;
|
|
285
286
|
}
|
|
286
287
|
|
|
@@ -377,8 +378,8 @@ export class GraphqlService implements BackendService {
|
|
|
377
378
|
* Update column filters by looping through all columns to inspect filters & update backend service filteringOptions
|
|
378
379
|
* @param columnFilters
|
|
379
380
|
*/
|
|
380
|
-
updateFilters(columnFilters: ColumnFilters | CurrentFilter[], isUpdatedByPresetOrDynamically: boolean) {
|
|
381
|
-
const searchByArray: GraphqlFilteringOption
|
|
381
|
+
updateFilters(columnFilters: ColumnFilters | CurrentFilter[], isUpdatedByPresetOrDynamically: boolean): void {
|
|
382
|
+
const searchByArray: Array<GraphqlCustomFilteringOption | GraphqlFilteringOption> = [];
|
|
382
383
|
let searchValue: string | string[];
|
|
383
384
|
|
|
384
385
|
// on filter preset load, we need to keep current filters
|
|
@@ -425,81 +426,115 @@ export class GraphqlService implements BackendService {
|
|
|
425
426
|
|
|
426
427
|
// run regex to find possible filter operators unless the user disabled the feature
|
|
427
428
|
const autoParseInputFilterOperator = columnDef.autoParseInputFilterOperator ?? this._gridOptions.autoParseInputFilterOperator;
|
|
429
|
+
|
|
430
|
+
// group (2): comboStartsWith, (3): comboEndsWith, (4): Operator, (1 or 5): searchValue, (6): last char is '*' (meaning starts with, ex.: abc*)
|
|
428
431
|
const matches = autoParseInputFilterOperator !== false
|
|
429
|
-
? fieldSearchValue.match(/^([<>!=*]{0,2})(.*[^<>!=*])([*]?)$/)
|
|
430
|
-
: [fieldSearchValue, '',
|
|
432
|
+
? fieldSearchValue.match(/^((.*[^\\*\r\n])[*]{1}(.*[^*\r\n]))|^([<>!=*]{0,2})(.*[^<>!=*])([*]?)$/) || []
|
|
433
|
+
: [fieldSearchValue, '', '', '', '', fieldSearchValue, ''];
|
|
431
434
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
const comboStartsWith = matches?.[2] || '';
|
|
436
|
+
const comboEndsWith = matches?.[3] || '';
|
|
437
|
+
let operator = columnFilter.operator || matches?.[4];
|
|
438
|
+
searchValue = matches?.[1] || matches?.[5] || '';
|
|
439
|
+
const lastValueChar = matches?.[6] || (operator === '*z' || operator === OperatorType.endsWith) ? '*' : '';
|
|
435
440
|
|
|
436
441
|
// no need to query if search value is empty
|
|
437
442
|
if (fieldName && searchValue === '' && searchTerms.length === 0) {
|
|
438
443
|
continue;
|
|
439
444
|
}
|
|
440
445
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
446
|
+
let filterQueryOverride: GraphqlCustomFilteringOption | undefined = undefined;
|
|
447
|
+
if (typeof this.options?.filterQueryOverride === 'function') {
|
|
448
|
+
filterQueryOverride = this.options?.filterQueryOverride({
|
|
449
|
+
fieldName: getHtmlStringOutput(fieldName),
|
|
450
|
+
columnDef,
|
|
451
|
+
operator,
|
|
452
|
+
columnFilterOperator: columnFilter.operator,
|
|
453
|
+
searchValue,
|
|
454
|
+
grid: this._grid
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (filterQueryOverride !== undefined) {
|
|
459
|
+
// since this is a Custom Filter, we expect Operator to be a string
|
|
460
|
+
// and it is assumed that the developer will implement this custom operator in their GraphQL Schema
|
|
461
|
+
// e.g.: https://stackoverflow.com/a/37981802/1212166
|
|
462
|
+
searchByArray.push(filterQueryOverride);
|
|
463
|
+
} else {
|
|
464
|
+
if (comboStartsWith && comboEndsWith) {
|
|
465
|
+
searchTerms = [comboStartsWith, comboEndsWith];
|
|
466
|
+
operator = OperatorType.startsWithEndsWith;
|
|
467
|
+
} else if (Array.isArray(searchTerms) && searchTerms.length === 1 && typeof searchTerms[0] === 'string' && searchTerms[0].indexOf('..') >= 0) {
|
|
468
|
+
if (operator !== OperatorType.rangeInclusive && operator !== OperatorType.rangeExclusive) {
|
|
469
|
+
operator = this._gridOptions.defaultFilterRangeOperator ?? OperatorType.rangeInclusive;
|
|
470
|
+
}
|
|
471
|
+
searchTerms = searchTerms[0].split('..', 2);
|
|
472
|
+
if (searchTerms[0] === '') {
|
|
473
|
+
operator = operator === OperatorType.rangeInclusive ? '<=' : operator === OperatorType.rangeExclusive ? '<' : operator;
|
|
474
|
+
searchTerms = searchTerms.slice(1);
|
|
475
|
+
searchValue = searchTerms[0];
|
|
476
|
+
} else if (searchTerms[1] === '') {
|
|
477
|
+
operator = operator === OperatorType.rangeInclusive ? '>=' : operator === OperatorType.rangeExclusive ? '>' : operator;
|
|
478
|
+
searchTerms = searchTerms.slice(0, 1);
|
|
479
|
+
searchValue = searchTerms[0];
|
|
480
|
+
}
|
|
444
481
|
}
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
operator
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
} else if (searchTerms[1] === '') {
|
|
451
|
-
operator = operator === OperatorType.rangeInclusive ? '>=' : operator === OperatorType.rangeExclusive ? '>' : operator;
|
|
452
|
-
searchTerms = searchTerms.slice(0, 1);
|
|
453
|
-
searchValue = searchTerms[0];
|
|
482
|
+
|
|
483
|
+
if (typeof searchValue === 'string') {
|
|
484
|
+
if (operator === '*' || operator === 'a*' || operator === '*z' || lastValueChar === '*') {
|
|
485
|
+
operator = ((operator === '*' || operator === '*z') ? 'EndsWith' : 'StartsWith') as OperatorString;
|
|
486
|
+
}
|
|
454
487
|
}
|
|
455
|
-
}
|
|
456
488
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
489
|
+
// if we didn't find an Operator but we have a Column Operator inside the Filter (DOM Element), we should use its default Operator
|
|
490
|
+
// multipleSelect is "IN", while singleSelect is "EQ", else don't map any operator
|
|
491
|
+
if (!operator && columnDef.filter && columnDef.filter.operator) {
|
|
492
|
+
operator = columnDef.filter.operator;
|
|
460
493
|
}
|
|
461
|
-
}
|
|
462
494
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
495
|
+
// No operator and 2 search terms should lead to default range operator.
|
|
496
|
+
if (!operator && Array.isArray(searchTerms) && searchTerms.length === 2 && searchTerms[0] && searchTerms[1]) {
|
|
497
|
+
operator = this._gridOptions.defaultFilterRangeOperator as OperatorString;
|
|
498
|
+
}
|
|
468
499
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
500
|
+
// Range with 1 searchterm should lead to equals for a date field.
|
|
501
|
+
if ((operator === OperatorType.rangeInclusive || operator === OperatorType.rangeExclusive) && Array.isArray(searchTerms) && searchTerms.length === 1 && fieldType === FieldType.date) {
|
|
502
|
+
operator = OperatorType.equal;
|
|
503
|
+
}
|
|
473
504
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
505
|
+
// Normalize all search values
|
|
506
|
+
searchValue = this.normalizeSearchValue(fieldType, searchValue);
|
|
507
|
+
if (Array.isArray(searchTerms)) {
|
|
508
|
+
searchTerms.forEach((_part, index) => {
|
|
509
|
+
searchTerms[index] = this.normalizeSearchValue(fieldType, searchTerms[index]);
|
|
510
|
+
});
|
|
511
|
+
}
|
|
478
512
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
513
|
+
// StartsWith + EndsWith combo
|
|
514
|
+
if (operator === OperatorType.startsWithEndsWith && Array.isArray(searchTerms) && searchTerms.length === 2) {
|
|
515
|
+
// add 2 conditions (StartsWith A + EndsWith B) to the search array
|
|
516
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: OperatorType.startsWith, value: comboStartsWith });
|
|
517
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: OperatorType.endsWith, value: comboEndsWith });
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
486
520
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
521
|
+
// when having more than 1 search term (we need to create a CSV string for GraphQL "IN" or "NOT IN" filter search)
|
|
522
|
+
if (searchTerms?.length > 1 && (operator === 'IN' || operator === 'NIN' || operator === 'NOT_IN')) {
|
|
523
|
+
searchValue = searchTerms.join(',');
|
|
524
|
+
} else if (searchTerms?.length === 2 && (operator === OperatorType.rangeExclusive || operator === OperatorType.rangeInclusive)) {
|
|
525
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: (operator === OperatorType.rangeInclusive ? 'GE' : 'GT'), value: searchTerms[0] });
|
|
526
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: (operator === OperatorType.rangeInclusive ? 'LE' : 'LT'), value: searchTerms[1] });
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
495
529
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
530
|
+
// if we still don't have an operator find the proper Operator to use according field type
|
|
531
|
+
if (!operator) {
|
|
532
|
+
operator = mapOperatorByFieldType(fieldType);
|
|
533
|
+
}
|
|
500
534
|
|
|
501
|
-
|
|
502
|
-
|
|
535
|
+
// build the search array
|
|
536
|
+
searchByArray.push({ field: getHtmlStringOutput(fieldName), operator: mapOperatorType(operator), value: searchValue });
|
|
537
|
+
}
|
|
503
538
|
}
|
|
504
539
|
}
|
|
505
540
|
|
|
@@ -513,7 +548,7 @@ export class GraphqlService implements BackendService {
|
|
|
513
548
|
* @param {Number} pageSize
|
|
514
549
|
* @param {*} [cursorArgs] these should be supplied when using cursor based pagination
|
|
515
550
|
*/
|
|
516
|
-
updatePagination(newPage: number, pageSize: number, cursorArgs?: PaginationCursorChangedArgs) {
|
|
551
|
+
updatePagination(newPage: number, pageSize: number, cursorArgs?: PaginationCursorChangedArgs): void {
|
|
517
552
|
this._currentPagination = {
|
|
518
553
|
pageNumber: newPage,
|
|
519
554
|
pageSize
|
|
@@ -546,7 +581,7 @@ export class GraphqlService implements BackendService {
|
|
|
546
581
|
/**
|
|
547
582
|
* Update all Sorting by looping through all columns to inspect sorters & update backend service sortingOptions
|
|
548
583
|
*/
|
|
549
|
-
updateSorters(sortColumns?: ColumnSort[], presetSorters?: CurrentSorter[]) {
|
|
584
|
+
updateSorters(sortColumns?: ColumnSort[], presetSorters?: CurrentSorter[]): void {
|
|
550
585
|
let currentSorters: CurrentSorter[] = [];
|
|
551
586
|
const graphqlSorters: GraphqlSortingOption[] = [];
|
|
552
587
|
|
|
@@ -626,7 +661,7 @@ export class GraphqlService implements BackendService {
|
|
|
626
661
|
* @param keepArgumentFieldDoubleQuotes - do we keep field double quotes? (i.e.: field: "user.name")
|
|
627
662
|
* @returns outputStr output string
|
|
628
663
|
*/
|
|
629
|
-
trimDoubleQuotesOnEnumField(inputStr: string, enumSearchWords: string[], keepArgumentFieldDoubleQuotes: boolean) {
|
|
664
|
+
trimDoubleQuotesOnEnumField(inputStr: string, enumSearchWords: string[], keepArgumentFieldDoubleQuotes: boolean): string {
|
|
630
665
|
// eslint-disable-next-line
|
|
631
666
|
const patternWordInQuotes = `\s?((field:\s*)?".*?")`;
|
|
632
667
|
let patternRegex = enumSearchWords.join(patternWordInQuotes + '|');
|
|
@@ -14,7 +14,7 @@ export default class GraphqlQueryBuilder {
|
|
|
14
14
|
body: any;
|
|
15
15
|
|
|
16
16
|
/* Constructor, query/mutator you wish to use, and an alias or filter arguments. */
|
|
17
|
-
constructor(protected queryFnName: string, aliasOrFilter?: string | object) {
|
|
17
|
+
constructor(protected queryFnName: string, aliasOrFilter?: string | object | undefined) {
|
|
18
18
|
if (typeof aliasOrFilter === 'string') {
|
|
19
19
|
this.alias = aliasOrFilter;
|
|
20
20
|
} else if (typeof aliasOrFilter === 'object') {
|
|
@@ -30,7 +30,7 @@ export default class GraphqlQueryBuilder {
|
|
|
30
30
|
* The parameters to run the query against.
|
|
31
31
|
* @param filters An object mapping attribute to values
|
|
32
32
|
*/
|
|
33
|
-
filter(filters: any) {
|
|
33
|
+
filter(filters: any): this {
|
|
34
34
|
for (const prop of Object.keys(filters)) {
|
|
35
35
|
if (typeof filters[prop] === 'function') {
|
|
36
36
|
continue;
|
|
@@ -48,7 +48,7 @@ export default class GraphqlQueryBuilder {
|
|
|
48
48
|
* Outlines the properties you wish to be returned from the query.
|
|
49
49
|
* @param properties representing each attribute you want Returned
|
|
50
50
|
*/
|
|
51
|
-
find(...searches: any[]) { // THIS NEED TO BE A "FUNCTION" to scope 'arguments'
|
|
51
|
+
find(...searches: any[]): this { // THIS NEED TO BE A "FUNCTION" to scope 'arguments'
|
|
52
52
|
if (!searches || !Array.isArray(searches) || searches.length === 0) {
|
|
53
53
|
throw new TypeError(`find value can not be >>falsy<<`);
|
|
54
54
|
}
|
|
@@ -63,7 +63,7 @@ export default class GraphqlQueryBuilder {
|
|
|
63
63
|
* set an alias for this result.
|
|
64
64
|
* @param alias
|
|
65
65
|
*/
|
|
66
|
-
setAlias(alias: string) {
|
|
66
|
+
setAlias(alias: string): void {
|
|
67
67
|
this.alias = alias;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -71,7 +71,7 @@ export default class GraphqlQueryBuilder {
|
|
|
71
71
|
* Return to the formatted query string
|
|
72
72
|
* @return
|
|
73
73
|
*/
|
|
74
|
-
toString() {
|
|
74
|
+
toString(): string {
|
|
75
75
|
if (this.body === undefined) {
|
|
76
76
|
throw new ReferenceError(`return properties are not defined. use the 'find' function to defined them`);
|
|
77
77
|
}
|
|
@@ -83,7 +83,7 @@ export default class GraphqlQueryBuilder {
|
|
|
83
83
|
// protected functions
|
|
84
84
|
// --------------------
|
|
85
85
|
|
|
86
|
-
protected parceFind(_levelA: any[]) {
|
|
86
|
+
protected parceFind(_levelA: any[]): string {
|
|
87
87
|
const propsA = _levelA.map((_currentValue, index) => {
|
|
88
88
|
const itemX = _levelA[index];
|
|
89
89
|
|
|
@@ -111,7 +111,7 @@ export default class GraphqlQueryBuilder {
|
|
|
111
111
|
return propsA.join(',');
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
protected getGraphQLValue(value: any) {
|
|
114
|
+
protected getGraphQLValue(value: any): any {
|
|
115
115
|
if (typeof value === 'string') {
|
|
116
116
|
value = JSON.stringify(value);
|
|
117
117
|
} else if (Array.isArray(value)) {
|