@osdk/maker 0.9.0-beta.25 → 0.9.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/browser/api/defineImportSpt.js +4 -2
  3. package/build/browser/api/defineImportSpt.js.map +1 -1
  4. package/build/browser/api/defineObject.js +56 -80
  5. package/build/browser/api/defineObject.js.map +1 -1
  6. package/build/browser/api/defineOntology.js +106 -0
  7. package/build/browser/api/defineOntology.js.map +1 -1
  8. package/build/browser/api/defineSpt.js +1 -0
  9. package/build/browser/api/defineSpt.js.map +1 -1
  10. package/build/browser/api/overall.test.js +332 -0
  11. package/build/browser/api/overall.test.js.map +1 -1
  12. package/build/browser/api/types.js.map +1 -1
  13. package/build/browser/cli/main.js +1 -4
  14. package/build/browser/cli/main.js.map +1 -1
  15. package/build/browser/index.js +1 -0
  16. package/build/browser/index.js.map +1 -1
  17. package/build/cjs/index.cjs +158 -3
  18. package/build/cjs/index.cjs.map +1 -1
  19. package/build/cjs/index.d.cts +40 -4
  20. package/build/esm/api/defineImportSpt.js +4 -2
  21. package/build/esm/api/defineImportSpt.js.map +1 -1
  22. package/build/esm/api/defineObject.js +56 -80
  23. package/build/esm/api/defineObject.js.map +1 -1
  24. package/build/esm/api/defineOntology.js +106 -0
  25. package/build/esm/api/defineOntology.js.map +1 -1
  26. package/build/esm/api/defineSpt.js +1 -0
  27. package/build/esm/api/defineSpt.js.map +1 -1
  28. package/build/esm/api/overall.test.js +332 -0
  29. package/build/esm/api/overall.test.js.map +1 -1
  30. package/build/esm/api/types.js.map +1 -1
  31. package/build/esm/cli/main.js +1 -4
  32. package/build/esm/cli/main.js.map +1 -1
  33. package/build/esm/index.js +1 -0
  34. package/build/esm/index.js.map +1 -1
  35. package/package.json +6 -6
  36. package/build/browser/api/defineLink.js +0 -38
  37. package/build/browser/api/defineLink.js.map +0 -1
  38. package/build/esm/api/defineLink.js +0 -38
  39. package/build/esm/api/defineLink.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @osdk/maker
2
2
 
3
+ ## 0.9.0-beta.26
4
+
5
+ ### Minor Changes
6
+
7
+ - 44e62f6: Updating fetch for auth and other packages.
8
+ - 94463b6: Support objects as code
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [7865cb6]
13
+ - Updated dependencies [9c4efe6]
14
+ - Updated dependencies [f19da8e]
15
+ - @osdk/api@2.1.0-beta.26
16
+
3
17
  ## 0.9.0-beta.25
4
18
 
5
19
  ### Patch Changes
@@ -34,12 +34,14 @@ export function importSharedPropertyType(opts) {
34
34
  !(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name includes upper case characters") : invariant(false) : void 0;
35
35
  return {
36
36
  apiName: packageName + "." + apiName,
37
- type: typeHint
37
+ type: typeHint,
38
+ nonNameSpacedApiName: apiName
38
39
  };
39
40
  }
40
41
  return {
41
42
  apiName: apiName,
42
- type: typeHint
43
+ type: typeHint,
44
+ nonNameSpacedApiName: apiName
43
45
  };
44
46
  }
45
47
  //# sourceMappingURL=defineImportSpt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineImportSpt.js","names":["invariant","ontologyDefinition","importSharedPropertyType","opts","apiName","packageName","typeHint","undefined","importedTypes","sharedPropertyTypes","push","endsWith","process","env","NODE_ENV","match","type"],"sources":["defineImportSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(\n opts: {\n apiName: string;\n packageName?: string;\n typeHint: PropertyTypeType;\n },\n): SharedPropertyType {\n const { apiName, packageName, typeHint } = opts;\n if (packageName !== undefined) {\n ontologyDefinition.importedTypes.sharedPropertyTypes.push({\n apiName,\n packageName,\n });\n invariant(\n !packageName.endsWith(\".\"),\n \"Package name format invalid ends with period\",\n );\n\n invariant(\n packageName.match(\"[A-Z]\") == null,\n \"Package name includes upper case characters\",\n );\n\n return { apiName: packageName + \".\" + apiName, type: typeHint };\n }\n return { apiName: apiName, type: typeHint };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AAGxD;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAIC,EACmB;EACpB,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,IAAI;EAC/C,IAAIE,WAAW,KAAKE,SAAS,EAAE;IAC7BN,kBAAkB,CAACO,aAAa,CAACC,mBAAmB,CAACC,IAAI,CAAC;MACxDN,OAAO;MACPC;IACF,CAAC,CAAC;IACF,CACE,CAACA,WAAW,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD5Bd,SAAS,QAEP,8CAA8C,IAFhDA,SAAS;IAKT,EACEK,WAAW,CAACU,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADpCd,SAAS,QAEP,6CAA6C,IAF/CA,SAAS;IAKT,OAAO;MAAEI,OAAO,EAAEC,WAAW,GAAG,GAAG,GAAGD,OAAO;MAAEY,IAAI,EAAEV;IAAS,CAAC;EACjE;EACA,OAAO;IAAEF,OAAO,EAAEA,OAAO;IAAEY,IAAI,EAAEV;EAAS,CAAC;AAC7C","ignoreList":[]}
