@osdk/client 2.1.0-beta.2 → 2.1.0-beta.21

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 (298) hide show
  1. package/CHANGELOG.md +297 -0
  2. package/build/browser/Client.d.ts +6 -22
  3. package/build/browser/Client.d.ts.map +1 -1
  4. package/build/browser/Client.js +3 -1
  5. package/build/browser/Client.js.map +1 -1
  6. package/build/browser/MinimalClientContext.d.ts +1 -1
  7. package/build/browser/MinimalClientContext.d.ts.map +1 -1
  8. package/build/browser/__unstable/ConjureSupport.js +5 -5
  9. package/build/browser/__unstable/ConjureSupport.js.map +1 -1
  10. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
  11. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  12. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js +2 -2
  13. package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
  14. package/build/browser/actions/actions.test.js +28 -0
  15. package/build/browser/actions/actions.test.js.map +1 -1
  16. package/build/browser/actions/applyAction.js +1 -1
  17. package/build/browser/actions/applyAction.js.map +1 -1
  18. package/build/browser/createClient.d.ts +1 -1
  19. package/build/browser/createClient.d.ts.map +1 -1
  20. package/build/browser/createClient.js +41 -19
  21. package/build/browser/createClient.js.map +1 -1
  22. package/build/browser/createClient.test.js +24 -0
  23. package/build/browser/createClient.test.js.map +1 -1
  24. package/build/browser/createGeotimeSeriesProperty.d.ts +1 -1
  25. package/build/browser/createGeotimeSeriesProperty.d.ts.map +1 -1
  26. package/build/browser/createGeotimeSeriesProperty.js +4 -1
  27. package/build/browser/createGeotimeSeriesProperty.js.map +1 -1
  28. package/build/browser/createMinimalClient.js +9 -4
  29. package/build/browser/createMinimalClient.js.map +1 -1
  30. package/build/browser/createPlatformClient.d.ts +1 -1
  31. package/build/browser/createPlatformClient.d.ts.map +1 -1
  32. package/build/browser/createTimeseriesProperty.d.ts.map +1 -1
  33. package/build/browser/fetchMetadata.test.js +14 -0
  34. package/build/browser/fetchMetadata.test.js.map +1 -1
  35. package/build/browser/index.d.ts +2 -2
  36. package/build/browser/index.d.ts.map +1 -1
  37. package/build/browser/index.js +1 -1
  38. package/build/browser/index.js.map +1 -1
  39. package/build/browser/intellisense.test.js +1 -1
  40. package/build/browser/intellisense.test.js.map +1 -1
  41. package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
  42. package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
  43. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +11 -3
  44. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  45. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +208 -7
  46. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  47. package/build/browser/object/AttachmentUpload.d.ts.map +1 -1
  48. package/build/browser/object/AttachmentUpload.js +5 -7
  49. package/build/browser/object/AttachmentUpload.js.map +1 -1
  50. package/build/browser/object/aggregate.js +4 -5
  51. package/build/browser/object/aggregate.js.map +1 -1
  52. package/build/browser/object/aggregate.test.js +6 -9
  53. package/build/browser/object/aggregate.test.js.map +1 -1
  54. package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
  55. package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
  56. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
  57. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  58. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js +4 -3
  59. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
  60. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +41 -85
  61. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  62. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +0 -6
  63. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
  64. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +60 -89
  65. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  66. package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js +2 -2
  67. package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
  68. package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js +14 -38
  69. package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  70. package/build/browser/object/convertWireToOsdkObjects.js +42 -6
  71. package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
  72. package/build/browser/object/convertWireToOsdkObjects.test.js +177 -45
  73. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  74. package/build/browser/object/fetchPage.d.ts.map +1 -1
  75. package/build/browser/object/fetchPage.js +34 -23
  76. package/build/browser/object/fetchPage.js.map +1 -1
  77. package/build/browser/object/fetchPage.test.js +75 -1
  78. package/build/browser/object/fetchPage.test.js.map +1 -1
  79. package/build/browser/object/object.test.d.ts.map +1 -1
  80. package/build/browser/object/object.test.js +25 -1
  81. package/build/browser/object/object.test.js.map +1 -1
  82. package/build/browser/object/timeseries.test.js +10 -0
  83. package/build/browser/object/timeseries.test.js.map +1 -1
  84. package/build/browser/objectSet/InterfaceObjectSet.test.d.ts +2 -0
  85. package/build/browser/objectSet/InterfaceObjectSet.test.d.ts.map +1 -0
  86. package/build/browser/objectSet/InterfaceObjectSet.test.js +61 -0
  87. package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -0
  88. package/build/browser/objectSet/ObjectSet.test.js +162 -48
  89. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  90. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +136 -74
  91. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  92. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +150 -42
  93. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  94. package/build/browser/objectSet/createObjectSet.js +10 -8
  95. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  96. package/build/browser/objectSet/toConjureObjectSet.js +2 -0
  97. package/build/browser/objectSet/toConjureObjectSet.js.map +1 -1
  98. package/build/browser/ontology/makeConjureContext.d.ts +1 -1
  99. package/build/browser/ontology/makeConjureContext.d.ts.map +1 -1
  100. package/build/browser/public/internal.d.ts +4 -0
  101. package/build/browser/public/internal.d.ts.map +1 -0
  102. package/build/browser/public/internal.js +19 -0
  103. package/build/browser/public/internal.js.map +1 -0
  104. package/build/browser/public-utils/createAndFetchTempObjectSetRid.d.ts +11 -0
  105. package/build/browser/public-utils/createAndFetchTempObjectSetRid.d.ts.map +1 -0
  106. package/build/browser/public-utils/createAndFetchTempObjectSetRid.js +32 -0
  107. package/build/browser/public-utils/createAndFetchTempObjectSetRid.js.map +1 -0
  108. package/build/browser/public-utils/hydrateAttachmentFromRid.d.ts +10 -0
  109. package/build/browser/public-utils/hydrateAttachmentFromRid.d.ts.map +1 -0
  110. package/build/{esm/createAttachmentFromRid.js → browser/public-utils/hydrateAttachmentFromRid.js} +9 -4
  111. package/build/browser/public-utils/hydrateAttachmentFromRid.js.map +1 -0
  112. package/build/browser/public-utils/hydrateObjectSetFromRid.d.ts +11 -0
  113. package/build/browser/public-utils/hydrateObjectSetFromRid.d.ts.map +1 -0
  114. package/build/browser/public-utils/hydrateObjectSetFromRid.js +37 -0
  115. package/build/browser/public-utils/hydrateObjectSetFromRid.js.map +1 -0
  116. package/build/browser/queries/applyQuery.d.ts.map +1 -1
  117. package/build/browser/queries/applyQuery.js +3 -4
  118. package/build/browser/queries/applyQuery.js.map +1 -1
  119. package/build/browser/queries/queries.test.js +30 -2
  120. package/build/browser/queries/queries.test.js.map +1 -1
  121. package/build/browser/tsserver.js +1 -1
  122. package/build/browser/tsserver.js.map +1 -1
  123. package/build/browser/util/UserAgent.js +1 -1
  124. package/build/browser/util/UserAgent.js.map +1 -1
  125. package/build/browser/util/datetimeConverters.d.ts +22 -0
  126. package/build/browser/util/datetimeConverters.d.ts.map +1 -0
  127. package/build/browser/util/datetimeConverters.js +55 -0
  128. package/build/browser/util/datetimeConverters.js.map +1 -0
  129. package/build/browser/util/datetimeConverters.test.d.ts +2 -0
  130. package/build/browser/util/datetimeConverters.test.d.ts.map +1 -0
  131. package/build/browser/util/datetimeConverters.test.js +75 -0
  132. package/build/browser/util/datetimeConverters.test.js.map +1 -0
  133. package/build/browser/util/objectSetUtils.d.ts +4 -0
  134. package/build/browser/util/objectSetUtils.d.ts.map +1 -0
  135. package/build/browser/util/objectSetUtils.js +25 -0
  136. package/build/browser/util/objectSetUtils.js.map +1 -0
  137. package/build/browser/util/timeseriesUtils.d.ts +1 -1
  138. package/build/browser/util/timeseriesUtils.d.ts.map +1 -1
  139. package/build/browser/util/timeseriesUtils.js +1 -1
  140. package/build/browser/util/timeseriesUtils.js.map +1 -1
  141. package/build/browser/util/toDataValue.js +6 -0
  142. package/build/browser/util/toDataValue.js.map +1 -1
  143. package/build/browser/util/toDataValue.test.js +9 -1
  144. package/build/browser/util/toDataValue.test.js.map +1 -1
  145. package/build/browser/util/toDataValueQueries.js +6 -0
  146. package/build/browser/util/toDataValueQueries.js.map +1 -1
  147. package/build/esm/Client.d.ts +6 -22
  148. package/build/esm/Client.d.ts.map +1 -1
  149. package/build/esm/Client.js +3 -1
  150. package/build/esm/Client.js.map +1 -1
  151. package/build/esm/MinimalClientContext.d.ts +1 -1
  152. package/build/esm/MinimalClientContext.d.ts.map +1 -1
  153. package/build/esm/__unstable/ConjureSupport.js +5 -5
  154. package/build/esm/__unstable/ConjureSupport.js.map +1 -1
  155. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
  156. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
  157. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js +2 -2
  158. package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
  159. package/build/esm/actions/actions.test.js +28 -0
  160. package/build/esm/actions/actions.test.js.map +1 -1
  161. package/build/esm/actions/applyAction.js +1 -1
  162. package/build/esm/actions/applyAction.js.map +1 -1
  163. package/build/esm/createClient.d.ts +1 -1
  164. package/build/esm/createClient.d.ts.map +1 -1
  165. package/build/esm/createClient.js +41 -19
  166. package/build/esm/createClient.js.map +1 -1
  167. package/build/esm/createClient.test.js +24 -0
  168. package/build/esm/createClient.test.js.map +1 -1
  169. package/build/esm/createGeotimeSeriesProperty.d.ts +1 -1
  170. package/build/esm/createGeotimeSeriesProperty.d.ts.map +1 -1
  171. package/build/esm/createGeotimeSeriesProperty.js +4 -1
  172. package/build/esm/createGeotimeSeriesProperty.js.map +1 -1
  173. package/build/esm/createMinimalClient.js +9 -4
  174. package/build/esm/createMinimalClient.js.map +1 -1
  175. package/build/esm/createPlatformClient.d.ts +1 -1
  176. package/build/esm/createPlatformClient.d.ts.map +1 -1
  177. package/build/esm/createTimeseriesProperty.d.ts.map +1 -1
  178. package/build/esm/fetchMetadata.test.js +14 -0
  179. package/build/esm/fetchMetadata.test.js.map +1 -1
  180. package/build/esm/index.d.ts +2 -2
  181. package/build/esm/index.d.ts.map +1 -1
  182. package/build/esm/index.js +1 -1
  183. package/build/esm/index.js.map +1 -1
  184. package/build/esm/intellisense.test.js +1 -1
  185. package/build/esm/intellisense.test.js.map +1 -1
  186. package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
  187. package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
  188. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +11 -3
  189. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  190. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +208 -7
  191. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  192. package/build/esm/object/AttachmentUpload.d.ts.map +1 -1
  193. package/build/esm/object/AttachmentUpload.js +5 -7
  194. package/build/esm/object/AttachmentUpload.js.map +1 -1
  195. package/build/esm/object/aggregate.js +4 -5
  196. package/build/esm/object/aggregate.js.map +1 -1
  197. package/build/esm/object/aggregate.test.js +6 -9
  198. package/build/esm/object/aggregate.test.js.map +1 -1
  199. package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
  200. package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
  201. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
  202. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  203. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js +4 -3
  204. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
  205. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +41 -85
  206. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  207. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +0 -6
  208. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
  209. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +60 -89
  210. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  211. package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js +2 -2
  212. package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
  213. package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js +14 -38
  214. package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  215. package/build/esm/object/convertWireToOsdkObjects.js +42 -6
  216. package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
  217. package/build/esm/object/convertWireToOsdkObjects.test.js +177 -45
  218. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  219. package/build/esm/object/fetchPage.d.ts.map +1 -1
  220. package/build/esm/object/fetchPage.js +34 -23
  221. package/build/esm/object/fetchPage.js.map +1 -1
  222. package/build/esm/object/fetchPage.test.js +75 -1
  223. package/build/esm/object/fetchPage.test.js.map +1 -1
  224. package/build/esm/object/object.test.d.ts.map +1 -1
  225. package/build/esm/object/object.test.js +25 -1
  226. package/build/esm/object/object.test.js.map +1 -1
  227. package/build/esm/object/timeseries.test.js +10 -0
  228. package/build/esm/object/timeseries.test.js.map +1 -1
  229. package/build/esm/objectSet/InterfaceObjectSet.test.d.ts +2 -0
  230. package/build/esm/objectSet/InterfaceObjectSet.test.d.ts.map +1 -0
  231. package/build/esm/objectSet/InterfaceObjectSet.test.js +61 -0
  232. package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -0
  233. package/build/esm/objectSet/ObjectSet.test.js +162 -48
  234. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  235. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +136 -77
  236. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  237. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +150 -42
  238. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  239. package/build/esm/objectSet/createObjectSet.js +10 -8
  240. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  241. package/build/esm/objectSet/toConjureObjectSet.js +2 -0
  242. package/build/esm/objectSet/toConjureObjectSet.js.map +1 -1
  243. package/build/esm/ontology/makeConjureContext.d.ts +1 -1
  244. package/build/esm/ontology/makeConjureContext.d.ts.map +1 -1
  245. package/build/esm/public/internal.d.ts +4 -0
  246. package/build/esm/public/internal.d.ts.map +1 -0
  247. package/build/esm/public/internal.js +19 -0
  248. package/build/esm/public/internal.js.map +1 -0
  249. package/build/esm/public-utils/createAndFetchTempObjectSetRid.d.ts +11 -0
  250. package/build/esm/public-utils/createAndFetchTempObjectSetRid.d.ts.map +1 -0
  251. package/build/esm/public-utils/createAndFetchTempObjectSetRid.js +32 -0
  252. package/build/esm/public-utils/createAndFetchTempObjectSetRid.js.map +1 -0
  253. package/build/esm/public-utils/hydrateAttachmentFromRid.d.ts +10 -0
  254. package/build/esm/public-utils/hydrateAttachmentFromRid.d.ts.map +1 -0
  255. package/build/{browser/createAttachmentFromRid.js → esm/public-utils/hydrateAttachmentFromRid.js} +9 -4
  256. package/build/esm/public-utils/hydrateAttachmentFromRid.js.map +1 -0
  257. package/build/esm/public-utils/hydrateObjectSetFromRid.d.ts +11 -0
  258. package/build/esm/public-utils/hydrateObjectSetFromRid.d.ts.map +1 -0
  259. package/build/esm/public-utils/hydrateObjectSetFromRid.js +37 -0
  260. package/build/esm/public-utils/hydrateObjectSetFromRid.js.map +1 -0
  261. package/build/esm/queries/applyQuery.d.ts.map +1 -1
  262. package/build/esm/queries/applyQuery.js +3 -4
  263. package/build/esm/queries/applyQuery.js.map +1 -1
  264. package/build/esm/queries/queries.test.js +30 -2
  265. package/build/esm/queries/queries.test.js.map +1 -1
  266. package/build/esm/tsserver.js +1 -1
  267. package/build/esm/tsserver.js.map +1 -1
  268. package/build/esm/util/UserAgent.js +1 -1
  269. package/build/esm/util/UserAgent.js.map +1 -1
  270. package/build/esm/util/datetimeConverters.d.ts +22 -0
  271. package/build/esm/util/datetimeConverters.d.ts.map +1 -0
  272. package/build/esm/util/datetimeConverters.js +55 -0
  273. package/build/esm/util/datetimeConverters.js.map +1 -0
  274. package/build/esm/util/datetimeConverters.test.d.ts +2 -0
  275. package/build/esm/util/datetimeConverters.test.d.ts.map +1 -0
  276. package/build/esm/util/datetimeConverters.test.js +75 -0
  277. package/build/esm/util/datetimeConverters.test.js.map +1 -0
  278. package/build/esm/util/objectSetUtils.d.ts +4 -0
  279. package/build/esm/util/objectSetUtils.d.ts.map +1 -0
  280. package/build/esm/util/objectSetUtils.js +25 -0
  281. package/build/esm/util/objectSetUtils.js.map +1 -0
  282. package/build/esm/util/timeseriesUtils.d.ts +1 -1
  283. package/build/esm/util/timeseriesUtils.d.ts.map +1 -1
  284. package/build/esm/util/timeseriesUtils.js +1 -1
  285. package/build/esm/util/timeseriesUtils.js.map +1 -1
  286. package/build/esm/util/toDataValue.js +6 -0
  287. package/build/esm/util/toDataValue.js.map +1 -1
  288. package/build/esm/util/toDataValue.test.js +9 -1
  289. package/build/esm/util/toDataValue.test.js.map +1 -1
  290. package/build/esm/util/toDataValueQueries.js +6 -0
  291. package/build/esm/util/toDataValueQueries.js.map +1 -1
  292. package/package.json +23 -19
  293. package/build/browser/createAttachmentFromRid.d.ts +0 -10
  294. package/build/browser/createAttachmentFromRid.d.ts.map +0 -1
  295. package/build/browser/createAttachmentFromRid.js.map +0 -1
  296. package/build/esm/createAttachmentFromRid.d.ts +0 -10
  297. package/build/esm/createAttachmentFromRid.d.ts.map +0 -1
  298. package/build/esm/createAttachmentFromRid.js.map +0 -1
