You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Objects can have derived properties, which are computed at runtime from other linked objects. Properties can be mapped directly, or an aggregation function (e.g. `collectList`, `avg`, `max`, etc.) can be used.
734
+
735
+
```typescript
736
+
const passenger =defineObject({
737
+
displayName: "Passenger",
738
+
pluralDisplayName: "Passengers",
739
+
apiName: "passenger",
740
+
primaryKeyPropertyApiName: "name",
741
+
titlePropertyApiName: "name",
742
+
properties: {
743
+
name: {
744
+
type: "string",
745
+
displayName: "Name",
746
+
},
747
+
flight_id: {
748
+
type: "string",
749
+
displayName: "Flight ID",
750
+
},
751
+
},
752
+
});
753
+
const flightToPassengers =defineLink({
754
+
apiName: "flightToPassengersLink",
755
+
one: {
756
+
// because the object has not been created yet,
757
+
// reference it by its fully qualified API name manually
758
+
object: "com.palantir.flight",
759
+
metadata: {
760
+
apiName: "flightFromPassengers",
761
+
},
762
+
},
763
+
toMany: {
764
+
object: passenger.apiName,
765
+
metadata: {
766
+
apiName: "passengersFromFlight",
767
+
},
768
+
},
769
+
manyForeignKeyProperty: "flight_id",
770
+
});
771
+
const flight =defineObject({
772
+
displayName: "Flight",
773
+
pluralDisplayName: "Flights",
774
+
apiName: "flight",
775
+
primaryKeyPropertyApiName: "id",
776
+
titlePropertyApiName: "id",
777
+
properties: {
778
+
id: {
779
+
type: "string",
780
+
displayName: "ID",
781
+
},
782
+
passengersList: {
783
+
type: "string",
784
+
array: true,
785
+
displayName: "Passengers",
786
+
},
787
+
},
788
+
datasources: [
789
+
// the dataset will back all of the properties not specified in other datasources
790
+
{ type: "dataset" },
791
+
{
792
+
type: "derived",
793
+
// multi-hop link traversals are also supported, just extend this list!
`Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`,
48
-
);
49
-
50
-
invariant(
51
-
typeIdPattern.test(linkDefinition.apiName),
52
-
`Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`,
53
-
);
39
+
// NOTE: we would normally do validation here, but because of circular dependencies
40
+
// we have to wait to validate until everything has been defined. The code for validation
`LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`,
`LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`,
0 commit comments