@osdk/maker 0.9.1 → 0.10.0-beta.10

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 (51) hide show
  1. package/CHANGELOG.md +73 -89
  2. package/build/browser/api/defineInterface.js +30 -18
  3. package/build/browser/api/defineInterface.js.map +1 -1
  4. package/build/browser/api/defineObject.js +6 -6
  5. package/build/browser/api/defineObject.js.map +1 -1
  6. package/build/browser/api/defineOntology.js +7 -2
  7. package/build/browser/api/defineOntology.js.map +1 -1
  8. package/build/browser/api/overall.test.js +638 -464
  9. package/build/browser/api/overall.test.js.map +1 -1
  10. package/build/browser/api/types.js.map +1 -1
  11. package/build/browser/cli/main.js +1 -13
  12. package/build/browser/cli/main.js.map +1 -1
  13. package/build/cjs/index.cjs +44 -27
  14. package/build/cjs/index.cjs.map +1 -1
  15. package/build/cjs/index.d.cts +12 -3
  16. package/build/esm/api/defineInterface.js +30 -18
  17. package/build/esm/api/defineInterface.js.map +1 -1
  18. package/build/esm/api/defineObject.js +6 -6
  19. package/build/esm/api/defineObject.js.map +1 -1
  20. package/build/esm/api/defineOntology.js +7 -2
  21. package/build/esm/api/defineOntology.js.map +1 -1
  22. package/build/esm/api/overall.test.js +638 -464
  23. package/build/esm/api/overall.test.js.map +1 -1
  24. package/build/esm/api/types.js.map +1 -1
  25. package/build/esm/cli/main.js +1 -13
  26. package/build/esm/cli/main.js.map +1 -1
  27. package/build/types/api/defineImportSpt.d.ts +9 -0
  28. package/build/types/api/defineImportSpt.d.ts.map +1 -0
  29. package/build/types/api/defineInterface.d.ts +29 -0
  30. package/build/types/api/defineInterface.d.ts.map +1 -0
  31. package/build/types/api/defineInterfaceLinkConstraint.d.ts +22 -0
  32. package/build/types/api/defineInterfaceLinkConstraint.d.ts.map +1 -0
  33. package/build/types/api/defineObject.d.ts +2 -0
  34. package/build/types/api/defineObject.d.ts.map +1 -0
  35. package/build/types/api/defineOntology.d.ts +9 -0
  36. package/build/types/api/defineOntology.d.ts.map +1 -0
  37. package/build/types/api/defineSpt.d.ts +12 -0
  38. package/build/types/api/defineSpt.d.ts.map +1 -0
  39. package/build/types/api/defineValueType.d.ts +14 -0
  40. package/build/types/api/defineValueType.d.ts.map +1 -0
  41. package/build/types/api/iconNames.d.ts +2 -0
  42. package/build/types/api/iconNames.d.ts.map +1 -0
  43. package/build/types/api/overall.test.d.ts +1 -0
  44. package/build/types/api/overall.test.d.ts.map +1 -0
  45. package/build/types/api/types.d.ts +276 -0
  46. package/build/types/api/types.d.ts.map +1 -0
  47. package/build/types/cli/main.d.ts +1 -0
  48. package/build/types/cli/main.d.ts.map +1 -0
  49. package/build/types/index.d.ts +7 -0
  50. package/build/types/index.d.ts.map +1 -0
  51. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,108 +1,92 @@
1
1
  # @osdk/maker
2
2
 
3
- ## 0.9.1
3
+ ## 0.10.0-beta.10
4
+
5
+ ### Minor Changes
6
+
7
+ - 0a41cec: Support optional interface properties
8
+ - 5e8e839: Bump OMS API to include links in ontology IR
4
9
 
5
10
  ### Patch Changes
6
11
 
7
- - Updated dependencies [2e827ae]
8
- - @osdk/api@2.1.1
12
+ - Updated dependencies [23ea0e4]
13
+ - Updated dependencies [46cede4]
14
+ - @osdk/api@2.2.0-beta.10
9
15
 