1
+ {"version":3,"file":"defineImportSpt.js","names":["invariant","ontologyDefinition","importSharedPropertyType","opts","apiName","packageName","typeHint","undefined","importedTypes","sharedPropertyTypes","push","endsWith","process","env","NODE_ENV","match","type","nonNameSpacedApiName"],"sources":["defineImportSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(\n opts: {\n apiName: string;\n packageName?: string;\n typeHint: PropertyTypeType;\n },\n): SharedPropertyType {\n const { apiName, packageName, typeHint } = opts;\n if (packageName !== undefined) {\n ontologyDefinition.importedTypes.sharedPropertyTypes.push({\n apiName,\n packageName,\n });\n invariant(\n !packageName.endsWith(\".\"),\n \"Package name format invalid ends with period\",\n );\n\n invariant(\n packageName.match(\"[A-Z]\") == null,\n \"Package name includes upper case characters\",\n );\n\n return {\n apiName: packageName + \".\" + apiName,\n type: typeHint,\n nonNameSpacedApiName: apiName,\n };\n }\n return { apiName: apiName, type: typeHint, nonNameSpacedApiName: apiName };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AAGxD;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAIC,EACmB;EACpB,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,IAAI;EAC/C,IAAIE,WAAW,KAAKE,SAAS,EAAE;IAC7BN,kBAAkB,CAACO,aAAa,CAACC,mBAAmB,CAACC,IAAI,CAAC;MACxDN,OAAO;MACPC;IACF,CAAC,CAAC;IACF,CACE,CAACA,WAAW,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD5Bd,SAAS,QAEP,8CAA8C,IAFhDA,SAAS;IAKT,EACEK,WAAW,CAACU,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADpCd,SAAS,QAEP,6CAA6C,IAF/CA,SAAS;IAKT,OAAO;MACLI,OAAO,EAAEC,WAAW,GAAG,GAAG,GAAGD,OAAO;MACpCY,IAAI,EAAEV,QAAQ;MACdW,oBAAoB,EAAEb;IACxB,CAAC;EACH;EACA,OAAO;IAAEA,OAAO,EAAEA,OAAO;IAAEY,IAAI,EAAEV,QAAQ;IAAEW,oBAAoB,EAAEb;EAAQ,CAAC;AAC5E","ignoreList":[]}
@@ -15,91 +15,67 @@
15
15
  */
16
16
 
17
17
  import invariant from "tiny-invariant";
18
- import { ontologyDefinition } from "./defineOntology.js";
19
- export function defineObject(apiName, opts) {
18
+ import { namespace, ontologyDefinition } from "./defineOntology.js";
19
+ export function defineObject(objectDef) {
20
+ const apiName = namespace + objectDef.apiName;
21
+ const propertyApiNames = (objectDef.properties ?? []).map(val => val.apiName);
22
+ if (ontologyDefinition.objectTypes[apiName] !== undefined) {
23
+ throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
24
+ }
25
+ !propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant(false) : void 0;
26
+ !(objectDef.primaryKeys.length !== 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `${objectDef.apiName} does not have any primary keys, objects must have at least one primary key`) : invariant(false) : void 0;
27
+ const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey => !objectDef.properties?.map(val => val.apiName).includes(primaryKey));
28
+ !(nonExistentPrimaryKeys.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key properties ${nonExistentPrimaryKeys} do not exist on object ${objectDef.apiName}`) : invariant(false) : void 0;
29
+ objectDef.implementsInterfaces?.forEach(interfaceImpl => {
30
+ const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => interfaceImpl.implements.properties[interfaceProperty] === undefined).map(interfaceProp => ({
31
+ type: "invalid",
32
+ reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
33
+ }));
34
+ const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [mapping.interfaceProperty, mapping.mapsTo]));
35
+ const validateProperty = interfaceProp => {
36
+ if (interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties) {
37
+ return validateInterfaceImplProperty(interfaceProp[1], interfaceToObjectProperties[interfaceProp[0]], objectDef);
38
+ }
39
+ return {
40
+ type: "invalid",
41
+ reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp[1].nonNameSpacedApiName} not implemented by ${objectDef.apiName} object definition`
42
+ };
43
+ };
44
+ const baseValidations = Object.entries(interfaceImpl.implements.properties).map(validateProperty);
45
+ const extendsValidations = interfaceImpl.implements.extendsInterfaces.flatMap(interfaceApiName => Object.entries(ontologyDefinition.interfaceTypes[interfaceApiName].properties).map(validateProperty));
46
+ const allFailedValidations = baseValidations.concat(extendsValidations, nonExistentInterfaceProperties).filter(val => val.type === "invalid");
47
+ !(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant(false) : void 0;
48
+ });
20
49
  ontologyDefinition.objectTypes[apiName] = {
21
- implementsInterfaces: [],
22
- implementsInterfaces2: {},
23
- linkTypes: [],
24
- objectType: {
25
- apiName,
26
- primaryKey: opts.primaryKey.apiName,
27
- displayName: opts.displayName ?? apiName,
28
- pluralDisplayName: opts.pluralDisplayName ?? apiName,
29
- icon: {
30
- color: "blue",
31
- name: "cube",
32
- type: "blueprint"
33
- },
34
- properties: {
35
- [opts.primaryKey.apiName]: {
36
- dataType: convertType(opts.primaryKey),
37
- rid: "rid"
38
- }
39
- },
40
- rid: "PLACEHOLDER",
41
- status: "ACTIVE",
42
- titleProperty: opts.primaryKey.apiName
43
- },
44
- sharedPropertyTypeMapping: {}
50
+ ...objectDef,
51
+ apiName: apiName
45
52
  };
46
-
47
- // FIXME: don't return the raw value
48
53
  return {
49
- data: ontologyDefinition.objectTypes[apiName],
50
- linkTypes: {}
54
+ ...objectDef,
55
+ apiName: apiName
51
56
  };
52
57
  }
