@slickgrid-universal/graphql 2.4.1 → 2.6.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.
Files changed (77) hide show
  1. package/dist/commonjs/index.js +22 -22
  2. package/dist/commonjs/interfaces/graphqlCursorPaginationOption.interface.js +2 -2
  3. package/dist/commonjs/interfaces/graphqlDatasetFilter.interface.js +2 -2
  4. package/dist/commonjs/interfaces/graphqlFilteringOption.interface.js +2 -2
  5. package/dist/commonjs/interfaces/graphqlPaginatedResult.interface.js +2 -2
  6. package/dist/commonjs/interfaces/graphqlPaginationOption.interface.js +2 -2
  7. package/dist/commonjs/interfaces/graphqlResult.interface.js +2 -2
  8. package/dist/commonjs/interfaces/graphqlServiceApi.interface.js +2 -2
  9. package/dist/commonjs/interfaces/graphqlServiceOption.interface.js +2 -2
  10. package/dist/commonjs/interfaces/graphqlSortingOption.interface.js +2 -2
  11. package/dist/commonjs/interfaces/index.js +26 -26
  12. package/dist/commonjs/interfaces/queryArgument.interface.js +2 -2
  13. package/dist/commonjs/services/graphql.service.js +584 -584
  14. package/dist/commonjs/services/graphqlQueryBuilder.js +137 -137
  15. package/dist/commonjs/services/index.js +20 -20
  16. package/dist/esm/index.js +3 -3
  17. package/dist/esm/interfaces/graphqlCursorPaginationOption.interface.js +1 -1
  18. package/dist/esm/interfaces/graphqlDatasetFilter.interface.js +1 -1
  19. package/dist/esm/interfaces/graphqlFilteringOption.interface.js +1 -1
  20. package/dist/esm/interfaces/graphqlPaginatedResult.interface.js +1 -1
  21. package/dist/esm/interfaces/graphqlPaginationOption.interface.js +1 -1
  22. package/dist/esm/interfaces/graphqlResult.interface.js +1 -1
  23. package/dist/esm/interfaces/graphqlServiceApi.interface.js +1 -1
  24. package/dist/esm/interfaces/graphqlServiceOption.interface.js +1 -1
  25. package/dist/esm/interfaces/graphqlSortingOption.interface.js +1 -1
  26. package/dist/esm/interfaces/index.js +10 -10
  27. package/dist/esm/interfaces/queryArgument.interface.js +1 -1
  28. package/dist/esm/services/graphql.service.js +582 -582
  29. package/dist/esm/services/graphqlQueryBuilder.js +134 -134
  30. package/dist/esm/services/index.js +2 -2
  31. package/dist/tsconfig.tsbuildinfo +1 -0
  32. package/dist/{commonjs → types}/index.d.ts +4 -3
  33. package/dist/types/index.d.ts.map +1 -0
  34. package/dist/{esm → types}/interfaces/graphqlCursorPaginationOption.interface.d.ts +11 -10
  35. package/dist/types/interfaces/graphqlCursorPaginationOption.interface.d.ts.map +1 -0
  36. package/dist/{commonjs → types}/interfaces/graphqlDatasetFilter.interface.d.ts +13 -12
  37. package/dist/types/interfaces/graphqlDatasetFilter.interface.d.ts.map +1 -0
  38. package/dist/{esm → types}/interfaces/graphqlFilteringOption.interface.d.ts +10 -9
  39. package/dist/types/interfaces/graphqlFilteringOption.interface.d.ts.map +1 -0
  40. package/dist/{commonjs → types}/interfaces/graphqlPaginatedResult.interface.d.ts +30 -29
  41. package/dist/types/interfaces/graphqlPaginatedResult.interface.d.ts.map +1 -0
  42. package/dist/{commonjs → types}/interfaces/graphqlPaginationOption.interface.d.ts +6 -5
  43. package/dist/types/interfaces/graphqlPaginationOption.interface.d.ts.map +1 -0
  44. package/dist/{commonjs → types}/interfaces/graphqlResult.interface.d.ts +9 -8
  45. package/dist/types/interfaces/graphqlResult.interface.d.ts.map +1 -0
  46. package/dist/{esm → types}/interfaces/graphqlServiceApi.interface.d.ts +23 -22
  47. package/dist/types/interfaces/graphqlServiceApi.interface.d.ts.map +1 -0
  48. package/dist/{esm → types}/interfaces/graphqlServiceOption.interface.d.ts +35 -34
  49. package/dist/types/interfaces/graphqlServiceOption.interface.d.ts.map +1 -0
  50. package/dist/{esm → types}/interfaces/graphqlSortingOption.interface.d.ts +6 -5
  51. package/dist/types/interfaces/graphqlSortingOption.interface.d.ts.map +1 -0
  52. package/dist/{esm → types}/interfaces/index.d.ts +11 -10
  53. package/dist/types/interfaces/index.d.ts.map +1 -0
  54. package/dist/{commonjs → types}/interfaces/queryArgument.interface.d.ts +5 -4
  55. package/dist/types/interfaces/queryArgument.interface.d.ts.map +1 -0
  56. package/dist/{commonjs → types}/services/graphql.service.d.ts +100 -99
  57. package/dist/types/services/graphql.service.d.ts.map +1 -0
  58. package/dist/{esm → types}/services/graphqlQueryBuilder.d.ts +39 -38
  59. package/dist/types/services/graphqlQueryBuilder.d.ts.map +1 -0
  60. package/dist/{esm → types}/services/index.d.ts +3 -2
  61. package/dist/types/services/index.d.ts.map +1 -0
  62. package/package.json +8 -8
  63. package/dist/commonjs/interfaces/graphqlCursorPaginationOption.interface.d.ts +0 -10
  64. package/dist/commonjs/interfaces/graphqlFilteringOption.interface.d.ts +0 -9
  65. package/dist/commonjs/interfaces/graphqlServiceApi.interface.d.ts +0 -22
  66. package/dist/commonjs/interfaces/graphqlServiceOption.interface.d.ts +0 -34
  67. package/dist/commonjs/interfaces/graphqlSortingOption.interface.d.ts +0 -5
  68. package/dist/commonjs/interfaces/index.d.ts +0 -10
  69. package/dist/commonjs/services/graphqlQueryBuilder.d.ts +0 -38
  70. package/dist/commonjs/services/index.d.ts +0 -2
  71. package/dist/esm/index.d.ts +0 -3
  72. package/dist/esm/interfaces/graphqlDatasetFilter.interface.d.ts +0 -12
  73. package/dist/esm/interfaces/graphqlPaginatedResult.interface.d.ts +0 -29
  74. package/dist/esm/interfaces/graphqlPaginationOption.interface.d.ts +0 -5
  75. package/dist/esm/interfaces/graphqlResult.interface.d.ts +0 -8
  76. package/dist/esm/interfaces/queryArgument.interface.d.ts +0 -4
  77. package/dist/esm/services/graphql.service.d.ts +0 -99
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@slickgrid-universal/graphql",
3
- "version": "2.4.1",
3
+ "version": "2.6.0",
4
4
  "description": "GraphQL Service to sync a grid with a GraphQL backend server",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "exports": {
8
8
  ".": {
9
- "browser": "./dist/esm/index.js",
10
- "import": "./dist/esm/index.d.ts",
11
- "require": "./dist/commonjs/index.js"
9
+ "import": "./dist/esm/index.js",
10
+ "require": "./dist/commonjs/index.js",
11
+ "default": "./dist/esm/index.js"
12
12
  },
13
13
  "./*": "./*"
14
14
  },
