@prismicio/types-internal 3.7.0 → 3.8.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.
Files changed (33) hide show
  1. package/lib/content/Document.d.ts +114 -42
  2. package/lib/content/fields/RepeatableContent.d.ts +45 -47
  3. package/lib/content/fields/WidgetContent.d.ts +114 -42
  4. package/lib/content/fields/nestable/LinkContent.js +4 -16
  5. package/lib/content/fields/nestable/NestableContent.d.ts +19 -7
  6. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +192 -55
  7. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +10 -10
  8. package/lib/content/fields/nestable/TableContent.d.ts +25 -9
  9. package/lib/content/fields/nestable/TableContent.js +8 -8
  10. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +38 -14
  11. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +7 -3
  12. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +38 -14
  13. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +19 -7
  14. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +19 -7
  15. package/lib/content/fields/slices/Slice/index.d.ts +65 -25
  16. package/lib/content/fields/slices/SliceItem.d.ts +65 -25
  17. package/lib/content/fields/slices/SlicesContent.d.ts +95 -35
  18. package/lib/content/utils.d.ts +4 -0
  19. package/lib/content/utils.js +16 -1
  20. package/lib/customtypes/widgets/slices/SliceWidget.d.ts +327 -0
  21. package/lib/customtypes/widgets/slices/SliceWidget.js +8 -0
  22. package/package.json +1 -1
  23. package/src/content/fields/nestable/LinkContent.ts +1 -20
  24. package/src/content/fields/nestable/TableContent.ts +37 -29
  25. package/src/content/utils.ts +20 -0
  26. package/lib/content/fields/nestable/RichTextContent/Block.d.ts +0 -1036
  27. package/lib/content/fields/nestable/RichTextContent/Block.js +0 -31
  28. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.d.ts +0 -60
  29. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.js +0 -53
  30. package/lib/content/fields/nestable/RichTextContent/ImageBlock.d.ts +0 -203
  31. package/lib/content/fields/nestable/RichTextContent/ImageBlock.js +0 -36
  32. package/lib/content/fields/nestable/RichTextContent/TableBlock.d.ts +0 -500
  33. package/lib/content/fields/nestable/RichTextContent/TableBlock.js +0 -21
@@ -432,9 +432,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
432
432
  __TYPE__: "SeparatorContent";
433
433
  } | {
434
434
  __TYPE__: "TableContent";
435
- content: {
435
+ content: ({
436
+ key: string;
437
+ } & {
436
438
  type: "tableRow";
437
439
  content: ({
440
+ key: string;
441
+ } & {
438
442
  type: "tableHeader" | "tableCell";
439
443
  content: {
440
444
  __TYPE__: "StructuredTextContent";
@@ -593,7 +597,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
593
597
  } & {
594
598
  columnWidth?: number;
595
599
  })[];
596
- }[];
600
+ })[];
597
601
  } | {
598
602
  __TYPE__: "CompositeSliceContent";
599
603
  nonRepeat: {
@@ -1020,9 +1024,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
1020
1024
  __TYPE__: "SeparatorContent";
1021
1025
  } | {
1022
1026
  __TYPE__: "TableContent";
1023
- content: {
1027
+ content: ({
1028
+ key: string;
1029
+ } & {
1024
1030
  type: "tableRow";
1025
1031
  content: ({
1032
+ key: string;
1033
+ } & {
1026
1034
  type: "tableHeader" | "tableCell";
1027
1035
  content: {
1028
1036
  __TYPE__: "StructuredTextContent";
@@ -1181,7 +1189,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
1181
1189
  } & {
1182
1190
  columnWidth?: number;
1183
1191
  })[];
1184
- }[];
1192
+ })[];
1185
1193
  };
1186
1194
  };
1187
1195
  repeat: {
@@ -1609,9 +1617,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
1609
1617
  __TYPE__: "SeparatorContent";
1610
1618
  } | {
1611
1619
  __TYPE__: "TableContent";
1612
- content: {
1620
+ content: ({
1621
+ key: string;
1622
+ } & {
1613
1623
  type: "tableRow";
1614
1624
  content: ({
1625
+ key: string;
1626
+ } & {
1615
1627
  type: "tableHeader" | "tableCell";
1616
1628
  content: {
1617
1629
  __TYPE__: "StructuredTextContent";
@@ -1770,7 +1782,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
1770
1782
  } & {
1771
1783
  columnWidth?: number;
1772
1784
  })[];
1773
- }[];
1785
+ })[];
1774
1786
  }][];
1775
1787
  }[];
1776
1788
  } | {
@@ -2200,9 +2212,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
2200
2212
  __TYPE__: "SeparatorContent";
2201
2213
  } | {
2202
2214
  __TYPE__: "TableContent";
2203
- content: {
2215
+ content: ({
2216
+ key: string;
2217
+ } & {
2204
2218
  type: "tableRow";
2205
2219
  content: ({
2220
+ key: string;
2221
+ } & {
2206
2222
  type: "tableHeader" | "tableCell";
2207
2223
  content: {
2208
2224
  __TYPE__: "StructuredTextContent";
@@ -2361,7 +2377,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
2361
2377
  } & {
2362
2378
  columnWidth?: number;
2363
2379
  })[];
2364
- }[];
2380
+ })[];
2365
2381
  };
2366
2382
  };
