@esri/hub-common 12.19.0 → 12.20.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/esm/core/types/DynamicValues.js +1 -0
- package/dist/esm/core/types/DynamicValues.js.map +1 -0
- package/dist/esm/core/types/index.js +1 -0
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/esm/search/_internal/combineQueries.js +25 -0
- package/dist/esm/search/_internal/combineQueries.js.map +1 -0
- package/dist/esm/search/_internal/portalSearchItems.js +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/internal/aggregateValues.js +35 -0
- package/dist/esm/utils/internal/aggregateValues.js.map +1 -0
- package/dist/esm/utils/internal/resolveDynamicValue.js +34 -0
- package/dist/esm/utils/internal/resolveDynamicValue.js.map +1 -0
- package/dist/esm/utils/internal/resolveDynamicValues.js +19 -0
- package/dist/esm/utils/internal/resolveDynamicValues.js.map +1 -0
- package/dist/esm/utils/internal/resolveItemQueryValues.js +73 -0
- package/dist/esm/utils/internal/resolveItemQueryValues.js.map +1 -0
- package/dist/esm/utils/internal/resolvePortalValues.js +24 -0
- package/dist/esm/utils/internal/resolvePortalValues.js.map +1 -0
- package/dist/esm/utils/internal/resolveServiceQueryValues.js +38 -0
- package/dist/esm/utils/internal/resolveServiceQueryValues.js.map +1 -0
- package/dist/esm/utils/memoize.js +38 -0
- package/dist/esm/utils/memoize.js.map +1 -0
- package/dist/node/core/types/DynamicValues.js +3 -0
- package/dist/node/core/types/DynamicValues.js.map +1 -0
- package/dist/node/core/types/index.js +1 -0
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/node/search/_internal/combineQueries.js +28 -0
- package/dist/node/search/_internal/combineQueries.js.map +1 -0
- package/dist/node/search/_internal/portalSearchItems.js +1 -1
- package/dist/node/utils/index.js +1 -0
- package/dist/node/utils/index.js.map +1 -1
- package/dist/node/utils/internal/aggregateValues.js +39 -0
- package/dist/node/utils/internal/aggregateValues.js.map +1 -0
- package/dist/node/utils/internal/resolveDynamicValue.js +38 -0
- package/dist/node/utils/internal/resolveDynamicValue.js.map +1 -0
- package/dist/node/utils/internal/resolveDynamicValues.js +22 -0
- package/dist/node/utils/internal/resolveDynamicValues.js.map +1 -0
- package/dist/node/utils/internal/resolveItemQueryValues.js +77 -0
- package/dist/node/utils/internal/resolveItemQueryValues.js.map +1 -0
- package/dist/node/utils/internal/resolvePortalValues.js +28 -0
- package/dist/node/utils/internal/resolvePortalValues.js.map +1 -0
- package/dist/node/utils/internal/resolveServiceQueryValues.js +41 -0
- package/dist/node/utils/internal/resolveServiceQueryValues.js.map +1 -0
- package/dist/node/utils/memoize.js +41 -0
- package/dist/node/utils/memoize.js.map +1 -0
- package/dist/types/core/types/DynamicValues.d.ts +140 -0
- package/dist/types/core/types/index.d.ts +1 -0
- package/dist/types/search/_internal/combineQueries.d.ts +12 -0
- package/dist/types/search/_internal/portalSearchItems.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/internal/aggregateValues.d.ts +9 -0
- package/dist/types/utils/internal/resolveDynamicValue.d.ts +10 -0
- package/dist/types/utils/internal/resolveDynamicValues.d.ts +11 -0
- package/dist/types/utils/internal/resolveItemQueryValues.d.ts +12 -0
- package/dist/types/utils/internal/resolvePortalValues.d.ts +11 -0
- package/dist/types/utils/internal/resolveServiceQueryValues.d.ts +10 -0
- package/dist/types/utils/memoize.d.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DynamicValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicValues.js","sourceRoot":"","sources":["../../../../src/core/types/DynamicValues.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;A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
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Naieve implementation to merge two queries into one. This
|
|
4
|
+
* simply combines the filters of the two queries. It does not attempt
|
|
5
|
+
* to disabiguate the filters or predicates. It is up to the caller
|
|
6
|
+
* to ensure that the queries are compatible and don't result in a null set
|
|
7
|
+
* of results.
|
|
8
|
+
* @param queries
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export const combineQueries = (queries) => {
|
|
12
|
+
// check tht all queries are for the same entity type
|
|
13
|
+
const targetEntity = queries[0].targetEntity;
|
|
14
|
+
if (queries.some((q) => q.targetEntity !== targetEntity)) {
|
|
15
|
+
throw new Error("Cannot combine queries for different entity types");
|
|
16
|
+
}
|
|
17
|
+
// combine the filters from all the queries
|
|
18
|
+
const filters = queries.reduce((acc, q) => [...acc, ...q.filters], []);
|
|
19
|
+
const result = {
|
|
20
|
+
targetEntity,
|
|
21
|
+
filters,
|
|
22
|
+
};
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=combineQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineQueries.js","sourceRoot":"","sources":["../../../../src/search/_internal/combineQueries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAiB,EAAU,EAAE;IAC1D,qDAAqD;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,EAAE;QACxD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,2CAA2C;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAEvE,MAAM,MAAM,GAAW;QACrB,YAAY;QACZ,OAAO;KACR,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { enrichContentSearchResult } from "../../content";
|
|
|
11
11
|
import { cloneObject } from "../../util";
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
|
-
* Portal Search Implementation for Items
|
|
14
|
+
* Portal Search Implementation for Items returning IHubSearchResults
|
|
15
15
|
* @param query
|
|
16
16
|
* @param options
|
|
17
17
|
* @returns
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Aggregate a set of values based on the aggregation type
|
|
4
|
+
* @param values
|
|
5
|
+
* @param aggregation
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function aggregateValues(values, aggregation) {
|
|
9
|
+
switch (aggregation) {
|
|
10
|
+
case "sum":
|
|
11
|
+
return values.reduce((acc, v) => acc + v, 0);
|
|
12
|
+
case "count":
|
|
13
|
+
return values.length;
|
|
14
|
+
case "avg":
|
|
15
|
+
return values.reduce((acc, v) => acc + v, 0) / values.length;
|
|
16
|
+
case "min":
|
|
17
|
+
return values.reduce((acc, v) => Math.min(acc, v), Number.MAX_VALUE);
|
|
18
|
+
case "max":
|
|
19
|
+
return values.reduce((acc, v) => Math.max(acc, v), Number.MIN_VALUE);
|
|
20
|
+
case "countByValue": // count for each value as a hash {value: string, count: number}
|
|
21
|
+
return values.reduce((acc, v) => {
|
|
22
|
+
if (acc[v]) {
|
|
23
|
+
acc[v] += 1;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
acc[v] = 1;
|
|
27
|
+
}
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
default:
|
|
31
|
+
// console.error(`Unknown aggregation: ${aggregation}`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=aggregateValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/aggregateValues.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAa,EACb,WAA+B;IAE/B,QAAQ,WAAW,EAAE;QACnB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/D,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,KAAK,cAAc,EAAE,gEAAgE;YACnF,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC9B,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;oBACV,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;iBACb;qBAAM;oBACL,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;iBACZ;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACT;YACE,wDAAwD;YACxD,OAAO,IAAI,CAAC;KACf;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getProp } from "../../objects/get-prop";
|
|
2
|
+
import { resolveItemQueryValues } from "./resolveItemQueryValues";
|
|
3
|
+
import { resolvePortalValues } from "./resolvePortalValues";
|
|
4
|
+
import { resolveServiceQueryValues } from "./resolveServiceQueryValues";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Resolve a single dynamic value. The definition can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
8
|
+
* @param valueDef
|
|
9
|
+
* @param context
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export async function resolveDynamicValue(valueDef, context) {
|
|
13
|
+
let result = {};
|
|
14
|
+
switch (valueDef.type) {
|
|
15
|
+
case "static-value":
|
|
16
|
+
const val = getProp(valueDef, "value");
|
|
17
|
+
const outPath = getProp(valueDef, "outPath");
|
|
18
|
+
result[outPath] = val;
|
|
19
|
+
break;
|
|
20
|
+
case "item-query":
|
|
21
|
+
result = await resolveItemQueryValues(valueDef, context);
|
|
22
|
+
break;
|
|
23
|
+
case "portal":
|
|
24
|
+
result = await resolvePortalValues(valueDef, context);
|
|
25
|
+
break;
|
|
26
|
+
case "service-query":
|
|
27
|
+
result = await resolveServiceQueryValues(valueDef, context);
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Cannot resolve value - unexpected source.`);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=resolveDynamicValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDynamicValue.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveDynamicValue.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAgC,EAChC,OAAuB;IAEvB,IAAI,MAAM,GAAwB,EAAE,CAAC;IACrC,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACrB,KAAK,cAAc;YACjB,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACvC,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;YACtB,MAAM;QACR,KAAK,YAAY;YACf,MAAM,GAAG,MAAM,sBAAsB,CACnC,QAAuC,EACvC,OAAO,CACR,CAAC;YACF,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,GAAG,MAAM,mBAAmB,CAChC,QAAwC,EACxC,OAAO,CACR,CAAC;YACF,MAAM;QACR,KAAK,eAAe;YAClB,MAAM,GAAG,MAAM,yBAAyB,CACtC,QAA0C,EAC1C,OAAO,CACR,CAAC;YACF,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolveDynamicValue } from "./resolveDynamicValue";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Resolve a set of dynamic values.
|
|
5
|
+
* The individual definitions can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
6
|
+
* @param dynamicValues Array of dynamic value definitions to resolve
|
|
7
|
+
* @param context ArcGIS context of the current user.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export const resolveDynamicValues = async (dynamicValues, context) => {
|
|
11
|
+
let result = {};
|
|
12
|
+
// iterate over the dynamic values and resolve each one via Promise.all
|
|
13
|
+
// this will allow us to resolve all the values in parallel
|
|
14
|
+
const resolvedValues = await Promise.all(dynamicValues.map((valueDef) => resolveDynamicValue(valueDef, context)));
|
|
15
|
+
// merge the resolved values into a single object
|
|
16
|
+
result = resolvedValues.reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=resolveDynamicValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDynamicValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveDynamicValues.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,aAAuC,EACvC,OAAuB,EACsB,EAAE;IAC/C,IAAI,MAAM,GAAwB,EAAE,CAAC;IAErC,uEAAuE;IACvE,2DAA2D;IAC3D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACtC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CACxE,CAAC;IACF,iDAAiD;IACjD,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,iCAAM,GAAG,GAAK,GAAG,EAAG,EAAE,EAAE,CAAC,CAAC;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { setProp } from "../../objects";
|
|
2
|
+
import { getProp } from "../../objects/get-prop";
|
|
3
|
+
import { combineQueries } from "../../search/_internal/combineQueries";
|
|
4
|
+
import { portalSearchItemsAsItems } from "../../search/_internal/portalSearchItems";
|
|
5
|
+
import { aggregateValues } from "./aggregateValues";
|
|
6
|
+
import { memoize } from "../memoize";
|
|
7
|
+
import { resolveDynamicValue } from "./resolveDynamicValue";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
* Resolve a set of dynamic values based on an item query.
|
|
11
|
+
* This is used to query for a set of items, extract a specific value from each
|
|
12
|
+
* then run an aggregation on the set of values.
|
|
13
|
+
* @param valueDef Item Query Definition that will be resolved by querying for items and extracting a specific value from each
|
|
14
|
+
* @param context ArcGIS context of the current user.
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export async function resolveItemQueryValues(valueDef, context) {
|
|
18
|
+
const result = {};
|
|
19
|
+
// execute the query
|
|
20
|
+
// TODO: Error if neither query or scope are defined
|
|
21
|
+
// Combine the query and scope into a single query;
|
|
22
|
+
// The query and scope have already been dereferenced
|
|
23
|
+
// but since the typing allows for `Reference` we need
|
|
24
|
+
// to use `as IQuery` to TS to chill out.
|
|
25
|
+
const query = valueDef.query || {
|
|
26
|
+
targetEntity: "item",
|
|
27
|
+
filters: [],
|
|
28
|
+
};
|
|
29
|
+
const scope = valueDef.scope || {
|
|
30
|
+
targetEntity: "item",
|
|
31
|
+
filters: [],
|
|
32
|
+
};
|
|
33
|
+
const combined = combineQueries([query, scope]);
|
|
34
|
+
const opts = {
|
|
35
|
+
requestOptions: context.hubRequestOptions,
|
|
36
|
+
};
|
|
37
|
+
// create/get memoized version of portalSearchItemsAsItems
|
|
38
|
+
const memoizedPortalSearch = memoize(portalSearchItemsAsItems);
|
|
39
|
+
// Execute the query
|
|
40
|
+
const response = await memoizedPortalSearch(combined, opts);
|
|
41
|
+
// TODO: dereference metrics so we can delegate one to another
|
|
42
|
+
// This next section is all promise based so that a dynamic value
|
|
43
|
+
// can itself be a dynamic value definition, which then needs to be
|
|
44
|
+
// resolved.
|
|
45
|
+
const promises = await response.results.reduce(async (valsPromise, r) => {
|
|
46
|
+
const vals = await valsPromise;
|
|
47
|
+
const valueFromItem = getProp(r, valueDef.sourcePath);
|
|
48
|
+
// Handle case where value is not found...
|
|
49
|
+
// e.g. the project exists but the metric is not defined yet
|
|
50
|
+
if (valueFromItem) {
|
|
51
|
+
if (typeof valueFromItem === "string" ||
|
|
52
|
+
typeof valueFromItem === "number") {
|
|
53
|
+
vals.push(Promise.resolve(valueFromItem));
|
|
54
|
+
}
|
|
55
|
+
else if (valueFromItem.type === "static-value") {
|
|
56
|
+
vals.push(Promise.resolve(valueFromItem.value));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// valueFromItem is itself a valueDefinition so we call resolveDynamicValues again
|
|
60
|
+
const vResult = await resolveDynamicValue(valueFromItem, context);
|
|
61
|
+
// vals needs just the value - the number or string but vResult is an object
|
|
62
|
+
// so we need to get it out of the object
|
|
63
|
+
vals.push(getProp(vResult, valueFromItem.outPath));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return vals;
|
|
67
|
+
}, Promise.resolve([]));
|
|
68
|
+
const values = await Promise.all(promises);
|
|
69
|
+
const aggretate = aggregateValues(values, valueDef.aggregation);
|
|
70
|
+
setProp(valueDef.outPath, aggretate, result);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=resolveItemQueryValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveItemQueryValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveItemQueryValues.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAIjD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;A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AAC,UAAU,CAAC,CAAC;QACtD,0CAA0C;QAC1C,4DAA4D;QAC5D,IAAI,aAAa,EAAE;YACjB,IACE,OAAO,aAAa,KAAK,QAAQ;gBACjC,OAAO,aAAa,KAAK,QAAQ,EACjC;gBACA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;aAC3C;iBAAM,IAAI,aAAa,CAAC,IAAI,KAAK,cAAc,EAAE;gBAChD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;aACjD;iBAAM;gBACL,kFAAkF;gBAClF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;gBAClE,4EAA4E;gBAC5E,yCAAyC;gBACzC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;aACpD;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EACD,OAAO,CAAC,OAAO,CAAC,EAAW,CAAC,CAC7B,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChE,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getSelf } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { setProp } from "../../objects";
|
|
3
|
+
import { getProp } from "../../objects/get-prop";
|
|
4
|
+
import { memoize } from "../memoize";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Resolve a set of dynamic values by extracting properties
|
|
8
|
+
* from the current user's portal/self
|
|
9
|
+
* @param valueDef Portal Query Definition that wil be resolved using properties from the current user's portal/self
|
|
10
|
+
* @param context ArcGIS context of the current user.
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export async function resolvePortalValues(valueDef, context) {
|
|
14
|
+
const result = {};
|
|
15
|
+
const memoizedPortalSelf = memoize(getSelf);
|
|
16
|
+
// TODO: This could use the context.portal values to skip even a single request
|
|
17
|
+
// get the portalSelf via memoized function
|
|
18
|
+
const portal = await memoizedPortalSelf(context.requestOptions.authentication);
|
|
19
|
+
// get the value from the portal and attach into the result
|
|
20
|
+
const value = getProp(portal, valueDef.sourcePath);
|
|
21
|
+
setProp(valueDef.outPath, value, result);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=resolvePortalValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePortalValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolvePortalValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAsC,EACtC,OAAuB;IAEvB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,+EAA+E;IAC/E,2CAA2C;IAC3C,MAAM,MAAM,GAAG,MAAM,kBAAkB,CACrC,OAAO,CAAC,cAAc,CAAC,cAAc,CACtC,CAAC;IAEF,2DAA2D;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { queryFeatures } from "@esri/arcgis-rest-feature-layer";
|
|
2
|
+
import { setProp } from "../../objects";
|
|
3
|
+
import { getProp } from "../../objects/get-prop";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Resolve a dynamic value that is derived from a service query
|
|
7
|
+
* @param valueDef Service Query Definition that will be resolved by executing an aggregation querying on service and returning that value
|
|
8
|
+
* @param context ArcGIS context of the current user.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export const resolveServiceQueryValues = async (valueDef, context) => {
|
|
12
|
+
// If no where is provided, default to "1=1"
|
|
13
|
+
valueDef.options.where = valueDef.options.where || "1=1";
|
|
14
|
+
// construct the result object
|
|
15
|
+
const result = {};
|
|
16
|
+
// Construct the stats definition
|
|
17
|
+
const statsDef = {
|
|
18
|
+
onStatisticField: valueDef.options.field,
|
|
19
|
+
statisticType: valueDef.options.statisticType,
|
|
20
|
+
outStatisticFieldName: valueDef.options.field,
|
|
21
|
+
};
|
|
22
|
+
// Execute the query
|
|
23
|
+
const response = await queryFeatures({
|
|
24
|
+
url: valueDef.options.url,
|
|
25
|
+
where: valueDef.options.where,
|
|
26
|
+
f: "json",
|
|
27
|
+
outStatistics: [statsDef],
|
|
28
|
+
authentication: context.requestOptions.authentication,
|
|
29
|
+
});
|
|
30
|
+
// Pull the aggreate value out of the response
|
|
31
|
+
const features = getProp(response, "features") || [];
|
|
32
|
+
const firstEntry = features[0] || {};
|
|
33
|
+
const aggregate = getProp(firstEntry, `attributes.${valueDef.options.field}`) || 0;
|
|
34
|
+
// set that on the result
|
|
35
|
+
setProp(valueDef.outPath, aggregate, result);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=resolveServiceQueryValues.js.map
|
|
@@ -0,0 +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,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;IAEnE,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a cache key from an array of arguments
|
|
3
|
+
* @param args
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
const createCacheKeyFromArgs = (args) => args.reduce((cacheKey, arg) => (cacheKey += `_${typeof arg === "object" ? JSON.stringify(args) : `${arg}`}_`), "");
|
|
7
|
+
const memoizedFnCache = {};
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a function into a memoized version of itself. Multiple calls for the same function
|
|
10
|
+
* will return the same memoized function - thus enabling a shared cache of results.
|
|
11
|
+
* `const memoizedItemSearch = memoize(searchItems);`
|
|
12
|
+
* @param fn
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export const memoize = (fn) => {
|
|
16
|
+
if (!memoizedFnCache[fn.name]) {
|
|
17
|
+
const cache = {};
|
|
18
|
+
const memoizedFn = (...args) => {
|
|
19
|
+
const cacheKey = createCacheKeyFromArgs(args);
|
|
20
|
+
if (cache[cacheKey]) {
|
|
21
|
+
return cache[cacheKey];
|
|
22
|
+
}
|
|
23
|
+
const asyncFn = fn.call(undefined, ...args);
|
|
24
|
+
cache[cacheKey] = asyncFn;
|
|
25
|
+
return asyncFn;
|
|
26
|
+
};
|
|
27
|
+
memoizedFnCache[fn.name] = memoizedFn;
|
|
28
|
+
}
|
|
29
|
+
return memoizedFnCache[fn.name];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Clear the cache of a memoized function
|
|
33
|
+
* @param fn
|
|
34
|
+
*/
|
|
35
|
+
export const clearMemoizedCache = (fnName) => {
|
|
36
|
+
delete memoizedFnCache[fnName];
|
|
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,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE;IACnD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicValues.js","sourceRoot":"","sources":["../../../../src/core/types/DynamicValues.ts"],"names":[],"mappings":""}
|
|
@@ -23,4 +23,5 @@ tslib_1.__exportStar(require("./IItemEnrichments"), exports);
|
|
|
23
23
|
tslib_1.__exportStar(require("./IServerEnrichments"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./ISystemStatus"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./types"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./DynamicValues"), exports);
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,0DAAgC;AAChC,wDAA8B;AAC9B,mEAAyC;AACzC,2DAAiC;AACjC,gEAAsC;AACtC,2DAAiC;AACjC,sDAA4B;AAC5B,sDAA4B;AAC5B,2DAAiC;AACjC,2DAAiC;AACjC,uDAA6B;AAC7B,yDAA+B;AAC/B,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,0DAAgC;AAChC,yDAA+B;AAC/B,6DAAmC;AACnC,+DAAqC;AACrC,0DAAgC;AAChC,kDAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,0DAAgC;AAChC,wDAA8B;AAC9B,mEAAyC;AACzC,2DAAiC;AACjC,gEAAsC;AACtC,2DAAiC;AACjC,sDAA4B;AAC5B,sDAA4B;AAC5B,2DAAiC;AACjC,2DAAiC;AACjC,uDAA6B;AAC7B,yDAA+B;AAC/B,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,0DAAgC;AAChC,yDAA+B;AAC/B,6DAAmC;AACnC,+DAAqC;AACrC,0DAAgC;AAChC,kDAAwB;AACxB,0DAAgC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.combineQueries = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Naieve implementation to merge two queries into one. This
|
|
7
|
+
* simply combines the filters of the two queries. It does not attempt
|
|
8
|
+
* to disabiguate the filters or predicates. It is up to the caller
|
|
9
|
+
* to ensure that the queries are compatible and don't result in a null set
|
|
10
|
+
* of results.
|
|
11
|
+
* @param queries
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
exports.combineQueries = (queries) => {
|
|
15
|
+
// check tht all queries are for the same entity type
|
|
16
|
+
const targetEntity = queries[0].targetEntity;
|
|
17
|
+
if (queries.some((q) => q.targetEntity !== targetEntity)) {
|
|
18
|
+
throw new Error("Cannot combine queries for different entity types");
|
|
19
|
+
}
|
|
20
|
+
// combine the filters from all the queries
|
|
21
|
+
const filters = queries.reduce((acc, q) => [...acc, ...q.filters], []);
|
|
22
|
+
const result = {
|
|
23
|
+
targetEntity,
|
|
24
|
+
filters,
|
|
25
|
+
};
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=combineQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineQueries.js","sourceRoot":"","sources":["../../../../src/search/_internal/combineQueries.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;GASG;AAEU,QAAA,cAAc,GAAG,CAAC,OAAiB,EAAU,EAAE;IAC1D,qDAAqD;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,EAAE;QACxD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,2CAA2C;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAEvE,MAAM,MAAM,GAAW;QACrB,YAAY;QACZ,OAAO;KACR,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -14,7 +14,7 @@ const content_1 = require("../../content");
|
|
|
14
14
|
const util_1 = require("../../util");
|
|
15
15
|
/**
|
|
16
16
|
* @internal
|
|
17
|
-
* Portal Search Implementation for Items
|
|
17
|
+
* Portal Search Implementation for Items returning IHubSearchResults
|
|
18
18
|
* @param query
|
|
19
19
|
* @param options
|
|
20
20
|
* @returns
|
package/dist/node/utils/index.js
CHANGED
|
@@ -22,4 +22,5 @@ tslib_1.__exportStar(require("./revertable-tasks"), exports);
|
|
|
22
22
|
tslib_1.__exportStar(require("./sessionLocalStorage"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./dasherize"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./titleize"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./memoize"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,kDAAwB;AACxB,iEAAuC;AACvC,sEAA4C;AAC5C,sDAA4B;AAC5B,mEAAyC;AACzC,4DAAkC;AAClC,kEAAwC;AACxC,qDAA2B;AAC3B,oDAA0B;AAC1B,mDAAyB;AACzB,oDAA0B;AAC1B,4DAAkC;AAClC,2DAAiC;AACjC,6DAAmC;AACnC,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC;AACnC,gEAAsC;AACtC,sDAA4B;AAC5B,qDAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,kDAAwB;AACxB,iEAAuC;AACvC,sEAA4C;AAC5C,sDAA4B;AAC5B,mEAAyC;AACzC,4DAAkC;AAClC,kEAAwC;AACxC,qDAA2B;AAC3B,oDAA0B;AAC1B,mDAAyB;AACzB,oDAA0B;AAC1B,4DAAkC;AAClC,2DAAiC;AACjC,6DAAmC;AACnC,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC;AACnC,gEAAsC;AACtC,sDAA4B;AAC5B,qDAA2B;AAC3B,oDAA0B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aggregateValues = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Aggregate a set of values based on the aggregation type
|
|
7
|
+
* @param values
|
|
8
|
+
* @param aggregation
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function aggregateValues(values, aggregation) {
|
|
12
|
+
switch (aggregation) {
|
|
13
|
+
case "sum":
|
|
14
|
+
return values.reduce((acc, v) => acc + v, 0);
|
|
15
|
+
case "count":
|
|
16
|
+
return values.length;
|
|
17
|
+
case "avg":
|
|
18
|
+
return values.reduce((acc, v) => acc + v, 0) / values.length;
|
|
19
|
+
case "min":
|
|
20
|
+
return values.reduce((acc, v) => Math.min(acc, v), Number.MAX_VALUE);
|
|
21
|
+
case "max":
|
|
22
|
+
return values.reduce((acc, v) => Math.max(acc, v), Number.MIN_VALUE);
|
|
23
|
+
case "countByValue": // count for each value as a hash {value: string, count: number}
|
|
24
|
+
return values.reduce((acc, v) => {
|
|
25
|
+
if (acc[v]) {
|
|
26
|
+
acc[v] += 1;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
acc[v] = 1;
|
|
30
|
+
}
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
default:
|
|
34
|
+
// console.error(`Unknown aggregation: ${aggregation}`);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.aggregateValues = aggregateValues;
|
|
39
|
+
//# sourceMappingURL=aggregateValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/aggregateValues.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,MAAa,EACb,WAA+B;IAE/B,QAAQ,WAAW,EAAE;QACnB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/D,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,KAAK,cAAc,EAAE,gEAAgE;YACnF,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC9B,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;oBACV,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;iBACb;qBAAM;oBACL,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;iBACZ;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACT;YACE,wDAAwD;YACxD,OAAO,IAAI,CAAC;KACf;AACH,CAAC;AA5BD,0CA4BC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDynamicValue = void 0;
|
|
4
|
+
const get_prop_1 = require("../../objects/get-prop");
|
|
5
|
+
const resolveItemQueryValues_1 = require("./resolveItemQueryValues");
|
|
6
|
+
const resolvePortalValues_1 = require("./resolvePortalValues");
|
|
7
|
+
const resolveServiceQueryValues_1 = require("./resolveServiceQueryValues");
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
* Resolve a single dynamic value. The definition can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
11
|
+
* @param valueDef
|
|
12
|
+
* @param context
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
async function resolveDynamicValue(valueDef, context) {
|
|
16
|
+
let result = {};
|
|
17
|
+
switch (valueDef.type) {
|
|
18
|
+
case "static-value":
|
|
19
|
+
const val = get_prop_1.getProp(valueDef, "value");
|
|
20
|
+
const outPath = get_prop_1.getProp(valueDef, "outPath");
|
|
21
|
+
result[outPath] = val;
|
|
22
|
+
break;
|
|
23
|
+
case "item-query":
|
|
24
|
+
result = await resolveItemQueryValues_1.resolveItemQueryValues(valueDef, context);
|
|
25
|
+
break;
|
|
26
|
+
case "portal":
|
|
27
|
+
result = await resolvePortalValues_1.resolvePortalValues(valueDef, context);
|
|
28
|
+
break;
|
|
29
|
+
case "service-query":
|
|
30
|
+
result = await resolveServiceQueryValues_1.resolveServiceQueryValues(valueDef, context);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Cannot resolve value - unexpected source.`);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
exports.resolveDynamicValue = resolveDynamicValue;
|
|
38
|
+
//# sourceMappingURL=resolveDynamicValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDynamicValue.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveDynamicValue.ts"],"names":[],"mappings":";;;AAQA,qDAAiD;AACjD,qEAAkE;AAClE,+DAA4D;AAC5D,2EAAwE;AAExE;;;;;;GAMG;AACI,KAAK,UAAU,mBAAmB,CACvC,QAAgC,EAChC,OAAuB;IAEvB,IAAI,MAAM,GAAwB,EAAE,CAAC;IACrC,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACrB,KAAK,cAAc;YACjB,MAAM,GAAG,GAAG,kBAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACvC,MAAM,OAAO,GAAG,kBAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;YACtB,MAAM;QACR,KAAK,YAAY;YACf,MAAM,GAAG,MAAM,+CAAsB,CACnC,QAAuC,EACvC,OAAO,CACR,CAAC;YACF,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,GAAG,MAAM,yCAAmB,CAChC,QAAwC,EACxC,OAAO,CACR,CAAC;YACF,MAAM;QACR,KAAK,eAAe;YAClB,MAAM,GAAG,MAAM,qDAAyB,CACtC,QAA0C,EAC1C,OAAO,CACR,CAAC;YACF,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,kDAiCC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDynamicValues = void 0;
|
|
4
|
+
const resolveDynamicValue_1 = require("./resolveDynamicValue");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Resolve a set of dynamic values.
|
|
8
|
+
* The individual definitions can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
9
|
+
* @param dynamicValues Array of dynamic value definitions to resolve
|
|
10
|
+
* @param context ArcGIS context of the current user.
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
exports.resolveDynamicValues = async (dynamicValues, context) => {
|
|
14
|
+
let result = {};
|
|
15
|
+
// iterate over the dynamic values and resolve each one via Promise.all
|
|
16
|
+
// this will allow us to resolve all the values in parallel
|
|
17
|
+
const resolvedValues = await Promise.all(dynamicValues.map((valueDef) => resolveDynamicValue_1.resolveDynamicValue(valueDef, context)));
|
|
18
|
+
// merge the resolved values into a single object
|
|
19
|
+
result = resolvedValues.reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=resolveDynamicValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDynamicValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveDynamicValues.ts"],"names":[],"mappings":";;;AAKA,+DAA4D;AAE5D;;;;;;;GAOG;AACU,QAAA,oBAAoB,GAAG,KAAK,EACvC,aAAuC,EACvC,OAAuB,EACsB,EAAE;IAC/C,IAAI,MAAM,GAAwB,EAAE,CAAC;IAErC,uEAAuE;IACvE,2DAA2D;IAC3D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACtC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,yCAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CACxE,CAAC;IACF,iDAAiD;IACjD,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,iCAAM,GAAG,GAAK,GAAG,EAAG,EAAE,EAAE,CAAC,CAAC;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveItemQueryValues = void 0;
|
|
4
|
+
const objects_1 = require("../../objects");
|
|
5
|
+
const get_prop_1 = require("../../objects/get-prop");
|
|
6
|
+
const combineQueries_1 = require("../../search/_internal/combineQueries");
|
|
7
|
+
const portalSearchItems_1 = require("../../search/_internal/portalSearchItems");
|
|
8
|
+
const aggregateValues_1 = require("./aggregateValues");
|
|
9
|
+
const memoize_1 = require("../memoize");
|
|
10
|
+
const resolveDynamicValue_1 = require("./resolveDynamicValue");
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
* Resolve a set of dynamic values based on an item query.
|
|
14
|
+
* This is used to query for a set of items, extract a specific value from each
|
|
15
|
+
* then run an aggregation on the set of values.
|
|
16
|
+
* @param valueDef Item Query Definition that will be resolved by querying for items and extracting a specific value from each
|
|
17
|
+
* @param context ArcGIS context of the current user.
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
async function resolveItemQueryValues(valueDef, context) {
|
|
21
|
+
const result = {};
|
|
22
|
+
// execute the query
|
|
23
|
+
// TODO: Error if neither query or scope are defined
|
|
24
|
+
// Combine the query and scope into a single query;
|
|
25
|
+
// The query and scope have already been dereferenced
|
|
26
|
+
// but since the typing allows for `Reference` we need
|
|
27
|
+
// to use `as IQuery` to TS to chill out.
|
|
28
|
+
const query = valueDef.query || {
|
|
29
|
+
targetEntity: "item",
|
|
30
|
+
filters: [],
|
|
31
|
+
};
|
|
32
|
+
const scope = valueDef.scope || {
|
|
33
|
+
targetEntity: "item",
|
|
34
|
+
filters: [],
|
|
35
|
+
};
|
|
36
|
+
const combined = combineQueries_1.combineQueries([query, scope]);
|
|
37
|
+
const opts = {
|
|
38
|
+
requestOptions: context.hubRequestOptions,
|
|
39
|
+
};
|
|
40
|
+
// create/get memoized version of portalSearchItemsAsItems
|
|
41
|
+
const memoizedPortalSearch = memoize_1.memoize(portalSearchItems_1.portalSearchItemsAsItems);
|
|
42
|
+
// Execute the query
|
|
43
|
+
const response = await memoizedPortalSearch(combined, opts);
|
|
44
|
+
// TODO: dereference metrics so we can delegate one to another
|
|
45
|
+
// This next section is all promise based so that a dynamic value
|
|
46
|
+
// can itself be a dynamic value definition, which then needs to be
|
|
47
|
+
// resolved.
|
|
48
|
+
const promises = await response.results.reduce(async (valsPromise, r) => {
|
|
49
|
+
const vals = await valsPromise;
|
|
50
|
+
const valueFromItem = get_prop_1.getProp(r, valueDef.sourcePath);
|
|
51
|
+
// Handle case where value is not found...
|
|
52
|
+
// e.g. the project exists but the metric is not defined yet
|
|
53
|
+
if (valueFromItem) {
|
|
54
|
+
if (typeof valueFromItem === "string" ||
|
|
55
|
+
typeof valueFromItem === "number") {
|
|
56
|
+
vals.push(Promise.resolve(valueFromItem));
|
|
57
|
+
}
|
|
58
|
+
else if (valueFromItem.type === "static-value") {
|
|
59
|
+
vals.push(Promise.resolve(valueFromItem.value));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// valueFromItem is itself a valueDefinition so we call resolveDynamicValues again
|
|
63
|
+
const vResult = await resolveDynamicValue_1.resolveDynamicValue(valueFromItem, context);
|
|
64
|
+
// vals needs just the value - the number or string but vResult is an object
|
|
65
|
+
// so we need to get it out of the object
|
|
66
|
+
vals.push(get_prop_1.getProp(vResult, valueFromItem.outPath));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return vals;
|
|
70
|
+
}, Promise.resolve([]));
|
|
71
|
+
const values = await Promise.all(promises);
|
|
72
|
+
const aggretate = aggregateValues_1.aggregateValues(values, valueDef.aggregation);
|
|
73
|
+
objects_1.setProp(valueDef.outPath, aggretate, result);
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
exports.resolveItemQueryValues = resolveItemQueryValues;
|
|
77
|
+
//# sourceMappingURL=resolveItemQueryValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveItemQueryValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveItemQueryValues.ts"],"names":[],"mappings":";;;AAKA,2CAAwC;AACxC,qDAAiD;AAIjD,0EAAuE;AACvE,gFAAoF;AACpF,uDAAoD;AACpD,wCAAqC;AACrC,+DAA4D;AAE5D;;;;;;;;GAQG;AACI,KAAK,UAAU,sBAAsB,CAC1C,QAAqC,EACrC,OAAuB;IAEvB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,oBAAoB;IACpB,oDAAoD;IACpD,mDAAmD;IACnD,qDAAqD;IACrD,sDAAsD;IACtD,yCAAyC;IACzC,MAAM,KAAK,GAAI,QAAQ,CAAC,KAAgB,IAAI;QAC1C,YAAY,EAAE,MAAM;QACpB,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,KAAK,GAAI,QAAQ,CAAC,KAAgB,IAAI;QAC1C,YAAY,EAAE,MAAM;QACpB,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,MAAM,QAAQ,GAAG,+BAAc,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAsB;QAC9B,cAAc,EAAE,OAAO,CAAC,iBAAiB;KAC1C,CAAC;IACF,0DAA0D;IAC1D,MAAM,oBAAoB,GAAG,iBAAO,CAAC,4CAAwB,CAAC,CAAC;IAC/D,oBAAoB;IACpB,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE5D,8DAA8D;IAE9D,iEAAiE;IACjE,mEAAmE;IACnE,YAAY;I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|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePortalValues = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const objects_1 = require("../../objects");
|
|
6
|
+
const get_prop_1 = require("../../objects/get-prop");
|
|
7
|
+
const memoize_1 = require("../memoize");
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
* Resolve a set of dynamic values by extracting properties
|
|
11
|
+
* from the current user's portal/self
|
|
12
|
+
* @param valueDef Portal Query Definition that wil be resolved using properties from the current user's portal/self
|
|
13
|
+
* @param context ArcGIS context of the current user.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
async function resolvePortalValues(valueDef, context) {
|
|
17
|
+
const result = {};
|
|
18
|
+
const memoizedPortalSelf = memoize_1.memoize(arcgis_rest_portal_1.getSelf);
|
|
19
|
+
// TODO: This could use the context.portal values to skip even a single request
|
|
20
|
+
// get the portalSelf via memoized function
|
|
21
|
+
const portal = await memoizedPortalSelf(context.requestOptions.authentication);
|
|
22
|
+
// get the value from the portal and attach into the result
|
|
23
|
+
const value = get_prop_1.getProp(portal, valueDef.sourcePath);
|
|
24
|
+
objects_1.setProp(valueDef.outPath, value, result);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
exports.resolvePortalValues = resolvePortalValues;
|
|
28
|
+
//# sourceMappingURL=resolvePortalValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePortalValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolvePortalValues.ts"],"names":[],"mappings":";;;AAAA,iEAAmD;AAMnD,2CAAwC;AACxC,qDAAiD;AACjD,wCAAqC;AAErC;;;;;;;GAOG;AACI,KAAK,UAAU,mBAAmB,CACvC,QAAsC,EACtC,OAAuB;IAEvB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,kBAAkB,GAAG,iBAAO,CAAC,4BAAO,CAAC,CAAC;IAC5C,+EAA+E;IAC/E,2CAA2C;IAC3C,MAAM,MAAM,GAAG,MAAM,kBAAkB,CACrC,OAAO,CAAC,cAAc,CAAC,cAAc,CACtC,CAAC;IAEF,2DAA2D;IAC3D,MAAM,KAAK,GAAG,kBAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IACnD,iBAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC;AAjBD,kDAiBC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveServiceQueryValues = void 0;
|
|
4
|
+
const arcgis_rest_feature_layer_1 = require("@esri/arcgis-rest-feature-layer");
|
|
5
|
+
const objects_1 = require("../../objects");
|
|
6
|
+
const get_prop_1 = require("../../objects/get-prop");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Resolve a dynamic value that is derived from a service query
|
|
10
|
+
* @param valueDef Service Query Definition that will be resolved by executing an aggregation querying on service and returning that value
|
|
11
|
+
* @param context ArcGIS context of the current user.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
exports.resolveServiceQueryValues = async (valueDef, context) => {
|
|
15
|
+
// If no where is provided, default to "1=1"
|
|
16
|
+
valueDef.options.where = valueDef.options.where || "1=1";
|
|
17
|
+
// construct the result object
|
|
18
|
+
const result = {};
|
|
19
|
+
// Construct the stats definition
|
|
20
|
+
const statsDef = {
|
|
21
|
+
onStatisticField: valueDef.options.field,
|
|
22
|
+
statisticType: valueDef.options.statisticType,
|
|
23
|
+
outStatisticFieldName: valueDef.options.field,
|
|
24
|
+
};
|
|
25
|
+
// Execute the query
|
|
26
|
+
const response = await arcgis_rest_feature_layer_1.queryFeatures({
|
|
27
|
+
url: valueDef.options.url,
|
|
28
|
+
where: valueDef.options.where,
|
|
29
|
+
f: "json",
|
|
30
|
+
outStatistics: [statsDef],
|
|
31
|
+
authentication: context.requestOptions.authentication,
|
|
32
|
+
});
|
|
33
|
+
// Pull the aggreate value out of the response
|
|
34
|
+
const features = get_prop_1.getProp(response, "features") || [];
|
|
35
|
+
const firstEntry = features[0] || {};
|
|
36
|
+
const aggregate = get_prop_1.getProp(firstEntry, `attributes.${valueDef.options.field}`) || 0;
|
|
37
|
+
// set that on the result
|
|
38
|
+
objects_1.setProp(valueDef.outPath, aggregate, result);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=resolveServiceQueryValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveServiceQueryValues.js","sourceRoot":"","sources":["../../../../src/utils/internal/resolveServiceQueryValues.ts"],"names":[],"mappings":";;;AAAA,+EAAgE;AAOhE,2CAAwC;AACxC,qDAAiD;AAEjD;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,KAAK,EAC5C,QAAwC,EACxC,OAAuB,EACC,EAAE;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACzD,8BAA8B;IAC9B,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,iCAAiC;IACjC,MAAM,QAAQ,GAAyB;QACrC,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK;QACxC,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa;QAC7C,qBAAqB,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK;KAC9C,CAAC;IACF,oBAAoB;IACpB,MAAM,QAAQ,GAAG,MAAM,yCAAa,CAAC;QACnC,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAa;QACnC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAe;QACvC,CAAC,EAAE,MAAM;QACT,aAAa,EAAE,CAAC,QAAQ,CAAC;QACzB,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,cAAc;KACtD,CAAC,CAAC;IAEH,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,kBAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;IACrD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,SAAS,GACb,kBAAO,CAAC,UAAU,EAAE,cAAc,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;IAEnE,yBAAyB;IACzB,iBAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearMemoizedCache = exports.memoize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Create a cache key from an array of arguments
|
|
6
|
+
* @param args
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
const createCacheKeyFromArgs = (args) => args.reduce((cacheKey, arg) => (cacheKey += `_${typeof arg === "object" ? JSON.stringify(args) : `${arg}`}_`), "");
|
|
10
|
+
const memoizedFnCache = {};
|
|
11
|
+
/**
|
|
12
|
+
* Wrap a function into a memoized version of itself. Multiple calls for the same function
|
|
13
|
+
* will return the same memoized function - thus enabling a shared cache of results.
|
|
14
|
+
* `const memoizedItemSearch = memoize(searchItems);`
|
|
15
|
+
* @param fn
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
exports.memoize = (fn) => {
|
|
19
|
+
if (!memoizedFnCache[fn.name]) {
|
|
20
|
+
const cache = {};
|
|
21
|
+
const memoizedFn = (...args) => {
|
|
22
|
+
const cacheKey = createCacheKeyFromArgs(args);
|
|
23
|
+
if (cache[cacheKey]) {
|
|
24
|
+
return cache[cacheKey];
|
|
25
|
+
}
|
|
26
|
+
const asyncFn = fn.call(undefined, ...args);
|
|
27
|
+
cache[cacheKey] = asyncFn;
|
|
28
|
+
return asyncFn;
|
|
29
|
+
};
|
|
30
|
+
memoizedFnCache[fn.name] = memoizedFn;
|
|
31
|
+
}
|
|
32
|
+
return memoizedFnCache[fn.name];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Clear the cache of a memoized function
|
|
36
|
+
* @param fn
|
|
37
|
+
*/
|
|
38
|
+
exports.clearMemoizedCache = (fnName) => {
|
|
39
|
+
delete memoizedFnCache[fnName];
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=memoize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../../src/utils/memoize.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,CAAC,IAAW,EAAE,EAAE,CAC7C,IAAI,CAAC,MAAM,CACT,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAChB,CAAC,QAAQ,IAAI,IACX,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EACzD,GAAG,CAAC,EACN,EAAE,CACH,CAAC;AAEJ,MAAM,eAAe,GAAwB,EAAE,CAAC;AAChD;;;;;;GAMG;AACU,QAAA,OAAO,GAAG,CACrB,EAA0B,EAC1B,EAAE;IACF,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAU,EAAE,EAAE;YACnC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAE9C,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;gBACnB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;aACxB;YAED,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;YAC5C,KAAK,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;YAC1B,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QACF,eAAe,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;KACvC;IACD,OAAO,eAAe,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE;IACnD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { IQuery } from "../../search/types/IHubCatalog";
|
|
2
|
+
import { IConfigurationSchema } from "../schemas";
|
|
3
|
+
/**
|
|
4
|
+
* The source for a dynamic value. Used to determine how to resolve the value
|
|
5
|
+
*/
|
|
6
|
+
export declare type DynamicValueType = "static-value" | "item-query" | "service-query" | "portal";
|
|
7
|
+
/**
|
|
8
|
+
* Options used to defined a feature service query
|
|
9
|
+
*/
|
|
10
|
+
export interface IServiceQueryOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The url of the feature service, including the layer
|
|
13
|
+
*/
|
|
14
|
+
url: string;
|
|
15
|
+
/**
|
|
16
|
+
* Field on which to run an aggregation
|
|
17
|
+
*/
|
|
18
|
+
field: string;
|
|
19
|
+
/**
|
|
20
|
+
* The type of server-side aggregation to run
|
|
21
|
+
*/
|
|
22
|
+
statisticType: ServiceAggregation;
|
|
23
|
+
/**
|
|
24
|
+
* Where clause to apply to the query. Defaults to "1=1" if not provided
|
|
25
|
+
*/
|
|
26
|
+
where?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Aggregations that can be done on a service
|
|
30
|
+
*/
|
|
31
|
+
export declare type ServiceAggregation = "count" | "sum" | "min" | "max" | "avg";
|
|
32
|
+
/**
|
|
33
|
+
* Aggregations that can be applied to a set of dynamic values
|
|
34
|
+
*/
|
|
35
|
+
export declare type DynamicAggregation = ServiceAggregation | "countByValue";
|
|
36
|
+
/**
|
|
37
|
+
* Properties shared by all DynamicValueDefinitions
|
|
38
|
+
*/
|
|
39
|
+
interface IBaseValueDefinition {
|
|
40
|
+
type: DynamicValueType;
|
|
41
|
+
/**
|
|
42
|
+
* The property path used to connect the resolved value to the parent object
|
|
43
|
+
*/
|
|
44
|
+
outPath: string;
|
|
45
|
+
/**
|
|
46
|
+
* JSON schema used to validate the value. If not provided, the value will not be validated
|
|
47
|
+
* NOTE: This may be swapped for a smaller set of props that would be used to generate the schema
|
|
48
|
+
*/
|
|
49
|
+
schema?: Partial<IConfigurationSchema>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Definition for a static value that is not resolved via a query.
|
|
53
|
+
* Enables workflows where the dynamic value source is not yet configured, or the value is known ahead of time
|
|
54
|
+
*/
|
|
55
|
+
export interface IStaticValueDefinition extends IBaseValueDefinition {
|
|
56
|
+
type: "static-value";
|
|
57
|
+
/**
|
|
58
|
+
* Enables a static value to be provided vs forcing a dynamic value
|
|
59
|
+
*/
|
|
60
|
+
value: string | number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Definition for a dynamic value that is resolved from the portal/self
|
|
64
|
+
*/
|
|
65
|
+
export interface IDynamicPortalSelfDefinition extends IBaseValueDefinition {
|
|
66
|
+
type: "portal";
|
|
67
|
+
/**
|
|
68
|
+
* The path to the property on the portal/self response to return
|
|
69
|
+
*/
|
|
70
|
+
sourcePath: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Interface for a reference to another value in the same object graph.
|
|
74
|
+
* Can be used with `getProp(obj, ref.$use)` to get the value of the referenced property
|
|
75
|
+
*/
|
|
76
|
+
export interface IReference {
|
|
77
|
+
$use: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Definition for a dynamic value that is resolved from an item query to the portal
|
|
81
|
+
*/
|
|
82
|
+
export interface IDynamicItemQueryDefinition extends IBaseValueDefinition {
|
|
83
|
+
type: "item-query";
|
|
84
|
+
/**
|
|
85
|
+
* The path to the property on the item to return
|
|
86
|
+
*/
|
|
87
|
+
sourcePath: string;
|
|
88
|
+
/**
|
|
89
|
+
* Portal Query to be exectute to return the set of items
|
|
90
|
+
*/
|
|
91
|
+
query?: IQuery | IReference;
|
|
92
|
+
/**
|
|
93
|
+
* The type of aggregation to apply to the set of results
|
|
94
|
+
*/
|
|
95
|
+
aggregation: DynamicAggregation;
|
|
96
|
+
scope?: IQuery | IReference;
|
|
97
|
+
/**
|
|
98
|
+
* Indicates if the raw values should be returned
|
|
99
|
+
*/
|
|
100
|
+
includeRawValues?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Definition for a dynamic value that is resolved from a feature service query
|
|
104
|
+
*/
|
|
105
|
+
export interface IDynamicServiceQueryDefinition extends IBaseValueDefinition {
|
|
106
|
+
type: "service-query";
|
|
107
|
+
/**
|
|
108
|
+
* Options used for the service query
|
|
109
|
+
*/
|
|
110
|
+
options: IServiceQueryOptions;
|
|
111
|
+
/**
|
|
112
|
+
* The type of aggregation to apply to the set of results
|
|
113
|
+
*/
|
|
114
|
+
aggregation: DynamicAggregation;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Union of all the dynamic value definitions
|
|
118
|
+
*/
|
|
119
|
+
export declare type DynamicValueDefinition = IStaticValueDefinition | IDynamicPortalSelfDefinition | IDynamicItemQueryDefinition | IDynamicServiceQueryDefinition;
|
|
120
|
+
/**
|
|
121
|
+
* Type to hold a count-by-value result
|
|
122
|
+
* ```js
|
|
123
|
+
* { "value1": 2, "value2": 1}
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare type CountByValue = Record<string, number>;
|
|
127
|
+
/**
|
|
128
|
+
* A dynamic value can be a string, number, or another definition
|
|
129
|
+
* which will be recursively resolved.
|
|
130
|
+
*/
|
|
131
|
+
export declare type DynamicValue = string | number | DynamicValueDefinition;
|
|
132
|
+
/**
|
|
133
|
+
* The output of the resolution of a dynamic value
|
|
134
|
+
*/
|
|
135
|
+
export declare type DynamicValueResult = string | number | CountByValue;
|
|
136
|
+
/**
|
|
137
|
+
* A set of dynamic values, keyed by the outPath
|
|
138
|
+
*/
|
|
139
|
+
export declare type DynamicValues = Record<string, DynamicValue>;
|
|
140
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IQuery } from "../types/IHubCatalog";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Naieve implementation to merge two queries into one. This
|
|
5
|
+
* simply combines the filters of the two queries. It does not attempt
|
|
6
|
+
* to disabiguate the filters or predicates. It is up to the caller
|
|
7
|
+
* to ensure that the queries are compatible and don't result in a null set
|
|
8
|
+
* of results.
|
|
9
|
+
* @param queries
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const combineQueries: (queries: IQuery[]) => IQuery;
|
|
@@ -3,7 +3,7 @@ import { IHubRequestOptions } from "../../types";
|
|
|
3
3
|
import { IHubSearchOptions, IHubSearchResponse, IHubSearchResult, IMatchOptions, IPredicate, IQuery } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
|
-
* Portal Search Implementation for Items
|
|
6
|
+
* Portal Search Implementation for Items returning IHubSearchResults
|
|
7
7
|
* @param query
|
|
8
8
|
* @param options
|
|
9
9
|
* @returns
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicAggregation } from "../../core/types/DynamicValues";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Aggregate a set of values based on the aggregation type
|
|
5
|
+
* @param values
|
|
6
|
+
* @param aggregation
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function aggregateValues(values: any[], aggregation: DynamicAggregation): any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../ArcGISContext";
|
|
2
|
+
import { DynamicValueDefinition, DynamicValueResult } from "../../core/types/DynamicValues";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Resolve a single dynamic value. The definition can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
6
|
+
* @param valueDef
|
|
7
|
+
* @param context
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveDynamicValue(valueDef: DynamicValueDefinition, context: IArcGISContext): Promise<Record<string, DynamicValueResult>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../ArcGISContext";
|
|
2
|
+
import { DynamicValueDefinition, DynamicValueResult } from "../../core/types/DynamicValues";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Resolve a set of dynamic values.
|
|
6
|
+
* The individual definitions can be of many types (item-query, portal etc), each of which has their own logic for resolving the value.
|
|
7
|
+
* @param dynamicValues Array of dynamic value definitions to resolve
|
|
8
|
+
* @param context ArcGIS context of the current user.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolveDynamicValues: (dynamicValues: DynamicValueDefinition[], context: IArcGISContext) => Promise<Record<string, DynamicValueResult>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../ArcGISContext";
|
|
2
|
+
import { DynamicValues, IDynamicItemQueryDefinition } from "../../core/types/DynamicValues";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Resolve a set of dynamic values based on an item query.
|
|
6
|
+
* This is used to query for a set of items, extract a specific value from each
|
|
7
|
+
* then run an aggregation on the set of values.
|
|
8
|
+
* @param valueDef Item Query Definition that will be resolved by querying for items and extracting a specific value from each
|
|
9
|
+
* @param context ArcGIS context of the current user.
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveItemQueryValues(valueDef: IDynamicItemQueryDefinition, context: IArcGISContext): Promise<DynamicValues>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../ArcGISContext";
|
|
2
|
+
import { DynamicValues, IDynamicPortalSelfDefinition } from "../../core/types/DynamicValues";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Resolve a set of dynamic values by extracting properties
|
|
6
|
+
* from the current user's portal/self
|
|
7
|
+
* @param valueDef Portal Query Definition that wil be resolved using properties from the current user's portal/self
|
|
8
|
+
* @param context ArcGIS context of the current user.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolvePortalValues(valueDef: IDynamicPortalSelfDefinition, context: IArcGISContext): Promise<DynamicValues>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../ArcGISContext";
|
|
2
|
+
import { DynamicValues, IDynamicServiceQueryDefinition } from "../../core/types/DynamicValues";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Resolve a dynamic value that is derived from a service query
|
|
6
|
+
* @param valueDef Service Query Definition that will be resolved by executing an aggregation querying on service and returning that value
|
|
7
|
+
* @param context ArcGIS context of the current user.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveServiceQueryValues: (valueDef: IDynamicServiceQueryDefinition, context: IArcGISContext) => Promise<DynamicValues>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a function into a memoized version of itself. Multiple calls for the same function
|
|
3
|
+
* will return the same memoized function - thus enabling a shared cache of results.
|
|
4
|
+
* `const memoizedItemSearch = memoize(searchItems);`
|
|
5
|
+
* @param fn
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const memoize: <ARGS extends unknown[], RET>(fn: (...args: ARGS) => RET) => any;
|
|
9
|
+
/**
|
|
10
|
+
* Clear the cache of a memoized function
|
|
11
|
+
* @param fn
|
|
12
|
+
*/
|
|
13
|
+
export declare const clearMemoizedCache: (fnName: string) => void;
|