@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.
Files changed (90) hide show
  1. package/dist/_exports/_internal.d.ts +25 -3
  2. package/dist/_exports/_internal.d.ts.map +1 -1
  3. package/dist/_exports/_internal.js +127 -9
  4. package/dist/_exports/_internal.js.map +1 -1
  5. package/dist/_exports/agent.d.ts +1 -1
  6. package/dist/_exports/agent.js +1 -1
  7. package/dist/_exports/comlink.d.ts +1 -1
  8. package/dist/_exports/comlink.js +2 -3
  9. package/dist/_exports/comlink.js.map +1 -1
  10. package/dist/{authStore-C0o1NOxW.d.ts → authStore-C-OEkGaM.d.ts} +2 -2
  11. package/dist/{authStore-C0o1NOxW.d.ts.map → authStore-C-OEkGaM.d.ts.map} +1 -1
  12. package/dist/{authStore-CtE9bLHW.js → clientStore-gUALQ0qW.js} +269 -11
  13. package/dist/{authStore-CtE9bLHW.js.map → clientStore-gUALQ0qW.js.map} +1 -1
  14. package/dist/{createSanityInstance-DUI1bGIg.d.ts → createSanityInstance-DCePpBYW.d.ts} +2 -2
  15. package/dist/{createSanityInstance-DUI1bGIg.d.ts.map → createSanityInstance-DCePpBYW.d.ts.map} +1 -1
  16. package/dist/{getNodeState-CR3__B2D.js → getNodeState-E0hjqFOo.js} +2 -3
  17. package/dist/{getNodeState-CR3__B2D.js.map → getNodeState-E0hjqFOo.js.map} +1 -1
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +40 -44
  20. package/dist/index.js.map +1 -1
  21. package/dist/{createStateSourceAction-BOKtqFNm.js → object-BwynGPRZ.js} +87 -3
  22. package/dist/object-BwynGPRZ.js.map +1 -0
  23. package/dist/{queryStore-C7yMHPUI.js → version-C90rNWaX.js} +47 -15
  24. package/dist/version-C90rNWaX.js.map +1 -0
  25. package/package.json +5 -5
  26. package/src/_exports/_internal.ts +1 -0
  27. package/src/access/checkPermissions.test.ts +1 -1
  28. package/src/access/checkPermissions.ts +1 -1
  29. package/src/applications/applications.test.ts +4 -4
  30. package/src/applications/applications.ts +4 -4
  31. package/src/auth/handleAuthCallback.test.ts +2 -2
  32. package/src/auth/handleAuthCallback.ts +1 -1
  33. package/src/auth/logout.test.ts +1 -1
  34. package/src/auth/logout.ts +1 -1
  35. package/src/auth/refreshStampedToken.ts +1 -1
  36. package/src/auth/studioModeAuth.test.ts +1 -1
  37. package/src/auth/studioModeAuth.ts +1 -1
  38. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -2
  39. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
  40. package/src/comments/addonDatasetStore.test.ts +2 -2
  41. package/src/comments/addonDatasetStore.ts +2 -2
  42. package/src/comments/commentActions.ts +6 -5
  43. package/src/comments/commentsStore.ts +4 -4
  44. package/src/document/applyDocumentActions.ts +2 -6
  45. package/src/document/documentStore.concurrency.test.ts +2 -1
  46. package/src/document/documentStore.test.ts +19 -18
  47. package/src/document/documentStore.ts +5 -5
  48. package/src/document/permissions.ts +2 -1
  49. package/src/document/processActions.test.ts +2 -1
  50. package/src/document/processMutations.ts +3 -2
  51. package/src/document/reducers.ts +2 -2
  52. package/src/installations/installations.test.ts +2 -2
  53. package/src/installations/installations.ts +2 -2
  54. package/src/organization/organization.test.ts +2 -2
  55. package/src/organization/organization.ts +1 -1
  56. package/src/organizations/organizations.test.ts +2 -2
  57. package/src/organizations/organizations.ts +1 -1
  58. package/src/presence/presenceStore.test.ts +15 -22
  59. package/src/presence/presenceStore.ts +3 -2
  60. package/src/project/project.test.ts +3 -3
  61. package/src/project/project.ts +1 -1
  62. package/src/projection/getProjectionState.test.ts +6 -4
  63. package/src/projection/getProjectionState.ts +2 -2
  64. package/src/projects/projects.test.ts +2 -2
  65. package/src/projects/projects.ts +1 -1
  66. package/src/query/queryStore.ts +3 -3
  67. package/src/store/createSanityInstance.test.ts +1 -1
  68. package/src/store/createSanityInstance.ts +4 -4
  69. package/src/store/createStoreInstance.test.ts +0 -5
  70. package/src/telemetry/telemetryManager.test.ts +1 -1
  71. package/src/telemetry/telemetryManager.ts +2 -2
  72. package/src/users/usersStore.test.ts +1 -1
  73. package/src/users/usersStore.ts +5 -5
  74. package/src/utils/ids.test.ts +40 -15
  75. package/src/utils/ids.ts +47 -2
  76. package/dist/clientStore-BtE2-q2i.js +0 -90
  77. package/dist/clientStore-BtE2-q2i.js.map +0 -1
  78. package/dist/createStateSourceAction-BOKtqFNm.js.map +0 -1
  79. package/dist/getEnv-D5RGkQLu.js +0 -8
  80. package/dist/getEnv-D5RGkQLu.js.map +0 -1
  81. package/dist/logger-DAtJb5RQ.js +0 -173
  82. package/dist/logger-DAtJb5RQ.js.map +0 -1
  83. package/dist/object-CxXlSVg7.js +0 -83
  84. package/dist/object-CxXlSVg7.js.map +0 -1
  85. package/dist/queryStore-C7yMHPUI.js.map +0 -1
  86. package/dist/rolldown-runtime-vyAXikos.js +0 -9
  87. package/dist/telemetryManager-UIEiMtC0.js +0 -127
  88. package/dist/telemetryManager-UIEiMtC0.js.map +0 -1
  89. package/dist/version-D8RP_Q59.js +0 -9
  90. package/dist/version-D8RP_Q59.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,12 +1,8 @@