2367
2383
  items: {
@@ -2789,9 +2805,13 @@ export declare const isSlicesContent: (u: unknown) => u is {
2789
2805
  __TYPE__: "SeparatorContent";
2790
2806
  } | {
2791
2807
  __TYPE__: "TableContent";
2792
- content: {
2808
+ content: ({
2809
+ key: string;
2810
+ } & {
2793
2811
  type: "tableRow";
2794
2812
  content: ({
2813
+ key: string;
2814
+ } & {
2795
2815
  type: "tableHeader" | "tableCell";
2796
2816
  content: {
2797
2817
  __TYPE__: "StructuredTextContent";
@@ -2950,7 +2970,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
2950
2970
  } & {
2951
2971
  columnWidth?: number;
2952
2972
  })[];
2953
- }[];
2973
+ })[];
2954
2974
  }][];
2955
2975
  }[];
2956
2976
  };
@@ -3386,9 +3406,13 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3386
3406
  __TYPE__: "SeparatorContent";
3387
3407
  } | {
3388
3408
  __TYPE__: "TableContent";
3389
- content: {
3409
+ content: ({
3410
+ key: string;
3411
+ } & {
3390
3412
  type: "tableRow";
3391
3413
  content: ({
3414
+ key: string;
3415
+ } & {
3392
3416
  type: "tableHeader" | "tableCell";
3393
3417
  content: {
3394
3418
  __TYPE__: "StructuredTextContent";
@@ -3547,7 +3571,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3547
3571
  } & {
3548
3572
  columnWidth?: number;
3549
3573
  })[];
3550
- }[];
3574
+ })[];
3551
3575
  } | {
3552
3576
  __TYPE__: "CompositeSliceContent";
3553
3577
  nonRepeat: {
@@ -3974,9 +3998,13 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3974
3998
  __TYPE__: "SeparatorContent";
3975
3999
  } | {
3976
4000
  __TYPE__: "TableContent";
3977
- content: {
4001
+ content: ({
4002
+ key: string;
4003
+ } & {
3978
4004
  type: "tableRow";
3979
4005
  content: ({
4006
+ key: string;
4007
+ } & {
3980
4008
  type: "tableHeader" | "tableCell";
3981
4009
  content: {
3982
4010
  __TYPE__: "StructuredTextContent";
@@ -4135,7 +4163,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
4135
4163
  } & {
4136
4164
  columnWidth?: number;
4137
4165
  })[];
4138
- }[];
4166
+ })[];
4139
4167
  };
4140
4168
  };
4141
4169
  repeat: {
@@ -4563,9 +4591,13 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
4563
4591
  __TYPE__: "SeparatorContent";
4564
4592
  } | {
4565
4593
  __TYPE__: "TableContent";
4566
- content: {
4594
+ content: ({
4595
+ key: string;
4596
+ } & {
4567
4597
  type: "tableRow";
4568
4598
  content: ({
4599
+ key: string;
4600
+ } & {
4569
4601
  type: "tableHeader" | "tableCell";
4570
4602
  content: {
4571
4603
  __TYPE__: "StructuredTextContent";
@@ -4724,7 +4756,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
4724
4756
  } & {
4725
4757
  columnWidth?: number;
4726
4758
  })[];
4727
- }[];
4759
+ })[];
4728
4760
  }][];
4729
4761
  }[];
4730
4762
  } | {
@@ -5154,9 +5186,13 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
5154
5186
  __TYPE__: "SeparatorContent";
5155
5187
  } | {
5156
5188
  __TYPE__: "TableContent";
5157
- content: {
5189
+ content: ({
5190
+ key: string;
5191
+ } & {
5158
5192
  type: "tableRow";
5159
5193
  content: ({
5194
+ key: string;
5195
+ } & {
5160
5196
  type: "tableHeader" | "tableCell";
5161
5197
  content: {
5162
5198
  __TYPE__: "StructuredTextContent";
@@ -5315,7 +5351,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
5315
5351
  } & {
5316
5352
  columnWidth?: number;
5317
5353
  })[];
5318
- }[];
5354
+ })[];
5319
5355
  };
5320
5356
  };
