@esri/hub-common 14.30.1 → 14.31.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/sites/feed-configuration.js +85 -0
- package/dist/esm/sites/feed-configuration.js.map +1 -0
- package/dist/esm/sites/index.js +1 -0
- package/dist/esm/sites/index.js.map +1 -1
- package/dist/esm/utils/poll.js +19 -6
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/node/sites/feed-configuration.js +90 -0
- package/dist/node/sites/feed-configuration.js.map +1 -0
- package/dist/node/sites/index.js +1 -0
- package/dist/node/sites/index.js.map +1 -1
- package/dist/node/utils/poll.js +19 -6
- package/dist/node/utils/poll.js.map +1 -1
- package/dist/types/sites/feed-configuration.d.ts +20 -0
- package/dist/types/sites/index.d.ts +1 -0
- package/dist/types/utils/poll.d.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns feed configuration from a site model
|
|
3
|
+
*
|
|
4
|
+
* @param {IModel} site - site model
|
|
5
|
+
* @param {FeedFormat} format - feed format
|
|
6
|
+
* @param {string} version - semantic version
|
|
7
|
+
*/
|
|
8
|
+
export function getFeedConfiguration(site, format, version) {
|
|
9
|
+
if (format === "dcat-us") {
|
|
10
|
+
return getDcatUsConfig(site, version);
|
|
11
|
+
}
|
|
12
|
+
if (format === "dcat-ap") {
|
|
13
|
+
return getDcatApConfig(site, version);
|
|
14
|
+
}
|
|
15
|
+
if (format === "rss") {
|
|
16
|
+
return getRssConfig(site, version);
|
|
17
|
+
}
|
|
18
|
+
throw new Error("Unsupported feed format");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns feed configuration from a site model
|
|
22
|
+
*
|
|
23
|
+
* @param {IModel} site - site model
|
|
24
|
+
* @param {FeedFormat} format - feed format
|
|
25
|
+
* @param {string} version - semantic version
|
|
26
|
+
* @param {Record<string, any>} feedConfig - feed configuration
|
|
27
|
+
*/
|
|
28
|
+
export function setFeedConfiguration(site, format, version, feedConfig) {
|
|
29
|
+
if (format === "dcat-us") {
|
|
30
|
+
setDcatUsConfig(site, version, feedConfig);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (format === "dcat-ap") {
|
|
34
|
+
setDcatApConfig(site, version, feedConfig);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (format === "rss") {
|
|
38
|
+
setRssConfig(site, version, feedConfig);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("Unsupported feed format");
|
|
42
|
+
}
|
|
43
|
+
function getDcatApConfig(site, version) {
|
|
44
|
+
if (getMajorVersion(version) === "2") {
|
|
45
|
+
return site.data.feeds.dcatAP2XX || site.data.feeds.dcatAP201;
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Unsupported DCAT AP version");
|
|
48
|
+
}
|
|
49
|
+
function getDcatUsConfig(site, version) {
|
|
50
|
+
if (getMajorVersion(version) === "1") {
|
|
51
|
+
return site.data.feeds.dcatUS1X || site.data.feeds.dcatUS11;
|
|
52
|
+
}
|
|
53
|
+
throw new Error("Unsupported DCAT US version");
|
|
54
|
+
}
|
|
55
|
+
function getRssConfig(site, version) {
|
|
56
|
+
if (getMajorVersion(version) === "2") {
|
|
57
|
+
return site.data.feeds.rss2;
|
|
58
|
+
}
|
|
59
|
+
throw new Error("Unsupported RSS version");
|
|
60
|
+
}
|
|
61
|
+
function setDcatApConfig(site, version, config) {
|
|
62
|
+
if (getMajorVersion(version) === "2") {
|
|
63
|
+
site.data.feeds.dcatAP2XX = config;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Unsupported DCAT AP Version");
|
|
67
|
+
}
|
|
68
|
+
function setDcatUsConfig(site, version, config) {
|
|
69
|
+
if (getMajorVersion(version) === "1") {
|
|
70
|
+
site.data.feeds.dcatUS1X = config;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
throw new Error("Unsupported DCAT US Version");
|
|
74
|
+
}
|
|
75
|
+
function setRssConfig(site, version, config) {
|
|
76
|
+
if (getMajorVersion(version) === "2") {
|
|
77
|
+
site.data.feeds.rss2 = config;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
throw new Error("Unsupported RSS Version");
|
|
81
|
+
}
|
|
82
|
+
function getMajorVersion(version) {
|
|
83
|
+
return version.split(".")[0];
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=feed-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed-configuration.js","sourceRoot":"","sources":["../../../src/sites/feed-configuration.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,MAAkB,EAClB,OAAe;IAEf,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACvC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACvC;IAED,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACpC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,MAAkB,EAClB,OAAe,EACf,UAA+B;IAE/B,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3C,OAAO;KACR;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3C,OAAO;KACR;IAED,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,YAAY,CAAC,IAAI,EA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,GAAG,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;QAClC,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,YAAY,CACnB,IAAY,EACZ,OAAe,EACf,MAA2B;IAE3B,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;QAC9B,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/esm/sites/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./HubSites";
|
|
|
10
10
|
export * from "./site-schema-version";
|
|
11
11
|
export * from "./themes";
|
|
12
12
|
export * from "./upgrade-site-schema";
|
|
13
|
+
export * from "./feed-configuration";
|
|
13
14
|
// No longer exported b/c site app registration is now handled
|
|
14
15
|
// by the domain service due to requirement to send signed HMAC request
|
|
15
16
|
// export * from "./registerSiteAsApplication";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,8DAA8D;AAC9D,uEAAuE;AACvE,+CAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,8DAA8D;AAC9D,uEAAuE;AACvE,+CAA+C"}
|
package/dist/esm/utils/poll.js
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Function to poll a provided request until a validation
|
|
3
3
|
* state or timeout is reached
|
|
4
|
+
*
|
|
5
|
+
* NOTE: we expose this as a public util, but should use this
|
|
6
|
+
* functionality sparingly when dealing with the Portal API.
|
|
7
|
+
* Best practice is to leverage this polling functionality
|
|
8
|
+
* internally on functions that we know incur a Portal delay.
|
|
9
|
+
*
|
|
4
10
|
* @param requestFn
|
|
5
11
|
* @param validationFn
|
|
6
12
|
* @param opts
|
|
7
13
|
*/
|
|
8
14
|
export const poll = async (requestFn, validationFn, opts) => {
|
|
9
|
-
const options = opts || /* istanbul ignore next - must pass in overrides for tests */ {};
|
|
10
|
-
const timeout = options.timeout
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const options = opts || /* istanbul ignore next - we must pass in overrides for tests */ {};
|
|
16
|
+
const timeout = isNaN(options.timeout) ? 30000 : options.timeout;
|
|
17
|
+
/* istanbul ignore next - should not cover the 3000 case in tests */
|
|
18
|
+
const timeBetweenRequests = isNaN(options.timeBetweenRequests)
|
|
19
|
+
? 3000
|
|
20
|
+
: options.timeBetweenRequests;
|
|
13
21
|
let resp;
|
|
14
22
|
let requestCount = 0;
|
|
23
|
+
let timeElapsed = 0;
|
|
15
24
|
do {
|
|
16
25
|
// On subsequent requests, check if the timeout has been reached
|
|
17
26
|
// If YES: throw an error
|
|
18
27
|
// If NO: delay before the next request
|
|
19
28
|
if (requestCount > 0) {
|
|
20
|
-
|
|
29
|
+
timeElapsed += requestCount * timeBetweenRequests;
|
|
30
|
+
if (timeElapsed >= timeout) {
|
|
21
31
|
throw new Error("Polling timeout");
|
|
22
32
|
}
|
|
23
|
-
|
|
33
|
+
// NOTE: we incrementally increase the time between requests
|
|
34
|
+
// so as not to hammer an API with subsequent calls.
|
|
35
|
+
// This was specifically requested by the Portal API team
|
|
36
|
+
await delay(requestCount * timeBetweenRequests);
|
|
24
37
|
}
|
|
25
38
|
resp = await requestFn();
|
|
26
39
|
requestCount++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../src/utils/poll.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../src/utils/poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,SAAoB,EACpB,YAAoC,EACpC,IAGC,EACa,EAAE;IAChB,MAAM,OAAO,GACX,IAAI,IAAI,gEAAgE,CAAC,EAAE,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACjE,oEAAoE;IACpE,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC5D,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;IAEhC,IAAI,IAAS,CAAC;IACd,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,GAAG;QACD,gEAAgE;QAChE,yBAAyB;QACzB,uCAAuC;QACvC,IAAI,YAAY,GAAG,CAAC,EAAE;YACpB,WAAW,IAAI,YAAY,GAAG,mBAAmB,CAAC;YAClD,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;aACpC;YAED,4DAA4D;YAC5D,oDAAoD;YACpD,yDAAyD;YACzD,MAAM,KAAK,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;SACjD;QAED,IAAI,GAAG,MAAM,SAAS,EAAE,CAAC;QACzB,YAAY,EAAE,CAAC;KAChB,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE9B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,YAAoB,EAAE,EAAE;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setFeedConfiguration = exports.getFeedConfiguration = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns feed configuration from a site model
|
|
6
|
+
*
|
|
7
|
+
* @param {IModel} site - site model
|
|
8
|
+
* @param {FeedFormat} format - feed format
|
|
9
|
+
* @param {string} version - semantic version
|
|
10
|
+
*/
|
|
11
|
+
function getFeedConfiguration(site, format, version) {
|
|
12
|
+
if (format === "dcat-us") {
|
|
13
|
+
return getDcatUsConfig(site, version);
|
|
14
|
+
}
|
|
15
|
+
if (format === "dcat-ap") {
|
|
16
|
+
return getDcatApConfig(site, version);
|
|
17
|
+
}
|
|
18
|
+
if (format === "rss") {
|
|
19
|
+
return getRssConfig(site, version);
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Unsupported feed format");
|
|
22
|
+
}
|
|
23
|
+
exports.getFeedConfiguration = getFeedConfiguration;
|
|
24
|
+
/**
|
|
25
|
+
* Returns feed configuration from a site model
|
|
26
|
+
*
|
|
27
|
+
* @param {IModel} site - site model
|
|
28
|
+
* @param {FeedFormat} format - feed format
|
|
29
|
+
* @param {string} version - semantic version
|
|
30
|
+
* @param {Record<string, any>} feedConfig - feed configuration
|
|
31
|
+
*/
|
|
32
|
+
function setFeedConfiguration(site, format, version, feedConfig) {
|
|
33
|
+
if (format === "dcat-us") {
|
|
34
|
+
setDcatUsConfig(site, version, feedConfig);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (format === "dcat-ap") {
|
|
38
|
+
setDcatApConfig(site, version, feedConfig);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (format === "rss") {
|
|
42
|
+
setRssConfig(site, version, feedConfig);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
throw new Error("Unsupported feed format");
|
|
46
|
+
}
|
|
47
|
+
exports.setFeedConfiguration = setFeedConfiguration;
|
|
48
|
+
function getDcatApConfig(site, version) {
|
|
49
|
+
if (getMajorVersion(version) === "2") {
|
|
50
|
+
return site.data.feeds.dcatAP2XX || site.data.feeds.dcatAP201;
|
|
51
|
+
}
|
|
52
|
+
throw new Error("Unsupported DCAT AP version");
|
|
53
|
+
}
|
|
54
|
+
function getDcatUsConfig(site, version) {
|
|
55
|
+
if (getMajorVersion(version) === "1") {
|
|
56
|
+
return site.data.feeds.dcatUS1X || site.data.feeds.dcatUS11;
|
|
57
|
+
}
|
|
58
|
+
throw new Error("Unsupported DCAT US version");
|
|
59
|
+
}
|
|
60
|
+
function getRssConfig(site, version) {
|
|
61
|
+
if (getMajorVersion(version) === "2") {
|
|
62
|
+
return site.data.feeds.rss2;
|
|
63
|
+
}
|
|
64
|
+
throw new Error("Unsupported RSS version");
|
|
65
|
+
}
|
|
66
|
+
function setDcatApConfig(site, version, config) {
|
|
67
|
+
if (getMajorVersion(version) === "2") {
|
|
68
|
+
site.data.feeds.dcatAP2XX = config;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
throw new Error("Unsupported DCAT AP Version");
|
|
72
|
+
}
|
|
73
|
+
function setDcatUsConfig(site, version, config) {
|
|
74
|
+
if (getMajorVersion(version) === "1") {
|
|
75
|
+
site.data.feeds.dcatUS1X = config;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Unsupported DCAT US Version");
|
|
79
|
+
}
|
|
80
|
+
function setRssConfig(site, version, config) {
|
|
81
|
+
if (getMajorVersion(version) === "2") {
|
|
82
|
+
site.data.feeds.rss2 = config;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Unsupported RSS Version");
|
|
86
|
+
}
|
|
87
|
+
function getMajorVersion(version) {
|
|
88
|
+
return version.split(".")[0];
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=feed-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed-configuration.js","sourceRoot":"","sources":["../../../src/sites/feed-configuration.ts"],"names":[],"mappings":";;;AAIA;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,IAAY,EACZ,MAAkB,EAClB,OAAe;IAEf,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACvC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACvC;IAED,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACpC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAlBD,oDAkBC;AAED;;;;;;;GAOG;AACH,SA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,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CACtB,IAAY,EACZ,OAAe,EACf,MAA2B;IAE3B,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;QACnC,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,eAAe,CACtB,IAAY,EACZ,OAAe,EACf,MAA2B;IAE3B,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;QAClC,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,YAAY,CACnB,IAAY,EACZ,OAAe,EACf,MAA2B;IAE3B,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;QAC9B,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/node/sites/index.js
CHANGED
|
@@ -13,6 +13,7 @@ tslib_1.__exportStar(require("./HubSites"), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require("./site-schema-version"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./themes"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./upgrade-site-schema"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./feed-configuration"), exports);
|
|
16
17
|
// No longer exported b/c site app registration is now handled
|
|
17
18
|
// by the domain service due to requirement to send signed HMAC request
|
|
18
19
|
// export * from "./registerSiteAsApplication";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,2EAAiD;AACjD,uFAA6D;AAC7D,oDAA0B;AAC1B,mDAAyB;AACzB,2DAAiC;AACjC,2DAAiC;AACjC,oDAA0B;AAC1B,qDAA2B;AAC3B,gEAAsC;AACtC,mDAAyB;AACzB,gEAAsC;AACtC,8DAA8D;AAC9D,uEAAuE;AACvE,+CAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,2EAAiD;AACjD,uFAA6D;AAC7D,oDAA0B;AAC1B,mDAAyB;AACzB,2DAAiC;AACjC,2DAAiC;AACjC,oDAA0B;AAC1B,qDAA2B;AAC3B,gEAAsC;AACtC,mDAAyB;AACzB,gEAAsC;AACtC,+DAAqC;AACrC,8DAA8D;AAC9D,uEAAuE;AACvE,+CAA+C"}
|
package/dist/node/utils/poll.js
CHANGED
|
@@ -4,26 +4,39 @@ exports.poll = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Function to poll a provided request until a validation
|
|
6
6
|
* state or timeout is reached
|
|
7
|
+
*
|
|
8
|
+
* NOTE: we expose this as a public util, but should use this
|
|
9
|
+
* functionality sparingly when dealing with the Portal API.
|
|
10
|
+
* Best practice is to leverage this polling functionality
|
|
11
|
+
* internally on functions that we know incur a Portal delay.
|
|
12
|
+
*
|
|
7
13
|
* @param requestFn
|
|
8
14
|
* @param validationFn
|
|
9
15
|
* @param opts
|
|
10
16
|
*/
|
|
11
17
|
exports.poll = async (requestFn, validationFn, opts) => {
|
|
12
|
-
const options = opts || /* istanbul ignore next - must pass in overrides for tests */ {};
|
|
13
|
-
const timeout = options.timeout
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const options = opts || /* istanbul ignore next - we must pass in overrides for tests */ {};
|
|
19
|
+
const timeout = isNaN(options.timeout) ? 30000 : options.timeout;
|
|
20
|
+
/* istanbul ignore next - should not cover the 3000 case in tests */
|
|
21
|
+
const timeBetweenRequests = isNaN(options.timeBetweenRequests)
|
|
22
|
+
? 3000
|
|
23
|
+
: options.timeBetweenRequests;
|
|
16
24
|
let resp;
|
|
17
25
|
let requestCount = 0;
|
|
26
|
+
let timeElapsed = 0;
|
|
18
27
|
do {
|
|
19
28
|
// On subsequent requests, check if the timeout has been reached
|
|
20
29
|
// If YES: throw an error
|
|
21
30
|
// If NO: delay before the next request
|
|
22
31
|
if (requestCount > 0) {
|
|
23
|
-
|
|
32
|
+
timeElapsed += requestCount * timeBetweenRequests;
|
|
33
|
+
if (timeElapsed >= timeout) {
|
|
24
34
|
throw new Error("Polling timeout");
|
|
25
35
|
}
|
|
26
|
-
|
|
36
|
+
// NOTE: we incrementally increase the time between requests
|
|
37
|
+
// so as not to hammer an API with subsequent calls.
|
|
38
|
+
// This was specifically requested by the Portal API team
|
|
39
|
+
await delay(requestCount * timeBetweenRequests);
|
|
27
40
|
}
|
|
28
41
|
resp = await requestFn();
|
|
29
42
|
requestCount++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../src/utils/poll.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../src/utils/poll.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACU,QAAA,IAAI,GAAG,KAAK,EACvB,SAAoB,EACpB,YAAoC,EACpC,IAGC,EACa,EAAE;IAChB,MAAM,OAAO,GACX,IAAI,IAAI,gEAAgE,CAAC,EAAE,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACjE,oEAAoE;IACpE,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC5D,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;IAEhC,IAAI,IAAS,CAAC;IACd,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,GAAG;QACD,gEAAgE;QAChE,yBAAyB;QACzB,uCAAuC;QACvC,IAAI,YAAY,GAAG,CAAC,EAAE;YACpB,WAAW,IAAI,YAAY,GAAG,mBAAmB,CAAC;YAClD,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;aACpC;YAED,4DAA4D;YAC5D,oDAAoD;YACpD,yDAAyD;YACzD,MAAM,KAAK,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;SACjD;QAED,IAAI,GAAG,MAAM,SAAS,EAAE,CAAC;QACzB,YAAY,EAAE,CAAC;KAChB,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;IAE9B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,YAAoB,EAAE,EAAE;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IModel } from "../types";
|
|
2
|
+
declare type FeedFormat = "dcat-us" | "dcat-ap" | "rss";
|
|
3
|
+
/**
|
|
4
|
+
* Returns feed configuration from a site model
|
|
5
|
+
*
|
|
6
|
+
* @param {IModel} site - site model
|
|
7
|
+
* @param {FeedFormat} format - feed format
|
|
8
|
+
* @param {string} version - semantic version
|
|
9
|
+
*/
|
|
10
|
+
export declare function getFeedConfiguration(site: IModel, format: FeedFormat, version: string): any;
|
|
11
|
+
/**
|
|
12
|
+
* Returns feed configuration from a site model
|
|
13
|
+
*
|
|
14
|
+
* @param {IModel} site - site model
|
|
15
|
+
* @param {FeedFormat} format - feed format
|
|
16
|
+
* @param {string} version - semantic version
|
|
17
|
+
* @param {Record<string, any>} feedConfig - feed configuration
|
|
18
|
+
*/
|
|
19
|
+
export declare function setFeedConfiguration(site: IModel, format: FeedFormat, version: string, feedConfig: Record<string, any>): void;
|
|
20
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Function to poll a provided request until a validation
|
|
3
3
|
* state or timeout is reached
|
|
4
|
+
*
|
|
5
|
+
* NOTE: we expose this as a public util, but should use this
|
|
6
|
+
* functionality sparingly when dealing with the Portal API.
|
|
7
|
+
* Best practice is to leverage this polling functionality
|
|
8
|
+
* internally on functions that we know incur a Portal delay.
|
|
9
|
+
*
|
|
4
10
|
* @param requestFn
|
|
5
11
|
* @param validationFn
|
|
6
12
|
* @param opts
|