@osdk/maker 0.16.0-beta.2 → 0.16.0-beta.4

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 (165) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +14 -0
  3. package/build/browser/api/cloneDefinition.js +36 -0
  4. package/build/browser/api/cloneDefinition.js.map +1 -0
  5. package/build/browser/api/code-snippets/createCodeSnippets.js +1 -1
  6. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
  7. package/build/browser/api/defineAction.js +3 -1
  8. package/build/browser/api/defineAction.js.map +1 -1
  9. package/build/browser/api/defineCreateInterfaceObjectAction.js +3 -1
  10. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
  11. package/build/browser/api/defineCreateObjectAction.js +3 -1
  12. package/build/browser/api/defineCreateObjectAction.js.map +1 -1
  13. package/build/browser/api/defineCreateOrModifyObjectAction.js +3 -1
  14. package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
  15. package/build/browser/api/defineDeleteInterfaceObjectAction.js +3 -1
  16. package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  17. package/build/browser/api/defineDeleteObjectAction.js +3 -1
  18. package/build/browser/api/defineDeleteObjectAction.js.map +1 -1
  19. package/build/browser/api/defineInterface.js +3 -1
  20. package/build/browser/api/defineInterface.js.map +1 -1
  21. package/build/browser/api/defineInterfaceLinkConstraint.js +6 -2
  22. package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
  23. package/build/browser/api/defineLink.js +3 -1
  24. package/build/browser/api/defineLink.js.map +1 -1
  25. package/build/browser/api/defineModifyInterfaceObjectAction.js +3 -1
  26. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
  27. package/build/browser/api/defineModifyObjectAction.js +3 -1
  28. package/build/browser/api/defineModifyObjectAction.js.map +1 -1
  29. package/build/browser/api/defineObject.js +29 -10
  30. package/build/browser/api/defineObject.js.map +1 -1
  31. package/build/browser/api/defineSpt.js +3 -1
  32. package/build/browser/api/defineSpt.js.map +1 -1
  33. package/build/browser/api/defineValueType.js +3 -1
  34. package/build/browser/api/defineValueType.js.map +1 -1
  35. package/build/browser/api/object/ObjectPropertyType.js.map +1 -1
  36. package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
  37. package/build/browser/api/properties/ReducerType.js +2 -0
  38. package/build/browser/api/properties/ReducerType.js.map +1 -0
  39. package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
  40. package/build/browser/api/test/actions.test.js +5 -0
  41. package/build/browser/api/test/actions.test.js.map +1 -1
  42. package/build/browser/api/test/objectStatus.test.js +93 -1
  43. package/build/browser/api/test/objectStatus.test.js.map +1 -1
  44. package/build/browser/api/test/objects.test.js +576 -0
  45. package/build/browser/api/test/objects.test.js.map +1 -1
  46. package/build/browser/api/test/spt.test.js +62 -61
  47. package/build/browser/api/test/spt.test.js.map +1 -1
  48. package/build/browser/cli/main.js +1 -1
  49. package/build/browser/conversion/toMarketplace/convertMainValue.js +36 -0
  50. package/build/browser/conversion/toMarketplace/convertMainValue.js.map +1 -0
  51. package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
  52. package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
  53. package/build/browser/conversion/toMarketplace/convertReducers.js +53 -0
  54. package/build/browser/conversion/toMarketplace/convertReducers.js.map +1 -0
  55. package/build/browser/conversion/toMarketplace/convertSpt.js +5 -3
  56. package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
  57. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
  58. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  59. package/build/cjs/index.cjs +194 -98
  60. package/build/cjs/index.cjs.map +1 -1
  61. package/build/cjs/index.d.cts +27 -15
  62. package/build/esm/api/cloneDefinition.js +36 -0
  63. package/build/esm/api/cloneDefinition.js.map +1 -0
  64. package/build/esm/api/code-snippets/createCodeSnippets.js +1 -1
  65. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
  66. package/build/esm/api/defineAction.js +3 -1
  67. package/build/esm/api/defineAction.js.map +1 -1
  68. package/build/esm/api/defineCreateInterfaceObjectAction.js +3 -1
  69. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
  70. package/build/esm/api/defineCreateObjectAction.js +3 -1
  71. package/build/esm/api/defineCreateObjectAction.js.map +1 -1
  72. package/build/esm/api/defineCreateOrModifyObjectAction.js +3 -1
  73. package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
  74. package/build/esm/api/defineDeleteInterfaceObjectAction.js +3 -1
  75. package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  76. package/build/esm/api/defineDeleteObjectAction.js +3 -1
  77. package/build/esm/api/defineDeleteObjectAction.js.map +1 -1
  78. package/build/esm/api/defineInterface.js +3 -1
  79. package/build/esm/api/defineInterface.js.map +1 -1
  80. package/build/esm/api/defineInterfaceLinkConstraint.js +6 -2
  81. package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
  82. package/build/esm/api/defineLink.js +3 -1
  83. package/build/esm/api/defineLink.js.map +1 -1
  84. package/build/esm/api/defineModifyInterfaceObjectAction.js +3 -1
  85. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
  86. package/build/esm/api/defineModifyObjectAction.js +3 -1
  87. package/build/esm/api/defineModifyObjectAction.js.map +1 -1
  88. package/build/esm/api/defineObject.js +29 -10
  89. package/build/esm/api/defineObject.js.map +1 -1
  90. package/build/esm/api/defineSpt.js +3 -1
  91. package/build/esm/api/defineSpt.js.map +1 -1
  92. package/build/esm/api/defineValueType.js +3 -1
  93. package/build/esm/api/defineValueType.js.map +1 -1
  94. package/build/esm/api/object/ObjectPropertyType.js.map +1 -1
  95. package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
  96. package/build/esm/api/properties/ReducerType.js +2 -0
  97. package/build/esm/api/properties/ReducerType.js.map +1 -0
  98. package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
  99. package/build/esm/api/test/actions.test.js +5 -0
  100. package/build/esm/api/test/actions.test.js.map +1 -1
  101. package/build/esm/api/test/objectStatus.test.js +93 -1
  102. package/build/esm/api/test/objectStatus.test.js.map +1 -1
  103. package/build/esm/api/test/objects.test.js +576 -0
  104. package/build/esm/api/test/objects.test.js.map +1 -1
  105. package/build/esm/api/test/spt.test.js +62 -61
  106. package/build/esm/api/test/spt.test.js.map +1 -1
  107. package/build/esm/cli/main.js +1 -1
  108. package/build/esm/conversion/toMarketplace/convertMainValue.js +36 -0
  109. package/build/esm/conversion/toMarketplace/convertMainValue.js.map +1 -0
  110. package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
  111. package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
  112. package/build/esm/conversion/toMarketplace/convertReducers.js +53 -0
  113. package/build/esm/conversion/toMarketplace/convertReducers.js.map +1 -0
  114. package/build/esm/conversion/toMarketplace/convertSpt.js +5 -3
  115. package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
  116. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
  117. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  118. package/build/types/api/cloneDefinition.d.ts +9 -0
  119. package/build/types/api/cloneDefinition.d.ts.map +1 -0
  120. package/build/types/api/defineAction.d.ts +1 -1
  121. package/build/types/api/defineAction.d.ts.map +1 -1
  122. package/build/types/api/defineCreateInterfaceObjectAction.d.ts +1 -1
  123. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
  124. package/build/types/api/defineCreateObjectAction.d.ts +1 -1
  125. package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
  126. package/build/types/api/defineCreateOrModifyObjectAction.d.ts +1 -1
  127. package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -1
  128. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +1 -1
  129. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -1
  130. package/build/types/api/defineDeleteObjectAction.d.ts +1 -1
  131. package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -1
  132. package/build/types/api/defineInterface.d.ts +1 -1
  133. package/build/types/api/defineInterface.d.ts.map +1 -1
  134. package/build/types/api/defineInterfaceLinkConstraint.d.ts +1 -1
  135. package/build/types/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
  136. package/build/types/api/defineLink.d.ts +1 -1
  137. package/build/types/api/defineLink.d.ts.map +1 -1
  138. package/build/types/api/defineModifyInterfaceObjectAction.d.ts +1 -1
  139. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
  140. package/build/types/api/defineModifyObjectAction.d.ts +1 -1
  141. package/build/types/api/defineModifyObjectAction.d.ts.map +1 -1
  142. package/build/types/api/defineObject.d.ts +1 -1
  143. package/build/types/api/defineObject.d.ts.map +1 -1
  144. package/build/types/api/defineSpt.d.ts +3 -1
  145. package/build/types/api/defineSpt.d.ts.map +1 -1
  146. package/build/types/api/defineValueType.d.ts +1 -1
  147. package/build/types/api/defineValueType.d.ts.map +1 -1
  148. package/build/types/api/object/ObjectPropertyType.d.ts +2 -0
  149. package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -1
  150. package/build/types/api/properties/PropertyTypeType.d.ts +4 -0
  151. package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
  152. package/build/types/api/properties/ReducerType.d.ts +4 -0
  153. package/build/types/api/properties/ReducerType.d.ts.map +1 -0
  154. package/build/types/api/properties/SharedPropertyType.d.ts +2 -0
  155. package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
  156. package/build/types/conversion/toMarketplace/convertMainValue.d.ts +4 -0
  157. package/build/types/conversion/toMarketplace/convertMainValue.d.ts.map +1 -0
  158. package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -1
  159. package/build/types/conversion/toMarketplace/convertReducers.d.ts +6 -0
  160. package/build/types/conversion/toMarketplace/convertReducers.d.ts.map +1 -0
  161. package/build/types/conversion/toMarketplace/convertSpt.d.ts +1 -1
  162. package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -1
  163. package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts +2 -1
  164. package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -1
  165. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"defineModifyObjectAction.js","names":["convertMappingValue","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","isPropertyParameter","kebab","MODIFY_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","defineModifyObjectAction","def","Object","keys","objectType","properties","apiName","propertyParameters","filter","id","type","primaryKeyPropertyApiName","parameterNames","Set","parameterConfiguration","forEach","param","add","actionApiName","split","pop","parameterOrdering","includes","unshift","parameters","p","defaultValue","undefined","objectParameterPropertyValue","parameterId","propertyTypeId","mappings","fromEntries","entries","nonParameterMappings","map","value","displayName","status","rules","modifyObjectRule","objectToModify","propertyValues","structFieldValues","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyObjectAction.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\nimport { convertMappingValue } from \"../conversion/toMarketplace/convertMappingValue.js\";\nimport { type ActionType } from \"./action/ActionType.js\";\nimport type { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n isPropertyParameter,\n kebab,\n MODIFY_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\n\nexport function defineModifyObjectAction(\n def: ActionTypeUserDefinition,\n): ActionType {\n validateActionParameters(\n def,\n Object.keys(def.objectType.properties ?? {}),\n def.objectType.apiName,\n );\n const propertyParameters = Object.keys(def.objectType.properties ?? {})\n .filter(\n id =>\n isPropertyParameter(def, id, def.objectType.properties?.[id].type!)\n && id !== def.objectType.primaryKeyPropertyApiName,\n );\n const parameterNames = new Set(propertyParameters);\n Object.keys(def.parameterConfiguration ?? {}).forEach(param =>\n parameterNames.add(param)\n );\n parameterNames.add(MODIFY_OBJECT_PARAMETER);\n const actionApiName = def.apiName\n ?? `modify-object-${\n kebab(def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName)\n }`;\n if (def.parameterOrdering) {\n if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);\n }\n validateParameterOrdering(\n def.parameterOrdering,\n parameterNames,\n actionApiName,\n );\n }\n const parameters = createParameters(\n def,\n def.objectType.properties ?? {},\n parameterNames,\n );\n parameters.forEach(\n p => {\n // create prefilled parameters for object type properties unless overridden\n if (def.objectType.properties?.[p.id] && p.defaultValue === undefined) {\n p.defaultValue = {\n type: \"objectParameterPropertyValue\",\n objectParameterPropertyValue: {\n parameterId: MODIFY_OBJECT_PARAMETER,\n propertyTypeId: p.id,\n },\n };\n }\n },\n );\n\n const mappings = Object.fromEntries(\n Object.entries(def.nonParameterMappings ?? {}).map((\n [id, value],\n ) => [id, convertMappingValue(value)]),\n );\n\n return defineAction({\n apiName: actionApiName,\n displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,\n parameters: parameters,\n status: def.status ?? \"active\",\n rules: [{\n type: \"modifyObjectRule\",\n modifyObjectRule: {\n objectToModify: MODIFY_OBJECT_PARAMETER,\n propertyValues: {\n ...Object.fromEntries(\n propertyParameters.map(\n p => [p, { type: \"parameterId\", parameterId: p }],\n ),\n ),\n ...mappings,\n },\n structFieldValues: {},\n },\n }],\n entities: {\n affectedInterfaceTypes: [],\n affectedObjectTypes: [def.objectType.apiName],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n parameterOrdering: def.parameterOrdering\n ?? createDefaultParameterOrdering(\n def,\n Object.keys(def.objectType.properties ?? {}),\n parameters,\n MODIFY_OBJECT_PARAMETER,\n ),\n ...(def.actionLevelValidation\n ? {\n validation: convertValidationRule(\n def.actionLevelValidation,\n parameters,\n ),\n }\n : {}),\n ...(def.defaultFormat && { defaultFormat: def.defaultFormat }),\n ...(def.enableLayoutSwitch\n && { enableLayoutSwitch: def.enableLayoutSwitch }),\n ...(def.tableConfiguration && {\n displayAndFormat: {\n table: def.tableConfiguration,\n },\n }),\n ...(def.sections\n && {\n sections: Object.fromEntries(\n def.sections.map(section => [section.id, section]),\n ),\n }),\n ...(def.submissionMetadata\n && { submissionMetadata: def.submissionMetadata }),\n ...(def.icon && { icon: def.icon }),\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,mBAAmB,QAAQ,oDAAoD;AAGxF,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,mBAAmB,EACnBC,KAAK,EACLC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,QACpB,mBAAmB;AAE1B,OAAO,SAASC,wBAAwBA,CACtCC,GAA6B,EACjB;EACZH,wBAAwB,CACtBG,GAAG,EACHC,MAAM,CAACC,IAAI,CAACF,GAAG,CAACG,UAAU,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,EAC5CJ,GAAG,CAACG,UAAU,CAACE,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ertMappingValue","cloneDefinition","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","isPropertyParameter","kebab","MODIFY_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","defineModifyObjectAction","defInput","def","Object","keys","objectType","properties","apiName","propertyParameters","filter","id","type","primaryKeyPropertyApiName","parameterNames","Set","parameterConfiguration","forEach","param","add","actionApiName","split","pop","parameterOrdering","includes","unshift","parameters","p","defaultValue","undefined","objectParameterPropertyValue","parameterId","propertyTypeId","mappings","fromEntries","entries","nonParameterMappings","map","value","displayName","status","rules","modifyObjectRule","objectToModify","propertyValues","structFieldValues","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyObjectAction.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\nimport { convertMappingValue } from \"../conversion/toMarketplace/convertMappingValue.js\";\nimport { type ActionType } from \"./action/ActionType.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n isPropertyParameter,\n kebab,\n MODIFY_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\n\nexport function defineModifyObjectAction(\n defInput: ActionTypeUserDefinition,\n): ActionType {\n const def = cloneDefinition(defInput);\n validateActionParameters(\n def,\n Object.keys(def.objectType.properties ?? {}),\n def.objectType.apiName,\n );\n const propertyParameters = Object.keys(def.objectType.properties ?? {})\n .filter(\n id =>\n isPropertyParameter(def, id, def.objectType.properties?.[id].type!)\n && id !== def.objectType.primaryKeyPropertyApiName,\n );\n const parameterNames = new Set(propertyParameters);\n Object.keys(def.parameterConfiguration ?? {}).forEach(param =>\n parameterNames.add(param)\n );\n parameterNames.add(MODIFY_OBJECT_PARAMETER);\n const actionApiName = def.apiName\n ?? `modify-object-${\n kebab(def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName)\n }`;\n if (def.parameterOrdering) {\n if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);\n }\n validateParameterOrdering(\n def.parameterOrdering,\n parameterNames,\n actionApiName,\n );\n }\n const parameters = createParameters(\n def,\n def.objectType.properties ?? {},\n parameterNames,\n );\n parameters.forEach(\n p => {\n // create prefilled parameters for object type properties unless overridden\n if (def.objectType.properties?.[p.id] && p.defaultValue === undefined) {\n p.defaultValue = {\n type: \"objectParameterPropertyValue\",\n objectParameterPropertyValue: {\n parameterId: MODIFY_OBJECT_PARAMETER,\n propertyTypeId: p.id,\n },\n };\n }\n },\n );\n\n const mappings = Object.fromEntries(\n Object.entries(def.nonParameterMappings ?? {}).map((\n [id, value],\n ) => [id, convertMappingValue(value)]),\n );\n\n return defineAction({\n apiName: actionApiName,\n displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,\n parameters: parameters,\n status: def.status ?? \"active\",\n rules: [{\n type: \"modifyObjectRule\",\n modifyObjectRule: {\n objectToModify: MODIFY_OBJECT_PARAMETER,\n propertyValues: {\n ...Object.fromEntries(\n propertyParameters.map(\n p => [p, { type: \"parameterId\", parameterId: p }],\n ),\n ),\n ...mappings,\n },\n structFieldValues: {},\n },\n }],\n entities: {\n affectedInterfaceTypes: [],\n affectedObjectTypes: [def.objectType.apiName],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n parameterOrdering: def.parameterOrdering\n ?? createDefaultParameterOrdering(\n def,\n Object.keys(def.objectType.properties ?? {}),\n parameters,\n MODIFY_OBJECT_PARAMETER,\n ),\n ...(def.actionLevelValidation\n ? {\n validation: convertValidationRule(\n def.actionLevelValidation,\n parameters,\n ),\n }\n : {}),\n ...(def.defaultFormat && { defaultFormat: def.defaultFormat }),\n ...(def.enableLayoutSwitch\n && { enableLayoutSwitch: def.enableLayoutSwitch }),\n ...(def.tableConfiguration && {\n displayAndFormat: {\n table: def.tableConfiguration,\n },\n }),\n ...(def.sections\n && {\n sections: Object.fromEntries(\n def.sections.map(section => [section.id, section]),\n ),\n }),\n ...(def.submissionMetadata\n && { submissionMetadata: def.submissionMetadata }),\n ...(def.icon && { icon: def.icon }),\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,mBAAmB,QAAQ,oDAAoD;AAExF,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,mBAAmB,EACnBC,KAAK,EACLC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,QACpB,mBAAmB;AAE1B,OAAO,SAASC,wBAAwBA,CACtCC,QAAkC,EACtB;EACZ,MAAMC,GAAG,GAAGZ,eAAe,CAACW,QAAQ,CAAC;EACrCH,wBAAwB,CACtBI,GAAG,EACHC,MAAM,CAACC,IAAI,CAACF,GAAG,CAACG,UAAU,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,EAC5CJ,GAAG,CAACG,UAAU,CAACE,OACjB,CAAC;EACD,MAAMC,kBAAkB,GAAGL,MAAM,CAACC,IAAI,CAACF,GAAG,CAACG,UAAU,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,CACpEG,MAAM,CACLC,EAAE,IACAf,mBAAmB,CAACO,GAAG,EAAEQ,EAAE,E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HC,MAAM,CAACC,IAAI,CAACF,GAAG,CAACG,UAAU,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,EAC5CmB,UAAU,EACV5B,uBACF,CAAC;IACH,IAAIK,GAAG,CAACgD,qBAAqB,GACzB;MACAC,UAAU,EAAE5D,qBAAqB,CAC/BW,GAAG,CAACgD,qBAAqB,EACzBzB,UACF;IACF,CAAC,GACC,CAAC,CAAC,CAAC;IACP,IAAIvB,GAAG,CAACkD,aAAa,IAAI;MAAEA,aAAa,EAAElD,GAAG,CAACkD;IAAc,CAAC,CAAC;IAC9D,IAAIlD,GAAG,CAACmD,kBAAkB,IACrB;MAAEA,kBAAkB,EAAEnD,GAAG,CAACmD;IAAmB,CAAC,CAAC;IACpD,IAAInD,GAAG,CAACoD,kBAAkB,IAAI;MAC5BC,gBAAgB,EAAE;QAChBC,KAAK,EAAEtD,GAAG,CAACoD;MACb;IACF,CAAC,CAAC;IACF,IAAIpD,GAAG,CAACuD,QAAQ,IACX;MACDA,QAAQ,EAAEtD,MAAM,CAAC8B,WAAW,CAC1B/B,GAAG,CAACuD,QAAQ,CAACrB,GAAG,CAACsB,OAAO,IAAI,CAACA,OAAO,CAAChD,EAAE,EAAEgD,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAIxD,GAAG,CAACyD,kBAAkB,IACrB;MAAEA,kBAAkB,EAAEzD,GAAG,CAACyD;IAAmB,CAAC,CAAC;IACpD,IAAIzD,GAAG,CAAC0D,IAAI,IAAI;MAAEA,IAAI,EAAE1D,GAAG,CAAC0D;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -16,19 +16,20 @@
16
16
 
17
17
  import invariant from "tiny-invariant";
18
18
  import { getObject } from "../conversion/toMarketplace/convertLink.js";
19
+ import { cloneDefinition } from "./cloneDefinition.js";
19
20
  import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
20
21
  import { addNamespaceIfNone, importedTypes, namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
21
22
  import { getFlattenedInterfaceProperties } from "./interface/getFlattenedInterfaceProperties.js";
22
23
  import { getInterfacePropertyTypeType, isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
23
- import { isExotic } from "./properties/PropertyTypeType.js";
24
-
24
+ import { isExotic, isStruct } from "./properties/PropertyTypeType.js";
25
25
  // From https://stackoverflow.com/a/79288714
26
26
  const ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+D)|(?:\d+(?:\.|,)\d+D$))?(T((?:\d+H)|(?:\d+(?:\.|,)\d+H$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+S)|(?:\d+(?:\.|,)\d+S$))?)?)|(?:\d+(?:(?:\.|,)\d+)?W))$/;
