@sanity/sdk 2.9.0 → 2.10.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/_chunks-dts/utils.d.ts +105 -51
- package/dist/_chunks-es/createGroqSearchFilter.js +131 -54
- package/dist/_chunks-es/createGroqSearchFilter.js.map +1 -1
- package/dist/_chunks-es/version.js +1 -1
- package/dist/_exports/_internal.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +119 -73
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/_exports/index.ts +8 -0
- package/src/client/clientStore.test.ts +30 -30
- package/src/client/clientStore.ts +47 -47
- package/src/comlink/controller/actions/getOrCreateChannel.ts +2 -2
- package/src/comlink/node/actions/getOrCreateNode.ts +2 -2
- package/src/config/sanityConfig.ts +72 -12
- package/src/document/applyDocumentActions.test.ts +7 -7
- package/src/document/applyDocumentActions.ts +5 -5
- package/src/document/documentStore.test.ts +68 -62
- package/src/document/documentStore.ts +36 -36
- package/src/document/processActions.ts +2 -2
- package/src/document/reducers.ts +4 -4
- package/src/document/sharedListener.ts +7 -7
- package/src/presence/bifurTransport.test.ts +46 -6
- package/src/presence/bifurTransport.ts +13 -1
- package/src/presence/presenceStore.test.ts +96 -0
- package/src/presence/presenceStore.ts +96 -24
- package/src/preview/getPreviewState.ts +1 -1
- package/src/preview/previewProjectionUtils.test.ts +4 -4
- package/src/preview/previewProjectionUtils.ts +7 -7
- package/src/preview/resolvePreview.ts +5 -1
- package/src/projection/getProjectionState.ts +4 -4
- package/src/projection/projectionStore.test.ts +2 -2
- package/src/projection/resolveProjection.ts +2 -2
- package/src/projection/subscribeToStateAndFetchBatches.test.ts +1 -1
- package/src/projection/subscribeToStateAndFetchBatches.ts +12 -11
- package/src/query/queryStore.test.ts +12 -12
- package/src/query/queryStore.ts +10 -10
- package/src/query/reducers.ts +3 -3
- package/src/releases/getPerspectiveState.ts +5 -5
- package/src/releases/releasesStore.test.ts +6 -6
- package/src/releases/releasesStore.ts +9 -9
- package/src/store/createActionBinder.test.ts +31 -31
- package/src/store/createActionBinder.ts +43 -38
- package/src/store/createSanityInstance.ts +2 -3
- package/src/users/reducers.ts +3 -4
- package/src/utils/createFetcherStore.ts +6 -4
- package/src/utils/isImportError.test.ts +72 -0
- package/src/utils/isImportError.ts +34 -0
- package/src/utils/object.test.ts +95 -0
- package/src/utils/object.ts +142 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as createGroqSearchFilter, Sr as isStudioConfig, U as getUsersKey, W as parseUsersKey, Y as getQueryKey, Z as parseQueryKey, a as isProjectUserNotFoundClientError, br as SanityInstance, ct as PREVIEW_PROJECTION, i as getClientErrorApiType, n as getClientErrorApiBody, r as getClientErrorApiDescription, st as transformProjectionToPreview, t as ApiErrorBody } from "../_chunks-dts/utils.js";
|
|
2
2
|
import { SanityClient } from "@sanity/client";
|
|
3
3
|
/**
|
|
4
4
|
* Manages dev-mode telemetry for a single SDK instance.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { ActionErrorEvent, ActionsResult, AgentGenerateOptions, AgentGenerateResult, AgentPatchOptions, AgentPatchResult, AgentPromptOptions, AgentPromptResult, AgentTransformOptions, AgentTransformResult, AgentTranslateOptions, AgentTranslateResult, ApiErrorBody, ApplyDocumentActionsOptions, AuthConfig, AuthProvider, AuthState, AuthStateType, AuthStoreState, CORE_SDK_VERSION, CanvasSource, ClientOptions, ClientStoreState as ClientState, ComlinkControllerState, ComlinkNodeState, CreateDocumentAction, CurrentUser, DatasetHandle, DatasetSource, DeleteDocumentAction, DiscardDocumentAction, DisconnectEvent, DocumentAction, DocumentCreatedEvent, DocumentDeletedEvent, DocumentDiscardedEvent, DocumentEditedEvent, DocumentEvent, DocumentHandle, DocumentOptions, DocumentPermissionsResult, DocumentPublishedEvent, DocumentSource, DocumentTransactionSubmissionResult, DocumentTypeHandle, DocumentUnpublishedEvent, EditDocumentAction, ErrorAuthState, FavoriteStatusResponse, FetcherStore, FetcherStoreState, FrameMessage, GetPreviewStateOptions, GetUserOptions, GetUsersOptions, InstanceContext, Intent, IntentFilter, JsonMatch, LogContext, LogLevel, LogNamespace, LoggedInAuthState, LoggedOutAuthState, Logger, LoggerConfig, LoggingInAuthState, MediaLibrarySource, Membership, NewTokenResponseMessage, NodeState, OrgVerificationResult, PREVIEW_PROJECTION, PermissionDeniedReason, PerspectiveHandle, PresenceLocation, PreviewMedia, PreviewQueryResult, PreviewStoreState, PreviewValue, ProjectHandle, ProjectionValuePending, PublishDocumentAction, QueryOptions, ReleaseDocument, ReleasePerspective, RequestNewTokenMessage, ResolvePreviewOptions, ResolveUserOptions, ResolveUsersOptions, Role, RollCallEvent, SanityConfig, SanityDocument, SanityInstance, SanityProject, SanityUser, SanityUserResponse, Selector, StateEvent, StateSource, StudioConfig, TokenSource, TransactionAcceptedEvent, TransactionRevertedEvent, TransportEvent, UnpublishDocumentAction, UserPresence, UserProfile, UsersGroupState, UsersStoreState, ValidProjection, ValuePending, WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createSanityInstance, defineIntent, deleteDocument, destroyController, discardDocument, editDocument, getActiveReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasSource, isDatasetSource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unpublishDocument };
|
|
1
|
+
import { $ as getProjectsState, $n as getClientState, $t as getDocumentState, A as isImportError, An as Logger, Ar as DocumentSource, At as SanityUser, B as loadMoreUsers, Bn as releaseNode, Br as isCanvasResource, Bt as applyDocumentActions, C as getIndexForKey, Cn as getDatasetsState, Cr as CanvasResource, Ct as TransportEvent, D as slicePath, Dn as LogContext, Dr as DatasetSource, Dt as Membership, E as jsonMatch, En as InstanceContext, Er as DatasetResource, Et as GetUsersOptions, F as createGroqSearchFilter, Fn as createProjectHandle, Fr as ProjectHandle, Ft as FavoriteStatusResponse, G as getPerspectiveState, Gn as releaseChannel, Gr as isMediaLibrarySource, Gt as DocumentEditedEvent, H as resolveUsers, Hn as destroyController, Hr as isDatasetResource, Ht as DocumentCreatedEvent, I as FetcherStore, In as NodeState, Ir as ReleasePerspective, It as getFavoritesState, J as QueryOptions, Jn as RequestNewTokenMessage, Jt as DocumentTransactionSubmissionResult, K as ReleaseDocument, Kn as FrameMessage, Kr as AuthConfig, Kt as DocumentEvent, L as FetcherStoreState, Ln as getNodeState, Lr as SanityConfig, Lt as resolveFavoritesState, M as Intent, Mn as createDatasetHandle, Mr as MediaLibraryResource, Mt as UserProfile, N as IntentFilter, Nn as createDocumentHandle, Nr as MediaLibrarySource, Nt as UsersGroupState, O as stringifyPath, On as LogLevel, Or as DocumentHandle, Ot as ResolveUserOptions, P as defineIntent, Pn as createDocumentTypeHandle, Pr as PerspectiveHandle, Pt as UsersStoreState, Q as resolveQuery, Qn as getClient, Qt as DocumentOptions, R as getUserState, Rn as ComlinkNodeState, Rr as StudioConfig, Rt as ActionsResult, S as SanityProject, Sn as unpublishDocument, Sr as isStudioConfig, St as StateEvent, T as joinPaths, Tn as configureLogging, Tr as DatasetHandle, Tt as GetUserOptions, U as getUsersKey, Un as getOrCreateChannel, Ur as isDatasetSource, Ut as DocumentDeletedEvent, V as resolveUser, Vn as ComlinkControllerState, Vr as isCanvasSource, Vt as ActionErrorEvent, W as parseUsersKey, Wn as getOrCreateController, Wr as isMediaLibraryResource, Wt as DocumentDiscardedEvent, X as getQueryState, Xn as ClientOptions, Xt as TransactionAcceptedEvent, Y as getQueryKey, Yn as WindowMessage, Yt as DocumentUnpublishedEvent, Z as parseQueryKey, Zn as ClientStoreState, Zt as TransactionRevertedEvent, _ as getTokenState, _n as createDocument, _r as agentPrompt, _t as ValidProjection, a as isProjectUserNotFoundClientError, an as DocumentPermissionsResult, ar as AgentGenerateOptions, at as ResolvePreviewOptions, b as Role, bn as editDocument, br as SanityInstance, bt as PresenceLocation, c as ErrorAuthState, cn as Selector, cr as AgentPatchResult, ct as PREVIEW_PROJECTION, d as LoggingInAuthState, dn as DeleteDocumentAction, dr as AgentTransformOptions, dt as PreviewMedia, en as getDocumentSyncStatus, er as logout, et as resolveProjects, f as getAuthState, fn as DiscardDocumentAction, fr as AgentTransformResult, ft as PreviewQueryResult, g as getLoginUrlState, gn as UnpublishDocumentAction, gr as agentPatch, gt as ProjectionValuePending, h as getIsInDashboardState, hn as PublishDocumentAction, hr as agentGenerate, ht as ValuePending, i as getClientErrorApiType, in as subscribeDocumentEvents, ir as AuthStateType, it as resolveProject, j as getCorsErrorProjectId, jn as LoggerConfig, jr as DocumentTypeHandle, jt as SanityUserResponse, k as CORE_SDK_VERSION, kn as LogNamespace, kr as DocumentResource, kt as ResolveUsersOptions, l as LoggedInAuthState, ln as StateSource, lr as AgentPromptOptions, lt as GetPreviewStateOptions, m as getDashboardOrganizationId, mn as EditDocumentAction, mr as AgentTranslateResult, mt as PreviewValue, n as getClientErrorApiBody, nn as resolveDocument, nr as observeOrganizationVerificationState, nt as getProjectionState, o as AuthState, on as PermissionDeniedReason, or as AgentGenerateResult, ot as resolvePreview, p as getCurrentUserState, pn as DocumentAction, pr as AgentTranslateOptions, pt as PreviewStoreState, q as getActiveReleasesState, qn as NewTokenResponseMessage, qr as AuthProvider, qt as DocumentPublishedEvent, r as getClientErrorApiDescription, rn as resolvePermissions, rr as OrgVerificationResult, rt as getProjectState, s as AuthStoreState, sn as JsonMatch, sr as AgentPatchOptions, st as transformProjectionToPreview, t as ApiErrorBody, tn as getPermissionsState, tr as handleAuthCallback, tt as resolveProjection, u as LoggedOutAuthState, un as CreateDocumentAction, ur as AgentPromptResult, ut as getPreviewState, v as setAuthToken, vn as deleteDocument, vr as agentTransform, vt as getPresence, w as getPathDepth, wn as resolveDatasets, wr as CanvasSource, wt as UserPresence, x as SanityDocument, xn as publishDocument, xr as createSanityInstance, xt as RollCallEvent, y as CurrentUser, yn as discardDocument, yr as agentTranslate, yt as DisconnectEvent, z as getUsersState, zn as getOrCreateNode, zr as TokenSource, zt as ApplyDocumentActionsOptions } from "./_chunks-dts/utils.js";
|
|
2
|
+
export { ActionErrorEvent, ActionsResult, AgentGenerateOptions, AgentGenerateResult, AgentPatchOptions, AgentPatchResult, AgentPromptOptions, AgentPromptResult, AgentTransformOptions, AgentTransformResult, AgentTranslateOptions, AgentTranslateResult, ApiErrorBody, ApplyDocumentActionsOptions, AuthConfig, AuthProvider, AuthState, AuthStateType, AuthStoreState, CORE_SDK_VERSION, CanvasResource, CanvasSource, ClientOptions, ClientStoreState as ClientState, ComlinkControllerState, ComlinkNodeState, CreateDocumentAction, CurrentUser, DatasetHandle, DatasetResource, DatasetSource, DeleteDocumentAction, DiscardDocumentAction, DisconnectEvent, DocumentAction, DocumentCreatedEvent, DocumentDeletedEvent, DocumentDiscardedEvent, DocumentEditedEvent, DocumentEvent, DocumentHandle, DocumentOptions, DocumentPermissionsResult, DocumentPublishedEvent, DocumentResource, DocumentSource, DocumentTransactionSubmissionResult, DocumentTypeHandle, DocumentUnpublishedEvent, EditDocumentAction, ErrorAuthState, FavoriteStatusResponse, FetcherStore, FetcherStoreState, FrameMessage, GetPreviewStateOptions, GetUserOptions, GetUsersOptions, InstanceContext, Intent, IntentFilter, JsonMatch, LogContext, LogLevel, LogNamespace, LoggedInAuthState, LoggedOutAuthState, Logger, LoggerConfig, LoggingInAuthState, MediaLibraryResource, MediaLibrarySource, Membership, NewTokenResponseMessage, NodeState, OrgVerificationResult, PREVIEW_PROJECTION, PermissionDeniedReason, PerspectiveHandle, PresenceLocation, PreviewMedia, PreviewQueryResult, PreviewStoreState, PreviewValue, ProjectHandle, ProjectionValuePending, PublishDocumentAction, QueryOptions, ReleaseDocument, ReleasePerspective, RequestNewTokenMessage, ResolvePreviewOptions, ResolveUserOptions, ResolveUsersOptions, Role, RollCallEvent, SanityConfig, SanityDocument, SanityInstance, SanityProject, SanityUser, SanityUserResponse, Selector, StateEvent, StateSource, StudioConfig, TokenSource, TransactionAcceptedEvent, TransactionRevertedEvent, TransportEvent, UnpublishDocumentAction, UserPresence, UserProfile, UsersGroupState, UsersStoreState, ValidProjection, ValuePending, WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createSanityInstance, defineIntent, deleteDocument, destroyController, discardDocument, editDocument, getActiveReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isCanvasSource, isDatasetResource, isDatasetSource, isImportError, isMediaLibraryResource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unpublishDocument };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { switchMap, from, firstValueFrom, EMPTY, asapScheduler, distinctUntilChanged, map as map$1, combineLatest, of, concatMap, withLatestFrom, filter as filter$1, concat, timer, throwError, first as first$1, Subject, takeUntil, share, 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, skip, Observable, NEVER, fromEvent, Subscription, debounceTime, defer } from "rxjs";
|
|
2
|
-
import { createLogger, insecureRandomId, getClientState, bindActionGlobally,
|
|
3
|
-
import { createGroqSearchFilter, getActiveReleasesState, getAuthState, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getCurrentUserState, getIsInDashboardState, getLoginUrlState, getPerspectiveState, getQueryKey, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, setAuthToken } from "./_chunks-es/createGroqSearchFilter.js";
|
|
4
|
-
import { pick, omit, isEqual } from "lodash-es";
|
|
2
|
+
import { createLogger, pickProperties, insecureRandomId, getClientState, bindActionGlobally, createStateSourceAction, setCleanupTimeout, omitProperty, defineStore, authStore, AuthStateType, getCleanedUrl, getTokenFromLocation, createLoggedInAuthState, getAuthCode, REQUEST_TAG_PREFIX, DEFAULT_API_VERSION, getDefaultLocation, isDeepEqual, configureLogging as configureLogging$1, isReleasePerspective, isDatasetResource, bindActionByResource, isMediaLibraryResource, isCanvasResource, getUsersKey, addSubscription, parseUsersKey, getClient, PROJECT_API_VERSION, setUsersError, setUsersData, API_VERSION as API_VERSION$6, getDashboardOrganizationId as getDashboardOrganizationId$1, USERS_STATE_CLEAR_DELAY, removeSubscription, updateLastLoadMoreRequest, cancelRequest, initializeRequest, getTokenState, getQueryState, resolveQuery, bindActionByResourceAndPerspective, PREVIEW_PROJECTION, transformProjectionToPreview } from "./_chunks-es/createGroqSearchFilter.js";
|
|
3
|
+
import { createGroqSearchFilter, getActiveReleasesState, getAuthState, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getCurrentUserState, getIsInDashboardState, getLoginUrlState, getPerspectiveState, getQueryKey, isCanvasSource, isDatasetSource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, setAuthToken } from "./_chunks-es/createGroqSearchFilter.js";
|
|
5
4
|
import { first, switchMap as switchMap$1, groupBy, mergeMap, startWith, pairwise, filter, map, delay, tap, catchError, scan, share as share$1 } from "rxjs/operators";
|
|
6
5
|
import { createController, createNode } from "@sanity/comlink";
|
|
7
6
|
import { createSelector } from "reselect";
|
|
8
7
|
import { SanityEncoder } from "@sanity/mutate";
|
|
9
|
-
import { getVersionId,
|
|
8
|
+
import { getVersionId, DocumentId, getPublishedId, getDraftId, isDraftId, isVersionId, isPublishedId } from "@sanity/id-utils";
|
|
10
9
|
import { jsonMatch, stringifyPath, slicePath, getIndexForKey } from "@sanity/json-match";
|
|
11
10
|
import { getIndexForKey as getIndexForKey2, getPathDepth, joinPaths, jsonMatch as jsonMatch2, slicePath as slicePath2, stringifyPath as stringifyPath2 } from "@sanity/json-match";
|
|
12
11
|
import { evaluateSync, parse } from "groq-js";
|
|
@@ -82,7 +81,7 @@ function createSanityInstance(config = {}) {
|
|
|
82
81
|
}), child;
|
|
83
82
|
},
|
|
84
83
|
match: (targetConfig) => {
|
|
85
|
-
if (Object.entries(
|
|
84
|
+
if (Object.entries(pickProperties(targetConfig, ["auth", "projectId", "dataset"])).every(
|
|
86
85
|
([key, value]) => config[key] === value
|
|
87
86
|
))
|
|
88
87
|
return instance;
|
|
@@ -193,8 +192,8 @@ function createFetcherStore({
|
|
|
193
192
|
stateByParams: {
|
|
194
193
|
...prev.stateByParams,
|
|
195
194
|
[entry.key]: {
|
|
196
|
-
...
|
|
197
|
-
...
|
|
195
|
+
...omitProperty(entry, "error"),
|
|
196
|
+
...prev.stateByParams[entry.key] ? omitProperty(prev.stateByParams[entry.key], "error") : {},
|
|
198
197
|
data
|
|
199
198
|
}
|
|
200
199
|
}
|
|
@@ -246,7 +245,7 @@ function createFetcherStore({
|
|
|
246
245
|
const entry = prev.stateByParams[key];
|
|
247
246
|
if (!entry) return prev;
|
|
248
247
|
const newSubs = (entry.subscriptions || []).filter((id) => id !== subscriptionId);
|
|
249
|
-
return newSubs.length === 0 ? { stateByParams:
|
|
248
|
+
return newSubs.length === 0 ? { stateByParams: omitProperty(prev.stateByParams, key) } : {
|
|
250
249
|
stateByParams: {
|
|
251
250
|
...prev.stateByParams,
|
|
252
251
|
[key]: {
|
|
@@ -403,7 +402,7 @@ const handleAuthCallback = bindActionGlobally(
|
|
|
403
402
|
throw new Error("Controller must be initialized before using or creating channels");
|
|
404
403
|
const channels = state.get().channels, existing = channels.get(options.name);
|
|
405
404
|
if (existing) {
|
|
406
|
-
if (!
|
|
405
|
+
if (!isDeepEqual(existing.options, options))
|
|
407
406
|
throw new Error(`Channel "${options.name}" already exists with different options`);
|
|
408
407
|
return state.set("incrementChannelRefCount", {
|
|
409
408
|
channels: new Map(channels).set(options.name, {
|
|
@@ -465,7 +464,7 @@ const handleAuthCallback = bindActionGlobally(
|
|
|
465
464
|
), releaseChannel = bindActionGlobally(comlinkControllerStore, releaseChannel$1), getOrCreateNode$1 = ({ state }, options) => {
|
|
466
465
|
const nodes = state.get().nodes, existing = nodes.get(options.name);
|
|
467
466
|
if (existing) {
|
|
468
|
-
if (!
|
|
467
|
+
if (!isDeepEqual(existing.options, options))
|
|
469
468
|
throw new Error(`Node "${options.name}" already exists with different options`);
|
|
470
469
|
return existing.node.start(), existing.node;
|
|
471
470
|
}
|
|
@@ -1562,7 +1561,7 @@ function processActions({
|
|
|
1562
1561
|
transactionId,
|
|
1563
1562
|
message: `Cannot publish because no draft version was found for document "${documentId}".`
|
|
1564
1563
|
});
|
|
1565
|
-
if (!
|
|
1564
|
+
if (!isDeepEqual(workingDraft, baseDraft))
|
|
1566
1565
|
throw new ActionError({
|
|
1567
1566
|
documentId,
|
|
1568
1567
|
transactionId,
|
|
@@ -1841,7 +1840,7 @@ function revertOutgoingTransaction(prev) {
|
|
|
1841
1840
|
const next = {
|
|
1842
1841
|
...documentState,
|
|
1843
1842
|
local: documentId in working ? working[documentId] : local,
|
|
1844
|
-
unverifiedRevisions: prev.outgoing && prev.outgoing.transactionId in unverifiedRevisions ?
|
|
1843
|
+
unverifiedRevisions: prev.outgoing && prev.outgoing.transactionId in unverifiedRevisions ? omitProperty(unverifiedRevisions, prev.outgoing.transactionId) : unverifiedRevisions
|
|
1845
1844
|
};
|
|
1846
1845
|
return [documentId, next];
|
|
1847
1846
|
})
|
|
@@ -1854,7 +1853,7 @@ function applyRemoteDocument(prev, { document, documentId, previousRev, revision
|
|
|
1854
1853
|
if (!prevDocState) return prev;
|
|
1855
1854
|
const prevUnverifiedRevisions = prevDocState.unverifiedRevisions, revisionToVerify = revision ? prevUnverifiedRevisions?.[revision] : void 0;
|
|
1856
1855
|
let unverifiedRevisions = prevUnverifiedRevisions ?? EMPTY_REVISIONS;
|
|
1857
|
-
if (revision && revisionToVerify && (unverifiedRevisions =
|
|
1856
|
+
if (revision && revisionToVerify && (unverifiedRevisions = omitProperty(prevUnverifiedRevisions, revision)), type === "sync" && (unverifiedRevisions = Object.fromEntries(
|
|
1858
1857
|
Object.entries(unverifiedRevisions).filter(([, unverifiedRevision]) => unverifiedRevision ? new Date(timestamp).getTime() <= new Date(unverifiedRevision.timestamp).getTime() : !1)
|
|
1859
1858
|
)), revisionToVerify && revisionToVerify.previousRev === previousRev)
|
|
1860
1859
|
return {
|
|
@@ -1925,7 +1924,7 @@ function removeSubscriptionIdFromDocument(prev, documentId, subscriptionId) {
|
|
|
1925
1924
|
...prev.documentStates,
|
|
1926
1925
|
[documentId]: { ...prevDocState, subscriptions }
|
|
1927
1926
|
}
|
|
1928
|
-
} : { ...prev, documentStates:
|
|
1927
|
+
} : { ...prev, documentStates: omitProperty(prev.documentStates, documentId) } : prev;
|
|
1929
1928
|
}
|
|
1930
1929
|
function manageSubscriberIds({ state }, handles) {
|
|
1931
1930
|
const documentIds = getDocumentIdsFromHandleLikes(handles), subscriptionId = insecureRandomId();
|
|
@@ -1979,11 +1978,11 @@ function getDocumentEvents(outgoing) {
|
|
|
1979
1978
|
);
|
|
1980
1979
|
}
|
|
1981
1980
|
const API_VERSION$1 = "v2025-05-06";
|
|
1982
|
-
function createSharedListener(instance,
|
|
1981
|
+
function createSharedListener(instance, resource) {
|
|
1983
1982
|
const dispose$ = new Subject(), events$ = getClientState(instance, {
|
|
1984
1983
|
apiVersion: API_VERSION$1,
|
|
1985
|
-
// TODO: remove in v3 when we're ready for everything to be queried via
|
|
1986
|
-
|
|
1984
|
+
// TODO: remove in v3 when we're ready for everything to be queried via resource
|
|
1985
|
+
resource: resource && !isDatasetResource(resource) ? resource : void 0
|
|
1987
1986
|
}).observable.pipe(
|
|
1988
1987
|
switchMap(
|
|
1989
1988
|
(client) => (
|
|
@@ -2017,12 +2016,12 @@ function createSharedListener(instance, source) {
|
|
|
2017
2016
|
dispose: () => dispose$.next()
|
|
2018
2017
|
};
|
|
2019
2018
|
}
|
|
2020
|
-
function createFetchDocument(instance,
|
|
2019
|
+
function createFetchDocument(instance, resource) {
|
|
2021
2020
|
return function(documentId) {
|
|
2022
2021
|
return getClientState(instance, {
|
|
2023
2022
|
apiVersion: API_VERSION$1,
|
|
2024
|
-
// TODO: remove in v3 when we're ready for everything to be queried via
|
|
2025
|
-
|
|
2023
|
+
// TODO: remove in v3 when we're ready for everything to be queried via resource
|
|
2024
|
+
resource: resource && !isDatasetResource(resource) ? resource : void 0
|
|
2026
2025
|
}).observable.pipe(
|
|
2027
2026
|
switchMap((client) => createDocumentLoaderFromClient(client)(documentId)),
|
|
2028
2027
|
map$1((result) => {
|
|
@@ -2038,13 +2037,13 @@ function createFetchDocument(instance, source) {
|
|
|
2038
2037
|
}
|
|
2039
2038
|
const documentStore = defineStore({
|
|
2040
2039
|
name: "Document",
|
|
2041
|
-
getInitialState: (instance, {
|
|
2040
|
+
getInitialState: (instance, { resource }) => ({
|
|
2042
2041
|
documentStates: {},
|
|
2043
2042
|
// these can be emptied on refetch
|
|
2044
2043
|
queued: [],
|
|
2045
2044
|
applied: [],
|
|
2046
|
-
sharedListener: createSharedListener(instance,
|
|
2047
|
-
fetchDocument: createFetchDocument(instance,
|
|
2045
|
+
sharedListener: createSharedListener(instance, resource),
|
|
2046
|
+
fetchDocument: createFetchDocument(instance, resource),
|
|
2048
2047
|
events: new Subject()
|
|
2049
2048
|
}),
|
|
2050
2049
|
initialize(context) {
|
|
@@ -2062,7 +2061,7 @@ const documentStore = defineStore({
|
|
|
2062
2061
|
function getDocumentState(...args) {
|
|
2063
2062
|
return _getDocumentState(...args);
|
|
2064
2063
|
}
|
|
2065
|
-
const _getDocumentState =
|
|
2064
|
+
const _getDocumentState = bindActionByResource(
|
|
2066
2065
|
documentStore,
|
|
2067
2066
|
createStateSourceAction({
|
|
2068
2067
|
selector: ({ state: { error, documentStates } }, options) => {
|
|
@@ -2093,7 +2092,7 @@ const _getDocumentState = bindActionBySource(
|
|
|
2093
2092
|
function resolveDocument(...args) {
|
|
2094
2093
|
return _resolveDocument(...args);
|
|
2095
2094
|
}
|
|
2096
|
-
const _resolveDocument =
|
|
2095
|
+
const _resolveDocument = bindActionByResource(
|
|
2097
2096
|
documentStore,
|
|
2098
2097
|
({ instance }, docHandle) => firstValueFrom(
|
|
2099
2098
|
getDocumentState(instance, {
|
|
@@ -2101,7 +2100,7 @@ const _resolveDocument = bindActionBySource(
|
|
|
2101
2100
|
path: void 0
|
|
2102
2101
|
}).observable.pipe(filter$1((i) => i !== void 0))
|
|
2103
2102
|
)
|
|
2104
|
-
), getDocumentSyncStatus =
|
|
2103
|
+
), getDocumentSyncStatus = bindActionByResource(
|
|
2105
2104
|
documentStore,
|
|
2106
2105
|
createStateSourceAction({
|
|
2107
2106
|
selector: ({ state: { error, documentStates: documents, outgoing, applied, queued } }, doc) => {
|
|
@@ -2119,7 +2118,7 @@ const _resolveDocument = bindActionBySource(
|
|
|
2119
2118
|
},
|
|
2120
2119
|
onSubscribe: (context, doc) => manageSubscriberIds(context, [doc])
|
|
2121
2120
|
})
|
|
2122
|
-
), getPermissionsState =
|
|
2121
|
+
), getPermissionsState = bindActionByResource(
|
|
2123
2122
|
documentStore,
|
|
2124
2123
|
createStateSourceAction({
|
|
2125
2124
|
selector: calculatePermissions,
|
|
@@ -2127,12 +2126,12 @@ const _resolveDocument = bindActionBySource(
|
|
|
2127
2126
|
manageSubscriberIds(context, actions);
|
|
2128
2127
|
}
|
|
2129
2128
|
})
|
|
2130
|
-
), resolvePermissions =
|
|
2129
|
+
), resolvePermissions = bindActionByResource(
|
|
2131
2130
|
documentStore,
|
|
2132
2131
|
({ instance }, options) => firstValueFrom(
|
|
2133
2132
|
getPermissionsState(instance, options).observable.pipe(filter$1((i) => i !== void 0))
|
|
2134
2133
|
)
|
|
2135
|
-
), subscribeDocumentEvents =
|
|
2134
|
+
), subscribeDocumentEvents = bindActionByResource(
|
|
2136
2135
|
documentStore,
|
|
2137
2136
|
({ state }, options) => {
|
|
2138
2137
|
const { events } = state.get(), subscription = events.subscribe(options.eventHandler);
|
|
@@ -2164,7 +2163,7 @@ const _resolveDocument = bindActionBySource(
|
|
|
2164
2163
|
}, subscribeToAppliedAndSubmitNextTransaction = ({
|
|
2165
2164
|
state,
|
|
2166
2165
|
instance,
|
|
2167
|
-
key: {
|
|
2166
|
+
key: { resource }
|
|
2168
2167
|
}) => {
|
|
2169
2168
|
const { events } = state.get();
|
|
2170
2169
|
return state.observable.pipe(
|
|
@@ -2187,8 +2186,8 @@ const _resolveDocument = bindActionBySource(
|
|
|
2187
2186
|
withLatestFrom(
|
|
2188
2187
|
getClientState(instance, {
|
|
2189
2188
|
apiVersion: API_VERSION$2,
|
|
2190
|
-
// TODO: remove in v3 when we're ready for everything to be queried via
|
|
2191
|
-
|
|
2189
|
+
// TODO: remove in v3 when we're ready for everything to be queried via resource
|
|
2190
|
+
resource: resource && !isDatasetResource(resource) ? resource : void 0
|
|
2192
2191
|
}).observable
|
|
2193
2192
|
),
|
|
2194
2193
|
concatMap(([outgoing, client]) => {
|
|
@@ -2262,19 +2261,19 @@ const _resolveDocument = bindActionBySource(
|
|
|
2262
2261
|
}, subscribeToClientAndFetchDatasetAcl = ({
|
|
2263
2262
|
instance,
|
|
2264
2263
|
state,
|
|
2265
|
-
key: {
|
|
2264
|
+
key: { resource }
|
|
2266
2265
|
}) => {
|
|
2267
2266
|
const clientOptions = { apiVersion: API_VERSION$2 };
|
|
2268
|
-
|
|
2267
|
+
resource && !isDatasetResource(resource) && (clientOptions.resource = resource);
|
|
2269
2268
|
let uri;
|
|
2270
|
-
if (
|
|
2271
|
-
uri = `/projects/${
|
|
2272
|
-
else if (
|
|
2273
|
-
uri = `/media-libraries/${
|
|
2274
|
-
else if (
|
|
2275
|
-
uri = `/canvases/${
|
|
2269
|
+
if (resource && isDatasetResource(resource))
|
|
2270
|
+
uri = `/projects/${resource.projectId}/datasets/${resource.dataset}/acl`;
|
|
2271
|
+
else if (resource && isMediaLibraryResource(resource))
|
|
2272
|
+
uri = `/media-libraries/${resource.mediaLibraryId}/acl`;
|
|
2273
|
+
else if (resource && isCanvasResource(resource))
|
|
2274
|
+
uri = `/canvases/${resource.canvasId}/acl`;
|
|
2276
2275
|
else
|
|
2277
|
-
throw new Error(`Received invalid
|
|
2276
|
+
throw new Error(`Received invalid resource: ${JSON.stringify(resource)}`);
|
|
2278
2277
|
return getClientState(instance, clientOptions).observable.pipe(
|
|
2279
2278
|
switchMap(
|
|
2280
2279
|
(client) => client.observable.request({
|
|
@@ -2291,7 +2290,7 @@ const _resolveDocument = bindActionBySource(
|
|
|
2291
2290
|
function applyDocumentActions(...args) {
|
|
2292
2291
|
return boundApplyDocumentActions(...args);
|
|
2293
2292
|
}
|
|
2294
|
-
const boundApplyDocumentActions =
|
|
2293
|
+
const boundApplyDocumentActions = bindActionByResource(documentStore, _applyDocumentActions);
|
|
2295
2294
|
async function _applyDocumentActions({ state }, { actions, transactionId = crypto.randomUUID(), disableBatching }) {
|
|
2296
2295
|
const { events } = state.get(), transaction = {
|
|
2297
2296
|
transactionId,
|
|
@@ -2576,10 +2575,19 @@ const favorites = createFetcherStore({
|
|
|
2576
2575
|
);
|
|
2577
2576
|
function getBifurClient(client, token$) {
|
|
2578
2577
|
const bifurVersionedClient = client.withConfig({ apiVersion: "2022-06-30" }), {
|
|
2578
|
+
resource,
|
|
2579
2579
|
dataset,
|
|
2580
2580
|
url: baseUrl,
|
|
2581
2581
|
requestTagPrefix = "sanity.sdk.presence"
|
|
2582
|
-
} = bifurVersionedClient.config()
|
|
2582
|
+
} = bifurVersionedClient.config();
|
|
2583
|
+
let resourcePath;
|
|
2584
|
+
if (resource?.type === "canvas")
|
|
2585
|
+
resourcePath = `canvases/${resource.id}`;
|
|
2586
|
+
else if (dataset)
|
|
2587
|
+
resourcePath = dataset;
|
|
2588
|
+
else
|
|
2589
|
+
throw new Error("Unable to determine presence URL: no canvas resource or dataset configured");
|
|
2590
|
+
const urlWithTag = `${`${baseUrl}/socket/${resourcePath}`.replace(/^http/, "ws")}?tag=${requestTagPrefix}`;
|
|
2583
2591
|
return fromUrl(urlWithTag, { token$ });
|
|
2584
2592
|
}
|
|
2585
2593
|
const handleIncomingMessage = (event) => {
|
|
@@ -2626,7 +2634,7 @@ const handleIncomingMessage = (event) => {
|
|
|
2626
2634
|
}
|
|
2627
2635
|
};
|
|
2628
2636
|
return typeof window < "u" && fromEvent(window, "beforeunload").pipe(switchMap$1(() => dispatchMessage({ type: "disconnect" }))).subscribe(), [incomingEvents$.pipe(share$1()), dispatchMessage];
|
|
2629
|
-
}, getInitialState = () => ({
|
|
2637
|
+
}, PRESENCE_API_VERSION = "2026-03-30", getInitialState = () => ({
|
|
2630
2638
|
locations: /* @__PURE__ */ new Map(),
|
|
2631
2639
|
users: {}
|
|
2632
2640
|
}), presenceStore = defineStore({
|
|
@@ -2636,17 +2644,24 @@ const handleIncomingMessage = (event) => {
|
|
|
2636
2644
|
const {
|
|
2637
2645
|
instance,
|
|
2638
2646
|
state,
|
|
2639
|
-
key: {
|
|
2640
|
-
} = context
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2647
|
+
key: { resource }
|
|
2648
|
+
} = context;
|
|
2649
|
+
if (isMediaLibraryResource(resource))
|
|
2650
|
+
throw new Error("Presence is not supported for media library resources.");
|
|
2651
|
+
const sessionId = crypto.randomUUID(), client = isDatasetResource(resource) ? getClient(instance, {
|
|
2652
|
+
apiVersion: PRESENCE_API_VERSION,
|
|
2653
|
+
projectId: resource.projectId,
|
|
2654
|
+
dataset: resource.dataset,
|
|
2655
|
+
useProjectHostname: !0
|
|
2656
|
+
}) : getClient(instance, {
|
|
2657
|
+
apiVersion: PRESENCE_API_VERSION,
|
|
2658
|
+
resource
|
|
2644
2659
|
}), token$ = getTokenState(instance).observable.pipe(distinctUntilChanged()), [incomingEvents$, dispatch] = createBifurTransport({
|
|
2645
2660
|
client,
|
|
2646
2661
|
token$,
|
|
2647
2662
|
sessionId
|
|
2648
2663
|
}), subscription = new Subscription();
|
|
2649
|
-
|
|
2664
|
+
if (subscription.add(
|
|
2650
2665
|
incomingEvents$.subscribe((event) => {
|
|
2651
2666
|
"sessionId" in event && event.sessionId === sessionId || (event.type === "state" ? state.set("presence/state", (prevState) => {
|
|
2652
2667
|
const newLocations = new Map(prevState.locations);
|
|
@@ -2662,7 +2677,18 @@ const handleIncomingMessage = (event) => {
|
|
|
2662
2677
|
return newLocations.delete(event.sessionId), { ...prevState, locations: newLocations };
|
|
2663
2678
|
}));
|
|
2664
2679
|
})
|
|
2665
|
-
), dispatch({ type: "rollCall" }).subscribe(), ()
|
|
2680
|
+
), dispatch({ type: "rollCall" }).subscribe(), isCanvasResource(resource)) {
|
|
2681
|
+
const globalClient = getClient(instance, { apiVersion: PRESENCE_API_VERSION });
|
|
2682
|
+
subscription.add(
|
|
2683
|
+
globalClient.observable.request({
|
|
2684
|
+
uri: `/canvases/${resource.canvasId}`,
|
|
2685
|
+
tag: "canvases.get"
|
|
2686
|
+
}).pipe(catchError$1(() => EMPTY)).subscribe(({ organizationId }) => {
|
|
2687
|
+
state.set("presence/organizationId", (prev) => ({ ...prev, organizationId }));
|
|
2688
|
+
})
|
|
2689
|
+
);
|
|
2690
|
+
}
|
|
2691
|
+
return () => {
|
|
2666
2692
|
dispatch({ type: "disconnect" }).subscribe(), subscription.unsubscribe();
|
|
2667
2693
|
};
|
|
2668
2694
|
}
|
|
@@ -2679,31 +2705,34 @@ const handleIncomingMessage = (event) => {
|
|
|
2679
2705
|
sessionId,
|
|
2680
2706
|
locations: locs
|
|
2681
2707
|
}))
|
|
2682
|
-
),
|
|
2708
|
+
), _getPresence = bindActionByResource(
|
|
2683
2709
|
presenceStore,
|
|
2684
2710
|
createStateSourceAction({
|
|
2685
|
-
selector: (context
|
|
2686
|
-
onSubscribe: (context
|
|
2687
|
-
const
|
|
2711
|
+
selector: (context) => selectPresence(context.state),
|
|
2712
|
+
onSubscribe: (context) => {
|
|
2713
|
+
const resource = context.key.resource, userIds$ = context.state.observable.pipe(
|
|
2688
2714
|
map$1(
|
|
2689
2715
|
(state) => Array.from(state.locations.values()).map((l) => l.userId).filter((id) => !!id)
|
|
2690
2716
|
),
|
|
2691
2717
|
distinctUntilChanged((a, b) => a.length === b.length && a.every((v, i) => v === b[i]))
|
|
2692
|
-
).pipe(
|
|
2693
|
-
|
|
2718
|
+
), organizationId$ = isCanvasResource(resource) ? context.state.observable.pipe(
|
|
2719
|
+
map$1((s) => s.organizationId),
|
|
2720
|
+
filter$1((id) => id !== void 0),
|
|
2721
|
+
first$1()
|
|
2722
|
+
) : of(void 0), subscription = combineLatest([userIds$, organizationId$]).pipe(
|
|
2723
|
+
switchMap(([userIds, organizationId]) => {
|
|
2694
2724
|
if (userIds.length === 0)
|
|
2695
2725
|
return of([]);
|
|
2696
2726
|
const userObservables = userIds.map(
|
|
2697
2727
|
(userId) => getUserState(context.instance, {
|
|
2698
2728
|
userId,
|
|
2699
|
-
resourceType: "project",
|
|
2700
|
-
projectId: context.key.projectId
|
|
2729
|
+
...isDatasetResource(resource) ? { resourceType: "project", projectId: resource.projectId } : { resourceType: "organization", organizationId }
|
|
2701
2730
|
}).pipe(filter$1((v) => !!v))
|
|
2702
2731
|
);
|
|
2703
2732
|
return combineLatest(userObservables);
|
|
2704
2733
|
})
|
|
2705
2734
|
).subscribe((users) => {
|
|
2706
|
-
|
|
2735
|
+
context.state.set("presence/users", (prevState) => ({
|
|
2707
2736
|
...prevState,
|
|
2708
2737
|
users: {
|
|
2709
2738
|
...prevState.users,
|
|
@@ -2715,6 +2744,9 @@ const handleIncomingMessage = (event) => {
|
|
|
2715
2744
|
}
|
|
2716
2745
|
})
|
|
2717
2746
|
);
|
|
2747
|
+
function getPresence(instance, params) {
|
|
2748
|
+
return _getPresence(instance, params ?? {});
|
|
2749
|
+
}
|
|
2718
2750
|
function hashString(str) {
|
|
2719
2751
|
let hash = 0;
|
|
2720
2752
|
for (let i = 0; i < str.length; i++)
|
|
@@ -2800,13 +2832,13 @@ function processStatusQueryResults(results) {
|
|
|
2800
2832
|
const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Array.from(a).every((i) => b.has(i)), subscribeToStateAndFetchBatches = ({
|
|
2801
2833
|
state,
|
|
2802
2834
|
instance,
|
|
2803
|
-
key: {
|
|
2835
|
+
key: { resource, perspective }
|
|
2804
2836
|
}) => {
|
|
2805
2837
|
const documentProjections$ = state.observable.pipe(
|
|
2806
2838
|
map$1((s) => s.documentProjections),
|
|
2807
|
-
distinctUntilChanged(
|
|
2839
|
+
distinctUntilChanged(isDeepEqual)
|
|
2808
2840
|
), activeDocumentIds$ = state.observable.pipe(
|
|
2809
|
-
map$1(({ subscriptions }) => new Set(Object.keys(subscriptions))),
|
|
2841
|
+
map$1(({ subscriptions }) => new Set(Object.keys(subscriptions).map((id) => DocumentId(id)))),
|
|
2810
2842
|
distinctUntilChanged(isSetEqual)
|
|
2811
2843
|
), pendingUpdateSubscription = activeDocumentIds$.pipe(
|
|
2812
2844
|
debounceTime(BATCH_DEBOUNCE_TIME),
|
|
@@ -2834,7 +2866,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2834
2866
|
})
|
|
2835
2867
|
).subscribe(), queryExecutionSubscription = combineLatest([activeDocumentIds$, documentProjections$]).pipe(
|
|
2836
2868
|
debounceTime(BATCH_DEBOUNCE_TIME),
|
|
2837
|
-
distinctUntilChanged(
|
|
2869
|
+
distinctUntilChanged(isDeepEqual)
|
|
2838
2870
|
).pipe(
|
|
2839
2871
|
switchMap(([ids, documentProjections]) => {
|
|
2840
2872
|
if (!ids.size) return EMPTY;
|
|
@@ -2845,7 +2877,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2845
2877
|
tag: PROJECTION_TAG,
|
|
2846
2878
|
perspective,
|
|
2847
2879
|
// temporary guard here until we're ready for everything to be queried via global API
|
|
2848
|
-
...
|
|
2880
|
+
...resource && !isDatasetResource(resource) ? { resource } : {}
|
|
2849
2881
|
}), subscription = defer(() => getCurrent() === void 0 ? from(
|
|
2850
2882
|
resolveQuery(instance, {
|
|
2851
2883
|
query,
|
|
@@ -2854,7 +2886,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2854
2886
|
signal: controller.signal,
|
|
2855
2887
|
perspective,
|
|
2856
2888
|
// temporary guard here until we're ready for everything to be queried via global API in v3
|
|
2857
|
-
...
|
|
2889
|
+
...resource && !isDatasetResource(resource) ? { resource } : {}
|
|
2858
2890
|
})
|
|
2859
2891
|
).pipe(switchMap(() => observable)) : observable).pipe(filter$1((result) => result !== void 0)).subscribe(observer);
|
|
2860
2892
|
return () => {
|
|
@@ -2867,7 +2899,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2867
2899
|
tag: PROJECTION_TAG,
|
|
2868
2900
|
perspective: "raw",
|
|
2869
2901
|
// temporary guard here until we're ready for everything to be queried via global API
|
|
2870
|
-
...
|
|
2902
|
+
...resource && !isDatasetResource(resource) ? { resource } : {}
|
|
2871
2903
|
}), subscription = defer(() => getCurrent() === void 0 ? from(
|
|
2872
2904
|
resolveQuery(instance, {
|
|
2873
2905
|
query: statusQuery,
|
|
@@ -2876,7 +2908,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2876
2908
|
signal: controller.signal,
|
|
2877
2909
|
perspective: "raw",
|
|
2878
2910
|
// temporary guard here until we're ready for everything to be queried via global API
|
|
2879
|
-
...
|
|
2911
|
+
...resource && !isDatasetResource(resource) ? { resource } : {}
|
|
2880
2912
|
})
|
|
2881
2913
|
).pipe(switchMap(() => observable)) : observable).pipe(filter$1((result) => result !== void 0)).subscribe(observer);
|
|
2882
2914
|
return () => {
|
|
@@ -2946,7 +2978,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
|
|
|
2946
2978
|
function getProjectionState(...args) {
|
|
2947
2979
|
return _getProjectionState(...args);
|
|
2948
2980
|
}
|
|
2949
|
-
const _getProjectionState =
|
|
2981
|
+
const _getProjectionState = bindActionByResourceAndPerspective(
|
|
2950
2982
|
projectionStore,
|
|
2951
2983
|
createStateSourceAction({
|
|
2952
2984
|
selector: ({ state }, options) => {
|
|
@@ -2976,7 +3008,7 @@ const _getProjectionState = bindActionBySourceAndPerspective(
|
|
|
2976
3008
|
})), () => {
|
|
2977
3009
|
setCleanupTimeout(() => {
|
|
2978
3010
|
state.set("removeSubscription", (prev) => {
|
|
2979
|
-
const documentSubscriptionsForHash =
|
|
3011
|
+
const documentSubscriptionsForHash = omitProperty(
|
|
2980
3012
|
prev.subscriptions[documentId]?.[projectionHash],
|
|
2981
3013
|
subscriptionId
|
|
2982
3014
|
), hasSubscribersForProjection = !!Object.keys(documentSubscriptionsForHash).length, nextSubscriptions = { ...prev.subscriptions }, nextDocumentProjections = { ...prev.documentProjections }, nextValues = { ...prev.values };
|
|
@@ -3008,7 +3040,7 @@ function getPreviewState(instance, options) {
|
|
|
3008
3040
|
...options,
|
|
3009
3041
|
projection: PREVIEW_PROJECTION
|
|
3010
3042
|
}), transformResult = (current) => !current || current.data === null ? { data: null, isPending: current?.isPending ?? !1 } : {
|
|
3011
|
-
data: transformProjectionToPreview(instance, current.data, options.
|
|
3043
|
+
data: transformProjectionToPreview(instance, current.data, options.resource),
|
|
3012
3044
|
isPending: current.isPending
|
|
3013
3045
|
};
|
|
3014
3046
|
return {
|
|
@@ -3020,7 +3052,7 @@ function getPreviewState(instance, options) {
|
|
|
3020
3052
|
function resolveProjection(...args) {
|
|
3021
3053
|
return _resolveProjection(...args);
|
|
3022
3054
|
}
|
|
3023
|
-
const _resolveProjection =
|
|
3055
|
+
const _resolveProjection = bindActionByResourceAndPerspective(
|
|
3024
3056
|
projectionStore,
|
|
3025
3057
|
({ instance }, options) => firstValueFrom(
|
|
3026
3058
|
getProjectionState(instance, options).observable.pipe(
|
|
@@ -3034,7 +3066,11 @@ async function resolvePreview(instance, options) {
|
|
|
3034
3066
|
projection: PREVIEW_PROJECTION
|
|
3035
3067
|
});
|
|
3036
3068
|
return projectionResult.data ? {
|
|
3037
|
-
data: transformProjectionToPreview(
|
|
3069
|
+
data: transformProjectionToPreview(
|
|
3070
|
+
instance,
|
|
3071
|
+
projectionResult.data,
|
|
3072
|
+
options.resource
|
|
3073
|
+
),
|
|
3038
3074
|
isPending: projectionResult.isPending
|
|
3039
3075
|
} : { data: null, isPending: projectionResult.isPending };
|
|
3040
3076
|
}
|
|
@@ -3117,6 +3153,12 @@ function getCorsErrorProjectId(error) {
|
|
|
3117
3153
|
const projMatch = (error.message || "").match(/manage\/project\/([^/?#]+)/);
|
|
3118
3154
|
return projMatch ? projMatch[1] : null;
|
|
3119
3155
|
}
|
|
3156
|
+
function isImportError(error) {
|
|
3157
|
+
if (!(error instanceof Error)) return !1;
|
|
3158
|
+
if (error.name === "ChunkLoadError") return !0;
|
|
3159
|
+
const message = error.message || "";
|
|
3160
|
+
return /Loading chunk [\w-]+ failed/i.test(message) || /Failed to fetch dynamically imported module/i.test(message) || /error loading dynamically imported module/i.test(message) || /Import(?:ing)? a module script failed/i.test(message) || /Unable to preload CSS/i.test(message);
|
|
3161
|
+
}
|
|
3120
3162
|
export {
|
|
3121
3163
|
AuthStateType,
|
|
3122
3164
|
CORE_SDK_VERSION,
|
|
@@ -3176,8 +3218,12 @@ export {
|
|
|
3176
3218
|
getUsersKey,
|
|
3177
3219
|
getUsersState,
|
|
3178
3220
|
handleAuthCallback,
|
|
3221
|
+
isCanvasResource,
|
|
3179
3222
|
isCanvasSource,
|
|
3223
|
+
isDatasetResource,
|
|
3180
3224
|
isDatasetSource,
|
|
3225
|
+
isImportError,
|
|
3226
|
+
isMediaLibraryResource,
|
|
3181
3227
|
isMediaLibrarySource,
|
|
3182
3228
|
isProjectUserNotFoundClientError,
|
|
3183
3229
|
isStudioConfig,
|