@osdk/react 2.94.0 → 2.94.1-main-718be7c10524d5aa3086fbfd38785c0abd0a2c87
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.
- package/CHANGELOG.md +9 -0
- package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
- package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -1
- package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useObjectSet.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +2 -5
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/{chunk-EJT5W6SI.cjs → chunk-4PFYL4UI.cjs} +3 -3
- package/build/cjs/chunk-4PFYL4UI.cjs.map +1 -0
- package/build/cjs/index.cjs +15 -15
- package/build/cjs/public/experimental.cjs +16 -16
- package/build/cjs/public/experimental.d.cts +9 -12
- package/build/cjs/public/platform-apis.d.cts +1 -4
- package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
- package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -1
- package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useObjectSet.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +2 -5
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +0 -1
- package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -1
- package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +1 -2
- package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -1
- package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +0 -1
- package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -1
- package/build/types/new/useLinks.d.ts +2 -2
- package/build/types/new/useObjectSet.d.ts +2 -2
- package/build/types/new/useOsdkAggregation.d.ts +3 -6
- package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
- package/build/types/new/useOsdkObjects.d.ts +2 -2
- package/docs/actions.mdx +314 -0
- package/docs/aggregations.mdx +256 -0
- package/docs/cache-invalidation.mdx +229 -0
- package/docs/devtools/cache.mdx +29 -0
- package/docs/devtools/components.mdx +40 -0
- package/docs/devtools/console.mdx +29 -0
- package/docs/devtools/index.mdx +151 -0
- package/docs/devtools/overview.mdx +45 -0
- package/docs/functions.mdx +246 -0
- package/docs/index.mdx +62 -0
- package/docs/links.mdx +270 -0
- package/docs/meta.json +30 -0
- package/docs/object-sets.mdx +296 -0
- package/docs/objects.mdx +489 -0
- package/docs/optimistic-updates.mdx +164 -0
- package/docs/platform-apis.mdx +296 -0
- package/docs/testing.mdx +348 -0
- package/package.json +6 -6
- package/build/cjs/chunk-EJT5W6SI.cjs.map +0 -1
- package/docs/actions.md +0 -432
- package/docs/advanced-queries.md +0 -678
- package/docs/cache-management.md +0 -222
- package/docs/getting-started.md +0 -319
- package/docs/platform-apis.md +0 -234
- package/docs/prerequisites.md +0 -48
- package/docs/querying-data.md +0 -810
package/docs/platform-apis.md
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 6
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Platform APIs
|
|
6
|
-
|
|
7
|
-
This guide covers available platform APIs that can used with OSDK React hooks.
|
|
8
|
-
|
|
9
|
-
## Handling errors with PalantirApiError
|
|
10
|
-
|
|
11
|
-
All platform-API hooks return errors as plain `Error` instances; when the failure originates from a Foundry API call, the error is a `PalantirApiError` (re-exported from `@osdk/client`). Narrow with `instanceof` to access the structured fields. All fields below are optional — narrow before you use them:
|
|
12
|
-
|
|
13
|
-
| Field | Type | Use |
|
|
14
|
-
| ------------------ | --------- | --------------------------------------------------- |
|
|
15
|
-
| `errorName` | `string?` | Stable machine identifier (e.g. `UserNotFound`) |
|
|
16
|
-
| `errorCode` | `string?` | HTTP-style code (e.g. `NOT_FOUND`) |
|
|
17
|
-
| `errorDescription` | `string?` | Human-readable message |
|
|
18
|
-
| `statusCode` | `number?` | HTTP status |
|
|
19
|
-
| `errorInstanceId` | `string?` | Server-side correlation ID — include in bug reports |
|
|
20
|
-
| `parameters` | `object?` | Server-supplied context (e.g. `{ userId }`) |
|
|
21
|
-
|
|
22
|
-
Switch on `errorName` for branching behavior; show `errorInstanceId` to support engineers when surfacing an opaque failure.
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import { PalantirApiError } from "@osdk/client";
|
|
26
|
-
|
|
27
|
-
function describe(error: Error): string {
|
|
28
|
-
if (!(error instanceof PalantirApiError)) {
|
|
29
|
-
return error.message;
|
|
30
|
-
}
|
|
31
|
-
if (error.errorName === "UserNotFound") {
|
|
32
|
-
return "We couldn't find that user.";
|
|
33
|
-
}
|
|
34
|
-
return `${error.errorDescription} (id: ${error.errorInstanceId})`;
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## useFoundryUser
|
|
41
|
-
|
|
42
|
-
Retrieves a specific Foundry user by their user ID.
|
|
43
|
-
|
|
44
|
-
### Basic Usage
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
import { PalantirApiError } from "@osdk/client";
|
|
48
|
-
import { useFoundryUser } from "@osdk/react/platform-apis";
|
|
49
|
-
|
|
50
|
-
export function UserProfile({ userId }: { userId: string }) {
|
|
51
|
-
const { user, isLoading, error } = useFoundryUser(userId);
|
|
52
|
-
|
|
53
|
-
if (error != null) {
|
|
54
|
-
const errorMessage = error instanceof PalantirApiError
|
|
55
|
-
? error.errorDescription
|
|
56
|
-
: error.message;
|
|
57
|
-
|
|
58
|
-
return <div>Failed to load user: {errorMessage}</div>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div>
|
|
63
|
-
{isLoading && <span>Loading...</span>}
|
|
64
|
-
{user && (
|
|
65
|
-
<div>
|
|
66
|
-
<h2>
|
|
67
|
-
{user.givenName} {user.familyName}
|
|
68
|
-
</h2>
|
|
69
|
-
<p>Username: {user.username}</p>
|
|
70
|
-
<p>Email: {user.email}</p>
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Return Values
|
|
79
|
-
|
|
80
|
-
- `user` - The user object, or undefined if not loaded
|
|
81
|
-
- `isLoading` - True while fetching from server
|
|
82
|
-
- `error` - Error object if fetch failed
|
|
83
|
-
- `refetch` - Function to manually refetch the user data
|
|
84
|
-
|
|
85
|
-
### Options
|
|
86
|
-
|
|
87
|
-
- `userId` (required) - The Foundry User ID to fetch
|
|
88
|
-
- `enabled` - Enable/disable the query (default: `true`)
|
|
89
|
-
- `status` - User status filter (default: `"ACTIVE"`)
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## useCurrentFoundryUser
|
|
94
|
-
|
|
95
|
-
Retrieves the currently signed-in Foundry user.
|
|
96
|
-
|
|
97
|
-
### Basic Usage
|
|
98
|
-
|
|
99
|
-
```tsx
|
|
100
|
-
import { PalantirApiError } from "@osdk/client";
|
|
101
|
-
import { useCurrentFoundryUser } from "@osdk/react/platform-apis";
|
|
102
|
-
|
|
103
|
-
export function CurrentUserBadge() {
|
|
104
|
-
const { currentUser, isLoading, error } = useCurrentFoundryUser();
|
|
105
|
-
|
|
106
|
-
if (error != null) {
|
|
107
|
-
const errorMessage = error instanceof PalantirApiError
|
|
108
|
-
? error.errorDescription
|
|
109
|
-
: error.message;
|
|
110
|
-
|
|
111
|
-
return <div>Failed to load current user: {errorMessage}</div>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div>
|
|
116
|
-
{isLoading && <span>Loading...</span>}
|
|
117
|
-
{currentUser && <span>Welcome, {currentUser.givenName}!</span>}
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Return Values
|
|
124
|
-
|
|
125
|
-
- `currentUser` - The current user object, or undefined if not loaded
|
|
126
|
-
- `isLoading` - True while fetching from server
|
|
127
|
-
- `error` - Error object if fetch failed
|
|
128
|
-
- `refetch` - Function to manually refetch the current user data
|
|
129
|
-
|
|
130
|
-
### Options
|
|
131
|
-
|
|
132
|
-
- `enabled` - Enable/disable the query (default: `true`)
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## useFoundryUsersList
|
|
137
|
-
|
|
138
|
-
Lists all Foundry users with pagination support.
|
|
139
|
-
|
|
140
|
-
### Basic Usage
|
|
141
|
-
|
|
142
|
-
```tsx
|
|
143
|
-
import { PalantirApiError } from "@osdk/client";
|
|
144
|
-
import { useFoundryUsersList } from "@osdk/react/platform-apis";
|
|
145
|
-
|
|
146
|
-
export function UsersList() {
|
|
147
|
-
const { users, isLoading, error } = useFoundryUsersList();
|
|
148
|
-
|
|
149
|
-
if (error != null) {
|
|
150
|
-
const errorMessage = error instanceof PalantirApiError
|
|
151
|
-
? error.errorDescription
|
|
152
|
-
: error.message;
|
|
153
|
-
|
|
154
|
-
return <div>Failed to load user list: {errorMessage}</div>;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<div>
|
|
159
|
-
{isLoading && <span>Loading users...</span>}
|
|
160
|
-
{users && (
|
|
161
|
-
<ul>
|
|
162
|
-
{users.map((user) => (
|
|
163
|
-
<li key={user.id}>
|
|
164
|
-
{user.username}
|
|
165
|
-
</li>
|
|
166
|
-
))}
|
|
167
|
-
</ul>
|
|
168
|
-
)}
|
|
169
|
-
</div>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Return Values
|
|
175
|
-
|
|
176
|
-
- `users` - Array of users, or undefined if not loaded
|
|
177
|
-
- `nextPageToken` - Page token for the next page (undefined if no more pages)
|
|
178
|
-
- `isLoading` - True while fetching from server
|
|
179
|
-
- `error` - Error object if fetch failed
|
|
180
|
-
- `refetch` - Function to manually refetch the users list
|
|
181
|
-
|
|
182
|
-
### Options
|
|
183
|
-
|
|
184
|
-
- `enabled` - Enable/disable the query (default: `true`)
|
|
185
|
-
- `include` - User status filter (default: `"ACTIVE"`)
|
|
186
|
-
- `pageSize` - Preferred page size (default: `1000`)
|
|
187
|
-
- `pageToken` - Page token for fetching subsequent pages (omit for first page)
|
|
188
|
-
|
|
189
|
-
### Pagination
|
|
190
|
-
|
|
191
|
-
```tsx
|
|
192
|
-
import { PalantirApiError } from "@osdk/client";
|
|
193
|
-
import { useFoundryUsersList } from "@osdk/react/platform-apis";
|
|
194
|
-
import { useState } from "react";
|
|
195
|
-
|
|
196
|
-
export function UsersList() {
|
|
197
|
-
const [pageToken, setPageToken] = useState<string | undefined>(undefined);
|
|
198
|
-
|
|
199
|
-
const { users, nextPageToken, error, isLoading } = useFoundryUsersList({
|
|
200
|
-
pageSize: 10,
|
|
201
|
-
pageToken,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
if (error != null) {
|
|
205
|
-
const errorMessage = error instanceof PalantirApiError
|
|
206
|
-
? error.errorDescription
|
|
207
|
-
: error.message;
|
|
208
|
-
|
|
209
|
-
return <div>Failed to load users: {errorMessage}</div>;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return (
|
|
213
|
-
<div>
|
|
214
|
-
{isLoading && <span>Loading...</span>}
|
|
215
|
-
{users && (
|
|
216
|
-
<>
|
|
217
|
-
<ul>
|
|
218
|
-
{users.map((user) => <li key={user.id}>{user.username}</li>)}
|
|
219
|
-
</ul>
|
|
220
|
-
|
|
221
|
-
{nextPageToken && (
|
|
222
|
-
<button
|
|
223
|
-
onClick={() => setPageToken(nextPageToken)}
|
|
224
|
-
disabled={isLoading}
|
|
225
|
-
>
|
|
226
|
-
Next page
|
|
227
|
-
</button>
|
|
228
|
-
)}
|
|
229
|
-
</>
|
|
230
|
-
)}
|
|
231
|
-
</div>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
```
|
package/docs/prerequisites.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Prerequisites
|
|
6
|
-
|
|
7
|
-
Setup required before using `@osdk/react` hooks.
|
|
8
|
-
|
|
9
|
-
## Install dependencies
|
|
10
|
-
|
|
11
|
-
:::tip If your tooling already installs dependencies, skip this step.
|
|
12
|
-
:::
|
|
13
|
-
|
|
14
|
-
Use whichever package manager your project uses:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# npm
|
|
18
|
-
npm install @osdk/api @osdk/client @osdk/react react react-dom
|
|
19
|
-
|
|
20
|
-
# pnpm
|
|
21
|
-
pnpm add @osdk/api @osdk/client @osdk/react react react-dom
|
|
22
|
-
|
|
23
|
-
# yarn
|
|
24
|
-
yarn add @osdk/api @osdk/client @osdk/react react react-dom
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Configure the OSDK client
|
|
28
|
-
|
|
29
|
-
Create an OSDK client and wrap your app with `OsdkProvider`:
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
import { createClient } from "@osdk/client";
|
|
33
|
-
import { OsdkProvider } from "@osdk/react";
|
|
34
|
-
|
|
35
|
-
const client = createClient(
|
|
36
|
-
"https://your-stack.palantirfoundry.com",
|
|
37
|
-
"ri.ontology.main.ontology.{UUID}",
|
|
38
|
-
async () => {
|
|
39
|
-
// return your auth token
|
|
40
|
-
},
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
function App() {
|
|
44
|
-
return <OsdkProvider client={client}>{/* your app */}</OsdkProvider>;
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
All `@osdk/react` hooks must be called inside an `OsdkProvider`. Without it, hooks will throw.
|