@esri/hub-common 9.29.0 → 9.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/content/_internal.js +2 -0
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +1 -1
- package/dist/es2017/content/compose.js.map +1 -1
- package/dist/es2017/content/get-family.js +1 -1
- package/dist/es2017/content/get-family.js.map +1 -1
- package/dist/es2017/content/index.js +3 -2
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/items/_internal/_prepare-upload-requests.js +28 -0
- package/dist/es2017/items/_internal/_prepare-upload-requests.js.map +1 -0
- package/dist/es2017/items/_internal/_wait-for-item-ready.js +23 -0
- package/dist/es2017/items/_internal/_wait-for-item-ready.js.map +1 -0
- package/dist/es2017/items/create-item-from-file.js +52 -0
- package/dist/es2017/items/create-item-from-file.js.map +1 -0
- package/dist/es2017/items/create-item-from-url-or-file.js +46 -0
- package/dist/es2017/items/create-item-from-url-or-file.js.map +1 -0
- package/dist/es2017/items/create-item-from-url.js +16 -0
- package/dist/es2017/items/create-item-from-url.js.map +1 -0
- package/dist/esm/content/_internal.js +2 -0
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +1 -1
- package/dist/esm/content/compose.js.map +1 -1
- package/dist/esm/content/get-family.js +1 -1
- package/dist/esm/content/get-family.js.map +1 -1
- package/dist/esm/content/index.js +3 -2
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/items/_internal/_prepare-upload-requests.js +29 -0
- package/dist/esm/items/_internal/_prepare-upload-requests.js.map +1 -0
- package/dist/esm/items/_internal/_wait-for-item-ready.js +37 -0
- package/dist/esm/items/_internal/_wait-for-item-ready.js.map +1 -0
- package/dist/esm/items/create-item-from-file.js +76 -0
- package/dist/esm/items/create-item-from-file.js.map +1 -0
- package/dist/esm/items/create-item-from-url-or-file.js +59 -0
- package/dist/esm/items/create-item-from-url-or-file.js.map +1 -0
- package/dist/esm/items/create-item-from-url.js +25 -0
- package/dist/esm/items/create-item-from-url.js.map +1 -0
- package/dist/node/content/_internal.js +2 -0
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +1 -1
- package/dist/node/content/compose.js.map +1 -1
- package/dist/node/content/get-family.js +1 -1
- package/dist/node/content/get-family.js.map +1 -1
- package/dist/node/content/index.js +3 -2
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/items/_internal/_prepare-upload-requests.js +32 -0
- package/dist/node/items/_internal/_prepare-upload-requests.js.map +1 -0
- package/dist/node/items/_internal/_wait-for-item-ready.js +27 -0
- package/dist/node/items/_internal/_wait-for-item-ready.js.map +1 -0
- package/dist/node/items/create-item-from-file.js +56 -0
- package/dist/node/items/create-item-from-file.js.map +1 -0
- package/dist/node/items/create-item-from-url-or-file.js +50 -0
- package/dist/node/items/create-item-from-url-or-file.js.map +1 -0
- package/dist/node/items/create-item-from-url.js +20 -0
- package/dist/node/items/create-item-from-url.js.map +1 -0
- package/dist/types/content/index.d.ts +2 -2
- package/dist/types/items/_internal/_prepare-upload-requests.d.ts +16 -0
- package/dist/types/items/_internal/_wait-for-item-ready.d.ts +10 -0
- package/dist/types/items/create-item-from-file.d.ts +13 -0
- package/dist/types/items/create-item-from-url-or-file.d.ts +18 -0
- package/dist/types/items/create-item-from-url.d.ts +12 -0
- package/dist/umd/common.umd.js +16 -5
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -2
- package/dist/umd/common.umd.min.js +0 -2
- package/dist/umd/common.umd.min.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createItemFromFile = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const _prepare_upload_requests_1 = require("./_internal/_prepare-upload-requests");
|
|
8
|
+
/**
|
|
9
|
+
* Creates an item in online from a local file/item.
|
|
10
|
+
* Upload is multithreaded as the item is chunked up.
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @param {IItemAdd} item Item to be uploaded into online.
|
|
14
|
+
* @param {IUserRequestOptions} requestOptions
|
|
15
|
+
* @return {*} {Promise<string>} Newly created item id
|
|
16
|
+
*/
|
|
17
|
+
async function createItemFromFile(item, requestOptions) {
|
|
18
|
+
// Make a copy of the file
|
|
19
|
+
const file = util_1.cloneObject(item.file);
|
|
20
|
+
// and remove the file object so
|
|
21
|
+
// that it won't trigger the direct upload at the createContent request
|
|
22
|
+
delete item.file;
|
|
23
|
+
// Create the item in online so we have an id
|
|
24
|
+
const createResult = await arcgis_rest_portal_1.createItem(Object.assign({ item, filename: file.name, async: true, multipart: true, overwrite: true }, requestOptions));
|
|
25
|
+
// get the items id
|
|
26
|
+
const itemId = createResult.id;
|
|
27
|
+
try {
|
|
28
|
+
// AGOL recommends at least 5mb for each file part
|
|
29
|
+
// to upload so we use 6mb to slice the file.
|
|
30
|
+
// see https://developers.arcgis.com/rest/users-groups-and-items/add-item-part.htm
|
|
31
|
+
const sizeLimit = 6 * 1000 * 1000;
|
|
32
|
+
// Create queue of upload requests.
|
|
33
|
+
const uploadQueue = _prepare_upload_requests_1._prepareUploadRequests(file, item.owner, itemId, sizeLimit, requestOptions);
|
|
34
|
+
// execute up to 5 concurrent requests
|
|
35
|
+
await utils_1.batch(uploadQueue,
|
|
36
|
+
// We are doing this to catch individual response failures
|
|
37
|
+
// and throwing them to stop further xhr's
|
|
38
|
+
async (opts) => {
|
|
39
|
+
const resp = await arcgis_rest_portal_1.addItemPart(opts);
|
|
40
|
+
// If the response did not return with success then throw an error
|
|
41
|
+
if (!resp.success) {
|
|
42
|
+
throw new Error("addItemPart failed");
|
|
43
|
+
}
|
|
44
|
+
}, 5);
|
|
45
|
+
// Commit is called once all parts are uploaded during a multipart add item or update item operation.
|
|
46
|
+
await arcgis_rest_portal_1.commitItemUpload(Object.assign({ id: itemId, item, owner: item.owner }, requestOptions));
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
// If an error is thrown then cancel item upload
|
|
50
|
+
await arcgis_rest_portal_1.cancelItemUpload(Object.assign({ id: itemId, owner: item.owner }, requestOptions));
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
return createResult;
|
|
54
|
+
}
|
|
55
|
+
exports.createItemFromFile = createItemFromFile;
|
|
56
|
+
//# sourceMappingURL=create-item-from-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-item-from-file.js","sourceRoot":"","sources":["../../../src/items/create-item-from-file.ts"],"names":[],"mappings":";;;AACA,iEAMkC;AAElC,kCAAsC;AACtC,oCAAiC;AACjC,mFAA8E;AAE9E;;;;;;;;GAQG;AACI,KAAK,UAAU,kBAAkB,CACtC,IAAc,EACd,cAAmC;IAEnC,0BAA0B;IAC1B,MAAM,IAAI,GAAQ,kBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,iCAAiC;IACjC,uEAAuE;IACvE,OAAO,IAAI,CAAC,IAAI,CAAC;IAEjB,6CAA6C;IAC7C,MAAM,YAAY,GAAwB,MAAM,+BAAU,iBACxD,IAAI,EACJ,QAAQ,EAAE,IAAI,CAAC,IAAI,EACnB,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,IAAI,EACf,SAAS,EAAE,IAAI,IACZ,cAAc,EACjB,CAAC;IACH,mBAAmB;IACnB,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,CAAC;IAE/B,IAAI;QACF,kDAAkD;QAClD,6CAA6C;QAC7C,kFAAkF;QAClF,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QAClC,mCAAmC;QACnC,MAAM,WAAW,GAAG,iDAAsB,CACxC,IAAI,EACJ,IAAI,CAAC,KAAK,EACV,MAAM,EACN,SAAS,EACT,cAAc,CACf,CAAC;QACF,sCAAsC;QACtC,MAAM,aAAK,CACT,WAAW;QACX,0DAA0D;QAC1D,0CAA0C;QAC1C,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,MAAM,IAAI,GAAG,MAAM,gCAAW,CAAC,IAAI,CAAC,CAAC;YACrC,kEAAkE;YAClE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACvC;QACH,CAAC,EACD,CAAC,CACF,CAAC;QAEF,qGAAqG;QACrG,MAAM,qCAAgB,iBACpB,EAAE,EAAE,MAAM,EACV,IAAI,EACJ,KAAK,EAAE,IAAI,CAAC,KAAK,IACd,cAAc,EACjB,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,gDAAgD;QAChD,MAAM,qCAAgB,iBACpB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,IAAI,CAAC,KAAK,IACd,cAAc,EACjB,CAAC;QAEH,MAAM,CAAC,CAAC;KACT;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AArED,gDAqEC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createItemFromUrlOrFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const create_item_from_file_1 = require("./create-item-from-file");
|
|
8
|
+
const create_item_from_url_1 = require("./create-item-from-url");
|
|
9
|
+
const _wait_for_item_ready_1 = require("./_internal/_wait-for-item-ready");
|
|
10
|
+
/**
|
|
11
|
+
* Creates an item in online from either url or file.
|
|
12
|
+
* Once created we wait for the item to be ready (or throw an error if creation failed)
|
|
13
|
+
* If access is not private then we make a call to update that.
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @param {ICreateItemFromUrlOrFileOptions} createItemFromUrlOrFileOptions Input params (item, groups?, requestoptions)
|
|
17
|
+
* @return {*} {Promise<string>} AGO item id
|
|
18
|
+
*/
|
|
19
|
+
async function createItemFromUrlOrFile(createItemFromUrlOrFileOptions) {
|
|
20
|
+
const { item, groups } = createItemFromUrlOrFileOptions, userRequestOptions = tslib_1.__rest(createItemFromUrlOrFileOptions, ["item", "groups"]);
|
|
21
|
+
// Is there a file or data url?
|
|
22
|
+
const shouldWaitForItemReady = item.dataUrl || item.file;
|
|
23
|
+
let createdItem;
|
|
24
|
+
// If there is a file then we create the item and chunk the file
|
|
25
|
+
// while multithread uploading it
|
|
26
|
+
if (item.file) {
|
|
27
|
+
createdItem = await create_item_from_file_1.createItemFromFile(item, userRequestOptions);
|
|
28
|
+
// Otherwise it's being created from a url.
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
createdItem = await create_item_from_url_1.createItemFromUrl(item, userRequestOptions);
|
|
32
|
+
}
|
|
33
|
+
// If there is a file or data url we want to check to see if / when the item is ready.
|
|
34
|
+
if (shouldWaitForItemReady) {
|
|
35
|
+
await _wait_for_item_ready_1._waitForItemReady(createdItem.id, userRequestOptions);
|
|
36
|
+
}
|
|
37
|
+
// If the item access is NOT private (which is the sharing access level by default)
|
|
38
|
+
// We subsequently update the items access level.
|
|
39
|
+
if (item.access !== "private") {
|
|
40
|
+
await arcgis_rest_portal_1.setItemAccess(Object.assign({ id: createdItem.id, owner: item.owner, access: item.access }, userRequestOptions));
|
|
41
|
+
}
|
|
42
|
+
// If group ids were passedd in then make share calls to each.
|
|
43
|
+
if (groups === null || groups === void 0 ? void 0 : groups.length) {
|
|
44
|
+
const failSafeShare = utils_1.failSafe(arcgis_rest_portal_1.shareItemWithGroup);
|
|
45
|
+
await Promise.all(groups.map((group) => failSafeShare(Object.assign({ id: createdItem.id, owner: item.owner, groupId: group.id, confirmItemControl: utils_1.isUpdateGroup(group) }, userRequestOptions))));
|
|
46
|
+
}
|
|
47
|
+
return createdItem;
|
|
48
|
+
}
|
|
49
|
+
exports.createItemFromUrlOrFile = createItemFromUrlOrFile;
|
|
50
|
+
//# sourceMappingURL=create-item-from-url-or-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-item-from-url-or-file.js","sourceRoot":"","sources":["../../../src/items/create-item-from-url-or-file.ts"],"names":[],"mappings":";;;;AACA,iEAIkC;AAElC,oCAAmD;AACnD,mEAA6D;AAC7D,iEAA2D;AAC3D,2EAAqE;AAOrE;;;;;;;;GAQG;AACI,KAAK,UAAU,uBAAuB,CAC3C,8BAA+D;IAE/D,MAAM,EAAE,IAAI,EAAE,MAAM,KAClB,8BAA8B,EADP,kBAAkB,kBACzC,8BAA8B,EAD1B,kBAAuC,CACb,CAAC;IACjC,+BAA+B;IAC/B,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC;IACzD,IAAI,WAAgC,CAAC;IAErC,gEAAgE;IAChE,iCAAiC;IACjC,IAAI,IAAI,CAAC,IAAI,EAAE;QACb,WAAW,GAAG,MAAM,0CAAkB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACjE,2CAA2C;KAC5C;SAAM;QACL,WAAW,GAAG,MAAM,wCAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;KACjE;IAED,sFAAsF;IACtF,IAAI,sBAAsB,EAAE;QAC1B,MAAM,wCAAiB,CAAC,WAAW,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;KAC7D;IAED,mFAAmF;IACnF,iDAAiD;IACjD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;QAC7B,MAAM,kCAAa,iBACjB,EAAE,EAAE,WAAW,CAAC,EAAE,EAClB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,IAChB,kBAAkB,EACrB,CAAC;KACJ;IAED,8DAA8D;IAC9D,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;QAClB,MAAM,aAAa,GAAG,gBAAQ,CAAC,uCAAkB,CAAC,CAAC;QACnD,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAC3B,aAAa,iBACX,EAAE,EAAE,WAAW,CAAC,EAAE,EAClB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,KAAK,CAAC,EAAE,EACjB,kBAAkB,EAAE,qBAAa,CAAC,KAAK,CAAC,IACrC,kBAAkB,EACrB,CACH,CACF,CAAC;KACH;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAnDD,0DAmDC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createItemFromUrl = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
/**
|
|
6
|
+
* Create AGO item from a URL
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @param {IItemAdd} item Item to be uploaded into online.
|
|
10
|
+
* @param {IUserRequestOptions} requestOptions
|
|
11
|
+
* @return {*} {Promise<string>} Newly created item ID
|
|
12
|
+
*/
|
|
13
|
+
async function createItemFromUrl(item, requestOptions) {
|
|
14
|
+
// Fire off createItem call
|
|
15
|
+
const createResult = await arcgis_rest_portal_1.createItem(Object.assign({ item, owner: item.owner, file: item.file, dataUrl: item.dataUrl, text: item.text, multipart: item.multipart, async: item.async }, requestOptions));
|
|
16
|
+
// return the newly created item id
|
|
17
|
+
return createResult;
|
|
18
|
+
}
|
|
19
|
+
exports.createItemFromUrl = createItemFromUrl;
|
|
20
|
+
//# sourceMappingURL=create-item-from-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-item-from-url.js","sourceRoot":"","sources":["../../../src/items/create-item-from-url.ts"],"names":[],"mappings":";;;AACA,iEAA2E;AAG3E;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAc,EACd,cAAmC;IAEnC,2BAA2B;IAC3B,MAAM,YAAY,GAAwB,MAAM,+BAAU,iBACxD,IAAI,EACJ,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,IACd,cAAc,EACjB,CAAC;IACH,mCAAmC;IACnC,OAAO,YAAY,CAAC;AACtB,CAAC;AAjBD,8CAiBC"}
|
|
@@ -114,14 +114,14 @@ export declare const setContentType: (content: IHubContent, type: string) => IHu
|
|
|
114
114
|
*/
|
|
115
115
|
export declare const getContentTypeLabel: (contentType: string, isProxied: boolean) => string;
|
|
116
116
|
/**
|
|
117
|
-
* returns a new content that has the specified hubId and updated identifier
|
|
117
|
+
* DEPRECATED returns a new content that has the specified hubId and updated identifier
|
|
118
118
|
* @param content orignal content
|
|
119
119
|
* @param hubId new hubId
|
|
120
120
|
* @returns new content
|
|
121
121
|
*/
|
|
122
122
|
export declare const setContentHubId: (content: IHubContent, hubId: string) => IHubContent;
|
|
123
123
|
/**
|
|
124
|
-
* Calculates the relative and absolute urls for a given content on a specific site
|
|
124
|
+
* DEPRECATED: Calculates the relative and absolute urls for a given content on a specific site
|
|
125
125
|
*
|
|
126
126
|
* @param content
|
|
127
127
|
* @param siteModel
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
2
|
+
import { IBatch } from "../..";
|
|
3
|
+
/**
|
|
4
|
+
* Takes a file, file owner, and file AGO item id along with a size limit
|
|
5
|
+
* Then chunks the file up based on that file limit.
|
|
6
|
+
* The chunks are added to addItemPart calls and added to a queue array.
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @param {*} file File to be uploaded
|
|
10
|
+
* @param {string} owner file owner
|
|
11
|
+
* @param {string} id file ID from AGO
|
|
12
|
+
* @param {number} sizeLimit How large should the chunks be?
|
|
13
|
+
* @param {IUserRequestOptions} requestOptions
|
|
14
|
+
* @return {*} {IBatch}
|
|
15
|
+
*/
|
|
16
|
+
export declare function _prepareUploadRequests(file: any, owner: string, id: string, sizeLimit: number, requestOptions: IUserRequestOptions): IBatch;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function which takes an itemId and checks the status
|
|
4
|
+
* of the item every 2 seconds until it is either complete or failed.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @param {string} itemId AGO item id
|
|
8
|
+
* @param {IUserRequestOptions} requestOptions
|
|
9
|
+
*/
|
|
10
|
+
export declare function _waitForItemReady(itemId: string, requestOptions: IUserRequestOptions): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
2
|
+
import { ICreateItemResponse } from "@esri/arcgis-rest-portal";
|
|
3
|
+
import { IItemAdd } from "@esri/arcgis-rest-types";
|
|
4
|
+
/**
|
|
5
|
+
* Creates an item in online from a local file/item.
|
|
6
|
+
* Upload is multithreaded as the item is chunked up.
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @param {IItemAdd} item Item to be uploaded into online.
|
|
10
|
+
* @param {IUserRequestOptions} requestOptions
|
|
11
|
+
* @return {*} {Promise<string>} Newly created item id
|
|
12
|
+
*/
|
|
13
|
+
export declare function createItemFromFile(item: IItemAdd, requestOptions: IUserRequestOptions): Promise<ICreateItemResponse>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
2
|
+
import { ICreateItemResponse } from "@esri/arcgis-rest-portal";
|
|
3
|
+
import { IGroup, IItemAdd } from "@esri/arcgis-rest-types";
|
|
4
|
+
interface ICreateItemFromUrlOrFileOptions extends IUserRequestOptions {
|
|
5
|
+
item: IItemAdd;
|
|
6
|
+
groups?: IGroup[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates an item in online from either url or file.
|
|
10
|
+
* Once created we wait for the item to be ready (or throw an error if creation failed)
|
|
11
|
+
* If access is not private then we make a call to update that.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @param {ICreateItemFromUrlOrFileOptions} createItemFromUrlOrFileOptions Input params (item, groups?, requestoptions)
|
|
15
|
+
* @return {*} {Promise<string>} AGO item id
|
|
16
|
+
*/
|
|
17
|
+
export declare function createItemFromUrlOrFile(createItemFromUrlOrFileOptions: ICreateItemFromUrlOrFileOptions): Promise<ICreateItemResponse>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
2
|
+
import { ICreateItemResponse } from "@esri/arcgis-rest-portal";
|
|
3
|
+
import { IItemAdd } from "@esri/arcgis-rest-types";
|
|
4
|
+
/**
|
|
5
|
+
* Create AGO item from a URL
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @param {IItemAdd} item Item to be uploaded into online.
|
|
9
|
+
* @param {IUserRequestOptions} requestOptions
|
|
10
|
+
* @return {*} {Promise<string>} Newly created item ID
|
|
11
|
+
*/
|
|
12
|
+
export declare function createItemFromUrl(item: IItemAdd, requestOptions: IUserRequestOptions): Promise<ICreateItemResponse>;
|
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.
|
|
2
|
+
* @esri/hub-common - v9.29.0 - Mon May 09 2022 16:03:22 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -6371,7 +6371,7 @@
|
|
|
6371
6371
|
var family;
|
|
6372
6372
|
// override default behavior for the rows that are highlighted in yellow here:
|
|
6373
6373
|
// https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac
|
|
6374
|
-
switch (
|
|
6374
|
+
switch (type.toLowerCase()) {
|
|
6375
6375
|
case "image service":
|
|
6376
6376
|
family = "dataset";
|
|
6377
6377
|
break;
|
|
@@ -6522,6 +6522,8 @@
|
|
|
6522
6522
|
// deployed solutions go to the generic content route
|
|
6523
6523
|
hubUrl = "/content/" + identifier;
|
|
6524
6524
|
}
|
|
6525
|
+
// TODO: I think this is a bug. The line below should be w/in else
|
|
6526
|
+
// in order to avoid overwriting the above for deployed solutions, right?
|
|
6525
6527
|
// others go to the solution about route
|
|
6526
6528
|
hubUrl = "/templates/" + identifier + "/about";
|
|
6527
6529
|
}
|
|
@@ -7200,7 +7202,7 @@
|
|
|
7200
7202
|
*/
|
|
7201
7203
|
var getContentTypeIcon = function (contentType) {
|
|
7202
7204
|
var _a;
|
|
7203
|
-
var type = camelize(contentType
|
|
7205
|
+
var type = camelize(contentType);
|
|
7204
7206
|
var iconMap = {
|
|
7205
7207
|
appbuilderExtension: "file",
|
|
7206
7208
|
appbuilderWidgetPackage: "widgets-source",
|
|
@@ -9603,11 +9605,12 @@
|
|
|
9603
9605
|
return isProxied ? "CSV" : camelize(contentType || "");
|
|
9604
9606
|
};
|
|
9605
9607
|
/**
|
|
9606
|
-
* returns a new content that has the specified hubId and updated identifier
|
|
9608
|
+
* DEPRECATED returns a new content that has the specified hubId and updated identifier
|
|
9607
9609
|
* @param content orignal content
|
|
9608
9610
|
* @param hubId new hubId
|
|
9609
9611
|
* @returns new content
|
|
9610
9612
|
*/
|
|
9613
|
+
/* istanbul ignore next DEPRECATED and no longer in use */
|
|
9611
9614
|
var setContentHubId = function (content, hubId) {
|
|
9612
9615
|
var id = content.id, slug = content.slug;
|
|
9613
9616
|
// get the identifier which is based on hubId
|
|
@@ -9620,7 +9623,7 @@
|
|
|
9620
9623
|
});
|
|
9621
9624
|
};
|
|
9622
9625
|
/**
|
|
9623
|
-
* Calculates the relative and absolute urls for a given content on a specific site
|
|
9626
|
+
* DEPRECATED: Calculates the relative and absolute urls for a given content on a specific site
|
|
9624
9627
|
*
|
|
9625
9628
|
* @param content
|
|
9626
9629
|
* @param siteModel
|
|
@@ -9665,6 +9668,10 @@
|
|
|
9665
9668
|
* instead of throwing INVALID_CHARACTER_ERR we return null.
|
|
9666
9669
|
*/
|
|
9667
9670
|
function atob(data) {
|
|
9671
|
+
if (arguments.length === 0) {
|
|
9672
|
+
throw new TypeError("1 argument required, but only 0 present.");
|
|
9673
|
+
}
|
|
9674
|
+
|
|
9668
9675
|
// Web IDL requires DOMStrings to just be converted using ECMAScript
|
|
9669
9676
|
// ToString, which in our case amounts to using a template literal.
|
|
9670
9677
|
data = `${data}`;
|
|
@@ -9761,6 +9768,10 @@
|
|
|
9761
9768
|
* RFC 4648.
|
|
9762
9769
|
*/
|
|
9763
9770
|
function btoa(s) {
|
|
9771
|
+
if (arguments.length === 0) {
|
|
9772
|
+
throw new TypeError("1 argument required, but only 0 present.");
|
|
9773
|
+
}
|
|
9774
|
+
|
|
9764
9775
|
let i;
|
|
9765
9776
|
// String conversion as required by Web IDL.
|
|
9766
9777
|
s = `${s}`;
|