@osdk/react 0.8.0 → 0.9.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.
- package/AGENTS.md +253 -0
- package/CHANGELOG.md +105 -24
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js +1 -1
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +1 -1
- package/build/browser/intellisense.test.js +1 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
- package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useFoundryUser.js +50 -0
- package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useFoundryUsersList.js +54 -0
- package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
- package/build/browser/new/useLinks.js +15 -8
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useObjectSet.js +3 -2
- package/build/browser/new/useObjectSet.js.map +1 -1
- package/build/browser/new/useOsdkAction.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +1 -1
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkFunction.js +101 -0
- package/build/browser/new/useOsdkFunction.js.map +1 -0
- package/build/browser/new/useOsdkObject.js +1 -1
- package/build/browser/new/useOsdkObject.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +4 -3
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/public/experimental.js +4 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/utils/usePlatformQuery.js +74 -0
- package/build/browser/utils/usePlatformQuery.js.map +1 -0
- package/build/cjs/{chunk-OVBG5VXE.cjs → chunk-V32JHU3O.cjs} +8 -3
- package/build/cjs/chunk-V32JHU3O.cjs.map +1 -0
- package/build/cjs/index.cjs +4 -4
- package/build/cjs/public/experimental.cjs +399 -66
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +279 -32
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js +1 -1
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +1 -1
- package/build/esm/intellisense.test.js +1 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
- package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useFoundryUser.js +50 -0
- package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useFoundryUsersList.js +54 -0
- package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
- package/build/esm/new/useLinks.js +15 -8
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useObjectSet.js +3 -2
- package/build/esm/new/useObjectSet.js.map +1 -1
- package/build/esm/new/useOsdkAction.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +1 -1
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkFunction.js +101 -0
- package/build/esm/new/useOsdkFunction.js.map +1 -0
- package/build/esm/new/useOsdkObject.js +1 -1
- package/build/esm/new/useOsdkObject.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +4 -3
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/esm/public/experimental.js +4 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/esm/utils/usePlatformQuery.js +74 -0
- package/build/esm/utils/usePlatformQuery.js.map +1 -0
- package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +28 -0
- package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +36 -0
- package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +52 -0
- package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -0
- package/build/types/new/useLinks.d.ts +5 -5
- package/build/types/new/useLinks.d.ts.map +1 -1
- package/build/types/new/useObjectSet.d.ts +4 -0
- package/build/types/new/useObjectSet.d.ts.map +1 -1
- package/build/types/new/useOsdkAction.d.ts +3 -3
- package/build/types/new/useOsdkAction.d.ts.map +1 -1
- package/build/types/new/useOsdkAggregation.d.ts +10 -12
- package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
- package/build/types/new/useOsdkFunction.d.ts +112 -0
- package/build/types/new/useOsdkFunction.d.ts.map +1 -0
- package/build/types/new/useOsdkObjects.d.ts +31 -13
- package/build/types/new/useOsdkObjects.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +5 -0
- package/build/types/public/experimental.d.ts.map +1 -1
- package/build/types/utils/usePlatformQuery.d.ts +25 -0
- package/build/types/utils/usePlatformQuery.d.ts.map +1 -0
- package/docs/actions.md +414 -0
- package/docs/advanced-queries.md +663 -0
- package/docs/cache-management.md +213 -0
- package/docs/getting-started.md +382 -0
- package/docs/platform-apis.md +203 -0
- package/docs/querying-data.md +648 -0
- package/package.json +10 -6
- package/build/browser/new/types.js +0 -2
- package/build/browser/new/types.js.map +0 -1
- package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
- package/build/esm/new/types.js +0 -2
- package/build/esm/new/types.js.map +0 -1
- package/build/types/new/types.d.ts +0 -5
- package/build/types/new/types.d.ts.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkV32JHU3O_cjs = require('../chunk-V32JHU3O.cjs');
|
|
4
4
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
5
|
-
var
|
|
5
|
+
var React9 = require('react');
|
|
6
6
|
var client = require('@osdk/client');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var React9__default = /*#__PURE__*/_interopDefault(React9);
|
|
11
11
|
|
|
12
12
|
function fakeClientFn(..._args) {
|
|
13
13
|
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
@@ -15,7 +15,7 @@ function fakeClientFn(..._args) {
|
|
|
15
15
|
var fakeClient = Object.assign(fakeClientFn, {
|
|
16
16
|
fetchMetadata: fakeClientFn
|
|
17
17
|
});
|
|
18
|
-
var OsdkContext2 = /* @__PURE__ */
|
|
18
|
+
var OsdkContext2 = /* @__PURE__ */ React9__default.default.createContext({
|
|
19
19
|
client: fakeClient,
|
|
20
20
|
observableClient: void 0
|
|
21
21
|
});
|
|
@@ -26,19 +26,162 @@ function OsdkProvider2({
|
|
|
26
26
|
client,
|
|
27
27
|
observableClient
|
|
28
28
|
}) {
|
|
29
|
-
observableClient =
|
|
30
|
-
return /* @__PURE__ */
|
|
29
|
+
observableClient = React9.useMemo(() => observableClient ?? unstableDoNotUse.createObservableClient(client), [client, observableClient]);
|
|
30
|
+
return /* @__PURE__ */ React9__default.default.createElement(OsdkContext2.Provider, {
|
|
31
31
|
value: {
|
|
32
32
|
client,
|
|
33
33
|
observableClient
|
|
34
34
|
}
|
|
35
|
-
}, /* @__PURE__ */
|
|
35
|
+
}, /* @__PURE__ */ React9__default.default.createElement(chunkV32JHU3O_cjs.OsdkContext.Provider, {
|
|
36
36
|
value: {
|
|
37
37
|
client
|
|
38
38
|
}
|
|
39
39
|
}, children));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// ../../node_modules/.pnpm/@osdk+shared.client@1.0.1/node_modules/@osdk/shared.client/index.js
|
|
43
|
+
var symbolClientContext = Symbol("ClientContext");
|
|
44
|
+
|
|
45
|
+
// ../../node_modules/.pnpm/@osdk+shared.client2@1.0.0/node_modules/@osdk/shared.client2/index.js
|
|
46
|
+
var symbolClientContext2 = "__osdkClientContext";
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/.pnpm/@osdk+shared.net.errors@2.5.0-beta.2/node_modules/@osdk/shared.net.errors/build/esm/PalantirApiError.js
|
|
49
|
+
var PalantirApiError = class extends Error {
|
|
50
|
+
constructor(message, errorName, errorCode, errorDescription, statusCode, errorInstanceId, parameters) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.message = message;
|
|
53
|
+
this.errorName = errorName;
|
|
54
|
+
this.errorCode = errorCode;
|
|
55
|
+
this.errorDescription = errorDescription;
|
|
56
|
+
this.statusCode = statusCode;
|
|
57
|
+
this.errorInstanceId = errorInstanceId;
|
|
58
|
+
this.parameters = parameters;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/@osdk+shared.net.errors@2.5.0-beta.2/node_modules/@osdk/shared.net.errors/build/esm/UnknownError.js
|
|
63
|
+
var UnknownError = class extends PalantirApiError {
|
|
64
|
+
constructor(message, errorName, originalError, statusCode) {
|
|
65
|
+
super(message, errorName, void 0, void 0, statusCode);
|
|
66
|
+
this.originalError = originalError;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// ../../node_modules/.pnpm/@osdk+shared.net.platformapi@1.6.0/node_modules/@osdk/shared.net.platformapi/build/esm/foundryPlatformFetch.js
|
|
71
|
+
async function foundryPlatformFetch(client, [httpMethodNum, origPath, flags, contentType, responseContentType], ...args) {
|
|
72
|
+
const path = origPath.replace(/\{([^}]+)\}/g, () => encodeURIComponent(args.shift()));
|
|
73
|
+
const body = flags & 1 ? args.shift() : void 0;
|
|
74
|
+
const queryArgs = flags & 2 ? args.shift() : void 0;
|
|
75
|
+
const headerArgs = flags & 4 ? args.shift() : void 0;
|
|
76
|
+
const method = ["GET", "POST", "PUT", "DELETE", "PATCH"][httpMethodNum];
|
|
77
|
+
return await apiFetch(client[symbolClientContext2] ?? client[symbolClientContext] ?? client, method, path, body, queryArgs, headerArgs, contentType, responseContentType);
|
|
78
|
+
}
|
|
79
|
+
async function apiFetch(clientCtx, method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {
|
|
80
|
+
const url = parseUrl(clientCtx.baseUrl, endpointPath);
|
|
81
|
+
for (const [key, value] of Object.entries(queryArguments || {})) {
|
|
82
|
+
if (value == null) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
for (const item of value) {
|
|
87
|
+
url.searchParams.append(key, item);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
url.searchParams.append(key, value);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const headersInit = new Headers();
|
|
94
|
+
headersInit.set("Content-Type", requestMediaType ?? "application/json");
|
|
95
|
+
headersInit.set("Accept", responseMediaType ?? "application/json");
|
|
96
|
+
Object.entries(headers || {}).forEach(([key, value]) => {
|
|
97
|
+
if (key === "Content-Type" && typeof value === "string") {
|
|
98
|
+
headersInit.set("Content-Type", value);
|
|
99
|
+
} else if (key === "Accept" && typeof value === "string") {
|
|
100
|
+
headersInit.set("Accept", value);
|
|
101
|
+
} else if (value != null) {
|
|
102
|
+
headersInit.append(key, value.toString());
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const body = data == null || data instanceof globalThis.Blob ? data : JSON.stringify(data);
|
|
106
|
+
const response = await clientCtx.fetch(url.toString(), {
|
|
107
|
+
body,
|
|
108
|
+
method,
|
|
109
|
+
headers: headersInit
|
|
110
|
+
});
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
try {
|
|
113
|
+
const convertedError = await response.json();
|
|
114
|
+
return new PalantirApiError(convertedError.message, convertedError.errorName, convertedError.errorCode, convertedError.errorDescription, response.status, convertedError.errorInstanceId, convertedError.parameters);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
if (e instanceof Error) {
|
|
117
|
+
return new UnknownError(e.message, "UNKNOWN");
|
|
118
|
+
}
|
|
119
|
+
return new UnknownError("Unable to parse error response", "UNKNOWN");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (response.status === 204) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (responseMediaType == null || responseMediaType === "application/json") {
|
|
126
|
+
return await response.json();
|
|
127
|
+
}
|
|
128
|
+
return response;
|
|
129
|
+
}
|
|
130
|
+
function parseUrl(baseUrl, endpointPath) {
|
|
131
|
+
baseUrl += baseUrl.endsWith("/") ? "" : "/";
|
|
132
|
+
return new URL(`api${endpointPath}`, baseUrl);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ../../node_modules/.pnpm/@osdk+foundry.admin@2.45.0/node_modules/@osdk/foundry.admin/build/esm/public/User.js
|
|
136
|
+
var User_exports = {};
|
|
137
|
+
chunkV32JHU3O_cjs.__export(User_exports, {
|
|
138
|
+
deleteUser: () => deleteUser,
|
|
139
|
+
get: () => get,
|
|
140
|
+
getBatch: () => getBatch,
|
|
141
|
+
getCurrent: () => getCurrent,
|
|
142
|
+
getMarkings: () => getMarkings,
|
|
143
|
+
list: () => list,
|
|
144
|
+
profilePicture: () => profilePicture,
|
|
145
|
+
revokeAllTokens: () => revokeAllTokens,
|
|
146
|
+
search: () => search
|
|
147
|
+
});
|
|
148
|
+
var _deleteUser = [3, "/v2/admin/users/{0}"];
|
|
149
|
+
function deleteUser($ctx, ...args) {
|
|
150
|
+
return foundryPlatformFetch($ctx, _deleteUser, ...args);
|
|
151
|
+
}
|
|
152
|
+
var _list = [0, "/v2/admin/users", 2];
|
|
153
|
+
function list($ctx, ...args) {
|
|
154
|
+
return foundryPlatformFetch($ctx, _list, ...args);
|
|
155
|
+
}
|
|
156
|
+
var _get = [0, "/v2/admin/users/{0}", 2];
|
|
157
|
+
function get($ctx, ...args) {
|
|
158
|
+
return foundryPlatformFetch($ctx, _get, ...args);
|
|
159
|
+
}
|
|
160
|
+
var _getBatch = [1, "/v2/admin/users/getBatch", 1];
|
|
161
|
+
function getBatch($ctx, ...args) {
|
|
162
|
+
return foundryPlatformFetch($ctx, _getBatch, ...args);
|
|
163
|
+
}
|
|
164
|
+
var _getCurrent = [0, "/v2/admin/users/getCurrent"];
|
|
165
|
+
function getCurrent($ctx, ...args) {
|
|
166
|
+
return foundryPlatformFetch($ctx, _getCurrent, ...args);
|
|
167
|
+
}
|
|
168
|
+
var _getMarkings = [0, "/v2/admin/users/{0}/getMarkings", 2];
|
|
169
|
+
function getMarkings($ctx, ...args) {
|
|
170
|
+
return foundryPlatformFetch($ctx, _getMarkings, ...args);
|
|
171
|
+
}
|
|
172
|
+
var _profilePicture = [0, "/v2/admin/users/{0}/profilePicture", , , "application/octet-stream"];
|
|
173
|
+
function profilePicture($ctx, ...args) {
|
|
174
|
+
return foundryPlatformFetch($ctx, _profilePicture, ...args);
|
|
175
|
+
}
|
|
176
|
+
var _search = [1, "/v2/admin/users/search", 1];
|
|
177
|
+
function search($ctx, ...args) {
|
|
178
|
+
return foundryPlatformFetch($ctx, _search, ...args);
|
|
179
|
+
}
|
|
180
|
+
var _revokeAllTokens = [1, "/v2/admin/users/{0}/revokeAllTokens", 2];
|
|
181
|
+
function revokeAllTokens($ctx, ...args) {
|
|
182
|
+
return foundryPlatformFetch($ctx, _revokeAllTokens, ...args);
|
|
183
|
+
}
|
|
184
|
+
|
|
42
185
|
// src/new/makeExternalStore.ts
|
|
43
186
|
function makeExternalStore(createObservation, _name, initialValue) {
|
|
44
187
|
let lastResult = initialValue;
|
|
@@ -71,59 +214,196 @@ function makeExternalStore(createObservation, _name, initialValue) {
|
|
|
71
214
|
};
|
|
72
215
|
}
|
|
73
216
|
|
|
74
|
-
// src/
|
|
217
|
+
// src/utils/usePlatformQuery.ts
|
|
218
|
+
function usePlatformQuery({
|
|
219
|
+
query,
|
|
220
|
+
queryName,
|
|
221
|
+
enabled = true
|
|
222
|
+
}) {
|
|
223
|
+
const observerRef = React9__default.default.useRef();
|
|
224
|
+
const handleQuery = React9__default.default.useCallback(() => {
|
|
225
|
+
const observer = observerRef.current;
|
|
226
|
+
if (observer == null) return;
|
|
227
|
+
observer.next({
|
|
228
|
+
status: "loading",
|
|
229
|
+
data: void 0
|
|
230
|
+
});
|
|
231
|
+
query().then((data) => {
|
|
232
|
+
observer.next({
|
|
233
|
+
status: "success",
|
|
234
|
+
data
|
|
235
|
+
});
|
|
236
|
+
}).catch((err) => {
|
|
237
|
+
observer.error(err);
|
|
238
|
+
});
|
|
239
|
+
}, [query]);
|
|
240
|
+
const {
|
|
241
|
+
subscribe,
|
|
242
|
+
getSnapShot
|
|
243
|
+
} = React9__default.default.useMemo(() => {
|
|
244
|
+
if (!enabled) {
|
|
245
|
+
return makeExternalStore(() => ({
|
|
246
|
+
unsubscribe: () => {
|
|
247
|
+
}
|
|
248
|
+
}), process.env.NODE_ENV !== "production" ? `${queryName} Query [DISABLED]` : void 0);
|
|
249
|
+
}
|
|
250
|
+
return makeExternalStore((observer) => {
|
|
251
|
+
observerRef.current = observer;
|
|
252
|
+
handleQuery();
|
|
253
|
+
return {
|
|
254
|
+
unsubscribe: () => {
|
|
255
|
+
observerRef.current = void 0;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
}, [enabled, queryName, handleQuery]);
|
|
260
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
261
|
+
let error;
|
|
262
|
+
if (payload && "error" in payload && payload.error != null) {
|
|
263
|
+
error = payload.error;
|
|
264
|
+
} else if (payload?.status === "error") {
|
|
265
|
+
error = new Error(`Failed to query platform API: ${queryName}`);
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
data: payload?.data,
|
|
269
|
+
isLoading: enabled ? payload?.status === "loading" || !payload : false,
|
|
270
|
+
error,
|
|
271
|
+
refetch: handleQuery
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/new/platform-apis/admin/useCurrentFoundryUser.ts
|
|
276
|
+
function useCurrentFoundryUser({
|
|
277
|
+
enabled = true
|
|
278
|
+
} = {}) {
|
|
279
|
+
const {
|
|
280
|
+
client
|
|
281
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
282
|
+
const handleQuery = React9__default.default.useCallback(() => User_exports.getCurrent(client), [client]);
|
|
283
|
+
const query = usePlatformQuery({
|
|
284
|
+
query: handleQuery,
|
|
285
|
+
enabled,
|
|
286
|
+
queryName: "foundry-current-user"
|
|
287
|
+
});
|
|
288
|
+
return {
|
|
289
|
+
currentUser: query.data,
|
|
290
|
+
isLoading: query.isLoading,
|
|
291
|
+
error: query.error,
|
|
292
|
+
refetch: query.refetch
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function useFoundryUser(userId, {
|
|
296
|
+
enabled = true,
|
|
297
|
+
status = "ACTIVE"
|
|
298
|
+
} = {}) {
|
|
299
|
+
const {
|
|
300
|
+
client
|
|
301
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
302
|
+
const handleQuery = React9__default.default.useCallback(() => {
|
|
303
|
+
return User_exports.get(client, userId, {
|
|
304
|
+
status
|
|
305
|
+
});
|
|
306
|
+
}, [client, userId, status]);
|
|
307
|
+
const query = usePlatformQuery({
|
|
308
|
+
query: handleQuery,
|
|
309
|
+
enabled,
|
|
310
|
+
queryName: "foundry-user"
|
|
311
|
+
});
|
|
312
|
+
return {
|
|
313
|
+
user: query.data,
|
|
314
|
+
isLoading: query.isLoading,
|
|
315
|
+
error: query.error,
|
|
316
|
+
refetch: query.refetch
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function useFoundryUsersList({
|
|
320
|
+
enabled = true,
|
|
321
|
+
include = "ACTIVE",
|
|
322
|
+
pageSize = 1e3,
|
|
323
|
+
pageToken
|
|
324
|
+
} = {}) {
|
|
325
|
+
const {
|
|
326
|
+
client
|
|
327
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
328
|
+
const handleQuery = React9__default.default.useCallback(() => {
|
|
329
|
+
return User_exports.list(client, {
|
|
330
|
+
include,
|
|
331
|
+
pageSize,
|
|
332
|
+
pageToken
|
|
333
|
+
});
|
|
334
|
+
}, [client, include, pageSize, pageToken]);
|
|
335
|
+
const query = usePlatformQuery({
|
|
336
|
+
query: handleQuery,
|
|
337
|
+
enabled,
|
|
338
|
+
queryName: "foundry-users-list"
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
users: query.data?.data,
|
|
342
|
+
nextPageToken: query.data?.nextPageToken,
|
|
343
|
+
isLoading: query.isLoading,
|
|
344
|
+
error: query.error,
|
|
345
|
+
refetch: query.refetch
|
|
346
|
+
};
|
|
347
|
+
}
|
|
75
348
|
var emptyArray = Object.freeze([]);
|
|
76
349
|
function useLinks(objects, linkName, options = {}) {
|
|
77
350
|
const {
|
|
78
351
|
observableClient
|
|
79
|
-
} =
|
|
352
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
80
353
|
const {
|
|
81
354
|
enabled = true,
|
|
82
355
|
...otherOptions
|
|
83
356
|
} = options;
|
|
84
|
-
const
|
|
85
|
-
|
|
357
|
+
const stableWhere = React9__default.default.useMemo(() => otherOptions.where, [JSON.stringify(otherOptions.where)]);
|
|
358
|
+
const stableOrderBy = React9__default.default.useMemo(() => otherOptions.orderBy, [JSON.stringify(otherOptions.orderBy)]);
|
|
359
|
+
const objectsKey = React9__default.default.useMemo(() => {
|
|
360
|
+
if (objects === void 0) return "";
|
|
361
|
+
const arr = Array.isArray(objects) ? objects : [objects];
|
|
362
|
+
return arr.map((obj) => `${obj.$apiName}:${obj.$primaryKey}`).join(",");
|
|
86
363
|
}, [objects]);
|
|
364
|
+
const objectsArray = React9__default.default.useMemo(() => {
|
|
365
|
+
return objects === void 0 ? emptyArray : Array.isArray(objects) ? objects : [objects];
|
|
366
|
+
}, [objectsKey, objects]);
|
|
87
367
|
const {
|
|
88
368
|
subscribe,
|
|
89
369
|
getSnapShot
|
|
90
|
-
} =
|
|
370
|
+
} = React9__default.default.useMemo(() => {
|
|
91
371
|
if (!enabled) {
|
|
92
372
|
return makeExternalStore(() => ({
|
|
93
373
|
unsubscribe: () => {
|
|
94
374
|
}
|
|
95
|
-
})
|
|
375
|
+
}));
|
|
96
376
|
}
|
|
97
377
|
return makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
98
378
|
linkName,
|
|
99
|
-
where:
|
|
379
|
+
where: stableWhere,
|
|
100
380
|
pageSize: otherOptions.pageSize,
|
|
101
|
-
orderBy:
|
|
381
|
+
orderBy: stableOrderBy,
|
|
102
382
|
mode: otherOptions.mode
|
|
103
|
-
}, observer)
|
|
104
|
-
}, [enabled, observableClient, objectsArray, linkName,
|
|
105
|
-
const payload =
|
|
383
|
+
}, observer));
|
|
384
|
+
}, [enabled, observableClient, objectsArray, objectsKey, linkName, stableWhere, otherOptions.pageSize, stableOrderBy, otherOptions.mode]);
|
|
385
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
106
386
|
return {
|
|
107
387
|
links: payload?.resolvedList,
|
|
108
|
-
isLoading: payload?.status === "loading",
|
|
388
|
+
isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
|
|
109
389
|
isOptimistic: payload?.isOptimistic ?? false,
|
|
110
390
|
error: payload?.error,
|
|
111
|
-
fetchMore: payload?.fetchMore,
|
|
391
|
+
fetchMore: payload?.hasMore ? payload?.fetchMore : void 0,
|
|
112
392
|
hasMore: payload?.hasMore ?? false
|
|
113
393
|
};
|
|
114
394
|
}
|
|
115
395
|
function useObjectSet(baseObjectSet, options = {}) {
|
|
116
396
|
const {
|
|
117
397
|
observableClient
|
|
118
|
-
} =
|
|
398
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
119
399
|
const {
|
|
120
400
|
enabled = true,
|
|
121
401
|
streamUpdates,
|
|
122
402
|
...otherOptions
|
|
123
403
|
} = options;
|
|
124
404
|
const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
|
|
125
|
-
const previousObjectTypeRef =
|
|
126
|
-
const previousPayloadRef =
|
|
405
|
+
const previousObjectTypeRef = React9__default.default.useRef(objectTypeKey);
|
|
406
|
+
const previousPayloadRef = React9__default.default.useRef();
|
|
127
407
|
const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
|
|
128
408
|
if (objectTypeChanged) {
|
|
129
409
|
previousObjectTypeRef.current = objectTypeKey;
|
|
@@ -141,7 +421,7 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
141
421
|
const {
|
|
142
422
|
subscribe,
|
|
143
423
|
getSnapShot
|
|
144
|
-
} =
|
|
424
|
+
} = React9__default.default.useMemo(() => {
|
|
145
425
|
if (!enabled) {
|
|
146
426
|
return makeExternalStore(() => ({
|
|
147
427
|
unsubscribe: () => {
|
|
@@ -166,8 +446,8 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
166
446
|
return subscription;
|
|
167
447
|
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
|
|
168
448
|
}, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
|
|
169
|
-
const payload =
|
|
170
|
-
|
|
449
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
450
|
+
React9__default.default.useEffect(() => {
|
|
171
451
|
if (payload) {
|
|
172
452
|
previousPayloadRef.current = payload;
|
|
173
453
|
}
|
|
@@ -176,21 +456,22 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
176
456
|
data: payload?.resolvedList,
|
|
177
457
|
isLoading: payload?.status === "loading" || !payload && true || false,
|
|
178
458
|
error: payload && "error" in payload ? payload.error : void 0,
|
|
179
|
-
fetchMore: payload?.fetchMore,
|
|
180
|
-
objectSet: payload?.objectSet || baseObjectSet
|
|
459
|
+
fetchMore: payload?.hasMore ? payload.fetchMore : void 0,
|
|
460
|
+
objectSet: payload?.objectSet || baseObjectSet,
|
|
461
|
+
totalCount: payload?.totalCount
|
|
181
462
|
};
|
|
182
463
|
}
|
|
183
464
|
function useOsdkAction(actionDef) {
|
|
184
465
|
const {
|
|
185
466
|
observableClient
|
|
186
|
-
} =
|
|
187
|
-
const [error, setError] =
|
|
188
|
-
const [data, setData] =
|
|
189
|
-
const [isPending, setPending] =
|
|
190
|
-
const [isValidating, setValidating] =
|
|
191
|
-
const [validationResult, setValidationResult] =
|
|
192
|
-
const abortControllerRef =
|
|
193
|
-
const applyAction =
|
|
467
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
468
|
+
const [error, setError] = React9__default.default.useState();
|
|
469
|
+
const [data, setData] = React9__default.default.useState();
|
|
470
|
+
const [isPending, setPending] = React9__default.default.useState(false);
|
|
471
|
+
const [isValidating, setValidating] = React9__default.default.useState(false);
|
|
472
|
+
const [validationResult, setValidationResult] = React9__default.default.useState();
|
|
473
|
+
const abortControllerRef = React9__default.default.useRef(null);
|
|
474
|
+
const applyAction = React9__default.default.useCallback(async function applyAction2(hookArgs) {
|
|
194
475
|
try {
|
|
195
476
|
if (isValidating && abortControllerRef.current) {
|
|
196
477
|
abortControllerRef.current.abort();
|
|
@@ -244,7 +525,7 @@ function useOsdkAction(actionDef) {
|
|
|
244
525
|
setPending(false);
|
|
245
526
|
}
|
|
246
527
|
}, [observableClient, actionDef, isValidating]);
|
|
247
|
-
const validateAction =
|
|
528
|
+
const validateAction = React9__default.default.useCallback(async function validateAction2(args) {
|
|
248
529
|
try {
|
|
249
530
|
if (isPending) {
|
|
250
531
|
return void 0;
|
|
@@ -280,7 +561,7 @@ function useOsdkAction(actionDef) {
|
|
|
280
561
|
setValidating(false);
|
|
281
562
|
}
|
|
282
563
|
}, [observableClient, actionDef, isPending]);
|
|
283
|
-
|
|
564
|
+
React9__default.default.useEffect(() => {
|
|
284
565
|
return () => {
|
|
285
566
|
if (abortControllerRef.current) {
|
|
286
567
|
abortControllerRef.current.abort();
|
|
@@ -305,41 +586,88 @@ function useOsdkAggregation(type, {
|
|
|
305
586
|
}) {
|
|
306
587
|
const {
|
|
307
588
|
observableClient
|
|
308
|
-
} =
|
|
589
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
309
590
|
const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
|
|
310
|
-
const stableWithProperties =
|
|
311
|
-
const stableAggregate =
|
|
591
|
+
const stableWithProperties = React9__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
592
|
+
const stableAggregate = React9__default.default.useMemo(() => aggregate, [JSON.stringify(aggregate)]);
|
|
312
593
|
const {
|
|
313
594
|
subscribe,
|
|
314
595
|
getSnapShot
|
|
315
|
-
} =
|
|
596
|
+
} = React9__default.default.useMemo(() => makeExternalStore((observer) => observableClient.observeAggregation({
|
|
316
597
|
type,
|
|
317
598
|
where: canonWhere,
|
|
318
599
|
withProperties: stableWithProperties,
|
|
319
600
|
aggregate: stableAggregate,
|
|
320
601
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
321
602
|
}, observer), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type.apiName, type.type, canonWhere, stableWithProperties, stableAggregate, dedupeIntervalMs]);
|
|
322
|
-
const payload =
|
|
603
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
323
604
|
let error;
|
|
324
605
|
if (payload && "error" in payload && payload.error) {
|
|
325
606
|
error = payload.error;
|
|
326
607
|
} else if (payload?.status === "error") {
|
|
327
608
|
error = new Error("Failed to execute aggregation");
|
|
328
609
|
}
|
|
329
|
-
const refetch =
|
|
610
|
+
const refetch = React9__default.default.useCallback(async () => {
|
|
330
611
|
await observableClient.invalidateObjectType(type.apiName);
|
|
331
612
|
}, [observableClient, type.apiName]);
|
|
613
|
+
return {
|
|
614
|
+
data: payload?.result,
|
|
615
|
+
isLoading: payload?.status === "loading" || payload?.status === "init" || !payload,
|
|
616
|
+
error,
|
|
617
|
+
refetch
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function useOsdkFunction(queryDef, options = {}) {
|
|
621
|
+
const {
|
|
622
|
+
observableClient
|
|
623
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
624
|
+
const {
|
|
625
|
+
params,
|
|
626
|
+
dependsOn,
|
|
627
|
+
dependsOnObjects,
|
|
628
|
+
dedupeIntervalMs,
|
|
629
|
+
enabled = true
|
|
630
|
+
} = options;
|
|
631
|
+
const stableParams = React9__default.default.useMemo(() => params, [JSON.stringify(params)]);
|
|
632
|
+
const stableDependsOn = React9__default.default.useMemo(() => dependsOn, [JSON.stringify(dependsOn?.map((d) => typeof d === "string" ? d : d.apiName))]);
|
|
633
|
+
const stableDependsOnObjects = React9__default.default.useMemo(() => dependsOnObjects, [JSON.stringify(dependsOnObjects?.map((o) => ({
|
|
634
|
+
$apiName: o.$apiName,
|
|
635
|
+
$primaryKey: o.$primaryKey
|
|
636
|
+
})))]);
|
|
637
|
+
const paramsForApi = stableParams;
|
|
638
|
+
const {
|
|
639
|
+
subscribe,
|
|
640
|
+
getSnapShot
|
|
641
|
+
} = React9__default.default.useMemo(() => {
|
|
642
|
+
if (!enabled) {
|
|
643
|
+
return makeExternalStore(() => ({
|
|
644
|
+
unsubscribe: () => {
|
|
645
|
+
}
|
|
646
|
+
}), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)} [DISABLED]` : void 0);
|
|
647
|
+
}
|
|
648
|
+
return makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
649
|
+
dependsOn: stableDependsOn,
|
|
650
|
+
dependsOnObjects: stableDependsOnObjects,
|
|
651
|
+
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
652
|
+
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
653
|
+
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
654
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
655
|
+
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : void 0);
|
|
656
|
+
const refetch = React9__default.default.useCallback(() => {
|
|
657
|
+
void observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
658
|
+
}, [observableClient, queryDef, paramsForApi]);
|
|
332
659
|
return {
|
|
333
660
|
data: payload?.result,
|
|
334
661
|
isLoading: payload?.status === "loading",
|
|
335
662
|
error,
|
|
663
|
+
lastUpdated: payload?.lastUpdated ?? 0,
|
|
336
664
|
refetch
|
|
337
665
|
};
|
|
338
666
|
}
|
|
339
667
|
function useOsdkObject(...args) {
|
|
340
668
|
const {
|
|
341
669
|
observableClient
|
|
342
|
-
} =
|
|
670
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
343
671
|
const isInstanceSignature = "$objectType" in args[0];
|
|
344
672
|
const enabled = isInstanceSignature ? typeof args[1] === "boolean" ? args[1] : true : typeof args[2] === "boolean" ? args[2] : true;
|
|
345
673
|
const mode = isInstanceSignature ? "offline" : void 0;
|
|
@@ -348,7 +676,7 @@ function useOsdkObject(...args) {
|
|
|
348
676
|
const {
|
|
349
677
|
subscribe,
|
|
350
678
|
getSnapShot
|
|
351
|
-
} =
|
|
679
|
+
} = React9__default.default.useMemo(() => {
|
|
352
680
|
if (!enabled) {
|
|
353
681
|
return makeExternalStore(() => ({
|
|
354
682
|
unsubscribe: () => {
|
|
@@ -359,7 +687,7 @@ function useOsdkObject(...args) {
|
|
|
359
687
|
mode
|
|
360
688
|
}, observer));
|
|
361
689
|
}, [enabled, observableClient, objectType, primaryKey, mode]);
|
|
362
|
-
const payload =
|
|
690
|
+
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
363
691
|
let error;
|
|
364
692
|
if (payload && "error" in payload && payload.error) {
|
|
365
693
|
error = payload.error;
|
|
@@ -368,7 +696,7 @@ function useOsdkObject(...args) {
|
|
|
368
696
|
}
|
|
369
697
|
return {
|
|
370
698
|
object: payload?.object,
|
|
371
|
-
isLoading: payload?.status === "loading",
|
|
699
|
+
isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
|
|
372
700
|
isOptimistic: !!payload?.isOptimistic,
|
|
373
701
|
error,
|
|
374
702
|
forceUpdate: () => {
|
|
@@ -391,15 +719,15 @@ function useOsdkObjects(type, options) {
|
|
|
391
719
|
} = options ?? {};
|
|
392
720
|
const {
|
|
393
721
|
observableClient
|
|
394
|
-
} =
|
|
722
|
+
} = React9__default.default.useContext(OsdkContext2);
|
|
395
723
|
const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
|
|
396
|
-
const stableWithProperties =
|
|
397
|
-
const stableIntersectWith =
|
|
398
|
-
const stableOrderBy =
|
|
724
|
+
const stableWithProperties = React9__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
725
|
+
const stableIntersectWith = React9__default.default.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
726
|
+
const stableOrderBy = React9__default.default.useMemo(() => orderBy, [JSON.stringify(orderBy)]);
|
|
399
727
|
const {
|
|
400
728
|
subscribe,
|
|
401
729
|
getSnapShot
|
|
402
|
-
} =
|
|
730
|
+
} = React9__default.default.useMemo(() => {
|
|
403
731
|
if (!enabled) {
|
|
404
732
|
return makeExternalStore(() => ({
|
|
405
733
|
unsubscribe: () => {
|
|
@@ -423,7 +751,7 @@ function useOsdkObjects(type, options) {
|
|
|
423
751
|
} : {}
|
|
424
752
|
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0);
|
|
425
753
|
}, [enabled, observableClient, type, canonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo]);
|
|
426
|
-
const listPayload =
|
|
754
|
+
const listPayload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
427
755
|
let error;
|
|
428
756
|
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
429
757
|
error = listPayload.error;
|
|
@@ -431,39 +759,40 @@ function useOsdkObjects(type, options) {
|
|
|
431
759
|
error = new Error("Failed to load objects");
|
|
432
760
|
}
|
|
433
761
|
return {
|
|
434
|
-
fetchMore: listPayload?.fetchMore,
|
|
762
|
+
fetchMore: listPayload?.hasMore ? listPayload.fetchMore : void 0,
|
|
435
763
|
error,
|
|
436
764
|
data: listPayload?.resolvedList,
|
|
437
|
-
isLoading: listPayload?.status === "loading",
|
|
438
|
-
isOptimistic: listPayload?.isOptimistic ?? false
|
|
765
|
+
isLoading: enabled ? listPayload?.status === "loading" || listPayload?.status === "init" || !listPayload : false,
|
|
766
|
+
isOptimistic: listPayload?.isOptimistic ?? false,
|
|
767
|
+
totalCount: listPayload?.totalCount
|
|
439
768
|
};
|
|
440
769
|
}
|
|
441
770
|
function useDebouncedCallback(callback, delay) {
|
|
442
|
-
const timeoutRef =
|
|
443
|
-
const callbackRef =
|
|
444
|
-
const lastArgsRef =
|
|
771
|
+
const timeoutRef = React9__default.default.useRef();
|
|
772
|
+
const callbackRef = React9__default.default.useRef(callback);
|
|
773
|
+
const lastArgsRef = React9__default.default.useRef();
|
|
445
774
|
callbackRef.current = callback;
|
|
446
|
-
const cancel =
|
|
775
|
+
const cancel = React9__default.default.useCallback(() => {
|
|
447
776
|
if (timeoutRef.current) {
|
|
448
777
|
clearTimeout(timeoutRef.current);
|
|
449
778
|
timeoutRef.current = void 0;
|
|
450
779
|
}
|
|
451
780
|
}, []);
|
|
452
|
-
const flush =
|
|
781
|
+
const flush = React9__default.default.useCallback(() => {
|
|
453
782
|
if (timeoutRef.current && lastArgsRef.current) {
|
|
454
783
|
clearTimeout(timeoutRef.current);
|
|
455
784
|
timeoutRef.current = void 0;
|
|
456
785
|
void callbackRef.current(...lastArgsRef.current);
|
|
457
786
|
}
|
|
458
787
|
}, []);
|
|
459
|
-
const debouncedCallback =
|
|
788
|
+
const debouncedCallback = React9__default.default.useCallback((...args) => {
|
|
460
789
|
lastArgsRef.current = args;
|
|
461
790
|
cancel();
|
|
462
791
|
timeoutRef.current = setTimeout(() => {
|
|
463
792
|
void callbackRef.current(...args);
|
|
464
793
|
}, delay);
|
|
465
794
|
}, [delay, cancel]);
|
|
466
|
-
|
|
795
|
+
React9__default.default.useEffect(() => {
|
|
467
796
|
return () => {
|
|
468
797
|
cancel();
|
|
469
798
|
};
|
|
@@ -476,18 +805,22 @@ function useDebouncedCallback(callback, delay) {
|
|
|
476
805
|
|
|
477
806
|
Object.defineProperty(exports, "useOsdkClient", {
|
|
478
807
|
enumerable: true,
|
|
479
|
-
get: function () { return
|
|
808
|
+
get: function () { return chunkV32JHU3O_cjs.useOsdkClient; }
|
|
480
809
|
});
|
|
481
810
|
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
482
811
|
enumerable: true,
|
|
483
|
-
get: function () { return
|
|
812
|
+
get: function () { return chunkV32JHU3O_cjs.useOsdkMetadata; }
|
|
484
813
|
});
|
|
485
814
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
815
|
+
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|
|
486
816
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
817
|
+
exports.useFoundryUser = useFoundryUser;
|
|
818
|
+
exports.useFoundryUsersList = useFoundryUsersList;
|
|
487
819
|
exports.useLinks = useLinks;
|
|
488
820
|
exports.useObjectSet = useObjectSet;
|
|
489
821
|
exports.useOsdkAction = useOsdkAction;
|
|
490
822
|
exports.useOsdkAggregation = useOsdkAggregation;
|
|
823
|
+
exports.useOsdkFunction = useOsdkFunction;
|
|
491
824
|
exports.useOsdkObject = useOsdkObject;
|
|
492
825
|
exports.useOsdkObjects = useOsdkObjects;
|
|
493
826
|
//# sourceMappingURL=experimental.cjs.map
|