27
27
 
28
28
  // ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)
29
29
  const ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
30
30
  const API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
31
- export function defineObject(objectDef) {
31
+ export function defineObject(objectDefInput) {
32
+ const objectDef = cloneDefinition(objectDefInput);
32
33
  const apiName = namespace + objectDef.apiName;
33
34
  const propertyApiNames = objectDef.properties ? Object.keys(objectDef.properties) : [];
34
35
  if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== undefined) {
@@ -49,15 +50,23 @@ export function defineObject(objectDef) {
49
50
  derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));
50
51
  }
51
52
 
52
- // Validate that if object status is experimental, no property can have a status of active
53
- if (objectDef.status === "experimental") {
54
- const activeProperties = [];
53
+ // Validate property statuses match the object status.
54
+ // An experimental object can only have experimental properties.
55
+ // A deprecated object can only have deprecated properties.
56
+ // An example object can only have example properties.
57
+ // There is no restriction on property statuses of an active object.
58
+ const objectStatusType = getStatusType(objectDef.status);
59
+ if (objectStatusType === "experimental" || objectStatusType === "deprecated" || objectStatusType === "example") {
60
+ const mismatchedProperties = [];
55
61
  Object.entries(objectDef.properties ?? {}).forEach(([apiName, property]) => {
56
- if (property.status === "active") {
57
- activeProperties.push(apiName);
62
+ if (property.status !== undefined) {
63
+ const propertyStatusType = getStatusType(property.status);
64
+ if (propertyStatusType !== objectStatusType) {
65
+ mismatchedProperties.push(apiName);
66
+ }
58
67
  }
59
68
  });
60
- !(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant(false) : void 0;
69
+ !(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object "${objectDef.apiName}" has "${objectStatusType}" status, but the following properties have a different status: ${mismatchedProperties.join(", ")}`) : invariant(false) : void 0;
61
70
  }
62
71
 
63
72
  // Validate deprecated status deadline is in ISO 8601 format
@@ -65,7 +74,8 @@ export function defineObject(objectDef) {
65
74
  const deadline = objectDef.status.deadline;
66
75
  !(deadline !== undefined && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant(false) : void 0;
67
76
  }
68
- !!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant(false) : void 0;
77
+ const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
78
+ !(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant(false) : void 0;
69
79
  !!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant(false) : void 0;
70
80
  objectDef.implementsInterfaces?.forEach(interfaceImpl => {
71
81
  const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
@@ -258,4 +268,13 @@ function isPrimitive(type) {
258
268
  const typeType = typeof type === "string" ? type : type.type;
259
269
  return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
260
270
  }
271
+ function getStatusType(status) {
272
+ if (status === undefined) {
273
+ return "active";
274
+ }
275
+ if (typeof status === "string") {
276
+ return status;
277
+ }
278
+ return status.type;
279
+ }
261
280
  //# sourceMappingURL=defineObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineObject.js","names":["invariant","getObject","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","withoutNamespace","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","isExotic","ISO_8601_DURATION","ISO_8601_DATETIME","API_NAME_PATTERN","defineObject","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","test","process","env","NODE_ENV","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","retentionPeriods","datasources","filter","ds","type","map","retentionPeriod","forEach","baseDatasources","length","join","derivedDatasources","validateDerivedDatasource","status","activeProperties","entries","property","push","deadline","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","mappedObjectProp","object","objProp","propertyType","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"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 { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic } from \"./properties/PropertyTypeType.js\";\n\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nconst API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\\\-]*)$/;\n\nexport function defineObject(\n objectDef: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n API_NAME_PATTERN.test(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate that if object status is experimental, no property can have a status of active\n if (objectDef.status === \"experimental\") {\n const activeProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status === \"active\") {\n activeProperties.push(apiName);\n }\n },\n );\n invariant(\n activeProperties.length === 0,\n `When object \"${objectDef.apiName}\" has experimental status, no properties can have \"active\" status, but found active properties: ${\n activeProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n invariant(\n !isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined\n && allInterfaceProperties[withoutNamespace(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n mapping.interfaceProperty,\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n const apiName = isInterfaceSharedPropertyType(interfaceProp[1])\n ? interfaceProp[1].sharedPropertyType.apiName\n : interfaceProp[0];\n if (apiName in interfaceToObjectProperties) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n apiName,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason:\n `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\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 const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\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 type: InterfacePropertyType,\n apiName: string,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\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 const propertyType = getInterfacePropertyTypeType(type);\n if (JSON.stringify(propertyType) !== JSON.stringify(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: ${apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\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,QAAQ,4CAA4C;AACtE,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,kBAAkB,EAClBC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,+BAA+B,QAAQ,gDAAgD;AAChG,SACEC,4BAA4B,EAE5BC,6BAA6B,QACxB,sCAAsC;AAW7C,SAASC,QAAQ,QAAQ,kCAAkC;;AAE3D;AACA,MAAMC,iBAAiB,GACrB,+OAA+O;;AAEjP;AACA,MAAMC,iBAAiB,GACrB,sEAAsE;AAExE,MAAMC,gBAAgB,GAAG,6BAA6B;AAEtD,OAAO,SAASC,YAAYA,CAC1BC,SAA+B,EACT;EACtB,MAAMC,OAAO,GAAGb,SAAS,GAAGY,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,UAAU,GACzCC,MAAM,CAACC,IAAI,CAACL,SAAS,CAACG,UAAU,CAAC,GACjC,EAAE;EACN,IACEd,kBAAkB,CAACJ,sB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F,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACA,IAAI;EAC5D,OAAO,CACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,CACR,CAACR,QAAQ,CAAC8F,QAAQ,CAAC;AACtB;AAEA,SAASH,WAAWA,CAACnF,IAAsB,EAAW;EACpD,MAAMsF,QAAQ,GAAG,OAAOtF,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACA,IAAI;EAC5D,OAAO,CACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,WAAW,CACZ,CAACR,QAAQ,CAAC8F,QAAQ,CAAC;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"defineObject.js","names":["invariant","getObject","cloneDefinition","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","withoutNamespace","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","isExotic","isStruct","ISO_8601_DURATION","ISO_8601_DATETIME","API_NAME_PATTERN","defineObject","objectDefInput","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","test","process","env","NODE_ENV","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","retentionPeriods","datasources","filter","ds","type","map","retentionPeriod","forEach","baseDatasources","length","join","derivedDatasources","validateDerivedDatasource","objectStatusType","getStatusType","status","mismatchedProperties","entries","property","propertyStatusType","push","deadline","titleProp","mainValue","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","mappedObjectProp","object","objProp","propertyType","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"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 { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { ObjectTypeStatus } from \"./object/ObjectTypeStatus.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic, isStruct } from \"./properties/PropertyTypeType.js\";\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nconst API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\\\-]*)$/;\n\nexport function defineObject(\n objectDefInput: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const objectDef = cloneDefinition(objectDefInput);\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n API_NAME_PATTERN.test(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate property statuses match the object status.\n // An experimental object can only have experimental properties.\n // A deprecated object can only have deprecated properties.\n // An example object can only have example properties.\n // There is no restriction on property statuses of an active object.\n const objectStatusType = getStatusType(objectDef.status);\n if (\n objectStatusType === \"experimental\" || objectStatusType === \"deprecated\"\n || objectStatusType === \"example\"\n ) {\n const mismatchedProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status !== undefined) {\n const propertyStatusType = getStatusType(property.status);\n if (propertyStatusType !== objectStatusType) {\n mismatchedProperties.push(apiName);\n }\n }\n },\n );\n invariant(\n mismatchedProperties.length === 0,\n `Object \"${objectDef.apiName}\" has \"${objectStatusType}\" status, but the following properties have a different status: ${\n mismatchedProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]\n ?.type;\n invariant(\n !isExotic(titleProp)\n || (isStruct(titleProp) && titleProp.mainValue\n && !isExotic(titleProp.mainValue.type)),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined\n && allInterfaceProperties[withoutNamespace(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n mapping.interfaceProperty,\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n const apiName = isInterfaceSharedPropertyType(interfaceProp[1])\n ? interfaceProp[1].sharedPropertyType.apiName\n : interfaceProp[0];\n if (apiName in interfaceToObjectProperties) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n apiName,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason:\n `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\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 const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\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 type: InterfacePropertyType,\n apiName: string,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\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 const propertyType = getInterfacePropertyTypeType(type);\n if (JSON.stringify(propertyType) !== JSON.stringify(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: ${apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction getStatusType(status: ObjectTypeStatus | undefined): string {\n if (status === undefined) {\n return \"active\";\n }\n if (typeof status === \"string\") {\n return status;\n }\n return status.type;\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,QAAQ,4CAA4C;AACtE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,kBAAkB,EAClBC,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AEA,SAASH,WAAWA,CAACxF,IAAsB,EAAW;EACpD,MAAM2F,QAAQ,GAAG,OAAO3F,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACA,IAAI;EAC5D,OAAO,CACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,WAAW,CACZ,CAACR,QAAQ,CAACmG,QAAQ,CAAC;AACtB;AAEA,SAASjF,aAAaA,CAACC,MAAoC,EAAU;EACnE,IAAIA,MAAM,KAAKzB,SAAS,EAAE;IACxB,OAAO,QAAQ;EACjB;EACA,IAAI,OAAOyB,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EACA,OAAOA,MAAM,CAACX,IAAI;AACpB","ignoreList":[]}
@@ -15,10 +15,12 @@
15
15
  */
16
16
 
17
17
  import invariant from "tiny-invariant";
18
+ import { cloneDefinition } from "./cloneDefinition.js";
18
19
  import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
19
20
  import { namespace, ontologyDefinition, updateOntology } from "./defineOntology.js";
20
21
  import { defaultTypeClasses, getPropertyTypeName, hasRenderHints, shouldNotHaveRenderHints } from "./propertyConversionUtils.js";
21
- export function defineSharedPropertyType(sptDef) {
22
+ export function defineSharedPropertyType(sptDefInput) {
23
+ const sptDef = cloneDefinition(sptDefInput);
22
24
  const apiName = namespace + sptDef.apiName;
23
25
  !(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;
24
26
  !(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant(false) : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"defineSpt.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldNotHaveRenderHints","defineSharedPropertyType","sptDef","apiName","SHARED_PROPERTY_TYPE","undefined","process","env","NODE_ENV","type","typeClasses","fullSpt","nonNameSpacedApiName","displayName","__type"],"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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport type { Nullability } from \"./properties/Nullability.js\";\nimport { type PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldNotHaveRenderHints,\n} from \"./propertyConversionUtils.js\";\n\nexport interface SharedPropertyTypeDefinition {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n nullability?: Nullability;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n}\n\nexport function defineSharedPropertyType(\n sptDef: SharedPropertyTypeDefinition,\n): SharedPropertyType {\n const apiName = namespace + sptDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName]\n === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n invariant(\n !shouldNotHaveRenderHints(sptDef.type)\n || !hasRenderHints(sptDef.typeClasses),\n `Shared property type ${apiName} of type '${\n getPropertyTypeName(sptDef.type)\n }' should not have render hints`,\n );\n\n const fullSpt: SharedPropertyType = {\n ...sptDef,\n apiName,\n nonNameSpacedApiName: sptDef.apiName,\n displayName: sptDef.displayName ?? sptDef.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: sptDef.typeClasses\n ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n updateOntology(fullSpt);\n return fullSpt;\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,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AAI5B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,QACnB,8BAA8B;AAiBrC,OAAO,SAASC,wBAAwBA,CACtCC,MAAoC,EAChB;EACpB,MAAMC,OAAO,GAAGT,SAAS,GAAGQ,MAAM,CAACC,OAAO;EAC1C,EACER,kBAAkB,CAACF,sBAAsB,CAACW,oBAAoB,CAAC,CAACD,OAAO,CAAC,KAClEE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFjBhB,SAAS,QAGP,wBAAwBW,OAAO,iBAAiB,IAHlDX,SAAS;EAMT,EACE,CAACQ,wBAAwB,CAACE,MAAM,CAACO,IAAI,CAAC,IACjC,CAACV,cAAc,CAACG,MAAM,CAACQ,WAAW,CAAC,IAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1ChB,SAAS,QAGP,wBAAwBW,OAAO,aAC7BL,mBAAmB,CAACI,MAAM,CAACO,IAAI,CAAC,gCACF,IALlCjB,SAAS;EAQT,MAAMmB,OAA2B,GAAG;IAClC,GAAGT,MAAM;IACTC,OAAO;IACPS,oBAAoB,EAAEV,MAAM,CAACC,OAAO;IACpCU,WAAW,EAAEX,MAAM,CAACW,WAAW,IAAIX,MAAM,CAACC,OAAO;IAAE;IACnDO,WAAW,EAAER,MAAM,CAACQ,WAAW,KACzBV,wBAAwB,CAACE,MAAM,CAACO,IAAI,CAAC,GAAG,EAAE,GAAGZ,kBAAkB,CAAC;IACtEiB,MAAM,EAAErB,sBAAsB,CAACW;EACjC,CAAC;EACDR,cAAc,CAACe,OAAO,CAAC;EACvB,OAAOA,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"defineSpt.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldNotHaveRenderHints","defineSharedPropertyType","sptDefInput","sptDef","apiName","SHARED_PROPERTY_TYPE","undefined","process","env","NODE_ENV","type","typeClasses","fullSpt","nonNameSpacedApiName","displayName","__type"],"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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport type { Nullability } from \"./properties/Nullability.js\";\nimport { type PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport type { ReducerType } from \"./properties/ReducerType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldNotHaveRenderHints,\n} from \"./propertyConversionUtils.js\";\n\nexport interface SharedPropertyTypeDefinition {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n reducers?: Array<ReducerType>;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n nullability?: Nullability;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n}\n\nexport function defineSharedPropertyType(\n sptDefInput: SharedPropertyTypeDefinition,\n): SharedPropertyType {\n const sptDef = cloneDefinition(sptDefInput);\n const apiName = namespace + sptDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName]\n === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n invariant(\n !shouldNotHaveRenderHints(sptDef.type)\n || !hasRenderHints(sptDef.typeClasses),\n `Shared property type ${apiName} of type '${\n getPropertyTypeName(sptDef.type)\n }' should not have render hints`,\n );\n\n const fullSpt: SharedPropertyType = {\n ...sptDef,\n apiName,\n nonNameSpacedApiName: sptDef.apiName,\n displayName: sptDef.displayName ?? sptDef.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: sptDef.typeClasses\n ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n updateOntology(fullSpt);\n return fullSpt;\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,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AAK5B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,QACnB,8BAA8B;AAkBrC,OAAO,SAASC,wBAAwBA,CACtCC,WAAyC,EACrB;EACpB,MAAMC,MAAM,GAAGX,eAAe,CAACU,WAAW,CAAC;EAC3C,MAAME,OAAO,GAAGV,SAAS,GAAGS,MAAM,CAACC,OAAO;EAC1C,EACET,kBAAkB,CAACF,sBAAsB,CAACY,oBAAoB,CAAC,CAACD,OAAO,CAAC,KAClEE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFjBlB,SAAS,QAGP,wBAAwBa,OAAO,iBAAiB,IAHlDb,SAAS;EAMT,EACE,CAACS,wBAAwB,CAACG,MAAM,CAACO,IAAI,CAAC,IACjC,CAACX,cAAc,CAACI,MAAM,CAACQ,WAAW,CAAC,IAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1ClB,SAAS,QAGP,wBAAwBa,OAAO,aAC7BN,mBAAmB,CAACK,MAAM,CAACO,IAAI,CAAC,gCACF,IALlCnB,SAAS;EAQT,MAAMqB,OAA2B,GAAG;IAClC,GAAGT,MAAM;IACTC,OAAO;IACPS,oBAAoB,EAAEV,MAAM,CAACC,OAAO;IACpCU,WAAW,EAAEX,MAAM,CAACW,WAAW,IAAIX,MAAM,CAACC,OAAO;IAAE;IACnDO,WAAW,EAAER,MAAM,CAACQ,WAAW,KACzBX,wBAAwB,CAACG,MAAM,CAACO,IAAI,CAAC,GAAG,EAAE,GAAGb,kBAAkB,CAAC;IACtEkB,MAAM,EAAEtB,sBAAsB,CAACY;EACjC,CAAC;EACDT,cAAc,CAACgB,OAAO,CAAC;EACvB,OAAOA,OAAO;AAChB","ignoreList":[]}
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import invariant from "tiny-invariant";
18
+ import { cloneDefinition } from "./cloneDefinition.js";
18
19
  import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
19
20
  import { namespace, ontologyDefinition, updateOntology } from "./defineOntology.js";
20
21
  function convertValueTypeTypeToBaseType(valueType) {
@@ -61,7 +62,8 @@ function convertValueTypeTypeToBaseType(valueType) {
61
62
  throw new Error("Invalid ValueTypeType");
62
63
  }
63
64
  }
64
- export function defineValueType(valueTypeDef) {
65
+ export function defineValueType(valueTypeDefInput) {
66
+ const valueTypeDef = cloneDefinition(valueTypeDefInput);
65
67
  const {
66
68
  apiName: inputApiName,
67
69
  displayName,
@@ -1 +1 @@
1
- {"version":3,"file":"defineValueType.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","convertValueTypeTypeToBaseType","valueType","type","array","elementType","structV2","fields","map","field","identifier","baseType","keyType","optional","wrappedType","Error","defineValueType","valueTypeDef","apiName","inputApiName","displayName","description","version","namespacePrefix","test","process","env","NODE_ENV","existingVersions","VALUE_TYPE","duplicateVersion","find","vt","undefined","typeName","constraints","constraint","output","failureMessage","packageNamespace","substring","length","displayMetadata","status","convertUserValueTypeStatusToValueTypeStatus","exampleValues","__type","deprecated","message","deadline","replacedBy","active"],"sources":["defineValueType.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 BaseType,\n DataConstraint,\n DataConstraintWrapper,\n FailureMessage,\n ValueTypeDataConstraint,\n ValueTypeRid,\n ValueTypeStatus,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { type ValueTypeDefinitionVersion } from \"./values/ValueTypeDefinitionVersion.js\";\nimport { type ValueTypeType } from \"./values/ValueTypeType.js\";\n\ntype ZipBaseAndConstraint<Base, Constraint> = {\n [PropertyType in (BaseType[\"type\"] & DataConstraint[\"type\"])]: Base extends\n { type: PropertyType } ? {\n baseType: Omit<Base, \"type\">;\n constraints?: Constraint extends { type: PropertyType } ? {\n constraint: Omit<Constraint, \"type\">;\n failureMessage?: FailureMessage;\n }[]\n : undefined;\n }\n : never;\n};\n\ntype MappedZip = ZipBaseAndConstraint<BaseType, DataConstraint>;\n\ntype TypeNames = ValueTypeType[\"type\"];\n\ntype ValueTypeDefinitionBacking = {\n [Type in ValueTypeType[\"type\"] & DataConstraint[\"type\"]]: {\n baseType: { \"type\": Extract<ValueTypeType, { type: Type }>[\"value\"] } & {\n constraints: {\n constraint: Extract<\n DataConstraint,\n { type: Type }\n >[keyof Omit<Extract<DataConstraint, { type: Type }>, \"type\">];\n failureMessage?: FailureMessage;\n }[];\n };\n };\n};\n\ntype NewValueTypeDefinitionBacking = {\n [Type in ValueTypeType as Type[\"type\"]]: {\n type: Type[\"value\"];\n constraints?: Type[\"constraints\"];\n };\n};\ntype NewValueTypeDefinition =\n NewValueTypeDefinitionBacking[keyof NewValueTypeDefinitionBacking];\n\nfunction convertValueTypeTypeToBaseType(\n valueType: ValueTypeType[\"value\"],\n): BaseType {\n if (typeof valueType === \"string\") {\n }\n switch (true) {\n case (typeof valueType === \"object\" && valueType.type === \"array\"):\n return {\n type: \"array\",\n array: {\n elementType: convertValueTypeTypeToBaseType(valueType.elementType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"struct\"):\n return {\n type: \"structV2\",\n structV2: {\n fields: valueType.fields.map(field => ({\n identifier: field.identifier,\n baseType: convertValueTypeTypeToBaseType(field.baseType),\n })),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"map\"):\n return {\n type: \"map\",\n map: {\n keyType: convertValueTypeTypeToBaseType(valueType.keyType),\n valueType: convertValueTypeTypeToBaseType(valueType.valueType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"optional\"):\n return {\n type: \"optional\",\n optional: {\n wrappedType: convertValueTypeTypeToBaseType(valueType.wrappedType),\n },\n };\n case (typeof valueType === \"string\"):\n return { type: valueType, [valueType]: {} } as any;\n default:\n throw new Error(\"Invalid ValueTypeType\");\n }\n}\n\nexport type ValueTypeDefinition = {\n apiName: string;\n displayName: string;\n description?: string;\n type: NewValueTypeDefinition;\n version: string;\n status?: UserValueTypeStatus;\n namespacePrefix?: boolean;\n};\n\nexport type UserValueTypeStatus = \"active\" | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: ValueTypeRid;\n};\n\nexport function defineValueType(\n valueTypeDef: ValueTypeDefinition,\n): ValueTypeDefinitionVersion {\n const {\n apiName: inputApiName,\n displayName,\n description,\n type,\n version,\n namespacePrefix,\n } = valueTypeDef;\n const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;\n const semverValidation =\n /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n\n const existingVersions =\n ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];\n const duplicateVersion = existingVersions.find(vt => vt.version === version);\n invariant(\n duplicateVersion === undefined,\n `Value type with apiName ${apiName} and version ${version} is already defined`,\n );\n\n const typeName: TypeNames = typeof type.type === \"string\"\n ? type.type\n : type.type.type === \"struct\"\n ? \"structV2\"\n : type.type.type;\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = type.constraints\n ? type.constraints.map<ValueTypeDataConstraint>(constraint => {\n const output: any = {\n constraint: { type: typeName, [typeName]: constraint.constraint },\n failureMessage: constraint.failureMessage,\n };\n return { constraint: output as DataConstraintWrapper };\n })\n : [];\n\n const baseType: BaseType = convertValueTypeTypeToBaseType(type.type);\n\n const vt: ValueTypeDefinitionVersion = {\n apiName,\n packageNamespace: namespace.substring(0, namespace.length - 1),\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: convertUserValueTypeStatusToValueTypeStatus(valueTypeDef.status),\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n __type: OntologyEntityTypeEnum.VALUE_TYPE,\n };\n updateOntology(vt);\n return vt;\n}\n\nexport function convertUserValueTypeStatusToValueTypeStatus(\n status: UserValueTypeStatus | undefined,\n): ValueTypeStatus {\n if (typeof status === \"object\" && status.type === \"deprecated\") {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: status.replacedBy,\n },\n };\n }\n return { type: \"active\", active: {} };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AA4C5B,SAASC,8BAA8BA,CACrCC,SAAiC,EACvB;EACV,IAAI,OA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UAAU,EAAEC;IAAgC,CAAC;EACxD,CAAC,CAAC,GACA,EAAE;EAEN,MAAM1B,QAAkB,GAAGV,8BAA8B,CAACE,IAAI,CAACA,IAAI,CAAC;EAEpE,MAAM6B,EAA8B,GAAG;IACrCd,OAAO;IACPqB,gBAAgB,EAAEzC,SAAS,CAAC0C,SAAS,CAAC,CAAC,EAAE1C,SAAS,CAAC2C,MAAM,GAAG,CAAC,CAAC;IAC9DC,eAAe,EAAE;MACftB,WAAW,EAAEA,WAAW;MACxBC,WAAW,EAAEA,WAAW,IAAI;IAC9B,CAAC;IACDsB,MAAM,EAAEC,2CAA2C,CAAC3B,YAAY,CAAC0B,MAAM,CAAC;IACxErB,OAAO,EAAEA,OAAO;IAChBX,QAAQ,EAAEA,QAAQ;IAClBwB,WAAW,EAAEA,WAAW;IACxBU,aAAa,EAAE,EAAE;IACjBC,MAAM,EAAEjD,sBAAsB,CAACgC;EACjC,CAAC;EACD7B,cAAc,CAACgC,EAAE,CAAC;EAClB,OAAOA,EAAE;AACX;AAEA,OAAO,SAASY,2CAA2CA,CACzDD,MAAuC,EACtB;EACjB,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACxC,IAAI,KAAK,YAAY,EAAE;IAC9D,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB4C,UAAU,EAAE;QACVC,OAAO,EAAEL,MAAM,CAACK,OAAO;QACvBC,QAAQ,EAAEN,MAAM,CAACM,QAAQ;QACzBC,UAAU,EAAEP,MAAM,CAACO;MACrB;IACF,CAAC;EACH;EACA,OAAO;IAAE/C,IAAI,EAAE,QAAQ;IAAEgD,MAAM,EAAE,CAAC;EAAE,CAAC;AACvC","ignoreList":[]}
1
+ {"version":3,"file":"defineValueType.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","convertValueTypeTypeToBaseType","valueType","type","array","elementType","structV2","fields","map","field","identifier","baseType","keyType","optional","wrappedType","Error","defineValueType","valueTypeDefInput","valueTypeDef","apiName","inputApiName","displayName","description","version","namespacePrefix","test","process","env","NODE_ENV","existingVersions","VALUE_TYPE","duplicateVersion","find","vt","undefined","typeName","constraints","constraint","output","failureMessage","packageNamespace","substring","length","displayMetadata","status","convertUserValueTypeStatusToValueTypeStatus","exampleValues","__type","deprecated","message","deadline","replacedBy","active"],"sources":["defineValueType.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 BaseType,\n DataConstraint,\n DataConstraintWrapper,\n FailureMessage,\n ValueTypeDataConstraint,\n ValueTypeRid,\n ValueTypeStatus,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { type ValueTypeDefinitionVersion } from \"./values/ValueTypeDefinitionVersion.js\";\nimport { type ValueTypeType } from \"./values/ValueTypeType.js\";\n\ntype ZipBaseAndConstraint<Base, Constraint> = {\n [PropertyType in (BaseType[\"type\"] & DataConstraint[\"type\"])]: Base extends\n { type: PropertyType } ? {\n baseType: Omit<Base, \"type\">;\n constraints?: Constraint extends { type: PropertyType } ? {\n constraint: Omit<Constraint, \"type\">;\n failureMessage?: FailureMessage;\n }[]\n : undefined;\n }\n : never;\n};\n\ntype MappedZip = ZipBaseAndConstraint<BaseType, DataConstraint>;\n\ntype TypeNames = ValueTypeType[\"type\"];\n\ntype ValueTypeDefinitionBacking = {\n [Type in ValueTypeType[\"type\"] & DataConstraint[\"type\"]]: {\n baseType: { \"type\": Extract<ValueTypeType, { type: Type }>[\"value\"] } & {\n constraints: {\n constraint: Extract<\n DataConstraint,\n { type: Type }\n >[keyof Omit<Extract<DataConstraint, { type: Type }>, \"type\">];\n failureMessage?: FailureMessage;\n }[];\n };\n };\n};\n\ntype NewValueTypeDefinitionBacking = {\n [Type in ValueTypeType as Type[\"type\"]]: {\n type: Type[\"value\"];\n constraints?: Type[\"constraints\"];\n };\n};\ntype NewValueTypeDefinition =\n NewValueTypeDefinitionBacking[keyof NewValueTypeDefinitionBacking];\n\nfunction convertValueTypeTypeToBaseType(\n valueType: ValueTypeType[\"value\"],\n): BaseType {\n if (typeof valueType === \"string\") {\n }\n switch (true) {\n case (typeof valueType === \"object\" && valueType.type === \"array\"):\n return {\n type: \"array\",\n array: {\n elementType: convertValueTypeTypeToBaseType(valueType.elementType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"struct\"):\n return {\n type: \"structV2\",\n structV2: {\n fields: valueType.fields.map(field => ({\n identifier: field.identifier,\n baseType: convertValueTypeTypeToBaseType(field.baseType),\n })),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"map\"):\n return {\n type: \"map\",\n map: {\n keyType: convertValueTypeTypeToBaseType(valueType.keyType),\n valueType: convertValueTypeTypeToBaseType(valueType.valueType),\n },\n };\n case (typeof valueType === \"object\" && valueType.type === \"optional\"):\n return {\n type: \"optional\",\n optional: {\n wrappedType: convertValueTypeTypeToBaseType(valueType.wrappedType),\n },\n };\n case (typeof valueType === \"string\"):\n return { type: valueType, [valueType]: {} } as any;\n default:\n throw new Error(\"Invalid ValueTypeType\");\n }\n}\n\nexport type ValueTypeDefinition = {\n apiName: string;\n displayName: string;\n description?: string;\n type: NewValueTypeDefinition;\n version: string;\n status?: UserValueTypeStatus;\n namespacePrefix?: boolean;\n};\n\nexport type UserValueTypeStatus = \"active\" | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: ValueTypeRid;\n};\n\nexport function defineValueType(\n valueTypeDefInput: ValueTypeDefinition,\n): ValueTypeDefinitionVersion {\n const valueTypeDef = cloneDefinition(valueTypeDefInput);\n const {\n apiName: inputApiName,\n displayName,\n description,\n type,\n version,\n namespacePrefix,\n } = valueTypeDef;\n const apiName = namespacePrefix ? namespace + inputApiName : inputApiName;\n const semverValidation =\n /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n\n const existingVersions =\n ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][apiName] ?? [];\n const duplicateVersion = existingVersions.find(vt => vt.version === version);\n invariant(\n duplicateVersion === undefined,\n `Value type with apiName ${apiName} and version ${version} is already defined`,\n );\n\n const typeName: TypeNames = typeof type.type === \"string\"\n ? type.type\n : type.type.type === \"struct\"\n ? \"structV2\"\n : type.type.type;\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = type.constraints\n ? type.constraints.map<ValueTypeDataConstraint>(constraint => {\n const output: any = {\n constraint: { type: typeName, [typeName]: constraint.constraint },\n failureMessage: constraint.failureMessage,\n };\n return { constraint: output as DataConstraintWrapper };\n })\n : [];\n\n const baseType: BaseType = convertValueTypeTypeToBaseType(type.type);\n\n const vt: ValueTypeDefinitionVersion = {\n apiName,\n packageNamespace: namespace.substring(0, namespace.length - 1),\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: convertUserValueTypeStatusToValueTypeStatus(valueTypeDef.status),\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n __type: OntologyEntityTypeEnum.VALUE_TYPE,\n };\n updateOntology(vt);\n return vt;\n}\n\nexport function convertUserValueTypeStatusToValueTypeStatus(\n status: UserValueTypeStatus | undefined,\n): ValueTypeStatus {\n if (typeof status === \"object\" && status.type === \"deprecated\") {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: status.replacedBy,\n },\n };\n }\n return { type: \"active\", active: {} };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AA4C5B,SAASC,8BAA8BA,CACrCC,SAAiC,EACvB;EACV,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE,CACnC;EACA,QAAQ,IAAI;IACV,KAAM,OAAOA,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,OAAO;MAC/D,OAAO;QACLA,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;UACLC,WAAW,EAAEJ,8BAA8B,CAACC,SAAS,CAACG,WAAW;QACnE;MACF,CAAC;IACH,KAAM,OAAOH,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,QAAQ;MAChE,OAAO;QACLA,IAAI,EAAE,UAAU;QAChBG,QAAQ,EAAE;UACRC,MAAM,EAAEL,SAAS,CAACK,MAAM,CAACC,GAAG,CAACC,KAAK,KAAK;YACrCC,UAAU,EAAED,KAAK,CAACC,UAAU;YAC5BC,QAAQ,EAAEV,8BAA8B,CAACQ,KAAK,CAACE,QAAQ;UACzD,CAAC,CAAC;QACJ;MACF,CAAC;IACH,KAAM,OAAOT,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACC,IAAI,KAAK,KAAK;MAC7D,OAAO;QACLA,IAAI,EAAE,KAAK;QACXK,GAAG,EAAE;UACHI,OAAO,EAAEX,8BAA8B,CAACC,SAAS,CAACU,OAAO,CAAC;U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QAAQ,IAAIA,MAAM,CAACzC,IAAI,KAAK,YAAY,EAAE;IAC9D,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB6C,UAAU,EAAE;QACVC,OAAO,EAAEL,MAAM,CAACK,OAAO;QACvBC,QAAQ,EAAEN,MAAM,CAACM,QAAQ;QACzBC,UAAU,EAAEP,MAAM,CAACO;MACrB;IACF,CAAC;EACH;EACA,OAAO;IAAEhD,IAAI,EAAE,QAAQ;IAAEiD,MAAM,EAAE,CAAC;EAAE,CAAC;AACvC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPropertyType.js","names":[],"sources":["ObjectPropertyType.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\nimport type {\n OntologyIrBaseFormatter,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { Nullability } from \"../properties/Nullability.js\";\nimport type { PropertyTypeType } from \"../properties/PropertyTypeType.js\";\nimport type { SharedPropertyType } from \"../properties/SharedPropertyType.js\";\nimport type { ValueTypeDefinitionVersion } from \"../values/ValueTypeDefinitionVersion.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectPropertyType = RequiredFields<\n Partial<ObjectPropertyTypeInner>,\n \"apiName\" | \"type\" | \"displayName\"\n>;\n\nexport interface ObjectPropertyTypeInner {\n // <These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n apiName: string; // was: ObjectTypeFieldApiName;\n\n // FIXME: This still depends on conjure types\n baseFormatter?: OntologyIrBaseFormatter | null | undefined;\n indexedForSearch: boolean;\n typeClasses: Array<{\n kind: string;\n name: string;\n }>;\n // </These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n type: PropertyTypeType;\n array?: boolean;\n valueType: ValueTypeDefinitionVersion;\n sharedPropertyType: SharedPropertyType;\n description: string | undefined;\n displayName: string;\n visibility: Visibility;\n nullability?: Nullability;\n status?: ObjectTypeStatus;\n editOnly?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectPropertyType.js","names":[],"sources":["ObjectPropertyType.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\nimport type {\n OntologyIrBaseFormatter,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { Nullability } from \"../properties/Nullability.js\";\nimport type { PropertyTypeType } from \"../properties/PropertyTypeType.js\";\nimport type { ReducerType } from \"../properties/ReducerType.js\";\nimport type { SharedPropertyType } from \"../properties/SharedPropertyType.js\";\nimport type { ValueTypeDefinitionVersion } from \"../values/ValueTypeDefinitionVersion.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectPropertyType = RequiredFields<\n Partial<ObjectPropertyTypeInner>,\n \"apiName\" | \"type\" | \"displayName\"\n>;\n\nexport interface ObjectPropertyTypeInner {\n // <These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n apiName: string; // was: ObjectTypeFieldApiName;\n\n // FIXME: This still depends on conjure types\n baseFormatter?: OntologyIrBaseFormatter | null | undefined;\n indexedForSearch: boolean;\n typeClasses: Array<{\n kind: string;\n name: string;\n }>;\n // </These values are taken from OntologyIrPropertyType (Old code used an Omit)>\n type: PropertyTypeType;\n array?: boolean;\n reducers?: Array<ReducerType>;\n valueType: ValueTypeDefinitionVersion;\n sharedPropertyType: SharedPropertyType;\n description: string | undefined;\n displayName: string;\n visibility: Visibility;\n nullability?: Nullability;\n status?: ObjectTypeStatus;\n editOnly?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyTypeType.js","names":["isPropertyTypeType","v","type","isExotic","undefined","includes","isStruct"],"sources":["PropertyTypeType.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\nimport type { StructFieldType } from \"@osdk/client.unstable\";\n\nexport type PropertyTypeType =\n | PropertyTypeTypePrimitive\n | PropertyTypeTypeExotic;\n\nexport type PropertyTypeTypePrimitive =\n | \"boolean\"\n | \"byte\"\n | \"date\"\n | \"decimal\"\n | \"double\"\n | \"float\"\n | \"integer\"\n | \"long\"\n | \"short\"\n | \"string\"\n | \"timestamp\"\n | \"attachment\";\n\nexport type PropertyTypeTypeExotic =\n | \"geopoint\"\n | \"geoshape\"\n | \"mediaReference\"\n | \"geotimeSeries\"\n | PropertyTypeTypeMarking\n | PropertyTypeTypeStruct\n | PropertyTypeTypeString\n | PropertyTypeTypeDecimal;\n\ntype PropertyTypeTypeMarking = {\n type: \"marking\";\n markingType: \"MANDATORY\" | \"CBAC\";\n markingInputGroupName: string;\n};\n\nexport type PropertyTypeTypeStruct = {\n type: \"struct\";\n structDefinition: {\n [api_name: string]:\n | StructPropertyType\n | Exclude<PropertyTypeTypesWithoutStruct, PropertyTypeTypeMarking>;\n };\n};\n\ntype PropertyTypeTypeString = {\n type: \"string\";\n isLongText?: boolean;\n supportsEfficientLeadingWildcard?: boolean;\n supportsExactMatching?: boolean;\n supportsFullTextRegex?: boolean;\n enableAsciiFolding?: boolean;\n};\n\ntype PropertyTypeTypeDecimal = {\n type: \"decimal\";\n precision?: number;\n scale?: number;\n};\n\nexport type PropertyTypeTypesWithoutStruct = Exclude<\n PropertyTypeType,\n PropertyTypeTypeStruct\n>;\nexport function 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}\nexport function isExotic(\n type: PropertyTypeType | undefined,\n): type is PropertyTypeTypeExotic {\n if (type === undefined) {\n return false;\n }\n if (typeof type === \"string\") {\n return [\"geopoint\", \"geoshape\", \"mediaReference\", \"geotimeSeries\"].includes(\n type,\n );\n } else if (typeof type === \"object\" && type != null) {\n return type.type === \"marking\" || type.type === \"struct\"\n || type.type === \"string\"\n || type.type === \"decimal\";\n }\n return false;\n}\nexport function isStruct(\n type: PropertyTypeType,\n): type is PropertyTypeTypeStruct {\n return typeof type === \"object\" && type.type === \"struct\";\n}\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport interface StructPropertyType extends\n Optional<\n Omit<\n StructFieldType,\n \"fieldType\" | \"structFieldRid\" | \"apiName\"\n >,\n \"typeClasses\" | \"aliases\"\n >\n{\n fieldType: PropertyTypeTypesWithoutStruct;\n requireImplementation?: boolean;\n}\n"],"mappings":"AAAA;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eType","v","type","isExotic","undefined","includes","isStruct"],"sources":["PropertyTypeType.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\nimport type { StructFieldType } from \"@osdk/client.unstable\";\n\nexport type PropertyTypeType =\n | PropertyTypeTypePrimitive\n | PropertyTypeTypeExotic;\n\nexport type PropertyTypeTypePrimitive =\n | \"boolean\"\n | \"byte\"\n | \"date\"\n | \"decimal\"\n | \"double\"\n | \"float\"\n | \"integer\"\n | \"long\"\n | \"short\"\n | \"string\"\n | \"timestamp\"\n | \"attachment\";\n\nexport type PropertyTypeTypeExotic =\n | \"geopoint\"\n | \"geoshape\"\n | \"mediaReference\"\n | \"geotimeSeries\"\n | PropertyTypeTypeMarking\n | PropertyTypeTypeStruct\n | PropertyTypeTypeString\n | PropertyTypeTypeDecimal;\n\ntype PropertyTypeTypeMarking = {\n type: \"marking\";\n markingType: \"MANDATORY\" | \"CBAC\";\n markingInputGroupName: string;\n};\n\nexport type PropertyTypeTypeStruct = {\n type: \"struct\";\n structDefinition: {\n [api_name: string]:\n | StructPropertyType\n | Exclude<PropertyTypeTypesWithoutStruct, PropertyTypeTypeMarking>;\n };\n mainValue?: {\n fields: string | Array<string>;\n // TODO(ethana): we can infer this type from fields\n type: PropertyTypeType;\n };\n};\n\ntype PropertyTypeTypeString = {\n type: \"string\";\n isLongText?: boolean;\n supportsEfficientLeadingWildcard?: boolean;\n supportsExactMatching?: boolean;\n supportsFullTextRegex?: boolean;\n enableAsciiFolding?: boolean;\n};\n\ntype PropertyTypeTypeDecimal = {\n type: \"decimal\";\n precision?: number;\n scale?: number;\n};\n\nexport type PropertyTypeTypesWithoutStruct = Exclude<\n PropertyTypeType,\n PropertyTypeTypeStruct\n>;\nexport function 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}\nexport function isExotic(\n type: PropertyTypeType | undefined,\n): type is PropertyTypeTypeExotic {\n if (type === undefined) {\n return false;\n }\n if (typeof type === \"string\") {\n return [\"geopoint\", \"geoshape\", \"mediaReference\", \"geotimeSeries\"].includes(\n type,\n );\n } else if (typeof type === \"object\" && type != null) {\n return type.type === \"marking\" || type.type === \"struct\"\n || type.type === \"string\"\n || type.type === \"decimal\";\n }\n return false;\n}\nexport function isStruct(\n type: PropertyTypeType,\n): type is PropertyTypeTypeStruct {\n return typeof type === \"object\" && type.type === \"struct\";\n}\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport interface StructPropertyType extends\n Optional<\n Omit<\n StructFieldType,\n \"fieldType\" | \"structFieldRid\" | \"apiName\"\n >,\n \"typeClasses\" | \"aliases\"\n >\n{\n fieldType: PropertyTypeTypesWithoutStruct;\n requireImplementation?: boolean;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuEA,OAAO,SAASA,kBAAkBA,CAChCC,CAAmB,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,CAACC,IAAI,KAAK,SAAU,IAC/CD,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AACxB;AACA,OAAO,SAASE,QAAQA,CACtBD,IAAkC,EACF;EAChC,IAAIA,IAAI,KAAKE,SAAS,EAAE;IACtB,OAAO,KAAK;EACd;EACA,IAAI,OAAOF,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAACG,QAAQ,CACzEH,IACF,CAAC;EACH,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,IAAI,IAAI,EAAE;IACnD,OAAOA,IAAI,CAACA,IAAI,KAAK,SAAS,IAAIA,IAAI,CAACA,IAAI,KAAK,QAAQ,IACnDA,IAAI,CAACA,IAAI,KAAK,QAAQ,IACtBA,IAAI,CAACA,IAAI,KAAK,SAAS;EAC9B;EACA,OAAO,KAAK;AACd;AACA,OAAO,SAASI,QAAQA,CACtBJ,IAAsB,EACU;EAChC,OAAO,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACA,IAAI,KAAK,QAAQ;AAC3D","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ReducerType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReducerType.js","names":[],"sources":["ReducerType.ts"],"sourcesContent":["/*\n * Copyright 2026 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\nexport type ReducerType = {\n direction:\n | \"ascending\" // first (A -> Z) value, least recent date, etc.\n | \"descending\"; // last (Z -> A) value, most recent date, etc.\n structField?: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"SharedPropertyType.js","names":[],"sources":["SharedPropertyType.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\nimport type {\n OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { TypeClass } from \"../common/TypeClass.js\";\nimport type { Nullability } from \"./Nullability.js\";\nimport type { PropertyTypeType } from \"./PropertyTypeType.js\";\n\nexport interface SharedPropertyType extends OntologyEntityBase, PropertyType {\n apiName: string;\n nonNameSpacedApiName: string;\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE;\n}\nexport interface PropertyType {\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n typeClasses?: TypeClass[];\n nullability?: Nullability;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"SharedPropertyType.js","names":[],"sources":["SharedPropertyType.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\nimport type {\n OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { TypeClass } from \"../common/TypeClass.js\";\nimport type { Nullability } from \"./Nullability.js\";\nimport type { PropertyTypeType } from \"./PropertyTypeType.js\";\nimport type { ReducerType } from \"./ReducerType.js\";\n\nexport interface SharedPropertyType extends OntologyEntityBase, PropertyType {\n apiName: string;\n nonNameSpacedApiName: string;\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE;\n}\nexport interface PropertyType {\n type: PropertyTypeType;\n array?: boolean;\n reducers?: Array<ReducerType>;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n typeClasses?: TypeClass[];\n nullability?: Nullability;\n}\n"],"mappings":"","ignoreList":[]}
@@ -950,6 +950,7 @@
950
950
  "indexedForSearch": true,
951
951
  "type": {
952
952
  "struct": {
953
+ "mainValue": undefined,
953
954
  "structFields": [
954
955
  {
955
956
  "aliases": [],
@@ -1037,6 +1038,7 @@
1037
1038
  "indexedForSearch": true,
1038
1039
  "type": {
1039
1040
  "struct": {
1041
+ "mainValue": undefined,
1040
1042
  "structFields": [
1041
1043
  {
1042
1044
  "aliases": [],
@@ -1291,6 +1293,7 @@
1291
1293
  },
1292
1294
  "type": {
1293
1295
  "struct": {
1296
+ "mainValue": undefined,
1294
1297
  "structFields": [
1295
1298
  {
1296
1299
  "aliases": [],
@@ -1384,6 +1387,7 @@
1384
1387
  "indexedForSearch": true,
1385
1388
  "type": {
1386
1389
  "struct": {
1390
+ "mainValue": undefined,
1387
1391
  "structFields": [
1388
1392
  {
1389
1393
  "aliases": [],
@@ -6414,6 +6418,7 @@
6414
6418
  },
6415
6419
  "type": {
6416
6420
  "struct": {
6421
+ "mainValue": undefined,
6417
6422
  "structFields": [
6418
6423
  {
6419
6424
  "aliases": [],