@sanity/client 6.9.4-canary.1 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{browserMiddleware-qjpIf6pt.js → browserMiddleware-eLzHI4Fk.js} +6 -5
- package/dist/_chunks/browserMiddleware-eLzHI4Fk.js.map +1 -0
- package/dist/_chunks/{browserMiddleware-QFfeiNj_.cjs → browserMiddleware-hi8PGbSU.cjs} +6 -5
- package/dist/_chunks/browserMiddleware-hi8PGbSU.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-15oKiAwT.cjs → nodeMiddleware-1l7OW-D5.cjs} +7 -6
- package/dist/_chunks/nodeMiddleware-1l7OW-D5.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-GQqb_VSH.js → nodeMiddleware-KnoWsJY5.js} +7 -6
- package/dist/_chunks/nodeMiddleware-KnoWsJY5.js.map +1 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +11 -9
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.js +12 -10
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +11 -9
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.ts +2 -0
- package/dist/stega.js +12 -10
- package/dist/stega.js.map +1 -1
- package/package.json +1 -1
- package/src/data/dataMethods.ts +2 -1
- package/src/stega/SanityStegaClient.ts +5 -2
- package/src/types.ts +2 -18
- package/umd/sanityClient.js +5 -4
- package/umd/sanityClient.min.js +1 -1
- package/dist/_chunks/browserMiddleware-QFfeiNj_.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-qjpIf6pt.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-15oKiAwT.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-GQqb_VSH.js.map +0 -1
package/dist/stega.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ObservableSanityClient, defaultConfig, SanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-
|
|
2
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-
|
|
1
|
+
import { ObservableSanityClient, defaultConfig, SanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-KnoWsJY5.js';
|
|
2
|
+
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-KnoWsJY5.js';
|
|
3
3
|
import { map } from 'rxjs/operators';
|
|
4
4
|
import { vercelStegaCombine, vercelStegaSplit } from '@vercel/stega';
|
|
5
5
|
import { walkMap, resolveMapping, parseJsonPath, resolveStudioBaseRoute, createEditUrl, reKeySegment, toString, jsonPathToStudioPath } from './_chunks/resolveEditInfo-AeWgV4US.js';
|
|
@@ -256,6 +256,12 @@ function stegaEncodeSourceMap(result, resultSourceMap, config) {
|
|
|
256
256
|
function prettyPathForLogging(path) {
|
|
257
257
|
return toString(jsonPathToStudioPath(path));
|
|
258
258
|
}
|
|
259
|
+
function vercelStegaCleanAll(result) {
|
|
260
|
+
return JSON.parse(JSON.stringify(result, (key, value) => {
|
|
261
|
+
if (typeof value !== "string") return value;
|
|
262
|
+
return vercelStegaSplit(value).cleaned;
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
259
265
|
var __accessCheck = (obj, member, msg) => {
|
|
260
266
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
261
267
|
};
|
|
@@ -330,12 +336,13 @@ const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends
|
|
|
330
336
|
}
|
|
331
337
|
});
|
|
332
338
|
}
|
|
333
|
-
fetch(query,
|
|
339
|
+
fetch(query, _params) {
|
|
334
340
|
let _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
335
341
|
const {
|
|
336
342
|
stegaConfig,
|
|
337
343
|
fetchOptions: options
|
|
338
344
|
} = splitStegaConfigFromFetchOptions(_options, this.stegaConfig);
|
|
345
|
+
const params = _params ? vercelStegaCleanAll(_params) : _params;
|
|
339
346
|
if (!stegaConfig.enabled) {
|
|
340
347
|
return super.fetch(query, params, options);
|
|
341
348
|
}
|
|
@@ -420,12 +427,13 @@ const _SanityStegaClient = class _SanityStegaClient extends SanityClient {
|
|
|
420
427
|
}
|
|
421
428
|
});
|
|
422
429
|
}
|
|
423
|
-
fetch(query,
|
|
430
|
+
fetch(query, _params) {
|
|
424
431
|
let _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
425
432
|
const {
|
|
426
433
|
stegaConfig,
|
|
427
434
|
fetchOptions: options
|
|
428
435
|
} = splitStegaConfigFromFetchOptions(_options, this.stegaConfig);
|
|
436
|
+
const params = _params ? vercelStegaCleanAll(_params) : _params;
|
|
429
437
|
if (!stegaConfig.enabled) {
|
|
430
438
|
return super.fetch(query, params, options);
|
|
431
439
|
}
|
|
@@ -450,12 +458,6 @@ const _SanityStegaClient = class _SanityStegaClient extends SanityClient {
|
|
|
450
458
|
};
|
|
451
459
|
_httpRequest2 = new WeakMap();
|
|
452
460
|
let SanityStegaClient = _SanityStegaClient;
|
|
453
|
-
function vercelStegaCleanAll(result) {
|
|
454
|
-
return JSON.parse(JSON.stringify(result, (key, value) => {
|
|
455
|
-
if (typeof value !== "string") return value;
|
|
456
|
-
return vercelStegaSplit(value).cleaned;
|
|
457
|
-
}));
|
|
458
|
-
}
|
|
459
461
|
const exp = defineCreateClientExports(middleware, SanityStegaClient);
|
|
460
462
|
const requester = exp.requester;
|
|
461
463
|
const createClient = exp.createClient;
|
package/dist/stega.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stega.js","sources":["../src/stega/config.ts","../src/stega/encodeIntoResult.ts","../src/stega/filterDefault.ts","../src/stega/stegaEncodeSourceMap.ts","../src/stega/SanityStegaClient.ts","../src/stega/vercelStegaCleanAll.ts","../src/stega/index.ts"],"sourcesContent":["import type {\n ClientConfig,\n FilteredResponseQueryOptions,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport type {ClientStegaConfig, InitializedStegaConfig, StegaConfig} from './types'\n\nexport const defaultStegaConfig: StegaConfig = {\n enabled: false,\n filter: (props) => props.filterDefault(props),\n}\n\nexport function splitConfig(config: ClientStegaConfig): {\n clientConfig: ClientConfig\n stegaConfig: StegaConfig\n} {\n const {stega = {}, ...clientConfig} = config\n return {clientConfig, stegaConfig: typeof stega === 'boolean' ? {enabled: stega} : stega}\n}\n\nexport const initStegaConfig = (\n config: Partial<StegaConfig>,\n prevConfig: Partial<StegaConfig>,\n): InitializedStegaConfig => {\n const specifiedConfig = Object.assign({} as StegaConfig, prevConfig, config)\n const newConfig = Object.assign({} as InitializedStegaConfig, defaultStegaConfig, specifiedConfig)\n\n if ('encodeSourceMap' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client/stega'. Did you mean 'enabled'?`,\n )\n }\n\n if ('encodeSourceMapAtPath' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client/stega'. Did you mean 'filter'?`,\n )\n }\n\n if (typeof newConfig.enabled !== 'boolean') {\n throw new Error(`config.enabled must be a boolean, received ${newConfig.enabled}`)\n }\n\n if (newConfig.enabled && newConfig.studioUrl === undefined) {\n throw new Error(`config.studioUrl must be defined when config.enabled is true`)\n }\n\n if (\n newConfig.enabled &&\n typeof newConfig.studioUrl !== 'string' &&\n typeof newConfig.studioUrl !== 'function'\n ) {\n throw new Error(\n `config.studioUrl must be a string or a function, received ${newConfig.studioUrl}`,\n )\n }\n\n return newConfig\n}\n\nexport function splitStegaConfigFromFetchOptions(\n options: (FilteredResponseQueryOptions | UnfilteredResponseQueryOptions) & {\n stega?: boolean | StegaConfig\n },\n initializedStegaConfig: InitializedStegaConfig,\n): {\n fetchOptions: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions\n stegaConfig: InitializedStegaConfig\n} {\n const {stega = {}, ...fetchOptions} = options\n const stegaConfig = initStegaConfig(\n typeof stega === 'boolean' ? {enabled: stega} : stega,\n initializedStegaConfig,\n )\n return {fetchOptions, stegaConfig}\n}\n","import {parseJsonPath} from '../csm/jsonPath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport type {ContentSourceMap} from '../csm/types'\nimport {walkMap} from '../csm/walkMap'\nimport type {Encoder} from './types'\n\n/**\n * @internal\n */\nexport function encodeIntoResult<Result>(\n result: Result,\n csm: ContentSourceMap,\n encoder: Encoder,\n): Result {\n return walkMap(result, (value, path) => {\n // Only map strings, we could extend this in the future to support other types like integers...\n if (typeof value !== 'string') {\n return value\n }\n\n const resolveMappingResult = resolveMapping(path, csm)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, matchedPath} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = csm.documents[mapping.source.document!]\n const sourcePath = csm.paths[mapping.source.path]\n\n const matchPathSegments = parseJsonPath(matchedPath)\n const sourcePathSegments = parseJsonPath(sourcePath)\n const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length))\n\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, value}) => {\n // Skips encoding on URL or Date strings, similar to the `skip: 'auto'` parameter in vercelStegaCombine()\n if (isValidDate(value) || isValidURL(value)) {\n return false\n }\n\n const endPath = sourcePath.at(-1)\n // Never encode slugs\n if (sourcePath.at(-2) === 'slug' && endPath === 'current') {\n return false\n }\n\n // Skip underscored keys, needs better heuristics but it works for now\n if (typeof endPath === 'string' && endPath.startsWith('_')) {\n return false\n }\n\n /**\n * Best effort infer Portable Text paths that should not be encoded.\n * Nothing is for certain, and the below implementation may cause paths that aren't Portable Text and otherwise be safe to encode to be skipped.\n * However, that's ok as userland can always opt-in with the `encodeSourceMapAtPath` option and mark known safe paths as such, which will override this heuristic.\n */\n // If the path ends in marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {\n return false\n }\n // Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163\n if (\n endPath === 'href' &&\n typeof sourcePath.at(-2) === 'number' &&\n sourcePath.at(-3) === 'markDefs'\n ) {\n return false\n }\n // Otherwise we have to deal with special properties of PortableTextBlock, and we can't confidently know if it's actually a `_type: 'block'` array item or not.\n // All we know is that if it is indeed a block, and we encode the strings on these keys it'll for sure break the PortableText rendering and thus we skip encoding.\n // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\n return false\n }\n\n // Don't encode into anything that is suggested it'll render for SEO in meta tags\n if (\n sourcePath.some(\n (path) => path === 'meta' || path === 'metadata' || path === 'openGraph' || path === 'seo',\n )\n ) {\n return false\n }\n\n // Finally, we ignore a bunch of paths that are typically used for page building\n if (typeof endPath === 'string' && denylist.has(endPath)) {\n return false\n }\n\n return true\n}\n\nconst denylist = new Set([\n 'color',\n 'colour',\n 'currency',\n 'email',\n 'format',\n 'gid',\n 'hex',\n 'href',\n 'hsl',\n 'hsla',\n 'icon',\n 'id',\n 'index',\n 'key',\n 'language',\n 'layout',\n 'link',\n 'linkAction',\n 'locale',\n 'lqip',\n 'page',\n 'path',\n 'ref',\n 'rgb',\n 'rgba',\n 'route',\n 'secret',\n 'slug',\n 'status',\n 'tag',\n 'template',\n 'theme',\n 'type',\n 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return Number.isNaN(Number(dateString)) ? Boolean(Date.parse(dateString)) : false\n}\n\nfunction isValidURL(url: string) {\n try {\n new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n } catch {\n return false\n }\n return true\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport {createEditUrl} from '../csm/createEditUrl'\nimport {jsonPathToStudioPath} from '../csm/jsonPath'\nimport {resolveStudioBaseRoute} from '../csm/resolveEditInfo'\nimport {reKeySegment, toString as studioPathToString} from '../csm/studioPath'\nimport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, ContentSourceMapParsedPath, InitializedStegaConfig} from './types'\n\nconst TRUNCATE_LENGTH = 20\n\n/**\n * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.\n * The JSON payloads are added using invisible characters so they don't show up visually.\n * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.\n * @public\n */\nexport function stegaEncodeSourceMap<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n config: InitializedStegaConfig,\n): Result {\n const {filter, logger, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client/stega]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client/stega]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!config.studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client/stega]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n const report: Record<'encoded' | 'skipped', {path: string; length: number; value: string}[]> = {\n encoded: [],\n skipped: [],\n }\n\n const resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({sourcePath, sourceDocument, resultPath, value}) => {\n // Allow userland to control when to opt-out of encoding\n if (\n (typeof filter === 'function'\n ? filter({sourcePath, resultPath, filterDefault, sourceDocument, value})\n : filterDefault({sourcePath, resultPath, filterDefault, sourceDocument, value})) === false\n ) {\n if (logger) {\n report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${\n value.length > TRUNCATE_LENGTH ? '...' : ''\n }`,\n length: value.length,\n })\n }\n return value\n }\n\n if (logger) {\n report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? '...' : ''}`,\n length: value.length,\n })\n }\n\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof config.studioUrl === 'function'\n ? config.studioUrl(sourceDocument)\n : config.studioUrl!,\n )\n if (!baseUrl) return value\n const {_id: id, _type: type} = sourceDocument\n\n return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n }),\n },\n // We use custom logic to determine if we should skip encoding\n false,\n )\n },\n )\n\n if (logger) {\n const isSkipping = report.skipped.length\n const isEncoding = report.encoded.length\n if (isSkipping || isEncoding) {\n ;(logger?.groupCollapsed || logger.log)?.(\n '[@sanity/client/stega]: Encoding source map into result',\n )\n logger.log?.(\n `[@sanity/client/stega]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client/stega]: Table of encoded paths`)\n ;(logger?.table || logger.log)?.(report.encoded)\n }\n if (report.skipped.length > 0) {\n const skipped = new Set<string>()\n for (const {path} of report.skipped) {\n skipped.add(path.replace(reKeySegment, '0').replace(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client/stega]: List of skipped paths`, [...skipped.values()])\n }\n\n if (isSkipping || isEncoding) {\n logger?.groupEnd?.()\n }\n }\n\n return resultWithStega\n}\n\nfunction prettyPathForLogging(path: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n","import {Observable} from 'rxjs'\nimport {map} from 'rxjs/operators'\n\nimport {defaultConfig} from '../config'\nimport {\n ObservableSanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n SanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\n} from '../SanityClient'\nimport type {\n Any,\n ClientConfig,\n FilteredResponseQueryOptions,\n HttpRequest,\n QueryParams,\n RawQueryResponse,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport {\n defaultStegaConfig,\n initStegaConfig,\n splitConfig,\n splitStegaConfigFromFetchOptions,\n} from './config'\nimport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nimport {ClientStegaConfig, InitializedClientStegaConfig, InitializedStegaConfig} from './types'\n\n/** @public */\nexport class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient {\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): ObservableSanityStegaClient {\n return new ObservableSanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityStegaClient {\n const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new ObservableSanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Observable<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n params?: Q,\n _options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Observable<RawQueryResponse<R> | R> {\n const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .pipe(\n map((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n }),\n )\n }\n}\n\n/** @public */\nexport class SanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient {\n /**\n * Observable version of the Sanity client, with the same configuration as the promise-based one\n */\n observable: ObservableSanityStegaClient\n\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n\n this.observable = new ObservableSanityStegaClient(httpRequest, config)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): SanityStegaClient {\n return new SanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, {...(this.stegaConfig || {})})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientStegaConfig>): SanityStegaClient {\n const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new SanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Promise<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n params?: Q,\n _options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Promise<RawQueryResponse<R> | R> {\n const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .then((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n })\n }\n}\n\nexport type {\n INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\n}\n","import {vercelStegaSplit} from '@vercel/stega'\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @alpha\n */\nexport function vercelStegaCleanAll<Result = unknown>(result: Result): Result {\n return JSON.parse(\n JSON.stringify(result, (key, value) => {\n if (typeof value !== 'string') return value\n return vercelStegaSplit(value).cleaned\n }),\n )\n}\n","export * from '../defineCreateClient'\n\nimport defineCreateClientExports from '../defineCreateClient'\nimport envMiddleware from '../http/nodeMiddleware'\nimport {SanityStegaClient} from './SanityStegaClient'\nimport type {ClientStegaConfig} from './types'\n\nconst exp = defineCreateClientExports<SanityStegaClient, ClientStegaConfig>(\n envMiddleware,\n SanityStegaClient,\n)\n\nexport type {ObservableSanityClient, SanityClient} from './shared'\nexport * from './shared'\n\n/** @public */\nexport const requester = exp.requester\n\n/** @public */\nexport const createClient = exp.createClient\n"],"names":["defaultStegaConfig","enabled","filter","props","filterDefault","splitConfig","config","stega","clientConfig","stegaConfig","initStegaConfig","prevConfig","specifiedConfig","Object","assign","newConfig","Error","concat","studioUrl","splitStegaConfigFromFetchOptions","options","initializedStegaConfig","fetchOptions","encodeIntoResult","result","csm","encoder","walkMap","value","path","resolveMappingResult","resolveMapping","mapping","matchedPath","type","source","sourceDocument","documents","document","sourcePath","paths","matchPathSegments","parseJsonPath","sourcePathSegments","fullSourceSegments","slice","length","resultPath","_ref","isValidDate","isValidURL","endPath","at","startsWith","some","denylist","has","Set","dateString","Number","isNaN","Boolean","Date","parse","url","URL","TRUNCATE_LENGTH","stegaEncodeSourceMap","resultSourceMap","_a","_b","_c","_d","_e","_f","_g","_h","_i","logger","msg","error","call","TypeError","report","encoded","skipped","resultWithStega","_ref2","push","prettyPathForLogging","baseUrl","workspace","tool","resolveStudioBaseRoute","_id","id","_type","vercelStegaCombine","origin","href","createEditUrl","isSkipping","isEncoding","groupCollapsed","log","table","add","replace","reKeySegment","values","groupEnd","studioPathToString","jsonPathToStudioPath","_httpRequest","_ObservableSanityStegaClient","INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient","constructor","httpRequest","arguments","undefined","defaultConfig","__privateAdd","__privateSet","clone","__privateGet","withConfig","thisConfig","fetch","query","params","_options","filterResponse","originalFilterResponse","pipe","map","res","_result","WeakMap","ObservableSanityStegaClient","_SanityStegaClient","INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient","observable","then","SanityStegaClient","vercelStegaCleanAll","JSON","stringify","key","vercelStegaSplit","cleaned","exp","defineCreateClientExports","envMiddleware","requester","createClient"],"mappings":";;;;;;AAOO,MAAMA,kBAAkC,GAAA;EAC7CC,OAAS,EAAA,KAAA;EACTC,MAAQ,EAACC,KAAU,IAAAA,KAAA,CAAMC,cAAcD,KAAK;AAC9C,CAAA;AAEO,SAASE,YAAYC,MAG1B,EAAA;EACA,MAAM;IAACC,KAAQ,GAAA,CAAA,CAAI;IAAA,GAAGC;GAAgB,GAAAF,MAAA;EAC/B,OAAA;IAACE,YAAc;IAAAC,WAAA,EAAa,OAAOF,KAAA,KAAU,YAAY;MAACN,OAAA,EAASM;KAAK,GAAIA;GAAK;AAC1F;AAEa,MAAAG,eAAA,GAAkBA,CAC7BJ,MAAA,EACAK,UAC2B,KAAA;EAC3B,MAAMC,kBAAkBC,MAAO,CAAAC,MAAA,CAAO,CAAA,CAAC,EAAkBH,YAAYL,MAAM,CAAA;EAC3E,MAAMS,YAAYF,MAAO,CAAAC,MAAA,CAAO,CAAA,CAAC,EAA6Bd,oBAAoBY,eAAe,CAAA;EAEjG,IAAI,qBAAqBG,SAAW,EAAA;IAClC,MAAM,IAAIC,KAAA,CACR,kKAAA,CACF;EACF;EAEA,IAAI,2BAA2BD,SAAW,EAAA;IACxC,MAAM,IAAIC,KAAA,CACR,uKAAA,CACF;EACF;EAEI,IAAA,OAAOD,SAAU,CAAAd,OAAA,KAAY,SAAW,EAAA;IAC1C,MAAM,IAAIe,KAAA,CAAM,6CAA8C,CAAAC,MAAA,CAAAF,SAAA,CAAUd,OAAS,CAAA,CAAA;EACnF;EAEA,IAAIc,SAAU,CAAAd,OAAA,IAAWc,SAAU,CAAAG,SAAA,KAAc,KAAW,CAAA,EAAA;IACpD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+G,cAAgB,EAAA,KAAA;MAChB/D,eAAiB,EAAA;IAAA,CAClB,CAAA,CACH,CACC0E,IAAK,CAACP,GAAa,IAAA;MAClB,MAAM;QAAC/G,MAAA,EAAQgH,OAAS;QAAApE;MAAA,CAAmB,GAAAmE,GAAA;MAC3C,MAAM/G,MAAS,GAAA2C,oBAAA,CAAqBqE,OAAS,EAAApE,eAAA,EAAiB3D,WAAW,CAAA;MACzE,OAAO2H,sBAAyB,GAAA5G,MAAA,GAAS;QAAC,GAAG+G;QAAK/G;MAAM,CAAA;IAAA,CACzD,CAAA;EACL;AACF,CAAA;AA3HEyF,aAAA,GAAA,IAAAwB,OAAA,CAAA,CAAA;AATK,IAAMM,iBAAN,GAAAJ,kBAAA;ACtJA,SAASK,oBAAsCxH,MAAwB,EAAA;EAC5E,OAAOyH,IAAK,CAAAlF,KAAA,CACVkF,IAAK,CAAAC,SAAA,CAAU1H,MAAQ,EAAA,CAAC2H,KAAKvH,KAAU,KAAA;IACrC,IAAI,OAAOA,KAAU,KAAA,QAAA,EAAiB,OAAAA,KAAA;IAC/B,OAAAwH,gBAAA,CAAiBxH,KAAK,CAAE,CAAAyH,OAAA;EAAA,CAChC,CAAA,CACH;AACF;ACPA,MAAMC,GAAM,GAAAC,yBAAA,CACVC,UAAA,EACAT,iBACF,CAAA;AAMO,MAAMU,YAAYH,GAAI,CAAAG,SAAA;AAGtB,MAAMC,eAAeJ,GAAI,CAAAI,YAAA;"}
|
|
1
|
+
{"version":3,"file":"stega.js","sources":["../src/stega/config.ts","../src/stega/encodeIntoResult.ts","../src/stega/filterDefault.ts","../src/stega/stegaEncodeSourceMap.ts","../src/stega/vercelStegaCleanAll.ts","../src/stega/SanityStegaClient.ts","../src/stega/index.ts"],"sourcesContent":["import type {\n ClientConfig,\n FilteredResponseQueryOptions,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport type {ClientStegaConfig, InitializedStegaConfig, StegaConfig} from './types'\n\nexport const defaultStegaConfig: StegaConfig = {\n enabled: false,\n filter: (props) => props.filterDefault(props),\n}\n\nexport function splitConfig(config: ClientStegaConfig): {\n clientConfig: ClientConfig\n stegaConfig: StegaConfig\n} {\n const {stega = {}, ...clientConfig} = config\n return {clientConfig, stegaConfig: typeof stega === 'boolean' ? {enabled: stega} : stega}\n}\n\nexport const initStegaConfig = (\n config: Partial<StegaConfig>,\n prevConfig: Partial<StegaConfig>,\n): InitializedStegaConfig => {\n const specifiedConfig = Object.assign({} as StegaConfig, prevConfig, config)\n const newConfig = Object.assign({} as InitializedStegaConfig, defaultStegaConfig, specifiedConfig)\n\n if ('encodeSourceMap' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client/stega'. Did you mean 'enabled'?`,\n )\n }\n\n if ('encodeSourceMapAtPath' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client/stega'. Did you mean 'filter'?`,\n )\n }\n\n if (typeof newConfig.enabled !== 'boolean') {\n throw new Error(`config.enabled must be a boolean, received ${newConfig.enabled}`)\n }\n\n if (newConfig.enabled && newConfig.studioUrl === undefined) {\n throw new Error(`config.studioUrl must be defined when config.enabled is true`)\n }\n\n if (\n newConfig.enabled &&\n typeof newConfig.studioUrl !== 'string' &&\n typeof newConfig.studioUrl !== 'function'\n ) {\n throw new Error(\n `config.studioUrl must be a string or a function, received ${newConfig.studioUrl}`,\n )\n }\n\n return newConfig\n}\n\nexport function splitStegaConfigFromFetchOptions(\n options: (FilteredResponseQueryOptions | UnfilteredResponseQueryOptions) & {\n stega?: boolean | StegaConfig\n },\n initializedStegaConfig: InitializedStegaConfig,\n): {\n fetchOptions: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions\n stegaConfig: InitializedStegaConfig\n} {\n const {stega = {}, ...fetchOptions} = options\n const stegaConfig = initStegaConfig(\n typeof stega === 'boolean' ? {enabled: stega} : stega,\n initializedStegaConfig,\n )\n return {fetchOptions, stegaConfig}\n}\n","import {parseJsonPath} from '../csm/jsonPath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport type {ContentSourceMap} from '../csm/types'\nimport {walkMap} from '../csm/walkMap'\nimport type {Encoder} from './types'\n\n/**\n * @internal\n */\nexport function encodeIntoResult<Result>(\n result: Result,\n csm: ContentSourceMap,\n encoder: Encoder,\n): Result {\n return walkMap(result, (value, path) => {\n // Only map strings, we could extend this in the future to support other types like integers...\n if (typeof value !== 'string') {\n return value\n }\n\n const resolveMappingResult = resolveMapping(path, csm)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, matchedPath} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = csm.documents[mapping.source.document!]\n const sourcePath = csm.paths[mapping.source.path]\n\n const matchPathSegments = parseJsonPath(matchedPath)\n const sourcePathSegments = parseJsonPath(sourcePath)\n const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length))\n\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, value}) => {\n // Skips encoding on URL or Date strings, similar to the `skip: 'auto'` parameter in vercelStegaCombine()\n if (isValidDate(value) || isValidURL(value)) {\n return false\n }\n\n const endPath = sourcePath.at(-1)\n // Never encode slugs\n if (sourcePath.at(-2) === 'slug' && endPath === 'current') {\n return false\n }\n\n // Skip underscored keys, needs better heuristics but it works for now\n if (typeof endPath === 'string' && endPath.startsWith('_')) {\n return false\n }\n\n /**\n * Best effort infer Portable Text paths that should not be encoded.\n * Nothing is for certain, and the below implementation may cause paths that aren't Portable Text and otherwise be safe to encode to be skipped.\n * However, that's ok as userland can always opt-in with the `encodeSourceMapAtPath` option and mark known safe paths as such, which will override this heuristic.\n */\n // If the path ends in marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {\n return false\n }\n // Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163\n if (\n endPath === 'href' &&\n typeof sourcePath.at(-2) === 'number' &&\n sourcePath.at(-3) === 'markDefs'\n ) {\n return false\n }\n // Otherwise we have to deal with special properties of PortableTextBlock, and we can't confidently know if it's actually a `_type: 'block'` array item or not.\n // All we know is that if it is indeed a block, and we encode the strings on these keys it'll for sure break the PortableText rendering and thus we skip encoding.\n // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\n return false\n }\n\n // Don't encode into anything that is suggested it'll render for SEO in meta tags\n if (\n sourcePath.some(\n (path) => path === 'meta' || path === 'metadata' || path === 'openGraph' || path === 'seo',\n )\n ) {\n return false\n }\n\n // Finally, we ignore a bunch of paths that are typically used for page building\n if (typeof endPath === 'string' && denylist.has(endPath)) {\n return false\n }\n\n return true\n}\n\nconst denylist = new Set([\n 'color',\n 'colour',\n 'currency',\n 'email',\n 'format',\n 'gid',\n 'hex',\n 'href',\n 'hsl',\n 'hsla',\n 'icon',\n 'id',\n 'index',\n 'key',\n 'language',\n 'layout',\n 'link',\n 'linkAction',\n 'locale',\n 'lqip',\n 'page',\n 'path',\n 'ref',\n 'rgb',\n 'rgba',\n 'route',\n 'secret',\n 'slug',\n 'status',\n 'tag',\n 'template',\n 'theme',\n 'type',\n 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return Number.isNaN(Number(dateString)) ? Boolean(Date.parse(dateString)) : false\n}\n\nfunction isValidURL(url: string) {\n try {\n new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n } catch {\n return false\n }\n return true\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport {createEditUrl} from '../csm/createEditUrl'\nimport {jsonPathToStudioPath} from '../csm/jsonPath'\nimport {resolveStudioBaseRoute} from '../csm/resolveEditInfo'\nimport {reKeySegment, toString as studioPathToString} from '../csm/studioPath'\nimport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, ContentSourceMapParsedPath, InitializedStegaConfig} from './types'\n\nconst TRUNCATE_LENGTH = 20\n\n/**\n * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.\n * The JSON payloads are added using invisible characters so they don't show up visually.\n * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.\n * @public\n */\nexport function stegaEncodeSourceMap<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n config: InitializedStegaConfig,\n): Result {\n const {filter, logger, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client/stega]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client/stega]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!config.studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client/stega]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n const report: Record<'encoded' | 'skipped', {path: string; length: number; value: string}[]> = {\n encoded: [],\n skipped: [],\n }\n\n const resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({sourcePath, sourceDocument, resultPath, value}) => {\n // Allow userland to control when to opt-out of encoding\n if (\n (typeof filter === 'function'\n ? filter({sourcePath, resultPath, filterDefault, sourceDocument, value})\n : filterDefault({sourcePath, resultPath, filterDefault, sourceDocument, value})) === false\n ) {\n if (logger) {\n report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${\n value.length > TRUNCATE_LENGTH ? '...' : ''\n }`,\n length: value.length,\n })\n }\n return value\n }\n\n if (logger) {\n report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? '...' : ''}`,\n length: value.length,\n })\n }\n\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof config.studioUrl === 'function'\n ? config.studioUrl(sourceDocument)\n : config.studioUrl!,\n )\n if (!baseUrl) return value\n const {_id: id, _type: type} = sourceDocument\n\n return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n }),\n },\n // We use custom logic to determine if we should skip encoding\n false,\n )\n },\n )\n\n if (logger) {\n const isSkipping = report.skipped.length\n const isEncoding = report.encoded.length\n if (isSkipping || isEncoding) {\n ;(logger?.groupCollapsed || logger.log)?.(\n '[@sanity/client/stega]: Encoding source map into result',\n )\n logger.log?.(\n `[@sanity/client/stega]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client/stega]: Table of encoded paths`)\n ;(logger?.table || logger.log)?.(report.encoded)\n }\n if (report.skipped.length > 0) {\n const skipped = new Set<string>()\n for (const {path} of report.skipped) {\n skipped.add(path.replace(reKeySegment, '0').replace(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client/stega]: List of skipped paths`, [...skipped.values()])\n }\n\n if (isSkipping || isEncoding) {\n logger?.groupEnd?.()\n }\n }\n\n return resultWithStega\n}\n\nfunction prettyPathForLogging(path: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n","import {vercelStegaSplit} from '@vercel/stega'\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @alpha\n */\nexport function vercelStegaCleanAll<Result = unknown>(result: Result): Result {\n return JSON.parse(\n JSON.stringify(result, (key, value) => {\n if (typeof value !== 'string') return value\n return vercelStegaSplit(value).cleaned\n }),\n )\n}\n","import {Observable} from 'rxjs'\nimport {map} from 'rxjs/operators'\n\nimport {defaultConfig} from '../config'\nimport {\n ObservableSanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n SanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\n} from '../SanityClient'\nimport type {\n Any,\n ClientConfig,\n FilteredResponseQueryOptions,\n HttpRequest,\n QueryParams,\n RawQueryResponse,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport {\n defaultStegaConfig,\n initStegaConfig,\n splitConfig,\n splitStegaConfigFromFetchOptions,\n} from './config'\nimport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nimport {ClientStegaConfig, InitializedClientStegaConfig, InitializedStegaConfig} from './types'\nimport {vercelStegaCleanAll} from './vercelStegaCleanAll'\n\n/** @public */\nexport class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient {\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): ObservableSanityStegaClient {\n return new ObservableSanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityStegaClient {\n const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new ObservableSanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Observable<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n _params?: Q,\n _options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Observable<RawQueryResponse<R> | R> {\n const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n const params = _params ? vercelStegaCleanAll(_params) : _params\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .pipe(\n map((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n }),\n )\n }\n}\n\n/** @public */\nexport class SanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient {\n /**\n * Observable version of the Sanity client, with the same configuration as the promise-based one\n */\n observable: ObservableSanityStegaClient\n\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n\n this.observable = new ObservableSanityStegaClient(httpRequest, config)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): SanityStegaClient {\n return new SanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, {...(this.stegaConfig || {})})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientStegaConfig>): SanityStegaClient {\n const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new SanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Promise<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n _params?: Q,\n _options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Promise<RawQueryResponse<R> | R> {\n const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n const params = _params ? vercelStegaCleanAll(_params) : _params\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .then((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n })\n }\n}\n\nexport type {\n INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\n}\n","export * from '../defineCreateClient'\n\nimport defineCreateClientExports from '../defineCreateClient'\nimport envMiddleware from '../http/nodeMiddleware'\nimport {SanityStegaClient} from './SanityStegaClient'\nimport type {ClientStegaConfig} from './types'\n\nconst exp = defineCreateClientExports<SanityStegaClient, ClientStegaConfig>(\n envMiddleware,\n SanityStegaClient,\n)\n\nexport type {ObservableSanityClient, SanityClient} from './shared'\nexport * from './shared'\n\n/** @public */\nexport const requester = exp.requester\n\n/** @public */\nexport const createClient = exp.createClient\n"],"names":["defaultStegaConfig","enabled","filter","props","filterDefault","splitConfig","config","stega","clientConfig","stegaConfig","initStegaConfig","prevConfig","specifiedConfig","Object","assign","newConfig","Error","concat","studioUrl","splitStegaConfigFromFetchOptions","options","initializedStegaConfig","fetchOptions","encodeIntoResult","result","csm","encoder","walkMap","value","path","resolveMappingResult","resolveMapping","mapping","matchedPath","type","source","sourceDocument","documents","document","sourcePath","paths","matchPathSegments","parseJsonPath","sourcePathSegments","fullSourceSegments","slice","length","resultPath","_ref","isValidDate","isValidURL","endPath","at","startsWith","some","denylist","has","Set","dateString","Number","isNaN","Boolean","Date","parse","url","URL","TRUNCATE_LENGTH","stegaEncodeSourceMap","resultSourceMap","_a","_b","_c","_d","_e","_f","_g","_h","_i","logger","msg","error","call","TypeError","report","encoded","skipped","resultWithStega","_ref2","push","prettyPathForLogging","baseUrl","workspace","tool","resolveStudioBaseRoute","_id","id","_type","vercelStegaCombine","origin","href","createEditUrl","isSkipping","isEncoding","groupCollapsed","log","table","add","replace","reKeySegment","values","groupEnd","studioPathToString","jsonPathToStudioPath","vercelStegaCleanAll","JSON","stringify","key","vercelStegaSplit","cleaned","_httpRequest","_ObservableSanityStegaClient","INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient","constructor","httpRequest","arguments","undefined","defaultConfig","__privateAdd","__privateSet","clone","__privateGet","withConfig","thisConfig","fetch","query","_params","_options","params","filterResponse","originalFilterResponse","pipe","map","res","_result","WeakMap","ObservableSanityStegaClient","_SanityStegaClient","INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient","observable","then","SanityStegaClient","exp","defineCreateClientExports","envMiddleware","requester","createClient"],"mappings":";;;;;;AAOO,MAAMA,kBAAkC,GAAA;EAC7CC,OAAS,EAAA,KAAA;EACTC,MAAQ,EAACC,KAAU,IAAAA,KAAA,CAAMC,cAAcD,KAAK;AAC9C,CAAA;AAEO,SAASE,YAAYC,MAG1B,EAAA;EACA,MAAM;IAACC,KAAQ,GAAA,CAAA,CAAI;IAAA,GAAGC;GAAgB,GAAAF,MAAA;EAC/B,OAAA;IAACE,YAAc;IAAAC,WAAA,EAAa,OAAOF,KAAA,KAAU,YAAY;MAACN,OAAA,EAASM;KAAK,GAAIA;GAAK;AAC1F;AAEa,MAAAG,eAAA,GAAkBA,CAC7BJ,MAAA,EACAK,UAC2B,KAAA;EAC3B,MAAMC,kBAAkBC,MAAO,CAAAC,MAAA,CAAO,CAAA,CAAC,EAAkBH,YAAYL,MAAM,CAAA;EAC3E,MAAMS,YAAYF,MAAO,CAAAC,MAAA,CAAO,CAAA,CAAC,EAA6Bd,oBAAoBY,eAAe,CAAA;EAEjG,IAAI,qBAAqBG,SAAW,EAAA;IAClC,MAAM,IAAIC,KAAA,CACR,kKAAA,CACF;EACF;EAEA,IAAI,2BAA2BD,SAAW,EAAA;IACxC,MAAM,IAAIC,KAAA,CACR,uKAAA,CACF;EACF;EAEI,IAAA,OAAOD,SAAU,CAAAd,OAAA,KAAY,SAAW,EAAA;IAC1C,MAAM,IAAIe,KAAA,CAAM,6CAA8C,CAAAC,MAAA,CAAAF,SAAA,CAAUd,OAAS,CAAA,CAAA;EACnF;EAEA,IAAIc,SAAU,CAAAd,OAAA,IAAWc,SAAU,CAAAG,SAAA,KAAc,KAAW,CAAA,EAAA;IACpD,MAAA,IAAIF,MAAM,8DAA8D,CAAA;EAChF;EAGE,IAAAD,SAAA,CAAUd,WACV,OAAOc,SAAA,CAAUG,cAAc,QAC/B,IAAA,OAA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AO,CAAI,GAAAA,OAAA;IACpD,IAAA,CAAC9H,YAAYR,OAAS,EAAA;MACxB,OAAO,KAAM,CAAAoI,KAAA,CAAYC,KAAO,EAAAG,MAAA,EAAQrH,OAAc,CAAA;IACxD;IACA,MAAM;MAACsH,cAAA,EAAgBC,sBAAyB,GAAA;IAAA,CAAQ,GAAAvH,OAAA;IACxD,OAAO,KACJ,CAAAiH,KAAA,CACCC,KAAA,EACAG,MAAA,EACA5H,MAAO,CAAAC,MAAA,CAAO,CAAC,CAAA,EAAGM,OAAgB,EAAA;MAChCsH,cAAgB,EAAA,KAAA;MAChBtE,eAAiB,EAAA;IAAA,CAClB,CAAA,CACH,CACCiF,IAAK,CAACP,GAAa,IAAA;MAClB,MAAM;QAACtH,MAAA,EAAQuH,OAAS;QAAA3E;MAAA,CAAmB,GAAA0E,GAAA;MAC3C,MAAMtH,MAAS,GAAA2C,oBAAA,CAAqB4E,OAAS,EAAA3E,eAAA,EAAiB3D,WAAW,CAAA;MACzE,OAAOkI,sBAAyB,GAAAnH,MAAA,GAAS;QAAC,GAAGsH;QAAKtH;MAAM,CAAA;IAAA,CACzD,CAAA;EACL;AACF,CAAA;AA5HE+F,aAAA,GAAA,IAAAyB,OAAA,CAAA,CAAA;AATK,IAAMM,iBAAN,GAAAJ,kBAAA;ACxJP,MAAMK,GAAM,GAAAC,yBAAA,CACVC,UAAA,EACAH,iBACF,CAAA;AAMO,MAAMI,YAAYH,GAAI,CAAAG,SAAA;AAGtB,MAAMC,eAAeJ,GAAI,CAAAI,YAAA;"}
|
package/package.json
CHANGED
package/src/data/dataMethods.ts
CHANGED
|
@@ -247,6 +247,7 @@ export function _dataRequest(
|
|
|
247
247
|
signal: options.signal,
|
|
248
248
|
fetch: options.fetch,
|
|
249
249
|
useAbortSignal: options.useAbortSignal,
|
|
250
|
+
useCdn: options.useCdn,
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
return _requestObservable(client, httpRequest, reqOptions).pipe(
|
|
@@ -312,7 +313,7 @@ export function _requestObservable<R>(
|
|
|
312
313
|
? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 && uri.indexOf('/data/') === 0
|
|
313
314
|
: options.canUseCdn
|
|
314
315
|
|
|
315
|
-
let useCdn = config.useCdn && canUseCdn
|
|
316
|
+
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn
|
|
316
317
|
|
|
317
318
|
const tag =
|
|
318
319
|
options.tag && config.requestTagPrefix
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from './config'
|
|
24
24
|
import {stegaEncodeSourceMap} from './stegaEncodeSourceMap'
|
|
25
25
|
import {ClientStegaConfig, InitializedClientStegaConfig, InitializedStegaConfig} from './types'
|
|
26
|
+
import {vercelStegaCleanAll} from './vercelStegaCleanAll'
|
|
26
27
|
|
|
27
28
|
/** @public */
|
|
28
29
|
export class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient {
|
|
@@ -124,13 +125,14 @@ export class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_Ob
|
|
|
124
125
|
): Observable<RawQueryResponse<R>>
|
|
125
126
|
fetch<R, Q extends QueryParams>(
|
|
126
127
|
query: string,
|
|
127
|
-
|
|
128
|
+
_params?: Q,
|
|
128
129
|
_options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
|
|
129
130
|
): Observable<RawQueryResponse<R> | R> {
|
|
130
131
|
const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(
|
|
131
132
|
_options,
|
|
132
133
|
this.stegaConfig,
|
|
133
134
|
)
|
|
135
|
+
const params = _params ? vercelStegaCleanAll(_params) : _params
|
|
134
136
|
if (!stegaConfig.enabled) {
|
|
135
137
|
return super.fetch<R, Q>(query, params, options as Any)
|
|
136
138
|
}
|
|
@@ -261,13 +263,14 @@ export class SanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient
|
|
|
261
263
|
): Promise<RawQueryResponse<R>>
|
|
262
264
|
fetch<R, Q extends QueryParams>(
|
|
263
265
|
query: string,
|
|
264
|
-
|
|
266
|
+
_params?: Q,
|
|
265
267
|
_options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
|
|
266
268
|
): Promise<RawQueryResponse<R> | R> {
|
|
267
269
|
const {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(
|
|
268
270
|
_options,
|
|
269
271
|
this.stegaConfig,
|
|
270
272
|
)
|
|
273
|
+
const params = _params ? vercelStegaCleanAll(_params) : _params
|
|
271
274
|
if (!stegaConfig.enabled) {
|
|
272
275
|
return super.fetch<R, Q>(query, params, options as Any)
|
|
273
276
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import type {Requester} from 'get-it'
|
|
4
4
|
|
|
5
|
-
// import type {StegaConfig} from './stega/types'
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
9
7
|
* @internal
|
|
@@ -294,6 +292,7 @@ export interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
|
294
292
|
url?: string
|
|
295
293
|
uri?: string
|
|
296
294
|
canUseCdn?: boolean
|
|
295
|
+
useCdn?: boolean
|
|
297
296
|
tag?: string
|
|
298
297
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
299
298
|
perspective?: ClientPerspective
|
|
@@ -670,10 +669,7 @@ export interface ResponseQueryOptions<T = 'next'> extends RequestOptions {
|
|
|
670
669
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
671
670
|
cache?: RequestInit['cache']
|
|
672
671
|
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
673
|
-
|
|
674
|
-
* @deprecated -- use `@sanity/client/stega` to set this option
|
|
675
|
-
*/
|
|
676
|
-
// stega?: boolean | StegaConfig
|
|
672
|
+
useCdn?: boolean
|
|
677
673
|
}
|
|
678
674
|
|
|
679
675
|
/** @public */
|
|
@@ -902,15 +898,3 @@ export interface ContentSourceMap {
|
|
|
902
898
|
documents: ContentSourceMapDocuments
|
|
903
899
|
paths: ContentSourceMapPaths
|
|
904
900
|
}
|
|
905
|
-
|
|
906
|
-
// export type {StegaConfig}
|
|
907
|
-
// export type {
|
|
908
|
-
// ContentSourceMapParsedPath,
|
|
909
|
-
// ContentSourceMapParsedPathKeyedSegment,
|
|
910
|
-
// FilterDefault,
|
|
911
|
-
// Logger,
|
|
912
|
-
// ResolveStudioUrl,
|
|
913
|
-
// StudioBaseRoute,
|
|
914
|
-
// StudioBaseUrl,
|
|
915
|
-
// StudioUrl,
|
|
916
|
-
// } from './stega/types'
|
package/umd/sanityClient.js
CHANGED
|
@@ -3034,7 +3034,8 @@
|
|
|
3034
3034
|
canUseCdn: isQuery,
|
|
3035
3035
|
signal: options.signal,
|
|
3036
3036
|
fetch: options.fetch,
|
|
3037
|
-
useAbortSignal: options.useAbortSignal
|
|
3037
|
+
useAbortSignal: options.useAbortSignal,
|
|
3038
|
+
useCdn: options.useCdn
|
|
3038
3039
|
};
|
|
3039
3040
|
return _requestObservable(client, httpRequest, reqOptions).pipe(filter(isResponse), map(getBody), map(res => {
|
|
3040
3041
|
if (!isMutation) {
|
|
@@ -3067,11 +3068,11 @@
|
|
|
3067
3068
|
}, opts);
|
|
3068
3069
|
}
|
|
3069
3070
|
function _requestObservable(client, httpRequest, options) {
|
|
3070
|
-
var _a;
|
|
3071
|
+
var _a, _b;
|
|
3071
3072
|
const uri = options.url || options.uri;
|
|
3072
3073
|
const config = client.config();
|
|
3073
3074
|
const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
|
|
3074
|
-
let useCdn = config.useCdn && canUseCdn;
|
|
3075
|
+
let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
|
|
3075
3076
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
3076
3077
|
if (tag && options.tag !== null) {
|
|
3077
3078
|
options.query = {
|
|
@@ -3080,7 +3081,7 @@
|
|
|
3080
3081
|
};
|
|
3081
3082
|
}
|
|
3082
3083
|
if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
3083
|
-
const resultSourceMap = (
|
|
3084
|
+
const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
|
|
3084
3085
|
if (resultSourceMap !== void 0 && resultSourceMap !== false) {
|
|
3085
3086
|
options.query = {
|
|
3086
3087
|
resultSourceMap,
|