@osdk/react 0.10.0-beta.7 → 0.10.0-beta.9
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 +29 -0
- package/build/browser/new/useLinks.js +8 -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/browser/useOsdkMetadata.js.map +1 -1
- package/build/cjs/chunk-SVVMLSKN.cjs +111 -0
- package/build/cjs/chunk-SVVMLSKN.cjs.map +1 -0
- 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 +114 -328
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +41 -118
- package/build/cjs/useOsdkMetadata-BElt3F5s.d.cts +15 -0
- package/build/esm/new/useLinks.js +8 -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/esm/useOsdkMetadata.js.map +1 -1
- package/build/types/new/useLinks.d.ts +12 -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/types/useOsdkMetadata.d.ts +5 -4
- package/build/types/useOsdkMetadata.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/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,303 +1,79 @@
|
|
|
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([]);
|
|
31
|
+
var emptyMap = /* @__PURE__ */ new Map();
|
|
261
32
|
function useLinks(objects, linkName, options = {}) {
|
|
262
33
|
const {
|
|
263
34
|
observableClient
|
|
264
|
-
} =
|
|
35
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
265
36
|
const {
|
|
266
37
|
enabled = true,
|
|
267
38
|
...otherOptions
|
|
268
39
|
} = options;
|
|
269
|
-
const stableWhere =
|
|
270
|
-
const stableOrderBy =
|
|
271
|
-
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(() => {
|
|
272
44
|
if (objects === void 0) return "";
|
|
273
45
|
const arr = Array.isArray(objects) ? objects : [objects];
|
|
274
46
|
return arr.map((obj) => `${obj.$apiName}:${obj.$primaryKey}`).join(",");
|
|
275
47
|
}, [objects]);
|
|
276
|
-
const objectsArray =
|
|
48
|
+
const objectsArray = React4__default.default.useMemo(() => {
|
|
277
49
|
return objects === void 0 ? emptyArray : Array.isArray(objects) ? objects : [objects];
|
|
278
50
|
}, [objectsKey, objects]);
|
|
279
51
|
const {
|
|
280
52
|
subscribe,
|
|
281
53
|
getSnapShot
|
|
282
|
-
} =
|
|
54
|
+
} = React4__default.default.useMemo(() => {
|
|
283
55
|
if (!enabled) {
|
|
284
|
-
return makeExternalStore(() => ({
|
|
56
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
285
57
|
unsubscribe: () => {
|
|
286
58
|
}
|
|
287
|
-
}));
|
|
59
|
+
}), `links ${linkName} for ${objectsKey} [DISABLED]`);
|
|
288
60
|
}
|
|
289
|
-
return makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
61
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
290
62
|
linkName,
|
|
291
63
|
where: stableWhere,
|
|
292
64
|
pageSize: otherOptions.pageSize,
|
|
293
65
|
orderBy: stableOrderBy,
|
|
294
66
|
mode: otherOptions.mode,
|
|
295
|
-
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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(() => ({
|
|
300
75
|
links: payload?.resolvedList,
|
|
76
|
+
linkedObjectsBySourcePrimaryKey: payload?.linkedObjectsBySourcePrimaryKey ?? emptyMap,
|
|
301
77
|
isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
|
|
302
78
|
isOptimistic: payload?.isOptimistic ?? false,
|
|
303
79
|
error: payload?.error,
|
|
@@ -309,15 +85,15 @@ var OBJECT_TYPE_PLACEHOLDER = "$__OBJECT__TYPE__PLACEHOLDER";
|
|
|
309
85
|
function useObjectSet(baseObjectSet, options = {}) {
|
|
310
86
|
const {
|
|
311
87
|
observableClient
|
|
312
|
-
} =
|
|
88
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
313
89
|
const {
|
|
314
90
|
enabled = true,
|
|
315
91
|
streamUpdates,
|
|
316
92
|
...otherOptions
|
|
317
93
|
} = options;
|
|
318
94
|
const objectTypeKey = enabled ? baseObjectSet.$objectSetInternals.def.apiName : OBJECT_TYPE_PLACEHOLDER;
|
|
319
|
-
const previousObjectTypeRef =
|
|
320
|
-
const previousCompletedPayloadRef =
|
|
95
|
+
const previousObjectTypeRef = React4__default.default.useRef(objectTypeKey);
|
|
96
|
+
const previousCompletedPayloadRef = React4__default.default.useRef();
|
|
321
97
|
const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
|
|
322
98
|
if (objectTypeChanged) {
|
|
323
99
|
previousObjectTypeRef.current = objectTypeKey;
|
|
@@ -331,20 +107,21 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
331
107
|
subtract: otherOptions.subtract,
|
|
332
108
|
pivotTo: otherOptions.pivotTo,
|
|
333
109
|
pageSize: otherOptions.pageSize,
|
|
334
|
-
orderBy: otherOptions.orderBy
|
|
110
|
+
orderBy: otherOptions.orderBy,
|
|
111
|
+
select: otherOptions.$select
|
|
335
112
|
});
|
|
336
113
|
const {
|
|
337
114
|
subscribe,
|
|
338
115
|
getSnapShot
|
|
339
|
-
} =
|
|
116
|
+
} = React4__default.default.useMemo(() => {
|
|
340
117
|
if (!enabled) {
|
|
341
|
-
return makeExternalStore(() => ({
|
|
118
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
342
119
|
unsubscribe: () => {
|
|
343
120
|
}
|
|
344
121
|
}), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
|
|
345
122
|
}
|
|
346
123
|
const initialValue = objectTypeChanged ? void 0 : previousCompletedPayloadRef.current;
|
|
347
|
-
return makeExternalStore((observer) => {
|
|
124
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => {
|
|
348
125
|
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
349
126
|
where: otherOptions.where,
|
|
350
127
|
withProperties: otherOptions.withProperties,
|
|
@@ -356,16 +133,17 @@ function useObjectSet(baseObjectSet, options = {}) {
|
|
|
356
133
|
orderBy: otherOptions.orderBy,
|
|
357
134
|
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3,
|
|
358
135
|
autoFetchMore: otherOptions.autoFetchMore,
|
|
359
|
-
streamUpdates
|
|
136
|
+
streamUpdates,
|
|
137
|
+
select: otherOptions.$select
|
|
360
138
|
}, observer);
|
|
361
139
|
return subscription;
|
|
362
140
|
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
|
|
363
141
|
}, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
|
|
364
|
-
const payload =
|
|
142
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
365
143
|
if (payload && isPayloadCompleted(payload)) {
|
|
366
144
|
previousCompletedPayloadRef.current = payload;
|
|
367
145
|
}
|
|
368
|
-
return
|
|
146
|
+
return React4__default.default.useMemo(() => {
|
|
369
147
|
const lastLoaded = isPayloadCompleted(payload) ? payload : previousCompletedPayloadRef.current;
|
|
370
148
|
return {
|
|
371
149
|
data: lastLoaded?.resolvedList,
|
|
@@ -399,14 +177,14 @@ function isPayloadCompleted(payload) {
|
|
|
399
177
|
function useOsdkAction(actionDef) {
|
|
400
178
|
const {
|
|
401
179
|
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 =
|
|
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) {
|
|
410
188
|
try {
|
|
411
189
|
if (isValidating && abortControllerRef.current) {
|
|
412
190
|
abortControllerRef.current.abort();
|
|
@@ -460,7 +238,7 @@ function useOsdkAction(actionDef) {
|
|
|
460
238
|
setPending(false);
|
|
461
239
|
}
|
|
462
240
|
}, [observableClient, actionDef, isValidating]);
|
|
463
|
-
const validateAction =
|
|
241
|
+
const validateAction = React4__default.default.useCallback(async function validateAction2(args) {
|
|
464
242
|
try {
|
|
465
243
|
if (isPending) {
|
|
466
244
|
return void 0;
|
|
@@ -496,14 +274,14 @@ function useOsdkAction(actionDef) {
|
|
|
496
274
|
setValidating(false);
|
|
497
275
|
}
|
|
498
276
|
}, [observableClient, actionDef, isPending]);
|
|
499
|
-
|
|
277
|
+
React4__default.default.useEffect(() => {
|
|
500
278
|
return () => {
|
|
501
279
|
if (abortControllerRef.current) {
|
|
502
280
|
abortControllerRef.current.abort();
|
|
503
281
|
}
|
|
504
282
|
};
|
|
505
283
|
}, []);
|
|
506
|
-
return
|
|
284
|
+
return React4__default.default.useMemo(() => ({
|
|
507
285
|
applyAction,
|
|
508
286
|
validateAction,
|
|
509
287
|
error,
|
|
@@ -525,21 +303,21 @@ function useOsdkAggregation(type, options) {
|
|
|
525
303
|
const objectSet = "objectSet" in options ? options.objectSet : void 0;
|
|
526
304
|
const {
|
|
527
305
|
observableClient
|
|
528
|
-
} =
|
|
306
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
529
307
|
const canonWhere = observableClient.canonicalizeWhereClause(where);
|
|
530
|
-
const stableCanonWhere =
|
|
531
|
-
const objectSetRef =
|
|
308
|
+
const stableCanonWhere = React4__default.default.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
309
|
+
const objectSetRef = React4__default.default.useRef(objectSet);
|
|
532
310
|
objectSetRef.current = objectSet;
|
|
533
311
|
const objectSetKeyString = objectSet ? unstableDoNotUse.computeObjectSetCacheKey(objectSet) : void 0;
|
|
534
|
-
const stableWithProperties =
|
|
535
|
-
const stableAggregate =
|
|
536
|
-
const stableIntersectWith =
|
|
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)]);
|
|
537
315
|
const {
|
|
538
316
|
subscribe,
|
|
539
317
|
getSnapShot
|
|
540
|
-
} =
|
|
318
|
+
} = React4__default.default.useMemo(() => {
|
|
541
319
|
if (objectSetKeyString && objectSetRef.current) {
|
|
542
|
-
return makeExternalStoreAsync((observer) => observableClient.observeAggregation({
|
|
320
|
+
return chunkSVVMLSKN_cjs.makeExternalStoreAsync((observer) => observableClient.observeAggregation({
|
|
543
321
|
type,
|
|
544
322
|
objectSet: objectSetRef.current,
|
|
545
323
|
where: stableCanonWhere,
|
|
@@ -549,7 +327,7 @@ function useOsdkAggregation(type, options) {
|
|
|
549
327
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
550
328
|
}, observer), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${objectSetKeyString} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
551
329
|
}
|
|
552
|
-
return makeExternalStore((observer) => (
|
|
330
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => (
|
|
553
331
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
554
332
|
observableClient.observeAggregation({
|
|
555
333
|
type,
|
|
@@ -561,11 +339,11 @@ function useOsdkAggregation(type, options) {
|
|
|
561
339
|
}, observer)
|
|
562
340
|
), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
563
341
|
}, [observableClient, type.apiName, type.type, objectSetKeyString, stableCanonWhere, stableWithProperties, stableIntersectWith, stableAggregate, dedupeIntervalMs]);
|
|
564
|
-
const payload =
|
|
565
|
-
const refetch =
|
|
342
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
343
|
+
const refetch = React4__default.default.useCallback(async () => {
|
|
566
344
|
await observableClient.invalidateObjectType(type.apiName);
|
|
567
345
|
}, [observableClient, type.apiName]);
|
|
568
|
-
return
|
|
346
|
+
return React4__default.default.useMemo(() => {
|
|
569
347
|
let error;
|
|
570
348
|
if (payload && "error" in payload && payload.error) {
|
|
571
349
|
error = payload.error;
|
|
@@ -583,7 +361,7 @@ function useOsdkAggregation(type, options) {
|
|
|
583
361
|
function useOsdkFunction(queryDef, options = {}) {
|
|
584
362
|
const {
|
|
585
363
|
observableClient
|
|
586
|
-
} =
|
|
364
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
587
365
|
const {
|
|
588
366
|
params,
|
|
589
367
|
dependsOn,
|
|
@@ -591,9 +369,9 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
591
369
|
dedupeIntervalMs,
|
|
592
370
|
enabled = true
|
|
593
371
|
} = options;
|
|
594
|
-
const stableParams =
|
|
595
|
-
const stableDependsOn =
|
|
596
|
-
const stableDependsOnObjects =
|
|
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 ? {
|
|
597
375
|
$apiName: item.$apiName,
|
|
598
376
|
$primaryKey: item.$primaryKey
|
|
599
377
|
} : {
|
|
@@ -603,24 +381,24 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
603
381
|
const {
|
|
604
382
|
subscribe,
|
|
605
383
|
getSnapShot
|
|
606
|
-
} =
|
|
384
|
+
} = React4__default.default.useMemo(() => {
|
|
607
385
|
if (!enabled) {
|
|
608
|
-
return makeExternalStore(() => ({
|
|
386
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
609
387
|
unsubscribe: () => {
|
|
610
388
|
}
|
|
611
389
|
}), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)} [DISABLED]` : void 0);
|
|
612
390
|
}
|
|
613
|
-
return makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
391
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeFunction(queryDef, paramsForApi, {
|
|
614
392
|
dependsOn: stableDependsOn,
|
|
615
393
|
dependsOnObjects: stableDependsOnObjects,
|
|
616
394
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
617
395
|
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
618
396
|
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
619
|
-
const payload =
|
|
620
|
-
const refetch =
|
|
397
|
+
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
398
|
+
const refetch = React4__default.default.useCallback(() => {
|
|
621
399
|
void observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
622
400
|
}, [observableClient, queryDef, paramsForApi]);
|
|
623
|
-
return
|
|
401
|
+
return React4__default.default.useMemo(() => {
|
|
624
402
|
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : void 0);
|
|
625
403
|
return {
|
|
626
404
|
data: payload?.result,
|
|
@@ -634,32 +412,38 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
634
412
|
function useOsdkObject(...args) {
|
|
635
413
|
const {
|
|
636
414
|
observableClient
|
|
637
|
-
} =
|
|
415
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
638
416
|
const isInstanceSignature = "$objectType" in args[0];
|
|
639
|
-
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;
|
|
640
420
|
const mode = isInstanceSignature ? "offline" : void 0;
|
|
641
421
|
const typeOrApiName = isInstanceSignature ? args[0].$objectType : args[0];
|
|
642
422
|
const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];
|
|
643
423
|
const apiNameString = typeof typeOrApiName === "string" ? typeOrApiName : typeOrApiName.apiName;
|
|
424
|
+
const stableSelect = React4__default.default.useMemo(() => selectArg, [JSON.stringify(selectArg)]);
|
|
644
425
|
const {
|
|
645
426
|
subscribe,
|
|
646
427
|
getSnapShot
|
|
647
|
-
} =
|
|
428
|
+
} = React4__default.default.useMemo(() => {
|
|
648
429
|
if (!enabled) {
|
|
649
|
-
return makeExternalStore(() => ({
|
|
430
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
650
431
|
unsubscribe: () => {
|
|
651
432
|
}
|
|
652
|
-
}));
|
|
433
|
+
}), `object ${apiNameString} ${primaryKey} [DISABLED]`);
|
|
653
434
|
}
|
|
654
|
-
return makeExternalStore((observer) => observableClient.observeObject(typeOrApiName, primaryKey, {
|
|
655
|
-
mode
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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(() => {
|
|
660
444
|
throw new Error("not implemented");
|
|
661
445
|
}, []);
|
|
662
|
-
return
|
|
446
|
+
return React4__default.default.useMemo(() => {
|
|
663
447
|
let error;
|
|
664
448
|
if (payload && "error" in payload && payload.error) {
|
|
665
449
|
error = payload.error;
|
|
@@ -679,7 +463,7 @@ var EMPTY_WHERE2 = {};
|
|
|
679
463
|
function useOsdkObjects(type, options) {
|
|
680
464
|
const {
|
|
681
465
|
observableClient
|
|
682
|
-
} =
|
|
466
|
+
} = React4__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
683
467
|
const {
|
|
684
468
|
pageSize,
|
|
685
469
|
dedupeIntervalMs,
|
|
@@ -691,25 +475,27 @@ function useOsdkObjects(type, options) {
|
|
|
691
475
|
streamUpdates,
|
|
692
476
|
autoFetchMore,
|
|
693
477
|
intersectWith,
|
|
694
|
-
pivotTo
|
|
478
|
+
pivotTo,
|
|
479
|
+
$select
|
|
695
480
|
} = options ?? {};
|
|
696
481
|
const canonWhere = observableClient.canonicalizeWhereClause(where ?? EMPTY_WHERE2);
|
|
697
|
-
const stableCanonWhere =
|
|
698
|
-
const stableRids =
|
|
699
|
-
const stableWithProperties =
|
|
700
|
-
const stableIntersectWith =
|
|
701
|
-
const stableOrderBy =
|
|
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)]);
|
|
702
488
|
const {
|
|
703
489
|
subscribe,
|
|
704
490
|
getSnapShot
|
|
705
|
-
} =
|
|
491
|
+
} = React4__default.default.useMemo(() => {
|
|
706
492
|
if (!enabled) {
|
|
707
|
-
return makeExternalStore(() => ({
|
|
493
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
708
494
|
unsubscribe: () => {
|
|
709
495
|
}
|
|
710
496
|
}), process.env.NODE_ENV !== "production" ? `list ${type.apiName} [DISABLED]` : void 0);
|
|
711
497
|
}
|
|
712
|
-
return makeExternalStore((observer) => observableClient.observeList({
|
|
498
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => observableClient.observeList({
|
|
713
499
|
type,
|
|
714
500
|
rids: stableRids,
|
|
715
501
|
where: stableCanonWhere,
|
|
@@ -724,11 +510,14 @@ function useOsdkObjects(type, options) {
|
|
|
724
510
|
} : {},
|
|
725
511
|
...pivotTo ? {
|
|
726
512
|
pivotTo
|
|
513
|
+
} : {},
|
|
514
|
+
...stableSelect ? {
|
|
515
|
+
select: stableSelect
|
|
727
516
|
} : {}
|
|
728
517
|
}, 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
|
|
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(() => {
|
|
732
521
|
let error;
|
|
733
522
|
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
734
523
|
error = listPayload.error;
|
|
@@ -746,31 +535,31 @@ function useOsdkObjects(type, options) {
|
|
|
746
535
|
}, [listPayload, enabled]);
|
|
747
536
|
}
|
|
748
537
|
function useDebouncedCallback(callback, delay) {
|
|
749
|
-
const timeoutRef =
|
|
750
|
-
const callbackRef =
|
|
751
|
-
const lastArgsRef =
|
|
538
|
+
const timeoutRef = React4__default.default.useRef();
|
|
539
|
+
const callbackRef = React4__default.default.useRef(callback);
|
|
540
|
+
const lastArgsRef = React4__default.default.useRef();
|
|
752
541
|
callbackRef.current = callback;
|
|
753
|
-
const cancel =
|
|
542
|
+
const cancel = React4__default.default.useCallback(() => {
|
|
754
543
|
if (timeoutRef.current) {
|
|
755
544
|
clearTimeout(timeoutRef.current);
|
|
756
545
|
timeoutRef.current = void 0;
|
|
757
546
|
}
|
|
758
547
|
}, []);
|
|
759
|
-
const flush =
|
|
548
|
+
const flush = React4__default.default.useCallback(() => {
|
|
760
549
|
if (timeoutRef.current && lastArgsRef.current) {
|
|
761
550
|
clearTimeout(timeoutRef.current);
|
|
762
551
|
timeoutRef.current = void 0;
|
|
763
552
|
void callbackRef.current(...lastArgsRef.current);
|
|
764
553
|
}
|
|
765
554
|
}, []);
|
|
766
|
-
const debouncedCallback =
|
|
555
|
+
const debouncedCallback = React4__default.default.useCallback((...args) => {
|
|
767
556
|
lastArgsRef.current = args;
|
|
768
557
|
cancel();
|
|
769
558
|
timeoutRef.current = setTimeout(() => {
|
|
770
559
|
void callbackRef.current(...args);
|
|
771
560
|
}, delay);
|
|
772
561
|
}, [delay, cancel]);
|
|
773
|
-
|
|
562
|
+
React4__default.default.useEffect(() => {
|
|
774
563
|
return () => {
|
|
775
564
|
cancel();
|
|
776
565
|
};
|
|
@@ -790,10 +579,7 @@ Object.defineProperty(exports, "useOsdkMetadata", {
|
|
|
790
579
|
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
791
580
|
});
|
|
792
581
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
793
|
-
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|
|
794
582
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
795
|
-
exports.useFoundryUser = useFoundryUser;
|
|
796
|
-
exports.useFoundryUsersList = useFoundryUsersList;
|
|
797
583
|
exports.useLinks = useLinks;
|
|
798
584
|
exports.useObjectSet = useObjectSet;
|
|
799
585
|
exports.useOsdkAction = useOsdkAction;
|