5321
5357
  items: {
@@ -5743,9 +5779,13 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
5743
5779
  __TYPE__: "SeparatorContent";
5744
5780
  } | {
5745
5781
  __TYPE__: "TableContent";
5746
- content: {
5782
+ content: ({
5783
+ key: string;
5784
+ } & {
5747
5785
  type: "tableRow";
5748
5786
  content: ({
5787
+ key: string;
5788
+ } & {
5749
5789
  type: "tableHeader" | "tableCell";
5750
5790
  content: {
5751
5791
  __TYPE__: "StructuredTextContent";
@@ -5904,7 +5944,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
5904
5944
  } & {
5905
5945
  columnWidth?: number;
5906
5946
  })[];
5907
- }[];
5947
+ })[];
5908
5948
  }][];
5909
5949
  }[];
5910
5950
  };
@@ -6348,9 +6388,13 @@ export declare const SlicesContent: t.TypeC<{
6348
6388
  __TYPE__: t.LiteralC<"SeparatorContent">;
6349
6389
  }>>, t.ExactC<t.TypeC<{
6350
6390
  __TYPE__: t.LiteralC<"TableContent">;
6351
- content: t.ArrayC<t.ExactC<t.TypeC<{
6391
+ content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
6392
+ key: t.Type<string, string, unknown>;
6393
+ }>>, t.ExactC<t.TypeC<{
6352
6394
  type: t.LiteralC<"tableRow">;
6353
6395
  content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
6396
+ key: t.Type<string, string, unknown>;
6397
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
6354
6398
  type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
6355
6399
  content: t.ExactC<t.TypeC<{
6356
6400
  __TYPE__: t.LiteralC<"StructuredTextContent">;
@@ -6594,8 +6638,8 @@ export declare const SlicesContent: t.TypeC<{
6594
6638
  }>>;
6595
6639
  }>>, t.ExactC<t.PartialC<{
6596
6640
  columnWidth: t.NumberC;
6597
- }>>]>>;
6598
- }>>>;
6641
+ }>>]>]>>;
6642
+ }>>]>>;
6599
6643
  }>>, t.ExactC<t.TypeC<{
6600
6644
  __TYPE__: t.LiteralC<"RepeatableContent">;
6601
6645
  type: t.LiteralC<"Link">;
@@ -7110,9 +7154,13 @@ export declare const SlicesContent: t.TypeC<{
7110
7154
  __TYPE__: t.LiteralC<"SeparatorContent">;
7111
7155
  }>>, t.ExactC<t.TypeC<{
7112
7156
  __TYPE__: t.LiteralC<"TableContent">;
7113
- content: t.ArrayC<t.ExactC<t.TypeC<{
7157
+ content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
7158
+ key: t.Type<string, string, unknown>;
7159
+ }>>, t.ExactC<t.TypeC<{
7114
7160
  type: t.LiteralC<"tableRow">;
7115
7161
  content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
7162
+ key: t.Type<string, string, unknown>;
7163
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
7116
7164
  type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
7117
7165
  content: t.ExactC<t.TypeC<{
7118
7166
  __TYPE__: t.LiteralC<"StructuredTextContent">;
@@ -7356,8 +7404,8 @@ export declare const SlicesContent: t.TypeC<{
7356
7404
  }>>;
7357
7405
  }>>, t.ExactC<t.PartialC<{
7358
7406
  columnWidth: t.NumberC;
7359
- }>>]>>;
7360
- }>>>;
7407
+ }>>]>]>>;
7408
+ }>>]>>;
7361
7409
  }>>, t.ExactC<t.TypeC<{
7362
7410
  __TYPE__: t.LiteralC<"RepeatableContent">;
7363
7411
  type: t.LiteralC<"Link">;
@@ -7874,9 +7922,13 @@ export declare const SlicesContent: t.TypeC<{
7874
7922
  __TYPE__: t.LiteralC<"SeparatorContent">;
7875
7923
  }>>, t.ExactC<t.TypeC<{
7876
7924
  __TYPE__: t.LiteralC<"TableContent">;
7877
- content: t.ArrayC<t.ExactC<t.TypeC<{
7925
+ content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
7926
+ key: t.Type<string, string, unknown>;
7927
+ }>>, t.ExactC<t.TypeC<{
7878
7928
  type: t.LiteralC<"tableRow">;
7879
7929
  content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
7930
+ key: t.Type<string, string, unknown>;
7931
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
7880
7932
  type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
7881
7933
  content: t.ExactC<t.TypeC<{
7882
7934
  __TYPE__: t.LiteralC<"StructuredTextContent">;
@@ -8120,8 +8172,8 @@ export declare const SlicesContent: t.TypeC<{
8120
8172
  }>>;
8121
8173
  }>>, t.ExactC<t.PartialC<{
8122
8174
  columnWidth: t.NumberC;
8123
- }>>]>>;
8124
- }>>>;
8175
+ }>>]>]>>;
8176
+ }>>]>>;
8125
8177
  }>>, t.ExactC<t.TypeC<{
8126
8178
  __TYPE__: t.LiteralC<"RepeatableContent">;
8127
8179
  type: t.LiteralC<"Link">;
@@ -8636,9 +8688,13 @@ export declare const SlicesContent: t.TypeC<{
8636
8688
  __TYPE__: t.LiteralC<"SeparatorContent">;
8637
8689
  }>>, t.ExactC<t.TypeC<{
8638
8690
  __TYPE__: t.LiteralC<"TableContent">;
8639
- content: t.ArrayC<t.ExactC<t.TypeC<{
8691
+ content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
8692
+ key: t.Type<string, string, unknown>;
8693
+ }>>, t.ExactC<t.TypeC<{
8640
8694
  type: t.LiteralC<"tableRow">;
8641
8695
  content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
8696
+ key: t.Type<string, string, unknown>;
8697
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
8642
8698
  type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
8643
8699
  content: t.ExactC<t.TypeC<{
8644
8700
  __TYPE__: t.LiteralC<"StructuredTextContent">;
@@ -8882,8 +8938,8 @@ export declare const SlicesContent: t.TypeC<{
8882
8938
  }>>;
8883
8939
  }>>, t.ExactC<t.PartialC<{
8884
8940
  columnWidth: t.NumberC;
8885
- }>>]>>;
8886
- }>>>;
8941
+ }>>]>]>>;
8942
+ }>>]>>;
8887
8943
  }>>, t.ExactC<t.TypeC<{
8888
8944
  __TYPE__: t.LiteralC<"RepeatableContent">;
8889
8945
  type: t.LiteralC<"Link">;
@@ -9397,9 +9453,13 @@ export declare const SlicesContent: t.TypeC<{
9397
9453
  __TYPE__: t.LiteralC<"SeparatorContent">;
9398
9454
  }>>, t.ExactC<t.TypeC<{
9399
9455
  __TYPE__: t.LiteralC<"TableContent">;
9400
- content: t.ArrayC<t.ExactC<t.TypeC<{
9456
+ content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
9457
+ key: t.Type<string, string, unknown>;
9458
+ }>>, t.ExactC<t.TypeC<{
9401
9459
  type: t.LiteralC<"tableRow">;
9402
9460
  content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
9461
+ key: t.Type<string, string, unknown>;
9462
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
9403
9463
  type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
9404
9464
  content: t.ExactC<t.TypeC<{
9405
9465
  __TYPE__: t.LiteralC<"StructuredTextContent">;
@@ -9643,8 +9703,8 @@ export declare const SlicesContent: t.TypeC<{
9643
9703
  }>>;
9644
9704
  }>>, t.ExactC<t.PartialC<{
9645
9705
  columnWidth: t.NumberC;
9646
- }>>]>>;
9647
- }>>>;
9706
+ }>>]>]>>;
9707
+ }>>]>>;
9648
9708
  }>>, t.ExactC<t.TypeC<{
9649
9709
  __TYPE__: t.LiteralC<"RepeatableContent">;
9650
9710
  type: t.LiteralC<"Link">;
@@ -1,3 +1,4 @@
1
+ import * as t from "io-ts";
1
2
  import { FieldType } from "./fields";
2
3
  declare type WithFieldType = WithContentType & {
3
4
  type: FieldType;
@@ -7,4 +8,7 @@ declare type WithContentType = {
7
8
  __TYPE__: string;
8
9
  };
9
10
  export declare function hasContentType(obj: unknown): obj is WithContentType;
11
+ export declare function withKey<C extends t.Mixed>(codec: C): t.IntersectionC<[t.ExactC<t.TypeC<{
12
+ key: t.Type<string, string, unknown>;
13
+ }>>, C]>;
10
14
  export {};
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasContentType = exports.hasFieldContentType = void 0;
3
+ exports.withKey = exports.hasContentType = exports.hasFieldContentType = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const Either_1 = require("fp-ts/lib/Either");
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ const uuid_1 = require("uuid");
5
8
  const fields_1 = require("./fields");
6
9
  function hasFieldContentType(obj) {
7
10
  var _a;
@@ -16,3 +19,15 @@ function hasContentType(obj) {
16
19
  return typeof obj === "object" && obj !== null && "__TYPE__" in obj;
17
20
  }
18
21
  exports.hasContentType = hasContentType;
22
+ const isUuid = (input) => typeof input === "string" && (0, uuid_1.validate)(input);
23
+ const uuidWithFallback = new t.Type("UUID", isUuid, (u, c) => {
24
+ if (typeof u === "undefined")
25
+ return t.success((0, uuid_1.v4)());
26
+ if (isUuid(u))
27
+ return t.success(u);
28
+ return t.failure(u, c);
29
+ }, t.identity);
30
+ function withKey(codec) {
31
+ return t.intersection([t.strict({ key: uuidWithFallback }), codec]);
32
+ }
33
+ exports.withKey = withKey;