10
- ## 0.9.0
16
+ ## 0.10.0-beta.9
11
17
 
12
18
  ### Minor Changes
13
19
 
14
- - 25fd9f0: Updating package.json to have better entry points to support react native bundlers.
15
- - f0b519d: Upgrade to vitest 3 and vite 6
16
- - 1812118: Add geotime support for OSDK.
17
- - bc1761c: Update platform API dependencies.
18
- - bb8b219: Use new external packages instead of the internal ones.
19
- - 44e62f6: Updating fetch for auth and other packages.
20
- - 91cfa3a: Fixing url parsing for client.
21
- - c9e855d: Allowing interfaces to extend other interfaces for ontology as code.
22
- - 94463b6: Support objects as code
23
- - 9d35a1f: Remove unused imports
24
- - 8d8bebb: Fix nullability
25
- - 7a95618: Generate new OMS APIs
26
- - c9da74c: Improves code quality by fixing linting errors
27
- - abfe4b3: Add support for reading struct properties.
28
- - caf1abc: Support generating linked products for marketplace
29
- - cd8d657: Support importing foreign SPTs
30
- - b8a1a58: 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.
31
- - b0544d4: Add additional marking configuration
32
- - 9018dc2: Updating platform api dependencies.
33
- - f569124: Add media reference to maker
34
- - 0a4f131: Fix value types so they actually serialize correctly.
35
- - 8e5e49a: Add optional link constraints
36
- - 6b6c8a1: Updates gateway endpoints and changes fetchContents for attachments to return a response
37
- - 2b35ed4: Structs in maker package
38
- - 09eaf24: Update to latest platform sdks
39
- - 06e66dc: Making interface type status configurable
40
- - d665147: Update platform sdk deps
20
+ - 12843cb: Add ability to load all underlying properties of an interface.
41
21
 
42
22
  ### Patch Changes
43
23
 
44
- - Updated dependencies [966d408]
45
- - Updated dependencies [cddc196]
46
- - Updated dependencies [d794c19]
47
- - Updated dependencies [05febf4]
48
- - Updated dependencies [55c05f2]
49
- - Updated dependencies [0dc40b0]
50
- - Updated dependencies [25fd9f0]
51
- - Updated dependencies [11a05cc]
52
- - Updated dependencies [7865cb6]
53
- - Updated dependencies [9c4efe6]
54
- - Updated dependencies [3ea2e79]
55
- - Updated dependencies [1812118]
56
- - Updated dependencies [bc1761c]
57
- - Updated dependencies [656f975]
58
- - Updated dependencies [f1145ff]
59
- - Updated dependencies [f446d0c]
60
- - Updated dependencies [c80ca45]
61
- - Updated dependencies [bb8b219]
62
- - Updated dependencies [03f95eb]
63
- - Updated dependencies [1a89f23]
64
- - Updated dependencies [9d35a1f]
65
- - Updated dependencies [c691c8b]
66
- - Updated dependencies [749cf69]
67
- - Updated dependencies [f03e39f]
68
- - Updated dependencies [11088aa]
69
- - Updated dependencies [72c1905]
70
- - Updated dependencies [9298f75]
71
- - Updated dependencies [f34b3d4]
72
- - Updated dependencies [acbfab9]
73
- - Updated dependencies [62c1d63]
74
- - Updated dependencies [3c9ac22]
75
- - Updated dependencies [1591f04]
76
- - Updated dependencies [03e1941]
77
- - Updated dependencies [abfe4b3]
78
- - Updated dependencies [b79becf]
79
- - Updated dependencies [27866a8]
80
- - Updated dependencies [e5fe7c0]
81
- - Updated dependencies [1b2e8c9]
82
- - Updated dependencies [9f3807c]
83
- - Updated dependencies [0c56d21]
84
- - Updated dependencies [e548b9b]
85
- - Updated dependencies [ee6224b]
86
- - Updated dependencies [1dc0228]
87
- - Updated dependencies [6c60414]
88
- - Updated dependencies [5fe2c8d]
89
- - Updated dependencies [d3b3f35]
90
- - Updated dependencies [785f663]
91
- - Updated dependencies [6b6c8a1]
92
- - Updated dependencies [c537e2d]
93
- - Updated dependencies [73fa373]
94
- - Updated dependencies [8e6a5f4]
95
- - Updated dependencies [2d5e648]
96
- - Updated dependencies [31e7d70]
97
- - Updated dependencies [f19da8e]
98
- - @osdk/api@2.1.0
24
+ - Updated dependencies [12843cb]
25
+ - Updated dependencies [f82767c]
26
+ - @osdk/api@2.2.0-beta.9
27
+
28
+ ## 0.10.0-beta.8
29
+
30
+ ### Minor Changes
31
+
32
+ - 63b2e63: Update Platform SDK Dependencies
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [0e874b1]
37
+ - Updated dependencies [63b2e63]
38
+ - Updated dependencies [26c2d95]
39
+ - Updated dependencies [63b2e63]
40
+ - Updated dependencies [63b2e63]
41
+ - @osdk/api@2.2.0-beta.8
42
+
43
+ ## 0.10.0-beta.7
44
+
45
+ ### Minor Changes
46
+
47
+ - 21e33a5: Upgrade consola to 3.4.0
48
+ - 7416ce4: Update Platform SDK Dependencies
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [7416ce4]
53
+ - Updated dependencies [7416ce4]
54
+ - Updated dependencies [805df40]
55
+ - @osdk/api@2.2.0-beta.7
56
+
57
+ ## 0.10.0-beta.6
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [cddfbf9]
62
+ - Updated dependencies [a6e5f89]
63
+ - @osdk/api@2.2.0-beta.6
64
+
65
+ ## 0.10.0-beta.5
66
+
67
+ ### Patch Changes
68
+
69
+ - @osdk/api@2.2.0-beta.5
70
+
71
+ ## 0.10.0-beta.4
72
+
73
+ ### Patch Changes
74
+
75
+ - @osdk/api@2.2.0-beta.4
76
+
77
+ ## 0.10.0-beta.3
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies [761e69d]
82
+ - @osdk/api@2.2.0-beta.3
99
83
 
