@sanity/sdk 3.0.0 → 3.1.0
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/dist/_exports/_internal.d.ts +25 -3
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +127 -9
- package/dist/_exports/_internal.js.map +1 -1
- package/dist/_exports/agent.d.ts +1 -1
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/comlink.d.ts +1 -1
- package/dist/_exports/comlink.js +2 -3
- package/dist/_exports/comlink.js.map +1 -1
- package/dist/{authStore-C0o1NOxW.d.ts → authStore-C-OEkGaM.d.ts} +2 -2
- package/dist/{authStore-C0o1NOxW.d.ts.map → authStore-C-OEkGaM.d.ts.map} +1 -1
- package/dist/{authStore-CtE9bLHW.js → clientStore-gUALQ0qW.js} +269 -11
- package/dist/{authStore-CtE9bLHW.js.map → clientStore-gUALQ0qW.js.map} +1 -1
- package/dist/{createSanityInstance-DUI1bGIg.d.ts → createSanityInstance-DCePpBYW.d.ts} +2 -2
- package/dist/{createSanityInstance-DUI1bGIg.d.ts.map → createSanityInstance-DCePpBYW.d.ts.map} +1 -1
- package/dist/{getNodeState-CR3__B2D.js → getNodeState-E0hjqFOo.js} +2 -3
- package/dist/{getNodeState-CR3__B2D.js.map → getNodeState-E0hjqFOo.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -44
- package/dist/index.js.map +1 -1
- package/dist/{createStateSourceAction-BOKtqFNm.js → object-BwynGPRZ.js} +87 -3
- package/dist/object-BwynGPRZ.js.map +1 -0
- package/dist/{queryStore-C7yMHPUI.js → version-C90rNWaX.js} +47 -15
- package/dist/version-C90rNWaX.js.map +1 -0
- package/package.json +5 -5
- package/src/_exports/_internal.ts +1 -0
- package/src/access/checkPermissions.test.ts +1 -1
- package/src/access/checkPermissions.ts +1 -1
- package/src/applications/applications.test.ts +4 -4
- package/src/applications/applications.ts +4 -4
- package/src/auth/handleAuthCallback.test.ts +2 -2
- package/src/auth/handleAuthCallback.ts +1 -1
- package/src/auth/logout.test.ts +1 -1
- package/src/auth/logout.ts +1 -1
- package/src/auth/refreshStampedToken.ts +1 -1
- package/src/auth/studioModeAuth.test.ts +1 -1
- package/src/auth/studioModeAuth.ts +1 -1
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -2
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
- package/src/comments/addonDatasetStore.test.ts +2 -2
- package/src/comments/addonDatasetStore.ts +2 -2
- package/src/comments/commentActions.ts +6 -5
- package/src/comments/commentsStore.ts +4 -4
- package/src/document/applyDocumentActions.ts +2 -6
- package/src/document/documentStore.concurrency.test.ts +2 -1
- package/src/document/documentStore.test.ts +19 -18
- package/src/document/documentStore.ts +5 -5
- package/src/document/permissions.ts +2 -1
- package/src/document/processActions.test.ts +2 -1
- package/src/document/processMutations.ts +3 -2
- package/src/document/reducers.ts +2 -2
- package/src/installations/installations.test.ts +2 -2
- package/src/installations/installations.ts +2 -2
- package/src/organization/organization.test.ts +2 -2
- package/src/organization/organization.ts +1 -1
- package/src/organizations/organizations.test.ts +2 -2
- package/src/organizations/organizations.ts +1 -1
- package/src/presence/presenceStore.test.ts +15 -22
- package/src/presence/presenceStore.ts +3 -2
- package/src/project/project.test.ts +3 -3
- package/src/project/project.ts +1 -1
- package/src/projection/getProjectionState.test.ts +6 -4
- package/src/projection/getProjectionState.ts +2 -2
- package/src/projects/projects.test.ts +2 -2
- package/src/projects/projects.ts +1 -1
- package/src/query/queryStore.ts +3 -3
- package/src/store/createSanityInstance.test.ts +1 -1
- package/src/store/createSanityInstance.ts +4 -4
- package/src/store/createStoreInstance.test.ts +0 -5
- package/src/telemetry/telemetryManager.test.ts +1 -1
- package/src/telemetry/telemetryManager.ts +2 -2
- package/src/users/usersStore.test.ts +1 -1
- package/src/users/usersStore.ts +5 -5
- package/src/utils/ids.test.ts +40 -15
- package/src/utils/ids.ts +47 -2
- package/dist/clientStore-BtE2-q2i.js +0 -90
- package/dist/clientStore-BtE2-q2i.js.map +0 -1
- package/dist/createStateSourceAction-BOKtqFNm.js.map +0 -1
- package/dist/getEnv-D5RGkQLu.js +0 -8
- package/dist/getEnv-D5RGkQLu.js.map +0 -1
- package/dist/logger-DAtJb5RQ.js +0 -173
- package/dist/logger-DAtJb5RQ.js.map +0 -1
- package/dist/object-CxXlSVg7.js +0 -83
- package/dist/object-CxXlSVg7.js.map +0 -1
- package/dist/queryStore-C7yMHPUI.js.map +0 -1
- package/dist/rolldown-runtime-vyAXikos.js +0 -9
- package/dist/telemetryManager-UIEiMtC0.js +0 -127
- package/dist/telemetryManager-UIEiMtC0.js.map +0 -1
- package/dist/version-D8RP_Q59.js +0 -9
- package/dist/version-D8RP_Q59.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as REQUEST_TAG_PREFIX, S as DEFAULT_API_VERSION, _ as getDefaultLocation, a as getCurrentUserState, b as AuthStateType, c as getLoginUrlState, d as createLoggedInAuthState, f as getAuthCode, i as getAuthState, l as getTokenState, o as getDashboardOrganizationId, p as getCleanedUrl, s as getIsInDashboardState, t as authStore, u as setAuthToken, v as getTokenFromLocation, w as getAuthLogger } from "./authStore-CtE9bLHW.js";
|
|
5
|
-
import { r as omitProperty, t as isDeepEqual } from "./object-CxXlSVg7.js";
|
|
6
|
-
import { n as getClient, r as getClientState } from "./clientStore-BtE2-q2i.js";
|
|
1
|
+
import { D as configureLogging$1, E as getAuthLogger, O as createLogger, S as AuthStateType, T as REQUEST_TAG_PREFIX, b as getTokenFromLocation, c as getDashboardOrganizationId, d as getTokenState, f as setAuthToken, h as getCleanedUrl, i as authStore, l as getIsInDashboardState, m as getAuthCode, n as getClient, o as getAuthState, p as createLoggedInAuthState, r as getClientState, s as getCurrentUserState, u as getLoginUrlState, w as DEFAULT_API_VERSION, y as getDefaultLocation } from "./clientStore-gUALQ0qW.js";
|
|
2
|
+
import { a as createStateSourceAction, c as bindActionGlobally, d as isReleasePerspective, f as isCanvasResource, l as defineStore, m as isMediaLibraryResource, o as bindActionByResource, p as isDatasetResource, r as omitProperty, s as bindActionByResourceAndPerspective, t as isDeepEqual } from "./object-BwynGPRZ.js";
|
|
3
|
+
import { A as clearPendingTransaction, B as assertDatasetResource, C as getCommentsState, D as toCommentsKeyParts, E as resolveComments, F as rollbackCommentUpdate, G as defineMutation, H as provisionAddonDataset, I as setCommentCreateError, K as randomId, L as setPendingTransaction, M as receiveComment, N as removeCommentById, O as addComment, P as restoreComments, R as normalizeComment, T as resolveCommentThreads, U as COMMENTS_API_VERSION, V as getAddonDatasetState, W as defineFetcher, _ as updateLastLoadMoreRequest, a as resolveQuery, b as commentsStore, c as getAllReleasesState, d as getUsersKey, f as initializeRequest, g as setUsersError, h as setUsersData, j as getCommentsKey, k as applyCommentUpdate, l as addSubscription, m as removeSubscription, o as getPerspectiveState, p as parseUsersKey, q as randomUuid, r as getQueryState, s as getActiveReleasesState, t as CORE_SDK_VERSION, u as cancelRequest, v as PROJECT_API_VERSION, x as getCommentThreadsState, y as USERS_STATE_CLEAR_DELAY, z as toCommentFieldPath } from "./version-C90rNWaX.js";
|
|
7
4
|
import { n as setCleanupTimeout } from "./setCleanupTimeout-BiM6q1KF.js";
|
|
8
|
-
import { t as getNodeState } from "./getNodeState-
|
|
9
|
-
import { t as CORE_SDK_VERSION } from "./version-D8RP_Q59.js";
|
|
5
|
+
import { t as getNodeState } from "./getNodeState-E0hjqFOo.js";
|
|
10
6
|
import { ClientError, CorsOriginError } from "@sanity/client";
|
|
11
7
|
import { EMPTY, NEVER, Observable, Subject, Subscription, auditTime, catchError, combineLatest, concat, concatMap, debounceTime, defer, distinctUntilChanged, filter, first, firstValueFrom, from, fromEvent, groupBy, map, merge, mergeMap, of, pairwise, partition, race, retry, share, shareReplay, skip, startWith, switchMap, take, takeUntil, tap, throttle, throwError, timer, withLatestFrom } from "rxjs";
|
|
12
8
|
import { isKeySegment, isKeyedObject } from "@sanity/types";
|
|
@@ -30,7 +26,7 @@ import { fromUrl } from "@sanity/bifur-client";
|
|
|
30
26
|
* @public
|
|
31
27
|
*/
|
|
32
28
|
function createSanityInstance(config = {}) {
|
|
33
|
-
let instanceId =
|
|
29
|
+
let instanceId = randomId(16), disposeListeners = /* @__PURE__ */ new Map(), disposed = { current: !1 }, instanceContext = {
|
|
34
30
|
instanceId,
|
|
35
31
|
projectId: config.projectId,
|
|
36
32
|
dataset: config.dataset
|
|
@@ -63,7 +59,7 @@ function createSanityInstance(config = {}) {
|
|
|
63
59
|
}), disposed.current = !0, disposeListeners.forEach((listener) => listener()), disposeListeners.clear(), logger.info("Instance disposed");
|
|
64
60
|
},
|
|
65
61
|
onDispose: (cb) => {
|
|
66
|
-
let listenerId =
|
|
62
|
+
let listenerId = randomId(16);
|
|
67
63
|
return disposeListeners.set(listenerId, cb), () => {
|
|
68
64
|
disposeListeners.delete(listenerId);
|
|
69
65
|
};
|
|
@@ -77,7 +73,7 @@ const checkPermissions = defineFetcher({
|
|
|
77
73
|
apiVersion: "v2025-07-11",
|
|
78
74
|
scope: "global"
|
|
79
75
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
80
|
-
|
|
76
|
+
url: `/access/${resourceType}/${resourceId}/user-permissions/me/check`,
|
|
81
77
|
query: { permissions },
|
|
82
78
|
tag: "access.check"
|
|
83
79
|
}).pipe(map((response) => response.data)))),
|
|
@@ -121,7 +117,7 @@ const applications = defineFetcher({
|
|
|
121
117
|
apiVersion: "vX",
|
|
122
118
|
scope: "global"
|
|
123
119
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
124
|
-
|
|
120
|
+
url: "/applications",
|
|
125
121
|
query: buildQuery({
|
|
126
122
|
organizationId: options.organizationId,
|
|
127
123
|
type: options.type,
|
|
@@ -145,7 +141,7 @@ const applications = defineFetcher({
|
|
|
145
141
|
apiVersion: "vX",
|
|
146
142
|
scope: "global"
|
|
147
143
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
148
|
-
|
|
144
|
+
url: `/applications/${applicationId}`,
|
|
149
145
|
query: buildQuery({ include: serializeInclude$1(options?.include) }),
|
|
150
146
|
tag: "applications.get"
|
|
151
147
|
}))),
|
|
@@ -159,7 +155,7 @@ const applications = defineFetcher({
|
|
|
159
155
|
apiVersion: "vX",
|
|
160
156
|
scope: "global"
|
|
161
157
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
162
|
-
|
|
158
|
+
url: `/applications/${applicationId}`,
|
|
163
159
|
method: "PATCH",
|
|
164
160
|
body,
|
|
165
161
|
tag: "applications.update"
|
|
@@ -177,7 +173,7 @@ const applications = defineFetcher({
|
|
|
177
173
|
apiVersion: "vX",
|
|
178
174
|
scope: "global"
|
|
179
175
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
180
|
-
|
|
176
|
+
url: `/applications/${applicationId}`,
|
|
181
177
|
method: "DELETE",
|
|
182
178
|
tag: "applications.delete"
|
|
183
179
|
}))),
|
|
@@ -222,7 +218,7 @@ const projects = defineFetcher({
|
|
|
222
218
|
apiVersion: "v2025-02-19",
|
|
223
219
|
scope: "global"
|
|
224
220
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
225
|
-
|
|
221
|
+
url: "/projects",
|
|
226
222
|
query: buildQuery(normalizeProjectsOptions(options)),
|
|
227
223
|
tag: "projects.list"
|
|
228
224
|
}))),
|
|
@@ -265,7 +261,7 @@ const project = defineFetcher({
|
|
|
265
261
|
apiVersion: "v2025-02-19",
|
|
266
262
|
scope: "global"
|
|
267
263
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
268
|
-
|
|
264
|
+
url: `/projects/${resolveProjectId$1(instance, options)}`,
|
|
269
265
|
query: buildQuery(normalizeProjectOptions(options)),
|
|
270
266
|
tag: "projects.get"
|
|
271
267
|
}))),
|
|
@@ -345,7 +341,7 @@ const handleAuthCallback = bindActionGlobally(authStore, async ({ state, instanc
|
|
|
345
341
|
logger.debug("Fetching token from auth endpoint");
|
|
346
342
|
let { token } = await client.request({
|
|
347
343
|
method: "GET",
|
|
348
|
-
|
|
344
|
+
url: "/auth/fetch",
|
|
349
345
|
query: { sid: authCode },
|
|
350
346
|
tag: "fetch-token"
|
|
351
347
|
});
|
|
@@ -383,7 +379,7 @@ const handleAuthCallback = bindActionGlobally(authStore, async ({ state, instanc
|
|
|
383
379
|
useCdn: !1
|
|
384
380
|
});
|
|
385
381
|
logger.debug("Calling logout endpoint"), await client.request({
|
|
386
|
-
|
|
382
|
+
url: "/auth/logout",
|
|
387
383
|
method: "POST",
|
|
388
384
|
tag: "logout"
|
|
389
385
|
});
|
|
@@ -517,7 +513,7 @@ const createComment = bindActionByResource(commentsStore, async (context, option
|
|
|
517
513
|
let { instance, key } = context, perspective = options.perspective ?? instance.config.perspective, fieldPath = requireFieldPath(options.fieldPath);
|
|
518
514
|
return postComment(context, options, buildCommentPayload({
|
|
519
515
|
authorId: requireCurrentUserId(instance),
|
|
520
|
-
commentId: options.commentId ??
|
|
516
|
+
commentId: options.commentId ?? randomUuid(),
|
|
521
517
|
contentSnapshot: options.contentSnapshot,
|
|
522
518
|
context: options.context,
|
|
523
519
|
documentRevisionId: options.documentRevisionId,
|
|
@@ -527,7 +523,7 @@ const createComment = bindActionByResource(commentsStore, async (context, option
|
|
|
527
523
|
fieldPath,
|
|
528
524
|
selection: options.selection,
|
|
529
525
|
status: options.status ?? "open",
|
|
530
|
-
threadId: options.threadId ??
|
|
526
|
+
threadId: options.threadId ?? randomUuid(),
|
|
531
527
|
...isReleasePerspective(perspective) ? { documentVersionId: perspective.releaseName } : {}
|
|
532
528
|
}));
|
|
533
529
|
}), replyToComment = bindActionByResource(commentsStore, async (context, options) => {
|
|
@@ -538,7 +534,7 @@ const createComment = bindActionByResource(commentsStore, async (context, option
|
|
|
538
534
|
let perspective = options.perspective ?? instance.config.perspective;
|
|
539
535
|
return postComment(context, options, buildCommentPayload({
|
|
540
536
|
authorId: requireCurrentUserId(instance),
|
|
541
|
-
commentId: options.commentId ??
|
|
537
|
+
commentId: options.commentId ?? randomUuid(),
|
|
542
538
|
handle: options,
|
|
543
539
|
message: options.message,
|
|
544
540
|
parentCommentId: parent?.parentCommentId ?? options.parentCommentId,
|
|
@@ -549,7 +545,7 @@ const createComment = bindActionByResource(commentsStore, async (context, option
|
|
|
549
545
|
...isReleasePerspective(perspective) ? { documentVersionId: perspective.releaseName } : {}
|
|
550
546
|
}));
|
|
551
547
|
}), updateComment = bindActionByResource(commentsStore, async ({ state, instance, key }, { commentId, message }) => {
|
|
552
|
-
let lastEditedAt = (/* @__PURE__ */ new Date()).toISOString(), transactionId =
|
|
548
|
+
let lastEditedAt = (/* @__PURE__ */ new Date()).toISOString(), transactionId = randomUuid(), previous = findCommentById(state, commentId);
|
|
553
549
|
previous && (state.set("setPendingTransaction", setPendingTransaction(commentId, transactionId)), state.set("updateComment", applyCommentUpdate(commentId, {
|
|
554
550
|
message,
|
|
555
551
|
lastEditedAt
|
|
@@ -564,7 +560,7 @@ const createComment = bindActionByResource(commentsStore, async (context, option
|
|
|
564
560
|
throw previous && state.set("rollbackCommentUpdate", rollbackCommentUpdate(commentId, transactionId, previous)), error;
|
|
565
561
|
}
|
|
566
562
|
}), setCommentStatus = bindActionByResource(commentsStore, async ({ state, instance, key }, { commentId, status }) => {
|
|
567
|
-
let transactionId =
|
|
563
|
+
let transactionId = randomUuid(), previousComments = [];
|
|
568
564
|
for (let entry of Object.values(state.get().entries)) for (let candidate of Object.values(entry?.comments ?? {})) (candidate._id === commentId || candidate.parentCommentId === commentId) && (previousComments.push(candidate), state.set("setPendingTransaction", setPendingTransaction(candidate._id, transactionId)), state.set("updateCommentStatus", applyCommentUpdate(candidate._id, { status })));
|
|
569
565
|
try {
|
|
570
566
|
await (await getWritableClient(instance, key.resource, { createIfMissing: !1 })).mutate([{ patch: {
|
|
@@ -1258,7 +1254,7 @@ const patchOperations = {
|
|
|
1258
1254
|
* [- source](https://www.sanity.io/docs/http-mutations#c732f27330a4)
|
|
1259
1255
|
*/
|
|
1260
1256
|
function getId(id) {
|
|
1261
|
-
return !id || typeof id != "string" ?
|
|
1257
|
+
return !id || typeof id != "string" ? randomUuid() : id.endsWith(".") ? `${id}${randomUuid()}` : id;
|
|
1262
1258
|
}
|
|
1263
1259
|
function getDocumentIds(selection) {
|
|
1264
1260
|
if ("id" in selection) {
|
|
@@ -1790,7 +1786,7 @@ const _calculatePermissions = createSelector([
|
|
|
1790
1786
|
try {
|
|
1791
1787
|
processActions({
|
|
1792
1788
|
actions,
|
|
1793
|
-
transactionId:
|
|
1789
|
+
transactionId: randomId(16),
|
|
1794
1790
|
working: documents,
|
|
1795
1791
|
base: documents,
|
|
1796
1792
|
timestamp,
|
|
@@ -2835,7 +2831,7 @@ function evictOrphanedDocumentStates(documentStates) {
|
|
|
2835
2831
|
return next;
|
|
2836
2832
|
}
|
|
2837
2833
|
function manageSubscriberIds({ state }, handles) {
|
|
2838
|
-
let documentIds = getDocumentIdsFromHandleLikes(handles), subscriptionId =
|
|
2834
|
+
let documentIds = getDocumentIdsFromHandleLikes(handles), subscriptionId = randomId(16);
|
|
2839
2835
|
return state.set("addSubscribers", (prev) => documentIds.reduce((acc, id) => addSubscriptionIdToDocument(acc, id, subscriptionId), prev)), () => {
|
|
2840
2836
|
setCleanupTimeout(() => {
|
|
2841
2837
|
state.set("removeSubscribers", (prev) => documentIds.reduce((acc, id) => removeSubscriptionIdFromDocument(acc, id, subscriptionId), prev));
|
|
@@ -3185,13 +3181,13 @@ const _resolveDocument = bindActionByResource(documentStore, ({ instance }, docH
|
|
|
3185
3181
|
let clientOptions = {
|
|
3186
3182
|
apiVersion: API_VERSION$4,
|
|
3187
3183
|
resource
|
|
3188
|
-
},
|
|
3189
|
-
if (resource && isDatasetResource(resource))
|
|
3190
|
-
else if (resource && isMediaLibraryResource(resource))
|
|
3191
|
-
else if (resource && isCanvasResource(resource))
|
|
3184
|
+
}, url;
|
|
3185
|
+
if (resource && isDatasetResource(resource)) url = `/projects/${resource.projectId}/datasets/${resource.dataset}/acl`;
|
|
3186
|
+
else if (resource && isMediaLibraryResource(resource)) url = `/media-libraries/${resource.mediaLibraryId}/acl`;
|
|
3187
|
+
else if (resource && isCanvasResource(resource)) url = `/canvases/${resource.canvasId}/acl`;
|
|
3192
3188
|
else throw Error(`Received invalid resource: ${JSON.stringify(resource)}`);
|
|
3193
3189
|
return getClientState(instance, clientOptions).observable.pipe(switchMap((client) => client.observable.request({
|
|
3194
|
-
|
|
3190
|
+
url,
|
|
3195
3191
|
tag: "acl.get"
|
|
3196
3192
|
}).pipe(retry({ delay: (error, retryCount) => {
|
|
3197
3193
|
let isTransientClientError = error instanceof ClientError && (error.statusCode === 408 || error.statusCode === 429);
|
|
@@ -3269,7 +3265,7 @@ function applyDocumentActions(...args) {
|
|
|
3269
3265
|
}
|
|
3270
3266
|
const boundApplyDocumentActions = bindActionByResource(documentStore, _applyDocumentActions);
|
|
3271
3267
|
/** @internal */
|
|
3272
|
-
async function _applyDocumentActions({ state }, { actions, resource, transactionId =
|
|
3268
|
+
async function _applyDocumentActions({ state }, { actions, resource, transactionId = randomUuid(), disableBatching }) {
|
|
3273
3269
|
let { events } = state.get(), transaction = {
|
|
3274
3270
|
transactionId,
|
|
3275
3271
|
actions: normalizeActionsForResource(actions, resource),
|
|
@@ -3395,7 +3391,7 @@ const installations = defineFetcher({
|
|
|
3395
3391
|
apiVersion: "vX",
|
|
3396
3392
|
scope: "global"
|
|
3397
3393
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
3398
|
-
|
|
3394
|
+
url: "/installations",
|
|
3399
3395
|
query: buildQuery({
|
|
3400
3396
|
organizationId: options.organizationId,
|
|
3401
3397
|
include: serializeInclude(options.include),
|
|
@@ -3418,7 +3414,7 @@ const installations = defineFetcher({
|
|
|
3418
3414
|
apiVersion: "vX",
|
|
3419
3415
|
scope: "global"
|
|
3420
3416
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
3421
|
-
|
|
3417
|
+
url: `/installations/${installationId}`,
|
|
3422
3418
|
query: buildQuery({ include: serializeInclude(options?.include) }),
|
|
3423
3419
|
tag: "installations.get"
|
|
3424
3420
|
}))),
|
|
@@ -3458,7 +3454,7 @@ const organization = defineFetcher({
|
|
|
3458
3454
|
apiVersion: "v2025-02-19",
|
|
3459
3455
|
scope: "global"
|
|
3460
3456
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
3461
|
-
|
|
3457
|
+
url: `/organizations/${resolveOrganizationId(options)}`,
|
|
3462
3458
|
query: buildQuery(normalizeOrganizationOptions(options)),
|
|
3463
3459
|
tag: "organizations.get"
|
|
3464
3460
|
}))),
|
|
@@ -3492,7 +3488,7 @@ const organizations = defineFetcher({
|
|
|
3492
3488
|
apiVersion: "v2025-02-19",
|
|
3493
3489
|
scope: "global"
|
|
3494
3490
|
}).observable.pipe(switchMap((client) => client.observable.request({
|
|
3495
|
-
|
|
3491
|
+
url: "/organizations",
|
|
3496
3492
|
query: buildQuery(normalizeOrganizationsOptions(options)),
|
|
3497
3493
|
tag: "organizations.list"
|
|
3498
3494
|
}))),
|
|
@@ -3529,7 +3525,7 @@ const organizations = defineFetcher({
|
|
|
3529
3525
|
useProjectHostname: !0
|
|
3530
3526
|
}).observable.request({
|
|
3531
3527
|
method: "GET",
|
|
3532
|
-
|
|
3528
|
+
url: `/users/${userId}`,
|
|
3533
3529
|
tag: "users.get"
|
|
3534
3530
|
}).pipe(map((user) => ({
|
|
3535
3531
|
data: [{
|
|
@@ -3558,7 +3554,7 @@ const organizations = defineFetcher({
|
|
|
3558
3554
|
}), resourceType = options.resourceType || "project", resourceId = resourceType === "organization" ? options.organizationId : options.projectId;
|
|
3559
3555
|
return resourceId ? client.observable.request({
|
|
3560
3556
|
method: "GET",
|
|
3561
|
-
|
|
3557
|
+
url: `access/${resourceType}/${resourceId}/users/${userId}`,
|
|
3562
3558
|
tag: "users.get"
|
|
3563
3559
|
}).pipe(map((response) => "sanityUserId" in response ? {
|
|
3564
3560
|
data: [response],
|
|
@@ -3582,7 +3578,7 @@ const organizations = defineFetcher({
|
|
|
3582
3578
|
loadMore$
|
|
3583
3579
|
]).pipe(withLatestFrom(cursor$), switchMap(([[resource, client], cursor]) => client.observable.request({
|
|
3584
3580
|
method: "GET",
|
|
3585
|
-
|
|
3581
|
+
url: `access/${resource.type}/${resource.id}/users`,
|
|
3586
3582
|
tag: "users.list",
|
|
3587
3583
|
query: cursor ? {
|
|
3588
3584
|
nextCursor: cursor,
|
|
@@ -3604,7 +3600,7 @@ const organizations = defineFetcher({
|
|
|
3604
3600
|
};
|
|
3605
3601
|
}),
|
|
3606
3602
|
onSubscribe: ({ instance, state }, options) => {
|
|
3607
|
-
let subscriptionId =
|
|
3603
|
+
let subscriptionId = randomId(16), key = getUsersKey(instance, options);
|
|
3608
3604
|
return state.set("addSubscription", addSubscription(subscriptionId, key)), () => {
|
|
3609
3605
|
setCleanupTimeout(() => state.set("removeSubscription", removeSubscription(subscriptionId, key)), USERS_STATE_CLEAR_DELAY);
|
|
3610
3606
|
};
|
|
@@ -3756,7 +3752,7 @@ const presenceStore = defineStore({
|
|
|
3756
3752
|
initialize: (context) => {
|
|
3757
3753
|
let { instance, state, key: { resource } } = context;
|
|
3758
3754
|
if (isMediaLibraryResource(resource)) throw Error("Presence is not supported for media library resources.");
|
|
3759
|
-
let sessionId =
|
|
3755
|
+
let sessionId = randomId(16), client = isDatasetResource(resource) ? getClient(instance, {
|
|
3760
3756
|
apiVersion: PRESENCE_API_VERSION,
|
|
3761
3757
|
projectId: resource.projectId,
|
|
3762
3758
|
dataset: resource.dataset,
|
|
@@ -3839,7 +3835,7 @@ const presenceStore = defineStore({
|
|
|
3839
3835
|
})), isCanvasResource(resource)) {
|
|
3840
3836
|
let globalClient = getClient(instance, { apiVersion: PRESENCE_API_VERSION });
|
|
3841
3837
|
subscription.add(globalClient.observable.request({
|
|
3842
|
-
|
|
3838
|
+
url: `/canvases/${resource.canvasId}`,
|
|
3843
3839
|
tag: "canvases.get"
|
|
3844
3840
|
}).subscribe({
|
|
3845
3841
|
next: ({ organizationId }) => {
|
|
@@ -4181,7 +4177,7 @@ const _getProjectionState = bindActionByResourceAndPerspective(projectionStore,
|
|
|
4181
4177
|
return state.values[documentId]?.[projectionHash] ?? STABLE_EMPTY_PROJECTION;
|
|
4182
4178
|
},
|
|
4183
4179
|
onSubscribe: ({ state }, options) => {
|
|
4184
|
-
let { projection, ...docHandle } = options, subscriptionId =
|
|
4180
|
+
let { projection, ...docHandle } = options, subscriptionId = randomId(16), documentId = getPublishedId(DocumentId(docHandle.documentId)), validProjection = validateProjection(projection), projectionHash = hashString(validProjection);
|
|
4185
4181
|
return state.set("addSubscription", (prev) => ({
|
|
4186
4182
|
documentProjections: {
|
|
4187
4183
|
...prev.documentProjections,
|