@sanity/sdk 3.8.0 → 3.9.0-next.20261007114705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/_internal.d.ts +8 -2
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +8 -8
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/dashboard.d.ts +2 -2
- package/dist/_exports/dashboard.js +2 -2
- package/dist/{applications-CaitEfgp.d.ts → applications-BioeDdGe.d.ts} +46 -11
- package/dist/{applications-CaitEfgp.d.ts.map → applications-BioeDdGe.d.ts.map} +1 -1
- package/dist/{authStore-DRX3qU3e.js → authStore-CwZPW3jK.js} +10 -2
- package/dist/{authStore-DRX3qU3e.js.map → authStore-CwZPW3jK.js.map} +1 -1
- package/dist/{bus-BjkKneLg.d.ts → bus-BULkpPgi.d.ts} +2 -2
- package/dist/{bus-BjkKneLg.d.ts.map → bus-BULkpPgi.d.ts.map} +1 -1
- package/dist/{clientStore-mFP_nOqf.js → clientStore-iv9ooGew.js} +2 -2
- package/dist/{clientStore-mFP_nOqf.js.map → clientStore-iv9ooGew.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/{topicStore-D5RKaWQk.js → topicStore-CjKrnfeL.js} +2 -2
- package/dist/{topicStore-D5RKaWQk.js.map → topicStore-CjKrnfeL.js.map} +1 -1
- package/dist/{version-asrkIujR.js → version-D68H4Kcd.js} +3 -3
- package/dist/{version-asrkIujR.js.map → version-D68H4Kcd.js.map} +1 -1
- package/package.json +2 -2
- package/src/_exports/_internal.ts +1 -0
- package/src/auth/utils.test.ts +25 -0
- package/src/auth/utils.ts +10 -1
- package/src/config/__tests__/handles.test-d.ts +24 -0
- package/src/typegen/resolve.test-d.ts +105 -0
- package/src/typegen/resolve.ts +61 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dr as StateTopic, Er as ReplyOf, Mr as ValueOf, _r as EventTopic, jr as Topics, kr as TopicName, t as Application, wr as PayloadOf, xr as MessageBusTopics } from "./applications-
|
|
1
|
+
import { Dr as StateTopic, Er as ReplyOf, Mr as ValueOf, _r as EventTopic, jr as Topics, kr as TopicName, t as Application, wr as PayloadOf, xr as MessageBusTopics } from "./applications-BioeDdGe.js";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
/**
|
|
4
4
|
* A message bus protocol error code.
|
|
@@ -238,4 +238,4 @@ interface InstallMessageBusOptions {
|
|
|
238
238
|
*/
|
|
239
239
|
declare function installMessageBus(options?: InstallMessageBusOptions): MessageBusHost<Topics>;
|
|
240
240
|
export { installMessageBus as _, MessageBusClient as a, MessageBusEmitResult as c, MessageBusHost as d, MessageBusMessage as f, connectMessageBus as g, MessageBusStateSource as h, MessageBusAbortOptions as i, MessageBusError as l, MessageBusQueryOptions as m, InstallMessageBusOptions as n, MessageBusConnection as o, MessageBusMeta as p, MessageBus as r, MessageBusEmitOptions as s, ConnectMessageBusOptions as t, MessageBusErrorCode as u, isMessageBusEnvironment as v, resetMessageBus as y };
|
|
241
|
-
//# sourceMappingURL=bus-
|
|
241
|
+
//# sourceMappingURL=bus-BULkpPgi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bus-
|
|
1
|
+
{"version":3,"file":"bus-BULkpPgi.d.ts","names":[],"sources":["../src/dashboard/messageBus/bus.ts"],"mappings":";;;;;;;KAqCY;;;;;;cAeC,wBAAwB;;WAE1B,MAAM;;EAGH,YAAA,MAAM,qBAAqB,kBAAkB;IAAW;;;;;;;;UAYrD;;EAEf,OAAO;;;;;;EAMP;;EAEA;;;;;;;UAQe,kBAAkB,GAAG,WAAW,UAAU,cAAc;;EAEvE,MAAM;;EAEN,SAAS;;EAET,MAAM;;EAEN,MAAM,OAAO;;;;;;EAMb,OAAO;;WAEE,QAAQ;;;;;;;UAQF,sBAAsB,WAAW,WAAW;;EAE3D,cAAc;;WAEL,YAAY,QAAQ;;;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AS,2BAAgC,eAAe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-vyAXikos.js";
|
|
2
2
|
import { h as isMediaLibraryResource, i as bindActionGlobally, m as isDatasetResource, p as isCanvasResource, s as defineStore, t as createStateSourceAction } from "./createStateSourceAction-Bn0po7Z3.js";
|
|
3
|
-
import {
|
|
3
|
+
import { H as getStagingApiHost, c as getTokenState, r as getAuthMethodState } from "./authStore-CwZPW3jK.js";
|
|
4
4
|
import { i as pickProperties } from "./object-CxXlSVg7.js";
|
|
5
5
|
import { createClient } from "@sanity/client";
|
|
6
6
|
var clientStore_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -87,4 +87,4 @@ const allowedKeys = Object.keys({
|
|
|
87
87
|
}), getClientState = bindActionGlobally(clientStore, createStateSourceAction(({ instance }, options) => getClient(instance, options)));
|
|
88
88
|
export { getClient as n, getClientState as r, clientStore_exports as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=clientStore-
|
|
90
|
+
//# sourceMappingURL=clientStore-iv9ooGew.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientStore-mFP_nOqf.js","names":[],"sources":["../src/client/clientStore.ts"],"sourcesContent":["import {type ClientConfig, createClient, type SanityClient} from '@sanity/client'\n\nimport {getAuthMethodState, getTokenState} from '../auth/authStore'\nimport {\n type DocumentResource,\n isCanvasResource,\n isDatasetResource,\n isMediaLibraryResource,\n} from '../config/sanityConfig'\nimport {bindActionGlobally} from '../store/createActionBinder'\nimport {createStateSourceAction} from '../store/createStateSourceAction'\nimport {defineStore, type StoreContext} from '../store/defineStore'\nimport {getStagingApiHost} from '../utils/getStagingApiHost'\nimport {pickProperties} from '../utils/object'\n\nconst DEFAULT_API_VERSION = '2024-11-12'\nconst DEFAULT_REQUEST_TAG_PREFIX = 'sanity.sdk'\n\ntype AllowedClientConfigKey =\n | 'useCdn'\n | 'token'\n | 'perspective'\n | 'apiHost'\n | 'proxy'\n | 'withCredentials'\n | 'timeout'\n | 'maxRetries'\n | 'dataset'\n | 'projectId'\n | 'requestTagPrefix'\n | 'useProjectHostname'\n\nconst allowedKeys = Object.keys({\n apiHost: null,\n useCdn: null,\n token: null,\n perspective: null,\n proxy: null,\n withCredentials: null,\n timeout: null,\n maxRetries: null,\n dataset: null,\n projectId: null,\n scope: null,\n apiVersion: null,\n requestTagPrefix: null,\n useProjectHostname: null,\n resource: null,\n} satisfies Record<keyof ClientOptions, null>) as (keyof ClientOptions)[]\n\nconst DEFAULT_CLIENT_CONFIG: ClientConfig = {\n apiVersion: DEFAULT_API_VERSION,\n useCdn: false,\n ignoreBrowserTokenWarning: true,\n allowReconfigure: false,\n requestTagPrefix: DEFAULT_REQUEST_TAG_PREFIX,\n}\n\n/**\n * States tracked by the client store\n * @public\n */\nexport interface ClientStoreState {\n token: string | null\n clients: {[TKey in string]?: SanityClient}\n authMethod?: 'localstorage' | 'cookie'\n}\n\n/**\n * Options used when retrieving a client instance from the client store.\n *\n * This interface extends the base {@link ClientConfig} and adds:\n *\n * - **apiVersion:** A required string indicating the API version for the client.\n * - **scope:** An optional flag to choose between the project-specific client\n * ('project') and the global client ('global'). When set to `'global'`, the\n * global client is used.\n *\n * These options are utilized by `getClient` and `getClientState` to configure and\n * return appropriate client instances that automatically handle authentication\n * updates and configuration changes.\n *\n * @public\n */\nexport interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {\n /**\n * An optional flag to choose between the default client (typically project-level)\n * and the global client ('global'). When set to `'global'`, the global client\n * is used.\n */\n scope?: 'default' | 'global'\n /**\n * A required string indicating the API version for the client.\n */\n apiVersion: string\n\n /**\n * @internal\n * The SDK resource to use for the client -- this will get transformed into a ClientConfig resource.\n */\n resource?: DocumentResource\n}\n\nconst clientStore = defineStore<ClientStoreState>({\n name: 'clientStore',\n\n getInitialState: (instance) => ({\n clients: {},\n token: getTokenState(instance).getCurrent(),\n }),\n\n initialize(context) {\n const subscription = listenToToken(context)\n const authMethodSubscription = listenToAuthMethod(context)\n return () => {\n subscription.unsubscribe()\n authMethodSubscription.unsubscribe()\n }\n },\n})\n\n/**\n * Updates the client store state when a token is received.\n * @internal\n */\nconst listenToToken = ({instance, state}: StoreContext<ClientStoreState>) => {\n return getTokenState(instance).observable.subscribe((token) => {\n state.set('setTokenAndResetClients', {token, clients: {}})\n })\n}\n\nconst listenToAuthMethod = ({instance, state}: StoreContext<ClientStoreState>) => {\n return getAuthMethodState(instance).observable.subscribe((authMethod) => {\n state.set('setAuthMethod', {authMethod})\n })\n}\n\ntype ClientInstanceCacheKeyInput = ClientConfig &\n Partial<Pick<ClientOptions, 'scope'>> & {\n apiVersion: string\n }\n\nconst getClientConfigKey = (options: ClientInstanceCacheKeyInput) =>\n JSON.stringify(pickProperties(options, allowedKeys))\n\n/**\n * Retrieves a Sanity client instance configured with the provided options.\n *\n * This function returns a client instance configured for the project or as a\n * global client based on the options provided. It ensures efficient reuse of\n * client instances by returning the same instance for the same options.\n * For automatic handling of authentication token updates, consider using\n * `getClientState`.\n *\n * @public\n */\nexport const getClient = bindActionGlobally(\n clientStore,\n ({state, instance}, options: ClientOptions) => {\n if (!options || typeof options !== 'object') {\n throw new Error(\n 'getClient() requires a configuration object with at least an \"apiVersion\" property. ' +\n 'Example: getClient(instance, { apiVersion: \"2024-11-12\" })',\n )\n }\n\n // Check for disallowed keys\n const providedKeys = Object.keys(options) as (keyof ClientOptions)[]\n const disallowedKeys = providedKeys.filter((key) => !allowedKeys.includes(key))\n\n if (disallowedKeys.length > 0) {\n const listFormatter = new Intl.ListFormat('en', {style: 'long', type: 'conjunction'})\n throw new Error(\n `The client options provided contains unsupported properties: ${listFormatter.format(disallowedKeys)}. ` +\n `Allowed keys are: ${listFormatter.format(allowedKeys)}.`,\n )\n }\n\n const tokenFromState = state.get().token\n const {clients, authMethod} = state.get()\n let projectId = options.projectId ?? instance.config.projectId\n let dataset = options.dataset ?? instance.config.dataset\n\n let resource: ClientConfig['resource'] | undefined\n\n if (options.resource) {\n if (isMediaLibraryResource(options.resource)) {\n resource = {type: 'media-library', id: options.resource.mediaLibraryId}\n } else if (isCanvasResource(options.resource)) {\n resource = {type: 'canvas', id: options.resource.canvasId}\n } else if (isDatasetResource(options.resource)) {\n // use project-based routes for datasets to avoid existing CORS and Studio auth cookie issues\n projectId = options.resource.projectId\n dataset = options.resource.dataset\n }\n }\n\n const apiHost = options.apiHost ?? instance.config.auth?.apiHost ?? getStagingApiHost()\n\n const effectiveOptions: ClientConfig & {apiVersion: string} = {\n ...DEFAULT_CLIENT_CONFIG,\n ...((options.scope === 'global' || !projectId || resource) && {useProjectHostname: false}),\n token: authMethod === 'cookie' ? undefined : (tokenFromState ?? undefined),\n ...options,\n ...(projectId && {projectId}),\n ...(dataset && {dataset}),\n ...(resource ? {resource} : {resource: undefined}),\n ...(apiHost && {apiHost}),\n }\n\n // When a resource is provided, don't use projectId/dataset - the client should be \"projectless\"\n // The client code itself will ignore the non-resource config, so we do this to prevent confusing the user.\n // (ref: https://github.com/sanity-io/client/blob/5c23f81f5ab93a53f5b22b39845c867988508d84/src/data/dataMethods.ts#L691)\n if (resource) {\n delete effectiveOptions.projectId\n delete effectiveOptions.dataset\n }\n\n if (effectiveOptions.token === null || typeof effectiveOptions.token === 'undefined') {\n delete effectiveOptions.token\n if (authMethod === 'cookie') {\n effectiveOptions.withCredentials = true\n }\n } else {\n delete effectiveOptions.withCredentials\n }\n\n const key = getClientConfigKey(effectiveOptions)\n\n if (clients[key]) return clients[key]\n\n const client = createClient(effectiveOptions)\n state.set('addClient', (prev) => ({clients: {...prev.clients, [key]: client}}))\n\n return client\n },\n)\n\n/**\n * Returns a state source for the Sanity client instance.\n *\n * This function provides a subscribable state source that emits updated client\n * instances whenever relevant configurations change (such as authentication tokens).\n * Use this when you need to react to client configuration changes in your application.\n *\n * @public\n */\nexport const getClientState = bindActionGlobally(\n clientStore,\n createStateSourceAction(({instance}, options: ClientOptions) => getClient(instance, options)),\n)\n"],"mappings":";;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OAFA,MAAM,IAAI,cAAc,UAAU,EAAC,SAAS;EAAC,GAAG,KAAK;GAAU,MAAM;CAAM,EAAC,EAAE,GAEvE;AACT,CACF,GAWa,iBAAiB,mBAC5B,aACA,yBAAyB,EAAC,YAAW,YAA2B,UAAU,UAAU,OAAO,CAAC,CAC9F"}
|
|
1
|
+
{"version":3,"file":"clientStore-iv9ooGew.js","names":[],"sources":["../src/client/clientStore.ts"],"sourcesContent":["import {type ClientConfig, createClient, type SanityClient} from '@sanity/client'\n\nimport {getAuthMethodState, getTokenState} from '../auth/authStore'\nimport {\n type DocumentResource,\n isCanvasResource,\n isDatasetResource,\n isMediaLibraryResource,\n} from '../config/sanityConfig'\nimport {bindActionGlobally} from '../store/createActionBinder'\nimport {createStateSourceAction} from '../store/createStateSourceAction'\nimport {defineStore, type StoreContext} from '../store/defineStore'\nimport {getStagingApiHost} from '../utils/getStagingApiHost'\nimport {pickProperties} from '../utils/object'\n\nconst DEFAULT_API_VERSION = '2024-11-12'\nconst DEFAULT_REQUEST_TAG_PREFIX = 'sanity.sdk'\n\ntype AllowedClientConfigKey =\n | 'useCdn'\n | 'token'\n | 'perspective'\n | 'apiHost'\n | 'proxy'\n | 'withCredentials'\n | 'timeout'\n | 'maxRetries'\n | 'dataset'\n | 'projectId'\n | 'requestTagPrefix'\n | 'useProjectHostname'\n\nconst allowedKeys = Object.keys({\n apiHost: null,\n useCdn: null,\n token: null,\n perspective: null,\n proxy: null,\n withCredentials: null,\n timeout: null,\n maxRetries: null,\n dataset: null,\n projectId: null,\n scope: null,\n apiVersion: null,\n requestTagPrefix: null,\n useProjectHostname: null,\n resource: null,\n} satisfies Record<keyof ClientOptions, null>) as (keyof ClientOptions)[]\n\nconst DEFAULT_CLIENT_CONFIG: ClientConfig = {\n apiVersion: DEFAULT_API_VERSION,\n useCdn: false,\n ignoreBrowserTokenWarning: true,\n allowReconfigure: false,\n requestTagPrefix: DEFAULT_REQUEST_TAG_PREFIX,\n}\n\n/**\n * States tracked by the client store\n * @public\n */\nexport interface ClientStoreState {\n token: string | null\n clients: {[TKey in string]?: SanityClient}\n authMethod?: 'localstorage' | 'cookie'\n}\n\n/**\n * Options used when retrieving a client instance from the client store.\n *\n * This interface extends the base {@link ClientConfig} and adds:\n *\n * - **apiVersion:** A required string indicating the API version for the client.\n * - **scope:** An optional flag to choose between the project-specific client\n * ('project') and the global client ('global'). When set to `'global'`, the\n * global client is used.\n *\n * These options are utilized by `getClient` and `getClientState` to configure and\n * return appropriate client instances that automatically handle authentication\n * updates and configuration changes.\n *\n * @public\n */\nexport interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {\n /**\n * An optional flag to choose between the default client (typically project-level)\n * and the global client ('global'). When set to `'global'`, the global client\n * is used.\n */\n scope?: 'default' | 'global'\n /**\n * A required string indicating the API version for the client.\n */\n apiVersion: string\n\n /**\n * @internal\n * The SDK resource to use for the client -- this will get transformed into a ClientConfig resource.\n */\n resource?: DocumentResource\n}\n\nconst clientStore = defineStore<ClientStoreState>({\n name: 'clientStore',\n\n getInitialState: (instance) => ({\n clients: {},\n token: getTokenState(instance).getCurrent(),\n }),\n\n initialize(context) {\n const subscription = listenToToken(context)\n const authMethodSubscription = listenToAuthMethod(context)\n return () => {\n subscription.unsubscribe()\n authMethodSubscription.unsubscribe()\n }\n },\n})\n\n/**\n * Updates the client store state when a token is received.\n * @internal\n */\nconst listenToToken = ({instance, state}: StoreContext<ClientStoreState>) => {\n return getTokenState(instance).observable.subscribe((token) => {\n state.set('setTokenAndResetClients', {token, clients: {}})\n })\n}\n\nconst listenToAuthMethod = ({instance, state}: StoreContext<ClientStoreState>) => {\n return getAuthMethodState(instance).observable.subscribe((authMethod) => {\n state.set('setAuthMethod', {authMethod})\n })\n}\n\ntype ClientInstanceCacheKeyInput = ClientConfig &\n Partial<Pick<ClientOptions, 'scope'>> & {\n apiVersion: string\n }\n\nconst getClientConfigKey = (options: ClientInstanceCacheKeyInput) =>\n JSON.stringify(pickProperties(options, allowedKeys))\n\n/**\n * Retrieves a Sanity client instance configured with the provided options.\n *\n * This function returns a client instance configured for the project or as a\n * global client based on the options provided. It ensures efficient reuse of\n * client instances by returning the same instance for the same options.\n * For automatic handling of authentication token updates, consider using\n * `getClientState`.\n *\n * @public\n */\nexport const getClient = bindActionGlobally(\n clientStore,\n ({state, instance}, options: ClientOptions) => {\n if (!options || typeof options !== 'object') {\n throw new Error(\n 'getClient() requires a configuration object with at least an \"apiVersion\" property. ' +\n 'Example: getClient(instance, { apiVersion: \"2024-11-12\" })',\n )\n }\n\n // Check for disallowed keys\n const providedKeys = Object.keys(options) as (keyof ClientOptions)[]\n const disallowedKeys = providedKeys.filter((key) => !allowedKeys.includes(key))\n\n if (disallowedKeys.length > 0) {\n const listFormatter = new Intl.ListFormat('en', {style: 'long', type: 'conjunction'})\n throw new Error(\n `The client options provided contains unsupported properties: ${listFormatter.format(disallowedKeys)}. ` +\n `Allowed keys are: ${listFormatter.format(allowedKeys)}.`,\n )\n }\n\n const tokenFromState = state.get().token\n const {clients, authMethod} = state.get()\n let projectId = options.projectId ?? instance.config.projectId\n let dataset = options.dataset ?? instance.config.dataset\n\n let resource: ClientConfig['resource'] | undefined\n\n if (options.resource) {\n if (isMediaLibraryResource(options.resource)) {\n resource = {type: 'media-library', id: options.resource.mediaLibraryId}\n } else if (isCanvasResource(options.resource)) {\n resource = {type: 'canvas', id: options.resource.canvasId}\n } else if (isDatasetResource(options.resource)) {\n // use project-based routes for datasets to avoid existing CORS and Studio auth cookie issues\n projectId = options.resource.projectId\n dataset = options.resource.dataset\n }\n }\n\n const apiHost = options.apiHost ?? instance.config.auth?.apiHost ?? getStagingApiHost()\n\n const effectiveOptions: ClientConfig & {apiVersion: string} = {\n ...DEFAULT_CLIENT_CONFIG,\n ...((options.scope === 'global' || !projectId || resource) && {useProjectHostname: false}),\n token: authMethod === 'cookie' ? undefined : (tokenFromState ?? undefined),\n ...options,\n ...(projectId && {projectId}),\n ...(dataset && {dataset}),\n ...(resource ? {resource} : {resource: undefined}),\n ...(apiHost && {apiHost}),\n }\n\n // When a resource is provided, don't use projectId/dataset - the client should be \"projectless\"\n // The client code itself will ignore the non-resource config, so we do this to prevent confusing the user.\n // (ref: https://github.com/sanity-io/client/blob/5c23f81f5ab93a53f5b22b39845c867988508d84/src/data/dataMethods.ts#L691)\n if (resource) {\n delete effectiveOptions.projectId\n delete effectiveOptions.dataset\n }\n\n if (effectiveOptions.token === null || typeof effectiveOptions.token === 'undefined') {\n delete effectiveOptions.token\n if (authMethod === 'cookie') {\n effectiveOptions.withCredentials = true\n }\n } else {\n delete effectiveOptions.withCredentials\n }\n\n const key = getClientConfigKey(effectiveOptions)\n\n if (clients[key]) return clients[key]\n\n const client = createClient(effectiveOptions)\n state.set('addClient', (prev) => ({clients: {...prev.clients, [key]: client}}))\n\n return client\n },\n)\n\n/**\n * Returns a state source for the Sanity client instance.\n *\n * This function provides a subscribable state source that emits updated client\n * instances whenever relevant configurations change (such as authentication tokens).\n * Use this when you need to react to client configuration changes in your application.\n *\n * @public\n */\nexport const getClientState = bindActionGlobally(\n clientStore,\n createStateSourceAction(({instance}, options: ClientOptions) => getClient(instance, options)),\n)\n"],"mappings":";;;;;;;;;AAeA,MAiBM,cAAc,OAAO,KAAK;CAC9B,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,iBAAiB;CACjB,SAAS;CACT,YAAY;CACZ,SAAS;CACT,WAAW;CACX,OAAO;CACP,YAAY;CACZ,kBAAkB;CAClB,oBAAoB;CACpB,UAAU;AACZ,CAA6C,GAEvC,wBAAsC;CAC1C,YAAY;CACZ,QAAQ;CACR,2BAA2B;CAC3B,kBAAkB;CAClB,kBAAkB;AACpB,GA+CM,cAAc,YAA8B;CAChD,MAAM;CAEN,kBAAkB,cAAc;EAC9B,SAAS,CAAC;EACV,OAAO,cAAc,QAAQ,CAAC,CAAC,WAAW;CAC5C;CAEA,WAAW,SAAS;EAClB,IAAM,eAAe,cAAc,OAAO,GACpC,yBA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QAAQ,MAE3C,YAAY,QAAQ,SAAS,WAC7B,UAAU,QAAQ,SAAS;CAI/B,IAAM,UAAU,QAAQ,WAAW,SAAS,OAAO,MAAM,WAAW,kBAAkB,GAEhF,mBAAwD;EAC5D,GAAG;EACH,IAAK,QAAQ,UAAU,YAAY,CAAC,aAAa,aAAa,EAAC,oBAAoB,GAAK;EACxF,OAAO,eAAe,WAAW,KAAA,IAAa,kBAAkB,KAAA;EAChE,GAAG;EACH,GAAI,aAAa,EAAC,UAAS;EAC3B,GAAI,WAAW,EAAC,QAAO;EACvB,GAAI,WAAW,EAAC,SAAQ,IAAI,EAAC,UAAU,KAAA,EAAS;EAChD,GAAI,WAAW,EAAC,QAAO;CACzB;CAUA,AALI,aACF,OAAO,iBAAiB,WACxB,OAAO,iBAAiB,UAGtB,iBAAiB,UAAU,QAAe,iBAAiB,UAAU,UACvE,OAAO,iBAAiB,OACpB,eAAe,aACjB,iBAAiB,kBAAkB,OAGrC,OAAO,iBAAiB;CAG1B,IAAM,MAAM,mBAAmB,gBAAgB;CAE/C,IAAI,QAAQ,MAAM,OAAO,QAAQ;CAEjC,IAAM,SAAS,aAAa,gBAAgB;CAG5C,OAFA,MAAM,IAAI,cAAc,UAAU,EAAC,SAAS;EAAC,GAAG,KAAK;GAAU,MAAM;CAAM,EAAC,EAAE,GAEvE;AACT,CACF,GAWa,iBAAiB,mBAC5B,aACA,yBAAyB,EAAC,YAAW,YAA2B,UAAU,UAAU,OAAO,CAAC,CAC9F"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { _ as isCanvasResource, a as DatasetResource, b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, g as TokenSource, h as StudioConfig, i as DatasetHandle, l as MediaLibraryResource, m as SanityConfig, n as createSanityInstance, o as DocumentHandle, p as ReleasePerspective, r as CanvasResource, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, v as isDatasetResource, x as AuthProvider, y as isMediaLibraryResource } from "./createSanityInstance--Lrldto8.js";
|
|
2
2
|
import { n as StateSource, t as Selector } from "./createStateSourceAction-CICvr0ZE.js";
|
|
3
|
-
import { $ as Project, $i as getIsInDashboardState, $n as ResolveProjectionResult, $r as Logger, $t as DocumentPublishedEvent, A as stringifyPath, Ai as CommentTextSelectionItem, An as EditReleaseAction, At as SanityUser, B as getPerspectiveState, Bi as startOAuthAuthorization, Bn as createRelease, Br as InstallationAccess, Bt as SetFavoriteInput, C as SanityDocument, Ci as updateComment, Cn as CreateReleaseAction, Ct as TransportEvent, D as joinPaths, Di as CommentReaction, Dn as DocumentAction, Dt as Membership, E as getPathDepth, Ei as CommentMessage, En as DiscardDocumentAction, Et as GetUsersOptions, F as getUsersState, Fi as getClientState, Fn as UnarchiveReleaseAction, Fr as OrganizationBase, Ft as Organizations, Gi as AuthState, Gn as editRelease, Gr as InstallationsResponse, Gt as ApplyDocumentActionsOptions, H as getActiveReleasesState, Hi as handleAuthCallback, Hn as deleteRelease, Hr as InstallationBase, Ht as setFavorite, I as loadMoreUsers, Ii as getOAuthTokensState, In as UnpublishDocumentAction, Ir as OrganizationMember, It as OrganizationsOptions, J as resolveQuery, Ji as LoggedInAuthState, Jn as scheduleRelease, Jr as configureLogging, Jt as DocumentCreatedEvent, K as getQueryState, Ki as AuthStoreState, Kn as publishDocument, Kr as installation, Kt as applyDocumentActions, L as resolveUser, Li as handleOAuthCallback, Ln as UnscheduleReleaseAction, Lr as OrganizationOptions, Lt as organizations, M as isImportError, Mi as ClientOptions, Mn as PublishReleaseAction, Mt as UserProfile, N as getCorsErrorProjectId, Ni as ClientStoreState, Nn as ReleaseAction, Nt as UsersGroupState, O as jsonMatch, Oi as CommentStatus, On as EditDocumentAction, Ot as ResolveUserOptions, P as getUserState, Pi as getClient, Pn as ScheduleReleaseAction, Pr as Organization, Pt as UsersStoreState, Q as getProjectionState, Qi as getCurrentUserState, Qn as ResolveDocument, Qr as LogNamespace, Qt as DocumentEvent, R as resolveUsers, Ri as refreshOAuthTokens, Rn as archiveRelease, Rr as organization, Rt as FavoriteDocumentContext, S as Role, Si as setCommentStatus, Sn as CreateDocumentAction, St as StateEvent, T as getIndexForKey, Ti as CommentLocalState, Tn as DeleteReleaseAction, Tt as GetUserOptions, U as getAllReleasesState, Ui as observeOrganizationVerificationState, Un as discardDocument, Ur as InstallationInclude, Ut as getReleaseDocumentId, V as ReleaseState, Vi as logout, Vn as deleteDocument, Vr as InstallationActiveConfig, Vt as favorites, W as QueryOptions, Wi as OrgVerificationResult, Wn as editDocument, Wr as InstallationsOptions, Wt as ActionsResult, X as projects, Xi as LoggingInAuthState, Xn as unpublishDocument, Xr as LogContext, Xt as DocumentDiscardedEvent, Y as ProjectsOptions, Yi as LoggedOutAuthState, Yn as unarchiveRelease, Yr as InstanceContext, Yt as DocumentDeletedEvent, Z as resolveProjection, Zi as getAuthState, Zn as unscheduleRelease, Zr as LogLevel, Zt as DocumentEditedEvent, _ as applications, _i as SetCommentStatusOptions, _n as patchOperations, _t as PresencePerspectiveOptions, a as ApplicationInclude, aa as AccessResourceType, ai as createProjectHandle, an as TransactionSubmissionFailedEvent, at as project, b as CurrentUser, bi as removeComment, bn as Action, bt as ReportPresenceOptions, c as ApplicationStudioConfig, ci as getCommentThreadsState, cn as getDocumentSyncStatus, ct as PreviewValue, d as ApplicationsOptions, dn as resolvePermissions, dt as getPresence, ea as getLoginUrlState, ei as LoggerConfig, en as DocumentRemotePatchesEvent, er as ResolveQueryResult, et as ProjectBase, f as ApplicationsResponse, fi as resolveCommentThreads, fn as subscribeDocumentEvents, ft as reportPresence, g as application, gi as ReplyToCommentOptions, gn as ProcessMutationsOptions, gt as PresenceLocation, h as UpdateApplicationInput, hi as RemoveCommentOptions, hn as DocumentSet, ht as DocumentPresenceOptions, i as ApplicationDeployment, ia as AuthStateType, ii as createDocumentTypeHandle, in as TransactionRevertedEvent, ir as getDashboardOrganizationId, it as ProjectOptions, j as CORE_SDK_VERSION, ji as CommentThread, jn as PublishDocumentAction, jt as SanityUserResponse, k as slicePath, ki as CommentTextSelection, kn as EditDocumentOptions, kt as ResolveUsersOptions, l as ApplicationVisibility, ln as getPermissionsState, lt as ProjectionValuePending, m as DeletedResult, mi as CreateCommentOptions, mn as PermissionDeniedReason, mt as DocumentPresence, n as ApplicationAccess, na as setAuthToken, ni as createDatasetHandle, nn as DocumentUnpublishedEvent, nt as ProjectMemberRole, o as ApplicationInterface, oa as checkPermissions, oi as CommentsOptions, on as DocumentOptions, ot as PreviewMedia, p as DeleteApplicationInput, pi as resolveComments, pn as DocumentPermissionsResult, pt as DisconnectEvent, qi as ErrorAuthState, qn as publishRelease, qr as installations, qt as ActionErrorEvent, r as ApplicationBase, ra as OAuthTokens, ri as createDocumentHandle, rn as TransactionAcceptedEvent, rt as ProjectMetadata, s as ApplicationInterfacePlacementMetadata, si as ResolveCommentsOptions, sn as getDocumentState, st as PreviewQueryResult, t as Application, ta as getTokenState, tn as DocumentTransactionSubmissionResult, tr as datasets, tt as ProjectMember, u as ApplicationWorkspace, ui as getCommentsState, un as resolveDocument, ut as getDocumentPresence, v as deleteApplication, vi as UpdateCommentOptions, vn as processMutations, vt as PresenceSelection, w as SanityProject, wi as Comment, wn as DeleteDocumentAction, wt as UserPresence, x as ReleaseDocument, xi as replyToComment, xn as ArchiveReleaseAction, xt as RollCallEvent, y as updateApplication, yi as createComment, yn as JsonMatch, yt as PresenceSelectionPoint, z as defineProjection, zi as revokeOAuthTokens, zn as createDocument, zr as Installation, zt as FavoriteStatusResponse } from "./applications-
|
|
3
|
+
import { $ as Project, $i as getIsInDashboardState, $n as ResolveProjectionResult, $r as Logger, $t as DocumentPublishedEvent, A as stringifyPath, Ai as CommentTextSelectionItem, An as EditReleaseAction, At as SanityUser, B as getPerspectiveState, Bi as startOAuthAuthorization, Bn as createRelease, Br as InstallationAccess, Bt as SetFavoriteInput, C as SanityDocument, Ci as updateComment, Cn as CreateReleaseAction, Ct as TransportEvent, D as joinPaths, Di as CommentReaction, Dn as DocumentAction, Dt as Membership, E as getPathDepth, Ei as CommentMessage, En as DiscardDocumentAction, Et as GetUsersOptions, F as getUsersState, Fi as getClientState, Fn as UnarchiveReleaseAction, Fr as OrganizationBase, Ft as Organizations, Gi as AuthState, Gn as editRelease, Gr as InstallationsResponse, Gt as ApplyDocumentActionsOptions, H as getActiveReleasesState, Hi as handleAuthCallback, Hn as deleteRelease, Hr as InstallationBase, Ht as setFavorite, I as loadMoreUsers, Ii as getOAuthTokensState, In as UnpublishDocumentAction, Ir as OrganizationMember, It as OrganizationsOptions, J as resolveQuery, Ji as LoggedInAuthState, Jn as scheduleRelease, Jr as configureLogging, Jt as DocumentCreatedEvent, K as getQueryState, Ki as AuthStoreState, Kn as publishDocument, Kr as installation, Kt as applyDocumentActions, L as resolveUser, Li as handleOAuthCallback, Ln as UnscheduleReleaseAction, Lr as OrganizationOptions, Lt as organizations, M as isImportError, Mi as ClientOptions, Mn as PublishReleaseAction, Mt as UserProfile, N as getCorsErrorProjectId, Ni as ClientStoreState, Nn as ReleaseAction, Nt as UsersGroupState, O as jsonMatch, Oi as CommentStatus, On as EditDocumentAction, Ot as ResolveUserOptions, P as getUserState, Pi as getClient, Pn as ScheduleReleaseAction, Pr as Organization, Pt as UsersStoreState, Q as getProjectionState, Qi as getCurrentUserState, Qn as ResolveDocument, Qr as LogNamespace, Qt as DocumentEvent, R as resolveUsers, Ri as refreshOAuthTokens, Rn as archiveRelease, Rr as organization, Rt as FavoriteDocumentContext, S as Role, Si as setCommentStatus, Sn as CreateDocumentAction, St as StateEvent, T as getIndexForKey, Ti as CommentLocalState, Tn as DeleteReleaseAction, Tt as GetUserOptions, U as getAllReleasesState, Ui as observeOrganizationVerificationState, Un as discardDocument, Ur as InstallationInclude, Ut as getReleaseDocumentId, V as ReleaseState, Vi as logout, Vn as deleteDocument, Vr as InstallationActiveConfig, Vt as favorites, W as QueryOptions, Wi as OrgVerificationResult, Wn as editDocument, Wr as InstallationsOptions, Wt as ActionsResult, X as projects, Xi as LoggingInAuthState, Xn as unpublishDocument, Xr as LogContext, Xt as DocumentDiscardedEvent, Y as ProjectsOptions, Yi as LoggedOutAuthState, Yn as unarchiveRelease, Yr as InstanceContext, Yt as DocumentDeletedEvent, Z as resolveProjection, Zi as getAuthState, Zn as unscheduleRelease, Zr as LogLevel, Zt as DocumentEditedEvent, _ as applications, _i as SetCommentStatusOptions, _n as patchOperations, _t as PresencePerspectiveOptions, a as ApplicationInclude, aa as AccessResourceType, ai as createProjectHandle, an as TransactionSubmissionFailedEvent, at as project, b as CurrentUser, bi as removeComment, bn as Action, bt as ReportPresenceOptions, c as ApplicationStudioConfig, ci as getCommentThreadsState, cn as getDocumentSyncStatus, ct as PreviewValue, d as ApplicationsOptions, dn as resolvePermissions, dt as getPresence, ea as getLoginUrlState, ei as LoggerConfig, en as DocumentRemotePatchesEvent, er as ResolveQueryResult, et as ProjectBase, f as ApplicationsResponse, fi as resolveCommentThreads, fn as subscribeDocumentEvents, ft as reportPresence, g as application, gi as ReplyToCommentOptions, gn as ProcessMutationsOptions, gt as PresenceLocation, h as UpdateApplicationInput, hi as RemoveCommentOptions, hn as DocumentSet, ht as DocumentPresenceOptions, i as ApplicationDeployment, ia as AuthStateType, ii as createDocumentTypeHandle, in as TransactionRevertedEvent, ir as getDashboardOrganizationId, it as ProjectOptions, j as CORE_SDK_VERSION, ji as CommentThread, jn as PublishDocumentAction, jt as SanityUserResponse, k as slicePath, ki as CommentTextSelection, kn as EditDocumentOptions, kt as ResolveUsersOptions, l as ApplicationVisibility, ln as getPermissionsState, lt as ProjectionValuePending, m as DeletedResult, mi as CreateCommentOptions, mn as PermissionDeniedReason, mt as DocumentPresence, n as ApplicationAccess, na as setAuthToken, ni as createDatasetHandle, nn as DocumentUnpublishedEvent, nt as ProjectMemberRole, o as ApplicationInterface, oa as checkPermissions, oi as CommentsOptions, on as DocumentOptions, ot as PreviewMedia, p as DeleteApplicationInput, pi as resolveComments, pn as DocumentPermissionsResult, pt as DisconnectEvent, qi as ErrorAuthState, qn as publishRelease, qr as installations, qt as ActionErrorEvent, r as ApplicationBase, ra as OAuthTokens, ri as createDocumentHandle, rn as TransactionAcceptedEvent, rt as ProjectMetadata, s as ApplicationInterfacePlacementMetadata, si as ResolveCommentsOptions, sn as getDocumentState, st as PreviewQueryResult, t as Application, ta as getTokenState, tn as DocumentTransactionSubmissionResult, tr as datasets, tt as ProjectMember, u as ApplicationWorkspace, ui as getCommentsState, un as resolveDocument, ut as getDocumentPresence, v as deleteApplication, vi as UpdateCommentOptions, vn as processMutations, vt as PresenceSelection, w as SanityProject, wi as Comment, wn as DeleteDocumentAction, wt as UserPresence, x as ReleaseDocument, xi as replyToComment, xn as ArchiveReleaseAction, xt as RollCallEvent, y as updateApplication, yi as createComment, yn as JsonMatch, yt as PresenceSelectionPoint, z as defineProjection, zi as revokeOAuthTokens, zn as createDocument, zr as Installation, zt as FavoriteStatusResponse } from "./applications-BioeDdGe.js";
|
|
4
4
|
export { type AccessResourceType, type Action, type ActionErrorEvent, type ActionsResult, type Application, type ApplicationAccess, type ApplicationBase, type ApplicationDeployment, type ApplicationInclude, type ApplicationInterface, type ApplicationInterfacePlacementMetadata, type ApplicationStudioConfig, type ApplicationVisibility, type ApplicationWorkspace, type ApplicationsOptions, type ApplicationsResponse, type ApplyDocumentActionsOptions, type ArchiveReleaseAction, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasResource, type ClientOptions, type ClientStoreState as ClientState, type Comment, type CommentLocalState, type CommentMessage, type CommentReaction, type CommentStatus, type CommentTextSelection, type CommentTextSelectionItem, type CommentThread, type CommentsOptions, type CreateCommentOptions, type CreateDocumentAction, type CreateReleaseAction, type CurrentUser, type DatasetHandle, type DatasetResource, type DeleteApplicationInput, type DeleteDocumentAction, type DeleteReleaseAction, type DeletedResult, type DiscardDocumentAction, type DisconnectEvent, type DocumentAction, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentDiscardedEvent, type DocumentEditedEvent, type DocumentEvent, type DocumentHandle, type DocumentOptions, type DocumentPermissionsResult, type DocumentPresence, type DocumentPresenceOptions, type DocumentPublishedEvent, type DocumentRemotePatchesEvent, type DocumentResource, type DocumentSet, type DocumentTransactionSubmissionResult, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type EditDocumentOptions, type EditReleaseAction, type ErrorAuthState, type FavoriteDocumentContext, type FavoriteStatusResponse, type GetUserOptions, type GetUsersOptions, type Installation, type InstallationAccess, type InstallationActiveConfig, type InstallationBase, type InstallationInclude, type InstallationsOptions, type InstallationsResponse, type InstanceContext, type JsonMatch, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibraryResource, type Membership, type OAuthTokens, type OrgVerificationResult, type Organization, type OrganizationBase, type OrganizationMember, type OrganizationOptions, type Organizations, type OrganizationsOptions, type PermissionDeniedReason, type PerspectiveHandle, type PresenceLocation, type PresencePerspectiveOptions, type PresenceSelection, type PresenceSelectionPoint, type PreviewMedia, type PreviewQueryResult, type PreviewValue, type ProcessMutationsOptions, type Project, type ProjectBase, type ProjectHandle, type ProjectMember, type ProjectMemberRole, type ProjectMetadata, type ProjectOptions, type ProjectionValuePending, type ProjectsOptions, type PublishDocumentAction, type PublishReleaseAction, type QueryOptions, type ReleaseAction, type ReleaseDocument, type ReleaseHandle, type ReleasePerspective, type ReleaseState, type RemoveCommentOptions, type ReplyToCommentOptions, type ReportPresenceOptions, type ResolveCommentsOptions, type ResolveDocument, type ResolveProjectionResult, type ResolveQueryResult, type ResolveUserOptions, type ResolveUsersOptions, type Role, type RollCallEvent, type SanityConfig, type SanityDocument, type SanityInstance, SanityProject, type SanityUser, type SanityUserResponse, type ScheduleReleaseAction, type Selector, type SetCommentStatusOptions, type SetFavoriteInput, type StateEvent, type StateSource, type StudioConfig, type TokenSource, type TransactionAcceptedEvent, type TransactionRevertedEvent, type TransactionSubmissionFailedEvent, type TransportEvent, type UnarchiveReleaseAction, type UnpublishDocumentAction, type UnscheduleReleaseAction, type UpdateApplicationInput, type UpdateCommentOptions, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, application, applications, applyDocumentActions, archiveRelease, checkPermissions, configureLogging, createComment, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createProjectHandle, createRelease, createSanityInstance, datasets, defineProjection, deleteApplication, deleteDocument, deleteRelease, discardDocument, editDocument, editRelease, favorites, getActiveReleasesState, getAllReleasesState, getAuthState, getClient, getClientState, getCommentThreadsState, getCommentsState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDocumentPresence, getDocumentState, getDocumentSyncStatus, getIndexForKey, getIsInDashboardState, getLoginUrlState, getOAuthTokensState, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getProjectionState, getQueryState, getReleaseDocumentId, getTokenState, getUserState, getUsersState, handleAuthCallback, handleOAuthCallback, installation, installations, isCanvasResource, isDatasetResource, isImportError, isMediaLibraryResource, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, organization, organizations, patchOperations, processMutations, project, projects, publishDocument, publishRelease, refreshOAuthTokens, removeComment, replyToComment, reportPresence, resolveCommentThreads, resolveComments, resolveDocument, resolvePermissions, resolveProjection, resolveQuery, resolveUser, resolveUsers, revokeOAuthTokens, scheduleRelease, setAuthToken, setCommentStatus, setFavorite, slicePath, startOAuthAuthorization, stringifyPath, subscribeDocumentEvents, unarchiveRelease, unpublishDocument, unscheduleRelease, updateApplication, updateComment };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as cleanupTimer, f as isReleasePerspective, h as isMediaLibraryResource, i as bindActionGlobally, m as isDatasetResource, n as bindActionByResource, o as UPSTREAM_CLOSE_DELAY_MS, p as isCanvasResource, r as bindActionByResourceAndPerspective, s as defineStore, t as createStateSourceAction, u as setCleanupTimeout } from "./createStateSourceAction-Bn0po7Z3.js";
|
|
2
|
-
import { A as toCommentsKeyParts, B as setPendingTransaction, C as commentsStore, E as getCommentsState, F as receiveComment, G as provisionAddonDataset, H as toCommentFieldPath, I as removeCommentById, J as defineMutation, K as COMMENTS_API_VERSION, L as restoreComments, M as applyCommentUpdate, N as clearPendingTransaction, O as resolveCommentThreads, P as getCommentsKey, R as rollbackCommentUpdate, U as assertDatasetResource, V as normalizeComment, W as getAddonDatasetState, X as randomUuid, Y as randomId, _ as updateLastLoadMoreRequest, a as resolveQuery, b as favorites, c as getAllReleasesState, d as getUsersKey, f as initializeRequest, g as setUsersError, h as setUsersData, j as addComment, k as resolveComments, l as addSubscription, m as removeSubscription, o as getPerspectiveState, p as parseUsersKey, q as defineFetcher, r as getQueryState, s as getActiveReleasesState, t as CORE_SDK_VERSION, u as cancelRequest, v as PROJECT_API_VERSION, w as getCommentThreadsState, x as setFavorite, y as USERS_STATE_CLEAR_DELAY, z as setCommentCreateError } from "./version-
|
|
3
|
-
import { A as
|
|
2
|
+
import { A as toCommentsKeyParts, B as setPendingTransaction, C as commentsStore, E as getCommentsState, F as receiveComment, G as provisionAddonDataset, H as toCommentFieldPath, I as removeCommentById, J as defineMutation, K as COMMENTS_API_VERSION, L as restoreComments, M as applyCommentUpdate, N as clearPendingTransaction, O as resolveCommentThreads, P as getCommentsKey, R as rollbackCommentUpdate, U as assertDatasetResource, V as normalizeComment, W as getAddonDatasetState, X as randomUuid, Y as randomId, _ as updateLastLoadMoreRequest, a as resolveQuery, b as favorites, c as getAllReleasesState, d as getUsersKey, f as initializeRequest, g as setUsersError, h as setUsersData, j as addComment, k as resolveComments, l as addSubscription, m as removeSubscription, o as getPerspectiveState, p as parseUsersKey, q as defineFetcher, r as getQueryState, s as getActiveReleasesState, t as CORE_SDK_VERSION, u as cancelRequest, v as PROJECT_API_VERSION, w as getCommentThreadsState, x as setFavorite, y as USERS_STATE_CLEAR_DELAY, z as setCommentCreateError } from "./version-D68H4Kcd.js";
|
|
3
|
+
import { A as DEFAULT_API_VERSION, D as AuthStateType, M as REQUEST_TAG_PREFIX, T as getTokenFromLocation, U as configureLogging$1, V as getAuthLogger, W as createLogger, _ as createLoggedInAuthState, a as getCurrentUserState, c as getTokenState, d as appendResourceIndicator, f as createOAuthClient, g as toOAuthTokens, h as serializeTokens, i as getAuthState, j as DEFAULT_BASE, l as setAuthToken, m as postTokenRequest, o as getIsInDashboardState, p as getOAuthOptions, s as getLoginUrlState, t as authStore, u as runOAuthTokenRefresh, v as getAuthCode, w as getDefaultLocation, y as getCleanedUrl, z as _defineProperty } from "./authStore-CwZPW3jK.js";
|
|
4
4
|
import { r as omitProperty, t as isDeepEqual } from "./object-CxXlSVg7.js";
|
|
5
|
-
import { n as getClient, r as getClientState } from "./clientStore-
|
|
6
|
-
import { n as getDashboardOrganizationId } from "./topicStore-
|
|
5
|
+
import { n as getClient, r as getClientState } from "./clientStore-iv9ooGew.js";
|
|
6
|
+
import { n as getDashboardOrganizationId } from "./topicStore-CjKrnfeL.js";
|
|
7
7
|
import { ClientError, CorsOriginError, ServerError } from "@sanity/client";
|
|
8
8
|
import { EMPTY, NEVER, Observable, ReplaySubject, 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, skip, startWith, switchMap, take, takeUntil, tap, throttle, throwError, timer, withLatestFrom } from "rxjs";
|
|
9
9
|
import { isKeySegment, isKeyedObject } from "@sanity/types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as createActionBinder, i as bindActionGlobally, s as defineStore, t as createStateSourceAction, u as setCleanupTimeout } from "./createStateSourceAction-Bn0po7Z3.js";
|
|
2
|
-
import {
|
|
2
|
+
import { L as isMessageBusInstalled, P as connectMessageBus, o as getIsInDashboardState, t as authStore, z as _defineProperty } from "./authStore-CwZPW3jK.js";
|
|
3
3
|
import { distinctUntilChanged, map, skip } from "rxjs";
|
|
4
4
|
/**
|
|
5
5
|
* Returns the message bus connection for this instance, connecting on first call.
|
|
@@ -130,4 +130,4 @@ function getDashboardOrganizationId(instance) {
|
|
|
130
130
|
}
|
|
131
131
|
export { getDashboardMessageBus as a, resolveTopic as i, getDashboardOrganizationId as n, isDashboardEnvironment as o, getTopicState as r, requireDashboardMessageBus as s, TopicError as t };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=topicStore-
|
|
133
|
+
//# sourceMappingURL=topicStore-CjKrnfeL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topicStore-D5RKaWQk.js","names":["bindActionByInstance"],"sources":["../src/dashboard/messageBus/store.ts","../src/dashboard/messageBus/topicStore.ts"],"sourcesContent":["import {getIsInDashboardState} from '../../auth/authStore'\nimport {createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {defineStore} from '../../store/defineStore'\nimport {connectMessageBus, isMessageBusInstalled, type MessageBusConnection} from './bus'\n\ninterface DashboardMessageBusState {\n connection?: MessageBusConnection\n}\n\nconst bindActionByInstance = createActionBinder<{name: string}, [moduleId?: string]>(\n (instance) => ({name: instance.instanceId}),\n)\n\nconst dashboardMessageBusStore = defineStore<DashboardMessageBusState>({\n name: 'dashboardMessageBus',\n getInitialState: () => ({}),\n // Runs when the instance is disposed, tearing down this window's connection.\n initialize:\n ({state}) =>\n () =>\n state.get().connection?.disconnect(),\n})\n\n/**\n * Returns the message bus connection for this instance, connecting on first call.\n *\n * @remarks\n * One connection is made per {@link SanityInstance}, carrying that window's\n * module identity. The first caller wins; later callers get the cached\n * connection. When no host bus is installed it returns `undefined` without\n * caching, so a later call retries once a host installs the bus.\n * @internal\n */\nexport const getDashboardMessageBus = bindActionByInstance(\n dashboardMessageBusStore,\n ({state}, moduleId?: string): MessageBusConnection | undefined => {\n const current = state.get().connection\n if (current) return current\n if (!isMessageBusInstalled()) return undefined\n const connection = connectMessageBus({moduleId})\n if (!connection) return undefined\n state.set('connect', {connection})\n return connection\n },\n)\n\n/**\n * Returns the instance's message bus connection, or throws when no dashboard host has\n * installed a bus. `action` names what the caller was about to do, e.g. `read topic \"x\"`.\n * @internal\n */\nexport function requireDashboardMessageBus(\n instance: SanityInstance,\n action: string,\n): MessageBusConnection {\n const messageBus = getDashboardMessageBus(instance)\n if (!messageBus) {\n throw new Error(`Cannot ${action} without an installed dashboard message bus`)\n }\n return messageBus\n}\n\n/**\n * Returns whether a dashboard hosts the instance, over Comlink or an installed message bus.\n *\n * @remarks\n * Answers \"does a host own this session\", not \"has this instance connected yet\". Callers\n * such as the login redirect run before {@link getDashboardMessageBus} has been called for\n * the instance, so this must not depend on the connection state.\n * @internal\n */\nexport function isDashboardEnvironment(instance: SanityInstance): boolean {\n return getIsInDashboardState(instance).getCurrent() || isMessageBusInstalled()\n}\n","import {distinctUntilChanged, map, skip} from 'rxjs'\n\nimport {authStore} from '../../auth/authStore'\nimport {bindActionGlobally, createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {createStateSourceAction, type StateSource} from '../../store/createStateSourceAction'\nimport {defineStore} from '../../store/defineStore'\nimport {setCleanupTimeout} from '../../utils/setCleanupTimeout'\nimport {type MessageBus, type MessageBusStateSource} from './bus'\nimport {getDashboardMessageBus, requireDashboardMessageBus} from './store'\nimport {type StateTopic, type ValueOf} from './topics'\n\n/**\n * An error raised when a dashboard state topic reports failure.\n * @public\n * @category Message Bus\n */\nexport class TopicError extends Error {\n /** The topic that failed. */\n readonly topic: StateTopic\n\n /** Creates an error for a failed topic. */\n constructor(topic: StateTopic) {\n super(`Topic \"${topic}\" failed`)\n this.name = 'TopicError'\n this.topic = topic\n }\n}\n\n/**\n * The value of a state topic, with `TopicResult` wrappers unwrapped to their success value.\n * @public\n * @category Message Bus\n */\nexport type TopicData<K extends StateTopic> =\n ValueOf<K> extends infer Value\n ? Value extends {ok: true; value: infer Success}\n ? Success\n : Value extends {ok: false}\n ? never\n : Value\n : never\n\n// Mirrors the `TopicResult` shape declared in the topic manifest; no plain-value topic has an `ok` field.\nfunction isTopicResult(value: unknown): value is {ok: boolean; value?: unknown} {\n return (\n typeof value === 'object' && value !== null && 'ok' in value && typeof value.ok === 'boolean'\n )\n}\n\nfunction unwrapTopicResult(topic: StateTopic, value: unknown): unknown {\n if (!isTopicResult(value)) return value\n if (!value.ok) throw new TopicError(topic)\n return value.value\n}\n\ninterface TopicEntry {\n /** Why the first-value query failed. Dropped with the entry when its last subscriber leaves. */\n error?: unknown\n /** The in-flight first-value query, shared by every suspended render of the topic. */\n pending?: Promise<void>\n subscribers: number\n}\n\ninterface DashboardTopicsState {\n topics: {[topic: string]: TopicEntry}\n}\n\n// Matches the query store: a suspended component re-renders after its promise settles before\n// the temporary subscriber is released, so it still sees the recorded failure.\nconst TOPIC_STATE_CLEAR_DELAY = 1000\n\nconst bindActionByInstance = createActionBinder<{name: string}, [topic: StateTopic]>(\n (instance) => ({name: instance.instanceId}),\n)\n\n// The bus is the source of truth for topic values (it already keeps one replaying source per\n// topic). This store only tracks what the bus cannot: read failures and who is still reading.\nconst dashboardTopicsStore = defineStore<DashboardTopicsState>({\n name: 'dashboardTopics',\n getInitialState: () => ({topics: {}}),\n})\n\nconst getMessageBus = (instance: SanityInstance, topic: StateTopic): MessageBus =>\n requireDashboardMessageBus(instance, `read topic \"${topic}\"`)\n\nfunction getSource(instance: SanityInstance, topic: StateTopic): MessageBusStateSource<unknown> {\n return getMessageBus(instance, topic).subscribe(topic)\n}\n\n// An entry lives as long as it has subscribers. Dropping it with the last one is what gives a\n// later mount a fresh deadline instead of a stale failure.\nconst updateEntry =\n (topic: string, update: (entry: TopicEntry) => TopicEntry) =>\n (state: DashboardTopicsState): DashboardTopicsState => {\n const {[topic]: entry = {subscribers: 0}, ...rest} = state.topics\n const next = update(entry)\n return {topics: next.subscribers > 0 ? {...rest, [topic]: next} : rest}\n }\n\nconst addSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers + 1}))\n\nconst removeSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers - 1}))\n\n/**\n * A state source for a dashboard state topic, with `TopicResult` wrappers unwrapped.\n *\n * @remarks\n * Returns `undefined` until the topic publishes; use {@link resolveTopic} to wait for that\n * first value. While the topic is still unpublished, reading throws the failure that\n * {@link resolveTopic} recorded. A published value takes precedence over a recorded failure,\n * and a {@link TopicError} is thrown when the topic itself reports failure. A thrown failure\n * ends the subscription, so a reader recovers by subscribing again.\n * @internal\n */\nexport const getTopicState = bindActionByInstance(\n dashboardTopicsStore,\n createStateSourceAction({\n selector: ({state, instance}, topic: StateTopic) => {\n const current = getSource(instance, topic).getCurrent()\n // A recorded failure only describes the wait for a first value; a published value wins.\n const entry = state.topics[topic]\n if (current === undefined && entry?.error) throw entry.error\n return unwrapTopicResult(topic, current)\n },\n onSubscribe: ({state, instance}, topic: StateTopic) => {\n state.set('addSubscriber', addSubscriber(topic))\n // Each publish writes a fresh state object so the selector re-runs against the bus.\n const subscription = getSource(instance, topic).subscribe(() =>\n state.set(\n 'publish',\n updateEntry(topic, (entry) => ({...entry})),\n ),\n )\n return () => {\n subscription.unsubscribe()\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n }\n },\n }),\n)\n\n/**\n * Resolves once a dashboard state topic has published, or records the failure for\n * {@link getTopicState} to throw. Repeated calls for a pending topic share one query.\n *\n * @remarks\n * Holds a temporary subscriber while the query is in flight so a failure recorded after the\n * reading component has gone is dropped with it, rather than thrown at the next mount.\n * @internal\n */\nexport const resolveTopic = bindActionByInstance(\n dashboardTopicsStore,\n ({state, instance}, topic: StateTopic): Promise<void> => {\n const existing = state.get().topics[topic]?.pending\n if (existing) return existing\n\n const release = () =>\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n const pending = getMessageBus(instance, topic)\n .query(topic)\n .then(\n () =>\n state.set(\n 'resolved',\n updateEntry(topic, ({pending: _pending, ...entry}) => entry),\n ),\n (error: unknown) =>\n state.set(\n 'failed',\n updateEntry(topic, ({pending: _pending, ...entry}) => ({...entry, error})),\n ),\n )\n pending.then(release, release)\n state.set(\n 'query',\n updateEntry(topic, (entry) => ({...entry, pending, subscribers: entry.subscribers + 1})),\n )\n return pending\n },\n)\n\nconst getComlinkOrganizationId = bindActionGlobally(\n authStore,\n createStateSourceAction(({state: {dashboardContext}}) => dashboardContext?.orgId),\n)\n\ntype CurrentOrganization = TopicData<'organizations.current'> | undefined\n\n/**\n * Returns the organization the dashboard has selected: the `organizations.current` topic on a\n * message bus, or the `_context` URL param in a Comlink dashboard.\n * @public\n */\nexport function getDashboardOrganizationId(\n instance: SanityInstance,\n): StateSource<string | undefined> {\n if (!getDashboardMessageBus(instance)) return getComlinkOrganizationId(instance)\n const organization = getTopicState(instance, 'organizations.current')\n const observable = organization.observable.pipe(\n map((value) => (value as CurrentOrganization)?.id),\n distinctUntilChanged(),\n )\n return {\n subscribe: (onStoreChanged) => {\n const subscription = observable.pipe(skip(1)).subscribe({\n next: () => onStoreChanged?.(),\n error: () => onStoreChanged?.(),\n })\n return () => subscription.unsubscribe()\n },\n getCurrent: () => (organization.getCurrent() as CurrentOrganization)?.id,\n observable,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAa,yBAxBgB,oBAC1B,cAAc,EAAC,MAAM,SAAS,WAAU,EAuBLA,CAAAA,CApBL,YAAsC;CACrE,MAAM;CACN,wBAAwB,CAAC;CAEzB,aACG,EAAC,kBAEA,MAAM,IAAI,CAAC,CAAC,YAAY,WAAW;AACzC,CAaE,IACC,EAAC,SAAQ,aAAwD;CAChE,IAAM,UAAU,MAAM,IAAI,CAAC,CAAC;CAC5B,IAAI,SAAS,OAAO;CACpB,IAAI,CAAC,sBAAsB,GAAG;CAC9B,IAAM,aAAa,kBAAkB,EAAC,SAAQ,CAAC;CAC/C,IAAK,YAE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,EAAC,SAAS,UAAU,GAAG,aAAY;EAAC,GAAG;EAAO;CAAK,EAAE,CAC3E,CACJ;CAMF,OALA,QAAQ,KAAK,SAAS,OAAO,GAC7B,MAAM,IACJ,SACA,YAAY,QAAQ,WAAW;EAAC,GAAG;EAAO;EAAS,aAAa,MAAM,cAAc;CAAC,EAAE,CACzF,GACO;AACT,CACF,GAEM,2BAA2B,mBAC/B,WACA,yBAAyB,EAAC,OAAO,EAAC,yBAAuB,kBAAkB,KAAK,CAClF;;;;;;AASA,SAAgB,2BACd,UACiC;CACjC,IAAI,CAAC,uBAAuB,QAAQ,GAAG,OAAO,yBAAyB,QAAQ;CAC/E,IAAM,eAAe,cAAc,UAAU,uBAAuB,GAC9D,aAAa,aAAa,WAAW,KACzC,KAAK,UAAW,OAA+B,EAAE,GACjD,qBAAqB,CACvB;CACA,OAAO;EACL,YAAY,mBAAmB;GAC7B,IAAM,eAAe,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU;IACtD,YAAY,iBAAiB;IAC7B,aAAa,iBAAiB;GAChC,CAAC;GACD,aAAa,aAAa,YAAY;EACxC;EACA,kBAAmB,aAAa,WAAW,CAAC,EAA0B;EACtE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"topicStore-CjKrnfeL.js","names":["bindActionByInstance"],"sources":["../src/dashboard/messageBus/store.ts","../src/dashboard/messageBus/topicStore.ts"],"sourcesContent":["import {getIsInDashboardState} from '../../auth/authStore'\nimport {createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {defineStore} from '../../store/defineStore'\nimport {connectMessageBus, isMessageBusInstalled, type MessageBusConnection} from './bus'\n\ninterface DashboardMessageBusState {\n connection?: MessageBusConnection\n}\n\nconst bindActionByInstance = createActionBinder<{name: string}, [moduleId?: string]>(\n (instance) => ({name: instance.instanceId}),\n)\n\nconst dashboardMessageBusStore = defineStore<DashboardMessageBusState>({\n name: 'dashboardMessageBus',\n getInitialState: () => ({}),\n // Runs when the instance is disposed, tearing down this window's connection.\n initialize:\n ({state}) =>\n () =>\n state.get().connection?.disconnect(),\n})\n\n/**\n * Returns the message bus connection for this instance, connecting on first call.\n *\n * @remarks\n * One connection is made per {@link SanityInstance}, carrying that window's\n * module identity. The first caller wins; later callers get the cached\n * connection. When no host bus is installed it returns `undefined` without\n * caching, so a later call retries once a host installs the bus.\n * @internal\n */\nexport const getDashboardMessageBus = bindActionByInstance(\n dashboardMessageBusStore,\n ({state}, moduleId?: string): MessageBusConnection | undefined => {\n const current = state.get().connection\n if (current) return current\n if (!isMessageBusInstalled()) return undefined\n const connection = connectMessageBus({moduleId})\n if (!connection) return undefined\n state.set('connect', {connection})\n return connection\n },\n)\n\n/**\n * Returns the instance's message bus connection, or throws when no dashboard host has\n * installed a bus. `action` names what the caller was about to do, e.g. `read topic \"x\"`.\n * @internal\n */\nexport function requireDashboardMessageBus(\n instance: SanityInstance,\n action: string,\n): MessageBusConnection {\n const messageBus = getDashboardMessageBus(instance)\n if (!messageBus) {\n throw new Error(`Cannot ${action} without an installed dashboard message bus`)\n }\n return messageBus\n}\n\n/**\n * Returns whether a dashboard hosts the instance, over Comlink or an installed message bus.\n *\n * @remarks\n * Answers \"does a host own this session\", not \"has this instance connected yet\". Callers\n * such as the login redirect run before {@link getDashboardMessageBus} has been called for\n * the instance, so this must not depend on the connection state.\n * @internal\n */\nexport function isDashboardEnvironment(instance: SanityInstance): boolean {\n return getIsInDashboardState(instance).getCurrent() || isMessageBusInstalled()\n}\n","import {distinctUntilChanged, map, skip} from 'rxjs'\n\nimport {authStore} from '../../auth/authStore'\nimport {bindActionGlobally, createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {createStateSourceAction, type StateSource} from '../../store/createStateSourceAction'\nimport {defineStore} from '../../store/defineStore'\nimport {setCleanupTimeout} from '../../utils/setCleanupTimeout'\nimport {type MessageBus, type MessageBusStateSource} from './bus'\nimport {getDashboardMessageBus, requireDashboardMessageBus} from './store'\nimport {type StateTopic, type ValueOf} from './topics'\n\n/**\n * An error raised when a dashboard state topic reports failure.\n * @public\n * @category Message Bus\n */\nexport class TopicError extends Error {\n /** The topic that failed. */\n readonly topic: StateTopic\n\n /** Creates an error for a failed topic. */\n constructor(topic: StateTopic) {\n super(`Topic \"${topic}\" failed`)\n this.name = 'TopicError'\n this.topic = topic\n }\n}\n\n/**\n * The value of a state topic, with `TopicResult` wrappers unwrapped to their success value.\n * @public\n * @category Message Bus\n */\nexport type TopicData<K extends StateTopic> =\n ValueOf<K> extends infer Value\n ? Value extends {ok: true; value: infer Success}\n ? Success\n : Value extends {ok: false}\n ? never\n : Value\n : never\n\n// Mirrors the `TopicResult` shape declared in the topic manifest; no plain-value topic has an `ok` field.\nfunction isTopicResult(value: unknown): value is {ok: boolean; value?: unknown} {\n return (\n typeof value === 'object' && value !== null && 'ok' in value && typeof value.ok === 'boolean'\n )\n}\n\nfunction unwrapTopicResult(topic: StateTopic, value: unknown): unknown {\n if (!isTopicResult(value)) return value\n if (!value.ok) throw new TopicError(topic)\n return value.value\n}\n\ninterface TopicEntry {\n /** Why the first-value query failed. Dropped with the entry when its last subscriber leaves. */\n error?: unknown\n /** The in-flight first-value query, shared by every suspended render of the topic. */\n pending?: Promise<void>\n subscribers: number\n}\n\ninterface DashboardTopicsState {\n topics: {[topic: string]: TopicEntry}\n}\n\n// Matches the query store: a suspended component re-renders after its promise settles before\n// the temporary subscriber is released, so it still sees the recorded failure.\nconst TOPIC_STATE_CLEAR_DELAY = 1000\n\nconst bindActionByInstance = createActionBinder<{name: string}, [topic: StateTopic]>(\n (instance) => ({name: instance.instanceId}),\n)\n\n// The bus is the source of truth for topic values (it already keeps one replaying source per\n// topic). This store only tracks what the bus cannot: read failures and who is still reading.\nconst dashboardTopicsStore = defineStore<DashboardTopicsState>({\n name: 'dashboardTopics',\n getInitialState: () => ({topics: {}}),\n})\n\nconst getMessageBus = (instance: SanityInstance, topic: StateTopic): MessageBus =>\n requireDashboardMessageBus(instance, `read topic \"${topic}\"`)\n\nfunction getSource(instance: SanityInstance, topic: StateTopic): MessageBusStateSource<unknown> {\n return getMessageBus(instance, topic).subscribe(topic)\n}\n\n// An entry lives as long as it has subscribers. Dropping it with the last one is what gives a\n// later mount a fresh deadline instead of a stale failure.\nconst updateEntry =\n (topic: string, update: (entry: TopicEntry) => TopicEntry) =>\n (state: DashboardTopicsState): DashboardTopicsState => {\n const {[topic]: entry = {subscribers: 0}, ...rest} = state.topics\n const next = update(entry)\n return {topics: next.subscribers > 0 ? {...rest, [topic]: next} : rest}\n }\n\nconst addSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers + 1}))\n\nconst removeSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers - 1}))\n\n/**\n * A state source for a dashboard state topic, with `TopicResult` wrappers unwrapped.\n *\n * @remarks\n * Returns `undefined` until the topic publishes; use {@link resolveTopic} to wait for that\n * first value. While the topic is still unpublished, reading throws the failure that\n * {@link resolveTopic} recorded. A published value takes precedence over a recorded failure,\n * and a {@link TopicError} is thrown when the topic itself reports failure. A thrown failure\n * ends the subscription, so a reader recovers by subscribing again.\n * @internal\n */\nexport const getTopicState = bindActionByInstance(\n dashboardTopicsStore,\n createStateSourceAction({\n selector: ({state, instance}, topic: StateTopic) => {\n const current = getSource(instance, topic).getCurrent()\n // A recorded failure only describes the wait for a first value; a published value wins.\n const entry = state.topics[topic]\n if (current === undefined && entry?.error) throw entry.error\n return unwrapTopicResult(topic, current)\n },\n onSubscribe: ({state, instance}, topic: StateTopic) => {\n state.set('addSubscriber', addSubscriber(topic))\n // Each publish writes a fresh state object so the selector re-runs against the bus.\n const subscription = getSource(instance, topic).subscribe(() =>\n state.set(\n 'publish',\n updateEntry(topic, (entry) => ({...entry})),\n ),\n )\n return () => {\n subscription.unsubscribe()\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n }\n },\n }),\n)\n\n/**\n * Resolves once a dashboard state topic has published, or records the failure for\n * {@link getTopicState} to throw. Repeated calls for a pending topic share one query.\n *\n * @remarks\n * Holds a temporary subscriber while the query is in flight so a failure recorded after the\n * reading component has gone is dropped with it, rather than thrown at the next mount.\n * @internal\n */\nexport const resolveTopic = bindActionByInstance(\n dashboardTopicsStore,\n ({state, instance}, topic: StateTopic): Promise<void> => {\n const existing = state.get().topics[topic]?.pending\n if (existing) return existing\n\n const release = () =>\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n const pending = getMessageBus(instance, topic)\n .query(topic)\n .then(\n () =>\n state.set(\n 'resolved',\n updateEntry(topic, ({pending: _pending, ...entry}) => entry),\n ),\n (error: unknown) =>\n state.set(\n 'failed',\n updateEntry(topic, ({pending: _pending, ...entry}) => ({...entry, error})),\n ),\n )\n pending.then(release, release)\n state.set(\n 'query',\n updateEntry(topic, (entry) => ({...entry, pending, subscribers: entry.subscribers + 1})),\n )\n return pending\n },\n)\n\nconst getComlinkOrganizationId = bindActionGlobally(\n authStore,\n createStateSourceAction(({state: {dashboardContext}}) => dashboardContext?.orgId),\n)\n\ntype CurrentOrganization = TopicData<'organizations.current'> | undefined\n\n/**\n * Returns the organization the dashboard has selected: the `organizations.current` topic on a\n * message bus, or the `_context` URL param in a Comlink dashboard.\n * @public\n */\nexport function getDashboardOrganizationId(\n instance: SanityInstance,\n): StateSource<string | undefined> {\n if (!getDashboardMessageBus(instance)) return getComlinkOrganizationId(instance)\n const organization = getTopicState(instance, 'organizations.current')\n const observable = organization.observable.pipe(\n map((value) => (value as CurrentOrganization)?.id),\n distinctUntilChanged(),\n )\n return {\n subscribe: (onStoreChanged) => {\n const subscription = observable.pipe(skip(1)).subscribe({\n next: () => onStoreChanged?.(),\n error: () => onStoreChanged?.(),\n })\n return () => subscription.unsubscribe()\n },\n getCurrent: () => (organization.getCur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
1
1
|
import { d as getEnv, f as isReleasePerspective, i as bindActionGlobally, l as setCleanupInterval, m as isDatasetResource, n as bindActionByResource, o as UPSTREAM_CLOSE_DELAY_MS, s as defineStore, t as createStateSourceAction, u as setCleanupTimeout } from "./createStateSourceAction-Bn0po7Z3.js";
|
|
2
2
|
import { r as omitProperty } from "./object-CxXlSVg7.js";
|
|
3
|
-
import { n as getClient, r as getClientState } from "./clientStore-
|
|
3
|
+
import { n as getClient, r as getClientState } from "./clientStore-iv9ooGew.js";
|
|
4
4
|
import { t as getNodeState } from "./getNodeState-CkxvEZD5.js";
|
|
5
5
|
import { ConnectionFailedError, CorsOriginError, DisconnectError } from "@sanity/client";
|
|
6
6
|
import { BehaviorSubject, EMPTY, NEVER, Observable, Subscription, catchError, combineLatest, defer, distinctUntilChanged, filter, first, firstValueFrom, from, groupBy, map, mergeMap, of, pairwise, race, retry, share, startWith, switchMap, take, tap } from "rxjs";
|
|
@@ -1434,7 +1434,7 @@ const _resolveQuery = bindActionByResource(queryStore, ({ state, instance }, { s
|
|
|
1434
1434
|
}, QUERY_STATE_CLEAR_DELAY);
|
|
1435
1435
|
};
|
|
1436
1436
|
return promise.then(releaseSubscriber, releaseSubscriber), promise;
|
|
1437
|
-
}), CORE_SDK_VERSION = getEnv("PKG_VERSION") || "3.
|
|
1437
|
+
}), CORE_SDK_VERSION = getEnv("PKG_VERSION") || "3.9.0-next.20261007114705-development";
|
|
1438
1438
|
export { toCommentsKeyParts as A, setPendingTransaction as B, commentsStore as C, parseCommentsOptionsKey as D, getCommentsState as E, receiveComment as F, provisionAddonDataset as G, toCommentFieldPath as H, removeCommentById as I, defineMutation as J, COMMENTS_API_VERSION as K, restoreComments as L, applyCommentUpdate as M, clearPendingTransaction as N, resolveCommentThreads as O, getCommentsKey as P, rollbackCommentUpdate as R, toFavoriteDocument as S, getCommentsOptionsKey as T, assertDatasetResource as U, normalizeComment as V, getAddonDatasetState as W, randomUuid as X, randomId as Y, updateLastLoadMoreRequest as _, resolveQuery as a, favorites as b, getAllReleasesState as c, getUsersKey as d, initializeRequest as f, setUsersError as g, setUsersData as h, parseQueryKey as i, addComment as j, resolveComments as k, addSubscription as l, removeSubscription as m, getQueryKey as n, getPerspectiveState as o, parseUsersKey as p, defineFetcher as q, getQueryState as r, getActiveReleasesState as s, CORE_SDK_VERSION as t, cancelRequest as u, PROJECT_API_VERSION as v, getCommentThreadsState as w, setFavorite as x, USERS_STATE_CLEAR_DELAY as y, setCommentCreateError as z };
|
|
1439
1439
|
|
|
1440
|
-
//# sourceMappingURL=version-
|
|
1440
|
+
//# sourceMappingURL=version-D68H4Kcd.js.map
|