100
- ## 0.9.0-rc.32
84
+ ## 0.10.0-beta.2
101
85
 
102
86
  ### Patch Changes
103
87
 
104
- - Updated dependencies [55c05f2]
105
- - @osdk/api@2.1.0-rc.32
88
+ - Updated dependencies [fccd9ac]
89
+ - @osdk/api@2.2.0-beta.2
106
90
 
107
91
  ## 0.9.0-beta.31
108
92
 
@@ -21,23 +21,16 @@ export function defineInterface(opts) {
21
21
  const apiName = namespace + opts.apiName;
22
22
  !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
23
23
  const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {
24
- if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
25
- !isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
26
- const spt = defineSharedPropertyType({
27
- apiName,
28
- displayName: apiName,
29
- type,
30
- array: false
31
- });
32
- return [apiName, spt];
33
- } else {
34
- const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(".") + 1);
35
- !(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
36
- key: apiName,
37
- apiName: type.apiName
38
- })}`) : invariant(false) : void 0;
39
- return [apiName, type];
24
+ if (typeof type === "object" && "propertyDefinition" in type) {
25
+ return [apiName, {
26
+ required: type.required,
27
+ sharedPropertyType: unifyBasePropertyDefinition(apiName, type.propertyDefinition)
28
+ }];
40
29
  }
30
+ return [apiName, {
31
+ required: true,
32
+ sharedPropertyType: unifyBasePropertyDefinition(apiName, type)
33
+ }];
41
34
  }));
42
35
  let extendsInterfaces = [];
43
36
  if (opts.extends) {
@@ -70,8 +63,8 @@ export function defineInterface(opts) {
70
63
  },
71
64
  extendsInterfaces: extendsInterfaces,
72
65
  links: [],
73
- properties,
74
- status
66
+ status,
67
+ propertiesV2: properties
75
68
  };
76
69
  return ontologyDefinition.interfaceTypes[apiName] = a;
77
70
  }
@@ -103,4 +96,23 @@ function mapSimplifiedStatusToInterfaceTypeStatus(status) {
103
96
  throw new Error(`Invalid status type: ${status.type}`);
104
97
  }
105
98
  }
99
+ function unifyBasePropertyDefinition(apiName, type) {
100
+ if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
101
+ !isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
102
+ const spt = defineSharedPropertyType({
103
+ apiName,
104
+ displayName: apiName,
105
+ type,
106
+ array: false
107
+ });
108
+ return spt;
109
+ } else {
110
+ const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(".") + 1);
111
+ !(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
112
+ key: apiName,
113
+ apiName: type.apiName
114
+ })}`) : invariant(false) : void 0;
115
+ return type;
116
+ }
117
+ }
106
118
  //# sourceMappingURL=defineInterface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","JSON","stringify","spt","displayName","array","unNamespacedTypeApiName","slice","lastIndexOf","key","extendsInterfaces","extends","Array","isArray","every","item","status","mapSimplifiedStatusToInterfaceTypeStatus","deprecated","message","deadline","a","displayMetadata","description","icon","blueprint","color","locator","links","v","replacedBy","active","experimental","Error"],"sources":["defineInterface.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 { defineSharedPropertyType } from \"./defineSpt.js\";\nimport type { BlueprintIcon } from \"./iconNames.js\";\nimport type {\n InterfaceType,\n InterfaceTypeStatus,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\ntype SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\nexport function defineInterface(\n opts: {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n SharedPropertyType | PropertyTypeType\n >;\n\n extends?: InterfaceType | InterfaceType[] | string | string[];\n },\n): InterfaceType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.interfaceTypes[apiName] === undefined,\n `Interface ${apiName} already exists`,\n );\n\n const properties = Object.fromEntries(\n Object.entries(opts.properties ?? {}).map<\n [string, SharedPropertyType]\n >(\n ([apiName, type]) => {\n if (\n typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))\n ) {\n invariant(\n isPropertyTypeType(type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n } else {\n const unNamespacedTypeApiName = type.apiName.slice(\n type.apiName.lastIndexOf(\".\") + 1,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return [apiName, type];\n }\n },\n ),\n );\n\n let extendsInterfaces: string[] = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n } else if (\n Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")\n ) {\n extendsInterfaces = opts.extends;\n } else if ((opts.extends as InterfaceType).apiName !== undefined) {\n extendsInterfaces = [(opts.extends as InterfaceType).apiName];\n } else {\n extendsInterfaces = (opts.extends as InterfaceType[]).map(item =>\n item.apiName\n );\n }\n }\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n opts.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const a: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status,\n };\n\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\n\nfunction isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n\nfunction mapSimplifiedStatusToInterfaceTypeStatus(\n status: SimplifiedInterfaceTypeStatus,\n): InterfaceTypeStatus {\n switch (status.type) {\n case \"deprecated\":\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: undefined,\n },\n };\n case \"active\":\n return {\n type: \"active\",\n active: {},\n };\n case \"experimental\":\n return {\n type: \"experimental\",\n experimental: {},\n };\n default:\n throw new Error(`Invalid status type: ${(status as any).type}`);\n }\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;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AAczD,OAAO,SAASC,eAAeA,CAC7BC,IAYC,EACc;EACf,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EACEJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1DX,SAAS,QAEP,aAAaM,OAAO,iBAAiB,IAFvCN,SAAS;EAKT,MAAMY,UAAU,GAAGC,MAAM,CAACC,WAAW,CACnCD,MAAM,CAACE,OAAO,CAACV,IAAI,CAACO,UAAU,IAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAGvC,CAAC,CAACV,OAAO,EAAEW,IAAI,CAAC,KAAK;IACnB,IACE,OAAOA,IAAI,KAAK,QAAQ,IACpB,OAAOA,IAAI,KAAK,QAAQ,IAAI,EAAE,SAAS,IAAIA,IAAI,CAAE,EACrD;MACA,CACEC,kBAAkB,CAACD,IAAI,CAAC,GAAAR,OAAA,CAAAC,GAAA,CAAAC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B,EACI;EACvB,OAAOA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IACjCA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,QAAQ,IACjDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,UAAU,IAAIA,CAAC,KAAK,UAAU,IACrDA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAC9B,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,CAAC9B,IAAI,KAAK,SAAU,IAC/C8B,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AACxB;AAEA,SAASZ,wCAAwCA,CAC/CD,MAAqC,EAChB;EACrB,QAAQA,MAAM,CAACjB,IAAI;IACjB,KAAK,YAAY;MACf,OAAO;QACLA,IAAI,EAAE,YAAY;QAClBmB,UAAU,EAAE;UACVC,OAAO,EAAEH,MAAM,CAACG,OAAO;UACvBC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;UACzBU,UAAU,EAAExC;QACd;MACF,CAAC;IACH,KAAK,QAAQ;MACX,OAAO;QACLS,IAAI,EAAE,QAAQ;QACdgC,MAAM,EAAE,CAAC;MACX,CAAC;IACH,KAAK,cAAc;MACjB,OAAO;QACLhC,IAAI,EAAE,cAAc;QACpBiC,YAAY,EAAE,CAAC;MACjB,CAAC;IACH;MACE,MAAM,IAAIC,KAAK,CAAC,wBAAyBjB,MAAM,CAASjB,IAAI,EAAE,CAAC;EACnE;AACF","ignoreList":[]}
