@sanity/client 7.11.2-audience-decide.0 → 7.11.2

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/index.d.cts CHANGED
@@ -706,10 +706,6 @@ export declare interface ClientConfig {
706
706
  * @defaultValue 'published'
707
707
  */
708
708
  perspective?: ClientPerspective
709
- /**
710
- * Parameters to pass to Sanity Decide for personalisation
711
- */
712
- decideParameters?: DecideParameters
713
709
  apiHost?: string
714
710
  /**
715
711
  @remarks
@@ -1136,12 +1132,6 @@ export declare type DatasetsResponse = {
1136
1132
  tags: string[]
1137
1133
  }[]
1138
1134
 
1139
- /** @public */
1140
- export declare interface DecideParameters {
1141
- audience: string | string[]
1142
- [key: string]: unknown
1143
- }
1144
-
1145
1135
  /**
1146
1136
  * Deletes the published version of a document and optionally some (likely all known) draft versions.
1147
1137
  * If any draft version exists that is not specified for deletion this is an error.
@@ -4143,8 +4133,6 @@ export declare interface QueryParams {
4143
4133
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4144
4134
  cache?: 'next' extends keyof RequestInit ? never : any
4145
4135
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4146
- decideParameters?: never
4147
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4148
4136
  filterResponse?: never
4149
4137
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4150
4138
  headers?: never
@@ -4654,7 +4642,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
4654
4642
  returnQuery?: boolean
4655
4643
  resultSourceMap?: boolean | 'withKeyArraySelector'
4656
4644
  perspective?: ClientPerspective
4657
- decideParameters?: DecideParameters
4658
4645
  lastLiveEventId?: string
4659
4646
  cacheMode?: 'noStale'
4660
4647
  }
@@ -4687,7 +4674,6 @@ export declare interface ResponseEvent<T = unknown> {
4687
4674
  /** @public */
4688
4675
  export declare interface ResponseQueryOptions extends RequestOptions {
4689
4676
  perspective?: ClientPerspective
4690
- decideParameters?: DecideParameters
4691
4677
  resultSourceMap?: boolean | 'withKeyArraySelector'
4692
4678
  returnQuery?: boolean
4693
4679
  useCdn?: boolean
package/dist/index.d.ts CHANGED
@@ -706,10 +706,6 @@ export declare interface ClientConfig {
706
706
  * @defaultValue 'published'
707
707
  */
708
708
  perspective?: ClientPerspective
709
- /**
710
- * Parameters to pass to Sanity Decide for personalisation
711
- */
712
- decideParameters?: DecideParameters
713
709
  apiHost?: string
714
710
  /**
715
711
  @remarks
@@ -1136,12 +1132,6 @@ export declare type DatasetsResponse = {
1136
1132
  tags: string[]
1137
1133
  }[]
1138
1134
 
1139
- /** @public */
1140
- export declare interface DecideParameters {
1141
- audience: string | string[]
1142
- [key: string]: unknown
1143
- }
1144
-
1145
1135
  /**
1146
1136
  * Deletes the published version of a document and optionally some (likely all known) draft versions.
1147
1137
  * If any draft version exists that is not specified for deletion this is an error.
@@ -4143,8 +4133,6 @@ export declare interface QueryParams {
4143
4133
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4144
4134
  cache?: 'next' extends keyof RequestInit ? never : any
4145
4135
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4146
- decideParameters?: never
4147
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4148
4136
  filterResponse?: never
4149
4137
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
4150
4138
  headers?: never
@@ -4654,7 +4642,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
4654
4642
  returnQuery?: boolean
4655
4643
  resultSourceMap?: boolean | 'withKeyArraySelector'
4656
4644
  perspective?: ClientPerspective
4657
- decideParameters?: DecideParameters
4658
4645
  lastLiveEventId?: string
4659
4646
  cacheMode?: 'noStale'
4660
4647
  }
@@ -4687,7 +4674,6 @@ export declare interface ResponseEvent<T = unknown> {
4687
4674
  /** @public */
4688
4675
  export declare interface ResponseQueryOptions extends RequestOptions {
4689
4676
  perspective?: ClientPerspective
4690
- decideParameters?: DecideParameters
4691
4677
  resultSourceMap?: boolean | 'withKeyArraySelector'
4692
4678
  returnQuery?: boolean
4693
4679
  useCdn?: boolean
package/dist/index.js CHANGED
@@ -670,32 +670,6 @@ function requestOptions(config, overrides = {}) {
670
670
  fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
671
671
  });
672
672
  }
673
- function isDecideField(value) {
674
- return value != null && typeof value == "object" && !Array.isArray(value) && "default" in value && "conditions" in value && Array.isArray(value.conditions);
675
- }
676
- function resolveDecideField(field, decideParameters) {
677
- const audience = decideParameters.audience, matchingCondition = field.conditions.find((condition) => Array.isArray(audience) ? audience.includes(condition.audience) : condition.audience === audience);
678
- return matchingCondition ? matchingCondition.value : field.default;
679
- }
680
- function processObjectRecursively(obj, decideParameters) {
681
- return obj == null || typeof obj != "object" ? obj : Array.isArray(obj) ? obj.map((item) => processObjectRecursively(item, decideParameters)) : Object.entries(obj).reduce((processed, [key, value]) => {
682
- try {
683
- isDecideField(value) ? processed[key] = resolveDecideField(value, decideParameters) : processed[key] = processObjectRecursively(value, decideParameters);
684
- } catch (error) {
685
- console.warn(`Failed to process decide field '${key}':`, error), processed[key] = value;
686
- }
687
- return processed;
688
- }, {});
689
- }
690
- function processDecideFields(data, decideParameters) {
691
- if (!decideParameters || !decideParameters.audience)
692
- return data;
693
- try {
694
- return processObjectRecursively(data, decideParameters);
695
- } catch (error) {
696
- return console.warn("Failed to process decide fields:", error), data;
697
- }
698
- }
699
673
  const encodeQueryString = ({
700
674
  query,
701
675
  params = {},
@@ -720,7 +694,7 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
720
694
  const stega = "stega" in options ? {
721
695
  ..._stega || {},
722
696
  ...typeof options.stega == "boolean" ? { enabled: options.stega } : options.stega || {}
723
- } : _stega, params = stega.enabled ? stegaClean(_params) : _params, mapResponse = options.filterResponse === !1 ? (res) => res : (res) => res.result, processDecideResponse = (response) => options.decideParameters && options.decideParameters.audience ? processDecideFields(response, options.decideParameters) : response, { cache, next, ...opts } = {
697
+ } : _stega, params = stega.enabled ? stegaClean(_params) : _params, mapResponse = options.filterResponse === !1 ? (res) => res : (res) => res.result, { cache, next, ...opts } = {
724
698
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
725
699
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
726
700
  useAbortSignal: typeof options.signal < "u",
@@ -743,11 +717,11 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
743
717
  ),
744
718
  map(
745
719
  ([res, stegaEncodeSourceMap]) => {
746
- const result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega), mappedResponse = mapResponse({ ...res, result });
747
- return processDecideResponse(mappedResponse);
720
+ const result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega);
721
+ return mapResponse({ ...res, result });
748
722
  }
749
723
  )
750
- ) : $request.pipe(map(mapResponse), map(processDecideResponse));
724
+ ) : $request.pipe(map(mapResponse));
751
725
  }
