@sanity/sdk 2.3.0 → 2.4.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/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { createClient, CorsOriginError } from "@sanity/client";
2
1
  import { Observable, share, map, distinctUntilChanged, skip, filter, exhaustMap, from, timer, switchMap, takeWhile, firstValueFrom, fromEvent, EMPTY, defer, asapScheduler, combineLatest, of, concatMap, withLatestFrom, concat, throwError, first as first$1, Subject, takeUntil, partition, merge, shareReplay, tap as tap$1, catchError as catchError$1, startWith as startWith$1, pairwise as pairwise$1, groupBy as groupBy$1, mergeMap as mergeMap$1, throttle, race, NEVER, Subscription, retry, debounceTime as debounceTime$1 } from "rxjs";
2
+ import { createClient, CorsOriginError } from "@sanity/client";
3
+ import { pick, omit, isEqual, isObject } from "lodash-es";
3
4
  import { devtools } from "zustand/middleware";
4
5
  import { createStore } from "zustand/vanilla";
5
- import { pick, omit, isEqual, isObject } from "lodash-es";
6
6
  import { first, switchMap as switchMap$1, groupBy, mergeMap, startWith, pairwise, filter as filter$1, map as map$1, delay, tap, catchError, scan, share as share$1, take, debounceTime } from "rxjs/operators";
7
7
  import { createController, createNode } from "@sanity/comlink";
8
8
  import { createSelector } from "reselect";
@@ -17,7 +17,16 @@ import { isKeySegment, isKeyedObject } from "@sanity/types";
17
17
  import { createDocumentLoaderFromClient } from "@sanity/mutate/_unstable_store";
18
18
  import { SDK_CHANNEL_NAME, SDK_NODE_NAME } from "@sanity/message-protocol";
19
19
  import { fromUrl } from "@sanity/bifur-client";