15
15
  "typesVersions": {
16
16
  "*": {
17
17
  "*": [
18
- "./dist/esm/index.d.ts"
18
+ "./dist/types/index.d.ts"
19
19
  ]
20
20
  }
21
21
  },
22
- "types": "dist/esm/index.d.ts",
22
+ "types": "dist/types/index.d.ts",
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
@@ -43,11 +43,11 @@
43
43
  "not dead"
44
44
  ],
45
45
  "dependencies": {
46
- "@slickgrid-universal/common": "~2.4.1"
46
+ "@slickgrid-universal/common": "~2.6.0"
47
47
  },
48
48
  "funding": {
49
49
  "type": "ko_fi",
50
50
  "url": "https://ko-fi.com/ghiscoding"
51
51
  },
52
- "gitHead": "e62c2da0d9d1c8e97462f4125bfdf735d4e4782d"
52
+ "gitHead": "9cddf3ee91a91ca829d0ced99c1f20f6d0e9941f"
53
53
  }
@@ -1,10 +0,0 @@
1
- export interface GraphqlCursorPaginationOption {
2
- /** Start our page After cursor X */
3
- after?: string;
4
- /** Start our page Before cursor X */
5
- before?: string;
6
- /** Get first X number of objects */
7
- first?: number;
8
- /** Get last X number of objects */
9
- last?: number;
10
- }
@@ -1,9 +0,0 @@
1
- import { OperatorString, OperatorType } from '@slickgrid-universal/common';
2
- export interface GraphqlFilteringOption {
3
- /** Field name to use when filtering */
4
- field: string;
5
- /** Operator to use when filtering */
6
- operator: OperatorType | OperatorString;
7
- /** Value to use when filtering */
8
- value: any | any[];
9
- }
@@ -1,22 +0,0 @@
1
- import { BackendServiceApi, Observable } from '@slickgrid-universal/common';
2
- import { GraphqlResult } from './graphqlResult.interface';
3
- import { GraphqlPaginatedResult } from './graphqlPaginatedResult.interface';
4
- import { GraphqlServiceOption } from './graphqlServiceOption.interface';
5
- import { GraphqlService } from '../services/index';
6
- export interface GraphqlServiceApi extends BackendServiceApi {
7
- /** Backend Service Options */
8
- options: GraphqlServiceOption;
9
- /** Backend Service instance (could be OData or GraphQL Service) */
10
- service: GraphqlService;
11
- /** On init (or on page load), what action to perform? */
12
- onInit?: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult> | Observable<GraphqlResult | GraphqlPaginatedResult>;
13
- /** On Processing, we get the query back from the service, and we need to provide a Promise/Observable. For example: this.http.get(myGraphqlUrl) */
14
- process: (query: string) => Promise<GraphqlResult | GraphqlPaginatedResult> | Observable<GraphqlResult | GraphqlPaginatedResult>;
15
- /** After executing the query, what action to perform? For example, stop the spinner */
16
- postProcess?: (response: GraphqlResult | GraphqlPaginatedResult) => void;
17
- /**
18
- * INTERNAL USAGE ONLY by Slickgrid-Universal
19
- * This internal process will be run just before postProcess and is meant to refresh the Dataset & Pagination after a GraphQL call
20
- */
21
- internalPostProcess?: (result: GraphqlResult | GraphqlPaginatedResult) => void;
22
- }
@@ -1,34 +0,0 @@
1
- import { BackendServiceOption } from '@slickgrid-universal/common';
2
- import { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
3
- import { GraphqlSortingOption } from './graphqlSortingOption.interface';
4
- import { GraphqlCursorPaginationOption } from './graphqlCursorPaginationOption.interface';
5
- import { GraphqlPaginationOption } from './graphqlPaginationOption.interface';
6
- import { QueryArgument } from './queryArgument.interface';
7
- export interface GraphqlServiceOption extends BackendServiceOption {
8
- /**
9
- * When using Translation, we probably want to add locale as a query parameter for the filterBy/orderBy to work
10
- * ex.: users(first: 10, offset: 0, locale: "en-CA", filterBy: [{field: name, operator: EQ, value:"John"}]) { }
11
- */
12
- addLocaleIntoQuery?: boolean;
13
- /** What is the dataset, this is required for the GraphQL query to be built */
14
- datasetName: string;
15
- /**
16
- * Extra query arguments that be passed in addition to the default query arguments
17
- * For example in GraphQL, if we want to pass "userId" and we want the query to look like
18
- * users (first: 20, offset: 10, userId: 123) { ... }
19
- */
20
- extraQueryArguments?: QueryArgument[];
21
- /** (NOT FULLY IMPLEMENTED) Is the GraphQL Server using cursors? */
22
- isWithCursor?: boolean;
23
- /** What are the pagination options? ex.: (first, last, offset) */
24
- paginationOptions?: GraphqlPaginationOption | GraphqlCursorPaginationOption;
25
- /** array of Filtering Options, ex.: { field: name, operator: EQ, value: "John" } */
26
- filteringOptions?: GraphqlFilteringOption[];
27
- /** array of Filtering Options, ex.: { field: name, direction: DESC } */
28
- sortingOptions?: GraphqlSortingOption[];
29
- /**
30
- * Do we want to keep double quotes on field arguments of filterBy/sortBy (field: "name" instead of field: name)
31
- * ex.: { field: "name", operator: EQ, value: "John" }
32
- */
33
- keepArgumentFieldDoubleQuotes?: boolean;
34
- }
@@ -1,5 +0,0 @@
1
- import { SortDirection, SortDirectionString } from '@slickgrid-universal/common';
2
- export interface GraphqlSortingOption {
3
- field: string;
4
- direction: SortDirection | SortDirectionString;
5
- }
@@ -1,10 +0,0 @@
1
- export * from './graphqlCursorPaginationOption.interface';
2
- export * from './graphqlDatasetFilter.interface';
3
- export * from './graphqlFilteringOption.interface';
4
- export * from './graphqlPaginatedResult.interface';
5
- export * from './graphqlPaginationOption.interface';
6
- export * from './graphqlResult.interface';
7
- export * from './graphqlServiceApi.interface';
8
- export * from './graphqlServiceOption.interface';
9
- export * from './graphqlSortingOption.interface';
10
- export * from './queryArgument.interface';
@@ -1,38 +0,0 @@
1
- /**
2
- * This GraphqlQueryBuilder class is a lib that already exist
3
- * but was causing issues with TypeScript, RequireJS and other bundler/packagers
4
- * and so I rewrote it in pure TypeScript.
5
- *
6
- * The previous lib can be viewed here at this Github
7
- * https://github.com/codemeasandwich/graphql-query-builder
8
- */
9
- export default class GraphqlQueryBuilder {
10
- protected queryFnName: string;
11
- alias: string | Function;
12
- head: any[];
13
- body: any;
14
- constructor(queryFnName: string, aliasOrFilter?: string | object);
15
- /**
16
- * The parameters to run the query against.
17
- * @param filters An object mapping attribute to values
18
- */
19
- filter(filters: any): this;
20
- /**
21
- * Outlines the properties you wish to be returned from the query.
22
- * @param properties representing each attribute you want Returned
23
- */
24
- find(...searches: any[]): this;
25
- /**
26
- * set an alias for this result.
27
- * @param alias
28
- */
29
- setAlias(alias: string): void;
30
- /**
31
- * Return to the formatted query string
32
- * @return
33
- */
34
- toString(): string;
35
- protected parceFind(_levelA: any[]): string;
36
- protected getGraphQLValue(value: any): any;
37
- protected objectToString(obj: any): string;
38
- }
@@ -1,2 +0,0 @@
1
- export * from './graphql.service';
2
- export { default as GraphqlQueryBuilder } from './graphqlQueryBuilder';
@@ -1,3 +0,0 @@
1
- export { GraphqlService } from './services/graphql.service';
2
- export { default as GraphqlQueryBuilder } from './services/graphqlQueryBuilder';
3
- export * from './interfaces/index';
@@ -1,12 +0,0 @@
1
- import { GraphqlFilteringOption } from './graphqlFilteringOption.interface';
2
- import { GraphqlSortingOption } from './graphqlSortingOption.interface';
3
- export interface GraphqlDatasetFilter {
4
- first?: number;
5
- last?: number;
6
- offset?: number;
7
- after?: string;
8
- before?: string;
9
- locale?: string;
10
- filterBy?: GraphqlFilteringOption[];
11
- orderBy?: GraphqlSortingOption[];
12
- }
@@ -1,29 +0,0 @@
1
- import { Metrics } from '@slickgrid-universal/common';
2
- export interface GraphqlPaginatedResult {
3
- data: {
4
- [datasetName: string]: {
5
- /** result set of data objects (array of data) */
6
- nodes: any[];
7
- /** Total count of items in the table (needed for the Pagination to work) */
8
- totalCount: number;
9
- /** Edges information of the current cursor */
10
- edges?: {
11
- /** Current cursor position */
12
- cursor: string;
13
- };
14
- /** Page information of the current cursor, do we have a next page and what is the end cursor? */
15
- pageInfo?: {
16
- /** Do we have a next page from current cursor position? */
17
- hasNextPage: boolean;
18
- /** Do we have a previous page from current cursor position? */
19
- hasPreviousPage: boolean;
20
- /** What is the last cursor? */
21
- endCursor: string;
22
- /** What is the first cursor? */
23
- startCursor: string;
24
- };
25
- };
26
- };
27
- /** Some metrics of the last executed query (startTime, endTime, executionTime, itemCount, totalItemCount) */
28
- metrics?: Metrics;
29
- }
@@ -1,5 +0,0 @@
1
- export interface GraphqlPaginationOption {
2
- first?: number;
3
- last?: number;
4
- offset?: number;
5
- }
@@ -1,8 +0,0 @@
1
- import { Metrics } from '@slickgrid-universal/common';
2
- export interface GraphqlResult<T = any> {
3
- data: {
4
- [datasetName: string]: T[];
5
- };
6
- /** Some metrics of the last executed query (startTime, endTime, executionTime, itemCount, totalItemCount) */
7
- metrics?: Metrics;
8
- }
@@ -1,4 +0,0 @@
1
- export interface QueryArgument {
2
- field: string;
3
- value: string | number | boolean;
4
- }
@@ -1,99 +0,0 @@
1
- import { BackendService, Column, ColumnFilters, ColumnSort, CurrentFilter, CurrentPagination, CurrentSorter, FieldType, FilterChangedArgs, GridOption, MultiColumnSort, Pagination, PaginationChangedArgs, SharedService, SingleColumnSort, SlickGrid } from '@slickgrid-universal/common';
2
- import { GraphqlCursorPaginationOption, GraphqlDatasetFilter, GraphqlPaginationOption, GraphqlServiceOption } from '../interfaces/index';
3
- export declare class GraphqlService implements BackendService {
4
- protected _currentFilters: ColumnFilters | CurrentFilter[];
5
- protected _currentPagination: CurrentPagination | null;
6
- protected _currentSorters: CurrentSorter[];
7
- protected _columnDefinitions?: Column[];
8
- protected _grid: SlickGrid | undefined;
9
- protected _datasetIdPropName: string;
10
- options: GraphqlServiceOption | undefined;
11
- pagination: Pagination | undefined;
12
- defaultPaginationOptions: GraphqlPaginationOption | GraphqlCursorPaginationOption;
13
- /** Getter for the Column Definitions */
14
- get columnDefinitions(): Column<any>[] | undefined;
15
- /** Getter for the Grid Options pulled through the Grid Object */
16
- protected get _gridOptions(): GridOption;
17
- /** Initialization of the service, which acts as a constructor */
18
- init(serviceOptions?: GraphqlServiceOption, pagination?: Pagination, grid?: SlickGrid, sharedService?: SharedService): void;
19
- /**
20
- * Build the GraphQL query, since the service include/exclude cursor, the output query will be different.
21
- * @param serviceOptions GraphqlServiceOption
22
- */
23
- buildQuery(): string;
24
- /**
25
- * From an input array of strings, we want to build a GraphQL query string.
26
- * The process has to take the dot notation and parse it into a valid GraphQL query
27
- * Following this SO answer https://stackoverflow.com/a/47705476/1212166
28
- *
29
- * INPUT
30
- * ['firstName', 'lastName', 'billing.address.street', 'billing.address.zip']
31
- * OUTPUT
32
- * firstName, lastName, billing{address{street, zip}}
33
- * @param inputArray
34
- */
35
- buildFilterQuery(inputArray: string[]): string;
36
- clearFilters(): void;
37
- clearSorters(): void;
38
- /**
39
- * Get an initialization of Pagination options
40
- * @return Pagination Options
41
- */
42
- getInitPaginationOptions(): GraphqlDatasetFilter;
43
- /** Get the GraphQL dataset name */
44
- getDatasetName(): string;
45
- /** Get the Filters that are currently used by the grid */
46
- getCurrentFilters(): ColumnFilters | CurrentFilter[];
47
- /** Get the Pagination that is currently used by the grid */
48
- getCurrentPagination(): CurrentPagination | null;
49
- /** Get the Sorters that are currently used by the grid */
50
- getCurrentSorters(): CurrentSorter[];
51
- resetPaginationOptions(): void;
52
- updateOptions(serviceOptions?: Partial<GraphqlServiceOption>): void;
53
- processOnFilterChanged(_event: Event | undefined, args: FilterChangedArgs): string;
54
- processOnPaginationChanged(_event: Event | undefined, args: PaginationChangedArgs): string;
55
- processOnSortChanged(_event: Event | undefined, args: SingleColumnSort | MultiColumnSort): string;
56
- /**
57
- * loop through all columns to inspect filters & update backend service filteringOptions
58
- * @param columnFilters
59
- */
60
- updateFilters(columnFilters: ColumnFilters | CurrentFilter[], isUpdatedByPresetOrDynamically: boolean): void;
61
- /**
62
- * Update the pagination component with it's new page number and size
63
- * @param newPage
64
- * @param pageSize
65
- */
66
- updatePagination(newPage: number, pageSize: number): void;
67
- /**
68
- * loop through all columns to inspect sorters & update backend service sortingOptions
69
- * @param columnFilters
70
- */
71
- updateSorters(sortColumns?: ColumnSort[], presetSorters?: CurrentSorter[]): void;
72
- /**
73
- * A function which takes an input string and removes double quotes only
74
- * on certain fields are identified as GraphQL enums (except fields with dot notation)
75
- * For example let say we identified ("direction:", "sort") as word which are GraphQL enum fields
76
- * then the result will be:
77
- * FROM
78
- * query { users (orderBy:[{field:"firstName", direction:"ASC"} }]) }
79
- * TO
80
- * query { users (orderBy:[{field: firstName, direction: ASC}})}
81
- *
82
- * EXCEPTIONS (fields with dot notation "." which are inside a "field:")
83
- * these fields will keep double quotes while everything else will be stripped of double quotes
84
- * query { users (orderBy:[{field:"billing.street.name", direction: "ASC"} }
85
- * TO
86
- * query { users (orderBy:[{field:"billing.street.name", direction: ASC}}
87
- * @param inputStr input string
88
- * @param enumSearchWords array of enum words to filter
89
- * @returns outputStr output string
90
- */
91
- trimDoubleQuotesOnEnumField(inputStr: string, enumSearchWords: string[], keepArgumentFieldDoubleQuotes: boolean): string;
92
- /**
93
- * Cast provided filters (could be in multiple formats) into an array of CurrentFilter
94
- * @param columnFilters
95
- */
96
- protected castFilterToColumnFilters(columnFilters: ColumnFilters | CurrentFilter[]): CurrentFilter[];
97
- /** Normalizes the search value according to field type. */
98
- protected normalizeSearchValue(fieldType: typeof FieldType[keyof typeof FieldType], searchValue: any): any;
99
- }