@esri/arcgis-rest-portal 3.4.2 → 3.5.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/items/create.js +8 -1
- package/dist/esm/items/create.js.map +1 -1
- package/dist/esm/items/helpers.d.ts +13 -0
- package/dist/esm/items/helpers.js +21 -0
- package/dist/esm/items/helpers.js.map +1 -1
- package/dist/esm/items/update.js +8 -1
- package/dist/esm/items/update.js.map +1 -1
- package/dist/node/items/create.js +7 -0
- package/dist/node/items/create.js.map +1 -1
- package/dist/node/items/helpers.js +24 -1
- package/dist/node/items/helpers.js.map +1 -1
- package/dist/node/items/update.js +7 -0
- package/dist/node/items/update.js.map +1 -1
- package/dist/umd/portal.umd.js +38 -3
- package/dist/umd/portal.umd.js.map +1 -1
- package/dist/umd/portal.umd.min.js +4 -4
- package/dist/umd/portal.umd.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.umd.js","sources":["../../src/util/get-portal-url.ts","../../src/items/helpers.ts","../../src/items/update.ts","../../src/items/add.ts","../../src/items/content.ts","../../src/items/create.ts","../../src/items/export.ts","../../src/util/scrub-control-chars.ts","../../src/items/get.ts","../../src/items/protect.ts","../../src/groups/get.ts","../../src/sharing/helpers.ts","../../src/items/reassign.ts","../../src/items/remove.ts","../../src/util/SearchQueryBuilder.ts","../../src/util/generic-search.ts","../../src/items/search.ts","../../src/items/upload.ts","../../src/util/array.ts","../../src/groups/add-users.ts","../../src/groups/remove-users.ts","../../src/groups/invite-users.ts","../../src/groups/create.ts","../../src/groups/notification.ts","../../src/groups/protect.ts","../../src/groups/remove.ts","../../src/groups/search.ts","../../src/groups/update.ts","../../src/groups/update-user-membership.ts","../../src/groups/join.ts","../../src/orgs/notification.ts","../../src/users/get-user.ts","../../src/users/get-user-tags.ts","../../src/users/get-user-url.ts","../../src/users/invitation.ts","../../src/users/notification.ts","../../src/users/search-users.ts","../../src/users/update.ts","../../src/sharing/access.ts","../../src/sharing/is-item-shared-with-group.ts","../../src/sharing/share-item-with-group.ts","../../src/sharing/unshare-item-with-group.ts","../../src/services/is-service-name-available.ts","../../src/services/get-unique-service-name.ts","../../src/util/get-portal.ts","../../src/util/get-portal-settings.ts","../../src/util/get-subscription-info.ts"],"sourcesContent":["/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IRequestOptions, cleanUrl } from \"@esri/arcgis-rest-request\";\n\n/**\n * Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given\n * precedence over `authentication.portal`. If neither `portal` nor `authentication` is present,\n * `www.arcgis.com/sharing/rest` is returned.\n *\n * @param requestOptions - Request options that may have authentication manager\n * @returns Portal url to be used in API requests\n */\nexport function getPortalUrl(requestOptions: IRequestOptions = {}): string {\n // use portal in options if specified\n if (requestOptions.portal) {\n return cleanUrl(requestOptions.portal);\n }\n\n // if auth was passed, use that portal\n if (requestOptions.authentication) {\n // the portal url is already scrubbed in the auth package\n return requestOptions.authentication.portal;\n }\n\n // default to arcgis.com\n return \"https://www.arcgis.com/sharing/rest\";\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IRequestOptions, ArcGISRequestError } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd, IItemUpdate, IItem } from \"@esri/arcgis-rest-types\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\n/**\n * Base options interface for making authenticated requests for items.\n */\nexport interface IUserItemOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n /**\n * Item owner username. If not present, `authentication.username` is utilized.\n */\n owner?: string;\n}\n\nexport interface IFolderIdOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the folder.\n */\n folderId: string;\n /**\n * Item owner username. If not present, `authentication.username` is utilized.\n */\n owner?: string;\n}\n\nexport type ItemRelationshipType =\n | \"APIKey2Item\"\n | \"Area2CustomPackage\"\n | \"Area2Package\"\n | \"Item2Attachment\"\n | \"Item2Report\"\n | \"Listed2Provisioned\"\n | \"Map2AppConfig\"\n | \"Map2Area\"\n | \"Map2FeatureCollection\"\n | \"Map2Service\"\n | \"MobileApp2Code\"\n | \"Service2Data\"\n | \"Service2Layer\"\n | \"Service2Route\"\n | \"Service2Service\"\n | \"Service2Style\"\n | \"Solution2Item\"\n | \"Style2Style\"\n | \"Survey2Data\"\n | \"Survey2Service\"\n | \"SurveyAddIn2Data\"\n | \"Theme2Story\"\n | \"TrackView2Map\"\n | \"WebStyle2DesktopStyle\"\n | \"WMA2Code\"\n | \"WorkforceMap2FeatureService\"\n\n/**\n * Names of methods for reading the body of a fetch response, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\nexport type FetchReadMethodName =\n | \"arrayBuffer\"\n | \"blob\"\n | \"formData\"\n | \"json\"\n | \"text\";\n\nexport interface IItemRelationshipOptions extends IRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n /**\n * The type of relationship between the two items.\n */\n relationshipType: ItemRelationshipType | ItemRelationshipType[];\n /**\n * The direction of the relationship. Either forward (from origin -> destination) or reverse (from destination -> origin).\n */\n direction?: \"forward\" | \"reverse\";\n}\n\nexport interface IManageItemRelationshipOptions extends IUserRequestOptions {\n originItemId: string;\n destinationItemId: string;\n relationshipType: ItemRelationshipType;\n}\n\nexport interface IItemInfoOptions extends IUserItemOptions {\n /**\n * Subfolder for added information.\n */\n folderName?: string;\n /**\n * Object to store\n */\n file: any;\n}\n\nexport interface IItemResourceOptions extends IUserItemOptions {\n /**\n * New resource filename.\n */\n name?: string;\n /**\n * Folder in which to store the new resource.\n */\n prefix?: string;\n /**\n * Text input to be added as a file resource.\n */\n content?: string;\n /**\n * Controls whether access to the file resource is restricted to the owner or inherited from the sharing permissions set for the associated item.\n */\n private?: boolean;\n /**\n * Object to store\n */\n resource?: any;\n}\n\nexport interface IRemoveItemResourceOptions extends IUserItemOptions {\n /**\n * Resource item to be removed. Resource prefix needs to be specified if the file resource has one.\n */\n resource?: string;\n\n /**\n * If true, all file resources are removed.\n */\n deleteAll?: boolean;\n}\n\nexport interface ICreateUpdateItemOptions extends IUserRequestOptions {\n /**\n * The owner of the item. If this property is not present, `item.owner` will be passed, or lastly `authentication.username`.\n */\n owner?: string;\n /**\n * Id of the folder to house the item.\n */\n folderId?: string;\n /**\n * The file to be uploaded. If uploading a file, the request must be a multipart request.\n */\n file?: any;\n /**\n * The URL where the item can be downloaded. The resource will be downloaded and stored as a file type. Similar to uploading a file to be added, but instead of transferring the contents of the file, the URL of the data file is referenced and creates a file item.\n */\n dataUrl?: string;\n /**\n * The text content for the item to be submitted.\n */\n text?: string;\n /**\n * If true, the file is uploaded asynchronously. If false, the file is uploaded synchronously.\n */\n async?: boolean;\n /**\n * If true, the file is uploaded in multiple parts.\n */\n multipart?: boolean;\n /**\n * The filename being uploaded in multipart mode. Required if multipart=true.\n */\n filename?: string;\n /**\n * If true, overwrite the existing file.\n */\n overwrite?: boolean;\n}\n\nexport interface IItemDataOptions extends IRequestOptions {\n /**\n * Used to request binary data.\n */\n file?: boolean;\n}\n\nexport interface IItemPartOptions extends IUserItemOptions {\n /**\n * The file part to be uploaded.\n */\n file: any;\n /**\n * Part numbers can be any number from 1 to 10,000, inclusive. A part number uniquely identifies a part and also defines its position within the object being created. If you upload a new part using the same part number that was used with a previous part, the previously uploaded part is overwritten.\n */\n partNum: number;\n}\n\nexport interface IUpdateItemResponse {\n success: boolean;\n id: string;\n}\n\nexport interface IItemInfoResponse {\n success: boolean;\n itemId: string;\n owner: string;\n folder: string;\n}\n\nexport interface IItemResourceResponse {\n success: boolean;\n itemId: string;\n owner: string;\n folder: string;\n}\n\nexport interface IAddFolderResponse {\n /**\n * Success or failure of request.\n */\n success: boolean;\n /**\n * Information about created folder: its alphanumeric id, name, and owner's name.\n */\n folder: {\n id: string;\n title: string;\n username: string;\n };\n}\n\nexport interface IMoveItemResponse {\n /**\n * Success or failure of request.\n */\n success: boolean;\n /**\n * Alphanumeric id of moved item.\n */\n itemId: string;\n /**\n * Name of owner of item.\n */\n owner: string;\n /**\n * Alphanumeric id of folder now housing item.\n */\n folder: string;\n}\n\n/**\n * Serialize an item and its data into a json format accepted by the Portal API for create and update operations\n *\n * @param item Item to be serialized\n * @returns a formatted json object to be sent to Portal\n */\nexport function serializeItem(item: IItemAdd | IItemUpdate | IItem): any {\n // create a clone so we're not messing with the original\n const clone = JSON.parse(JSON.stringify(item));\n\n // binary data needs POSTed as a `file`\n // JSON object literals should be passed as `text`.\n if (clone.data) {\n (typeof Blob !== \"undefined\" && item.data instanceof Blob) ||\n // Node.js doesn't implement Blob\n item.data.constructor.name === \"ReadStream\"\n ? (clone.file = item.data)\n : (clone.text = item.data);\n delete clone.data;\n }\n return clone;\n}\n\n/**\n * `requestOptions.owner` is given priority, `requestOptions.item.owner` will be checked next. If neither are present, `authentication.getUserName()` will be used instead.\n */\nexport function determineOwner(requestOptions: any): Promise<string> {\n if (requestOptions.owner) {\n return Promise.resolve(requestOptions.owner);\n } else if (requestOptions.item && requestOptions.item.owner) {\n return Promise.resolve(requestOptions.item.owner);\n } else if (\n requestOptions.authentication &&\n requestOptions.authentication.getUsername\n ) {\n return requestOptions.authentication.getUsername();\n } else {\n return Promise.reject(\n new Error(\n \"Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option.\"\n )\n );\n }\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItemUpdate } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n ICreateUpdateItemOptions,\n IMoveItemResponse,\n IItemInfoOptions,\n IItemResourceOptions,\n IItemInfoResponse,\n IItemResourceResponse,\n IUpdateItemResponse,\n serializeItem,\n determineOwner\n} from \"./helpers\";\n\nexport interface IUpdateItemOptions extends ICreateUpdateItemOptions {\n item: IItemUpdate;\n}\n\nexport interface IMoveItemOptions extends ICreateUpdateItemOptions {\n /**\n * Alphanumeric id of item to be moved.\n */\n itemId: string;\n /**\n * Alphanumeric id of folder to house moved item. If null, empty, or \"/\", the destination is the\n * root folder.\n */\n folderId?: string;\n}\n\n/**\n * ```js\n * import { updateItem } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItem({\n * item: {\n * id: \"3ef\",\n * description: \"A three hour tour\"\n * },\n * authentication\n * })\n * .then(response)\n * ```\n * Update an Item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-item.htm) for more information.\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that updates an item.\n */\nexport function updateItem(\n requestOptions: IUpdateItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = requestOptions.folderId\n ? `${getPortalUrl(requestOptions)}/content/users/${owner}/${requestOptions.folderId}/items/${requestOptions.item.id}/update`\n : `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${requestOptions.item.id}/update`;\n\n // serialize the item into something Portal will accept\n requestOptions.params = {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n };\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { updateItemInfo } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItemInfo({\n * id: '3ef',\n * file: file,\n * authentication\n * })\n * .then(response)\n * ```\n * Update an info file associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-info.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that updates an item info file.\n */\nexport function updateItemInfo(\n requestOptions: IItemInfoOptions\n): Promise<IItemInfoResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions as IRequestOptions\n )}/content/users/${owner}/items/${requestOptions.id}/updateinfo`;\n\n // mix in user supplied params\n requestOptions.params = {\n folderName: requestOptions.folderName,\n file: requestOptions.file,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { updateItemResource } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItemResource({\n * id: '3ef',\n * resource: file,\n * name: 'bigkahuna.jpg',\n * authentication\n * })\n * .then(response)\n * ```\n * Update a resource associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-resources.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that updates an item resource.\n */\nexport function updateItemResource(\n requestOptions: IItemResourceOptions\n): Promise<IItemResourceResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions as IRequestOptions\n )}/content/users/${owner}/items/${requestOptions.id}/updateResources`;\n\n // mix in user supplied params\n requestOptions.params = {\n file: requestOptions.resource,\n fileName: requestOptions.name,\n resourcesPrefix: requestOptions.prefix,\n text: requestOptions.content,\n ...requestOptions.params\n };\n\n // only override the access specified previously if 'private' is passed explicitly\n if (typeof requestOptions.private !== \"undefined\") {\n requestOptions.params.access = requestOptions.private\n ? \"private\"\n : \"inherit\";\n }\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { moveItem } from \"@esri/arcgis-rest-portal\";\n * //\n * moveItem({\n * itemId: \"3ef\",\n * folderId: \"7c5\",\n * authentication: userSession\n * })\n * ```\n * Move an item to a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/move-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that resolves with owner and folder details once the move has been completed\n */\nexport function moveItem(\n requestOptions: IMoveItemOptions\n): Promise<IMoveItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.itemId\n }/move`;\n\n let folderId = requestOptions.folderId;\n if (!folderId) {\n folderId = \"/\";\n }\n requestOptions.params = {\n folder: folderId,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IItemResourceOptions,\n IUpdateItemResponse,\n IItemResourceResponse,\n determineOwner,\n IManageItemRelationshipOptions\n} from \"./helpers\";\nimport { updateItem, IUpdateItemOptions } from \"./update\";\n\nexport interface IAddItemDataOptions extends IUserItemOptions {\n /**\n * Object to store\n */\n data: any;\n}\n\n/**\n * ```js\n * import { addItemData } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemData({\n * id: '3ef',\n * data: file,\n * authentication\n * })\n * .then(response)\n * ```\n * Send a file or blob to an item to be stored as the `/data` resource. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with an object reporting\n * success/failure and echoing the item id.\n */\nexport function addItemData(\n requestOptions: IAddItemDataOptions\n): Promise<IUpdateItemResponse> {\n const options: any = {\n item: {\n id: requestOptions.id,\n data: requestOptions.data\n },\n ...requestOptions\n };\n\n delete options.id;\n delete options.data;\n\n return updateItem(options as IUpdateItemOptions);\n}\n\n/**\n * ```js\n * import { addItemRelationship } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemRelationship({\n * originItemId: '3ef',\n * destinationItemId: 'ae7',\n * relationshipType: 'Service2Layer',\n * authentication\n * })\n * .then(response)\n * ```\n * Add a relationship between two items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-relationship.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function addItemRelationship(\n requestOptions: IManageItemRelationshipOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${owner}/addRelationship`;\n\n const options = appendCustomParams<IManageItemRelationshipOptions>(\n requestOptions,\n [\"originItemId\", \"destinationItemId\", \"relationshipType\"],\n { params: { ...requestOptions.params } }\n );\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { addItemResource } from \"@esri/arcgis-rest-portal\";\n * //\n * // Add a file resource\n * addItemResource({\n * id: '3ef',\n * resource: file,\n * name: 'bigkahuna.jpg',\n * authentication\n * })\n * .then(response)\n * //\n * // Add a text resource\n * addItemResource({\n * id: '4fg',\n * content: \"Text content\",\n * name: 'bigkahuna.txt',\n * authentication\n * })\n * .then(response)\n * ```\n * Add a resource associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function addItemResource(\n requestOptions: IItemResourceOptions\n): Promise<IItemResourceResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/addResources`;\n\n requestOptions.params = {\n file: requestOptions.resource,\n fileName: requestOptions.name,\n resourcesPrefix: requestOptions.prefix,\n text: requestOptions.content,\n access: requestOptions.private ? \"private\" : \"inherit\",\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n","import { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport {\n IPagingParams,\n IItem,\n IFolder,\n IPagedResponse,\n} from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { determineOwner } from \"./helpers\";\n\nexport type UnixTime = number;\n\nexport interface IUserContentRequestOptions\n extends IPagingParams,\n IRequestOptions {\n owner?: string;\n folderId?: string;\n}\n\nexport interface IUserContentResponse extends IPagedResponse {\n username: string;\n currentFolder?: IFolder;\n items: IItem[];\n folders: IFolder[];\n}\n\n/**\n * ```js\n * import { getUserContent } from \"@esri/arcgis-rest-portal\";\n * //\n * getUserContent({\n * owner: 'geemike',\n * folderId: 'bao7',\n * start: 1,\n * num: 20,\n * authentication\n * })\n * ```\n * Returns a listing of the user's content. If the `username` is not supplied, it defaults to the username of the authenticated user. If `start` is not specificed it defaults to the first page.\n * If the `num` is not supplied it is defaulted to 10. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-content.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise<IUserContentResponse>\n */\nexport const getUserContent = (\n requestOptions: IUserContentRequestOptions\n): Promise<IUserContentResponse> => {\n const {\n folderId: folder,\n start = 1,\n num = 10,\n authentication,\n } = requestOptions;\n const suffix = folder ? `/${folder}` : \"\";\n\n return determineOwner(requestOptions)\n .then((owner) => `${getPortalUrl(requestOptions)}/content/users/${owner}${suffix}`)\n .then((url) => request(url, {\n httpMethod: \"GET\",\n authentication,\n params: {\n start,\n num,\n },\n })\n );\n};\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IAddFolderResponse,\n IUpdateItemResponse,\n ICreateUpdateItemOptions,\n serializeItem,\n determineOwner\n} from \"./helpers\";\n\nexport interface ICreateFolderOptions extends ICreateUpdateItemOptions {\n /**\n * Name of the folder to create.\n */\n title: string;\n}\n\nexport interface ICreateItemOptions extends ICreateUpdateItemOptions {\n item: IItemAdd;\n}\n\nexport interface ICreateItemResponse extends IUpdateItemResponse {\n folder: string;\n}\n\n/**\n * ```js\n * import { createFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * createFolder({\n * title: 'Map Collection',\n * authentication: userSession\n * })\n * .then(response)\n * ```\n * Create a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/create-folder.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that resolves with folder details once the folder has been created\n */\nexport function createFolder(\n requestOptions: ICreateFolderOptions\n): Promise<IAddFolderResponse> {\n return determineOwner(requestOptions).then(owner => {\n const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;\n const url = `${baseUrl}/createFolder`;\n\n requestOptions.params = {\n title: requestOptions.title,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { createItemInFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * createItemInFolder({\n * item: {\n * title: \"The Amazing Voyage\",\n * type: \"Web Map\"\n * },\n * folderId: 'fe8',\n * authentication\n * })\n * ```\n * Create an item in a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item.htm) for more information.\n *\n * @param requestOptions = Options for the request\n */\nexport function createItemInFolder(\n requestOptions: ICreateItemOptions\n): Promise<ICreateItemResponse> {\n if (requestOptions.multipart && !requestOptions.filename) {\n return Promise.reject(\n new Error(\"The filename is required for a multipart request.\")\n );\n }\n\n return determineOwner(requestOptions).then(owner => {\n const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;\n let url = `${baseUrl}/addItem`;\n\n if (requestOptions.folderId) {\n url = `${baseUrl}/${requestOptions.folderId}/addItem`;\n }\n\n requestOptions.params = {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n };\n\n // serialize the item into something Portal will accept\n const options = appendCustomParams<ICreateItemOptions>(\n requestOptions,\n [\n \"owner\",\n \"folderId\",\n \"file\",\n \"dataUrl\",\n \"text\",\n \"async\",\n \"multipart\",\n \"filename\",\n \"overwrite\"\n ],\n {\n params: { ...requestOptions.params }\n }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { createItem } from \"@esri/arcgis-rest-portal\";\n * //\n * createItem({\n * item: {\n * title: \"The Amazing Voyage\",\n * type: \"Web Map\"\n * },\n * authentication\n * })\n * ```\n * Create an Item in the user's root folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that creates an item.\n */\nexport function createItem(\n requestOptions: ICreateItemOptions\n): Promise<ICreateItemResponse> {\n // delegate to createItemInFolder placing in the root of the filestore\n const options = {\n folderId: null,\n ...requestOptions\n } as ICreateItemOptions;\n return createItemInFolder(options);\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { determineOwner, IUserItemOptions } from './helpers';\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { ISpatialReference } from '@esri/arcgis-rest-types';\n\ntype ExportFormat = 'Shapefile' | 'CSV' | 'File Geodatabase' | 'Feature Collection' | 'GeoJson' | 'Scene Package' | 'KML' | 'Excel';\n\nexport interface IExportLayerInfo {\n id: number;\n where?: string;\n includeGeometry?: boolean;\n xColumnName?: string;\n yColumnName?: string;\n}\n\nexport interface IExportParameters {\n layers?: IExportLayerInfo[];\n targetSR?: ISpatialReference | string;\n}\n\nexport interface IExportItemRequestOptions extends IUserItemOptions {\n title?: string;\n exportFormat: ExportFormat;\n exportParameters?: IExportParameters;\n}\n\nexport interface IExportItemResponse {\n type: string;\n size: number;\n jobId: string;\n exportItemId: string;\n serviceItemId: string;\n exportFormat: ExportFormat;\n}\n\n/**\n * ```js\n * import { exportItem } from \"@esri/arcgis-rest-portal\";\n * //\n * exportItem({\n * id: '3daf',\n * owner: 'geemike',\n * exportFormat: 'CSV',\n * exportParameters: {\n * layers: [\n * { id: 0 },\n * { id: 1, where: 'POP1999 > 100000' }\n * ]\n * },\n * authentication,\n * })\n * ```\n * Exports an item from the portal. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/export-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise<IExportItemResponse>\n */\nexport const exportItem = (requestOptions: IExportItemRequestOptions) : Promise<IExportItemResponse> => {\n const {\n authentication,\n id: itemId,\n title,\n exportFormat,\n exportParameters\n } = requestOptions;\n\n return determineOwner(requestOptions)\n .then(owner => `${getPortalUrl(requestOptions)}/content/users/${owner}/export`)\n .then(url => request(url, {\n httpMethod: 'POST',\n authentication,\n params: {\n itemId,\n title,\n exportFormat,\n exportParameters\n }\n })\n );\n}\n","// eslint-disable-next-line no-control-regex\nconst CONTROL_CHAR_MATCHER = /[\\x00-\\x1F\\x7F-\\x9F\\xA0]/g;\n\n/**\n * Returns a new string with all control characters removed.\n *\n * Doesn't remove characters from input string.\n *\n * @param str - the string to scrub\n */\nexport function scrubControlChars (str: string) {\n return str.replace(CONTROL_CHAR_MATCHER, \"\");\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\nimport { IItem, IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { scrubControlChars } from '../util/scrub-control-chars';\nimport {\n IItemDataOptions,\n IItemRelationshipOptions,\n IUserItemOptions,\n determineOwner,\n FetchReadMethodName\n} from \"./helpers\";\n\n/**\n * ```\n * import { getItem } from \"@esri/arcgis-rest-portal\";\n * //\n * getItem(\"ae7\")\n * .then(response);\n * // or\n * getItem(\"ae7\", { authentication })\n * .then(response)\n * ```\n * Get an item by id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item.htm) for more information.\n *\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function getItem(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IItem> {\n const url = getItemBaseUrl(id, requestOptions);\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Get the fully qualified base URL to the REST end point for an item.\n * @param id Item Id\n * @param portalUrlOrRequestOptions a portal URL or request options\n * @returns URL to the item's REST end point, defaults to `https://www.arcgis.com/sharing/rest/content/items/{id}`\n */\nexport const getItemBaseUrl = (\n id: string,\n portalUrlOrRequestOptions?: string | IRequestOptions\n) => {\n const portalUrl =\n typeof portalUrlOrRequestOptions === \"string\"\n ? portalUrlOrRequestOptions\n : getPortalUrl(portalUrlOrRequestOptions);\n return `${portalUrl}/content/items/${id}`;\n};\n\n/**\n * ```\n * import { getItemData } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemData(\"ae7\")\n * .then(response)\n * // or\n * getItemData(\"ae7\", { authentication })\n * .then(response)\n * ```\n * Get the /data for an item. If no data exists, returns `undefined`. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item-data.htm) for more information.\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the json data for the item.\n */\nexport function getItemData(\n id: string,\n requestOptions?: IItemDataOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}/data`;\n // default to a GET request\n const options: IItemDataOptions = {\n ...{ httpMethod: \"GET\", params: {} },\n ...requestOptions\n };\n\n if (options.file) {\n options.params.f = null;\n }\n\n return request(url, options).catch(err => {\n /* if the item doesn't include data, the response will be empty\n and the internal call to response.json() will fail */\n const emptyResponseErr = RegExp(\n /The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i\n );\n /* istanbul ignore else */\n if (emptyResponseErr.test(err.message)) {\n return;\n } else throw err;\n });\n}\n\nexport interface IGetRelatedItemsResponse {\n total: number;\n relatedItems: IItem[];\n}\n\n/**\n * ```\n * import { getRelatedItems } from \"@esri/arcgis-rest-portal\";\n * //\n * getRelatedItems({\n * id: \"ae7\",\n * relationshipType: \"Service2Layer\" // or several [\"Service2Layer\", \"Map2Area\"]\n * })\n * .then(response)\n * ```\n * Get the related items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/related-items.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item resources.\n */\nexport function getRelatedItems(\n requestOptions: IItemRelationshipOptions\n): Promise<IGetRelatedItemsResponse> {\n const url = `${getItemBaseUrl(\n requestOptions.id,\n requestOptions\n )}/relatedItems`;\n\n const options: IItemRelationshipOptions = {\n httpMethod: \"GET\",\n params: {\n direction: requestOptions.direction\n },\n ...requestOptions\n };\n\n if (typeof requestOptions.relationshipType === \"string\") {\n options.params.relationshipType = requestOptions.relationshipType;\n } else {\n options.params.relationshipTypes = requestOptions.relationshipType;\n }\n\n delete options.direction;\n delete options.relationshipType;\n\n return request(url, options);\n}\n\n/**\n * Get the resources associated with an item\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item resources.\n */\nexport function getItemResources(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}/resources`;\n\n // Mix in num:1000 with any user supplied params\n // Key thing - we don't want to mutate the passed in requestOptions\n // as that may be used in other (subsequent) calls in the course\n // of a long promise chains\n const options: IRequestOptions = {\n ...requestOptions\n };\n options.params = { num: 1000, ...options.params };\n\n return request(url, options);\n}\n\nexport interface IGetItemGroupsResponse {\n admin?: IGroup[];\n member?: IGroup[];\n other?: IGroup[];\n}\n\nexport interface IGetItemResourceOptions extends IRequestOptions {\n /**\n * Name of the info file, optionally including the folder path\n */\n fileName: string;\n /**\n * How the fetch response should be read, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\n readAs?: FetchReadMethodName;\n}\n\n/**\n * ```js\n * import { getItemResource } from \"@esri/arcgis-rest-portal\";\n *\n * // Parses contents as blob by default\n * getItemResource(\"3ef\", { fileName: \"resource.jpg\", ...})\n * .then(resourceContents => {});\n *\n * // Can override parse method\n * getItemResource(\"3ef\", { fileName: \"resource.json\", readAs: 'json', ...})\n * .then(resourceContents => {});\n *\n * // Get the response object instead\n * getItemResource(\"3ef\",{ rawResponse: true, fileName: \"resource.json\" })\n * .then(response => {})\n * ```\n * Fetches an item resource and optionally parses it to the correct format.\n *\n * Note: provides JSON parse error protection by sanitizing out any unescaped control\n * characters before parsing that would otherwise cause an error to be thrown\n *\n * @param {string} itemId\n * @param {IGetItemResourceOptions} requestOptions\n */\nexport function getItemResource(\n itemId: string,\n requestOptions: IGetItemResourceOptions\n) {\n const readAs = requestOptions.readAs || 'blob';\n return getItemFile(itemId, `/resources/${requestOptions.fileName}`, readAs, requestOptions);\n}\n\n\n/**\n * ```js\n * import { getItemGroups } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemGroups(\"30e5fe3149c34df1ba922e6f5bbf808f\")\n * .then(response)\n * ```\n * Lists the groups of which the item is a part, only showing the groups that the calling user can access. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/groups.htm) for more information.\n *\n * @param id - The Id of the item to query group association for.\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item groups.\n */\nexport function getItemGroups(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGetItemGroupsResponse> {\n const url = `${getItemBaseUrl(id, requestOptions)}/groups`;\n\n return request(url, requestOptions);\n}\n\nexport interface IItemStatusOptions extends IUserItemOptions {\n /**\n * The type of asynchronous job for which the status has to be checked. Default is none, which check the item's status.\n */\n jobType?: \"publish\" | \"generateFeatures\" | \"export\" | \"createService\";\n /**\n * The job ID returned during publish, generateFeatures, export, and createService calls.\n */\n jobId?: string;\n /**\n * The response format. The default and the only response format for this resource is HTML.\n */\n format?: \"html\";\n}\n\nexport interface IGetItemStatusResponse {\n status: \"partial\" | \"processing\" | \"failed\" | \"completed\";\n statusMessage: string;\n itemId: string;\n}\n\n/**\n * ```js\n * import { getItemStatus } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemStatus({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Inquire about status when publishing an item, adding an item in async mode, or adding with a multipart upload. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/status.htm) for more information.\n *\n * @param id - The Id of the item to get status for.\n * @param requestOptions - Options for the request\n * @returns A Promise to get the item status.\n */\nexport function getItemStatus(\n requestOptions: IItemStatusOptions\n): Promise<IGetItemStatusResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/status`;\n\n const options = appendCustomParams<IItemStatusOptions>(\n requestOptions,\n [\"jobId\", \"jobType\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\nexport interface IGetItemPartsResponse {\n parts: number[];\n}\n\n/**\n * ```js\n * import { getItemParts } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemParts({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Lists the part numbers of the file parts that have already been uploaded in a multipart file upload. This method can be used to verify the parts that have been received as well as those parts that were not received by the server. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/parts.htm) for more information.\n *\n * @param id - The Id of the item to get part list.\n * @param requestOptions - Options for the request\n * @returns A Promise to get the item part list.\n */\nexport function getItemParts(\n requestOptions: IUserItemOptions\n): Promise<IGetItemPartsResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/parts`;\n return request(url, requestOptions);\n });\n}\n\nexport interface IGetItemInfoOptions extends IRequestOptions {\n /**\n * Name of the info file, optionally including the folder path\n */\n fileName?: string;\n /**\n * How the fetch response should be read, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\n readAs?: FetchReadMethodName;\n}\n\n/**\n * ```\n * import { getItemInfo } from \"@esri/arcgis-rest-portal\";\n * // get the \"Info Card\" for the item\n * getItemInfo(\"ae7\")\n * .then(itemInfoXml) // XML document as a string\n * // or get the contents of a specific file\n * getItemInfo(\"ae7\", { fileName: \"form.json\", readAs: \"json\", authentication })\n * .then(formJson) // JSON document as JSON\n * ```\n * Get an info file for an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item-info-file.htm) for more information.\n * @param id - Item Id\n * @param requestOptions - Options for the request, including the file name which defaults to `iteminfo.xml`.\n * If the file is not a text file (XML, HTML, etc) you will need to specify the `readAs` parameter\n * @returns A Promise that will resolve with the contents of the info file for the item.\n */\nexport function getItemInfo(\n id: string,\n requestOptions?: IGetItemInfoOptions\n): Promise<any> {\n const { fileName = \"iteminfo.xml\", readAs = \"text\" } = requestOptions || {};\n const options: IRequestOptions = {\n httpMethod: \"GET\",\n ...requestOptions\n };\n return getItemFile(id, `/info/${fileName}`, readAs, options);\n}\n\n/**\n * ```\n * import { getItemMetadata } from \"@esri/arcgis-rest-portal\";\n * // get the metadata for the item\n * getItemMetadata(\"ae7\")\n * .then(itemMetadataXml) // XML document as a string\n * // or with additional request options\n * getItemMetadata(\"ae7\", { authentication })\n * .then(itemMetadataXml) // XML document as a string\n * ```\n * Get the standard formal metadata XML file for an item (`/info/metadata/metadata.xml`)\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the contents of the metadata file for the item as a string.\n */\nexport function getItemMetadata(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const options = {\n ...requestOptions,\n fileName: \"metadata/metadata.xml\"\n } as IGetItemInfoOptions;\n return getItemInfo(id, options);\n}\n\n// overrides request()'s default behavior for reading the response\n// which is based on `params.f` and defaults to JSON\n// Also adds JSON parse error protection by sanitizing out any unescaped control characters before parsing\nfunction getItemFile(\n id: string,\n // NOTE: fileName should include any folder/subfolders\n fileName: string,\n readMethod: FetchReadMethodName,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}${fileName}`;\n // preserve escape hatch to let the consumer read the response\n // and ensure the f param is not appended to the query string\n const options: IRequestOptions = {\n params: {},\n ...requestOptions\n };\n const justReturnResponse = options.rawResponse;\n options.rawResponse = true;\n options.params.f = null;\n\n return request(url, options).then(response => {\n if (justReturnResponse) {\n return response;\n }\n return readMethod !== 'json'\n ? response[readMethod]()\n : response.text().then((text: string) => JSON.parse(scrubControlChars(text)));\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserItemOptions, determineOwner } from \"./helpers\";\n\n/**\n * Protect an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/protect.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to protect an item.\n */\nexport function protectItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/protect`;\n return request(url, requestOptions);\n });\n}\n\n/**\n * Unprotect an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unprotect.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to unprotect an item.\n */\nexport function unprotectItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/unprotect`;\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\nimport { IPagingParams, IGroup, IItem, IUser } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IGroupCategorySchema {\n categorySchema: IGroupCategory[];\n}\n\nexport interface IGroupCategory {\n title: string;\n description?: string;\n categories?: IGroupCategory[];\n}\n\nexport interface IGetGroupContentOptions extends IRequestOptions {\n paging: IPagingParams;\n}\n\nexport interface IGroupContentResult {\n total: number;\n start: number;\n num: number;\n nextStart: number;\n items: IItem[];\n}\n\nexport interface IGroupUsersResult {\n owner: string;\n admins: string[];\n users: string[];\n}\n\n/**\n * ```js\n * import { getGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * getGroup(\"fxb988\") // id\n * .then(response)\n * ```\n * Fetch a group using its id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group.htm) for more information.\n *\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function getGroup(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroup> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}`;\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Gets the category schema set on a group\n *\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A promise that will resolve with JSON of group's category schema\n * @see https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm\n */\nexport function getGroupCategorySchema(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroupCategorySchema> {\n const url = `${getPortalUrl(\n requestOptions\n )}/community/groups/${id}/categorySchema`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Returns the content of a Group. Since the group may contain 1000s of items\n * the requestParams allow for paging.\n * @param id - Group Id\n * @param requestOptions - Options for the request, including paging parameters.\n * @returns A Promise that will resolve with the content of the group.\n */\nexport function getGroupContent(\n id: string,\n requestOptions?: IGetGroupContentOptions\n): Promise<IGroupContentResult> {\n const url = `${getPortalUrl(requestOptions)}/content/groups/${id}`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n params: { start: 1, num: 100 },\n ...requestOptions\n } as IGetGroupContentOptions;\n\n // is this the most concise way to mixin with the defaults above?\n if (requestOptions && requestOptions.paging) {\n options.params = { ...requestOptions.paging };\n }\n\n return request(url, options);\n}\n\n/**\n * Get the usernames of the admins and members. Does not return actual 'User' objects. Those must be\n * retrieved via separate calls to the User's API.\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with arrays of the group admin usernames and the member usernames\n */\nexport function getGroupUsers(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroupUsersResult> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/users`;\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\nexport interface ISearchGroupUsersOptions\n extends IRequestOptions,\n IPagingParams {\n name?: string;\n sortField?: string;\n sortOrder?: string;\n joined?: number | number[];\n memberType?: string;\n [key: string]: any;\n}\n\nexport interface ISearchGroupUsersResult {\n total: number;\n start: number;\n num: number;\n nextStart: number;\n owner: IUser;\n users: any[];\n}\n\n/**\n * ```js\n * import { searchGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroupUsers('abc123')\n * .then(response)\n * ```\n * Search the users in a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-users-list.htm) for more information.\n *\n * @param id - The group id\n * @param searchOptions - Options for the request, including paging parameters.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroupUsers(\n id: string,\n searchOptions?: ISearchGroupUsersOptions\n): Promise<ISearchGroupUsersResult> {\n const url = `${getPortalUrl(searchOptions)}/community/groups/${id}/userlist`;\n const options = appendCustomParams<ISearchGroupUsersOptions>(\n searchOptions || {},\n [\"name\", \"num\", \"start\", \"sortField\", \"sortOrder\", \"joined\", \"memberType\"],\n {\n httpMethod: \"GET\"\n }\n );\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IGroup, IUser, GroupMembership } from \"@esri/arcgis-rest-types\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { getGroup } from \"../groups/get\";\n\nexport interface ISharingOptions extends IUserRequestOptions {\n /**\n * Unique identifier for the item.\n */\n id: string;\n /**\n * Item owner, if different from the authenticated user.\n */\n owner?: string;\n}\n\nexport interface ISharingResponse {\n notSharedWith?: string[];\n notUnsharedFrom?: string[];\n itemId: string;\n}\n\nexport function getSharingUrl(requestOptions: ISharingOptions): string {\n const username = requestOptions.authentication.username;\n const owner = requestOptions.owner || username;\n return `${getPortalUrl(requestOptions)}/content/users/${encodeURIComponent(\n owner\n )}/items/${requestOptions.id}/share`;\n}\n\nexport function isItemOwner(requestOptions: ISharingOptions): boolean {\n const username = requestOptions.authentication.username;\n const owner = requestOptions.owner || username;\n return owner === username;\n}\n\n/**\n * Check it the user is a full org_admin\n * @param requestOptions\n * @returns Promise resolving in a boolean indicating if the user is an ArcGIS Organization administrator\n */\nexport function isOrgAdmin(\n requestOptions: IUserRequestOptions\n): Promise<boolean> {\n const session = requestOptions.authentication;\n\n return session.getUser(requestOptions).then((user: IUser) => {\n return user && user.role === \"org_admin\" && !user.roleId;\n });\n}\n\n/**\n * Get the User Membership for a particular group. Use this if all you have is the groupId.\n * If you have the group object, check the `userMembership.memberType` property instead of calling this method.\n *\n * @param requestOptions\n * @returns A Promise that resolves with \"owner\" | \"admin\" | \"member\" | \"nonmember\"\n */\nexport function getUserMembership(\n requestOptions: IGroupSharingOptions\n): Promise<GroupMembership> {\n // fetch the group...\n return getGroup(requestOptions.groupId, requestOptions)\n .then((group: IGroup) => {\n return group.userMembership.memberType;\n })\n .catch(() => {\n return \"none\" as GroupMembership;\n });\n}\n\nexport interface IGroupSharingOptions extends ISharingOptions {\n /**\n * Group identifier\n */\n groupId: string;\n confirmItemControl?: boolean;\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItem } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { isOrgAdmin } from \"../sharing/helpers\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\ninterface IReassignItemOptions extends IUserRequestOptions {\n id: string;\n currentOwner: string;\n targetUsername: string;\n targetFolderName?: string;\n}\n\ninterface IReassignItemResponse {\n success: boolean;\n itemId: string;\n}\n\n/**\n * ```js\n * import { reassignItem } from '@esri/arcgis-rest-portal';\n * //\n * reassignItem({\n * id: \"abc123\",\n * currentOwner: \"charles\",\n * targetUsername: \"leslie\",\n * authentication\n * })\n * ```\n * Reassign an item from one user to another.\n * Caller must be an org admin or the request will fail.\n * `currentOwner` and `targetUsername` must be in the same\n * organization or the request will fail\n * @param reassignOptions - Options for the request\n */\nexport function reassignItem(\n reassignOptions: IReassignItemOptions\n): Promise<IReassignItemResponse> {\n return isOrgAdmin(reassignOptions).then(isAdmin => {\n if (!isAdmin) {\n throw Error(\n `Item ${reassignOptions.id} can not be reassigned because current user is not an organization administrator.`\n );\n }\n // we're operating as an org-admin\n const url = `${getPortalUrl(reassignOptions)}/content/users/${\n reassignOptions.currentOwner\n }/items/${reassignOptions.id}/reassign`;\n\n const opts = {\n params: {\n targetUsername: reassignOptions.targetUsername,\n targetFolderName: reassignOptions.targetFolderName\n },\n authentication: reassignOptions.authentication\n };\n return request(url, opts);\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IRemoveItemResourceOptions,\n IFolderIdOptions,\n determineOwner,\n IManageItemRelationshipOptions\n} from \"./helpers\";\n\n/**\n * ```js\n * import { removeItem } from \"@esri/arcgis-rest-portal\";\n * //\n * removeItem({\n * id: \"3ef\",\n * authentication\n * })\n * ```\n * Delete an item from the portal. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes an item.\n */\nexport function removeItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean; itemId: string }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/delete`;\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { removeItemRelationship } from \"@esri/arcgis-rest-portal\";\n * //\n * removeItemRelationship({\n * originItemId: '3ef',\n * destinationItemId: 'ae7',\n * relationshipType: 'Service2Layer',\n * authentication\n * })\n * .then(response)\n * ```\n * Remove a relationship between two items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-relationship.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function removeItemRelationship(\n requestOptions: IManageItemRelationshipOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${owner}/deleteRelationship`;\n\n const options = appendCustomParams<IManageItemRelationshipOptions>(\n requestOptions,\n [\"originItemId\", \"destinationItemId\", \"relationshipType\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * Remove a resource associated with an item\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes an item resource.\n */\nexport function removeItemResource(\n requestOptions: IRemoveItemResourceOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/removeResources`;\n\n // mix in user supplied params\n requestOptions.params = {\n ...requestOptions.params,\n resource: requestOptions.resource\n };\n\n // only override the deleteAll param specified previously if it is passed explicitly\n if (typeof requestOptions.deleteAll !== \"undefined\") {\n requestOptions.params.deleteAll = requestOptions.deleteAll;\n }\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { removeFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * removeFolder({\n * folderId: \"fe4\",\n * owner: \"c@sey\",\n * authentication\n * })\n * .then(response)\n *\n * ```\n * Delete a non-root folder and all the items it contains. See the [REST\n * Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-folder.htm) for\n * more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes a folder\n */\nexport function removeFolder(\n requestOptions: IFolderIdOptions\n): Promise<{\n success: boolean;\n folder: {\n username: string;\n id: string;\n title: string;\n };\n}> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${encodeURIComponent(owner)}/${\n requestOptions.folderId\n }/delete`;\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2018-2021 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IParamBuilder, warn } from \"@esri/arcgis-rest-request\";\n\n/**\n * `SearchQueryBuilder` can be used to construct the `q` param for\n * [`searchItems`](/arcgis-rest-js/api/portal/searchItems#searchItems-search) or\n * [`searchGroups`](/arcgis-rest-js/api/portal/searchGroups#searchGroups-search).\n * By chaining methods, it helps build complex search queries.\n *\n * ```js\n * const startDate = new Date(\"2020-01-01\");\n * const endDate = new Date(\"2020-09-01\");\n * const query = new SearchQueryBuilder()\n * .match(\"Patrick\")\n * .in(\"owner\")\n * .and()\n * .from(startDate)\n * .to(endDate)\n * .in(\"created\")\n * .and()\n * .startGroup()\n * .match(\"Web Mapping Application\")\n * .in(\"type\")\n * .or()\n * .match(\"Mobile Application\")\n * .in(\"type\")\n * .or()\n * .match(\"Application\")\n * .in(\"type\")\n * .endGroup()\n * .and()\n * .match(\"Demo App\");\n *\n * searchItems(query).then((res) => {\n * console.log(res.results);\n * });\n * ```\n *\n * Will search for items matching\n * ```\n * \"owner: Patrick AND created:[1577836800000 TO 1598918400000] AND (type:\"Web Mapping Application\" OR type:\"Mobile Application\" OR type:Application) AND Demo App\"\n * ```\n */\nexport class SearchQueryBuilder implements IParamBuilder {\n private termStack: any[] = [];\n private rangeStack: any[] = [];\n private q: string;\n private openGroups = 0;\n private currentModifer: string;\n\n /**\n * @param q An existing query string to start building from.\n */\n constructor(q = \"\") {\n this.q = q;\n }\n\n /**\n * Defines strings to search for.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"My Layer\")\n * ```\n *\n * @param terms strings to search for.\n */\n public match(this: SearchQueryBuilder, ...terms: string[]) {\n this.termStack = this.termStack.concat(terms);\n return this;\n }\n\n /**\n * Defines fields to search in. You can pass `\"*\"` or call this method without arguments to search a default set of fields\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"My Layer\")\n * .in(\"title\")\n * ```\n *\n * @param field The field to search for the previous match in.\n */\n public in(this: SearchQueryBuilder, field?: string) {\n const fn = `\\`in(${field ? `\"${field}\"` : \"\"})\\``;\n\n if (!this.hasRange && !this.hasTerms) {\n warn(\n // apparently-p-rettier-ignore causes some\n `${fn} was called with no call to \\`match(...)\\` or \\`from(...)\\`/\\`to(...)\\`. Your query was not modified.`\n );\n return this;\n }\n\n if (field && field !== \"*\") {\n this.q += `${field}:`;\n }\n\n return this.commit();\n }\n\n /**\n * Starts a new search group.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .startGroup()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .endGroup()\n * .or()\n * .startGroup()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .endGroup()\n * ```\n */\n public startGroup(this: SearchQueryBuilder) {\n this.commit();\n if (this.openGroups > 0) {\n this.q += \" \";\n }\n this.openGroups++;\n this.q += \"(\";\n return this;\n }\n\n /**\n * Ends a search group.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .startGroup()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .endGroup()\n * .or()\n * .startGroup()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .endGroup()\n * ```\n */\n public endGroup(this: SearchQueryBuilder) {\n if (this.openGroups <= 0) {\n warn(\n `\\`endGroup(...)\\` was called without calling \\`startGroup(...)\\` first. Your query was not modified.`\n );\n return this;\n }\n this.commit();\n this.openGroups--;\n this.q += \")\";\n return this;\n }\n\n /**\n * Joins two sets of queries with an `AND` clause.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .and()\n * .match(\"Rivers\")\n * .in(\"title\")\n * ```\n */\n public and(this: SearchQueryBuilder) {\n return this.addModifier(\"and\");\n }\n\n /**\n * Joins two sets of queries with an `OR` clause.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .or()\n * .match(\"Rivers\")\n * .in(\"title\")\n * ```\n */\n public or(this: SearchQueryBuilder) {\n return this.addModifier(\"or\");\n }\n\n /**\n * Joins two sets of queries with a `NOT` clause. Another option for filtering results is the [prohibit operator '-'](https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm#ESRI_SECTION1_5C6C35DB9E4A4F4492C5B937BDA2BF67).\n *\n * ```js\n * // omit results with \"Rivers\" in their title\n * const query = new SearchQueryBuilder()\n * .not()\n * .match(\"Rivers\")\n * .in(\"title\")\n *\n * // equivalent\n * const query = new SearchQueryBuilder()\n * .match(\"Rivers\")\n * .in(\"-title\")\n * ```\n */\n public not(this: SearchQueryBuilder) {\n return this.addModifier(\"not\");\n }\n\n /**\n * Begins a new range query.\n *\n * ```js\n *\n * const NEWYEARS = new Date(\"2020-01-01\")\n * const TODAY = new Date()\n *\n * const query = new SearchQueryBuilder()\n * .from(NEWYEARS)\n * .to(TODAY)\n * .in(\"created\")\n * ```\n */\n public from(this: SearchQueryBuilder, term: number | string | Date) {\n if (this.hasTerms) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `\\`from(...)\\` is not allowed after \\`match(...)\\` try using \\`.from(...).to(...).in(...)\\`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date(\"2020-01-01\"). Your query was not modified.`\n );\n return this;\n }\n this.rangeStack[0] = term;\n return this;\n }\n\n /**\n * Ends a range query.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .from(yesterdaysDate)\n * .to(todaysDate)\n * .in(\"created\")\n * ```\n */\n public to(this: SearchQueryBuilder, term: any) {\n if (this.hasTerms) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `\\`to(...)\\` is not allowed after \\`match(...)\\` try using \\`.from(...).to(...).in(...)\\`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date(\"2020-01-01\"). Your query was not modified.`\n );\n return this;\n }\n this.rangeStack[1] = term;\n return this;\n }\n\n /**\n * Boosts the previous term to increase its rank in the results.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .or()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .boost(3)\n * ```\n */\n public boost(this: SearchQueryBuilder, num: number) {\n this.commit();\n this.q += `^${num}`;\n return this;\n }\n\n /**\n * Returns the current query string. Called internally when the request is made.\n */\n public toParam() {\n this.commit();\n this.cleanup();\n return this.q;\n }\n\n /**\n * Returns a new instance of `SearchQueryBuilder` based on the current instance.\n */\n public clone() {\n this.commit();\n this.cleanup();\n return new SearchQueryBuilder(this.q + \"\");\n }\n\n private addModifier(modifier: string) {\n if (this.currentModifer) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `You have called \\`${this.currentModifer}()\\` after \\`${modifier}()\\`. Your current query was not modified.`\n );\n return this;\n }\n\n this.commit();\n\n if (this.q === \"\" && modifier !== \"not\") {\n warn(\n `You have called \\`${modifier}()\\` without calling another method to modify your query first. Try calling \\`match()\\` first.`\n );\n return this;\n }\n\n this.currentModifer = modifier;\n this.q += this.q === \"\" ? \"\" : \" \";\n this.q += `${modifier.toUpperCase()} `;\n return this;\n }\n\n private needsQuotes(s: string) {\n return /\\s|:/g.test(s);\n }\n\n private formatTerm(term: any) {\n if (term instanceof Date) {\n return term.getTime();\n }\n\n if (typeof term === \"string\" && this.needsQuotes(term)) {\n return `\"${term}\"`;\n }\n\n return term;\n }\n\n private commit() {\n this.currentModifer = undefined;\n if (this.hasRange) {\n this.q += `[${this.formatTerm(this.rangeStack[0])} TO ${this.formatTerm(\n this.rangeStack[1]\n )}]`;\n this.rangeStack = [undefined, undefined];\n }\n\n if (this.hasTerms) {\n this.q += this.termStack\n .map((term) => {\n return this.formatTerm(term);\n })\n .join(\" \");\n this.termStack = [];\n }\n\n return this;\n }\n\n private get hasTerms() {\n return this.termStack.length > 0;\n }\n\n private get hasRange() {\n return this.rangeStack.length && this.rangeStack[0] && this.rangeStack[1];\n }\n\n private cleanup() {\n // end a group if we have started one\n if (this.openGroups > 0) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `Automatically closing ${this.openGroups} group(s). You can use \\`endGroup(...)\\` to remove this warning.`\n );\n\n while (this.openGroups > 0) {\n this.q += \")\";\n this.openGroups--;\n }\n }\n\n const oldQ = this.q;\n this.q = oldQ.replace(/( AND ?| NOT ?| OR ?)*$/, \"\");\n\n if (oldQ !== this.q) {\n warn(\n `\\`startGroup(...)\\` was called without calling \\`endGroup(...)\\` first. Your query was not modified.`\n );\n }\n\n // clear empty groups\n this.q = this.q.replace(/(\\(\\))*/, \"\");\n }\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams,\n} from \"@esri/arcgis-rest-request\";\nimport { IItem, IGroup, IUser } from \"@esri/arcgis-rest-types\";\n\nimport { SearchQueryBuilder } from \"./SearchQueryBuilder\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n ISearchOptions,\n ISearchGroupContentOptions,\n ISearchResult,\n} from \"../util/search\";\n\nexport function genericSearch<T extends IItem | IGroup | IUser>(\n search:\n | string\n | ISearchOptions\n | ISearchGroupContentOptions\n | SearchQueryBuilder,\n searchType: \"item\" | \"group\" | \"groupContent\" | \"user\"\n): Promise<ISearchResult<T>> {\n let options: IRequestOptions;\n if (typeof search === \"string\" || search instanceof SearchQueryBuilder) {\n options = {\n httpMethod: \"GET\",\n params: {\n q: search,\n },\n };\n } else {\n // searchUserAccess has one (knonw) valid value: \"groupMember\"\n options = appendCustomParams<ISearchOptions>(\n search,\n [\n \"q\",\n \"num\",\n \"start\",\n \"sortField\",\n \"sortOrder\",\n \"searchUserAccess\",\n \"searchUserName\",\n \"filter\",\n \"countFields\",\n \"countSize\",\n \"categories\",\n \"categoryFilters\",\n ],\n {\n httpMethod: \"GET\",\n }\n );\n }\n\n let path;\n switch (searchType) {\n case \"item\":\n path = \"/search\";\n break;\n case \"group\":\n path = \"/community/groups\";\n break;\n case \"groupContent\":\n // Need to have groupId property to do group contents search,\n // cso filter out all but ISearchGroupContentOptions\n if (\n typeof search !== \"string\" &&\n !(search instanceof SearchQueryBuilder) &&\n search.groupId\n ) {\n path = `/content/groups/${search.groupId}/search`;\n } else {\n return Promise.reject(\n new Error(\"you must pass a `groupId` option to `searchGroupContent`\")\n );\n }\n break;\n default:\n // \"users\"\n path = \"/portals/self/users/search\";\n break;\n }\n const url = getPortalUrl(options) + path;\n\n // send the request\n return request(url, options).then((r) => {\n if (r.nextStart && r.nextStart !== -1) {\n r.nextPage = function () {\n let newOptions: ISearchOptions;\n\n if (\n typeof search === \"string\" ||\n search instanceof SearchQueryBuilder\n ) {\n newOptions = {\n q: search,\n start: r.nextStart,\n };\n } else {\n newOptions = search;\n newOptions.start = r.nextStart;\n }\n\n return genericSearch<T>(newOptions, searchType);\n };\n }\n\n return r;\n });\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IItem } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport { ISearchOptions, ISearchResult } from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n/**\n * ```js\n * import { searchItems } from \"@esri/arcgis-rest-portal\";\n * //\n * searchItems('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/search.htm) for more information.\n *\n * @param search - A string or RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchItems(\n search: string | ISearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IItem>> {\n return genericSearch<IItem>(search, \"item\");\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IUpdateItemResponse,\n determineOwner,\n IItemPartOptions,\n serializeItem\n} from \"./helpers\";\n\nexport interface ICommitItemOptions extends IUserItemOptions {\n item: IItemAdd;\n}\n\n/**\n * ```js\n * import { addItemPart } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemPart({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * file: data,\n * partNum: 1,\n * authentication\n * })\n * .then(response)\n * ```\n * Add Item Part allows the caller to upload a file part when doing an add or update item operation in multipart mode. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item-part.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add the item part status.\n */\nexport function addItemPart(\n requestOptions?: IItemPartOptions\n): Promise<IUpdateItemResponse> {\n const partNum = requestOptions.partNum;\n\n if (!Number.isInteger(partNum) || partNum < 1 || partNum > 10000) {\n return Promise.reject(new Error('The part number must be an integer between 1 to 10000, inclusive.'))\n }\n\n return determineOwner(requestOptions).then(owner => {\n // AGO adds the \"partNum\" parameter in the query string, not in the body\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/addPart?partNum=${partNum}`;\n\n const options = appendCustomParams<IItemPartOptions>(\n requestOptions,\n [\"file\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { commitItemUpload } from \"@esri/arcgis-rest-portal\";\n * //\n * commitItemUpload({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Commit is called once all parts are uploaded during a multipart Add Item or Update Item operation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/commit.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get the commit result.\n */\nexport function commitItemUpload(\n requestOptions?: ICommitItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/commit`;\n\n const options = appendCustomParams<ICommitItemOptions>(\n requestOptions,\n [],\n {\n params: {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n }\n }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { cancelItemUpload } from \"@esri/arcgis-rest-portal\";\n * //\n * cancelItemUpload({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Cancels a multipart upload on an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/cancel.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get the commit result.\n */\nexport function cancelItemUpload(\n requestOptions?: IUserItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/cancel`;\n\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport function chunk<T>(array: T[], size: number) {\n if (array.length === 0) {\n return [];\n }\n\n const chunks = [];\n\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size));\n }\n\n return chunks;\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IAddGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be added to the group as group members\n */\n users?: string[];\n /**\n * An array of usernames to be added to the group as group admins\n */\n admins?: string[];\n}\n\nexport interface IAddGroupUsersResult {\n /**\n * An array of usernames that were not added\n */\n notAdded?: string[];\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * ```js\n * import { addGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * addGroupUsers({\n * id: groupId,\n * users: [\"username1\", \"username2\"],\n * admins: [\"username3\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Add users to a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-users-to-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function addGroupUsers(\n requestOptions: IAddGroupUsersOptions\n): Promise<IAddGroupUsersResult> {\n const id = requestOptions.id;\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/addUsers`;\n const baseOptions = Object.assign({}, requestOptions, {\n admins: undefined,\n users: undefined\n });\n\n const batchRequestOptions = [\n ..._prepareRequests(\"users\", requestOptions.users, baseOptions),\n ..._prepareRequests(\"admins\", requestOptions.admins, baseOptions)\n ];\n\n const promises = batchRequestOptions.map(options =>\n _sendSafeRequest(url, options)\n );\n\n return Promise.all(promises).then(_consolidateRequestResults);\n}\n\nfunction _prepareRequests(\n type: \"admins\" | \"users\",\n usernames: string[],\n baseOptions: IAddGroupUsersOptions\n): IAddGroupUsersOptions[] {\n if (!usernames || usernames.length < 1) {\n return [];\n }\n\n // the ArcGIS REST API only allows to add no more than 25 users per request,\n // see https://developers.arcgis.com/rest/users-groups-and-items/add-users-to-group.htm\n const userChunks: string[][] = chunk<string>(usernames, 25);\n\n return userChunks.map(users =>\n _generateRequestOptions(type, users, baseOptions)\n );\n}\n\nfunction _generateRequestOptions(\n type: \"admins\" | \"users\",\n usernames: string[],\n baseOptions: IAddGroupUsersOptions\n) {\n return Object.assign({}, baseOptions, {\n [type]: usernames,\n params: {\n ...baseOptions.params,\n [type]: usernames\n }\n });\n}\n\n// this request is safe since the request error will be handled\nfunction _sendSafeRequest(\n url: string,\n requestOptions: IAddGroupUsersOptions\n): Promise<IAddGroupUsersResult> {\n return request(url, requestOptions).catch(error => {\n return {\n errors: [error]\n };\n });\n}\n\nfunction _consolidateRequestResults(\n results: IAddGroupUsersResult[]\n): IAddGroupUsersResult {\n const notAdded = results\n .filter(result => result.notAdded)\n .reduce((collection, result) => collection.concat(result.notAdded), []);\n\n const errors = results\n .filter(result => result.errors)\n .reduce((collection, result) => collection.concat(result.errors), []);\n\n const consolidated: IAddGroupUsersResult = { notAdded };\n\n if (errors.length > 0) {\n consolidated.errors = errors;\n }\n\n return consolidated;\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IRemoveGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be removed from the group\n */\n users?: string[];\n}\n\nexport interface IRemoveGroupUsersResult {\n /**\n * An array of usernames that were not removed\n */\n notRemoved?: string[];\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * ```js\n * import { removeGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * removeGroupUsers({\n * id: groupId,\n * users: [\"username1\", \"username2\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Add users to a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/remove-users-from-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function removeGroupUsers (\n requestOptions: IRemoveGroupUsersOptions\n): Promise<IRemoveGroupUsersResult> {\n const { id, users: usersToRemove } = requestOptions;\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/removeUsers`;\n const safeSend = (users: string[]) => {\n const options: IRemoveGroupUsersOptions = {\n ...requestOptions,\n users,\n params: { users }\n };\n return request(url, options)\n .catch(error => ({ errors: [error] }));\n };\n // the ArcGIS REST API only allows to add no more than 25 users per request,\n // see https://developers.arcgis.com/rest/users-groups-and-items/remove-users-from-group.htm\n const promises = chunk(usersToRemove, 25).map(usersChunk => safeSend(usersChunk));\n return Promise.all(promises)\n .then(results => {\n const filtered = (propName: string) => results\n .filter(result => result[propName])\n .reduce((collection, result) => collection.concat(result[propName]), []);\n const errors = filtered('errors');\n const consolidated: IRemoveGroupUsersResult = { notRemoved: filtered('notRemoved') };\n return errors.length ? { ...consolidated, errors } : consolidated;\n });\n}","import {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IInviteGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be added to the group as group members\n */\n users: string[];\n /**\n * What role the users should be invited as ('group_member' | 'group_admin')\n */\n role: string;\n /**\n * Expiration date on the invitation can be set for one day, three days, one week, or two weeks, in minutes.\n */\n expiration: number\n}\n\nexport interface IInviteGroupUsersResult {\n /**\n * Whether the operation was successful\n */\n success: boolean;\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * Invites users to join a group. Operation success\n * will be indicated by a flag on the return\n * object. If there are any errors, they will be\n * placed in an errors array on the return object\n * \n * ```js\n * const authentication: IAuthenticationManager; // Typically passed into to the function\n * //\n * const options: IInviteGroupUsersOptions = {\n * id: 'group_id',\n * users: ['ed', 'edd', 'eddy'],\n * role: 'group-member',\n * expiration: 20160,\n * authentication\n * }\n * //\n * const result = await inviteGroupUsers(options);\n * //\n * const if_success_result_looks_like = {\n * success: true\n * }\n * //\n * const if_failure_result_looks_like = {\n * success: false,\n * errors: [ArcGISRequestError]\n * }\n * ```\n * @param {IInviteGroupUsersOptions} options\n *\n * @returns {Promise<IAddGroupUsersResult>} \n */\nexport function inviteGroupUsers(options: IInviteGroupUsersOptions): Promise<IInviteGroupUsersResult> {\n const id = options.id;\n const url = `${getPortalUrl(options)}/community/groups/${id}/invite`;\n const batches = _generateBatchRequests(options);\n const promises = batches.map(batch => _sendSafeRequest(url, batch));\n\n return Promise.all(promises).then(_combineResults);\n}\n\n/**\n * @private\n */\nfunction _generateBatchRequests(options: IInviteGroupUsersOptions) {\n const userBatches: string[][] = chunk<string>(options.users, 25);\n return userBatches.map(users => _generateRequestOptions(users, options));\n}\n\n/**\n * @private\n */\nfunction _generateRequestOptions(users: string[], baseOptions: IInviteGroupUsersOptions): IRequestOptions {\n const requestOptions: IInviteGroupUsersOptions = Object.assign({}, baseOptions);\n\n requestOptions.params = {\n ...requestOptions.params,\n users,\n role: requestOptions.role,\n expiration: requestOptions.expiration,\n }\n \n return requestOptions;\n}\n\n/**\n * @private \n */\nfunction _sendSafeRequest(url: string,requestOptions: IRequestOptions): Promise<IInviteGroupUsersResult> {\n return request(url, requestOptions)\n .catch(error => ({ errors: [error] }));\n}\n\n/**\n * @private \n */\nfunction _combineResults(responses: IInviteGroupUsersResult[]): IInviteGroupUsersResult {\n const success = responses.every(res => res.success);\n const errors: ArcGISRequestError[] = responses.reduce((collection, res) => collection.concat(res.errors || []), []);\n const combined: IInviteGroupUsersResult = { success };\n\n if (errors.length > 0) {\n combined.errors = errors;\n }\n\n return combined;\n}\n\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IGroupAdd, IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface ICreateGroupOptions extends IRequestOptions {\n group: IGroupAdd;\n}\n\n/**\n * ```js\n * import { createGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * createGroup({\n * group: {\n * title: \"No Homers\",\n * access: \"public\"\n * },\n * authentication\n * })\n * .then(response)\n * ```\n * Create a new Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/create-group.htm) for more information.\n *\n * Note: The group name must be unique within the user's organization.\n * @param requestOptions - Options for the request, including a group object\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function createGroup(\n requestOptions: ICreateGroupOptions\n): Promise<{ success: boolean; group: IGroup }> {\n const url = `${getPortalUrl(requestOptions)}/community/createGroup`;\n\n requestOptions.params = {\n ...requestOptions.params,\n ...requestOptions.group\n };\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUserGroupOptions } from \"./helpers\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport type NotificationChannelType = \"push\" | \"email\" | \"builtin\";\n\nexport interface ICreateGroupNotificationOptions extends IUserGroupOptions {\n /**\n * Subject of the notification. This only applies to email and builtin notifications. For push notifications, subject/title is provided as a part of the message payload.\n */\n subject?: string;\n /**\n * Message to be sent. For builtin and email notifications this is a string. For push notifications, this will be JSON.\n */\n message: string | object;\n /**\n * Array of usernames of the users in the group to whom the message should be sent. If not provided, the message will be sent to all users in the group if the user is an admin. Only group admins will be able to send notifications to a list of users. Group users will be able to send notifications to only one user at a time.\n */\n users?: string[];\n /**\n * The channel through which the notification is to be delivered. Supported values are push, email, or builtin. If push is chosen, a message will be delivered only to those group members that have registered their devices to receive push notifications. If the user has registered more than one device for the app, then message will be sent to all the registered devices. Email will be sent when the email option is chosen. If the builtin option is chosen, a notification will be added to the notifications list that the user can see when logged into the home app.\n */\n notificationChannelType?: NotificationChannelType;\n /**\n * ClientId of the application through which user receives messages on the mobile device. This only applies to push notifications.\n */\n clientId?: string;\n /**\n * This only applies to push notifications. When set to true, message will be delivered to the app and it will not show as an alert to the user.\n */\n silentNotification?: boolean;\n}\n\n/**\n * ```js\n * import { createGroupNotification } from '@esri/arcgis-rest-portal';\n * // send an email to an entire group\n * createGroupNotification({\n * authentication: UserSession,\n * subject: \"hello\",\n * message: \"world!\",\n * id: groupId\n * })\n * ```\n * Create a group notification.\n *\n * @param requestOptions - Options for the request\n *\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function createGroupNotification(\n requestOptions: ICreateGroupNotificationOptions\n): Promise<any> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/createNotification`;\n\n const options: ICreateGroupNotificationOptions = {\n params: {\n subject: requestOptions.subject,\n message: requestOptions.message,\n users: requestOptions.users,\n notificationChannelType:\n requestOptions.notificationChannelType || \"email\",\n clientId: requestOptions.clientId,\n silentNotification: requestOptions.silentNotification,\n notifyAll: !requestOptions.users || requestOptions.users.length === 0,\n ...requestOptions.params\n },\n ...requestOptions\n };\n return request(url, options);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { protectGroup } from '@esri/arcgis-rest-portal';\n * //\n * protectGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Protect a group to avoid accidental deletion. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/protect-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function protectGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/protect`;\n\n return request(url, requestOptions);\n}\n\n/**\n * ```js\n * import { unprotectGroup } from '@esri/arcgis-rest-portal';\n * //\n * unprotectGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Unprotect a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unprotect-group.htm) for more information.\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function unprotectGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/unprotect`;\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { removeGroup } from '@esri/arcgis-rest-portal';\n * //\n * removeGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Delete a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function removeGroup(requestOptions: IUserGroupOptions): Promise<any> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/delete`;\n const options: IUserGroupOptions = {\n ...requestOptions\n };\n return request(url, options);\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IItem, IGroup } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport {\n ISearchOptions,\n ISearchGroupContentOptions,\n ISearchResult\n} from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n/**\n * ```js\n * import { searchGroups } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroups('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for groups. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-search.htm) for more information.\n *\n * @param search - A string or RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroups(\n search: string | ISearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IGroup>> {\n return genericSearch<IGroup>(search, \"group\");\n}\n\n/**\n * ```js\n * import { searchGroupContent } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroupContent('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for items in a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-content-search.htm) for more information.\n *\n * @param options - RequestOptions object amended with search parameters.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroupContent(\n options: ISearchGroupContentOptions\n): Promise<ISearchResult<IItem>> {\n return genericSearch<IItem>(options, \"groupContent\");\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItemUpdate } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IUpdateGroupOptions extends IRequestOptions {\n group: IItemUpdate;\n}\n\n/**\n * ```js\n * import { updateGroup } from '@esri/arcgis-rest-portal';\n * //\n * updateGroup({\n * group: { id: \"fgr344\", title: \"new\" }\n * })\n * .then(response)\n * ```\n * Update the properties of a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-group.htm) for more information.\n *\n * @param requestOptions - Options for the request, including the group\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function updateGroup(\n requestOptions: IUpdateGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.group.id\n }/update`;\n\n requestOptions.params = {\n ...requestOptions.params,\n ...requestOptions.group\n };\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { request } from \"@esri/arcgis-rest-request\";\n\nexport interface IUpdateGroupUsersResult {\n /**\n * Array of results\n */\n results: any[];\n}\n\nexport interface IUpdateGroupUsersOptions extends IUserRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be updated\n */\n users: string[];\n /**\n * Membership Type to update to\n */\n newMemberType: \"member\" | \"admin\";\n}\n\n/**\n * ```js\n * import { updateUserMemberships } from \"@esri/arcgis-rest-portal\";\n * //\n * updateUserMemberships({\n * id: groupId,\n * admins: [\"username3\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Change the user membership levels of existing users in a group\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function updateUserMemberships(\n requestOptions: IUpdateGroupUsersOptions\n): Promise<IUpdateGroupUsersResult> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/updateUsers`;\n const opts: any = {\n authentication: requestOptions.authentication,\n params: {}\n };\n // add the correct params depending on the type of membership we are changing to\n if (requestOptions.newMemberType === \"admin\") {\n opts.params.admins = requestOptions.users;\n } else {\n opts.params.users = requestOptions.users;\n }\n // make the request\n return request(url, opts);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { joinGroup } from '@esri/arcgis-rest-portal';\n * //\n * joinGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Make a request as the authenticated user to join a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/join-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request and the groupId.\n */\nexport function joinGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/join`;\n\n return request(url, requestOptions);\n}\n\n/**\n * ```js\n * import { leaveGroup } from '@esri/arcgis-rest-portal';\n * //\n * leaveGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Make a request as the authenticated user to leave a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/leave-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request and the groupId.\n */\nexport function leaveGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/leave`;\n\n return request(url, requestOptions);\n}\n","import {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface ICreateOrgNotificationOptions extends IRequestOptions {\n /**\n * Subject of the notification. This only applies to email and builtin notifications. For push notifications, subject/title is provided as a part of the message payload.\n */\n subject?: string;\n /**\n * Message to be sent. For builtin and email notifications this is a string. For push notifications, this will be JSON.\n */\n message: string | object;\n /**\n * Array of usernames of the users in the group to whom the message should be sent. If not provided, the message will be sent to all users in the group if the user is an admin. Only group admins will be able to send notifications to a list of users. Group users will be able to send notifications to only one user at a time.\n */\n users?: string[];\n /**\n * The channel through which the notification is to be delivered. Supported values are email or builtin. Email will be sent when the email option is chosen. If the builtin option is chosen, a notification will be added to the notifications list that the user can see when logged into the home app.\n */\n notificationChannelType?: string;\n\n /**\n * How many emails should be sent at a time. Defaults to the max possible (25)\n */\n batchSize?: number\n}\n\nexport interface ICreateOrgNotificationResult {\n /**\n * Whether the operation was successful\n */\n success: boolean;\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * Send a notification to members of the requesting user's org.\n * Operation success will be indicated by a flag on the return\n * object. If there are any errors, they will be placed in an \n * errors array on the return object\n * \n * ```js\n * const authentication: IAuthenticationManager; // Typically passed into to the function\n * //\n * const options: IInviteGroupUsersOptions = {\n * id: 'group_id',\n * users: ['larry', 'curly', 'moe'],\n * notificationChannelType: 'email',\n * expiration: 20160,\n * authentication\n * }\n * //\n * const result = await createOrgNotification(options);\n * //\n * const if_success_result_looks_like = {\n * success: true\n * }\n * //\n * const if_failure_result_looks_like = {\n * success: false,\n * errors: [ArcGISRequestError]\n * }\n * ```\n * @param {ICreateOrgNotificationOptions} options\n *\n * @returns {ICreateOrgNotificationResult}\n */\nexport function createOrgNotification (options: ICreateOrgNotificationOptions) {\n const url = `${getPortalUrl(options)}/portals/self/createNotification`;\n const batches = _generateBatchRequests(options);\n const promises = batches.map(batch => _sendSafeRequest(url, batch));\n\n return Promise.all(promises).then(_combineResults);\n}\n\n/**\n * @private\n */\nfunction _generateBatchRequests(options: ICreateOrgNotificationOptions): IRequestOptions[] {\n const userBatches: string[][] = chunk<string>(options.users, options.batchSize || 25);\n return userBatches.map(users => _generateRequestOptions(users, options));\n}\n\n/**\n * @private\n */\nfunction _generateRequestOptions(users: string[], baseOptions: ICreateOrgNotificationOptions): IRequestOptions {\n const requestOptions: ICreateOrgNotificationOptions = Object.assign({}, baseOptions);\n\n requestOptions.params = {\n ...requestOptions.params,\n users,\n subject: baseOptions.subject,\n message: baseOptions.message,\n notificationChannelType: requestOptions.notificationChannelType,\n }\n \n return requestOptions;\n}\n\n/**\n * @private \n */\nfunction _sendSafeRequest(url: string,requestOptions: IRequestOptions): Promise<ICreateOrgNotificationResult> {\n return request(url, requestOptions)\n .catch(error => ({ errors: [error] }));\n}\n\n/**\n * @private \n */\nfunction _combineResults(responses: ICreateOrgNotificationResult[]): ICreateOrgNotificationResult {\n const success = responses.every(res => res.success);\n const errors: ArcGISRequestError[] = responses.reduce((collection, res) => collection.concat(res.errors || []), []);\n const combined: ICreateOrgNotificationResult = { success };\n\n if (errors.length > 0) {\n combined.errors = errors;\n }\n\n return combined;\n}\n\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IGetUserOptions extends IRequestOptions {\n /**\n * A session representing a logged in user.\n */\n authentication?: UserSession;\n /**\n * Supply a username if you'd like to fetch information about a different user than is being used to authenticate the request.\n */\n username?: string;\n}\n\n/**\n * ```js\n * import { getUser } from '@esri/arcgis-rest-portal';\n * //\n * getUser(\"jsmith\")\n * .then(response)\n * // => { firstName: \"John\", lastName: \"Smith\",tags: [\"GIS Analyst\", \"City of Redlands\"] }\n * ```\n * Get information about a user. This method has proven so generically useful that you can also call [`UserSession.getUser()`](/arcgis-rest-js/api/auth/UserSession#getUser-summary).\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with metadata about the user\n */\nexport function getUser(\n requestOptions?: string | IGetUserOptions\n): Promise<IUser> {\n let url;\n let options = { httpMethod: \"GET\" } as IGetUserOptions;\n\n // if a username is passed, assume ArcGIS Online\n if (typeof requestOptions === \"string\") {\n url = `https://www.arcgis.com/sharing/rest/community/users/${requestOptions}`;\n } else {\n // if an authenticated session is passed, default to that user/portal unless another username is provided manually\n const username =\n requestOptions.username || requestOptions.authentication.username;\n url = `${getPortalUrl(requestOptions)}/community/users/${encodeURIComponent(\n username\n )}`;\n options = {\n ...requestOptions,\n ...options\n };\n }\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IGetUserOptions } from \"./get-user\";\n\nexport interface ITagCount {\n /**\n * the name of a tag\n */\n tag: string;\n /**\n * a count that reports the number of times the tag was used\n */\n count: number;\n}\n\nexport interface IGetUserTagsResponse {\n /**\n * Array of user item tag objects\n */\n tags: ITagCount[];\n}\n\n/**\n * ```js\n * import { getUserTags } from '@esri/arcgis-rest-portal';\n * //\n * getUserTags({\n * username: \"jsmith\",\n * authentication\n * })\n * .then(response)\n * ```\n * Users tag the content they publish in their portal via the add and update item calls. This resource lists all the tags used by the user along with the number of times the tags have been used. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-tags.htm) for more information.\n *\n * @param IGetUserOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user tag array\n */\nexport function getUserTags(\n requestOptions: IGetUserOptions\n): Promise<IGetUserTagsResponse> {\n const username =\n requestOptions.username || requestOptions.authentication.username;\n const url = `${getPortalUrl(\n requestOptions\n )}/community/users/${encodeURIComponent(username)}/tags`;\n\n // send the request\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\n/**\n * Helper that returns the [user](https://developers.arcgis.com/rest/users-groups-and-items/user.htm) for a given portal.\n *\n * @param session\n * @returns User url to be used in API requests.\n */\nexport function getUserUrl(session: UserSession): string {\n return `${getPortalUrl(session)}/community/users/${encodeURIComponent(\n session.username\n )}`;\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IInvitation {\n id: string;\n targetType: string;\n targetId: string;\n received: number;\n accepted: boolean;\n mustApprove: boolean;\n email: string;\n role: string;\n type: string;\n dateAccepted: number;\n expiration: number;\n created: number;\n username: string;\n fromUsername: {\n username: string;\n fullname?: string;\n };\n group?: IGroup;\n groupId?: string;\n}\n\nexport interface IInvitationResult {\n userInvitations: IInvitation[];\n}\n\n/**\n * ```js\n * import { getUserInvitations } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserInvitations({ authentication })\n * .then(response) // response.userInvitations.length => 3\n * ```\n * Get all invitations for a user. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-invitations.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user's invitations\n */\nexport function getUserInvitations(\n requestOptions: IUserRequestOptions\n): Promise<IInvitationResult> {\n let options = { httpMethod: \"GET\" } as IUserRequestOptions;\n\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations`;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\nexport interface IGetUserInvitationOptions extends IUserRequestOptions {\n invitationId: string;\n}\n\n/**\n * ```js\n * import { getUserInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response) // => response.accepted => true\n * ```\n * Get an invitation for a user by id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-invitation.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the invitation\n */\nexport function getUserInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<IInvitation> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}`;\n\n let options = { httpMethod: \"GET\" } as IGetUserInvitationOptions;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\n/**\n * ```js\n * import { acceptInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * acceptInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response)\n * ```\n * Accept an invitation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/accept-invitation.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function acceptInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<{\n success: boolean;\n username: string;\n groupId: string;\n id: string;\n}> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}/accept`;\n\n const options: IGetUserInvitationOptions = { ...requestOptions };\n return request(url, options);\n}\n\n/**\n * ```js\n * import { declineInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * declineInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response)\n * ```\n * Decline an invitation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/decline-invitation.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function declineInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<{\n success: boolean;\n username: string;\n groupId: string;\n id: string;\n}> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}/decline`;\n\n const options: IGetUserInvitationOptions = { ...requestOptions };\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface INotification {\n id: string;\n type: string;\n target: string;\n targetType: string;\n received: number;\n data: { [key: string]: any };\n}\n\nexport interface IRemoveNotificationOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n}\nexport interface INotificationResult {\n notifications: INotification[];\n}\n\n/**\n * ```js\n * import { getUserNotifications } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserNotifications({ authentication })\n * .then(results) // results.notifications.length) => 3\n * ```\n * Get notifications for a user.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user's notifications\n */\nexport function getUserNotifications(\n requestOptions: IUserRequestOptions\n): Promise<INotificationResult> {\n let options = { httpMethod: \"GET\" } as IUserRequestOptions;\n\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/notifications`;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\n/**\n * Delete a notification.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function removeNotification(\n requestOptions: IRemoveNotificationOptions\n): Promise<{ success: boolean; notificationId: string }> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/notifications/${requestOptions.id}/delete`;\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { IAuthenticatedRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { IAuthenticationManager } from \"@esri/arcgis-rest-request\";\nimport { IPagingParams, IUser } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport { ISearchOptions, ISearchResult } from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n// export interface IUserSearchOptions extends IAuthenticatedRequestOptions, IPagingParams {\n// q: string | SearchQueryBuilder;\n// sortField?: string;\n// sortOrder?: string;\n// [key: string]: any;\n// }\n\nexport interface IUserSearchOptions extends ISearchOptions {\n authentication: IAuthenticationManager;\n}\n\n/**\n * ```js\n * import { searchItems } from \"@esri/arcgis-rest-portal\";\n * //\n * searchUsers({ q: 'tommy', authentication })\n * .then(response) // response.total => 355\n * ```\n * Search a portal for users.\n *\n * @param search - A RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchUsers(\n search: IUserSearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IUser>> {\n return genericSearch<IUser>(search, \"user\");\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\n\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IUpdateUserOptions extends IUserRequestOptions {\n /**\n * The user properties to be updated.\n */\n user: IUser;\n}\n\nexport interface IUpdateUserResponse {\n success: boolean;\n username: string;\n}\n\n/**\n * ```js\n * import { updateUser } from '@esri/arcgis-rest-portal';\n * // any user can update their own profile\n * updateUser({\n * authentication,\n * user: { description: \"better than the last one\" }\n * })\n * .then(response)\n * // org administrators must declare the username that will be updated explicitly\n * updateUser({\n * authentication,\n * user: { username: \"c@sey\", description: \"\" }\n * })\n * .then(response)\n * // => { \"success\": true, \"username\": \"c@sey\" }\n * ```\n * Update a user profile. The username will be extracted from the authentication session unless it is provided explicitly. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-user.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with metadata about the user\n */\nexport function updateUser(\n requestOptions?: IUpdateUserOptions\n): Promise<IUpdateUserResponse> {\n // default to the authenticated username unless another username is provided manually\n const username =\n requestOptions.user.username || requestOptions.authentication.username;\n\n const updateUrl = `${getPortalUrl(\n requestOptions\n )}/community/users/${encodeURIComponent(username)}/update`;\n\n // mixin custom params and the user information, then drop the user info\n requestOptions.params = {\n ...requestOptions.user,\n ...requestOptions.params\n };\n\n delete requestOptions.user;\n\n // send the request\n return request(updateUrl, requestOptions);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport {\n ISharingOptions,\n ISharingResponse,\n isItemOwner,\n getSharingUrl,\n isOrgAdmin\n} from \"./helpers\";\n\nexport interface ISetAccessOptions extends ISharingOptions {\n /**\n * \"private\" indicates that the item can only be accessed by the user. \"public\" means accessible to anyone. An item shared to the organization has an access level of \"org\".\n */\n access: \"private\" | \"org\" | \"public\";\n}\n\n/**\n * ```js\n * import { setItemAccess } from \"@esri/arcgis-rest-portal\";\n * //\n * setItemAccess({\n * id: \"abc123\",\n * access: \"public\", // 'org' || 'private'\n * authentication: session\n * })\n * ```\n * Change who is able to access an item.\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function setItemAccess(\n requestOptions: ISetAccessOptions\n): Promise<ISharingResponse> {\n const url = getSharingUrl(requestOptions);\n\n if (isItemOwner(requestOptions)) {\n // if the user owns the item, proceed\n return updateItemAccess(url, requestOptions);\n } else {\n // otherwise we need to check to see if they are an organization admin\n return isOrgAdmin(requestOptions).then(admin => {\n if (admin) {\n return updateItemAccess(url, requestOptions);\n } else {\n // if neither, updating the sharing isnt possible\n throw Error(\n `This item can not be shared by ${requestOptions.authentication.username}. They are neither the item owner nor an organization admin.`\n );\n }\n });\n }\n}\n\nfunction updateItemAccess(\n url: string,\n requestOptions: ISetAccessOptions\n): Promise<any> {\n requestOptions.params = {\n org: false,\n everyone: false,\n ...requestOptions.params\n };\n\n // if the user wants to make the item private, it needs to be unshared from any/all groups as well\n if (requestOptions.access === \"private\") {\n requestOptions.params.groups = \" \";\n }\n if (requestOptions.access === \"org\") {\n requestOptions.params.org = true;\n }\n // if sharing with everyone, share with the entire organization as well.\n if (requestOptions.access === \"public\") {\n // this is how the ArcGIS Online Home app sets public access\n // setting org = true instead of account = true will cancel out all sharing\n requestOptions.params.account = true;\n requestOptions.params.everyone = true;\n }\n return request(url, requestOptions);\n}\n","import { IGroupSharingOptions } from \"./helpers\";\nimport { searchItems } from \"../items/search\";\nimport { ISearchOptions } from \"../util/search\";\n\n/**\n * ```js\n * import { isItemSharedWithGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * isItemSharedWithGroup({\n * groupId: 'bc3,\n * itemId: 'f56,\n * authentication\n * })\n * .then(isShared => {})\n * ```\n * Find out whether or not an item is already shared with a group.\n *\n * @param requestOptions - Options for the request. NOTE: `rawResponse` is not supported by this operation.\n * @returns Promise that will resolve with true/false\n */\nexport function isItemSharedWithGroup(\n requestOptions: IGroupSharingOptions\n): Promise<boolean> {\n const searchOpts = {\n q: `id: ${requestOptions.id} AND group: ${requestOptions.groupId}`,\n start: 1,\n num: 10,\n sortField: \"title\",\n authentication: requestOptions.authentication,\n httpMethod: \"POST\"\n } as ISearchOptions;\n\n return searchItems(searchOpts).then(searchResponse => {\n let result = false;\n if (searchResponse.total > 0) {\n result = searchResponse.results.some((itm: any) => {\n return itm.id === requestOptions.id;\n });\n return result;\n }\n });\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IGroupSharingOptions,\n ISharingResponse,\n getUserMembership,\n} from \"./helpers\";\nimport { getUser } from \"../users/get-user\";\nimport { addGroupUsers, IAddGroupUsersResult } from \"../groups/add-users\";\nimport { removeGroupUsers } from \"../groups/remove-users\";\nimport {\n updateUserMemberships,\n IUpdateGroupUsersResult,\n} from \"../groups/update-user-membership\";\nimport { isItemSharedWithGroup } from \"../sharing/is-item-shared-with-group\";\n\ninterface IEnsureMembershipResult {\n promise: Promise<IAddGroupUsersResult>;\n revert: (sharingResults: ISharingResponse) => Promise<ISharingResponse>;\n}\n\n/**\n * ```js\n * import { shareItemWithGroup } from '@esri/arcgis-rest-portal';\n * //\n * shareItemWithGroup({\n * id: \"abc123\",\n * groupId: \"xyz987\",\n * owner: \"some-owner\",\n * authentication\n * })\n * ```\n * Share an item with a group, either as an\n * [item owner](https://developers.arcgis.com/rest/users-groups-and-items/share-item-as-item-owner-.htm),\n * [group admin](https://developers.arcgis.com/rest/users-groups-and-items/share-item-as-group-admin-.htm) or\n * organization admin.\n *\n * Note: Sharing the item as an Admin will use the `/content/users/:ownername/items/:itemid/share` end-point\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function shareItemWithGroup(\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n return isItemSharedWithGroup(requestOptions)\n .then((isShared) => {\n if (isShared) {\n // already shared, exit early with success response\n return {\n itemId: requestOptions.id,\n shortcut: true,\n notSharedWith: [],\n } as ISharingResponse;\n }\n\n const {\n authentication: { username },\n owner,\n confirmItemControl,\n } = requestOptions;\n const itemOwner = owner || username;\n\n // non-item owner\n if (itemOwner !== username) {\n // need to track if the user is an admin\n let isAdmin = false;\n // track if the admin & owner are in the same org\n let isCrossOrgSharing = false;\n // next perform any necessary membership adjustments for\n // current user and/or item owner\n return Promise.all([\n getUser({\n username,\n authentication: requestOptions.authentication,\n }),\n getUser({\n username: itemOwner,\n authentication: requestOptions.authentication,\n }),\n getUserMembership(requestOptions),\n ])\n .then(([currentUser, ownerUser, membership]) => {\n const isSharedEditingGroup = !!confirmItemControl;\n isAdmin = currentUser.role === \"org_admin\" && !currentUser.roleId;\n isCrossOrgSharing = currentUser.orgId !== ownerUser.orgId;\n return getMembershipAdjustments(\n currentUser,\n isSharedEditingGroup,\n membership,\n isAdmin,\n ownerUser,\n requestOptions\n );\n })\n .then((membershipAdjustments) => {\n const [\n { revert } = {\n promise: Promise.resolve({ notAdded: [] }),\n revert: (sharingResults: ISharingResponse) => {\n return Promise.resolve(sharingResults);\n },\n } as IEnsureMembershipResult,\n ] = membershipAdjustments;\n // perform all membership adjustments\n return Promise.all(\n membershipAdjustments.map(({ promise }) => promise)\n )\n .then(() => {\n // then attempt the share\n return shareToGroup(requestOptions, isAdmin, isCrossOrgSharing);\n })\n .then((sharingResults) => {\n // lastly, if the admin user was added to the group,\n // remove them from the group. this is a no-op that\n // immediately resolves the sharingResults when no\n // membership adjustment was needed\n return revert(sharingResults);\n });\n });\n }\n\n // item owner, let it call through\n return shareToGroup(requestOptions);\n })\n .then((sharingResponse) => {\n if (sharingResponse.notSharedWith.length) {\n throw Error(\n `Item ${requestOptions.id} could not be shared to group ${requestOptions.groupId}.`\n );\n } else {\n // all is well\n return sharingResponse;\n }\n });\n}\n\nfunction getMembershipAdjustments(\n currentUser: IUser,\n isSharedEditingGroup: boolean,\n membership: string,\n isAdmin: boolean,\n ownerUser: IUser,\n requestOptions: IGroupSharingOptions\n) {\n const membershipGuarantees = [];\n if (requestOptions.groupId !== currentUser.favGroupId) {\n if (isSharedEditingGroup) {\n if (!isAdmin) {\n // abort and reject promise\n throw Error(\n `This item can not be shared to shared editing group ${requestOptions.groupId} by ${currentUser.username} as they not the item owner or org admin.`\n );\n }\n\n membershipGuarantees.push(\n // admin user must be a group member to share, should be reverted afterwards\n ensureMembership(\n currentUser,\n currentUser,\n false,\n `Error adding ${currentUser.username} as member to edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n ),\n // item owner must be a group admin\n ensureMembership(\n currentUser,\n ownerUser,\n true,\n membership === \"none\"\n ? `Error adding user ${ownerUser.username} to edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`\n : `Error promoting user ${ownerUser.username} to admin in edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n )\n );\n } else if (isAdmin) {\n // admin user must be a group member to share, should be reverted afterwards\n membershipGuarantees.push(\n ensureMembership(\n currentUser,\n currentUser,\n false,\n `Error adding ${currentUser.username} as member to view group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n )\n );\n } else if (membership === \"none\") {\n // all other non-item owners must be a group member\n throw new Error(\n `This item can not be shared by ${currentUser.username} as they are not a member of the specified group ${requestOptions.groupId}.`\n );\n }\n }\n\n return membershipGuarantees;\n}\n\nfunction shareToGroup(\n requestOptions: IGroupSharingOptions,\n isAdmin = false,\n isCrossOrgSharing = false\n): Promise<ISharingResponse> {\n const username = requestOptions.authentication.username;\n const itemOwner = requestOptions.owner || username;\n // decide what url to use\n // default to the non-owner url...\n let url = `${getPortalUrl(requestOptions)}/content/items/${\n requestOptions.id\n }/share`;\n\n // but if they are the owner, or org_admin, use this route\n // Note: When using this end-point as an admin, apparently the admin does not need to be a member of the group (the itemOwner does)\n // Note: Admin's can only use this route when the item is in the same org they are admin for\n if (itemOwner === username || (isAdmin && !isCrossOrgSharing)) {\n url = `${getPortalUrl(requestOptions)}/content/users/${itemOwner}/items/${\n requestOptions.id\n }/share`;\n }\n\n // now its finally time to do the sharing\n requestOptions.params = {\n groups: requestOptions.groupId,\n confirmItemControl: requestOptions.confirmItemControl,\n };\n\n return request(url, requestOptions);\n}\n\nexport function ensureMembership(\n currentUser: IUser,\n ownerUser: IUser,\n shouldPromote: boolean,\n errorMessage: string,\n requestOptions: IGroupSharingOptions\n): IEnsureMembershipResult {\n const ownerGroups = ownerUser.groups || [];\n const group = ownerGroups.find((g) => {\n return g.id === requestOptions.groupId;\n });\n\n // if they are in different orgs, eject\n if (currentUser.orgId !== ownerUser.orgId) {\n throw Error(\n `User ${ownerUser.username} is not a member of the same org as ${currentUser.username}. Consequently they can not be added added to group ${requestOptions.groupId} nor can item ${requestOptions.id} be shared to the group.`\n );\n }\n\n // if owner is not a member, and has 512 groups\n if (!group && ownerGroups.length > 511) {\n throw Error(\n `User ${ownerUser.username} already has 512 groups, and can not be added to group ${requestOptions.groupId}. Consequently item ${requestOptions.id} can not be shared to the group.`\n );\n }\n\n let promise: Promise<IAddGroupUsersResult>;\n let revert: (sharingResults: ISharingResponse) => Promise<ISharingResponse>;\n\n // decide if we need to add them or upgrade them\n if (group) {\n // they are in the group...\n // check member type\n if (shouldPromote && group.userMembership.memberType === \"member\") {\n // promote them\n promise = updateUserMemberships({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n newMemberType: \"admin\",\n authentication: requestOptions.authentication,\n })\n .then((results: IUpdateGroupUsersResult) => {\n // convert the result into the right type\n const notAdded = results.results.reduce((acc: any[], entry: any) => {\n if (!entry.success) {\n acc.push(entry.username);\n }\n return acc;\n }, []);\n // and return it\n return Promise.resolve({ notAdded });\n })\n .catch(() => ({ notAdded: [ownerUser.username] }));\n revert = (sharingResults) =>\n updateUserMemberships({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n newMemberType: \"member\",\n authentication: requestOptions.authentication,\n })\n .then(() => sharingResults)\n .catch(() => sharingResults);\n } else {\n // they are already an admin in the group\n // return the same response the API would if we added them\n promise = Promise.resolve({ notAdded: [] });\n revert = (sharingResults) => Promise.resolve(sharingResults);\n }\n } else {\n // attempt to add user to group\n const userType = shouldPromote ? \"admins\" : \"users\";\n // can't currently determine if the group is within the admin's\n // org without performing a search, so attempt to add and handle\n // the api error\n promise = addGroupUsers({\n id: requestOptions.groupId,\n [userType]: [ownerUser.username],\n authentication: requestOptions.authentication,\n })\n .then((results) => {\n // results.errors includes an ArcGISAuthError when the group\n // is in a different org, but notAdded is empty, throw here\n // to normalize the results in below catch\n if (results.errors && results.errors.length) {\n throw results.errors[0];\n }\n return results;\n })\n .catch(() => ({ notAdded: [ownerUser.username] }));\n revert = (sharingResults) => {\n return removeGroupUsers({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n authentication: requestOptions.authentication,\n }).then(() => {\n // always resolves, suppress any resolved errors\n return sharingResults;\n });\n };\n }\n\n return {\n promise: promise.then((membershipResponse) => {\n if (membershipResponse.notAdded.length) {\n throw new Error(errorMessage);\n }\n return membershipResponse;\n }),\n revert,\n };\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IGroupSharingOptions,\n ISharingResponse,\n getUserMembership\n} from \"./helpers\";\nimport { isItemSharedWithGroup } from \"./is-item-shared-with-group\";\nimport { getUser } from \"../users/get-user\";\n\n/**\n * Stop sharing an item with a group, either as an\n * [item owner](https://developers.arcgis.com/rest/users-groups-and-items/unshare-item-as-item-owner-.htm),\n * [group admin](https://developers.arcgis.com/rest/users-groups-and-items/unshare-item-as-group-admin-.htm) or\n * organization admin.\n *\n * ```js\n * import { unshareItemWithGroup } from '@esri/arcgis-rest-portal';\n *\n * unshareItemWithGroup({\n * id: \"abc123\",\n * groupId: \"xyz987\",\n * owner: \"some-owner\",\n * authentication: session\n * })\n * ```\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function unshareItemWithGroup (\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n return isItemSharedWithGroup(requestOptions)\n .then(isShared => {\n // not shared\n if (!isShared) {\n // exit early with success response\n return Promise.resolve({\n itemId: requestOptions.id,\n shortcut: true,\n notUnsharedFrom: []\n } as ISharingResponse);\n }\n\n const {\n authentication: { username },\n owner\n } = requestOptions;\n\n // next check if the user is a member of the group\n return Promise.all([\n getUserMembership(requestOptions),\n getUser({\n username,\n authentication: requestOptions.authentication\n })\n ])\n .then(([membership, currentUser]) => {\n const itemOwner = owner || username;\n const isItemOwner = itemOwner === username;\n const isAdmin = currentUser.role === 'org_admin' && !currentUser.roleId;\n\n if (!isItemOwner && !isAdmin && ['admin', 'owner'].indexOf(membership) < 0) {\n // abort and reject promise\n throw Error(`This item can not be unshared from group ${requestOptions.groupId} by ${username} as they not the item owner, an org admin, group admin or group owner.`);\n }\n \n // let the sharing call go\n return unshareFromGroup(requestOptions);\n })\n .then(sharingResponse => {\n if (sharingResponse.notUnsharedFrom.length) {\n throw Error(\n `Item ${requestOptions.id} could not be unshared to group ${requestOptions.groupId}`\n );\n } else {\n // all is well\n return sharingResponse;\n }\n });\n });\n}\n\nfunction unshareFromGroup (\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n const username = requestOptions.authentication.username;\n const itemOwner = requestOptions.owner || username;\n // decide what url to use\n // default to the non-owner url...\n let url = `${getPortalUrl(requestOptions)}/content/items/${requestOptions.id}/unshare`;\n\n // but if they are the owner, we use a different path...\n if (itemOwner === username) {\n url = `${getPortalUrl(requestOptions)}/content/users/${itemOwner}/items/${requestOptions.id}/unshare`;\n }\n\n // now its finally time to do the sharing\n requestOptions.params = {\n groups: requestOptions.groupId\n };\n\n return request(url, requestOptions);\n}","/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IServiceNameAvailable } from \"@esri/arcgis-rest-types\";\n\n/**\n * Determine if a specific service name is available in the current user's organization\n *\n * @export\n * @param {string} name\n * @param {UserSession} session\n * @return {*} {Promise<IServiceNameAvailable>}\n */\nexport function isServiceNameAvailable(\n name: string,\n type: string,\n session: UserSession\n): Promise<IServiceNameAvailable> {\n const url = `${session.portal}/portals/self/isServiceNameAvailable`;\n return request(url, {\n params: {\n name,\n type,\n },\n httpMethod: \"GET\",\n authentication: session,\n });\n}\n","/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\nimport { isServiceNameAvailable } from \"./is-service-name-available\";\n\n/**\n * Given a starting name, return a service name that is unqieu within\n * the current users organization\n *\n * @export\n * @param {string} name\n * @param {UserSession} session\n * @param {number} step\n * @return {*} {Promise<string>}\n */\nexport function getUniqueServiceName(\n name: string,\n type: string,\n session: UserSession,\n step: number\n): Promise<string> {\n let nameToCheck = name;\n if (step) {\n nameToCheck = `${name}_${step}`;\n }\n return isServiceNameAvailable(nameToCheck, type, session).then((response) => {\n if (response.available) {\n return nameToCheck;\n } else {\n step = step + 1;\n return getUniqueServiceName(name, type, session, step);\n }\n });\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface IPortal {\n id: string;\n isPortal: boolean;\n name: string;\n [key: string]: any;\n}\n\n/**\n * Get the portal\n * @param requestOptions\n */\nexport function getSelf(requestOptions?: IRequestOptions): Promise<IPortal> {\n // just delegate to getPortal w/o an id\n return getPortal(null, requestOptions);\n}\n\n/**\n * ```js\n * import { getPortal } from \"@esri/arcgis-rest-request\";\n * //\n * getPortal()\n * getPortal(\"fe8\")\n * getPortal(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch information about the specified portal by id. If no id is passed, portals/self will be called.\n * Note that if you intend to request a portal by id and it is different from the portal specified by options.authentication, you must also pass options.portal.\n * @param id\n * @param requestOptions\n */\nexport function getPortal(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<IPortal> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(requestOptions)}/portals/${idOrSelf}`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IExtent } from \"@esri/arcgis-rest-types\";\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface IPortalSettings {\n allowedRedirectUris: string[];\n defaultExtent: IExtent;\n helperServices: { [key: string]: any };\n informationalBanner: { [key: string]: any };\n [key: string]: any;\n}\n\n/**\n * ```js\n * import { getPortalSettings } from \"@esri/arcgis-rest-portal\";\n * //\n * getPortalSettings()\n * getPortalSettings(\"fe8\")\n * getPortalSettings(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch the settings for the current portal by id. If no id is passed, portals/self/settings will be called\n * @param id\n * @param requestOptions\n */\nexport function getPortalSettings(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<IPortalSettings> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(requestOptions)}/portals/${idOrSelf}/settings`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface ISubscriptionInfo {\n id: string;\n [key: string]: any;\n}\n\n/**\n * ```js\n * import { getSubscriptionInfo } from \"@esri/arcgis-rest-request\";\n * //\n * getSubscriptionInfo()\n * getSubscriptionInfo(\"fe8\")\n * getSubscriptionInfo(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch subscription information about the current portal by id. If no id is passed, portals/self/subscriptionInfo will be called\n * @param id\n * @param requestOptions\n */\nexport function getSubscriptionInfo(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<ISubscriptionInfo> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(\n requestOptions\n )}/portals/${idOrSelf}/subscriptionInfo`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n"],"names":["cleanUrl","request","appendCustomParams","warn","_sendSafeRequest","_generateRequestOptions","_generateBatchRequests","_combineResults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;IAKA;;;;;;;;aAQgB,YAAY,CAAC,cAAoC;QAApC,+BAAA,EAAA,mBAAoC;;QAE/D,IAAI,cAAc,CAAC,MAAM,EAAE;YACzB,OAAOA,0BAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;SACxC;;QAGD,IAAI,cAAc,CAAC,cAAc,EAAE;;YAEjC,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC;SAC7C;;QAGD,OAAO,qCAAqC,CAAC;IAC/C;;IC3BA;;IAwPA;;;;;;aAMgB,aAAa,CAAC,IAAoC;;QAEhE,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;;;QAI/C,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,CAAC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,IAAI,YAAY,IAAI;;gB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,IAAM,OAAO,YACR,EAAE,UAAU,EAAE,KAAK,EAAE,EACrB,cAAc,CAClB,CAAC;;QAGF,OAAOA,yBAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B;;IC5CA;;IAYA;;;;;;;;;;;;aAYgB,mBAAmB,CACjC,EAAW,EACX,cAAgC;;QAGhC,IAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;QAClC,IAAM,GAAG,GAAM,YAAY,CACzB,cAAc,CACf,iBAAY,QAAQ,sBAAmB,CAAC;;QAGzC,IAAM,OAAO,YACR,EAAE,UAAU,EAAE,KAAK,EAAE,EACrB,cAAc,CAClB,CAAC;;QAGF,OAAOA,yBAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"portal.umd.js","sources":["../../src/util/get-portal-url.ts","../../src/items/helpers.ts","../../src/items/update.ts","../../src/items/add.ts","../../src/items/content.ts","../../src/items/create.ts","../../src/items/export.ts","../../src/util/scrub-control-chars.ts","../../src/items/get.ts","../../src/items/protect.ts","../../src/groups/get.ts","../../src/sharing/helpers.ts","../../src/items/reassign.ts","../../src/items/remove.ts","../../src/util/SearchQueryBuilder.ts","../../src/util/generic-search.ts","../../src/items/search.ts","../../src/items/upload.ts","../../src/util/array.ts","../../src/groups/add-users.ts","../../src/groups/remove-users.ts","../../src/groups/invite-users.ts","../../src/groups/create.ts","../../src/groups/notification.ts","../../src/groups/protect.ts","../../src/groups/remove.ts","../../src/groups/search.ts","../../src/groups/update.ts","../../src/groups/update-user-membership.ts","../../src/groups/join.ts","../../src/orgs/notification.ts","../../src/users/get-user.ts","../../src/users/get-user-tags.ts","../../src/users/get-user-url.ts","../../src/users/invitation.ts","../../src/users/notification.ts","../../src/users/search-users.ts","../../src/users/update.ts","../../src/sharing/access.ts","../../src/sharing/is-item-shared-with-group.ts","../../src/sharing/share-item-with-group.ts","../../src/sharing/unshare-item-with-group.ts","../../src/services/is-service-name-available.ts","../../src/services/get-unique-service-name.ts","../../src/util/get-portal.ts","../../src/util/get-portal-settings.ts","../../src/util/get-subscription-info.ts"],"sourcesContent":["/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IRequestOptions, cleanUrl } from \"@esri/arcgis-rest-request\";\n\n/**\n * Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given\n * precedence over `authentication.portal`. If neither `portal` nor `authentication` is present,\n * `www.arcgis.com/sharing/rest` is returned.\n *\n * @param requestOptions - Request options that may have authentication manager\n * @returns Portal url to be used in API requests\n */\nexport function getPortalUrl(requestOptions: IRequestOptions = {}): string {\n // use portal in options if specified\n if (requestOptions.portal) {\n return cleanUrl(requestOptions.portal);\n }\n\n // if auth was passed, use that portal\n if (requestOptions.authentication) {\n // the portal url is already scrubbed in the auth package\n return requestOptions.authentication.portal;\n }\n\n // default to arcgis.com\n return \"https://www.arcgis.com/sharing/rest\";\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IRequestOptions, ArcGISRequestError } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd, IItemUpdate, IItem } from \"@esri/arcgis-rest-types\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\n/**\n * Base options interface for making authenticated requests for items.\n */\nexport interface IUserItemOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n /**\n * Item owner username. If not present, `authentication.username` is utilized.\n */\n owner?: string;\n}\n\nexport interface IFolderIdOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the folder.\n */\n folderId: string;\n /**\n * Item owner username. If not present, `authentication.username` is utilized.\n */\n owner?: string;\n}\n\nexport type ItemRelationshipType =\n | \"APIKey2Item\"\n | \"Area2CustomPackage\"\n | \"Area2Package\"\n | \"Item2Attachment\"\n | \"Item2Report\"\n | \"Listed2Provisioned\"\n | \"Map2AppConfig\"\n | \"Map2Area\"\n | \"Map2FeatureCollection\"\n | \"Map2Service\"\n | \"MobileApp2Code\"\n | \"Service2Data\"\n | \"Service2Layer\"\n | \"Service2Route\"\n | \"Service2Service\"\n | \"Service2Style\"\n | \"Solution2Item\"\n | \"Style2Style\"\n | \"Survey2Data\"\n | \"Survey2Service\"\n | \"SurveyAddIn2Data\"\n | \"Theme2Story\"\n | \"TrackView2Map\"\n | \"WebStyle2DesktopStyle\"\n | \"WMA2Code\"\n | \"WorkforceMap2FeatureService\"\n\n/**\n * Names of methods for reading the body of a fetch response, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\nexport type FetchReadMethodName =\n | \"arrayBuffer\"\n | \"blob\"\n | \"formData\"\n | \"json\"\n | \"text\";\n\nexport interface IItemRelationshipOptions extends IRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n /**\n * The type of relationship between the two items.\n */\n relationshipType: ItemRelationshipType | ItemRelationshipType[];\n /**\n * The direction of the relationship. Either forward (from origin -> destination) or reverse (from destination -> origin).\n */\n direction?: \"forward\" | \"reverse\";\n}\n\nexport interface IManageItemRelationshipOptions extends IUserRequestOptions {\n originItemId: string;\n destinationItemId: string;\n relationshipType: ItemRelationshipType;\n}\n\nexport interface IItemInfoOptions extends IUserItemOptions {\n /**\n * Subfolder for added information.\n */\n folderName?: string;\n /**\n * Object to store\n */\n file: any;\n}\n\nexport interface IItemResourceOptions extends IUserItemOptions {\n /**\n * New resource filename.\n */\n name?: string;\n /**\n * Folder in which to store the new resource.\n */\n prefix?: string;\n /**\n * Text input to be added as a file resource.\n */\n content?: string;\n /**\n * Controls whether access to the file resource is restricted to the owner or inherited from the sharing permissions set for the associated item.\n */\n private?: boolean;\n /**\n * Object to store\n */\n resource?: any;\n}\n\nexport interface IRemoveItemResourceOptions extends IUserItemOptions {\n /**\n * Resource item to be removed. Resource prefix needs to be specified if the file resource has one.\n */\n resource?: string;\n\n /**\n * If true, all file resources are removed.\n */\n deleteAll?: boolean;\n}\n\nexport interface ICreateUpdateItemOptions extends IUserRequestOptions {\n /**\n * The owner of the item. If this property is not present, `item.owner` will be passed, or lastly `authentication.username`.\n */\n owner?: string;\n /**\n * Id of the folder to house the item.\n */\n folderId?: string;\n /**\n * The file to be uploaded. If uploading a file, the request must be a multipart request.\n */\n file?: any;\n /**\n * The URL where the item can be downloaded. The resource will be downloaded and stored as a file type. Similar to uploading a file to be added, but instead of transferring the contents of the file, the URL of the data file is referenced and creates a file item.\n */\n dataUrl?: string;\n /**\n * The text content for the item to be submitted.\n */\n text?: string;\n /**\n * If true, the file is uploaded asynchronously. If false, the file is uploaded synchronously.\n */\n async?: boolean;\n /**\n * If true, the file is uploaded in multiple parts.\n */\n multipart?: boolean;\n /**\n * The filename being uploaded in multipart mode. Required if multipart=true.\n */\n filename?: string;\n /**\n * If true, overwrite the existing file.\n */\n overwrite?: boolean;\n}\n\nexport interface IItemDataOptions extends IRequestOptions {\n /**\n * Used to request binary data.\n */\n file?: boolean;\n}\n\nexport interface IItemPartOptions extends IUserItemOptions {\n /**\n * The file part to be uploaded.\n */\n file: any;\n /**\n * Part numbers can be any number from 1 to 10,000, inclusive. A part number uniquely identifies a part and also defines its position within the object being created. If you upload a new part using the same part number that was used with a previous part, the previously uploaded part is overwritten.\n */\n partNum: number;\n}\n\nexport interface IUpdateItemResponse {\n success: boolean;\n id: string;\n}\n\nexport interface IItemInfoResponse {\n success: boolean;\n itemId: string;\n owner: string;\n folder: string;\n}\n\nexport interface IItemResourceResponse {\n success: boolean;\n itemId: string;\n owner: string;\n folder: string;\n}\n\nexport interface IAddFolderResponse {\n /**\n * Success or failure of request.\n */\n success: boolean;\n /**\n * Information about created folder: its alphanumeric id, name, and owner's name.\n */\n folder: {\n id: string;\n title: string;\n username: string;\n };\n}\n\nexport interface IMoveItemResponse {\n /**\n * Success or failure of request.\n */\n success: boolean;\n /**\n * Alphanumeric id of moved item.\n */\n itemId: string;\n /**\n * Name of owner of item.\n */\n owner: string;\n /**\n * Alphanumeric id of folder now housing item.\n */\n folder: string;\n}\n\n/**\n * Serialize an item and its data into a json format accepted by the Portal API for create and update operations\n *\n * @param item Item to be serialized\n * @returns a formatted json object to be sent to Portal\n */\nexport function serializeItem(item: IItemAdd | IItemUpdate | IItem): any {\n // create a clone so we're not messing with the original\n const clone = JSON.parse(JSON.stringify(item));\n\n // binary data needs POSTed as a `file`\n // JSON object literals should be passed as `text`.\n if (clone.data) {\n (typeof Blob !== \"undefined\" && item.data instanceof Blob) ||\n // Node.js doesn't implement Blob\n item.data.constructor.name === \"ReadStream\"\n ? (clone.file = item.data)\n : (clone.text = item.data);\n delete clone.data;\n }\n return clone;\n}\n\n/**\n * `requestOptions.owner` is given priority, `requestOptions.item.owner` will be checked next. If neither are present, `authentication.getUserName()` will be used instead.\n */\nexport function determineOwner(requestOptions: any): Promise<string> {\n if (requestOptions.owner) {\n return Promise.resolve(requestOptions.owner);\n } else if (requestOptions.item && requestOptions.item.owner) {\n return Promise.resolve(requestOptions.item.owner);\n } else if (\n requestOptions.authentication &&\n requestOptions.authentication.getUsername\n ) {\n return requestOptions.authentication.getUsername();\n } else {\n return Promise.reject(\n new Error(\n \"Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option.\"\n )\n );\n }\n}\n\n/**\n * checks if the extent is a valid BBox (2 element array of coordinate pair arrays)\n * @param extent\n * @returns\n */\n export function isBBox (extent: unknown): boolean {\n return (\n Array.isArray(extent) &&\n Array.isArray(extent[0]) &&\n Array.isArray(extent[1])\n );\n};\n\n/**\n * Given a Bbox, convert it to a string. Some api endpoints expect a string\n *\n * @param {BBox} extent\n * @return {*} {string}\n */\n export function bboxToString (extent: number[][]): string {\n return extent.join(\",\");\n};\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItemUpdate } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n ICreateUpdateItemOptions,\n IMoveItemResponse,\n IItemInfoOptions,\n IItemResourceOptions,\n IItemInfoResponse,\n IItemResourceResponse,\n IUpdateItemResponse,\n serializeItem,\n determineOwner,\n isBBox,\n bboxToString\n} from \"./helpers\";\n\nexport interface IUpdateItemOptions extends ICreateUpdateItemOptions {\n item: IItemUpdate;\n}\n\nexport interface IMoveItemOptions extends ICreateUpdateItemOptions {\n /**\n * Alphanumeric id of item to be moved.\n */\n itemId: string;\n /**\n * Alphanumeric id of folder to house moved item. If null, empty, or \"/\", the destination is the\n * root folder.\n */\n folderId?: string;\n}\n\n/**\n * ```js\n * import { updateItem } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItem({\n * item: {\n * id: \"3ef\",\n * description: \"A three hour tour\"\n * },\n * authentication\n * })\n * .then(response)\n * ```\n * Update an Item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-item.htm) for more information.\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that updates an item.\n */\nexport function updateItem(\n requestOptions: IUpdateItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = requestOptions.folderId\n ? `${getPortalUrl(requestOptions)}/content/users/${owner}/${requestOptions.folderId}/items/${requestOptions.item.id}/update`\n : `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${requestOptions.item.id}/update`;\n\n // serialize the item into something Portal will accept\n requestOptions.params = {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n };\n\n // convert extent, if present, into a string from bbox\n // processParams was previously doing this sort of work,\n // however now we need to let array of arrays through\n // Thus for extents we need to move this logic here\n if (requestOptions.params.extent && isBBox(requestOptions.params.extent)) {\n requestOptions.params.extent = bboxToString(requestOptions.params.extent);\n }\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { updateItemInfo } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItemInfo({\n * id: '3ef',\n * file: file,\n * authentication\n * })\n * .then(response)\n * ```\n * Update an info file associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-info.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that updates an item info file.\n */\nexport function updateItemInfo(\n requestOptions: IItemInfoOptions\n): Promise<IItemInfoResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions as IRequestOptions\n )}/content/users/${owner}/items/${requestOptions.id}/updateinfo`;\n\n // mix in user supplied params\n requestOptions.params = {\n folderName: requestOptions.folderName,\n file: requestOptions.file,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { updateItemResource } from \"@esri/arcgis-rest-portal\";\n * //\n * updateItemResource({\n * id: '3ef',\n * resource: file,\n * name: 'bigkahuna.jpg',\n * authentication\n * })\n * .then(response)\n * ```\n * Update a resource associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-resources.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that updates an item resource.\n */\nexport function updateItemResource(\n requestOptions: IItemResourceOptions\n): Promise<IItemResourceResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions as IRequestOptions\n )}/content/users/${owner}/items/${requestOptions.id}/updateResources`;\n\n // mix in user supplied params\n requestOptions.params = {\n file: requestOptions.resource,\n fileName: requestOptions.name,\n resourcesPrefix: requestOptions.prefix,\n text: requestOptions.content,\n ...requestOptions.params\n };\n\n // only override the access specified previously if 'private' is passed explicitly\n if (typeof requestOptions.private !== \"undefined\") {\n requestOptions.params.access = requestOptions.private\n ? \"private\"\n : \"inherit\";\n }\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { moveItem } from \"@esri/arcgis-rest-portal\";\n * //\n * moveItem({\n * itemId: \"3ef\",\n * folderId: \"7c5\",\n * authentication: userSession\n * })\n * ```\n * Move an item to a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/move-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that resolves with owner and folder details once the move has been completed\n */\nexport function moveItem(\n requestOptions: IMoveItemOptions\n): Promise<IMoveItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.itemId\n }/move`;\n\n let folderId = requestOptions.folderId;\n if (!folderId) {\n folderId = \"/\";\n }\n requestOptions.params = {\n folder: folderId,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IItemResourceOptions,\n IUpdateItemResponse,\n IItemResourceResponse,\n determineOwner,\n IManageItemRelationshipOptions\n} from \"./helpers\";\nimport { updateItem, IUpdateItemOptions } from \"./update\";\n\nexport interface IAddItemDataOptions extends IUserItemOptions {\n /**\n * Object to store\n */\n data: any;\n}\n\n/**\n * ```js\n * import { addItemData } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemData({\n * id: '3ef',\n * data: file,\n * authentication\n * })\n * .then(response)\n * ```\n * Send a file or blob to an item to be stored as the `/data` resource. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with an object reporting\n * success/failure and echoing the item id.\n */\nexport function addItemData(\n requestOptions: IAddItemDataOptions\n): Promise<IUpdateItemResponse> {\n const options: any = {\n item: {\n id: requestOptions.id,\n data: requestOptions.data\n },\n ...requestOptions\n };\n\n delete options.id;\n delete options.data;\n\n return updateItem(options as IUpdateItemOptions);\n}\n\n/**\n * ```js\n * import { addItemRelationship } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemRelationship({\n * originItemId: '3ef',\n * destinationItemId: 'ae7',\n * relationshipType: 'Service2Layer',\n * authentication\n * })\n * .then(response)\n * ```\n * Add a relationship between two items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-relationship.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function addItemRelationship(\n requestOptions: IManageItemRelationshipOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${owner}/addRelationship`;\n\n const options = appendCustomParams<IManageItemRelationshipOptions>(\n requestOptions,\n [\"originItemId\", \"destinationItemId\", \"relationshipType\"],\n { params: { ...requestOptions.params } }\n );\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { addItemResource } from \"@esri/arcgis-rest-portal\";\n * //\n * // Add a file resource\n * addItemResource({\n * id: '3ef',\n * resource: file,\n * name: 'bigkahuna.jpg',\n * authentication\n * })\n * .then(response)\n * //\n * // Add a text resource\n * addItemResource({\n * id: '4fg',\n * content: \"Text content\",\n * name: 'bigkahuna.txt',\n * authentication\n * })\n * .then(response)\n * ```\n * Add a resource associated with an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function addItemResource(\n requestOptions: IItemResourceOptions\n): Promise<IItemResourceResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/addResources`;\n\n requestOptions.params = {\n file: requestOptions.resource,\n fileName: requestOptions.name,\n resourcesPrefix: requestOptions.prefix,\n text: requestOptions.content,\n access: requestOptions.private ? \"private\" : \"inherit\",\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n","import { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport {\n IPagingParams,\n IItem,\n IFolder,\n IPagedResponse,\n} from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { determineOwner } from \"./helpers\";\n\nexport type UnixTime = number;\n\nexport interface IUserContentRequestOptions\n extends IPagingParams,\n IRequestOptions {\n owner?: string;\n folderId?: string;\n}\n\nexport interface IUserContentResponse extends IPagedResponse {\n username: string;\n currentFolder?: IFolder;\n items: IItem[];\n folders: IFolder[];\n}\n\n/**\n * ```js\n * import { getUserContent } from \"@esri/arcgis-rest-portal\";\n * //\n * getUserContent({\n * owner: 'geemike',\n * folderId: 'bao7',\n * start: 1,\n * num: 20,\n * authentication\n * })\n * ```\n * Returns a listing of the user's content. If the `username` is not supplied, it defaults to the username of the authenticated user. If `start` is not specificed it defaults to the first page.\n * If the `num` is not supplied it is defaulted to 10. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-content.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise<IUserContentResponse>\n */\nexport const getUserContent = (\n requestOptions: IUserContentRequestOptions\n): Promise<IUserContentResponse> => {\n const {\n folderId: folder,\n start = 1,\n num = 10,\n authentication,\n } = requestOptions;\n const suffix = folder ? `/${folder}` : \"\";\n\n return determineOwner(requestOptions)\n .then((owner) => `${getPortalUrl(requestOptions)}/content/users/${owner}${suffix}`)\n .then((url) => request(url, {\n httpMethod: \"GET\",\n authentication,\n params: {\n start,\n num,\n },\n })\n );\n};\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IAddFolderResponse,\n IUpdateItemResponse,\n ICreateUpdateItemOptions,\n serializeItem,\n determineOwner,\n isBBox,\n bboxToString\n} from \"./helpers\";\n\nexport interface ICreateFolderOptions extends ICreateUpdateItemOptions {\n /**\n * Name of the folder to create.\n */\n title: string;\n}\n\nexport interface ICreateItemOptions extends ICreateUpdateItemOptions {\n item: IItemAdd;\n}\n\nexport interface ICreateItemResponse extends IUpdateItemResponse {\n folder: string;\n}\n\n/**\n * ```js\n * import { createFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * createFolder({\n * title: 'Map Collection',\n * authentication: userSession\n * })\n * .then(response)\n * ```\n * Create a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/create-folder.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that resolves with folder details once the folder has been created\n */\nexport function createFolder(\n requestOptions: ICreateFolderOptions\n): Promise<IAddFolderResponse> {\n return determineOwner(requestOptions).then(owner => {\n const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;\n const url = `${baseUrl}/createFolder`;\n\n requestOptions.params = {\n title: requestOptions.title,\n ...requestOptions.params\n };\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { createItemInFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * createItemInFolder({\n * item: {\n * title: \"The Amazing Voyage\",\n * type: \"Web Map\"\n * },\n * folderId: 'fe8',\n * authentication\n * })\n * ```\n * Create an item in a folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item.htm) for more information.\n *\n * @param requestOptions = Options for the request\n */\nexport function createItemInFolder(\n requestOptions: ICreateItemOptions\n): Promise<ICreateItemResponse> {\n if (requestOptions.multipart && !requestOptions.filename) {\n return Promise.reject(\n new Error(\"The filename is required for a multipart request.\")\n );\n }\n\n return determineOwner(requestOptions).then(owner => {\n const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;\n let url = `${baseUrl}/addItem`;\n\n if (requestOptions.folderId) {\n url = `${baseUrl}/${requestOptions.folderId}/addItem`;\n }\n\n requestOptions.params = {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n };\n\n // convert extent, if present, into a string from bbox\n // processParams was previously doing this sort of work,\n // however now we need to let array of arrays through\n // Thus for extents we need to move this logic here\n if (requestOptions.params.extent && isBBox(requestOptions.params.extent)) {\n requestOptions.params.extent = bboxToString(requestOptions.params.extent);\n }\n\n // serialize the item into something Portal will accept\n const options = appendCustomParams<ICreateItemOptions>(\n requestOptions,\n [\n \"owner\",\n \"folderId\",\n \"file\",\n \"dataUrl\",\n \"text\",\n \"async\",\n \"multipart\",\n \"filename\",\n \"overwrite\"\n ],\n {\n params: { ...requestOptions.params }\n }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { createItem } from \"@esri/arcgis-rest-portal\";\n * //\n * createItem({\n * item: {\n * title: \"The Amazing Voyage\",\n * type: \"Web Map\"\n * },\n * authentication\n * })\n * ```\n * Create an Item in the user's root folder. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that creates an item.\n */\nexport function createItem(\n requestOptions: ICreateItemOptions\n): Promise<ICreateItemResponse> {\n // delegate to createItemInFolder placing in the root of the filestore\n const options = {\n folderId: null,\n ...requestOptions\n } as ICreateItemOptions;\n return createItemInFolder(options);\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { determineOwner, IUserItemOptions } from './helpers';\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { ISpatialReference } from '@esri/arcgis-rest-types';\n\ntype ExportFormat = 'Shapefile' | 'CSV' | 'File Geodatabase' | 'Feature Collection' | 'GeoJson' | 'Scene Package' | 'KML' | 'Excel';\n\nexport interface IExportLayerInfo {\n id: number;\n where?: string;\n includeGeometry?: boolean;\n xColumnName?: string;\n yColumnName?: string;\n}\n\nexport interface IExportParameters {\n layers?: IExportLayerInfo[];\n targetSR?: ISpatialReference | string;\n}\n\nexport interface IExportItemRequestOptions extends IUserItemOptions {\n title?: string;\n exportFormat: ExportFormat;\n exportParameters?: IExportParameters;\n}\n\nexport interface IExportItemResponse {\n type: string;\n size: number;\n jobId: string;\n exportItemId: string;\n serviceItemId: string;\n exportFormat: ExportFormat;\n}\n\n/**\n * ```js\n * import { exportItem } from \"@esri/arcgis-rest-portal\";\n * //\n * exportItem({\n * id: '3daf',\n * owner: 'geemike',\n * exportFormat: 'CSV',\n * exportParameters: {\n * layers: [\n * { id: 0 },\n * { id: 1, where: 'POP1999 > 100000' }\n * ]\n * },\n * authentication,\n * })\n * ```\n * Exports an item from the portal. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/export-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise<IExportItemResponse>\n */\nexport const exportItem = (requestOptions: IExportItemRequestOptions) : Promise<IExportItemResponse> => {\n const {\n authentication,\n id: itemId,\n title,\n exportFormat,\n exportParameters\n } = requestOptions;\n\n return determineOwner(requestOptions)\n .then(owner => `${getPortalUrl(requestOptions)}/content/users/${owner}/export`)\n .then(url => request(url, {\n httpMethod: 'POST',\n authentication,\n params: {\n itemId,\n title,\n exportFormat,\n exportParameters\n }\n })\n );\n}\n","// eslint-disable-next-line no-control-regex\nconst CONTROL_CHAR_MATCHER = /[\\x00-\\x1F\\x7F-\\x9F\\xA0]/g;\n\n/**\n * Returns a new string with all control characters removed.\n *\n * Doesn't remove characters from input string.\n *\n * @param str - the string to scrub\n */\nexport function scrubControlChars (str: string) {\n return str.replace(CONTROL_CHAR_MATCHER, \"\");\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\nimport { IItem, IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { scrubControlChars } from '../util/scrub-control-chars';\nimport {\n IItemDataOptions,\n IItemRelationshipOptions,\n IUserItemOptions,\n determineOwner,\n FetchReadMethodName\n} from \"./helpers\";\n\n/**\n * ```\n * import { getItem } from \"@esri/arcgis-rest-portal\";\n * //\n * getItem(\"ae7\")\n * .then(response);\n * // or\n * getItem(\"ae7\", { authentication })\n * .then(response)\n * ```\n * Get an item by id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item.htm) for more information.\n *\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function getItem(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IItem> {\n const url = getItemBaseUrl(id, requestOptions);\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Get the fully qualified base URL to the REST end point for an item.\n * @param id Item Id\n * @param portalUrlOrRequestOptions a portal URL or request options\n * @returns URL to the item's REST end point, defaults to `https://www.arcgis.com/sharing/rest/content/items/{id}`\n */\nexport const getItemBaseUrl = (\n id: string,\n portalUrlOrRequestOptions?: string | IRequestOptions\n) => {\n const portalUrl =\n typeof portalUrlOrRequestOptions === \"string\"\n ? portalUrlOrRequestOptions\n : getPortalUrl(portalUrlOrRequestOptions);\n return `${portalUrl}/content/items/${id}`;\n};\n\n/**\n * ```\n * import { getItemData } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemData(\"ae7\")\n * .then(response)\n * // or\n * getItemData(\"ae7\", { authentication })\n * .then(response)\n * ```\n * Get the /data for an item. If no data exists, returns `undefined`. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item-data.htm) for more information.\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the json data for the item.\n */\nexport function getItemData(\n id: string,\n requestOptions?: IItemDataOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}/data`;\n // default to a GET request\n const options: IItemDataOptions = {\n ...{ httpMethod: \"GET\", params: {} },\n ...requestOptions\n };\n\n if (options.file) {\n options.params.f = null;\n }\n\n return request(url, options).catch(err => {\n /* if the item doesn't include data, the response will be empty\n and the internal call to response.json() will fail */\n const emptyResponseErr = RegExp(\n /The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i\n );\n /* istanbul ignore else */\n if (emptyResponseErr.test(err.message)) {\n return;\n } else throw err;\n });\n}\n\nexport interface IGetRelatedItemsResponse {\n total: number;\n relatedItems: IItem[];\n}\n\n/**\n * ```\n * import { getRelatedItems } from \"@esri/arcgis-rest-portal\";\n * //\n * getRelatedItems({\n * id: \"ae7\",\n * relationshipType: \"Service2Layer\" // or several [\"Service2Layer\", \"Map2Area\"]\n * })\n * .then(response)\n * ```\n * Get the related items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/related-items.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item resources.\n */\nexport function getRelatedItems(\n requestOptions: IItemRelationshipOptions\n): Promise<IGetRelatedItemsResponse> {\n const url = `${getItemBaseUrl(\n requestOptions.id,\n requestOptions\n )}/relatedItems`;\n\n const options: IItemRelationshipOptions = {\n httpMethod: \"GET\",\n params: {\n direction: requestOptions.direction\n },\n ...requestOptions\n };\n\n if (typeof requestOptions.relationshipType === \"string\") {\n options.params.relationshipType = requestOptions.relationshipType;\n } else {\n options.params.relationshipTypes = requestOptions.relationshipType;\n }\n\n delete options.direction;\n delete options.relationshipType;\n\n return request(url, options);\n}\n\n/**\n * Get the resources associated with an item\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item resources.\n */\nexport function getItemResources(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}/resources`;\n\n // Mix in num:1000 with any user supplied params\n // Key thing - we don't want to mutate the passed in requestOptions\n // as that may be used in other (subsequent) calls in the course\n // of a long promise chains\n const options: IRequestOptions = {\n ...requestOptions\n };\n options.params = { num: 1000, ...options.params };\n\n return request(url, options);\n}\n\nexport interface IGetItemGroupsResponse {\n admin?: IGroup[];\n member?: IGroup[];\n other?: IGroup[];\n}\n\nexport interface IGetItemResourceOptions extends IRequestOptions {\n /**\n * Name of the info file, optionally including the folder path\n */\n fileName: string;\n /**\n * How the fetch response should be read, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\n readAs?: FetchReadMethodName;\n}\n\n/**\n * ```js\n * import { getItemResource } from \"@esri/arcgis-rest-portal\";\n *\n * // Parses contents as blob by default\n * getItemResource(\"3ef\", { fileName: \"resource.jpg\", ...})\n * .then(resourceContents => {});\n *\n * // Can override parse method\n * getItemResource(\"3ef\", { fileName: \"resource.json\", readAs: 'json', ...})\n * .then(resourceContents => {});\n *\n * // Get the response object instead\n * getItemResource(\"3ef\",{ rawResponse: true, fileName: \"resource.json\" })\n * .then(response => {})\n * ```\n * Fetches an item resource and optionally parses it to the correct format.\n *\n * Note: provides JSON parse error protection by sanitizing out any unescaped control\n * characters before parsing that would otherwise cause an error to be thrown\n *\n * @param {string} itemId\n * @param {IGetItemResourceOptions} requestOptions\n */\nexport function getItemResource(\n itemId: string,\n requestOptions: IGetItemResourceOptions\n) {\n const readAs = requestOptions.readAs || 'blob';\n return getItemFile(itemId, `/resources/${requestOptions.fileName}`, readAs, requestOptions);\n}\n\n\n/**\n * ```js\n * import { getItemGroups } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemGroups(\"30e5fe3149c34df1ba922e6f5bbf808f\")\n * .then(response)\n * ```\n * Lists the groups of which the item is a part, only showing the groups that the calling user can access. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/groups.htm) for more information.\n *\n * @param id - The Id of the item to query group association for.\n * @param requestOptions - Options for the request\n * @returns A Promise to get some item groups.\n */\nexport function getItemGroups(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGetItemGroupsResponse> {\n const url = `${getItemBaseUrl(id, requestOptions)}/groups`;\n\n return request(url, requestOptions);\n}\n\nexport interface IItemStatusOptions extends IUserItemOptions {\n /**\n * The type of asynchronous job for which the status has to be checked. Default is none, which check the item's status.\n */\n jobType?: \"publish\" | \"generateFeatures\" | \"export\" | \"createService\";\n /**\n * The job ID returned during publish, generateFeatures, export, and createService calls.\n */\n jobId?: string;\n /**\n * The response format. The default and the only response format for this resource is HTML.\n */\n format?: \"html\";\n}\n\nexport interface IGetItemStatusResponse {\n status: \"partial\" | \"processing\" | \"failed\" | \"completed\";\n statusMessage: string;\n itemId: string;\n}\n\n/**\n * ```js\n * import { getItemStatus } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemStatus({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Inquire about status when publishing an item, adding an item in async mode, or adding with a multipart upload. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/status.htm) for more information.\n *\n * @param id - The Id of the item to get status for.\n * @param requestOptions - Options for the request\n * @returns A Promise to get the item status.\n */\nexport function getItemStatus(\n requestOptions: IItemStatusOptions\n): Promise<IGetItemStatusResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/status`;\n\n const options = appendCustomParams<IItemStatusOptions>(\n requestOptions,\n [\"jobId\", \"jobType\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\nexport interface IGetItemPartsResponse {\n parts: number[];\n}\n\n/**\n * ```js\n * import { getItemParts } from \"@esri/arcgis-rest-portal\";\n * //\n * getItemParts({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Lists the part numbers of the file parts that have already been uploaded in a multipart file upload. This method can be used to verify the parts that have been received as well as those parts that were not received by the server. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/parts.htm) for more information.\n *\n * @param id - The Id of the item to get part list.\n * @param requestOptions - Options for the request\n * @returns A Promise to get the item part list.\n */\nexport function getItemParts(\n requestOptions: IUserItemOptions\n): Promise<IGetItemPartsResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/parts`;\n return request(url, requestOptions);\n });\n}\n\nexport interface IGetItemInfoOptions extends IRequestOptions {\n /**\n * Name of the info file, optionally including the folder path\n */\n fileName?: string;\n /**\n * How the fetch response should be read, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods\n */\n readAs?: FetchReadMethodName;\n}\n\n/**\n * ```\n * import { getItemInfo } from \"@esri/arcgis-rest-portal\";\n * // get the \"Info Card\" for the item\n * getItemInfo(\"ae7\")\n * .then(itemInfoXml) // XML document as a string\n * // or get the contents of a specific file\n * getItemInfo(\"ae7\", { fileName: \"form.json\", readAs: \"json\", authentication })\n * .then(formJson) // JSON document as JSON\n * ```\n * Get an info file for an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/item-info-file.htm) for more information.\n * @param id - Item Id\n * @param requestOptions - Options for the request, including the file name which defaults to `iteminfo.xml`.\n * If the file is not a text file (XML, HTML, etc) you will need to specify the `readAs` parameter\n * @returns A Promise that will resolve with the contents of the info file for the item.\n */\nexport function getItemInfo(\n id: string,\n requestOptions?: IGetItemInfoOptions\n): Promise<any> {\n const { fileName = \"iteminfo.xml\", readAs = \"text\" } = requestOptions || {};\n const options: IRequestOptions = {\n httpMethod: \"GET\",\n ...requestOptions\n };\n return getItemFile(id, `/info/${fileName}`, readAs, options);\n}\n\n/**\n * ```\n * import { getItemMetadata } from \"@esri/arcgis-rest-portal\";\n * // get the metadata for the item\n * getItemMetadata(\"ae7\")\n * .then(itemMetadataXml) // XML document as a string\n * // or with additional request options\n * getItemMetadata(\"ae7\", { authentication })\n * .then(itemMetadataXml) // XML document as a string\n * ```\n * Get the standard formal metadata XML file for an item (`/info/metadata/metadata.xml`)\n * @param id - Item Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the contents of the metadata file for the item as a string.\n */\nexport function getItemMetadata(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const options = {\n ...requestOptions,\n fileName: \"metadata/metadata.xml\"\n } as IGetItemInfoOptions;\n return getItemInfo(id, options);\n}\n\n// overrides request()'s default behavior for reading the response\n// which is based on `params.f` and defaults to JSON\n// Also adds JSON parse error protection by sanitizing out any unescaped control characters before parsing\nfunction getItemFile(\n id: string,\n // NOTE: fileName should include any folder/subfolders\n fileName: string,\n readMethod: FetchReadMethodName,\n requestOptions?: IRequestOptions\n): Promise<any> {\n const url = `${getItemBaseUrl(id, requestOptions)}${fileName}`;\n // preserve escape hatch to let the consumer read the response\n // and ensure the f param is not appended to the query string\n const options: IRequestOptions = {\n params: {},\n ...requestOptions\n };\n const justReturnResponse = options.rawResponse;\n options.rawResponse = true;\n options.params.f = null;\n\n return request(url, options).then(response => {\n if (justReturnResponse) {\n return response;\n }\n return readMethod !== 'json'\n ? response[readMethod]()\n : response.text().then((text: string) => JSON.parse(scrubControlChars(text)));\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserItemOptions, determineOwner } from \"./helpers\";\n\n/**\n * Protect an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/protect.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to protect an item.\n */\nexport function protectItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/protect`;\n return request(url, requestOptions);\n });\n}\n\n/**\n * Unprotect an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unprotect.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to unprotect an item.\n */\nexport function unprotectItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/unprotect`;\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\nimport { IPagingParams, IGroup, IItem, IUser } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IGroupCategorySchema {\n categorySchema: IGroupCategory[];\n}\n\nexport interface IGroupCategory {\n title: string;\n description?: string;\n categories?: IGroupCategory[];\n}\n\nexport interface IGetGroupContentOptions extends IRequestOptions {\n paging: IPagingParams;\n}\n\nexport interface IGroupContentResult {\n total: number;\n start: number;\n num: number;\n nextStart: number;\n items: IItem[];\n}\n\nexport interface IGroupUsersResult {\n owner: string;\n admins: string[];\n users: string[];\n}\n\n/**\n * ```js\n * import { getGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * getGroup(\"fxb988\") // id\n * .then(response)\n * ```\n * Fetch a group using its id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group.htm) for more information.\n *\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function getGroup(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroup> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}`;\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Gets the category schema set on a group\n *\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A promise that will resolve with JSON of group's category schema\n * @see https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm\n */\nexport function getGroupCategorySchema(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroupCategorySchema> {\n const url = `${getPortalUrl(\n requestOptions\n )}/community/groups/${id}/categorySchema`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\n/**\n * Returns the content of a Group. Since the group may contain 1000s of items\n * the requestParams allow for paging.\n * @param id - Group Id\n * @param requestOptions - Options for the request, including paging parameters.\n * @returns A Promise that will resolve with the content of the group.\n */\nexport function getGroupContent(\n id: string,\n requestOptions?: IGetGroupContentOptions\n): Promise<IGroupContentResult> {\n const url = `${getPortalUrl(requestOptions)}/content/groups/${id}`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n params: { start: 1, num: 100 },\n ...requestOptions\n } as IGetGroupContentOptions;\n\n // is this the most concise way to mixin with the defaults above?\n if (requestOptions && requestOptions.paging) {\n options.params = { ...requestOptions.paging };\n }\n\n return request(url, options);\n}\n\n/**\n * Get the usernames of the admins and members. Does not return actual 'User' objects. Those must be\n * retrieved via separate calls to the User's API.\n * @param id - Group Id\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with arrays of the group admin usernames and the member usernames\n */\nexport function getGroupUsers(\n id: string,\n requestOptions?: IRequestOptions\n): Promise<IGroupUsersResult> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/users`;\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n return request(url, options);\n}\n\nexport interface ISearchGroupUsersOptions\n extends IRequestOptions,\n IPagingParams {\n name?: string;\n sortField?: string;\n sortOrder?: string;\n joined?: number | number[];\n memberType?: string;\n [key: string]: any;\n}\n\nexport interface ISearchGroupUsersResult {\n total: number;\n start: number;\n num: number;\n nextStart: number;\n owner: IUser;\n users: any[];\n}\n\n/**\n * ```js\n * import { searchGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroupUsers('abc123')\n * .then(response)\n * ```\n * Search the users in a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-users-list.htm) for more information.\n *\n * @param id - The group id\n * @param searchOptions - Options for the request, including paging parameters.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroupUsers(\n id: string,\n searchOptions?: ISearchGroupUsersOptions\n): Promise<ISearchGroupUsersResult> {\n const url = `${getPortalUrl(searchOptions)}/community/groups/${id}/userlist`;\n const options = appendCustomParams<ISearchGroupUsersOptions>(\n searchOptions || {},\n [\"name\", \"num\", \"start\", \"sortField\", \"sortOrder\", \"joined\", \"memberType\"],\n {\n httpMethod: \"GET\"\n }\n );\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IGroup, IUser, GroupMembership } from \"@esri/arcgis-rest-types\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { getGroup } from \"../groups/get\";\n\nexport interface ISharingOptions extends IUserRequestOptions {\n /**\n * Unique identifier for the item.\n */\n id: string;\n /**\n * Item owner, if different from the authenticated user.\n */\n owner?: string;\n}\n\nexport interface ISharingResponse {\n notSharedWith?: string[];\n notUnsharedFrom?: string[];\n itemId: string;\n}\n\nexport function getSharingUrl(requestOptions: ISharingOptions): string {\n const username = requestOptions.authentication.username;\n const owner = requestOptions.owner || username;\n return `${getPortalUrl(requestOptions)}/content/users/${encodeURIComponent(\n owner\n )}/items/${requestOptions.id}/share`;\n}\n\nexport function isItemOwner(requestOptions: ISharingOptions): boolean {\n const username = requestOptions.authentication.username;\n const owner = requestOptions.owner || username;\n return owner === username;\n}\n\n/**\n * Check it the user is a full org_admin\n * @param requestOptions\n * @returns Promise resolving in a boolean indicating if the user is an ArcGIS Organization administrator\n */\nexport function isOrgAdmin(\n requestOptions: IUserRequestOptions\n): Promise<boolean> {\n const session = requestOptions.authentication;\n\n return session.getUser(requestOptions).then((user: IUser) => {\n return user && user.role === \"org_admin\" && !user.roleId;\n });\n}\n\n/**\n * Get the User Membership for a particular group. Use this if all you have is the groupId.\n * If you have the group object, check the `userMembership.memberType` property instead of calling this method.\n *\n * @param requestOptions\n * @returns A Promise that resolves with \"owner\" | \"admin\" | \"member\" | \"nonmember\"\n */\nexport function getUserMembership(\n requestOptions: IGroupSharingOptions\n): Promise<GroupMembership> {\n // fetch the group...\n return getGroup(requestOptions.groupId, requestOptions)\n .then((group: IGroup) => {\n return group.userMembership.memberType;\n })\n .catch(() => {\n return \"none\" as GroupMembership;\n });\n}\n\nexport interface IGroupSharingOptions extends ISharingOptions {\n /**\n * Group identifier\n */\n groupId: string;\n confirmItemControl?: boolean;\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItem } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { isOrgAdmin } from \"../sharing/helpers\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\ninterface IReassignItemOptions extends IUserRequestOptions {\n id: string;\n currentOwner: string;\n targetUsername: string;\n targetFolderName?: string;\n}\n\ninterface IReassignItemResponse {\n success: boolean;\n itemId: string;\n}\n\n/**\n * ```js\n * import { reassignItem } from '@esri/arcgis-rest-portal';\n * //\n * reassignItem({\n * id: \"abc123\",\n * currentOwner: \"charles\",\n * targetUsername: \"leslie\",\n * authentication\n * })\n * ```\n * Reassign an item from one user to another.\n * Caller must be an org admin or the request will fail.\n * `currentOwner` and `targetUsername` must be in the same\n * organization or the request will fail\n * @param reassignOptions - Options for the request\n */\nexport function reassignItem(\n reassignOptions: IReassignItemOptions\n): Promise<IReassignItemResponse> {\n return isOrgAdmin(reassignOptions).then(isAdmin => {\n if (!isAdmin) {\n throw Error(\n `Item ${reassignOptions.id} can not be reassigned because current user is not an organization administrator.`\n );\n }\n // we're operating as an org-admin\n const url = `${getPortalUrl(reassignOptions)}/content/users/${\n reassignOptions.currentOwner\n }/items/${reassignOptions.id}/reassign`;\n\n const opts = {\n params: {\n targetUsername: reassignOptions.targetUsername,\n targetFolderName: reassignOptions.targetFolderName\n },\n authentication: reassignOptions.authentication\n };\n return request(url, opts);\n });\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IRemoveItemResourceOptions,\n IFolderIdOptions,\n determineOwner,\n IManageItemRelationshipOptions\n} from \"./helpers\";\n\n/**\n * ```js\n * import { removeItem } from \"@esri/arcgis-rest-portal\";\n * //\n * removeItem({\n * id: \"3ef\",\n * authentication\n * })\n * ```\n * Delete an item from the portal. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-item.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes an item.\n */\nexport function removeItem(\n requestOptions: IUserItemOptions\n): Promise<{ success: boolean; itemId: string }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/delete`;\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { removeItemRelationship } from \"@esri/arcgis-rest-portal\";\n * //\n * removeItemRelationship({\n * originItemId: '3ef',\n * destinationItemId: 'ae7',\n * relationshipType: 'Service2Layer',\n * authentication\n * })\n * .then(response)\n * ```\n * Remove a relationship between two items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-relationship.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add item resources.\n */\nexport function removeItemRelationship(\n requestOptions: IManageItemRelationshipOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${owner}/deleteRelationship`;\n\n const options = appendCustomParams<IManageItemRelationshipOptions>(\n requestOptions,\n [\"originItemId\", \"destinationItemId\", \"relationshipType\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * Remove a resource associated with an item\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes an item resource.\n */\nexport function removeItemResource(\n requestOptions: IRemoveItemResourceOptions\n): Promise<{ success: boolean }> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/removeResources`;\n\n // mix in user supplied params\n requestOptions.params = {\n ...requestOptions.params,\n resource: requestOptions.resource\n };\n\n // only override the deleteAll param specified previously if it is passed explicitly\n if (typeof requestOptions.deleteAll !== \"undefined\") {\n requestOptions.params.deleteAll = requestOptions.deleteAll;\n }\n\n return request(url, requestOptions);\n });\n}\n\n/**\n * ```js\n * import { removeFolder } from \"@esri/arcgis-rest-portal\";\n * //\n * removeFolder({\n * folderId: \"fe4\",\n * owner: \"c@sey\",\n * authentication\n * })\n * .then(response)\n *\n * ```\n * Delete a non-root folder and all the items it contains. See the [REST\n * Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-folder.htm) for\n * more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that deletes a folder\n */\nexport function removeFolder(\n requestOptions: IFolderIdOptions\n): Promise<{\n success: boolean;\n folder: {\n username: string;\n id: string;\n title: string;\n };\n}> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(\n requestOptions\n )}/content/users/${encodeURIComponent(owner)}/${\n requestOptions.folderId\n }/delete`;\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2018-2021 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IParamBuilder, warn } from \"@esri/arcgis-rest-request\";\n\n/**\n * `SearchQueryBuilder` can be used to construct the `q` param for\n * [`searchItems`](/arcgis-rest-js/api/portal/searchItems#searchItems-search) or\n * [`searchGroups`](/arcgis-rest-js/api/portal/searchGroups#searchGroups-search).\n * By chaining methods, it helps build complex search queries.\n *\n * ```js\n * const startDate = new Date(\"2020-01-01\");\n * const endDate = new Date(\"2020-09-01\");\n * const query = new SearchQueryBuilder()\n * .match(\"Patrick\")\n * .in(\"owner\")\n * .and()\n * .from(startDate)\n * .to(endDate)\n * .in(\"created\")\n * .and()\n * .startGroup()\n * .match(\"Web Mapping Application\")\n * .in(\"type\")\n * .or()\n * .match(\"Mobile Application\")\n * .in(\"type\")\n * .or()\n * .match(\"Application\")\n * .in(\"type\")\n * .endGroup()\n * .and()\n * .match(\"Demo App\");\n *\n * searchItems(query).then((res) => {\n * console.log(res.results);\n * });\n * ```\n *\n * Will search for items matching\n * ```\n * \"owner: Patrick AND created:[1577836800000 TO 1598918400000] AND (type:\"Web Mapping Application\" OR type:\"Mobile Application\" OR type:Application) AND Demo App\"\n * ```\n */\nexport class SearchQueryBuilder implements IParamBuilder {\n private termStack: any[] = [];\n private rangeStack: any[] = [];\n private q: string;\n private openGroups = 0;\n private currentModifer: string;\n\n /**\n * @param q An existing query string to start building from.\n */\n constructor(q = \"\") {\n this.q = q;\n }\n\n /**\n * Defines strings to search for.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"My Layer\")\n * ```\n *\n * @param terms strings to search for.\n */\n public match(this: SearchQueryBuilder, ...terms: string[]) {\n this.termStack = this.termStack.concat(terms);\n return this;\n }\n\n /**\n * Defines fields to search in. You can pass `\"*\"` or call this method without arguments to search a default set of fields\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"My Layer\")\n * .in(\"title\")\n * ```\n *\n * @param field The field to search for the previous match in.\n */\n public in(this: SearchQueryBuilder, field?: string) {\n const fn = `\\`in(${field ? `\"${field}\"` : \"\"})\\``;\n\n if (!this.hasRange && !this.hasTerms) {\n warn(\n // apparently-p-rettier-ignore causes some\n `${fn} was called with no call to \\`match(...)\\` or \\`from(...)\\`/\\`to(...)\\`. Your query was not modified.`\n );\n return this;\n }\n\n if (field && field !== \"*\") {\n this.q += `${field}:`;\n }\n\n return this.commit();\n }\n\n /**\n * Starts a new search group.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .startGroup()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .endGroup()\n * .or()\n * .startGroup()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .endGroup()\n * ```\n */\n public startGroup(this: SearchQueryBuilder) {\n this.commit();\n if (this.openGroups > 0) {\n this.q += \" \";\n }\n this.openGroups++;\n this.q += \"(\";\n return this;\n }\n\n /**\n * Ends a search group.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .startGroup()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .endGroup()\n * .or()\n * .startGroup()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .endGroup()\n * ```\n */\n public endGroup(this: SearchQueryBuilder) {\n if (this.openGroups <= 0) {\n warn(\n `\\`endGroup(...)\\` was called without calling \\`startGroup(...)\\` first. Your query was not modified.`\n );\n return this;\n }\n this.commit();\n this.openGroups--;\n this.q += \")\";\n return this;\n }\n\n /**\n * Joins two sets of queries with an `AND` clause.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .and()\n * .match(\"Rivers\")\n * .in(\"title\")\n * ```\n */\n public and(this: SearchQueryBuilder) {\n return this.addModifier(\"and\");\n }\n\n /**\n * Joins two sets of queries with an `OR` clause.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .or()\n * .match(\"Rivers\")\n * .in(\"title\")\n * ```\n */\n public or(this: SearchQueryBuilder) {\n return this.addModifier(\"or\");\n }\n\n /**\n * Joins two sets of queries with a `NOT` clause. Another option for filtering results is the [prohibit operator '-'](https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm#ESRI_SECTION1_5C6C35DB9E4A4F4492C5B937BDA2BF67).\n *\n * ```js\n * // omit results with \"Rivers\" in their title\n * const query = new SearchQueryBuilder()\n * .not()\n * .match(\"Rivers\")\n * .in(\"title\")\n *\n * // equivalent\n * const query = new SearchQueryBuilder()\n * .match(\"Rivers\")\n * .in(\"-title\")\n * ```\n */\n public not(this: SearchQueryBuilder) {\n return this.addModifier(\"not\");\n }\n\n /**\n * Begins a new range query.\n *\n * ```js\n *\n * const NEWYEARS = new Date(\"2020-01-01\")\n * const TODAY = new Date()\n *\n * const query = new SearchQueryBuilder()\n * .from(NEWYEARS)\n * .to(TODAY)\n * .in(\"created\")\n * ```\n */\n public from(this: SearchQueryBuilder, term: number | string | Date) {\n if (this.hasTerms) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `\\`from(...)\\` is not allowed after \\`match(...)\\` try using \\`.from(...).to(...).in(...)\\`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date(\"2020-01-01\"). Your query was not modified.`\n );\n return this;\n }\n this.rangeStack[0] = term;\n return this;\n }\n\n /**\n * Ends a range query.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .from(yesterdaysDate)\n * .to(todaysDate)\n * .in(\"created\")\n * ```\n */\n public to(this: SearchQueryBuilder, term: any) {\n if (this.hasTerms) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `\\`to(...)\\` is not allowed after \\`match(...)\\` try using \\`.from(...).to(...).in(...)\\`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date(\"2020-01-01\"). Your query was not modified.`\n );\n return this;\n }\n this.rangeStack[1] = term;\n return this;\n }\n\n /**\n * Boosts the previous term to increase its rank in the results.\n *\n * ```js\n * const query = new SearchQueryBuilder()\n * .match(\"Lakes\")\n * .in(\"title\")\n * .or()\n * .match(\"Rivers\")\n * .in(\"title\")\n * .boost(3)\n * ```\n */\n public boost(this: SearchQueryBuilder, num: number) {\n this.commit();\n this.q += `^${num}`;\n return this;\n }\n\n /**\n * Returns the current query string. Called internally when the request is made.\n */\n public toParam() {\n this.commit();\n this.cleanup();\n return this.q;\n }\n\n /**\n * Returns a new instance of `SearchQueryBuilder` based on the current instance.\n */\n public clone() {\n this.commit();\n this.cleanup();\n return new SearchQueryBuilder(this.q + \"\");\n }\n\n private addModifier(modifier: string) {\n if (this.currentModifer) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `You have called \\`${this.currentModifer}()\\` after \\`${modifier}()\\`. Your current query was not modified.`\n );\n return this;\n }\n\n this.commit();\n\n if (this.q === \"\" && modifier !== \"not\") {\n warn(\n `You have called \\`${modifier}()\\` without calling another method to modify your query first. Try calling \\`match()\\` first.`\n );\n return this;\n }\n\n this.currentModifer = modifier;\n this.q += this.q === \"\" ? \"\" : \" \";\n this.q += `${modifier.toUpperCase()} `;\n return this;\n }\n\n private needsQuotes(s: string) {\n return /\\s|:/g.test(s);\n }\n\n private formatTerm(term: any) {\n if (term instanceof Date) {\n return term.getTime();\n }\n\n if (typeof term === \"string\" && this.needsQuotes(term)) {\n return `\"${term}\"`;\n }\n\n return term;\n }\n\n private commit() {\n this.currentModifer = undefined;\n if (this.hasRange) {\n this.q += `[${this.formatTerm(this.rangeStack[0])} TO ${this.formatTerm(\n this.rangeStack[1]\n )}]`;\n this.rangeStack = [undefined, undefined];\n }\n\n if (this.hasTerms) {\n this.q += this.termStack\n .map((term) => {\n return this.formatTerm(term);\n })\n .join(\" \");\n this.termStack = [];\n }\n\n return this;\n }\n\n private get hasTerms() {\n return this.termStack.length > 0;\n }\n\n private get hasRange() {\n return this.rangeStack.length && this.rangeStack[0] && this.rangeStack[1];\n }\n\n private cleanup() {\n // end a group if we have started one\n if (this.openGroups > 0) {\n warn(\n // apparently-p*rettier-ignore causes prettier to strip *all* comments O_o\n `Automatically closing ${this.openGroups} group(s). You can use \\`endGroup(...)\\` to remove this warning.`\n );\n\n while (this.openGroups > 0) {\n this.q += \")\";\n this.openGroups--;\n }\n }\n\n const oldQ = this.q;\n this.q = oldQ.replace(/( AND ?| NOT ?| OR ?)*$/, \"\");\n\n if (oldQ !== this.q) {\n warn(\n `\\`startGroup(...)\\` was called without calling \\`endGroup(...)\\` first. Your query was not modified.`\n );\n }\n\n // clear empty groups\n this.q = this.q.replace(/(\\(\\))*/, \"\");\n }\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n appendCustomParams,\n} from \"@esri/arcgis-rest-request\";\nimport { IItem, IGroup, IUser } from \"@esri/arcgis-rest-types\";\n\nimport { SearchQueryBuilder } from \"./SearchQueryBuilder\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n ISearchOptions,\n ISearchGroupContentOptions,\n ISearchResult,\n} from \"../util/search\";\n\nexport function genericSearch<T extends IItem | IGroup | IUser>(\n search:\n | string\n | ISearchOptions\n | ISearchGroupContentOptions\n | SearchQueryBuilder,\n searchType: \"item\" | \"group\" | \"groupContent\" | \"user\"\n): Promise<ISearchResult<T>> {\n let options: IRequestOptions;\n if (typeof search === \"string\" || search instanceof SearchQueryBuilder) {\n options = {\n httpMethod: \"GET\",\n params: {\n q: search,\n },\n };\n } else {\n // searchUserAccess has one (knonw) valid value: \"groupMember\"\n options = appendCustomParams<ISearchOptions>(\n search,\n [\n \"q\",\n \"num\",\n \"start\",\n \"sortField\",\n \"sortOrder\",\n \"searchUserAccess\",\n \"searchUserName\",\n \"filter\",\n \"countFields\",\n \"countSize\",\n \"categories\",\n \"categoryFilters\",\n ],\n {\n httpMethod: \"GET\",\n }\n );\n }\n\n let path;\n switch (searchType) {\n case \"item\":\n path = \"/search\";\n break;\n case \"group\":\n path = \"/community/groups\";\n break;\n case \"groupContent\":\n // Need to have groupId property to do group contents search,\n // cso filter out all but ISearchGroupContentOptions\n if (\n typeof search !== \"string\" &&\n !(search instanceof SearchQueryBuilder) &&\n search.groupId\n ) {\n path = `/content/groups/${search.groupId}/search`;\n } else {\n return Promise.reject(\n new Error(\"you must pass a `groupId` option to `searchGroupContent`\")\n );\n }\n break;\n default:\n // \"users\"\n path = \"/portals/self/users/search\";\n break;\n }\n const url = getPortalUrl(options) + path;\n\n // send the request\n return request(url, options).then((r) => {\n if (r.nextStart && r.nextStart !== -1) {\n r.nextPage = function () {\n let newOptions: ISearchOptions;\n\n if (\n typeof search === \"string\" ||\n search instanceof SearchQueryBuilder\n ) {\n newOptions = {\n q: search,\n start: r.nextStart,\n };\n } else {\n newOptions = search;\n newOptions.start = r.nextStart;\n }\n\n return genericSearch<T>(newOptions, searchType);\n };\n }\n\n return r;\n });\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IItem } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport { ISearchOptions, ISearchResult } from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n/**\n * ```js\n * import { searchItems } from \"@esri/arcgis-rest-portal\";\n * //\n * searchItems('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for items. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/search.htm) for more information.\n *\n * @param search - A string or RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchItems(\n search: string | ISearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IItem>> {\n return genericSearch<IItem>(search, \"item\");\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { IItemAdd } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IUserItemOptions,\n IUpdateItemResponse,\n determineOwner,\n IItemPartOptions,\n serializeItem\n} from \"./helpers\";\n\nexport interface ICommitItemOptions extends IUserItemOptions {\n item: IItemAdd;\n}\n\n/**\n * ```js\n * import { addItemPart } from \"@esri/arcgis-rest-portal\";\n * //\n * addItemPart({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * file: data,\n * partNum: 1,\n * authentication\n * })\n * .then(response)\n * ```\n * Add Item Part allows the caller to upload a file part when doing an add or update item operation in multipart mode. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-item-part.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to add the item part status.\n */\nexport function addItemPart(\n requestOptions?: IItemPartOptions\n): Promise<IUpdateItemResponse> {\n const partNum = requestOptions.partNum;\n\n if (!Number.isInteger(partNum) || partNum < 1 || partNum > 10000) {\n return Promise.reject(new Error('The part number must be an integer between 1 to 10000, inclusive.'))\n }\n\n return determineOwner(requestOptions).then(owner => {\n // AGO adds the \"partNum\" parameter in the query string, not in the body\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/addPart?partNum=${partNum}`;\n\n const options = appendCustomParams<IItemPartOptions>(\n requestOptions,\n [\"file\"],\n { params: { ...requestOptions.params } }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { commitItemUpload } from \"@esri/arcgis-rest-portal\";\n * //\n * commitItemUpload({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Commit is called once all parts are uploaded during a multipart Add Item or Update Item operation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/commit.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get the commit result.\n */\nexport function commitItemUpload(\n requestOptions?: ICommitItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/commit`;\n\n const options = appendCustomParams<ICommitItemOptions>(\n requestOptions,\n [],\n {\n params: {\n ...requestOptions.params,\n ...serializeItem(requestOptions.item)\n }\n }\n );\n\n return request(url, options);\n });\n}\n\n/**\n * ```js\n * import { cancelItemUpload } from \"@esri/arcgis-rest-portal\";\n * //\n * cancelItemUpload({\n * id: \"30e5fe3149c34df1ba922e6f5bbf808f\",\n * authentication\n * })\n * .then(response)\n * ```\n * Cancels a multipart upload on an item. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/cancel.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise to get the commit result.\n */\nexport function cancelItemUpload(\n requestOptions?: IUserItemOptions\n): Promise<IUpdateItemResponse> {\n return determineOwner(requestOptions).then(owner => {\n const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${\n requestOptions.id\n }/cancel`;\n\n return request(url, requestOptions);\n });\n}\n","/* Copyright (c) 2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport function chunk<T>(array: T[], size: number) {\n if (array.length === 0) {\n return [];\n }\n\n const chunks = [];\n\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size));\n }\n\n return chunks;\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IAddGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be added to the group as group members\n */\n users?: string[];\n /**\n * An array of usernames to be added to the group as group admins\n */\n admins?: string[];\n}\n\nexport interface IAddGroupUsersResult {\n /**\n * An array of usernames that were not added\n */\n notAdded?: string[];\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * ```js\n * import { addGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * addGroupUsers({\n * id: groupId,\n * users: [\"username1\", \"username2\"],\n * admins: [\"username3\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Add users to a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/add-users-to-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function addGroupUsers(\n requestOptions: IAddGroupUsersOptions\n): Promise<IAddGroupUsersResult> {\n const id = requestOptions.id;\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/addUsers`;\n const baseOptions = Object.assign({}, requestOptions, {\n admins: undefined,\n users: undefined\n });\n\n const batchRequestOptions = [\n ..._prepareRequests(\"users\", requestOptions.users, baseOptions),\n ..._prepareRequests(\"admins\", requestOptions.admins, baseOptions)\n ];\n\n const promises = batchRequestOptions.map(options =>\n _sendSafeRequest(url, options)\n );\n\n return Promise.all(promises).then(_consolidateRequestResults);\n}\n\nfunction _prepareRequests(\n type: \"admins\" | \"users\",\n usernames: string[],\n baseOptions: IAddGroupUsersOptions\n): IAddGroupUsersOptions[] {\n if (!usernames || usernames.length < 1) {\n return [];\n }\n\n // the ArcGIS REST API only allows to add no more than 25 users per request,\n // see https://developers.arcgis.com/rest/users-groups-and-items/add-users-to-group.htm\n const userChunks: string[][] = chunk<string>(usernames, 25);\n\n return userChunks.map(users =>\n _generateRequestOptions(type, users, baseOptions)\n );\n}\n\nfunction _generateRequestOptions(\n type: \"admins\" | \"users\",\n usernames: string[],\n baseOptions: IAddGroupUsersOptions\n) {\n return Object.assign({}, baseOptions, {\n [type]: usernames,\n params: {\n ...baseOptions.params,\n [type]: usernames\n }\n });\n}\n\n// this request is safe since the request error will be handled\nfunction _sendSafeRequest(\n url: string,\n requestOptions: IAddGroupUsersOptions\n): Promise<IAddGroupUsersResult> {\n return request(url, requestOptions).catch(error => {\n return {\n errors: [error]\n };\n });\n}\n\nfunction _consolidateRequestResults(\n results: IAddGroupUsersResult[]\n): IAddGroupUsersResult {\n const notAdded = results\n .filter(result => result.notAdded)\n .reduce((collection, result) => collection.concat(result.notAdded), []);\n\n const errors = results\n .filter(result => result.errors)\n .reduce((collection, result) => collection.concat(result.errors), []);\n\n const consolidated: IAddGroupUsersResult = { notAdded };\n\n if (errors.length > 0) {\n consolidated.errors = errors;\n }\n\n return consolidated;\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IRemoveGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be removed from the group\n */\n users?: string[];\n}\n\nexport interface IRemoveGroupUsersResult {\n /**\n * An array of usernames that were not removed\n */\n notRemoved?: string[];\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * ```js\n * import { removeGroupUsers } from \"@esri/arcgis-rest-portal\";\n * //\n * removeGroupUsers({\n * id: groupId,\n * users: [\"username1\", \"username2\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Add users to a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/remove-users-from-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function removeGroupUsers (\n requestOptions: IRemoveGroupUsersOptions\n): Promise<IRemoveGroupUsersResult> {\n const { id, users: usersToRemove } = requestOptions;\n const url = `${getPortalUrl(requestOptions)}/community/groups/${id}/removeUsers`;\n const safeSend = (users: string[]) => {\n const options: IRemoveGroupUsersOptions = {\n ...requestOptions,\n users,\n params: { users }\n };\n return request(url, options)\n .catch(error => ({ errors: [error] }));\n };\n // the ArcGIS REST API only allows to add no more than 25 users per request,\n // see https://developers.arcgis.com/rest/users-groups-and-items/remove-users-from-group.htm\n const promises = chunk(usersToRemove, 25).map(usersChunk => safeSend(usersChunk));\n return Promise.all(promises)\n .then(results => {\n const filtered = (propName: string) => results\n .filter(result => result[propName])\n .reduce((collection, result) => collection.concat(result[propName]), []);\n const errors = filtered('errors');\n const consolidated: IRemoveGroupUsersResult = { notRemoved: filtered('notRemoved') };\n return errors.length ? { ...consolidated, errors } : consolidated;\n });\n}","import {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface IInviteGroupUsersOptions extends IRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be added to the group as group members\n */\n users: string[];\n /**\n * What role the users should be invited as ('group_member' | 'group_admin')\n */\n role: string;\n /**\n * Expiration date on the invitation can be set for one day, three days, one week, or two weeks, in minutes.\n */\n expiration: number\n}\n\nexport interface IInviteGroupUsersResult {\n /**\n * Whether the operation was successful\n */\n success: boolean;\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * Invites users to join a group. Operation success\n * will be indicated by a flag on the return\n * object. If there are any errors, they will be\n * placed in an errors array on the return object\n * \n * ```js\n * const authentication: IAuthenticationManager; // Typically passed into to the function\n * //\n * const options: IInviteGroupUsersOptions = {\n * id: 'group_id',\n * users: ['ed', 'edd', 'eddy'],\n * role: 'group-member',\n * expiration: 20160,\n * authentication\n * }\n * //\n * const result = await inviteGroupUsers(options);\n * //\n * const if_success_result_looks_like = {\n * success: true\n * }\n * //\n * const if_failure_result_looks_like = {\n * success: false,\n * errors: [ArcGISRequestError]\n * }\n * ```\n * @param {IInviteGroupUsersOptions} options\n *\n * @returns {Promise<IAddGroupUsersResult>} \n */\nexport function inviteGroupUsers(options: IInviteGroupUsersOptions): Promise<IInviteGroupUsersResult> {\n const id = options.id;\n const url = `${getPortalUrl(options)}/community/groups/${id}/invite`;\n const batches = _generateBatchRequests(options);\n const promises = batches.map(batch => _sendSafeRequest(url, batch));\n\n return Promise.all(promises).then(_combineResults);\n}\n\n/**\n * @private\n */\nfunction _generateBatchRequests(options: IInviteGroupUsersOptions) {\n const userBatches: string[][] = chunk<string>(options.users, 25);\n return userBatches.map(users => _generateRequestOptions(users, options));\n}\n\n/**\n * @private\n */\nfunction _generateRequestOptions(users: string[], baseOptions: IInviteGroupUsersOptions): IRequestOptions {\n const requestOptions: IInviteGroupUsersOptions = Object.assign({}, baseOptions);\n\n requestOptions.params = {\n ...requestOptions.params,\n users,\n role: requestOptions.role,\n expiration: requestOptions.expiration,\n }\n \n return requestOptions;\n}\n\n/**\n * @private \n */\nfunction _sendSafeRequest(url: string,requestOptions: IRequestOptions): Promise<IInviteGroupUsersResult> {\n return request(url, requestOptions)\n .catch(error => ({ errors: [error] }));\n}\n\n/**\n * @private \n */\nfunction _combineResults(responses: IInviteGroupUsersResult[]): IInviteGroupUsersResult {\n const success = responses.every(res => res.success);\n const errors: ArcGISRequestError[] = responses.reduce((collection, res) => collection.concat(res.errors || []), []);\n const combined: IInviteGroupUsersResult = { success };\n\n if (errors.length > 0) {\n combined.errors = errors;\n }\n\n return combined;\n}\n\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IGroupAdd, IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface ICreateGroupOptions extends IRequestOptions {\n group: IGroupAdd;\n}\n\n/**\n * ```js\n * import { createGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * createGroup({\n * group: {\n * title: \"No Homers\",\n * access: \"public\"\n * },\n * authentication\n * })\n * .then(response)\n * ```\n * Create a new Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/create-group.htm) for more information.\n *\n * Note: The group name must be unique within the user's organization.\n * @param requestOptions - Options for the request, including a group object\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function createGroup(\n requestOptions: ICreateGroupOptions\n): Promise<{ success: boolean; group: IGroup }> {\n const url = `${getPortalUrl(requestOptions)}/community/createGroup`;\n\n requestOptions.params = {\n ...requestOptions.params,\n ...requestOptions.group\n };\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUserGroupOptions } from \"./helpers\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport type NotificationChannelType = \"push\" | \"email\" | \"builtin\";\n\nexport interface ICreateGroupNotificationOptions extends IUserGroupOptions {\n /**\n * Subject of the notification. This only applies to email and builtin notifications. For push notifications, subject/title is provided as a part of the message payload.\n */\n subject?: string;\n /**\n * Message to be sent. For builtin and email notifications this is a string. For push notifications, this will be JSON.\n */\n message: string | object;\n /**\n * Array of usernames of the users in the group to whom the message should be sent. If not provided, the message will be sent to all users in the group if the user is an admin. Only group admins will be able to send notifications to a list of users. Group users will be able to send notifications to only one user at a time.\n */\n users?: string[];\n /**\n * The channel through which the notification is to be delivered. Supported values are push, email, or builtin. If push is chosen, a message will be delivered only to those group members that have registered their devices to receive push notifications. If the user has registered more than one device for the app, then message will be sent to all the registered devices. Email will be sent when the email option is chosen. If the builtin option is chosen, a notification will be added to the notifications list that the user can see when logged into the home app.\n */\n notificationChannelType?: NotificationChannelType;\n /**\n * ClientId of the application through which user receives messages on the mobile device. This only applies to push notifications.\n */\n clientId?: string;\n /**\n * This only applies to push notifications. When set to true, message will be delivered to the app and it will not show as an alert to the user.\n */\n silentNotification?: boolean;\n}\n\n/**\n * ```js\n * import { createGroupNotification } from '@esri/arcgis-rest-portal';\n * // send an email to an entire group\n * createGroupNotification({\n * authentication: UserSession,\n * subject: \"hello\",\n * message: \"world!\",\n * id: groupId\n * })\n * ```\n * Create a group notification.\n *\n * @param requestOptions - Options for the request\n *\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function createGroupNotification(\n requestOptions: ICreateGroupNotificationOptions\n): Promise<any> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/createNotification`;\n\n const options: ICreateGroupNotificationOptions = {\n params: {\n subject: requestOptions.subject,\n message: requestOptions.message,\n users: requestOptions.users,\n notificationChannelType:\n requestOptions.notificationChannelType || \"email\",\n clientId: requestOptions.clientId,\n silentNotification: requestOptions.silentNotification,\n notifyAll: !requestOptions.users || requestOptions.users.length === 0,\n ...requestOptions.params\n },\n ...requestOptions\n };\n return request(url, options);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { protectGroup } from '@esri/arcgis-rest-portal';\n * //\n * protectGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Protect a group to avoid accidental deletion. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/protect-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function protectGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/protect`;\n\n return request(url, requestOptions);\n}\n\n/**\n * ```js\n * import { unprotectGroup } from '@esri/arcgis-rest-portal';\n * //\n * unprotectGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Unprotect a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unprotect-group.htm) for more information.\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function unprotectGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/unprotect`;\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { removeGroup } from '@esri/arcgis-rest-portal';\n * //\n * removeGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Delete a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/delete-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function removeGroup(requestOptions: IUserGroupOptions): Promise<any> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/delete`;\n const options: IUserGroupOptions = {\n ...requestOptions\n };\n return request(url, options);\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IItem, IGroup } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport {\n ISearchOptions,\n ISearchGroupContentOptions,\n ISearchResult\n} from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n/**\n * ```js\n * import { searchGroups } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroups('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for groups. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-search.htm) for more information.\n *\n * @param search - A string or RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroups(\n search: string | ISearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IGroup>> {\n return genericSearch<IGroup>(search, \"group\");\n}\n\n/**\n * ```js\n * import { searchGroupContent } from \"@esri/arcgis-rest-portal\";\n * //\n * searchGroupContent('water')\n * .then(response) // response.total => 355\n * ```\n * Search a portal for items in a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/group-content-search.htm) for more information.\n *\n * @param options - RequestOptions object amended with search parameters.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchGroupContent(\n options: ISearchGroupContentOptions\n): Promise<ISearchResult<IItem>> {\n return genericSearch<IItem>(options, \"groupContent\");\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IItemUpdate } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IUpdateGroupOptions extends IRequestOptions {\n group: IItemUpdate;\n}\n\n/**\n * ```js\n * import { updateGroup } from '@esri/arcgis-rest-portal';\n * //\n * updateGroup({\n * group: { id: \"fgr344\", title: \"new\" }\n * })\n * .then(response)\n * ```\n * Update the properties of a group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-group.htm) for more information.\n *\n * @param requestOptions - Options for the request, including the group\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function updateGroup(\n requestOptions: IUpdateGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.group.id\n }/update`;\n\n requestOptions.params = {\n ...requestOptions.params,\n ...requestOptions.group\n };\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { request } from \"@esri/arcgis-rest-request\";\n\nexport interface IUpdateGroupUsersResult {\n /**\n * Array of results\n */\n results: any[];\n}\n\nexport interface IUpdateGroupUsersOptions extends IUserRequestOptions {\n /**\n * Group ID\n */\n id: string;\n /**\n * An array of usernames to be updated\n */\n users: string[];\n /**\n * Membership Type to update to\n */\n newMemberType: \"member\" | \"admin\";\n}\n\n/**\n * ```js\n * import { updateUserMemberships } from \"@esri/arcgis-rest-portal\";\n * //\n * updateUserMemberships({\n * id: groupId,\n * admins: [\"username3\"],\n * authentication\n * })\n * .then(response);\n * ```\n * Change the user membership levels of existing users in a group\n *\n * @param requestOptions - Options for the request\n * @returns A Promise\n */\nexport function updateUserMemberships(\n requestOptions: IUpdateGroupUsersOptions\n): Promise<IUpdateGroupUsersResult> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/updateUsers`;\n const opts: any = {\n authentication: requestOptions.authentication,\n params: {}\n };\n // add the correct params depending on the type of membership we are changing to\n if (requestOptions.newMemberType === \"admin\") {\n opts.params.admins = requestOptions.users;\n } else {\n opts.params.users = requestOptions.users;\n }\n // make the request\n return request(url, opts);\n}\n","/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IUserGroupOptions } from \"./helpers\";\n\n/**\n * ```js\n * import { joinGroup } from '@esri/arcgis-rest-portal';\n * //\n * joinGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Make a request as the authenticated user to join a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/join-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request and the groupId.\n */\nexport function joinGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/join`;\n\n return request(url, requestOptions);\n}\n\n/**\n * ```js\n * import { leaveGroup } from '@esri/arcgis-rest-portal';\n * //\n * leaveGroup({\n * id: groupId,\n * authentication\n * })\n * .then(response)\n * ```\n * Make a request as the authenticated user to leave a Group. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/leave-group.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request and the groupId.\n */\nexport function leaveGroup(\n requestOptions: IUserGroupOptions\n): Promise<{ success: boolean; groupId: string }> {\n const url = `${getPortalUrl(requestOptions)}/community/groups/${\n requestOptions.id\n }/leave`;\n\n return request(url, requestOptions);\n}\n","import {\n request,\n IRequestOptions,\n ArcGISRequestError\n} from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { chunk } from \"../util/array\";\n\nexport interface ICreateOrgNotificationOptions extends IRequestOptions {\n /**\n * Subject of the notification. This only applies to email and builtin notifications. For push notifications, subject/title is provided as a part of the message payload.\n */\n subject?: string;\n /**\n * Message to be sent. For builtin and email notifications this is a string. For push notifications, this will be JSON.\n */\n message: string | object;\n /**\n * Array of usernames of the users in the group to whom the message should be sent. If not provided, the message will be sent to all users in the group if the user is an admin. Only group admins will be able to send notifications to a list of users. Group users will be able to send notifications to only one user at a time.\n */\n users?: string[];\n /**\n * The channel through which the notification is to be delivered. Supported values are email or builtin. Email will be sent when the email option is chosen. If the builtin option is chosen, a notification will be added to the notifications list that the user can see when logged into the home app.\n */\n notificationChannelType?: string;\n\n /**\n * How many emails should be sent at a time. Defaults to the max possible (25)\n */\n batchSize?: number\n}\n\nexport interface ICreateOrgNotificationResult {\n /**\n * Whether the operation was successful\n */\n success: boolean;\n /**\n * An array of request errors\n */\n errors?: ArcGISRequestError[];\n}\n\n/**\n * Send a notification to members of the requesting user's org.\n * Operation success will be indicated by a flag on the return\n * object. If there are any errors, they will be placed in an \n * errors array on the return object\n * \n * ```js\n * const authentication: IAuthenticationManager; // Typically passed into to the function\n * //\n * const options: IInviteGroupUsersOptions = {\n * id: 'group_id',\n * users: ['larry', 'curly', 'moe'],\n * notificationChannelType: 'email',\n * expiration: 20160,\n * authentication\n * }\n * //\n * const result = await createOrgNotification(options);\n * //\n * const if_success_result_looks_like = {\n * success: true\n * }\n * //\n * const if_failure_result_looks_like = {\n * success: false,\n * errors: [ArcGISRequestError]\n * }\n * ```\n * @param {ICreateOrgNotificationOptions} options\n *\n * @returns {ICreateOrgNotificationResult}\n */\nexport function createOrgNotification (options: ICreateOrgNotificationOptions) {\n const url = `${getPortalUrl(options)}/portals/self/createNotification`;\n const batches = _generateBatchRequests(options);\n const promises = batches.map(batch => _sendSafeRequest(url, batch));\n\n return Promise.all(promises).then(_combineResults);\n}\n\n/**\n * @private\n */\nfunction _generateBatchRequests(options: ICreateOrgNotificationOptions): IRequestOptions[] {\n const userBatches: string[][] = chunk<string>(options.users, options.batchSize || 25);\n return userBatches.map(users => _generateRequestOptions(users, options));\n}\n\n/**\n * @private\n */\nfunction _generateRequestOptions(users: string[], baseOptions: ICreateOrgNotificationOptions): IRequestOptions {\n const requestOptions: ICreateOrgNotificationOptions = Object.assign({}, baseOptions);\n\n requestOptions.params = {\n ...requestOptions.params,\n users,\n subject: baseOptions.subject,\n message: baseOptions.message,\n notificationChannelType: requestOptions.notificationChannelType,\n }\n \n return requestOptions;\n}\n\n/**\n * @private \n */\nfunction _sendSafeRequest(url: string,requestOptions: IRequestOptions): Promise<ICreateOrgNotificationResult> {\n return request(url, requestOptions)\n .catch(error => ({ errors: [error] }));\n}\n\n/**\n * @private \n */\nfunction _combineResults(responses: ICreateOrgNotificationResult[]): ICreateOrgNotificationResult {\n const success = responses.every(res => res.success);\n const errors: ArcGISRequestError[] = responses.reduce((collection, res) => collection.concat(res.errors || []), []);\n const combined: ICreateOrgNotificationResult = { success };\n\n if (errors.length > 0) {\n combined.errors = errors;\n }\n\n return combined;\n}\n\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IGetUserOptions extends IRequestOptions {\n /**\n * A session representing a logged in user.\n */\n authentication?: UserSession;\n /**\n * Supply a username if you'd like to fetch information about a different user than is being used to authenticate the request.\n */\n username?: string;\n}\n\n/**\n * ```js\n * import { getUser } from '@esri/arcgis-rest-portal';\n * //\n * getUser(\"jsmith\")\n * .then(response)\n * // => { firstName: \"John\", lastName: \"Smith\",tags: [\"GIS Analyst\", \"City of Redlands\"] }\n * ```\n * Get information about a user. This method has proven so generically useful that you can also call [`UserSession.getUser()`](/arcgis-rest-js/api/auth/UserSession#getUser-summary).\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with metadata about the user\n */\nexport function getUser(\n requestOptions?: string | IGetUserOptions\n): Promise<IUser> {\n let url;\n let options = { httpMethod: \"GET\" } as IGetUserOptions;\n\n // if a username is passed, assume ArcGIS Online\n if (typeof requestOptions === \"string\") {\n url = `https://www.arcgis.com/sharing/rest/community/users/${requestOptions}`;\n } else {\n // if an authenticated session is passed, default to that user/portal unless another username is provided manually\n const username =\n requestOptions.username || requestOptions.authentication.username;\n url = `${getPortalUrl(requestOptions)}/community/users/${encodeURIComponent(\n username\n )}`;\n options = {\n ...requestOptions,\n ...options\n };\n }\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport { IGetUserOptions } from \"./get-user\";\n\nexport interface ITagCount {\n /**\n * the name of a tag\n */\n tag: string;\n /**\n * a count that reports the number of times the tag was used\n */\n count: number;\n}\n\nexport interface IGetUserTagsResponse {\n /**\n * Array of user item tag objects\n */\n tags: ITagCount[];\n}\n\n/**\n * ```js\n * import { getUserTags } from '@esri/arcgis-rest-portal';\n * //\n * getUserTags({\n * username: \"jsmith\",\n * authentication\n * })\n * .then(response)\n * ```\n * Users tag the content they publish in their portal via the add and update item calls. This resource lists all the tags used by the user along with the number of times the tags have been used. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-tags.htm) for more information.\n *\n * @param IGetUserOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user tag array\n */\nexport function getUserTags(\n requestOptions: IGetUserOptions\n): Promise<IGetUserTagsResponse> {\n const username =\n requestOptions.username || requestOptions.authentication.username;\n const url = `${getPortalUrl(\n requestOptions\n )}/community/users/${encodeURIComponent(username)}/tags`;\n\n // send the request\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\n/**\n * Helper that returns the [user](https://developers.arcgis.com/rest/users-groups-and-items/user.htm) for a given portal.\n *\n * @param session\n * @returns User url to be used in API requests.\n */\nexport function getUserUrl(session: UserSession): string {\n return `${getPortalUrl(session)}/community/users/${encodeURIComponent(\n session.username\n )}`;\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IGroup } from \"@esri/arcgis-rest-types\";\n\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IInvitation {\n id: string;\n targetType: string;\n targetId: string;\n received: number;\n accepted: boolean;\n mustApprove: boolean;\n email: string;\n role: string;\n type: string;\n dateAccepted: number;\n expiration: number;\n created: number;\n username: string;\n fromUsername: {\n username: string;\n fullname?: string;\n };\n group?: IGroup;\n groupId?: string;\n}\n\nexport interface IInvitationResult {\n userInvitations: IInvitation[];\n}\n\n/**\n * ```js\n * import { getUserInvitations } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserInvitations({ authentication })\n * .then(response) // response.userInvitations.length => 3\n * ```\n * Get all invitations for a user. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-invitations.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user's invitations\n */\nexport function getUserInvitations(\n requestOptions: IUserRequestOptions\n): Promise<IInvitationResult> {\n let options = { httpMethod: \"GET\" } as IUserRequestOptions;\n\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations`;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\nexport interface IGetUserInvitationOptions extends IUserRequestOptions {\n invitationId: string;\n}\n\n/**\n * ```js\n * import { getUserInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response) // => response.accepted => true\n * ```\n * Get an invitation for a user by id. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/user-invitation.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the invitation\n */\nexport function getUserInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<IInvitation> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}`;\n\n let options = { httpMethod: \"GET\" } as IGetUserInvitationOptions;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\n/**\n * ```js\n * import { acceptInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * acceptInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response)\n * ```\n * Accept an invitation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/accept-invitation.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function acceptInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<{\n success: boolean;\n username: string;\n groupId: string;\n id: string;\n}> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}/accept`;\n\n const options: IGetUserInvitationOptions = { ...requestOptions };\n return request(url, options);\n}\n\n/**\n * ```js\n * import { declineInvitation } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * declineInvitation({\n * invitationId: \"3ef\",\n * authentication\n * })\n * .then(response)\n * ```\n * Decline an invitation. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/decline-invitation.htm) for more information.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function declineInvitation(\n requestOptions: IGetUserInvitationOptions\n): Promise<{\n success: boolean;\n username: string;\n groupId: string;\n id: string;\n}> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/invitations/${requestOptions.invitationId}/decline`;\n\n const options: IGetUserInvitationOptions = { ...requestOptions };\n return request(url, options);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface INotification {\n id: string;\n type: string;\n target: string;\n targetType: string;\n received: number;\n data: { [key: string]: any };\n}\n\nexport interface IRemoveNotificationOptions extends IUserRequestOptions {\n /**\n * Unique identifier of the item.\n */\n id: string;\n}\nexport interface INotificationResult {\n notifications: INotification[];\n}\n\n/**\n * ```js\n * import { getUserNotifications } from '@esri/arcgis-rest-portal';\n * // username is inferred from UserSession\n * getUserNotifications({ authentication })\n * .then(results) // results.notifications.length) => 3\n * ```\n * Get notifications for a user.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with the user's notifications\n */\nexport function getUserNotifications(\n requestOptions: IUserRequestOptions\n): Promise<INotificationResult> {\n let options = { httpMethod: \"GET\" } as IUserRequestOptions;\n\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/notifications`;\n options = { ...requestOptions, ...options };\n\n // send the request\n return request(url, options);\n}\n\n/**\n * Delete a notification.\n *\n * @param requestOptions - Options for the request\n * @returns A Promise that will resolve with the success/failure status of the request\n */\nexport function removeNotification(\n requestOptions: IRemoveNotificationOptions\n): Promise<{ success: boolean; notificationId: string }> {\n const username = encodeURIComponent(requestOptions.authentication.username);\n const portalUrl = getPortalUrl(requestOptions);\n const url = `${portalUrl}/community/users/${username}/notifications/${requestOptions.id}/delete`;\n\n return request(url, requestOptions);\n}\n","/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { IAuthenticatedRequestOptions } from \"@esri/arcgis-rest-auth\";\nimport { IAuthenticationManager } from \"@esri/arcgis-rest-request\";\nimport { IPagingParams, IUser } from \"@esri/arcgis-rest-types\";\nimport { SearchQueryBuilder } from \"../util/SearchQueryBuilder\";\nimport { ISearchOptions, ISearchResult } from \"../util/search\";\nimport { genericSearch } from \"../util/generic-search\";\n\n// export interface IUserSearchOptions extends IAuthenticatedRequestOptions, IPagingParams {\n// q: string | SearchQueryBuilder;\n// sortField?: string;\n// sortOrder?: string;\n// [key: string]: any;\n// }\n\nexport interface IUserSearchOptions extends ISearchOptions {\n authentication: IAuthenticationManager;\n}\n\n/**\n * ```js\n * import { searchItems } from \"@esri/arcgis-rest-portal\";\n * //\n * searchUsers({ q: 'tommy', authentication })\n * .then(response) // response.total => 355\n * ```\n * Search a portal for users.\n *\n * @param search - A RequestOptions object to pass through to the endpoint.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function searchUsers(\n search: IUserSearchOptions | SearchQueryBuilder\n): Promise<ISearchResult<IUser>> {\n return genericSearch<IUser>(search, \"user\");\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\n\nimport { IUserRequestOptions } from \"@esri/arcgis-rest-auth\";\n\nimport { getPortalUrl } from \"../util/get-portal-url\";\n\nexport interface IUpdateUserOptions extends IUserRequestOptions {\n /**\n * The user properties to be updated.\n */\n user: IUser;\n}\n\nexport interface IUpdateUserResponse {\n success: boolean;\n username: string;\n}\n\n/**\n * ```js\n * import { updateUser } from '@esri/arcgis-rest-portal';\n * // any user can update their own profile\n * updateUser({\n * authentication,\n * user: { description: \"better than the last one\" }\n * })\n * .then(response)\n * // org administrators must declare the username that will be updated explicitly\n * updateUser({\n * authentication,\n * user: { username: \"c@sey\", description: \"\" }\n * })\n * .then(response)\n * // => { \"success\": true, \"username\": \"c@sey\" }\n * ```\n * Update a user profile. The username will be extracted from the authentication session unless it is provided explicitly. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/update-user.htm) for more information.\n *\n * @param requestOptions - options to pass through in the request\n * @returns A Promise that will resolve with metadata about the user\n */\nexport function updateUser(\n requestOptions?: IUpdateUserOptions\n): Promise<IUpdateUserResponse> {\n // default to the authenticated username unless another username is provided manually\n const username =\n requestOptions.user.username || requestOptions.authentication.username;\n\n const updateUrl = `${getPortalUrl(\n requestOptions\n )}/community/users/${encodeURIComponent(username)}/update`;\n\n // mixin custom params and the user information, then drop the user info\n requestOptions.params = {\n ...requestOptions.user,\n ...requestOptions.params\n };\n\n delete requestOptions.user;\n\n // send the request\n return request(updateUrl, requestOptions);\n}\n","/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request } from \"@esri/arcgis-rest-request\";\n\nimport {\n ISharingOptions,\n ISharingResponse,\n isItemOwner,\n getSharingUrl,\n isOrgAdmin\n} from \"./helpers\";\n\nexport interface ISetAccessOptions extends ISharingOptions {\n /**\n * \"private\" indicates that the item can only be accessed by the user. \"public\" means accessible to anyone. An item shared to the organization has an access level of \"org\".\n */\n access: \"private\" | \"org\" | \"public\";\n}\n\n/**\n * ```js\n * import { setItemAccess } from \"@esri/arcgis-rest-portal\";\n * //\n * setItemAccess({\n * id: \"abc123\",\n * access: \"public\", // 'org' || 'private'\n * authentication: session\n * })\n * ```\n * Change who is able to access an item.\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function setItemAccess(\n requestOptions: ISetAccessOptions\n): Promise<ISharingResponse> {\n const url = getSharingUrl(requestOptions);\n\n if (isItemOwner(requestOptions)) {\n // if the user owns the item, proceed\n return updateItemAccess(url, requestOptions);\n } else {\n // otherwise we need to check to see if they are an organization admin\n return isOrgAdmin(requestOptions).then(admin => {\n if (admin) {\n return updateItemAccess(url, requestOptions);\n } else {\n // if neither, updating the sharing isnt possible\n throw Error(\n `This item can not be shared by ${requestOptions.authentication.username}. They are neither the item owner nor an organization admin.`\n );\n }\n });\n }\n}\n\nfunction updateItemAccess(\n url: string,\n requestOptions: ISetAccessOptions\n): Promise<any> {\n requestOptions.params = {\n org: false,\n everyone: false,\n ...requestOptions.params\n };\n\n // if the user wants to make the item private, it needs to be unshared from any/all groups as well\n if (requestOptions.access === \"private\") {\n requestOptions.params.groups = \" \";\n }\n if (requestOptions.access === \"org\") {\n requestOptions.params.org = true;\n }\n // if sharing with everyone, share with the entire organization as well.\n if (requestOptions.access === \"public\") {\n // this is how the ArcGIS Online Home app sets public access\n // setting org = true instead of account = true will cancel out all sharing\n requestOptions.params.account = true;\n requestOptions.params.everyone = true;\n }\n return request(url, requestOptions);\n}\n","import { IGroupSharingOptions } from \"./helpers\";\nimport { searchItems } from \"../items/search\";\nimport { ISearchOptions } from \"../util/search\";\n\n/**\n * ```js\n * import { isItemSharedWithGroup } from \"@esri/arcgis-rest-portal\";\n * //\n * isItemSharedWithGroup({\n * groupId: 'bc3,\n * itemId: 'f56,\n * authentication\n * })\n * .then(isShared => {})\n * ```\n * Find out whether or not an item is already shared with a group.\n *\n * @param requestOptions - Options for the request. NOTE: `rawResponse` is not supported by this operation.\n * @returns Promise that will resolve with true/false\n */\nexport function isItemSharedWithGroup(\n requestOptions: IGroupSharingOptions\n): Promise<boolean> {\n const searchOpts = {\n q: `id: ${requestOptions.id} AND group: ${requestOptions.groupId}`,\n start: 1,\n num: 10,\n sortField: \"title\",\n authentication: requestOptions.authentication,\n httpMethod: \"POST\"\n } as ISearchOptions;\n\n return searchItems(searchOpts).then(searchResponse => {\n let result = false;\n if (searchResponse.total > 0) {\n result = searchResponse.results.some((itm: any) => {\n return itm.id === requestOptions.id;\n });\n return result;\n }\n });\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { IUser } from \"@esri/arcgis-rest-types\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IGroupSharingOptions,\n ISharingResponse,\n getUserMembership,\n} from \"./helpers\";\nimport { getUser } from \"../users/get-user\";\nimport { addGroupUsers, IAddGroupUsersResult } from \"../groups/add-users\";\nimport { removeGroupUsers } from \"../groups/remove-users\";\nimport {\n updateUserMemberships,\n IUpdateGroupUsersResult,\n} from \"../groups/update-user-membership\";\nimport { isItemSharedWithGroup } from \"../sharing/is-item-shared-with-group\";\n\ninterface IEnsureMembershipResult {\n promise: Promise<IAddGroupUsersResult>;\n revert: (sharingResults: ISharingResponse) => Promise<ISharingResponse>;\n}\n\n/**\n * ```js\n * import { shareItemWithGroup } from '@esri/arcgis-rest-portal';\n * //\n * shareItemWithGroup({\n * id: \"abc123\",\n * groupId: \"xyz987\",\n * owner: \"some-owner\",\n * authentication\n * })\n * ```\n * Share an item with a group, either as an\n * [item owner](https://developers.arcgis.com/rest/users-groups-and-items/share-item-as-item-owner-.htm),\n * [group admin](https://developers.arcgis.com/rest/users-groups-and-items/share-item-as-group-admin-.htm) or\n * organization admin.\n *\n * Note: Sharing the item as an Admin will use the `/content/users/:ownername/items/:itemid/share` end-point\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function shareItemWithGroup(\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n return isItemSharedWithGroup(requestOptions)\n .then((isShared) => {\n if (isShared) {\n // already shared, exit early with success response\n return {\n itemId: requestOptions.id,\n shortcut: true,\n notSharedWith: [],\n } as ISharingResponse;\n }\n\n const {\n authentication: { username },\n owner,\n confirmItemControl,\n } = requestOptions;\n const itemOwner = owner || username;\n\n // non-item owner\n if (itemOwner !== username) {\n // need to track if the user is an admin\n let isAdmin = false;\n // track if the admin & owner are in the same org\n let isCrossOrgSharing = false;\n // next perform any necessary membership adjustments for\n // current user and/or item owner\n return Promise.all([\n getUser({\n username,\n authentication: requestOptions.authentication,\n }),\n getUser({\n username: itemOwner,\n authentication: requestOptions.authentication,\n }),\n getUserMembership(requestOptions),\n ])\n .then(([currentUser, ownerUser, membership]) => {\n const isSharedEditingGroup = !!confirmItemControl;\n isAdmin = currentUser.role === \"org_admin\" && !currentUser.roleId;\n isCrossOrgSharing = currentUser.orgId !== ownerUser.orgId;\n return getMembershipAdjustments(\n currentUser,\n isSharedEditingGroup,\n membership,\n isAdmin,\n ownerUser,\n requestOptions\n );\n })\n .then((membershipAdjustments) => {\n const [\n { revert } = {\n promise: Promise.resolve({ notAdded: [] }),\n revert: (sharingResults: ISharingResponse) => {\n return Promise.resolve(sharingResults);\n },\n } as IEnsureMembershipResult,\n ] = membershipAdjustments;\n // perform all membership adjustments\n return Promise.all(\n membershipAdjustments.map(({ promise }) => promise)\n )\n .then(() => {\n // then attempt the share\n return shareToGroup(requestOptions, isAdmin, isCrossOrgSharing);\n })\n .then((sharingResults) => {\n // lastly, if the admin user was added to the group,\n // remove them from the group. this is a no-op that\n // immediately resolves the sharingResults when no\n // membership adjustment was needed\n return revert(sharingResults);\n });\n });\n }\n\n // item owner, let it call through\n return shareToGroup(requestOptions);\n })\n .then((sharingResponse) => {\n if (sharingResponse.notSharedWith.length) {\n throw Error(\n `Item ${requestOptions.id} could not be shared to group ${requestOptions.groupId}.`\n );\n } else {\n // all is well\n return sharingResponse;\n }\n });\n}\n\nfunction getMembershipAdjustments(\n currentUser: IUser,\n isSharedEditingGroup: boolean,\n membership: string,\n isAdmin: boolean,\n ownerUser: IUser,\n requestOptions: IGroupSharingOptions\n) {\n const membershipGuarantees = [];\n if (requestOptions.groupId !== currentUser.favGroupId) {\n if (isSharedEditingGroup) {\n if (!isAdmin) {\n // abort and reject promise\n throw Error(\n `This item can not be shared to shared editing group ${requestOptions.groupId} by ${currentUser.username} as they not the item owner or org admin.`\n );\n }\n\n membershipGuarantees.push(\n // admin user must be a group member to share, should be reverted afterwards\n ensureMembership(\n currentUser,\n currentUser,\n false,\n `Error adding ${currentUser.username} as member to edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n ),\n // item owner must be a group admin\n ensureMembership(\n currentUser,\n ownerUser,\n true,\n membership === \"none\"\n ? `Error adding user ${ownerUser.username} to edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`\n : `Error promoting user ${ownerUser.username} to admin in edit group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n )\n );\n } else if (isAdmin) {\n // admin user must be a group member to share, should be reverted afterwards\n membershipGuarantees.push(\n ensureMembership(\n currentUser,\n currentUser,\n false,\n `Error adding ${currentUser.username} as member to view group ${requestOptions.groupId}. Consequently item ${requestOptions.id} was not shared to the group.`,\n requestOptions\n )\n );\n } else if (membership === \"none\") {\n // all other non-item owners must be a group member\n throw new Error(\n `This item can not be shared by ${currentUser.username} as they are not a member of the specified group ${requestOptions.groupId}.`\n );\n }\n }\n\n return membershipGuarantees;\n}\n\nfunction shareToGroup(\n requestOptions: IGroupSharingOptions,\n isAdmin = false,\n isCrossOrgSharing = false\n): Promise<ISharingResponse> {\n const username = requestOptions.authentication.username;\n const itemOwner = requestOptions.owner || username;\n // decide what url to use\n // default to the non-owner url...\n let url = `${getPortalUrl(requestOptions)}/content/items/${\n requestOptions.id\n }/share`;\n\n // but if they are the owner, or org_admin, use this route\n // Note: When using this end-point as an admin, apparently the admin does not need to be a member of the group (the itemOwner does)\n // Note: Admin's can only use this route when the item is in the same org they are admin for\n if (itemOwner === username || (isAdmin && !isCrossOrgSharing)) {\n url = `${getPortalUrl(requestOptions)}/content/users/${itemOwner}/items/${\n requestOptions.id\n }/share`;\n }\n\n // now its finally time to do the sharing\n requestOptions.params = {\n groups: requestOptions.groupId,\n confirmItemControl: requestOptions.confirmItemControl,\n };\n\n return request(url, requestOptions);\n}\n\nexport function ensureMembership(\n currentUser: IUser,\n ownerUser: IUser,\n shouldPromote: boolean,\n errorMessage: string,\n requestOptions: IGroupSharingOptions\n): IEnsureMembershipResult {\n const ownerGroups = ownerUser.groups || [];\n const group = ownerGroups.find((g) => {\n return g.id === requestOptions.groupId;\n });\n\n // if they are in different orgs, eject\n if (currentUser.orgId !== ownerUser.orgId) {\n throw Error(\n `User ${ownerUser.username} is not a member of the same org as ${currentUser.username}. Consequently they can not be added added to group ${requestOptions.groupId} nor can item ${requestOptions.id} be shared to the group.`\n );\n }\n\n // if owner is not a member, and has 512 groups\n if (!group && ownerGroups.length > 511) {\n throw Error(\n `User ${ownerUser.username} already has 512 groups, and can not be added to group ${requestOptions.groupId}. Consequently item ${requestOptions.id} can not be shared to the group.`\n );\n }\n\n let promise: Promise<IAddGroupUsersResult>;\n let revert: (sharingResults: ISharingResponse) => Promise<ISharingResponse>;\n\n // decide if we need to add them or upgrade them\n if (group) {\n // they are in the group...\n // check member type\n if (shouldPromote && group.userMembership.memberType === \"member\") {\n // promote them\n promise = updateUserMemberships({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n newMemberType: \"admin\",\n authentication: requestOptions.authentication,\n })\n .then((results: IUpdateGroupUsersResult) => {\n // convert the result into the right type\n const notAdded = results.results.reduce((acc: any[], entry: any) => {\n if (!entry.success) {\n acc.push(entry.username);\n }\n return acc;\n }, []);\n // and return it\n return Promise.resolve({ notAdded });\n })\n .catch(() => ({ notAdded: [ownerUser.username] }));\n revert = (sharingResults) =>\n updateUserMemberships({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n newMemberType: \"member\",\n authentication: requestOptions.authentication,\n })\n .then(() => sharingResults)\n .catch(() => sharingResults);\n } else {\n // they are already an admin in the group\n // return the same response the API would if we added them\n promise = Promise.resolve({ notAdded: [] });\n revert = (sharingResults) => Promise.resolve(sharingResults);\n }\n } else {\n // attempt to add user to group\n const userType = shouldPromote ? \"admins\" : \"users\";\n // can't currently determine if the group is within the admin's\n // org without performing a search, so attempt to add and handle\n // the api error\n promise = addGroupUsers({\n id: requestOptions.groupId,\n [userType]: [ownerUser.username],\n authentication: requestOptions.authentication,\n })\n .then((results) => {\n // results.errors includes an ArcGISAuthError when the group\n // is in a different org, but notAdded is empty, throw here\n // to normalize the results in below catch\n if (results.errors && results.errors.length) {\n throw results.errors[0];\n }\n return results;\n })\n .catch(() => ({ notAdded: [ownerUser.username] }));\n revert = (sharingResults) => {\n return removeGroupUsers({\n id: requestOptions.groupId,\n users: [ownerUser.username],\n authentication: requestOptions.authentication,\n }).then(() => {\n // always resolves, suppress any resolved errors\n return sharingResults;\n });\n };\n }\n\n return {\n promise: promise.then((membershipResponse) => {\n if (membershipResponse.notAdded.length) {\n throw new Error(errorMessage);\n }\n return membershipResponse;\n }),\n revert,\n };\n}\n","import { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"../util/get-portal-url\";\nimport {\n IGroupSharingOptions,\n ISharingResponse,\n getUserMembership\n} from \"./helpers\";\nimport { isItemSharedWithGroup } from \"./is-item-shared-with-group\";\nimport { getUser } from \"../users/get-user\";\n\n/**\n * Stop sharing an item with a group, either as an\n * [item owner](https://developers.arcgis.com/rest/users-groups-and-items/unshare-item-as-item-owner-.htm),\n * [group admin](https://developers.arcgis.com/rest/users-groups-and-items/unshare-item-as-group-admin-.htm) or\n * organization admin.\n *\n * ```js\n * import { unshareItemWithGroup } from '@esri/arcgis-rest-portal';\n *\n * unshareItemWithGroup({\n * id: \"abc123\",\n * groupId: \"xyz987\",\n * owner: \"some-owner\",\n * authentication: session\n * })\n * ```\n *\n * @param requestOptions - Options for the request.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function unshareItemWithGroup (\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n return isItemSharedWithGroup(requestOptions)\n .then(isShared => {\n // not shared\n if (!isShared) {\n // exit early with success response\n return Promise.resolve({\n itemId: requestOptions.id,\n shortcut: true,\n notUnsharedFrom: []\n } as ISharingResponse);\n }\n\n const {\n authentication: { username },\n owner\n } = requestOptions;\n\n // next check if the user is a member of the group\n return Promise.all([\n getUserMembership(requestOptions),\n getUser({\n username,\n authentication: requestOptions.authentication\n })\n ])\n .then(([membership, currentUser]) => {\n const itemOwner = owner || username;\n const isItemOwner = itemOwner === username;\n const isAdmin = currentUser.role === 'org_admin' && !currentUser.roleId;\n\n if (!isItemOwner && !isAdmin && ['admin', 'owner'].indexOf(membership) < 0) {\n // abort and reject promise\n throw Error(`This item can not be unshared from group ${requestOptions.groupId} by ${username} as they not the item owner, an org admin, group admin or group owner.`);\n }\n \n // let the sharing call go\n return unshareFromGroup(requestOptions);\n })\n .then(sharingResponse => {\n if (sharingResponse.notUnsharedFrom.length) {\n throw Error(\n `Item ${requestOptions.id} could not be unshared to group ${requestOptions.groupId}`\n );\n } else {\n // all is well\n return sharingResponse;\n }\n });\n });\n}\n\nfunction unshareFromGroup (\n requestOptions: IGroupSharingOptions\n): Promise<ISharingResponse> {\n const username = requestOptions.authentication.username;\n const itemOwner = requestOptions.owner || username;\n // decide what url to use\n // default to the non-owner url...\n let url = `${getPortalUrl(requestOptions)}/content/items/${requestOptions.id}/unshare`;\n\n // but if they are the owner, we use a different path...\n if (itemOwner === username) {\n url = `${getPortalUrl(requestOptions)}/content/users/${itemOwner}/items/${requestOptions.id}/unshare`;\n }\n\n // now its finally time to do the sharing\n requestOptions.params = {\n groups: requestOptions.groupId\n };\n\n return request(url, requestOptions);\n}","/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { IServiceNameAvailable } from \"@esri/arcgis-rest-types\";\n\n/**\n * Determine if a specific service name is available in the current user's organization\n *\n * @export\n * @param {string} name\n * @param {UserSession} session\n * @return {*} {Promise<IServiceNameAvailable>}\n */\nexport function isServiceNameAvailable(\n name: string,\n type: string,\n session: UserSession\n): Promise<IServiceNameAvailable> {\n const url = `${session.portal}/portals/self/isServiceNameAvailable`;\n return request(url, {\n params: {\n name,\n type,\n },\n httpMethod: \"GET\",\n authentication: session,\n });\n}\n","/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { UserSession } from \"@esri/arcgis-rest-auth\";\nimport { isServiceNameAvailable } from \"./is-service-name-available\";\n\n/**\n * Given a starting name, return a service name that is unqieu within\n * the current users organization\n *\n * @export\n * @param {string} name\n * @param {UserSession} session\n * @param {number} step\n * @return {*} {Promise<string>}\n */\nexport function getUniqueServiceName(\n name: string,\n type: string,\n session: UserSession,\n step: number\n): Promise<string> {\n let nameToCheck = name;\n if (step) {\n nameToCheck = `${name}_${step}`;\n }\n return isServiceNameAvailable(nameToCheck, type, session).then((response) => {\n if (response.available) {\n return nameToCheck;\n } else {\n step = step + 1;\n return getUniqueServiceName(name, type, session, step);\n }\n });\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface IPortal {\n id: string;\n isPortal: boolean;\n name: string;\n [key: string]: any;\n}\n\n/**\n * Get the portal\n * @param requestOptions\n */\nexport function getSelf(requestOptions?: IRequestOptions): Promise<IPortal> {\n // just delegate to getPortal w/o an id\n return getPortal(null, requestOptions);\n}\n\n/**\n * ```js\n * import { getPortal } from \"@esri/arcgis-rest-request\";\n * //\n * getPortal()\n * getPortal(\"fe8\")\n * getPortal(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch information about the specified portal by id. If no id is passed, portals/self will be called.\n * Note that if you intend to request a portal by id and it is different from the portal specified by options.authentication, you must also pass options.portal.\n * @param id\n * @param requestOptions\n */\nexport function getPortal(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<IPortal> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(requestOptions)}/portals/${idOrSelf}`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { IExtent } from \"@esri/arcgis-rest-types\";\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface IPortalSettings {\n allowedRedirectUris: string[];\n defaultExtent: IExtent;\n helperServices: { [key: string]: any };\n informationalBanner: { [key: string]: any };\n [key: string]: any;\n}\n\n/**\n * ```js\n * import { getPortalSettings } from \"@esri/arcgis-rest-portal\";\n * //\n * getPortalSettings()\n * getPortalSettings(\"fe8\")\n * getPortalSettings(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch the settings for the current portal by id. If no id is passed, portals/self/settings will be called\n * @param id\n * @param requestOptions\n */\nexport function getPortalSettings(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<IPortalSettings> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(requestOptions)}/portals/${idOrSelf}/settings`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n","/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, IRequestOptions } from \"@esri/arcgis-rest-request\";\n\nimport { getPortalUrl } from \"./get-portal-url\";\n\nexport interface ISubscriptionInfo {\n id: string;\n [key: string]: any;\n}\n\n/**\n * ```js\n * import { getSubscriptionInfo } from \"@esri/arcgis-rest-request\";\n * //\n * getSubscriptionInfo()\n * getSubscriptionInfo(\"fe8\")\n * getSubscriptionInfo(null, { portal: \"https://custom.maps.arcgis.com/sharing/rest/\" })\n * ```\n * Fetch subscription information about the current portal by id. If no id is passed, portals/self/subscriptionInfo will be called\n * @param id\n * @param requestOptions\n */\nexport function getSubscriptionInfo(\n id?: string,\n requestOptions?: IRequestOptions\n): Promise<ISubscriptionInfo> {\n // construct the search url\n const idOrSelf = id ? id : \"self\";\n const url = `${getPortalUrl(\n requestOptions\n )}/portals/${idOrSelf}/subscriptionInfo`;\n\n // default to a GET request\n const options: IRequestOptions = {\n ...{ httpMethod: \"GET\" },\n ...requestOptions\n };\n\n // send the request\n return request(url, options);\n}\n"],"names":["cleanUrl","request","appendCustomParams","warn","_sendSafeRequest","_generateRequestOptions","_generateBatchRequests","_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