@@ -14,95 +14,51 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { extractNamespace } from "../../internal/conversions/modernToLegacyWhereClause.js";
17
- import { createSimpleCache } from "../SimpleCache.js";
18
17
  import { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
19
- const handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);
20
18
  /** @internal */
21
19
  export function createOsdkInterface(underlying, interfaceDef) {
22
- const handler = handlerCache.get(interfaceDef);
23
- const proxy = new Proxy({
24
- [UnderlyingOsdkObject]: underlying,
25
- [InterfaceDefRef]: interfaceDef
26
- },
27
- // the wrapper doesn't contain everything obviously. we proxy
28
- handler);
29
- return proxy;
30
- }
31
- function createInterfaceProxyHandler(newDef) {
32
- return {
33
- getOwnPropertyDescriptor(target, p) {
34
- const underlying = target[UnderlyingOsdkObject];
35
- const objDef = underlying[ObjectDefRef];
36
- switch (p) {
37
- case "$primaryKey":
38
- case "$title":
39
- case "$objectType":
40
- case "$rid":
41
- return underlying[p] != null ? Reflect.getOwnPropertyDescriptor(underlying, p) : undefined;
42
- case "$apiName":
43
- return {
44
- enumerable: true,
45
- configurable: true,
46
- value: target[InterfaceDefRef].apiName
47
- };
48
- }
49
- const [objApiNamespace] = extractNamespace(newDef.apiName);
50
- if (objApiNamespace != null) {
51
- const [apiNamespace, apiName] = extractNamespace(p);
52
- if (apiNamespace == null) {
53
- p = `${objApiNamespace}.${apiName}`;
54
- }
55
- }
56
- if (newDef.properties[p] != null) {
57
- return {
58
- enumerable: true,
59
- configurable: true,
60
- value: underlying[objDef.interfaceMap[newDef.apiName][p]]
61
- };
62
- }
20
+ const [objApiNamespace] = extractNamespace(interfaceDef.apiName);
21
+ return Object.freeze(Object.defineProperties({}, {
22
+ // first to minimize hidden classes
23
+ [UnderlyingOsdkObject]: {
24
+ value: underlying
25
+ },
26
+ "$apiName": {
27
+ value: interfaceDef.apiName,
28
+ enumerable: true
29
+ },
30
+ "$as": {
31
+ value: underlying.$as,
32
+ enumerable: false
33
+ },
34
+ "$objectType": {
35
+ value: underlying.$objectType,
36
+ enumerable: "$objectType" in underlying
63
37
  },
64
- ownKeys(target) {
65
- const underlying = target[UnderlyingOsdkObject];
66
- const [objApiNamespace] = extractNamespace(newDef.apiName);
67
- let propNames = Object.keys(newDef.properties);
68
- if (objApiNamespace != null) {
69
- propNames = propNames.map(p => {
70
- const [apiNamespace, apiName] = extractNamespace(p);
71
- if (apiNamespace === objApiNamespace) {
72
- p = apiName;
73
- }
74
- return p;
75
- });
76
- }
77
- return ["$apiName", "$objectType", "$primaryKey", ...(underlying["$rid"] ? ["$rid"] : []), "$title", ...propNames];
38
+ "$primaryKey": {
39
+ value: underlying.$primaryKey,
40
+ enumerable: "$primaryKey" in underlying
78
41
  },
79
- get(target, p) {
80
- const underlying = target[UnderlyingOsdkObject];
81
- switch (p) {
82
- case InterfaceDefRef:
83
- return newDef;
84
- case "$apiName":
85
- return newDef.apiName;
86
- case "$as":
87
- case UnderlyingOsdkObject:
88
- case "$primaryKey":
89
- case "$title":
90
- case "$objectType":
91
- case "$rid":
92
- return underlying[p];
93
- }
94
- const [objApiNamespace] = extractNamespace(newDef.apiName);
95
- if (objApiNamespace != null) {
96
- const [apiNamespace, apiName] = extractNamespace(p);
97
- if (apiNamespace == null) {
98
- p = `${objApiNamespace}.${apiName}`;
99
- }
100
- }
101
- if (newDef.properties[p] != null) {
102
- const objDef = target[UnderlyingOsdkObject][ObjectDefRef];
103
- return underlying[objDef.interfaceMap[newDef.apiName][p]];
104
- }
105
- }
106
- };
42
+ "$title": {
43
+ value: underlying.$title,
44
+ enumerable: "$title" in underlying
45
+ },
46
+ "$rid": {
47
+ value: underlying.$rid,
48
+ enumerable: "$rid" in underlying
49
+ },
50
+ [InterfaceDefRef]: {
51
+ value: interfaceDef
52
+ },
53
+ ...Object.fromEntries(Object.keys(interfaceDef.properties).map(p => {
54
+ const objDef = underlying[ObjectDefRef];
55
+ const [apiNamespace, apiName] = extractNamespace(p);
56
+ const targetPropName = objDef.interfaceMap[interfaceDef.apiName][p];
57
+ return [apiNamespace === objApiNamespace ? apiName : p, {
58
+ enumerable: targetPropName in underlying,
59
+ value: underlying[targetPropName]
60
+ }];
61
+ }))
62
+ }));
107
63
  }
108
64
  //# sourceMappingURL=createOsdkInterface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","createSimpleCache","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","handlerCache","WeakMap","createInterfaceProxyHandler","createOsdkInterface","underlying","interfaceDef","handler","get","proxy","Proxy","newDef","getOwnPropertyDescriptor","target","p","objDef","Reflect","undefined","enumerable","configurable","value","apiName","objApiNamespace","apiNamespace","properties","interfaceMap","ownKeys","propNames","Object","keys","map"],"sources":["createOsdkInterface.js"],"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 */\nimport { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const interfaceHolder = {\n [UnderlyingOsdkObject]: underlying,\n [InterfaceDefRef]: interfaceDef,\n };\n const handler = handlerCache.get(interfaceDef);\n const proxy = new Proxy(interfaceHolder, // the wrapper doesn't contain everything obviously. we proxy\n handler);\n return proxy;\n}\nfunction createInterfaceProxyHandler(newDef) {\n return {\n getOwnPropertyDescriptor(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n const objDef = underlying[ObjectDefRef];\n switch (p) {\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p] != null\n ? Reflect.getOwnPropertyDescriptor(underlying, p)\n : undefined;\n case \"$apiName\":\n return {\n enumerable: true,\n configurable: true,\n value: target[InterfaceDefRef].apiName,\n };\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n return {\n enumerable: true,\n configurable: true,\n value: underlying[objDef.interfaceMap[newDef.apiName][p]],\n };\n }\n },\n ownKeys(target) {\n const underlying = target[UnderlyingOsdkObject];\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n let propNames = Object.keys(newDef.properties);\n if (objApiNamespace != null) {\n propNames = propNames.map(p => {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace === objApiNamespace) {\n p = apiName;\n }\n return p;\n });\n }\n return [\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ...(underlying[\"$rid\"] ? [\"$rid\"] : []),\n \"$title\",\n ...propNames,\n ];\n },\n get(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n switch (p) {\n case InterfaceDefRef:\n return newDef;\n case \"$apiName\":\n return newDef.apiName;\n case \"$as\":\n case UnderlyingOsdkObject:\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p];\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n const objDef = target[UnderlyingOsdkObject][ObjectDefRef];\n return underlying[objDef.interfaceMap[newDef.apiName][p]];\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yDAAyD;AAC1F,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,EAAEC,YAAY,EAAEC,oBAAoB,QAAS,sBAAsB;AAC3F,MAAMC,YAAY,GAAGJ,iBAAiB,CAAC,IAAIK,OAAO,CAAC,CAAC,EAAEC,2BAA2B,CAAC;AAClF;AACA,OAAO,SAASC,mBAAmBA,CAACC,UAAU,EAAEC,YAAY,EAAE;EAK1D,MAAMC,OAAO,GAAGN,YAAY,CAACO,GAAG,CAACF,YAAY,CAAC;EAC9C,MAAMG,KAAK,GAAG,IAAIC,KAAK,CALC;IACpB,CAACV,oBAAoB,GAAGK,UAAU;IAClC,CAACP,eAAe,GAAGQ;EACvB,CAAC;EAEwC;EACzCC,OAAO,CAAC;EACR,OAAOE,KAAK;AAChB;AACA,SAASN,2BAA2BA,CAACQ,MAAM,EAAE;EACzC,OAAO;IACHC,wBAAwBA,CAACC,MAAM,EAAEC,CAAC,EAAE;MAChC,MAAMT,UAAU,GAAGQ,MAAM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D,YAAY,CAAC;QACzD,OAAOM,UAAU,CAACU,MAAM,CAACU,YAAY,CAACd,MAAM,CAACU,OAAO,CAAC,CAACP,CAAC,CAAC,CAAC;MAC7D;IACJ;EACJ,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","createOsdkInterface","underlying","interfaceDef","objApiNamespace","apiName","Object","freeze","defineProperties","value","enumerable","$as","$objectType","$primaryKey","$title","$rid","fromEntries","keys","properties","map","p","objDef","apiNamespace","targetPropName","interfaceMap"],"sources":["createOsdkInterface.js"],"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 */\nimport { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const [objApiNamespace] = extractNamespace(interfaceDef.apiName);\n return Object.freeze(Object.defineProperties({}, {\n // first to minimize hidden classes\n [UnderlyingOsdkObject]: { value: underlying },\n \"$apiName\": { value: interfaceDef.apiName, enumerable: true },\n \"$as\": {\n value: underlying.$as,\n enumerable: false,\n },\n \"$objectType\": {\n value: underlying.$objectType,\n enumerable: \"$objectType\" in underlying,\n },\n \"$primaryKey\": {\n value: underlying.$primaryKey,\n enumerable: \"$primaryKey\" in underlying,\n },\n \"$title\": {\n value: underlying.$title,\n enumerable: \"$title\" in underlying,\n },\n \"$rid\": {\n value: underlying.$rid,\n enumerable: \"$rid\" in underlying,\n },\n [InterfaceDefRef]: { value: interfaceDef },\n ...Object.fromEntries(Object.keys(interfaceDef.properties).map(p => {\n const objDef = underlying[ObjectDefRef];\n const [apiNamespace, apiName] = extractNamespace(p);\n const targetPropName = objDef\n .interfaceMap[interfaceDef.apiName][p];\n return [apiNamespace === objApiNamespace ? apiName : p, {\n enumerable: targetPropName in underlying,\n value: underlying[targetPropName],\n }];\n })),\n }));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yDAAyD;AAC1F,SAASC,eAAe,EAAEC,YAAY,EAAEC,oBAAoB,QAAS,sBAAsB;AAC3F;AACA,OAAO,SAASC,mBAAmBA,CAACC,UAAU,EAAEC,YAAY,EAAE;EAC1D,MAAM,CAACC,eAAe,CAAC,GAAGP,gBAAgB,CAACM,YAAY,CAACE,OAAO,CAAC;EAChE,OAAOC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,gBAAgB,CAAC,CAAC,CAAC,EAAE;IAC7C;IACA,CAACR,oBAAoB,GAAG;MAAES,KAAK,EAAEP;IAAW,CAAC;IAC7C,UAAU,EAAE;MAAEO,KAAK,EAAEN,YAAY,CAACE,OAAO;MAAEK,UAAU,EAAE;IAAK,CAAC;IAC7D,KAAK,EAAE;MACHD,KAAK,EAAEP,UAAU,CAACS,GAAG;MACrBD,UAAU,EAAE;IAChB,CAAC;IACD,aAAa,EAAE;MACXD,KAAK,EAAEP,UAAU,CAACU,WAAW;MAC7BF,UAAU,EAAE,aAAa,IAAIR;IACjC,CAAC;IACD,aAAa,EAAE;MACXO,KAAK,EAAEP,UAAU,CAACW,WAAW;MAC7BH,UAAU,EAAE,aAAa,IAAIR;IACjC,CAAC;IACD,QAAQ,EAAE;MACNO,KAAK,EAAEP,UAAU,CAACY,MAAM;MACxBJ,UAAU,EAAE,QAAQ,IAAIR;IAC5B,CAAC;IACD,MAAM,EAAE;MACJO,KAAK,EAAEP,UAAU,CAACa,IAAI;MACtBL,UAAU,EAAE,MAAM,IAAIR;IAC1B,CAAC;IACD,CAACJ,eAAe,GAAG;MAAEW,KAAK,EAAEN;IAAa,CAAC;IAC1C,GAAGG,MAAM,CAACU,WAAW,CAACV,MAAM,CAACW,IAAI,CAACd,YAAY,CAACe,UAAU,CAAC,CAACC,GAAG,CAACC,CAAC,IAAI;MAChE,MAAMC,MAAM,GAAGnB,UAAU,CAACH,YAAY,CAAC;MACvC,MAAM,CAACuB,YAAY,EAAEjB,OAAO,CAAC,GAAGR,gBAAgB,CAACuB,CAAC,CAAC;MACnD,MAAMG,cAAc,GAAGF,MAAM,CACxBG,YAAY,CAACrB,YAAY,CAACE,OAAO,CAAC,CAACe,CAAC,CAAC;MAC1C,OAAO,CAACE,YAAY,KAAKlB,eAAe,GAAGC,OAAO,GAAGe,CAAC,EAAE;QAChDV,UAAU,EAAEa,cAAc,IAAIrB,UAAU;QACxCO,KAAK,EAAEP,UAAU,CAACqB,cAAc;MACpC,CAAC,CAAC;IACV,CAAC,CAAC;EACN,CAAC,CAAC,CAAC;AACP","ignoreList":[]}
@@ -19,8 +19,6 @@ import { createOsdkInterface } from "./createOsdkInterface.js";
19
19
  import { ObjectDefRef } from "./InternalSymbols.js";
20
20
  describe(createOsdkInterface, () => {
21
21
  it("works in the normal case", () => {
22
- // underlying: Osdk<Q> & ObjectHolder<Q>,
23
- // interfaceDef: InterfaceMetadata,
24
22
  const iface = createOsdkInterface({
25
23
  "foo": "hi mom",
26
24
  [ObjectDefRef]: {
@@ -75,8 +73,6 @@ describe(createOsdkInterface, () => {
75
73
  `);
76
74
  });
77
75
  it("properly maps apiNamespace", () => {
78
- // underlying: Osdk<Q> & ObjectHolder<Q>,
79
- // interfaceDef: InterfaceMetadata,
80
76
  const iface = createOsdkInterface({
81
77
  "foo": "hi mom",
82
78
  [ObjectDefRef]: {
@@ -131,8 +127,6 @@ describe(createOsdkInterface, () => {
131
127
  `);
132
128
  });
133
129
  it("works with mixed namespaces", () => {
134
- // underlying: Osdk<Q> & ObjectHolder<Q>,
135
- // interfaceDef: InterfaceMetadata,
136
130
  const iface = createOsdkInterface({
137
131
  "foo": "hi mom",
138
132
  [ObjectDefRef]: {
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkInterface.test.js","names":["describe","expect","it","InterfaceDefinitions","createOsdkInterface","ObjectDefRef","iface","apiName","displayName","interfaceMap","inverseInterfaceMap","links","pluralDisplayName","primaryKeyApiName","primaryKeyType","properties","type","titleProperty","rid","status","implements","Object","keys","toMatchInlineSnapshot","asdf","toBe","JSON","stringify","undefined"],"sources":["createOsdkInterface.test.js"],"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 */\nimport { describe, expect, it } from \"vitest\";\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { ObjectDefRef } from \"./InternalSymbols.js\";\ndescribe(createOsdkInterface, () => {\n it(\"works in the normal case\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"IFoo\": {\n \"asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"properly maps apiNamespace\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"a.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"a.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"works with mixed namespaces\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"b.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"b.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"b.asdf\",\n ]\n `);\n expect(iface[\"b.asdf\"]).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"b.asdf\": \"hi mom\"\n }\"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,oBAAoB,QAAS,oCAAoC;AAC1E,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,YAAY,QAAQ,sBAAsB;AACnDL,QAAQ,CAACI,mBAAmB,EAAE,MAAM;EAChCF,EAAE,CAAC,0BAA0B,EAAE,MAAM;IA4BjC;IACA;IACA,MAAMI,KAAK,GAAGF,mBAAmB,CA7Bd;MACf,KAAK,EAAE,QAAQ;MACf,CAACC,YAAY,GAAG;QACZ,CAACF,oBAAoB,GAAG,CAAC,CAAC;QAC1BI,OAAO,EAAE,KAAK;QAC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AE,KAAK;QACdC,WAAW,EAAE,EAAE;QACfC,YAAY,EAAE;UACV,QAAQ,EAAE;YACN,QAAQ,EAAE;UACd;QACJ,CAAC;QACDC,mBAAmB,EAAE,CAAC,CAAC;QACvBC,KAAK,EAAE,CAAC,CAAC;QACTC,iBAAiB,EAAE,EAAE;QACrBC,iBAAiB,EAAE,EAAE;QACrBC,cAAc,EAAE,QAAQ;QACxBC,UAAU,EAAE;UACR,KAAK,EAAE;YACHC,IAAI,EAAE;UACV;QACJ,CAAC;QACDA,IAAI,EAAE,QAAQ;QACdC,aAAa,EAAE,KAAK;QACpBC,GAAG,EAAE,EAAE;QACPC,MAAM,EAAE;MACZ;IACJ,CAAC,EAG6C;MAC1C,SAAS,EAAE,QAAQ;MACnBX,WAAW,EAAE,EAAE;MACfG,KAAK,EAAE,CAAC,CAAC;MACTI,UAAU,EAAE;QACR,QAAQ,EAAE;UACNC,IAAI,EAAE;QACV;MACJ,CAAC;MACDE,GAAG,EAAE,EAAE;MACPF,IAAI,EAAE,WAAW;MACjBI,UAAU,EAAE;IAChB,CAAC,CAAC;IACFnB,MAAM,CAACoB,MAAM,CAACC,IAAI,CAAChB,KAAK,CAAC,CAAC,CAACiB,qBAAqB,CAAC;AACzD;AACA;AACA;AACA;AACA,KAAK,CAAC;IACEtB,MAAM,CAACK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAACmB,IAAI,CAAC,QAAQ,CAAC;IACtCxB,MAAM,CAACyB,IAAI,CAACC,SAAS,CAACrB,KAAK,EAAEsB,SAAS,EAAE,CAAC,CAAC,CAAC,CAACL,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkInterface.test.js","names":["describe","expect","it","InterfaceDefinitions","createOsdkInterface","ObjectDefRef","iface","apiName","displayName","interfaceMap","inverseInterfaceMap","links","pluralDisplayName","primaryKeyApiName","primaryKeyType","properties","type","titleProperty","rid","status","implements","Object","keys","toMatchInlineSnapshot","asdf","toBe","JSON","stringify","undefined"],"sources":["createOsdkInterface.test.js"],"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 */\nimport { describe, expect, it } from \"vitest\";\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { ObjectDefRef } from \"./InternalSymbols.js\";\ndescribe(createOsdkInterface, () => {\n it(\"works in the normal case\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"IFoo\": {\n \"asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"properly maps apiNamespace\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"a.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"a.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"works with mixed namespaces\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"b.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"b.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"b.asdf\",\n ]\n `);\n expect(iface[\"b.asdf\"]).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"b.asdf\": \"hi mom\"\n }\"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,oBAAoB,QAAS,oCAAoC;AAC1E,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,YAAY,QAAQ,sBAAsB;AACnDL,QAAQ,CAACI,mBAAmB,EAAE,MAAM;EAChCF,EAAE,CAAC,0BAA0B,EAAE,MAAM;IA4BjC,MAAMI,KAAK,GAAGF,mBAAmB,CA3Bd;MACf,KAAK,EAAE,QAAQ;MACf,CAACC,YAAY,GAAG;QACZ,CAACF,oBAAoB,GAAG,CAAC,CAAC;QAC1BI,OAAO,EAAE,KAAK;QACdC,WAAW,EAAE,EAAE;QACfC,YAAY,EAAE;UACV,MAAM,EAAE;YACJ,MAAM,EAAE;UACZ;QACJ,CAAC;QACDC,mBAAmB,EAAE,CAAC,CAAC;QACvBC,KAAK,EAAE,CAAC,CAAC;QACTC,iBAAiB,EAAE,EAAE;QACrBC,iBAAiB,EAAE,EAAE;QACrBC,cAAc,EAAE,QAAQ;QACxBC,UAAU,EAAE;UACR,KAAK,EAAE;YACHC,IAAI,EAAE;UACV;QACJ,CAAC;QACDA,IAAI,EAAE,QAAQ;QACdC,aAAa,EAAE,KAAK;QACpBC,GAAG,EAAE,EAAE;QACPC,MAAM,EAAE;MACZ;IACJ,CAAC,EAC6C;MAC1C,SAAS,EAAE,MAAM;MACjBX,WAAW,EAAE,EAAE;MACfG,KAAK,EAAE,CAAC,CAAC;MACTI,UAAU,EAAE;Q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AQ,EAAE;UACNC,IAAI,EAAE;QACV;MACJ,CAAC;MACDE,GAAG,EAAE,EAAE;MACPF,IAAI,EAAE,WAAW;MACjBI,UAAU,EAAE;IAChB,CAAC,CAAC;IACFnB,MAAM,CAACoB,MAAM,CAACC,IAAI,CAAChB,KAAK,CAAC,CAAC,CAACiB,qBAAqB,CAAC;AACzD;AACA;AACA;AACA;AACA,KAAK,CAAC;IACEtB,MAAM,CAACK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAACmB,IAAI,CAAC,QAAQ,CAAC;IACtCxB,MAAM,CAACyB,IAAI,CAACC,SAAS,CAACrB,KAAK,EAAEsB,SAAS,EAAE,CAAC,CAAC,CAAC,CAACL,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -13,114 +13,85 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { createAttachmentFromRid } from "../../createAttachmentFromRid.js";
16
+ import invariant from "tiny-invariant";
17
17
  import { GeotimeSeriesPropertyImpl } from "../../createGeotimeSeriesProperty.js";
18
18
  import { TimeSeriesPropertyImpl } from "../../createTimeseriesProperty.js";
19
- import { createClientCache } from "../Cache.js";
19
+ import { hydrateAttachmentFromRidInternal } from "../../public-utils/hydrateAttachmentFromRid.js";
20
20
  import { get$as } from "./getDollarAs.js";
21
21
  import { get$link } from "./getDollarLink.js";
22
- import { CachedPropertiesRef, ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject } from "./InternalSymbols.js";
23
- const objectPrototypeCache = createClientCache(function (client, objectDef) {
24
- return Object.create(null, {
22
+ import { ClientRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
23
+ const specialPropertyTypes = new Set(["attachment", "geotimeSeriesReference", "numericTimeseries", "stringTimeseries", "sensorTimeseries"]);
24
+ // kept separate so we are not redefining these functions
25
+ // every time an object is created.
26
+ const basePropDefs = {
27
+ "$as": {
28
+ get: function () {
29
+ return get$as(this[ObjectDefRef]);
30
+ }
31
+ },
32
+ "$link": {
33
+ get: function () {
34
+ return get$link(this);
35
+ }
36
+ }
37
+ };
38
+ /** @internal */
39
+ export function createOsdkObject(client, objectDef, rawObj) {
40
+ // updates the object's "hidden class/map".
41
+ Object.defineProperties(rawObj, {
42
+ [UnderlyingOsdkObject]: {
43
+ enumerable: false,
44
+ value: rawObj
45
+ },
25
46
  [ObjectDefRef]: {
26
- value: objectDef
47
+ value: objectDef,
48
+ enumerable: false
27
49
  },
28
50
  [ClientRef]: {
29
- value: client
30
- },
31
- "$as": {
32
- value: get$as(objectDef)
51
+ value: client,
52
+ enumerable: false
33
53
  },
34
- "$link": {
35
- get: function () {
36
- return get$link(this);
37
- }
38
- },
39
- "$updateInternalValues": {
40
- value: function (newValues) {
41
- this[RawObject] = Object.assign({}, this[RawObject], newValues);
42
- }
43
- }
54
+ ...basePropDefs
44
55
  });
45
- });
46
- /** @internal */
47
- export function createOsdkObject(client, objectDef, rawObj) {
48
- // We use multiple layers of prototypes to maximize reuse and also to keep
49
- // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.
50
- const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {
51
- [RawObject]: {
52
- value: rawObj,
53
- writable: true // so we can allow updates
54
- },
55
- [CachedPropertiesRef]: {
56
- value: new Map(),
57
- writable: true
56
+ // Assign the special values
57
+ for (const propKey of Object.keys(rawObj)) {
58
+ if (propKey in objectDef.properties && typeof objectDef.properties[propKey].type === "string" && specialPropertyTypes.has(objectDef.properties[propKey].type)) {
59
+ rawObj[propKey] = createSpecialProperty(client, objectDef, rawObj, propKey);
58
60
  }
59
- });
60
- // we separate the holder out so we can update
61
- // the underlying data without having to return a new object
62
- // we also need the holder so we can customize the console.log output
63
- const holder = Object.create(objectHolderPrototype);
64
- const osdkObject = new Proxy(holder, {
65
- ownKeys(target) {
66
- return Reflect.ownKeys(target[RawObject]);
67
- },
68
- get(target, p, receiver) {
69
- switch (p) {
70
- case UnderlyingOsdkObject:
71
- // effectively point back to the proxy
72
- return receiver;
73
- }
74
- if (p in target) return target[p];
75
- if (p in rawObj) {
76
- const rawValue = target[RawObject][p];
77
- const propDef = objectDef.properties[p];
78
- if (propDef) {
61
+ }
62
+ return Object.freeze(rawObj);
63
+ }
64
+ function createSpecialProperty(client, objectDef, rawObject, p) {
65
+ const rawValue = rawObject[p];
66
+ const propDef = objectDef.properties[p];
67
+ if (process.env.NODE_ENV !== "production") {
68
+ !(propDef != null && typeof propDef.type === "string" && specialPropertyTypes.has(propDef.type)) ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
69
+ }
70
+ {
71
+ {
72
+ {
73
+ {
79
74
  if (propDef.type === "attachment") {
80
75
  if (Array.isArray(rawValue)) {
81
- return rawValue.map(a => createAttachmentFromRid(client, a.rid));
76
+ return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));
82
77
  }
83
- return createAttachmentFromRid(client, rawValue.rid);
78
+ return hydrateAttachmentFromRidInternal(client, rawValue.rid);
84
79
  }
85
- if (propDef.type === "numericTimeseries" || propDef.type === "stringTimeseries") {
86
- return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);
80
+ if (propDef.type === "numericTimeseries" || propDef.type === "stringTimeseries" || propDef.type === "sensorTimeseries") {
81
+ return new TimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p);
87
82
  }
88
83
  if (propDef.type === "geotimeSeriesReference") {
89
- const instance = target[CachedPropertiesRef].get(p);
90
- if (instance != null) {
91
- return instance;
92
- }
93
- const geotimeProp = new GeotimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);
94
- target[CachedPropertiesRef].set(p, geotimeProp);
95
- return geotimeProp;
84
+ return new GeotimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p, rawValue.type === "geotimeSeriesValue" ? {
85
+ time: rawValue.timestamp,
86
+ value: {
87
+ type: "Point",
88
+ coordinates: rawValue.position
89
+ }
90
+ } : undefined);
96
91
  }
97
92
  }
98
- return rawValue;
99
93
  }
100
- // we do not do any fall through to avoid unexpected behavior
101
- },
102
- set(target, p, newValue) {
103
- // allow the prototype to update this value
104
- if (p === RawObject) {
105
- // symbol only exists internally so no one else can hit this
106
- target[p] = newValue;
107
- return true;
108
- }
109
- return false;
110
- },
111
- getOwnPropertyDescriptor(target, p) {
112
- if (p === RawObject) {
113
- return Reflect.getOwnPropertyDescriptor(target, p);
114
- }
115
- if (target[RawObject][p] != null) {
116
- return {
117
- configurable: true,
118
- enumerable: true
119
- };
120
- }
121
- return undefined;
122
94
  }
123
- });
124
- return osdkObject;
95
+ }
125
96
  }
126
97
  //# sourceMappingURL=createOsdkObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkObject.js","names":["createAttachmentFromRid","GeotimeSeriesPropertyImpl","TimeSeriesPropertyImpl","createClientCache","get$as","get$link","CachedPropertiesRef","ClientRef","ObjectDefRef","RawObject","UnderlyingOsdkObject","objectPrototypeCache","client","objectDef","Object","create","value","get","newValues","assign","createOsdkObject","rawObj","objectHolderPrototype","writable","Map","holder","osdkObject","Proxy","ownKeys","target","Reflect","p","receiver","rawValue","propDef","properties","type","Array","isArray","map","a","rid","apiName","primaryKeyApiName","instance","geotimeProp","set","newValue","getOwnPropertyDescriptor","configurable","enumerable","undefined"],"sources":["createOsdkObject.js"],"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 */\nimport { createAttachmentFromRid } from \"../../createAttachmentFromRid.js\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { createClientCache } from \"../Cache.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { CachedPropertiesRef, ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst objectPrototypeCache = createClientCache(function (client, objectDef) {\n return Object.create(null, {\n [ObjectDefRef]: { value: objectDef },\n [ClientRef]: { value: client },\n \"$as\": { value: get$as(objectDef) },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n \"$updateInternalValues\": {\n value: function (newValues) {\n this[RawObject] = Object.assign({}, this[RawObject], newValues);\n },\n },\n });\n});\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // We use multiple layers of prototypes to maximize reuse and also to keep\n // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.\n const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {\n [RawObject]: {\n value: rawObj,\n writable: true, // so we can allow updates\n },\n [CachedPropertiesRef]: {\n value: new Map(),\n writable: true,\n },\n });\n // we separate the holder out so we can update\n // the underlying data without having to return a new object\n // we also need the holder so we can customize the console.log output\n const holder = Object.create(objectHolderPrototype);\n const osdkObject = new Proxy(holder, {\n ownKeys(target) {\n return Reflect.ownKeys(target[RawObject]);\n },\n get(target, p, receiver) {\n switch (p) {\n case UnderlyingOsdkObject:\n // effectively point back to the proxy\n return receiver;\n }\n if (p in target)\n return target[p];\n if (p in rawObj) {\n const rawValue = target[RawObject][p];\n const propDef = objectDef.properties[p];\n if (propDef) {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => createAttachmentFromRid(client, a.rid));\n }\n return createAttachmentFromRid(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n }\n if (propDef.type === \"geotimeSeriesReference\") {\n const instance = target[CachedPropertiesRef].get(p);\n if (instance != null) {\n return instance;\n }\n const geotimeProp = new GeotimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n target[CachedPropertiesRef].set(p, geotimeProp);\n return geotimeProp;\n }\n }\n return rawValue;\n }\n // we do not do any fall through to avoid unexpected behavior\n },\n set(target, p, newValue) {\n // allow the prototype to update this value\n if (p === RawObject) {\n // symbol only exists internally so no one else can hit this\n target[p] = newValue;\n return true;\n }\n return false;\n },\n getOwnPropertyDescriptor(target, p) {\n if (p === RawObject) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n if (target[RawObject][p] != null) {\n return { configurable: true, enumerable: true };\n }\n return undefined;\n },\n });\n return osdkObject;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,kCAAkC;AAC1E,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,sBAAsB,QAAQ,mCAAmC;AAC1E,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,mBAAmB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,QAAS,sBAAsB;AACrH,MAAMC,oBAAoB,GAAGR,iBAAiB,CAAC,UAAUS,MAAM,EAAEC,SAAS,EAAE;EACxE,OAAOC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE;IACvB,CAACP,YAAY,GAAG;MAAEQ,KAAK,EAAEH;IAAU,CAAC;IACpC,CAACN,SAAS,GAAG;MAAES,KAAK,EAA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AACf,CAAC,EAAEc,WAAW,CAAC;YAC/C,OAAOA,WAAW;UACtB;QACJ;QACA,OAAOZ,QAAQ;MACnB;MACA;IACJ,CAAC;IACDa,GAAGA,CAACjB,MAAM,EAAEE,CAAC,EAAEgB,QAAQ,EAAE;MACrB;MACA,IAAIhB,CAAC,KAAKtB,SAAS,EAAE;QACjB;QACAoB,MAAM,CAACE,CAAC,CAAC,GAAGgB,QAAQ;QACpB,OAAO,IAAI;MACf;MACA,OAAO,KAAK;IAChB,CAAC;IACDC,wBAAwBA,CAACnB,MAAM,EAAEE,CAAC,EAAE;MAChC,IAAIA,CAAC,KAAKtB,SAAS,EAAE;QACjB,OAAOqB,OAAO,CAACkB,wBAAwB,CAACnB,MAAM,EAAEE,CAAC,CAAC;MACtD;MACA,IAAIF,MAAM,CAACpB,SAAS,CAAC,CAACsB,CAAC,CAAC,IAAI,IAAI,EAAE;QAC9B,OAAO;UAAEkB,YAAY,EAAE,IAAI;UAAEC,UAAU,EAAE;QAAK,CAAC;MACnD;MACA,OAAOC,SAAS;IACpB;EACJ,CAAC,CAAC;EACF,OAAOzB,UAAU;AACrB","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","createOsdkObject","client","objectDef","rawObj","Object","defineProperties","enumerable","value","propKey","keys","properties","type","has","createSpecialProperty","freeze","rawObject","p","rawValue","propDef","process","env","NODE_ENV","Array","isArray","map","a","rid","apiName","primaryKeyApiName","time","timestamp","coordinates","position","undefined"],"sources":["createOsdkObject.js"],"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 */\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { ClientRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst specialPropertyTypes = new Set([\n \"attachment\",\n \"geotimeSeriesReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n]);\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function () {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n};\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // updates the object's \"hidden class/map\".\n Object.defineProperties(rawObj, {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: rawObj,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n });\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)) {\n rawObj[propKey] = createSpecialProperty(client, objectDef, rawObj, propKey);\n }\n }\n return Object.freeze(rawObj);\n}\nfunction createSpecialProperty(client, objectDef, rawObject, p) {\n const rawValue = rawObject[p];\n const propDef = objectDef.properties[p];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type));\n }\n {\n {\n {\n {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));\n }\n return hydrateAttachmentFromRidInternal(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p);\n }\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p, rawValue.type === \"geotimeSeriesValue\"\n ? {\n time: rawValue.timestamp,\n value: {\n type: \"Point\",\n coordinates: rawValue.position,\n },\n }\n : undefined);\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,sBAAsB,QAAQ,mCAAmC;AAC1E,SAASC,gCAAgC,QAAQ,gDAAgD;AACjG,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAAS,sBAAsB;AACrF,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAAC,CACjC,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CACrB,CAAC;AACF;AACA;AACA,MAAMC,YAAY,GAAG;EACjB,KAAK,EAAE;IACHC,GAAG,EAAE,SAAAA,CAAA,EAAY;MACb,OAAOR,MAAM,CAAC,IAAI,CAACG,YAAY,CAAC,CAAC;IACrC;EACJ,CAAC;EACD,OAAO,EAAE;IACLK,GAAG,EAAE,SAAAA,CAAA,EAAY;MACb,OAAOP,QAA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new Error(`Object does not implement interface '${targetMinDef}'.`);
46
46
  }
47
47
  const underlying = this[UnderlyingOsdkObject];
48
- const existing = osdkObjectToInterfaceView.get(underlying).get(targetInterfaceApiName);
48
+ const existing = osdkObjectToInterfaceView.get(underlying).get(targetInterfaceApiName)?.deref();
49
49
  if (existing) return existing;
50
50
  const osdkInterface = createOsdkInterface(underlying, def.def);
51
- osdkObjectToInterfaceView.get(underlying).set(targetInterfaceApiName, osdkInterface);
51
+ osdkObjectToInterfaceView.get(underlying).set(targetInterfaceApiName, new WeakRef(osdkInterface));
52
52
  return osdkInterface;
53
53
  };
54
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getDollarAs.js","names":["InterfaceDefinitions","createSimpleCache","createOsdkInterface","UnderlyingOsdkObject","get$as","WeakMap","$asFactory","get","osdkObjectToInterfaceView","Map","objDef","targetMinDef","targetInterfaceApiName","apiName","interfaceMap","Error","type","def","underlying","existing","osdkInterface","set"],"sources":["getDollarAs.js"],"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 */\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { UnderlyingOsdkObject } from \"./InternalSymbols.js\";\nexport const get$as = createSimpleCache(new WeakMap(), $asFactory).get;\nconst osdkObjectToInterfaceView = createSimpleCache(new WeakMap(), () => new Map());\nfunction $asFactory(objDef) {\n // We use the exact same logic for both the interface rep and the underlying rep\n return function $as(targetMinDef) {\n let targetInterfaceApiName;\n if (typeof targetMinDef === \"string\") {\n if (targetMinDef === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n }\n // this is sufficient to determine if we implement the interface\n if (objDef.interfaceMap?.[targetMinDef] == null) {\n throw new Error(`Object does not implement interface '${targetMinDef}'.`);\n }\n targetInterfaceApiName = targetMinDef;\n }\n else if (targetMinDef.apiName === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n }\n else {\n if (targetMinDef.type === \"object\") {\n throw new Error(`'${targetMinDef.apiName}' is not an interface nor is it '${objDef.apiName}', which is the object type.`);\n }\n targetInterfaceApiName = targetMinDef.apiName;\n }\n const def = objDef[InterfaceDefinitions][targetInterfaceApiName];\n if (!def) {\n throw new Error(`Object does not implement interface '${targetMinDef}'.`);\n }\n const underlying = this[UnderlyingOsdkObject];\n const existing = osdkObjectToInterfaceView\n .get(underlying)\n .get(targetInterfaceApiName);\n if (existing)\n return existing;\n const osdkInterface = createOsdkInterface(underlying, def.def);\n osdkObjectToInterfaceView.get(underlying).set(targetInterfaceApiName, osdkInterface);\n return osdkInterface;\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,oBAAoB,QAAS,oCAAoC;AAC1E,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,sBAAsB;AAC3D,OAAO,MAAMC,MAAM,GAAGH,iBAAiB,CAAC,IAAII,OAAO,CAAC,CAAC,EAAEC,UAAU,CAAC,CAACC,GAAG;AACtE,MAAMC,yBAAyB,GAAGP,iBAAiB,CAAC,IAAII,OAAO,CAAC,CAAC,EAAE,MAAM,IAAII,GAAG,CAAC,CAAC,CAAC;AACnF,SAASH,UAAUA,CAACI,MAAM,EAAE;EACxB;EACA,OAAO,UAAaC,YAAY,EAAE;IAC9B,IAAIC,sBAAsB;IAC1B,IAAI,OAAOD,YAA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faceDefinitions","createSimpleCache","createOsdkInterface","UnderlyingOsdkObject","get$as","WeakMap","$asFactory","get","osdkObjectToInterfaceView","Map","objDef","targetMinDef","targetInterfaceApiName","apiName","interfaceMap","Error","type","def","underlying","existing","deref","osdkInterface","set","WeakRef"],"sources":["getDollarAs.js"],"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 */\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { UnderlyingOsdkObject } from \"./InternalSymbols.js\";\nexport const get$as = createSimpleCache(new WeakMap(), $asFactory).get;\nconst osdkObjectToInterfaceView = createSimpleCache(new WeakMap(), () => new Map());\nfunction $asFactory(objDef) {\n // We use the exact same logic for both the interface rep and the underlying rep\n return function $as(targetMinDef) {\n let targetInterfaceApiName;\n if (typeof targetMinDef === \"string\") {\n if (targetMinDef === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n }\n // this is sufficient to determine if we implement the interface\n if (objDef.interfaceMap?.[targetMinDef] == null) {\n throw new Error(`Object does not implement interface '${targetMinDef}'.`);\n }\n targetInterfaceApiName = targetMinDef;\n }\n else if (targetMinDef.apiName === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n }\n else {\n if (targetMinDef.type === \"object\") {\n throw new Error(`'${targetMinDef.apiName}' is not an interface nor is it '${objDef.apiName}', which is the object type.`);\n }\n targetInterfaceApiName = targetMinDef.apiName;\n }\n const def = objDef[InterfaceDefinitions][targetInterfaceApiName];\n if (!def) {\n throw new Error(`Object does not implement interface '${targetMinDef}'.`);\n }\n const underlying = this[UnderlyingOsdkObject];\n const existing = osdkObjectToInterfaceView\n .get(underlying)\n .get(targetInterfaceApiName)?.deref();\n if (existing)\n return existing;\n const osdkInterface = createOsdkInterface(underlying, def.def);\n osdkObjectToInterfaceView.get(underlying).set(targetInterfaceApiName, new WeakRef(osdkInterface));\n return osdkInterface;\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,oBAAoB,QAAS,oCAAoC;AAC1E,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,sBAAsB;AAC3D,OAAO,MAAMC,MAAM,GAAGH,iBAAiB,CAAC,IAAII,OAAO,CAAC,CAAC,EAAEC,UAAU,CAAC,CAACC,GAAG;AACtE,MAAMC,yBAAyB,GAAGP,iBAAiB,CAAC,IAAII,OAAO,CAAC,CAAC,EAAE,MAAM,IAAII,GAAG,CAAC,CAAC,CAAC;AACnF,SAASH,UAAUA,CAACI,MAAM,EAAE;EACxB;EACA,OAAO,UAAaC,YAAY,EAAE;IAC9B,IAAIC,sBAAsB;IAC1B,IAAI,OAAOD,YAAY,KAAK,QAAQ,EAAE;MAClC,IAAIA,YAAY,KAAKD,MAAM,CAACG,OAAO,EAAE;QACjC,OAAO,IAAI,CAACV,oBAAoB,CAAC;MACrC;MACA;MACA,IAAIO,MAAM,CAACI,YAAY,GAAGH,YAAY,CAAC,IAAI,IAAI,EAAE;QAC7C,MAAM,IAAII,KAAK,CAAC,wCAAwCJ,YAAY,IAAI,CAAC;MAC7E;MACAC,sBAAsB,GAAGD,YAAY;IACzC,CAAC,MACI,IAAIA,YAAY,CAACE,OAAO,KAAKH,MAAM,CAACG,OAAO,EAAE;MAC9C,OAAO,IAAI,CAACV,oBAAoB,CAAC;IACrC,CAAC,MACI;MACD,IAAIQ,YAAY,CAACK,IAAI,KAAK,QAAQ,EAAE;QAChC,MAAM,IAAID,KAAK,CAAC,IAAIJ,YAAY,CAACE,OAAO,oCAAoCH,MAAM,CAACG,OAAO,8BAA8B,CAAC;MAC7H;MACAD,sBAAsB,GAAGD,YAAY,CAACE,OAAO;IACjD;IACA,MAAMI,GAAG,GAAGP,MAAM,CAACV,oBAAoB,CAAC,CAACY,sBAAsB,CAAC;IAChE,IAAI,CAACK,GAAG,EAAE;MACN,MAAM,IAAIF,KAAK,CAAC,wCAAwCJ,YAAY,IAAI,CAAC;IAC7E;IACA,MAAMO,UAAU,GAAG,IAAI,CAACf,oBAAoB,CAAC;IAC7C,MAAMgB,QAAQ,GAAGX,yBAAyB,CACrCD,GAAG,CAACW,UAAU,CAAC,CACfX,GAAG,CAACK,sBAAsB,CAAC,EAAEQ,KAAK,CAAC,CAAC;IACzC,IAAID,QAAQ,EACR,OAAOA,QAAQ;IACnB,MAAME,aAAa,GAAGnB,mBAAmB,CAACgB,UAAU,EAAED,GAAG,CAACA,GAAG,CAAC;IAC9DT,yBAAyB,CAACD,GAAG,CAACW,UAAU,CAAC,CAACI,GAAG,CAACV,sBAAsB,EAAE,IAAIW,OAAO,CAACF,aAAa,CAAC,CAAC;IACjG,OAAOA,aAAa;EACxB,CAAC;AACL","ignoreList":[]}
@@ -15,46 +15,22 @@
15
15
  */
16
16
  import { getWireObjectSet } from "../../objectSet/createObjectSet.js";
17
17
  import { fetchSingle, fetchSingleWithErrors } from "../fetchSingle.js";
18
- import { ClientRef, ObjectDefRef, RawObject } from "./InternalSymbols.js";
18
+ import { ClientRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
19
19
  /** @internal */
20
20
  export function get$link(holder) {
21
- return new Proxy(holder, DollarLinkProxyHandler);
22
- }
23
- const DollarLinkProxyHandler = {
24
- get(target, p) {
25
- const {
26
- [ObjectDefRef]: objDef,
27
- [ClientRef]: client,
28
- [RawObject]: rawObj
29
- } = target;
30
- const linkDef = objDef.links[p];
31
- if (linkDef == null) {
32
- return;
33
- }
21
+ const client = holder[ClientRef];
22
+ const objDef = holder[ObjectDefRef];
23
+ const rawObj = holder[UnderlyingOsdkObject];
24
+ return Object.freeze(Object.fromEntries(Object.keys(objDef.links).map(linkName => {
25
+ const linkDef = objDef.links[linkName];
34
26
  const objectSet = client.objectSetFactory(objDef, client).where({
35
27
  [objDef.primaryKeyApiName]: rawObj.$primaryKey
36
- }).pivotTo(p);
37
- if (!linkDef.multiplicity) {
38
- return {
39
- fetchOne: options => fetchSingle(client, objDef, options ?? {}, getWireObjectSet(objectSet)),
40
- fetchOneWithErrors: options => fetchSingleWithErrors(client, objDef, options ?? {}, getWireObjectSet(objectSet))
41
- };
42
- } else {
43
- return objectSet;
44
- }
45
- },
46
- ownKeys(target) {
47
- return [...Object.keys(target[ObjectDefRef].links)];
48
- },
49
- getOwnPropertyDescriptor(target, p) {
50
- if (target[ObjectDefRef].links[p]) {
51
- return {
52
- enumerable: true,
53
- configurable: true,
54
- // fixme
55
- writable: false
56
- };
57
- }
58
- }
59
- };
28
+ }).pivotTo(linkName);
29
+ const value = !linkDef.multiplicity ? {
30
+ fetchOne: options => fetchSingle(client, objDef, options ?? {}, getWireObjectSet(objectSet)),
31
+ fetchOneWithErrors: options => fetchSingleWithErrors(client, objDef, options ?? {}, getWireObjectSet(objectSet))
32
+ } : objectSet;
33
+ return [linkName, value];
34
+ })));
35
+ }
60
36
  //# sourceMappingURL=getDollarLink.js.map