@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.72 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import e from"../../../core/Error.js";import t from"../../../geometry/Geometry.js";import{geometryToWasm as n}from"./queryToWasmEncodedFactories.js";import{EsriFieldTypes as i,EsriGeometryTypes as r,EsriGraphPropertyRole as a,NamedObjectTypes as o}from"./WasmDataModelWrapperInterfaces.js";function s(t,n){if(!t.typeName)throw new e("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits");if(!("originId"in t)){const e=new n.EntityValue;e.deleteLater(),e.type_name=t.typeName;for(const[i,r]of Object.entries(t.properties))e.set_key_value(i,w(r,n));return t.id&&e.set_id(t.id),e}if("originId"in t&&"destinationId"in t){const e=new n.RelationshipValue;e.deleteLater(),e.type_name=t.typeName;for(const[i,r]of Object.entries(t.properties))e.set_key_value(i,w(r,n));return t.id&&e.set_id(t.id),t.originId&&t.destinationId&&e.set_related_entity_ids(t.originId,t.destinationId),e}throw new e("knowledge-graph:applyEdits-encoding-failure","Could not determine the type of a named graph object passed to the encoder")}function l(e){return{xy_resolution:e.xyResolution,x_false_origin:e.xFalseOrigin,y_false_origin:e.yFalseOrigin,z_resolution:e.zResolution,z_false_origin:e.zFalseOrigin,m_resolution:e.mResolution,m_false_origin:e.mFalseOrigin}}function d(e,t){const n=new t.EntityType;return n.deleteLater(),g(e,t,n)}function u(e,t){const n=new t.RelationshipType;n.deleteLater();for(const i of e.endPoints){const e=new t.EndPoint;e.deleteLater(),e.origin_entity_type=i.originEntityType,e.dest_entity_type=i.destinationEntityType,n.add_end_point(e)}return g(e,t,n)}function p(e,t){const n=new t.EntityType;return n.deleteLater(),h(e,n)}function y(e,t){const n=new t.RelationshipType;return n.deleteLater(),h(e,n)}function f(e,t){const n=new t.GraphProperty;return n.deleteLater(),n.name=e.name,n.alias=e.alias??"",n.field_type={value:i[e.fieldType]},n.geometry_type={value:e.geometryType?r[e.geometryType]:r.esriGeometryNull},n.has_m=e.hasM??!1,n.has_z=e.hasZ??!1,n.nullable=e.nullable??!1,n.editable=e.editable,n.required=e.required,n.default_visibility=e.defaultVisibility,n.system_maintained=e.systemMaintained??!1,n.role={value:a[e.role]},n.default_value=w(e.defaultValue,t),n}function c(e,t){const n=new t.GraphProperty;return n.deleteLater(),e.hasOwnProperty("alias")&&(n.alias=e.alias),e.hasOwnProperty("editable")&&(n.editable=e.editable),e.hasOwnProperty("required")&&(n.required=e.required),e.hasOwnProperty("defaultVisibility")&&(n.default_visibility=e.defaultVisibility),e.hasOwnProperty("defaultValue")&&(n.default_value=w(e.defaultValue,t)),n}function m(e,t){const n=new t.SearchIndexProperties;n.deleteLater();for(const i of e.propertyNames)n.add_search_property_name(i);return n}function _(e,t){const n=new t.FieldIndex;n.deleteLater(),n.name=e.name,n.unique=e.unique,n.ascending=e.ascending,n.description=e.description??"";for(const i of e.fieldNames)n.add_field(i);return n}function g(e,t,n){n.name=e.name,n.alias=e.alias??"",n.role={value:o[e.role]},n.strict=e.strict;for(const i of e.properties){const e=f(i,t);n.add_property(e)}return n}function h(e,t){return e.hasOwnProperty("alias")&&(t.alias=e.alias),t}function w(e,i){return null==e?null:"object"!=typeof e||e instanceof Date?e:e instanceof t?n(e,i):null}export{d as entityTypeToWasm,_ as fieldIndexToWasm,f as graphPropertyToWasm,l as inputQuantizationParametersToWasmFormat,s as namedObjectToWasm,u as relationshipTypeToWasm,p as updateEntityTypeToWasm,c as updateGraphPropertyToWasm,y as updateRelationshipTypeToWasm,m as updateSearchPropertiesToWasm};