@prismicio/types-internal 4.1.0 → 4.2.0-canary.09939e8

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 (108) hide show
  1. package/dist/content/field.js +1 -1
  2. package/dist/content/field.js.map +1 -1
  3. package/dist/content/group.d.ts +1 -2
  4. package/dist/content/group.d.ts.map +1 -1
  5. package/dist/content/group.js +1 -1
  6. package/dist/content/group.js.map +1 -1
  7. package/dist/content/legacy/link.d.ts +4 -4
  8. package/dist/content/legacy/link.js +4 -4
  9. package/dist/content/legacy/link.js.map +1 -1
  10. package/dist/content/legacy/richText.d.ts +23 -12
  11. package/dist/content/legacy/richText.d.ts.map +1 -1
  12. package/dist/content/legacy/richText.js +2 -2
  13. package/dist/content/legacy/richText.js.map +1 -1
  14. package/dist/content/link.d.ts +4 -4
  15. package/dist/content/nestable.d.ts +3 -3
  16. package/dist/content/nestable.d.ts.map +1 -1
  17. package/dist/content/nestable.js +3 -9
  18. package/dist/content/nestable.js.map +1 -1
  19. package/dist/content/richText.d.ts +1 -1
  20. package/dist/content/richText.d.ts.map +1 -1
  21. package/dist/content/richText.js +1 -1
  22. package/dist/content/richText.js.map +1 -1
  23. package/dist/content/slice.d.ts +507 -5
  24. package/dist/content/slice.d.ts.map +1 -1
  25. package/dist/content/slice.js +1 -1
  26. package/dist/content/slice.js.map +1 -1
  27. package/dist/content/slices.d.ts +507 -5
  28. package/dist/content/slices.d.ts.map +1 -1
  29. package/dist/content/table.d.ts +5 -2
  30. package/dist/content/table.d.ts.map +1 -1
  31. package/dist/content/widget.js +1 -1
  32. package/dist/content/widget.js.map +1 -1
  33. package/dist/helpers/customTypeModel.d.ts +6 -6
  34. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  35. package/dist/helpers/customTypeModel.js +6 -0
  36. package/dist/helpers/customTypeModel.js.map +1 -1
  37. package/dist/helpers/documentContent.d.ts +2 -1
  38. package/dist/helpers/documentContent.d.ts.map +1 -1
  39. package/dist/helpers/documentContent.js +4 -0
  40. package/dist/helpers/documentContent.js.map +1 -1
  41. package/dist/helpers/fieldModel.d.ts +7 -0
  42. package/dist/helpers/fieldModel.d.ts.map +1 -0
  43. package/dist/helpers/fieldModel.js +13 -0
  44. package/dist/helpers/fieldModel.js.map +1 -0
  45. package/dist/helpers/repository.d.ts +7 -0
  46. package/dist/helpers/repository.d.ts.map +1 -0
  47. package/dist/helpers/repository.js +15 -0
  48. package/dist/helpers/repository.js.map +1 -0
  49. package/dist/helpers/sliceModel.d.ts +8 -0
  50. package/dist/helpers/sliceModel.d.ts.map +1 -0
  51. package/dist/helpers/sliceModel.js +16 -0
  52. package/dist/helpers/sliceModel.js.map +1 -0
  53. package/dist/index.d.ts +9 -7
  54. package/dist/index.js +4 -1
  55. package/dist/io-ts.d.ts +5138 -1917
  56. package/dist/io-ts.d.ts.map +1 -1
  57. package/dist/io-ts.js +7 -6
  58. package/dist/io-ts.js.map +1 -1
  59. package/dist/model/customType.d.ts +9 -3
  60. package/dist/model/customType.d.ts.map +1 -1
  61. package/dist/model/customType.js +37 -5
  62. package/dist/model/customType.js.map +1 -1
  63. package/dist/model/group.d.ts +2 -2
  64. package/dist/model/group.js +1 -1
  65. package/dist/model/group.js.map +1 -1
  66. package/dist/model/image.js +1 -1
  67. package/dist/model/image.js.map +1 -1
  68. package/dist/model/nestable.js +1 -1
  69. package/dist/model/nestable.js.map +1 -1
  70. package/dist/model/slice.d.ts +10 -10
  71. package/dist/model/slice.d.ts.map +1 -1
  72. package/dist/model/slice.js +26 -6
  73. package/dist/model/slice.js.map +1 -1
  74. package/dist/model/widget.d.ts.map +1 -1
  75. package/dist/model/widget.js +2 -2
  76. package/dist/model/widget.js.map +1 -1
  77. package/dist/zod4.d.ts +1814 -249
  78. package/dist/zod4.d.ts.map +1 -1
  79. package/dist/zod4.js +7 -6
  80. package/dist/zod4.js.map +1 -1
  81. package/package.json +9 -6
  82. package/src/content/field.ts +1 -1
  83. package/src/content/group.ts +1 -1
  84. package/src/content/legacy/link.ts +4 -4
  85. package/src/content/legacy/richText.ts +14 -21
  86. package/src/content/nestable.ts +3 -18
  87. package/src/content/richText.ts +9 -6
  88. package/src/content/slice.ts +1 -1
  89. package/src/content/widget.ts +1 -1
  90. package/src/helpers/customTypeModel.ts +24 -5
  91. package/src/helpers/documentContent.ts +10 -0
  92. package/src/helpers/fieldModel.ts +18 -0
  93. package/src/helpers/repository.ts +25 -0
  94. package/src/helpers/sliceModel.ts +18 -0
  95. package/src/index.ts +10 -2
  96. package/src/io-ts.ts +8 -8
  97. package/src/model/customType.ts +67 -17
  98. package/src/model/group.ts +1 -1
  99. package/src/model/image.ts +1 -1
  100. package/src/model/nestable.ts +1 -1
  101. package/src/model/slice.ts +55 -25
  102. package/src/model/widget.ts +8 -12
  103. package/src/zod4.ts +8 -8
  104. package/dist/model/section.d.ts +0 -11
  105. package/dist/model/section.d.ts.map +0 -1
  106. package/dist/model/section.js +0 -10
  107. package/dist/model/section.js.map +0 -1
  108. package/src/model/section.ts +0 -12
