Hello! Apologies for the delay in response -
Structs are supported in TSv2 Functions - we’ve updated the docs here: https://www.palantir.com/docs/foundry/functions/typescript-v2-ontology-edits/#edits-on-struct-properties
When creating a Function-Backed Action for a function that takes a struct input, an Actions struct parameter mapped to the Functions struct input will be automatically created.
For instance, creating a function-backed action for the following function:
interface Address {
street: string,
city: string,
state: string,
country: string,
zipcode: string,
}
function createPerson(client: Client, age: Integer, name: string, address: Address) {
...
}
will generate a struct parameter in the action type that maps directly to the address function input.
The following would be an example of a function that edits an object type struct property:
import { Person } from "@osdk/generated";
import { createEditBatch, Edits, EditBatch } from "@osdk/functions"
import { Integer } from "@osdk/functions";
import { Client } from "@osdk/client";
type CreatePersonEdit = Edits.Object<Person>;
interface Address {
street: string,
city: string,
state: string,
country: string,
zipcode: string,
}
function createPerson(
client: Client, age: Integer, name: string, address: Address
): CreatePersonEdit[] {
let editBatch: EditBatch<CreatePersonEdit> = createEditBatch<CreatePersonEdit>(client);
editBatch.create(Person, {name: name, age: age, address: address});
return editBatch.getEdits();
}
export default createPerson;
The struct value submitted as the value for the address struct property can also be constructed within the function - it just needs to be a typescript interface value that contains the field names that correspond to the struct field API names of the ontology struct property. Assuming the address struct property has the struct field with the API names street, city, state, country, zipcode, the following example would also work:
function createPerson(
client: Client, age: Integer, name: string, street: string, city: string
): CreatePersonEdit[] {
let editBatch: EditBatch<CreatePersonEdit> = createEditBatch<CreatePersonEdit>(client);
let address = {
street: street,
city: city,
state: "NY",
country: "USA",
zipcode: "12345"
};
editBatch.create(Person, {name: name, age: age, address: address});
return editBatch.getEdits();
}