@osdk/react 0.10.0-beta.1 → 0.10.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/AGENTS.md +46 -221
  2. package/CHANGELOG.md +132 -0
  3. package/build/browser/new/makeExternalStore.js +61 -0
  4. package/build/browser/new/makeExternalStore.js.map +1 -1
  5. package/build/browser/new/useLinks.js +11 -4
  6. package/build/browser/new/useLinks.js.map +1 -1
  7. package/build/browser/new/useObjectSet.js +42 -18
  8. package/build/browser/new/useObjectSet.js.map +1 -1
  9. package/build/browser/new/useOsdkAction.js +2 -2
  10. package/build/browser/new/useOsdkAction.js.map +1 -1
  11. package/build/browser/new/useOsdkAggregation.js +65 -27
  12. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  13. package/build/browser/new/useOsdkFunction.js +17 -12
  14. package/build/browser/new/useOsdkFunction.js.map +1 -1
  15. package/build/browser/new/useOsdkObject.js +44 -26
  16. package/build/browser/new/useOsdkObject.js.map +1 -1
  17. package/build/browser/new/useOsdkObjects.js +28 -19
  18. package/build/browser/new/useOsdkObjects.js.map +1 -1
  19. package/build/browser/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
  20. package/build/browser/public/experimental/admin.js.map +1 -0
  21. package/build/browser/public/experimental.js +0 -3
  22. package/build/browser/public/experimental.js.map +1 -1
  23. package/build/browser/useOsdkMetadata.js.map +1 -1
  24. package/build/cjs/{chunk-V32JHU3O.cjs → chunk-OVBG5VXE.cjs} +3 -8
  25. package/build/cjs/chunk-OVBG5VXE.cjs.map +1 -0
  26. package/build/cjs/chunk-SVVMLSKN.cjs +111 -0
  27. package/build/cjs/chunk-SVVMLSKN.cjs.map +1 -0
  28. package/build/cjs/index.cjs +4 -4
  29. package/build/cjs/index.d.cts +1 -1
  30. package/build/cjs/public/experimental/admin.cjs +146 -0
  31. package/build/cjs/public/experimental/admin.cjs.map +1 -0
  32. package/build/cjs/public/experimental/admin.d.cts +118 -0
  33. package/build/cjs/public/experimental.cjs +253 -492
  34. package/build/cjs/public/experimental.cjs.map +1 -1
  35. package/build/cjs/public/experimental.d.cts +106 -138
  36. package/build/cjs/useOsdkMetadata-BElt3F5s.d.cts +15 -0
  37. package/build/esm/new/makeExternalStore.js +61 -0
  38. package/build/esm/new/makeExternalStore.js.map +1 -1
  39. package/build/esm/new/useLinks.js +11 -4
  40. package/build/esm/new/useLinks.js.map +1 -1
  41. package/build/esm/new/useObjectSet.js +42 -18
  42. package/build/esm/new/useObjectSet.js.map +1 -1
  43. package/build/esm/new/useOsdkAction.js +2 -2
  44. package/build/esm/new/useOsdkAction.js.map +1 -1
  45. package/build/esm/new/useOsdkAggregation.js +65 -27
  46. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  47. package/build/esm/new/useOsdkFunction.js +17 -12
  48. package/build/esm/new/useOsdkFunction.js.map +1 -1
  49. package/build/esm/new/useOsdkObject.js +44 -26
  50. package/build/esm/new/useOsdkObject.js.map +1 -1
  51. package/build/esm/new/useOsdkObjects.js +28 -19
  52. package/build/esm/new/useOsdkObjects.js.map +1 -1
  53. package/build/esm/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
  54. package/build/esm/public/experimental/admin.js.map +1 -0
  55. package/build/esm/public/experimental.js +0 -3
  56. package/build/esm/public/experimental.js.map +1 -1
  57. package/build/esm/useOsdkMetadata.js.map +1 -1
  58. package/build/types/new/makeExternalStore.d.ts +11 -0
  59. package/build/types/new/makeExternalStore.d.ts.map +1 -1
  60. package/build/types/new/useLinks.d.ts +19 -0
  61. package/build/types/new/useLinks.d.ts.map +1 -1
  62. package/build/types/new/useObjectSet.d.ts +10 -4
  63. package/build/types/new/useObjectSet.d.ts.map +1 -1
  64. package/build/types/new/useOsdkAggregation.d.ts +41 -3
  65. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  66. package/build/types/new/useOsdkFunction.d.ts +11 -5
  67. package/build/types/new/useOsdkFunction.d.ts.map +1 -1
  68. package/build/types/new/useOsdkObject.d.ts +18 -7
  69. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  70. package/build/types/new/useOsdkObjects.d.ts +26 -2
  71. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  72. package/build/types/public/experimental/admin.d.ts +3 -0
  73. package/build/types/public/experimental/admin.d.ts.map +1 -0
  74. package/build/types/public/experimental.d.ts +0 -3
  75. package/build/types/public/experimental.d.ts.map +1 -1
  76. package/build/types/useOsdkMetadata.d.ts +5 -4
  77. package/build/types/useOsdkMetadata.d.ts.map +1 -1
  78. package/docs/querying-data.md +19 -0
  79. package/{build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js → experimental/admin.d.ts} +1 -18
  80. package/package.json +29 -8
  81. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
  82. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js +0 -34
  83. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
  84. package/build/browser/intellisense.test.js +0 -148
  85. package/build/browser/intellisense.test.js.map +0 -1
  86. package/build/cjs/chunk-V32JHU3O.cjs.map +0 -1
  87. package/build/cjs/useOsdkMetadata-DFZhnhGZ.d.cts +0 -14
  88. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
  89. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
  90. package/build/esm/intellisense.test.js +0 -148
  91. package/build/esm/intellisense.test.js.map +0 -1
  92. package/build/types/intellisense.test.d.ts +0 -1
  93. package/build/types/intellisense.test.d.ts.map +0 -1
  94. package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts +0 -1
  95. package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts.map +0 -1
  96. package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts +0 -1
  97. package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts.map +0 -1
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ var chunkSVVMLSKN_cjs = require('../../chunk-SVVMLSKN.cjs');
4
+ var foundry_admin = require('@osdk/foundry.admin');
5
+ var React = require('react');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefault(React);
10
+
11
+ function usePlatformQuery({
12
+ query,
13
+ queryName,
14
+ enabled = true
15
+ }) {
16
+ const observerRef = React__default.default.useRef();
17
+ const handleQuery = React__default.default.useCallback(() => {
18
+ const observer = observerRef.current;
19
+ if (observer == null) return;
20
+ observer.next({
21
+ status: "loading",
22
+ data: void 0
23
+ });
24
+ query().then((data) => {
25
+ observer.next({
26
+ status: "success",
27
+ data
28
+ });
29
+ }).catch((err) => {
30
+ observer.error(err);
31
+ });
32
+ }, [query]);
33
+ const {
34
+ subscribe,
35
+ getSnapShot
36
+ } = React__default.default.useMemo(() => {
37
+ if (!enabled) {
38
+ return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
39
+ unsubscribe: () => {
40
+ }
41
+ }), process.env.NODE_ENV !== "production" ? `${queryName} Query [DISABLED]` : void 0);
42
+ }
43
+ return chunkSVVMLSKN_cjs.makeExternalStore((observer) => {
44
+ observerRef.current = observer;
45
+ handleQuery();
46
+ return {
47
+ unsubscribe: () => {
48
+ observerRef.current = void 0;
49
+ }
50
+ };
51
+ }, queryName);
52
+ }, [enabled, queryName, handleQuery]);
53
+ const payload = React__default.default.useSyncExternalStore(subscribe, getSnapShot);
54
+ let error;
55
+ if (payload && "error" in payload && payload.error != null) {
56
+ error = payload.error;
57
+ } else if (payload?.status === "error") {
58
+ error = new Error(`Failed to query platform API: ${queryName}`);
59
+ }
60
+ return {
61
+ data: payload?.data,
62
+ isLoading: enabled ? payload?.status === "loading" || !payload : false,
63
+ error,
64
+ refetch: handleQuery
65
+ };
66
+ }
67
+
68
+ // src/new/platform-apis/admin/useCurrentFoundryUser.ts
69
+ function useCurrentFoundryUser({
70
+ enabled = true
71
+ } = {}) {
72
+ const {
73
+ client
74
+ } = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
75
+ const handleQuery = React__default.default.useCallback(() => foundry_admin.Users.getCurrent(client), [client]);
76
+ const query = usePlatformQuery({
77
+ query: handleQuery,
78
+ enabled,
79
+ queryName: "foundry-current-user"
80
+ });
81
+ return {
82
+ currentUser: query.data,
83
+ isLoading: query.isLoading,
84
+ error: query.error,
85
+ refetch: query.refetch
86
+ };
87
+ }
88
+ function useFoundryUser(userId, {
89
+ enabled = true,
90
+ status = "ACTIVE"
91
+ } = {}) {
92
+ const {
93
+ client
94
+ } = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
95
+ const handleQuery = React__default.default.useCallback(() => {
96
+ return foundry_admin.Users.get(client, userId, {
97
+ status
98
+ });
99
+ }, [client, userId, status]);
100
+ const query = usePlatformQuery({
101
+ query: handleQuery,
102
+ enabled,
103
+ queryName: "foundry-user"
104
+ });
105
+ return {
106
+ user: query.data,
107
+ isLoading: query.isLoading,
108
+ error: query.error,
109
+ refetch: query.refetch
110
+ };
111
+ }
112
+ function useFoundryUsersList({
113
+ enabled = true,
114
+ include = "ACTIVE",
115
+ pageSize = 1e3,
116
+ pageToken
117
+ } = {}) {
118
+ const {
119
+ client
120
+ } = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
121
+ const handleQuery = React__default.default.useCallback(() => {
122
+ return foundry_admin.Users.list(client, {
123
+ include,
124
+ pageSize,
125
+ pageToken
126
+ });
127
+ }, [client, include, pageSize, pageToken]);
128
+ const query = usePlatformQuery({
129
+ query: handleQuery,
130
+ enabled,
131
+ queryName: "foundry-users-list"
132
+ });
133
+ return {
134
+ users: query.data?.data,
135
+ nextPageToken: query.data?.nextPageToken,
136
+ isLoading: query.isLoading,
137
+ error: query.error,
138
+ refetch: query.refetch
139
+ };
140
+ }
141
+
142
+ exports.useCurrentFoundryUser = useCurrentFoundryUser;
143
+ exports.useFoundryUser = useFoundryUser;
144
+ exports.useFoundryUsersList = useFoundryUsersList;
145
+ //# sourceMappingURL=admin.cjs.map
146
+ //# sourceMappingURL=admin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/usePlatformQuery.ts","../../../../src/new/platform-apis/admin/useCurrentFoundryUser.ts","../../../../src/new/platform-apis/admin/useFoundryUser.ts","../../../../src/new/platform-apis/admin/useFoundryUsersList.ts"],"names":["React","makeExternalStore","OsdkContext2","Users"],"mappings":";;;;;;;;;;AAkBO,SAAS,gBAAiB,CAAA;AAAA,EAC/B,KAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAU,GAAA;AACZ,CAAG,EAAA;AACD,EAAM,MAAA,WAAA,GAAcA,uBAAM,MAAO,EAAA;AACjC,EAAM,MAAA,WAAA,GAAcA,sBAAM,CAAA,WAAA,CAAY,MAAM;AAC1C,IAAA,MAAM,WAAW,WAAY,CAAA,OAAA;AAC7B,IAAA,IAAI,YAAY,IAAM,EAAA;AACtB,IAAA,QAAA,CAAS,IAAK,CAAA;AAAA,MACZ,MAAQ,EAAA,SAAA;AAAA,MACR,IAAM,EAAA;AAAA,KACP,CAAA;AACD,IAAM,KAAA,EAAA,CAAE,KAAK,CAAQ,IAAA,KAAA;AACnB,MAAA,QAAA,CAAS,IAAK,CAAA;AAAA,QACZ,MAAQ,EAAA,SAAA;AAAA,QACR;AAAA,OACD,CAAA;AAAA,KACF,CAAE,CAAA,KAAA,CAAM,CAAO,GAAA,KAAA;AACd,MAAA,QAAA,CAAS,MAAM,GAAG,CAAA;AAAA,KACnB,CAAA;AAAA,GACH,EAAG,CAAC,KAAK,CAAC,CAAA;AACV,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA;AAAA,GACF,GAAIA,sBAAM,CAAA,OAAA,CAAQ,MAAM;AACtB,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA,OAAOC,oCAAkB,OAAO;AA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A,GAAA;AAAA,EACX;AACF,CAAA,GAAI,EAAI,EAAA;AACN,EAAM,MAAA;AAAA,IACJ;AAAA,GACF,GAAIH,sBAAM,CAAA,UAAA,CAAWE,8BAAY,CAAA;AACjC,EAAM,MAAA,WAAA,GAAcF,sBAAM,CAAA,WAAA,CAAY,MAAM;AAC1C,IAAOG,OAAAA,mBAAAA,CAAM,KAAK,MAAQ,EAAA;AAAA,MACxB,OAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,KACA,CAAC,MAAA,EAAQ,OAAS,EAAA,QAAA,EAAU,SAAS,CAAC,CAAA;AACzC,EAAA,MAAM,QAAQ,gBAAiB,CAAA;AAAA,IAC7B,KAAO,EAAA,WAAA;AAAA,IACP,OAAA;AAAA,IACA,SAAW,EAAA;AAAA,GACZ,CAAA;AACD,EAAO,OAAA;AAAA,IACL,KAAA,EAAO,MAAM,IAAM,EAAA,IAAA;AAAA,IACnB,aAAA,EAAe,MAAM,IAAM,EAAA,aAAA;AAAA,IAC3B,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,OAAO,KAAM,CAAA,KAAA;AAAA,IACb,SAAS,KAAM,CAAA;AAAA,GACjB;AACF","file":"admin.cjs","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 React from \"react\";\nimport { makeExternalStore } from \"../new/makeExternalStore.js\";\nexport function usePlatformQuery({\n query,\n queryName,\n enabled = true\n}) {\n const observerRef = React.useRef();\n const handleQuery = React.useCallback(() => {\n const observer = observerRef.current;\n if (observer == null) return;\n observer.next({\n status: \"loading\",\n data: undefined\n });\n query().then(data => {\n observer.next({\n status: \"success\",\n data\n });\n }).catch(err => {\n observer.error(err);\n });\n }, [query]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), process.env.NODE_ENV !== \"production\" ? `${queryName} Query [DISABLED]` : undefined);\n }\n return makeExternalStore(observer => {\n observerRef.current = observer;\n handleQuery();\n return {\n unsubscribe: () => {\n observerRef.current = undefined;\n }\n };\n }, queryName);\n }, [enabled, queryName, handleQuery]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (payload && \"error\" in payload && payload.error != null) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(`Failed to query platform API: ${queryName}`);\n }\n return {\n data: payload?.data,\n isLoading: enabled ? payload?.status === \"loading\" || !payload : false,\n error,\n refetch: handleQuery\n };\n}","/*\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 { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser({\n enabled = true\n} = {}) {\n const {\n client\n } = React.useContext(OsdkContext2);\n const handleQuery = React.useCallback(() => Users.getCurrent(client), [client]);\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\"\n });\n return {\n currentUser: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch\n };\n}","/*\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 { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(userId, {\n enabled = true,\n status = \"ACTIVE\"\n} = {}) {\n const {\n client\n } = React.useContext(OsdkContext2);\n const handleQuery = React.useCallback(() => {\n return Users.get(client, userId, {\n status\n });\n }, [client, userId, status]);\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\"\n });\n return {\n user: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch\n };\n}","/*\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 { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList({\n enabled = true,\n include = \"ACTIVE\",\n pageSize = 1000,\n pageToken\n} = {}) {\n const {\n client\n } = React.useContext(OsdkContext2);\n const handleQuery = React.useCallback(() => {\n return Users.list(client, {\n include,\n pageSize,\n pageToken\n });\n }, [client, include, pageSize, pageToken]);\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\"\n });\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch\n };\n}"]}
@@ -0,0 +1,118 @@
1
+ import { User, ListUsersResponse } from '@osdk/foundry.admin';
2
+ import { UserStatus } from '@osdk/foundry.core';
3
+
4
+ interface UseCurrentFoundryUserOptions {
5
+ /**
6
+ * Enable or disable the query.
7
+ *
8
+ * When `false`, the query will not automatically execute.
9
+ *
10
+ * This is useful for:
11
+ * - Lazy/on-demand queries that should wait for user interaction
12
+ * - Dependent queries that need data from another query first
13
+ * - Conditional queries based on component state
14
+ *
15
+ * @default true
16
+ * });
17
+ */
18
+ enabled?: boolean;
19
+ }
20
+ interface UseCurrentFoundryUserResult {
21
+ currentUser: User | undefined;
22
+ isLoading: boolean;
23
+ error: Error | undefined;
24
+ refetch: () => void;
25
+ }
26
+ /**
27
+ * Get the currently signed in User.
28
+ * @param options Options to control the query.
29
+ */
30
+ declare function useCurrentFoundryUser({ enabled }?: UseCurrentFoundryUserOptions): UseCurrentFoundryUserResult;
31
+
32
+ interface UseFoundryUserOptions {
33
+ /**
34
+ * Enable or disable the query.
35
+ *
36
+ * When `false`, the query will not automatically execute.
37
+ *
38
+ * This is useful for:
39
+ * - Lazy/on-demand queries that should wait for user interaction
40
+ * - Dependent queries that need data from another query first
41
+ * - Conditional queries based on component state
42
+ *
43
+ * @default true
44
+ * });
45
+ */
46
+ enabled?: boolean;
47
+ /**
48
+ * The default status of the users returned in the list.
49
+ *
50
+ * @default "ACTIVE"
51
+ */
52
+ status?: UserStatus;
53
+ }
54
+ interface UseFoundryUserResult {
55
+ user: User | undefined;
56
+ isLoading: boolean;
57
+ error: Error | undefined;
58
+ refetch: () => void;
59
+ }
60
+ /**
61
+ * Get the User with the specified id.
62
+ * @param userId A Foundry User ID.
63
+ * @param options Options to control the query.
64
+ */
65
+ declare function useFoundryUser(userId: string, { enabled, status }?: UseFoundryUserOptions): UseFoundryUserResult;
66
+
67
+ interface UseFoundryUsersListOptions {
68
+ /**
69
+ * Enable or disable the query.
70
+ *
71
+ * When `false`, the query will not automatically execute.
72
+ *
73
+ * This is useful for:
74
+ * - Lazy/on-demand queries that should wait for user interaction
75
+ * - Dependent queries that need data from another query first
76
+ * - Conditional queries based on component state
77
+ *
78
+ * @default true
79
+ * });
80
+ */
81
+ enabled?: boolean;
82
+ /**
83
+ * The default status of the users returned in the list.
84
+ *
85
+ * @default "ACTIVE"
86
+ */
87
+ include?: UserStatus;
88
+ /**
89
+ * The preferred page size for the list.
90
+ *
91
+ * @default 1000
92
+ */
93
+ pageSize?: number;
94
+ /**
95
+ * The page token indicates where to start paging. This should be omitted from the first page's request.
96
+ * To fetch the next page, clients should take the value from the nextPageToken field of the previous
97
+ * response and use it to populate the pageToken field of the next request.
98
+ */
99
+ pageToken?: string;
100
+ }
101
+ interface UseFoundryUsersListResult {
102
+ users: ListUsersResponse["data"] | undefined;
103
+ /**
104
+ * The page token to be used for the next page of users. If this is undefined, there are no more
105
+ * pages of users to load.
106
+ */
107
+ nextPageToken: string | undefined;
108
+ isLoading: boolean;
109
+ error: Error | undefined;
110
+ refetch: () => void;
111
+ }
112
+ /**
113
+ * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.
114
+ * @param options Options to control the query.
115
+ */
116
+ declare function useFoundryUsersList({ enabled, include, pageSize, pageToken }?: UseFoundryUsersListOptions): UseFoundryUsersListResult;
117
+
118
+ export { useCurrentFoundryUser, useFoundryUser, useFoundryUsersList };