@slickgrid-universal/odata 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.
- package/dist/commonjs/index.js +22 -22
- package/dist/commonjs/interfaces/index.js +19 -19
- package/dist/commonjs/interfaces/odataOption.interface.js +2 -2
- package/dist/commonjs/interfaces/odataServiceApi.interface.js +2 -2
- package/dist/commonjs/interfaces/odataSortingOption.interface.js +2 -2
- package/dist/commonjs/services/grid-odata.service.js +582 -582
- package/dist/commonjs/services/index.js +18 -18
- package/dist/commonjs/services/odataQueryBuilder.service.js +208 -208
- package/dist/esm/index.js +3 -3
- package/dist/esm/interfaces/index.js +3 -3
- package/dist/esm/interfaces/odataOption.interface.js +1 -1
- package/dist/esm/interfaces/odataServiceApi.interface.js +1 -1
- package/dist/esm/interfaces/odataSortingOption.interface.js +1 -1
- package/dist/esm/services/grid-odata.service.js +580 -580
- package/dist/esm/services/index.js +2 -2
- package/dist/esm/services/odataQueryBuilder.service.js +204 -204
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/{commonjs → types}/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{esm → types}/interfaces/index.d.ts +4 -3
- package/dist/types/interfaces/index.d.ts.map +1 -0
- package/dist/{commonjs → types}/interfaces/odataOption.interface.d.ts +38 -37
- package/dist/types/interfaces/odataOption.interface.d.ts.map +1 -0
- package/dist/{esm → types}/interfaces/odataServiceApi.interface.d.ts +10 -9
- package/dist/types/interfaces/odataServiceApi.interface.d.ts.map +1 -0
- package/dist/{commonjs → types}/interfaces/odataSortingOption.interface.d.ts +6 -5
- package/dist/types/interfaces/odataSortingOption.interface.d.ts.map +1 -0
- package/dist/{commonjs → types}/services/grid-odata.service.d.ts +75 -74
- package/dist/types/services/grid-odata.service.d.ts.map +1 -0
- package/dist/{esm → types}/services/index.d.ts +3 -2
- package/dist/types/services/index.d.ts.map +1 -0
- package/dist/{commonjs → types}/services/odataQueryBuilder.service.d.ts +29 -28
- package/dist/types/services/odataQueryBuilder.service.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/commonjs/interfaces/index.d.ts +0 -3
- package/dist/commonjs/interfaces/odataServiceApi.interface.d.ts +0 -9
- package/dist/commonjs/services/index.d.ts +0 -2
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/interfaces/odataOption.interface.d.ts +0 -37
- package/dist/esm/interfaces/odataSortingOption.interface.d.ts +0 -5
- package/dist/esm/services/grid-odata.service.d.ts +0 -74
- package/dist/esm/services/odataQueryBuilder.service.d.ts +0 -28
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './grid-odata.service';
|
|
2
|
-
export * from './odataQueryBuilder.service';
|
|
1
|
+
export * from './grid-odata.service';
|
|
2
|
+
export * from './odataQueryBuilder.service';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
import { CaseType } from '@slickgrid-universal/common';
|
|
2
|
-
import { titleCase } from '@slickgrid-universal/utils';
|
|
3
|
-
export class OdataQueryBuilderService {
|
|
4
|
-
set columnDefinitions(columnDefinitions) {
|
|
5
|
-
this._columnDefinitions = columnDefinitions;
|
|
6
|
-
}
|
|
7
|
-
set datasetIdPropName(datasetIdPropName) {
|
|
8
|
-
this._datasetIdPropName = datasetIdPropName;
|
|
9
|
-
}
|
|
10
|
-
constructor() {
|
|
11
|
-
this._filterCount = 0;
|
|
12
|
-
this._columnDefinitions = [];
|
|
13
|
-
this._datasetIdPropName = 'id';
|
|
14
|
-
this._odataOptions = {
|
|
15
|
-
filterQueue: [],
|
|
16
|
-
orderBy: ''
|
|
17
|
-
};
|
|
18
|
-
this._defaultSortBy = '';
|
|
19
|
-
this._columnFilters = {};
|
|
20
|
-
}
|
|
21
|
-
/*
|
|
22
|
-
* Build the OData query string from all the options provided
|
|
23
|
-
* @return string OData query
|
|
24
|
-
*/
|
|
25
|
-
buildQuery() {
|
|
26
|
-
if (!this._odataOptions) {
|
|
27
|
-
throw new Error('Odata Service requires certain options like "top" for it to work');
|
|
28
|
-
}
|
|
29
|
-
this._odataOptions.filterQueue = [];
|
|
30
|
-
const queryTmpArray = [];
|
|
31
|
-
// When enableCount is set, add it to the OData query
|
|
32
|
-
if (this._odataOptions && this._odataOptions.enableCount === true) {
|
|
33
|
-
const countQuery = (this._odataOptions.version && this._odataOptions.version >= 4) ? '$count=true' : '$inlinecount=allpages';
|
|
34
|
-
queryTmpArray.push(countQuery);
|
|
35
|
-
}
|
|
36
|
-
if (this._odataOptions.top) {
|
|
37
|
-
queryTmpArray.push(`$top=${this._odataOptions.top}`);
|
|
38
|
-
}
|
|
39
|
-
if (this._odataOptions.skip) {
|
|
40
|
-
queryTmpArray.push(`$skip=${this._odataOptions.skip}`);
|
|
41
|
-
}
|
|
42
|
-
if (this._odataOptions.orderBy) {
|
|
43
|
-
let argument = '';
|
|
44
|
-
if (Array.isArray(this._odataOptions.orderBy)) {
|
|
45
|
-
argument = this._odataOptions.orderBy.join(','); // csv, that will form a query, for example: $orderby=RoleName asc, Id desc
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
argument = this._odataOptions.orderBy;
|
|
49
|
-
}
|
|
50
|
-
queryTmpArray.push(`$orderby=${argument}`);
|
|
51
|
-
}
|
|
52
|
-
if (this._odataOptions.filterBy || this._odataOptions.filter) {
|
|
53
|
-
const filterBy = this._odataOptions.filter || this._odataOptions.filterBy;
|
|
54
|
-
if (filterBy) {
|
|
55
|
-
this._filterCount = 1;
|
|
56
|
-
this._odataOptions.filterQueue = [];
|
|
57
|
-
let filterStr = filterBy;
|
|
58
|
-
if (Array.isArray(filterBy)) {
|
|
59
|
-
this._filterCount = filterBy.length;
|
|
60
|
-
filterStr = filterBy.join(` ${this._odataOptions.filterBySeparator || 'and'} `);
|
|
61
|
-
}
|
|
62
|
-
if (typeof filterStr === 'string') {
|
|
63
|
-
if (!(filterStr[0] === '(' && filterStr.slice(-1) === ')')) {
|
|
64
|
-
this.addToFilterQueueWhenNotExists(`(${filterStr})`);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.addToFilterQueueWhenNotExists(filterStr);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (this._odataOptions.filterQueue.length > 0) {
|
|
73
|
-
const query = this._odataOptions.filterQueue.join(` ${this._odataOptions.filterBySeparator || 'and'} `);
|
|
74
|
-
this._odataOptions.filter = query; // overwrite with
|
|
75
|
-
queryTmpArray.push(`$filter=${query}`);
|
|
76
|
-
}
|
|
77
|
-
if (this._odataOptions.enableSelect || this._odataOptions.enableExpand) {
|
|
78
|
-
const fields = this._columnDefinitions.flatMap(x => { var _a; return (_a = x.fields) !== null && _a !== void 0 ? _a : [x.field]; });
|
|
79
|
-
fields.unshift(this._datasetIdPropName);
|
|
80
|
-
const selectExpand = this.buildSelectExpand([...new Set(fields)]);
|
|
81
|
-
if (this._odataOptions.enableSelect) {
|
|
82
|
-
const select = selectExpand.selectParts.join(',');
|
|
83
|
-
queryTmpArray.push(`$select=${select}`);
|
|
84
|
-
}
|
|
85
|
-
if (this._odataOptions.enableExpand) {
|
|
86
|
-
const expand = selectExpand.expandParts.join(',');
|
|
87
|
-
queryTmpArray.push(`$expand=${expand}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// join all the odata functions by a '&'
|
|
91
|
-
return queryTmpArray.join('&');
|
|
92
|
-
}
|
|
93
|
-
getFilterCount() {
|
|
94
|
-
return this._filterCount;
|
|
95
|
-
}
|
|
96
|
-
get columnFilters() {
|
|
97
|
-
return this._columnFilters;
|
|
98
|
-
}
|
|
99
|
-
get options() {
|
|
100
|
-
return this._odataOptions;
|
|
101
|
-
}
|
|
102
|
-
set options(options) {
|
|
103
|
-
this._odataOptions = options;
|
|
104
|
-
}
|
|
105
|
-
removeColumnFilter(fieldName) {
|
|
106
|
-
if (this._columnFilters && this._columnFilters.hasOwnProperty(fieldName)) {
|
|
107
|
-
delete this._columnFilters[fieldName];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
saveColumnFilter(fieldName, value, searchTerms) {
|
|
111
|
-
this._columnFilters[fieldName] = {
|
|
112
|
-
search: searchTerms,
|
|
113
|
-
value
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Change any OData options that will be used to build the query
|
|
118
|
-
* @param object options
|
|
119
|
-
*/
|
|
120
|
-
updateOptions(options) {
|
|
121
|
-
for (const property of Object.keys(options)) {
|
|
122
|
-
if (options.hasOwnProperty(property)) {
|
|
123
|
-
this._odataOptions[property] = options[property]; // replace of the property
|
|
124
|
-
}
|
|
125
|
-
// we need to keep the defaultSortBy for references whenever the user removes his Sorting
|
|
126
|
-
// then we would revert to the defaultSortBy and the only way is to keep a hard copy here
|
|
127
|
-
if (property === 'orderBy' || property === 'sortBy') {
|
|
128
|
-
let sortBy = options[property];
|
|
129
|
-
// make sure first char of each orderBy field is capitalize
|
|
130
|
-
if (this._odataOptions.caseType === CaseType.pascalCase) {
|
|
131
|
-
if (Array.isArray(sortBy)) {
|
|
132
|
-
sortBy.forEach((field, index, inputArray) => {
|
|
133
|
-
inputArray[index] = titleCase(field);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
sortBy = titleCase(options[property]);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
this._odataOptions.orderBy = sortBy;
|
|
141
|
-
this._defaultSortBy = sortBy;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
//
|
|
146
|
-
// protected functions
|
|
147
|
-
// -------------------
|
|
148
|
-
addToFilterQueueWhenNotExists(filterStr) {
|
|
149
|
-
if (this._odataOptions.filterQueue && this._odataOptions.filterQueue.indexOf(filterStr) === -1) {
|
|
150
|
-
this._odataOptions.filterQueue.push(filterStr);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
//
|
|
154
|
-
// private functions
|
|
155
|
-
// -------------------
|
|
156
|
-
buildSelectExpand(selectFields) {
|
|
157
|
-
const navigations = {};
|
|
158
|
-
const selectItems = new Set();
|
|
159
|
-
for (const field of selectFields) {
|
|
160
|
-
const splits = field.split('/');
|
|
161
|
-
if (splits.length === 1) {
|
|
162
|
-
selectItems.add(field);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
const navigation = splits[0];
|
|
166
|
-
const properties = splits.splice(1).join('/');
|
|
167
|
-
if (!navigations[navigation]) {
|
|
168
|
-
navigations[navigation] = [];
|
|
169
|
-
}
|
|
170
|
-
navigations[navigation].push(properties);
|
|
171
|
-
if (this._odataOptions.enableExpand && !(this._odataOptions.version && this._odataOptions.version >= 4)) {
|
|
172
|
-
selectItems.add(navigation);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
selectParts: [...selectItems],
|
|
178
|
-
expandParts: this._odataOptions.enableExpand ? this.buildExpand(navigations) : []
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
buildExpand(navigations) {
|
|
182
|
-
const expandParts = [];
|
|
183
|
-
for (const navigation of Object.keys(navigations)) {
|
|
184
|
-
if (this._odataOptions.enableSelect && this._odataOptions.version && this._odataOptions.version >= 4) {
|
|
185
|
-
const subSelectExpand = this.buildSelectExpand(navigations[navigation]);
|
|
186
|
-
let subSelect = subSelectExpand.selectParts.join(',');
|
|
187
|
-
if (subSelect.length > 0) {
|
|
188
|
-
subSelect = '$select=' + subSelect;
|
|
189
|
-
}
|
|
190
|
-
if (this._odataOptions.enableExpand && subSelectExpand.expandParts.length > 0) {
|
|
191
|
-
subSelect += (subSelect.length > 0 ? ';' : '') + '$expand=' + subSelectExpand.expandParts.join(',');
|
|
192
|
-
}
|
|
193
|
-
if (subSelect.length > 0) {
|
|
194
|
-
subSelect = '(' + subSelect + ')';
|
|
195
|
-
}
|
|
196
|
-
expandParts.push(navigation + subSelect);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
expandParts.push(navigation);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return expandParts;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
1
|
+
import { CaseType } from '@slickgrid-universal/common';
|
|
2
|
+
import { titleCase } from '@slickgrid-universal/utils';
|
|
3
|
+
export class OdataQueryBuilderService {
|
|
4
|
+
set columnDefinitions(columnDefinitions) {
|
|
5
|
+
this._columnDefinitions = columnDefinitions;
|
|
6
|
+
}
|
|
7
|
+
set datasetIdPropName(datasetIdPropName) {
|
|
8
|
+
this._datasetIdPropName = datasetIdPropName;
|
|
9
|
+
}
|
|
10
|
+
constructor() {
|
|
11
|
+
this._filterCount = 0;
|
|
12
|
+
this._columnDefinitions = [];
|
|
13
|
+
this._datasetIdPropName = 'id';
|
|
14
|
+
this._odataOptions = {
|
|
15
|
+
filterQueue: [],
|
|
16
|
+
orderBy: ''
|
|
17
|
+
};
|
|
18
|
+
this._defaultSortBy = '';
|
|
19
|
+
this._columnFilters = {};
|
|
20
|
+
}
|
|
21
|
+
/*
|
|
22
|
+
* Build the OData query string from all the options provided
|
|
23
|
+
* @return string OData query
|
|
24
|
+
*/
|
|
25
|
+
buildQuery() {
|
|
26
|
+
if (!this._odataOptions) {
|
|
27
|
+
throw new Error('Odata Service requires certain options like "top" for it to work');
|
|
28
|
+
}
|
|
29
|
+
this._odataOptions.filterQueue = [];
|
|
30
|
+
const queryTmpArray = [];
|
|
31
|
+
// When enableCount is set, add it to the OData query
|
|
32
|
+
if (this._odataOptions && this._odataOptions.enableCount === true) {
|
|
33
|
+
const countQuery = (this._odataOptions.version && this._odataOptions.version >= 4) ? '$count=true' : '$inlinecount=allpages';
|
|
34
|
+
queryTmpArray.push(countQuery);
|
|
35
|
+
}
|
|
36
|
+
if (this._odataOptions.top) {
|
|
37
|
+
queryTmpArray.push(`$top=${this._odataOptions.top}`);
|
|
38
|
+
}
|
|
39
|
+
if (this._odataOptions.skip) {
|
|
40
|
+
queryTmpArray.push(`$skip=${this._odataOptions.skip}`);
|
|
41
|
+
}
|
|
42
|
+
if (this._odataOptions.orderBy) {
|
|
43
|
+
let argument = '';
|
|
44
|
+
if (Array.isArray(this._odataOptions.orderBy)) {
|
|
45
|
+
argument = this._odataOptions.orderBy.join(','); // csv, that will form a query, for example: $orderby=RoleName asc, Id desc
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
argument = this._odataOptions.orderBy;
|
|
49
|
+
}
|
|
50
|
+
queryTmpArray.push(`$orderby=${argument}`);
|
|
51
|
+
}
|
|
52
|
+
if (this._odataOptions.filterBy || this._odataOptions.filter) {
|
|
53
|
+
const filterBy = this._odataOptions.filter || this._odataOptions.filterBy;
|
|
54
|
+
if (filterBy) {
|
|
55
|
+
this._filterCount = 1;
|
|
56
|
+
this._odataOptions.filterQueue = [];
|
|
57
|
+
let filterStr = filterBy;
|
|
58
|
+
if (Array.isArray(filterBy)) {
|
|
59
|
+
this._filterCount = filterBy.length;
|
|
60
|
+
filterStr = filterBy.join(` ${this._odataOptions.filterBySeparator || 'and'} `);
|
|
61
|
+
}
|
|
62
|
+
if (typeof filterStr === 'string') {
|
|
63
|
+
if (!(filterStr[0] === '(' && filterStr.slice(-1) === ')')) {
|
|
64
|
+
this.addToFilterQueueWhenNotExists(`(${filterStr})`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.addToFilterQueueWhenNotExists(filterStr);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (this._odataOptions.filterQueue.length > 0) {
|
|
73
|
+
const query = this._odataOptions.filterQueue.join(` ${this._odataOptions.filterBySeparator || 'and'} `);
|
|
74
|
+
this._odataOptions.filter = query; // overwrite with
|
|
75
|
+
queryTmpArray.push(`$filter=${query}`);
|
|
76
|
+
}
|
|
77
|
+
if (this._odataOptions.enableSelect || this._odataOptions.enableExpand) {
|
|
78
|
+
const fields = this._columnDefinitions.flatMap(x => { var _a; return (_a = x.fields) !== null && _a !== void 0 ? _a : [x.field]; });
|
|
79
|
+
fields.unshift(this._datasetIdPropName);
|
|
80
|
+
const selectExpand = this.buildSelectExpand([...new Set(fields)]);
|
|
81
|
+
if (this._odataOptions.enableSelect) {
|
|
82
|
+
const select = selectExpand.selectParts.join(',');
|
|
83
|
+
queryTmpArray.push(`$select=${select}`);
|
|
84
|
+
}
|
|
85
|
+
if (this._odataOptions.enableExpand) {
|
|
86
|
+
const expand = selectExpand.expandParts.join(',');
|
|
87
|
+
queryTmpArray.push(`$expand=${expand}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// join all the odata functions by a '&'
|
|
91
|
+
return queryTmpArray.join('&');
|
|
92
|
+
}
|
|
93
|
+
getFilterCount() {
|
|
94
|
+
return this._filterCount;
|
|
95
|
+
}
|
|
96
|
+
get columnFilters() {
|
|
97
|
+
return this._columnFilters;
|
|
98
|
+
}
|
|
99
|
+
get options() {
|
|
100
|
+
return this._odataOptions;
|
|
101
|
+
}
|
|
102
|
+
set options(options) {
|
|
103
|
+
this._odataOptions = options;
|
|
104
|
+
}
|
|
105
|
+
removeColumnFilter(fieldName) {
|
|
106
|
+
if (this._columnFilters && this._columnFilters.hasOwnProperty(fieldName)) {
|
|
107
|
+
delete this._columnFilters[fieldName];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
saveColumnFilter(fieldName, value, searchTerms) {
|
|
111
|
+
this._columnFilters[fieldName] = {
|
|
112
|
+
search: searchTerms,
|
|
113
|
+
value
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Change any OData options that will be used to build the query
|
|
118
|
+
* @param object options
|
|
119
|
+
*/
|
|
120
|
+
updateOptions(options) {
|
|
121
|
+
for (const property of Object.keys(options)) {
|
|
122
|
+
if (options.hasOwnProperty(property)) {
|
|
123
|
+
this._odataOptions[property] = options[property]; // replace of the property
|
|
124
|
+
}
|
|
125
|
+
// we need to keep the defaultSortBy for references whenever the user removes his Sorting
|
|
126
|
+
// then we would revert to the defaultSortBy and the only way is to keep a hard copy here
|
|
127
|
+
if (property === 'orderBy' || property === 'sortBy') {
|
|
128
|
+
let sortBy = options[property];
|
|
129
|
+
// make sure first char of each orderBy field is capitalize
|
|
130
|
+
if (this._odataOptions.caseType === CaseType.pascalCase) {
|
|
131
|
+
if (Array.isArray(sortBy)) {
|
|
132
|
+
sortBy.forEach((field, index, inputArray) => {
|
|
133
|
+
inputArray[index] = titleCase(field);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
sortBy = titleCase(options[property]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this._odataOptions.orderBy = sortBy;
|
|
141
|
+
this._defaultSortBy = sortBy;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//
|
|
146
|
+
// protected functions
|
|
147
|
+
// -------------------
|
|
148
|
+
addToFilterQueueWhenNotExists(filterStr) {
|
|
149
|
+
if (this._odataOptions.filterQueue && this._odataOptions.filterQueue.indexOf(filterStr) === -1) {
|
|
150
|
+
this._odataOptions.filterQueue.push(filterStr);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//
|
|
154
|
+
// private functions
|
|
155
|
+
// -------------------
|
|
156
|
+
buildSelectExpand(selectFields) {
|
|
157
|
+
const navigations = {};
|
|
158
|
+
const selectItems = new Set();
|
|
159
|
+
for (const field of selectFields) {
|
|
160
|
+
const splits = field.split('/');
|
|
161
|
+
if (splits.length === 1) {
|
|
162
|
+
selectItems.add(field);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const navigation = splits[0];
|
|
166
|
+
const properties = splits.splice(1).join('/');
|
|
167
|
+
if (!navigations[navigation]) {
|
|
168
|
+
navigations[navigation] = [];
|
|
169
|
+
}
|
|
170
|
+
navigations[navigation].push(properties);
|
|
171
|
+
if (this._odataOptions.enableExpand && !(this._odataOptions.version && this._odataOptions.version >= 4)) {
|
|
172
|
+
selectItems.add(navigation);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
selectParts: [...selectItems],
|
|
178
|
+
expandParts: this._odataOptions.enableExpand ? this.buildExpand(navigations) : []
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
buildExpand(navigations) {
|
|
182
|
+
const expandParts = [];
|
|
183
|
+
for (const navigation of Object.keys(navigations)) {
|
|
184
|
+
if (this._odataOptions.enableSelect && this._odataOptions.version && this._odataOptions.version >= 4) {
|
|
185
|
+
const subSelectExpand = this.buildSelectExpand(navigations[navigation]);
|
|
186
|
+
let subSelect = subSelectExpand.selectParts.join(',');
|
|
187
|
+
if (subSelect.length > 0) {
|
|
188
|
+
subSelect = '$select=' + subSelect;
|
|
189
|
+
}
|
|
190
|
+
if (this._odataOptions.enableExpand && subSelectExpand.expandParts.length > 0) {
|
|
191
|
+
subSelect += (subSelect.length > 0 ? ';' : '') + '$expand=' + subSelectExpand.expandParts.join(',');
|
|
192
|
+
}
|
|
193
|
+
if (subSelect.length > 0) {
|
|
194
|
+
subSelect = '(' + subSelect + ')';
|
|
195
|
+
}
|
|
196
|
+
expandParts.push(navigation + subSelect);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
expandParts.push(navigation);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return expandParts;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
205
|
//# sourceMappingURL=odataQueryBuilder.service.js.map
|