@prismicio/types-internal 4.2.0-pr.15.41d45dd → 4.2.0-pr.15.8f26a93

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 (35) hide show
  1. package/dist/helpers/customTypeModel.d.ts +2 -1
  2. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  3. package/dist/helpers/customTypeModel.js +6 -0
  4. package/dist/helpers/customTypeModel.js.map +1 -1
  5. package/dist/helpers/documentContent.d.ts +2 -2
  6. package/dist/helpers/documentContent.d.ts.map +1 -1
  7. package/dist/helpers/documentContent.js +3 -3
  8. package/dist/helpers/documentContent.js.map +1 -1
  9. package/dist/helpers/fieldModel.d.ts +7 -0
  10. package/dist/helpers/fieldModel.d.ts.map +1 -0
  11. package/dist/helpers/{widgetModel.js → fieldModel.js} +5 -5
  12. package/dist/helpers/fieldModel.js.map +1 -0
  13. package/dist/helpers/repository.d.ts +2 -2
  14. package/dist/helpers/repository.d.ts.map +1 -1
  15. package/dist/helpers/repository.js +2 -2
  16. package/dist/helpers/repository.js.map +1 -1
  17. package/dist/helpers/sliceModel.d.ts +3 -3
  18. package/dist/helpers/sliceModel.d.ts.map +1 -1
  19. package/dist/helpers/sliceModel.js +4 -4
  20. package/dist/helpers/sliceModel.js.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +2 -2
  23. package/dist/io-ts.d.ts +444 -444
  24. package/dist/io-ts.d.ts.map +1 -1
  25. package/dist/model/widget.d.ts +6 -6
  26. package/package.json +1 -1
  27. package/src/helpers/customTypeModel.ts +16 -0
  28. package/src/helpers/documentContent.ts +1 -1
  29. package/src/helpers/{widgetModel.ts → fieldModel.ts} +1 -1
  30. package/src/helpers/repository.ts +1 -1
  31. package/src/helpers/sliceModel.ts +2 -2
  32. package/src/index.ts +1 -1
  33. package/dist/helpers/widgetModel.d.ts +0 -7
  34. package/dist/helpers/widgetModel.d.ts.map +0 -1
  35. package/dist/helpers/widgetModel.js.map +0 -1
