@prismicio/types-internal 0.3.1-beta.0 → 0.3.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.
@@ -9,7 +9,7 @@ declare const Group: t.ExactC<t.IntersectionC<[t.TypeC<{
9
9
  config: t.ExactC<t.PartialC<{
10
10
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
11
11
  repeat: t.BooleanC;
12
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
12
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
13
13
  type: t.LiteralC<WidgetTypes.Color>;
14
14
  }>, t.PartialC<{
15
15
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const widgets_1 = require("../../documents/widgets");
5
6
  const validators_1 = require("../../validators");
6
7
  const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget"));
7
8
  const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
8
9
  const GroupConfig = t.exact(t.partial({
9
10
  label: validators_1.StringOrNull,
10
11
  repeat: t.boolean,
11
- fields: t.record(t.string, NestableWidget_1.default),
12
+ fields: t.record(widgets_1.WidgetKey, NestableWidget_1.default),
12
13
  }));
13
14
  const Group = t.exact(t.intersection([
14
15
  t.type({
@@ -176,7 +176,7 @@ export declare function widgetReader<T extends StaticSlices | DynamicSlices>(cod
176
176
  config: t.ExactC<t.PartialC<{
177
177
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
178
178
  repeat: t.BooleanC;
179
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
179
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
180
180
  type: t.LiteralC<WidgetTypes.Color>;
181
181
  }>, t.PartialC<{
182
182
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -509,7 +509,7 @@ export declare const StaticWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
509
509
  config: t.ExactC<t.PartialC<{
510
510
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
511
511
  repeat: t.BooleanC;
512
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
512
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
513
513
  type: t.LiteralC<WidgetTypes.Color>;
514
514
  }>, t.PartialC<{
515
515
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1847,7 +1847,7 @@ export declare const DynamicWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<
1847
1847
  config: t.ExactC<t.PartialC<{
1848
1848
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1849
1849
  repeat: t.BooleanC;
1850
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1850
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1851
1851
  type: t.LiteralC<WidgetTypes.Color>;
1852
1852
  }>, t.PartialC<{
1853
1853
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -164,7 +164,7 @@ declare const LegacySlice: t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC
164
164
  config: t.ExactC<t.PartialC<{
165
165
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
166
166
  repeat: t.BooleanC;
167
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
167
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
168
168
  type: t.LiteralC<import("../WidgetTypes").default.Color>;
169
169
  }>, t.PartialC<{
170
170
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -16,7 +16,7 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
16
16
  }>, t.PartialC<{
17
17
  display: t.StringC;
18
18
  }>]>>>>, t.NullC]>;
19
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
19
+ choices: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
20
20
  type: t.LiteralC<WidgetTypes.Color>;
21
21
  }>, t.PartialC<{
22
22
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -181,7 +181,7 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
181
181
  config: t.ExactC<t.PartialC<{
182
182
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
183
183
  repeat: t.BooleanC;
184
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
184
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
185
185
  type: t.LiteralC<WidgetTypes.Color>;
186
186
  }>, t.PartialC<{
187
187
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -672,7 +672,7 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
672
672
  }>, t.PartialC<{
673
673
  display: t.StringC;
674
674
  }>]>>>>, t.NullC]>;
675
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
675
+ choices: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
676
676
  type: t.LiteralC<WidgetTypes.Color>;
677
677
  }>, t.PartialC<{
678
678
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -837,7 +837,7 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
837
837
  config: t.ExactC<t.PartialC<{
838
838
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
839
839
  repeat: t.BooleanC;
840
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
840
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
841
841
  type: t.LiteralC<WidgetTypes.Color>;
842
842
  }>, t.PartialC<{
843
843
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1663,7 +1663,7 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
1663
1663
  }>, t.PartialC<{
1664
1664
  display: t.StringC;
1665
1665
  }>]>>>>, t.NullC]>;
1666
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1666
+ choices: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1667
1667
  type: t.LiteralC<WidgetTypes.Color>;
1668
1668
  }>, t.PartialC<{
1669
1669
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1828,7 +1828,7 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
1828
1828
  config: t.ExactC<t.PartialC<{
1829
1829
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1830
1830
  repeat: t.BooleanC;
1831
- fields: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1831
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1832
1832
  type: t.LiteralC<WidgetTypes.Color>;
1833
1833
  }>, t.PartialC<{
1834
1834
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = exports.SlicesLabels = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const widgets_1 = require("../../../documents/widgets");
6
7
  const validators_1 = require("../../../validators");
7
8
  const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
8
9
  const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
@@ -25,7 +26,7 @@ function slicesConfigReader(codec) {
25
26
  return t.exact(t.partial({
26
27
  label: validators_1.StringOrNull,
27
28
  labels: exports.SlicesLabels,
28
- choices: t.record(t.string, t.union([LegacySlice_1.default, CompositeSlice_1.default, codec])),
29
+ choices: t.record(widgets_1.WidgetKey, t.union([LegacySlice_1.default, CompositeSlice_1.default, codec])),
29
30
  }));
30
31
  }
31
32
  exports.slicesConfigReader = slicesConfigReader;
@@ -25,7 +25,7 @@ exports.WidgetTypes = {
25
25
  Group: GroupContent_1.GroupContentType,
26
26
  slices: slices_1.SlicesContentType,
27
27
  };
28
- const widgetKeyRegex = new RegExp("^[^<>]+$");
28
+ const widgetKeyRegex = new RegExp("^[^<>]*$");
29
29
  exports.WidgetKey = (0, function_1.refineType)(t.string, "WidgetKey", (s) => widgetKeyRegex.test(s));
30
30
  exports.Widget = {
31
31
  fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
@@ -1,5 +1,4 @@
1
1
  import * as O from "fp-ts/Option";
2
- import * as t from "io-ts";
3
2
  import { SliceWidgetContent } from "./SliceWidgetContent";
4
3
  export declare type SlicesContentItem = {
5
4
  key: string;
@@ -12,8 +11,6 @@ export declare type SlicesContent = {
12
11
  __TYPE__: typeof SlicesContentType;
13
12
  value: SlicesContentItem[];
14
13
  };
15
- export declare const SliceKey: t.Type<string, string, unknown>;
16
- export declare type SliceKey = t.TypeOf<typeof SliceKey>;
17
14
  export declare const SlicesContent: {
18
15
  itemsCodec: (value: unknown, codecWidget: (n: string, v: unknown) => O.Option<SliceWidgetContent>) => O.Option<SlicesContentItem>;
19
16
  fromJson: (key: string, value: unknown, fieldTypes: Map<string, string>, fieldPositions: Map<string, number>) => O.Option<SlicesContent>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlicesContent = exports.SliceKey = exports.SlicesContentType = void 0;
3
+ exports.SlicesContent = exports.SlicesContentType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const A = (0, tslib_1.__importStar)(require("fp-ts/Array"));
6
6
  const function_1 = require("fp-ts/function");
@@ -9,11 +9,9 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));
9
9
  const function_2 = require("../../../validators/function");
10
10
  const SliceWidgetContent_1 = require("./SliceWidgetContent");
11
11
  exports.SlicesContentType = "SliceContentType";
12
- const sliceKeyRegex = new RegExp("^[-_\\w]+\\$[-\\w]+$");
13
- exports.SliceKey = (0, function_2.refineType)(t.string, "SliceKey", (s) => sliceKeyRegex.test(s));
14
12
  const codec = t.exact(t.intersection([
15
13
  t.type({
16
- key: exports.SliceKey,
14
+ key: t.string,
17
15
  value: t.unknown,
18
16
  }),
19
17
  t.partial({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "0.3.1-beta.0",
3
+ "version": "0.3.2",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -1,5 +1,6 @@
1
1
  import * as t from "io-ts"
2
2
 
3
+ import { WidgetKey } from "../../documents/widgets"
3
4
  import { StringOrNull } from "../../validators"
4
5
  import NestableWidget from "./nestable/NestableWidget"
5
6
  import WidgetTypes from "./WidgetTypes"
@@ -8,7 +9,7 @@ const GroupConfig = t.exact(
8
9
  t.partial({
9
10
  label: StringOrNull,
10
11
  repeat: t.boolean,
11
- fields: t.record(t.string, NestableWidget),
12
+ fields: t.record(WidgetKey, NestableWidget),
12
13
  }),
13
14
  )
14
15
  type GroupConfig = t.TypeOf<typeof GroupConfig>
@@ -1,5 +1,6 @@
1
1
  import * as t from "io-ts"
2
2
 
3
+ import { WidgetKey } from "../../../documents/widgets"
3
4
  import { StringOrNull } from "../../../validators"
4
5
  import WidgetTypes from "../WidgetTypes"
5
6
  import CompositeSlice from "./CompositeSlice"
@@ -36,7 +37,7 @@ export function slicesConfigReader<T extends SharedSlice | SharedSliceRef>(
36
37
  label: StringOrNull,
37
38
  labels: SlicesLabels,
38
39
  choices: t.record(
39
- t.string,
40
+ WidgetKey,
40
41
  t.union([LegacySlice, CompositeSlice, codec]),
41
42
  ),
42
43
  }),
@@ -27,7 +27,7 @@ export const WidgetTypes = {
27
27
  slices: SlicesContentType,
28
28
  } as const
29
29
 
30
- const widgetKeyRegex = new RegExp("^[^<>]+$")
30
+ const widgetKeyRegex = new RegExp("^[^<>]*$")
31
31
  export const WidgetKey = refineType(t.string, "WidgetKey", (s: string) =>
32
32
  widgetKeyRegex.test(s),
33
33
  )
@@ -3,7 +3,7 @@ import { pipe } from "fp-ts/function"
3
3
  import * as O from "fp-ts/Option"
4
4
  import * as t from "io-ts"
5
5
 
6
- import { nullable, refineType } from "../../../validators/function"
6
+ import { nullable } from "../../../validators/function"
7
7
  import { SliceWidgetContent } from "./SliceWidgetContent"
8
8
 
9
9
  export type SlicesContentItem = {
@@ -18,17 +18,10 @@ export type SlicesContent = {
18
18
  __TYPE__: typeof SlicesContentType
19
19
  value: SlicesContentItem[]
20
20
  }
21
-
22
- const sliceKeyRegex = new RegExp("^[-_\\w]+\\$[-\\w]+$")
23
- export const SliceKey = refineType(t.string, "SliceKey", (s: string) =>
24
- sliceKeyRegex.test(s),
25
- )
26
- export type SliceKey = t.TypeOf<typeof SliceKey>
27
-
28
21
  const codec = t.exact(
29
22
  t.intersection([
30
23
  t.type({
31
- key: SliceKey,
24
+ key: t.string,
32
25
  value: t.unknown,
33
26
  }),
34
27
  t.partial({