1
+ {"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","required","sharedPropertyType","unifyBasePropertyDefinition","propertyDefinition","extendsInterfaces","extends","Array","isArray","every","item","status","mapSimplifiedStatusToInterfaceTypeStatus","deprecated","message","deadline","a","displayMetadata","displayName","description","icon","blueprint","color","locator","links","propertiesV2","isPropertyTypeType","v","replacedBy","active","experimental","Error","JSON","stringify","spt","array","unNamespacedTypeApiName","slice","lastIndexOf","key"],"sources":["defineInterface.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 { defineSharedPropertyType } from \"./defineSpt.js\";\nimport type { BlueprintIcon } from \"./iconNames.js\";\nimport type {\n InterfaceType,\n InterfaceTypeStatus,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\ntype SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\ntype PropertyBase = SharedPropertyType | PropertyTypeType;\ntype PropertyWithOptional = {\n required: boolean;\n propertyDefinition: PropertyBase;\n};\n\nexport function defineInterface(\n opts: {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n PropertyBase | PropertyWithOptional\n >;\n\n extends?: InterfaceType | InterfaceType[] | string | string[];\n },\n): InterfaceType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.interfaceTypes[apiName] === undefined,\n `Interface ${apiName} already exists`,\n );\n\n const properties = Object.fromEntries(\n Object.entries(opts.properties ?? {}).map<\n [string, { required: boolean; sharedPropertyType: SharedPropertyType }]\n >(\n ([apiName, type]) => {\n if (typeof type === \"object\" && \"propertyDefinition\" in type) {\n return [apiName, {\n required: type.required,\n sharedPropertyType: unifyBasePropertyDefinition(\n apiName,\n type.propertyDefinition,\n ),\n }];\n }\n\n return [apiName, {\n required: true,\n sharedPropertyType: unifyBasePropertyDefinition(apiName, type),\n }];\n },\n ),\n );\n\n let extendsInterfaces: string[] = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n } else if (\n Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")\n ) {\n extendsInterfaces = opts.extends;\n } else if ((opts.extends as InterfaceType).apiName !== undefined) {\n extendsInterfaces = [(opts.extends as InterfaceType).apiName];\n } else {\n extendsInterfaces = (opts.extends as InterfaceType[]).map(item =>\n item.apiName\n );\n }\n }\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n opts.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const a: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n status,\n propertiesV2: properties,\n };\n\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\n\nfunction isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n\nfunction mapSimplifiedStatusToInterfaceTypeStatus(\n status: SimplifiedInterfaceTypeStatus,\n): InterfaceTypeStatus {\n switch (status.type) {\n case \"deprecated\":\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: undefined,\n },\n };\n case \"active\":\n return {\n type: \"active\",\n active: {},\n };\n case \"experimental\":\n return {\n type: \"experimental\",\n experimental: {},\n };\n default:\n throw new Error(`Invalid status type: ${(status as any).type}`);\n }\n}\n\nfunction unifyBasePropertyDefinition(\n apiName: string,\n type: PropertyBase,\n): SharedPropertyType {\n if (\n typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))\n ) {\n invariant(\n isPropertyTypeType(type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return spt;\n } else {\n const unNamespacedTypeApiName = type.apiName.slice(\n type.apiName.lastIndexOf(\".\") + 1,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return type;\n }\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;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AAoBzD,OAAO,SAASC,eAAeA,CAC7BC,IAYC,EACc;EACf,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EACEJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1DX,SAAS,QAEP,aAAaM,OAAO,iBAAiB,IAFvCN,SAAS;EAKT,MAAMY,UAAU,GAAGC,MAAM,CAACC,WAAW,CACnCD,MAAM,C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IAAI,CAACX,OAAO,CAACgD,KAAK,CAChDrC,IAAI,CAACX,OAAO,CAACiD,WAAW,CAAC,GAAG,CAAC,GAAG,CAClC,CAAC;IACD,EACEtD,SAAS,GAAGK,OAAO,KAAKW,IAAI,CAACX,OAAO,IAC/BA,OAAO,KAAK+C,uBAAuB,IAAA5C,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1CX,SAAS,QAGP,oDACEiD,IAAI,CAACC,SAAS,CAAC;MAAEM,GAAG,EAAElD,OAAO;MAAEA,OAAO,EAAEW,IAAI,CAACX;IAAQ,CAAC,CAAC,EACvD,IALJN,SAAS;IAOT,OAAOiB,IAAI;EACb;AACF","ignoreList":[]}
@@ -27,22 +27,22 @@ export function defineObject(objectDef) {
27
27
  const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey => !objectDef.properties?.map(val => val.apiName).includes(primaryKey));
28
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
29
  objectDef.implementsInterfaces?.forEach(interfaceImpl => {
30
- const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => interfaceImpl.implements.properties[interfaceProperty] === undefined).map(interfaceProp => ({
30
+ const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => interfaceImpl.implements.propertiesV2[interfaceProperty] === undefined).map(interfaceProp => ({
31
31
  type: "invalid",
32
32
  reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
33
33
  }));
34
34
  const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [mapping.interfaceProperty, mapping.mapsTo]));
35
35
  const validateProperty = interfaceProp => {
36
- if (interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties) {
37
- return validateInterfaceImplProperty(interfaceProp[1], interfaceToObjectProperties[interfaceProp[0]], objectDef);
36
+ if (interfaceProp[1].sharedPropertyType.nonNameSpacedApiName in interfaceToObjectProperties) {
37
+ return validateInterfaceImplProperty(interfaceProp[1].sharedPropertyType, interfaceToObjectProperties[interfaceProp[0]], objectDef);
38
38
  }
39
39
  return {
40
40
  type: "invalid",
41
- reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp[1].nonNameSpacedApiName} not implemented by ${objectDef.apiName} object definition`
41
+ reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp[1].sharedPropertyType.nonNameSpacedApiName} not implemented by ${objectDef.apiName} object definition`
42
42
  };
43
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));
44
+ const baseValidations = Object.entries(interfaceImpl.implements.propertiesV2).map(validateProperty);
45
+ const extendsValidations = interfaceImpl.implements.extendsInterfaces.flatMap(interfaceApiName => Object.entries(ontologyDefinition.interfaceTypes[interfaceApiName].propertiesV2).map(validateProperty));
46
46
  const allFailedValidations = baseValidations.concat(extendsValidations, nonExistentInterfaceProperties).filter(val => val.type === "invalid");
47
47
  !(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant(false) : void 0;
48
48
  });
