@osdk/react 0.9.3 → 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 +109 -51
- 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 +6 -3
- 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 +36 -17
- 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 +217 -478
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +88 -127
- 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 +6 -3
- 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 +36 -17
- 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 +6 -0
- 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 +12 -1
- package/build/types/new/useOsdkObject.d.ts.map +1 -1
- package/build/types/new/useOsdkObjects.d.ts +10 -0
- 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.helpers/useOsdkObjectsWithRids.js +0 -37
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithRids.js.map +0 -1
- package/build/browser/intellisense.test.js +0 -172
- 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.helpers/useOsdkObjectsWithRids.js +0 -37
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithRids.js.map +0 -1
- package/build/esm/intellisense.test.js +0 -172
- 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
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithRids.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithRids.d.ts.map +0 -1
|
@@ -1,409 +1,99 @@
|
|
|
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.5.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.44.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 previousCompletedPayloadRef =
|
|
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;
|
|
@@ -417,20 +107,21 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
417
107
|
subtract: otherOptions.subtract,
|
|
418
108
|
pivotTo: otherOptions.pivotTo,
|
|
419
109
|
pageSize: otherOptions.pageSize,
|
|
420
|
-
orderBy: otherOptions.orderBy
|
|
110
|
+
orderBy: otherOptions.orderBy,
|
|
111
|
+
select: otherOptions.$select
|
|
421
112
|
});
|
|
422
113
|
const {
|
|
423
114
|
subscribe,
|
|
424
115
|
getSnapShot
|
|
425
|
-
} =
|
|
116
|
+
} = React4__default.default.useMemo(() => {
|
|
426
117
|
if (!enabled) {
|
|
427
|
-
return makeExternalStore(() => ({
|
|
118
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
428
119
|
unsubscribe: () => {
|
|
429
120
|
}
|
|
430
121
|
}), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
|
|
431
122
|
}
|
|
432
123
|
const initialValue = objectTypeChanged ? void 0 : previousCompletedPayloadRef.current;
|
|
433
|
-
return makeExternalStore((observer) => {
|
|
124
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => {
|
|
434
125
|
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
435
126
|
where: otherOptions.where,
|
|
436
127
|
withProperties: otherOptions.withProperties,
|
|
@@ -442,16 +133,17 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
442
133
|
orderBy: otherOptions.orderBy,
|
|
443
134
|
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3,
|
|
444
135
|
autoFetchMore: otherOptions.autoFetchMore,
|
|
445
|
-
streamUpdates
|
|
136
|
+
streamUpdates,
|
|
137
|
+
select: otherOptions.$select
|
|
446
138
|
}, observer);
|
|
447
139
|
return subscription;
|
|
448
140
|
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
|
|
449
141
|
}, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
|
|
450
|
-
const payload =
|
|
142
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
451
143
|
if (payload && isPayloadCompleted(payload)) {
|
|
452
144
|
previousCompletedPayloadRef.current = payload;
|
|
453
145
|
}
|
|
454
|
-
return
|
|
146
|
+
return React4__default.default.useMemo(() => {
|
|
455
147
|
const lastLoaded = isPayloadCompleted(payload) ? payload : previousCompletedPayloadRef.current;
|
|
456
148
|
return {
|
|
457
149
|
data: lastLoaded?.resolvedList,
|
|
@@ -485,14 +177,14 @@ function isPayloadCompleted(payload) {
|
|
|
485
177
|
function useOsdkAction(actionDef) {
|
|
486
178
|
const {
|
|
487
179
|
observableClient
|
|
488
|
-
} =
|
|
489
|
-
const [error, setError] =
|
|
490
|
-
const [data, setData] =
|
|
491
|
-
const [isPending, setPending] =
|
|
492
|
-
const [isValidating, setValidating] =
|
|
493
|
-
const [validationResult, setValidationResult] =
|
|
494
|
-
const abortControllerRef =
|
|
495
|
-
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) {
|
|
496
188
|
try {
|
|
497
189
|
if (isValidating && abortControllerRef.current) {
|
|
498
190
|
abortControllerRef.current.abort();
|
|
@@ -546,7 +238,7 @@ function useOsdkAction(actionDef) {
|
|
|
546
238
|
setPending(false);
|
|
547
239
|
}
|
|
548
240
|
}, [observableClient, actionDef, isValidating]);
|
|
549
|
-
const validateAction =
|
|
241
|
+
const validateAction = React4__default.default.useCallback(async function validateAction2(args) {
|
|
550
242
|
try {
|
|
551
243
|
if (isPending) {
|
|
552
244
|
return void 0;
|
|
@@ -582,14 +274,14 @@ function useOsdkAction(actionDef) {
|
|
|
582
274
|
setValidating(false);
|
|
583
275
|
}
|
|
584
276
|
}, [observableClient, actionDef, isPending]);
|
|
585
|
-
|
|
277
|
+
React4__default.default.useEffect(() => {
|
|
586
278
|
return () => {
|
|
587
279
|
if (abortControllerRef.current) {
|
|
588
280
|
abortControllerRef.current.abort();
|
|
589
281
|
}
|
|
590
282
|
};
|
|
591
283
|
}, []);
|
|
592
|
-
return {
|
|
284
|
+
return React4__default.default.useMemo(() => ({
|
|
593
285
|
applyAction,
|
|
594
286
|
validateAction,
|
|
595
287
|
error,
|
|
@@ -597,51 +289,79 @@ function useOsdkAction(actionDef) {
|
|
|
597
289
|
isPending,
|
|
598
290
|
isValidating,
|
|
599
291
|
validationResult
|
|
600
|
-
};
|
|
292
|
+
}), [applyAction, validateAction, error, data, isPending, isValidating, validationResult]);
|
|
601
293
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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;
|
|
608
304
|
const {
|
|
609
305
|
observableClient
|
|
610
|
-
} =
|
|
611
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where
|
|
612
|
-
const
|
|
613
|
-
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)]);
|
|
614
315
|
const {
|
|
615
316
|
subscribe,
|
|
616
317
|
getSnapShot
|
|
617
|
-
} =
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
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 () => {
|
|
632
344
|
await observableClient.invalidateObjectType(type.apiName);
|
|
633
345
|
}, [observableClient, type.apiName]);
|
|
634
|
-
return {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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]);
|
|
640
360
|
}
|
|
641
361
|
function useOsdkFunction(queryDef, options = {}) {
|
|
642
362
|
const {
|
|
643
363
|
observableClient
|
|
644
|
-
} =
|
|
364
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
645
365
|
const {
|
|
646
366
|
params,
|
|
647
367
|
dependsOn,
|
|
@@ -649,87 +369,101 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
649
369
|
dedupeIntervalMs,
|
|
650
370
|
enabled = true
|
|
651
371
|
} = options;
|
|
652
|
-
const stableParams =
|
|
653
|
-
const stableDependsOn =
|
|
654
|
-
const stableDependsOnObjects =
|
|
655
|
-
$apiName:
|
|
656
|
-
$primaryKey:
|
|
657
|
-
}
|
|
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
|
+
}))]);
|
|
658
380
|
const paramsForApi = stableParams;
|
|
659
381
|
const {
|
|
660
382
|
subscribe,
|
|
661
383
|
getSnapShot
|
|
662
|
-
} =
|
|
384
|
+
} = React4__default.default.useMemo(() => {
|
|
663
385
|
if (!enabled) {
|
|
664
|
-
return makeExternalStore(() => ({
|
|
386
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
665
387
|
unsubscribe: () => {
|
|
666
388
|
}
|
|
667
389
|
}), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)} [DISABLED]` : void 0);
|
|
668
390
|
}
|
|
669
|
-
return makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
391
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
670
392
|
dependsOn: stableDependsOn,
|
|
671
393
|
dependsOnObjects: stableDependsOnObjects,
|
|
672
394
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
673
395
|
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
674
396
|
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
675
|
-
const payload =
|
|
676
|
-
const
|
|
677
|
-
const refetch = React9__default.default.useCallback(() => {
|
|
397
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
398
|
+
const refetch = React4__default.default.useCallback(() => {
|
|
678
399
|
void observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
679
400
|
}, [observableClient, queryDef, paramsForApi]);
|
|
680
|
-
return {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
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]);
|
|
687
411
|
}
|
|
688
412
|
function useOsdkObject(...args) {
|
|
689
413
|
const {
|
|
690
414
|
observableClient
|
|
691
|
-
} =
|
|
415
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
692
416
|
const isInstanceSignature = "$objectType" in args[0];
|
|
693
|
-
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;
|
|
694
420
|
const mode = isInstanceSignature ? "offline" : void 0;
|
|
695
421
|
const typeOrApiName = isInstanceSignature ? args[0].$objectType : args[0];
|
|
696
422
|
const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];
|
|
697
423
|
const apiNameString = typeof typeOrApiName === "string" ? typeOrApiName : typeOrApiName.apiName;
|
|
424
|
+
const stableSelect = React4__default.default.useMemo(() => selectArg, [JSON.stringify(selectArg)]);
|
|
698
425
|
const {
|
|
699
426
|
subscribe,
|
|
700
427
|
getSnapShot
|
|
701
|
-
} =
|
|
428
|
+
} = React4__default.default.useMemo(() => {
|
|
702
429
|
if (!enabled) {
|
|
703
|
-
return makeExternalStore(() => ({
|
|
430
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
704
431
|
unsubscribe: () => {
|
|
705
432
|
}
|
|
706
|
-
}));
|
|
433
|
+
}), `object ${apiNameString} ${primaryKey} [DISABLED]`);
|
|
707
434
|
}
|
|
708
|
-
return makeExternalStore((observer) => observableClient.observeObject(typeOrApiName, primaryKey, {
|
|
709
|
-
mode
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
return {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
error
|
|
724
|
-
|
|
725
|
-
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");
|
|
726
452
|
}
|
|
727
|
-
|
|
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]);
|
|
728
461
|
}
|
|
462
|
+
var EMPTY_WHERE2 = {};
|
|
729
463
|
function useOsdkObjects(type, options) {
|
|
730
464
|
const {
|
|
731
465
|
observableClient
|
|
732
|
-
} =
|
|
466
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
733
467
|
const {
|
|
734
468
|
pageSize,
|
|
735
469
|
dedupeIntervalMs,
|
|
@@ -741,27 +475,30 @@ function useOsdkObjects(type, options) {
|
|
|
741
475
|
streamUpdates,
|
|
742
476
|
autoFetchMore,
|
|
743
477
|
intersectWith,
|
|
744
|
-
pivotTo
|
|
478
|
+
pivotTo,
|
|
479
|
+
$select
|
|
745
480
|
} = options ?? {};
|
|
746
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where ??
|
|
747
|
-
const
|
|
748
|
-
const
|
|
749
|
-
const
|
|
750
|
-
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)]);
|
|
751
488
|
const {
|
|
752
489
|
subscribe,
|
|
753
490
|
getSnapShot
|
|
754
|
-
} =
|
|
491
|
+
} = React4__default.default.useMemo(() => {
|
|
755
492
|
if (!enabled) {
|
|
756
|
-
return makeExternalStore(() => ({
|
|
493
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
757
494
|
unsubscribe: () => {
|
|
758
495
|
}
|
|
759
496
|
}), process.env.NODE_ENV !== "production" ? `list ${type.apiName} [DISABLED]` : void 0);
|
|
760
497
|
}
|
|
761
|
-
return makeExternalStore((observer) => observableClient.observeList({
|
|
498
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeList({
|
|
762
499
|
type,
|
|
763
500
|
rids: stableRids,
|
|
764
|
-
where:
|
|
501
|
+
where: stableCanonWhere,
|
|
765
502
|
dedupeInterval: dedupeIntervalMs ?? 2e3,
|
|
766
503
|
pageSize,
|
|
767
504
|
orderBy: stableOrderBy,
|
|
@@ -773,51 +510,56 @@ function useOsdkObjects(type, options) {
|
|
|
773
510
|
} : {},
|
|
774
511
|
...pivotTo ? {
|
|
775
512
|
pivotTo
|
|
513
|
+
} : {},
|
|
514
|
+
...stableSelect ? {
|
|
515
|
+
select: stableSelect
|
|
776
516
|
} : {}
|
|
777
|
-
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(
|
|
778
|
-
}, [enabled, observableClient, type, stableRids,
|
|
779
|
-
const listPayload =
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
error
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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]);
|
|
794
536
|
}
|
|
795
537
|
function useDebouncedCallback(callback, delay) {
|
|
796
|
-
const timeoutRef =
|
|
797
|
-
const callbackRef =
|
|
798
|
-
const lastArgsRef =
|
|
538
|
+
const timeoutRef = React4__default.default.useRef();
|
|
539
|
+
const callbackRef = React4__default.default.useRef(callback);
|
|
540
|
+
const lastArgsRef = React4__default.default.useRef();
|
|
799
541
|
callbackRef.current = callback;
|
|
800
|
-
const cancel =
|
|
542
|
+
const cancel = React4__default.default.useCallback(() => {
|
|
801
543
|
if (timeoutRef.current) {
|
|
802
544
|
clearTimeout(timeoutRef.current);
|
|
803
545
|
timeoutRef.current = void 0;
|
|
804
546
|
}
|
|
805
547
|
}, []);
|
|
806
|
-
const flush =
|
|
548
|
+
const flush = React4__default.default.useCallback(() => {
|
|
807
549
|
if (timeoutRef.current && lastArgsRef.current) {
|
|
808
550
|
clearTimeout(timeoutRef.current);
|
|
809
551
|
timeoutRef.current = void 0;
|
|
810
552
|
void callbackRef.current(...lastArgsRef.current);
|
|
811
553
|
}
|
|
812
554
|
}, []);
|
|
813
|
-
const debouncedCallback =
|
|
555
|
+
const debouncedCallback = React4__default.default.useCallback((...args) => {
|
|
814
556
|
lastArgsRef.current = args;
|
|
815
557
|
cancel();
|
|
816
558
|
timeoutRef.current = setTimeout(() => {
|
|
817
559
|
void callbackRef.current(...args);
|
|
818
560
|
}, delay);
|
|
819
561
|
}, [delay, cancel]);
|
|
820
|
-
|
|
562
|
+
React4__default.default.useEffect(() => {
|
|
821
563
|
return () => {
|
|
822
564
|
cancel();
|
|
823
565
|
};
|
|
@@ -830,17 +572,14 @@ function useDebouncedCallback(callback, delay) {
|
|
|
830
572
|
|
|
831
573
|
Object.defineProperty(exports, "useOsdkClient", {
|
|
832
574
|
enumerable: true,
|
|
833
|
-
get: function () { return
|
|
575
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
834
576
|
});
|
|
835
577
|
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
836
578
|
enumerable: true,
|
|
837
|
-
get: function () { return
|
|
579
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
838
580
|
});
|
|
839
581
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
840
|
-
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|
|
841
582
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
842
|
-
exports.useFoundryUser = useFoundryUser;
|
|
843
|
-
exports.useFoundryUsersList = useFoundryUsersList;
|
|
844
583
|
exports.useLinks = useLinks;
|
|
845
584
|
exports.useObjectSet = useObjectSet;
|
|
846
585
|
exports.useOsdkAction = useOsdkAction;
|