The Function-supported Operation is having trouble implementing a modification related to Geohash/Geopoint - the Object Type requires a String format

Summary: My function-based Action that tries to set a GeoPoint as a Geohash property is failing with an error suggesting it was anticipating a string.

I have an Object Type with a String property that has been designated as a Geohash in the property editor. The field in the underlying dataset consists of strings representing lat,long pairs, formatted as '12.123456,34.345678'.

Subsequently, I have a function-based action for modifying Objects of that Object type. It is currently configured to accept a string as input (using the regex

^-?[0-8]?\d\.\d+,-?1?[0-7]?\d\.\d+$
for Submission Criteria to ensure it adheres to the expected lat,long format). The Typescript function then assigns it to the Object Type as a GeoPoint like this:

@Edits(myObjectType)
@OntologyEditFunction()
public editMyObjectType(
    myObject: myObjectType,
    .....
    latlong?: string,
    .....
): void (

    .....

    let geopoint = latlong? GeoPoint.fromString(latlong) : undefined;

    .....

    const cols: Partial<myObjectType> = {
        .....
        coordinate: geopoint
        .....
    }

    Object.assign(myObject, cols);
}

This does not lead to any errors. When I hover over coordinate within the cols variable, the tooltip indicates that, based on the imported Object Type of which it is an example, it anticipates a value of type GeoPoint | undefined. Clearly, GeoPoint.fromString(latlong), where latlong represents a string, effectively stores a GeoPoint in geopoint (when not undefined).

Nevertheless, when attempting to submit the Action in the front end, I encounter the following error:

Failed to apply change.

Error: [Actions] PropertyTypeDoesNotMatch
Error ID: <a UUID>
Related values:

 - propertyTypeRid: Optional[ri.ontology.main.property.<another UUID>]
 - expectedType: Optional[ValueType{value: PrimitiveWrapper{value: STRING}}]
 - actualType: Optional[Value{value: GeohashWrapper{value: 12.123456,34.345678}}]

The value at the end, 12.123456,34.345678, consistently corresponds to whatever is entered into the latlong field under consideration.

It seems that the Object Type is foreseeing receipt of a string from the function, even though in the Typescript editor it anticipates a GeoPoint and generates an error if a string is attempted to be provided. Why is this discrepancy occurring?

Edit: Furthermore, the function operates smoothly during testing in the Live Preview of the Typescript editor, producing an Object with attributes such as coordinate: 12.123456,34.345678.

Edit 2: I understand now that a GeoPoint is not simply a lat,long string but rather a structure containing distinct lat and long values. This raises the question: why, in TypeScript, does it interpret the coordinate property of myObject as a GeoPoint initially? Why is it not permissible to assign it a string?

Answer №1

After testing your code on a basic object type with the properties id (string), name (string), and location (geohash), I can confirm that it runs smoothly without any issues. I have reviewed the type signatures in your code and believe there are no errors present. However, there are a few things I recommend double-checking:

  1. Ensure that the property type is indeed a geohash and that there are no indexing problems associated with that specific object type.
  2. Confirm that the Action form fields have the correct types specified.
  3. Try creating a no-code Action to see if it achieves the same result as the function-backed Action you are attempting to use.

Basically, my suspicion is that the issue may not lie within the code itself but elsewhere.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for validating observations with an observer confirmation?

