@esri/arcgis-rest-portal
Advanced tools
Comparing version 2.13.2 to 2.14.0
export * from "./items/add"; | ||
export * from "./items/content"; | ||
export * from "./items/create"; | ||
export * from "./items/export"; | ||
export * from "./items/get"; | ||
@@ -37,2 +39,2 @@ export * from "./items/protect"; | ||
export * from "./util/SearchQueryBuilder"; | ||
export { IPagingParams, IUser, IItemAdd, IItemUpdate, IItem, IGroupAdd, IGroup, GroupMembership } from "@esri/arcgis-rest-types"; | ||
export { IPagingParams, IPagedResponse, IUser, IItemAdd, IItemUpdate, IItem, IFolder, IGroupAdd, IGroup, GroupMembership } from "@esri/arcgis-rest-types"; |
/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
export * from "./items/add"; | ||
export * from "./items/content"; | ||
export * from "./items/create"; | ||
export * from "./items/export"; | ||
export * from "./items/get"; | ||
@@ -6,0 +8,0 @@ export * from "./items/protect"; |
@@ -7,3 +7,5 @@ "use strict"; | ||
tslib_1.__exportStar(require("./items/add"), exports); | ||
tslib_1.__exportStar(require("./items/content"), exports); | ||
tslib_1.__exportStar(require("./items/create"), exports); | ||
tslib_1.__exportStar(require("./items/export"), exports); | ||
tslib_1.__exportStar(require("./items/get"), exports); | ||
@@ -10,0 +12,0 @@ tslib_1.__exportStar(require("./items/protect"), exports); |
/* @preserve | ||
* @esri/arcgis-rest-portal - v2.13.2 - Apache-2.0 | ||
* @esri/arcgis-rest-portal - v2.14.0 - Apache-2.0 | ||
* Copyright (c) 2017-2020 Esri, Inc. | ||
* Thu Jun 11 2020 14:15:56 GMT-0600 (Mountain Daylight Time) | ||
* Mon Jul 20 2020 13:48:00 GMT-0600 (Mountain Daylight Time) | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],e):e((t=t||self).arcgisRest=t.arcgisRest||{},t.arcgisRest)}(this,function(t,i){"use strict";var a=function(){return(a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function u(t){return void 0===t&&(t={}),t.portal?i.cleanUrl(t.portal):t.authentication?t.authentication.portal:"https://www.arcgis.com/sharing/rest"}function s(t){var e=JSON.parse(JSON.stringify(t));return e.data&&("undefined"!=typeof Blob&&t.data instanceof Blob||"ReadStream"===t.data.constructor.name?e.file=t.data:e.text=t.data,delete e.data),e}function e(t){return t.owner?Promise.resolve(t.owner):t.item&&t.item.owner?Promise.resolve(t.item.owner):t.authentication&&t.authentication.getUsername?t.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function r(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.item.id+"/update";return r.params=a({},r.params,s(r.item)),i.request(e,r)})}function n(o){return o.file&&!o.multipart?Promise.reject(new Error("The request must be a multipart request for file uploading.")):o.multipart&&!o.filename?Promise.reject(new Error("The file name is required for a multipart request.")):e(o).then(function(t){var e=u(o)+"/content/users/"+t,r=e+"/addItem";o.folderId&&(r=e+"/"+o.folderId+"/addItem"),o.params=a({},o.params,s(o.item));var n=i.appendCustomParams(o,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:a({},o.params)});return i.request(r,n)})}function o(t,e){var r=u(e)+"/community/groups/"+t,n=a({httpMethod:"GET"},e);return i.request(r,n)}function c(t){var e=t.authentication.username,r=t.owner||e;return u(t)+"/content/users/"+encodeURIComponent(r)+"/items/"+t.id+"/share"}function m(t){var e=t.authentication.username;return(t.owner||e)===e}function p(t){return t.authentication.getUser(t).then(function(t){return!(!t||"org_admin"!==t.role)})}function d(t){return o(t.groupId,t).then(function(t){return t.userMembership.memberType}).catch(function(){return"none"})}var h=(f.prototype.match=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.termStack=this.termStack.concat(t),this},f.prototype.in=function(t){var e="`in("+(t?'"'+t+'"':"")+")`";return this.hasRange||this.hasTerms?(t&&"*"!==t&&(this.q+=t+":"),this.commit()):(i.warn(e+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},f.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},f.prototype.endGroup=function(){return this.openGroups<=0?i.warn("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},f.prototype.and=function(){return this.addModifier("and")},f.prototype.or=function(){return this.addModifier("or")},f.prototype.not=function(){return this.addModifier("not")},f.prototype.from=function(t){return this.hasTerms?i.warn("`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Your query was not modified."):this.rangeStack[0]=t,this},f.prototype.to=function(t){return this.hasTerms?i.warn("`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Your query was not modified."):this.rangeStack[1]=t,this},f.prototype.boost=function(t){return this.commit(),this.q+="^"+t,this},f.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},f.prototype.clone=function(){return this.commit(),this.cleanup(),new f(this.q+"")},f.prototype.addModifier=function(t){return this.currentModifer?i.warn("You have called `"+this.currentModifer+"()` after `"+t+"()`. Your current query was not modified."):(this.commit(),""===this.q&&"not"!==t?i.warn("You have called `"+t+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=t,this.q+=""===this.q?"":" ",this.q+=t.toUpperCase()+" ")),this},f.prototype.hasWhiteSpace=function(t){return/\s/g.test(t)},f.prototype.formatTerm=function(t){return t instanceof Date?t.getTime():"string"==typeof t&&this.hasWhiteSpace(t)?'"'+t+'"':t},f.prototype.commit=function(){var e=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(t){return e.formatTerm(t)}).join(" "),this.termStack=[]),this},Object.defineProperty(f.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!0,configurable:!0}),f.prototype.cleanup=function(){if(0<this.openGroups)for(i.warn("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var t=this.q;this.q=t.replace(/( AND ?| NOT ?| OR ?)*$/,""),t!==this.q&&i.warn("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},f);function f(t){void 0===t&&(t=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=t}function l(r,n){var t,e,o;switch(e="string"==typeof r||r instanceof h?{httpMethod:"GET",params:{q:r}}:i.appendCustomParams(r,["q","num","start","sortField","sortOrder"],{httpMethod:"GET"}),n){case"item":o="/search";break;case"group":o="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof h||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));o="/content/groups/"+r.groupId+"/search";break;default:o="/portals/self/users/search"}return t=u(e)+o,i.request(t,e).then(function(e){return e.nextStart&&-1!==e.nextStart&&(e.nextPage=function(){var t;return"string"==typeof r||r instanceof h?t={q:r,start:e.nextStart}:(t=r).start=e.nextStart,l(t,n)}),e})}function g(t){return l(t,"item")}function v(t){var e=t.id,r=u(t)+"/community/groups/"+e+"/addUsers",n=Object.assign({},t,{admins:void 0,users:void 0}),o=y("users",t.users,n).concat(y("admins",t.admins,n)).map(function(t){return function(t,e){return i.request(t,e).catch(function(t){return{errors:[t]}})}(r,t)});return Promise.all(o).then(I)}function y(e,t,r){return!t||t.length<1?[]:function(t,e){if(0===t.length)return[];for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}(t,25).map(function(t){return function(t,e,r){var n,o;return Object.assign({},r,((n={})[t]=e,n.params=a({},r.params,((o={})[t]=e,o)),n))}(e,t,r)})}function I(t){var e=t.filter(function(t){return t.notAdded}).reduce(function(t,e){return t.concat(e.notAdded)},[]),r=t.filter(function(t){return t.errors}).reduce(function(t,e){return t.concat(e.errors)},[]),n={notAdded:e};return 0<r.length&&(n.errors=r),n}function q(t){var e=u(t)+"/community/groups/"+t.id+"/updateUsers",r={authentication:t.authentication,params:{}};return"admin"===t.newMemberType?r.params.admins=t.users:r.params.users=t.users,i.request(e,r)}function w(t){var e,r={httpMethod:"GET"};if("string"==typeof t)e="https://www.arcgis.com/sharing/rest/community/users/"+t;else{var n=t.username||t.authentication.username;e=u(t)+"/community/users/"+encodeURIComponent(n),r=a({},t,r)}return i.request(e,r)}function T(t,e){return e.params=a({org:!1,everyone:!1},e.params),"private"===e.access&&(e.params.groups=" "),"org"===e.access&&(e.params.org=!0),"public"===e.access&&(e.params.account=!0,e.params.everyone=!0),i.request(t,e)}function b(i){var a=i.authentication.username,u=i.owner||a,s=i.confirmItemControl||!1;return w({username:a,authentication:i.authentication}).then(function(r){var n="org_admin"===r.role,o="share"===i.action?"notSharedWith":"notUnsharedFrom";return U(i).then(function(t){if("share"===i.action&&!0===t||"unshare"===i.action&&!1===t){var e={itemId:i.id,shortcut:!0};return e[o]=[],e}return d(i).then(function(t){if("none"===t&&!n)throw Error("This item can not be "+i.action+"d by "+a+" as they are not a member of the specified group "+i.groupId+".");if(s&&u!==a&&!n)throw Error("This item can not be "+i.action+"d to shared editing group "+i.groupId+" by "+a+" as they not the item owner.");if("unshare"===i.action&&u!==a&&"admin"!==t&&"owner"!==t)throw Error("This item can not be "+i.action+"d from group "+i.groupId+" by "+a+" as they not the item owner, group admin or group owner.");if("share"===i.action&&s&&u!==a&&n)return function(n,o){var i=o.owner;return w({username:i,authentication:o.authentication}).then(function(t){if(n.orgId!==t.orgId)throw Error("User "+i+" is not a member of the same org as "+n.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");var e=t.groups||[],r=e.find(function(t){return t.id===o.groupId});if(!r&&511<e.length)throw Error("User "+i+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return r?"member"===r.userMembership.memberType?q({id:o.groupId,users:[i],newMemberType:"admin",authentication:o.authentication}).then(function(t){return{notAdded:t.results.reduce(function(t,e){return e.success||t.push(e.username),t},[])}}):{notAdded:[]}:v({id:o.groupId,admins:[i],authentication:o.authentication})}).then(function(t){if(t.notAdded.length)throw Error("Error adding user "+i+" to group "+o.groupId+". Consequently item "+o.id+" was not shared to the group.");return G(o)})}(r,i);if("none"!==t)return G(i);throw Error("This item can not be "+i.action+"d by "+a+" as they are not a member of the specified group "+i.groupId+".")}).then(function(t){if(t[o].length)throw Error("Item "+i.id+" could not be "+i.action+"d to group "+i.groupId+".");return t})})})}function G(t){var e=t.authentication.username,r=t.owner||e,n=u(t)+"/content/items/"+t.id+"/"+t.action;return r===e&&(n=u(t)+"/content/users/"+r+"/items/"+t.id+"/"+t.action),t.params={groups:t.groupId,confirmItemControl:t.confirmItemControl},i.request(n,t)}function U(e){return g({q:"id: "+e.id+" AND group: "+e.groupId,start:1,num:10,sortField:"title",authentication:e.authentication,httpMethod:"POST"}).then(function(t){if(0<t.total)return t.results.some(function(t){return t.id===e.id})})}function C(t,e){var r=t||"self",n=u(e)+"/portals/"+r,o=a({httpMethod:"GET"},e);return i.request(n,o)}t.SearchQueryBuilder=h,t.acceptInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=u(t)+"/community/users/"+e+"/invitations/"+t.invitationId+"/accept",n=a({},t);return i.request(r,n)},t.addGroupUsers=v,t.addItemData=function(t){var e=a({item:{id:t.id,data:t.data}},t);return delete e.id,delete e.data,r(e)},t.addItemPart=function(n){return e(n).then(function(t){var e=u(n)+"/content/users/"+t+"/items/"+n.id+"/addPart",r=i.appendCustomParams(n,["file","partNum"],{params:a({},n.params)});return i.request(e,r)})},t.addItemRelationship=function(n){return e(n).then(function(t){var e=u(n)+"/content/users/"+t+"/addRelationship",r=i.appendCustomParams(n,["originItemId","destinationItemId","relationshipType"],{params:a({},n.params)});return i.request(e,r)})},t.addItemResource=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/addResources";return r.params=a({file:r.resource,fileName:r.name,resourcesPrefix:r.prefix,text:r.content,access:r.private?"private":"inherit"},r.params),i.request(e,r)})},t.cancelItemUpload=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/cancel";return i.request(e,r)})},t.commitItemUpload=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/commit";return i.request(e,r)})},t.createFolder=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/createFolder";return r.params=a({title:r.title},r.params),i.request(e,r)})},t.createGroup=function(t){var e=u(t)+"/community/createGroup";return t.params=a({},t.params,t.group),i.request(e,t)},t.createGroupNotification=function(t){var e=u(t)+"/community/groups/"+t.id+"/createNotification",r=a({params:a({subject:t.subject,message:t.message,users:t.users,notificationChannelType:t.notificationChannelType||"email",clientId:t.clientId,silentNotification:t.silentNotification,notifyAll:!t.users||0===t.users.length},t.params)},t);return i.request(e,r)},t.createItem=function(t){return n(a({folderId:null},t))},t.createItemInFolder=n,t.declineInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=u(t)+"/community/users/"+e+"/invitations/"+t.invitationId+"/decline",n=a({},t);return i.request(r,n)},t.determineOwner=e,t.getGroup=o,t.getGroupCategorySchema=function(t,e){var r=u(e)+"/community/groups/"+t+"/categorySchema",n=a({httpMethod:"GET"},e);return i.request(r,n)},t.getGroupContent=function(t,e){var r=u(e)+"/content/groups/"+t,n=a({httpMethod:"GET"},{params:{start:1,num:100}},e);return e&&e.paging&&(n.params=a({},e.paging)),i.request(r,n)},t.getGroupUsers=function(t,e){var r=u(e)+"/community/groups/"+t+"/users",n=a({httpMethod:"GET"},e);return i.request(r,n)},t.getItem=function(t,e){var r=u(e)+"/content/items/"+t,n=a({httpMethod:"GET"},e);return i.request(r,n)},t.getItemData=function(t,e){var r=u(e)+"/content/items/"+t+"/data",n=a({httpMethod:"GET",params:{}},e);return n.file&&(n.params.f=null),i.request(r,n).catch(function(t){if(!RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i).test(t.message))throw t})},t.getItemGroups=function(t,e){var r=u(e)+"/content/items/"+t+"/groups";return i.request(r,e)},t.getItemParts=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/parts";return i.request(e,r)})},t.getItemResources=function(t,e){var r=u(e)+"/content/items/"+t+"/resources",n=a({},e);return n.params=a({num:1e3},n.params),i.request(r,n)},t.getItemStatus=function(n){return e(n).then(function(t){var e=u(n)+"/content/users/"+t+"/items/"+n.id+"/status",r=i.appendCustomParams(n,["jobId","jobType"],{params:a({},n.params)});return i.request(e,r)})},t.getPortal=C,t.getPortalSettings=function(t,e){var r=t||"self",n=u(e)+"/portals/"+r+"/settings",o=a({httpMethod:"GET"},e);return i.request(n,o)},t.getPortalUrl=u,t.getRelatedItems=function(t){var e=u(t)+"/content/items/"+t.id+"/relatedItems",r=a({httpMethod:"GET",params:{direction:t.direction}},t);return"string"==typeof t.relationshipType?r.params.relationshipType=t.relationshipType:r.params.relationshipTypes=t.relationshipType,delete r.direction,delete r.relationshipType,i.request(e,r)},t.getSelf=function(t){return C(null,t)},t.getSharingUrl=c,t.getUser=w,t.getUserInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=u(t)+"/community/users/"+e+"/invitations/"+t.invitationId,n={httpMethod:"GET"};return n=a({},t,n),i.request(r,n)},t.getUserInvitations=function(t){var e={httpMethod:"GET"},r=encodeURIComponent(t.authentication.username),n=u(t)+"/community/users/"+r+"/invitations";return e=a({},t,e),i.request(n,e)},t.getUserMembership=d,t.getUserNotifications=function(t){var e={httpMethod:"GET"},r=encodeURIComponent(t.authentication.username),n=u(t)+"/community/users/"+r+"/notifications";return e=a({},t,e),i.request(n,e)},t.getUserTags=function(t){var e=t.username||t.authentication.username,r=u(t)+"/community/users/"+encodeURIComponent(e)+"/tags";return i.request(r,t)},t.getUserUrl=function(t){return u(t)+"/community/users/"+encodeURIComponent(t.username)},t.isItemOwner=m,t.isItemSharedWithGroup=U,t.isOrgAdmin=p,t.joinGroup=function(t){var e=u(t)+"/community/groups/"+t.id+"/join";return i.request(e,t)},t.leaveGroup=function(t){var e=u(t)+"/community/groups/"+t.id+"/leave";return i.request(e,t)},t.moveItem=function(n){return e(n).then(function(t){var e=u(n)+"/content/users/"+t+"/items/"+n.itemId+"/move",r=n.folderId;return r=r||"/",n.params=a({folder:r},n.params),i.request(e,n)})},t.protectGroup=function(t){var e=u(t)+"/community/groups/"+t.id+"/protect";return i.request(e,t)},t.protectItem=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/protect";return i.request(e,r)})},t.reassignItem=function(n){return p(n).then(function(t){if(!t)throw Error("Item "+n.id+" can not be reassigned because current user is not an organization administrator.");var e=u(n)+"/content/users/"+n.currentOwner+"/items/"+n.id+"/reassign",r={params:{targetUsername:n.targetUsername,targetFolderName:n.targetFolderName},authentication:n.authentication};return i.request(e,r)})},t.removeFolder=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+encodeURIComponent(t)+"/"+r.folderId+"/delete";return i.request(e,r)})},t.removeGroup=function(t){var e=u(t)+"/community/groups/"+t.id+"/delete",r=a({},t);return i.request(e,r)},t.removeItem=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/delete";return i.request(e,r)})},t.removeItemRelationship=function(n){return e(n).then(function(t){var e=u(n)+"/content/users/"+t+"/removeRelationship",r=i.appendCustomParams(n,["originItemId","destinationItemId","relationshipType"],{params:a({},n.params)});return i.request(e,r)})},t.removeItemResource=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/removeResources";return r.params=a({},r.params,{resource:r.resource}),i.request(e,r)})},t.removeNotification=function(t){var e=encodeURIComponent(t.authentication.username),r=u(t)+"/community/users/"+e+"/notifications/"+t.id+"/delete";return i.request(r,t)},t.searchGroupContent=function(t){return l(t,"groupContent")},t.searchGroupUsers=function(t,e){var r=u(e)+"/community/groups/"+t+"/userlist",n=i.appendCustomParams(e||{},["name","num","start","sortField","sortOrder","joined","memberType"],{httpMethod:"GET"});return i.request(r,n)},t.searchGroups=function(t){return l(t,"group")},t.searchItems=g,t.searchUsers=function(t){return l(t,"user")},t.serializeItem=s,t.setItemAccess=function(e){var r=c(e);return m(e)?T(r,e):p(e).then(function(t){if(t)return T(r,e);throw Error("This item can not be shared by "+e.authentication.username+". They are neither the item owner nor an organization admin.")})},t.shareItemWithGroup=function(t){return b(a({action:"share"},t))},t.unprotectGroup=function(t){var e=u(t)+"/community/groups/"+t.id+"/unprotect";return i.request(e,t)},t.unprotectItem=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/unprotect";return i.request(e,r)})},t.unshareItemWithGroup=function(t){return b(a({action:"unshare"},t))},t.updateGroup=function(t){var e=u(t)+"/community/groups/"+t.group.id+"/update";return t.params=a({},t.params,t.group),i.request(e,t)},t.updateItem=r,t.updateItemInfo=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/updateinfo";return r.params=a({folderName:r.folderName,file:r.file},r.params),i.request(e,r)})},t.updateItemResource=function(r){return e(r).then(function(t){var e=u(r)+"/content/users/"+t+"/items/"+r.id+"/updateResources";return r.params=a({file:r.resource,fileName:r.name,text:r.content},r.params),void 0!==r.private&&(r.params.access=r.private?"private":"inherit"),i.request(e,r)})},t.updateUser=function(t){var e=t.user.username||t.authentication.username,r=u(t)+"/community/users/"+encodeURIComponent(e)+"/update";return t.params=a({},t.user,t.params),delete t.user,i.request(r,t)},t.updateUserMemberships=q,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],e):e((t=t||self).arcgisRest=t.arcgisRest||{},t.arcgisRest)}(this,function(t,s){"use strict";var i=function(){return(i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function c(t){return void 0===t&&(t={}),t.portal?s.cleanUrl(t.portal):t.authentication?t.authentication.portal:"https://www.arcgis.com/sharing/rest"}function a(t){var e=JSON.parse(JSON.stringify(t));return e.data&&("undefined"!=typeof Blob&&t.data instanceof Blob||"ReadStream"===t.data.constructor.name?e.file=t.data:e.text=t.data,delete e.data),e}function m(t){return t.owner?Promise.resolve(t.owner):t.item&&t.item.owner?Promise.resolve(t.item.owner):t.authentication&&t.authentication.getUsername?t.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function r(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.item.id+"/update";return r.params=i({},r.params,a(r.item)),s.request(e,r)})}function e(o){return o.file&&!o.multipart?Promise.reject(new Error("The request must be a multipart request for file uploading.")):o.multipart&&!o.filename?Promise.reject(new Error("The file name is required for a multipart request.")):m(o).then(function(t){var e=c(o)+"/content/users/"+t,r=e+"/addItem";o.folderId&&(r=e+"/"+o.folderId+"/addItem"),o.params=i({},o.params,a(o.item));var n=s.appendCustomParams(o,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:i({},o.params)});return s.request(r,n)})}function n(t,e){var r=c(e)+"/community/groups/"+t,n=i({httpMethod:"GET"},e);return s.request(r,n)}function o(t){var e=t.authentication.username,r=t.owner||e;return c(t)+"/content/users/"+encodeURIComponent(r)+"/items/"+t.id+"/share"}function u(t){var e=t.authentication.username;return(t.owner||e)===e}function p(t){return t.authentication.getUser(t).then(function(t){return!(!t||"org_admin"!==t.role)})}function d(t){return n(t.groupId,t).then(function(t){return t.userMembership.memberType}).catch(function(){return"none"})}var h=(f.prototype.match=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.termStack=this.termStack.concat(t),this},f.prototype.in=function(t){var e="`in("+(t?'"'+t+'"':"")+")`";return this.hasRange||this.hasTerms?(t&&"*"!==t&&(this.q+=t+":"),this.commit()):(s.warn(e+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},f.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},f.prototype.endGroup=function(){return this.openGroups<=0?s.warn("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},f.prototype.and=function(){return this.addModifier("and")},f.prototype.or=function(){return this.addModifier("or")},f.prototype.not=function(){return this.addModifier("not")},f.prototype.from=function(t){return this.hasTerms?s.warn("`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Your query was not modified."):this.rangeStack[0]=t,this},f.prototype.to=function(t){return this.hasTerms?s.warn("`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Your query was not modified."):this.rangeStack[1]=t,this},f.prototype.boost=function(t){return this.commit(),this.q+="^"+t,this},f.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},f.prototype.clone=function(){return this.commit(),this.cleanup(),new f(this.q+"")},f.prototype.addModifier=function(t){return this.currentModifer?s.warn("You have called `"+this.currentModifer+"()` after `"+t+"()`. Your current query was not modified."):(this.commit(),""===this.q&&"not"!==t?s.warn("You have called `"+t+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=t,this.q+=""===this.q?"":" ",this.q+=t.toUpperCase()+" ")),this},f.prototype.hasWhiteSpace=function(t){return/\s/g.test(t)},f.prototype.formatTerm=function(t){return t instanceof Date?t.getTime():"string"==typeof t&&this.hasWhiteSpace(t)?'"'+t+'"':t},f.prototype.commit=function(){var e=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(t){return e.formatTerm(t)}).join(" "),this.termStack=[]),this},Object.defineProperty(f.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!0,configurable:!0}),f.prototype.cleanup=function(){if(0<this.openGroups)for(s.warn("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var t=this.q;this.q=t.replace(/( AND ?| NOT ?| OR ?)*$/,""),t!==this.q&&s.warn("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},f);function f(t){void 0===t&&(t=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=t}function l(r,n){var t,e,o;switch(e="string"==typeof r||r instanceof h?{httpMethod:"GET",params:{q:r}}:s.appendCustomParams(r,["q","num","start","sortField","sortOrder"],{httpMethod:"GET"}),n){case"item":o="/search";break;case"group":o="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof h||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));o="/content/groups/"+r.groupId+"/search";break;default:o="/portals/self/users/search"}return t=c(e)+o,s.request(t,e).then(function(e){return e.nextStart&&-1!==e.nextStart&&(e.nextPage=function(){var t;return"string"==typeof r||r instanceof h?t={q:r,start:e.nextStart}:(t=r).start=e.nextStart,l(t,n)}),e})}function g(t){return l(t,"item")}function v(t){var e=t.id,r=c(t)+"/community/groups/"+e+"/addUsers",n=Object.assign({},t,{admins:void 0,users:void 0}),o=y("users",t.users,n).concat(y("admins",t.admins,n)).map(function(t){return function(t,e){return s.request(t,e).catch(function(t){return{errors:[t]}})}(r,t)});return Promise.all(o).then(I)}function y(e,t,r){return!t||t.length<1?[]:function(t,e){if(0===t.length)return[];for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}(t,25).map(function(t){return function(t,e,r){var n,o;return Object.assign({},r,((n={})[t]=e,n.params=i({},r.params,((o={})[t]=e,o)),n))}(e,t,r)})}function I(t){var e=t.filter(function(t){return t.notAdded}).reduce(function(t,e){return t.concat(e.notAdded)},[]),r=t.filter(function(t){return t.errors}).reduce(function(t,e){return t.concat(e.errors)},[]),n={notAdded:e};return 0<r.length&&(n.errors=r),n}function q(t){var e=c(t)+"/community/groups/"+t.id+"/updateUsers",r={authentication:t.authentication,params:{}};return"admin"===t.newMemberType?r.params.admins=t.users:r.params.users=t.users,s.request(e,r)}function w(t){var e,r={httpMethod:"GET"};if("string"==typeof t)e="https://www.arcgis.com/sharing/rest/community/users/"+t;else{var n=t.username||t.authentication.username;e=c(t)+"/community/users/"+encodeURIComponent(n),r=i({},t,r)}return s.request(e,r)}function T(t,e){return e.params=i({org:!1,everyone:!1},e.params),"private"===e.access&&(e.params.groups=" "),"org"===e.access&&(e.params.org=!0),"public"===e.access&&(e.params.account=!0,e.params.everyone=!0),s.request(t,e)}function G(i){var a=i.authentication.username,u=i.owner||a,s=i.confirmItemControl||!1;return w({username:a,authentication:i.authentication}).then(function(r){var n="org_admin"===r.role,o="share"===i.action?"notSharedWith":"notUnsharedFrom";return U(i).then(function(t){if("share"===i.action&&!0===t||"unshare"===i.action&&!1===t){var e={itemId:i.id,shortcut:!0};return e[o]=[],e}return d(i).then(function(t){if("none"===t&&!n)throw Error("This item can not be "+i.action+"d by "+a+" as they are not a member of the specified group "+i.groupId+".");if(s&&u!==a&&!n)throw Error("This item can not be "+i.action+"d to shared editing group "+i.groupId+" by "+a+" as they not the item owner.");if("unshare"===i.action&&u!==a&&"admin"!==t&&"owner"!==t)throw Error("This item can not be "+i.action+"d from group "+i.groupId+" by "+a+" as they not the item owner, group admin or group owner.");if("share"===i.action&&s&&u!==a&&n)return function(n,o){var i=o.owner;return w({username:i,authentication:o.authentication}).then(function(t){if(n.orgId!==t.orgId)throw Error("User "+i+" is not a member of the same org as "+n.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");var e=t.groups||[],r=e.find(function(t){return t.id===o.groupId});if(!r&&511<e.length)throw Error("User "+i+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return r?"member"===r.userMembership.memberType?q({id:o.groupId,users:[i],newMemberType:"admin",authentication:o.authentication}).then(function(t){return{notAdded:t.results.reduce(function(t,e){return e.success||t.push(e.username),t},[])}}):{notAdded:[]}:v({id:o.groupId,admins:[i],authentication:o.authentication})}).then(function(t){if(t.notAdded.length)throw Error("Error adding user "+i+" to group "+o.groupId+". Consequently item "+o.id+" was not shared to the group.");return b(o)})}(r,i);if("none"!==t)return b(i);throw Error("This item can not be "+i.action+"d by "+a+" as they are not a member of the specified group "+i.groupId+".")}).then(function(t){if(t[o].length)throw Error("Item "+i.id+" could not be "+i.action+"d to group "+i.groupId+".");return t})})})}function b(t){var e=t.authentication.username,r=t.owner||e,n=c(t)+"/content/items/"+t.id+"/"+t.action;return r===e&&(n=c(t)+"/content/users/"+r+"/items/"+t.id+"/"+t.action),t.params={groups:t.groupId,confirmItemControl:t.confirmItemControl},s.request(n,t)}function U(e){return g({q:"id: "+e.id+" AND group: "+e.groupId,start:1,num:10,sortField:"title",authentication:e.authentication,httpMethod:"POST"}).then(function(t){if(0<t.total)return t.results.some(function(t){return t.id===e.id})})}function C(t,e){var r=t||"self",n=c(e)+"/portals/"+r,o=i({httpMethod:"GET"},e);return s.request(n,o)}t.SearchQueryBuilder=h,t.acceptInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=c(t)+"/community/users/"+e+"/invitations/"+t.invitationId+"/accept",n=i({},t);return s.request(r,n)},t.addGroupUsers=v,t.addItemData=function(t){var e=i({item:{id:t.id,data:t.data}},t);return delete e.id,delete e.data,r(e)},t.addItemPart=function(n){return m(n).then(function(t){var e=c(n)+"/content/users/"+t+"/items/"+n.id+"/addPart",r=s.appendCustomParams(n,["file","partNum"],{params:i({},n.params)});return s.request(e,r)})},t.addItemRelationship=function(n){return m(n).then(function(t){var e=c(n)+"/content/users/"+t+"/addRelationship",r=s.appendCustomParams(n,["originItemId","destinationItemId","relationshipType"],{params:i({},n.params)});return s.request(e,r)})},t.addItemResource=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/addResources";return r.params=i({file:r.resource,fileName:r.name,resourcesPrefix:r.prefix,text:r.content,access:r.private?"private":"inherit"},r.params),s.request(e,r)})},t.cancelItemUpload=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/cancel";return s.request(e,r)})},t.commitItemUpload=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/commit";return s.request(e,r)})},t.createFolder=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/createFolder";return r.params=i({title:r.title},r.params),s.request(e,r)})},t.createGroup=function(t){var e=c(t)+"/community/createGroup";return t.params=i({},t.params,t.group),s.request(e,t)},t.createGroupNotification=function(t){var e=c(t)+"/community/groups/"+t.id+"/createNotification",r=i({params:i({subject:t.subject,message:t.message,users:t.users,notificationChannelType:t.notificationChannelType||"email",clientId:t.clientId,silentNotification:t.silentNotification,notifyAll:!t.users||0===t.users.length},t.params)},t);return s.request(e,r)},t.createItem=function(t){return e(i({folderId:null},t))},t.createItemInFolder=e,t.declineInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=c(t)+"/community/users/"+e+"/invitations/"+t.invitationId+"/decline",n=i({},t);return s.request(r,n)},t.determineOwner=m,t.exportItem=function(e){var r=e.authentication,n=e.id,o=e.title,i=e.exportFormat,a=e.exportParameters;return m(e).then(function(t){return c(e)+"/content/users/"+t+"/export"}).then(function(t){return s.request(t,{httpMethod:"POST",authentication:r,params:{itemId:n,title:o,exportFormat:i,exportParameters:a}})})},t.getGroup=n,t.getGroupCategorySchema=function(t,e){var r=c(e)+"/community/groups/"+t+"/categorySchema",n=i({httpMethod:"GET"},e);return s.request(r,n)},t.getGroupContent=function(t,e){var r=c(e)+"/content/groups/"+t,n=i({httpMethod:"GET"},{params:{start:1,num:100}},e);return e&&e.paging&&(n.params=i({},e.paging)),s.request(r,n)},t.getGroupUsers=function(t,e){var r=c(e)+"/community/groups/"+t+"/users",n=i({httpMethod:"GET"},e);return s.request(r,n)},t.getItem=function(t,e){var r=c(e)+"/content/items/"+t,n=i({httpMethod:"GET"},e);return s.request(r,n)},t.getItemData=function(t,e){var r=c(e)+"/content/items/"+t+"/data",n=i({httpMethod:"GET",params:{}},e);return n.file&&(n.params.f=null),s.request(r,n).catch(function(t){if(!RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i).test(t.message))throw t})},t.getItemGroups=function(t,e){var r=c(e)+"/content/items/"+t+"/groups";return s.request(r,e)},t.getItemParts=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/parts";return s.request(e,r)})},t.getItemResources=function(t,e){var r=c(e)+"/content/items/"+t+"/resources",n=i({},e);return n.params=i({num:1e3},n.params),s.request(r,n)},t.getItemStatus=function(n){return m(n).then(function(t){var e=c(n)+"/content/users/"+t+"/items/"+n.id+"/status",r=s.appendCustomParams(n,["jobId","jobType"],{params:i({},n.params)});return s.request(e,r)})},t.getPortal=C,t.getPortalSettings=function(t,e){var r=t||"self",n=c(e)+"/portals/"+r+"/settings",o=i({httpMethod:"GET"},e);return s.request(n,o)},t.getPortalUrl=c,t.getRelatedItems=function(t){var e=c(t)+"/content/items/"+t.id+"/relatedItems",r=i({httpMethod:"GET",params:{direction:t.direction}},t);return"string"==typeof t.relationshipType?r.params.relationshipType=t.relationshipType:r.params.relationshipTypes=t.relationshipType,delete r.direction,delete r.relationshipType,s.request(e,r)},t.getSelf=function(t){return C(null,t)},t.getSharingUrl=o,t.getUser=w,t.getUserContent=function(e){var t=e.folderId,r=e.start,n=void 0===r?1:r,o=e.num,i=void 0===o?10:o,a=e.authentication,u=t?"/"+t:"";return m(e).then(function(t){return c(e)+"/content/users/"+t+u}).then(function(t){return s.request(t,{httpMethod:"GET",authentication:a,params:{start:n,num:i}})})},t.getUserInvitation=function(t){var e=encodeURIComponent(t.authentication.username),r=c(t)+"/community/users/"+e+"/invitations/"+t.invitationId,n={httpMethod:"GET"};return n=i({},t,n),s.request(r,n)},t.getUserInvitations=function(t){var e={httpMethod:"GET"},r=encodeURIComponent(t.authentication.username),n=c(t)+"/community/users/"+r+"/invitations";return e=i({},t,e),s.request(n,e)},t.getUserMembership=d,t.getUserNotifications=function(t){var e={httpMethod:"GET"},r=encodeURIComponent(t.authentication.username),n=c(t)+"/community/users/"+r+"/notifications";return e=i({},t,e),s.request(n,e)},t.getUserTags=function(t){var e=t.username||t.authentication.username,r=c(t)+"/community/users/"+encodeURIComponent(e)+"/tags";return s.request(r,t)},t.getUserUrl=function(t){return c(t)+"/community/users/"+encodeURIComponent(t.username)},t.isItemOwner=u,t.isItemSharedWithGroup=U,t.isOrgAdmin=p,t.joinGroup=function(t){var e=c(t)+"/community/groups/"+t.id+"/join";return s.request(e,t)},t.leaveGroup=function(t){var e=c(t)+"/community/groups/"+t.id+"/leave";return s.request(e,t)},t.moveItem=function(n){return m(n).then(function(t){var e=c(n)+"/content/users/"+t+"/items/"+n.itemId+"/move",r=n.folderId;return r=r||"/",n.params=i({folder:r},n.params),s.request(e,n)})},t.protectGroup=function(t){var e=c(t)+"/community/groups/"+t.id+"/protect";return s.request(e,t)},t.protectItem=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/protect";return s.request(e,r)})},t.reassignItem=function(n){return p(n).then(function(t){if(!t)throw Error("Item "+n.id+" can not be reassigned because current user is not an organization administrator.");var e=c(n)+"/content/users/"+n.currentOwner+"/items/"+n.id+"/reassign",r={params:{targetUsername:n.targetUsername,targetFolderName:n.targetFolderName},authentication:n.authentication};return s.request(e,r)})},t.removeFolder=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+encodeURIComponent(t)+"/"+r.folderId+"/delete";return s.request(e,r)})},t.removeGroup=function(t){var e=c(t)+"/community/groups/"+t.id+"/delete",r=i({},t);return s.request(e,r)},t.removeItem=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/delete";return s.request(e,r)})},t.removeItemRelationship=function(n){return m(n).then(function(t){var e=c(n)+"/content/users/"+t+"/removeRelationship",r=s.appendCustomParams(n,["originItemId","destinationItemId","relationshipType"],{params:i({},n.params)});return s.request(e,r)})},t.removeItemResource=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/removeResources";return r.params=i({},r.params,{resource:r.resource}),s.request(e,r)})},t.removeNotification=function(t){var e=encodeURIComponent(t.authentication.username),r=c(t)+"/community/users/"+e+"/notifications/"+t.id+"/delete";return s.request(r,t)},t.searchGroupContent=function(t){return l(t,"groupContent")},t.searchGroupUsers=function(t,e){var r=c(e)+"/community/groups/"+t+"/userlist",n=s.appendCustomParams(e||{},["name","num","start","sortField","sortOrder","joined","memberType"],{httpMethod:"GET"});return s.request(r,n)},t.searchGroups=function(t){return l(t,"group")},t.searchItems=g,t.searchUsers=function(t){return l(t,"user")},t.serializeItem=a,t.setItemAccess=function(e){var r=o(e);return u(e)?T(r,e):p(e).then(function(t){if(t)return T(r,e);throw Error("This item can not be shared by "+e.authentication.username+". They are neither the item owner nor an organization admin.")})},t.shareItemWithGroup=function(t){return G(i({action:"share"},t))},t.unprotectGroup=function(t){var e=c(t)+"/community/groups/"+t.id+"/unprotect";return s.request(e,t)},t.unprotectItem=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/unprotect";return s.request(e,r)})},t.unshareItemWithGroup=function(t){return G(i({action:"unshare"},t))},t.updateGroup=function(t){var e=c(t)+"/community/groups/"+t.group.id+"/update";return t.params=i({},t.params,t.group),s.request(e,t)},t.updateItem=r,t.updateItemInfo=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/updateinfo";return r.params=i({folderName:r.folderName,file:r.file},r.params),s.request(e,r)})},t.updateItemResource=function(r){return m(r).then(function(t){var e=c(r)+"/content/users/"+t+"/items/"+r.id+"/updateResources";return r.params=i({file:r.resource,fileName:r.name,text:r.content},r.params),void 0!==r.private&&(r.params.access=r.private?"private":"inherit"),s.request(e,r)})},t.updateUser=function(t){var e=t.user.username||t.authentication.username,r=c(t)+"/community/users/"+encodeURIComponent(e)+"/update";return t.params=i({},t.user,t.params),delete t.user,s.request(r,t)},t.updateUserMemberships=q,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=portal.umd.min.js.map |
{ | ||
"name": "@esri/arcgis-rest-portal", | ||
"version": "2.13.2", | ||
"version": "2.14.0", | ||
"description": "ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request", | ||
@@ -16,8 +16,8 @@ "main": "dist/node/index.js", | ||
"dependencies": { | ||
"@esri/arcgis-rest-types": "^2.13.2", | ||
"@esri/arcgis-rest-types": "^2.14.0", | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": { | ||
"@esri/arcgis-rest-auth": "^2.13.2", | ||
"@esri/arcgis-rest-request": "^2.13.2" | ||
"@esri/arcgis-rest-auth": "^2.14.0", | ||
"@esri/arcgis-rest-request": "^2.14.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
791026
216
9548