@sanity/types 5.21.1-next.9 → 5.22.0-next.16

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.
Files changed (2) hide show
  1. package/lib/index.d.ts +66 -65
  2. package/package.json +5 -5
package/lib/index.d.ts CHANGED
@@ -943,6 +943,68 @@ interface ArrayDefinition extends BaseSchemaDefinition {
943
943
  validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>;
944
944
  options?: ArrayOptions;
945
945
  }
946
+ /** @public */
947
+ type PortableTextBlock = PortableTextTextBlock | PortableTextObject;
948
+ /** @public */
949
+ interface PortableTextTextBlock<TChild = PortableTextSpan | PortableTextObject> {
950
+ _type: string;
951
+ _key: string;
952
+ children: TChild[];
953
+ markDefs?: PortableTextObject[];
954
+ listItem?: string;
955
+ style?: string;
956
+ level?: number;
957
+ }
958
+ /** @public */
959
+ interface PortableTextObject {
960
+ _type: string;
961
+ _key: string;
962
+ [other: string]: unknown;
963
+ }
964
+ /** @public */
965
+ interface PortableTextSpan {
966
+ _key: string;
967
+ _type: 'span';
968
+ text: string;
969
+ marks?: string[];
970
+ }
971
+ /** @public */
972
+ type PortableTextChild = PortableTextObject | PortableTextSpan;
973
+ /** @public */
974
+ interface PortableTextListBlock extends PortableTextTextBlock {
975
+ listItem: string;
976
+ level: number;
977
+ }
978
+ /**
979
+ * Assert that a given object is a portable-text text-block type object
980
+ *
981
+ * @remarks
982
+ * * The `markDefs` and `style` property of a block is optional.
983
+ * * Block types can be named, so expect anything of the _type property.
984
+ *
985
+ * @alpha
986
+ */
987
+ declare function isPortableTextTextBlock<T = PortableTextSpan | PortableTextObject>(value: unknown): value is PortableTextTextBlock<T>;
988
+ /**
989
+ * Assert that a given object is a portable-text span-type object
990
+ *
991
+ * @remarks
992
+ * The `marks` property of a block is optional.
993
+ *
994
+ * @alpha
995
+ */
996
+ declare function isPortableTextSpan(value: unknown): value is PortableTextSpan;
997
+ /**
998
+ * Assert that a given object is a portable-text list-text-block-type object
999
+ *
1000
+ * @remarks
1001
+ * Uses `isPortableTextTextBlock` and checks for `listItem` and `level`
1002
+ *
1003
+ * @see isPortableTextTextBlock
1004
+ *
1005
+ * @alpha
1006
+ */
1007
+ declare function isPortableTextListBlock<T = PortableTextSpan | PortableTextObject>(value: unknown): value is PortableTextTextBlock<T>;
946
1008
  /**
947
1009
  * Schema options for a Block schema definition
948
1010
  * @public */
@@ -964,7 +1026,7 @@ interface BlockOptions extends BaseSchemaTypeOptions {
964
1026
  oneLine?: boolean;
965
1027
  }
966
1028
  /** @public */
967
- interface BlockRule extends RuleDef<BlockRule, any[]> {}
1029
+ interface BlockRule extends RuleDef<BlockRule, PortableTextBlock> {}
968
1030
  /**
969
1031
  * Schema definition for text block decorators.
970
1032
  *
@@ -1188,9 +1250,10 @@ interface BlockDefinition extends BaseSchemaDefinition {
1188
1250
  lists?: BlockListDefinition[];
1189
1251
  marks?: BlockMarksDefinition;
1190
1252
  of?: ArrayOfType<'object' | 'reference'>[];
1191
- initialValue?: InitialValueProperty<any, any[]>;
1253
+ /** Block types do not support initialValue - the runtime schema validation rejects it. */
1254
+ initialValue?: never;
1192
1255
  options?: BlockOptions;
1193
- validation?: ValidationBuilder<BlockRule, any[]>;
1256
+ validation?: ValidationBuilder<BlockRule, PortableTextBlock>;
1194
1257
  }
1195
1258
  /** @public */
