@sanity/schema 6.10.2-next.5 → 6.11.0-next.107

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.
@@ -56,8 +56,11 @@ type DescriptorRequestOptions = RequestOptions;
56
56
  /**
57
57
  * The transport seam. The client calls this for every request; the return value
58
58
  * is the parsed response body. Any requester with the shape
59
- * `<B>(options): Promise<B>` such as a configured `get-it` instance — is
60
- * structurally assignable, so callers can bring their own transport.
59
+ * `<B>(options): Promise<B>` is structurally assignable, so callers can bring
60
+ * their own transport. Note that a configured get-it v9 instance does NOT
61
+ * qualify on its own — it resolves with the full response object, not the
62
+ * parsed body — so it must be wrapped the way {@link createGetItRequester}
63
+ * wraps it.
61
64
  *
62
65
  * @internal
63
66
  */
@@ -391,8 +394,8 @@ declare const builtinTypes: ({
391
394
  name: string;
392
395
  type: string;
393
396
  title: string;
394
- fieldset?: undefined;
395
397
  readOnly?: undefined;
398
+ fieldset?: undefined;
396
399
  validation?: undefined;
397
400
  hidden?: undefined;
398
401
  } | {
@@ -470,8 +473,8 @@ declare const builtinTypes: ({
470
473
  name: string;
471
474
  type: string;
472
475
  title: string;
473
- fieldset?: undefined;
474
476
  readOnly?: undefined;
477
+ fieldset?: undefined;
475
478
  validation?: undefined;
476
479
  hidden?: undefined;
477
480
  } | {
@@ -547,17 +550,17 @@ declare const builtinTypes: ({
547
550
  };
548
551
  }[];
549
552
  fields: ({
550
- name: string;
551
- type: string;
552
- fieldset?: undefined;
553
553
  title?: undefined;
554
554
  readOnly?: undefined;
555
+ fieldset?: undefined;
556
+ name: string;
557
+ type: string;
555
558
  } | {
559
+ readOnly?: undefined;
556
560
  name: string;
557
561
  title: string;
558
562
  type: string;
559
563
  fieldset: string;
560
- readOnly?: undefined;
561
564
  } | {
562
565
  fieldset?: undefined;
563
566
  name: string;
package/lib/_internal.js CHANGED
@@ -1,11 +1,11 @@
1
- import { a as DEFAULT_MAX_FIELD_DEPTH, c as ALL_FIELDS_GROUP_NAME, l as OWN_PROPS_NAME, n as Schema$1, o as resolveSearchConfig, s as resolveSearchConfigForBaseFieldPaths, u as Rule } from "./Schema-BckCkziq.js";
1
+ import { c as resolveSearchConfig, d as OWN_PROPS_NAME, f as Rule, l as resolveSearchConfigForBaseFieldPaths, n as Schema$1, s as DEFAULT_MAX_FIELD_DEPTH, u as ALL_FIELDS_GROUP_NAME } from "./Schema-ClAx8eCc.js";
2
2
  import { SetBuilder, processSetSynchronization } from "@sanity/descriptors";
3
3
  import { isSpanSchemaType } from "@sanity/types";
4
4
  import isEqual from "lodash-es/isEqual.js";
5
5
  import isObject from "lodash-es/isObject.js";
6
6
  import cloneDeep from "lodash-es/cloneDeep.js";
7
- import { getIt } from "get-it";
8
- import { base, httpErrors, jsonRequest, jsonResponse, promise, retry } from "get-it/middleware";
7
+ import { HttpError, createRequester } from "get-it";
8
+ import { retry } from "get-it/middleware";
9
9
  import "@sanity/generate-help-url";
10
10
  import difference from "lodash-es/difference.js";
11
11
  import startCase from "lodash-es/startCase.js";
@@ -632,13 +632,26 @@ function processSchemaSynchronization(sync, response) {
632
632
  return processSetSynchronization(sync, response);
633
633
  }
634
634
  /**
635
- * Retry on rate-limit (429) and server (5xx) responses.
635
+ * Retry on rate-limit (429) and server (5xx) responses. get-it v9 throws a
636
+ * `HttpError` (with the status on `err.status`) for non-2xx responses; network
637
+ * and timeout failures are not `HttpError`s and are not retried, matching the
638
+ * v8 behavior of reading `err.response.statusCode`.
636
639
  *
637
640
  * @internal
638
641
  */
639
642
  function defaultShouldRetry(err) {
640
- let statusCode = err?.response?.statusCode;
641
- return statusCode === 429 || typeof statusCode == "number" && statusCode >= 500;
643
+ return err instanceof HttpError ? err.status === 429 || err.status >= 500 : !1;
644
+ }
645
+ /**
646
+ * Parse a response body the way get-it v8's `jsonResponse()` middleware did:
647
+ * JSON only when the body is non-empty and the content type says so, the raw
648
+ * text otherwise, `undefined` for empty bodies. get-it v9's `as: 'json'`
649
+ * parses unconditionally and throws on empty bodies, which an endpoint
650
+ * answering e.g. `204 No Content` would trip on.
651
+ */
652
+ function parseBody(res) {
653
+ let text = res.text();
654
+ if (text) return (res.headers.get("content-type") ?? "").toLowerCase().includes("application/json") ? res.json() : text;
642
655
  }
643
656
  /**
644
657
  * Build the default get-it requester. Auth and headers are NOT applied here —
@@ -648,15 +661,13 @@ function defaultShouldRetry(err) {
648
661
  * @internal
649
662
  */
650
663
  function createGetItRequester(options) {
651
- let requester = getIt([
652
- base(options.baseUrl),
653
- jsonResponse(),
654
- jsonRequest(),
655
- httpErrors(),
656
- retry({ shouldRetry: defaultShouldRetry }),
657
- promise({ onlyBody: !0 })
658
- ]);
659
- return (opts) => requester(opts);
664
+ let requester = createRequester({
665
+ base: options.baseUrl,
666
+ headers: { Accept: "application/json" },
667
+ fetch: options.fetch,
668
+ middleware: [retry({ shouldRetry: defaultShouldRetry })]
669
+ });
670
+ return async (opts) => parseBody(await requester(opts));
660
671
  }
661
672
  const sharedConverter = new DescriptorConverter();
662
673
  /**
@@ -1708,7 +1719,8 @@ const getTypeOf = (thing) => Array.isArray(thing) ? "array" : typeof thing, quot
1708
1719
  "title",
1709
1720
  "value",
1710
1721
  "icon",
1711
- "component"
1722
+ "component",
1723
+ "i18nTitleKey"
1712
1724
  ], allowedDecoratorKeys = [
1713
1725
  "blockEditor",
1714
1726
  "title",
@@ -1720,7 +1732,8 @@ const getTypeOf = (thing) => Array.isArray(thing) ? "array" : typeof thing, quot
1720
1732
  "title",
1721
1733
  "value",
1722
1734
  "icon",
1723
- "component"
1735
+ "component",
1736
+ "i18nTitleKey"
1724
1737
  ], supportedBuiltInObjectTypes = [
1725
1738
  "file",
1726
1739
  "image",