@prismicio/types-internal 4.2.0-pr.13.ce54183 → 4.2.0-pr.15.41d45dd

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 (37) hide show
  1. package/dist/helpers/documentContent.d.ts +2 -1
  2. package/dist/helpers/documentContent.d.ts.map +1 -1
  3. package/dist/helpers/documentContent.js +5 -1
  4. package/dist/helpers/documentContent.js.map +1 -1
  5. package/dist/helpers/repository.d.ts +7 -0
  6. package/dist/helpers/repository.d.ts.map +1 -0
  7. package/dist/helpers/repository.js +15 -0
  8. package/dist/helpers/repository.js.map +1 -0
  9. package/dist/helpers/sliceModel.d.ts +8 -0
  10. package/dist/helpers/sliceModel.d.ts.map +1 -0
  11. package/dist/helpers/sliceModel.js +16 -0
  12. package/dist/helpers/sliceModel.js.map +1 -0
  13. package/dist/helpers/widgetModel.d.ts +7 -0
  14. package/dist/helpers/widgetModel.d.ts.map +1 -0
  15. package/dist/helpers/widgetModel.js +13 -0
  16. package/dist/helpers/widgetModel.js.map +1 -0
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.js +4 -1
  19. package/dist/io-ts.d.ts +438 -438
  20. package/dist/io-ts.d.ts.map +1 -1
  21. package/dist/model/customType.d.ts.map +1 -1
  22. package/dist/model/customType.js +5 -10
  23. package/dist/model/customType.js.map +1 -1
  24. package/dist/model/image.js +1 -1
  25. package/dist/model/image.js.map +1 -1
  26. package/dist/model/slice.d.ts.map +1 -1
  27. package/dist/model/slice.js +15 -1
  28. package/dist/model/slice.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/helpers/documentContent.ts +10 -0
  31. package/src/helpers/repository.ts +25 -0
  32. package/src/helpers/sliceModel.ts +18 -0
  33. package/src/helpers/widgetModel.ts +18 -0
  34. package/src/index.ts +3 -0
  35. package/src/model/customType.ts +8 -13
  36. package/src/model/image.ts +1 -1
  37. package/src/model/slice.ts +20 -2
