@esri/hub-common 14.60.1 → 14.61.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/index.js +1 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/processActionLinks.js +62 -0
- package/dist/esm/core/processActionLinks.js.map +1 -0
- package/dist/node/core/index.js +1 -0
- package/dist/node/core/index.js.map +1 -1
- package/dist/node/core/processActionLinks.js +67 -0
- package/dist/node/core/processActionLinks.js.map +1 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/processActionLinks.d.ts +30 -0
- package/package.json +1 -1
package/dist/esm/core/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./fetchHubEntity";
|
|
|
6
6
|
export * from "./getTypeFromEntity";
|
|
7
7
|
export * from "./getRelativeWorkspaceUrl";
|
|
8
8
|
export * from "./isValidEntityType";
|
|
9
|
+
export * from "./processActionLinks";
|
|
9
10
|
// For sme reason, if updateHubEntity is exported here,
|
|
10
11
|
// it is not actually exported in the final package.
|
|
11
12
|
// export * from "./updateHubEntity";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAErC,uDAAuD;AACvD,oDAAoD;AACpD,qCAAqC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { hubSearch } from "../search";
|
|
2
|
+
/**
|
|
3
|
+
* Given an array of IHubActionLinks, the following util will
|
|
4
|
+
* "pre-process" the action links. This includes:
|
|
5
|
+
*
|
|
6
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
7
|
+
* its site relative href, and transforming the link into an
|
|
8
|
+
* external action link that can be consumed in the UI
|
|
9
|
+
*
|
|
10
|
+
* Note: we can add other pre-processing as necessary
|
|
11
|
+
*
|
|
12
|
+
* @param links hub action links
|
|
13
|
+
* @param requestOptions hub request options
|
|
14
|
+
*/
|
|
15
|
+
export async function processActionLinks(links, requestOptions) {
|
|
16
|
+
const processedActionLinks = await Promise.all(links.map(async (link) => {
|
|
17
|
+
return processActionLink(link, requestOptions);
|
|
18
|
+
}));
|
|
19
|
+
return processedActionLinks;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Given a single IHubActionLink, the following util will
|
|
23
|
+
* "pre-process" the action link. This includes:
|
|
24
|
+
*
|
|
25
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
26
|
+
* its site relative href, and transforming the link into an
|
|
27
|
+
* external action link that can be consumed in the UI
|
|
28
|
+
*
|
|
29
|
+
* Note: we can add other pre-processing as necessary
|
|
30
|
+
*
|
|
31
|
+
* @param link hub action link
|
|
32
|
+
* @param requestOptions hub request options
|
|
33
|
+
*/
|
|
34
|
+
export async function processActionLink(link, requestOptions) {
|
|
35
|
+
// recursively process nested links
|
|
36
|
+
if (link.kind === "section") {
|
|
37
|
+
link.children = await processActionLinks(link.children, requestOptions);
|
|
38
|
+
}
|
|
39
|
+
if (link.kind === "content") {
|
|
40
|
+
try {
|
|
41
|
+
// 1. query for the content item so we can grab its
|
|
42
|
+
// siteRelative href
|
|
43
|
+
const query = {
|
|
44
|
+
targetEntity: "item",
|
|
45
|
+
filters: [{ predicates: [{ id: link.contentId }] }],
|
|
46
|
+
};
|
|
47
|
+
const { results } = await hubSearch(query, { requestOptions });
|
|
48
|
+
// 2. construct a new "external" action link
|
|
49
|
+
// with the content item's site relative href
|
|
50
|
+
delete link.contentId;
|
|
51
|
+
const processedLink = Object.assign(Object.assign({}, link), { kind: "external", href: results[0].links.siteRelative });
|
|
52
|
+
return processedLink;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new Error(`Unable to fetch entity: ${link.contentId}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return link;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=processActionLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processActionLinks.js","sourceRoot":"","sources":["../../../src/core/processActionLinks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,WAAW,CAAC;AAQ9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAsB,EACtB,cAAkC;IAElC,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5C,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAmB,EAAE,EAAE;QACtC,OAAO,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAmB,EACnB,cAAkC;IAElC,mCAAmC;IACnC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACzE;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI;YACF,mDAAmD;YACnD,oBAAoB;YACpB,MAAM,KAAK,GAAW;gBACpB,YAAY,EAAE,MAAM;gBACpB,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;aACpD,CAAC;YACF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;YAE/D,4CAA4C;YAC5C,6CAA6C;YAC7C,OAAO,IAAI,CAAC,SAAS,CAAC;YACtB,MAAM,aAAa,mCACd,IAAI,KACP,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,GACpC,CAAC;YAEF,OAAO,aAAa,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;SAC9D;KACF;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
|
package/dist/node/core/index.js
CHANGED
|
@@ -9,6 +9,7 @@ tslib_1.__exportStar(require("./fetchHubEntity"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./getTypeFromEntity"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./getRelativeWorkspaceUrl"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./isValidEntityType"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./processActionLinks"), exports);
|
|
12
13
|
// For sme reason, if updateHubEntity is exported here,
|
|
13
14
|
// it is not actually exported in the final package.
|
|
14
15
|
// export * from "./updateHubEntity";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB;AACxB,sDAA4B;AAC5B,oDAA0B;AAC1B,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,8DAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB;AACxB,sDAA4B;AAC5B,oDAA0B;AAC1B,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,8DAAoC;AACpC,+DAAqC;AAErC,uDAAuD;AACvD,oDAAoD;AACpD,qCAAqC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processActionLink = exports.processActionLinks = void 0;
|
|
4
|
+
const search_1 = require("../search");
|
|
5
|
+
/**
|
|
6
|
+
* Given an array of IHubActionLinks, the following util will
|
|
7
|
+
* "pre-process" the action links. This includes:
|
|
8
|
+
*
|
|
9
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
10
|
+
* its site relative href, and transforming the link into an
|
|
11
|
+
* external action link that can be consumed in the UI
|
|
12
|
+
*
|
|
13
|
+
* Note: we can add other pre-processing as necessary
|
|
14
|
+
*
|
|
15
|
+
* @param links hub action links
|
|
16
|
+
* @param requestOptions hub request options
|
|
17
|
+
*/
|
|
18
|
+
async function processActionLinks(links, requestOptions) {
|
|
19
|
+
const processedActionLinks = await Promise.all(links.map(async (link) => {
|
|
20
|
+
return processActionLink(link, requestOptions);
|
|
21
|
+
}));
|
|
22
|
+
return processedActionLinks;
|
|
23
|
+
}
|
|
24
|
+
exports.processActionLinks = processActionLinks;
|
|
25
|
+
/**
|
|
26
|
+
* Given a single IHubActionLink, the following util will
|
|
27
|
+
* "pre-process" the action link. This includes:
|
|
28
|
+
*
|
|
29
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
30
|
+
* its site relative href, and transforming the link into an
|
|
31
|
+
* external action link that can be consumed in the UI
|
|
32
|
+
*
|
|
33
|
+
* Note: we can add other pre-processing as necessary
|
|
34
|
+
*
|
|
35
|
+
* @param link hub action link
|
|
36
|
+
* @param requestOptions hub request options
|
|
37
|
+
*/
|
|
38
|
+
async function processActionLink(link, requestOptions) {
|
|
39
|
+
// recursively process nested links
|
|
40
|
+
if (link.kind === "section") {
|
|
41
|
+
link.children = await processActionLinks(link.children, requestOptions);
|
|
42
|
+
}
|
|
43
|
+
if (link.kind === "content") {
|
|
44
|
+
try {
|
|
45
|
+
// 1. query for the content item so we can grab its
|
|
46
|
+
// siteRelative href
|
|
47
|
+
const query = {
|
|
48
|
+
targetEntity: "item",
|
|
49
|
+
filters: [{ predicates: [{ id: link.contentId }] }],
|
|
50
|
+
};
|
|
51
|
+
const { results } = await search_1.hubSearch(query, { requestOptions });
|
|
52
|
+
// 2. construct a new "external" action link
|
|
53
|
+
// with the content item's site relative href
|
|
54
|
+
delete link.contentId;
|
|
55
|
+
const processedLink = Object.assign(Object.assign({}, link), { kind: "external", href: results[0].links.siteRelative });
|
|
56
|
+
return processedLink;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Unable to fetch entity: ${link.contentId}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return link;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.processActionLink = processActionLink;
|
|
67
|
+
//# sourceMappingURL=processActionLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processActionLinks.js","sourceRoot":"","sources":["../../../src/core/processActionLinks.ts"],"names":[],"mappings":";;;AAAA,sCAA8C;AAQ9C;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,kBAAkB,CACtC,KAAsB,EACtB,cAAkC;IAElC,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5C,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAmB,EAAE,EAAE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from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Given an array of IHubActionLinks, the following util will
|
|
5
|
+
* "pre-process" the action links. This includes:
|
|
6
|
+
*
|
|
7
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
8
|
+
* its site relative href, and transforming the link into an
|
|
9
|
+
* external action link that can be consumed in the UI
|
|
10
|
+
*
|
|
11
|
+
* Note: we can add other pre-processing as necessary
|
|
12
|
+
*
|
|
13
|
+
* @param links hub action links
|
|
14
|
+
* @param requestOptions hub request options
|
|
15
|
+
*/
|
|
16
|
+
export declare function processActionLinks(links: HubActionLink[], requestOptions: IHubRequestOptions): Promise<Array<Exclude<HubActionLink, IHubContentActionLink>>>;
|
|
17
|
+
/**
|
|
18
|
+
* Given a single IHubActionLink, the following util will
|
|
19
|
+
* "pre-process" the action link. This includes:
|
|
20
|
+
*
|
|
21
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
22
|
+
* its site relative href, and transforming the link into an
|
|
23
|
+
* external action link that can be consumed in the UI
|
|
24
|
+
*
|
|
25
|
+
* Note: we can add other pre-processing as necessary
|
|
26
|
+
*
|
|
27
|
+
* @param link hub action link
|
|
28
|
+
* @param requestOptions hub request options
|
|
29
|
+
*/
|
|
30
|
+
export declare function processActionLink(link: HubActionLink, requestOptions: IHubRequestOptions): Promise<Exclude<HubActionLink, IHubContentActionLink>>;
|