@osdk/react 0.10.0-beta.1 → 0.10.0-beta.3
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 +1 -0
- package/CHANGELOG.md +27 -0
- package/build/browser/new/useLinks.js +3 -2
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +6 -4
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkFunction.js +7 -4
- package/build/browser/new/useOsdkFunction.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +6 -4
- package/build/browser/new/useOsdkObjects.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/index.cjs +4 -4
- package/build/cjs/public/experimental.cjs +29 -164
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +17 -4
- package/build/esm/new/useLinks.js +3 -2
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +6 -4
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkFunction.js +7 -4
- package/build/esm/new/useOsdkFunction.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +6 -4
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/types/new/useLinks.d.ts +7 -0
- package/build/types/new/useLinks.d.ts.map +1 -1
- 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/useOsdkObjects.d.ts.map +1 -1
- package/docs/querying-data.md +19 -0
- package/package.json +15 -5
- package/build/cjs/chunk-V32JHU3O.cjs.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOVBG5VXE_cjs = require('../chunk-OVBG5VXE.cjs');
|
|
4
4
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
5
5
|
var React9 = require('react');
|
|
6
|
+
var foundry_admin = require('@osdk/foundry.admin');
|
|
6
7
|
var client = require('@osdk/client');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -32,156 +33,13 @@ function OsdkProvider2({
|
|
|
32
33
|
client,
|
|
33
34
|
observableClient
|
|
34
35
|
}
|
|
35
|
-
}, /* @__PURE__ */ React9__default.default.createElement(
|
|
36
|
+
}, /* @__PURE__ */ React9__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
36
37
|
value: {
|
|
37
38
|
client
|
|
38
39
|
}
|
|
39
40
|
}, children));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
// ../../node_modules/.pnpm/@osdk+shared.client@1.0.1/node_modules/@osdk/shared.client/index.js
|
|
43
|
-
var symbolClientContext = Symbol("ClientContext");
|
|
44
|
-
|
|
45
|
-
// ../../node_modules/.pnpm/@osdk+shared.client2@1.0.0/node_modules/@osdk/shared.client2/index.js
|
|
46
|
-
var symbolClientContext2 = "__osdkClientContext";
|
|
47
|
-
|
|
48
|
-
// ../../node_modules/.pnpm/@osdk+shared.net.errors@2.5.0-beta.2/node_modules/@osdk/shared.net.errors/build/esm/PalantirApiError.js
|
|
49
|
-
var PalantirApiError = class extends Error {
|
|
50
|
-
constructor(message, errorName, errorCode, errorDescription, statusCode, errorInstanceId, parameters) {
|
|
51
|
-
super(message);
|
|
52
|
-
this.message = message;
|
|
53
|
-
this.errorName = errorName;
|
|
54
|
-
this.errorCode = errorCode;
|
|
55
|
-
this.errorDescription = errorDescription;
|
|
56
|
-
this.statusCode = statusCode;
|
|
57
|
-
this.errorInstanceId = errorInstanceId;
|
|
58
|
-
this.parameters = parameters;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// ../../node_modules/.pnpm/@osdk+shared.net.errors@2.5.0-beta.2/node_modules/@osdk/shared.net.errors/build/esm/UnknownError.js
|
|
63
|
-
var UnknownError = class extends PalantirApiError {
|
|
64
|
-
constructor(message, errorName, originalError, statusCode) {
|
|
65
|
-
super(message, errorName, void 0, void 0, statusCode);
|
|
66
|
-
this.originalError = originalError;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// ../../node_modules/.pnpm/@osdk+shared.net.platformapi@1.6.0/node_modules/@osdk/shared.net.platformapi/build/esm/foundryPlatformFetch.js
|
|
71
|
-
async function foundryPlatformFetch(client, [httpMethodNum, origPath, flags, contentType, responseContentType], ...args) {
|
|
72
|
-
const path = origPath.replace(/\{([^}]+)\}/g, () => encodeURIComponent(args.shift()));
|
|
73
|
-
const body = flags & 1 ? args.shift() : void 0;
|
|
74
|
-
const queryArgs = flags & 2 ? args.shift() : void 0;
|
|
75
|
-
const headerArgs = flags & 4 ? args.shift() : void 0;
|
|
76
|
-
const method = ["GET", "POST", "PUT", "DELETE", "PATCH"][httpMethodNum];
|
|
77
|
-
return await apiFetch(client[symbolClientContext2] ?? client[symbolClientContext] ?? client, method, path, body, queryArgs, headerArgs, contentType, responseContentType);
|
|
78
|
-
}
|
|
79
|
-
async function apiFetch(clientCtx, method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {
|
|
80
|
-
const url = parseUrl(clientCtx.baseUrl, endpointPath);
|
|
81
|
-
for (const [key, value] of Object.entries(queryArguments || {})) {
|
|
82
|
-
if (value == null) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (Array.isArray(value)) {
|
|
86
|
-
for (const item of value) {
|
|
87
|
-
url.searchParams.append(key, item);
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
url.searchParams.append(key, value);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const headersInit = new Headers();
|
|
94
|
-
headersInit.set("Content-Type", requestMediaType ?? "application/json");
|
|
95
|
-
headersInit.set("Accept", responseMediaType ?? "application/json");
|
|
96
|
-
Object.entries(headers || {}).forEach(([key, value]) => {
|
|
97
|
-
if (key === "Content-Type" && typeof value === "string") {
|
|
98
|
-
headersInit.set("Content-Type", value);
|
|
99
|
-
} else if (key === "Accept" && typeof value === "string") {
|
|
100
|
-
headersInit.set("Accept", value);
|
|
101
|
-
} else if (value != null) {
|
|
102
|
-
headersInit.append(key, value.toString());
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const body = data == null || data instanceof globalThis.Blob ? data : JSON.stringify(data);
|
|
106
|
-
const response = await clientCtx.fetch(url.toString(), {
|
|
107
|
-
body,
|
|
108
|
-
method,
|
|
109
|
-
headers: headersInit
|
|
110
|
-
});
|
|
111
|
-
if (!response.ok) {
|
|
112
|
-
try {
|
|
113
|
-
const convertedError = await response.json();
|
|
114
|
-
return new PalantirApiError(convertedError.message, convertedError.errorName, convertedError.errorCode, convertedError.errorDescription, response.status, convertedError.errorInstanceId, convertedError.parameters);
|
|
115
|
-
} catch (e) {
|
|
116
|
-
if (e instanceof Error) {
|
|
117
|
-
return new UnknownError(e.message, "UNKNOWN");
|
|
118
|
-
}
|
|
119
|
-
return new UnknownError("Unable to parse error response", "UNKNOWN");
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (response.status === 204) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (responseMediaType == null || responseMediaType === "application/json") {
|
|
126
|
-
return await response.json();
|
|
127
|
-
}
|
|
128
|
-
return response;
|
|
129
|
-
}
|
|
130
|
-
function parseUrl(baseUrl, endpointPath) {
|
|
131
|
-
baseUrl += baseUrl.endsWith("/") ? "" : "/";
|
|
132
|
-
return new URL(`api${endpointPath}`, baseUrl);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ../../node_modules/.pnpm/@osdk+foundry.admin@2.45.0/node_modules/@osdk/foundry.admin/build/esm/public/User.js
|
|
136
|
-
var User_exports = {};
|
|
137
|
-
chunkV32JHU3O_cjs.__export(User_exports, {
|
|
138
|
-
deleteUser: () => deleteUser,
|
|
139
|
-
get: () => get,
|
|
140
|
-
getBatch: () => getBatch,
|
|
141
|
-
getCurrent: () => getCurrent,
|
|
142
|
-
getMarkings: () => getMarkings,
|
|
143
|
-
list: () => list,
|
|
144
|
-
profilePicture: () => profilePicture,
|
|
145
|
-
revokeAllTokens: () => revokeAllTokens,
|
|
146
|
-
search: () => search
|
|
147
|
-
});
|
|
148
|
-
var _deleteUser = [3, "/v2/admin/users/{0}"];
|
|
149
|
-
function deleteUser($ctx, ...args) {
|
|
150
|
-
return foundryPlatformFetch($ctx, _deleteUser, ...args);
|
|
151
|
-
}
|
|
152
|
-
var _list = [0, "/v2/admin/users", 2];
|
|
153
|
-
function list($ctx, ...args) {
|
|
154
|
-
return foundryPlatformFetch($ctx, _list, ...args);
|
|
155
|
-
}
|
|
156
|
-
var _get = [0, "/v2/admin/users/{0}", 2];
|
|
157
|
-
function get($ctx, ...args) {
|
|
158
|
-
return foundryPlatformFetch($ctx, _get, ...args);
|
|
159
|
-
}
|
|
160
|
-
var _getBatch = [1, "/v2/admin/users/getBatch", 1];
|
|
161
|
-
function getBatch($ctx, ...args) {
|
|
162
|
-
return foundryPlatformFetch($ctx, _getBatch, ...args);
|
|
163
|
-
}
|
|
164
|
-
var _getCurrent = [0, "/v2/admin/users/getCurrent"];
|
|
165
|
-
function getCurrent($ctx, ...args) {
|
|
166
|
-
return foundryPlatformFetch($ctx, _getCurrent, ...args);
|
|
167
|
-
}
|
|
168
|
-
var _getMarkings = [0, "/v2/admin/users/{0}/getMarkings", 2];
|
|
169
|
-
function getMarkings($ctx, ...args) {
|
|
170
|
-
return foundryPlatformFetch($ctx, _getMarkings, ...args);
|
|
171
|
-
}
|
|
172
|
-
var _profilePicture = [0, "/v2/admin/users/{0}/profilePicture", , , "application/octet-stream"];
|
|
173
|
-
function profilePicture($ctx, ...args) {
|
|
174
|
-
return foundryPlatformFetch($ctx, _profilePicture, ...args);
|
|
175
|
-
}
|
|
176
|
-
var _search = [1, "/v2/admin/users/search", 1];
|
|
177
|
-
function search($ctx, ...args) {
|
|
178
|
-
return foundryPlatformFetch($ctx, _search, ...args);
|
|
179
|
-
}
|
|
180
|
-
var _revokeAllTokens = [1, "/v2/admin/users/{0}/revokeAllTokens", 2];
|
|
181
|
-
function revokeAllTokens($ctx, ...args) {
|
|
182
|
-
return foundryPlatformFetch($ctx, _revokeAllTokens, ...args);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
43
|
// src/new/makeExternalStore.ts
|
|
186
44
|
function makeExternalStore(createObservation, _name, initialValue) {
|
|
187
45
|
let lastResult = initialValue;
|
|
@@ -279,7 +137,7 @@ function useCurrentFoundryUser({
|
|
|
279
137
|
const {
|
|
280
138
|
client
|
|
281
139
|
} = React9__default.default.useContext(OsdkContext2);
|
|
282
|
-
const handleQuery = React9__default.default.useCallback(() =>
|
|
140
|
+
const handleQuery = React9__default.default.useCallback(() => foundry_admin.Users.getCurrent(client), [client]);
|
|
283
141
|
const query = usePlatformQuery({
|
|
284
142
|
query: handleQuery,
|
|
285
143
|
enabled,
|
|
@@ -300,7 +158,7 @@ function useFoundryUser(userId, {
|
|
|
300
158
|
client
|
|
301
159
|
} = React9__default.default.useContext(OsdkContext2);
|
|
302
160
|
const handleQuery = React9__default.default.useCallback(() => {
|
|
303
|
-
return
|
|
161
|
+
return foundry_admin.Users.get(client, userId, {
|
|
304
162
|
status
|
|
305
163
|
});
|
|
306
164
|
}, [client, userId, status]);
|
|
@@ -326,7 +184,7 @@ function useFoundryUsersList({
|
|
|
326
184
|
client
|
|
327
185
|
} = React9__default.default.useContext(OsdkContext2);
|
|
328
186
|
const handleQuery = React9__default.default.useCallback(() => {
|
|
329
|
-
return
|
|
187
|
+
return foundry_admin.Users.list(client, {
|
|
330
188
|
include,
|
|
331
189
|
pageSize,
|
|
332
190
|
pageToken
|
|
@@ -379,9 +237,10 @@ function useLinks(objects, linkName, options = {}) {
|
|
|
379
237
|
where: stableWhere,
|
|
380
238
|
pageSize: otherOptions.pageSize,
|
|
381
239
|
orderBy: stableOrderBy,
|
|
382
|
-
mode: otherOptions.mode
|
|
240
|
+
mode: otherOptions.mode,
|
|
241
|
+
dedupeInterval: otherOptions.dedupeIntervalMs ?? 2e3
|
|
383
242
|
}, observer));
|
|
384
|
-
}, [enabled, observableClient, objectsArray, objectsKey, linkName, stableWhere, otherOptions.pageSize, stableOrderBy, otherOptions.mode]);
|
|
243
|
+
}, [enabled, observableClient, objectsArray, objectsKey, linkName, stableWhere, otherOptions.pageSize, stableOrderBy, otherOptions.mode, otherOptions.dedupeIntervalMs]);
|
|
385
244
|
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
386
245
|
return {
|
|
387
246
|
links: payload?.resolvedList,
|
|
@@ -578,8 +437,9 @@ function useOsdkAction(actionDef) {
|
|
|
578
437
|
validationResult
|
|
579
438
|
};
|
|
580
439
|
}
|
|
440
|
+
var EMPTY_WHERE = {};
|
|
581
441
|
function useOsdkAggregation(type, {
|
|
582
|
-
where =
|
|
442
|
+
where = EMPTY_WHERE,
|
|
583
443
|
withProperties,
|
|
584
444
|
aggregate,
|
|
585
445
|
dedupeIntervalMs
|
|
@@ -587,7 +447,8 @@ function useOsdkAggregation(type, {
|
|
|
587
447
|
const {
|
|
588
448
|
observableClient
|
|
589
449
|
} = React9__default.default.useContext(OsdkContext2);
|
|
590
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where ??
|
|
450
|
+
const canonWhere = observableClient.canonicalizeWhereClause(where ?? EMPTY_WHERE);
|
|
451
|
+
const stableCanonWhere = React9__default.default.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
591
452
|
const stableWithProperties = React9__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
592
453
|
const stableAggregate = React9__default.default.useMemo(() => aggregate, [JSON.stringify(aggregate)]);
|
|
593
454
|
const {
|
|
@@ -595,11 +456,11 @@ function useOsdkAggregation(type, {
|
|
|
595
456
|
getSnapShot
|
|
596
457
|
} = React9__default.default.useMemo(() => makeExternalStore((observer) => observableClient.observeAggregation({
|
|
597
458
|
type,
|
|
598
|
-
where:
|
|
459
|
+
where: stableCanonWhere,
|
|
599
460
|
withProperties: stableWithProperties,
|
|
600
461
|
aggregate: stableAggregate,
|
|
601
462
|
dedupeInterval: dedupeIntervalMs ?? 2e3
|
|
602
|
-
}, observer), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${JSON.stringify(
|
|
463
|
+
}, observer), process.env.NODE_ENV !== "production" ? `aggregation ${type.apiName} ${JSON.stringify(stableCanonWhere)}` : void 0), [observableClient, type.apiName, type.type, stableCanonWhere, stableWithProperties, stableAggregate, dedupeIntervalMs]);
|
|
603
464
|
const payload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
604
465
|
let error;
|
|
605
466
|
if (payload && "error" in payload && payload.error) {
|
|
@@ -630,10 +491,12 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
630
491
|
} = options;
|
|
631
492
|
const stableParams = React9__default.default.useMemo(() => params, [JSON.stringify(params)]);
|
|
632
493
|
const stableDependsOn = React9__default.default.useMemo(() => dependsOn, [JSON.stringify(dependsOn?.map((d) => typeof d === "string" ? d : d.apiName))]);
|
|
633
|
-
const stableDependsOnObjects = React9__default.default.useMemo(() => dependsOnObjects, [JSON.stringify(dependsOnObjects?.map((
|
|
634
|
-
$apiName:
|
|
635
|
-
$primaryKey:
|
|
636
|
-
}
|
|
494
|
+
const stableDependsOnObjects = React9__default.default.useMemo(() => dependsOnObjects, [JSON.stringify(dependsOnObjects?.map((item) => "$apiName" in item ? {
|
|
495
|
+
$apiName: item.$apiName,
|
|
496
|
+
$primaryKey: item.$primaryKey
|
|
497
|
+
} : {
|
|
498
|
+
__objectSet: unstableDoNotUse.getWireObjectSet(item)
|
|
499
|
+
}))]);
|
|
637
500
|
const paramsForApi = stableParams;
|
|
638
501
|
const {
|
|
639
502
|
subscribe,
|
|
@@ -704,6 +567,7 @@ function useOsdkObject(...args) {
|
|
|
704
567
|
}
|
|
705
568
|
};
|
|
706
569
|
}
|
|
570
|
+
var EMPTY_WHERE2 = {};
|
|
707
571
|
function useOsdkObjects(type, options) {
|
|
708
572
|
const {
|
|
709
573
|
observableClient
|
|
@@ -721,7 +585,8 @@ function useOsdkObjects(type, options) {
|
|
|
721
585
|
intersectWith,
|
|
722
586
|
pivotTo
|
|
723
587
|
} = options ?? {};
|
|
724
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where ??
|
|
588
|
+
const canonWhere = observableClient.canonicalizeWhereClause(where ?? EMPTY_WHERE2);
|
|
589
|
+
const stableCanonWhere = React9__default.default.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
725
590
|
const stableRids = React9__default.default.useMemo(() => rids, [JSON.stringify(rids)]);
|
|
726
591
|
const stableWithProperties = React9__default.default.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
727
592
|
const stableIntersectWith = React9__default.default.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
@@ -739,7 +604,7 @@ function useOsdkObjects(type, options) {
|
|
|
739
604
|
return makeExternalStore((observer) => observableClient.observeList({
|
|
740
605
|
type,
|
|
741
606
|
rids: stableRids,
|
|
742
|
-
where:
|
|
607
|
+
where: stableCanonWhere,
|
|
743
608
|
dedupeInterval: dedupeIntervalMs ?? 2e3,
|
|
744
609
|
pageSize,
|
|
745
610
|
orderBy: stableOrderBy,
|
|
@@ -752,8 +617,8 @@ function useOsdkObjects(type, options) {
|
|
|
752
617
|
...pivotTo ? {
|
|
753
618
|
pivotTo
|
|
754
619
|
} : {}
|
|
755
|
-
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(
|
|
756
|
-
}, [enabled, observableClient, type, stableRids,
|
|
620
|
+
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
621
|
+
}, [enabled, observableClient, type.apiName, type.type, stableRids, stableCanonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo]);
|
|
757
622
|
const listPayload = React9__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
758
623
|
let error;
|
|
759
624
|
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
@@ -808,11 +673,11 @@ function useDebouncedCallback(callback, delay) {
|
|
|
808
673
|
|
|
809
674
|
Object.defineProperty(exports, "useOsdkClient", {
|
|
810
675
|
enumerable: true,
|
|
811
|
-
get: function () { return
|
|
676
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
812
677
|
});
|
|
813
678
|
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
814
679
|
enumerable: true,
|
|
815
|
-
get: function () { return
|
|
680
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
816
681
|
});
|
|
817
682
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
818
683
|
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|