@@ -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, toLegacy, uid };
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 uid(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,GAAA,CAAI,KAAA"}
@@ -13,7 +13,8 @@ import { z } from "zod/mini";
13
13
  var documentContent_exports = /* @__PURE__ */ __exportAll({
14
14
  collectWidgets: () => collectWidgets,
15
15
  fromLegacy: () => fromLegacy,
16
- toLegacy: () => toLegacy
16
+ toLegacy: () => toLegacy,
17
+ uid: () => uid
17
18
  });
18
19
  function collectWidgets(document, test) {
19
20
  const collected = {};
@@ -58,6 +59,9 @@ function toLegacy(document) {
58
59
  ...keys
59
60
  };
60
61
  }
62
+ function uid(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,CAAC,OAAO,QACX;CAGD,MAAM,wBAAQ,IAAI,KAA+B;CACjD,MAAM,uBAAO,IAAI,KAAqB;CACtC,MAAM,UAA0B,EAAE;AAClC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,KAAK,CACrD,KAAI,IAAI,SAAS,QAAQ,EAAE;EAC1B,MAAM,SAAS,uBAAuB,UAAU,MAAM;AACtD,MAAI,OAAO,QACV,OAAM,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,EAAE,EAAE,OAAO,KAAK;YAE/C,IAAI,SAAS,OAAO,EAAE;EAChC,MAAM,SAAS,EAAE,QAAQ,CAAC,UAAU,MAAM;AAC1C,MAAI,OAAO,QACV,MAAK,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,EAAE,EAAE,OAAO,KAAK;YAE9C,CAAC,IAAI,SAAS,YAAY,CACpC,SAAQ,OAAO;CAIjB,MAAM,SAAS,oBAAoB,WAAW,IAAI,OAAO,KAAK,CAAC,CAAC,UAAU,QAAQ;AAClF,KAAI,CAAC,OAAO,QACX;AAOD,KAJuB,OAAO,OAAOC,oBAAoC,MAAM,CAAC,CAAC,MAAM,UACtF,QAAQ,MAAM,YAAY,CAC1B,CAGA,QAAO,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"}
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\nexport function uid(input: string): string {\n\tconst nowhitespace = input.replace(/ /g, \"-\")\n\n\tconst normalized = nowhitespace.normalize(\"NFD\").replace(/\\p{M}/gu, \"\")\n\n\tconst slug = normalized.replace(/[^\\p{L}\\d_.-]/gu, \"\")\n\n\treturn slug.toLowerCase()\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,CAAC,OAAO,QACX;CAGD,MAAM,wBAAQ,IAAI,KAA+B;CACjD,MAAM,uBAAO,IAAI,KAAqB;CACtC,MAAM,UAA0B,EAAE;AAClC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,KAAK,CACrD,KAAI,IAAI,SAAS,QAAQ,EAAE;EAC1B,MAAM,SAAS,uBAAuB,UAAU,MAAM;AACtD,MAAI,OAAO,QACV,OAAM,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,EAAE,EAAE,OAAO,KAAK;YAE/C,IAAI,SAAS,OAAO,EAAE;EAChC,MAAM,SAAS,EAAE,QAAQ,CAAC,UAAU,MAAM;AAC1C,MAAI,OAAO,QACV,MAAK,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,EAAE,EAAE,OAAO,KAAK;YAE9C,CAAC,IAAI,SAAS,YAAY,CACpC,SAAQ,OAAO;CAIjB,MAAM,SAAS,oBAAoB,WAAW,IAAI,OAAO,KAAK,CAAC,CAAC,UAAU,QAAQ;AAClF,KAAI,CAAC,OAAO,QACX;AAOD,KAJuB,OAAO,OAAOC,oBAAoC,MAAM,CAAC,CAAC,MAAM,UACtF,QAAQ,MAAM,YAAY,CAC1B,CAGA,QAAO,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,IAAI,OAAuB;AAO1C,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 repository_d_exports {
2
+ export { id };
3
+ }
4
+ declare function id(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,EAAA,CAAG,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({ id: () => id });
4
+ const MIN_LENGTH = 4;
5
+ const MAX_LENGTH = 63;
6
+ function id(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 id(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,GAAG,OAAuB;CACzC,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 { id, variationID };
3
+ }
4
+ declare function id(input: string): string;
5
+ declare const variationID: typeof id;
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,EAAA,CAAG,KAAA;AAAA,cAiBN,WAAA,SAAW,EAAA"}
@@ -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
+ id: () => id,
5
+ variationID: () => variationID
6
+ });
7
+ function id(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 variationID = id;
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 id(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 variationID = id\n"],"mappings":";;;;;;AAAA,SAAgB,GAAG,OAAuB;CACzC,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,cAAc"}
@@ -0,0 +1,7 @@
1
+ declare namespace widgetModel_d_exports {
2
+ export { id };
3
+ }
4
+ declare function id(input: string): string;
5
+ //#endregion
6
+ export { widgetModel_d_exports };
7
+ //# sourceMappingURL=widgetModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetModel.d.ts","names":[],"sources":["../../src/helpers/widgetModel.ts"],"mappings":";;;iBAAgB,EAAA,CAAG,KAAA"}
@@ -0,0 +1,13 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region src/helpers/widgetModel.ts
3
+ var widgetModel_exports = /* @__PURE__ */ __exportAll({ id: () => id });
4
+ function id(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 { widgetModel_exports };
12
+
13
+ //# sourceMappingURL=widgetModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetModel.js","names":[],"sources":["../../src/helpers/widgetModel.ts"],"sourcesContent":["export function id(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,GAAG,OAAuB;CACzC,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"}
package/dist/index.d.ts CHANGED
@@ -50,9 +50,12 @@ import { LegacyContentCtx, defaultCtx, getFieldCtx } from "./content/codec/legac
50
50
  import { contentPath_d_exports } from "./helpers/contentPath.js";
51
51
  import { customTypeModel_d_exports } from "./helpers/customTypeModel.js";
52
52
  import { documentContent_d_exports } from "./helpers/documentContent.js";
53
+ import { repository_d_exports } from "./helpers/repository.js";
53
54
  import { sliceContent_d_exports } from "./helpers/sliceContent.js";
55
+ import { sliceModel_d_exports } from "./helpers/sliceModel.js";
56
+ import { widgetModel_d_exports } from "./helpers/widgetModel.js";
54
57
  import { withDefaultContent_d_exports } from "./helpers/withDefaultContent.js";
55
58
  import { imageContent_d_exports } from "./helpers/imageContent.js";
56
59
  import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
57
60
  import { TraverseSliceContentWithModelFunction, TraverseWidgetContentWithModelFunction, traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
58
- 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, 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, 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, widgetModel_d_exports as widgetModel, 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 { repository_exports } from "./helpers/repository.js";
12
+ import { sliceModel_exports } from "./helpers/sliceModel.js";
13
+ import { widgetModel_exports } from "./helpers/widgetModel.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, 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, widgetModel_exports as widgetModel, withDefaultContent_exports as withDefaultContent };