@sanity/schema 6.19.0-next.13 → 6.19.0-next.25

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.
@@ -387,17 +387,17 @@ export declare const builtinTypes: ({
387
387
  type: string;
388
388
  title: string;
389
389
  readOnly: boolean;
390
- fieldset?: undefined;
391
390
  validation?: undefined;
392
391
  hidden?: undefined;
392
+ fieldset?: undefined;
393
393
  } | {
394
394
  name: string;
395
395
  type: string;
396
396
  title: string;
397
- fieldset?: undefined;
398
- readOnly?: undefined;
399
397
  validation?: undefined;
400
398
  hidden?: undefined;
399
+ readOnly?: undefined;
400
+ fieldset?: undefined;
401
401
  } | {
402
402
  name: string;
403
403
  type: string;
@@ -412,8 +412,8 @@ export declare const builtinTypes: ({
412
412
  readOnly: boolean;
413
413
  hidden: boolean;
414
414
  fieldset: string;
415
- title?: undefined;
416
415
  validation?: undefined;
416
+ title?: undefined;
417
417
  } | {
418
418
  name: string;
419
419
  type: string;
@@ -466,17 +466,17 @@ export declare const builtinTypes: ({
466
466
  type: string;
467
467
  title: string;
468
468
  readOnly: boolean;
469
- fieldset?: undefined;
470
469
  validation?: undefined;
471
470
  hidden?: undefined;
471
+ fieldset?: undefined;
472
472
  } | {
473
473
  name: string;
474
474
  type: string;
475
475
  title: string;
476
- fieldset?: undefined;
477
- readOnly?: undefined;
478
476
  validation?: undefined;
479
477
  hidden?: undefined;
478
+ readOnly?: undefined;
479
+ fieldset?: undefined;
480
480
  } | {
481
481
  name: string;
482
482
  type: string;
@@ -486,21 +486,21 @@ export declare const builtinTypes: ({
486
486
  validation: (Rule: import("@sanity/types").Rule) => import("@sanity/types").Rule;
487
487
  hidden?: undefined;
488
488
  } | {
489
+ validation?: undefined;
489
490
  name: string;
490
491
  type: string;
491
492
  readOnly: boolean;
492
493
  hidden: boolean;
493
494
  fieldset: string;
494
495
  title?: undefined;
495
- validation?: undefined;
496
496
  } | {
497
+ validation?: undefined;
498
+ hidden?: undefined;
497
499
  name: string;
498
500
  type: string;
499
501
  title: string;
500
502
  readOnly: boolean;
501
503
  fieldset: string;
502
- validation?: undefined;
503
- hidden?: undefined;
504
504
  })[];
505
505
  preview: {
506
506
  select: {
@@ -550,17 +550,17 @@ export declare const builtinTypes: ({
550
550
  };
551
551
  }[];
552
552
  fields: ({
553
- name: string;
554
- type: string;
555
- fieldset?: undefined;
556
553
  title?: undefined;
557
554
  readOnly?: undefined;
555
+ fieldset?: undefined;
556
+ name: string;
557
+ type: string;
558
558
  } | {
559
+ readOnly?: undefined;
559
560
  name: string;
560
561
  title: string;
561
562
  type: string;
562
563
  fieldset: string;
563
- readOnly?: undefined;
564
564
  } | {
565
565
  fieldset?: undefined;
566
566
  name: string;
package/lib/_internal.js CHANGED
@@ -1811,11 +1811,8 @@ function validateAnnotations(annotations, visitorContext, problems) {
1811
1811
  });
1812
1812
  }
1813
1813
  function validateMembers(members, visitorContext, problems) {
1814
- if (!Array.isArray(members)) {
1815
- problems.push(error(`"of" declaration should be an array, got ${getTypeOf(members)}`));
1816
- return;
1817
- }
1818
- return members.map((member) => {
1814
+ if (!Array.isArray(members)) problems.push(error(`"of" declaration should be an array, got ${getTypeOf(members)}`));
1815
+ else return members.map((member) => {
1819
1816
  let { _problems } = visitorContext.visit(member, visitorContext);
1820
1817
  if (member.type === "object" && member.name && visitorContext.getType(member.name)) return {
1821
1818
  ...member,
@@ -2156,12 +2153,11 @@ function coerceType(obj) {
2156
2153
  }
2157
2154
  function traverse(obj) {
2158
2155
  if (isObject(obj)) {
2159
- if (Array.isArray(obj)) {
2160
- obj.forEach(traverse);
2161
- return;
2156
+ if (Array.isArray(obj)) obj.forEach(traverse);
2157
+ else {
2158
+ for (let v of Object.values(obj)) traverse(v);
2159
+ coerceValidation(obj);
2162
2160
  }
2163
- for (let v of Object.values(obj)) traverse(v);
2164
- coerceValidation(obj);
2165
2161
  }
2166
2162
  }
2167
2163
  function coerceValidation(val) {
@@ -2539,15 +2535,12 @@ function parseWorkspaceSchemaId(id, errors) {
2539
2535
  return;
2540
2536
  }
2541
2537
  let [, workspace] = trimmedId.match(taggedIdPattern) ?? trimmedId.match(baseIdPattern) ?? [];
2542
- if (!workspace) {
2543
- errors.push([
2544
- `id must either match ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName> `,
2545
- `or ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName>.tag.<tag> but found: "${trimmedId}". `,
2546
- `Note that workspace name characters not in [${validForNamesChars}] has to be replaced with _ for schema id.`
2547
- ].join(""));
2548
- return;
2549
- }
2550
- return {
2538
+ if (!workspace) errors.push([
2539
+ `id must either match ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName> `,
2540
+ `or ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName>.tag.<tag> but found: "${trimmedId}". `,
2541
+ `Note that workspace name characters not in [${validForNamesChars}] has to be replaced with _ for schema id.`
2542
+ ].join(""));
2543
+ else return {
2551
2544
  schemaId: trimmedId,
2552
2545
  workspace
2553
2546
  };
@@ -2612,21 +2605,11 @@ function extractSchema(schemaDef, extractOptions = {}) {
2612
2605
  let inlineFields = /* @__PURE__ */ new Set(), documentTypes = /* @__PURE__ */ new Map(), schema = [], hoistedRefMap = /* @__PURE__ */ new Map(), { sortedSchemaTypeNames, repeated } = sortByDependencies(schemaDef);
2613
2606
  repeated.forEach((key, objectField) => {
2614
2607
  let base = convertSchemaType(objectField.type);
2615
- if (base !== null) {
2616
- if (base.type === "inline") {
2617
- repeated.delete(objectField);
2618
- return;
2619
- }
2620
- if (base.type === "unknown") {
2621
- repeated.delete(objectField);
2622
- return;
2623
- }
2624
- schema.push({
2625
- type: "type",
2626
- name: key,
2627
- value: base
2628
- });
2629
- }
2608
+ base !== null && (base.type === "inline" || base.type === "unknown" ? repeated.delete(objectField) : schema.push({
2609
+ type: "type",
2610
+ name: key,
2611
+ value: base
2612
+ }));
2630
2613
  }), sortedSchemaTypeNames.forEach((typeName) => {
2631
2614
  let schemaType = schemaDef.get(typeName);
2632
2615
  if (schemaType === void 0) return;
@@ -2992,7 +2975,7 @@ function validateComponents(typeDef) {
2992
2975
  }
2993
2976
  function validateOptions(typeDef) {
2994
2977
  let problems = [];
2995
- return !typeDef.options || typeof typeDef.options != "object" ? problems : (problems.push(...validateCommonOptions(typeDef.options)), problems.push(...validateAssetSources(typeDef.options)), problems.push(...validateOtherFunctionOptions(typeDef.options)), problems);
2978
+ return !typeDef.options || typeof typeDef.options != "object" || (problems.push(...validateCommonOptions(typeDef.options)), problems.push(...validateAssetSources(typeDef.options)), problems.push(...validateOtherFunctionOptions(typeDef.options))), problems;
2996
2979
  }
2997
2980
  function validateCommonOptions(options) {
2998
2981
  let problems = [];
@@ -3041,7 +3024,7 @@ function validateGroups(groups) {
3041
3024
  }
3042
3025
  function validateBlockSpecific(typeDef) {
3043
3026
  let problems = [];
3044
- return typeDef.type === "block" ? (problems.push(...validateBlockStyles(typeDef.styles)), problems.push(...validateBlockMarks(typeDef.marks)), problems) : problems;
3027
+ return typeDef.type === "block" && (problems.push(...validateBlockStyles(typeDef.styles)), problems.push(...validateBlockMarks(typeDef.marks))), problems;
3045
3028
  }
3046
3029
  function validateBlockStyles(styles) {
3047
3030
  let problems = [];