Can you explain what the of() function creates in this scenario and how it operates? public onRemoving(tag): Observable<any> { const confirm = window.confirm('Do you really want to remove this tag?'); return Observable.of(tag).fil ...

Can someone guide me on configuring Material-UI DataGrid in React to have multiple headers with column span?

Is there a way to achieve multiple headers with column span in the Material-UI DataGrid component? view image example ...

Yep, implementing conditional logic with the `when` keyword and radio buttons

I seem to be encountering an issue with my implementation (probably something trivial). I am utilizing React Hook Form along with Yup and attempting to establish a condition based on the selection of a radio group. The scenario is as follows: if the first ...

Leveraging a Derived-Class Object Within the Base-Class to Invoke a Base-Class Function with Derived-Class Information

I have a situation where I need to access a method from a derived class in my base generic component that returns data specific to the derived class. The first issue I encountered is that I am unable to define the method as static in the abstract class! ...

Color key in square shape for graph legend

I am looking for legend colors in square shape, but I don't want them to appear as square boxes on the graph. https://i.stack.imgur.com/Of0AM.png The squares are also showing up on the graph, which is not what I want. https://i.stack.imgur.com/Az9G ...

A guide on incorporating a JavaScript plugin using Vue.use() into a TypeScript project equipped with typings

Currently, I am facing an issue while attempting to integrate Semantic-UI-Vue into my Vue project. Upon trying to execute Vue.use(SuiVue), the following error message is displayed: Argument of type 'typeof import("semantic-ui-vue")' is not ass ...

Mastering Angular Apollo Error Resolution Methods

Hey everyone, I'm facing a problem with apollo-angular and apollo-link-error that I just can't seem to figure out. I've experimented with different approaches but have had no luck catching errors on the client-side of my angular web app. Bel ...

Utilizing TypeScript to reference keys from one interface within another interface

I have two different interfaces with optional keys, Obj1 and Obj2, each having unique values: interface Obj1 { a?: string b?: string c?: number } interface Obj2 { a: boolean b: string c: number } In my scenario, Obj1 is used as an argument ...

The Angular 5 keyup event is being triggered twice

My app is incredibly simple, just a basic hello world. To enhance its appearance, I incorporated bootstrap for the design and ng-bootstrap for the components. Within one of my TS files, you will find the following code: showMeTheKey(event: KeyboardEvent) ...

Error encountered: NextJs could not find the specified module, which includes Typescript and SCSS

I am in the process of migrating a Next.js application from .js to .ts and incorporating ScSS. The first error I encounter is during 'npm run dev'. However, when I try 'npm run build', different issues arise that do not seem related to ...

Determining the Clicked Button in ReactJS

I need help with a simple coding requirement that involves detecting which button is clicked. Below is the code snippet: import React, { useState } from 'react' const App = () => { const data = [ ['Hotel 1A', ['A']], ...

Personalize your Stackblitz Angular project template

Currently, I am in the process of forking and customizing the Stackblitz Angular CLI project template which can be found at github.com/stackblitz/angular-cli-template. The main goal here is to adjust the TypeScript configuration by changing the target fro ...

Refresh a doughnut chart in real-time using NG2Charts

Currently, I am in the process of developing a macronutrient calculator as part of a project. The idea is to have a form where users can input values, and a corresponding doughnut chart will display with initial values set at 0. However, upon clicking the ...

Can the detectChanges() method in Angular cause any issues when used with the form control's valueChanges event?

Within my parent Component, I am working with a formGroup and updating its value using patchValue method. ngAfterViewInit() { this.sampleform.controls['a'].patchValue ...} I then pass this form to a child component in the parent component's ...

Using a targeted div as a child component in React

How can I specifically pass a div with the class name 'message-content' as props.children, without including all the divs above it? <div className="message"> <div className="message-title-info">A ...

Exploring the functionalities of TypeScript's mapKey and pick features

I am looking to convert the JavaScript code shown below into TypeScript, but I don't want to use loadish.js. let claimNames = _.filter<string>(_.keys(decodedToken), o => o.startsWith(ns) ); let claims = <any>( _.mapKeys(_ ...

Maintain synchrony of the state with swiftly unfolding occurrences

I developed a custom hook to keep track of a state variable that increments based on the number of socket events received. However, when I tested by sending 10 simultaneous events, the total value of the state variable ended up being 6, 7, or 8 instead of ...

Having trouble appending a new attribute to the Mongoose output

In my Nodejs server application, I am working with a userDetail document that contains all the relevant user information. Additionally, I have a login document that stores the time of the first login, which I need to incorporate into the userDetails result ...

What is the significance of having nodejs installed in order to run typescript?

What is the reason behind needing Node.js installed before installing TypeScript if we transpile typescript into JavaScript using tsc and run our code in the browser, not locally? ...

Can you explain the significance of { 0: T } in this particular type definition?

I stumbled upon this type declaration in my codebase which is meant for non-empty arrays: type NonEmptyArray<T> = T[] & { 0: T } and it functions as expected: const okay: NonEmptyArray<number> = [1, 2]; const alsoOkay: NonEmptyArray<n ...