53
- function convertType(t) {
54
- switch (true) {
55
- case t.multiplicity === true:
56
- return {
57
- type: "array",
58
- subType: convertType({
59
- ...t,
60
- multiplicity: false
61
- })
62
- };
63
- case t.type === "stringTimeseries":
64
- return {
65
- itemType: {
66
- type: "string"
67
- },
68
- type: "timeseries"
69
- };
70
- break;
71
- case t.type === "numericTimeseries":
72
- return {
73
- itemType: {
74
- type: "double"
75
- },
76
- type: "timeseries"
77
- };
78
- case t.type === "sensorTimeseries":
79
- return {
80
- type: "timeseries"
81
- };
82
- case t.type === "datetime":
83
- return {
84
- type: "timestamp"
85
- };
86
- case typeof t.type === "object":
87
- {
88
- return {
89
- type: "struct",
90
- structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({
91
- apiName,
92
- dataType: {
93
- type: dataType
94
- }
95
- }))
96
- };
97
- }
98
- default:
99
- return {
100
- type: t.type
101
- };
58
+ function formatValidationErrors(error) {
59
+ return `Ontology Definition Error: ${error.reason}\n`;
60
+ }
61
+
62
+ // Validate that the object and the interface property match up
63
+ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
64
+ const objProp = object.properties?.find(prop => prop.apiName === mappedObjectProp);
65
+ if (objProp === undefined) {
66
+ return {
67
+ type: "invalid",
68
+ reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
69
+ };
70
+ }
71
+ if (spt.type !== objProp?.type) {
72
+ return {
73
+ type: "invalid",
74
+ reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`
75
+ };
102
76
  }
103
- process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false);
77
+ return {
78
+ type: "valid"
79
+ };
104
80
  }
105
81
  //# sourceMappingURL=defineObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType","structFieldTypes","Object","entries","map","process","env","NODE_ENV"],"sources":["defineObject.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as api from \"@osdk/api\";\nimport type {\n ObjectPropertyType,\n ObjectTypeFullMetadata,\n PropertyV2,\n} from \"@osdk/internal.foundry.core\";\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\n\ntype Writeable<T> = {\n -readonly [P in keyof T]: T[P] extends ReadonlyArray<infer Q> ? Array<Q>\n : Writeable<T[P]>;\n};\n\nexport interface ObjectType {\n data: ObjectTypeFullMetadata;\n linkTypes: Record<string, {\n // hasMany: (apiName: string, t: ObjectType, {\n // reverse: {}\n // })\n }>;\n}\n\nexport function defineObject(\n apiName: string,\n opts: {\n displayName?: string;\n pluralDisplayName?: string;\n primaryKey: api.ObjectMetadata.Property & { apiName: string };\n properties?: Record<\n string,\n | api.WirePropertyTypes\n | api.ObjectMetadata.Property\n >;\n },\n): ObjectType {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n rid: \"rid\",\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\n\nfunction convertType(\n t: api.ObjectMetadata.Property & {\n apiName: string;\n },\n): PropertyV2[\"dataType\"] {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n\n case t.type === \"sensorTimeseries\":\n return {\n type: \"timeseries\",\n };\n\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n case typeof t.type === \"object\": {\n return {\n type: \"struct\",\n structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({\n apiName,\n dataType: { type: dataType } as ObjectPropertyType,\n })),\n };\n }\n default:\n return {\n type: t.type,\n };\n }\n\n invariant(false);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AAgBxD,OAAO,SAASC,YAAYA,CAC1BC,OAAe,EACfC,IASC,EACW;EACZH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACxCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACVN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACJC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACR,CAAC;MAEDC,UAAU,EAAE;QACV,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACzBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU,CAAC;UACtCU,GAAG,EAAE;QACP;MACF,CAAC;MACDA,GAAG,EAAE,aAAa;MAClBC,MAAM,EAAE,QAAQ;MAChBC,aAAa,EAAElB,IAAI,CAACM,UAAU,CAACP;IACjC,CAAC;IACDoB,yBAAyB,EAAE,CAAC;EAC9B,CAAC;;EAED;EACA,OAAO;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AACX","ignoreList":[]}
1
+ {"version":3,"file":"defineObject.js","names":["invariant","namespace","ontologyDefinition","defineObject","objectDef","apiName","propertyApiNames","properties","map","val","objectTypes","undefined","Error","includes","titlePropertyApiName","process","env","NODE_ENV","primaryKeys","length","nonExistentPrimaryKeys","filter","primaryKey","implementsInterfaces","forEach","interfaceImpl","nonExistentInterfaceProperties","propertyMapping","interfaceProperty","implements","interfaceProp","type","reason","interfaceToObjectProperties","Object","fromEntries","mapping","mapsTo","validateProperty","nonNameSpacedApiName","validateInterfaceImplProperty","baseValidations","entries","extendsValidations","extendsInterfaces","flatMap","interfaceApiName","interfaceTypes","allFailedValidations","concat","formatValidationErrors","join","error","spt","mappedObjectProp","object","objProp","find","prop"],"sources":["defineObject.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport type { ObjectType, SharedPropertyType } from \"./types.js\";\n\nexport function defineObject(objectDef: ObjectType): ObjectType {\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = (objectDef.properties ?? []).map(val => val.apiName);\n if (ontologyDefinition.objectTypes[apiName] !== undefined) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n objectDef.primaryKeys.length !== 0,\n `${objectDef.apiName} does not have any primary keys, objects must have at least one primary key`,\n );\n const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey =>\n !objectDef.properties?.map(val => val.apiName).includes(primaryKey)\n );\n invariant(\n nonExistentPrimaryKeys.length === 0,\n `Primary key properties ${nonExistentPrimaryKeys} do not exist on object ${objectDef.apiName}`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n interfaceImpl.implements.properties[interfaceProperty] === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [mapping.interfaceProperty, mapping.mapsTo],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, SharedPropertyType],\n ): ValidationResult => {\n if (\n interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties\n ) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason: `Interface property ${interfaceImpl.implements.apiName}.${\n interfaceProp[1].nonNameSpacedApiName\n } not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const baseValidations = Object.entries(interfaceImpl.implements.properties)\n .map<ValidationResult>(validateProperty);\n const extendsValidations = interfaceImpl.implements.extendsInterfaces\n .flatMap(interfaceApiName =>\n Object.entries(\n ontologyDefinition.interfaceTypes[interfaceApiName].properties,\n ).map(validateProperty)\n );\n\n const allFailedValidations = baseValidations.concat(\n extendsValidations,\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n ontologyDefinition.objectTypes[apiName] = { ...objectDef, apiName: apiName };\n return { ...objectDef, apiName: apiName };\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n spt: SharedPropertyType,\n mappedObjectProp: string,\n object: ObjectType,\n): ValidationResult {\n const objProp = object.properties?.find(prop =>\n prop.apiName === mappedObjectProp\n );\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n if (spt.type !== objProp?.type) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGnE,OAAO,SAASC,YAAYA,CAACC,SAAqB,EAAc;EAC9D,MAAMC,OAAO,GAAGJ,SAAS,GAAGG,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAG,CAACF,SAAS,CAACG,UAAU,IAAI,EAAE,EAAEC,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACJ,OAAO,CAAC;EAC7E,IAAIH,kBAAkB,CAACQ,WAAW,CAACL,OAAO,CAAC,KAAKM,SAAS,EAAE;IACzD,MAAM,IAAIC,KAAK,CACb,4BAA4BR,SAAS,CAACC,OAAO,qBAC/C,CAAC;EACH;EACA,CACEC,gBAAgB,CAACO,QAAQ,CAACT,SAAS,CAACU,oBAAoB,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD3DjB,SAAS,QAEP,kBAAkBI,SAAS,CAACU,oB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AG;IAAE,GAAGD,SAAS;IAAEC,OAAO,EAAEA;EAAQ,CAAC;EAC5E,OAAO;IAAE,GAAGD,SAAS;IAAEC,OAAO,EAAEA;EAAQ,CAAC;AAC3C;AAIA,SAAS6C,sBAAsBA,CAC7BE,KAA0C,EAClC;EACR,OAAO,8BAA8BA,KAAK,CAACpB,MAAM,IAAI;AACvD;;AAEA;AACA,SAASQ,6BAA6BA,CACpCa,GAAuB,EACvBC,gBAAwB,EACxBC,MAAkB,EACA;EAClB,MAAMC,OAAO,GAAGD,MAAM,CAAChD,UAAU,EAAEkD,IAAI,CAACC,IAAI,IAC1CA,IAAI,CAACrD,OAAO,KAAKiD,gBACnB,CAAC;EACD,IAAIE,OAAO,KAAK7C,SAAS,EAAE;IACzB,OAAO;MACLoB,IAAI,EAAE,SAAS;MACfC,MAAM,EACJ,+EAA+EsB,gBAAgB;IACnG,CAAC;EACH;EACA,IAAID,GAAG,CAACtB,IAAI,KAAKyB,OAAO,EAAEzB,IAAI,EAAE;IAC9B,OAAO;MACLA,IAAI,EAAE,SAAS;MACfC,MAAM,EACJ,mGAAmGqB,GAAG,CAAChD,OAAO,qBAAqBiD,gBAAgB;IACvJ,CAAC;EACH;EAEA,OAAO;IAAEvB,IAAI,EAAE;EAAQ,CAAC;AAC1B","ignoreList":[]}
@@ -1,3 +1,19 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
  /*
2
18
  * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
19
  *
@@ -64,6 +80,9 @@ function convertOntologyToValueTypeIr(ontology) {
64
80
  function convertToWireOntologyIr(ontology) {
65
81
  return {
66
82
  blockData: {
83
+ objectTypes: Object.fromEntries(Object.entries(ontology.objectTypes).map(([apiName, objectType]) => {
84
+ return [apiName, convertObject(objectType)];
85
+ })),
67
86
  sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {
68
87
  sharedPropertyType: convertSpt(spt)
69
88
  }])),
@@ -81,6 +100,93 @@ function convertToWireOntologyIr(ontology) {
81
100
  importedTypes: ontology.importedTypes
82
101
  };
83
102
  }
103
+ function convertObject(objectType) {
104
+ const propertyDatasource = {};
105
+ (objectType.properties ?? []).forEach(property => {
106
+ propertyDatasource[property.apiName] = {
107
+ type: "column",
108
+ column: property.apiName
109
+ };
110
+ });
111
+ const datasource = {
112
+ rid: "ri.ontology.main.datasource.".concat(objectType.apiName),
113
+ datasource: {
114
+ type: "datasetV2",
115
+ datasetV2: {
116
+ datasetRid: objectType.apiName,
117
+ propertyMapping: propertyDatasource
118
+ }
119
+ },
120
+ editsConfiguration: {
121
+ onlyAllowPrivilegedEdits: false
122
+ },
123
+ redacted: false
124
+ };
125
+ const implementations = objectType.implementsInterfaces ?? [];
126
+ return {
127
+ objectType: {
128
+ displayMetadata: {
129
+ description: objectType.description,
130
+ displayName: objectType.displayName,
131
+ groupDisplayName: undefined,
132
+ icon: {
133
+ type: "blueprint",
134
+ blueprint: objectType.icon ?? {
135
+ locator: "cube",
136
+ color: "#2D72D2"
137
+ }
138
+ },
139
+ pluralDisplayName: objectType.pluralDisplayName,
140
+ visibility: objectType.visibility ?? "NORMAL"
141
+ },
142
+ primaryKeys: objectType.primaryKeys,
143
+ propertyTypes: Object.fromEntries(objectType.properties?.map(val => [val.apiName, convertProperty(val)]) ?? []),
144
+ titlePropertyTypeRid: objectType.titlePropertyApiName,
145
+ apiName: objectType.apiName,
146
+ status: objectType.status ?? {
147
+ type: "active",
148
+ active: {}
149
+ },
150
+ redacted: false,
151
+ implementsInterfaces2: implementations.map(impl => ({
152
+ interfaceTypeApiName: impl.implements.apiName,
153
+ properties: Object.fromEntries(impl.propertyMapping.map(mapping => [namespace + mapping.interfaceProperty, {
154
+ propertyTypeRid: mapping.mapsTo
155
+ }]))
156
+ })),
157
+ allImplementsInterfaces: {}
158
+ },
159
+ datasources: [datasource],
160
+ entityMetadata: {
161
+ arePatchesEnabled: objectType.editsEnabled ?? false
162
+ }
163
+ };
164
+ }
165
+ function convertProperty(property) {
166
+ const output = {
167
+ apiName: property.apiName,
168
+ sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
169
+ displayMetadata: {
170
+ displayName: property.displayName,
171
+ description: property.description,
172
+ visibility: property.visibility ?? "NORMAL"
173
+ },
174
+ indexedForSearch: property.indexedForSearch ?? true,
175
+ ruleSetBinding: undefined,
176
+ baseFormatter: property.baseFormatter,
177
+ type: convertType(property.type),
178
+ typeClasses: property.typeClasses ?? [],
179
+ status: property.status ?? {
180
+ type: "active",
181
+ active: {}
182
+ },
183
+ inlineAction: undefined,
184
+ dataConstraints: property.dataConstraints,
185
+ sharedPropertyTypeRid: property.sharedPropertyType?.apiName,
186
+ valueType: undefined
187
+ };
188
+ return output;
189
+ }
84
190
  function convertInterface(interfaceType) {
85
191
  return {
86
192
  ...interfaceType,
@@ -1 +1 @@
1
- {"version":3,"file":"defineOntology.js","names":["ontologyDefinition","namespace","defineOntology","ns","body","actionTypes","objectTypes","queryTypes","interfaceTypes","sharedPropertyTypes","valueTypes","importedTypes","e","console","error","ontology","convertToWireOntologyIr","valueType","convertOntologyToValueTypeIr","Object","values","map","definitions","metadata","apiName","displayMetadata","status","versions","definition","version","baseType","constraints","exampleValues","blockData","fromEntries","entries","spt","sharedPropertyType","convertSpt","interfaceType","convertInterface","blockPermissionInformation","linkTypes","properties","allExtendsInterfaces","allLinks","allProperties","dumpOntologyFullMetadata","dumpValueTypeWireType","type","array","description","displayName","gothamMapping","typeClasses","dataConstraint","propertyTypeConstraints","nullability","undefined","nullabilityV2","noEmptyCollections","noNulls","visibility","subtype","convertType","aliases","baseFormatter","dataConstraints","indexedForSearch","provenance","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","fieldType","push","struct","geohash","precision","scale","analyzerOverride","enableAsciiFolding","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","mediaReference","distributeTypeHelper"],"sources":["defineOntology.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIr,\n OntologyIrInterfaceType,\n OntologyIrInterfaceTypeBlockDataV2,\n OntologyIrSharedPropertyType,\n OntologyIrSharedPropertyTypeBlockDataV2,\n OntologyIrStructFieldType,\n OntologyIrType,\n OntologyIrValueTypeBlockData,\n OntologyIrValueTypeBlockDataEntry,\n} from \"@osdk/client.unstable\";\nimport type {\n InterfaceType,\n Ontology,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\n/** @internal */\nexport let ontologyDefinition: Ontology;\n\n/** @internal */\nexport let namespace: string;\n\ntype OntologyAndValueTypeIrs = {\n ontology: OntologyIr;\n valueType: OntologyIrValueTypeBlockData;\n};\n\nexport async function defineOntology(\n ns: string,\n body: () => void | Promise<void>,\n): Promise<OntologyAndValueTypeIrs> {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n importedTypes: {\n sharedPropertyTypes: [],\n },\n };\n\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected error while processing the body of the ontology\",\n e,\n );\n throw e;\n }\n\n return {\n ontology: convertToWireOntologyIr(ontologyDefinition),\n valueType: convertOntologyToValueTypeIr(ontologyDefinition),\n };\n}\n\nfunction convertOntologyToValueTypeIr(\n ontology: Ontology,\n): OntologyIrValueTypeBlockData {\n return {\n valueTypes: Object.values(ontology.valueTypes).map<\n OntologyIrValueTypeBlockDataEntry\n >(definitions => ({\n metadata: {\n apiName: definitions[0].apiName,\n displayMetadata: definitions[0].displayMetadata,\n status: definitions[0].status,\n },\n versions: definitions.map(definition => ({\n version: definition.version,\n baseType: definition.baseType,\n constraints: definition.constraints,\n exampleValues: definition.exampleValues,\n })),\n })),\n };\n}\n\nfunction convertToWireOntologyIr(\n ontology: Ontology,\n): OntologyIr {\n return {\n blockData: {\n sharedPropertyTypes: Object.fromEntries(\n Object.entries(\n ontology.sharedPropertyTypes,\n )\n .map<[string, OntologyIrSharedPropertyTypeBlockDataV2]>((\n [apiName, spt],\n ) => [apiName, { sharedPropertyType: convertSpt(spt) }]),\n ),\n interfaceTypes: Object.fromEntries(\n Object.entries(\n ontology.interfaceTypes,\n )\n .map<[string, OntologyIrInterfaceTypeBlockDataV2]>(\n ([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType),\n }];\n },\n ),\n ),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {},\n },\n },\n importedTypes: ontology.importedTypes,\n };\n}\n\nfunction convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrInterfaceType {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties)\n .map<OntologyIrSharedPropertyType>((spt) => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: [],\n };\n}\n\nexport function dumpOntologyFullMetadata(): OntologyIr {\n return convertToWireOntologyIr(ontologyDefinition);\n}\n\nexport function dumpValueTypeWireType(): OntologyIrValueTypeBlockData {\n return convertOntologyToValueTypeIr(ontologyDefinition);\n}\n\nfunction convertSpt(\n {\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses,\n valueType,\n }: SharedPropertyType,\n): OntologyIrSharedPropertyType {\n const dataConstraint:\n | OntologyIrSharedPropertyType[\"dataConstraints\"]\n | undefined = (typeof type === \"object\" && type.type === \"marking\")\n ? {\n propertyTypeConstraints: [],\n nullability: undefined,\n nullabilityV2: { noEmptyCollections: true, noNulls: true },\n }\n : undefined;\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description,\n },\n type: array\n ? {\n type: \"array\" as const,\n array: {\n subtype: convertType(type),\n },\n }\n : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: dataConstraint,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: valueType,\n };\n}\n\nfunction convertType(\n type: PropertyTypeType,\n): OntologyIrType {\n switch (true) {\n case (typeof type === \"object\" && \"markingType\" in type):\n return {\n \"type\": \"marking\",\n marking: { markingType: type.markingType },\n };\n\n case (typeof type === \"object\" && \"structDefinition\" in type):\n const structFields: Array<OntologyIrStructFieldType> = new Array();\n for (const key in type.structDefinition) {\n const fieldTypeDefinition = type.structDefinition[key];\n let field: OntologyIrStructFieldType;\n if (typeof fieldTypeDefinition === \"string\") {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n } else {\n // If it is a full form type definition then process it as such\n if (\"fieldType\" in fieldTypeDefinition) {\n field = {\n ...fieldTypeDefinition,\n apiName: key,\n fieldType: convertType(fieldTypeDefinition.fieldType),\n typeClasses: fieldTypeDefinition.typeClasses ?? [],\n aliases: fieldTypeDefinition.aliases ?? [],\n };\n } else {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n }\n }\n\n structFields.push(field);\n }\n\n return {\n type: \"struct\",\n struct: { structFields },\n };\n\n case (type === \"geopoint\"):\n return { type: \"geohash\", geohash: {} };\n\n case (type === \"decimal\"):\n return { type, [type]: { precision: undefined, scale: undefined } };\n\n case (type === \"string\"):\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsEfficientLeadingWildcard: false,\n supportsExactMatching: true,\n },\n };\n\n case (type === \"mediaReference\"):\n return {\n type: type,\n mediaReference: {},\n };\n\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper<T extends string>(\n type: T,\n): T extends any ? { type: T } & { [K in T]: {} } : never {\n return { type, [type]: {} } as any; // any cast to match conditional return type\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA,OAAO,IAAIA,kBAA4B;;AAEvC;AACA,OAAO,IAAIC,SAAiB;AAO5B,OAAO,eAAeC,cAAcA,CAClCC,EAAU,EACVC,IAAgC,EACE;EAClCH,SAAS,GAAGE,EAAE;EACdH,kBAAkB,GAAG;IACnBK,WAAW,EAAE,CAAC,CAAC;IACfC,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC,CAAC;IACdC,cAAc,EAAE,CAAC,CAAC;IAClBC,mBAAmB,EAAE,CAAC,CAAC;IACvBC,UAAU,EAAE,CAAC,CAAC;IACdC,aAAa,EAAE;MACbF,mBAAmB,EAAE;IACvB;EACF,CAAC;EAED,IAAI;IACF,MAAML,IAAI,CAAC,CAAC;EACd,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,KA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ACvCC,qBAAqB,EAAE;QACzB;MACF,CAAC;IAEH,KAAMvC,IAAI,KAAK,gBAAgB;MAC7B,OAAO;QACLA,IAAI,EAAEA,IAAI;QACVwC,cAAc,EAAE,CAAC;MACnB,CAAC;IAEH;MACE;MACA,OAAOC,oBAAoB,CAACzC,IAAI,CAAC;EACrC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASyC,oBAAoBA,CAC3BzC,IAAO,EACiD;EACxD,OAAO;IAAEA,IAAI;IAAE,CAACA,IAAI,GAAG,CAAC;EAAE,CAAC,CAAQ,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"defineOntology.js","names":["ontologyDefinition","namespace","defineOntology","ns","body","actionTypes","objectTypes","queryTypes","interfaceTypes","sharedPropertyTypes","valueTypes","importedTypes","e","console","error","ontology","convertToWireOntologyIr","valueType","convertOntologyToValueTypeIr","Object","values","map","definitions","metadata","apiName","displayMetadata","status","versions","definition","version","baseType","constraints","exampleValues","blockData","fromEntries","entries","objectType","convertObject","spt","sharedPropertyType","convertSpt","interfaceType","convertInterface","blockPermissionInformation","linkTypes","propertyDatasource","properties","forEach","property","type","column","datasource","rid","concat","datasetV2","datasetRid","propertyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","implementations","implementsInterfaces","description","displayName","groupDisplayName","undefined","icon","blueprint","locator","color","pluralDisplayName","visibility","primaryKeys","propertyTypes","val","convertProperty","titlePropertyTypeRid","titlePropertyApiName","active","implementsInterfaces2","impl","interfaceTypeApiName","implements","mapping","interfaceProperty","propertyTypeRid","mapsTo","allImplementsInterfaces","datasources","entityMetadata","arePatchesEnabled","editsEnabled","output","sharedPropertyTypeApiName","indexedForSearch","ruleSetBinding","baseFormatter","convertType","typeClasses","inlineAction","dataConstraints","sharedPropertyTypeRid","allExtendsInterfaces","allLinks","allProperties","dumpOntologyFullMetadata","dumpValueTypeWireType","array","gothamMapping","dataConstraint","propertyTypeConstraints","nullability","nullabilityV2","noEmptyCollections","noNulls","subtype","aliases","provenance","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","fieldType","push","struct","geohash","precision","scale","analyzerOverride","enableAsciiFolding","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","mediaReference","distributeTypeHelper"],"sources":["defineOntology.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIr,\n OntologyIrInterfaceType,\n OntologyIrInterfaceTypeBlockDataV2,\n OntologyIrObjectTypeBlockDataV2,\n OntologyIrObjectTypeDatasource,\n OntologyIrPropertyType,\n OntologyIrSharedPropertyType,\n OntologyIrSharedPropertyTypeBlockDataV2,\n OntologyIrStructFieldType,\n OntologyIrType,\n OntologyIrValueTypeBlockData,\n OntologyIrValueTypeBlockDataEntry,\n PropertyTypeMappingInfo,\n} from \"@osdk/client.unstable\";\nimport type {\n InterfaceType,\n ObjectPropertyType,\n ObjectType,\n Ontology,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\n/** @internal */\nexport let ontologyDefinition: Ontology;\n\n/** @internal */\nexport let namespace: string;\n\ntype OntologyAndValueTypeIrs = {\n ontology: OntologyIr;\n valueType: OntologyIrValueTypeBlockData;\n};\n\nexport async function defineOntology(\n ns: string,\n body: () => void | Promise<void>,\n): Promise<OntologyAndValueTypeIrs> {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n importedTypes: {\n sharedPropertyTypes: [],\n },\n };\n\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected error while processing the body of the ontology\",\n e,\n );\n throw e;\n }\n\n return {\n ontology: convertToWireOntologyIr(ontologyDefinition),\n valueType: convertOntologyToValueTypeIr(ontologyDefinition),\n };\n}\n\nfunction convertOntologyToValueTypeIr(\n ontology: Ontology,\n): OntologyIrValueTypeBlockData {\n return {\n valueTypes: Object.values(ontology.valueTypes).map<\n OntologyIrValueTypeBlockDataEntry\n >(definitions => ({\n metadata: {\n apiName: definitions[0].apiName,\n displayMetadata: definitions[0].displayMetadata,\n status: definitions[0].status,\n },\n versions: definitions.map(definition => ({\n version: definition.version,\n baseType: definition.baseType,\n constraints: definition.constraints,\n exampleValues: definition.exampleValues,\n })),\n })),\n };\n}\n\nfunction convertToWireOntologyIr(\n ontology: Ontology,\n): OntologyIr {\n return {\n blockData: {\n objectTypes: Object.fromEntries(\n Object.entries(ontology.objectTypes).map<\n [string, OntologyIrObjectTypeBlockDataV2]\n >(([apiName, objectType]) => {\n return [apiName, convertObject(objectType)];\n }),\n ),\n sharedPropertyTypes: Object.fromEntries(\n Object.entries(\n ontology.sharedPropertyTypes,\n )\n .map<[string, OntologyIrSharedPropertyTypeBlockDataV2]>((\n [apiName, spt],\n ) => [apiName, { sharedPropertyType: convertSpt(spt) }]),\n ),\n interfaceTypes: Object.fromEntries(\n Object.entries(\n ontology.interfaceTypes,\n )\n .map<[string, OntologyIrInterfaceTypeBlockDataV2]>(\n ([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType),\n }];\n },\n ),\n ),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {},\n },\n },\n importedTypes: ontology.importedTypes,\n };\n}\n\nfunction convertObject(\n objectType: ObjectType,\n): OntologyIrObjectTypeBlockDataV2 {\n const propertyDatasource: Record<string, PropertyTypeMappingInfo> = {};\n (objectType.properties ?? []).forEach((property) => {\n propertyDatasource[property.apiName] = {\n type: \"column\",\n column: property.apiName,\n };\n });\n\n const datasource: OntologyIrObjectTypeDatasource = {\n rid: \"ri.ontology.main.datasource.\".concat(objectType.apiName),\n datasource: {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: propertyDatasource,\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: false,\n };\n\n const implementations = objectType.implementsInterfaces ?? [];\n\n return {\n objectType: {\n displayMetadata: {\n description: objectType.description,\n displayName: objectType.displayName,\n groupDisplayName: undefined,\n icon: {\n type: \"blueprint\",\n blueprint: objectType.icon ?? { locator: \"cube\", color: \"#2D72D2\" },\n },\n pluralDisplayName: objectType.pluralDisplayName,\n visibility: objectType.visibility ?? \"NORMAL\",\n },\n primaryKeys: objectType.primaryKeys,\n propertyTypes: Object.fromEntries(\n objectType.properties?.map<[string, OntologyIrPropertyType]>(\n val => [val.apiName, convertProperty(val)],\n ) ?? [],\n ),\n titlePropertyTypeRid: objectType.titlePropertyApiName,\n apiName: objectType.apiName,\n status: objectType.status ?? {\n type: \"active\",\n active: {},\n },\n redacted: false,\n implementsInterfaces2: implementations.map(impl => ({\n interfaceTypeApiName: impl.implements.apiName,\n properties: Object.fromEntries(\n impl.propertyMapping.map(\n mapping => [namespace + mapping.interfaceProperty, {\n propertyTypeRid: mapping.mapsTo,\n }],\n ),\n ),\n })),\n allImplementsInterfaces: {},\n },\n datasources: [datasource],\n entityMetadata: { arePatchesEnabled: objectType.editsEnabled ?? false },\n };\n}\n\nfunction convertProperty(property: ObjectPropertyType): OntologyIrPropertyType {\n const output: OntologyIrPropertyType = {\n apiName: property.apiName,\n sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,\n displayMetadata: {\n displayName: property.displayName,\n description: property.description,\n visibility: property.visibility ?? \"NORMAL\",\n },\n indexedForSearch: property.indexedForSearch ?? true,\n ruleSetBinding: undefined,\n baseFormatter: property.baseFormatter,\n type: convertType(property.type),\n typeClasses: property.typeClasses ?? [],\n status: property.status ?? { type: \"active\", active: {} },\n inlineAction: undefined,\n dataConstraints: property.dataConstraints,\n sharedPropertyTypeRid: property.sharedPropertyType?.apiName,\n valueType: undefined,\n };\n return output;\n}\n\nfunction convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrInterfaceType {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties)\n .map<OntologyIrSharedPropertyType>((spt) => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: [],\n };\n}\n\nexport function dumpOntologyFullMetadata(): OntologyIr {\n return convertToWireOntologyIr(ontologyDefinition);\n}\n\nexport function dumpValueTypeWireType(): OntologyIrValueTypeBlockData {\n return convertOntologyToValueTypeIr(ontologyDefinition);\n}\n\nfunction convertSpt(\n {\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses,\n valueType,\n }: SharedPropertyType,\n): OntologyIrSharedPropertyType {\n const dataConstraint:\n | OntologyIrSharedPropertyType[\"dataConstraints\"]\n | undefined = (typeof type === \"object\" && type.type === \"marking\")\n ? {\n propertyTypeConstraints: [],\n nullability: undefined,\n nullabilityV2: { noEmptyCollections: true, noNulls: true },\n }\n : undefined;\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description,\n },\n type: array\n ? {\n type: \"array\" as const,\n array: {\n subtype: convertType(type),\n },\n }\n : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: dataConstraint,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: valueType,\n };\n}\n\nfunction convertType(\n type: PropertyTypeType,\n): OntologyIrType {\n switch (true) {\n case (typeof type === \"object\" && \"markingType\" in type):\n return {\n \"type\": \"marking\",\n marking: { markingType: type.markingType },\n };\n\n case (typeof type === \"object\" && \"structDefinition\" in type):\n const structFields: Array<OntologyIrStructFieldType> = new Array();\n for (const key in type.structDefinition) {\n const fieldTypeDefinition = type.structDefinition[key];\n let field: OntologyIrStructFieldType;\n if (typeof fieldTypeDefinition === \"string\") {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n } else {\n // If it is a full form type definition then process it as such\n if (\"fieldType\" in fieldTypeDefinition) {\n field = {\n ...fieldTypeDefinition,\n apiName: key,\n fieldType: convertType(fieldTypeDefinition.fieldType),\n typeClasses: fieldTypeDefinition.typeClasses ?? [],\n aliases: fieldTypeDefinition.aliases ?? [],\n };\n } else {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n }\n }\n\n structFields.push(field);\n }\n\n return {\n type: \"struct\",\n struct: { structFields },\n };\n\n case (type === \"geopoint\"):\n return { type: \"geohash\", geohash: {} };\n\n case (type === \"decimal\"):\n return { type, [type]: { precision: undefined, scale: undefined } };\n\n case (type === \"string\"):\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsEfficientLeadingWildcard: false,\n supportsExactMatching: true,\n },\n };\n\n case (type === \"mediaReference\"):\n return {\n type: type,\n mediaReference: {},\n };\n\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper<T extends string>(\n type: T,\n): T extends any ? { type: T } & { [K in T]: {} } : never {\n return { type, [type]: {} } as any; // any cast to match conditional return type\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;AACA,OAAO,IAAIA,kBAA4B;;AAEvC;AACA,OAAO,IAAIC,SAAiB;AAO5B,OAAO,eAAeC,cAAcA,CAClCC,EAAU,EACVC,IAAgC,EACE;EAClCH,SAAS,GAAGE,EAAE;EACdH,kBAAkB,GAAG;IACnBK,WAAW,EAAE,CAAC,CAAC;IACfC,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC,CAAC;IACdC,cAAc,EAAE,CAAC,CAAC;IAClBC,mBAAmB,EAAE,CAAC,CAAC;IACvBC,UAAU,EAAE,CAAC,CAAC;IACdC,aAAa,EAAE;MACbF,mBAAmB,EAAE;IACvB;EACF,CAAC;EAED,IAAI;IACF,MAAML,IAAI,CAAC,CAAC;EACd,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,KAAK,CACX,4DAA4D,EAC5DF,CACF,CAAC;IACD,MAAMA,CAAC;EACT;EAEA,OAAO;IACLG,QAAQ,EAAEC,uBAAuB,CAAChB,kBAAkB,CAAC;IACrDiB,SAAS,EAAEC,4BAA4B,CAAClB,kBAAkB;EAC5D,CAAC;AACH;AAEA,SAASkB,4BAA4BA,CACnCH,QAAkB,EACY;EAC9B,OAAO;IACLL,UAAU,EAAES,MAAM,CAACC,MAAM,CAACL,QAAQ,CAACL,UAAU,CAAC,CAACW,GAAG,CAEhDC,WAAW,KAAK;MAChBC,QAAQ,EAAE;QACRC,OAAO,EAAEF,WAAW,CAAC,CAAC,CAAC,CAACE,OAAO;QAC/BC,eAAe,EAAEH,WAAW,CAAC,C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IAEzC,KAAMhF,IAAI,KAAK,SAAS;MACtB,OAAO;QAAEA,IAAI;QAAE,CAACA,IAAI,GAAG;UAAEiF,SAAS,EAAEjE,SAAS;UAAEkE,KAAK,EAAElE;QAAU;MAAE,CAAC;IAErE,KAAMhB,IAAI,KAAK,QAAQ;MACrB,OAAO;QACLA,IAAI;QACJ,CAACA,IAAI,GAAG;UACNmF,gBAAgB,EAAEnE,SAAS;UAC3BoE,kBAAkB,EAAEpE,SAAS;UAC7BqE,UAAU,EAAE,KAAK;UACjBC,gCAAgC,EAAE,KAAK;UACvCC,qBAAqB,EAAE;QACzB;MACF,CAAC;IAEH,KAAMvF,IAAI,KAAK,gBAAgB;MAC7B,OAAO;QACLA,IAAI,EAAEA,IAAI;QACVwF,cAAc,EAAE,CAAC;MACnB,CAAC;IAEH;MACE;MACA,OAAOC,oBAAoB,CAACzF,IAAI,CAAC;EACrC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASyF,oBAAoBA,CAC3BzF,IAAO,EACiD;EACxD,OAAO;IAAEA,IAAI;IAAE,CAACA,IAAI,GAAG,CAAC;EAAE,CAAC,CAAQ,CAAC;AACtC","ignoreList":[]}
@@ -29,6 +29,7 @@ export function defineSharedPropertyType(opts) {
29
29
  return ontologyDefinition.sharedPropertyTypes[apiName] = {
30
30
  ...opts,
31
31
  apiName,
32
+ nonNameSpacedApiName: opts.apiName,
32
33
  displayName: opts.displayName ?? opts.apiName,
33
34
  // This way the non-namespaced api name is the display name (maybe not ideal)
34
35
  typeClasses: opts.typeClasses ?? defaultTypeClasses
@@ -1 +1 @@
1
- {"version":3,"file":"defineSpt.js","names":["invariant","namespace","ontologyDefinition","defaultTypeClasses","kind","name","defineSharedPropertyType","opts","apiName","sharedPropertyTypes","undefined","process","env","NODE_ENV","displayName","typeClasses"],"sources":["defineSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ApiNameValueTypeReference,\n SharedPropertyTypeGothamMapping,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\nconst defaultTypeClasses: SharedPropertyType[\"typeClasses\"] = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\",\n}, { kind: \"render_hint\", name: \"SORTABLE\" }];\n\nexport function defineSharedPropertyType(\n opts: {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: ApiNameValueTypeReference;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n gothamMapping?: SharedPropertyTypeGothamMapping;\n },\n): SharedPropertyType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.sharedPropertyTypes[apiName] === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n displayName: opts.displayName ?? opts.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: opts.typeClasses ?? defaultTypeClasses,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGnE,MAAMC,kBAAqD,GAAG,CAAC;EAC7DC,IAAI,EAAE,aAAa;EACnBC,IAAI,EAAE;AACR,CAAC,EAAE;EAAED,IAAI,EAAE,aAAa;EAAEC,IAAI,EAAE;AAAW,CAAC,CAAC;AAE7C,OAAO,SAASC,wBAAwBA,CACtCC,IASC,EACmB;EACpB,MAAMC,OAAO,GAAGP,SAAS,GAAGM,IAAI,CAACC,OAAO;EACxC,EACEN,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD/Db,SAAS,QAEP,wBAAwBQ,OAAO,iBAAiB,IAFlDR,SAAS;EAKT,OAAOE,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,GAAG;IACvD,GAAGD,IAAI;IACPC,OAAO;IACPM,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIP,IAAI,CAACC,OAAO;IAAE;IAC/CO,WAAW,EAAER,IAAI,CAACQ,WAAW,IAAIZ;EACnC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"defineSpt.js","names":["invariant","namespace","ontologyDefinition","defaultTypeClasses","kind","name","defineSharedPropertyType","opts","apiName","sharedPropertyTypes","undefined","process","env","NODE_ENV","nonNameSpacedApiName","displayName","typeClasses"],"sources":["defineSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ApiNameValueTypeReference,\n SharedPropertyTypeGothamMapping,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\nconst defaultTypeClasses: SharedPropertyType[\"typeClasses\"] = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\",\n}, { kind: \"render_hint\", name: \"SORTABLE\" }];\n\nexport function defineSharedPropertyType(\n opts: {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: ApiNameValueTypeReference;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n gothamMapping?: SharedPropertyTypeGothamMapping;\n },\n): SharedPropertyType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.sharedPropertyTypes[apiName] === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n nonNameSpacedApiName: opts.apiName,\n displayName: opts.displayName ?? opts.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: opts.typeClasses ?? defaultTypeClasses,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGnE,MAAMC,kBAAqD,GAAG,CAAC;EAC7DC,IAAI,EAAE,aAAa;EACnBC,IAAI,EAAE;AACR,CAAC,EAAE;EAAED,IAAI,EAAE,aAAa;EAAEC,IAAI,EAAE;AAAW,CAAC,CAAC;AAE7C,OAAO,SAASC,wBAAwBA,CACtCC,IASC,EACmB;EACpB,MAAMC,OAAO,GAAGP,SAAS,GAAGM,IAAI,CAACC,OAAO;EACxC,EACEN,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD/Db,SAAS,QAEP,wBAAwBQ,OAAO,iBAAiB,IAFlDR,SAAS;EAKT,OAAOE,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,GAAG;IACvD,GAAGD,IAAI;IACPC,OAAO;IACPM,oBAAoB,EAAEP,IAAI,CAACC,OAAO;IAClCO,WAAW,EAAER,IAAI,CAACQ,WAAW,IAAIR,IAAI,CAACC,OAAO;IAAE;IAC/CQ,WAAW,EAAET,IAAI,CAACS,WAAW,IAAIb;EACnC,CAAC;AACH","ignoreList":[]}