123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import {
- L
- } from "./chunk-P4UZNLD5.js";
- import {
- g
- } from "./chunk-RZFGRBD7.js";
- import "./chunk-PUSPZYFZ.js";
- import "./chunk-EN7YGJWG.js";
- import "./chunk-VBNMTM7L.js";
- import "./chunk-3D3QEPRE.js";
- import "./chunk-JFNNSBWL.js";
- import "./chunk-WNCU6BFU.js";
- import "./chunk-PIGRDDRG.js";
- import "./chunk-C43UE3Z5.js";
- import "./chunk-7XXXCK2A.js";
- import "./chunk-7ZIDBK7B.js";
- import "./chunk-65BYCSII.js";
- import "./chunk-WZQZRKNH.js";
- import "./chunk-LRDX4TO7.js";
- import "./chunk-6A4U74YA.js";
- import "./chunk-N2663GRX.js";
- import "./chunk-WEMIK25H.js";
- import "./chunk-7N4X6GF3.js";
- import "./chunk-JXW4QTJA.js";
- import "./chunk-UXF37FQ4.js";
- import "./chunk-ZOEK6QHJ.js";
- import "./chunk-XNLG7T2T.js";
- import "./chunk-IR4PV7VK.js";
- import "./chunk-2Z6LERTI.js";
- import "./chunk-OWVBLVP3.js";
- import "./chunk-AFZ7XSEW.js";
- import "./chunk-4NKD334K.js";
- import "./chunk-65K7LC56.js";
- import "./chunk-ATPLLI5W.js";
- import "./chunk-XH7RUGVZ.js";
- import "./chunk-TBBTRX4O.js";
- import "./chunk-YBSUITLL.js";
- import {
- j
- } from "./chunk-ALDCDSPV.js";
- import "./chunk-DT6EAZQ5.js";
- import "./chunk-HNOZUNJ4.js";
- import "./chunk-VNFRAYHO.js";
- import "./chunk-R5IG2D6H.js";
- import {
- nt
- } from "./chunk-VBRY5KJM.js";
- import "./chunk-PDKDCAAD.js";
- import "./chunk-ECW2QABR.js";
- import "./chunk-GCDJLKH4.js";
- import "./chunk-MRJEICT6.js";
- import "./chunk-Y3WMVFTW.js";
- import "./chunk-SAS7RONY.js";
- import "./chunk-WSRBH7BF.js";
- import "./chunk-IHXECKQQ.js";
- import "./chunk-ULGDPLM2.js";
- import {
- s3 as s
- } from "./chunk-EMJ4ZSM2.js";
- import {
- m
- } from "./chunk-IKP3YN53.js";
- import {
- r
- } from "./chunk-GZT4BVFP.js";
- import "./chunk-A5ICIBVI.js";
- // node_modules/@arcgis/core/layers/graphics/editingSupport.js
- function n(e) {
- return e && e.applyEdits != null;
- }
- async function l(e, t, a, i = {}) {
- let s2, d;
- const n2 = { edits: a, result: new Promise((e2, t2) => {
- s2 = e2, d = t2;
- }) };
- e.emit("apply-edits", n2);
- try {
- const { results: d2, edits: n3 } = await o(e, t, a, i), l2 = (e2) => e2.filter((e3) => !e3.error).map(m), u2 = { edits: n3, addedFeatures: l2(d2.addFeatureResults), updatedFeatures: l2(d2.updateFeatureResults), deletedFeatures: l2(d2.deleteFeatureResults), addedAttachments: l2(d2.addAttachmentResults), updatedAttachments: l2(d2.updateAttachmentResults), deletedAttachments: l2(d2.deleteAttachmentResults) };
- return d2.editedFeatureResults?.length && (u2.editedFeatures = d2.editedFeatureResults), (u2.addedFeatures.length || u2.updatedFeatures.length || u2.deletedFeatures.length || u2.addedAttachments.length || u2.updatedAttachments.length || u2.deletedAttachments.length) && e.emit("edits", u2), s2(u2), d2;
- } catch (l2) {
- throw d(l2), l2;
- }
- }
- async function o(e, t, r2, i) {
- if (await e.load(), !n(t))
- throw new s(`${e.type}-layer:no-editing-support`, "Layer source does not support applyEdits capability", { layer: e });
- if (!e.editingEnabled)
- throw new s(`${e.type}-layer:editing-disabled`, "Editing is disabled for layer", { layer: e });
- const { edits: s2, options: d } = await u(e, r2, i);
- return s2.addFeatures.length || s2.updateFeatures.length || s2.deleteFeatures.length || s2.addAttachments.length || s2.updateAttachments.length || s2.deleteAttachments.length ? { edits: s2, results: await t.applyEdits(s2, d) } : { edits: s2, results: { addFeatureResults: [], updateFeatureResults: [], deleteFeatureResults: [], addAttachmentResults: [], updateAttachmentResults: [], deleteAttachmentResults: [] } };
- }
- async function u(e, r2, i) {
- const s2 = r2 && (r2.addFeatures || r2.updateFeatures || r2.deleteFeatures), d = r2 && (r2.addAttachments || r2.updateAttachments || r2.deleteAttachments);
- if (!r2 || !s2 && !d)
- throw new s(`${e.type}-layer:missing-parameters`, "'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");
- if (!e.capabilities.data.isVersioned && i && i.gdbVersion)
- throw new s(`${e.type}-layer:invalid-parameter`, "'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");
- if (!e.capabilities.editing.supportsRollbackOnFailure && i && i.rollbackOnFailureEnabled)
- throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");
- if (!e.capabilities.editing.supportsGlobalId && i && i.globalIdUsed)
- throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");
- if (!e.capabilities.editing.supportsGlobalId && d)
- throw new s(`${e.type}-layer:invalid-parameter`, "'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");
- if ((!i || !i.globalIdUsed) && d)
- throw new s(`${e.type}-layer:invalid-parameter`, "When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");
- const n2 = { ...i };
- if (n2.rollbackOnFailureEnabled != null || e.capabilities.editing.supportsRollbackOnFailure || (n2.rollbackOnFailureEnabled = true), n2.rollbackOnFailureEnabled === false && n2.returnServiceEditsOption === "original-and-current-features")
- throw new s(`${e.type}-layer:invalid-parameter`, "'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");
- if (!e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference && n2.returnServiceEditsInSourceSR)
- throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");
- if (n2.returnServiceEditsInSourceSR && n2.returnServiceEditsOption !== "original-and-current-features")
- throw new s(`${e.type}-layer:invalid-parameter`, "'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");
- const l2 = { ...r2 };
- if (l2.addFeatures = r2 && j.isCollection(r2.addFeatures) ? r2.addFeatures.toArray() : l2.addFeatures || [], l2.updateFeatures = r2 && j.isCollection(r2.updateFeatures) ? r2.updateFeatures.toArray() : l2.updateFeatures || [], l2.deleteFeatures = r2 && j.isCollection(r2.deleteFeatures) ? r2.deleteFeatures.toArray() : l2.deleteFeatures || [], l2.addFeatures.length && !e.capabilities.operations.supportsAdd)
- throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support adding features.");
- if (l2.updateFeatures.length && !e.capabilities.operations.supportsUpdate)
- throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support updating features.");
- if (l2.deleteFeatures.length && !e.capabilities.operations.supportsDelete)
- throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support deleting features.");
- l2.addAttachments = l2.addAttachments || [], l2.updateAttachments = l2.updateAttachments || [], l2.deleteAttachments = l2.deleteAttachments || [], l2.addFeatures = l2.addFeatures.map(g2), l2.updateFeatures = l2.updateFeatures.map(g2);
- const o2 = i && i.globalIdUsed;
- l2.addFeatures.forEach((t) => c(t, e, o2)), l2.updateFeatures.forEach((t) => m2(t, e, o2)), l2.deleteFeatures.forEach((t) => h(t, e, o2)), l2.addAttachments.forEach((t) => y(t, e)), l2.updateAttachments.forEach((t) => y(t, e));
- return { edits: await f(l2), options: n2 };
- }
- function p(e, t, r2) {
- if (r2) {
- if ("attributes" in e && !e.attributes[t.globalIdField])
- throw new s(`${t.type}-layer:invalid-parameter`, "Feature should have 'globalId' when 'globalIdUsed' is true");
- if (!("attributes" in e) && !e.globalId)
- throw new s(`${t.type}-layer:invalid-parameter`, "'globalId' of the feature should be passed when 'globalIdUsed' is true");
- }
- if ("geometry" in e && r(e.geometry)) {
- if (e.geometry.hasZ && t.capabilities.data.supportsZ === false)
- throw new s(`${t.type}-layer:z-unsupported`, "Layer does not support z values while feature has z values.");
- if (e.geometry.hasM && t.capabilities.data.supportsM === false)
- throw new s(`${t.type}-layer:m-unsupported`, "Layer does not support m values while feature has m values.");
- }
- }
- function c(e, t, a) {
- p(e, t, a);
- }
- function h(e, t, a) {
- p(e, t, a);
- }
- function m2(e, t, r2) {
- if (p(e, t, r2), "geometry" in e && r(e.geometry) && !t.capabilities.editing.supportsGeometryUpdate)
- throw new s(`${t.type}-layer:unsupported-operation`, "Layer does not support geometry updates.");
- }
- function y(e, t) {
- const { feature: r2, attachment: i } = e;
- if (!r2 || "attributes" in r2 && !r2.attributes[t.globalIdField])
- throw new s(`${t.type}-layer:invalid-parameter`, "Attachment should have reference to a feature with 'globalId'");
- if (!("attributes" in r2) && !r2.globalId)
- throw new s(`${t.type}-layer:invalid-parameter`, "Attachment should have reference to 'globalId' of the parent feature");
- if (!i.globalId)
- throw new s(`${t.type}-layer:invalid-parameter`, "Attachment should have 'globalId'");
- if (!i.data && !i.uploadId)
- throw new s(`${t.type}-layer:invalid-parameter`, "Attachment should have 'data' or 'uploadId'");
- if (!(i.data instanceof File && !!i.data.name) && !i.name)
- throw new s(`${t.type}-layer:invalid-parameter`, "'name' is required when attachment is specified as Base64 encoded string using 'data'");
- if (!t.capabilities.editing.supportsUploadWithItemId && i.uploadId)
- throw new s(`${t.type}-layer:invalid-parameter`, "This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");
- if (typeof i.data == "string") {
- const e2 = nt(i.data);
- if (e2 && !e2.isBase64)
- throw new s(`${t.type}-layer:invalid-parameter`, "Attachment 'data' should be a Blob, File or Base64 encoded string");
- }
- }
- async function f(e) {
- const t = e.addFeatures, a = e.updateFeatures, r2 = t.concat(a).map((e2) => e2.geometry), i = await L(r2), s2 = t.length, n2 = a.length;
- return i.slice(0, s2).forEach((t2, a2) => e.addFeatures[a2].geometry = t2), i.slice(s2, s2 + n2).forEach((t2, a2) => e.updateFeatures[a2].geometry = t2), e;
- }
- function g2(t) {
- const a = new g();
- return t.attributes || (t.attributes = {}), a.geometry = t.geometry, a.attributes = t.attributes, a;
- }
- export {
- l as applyEdits
- };
- //# sourceMappingURL=editingSupport-KL4E3VVF.js.map
|