@osdk/client 2.2.0-beta.9 → 2.3.0-beta.1

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 (385) hide show
  1. package/CHANGELOG.md +370 -0
  2. package/build/browser/MinimalClientContext.js.map +1 -1
  3. package/build/browser/__unstable/ConjureSupport.js.map +1 -1
  4. package/build/browser/actions/ActionValidationError.js +1 -1
  5. package/build/browser/actions/ActionValidationError.js.map +1 -1
  6. package/build/browser/actions/actions.test.js +134 -89
  7. package/build/browser/actions/actions.test.js.map +1 -1
  8. package/build/browser/actions/applyAction.js.map +1 -1
  9. package/build/browser/createClient.js +5 -1
  10. package/build/browser/createClient.js.map +1 -1
  11. package/build/browser/createClient.test.js +14 -6
  12. package/build/browser/createClient.test.js.map +1 -1
  13. package/build/browser/createMinimalClient.js.map +1 -1
  14. package/build/browser/createMinimalClientHelper.js +25 -0
  15. package/build/browser/createMinimalClientHelper.js.map +1 -0
  16. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +36 -13
  17. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  18. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
  19. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  20. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  21. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  22. package/build/browser/fetchMetadata.js +1 -1
  23. package/build/browser/fetchMetadata.js.map +1 -1
  24. package/build/browser/fetchMetadata.test.js +11 -9
  25. package/build/browser/fetchMetadata.test.js.map +1 -1
  26. package/build/browser/index.js +0 -1
  27. package/build/browser/index.js.map +1 -1
  28. package/build/{esm/util/isOsdkBaseObject.js → browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
  29. package/build/browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
  30. package/build/browser/intellisense.test.js +17 -1
  31. package/build/browser/intellisense.test.js.map +1 -1
  32. package/build/browser/logger/BaseLogger.js +59 -0
  33. package/build/browser/logger/BaseLogger.js.map +1 -0
  34. package/build/browser/logger/BrowserLogger.js +67 -0
  35. package/build/browser/logger/BrowserLogger.js.map +1 -0
  36. package/build/browser/logger/MinimalLogger.js +39 -0
  37. package/build/browser/logger/MinimalLogger.js.map +1 -0
  38. package/build/browser/logger/MinimalLogger.test.js +60 -0
  39. package/build/browser/logger/MinimalLogger.test.js.map +1 -0
  40. package/build/browser/logger/TestLogger.js +56 -0
  41. package/build/browser/logger/TestLogger.js.map +1 -0
  42. package/build/browser/object/attachment.test.js +20 -7
  43. package/build/browser/object/attachment.test.js.map +1 -1
  44. package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  45. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  46. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  47. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +44 -33
  48. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  49. package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  50. package/build/browser/object/convertWireToOsdkObjects.js +4 -14
  51. package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
  52. package/build/browser/object/convertWireToOsdkObjects.test.js +39 -33
  53. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  54. package/build/browser/object/fetchPage.js +4 -3
  55. package/build/browser/object/fetchPage.js.map +1 -1
  56. package/build/browser/object/geotimeseriesreference.test.js +56 -134
  57. package/build/browser/object/geotimeseriesreference.test.js.map +1 -1
  58. package/build/browser/object/media.test.js +19 -14
  59. package/build/browser/object/media.test.js.map +1 -1
  60. package/build/browser/object/object.test.js +96 -89
  61. package/build/browser/object/object.test.js.map +1 -1
  62. package/build/browser/object/timeseries.test.js +119 -85
  63. package/build/browser/object/timeseries.test.js.map +1 -1
  64. package/build/browser/objectSet/InterfaceObjectSet.test.js +24 -20
  65. package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -1
  66. package/build/browser/objectSet/ObjectSet.test.js +113 -19
  67. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  68. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +2 -2
  69. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  70. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
  71. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  72. package/build/browser/objectSet/createObjectSet.js +2 -1
  73. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  74. package/build/browser/observable/internal/ActionApplication.js +4 -4
  75. package/build/browser/observable/internal/ActionApplication.js.map +1 -1
  76. package/build/browser/observable/internal/BulkObjectLoader.js +93 -0
  77. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -0
  78. package/build/browser/observable/internal/BulkObjectLoader.test.js +112 -0
  79. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -0
  80. package/build/browser/observable/internal/ListQuery.js +4 -1
  81. package/build/browser/observable/internal/ListQuery.js.map +1 -1
  82. package/build/browser/observable/internal/ObjectQuery.js +3 -6
  83. package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
  84. package/build/browser/observable/internal/OptimisticJob.js +1 -1
  85. package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
  86. package/build/browser/observable/internal/Query.js.map +1 -1
  87. package/build/browser/observable/internal/Store.js +2 -2
  88. package/build/browser/observable/internal/Store.js.map +1 -1
  89. package/build/browser/observable/internal/Store.test.js +215 -206
  90. package/build/browser/observable/internal/Store.test.js.map +1 -1
  91. package/build/browser/observable/internal/objectMatchesWhereClause.js +0 -2
  92. package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
  93. package/build/browser/observable/internal/testUtils.js +4 -3
  94. package/build/browser/observable/internal/testUtils.js.map +1 -1
  95. package/build/browser/ontology/OntologyProvider.js.map +1 -1
  96. package/build/browser/ontology/StandardOntologyProvider.js +12 -5
  97. package/build/browser/ontology/StandardOntologyProvider.js.map +1 -1
  98. package/build/browser/ontology/StandardOntologyProvider.test.js +17 -16
  99. package/build/browser/ontology/StandardOntologyProvider.test.js.map +1 -1
  100. package/build/browser/ontology/loadFullObjectMetadata.js +0 -1
  101. package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
  102. package/build/browser/ontology/loadQueryMetadata.js +5 -2
  103. package/build/browser/ontology/loadQueryMetadata.js.map +1 -1
  104. package/build/browser/public/internal.js +2 -0
  105. package/build/browser/public/internal.js.map +1 -1
  106. package/build/browser/public/unstable-do-not-use.js +1 -0
  107. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  108. package/build/browser/public-utils/osdkConfig.js +49 -0
  109. package/build/browser/public-utils/osdkConfig.js.map +1 -0
  110. package/build/browser/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
  111. package/build/browser/queries/applyQuery.js +6 -4
  112. package/build/browser/queries/applyQuery.js.map +1 -1
  113. package/build/browser/queries/queries.test.js +93 -27
  114. package/build/browser/queries/queries.test.js.map +1 -1
  115. package/build/browser/queries/types.js.map +1 -1
  116. package/build/browser/tsserver.js.map +1 -1
  117. package/build/browser/util/UserAgent.js +1 -1
  118. package/build/browser/util/extractRdpDefinition.js +140 -0
  119. package/build/browser/util/extractRdpDefinition.js.map +1 -0
  120. package/build/browser/util/extractRdpDefinition.test.js +233 -0
  121. package/build/browser/util/extractRdpDefinition.test.js.map +1 -0
  122. package/build/browser/util/{isOsdkBaseObject.js → isObjectSpecifiersObject.js} +2 -2
  123. package/build/browser/util/isObjectSpecifiersObject.js.map +1 -0
  124. package/build/browser/util/isPoint.js +20 -0
  125. package/build/browser/util/isPoint.js.map +1 -0
  126. package/build/browser/util/objectSpecifierUtils.js +48 -0
  127. package/build/browser/util/objectSpecifierUtils.js.map +1 -0
  128. package/build/browser/util/objectSpecifierUtils.test.js +42 -0
  129. package/build/browser/util/objectSpecifierUtils.test.js.map +1 -0
  130. package/build/browser/util/toDataValue.js +6 -2
  131. package/build/browser/util/toDataValue.js.map +1 -1
  132. package/build/browser/util/toDataValue.test.js +37 -16
  133. package/build/browser/util/toDataValue.test.js.map +1 -1
  134. package/build/browser/util/toDataValueQueries.js +4 -6
  135. package/build/browser/util/toDataValueQueries.js.map +1 -1
  136. package/build/cjs/{Client-DBTcM9gB.d.cts → Client-CgL2LKN9.d.cts} +6 -7
  137. package/build/cjs/{chunk-MCQVHD2F.cjs → chunk-FKI2LO2O.cjs} +232 -68
  138. package/build/cjs/chunk-FKI2LO2O.cjs.map +1 -0
  139. package/build/cjs/{chunk-EY52J5Z4.cjs → chunk-W5PFESFR.cjs} +163 -34
  140. package/build/cjs/chunk-W5PFESFR.cjs.map +1 -0
  141. package/build/cjs/index.cjs +188 -166
  142. package/build/cjs/index.cjs.map +1 -1
  143. package/build/cjs/index.d.cts +4 -24
  144. package/build/cjs/public/internal.cjs +61 -7
  145. package/build/cjs/public/internal.cjs.map +1 -1
  146. package/build/cjs/public/internal.d.cts +50 -3
  147. package/build/cjs/public/unstable-do-not-use.cjs +224 -103
  148. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  149. package/build/cjs/public/unstable-do-not-use.d.cts +12 -3
  150. package/build/esm/MinimalClientContext.js.map +1 -1
  151. package/build/esm/__unstable/ConjureSupport.js.map +1 -1
  152. package/build/esm/actions/ActionValidationError.js +1 -1
  153. package/build/esm/actions/ActionValidationError.js.map +1 -1
  154. package/build/esm/actions/actions.test.js +134 -89
  155. package/build/esm/actions/actions.test.js.map +1 -1
  156. package/build/esm/actions/applyAction.js.map +1 -1
  157. package/build/esm/createClient.js +5 -1
  158. package/build/esm/createClient.js.map +1 -1
  159. package/build/esm/createClient.test.js +14 -6
  160. package/build/esm/createClient.test.js.map +1 -1
  161. package/build/esm/createMinimalClient.js.map +1 -1
  162. package/build/esm/createMinimalClientHelper.js +25 -0
  163. package/build/esm/createMinimalClientHelper.js.map +1 -0
  164. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +36 -13
  165. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  166. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
  167. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  168. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  169. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  170. package/build/esm/fetchMetadata.js +1 -1
  171. package/build/esm/fetchMetadata.js.map +1 -1
  172. package/build/esm/fetchMetadata.test.js +11 -9
  173. package/build/esm/fetchMetadata.test.js.map +1 -1
  174. package/build/esm/index.js +0 -1
  175. package/build/esm/index.js.map +1 -1
  176. package/build/esm/{util/isOsdkObject.js → intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
  177. package/build/esm/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
  178. package/build/esm/intellisense.test.js +17 -1
  179. package/build/esm/intellisense.test.js.map +1 -1
  180. package/build/esm/logger/BaseLogger.js +59 -0
  181. package/build/esm/logger/BaseLogger.js.map +1 -0
  182. package/build/esm/logger/BrowserLogger.js +67 -0
  183. package/build/esm/logger/BrowserLogger.js.map +1 -0
  184. package/build/esm/logger/MinimalLogger.js +39 -0
  185. package/build/esm/logger/MinimalLogger.js.map +1 -0
  186. package/build/esm/logger/MinimalLogger.test.js +60 -0
  187. package/build/esm/logger/MinimalLogger.test.js.map +1 -0
  188. package/build/esm/logger/TestLogger.js +56 -0
  189. package/build/esm/logger/TestLogger.js.map +1 -0
  190. package/build/esm/object/attachment.test.js +20 -7
  191. package/build/esm/object/attachment.test.js.map +1 -1
  192. package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  193. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  194. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  195. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +44 -33
  196. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  197. package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  198. package/build/esm/object/convertWireToOsdkObjects.js +4 -14
  199. package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
  200. package/build/esm/object/convertWireToOsdkObjects.test.js +39 -33
  201. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  202. package/build/esm/object/fetchPage.js +4 -3
  203. package/build/esm/object/fetchPage.js.map +1 -1
  204. package/build/esm/object/geotimeseriesreference.test.js +56 -134
  205. package/build/esm/object/geotimeseriesreference.test.js.map +1 -1
  206. package/build/esm/object/media.test.js +19 -14
  207. package/build/esm/object/media.test.js.map +1 -1
  208. package/build/esm/object/object.test.js +96 -89
  209. package/build/esm/object/object.test.js.map +1 -1
  210. package/build/esm/object/timeseries.test.js +119 -85
  211. package/build/esm/object/timeseries.test.js.map +1 -1
  212. package/build/esm/objectSet/InterfaceObjectSet.test.js +24 -20
  213. package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -1
  214. package/build/esm/objectSet/ObjectSet.test.js +113 -19
  215. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  216. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +2 -2
  217. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  218. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
  219. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  220. package/build/esm/objectSet/createObjectSet.js +2 -1
  221. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  222. package/build/esm/observable/internal/ActionApplication.js +4 -4
  223. package/build/esm/observable/internal/ActionApplication.js.map +1 -1
  224. package/build/esm/observable/internal/BulkObjectLoader.js +93 -0
  225. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -0
  226. package/build/esm/observable/internal/BulkObjectLoader.test.js +112 -0
  227. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -0
  228. package/build/esm/observable/internal/ListQuery.js +4 -1
  229. package/build/esm/observable/internal/ListQuery.js.map +1 -1
  230. package/build/esm/observable/internal/ObjectQuery.js +3 -6
  231. package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
  232. package/build/esm/observable/internal/OptimisticJob.js +1 -1
  233. package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
  234. package/build/esm/observable/internal/Query.js.map +1 -1
  235. package/build/esm/observable/internal/Store.js +2 -2
  236. package/build/esm/observable/internal/Store.js.map +1 -1
  237. package/build/esm/observable/internal/Store.test.js +215 -206
  238. package/build/esm/observable/internal/Store.test.js.map +1 -1
  239. package/build/esm/observable/internal/objectMatchesWhereClause.js +0 -2
  240. package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
  241. package/build/esm/observable/internal/testUtils.js +4 -3
  242. package/build/esm/observable/internal/testUtils.js.map +1 -1
  243. package/build/esm/ontology/OntologyProvider.js.map +1 -1
  244. package/build/esm/ontology/StandardOntologyProvider.js +12 -5
  245. package/build/esm/ontology/StandardOntologyProvider.js.map +1 -1
  246. package/build/esm/ontology/StandardOntologyProvider.test.js +17 -16
  247. package/build/esm/ontology/StandardOntologyProvider.test.js.map +1 -1
  248. package/build/esm/ontology/loadFullObjectMetadata.js +0 -1
  249. package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
  250. package/build/esm/ontology/loadQueryMetadata.js +5 -2
  251. package/build/esm/ontology/loadQueryMetadata.js.map +1 -1
  252. package/build/esm/public/internal.js +2 -0
  253. package/build/esm/public/internal.js.map +1 -1
  254. package/build/esm/public/unstable-do-not-use.js +1 -0
  255. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  256. package/build/esm/public-utils/osdkConfig.js +49 -0
  257. package/build/esm/public-utils/osdkConfig.js.map +1 -0
  258. package/build/esm/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
  259. package/build/esm/queries/applyQuery.js +6 -4
  260. package/build/esm/queries/applyQuery.js.map +1 -1
  261. package/build/esm/queries/queries.test.js +93 -27
  262. package/build/esm/queries/queries.test.js.map +1 -1
  263. package/build/esm/queries/types.js.map +1 -1
  264. package/build/esm/tsserver.js.map +1 -1
  265. package/build/esm/util/UserAgent.js +1 -1
  266. package/build/esm/util/extractRdpDefinition.js +140 -0
  267. package/build/esm/util/extractRdpDefinition.js.map +1 -0
  268. package/build/esm/util/extractRdpDefinition.test.js +233 -0
  269. package/build/esm/util/extractRdpDefinition.test.js.map +1 -0
  270. package/build/{browser/util/isOsdkObject.js → esm/util/isObjectSpecifiersObject.js} +2 -2
  271. package/build/esm/util/isObjectSpecifiersObject.js.map +1 -0
  272. package/build/esm/util/isPoint.js +20 -0
  273. package/build/esm/util/isPoint.js.map +1 -0
  274. package/build/esm/util/objectSpecifierUtils.js +48 -0
  275. package/build/esm/util/objectSpecifierUtils.js.map +1 -0
  276. package/build/esm/util/objectSpecifierUtils.test.js +42 -0
  277. package/build/esm/util/objectSpecifierUtils.test.js.map +1 -0
  278. package/build/esm/util/toDataValue.js +6 -2
  279. package/build/esm/util/toDataValue.js.map +1 -1
  280. package/build/esm/util/toDataValue.test.js +37 -16
  281. package/build/esm/util/toDataValue.test.js.map +1 -1
  282. package/build/esm/util/toDataValueQueries.js +4 -6
  283. package/build/esm/util/toDataValueQueries.js.map +1 -1
  284. package/build/types/MinimalClientContext.d.ts +1 -1
  285. package/build/types/MinimalClientContext.d.ts.map +1 -1
  286. package/build/types/__unstable/ConjureSupport.d.ts +2 -2
  287. package/build/types/actions/applyAction.d.ts +1 -2
  288. package/build/types/actions/applyAction.d.ts.map +1 -1
  289. package/build/types/createClient.d.ts +1 -1
  290. package/build/types/createClient.d.ts.map +1 -1
  291. package/build/types/createClient.test.d.ts +2 -1
  292. package/build/types/createClient.test.d.ts.map +1 -1
  293. package/build/types/createMinimalClientHelper.d.ts +1 -0
  294. package/build/types/createMinimalClientHelper.d.ts.map +1 -0
  295. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
  296. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
  297. package/build/types/index.d.ts +4 -6
  298. package/build/types/index.d.ts.map +1 -1
  299. package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts +1 -0
  300. package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts.map +1 -0
  301. package/build/types/logger/BaseLogger.d.ts +33 -0
  302. package/build/types/logger/BaseLogger.d.ts.map +1 -0
  303. package/build/types/logger/BrowserLogger.d.ts +9 -0
  304. package/build/types/logger/BrowserLogger.d.ts.map +1 -0
  305. package/build/types/logger/MinimalLogger.d.ts +9 -0
  306. package/build/types/logger/MinimalLogger.d.ts.map +1 -0
  307. package/build/types/logger/MinimalLogger.test.d.ts +1 -0
  308. package/build/types/logger/MinimalLogger.test.d.ts.map +1 -0
  309. package/build/types/logger/TestLogger.d.ts +14 -0
  310. package/build/types/logger/TestLogger.d.ts.map +1 -0
  311. package/build/types/object/convertWireToOsdkObjects.d.ts +4 -4
  312. package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
  313. package/build/types/object/fetchPage.d.ts.map +1 -1
  314. package/build/types/object/object.test.d.ts.map +1 -1
  315. package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
  316. package/build/types/observable/internal/ActionApplication.d.ts +2 -2
  317. package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
  318. package/build/types/observable/internal/BulkObjectLoader.d.ts +8 -0
  319. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -0
  320. package/build/types/observable/internal/BulkObjectLoader.test.d.ts +1 -0
  321. package/build/types/observable/internal/BulkObjectLoader.test.d.ts.map +1 -0
  322. package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
  323. package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
  324. package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
  325. package/build/types/observable/internal/Query.d.ts +2 -2
  326. package/build/types/observable/internal/Query.d.ts.map +1 -1
  327. package/build/types/observable/internal/Store.d.ts +2 -2
  328. package/build/types/observable/internal/Store.d.ts.map +1 -1
  329. package/build/types/observable/internal/testUtils.d.ts +1 -2
  330. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  331. package/build/types/ontology/OntologyProvider.d.ts +1 -1
  332. package/build/types/ontology/OntologyProvider.d.ts.map +1 -1
  333. package/build/types/ontology/loadQueryMetadata.d.ts +1 -1
  334. package/build/types/ontology/loadQueryMetadata.d.ts.map +1 -1
  335. package/build/types/public/internal.d.ts +2 -0
  336. package/build/types/public/internal.d.ts.map +1 -1
  337. package/build/types/public/unstable-do-not-use.d.ts +4 -2
  338. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  339. package/build/types/public-utils/osdkConfig.d.ts +8 -0
  340. package/build/types/public-utils/osdkConfig.d.ts.map +1 -0
  341. package/build/types/public-utils/vite-env.d.d.ts +3 -0
  342. package/build/types/public-utils/vite-env.d.d.ts.map +1 -0
  343. package/build/types/queries/applyQuery.d.ts +2 -2
  344. package/build/types/queries/applyQuery.d.ts.map +1 -1
  345. package/build/types/queries/types.d.ts +1 -1
  346. package/build/types/queries/types.d.ts.map +1 -1
  347. package/build/types/tsserver.d.ts +1 -1
  348. package/build/types/tsserver.d.ts.map +1 -1
  349. package/build/types/util/extractRdpDefinition.d.ts +4 -0
  350. package/build/types/util/extractRdpDefinition.d.ts.map +1 -0
  351. package/build/types/util/extractRdpDefinition.test.d.ts +1 -0
  352. package/build/types/util/extractRdpDefinition.test.d.ts.map +1 -0
  353. package/build/types/util/isObjectSpecifiersObject.d.ts +5 -0
  354. package/build/types/util/isObjectSpecifiersObject.d.ts.map +1 -0
  355. package/build/types/util/isPoint.d.ts +1 -0
  356. package/build/types/util/isPoint.d.ts.map +1 -0
  357. package/build/types/util/objectSpecifierUtils.d.ts +24 -0
  358. package/build/types/util/objectSpecifierUtils.d.ts.map +1 -0
  359. package/build/types/util/objectSpecifierUtils.test.d.ts +1 -0
  360. package/build/types/util/objectSpecifierUtils.test.d.ts.map +1 -0
  361. package/package.json +19 -18
  362. package/build/browser/Logger.js +0 -2
  363. package/build/browser/Logger.js.map +0 -1
  364. package/build/browser/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
  365. package/build/browser/util/isOsdkBaseObject.js.map +0 -1
  366. package/build/browser/util/isOsdkObject.js.map +0 -1
  367. package/build/cjs/chunk-EY52J5Z4.cjs.map +0 -1
  368. package/build/cjs/chunk-MCQVHD2F.cjs.map +0 -1
  369. package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
  370. package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
  371. package/build/cjs/graphql-RGM5SRWV.cjs +0 -10532
  372. package/build/cjs/graphql-RGM5SRWV.cjs.map +0 -1
  373. package/build/esm/Logger.js +0 -2
  374. package/build/esm/Logger.js.map +0 -1
  375. package/build/esm/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
  376. package/build/esm/util/isOsdkBaseObject.js.map +0 -1
  377. package/build/esm/util/isOsdkObject.js.map +0 -1
  378. package/build/types/Logger.d.ts +0 -17
  379. package/build/types/Logger.d.ts.map +0 -1
  380. package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts +0 -2
  381. package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts.map +0 -1
  382. package/build/types/util/isOsdkBaseObject.d.ts +0 -2
  383. package/build/types/util/isOsdkBaseObject.d.ts.map +0 -1
  384. package/build/types/util/isOsdkObject.d.ts +0 -2
  385. package/build/types/util/isOsdkObject.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchPage","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","fetchPageByRid","objectOrInterfaceType","rids","value","createClient"],"sources":["createClient.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 ActionDefinition,\n FetchPageArgs,\n FilteredPropertyKeys,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchPage } from \"./object/fetchPage.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n [rid],\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends FilteredPropertyKeys<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:\n return {\n fetchPageByRid: async <\n Q extends ObjectOrInterfaceDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectOrInterfaceType: Q,\n rids: string[],\n options: FetchPageArgs<Q, L, R, any, S> = {},\n ) => {\n return await fetchPage(\n clientCtx,\n objectOrInterfaceType,\n options,\n createWithRid(rids),\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rids: string[],\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": rids,\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACT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AAC;YACH;UACF,CAAC;QAEH,KAAKxD,iDAAiD,CAACyC,IAAI;UACzD,OAAO;YACLgB,cAAc,EAAE,MAAAA,CAMdC,qBAAwB,EACxBC,IAAc,EACd9B,OAAuC,GAAG,CAAC,CAAC,KACzC;cACH,OAAO,MAAMnB,SAAS,CACpBM,SAAS,EACT0C,qBAAqB,EACrB7B,OAAO,EACPiB,aAAa,CAACa,IAAI,CACpB,CAAC;YACH;UACF,CAAC;MACL;MAEA,MAAM,IAAI1B,KAAK,CAAC,iBAAiB,CAAC;IACpC,CAAC,MAAM;MACL,MAAM,IAAIA,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC,EAWC;IACE,CAAC7B,sBAAsB,GAAG;MACxBwD,KAAK,EAAE5C;IACT,CAAC;IACD,CARgD,qBAAqB,GAQ9C;MACrB4C,KAAK,EAAE5C;IACT,CAAC;IACD,CAACT,iBAAiB,GAAG;MACnBqD,KAAK,EAAE5C;IACT,CAAC;IACDmB,aAAa,EAAE;MACbyB,KAAK,EAAEzB;IACT;EACF,CACF,CAAC;EAED,OAAOC,MAAM;AACf;AAEA,OAAO,MAAMyB,YAQF,GAAGrC,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASkC,aAAaA,CACpBa,IAAc,EACd;EAMA,OAL+B;IAC7BnB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAEmB;EACb,CAAC;AAGH","ignoreList":[]}
1
+ {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","MinimalLogger","fetchPage","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","logger","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","fetchPageByRid","objectOrInterfaceType","rids","value","createClient"],"sources":["createClient.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 ActionDefinition,\n FetchPageArgs,\n InterfaceDefinition,\n Logger,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport { MinimalLogger } from \"./logger/MinimalLogger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchPage } from \"./object/fetchPage.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n { ...options, logger: options?.logger ?? new MinimalLogger() },\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n [rid],\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys.Filtered<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:\n return {\n fetchPageByRid: async <\n Q extends ObjectOrInterfaceDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectOrInterfaceType: Q,\n rids: string[],\n options: FetchPageArgs<Q, L, R, any, S> = {},\n ) => {\n return await fetchPage(\n clientCtx,\n objectOrInterfaceType,\n options,\n createWithRid(rids),\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rids: string[],\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": rids,\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC,EAChC;IACA;IACA;IACA;IACA;IACA,IAAI,CAACZ,WAAW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vBM,OAAO,EAAE;cACX,CACF,CAAC;YACH;UACF,CAAC;QAEH,KAAK1D,iDAAiD,CAAC2C,IAAI;UACzD,OAAO;YACLgB,cAAc,EAAE,MAAAA,CAMdC,qBAAwB,EACxBC,IAAc,EACd/B,OAAuC,GAAG,CAAC,CAAC,KACzC;cACH,OAAO,MAAMnB,SAAS,CACpBM,SAAS,EACT2C,qBAAqB,EACrB9B,OAAO,EACPkB,aAAa,CAACa,IAAI,CACpB,CAAC;YACH;UACF,CAAC;MACL;MAEA,MAAM,IAAI3B,KAAK,CAAC,iBAAiB,CAAC;IACpC,CAAC,MAAM;MACL,MAAM,IAAIA,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC,EAWC;IACE,CAAC9B,sBAAsB,GAAG;MACxB0D,KAAK,EAAE7C;IACT,CAAC;IACD,CARgD,qBAAqB,GAQ9C;MACrB6C,KAAK,EAAE7C;IACT,CAAC;IACD,CAACV,iBAAiB,GAAG;MACnBuD,KAAK,EAAE7C;IACT,CAAC;IACDoB,aAAa,EAAE;MACbyB,KAAK,EAAEzB;IACT;EACF,CACF,CAAC;EAED,OAAOC,MAAM;AACf;AAEA,OAAO,MAAMyB,YAQF,GAAGtC,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASmC,aAAaA,CACpBa,IAAc,EACd;EAMA,OAL+B;IAC7BnB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAEmB;EACb,CAAC;AAGH","ignoreList":[]}
@@ -16,18 +16,26 @@
16
16
 
17
17
  import { Task } from "@osdk/client.test.ontology";
18
18
  import * as SharedClientContext from "@osdk/shared.client.impl";
19
- import { mockFetchResponse, MockOntology } from "@osdk/shared.test";
20
19
  import { beforeEach, describe, expect, it, vi } from "vitest";
21
20
  import { metadataCacheClient } from "./__unstable/ConjureSupport.js";
22
21
  import { createClient } from "./createClient.js";
23
22
  import * as MakeConjureContext from "./ontology/makeConjureContext.js";
24
23
  import { USER_AGENT } from "./util/UserAgent.js";
24
+ export function mockFetchResponse(fetch, response) {
25
+ fetch.mockResolvedValueOnce({
26
+ json: () => Promise.resolve(response),
27
+ blob: () => Promise.resolve(response),
28
+ status: 200,
29
+ ok: true
30
+ });
31
+ }
25
32
  describe(createClient, () => {
26
33
  let fetchFunction;
27
34
  let client;
35
+ const ontologyRid = "ri.not.important";
28
36
  beforeEach(() => {
29
37
  fetchFunction = vi.fn();
30
- client = createClient("https://mock.com", MockOntology.metadata.ontologyRid, async () => "Token", undefined, fetchFunction);
38
+ client = createClient("https://mock.com", ontologyRid, async () => "Token", undefined, fetchFunction);
31
39
  mockFetchResponse(fetchFunction, {
32
40
  data: []
33
41
  });
@@ -48,13 +56,13 @@ describe(createClient, () => {
48
56
  describe("check url formatting", () => {
49
57
  it("urls are correctly formatted", async () => {
50
58
  const spy = vi.spyOn(SharedClientContext, "createSharedClientContext");
51
- const client = createClient("https://mock.com", MockOntology.metadata.ontologyRid, async () => "Token", undefined, fetchFunction);
59
+ const client = createClient("https://mock.com", ontologyRid, async () => "Token", undefined, fetchFunction);
52
60
  expect(spy.mock.calls[0][0]).toBe("https://mock.com/");
53
- createClient("https://mock1.com/", MockOntology.metadata.ontologyRid, async () => "Token", undefined, fetchFunction);
61
+ createClient("https://mock1.com/", ontologyRid, async () => "Token", undefined, fetchFunction);
54
62
  expect(spy.mock.calls[1][0]).toBe("https://mock1.com/");
55
- createClient("https://mock2.com/stuff/first/foo", MockOntology.metadata.ontologyRid, async () => "Token", undefined, fetchFunction);
63
+ createClient("https://mock2.com/stuff/first/foo", ontologyRid, async () => "Token", undefined, fetchFunction);
56
64
  expect(spy.mock.calls[2][0]).toBe("https://mock2.com/stuff/first/foo/");
57
- createClient("https://mock3.com/stuff/first/foo/", MockOntology.metadata.ontologyRid, async () => "Token", undefined, fetchFunction);
65
+ createClient("https://mock3.com/stuff/first/foo/", ontologyRid, async () => "Token", undefined, fetchFunction);
58
66
  expect(spy.mock.calls[3][0]).toBe("https://mock3.com/stuff/first/foo/");
59
67
  const conjureContextSpy = vi.spyOn(MakeConjureContext, "makeConjureContext");
60
68
  void metadataCacheClient({
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.test.js","names":["Task","SharedClientContext","mockFetchResponse","MockOntology","beforeEach","describe","expect","it","vi","metadataCacheClient","createClient","MakeConjureContext","USER_AGENT","fetchFunction","client","fn","metadata","ontologyRid","undefined","data","getUserAgentPartsFromMockedFetch","userAgent","mock","calls","headers","get","parts","split","fetchPage","toHaveBeenCalledTimes","toEqual","osdkMetadata","extraUserAgent","spy","spyOn","toBe","conjureContextSpy","baseUrl","ontologyProvider","getObjectDefinition","results","value"],"sources":["createClient.test.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { Task } from \"@osdk/client.test.ontology\";\nimport * as SharedClientContext from \"@osdk/shared.client.impl\";\nimport { mockFetchResponse, MockOntology } from \"@osdk/shared.test\";\nimport type { MockedFunction } from \"vitest\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { metadataCacheClient } from \"./__unstable/ConjureSupport.js\";\nimport type { Client } from \"./Client.js\";\nimport { createClient } from \"./createClient.js\";\nimport * as MakeConjureContext from \"./ontology/makeConjureContext.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\n\ndescribe(createClient, () => {\n const validOlderVersion = \"0.13.0\" as const;\n const validCurrentVersion = \"0.14.0\" as const;\n const invalidFutureVersion = \"100.100.100\" as const;\n\n let fetchFunction: MockedFunction<typeof globalThis.fetch>;\n let client: Client;\n\n beforeEach(() => {\n fetchFunction = vi.fn();\n\n client = createClient(\n \"https://mock.com\",\n MockOntology.metadata.ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n\n mockFetchResponse(fetchFunction, { data: [] });\n });\n\n describe(\"user agent passing\", () => {\n function getUserAgentPartsFromMockedFetch() {\n const userAgent = (fetchFunction.mock.calls[0][1]?.headers as Headers)\n .get(\n \"Fetch-User-Agent\",\n );\n const parts = userAgent?.split(\" \") ?? [];\n return parts;\n }\n\n it(\"works for objects\", async () => {\n await client(Task).fetchPage();\n expect(fetchFunction).toHaveBeenCalledTimes(1);\n\n const parts = getUserAgentPartsFromMockedFetch();\n expect(parts).toEqual([\n ...Task.osdkMetadata!\n .extraUserAgent\n .split(\" \"),\n USER_AGENT,\n ]);\n });\n });\n\n describe(\"check url formatting\", () => {\n it(\"urls are correctly formatted\", async () => {\n const spy = vi.spyOn(SharedClientContext, \"createSharedClientContext\");\n const client = createClient(\n \"https://mock.com\",\n MockOntology.metadata.ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[0][0]).toBe(\"https://mock.com/\");\n\n createClient(\n \"https://mock1.com/\",\n MockOntology.metadata.ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[1][0]).toBe(\"https://mock1.com/\");\n\n createClient(\n \"https://mock2.com/stuff/first/foo\",\n MockOntology.metadata.ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[2][0]).toBe(\"https://mock2.com/stuff/first/foo/\");\n\n createClient(\n \"https://mock3.com/stuff/first/foo/\",\n MockOntology.metadata.ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[3][0]).toBe(\"https://mock3.com/stuff/first/foo/\");\n\n const conjureContextSpy = vi.spyOn(\n MakeConjureContext,\n \"makeConjureContext\",\n );\n\n void metadataCacheClient(\n {\n baseUrl: \"https://mock4.com/\",\n ontologyProvider: { getObjectDefinition: async () => ({}) },\n } as any,\n );\n\n expect(\n conjureContextSpy.mock.results[0].value[\"baseUrl\"]\n + conjureContextSpy.mock.results[0].value[\"servicePath\"],\n ).toBe(\"https://mock4.com/ontology-metadata/api\");\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,4BAA4B;AACjD,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAC/D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,mBAAmB;AAEnE,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAC7D,SAASC,mBAAmB,QAAQ,gCAAgC;AAEpE,SAASC,YAAY,QAAQ,mBAAmB;AAChD,OAAO,KAAKC,kBAAkB,MAAM,kCAAkC;AACtE,SAASC,UAAU,QAAQ,qBAAqB;AAEhDP,QAAQ,CAACK,YAAY,EAAE,MAAM;EAK3B,IAAIG,aAAsD;EAC1D,IAAIC,MAAc;EAElBV,UAAU,CAAC,MAAM;IACfS,aAAa,GAAGL,EAAE,CAACO,EAAE,CAAC,CAAC;IAEvBD,MAAM,GAAGJ,YAAY,CACnB,kBAAkB,EAClBP,YAAY,CAACa,QAAQ,CAACC,WAAW,EACjC,YAAY,OAAO,EACnBC,SAAS,EACTL,aACF,CAAC;IAEDX,iBAAiB,CAACW,aAAa,EAAE;MAAEM,IAAI,EAAE;IAAG,CAAC,CAAC;EAChD,CAAC,CAAC;EAEFd,QAAQ,CAAC,oBAAoB,EAAE,MAAM;IACnC,SAASe,gCAAgCA,CAAA,EAAG;MAC1C,MAAMC,SAAS,GAAG,CAACR,aAAa,CAACS,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEC,OAAO,EACvDC,GAAG,CACF,kBACF,CAAC;MACH,MAAMC,KAAK,GAAGL,SAAS,EAA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SAAS,EACTL,aACF,CAAC;MACDP,MAAM,CAAC2B,GAAG,CAACX,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC,oCAAoC,CAAC;MAEvEzB,YAAY,CACV,oCAAoC,EACpCP,YAAY,CAACa,QAAQ,CAACC,WAAW,EACjC,YAAY,OAAO,EACnBC,SAAS,EACTL,aACF,CAAC;MACDP,MAAM,CAAC2B,GAAG,CAACX,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC,oCAAoC,CAAC;MAEvE,MAAMC,iBAAiB,GAAG5B,EAAE,CAAC0B,KAAK,CAChCvB,kBAAkB,EAClB,oBACF,CAAC;MAED,KAAKF,mBAAmB,CACtB;QACE4B,OAAO,EAAE,oBAAoB;QAC7BC,gBAAgB,EAAE;UAAEC,mBAAmB,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;QAAE;MAC5D,CACF,CAAC;MAEDjC,MAAM,CACJ8B,iBAAiB,CAACd,IAAI,CAACkB,OAAO,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,SAAS,CAAC,GAC9CL,iBAAiB,CAACd,IAAI,CAACkB,OAAO,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,aAAa,CAC3D,CAAC,CAACN,IAAI,CAAC,yCAAyC,CAAC;IACnD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createClient.test.js","names":["Task","SharedClientContext","beforeEach","describe","expect","it","vi","metadataCacheClient","createClient","MakeConjureContext","USER_AGENT","mockFetchResponse","fetch","response","mockResolvedValueOnce","json","Promise","resolve","blob","status","ok","fetchFunction","client","ontologyRid","fn","undefined","data","getUserAgentPartsFromMockedFetch","userAgent","mock","calls","headers","get","parts","split","fetchPage","toHaveBeenCalledTimes","toEqual","osdkMetadata","extraUserAgent","spy","spyOn","toBe","conjureContextSpy","baseUrl","ontologyProvider","getObjectDefinition","results","value"],"sources":["createClient.test.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { Task } from \"@osdk/client.test.ontology\";\nimport * as SharedClientContext from \"@osdk/shared.client.impl\";\nimport type { MockedFunction } from \"vitest\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { metadataCacheClient } from \"./__unstable/ConjureSupport.js\";\nimport type { Client } from \"./Client.js\";\nimport { createClient } from \"./createClient.js\";\nimport * as MakeConjureContext from \"./ontology/makeConjureContext.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\n\nexport function mockFetchResponse(\n fetch: MockedFunction<typeof globalThis.fetch>,\n response: any,\n): void {\n fetch.mockResolvedValueOnce({\n json: () => Promise.resolve(response),\n blob: () => Promise.resolve(response),\n status: 200,\n ok: true,\n } as any);\n}\n\ndescribe(createClient, () => {\n const validOlderVersion = \"0.13.0\" as const;\n const validCurrentVersion = \"0.14.0\" as const;\n const invalidFutureVersion = \"100.100.100\" as const;\n\n let fetchFunction: MockedFunction<typeof globalThis.fetch>;\n let client: Client;\n\n const ontologyRid = \"ri.not.important\";\n\n beforeEach(() => {\n fetchFunction = vi.fn();\n\n client = createClient(\n \"https://mock.com\",\n ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n\n mockFetchResponse(fetchFunction, { data: [] });\n });\n\n describe(\"user agent passing\", () => {\n function getUserAgentPartsFromMockedFetch() {\n const userAgent = (fetchFunction.mock.calls[0][1]?.headers as Headers)\n .get(\n \"Fetch-User-Agent\",\n );\n const parts = userAgent?.split(\" \") ?? [];\n return parts;\n }\n\n it(\"works for objects\", async () => {\n await client(Task).fetchPage();\n expect(fetchFunction).toHaveBeenCalledTimes(1);\n\n const parts = getUserAgentPartsFromMockedFetch();\n expect(parts).toEqual([\n ...Task.osdkMetadata!\n .extraUserAgent\n .split(\" \"),\n USER_AGENT,\n ]);\n });\n });\n\n describe(\"check url formatting\", () => {\n it(\"urls are correctly formatted\", async () => {\n const spy = vi.spyOn(SharedClientContext, \"createSharedClientContext\");\n const client = createClient(\n \"https://mock.com\",\n ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[0][0]).toBe(\"https://mock.com/\");\n\n createClient(\n \"https://mock1.com/\",\n ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[1][0]).toBe(\"https://mock1.com/\");\n\n createClient(\n \"https://mock2.com/stuff/first/foo\",\n ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[2][0]).toBe(\"https://mock2.com/stuff/first/foo/\");\n\n createClient(\n \"https://mock3.com/stuff/first/foo/\",\n ontologyRid,\n async () => \"Token\",\n undefined,\n fetchFunction,\n );\n expect(spy.mock.calls[3][0]).toBe(\"https://mock3.com/stuff/first/foo/\");\n\n const conjureContextSpy = vi.spyOn(\n MakeConjureContext,\n \"makeConjureContext\",\n );\n\n void metadataCacheClient(\n {\n baseUrl: \"https://mock4.com/\",\n ontologyProvider: { getObjectDefinition: async () => ({}) },\n } as any,\n );\n\n expect(\n conjureContextSpy.mock.results[0].value[\"baseUrl\"]\n + conjureContextSpy.mock.results[0].value[\"servicePath\"],\n ).toBe(\"https://mock4.com/ontology-metadata/api\");\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,4BAA4B;AACjD,OA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AAC,CAAC,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC,oCAAoC,CAAC;MAEvElC,YAAY,CACV,oCAAoC,EACpCe,WAAW,EACX,YAAY,OAAO,EACnBE,SAAS,EACTJ,aACF,CAAC;MACDjB,MAAM,CAACoC,GAAG,CAACX,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC,oCAAoC,CAAC;MAEvE,MAAMC,iBAAiB,GAAGrC,EAAE,CAACmC,KAAK,CAChChC,kBAAkB,EAClB,oBACF,CAAC;MAED,KAAKF,mBAAmB,CACtB;QACEqC,OAAO,EAAE,oBAAoB;QAC7BC,gBAAgB,EAAE;UAAEC,mBAAmB,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;QAAE;MAC5D,CACF,CAAC;MAED1C,MAAM,CACJuC,iBAAiB,CAACd,IAAI,CAACkB,OAAO,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,SAAS,CAAC,GAC9CL,iBAAiB,CAACd,IAAI,CAACkB,OAAO,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,aAAa,CAC3D,CAAC,CAACN,IAAI,CAAC,yCAAyC,CAAC;IACnD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"createMinimalClient.js","names":["createSharedClientContext","convertWireToOsdkObjects","convertWireToOsdkObjects2","createObjectSet","createStandardOntologyProviderFactory","USER_AGENT","createMinimalClient","metadata","baseUrl","tokenProvider","options","fetchFn","global","fetch","objectSetFactory","createOntologyProviderFactory","process","env","NODE_ENV","URL","e","hint","startsWith","Error","processedBaseUrl","pathname","endsWith","minimalClient","toString","objectFactory","objectFactory2","ontologyRid","logger","clientCacheKey","requestContext","Object","freeze","assign","ontologyProvider"],"sources":["createMinimalClient.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 { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport type { Logger } from \"./Logger.js\";\nimport type {\n ClientCacheKey,\n MinimalClient,\n MinimalClientParams,\n} from \"./MinimalClientContext.js\";\nimport {\n convertWireToOsdkObjects,\n convertWireToOsdkObjects2,\n} from \"./object/convertWireToOsdkObjects.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport type { OntologyProvider } from \"./ontology/OntologyProvider.js\";\nimport {\n createStandardOntologyProviderFactory,\n type OntologyCachingOptions,\n} from \"./ontology/StandardOntologyProvider.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\n\n/** @internal */\nexport function createMinimalClient(\n metadata: MinimalClientParams[\"metadata\"],\n baseUrl: string,\n tokenProvider: () => Promise<string>,\n options: OntologyCachingOptions & { logger?: Logger } = {},\n fetchFn: (\n input: Request | URL | string,\n init?: RequestInit | undefined,\n ) => Promise<Response> = global.fetch,\n objectSetFactory: ObjectSetFactory<any, any> = createObjectSet,\n createOntologyProviderFactory: (\n a: OntologyCachingOptions & { logger?: Logger },\n ) => (minimalClient: MinimalClient) => OntologyProvider =\n createStandardOntologyProviderFactory,\n) {\n if (process.env.NODE_ENV !== \"production\") {\n try {\n new URL(baseUrl);\n } catch (e) {\n const hint =\n !baseUrl.startsWith(\"http://\") || !baseUrl.startsWith(\"https://\")\n ? \". Did you forget to add 'http://' or 'https://'?\"\n : \"\";\n throw new Error(`Invalid stack URL: ${baseUrl}${hint}`);\n }\n }\n const processedBaseUrl = new URL(baseUrl);\n processedBaseUrl.pathname += processedBaseUrl.pathname.endsWith(\"/\")\n ? \"\"\n : \"/\";\n const minimalClient: MinimalClient = {\n ...createSharedClientContext(\n processedBaseUrl.toString(),\n tokenProvider,\n USER_AGENT,\n fetchFn,\n ),\n objectSetFactory,\n objectFactory: convertWireToOsdkObjects,\n objectFactory2: convertWireToOsdkObjects2,\n ontologyRid: metadata.ontologyRid,\n logger: options.logger,\n clientCacheKey: {} as ClientCacheKey,\n requestContext: {},\n } satisfies Omit<\n MinimalClient,\n \"ontologyProvider\"\n > as any;\n\n return Object.freeze(Object.assign(minimalClient, {\n ontologyProvider: createOntologyProviderFactory(\n options,\n )(minimalClient),\n }));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,yBAAyB,QAAQ,0BAA0B;AAOpE,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,sCAAsC;AAC7C,SAASC,eAAe,QAAQ,gCAAgC;AAGhE,SACEC,qCAAqC,QAEhC,wCAAwC;AAC/C,SAASC,UAAU,QAAQ,qBAAqB;;AAEhD;AACA,OAAO,SAASC,mBAAmBA,CACjCC,QAAyC,EACzCC,OAAe,EACfC,aAAoC,EACpCC,OAAqD,GAAG,CAAC,CAAC,EAC1DC,OAGsB,GAAGC,MAAM,CAACC,KAAK,EACrCC,gBAA4C,GAAGX,eAAe,EAC9DY,6BAEuD,GACrDX,qCAAqC,EACvC;EACA,IAAIY,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAI;MACF,IAAIC,GAAG,CAACX,OAAO,CAAC;IAClB,CAAC,CAAC,OAAOY,CAAC,EAAE;MACV,MAAMC,IAAI,GACR,CAACb,OAAO,CAACc,UAAU,CAAC,SAAS,CAAC,IAAI,CAACd,OAAO,CAACc,UAAU,CAAC,UAAU,CAAC,GAC7D,kDAAkD,GAClD,EAAE;MACR,MAAM,IAAIC,KAAK,CAAC,sBAAsBf,OAAO,GAAGa,IAAI,EAAE,CAAC;IACzD;EACF;EACA,MAAMG,gBAAgB,GAAG,IAAIL,GAAG,CAACX,OAAO,CAAC;EACzCgB,gBAAgB,CAACC,QAAQ,IAAID,gBAAgB,CAACC,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC,GAChE,EAAE,GACF,GAAG;EACP,MAAMC,aAA4B,GAAG;IACnC,GAAG3B,yBAAyB,CAC1BwB,gBAAgB,CAACI,QAAQ,CAAC,CAAC,EAC3BnB,aAAa,EACbJ,UAAU,EACVM,OACF,CAAC;IACDG,gBAAgB;IAChBe,aAAa,EAAE5B,wBAAwB;IACvC6B,cAAc,EAAE5B,yBAAyB;IACzC6B,WAAW,EAAExB,QAAQ,CAACwB,WAAW;IACjCC,MAAM,EAAEtB,OAAO,CAACsB,MAAM;IACtBC,cAAc,EAAE,CAAC,CAAmB;IACpCC,cAAc,EAAE,CAAC;EACnB,CAGQ;EAER,OAAOC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACV,aAAa,EAAE;IAChDW,gBAAgB,EAAEvB,6BAA6B,CAC7CL,OACF,CAAC,CAACiB,aAAa;EACjB,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"createMinimalClient.js","names":["createSharedClientContext","convertWireToOsdkObjects","convertWireToOsdkObjects2","createObjectSet","createStandardOntologyProviderFactory","USER_AGENT","createMinimalClient","metadata","baseUrl","tokenProvider","options","fetchFn","global","fetch","objectSetFactory","createOntologyProviderFactory","process","env","NODE_ENV","URL","e","hint","startsWith","Error","processedBaseUrl","pathname","endsWith","minimalClient","toString","objectFactory","objectFactory2","ontologyRid","logger","clientCacheKey","requestContext","Object","freeze","assign","ontologyProvider"],"sources":["createMinimalClient.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 { Logger } from \"@osdk/api\";\nimport { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport type {\n ClientCacheKey,\n MinimalClient,\n MinimalClientParams,\n} from \"./MinimalClientContext.js\";\nimport {\n convertWireToOsdkObjects,\n convertWireToOsdkObjects2,\n} from \"./object/convertWireToOsdkObjects.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport type { OntologyProvider } from \"./ontology/OntologyProvider.js\";\nimport {\n createStandardOntologyProviderFactory,\n type OntologyCachingOptions,\n} from \"./ontology/StandardOntologyProvider.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\n\n/** @internal */\nexport function createMinimalClient(\n metadata: MinimalClientParams[\"metadata\"],\n baseUrl: string,\n tokenProvider: () => Promise<string>,\n options: OntologyCachingOptions & { logger?: Logger } = {},\n fetchFn: (\n input: Request | URL | string,\n init?: RequestInit | undefined,\n ) => Promise<Response> = global.fetch,\n objectSetFactory: ObjectSetFactory<any, any> = createObjectSet,\n createOntologyProviderFactory: (\n a: OntologyCachingOptions & { logger?: Logger },\n ) => (minimalClient: MinimalClient) => OntologyProvider =\n createStandardOntologyProviderFactory,\n) {\n if (process.env.NODE_ENV !== \"production\") {\n try {\n new URL(baseUrl);\n } catch (e) {\n const hint =\n !baseUrl.startsWith(\"http://\") || !baseUrl.startsWith(\"https://\")\n ? \". Did you forget to add 'http://' or 'https://'?\"\n : \"\";\n throw new Error(`Invalid stack URL: ${baseUrl}${hint}`);\n }\n }\n const processedBaseUrl = new URL(baseUrl);\n processedBaseUrl.pathname += processedBaseUrl.pathname.endsWith(\"/\")\n ? \"\"\n : \"/\";\n const minimalClient: MinimalClient = {\n ...createSharedClientContext(\n processedBaseUrl.toString(),\n tokenProvider,\n USER_AGENT,\n fetchFn,\n ),\n objectSetFactory,\n objectFactory: convertWireToOsdkObjects,\n objectFactory2: convertWireToOsdkObjects2,\n ontologyRid: metadata.ontologyRid,\n logger: options.logger,\n clientCacheKey: {} as ClientCacheKey,\n requestContext: {},\n } satisfies Omit<\n MinimalClient,\n \"ontologyProvider\"\n > as any;\n\n return Object.freeze(Object.assign(minimalClient, {\n ontologyProvider: createOntologyProviderFactory(\n options,\n )(minimalClient),\n }));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,yBAAyB,QAAQ,0BAA0B;AAMpE,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,sCAAsC;AAC7C,SAASC,eAAe,QAAQ,gCAAgC;AAGhE,SACEC,qCAAqC,QAEhC,wCAAwC;AAC/C,SAASC,UAAU,QAAQ,qBAAqB;;AAEhD;AACA,OAAO,SAASC,mBAAmBA,CACjCC,QAAyC,EACzCC,OAAe,EACfC,aAAoC,EACpCC,OAAqD,GAAG,CAAC,CAAC,EAC1DC,OAGsB,GAAGC,MAAM,CAACC,KAAK,EACrCC,gBAA4C,GAAGX,eAAe,EAC9DY,6BAEuD,GACrDX,qCAAqC,EACvC;EACA,IAAIY,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAI;MACF,IAAIC,GAAG,CAACX,OAAO,CAAC;IAClB,CAAC,CAAC,OAAOY,CAAC,EAAE;MACV,MAAMC,IAAI,GACR,CAACb,OAAO,CAACc,UAAU,CAAC,SAAS,CAAC,IAAI,CAACd,OAAO,CAACc,UAAU,CAAC,UAAU,CAAC,GAC7D,kDAAkD,GAClD,EAAE;MACR,MAAM,IAAIC,KAAK,CAAC,sBAAsBf,OAAO,GAAGa,IAAI,EAAE,CAAC;IACzD;EACF;EACA,MAAMG,gBAAgB,GAAG,IAAIL,GAAG,CAACX,OAAO,CAAC;EACzCgB,gBAAgB,CAACC,QAAQ,IAAID,gBAAgB,CAACC,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC,GAChE,EAAE,GACF,GAAG;EACP,MAAMC,aAA4B,GAAG;IACnC,GAAG3B,yBAAyB,CAC1BwB,gBAAgB,CAACI,QAAQ,CAAC,CAAC,EAC3BnB,aAAa,EACbJ,UAAU,EACVM,OACF,CAAC;IACDG,gBAAgB;IAChBe,aAAa,EAAE5B,wBAAwB;IACvC6B,cAAc,EAAE5B,yBAAyB;IACzC6B,WAAW,EAAExB,QAAQ,CAACwB,WAAW;IACjCC,MAAM,EAAEtB,OAAO,CAACsB,MAAM;IACtBC,cAAc,EAAE,CAAC,CAAmB;IACpCC,cAAc,EAAE,CAAC;EACnB,CAGQ;EAER,OAAOC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACV,aAAa,EAAE;IAChDW,gBAAgB,EAAEvB,6BAA6B,CAC7CL,OACF,CAAC,CAACiB,aAAa;EACjB,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { createMinimalClient } from "./createMinimalClient.js";
18
+ /** @internal */
19
+
20
+ export function createMinimalClientHelper(baseUrl, ontologyRid, tokenProvider, ...args) {
21
+ return createMinimalClient({
22
+ ontologyRid
23
+ }, baseUrl, tokenProvider, ...args);
24
+ }
25
+ //# sourceMappingURL=createMinimalClientHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMinimalClientHelper.js","names":["createMinimalClient","createMinimalClientHelper","baseUrl","ontologyRid","tokenProvider","args"],"sources":["createMinimalClientHelper.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 { createMinimalClient } from \"./createMinimalClient.js\";\nimport type { MinimalClientParams } from \"./MinimalClientContext.js\";\n\n/** @internal */\n\nexport function createMinimalClientHelper(\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n ...args: typeof createMinimalClient extends (\n metadata: MinimalClientParams[\"metadata\"],\n baseUrl: string,\n tokenProvider: () => Promise<string>,\n ...args: infer A\n ) => any ? A\n : never\n): ReturnType<typeof createMinimalClient> {\n return createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n ...args,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,mBAAmB,QAAQ,0BAA0B;AAG9D;;AAEA,OAAO,SAASC,yBAAyBA,CACvCC,OAAe,EACfC,WAAqC,EACrCC,aAAoC,EACpC,GAAGC,IAMM,EAC+B;EACxC,OAAOL,mBAAmB,CACxB;IAAEG;EAAY,CAAC,EACfD,OAAO,EACPE,aAAa,EACb,GAAGC,IACL,CAAC;AACH","ignoreList":[]}
@@ -16,10 +16,9 @@
16
16
 
17
17
  import invariant from "tiny-invariant";
18
18
  import { modernToLegacyWhereClause } from "../internal/conversions/modernToLegacyWhereClause.js";
19
- const idCounter = 0;
20
-
19
+ import { derivedPropertyDefinitionFactory } from "./derivedPropertyDefinitionFactory.js";
21
20
  /** @internal */
22
- export function createWithPropertiesObjectSet(objectType, objectSet, definitionMap) {
21
+ export function createWithPropertiesObjectSet(objectType, objectSet, definitionMap, fromBaseObjectSet = false) {
23
22
  return {
24
23
  pivotTo: link => {
25
24
  return createWithPropertiesObjectSet(objectType, {
@@ -77,29 +76,53 @@ export function createWithPropertiesObjectSet(objectType, objectSet, definitionM
77
76
  default:
78
77
  process.env.NODE_ENV !== "production" ? invariant(false, "Invalid aggregation operation " + aggregationOperation) : invariant(false);
79
78
  }
80
- const selectorResult = {
81
- type: {}
82
- };
83
- definitionMap.set(selectorResult, {
79
+ const wrappedObjectSet = {
84
80
  type: "selection",
85
81
  objectSet: objectSet,
86
82
  operation: aggregationOperationDefinition
87
- });
83
+ };
84
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
85
+ definitionMap.set(selectorResult, wrappedObjectSet);
88
86
  return selectorResult;
89
87
  },
90
88
  selectProperty: name => {
91
- const selectorResult = {
92
- type: {}
93
- };
94
- definitionMap.set(selectorResult, {
89
+ if (fromBaseObjectSet) {
90
+ const wrappedObjectSet = {
91
+ type: "property",
92
+ apiName: name
93
+ };
94
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
95
+ definitionMap.set(selectorResult, wrappedObjectSet);
96
+ return selectorResult;
97
+ }
98
+ const wrappedObjectSet = {
95
99
  type: "selection",
96
100
  objectSet: objectSet,
97
101
  operation: {
98
102
  type: "get",
99
103
  selectedPropertyApiName: name
100
104
  }
101
- });
105
+ };
106
+ const selectorResult = derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);
107
+ definitionMap.set(selectorResult, wrappedObjectSet);
102
108
  return selectorResult;
109
+ },
110
+ constant: {
111
+ double: () => {
112
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
113
+ },
114
+ integer: () => {
115
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
116
+ },
117
+ long: () => {
118
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
119
+ },
120
+ datetime: () => {
121
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
122
+ },
123
+ timestamp: () => {
124
+ process.env.NODE_ENV !== "production" ? invariant(false, "Not supported") : invariant(false);
125
+ }
103
126
  }
104
127
  };
105
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","idCounter","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","pivotTo","link","type","where","clause","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","selectorResult","set","operation","selectProperty","name"],"sources":["createWithPropertiesObjectSet.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 { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\n\nconst idCounter = 0;\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n): DerivedProperty.SelectPropertyBuilder<Q, false> {\n const base: DerivedProperty.SelectPropertyBuilder<Q, false> = {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const selectorResult: DerivedProperty.SelectorResult<any> = { type: {} };\n definitionMap.set(selectorResult, {\n type: \"selection\",\n objectSet: objectSet,\n operation: aggregationOperationDefinition,\n });\n return selectorResult;\n },\n selectProperty: (name) => {\n const selectorResult: DerivedProperty.SelectorResult<any> = { type: {} };\n definitionMap.set(selectorResult, {\n type: \"selection\",\n objectSet: objectSet,\n operation: {\n type: \"get\",\n selectedPropertyApiName: name,\n },\n });\n return selectorResult;\n },\n };\n\n return base;\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,yBAAyB,QAAQ,sDAAsD;AAEhG,MAAMC,SAAS,GAAG,CAAC;;AAEnB;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EACD;EAsFjD,OArF8D;IAC5DC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAOL,6BAA6B,CAACC,UAAU,EAAE;QAC/CK,IAAI,EAAE,cAAc;QACpBJ,SAAS;QACTG;MACF,CAAC,EAAEF,aAAa,CAAC;IACnB,CAAC;IACDI,KAAK,EAAGC,MAAM,IAAK;MACjB,OAAOR,6BAA6B,CAACC,UAAU,EAAE;QAC/CK,IAAI,EAAE,QAAQ;QACdJ,SAAS,EAAEA,SAAS;QACpBK,KAAK,EAAET,yBAAyB,CAACU,MAAM,EAAEP,UAAU;MACrD,CAAC,EAAEE,aAAa,CAAC;IACnB,CAAC;IACDM,SAAS,EAAEA,CAACC,WAAmB,EAAEC,GAAQ,KAAK;MAC5C,MAAMC,gBAAgB,GAAGF,WAAW,CAACG,KAAK,CAAC,GAAG,CAAC;MAC/C,EACED,gBAAgB,CAACE,MAAM,KAAK,CAAC,IAAIF,gBAAgB,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADnEpB,SAAS,QAEP,4BAA4B,IAF9BA,SAAS;MAIT,MAAM,CAACqB,uBAAuB,EAAEC,oBAAoB,CAAC,GAAGP,gBAAgB;MACxE,IAAIQ,8BAAyD;MAC7D,QAAQD,oBAAoB;QAC1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ACTtB,IAAI,EAAE,KAAK;UACXe,uBAAuB,EAAES;QAC3B;MACF,CAAC,CAAC;MACF,OAAOJ,cAAc;IACvB;EACF,CAAC;AAGH","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.js","names":["invariant","modernToLegacyWhereClause","derivedPropertyDefinitionFactory","createWithPropertiesObjectSet","objectType","objectSet","definitionMap","fromBaseObjectSet","pivotTo","link","type","where","clause","aggregate","aggregation","opt","splitAggregation","split","length","process","env","NODE_ENV","aggregationPropertyName","aggregationOperation","aggregationOperationDefinition","selectedPropertyApiName","approximatePercentile","percentile","limit","undefined","wrappedObjectSet","operation","selectorResult","set","selectProperty","name","apiName","constant","double","integer","long","datetime","timestamp"],"sources":["createWithPropertiesObjectSet.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 { DerivedProperty, ObjectOrInterfaceDefinition } from \"@osdk/api\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n SelectedPropertyOperation,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { derivedPropertyDefinitionFactory } from \"./derivedPropertyDefinitionFactory.js\";\n\ntype WithConstSelect<Q extends ObjectOrInterfaceDefinition> =\n & DerivedProperty.SelectPropertyBuilder<Q, false>\n & {\n constant: DerivedProperty.Builder<Q, true>[\"constant\"];\n };\n\n/** @internal */\nexport function createWithPropertiesObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n>(\n objectType: Q,\n objectSet: WireObjectSet,\n definitionMap: Map<any, DerivedPropertyDefinition>,\n fromBaseObjectSet: boolean = false,\n): WithConstSelect<Q> {\n return {\n pivotTo: (link) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"searchAround\",\n objectSet,\n link,\n }, definitionMap);\n },\n where: (clause) => {\n return createWithPropertiesObjectSet(objectType, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n }, definitionMap);\n },\n aggregate: (aggregation: string, opt: any) => {\n const splitAggregation = aggregation.split(\":\");\n invariant(\n splitAggregation.length === 2 || splitAggregation[0] === \"$count\",\n \"Invalid aggregation format\",\n );\n const [aggregationPropertyName, aggregationOperation] = splitAggregation;\n let aggregationOperationDefinition: SelectedPropertyOperation;\n switch (aggregationOperation) {\n case \"sum\":\n case \"avg\":\n case \"min\":\n case \"max\":\n case \"exactDistinct\":\n case \"approximateDistinct\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n };\n break;\n case \"approximatePercentile\":\n aggregationOperationDefinition = {\n type: \"approximatePercentile\",\n selectedPropertyApiName: aggregationPropertyName,\n approximatePercentile: opt?.percentile ?? .5,\n };\n break;\n case \"collectSet\":\n case \"collectList\":\n aggregationOperationDefinition = {\n type: aggregationOperation,\n selectedPropertyApiName: aggregationPropertyName,\n limit: opt?.limit ?? 100,\n };\n break;\n case undefined:\n if (aggregationPropertyName === \"$count\") {\n aggregationOperationDefinition = {\n type: \"count\",\n };\n break;\n }\n default:\n invariant(\n false,\n \"Invalid aggregation operation \" + aggregationOperation,\n );\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: aggregationOperationDefinition,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n selectProperty: (name) => {\n if (fromBaseObjectSet) {\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"property\",\n apiName: name,\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n }\n const wrappedObjectSet: DerivedPropertyDefinition = {\n type: \"selection\",\n objectSet: objectSet,\n operation: {\n type: \"get\",\n selectedPropertyApiName: name,\n },\n };\n const selectorResult: DerivedProperty.Definition<any, any> =\n derivedPropertyDefinitionFactory(wrappedObjectSet, definitionMap);\n definitionMap.set(selectorResult, wrappedObjectSet);\n return selectorResult as any;\n },\n constant: {\n double: (value) => {\n invariant(false, \"Not supported\");\n },\n integer: (value) => {\n invariant(false, \"Not supported\");\n },\n long: (value) => {\n invariant(false, \"Not supported\");\n },\n datetime: (value) => {\n invariant(false, \"Not supported\");\n },\n timestamp: (value) => {\n invariant(false, \"Not supported\");\n },\n },\n };\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,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,gCAAgC,QAAQ,uCAAuC;AAQxF;AACA,OAAO,SAASC,6BAA6BA,CAG3CC,UAAa,EACbC,SAAwB,EACxBC,aAAkD,EAClDC,iBAA0B,GAAG,KAAK,EACd;EACpB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;MACjB,OAAON,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,cAAc;QACpBL,SAAS;QACTI;MACF,CAAC,EAAEH,aAAa,CAAC;IACnB,CAAC;IACDK,KAAK,EAAGC,MAAM,IAAK;MACjB,OAAOT,6BAA6B,CAACC,UAAU,EAAE;QAC/CM,IAAI,EAAE,QAAQ;QACdL,SAAS,EAAEA,SAAS;QACpBM,KAAK,EAAEV,yB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EAAEA,CAAA,KAAW;QACfrB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACDyC,QAAQ,EAAEA,CAAA,KAAW;QACnBtB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX,CAAC;MACD0C,SAAS,EAAEA,CAAA,KAAW;QACpBvB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAArB,SAAS,QAAQ,eAAe,IAAhCA,SAAS;MACX;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -44,6 +44,22 @@ describe(createWithPropertiesObjectSet, () => {
44
44
  }
45
45
  `);
46
46
  });
47
+ it("correctly allows select property off the base object set", () => {
48
+ const map = new Map();
49
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
50
+ type: "methodInput"
51
+ }, map, true);
52
+ const result = {
53
+ "derivedPropertyName": base => base.selectProperty("employeeId")
54
+ }["derivedPropertyName"](deriveObjectSet);
55
+ const definition = map.get(result);
56
+ expect(definition).toMatchInlineSnapshot(`
57
+ {
58
+ "apiName": "employeeId",
59
+ "type": "property",
60
+ }
61
+ `);
62
+ });
47
63
  it("correctly handles multiple definitions in one clause", () => {
48
64
  const map = new Map();
49
65
  const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
@@ -96,5 +112,122 @@ describe(createWithPropertiesObjectSet, () => {
96
112
  }
97
113
  `);
98
114
  });
115
+ describe("expressions", () => {
116
+ it("can handle expressions referencing other property keys", () => {
117
+ const map = new Map();
118
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
119
+ type: "methodInput"
120
+ }, map, true);
121
+ const result = {
122
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("employeeId"))
123
+ // "secondaryDerivedPropertyName": (base) =>
124
+ // base.pivotTo("lead").aggregate("employeeId:avg").divide("employeeId", 2),
125
+ }["derivedPropertyName"](deriveObjectSet);
126
+ const definition = map.get(result);
127
+ expect(definition).toMatchInlineSnapshot(`
128
+ {
129
+ "properties": [
130
+ {
131
+ "objectSet": {
132
+ "link": "lead",
133
+ "objectSet": {
134
+ "type": "methodInput",
135
+ },
136
+ "type": "searchAround",
137
+ },
138
+ "operation": {
139
+ "selectedPropertyApiName": "employeeId",
140
+ "type": "get",
141
+ },
142
+ "type": "selection",
143
+ },
144
+ {
145
+ "apiName": "employeeId",
146
+ "type": "property",
147
+ },
148
+ ],
149
+ "type": "add",
150
+ }
151
+ `);
152
+ });
153
+
154
+ // TODO: Add test for literal
155
+ it("can handle nested definitions in an expression", () => {
156
+ const map = new Map();
157
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
158
+ type: "methodInput"
159
+ }, map);
160
+ const result = {
161
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId").add(base.pivotTo("lead").selectProperty("employeeId"))
162
+ }["derivedPropertyName"](deriveObjectSet);
163
+ const definition = map.get(result);
164
+ expect(definition).toMatchInlineSnapshot(`
165
+ {
166
+ "properties": [
167
+ {
168
+ "objectSet": {
169
+ "link": "lead",
170
+ "objectSet": {
171
+ "type": "methodInput",
172
+ },
173
+ "type": "searchAround",
174
+ },
175
+ "operation": {
176
+ "selectedPropertyApiName": "employeeId",
177
+ "type": "get",
178
+ },
179
+ "type": "selection",
180
+ },
181
+ {
182
+ "objectSet": {
183
+ "link": "lead",
184
+ "objectSet": {
185
+ "type": "methodInput",
186
+ },
187
+ "type": "searchAround",
188
+ },
189
+ "operation": {
190
+ "selectedPropertyApiName": "employeeId",
191
+ "type": "get",
192
+ },
193
+ "type": "selection",
194
+ },
195
+ ],
196
+ "type": "add",
197
+ }
198
+ `);
199
+ });
200
+ });
201
+ it("handles datetime expressions", () => {
202
+ const map = new Map();
203
+ const deriveObjectSet = createWithPropertiesObjectSet(Employee, {
204
+ type: "methodInput"
205
+ }, map);
206
+ const result = {
207
+ "derivedPropertyName": base => base.pivotTo("lead").selectProperty("startDate").extractPart("MONTHS"),
208
+ "secondaryDerivedPropertyName": base => base.pivotTo("lead").selectProperty("startDate").min(base.pivotTo("lead").selectProperty("startDate"))
209
+ }["derivedPropertyName"](deriveObjectSet);
210
+ const definition = map.get(result);
211
+ expect(definition).toMatchInlineSnapshot(`
212
+ {
213
+ "part": "MONTHS",
214
+ "property": {
215
+ "objectSet": {
216
+ "link": "lead",
217
+ "objectSet": {
218
+ "type": "methodInput",
219
+ },
220
+ "type": "searchAround",
221
+ },
222
+ "operation": {
223
+ "selectedPropertyApiName": "startDate",
224
+ "type": "get",
225
+ },
226
+ "type": "selection",
227
+ },
228
+ "type": "extract",
229
+ }
230
+ `);
231
+ });
99
232
  });
100
233
  //# sourceMappingURL=createWithPropertiesObjectSet.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","selectProperty","definition","get","toMatchInlineSnapshot","clause","aggregate","percentile","limit","secondResult","secondDefinition"],"sources":["createWithPropertiesObjectSet.test.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 { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,6BAA6B,QAAQ,oCAAoC;AAElFH,QAAQ,CAACG,6BAA6B,EAAE,MAAM;EAC5CD,EAAE,CAAC,4DAA4D,EAAE,MAAM;IACrE,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ,QAAQ,EAAE;MAC9DQ,IAAI,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAOP,MAAMI,MAAM,GALG;MACb,qBAAqB,EAAGC,IAAI,IAC1BA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,YAAY;IACpD,CAAC,CAEqB,qBAAqB,CAAC,CAACL,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAClCP,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;EAEFZ,EAAE,CAAC,sDAAsD,EAAE,MAAM;IAC/D,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ,QAAQ,EAAE;MAC9DQ,IAAI,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAEP,MAAMW,MAAwC,GAAG;MAC/C,qBAAqB,EAAGN,IAAI,IAC1BA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACM,SAAS,CAAC,kCAAkC,EAAE;QACjEC,UAAU,EAAE;MACd,CAAC,CAAC;MAEJ,8BAA8B,EAAGR,IAAI,IACnCA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACM,SAAS,CAAC,qBAAqB,EAAE;QACpDE,KAAK,EAAE;MACT,CAAC;IACL,CAAC;IAED,MAAMV,MAAM,GAAGO,MAAM,CAAC,qBAAqB,CAAC,CAACT,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAElC,MAAMW,YAAY,GAAGJ,MAAM,CAAC,8BAA8B,CAAC,CACzDT,eACF,CAAC;IACD,MAAMc,gBAAgB,GAAGhB,GAAG,CAACS,GAAG,CAACM,YAAY,CAAC;IAE9ClB,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IAEJb,MAAM,CAACmB,gBAAgB,CAAC,CAACN,qBAAqB,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","selectProperty","definition","get","toMatchInlineSnapshot","clause","aggregate","percentile","limit","secondResult","secondDefinition","add","extractPart","min"],"sources":["createWithPropertiesObjectSet.test.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 { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly allows select property off the base object set\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(\n Employee,\n {\n type: \"methodInput\",\n },\n map,\n true,\n );\n\n const clause = {\n \"derivedPropertyName\": (base) => base.selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"apiName\": \"employeeId\",\n \"type\": \"property\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n describe(\"expressions\", () => {\n it(\"can handle expressions referencing other property keys\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(\n Employee,\n {\n type: \"methodInput\",\n },\n map,\n true,\n );\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\").add(\n base.selectProperty(\"employeeId\"),\n ),\n // \"secondaryDerivedPropertyName\": (base) =>\n // base.pivotTo(\"lead\").aggregate(\"employeeId:avg\").divide(\"employeeId\", 2),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"properties\": [\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n {\n \"apiName\": \"employeeId\",\n \"type\": \"property\",\n },\n ],\n \"type\": \"add\",\n }\n `);\n });\n\n // TODO: Add test for literal\n it(\"can handle nested definitions in an expression\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\").add(\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n ),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"properties\": [\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n ],\n \"type\": \"add\",\n }\n `);\n });\n });\n\n it(\"handles datetime expressions\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"startDate\").extractPart(\"MONTHS\"),\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"startDate\").min(\n base.pivotTo(\"lead\").selectProperty(\"startDate\"),\n ),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"part\": \"MONTHS\",\n \"property\": {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"startDate\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n },\n \"type\": \"extract\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,6BAA6B,QAAQ,oCAAoC;AAElFH,QAAQ,CAACG,6BAA6B,EAAE,MAAM;EAC5CD,EAAE,CAAC,4DAA4D,EAAE,MAAM;IACrE,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ,QAAQ,EAAE;MAC9DQ,IAAI,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAOP,MAAMI,MAAM,GALG;MACb,qBAAqB,EAAGC,IAAI,IAC1BA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC,CAACC,cAAc,CAAC,YAAY;IACpD,CAAC,CAEqB,qBAAqB,CAAC,CAACL,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAClCP,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CA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