@esri/hub-common 14.178.0 → 14.180.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/content/HubContent.js +5 -0
- package/dist/esm/content/HubContent.js.map +1 -1
- package/dist/esm/content/_internal/ContentSchema.js +5 -0
- package/dist/esm/content/_internal/ContentSchema.js.map +1 -1
- package/dist/esm/content/_internal/ContentUiSchemaSettings.js +5 -23
- package/dist/esm/content/_internal/ContentUiSchemaSettings.js.map +1 -1
- package/dist/esm/content/_internal/computeProps.js +1 -0
- package/dist/esm/content/_internal/computeProps.js.map +1 -1
- package/dist/esm/content/_internal/getDownloadsSection.js +135 -0
- package/dist/esm/content/_internal/getDownloadsSection.js.map +1 -0
- package/dist/esm/content/_internal/shouldShowDownloadsConfiguration.js +23 -0
- package/dist/esm/content/_internal/shouldShowDownloadsConfiguration.js.map +1 -0
- package/dist/esm/content/edit.js +40 -3
- package/dist/esm/content/edit.js.map +1 -1
- package/dist/esm/downloads/_internal/additional-resources/utils.js +23 -0
- package/dist/esm/downloads/_internal/additional-resources/utils.js.map +1 -0
- package/dist/esm/downloads/_internal/getDownloadConfigurationDisplayFormats.js +75 -0
- package/dist/esm/downloads/_internal/getDownloadConfigurationDisplayFormats.js.map +1 -0
- package/dist/esm/downloads/_internal/getDownloadFlow.js +26 -0
- package/dist/esm/downloads/_internal/getDownloadFlow.js.map +1 -0
- package/dist/esm/downloads/_internal/getDownloadFormatsByFlow.js +28 -0
- package/dist/esm/downloads/_internal/getDownloadFormatsByFlow.js.map +1 -0
- package/dist/esm/downloads/fetchDownloadFile.js +20 -0
- package/dist/esm/downloads/fetchDownloadFile.js.map +1 -1
- package/dist/esm/downloads/fetchDownloadFormats.js +4 -0
- package/dist/esm/downloads/fetchDownloadFormats.js.map +1 -1
- package/dist/esm/downloads/getDownloadConfiguration.js +52 -0
- package/dist/esm/downloads/getDownloadConfiguration.js.map +1 -0
- package/dist/esm/downloads/getDownloadFormats.js +59 -0
- package/dist/esm/downloads/getDownloadFormats.js.map +1 -0
- package/dist/esm/downloads/index.js +2 -0
- package/dist/esm/downloads/index.js.map +1 -1
- package/dist/node/content/HubContent.js +5 -0
- package/dist/node/content/HubContent.js.map +1 -1
- package/dist/node/content/_internal/ContentSchema.js +5 -0
- package/dist/node/content/_internal/ContentSchema.js.map +1 -1
- package/dist/node/content/_internal/ContentUiSchemaSettings.js +5 -23
- package/dist/node/content/_internal/ContentUiSchemaSettings.js.map +1 -1
- package/dist/node/content/_internal/computeProps.js +1 -0
- package/dist/node/content/_internal/computeProps.js.map +1 -1
- package/dist/node/content/_internal/getDownloadsSection.js +139 -0
- package/dist/node/content/_internal/getDownloadsSection.js.map +1 -0
- package/dist/node/content/_internal/shouldShowDownloadsConfiguration.js +27 -0
- package/dist/node/content/_internal/shouldShowDownloadsConfiguration.js.map +1 -0
- package/dist/node/content/edit.js +39 -2
- package/dist/node/content/edit.js.map +1 -1
- package/dist/node/downloads/_internal/additional-resources/utils.js +28 -0
- package/dist/node/downloads/_internal/additional-resources/utils.js.map +1 -0
- package/dist/node/downloads/_internal/getDownloadConfigurationDisplayFormats.js +79 -0
- package/dist/node/downloads/_internal/getDownloadConfigurationDisplayFormats.js.map +1 -0
- package/dist/node/downloads/_internal/getDownloadFlow.js +30 -0
- package/dist/node/downloads/_internal/getDownloadFlow.js.map +1 -0
- package/dist/node/downloads/_internal/getDownloadFormatsByFlow.js +32 -0
- package/dist/node/downloads/_internal/getDownloadFormatsByFlow.js.map +1 -0
- package/dist/node/downloads/fetchDownloadFile.js +20 -0
- package/dist/node/downloads/fetchDownloadFile.js.map +1 -1
- package/dist/node/downloads/fetchDownloadFormats.js +4 -0
- package/dist/node/downloads/fetchDownloadFormats.js.map +1 -1
- package/dist/node/downloads/getDownloadConfiguration.js +56 -0
- package/dist/node/downloads/getDownloadConfiguration.js.map +1 -0
- package/dist/node/downloads/getDownloadFormats.js +63 -0
- package/dist/node/downloads/getDownloadFormats.js.map +1 -0
- package/dist/node/downloads/index.js +2 -0
- package/dist/node/downloads/index.js.map +1 -1
- package/dist/types/content/_internal/getDownloadsSection.d.ts +13 -0
- package/dist/types/content/_internal/shouldShowDownloadsConfiguration.d.ts +13 -0
- package/dist/types/core/types/IHubCardViewModel.d.ts +1 -0
- package/dist/types/core/types/IHubEditableContent.d.ts +57 -1
- package/dist/types/downloads/_internal/additional-resources/utils.d.ts +19 -0
- package/dist/types/downloads/_internal/getDownloadConfigurationDisplayFormats.d.ts +10 -0
- package/dist/types/downloads/_internal/getDownloadFlow.d.ts +11 -0
- package/dist/types/downloads/_internal/getDownloadFormatsByFlow.d.ts +11 -0
- package/dist/types/downloads/fetchDownloadFormats.d.ts +2 -0
- package/dist/types/downloads/getDownloadConfiguration.d.ts +11 -0
- package/dist/types/downloads/getDownloadFormats.d.ts +9 -0
- package/dist/types/downloads/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadConfigurationDisplayFormats = void 0;
|
|
4
|
+
const content_1 = require("../../content");
|
|
5
|
+
const get_prop_1 = require("../../objects/get-prop");
|
|
6
|
+
const getDownloadConfiguration_1 = require("../getDownloadConfiguration");
|
|
7
|
+
const getCreateReplicaFormats_1 = require("./format-fetchers/getCreateReplicaFormats");
|
|
8
|
+
const getPagingJobFormats_1 = require("./format-fetchers/getPagingJobFormats");
|
|
9
|
+
const utils_1 = require("./additional-resources/utils");
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
* Returns configuration objects for each download format that should be displayed
|
|
13
|
+
* in the editing experience of a content entity. This function should not be used
|
|
14
|
+
* to calculate the download formats that should be present on the live UI.
|
|
15
|
+
* @param entity entity to get download format configurations for
|
|
16
|
+
* @returns download format configurations to display
|
|
17
|
+
*/
|
|
18
|
+
function getDownloadConfigurationDisplayFormats(entity) {
|
|
19
|
+
const configuration = getDownloadConfiguration_1.getDownloadConfiguration(entity);
|
|
20
|
+
const flowType = configuration.flowType;
|
|
21
|
+
let formats = configuration.formats;
|
|
22
|
+
// For feature or map services that don't meet the criteria to be downloaded (i.e., no flowType)
|
|
23
|
+
// Product wants to show paging formats as a preview of what _could_ be downloaded should
|
|
24
|
+
// the criteria be met.
|
|
25
|
+
if (!flowType && ["Feature Service", "Map Service"].includes(entity.type)) {
|
|
26
|
+
const pagingFormats = getPagingJobFormats_1.getPagingJobFormats().map((f) => {
|
|
27
|
+
return {
|
|
28
|
+
key: f.format,
|
|
29
|
+
hidden: false,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
// TODO: Should we just show paging formats as a preview or include additional resources?
|
|
33
|
+
formats = pagingFormats;
|
|
34
|
+
}
|
|
35
|
+
// For main entities of a hosted feature service with extract disabled, we want to display
|
|
36
|
+
// the list of createReplica formats as a preview of what _could_ be downloaded should
|
|
37
|
+
// the extract capability be enabled
|
|
38
|
+
if (content_1.isHostedFeatureServiceMainEntity(entity) &&
|
|
39
|
+
flowType !== "createReplica") {
|
|
40
|
+
const createReplicaFormats = getCreateReplicaFormats_1.getCreateReplicaFormats(entity).map((f) => {
|
|
41
|
+
return {
|
|
42
|
+
key: f.format,
|
|
43
|
+
hidden: false,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
formats = createReplicaFormats;
|
|
47
|
+
}
|
|
48
|
+
const additionalResources = get_prop_1.getProp(entity, "extendedProps.additionalResources") || [];
|
|
49
|
+
return formats.map((f) => utils_1.isAdditionalResourceConfiguration(f)
|
|
50
|
+
? toAdditionalResourceConfigurationDisplay(f, additionalResources)
|
|
51
|
+
: toDownloadFormatConfigurationDisplay(f));
|
|
52
|
+
}
|
|
53
|
+
exports.getDownloadConfigurationDisplayFormats = getDownloadConfigurationDisplayFormats;
|
|
54
|
+
// Converts a download format configuration storage object to a display object
|
|
55
|
+
// (i.e., adds appropriate labels, etc.)
|
|
56
|
+
function toDownloadFormatConfigurationDisplay(config) {
|
|
57
|
+
return Object.assign({ label: `{{shared.fields.download.format.${config.key}:translate}}` }, config);
|
|
58
|
+
}
|
|
59
|
+
// Converts an additional resource configuration storage object to a display object
|
|
60
|
+
// (i.e., adds appropriate labels, etc.)
|
|
61
|
+
function toAdditionalResourceConfigurationDisplay(config, additionalResources) {
|
|
62
|
+
const resourceIndex = utils_1.getAdditionalResourceIndex(config);
|
|
63
|
+
const { name, isDataSource } = additionalResources[resourceIndex];
|
|
64
|
+
let label;
|
|
65
|
+
// Prefer the name of the additional resource if it exists
|
|
66
|
+
if (name) {
|
|
67
|
+
label = `{{shared.fields.download.additionalResource|resourceName=${encodeURIComponent(name)}:translate}}`;
|
|
68
|
+
// If the additional resource is the data source...
|
|
69
|
+
}
|
|
70
|
+
else if (isDataSource) {
|
|
71
|
+
label = "{{shared.fields.download.dataSourceResource:translate}}";
|
|
72
|
+
// If the additional resource has no name...
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
label = "{{shared.fields.download.noTitleResource:translate}}";
|
|
76
|
+
}
|
|
77
|
+
return Object.assign({ label }, config);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=getDownloadConfigurationDisplayFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadConfigurationDisplayFormats.js","sourceRoot":"","sources":["../../../../src/downloads/_internal/getDownloadConfigurationDisplayFormats.ts"],"names":[],"mappings":";;;AAAA,2CAAiE;AAOjE,qDAAiD;AACjD,0EAAuE;AACvE,uFAAoF;AAEpF,+EAA4E;AAC5E,wDAGsC;AAEtC;;;;;;;GAOG;AACH,SAAgB,sCAAsC,CACpD,MAA2B;IAE3B,MAAM,aAAa,GAAG,mDAAwB,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;IACxC,IAAI,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;IAEpC,gGAAgG;IAChG,yFAAyF;IAC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wC,CAC/C,MAAoC,EACpC,mBAA6C;IAE7C,MAAM,aAAa,GAAG,kCAA0B,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAElE,IAAI,KAAK,CAAC;IACV,0DAA0D;IAC1D,IAAI,IAAI,EAAE;QACR,KAAK,GAAG,4DAA4D,kBAAkB,CACpF,IAAI,CACL,cAAc,CAAC;QAChB,mDAAmD;KACpD;SAAM,IAAI,YAAY,EAAE;QACvB,KAAK,GAAG,yDAAyD,CAAC;QAClE,4CAA4C;KAC7C;SAAM;QACL,KAAK,GAAG,sDAAsD,CAAC;KAChE;IAED,uBACE,KAAK,IACF,MAAM,EACT;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadFlow = void 0;
|
|
4
|
+
const canUseCreateReplica_1 = require("../canUseCreateReplica");
|
|
5
|
+
const canUseHubDownloadSystem_1 = require("../canUseHubDownloadSystem");
|
|
6
|
+
const canUseExportImageFlow_1 = require("./canUseExportImageFlow");
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
* Determines the download flow that will be used for the current entity.
|
|
10
|
+
* If the entity cannot be downloaded, returns null.
|
|
11
|
+
*
|
|
12
|
+
* @param entity the entity to get the download flow for
|
|
13
|
+
* @param isEnterprise whether the the download will be executed in an enterprise environment
|
|
14
|
+
* @returns the download flow that will be used for the current entity
|
|
15
|
+
*/
|
|
16
|
+
function getDownloadFlow(entity, isEnterprise) {
|
|
17
|
+
let downloadFlow = null;
|
|
18
|
+
if (canUseCreateReplica_1.canUseCreateReplica(entity)) {
|
|
19
|
+
downloadFlow = "createReplica";
|
|
20
|
+
}
|
|
21
|
+
else if (canUseHubDownloadSystem_1.canUseHubDownloadSystem(entity) && !isEnterprise) {
|
|
22
|
+
downloadFlow = "paging";
|
|
23
|
+
}
|
|
24
|
+
else if (canUseExportImageFlow_1.canUseExportImageFlow(entity)) {
|
|
25
|
+
downloadFlow = "exportImage";
|
|
26
|
+
}
|
|
27
|
+
return downloadFlow;
|
|
28
|
+
}
|
|
29
|
+
exports.getDownloadFlow = getDownloadFlow;
|
|
30
|
+
//# sourceMappingURL=getDownloadFlow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadFlow.js","sourceRoot":"","sources":["../../../../src/downloads/_internal/getDownloadFlow.ts"],"names":[],"mappings":";;;AACA,gEAA6D;AAC7D,wEAAqE;AACrE,mEAAgE;AAEhE;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,MAA2B,EAC3B,YAAsB;IAEtB,IAAI,YAAY,GAAqB,IAAI,CAAC;IAC1C,IAAI,yCAAmB,CAAC,MAAM,CAAC,EAAE;QAC/B,YAAY,GAAG,eAAe,CAAC;KAChC;SAAM,IAAI,iDAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE;QAC3D,YAAY,GAAG,QAAQ,CAAC;KACzB;SAAM,IAAI,6CAAqB,CAAC,MAAM,CAAC,EAAE;QACxC,YAAY,GAAG,aAAa,CAAC;KAC9B;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAbD,0CAaC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadFormatsByFlow = void 0;
|
|
4
|
+
const getCreateReplicaFormats_1 = require("./format-fetchers/getCreateReplicaFormats");
|
|
5
|
+
const getExportImageFormats_1 = require("./format-fetchers/getExportImageFormats");
|
|
6
|
+
const getPagingJobFormats_1 = require("./format-fetchers/getPagingJobFormats");
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
* Get the download formats for a given download flow and entity.
|
|
10
|
+
*
|
|
11
|
+
* @param downloadFlow DownloadFlowType
|
|
12
|
+
* @param entity IHubEditableContent
|
|
13
|
+
* @returns IDynamicDownloadFormat[]
|
|
14
|
+
*/
|
|
15
|
+
function getDownloadFormatsByFlow(downloadFlow, entity) {
|
|
16
|
+
let downloadFormats = [];
|
|
17
|
+
const actionsByFlow = {
|
|
18
|
+
createReplica: () => {
|
|
19
|
+
downloadFormats = getCreateReplicaFormats_1.getCreateReplicaFormats(entity);
|
|
20
|
+
},
|
|
21
|
+
paging: () => {
|
|
22
|
+
downloadFormats = getPagingJobFormats_1.getPagingJobFormats();
|
|
23
|
+
},
|
|
24
|
+
exportImage: () => {
|
|
25
|
+
downloadFormats = getExportImageFormats_1.getExportImageFormats(entity);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
actionsByFlow[downloadFlow] && actionsByFlow[downloadFlow]();
|
|
29
|
+
return downloadFormats;
|
|
30
|
+
}
|
|
31
|
+
exports.getDownloadFormatsByFlow = getDownloadFormatsByFlow;
|
|
32
|
+
//# sourceMappingURL=getDownloadFormatsByFlow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadFormatsByFlow.js","sourceRoot":"","sources":["../../../../src/downloads/_internal/getDownloadFormatsByFlow.ts"],"names":[],"mappings":";;;AAKA,uFAAoF;AACpF,mFAAgF;AAChF,+EAA4E;AAE5E;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,YAA8B,EAC9B,MAA2B;IAE3B,IAAI,eAAe,GAA6B,EAAE,CAAC;IACnD,MAAM,aAAa,GAAyC;QAC1D,aAAa,EAAE,GAAG,EAAE;YAClB,eAAe,GAAG,iDAAuB,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACX,eAAe,GAAG,yCAAmB,EAAE,CAAC;QAC1C,CAAC;QACD,WAAW,EAAE,GAAG,EAAE;YAChB,eAAe,GAAG,6CAAqB,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;IACF,aAAa,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;IAC7D,OAAO,eAAe,CAAC;AACzB,CAAC;AAlBD,4DAkBC"}
|
|
@@ -4,6 +4,7 @@ exports.fetchDownloadFile = void 0;
|
|
|
4
4
|
const HubError_1 = require("../HubError");
|
|
5
5
|
const canUseExportImageFlow_1 = require("./_internal/canUseExportImageFlow");
|
|
6
6
|
const canUseHubDownloadApi_1 = require("./canUseHubDownloadApi");
|
|
7
|
+
const getDownloadFormats_1 = require("./getDownloadFormats");
|
|
7
8
|
/**
|
|
8
9
|
* Fetches a download file URL for the given entity and format.
|
|
9
10
|
* @param options options to refine / filter the results of the fetchDownloadFile operation
|
|
@@ -11,6 +12,8 @@ const canUseHubDownloadApi_1 = require("./canUseHubDownloadApi");
|
|
|
11
12
|
* @throws {ArcgisHubDownloadError} if the download file URL cannot be fetched for a well-known reason
|
|
12
13
|
*/
|
|
13
14
|
async function fetchDownloadFile(options) {
|
|
15
|
+
// Make sure that format requested has been enabled for the entity
|
|
16
|
+
validateFormat(options);
|
|
14
17
|
// If the pollInterval is not set, default to 3 seconds
|
|
15
18
|
const withPollInterval = options.pollInterval == null ? Object.assign(Object.assign({}, options), { pollInterval: 3000 }) : options;
|
|
16
19
|
let fetchingFn;
|
|
@@ -26,4 +29,21 @@ async function fetchDownloadFile(options) {
|
|
|
26
29
|
return fetchingFn(withPollInterval);
|
|
27
30
|
}
|
|
28
31
|
exports.fetchDownloadFile = fetchDownloadFile;
|
|
32
|
+
/**
|
|
33
|
+
* Validates the format requested is enabled for the entity
|
|
34
|
+
* @param options options for the fetchDownloadFile operation
|
|
35
|
+
* @throws {HubError} if the format requested is not enabled for the entity
|
|
36
|
+
*/
|
|
37
|
+
function validateFormat(options) {
|
|
38
|
+
const { entity, context, format } = options;
|
|
39
|
+
const validServerFormats = getDownloadFormats_1.getDownloadFormats({
|
|
40
|
+
entity,
|
|
41
|
+
context,
|
|
42
|
+
})
|
|
43
|
+
.filter((f) => f.type === "dynamic")
|
|
44
|
+
.map((f) => f.format);
|
|
45
|
+
if (!validServerFormats.includes(format)) {
|
|
46
|
+
throw new HubError_1.default("fetchDownloadFile", `The following format is not enabled for the entity: ${format}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
29
49
|
//# sourceMappingURL=fetchDownloadFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDownloadFile.js","sourceRoot":"","sources":["../../../src/downloads/fetchDownloadFile.ts"],"names":[],"mappings":";;;AAAA,0CAAmC;AACnC,6EAA0E;AAC1E,iEAA8D;
|
|
1
|
+
{"version":3,"file":"fetchDownloadFile.js","sourceRoot":"","sources":["../../../src/downloads/fetchDownloadFile.ts"],"names":[],"mappings":";;;AAAA,0CAAmC;AACnC,6EAA0E;AAC1E,iEAA8D;AAC9D,6DAA0D;AAQ1D;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAkC;IAElC,kEAAkE;IAClE,cAAc,CAAC,OAAO,CAAC,CAAC;IAExB,uDAAuD;IACvD,MAAM,gBAAgB,GACpB,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,iCAAM,OAAO,KAAE,YAAY,EAAE,IAAI,IAAG,CAAC,CAAC,OAAO,CAAC;IAE9E,IAAI,UAAU,CAAC;IACf,IAAI,2CAAoB,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC3E,UAAU,GAAG,CACX,2CAAa,uDAAuD,EAAC,CACtE,CAAC,uBAAuB,CAAC;KAC3B;SAAM,IAAI,6CAAqB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;QACzD,UAAU,GAAG,CACX,2CAAa,4DAA4D,EAAC,CAC3E,CAAC,4BAA4B,CAAC;KAChC;SAAM;QACL,MAAM,IAAI,kBAAQ,CAChB,mBAAmB,EACnB,+DAA+D,CAChE,CAAC;KACH;IACD,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC;AA1BD,8CA0BC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,OAAkC;IACxD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,kBAAkB,GAA4B,uCAAkB,CAAC;QACrE,MAAM;QACN,OAAO;KACR,CAAC;SACC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAA4B,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,IAAI,kBAAQ,CAChB,mBAAmB,EACnB,uDAAuD,MAAM,EAAE,CAChE,CAAC;KACH;AACH,CAAC"}
|
|
@@ -4,11 +4,15 @@ exports.fetchDownloadFormats = void 0;
|
|
|
4
4
|
const canUseExportImageFlow_1 = require("./_internal/canUseExportImageFlow");
|
|
5
5
|
const canUseHubDownloadApi_1 = require("./canUseHubDownloadApi");
|
|
6
6
|
/**
|
|
7
|
+
* DEPRECATED: This will be removed in the next breaking version. Use "getDownloadFormats()" instead.
|
|
8
|
+
*
|
|
7
9
|
* Fetches download formats for the given entity. Also folds in any additional resources defined on the entity.
|
|
8
10
|
* @param options options to refine / filter the results of the fetchDownloadFormats operation
|
|
9
11
|
* @returns a promise that resolves with the download formats
|
|
10
12
|
*/
|
|
11
13
|
async function fetchDownloadFormats(options) {
|
|
14
|
+
/* tslint:disable no-console */
|
|
15
|
+
console.warn(`"fetchDownloadFormats()" is deprecated. Please use "getDownloadFormats()"`);
|
|
12
16
|
const { entity, context, layers } = options;
|
|
13
17
|
// fetch base formats for the item
|
|
14
18
|
let baseFormats = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDownloadFormats.js","sourceRoot":"","sources":["../../../src/downloads/fetchDownloadFormats.ts"],"names":[],"mappings":";;;AACA,6EAA0E;AAC1E,iEAA8D;AAO9D
|
|
1
|
+
{"version":3,"file":"fetchDownloadFormats.js","sourceRoot":"","sources":["../../../src/downloads/fetchDownloadFormats.ts"],"names":[],"mappings":";;;AACA,6EAA0E;AAC1E,iEAA8D;AAO9D;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAAqC;IAErC,+BAA+B;IAC/B,OAAO,CAAC,IAAI,CACV,2EAA2E,CAC5E,CAAC;IAEF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC5C,kCAAkC;IAClC,IAAI,WAAW,GAAsB,EAAE,CAAC;IACxC,IAAI,2CAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QACzC,MAAM,EAAE,wBAAwB,EAAE,GAAG,2CACnC,4BAA4B,EAC7B,CAAC;QACF,WAAW,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;KAChD;SAAM,IAAI,6CAAqB,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,EAAE,qBAAqB,EAAE,GAAG,2CAChC,mDAAmD,EACpD,CAAC;QACF,WAAW,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;KAC7C;IAED,kDAAkD;IAClD,0DAA0D;IAC1D,MAAM,iBAAiB,GAAG,CAAC,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAC9D,cAAc,CACf,CAAC;IAEF,mCAAmC;IACnC,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,iBAAiB,CAAC,CAAC;AAChD,CAAC;AA/BD,oDA+BC;AAED,SAAS,cAAc,CACrB,QAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EACH,QAAQ,CAAC,IAAI;YACb,CAAC,QAAQ,CAAC,YAAY,IAAI,0BAA0B,CAAC,IAAI,+CAA+C;YACxG,uBAAuB;QACzB,GAAG,EAAE,QAAQ,CAAC,GAAG;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadConfiguration = void 0;
|
|
4
|
+
const get_prop_1 = require("../objects/get-prop");
|
|
5
|
+
const getDownloadFlow_1 = require("./_internal/getDownloadFlow");
|
|
6
|
+
const getDownloadFormatsByFlow_1 = require("./_internal/getDownloadFormatsByFlow");
|
|
7
|
+
/**
|
|
8
|
+
* Returns the download configuration for an entity at this moment in time.
|
|
9
|
+
*
|
|
10
|
+
* If no configuration exists, a default configuration is returned based on the entity's current download flow.
|
|
11
|
+
* If a configuration exists but is no longer valid, the default configuration will also be returned.
|
|
12
|
+
*
|
|
13
|
+
* @param entity entity to get download configuration for
|
|
14
|
+
* @returns the current download configuration for the entity
|
|
15
|
+
*/
|
|
16
|
+
function getDownloadConfiguration(entity) {
|
|
17
|
+
// TODO: account for enterprise environments
|
|
18
|
+
const downloadFlow = getDownloadFlow_1.getDownloadFlow(entity);
|
|
19
|
+
const serverFormats = getDownloadFormatsByFlow_1.getDownloadFormatsByFlow(downloadFlow, entity);
|
|
20
|
+
const additionalResources = get_prop_1.getProp(entity, "extendedProps.additionalResources") || [];
|
|
21
|
+
const existingConfiguration = get_prop_1.getProp(entity, "extendedProps.downloads");
|
|
22
|
+
// Base combined default formats
|
|
23
|
+
const combinedDefaultFormats = serverFormats.map((f) => {
|
|
24
|
+
return {
|
|
25
|
+
key: f.format,
|
|
26
|
+
hidden: false,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
additionalResources.forEach((f, idx) => {
|
|
30
|
+
combinedDefaultFormats.push({
|
|
31
|
+
key: `additionalResource::${idx}`,
|
|
32
|
+
hidden: false,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const shouldUseExistingConfiguration = existingConfiguration && existingConfiguration.flowType === downloadFlow;
|
|
36
|
+
// Existing configuration matches the current flow
|
|
37
|
+
if (shouldUseExistingConfiguration) {
|
|
38
|
+
const missingDefaultFormats = combinedDefaultFormats.filter((f) => {
|
|
39
|
+
return !existingConfiguration.formats.find((df) => df.key === f.key);
|
|
40
|
+
});
|
|
41
|
+
const validConfiguredFormats = existingConfiguration.formats.filter((f) => {
|
|
42
|
+
return combinedDefaultFormats.find((df) => df.key === f.key);
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
flowType: downloadFlow,
|
|
46
|
+
formats: [...validConfiguredFormats, ...missingDefaultFormats],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Existing configuration does not match the current flow
|
|
50
|
+
return {
|
|
51
|
+
flowType: downloadFlow,
|
|
52
|
+
formats: combinedDefaultFormats,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.getDownloadConfiguration = getDownloadConfiguration;
|
|
56
|
+
//# sourceMappingURL=getDownloadConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadConfiguration.js","sourceRoot":"","sources":["../../../src/downloads/getDownloadConfiguration.ts"],"names":[],"mappings":";;;AAMA,kDAA8C;AAC9C,iEAA8D;AAC9D,mFAAgF;AAEhF;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CACtC,MAA2B;IAE3B,4CAA4C;IAC5C,MAAM,YAAY,GAAG,iCAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,mDAAwB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrE,MAAM,mBAAmB,GACvB,kBAAO,CAAC,MAAM,EAAE,mCAAmC,CAAC,IAAI,EAAE,CAAC;IAC7D,MAAM,qBAAqB,GAAiC,kBAAO,CACjE,MAAM,EACN,yBAAyB,CAC1B,CAAC;IAEF,gCAAgC;IAChC,MAAM,sBAAsB,GAC1B,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAgC,EAAE;QACpD,OAAO;YACL,GA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adFormats = void 0;
|
|
4
|
+
const get_prop_1 = require("../objects/get-prop");
|
|
5
|
+
const canUseExportImageFlow_1 = require("./_internal/canUseExportImageFlow");
|
|
6
|
+
const getExportImageFormats_1 = require("./_internal/format-fetchers/getExportImageFormats");
|
|
7
|
+
const utils_1 = require("./_internal/additional-resources/utils");
|
|
8
|
+
const canUseHubDownloadApi_1 = require("./canUseHubDownloadApi");
|
|
9
|
+
const getDownloadConfiguration_1 = require("./getDownloadConfiguration");
|
|
10
|
+
const getHubDownloadApiFormats_1 = require("./getHubDownloadApiFormats");
|
|
11
|
+
/**
|
|
12
|
+
* Gets available download formats / additional resources for the given entity in the order they have been configured.
|
|
13
|
+
* If a format has been configured to be hidden, it will not be included in the results.
|
|
14
|
+
*
|
|
15
|
+
* @param options options to refine / filter the results of the fetchDownloadFormats operation
|
|
16
|
+
* @returns The available download formats and additional resources
|
|
17
|
+
*/
|
|
18
|
+
function getDownloadFormats(options) {
|
|
19
|
+
const { entity, context } = options;
|
|
20
|
+
// get the base formats for the item
|
|
21
|
+
let baseFormats = [];
|
|
22
|
+
// TODO: use typescript to enforce a branch for each flow type
|
|
23
|
+
if (canUseHubDownloadApi_1.canUseHubDownloadApi(entity, context)) {
|
|
24
|
+
baseFormats = getHubDownloadApiFormats_1.getHubDownloadApiFormats(entity);
|
|
25
|
+
}
|
|
26
|
+
else if (canUseExportImageFlow_1.canUseExportImageFlow(entity)) {
|
|
27
|
+
baseFormats = getExportImageFormats_1.getExportImageFormats(entity);
|
|
28
|
+
}
|
|
29
|
+
// add additional resource links as static formats
|
|
30
|
+
const additionalResources = get_prop_1.getProp(entity, "extendedProps.additionalResources") || [];
|
|
31
|
+
const additionalFormats = additionalResources.map(toStaticFormat);
|
|
32
|
+
// Respect the order and visibility of the formats as configured for the entity
|
|
33
|
+
const downloadConfiguration = getDownloadConfiguration_1.getDownloadConfiguration(entity);
|
|
34
|
+
return downloadConfiguration.formats.reduce((acc, format) => {
|
|
35
|
+
if (!format.hidden) {
|
|
36
|
+
let includedFormat;
|
|
37
|
+
if (utils_1.isAdditionalResourceConfiguration(format)) {
|
|
38
|
+
const additionalResourceIndex = utils_1.getAdditionalResourceIndex(format);
|
|
39
|
+
includedFormat = additionalFormats[additionalResourceIndex];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
baseFormats.forEach((baseFormat) => {
|
|
43
|
+
if (baseFormat.format === format.key) {
|
|
44
|
+
includedFormat = baseFormat;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
acc.push(includedFormat);
|
|
49
|
+
}
|
|
50
|
+
return acc;
|
|
51
|
+
}, []);
|
|
52
|
+
}
|
|
53
|
+
exports.getDownloadFormats = getDownloadFormats;
|
|
54
|
+
function toStaticFormat(resource) {
|
|
55
|
+
return {
|
|
56
|
+
type: "static",
|
|
57
|
+
label: resource.name ||
|
|
58
|
+
(resource.isDataSource && `{{dataSource:translate}}`) || // if the additional resource is the datasource
|
|
59
|
+
`{{noTitle:translate}}`,
|
|
60
|
+
url: resource.url,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=getDownloadFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadFormats.js","sourceRoot":"","sources":["../../../src/downloads/getDownloadFormats.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAC9C,6EAA0E;AAC1E,6FAA0F;AAC1F,kEAGgD;AAChD,iEAA8D;AAC9D,yEAAsE;AACtE,yEAAsE;AAQtE;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,OAAqC;IAErC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACpC,oCAAoC;IACpC,IAAI,WAAW,GAA6B,EAAE,CAAC;IAC/C,8DAA8D;IAC9D,IAAI,2CAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QACzC,WAAW,GAAG,mDAAwB,CAAC,MAAM,CAAC,CAAC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AAC;AACJ,CAAC"}
|
|
@@ -9,4 +9,6 @@ tslib_1.__exportStar(require("./canUseCreateReplica"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./canUseHubDownloadSystem"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./canUseHubDownloadApi"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./getHubDownloadApiFormats"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./getDownloadConfiguration"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./getDownloadFormats"), exports);
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/downloads/index.ts"],"names":[],"mappings":";;;AAAA,gFAAsD;AACtD,kDAAwB;AACxB,8DAAoC;AACpC,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,iEAAuC;AACvC,qEAA2C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/downloads/index.ts"],"names":[],"mappings":";;;AAAA,gFAAsD;AACtD,kDAAwB;AACxB,8DAAoC;AACpC,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,iEAAuC;AACvC,qEAA2C;AAC3C,qEAA2C;AAC3C,+DAAqC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IUiSchemaElement } from "../../core/schemas/types";
|
|
2
|
+
import { IHubEditableContent } from "../../core/types/IHubEditableContent";
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Constructs the downloads section for an IHubEditableContent entity.
|
|
6
|
+
* Due to numerous product requirements, the content and state of this section
|
|
7
|
+
* can vary greatly depending on the entity type and configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param i18nScope translation scope
|
|
10
|
+
* @param entity entity to get the downloads section for
|
|
11
|
+
* @returns ui schema elements for the downloads section
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDownloadsSection(i18nScope: string, entity: IHubEditableContent): IUiSchemaElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IHubEditableContent } from "../../core/types/IHubEditableContent";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* Determines if the downloads configuration should be shown for an entity.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: product has asked that the download configuration be shown for entities that _can_
|
|
7
|
+
* be downloaded, as well as certain entities that _cannot_ be downloaded currently, but
|
|
8
|
+
* could be downloaded with a change in item / service settings.
|
|
9
|
+
*
|
|
10
|
+
* @param entity entity to check
|
|
11
|
+
* @returns whether downloads configuration should be shown
|
|
12
|
+
*/
|
|
13
|
+
export declare function shouldShowDownloadsConfiguration(entity: IHubEditableContent): boolean;
|
|
@@ -52,6 +52,49 @@ export interface IHubEditableContent extends IHubItemEntity, IWithSlug, IWithPer
|
|
|
52
52
|
* This is a discriminated union of the possible additional props.
|
|
53
53
|
*/
|
|
54
54
|
export declare type IExtendedProps = IContentExtendedProps | IServiceExtendedProps;
|
|
55
|
+
/**
|
|
56
|
+
* Represents the download process that the configuration was created for
|
|
57
|
+
*/
|
|
58
|
+
export declare type DownloadFlowType = "createReplica" | "paging" | "exportImage";
|
|
59
|
+
/**
|
|
60
|
+
* Represents the storage object for configuring a single download format
|
|
61
|
+
* TODO: Should this be IDownloadFormatConfigurationStorage?
|
|
62
|
+
*/
|
|
63
|
+
export interface IDownloadFormatConfiguration {
|
|
64
|
+
/**
|
|
65
|
+
* Key that identifies the download format.
|
|
66
|
+
*/
|
|
67
|
+
key: string;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the download format should be hidden from the UI
|
|
70
|
+
*/
|
|
71
|
+
hidden?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Represents the display object for configuring a single download format.
|
|
75
|
+
* To be used in editing contexts rather than user-facing contexts.
|
|
76
|
+
*/
|
|
77
|
+
export interface IDownloadFormatConfigurationDisplay extends IDownloadFormatConfiguration {
|
|
78
|
+
/**
|
|
79
|
+
* Translated label to display for the download format
|
|
80
|
+
*/
|
|
81
|
+
label: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Represents the configurations for downloading an item
|
|
85
|
+
*/
|
|
86
|
+
export interface IEntityDownloadConfiguration {
|
|
87
|
+
/**
|
|
88
|
+
* Indicates the download flow that the configuration was created for
|
|
89
|
+
* (i.e., the download process that would have been used at the time of configuration)
|
|
90
|
+
*/
|
|
91
|
+
flowType: DownloadFlowType;
|
|
92
|
+
/**
|
|
93
|
+
* Configuration for the download formats that are available for the item.
|
|
94
|
+
* Saved in the order that they should be displayed in the UI.
|
|
95
|
+
*/
|
|
96
|
+
formats: IDownloadFormatConfiguration[];
|
|
97
|
+
}
|
|
55
98
|
/**
|
|
56
99
|
* Optional enrichments that are common to all content types
|
|
57
100
|
*/
|
|
@@ -68,6 +111,10 @@ export interface IBaseExtendedProps {
|
|
|
68
111
|
* Convenience links to additional resources specified in the formal item metadata
|
|
69
112
|
*/
|
|
70
113
|
additionalResources?: IHubAdditionalResource[];
|
|
114
|
+
/**
|
|
115
|
+
* Download configuration for the item
|
|
116
|
+
*/
|
|
117
|
+
downloads?: IEntityDownloadConfiguration;
|
|
71
118
|
}
|
|
72
119
|
/**
|
|
73
120
|
* Enrichments specific to items that are not backed by a service
|
|
@@ -104,4 +151,13 @@ export interface IServiceExtendedProps extends IBaseExtendedProps {
|
|
|
104
151
|
*/
|
|
105
152
|
serverExtractFormats?: string[];
|
|
106
153
|
}
|
|
107
|
-
export declare type IHubContentEditor = IHubItemEntityEditor<IHubEditableContent> & {
|
|
154
|
+
export declare type IHubContentEditor = IHubItemEntityEditor<IHubEditableContent> & {
|
|
155
|
+
/**
|
|
156
|
+
* Download formats that should be rendered in the editing UI.
|
|
157
|
+
*
|
|
158
|
+
* NOTE: The formats present in this array may or may not be actually accessible.
|
|
159
|
+
* Product has asked that in certain cases, we display formats that _could_ be available
|
|
160
|
+
* if the user were to make the necessary changes to the item / service.
|
|
161
|
+
*/
|
|
162
|
+
downloadFormats?: IDownloadFormatConfigurationDisplay[];
|
|
163
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IDownloadFormatConfiguration } from "../../../core/types/IHubEditableContent";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* Determines if the given download format configuration is for
|
|
5
|
+
* an additional resource.
|
|
6
|
+
*
|
|
7
|
+
* @param config IDownloadFormatConfiguration
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAdditionalResourceConfiguration(config: IDownloadFormatConfiguration): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* Get's the index of the additional resource from the given
|
|
14
|
+
* download format configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param config IDownloadFormatConfiguration
|
|
17
|
+
* @returns number - The index of the additional resource
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAdditionalResourceIndex(config: IDownloadFormatConfiguration): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDownloadFormatConfigurationDisplay, IHubEditableContent } from "../../core/types/IHubEditableContent";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* Returns configuration objects for each download format that should be displayed
|
|
5
|
+
* in the editing experience of a content entity. This function should not be used
|
|
6
|
+
* to calculate the download formats that should be present on the live UI.
|
|
7
|
+
* @param entity entity to get download format configurations for
|
|
8
|
+
* @returns download format configurations to display
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDownloadConfigurationDisplayFormats(entity: IHubEditableContent): IDownloadFormatConfigurationDisplay[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DownloadFlowType, IHubEditableContent } from "../../core";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* Determines the download flow that will be used for the current entity.
|
|
5
|
+
* If the entity cannot be downloaded, returns null.
|
|
6
|
+
*
|
|
7
|
+
* @param entity the entity to get the download flow for
|
|
8
|
+
* @param isEnterprise whether the the download will be executed in an enterprise environment
|
|
9
|
+
* @returns the download flow that will be used for the current entity
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDownloadFlow(entity: IHubEditableContent, isEnterprise?: boolean): DownloadFlowType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DownloadFlowType, IHubEditableContent } from "../../core/types/IHubEditableContent";
|
|
2
|
+
import { IDynamicDownloadFormat } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Get the download formats for a given download flow and entity.
|
|
6
|
+
*
|
|
7
|
+
* @param downloadFlow DownloadFlowType
|
|
8
|
+
* @param entity IHubEditableContent
|
|
9
|
+
* @returns IDynamicDownloadFormat[]
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDownloadFormatsByFlow(downloadFlow: DownloadFlowType, entity: IHubEditableContent): IDynamicDownloadFormat[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IDownloadFormat, IFetchDownloadFormatsOptions } from "./types";
|
|
2
2
|
/**
|
|
3
|
+
* DEPRECATED: This will be removed in the next breaking version. Use "getDownloadFormats()" instead.
|
|
4
|
+
*
|
|
3
5
|
* Fetches download formats for the given entity. Also folds in any additional resources defined on the entity.
|
|
4
6
|
* @param options options to refine / filter the results of the fetchDownloadFormats operation
|
|
5
7
|
* @returns a promise that resolves with the download formats
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IEntityDownloadConfiguration, IHubEditableContent } from "../core/types/IHubEditableContent";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the download configuration for an entity at this moment in time.
|
|
4
|
+
*
|
|
5
|
+
* If no configuration exists, a default configuration is returned based on the entity's current download flow.
|
|
6
|
+
* If a configuration exists but is no longer valid, the default configuration will also be returned.
|
|
7
|
+
*
|
|
8
|
+
* @param entity entity to get download configuration for
|
|
9
|
+
* @returns the current download configuration for the entity
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDownloadConfiguration(entity: IHubEditableContent): IEntityDownloadConfiguration;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IDownloadFormat, IFetchDownloadFormatsOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Gets available download formats / additional resources for the given entity in the order they have been configured.
|
|
4
|
+
* If a format has been configured to be hidden, it will not be included in the results.
|
|
5
|
+
*
|
|
6
|
+
* @param options options to refine / filter the results of the fetchDownloadFormats operation
|
|
7
|
+
* @returns The available download formats and additional resources
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDownloadFormats(options: IFetchDownloadFormatsOptions): IDownloadFormat[];
|