1196
1259
  interface BooleanOptions extends BaseSchemaTypeOptions {
@@ -3326,68 +3389,6 @@ declare function isCreateOrReplaceMutation(mutation: Mutation | TransactionLogMu
3326
3389
  declare function isDeleteMutation(mutation: Mutation | TransactionLogMutation): mutation is DeleteMutation;
3327
3390
  /** @internal */
3328
3391
  declare function isPatchMutation(mutation: Mutation | TransactionLogMutation): mutation is PatchMutation;
3329
- /** @alpha */
3330
- type PortableTextBlock = PortableTextTextBlock | PortableTextObject;
3331
- /** @alpha */
3332
- interface PortableTextTextBlock<TChild = PortableTextSpan | PortableTextObject> {
3333
- _type: string;
3334
- _key: string;
3335
- children: TChild[];
3336
- markDefs?: PortableTextObject[];
3337
- listItem?: string;
3338
- style?: string;
3339
- level?: number;
3340
- }
3341
- /** @alpha */
3342
- interface PortableTextObject {
3343
- _type: string;
3344
- _key: string;
3345
- [other: string]: unknown;
3346
- }
3347
- /** @alpha */
3348
- interface PortableTextSpan {
3349
- _key: string;
3350
- _type: 'span';
3351
- text: string;
3352
- marks?: string[];
3353
- }
3354
- /** @alpha */
3355
- type PortableTextChild = PortableTextObject | PortableTextSpan;
3356
- /** @alpha */
3357
- interface PortableTextListBlock extends PortableTextTextBlock {
3358
- listItem: string;
3359
- level: number;
3360
- }
3361
- /**
3362
- * Assert that a given object is a portable-text text-block type object
3363
- *
3364
- * @remarks
3365
- * * The `markDefs` and `style` property of a block is optional.
3366
- * * Block types can be named, so expect anything of the _type property.
3367
- *
3368
- * @alpha
3369
- */
3370
- declare function isPortableTextTextBlock<T = PortableTextSpan | PortableTextObject>(value: unknown): value is PortableTextTextBlock<T>;
3371
- /**
3372
- * Assert that a given object is a portable-text span-type object
3373
- *
3374
- * @remarks
3375
- * The `marks` property of a block is optional.
3376
- *
3377
- * @alpha
3378
- */
3379
- declare function isPortableTextSpan(value: unknown): value is PortableTextSpan;
3380
- /**
3381
- * Assert that a given object is a portable-text list-text-block-type object
3382
- *
3383
- * @remarks
3384
- * Uses `isPortableTextTextBlock` and checks for `listItem` and `level`
3385
- *
3386
- * @see isPortableTextTextBlock
3387
- *
3388
- * @alpha
3389
- */
3390
- declare function isPortableTextListBlock<T = PortableTextSpan | PortableTextObject>(value: unknown): value is PortableTextTextBlock<T>;
3391
3392
  /**
3392
3393
  * @internal
3393
3394
  * Payload that will be passed by the comments backend to our notifications system to display the notification in dashboard.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/types",
3
- "version": "5.21.1-next.9+047297dd60",
3
+ "version": "5.22.0-next.16+41c0f27133",
4
4
  "description": "Type definitions for common Sanity data structures",
5
5
  "keywords": [
6
6
  "cms",
@@ -47,10 +47,10 @@
47
47
  "react": "^19.2.4",
48
48
  "rimraf": "^6.1.3",
49
49
  "vitest": "^4.1.4",
50
- "@repo/eslint-config": "5.21.1-next.9+047297dd60",
51
- "@repo/test-config": "5.21.1-next.9+047297dd60",
52
- "@repo/package.config": "5.21.1-next.9+047297dd60",
53
- "@repo/tsconfig": "5.21.1-next.9+047297dd60"
50
+ "@repo/eslint-config": "5.22.0-next.16+41c0f27133",
51
+ "@repo/package.config": "5.22.0-next.16+41c0f27133",
52
+ "@repo/test-config": "5.22.0-next.16+41c0f27133",
53
+ "@repo/tsconfig": "5.22.0-next.16+41c0f27133"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@types/react": "^19.2"