@sanity/sdk 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/_internal.d.ts +25 -3
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +127 -9
- package/dist/_exports/_internal.js.map +1 -1
- package/dist/_exports/agent.d.ts +1 -1
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/comlink.d.ts +1 -1
- package/dist/_exports/comlink.js +2 -3
- package/dist/_exports/comlink.js.map +1 -1
- package/dist/{authStore-C0o1NOxW.d.ts → authStore-C-OEkGaM.d.ts} +2 -2
- package/dist/{authStore-C0o1NOxW.d.ts.map → authStore-C-OEkGaM.d.ts.map} +1 -1
- package/dist/{authStore-CtE9bLHW.js → clientStore-gUALQ0qW.js} +269 -11
- package/dist/{authStore-CtE9bLHW.js.map → clientStore-gUALQ0qW.js.map} +1 -1
- package/dist/{createSanityInstance-DUI1bGIg.d.ts → createSanityInstance-DCePpBYW.d.ts} +2 -2
- package/dist/{createSanityInstance-DUI1bGIg.d.ts.map → createSanityInstance-DCePpBYW.d.ts.map} +1 -1
- package/dist/{getNodeState-CR3__B2D.js → getNodeState-E0hjqFOo.js} +2 -3
- package/dist/{getNodeState-CR3__B2D.js.map → getNodeState-E0hjqFOo.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -44
- package/dist/index.js.map +1 -1
- package/dist/{createStateSourceAction-BOKtqFNm.js → object-BwynGPRZ.js} +87 -3
- package/dist/object-BwynGPRZ.js.map +1 -0
- package/dist/{queryStore-C7yMHPUI.js → version-C90rNWaX.js} +47 -15
- package/dist/version-C90rNWaX.js.map +1 -0
- package/package.json +5 -5
- package/src/_exports/_internal.ts +1 -0
- package/src/access/checkPermissions.test.ts +1 -1
- package/src/access/checkPermissions.ts +1 -1
- package/src/applications/applications.test.ts +4 -4
- package/src/applications/applications.ts +4 -4
- package/src/auth/handleAuthCallback.test.ts +2 -2
- package/src/auth/handleAuthCallback.ts +1 -1
- package/src/auth/logout.test.ts +1 -1
- package/src/auth/logout.ts +1 -1
- package/src/auth/refreshStampedToken.ts +1 -1
- package/src/auth/studioModeAuth.test.ts +1 -1
- package/src/auth/studioModeAuth.ts +1 -1
- package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -2
- package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
- package/src/comments/addonDatasetStore.test.ts +2 -2
- package/src/comments/addonDatasetStore.ts +2 -2
- package/src/comments/commentActions.ts +6 -5
- package/src/comments/commentsStore.ts +4 -4
- package/src/document/applyDocumentActions.ts +2 -6
- package/src/document/documentStore.concurrency.test.ts +2 -1
- package/src/document/documentStore.test.ts +19 -18
- package/src/document/documentStore.ts +5 -5
- package/src/document/permissions.ts +2 -1
- package/src/document/processActions.test.ts +2 -1
- package/src/document/processMutations.ts +3 -2
- package/src/document/reducers.ts +2 -2
- package/src/installations/installations.test.ts +2 -2
- package/src/installations/installations.ts +2 -2
- package/src/organization/organization.test.ts +2 -2
- package/src/organization/organization.ts +1 -1
- package/src/organizations/organizations.test.ts +2 -2
- package/src/organizations/organizations.ts +1 -1
- package/src/presence/presenceStore.test.ts +15 -22
- package/src/presence/presenceStore.ts +3 -2
- package/src/project/project.test.ts +3 -3
- package/src/project/project.ts +1 -1
- package/src/projection/getProjectionState.test.ts +6 -4
- package/src/projection/getProjectionState.ts +2 -2
- package/src/projects/projects.test.ts +2 -2
- package/src/projects/projects.ts +1 -1
- package/src/query/queryStore.ts +3 -3
- package/src/store/createSanityInstance.test.ts +1 -1
- package/src/store/createSanityInstance.ts +4 -4
- package/src/store/createStoreInstance.test.ts +0 -5
- package/src/telemetry/telemetryManager.test.ts +1 -1
- package/src/telemetry/telemetryManager.ts +2 -2
- package/src/users/usersStore.test.ts +1 -1
- package/src/users/usersStore.ts +5 -5
- package/src/utils/ids.test.ts +40 -15
- package/src/utils/ids.ts +47 -2
- package/dist/clientStore-BtE2-q2i.js +0 -90
- package/dist/clientStore-BtE2-q2i.js.map +0 -1
- package/dist/createStateSourceAction-BOKtqFNm.js.map +0 -1
- package/dist/getEnv-D5RGkQLu.js +0 -8
- package/dist/getEnv-D5RGkQLu.js.map +0 -1
- package/dist/logger-DAtJb5RQ.js +0 -173
- package/dist/logger-DAtJb5RQ.js.map +0 -1
- package/dist/object-CxXlSVg7.js +0 -83
- package/dist/object-CxXlSVg7.js.map +0 -1
- package/dist/queryStore-C7yMHPUI.js.map +0 -1
- package/dist/rolldown-runtime-vyAXikos.js +0 -9
- package/dist/telemetryManager-UIEiMtC0.js +0 -127
- package/dist/telemetryManager-UIEiMtC0.js.map +0 -1
- package/dist/version-D8RP_Q59.js +0 -9
- package/dist/version-D8RP_Q59.js.map +0 -1
|
@@ -1,9 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as defineStore, i as bindActionGlobally, t as createStateSourceAction } from "./createStateSourceAction-BOKtqFNm.js";
|
|
3
|
-
import { n as createLogger } from "./logger-DAtJb5RQ.js";
|
|
1
|
+
import { a as createStateSourceAction, c as bindActionGlobally, f as isCanvasResource, i as pickProperties, l as defineStore, m as isMediaLibraryResource, p as isDatasetResource } from "./object-BwynGPRZ.js";
|
|
4
2
|
import { createClient } from "@sanity/client";
|
|
5
3
|
import { EMPTY, Observable, catchError, defer, distinctUntilChanged, exhaustMap, filter, fromEvent, map, switchMap, takeWhile, timer } from "rxjs";
|
|
6
4
|
import "@sanity/types";
|
|
5
|
+
var __defProp = Object.defineProperty, __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: !0
|
|
10
|
+
});
|
|
11
|
+
return no_symbols || __defProp(target, Symbol.toStringTag, { value: "Module" }), target;
|
|
12
|
+
};
|
|
13
|
+
const LOG_LEVEL_PRIORITY = {
|
|
14
|
+
error: 0,
|
|
15
|
+
warn: 1,
|
|
16
|
+
info: 2,
|
|
17
|
+
debug: 3,
|
|
18
|
+
trace: 4
|
|
19
|
+
}, DEFAULT_CONFIG = {
|
|
20
|
+
level: "warn",
|
|
21
|
+
namespaces: [],
|
|
22
|
+
internal: !1,
|
|
23
|
+
timestamps: !0,
|
|
24
|
+
enableInProduction: !1,
|
|
25
|
+
handler: {
|
|
26
|
+
error: console.error.bind(console),
|
|
27
|
+
warn: console.warn.bind(console),
|
|
28
|
+
info: console.info.bind(console),
|
|
29
|
+
debug: console.debug.bind(console),
|
|
30
|
+
trace: console.debug.bind(console)
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Parse DEBUG environment variable for automatic logging configuration
|
|
35
|
+
*
|
|
36
|
+
* Supports patterns similar to Sanity CLI/Studio:
|
|
37
|
+
* - DEBUG=sanity:* (all namespaces, debug level)
|
|
38
|
+
* - DEBUG=sanity:auth,sanity:document (specific namespaces)
|
|
39
|
+
* - DEBUG=sanity:trace:* (all namespaces, trace level)
|
|
40
|
+
* - DEBUG=sanity:*:internal (enable internal logs)
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
function parseDebugEnvVar() {
|
|
45
|
+
if (typeof process > "u" || !process.env?.DEBUG) return null;
|
|
46
|
+
let debug = process.env.DEBUG;
|
|
47
|
+
if (!debug.includes("sanity")) return null;
|
|
48
|
+
let config = {}, levelMatch = debug.match(/sanity:(trace|debug|info|warn|error):/), hasLevelSpecifier = !!levelMatch;
|
|
49
|
+
if (config.level = levelMatch ? levelMatch[1] : "debug", debug === "sanity") config.namespaces = ["*"];
|
|
50
|
+
else if (hasLevelSpecifier && debug.match(/sanity:(trace|debug|info|warn|error):\*/)) config.namespaces = ["*"];
|
|
51
|
+
else if (!hasLevelSpecifier && debug.includes("sanity:*")) config.namespaces = ["*"];
|
|
52
|
+
else {
|
|
53
|
+
let namespaces = debug.split(",").filter((s) => s.includes("sanity:")).map((s) => {
|
|
54
|
+
let cleaned = s.replace(/^sanity:/, "");
|
|
55
|
+
return hasLevelSpecifier && cleaned.match(/^(trace|debug|info|warn|error):/) ? cleaned.split(":").slice(1).join(":") : cleaned.split(":")[0];
|
|
56
|
+
}).filter(Boolean).filter((ns) => ns !== "*");
|
|
57
|
+
namespaces.length > 0 && (config.namespaces = namespaces);
|
|
58
|
+
}
|
|
59
|
+
return debug.includes(":internal") && (config.internal = !0), config;
|
|
60
|
+
}
|
|
61
|
+
const envConfig = parseDebugEnvVar();
|
|
62
|
+
let globalConfig = {
|
|
63
|
+
...DEFAULT_CONFIG,
|
|
64
|
+
...envConfig ?? {}
|
|
65
|
+
};
|
|
66
|
+
/* c8 ignore next 14 */
|
|
67
|
+
envConfig && ([
|
|
68
|
+
"info",
|
|
69
|
+
"debug",
|
|
70
|
+
"trace"
|
|
71
|
+
].includes(globalConfig.level) || globalConfig.level === "warn") && console.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] [INFO] [sdk] Logging auto-configured from DEBUG environment variable`, {
|
|
72
|
+
level: globalConfig.level,
|
|
73
|
+
namespaces: globalConfig.namespaces,
|
|
74
|
+
internal: globalConfig.internal,
|
|
75
|
+
source: "env:DEBUG",
|
|
76
|
+
value: typeof process < "u" ? process.env?.DEBUG : void 0
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Configure the global logging system
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
function configureLogging(config) {
|
|
83
|
+
globalConfig = {
|
|
84
|
+
...globalConfig,
|
|
85
|
+
...config,
|
|
86
|
+
handler: config.handler ?? globalConfig.handler
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if logging is enabled in the current environment
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
function isLoggingEnabled() {
|
|
94
|
+
return typeof process < "u" && process.env?.NODE_ENV === "production" ? globalConfig.enableInProduction : !0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if a namespace is enabled
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
function isNamespaceEnabled(namespace) {
|
|
101
|
+
return isLoggingEnabled() ? globalConfig.namespaces.includes("*") ? !0 : globalConfig.namespaces.includes(namespace) : !1;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if a log level is enabled
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
function isLevelEnabled(level) {
|
|
108
|
+
return isLoggingEnabled() ? LOG_LEVEL_PRIORITY[level] <= LOG_LEVEL_PRIORITY[globalConfig.level] : !1;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Format a log message with timestamp, namespace, and instance context
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
function formatMessage(namespace, level, message, context) {
|
|
115
|
+
let parts = [];
|
|
116
|
+
if (globalConfig.timestamps) {
|
|
117
|
+
let timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
118
|
+
parts.push(`[${timestamp}]`);
|
|
119
|
+
}
|
|
120
|
+
parts.push(`[${level.toUpperCase()}]`), parts.push(`[${namespace}]`);
|
|
121
|
+
let instanceContext = context?.instanceContext;
|
|
122
|
+
return instanceContext && (instanceContext.projectId && parts.push(`[project:${instanceContext.projectId}]`), instanceContext.dataset && parts.push(`[dataset:${instanceContext.dataset}]`), instanceContext.instanceId && parts.push(`[instance:${instanceContext.instanceId.slice(0, 8)}]`)), parts.push(message), [parts.join(" "), context];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sanitize context for logging (remove sensitive data)
|
|
126
|
+
* @internal
|
|
127
|
+
* @remarks
|
|
128
|
+
* This performs shallow sanitization only - it redacts top-level keys that contain
|
|
129
|
+
* sensitive names (token, password, secret, apiKey, authorization).
|
|
130
|
+
* Nested sensitive data (e.g., `\{auth: \{token: 'secret'\}\}`) will NOT be redacted.
|
|
131
|
+
* If deep sanitization is needed in the future, this can be enhanced to recursively
|
|
132
|
+
* traverse nested objects.
|
|
133
|
+
*/
|
|
134
|
+
function sanitizeContext(context) {
|
|
135
|
+
if (!context || Object.keys(context).length === 0) return;
|
|
136
|
+
let sanitized = { ...context }, sensitiveKeys = [
|
|
137
|
+
"token",
|
|
138
|
+
"password",
|
|
139
|
+
"secret",
|
|
140
|
+
"apiKey",
|
|
141
|
+
"authorization"
|
|
142
|
+
];
|
|
143
|
+
for (let key of Object.keys(sanitized)) sensitiveKeys.some((sensitive) => key.toLowerCase().includes(sensitive)) && (sanitized[key] = "[REDACTED]");
|
|
144
|
+
return sanitized;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a logger for a specific namespace
|
|
148
|
+
* @param namespace - A string identifier for the logging domain (e.g., 'auth', 'document')
|
|
149
|
+
* @param baseContext - Optional base context to include in all log messages
|
|
150
|
+
* @remarks
|
|
151
|
+
* If baseContext includes an `instanceContext` property (with projectId, dataset, instanceId),
|
|
152
|
+
* it will be automatically formatted into the log output for easier debugging of
|
|
153
|
+
* multi-instance scenarios.
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
function createLogger(namespace, baseContext) {
|
|
157
|
+
let logAtLevel = (level, message, context) => {
|
|
158
|
+
if (!isNamespaceEnabled(namespace) || !isLevelEnabled(level) || context?.internal && !globalConfig.internal) return;
|
|
159
|
+
let [formatted, finalContext] = formatMessage(namespace, level, message, sanitizeContext({
|
|
160
|
+
...baseContext,
|
|
161
|
+
...context
|
|
162
|
+
}));
|
|
163
|
+
globalConfig.handler[level](formatted, finalContext);
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
namespace,
|
|
167
|
+
error: (message, context) => logAtLevel("error", message, context),
|
|
168
|
+
warn: (message, context) => logAtLevel("warn", message, context),
|
|
169
|
+
info: (message, context) => logAtLevel("info", message, context),
|
|
170
|
+
debug: (message, context) => logAtLevel("debug", message, context),
|
|
171
|
+
trace: (message, context) => logAtLevel("trace", message, {
|
|
172
|
+
...context,
|
|
173
|
+
internal: !0
|
|
174
|
+
}),
|
|
175
|
+
isLevelEnabled: (level) => isNamespaceEnabled(namespace) && isLevelEnabled(level),
|
|
176
|
+
child: (childContext) => createLogger(namespace, {
|
|
177
|
+
...baseContext,
|
|
178
|
+
...childContext
|
|
179
|
+
}),
|
|
180
|
+
getInstanceContext: () => baseContext?.instanceContext
|
|
181
|
+
};
|
|
182
|
+
}
|
|
7
183
|
/**
|
|
8
184
|
* Returns the staging API host if the `__SANITY_STAGING__` build-time flag is
|
|
9
185
|
* set to `true` (mirroring how Sanity Studio detects staging builds).
|
|
@@ -33,7 +209,7 @@ function getAuthLogger(instance) {
|
|
|
33
209
|
dataset: instance.config.dataset
|
|
34
210
|
} }), loggers.set(instance, logger)), logger;
|
|
35
211
|
}
|
|
36
|
-
const DEFAULT_BASE = "http://localhost", DEFAULT_API_VERSION = "2021-06-07", REQUEST_TAG_PREFIX = "sanity.sdk.auth";
|
|
212
|
+
const DEFAULT_BASE = "http://localhost", DEFAULT_API_VERSION$1 = "2021-06-07", REQUEST_TAG_PREFIX = "sanity.sdk.auth";
|
|
37
213
|
/**
|
|
38
214
|
* Determines the auth mode from instance config and environment.
|
|
39
215
|
*
|
|
@@ -84,7 +260,7 @@ const REFRESH_INTERVAL = 432e5;
|
|
|
84
260
|
function createTokenRefreshStream(token, clientFactory, apiHost) {
|
|
85
261
|
return new Observable((subscriber) => {
|
|
86
262
|
let subscription = clientFactory({
|
|
87
|
-
apiVersion: DEFAULT_API_VERSION,
|
|
263
|
+
apiVersion: DEFAULT_API_VERSION$1,
|
|
88
264
|
requestTagPrefix: REQUEST_TAG_PREFIX,
|
|
89
265
|
useProjectHostname: !1,
|
|
90
266
|
useCdn: !1,
|
|
@@ -92,7 +268,7 @@ function createTokenRefreshStream(token, clientFactory, apiHost) {
|
|
|
92
268
|
ignoreBrowserTokenWarning: !0,
|
|
93
269
|
...apiHost && { apiHost }
|
|
94
270
|
}).observable.request({
|
|
95
|
-
|
|
271
|
+
url: "auth/refresh-token",
|
|
96
272
|
method: "POST",
|
|
97
273
|
tag: "refresh-token",
|
|
98
274
|
body: { token }
|
|
@@ -170,7 +346,7 @@ const refreshStampedToken = ({ state, instance }) => {
|
|
|
170
346
|
token: value.authState.token,
|
|
171
347
|
authMethod: value.authMethod
|
|
172
348
|
})), distinctUntilChanged((prev, curr) => prev.token === curr.token && prev.authMethod === curr.authMethod)).pipe(map(({ token, authMethod }) => clientFactory({
|
|
173
|
-
apiVersion: DEFAULT_API_VERSION,
|
|
349
|
+
apiVersion: DEFAULT_API_VERSION$1,
|
|
174
350
|
requestTagPrefix: REQUEST_TAG_PREFIX,
|
|
175
351
|
token: authMethod === "cookie" ? void 0 : token,
|
|
176
352
|
ignoreBrowserTokenWarning: !0,
|
|
@@ -180,7 +356,7 @@ const refreshStampedToken = ({ state, instance }) => {
|
|
|
180
356
|
...useProjectHostname && projectId ? { projectId } : {},
|
|
181
357
|
...apiHost && { apiHost }
|
|
182
358
|
})), switchMap((client) => client.observable.request({
|
|
183
|
-
|
|
359
|
+
url: "/users/me",
|
|
184
360
|
method: "GET",
|
|
185
361
|
tag: "users.get-current"
|
|
186
362
|
}).pipe(
|
|
@@ -484,7 +660,7 @@ async function checkForCookieAuth(projectId, clientFactory) {
|
|
|
484
660
|
requestTagPrefix: REQUEST_TAG_PREFIX,
|
|
485
661
|
timeout: 1e4
|
|
486
662
|
}).request({
|
|
487
|
-
|
|
663
|
+
url: "/users/me",
|
|
488
664
|
withCredentials: !0,
|
|
489
665
|
tag: "users.get-current"
|
|
490
666
|
});
|
|
@@ -749,6 +925,88 @@ const authStore = defineStore({
|
|
|
749
925
|
isDestroyingSession: !1
|
|
750
926
|
} }));
|
|
751
927
|
});
|
|
752
|
-
|
|
928
|
+
var clientStore_exports = /* @__PURE__ */ __exportAll({
|
|
929
|
+
getClient: () => getClient,
|
|
930
|
+
getClientState: () => getClientState
|
|
931
|
+
});
|
|
932
|
+
const allowedKeys = Object.keys({
|
|
933
|
+
apiHost: null,
|
|
934
|
+
useCdn: null,
|
|
935
|
+
token: null,
|
|
936
|
+
perspective: null,
|
|
937
|
+
proxy: null,
|
|
938
|
+
withCredentials: null,
|
|
939
|
+
timeout: null,
|
|
940
|
+
maxRetries: null,
|
|
941
|
+
dataset: null,
|
|
942
|
+
projectId: null,
|
|
943
|
+
scope: null,
|
|
944
|
+
apiVersion: null,
|
|
945
|
+
requestTagPrefix: null,
|
|
946
|
+
useProjectHostname: null,
|
|
947
|
+
resource: null
|
|
948
|
+
}), DEFAULT_CLIENT_CONFIG = {
|
|
949
|
+
apiVersion: "2024-11-12",
|
|
950
|
+
useCdn: !1,
|
|
951
|
+
ignoreBrowserTokenWarning: !0,
|
|
952
|
+
allowReconfigure: !1,
|
|
953
|
+
requestTagPrefix: "sanity.sdk"
|
|
954
|
+
}, clientStore = defineStore({
|
|
955
|
+
name: "clientStore",
|
|
956
|
+
getInitialState: (instance) => ({
|
|
957
|
+
clients: {},
|
|
958
|
+
token: getTokenState(instance).getCurrent()
|
|
959
|
+
}),
|
|
960
|
+
initialize(context) {
|
|
961
|
+
let subscription = listenToToken(context), authMethodSubscription = listenToAuthMethod(context);
|
|
962
|
+
return () => {
|
|
963
|
+
subscription.unsubscribe(), authMethodSubscription.unsubscribe();
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
}), listenToToken = ({ instance, state }) => getTokenState(instance).observable.subscribe((token) => {
|
|
967
|
+
state.set("setTokenAndResetClients", {
|
|
968
|
+
token,
|
|
969
|
+
clients: {}
|
|
970
|
+
});
|
|
971
|
+
}), listenToAuthMethod = ({ instance, state }) => getAuthMethodState(instance).observable.subscribe((authMethod) => {
|
|
972
|
+
state.set("setAuthMethod", { authMethod });
|
|
973
|
+
}), getClientConfigKey = (options) => JSON.stringify(pickProperties(options, allowedKeys)), getClient = bindActionGlobally(clientStore, ({ state, instance }, options) => {
|
|
974
|
+
if (!options || typeof options != "object") throw Error("getClient() requires a configuration object with at least an \"apiVersion\" property. Example: getClient(instance, { apiVersion: \"2024-11-12\" })");
|
|
975
|
+
let disallowedKeys = Object.keys(options).filter((key) => !allowedKeys.includes(key));
|
|
976
|
+
if (disallowedKeys.length > 0) {
|
|
977
|
+
let listFormatter = new Intl.ListFormat("en", {
|
|
978
|
+
style: "long",
|
|
979
|
+
type: "conjunction"
|
|
980
|
+
});
|
|
981
|
+
throw Error(`The client options provided contains unsupported properties: ${listFormatter.format(disallowedKeys)}. Allowed keys are: ${listFormatter.format(allowedKeys)}.`);
|
|
982
|
+
}
|
|
983
|
+
let tokenFromState = state.get().token, { clients, authMethod } = state.get(), projectId = options.projectId ?? instance.config.projectId, dataset = options.dataset ?? instance.config.dataset, resource;
|
|
984
|
+
options.resource && (isMediaLibraryResource(options.resource) ? resource = {
|
|
985
|
+
type: "media-library",
|
|
986
|
+
id: options.resource.mediaLibraryId
|
|
987
|
+
} : isCanvasResource(options.resource) ? resource = {
|
|
988
|
+
type: "canvas",
|
|
989
|
+
id: options.resource.canvasId
|
|
990
|
+
} : isDatasetResource(options.resource) && (projectId = options.resource.projectId, dataset = options.resource.dataset));
|
|
991
|
+
let apiHost = options.apiHost ?? instance.config.auth?.apiHost ?? getStagingApiHost(), effectiveOptions = {
|
|
992
|
+
...DEFAULT_CLIENT_CONFIG,
|
|
993
|
+
...(options.scope === "global" || !projectId || resource) && { useProjectHostname: !1 },
|
|
994
|
+
token: authMethod === "cookie" ? void 0 : tokenFromState ?? void 0,
|
|
995
|
+
...options,
|
|
996
|
+
...projectId && { projectId },
|
|
997
|
+
...dataset && { dataset },
|
|
998
|
+
...resource ? { resource } : { resource: void 0 },
|
|
999
|
+
...apiHost && { apiHost }
|
|
1000
|
+
};
|
|
1001
|
+
resource && (delete effectiveOptions.projectId, delete effectiveOptions.dataset), effectiveOptions.token === null || effectiveOptions.token === void 0 ? (delete effectiveOptions.token, authMethod === "cookie" && (effectiveOptions.withCredentials = !0)) : delete effectiveOptions.withCredentials;
|
|
1002
|
+
let key = getClientConfigKey(effectiveOptions);
|
|
1003
|
+
if (clients[key]) return clients[key];
|
|
1004
|
+
let client = createClient(effectiveOptions);
|
|
1005
|
+
return state.set("addClient", (prev) => ({ clients: {
|
|
1006
|
+
...prev.clients,
|
|
1007
|
+
[key]: client
|
|
1008
|
+
} })), client;
|
|
1009
|
+
}), getClientState = bindActionGlobally(clientStore, createStateSourceAction(({ instance }, options) => getClient(instance, options)));
|
|
1010
|
+
export { isStudioConfig as C, configureLogging as D, getAuthLogger as E, createLogger as O, AuthStateType as S, REQUEST_TAG_PREFIX as T, getClientErrorApiDescription as _, authStore_exports as a, getTokenFromLocation as b, getDashboardOrganizationId as c, getTokenState as d, setAuthToken as f, getClientErrorApiBody as g, getCleanedUrl as h, authStore as i, __exportAll as k, getIsInDashboardState as l, getAuthCode as m, getClient as n, getAuthState as o, createLoggedInAuthState as p, getClientState as r, getCurrentUserState as s, clientStore_exports as t, getLoginUrlState as u, getClientErrorApiType as v, DEFAULT_API_VERSION$1 as w, isProjectUserNotFoundClientError as x, getDefaultLocation as y };
|
|
753
1011
|
|
|
754
|
-
//# sourceMappingURL=
|
|
1012
|
+
//# sourceMappingURL=clientStore-gUALQ0qW.js.map
|