@esri/arcgis-rest-portal 4.6.1 → 4.6.2-alpha.1
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.6.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.6.1 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Mon May 12 2025 21:29:23 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.6.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.6.1 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Mon May 12 2025 21:29:23 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){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`;return t.params=Object.assign(Object.assign({},t.params),t.item),t.params.extent&&i(t.params.extent)&&(t.params.extent=a(t.params.extent)),e(r,t)}))}function c(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 m(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 h(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 d(t){const e=Object.assign({item:{id:t.id,text:t.text,file:t.file}},t);return delete e.id,delete e.data,u(e)}function p(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 l(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 g=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 f(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 $(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 b(t){return $(Object.assign({folderId:null},t))}const y=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}})))},w=/[\x00-\x1F\x7F-\x9F\xA0]/g;function j(t){return t.replace(w,"")}function O(t,n){const r=I(t,n),s=Object.assign({httpMethod:"GET"},n);return e(r,s)}const I=(t,e)=>`${"string"==typeof e?e:s(e)}/content/items/${t}`;function T(t,n){const r=`${I(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 v(t){const n=`${I(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 x(t,n){const r=`${I(t,n)}/resources`,s=Object.assign({},n);return s.params=Object.assign({num:1e3},s.params),e(r,s)}function E(t,e){const n=e.readAs||"blob";return P(t,`/resources/${e.fileName}`,n,e)}function q(t,n){const r=`${I(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 U(t,e){const{fileName:n="iteminfo.xml",readAs:r="text"}=e||{};return P(t,`/info/${n}`,r,Object.assign({httpMethod:"GET"},e))}function S(t,e){return U(t,Object.assign(Object.assign({},e),{fileName:"metadata/metadata.xml"}))}function P(t,n,r,s){const o=`${I(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(j(t))))))}function A(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/protect`;return e(r,t)}))}function C(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/unprotect`;return e(r,t)}))}function N(t,n){const r=`${s(n)}/community/groups/${t}`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function R(t,n){const r=`${s(n)}/community/groups/${t}/categorySchema`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function k(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 F(t,n){const r=`${s(n)}/community/groups/${t}/users`,o=Object.assign({httpMethod:"GET"},n);return e(r,o)}function D(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 Y(t,e){const n=e||t.authentication.username,r=t.owner||n;return`${s(t)}/content/users/${encodeURIComponent(r)}/items/${t.id}/share`}function z(t,e){const n=e||t.authentication.username;return(t.owner||n)===n}function W(t){return t.authentication.getUser().then((t=>t&&"org_admin"===t.role&&!t.roleId))}function _(t){return N(t.groupId,t).then((t=>t.userMembership.memberType)).catch((()=>"none"))}function J(t){return W(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 V(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/delete`;return e(r,t)}))}function B(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 H(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 K(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${encodeURIComponent(n)}/${t.folderId}/delete`;return e(r,t)}))}function L(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/deleteThumbnail`;return e(r,t)}))}class Q{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 Q(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 X(t,r){let o,i;switch(o="string"==typeof t||t instanceof Q?{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 Q||!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 Q?n={q:t,start:e.nextStart}:(n=t,n.start=e.nextStart),X(n,r)}),e)))}function Z(t){return X(t,"item")}function tt(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 et(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 nt(t){return o(t).then((n=>{const r=`${s(t)}/content/users/${n}/items/${t.id}/cancel`;return e(r,t)}))}function rt(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 st(t){const n=t.id,r=`${s(t)}/community/groups/${n}/addUsers`,o=Object.assign({},t,{admins:void 0,users:void 0}),i=[...ot("users",t.users,o),...ot("admins",t.admins,o)].map((t=>function(t,n){return e(t,n).catch((t=>({errors:[t]})))}(r,t)));return Promise.all(i).then(it)}function ot(t,e,n){if(!e||e.length<1)return[];return rt(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 it(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 at(t){const{id:n,users:r}=t,o=`${s(t)}/community/groups/${n}/removeUsers`,i=rt(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 ut(t){const n=t.id,r=`${s(t)}/community/groups/${n}/invite`,o=function(t){const e=rt(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(ct)}function ct(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 mt(t){const n=`${s(t)}/community/createGroup`;return t.params=Object.assign(Object.assign({},t.params),t.group),e(n,t)}function ht(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 dt(t){const n=`${s(t)}/community/groups/${t.id}/protect`;return e(n,t)}function pt(t){const n=`${s(t)}/community/groups/${t.id}/unprotect`;return e(n,t)}function lt(t){const n=`${s(t)}/community/groups/${t.id}/delete`,r=Object.assign({},t);return e(n,r)}function gt(t){return X(t,"group")}function ft(t){return X(t,"groupContent")}function $t(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 bt(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 yt(t){const n=`${s(t)}/community/groups/${t.id}/join`;return e(n,t)}function wt(t){const n=`${s(t)}/community/groups/${t.id}/leave`;return e(n,t)}function jt(t){const n=`${s(t)}/portals/self/createNotification`,r=function(t){const e=rt(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(Ot)}function Ot(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 It(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 Tt(t){let n,r={httpMethod:"GET"};if("string"==typeof t)n=`https://www.arcgis.com/sharing/rest/community/users/${t}`;else{const e=await It(t);n=`${s(t)}/community/users/${e}`,r=Object.assign(Object.assign({},t),r)}return e(n,r)}async function vt(t){const n=await It(t),r=`${s(t)}/community/users/${n}/tags`;return e(r,t)}function xt(t){return`${s(t)}/community/users/${encodeURIComponent(t.username)}`}async function Et(t){let n={httpMethod:"GET"};const r=await It(t),o=`${s(t)}/community/users/${r}/invitations`;return n=Object.assign(Object.assign({},t),n),e(o,n)}async function qt(t){const n=await It(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 It(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 It(t),r=`${s(t)}/community/users/${n}/invitations/${t.invitationId}/decline`,o=Object.assign({},t);return e(r,o)}async function Ut(t){let n={httpMethod:"GET"};const r=await It(t),o=`${s(t)}/community/users/${r}/notifications`;return n=Object.assign(Object.assign({},t),n),e(o,n)}async function St(t){const n=await It(t),r=`${s(t)}/community/users/${n}/notifications/${t.id}/delete`;return e(r,t)}function Pt(t){return X(t,"user")}function At(t){return X(t,"communityUser")}async function Ct(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 Nt(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 Rt(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 kt(t){const e=await t.authentication.getUsername(),n=Y(t,e);return z(t,e)?Ft(n,t):W(t).then((r=>{if(r)return Ft(n,t);throw Error(`This item can not be shared by ${e}. They are neither the item owner nor an organization admin.`)}))}function Ft(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 Dt(t){return Z({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 Yt(t){return Dt(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([Tt({username:s,authentication:t.authentication}),Tt({username:o,authentication:t.authentication}),_(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(Wt(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),Wt(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(Wt(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((()=>zt(t,e,n))).then((t=>s(t)))}))}return zt(t)})).then((e=>{if(e.notSharedWith.length)throw Error(`Item ${t.id} could not be shared to group ${t.groupId}.`);return e}))}async function zt(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 Wt(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=bt({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=>bt({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=st({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=>at({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 _t(t){return Dt(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([_(t),Tt({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 Jt(t,n,r){const s=`${r.portal}/portals/self/isServiceNameAvailable`;return e(s,{params:{name:t,type:n},httpMethod:"GET",authentication:r})}function Vt(t,e,n,r){let s=t;return r&&(s=`${t}_${r}`),Jt(s,e,n).then((o=>o.available?s:Vt(t,e,n,r+=1)))}function Bt(t){return Ht(null,t)}function Ht(t,n){const r=t||"self",o=`${s(n)}/portals/${r}`,i=Object.assign({httpMethod:"GET"},n);return e(o,i)}function Kt(t,n){const r=t||"self",o=`${s(n)}/portals/${r}/settings`,i=Object.assign({httpMethod:"GET"},n);return e(o,i)}export{Q as SearchQueryBuilder,Gt as acceptInvitation,st as addGroupUsers,d as addItemData,tt as addItemPart,p as addItemRelationship,l as addItemResource,a as bboxToString,nt as cancelItemUpload,et as commitItemUpload,f as createFolder,mt as createGroup,ht as createGroupNotification,b as createItem,$ as createItemInFolder,jt as createOrgNotification,Mt as declineInvitation,o as determineOwner,It as determineUsername,Wt as ensureMembership,y as exportItem,N as getGroup,R as getGroupCategorySchema,k as getGroupContent,F as getGroupUsers,O as getItem,I as getItemBaseUrl,T as getItemData,q as getItemGroups,U as getItemInfo,S as getItemMetadata,M as getItemParts,E as getItemResource,x as getItemResources,G as getItemStatus,Ht as getPortal,Kt as getPortalSettings,s as getPortalUrl,v as getRelatedItems,Bt as getSelf,Y as getSharingUrl,Vt as getUniqueServiceName,Tt as getUser,g as getUserContent,qt as getUserInvitation,Et as getUserInvitations,_ as getUserMembership,Ut as getUserNotifications,Nt as getUserProperties,vt as getUserTags,xt as getUserUrl,ut as inviteGroupUsers,i as isBBox,z as isItemOwner,Dt as isItemSharedWithGroup,W as isOrgAdmin,Jt as isServiceNameAvailable,yt as joinGroup,wt as leaveGroup,h as moveItem,dt as protectGroup,A as protectItem,J as reassignItem,K as removeFolder,lt as removeGroup,at as removeGroupUsers,V as removeItem,B as removeItemRelationship,H as removeItemResource,L as removeItemThumbnail,St as removeNotification,j as scrubControlChars,At as searchCommunityUsers,ft as searchGroupContent,D as searchGroupUsers,gt as searchGroups,Z as searchItems,Pt as searchUsers,kt as setItemAccess,Rt as setUserProperties,Yt as shareItemWithGroup,pt as unprotectGroup,C as unprotectItem,_t as unshareItemWithGroup,$t as updateGroup,u as updateItem,c as updateItemInfo,m as updateItemResource,Ct as updateUser,bt as updateUserMemberships};
|
|
7
7
|
//# sourceMappingURL=portal.esm.min.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-portal - v4.6.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.6.1 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Mon May 12 2025 21:29:23 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.6.
|
|
2
|
+
* @esri/arcgis-rest-portal - v4.6.1 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Mon May 12 2025 21:29:23 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){return n(e).then((n=>{const i=e.folderId?`${r(e)}/content/users/${n}/${e.folderId}/items/${e.item.id}/update`:`${r(e)}/content/users/${n}/items/${e.item.id}/update`;return e.params=Object.assign(Object.assign({},e.params),e.item),e.params.extent&&s(e.params.extent)&&(e.params.extent=o(e.params.extent)),t.request(i,e)}))}function a(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 u=/[\x00-\x1F\x7F-\x9F\xA0]/g;function c(e){return e.replace(u,"")}const m=(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 p(e,`/info/${r}`,n,Object.assign({httpMethod:"GET"},t))}function p(e,r,n,s){const o=`${m(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(c(e))))))}function h(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 l(e,t){const r=t||e.authentication.username;return(e.owner||r)===r}function f(e){return e.authentication.getUser().then((e=>e&&"org_admin"===e.role&&!e.roleId))}function $(e){return h(e.groupId,e).then((e=>e.userMembership.memberType)).catch((()=>"none"))}class b{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 b(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 y(e,n){let s,o;switch(s="string"==typeof e||e instanceof b?{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 b||!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 b?r={q:e,start:t.nextStart}:(r=e,r.start=t.nextStart),y(r,n)}),t)))}function I(e){return y(e,"item")}function w(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 q(e){const n=e.id,s=`${r(e)}/community/groups/${n}/addUsers`,o=Object.assign({},e,{admins:void 0,users:void 0}),i=[...j("users",e.users,o),...j("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(O)}function j(e,t,r){if(!t||t.length<1)return[];return w(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 O(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 v(e){const{id:n,users:s}=e,o=`${r(e)}/community/groups/${n}/removeUsers`,i=w(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 T(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 U(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 G(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 x(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 P(e){let n,s={httpMethod:"GET"};if("string"==typeof e)n=`https://www.arcgis.com/sharing/rest/community/users/${e}`;else{const t=await x(e);n=`${r(e)}/community/users/${t}`,s=Object.assign(Object.assign({},e),s)}return t.request(n,s)}function S(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 C(e){return I({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 E(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 M(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=U({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=>U({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=q({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=>v({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 R(e,r,n){const s=`${n.portal}/portals/self/isServiceNameAvailable`;return t.request(s,{params:{name:e,type:r},httpMethod:"GET",authentication:n})}function A(e,n){const s=e||"self",o=`${r(n)}/portals/${s}`,i=Object.assign({httpMethod:"GET"},n);return t.request(o,i)}e.SearchQueryBuilder=b,e.acceptInvitation=async function(e){const n=await x(e),s=`${r(e)}/community/users/${n}/invitations/${e.invitationId}/accept`,o=Object.assign({},e);return t.request(s,o)},e.addGroupUsers=q,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,i(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 a(Object.assign({folderId:null},e))},e.createItemInFolder=a,e.createOrgNotification=function(e){const n=`${r(e)}/portals/self/createNotification`,s=function(e){const t=w(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(G)},e.declineInvitation=async function(e){const n=await x(e),s=`${r(e)}/community/users/${n}/invitations/${e.invitationId}/decline`,o=Object.assign({},e);return t.request(s,o)},e.determineOwner=n,e.determineUsername=x,e.ensureMembership=M,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=h,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,r){const n=m(e,r),s=Object.assign({httpMethod:"GET"},r);return t.request(n,s)},e.getItemBaseUrl=m,e.getItemData=function(e,r){const n=`${m(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=`${m(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 p(e,`/resources/${t.fileName}`,r,t)},e.getItemResources=function(e,r){const n=`${m(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=A,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=`${m(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 A(null,e)},e.getSharingUrl=g,e.getUniqueServiceName=function e(t,r,n,s){let o=t;return s&&(o=`${t}_${s}`),R(o,r,n).then((i=>i.available?o:e(t,r,n,s+=1)))},e.getUser=P,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 x(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 x(e),o=`${r(e)}/community/users/${s}/invitations`;return n=Object.assign(Object.assign({},e),n),t.request(o,n)},e.getUserMembership=$,e.getUserNotifications=async function(e){let n={httpMethod:"GET"};const s=await x(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 x(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=w(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(T)},e.isBBox=s,e.isItemOwner=l,e.isItemSharedWithGroup=C,e.isOrgAdmin=f,e.isServiceNameAvailable=R,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 f(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=v,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 x(e),s=`${r(e)}/community/users/${n}/notifications/${e.id}/delete`;return t.request(s,e)},e.scrubControlChars=c,e.searchCommunityUsers=function(e){return y(e,"communityUser")},e.searchGroupContent=function(e){return y(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 y(e,"group")},e.searchItems=I,e.searchUsers=function(e){return y(e,"user")},e.setItemAccess=async function(e){const t=await e.authentication.getUsername(),r=g(e,t);return l(e,t)?S(r,e):f(e).then((n=>{if(n)return S(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 C(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([P({username:s,authentication:e.authentication}),P({username:o,authentication:e.authentication}),$(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(M(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),M(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(M(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((()=>E(e,t,r))).then((e=>s(e)))}))}return E(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 C(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([$(e),P({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=i,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=U,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
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.6.1",
|
|
3
|
+
"version": "4.6.2-alpha.1",
|
|
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": [
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"tslib": "^2.3.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@esri/arcgis-rest-request": "
|
|
50
|
+
"@esri/arcgis-rest-request": "4.5.1-alpha.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@esri/arcgis-rest-request": "
|
|
53
|
+
"@esri/arcgis-rest-request": "4.5.1-alpha.1"
|
|
54
54
|
},
|
|
55
55
|
"contributors": [
|
|
56
56
|
"Dave Bouwman <dbouwman@esri.com> (http://blog.davebouwman.com/)"
|