Skip to content

Commit

Permalink
Adding data constraints which are required for markings (#962)
Browse files Browse the repository at this point in the history
* Adding data constraints which are required for markings

* Add tests

* fix

---------

Co-authored-by: Alex Parson <[email protected]>
  • Loading branch information
aep000 and Alex Parson authored Nov 7, 2024
1 parent 0cd1603 commit b8a1a58
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-jokes-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/maker": minor
---

Add nullability to markings because of course they need to be nullable. This sucks in the data model, I should talk to the ontology team about this.
11 changes: 10 additions & 1 deletion packages/maker/src/api/defineOntology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ function convertSpt(
valueType,
}: SharedPropertyType,
): OntologyIrSharedPropertyType {
const dataConstraint:
| OntologyIrSharedPropertyType["dataConstraints"]
| undefined = (typeof type === "object" && type.type === "marking")
? {
propertyTypeConstraints: [],
nullability: undefined,
nullabilityV2: { noEmptyCollections: true, noNulls: true },
}
: undefined;
return {
apiName,
displayMetadata: {
Expand All @@ -181,7 +190,7 @@ function convertSpt(
: convertType(type),
aliases: [],
baseFormatter: undefined,
dataConstraints: undefined,
dataConstraints: dataConstraint,
gothamMapping: gothamMapping,
indexedForSearch: true,
provenance: undefined,
Expand Down
18 changes: 16 additions & 2 deletions packages/maker/src/api/overall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,14 @@ describe("Ontology Defining", () => {
"aliases": [],
"apiName": "com.palantir.foo",
"baseFormatter": undefined,
"dataConstraints": undefined,
"dataConstraints": {
"nullability": undefined,
"nullabilityV2": {
"noEmptyCollections": true,
"noNulls": true,
},
"propertyTypeConstraints": [],
},
"displayMetadata": {
"description": undefined,
"displayName": "foo",
Expand Down Expand Up @@ -1251,7 +1258,14 @@ describe("Ontology Defining", () => {
"aliases": [],
"apiName": "com.palantir.foo",
"baseFormatter": undefined,
"dataConstraints": undefined,
"dataConstraints": {
"nullability": undefined,
"nullabilityV2": {
"noEmptyCollections": true,
"noNulls": true,
},
"propertyTypeConstraints": [],
},
"displayMetadata": {
"description": undefined,
"displayName": "foo",
Expand Down

0 comments on commit b8a1a58

Please sign in to comment.