@prismicio/types-internal 4.7.0-pr.28.255f9f9 → 4.7.0-pr.36.885e913

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 (49) hide show
  1. package/dist/content/codec/legacyContentCtx.d.ts.map +1 -1
  2. package/dist/content/codec/legacyContentCtx.js +5 -1
  3. package/dist/content/codec/legacyContentCtx.js.map +1 -1
  4. package/dist/helpers/customTypeModel.d.ts +2 -2
  5. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  6. package/dist/helpers/customTypeModel.js +1 -1
  7. package/dist/helpers/customTypeModel.js.map +1 -1
  8. package/dist/helpers/documentContent.d.ts +4 -3
  9. package/dist/helpers/documentContent.d.ts.map +1 -1
  10. package/dist/helpers/documentContent.js +12 -15
  11. package/dist/helpers/documentContent.js.map +1 -1
  12. package/dist/helpers/sliceContent.d.ts +4 -2
  13. package/dist/helpers/sliceContent.d.ts.map +1 -1
  14. package/dist/helpers/sliceContent.js +11 -2
  15. package/dist/helpers/sliceContent.js.map +1 -1
  16. package/dist/helpers/traverseContent.d.ts +2 -2
  17. package/dist/helpers/traverseContent.d.ts.map +1 -1
  18. package/dist/helpers/traverseContent.js +6 -3
  19. package/dist/helpers/traverseContent.js.map +1 -1
  20. package/dist/index.d.ts +6 -6
  21. package/dist/index.js +2 -2
  22. package/dist/io-ts.d.ts +187 -137
  23. package/dist/io-ts.d.ts.map +1 -1
  24. package/dist/io-ts.js +5 -3
  25. package/dist/io-ts.js.map +1 -1
  26. package/dist/model/customType.d.ts +5 -1
  27. package/dist/model/customType.d.ts.map +1 -1
  28. package/dist/model/customType.js.map +1 -1
  29. package/dist/model/link.d.ts +27 -1
  30. package/dist/model/link.d.ts.map +1 -1
  31. package/dist/model/link.js +3 -3
  32. package/dist/model/link.js.map +1 -1
  33. package/dist/model/table.d.ts +3 -2
  34. package/dist/model/table.d.ts.map +1 -1
  35. package/dist/zod4.d.ts +48 -1
  36. package/dist/zod4.d.ts.map +1 -1
  37. package/dist/zod4.js +5 -3
  38. package/dist/zod4.js.map +1 -1
  39. package/package.json +4 -1
  40. package/src/content/codec/legacyContentCtx.ts +7 -1
  41. package/src/helpers/customTypeModel.ts +3 -2
  42. package/src/helpers/documentContent.ts +21 -28
  43. package/src/helpers/sliceContent.ts +16 -0
  44. package/src/helpers/traverseContent.ts +8 -5
  45. package/src/index.ts +9 -3
  46. package/src/io-ts.ts +7 -1
  47. package/src/model/customType.ts +5 -0
  48. package/src/model/link.ts +4 -2
  49. package/src/zod4.ts +7 -1
@@ -1 +1 @@
1
- {"version":3,"file":"legacyContentCtx.d.ts","names":[],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"mappings":";;;UAIU;EACT;EACA;EACA,YAAY;EACZ,cAAc;EACd,WAAW,YAAY;EACvB,UAAU;;cAGE;EACZ;EACA;EACA;EACA;EACA,WAAW;EACX,YAAY;EACZ,UAAU,YAAY;EACtB,SAAS;EACT;EACA,aAAa;EACb;EAEA,cACC,UACA,YACA,aACA,WACA,UACA,WACE;EAmBH,eAAe,qBAAqB;;UAS3B;EACT;EACA;EACA,KAAK;EACL,WAAW;;iBAGI,cACf,UACA,YAAY,iBACZ,KACA,YACE,oBAAoB;iBAYP,WACf,aACA,WAAU,YAAY,mBACtB,UAAS,sBACP"}
1
+ {"version":3,"file":"legacyContentCtx.d.ts","names":[],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"mappings":";;;UASU;EACT;EACA;EACA,YAAY;EACZ,cAAc;EACd,WAAW,YAAY;EACvB,UAAU;;cAGE;EACZ;EACA;EACA;EACA;EACA,WAAW;EACX,YAAY;EACZ,UAAU,YAAY;EACtB,SAAS;EACT;EACA,aAAa;EACb;EAEA,cACC,UACA,YACA,aACA,WACA,UACA,WACE;EAoBH,eAAe,qBAAqB;;UAS3B;EACT;EACA;EACA,KAAK;EACL,WAAW;;iBAGI,cACf,UACA,YAAY,iBACZ,KACA,YACE,oBAAoB;iBAYP,WACf,aACA,WAAU,YAAY,mBACtB,UAAS,sBACP"}
@@ -1,4 +1,8 @@
1
+ import { v5 } from "uuid";
1
2
  //#region src/content/codec/legacyContentCtx.ts
