@esri/arcgis-rest-portal 4.9.1 → 4.10.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-portal - v4.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.10.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2026 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Mar 05 2026 01:31:06 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import { cleanUrl, request, appendCustomParams, warn } from '@esri/arcgis-rest-request';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-portal - v4.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.10.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2026 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Mar 05 2026 01:31:06 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import{cleanUrl as t,request as e,appendCustomParams as n,warn as r}from"@esri/arcgis-rest-request";function s(e={}){return e.portal?t(e.portal):e.authentication&&"string"!=typeof e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function o(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 i(t){return Array.isArray(t)&&Array.isArray(t[0])&&Array.isArray(t[1])}function a(t){return t.join(",")}function u(t,e,n){if(!t)return t;let r=null;return"string"==typeof t.thumbnail&&(r=`${e}/content/items/${t.id}/info/${t.thumbnail}`,r&&"public"!==t.access&&n&&(r+=`?${n}`)),Object.assign(Object.assign({},t),r?{thumbnailUrl:r}:{})}function c(t){return o(t).then(n=>{const r=t.folderId?`${s(t)}/content/users/${n}/${t.folderId}/items/${t.item.id}/update`:`${s(t)}/content/users/${n}/items/${t.item.id}/update`;t.params=Object.assign(Object.assign({},t.params),t.item),t.params.extent&&i(t.params.extent)&&(t.params.extent=a(t.params.extent));const o=s(t),c=u(Object.assign(Object.assign({},t.item),{access:t.item.access}),o),m=t.params.thumbnailUrl;return"string"==typeof c.thumbnailUrl&&"string"==typeof m&&c.thumbnailUrl.split("?")[0]===m.split("?")[0]&&delete t.params.thumbnailUrl,e(r,t)})}function m(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/updateinfo`;return t.params=Object.assign({folderName:t.folderName,file:t.file},t.params),e(r,t)})}function h(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/updateResources`;return t.params=Object.assign({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content},t.params),void 0!==t.private&&(t.params.access=t.private?"private":"inherit"),e(r,t)})}function d(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.itemId}/move`;let o=t.folderId;return o||(o="/"),t.params=Object.assign({folder:o},t.params),e(r,t)})}function p(t){const e=Object.assign({item:{id:t.id,text:t.text,file:t.file}},t);return delete e.id,delete e.data,c(e)}function l(t){return o(t).then(r=>{const o=`${s(t)}/content/users/${r}/addRelationship`,i=n(t,["originItemId","destinationItemId","relationshipType"],{params:Object.assign({},t.params)});return e(o,i)})}function g(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/addResources`;return t.params=Object.assign({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content,access:t.private?"private":"inherit"},t.params),e(r,t)})}const f=t=>{const{folderId:n,start:r=1,num:i=10,authentication:a}=t,u=n?`/${n}`:"";return o(t).then(e=>`${s(t)}/content/users/${e}${u}`).then(t=>e(t,{httpMethod:"GET",authentication:a,params:{start:r,num:i}}))};function $(t){return o(t).then(n=>{const r=`${`${s(t)}/content/users/${n}`}/createFolder`;return t.params=Object.assign({title:t.title},t.params),e(r,t)})}function b(t){return t.multipart&&!t.filename?Promise.reject(new Error("The filename is required for a multipart request.")):o(t).then(r=>{const o=`${s(t)}/content/users/${r}`;let u=`${o}/addItem`;t.folderId&&(u=`${o}/${t.folderId}/addItem`),t.params=Object.assign(Object.assign({},t.params),t.item),t.params.extent&&i(t.params.extent)&&(t.params.extent=a(t.params.extent));const c=n(t,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:Object.assign({},t.params)});return e(u,c)})}function y(t){return b(Object.assign({folderId:null},t))}const w=t=>{const{authentication:n,id:r,title:i,exportFormat:a,exportParameters:u}=t;return o(t).then(e=>`${s(t)}/content/users/${e}/export`).then(t=>e(t,{httpMethod:"POST",authentication:n,params:{itemId:r,title:i,exportFormat:a,exportParameters:u}}))},j=/[\x00-\x1F\x7F-\x9F\xA0]/g;function O(t){return t.replace(j,"")}function I(t,n){const r=T(t,n),o=Object.assign({httpMethod:"GET"},n);return e(r,o).then(async t=>{const e=(null==n?void 0:n.portal)||s(n);let o;return(null==n?void 0:n.authentication)&&"string"!=typeof n.authentication&&"public"!==t.access&&(o=await n.authentication.getToken(r)),u(t,e,o)})}const T=(t,e)=>`${"string"==typeof e?e:s(e)}/content/items/${t}`;function v(t,n){const r=`${T(t,n)}/data`,s=Object.assign({httpMethod:"GET",params:{}},n);return s.file&&(s.params.f=null),e(r,s).catch(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})}function x(t){const n=`${T(t.id,t)}/relatedItems`,r=Object.assign({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,e(n,r)}function E(t,n){const r=`${T(t,n)}/resources`,s=Object.assign({},n);return s.params=Object.assign({num:1e3},s.params),e(r,s)}function q(t,e){const n=e.readAs||"blob";return A(t,`/resources/${e.fileName}`,n,e)}function U(t,n){const r=`${T(t,n)}/groups`;return e(r,n)}function G(t){return o(t).then(r=>{const o=`${s(t)}/content/users/${r}/items/${t.id}/status`,i=n(t,["jobId","jobType"],{params:Object.assign({},t.params)});return e(o,i)})}function M(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/parts`;return e(r,t)})}function S(t,e){const{fileName:n="iteminfo.xml",readAs:r="text"}=e||{};return A(t,`/info/${n}`,r,Object.assign({httpMethod:"GET"},e))}function P(t,e){return S(t,Object.assign(Object.assign({},e),{fileName:"metadata/metadata.xml"}))}function A(t,n,r,s){const o=`${T(t,s)}${n}`,i=Object.assign({params:{}},s),a=i.rawResponse;return i.rawResponse=!0,i.params.f=null,e(o,i).then(t=>a?t:"json"!==r?t[r]():t.text().then(t=>JSON.parse(O(t))))}function C(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/protect`;return e(r,t)})}function N(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/unprotect`;return e(r,t)})}function R(t,n){const r=`${s(n)}/community/groups/${t}`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function k(t,n){const r=`${s(n)}/community/groups/${t}/categorySchema`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function F(t,n){const r=`${s(n)}/content/groups/${t}`,o=Object.assign(Object.assign({httpMethod:"GET"},{params:{start:1,num:100}}),n);return n&&n.paging&&(o.params=Object.assign({},n.paging)),e(r,o)}function D(t,n){const r=`${s(n)}/community/groups/${t}/users`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function Y(t,r){const o=`${s(r)}/community/groups/${t}/userlist`,i=n(r||{},["name","num","start","sortField","sortOrder","joined","memberType"],{httpMethod:"GET"});return e(o,i)}function z(t,e){const n=e||t.authentication.username,r=t.owner||n;return`${s(t)}/content/users/${encodeURIComponent(r)}/items/${t.id}/share`}function W(t,e){const n=e||t.authentication.username;return(t.owner||n)===n}function _(t){return t.authentication.getUser().then(t=>t&&"org_admin"===t.role&&!t.roleId)}function J(t){return R(t.groupId,t).then(t=>t.userMembership.memberType).catch(()=>"none")}function V(t){return _(t).then(n=>{if(!n)throw Error(`Item ${t.id} can not be reassigned because current user is not an organization administrator.`);const r=`${s(t)}/content/users/${t.currentOwner}/items/${t.id}/reassign`,o={params:{targetUsername:t.targetUsername,targetFolderName:t.targetFolderName},authentication:t.authentication};return e(r,o)})}function B(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/delete`;return e(r,t)})}function H(t){return o(t).then(r=>{const o=`${s(t)}/content/users/${r}/deleteRelationship`,i=n(t,["originItemId","destinationItemId","relationshipType"],{params:Object.assign({},t.params)});return e(o,i)})}function K(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/removeResources`;return t.params=Object.assign(Object.assign({},t.params),{resource:t.resource}),void 0!==t.deleteAll&&(t.params.deleteAll=t.deleteAll),e(r,t)})}function L(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${encodeURIComponent(n)}/${t.folderId}/delete`;return e(r,t)})}function Q(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/deleteThumbnail`;return e(r,t)})}class X{constructor(t=""){this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=t}match(...t){return this.termStack=this.termStack.concat(t),this}in(t){const e=`\`in(${t?`"${t}"`:""})\``;return this.hasRange||this.hasTerms?(t&&"*"!==t&&(this.q+=`${t}:`),this.commit()):(r(`${e} was called with no call to \`match(...)\` or \`from(...)\`/\`to(...)\`. Your query was not modified.`),this)}startGroup(){return this.commit(),this.openGroups>0&&(this.q+=" "),this.openGroups++,this.q+="(",this}endGroup(){return this.openGroups<=0?(r("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."),this):(this.commit(),this.openGroups--,this.q+=")",this)}and(){return this.addModifier("and")}or(){return this.addModifier("or")}not(){return this.addModifier("not")}from(t){return this.hasTerms?(r('`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.'),this):(this.rangeStack[0]=t,this)}to(t){return this.hasTerms?(r('`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.'),this):(this.rangeStack[1]=t,this)}boost(t){return this.commit(),this.q+=`^${t}`,this}toParam(){return this.commit(),this.cleanup(),this.q}clone(){return this.commit(),this.cleanup(),new X(this.q+"")}addModifier(t){return this.currentModifer?(r(`You have called \`${this.currentModifer}()\` after \`${t}()\`. Your current query was not modified.`),this):(this.commit(),""===this.q&&"not"!==t?(r(`You have called \`${t}()\` without calling another method to modify your query first. Try calling \`match()\` first.`),this):(this.currentModifer=t,this.q+=""===this.q?"":" ",this.q+=`${t.toUpperCase()} `,this))}hasWhiteSpace(t){return/\s/g.test(t)}formatTerm(t){return t instanceof Date?t.getTime():"string"==typeof t&&this.hasWhiteSpace(t)?`"${t}"`:t}commit(){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(t=>this.formatTerm(t)).join(" "),this.termStack=[]),this}get hasTerms(){return this.termStack.length>0}get hasRange(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]}cleanup(){if(this.openGroups>0)for(r(`Automatically closing ${this.openGroups} group(s). You can use \`endGroup(...)\` to remove this warning.`);this.openGroups>0;)this.q+=")",this.openGroups--;const t=this.q;this.q=t.replace(/( AND ?| NOT ?| OR ?)*$/,""),t!==this.q&&r("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")}}function Z(t,r){let o,i;switch(o="string"==typeof t||t instanceof X?{httpMethod:"GET",params:{q:t}}:n(t,["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],{httpMethod:"GET"}),r){case"item":i="/search";break;case"group":i="/community/groups";break;case"groupContent":if("string"==typeof t||t instanceof X||!t.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));i=`/content/groups/${t.groupId}/search`;break;case"communityUser":i="/community/users";break;default:i="/portals/self/users/search"}const a=s(o)+i;return e(a,o).then(e=>(e.nextStart&&-1!==e.nextStart&&(e.nextPage=function(){let n;return"string"==typeof t||t instanceof X?n={q:t,start:e.nextStart}:(n=t,n.start=e.nextStart),Z(n,r)}),e))}function tt(t){return Z(t,"item")}function et(t){const r=t.partNum;return!Number.isInteger(r)||r<1||r>1e4?Promise.reject(new Error("The part number must be an integer between 1 to 10000, inclusive.")):o(t).then(o=>{const i=`${s(t)}/content/users/${o}/items/${t.id}/addPart?partNum=${r}`,a=n(t,["file"],{params:Object.assign({},t.params)});return e(i,a)})}function nt(t){return o(t).then(r=>{const o=`${s(t)}/content/users/${r}/items/${t.id}/commit`,i=n(t,[],{params:Object.assign(Object.assign({},t.params),t.item)});return e(o,i)})}function rt(t){return o(t).then(n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/cancel`;return e(r,t)})}function st(t,e){if(0===t.length)return[];const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}function ot(t){const n=t.id,r=`${s(t)}/community/groups/${n}/addUsers`,o=Object.assign({},t,{admins:void 0,users:void 0}),i=[...it("users",t.users,o),...it("admins",t.admins,o)].map(t=>function(t,n){return e(t,n).catch(t=>({errors:[t]}))}(r,t));return Promise.all(i).then(at)}function it(t,e,n){if(!e||e.length<1)return[];return st(e,25).map(e=>function(t,e,n){return Object.assign({},n,{[t]:e,params:Object.assign(Object.assign({},n.params),{[t]:e})})}(t,e,n))}function at(t){const e=t.filter(t=>t.notAdded).reduce((t,e)=>t.concat(e.notAdded),[]),n=t.filter(t=>t.errors).reduce((t,e)=>t.concat(e.errors),[]),r={notAdded:e};return n.length>0&&(r.errors=n),r}function ut(t){const{id:n,users:r}=t,o=`${s(t)}/community/groups/${n}/removeUsers`,i=st(r,25).map(n=>(n=>{const r=Object.assign(Object.assign({},t),{users:n,params:{users:n}});return e(o,r).catch(t=>({errors:[t]}))})(n));return Promise.all(i).then(t=>{const e=e=>t.filter(t=>t[e]).reduce((t,n)=>t.concat(n[e]),[]),n=e("errors"),r={notRemoved:e("notRemoved")};return n.length?Object.assign(Object.assign({},r),{errors:n}):r})}function ct(t){const n=t.id,r=`${s(t)}/community/groups/${n}/invite`,o=function(t){const e=st(t.users,25);return e.map(e=>function(t,e){const n=Object.assign({},e);return n.params=Object.assign(Object.assign({},n.params),{users:t,role:n.role,expiration:n.expiration}),n}(e,t))}(t),i=o.map(t=>function(t,n){return e(t,n).catch(t=>({errors:[t]}))}(r,t));return Promise.all(i).then(mt)}function mt(t){const e=t.every(t=>t.success),n=t.reduce((t,e)=>t.concat(e.errors||[]),[]),r={success:e};return n.length>0&&(r.errors=n),r}function ht(t){const n=`${s(t)}/community/createGroup`;return t.params=Object.assign(Object.assign({},t.params),t.group),e(n,t)}function dt(t){const n=`${s(t)}/community/groups/${t.id}/createNotification`,r=Object.assign({params:Object.assign({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 e(n,r)}function pt(t){const n=`${s(t)}/community/groups/${t.id}/protect`;return e(n,t)}function lt(t){const n=`${s(t)}/community/groups/${t.id}/unprotect`;return e(n,t)}function gt(t){const n=`${s(t)}/community/groups/${t.id}/delete`,r=Object.assign({},t);return e(n,r)}function ft(t){return Z(t,"group")}function $t(t){return Z(t,"groupContent")}function bt(t){const n=`${s(t)}/community/groups/${t.group.id}/update`;return t.params=Object.assign(Object.assign({},t.params),t.group),e(n,t)}function yt(t){const n=`${s(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,e(n,r)}function wt(t){const n=`${s(t)}/community/groups/${t.id}/join`;return e(n,t)}function jt(t){const n=`${s(t)}/community/groups/${t.id}/leave`;return e(n,t)}function Ot(t){const n=`${s(t)}/portals/self/createNotification`,r=function(t){const e=st(t.users,t.batchSize||25);return e.map(e=>function(t,e){const n=Object.assign({},e);return n.params=Object.assign(Object.assign({},n.params),{users:t,subject:e.subject,message:e.message,notificationChannelType:n.notificationChannelType}),n}(e,t))}(t),o=r.map(t=>function(t,n){return e(t,n).catch(t=>({errors:[t]}))}(n,t));return Promise.all(o).then(It)}function It(t){const e=t.every(t=>t.success),n=t.reduce((t,e)=>t.concat(e.errors||[]),[]),r={success:e};return n.length>0&&(r.errors=n),r}async function Tt(t){var e;return t.username?encodeURIComponent(t.username):(null===(e=t.authentication)||void 0===e?void 0:e.username)?encodeURIComponent(t.authentication.username):t.authentication?t.authentication.getUsername().then(encodeURIComponent):void 0}async function vt(t){let n,r={httpMethod:"GET"};if("string"==typeof t)n=`https://www.arcgis.com/sharing/rest/community/users/${t}`;else{const e=await Tt(t);n=`${s(t)}/community/users/${e}`,r=Object.assign(Object.assign({},t),r)}return e(n,r)}async function xt(t){const n=await Tt(t),r=`${s(t)}/community/users/${n}/tags`;return e(r,t)}function Et(t){return`${s(t)}/community/users/${encodeURIComponent(t.username)}`}async function qt(t){let n={httpMethod:"GET"};const r=await Tt(t),o=`${s(t)}/community/users/${r}/invitations`;return n=Object.assign(Object.assign({},t),n),e(o,n)}async function Ut(t){const n=await Tt(t),r=`${s(t)}/community/users/${n}/invitations/${t.invitationId}`;let o={httpMethod:"GET"};return o=Object.assign(Object.assign({},t),o),e(r,o)}async function Gt(t){const n=await Tt(t),r=`${s(t)}/community/users/${n}/invitations/${t.invitationId}/accept`,o=Object.assign({},t);return e(r,o)}async function Mt(t){const n=await Tt(t),r=`${s(t)}/community/users/${n}/invitations/${t.invitationId}/decline`,o=Object.assign({},t);return e(r,o)}async function St(t){let n={httpMethod:"GET"};const r=await Tt(t),o=`${s(t)}/community/users/${r}/notifications`;return n=Object.assign(Object.assign({},t),n),e(o,n)}async function Pt(t){const n=await Tt(t),r=`${s(t)}/community/users/${n}/notifications/${t.id}/delete`;return e(r,t)}function At(t){return Z(t,"user")}function Ct(t){return Z(t,"communityUser")}async function Nt(t){const n=t.user.username||await t.authentication.getUsername(),r=`${s(t)}/community/users/${encodeURIComponent(n)}/update`;return t.params=Object.assign(Object.assign({},t.user),t.params),delete t.user,e(r,t)}async function Rt(t,n){const r=`${s(n)}/community/users/${encodeURIComponent(t)}/properties`,o=await e(r,Object.assign({httpMethod:"GET"},n));return o.properties.mapViewer||(o.properties.mapViewer="modern"),o.properties}async function kt(t,n,r){const o=`${s(r)}/community/users/${encodeURIComponent(t)}/setProperties`,i=Object.assign({httpMethod:"POST",params:{properties:n}},r);try{const t=await e(o,i);if(!t.success)throw new Error("Success was false");return t}catch(t){throw new Error(`Failed to set user properties: ${t.message}`)}}async function Ft(t){const e=await t.authentication.getUsername(),n=z(t,e);return W(t,e)?Dt(n,t):_(t).then(r=>{if(r)return Dt(n,t);throw Error(`This item can not be shared by ${e}. They are neither the item owner nor an organization admin.`)})}function Dt(t,n){return n.params=Object.assign({org:!1,everyone:!1},n.params),"private"===n.access&&(n.params.groups=" "),"org"===n.access&&(n.params.org=!0),"public"===n.access&&(n.params.account=!0,n.params.everyone=!0),e(t,n)}function Yt(t){return tt({q:`id: ${t.id} AND group: ${t.groupId}`,start:1,num:10,sortField:"title",authentication:t.authentication,httpMethod:"POST"}).then(e=>{let n=!1;if(e.total>0)return n=e.results.some(e=>e.id===t.id),n})}async function zt(t){return Yt(t).then(async e=>{if(e)return{itemId:t.id,shortcut:!0,notSharedWith:[]};const{owner:n,confirmItemControl:r}=t,s=await t.authentication.getUsername(),o=n||s;if(o!==s){let e=!1,n=!1;return Promise.all([vt({username:s,authentication:t.authentication}),vt({username:o,authentication:t.authentication}),J(t)]).then(([s,o,i])=>{const a=!!r;return e="org_admin"===s.role&&!s.roleId,n=s.orgId!==o.orgId,function(t,e,n,r,s,o){const i=[];if(o.groupId!==t.favGroupId)if(e){if(!r)throw Error(`This item can not be shared to shared editing group ${o.groupId} by ${t.username} as they not the item owner or org admin.`);i.push(_t(t,t,!1,`Error adding ${t.username} as member to edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o),_t(t,s,!0,"none"===n?`Error adding user ${s.username} to edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`:`Error promoting user ${s.username} to admin in edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o))}else if(r)i.push(_t(t,t,!1,`Error adding ${t.username} as member to view group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o));else if("none"===n)throw new Error(`This item can not be shared by ${t.username} as they are not a member of the specified group ${o.groupId}.`);return i}(s,a,i,e,o,t)}).then(r=>{const[{revert:s}={promise:Promise.resolve({notAdded:[]}),revert:t=>Promise.resolve(t)}]=r;return Promise.all(r.map(({promise:t})=>t)).then(()=>Wt(t,e,n)).then(t=>s(t))})}return Wt(t)}).then(e=>{if(e.notSharedWith.length)throw Error(`Item ${t.id} could not be shared to group ${t.groupId}.`);return e})}async function Wt(t,n=!1,r=!1){const o=await t.authentication.getUsername(),i=t.owner||o;let a=`${s(t)}/content/items/${t.id}/share`;return(i===o||n&&!r)&&(a=`${s(t)}/content/users/${i}/items/${t.id}/share`),t.params={groups:t.groupId,confirmItemControl:t.confirmItemControl},e(a,t)}function _t(t,e,n,r,s){const o=e.groups||[],i=o.find(t=>t.id===s.groupId);if(t.orgId!==e.orgId)throw Error(`User ${e.username} is not a member of the same org as ${t.username}. Consequently they can not be added added to group ${s.groupId} nor can item ${s.id} be shared to the group.`);if(!i&&o.length>511)throw Error(`User ${e.username} already has 512 groups, and can not be added to group ${s.groupId}. Consequently item ${s.id} can not be shared to the group.`);let a,u;if(i)n&&"member"===i.userMembership.memberType?(a=yt({id:s.groupId,users:[e.username],newMemberType:"admin",authentication:s.authentication}).then(t=>{const e=t.results.reduce((t,e)=>(e.success||t.push(e.username),t),[]);return Promise.resolve({notAdded:e})}).catch(()=>({notAdded:[e.username]})),u=t=>yt({id:s.groupId,users:[e.username],newMemberType:"member",authentication:s.authentication}).then(()=>t).catch(()=>t)):(a=Promise.resolve({notAdded:[]}),u=t=>Promise.resolve(t));else{const t=n?"admins":"users";a=ot({id:s.groupId,[t]:[e.username],authentication:s.authentication}).then(t=>{if(t.errors&&t.errors.length)throw t.errors[0];return t}).catch(()=>({notAdded:[e.username]})),u=t=>ut({id:s.groupId,users:[e.username],authentication:s.authentication}).then(()=>t)}return{promise:a.then(t=>{if(t.notAdded.length)throw new Error(r);return t}),revert:u}}function Jt(t){return Yt(t).then(async n=>{if(!n)return Promise.resolve({itemId:t.id,shortcut:!0,notUnsharedFrom:[]});const{owner:r}=t,o=await t.authentication.getUsername();return Promise.all([J(t),vt({username:o,authentication:t.authentication})]).then(([n,i])=>{const a=(r||o)===o,u="org_admin"===i.role&&!i.roleId;if(!a&&!u&&["admin","owner"].indexOf(n)<0)throw Error(`This item can not be unshared from group ${t.groupId} by ${o} as they not the item owner, an org admin, group admin or group owner.`);return async function(t){const n=await t.authentication.getUsername(),r=t.owner||n;let o=`${s(t)}/content/items/${t.id}/unshare`;r===n&&(o=`${s(t)}/content/users/${r}/items/${t.id}/unshare`);return t.params={groups:t.groupId},e(o,t)}(t)}).then(e=>{if(e.notUnsharedFrom.length)throw Error(`Item ${t.id} could not be unshared to group ${t.groupId}`);return e})})}function Vt(t,n,r){const s=`${r.portal}/portals/self/isServiceNameAvailable`;return e(s,{params:{name:t,type:n},httpMethod:"GET",authentication:r})}function Bt(t,e,n,r){let s=t;return r&&(s=`${t}_${r}`),Vt(s,e,n).then(o=>o.available?s:Bt(t,e,n,r+=1))}function Ht(t){return Kt(null,t)}function Kt(t,n){const r=t||"self",o=`${s(n)}/portals/${r}`,i=Object.assign({httpMethod:"GET"},n);return e(o,i)}function Lt(t,n){const r=t||"self",o=`${s(n)}/portals/${r}/settings`,i=Object.assign({httpMethod:"GET"},n);return e(o,i)}export{X as SearchQueryBuilder,Gt as acceptInvitation,ot as addGroupUsers,p as addItemData,et as addItemPart,l as addItemRelationship,g as addItemResource,a as bboxToString,rt as cancelItemUpload,nt as commitItemUpload,$ as createFolder,ht as createGroup,dt as createGroupNotification,y as createItem,b as createItemInFolder,Ot as createOrgNotification,Mt as declineInvitation,u as decorateThumbnail,o as determineOwner,Tt as determineUsername,_t as ensureMembership,w as exportItem,R as getGroup,k as getGroupCategorySchema,F as getGroupContent,D as getGroupUsers,I as getItem,T as getItemBaseUrl,v as getItemData,U as getItemGroups,S as getItemInfo,P as getItemMetadata,M as getItemParts,q as getItemResource,E as getItemResources,G as getItemStatus,Kt as getPortal,Lt as getPortalSettings,s as getPortalUrl,x as getRelatedItems,Ht as getSelf,z as getSharingUrl,Bt as getUniqueServiceName,vt as getUser,f as getUserContent,Ut as getUserInvitation,qt as getUserInvitations,J as getUserMembership,St as getUserNotifications,Rt as getUserProperties,xt as getUserTags,Et as getUserUrl,ct as inviteGroupUsers,i as isBBox,W as isItemOwner,Yt as isItemSharedWithGroup,_ as isOrgAdmin,Vt as isServiceNameAvailable,wt as joinGroup,jt as leaveGroup,d as moveItem,pt as protectGroup,C as protectItem,V as reassignItem,L as removeFolder,gt as removeGroup,ut as removeGroupUsers,B as removeItem,H as removeItemRelationship,K as removeItemResource,Q as removeItemThumbnail,Pt as removeNotification,O as scrubControlChars,Ct as searchCommunityUsers,$t as searchGroupContent,Y as searchGroupUsers,ft as searchGroups,tt as searchItems,At as searchUsers,Ft as setItemAccess,kt as setUserProperties,zt as shareItemWithGroup,lt as unprotectGroup,N as unprotectItem,Jt as unshareItemWithGroup,bt as updateGroup,c as updateItem,m as updateItemInfo,h as updateItemResource,Nt as updateUser,yt as updateUserMemberships};
|
|
7
7
|
//# sourceMappingURL=portal.esm.min.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-portal - v4.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.10.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2026 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Mar 05 2026 01:31:06 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) :
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-portal - v4.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.10.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2026 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Mar 05 2026 01:31:06 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,t){"use strict";function r(e={}){return e.portal?t.cleanUrl(e.portal):e.authentication&&"string"!=typeof e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function n(e){return e.owner?Promise.resolve(e.owner):e.item&&e.item.owner?Promise.resolve(e.item.owner):e.authentication&&e.authentication.getUsername?e.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function s(e){return Array.isArray(e)&&Array.isArray(e[0])&&Array.isArray(e[1])}function o(e){return e.join(",")}function i(e,t,r){if(!e)return e;let n=null;return"string"==typeof e.thumbnail&&(n=`${t}/content/items/${e.id}/info/${e.thumbnail}`,n&&"public"!==e.access&&r&&(n+=`?${r}`)),Object.assign(Object.assign({},e),n?{thumbnailUrl:n}:{})}function a(e){return n(e).then(n=>{const a=e.folderId?`${r(e)}/content/users/${n}/${e.folderId}/items/${e.item.id}/update`:`${r(e)}/content/users/${n}/items/${e.item.id}/update`;e.params=Object.assign(Object.assign({},e.params),e.item),e.params.extent&&s(e.params.extent)&&(e.params.extent=o(e.params.extent));const u=r(e),c=i(Object.assign(Object.assign({},e.item),{access:e.item.access}),u),m=e.params.thumbnailUrl;return"string"==typeof c.thumbnailUrl&&"string"==typeof m&&c.thumbnailUrl.split("?")[0]===m.split("?")[0]&&delete e.params.thumbnailUrl,t.request(a,e)})}function u(e){return e.multipart&&!e.filename?Promise.reject(new Error("The filename is required for a multipart request.")):n(e).then(n=>{const i=`${r(e)}/content/users/${n}`;let a=`${i}/addItem`;e.folderId&&(a=`${i}/${e.folderId}/addItem`),e.params=Object.assign(Object.assign({},e.params),e.item),e.params.extent&&s(e.params.extent)&&(e.params.extent=o(e.params.extent));const u=t.appendCustomParams(e,["owner","folderId","file","dataUrl","text","async","multipart","filename","overwrite"],{params:Object.assign({},e.params)});return t.request(a,u)})}const c=/[\x00-\x1F\x7F-\x9F\xA0]/g;function m(e){return e.replace(c,"")}const p=(e,t)=>`${"string"==typeof t?t:r(t)}/content/items/${e}`;function d(e,t){const{fileName:r="iteminfo.xml",readAs:n="text"}=t||{};return h(e,`/info/${r}`,n,Object.assign({httpMethod:"GET"},t))}function h(e,r,n,s){const o=`${p(e,s)}${r}`,i=Object.assign({params:{}},s),a=i.rawResponse;return i.rawResponse=!0,i.params.f=null,t.request(o,i).then(e=>a?e:"json"!==n?e[n]():e.text().then(e=>JSON.parse(m(e))))}function l(e,n){const s=`${r(n)}/community/groups/${e}`,o=Object.assign({httpMethod:"GET"},n);return t.request(s,o)}function g(e,t){const n=t||e.authentication.username,s=e.owner||n;return`${r(e)}/content/users/${encodeURIComponent(s)}/items/${e.id}/share`}function f(e,t){const r=t||e.authentication.username;return(e.owner||r)===r}function $(e){return e.authentication.getUser().then(e=>e&&"org_admin"===e.role&&!e.roleId)}function b(e){return l(e.groupId,e).then(e=>e.userMembership.memberType).catch(()=>"none")}class y{constructor(e=""){this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=e}match(...e){return this.termStack=this.termStack.concat(e),this}in(e){const r=`\`in(${e?`"${e}"`:""})\``;return this.hasRange||this.hasTerms?(e&&"*"!==e&&(this.q+=`${e}:`),this.commit()):(t.warn(`${r} was called with no call to \`match(...)\` or \`from(...)\`/\`to(...)\`. Your query was not modified.`),this)}startGroup(){return this.commit(),this.openGroups>0&&(this.q+=" "),this.openGroups++,this.q+="(",this}endGroup(){return this.openGroups<=0?(t.warn("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."),this):(this.commit(),this.openGroups--,this.q+=")",this)}and(){return this.addModifier("and")}or(){return this.addModifier("or")}not(){return this.addModifier("not")}from(e){return this.hasTerms?(t.warn('`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.'),this):(this.rangeStack[0]=e,this)}to(e){return this.hasTerms?(t.warn('`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.'),this):(this.rangeStack[1]=e,this)}boost(e){return this.commit(),this.q+=`^${e}`,this}toParam(){return this.commit(),this.cleanup(),this.q}clone(){return this.commit(),this.cleanup(),new y(this.q+"")}addModifier(e){return this.currentModifer?(t.warn(`You have called \`${this.currentModifer}()\` after \`${e}()\`. Your current query was not modified.`),this):(this.commit(),""===this.q&&"not"!==e?(t.warn(`You have called \`${e}()\` without calling another method to modify your query first. Try calling \`match()\` first.`),this):(this.currentModifer=e,this.q+=""===this.q?"":" ",this.q+=`${e.toUpperCase()} `,this))}hasWhiteSpace(e){return/\s/g.test(e)}formatTerm(e){return e instanceof Date?e.getTime():"string"==typeof e&&this.hasWhiteSpace(e)?`"${e}"`:e}commit(){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(e=>this.formatTerm(e)).join(" "),this.termStack=[]),this}get hasTerms(){return this.termStack.length>0}get hasRange(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]}cleanup(){if(this.openGroups>0)for(t.warn(`Automatically closing ${this.openGroups} group(s). You can use \`endGroup(...)\` to remove this warning.`);this.openGroups>0;)this.q+=")",this.openGroups--;const e=this.q;this.q=e.replace(/( AND ?| NOT ?| OR ?)*$/,""),e!==this.q&&t.warn("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")}}function I(e,n){let s,o;switch(s="string"==typeof e||e instanceof y?{httpMethod:"GET",params:{q:e}}:t.appendCustomParams(e,["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],{httpMethod:"GET"}),n){case"item":o="/search";break;case"group":o="/community/groups";break;case"groupContent":if("string"==typeof e||e instanceof y||!e.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));o=`/content/groups/${e.groupId}/search`;break;case"communityUser":o="/community/users";break;default:o="/portals/self/users/search"}const i=r(s)+o;return t.request(i,s).then(t=>(t.nextStart&&-1!==t.nextStart&&(t.nextPage=function(){let r;return"string"==typeof e||e instanceof y?r={q:e,start:t.nextStart}:(r=e,r.start=t.nextStart),I(r,n)}),t))}function w(e){return I(e,"item")}function q(e,t){if(0===e.length)return[];const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function j(e){const n=e.id,s=`${r(e)}/community/groups/${n}/addUsers`,o=Object.assign({},e,{admins:void 0,users:void 0}),i=[...O("users",e.users,o),...O("admins",e.admins,o)].map(e=>function(e,r){return t.request(e,r).catch(e=>({errors:[e]}))}(s,e));return Promise.all(i).then(v)}function O(e,t,r){if(!t||t.length<1)return[];return q(t,25).map(t=>function(e,t,r){return Object.assign({},r,{[e]:t,params:Object.assign(Object.assign({},r.params),{[e]:t})})}(e,t,r))}function v(e){const t=e.filter(e=>e.notAdded).reduce((e,t)=>e.concat(t.notAdded),[]),r=e.filter(e=>e.errors).reduce((e,t)=>e.concat(t.errors),[]),n={notAdded:t};return r.length>0&&(n.errors=r),n}function T(e){const{id:n,users:s}=e,o=`${r(e)}/community/groups/${n}/removeUsers`,i=q(s,25).map(r=>(r=>{const n=Object.assign(Object.assign({},e),{users:r,params:{users:r}});return t.request(o,n).catch(e=>({errors:[e]}))})(r));return Promise.all(i).then(e=>{const t=t=>e.filter(e=>e[t]).reduce((e,r)=>e.concat(r[t]),[]),r=t("errors"),n={notRemoved:t("notRemoved")};return r.length?Object.assign(Object.assign({},n),{errors:r}):n})}function U(e){const t=e.every(e=>e.success),r=e.reduce((e,t)=>e.concat(t.errors||[]),[]),n={success:t};return r.length>0&&(n.errors=r),n}function G(e){const n=`${r(e)}/community/groups/${e.id}/updateUsers`,s={authentication:e.authentication,params:{}};return"admin"===e.newMemberType?s.params.admins=e.users:s.params.users=e.users,t.request(n,s)}function x(e){const t=e.every(e=>e.success),r=e.reduce((e,t)=>e.concat(t.errors||[]),[]),n={success:t};return r.length>0&&(n.errors=r),n}async function P(e){var t;return e.username?encodeURIComponent(e.username):(null===(t=e.authentication)||void 0===t?void 0:t.username)?encodeURIComponent(e.authentication.username):e.authentication?e.authentication.getUsername().then(encodeURIComponent):void 0}async function S(e){let n,s={httpMethod:"GET"};if("string"==typeof e)n=`https://www.arcgis.com/sharing/rest/community/users/${e}`;else{const t=await P(e);n=`${r(e)}/community/users/${t}`,s=Object.assign(Object.assign({},e),s)}return t.request(n,s)}function C(e,r){return r.params=Object.assign({org:!1,everyone:!1},r.params),"private"===r.access&&(r.params.groups=" "),"org"===r.access&&(r.params.org=!0),"public"===r.access&&(r.params.account=!0,r.params.everyone=!0),t.request(e,r)}function E(e){return w({q:`id: ${e.id} AND group: ${e.groupId}`,start:1,num:10,sortField:"title",authentication:e.authentication,httpMethod:"POST"}).then(t=>{let r=!1;if(t.total>0)return r=t.results.some(t=>t.id===e.id),r})}async function M(e,n=!1,s=!1){const o=await e.authentication.getUsername(),i=e.owner||o;let a=`${r(e)}/content/items/${e.id}/share`;return(i===o||n&&!s)&&(a=`${r(e)}/content/users/${i}/items/${e.id}/share`),e.params={groups:e.groupId,confirmItemControl:e.confirmItemControl},t.request(a,e)}function R(e,t,r,n,s){const o=t.groups||[],i=o.find(e=>e.id===s.groupId);if(e.orgId!==t.orgId)throw Error(`User ${t.username} is not a member of the same org as ${e.username}. Consequently they can not be added added to group ${s.groupId} nor can item ${s.id} be shared to the group.`);if(!i&&o.length>511)throw Error(`User ${t.username} already has 512 groups, and can not be added to group ${s.groupId}. Consequently item ${s.id} can not be shared to the group.`);let a,u;if(i)r&&"member"===i.userMembership.memberType?(a=G({id:s.groupId,users:[t.username],newMemberType:"admin",authentication:s.authentication}).then(e=>{const t=e.results.reduce((e,t)=>(t.success||e.push(t.username),e),[]);return Promise.resolve({notAdded:t})}).catch(()=>({notAdded:[t.username]})),u=e=>G({id:s.groupId,users:[t.username],newMemberType:"member",authentication:s.authentication}).then(()=>e).catch(()=>e)):(a=Promise.resolve({notAdded:[]}),u=e=>Promise.resolve(e));else{const e=r?"admins":"users";a=j({id:s.groupId,[e]:[t.username],authentication:s.authentication}).then(e=>{if(e.errors&&e.errors.length)throw e.errors[0];return e}).catch(()=>({notAdded:[t.username]})),u=e=>T({id:s.groupId,users:[t.username],authentication:s.authentication}).then(()=>e)}return{promise:a.then(e=>{if(e.notAdded.length)throw new Error(n);return e}),revert:u}}function A(e,r,n){const s=`${n.portal}/portals/self/isServiceNameAvailable`;return t.request(s,{params:{name:e,type:r},httpMethod:"GET",authentication:n})}function N(e,n){const s=e||"self",o=`${r(n)}/portals/${s}`,i=Object.assign({httpMethod:"GET"},n);return t.request(o,i)}e.SearchQueryBuilder=y,e.acceptInvitation=async function(e){const n=await P(e),s=`${r(e)}/community/users/${n}/invitations/${e.invitationId}/accept`,o=Object.assign({},e);return t.request(s,o)},e.addGroupUsers=j,e.addItemData=function(e){const t=Object.assign({item:{id:e.id,text:e.text,file:e.file}},e);return delete t.id,delete t.data,a(t)},e.addItemPart=function(e){const s=e.partNum;return!Number.isInteger(s)||s<1||s>1e4?Promise.reject(new Error("The part number must be an integer between 1 to 10000, inclusive.")):n(e).then(n=>{const o=`${r(e)}/content/users/${n}/items/${e.id}/addPart?partNum=${s}`,i=t.appendCustomParams(e,["file"],{params:Object.assign({},e.params)});return t.request(o,i)})},e.addItemRelationship=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/addRelationship`,o=t.appendCustomParams(e,["originItemId","destinationItemId","relationshipType"],{params:Object.assign({},e.params)});return t.request(s,o)})},e.addItemResource=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/addResources`;return e.params=Object.assign({file:e.resource,fileName:e.name,resourcesPrefix:e.prefix,text:e.content,access:e.private?"private":"inherit"},e.params),t.request(s,e)})},e.bboxToString=o,e.cancelItemUpload=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/cancel`;return t.request(s,e)})},e.commitItemUpload=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/commit`,o=t.appendCustomParams(e,[],{params:Object.assign(Object.assign({},e.params),e.item)});return t.request(s,o)})},e.createFolder=function(e){return n(e).then(n=>{const s=`${`${r(e)}/content/users/${n}`}/createFolder`;return e.params=Object.assign({title:e.title},e.params),t.request(s,e)})},e.createGroup=function(e){const n=`${r(e)}/community/createGroup`;return e.params=Object.assign(Object.assign({},e.params),e.group),t.request(n,e)},e.createGroupNotification=function(e){const n=`${r(e)}/community/groups/${e.id}/createNotification`,s=Object.assign({params:Object.assign({subject:e.subject,message:e.message,users:e.users,notificationChannelType:e.notificationChannelType||"email",clientId:e.clientId,silentNotification:e.silentNotification,notifyAll:!e.users||0===e.users.length},e.params)},e);return t.request(n,s)},e.createItem=function(e){return u(Object.assign({folderId:null},e))},e.createItemInFolder=u,e.createOrgNotification=function(e){const n=`${r(e)}/portals/self/createNotification`,s=function(e){const t=q(e.users,e.batchSize||25);return t.map(t=>function(e,t){const r=Object.assign({},t);return r.params=Object.assign(Object.assign({},r.params),{users:e,subject:t.subject,message:t.message,notificationChannelType:r.notificationChannelType}),r}(t,e))}(e).map(e=>function(e,r){return t.request(e,r).catch(e=>({errors:[e]}))}(n,e));return Promise.all(s).then(x)},e.declineInvitation=async function(e){const n=await P(e),s=`${r(e)}/community/users/${n}/invitations/${e.invitationId}/decline`,o=Object.assign({},e);return t.request(s,o)},e.decorateThumbnail=i,e.determineOwner=n,e.determineUsername=P,e.ensureMembership=R,e.exportItem=e=>{const{authentication:s,id:o,title:i,exportFormat:a,exportParameters:u}=e;return n(e).then(t=>`${r(e)}/content/users/${t}/export`).then(e=>t.request(e,{httpMethod:"POST",authentication:s,params:{itemId:o,title:i,exportFormat:a,exportParameters:u}}))},e.getGroup=l,e.getGroupCategorySchema=function(e,n){const s=`${r(n)}/community/groups/${e}/categorySchema`,o=Object.assign({httpMethod:"GET"},n);return t.request(s,o)},e.getGroupContent=function(e,n){const s=`${r(n)}/content/groups/${e}`,o=Object.assign(Object.assign({httpMethod:"GET"},{params:{start:1,num:100}}),n);return n&&n.paging&&(o.params=Object.assign({},n.paging)),t.request(s,o)},e.getGroupUsers=function(e,n){const s=`${r(n)}/community/groups/${e}/users`,o=Object.assign({httpMethod:"GET"},n);return t.request(s,o)},e.getItem=function(e,n){const s=p(e,n),o=Object.assign({httpMethod:"GET"},n);return t.request(s,o).then(async e=>{const t=(null==n?void 0:n.portal)||r(n);let o;return(null==n?void 0:n.authentication)&&"string"!=typeof n.authentication&&"public"!==e.access&&(o=await n.authentication.getToken(s)),i(e,t,o)})},e.getItemBaseUrl=p,e.getItemData=function(e,r){const n=`${p(e,r)}/data`,s=Object.assign({httpMethod:"GET",params:{}},r);return s.file&&(s.params.f=null),t.request(n,s).catch(e=>{if(!RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i).test(e.message))throw e})},e.getItemGroups=function(e,r){const n=`${p(e,r)}/groups`;return t.request(n,r)},e.getItemInfo=d,e.getItemMetadata=function(e,t){return d(e,Object.assign(Object.assign({},t),{fileName:"metadata/metadata.xml"}))},e.getItemParts=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/parts`;return t.request(s,e)})},e.getItemResource=function(e,t){const r=t.readAs||"blob";return h(e,`/resources/${t.fileName}`,r,t)},e.getItemResources=function(e,r){const n=`${p(e,r)}/resources`,s=Object.assign({},r);return s.params=Object.assign({num:1e3},s.params),t.request(n,s)},e.getItemStatus=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/status`,o=t.appendCustomParams(e,["jobId","jobType"],{params:Object.assign({},e.params)});return t.request(s,o)})},e.getPortal=N,e.getPortalSettings=function(e,n){const s=e||"self",o=`${r(n)}/portals/${s}/settings`,i=Object.assign({httpMethod:"GET"},n);return t.request(o,i)},e.getPortalUrl=r,e.getRelatedItems=function(e){const r=`${p(e.id,e)}/relatedItems`,n=Object.assign({httpMethod:"GET",params:{direction:e.direction}},e);return"string"==typeof e.relationshipType?n.params.relationshipType=e.relationshipType:n.params.relationshipTypes=e.relationshipType,delete n.direction,delete n.relationshipType,t.request(r,n)},e.getSelf=function(e){return N(null,e)},e.getSharingUrl=g,e.getUniqueServiceName=function e(t,r,n,s){let o=t;return s&&(o=`${t}_${s}`),A(o,r,n).then(i=>i.available?o:e(t,r,n,s+=1))},e.getUser=S,e.getUserContent=e=>{const{folderId:s,start:o=1,num:i=10,authentication:a}=e,u=s?`/${s}`:"";return n(e).then(t=>`${r(e)}/content/users/${t}${u}`).then(e=>t.request(e,{httpMethod:"GET",authentication:a,params:{start:o,num:i}}))},e.getUserInvitation=async function(e){const n=await P(e),s=`${r(e)}/community/users/${n}/invitations/${e.invitationId}`;let o={httpMethod:"GET"};return o=Object.assign(Object.assign({},e),o),t.request(s,o)},e.getUserInvitations=async function(e){let n={httpMethod:"GET"};const s=await P(e),o=`${r(e)}/community/users/${s}/invitations`;return n=Object.assign(Object.assign({},e),n),t.request(o,n)},e.getUserMembership=b,e.getUserNotifications=async function(e){let n={httpMethod:"GET"};const s=await P(e),o=`${r(e)}/community/users/${s}/notifications`;return n=Object.assign(Object.assign({},e),n),t.request(o,n)},e.getUserProperties=async function(e,n){const s=`${r(n)}/community/users/${encodeURIComponent(e)}/properties`,o=await t.request(s,Object.assign({httpMethod:"GET"},n));return o.properties.mapViewer||(o.properties.mapViewer="modern"),o.properties},e.getUserTags=async function(e){const n=await P(e),s=`${r(e)}/community/users/${n}/tags`;return t.request(s,e)},e.getUserUrl=function(e){return`${r(e)}/community/users/${encodeURIComponent(e.username)}`},e.inviteGroupUsers=function(e){const n=e.id,s=`${r(e)}/community/groups/${n}/invite`,o=function(e){const t=q(e.users,25);return t.map(t=>function(e,t){const r=Object.assign({},t);return r.params=Object.assign(Object.assign({},r.params),{users:e,role:r.role,expiration:r.expiration}),r}(t,e))}(e).map(e=>function(e,r){return t.request(e,r).catch(e=>({errors:[e]}))}(s,e));return Promise.all(o).then(U)},e.isBBox=s,e.isItemOwner=f,e.isItemSharedWithGroup=E,e.isOrgAdmin=$,e.isServiceNameAvailable=A,e.joinGroup=function(e){const n=`${r(e)}/community/groups/${e.id}/join`;return t.request(n,e)},e.leaveGroup=function(e){const n=`${r(e)}/community/groups/${e.id}/leave`;return t.request(n,e)},e.moveItem=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.itemId}/move`;let o=e.folderId;return o||(o="/"),e.params=Object.assign({folder:o},e.params),t.request(s,e)})},e.protectGroup=function(e){const n=`${r(e)}/community/groups/${e.id}/protect`;return t.request(n,e)},e.protectItem=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/protect`;return t.request(s,e)})},e.reassignItem=function(e){return $(e).then(n=>{if(!n)throw Error(`Item ${e.id} can not be reassigned because current user is not an organization administrator.`);const s=`${r(e)}/content/users/${e.currentOwner}/items/${e.id}/reassign`,o={params:{targetUsername:e.targetUsername,targetFolderName:e.targetFolderName},authentication:e.authentication};return t.request(s,o)})},e.removeFolder=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${encodeURIComponent(n)}/${e.folderId}/delete`;return t.request(s,e)})},e.removeGroup=function(e){const n=`${r(e)}/community/groups/${e.id}/delete`,s=Object.assign({},e);return t.request(n,s)},e.removeGroupUsers=T,e.removeItem=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/delete`;return t.request(s,e)})},e.removeItemRelationship=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/deleteRelationship`,o=t.appendCustomParams(e,["originItemId","destinationItemId","relationshipType"],{params:Object.assign({},e.params)});return t.request(s,o)})},e.removeItemResource=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/removeResources`;return e.params=Object.assign(Object.assign({},e.params),{resource:e.resource}),void 0!==e.deleteAll&&(e.params.deleteAll=e.deleteAll),t.request(s,e)})},e.removeItemThumbnail=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/deleteThumbnail`;return t.request(s,e)})},e.removeNotification=async function(e){const n=await P(e),s=`${r(e)}/community/users/${n}/notifications/${e.id}/delete`;return t.request(s,e)},e.scrubControlChars=m,e.searchCommunityUsers=function(e){return I(e,"communityUser")},e.searchGroupContent=function(e){return I(e,"groupContent")},e.searchGroupUsers=function(e,n){const s=`${r(n)}/community/groups/${e}/userlist`,o=t.appendCustomParams(n||{},["name","num","start","sortField","sortOrder","joined","memberType"],{httpMethod:"GET"});return t.request(s,o)},e.searchGroups=function(e){return I(e,"group")},e.searchItems=w,e.searchUsers=function(e){return I(e,"user")},e.setItemAccess=async function(e){const t=await e.authentication.getUsername(),r=g(e,t);return f(e,t)?C(r,e):$(e).then(n=>{if(n)return C(r,e);throw Error(`This item can not be shared by ${t}. They are neither the item owner nor an organization admin.`)})},e.setUserProperties=async function(e,n,s){const o=`${r(s)}/community/users/${encodeURIComponent(e)}/setProperties`,i=Object.assign({httpMethod:"POST",params:{properties:n}},s);try{const e=await t.request(o,i);if(!e.success)throw new Error("Success was false");return e}catch(e){throw new Error(`Failed to set user properties: ${e.message}`)}},e.shareItemWithGroup=async function(e){return E(e).then(async t=>{if(t)return{itemId:e.id,shortcut:!0,notSharedWith:[]};const{owner:r,confirmItemControl:n}=e,s=await e.authentication.getUsername(),o=r||s;if(o!==s){let t=!1,r=!1;return Promise.all([S({username:s,authentication:e.authentication}),S({username:o,authentication:e.authentication}),b(e)]).then(([s,o,i])=>{const a=!!n;return t="org_admin"===s.role&&!s.roleId,r=s.orgId!==o.orgId,function(e,t,r,n,s,o){const i=[];if(o.groupId!==e.favGroupId)if(t){if(!n)throw Error(`This item can not be shared to shared editing group ${o.groupId} by ${e.username} as they not the item owner or org admin.`);i.push(R(e,e,!1,`Error adding ${e.username} as member to edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o),R(e,s,!0,"none"===r?`Error adding user ${s.username} to edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`:`Error promoting user ${s.username} to admin in edit group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o))}else if(n)i.push(R(e,e,!1,`Error adding ${e.username} as member to view group ${o.groupId}. Consequently item ${o.id} was not shared to the group.`,o));else if("none"===r)throw new Error(`This item can not be shared by ${e.username} as they are not a member of the specified group ${o.groupId}.`);return i}(s,a,i,t,o,e)}).then(n=>{const[{revert:s}={promise:Promise.resolve({notAdded:[]}),revert:e=>Promise.resolve(e)}]=n;return Promise.all(n.map(({promise:e})=>e)).then(()=>M(e,t,r)).then(e=>s(e))})}return M(e)}).then(t=>{if(t.notSharedWith.length)throw Error(`Item ${e.id} could not be shared to group ${e.groupId}.`);return t})},e.unprotectGroup=function(e){const n=`${r(e)}/community/groups/${e.id}/unprotect`;return t.request(n,e)},e.unprotectItem=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/unprotect`;return t.request(s,e)})},e.unshareItemWithGroup=function(e){return E(e).then(async n=>{if(!n)return Promise.resolve({itemId:e.id,shortcut:!0,notUnsharedFrom:[]});const{owner:s}=e,o=await e.authentication.getUsername();return Promise.all([b(e),S({username:o,authentication:e.authentication})]).then(([n,i])=>{const a=(s||o)===o,u="org_admin"===i.role&&!i.roleId;if(!a&&!u&&["admin","owner"].indexOf(n)<0)throw Error(`This item can not be unshared from group ${e.groupId} by ${o} as they not the item owner, an org admin, group admin or group owner.`);return async function(e){const n=await e.authentication.getUsername(),s=e.owner||n;let o=`${r(e)}/content/items/${e.id}/unshare`;s===n&&(o=`${r(e)}/content/users/${s}/items/${e.id}/unshare`);return e.params={groups:e.groupId},t.request(o,e)}(e)}).then(t=>{if(t.notUnsharedFrom.length)throw Error(`Item ${e.id} could not be unshared to group ${e.groupId}`);return t})})},e.updateGroup=function(e){const n=`${r(e)}/community/groups/${e.group.id}/update`;return e.params=Object.assign(Object.assign({},e.params),e.group),t.request(n,e)},e.updateItem=a,e.updateItemInfo=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/updateinfo`;return e.params=Object.assign({folderName:e.folderName,file:e.file},e.params),t.request(s,e)})},e.updateItemResource=function(e){return n(e).then(n=>{const s=`${r(e)}/content/users/${n}/items/${e.id}/updateResources`;return e.params=Object.assign({file:e.resource,fileName:e.name,resourcesPrefix:e.prefix,text:e.content},e.params),void 0!==e.private&&(e.params.access=e.private?"private":"inherit"),t.request(s,e)})},e.updateUser=async function(e){const n=e.user.username||await e.authentication.getUsername(),s=`${r(e)}/community/users/${encodeURIComponent(n)}/update`;return e.params=Object.assign(Object.assign({},e.user),e.params),delete e.user,t.request(s,e)},e.updateUserMemberships=G});
|
|
7
7
|
//# sourceMappingURL=portal.umd.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/arcgis-rest-portal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@esri/arcgis-rest-request": "^4.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@esri/arcgis-rest-request": "^4.
|
|
53
|
+
"@esri/arcgis-rest-request": "^4.10.0"
|
|
54
54
|
},
|
|
55
55
|
"contributors": [
|
|
56
56
|
"Dave Bouwman <dbouwman@esri.com> (http://blog.davebouwman.com/)"
|