752
726
  function _getDocument(client, httpRequest, id, opts = {}) {
753
727
  const docId = (() => {
@@ -900,7 +874,6 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
900
874
  tag,
901
875
  returnQuery,
902
876
  perspective: options.perspective,
903
- decideParameters: options.decideParameters,
904
877
  resultSourceMap: options.resultSourceMap,
905
878
  lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
906
879
  cacheMode,
@@ -945,15 +918,7 @@ function _requestObservable(client, httpRequest, options) {
945
918
  perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
946
919
  ...options.query
947
920
  }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
948
- perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()));
949
- const decideParametersOption = options.decideParameters || config.decideParameters;
950
- decideParametersOption && typeof decideParametersOption == "object" && (options.query = {
951
- ...options.query,
952
- ...Object.keys(decideParametersOption).reduce(
953
- (acc, key) => (acc[`decide.${key}`] = decideParametersOption[key], acc),
954
- {}
955
- )
956
- }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
921
+ perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
957
922
  }
958
923
  const reqOptions = requestOptions(
959
924
  config,
@@ -2704,7 +2669,7 @@ function defineDeprecatedCreateClient(createClient2) {
2704
2669
  return printNoDefaultExport(), createClient2(config);
2705
2670
  };
2706
2671
  }
2707
- var name = "@sanity/client", version = "7.11.2-audience-decide.0";
2672
+ var name = "@sanity/client", version = "7.11.2";
2708
2673
  const middleware = [
2709
2674
  debug({ verbose: !0, namespace: "sanity:client" }),
2710
2675
  headers({ "User-Agent": `${name} ${version}` }),