@@ -3,12 +3,13 @@ import { DynamicCustomTypeModel, StaticCustomTypeModel, StaticCustomTypeModelTab
3
3
 
4
4
  //#region src/helpers/customTypeModel.d.ts
5
5
  declare namespace customTypeModel_d_exports {
6
- export { collectSharedSlices, filterMissingSharedSlices, flatten, toStatic };
6
+ export { collectSharedSlices, filterMissingSharedSlices, flatten, serializeID, toStatic };
7
7
  }
8
8
  declare function toStatic(customType: DynamicCustomTypeModel, sharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>): StaticCustomTypeModel;
9
9
  declare function flatten(customType: StaticCustomTypeModel): StaticCustomTypeModelTab;
10
10
  declare function collectSharedSlices(customType: StaticCustomTypeModel): Record<string, SharedSliceModel>;
11
11
  declare function filterMissingSharedSlices<TCustomType extends StaticCustomTypeModel | DynamicCustomTypeModel>(customType: TCustomType, sharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>): TCustomType;
12
+ declare function serializeID(input: string): string;
12
13
  //#endregion
13
14
  export { customTypeModel_d_exports };
14
15
  //# sourceMappingURL=customTypeModel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;;;iBAOgB,QAAA,CACf,UAAA,EAAY,sBAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,qBAAA;AAAA,iBAwCa,OAAA,CAAQ,UAAA,EAAY,qBAAA,GAAwB,wBAAA;AAAA,iBAI5C,mBAAA,CACf,UAAA,EAAY,qBAAA,GACV,MAAA,SAAe,gBAAA;AAAA,iBAiBF,yBAAA,qBACK,qBAAA,GAAwB,sBAAA,CAAA,CAE5C,UAAA,EAAY,WAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,WAAA"}
1
+ {"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;;;iBAOgB,QAAA,CACf,UAAA,EAAY,sBAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,qBAAA;AAAA,iBAwCa,OAAA,CAAQ,UAAA,EAAY,qBAAA,GAAwB,wBAAA;AAAA,iBAI5C,mBAAA,CACf,UAAA,EAAY,qBAAA,GACV,MAAA,SAAe,gBAAA;AAAA,iBAiBF,yBAAA,qBACK,qBAAA,GAAwB,sBAAA,CAAA,CAE5C,UAAA,EAAY,WAAA,EACZ,YAAA,EAAc,GAAA,SAAY,gBAAA,IAAoB,MAAA,SAAe,gBAAA,IAC3D,WAAA;AAAA,iBAuCa,WAAA,CAAY,KAAA"}
@@ -4,6 +4,7 @@ var customTypeModel_exports = /* @__PURE__ */ __exportAll({
4
4
  collectSharedSlices: () => collectSharedSlices,
5
5
  filterMissingSharedSlices: () => filterMissingSharedSlices,
6
6
  flatten: () => flatten,
7
+ serializeID: () => serializeID,
7
8
  toStatic: () => toStatic
8
9
  });
9
10
  function toStatic(customType, sharedSlices) {
@@ -79,6 +80,11 @@ function filterMissingSharedSlices(customType, sharedSlices) {
79
80
  json
80
81
  };
81
82
  }
83
+ function serializeID(input) {
84
+ const normalized = input.trim().normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
85
+ if (normalized.length === 0) throw new Error(`Cannot serialize "${input}": result is empty.`);
86
+ return normalized;
87
+ }
82
88
  //#endregion
83
89
  export { collectSharedSlices, customTypeModel_exports, flatten };
84
90
 
@@ -1 +1 @@
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"],"mappings":";;;;;;;;AAOA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,EAAE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Q,aAAa,CAAC;AAEnF,MAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,KAAK,EAAE;EAC5D,MAAM,UAAsB,EAAE;AAC9B,OAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,IAAI,CAC9C,SAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAAwD,EAAE;AAChE,SAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,CAAC,CACrE,KAAI,MAAM,SAAS;SACd,gBAAgB,IAAI,GAAG,CAC1B,SAAQ,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,MAA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Q,IAAI,CAC9C,SAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAAwD,EAAE;AAChE,SAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,CAAC,CACrE,KAAI,MAAM,SAAS;SACd,gBAAgB,IAAI,GAAG,CAC1B,SAAQ,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;;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, uid };
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,7 +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
+ declare function serializeUID(input: string): string;
19
19
  //#endregion
20
20
  export { documentContent_d_exports };
21
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;AAAA,iBAMrC,GAAA,CAAI,KAAA"}
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,8 +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,
17
- uid: () => uid
16
+ serializeUID: () => serializeUID,
17
+ toLegacy: () => toLegacy
18
18
  });
19
19
  function collectWidgets(document, test) {
20
20
  const collected = {};
@@ -59,7 +59,7 @@ function toLegacy(document) {
59
59
  ...keys
60
60
  };
61
61
  }
