@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.
- package/AGENTS.md +46 -221
- package/CHANGELOG.md +132 -0
- package/build/browser/new/makeExternalStore.js +61 -0
- package/build/browser/new/makeExternalStore.js.map +1 -1
- package/build/browser/new/useLinks.js +11 -4
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useObjectSet.js +42 -18
- package/build/browser/new/useObjectSet.js.map +1 -1
- package/build/browser/new/useOsdkAction.js +2 -2
- package/build/browser/new/useOsdkAction.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +65 -27
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkFunction.js +17 -12
- package/build/browser/new/useOsdkFunction.js.map +1 -1
- package/build/browser/new/useOsdkObject.js +44 -26
- package/build/browser/new/useOsdkObject.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +28 -19
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
- package/build/browser/public/experimental/admin.js.map +1 -0
- package/build/browser/public/experimental.js +0 -3
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/useOsdkMetadata.js.map +1 -1
- package/build/cjs/{chunk-V32JHU3O.cjs → chunk-OVBG5VXE.cjs} +3 -8
- package/build/cjs/chunk-OVBG5VXE.cjs.map +1 -0
- package/build/cjs/chunk-SVVMLSKN.cjs +111 -0
- package/build/cjs/chunk-SVVMLSKN.cjs.map +1 -0
- package/build/cjs/index.cjs +4 -4
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/experimental/admin.cjs +146 -0
- package/build/cjs/public/experimental/admin.cjs.map +1 -0
- package/build/cjs/public/experimental/admin.d.cts +118 -0
- package/build/cjs/public/experimental.cjs +253 -492
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +106 -138
- package/build/cjs/useOsdkMetadata-BElt3F5s.d.cts +15 -0
- package/build/esm/new/makeExternalStore.js +61 -0
- package/build/esm/new/makeExternalStore.js.map +1 -1
- package/build/esm/new/useLinks.js +11 -4
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useObjectSet.js +42 -18
- package/build/esm/new/useObjectSet.js.map +1 -1
- package/build/esm/new/useOsdkAction.js +2 -2
- package/build/esm/new/useOsdkAction.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +65 -27
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkFunction.js +17 -12
- package/build/esm/new/useOsdkFunction.js.map +1 -1
- package/build/esm/new/useOsdkObject.js +44 -26
- package/build/esm/new/useOsdkObject.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +28 -19
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/esm/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
- package/build/esm/public/experimental/admin.js.map +1 -0
- package/build/esm/public/experimental.js +0 -3
- package/build/esm/public/experimental.js.map +1 -1
- package/build/esm/useOsdkMetadata.js.map +1 -1
- package/build/types/new/makeExternalStore.d.ts +11 -0
- package/build/types/new/makeExternalStore.d.ts.map +1 -1
- package/build/types/new/useLinks.d.ts +19 -0
- package/build/types/new/useLinks.d.ts.map +1 -1
- package/build/types/new/useObjectSet.d.ts +10 -4
- package/build/types/new/useObjectSet.d.ts.map +1 -1
- package/build/types/new/useOsdkAggregation.d.ts +41 -3
- package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
- package/build/types/new/useOsdkFunction.d.ts +11 -5
- package/build/types/new/useOsdkFunction.d.ts.map +1 -1
- package/build/types/new/useOsdkObject.d.ts +18 -7
- package/build/types/new/useOsdkObject.d.ts.map +1 -1
- package/build/types/new/useOsdkObjects.d.ts +26 -2
- package/build/types/new/useOsdkObjects.d.ts.map +1 -1
- package/build/types/public/experimental/admin.d.ts +3 -0
- package/build/types/public/experimental/admin.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +0 -3
- package/build/types/public/experimental.d.ts.map +1 -1
- package/build/types/useOsdkMetadata.d.ts +5 -4
- package/build/types/useOsdkMetadata.d.ts.map +1 -1
- package/docs/querying-data.md +19 -0
- package/{build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js → experimental/admin.d.ts} +1 -18
- package/package.json +29 -8
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js +0 -34
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
- package/build/browser/intellisense.test.js +0 -148
- package/build/browser/intellisense.test.js.map +0 -1
- package/build/cjs/chunk-V32JHU3O.cjs.map +0 -1
- package/build/cjs/useOsdkMetadata-DFZhnhGZ.d.cts +0 -14
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
- package/build/esm/intellisense.test.js +0 -148
- package/build/esm/intellisense.test.js.map +0 -1
- package/build/types/intellisense.test.d.ts +0 -1
- package/build/types/intellisense.test.d.ts.map +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts.map +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts.map +0 -1
|
@@ -1,412 +1,103 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOVBG5VXE_cjs = require('../chunk-OVBG5VXE.cjs');
|
|
4
|
+
var chunkSVVMLSKN_cjs = require('../chunk-SVVMLSKN.cjs');
|
|
4
5
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
5
|
-
var
|
|
6
|
+
var React4 = require('react');
|
|
6
7
|
var client = require('@osdk/client');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
+
var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
11
12
|
|
|
12
|
-
function fakeClientFn(..._args) {
|
|
13
|
-
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
14
|
-
}
|
|
15
|
-
var fakeClient = Object.assign(fakeClientFn, {
|
|
16
|
-
fetchMetadata: fakeClientFn
|
|
17
|
-
});
|
|
18
|
-
var OsdkContext2 = /* @__PURE__ */ React9__default.default.createContext({
|
|
19
|
-
client: fakeClient,
|
|
20
|
-
observableClient: void 0
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// src/new/OsdkProvider2.tsx
|
|
24
13
|
function OsdkProvider2({
|
|
25
14
|
children,
|
|
26
15
|
client,
|
|
27
16
|
observableClient
|
|
28
17
|
}) {
|
|
29
|
-
observableClient =
|
|
30
|
-
return /* @__PURE__ */
|
|
18
|
+
observableClient = React4.useMemo(() => observableClient ?? unstableDoNotUse.createObservableClient(client), [client, observableClient]);
|
|
19
|
+
return /* @__PURE__ */ React4__default.default.createElement(chunkSVVMLSKN_cjs.OsdkContext2.Provider, {
|
|
31
20
|
value: {
|
|
32
21
|
client,
|
|
33
22
|
observableClient
|
|
34
23
|
}
|
|
35
|
-
}, /* @__PURE__ */
|
|
24
|
+
}, /* @__PURE__ */ React4__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
36
25
|
value: {
|
|
37
26
|
client
|
|
38
27
|
}
|
|
39
28
|
}, children));
|
|
40
29
|
}
|
|
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
|
-
|
|
185
|
-
// src/new/makeExternalStore.ts
|
|
186
|
-
function makeExternalStore(createObservation, _name, initialValue) {
|
|
187
|
-
let lastResult = initialValue;
|
|
188
|
-
function getSnapShot() {
|
|
189
|
-
return lastResult;
|
|
190
|
-
}
|
|
191
|
-
function subscribe(notifyUpdate) {
|
|
192
|
-
const obs = createObservation({
|
|
193
|
-
next: (payload) => {
|
|
194
|
-
lastResult = payload;
|
|
195
|
-
notifyUpdate();
|
|
196
|
-
},
|
|
197
|
-
error: (error) => {
|
|
198
|
-
lastResult = {
|
|
199
|
-
...lastResult ?? {},
|
|
200
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
201
|
-
};
|
|
202
|
-
notifyUpdate();
|
|
203
|
-
},
|
|
204
|
-
complete: () => {
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
return () => {
|
|
208
|
-
obs.unsubscribe();
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
return {
|
|
212
|
-
subscribe,
|
|
213
|
-
getSnapShot
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
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
|
-
}
|
|
348
30
|
var emptyArray = Object.freeze([]);
|
|
31
|
+
var emptyMap = /* @__PURE__ */ new Map();
|
|
349
32
|
function useLinks(objects, linkName, options = {}) {
|
|
350
33
|
const {
|
|
351
34
|
observableClient
|
|
352
|
-
} =
|
|
35
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
353
36
|
const {
|
|
354
37
|
enabled = true,
|
|
355
38
|
...otherOptions
|
|
356
39
|
} = options;
|
|
357
|
-
const stableWhere =
|
|
358
|
-
const stableOrderBy =
|
|
359
|
-
const
|
|
40
|
+
const stableWhere = React4__default.default.useMemo(() => otherOptions.where, [JSON.stringify(otherOptions.where)]);
|
|
41
|
+
const stableOrderBy = React4__default.default.useMemo(() => otherOptions.orderBy, [JSON.stringify(otherOptions.orderBy)]);
|
|
42
|
+
const stableSelect = React4__default.default.useMemo(() => otherOptions.$select, [JSON.stringify(otherOptions.$select)]);
|
|
43
|
+
const objectsKey = React4__default.default.useMemo(() => {
|
|
360
44
|
if (objects === void 0) return "";
|
|
361
45
|
const arr = Array.isArray(objects) ? objects : [objects];
|
|
362
46
|
return arr.map((obj) => `${obj.$apiName}:${obj.$primaryKey}`).join(",");
|
|
363
47
|
}, [objects]);
|
|
364
|
-
const objectsArray =
|
|
48
|
+
const objectsArray = React4__default.default.useMemo(() => {
|
|
365
49
|
return objects === void 0 ? emptyArray : Array.isArray(objects) ? objects : [objects];
|
|
366
50
|
}, [objectsKey, objects]);
|
|
367
51
|
const {
|
|
368
52
|
subscribe,
|
|
369
53
|
getSnapShot
|
|
370
|
-
} =
|
|
54
|
+
} = React4__default.default.useMemo(() => {
|
|
371
55
|
if (!enabled) {
|
|
372
|
-
return makeExternalStore(() => ({
|
|
56
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
373
57
|
unsubscribe: () => {
|
|
374
58
|
}
|
|
375
|
-
}));
|
|
59
|
+
}), `links ${linkName} for ${objectsKey} [DISABLED]`);
|
|
376
60
|
}
|
|
377
|
-
return makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
61
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
378
62
|
linkName,
|
|
379
63
|
where: stableWhere,
|
|
380
64
|
pageSize: otherOptions.pageSize,
|
|
381
65
|
orderBy: stableOrderBy,
|
|
382
|
-
mode: otherOptions.mode
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
66
|
+
mode: otherOptions.mode,
|
|
67
|
+
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3,
|
|
68
|
+
...stableSelect ? {
|
|
69
|
+
select: stableSelect
|
|
70
|
+
} : {}
|
|
71
|
+
}, observer), `links ${linkName} for ${objectsKey}`);
|
|
72
|
+
}, [enabled, observableClient, objectsArray, objectsKey, linkName, stableWhere, otherOptions.pageSize, stableOrderBy, otherOptions.mode, otherOptions.dedupeIntervalMs, stableSelect]);
|
|
73
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
74
|
+
return React4__default.default.useMemo(() => ({
|
|
387
75
|
links: payload?.resolvedList,
|
|
76
|
+
linkedObjectsBySourcePrimaryKey: payload?.linkedObjectsBySourcePrimaryKey ?? emptyMap,
|
|
388
77
|
isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
|
|
389
78
|
isOptimistic: payload?.isOptimistic ?? false,
|
|
390
79
|
error: payload?.error,
|
|
391
80
|
fetchMore: payload?.hasMore ? payload?.fetchMore : void 0,
|
|
392
81
|
hasMore: payload?.hasMore ?? false
|
|
393
|
-
};
|
|
82
|
+
}), [payload, enabled]);
|
|
394
83
|
}
|
|
84
|
+
var OBJECT_TYPE_PLACEHOLDER = "$__OBJECT__TYPE__PLACEHOLDER";
|
|
395
85
|
function useObjectSet(baseObjectSet, options = {}) {
|
|
396
86
|
const {
|
|
397
87
|
observableClient
|
|
398
|
-
} =
|
|
88
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
399
89
|
const {
|
|
400
90
|
enabled = true,
|
|
401
91
|
streamUpdates,
|
|
402
92
|
...otherOptions
|
|
403
93
|
} = options;
|
|
404
|
-
const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
|
|
405
|
-
const previousObjectTypeRef =
|
|
406
|
-
const
|
|
94
|
+
const objectTypeKey = enabled ? baseObjectSet.$objectSetInternals.def.apiName : OBJECT_TYPE_PLACEHOLDER;
|
|
95
|
+
const previousObjectTypeRef = React4__default.default.useRef(objectTypeKey);
|
|
96
|
+
const previousCompletedPayloadRef = React4__default.default.useRef();
|
|
407
97
|
const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
|
|
408
98
|
if (objectTypeChanged) {
|
|
409
99
|
previousObjectTypeRef.current = objectTypeKey;
|
|
100
|
+
previousCompletedPayloadRef.current = void 0;
|
|
410
101
|
}
|
|
411
102
|
const stableKey = unstableDoNotUse.computeObjectSetCacheKey(baseObjectSet, {
|
|
412
103
|
where: otherOptions.where,
|
|
@@ -416,20 +107,21 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
416
107
|
subtract: otherOptions.subtract,
|
|
417
108
|
pivotTo: otherOptions.pivotTo,
|
|
418
109
|
pageSize: otherOptions.pageSize,
|
|
419
|
-
orderBy: otherOptions.orderBy
|
|
110
|
+
orderBy: otherOptions.orderBy,
|
|
111
|
+
select: otherOptions.$select
|
|
420
112
|
});
|
|
421
113
|
const {
|
|
422
114
|
subscribe,
|
|
423
115
|
getSnapShot
|
|
424
|
-
} =
|
|
116
|
+
} = React4__default.default.useMemo(() => {
|
|
425
117
|
if (!enabled) {
|
|
426
|
-
return makeExternalStore(() => ({
|
|
118
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
427
119
|
unsubscribe: () => {
|
|
428
120
|
}
|
|
429
121
|
}), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
|
|
430
122
|
}
|
|
431
|
-
const initialValue = objectTypeChanged ? void 0 :
|
|
432
|
-
return makeExternalStore((observer) => {
|
|
123
|
+
const initialValue = objectTypeChanged ? void 0 : previousCompletedPayloadRef.current;
|
|
124
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => {
|
|
433
125
|
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
434
126
|
where: otherOptions.where,
|
|
435
127
|
withProperties: otherOptions.withProperties,
|
|
@@ -441,37 +133,58 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
441
133
|
orderBy: otherOptions.orderBy,
|
|
442
134
|
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3,
|
|
443
135
|
autoFetchMore: otherOptions.autoFetchMore,
|
|
444
|
-
streamUpdates
|
|
136
|
+
streamUpdates,
|
|
137
|
+
select: otherOptions.$select
|
|
445
138
|
}, observer);
|
|
446
139
|
return subscription;
|
|
447
140
|
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
|
|
448
141
|
}, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
|
|
449
|
-
const payload =
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
142
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
143
|
+
if (payload && isPayloadCompleted(payload)) {
|
|
144
|
+
previousCompletedPayloadRef.current = payload;
|
|
145
|
+
}
|
|
146
|
+
return React4__default.default.useMemo(() => {
|
|
147
|
+
const lastLoaded = isPayloadCompleted(payload) ? payload : previousCompletedPayloadRef.current;
|
|
148
|
+
return {
|
|
149
|
+
data: lastLoaded?.resolvedList,
|
|
150
|
+
isLoading: !isPayloadCompleted(payload),
|
|
151
|
+
error: lastLoaded && "error" in lastLoaded ? lastLoaded.error : void 0,
|
|
152
|
+
fetchMore: payload?.hasMore ? payload.fetchMore : void 0,
|
|
153
|
+
objectSet: payload?.objectSet || baseObjectSet,
|
|
154
|
+
totalCount: lastLoaded?.totalCount
|
|
155
|
+
};
|
|
156
|
+
}, [payload, baseObjectSet]);
|
|
157
|
+
}
|
|
158
|
+
function isPayloadCompleted(payload) {
|
|
159
|
+
if (payload != null && "error" in payload) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (payload?.status == null) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
switch (payload.status) {
|
|
166
|
+
case "loaded":
|
|
167
|
+
case "error":
|
|
168
|
+
return true;
|
|
169
|
+
case "loading":
|
|
170
|
+
case "init":
|
|
171
|
+
return false;
|
|
172
|
+
default:
|
|
173
|
+
payload.status;
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
463
176
|
}
|
|
464
177
|
function useOsdkAction(actionDef) {
|
|
465
178
|
const {
|
|
466
179
|
observableClient
|
|
467
|
-
} =
|
|
468
|
-
const [error, setError] =
|
|
469
|
-
const [data, setData] =
|
|
470
|
-
const [isPending, setPending] =
|
|
471
|
-
const [isValidating, setValidating] =
|
|
472
|
-
const [validationResult, setValidationResult] =
|
|
473
|
-
const abortControllerRef =
|
|
474
|
-
const applyAction =
|
|
180
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
181
|
+
const [error, setError] = React4__default.default.useState();
|
|
182
|
+
const [data, setData] = React4__default.default.useState();
|
|
183
|
+
const [isPending, setPending] = React4__default.default.useState(false);
|
|
184
|
+
const [isValidating, setValidating] = React4__default.default.useState(false);
|
|
185
|
+
const [validationResult, setValidationResult] = React4__default.default.useState();
|
|
186
|
+
const abortControllerRef = React4__default.default.useRef(null);
|
|
187
|
+
const applyAction = React4__default.default.useCallback(async function applyAction2(hookArgs) {
|
|
475
188
|
try {
|
|
476
189
|
if (isValidating && abortControllerRef.current) {
|
|
477
190
|
abortControllerRef.current.abort();
|
|
@@ -525,7 +238,7 @@ function useOsdkAction(actionDef) {
|
|
|
525
238
|
setPending(false);
|
|
526
239
|
}
|
|
527
240
|
}, [observableClient, actionDef, isValidating]);
|
|
528
|
-
const validateAction =
|
|
241
|
+
const validateAction = React4__default.default.useCallback(async function validateAction2(args) {
|
|
529
242
|
try {
|
|
530
243
|
if (isPending) {
|
|
531
244
|
return void 0;
|
|
@@ -561,14 +274,14 @@ function useOsdkAction(actionDef) {
|
|
|
561
274
|
setValidating(false);
|
|
562
275
|
}
|
|
563
276
|
}, [observableClient, actionDef, isPending]);
|
|
564
|
-
|
|
277
|
+
React4__default.default.useEffect(() => {
|
|
565
278
|
return () => {
|
|
566
279
|
if (abortControllerRef.current) {
|
|
567
280
|
abortControllerRef.current.abort();
|
|
568
281
|
}
|
|
569
282
|
};
|
|
570
283
|
}, []);
|
|
571
|
-
return {
|
|
284
|
+
return React4__default.default.useMemo(() => ({
|
|
572
285
|
applyAction,
|
|
573
286
|
validateAction,
|
|
574
287
|
error,
|
|
@@ -576,51 +289,79 @@ function useOsdkAction(actionDef) {
|
|
|
576
289
|
isPending,
|
|
577
290
|
isValidating,
|
|
578
291
|
validationResult
|
|
579
|
-
};
|
|
292
|
+
}), [applyAction, validateAction, error, data, isPending, isValidating, validationResult]);
|
|
580
293
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
294
|
+
var EMPTY_WHERE = {};
|
|
295
|
+
function useOsdkAggregation(type, options) {
|
|
296
|
+
const {
|
|
297
|
+
where = EMPTY_WHERE,
|
|
298
|
+
withProperties,
|
|
299
|
+
intersectWith,
|
|
300
|
+
aggregate,
|
|
301
|
+
dedupeIntervalMs
|
|
302
|
+
} = options;
|
|
303
|
+
const objectSet = "objectSet" in options ? options.objectSet : void 0;
|
|
587
304
|
const {
|
|
588
305
|
observableClient
|
|
589
|
-
} =
|
|
590
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where
|
|
591
|
-
const
|
|
592
|
-
const
|
|
306
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
307
|
+
const canonWhere = observableClient.canonicalizeWhereClause(where);
|
|
308
|
+
const stableCanonWhere = React4__default.default.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
309
|
+
const objectSetRef = React4__default.default.useRef(objectSet);
|
|
310
|
+
objectSetRef.current = objectSet;
|
|
311
|
+
const objectSetKeyString = objectSet ? unstableDoNotUse.computeObjectSetCacheKey(objectSet) : void 0;
|
|
312
|
+
const stableWithProperties = React4__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
313
|
+
const stableAggregate = React4__default.default.useMemo(() => aggregate, [JSON.stringify(aggregate)]);
|
|
314
|
+
const stableIntersectWith = React4__default.default.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
593
315
|
const {
|
|
594
316
|
subscribe,
|
|
595
317
|
getSnapShot
|
|
596
|
-
} =
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
318
|
+
} = React4__default.default.useMemo(() => {
|
|
319
|
+
if (objectSetKeyString && objectSetRef.current) {
|
|
320
|
+
return chunkSVVMLSKN_cjs.makeExternalStoreAsync((observer) => observableClient.observeAggregation({
|
|
321
|
+
type,
|
|
322
|
+
objectSet: objectSetRef.current,
|
|
323
|
+
where: stableCanonWhere,
|
|
324
|
+
withProperties: stableWithProperties,
|
|
325
|
+
intersectWith: stableIntersectWith,
|
|
326
|
+
aggregate: stableAggregate,
|
|
327
|
+
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
328
|
+
}, observer), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${objectSetKeyString} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
329
|
+
}
|
|
330
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => (
|
|
331
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
332
|
+
observableClient.observeAggregation({
|
|
333
|
+
type,
|
|
334
|
+
where: stableCanonWhere,
|
|
335
|
+
withProperties: stableWithProperties,
|
|
336
|
+
intersectWith: stableIntersectWith,
|
|
337
|
+
aggregate: stableAggregate,
|
|
338
|
+
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
339
|
+
}, observer)
|
|
340
|
+
), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
341
|
+
}, [observableClient, type.apiName, type.type, objectSetKeyString, stableCanonWhere, stableWithProperties, stableIntersectWith, stableAggregate, dedupeIntervalMs]);
|
|
342
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
343
|
+
const refetch = React4__default.default.useCallback(async () => {
|
|
611
344
|
await observableClient.invalidateObjectType(type.apiName);
|
|
612
345
|
}, [observableClient, type.apiName]);
|
|
613
|
-
return {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
346
|
+
return React4__default.default.useMemo(() => {
|
|
347
|
+
let error;
|
|
348
|
+
if (payload && "error" in payload && payload.error) {
|
|
349
|
+
error = payload.error;
|
|
350
|
+
} else if (payload?.status === "error") {
|
|
351
|
+
error = new Error("Failed to execute aggregation");
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
data: payload?.result,
|
|
355
|
+
isLoading: payload?.status === "loading" || payload?.status === "init" || !payload,
|
|
356
|
+
error,
|
|
357
|
+
refetch
|
|
358
|
+
};
|
|
359
|
+
}, [payload, refetch]);
|
|
619
360
|
}
|
|
620
361
|
function useOsdkFunction(queryDef, options = {}) {
|
|
621
362
|
const {
|
|
622
363
|
observableClient
|
|
623
|
-
} =
|
|
364
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
624
365
|
const {
|
|
625
366
|
params,
|
|
626
367
|
dependsOn,
|
|
@@ -628,86 +369,101 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
628
369
|
dedupeIntervalMs,
|
|
629
370
|
enabled = true
|
|
630
371
|
} = options;
|
|
631
|
-
const stableParams =
|
|
632
|
-
const stableDependsOn =
|
|
633
|
-
const stableDependsOnObjects =
|
|
634
|
-
$apiName:
|
|
635
|
-
$primaryKey:
|
|
636
|
-
}
|
|
372
|
+
const stableParams = React4__default.default.useMemo(() => params, [JSON.stringify(params)]);
|
|
373
|
+
const stableDependsOn = React4__default.default.useMemo(() => dependsOn, [JSON.stringify(dependsOn?.map((d) => typeof d === "string" ? d : d.apiName))]);
|
|
374
|
+
const stableDependsOnObjects = React4__default.default.useMemo(() => dependsOnObjects, [JSON.stringify(dependsOnObjects?.map((item) => "$apiName" in item ? {
|
|
375
|
+
$apiName: item.$apiName,
|
|
376
|
+
$primaryKey: item.$primaryKey
|
|
377
|
+
} : {
|
|
378
|
+
__objectSet: unstableDoNotUse.getWireObjectSet(item)
|
|
379
|
+
}))]);
|
|
637
380
|
const paramsForApi = stableParams;
|
|
638
381
|
const {
|
|
639
382
|
subscribe,
|
|
640
383
|
getSnapShot
|
|
641
|
-
} =
|
|
384
|
+
} = React4__default.default.useMemo(() => {
|
|
642
385
|
if (!enabled) {
|
|
643
|
-
return makeExternalStore(() => ({
|
|
386
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
644
387
|
unsubscribe: () => {
|
|
645
388
|
}
|
|
646
389
|
}), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)} [DISABLED]` : void 0);
|
|
647
390
|
}
|
|
648
|
-
return makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
391
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
649
392
|
dependsOn: stableDependsOn,
|
|
650
393
|
dependsOnObjects: stableDependsOnObjects,
|
|
651
394
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
652
395
|
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
653
396
|
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
654
|
-
const payload =
|
|
655
|
-
const
|
|
656
|
-
const refetch = React9__default.default.useCallback(() => {
|
|
397
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
398
|
+
const refetch = React4__default.default.useCallback(() => {
|
|
657
399
|
void observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
658
400
|
}, [observableClient, queryDef, paramsForApi]);
|
|
659
|
-
return {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
401
|
+
return React4__default.default.useMemo(() => {
|
|
402
|
+
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : void 0);
|
|
403
|
+
return {
|
|
404
|
+
data: payload?.result,
|
|
405
|
+
isLoading: payload?.status === "loading",
|
|
406
|
+
error,
|
|
407
|
+
lastUpdated: payload?.lastUpdated ?? 0,
|
|
408
|
+
refetch
|
|
409
|
+
};
|
|
410
|
+
}, [payload, refetch]);
|
|
666
411
|
}
|
|
667
412
|
function useOsdkObject(...args) {
|
|
668
413
|
const {
|
|
669
414
|
observableClient
|
|
670
|
-
} =
|
|
415
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
671
416
|
const isInstanceSignature = "$objectType" in args[0];
|
|
672
|
-
const
|
|
417
|
+
const optionsArg = !isInstanceSignature && args[2] != null && typeof args[2] === "object" ? args[2] : void 0;
|
|
418
|
+
const enabled = isInstanceSignature ? typeof args[1] === "boolean" ? args[1] : true : optionsArg ? optionsArg.enabled ?? true : typeof args[2] === "boolean" ? args[2] : true;
|
|
419
|
+
const selectArg = optionsArg?.$select;
|
|
673
420
|
const mode = isInstanceSignature ? "offline" : void 0;
|
|
674
|
-
const
|
|
421
|
+
const typeOrApiName = isInstanceSignature ? args[0].$objectType : args[0];
|
|
675
422
|
const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];
|
|
423
|
+
const apiNameString = typeof typeOrApiName === "string" ? typeOrApiName : typeOrApiName.apiName;
|
|
424
|
+
const stableSelect = React4__default.default.useMemo(() => selectArg, [JSON.stringify(selectArg)]);
|
|
676
425
|
const {
|
|
677
426
|
subscribe,
|
|
678
427
|
getSnapShot
|
|
679
|
-
} =
|
|
428
|
+
} = React4__default.default.useMemo(() => {
|
|
680
429
|
if (!enabled) {
|
|
681
|
-
return makeExternalStore(() => ({
|
|
430
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
682
431
|
unsubscribe: () => {
|
|
683
432
|
}
|
|
684
|
-
}));
|
|
433
|
+
}), `object ${apiNameString} ${primaryKey} [DISABLED]`);
|
|
685
434
|
}
|
|
686
|
-
return makeExternalStore((observer) => observableClient.observeObject(
|
|
687
|
-
mode
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
error
|
|
702
|
-
|
|
703
|
-
throw new Error("not implemented");
|
|
435
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeObject(typeOrApiName, primaryKey, {
|
|
436
|
+
mode,
|
|
437
|
+
...stableSelect ? {
|
|
438
|
+
select: stableSelect
|
|
439
|
+
} : {}
|
|
440
|
+
}, observer), `object ${apiNameString} ${primaryKey}`);
|
|
441
|
+
}, [enabled, observableClient, typeOrApiName, apiNameString, primaryKey, mode, stableSelect]);
|
|
442
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
443
|
+
const forceUpdate = React4__default.default.useCallback(() => {
|
|
444
|
+
throw new Error("not implemented");
|
|
445
|
+
}, []);
|
|
446
|
+
return React4__default.default.useMemo(() => {
|
|
447
|
+
let error;
|
|
448
|
+
if (payload && "error" in payload && payload.error) {
|
|
449
|
+
error = payload.error;
|
|
450
|
+
} else if (payload?.status === "error") {
|
|
451
|
+
error = new Error("Failed to load object");
|
|
704
452
|
}
|
|
705
|
-
|
|
453
|
+
return {
|
|
454
|
+
object: payload?.object,
|
|
455
|
+
isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
|
|
456
|
+
isOptimistic: !!payload?.isOptimistic,
|
|
457
|
+
error,
|
|
458
|
+
forceUpdate
|
|
459
|
+
};
|
|
460
|
+
}, [payload, enabled, forceUpdate]);
|
|
706
461
|
}
|
|
462
|
+
var EMPTY_WHERE2 = {};
|
|
707
463
|
function useOsdkObjects(type, options) {
|
|
708
464
|
const {
|
|
709
465
|
observableClient
|
|
710
|
-
} =
|
|
466
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
711
467
|
const {
|
|
712
468
|
pageSize,
|
|
713
469
|
dedupeIntervalMs,
|
|
@@ -719,27 +475,30 @@ function useOsdkObjects(type, options) {
|
|
|
719
475
|
streamUpdates,
|
|
720
476
|
autoFetchMore,
|
|
721
477
|
intersectWith,
|
|
722
|
-
pivotTo
|
|
478
|
+
pivotTo,
|
|
479
|
+
$select
|
|
723
480
|
} = options ?? {};
|
|
724
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where ??
|
|
725
|
-
const
|
|
726
|
-
const
|
|
727
|
-
const
|
|
728
|
-
const
|
|
481
|
+
const canonWhere = observableClient.canonicalizeWhereClause(where ?? EMPTY_WHERE2);
|
|
482
|
+
const stableCanonWhere = React4__default.default.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
483
|
+
const stableRids = React4__default.default.useMemo(() => rids, [JSON.stringify(rids)]);
|
|
484
|
+
const stableWithProperties = React4__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
485
|
+
const stableIntersectWith = React4__default.default.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
486
|
+
const stableOrderBy = React4__default.default.useMemo(() => orderBy, [JSON.stringify(orderBy)]);
|
|
487
|
+
const stableSelect = React4__default.default.useMemo(() => $select, [JSON.stringify($select)]);
|
|
729
488
|
const {
|
|
730
489
|
subscribe,
|
|
731
490
|
getSnapShot
|
|
732
|
-
} =
|
|
491
|
+
} = React4__default.default.useMemo(() => {
|
|
733
492
|
if (!enabled) {
|
|
734
|
-
return makeExternalStore(() => ({
|
|
493
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
735
494
|
unsubscribe: () => {
|
|
736
495
|
}
|
|
737
496
|
}), process.env.NODE_ENV !== "production" ? `list ${type.apiName} [DISABLED]` : void 0);
|
|
738
497
|
}
|
|
739
|
-
return makeExternalStore((observer) => observableClient.observeList({
|
|
498
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeList({
|
|
740
499
|
type,
|
|
741
500
|
rids: stableRids,
|
|
742
|
-
where:
|
|
501
|
+
where: stableCanonWhere,
|
|
743
502
|
dedupeInterval: dedupeIntervalMs ?? 2e3,
|
|
744
503
|
pageSize,
|
|
745
504
|
orderBy: stableOrderBy,
|
|
@@ -751,51 +510,56 @@ function useOsdkObjects(type, options) {
|
|
|
751
510
|
} : {},
|
|
752
511
|
...pivotTo ? {
|
|
753
512
|
pivotTo
|
|
513
|
+
} : {},
|
|
514
|
+
...stableSelect ? {
|
|
515
|
+
select: stableSelect
|
|
754
516
|
} : {}
|
|
755
|
-
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(
|
|
756
|
-
}, [enabled, observableClient, type, stableRids,
|
|
757
|
-
const listPayload =
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
error
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
517
|
+
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
518
|
+
}, [enabled, observableClient, type.apiName, type.type, stableRids, stableCanonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo, stableSelect]);
|
|
519
|
+
const listPayload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
520
|
+
return React4__default.default.useMemo(() => {
|
|
521
|
+
let error;
|
|
522
|
+
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
523
|
+
error = listPayload.error;
|
|
524
|
+
} else if (listPayload?.status === "error") {
|
|
525
|
+
error = new Error("Failed to load objects");
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
fetchMore: listPayload?.hasMore ? listPayload.fetchMore : void 0,
|
|
529
|
+
error,
|
|
530
|
+
data: listPayload?.resolvedList,
|
|
531
|
+
isLoading: enabled ? listPayload?.status === "loading" || listPayload?.status === "init" || !listPayload : false,
|
|
532
|
+
isOptimistic: listPayload?.isOptimistic ?? false,
|
|
533
|
+
totalCount: listPayload?.totalCount
|
|
534
|
+
};
|
|
535
|
+
}, [listPayload, enabled]);
|
|
772
536
|
}
|
|
773
537
|
function useDebouncedCallback(callback, delay) {
|
|
774
|
-
const timeoutRef =
|
|
775
|
-
const callbackRef =
|
|
776
|
-
const lastArgsRef =
|
|
538
|
+
const timeoutRef = React4__default.default.useRef();
|
|
539
|
+
const callbackRef = React4__default.default.useRef(callback);
|
|
540
|
+
const lastArgsRef = React4__default.default.useRef();
|
|
777
541
|
callbackRef.current = callback;
|
|
778
|
-
const cancel =
|
|
542
|
+
const cancel = React4__default.default.useCallback(() => {
|
|
779
543
|
if (timeoutRef.current) {
|
|
780
544
|
clearTimeout(timeoutRef.current);
|
|
781
545
|
timeoutRef.current = void 0;
|
|
782
546
|
}
|
|
783
547
|
}, []);
|
|
784
|
-
const flush =
|
|
548
|
+
const flush = React4__default.default.useCallback(() => {
|
|
785
549
|
if (timeoutRef.current && lastArgsRef.current) {
|
|
786
550
|
clearTimeout(timeoutRef.current);
|
|
787
551
|
timeoutRef.current = void 0;
|
|
788
552
|
void callbackRef.current(...lastArgsRef.current);
|
|
789
553
|
}
|
|
790
554
|
}, []);
|
|
791
|
-
const debouncedCallback =
|
|
555
|
+
const debouncedCallback = React4__default.default.useCallback((...args) => {
|
|
792
556
|
lastArgsRef.current = args;
|
|
793
557
|
cancel();
|
|
794
558
|
timeoutRef.current = setTimeout(() => {
|
|
795
559
|
void callbackRef.current(...args);
|
|
796
560
|
}, delay);
|
|
797
561
|
}, [delay, cancel]);
|
|
798
|
-
|
|
562
|
+
React4__default.default.useEffect(() => {
|
|
799
563
|
return () => {
|
|
800
564
|
cancel();
|
|
801
565
|
};
|
|
@@ -808,17 +572,14 @@ function useDebouncedCallback(callback, delay) {
|
|
|
808
572
|
|
|
809
573
|
Object.defineProperty(exports, "useOsdkClient", {
|
|
810
574
|
enumerable: true,
|
|
811
|
-
get: function () { return
|
|
575
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
812
576
|
});
|
|
813
577
|
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
814
578
|
enumerable: true,
|
|
815
|
-
get: function () { return
|
|
579
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
816
580
|
});
|
|
817
581
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
818
|
-
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|
|
819
582
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
820
|
-
exports.useFoundryUser = useFoundryUser;
|
|
821
|
-
exports.useFoundryUsersList = useFoundryUsersList;
|
|
822
583
|
exports.useLinks = useLinks;
|
|
823
584
|
exports.useObjectSet = useObjectSet;
|
|
824
585
|
exports.useOsdkAction = useOsdkAction;
|