UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.53 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{addTokenParameter as t}from"../../../kernel.js";import o from"../../../request.js";import{addProxy as e}from"../../../core/urlUtils.js";import{mapParameters as r}from"../../operations/urlUtils.js";import n from"../support/AttachmentInfo.js";function s(t){const o=t.toJSON();return o.attachmentTypes&&(o.attachmentTypes=o.attachmentTypes.join(",")),o.keywords&&(o.keywords=o.keywords.join(",")),o.globalIds&&(o.globalIds=o.globalIds.join(",")),o.objectIds&&(o.objectIds=o.objectIds.join(",")),o.size&&(o.size=o.size.join(",")),o.orderByFields&&(o.orderByFields=o.orderByFields.join(",")),o}function a(o,r){const s={};for(const a of r){const{parentObjectId:r,parentGlobalId:c,attachmentInfos:i}=a;for(const a of i){const{id:i}=a,d=e(t(`${o.path}/${r}/attachments/${i}`)),m=n.fromJSON(a);m.set({url:d,parentObjectId:r,parentGlobalId:c}),s[r]?s[r].push(m):s[r]=[m]}}return s}function c(t,e,n){let a={query:r({...t.query,f:"json",...s(e)})};return n&&(a={...n,...a,query:{...n.query,...a.query}}),o(t.path+"/queryAttachments",a).then((t=>t.data.attachmentGroups))}async function i(t,e,r){const{objectIds:n}=e,s=[];for(const a of n)s.push(o(t.path+"/"+a+"/attachments",r));return Promise.all(s).then((t=>n.map(((o,e)=>({parentObjectId:o,attachmentInfos:t[e].data.attachmentInfos})))))}export{c as executeAttachmentQuery,i as fetchAttachments,a as processAttachmentQueryResult};