@@ -1 +1 @@
1
- {"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type { CustomTypeModel, StaticCustomTypeModel } from \"../model/customType\"\nimport type { StaticSectionModel } from \"../model/section\"\nimport type { SharedSliceModel, StaticSliceModel } from \"../model/slice\"\n\nexport function toStatic(\n\tcustomType: CustomTypeModel,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): StaticCustomTypeModel {\n\tconst json: StaticCustomTypeModel[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: StaticCustomTypeModel[\"json\"][string] = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Record<string, StaticSliceModel> = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tconst sharedSlice = sharedSlicesMap.get(id)\n\t\t\t\t\t\t\tif (sharedSlice) {\n\t\t\t\t\t\t\t\tchoices[id] = sharedSlice\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n\nexport function flatten(customType: StaticCustomTypeModel): StaticSectionModel {\n\treturn Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})\n}\n\nexport function collectSharedSlices(\n\tcustomType: StaticCustomTypeModel,\n): Record<string, SharedSliceModel> {\n\tconst sharedSlices: Record<string, SharedSliceModel> = {}\n\n\tconst flattened = flatten(customType)\n\tfor (const widget of Object.values(flattened)) {\n\t\tif (widget.type === \"Slices\" || widget.type === \"Choice\") {\n\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\tsharedSlices[id] = model\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sharedSlices\n}\n\nexport function filterMissingSharedSlices<\n\tTCustomType extends StaticCustomTypeModel | CustomTypeModel,\n>(\n\tcustomType: TCustomType,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): TCustomType {\n\tconst json: TCustomType[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: typeof tab = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Required<typeof widget>[\"config\"][\"choices\"] = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tif (sharedSlicesMap.get(id)) {\n\t\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,EAAE;CAE9C,MAAM,kBACL,wBAAwB,MAAM,eAAe,IAAI,IAAI,OAAO,QAAQ,aAAa,CAAC;AAEnF,MAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,EAAE;EAC5D,MAAM,UAAiD,EAAE;AACzD,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,IAAI,CAC9C,SAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAA4C,EAAE;AACpD,SAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,CAAC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AQ,MAAM;UAGf,SAAQ,MAAM;AAIhB,YAAQ,OAAO;KACd,GAAG;KACH,QAAQ;MAAE,GAAG,OAAO;MAAQ;MAAS;KACrC;AACD;GACD,QACC,SAAQ,OAAO;;AAIlB,OAAK,UAAU;;AAGhB,QAAO;EAAE,GAAG;EAAY;EAAM"}
1
+ {"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type {\n\tDynamicCustomTypeModel,\n\tStaticCustomTypeModel,\n\tStaticCustomTypeModelTab,\n} from \"../model/customType\"\nimport type { SharedSliceModel, StaticSliceModel } from \"../model/slice\"\n\nexport function toStatic(\n\tcustomType: DynamicCustomTypeModel,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): StaticCustomTypeModel {\n\tconst json: StaticCustomTypeModel[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: StaticCustomTypeModel[\"json\"][string] = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Record<string, StaticSliceModel> = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tconst sharedSlice = sharedSlicesMap.get(id)\n\t\t\t\t\t\t\tif (sharedSlice) {\n\t\t\t\t\t\t\t\tchoices[id] = sharedSlice\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n\nexport function flatten(customType: StaticCustomTypeModel): StaticCustomTypeModelTab {\n\treturn Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})\n}\n\nexport function collectSharedSlices(\n\tcustomType: StaticCustomTypeModel,\n): Record<string, SharedSliceModel> {\n\tconst sharedSlices: Record<string, SharedSliceModel> = {}\n\n\tconst flattened = flatten(customType)\n\tfor (const widget of Object.values(flattened)) {\n\t\tif (widget.type === \"Slices\" || widget.type === \"Choice\") {\n\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\tsharedSlices[id] = model\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sharedSlices\n}\n\nexport function filterMissingSharedSlices<\n\tTCustomType extends StaticCustomTypeModel | DynamicCustomTypeModel,\n>(\n\tcustomType: TCustomType,\n\tsharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>,\n): TCustomType {\n\tconst json: TCustomType[\"json\"] = {}\n\n\tconst sharedSlicesMap =\n\t\tsharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: typeof tab = {}\n\t\tfor (const [key, widget] of Object.entries(tab)) {\n\t\t\tswitch (widget.type) {\n\t\t\t\tcase \"Slices\":\n\t\t\t\tcase \"Choice\":\n\t\t\t\t\tconst choices: Required<typeof widget>[\"config\"][\"choices\"] = {}\n\t\t\t\t\tfor (const [id, model] of Object.entries(widget.config?.choices || {})) {\n\t\t\t\t\t\tif (model.type === \"SharedSlice\") {\n\t\t\t\t\t\t\tif (sharedSlicesMap.get(id)) {\n\t\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tchoices[id] = model\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttabJSON[key] = {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tconfig: { ...widget.config, choices },\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\ttabJSON[key] = widget\n\t\t\t}\n\t\t}\n\n\t\tjson[tabKey] = tabJSON\n\t}\n\n\treturn { ...customType, json }\n}\n\nexport function serializeID(input: string): string {\n\tconst normalized = input\n\t\t.trim()\n\t\t.normalize(\"NFD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"_\")\n\t\t.replace(/^_+|_+$/g, \"\")\n\n\tif (normalized.length === 0) {\n\t\tthrow new Error(`Cannot serialize \"${input}\": result is empty.`)\n\t}\n\n\treturn normalized\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,EAAE;CAE9C,MAAM,kBACL,wBAAwB,MAAM,eAAe,IAAI,IAAI,OAAO,QAAQ,aAAa,CAAC;AAEnF,MAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,EAAE;EAC5D,MAAM,UAAiD,EAAE;AACzD,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,IAAI,CAC9C,SAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAA4C,EAAE;AACpD,SAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,CAAC,CACrE,KAAI,MAAM,SAAS,eAAe;KACjC,MAAM,cAAc,gBAAgB,IAAI,GAAG;AAC3C,SAAI,YACH,SAAQ,MAAM;UAGf,SAAQ,MAAM;AAIhB,YAAQ,OAAO;KACd,GAAG;KACH,QA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AAGhB,QAAO;EAAE,GAAG;EAAY;EAAM;;AAG/B,SAAgB,YAAY,OAAuB;CAClD,MAAM,aAAa,MACjB,MAAM,CACN,UAAU,MAAM,CAChB,QAAQ,WAAW,GAAG,CACtB,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG;AAEzB,KAAI,WAAW,WAAW,EACzB,OAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;AAGjE,QAAO"}
@@ -6,7 +6,7 @@ import { DocumentLegacy } from "../content/legacy/document.js";
6
6
 