62
- function uid(input) {
62
+ function serializeUID(input) {
63
63
  return input.replace(/ /g, "-").normalize("NFD").replace(/\p{M}/gu, "").replace(/[^\p{L}\d_.-]/gu, "").toLowerCase();
64
64
  }
65
65
  //#endregion
@@ -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\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"}
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 serializeUID(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;C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AS,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"}
@@ -1,13 +1,13 @@
1
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) {
2
+ //#region src/helpers/fieldModel.ts
3
+ var fieldModel_exports = /* @__PURE__ */ __exportAll({ serializeID: () => serializeID });
4
+ function serializeID(input) {
5
5
  const tokens = input.trim().normalize("NFD").replace(/\p{M}/gu, "").split(/[^A-Za-z0-9]+/).filter(Boolean);
6
6
  if (tokens.length === 0) throw new Error(`Cannot serialize "${input}": result is empty.`);
7
7
  const [first, ...rest] = tokens;
8
8
  return first.toLowerCase() + rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("");
9
9
  }
10
10
  //#endregion
11
- export { widgetModel_exports };
11
+ export { fieldModel_exports };
12
12
 
13
- //# sourceMappingURL=widgetModel.js.map
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"}
@@ -1,7 +1,7 @@
1
1
  declare namespace repository_d_exports {
2
- export { id };
2
+ export { serializeID };
3
3
  }
4
- declare function id(input: string): string;
4
+ declare function serializeID(input: string): string;
5
5
  //#endregion
6
6
  export { repository_d_exports };
7
7
  //# sourceMappingURL=repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/helpers/repository.ts"],"mappings":";;;iBAGgB,EAAA,CAAG,KAAA"}
1
+ {"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/helpers/repository.ts"],"mappings":";;;iBAGgB,WAAA,CAAY,KAAA"}
@@ -1,9 +1,9 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  //#region src/helpers/repository.ts
3
- var repository_exports = /* @__PURE__ */ __exportAll({ id: () => id });
3
+ var repository_exports = /* @__PURE__ */ __exportAll({ serializeID: () => serializeID });
4
4
  const MIN_LENGTH = 4;
5
5
  const MAX_LENGTH = 63;
6
- function id(input) {
6
+ function serializeID(input) {
7
7
  const normalized = input.trim().normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
8
8
  const truncated = normalized.length > MAX_LENGTH ? normalized.slice(0, MAX_LENGTH).replace(/-+$/, "") : normalized;
9
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.`);
@@ -1 +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"}
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"}
@@ -1,8 +1,8 @@
1
1
  declare namespace sliceModel_d_exports {
2
- export { id, variationID };
2
+ export { serializeID, serializeVariationID };
3
3
  }
4
- declare function id(input: string): string;
5
- declare const variationID: typeof id;
4
+ declare function serializeID(input: string): string;
5
+ declare const serializeVariationID: typeof serializeID;
6
6
  //#endregion
7
7
  export { sliceModel_d_exports };
8
8
  //# sourceMappingURL=sliceModel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sliceModel.d.ts","names":[],"sources":["../../src/helpers/sliceModel.ts"],"mappings":";;;iBAAgB,EAAA,CAAG,KAAA;AAAA,cAiBN,WAAA,SAAW,EAAA"}
1
+ {"version":3,"file":"sliceModel.d.ts","names":[],"sources":["../../src/helpers/sliceModel.ts"],"mappings":";;;iBAAgB,WAAA,CAAY,KAAA;AAAA,cAiBf,oBAAA,SAAoB,WAAA"}
@@ -1,15 +1,15 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  //#region src/helpers/sliceModel.ts
3
3
  var sliceModel_exports = /* @__PURE__ */ __exportAll({
4
- id: () => id,
5
- variationID: () => variationID
4
+ serializeID: () => serializeID,
5
+ serializeVariationID: () => serializeVariationID
6
6
  });
7
- function id(input) {
7
+ function serializeID(input) {
8
8
  const tokens = input.trim().normalize("NFD").replace(/\p{M}/gu, "").split(/[^A-Za-z0-9]+/).filter(Boolean);
9
9
  if (tokens.length === 0) throw new Error(`Cannot serialize "${input}": result is empty.`);
10
10
  return tokens.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("");
11
11
  }
12
- const variationID = id;
12
+ const serializeVariationID = serializeID;
13
13
  //#endregion
14
14
  export { sliceModel_exports };
15
15
 
@@ -1 +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"}
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
@@ -50,12 +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 { fieldModel_d_exports } from "./helpers/fieldModel.js";
53
54
  import { repository_d_exports } from "./helpers/repository.js";
54
55
  import { sliceContent_d_exports } from "./helpers/sliceContent.js";
55
56
  import { sliceModel_d_exports } from "./helpers/sliceModel.js";
56
- import { widgetModel_d_exports } from "./helpers/widgetModel.js";
57
57
  import { withDefaultContent_d_exports } from "./helpers/withDefaultContent.js";
58
58
  import { imageContent_d_exports } from "./helpers/imageContent.js";
59
59
  import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
60
60
  import { TraverseSliceContentWithModelFunction, TraverseWidgetContentWithModelFunction, traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
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 };
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,10 +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";
11
12
  import { repository_exports } from "./helpers/repository.js";
12
13
  import { sliceModel_exports } from "./helpers/sliceModel.js";
13
- import { widgetModel_exports } from "./helpers/widgetModel.js";
14
14
  import { withDefaultContent_exports } from "./helpers/withDefaultContent.js";
15
15
  import { imageContent_exports } from "./helpers/imageContent.js";
16
16
  import { traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
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 };
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 };