20
- var AuthStateType = /* @__PURE__ */ ((AuthStateType2) => (AuthStateType2.LOGGED_IN = "logged-in", AuthStateType2.LOGGING_IN = "logging-in", AuthStateType2.ERROR = "error", AuthStateType2.LOGGED_OUT = "logged-out", AuthStateType2))(AuthStateType || {});
20
+ const SOURCE_ID = "__sanity_internal_sourceId";
21
+ function datasetSource(projectId, dataset) {
22
+ return { [SOURCE_ID]: { projectId, dataset } };
23
+ }
24
+ function mediaLibrarySource(id) {
25
+ return { [SOURCE_ID]: ["media-library", id] };
26
+ }
27
+ function canvasSource(id) {
28
+ return { [SOURCE_ID]: ["canvas", id] };
29
+ }
21
30
  function getPublishedId(id) {
22
31
  const draftsPrefix = "drafts.";
23
32
  return id.startsWith(draftsPrefix) ? id.slice(draftsPrefix.length) : id;
@@ -105,7 +114,7 @@ function createActionBinder(keyFn) {
105
114
  const instanceRegistry = /* @__PURE__ */ new Map(), storeRegistry = /* @__PURE__ */ new Map();
106
115
  return function(storeDefinition, action) {
107
116
  return function(instance, ...params) {
108
- const keySuffix = keyFn(instance.config), compositeKey = storeDefinition.name + (keySuffix ? `:${keySuffix}` : "");
117
+ const keySuffix = keyFn(instance.config, ...params), compositeKey = storeDefinition.name + (keySuffix ? `:${keySuffix}` : "");
109
118
  let instances = instanceRegistry.get(compositeKey);
110
119
  instances || (instances = /* @__PURE__ */ new Set(), instanceRegistry.set(compositeKey, instances)), instances.has(instance.instanceId) || (instances.add(instance.instanceId), instance.onDispose(() => {
111
120
  instances.delete(instance.instanceId), instances.size === 0 && (storeRegistry.get(compositeKey)?.dispose(), storeRegistry.delete(compositeKey), instanceRegistry.delete(compositeKey));
@@ -119,7 +128,18 @@ const bindActionByDataset = createActionBinder(({ projectId, dataset }) => {
119
128
  if (!projectId || !dataset)
120
129
  throw new Error("This API requires a project ID and dataset configured.");
121
130
  return `${projectId}.${dataset}`;
122
- }), bindActionGlobally = createActionBinder(() => "global");
131
+ }), bindActionBySource = createActionBinder(
132
+ ({ projectId, dataset }, { source }) => {
133
+ if (source) {
134
+ const id = source[SOURCE_ID];
135
+ if (!id) throw new Error("Invalid source (missing ID information)");
136
+ return Array.isArray(id) ? id.join(":") : `${id.projectId}.${id.dataset}`;
137
+ }
138
+ if (!projectId || !dataset)
139
+ throw new Error("This API requires a project ID and dataset configured.");
140
+ return `${projectId}.${dataset}`;
141
+ }
142
+ ), bindActionGlobally = createActionBinder(() => "global");
123
143
  function createStateSourceAction(options) {
124
144
  const selector = typeof options == "function" ? options : options.selector, subscribeHandler = options && "onSubscribe" in options ? options.onSubscribe : void 0, isEqual2 = options && "isEqual" in options ? options.isEqual ?? Object.is : Object.is, selectorContextCache = /* @__PURE__ */ new WeakMap();
125
145
  function stateSourceAction(context, ...params) {
@@ -167,6 +187,7 @@ function createStateSourceAction(options) {
167
187
  }
168
188
  return stateSourceAction;
169
189
  }
190
+ var AuthStateType = /* @__PURE__ */ ((AuthStateType2) => (AuthStateType2.LOGGED_IN = "logged-in", AuthStateType2.LOGGING_IN = "logging-in", AuthStateType2.ERROR = "error", AuthStateType2.LOGGED_OUT = "logged-out", AuthStateType2))(AuthStateType || {});
170
191
  const DEFAULT_BASE = "http://localhost", AUTH_CODE_PARAM = "sid", DEFAULT_API_VERSION$1 = "2021-06-07", REQUEST_TAG_PREFIX = "sanity.sdk.auth", REFRESH_INTERVAL = 12 * 60 * 60 * 1e3, LOCK_NAME = "sanity-token-refresh-lock";
171
192
  function getLastRefreshTime(storageArea, storageKey) {
172
193
  try {
@@ -389,6 +410,21 @@ function getCleanedUrl(locationUrl) {
389
410
  }
390
411
  return loc.searchParams.delete("sid"), loc.searchParams.delete("url"), loc.toString();
391
412
  }
413
+ function getClientErrorApiBody(error) {
414
+ const body = error.response?.body;
415
+ return body && typeof body == "object" ? body : void 0;
416
+ }
417
+ function getClientErrorApiType(error) {
418
+ const body = getClientErrorApiBody(error);
419
+ return body?.error?.type ?? body?.type;
420
+ }
421
+ function getClientErrorApiDescription(error) {
422
+ const body = getClientErrorApiBody(error);
423
+ return body?.error?.description ?? body?.description;
424
+ }
425
+ function isProjectUserNotFoundClientError(error) {
426
+ return getClientErrorApiType(error) === "projectUserNotFoundError";
427
+ }
392
428
  async function checkForCookieAuth(projectId, clientFactory) {
393
429
  if (!projectId) return !1;
394
430
  try {
@@ -404,31 +440,34 @@ async function checkForCookieAuth(projectId, clientFactory) {
404
440
  return !1;
405
441
  }
406
442
  }
407
- function getStudioTokenFromLocalStorage(storageArea, projectId) {
408
- if (!storageArea || !projectId) return null;
409
- const studioStorageKey = `__studio_auth_token_${projectId}`;
410
- return getTokenFromStorage(storageArea, studioStorageKey) || null;
443
+ function getStudioTokenFromLocalStorage(storageArea, storageKey) {
444
+ return !storageArea || !storageKey ? null : getTokenFromStorage(storageArea, storageKey) || null;
411
445
  }
412
446
  const subscribeToStateAndFetchCurrentUser = ({
413
- state
447
+ state,
448
+ instance
414
449
  }) => {
415
- const { clientFactory, apiHost } = state.get().options;
450
+ const { clientFactory, apiHost } = state.get().options, useProjectHostname = !!instance.config.studioMode?.enabled, projectId = instance.config.projectId;
416
451
  return state.observable.pipe(
417
- map(({ authState }) => authState),
452
+ map(({ authState, options }) => ({ authState, authMethod: options.authMethod })),
418
453
  filter(
419
- (authState) => authState.type === AuthStateType.LOGGED_IN && !authState.currentUser
454
+ (value) => value.authState.type === AuthStateType.LOGGED_IN && !value.authState.currentUser
420
455
  ),
421
- map((authState) => authState.token),
422
- distinctUntilChanged()
456
+ map((value) => ({ token: value.authState.token, authMethod: value.authMethod })),
457
+ distinctUntilChanged(
458
+ (prev, curr) => prev.token === curr.token && prev.authMethod === curr.authMethod
459
+ )
423
460
  ).pipe(
424
461
  map(
425
- (token) => clientFactory({
462
+ ({ token, authMethod }) => clientFactory({
426
463
  apiVersion: DEFAULT_API_VERSION$1,
427
464
  requestTagPrefix: REQUEST_TAG_PREFIX,
428
- token,
465
+ token: authMethod === "cookie" ? void 0 : token,
429
466
  ignoreBrowserTokenWarning: !0,
430
- useProjectHostname: !1,
467
+ useProjectHostname,
431
468
  useCdn: !1,
469
+ ...authMethod === "cookie" ? { withCredentials: !0 } : {},
470
+ ...useProjectHostname && projectId ? { projectId } : {},
432
471
  ...apiHost && { apiHost }
433
472
  })
434
473
  ),
@@ -473,8 +512,8 @@ const authStore = {
473
512
  clientFactory = createClient,
474
513
  initialLocationHref = getDefaultLocation()
475
514
  } = instance.config.auth ?? {};
476
- let storageArea = instance.config.auth?.storageArea;
477
- const storageKey = "__sanity_auth_token";
515
+ let storageArea = instance.config.auth?.storageArea, storageKey = "__sanity_auth_token";
516
+ const studioModeEnabled = instance.config.studioMode?.enabled;
478
517
  let loginDomain = "https://www.sanity.io";
479
518
  try {
480
519
  apiHost && new URL(apiHost).hostname.endsWith(".sanity.work") && (loginDomain = "https://www.sanity.work");
@@ -492,13 +531,15 @@ const authStore = {
492
531
  } catch (err) {
493
532
  console.error("Failed to parse dashboard context from initial location:", err);
494
533
  }
495
- isInDashboard || (storageArea = storageArea ?? getDefaultStorage());
534
+ (!isInDashboard || studioModeEnabled) && (storageArea = storageArea ?? getDefaultStorage());
496
535
  let token, authMethod;
497
- instance.config.studioMode?.enabled ? (token = getStudioTokenFromLocalStorage(storageArea, instance.config.projectId), token ? authMethod = "localstorage" : checkForCookieAuth(instance.config.projectId, clientFactory).then((isCookieAuthEnabled) => {
498
- isCookieAuthEnabled && (authMethod = "cookie");
499
- })) : (token = getTokenFromStorage(storageArea, storageKey), token && (authMethod = "localstorage"));
536
+ if (studioModeEnabled) {
537
+ const studioStorageKey = `__studio_auth_token_${instance.config.projectId ?? ""}`;
538
+ storageKey = studioStorageKey, token = getStudioTokenFromLocalStorage(storageArea, studioStorageKey), token && (authMethod = "localstorage");
539
+ } else
540
+ token = getTokenFromStorage(storageArea, storageKey), token && (authMethod = "localstorage");
500
541
  let authState;
501
- return providedToken ? authState = { type: AuthStateType.LOGGED_IN, token: providedToken, currentUser: null } : getAuthCode(callbackUrl, initialLocationHref) || getTokenFromLocation(initialLocationHref) ? authState = { type: AuthStateType.LOGGING_IN, isExchangingToken: !1 } : token && !isInDashboard ? authState = { type: AuthStateType.LOGGED_IN, token, currentUser: null } : authState = { type: AuthStateType.LOGGED_OUT, isDestroyingSession: !1 }, {
542
+ return providedToken ? authState = { type: AuthStateType.LOGGED_IN, token: providedToken, currentUser: null } : token && studioModeEnabled ? authState = { type: AuthStateType.LOGGED_IN, token: token ?? "", currentUser: null } : getAuthCode(callbackUrl, initialLocationHref) || getTokenFromLocation(initialLocationHref) ? authState = { type: AuthStateType.LOGGING_IN, isExchangingToken: !1 } : token && !isInDashboard && !studioModeEnabled ? authState = { type: AuthStateType.LOGGED_IN, token, currentUser: null } : authState = { type: AuthStateType.LOGGED_OUT, isDestroyingSession: !1 }, {
502
543
  authState,
503
544
  dashboardContext,
504
545
  options: {
@@ -517,7 +558,21 @@ const authStore = {
517
558
  },
518
559
  initialize(context) {
519
560
  const subscriptions = [];
520
- return subscriptions.push(subscribeToStateAndFetchCurrentUser(context)), context.state.get().options?.storageArea && subscriptions.push(subscribeToStorageEventsAndSetToken(context)), tokenRefresherRunning || (tokenRefresherRunning = !0, subscriptions.push(refreshStampedToken(context))), () => {
561
+ subscriptions.push(subscribeToStateAndFetchCurrentUser(context)), context.state.get().options?.storageArea && subscriptions.push(subscribeToStorageEventsAndSetToken(context));
562
+ try {
563
+ const { instance, state } = context, studioModeEnabled = !!instance.config.studioMode?.enabled, token = state.get().authState?.type === AuthStateType.LOGGED_IN ? state.get().authState.token : null;
564
+ if (studioModeEnabled && !token) {
565
+ const projectId = instance.config.projectId, clientFactory = state.get().options.clientFactory;
566
+ checkForCookieAuth(projectId, clientFactory).then((isCookieAuthEnabled) => {
567
+ isCookieAuthEnabled && state.set("enableCookieAuth", (prev) => ({
568
+ options: { ...prev.options, authMethod: "cookie" },
569
+ authState: prev.authState.type === AuthStateType.LOGGED_IN ? prev.authState : { type: AuthStateType.LOGGED_IN, token: "", currentUser: null }
570
+ }));
571
+ });
572
+ }
573
+ } catch {
574
+ }
575
+ return tokenRefresherRunning || (tokenRefresherRunning = !0, subscriptions.push(refreshStampedToken(context))), () => {
521
576
  for (const subscription of subscriptions)
522
577
  subscription.unsubscribe();
523
578
  };
@@ -565,13 +620,7 @@ const authStore = {
565
620
  }) : currentAuthState.type !== AuthStateType.LOGGED_OUT && state.set("setToken", {
566
621
  authState: { type: AuthStateType.LOGGED_OUT, isDestroyingSession: !1 }
567
622
  });
568
- });
569
- function compareProjectOrganization(projectId, projectOrganizationId, currentDashboardOrgId) {
570
- return projectOrganizationId !== currentDashboardOrgId ? {
571
- error: `Project ${projectId} belongs to Organization ${projectOrganizationId ?? "unknown"}, but the Dashboard has Organization ${currentDashboardOrgId} selected`
572
- } : { error: null };
573
- }
574
- const DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.sdk", allowedKeys = Object.keys({
623
+ }), DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.sdk", allowedKeys = Object.keys({
575
624
  apiHost: null,
576
625
  useCdn: null,
577
626
  token: null,
@@ -586,7 +635,8 @@ const DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.s
586
635
  apiVersion: null,
587
636
  requestTagPrefix: null,
588
637
  useProjectHostname: null,
589
- "~experimental_resource": null
638
+ "~experimental_resource": null,
639
+ source: null
590
640
  }), DEFAULT_CLIENT_CONFIG = {
591
641
  apiVersion: DEFAULT_API_VERSION,
592
642
  useCdn: !1,
@@ -612,6 +662,10 @@ const DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.s
612
662
  }), getClientConfigKey = (options) => JSON.stringify(pick(options, ...allowedKeys)), getClient = bindActionGlobally(
613
663
  clientStore,
614
664
  ({ state, instance }, options) => {
665
+ if (!options || typeof options != "object")
666
+ throw new Error(
667
+ 'getClient() requires a configuration object with at least an "apiVersion" property. Example: getClient(instance, { apiVersion: "2024-11-12" })'
668
+ );
615
669
  const disallowedKeys = Object.keys(options).filter((key2) => !allowedKeys.includes(key2));
616
670
  if (disallowedKeys.length > 0) {
617
671
  const listFormatter = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
@@ -619,16 +673,22 @@ const DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.s
619
673
  `The client options provided contains unsupported properties: ${listFormatter.format(disallowedKeys)}. Allowed keys are: ${listFormatter.format(allowedKeys)}.`
620
674
  );
621
675
  }
622
- const tokenFromState = state.get().token, { clients, authMethod } = state.get(), projectId = options.projectId ?? instance.config.projectId, dataset = options.dataset ?? instance.config.dataset, apiHost = options.apiHost ?? instance.config.auth?.apiHost, effectiveOptions = {
676
+ const tokenFromState = state.get().token, { clients, authMethod } = state.get(), hasSource = !!options.source;
677
+ let sourceId = options.source?.[SOURCE_ID], resource;
678
+ Array.isArray(sourceId) && (resource = { type: sourceId[0], id: sourceId[1] }, sourceId = void 0);
679
+ const projectId = options.projectId ?? instance.config.projectId, dataset = options.dataset ?? instance.config.dataset, apiHost = options.apiHost ?? instance.config.auth?.apiHost, effectiveOptions = {
623
680
  ...DEFAULT_CLIENT_CONFIG,
624
- ...(options.scope === "global" || !projectId) && { useProjectHostname: !1 },
681
+ ...(options.scope === "global" || !projectId || hasSource) && { useProjectHostname: !1 },
625
682
  token: authMethod === "cookie" ? void 0 : tokenFromState ?? void 0,
626
683
  ...options,
627
684
  ...projectId && { projectId },
628
685
  ...dataset && { dataset },
629
- ...apiHost && { apiHost }
686
+ ...apiHost && { apiHost },
687
+ ...resource && { "~experimental_resource": resource }
630
688
  };
631
- effectiveOptions.token === null || typeof effectiveOptions.token > "u" ? (delete effectiveOptions.token, authMethod === "cookie" && (effectiveOptions.withCredentials = !0)) : delete effectiveOptions.withCredentials;
689
+ hasSource && ((options.projectId || options.dataset) && console.warn(
690
+ "Both source and explicit projectId/dataset are provided. The source will be used and projectId/dataset will be ignored."
691
+ ), delete effectiveOptions.projectId, delete effectiveOptions.dataset), effectiveOptions.token === null || typeof effectiveOptions.token > "u" ? (delete effectiveOptions.token, authMethod === "cookie" && (effectiveOptions.withCredentials = !0)) : delete effectiveOptions.withCredentials;
632
692
  const key = getClientConfigKey(effectiveOptions);
633
693
  if (clients[key]) return clients[key];
634
694
  const client = createClient(effectiveOptions);
@@ -637,7 +697,47 @@ const DEFAULT_API_VERSION = "2024-11-12", DEFAULT_REQUEST_TAG_PREFIX = "sanity.s
637
697
  ), getClientState = bindActionGlobally(
638
698
  clientStore,
639
699
  createStateSourceAction(({ instance }, options) => getClient(instance, options))
640
- );
700
+ ), API_VERSION$6 = "vX";
701
+ function agentGenerate(instance, options) {
702
+ return getClientState(instance, {
703
+ apiVersion: API_VERSION$6,
704
+ projectId: instance.config.projectId,
705
+ dataset: instance.config.dataset
706
+ }).observable.pipe(switchMap((client) => client.observable.agent.action.generate(options)));
707
+ }
708
+ function agentTransform(instance, options) {
709
+ return getClientState(instance, {
710
+ apiVersion: API_VERSION$6,
711
+ projectId: instance.config.projectId,
712
+ dataset: instance.config.dataset
713
+ }).observable.pipe(switchMap((client) => client.observable.agent.action.transform(options)));
714
+ }
715
+ function agentTranslate(instance, options) {
716
+ return getClientState(instance, {
717
+ apiVersion: API_VERSION$6,
718
+ projectId: instance.config.projectId,
719
+ dataset: instance.config.dataset
720
+ }).observable.pipe(switchMap((client) => client.observable.agent.action.translate(options)));
721
+ }
722
+ function agentPrompt(instance, options) {
723
+ return getClientState(instance, {
724
+ apiVersion: API_VERSION$6,
725
+ projectId: instance.config.projectId,
726
+ dataset: instance.config.dataset
727
+ }).observable.pipe(switchMap((client) => from(client.agent.action.prompt(options))));
728
+ }
729
+ function agentPatch(instance, options) {
730
+ return getClientState(instance, {
731
+ apiVersion: API_VERSION$6,
732
+ projectId: instance.config.projectId,
733
+ dataset: instance.config.dataset
734
+ }).observable.pipe(switchMap((client) => from(client.agent.action.patch(options))));
735
+ }
736
+ function compareProjectOrganization(projectId, projectOrganizationId, currentDashboardOrgId) {
737
+ return projectOrganizationId !== currentDashboardOrgId ? {
738
+ error: `Project ${projectId} belongs to Organization ${projectOrganizationId ?? "unknown"}, but the Dashboard has Organization ${currentDashboardOrgId} selected`
739
+ } : { error: null };
740
+ }
641
741
  function createFetcherStore({
642
742
  name,
643
743
  fetcher: getObservable,
@@ -1059,11 +1159,12 @@ const API_VERSION$4 = "v2025-02-19", datasets = createFetcherStore({
1059
1159
  useProjectHostname: !0
1060
1160
  }).observable.pipe(switchMap((client) => client.observable.datasets.list()))
1061
1161
  }), getDatasetsState = datasets.getState, resolveDatasets = datasets.resolveState, isSanityMutatePatch = (value) => !(typeof value != "object" || !value || !("type" in value) || typeof value.type != "string" || value.type !== "patch" || !("id" in value) || typeof value.id != "string" || !("patches" in value) || !Array.isArray(value.patches));
1062
- function createDocument(doc) {
1162
+ function createDocument(doc, initialValue) {
1063
1163
  return {
1064
1164
  type: "document.create",
1065
1165
  ...doc,
1066
- ...doc.documentId && { documentId: getPublishedId(doc.documentId) }
1166
+ ...doc.documentId && { documentId: getPublishedId(doc.documentId) },
1167
+ ...initialValue && { initialValue }
1067
1168
  };
1068
1169
  }
1069
1170
  function deleteDocument(doc) {
@@ -1772,7 +1873,17 @@ function processActions({
1772
1873
  transactionId,
1773
1874
  message: "A draft version of this document already exists. Please use or discard the existing draft before creating a new one."
1774
1875
  });
1775
- const newDocBase = { ...base[publishedId], _type: action.documentType, _id: draftId }, newDocWorking = { ...working[publishedId], _type: action.documentType, _id: draftId }, mutations = [{ create: newDocWorking }];
1876
+ const newDocBase = {
1877
+ ...base[publishedId],
1878
+ _type: action.documentType,
1879
+ _id: draftId,
1880
+ ...action.initialValue
1881
+ }, newDocWorking = {
1882
+ ...working[publishedId],
1883
+ _type: action.documentType,
1884
+ _id: draftId,
1885
+ ...action.initialValue
1886
+ }, mutations = [{ create: newDocWorking }];
1776
1887
  if (base = processMutations({
1777
1888
  documents: base,
1778
1889
  transactionId,
@@ -3233,6 +3344,7 @@ const queryStore = {
3233
3344
  projectId,
3234
3345
  dataset,
3235
3346
  tag,
3347
+ source,
3236
3348
  perspective: perspectiveFromOptions,
3237
3349
  ...restOptions
3238
3350
  } = parseQueryKey(group$.key), perspective$ = getPerspectiveState(instance, {
@@ -3240,7 +3352,8 @@ const queryStore = {
3240
3352
  }).observable.pipe(filter(Boolean)), client$ = getClientState(instance, {
3241
3353
  apiVersion: QUERY_STORE_API_VERSION,
3242
3354
  projectId,
3243
- dataset
3355
+ dataset,
3356
+ source
3244
3357
  }).observable;
3245
3358
  return combineLatest([lastLiveEventId$, client$, perspective$]).pipe(
3246
3359
  switchMap(
@@ -3303,7 +3416,7 @@ const queryStore = {
3303
3416
  function getQueryState(...args) {
3304
3417
  return _getQueryState(...args);
3305
3418
  }
3306
- const _getQueryState = bindActionByDataset(
3419
+ const _getQueryState = bindActionBySource(
3307
3420
  queryStore,
3308
3421
  createStateSourceAction({
3309
3422
  selector: ({ state, instance }, options) => {
@@ -3326,7 +3439,7 @@ const _getQueryState = bindActionByDataset(
3326
3439
  function resolveQuery(...args) {
3327
3440
  return _resolveQuery(...args);
3328
3441
  }
3329
- const _resolveQuery = bindActionByDataset(
3442
+ const _resolveQuery = bindActionBySource(
3330
3443
  queryStore,
3331
3444
  ({ state, instance }, { signal, ...options }) => {
3332
3445
  const normalized = normalizeOptionsWithPerspective(instance, options), { getCurrent } = getQueryState(instance, normalized), key = getQueryKey(normalized), aborted$ = signal ? new Observable((observer) => {
@@ -3883,12 +3996,18 @@ function getCorsErrorProjectId(error) {
3883
3996
  const projMatch = (error.message || "").match(/manage\/project\/([^/?#]+)/);
3884
3997
  return projMatch ? projMatch[1] : null;
3885
3998
  }
3886
- var version = "2.3.0";
3999
+ var version = "2.4.0";
3887
4000
  const CORE_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
3888
4001
  export {
3889
4002
  AuthStateType,
3890
4003
  CORE_SDK_VERSION,
4004
+ agentGenerate,
4005
+ agentPatch,
4006
+ agentPrompt,
4007
+ agentTransform,
4008
+ agentTranslate,
3891
4009
  applyDocumentActions,
4010
+ canvasSource,
3892
4011
  createDatasetHandle,
3893
4012
  createDocument,
3894
4013
  createDocumentHandle,
@@ -3896,6 +4015,7 @@ export {
3896
4015
  createGroqSearchFilter,
3897
4016
  createProjectHandle,
3898
4017
  createSanityInstance,
4018
+ datasetSource,
3899
4019
  defineIntent,
3900
4020
  deleteDocument,
3901
4021
  destroyController,
@@ -3904,6 +4024,9 @@ export {
3904
4024
  getActiveReleasesState,
3905
4025
  getAuthState,
3906
4026
  getClient,
4027
+ getClientErrorApiBody,
4028
+ getClientErrorApiDescription,
4029
+ getClientErrorApiType,
3907
4030
  getClientState,
3908
4031
  getCorsErrorProjectId,
3909
4032
  getCurrentUserState,
@@ -3934,10 +4057,12 @@ export {
3934
4057
  getUsersKey,
3935
4058
  getUsersState,
3936
4059
  handleAuthCallback,
4060
+ isProjectUserNotFoundClientError,
3937
4061
  joinPaths,
3938
4062
  jsonMatch2 as jsonMatch,
3939
4063
  loadMoreUsers,
3940
4064
  logout,
4065
+ mediaLibrarySource,
3941
4066
  observeOrganizationVerificationState,
3942
4067
  parseQueryKey,
3943
4068
  parseUsersKey,