7
7
  //#region src/helpers/documentContent.d.ts
8
8
  declare namespace documentContent_d_exports {
9
- export { collectWidgets, fromLegacy, toLegacy };
9
+ export { collectWidgets, fromLegacy, serializeUID, toLegacy };
10
10
  }
11
11
  declare function collectWidgets<TWidgetContent extends WidgetContent>(document: DocumentContent, test: (content: WidgetContent, args: {
12
12
  path: Path;
@@ -15,6 +15,7 @@ declare function collectWidgets<TWidgetContent extends WidgetContent>(document:
15
15
  }) => content is TWidgetContent): Record<string, TWidgetContent>;
16
16
  declare function fromLegacy(legacy: DocumentLegacy, model: StaticCustomTypeModel): DocumentContent | undefined;
17
17
  declare function toLegacy(document: DocumentContent): DocumentLegacy;
18
+ declare function serializeUID(input: string): string;
18
19
  //#endregion
19
20
  export { documentContent_d_exports };
20
21
  //# sourceMappingURL=documentContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":";;;;;;;;;;iBAkBgB,cAAA,wBAAsC,aAAA,CAAA,CACrD,QAAA,EAAU,eAAA,EACV,IAAA,GACC,OAAA,EAAS,aAAA,EACT,IAAA;EACC,IAAA,EAAM,IAAA;EACN,GAAA;EACA,KAAA;AAAA,MAEG,OAAA,IAAW,cAAA,GACd,MAAA,SAAe,cAAA;AAAA,iBAgBF,UAAA,CACf,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,qBAAA,GACL,eAAA;AAAA,iBAwDa,QAAA,CAAS,QAAA,EAAU,eAAA,GAAkB,cAAA"}
1
+ {"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":";;;;;;;;;;iBAkBgB,cAAA,wBAAsC,aAAA,CAAA,CACrD,QAAA,EAAU,eAAA,EACV,IAAA,GACC,OAAA,EAAS,aAAA,EACT,IAAA;EACC,IAAA,EAAM,IAAA;EACN,GAAA;EACA,KAAA;AAAA,MAEG,OAAA,IAAW,cAAA,GACd,MAAA,SAAe,cAAA;AAAA,iBAgBF,UAAA,CACf,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,qBAAA,GACL,eAAA;AAAA,iBAwDa,QAAA,CAAS,QAAA,EAAU,eAAA,GAAkB,cAAA;AAAA,iBAMrC,YAAA,CAAa,KAAA"}
@@ -13,6 +13,7 @@ import { z } from "zod/mini";
13
13
  var documentContent_exports = /* @__PURE__ */ __exportAll({
14
14
  collectWidgets: () => collectWidgets,
15
15
  fromLegacy: () => fromLegacy,
16
+ serializeUID: () => serializeUID,
16
17
  toLegacy: () => toLegacy
17
18
  });
18
19
  function collectWidgets(document, test) {
@@ -58,6 +59,9 @@ function toLegacy(document) {
58
59
  ...keys
59
60
  };
60
61
  }
62
+ function serializeUID(input) {
63
+ return input.replace(/ /g, "-").normalize("NFD").replace(/\p{M}/gu, "").replace(/[^\p{L}\d_.-]/gu, "").toLowerCase();
64
+ }
61
65
  //#endregion
62
66
  export { documentContent_exports };
63
67
 
@@ -1 +1 @@
1
- {"version":3,"file":"documentContent.js","names":["contentPath.serialize","customTypeModel.collectSharedSlices","sliceContent.compositeToShared","sliceContent.legacyToShared"],"sources":["../../src/helpers/documentContent.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { DocumentLegacyCodec } from \"../content/codec/document\"\nimport { defaultCtx } from \"../content/codec/legacyContentCtx\"\nimport type { DocumentContent } from \"../content/document\"\nimport type { DocumentLegacy } from \"../content/legacy/document\"\nimport { DocumentLegacySchema } from \"../content/legacy/document\"\nimport { isNestableContent } from \"../content/nestable\"\nimport type { CompositeSliceItemContent, LegacySliceItemContent } from \"../content/slices\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { FieldOrSliceType } from \"../model/widget\"\nimport { FieldOrSliceTypeSchema } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\nimport * as sliceContent from \"./sliceContent\"\nimport { traverseDocumentContent } from \"./traverseContent\"\n\nexport function collectWidgets<TWidgetContent extends WidgetContent>(\n\tdocument: DocumentContent,\n\ttest: (\n\t\tcontent: WidgetContent,\n\t\targs: {\n\t\t\tpath: contentPath.Path\n\t\t\tkey: string\n\t\t\tapiID: string\n\t\t},\n\t) => content is TWidgetContent,\n): Record<string, TWidgetContent> {\n\tconst collected: Record<string, TWidgetContent> = {}\n\n\ttraverseDocumentContent(document, {\n\t\ttransformWidget: ({ content, ...args }) => {\n\t\t\tif (test(content, args)) {\n\t\t\t\tcollected[contentPath.serialize(args.path)] = content\n\t\t\t}\n\n\t\t\treturn content\n\t\t},\n\t})\n\n\treturn collected\n}\n\nexport function fromLegacy(\n\tlegacy: DocumentLegacy,\n\tmodel: StaticCustomTypeModel,\n): DocumentContent | undefined {\n\tconst parsed = DocumentLegacySchema.safeParse(legacy)\n\tif (!parsed.success) {\n\t\treturn\n\t}\n\n\tconst types = new Map<string, FieldOrSliceType>()\n\tconst keys = new Map<string, string>()\n\tconst widgets: DocumentLegacy = {}\n\tfor (const [key, value] of Object.entries(parsed.data)) {\n\t\tif (key.endsWith(\"_TYPE\")) {\n\t\t\tconst parsed = FieldOrSliceTypeSchema.safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\ttypes.set(key.substring(0, key.length - 5), parsed.data)\n\t\t\t}\n\t\t} else if (key.endsWith(\"_KEY\")) {\n\t\t\tconst parsed = z.uuidv4().safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\tkeys.set(key.substring(0, key.length - 4), parsed.data)\n\t\t\t}\n\t\t} else if (!key.endsWith(\"_POSITION\")) {\n\t\t\twidgets[key] = value\n\t\t}\n\t}\n\n\tconst result = DocumentLegacyCodec(defaultCtx(\"\", types, keys)).toContent(widgets)\n\tif (!result.success) {\n\t\treturn\n\t}\n\n\tconst needsMigration = Object.values(customTypeModel.collectSharedSlices(model)).some((slice) =>\n\t\tBoolean(slice.legacyPaths),\n\t)\n\n\tif (needsMigration) {\n\t\treturn traverseDocumentContent(result.data, {\n\t\t\tmodel,\n\t\t\ttransformSlice: ({ content, model }) => {\n\t\t\t\tif (model?.type === \"SharedSlice\") {\n\t\t\t\t\tif (content.widget.__TYPE__ === \"CompositeSliceContent\") {\n\t\t\t\t\t\treturn sliceContent.compositeToShared(content as CompositeSliceItemContent, model)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tcontent.widget.__TYPE__ === \"GroupContentType\" ||\n\t\t\t\t\t\tisNestableContent(content.widget)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn sliceContent.legacyToShared(content as LegacySliceItemContent, model)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn content\n\t\t\t},\n\t\t})\n\t}\n\n\treturn result.data\n}\n\nexport function toLegacy(document: DocumentContent): DocumentLegacy {\n\tconst { content, types, keys } = DocumentLegacyCodec(defaultCtx(\"\")).fromContent(document)\n\n\treturn { ...content, ...types, ...keys }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAgB,eACf,UACA,MAQiC;CACjC,MAAM,YAA4C,EAAE;AAEpD,yBAAwB,UAAU,EACjC,kBAAkB,EAAE,SAAS,GAAG,WAAW;AAC1C,MAAI,KAAK,SAAS,KAAK,CACtB,WAAUA,UAAsB,KAAK,KAAK,IAAI;AAG/C,SAAO;IAER,CAAC;AAEF,QAAO;;AAGR,SAAgB,WACf,QACA,OAC8B;CAC9B,MAAM,SAAS,qBAAqB,UAAU,OAAO;AACrD,KAAI,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ent.js","names":["contentPath.serialize","customTypeModel.collectSharedSlices","sliceContent.compositeToShared","sliceContent.legacyToShared"],"sources":["../../src/helpers/documentContent.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { DocumentLegacyCodec } from \"../content/codec/document\"\nimport { defaultCtx } from \"../content/codec/legacyContentCtx\"\nimport type { DocumentContent } from \"../content/document\"\nimport type { DocumentLegacy } from \"../content/legacy/document\"\nimport { DocumentLegacySchema } from \"../content/legacy/document\"\nimport { isNestableContent } from \"../content/nestable\"\nimport type { CompositeSliceItemContent, LegacySliceItemContent } from \"../content/slices\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { FieldOrSliceType } from \"../model/widget\"\nimport { FieldOrSliceTypeSchema } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\nimport * as sliceContent from \"./sliceContent\"\nimport { traverseDocumentContent } from \"./traverseContent\"\n\nexport function collectWidgets<TWidgetContent extends WidgetContent>(\n\tdocument: DocumentContent,\n\ttest: (\n\t\tcontent: WidgetContent,\n\t\targs: {\n\t\t\tpath: contentPath.Path\n\t\t\tkey: string\n\t\t\tapiID: string\n\t\t},\n\t) => content is TWidgetContent,\n): Record<string, TWidgetContent> {\n\tconst collected: Record<string, TWidgetContent> = {}\n\n\ttraverseDocumentContent(document, {\n\t\ttransformWidget: ({ content, ...args }) => {\n\t\t\tif (test(content, args)) {\n\t\t\t\tcollected[contentPath.serialize(args.path)] = content\n\t\t\t}\n\n\t\t\treturn content\n\t\t},\n\t})\n\n\treturn collected\n}\n\nexport function fromLegacy(\n\tlegacy: DocumentLegacy,\n\tmodel: StaticCustomTypeModel,\n): DocumentContent | undefined {\n\tconst parsed = DocumentLegacySchema.safeParse(legacy)\n\tif (!parsed.success) {\n\t\treturn\n\t}\n\n\tconst types = new Map<string, FieldOrSliceType>()\n\tconst keys = new Map<string, string>()\n\tconst widgets: DocumentLegacy = {}\n\tfor (const [key, value] of Object.entries(parsed.data)) {\n\t\tif (key.endsWith(\"_TYPE\")) {\n\t\t\tconst parsed = FieldOrSliceTypeSchema.safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\ttypes.set(key.substring(0, key.length - 5), parsed.data)\n\t\t\t}\n\t\t} else if (key.endsWith(\"_KEY\")) {\n\t\t\tconst parsed = z.uuidv4().safeParse(value)\n\t\t\tif (parsed.success) {\n\t\t\t\tkeys.set(key.substring(0, key.length - 4), parsed.data)\n\t\t\t}\n\t\t} else if (!key.endsWith(\"_POSITION\")) {\n\t\t\twidgets[key] = value\n\t\t}\n\t}\n\n\tconst result = DocumentLegacyCodec(defaultCtx(\"\", types, keys)).toContent(widgets)\n\tif (!result.success) {\n\t\treturn\n\t}\n\n\tconst needsMigration = Object.values(customTypeModel.collectSharedSlices(model)).some((slice) =>\n\t\tBoolean(slice.legacyPaths),\n\t)\n\n\tif (needsMigration) {\n\t\treturn traverseDocumentContent(result.data, {\n\t\t\tmodel,\n\t\t\ttransformSlice: ({ content, model }) => {\n\t\t\t\tif (model?.type === \"SharedSlice\") {\n\t\t\t\t\tif (content.widget.__TYPE__ === \"CompositeSliceContent\") {\n\t\t\t\t\t\treturn sliceContent.compositeToShared(content as CompositeSliceItemContent, model)\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tcontent.widget.__TYPE__ === \"GroupContentType\" ||\n\t\t\t\t\t\tisNestableContent(content.widget)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn sliceContent.legacyToShared(content as LegacySliceItemContent, model)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn content\n\t\t\t},\n\t\t})\n\t}\n\n\treturn result.data\n}\n\nexport function toLegacy(document: DocumentContent): DocumentLegacy {\n\tconst { content, types, keys } = DocumentLegacyCodec(defaultCtx(\"\")).fromContent(document)\n\n\treturn { ...content, ...types, ...keys }\n}\n\nexport function serializeUID(input: string): string {\n\tconst nowhitespace = input.replace(/ /g, \"-\")\n\n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,wBAAwB,OAAO,MAAM;EAC3C;EACA,iBAAiB,EAAE,SAAS,YAAY;AACvC,OAAI,OAAO,SAAS;QACf,QAAQ,OAAO,aAAa,wBAC/B,QAAOC,kBAA+B,SAAsC,MAAM;aAElF,QAAQ,OAAO,aAAa,sBAC5B,kBAAkB,QAAQ,OAAO,CAEjC,QAAOC,eAA4B,SAAmC,MAAM;;AAG9E,UAAO;;EAER,CAAC;AAGH,QAAO,OAAO;;AAGf,SAAgB,SAAS,UAA2C;CACnE,MAAM,EAAE,SAAS,OAAO,SAAS,oBAAoB,WAAW,GAAG,CAAC,CAAC,YAAY,SAAS;AAE1F,QAAO;EAAE,GAAG;EAAS,GAAG;EAAO,GAAG;EAAM;;AAGzC,SAAgB,aAAa,OAAuB;AAOnD,QANqB,MAAM,QAAQ,MAAM,IAAI,CAEb,UAAU,MAAM,CAAC,QAAQ,WAAW,GAAG,CAE/C,QAAQ,mBAAmB,GAAG,CAE1C,aAAa"}
@@ -0,0 +1,7 @@
1
+ declare namespace fieldModel_d_exports {
2
+ export { serializeID };
3
+ }
4
+ declare function serializeID(input: string): string;
5
+ //#endregion
6
+ export { fieldModel_d_exports };
7
+ //# sourceMappingURL=fieldModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldModel.d.ts","names":[],"sources":["../../src/helpers/fieldModel.ts"],"mappings":";;;iBAAgB,WAAA,CAAY,KAAA"}
@@ -0,0 +1,13 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region src/helpers/fieldModel.ts
3
+ var fieldModel_exports = /* @__PURE__ */ __exportAll({ serializeID: () => serializeID });
4
+ function serializeID(input) {
5
+ const tokens = input.trim().normalize("NFD").replace(/\p{M}/gu, "").split(/[^A-Za-z0-9]+/).filter(Boolean);
6
+ if (tokens.length === 0) throw new Error(`Cannot serialize "${input}": result is empty.`);
7
+ const [first, ...rest] = tokens;
8
+ return first.toLowerCase() + rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("");
9
+ }
10
+ //#endregion
11
+ export { fieldModel_exports };
12
+
13
+ //# sourceMappingURL=fieldModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldModel.js","names":[],"sources":["../../src/helpers/fieldModel.ts"],"sourcesContent":["export function serializeID(input: string): string {\n\tconst tokens = input\n\t\t.trim()\n\t\t.normalize(\"NFD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.split(/[^A-Za-z0-9]+/)\n\t\t.filter(Boolean)\n\n\tif (tokens.length === 0) {\n\t\tthrow new Error(`Cannot serialize \"${input}\": result is empty.`)\n\t}\n\n\tconst [first, ...rest] = tokens\n\treturn (\n\t\tfirst.toLowerCase() +\n\t\trest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join(\"\")\n\t)\n}\n"],"mappings":";;;AAAA,SAAgB,YAAY,OAAuB;CAClD,MAAM,SAAS,MACb,MAAM,CACN,UAAU,MAAM,CAChB,QAAQ,WAAW,GAAG,CACtB,MAAM,gBAAgB,CACtB,OAAO,QAAQ;AAEjB,KAAI,OAAO,WAAW,EACrB,OAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;CAGjE,MAAM,CAAC,OAAO,GAAG,QAAQ;AACzB,QACC,MAAM,aAAa,GACnB,KAAK,KAAK,UAAU,MAAM,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,MAAM,EAAE,CAAC,aAAa,CAAC,CAAC,KAAK,GAAG"}
@@ -0,0 +1,7 @@
1
+ declare namespace repository_d_exports {
2
+ export { serializeID };
3
+ }
4
+ declare function serializeID(input: string): string;
5
+ //#endregion
6
+ export { repository_d_exports };
7
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/helpers/repository.ts"],"mappings":";;;iBAGgB,WAAA,CAAY,KAAA"}
@@ -0,0 +1,15 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region src/helpers/repository.ts
3
+ var repository_exports = /* @__PURE__ */ __exportAll({ serializeID: () => serializeID });
4
+ const MIN_LENGTH = 4;
5
+ const MAX_LENGTH = 63;
6
+ function serializeID(input) {
7
+ const normalized = input.trim().normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
8
+ const truncated = normalized.length > MAX_LENGTH ? normalized.slice(0, MAX_LENGTH).replace(/-+$/, "") : normalized;
9
+ if (truncated.length < MIN_LENGTH) throw new Error(`Cannot serialize "${input}" to a repository ID: result must be between ${MIN_LENGTH} and ${MAX_LENGTH} characters.`);
10
+ return truncated;
11
+ }
12
+ //#endregion
13
+ export { repository_exports };
14
+
15
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","names":[],"sources":["../../src/helpers/repository.ts"],"sourcesContent":["const MIN_LENGTH = 4\nconst MAX_LENGTH = 63\n\nexport function serializeID(input: string): string {\n\tconst normalized = input\n\t\t.trim()\n\t\t.normalize(\"NFD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\")\n\n\tconst truncated =\n\t\tnormalized.length > MAX_LENGTH\n\t\t\t? normalized.slice(0, MAX_LENGTH).replace(/-+$/, \"\")\n\t\t\t: normalized\n\n\tif (truncated.length < MIN_LENGTH) {\n\t\tthrow new Error(\n\t\t\t`Cannot serialize \"${input}\" to a repository ID: result must be between ${MIN_LENGTH} and ${MAX_LENGTH} characters.`,\n\t\t)\n\t}\n\n\treturn truncated\n}\n"],"mappings":";;;AAAA,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,SAAgB,YAAY,OAAuB;CAClD,MAAM,aAAa,MACjB,MAAM,CACN,UAAU,MAAM,CAChB,QAAQ,WAAW,GAAG,CACtB,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG;CAEzB,MAAM,YACL,WAAW,SAAS,aACjB,WAAW,MAAM,GAAG,WAAW,CAAC,QAAQ,OAAO,GAAG,GAClD;AAEJ,KAAI,UAAU,SAAS,WACtB,OAAM,IAAI,MACT,qBAAqB,MAAM,+CAA+C,WAAW,OAAO,WAAW,cACvG;AAGF,QAAO"}
@@ -0,0 +1,8 @@
1
+ declare namespace sliceModel_d_exports {
2
+ export { serializeID, serializeVariationID };
3
+ }
4
+ declare function serializeID(input: string): string;
5
+ declare const serializeVariationID: typeof serializeID;
6
+ //#endregion
7
+ export { sliceModel_d_exports };
8
+ //# sourceMappingURL=sliceModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sliceModel.d.ts","names":[],"sources":["../../src/helpers/sliceModel.ts"],"mappings":";;;iBAAgB,WAAA,CAAY,KAAA;AAAA,cAiBf,oBAAA,SAAoB,WAAA"}
@@ -0,0 +1,16 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region src/helpers/sliceModel.ts
3
+ var sliceModel_exports = /* @__PURE__ */ __exportAll({
4
+ serializeID: () => serializeID,
5
+ serializeVariationID: () => serializeVariationID
6
+ });
7
+ function serializeID(input) {
8
+ const tokens = input.trim().normalize("NFD").replace(/\p{M}/gu, "").split(/[^A-Za-z0-9]+/).filter(Boolean);
9
+ if (tokens.length === 0) throw new Error(`Cannot serialize "${input}": result is empty.`);
10
+ return tokens.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("");
11
+ }
12
+ const serializeVariationID = serializeID;
13
+ //#endregion
14
+ export { sliceModel_exports };
15
+
16
+ //# sourceMappingURL=sliceModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sliceModel.js","names":[],"sources":["../../src/helpers/sliceModel.ts"],"sourcesContent":["export function serializeID(input: string): string {\n\tconst tokens = input\n\t\t.trim()\n\t\t.normalize(\"NFD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.split(/[^A-Za-z0-9]+/)\n\t\t.filter(Boolean)\n\n\tif (tokens.length === 0) {\n\t\tthrow new Error(`Cannot serialize \"${input}\": result is empty.`)\n\t}\n\n\treturn tokens\n\t\t.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase())\n\t\t.join(\"\")\n}\n\nexport const serializeVariationID = serializeID\n"],"mappings":";;;;;;AAAA,SAAgB,YAAY,OAAuB;CAClD,MAAM,SAAS,MACb,MAAM,CACN,UAAU,MAAM,CAChB,QAAQ,WAAW,GAAG,CACtB,MAAM,gBAAgB,CACtB,OAAO,QAAQ;AAEjB,KAAI,OAAO,WAAW,EACrB,OAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;AAGjE,QAAO,OACL,KAAK,UAAU,MAAM,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,MAAM,EAAE,CAAC,aAAa,CAAC,CAC5E,KAAK,GAAG;;AAGX,MAAa,uBAAuB"}
package/dist/index.d.ts CHANGED
@@ -4,16 +4,16 @@ import { HexaColorCode } from "./common/hexaColorCode.js";
4
4
  import { NonEmptyString } from "./common/nonEmptyString.js";
5
5
  import { WidgetKey } from "./common/widgetKey.js";
6
6
  import { BooleanContent } from "./content/boolean.js";
7
+ import { EmptyLinkContent, FilledLinkContent, LinkContent } from "./content/link.js";
7
8
  import { EmbedContent } from "./content/embed.js";
9
+ import { ImageContent, ImageContentView } from "./content/image.js";
10
+ import { RichTextNodeType, RichTextNodeTypes } from "./content/legacy/richText.js";
11
+ import { RichTextContent, RichTextContentBlock, RichTextContentEmbedBlock, RichTextContentImageBlock, RichTextContentSpan, RichTextContentTextBlock } from "./content/richText.js";
8
12
  import { EmptyContent } from "./content/empty.js";
9
13
  import { ColorContent, DateContent, FieldContent, NumberContent, RangeContent, SelectContent, TextContent, TimestampContent } from "./content/field.js";
10
14
  import { GeoPointContent } from "./content/geopoint.js";
11
- import { ImageContent, ImageContentView } from "./content/image.js";
12
15
  import { IntegrationFieldContent } from "./content/integrationField.js";
13
- import { EmptyLinkContent, FilledLinkContent, LinkContent } from "./content/link.js";
14
16
  import { RepeatableContent } from "./content/repeatable.js";
15
- import { RichTextNodeType, RichTextNodeTypes } from "./content/legacy/richText.js";
16
- import { RichTextContent, RichTextContentBlock, RichTextContentEmbedBlock, RichTextContentImageBlock, RichTextContentSpan, RichTextContentTextBlock } from "./content/richText.js";
17
17
  import { SeparatorContent } from "./content/separator.js";
18
18
  import { TableContent } from "./content/table.js";
19
19
  import { NestableContent } from "./content/nestable.js";
@@ -45,15 +45,17 @@ import { CompositeSliceModel, DynamicSliceModel, LegacySliceModel, SharedSliceMo
45
45
  import { DynamicSlicesModel, StaticSlicesModel } from "./model/slices.js";
46
46
  import { UIDModel } from "./model/uid.js";
47
47
  import { DynamicWidgetModel, FieldModelType, StaticWidgetModel } from "./model/widget.js";
48
- import { CustomTypeModel, StaticCustomTypeModel } from "./model/customType.js";
49
- import { DynamicSectionModel, StaticSectionModel } from "./model/section.js";
48
+ import { CustomTypeModel, DynamicCustomTypeModel, DynamicCustomTypeModelTab, StaticCustomTypeModel, StaticCustomTypeModelTab } from "./model/customType.js";
50
49
  import { LegacyContentCtx, defaultCtx, getFieldCtx } from "./content/codec/legacyContentCtx.js";
51
50
  import { contentPath_d_exports } from "./helpers/contentPath.js";
52
51
  import { customTypeModel_d_exports } from "./helpers/customTypeModel.js";
53
52
  import { documentContent_d_exports } from "./helpers/documentContent.js";
53
+ import { fieldModel_d_exports } from "./helpers/fieldModel.js";
54
+ import { repository_d_exports } from "./helpers/repository.js";
54
55
  import { sliceContent_d_exports } from "./helpers/sliceContent.js";
56
+ import { sliceModel_d_exports } from "./helpers/sliceModel.js";
55
57
  import { withDefaultContent_d_exports } from "./helpers/withDefaultContent.js";
56
58
  import { imageContent_d_exports } from "./helpers/imageContent.js";
57
59
  import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
58
60
  import { TraverseSliceContentWithModelFunction, TraverseWidgetContentWithModelFunction, traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
59
- export { type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type DateContent, type DateModel, type DocumentContent, type DynamicSectionModel, type DynamicSliceModel, type DynamicSlicesModel, type DynamicWidgetModel, type Embed, type EmbedContent, type EmbedModel, type EmptyContent, type EmptyLinkContent, type FieldContent, type FieldModelType, type FilledLinkContent, type GeoPointContent, type GeoPointModel, type GroupContent, type GroupItemContent, type GroupModel, type HexaColorCode, type ImageContent, type ImageContentView, type ImageModel, type IntegrationFieldContent, type IntegrationFieldModel, LegacyContentCtx, type LegacySliceContent, type LegacySliceItemContent, type LegacySliceModel, type LinkContent, type LinkModel, type NestableContent, type NestableModel, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RepeatableContent, type RichTextContent, type RichTextContentBlock, type RichTextContentEmbedBlock, type RichTextContentImageBlock, type RichTextContentSpan, type RichTextContentTextBlock, type RichTextModel, RichTextModelNodeType, type RichTextModelNodeTypes, RichTextNodeType, type RichTextNodeTypes, type SelectContent, type SelectModel, type SeparatorContent, type SeparatorModel, type SharedSliceContent, type SharedSliceItemContent, type SharedSliceModel, type SharedSliceModelVariation, type SharedSliceRefModel, type SharedSliceVariationContentModel, type SliceContent, type SliceContentModel, type SliceItemContent, type SliceModelType, type SlicesContent, type StaticCustomTypeModel, type StaticSectionModel, type StaticSliceModel, type StaticSlicesModel, type StaticWidgetModel, TableCellModelNodeTypes, type TableContent, type TableModel, type TextContent, type TextModel, type TimestampContent, type TimestampModel, type TraverseSliceContentFunction, type TraverseSliceContentWithModelFunction, type TraverseWidgetContentFunction, type TraverseWidgetContentWithModelFunction, type UIDContent, type UIDModel, type WidgetContent, type WidgetKey, contentPath_d_exports as contentPath, customTypeModel_d_exports as customTypeModel, defaultCtx, documentContent_d_exports as documentContent, getFieldCtx, imageContent_d_exports as imageContent, sliceContent_d_exports as sliceContent, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel, withDefaultContent_d_exports as withDefaultContent };
61
+ export { type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type DateContent, type DateModel, type DocumentContent, type DynamicCustomTypeModel, type DynamicCustomTypeModelTab, type DynamicSliceModel, type DynamicSlicesModel, type DynamicWidgetModel, type Embed, type EmbedContent, type EmbedModel, type EmptyContent, type EmptyLinkContent, type FieldContent, type FieldModelType, type FilledLinkContent, type GeoPointContent, type GeoPointModel, type GroupContent, type GroupItemContent, type GroupModel, type HexaColorCode, type ImageContent, type ImageContentView, type ImageModel, type IntegrationFieldContent, type IntegrationFieldModel, LegacyContentCtx, type LegacySliceContent, type LegacySliceItemContent, type LegacySliceModel, type LinkContent, type LinkModel, type NestableContent, type NestableModel, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RepeatableContent, type RichTextContent, type RichTextContentBlock, type RichTextContentEmbedBlock, type RichTextContentImageBlock, type RichTextContentSpan, type RichTextContentTextBlock, type RichTextModel, RichTextModelNodeType, type RichTextModelNodeTypes, RichTextNodeType, type RichTextNodeTypes, type SelectContent, type SelectModel, type SeparatorContent, type SeparatorModel, type SharedSliceContent, type SharedSliceItemContent, type SharedSliceModel, type SharedSliceModelVariation, type SharedSliceRefModel, type SharedSliceVariationContentModel, type SliceContent, type SliceContentModel, type SliceItemContent, type SliceModelType, type SlicesContent, type StaticCustomTypeModel, type StaticCustomTypeModelTab, type StaticSliceModel, type StaticSlicesModel, type StaticWidgetModel, TableCellModelNodeTypes, type TableContent, type TableModel, type TextContent, type TextModel, type TimestampContent, type TimestampModel, type TraverseSliceContentFunction, type TraverseSliceContentWithModelFunction, type TraverseWidgetContentFunction, type TraverseWidgetContentWithModelFunction, type UIDContent, type UIDModel, type WidgetContent, type WidgetKey, contentPath_d_exports as contentPath, customTypeModel_d_exports as customTypeModel, defaultCtx, documentContent_d_exports as documentContent, fieldModel_d_exports as fieldModel, getFieldCtx, imageContent_d_exports as imageContent, repository_d_exports as repository, sliceContent_d_exports as sliceContent, sliceModel_d_exports as sliceModel, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel, withDefaultContent_d_exports as withDefaultContent };
package/dist/index.js CHANGED
@@ -8,7 +8,10 @@ import { customTypeModel_exports } from "./helpers/customTypeModel.js";
8
8
  import { sliceContent_exports } from "./helpers/sliceContent.js";
9
9
  import { traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
10
10
  import { documentContent_exports } from "./helpers/documentContent.js";
11
+ import { fieldModel_exports } from "./helpers/fieldModel.js";
12
+ import { repository_exports } from "./helpers/repository.js";
13
+ import { sliceModel_exports } from "./helpers/sliceModel.js";
11
14
  import { withDefaultContent_exports } from "./helpers/withDefaultContent.js";
12
15
  import { imageContent_exports } from "./helpers/imageContent.js";
13
16
  import { traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
14
- export { LegacyContentCtx, RichTextModelNodeType, RichTextNodeType, TableCellModelNodeTypes, contentPath_exports as contentPath, customTypeModel_exports as customTypeModel, defaultCtx, documentContent_exports as documentContent, getFieldCtx, imageContent_exports as imageContent, sliceContent_exports as sliceContent, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel, withDefaultContent_exports as withDefaultContent };
17
+ export { LegacyContentCtx, RichTextModelNodeType, RichTextNodeType, TableCellModelNodeTypes, contentPath_exports as contentPath, customTypeModel_exports as customTypeModel, defaultCtx, documentContent_exports as documentContent, fieldModel_exports as fieldModel, getFieldCtx, imageContent_exports as imageContent, repository_exports as repository, sliceContent_exports as sliceContent, sliceModel_exports as sliceModel, traverseCompositeSliceContent, traverseCompositeSliceContentWithModel, traverseDocumentContent, traverseDocumentContentWithModel, traverseGroupContent, traverseGroupContentWithModel, traverseGroupItemsContent, traverseGroupItemsContentWithModel, traverseLegacySliceContent, traverseLegacySliceContentWithModel, traverseRepeatableContent, traverseRepeatableContentWithModel, traverseSharedSliceContent, traverseSharedSliceContentWithModel, traverseSlicesContent, traverseSlicesContentWithModel, traverseTableContent, traverseTableContentWithModel, withDefaultContent_exports as withDefaultContent };