3
+ function uuidV5ForPath(path) {
4
+ return v5(JSON.stringify(path), v5.URL);
5
+ }
2
6
  var LegacyContentCtx = class LegacyContentCtx {
3
7
  fieldKey;
4
8
  prefixedKey;
@@ -24,7 +28,7 @@ var LegacyContentCtx = class LegacyContentCtx {
24
28
  this.keyOfType = `${prefixedKey}_TYPE`;
25
29
  this.keyOfKey = `${prefixedContentKey}_KEY`;
26
30
  this.fieldType = this.allTypes.get(this.prefixedKey);
27
- this.fieldContentKey = this.allKeys.get(prefixedContentKey) ?? crypto.randomUUID();
31
+ this.fieldContentKey = this.allKeys.get(prefixedContentKey) ?? uuidV5ForPath([...this.contentPath, this.contentKey]);
28
32
  }
29
33
  withContentKey(contentKey) {
30
34
  return new LegacyContentCtx({
@@ -1 +1 @@
1
- {"version":3,"file":"legacyContentCtx.js","names":[],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"sourcesContent":["import type { z } from \"zod/mini\"\n\nimport type { FieldOrSliceType } from \"../../model/widget\"\n\ninterface LegacyContentCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tfieldPath?: Array<string>\n\tcontentPath?: Array<string>\n\tallTypes?: Map<string, FieldOrSliceType>\n\tallKeys?: Map<string, string>\n}\n\nexport class LegacyContentCtx {\n\tfieldKey: string\n\tprefixedKey: string\n\tkeyOfType: string\n\tkeyOfKey: string\n\tfieldPath: Array<string>\n\tfieldType?: FieldOrSliceType | undefined\n\tallTypes: Map<string, FieldOrSliceType>\n\tallKeys: Map<string, string>\n\tcontentKey: string\n\tcontentPath: Array<string>\n\tfieldContentKey: string\n\n\tconstructor({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath,\n\t\tfieldPath,\n\t\tallTypes,\n\t\tallKeys,\n\t}: LegacyContentCtxParams) {\n\t\tthis.fieldKey = fieldKey\n\t\tthis.contentKey = contentKey || fieldKey\n\t\tthis.fieldPath = fieldPath || []\n\t\tthis.contentPath = contentPath || []\n\t\tthis.allTypes = allTypes || new Map<string, FieldOrSliceType>()\n\t\tthis.allKeys = allKeys || new Map<string, string>()\n\n\t\tconst prefixedKey = Array.of(this.fieldPath, [this.fieldKey]).flat().join(\".\")\n\n\t\tconst prefixedContentKey = Array.of(this.contentPath, [this.contentKey]).flat().join(\".\")\n\n\t\tthis.prefixedKey = prefixedKey\n\t\tthis.keyOfType = `${prefixedKey}_TYPE`\n\t\tthis.keyOfKey = `${prefixedContentKey}_KEY`\n\t\tthis.fieldType = this.allTypes.get(this.prefixedKey)\n\t\tthis.fieldContentKey = this.allKeys.get(prefixedContentKey) ?? crypto.randomUUID()\n\t}\n\n\twithContentKey(contentKey: string): LegacyContentCtx {\n\t\treturn new LegacyContentCtx({\n\t\t\t...this,\n\t\t\tcontentPath: [...this.contentPath, this.contentKey],\n\t\t\tcontentKey,\n\t\t})\n\t}\n}\n\ninterface GetFieldCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tctx: LegacyContentCtx\n\tprefixes?: Array<string>\n}\n\nexport function getFieldCtx({\n\tfieldKey,\n\tcontentKey: contentKeyParam,\n\tctx,\n\tprefixes,\n}: GetFieldCtxParams): LegacyContentCtx {\n\tconst contentKey = contentKeyParam || fieldKey\n\treturn new LegacyContentCtx({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath: [...ctx.contentPath, ctx.contentKey, ...(prefixes || [])],\n\t\tfieldPath: [...ctx.fieldPath, ctx.fieldKey, ...(prefixes || [])],\n\t\tallTypes: ctx.allTypes,\n\t\tallKeys: ctx.allKeys,\n\t})\n}\n\nexport function defaultCtx(\n\tkey: string,\n\tallTypes: Map<string, FieldOrSliceType> = new Map(),\n\tallKeys: Map<string, string> = new Map(),\n): LegacyContentCtx {\n\treturn new LegacyContentCtx({\n\t\tfieldKey: key,\n\t\tcontentKey: key,\n\t\tcontentPath: [],\n\t\tfieldPath: [],\n\t\tallTypes,\n\t\tallKeys,\n\t})\n}\n\ntype WithTypes<T> = {\n\tkeys: Record<string, string>\n\ttypes: Record<string, FieldOrSliceType>\n\tcontent: T\n}\n\nexport type LegacyCodec<A, LegacyRaw, AllowUndefined extends boolean = false> = {\n\tname: string\n\tis(input: unknown): input is A\n\ttoContent(\n\t\tinput: unknown,\n\t): z.core.util.SafeParseSuccess<A> | z.core.util.SafeParseError<LegacyRaw | unknown>\n\tfromContent(\n\t\tvalue: A,\n\t): AllowUndefined extends false ? WithTypes<LegacyRaw> : WithTypes<LegacyRaw> | undefined\n}\n"],"mappings":";AAaA,IAAa,mBAAb,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,EACX,UACA,YACA,aACA,WACA,UACA,WAC0B;EAC1B,KAAK,WAAW;EAChB,KAAK,aAAa,cAAc;EAChC,KAAK,YAAY,aAAa,CAAC;EAC/B,KAAK,cAAc,eAAe,CAAC;EACnC,KAAK,WAAW,4BAAY,IAAI,IAA8B;EAC9D,KAAK,UAAU,2BAAW,IAAI,IAAoB;EAElD,MAAM,cAAc,MAAM,GAAG,KAAK,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EAE7E,MAAM,qBAAqB,MAAM,GAAG,KAAK,aAAa,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EAExF,KAAK,cAAc;EACnB,KAAK,YAAY,GAAG,YAAY;EAChC,KAAK,WAAW,GAAG,mBAAmB;EACtC,KAAK,YAAY,KAAK,SAAS,IAAI,KAAK,WAAW;EACnD,KAAK,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,OAAO,WAAW;CAClF;CAEA,eAAe,YAAsC;EACpD,OAAO,IAAI,iBAAiB;GAC3B,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,aAAa,KAAK,UAAU;GAClD;EACD,CAAC;CACF;AACD;AASA,SAAgB,YAAY,EAC3B,UACA,YAAY,iBACZ,KACA,YACuC;CAEvC,OAAO,IAAI,iBAAiB;EAC3B;EACA,YAHkB,mBAAmB;EAIrC,aAAa;GAAC,GAAG,IAAI;GAAa,IAAI;GAAY,GAAI,YAAY,CAAC;EAAE;EACrE,WAAW;GAAC,GAAG,IAAI;GAAW,IAAI;GAAU,GAAI,YAAY,CAAC;EAAE;EAC/D,UAAU,IAAI;EACd,SAAS,IAAI;CACd,CAAC;AACF;AAEA,SAAgB,WACf,KACA,2BAA0C,IAAI,IAAI,GAClD,0BAA+B,IAAI,IAAI,GACpB;CACnB,OAAO,IAAI,iBAAiB;EAC3B,UAAU;EACV,YAAY;EACZ,aAAa,CAAC;EACd,WAAW,CAAC;EACZ;EACA;CACD,CAAC;AACF"}
1
+ {"version":3,"file":"legacyContentCtx.js","names":["uuidV5"],"sources":["../../../src/content/codec/legacyContentCtx.ts"],"sourcesContent":["import { v5 as uuidV5 } from \"uuid\"\nimport type { z } from \"zod/mini\"\n\nimport type { FieldOrSliceType } from \"../../model/widget\"\n\nfunction uuidV5ForPath(path: string[]): string {\n\treturn uuidV5(JSON.stringify(path), uuidV5.URL)\n}\n\ninterface LegacyContentCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tfieldPath?: Array<string>\n\tcontentPath?: Array<string>\n\tallTypes?: Map<string, FieldOrSliceType>\n\tallKeys?: Map<string, string>\n}\n\nexport class LegacyContentCtx {\n\tfieldKey: string\n\tprefixedKey: string\n\tkeyOfType: string\n\tkeyOfKey: string\n\tfieldPath: Array<string>\n\tfieldType?: FieldOrSliceType | undefined\n\tallTypes: Map<string, FieldOrSliceType>\n\tallKeys: Map<string, string>\n\tcontentKey: string\n\tcontentPath: Array<string>\n\tfieldContentKey: string\n\n\tconstructor({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath,\n\t\tfieldPath,\n\t\tallTypes,\n\t\tallKeys,\n\t}: LegacyContentCtxParams) {\n\t\tthis.fieldKey = fieldKey\n\t\tthis.contentKey = contentKey || fieldKey\n\t\tthis.fieldPath = fieldPath || []\n\t\tthis.contentPath = contentPath || []\n\t\tthis.allTypes = allTypes || new Map<string, FieldOrSliceType>()\n\t\tthis.allKeys = allKeys || new Map<string, string>()\n\n\t\tconst prefixedKey = Array.of(this.fieldPath, [this.fieldKey]).flat().join(\".\")\n\n\t\tconst prefixedContentKey = Array.of(this.contentPath, [this.contentKey]).flat().join(\".\")\n\n\t\tthis.prefixedKey = prefixedKey\n\t\tthis.keyOfType = `${prefixedKey}_TYPE`\n\t\tthis.keyOfKey = `${prefixedContentKey}_KEY`\n\t\tthis.fieldType = this.allTypes.get(this.prefixedKey)\n\t\tthis.fieldContentKey =\n\t\t\tthis.allKeys.get(prefixedContentKey) ?? uuidV5ForPath([...this.contentPath, this.contentKey])\n\t}\n\n\twithContentKey(contentKey: string): LegacyContentCtx {\n\t\treturn new LegacyContentCtx({\n\t\t\t...this,\n\t\t\tcontentPath: [...this.contentPath, this.contentKey],\n\t\t\tcontentKey,\n\t\t})\n\t}\n}\n\ninterface GetFieldCtxParams {\n\tfieldKey: string\n\tcontentKey?: string\n\tctx: LegacyContentCtx\n\tprefixes?: Array<string>\n}\n\nexport function getFieldCtx({\n\tfieldKey,\n\tcontentKey: contentKeyParam,\n\tctx,\n\tprefixes,\n}: GetFieldCtxParams): LegacyContentCtx {\n\tconst contentKey = contentKeyParam || fieldKey\n\treturn new LegacyContentCtx({\n\t\tfieldKey,\n\t\tcontentKey,\n\t\tcontentPath: [...ctx.contentPath, ctx.contentKey, ...(prefixes || [])],\n\t\tfieldPath: [...ctx.fieldPath, ctx.fieldKey, ...(prefixes || [])],\n\t\tallTypes: ctx.allTypes,\n\t\tallKeys: ctx.allKeys,\n\t})\n}\n\nexport function defaultCtx(\n\tkey: string,\n\tallTypes: Map<string, FieldOrSliceType> = new Map(),\n\tallKeys: Map<string, string> = new Map(),\n): LegacyContentCtx {\n\treturn new LegacyContentCtx({\n\t\tfieldKey: key,\n\t\tcontentKey: key,\n\t\tcontentPath: [],\n\t\tfieldPath: [],\n\t\tallTypes,\n\t\tallKeys,\n\t})\n}\n\ntype WithTypes<T> = {\n\tkeys: Record<string, string>\n\ttypes: Record<string, FieldOrSliceType>\n\tcontent: T\n}\n\nexport type LegacyCodec<A, LegacyRaw, AllowUndefined extends boolean = false> = {\n\tname: string\n\tis(input: unknown): input is A\n\ttoContent(\n\t\tinput: unknown,\n\t): z.core.util.SafeParseSuccess<A> | z.core.util.SafeParseError<LegacyRaw | unknown>\n\tfromContent(\n\t\tvalue: A,\n\t): AllowUndefined extends false ? WithTypes<LegacyRaw> : WithTypes<LegacyRaw> | undefined\n}\n"],"mappings":";;AAKA,SAAS,cAAc,MAAwB;CAC9C,OAAOA,GAAO,KAAK,UAAU,IAAI,GAAGA,GAAO,GAAG;AAC/C;AAWA,IAAa,mBAAb,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,EACX,UACA,YACA,aACA,WACA,UACA,WAC0B;EAC1B,KAAK,WAAW;EAChB,KAAK,aAAa,cAAc;EAChC,KAAK,YAAY,aAAa,CAAC;EAC/B,KAAK,cAAc,eAAe,CAAC;EACnC,KAAK,WAAW,4BAAY,IAAI,IAA8B;EAC9D,KAAK,UAAU,2BAAW,IAAI,IAAoB;EAElD,MAAM,cAAc,MAAM,GAAG,KAAK,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EAE7E,MAAM,qBAAqB,MAAM,GAAG,KAAK,aAAa,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EAExF,KAAK,cAAc;EACnB,KAAK,YAAY,GAAG,YAAY;EAChC,KAAK,WAAW,GAAG,mBAAmB;EACtC,KAAK,YAAY,KAAK,SAAS,IAAI,KAAK,WAAW;EACnD,KAAK,kBACJ,KAAK,QAAQ,IAAI,kBAAkB,KAAK,cAAc,CAAC,GAAG,KAAK,aAAa,KAAK,UAAU,CAAC;CAC9F;CAEA,eAAe,YAAsC;EACpD,OAAO,IAAI,iBAAiB;GAC3B,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,aAAa,KAAK,UAAU;GAClD;EACD,CAAC;CACF;AACD;AASA,SAAgB,YAAY,EAC3B,UACA,YAAY,iBACZ,KACA,YACuC;CAEvC,OAAO,IAAI,iBAAiB;EAC3B;EACA,YAHkB,mBAAmB;EAIrC,aAAa;GAAC,GAAG,IAAI;GAAa,IAAI;GAAY,GAAI,YAAY,CAAC;EAAE;EACrE,WAAW;GAAC,GAAG,IAAI;GAAW,IAAI;GAAU,GAAI,YAAY,CAAC;EAAE;EAC/D,UAAU,IAAI;EACd,SAAS,IAAI;CACd,CAAC;AACF;AAEA,SAAgB,WACf,KACA,2BAA0C,IAAI,IAAI,GAClD,0BAA+B,IAAI,IAAI,GACpB;CACnB,OAAO,IAAI,iBAAiB;EAC3B,UAAU;EACV,YAAY;EACZ,aAAa,CAAC;EACd,WAAW,CAAC;EACZ;EACA;CACD,CAAC;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { SharedSliceModel } from "../model/slice.js";
2
- import { DynamicCustomTypeModel, DynamicCustomTypeModelTab, StaticCustomTypeModel, StaticCustomTypeModelTab } from "../model/customType.js";
2
+ import { DynamicCustomTypeModel, DynamicCustomTypeModelTab, FlattenedStaticCustomTypeModel, StaticCustomTypeModel, StaticCustomTypeModelTab } from "../model/customType.js";
3
3
  declare namespace customTypeModel_d_exports {
4
4
  export { collectSharedSlices, filterMissingSharedSlices, flatten, serializeID, toDynamic, toStatic };
5
5
  }
@@ -7,7 +7,7 @@ declare function toStatic(customType: DynamicCustomTypeModel, sharedSlices: Map<
7
7
  declare function toDynamic(customType: StaticCustomTypeModel): DynamicCustomTypeModel;
8
8
  declare function flatten(customType: StaticCustomTypeModel): StaticCustomTypeModelTab;
9
9
  declare function flatten(customType: DynamicCustomTypeModel): DynamicCustomTypeModelTab;
10
- declare function collectSharedSlices(customType: StaticCustomTypeModel): Record<string, SharedSliceModel>;
10
+ declare function collectSharedSlices(customType: StaticCustomTypeModel | FlattenedStaticCustomTypeModel): Record<string, SharedSliceModel>;
11
11
  declare function filterMissingSharedSlices<TCustomType extends StaticCustomTypeModel | DynamicCustomTypeModel>(customType: TCustomType, sharedSlices: Map<string, SharedSliceModel> | Record<string, SharedSliceModel>): TCustomType;
12
12
  declare function serializeID(input: string): string;
13
13
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;iBAQgB,SACf,YAAY,wBACZ,cAAc,YAAY,oBAAoB,eAAe,oBAC3D;iBAwCa,UAAU,YAAY,wBAAwB;iBAkC9C,QAAQ,YAAY,wBAAwB;iBAC5C,QAAQ,YAAY,yBAAyB;iBAO7C,oBACf,YAAY,wBACV,eAAe;iBAiBF,0BACf,oBAAoB,wBAAwB,wBAE5C,YAAY,aACZ,cAAc,YAAY,oBAAoB,eAAe,oBAC3D;iBAuCa,YAAY"}
1
+ {"version":3,"file":"customTypeModel.d.ts","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"mappings":";;;;;iBASgB,SACf,YAAY,wBACZ,cAAc,YAAY,oBAAoB,eAAe,oBAC3D;iBAwCa,UAAU,YAAY,wBAAwB;iBAkC9C,QAAQ,YAAY,wBAAwB;iBAC5C,QAAQ,YAAY,yBAAyB;iBAO7C,oBACf,YAAY,wBAAwB,iCAClC,eAAe;iBAiBF,0BACf,oBAAoB,wBAAwB,wBAE5C,YAAY,aACZ,cAAc,YAAY,oBAAoB,eAAe,oBAC3D;iBAuCa,YAAY"}
@@ -73,7 +73,7 @@ function flatten(customType) {
73
73
  }
74
74
  function collectSharedSlices(customType) {
75
75
  const sharedSlices = {};
76
- const flattened = flatten(customType);
76
+ const flattened = "fields" in customType ? customType.fields : flatten(customType);
77
77
  for (const widget of Object.values(flattened)) if (widget.type === "Slices" || widget.type === "Choice") {
78
78
  for (const [id, model] of Object.entries(widget.config?.choices || {})) if (model.type === "SharedSlice") sharedSlices[id] = model;
79
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type {\n\tDynamicCustomTypeModel,\n\tDynamicCustomTypeModelTab,\n\tStaticCustomTypeModel,\n\tStaticCustomTypeModelTab,\n} from \"../model/customType\"\nimport type { DynamicSliceModel, 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 toDynamic(customType: StaticCustomTypeModel): DynamicCustomTypeModel {\n\tconst json: DynamicCustomTypeModel[\"json\"] = {}\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: DynamicCustomTypeModel[\"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, DynamicSliceModel> = {}\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\tchoices[id] = { type: \"SharedSlice\" }\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\nexport function flatten(customType: DynamicCustomTypeModel): DynamicCustomTypeModelTab\nexport function flatten(\n\tcustomType: StaticCustomTypeModel | DynamicCustomTypeModel,\n): StaticCustomTypeModelTab | DynamicCustomTypeModelTab {\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":";;;;;;;;;;AAQA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,CAAC;CAE7C,MAAM,kBACL,wBAAwB,MAAM,eAAe,IAAI,IAAI,OAAO,QAAQ,YAAY,CAAC;CAElF,KAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,IAAI,GAAG;EAC5D,MAAM,UAAiD,CAAC;EACxD,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,GAAG,GAC7C,QAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAA4C,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,CAAC,CAAC,GACpE,IAAI,MAAM,SAAS,eAAe;KACjC,MAAM,cAAc,gBAAgB,IAAI,EAAE;KAC1C,IAAI,aACH,QAAQ,MAAM;IAEhB,OACC,QAAQ,MAAM;IAIhB,QAAQ,OAAO;KACd,GAAG;KACH,QAAQ;MAAE,GAAG,OAAO;MAAQ;KAAQ;IACrC;IACA;GACD,SACC,QAAQ,OAAO;EACjB;EAGD,KAAK,UAAU;CAChB;CAEA,OAAO;EAAE,GAAG;EAAY;CAAK;AAC9B;AAEA,SAAgB,UAAU,YAA2D;CACpF,MAAM,OAAuC,CAAC;CAE9C,KAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,IAAI,GAAG;EAC5D,MAAM,UAAkD,CAAC;EACzD,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAA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wD,CAAC;IAC/D,KAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,WAAW,CAAC,CAAC,GACpE,IAAI,MAAM,SAAS;SACd,gBAAgB,IAAI,EAAE,GACzB,QAAQ,MAAM;IAAA,OAGf,QAAQ,MAAM;IAIhB,QAAQ,OAAO;KACd,GAAG;KACH,QAAQ;MAAE,GAAG,OAAO;MAAQ;KAAQ;IACrC;IACA;GACD,SACC,QAAQ,OAAO;EACjB;EAGD,KAAK,UAAU;CAChB;CAEA,OAAO;EAAE,GAAG;EAAY;CAAK;AAC9B;AAEA,SAAgB,YAAY,OAAuB;CAClD,MAAM,aAAa,MACjB,KAAK,CAAC,CACN,UAAU,KAAK,CAAC,CAChB,QAAQ,WAAW,EAAE,CAAC,CACtB,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE;CAExB,IAAI,WAAW,WAAW,GACzB,MAAM,IAAI,MAAM,qBAAqB,MAAM,oBAAoB;CAGhE,OAAO;AACR"}
1
+ {"version":3,"file":"customTypeModel.js","names":[],"sources":["../../src/helpers/customTypeModel.ts"],"sourcesContent":["import type {\n\tDynamicCustomTypeModel,\n\tDynamicCustomTypeModelTab,\n\tFlattenedStaticCustomTypeModel,\n\tStaticCustomTypeModel,\n\tStaticCustomTypeModelTab,\n} from \"../model/customType\"\nimport type { DynamicSliceModel, 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 toDynamic(customType: StaticCustomTypeModel): DynamicCustomTypeModel {\n\tconst json: DynamicCustomTypeModel[\"json\"] = {}\n\n\tfor (const [tabKey, tab] of Object.entries(customType.json)) {\n\t\tconst tabJSON: DynamicCustomTypeModel[\"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, DynamicSliceModel> = {}\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\tchoices[id] = { type: \"SharedSlice\" }\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\nexport function flatten(customType: DynamicCustomTypeModel): DynamicCustomTypeModelTab\nexport function flatten(\n\tcustomType: StaticCustomTypeModel | DynamicCustomTypeModel,\n): StaticCustomTypeModelTab | DynamicCustomTypeModelTab {\n\treturn Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})\n}\n\nexport function collectSharedSlices(\n\tcustomType: StaticCustomTypeModel | FlattenedStaticCustomTypeModel,\n): Record<string, SharedSliceModel> {\n\tconst sharedSlices: Record<string, SharedSliceModel> = {}\n\n\tconst flattened = \"fields\" in customType ? customType.fields : 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":";;;;;;;;;;AASA,SAAgB,SACf,YACA,cACwB;CACxB,MAAM,OAAsC,CAAC;CAE7C,MAAM,kBACL,wBAAwB,MAAM,eAAe,IAAI,IAAI,OAAO,QAAQ,YAAY,CAAC;CAElF,KAAK,MAAM,CAAC,QAAQ,QAAQ,OAAO,QAAQ,WAAW,IAAI,GAAG;EAC5D,MAAM,UAAiD,CAAC;EACxD,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,GAAG,GAC7C,QAAQ,OAAO,MAAf;GACC,KAAK;GACL,KAAK;IACJ,MAAM,UAA4C,CAAC;IACnD,KAAK,MAAM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O;AACR"}
@@ -1,19 +1,20 @@
1
1
  import { WidgetContent } from "../content/widget.js";
2
2
  import { DocumentContent } from "../content/document.js";
3
- import { StaticCustomTypeModel } from "../model/customType.js";
3
+ import { FlattenedStaticCustomTypeModel, StaticCustomTypeModel } from "../model/customType.js";
4
4
  import { Path } from "./contentPath.js";
5
5
  import { DocumentLegacy } from "../content/legacy/document.js";
6
6
  declare namespace documentContent_d_exports {
7
- export { collectWidgets, fromLegacy, serializeUID, toLegacy };
7
+ export { collectWidgets, fromLegacy, migrateDocument, serializeUID, toLegacy };
8
8
  }
9
9
  declare function collectWidgets<TWidgetContent extends WidgetContent>(document: DocumentContent, test: (content: WidgetContent, args: {
10
10
  path: Path;
11
11
  key: string;
12
12
  apiID: string;
13
13
  }) => content is TWidgetContent): Record<string, TWidgetContent>;
14
+ declare function migrateDocument(document: DocumentContent, model: StaticCustomTypeModel | FlattenedStaticCustomTypeModel): DocumentContent;
14
15
  declare function fromLegacy(legacy: DocumentLegacy, model: StaticCustomTypeModel): DocumentContent | undefined;
15
16
  declare function toLegacy(document: DocumentContent): DocumentLegacy;
16
17
  declare function serializeUID(input: string): string;
17
18
  //#endregion
18
- export { collectWidgets, documentContent_d_exports, fromLegacy, serializeUID, toLegacy };
19
+ export { collectWidgets, documentContent_d_exports, fromLegacy, migrateDocument, serializeUID, toLegacy };
19
20
  //# sourceMappingURL=documentContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":";;;;;;;;iBAkBgB,eAAe,uBAAuB,eACrD,UAAU,iBACV,OACC,SAAS,eACT;EACC,MAAM;EACN;EACA;MAEG,WAAW,iBACd,eAAe;iBAgBF,WACf,QAAQ,gBACR,OAAO,wBACL;iBAwDa,SAAS,UAAU,kBAAkB;iBAMrC,aAAa"}
1
+ {"version":3,"file":"documentContent.d.ts","names":[],"sources":["../../src/helpers/documentContent.ts"],"mappings":";;;;;;;;iBAgBgB,eAAe,uBAAuB,eACrD,UAAU,iBACV,OACC,SAAS,eACT;EACC,MAAM;EACN;EACA;MAEG,WAAW,iBACd,eAAe;iBAgBF,gBACf,UAAU,iBACV,OAAO,wBAAwB,iCAC7B;iBAea,WACf,QAAQ,gBACR,OAAO,wBACL;iBAiCa,SAAS,UAAU,kBAAkB;iBAMrC,aAAa"}
@@ -2,17 +2,17 @@ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { defaultCtx } from "../content/codec/legacyContentCtx.js";
3
3
  import { serialize } from "./contentPath.js";
4
4
  import { collectSharedSlices } from "./customTypeModel.js";
5
- import { isNestableContent } from "../content/nestable.js";
6
5
  import { DocumentLegacySchema } from "../content/legacy/document.js";
7
6
  import { DocumentLegacyCodec } from "../content/codec/document.js";
8
7
  import { FieldOrSliceTypeSchema } from "../model/widget.js";
9
- import { compositeToShared, legacyToShared } from "./sliceContent.js";
8
+ import { migrateSliceItem } from "./sliceContent.js";
10
9
  import { traverseDocumentContent } from "./traverseContent.js";
11
10
  import { z } from "zod/mini";
12
11
  //#region src/helpers/documentContent.ts
13
12
  var documentContent_exports = /* @__PURE__ */ __exportAll({
14
13
  collectWidgets: () => collectWidgets,
15
14
  fromLegacy: () => fromLegacy,
15
+ migrateDocument: () => migrateDocument,
16
16
  serializeUID: () => serializeUID,
17
17
  toLegacy: () => toLegacy
18
18
  });
@@ -24,6 +24,13 @@ function collectWidgets(document, test) {
24
24
  } });
25
25
  return collected;
26
26
  }
27
+ function migrateDocument(document, model) {
28
+ if (Object.values(collectSharedSlices(model)).some((slice) => Boolean(slice.legacyPaths))) return traverseDocumentContent(document, {
29
+ model,
30
+ transformSlice: migrateSliceItem
31
+ });
32
+ return document;
33
+ }
27
34
  function fromLegacy(legacy, model) {
28
35
  const parsed = DocumentLegacySchema.safeParse(legacy);
29
36
  if (!parsed.success) return;
@@ -34,22 +41,12 @@ function fromLegacy(legacy, model) {
34
41
  const parsed = FieldOrSliceTypeSchema.safeParse(value);
35
42
  if (parsed.success) types.set(key.substring(0, key.length - 5), parsed.data);
36
43
  } else if (key.endsWith("_KEY")) {
37
- const parsed = z.uuidv4().safeParse(value);
44
+ const parsed = z.union([z.uuidv4(), z.uuid({ version: "v5" })]).safeParse(value);
38
45
  if (parsed.success) keys.set(key.substring(0, key.length - 4), parsed.data);
39
46
  } else if (!key.endsWith("_POSITION")) widgets[key] = value;
40
47
  const result = DocumentLegacyCodec(defaultCtx("", types, keys)).toContent(widgets);
41
48
  if (!result.success) return;
42
- if (Object.values(collectSharedSlices(model)).some((slice) => Boolean(slice.legacyPaths))) return traverseDocumentContent(result.data, {
43
- model,
44
- transformSlice: ({ content, model }) => {
45
- if (model?.type === "SharedSlice") {
46
- if (content.widget.__TYPE__ === "CompositeSliceContent") return compositeToShared(content, model);
47
- else if (content.widget.__TYPE__ === "GroupContentType" || isNestableContent(content.widget)) return legacyToShared(content, model);
48
- }
49
- return content;
50
- }
51
- });
52
- return result.data;
49
+ return migrateDocument(result.data, model);
53
50
  }
54
51
  function toLegacy(document) {
55
52
  const { content, types, keys } = DocumentLegacyCodec(defaultCtx("")).fromContent(document);
@@ -63,6 +60,6 @@ function serializeUID(input) {
63
60
  return input.replace(/ /g, "-").normalize("NFD").replace(/\p{M}/gu, "").replace(/[^\p{L}\d_.-]/gu, "").toLowerCase();
64
61
  }
65
62
  //#endregion
66
- export { collectWidgets, documentContent_exports, fromLegacy, serializeUID, toLegacy };
63
+ export { collectWidgets, documentContent_exports, fromLegacy, migrateDocument, serializeUID, toLegacy };
67
64
 
68
65
  //# sourceMappingURL=documentContent.js.map
@@ -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 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,CAAC;C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sBAC5B,kBAAkB,QAAQ,MAAM,GAEhC,OAAOC,eAA4B,SAAmC,KAAK;GAAA;GAG7E,OAAO;EACR;CACD,CAAC;CAGF,OAAO,OAAO;AACf;AAEA,SAAgB,SAAS,UAA2C;CACnE,MAAM,EAAE,SAAS,OAAO,SAAS,oBAAoB,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,QAAQ;CAEzF,OAAO;EAAE,GAAG;EAAS,GAAG;EAAO,GAAG;CAAK;AACxC;AAEA,SAAgB,aAAa,OAAuB;CAOnD,OANqB,MAAM,QAAQ,MAAM,GAEX,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,QAAQ,WAAW,EAE9C,CAAC,CAAC,QAAQ,mBAAmB,EAEzC,CAAC,CAAC,YAAY;AACzB"}
1
+ {"version":3,"file":"documentContent.js","names":["contentPath.serialize","customTypeModel.collectSharedSlices","sliceContent.migrateSliceItem"],"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 type { WidgetContent } from \"../content/widget\"\nimport type { FlattenedStaticCustomTypeModel, 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 migrateDocument(\n\tdocument: DocumentContent,\n\tmodel: StaticCustomTypeModel | FlattenedStaticCustomTypeModel,\n): DocumentContent {\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(document, {\n\t\t\tmodel,\n\t\t\ttransformSlice: sliceContent.migrateSliceItem,\n\t\t})\n\t}\n\n\treturn document\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.union([z.uuidv4(), z.uuid({ version: \"v5\" })]).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\treturn migrateDocument(result.data, model)\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":";;;;;;;;;;;;;;;;;;AAgBA,SAAgB,eACf,UACA,MAQiC;CACjC,MAAM,YAA4C,CAAC;CAEnD,wBAAwB,UAAU,EACjC,kBAAkB,EAAE,SAAS,GAAG,WAAW;EAC1C,IAAI,KAAK,SAAS,IAAI,GACrB,UAAUA,UAAsB,KAAK,IAAI,KAAK;EAG/C,OAAO;CACR,EACD,CAAC;CAED,OAAO;AACR;AAEA,SAAgB,gBACf,UACA,OACkB;CAKlB,IAJuB,OAAO,OAAOC,oBAAoC,KAAK,CAAC,CAAC,CAAC,MAAM,UACtF,QAAQ,MAAM,WAAW,CAGT,GAChB,OAAO,wBAAwB,UAAU;EACxC;EACA,gBAAgBC;CACjB,CAAC;CAGF,OAAO;AACR;AAEA,SAAgB,WACf,QACA,OAC8B;CAC9B,MAAM,SAAS,qBAAqB,UAAU,MAAM;CACpD,IAAI,CAAC,OAAO,SACX;CAGD,MAAM,wBAAQ,IAAI,IAA8B;CAChD,MAAM,uBAAO,IAAI,IAAoB;CACrC,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,IAAI,GACpD,IAAI,IAAI,SAAS,OAAO,GAAG;EAC1B,MAAM,SAAS,uBAAuB,UAAU,KAAK;EACrD,IAAI,OAAO,SACV,MAAM,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,CAAC,GAAG,OAAO,IAAI;CAEzD,OAAO,IAAI,IAAI,SAAS,MAAM,GAAG;EAChC,MAAM,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK;EAC/E,IAAI,OAAO,SACV,KAAK,IAAI,IAAI,UAAU,GAAG,IAAI,SAAS,CAAC,GAAG,OAAO,IAAI;CAExD,OAAO,IAAI,CAAC,IAAI,SAAS,WAAW,GACnC,QAAQ,OAAO;CAIjB,MAAM,SAAS,oBAAoB,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,OAAO;CACjF,IAAI,CAAC,OAAO,SACX;CAGD,OAAO,gBAAgB,OAAO,MAAM,KAAK;AAC1C;AAEA,SAAgB,SAAS,UAA2C;CACnE,MAAM,EAAE,SAAS,OAAO,SAAS,oBAAoB,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,QAAQ;CAEzF,OAAO;EAAE,GAAG;EAAS,GAAG;EAAO,GAAG;CAAK;AACxC;AAEA,SAAgB,aAAa,OAAuB;CAOnD,OANqB,MAAM,QAAQ,MAAM,GAEX,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,QAAQ,WAAW,EAE9C,CAAC,CAAC,QAAQ,mBAAmB,EAEzC,CAAC,CAAC,YAAY;AACzB"}
@@ -1,10 +1,12 @@
1
1
  import { CompositeSliceItemContent, LegacySliceItemContent, SharedSliceItemContent } from "../content/slices.js";
2
2
  import { SharedSliceVariationContentModel } from "../model/slice.js";
3
+ import { TraverseSliceContentFunction } from "./traverseContent.js";
3
4
  declare namespace sliceContent_d_exports {
4
- export { compositeToShared, legacyToShared };
5
+ export { compositeToShared, legacyToShared, migrateSliceItem };
5
6
  }
7
+ declare const migrateSliceItem: TraverseSliceContentFunction;
6
8
  declare const legacyToShared: (content: LegacySliceItemContent, model: SharedSliceVariationContentModel) => SharedSliceItemContent;
7
9
  declare const compositeToShared: (content: CompositeSliceItemContent, model: SharedSliceVariationContentModel) => SharedSliceItemContent;
8
10
  //#endregion
9
- export { compositeToShared, legacyToShared, sliceContent_d_exports };
11
+ export { compositeToShared, legacyToShared, migrateSliceItem, sliceContent_d_exports };
10
12
  //# sourceMappingURL=sliceContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sliceContent.d.ts","names":[],"sources":["../../src/helpers/sliceContent.ts"],"mappings":";;;;;cASa,iBAAc,SACjB,wBAAsB,OACxB,qCACL;cAoCU,oBAAiB,SACpB,2BAAyB,OAC3B,qCACL"}
1
+ {"version":3,"file":"sliceContent.d.ts","names":[],"sources":["../../src/helpers/sliceContent.ts"],"mappings":";;;;;;cAWa,kBAAkB;cAclB,iBAAc,SACjB,wBAAsB,OACxB,qCACL;cAoCU,oBAAiB,SACpB,2BAAyB,OAC3B,qCACL"}
@@ -1,9 +1,18 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { isNestableContent } from "../content/nestable.js";
2
3
  //#region src/helpers/sliceContent.ts
3
4
  var sliceContent_exports = /* @__PURE__ */ __exportAll({
4
5
  compositeToShared: () => compositeToShared,
5
- legacyToShared: () => legacyToShared
6
+ legacyToShared: () => legacyToShared,
7
+ migrateSliceItem: () => migrateSliceItem
6
8
  });
9
+ const migrateSliceItem = ({ content, model }) => {
10
+ if (model?.type === "SharedSlice") {
11
+ if (content.widget.__TYPE__ === "CompositeSliceContent") return compositeToShared(content, model);
12
+ else if (content.widget.__TYPE__ === "GroupContentType" || isNestableContent(content.widget)) return legacyToShared(content, model);
13
+ }
14
+ return content;
15
+ };
7
16
  const legacyToShared = (content, model) => {
8
17
  const sliceUUID = content.key.split("$")[1];
9
18
  const primary = {};
@@ -55,6 +64,6 @@ const compositeToShared = (content, model) => {
55
64
  };
56
65
  };
57
66
  //#endregion
58
- export { compositeToShared, legacyToShared, sliceContent_exports };
67
+ export { compositeToShared, legacyToShared, migrateSliceItem, sliceContent_exports };
59
68
 
60
69
  //# sourceMappingURL=sliceContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sliceContent.js","names":[],"sources":["../../src/helpers/sliceContent.ts"],"sourcesContent":["import type { GroupItemContent } from \"../content/group\"\nimport type { SharedSliceContent } from \"../content/slice\"\nimport type {\n\tCompositeSliceItemContent,\n\tLegacySliceItemContent,\n\tSharedSliceItemContent,\n} from \"../content/slices\"\nimport type { SharedSliceVariationContentModel } from \"../model/slice\"\n\nexport const legacyToShared = (\n\tcontent: LegacySliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tconst items: SharedSliceContent[\"items\"] = []\n\tif (content.widget.__TYPE__ === \"GroupContentType\") {\n\t\t// Group content\n\t\tfor (const item of content.widget.value) {\n\t\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\t\tfor (const [key, nestable] of item.value) {\n\t\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\t\tvalue.push([key, nestable])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\titems.push({ ...item, value })\n\t\t}\n\t} else if (model.fields.primary?.[content.name]) {\n\t\t// Nestable content\n\t\tprimary[content.name] = content.widget\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variationID,\n\t\t\tprimary,\n\t\t\titems,\n\t\t},\n\t}\n}\n\nexport const compositeToShared = (\n\tcontent: CompositeSliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, value] of Object.entries(content.widget.nonRepeat)) {\n\t\tif (model.fields.primary?.[key]) {\n\t\t\tprimary[key] = value\n\t\t}\n\t}\n\n\tconst items: SharedSliceContent[\"items\"] = []\n\tfor (const item of content.widget.repeat) {\n\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\tfor (const [key, nestable] of item.value) {\n\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\tvalue.push([key, nestable])\n\t\t\t}\n\t\t}\n\n\t\titems.push({ ...item, value })\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variationID,\n\t\t\tprimary,\n\t\t\titems,\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;AASA,MAAa,kBACZ,SACA,UAC4B;CAC5B,MAAM,YAAY,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC;CAEzC,MAAM,UAAyC,CAAC;CAChD,MAAM,QAAqC,CAAC;CAC5C,IAAI,QAAQ,OAAO,aAAa,oBAE/B,KAAK,MAAM,QAAQ,QAAQ,OAAO,OAAO;EACxC,MAAM,QAAmC,CAAC;EAE1C,KAAK,MAAM,CAAC,KAAK,aAAa,KAAK,OAClC,IAAI,MAAM,OAAO,QAAQ,MACxB,MAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;EAI5B,MAAM,KAAK;GAAE,GAAG;GAAM;EAAM,CAAC;CAC9B;MACM,IAAI,MAAM,OAAO,UAAU,QAAQ,OAEzC,QAAQ,QAAQ,QAAQ,QAAQ;CAGjC,OAAO;EACN,KAAK,GAAG,MAAM,UAAU,GAAG;EAC3B,MAAM,MAAM;EACZ,YAAY,QAAQ;EACpB,QAAQ;GACP,UAAU;GACV,WAAW,MAAM;GACjB;GACA;EACD;CACD;AACD;AAEA,MAAa,qBACZ,SACA,UAC4B;CAC5B,MAAM,YAAY,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC;CAEzC,MAAM,UAAyC,CAAC;CAChD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,SAAS,GACjE,IAAI,MAAM,OAAO,UAAU,MAC1B,QAAQ,OAAO;CAIjB,MAAM,QAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,QAAQ,OAAO,QAAQ;EACzC,MAAM,QAAmC,CAAC;EAE1C,KAAK,MAAM,CAAC,KAAK,aAAa,KAAK,OAClC,IAAI,MAAM,OAAO,QAAQ,MACxB,MAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;EAI5B,MAAM,KAAK;GAAE,GAAG;GAAM;EAAM,CAAC;CAC9B;CAEA,OAAO;EACN,KAAK,GAAG,MAAM,UAAU,GAAG;EAC3B,MAAM,MAAM;EACZ,YAAY,QAAQ;EACpB,QAAQ;GACP,UAAU;GACV,WAAW,MAAM;GACjB;GACA;EACD;CACD;AACD"}
1
+ {"version":3,"file":"sliceContent.js","names":[],"sources":["../../src/helpers/sliceContent.ts"],"sourcesContent":["import type { GroupItemContent } from \"../content/group\"\nimport { isNestableContent } from \"../content/nestable\"\nimport type { SharedSliceContent } from \"../content/slice\"\nimport type {\n\tCompositeSliceItemContent,\n\tLegacySliceItemContent,\n\tSharedSliceItemContent,\n} from \"../content/slices\"\nimport type { SharedSliceVariationContentModel } from \"../model/slice\"\nimport type { TraverseSliceContentFunction } from \"./traverseContent\"\n\nexport const migrateSliceItem: TraverseSliceContentFunction = ({ content, model }) => {\n\tif (model?.type === \"SharedSlice\") {\n\t\tif (content.widget.__TYPE__ === \"CompositeSliceContent\") {\n\t\t\treturn compositeToShared(content as CompositeSliceItemContent, model)\n\t\t} else if (\n\t\t\tcontent.widget.__TYPE__ === \"GroupContentType\" ||\n\t\t\tisNestableContent(content.widget)\n\t\t) {\n\t\t\treturn legacyToShared(content as LegacySliceItemContent, model)\n\t\t}\n\t}\n\treturn content\n}\n\nexport const legacyToShared = (\n\tcontent: LegacySliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tconst items: SharedSliceContent[\"items\"] = []\n\tif (content.widget.__TYPE__ === \"GroupContentType\") {\n\t\t// Group content\n\t\tfor (const item of content.widget.value) {\n\t\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\t\tfor (const [key, nestable] of item.value) {\n\t\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\t\tvalue.push([key, nestable])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\titems.push({ ...item, value })\n\t\t}\n\t} else if (model.fields.primary?.[content.name]) {\n\t\t// Nestable content\n\t\tprimary[content.name] = content.widget\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variationID,\n\t\t\tprimary,\n\t\t\titems,\n\t\t},\n\t}\n}\n\nexport const compositeToShared = (\n\tcontent: CompositeSliceItemContent,\n\tmodel: SharedSliceVariationContentModel,\n): SharedSliceItemContent => {\n\tconst sliceUUID = content.key.split(\"$\")[1]\n\n\tconst primary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, value] of Object.entries(content.widget.nonRepeat)) {\n\t\tif (model.fields.primary?.[key]) {\n\t\t\tprimary[key] = value\n\t\t}\n\t}\n\n\tconst items: SharedSliceContent[\"items\"] = []\n\tfor (const item of content.widget.repeat) {\n\t\tconst value: GroupItemContent[\"value\"] = []\n\n\t\tfor (const [key, nestable] of item.value) {\n\t\t\tif (model.fields.items?.[key]) {\n\t\t\t\tvalue.push([key, nestable])\n\t\t\t}\n\t\t}\n\n\t\titems.push({ ...item, value })\n\t}\n\n\treturn {\n\t\tkey: `${model.sliceName}$${sliceUUID}`,\n\t\tname: model.sliceName,\n\t\tmaybeLabel: content.maybeLabel,\n\t\twidget: {\n\t\t\t__TYPE__: \"SharedSliceContent\",\n\t\t\tvariation: model.variation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AAQ,QAAQ,OAAO,QAAQ;EACzC,MAAM,QAAmC,CAAC;EAE1C,KAAK,MAAM,CAAC,KAAK,aAAa,KAAK,OAClC,IAAI,MAAM,OAAO,QAAQ,MACxB,MAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;EAI5B,MAAM,KAAK;GAAE,GAAG;GAAM;EAAM,CAAC;CAC9B;CAEA,OAAO;EACN,KAAK,GAAG,MAAM,UAAU,GAAG;EAC3B,MAAM,MAAM;EACZ,YAAY,QAAQ;EACpB,QAAQ;GACP,UAAU;GACV,WAAW,MAAM;GACjB;GACA;EACD;CACD;AACD"}
@@ -11,11 +11,11 @@ import { GroupModel, NestedGroupModel } from "../model/group.js";
11
11
  import { CompositeSliceModel, LegacySliceModel, SharedSliceVariationContentModel, SliceContentModel } from "../model/slice.js";
12
12
  import { StaticSlicesModel } from "../model/slices.js";
13
13
  import { StaticWidgetModel } from "../model/widget.js";
14
- import { StaticCustomTypeModel } from "../model/customType.js";
14
+ import { FlattenedStaticCustomTypeModel, StaticCustomTypeModel } from "../model/customType.js";
15
15
  import { Path } from "./contentPath.js";
16
16
  //#region src/helpers/traverseContent.d.ts
17
17
  type TraverseDocumentContentConfig = {
18
- model?: StaticCustomTypeModel;
18
+ model?: StaticCustomTypeModel | FlattenedStaticCustomTypeModel;
19
19
  transformWidget?: TraverseWidgetContentFunction;
20
20
  transformSlice?: TraverseSliceContentFunction;
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"traverseContent.d.ts","names":[],"sources":["../../src/helpers/traverseContent.ts"],"mappings":";;;;;;;;;;;;;;;;KAqCK;EACJ,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;;iBAGF,wBACf,UAAU,iBACV,QAAQ,gCACN;KA0BE;EACJ,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;;iBAGF,sBACf,MAAM,MACN,aACA,eACA,SAAS,eACT,QAAQ,8BACN;KAiHE;EACJ,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;;iBAGF,2BACf,MAAM,MACN,aACA,eACA,SAAS,wBACT,QAAQ,mCACN;KA0CE;EACJ,QAAQ,sBAAsB;EAC9B,kBAAkB;EAClB,iBAAiB;;iBAGF,8BACf,MAAM,MACN,aACA,eACA,SAAS,2BACT,QAAQ,sCACN,4BAA4B;KA2C1B;EACJ,QAAQ,mBAAmB;EAC3B,kBAAkB;EAClB,iBAAiB;;iBAGF,2BACf,MAAM,MACN,aACA,eACA,SAAS,wBACT,QAAQ,mCACN,yBAAyB;KA6CvB;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,qBACf,MAAM,MACN,aACA,eACA,SAAS,cACT,QAAQ,6BACN;KAiBE;EACJ,QAAQ,eAAe,mBAAmB;EAC1C,iBAAiB;;iBAGF,0BACf,MAAM,MACN,SAAS,oBACT,QAAQ,kCACN;KA4CE;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,0BACf,MAAM,MACN,aACA,eACA,SAAS,mBACT,QAAQ,kCACN;KA+BE;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,qBACf,MAAM,MACN,aACA,eACA,SAAS,cACT,QAAQ,6BACN;KA2CS,gCAAgC,iBAAiB,kBAAkB;EAC9E,MAAM;EACN;EACA;EACA,SAAS;EACT,QAAQ;MACH,WAAW;KAEL,8BACX,oEACI,iBAAiB,eAAe;EACpC,MAAM;EACN;EACA;EACA,SAAS;EACT,QAAQ;OACF,2CAA2C,WAAW"}
1
+ {"version":3,"file":"traverseContent.d.ts","names":[],"sources":["../../src/helpers/traverseContent.ts"],"mappings":";;;;;;;;;;;;;;;;KAqCK;EACJ,QAAQ,wBAAwB;EAChC,kBAAkB;EAClB,iBAAiB;;iBAGF,wBACf,UAAU,iBACV,QAAQ,gCACN;KA6BE;EACJ,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;;iBAGF,sBACf,MAAM,MACN,aACA,eACA,SAAS,eACT,QAAQ,8BACN;KAiHE;EACJ,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;;iBAGF,2BACf,MAAM,MACN,aACA,eACA,SAAS,wBACT,QAAQ,mCACN;KA0CE;EACJ,QAAQ,sBAAsB;EAC9B,kBAAkB;EAClB,iBAAiB;;iBAGF,8BACf,MAAM,MACN,aACA,eACA,SAAS,2BACT,QAAQ,sCACN,4BAA4B;KA2C1B;EACJ,QAAQ,mBAAmB;EAC3B,kBAAkB;EAClB,iBAAiB;;iBAGF,2BACf,MAAM,MACN,aACA,eACA,SAAS,wBACT,QAAQ,mCACN,yBAAyB;KA6CvB;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,qBACf,MAAM,MACN,aACA,eACA,SAAS,cACT,QAAQ,6BACN;KAiBE;EACJ,QAAQ,eAAe,mBAAmB;EAC1C,iBAAiB;;iBAGF,0BACf,MAAM,MACN,SAAS,oBACT,QAAQ,kCACN;KA4CE;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,0BACf,MAAM,MACN,aACA,eACA,SAAS,mBACT,QAAQ,kCACN;KA+BE;EACJ,QAAQ;EACR,iBAAiB;;iBAGF,qBACf,MAAM,MACN,aACA,eACA,SAAS,cACT,QAAQ,6BACN;KA2CS,gCAAgC,iBAAiB,kBAAkB;EAC9E,MAAM;EACN;EACA;EACA,SAAS;EACT,QAAQ;MACH,WAAW;KAEL,8BACX,oEACI,iBAAiB,eAAe;EACpC,MAAM;EACN;EACA;EACA,SAAS;EACT,QAAQ;OACF,2CAA2C,WAAW"}
@@ -11,17 +11,20 @@ import "../content/slices.js";
11
11
  //#region src/helpers/traverseContent.ts
12
12
  function traverseDocumentContent(document, config) {
13
13
  const { model, transformWidget, transformSlice } = config;
14
- const flatModel = model ? flatten(model) : {};
14
+ const flatModel = model && !("fields" in model) ? {
15
+ customTypeId: model.id,
16
+ fields: flatten(model)
17
+ } : model;
15
18
  const traversed = {};
16
19
  for (const [key, content] of Object.entries(document)) {
17
20
  const traversedContent = traverseWidgetContent(make({
18
- key: config.model?.id,
21
+ key: flatModel?.customTypeId,
19
22
  type: "CustomType"
20
23
  }, {
21
24
  key,
22
25
  type: "Widget"
23
26
  }), key, key, content, {
24
- model: flatModel[key],
27
+ model: flatModel?.fields[key],
25
28
  transformWidget,
26
29
  transformSlice
27
30
  });
@@ -1 +1 @@
1
- {"version":3,"file":"traverseContent.js","names":["customTypeModel.flatten","contentPath.make","contentPath.append","contentPath.serialize"],"sources":["../../src/helpers/traverseContent.ts"],"sourcesContent":["import type { DocumentContent } from \"../content/document\"\nimport { GroupContentType } from \"../content/group\"\nimport type { GroupContent, GroupItemContent } from \"../content/group\"\nimport { isNestableContent } from \"../content/nestable\"\nimport { isRepeatableContentValue, RepeatableContentType } from \"../content/repeatable\"\nimport type { RepeatableContent } from \"../content/repeatable\"\nimport { RichTextContentType } from \"../content/richText\"\nimport { CompositeSliceContentType, SharedSliceContentType } from \"../content/slice\"\nimport type { CompositeSliceContent, SharedSliceContent } from \"../content/slice\"\nimport {\n\ttype CompositeSliceItemContent,\n\ttype SharedSliceItemContent,\n\ttype LegacySliceItemContent,\n\ttype SliceItemContent,\n\ttype SlicesContent,\n\tSlicesContentType,\n} from \"../content/slices\"\nimport { TableContentType, type TableContent } from \"../content/table\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { StaticCustomTypeModel } from \"../model/customType\"\nimport type { GroupModel, NestedGroupModel } from \"../model/group\"\nimport type { LinkModel } from \"../model/link\"\nimport type { NestableModel } from \"../model/nestable\"\nimport type {\n\tCompositeSliceModel,\n\tLegacySliceModel,\n\tSharedSliceModel,\n\tSharedSliceVariationContentModel,\n\tSliceContentModel,\n} from \"../model/slice\"\nimport type { StaticSlicesModel } from \"../model/slices\"\nimport { TableCellModel } from \"../model/table\"\nimport type { TableModel } from \"../model/table\"\nimport type { StaticWidgetModel } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\n\ntype TraverseDocumentContentConfig = {\n\tmodel?: StaticCustomTypeModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseDocumentContent(\n\tdocument: DocumentContent,\n\tconfig: TraverseDocumentContentConfig,\n): DocumentContent {\n\tconst { model, transformWidget, transformSlice } = config\n\n\t// Remove tabs from custom type model\n\tconst flatModel = model ? customTypeModel.flatten(model) : {}\n\n\tconst traversed: DocumentContent = {}\n\tfor (const [key, content] of Object.entries(document)) {\n\t\tconst path = contentPath.make(\n\t\t\t{ key: config.model?.id, type: \"CustomType\" },\n\t\t\t{ key, type: \"Widget\" },\n\t\t)\n\n\t\tconst traversedContent = traverseWidgetContent(path, key, key, content, {\n\t\t\tmodel: flatModel[key],\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t})\n\t\tif (traversedContent) {\n\t\t\ttraversed[key] = traversedContent\n\t\t}\n\t}\n\n\treturn traversed\n}\n\ntype TraverseSlicesContentConfig = {\n\tmodel?: StaticSlicesModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseSlicesContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SlicesContent,\n\tconfig: TraverseSlicesContentConfig,\n): SlicesContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversed: SlicesContent[\"value\"] = []\n\tfor (const sliceItemContent of content.value) {\n\t\tconst sliceModel = config.model?.config?.choices?.[sliceItemContent.name]\n\n\t\tlet sliceContentModel: SliceContentModel | undefined\n\n\t\t// Happy path, content and model are both shared slices\n\t\tif (\n\t\t\tsliceItemContent.widget.__TYPE__ === SharedSliceContentType &&\n\t\t\tsliceModel?.type === \"SharedSlice\"\n\t\t) {\n\t\t\tconst variationID = sliceItemContent.widget.variation\n\t\t\tconst variationModel = sliceModel.variations.find((variation) => variation.id === variationID)\n\t\t\tif (variationModel) {\n\t\t\t\tsliceContentModel = {\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\tsliceName: sliceModel.id,\n\t\t\t\t\tvariationID: variationModel.id,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tprimary: variationModel.primary || {},\n\t\t\t\t\t\titems: variationModel.items || {},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Migrated path, content is composite or legacy, model is shared slice\n\t\tif (!sliceContentModel) {\n\t\t\tconst legacyPath = contentPath.append(contentPath.serialize(path), sliceItemContent.name)\n\n\t\t\t// Find the migrated slice model who's legacy path matches the content path\n\t\t\tconst migratedSliceModel = Object.values(config.model?.config?.choices || {}).find(\n\t\t\t\t(model): model is SharedSliceModel => {\n\t\t\t\t\treturn model.type === \"SharedSlice\" && Boolean(model.legacyPaths?.[legacyPath])\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tif (migratedSliceModel) {\n\t\t\t\t// Find the variation that matches the legacy path\n\t\t\t\tconst variation = migratedSliceModel.variations.find((variation) => {\n\t\t\t\t\treturn variation.id === migratedSliceModel.legacyPaths?.[legacyPath]\n\t\t\t\t})\n\n\t\t\t\tif (variation) {\n\t\t\t\t\tsliceContentModel = {\n\t\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\t\tsliceName: migratedSliceModel.id,\n\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\tprimary: variation.primary || {},\n\t\t\t\t\t\t\titems: variation.items || {},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Non-migrated path, content and model are composite or legacy\n\t\tif (!sliceContentModel && sliceModel && sliceModel.type !== \"SharedSlice\") {\n\t\t\tsliceContentModel = sliceModel\n\t\t}\n\n\t\tlet traversedSliceItemContent: SliceItemContent | undefined\n\t\tif (sliceItemContent.widget.__TYPE__ === SharedSliceContentType) {\n\t\t\tconst model = sliceContentModel?.type === \"SharedSlice\" ? sliceContentModel : undefined\n\t\t\ttraversedSliceItemContent = traverseSharedSliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"SharedSlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as SharedSliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t} else if (sliceItemContent.widget.__TYPE__ === CompositeSliceContentType) {\n\t\t\tconst model =\n\t\t\t\tsliceContentModel?.type === \"Slice\" || sliceContentModel?.type === \"SharedSlice\"\n\t\t\t\t\t? sliceContentModel\n\t\t\t\t\t: undefined\n\t\t\ttraversedSliceItemContent = traverseCompositeSliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"Slice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as CompositeSliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t} else {\n\t\t\tconst model = sliceContentModel?.type !== \"Slice\" ? sliceContentModel : undefined\n\t\t\ttraversedSliceItemContent = traverseLegacySliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"LegacySlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as LegacySliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t}\n\n\t\tif (traversedSliceItemContent) {\n\t\t\ttraversed.push(traversedSliceItemContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseSharedSliceContentConfig = {\n\tmodel?: SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseSharedSliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SharedSliceItemContent,\n\tconfig: TraverseSharedSliceContentConfig,\n): SharedSliceItemContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversedPrimary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, fieldContent] of Object.entries(content.widget.primary)) {\n\t\tconst model = config.model?.fields.primary?.[key]\n\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: \"primary\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tkey,\n\t\t\tfieldContent,\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (\n\t\t\ttraversedContent &&\n\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst traversedItems = traverseGroupItemsContent(\n\t\tpath.concat({ key: \"items\", type: \"items\" }),\n\t\tcontent.widget.items,\n\t\t{ model: config.model?.fields.items, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, primary: traversedPrimary, items: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseCompositeSliceContentConfig = {\n\tmodel?: CompositeSliceModel | SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseCompositeSliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: CompositeSliceItemContent,\n\tconfig: TraverseCompositeSliceContentConfig,\n): CompositeSliceItemContent | SharedSliceItemContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst primaryModel =\n\t\tconfig.model?.type === \"SharedSlice\"\n\t\t\t? config.model?.fields.primary\n\t\t\t: config.model?.[\"non-repeat\"]\n\tconst traversedPrimary: CompositeSliceContent[\"nonRepeat\"] = {}\n\tfor (const [key, fieldContent] of Object.entries(content.widget.nonRepeat)) {\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: \"non-repeat\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tfieldContent,\n\t\t\t{ model: primaryModel?.[key], transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isNestableContent(traversedContent)) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst itemsModel =\n\t\tconfig.model?.type === \"SharedSlice\" ? config.model?.fields.items : config.model?.repeat\n\tconst traversedItems = traverseGroupItemsContent(\n\t\tpath.concat({ key: \"repeat\", type: \"items\" }),\n\t\tcontent.widget.repeat,\n\t\t{ model: itemsModel, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, nonRepeat: traversedPrimary, repeat: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseLegacySliceContentConfig = {\n\tmodel?: LegacySliceModel | SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseLegacySliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: LegacySliceItemContent,\n\tconfig: TraverseLegacySliceContentConfig,\n): LegacySliceItemContent | SharedSliceItemContent | undefined {\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tlet legacySliceModel: LegacySliceModel | undefined\n\tif (content.widget.__TYPE__ === \"GroupContentType\") {\n\t\tif (model?.type === \"Group\") {\n\t\t\tlegacySliceModel = model\n\t\t} else if (model?.type === \"SharedSlice\") {\n\t\t\tlegacySliceModel = { type: \"Group\", config: { fields: model.fields.items } }\n\t\t}\n\t} else {\n\t\tif (model?.type === \"SharedSlice\") {\n\t\t\tconst primaryModel = model.fields.primary?.[content.name]\n\t\t\tif (primaryModel?.type !== \"Group\") {\n\t\t\t\tlegacySliceModel = primaryModel\n\t\t\t}\n\t\t} else if (model?.type !== \"Group\") {\n\t\t\tlegacySliceModel = model\n\t\t}\n\t}\n\n\tconst traversedContent = traverseWidgetContent(path, key, apiID, content.widget, {\n\t\tmodel: legacySliceModel,\n\t\ttransformWidget,\n\t\ttransformSlice,\n\t})\n\n\tif (\n\t\ttraversedContent &&\n\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t) {\n\t\treturn transformSlice({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent: { ...content, widget: traversedContent },\n\t\t\tmodel,\n\t\t})\n\t}\n}\n\ntype TraverseGroupContentConfig = {\n\tmodel?: GroupModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseGroupContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: GroupContent,\n\tconfig: TraverseGroupContentConfig,\n): GroupContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tconst traversed = traverseGroupItemsContent(path, content.value, {\n\t\tmodel: model?.config?.fields,\n\t\ttransformWidget,\n\t})\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseGroupItemsContentConfig = {\n\tmodel?: Record<string, NestedGroupModel | NestableModel>\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseGroupItemsContent(\n\tpath: contentPath.Path,\n\tcontent: GroupItemContent[],\n\tconfig: TraverseGroupItemsContentConfig,\n): GroupItemContent[] {\n\tconst { transformWidget } = config\n\n\tconst traversed: GroupItemContent[] = []\n\tfor (const groupItemContent of content) {\n\t\t// Legacy v3 documents can have .value as a plain object or string\n\t\t// instead of the expected [key, content][] tuples.\n\t\tif (!Array.isArray(groupItemContent.value)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst groupItemPath = path.concat({ key: groupItemContent.key, type: \"GroupItem\" })\n\n\t\tconst traversedValue: GroupItemContent[\"value\"] = []\n\t\tfor (const [key, content] of groupItemContent.value) {\n\t\t\t// In some edge cases v3 handled implicitly, content\n\t\t\t// could be undefined, so we need to skip such cases.\n\t\t\tif (!content) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst model = config.model?.[key]\n\t\t\tconst traversedContent = traverseWidgetContent(\n\t\t\t\tgroupItemPath.concat({ key, type: \"Widget\" }),\n\t\t\t\tkey,\n\t\t\t\tkey,\n\t\t\t\tcontent,\n\t\t\t\t{ model, transformWidget },\n\t\t\t)\n\n\t\t\tif (\n\t\t\t\ttraversedContent &&\n\t\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t\t) {\n\t\t\t\ttraversedValue.push([key, traversedContent])\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...groupItemContent, value: traversedValue })\n\t}\n\n\treturn traversed\n}\n\ntype TraverseRepeatableContentConfig = {\n\tmodel?: LinkModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseRepeatableContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: RepeatableContent,\n\tconfig: TraverseRepeatableContentConfig,\n): RepeatableContent | undefined {\n\tconst { model, transformWidget } = config\n\tconst nonRepeatModel =\n\t\tmodel?.type === \"Link\" && model.config\n\t\t\t? { ...model, config: { ...model.config, repeat: false } }\n\t\t\t: model\n\n\tconst traversed: RepeatableContent[\"value\"] = []\n\tfor (let index = 0; index < content.value.length; index++) {\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: index.toString(), type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.value[index],\n\t\t\t{ model: nonRepeatModel, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isRepeatableContentValue(traversedContent)) {\n\t\t\ttraversed.push(traversedContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseTableContentConfig = {\n\tmodel?: TableModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseTableContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: TableContent,\n\tconfig: TraverseTableContentConfig,\n): TableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tconst traversed: TableContent[\"content\"] = []\n\tfor (let rowIndex = 0; rowIndex < content.content.length; rowIndex++) {\n\t\tconst traversedContent: TableContent[\"content\"][number][\"content\"] = []\n\t\tfor (let cellIndex = 0; cellIndex < content.content[rowIndex].content.length; cellIndex++) {\n\t\t\tconst cellPath = path.concat({ key: [rowIndex, cellIndex].join(\",\"), type: \"Widget\" })\n\t\t\tconst cell = content.content[rowIndex].content[cellIndex]\n\n\t\t\tconst transformed = transformWidget({\n\t\t\t\tpath: cellPath,\n\t\t\t\tkey,\n\t\t\t\tapiID,\n\t\t\t\tcontent: cell.content,\n\t\t\t\tmodel: TableCellModel,\n\t\t\t})\n\n\t\t\tif (transformed && transformed.__TYPE__ === RichTextContentType) {\n\t\t\t\ttraversedContent.push({ ...cell, content: transformed })\n\t\t\t} else {\n\t\t\t\ttraversedContent.push({\n\t\t\t\t\t...cell,\n\t\t\t\t\tcontent: {\n\t\t\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t\t\t\tvalue: [],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...content.content[rowIndex], content: traversedContent })\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, content: traversed },\n\t\tmodel,\n\t})\n}\n\nexport type TraverseSliceContentFunction = <TContent extends SliceItemContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent: TContent\n\tmodel?: SliceContentModel\n}) => TContent | SharedSliceItemContent | undefined\n\nexport type TraverseWidgetContentFunction<\n\tTContentTransformMode extends \"preserve\" | \"widen\" = \"preserve\",\n> = <TContent extends WidgetContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent: TContent\n\tmodel?: StaticWidgetModel\n}) => (TContentTransformMode extends \"preserve\" ? TContent : WidgetContent) | undefined\n\n// Internals\ntype TraverseWidgetContentConfig = {\n\tmodel?: StaticWidgetModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nfunction traverseWidgetContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: WidgetContent,\n\tconfig: TraverseWidgetContentConfig,\n): WidgetContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tif (content.__TYPE__ === SlicesContentType) {\n\t\tconst model =\n\t\t\tconfig.model?.type === \"Slices\" || config.model?.type === \"Choice\" ? config.model : undefined\n\t\treturn traverseSlicesContent(path, key, apiID, content, {\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (content.__TYPE__ === GroupContentType) {\n\t\tconst model = config.model?.type === \"Group\" ? config.model : undefined\n\t\treturn traverseGroupContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tif (content.__TYPE__ === RepeatableContentType) {\n\t\tconst model = config.model?.type === \"Link\" ? config.model : undefined\n\t\treturn traverseRepeatableContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tif (content.__TYPE__ === TableContentType) {\n\t\tconst model = config.model?.type === \"Table\" ? config.model : undefined\n\t\treturn traverseTableContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tconst model =\n\t\tconfig.model?.type !== \"Slices\" &&\n\t\tconfig.model?.type !== \"Choice\" &&\n\t\tconfig.model?.type !== \"Group\" &&\n\t\tconfig.model?.type !== \"Table\"\n\t\t\t? config.model\n\t\t\t: undefined\n\treturn transformWidget({ path, key, apiID, content, model })\n}\n"],"mappings":";;;;;;;;;;;AA2CA,SAAgB,wBACf,UACA,QACkB;CAClB,MAAM,EAAE,OAAO,iBAAiB,mBAAmB;CAGnD,MAAM,YAAY,QAAQA,QAAwB,KAAK,IAAI,CAAC;CAE5D,MAAM,YAA6B,CAAC;CACpC,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,QAAQ,GAAG;EAMtD,MAAM,mBAAmB,sBALZC,KACZ;GAAE,KAAK,OAAO,OAAO;GAAI,MAAM;EAAa,GAC5C;GAAE;GAAK,MAAM;EAAS,CAG2B,GAAG,KAAK,KAAK,SAAS;GACvE,OAAO,UAAU;GACjB;GACA;EACD,CAAC;EACD,IAAI,kBACH,UAAU,OAAO;CAEnB;CAEA,OAAO;AACR;AAQA,SAAgB,sBACf,MACA,KACA,OACA,SACA,QAC4B;CAC5B,MAAM,EAAE,mBAAmB,SAAS,KAAK,SAAS,kBAAkB,SAAS,KAAK,YACjF;CAED,MAAM,YAAoC,CAAC;CAC3C,KAAK,MAAM,oBAAoB,QAAQ,OAAO;EAC7C,MAAM,aAAa,OAAO,OAAO,QAAQ,UAAU,iBAAiB;EAEpE,IAAI;EAGJ,IACC,iBAAiB,OAAO,aAAA,wBACxB,YAAY,SAAS,eACpB;GACD,MAAM,cAAc,iBAAiB,OAAO;GAC5C,MAAM,iBAAiB,WAAW,WAAW,MAAM,cAAc,UAAU,OAAO,WAAW;GAC7F,IAAI,gBACH,oBAAoB;IACnB,MAAM;IACN,WAAW,WAAW;IACtB,aAAa,eAAe;IAC5B,QAAQ;KACP,SAAS,eAAe,WAAW,CAAC;KACpC,OAAO,eAAe,SAAS,CAAC;IACjC;GACD;EAEF;EAGA,IAAI,CAAC,mBAAmB;GACvB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;KACR,UAAU;KACV,OAAO,CAAC;IACT;GACD,CAAC;EAEH;EAEA,UAAU,KAAK;GAAE,GAAG,QAAQ,QAAQ;GAAW,SAAS;EAAiB,CAAC;CAC3E;CAEA,OAAO,gBAAgB;EACtB;EACA;EACA;EACA,SAAS;GAAE,GAAG;GAAS,SAAS;EAAU;EAC1C;CACD,CAAC;AACF;AA2BA,SAAS,sBACR,MACA,KACA,OACA,SACA,QAC4B;CAC5B,MAAM,EAAE,mBAAmB,SAAS,KAAK,SAAS,kBAAkB,SAAS,KAAK,YACjF;CAED,IAAI,QAAQ,aAAA,oBAGX,OAAO,sBAAsB,MAAM,KAAK,OAAO,SAAS;EACvD;EACA;EACA,OAJA,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,SAAS,WAAW,OAAO,QAAQ,KAAA;CAKrF,CAAC;CAGF,IAAI,QAAQ,aAAA,oBAEX,OAAO,qBAAqB,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OAD5D,OAAO,OAAO,SAAS,UAAU,OAAO,QAAQ,KAAA;CACkB,CAAC;CAGlF,IAAI,QAAQ,aAAA,qBAEX,OAAO,0BAA0B,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OADjE,OAAO,OAAO,SAAS,SAAS,OAAO,QAAQ,KAAA;CACwB,CAAC;CAGvF,IAAI,QAAQ,aAAA,gBAEX,OAAO,qBAAqB,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OAD5D,OAAO,OAAO,SAAS,UAAU,OAAO,QAAQ,KAAA;CACkB,CAAC;CAUlF,OAAO,gBAAgB;EAAE;EAAM;EAAK;EAAO;EAAS,OANnD,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,SAAS,WACvB,OAAO,OAAO,SAAS,UACpB,OAAO,QACP,KAAA;CACsD,CAAC;AAC5D"}
1
+ {"version":3,"file":"traverseContent.js","names":["customTypeModel.flatten","contentPath.make","contentPath.append","contentPath.serialize"],"sources":["../../src/helpers/traverseContent.ts"],"sourcesContent":["import type { DocumentContent } from \"../content/document\"\nimport { GroupContentType } from \"../content/group\"\nimport type { GroupContent, GroupItemContent } from \"../content/group\"\nimport { isNestableContent } from \"../content/nestable\"\nimport { isRepeatableContentValue, RepeatableContentType } from \"../content/repeatable\"\nimport type { RepeatableContent } from \"../content/repeatable\"\nimport { RichTextContentType } from \"../content/richText\"\nimport { CompositeSliceContentType, SharedSliceContentType } from \"../content/slice\"\nimport type { CompositeSliceContent, SharedSliceContent } from \"../content/slice\"\nimport {\n\ttype CompositeSliceItemContent,\n\ttype SharedSliceItemContent,\n\ttype LegacySliceItemContent,\n\ttype SliceItemContent,\n\ttype SlicesContent,\n\tSlicesContentType,\n} from \"../content/slices\"\nimport { TableContentType, type TableContent } from \"../content/table\"\nimport type { WidgetContent } from \"../content/widget\"\nimport type { FlattenedStaticCustomTypeModel, StaticCustomTypeModel } from \"../model/customType\"\nimport type { GroupModel, NestedGroupModel } from \"../model/group\"\nimport type { LinkModel } from \"../model/link\"\nimport type { NestableModel } from \"../model/nestable\"\nimport type {\n\tCompositeSliceModel,\n\tLegacySliceModel,\n\tSharedSliceModel,\n\tSharedSliceVariationContentModel,\n\tSliceContentModel,\n} from \"../model/slice\"\nimport type { StaticSlicesModel } from \"../model/slices\"\nimport { TableCellModel } from \"../model/table\"\nimport type { TableModel } from \"../model/table\"\nimport type { StaticWidgetModel } from \"../model/widget\"\nimport * as contentPath from \"./contentPath\"\nimport * as customTypeModel from \"./customTypeModel\"\n\ntype TraverseDocumentContentConfig = {\n\tmodel?: StaticCustomTypeModel | FlattenedStaticCustomTypeModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseDocumentContent(\n\tdocument: DocumentContent,\n\tconfig: TraverseDocumentContentConfig,\n): DocumentContent {\n\tconst { model, transformWidget, transformSlice } = config\n\n\t// Remove tabs from custom type model\n\tconst flatModel =\n\t\tmodel && !(\"fields\" in model)\n\t\t\t? { customTypeId: model.id, fields: customTypeModel.flatten(model) }\n\t\t\t: model\n\n\tconst traversed: DocumentContent = {}\n\tfor (const [key, content] of Object.entries(document)) {\n\t\tconst path = contentPath.make(\n\t\t\t{ key: flatModel?.customTypeId, type: \"CustomType\" },\n\t\t\t{ key, type: \"Widget\" },\n\t\t)\n\n\t\tconst traversedContent = traverseWidgetContent(path, key, key, content, {\n\t\t\tmodel: flatModel?.fields[key],\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t})\n\t\tif (traversedContent) {\n\t\t\ttraversed[key] = traversedContent\n\t\t}\n\t}\n\n\treturn traversed\n}\n\ntype TraverseSlicesContentConfig = {\n\tmodel?: StaticSlicesModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseSlicesContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SlicesContent,\n\tconfig: TraverseSlicesContentConfig,\n): SlicesContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversed: SlicesContent[\"value\"] = []\n\tfor (const sliceItemContent of content.value) {\n\t\tconst sliceModel = config.model?.config?.choices?.[sliceItemContent.name]\n\n\t\tlet sliceContentModel: SliceContentModel | undefined\n\n\t\t// Happy path, content and model are both shared slices\n\t\tif (\n\t\t\tsliceItemContent.widget.__TYPE__ === SharedSliceContentType &&\n\t\t\tsliceModel?.type === \"SharedSlice\"\n\t\t) {\n\t\t\tconst variationID = sliceItemContent.widget.variation\n\t\t\tconst variationModel = sliceModel.variations.find((variation) => variation.id === variationID)\n\t\t\tif (variationModel) {\n\t\t\t\tsliceContentModel = {\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\tsliceName: sliceModel.id,\n\t\t\t\t\tvariationID: variationModel.id,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tprimary: variationModel.primary || {},\n\t\t\t\t\t\titems: variationModel.items || {},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Migrated path, content is composite or legacy, model is shared slice\n\t\tif (!sliceContentModel) {\n\t\t\tconst legacyPath = contentPath.append(contentPath.serialize(path), sliceItemContent.name)\n\n\t\t\t// Find the migrated slice model who's legacy path matches the content path\n\t\t\tconst migratedSliceModel = Object.values(config.model?.config?.choices || {}).find(\n\t\t\t\t(model): model is SharedSliceModel => {\n\t\t\t\t\treturn model.type === \"SharedSlice\" && Boolean(model.legacyPaths?.[legacyPath])\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tif (migratedSliceModel) {\n\t\t\t\t// Find the variation that matches the legacy path\n\t\t\t\tconst variation = migratedSliceModel.variations.find((variation) => {\n\t\t\t\t\treturn variation.id === migratedSliceModel.legacyPaths?.[legacyPath]\n\t\t\t\t})\n\n\t\t\t\tif (variation) {\n\t\t\t\t\tsliceContentModel = {\n\t\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\t\tsliceName: migratedSliceModel.id,\n\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\tprimary: variation.primary || {},\n\t\t\t\t\t\t\titems: variation.items || {},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Non-migrated path, content and model are composite or legacy\n\t\tif (!sliceContentModel && sliceModel && sliceModel.type !== \"SharedSlice\") {\n\t\t\tsliceContentModel = sliceModel\n\t\t}\n\n\t\tlet traversedSliceItemContent: SliceItemContent | undefined\n\t\tif (sliceItemContent.widget.__TYPE__ === SharedSliceContentType) {\n\t\t\tconst model = sliceContentModel?.type === \"SharedSlice\" ? sliceContentModel : undefined\n\t\t\ttraversedSliceItemContent = traverseSharedSliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"SharedSlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as SharedSliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t} else if (sliceItemContent.widget.__TYPE__ === CompositeSliceContentType) {\n\t\t\tconst model =\n\t\t\t\tsliceContentModel?.type === \"Slice\" || sliceContentModel?.type === \"SharedSlice\"\n\t\t\t\t\t? sliceContentModel\n\t\t\t\t\t: undefined\n\t\t\ttraversedSliceItemContent = traverseCompositeSliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"Slice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as CompositeSliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t} else {\n\t\t\tconst model = sliceContentModel?.type !== \"Slice\" ? sliceContentModel : undefined\n\t\t\ttraversedSliceItemContent = traverseLegacySliceContent(\n\t\t\t\tpath.concat({ key: sliceItemContent.key, type: \"LegacySlice\" }),\n\t\t\t\tsliceItemContent.key,\n\t\t\t\tsliceItemContent.name,\n\t\t\t\tsliceItemContent as LegacySliceItemContent,\n\t\t\t\t{ model, transformWidget, transformSlice },\n\t\t\t)\n\t\t}\n\n\t\tif (traversedSliceItemContent) {\n\t\t\ttraversed.push(traversedSliceItemContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseSharedSliceContentConfig = {\n\tmodel?: SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseSharedSliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: SharedSliceItemContent,\n\tconfig: TraverseSharedSliceContentConfig,\n): SharedSliceItemContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst traversedPrimary: SharedSliceContent[\"primary\"] = {}\n\tfor (const [key, fieldContent] of Object.entries(content.widget.primary)) {\n\t\tconst model = config.model?.fields.primary?.[key]\n\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: \"primary\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tkey,\n\t\t\tfieldContent,\n\t\t\t{ model, transformWidget },\n\t\t)\n\n\t\tif (\n\t\t\ttraversedContent &&\n\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst traversedItems = traverseGroupItemsContent(\n\t\tpath.concat({ key: \"items\", type: \"items\" }),\n\t\tcontent.widget.items,\n\t\t{ model: config.model?.fields.items, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, primary: traversedPrimary, items: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseCompositeSliceContentConfig = {\n\tmodel?: CompositeSliceModel | SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseCompositeSliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: CompositeSliceItemContent,\n\tconfig: TraverseCompositeSliceContentConfig,\n): CompositeSliceItemContent | SharedSliceItemContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tconst primaryModel =\n\t\tconfig.model?.type === \"SharedSlice\"\n\t\t\t? config.model?.fields.primary\n\t\t\t: config.model?.[\"non-repeat\"]\n\tconst traversedPrimary: CompositeSliceContent[\"nonRepeat\"] = {}\n\tfor (const [key, fieldContent] of Object.entries(content.widget.nonRepeat)) {\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: \"non-repeat\", type: \"primary\" }, { key, type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tfieldContent,\n\t\t\t{ model: primaryModel?.[key], transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isNestableContent(traversedContent)) {\n\t\t\ttraversedPrimary[key] = traversedContent\n\t\t}\n\t}\n\n\tconst itemsModel =\n\t\tconfig.model?.type === \"SharedSlice\" ? config.model?.fields.items : config.model?.repeat\n\tconst traversedItems = traverseGroupItemsContent(\n\t\tpath.concat({ key: \"repeat\", type: \"items\" }),\n\t\tcontent.widget.repeat,\n\t\t{ model: itemsModel, transformWidget },\n\t)\n\n\treturn transformSlice({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: {\n\t\t\t...content,\n\t\t\twidget: { ...content.widget, nonRepeat: traversedPrimary, repeat: traversedItems },\n\t\t},\n\t\tmodel: config.model,\n\t})\n}\n\ntype TraverseLegacySliceContentConfig = {\n\tmodel?: LegacySliceModel | SharedSliceVariationContentModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nexport function traverseLegacySliceContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: LegacySliceItemContent,\n\tconfig: TraverseLegacySliceContentConfig,\n): LegacySliceItemContent | SharedSliceItemContent | undefined {\n\tconst {\n\t\tmodel,\n\t\ttransformWidget = (args) => args.content,\n\t\ttransformSlice = (args) => args.content,\n\t} = config\n\n\tlet legacySliceModel: LegacySliceModel | undefined\n\tif (content.widget.__TYPE__ === \"GroupContentType\") {\n\t\tif (model?.type === \"Group\") {\n\t\t\tlegacySliceModel = model\n\t\t} else if (model?.type === \"SharedSlice\") {\n\t\t\tlegacySliceModel = { type: \"Group\", config: { fields: model.fields.items } }\n\t\t}\n\t} else {\n\t\tif (model?.type === \"SharedSlice\") {\n\t\t\tconst primaryModel = model.fields.primary?.[content.name]\n\t\t\tif (primaryModel?.type !== \"Group\") {\n\t\t\t\tlegacySliceModel = primaryModel\n\t\t\t}\n\t\t} else if (model?.type !== \"Group\") {\n\t\t\tlegacySliceModel = model\n\t\t}\n\t}\n\n\tconst traversedContent = traverseWidgetContent(path, key, apiID, content.widget, {\n\t\tmodel: legacySliceModel,\n\t\ttransformWidget,\n\t\ttransformSlice,\n\t})\n\n\tif (\n\t\ttraversedContent &&\n\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t) {\n\t\treturn transformSlice({\n\t\t\tpath,\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent: { ...content, widget: traversedContent },\n\t\t\tmodel,\n\t\t})\n\t}\n}\n\ntype TraverseGroupContentConfig = {\n\tmodel?: GroupModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseGroupContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: GroupContent,\n\tconfig: TraverseGroupContentConfig,\n): GroupContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tconst traversed = traverseGroupItemsContent(path, content.value, {\n\t\tmodel: model?.config?.fields,\n\t\ttransformWidget,\n\t})\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseGroupItemsContentConfig = {\n\tmodel?: Record<string, NestedGroupModel | NestableModel>\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseGroupItemsContent(\n\tpath: contentPath.Path,\n\tcontent: GroupItemContent[],\n\tconfig: TraverseGroupItemsContentConfig,\n): GroupItemContent[] {\n\tconst { transformWidget } = config\n\n\tconst traversed: GroupItemContent[] = []\n\tfor (const groupItemContent of content) {\n\t\t// Legacy v3 documents can have .value as a plain object or string\n\t\t// instead of the expected [key, content][] tuples.\n\t\tif (!Array.isArray(groupItemContent.value)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst groupItemPath = path.concat({ key: groupItemContent.key, type: \"GroupItem\" })\n\n\t\tconst traversedValue: GroupItemContent[\"value\"] = []\n\t\tfor (const [key, content] of groupItemContent.value) {\n\t\t\t// In some edge cases v3 handled implicitly, content\n\t\t\t// could be undefined, so we need to skip such cases.\n\t\t\tif (!content) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst model = config.model?.[key]\n\t\t\tconst traversedContent = traverseWidgetContent(\n\t\t\t\tgroupItemPath.concat({ key, type: \"Widget\" }),\n\t\t\t\tkey,\n\t\t\t\tkey,\n\t\t\t\tcontent,\n\t\t\t\t{ model, transformWidget },\n\t\t\t)\n\n\t\t\tif (\n\t\t\t\ttraversedContent &&\n\t\t\t\t(isNestableContent(traversedContent) || traversedContent.__TYPE__ === GroupContentType)\n\t\t\t) {\n\t\t\t\ttraversedValue.push([key, traversedContent])\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...groupItemContent, value: traversedValue })\n\t}\n\n\treturn traversed\n}\n\ntype TraverseRepeatableContentConfig = {\n\tmodel?: LinkModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseRepeatableContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: RepeatableContent,\n\tconfig: TraverseRepeatableContentConfig,\n): RepeatableContent | undefined {\n\tconst { model, transformWidget } = config\n\tconst nonRepeatModel =\n\t\tmodel?.type === \"Link\" && model.config\n\t\t\t? { ...model, config: { ...model.config, repeat: false } }\n\t\t\t: model\n\n\tconst traversed: RepeatableContent[\"value\"] = []\n\tfor (let index = 0; index < content.value.length; index++) {\n\t\tconst traversedContent = traverseWidgetContent(\n\t\t\tpath.concat({ key: index.toString(), type: \"Widget\" }),\n\t\t\tkey,\n\t\t\tapiID,\n\t\t\tcontent.value[index],\n\t\t\t{ model: nonRepeatModel, transformWidget },\n\t\t)\n\n\t\tif (traversedContent && isRepeatableContentValue(traversedContent)) {\n\t\t\ttraversed.push(traversedContent)\n\t\t}\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, value: traversed },\n\t\tmodel,\n\t})\n}\n\ntype TraverseTableContentConfig = {\n\tmodel?: TableModel\n\ttransformWidget: TraverseWidgetContentFunction\n}\n\nexport function traverseTableContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: TableContent,\n\tconfig: TraverseTableContentConfig,\n): TableContent | undefined {\n\tconst { model, transformWidget } = config\n\n\tconst traversed: TableContent[\"content\"] = []\n\tfor (let rowIndex = 0; rowIndex < content.content.length; rowIndex++) {\n\t\tconst traversedContent: TableContent[\"content\"][number][\"content\"] = []\n\t\tfor (let cellIndex = 0; cellIndex < content.content[rowIndex].content.length; cellIndex++) {\n\t\t\tconst cellPath = path.concat({ key: [rowIndex, cellIndex].join(\",\"), type: \"Widget\" })\n\t\t\tconst cell = content.content[rowIndex].content[cellIndex]\n\n\t\t\tconst transformed = transformWidget({\n\t\t\t\tpath: cellPath,\n\t\t\t\tkey,\n\t\t\t\tapiID,\n\t\t\t\tcontent: cell.content,\n\t\t\t\tmodel: TableCellModel,\n\t\t\t})\n\n\t\t\tif (transformed && transformed.__TYPE__ === RichTextContentType) {\n\t\t\t\ttraversedContent.push({ ...cell, content: transformed })\n\t\t\t} else {\n\t\t\t\ttraversedContent.push({\n\t\t\t\t\t...cell,\n\t\t\t\t\tcontent: {\n\t\t\t\t\t\t__TYPE__: RichTextContentType,\n\t\t\t\t\t\tvalue: [],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\ttraversed.push({ ...content.content[rowIndex], content: traversedContent })\n\t}\n\n\treturn transformWidget({\n\t\tpath,\n\t\tkey,\n\t\tapiID,\n\t\tcontent: { ...content, content: traversed },\n\t\tmodel,\n\t})\n}\n\nexport type TraverseSliceContentFunction = <TContent extends SliceItemContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent: TContent\n\tmodel?: SliceContentModel\n}) => TContent | SharedSliceItemContent | undefined\n\nexport type TraverseWidgetContentFunction<\n\tTContentTransformMode extends \"preserve\" | \"widen\" = \"preserve\",\n> = <TContent extends WidgetContent>(args: {\n\tpath: contentPath.Path\n\tkey: string\n\tapiID: string\n\tcontent: TContent\n\tmodel?: StaticWidgetModel\n}) => (TContentTransformMode extends \"preserve\" ? TContent : WidgetContent) | undefined\n\n// Internals\ntype TraverseWidgetContentConfig = {\n\tmodel?: StaticWidgetModel\n\ttransformWidget?: TraverseWidgetContentFunction\n\ttransformSlice?: TraverseSliceContentFunction\n}\n\nfunction traverseWidgetContent(\n\tpath: contentPath.Path,\n\tkey: string,\n\tapiID: string,\n\tcontent: WidgetContent,\n\tconfig: TraverseWidgetContentConfig,\n): WidgetContent | undefined {\n\tconst { transformWidget = (args) => args.content, transformSlice = (args) => args.content } =\n\t\tconfig\n\n\tif (content.__TYPE__ === SlicesContentType) {\n\t\tconst model =\n\t\t\tconfig.model?.type === \"Slices\" || config.model?.type === \"Choice\" ? config.model : undefined\n\t\treturn traverseSlicesContent(path, key, apiID, content, {\n\t\t\ttransformWidget,\n\t\t\ttransformSlice,\n\t\t\tmodel,\n\t\t})\n\t}\n\n\tif (content.__TYPE__ === GroupContentType) {\n\t\tconst model = config.model?.type === \"Group\" ? config.model : undefined\n\t\treturn traverseGroupContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tif (content.__TYPE__ === RepeatableContentType) {\n\t\tconst model = config.model?.type === \"Link\" ? config.model : undefined\n\t\treturn traverseRepeatableContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tif (content.__TYPE__ === TableContentType) {\n\t\tconst model = config.model?.type === \"Table\" ? config.model : undefined\n\t\treturn traverseTableContent(path, key, apiID, content, { transformWidget, model })\n\t}\n\n\tconst model =\n\t\tconfig.model?.type !== \"Slices\" &&\n\t\tconfig.model?.type !== \"Choice\" &&\n\t\tconfig.model?.type !== \"Group\" &&\n\t\tconfig.model?.type !== \"Table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A,UAAU,KAAK;GAAE,GAAG,QAAQ,QAAQ;GAAW,SAAS;EAAiB,CAAC;CAC3E;CAEA,OAAO,gBAAgB;EACtB;EACA;EACA;EACA,SAAS;GAAE,GAAG;GAAS,SAAS;EAAU;EAC1C;CACD,CAAC;AACF;AA2BA,SAAS,sBACR,MACA,KACA,OACA,SACA,QAC4B;CAC5B,MAAM,EAAE,mBAAmB,SAAS,KAAK,SAAS,kBAAkB,SAAS,KAAK,YACjF;CAED,IAAI,QAAQ,aAAA,oBAGX,OAAO,sBAAsB,MAAM,KAAK,OAAO,SAAS;EACvD;EACA;EACA,OAJA,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,SAAS,WAAW,OAAO,QAAQ,KAAA;CAKrF,CAAC;CAGF,IAAI,QAAQ,aAAA,oBAEX,OAAO,qBAAqB,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OAD5D,OAAO,OAAO,SAAS,UAAU,OAAO,QAAQ,KAAA;CACkB,CAAC;CAGlF,IAAI,QAAQ,aAAA,qBAEX,OAAO,0BAA0B,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OADjE,OAAO,OAAO,SAAS,SAAS,OAAO,QAAQ,KAAA;CACwB,CAAC;CAGvF,IAAI,QAAQ,aAAA,gBAEX,OAAO,qBAAqB,MAAM,KAAK,OAAO,SAAS;EAAE;EAAiB,OAD5D,OAAO,OAAO,SAAS,UAAU,OAAO,QAAQ,KAAA;CACkB,CAAC;CAUlF,OAAO,gBAAgB;EAAE;EAAM;EAAK;EAAO;EAAS,OANnD,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,SAAS,WACvB,OAAO,OAAO,SAAS,UACpB,OAAO,QACP,KAAA;CACsD,CAAC;AAC5D"}
package/dist/index.d.ts CHANGED
@@ -30,13 +30,13 @@ import { EmbedModel } from "./model/embed.js";
30
30
  import { GeoPointModel } from "./model/geopoint.js";
31
31
  import { ImageModel } from "./model/image.js";
32
32
  import { IntegrationFieldModel } from "./model/integrationField.js";
33
- import { LinkModel } from "./model/link.js";
33
+ import { CustomTypesModel, LinkModel } from "./model/link.js";
34
34
  import { NumberModel } from "./model/number.js";
35
35
  import { RangeModel } from "./model/range.js";
36
36
  import { RichTextModel, RichTextModelNodeType, RichTextModelNodeTypes } from "./model/richText.js";
37
37
  import { SelectModel } from "./model/select.js";
38
38
  import { SeparatorModel } from "./model/separator.js";
39
- import { TableCellModelNodeTypes, TableModel } from "./model/table.js";
39
+ import { TableCellModel, TableCellModelNodeTypes, TableModel } from "./model/table.js";
40
40
  import { TextModel } from "./model/text.js";
41
41
  import { TimestampModel } from "./model/timestamp.js";
42
42
  import { NestableModel } from "./model/nestable.js";
@@ -44,8 +44,8 @@ import { GroupModel, NestedGroupModel } from "./model/group.js";
44
44
  import { CompositeSliceModel, DynamicSliceModel, LegacySliceModel, SharedSliceModel, SharedSliceModelVariation, SharedSliceRefModel, SharedSliceVariationContentModel, SliceContentModel, SliceModelType, StaticSliceModel } from "./model/slice.js";
45
45
  import { DynamicSlicesModel, StaticSlicesModel } from "./model/slices.js";
46
46
  import { UIDModel } from "./model/uid.js";
47
- import { DynamicWidgetModel, FieldModelType, StaticWidgetModel } from "./model/widget.js";
48
- import { CustomTypeModel, DynamicCustomTypeModel, DynamicCustomTypeModelTab, StaticCustomTypeModel, StaticCustomTypeModelTab } from "./model/customType.js";
47
+ import { DynamicWidgetModel, FieldModelType, FieldOrSliceType, StaticWidgetModel } from "./model/widget.js";
48
+ import { CustomTypeModel, DynamicCustomTypeModel, DynamicCustomTypeModelTab, FlattenedStaticCustomTypeModel, StaticCustomTypeModel, StaticCustomTypeModelTab } from "./model/customType.js";
49
49
  import { AddedDiff, Diff, DiffOperation, RemovedDiff, UpdatedDiff } from "./model/diff/changes.js";
50
50
  import { GroupWidgetDiff, GroupWidgetWithFieldsDiff, NestableWidgetDiff, SlicePrimaryWidgetDiff } from "./model/diff/widgets.js";
51
51
  import { VariationDiff, VariationDiffComparator, VariationDiffMetadata } from "./model/diff/variation.js";
@@ -56,10 +56,10 @@ import { customTypeModel_d_exports } from "./helpers/customTypeModel.js";
56
56
  import { documentContent_d_exports } from "./helpers/documentContent.js";
57
57
  import { fieldModel_d_exports } from "./helpers/fieldModel.js";
58
58
  import { repository_d_exports } from "./helpers/repository.js";
59
+ import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
59
60
  import { sliceContent_d_exports } from "./helpers/sliceContent.js";
60
61
  import { sliceModel_d_exports } from "./helpers/sliceModel.js";
61
62
  import { withDefaultContent_d_exports } from "./helpers/withDefaultContent.js";
62
63
  import { imageContent_d_exports } from "./helpers/imageContent.js";
63
- import { TraverseSliceContentFunction, TraverseWidgetContentFunction, traverseCompositeSliceContent, traverseDocumentContent, traverseGroupContent, traverseGroupItemsContent, traverseLegacySliceContent, traverseRepeatableContent, traverseSharedSliceContent, traverseSlicesContent, traverseTableContent } from "./helpers/traverseContent.js";
64
64
  import { TraverseSliceContentWithModelFunction, TraverseWidgetContentWithModelFunction, traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
65
- export { type AddedDiff, type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type DateContent, type DateModel, type Diff, DiffOperation, 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 GroupWidgetDiff, type GroupWidgetWithFieldsDiff, 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 NestableWidgetDiff, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RemovedDiff, 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 SliceDiff, SliceDiffComparator, type SliceDiffMetadata, type SliceItemContent, type SliceModelType, type SlicePrimaryWidgetDiff, 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 UpdatedDiff, type VariationDiff, VariationDiffComparator, type VariationDiffMetadata, 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 };
65
+ export { type AddedDiff, type Asset, type BooleanContent, type BooleanModel, type ColorContent, type ColorModel, type CompositeSliceContent, type CompositeSliceItemContent, type CompositeSliceModel, type CustomTypeModel, type CustomTypesModel, type DateContent, type DateModel, type Diff, DiffOperation, 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 FieldOrSliceType, type FilledLinkContent, type FlattenedStaticCustomTypeModel, type GeoPointContent, type GeoPointModel, type GroupContent, type GroupItemContent, type GroupModel, type GroupWidgetDiff, type GroupWidgetWithFieldsDiff, 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 NestableWidgetDiff, type NestedGroupModel, type NonEmptyString, type NumberContent, type NumberModel, type RangeContent, type RangeModel, type RemovedDiff, 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 SliceDiff, SliceDiffComparator, type SliceDiffMetadata, type SliceItemContent, type SliceModelType, type SlicePrimaryWidgetDiff, type SlicesContent, type StaticCustomTypeModel, type StaticCustomTypeModelTab, type StaticSliceModel, type StaticSlicesModel, type StaticWidgetModel, TableCellModel, 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 UpdatedDiff, type VariationDiff, VariationDiffComparator, type VariationDiffMetadata, 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
@@ -2,7 +2,7 @@ import { RichTextNodeType } from "./content/legacy/richText.js";
2
2
  import "./content/richText.js";
3
3
  import { DiffOperation } from "./model/diff/changes.js";
4
4
  import { RichTextModelNodeType } from "./model/richText.js";
5
- import { TableCellModelNodeTypes } from "./model/table.js";
5
+ import { TableCellModel, TableCellModelNodeTypes } from "./model/table.js";
6
6
  import { VariationDiffComparator } from "./model/diff/variation.js";
7
7
  import { SliceDiffComparator } from "./model/diff/sharedSlice.js";
8
8
  import { LegacyContentCtx, defaultCtx, getFieldCtx } from "./content/codec/legacyContentCtx.js";
@@ -17,4 +17,4 @@ import { sliceModel_exports } from "./helpers/sliceModel.js";
17
17
  import { withDefaultContent_exports } from "./helpers/withDefaultContent.js";
18
18
  import { imageContent_exports } from "./helpers/imageContent.js";
19
19
  import { traverseCompositeSliceContentWithModel, traverseDocumentContentWithModel, traverseGroupContentWithModel, traverseGroupItemsContentWithModel, traverseLegacySliceContentWithModel, traverseRepeatableContentWithModel, traverseSharedSliceContentWithModel, traverseSlicesContentWithModel, traverseTableContentWithModel } from "./helpers/traverseContentWithModel.js";
20
- export { DiffOperation, LegacyContentCtx, RichTextModelNodeType, RichTextNodeType, SliceDiffComparator, TableCellModelNodeTypes, VariationDiffComparator, 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 };
20
+ export { DiffOperation, LegacyContentCtx, RichTextModelNodeType, RichTextNodeType, SliceDiffComparator, TableCellModel, TableCellModelNodeTypes, VariationDiffComparator, 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 };