1
- import { a as defineStore, c as isDatasetResource, i as bindActionGlobally, l as isMediaLibraryResource, n as bindActionByResource, o as isReleasePerspective, r as bindActionByResourceAndPerspective, s as isCanvasResource, t as createStateSourceAction } from "./createStateSourceAction-BOKtqFNm.js";
2
- import { A as getCommentsKey, B as getAddonDatasetState, D as addComment, E as toCommentsKeyParts, F as setCommentCreateError, G as insecureRandomId, H as COMMENTS_API_VERSION, I as setPendingTransaction, L as normalizeComment, M as removeCommentById, N as restoreComments, O as applyCommentUpdate, P as rollbackCommentUpdate, R as toCommentFieldPath, S as getCommentsState, T as resolveComments, U as defineFetcher, V as provisionAddonDataset, W as defineMutation, _ as PROJECT_API_VERSION, a as getPerspectiveState, b as getCommentThreadsState, c as addSubscription, d as initializeRequest, f as parseUsersKey, g as updateLastLoadMoreRequest, h as setUsersError, i as resolveQuery, j as receiveComment, k as clearPendingTransaction, l as cancelRequest, m as setUsersData, n as getQueryState, o as getActiveReleasesState, p as removeSubscription, s as getAllReleasesState, u as getUsersKey, v as USERS_STATE_CLEAR_DELAY, w as resolveCommentThreads, y as commentsStore, z as assertDatasetResource } from "./queryStore-C7yMHPUI.js";
3
- import { n as createLogger, t as configureLogging$1 } from "./logger-DAtJb5RQ.js";
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-CR3__B2D.js";
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 = crypto.randomUUID(), disposeListeners = /* @__PURE__ */ new Map(), disposed = { current: !1 }, instanceContext = {
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 = insecureRandomId();
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
- uri: `/access/${resourceType}/${resourceId}/user-permissions/me/check`,
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
- uri: "/applications",
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
- uri: `/applications/${applicationId}`,
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
- uri: `/applications/${applicationId}`,
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
- uri: `/applications/${applicationId}`,
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
- uri: "/projects",
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
- uri: `/projects/${resolveProjectId$1(instance, options)}`,
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
- uri: "/auth/fetch",
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
- uri: "/auth/logout",
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 ?? crypto.randomUUID(),
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 ?? crypto.randomUUID(),
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 ?? crypto.randomUUID(),
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 = crypto.randomUUID(), previous = findCommentById(state, commentId);
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 = crypto.randomUUID(), previousComments = [];
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" ? crypto.randomUUID() : id.endsWith(".") ? `${id}${crypto.randomUUID()}` : id;
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: crypto.randomUUID(),
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 = insecureRandomId();
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
- }, uri;
3189
- if (resource && isDatasetResource(resource)) uri = `/projects/${resource.projectId}/datasets/${resource.dataset}/acl`;
3190
- else if (resource && isMediaLibraryResource(resource)) uri = `/media-libraries/${resource.mediaLibraryId}/acl`;
3191
- else if (resource && isCanvasResource(resource)) uri = `/canvases/${resource.canvasId}/acl`;
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
- uri,
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 = crypto.randomUUID(), disableBatching }) {
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
- uri: "/installations",
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
- uri: `/installations/${installationId}`,
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
- uri: `/organizations/${resolveOrganizationId(options)}`,
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
- uri: "/organizations",
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
- uri: `/users/${userId}`,
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
- uri: `access/${resourceType}/${resourceId}/users/${userId}`,
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
- uri: `access/${resource.type}/${resource.id}/users`,
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 = insecureRandomId(), key = getUsersKey(instance, options);
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 = crypto.randomUUID(), client = isDatasetResource(resource) ? getClient(instance, {
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
- uri: `/canvases/${resource.canvasId}`,
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 = insecureRandomId(), documentId = getPublishedId(DocumentId(docHandle.documentId)), validProjection = validateProjection(projection), projectionHash = hashString(validProjection);
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,