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

Ignore any information in NestJS that is not included in the data transfer object

In my NestJS controller, I have defined a route for updating locality information. The structure of the controller method is as follows: @Put('/:id') updateLocalityInfo( @Query('type') type: string, @Body() data: EditLocalityD ...

Is it necessary to 'type assert' the retrieved data in Axios if I have already specified the return type in the function declaration?

Consider the code snippet below: import axios from 'axios' async function fetchAPI<T>(path: string, data: any): Promise<T> { return (await axios.get(path, data)).data as T } async function getSomething(): Promise<SomeType> { ...

Is the client component not initializing the fetch operation?

On my page, there is a sidebar that displays items by fetching data successfully. However, when I click on one of the sidebar items to pass props to another component for fetching data, it doesn't fetch any data until I manually click the refresh butt ...

React Type Mutation response feedback is a valuable tool for receiving input

I am facing an issue with passing the mutation success response in my code. I have a file named change-email.tsx which calls a component file updateEmail.tsx containing a mutation function. The submit function is working fine, but I cannot figure out how t ...

Clear drop down selections after button is pressed

I am currently working with a grid in my template that contains multiple dropdowns, each row having its own. When I click a button, I gather the values from these dropdowns. However, upon clicking this button, I wish to reset all the dropdowns back to thei ...

Tips for bypassing the 'server-only' restrictions when executing commands from the command line

I have a NextJS application with a specific library that I want to ensure is only imported on the server side and not on the client side. To achieve this, I use import 'server-only'. However, I also need to use this file for a local script. The i ...

It's conceivable that the item is 'null'

I am encountering Typescript errors in my code that are related to parameters I am receiving from a previous screen. This is similar to the example shown in the React Navigation documentation found at https://reactnavigation.org/docs/params/. interface Pix ...

An effective approach to automatically close an Expansion Panel in an Angular Mat when another one is opened

I am attempting to implement functionality where one expansion panel closes when another is opened. By default, the multi attribute is set to "false" and it works perfectly when using multiple expansion panels within an accordion. However, in this case, I ...

Guide on transforming a tuple of random types into a nested type structure with the help of recursive conditional types

When I responded to the query on whether Typescript Interfaces can express co-occurrence constraints for properties, I shared the following code snippet: type None<T> = {[K in keyof T]?: never} type EitherOrBoth<T1, T2> = T1 & None<T2&g ...

Material UI React Autocomplete Component

I'm currently working on integrating an Autocomplete component using the Material UI library. However, I've encountered a challenge - I'm unsure of how to properly pass the value and onChange functions, especially since I have a custom Text ...

Commitments shatter amidst constructing a website

Utilizing promise and http.get to retrieve data from a JSON API in Wordpress. Once the data is retrieved, it should be displayed on a page... However, an error occurs when attempting to build the page due to the data not being available. What steps can ...

In Angular, dynamically updating ApexCharts series daily for real-time data visualization

I am currently working with apexchart and struggling to figure out how to properly utilize the updateseries feature. I have attempted to directly input the values but facing difficulties. HTML <apx-chart [chart]="{ type: ...

The operation failed with a TypeError because the object does not allow the addition of the newField property

I encountered an error that says: TypeError: Cannot add property newField, object is not extensible Whenever I try to add a new key or change a value, it doesn't work and I'm not sure what the issue is. dynamicFilter; public ionViewWillEnte ...

Establishing a pair of separate static directories within Nest

I am looking to utilize Nest in order to host two static applications. Essentially, I have a folder structure like this: /public /admin /main Within my Nest application, I currently have the following setup: app.useStaticAssets(join(__dirn ...

Angular Routing can be a powerful tool for managing multiple article posts in an efficient and organized way

I am in the process of building a website with Angular that features numerous articles. Whenever a user clicks on an article, I want it to navigate to a new URL using routing. To achieve this, I have created a new Article component and here is how my app- ...

Accurate TS declaration for combining fields into one mapping

I have a data structure called AccountDefinition which is structured like this: something: { type: 'client', parameters: { foo: 3 } }, other: { type: 'user', parameters: { bar: 3 } }, ... The TypeScript declaration ...

What methods can I employ to trace anonymous functions within the Angular framework?

I'm curious about how to keep track of anonymous functions for performance purposes. Is there a way to determine which piece of code an anonymous function is associated with? Here's an example of my code: <button (click)="startTimeout()&q ...

Is it possible to access the attributes of an interface in TypeScript without relying on external libraries?

Ensuring the properties of an interface align with an object that implements it is crucial for successful unit testing. If modifications are made to the interface, the unit test should fail if it is not updated with the new members. Although I attempted ...

conditional operator that compares values in router events

As I examine an object, links = { link1: 'page1', link2: 'page2', link3: 'page3', link4: 'page4', link5: 'page5', link6: 'page6' } I possess a function for retrieving t ...

Sharing information between Angular components

Having recently started using Angular, I'm facing an issue with passing an array to a different component that is not parent or child related. What I aim to achieve is: upon selecting rows from the first component table, a new view should open up disp ...