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