@prismicio/types-internal 2.1.0-alpha.2 → 2.1.0-alpha.4

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 (39) hide show
  1. package/lib/content/Document.d.ts +1 -1
  2. package/lib/content/Document.js +1 -6
  3. package/lib/customtypes/CustomType.d.ts +1046 -1180
  4. package/lib/customtypes/CustomType.js +13 -74
  5. package/lib/customtypes/Section.d.ts +1047 -1171
  6. package/lib/customtypes/Section.js +23 -1
  7. package/lib/customtypes/_internal/utils.d.ts +3 -0
  8. package/lib/customtypes/_internal/utils.js +20 -0
  9. package/lib/customtypes/diff/SharedSlice.d.ts +184 -220
  10. package/lib/customtypes/diff/Variation.d.ts +183 -219
  11. package/lib/customtypes/widgets/Group.d.ts +6 -40
  12. package/lib/customtypes/widgets/Group.js +20 -1
  13. package/lib/customtypes/widgets/Widget.d.ts +778 -976
  14. package/lib/customtypes/widgets/nestable/Link/ContentRelationshipResolver.d.ts +4 -22
  15. package/lib/customtypes/widgets/nestable/Link/ContentRelationshipResolver.js +5 -34
  16. package/lib/customtypes/widgets/nestable/Link/index.d.ts +4 -40
  17. package/lib/customtypes/widgets/nestable/Link/index.js +1 -1
  18. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +2 -20
  19. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +6 -40
  20. package/lib/customtypes/widgets/slices/CompositeSlice.js +26 -1
  21. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +4 -40
  22. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +10 -80
  23. package/lib/customtypes/widgets/slices/SharedSlice.js +35 -1
  24. package/lib/customtypes/widgets/slices/Slices.d.ts +924 -1246
  25. package/lib/customtypes/widgets/slices/Slices.js +34 -1
  26. package/lib/validators/StringOrT.d.ts +3 -0
  27. package/lib/validators/StringOrT.js +15 -0
  28. package/package.json +1 -1
  29. package/src/content/Document.ts +2 -6
  30. package/src/customtypes/CustomType.ts +24 -97
  31. package/src/customtypes/Section.ts +28 -1
  32. package/src/customtypes/_internal/utils.ts +25 -0
  33. package/src/customtypes/widgets/Group.ts +24 -0
  34. package/src/customtypes/widgets/nestable/Link/ContentRelationshipResolver.ts +5 -54
  35. package/src/customtypes/widgets/nestable/Link/index.ts +2 -2
  36. package/src/customtypes/widgets/slices/CompositeSlice.ts +33 -0
  37. package/src/customtypes/widgets/slices/SharedSlice.ts +47 -0
  38. package/src/customtypes/widgets/slices/Slices.ts +44 -1
  39. package/src/validators/StringOrT.ts +21 -0
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Group = exports.GroupConfig = exports.GroupFieldType = void 0;
3
+ exports.traverseGroup = exports.Group = exports.GroupConfig = exports.GroupFieldType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = (0, tslib_1.__importStar)(require("io-ts"));
6
6
  const common_1 = require("../../common");
7
7
  const validators_1 = require("../../validators");
8
+ const utils_1 = require("../_internal/utils");
8
9
  const NestableWidget_1 = require("./nestable/NestableWidget");
9
10
  exports.GroupFieldType = "Group";
10
11
  exports.GroupConfig = t.exact(t.partial({
@@ -23,3 +24,21 @@ exports.Group = t.exact(t.intersection([
23
24
  config: exports.GroupConfig,
24
25
  }),
25
26
  ]));
27
+ function traverseGroup(path, group, f) {
28
+ var _a;
29
+ const entries = ((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields) &&
30
+ Object.entries(group.config.fields).map(([widgetKey, widgetValue]) => {
31
+ return [widgetKey, f(widgetValue, widgetKey, path.concat(widgetKey))];
32
+ });
33
+ const config = group.config && {
34
+ ...group.config,
35
+ ...(group.config.fields && entries
36
+ ? { fields: (0, utils_1.fromEntriesWithValue)(entries) }
37
+ : {}),
38
+ };
39
+ return {
40
+ ...group,
41
+ ...(config ? { config } : {}),
42
+ };
43
+ }
44
+ exports.traverseGroup = traverseGroup;