@esri/hub-common 9.3.0 → 9.4.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/es2017/search/_searchContent.js +62 -0
- package/dist/es2017/search/_searchContent.js.map +1 -0
- package/dist/es2017/search/content-utils.js +422 -0
- package/dist/es2017/search/content-utils.js.map +1 -0
- package/dist/es2017/search/index.js +4 -0
- package/dist/es2017/search/index.js.map +1 -1
- package/dist/es2017/search/types.js +1 -0
- package/dist/es2017/search/types.js.map +1 -0
- package/dist/es2017/search/utils.js +344 -0
- package/dist/es2017/search/utils.js.map +1 -0
- package/dist/esm/search/_searchContent.js +70 -0
- package/dist/esm/search/_searchContent.js.map +1 -0
- package/dist/esm/search/content-utils.js +426 -0
- package/dist/esm/search/content-utils.js.map +1 -0
- package/dist/esm/search/index.js +4 -0
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/search/types.js +1 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/search/utils.js +341 -0
- package/dist/esm/search/utils.js.map +1 -0
- package/dist/node/search/_searchContent.js +66 -0
- package/dist/node/search/_searchContent.js.map +1 -0
- package/dist/node/search/content-utils.js +432 -0
- package/dist/node/search/content-utils.js.map +1 -0
- package/dist/node/search/index.js +4 -0
- package/dist/node/search/index.js.map +1 -1
- package/dist/node/search/types.js +3 -0
- package/dist/node/search/types.js.map +1 -0
- package/dist/node/search/utils.js +357 -0
- package/dist/node/search/utils.js.map +1 -0
- package/dist/types/search/_searchContent.d.ts +7 -0
- package/dist/types/search/content-utils.d.ts +70 -0
- package/dist/types/search/index.d.ts +4 -0
- package/dist/types/search/types.d.ts +294 -0
- package/dist/types/search/utils.d.ts +92 -0
- package/dist/umd/common.umd.js +842 -1
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2018-2021 Environmental Systems Research Institute, Inc.
|
|
3
|
+
* Apache-2.0 */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.serializeStringOrArray = exports.serializeDateRange = exports.serializeMatchOptions = exports.mergeSearchOptions = exports.relativeDateToDateRange = exports.valueToMatchOptions = exports.mergeMatchOptions = exports.mergeDateRange = exports.mergeSearchResults = exports.expandApis = exports.SEARCH_APIS = void 0;
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
/**
|
|
8
|
+
* Well known APIs
|
|
9
|
+
* Short-forms for specifying common APIs
|
|
10
|
+
*/
|
|
11
|
+
exports.SEARCH_APIS = {
|
|
12
|
+
arcgis: {
|
|
13
|
+
label: "ArcGIS Online",
|
|
14
|
+
url: "https://www.arcgis.com",
|
|
15
|
+
type: "arcgis",
|
|
16
|
+
},
|
|
17
|
+
arcgisQA: {
|
|
18
|
+
label: "ArcGIS Online QAEXT",
|
|
19
|
+
url: "https://qaext.arcgis.com",
|
|
20
|
+
type: "arcgis",
|
|
21
|
+
},
|
|
22
|
+
arcgisDEV: {
|
|
23
|
+
label: "ArcGIS Online DEVEXT",
|
|
24
|
+
url: "https://devext.arcgis.com",
|
|
25
|
+
type: "arcgis",
|
|
26
|
+
},
|
|
27
|
+
hub: {
|
|
28
|
+
label: "ArcGIS Hub",
|
|
29
|
+
url: "https://hub.arcgis.com/api",
|
|
30
|
+
type: "arcgis-hub",
|
|
31
|
+
},
|
|
32
|
+
hubDEV: {
|
|
33
|
+
label: "ArcGIS Hub DEV",
|
|
34
|
+
url: "https://hubdev.arcgis.com/api",
|
|
35
|
+
type: "arcgis-hub",
|
|
36
|
+
},
|
|
37
|
+
hubQA: {
|
|
38
|
+
label: "ArcGIS Hub QA",
|
|
39
|
+
url: "https://hubqa.arcgis.com/api",
|
|
40
|
+
type: "arcgis-hub",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
* Convert api "names" into full ApiDefinitions
|
|
46
|
+
* @param apis
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
function expandApis(apis) {
|
|
50
|
+
return apis.map((api) => {
|
|
51
|
+
if (typeof api === "string" && api in exports.SEARCH_APIS) {
|
|
52
|
+
return exports.SEARCH_APIS[api];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// it's an object, so we trust that it's well formed
|
|
56
|
+
return api;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.expandApis = expandApis;
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
* Merge multiple search responses
|
|
64
|
+
*
|
|
65
|
+
* Naieve implementation that just merges arrays
|
|
66
|
+
* @param responses
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function mergeSearchResults(responses) {
|
|
70
|
+
// Merge content
|
|
71
|
+
const content = responses.reduce((acc, response) => {
|
|
72
|
+
if (response.content) {
|
|
73
|
+
acc = acc.concat(response.content);
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, []);
|
|
77
|
+
// Merge Facets
|
|
78
|
+
const facets = responses.reduce((acc, response) => {
|
|
79
|
+
if (response.facets) {
|
|
80
|
+
acc = acc.concat(response.facets);
|
|
81
|
+
}
|
|
82
|
+
return acc;
|
|
83
|
+
}, []);
|
|
84
|
+
return { content, facets };
|
|
85
|
+
}
|
|
86
|
+
exports.mergeSearchResults = mergeSearchResults;
|
|
87
|
+
/**
|
|
88
|
+
* @private
|
|
89
|
+
* Merge two date ranges by taking the longest span
|
|
90
|
+
* @param dr1
|
|
91
|
+
* @param dr2
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
function mergeDateRange(dr1, dr2) {
|
|
95
|
+
const result = util_1.cloneObject(dr1);
|
|
96
|
+
// feels like there is a more concise way to do this...
|
|
97
|
+
if (dr2.from < dr1.from) {
|
|
98
|
+
result.from = dr2.from;
|
|
99
|
+
}
|
|
100
|
+
if (dr2.to > dr1.to) {
|
|
101
|
+
result.to = dr2.to;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
exports.mergeDateRange = mergeDateRange;
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
* Merge two [`MatchOptions`](../MatchOptions)
|
|
109
|
+
*
|
|
110
|
+
* Currently a naieve implementation where the arrays are simply merged
|
|
111
|
+
*
|
|
112
|
+
* @param mo1
|
|
113
|
+
* @param mo2
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
function mergeMatchOptions(mo1, mo2) {
|
|
117
|
+
const result = {};
|
|
118
|
+
// None of these props are required, so we can't just
|
|
119
|
+
// use Object.keys/.entries
|
|
120
|
+
const props = ["any", "all", "not", "exact"];
|
|
121
|
+
props.forEach((prop) => {
|
|
122
|
+
const key = prop;
|
|
123
|
+
const merged = [...getMatchValue(mo1, key), ...getMatchValue(mo2, key)];
|
|
124
|
+
if (merged.length) {
|
|
125
|
+
// remove any dupes and set on the return
|
|
126
|
+
result[key] = merged.filter(util_1.unique);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
exports.mergeMatchOptions = mergeMatchOptions;
|
|
132
|
+
/**
|
|
133
|
+
* Get the value of a property on an IMatchOptions
|
|
134
|
+
*
|
|
135
|
+
* This is complex b/c all the props are optional, and
|
|
136
|
+
* they could be a simple string, or an array of strings.
|
|
137
|
+
*
|
|
138
|
+
* This function normalizes all that and returns an array,
|
|
139
|
+
* which may or may not be empty
|
|
140
|
+
* @param option
|
|
141
|
+
* @param key
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
function getMatchValue(option, key) {
|
|
145
|
+
let matchValue = [];
|
|
146
|
+
if (option[key]) {
|
|
147
|
+
const val = option[key];
|
|
148
|
+
if (Array.isArray(val)) {
|
|
149
|
+
matchValue = val;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
matchValue = [val];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return matchValue;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @private
|
|
159
|
+
* Convert a field value into a MatchOptions if it's not already one
|
|
160
|
+
* @param value
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
function valueToMatchOptions(value) {
|
|
164
|
+
let result = {};
|
|
165
|
+
if (Array.isArray(value)) {
|
|
166
|
+
result = {
|
|
167
|
+
any: value,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
if (typeof value === "string") {
|
|
172
|
+
result = {
|
|
173
|
+
any: [value],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (typeof value === "object") {
|
|
177
|
+
result = value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
exports.valueToMatchOptions = valueToMatchOptions;
|
|
183
|
+
/**
|
|
184
|
+
* @private
|
|
185
|
+
* Convert a RelativeDate to a DateRange<number>
|
|
186
|
+
* @param relative
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
function relativeDateToDateRange(relative) {
|
|
190
|
+
// hash of offsets
|
|
191
|
+
const offsetMs = {
|
|
192
|
+
min: 1000 * 60,
|
|
193
|
+
hours: 1000 * 60 * 60,
|
|
194
|
+
days: 1000 * 60 * 60 * 24,
|
|
195
|
+
weeks: 1000 * 60 * 60 * 24 * 7,
|
|
196
|
+
};
|
|
197
|
+
const now = new Date();
|
|
198
|
+
// default
|
|
199
|
+
const result = {
|
|
200
|
+
type: "date-range",
|
|
201
|
+
from: now.getTime(),
|
|
202
|
+
to: now.getTime(),
|
|
203
|
+
};
|
|
204
|
+
//
|
|
205
|
+
switch (relative.unit) {
|
|
206
|
+
case "hours":
|
|
207
|
+
case "days":
|
|
208
|
+
case "weeks":
|
|
209
|
+
result.from = result.to - offsetMs[relative.unit] * relative.num;
|
|
210
|
+
break;
|
|
211
|
+
case "months":
|
|
212
|
+
// get the current month and subtract num
|
|
213
|
+
now.setMonth(now.getMonth() - relative.num);
|
|
214
|
+
result.from = now.getTime();
|
|
215
|
+
break;
|
|
216
|
+
case "years":
|
|
217
|
+
now.setFullYear(now.getFullYear() - relative.num);
|
|
218
|
+
result.from = now.getTime();
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
exports.relativeDateToDateRange = relativeDateToDateRange;
|
|
224
|
+
/**
|
|
225
|
+
* @private
|
|
226
|
+
* As a final `ISearchOptions` object gets created, many such objects are created, and
|
|
227
|
+
* need to be systematically "merged" so as to return consistently structured `q` and `filter`
|
|
228
|
+
* values.
|
|
229
|
+
* @param so1
|
|
230
|
+
* @param so2
|
|
231
|
+
* @param join
|
|
232
|
+
* @returns
|
|
233
|
+
*/
|
|
234
|
+
function mergeSearchOptions(so1, so2, join) {
|
|
235
|
+
const result = util_1.cloneObject(so1);
|
|
236
|
+
const { q, filter } = so2;
|
|
237
|
+
if (q) {
|
|
238
|
+
result.q = (result.q ? ` (${result.q} ${join} ${q})` : q).trim();
|
|
239
|
+
}
|
|
240
|
+
if (filter) {
|
|
241
|
+
result.filter = (result.filter ? `(${result.filter} ${join} ${filter})` : filter).trim();
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
exports.mergeSearchOptions = mergeSearchOptions;
|
|
246
|
+
/**
|
|
247
|
+
* @private
|
|
248
|
+
* Serialize a `MatchOptions` into `q` or `filter` on an `ISearchOptions`
|
|
249
|
+
* @param key
|
|
250
|
+
* @param opts
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
253
|
+
function serializeMatchOptions(key, opts) {
|
|
254
|
+
const result = {
|
|
255
|
+
q: "",
|
|
256
|
+
filter: "",
|
|
257
|
+
};
|
|
258
|
+
if (opts.exact) {
|
|
259
|
+
// defined separately for refactoring later
|
|
260
|
+
const userFilterableFields = [
|
|
261
|
+
"username",
|
|
262
|
+
"firstname",
|
|
263
|
+
"lastname",
|
|
264
|
+
"fullname",
|
|
265
|
+
"email",
|
|
266
|
+
];
|
|
267
|
+
const itemFilterableFields = [
|
|
268
|
+
"title",
|
|
269
|
+
"tags",
|
|
270
|
+
"typekeywords",
|
|
271
|
+
"type",
|
|
272
|
+
"name",
|
|
273
|
+
"owner",
|
|
274
|
+
];
|
|
275
|
+
const groupFilterableFields = ["title", "typekeywords", "owner"];
|
|
276
|
+
const filterableFields = [
|
|
277
|
+
...userFilterableFields,
|
|
278
|
+
...itemFilterableFields,
|
|
279
|
+
...groupFilterableFields,
|
|
280
|
+
];
|
|
281
|
+
if (filterableFields.includes(key)) {
|
|
282
|
+
result.filter = serializeStringOrArray("AND", key, opts.exact);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
// Treat it the same as .all
|
|
286
|
+
if (typeof opts.exact === "string") {
|
|
287
|
+
if (!opts.all) {
|
|
288
|
+
opts.all = [];
|
|
289
|
+
}
|
|
290
|
+
if (typeof opts.all === "string") {
|
|
291
|
+
opts.all = [opts.all];
|
|
292
|
+
}
|
|
293
|
+
opts.all.push(opts.exact);
|
|
294
|
+
}
|
|
295
|
+
if (Array.isArray(opts.exact)) {
|
|
296
|
+
if (!opts.all) {
|
|
297
|
+
opts.all = [];
|
|
298
|
+
}
|
|
299
|
+
if (typeof opts.all === "string") {
|
|
300
|
+
opts.all = [opts.all];
|
|
301
|
+
}
|
|
302
|
+
opts.all = opts.all.concat(opts.exact);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// Handle the other props
|
|
307
|
+
if (opts.any) {
|
|
308
|
+
result.q = serializeStringOrArray("OR", key, opts.any);
|
|
309
|
+
}
|
|
310
|
+
if (opts.all) {
|
|
311
|
+
result.q =
|
|
312
|
+
(result.q ? result.q + " AND " : "") +
|
|
313
|
+
serializeStringOrArray("AND", key, opts.all);
|
|
314
|
+
}
|
|
315
|
+
if (opts.not) {
|
|
316
|
+
// negate the entries if they are not
|
|
317
|
+
result.q =
|
|
318
|
+
(result.q ? result.q + " AND " : "") +
|
|
319
|
+
serializeStringOrArray("OR", `-${key}`, opts.not);
|
|
320
|
+
}
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
exports.serializeMatchOptions = serializeMatchOptions;
|
|
324
|
+
/**
|
|
325
|
+
* @private
|
|
326
|
+
* Serialize a DateRange<number> into a Portal Query string
|
|
327
|
+
* @param key
|
|
328
|
+
* @param range
|
|
329
|
+
* @returns
|
|
330
|
+
*/
|
|
331
|
+
function serializeDateRange(key, range) {
|
|
332
|
+
return {
|
|
333
|
+
q: `${key}:[${range.from} TO ${range.to}]`,
|
|
334
|
+
filter: "",
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
exports.serializeDateRange = serializeDateRange;
|
|
338
|
+
/**
|
|
339
|
+
* @private
|
|
340
|
+
* Serialize a `string` or `string[]` into a string
|
|
341
|
+
* @param join
|
|
342
|
+
* @param key
|
|
343
|
+
* @param value
|
|
344
|
+
* @returns
|
|
345
|
+
*/
|
|
346
|
+
function serializeStringOrArray(join, key, value) {
|
|
347
|
+
let q = "";
|
|
348
|
+
if (Array.isArray(value)) {
|
|
349
|
+
q = `(${key}:"${value.join(`" ${join} ${key}:"`)}")`;
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
q = `${key}:"${value}"`;
|
|
353
|
+
}
|
|
354
|
+
return q;
|
|
355
|
+
}
|
|
356
|
+
exports.serializeStringOrArray = serializeStringOrArray;
|
|
357
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/search/utils.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAIhB,kCAA8C;AAY9C;;;GAGG;AACU,QAAA,WAAW,GAAmB;IACzC,MAAM,EAA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AAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpC,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;KACrD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA1ED,sDA0EC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,GAAW,EACX,KAAyB;IAEzB,OAAO;QACL,CAAC,EAAE,GAAG,GAAG,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,GAAG;QAC1C,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC;AARD,gDAQC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,IAAkB,EAClB,GAAW,EACX,KAAwB;IAExB,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,CAAC,GAAG,IAAI,GAAG,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;KACtD;SAAM;QACL,CAAC,GAAG,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;KACzB;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAZD,wDAYC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Filter, IHubSearchOptions, IContentSearchResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Search for content via the Portal or Hub API
|
|
4
|
+
* @param filter
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
export declare function _searchContent(filter: Filter<"content">, options: IHubSearchOptions): Promise<IContentSearchResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IItem, ISearchOptions, ISearchResult } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { IContentFilter, IContentFilterDefinition, Filter, IFacet } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Convert portal search response to items
|
|
6
|
+
* @param response
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function convertPortalResponseToFacets(response: ISearchResult<IItem>): IFacet[];
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
* Merge `Filter<"content">` objects
|
|
13
|
+
* @param filters
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function mergeContentFilter(filters: Array<Filter<"content">>): Filter<"content">;
|
|
17
|
+
/**
|
|
18
|
+
* Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
|
|
19
|
+
*
|
|
20
|
+
* Filter's can express their intent in a very terse form, but to ensure consistent
|
|
21
|
+
* into their more verbose form.
|
|
22
|
+
*
|
|
23
|
+
* i.e. `title: "Water"` expands into `title: { any: ["Water"]}`
|
|
24
|
+
*
|
|
25
|
+
* - "well known" type values are expanded
|
|
26
|
+
* - i.e. `type: "$storymap"` expands into two `subFilter` entries
|
|
27
|
+
* - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
|
|
28
|
+
* - RelativeDate fields are converted to DateRange<number>
|
|
29
|
+
*
|
|
30
|
+
* @param filter
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function expandContentFilter(filter: Filter<"content">): IContentFilter;
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
* Expand from a well-known "type" into it's longer form
|
|
37
|
+
*
|
|
38
|
+
* i.e. `type: "$storymap"` expands into two subFilters entries
|
|
39
|
+
*
|
|
40
|
+
* @param filter
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function expandTypeField(filter: Filter<"content">): Filter<"content">;
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* Convert a `ContentFilterDefinition` to a `ContentFilter`
|
|
47
|
+
*
|
|
48
|
+
* ContentFilter is a narrower version of ContentFilterDefinition, without
|
|
49
|
+
* the union types. Using a ContentFilter makes working with the structure
|
|
50
|
+
* in typescript much easier.
|
|
51
|
+
*
|
|
52
|
+
* @param filter
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function convertContentDefinitionToFilter(filter: IContentFilterDefinition): IContentFilter;
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
* Serialize a `ContentFilter` into an `ISearchOptions` for use with `searchItems`
|
|
59
|
+
* @param filter
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
export declare function serializeContentFilterForPortal(filter: IContentFilter): ISearchOptions;
|
|
63
|
+
/**
|
|
64
|
+
* @private
|
|
65
|
+
* Convert a ContentFilter to a SearchOptions
|
|
66
|
+
*
|
|
67
|
+
* @param filter
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
export declare function convertContentFilterToSearchOptions(filter: IContentFilter): ISearchOptions;
|