@@ -1 +1 @@
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,oBAAoB,6BAA6BV,SAAS,CAACC,OAAO,EAAE,IAFlGL,SAAS;EAIT,EACEI,SAAS,CAACc,WAAW,CAACC,MAAM,KAAK,CAAC,IAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADpCjB,SAAS,QAEP,GAAGI,SAAS,CAACC,OAAO,6EAA6E,IAFnGL,SAAS;EAIT,MAAMoB,sBAAsB,GAAGhB,SAAS,CAACc,WAAW,CAACG,MAAM,CAACC,UAAU,IACpE,CAAClB,SAA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B,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
+ {"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","propertiesV2","interfaceProp","type","reason","interfaceToObjectProperties","Object","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","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 {\n InterfacePropertyType,\n ObjectType,\n SharedPropertyType,\n} 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.propertiesV2[interfaceProperty]\n === 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, InterfacePropertyType],\n ): ValidationResult => {\n if (\n interfaceProp[1].sharedPropertyType.nonNameSpacedApiName\n in interfaceToObjectProperties\n ) {\n return validateInterfaceImplProperty(\n interfaceProp[1].sharedPropertyType,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason: `Interface property ${interfaceImpl.implements.apiName}.${\n interfaceProp[1].sharedPropertyType.nonNameSpacedApiName\n } not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const baseValidations = Object.entries(\n interfaceImpl.implements.propertiesV2,\n )\n .map<ValidationResult>(validateProperty);\n const extendsValidations = interfaceImpl.implements.extendsInterfaces\n .flatMap(interfaceApiName =>\n Object.entries(\n ontologyDefinition.interfaceTypes[interfaceApiName].propertiesV2,\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,gBA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IAAI,EAAE;IAC9B,OAAO;MACLA,IAAI,EAAE,SAAS;MACfC,MAAM,EACJ,mGAAmGsB,GAAG,CAAClD,OAAO,qBAAqBmD,gBAAgB;IACvJ,CAAC;EACH;EAEA,OAAO;IAAExB,IAAI,EAAE;EAAQ,CAAC;AAC1B","ignoreList":[]}
@@ -190,11 +190,16 @@ function convertProperty(property) {
190
190
  function convertInterface(interfaceType) {
191
191
  return {
192
192
  ...interfaceType,
193
- properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),
193
+ propertiesV2: Object.fromEntries(Object.values(interfaceType.propertiesV2).map(spt => [spt.sharedPropertyType.apiName, {
194
+ required: spt.required,
195
+ sharedPropertyType: convertSpt(spt.sharedPropertyType)
196
+ }])),
194
197
  // these are omitted from our internal types but we need to re-add them for the final json
195
198
  allExtendsInterfaces: [],
196
199
  allLinks: [],
197
- allProperties: []
200
+ allProperties: [],
201
+ allPropertiesV2: {},
202
+ properties: []
198
203
  };
199
204
  }
200
205
  export function dumpOntologyFullMetadata() {
@@ -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","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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B;YAC5C,CAAC;UACH;QACF;QAEAJ,YAAY,CAACO,IAAI,CAACF,KAAK,CAAC;MAC1B;MAEA,OAAO;QACL5E,IAAI,EAAE,QAAQ;QACd+E,MAAM,EAAE;UAAER;QAAa;MACzB,CAAC;IAEH,KAAMvE,IAAI,KAAK,UAAU;MACvB,OAAO;QAAEA,IAAI,EAAE,SAAS;QAAEgF,OAAO,EAAE,CAAC;MAAE,CAAC;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":[]}
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","propertiesV2","required","allExtendsInterfaces","allLinks","allProperties","allPropertiesV2","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 propertiesV2: Object.fromEntries(\n Object.values(interfaceType.propertiesV2)\n .map((\n spt,\n ) => [spt.sharedPropertyType.apiName, {\n required: spt.required,\n sharedPropertyType: convertSpt(spt.sharedPropertyType),\n }]),\n ),\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 allPropertiesV2: {},\n properties: [],\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,CAA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