@osdk/react 2.41.0 → 2.41.1-main-e39a72892d538f3130e2cd51cee05d83d11fa493

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 (142) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/browser/aip/chatStore.js.map +1 -1
  3. package/build/browser/aip/chatStream.js +1 -1
  4. package/build/browser/aip/chatStream.js.map +1 -1
  5. package/build/browser/aip/useChat.js +1 -1
  6. package/build/browser/aip/useChat.js.map +1 -1
  7. package/build/browser/new/OsdkContext.js.map +1 -1
  8. package/build/browser/new/OsdkProvider.js.map +1 -1
  9. package/build/browser/new/UserAgentContext.js.map +1 -1
  10. package/build/browser/new/core/stableSerialize.js.map +1 -1
  11. package/build/browser/new/core/useStableObjectSet.js.map +1 -1
  12. package/build/browser/new/createCompositeExternalStore.js +1 -1
  13. package/build/browser/new/createCompositeExternalStore.js.map +1 -1
  14. package/build/browser/new/hookUtils.js.map +1 -1
  15. package/build/browser/new/makeExternalStore.js +3 -3
  16. package/build/browser/new/makeExternalStore.js.map +1 -1
  17. package/build/browser/new/platform-apis/admin/useCbacBanner.js.map +1 -1
  18. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -1
  19. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  20. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  21. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  22. package/build/browser/new/platform-apis/admin/useMarkingCategories.js.map +1 -1
  23. package/build/browser/new/platform-apis/admin/useMarkings.js.map +1 -1
  24. package/build/browser/new/platform-apis/admin/useUserMarkings.js.map +1 -1
  25. package/build/browser/new/shapes/derivedLinksStore.js.map +1 -1
  26. package/build/browser/new/shapes/types.js.map +1 -1
  27. package/build/browser/new/shapes/useShape.js.map +1 -1
  28. package/build/browser/new/shared/storeUtils.js.map +1 -1
  29. package/build/browser/new/useDevToolsClient.js.map +1 -1
  30. package/build/browser/new/useLinks.js.map +1 -1
  31. package/build/browser/new/useObjectSet.js.map +1 -1
  32. package/build/browser/new/useOsdkAction.js.map +1 -1
  33. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  34. package/build/browser/new/useOsdkFunction.js.map +1 -1
  35. package/build/browser/new/useOsdkFunctions.js.map +1 -1
  36. package/build/browser/new/useOsdkObject.js.map +1 -1
  37. package/build/browser/new/useOsdkObjects.js.map +1 -1
  38. package/build/browser/new/useRegisterUserAgent.js.map +1 -1
  39. package/build/browser/public/testing.js.map +1 -1
  40. package/build/browser/useObservableClient.js.map +1 -1
  41. package/build/browser/useOsdkClient.js.map +1 -1
  42. package/build/browser/useOsdkMetadata.js.map +1 -1
  43. package/build/browser/util/UserAgent.js +1 -1
  44. package/build/browser/util/UserAgent.js.map +1 -1
  45. package/build/browser/utils/useDebouncedCallback.js.map +1 -1
  46. package/build/browser/utils/usePlatformQuery.js.map +1 -1
  47. package/build/cjs/{chunk-SEFARM7Y.cjs → chunk-ICSJXGFL.cjs} +32 -32
  48. package/build/cjs/chunk-ICSJXGFL.cjs.map +1 -0
  49. package/build/cjs/{chunk-UKQGMTMG.cjs → chunk-O5ISVU2U.cjs} +5 -5
  50. package/build/cjs/chunk-O5ISVU2U.cjs.map +1 -0
  51. package/build/cjs/{chunk-HJHKH4B6.cjs → chunk-VQ4PS6U2.cjs} +7 -7
  52. package/build/cjs/{chunk-HJHKH4B6.cjs.map → chunk-VQ4PS6U2.cjs.map} +1 -1
  53. package/build/cjs/index.cjs +16 -16
  54. package/build/cjs/public/experimental/admin.cjs +10 -10
  55. package/build/cjs/public/experimental/aip.cjs +2 -2
  56. package/build/cjs/public/experimental/aip.cjs.map +1 -1
  57. package/build/cjs/public/experimental.cjs +17 -17
  58. package/build/cjs/public/experimental.d.cts +1 -1
  59. package/build/cjs/public/platform-apis.cjs +10 -10
  60. package/build/cjs/public/platform-apis.d.cts +7 -7
  61. package/build/esm/aip/chatStore.js.map +1 -1
  62. package/build/esm/aip/chatStream.js +1 -1
  63. package/build/esm/aip/chatStream.js.map +1 -1
  64. package/build/esm/aip/useChat.js +1 -1
  65. package/build/esm/aip/useChat.js.map +1 -1
  66. package/build/esm/new/OsdkContext.js.map +1 -1
  67. package/build/esm/new/OsdkProvider.js.map +1 -1
  68. package/build/esm/new/UserAgentContext.js.map +1 -1
  69. package/build/esm/new/core/stableSerialize.js.map +1 -1
  70. package/build/esm/new/core/useStableObjectSet.js.map +1 -1
  71. package/build/esm/new/createCompositeExternalStore.js +1 -1
  72. package/build/esm/new/createCompositeExternalStore.js.map +1 -1
  73. package/build/esm/new/hookUtils.js.map +1 -1
  74. package/build/esm/new/makeExternalStore.js +3 -3
  75. package/build/esm/new/makeExternalStore.js.map +1 -1
  76. package/build/esm/new/platform-apis/admin/useCbacBanner.js.map +1 -1
  77. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -1
  78. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  79. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  80. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  81. package/build/esm/new/platform-apis/admin/useMarkingCategories.js.map +1 -1
  82. package/build/esm/new/platform-apis/admin/useMarkings.js.map +1 -1
  83. package/build/esm/new/platform-apis/admin/useUserMarkings.js.map +1 -1
  84. package/build/esm/new/shapes/derivedLinksStore.js.map +1 -1
  85. package/build/esm/new/shapes/types.js.map +1 -1
  86. package/build/esm/new/shapes/useShape.js.map +1 -1
  87. package/build/esm/new/shared/storeUtils.js.map +1 -1
  88. package/build/esm/new/useDevToolsClient.js.map +1 -1
  89. package/build/esm/new/useLinks.js.map +1 -1
  90. package/build/esm/new/useObjectSet.js.map +1 -1
  91. package/build/esm/new/useOsdkAction.js.map +1 -1
  92. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  93. package/build/esm/new/useOsdkFunction.js.map +1 -1
  94. package/build/esm/new/useOsdkFunctions.js.map +1 -1
  95. package/build/esm/new/useOsdkObject.js.map +1 -1
  96. package/build/esm/new/useOsdkObjects.js.map +1 -1
  97. package/build/esm/new/useRegisterUserAgent.js.map +1 -1
  98. package/build/esm/public/testing.js.map +1 -1
  99. package/build/esm/useObservableClient.js.map +1 -1
  100. package/build/esm/useOsdkClient.js.map +1 -1
  101. package/build/esm/useOsdkMetadata.js.map +1 -1
  102. package/build/esm/util/UserAgent.js +1 -1
  103. package/build/esm/util/UserAgent.js.map +1 -1
  104. package/build/esm/utils/useDebouncedCallback.js.map +1 -1
  105. package/build/esm/utils/usePlatformQuery.js.map +1 -1
  106. package/build/types/aip/chatStore.d.ts.map +1 -1
  107. package/build/types/aip/chatStream.d.ts.map +1 -1
  108. package/build/types/aip/useChat.d.ts.map +1 -1
  109. package/build/types/new/OsdkProvider.d.ts.map +1 -1
  110. package/build/types/new/core/stableSerialize.d.ts.map +1 -1
  111. package/build/types/new/core/useStableObjectSet.d.ts.map +1 -1
  112. package/build/types/new/createCompositeExternalStore.d.ts +1 -1
  113. package/build/types/new/createCompositeExternalStore.d.ts.map +1 -1
  114. package/build/types/new/makeExternalStore.d.ts +2 -2
  115. package/build/types/new/makeExternalStore.d.ts.map +1 -1
  116. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts.map +1 -1
  117. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts.map +1 -1
  118. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -1
  119. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -1
  120. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -1
  121. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts.map +1 -1
  122. package/build/types/new/platform-apis/admin/useMarkings.d.ts.map +1 -1
  123. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts.map +1 -1
  124. package/build/types/new/shapes/derivedLinksStore.d.ts.map +1 -1
  125. package/build/types/new/shapes/useShape.d.ts.map +1 -1
  126. package/build/types/new/useDevToolsClient.d.ts.map +1 -1
  127. package/build/types/new/useLinks.d.ts.map +1 -1
  128. package/build/types/new/useOsdkAction.d.ts.map +1 -1
  129. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  130. package/build/types/new/useOsdkFunction.d.ts.map +1 -1
  131. package/build/types/new/useOsdkFunctions.d.ts.map +1 -1
  132. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  133. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  134. package/build/types/new/useRegisterUserAgent.d.ts.map +1 -1
  135. package/build/types/public/testing.d.ts.map +1 -1
  136. package/build/types/useObservableClient.d.ts.map +1 -1
  137. package/build/types/useOsdkClient.d.ts.map +1 -1
  138. package/build/types/useOsdkMetadata.d.ts.map +1 -1
  139. package/build/types/utils/usePlatformQuery.d.ts.map +1 -1
  140. package/package.json +9 -9
  141. package/build/cjs/chunk-SEFARM7Y.cjs.map +0 -1
  142. package/build/cjs/chunk-UKQGMTMG.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useMarkingCategories.js","names":["MarkingCategories","React","usePlatformQuery","OsdkContext","useMarkingCategories","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","categories","data","isLoading","error","refetch"],"sources":["useMarkingCategories.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MarkingCategory } from \"@osdk/foundry.admin\";\nimport { MarkingCategories } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseMarkingCategoriesOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingCategoriesResult {\n categories: MarkingCategory[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all marking categories.\n * @param options Options to control the query.\n */\nexport function useMarkingCategories(\n { enabled = true }: UseMarkingCategoriesOptions = {},\n): UseMarkingCategoriesResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return MarkingCategories.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"marking-categories\",\n });\n\n return {\n categories: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA2BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClC;EAAEC,OAAO,GAAG;AAAkC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC5B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,iBAAiB,CAACU,IAAI,CAACJ,MAAM,CAAC;EACvC,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC5BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useMarkingCategories.js","names":["MarkingCategories","React","usePlatformQuery","OsdkContext","useMarkingCategories","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","categories","data","isLoading","error","refetch"],"sources":["useMarkingCategories.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MarkingCategory } from \"@osdk/foundry.admin\";\nimport { MarkingCategories } from \"@osdk/foundry.admin\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseMarkingCategoriesOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingCategoriesResult {\n categories: MarkingCategory[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all marking categories.\n * @param options Options to control the query.\n */\nexport function useMarkingCategories({\n enabled = true,\n}: UseMarkingCategoriesOptions = {}): UseMarkingCategoriesResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return MarkingCategories.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"marking-categories\",\n });\n\n return {\n categories: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA2BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAC;EACnCC,OAAO,GAAG;AACiB,CAAC,GAAG,CAAC,CAAC,EAA8B;EAC/D,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,iBAAiB,CAACU,IAAI,CAACJ,MAAM,CAAC;EACvC,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC5BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useMarkings.js","names":["Markings","React","usePlatformQuery","OsdkContext","useMarkings","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","markings","data","isLoading","error","refetch"],"sources":["useMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Marking } from \"@osdk/foundry.admin\";\nimport { Markings } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseMarkingsOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingsResult {\n markings: Marking[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all markings.\n * @param options Options to control the query.\n */\nexport function useMarkings(\n { enabled = true }: UseMarkingsOptions = {},\n): UseMarkingsResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Markings.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"markings\",\n });\n\n return {\n markings: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA2BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzB;EAAEC,OAAO,GAAG;AAAyB,CAAC,GAAG,CAAC,CAAC,EACxB;EACnB,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,QAAQ,CAACU,IAAI,CAACJ,MAAM,CAAC;EAC9B,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,QAAQ,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC1BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useMarkings.js","names":["Markings","React","usePlatformQuery","OsdkContext","useMarkings","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","markings","data","isLoading","error","refetch"],"sources":["useMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Marking } from \"@osdk/foundry.admin\";\nimport { Markings } from \"@osdk/foundry.admin\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseMarkingsOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingsResult {\n markings: Marking[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all markings.\n * @param options Options to control the query.\n */\nexport function useMarkings({\n enabled = true,\n}: UseMarkingsOptions = {}): UseMarkingsResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Markings.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"markings\",\n });\n\n return {\n markings: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA2BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAC;EAC1BC,OAAO,GAAG;AACQ,CAAC,GAAG,CAAC,CAAC,EAAqB;EAC7C,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,QAAQ,CAACU,IAAI,CAACJ,MAAM,CAAC;EAC9B,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,QAAQ,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC1BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useUserMarkings.js","names":["Users","React","usePlatformQuery","OsdkContext","useUserViewMarkings","userId","enabled","client","useContext","handleQuery","useCallback","resolvedUserId","getCurrent","id","getMarkings","query","queryName","markingIds","data","view","isLoading","error","refetch"],"sources":["useUserMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseUserViewMarkingsOptions {\n /**\n * The user ID to fetch view markings for.\n * When omitted, fetches markings for the current user.\n */\n userId?: string;\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseUserViewMarkingsResult {\n markingIds: string[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get view-accessible markings for a user.\n * When `userId` is provided, fetches markings for that user.\n * When omitted, fetches markings for the current user.\n * @param options Options to control the query.\n */\nexport function useUserViewMarkings(\n { userId, enabled = true }: UseUserViewMarkingsOptions = {},\n): UseUserViewMarkingsResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(async () => {\n const resolvedUserId = userId\n ?? (await Users.getCurrent(client)).id;\n return Users.getMarkings(client, resolvedUserId);\n }, [client, userId]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"user-view-markings\",\n });\n\n return {\n markingIds: query.data?.view,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,qBAAqB;AAC3C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAgClD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,MAAM;EAAEC,OAAO,GAAG;AAAiC,CAAC,GAAG,CAAC,CAAC,EAChC;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,WAAW,CAAC;EAEhD,MAAMM,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,YAAY;IAChD,MAAMC,cAAc,GAAGN,MAAM,IACxB,CAAC,MAAML,KAAK,CAACY,UAAU,CAACL,MAAM,CAAC,EAAEM,EAAE;IACxC,OAAOb,KAAK,CAACc,WAAW,CAACP,MAAM,EAAEI,cAAc,CAAC;EAClD,CAAC,EAAE,CAACJ,MAAM,EAAEF,MAAM,CAAC,CAAC;EAEpB,MAAMU,KAAK,GAAGb,gBAAgB,CAAC;IAC7Ba,KAAK,EAAEN,WAAW;IAClBH,OAAO;IACPU,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEC,IAAI;IAC5BC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useUserMarkings.js","names":["Users","React","usePlatformQuery","OsdkContext","useUserViewMarkings","userId","enabled","client","useContext","handleQuery","useCallback","resolvedUserId","getCurrent","id","getMarkings","query","queryName","markingIds","data","view","isLoading","error","refetch"],"sources":["useUserMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseUserViewMarkingsOptions {\n /**\n * The user ID to fetch view markings for.\n * When omitted, fetches markings for the current user.\n */\n userId?: string;\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseUserViewMarkingsResult {\n markingIds: string[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get view-accessible markings for a user.\n * When `userId` is provided, fetches markings for that user.\n * When omitted, fetches markings for the current user.\n * @param options Options to control the query.\n */\nexport function useUserViewMarkings({\n userId,\n enabled = true,\n}: UseUserViewMarkingsOptions = {}): UseUserViewMarkingsResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(async () => {\n const resolvedUserId = userId ?? (await Users.getCurrent(client)).id;\n return Users.getMarkings(client, resolvedUserId);\n }, [client, userId]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"user-view-markings\",\n });\n\n return {\n markingIds: query.data?.view,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,qBAAqB;AAC3C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAgClD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAC;EAClCC,MAAM;EACNC,OAAO,GAAG;AACgB,CAAC,GAAG,CAAC,CAAC,EAA6B;EAC7D,MAAM;IAAEC;EAAO,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,WAAW,CAAC;EAEhD,MAAMM,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,YAAY;IAChD,MAAMC,cAAc,GAAGN,MAAM,IAAI,CAAC,MAAML,KAAK,CAACY,UAAU,CAACL,MAAM,CAAC,EAAEM,EAAE;IACpE,OAAOb,KAAK,CAACc,WAAW,CAACP,MAAM,EAAEI,cAAc,CAAC;EAClD,CAAC,EAAE,CAACJ,MAAM,EAAEF,MAAM,CAAC,CAAC;EAEpB,MAAMU,KAAK,GAAGb,gBAAgB,CAAC;IAC7Ba,KAAK,EAAEN,WAAW;IAClBH,OAAO;IACPU,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEC,IAAI;IAC5BC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"derivedLinksStore.js","names":["applyShapeTransformationsToArray","buildObjectSetFromLinkDefByType","getLinkQueryOptions","createCachingNotifier","createStoreSubscribe","createVersionedCache","wrapError","buildDataWithNestedLinks","cleanupNestedMap","createLinkEntry","violationsToError","createEmptyDerivedLinksStore","isBatchableLink","NOOP_FETCH_MORE","NESTED_FLUSH_DELAY_MS","pruneStaleNestedEntries","nestedByPk","currentPks","pk","nestedMap","has","delete","createDerivedLinksStore","shape","sourceObject","observableClient","client","linkConfig","linkEntries","Map","derivedLinks","__derivedLinks","linkDef","config","name","set","defer","subscribers","Set","cache","notifySubscribers","pendingNestedEntries","nestedFlushTimer","isDestroyed","scheduleNestedFlush","setTimeout","undefined","batch","splice","filter","entry","cleaned","length","startLinksInBatch","trackNestedLinksForObjects","parentEntry","rawObjects","nestedDerivedLinks","targetShape","rawObj","$primaryKey","add","get","nestedLinkDef","nestedEntry","status","push","sourceType","__baseType","handleNestedLinks","pendingBefore","entries","error","startLinkObservationInternal","catch","err","startLinkObservation","createLinkObserver","next","payload","resolved","resolvedList","transformResult","hasMore","fetchMore","violations","data","complete","objectSet","objectSetDef","queryOptions","pageSize","subscription","observeObjectSet","where","orderBy","autoFetchMore","streamUpdates","unsubscribe","destroy","clearTimeout","values","clear","subscribe","entriesToStart","getSnapShot","buildSnapshot","links","linkStatus","anyLoading","anyError","isLoadingOrInit","isLoading","loadDeferred","linkName","String","retry","retryEntry"],"sources":["derivedLinksStore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Store layer for one source object's derived links on a given shape. Owns\n * one `LinkEntry` per top-level derived link. If a link's target shape has\n * its own derived links, also owns one `LinkEntry` per (pk, nestedLinkName)\n * under the parent's `nestedByPk`. Feeds `useSyncExternalStore` via\n * `subscribe` / `getSnapShot`. Teardown is one-way via `destroy`.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type { ShapeDerivedLinkDef } from \"@osdk/api/shapes-internal\";\nimport type {\n LinkLoadConfig,\n LinkStatus,\n ShapeBaseType,\n ShapeDefinition,\n ShapeDerivedLinks,\n} from \"@osdk/api/unstable\";\nimport type { Client } from \"@osdk/client\";\nimport type { ObservableClient, Observer } from \"@osdk/client/observable\";\nimport {\n applyShapeTransformationsToArray,\n buildObjectSetFromLinkDefByType,\n getLinkQueryOptions,\n} from \"@osdk/client/unstable-do-not-use\";\nimport {\n createCachingNotifier,\n createStoreSubscribe,\n createVersionedCache,\n wrapError,\n} from \"../shared/storeUtils.js\";\nimport type {\n AnyShapeInstance,\n DerivedLinksPayload,\n DerivedLinksStore,\n LinkEntry,\n ListObserverPayload,\n} from \"./types.js\";\nimport {\n buildDataWithNestedLinks,\n cleanupNestedMap,\n createLinkEntry,\n violationsToError,\n} from \"./types.js\";\n\nexport type {\n AnyShapeInstance,\n DerivedLinksPayload,\n DerivedLinksStore,\n} from \"./types.js\";\nexport {\n buildDataWithNestedLinks,\n cleanupNestedMap,\n createEmptyDerivedLinksStore,\n isBatchableLink,\n NOOP_FETCH_MORE,\n violationsToError,\n} from \"./types.js\";\n\n/**\n * Debounce window before starting newly-queued nested link observations.\n * When a parent list resolves, each item needs its own nested link\n * subscriptions. If the parent observer emits a few times in quick\n * succession (e.g. streamUpdates), we collapse those into one\n * `startLinksInBatch` call instead of kicking off subscriptions per\n * emission. 25ms is a guess: small enough to feel instant, large enough\n * to coalesce sync-ish bursts. Not tuned against real workloads.\n */\nconst NESTED_FLUSH_DELAY_MS = 25;\n\n/**\n * Removes nested entries for pks that are no longer in the parent's result\n * set. `cleanupNestedMap` recursively unsubscribes each entry and marks it\n * `cleaned`, which allows any already-queued flushes for those entries to\n * no-op gracefully.\n */\nfunction pruneStaleNestedEntries(\n nestedByPk: Map<string | number, Map<string, LinkEntry>>,\n currentPks: Set<string | number>,\n): void {\n for (const [pk, nestedMap] of nestedByPk) {\n if (!currentPks.has(pk)) {\n cleanupNestedMap(nestedMap);\n nestedByPk.delete(pk);\n }\n }\n}\n\n/**\n * Creates a store that observes all derived links for a single source\n * object against the given shape. Returned methods:\n *\n * - `subscribe(notify)`: add a listener. First subscribe kicks off\n * observation of all non-deferred top-level links. Last unsubscribe\n * triggers `destroy`.\n * - `getSnapShot()`: read a cached snapshot of all link data + statuses.\n * - `loadDeferred(linkName)`: start a link configured with `defer: true`.\n * - `retry(linkName?)`: restart error-state entries.\n * - `destroy()`: one-way teardown; cascades through nested subscriptions.\n */\nexport function createDerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(\n shape: S,\n sourceObject: Osdk.Instance<ShapeBaseType<S>>,\n observableClient: ObservableClient,\n client: Client,\n linkConfig: Partial<Record<keyof ShapeDerivedLinks<S>, LinkLoadConfig>>,\n): DerivedLinksStore<S> {\n const castSource = sourceObject as Osdk.Instance<ObjectOrInterfaceDefinition>;\n const linkEntries = new Map<string, LinkEntry>();\n const derivedLinks = shape.__derivedLinks as readonly ShapeDerivedLinkDef[];\n for (const linkDef of derivedLinks) {\n const config = (linkConfig as Partial<Record<string, LinkLoadConfig>>)[\n linkDef.name\n ];\n linkEntries.set(\n linkDef.name,\n createLinkEntry(linkDef, castSource, config?.defer),\n );\n }\n const subscribers = new Set<() => void>();\n const cache = createVersionedCache<DerivedLinksPayload<S>>();\n const notifySubscribers = createCachingNotifier(subscribers, cache);\n\n const pendingNestedEntries: Array<\n { entry: LinkEntry; sourceType: ObjectOrInterfaceDefinition }\n > = [];\n let nestedFlushTimer: ReturnType<typeof setTimeout> | undefined;\n let isDestroyed = false;\n\n /**\n * Schedules a single flush of `pendingNestedEntries` after the debounce\n * window. An entry can be pruned (via `cleanupNestedMap` setting `cleaned`)\n * between being queued and the flush firing, so we filter those out here\n * instead of trying to remove them from the queue at prune time.\n */\n function scheduleNestedFlush(): void {\n if (nestedFlushTimer != null) {\n return;\n }\n nestedFlushTimer = setTimeout(() => {\n nestedFlushTimer = undefined;\n if (isDestroyed) {\n return;\n }\n const batch = pendingNestedEntries.splice(0).filter(({ entry }) =>\n !entry.cleaned\n );\n if (batch.length > 0) {\n startLinksInBatch(batch);\n }\n }, NESTED_FLUSH_DELAY_MS);\n }\n\n /**\n * For each raw object in a parent's result set, ensure a nested `LinkEntry`\n * exists for every nested derived link the target shape declares. New entries\n * with status `\"init\"` are queued for batched startup; returns the set of\n * pks seen so the caller can prune entries whose pks disappeared.\n */\n function trackNestedLinksForObjects(\n parentEntry: LinkEntry,\n rawObjects: Osdk.Instance<ObjectOrInterfaceDefinition>[],\n ): Set<string | number> {\n const nestedDerivedLinks = parentEntry.linkDef.targetShape\n .__derivedLinks as readonly ShapeDerivedLinkDef[];\n const currentPks = new Set<string | number>();\n\n for (const rawObj of rawObjects) {\n const pk = rawObj.$primaryKey;\n currentPks.add(pk);\n\n let nestedMap = parentEntry.nestedByPk.get(pk);\n if (!nestedMap) {\n nestedMap = new Map();\n parentEntry.nestedByPk.set(pk, nestedMap);\n }\n\n for (const nestedLinkDef of nestedDerivedLinks) {\n if (!nestedMap.has(nestedLinkDef.name)) {\n const nestedEntry = createLinkEntry(nestedLinkDef, rawObj);\n nestedMap.set(nestedLinkDef.name, nestedEntry);\n if (nestedEntry.status === \"init\") {\n pendingNestedEntries.push({\n entry: nestedEntry,\n sourceType: parentEntry.linkDef.targetShape.__baseType,\n });\n }\n }\n }\n }\n\n return currentPks;\n }\n\n /**\n * Called every time a parent link's observer emits. Three steps:\n * 1. Ensure nested entries exist for each raw object (and queue new ones).\n * 2. Prune nested entries for pks no longer in the result set.\n * 3. If new entries were queued, schedule the debounced flush to start them.\n */\n function handleNestedLinks(\n parentEntry: LinkEntry,\n rawObjects: Osdk.Instance<ObjectOrInterfaceDefinition>[],\n ): void {\n const nestedDerivedLinks = parentEntry.linkDef.targetShape\n .__derivedLinks as readonly ShapeDerivedLinkDef[];\n if (nestedDerivedLinks.length === 0) {\n return;\n }\n\n const pendingBefore = pendingNestedEntries.length;\n const currentPks = trackNestedLinksForObjects(parentEntry, rawObjects);\n pruneStaleNestedEntries(parentEntry.nestedByPk, currentPks);\n\n if (pendingNestedEntries.length > pendingBefore) {\n scheduleNestedFlush();\n }\n }\n\n /**\n * Moves a batch of entries to `\"loading\"` in one pass, notifies subscribers\n * once for the bulk status change, and then kicks off each entry's async\n * observation. Errors from `startLinkObservationInternal` flip the entry\n * to `\"error\"` individually.\n */\n function startLinksInBatch(\n entries: Array<\n { entry: LinkEntry; sourceType: ObjectOrInterfaceDefinition }\n >,\n ): void {\n for (const { entry } of entries) {\n entry.status = \"loading\";\n entry.error = undefined;\n }\n notifySubscribers();\n for (const { entry, sourceType } of entries) {\n startLinkObservationInternal(entry, sourceType).catch((err) => {\n entry.status = \"error\";\n entry.error = wrapError(err);\n notifySubscribers();\n });\n }\n }\n\n /** Skips links already loading/loaded, otherwise marks as loading and starts observation. */\n function startLinkObservation(\n entry: LinkEntry,\n sourceType: ObjectOrInterfaceDefinition,\n ): void {\n if (entry.status === \"loading\" || entry.status === \"loaded\") {\n return;\n }\n startLinksInBatch([{ entry, sourceType }]);\n }\n\n /**\n * Observer used for `observeObjectSet` on each link entry. On `next` it\n * applies shape transformations, updates entry state, recurses into nested\n * link handling, and rebuilds the entry's data with any nested link data\n * attached. On `error` it flips the entry to `\"error\"`.\n */\n function createLinkObserver(\n entry: LinkEntry,\n ): Observer<ListObserverPayload> {\n return {\n next: (payload) => {\n if (isDestroyed) {\n return;\n }\n const resolved = payload.resolvedList ?? [];\n const transformResult = applyShapeTransformationsToArray(\n entry.linkDef.targetShape,\n resolved,\n );\n\n entry.status = payload.status === \"loading\" ? \"loading\" : \"loaded\";\n entry.hasMore = payload.hasMore;\n entry.fetchMore = payload.fetchMore;\n entry.error = violationsToError(\n entry.linkDef.targetShape,\n transformResult.violations,\n );\n\n handleNestedLinks(entry, resolved);\n entry.data = buildDataWithNestedLinks(entry, transformResult.data);\n\n notifySubscribers();\n },\n error: (err) => {\n if (isDestroyed) {\n return;\n }\n entry.status = \"error\";\n entry.error = wrapError(err);\n notifySubscribers();\n },\n complete: () => {},\n };\n }\n\n async function startLinkObservationInternal(\n entry: LinkEntry,\n sourceType: ObjectOrInterfaceDefinition,\n ): Promise<void> {\n const objectSet = await buildObjectSetFromLinkDefByType(\n client,\n sourceType,\n entry.sourceObject.$primaryKey,\n entry.linkDef.objectSetDef,\n );\n\n if (isDestroyed) {\n return;\n }\n\n const config = linkEntries.has(entry.linkDef.name)\n ? linkConfig[entry.linkDef.name as keyof ShapeDerivedLinks<S>]\n : undefined;\n\n const queryOptions = getLinkQueryOptions(\n entry.linkDef.objectSetDef,\n entry.sourceObject,\n config?.pageSize,\n );\n\n const subscription = observableClient.observeObjectSet(\n objectSet as ObjectSet<ObjectTypeDefinition>,\n {\n where: queryOptions.where,\n orderBy: queryOptions.orderBy,\n pageSize: queryOptions.pageSize,\n autoFetchMore: config?.autoFetchMore,\n streamUpdates: config?.streamUpdates,\n },\n createLinkObserver(entry),\n );\n\n if (isDestroyed) {\n subscription.unsubscribe();\n return;\n }\n entry.subscription = subscription;\n }\n\n function buildSnapshot(): DerivedLinksPayload<S> {\n return cache.get(() => {\n const links: Record<string, AnyShapeInstance[]> = {};\n const linkStatus: Record<string, LinkStatus> = {};\n let anyLoading = false;\n let anyError = false;\n\n for (const [name, entry] of linkEntries) {\n links[name] = entry.data;\n const isLoadingOrInit = entry.status === \"loading\"\n || entry.status === \"init\";\n if (isLoadingOrInit) {\n anyLoading = true;\n }\n if (entry.status === \"error\") {\n anyError = true;\n }\n linkStatus[name] = {\n isLoading: isLoadingOrInit,\n error: entry.error,\n hasMore: entry.hasMore,\n fetchMore: entry.fetchMore,\n };\n }\n\n return {\n links,\n linkStatus: linkStatus as Partial<\n { [K in keyof ShapeDerivedLinks<S>]: LinkStatus }\n >,\n anyLoading,\n anyError,\n };\n });\n }\n\n /**\n * One-way teardown. Order matters: set `isDestroyed` first so in-flight\n * async work (observer next/error, startLinkObservationInternal) no-ops.\n * Then clear the flush timer, drop the pending queue, unsubscribe every\n * entry, and cascade through `nestedByPk`.\n */\n function destroy(): void {\n isDestroyed = true;\n if (nestedFlushTimer != null) {\n clearTimeout(nestedFlushTimer);\n nestedFlushTimer = undefined;\n }\n pendingNestedEntries.length = 0;\n for (const entry of linkEntries.values()) {\n entry.subscription?.unsubscribe();\n for (const nestedMap of entry.nestedByPk.values()) {\n cleanupNestedMap(nestedMap);\n }\n }\n linkEntries.clear();\n }\n\n const subscribe = createStoreSubscribe(\n subscribers,\n () => {\n const entriesToStart: Array<\n { entry: LinkEntry; sourceType: ObjectOrInterfaceDefinition }\n > = [];\n for (const entry of linkEntries.values()) {\n if (entry.status === \"init\") {\n entriesToStart.push({ entry, sourceType: shape.__baseType });\n }\n }\n if (entriesToStart.length > 0) {\n startLinksInBatch(entriesToStart);\n }\n },\n destroy,\n );\n\n /**\n * Starts observation for a link that was configured with `defer: true`.\n * No-op for unknown link names or links not in the `deferred` state.\n */\n function loadDeferred(\n linkName: keyof ShapeDerivedLinks<S>,\n ): void {\n const entry = linkEntries.get(String(linkName));\n if (!entry || entry.status !== \"deferred\") {\n return;\n }\n startLinkObservation(entry, shape.__baseType);\n }\n\n /**\n * Resets error-state entries back to `\"init\"` and restarts observation.\n * With a `linkName`, scopes to a single entry; otherwise retries all links.\n * No-op for entries not currently in `\"error\"`.\n */\n function retry(linkName?: keyof ShapeDerivedLinks<S>): void {\n const retryEntry = (entry: LinkEntry) => {\n if (entry.status !== \"error\") {\n return;\n }\n entry.subscription?.unsubscribe();\n entry.status = \"init\";\n entry.error = undefined;\n entry.subscription = undefined;\n startLinkObservation(entry, shape.__baseType);\n };\n\n if (linkName) {\n const entry = linkEntries.get(String(linkName));\n if (entry) {\n retryEntry(entry);\n }\n } else {\n for (const entry of linkEntries.values()) {\n retryEntry(entry);\n }\n }\n }\n\n return {\n subscribe,\n getSnapShot: buildSnapshot,\n loadDeferred,\n retry,\n destroy,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,SACEA,gCAAgC,EAChCC,+BAA+B,EAC/BC,mBAAmB,QACd,kCAAkC;AACzC,SACEC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,EACpBC,SAAS,QACJ,yBAAyB;AAQhC,SACEC,wBAAwB,EACxBC,gBAAgB,EAChBC,eAAe,EACfC,iBAAiB,QACZ,YAAY;AAOnB,SACEH,wBAAwB,EACxBC,gBAAgB,EAChBG,4BAA4B,EAC5BC,eAAe,EACfC,eAAe,EACfH,iBAAiB,QACZ,YAAY;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,qBAAqB,GAAG,EAAE;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,uBAAuBA,CAC9BC,UAAwD,EACxDC,UAAgC,EAC1B;EACN,KAAK,MAAM,CAACC,EAAE,EAAEC,SAAS,CAAC,IAAIH,UAAU,EAAE;IACxC,IAAI,CAACC,UAAU,CAACG,GAAG,CAACF,EAAE,CAA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CAACqD,MAAM,CAACD,QAAQ,CAAC,CAAC;QAC/C,IAAIhE,KAAK,EAAE;UACTmE,UAAU,CAACnE,KAAK,CAAC;QACnB;MACF,CAAC,MAAM;QACL,KAAK,MAAMA,KAAK,IAAItB,WAAW,CAACyE,MAAM,CAAC,CAAC,EAAE;UACxCgB,UAAU,CAACnE,KAAK,CAAC;QACnB;MACF;IACF,CAMO;IACLiD;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"derivedLinksStore.js","names":["applyShapeTransformationsToArray","buildObjectSetFromLinkDefByType","getLinkQueryOptions","createCachingNotifier","createStoreSubscribe","createVersionedCache","wrapError","buildDataWithNestedLinks","cleanupNestedMap","createLinkEntry","violationsToError","createEmptyDerivedLinksStore","isBatchableLink","NOOP_FETCH_MORE","NESTED_FLUSH_DELAY_MS","pruneStaleNestedEntries","nestedByPk","currentPks","pk","nestedMap","has","delete","createDerivedLinksStore","shape","sourceObject","observableClient","client","linkConfig","linkEntries","Map","derivedLinks","__derivedLinks","linkDef","config","name","set","defer","subscribers","Set","cache","notifySubscribers","pendingNestedEntries","nestedFlushTimer","isDestroyed","scheduleNestedFlush","setTimeout","undefined","batch","splice","filter","entry","cleaned","length","startLinksInBatch","trackNestedLinksForObjects","parentEntry","rawObjects","nestedDerivedLinks","targetShape","rawObj","$primaryKey","add","get","nestedLinkDef","nestedEntry","status","push","sourceType","__baseType","handleNestedLinks","pendingBefore","entries","error","startLinkObservationInternal","catch","err","startLinkObservation","createLinkObserver","next","payload","resolved","resolvedList","transformResult","hasMore","fetchMore","violations","data","complete","objectSet","objectSetDef","queryOptions","pageSize","subscription","observeObjectSet","where","orderBy","autoFetchMore","streamUpdates","unsubscribe","destroy","clearTimeout","values","clear","subscribe","entriesToStart","getSnapShot","buildSnapshot","links","linkStatus","anyLoading","anyError","isLoadingOrInit","isLoading","loadDeferred","linkName","String","retry","retryEntry"],"sources":["derivedLinksStore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Store layer for one source object's derived links on a given shape. Owns\n * one `LinkEntry` per top-level derived link. If a link's target shape has\n * its own derived links, also owns one `LinkEntry` per (pk, nestedLinkName)\n * under the parent's `nestedByPk`. Feeds `useSyncExternalStore` via\n * `subscribe` / `getSnapShot`. Teardown is one-way via `destroy`.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type { ShapeDerivedLinkDef } from \"@osdk/api/shapes-internal\";\nimport type {\n LinkLoadConfig,\n LinkStatus,\n ShapeBaseType,\n ShapeDefinition,\n ShapeDerivedLinks,\n} from \"@osdk/api/unstable\";\nimport type { Client } from \"@osdk/client\";\nimport type { ObservableClient, Observer } from \"@osdk/client/observable\";\nimport {\n applyShapeTransformationsToArray,\n buildObjectSetFromLinkDefByType,\n getLinkQueryOptions,\n} from \"@osdk/client/unstable-do-not-use\";\n\nimport {\n createCachingNotifier,\n createStoreSubscribe,\n createVersionedCache,\n wrapError,\n} from \"../shared/storeUtils.js\";\nimport type {\n AnyShapeInstance,\n DerivedLinksPayload,\n DerivedLinksStore,\n LinkEntry,\n ListObserverPayload,\n} from \"./types.js\";\nimport {\n buildDataWithNestedLinks,\n cleanupNestedMap,\n createLinkEntry,\n violationsToError,\n} from \"./types.js\";\n\nexport type {\n AnyShapeInstance,\n DerivedLinksPayload,\n DerivedLinksStore,\n} from \"./types.js\";\nexport {\n buildDataWithNestedLinks,\n cleanupNestedMap,\n createEmptyDerivedLinksStore,\n isBatchableLink,\n NOOP_FETCH_MORE,\n violationsToError,\n} from \"./types.js\";\n\n/**\n * Debounce window before starting newly-queued nested link observations.\n * When a parent list resolves, each item needs its own nested link\n * subscriptions. If the parent observer emits a few times in quick\n * succession (e.g. streamUpdates), we collapse those into one\n * `startLinksInBatch` call instead of kicking off subscriptions per\n * emission. 25ms is a guess: small enough to feel instant, large enough\n * to coalesce sync-ish bursts. Not tuned against real workloads.\n */\nconst NESTED_FLUSH_DELAY_MS = 25;\n\n/**\n * Removes nested entries for pks that are no longer in the parent's result\n * set. `cleanupNestedMap` recursively unsubscribes each entry and marks it\n * `cleaned`, which allows any already-queued flushes for those entries to\n * no-op gracefully.\n */\nfunction pruneStaleNestedEntries(\n nestedByPk: Map<string | number, Map<string, LinkEntry>>,\n currentPks: Set<string | number>\n): void {\n for (const [pk, nestedMap] of nestedByPk) {\n if (!currentPks.has(pk)) {\n cleanupNestedMap(nestedMap);\n nestedByPk.delete(pk);\n }\n }\n}\n\n/**\n * Creates a store that observes all derived links for a single source\n * object against the given shape. Returned methods:\n *\n * - `subscribe(notify)`: add a listener. First subscribe kicks off\n * observation of all non-deferred top-level links. Last unsubscribe\n * triggers `destroy`.\n * - `getSnapShot()`: read a cached snapshot of all link data + statuses.\n * - `loadDeferred(linkName)`: start a link configured with `defer: true`.\n * - `retry(linkName?)`: restart error-state entries.\n * - `destroy()`: one-way teardown; cascades through nested subscriptions.\n */\nexport function createDerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(\n shape: S,\n sourceObject: Osdk.Instance<ShapeBaseType<S>>,\n observableClient: ObservableClient,\n client: Client,\n linkConfig: Partial<Record<keyof ShapeDerivedLinks<S>, LinkLoadConfig>>\n): DerivedLinksStore<S> {\n const castSource = sourceObject as Osdk.Instance<ObjectOrInterfaceDefinition>;\n const linkEntries = new Map<string, LinkEntry>();\n const derivedLinks = shape.__derivedLinks as readonly ShapeDerivedLinkDef[];\n for (const linkDef of derivedLinks) {\n const config = (linkConfig as Partial<Record<string, LinkLoadConfig>>)[\n linkDef.name\n ];\n linkEntries.set(\n linkDef.name,\n createLinkEntry(linkDef, castSource, config?.defer)\n );\n }\n const subscribers = new Set<() => void>();\n const cache = createVersionedCache<DerivedLinksPayload<S>>();\n const notifySubscribers = createCachingNotifier(subscribers, cache);\n\n const pendingNestedEntries: Array<{\n entry: LinkEntry;\n sourceType: ObjectOrInterfaceDefinition;\n }> = [];\n let nestedFlushTimer: ReturnType<typeof setTimeout> | undefined;\n let isDestroyed = false;\n\n /**\n * Schedules a single flush of `pendingNestedEntries` after the debounce\n * window. An entry can be pruned (via `cleanupNestedMap` setting `cleaned`)\n * between being queued and the flush firing, so we filter those out here\n * instead of trying to remove them from the queue at prune time.\n */\n function scheduleNestedFlush(): void {\n if (nestedFlushTimer != null) {\n return;\n }\n nestedFlushTimer = setTimeout(() => {\n nestedFlushTimer = undefined;\n if (isDestroyed) {\n return;\n }\n const batch = pendingNestedEntries\n .splice(0)\n .filter(({ entry }) => !entry.cleaned);\n if (batch.length > 0) {\n startLinksInBatch(batch);\n }\n }, NESTED_FLUSH_DELAY_MS);\n }\n\n /**\n * For each raw object in a parent's result set, ensure a nested `LinkEntry`\n * exists for every nested derived link the target shape declares. New entries\n * with status `\"init\"` are queued for batched startup; returns the set of\n * pks seen so the caller can prune entries whose pks disappeared.\n */\n function trackNestedLinksForObjects(\n parentEntry: LinkEntry,\n rawObjects: Osdk.Instance<ObjectOrInterfaceDefinition>[]\n ): Set<string | number> {\n const nestedDerivedLinks = parentEntry.linkDef.targetShape\n .__derivedLinks as readonly ShapeDerivedLinkDef[];\n const currentPks = new Set<string | number>();\n\n for (const rawObj of rawObjects) {\n const pk = rawObj.$primaryKey;\n currentPks.add(pk);\n\n let nestedMap = parentEntry.nestedByPk.get(pk);\n if (!nestedMap) {\n nestedMap = new Map();\n parentEntry.nestedByPk.set(pk, nestedMap);\n }\n\n for (const nestedLinkDef of nestedDerivedLinks) {\n if (!nestedMap.has(nestedLinkDef.name)) {\n const nestedEntry = createLinkEntry(nestedLinkDef, rawObj);\n nestedMap.set(nestedLinkDef.name, nestedEntry);\n if (nestedEntry.status === \"init\") {\n pendingNestedEntries.push({\n entry: nestedEntry,\n sourceType: parentEntry.linkDef.targetShape.__baseType,\n });\n }\n }\n }\n }\n\n return currentPks;\n }\n\n /**\n * Called every time a parent link's observer emits. Three steps:\n * 1. Ensure nested entries exist for each raw object (and queue new ones).\n * 2. Prune nested entries for pks no longer in the result set.\n * 3. If new entries were queued, schedule the debounced flush to start them.\n */\n function handleNestedLinks(\n parentEntry: LinkEntry,\n rawObjects: Osdk.Instance<ObjectOrInterfaceDefinition>[]\n ): void {\n const nestedDerivedLinks = parentEntry.linkDef.targetShape\n .__derivedLinks as readonly ShapeDerivedLinkDef[];\n if (nestedDerivedLinks.length === 0) {\n return;\n }\n\n const pendingBefore = pendingNestedEntries.length;\n const currentPks = trackNestedLinksForObjects(parentEntry, rawObjects);\n pruneStaleNestedEntries(parentEntry.nestedByPk, currentPks);\n\n if (pendingNestedEntries.length > pendingBefore) {\n scheduleNestedFlush();\n }\n }\n\n /**\n * Moves a batch of entries to `\"loading\"` in one pass, notifies subscribers\n * once for the bulk status change, and then kicks off each entry's async\n * observation. Errors from `startLinkObservationInternal` flip the entry\n * to `\"error\"` individually.\n */\n function startLinksInBatch(\n entries: Array<{\n entry: LinkEntry;\n sourceType: ObjectOrInterfaceDefinition;\n }>\n ): void {\n for (const { entry } of entries) {\n entry.status = \"loading\";\n entry.error = undefined;\n }\n notifySubscribers();\n for (const { entry, sourceType } of entries) {\n startLinkObservationInternal(entry, sourceType).catch((err) => {\n entry.status = \"error\";\n entry.error = wrapError(err);\n notifySubscribers();\n });\n }\n }\n\n /** Skips links already loading/loaded, otherwise marks as loading and starts observation. */\n function startLinkObservation(\n entry: LinkEntry,\n sourceType: ObjectOrInterfaceDefinition\n ): void {\n if (entry.status === \"loading\" || entry.status === \"loaded\") {\n return;\n }\n startLinksInBatch([{ entry, sourceType }]);\n }\n\n /**\n * Observer used for `observeObjectSet` on each link entry. On `next` it\n * applies shape transformations, updates entry state, recurses into nested\n * link handling, and rebuilds the entry's data with any nested link data\n * attached. On `error` it flips the entry to `\"error\"`.\n */\n function createLinkObserver(entry: LinkEntry): Observer<ListObserverPayload> {\n return {\n next: (payload) => {\n if (isDestroyed) {\n return;\n }\n const resolved = payload.resolvedList ?? [];\n const transformResult = applyShapeTransformationsToArray(\n entry.linkDef.targetShape,\n resolved\n );\n\n entry.status = payload.status === \"loading\" ? \"loading\" : \"loaded\";\n entry.hasMore = payload.hasMore;\n entry.fetchMore = payload.fetchMore;\n entry.error = violationsToError(\n entry.linkDef.targetShape,\n transformResult.violations\n );\n\n handleNestedLinks(entry, resolved);\n entry.data = buildDataWithNestedLinks(entry, transformResult.data);\n\n notifySubscribers();\n },\n error: (err) => {\n if (isDestroyed) {\n return;\n }\n entry.status = \"error\";\n entry.error = wrapError(err);\n notifySubscribers();\n },\n complete: () => {},\n };\n }\n\n async function startLinkObservationInternal(\n entry: LinkEntry,\n sourceType: ObjectOrInterfaceDefinition\n ): Promise<void> {\n const objectSet = await buildObjectSetFromLinkDefByType(\n client,\n sourceType,\n entry.sourceObject.$primaryKey,\n entry.linkDef.objectSetDef\n );\n\n if (isDestroyed) {\n return;\n }\n\n const config = linkEntries.has(entry.linkDef.name)\n ? linkConfig[entry.linkDef.name as keyof ShapeDerivedLinks<S>]\n : undefined;\n\n const queryOptions = getLinkQueryOptions(\n entry.linkDef.objectSetDef,\n entry.sourceObject,\n config?.pageSize\n );\n\n const subscription = observableClient.observeObjectSet(\n objectSet as ObjectSet<ObjectTypeDefinition>,\n {\n where: queryOptions.where,\n orderBy: queryOptions.orderBy,\n pageSize: queryOptions.pageSize,\n autoFetchMore: config?.autoFetchMore,\n streamUpdates: config?.streamUpdates,\n },\n createLinkObserver(entry)\n );\n\n if (isDestroyed) {\n subscription.unsubscribe();\n return;\n }\n entry.subscription = subscription;\n }\n\n function buildSnapshot(): DerivedLinksPayload<S> {\n return cache.get(() => {\n const links: Record<string, AnyShapeInstance[]> = {};\n const linkStatus: Record<string, LinkStatus> = {};\n let anyLoading = false;\n let anyError = false;\n\n for (const [name, entry] of linkEntries) {\n links[name] = entry.data;\n const isLoadingOrInit =\n entry.status === \"loading\" || entry.status === \"init\";\n if (isLoadingOrInit) {\n anyLoading = true;\n }\n if (entry.status === \"error\") {\n anyError = true;\n }\n linkStatus[name] = {\n isLoading: isLoadingOrInit,\n error: entry.error,\n hasMore: entry.hasMore,\n fetchMore: entry.fetchMore,\n };\n }\n\n return {\n links,\n linkStatus: linkStatus as Partial<{\n [K in keyof ShapeDerivedLinks<S>]: LinkStatus;\n }>,\n anyLoading,\n anyError,\n };\n });\n }\n\n /**\n * One-way teardown. Order matters: set `isDestroyed` first so in-flight\n * async work (observer next/error, startLinkObservationInternal) no-ops.\n * Then clear the flush timer, drop the pending queue, unsubscribe every\n * entry, and cascade through `nestedByPk`.\n */\n function destroy(): void {\n isDestroyed = true;\n if (nestedFlushTimer != null) {\n clearTimeout(nestedFlushTimer);\n nestedFlushTimer = undefined;\n }\n pendingNestedEntries.length = 0;\n for (const entry of linkEntries.values()) {\n entry.subscription?.unsubscribe();\n for (const nestedMap of entry.nestedByPk.values()) {\n cleanupNestedMap(nestedMap);\n }\n }\n linkEntries.clear();\n }\n\n const subscribe = createStoreSubscribe(\n subscribers,\n () => {\n const entriesToStart: Array<{\n entry: LinkEntry;\n sourceType: ObjectOrInterfaceDefinition;\n }> = [];\n for (const entry of linkEntries.values()) {\n if (entry.status === \"init\") {\n entriesToStart.push({ entry, sourceType: shape.__baseType });\n }\n }\n if (entriesToStart.length > 0) {\n startLinksInBatch(entriesToStart);\n }\n },\n destroy\n );\n\n /**\n * Starts observation for a link that was configured with `defer: true`.\n * No-op for unknown link names or links not in the `deferred` state.\n */\n function loadDeferred(linkName: keyof ShapeDerivedLinks<S>): void {\n const entry = linkEntries.get(String(linkName));\n if (!entry || entry.status !== \"deferred\") {\n return;\n }\n startLinkObservation(entry, shape.__baseType);\n }\n\n /**\n * Resets error-state entries back to `\"init\"` and restarts observation.\n * With a `linkName`, scopes to a single entry; otherwise retries all links.\n * No-op for entries not currently in `\"error\"`.\n */\n function retry(linkName?: keyof ShapeDerivedLinks<S>): void {\n const retryEntry = (entry: LinkEntry) => {\n if (entry.status !== \"error\") {\n return;\n }\n entry.subscription?.unsubscribe();\n entry.status = \"init\";\n entry.error = undefined;\n entry.subscription = undefined;\n startLinkObservation(entry, shape.__baseType);\n };\n\n if (linkName) {\n const entry = linkEntries.get(String(linkName));\n if (entry) {\n retryEntry(entry);\n }\n } else {\n for (const entry of linkEntries.values()) {\n retryEntry(entry);\n }\n }\n }\n\n return {\n subscribe,\n getSnapShot: buildSnapshot,\n loadDeferred,\n retry,\n destroy,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,SACEA,gCAAgC,EAChCC,+BAA+B,EAC/BC,mBAAmB,QACd,kCAAkC;AAEzC,SACEC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,EACpBC,SAAS,QACJ,yBAAyB;AAQhC,SACEC,wBAAwB,EACxBC,gBAAgB,EAChBC,eAAe,EACfC,iBAAiB,QACZ,YAAY;AAOnB,SACEH,wBAAwB,EACxBC,gBAAgB,EAChBG,4BAA4B,EAC5BC,eAAe,EACfC,eAAe,EACfH,iBAAiB,QACZ,YAAY;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,qBAAqB,GAAG,EAAE;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,uBAAuBA,CAC9BC,UAAwD,EACxDC,UAAgC,EAC1B;EACN,KAAK,MAAM,CAACC,EAAE,EAAEC,SAAS,CAAC,IAAIH,UAAU,EAAE;IACxC,IAAI,CAACC,UAAU,CAACG,GAAG,CAACF,EA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kC,GAAG,CAACqD,MAAM,CAACD,QAAQ,CAAC,CAAC;QAC/C,IAAIhE,KAAK,EAAE;UACTmE,UAAU,CAACnE,KAAK,CAAC;QACnB;MACF,CAAC,MAAM;QACL,KAAK,MAAMA,KAAK,IAAItB,WAAW,CAACyE,MAAM,CAAC,CAAC,EAAE;UACxCgB,UAAU,CAACnE,KAAK,CAAC;QACnB;MACF;IACF,CAMO;IACLiD;EACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["ShapeNullabilityError","NOOP_FETCH_MORE","violationsToError","shape","violations","some","v","constraint","undefined","createLinkEntry","linkDef","sourceObject","configDefer","isDeferred","config","defer","status","data","error","hasMore","fetchMore","subscription","nestedByPk","Map","cleaned","createEmptyDerivedLinksStore","emptyPayload","links","linkStatus","anyLoading","anyError","subscribe","getSnapShot","loadDeferred","retry","destroy","cleanupNestedMap","map","entry","values","unsubscribe","nestedMap","buildDataWithNestedLinks","transformedData","targetShape","__derivedLinks","length","obj","pk","$primaryKey","get","size","nestedLinks","linkName","nestedEntry","isBatchableLink","def","objectSetDef","segments","type","setOperations","where","orderBy","limit","distinct"],"sources":["types.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 { ObjectOrInterfaceDefinition, Osdk } from \"@osdk/api\";\nimport type { ShapeDerivedLinkDef } from \"@osdk/api/shapes-internal\";\nimport type {\n LinkStatus,\n ShapeDefinition,\n ShapeDerivedLinks,\n ShapeInstance,\n} from \"@osdk/api/unstable\";\nimport { ShapeNullabilityError } from \"@osdk/api/unstable\";\nimport type { Unsubscribable } from \"@osdk/client/observable\";\n\nexport type AnyShapeInstance = ShapeInstance<\n ShapeDefinition<ObjectOrInterfaceDefinition>\n>;\n\nexport type ListObserverPayload = {\n resolvedList: Osdk.Instance<ObjectOrInterfaceDefinition>[] | undefined;\n hasMore: boolean;\n fetchMore: () => Promise<void>;\n status: string;\n isOptimistic: boolean;\n};\n\nexport const NOOP_FETCH_MORE = async (): Promise<void> => {};\n\nexport function violationsToError(\n shape: ShapeDefinition<ObjectOrInterfaceDefinition>,\n violations: readonly { property: string; constraint: string }[],\n): Error | undefined {\n if (violations.some(v => v.constraint === \"require\")) {\n return new ShapeNullabilityError(\n shape,\n violations as readonly {\n property: string;\n primaryKey: unknown;\n constraint: \"require\" | \"dropIfNull\" | \"transformError\";\n }[],\n );\n }\n return undefined;\n}\n\nexport interface LinkEntry {\n linkDef: ShapeDerivedLinkDef;\n sourceObject: Osdk.Instance<ObjectOrInterfaceDefinition>;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" | \"deferred\";\n data: AnyShapeInstance[];\n error?: Error;\n hasMore: boolean;\n fetchMore: () => Promise<void>;\n subscription?: Unsubscribable;\n nestedByPk: Map<string | number, Map<string, LinkEntry>>;\n cleaned: boolean;\n}\n\nexport function createLinkEntry(\n linkDef: ShapeDerivedLinkDef,\n sourceObject: Osdk.Instance<ObjectOrInterfaceDefinition>,\n configDefer?: boolean,\n): LinkEntry {\n const isDeferred = linkDef.config.defer ?? configDefer ?? false;\n return {\n linkDef,\n sourceObject,\n status: isDeferred ? \"deferred\" : \"init\",\n data: [],\n error: undefined,\n hasMore: false,\n fetchMore: NOOP_FETCH_MORE,\n subscription: undefined,\n nestedByPk: new Map(),\n cleaned: false,\n };\n}\n\nexport interface DerivedLinksPayload<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n links: Record<string, AnyShapeInstance[]>;\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n anyLoading: boolean;\n anyError: boolean;\n}\n\nexport interface DerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => DerivedLinksPayload<S>;\n loadDeferred: (linkName: keyof ShapeDerivedLinks<S>) => void;\n retry: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n destroy: () => void;\n}\n\nexport function createEmptyDerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(): DerivedLinksStore<S> {\n const emptyPayload: DerivedLinksPayload<S> = {\n links: {},\n linkStatus: {},\n anyLoading: false,\n anyError: false,\n };\n\n return {\n subscribe: () => () => {},\n getSnapShot: () => emptyPayload,\n loadDeferred: () => {},\n retry: () => {},\n destroy: () => {},\n };\n}\n\nexport function cleanupNestedMap(map: Map<string, LinkEntry>): void {\n for (const entry of map.values()) {\n entry.cleaned = true;\n entry.subscription?.unsubscribe();\n for (const nestedMap of entry.nestedByPk.values()) {\n cleanupNestedMap(nestedMap);\n }\n }\n}\n\nexport function buildDataWithNestedLinks(\n entry: LinkEntry,\n transformedData: AnyShapeInstance[],\n): AnyShapeInstance[] {\n const targetShape = entry.linkDef.targetShape;\n if (targetShape.__derivedLinks.length === 0) {\n return transformedData;\n }\n\n return transformedData.map((obj) => {\n const pk = obj.$primaryKey;\n const nestedMap = entry.nestedByPk.get(pk);\n if (!nestedMap || nestedMap.size === 0) {\n return obj;\n }\n\n const nestedLinks: Record<string, AnyShapeInstance[]> = {};\n for (const [linkName, nestedEntry] of nestedMap) {\n nestedLinks[linkName] = buildDataWithNestedLinks(\n nestedEntry,\n nestedEntry.data,\n );\n }\n\n return { ...obj, ...nestedLinks } as AnyShapeInstance;\n });\n}\n\n/**\n * A link is batchable when it can use observeLinks (one API call for all source\n * objects) instead of per-object observeObjectSet calls. This requires a simple\n * single-hop pivotTo with no filters, ordering, limits, or set operations,\n * since observeLinks doesn't support those query features.\n */\nexport function isBatchableLink(linkDef: ShapeDerivedLinkDef): boolean {\n const def = linkDef.objectSetDef;\n return (\n def.segments.length === 1\n && def.segments[0].type === \"pivotTo\"\n && (!def.setOperations || def.setOperations.length === 0)\n && !def.where\n && !def.orderBy\n && def.limit == null\n && !def.distinct\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,qBAAqB,QAAQ,oBAAoB;AAe1D,OAAO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAA2B,CAAC,CAAC;AAE5D,OAAO,SAASC,iBAAiBA,CAC/BC,KAAmD,EACnDC,UAA+D,EAC5C;EACnB,IAAIA,UAAU,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,UAAU,KAAK,SAAS,CAAC,EAAE;IACpD,OAAO,IAAIP,qBAAqB,CAC9BG,KAAK,EACLC,UAKF,CAAC;EACH;EACA,OAAOI,SAAS;AAClB;AAeA,OAAO,SAASC,eAAeA,CAC7BC,OAA4B,EAC5BC,YAAwD,EACxDC,WAAqB,EACV;EACX,MAAMC,UAAU,GAAGH,OAAO,CAACI,MAAM,CAACC,KAAK,IAAIH,WAAW,IAAI,KAAK;EAC/D,OAAO;IACLF,OAAO;IACPC,YAAY;IACZK,MAAM,EAAEH,UAAU,GAAG,UAAU,GAAG,MAAM;IACxCI,IAAI,EAAE,EAAE;IACRC,KAAK,EAAEV,SAAS;IAChBW,OAAO,EAAE,KAAK;IACdC,SAAS,EAAEnB,eAAe;IAC1BoB,YAAY,EAAEb,SAAS;IACvBc,UAAU,EAAE,IAAIC,GAAG,CAAC,CAAC;IACrBC,OAAO,EAAE;EACX,CAAC;AACH;AAqBA,OAAO,SAASC,4BAA4BA,CAAA,EAElB;EACxB,MAAMC,YAAoC,GAAG;IAC3CC,KAAK,EAAE,CAAC,CAAC;IACTC,UAAU,EAAE,CAAC,CAAC;IACdC,UAAU,EAAE,KAAK;IACjBC,QAAQ,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,wBAAwB,CAC9CY,WAAW,EACXA,WAAW,CAACrC,IACd,CAAC;IACH;IAEA,OAAO;MAAE,GAAG8B,GAAG;MAAE,GAAGK;IAAY,CAAC;EACnC,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,eAAeA,CAAC7C,OAA4B,EAAW;EACrE,MAAM8C,GAAG,GAAG9C,OAAO,CAAC+C,YAAY;EAChC,OACED,GAAG,CAACE,QAAQ,CAACZ,MAAM,KAAK,CAAC,IACtBU,GAAG,CAACE,QAAQ,CAAC,CAAC,CAAC,CAACC,IAAI,KAAK,SAAS,KACjC,CAACH,GAAG,CAACI,aAAa,IAAIJ,GAAG,CAACI,aAAa,CAACd,MAAM,KAAK,CAAC,CAAC,IACtD,CAACU,GAAG,CAACK,KAAK,IACV,CAACL,GAAG,CAACM,OAAO,IACZN,GAAG,CAACO,KAAK,IAAI,IAAI,IACjB,CAACP,GAAG,CAACQ,QAAQ;AAEpB","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":["ShapeNullabilityError","NOOP_FETCH_MORE","violationsToError","shape","violations","some","v","constraint","undefined","createLinkEntry","linkDef","sourceObject","configDefer","isDeferred","config","defer","status","data","error","hasMore","fetchMore","subscription","nestedByPk","Map","cleaned","createEmptyDerivedLinksStore","emptyPayload","links","linkStatus","anyLoading","anyError","subscribe","getSnapShot","loadDeferred","retry","destroy","cleanupNestedMap","map","entry","values","unsubscribe","nestedMap","buildDataWithNestedLinks","transformedData","targetShape","__derivedLinks","length","obj","pk","$primaryKey","get","size","nestedLinks","linkName","nestedEntry","isBatchableLink","def","objectSetDef","segments","type","setOperations","where","orderBy","limit","distinct"],"sources":["types.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 { ObjectOrInterfaceDefinition, Osdk } from \"@osdk/api\";\nimport type { ShapeDerivedLinkDef } from \"@osdk/api/shapes-internal\";\nimport type {\n LinkStatus,\n ShapeDefinition,\n ShapeDerivedLinks,\n ShapeInstance,\n} from \"@osdk/api/unstable\";\nimport { ShapeNullabilityError } from \"@osdk/api/unstable\";\nimport type { Unsubscribable } from \"@osdk/client/observable\";\n\nexport type AnyShapeInstance = ShapeInstance<\n ShapeDefinition<ObjectOrInterfaceDefinition>\n>;\n\nexport type ListObserverPayload = {\n resolvedList: Osdk.Instance<ObjectOrInterfaceDefinition>[] | undefined;\n hasMore: boolean;\n fetchMore: () => Promise<void>;\n status: string;\n isOptimistic: boolean;\n};\n\nexport const NOOP_FETCH_MORE = async (): Promise<void> => {};\n\nexport function violationsToError(\n shape: ShapeDefinition<ObjectOrInterfaceDefinition>,\n violations: readonly { property: string; constraint: string }[]\n): Error | undefined {\n if (violations.some((v) => v.constraint === \"require\")) {\n return new ShapeNullabilityError(\n shape,\n violations as readonly {\n property: string;\n primaryKey: unknown;\n constraint: \"require\" | \"dropIfNull\" | \"transformError\";\n }[]\n );\n }\n return undefined;\n}\n\nexport interface LinkEntry {\n linkDef: ShapeDerivedLinkDef;\n sourceObject: Osdk.Instance<ObjectOrInterfaceDefinition>;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" | \"deferred\";\n data: AnyShapeInstance[];\n error?: Error;\n hasMore: boolean;\n fetchMore: () => Promise<void>;\n subscription?: Unsubscribable;\n nestedByPk: Map<string | number, Map<string, LinkEntry>>;\n cleaned: boolean;\n}\n\nexport function createLinkEntry(\n linkDef: ShapeDerivedLinkDef,\n sourceObject: Osdk.Instance<ObjectOrInterfaceDefinition>,\n configDefer?: boolean\n): LinkEntry {\n const isDeferred = linkDef.config.defer ?? configDefer ?? false;\n return {\n linkDef,\n sourceObject,\n status: isDeferred ? \"deferred\" : \"init\",\n data: [],\n error: undefined,\n hasMore: false,\n fetchMore: NOOP_FETCH_MORE,\n subscription: undefined,\n nestedByPk: new Map(),\n cleaned: false,\n };\n}\n\nexport interface DerivedLinksPayload<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n links: Record<string, AnyShapeInstance[]>;\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n anyLoading: boolean;\n anyError: boolean;\n}\n\nexport interface DerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => DerivedLinksPayload<S>;\n loadDeferred: (linkName: keyof ShapeDerivedLinks<S>) => void;\n retry: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n destroy: () => void;\n}\n\nexport function createEmptyDerivedLinksStore<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(): DerivedLinksStore<S> {\n const emptyPayload: DerivedLinksPayload<S> = {\n links: {},\n linkStatus: {},\n anyLoading: false,\n anyError: false,\n };\n\n return {\n subscribe: () => () => {},\n getSnapShot: () => emptyPayload,\n loadDeferred: () => {},\n retry: () => {},\n destroy: () => {},\n };\n}\n\nexport function cleanupNestedMap(map: Map<string, LinkEntry>): void {\n for (const entry of map.values()) {\n entry.cleaned = true;\n entry.subscription?.unsubscribe();\n for (const nestedMap of entry.nestedByPk.values()) {\n cleanupNestedMap(nestedMap);\n }\n }\n}\n\nexport function buildDataWithNestedLinks(\n entry: LinkEntry,\n transformedData: AnyShapeInstance[]\n): AnyShapeInstance[] {\n const targetShape = entry.linkDef.targetShape;\n if (targetShape.__derivedLinks.length === 0) {\n return transformedData;\n }\n\n return transformedData.map((obj) => {\n const pk = obj.$primaryKey;\n const nestedMap = entry.nestedByPk.get(pk);\n if (!nestedMap || nestedMap.size === 0) {\n return obj;\n }\n\n const nestedLinks: Record<string, AnyShapeInstance[]> = {};\n for (const [linkName, nestedEntry] of nestedMap) {\n nestedLinks[linkName] = buildDataWithNestedLinks(\n nestedEntry,\n nestedEntry.data\n );\n }\n\n return { ...obj, ...nestedLinks } as AnyShapeInstance;\n });\n}\n\n/**\n * A link is batchable when it can use observeLinks (one API call for all source\n * objects) instead of per-object observeObjectSet calls. This requires a simple\n * single-hop pivotTo with no filters, ordering, limits, or set operations,\n * since observeLinks doesn't support those query features.\n */\nexport function isBatchableLink(linkDef: ShapeDerivedLinkDef): boolean {\n const def = linkDef.objectSetDef;\n return (\n def.segments.length === 1 &&\n def.segments[0].type === \"pivotTo\" &&\n (!def.setOperations || def.setOperations.length === 0) &&\n !def.where &&\n !def.orderBy &&\n def.limit == null &&\n !def.distinct\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,qBAAqB,QAAQ,oBAAoB;AAe1D,OAAO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAA2B,CAAC,CAAC;AAE5D,OAAO,SAASC,iBAAiBA,CAC/BC,KAAmD,EACnDC,UAA+D,EAC5C;EACnB,IAAIA,UAAU,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,UAAU,KAAK,SAAS,CAAC,EAAE;IACtD,OAAO,IAAIP,qBAAqB,CAC9BG,KAAK,EACLC,UAKF,CAAC;EACH;EACA,OAAOI,SAAS;AAClB;AAeA,OAAO,SAASC,eAAeA,CAC7BC,OAA4B,EAC5BC,YAAwD,EACxDC,WAAqB,EACV;EACX,MAAMC,UAAU,GAAGH,OAAO,CAACI,MAAM,CAACC,KAAK,IAAIH,WAAW,IAAI,KAAK;EAC/D,OAAO;IACLF,OAAO;IACPC,YAAY;IACZK,MAAM,EAAEH,UAAU,GAAG,UAAU,GAAG,MAAM;IACxCI,IAAI,EAAE,EAAE;IACRC,KAAK,EAAEV,SAAS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WAAW;IAC1B,MAAMR,SAAS,GAAGH,KAAK,CAAChB,UAAU,CAAC4B,GAAG,CAACF,EAAE,CAAC;IAC1C,IAAI,CAACP,SAAS,IAAIA,SAAS,CAACU,IAAI,KAAK,CAAC,EAAE;MACtC,OAAOJ,GAAG;IACZ;IAEA,MAAMK,WAA+C,GAAG,CAAC,CAAC;IAC1D,KAAK,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,IAAIb,SAAS,EAAE;MAC/CW,WAAW,CAACC,QAAQ,CAAC,GAAGX,wBAAwB,CAC9CY,WAAW,EACXA,WAAW,CAACrC,IACd,CAAC;IACH;IAEA,OAAO;MAAE,GAAG8B,GAAG;MAAE,GAAGK;IAAY,CAAC;EACnC,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,eAAeA,CAAC7C,OAA4B,EAAW;EACrE,MAAM8C,GAAG,GAAG9C,OAAO,CAAC+C,YAAY;EAChC,OACED,GAAG,CAACE,QAAQ,CAACZ,MAAM,KAAK,CAAC,IACzBU,GAAG,CAACE,QAAQ,CAAC,CAAC,CAAC,CAACC,IAAI,KAAK,SAAS,KACjC,CAACH,GAAG,CAACI,aAAa,IAAIJ,GAAG,CAACI,aAAa,CAACd,MAAM,KAAK,CAAC,CAAC,IACtD,CAACU,GAAG,CAACK,KAAK,IACV,CAACL,GAAG,CAACM,OAAO,IACZN,GAAG,CAACO,KAAK,IAAI,IAAI,IACjB,CAACP,GAAG,CAACQ,QAAQ;AAEjB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useShape.js","names":["useShapeSingle","Error","useShapeList"],"sources":["useShape.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type {\n LinkLoadConfig,\n LinkStatus,\n NullabilityViolation,\n ShapeBaseType,\n ShapeDefinition,\n ShapeDerivedLinks,\n ShapeInstance,\n} from \"@osdk/api/unstable\";\n\nexport interface UseShapeResult<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n data: ShapeInstance<S> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n isOptimistic: boolean;\n droppedDueToNullability: boolean;\n nullabilityViolations: readonly NullabilityViolation[];\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n loadDeferred: (linkName: keyof ShapeDerivedLinks<S>) => void;\n retry: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n invalidate: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n}\n\nexport interface UseShapeListOptions<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n where?: WhereClause<ShapeBaseType<S>>;\n pageSize?: number;\n orderBy?: { [K in PropertyKeys<ShapeBaseType<S>>]?: \"asc\" | \"desc\" };\n autoFetchMore?: boolean | number;\n dedupeIntervalMs?: number;\n streamUpdates?: boolean;\n enabled?: boolean;\n links?: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkLoadConfig }>;\n}\n\nexport type PerItemLinkStatus<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> = Map<\n string | number,\n Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>\n>;\n\nexport interface UseShapeListResult<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n data: ShapeInstance<S>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n isOptimistic: boolean;\n fetchMore: (() => Promise<void>) | undefined;\n droppedCount: number;\n nullabilityViolations: readonly NullabilityViolation[];\n itemLinkStatus: PerItemLinkStatus<S>;\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n loadDeferred: (\n primaryKey: string | number,\n linkName: keyof ShapeDerivedLinks<S>,\n ) => void;\n retry: (\n primaryKey?: string | number,\n linkName?: keyof ShapeDerivedLinks<S>,\n ) => void;\n invalidate: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n}\n\nexport function useShapeSingle<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(\n _shape: S,\n _primaryKey: PrimaryKeyType<ShapeBaseType<S>>,\n _options?: {\n enabled?: boolean;\n links?: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkLoadConfig }>;\n },\n): UseShapeResult<S> {\n throw new Error(\"useShapeSingle is not implemented yet\");\n}\n\nexport function useShapeList<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(\n _shape: S,\n _options: UseShapeListOptions<S>,\n): UseShapeListResult<S> {\n throw new Error(\"useShapeList is not implemented yet\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4EA,OAAO,SAASA,cAAcA,CAAA,EAST;EACnB,MAAM,IAAIC,KAAK,CAAC,uCAAuC,CAAC;AAC1D;AAEA,OAAO,SAASC,YAAYA,CAAA,EAKH;EACvB,MAAM,IAAID,KAAK,CAAC,qCAAqC,CAAC;AACxD","ignoreList":[]}
1
+ {"version":3,"file":"useShape.js","names":["useShapeSingle","Error","useShapeList"],"sources":["useShape.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type {\n LinkLoadConfig,\n LinkStatus,\n NullabilityViolation,\n ShapeBaseType,\n ShapeDefinition,\n ShapeDerivedLinks,\n ShapeInstance,\n} from \"@osdk/api/unstable\";\n\nexport interface UseShapeResult<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n data: ShapeInstance<S> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n isOptimistic: boolean;\n droppedDueToNullability: boolean;\n nullabilityViolations: readonly NullabilityViolation[];\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n loadDeferred: (linkName: keyof ShapeDerivedLinks<S>) => void;\n retry: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n invalidate: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n}\n\nexport interface UseShapeListOptions<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n where?: WhereClause<ShapeBaseType<S>>;\n pageSize?: number;\n orderBy?: { [K in PropertyKeys<ShapeBaseType<S>>]?: \"asc\" | \"desc\" };\n autoFetchMore?: boolean | number;\n dedupeIntervalMs?: number;\n streamUpdates?: boolean;\n enabled?: boolean;\n links?: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkLoadConfig }>;\n}\n\nexport type PerItemLinkStatus<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> = Map<\n string | number,\n Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>\n>;\n\nexport interface UseShapeListResult<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n> {\n data: ShapeInstance<S>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n isOptimistic: boolean;\n fetchMore: (() => Promise<void>) | undefined;\n droppedCount: number;\n nullabilityViolations: readonly NullabilityViolation[];\n itemLinkStatus: PerItemLinkStatus<S>;\n linkStatus: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkStatus }>;\n loadDeferred: (\n primaryKey: string | number,\n linkName: keyof ShapeDerivedLinks<S>\n ) => void;\n retry: (\n primaryKey?: string | number,\n linkName?: keyof ShapeDerivedLinks<S>\n ) => void;\n invalidate: (linkName?: keyof ShapeDerivedLinks<S>) => void;\n}\n\nexport function useShapeSingle<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(\n _shape: S,\n _primaryKey: PrimaryKeyType<ShapeBaseType<S>>,\n _options?: {\n enabled?: boolean;\n links?: Partial<{ [K in keyof ShapeDerivedLinks<S>]: LinkLoadConfig }>;\n }\n): UseShapeResult<S> {\n throw new Error(\"useShapeSingle is not implemented yet\");\n}\n\nexport function useShapeList<\n S extends ShapeDefinition<ObjectOrInterfaceDefinition>,\n>(_shape: S, _options: UseShapeListOptions<S>): UseShapeListResult<S> {\n throw new Error(\"useShapeList is not implemented yet\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4EA,OAAO,SAASA,cAAcA,CAAA,EAST;EACnB,MAAM,IAAIC,KAAK,CAAC,uCAAuC,CAAC;AAC1D;AAEA,OAAO,SAASC,YAAYA,CAAA,EAE0C;EACpE,MAAM,IAAID,KAAK,CAAC,qCAAqC,CAAC;AACxD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"storeUtils.js","names":["deepEqual","React","useStableValue","value","ref","useRef","current","createVersionedCache","version","cachedSnapshot","snapshotVersion","invalidate","get","builder","wrapError","err","Error","String","createCachingNotifier","subscribers","cache","cb","createStoreSubscribe","onInit","onCleanup","notifyUpdate","shouldInit","size","add","delete"],"sources":["storeUtils.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 deepEqual from \"fast-deep-equal\";\nimport React from \"react\";\n\nexport function useStableValue<T>(value: T): T {\n const ref = React.useRef(value);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n\nexport function createVersionedCache<T>() {\n let version = 0;\n let cachedSnapshot: T | null = null;\n let snapshotVersion = -1;\n\n return {\n invalidate(): void {\n version++;\n cachedSnapshot = null;\n },\n get(builder: () => T): T {\n if (cachedSnapshot != null && snapshotVersion === version) {\n return cachedSnapshot;\n }\n cachedSnapshot = builder();\n snapshotVersion = version;\n return cachedSnapshot;\n },\n };\n}\n\nexport function wrapError(err: unknown): Error {\n return err instanceof Error ? err : new Error(String(err));\n}\n\nexport function createCachingNotifier<T>(\n subscribers: Set<() => void>,\n cache: ReturnType<typeof createVersionedCache<T>>,\n): () => void {\n return function notify(): void {\n cache.invalidate();\n for (const cb of subscribers) {\n cb();\n }\n };\n}\n\nexport function createStoreSubscribe(\n subscribers: Set<() => void>,\n onInit: () => void,\n onCleanup: () => void,\n): (notifyUpdate: () => void) => () => void {\n return (notifyUpdate: () => void): () => void => {\n const shouldInit = subscribers.size === 0;\n subscribers.add(notifyUpdate);\n\n if (shouldInit) {\n onInit();\n }\n\n return () => {\n subscribers.delete(notifyUpdate);\n if (subscribers.size === 0) {\n onCleanup();\n }\n };\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAE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Q,IAAI,KAAK,CAAC;IACzCR,WAAW,CAACS,GAAG,CAACH,YAAY,CAAC;IAE7B,IAAIC,UAAU,EAAE;MACdH,MAAM,CAAC,CAAC;IACV;IAEA,OAAO,MAAM;MACXJ,WAAW,CAACU,MAAM,CAACJ,YAAY,CAAC;MAChC,IAAIN,WAAW,CAACQ,IAAI,KAAK,CAAC,EAAE;QAC1BH,SAAS,CAAC,CAAC;MACb;IACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"storeUtils.js","names":["deepEqual","React","useStableValue","value","ref","useRef","current","createVersionedCache","version","cachedSnapshot","snapshotVersion","invalidate","get","builder","wrapError","err","Error","String","createCachingNotifier","subscribers","cache","cb","createStoreSubscribe","onInit","onCleanup","notifyUpdate","shouldInit","size","add","delete"],"sources":["storeUtils.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 deepEqual from \"fast-deep-equal\";\nimport React from \"react\";\n\nexport function useStableValue<T>(value: T): T {\n const ref = React.useRef(value);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n\nexport function createVersionedCache<T>() {\n let version = 0;\n let cachedSnapshot: T | null = null;\n let snapshotVersion = -1;\n\n return {\n invalidate(): void {\n version++;\n cachedSnapshot = null;\n },\n get(builder: () => T): T {\n if (cachedSnapshot != null && snapshotVersion === version) {\n return cachedSnapshot;\n }\n cachedSnapshot = builder();\n snapshotVersion = version;\n return cachedSnapshot;\n },\n };\n}\n\nexport function wrapError(err: unknown): Error {\n return err instanceof Error ? err : new Error(String(err));\n}\n\nexport function createCachingNotifier<T>(\n subscribers: Set<() => void>,\n cache: ReturnType<typeof createVersionedCache<T>>\n): () => void {\n return function notify(): void {\n cache.invalidate();\n for (const cb of subscribers) {\n cb();\n }\n };\n}\n\nexport function createStoreSubscribe(\n subscribers: Set<() => void>,\n onInit: () => void,\n onCleanup: () => void\n): (notifyUpdate: () => void) => () => void {\n return (notifyUpdate: () => void): (() => void) => {\n const shouldInit = subscribers.size === 0;\n subscribers.add(notifyUpdate);\n\n if (shouldInit) {\n onInit();\n }\n\n return () => {\n subscribers.delete(notifyUpdate);\n if (subscribers.size === 0) {\n onCleanup();\n }\n };\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAO,SAASC,cAAcA,CAAIC,KAAQ,EAAK;EAC7C,MAAMC,GAAG,GAAGH,KAAK,CAACI,MAAM,CAACF,KAAK,CAAC;EAC/B,IAAI,CAACH,SAAS,CAACI,GAAG,CAACE,OAAO,EAAEH,KAAK,CAAC,EAAE;IAClCC,GAAG,CAACE,OAAO,GAAGH,KAAK;EACrB;EACA,OAAOC,GAAG,CAACE,OAAO;AACpB;AAEA,OAAO,SAASC,oBAAoBA,CAAA,EAAM;EACxC,IAAIC,OAAO,GAAG,CAAC;EACf,IAAIC,cAAwB,GAAG,IAAI;EACnC,IAAIC,eAAe,GAAG,CAAC,CAAC;EAExB,OAAO;IACLC,UAAUA,CAAA,EAAS;MACjBH,OAAO,EAAE;MACTC,cAAc,GAAG,IAAI;IACvB,CAAC;IACDG,GAAGA,CAACC,OAAgB,EAAK;MACvB,IAAIJ,cAAc,IAAI,IAAI,IAAIC,eAAe,KAAKF,OAAO,EAAE;QACzD,OAAOC,cAAc;MACvB;MACAA,cAAc,GAAGI,OAAO,CAAC,CAAC;MAC1BH,eAAe,GAAGF,OAAO;MACzB,OAAOC,cAAc;IACvB;EACF,CAAC;AACH;AAEA,OAAO,SAASK,SAASA,CAACC,GAAY,EAAS;EAC7C,OAAOA,GAAG,YAAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC,CAAC;AAC5D;AAEA,OAAO,SAASG,qBAAqBA,CACnCC,WAA4B,EAC5BC,KAAiD,EACrC;EACZ,OAAO,YAAwB;IAC7BA,KAAK,CAACT,UAAU,CAAC,CAAC;IAClB,KAAK,MAAMU,EAAE,IAAIF,WAAW,EAAE;MAC5BE,EAAE,CAAC,CAAC;IACN;EACF,CAAC;AACH;AAEA,OAAO,SAASC,oBAAoBA,CAClCH,WAA4B,EAC5BI,MAAkB,EAClBC,SAAqB,EACqB;EAC1C,OAAQC,YAAwB,IAAmB;IACjD,MAAMC,UAAU,GAAGP,WAAW,CAACQ,IAAI,KAAK,CAAC;IACzCR,WAAW,CAACS,GAAG,CAACH,YAAY,CAAC;IAE7B,IAAIC,UAAU,EAAE;MACdH,MAAM,CAAC,CAAC;IACV;IAEA,OAAO,MAAM;MACXJ,WAAW,CAACU,MAAM,CAACJ,YAAY,CAAC;MAChC,IAAIN,WAAW,CAACQ,IAAI,KAAK,CAAC,EAAE;QAC1BH,SAAS,CAAC,CAAC;MACb;IACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useDevToolsClient.js","names":["useMemo","useRef","getRegisteredDevTools","useDevToolsClient","baseClient","enabled","stateRef","prev","current","wrappedClient","devTools","base","monitored","wrapClient","currentState","wrapChildren","children","client"],"sources":["useDevToolsClient.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 { ObservableClient } from \"@osdk/client/observable\";\nimport type React from \"react\";\nimport { useMemo, useRef } from \"react\";\nimport {\n type DevToolsRegistry,\n getRegisteredDevTools,\n} from \"../public/devtools-registry.js\";\n\nexport function useDevToolsClient(\n baseClient: ObservableClient,\n enabled: boolean,\n): {\n client: ObservableClient;\n wrapChildren: ((children: React.ReactNode) => React.ReactNode) | null;\n} {\n const stateRef = useRef<\n {\n base: ObservableClient;\n monitored: ObservableClient;\n devTools: DevToolsRegistry;\n } | null\n >(null);\n\n const prev = stateRef.current;\n\n let wrappedClient: ObservableClient;\n if (!enabled) {\n stateRef.current = null;\n wrappedClient = baseClient;\n } else {\n const devTools = getRegisteredDevTools();\n if (devTools == null) {\n stateRef.current = null;\n wrappedClient = baseClient;\n } else if (\n prev != null && prev.base === baseClient && prev.devTools === devTools\n ) {\n wrappedClient = prev.monitored;\n } else {\n const monitored = devTools.wrapClient(baseClient);\n stateRef.current = { base: baseClient, monitored, devTools };\n wrappedClient = monitored;\n }\n }\n\n const currentState = stateRef.current;\n const wrapChildren = useMemo(\n () =>\n currentState != null\n ? (children: React.ReactNode): React.ReactNode =>\n currentState.devTools.wrapChildren(children, currentState.monitored)\n : null,\n [currentState],\n );\n\n return { client: wrappedClient, wrapChildren };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACvC,SAEEC,qBAAqB,QAChB,gCAAgC;AAEvC,OAAO,SAASC,iBAAiBA,CAC/BC,UAA4B,EAC5BC,OAAgB,EAIhB;EACA,MAAMC,QAAQ,GAAGL,MAAM,CAMrB,IAAI,CAAC;EAEP,MAAMM,IAAI,GAAGD,QAAQ,CAACE,OAAO;EAE7B,IAAIC,aAA+B;EACnC,IAAI,CAACJ,OAAO,EAAE;IACZC,QAAQ,CAACE,OAAO,GAAG,IAAI;IACvBC,aAAa,GAAGL,UAAU;EAC5B,CAAC,MAAM;IACL,MAAMM,QAAQ,GAAGR,qBAAqB,CAAC,CAAC;IACxC,IAAIQ,QAAQ,IAAI,IAAI,EAAE;MACpBJ,QAAQ,CAACE,OAAO,GAAG,IAAI;MACvBC,aAAa,GAAGL,UAAU;IAC5B,CAAC,MAAM,IACLG,IAAI,IAAI,IAAI,IAAIA,IAAI,CAACI,IAAI,KAAKP,UAAU,IAAIG,IAAI,CAACG,QAAQ,KAAKA,QAAQ,EACtE;MACAD,aAAa,GAAGF,IAAI,CAACK,SAAS;IAChC,CAAC,MAAM;MACL,MAAMA,SAAS,GAAGF,QAAQ,CAACG,UAAU,CAACT,UAAU,CAAC;MACjDE,QAAQ,CAACE,OAAO,GAAG;QAAEG,IAAI,EAAEP,UAAU;QAAEQ,SAAS;QAAEF;MAAS,CAAC;MAC5DD,aAAa,GAAGG,SAAS;IAC3B;EACF;EAEA,MAAME,YAAY,GAAGR,QAAQ,CAACE,OAAO;EACrC,MAAMO,YAAY,GAAGf,OAAO,CAC1B,MACEc,YAAY,IAAI,IAAI,GACfE,QAAyB,IAC1BF,YAAY,CAACJ,QAAQ,CAACK,YAAY,CAACC,QAAQ,EAAEF,YAAY,CAACF,SAAS,CAAC,GACpE,IAAI,EACV,CAACE,YAAY,CACf,CAAC;EAED,OAAO;IAAEG,MAAM,EAAER,aAAa;IAAEM;EAAa,CAAC;AAChD","ignoreList":[]}
1
+ {"version":3,"file":"useDevToolsClient.js","names":["useMemo","useRef","getRegisteredDevTools","useDevToolsClient","baseClient","enabled","stateRef","prev","current","wrappedClient","devTools","base","monitored","wrapClient","currentState","wrapChildren","children","client"],"sources":["useDevToolsClient.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 { ObservableClient } from \"@osdk/client/observable\";\nimport type React from \"react\";\nimport { useMemo, useRef } from \"react\";\n\nimport {\n type DevToolsRegistry,\n getRegisteredDevTools,\n} from \"../public/devtools-registry.js\";\n\nexport function useDevToolsClient(\n baseClient: ObservableClient,\n enabled: boolean\n): {\n client: ObservableClient;\n wrapChildren: ((children: React.ReactNode) => React.ReactNode) | null;\n} {\n const stateRef = useRef<{\n base: ObservableClient;\n monitored: ObservableClient;\n devTools: DevToolsRegistry;\n } | null>(null);\n\n const prev = stateRef.current;\n\n let wrappedClient: ObservableClient;\n if (!enabled) {\n stateRef.current = null;\n wrappedClient = baseClient;\n } else {\n const devTools = getRegisteredDevTools();\n if (devTools == null) {\n stateRef.current = null;\n wrappedClient = baseClient;\n } else if (\n prev != null &&\n prev.base === baseClient &&\n prev.devTools === devTools\n ) {\n wrappedClient = prev.monitored;\n } else {\n const monitored = devTools.wrapClient(baseClient);\n stateRef.current = { base: baseClient, monitored, devTools };\n wrappedClient = monitored;\n }\n }\n\n const currentState = stateRef.current;\n const wrapChildren = useMemo(\n () =>\n currentState != null\n ? (children: React.ReactNode): React.ReactNode =>\n currentState.devTools.wrapChildren(children, currentState.monitored)\n : null,\n [currentState]\n );\n\n return { client: wrappedClient, wrapChildren };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAEvC,SAEEC,qBAAqB,QAChB,gCAAgC;AAEvC,OAAO,SAASC,iBAAiBA,CAC/BC,UAA4B,EAC5BC,OAAgB,EAIhB;EACA,MAAMC,QAAQ,GAAGL,MAAM,CAIb,IAAI,CAAC;EAEf,MAAMM,IAAI,GAAGD,QAAQ,CAACE,OAAO;EAE7B,IAAIC,aAA+B;EACnC,IAAI,CAACJ,OAAO,EAAE;IACZC,QAAQ,CAACE,OAAO,GAAG,IAAI;IACvBC,aAAa,GAAGL,UAAU;EAC5B,CAAC,MAAM;IACL,MAAMM,QAAQ,GAAGR,qBAAqB,CAAC,CAAC;IACxC,IAAIQ,QAAQ,IAAI,IAAI,EAAE;MACpBJ,QAAQ,CAACE,OAAO,GAAG,IAAI;MACvBC,aAAa,GAAGL,UAAU;IAC5B,CAAC,MAAM,IACLG,IAAI,IAAI,IAAI,IACZA,IAAI,CAACI,IAAI,KAAKP,UAAU,IACxBG,IAAI,CAACG,QAAQ,KAAKA,QAAQ,EAC1B;MACAD,aAAa,GAAGF,IAAI,CAACK,SAAS;IAChC,CAAC,MAAM;MACL,MAAMA,SAAS,GAAGF,QAAQ,CAACG,UAAU,CAACT,UAAU,CAAC;MACjDE,QAAQ,CAACE,OAAO,GAAG;QAAEG,IAAI,EAAEP,UAAU;QAAEQ,SAAS;QAAEF;MAAS,CAAC;MAC5DD,aAAa,GAAGG,SAAS;IAC3B;EACF;EAEA,MAAME,YAAY,GAAGR,QAAQ,CAACE,OAAO;EACrC,MAAMO,YAAY,GAAGf,OAAO,CAC1B,MACEc,YAAY,IAAI,IAAI,GACfE,QAAyB,IACxBF,YAAY,CAACJ,QAAQ,CAACK,YAAY,CAACC,QAAQ,EAAEF,YAAY,CAACF,SAAS,CAAC,GACtE,IAAI,EACV,CAACE,YAAY,CACf,CAAC;EAED,OAAO;IAAEG,MAAM,EAAER,aAAa;IAAEM;EAAa,CAAC;AAChD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useLinks.js","names":["React","extractPayloadError","isPayloadLoading","devToolsMetadata","makeExternalStore","OsdkContext","emptyArray","Object","freeze","emptyMap","Map","useLinks","objects","linkName","options","observableClient","useContext","enabled","$includeAllBaseObjectProperties","resolveToObjectType","otherOptions","canonOptions","canonicalizeOptions","where","orderBy","$select","objectsKey","useMemo","undefined","arr","Array","isArray","map","obj","$apiName","$primaryKey","join","objectsArray","subscribe","getSnapShot","unsubscribe","hookType","sourceObjectType","observer","observeLinks","pageSize","mode","dedupeInterval","dedupeIntervalMs","select","payload","useSyncExternalStore","links","resolvedList","linkedObjectsBySourcePrimaryKey","isLoading","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type { Osdk, PropertyKeys, WhereClause } from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/observable\";\nimport React from \"react\";\nimport { extractPayloadError, isPayloadLoading } from \"./hookUtils.js\";\nimport { devToolsMetadata, makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nimport type { ResolveToObjectTypeOption } from \"./useOsdkObjects.js\";\n\nexport type UseLinksOptions<\n T extends ObjectOrInterfaceDefinition,\n> =\n & UseLinksBaseOptions<T>\n & ResolveToObjectTypeOption<T>;\n\ninterface UseLinksBaseOptions<\n T extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Restrict which properties are returned for each linked object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n $select?: readonly PropertyKeys<T>[];\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\n\n /**\n * The number of milliseconds to wait after the last observed link change.\n *\n * Two uses of `useLinks` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * ```tsx\n * // Dependent query - wait for employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee,\n * });\n * ```\n */\n enabled?: boolean;\n\n /**\n * When true, includes all properties of the underlying concrete object type\n * for interface link targets. Has no effect when the link target is a plain\n * object type.\n */\n $includeAllBaseObjectProperties?: boolean;\n}\n\nexport interface UseLinksResult<Q extends ObjectOrInterfaceDefinition> {\n links: Osdk.Instance<Q, \"$allBaseProperties\">[] | undefined;\n\n /**\n * Maps each source object's primary key to its linked object instances.\n * Useful when observing links from multiple source objects to determine\n * which source links to which targets.\n */\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<Q, \"$allBaseProperties\">>\n >;\n\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\nconst emptyMap: ReadonlyMap<string | number, ReadonlyArray<never>> = new Map();\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectOrInterfaceDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {},\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext);\n\n const {\n enabled = true,\n $includeAllBaseObjectProperties,\n resolveToObjectType,\n ...otherOptions\n } = options;\n\n const canonOptions = observableClient.canonicalizeOptions({\n where: otherOptions.where,\n orderBy: otherOptions.orderBy,\n $select: otherOptions.$select,\n });\n\n const objectsKey = React.useMemo(() => {\n if (objects === undefined) return \"\";\n const arr = Array.isArray(objects) ? objects : [objects];\n return arr.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\");\n }, [objects]);\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objectsKey, objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<\n ObserveLinks.CallbackArgs<LinkedType<T, L>>\n >(\n () => ({ unsubscribe: () => {} }),\n devToolsMetadata({\n hookType: \"useLinks\",\n sourceObjectType: objectsArray[0]?.$apiName,\n linkName,\n }),\n );\n }\n return makeExternalStore<\n ObserveLinks.CallbackArgs<LinkedType<T, L>>\n >(\n (observer) =>\n observableClient.observeLinks<T, L>(\n objectsArray,\n linkName,\n {\n linkName,\n where: canonOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: canonOptions.orderBy,\n mode: otherOptions.mode,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n $includeAllBaseObjectProperties,\n resolveToObjectType,\n ...(canonOptions.$select ? { select: canonOptions.$select } : {}),\n },\n observer,\n ),\n devToolsMetadata({\n hookType: \"useLinks\",\n sourceObjectType: objectsArray[0]?.$apiName,\n linkName,\n }),\n );\n },\n [\n enabled,\n observableClient,\n objectsArray,\n objectsKey,\n linkName,\n canonOptions.where,\n otherOptions.pageSize,\n canonOptions.orderBy,\n otherOptions.mode,\n otherOptions.dedupeIntervalMs,\n canonOptions.$select,\n $includeAllBaseObjectProperties,\n !!resolveToObjectType,\n ],\n );\n\n const payload = React.useSyncExternalStore(\n subscribe,\n getSnapShot,\n );\n\n return React.useMemo(() => ({\n links: payload?.resolvedList,\n linkedObjectsBySourcePrimaryKey: payload?.linkedObjectsBySourcePrimaryKey\n ?? emptyMap,\n isLoading: isPayloadLoading(payload, enabled),\n isOptimistic: payload?.isOptimistic ?? false,\n error: extractPayloadError(payload, \"Failed to load links\"),\n fetchMore: payload?.hasMore ? payload?.fetchMore : undefined,\n hasMore: payload?.hasMore ?? false,\n }), [payload, enabled]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,gBAAgB;AACtE,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,wBAAwB;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAiH9C,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;AACpC,MAAMC,QAA4D,GAAG,IAAIC,GAAG,CAAC,CAAC;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAItBC,OAA+D,EAC/DC,QAAW,EACXC,OAA0C,GAAG,CAAC,CAAC,EACb;EAClC,MAAM;IAAE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O,EAAEG,YAAY;IAC5BC,+BAA+B,EAAEJ,OAAO,EAAEI,+BAA+B,IACpE7C,QAAQ;IACb8C,SAAS,EAAErD,gBAAgB,CAACgD,OAAO,EAAEjC,OAAO,CAAC;IAC7CuC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAExD,mBAAmB,CAACiD,OAAO,EAAE,sBAAsB,CAAC;IAC3DQ,SAAS,EAAER,OAAO,EAAES,OAAO,GAAGT,OAAO,EAAEQ,SAAS,GAAG9B,SAAS;IAC5D+B,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC,CAAC,EAAE,CAACT,OAAO,EAAEjC,OAAO,CAAC,CAAC;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"useLinks.js","names":["React","extractPayloadError","isPayloadLoading","devToolsMetadata","makeExternalStore","OsdkContext","emptyArray","Object","freeze","emptyMap","Map","useLinks","objects","linkName","options","observableClient","useContext","enabled","$includeAllBaseObjectProperties","resolveToObjectType","otherOptions","canonOptions","canonicalizeOptions","where","orderBy","$select","objectsKey","useMemo","undefined","arr","Array","isArray","map","obj","$apiName","$primaryKey","join","objectsArray","subscribe","getSnapShot","unsubscribe","hookType","sourceObjectType","observer","observeLinks","pageSize","mode","dedupeInterval","dedupeIntervalMs","select","payload","useSyncExternalStore","links","resolvedList","linkedObjectsBySourcePrimaryKey","isLoading","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type { Osdk, PropertyKeys, WhereClause } from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/observable\";\nimport React from \"react\";\n\nimport { extractPayloadError, isPayloadLoading } from \"./hookUtils.js\";\nimport { devToolsMetadata, makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nimport type { ResolveToObjectTypeOption } from \"./useOsdkObjects.js\";\n\nexport type UseLinksOptions<T extends ObjectOrInterfaceDefinition> =\n UseLinksBaseOptions<T> & ResolveToObjectTypeOption<T>;\n\ninterface UseLinksBaseOptions<T extends ObjectOrInterfaceDefinition> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Restrict which properties are returned for each linked object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n $select?: readonly PropertyKeys<T>[];\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\n\n /**\n * The number of milliseconds to wait after the last observed link change.\n *\n * Two uses of `useLinks` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * ```tsx\n * // Dependent query - wait for employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee,\n * });\n * ```\n */\n enabled?: boolean;\n\n /**\n * When true, includes all properties of the underlying concrete object type\n * for interface link targets. Has no effect when the link target is a plain\n * object type.\n */\n $includeAllBaseObjectProperties?: boolean;\n}\n\nexport interface UseLinksResult<Q extends ObjectOrInterfaceDefinition> {\n links: Osdk.Instance<Q, \"$allBaseProperties\">[] | undefined;\n\n /**\n * Maps each source object's primary key to its linked object instances.\n * Useful when observing links from multiple source objects to determine\n * which source links to which targets.\n */\n linkedObjectsBySourcePrimaryKey: ReadonlyMap<\n string | number,\n ReadonlyArray<Osdk.Instance<Q, \"$allBaseProperties\">>\n >;\n\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\nconst emptyMap: ReadonlyMap<string | number, ReadonlyArray<never>> = new Map();\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectOrInterfaceDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {}\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext);\n\n const {\n enabled = true,\n $includeAllBaseObjectProperties,\n resolveToObjectType,\n ...otherOptions\n } = options;\n\n const canonOptions = observableClient.canonicalizeOptions({\n where: otherOptions.where,\n orderBy: otherOptions.orderBy,\n $select: otherOptions.$select,\n });\n\n const objectsKey = React.useMemo(() => {\n if (objects === undefined) return \"\";\n const arr = Array.isArray(objects) ? objects : [objects];\n return arr.map((obj) => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\");\n }, [objects]);\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objectsKey, objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore<ObserveLinks.CallbackArgs<LinkedType<T, L>>>(\n () => ({ unsubscribe: () => {} }),\n devToolsMetadata({\n hookType: \"useLinks\",\n sourceObjectType: objectsArray[0]?.$apiName,\n linkName,\n })\n );\n }\n return makeExternalStore<ObserveLinks.CallbackArgs<LinkedType<T, L>>>(\n (observer) =>\n observableClient.observeLinks<T, L>(\n objectsArray,\n linkName,\n {\n linkName,\n where: canonOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: canonOptions.orderBy,\n mode: otherOptions.mode,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n $includeAllBaseObjectProperties,\n resolveToObjectType,\n ...(canonOptions.$select ? { select: canonOptions.$select } : {}),\n },\n observer\n ),\n devToolsMetadata({\n hookType: \"useLinks\",\n sourceObjectType: objectsArray[0]?.$apiName,\n linkName,\n })\n );\n }, [\n enabled,\n observableClient,\n objectsArray,\n objectsKey,\n linkName,\n canonOptions.where,\n otherOptions.pageSize,\n canonOptions.orderBy,\n otherOptions.mode,\n otherOptions.dedupeIntervalMs,\n canonOptions.$select,\n $includeAllBaseObjectProperties,\n !!resolveToObjectType,\n ]);\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return React.useMemo(\n () => ({\n links: payload?.resolvedList,\n linkedObjectsBySourcePrimaryKey:\n payload?.linkedObjectsBySourcePrimaryKey ?? emptyMap,\n isLoading: isPayloadLoading(payload, enabled),\n isOptimistic: payload?.isOptimistic ?? false,\n error: extractPayloadError(payload, \"Failed to load links\"),\n fetchMore: payload?.hasMore ? payload?.fetchMore : undefined,\n hasMore: payload?.hasMore ?? false,\n }),\n [pay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EAAEL,YAAY,CAAC,CAAC,CAAC,EAAEH,QAAQ;MAC3CrB;IACF,CAAC,CACH,CAAC;EACH,CAAC,EAAE,CACDI,OAAO,EACPF,gBAAgB,EAChBsB,YAAY,EACZX,UAAU,EACVb,QAAQ,EACRQ,YAAY,CAACE,KAAK,EAClBH,YAAY,CAACyB,QAAQ,EACrBxB,YAAY,CAACG,OAAO,EACpBJ,YAAY,CAAC0B,IAAI,EACjB1B,YAAY,CAAC4B,gBAAgB,EAC7B3B,YAAY,CAACI,OAAO,EACpBP,+BAA+B,EAC/B,CAAC,CAACC,mBAAmB,CACtB,CAAC;EAEF,MAAM+B,OAAO,GAAGlD,KAAK,CAACmD,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAOvC,KAAK,CAAC2B,OAAO,CAClB,OAAO;IACLyB,KAAK,EAAEF,OAAO,EAAEG,YAAY;IAC5BC,+BAA+B,EAC7BJ,OAAO,EAAEI,+BAA+B,IAAI7C,QAAQ;IACtD8C,SAAS,EAAErD,gBAAgB,CAACgD,OAAO,EAAEjC,OAAO,CAAC;IAC7CuC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAExD,mBAAmB,CAACiD,OAAO,EAAE,sBAAsB,CAAC;IAC3DQ,SAAS,EAAER,OAAO,EAAES,OAAO,GAAGT,OAAO,EAAEQ,SAAS,GAAG9B,SAAS;IAC5D+B,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC,CAAC,EACF,CAACT,OAAO,EAAEjC,OAAO,CACnB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectSet.js","names":["getWireObjectSet","React","extractPayloadError","devToolsMetadata","makeExternalStore","OsdkContext","OBJECT_TYPE_PLACEHOLDER","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","enabledOption","streamUpdates","otherOptions","objectTypeKey","$objectSetInternals","def","apiName","previousObjectTypeRef","useRef","previousCompletedPayloadRef","objectTypeChanged","current","undefined","canonOptions","canonicalizeOptions","where","withProperties","orderBy","union","intersect","subtract","$select","objectSetKey","JSON","stringify","baseObjectSetRef","subscribe","getSnapShot","useMemo","unsubscribe","hookType","objectType","initialValue","observer","subscription","observeObjectSet","pivotTo","pageSize","dedupeInterval","dedupeIntervalMs","autoFetchMore","select","payload","useSyncExternalStore","isPayloadCompleted","typeApiName","refetch","useCallback","invalidateObjectType","lastLoaded","data","resolvedList","isLoading","error","isOptimistic","fetchMore","hasMore","objectSet","totalCount","status"],"sources":["useObjectSet.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n LinkNames,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport { getWireObjectSet } from \"@osdk/client\";\nimport type { ObserveObjectSetArgs } from \"@osdk/client/observable\";\nimport React from \"react\";\nimport { extractPayloadError } from \"./hookUtils.js\";\nimport {\n devToolsMetadata,\n makeExternalStore,\n type Snapshot,\n} from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type).\n *\n * Cannot be combined with `streamUpdates`. The server does not support\n * websocket subscriptions for link-traversal queries.\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * Cannot be combined with `pivotTo`. The server does not support\n * websocket subscriptions for link-traversal queries.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n $select?: readonly PropertyKeys<Q>[];\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * ```tsx\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus,\n * });\n * ```\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n isOptimistic: boolean;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n hasMore: boolean;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n\n /**\n * The total count of objects matching the query (if available from the API)\n */\n totalCount?: string;\n\n refetch: () => Promise<void>;\n}\n\nconst OBJECT_TYPE_PLACEHOLDER = \"$__OBJECT__TYPE__PLACEHOLDER\";\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\n// pivotTo overload: streamUpdates is forbidden (the server does not support\n// websocket subscriptions for link-traversal queries).\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options: UseObjectSetOptions<Q, RDPs> & {\n pivotTo: LinkNames<Q>;\n streamUpdates?: never;\n },\n): UseObjectSetResult<Q, RDPs>;\n\n// Non-pivotTo overload: pivotTo is forbidden to prevent fallthrough.\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options?: UseObjectSetOptions<Q, RDPs> & { pivotTo?: never },\n): UseObjectSetResult<Q, RDPs>;\n\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext);\n\n const { enabled: enabledOption = true, streamUpdates, ...otherOptions } =\n options;\n const enabled = enabledOption && baseObjectSet != null;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey = enabled && baseObjectSet\n ? baseObjectSet.$objectSetInternals.def.apiName\n : OBJECT_TYPE_PLACEHOLDER;\n\n const previousObjectTypeRef = React.useRef<string>(objectTypeKey);\n const previousCompletedPayloadRef = React.useRef<\n Snapshot<ObserveObjectSetArgs<Q, RDPs>> | undefined\n >();\n // TODO: Is it expected to only clear the previousCompletedPayloadRef when the object type changes?\n // What if the same object type is queried with different filters, should we also clear the cache?\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n previousCompletedPayloadRef.current = undefined;\n }\n\n // canonicalizeOptions stabilizes complex query identity options.\n // pageSize is a view level concern (handled per subscriber, not part of\n // query identity), and pivotTo is a plain string that does not need\n // stabilization.\n const canonOptions = observableClient.canonicalizeOptions({\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n orderBy: otherOptions.orderBy,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n $select: otherOptions.$select,\n });\n\n const objectSetKey = baseObjectSet\n ? JSON.stringify(getWireObjectSet(baseObjectSet as ObjectSet<Q>))\n : undefined;\n\n const baseObjectSetRef = React.useRef(baseObjectSet);\n baseObjectSetRef.current = baseObjectSet;\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n devToolsMetadata({\n hookType: \"useObjectSet\",\n objectType: objectTypeKey,\n }),\n );\n }\n\n const initialValue = objectTypeChanged\n ? undefined\n : previousCompletedPayloadRef.current;\n\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n if (!baseObjectSetRef.current) {\n return { unsubscribe: () => {} };\n }\n const subscription = observableClient.observeObjectSet(\n baseObjectSetRef.current as ObjectSet<Q>,\n {\n where: canonOptions.where,\n withProperties: canonOptions.withProperties,\n union: canonOptions.union,\n intersect: canonOptions.intersect,\n subtract: canonOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: canonOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n select: canonOptions.$select,\n },\n observer,\n );\n return subscription;\n },\n devToolsMetadata({\n hookType: \"useObjectSet\",\n objectType: objectTypeKey,\n }),\n initialValue,\n );\n },\n [\n enabled,\n observableClient,\n objectSetKey,\n canonOptions.where,\n canonOptions.withProperties,\n canonOptions.orderBy,\n canonOptions.union,\n canonOptions.intersect,\n canonOptions.subtract,\n canonOptions.$select,\n otherOptions.pivotTo,\n otherOptions.pageSize,\n otherOptions.autoFetchMore,\n otherOptions.dedupeIntervalMs,\n streamUpdates,\n objectTypeKey,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n if (payload && isPayloadCompleted(payload)) {\n previousCompletedPayloadRef.current = payload;\n }\n\n const typeApiName = baseObjectSet?.$objectSetInternals.def.apiName;\n\n const refetch = React.useCallback(async () => {\n if (typeApiName) {\n await observableClient.invalidateObjectType(typeApiName);\n }\n }, [observableClient, typeApiName]);\n\n return React.useMemo(() => {\n const lastLoaded = isPayloadCompleted(payload)\n ? payload\n : previousCompletedPayloadRef.current;\n return {\n data: lastLoaded?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: enabled\n ? !isPayloadCompleted(payload)\n : false,\n error: extractPayloadError(lastLoaded, \"Failed to load object set\"),\n isOptimistic: payload?.isOptimistic ?? false,\n fetchMore: payload?.hasMore ? payload.fetchMore : undefined,\n hasMore: payload?.hasMore ?? false,\n objectSet: lastLoaded?.objectSet as ObjectSet<Q, RDPs> | undefined,\n totalCount: lastLoaded?.totalCount,\n refetch,\n };\n }, [payload, refetch, enabled]);\n}\n\nfunction isPayloadCompleted<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n>(\n payload: Snapshot<ObserveObjectSetArgs<Q, RDPs>>,\n): boolean {\n if (payload != null && \"error\" in payload) {\n return true;\n }\n\n if (payload?.status == null) {\n return false;\n }\n\n switch (payload.status) {\n case \"loaded\":\n case \"error\":\n return true;\n case \"loading\":\n case \"init\":\n return false;\n default:\n payload.status satisfies never;\n return false;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,gBAAgB,QAAQ,cAAc;AAE/C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SACEC,gBAAgB,EAChBC,iBAAiB,QAEZ,wBAAwB;AAC/B,SAASC,WAAW,QAAQ,kBAAkB;AAuJ9C,MAAMC,uBAAuB,GAAG,8BAA8B;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;;AAUA,OAAO,SAASC,YAAYA,CAK1BC,aAAiD,EACjDC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACN,WAAW,CAAC;EAE1D,MAAM;IAAEO,OAAO,EAAEC,aAAa,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAC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a,SAAS,GAAG3C,SAAS;MAC3D4C,OAAO,EAAEd,OAAO,EAAEc,OAAO,IAAI,KAAK;MAClCC,SAAS,EAAER,UAAU,EAAEQ,SAA2C;MAClEC,UAAU,EAAET,UAAU,EAAES,UAAU;MAClCZ;IACF,CAAC;EACH,CAAC,EAAE,CAACJ,OAAO,EAAEI,OAAO,EAAE/C,OAAO,CAAC,CAAC;AACjC;AAEA,SAAS6C,kBAAkBA,CAIzBF,OAAgD,EACvC;EACT,IAAIA,OAAO,IAAI,IAAI,IAAI,OAAO,IAAIA,OAAO,EAAE;IACzC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,EAAEiB,MAAM,IAAI,IAAI,EAAE;IAC3B,OAAO,KAAK;EACd;EAEA,QAAQjB,OAAO,CAACiB,MAAM;IACpB,KAAK,QAAQ;IACb,KAAK,OAAO;MACV,OAAO,IAAI;IACb,KAAK,SAAS;IACd,KAAK,MAAM;MACT,OAAO,KAAK;IACd;MACEjB,OAAO,CAACiB,MAAM;MACd,OAAO,KAAK;EAChB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"useObjectSet.js","names":["getWireObjectSet","React","extractPayloadError","devToolsMetadata","makeExternalStore","OsdkContext","OBJECT_TYPE_PLACEHOLDER","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","enabledOption","streamUpdates","otherOptions","objectTypeKey","$objectSetInternals","def","apiName","previousObjectTypeRef","useRef","previousCompletedPayloadRef","objectTypeChanged","current","undefined","canonOptions","canonicalizeOptions","where","withProperties","orderBy","union","intersect","subtract","$select","objectSetKey","JSON","stringify","baseObjectSetRef","subscribe","getSnapShot","useMemo","unsubscribe","hookType","objectType","initialValue","observer","subscription","observeObjectSet","pivotTo","pageSize","dedupeInterval","dedupeIntervalMs","autoFetchMore","select","payload","useSyncExternalStore","isPayloadCompleted","typeApiName","refetch","useCallback","invalidateObjectType","lastLoaded","data","resolvedList","isLoading","error","isOptimistic","fetchMore","hasMore","objectSet","totalCount","status"],"sources":["useObjectSet.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n LinkNames,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport { getWireObjectSet } from \"@osdk/client\";\nimport type { ObserveObjectSetArgs } from \"@osdk/client/observable\";\nimport React from \"react\";\n\nimport { extractPayloadError } from \"./hookUtils.js\";\nimport {\n devToolsMetadata,\n makeExternalStore,\n type Snapshot,\n} from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type).\n *\n * Cannot be combined with `streamUpdates`. The server does not support\n * websocket subscriptions for link-traversal queries.\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * Cannot be combined with `pivotTo`. The server does not support\n * websocket subscriptions for link-traversal queries.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n */\n $select?: readonly PropertyKeys<Q>[];\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * ```tsx\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus,\n * });\n * ```\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n isOptimistic: boolean;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n hasMore: boolean;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n\n /**\n * The total count of objects matching the query (if available from the API)\n */\n totalCount?: string;\n\n refetch: () => Promise<void>;\n}\n\nconst OBJECT_TYPE_PLACEHOLDER = \"$__OBJECT__TYPE__PLACEHOLDER\";\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\n// pivotTo overload: streamUpdates is forbidden (the server does not support\n// websocket subscriptions for link-traversal queries).\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options: UseObjectSetOptions<Q, RDPs> & {\n pivotTo: LinkNames<Q>;\n streamUpdates?: never;\n }\n): UseObjectSetResult<Q, RDPs>;\n\n// Non-pivotTo overload: pivotTo is forbidden to prevent fallthrough.\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options?: UseObjectSetOptions<Q, RDPs> & { pivotTo?: never }\n): UseObjectSetResult<Q, RDPs>;\n\nexport function useObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs> | undefined,\n options: UseObjectSetOptions<Q, RDPs> = {}\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext);\n\n const {\n enabled: enabledOption = true,\n streamUpdates,\n ...otherOptions\n } = options;\n const enabled = enabledOption && baseObjectSet != null;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey =\n enabled && baseObjectSet\n ? baseObjectSet.$objectSetInternals.def.apiName\n : OBJECT_TYPE_PLACEHOLDER;\n\n const previousObjectTypeRef = React.useRef<string>(objectTypeKey);\n const previousCompletedPayloadRef = React.useRef<\n Snapshot<ObserveObjectSetArgs<Q, RDPs>> | undefined\n >();\n // TODO: Is it expected to only clear the previousCompletedPayloadRef when the object type changes?\n // What if the same object type is queried with different filters, should we also clear the cache?\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n previousCompletedPayloadRef.current = undefined;\n }\n\n // canonicalizeOptions stabilizes complex query identity options.\n // pageSize is a view level concern (handled per subscriber, not part of\n // query identity), and pivotTo is a plain string that does not need\n // stabilization.\n const canonOptions = observableClient.canonicalizeOptions({\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n orderBy: otherOptions.orderBy,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n $select: otherOptions.$select,\n });\n\n const objectSetKey = baseObjectSet\n ? JSON.stringify(getWireObjectSet(baseObjectSet as ObjectSet<Q>))\n : undefined;\n\n const baseObjectSetRef = React.useRef(baseObjectSet);\n baseObjectSetRef.current = baseObjectSet;\n\n const { subscribe, getSnapShot } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n devToolsMetadata({\n hookType: \"useObjectSet\",\n objectType: objectTypeKey,\n })\n );\n }\n\n const initialValue = objectTypeChanged\n ? undefined\n : previousCompletedPayloadRef.current;\n\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n if (!baseObjectSetRef.current) {\n return { unsubscribe: () => {} };\n }\n const subscription = observableClient.observeObjectSet(\n baseObjectSetRef.current as ObjectSet<Q>,\n {\n where: canonOptions.where,\n withProperties: canonOptions.withProperties,\n union: canonOptions.union,\n intersect: canonOptions.intersect,\n subtract: canonOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: canonOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n select: canonOptions.$select,\n },\n observer\n );\n return subscription;\n },\n devToolsMetadata({\n hookType: \"useObjectSet\",\n objectType: objectTypeKey,\n }),\n initialValue\n );\n }, [\n enabled,\n observableClient,\n objectSetKey,\n canonOptions.where,\n canonOptions.withProperties,\n canonOptions.orderBy,\n canonOptions.union,\n canonOptions.intersect,\n canonOptions.subtract,\n canonOptions.$select,\n otherOptions.pivotTo,\n otherOptions.pageSize,\n otherOptions.autoFetchMore,\n otherOptions.dedupeIntervalMs,\n streamUpdates,\n objectTypeKey,\n ]);\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n if (payload && isPayloadCompleted(payload)) {\n previousCompletedPayloadRef.current = payload;\n }\n\n const typeApiName = baseObjectSet?.$objectSetInternals.def.apiName;\n\n const refetch = React.useCallback(async () => {\n if (typeApiName) {\n await observableClient.invalidateObjectType(typeApiName);\n }\n }, [observableClient, typeApiName]);\n\n return React.useMemo(() => {\n const lastLoaded = isPayloadCompleted(payload)\n ? payload\n : previousCompletedPayloadRef.current;\n return {\n data: lastLoaded?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: enabled ? !isPayloadCompleted(payload) : false,\n error: extractPayloadError(lastLoaded, \"Failed to load object set\"),\n isOptimistic: payload?.isOptimistic ?? false,\n fetchMore: payload?.hasMore ? payload.fetchMore : undefined,\n hasMore: payload?.hasMore ?? false,\n objectSet: lastLoaded?.objectSet as ObjectSet<Q, RDPs> | undefined,\n totalCount: lastLoaded?.totalCount,\n refetch,\n };\n }, [payload, refetch, enabled]);\n}\n\nfunction isPayloadCompleted<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n>(payload: Snapshot<ObserveObjectSetArgs<Q, RDPs>>): boolean {\n if (payload != null && \"error\" in payload) {\n return true;\n }\n\n if (payload?.status == null) {\n return false;\n }\n\n switch (payload.status) {\n case \"loaded\":\n case \"error\":\n return true;\n case \"loading\":\n case \"init\":\n return false;\n default:\n payload.status satisfies never;\n return false;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,gBAAgB,QAAQ,cAAc;AAE/C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SACEC,gBAAgB,EAChBC,iBAAiB,QAEZ,wBAAwB;AAC/B,SAASC,WAAW,QAAQ,kBAAkB;AAuJ9C,MAAMC,uBAAuB,GAAG,8BAA8B;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;;AAUA,OAAO,SAASC,YAAYA,CAK1BC,aAAiD,EACjDC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACN,WAAW,CAAC;EAE1D,MAAM;IACJO,OAAO,EAAEC,aAAa,GAAG,IAAI;IAC7BC,aAAa;IACb,GAAGC;EACL,CAAC,GAAGN,OAAO;EACX,MAAMG,OAAO,GAAGC,aAAa,IAAIL,aAAa,IAAI,IAAI;;EAEtD;EACA,MAAMQ,aAAa,GACjBJ,OAAO,IAAIJ,aAAa,GACpBA,aAAa,CAACS,mBAAmB,CAACC,GAAG,CAACC,OAAO,GAC7Cb,uBAAuB;EAE7B,MAAMc,qBAAqB,GAAGnB,KAAK,CAACoB,MAAM,CAASL,aAAa,CAAC;EACjE,MAAMM,2BAA2B,GAAGrB,KAAK,CAACoB,MAAM,CAE9C,CAAC;EACH;EACA;EACA,MAAME,iBAAiB,GAAGH,qBA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OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,EAAEiB,MAAM,IAAI,IAAI,EAAE;IAC3B,OAAO,KAAK;EACd;EAEA,QAAQjB,OAAO,CAACiB,MAAM;IACpB,KAAK,QAAQ;IACb,KAAK,OAAO;MACV,OAAO,IAAI;IACb,KAAK,SAAS;IACd,KAAK,MAAM;MACT,OAAO,KAAK;IACd;MACEjB,OAAO,CAACiB,MAAM;MACd,OAAO,KAAK;EAChB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","useDevToolsMetadata","OsdkContext","useOsdkAction","actionDef","observableClient","devtoolsEnabled","useContext","apiName","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect","useMemo"],"sources":["useOsdkAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/observable\";\nimport React from \"react\";\nimport { useDevToolsMetadata } from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) => Promise<ActionEditResponse | undefined>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: ActionEditResponse | undefined;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient, devtoolsEnabled } = React.useContext(OsdkContext);\n useDevToolsMetadata(devtoolsEnabled, \"useOsdkAction\", actionDef.apiName);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<ActionEditResponse | undefined>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map(a => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n\n const validateAction = React.useCallback(async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n abortControllerRef.current?.abort();\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return React.useMemo(() => ({\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n }), [\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n ]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AO,CAAC,OAAO;IAC1B9B,WAAW;IACXqB,cAAc;IACdlC,KAAK;IACLG,IAAI;IACJE,SAAS;IACTE,YAAY;IACZE;EACF,CAAC,CAAC,EAAE,CACFI,WAAW,EACXqB,cAAc,EACdlC,KAAK,EACLG,IAAI,EACJE,SAAS,EACTE,YAAY,EACZE,gBAAgB,CACjB,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","useDevToolsMetadata","OsdkContext","useOsdkAction","actionDef","observableClient","devtoolsEnabled","useContext","apiName","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect","useMemo"],"sources":["useOsdkAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/observable\";\nimport React from \"react\";\n\nimport { useDevToolsMetadata } from \"./makeExternalStore.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<\n ActionSignatureFromDef<Q>[\"applyAction\"]\n>[0] & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]: ObservableClient.ApplyActionOptions[K];\n};\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>\n ) => Promise<ActionEditResponse | undefined>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: ActionEditResponse | undefined;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q\n): UseOsdkActionResult<Q> {\n const { observableClient, devtoolsEnabled } = React.useContext(OsdkContext);\n useDevToolsMetadata(devtoolsEnabled, \"useOsdkAction\", actionDef.apiName);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<ActionEditResponse | undefined>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(\n async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map((a) => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setPending(false);\n }\n },\n [observableClient, actionDef, isValidating]\n );\n\n const validateAction = React.useCallback(\n async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n abortControllerRef.current?.abort();\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n },\n [observableClient, actionDef, isPending]\n );\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return React.useMemo(\n () => ({\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n }),\n [\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n ]\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,qBAAqB,Q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