@sanity/sdk 3.12.0 → 3.13.0-app-functions.20261106191857
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 +14 -3
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +296 -9
- package/dist/_exports/_internal.js.map +1 -1
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/collaboration.js +2 -2
- package/dist/_exports/dashboard.d.ts +2 -2
- package/dist/_exports/functions.d.ts +67 -0
- package/dist/_exports/functions.d.ts.map +1 -0
- package/dist/_exports/functions.js +45 -0
- package/dist/_exports/functions.js.map +1 -0
- package/dist/{applications-DEghtEl9.d.ts → applications-BARgMsKm.d.ts} +28 -3
- package/dist/applications-BARgMsKm.d.ts.map +1 -0
- package/dist/{buildCommentThreads-DvEkmq6P.js → buildCommentThreads-C-W_UO7t.js} +2 -2
- package/dist/{buildCommentThreads-DvEkmq6P.js.map → buildCommentThreads-C-W_UO7t.js.map} +1 -1
- package/dist/{bus-DEoWx5fV.d.ts → bus-CnEdzivJ.d.ts} +2 -2
- package/dist/{bus-DEoWx5fV.d.ts.map → bus-CnEdzivJ.d.ts.map} +1 -1
- package/dist/{clientStore-C20oRB2w.js → clientStore-Bj-ZHyq7.js} +4 -2
- package/dist/clientStore-Bj-ZHyq7.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -517
- package/dist/index.js.map +1 -1
- package/dist/sentryBrowser-DT6hL7NZ.js +1 -0
- package/dist/version-R_3sK-Uf.js +1072 -0
- package/dist/version-R_3sK-Uf.js.map +1 -0
- package/package.json +9 -6
- package/src/_exports/_internal.ts +2 -0
- package/src/_exports/functions.ts +10 -0
- package/src/_exports/index.ts +5 -0
- package/src/client/clientStore.ts +4 -0
- package/src/errorReporting/errorReporter.test.ts +207 -0
- package/src/errorReporting/errorReporter.ts +223 -0
- package/src/errorReporting/isErrorReportingEnabled.test.ts +67 -0
- package/src/errorReporting/isErrorReportingEnabled.ts +47 -0
- package/src/errorReporting/isKnownSdkError.test.ts +57 -0
- package/src/errorReporting/isKnownSdkError.ts +67 -0
- package/src/errorReporting/privacy.test.ts +67 -0
- package/src/errorReporting/privacy.ts +61 -0
- package/src/errorReporting/sentryBrowser.ts +10 -0
- package/src/errorReporting/sentryTypes.ts +7 -0
- package/src/functions/clientFunctions.ts +68 -0
- package/src/functions/functionHandler.test.ts +75 -0
- package/src/functions/functionHandler.ts +115 -0
- package/dist/applications-DEghtEl9.d.ts.map +0 -1
- package/dist/clientStore-C20oRB2w.js.map +0 -1
- package/dist/version-DfqE7Tzw.js +0 -559
- package/dist/version-DfqE7Tzw.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { m as SanityConfig, s as DocumentResource, t as SanityInstance } from "../createSanityInstance-BtgGknwT.js";
|
|
2
2
|
import { n as StateSource, r as BoundStoreAction } from "../createStateSourceAction-CzAwbNjw.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Ca as MutationResult, Dt as GetUsersOptions, G as getQueryKey, Gi as getSignInMethodLabel, Gt as FavoriteStatusResponse, Hi as ProjectAccessErrorDetails, Kt as SetFavoriteInput, Sa as MutationDefinition, Ta as defineMutation, Ui as getProjectAccessErrorDetails, Ut as createAppFunctions, Wt as FavoriteDocumentContext, _a as CacheTag, _r as ApplicationStatus, ba as FetcherDefinition, ct as PreviewValue, dr as getTopicState, fr as resolveTopic, q as parseQueryKey, r as ApplicationBase, si as createLogger, st as PreviewQueryResult, va as CacheWriter, vi as getCommentsOptionsKey, vr as ApplicationStatusUpdate, wa as defineFetcher, xa as FetcherSnapshot, ya as Fetcher, yi as parseCommentsOptionsKey, zt as AppFunctionContract } from "../applications-BARgMsKm.js";
|
|
4
4
|
import { c as parseCommentsQueryOptionsKey, l as parseDocumentCommentsOptionsKey, o as getCommentsQueryOptionsKey, s as getDocumentCommentsOptionsKey } from "../commentsOptions-DuLgrFc5.js";
|
|
5
|
-
import { b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, v as installMessageBus, x as workerMessages, y as isMessageBusEnvironment } from "../bus-
|
|
5
|
+
import { b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, v as installMessageBus, x as workerMessages, y as isMessageBusEnvironment } from "../bus-CnEdzivJ.js";
|
|
6
6
|
import { Auth, ClientError, SanityClient } from "@sanity/client";
|
|
7
7
|
import { Observable } from "rxjs";
|
|
8
8
|
import { CurrentUser } from "@sanity/types";
|
|
@@ -86,6 +86,17 @@ interface DashboardWorkersState {
|
|
|
86
86
|
* @internal
|
|
87
87
|
*/
|
|
88
88
|
export declare const getWorkerClient: BoundStoreAction<DashboardWorkersState, [name: string], WorkerConnection>;
|
|
89
|
+
/** @internal */
|
|
90
|
+
interface ReportErrorInfo {
|
|
91
|
+
/** The name of the error boundary that caught the error. */
|
|
92
|
+
errorBoundary?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reports an unexpected error from the SDK to Sentry, when error reporting is enabled.
|
|
96
|
+
*
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
export declare const reportError: (error: unknown, info?: ReportErrorInfo) => void;
|
|
89
100
|
/**
|
|
90
101
|
* A state source for whether a document is favorited, matched against the `favorites.documents`
|
|
91
102
|
* the dashboard message bus host publishes. The message bus counterpart to the Comlink
|
|
@@ -268,5 +279,5 @@ export declare function pickProperties<T extends object, K extends keyof T>(valu
|
|
|
268
279
|
* @internal
|
|
269
280
|
*/
|
|
270
281
|
export declare function isDeepEqual<T>(left: T, right: T): boolean;
|
|
271
|
-
export { type ApiErrorBody, type ApplicationStatus, type ApplicationStatusUpdate, type CacheTag, type CacheWriter, type Fetcher, type FetcherDefinition, type FetcherSnapshot, type InstallMessageBusOptions, type MutationDefinition, type MutationResult, type ProjectAccessErrorDetails, type WorkerConnection, createLogger, defineFetcher, defineMutation, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTopicState, installMessageBus, isMessageBusEnvironment, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, resetMessageBus, resolveTopic, workerMessages };
|
|
282
|
+
export { type ApiErrorBody, type AppFunctionContract, type ApplicationStatus, type ApplicationStatusUpdate, type CacheTag, type CacheWriter, type Fetcher, type FetcherDefinition, type FetcherSnapshot, type InstallMessageBusOptions, type MutationDefinition, type MutationResult, type ProjectAccessErrorDetails, type WorkerConnection, createAppFunctions, createLogger, defineFetcher, defineMutation, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTopicState, installMessageBus, isMessageBusEnvironment, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, resetMessageBus, resolveTopic, workerMessages };
|
|
272
283
|
//# sourceMappingURL=_internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internal.d.ts","names":["_$______store_createActionBinder0.BoundStoreAction","_$___store_fetcherStore0.MutationResult"],"sources":["../../src/applications/applicationOrigin.ts","../../src/auth/authMode.ts","../../src/auth/utils.ts","../../src/dashboard/messageBus/store.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/users/reducers.ts","../../src/utils/createGroqSearchFilter.ts","../../src/utils/ids.ts","../../src/utils/object.ts"],"mappings":";;;;;;;;;;;;;;;wBAWgB,qBACd,aAAa,KAAK;;;;;;wBCkCJ,eAAe,QAAQ;;KC4I3B;EACV;IAAS;IAAe;IAAsB;IAAqB;;EACnE;EACA;EACA;EACA;;;wBAIc,sBAAsB,OAAO,cAAc;;;;;;;;;;;;;wBCjJ3C,uBACd,UAAU,gBACV,mBACA,qBACC;;;;;;wBAca,2BACd,UAAU,gBACV,iBACC;;;;;;;;;;wBAiBa,uBAAuB,UAAU;;;;;UC/EhC;EACf,KAAK,mBAAmB,UAAU,wBAAwB;EAC1D,UAAU,UAAU;;UAGZ;EACR;KAAW,eAAe;;;;;;;;;;;qBAoBf,iBAAeA,iBAAA,wBAAA,eAAA;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"_internal.d.ts","names":["_$______store_createActionBinder0.BoundStoreAction","_$___store_fetcherStore0.MutationResult"],"sources":["../../src/applications/applicationOrigin.ts","../../src/auth/authMode.ts","../../src/auth/utils.ts","../../src/dashboard/messageBus/store.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/errorReporting/errorReporter.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/users/reducers.ts","../../src/utils/createGroqSearchFilter.ts","../../src/utils/ids.ts","../../src/utils/object.ts"],"mappings":";;;;;;;;;;;;;;;wBAWgB,qBACd,aAAa,KAAK;;;;;;wBCkCJ,eAAe,QAAQ;;KC4I3B;EACV;IAAS;IAAe;IAAsB;IAAqB;;EACnE;EACA;EACA;EACA;;;wBAIc,sBAAsB,OAAO,cAAc;;;;;;;;;;;;;wBCjJ3C,uBACd,UAAU,gBACV,mBACA,qBACC;;;;;;wBAca,2BACd,UAAU,gBACV,iBACC;;;;;;;;;;wBAiBa,uBAAuB,UAAU;;;;;UC/EhC;EACf,KAAK,mBAAmB,UAAU,wBAAwB;EAC1D,UAAU,UAAU;;UAGZ;EACR;KAAW,eAAe;;;;;;;;;;;qBAoBf,iBAAeA,iBAAA,wBAAA,eAAA;;UCRX;;EAEf;;;;;;;qBAiMY,cAAW,gBA/EK,OAAS;;;;;;;;;;;;;;wBCtGvB,oBACd,UAAU,gBACV,SAAS,0BACR;;;;;;;wBAwCa,mBAAmB,UAAU,iBAAiB;;;;;;;;qBAejD,iBAAc,UAAA,gBAAA,OAAA,qBAAA,QAAAC,eAAA;;;;;;;qBC7Ed;;;;;;;;;;wBCiDG,6BACd,UAAU,gBACV,kBAAkB,oBAClB,WAAW,mBACV;;;;;;;;;;;;UCrCc;;;;;;;EAOf,gBAAgB;;EAGhB,kBAAkB;IAAO;IAAmB;;;EAG5C,iBAAiB;;EAGjB,SAAS,mBAAmB;;EAG5B;;EAGA;;WAGS,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCjBN,cAAc,UAAU,gBAAgB;;;;;;;wBA8IxC,oBAAoB,UAAU,iBAAiB;;;;;;;;wBAW/C,iBAAiB,UAAU,gBAAgB;;qBCjM9C,cAAW,UACZ,kBAAc,cAAA,gBAAA,WAAA,WAAA,WAOrB;;qBAWQ,gBAAa;EAGxB;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;wBCYc,uBAAuB;;;;;;;;;;;wBChCvB,SAAS;;;;;;;;;;;wBAsBT;;;;;;wBCIA,eAAe,kBAAkB,gBAAgB,GAC/D,OAAO,GACP,eAAe,MACd,KAAK,GAAG;;;;;;;;wBA2DK,YAAY,GAAG,MAAM,GAAG,OAAO"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-vyAXikos.js";
|
|
2
2
|
import { a as createActionBinder, s as defineStore } from "../createStateSourceAction-BdcaQ2os.js";
|
|
3
|
-
import { J as isMessageBusEnvironment, M as getClientErrorApiBody, V as isStudioConfig, X as resetMessageBus, Z as workerMessages, et as createLogger, nt as randomUuid, q as installMessageBus, tt as randomId } from "../authStore-A65hzFu3.js";
|
|
3
|
+
import { G as MessageBusError, J as isMessageBusEnvironment, M as getClientErrorApiBody, V as isStudioConfig, X as resetMessageBus, Z as workerMessages, et as createLogger, nt as randomUuid, q as installMessageBus, tt as randomId, x as DocumentInaccessibleError } from "../authStore-A65hzFu3.js";
|
|
4
4
|
import { n as defineFetcher, r as defineMutation, t as toCommentFieldPath } from "../commentFieldPath-BbKsoQiW.js";
|
|
5
5
|
import { i as pickProperties, n as isObject, t as isDeepEqual } from "../object-CxXlSVg7.js";
|
|
6
|
-
import { n as getClient } from "../clientStore-
|
|
7
|
-
import { a as getDashboardMessageBus, i as resolveTopic, o as isDashboardEnvironment, r as getTopicState, s as requireDashboardMessageBus } from "../topicStore-BKyvThWM.js";
|
|
8
|
-
import { C as
|
|
9
|
-
import "@sanity/client";
|
|
6
|
+
import { n as getClient } from "../clientStore-Bj-ZHyq7.js";
|
|
7
|
+
import { a as getDashboardMessageBus, i as resolveTopic, o as isDashboardEnvironment, r as getTopicState, s as requireDashboardMessageBus, t as TopicError } from "../topicStore-BKyvThWM.js";
|
|
8
|
+
import { C as ActionError, M as getProjectAccessErrorDetails, P as getSignInMethodLabel, S as toFavoriteDocument, d as getUsersKey, i as parseQueryKey, n as getQueryKey, p as parseUsersKey, t as CORE_SDK_VERSION } from "../version-R_3sK-Uf.js";
|
|
9
|
+
import { ClientError, ConnectionFailedError, ServerError, isTimeoutError } from "@sanity/client";
|
|
10
10
|
import { EMPTY, catchError, defer, distinctUntilChanged, map, merge } from "rxjs";
|
|
11
11
|
import "@sanity/types";
|
|
12
12
|
import { DocumentId, isPublishedIdEqual } from "@sanity/id-utils";
|
|
@@ -139,7 +139,272 @@ const getWorkerClient = createActionBinder((instance) => ({ name: instance.insta
|
|
|
139
139
|
...workers,
|
|
140
140
|
[name]: client
|
|
141
141
|
} })), client;
|
|
142
|
-
})
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Whether the document has an import map with an `@sanity/sdk` entry. The Sanity CLI adds one
|
|
145
|
+
* when an app is deployed with `autoUpdates`, so its presence means Sanity serves the SDK bundle.
|
|
146
|
+
*/
|
|
147
|
+
function hasSdkPackageInImportMap() {
|
|
148
|
+
return typeof document > "u" || !("querySelectorAll" in document) ? !1 : Array.from(document.querySelectorAll("script[type=\"importmap\"]")).some((entry) => {
|
|
149
|
+
if (!entry.textContent) return !1;
|
|
150
|
+
try {
|
|
151
|
+
let imports = JSON.parse(entry.textContent).imports;
|
|
152
|
+
return !!imports && "@sanity/sdk" in imports;
|
|
153
|
+
} catch {
|
|
154
|
+
return !1;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Whether the debug flag is set in localStorage. It also lets the origin filter accept this
|
|
160
|
+
* repo's own source paths, which only appear in local development.
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
function hasDebugFlag() {
|
|
165
|
+
try {
|
|
166
|
+
return typeof localStorage < "u" && !!localStorage.getItem("SANITY_DEBUG_ERROR_REPORTING");
|
|
167
|
+
} catch {
|
|
168
|
+
return !1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Error reporting only runs in apps where Sanity serves the SDK bundle (auto-updating apps), or
|
|
173
|
+
* when the debug flag is set. It never runs outside a browser.
|
|
174
|
+
*
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
function isErrorReportingEnabled() {
|
|
178
|
+
return typeof window > "u" ? !1 : hasDebugFlag() || hasSdkPackageInImportMap();
|
|
179
|
+
}
|
|
180
|
+
const NETWORK_FAILURE_MESSAGE = /failed to fetch|networkerror|load failed|network request failed/i;
|
|
181
|
+
/**
|
|
182
|
+
* Aborting a request on teardown is routine. Matched by name because `DOMException` and abort
|
|
183
|
+
* errors from other libraries do not share a class.
|
|
184
|
+
*/
|
|
185
|
+
function isAbortError(error) {
|
|
186
|
+
return error instanceof Error && error.name === "AbortError";
|
|
187
|
+
}
|
|
188
|
+
function isNetworkFailure(error) {
|
|
189
|
+
return error instanceof TypeError && NETWORK_FAILURE_MESSAGE.test(error.message);
|
|
190
|
+
}
|
|
191
|
+
/** Known errors that cannot be matched by class. */
|
|
192
|
+
const KNOWN_ERROR_CHECKS = [
|
|
193
|
+
isTimeoutError,
|
|
194
|
+
isAbortError,
|
|
195
|
+
isNetworkFailure
|
|
196
|
+
];
|
|
197
|
+
function isKnownErrorInstance(error) {
|
|
198
|
+
return [
|
|
199
|
+
ActionError,
|
|
200
|
+
DocumentInaccessibleError,
|
|
201
|
+
MessageBusError,
|
|
202
|
+
TopicError,
|
|
203
|
+
ClientError,
|
|
204
|
+
ServerError,
|
|
205
|
+
ConnectionFailedError
|
|
206
|
+
].some((knownClass) => error instanceof knownClass) || KNOWN_ERROR_CHECKS.some((check) => check(error));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Whether an error is an expected state caused by the app's configuration, the user's
|
|
210
|
+
* permissions, the user's network, or the Sanity API, and so is not worth reporting as an SDK
|
|
211
|
+
* bug. Wrapped errors are checked through their `cause` chain.
|
|
212
|
+
*
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
function isKnownSdkError(error) {
|
|
216
|
+
let current = error;
|
|
217
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
218
|
+
if (isKnownErrorInstance(current)) return !0;
|
|
219
|
+
if (!(current instanceof Error) || current.cause === void 0) return !1;
|
|
220
|
+
current = current.cause;
|
|
221
|
+
}
|
|
222
|
+
return !1;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Key fragments Sentry denies when `sendDefaultPii` is left unset. The Sentry v11 migration guide
|
|
226
|
+
* uses the same list for headers and query params.
|
|
227
|
+
*/
|
|
228
|
+
const PII_KEY_DENYLIST = [
|
|
229
|
+
"forwarded",
|
|
230
|
+
"-ip",
|
|
231
|
+
"remote-",
|
|
232
|
+
"via",
|
|
233
|
+
"-user"
|
|
234
|
+
], sdkSentryDataCollection = {
|
|
235
|
+
userInfo: !1,
|
|
236
|
+
cookies: !1,
|
|
237
|
+
httpHeaders: {
|
|
238
|
+
request: { deny: PII_KEY_DENYLIST },
|
|
239
|
+
response: { deny: PII_KEY_DENYLIST }
|
|
240
|
+
},
|
|
241
|
+
httpBodies: [],
|
|
242
|
+
urlQueryParams: { deny: PII_KEY_DENYLIST },
|
|
243
|
+
genAI: {
|
|
244
|
+
inputs: !1,
|
|
245
|
+
outputs: !1
|
|
246
|
+
},
|
|
247
|
+
databaseQueryData: !1,
|
|
248
|
+
graphQL: {
|
|
249
|
+
document: !1,
|
|
250
|
+
variables: !1
|
|
251
|
+
},
|
|
252
|
+
queues: !1
|
|
253
|
+
}, KEPT_TAGS = ["handled", "errorBoundary"];
|
|
254
|
+
/**
|
|
255
|
+
* Sentry `beforeSend` hook that rebuilds the event from an allowlist of fields. Sentry merges
|
|
256
|
+
* the global and isolation scopes into every event, and when the host page runs the same Sentry
|
|
257
|
+
* version those scopes are the host's: its tags, extras, breadcrumbs, and contexts would be
|
|
258
|
+
* sent along with the SDK's error. Anything not listed here is dropped, and the zeroed IP stops
|
|
259
|
+
* Sentry from filling one in from the connection. Exception messages and stack frames are kept
|
|
260
|
+
* as they are.
|
|
261
|
+
*/
|
|
262
|
+
function beforeSend(event) {
|
|
263
|
+
let tags = {};
|
|
264
|
+
for (let key of KEPT_TAGS) {
|
|
265
|
+
let value = event.tags?.[key];
|
|
266
|
+
value !== void 0 && (tags[key] = value);
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
type: void 0,
|
|
270
|
+
event_id: event.event_id,
|
|
271
|
+
timestamp: event.timestamp,
|
|
272
|
+
platform: event.platform,
|
|
273
|
+
level: event.level,
|
|
274
|
+
release: event.release,
|
|
275
|
+
environment: event.environment,
|
|
276
|
+
message: event.message,
|
|
277
|
+
exception: event.exception,
|
|
278
|
+
sdk: event.sdk,
|
|
279
|
+
tags,
|
|
280
|
+
user: { ip_address: "0.0.0.0" }
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The value of the error that was thrown. When `linkedErrors` adds the causes, they come first
|
|
285
|
+
* and the thrown error is last.
|
|
286
|
+
*/
|
|
287
|
+
function getThrownValue(event) {
|
|
288
|
+
return event.exception?.values?.at(-1)?.value ?? event.message;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Caps the events per session and drops repeats of the same message inside a time window.
|
|
292
|
+
*/
|
|
293
|
+
function limitEventsIntegration() {
|
|
294
|
+
let seen = /* @__PURE__ */ new Map(), sent = 0;
|
|
295
|
+
return {
|
|
296
|
+
name: "SdkLimitEvents",
|
|
297
|
+
processEvent(event) {
|
|
298
|
+
if (sent >= 10) return null;
|
|
299
|
+
let message = getThrownValue(event) ?? "", now = Date.now(), previous = seen.get(message);
|
|
300
|
+
return previous !== void 0 && now - previous < 3e5 ? null : (seen.set(message, now), sent++, event);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Matches the SDK bundle served by the module server (`@sanity__sdk`, `@sanity__sdk-react`) and
|
|
306
|
+
* the same packages under `node_modules` (`@sanity/sdk`, or `@sanity_sdk-react` in a Vite
|
|
307
|
+
* dependency cache). The package name must end at a path separator or a file extension, so
|
|
308
|
+
* `@sanity/sdk-other` does not match.
|
|
309
|
+
*/
|
|
310
|
+
const SDK_MODULE_PATTERN = /(?:@|%40)sanity(?:__|_|\/|%2F)sdk(?:-react)?(?=[/.]|$)/, SDK_SOURCE_PATTERN = /\/packages\/(?:core|react)\/(?:src|dist)\//, BUILTIN_FRAME_PATTERN = /^(?:<.*>|native)$/;
|
|
311
|
+
function isSdkFilename(filename) {
|
|
312
|
+
return SDK_MODULE_PATTERN.test(filename) || hasDebugFlag() && SDK_SOURCE_PATTERN.test(filename);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The file of the innermost frame that has a URL. Builtins such as `JSON.parse` and `new URL`
|
|
316
|
+
* sit on top of the stack when they throw, and the code that called them decides the owner.
|
|
317
|
+
*/
|
|
318
|
+
function getThrowingFilename(event) {
|
|
319
|
+
let frames = event.exception?.values?.at(-1)?.stacktrace?.frames ?? [];
|
|
320
|
+
for (let index = frames.length - 1; index >= 0; index--) {
|
|
321
|
+
let filename = frames[index]?.filename;
|
|
322
|
+
if (filename && !BUILTIN_FRAME_PATTERN.test(filename)) return filename;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Keeps only events thrown by SDK code. Error boundaries also catch errors thrown by the app
|
|
327
|
+
* rendered beneath them, so the frame that threw decides who owns the error. Events with no
|
|
328
|
+
* usable frame cannot be attributed and are dropped.
|
|
329
|
+
*/
|
|
330
|
+
function sdkOriginIntegration() {
|
|
331
|
+
return {
|
|
332
|
+
name: "SdkOrigin",
|
|
333
|
+
processEvent(event) {
|
|
334
|
+
let filename = getThrowingFilename(event);
|
|
335
|
+
return filename && isSdkFilename(filename) ? event : null;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Sentry marks every error it is given as already captured, and skips marked errors in every
|
|
341
|
+
* Sentry client on the page. Capturing a copy keeps that mark off the app's own error objects.
|
|
342
|
+
*/
|
|
343
|
+
function toCapturable(error) {
|
|
344
|
+
let copy = Error(error.message, error.cause === void 0 ? void 0 : { cause: error.cause });
|
|
345
|
+
return copy.name = error.name, copy.stack = error.stack, copy;
|
|
346
|
+
}
|
|
347
|
+
function getEnvironment() {
|
|
348
|
+
let hostname = typeof window > "u" ? "" : window.location?.hostname;
|
|
349
|
+
return hostname === "localhost" || hostname === "127.0.0.1" ? "development" : "production";
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Creates a reporter that sends unexpected SDK errors to Sentry. It owns its own Sentry client
|
|
353
|
+
* and scope, and installs no global error handlers. Nothing is sent unless `reportError` is
|
|
354
|
+
* called.
|
|
355
|
+
*
|
|
356
|
+
* @internal
|
|
357
|
+
*/
|
|
358
|
+
function createErrorReporter(options = {}) {
|
|
359
|
+
let scopePromise, loadFailures = 0;
|
|
360
|
+
function getScope() {
|
|
361
|
+
return scopePromise ??= import("../sentryBrowser-DT6hL7NZ.js").then((sentry) => {
|
|
362
|
+
let client = new sentry.BrowserClient({
|
|
363
|
+
dsn: "https://08e08ab0cbf33a49f7f5066597d5e374@sentry.sanity.io/4512347487666176",
|
|
364
|
+
tunnel: "https://api.sanity.io/vX/intake/tracing",
|
|
365
|
+
release: String(CORE_SDK_VERSION),
|
|
366
|
+
environment: getEnvironment(),
|
|
367
|
+
dataCollection: sdkSentryDataCollection,
|
|
368
|
+
stackParser: sentry.defaultStackParser,
|
|
369
|
+
transport: options.transport ?? sentry.makeFetchTransport,
|
|
370
|
+
integrations: [
|
|
371
|
+
sentry.linkedErrorsIntegration(),
|
|
372
|
+
sdkOriginIntegration(),
|
|
373
|
+
limitEventsIntegration()
|
|
374
|
+
],
|
|
375
|
+
beforeSend: (event) => beforeSend(event)
|
|
376
|
+
}), scope = new sentry.Scope();
|
|
377
|
+
return scope.setClient(client), client.init(), scope;
|
|
378
|
+
}).catch((error) => {
|
|
379
|
+
throw scopePromise = void 0, loadFailures++, error;
|
|
380
|
+
}), scopePromise;
|
|
381
|
+
}
|
|
382
|
+
function reportError(error, info = {}) {
|
|
383
|
+
try {
|
|
384
|
+
if (!(error instanceof Error) || loadFailures >= 3 || !isErrorReportingEnabled() || isKnownSdkError(error)) return;
|
|
385
|
+
let capturable = toCapturable(error), { errorBoundary } = info, tags = errorBoundary ? {
|
|
386
|
+
handled: "no",
|
|
387
|
+
errorBoundary
|
|
388
|
+
} : { handled: "no" };
|
|
389
|
+
getScope().then((scope) => {
|
|
390
|
+
scope.captureException(capturable, {
|
|
391
|
+
mechanism: {
|
|
392
|
+
handled: !1,
|
|
393
|
+
type: "generic"
|
|
394
|
+
},
|
|
395
|
+
captureContext: { tags }
|
|
396
|
+
});
|
|
397
|
+
}).catch(() => {});
|
|
398
|
+
} catch {}
|
|
399
|
+
}
|
|
400
|
+
return { reportError };
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Reports an unexpected error from the SDK to Sentry, when error reporting is enabled.
|
|
404
|
+
*
|
|
405
|
+
* @internal
|
|
406
|
+
*/
|
|
407
|
+
const { reportError } = createErrorReporter(), isSameFavorite = (a, b) => a.type === b.type && a.resource.id === b.resource.id && a.resource.type === b.resource.type && a.resource.schemaName === b.resource.schemaName && isPublishedIdEqual(DocumentId(a.id), DocumentId(b.id));
|
|
143
408
|
/**
|
|
144
409
|
* A state source for whether a document is favorited, matched against the `favorites.documents`
|
|
145
410
|
* the dashboard message bus host publishes. The message bus counterpart to the Comlink
|
|
@@ -197,7 +462,29 @@ const setBusFavorite = defineMutation({
|
|
|
197
462
|
document: toFavoriteDocument(context),
|
|
198
463
|
favorited: isFavorited
|
|
199
464
|
}, { timeout: FETCH_TIMEOUT_DEFAULT })).pipe(map(() => ({ isFavorited })))
|
|
200
|
-
})
|
|
465
|
+
});
|
|
466
|
+
/** Bind generated function contracts to an authenticated client. @internal */
|
|
467
|
+
function createAppFunctions(client, contracts) {
|
|
468
|
+
let entries = Object.entries(contracts).map(([name, contract]) => [name, async (...args) => {
|
|
469
|
+
let input = contract.hasInput ? args[0] : void 0, options = contract.hasInput ? args[1] : args[0];
|
|
470
|
+
if (!contract.validateInput(input)) throw TypeError(`Invalid input for function "${name}". Match its declared input type.`);
|
|
471
|
+
let result = await client.functions.invoke(name, {
|
|
472
|
+
event: { data: contract.hasInput ? input : {} },
|
|
473
|
+
timeout: options?.timeout,
|
|
474
|
+
signal: options?.signal
|
|
475
|
+
}, { sync: !0 });
|
|
476
|
+
if (!contract.validateOutput(result)) throw TypeError(`Unexpected response from function "${name}". Rebuild and redeploy the app and its functions together.`);
|
|
477
|
+
return result;
|
|
478
|
+
}]);
|
|
479
|
+
return Object.fromEntries(entries);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The fields to check for a title.
|
|
483
|
+
* The order of the items in the array defines the priority.
|
|
484
|
+
*
|
|
485
|
+
* @internal
|
|
486
|
+
*/
|
|
487
|
+
const TITLE_CANDIDATES = [
|
|
201
488
|
"title",
|
|
202
489
|
"name",
|
|
203
490
|
"label",
|
|
@@ -503,7 +790,7 @@ function initTelemetry(instance, projectId) {
|
|
|
503
790
|
environment
|
|
504
791
|
}), Promise.all([
|
|
505
792
|
Promise.resolve().then(() => telemetryManager_exports),
|
|
506
|
-
import("../clientStore-
|
|
793
|
+
import("../clientStore-Bj-ZHyq7.js").then((n) => n.t),
|
|
507
794
|
import("../authStore-A65hzFu3.js").then((n) => n.n),
|
|
508
795
|
import("../authStore-A65hzFu3.js").then((n) => n.B)
|
|
509
796
|
]).then(async ([{ createTelemetryManager }, { getClient }, { getTokenState }, { isStudioConfig }]) => {
|
|
@@ -641,6 +928,6 @@ function createGroqSearchFilter(query) {
|
|
|
641
928
|
let tokens = trimmedQuery.match(TOKEN_REGEX) ?? [], reversedIndex = [...tokens].reverse().findIndex((token) => !isNegationToken(token) && !isExactMatchToken(token)), finalIncrementalTokenIndex = reversedIndex === -1 ? -1 : tokens.length - 1 - reversedIndex, finalIncrementalToken = tokens[finalIncrementalTokenIndex], processedTokens = [...tokens];
|
|
642
929
|
return finalIncrementalToken !== void 0 && !isPrefixToken(finalIncrementalToken) && processedTokens.splice(finalIncrementalTokenIndex, 1, `${finalIncrementalToken}*`), `[@] match text::query("${processedTokens.join(" ").replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}")`;
|
|
643
930
|
}
|
|
644
|
-
export { PREVIEW_PROJECTION, createGroqSearchFilter, createLogger, defineFetcher, defineMutation, getApplicationOrigin, getBusFavoriteState, getClientErrorApiBody, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDashboardMessageBus, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTelemetryManager, getTopicState, getUsersKey, getWorkerClient, initTelemetry, installMessageBus, isDashboardEnvironment, isDeepEqual, isMessageBusEnvironment, isStudioConfig, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, parseUsersKey, pickProperties, randomId, randomUuid, requireDashboardMessageBus, resetMessageBus, resolveBusFavorite, resolveTopic, setBusFavorite, trackHookMounted, transformProjectionToPreview, workerMessages };
|
|
931
|
+
export { PREVIEW_PROJECTION, createAppFunctions, createGroqSearchFilter, createLogger, defineFetcher, defineMutation, getApplicationOrigin, getBusFavoriteState, getClientErrorApiBody, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDashboardMessageBus, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTelemetryManager, getTopicState, getUsersKey, getWorkerClient, initTelemetry, installMessageBus, isDashboardEnvironment, isDeepEqual, isMessageBusEnvironment, isStudioConfig, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, parseUsersKey, pickProperties, randomId, randomUuid, reportError, requireDashboardMessageBus, resetMessageBus, resolveBusFavorite, resolveTopic, setBusFavorite, trackHookMounted, transformProjectionToPreview, workerMessages };
|
|
645
932
|
|
|
646
933
|
//# sourceMappingURL=_internal.js.map
|