@prismicio/types-internal 4.6.0-pr.26.ebb6cbc → 4.7.0-pr.28.255f9f9
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.
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/io-ts.d.ts +552 -552
- package/dist/io-ts.js +16 -16
- package/dist/model/diff/changes.d.ts +21 -0
- package/dist/model/diff/changes.d.ts.map +1 -0
- package/dist/model/diff/changes.js +11 -0
- package/dist/model/diff/changes.js.map +1 -0
- package/dist/model/diff/sharedSlice.d.ts +14 -0
- package/dist/model/diff/sharedSlice.d.ts.map +1 -0
- package/dist/model/diff/sharedSlice.js +45 -0
- package/dist/model/diff/sharedSlice.js.map +1 -0
- package/dist/model/diff/utils.js +40 -0
- package/dist/model/diff/utils.js.map +1 -0
- package/dist/model/diff/variation.d.ts +15 -0
- package/dist/model/diff/variation.d.ts.map +1 -0
- package/dist/model/diff/variation.js +92 -0
- package/dist/model/diff/variation.js.map +1 -0
- package/dist/model/diff/widgets.d.ts +15 -0
- package/dist/model/diff/widgets.d.ts.map +1 -0
- package/dist/model/nestable.js +3 -3
- package/dist/zod4.js +16 -16
- package/package.json +2 -2
- package/src/index.ts +12 -0
- package/src/model/diff/changes.ts +4 -4
- package/src/model/diff/sharedSlice.ts +8 -8
- package/src/model/diff/variation.ts +6 -6
- package/src/model/diff/widgets.ts +3 -3
package/dist/io-ts.js
CHANGED
|
@@ -3,10 +3,25 @@ import { ImageContentSchema as ImageContentSchema$1, ImageContentViewSchema as I
|
|
|
3
3
|
import { NonEmptyStringSchema as NonEmptyStringSchema$1 } from "./common/nonEmptyString.js";
|
|
4
4
|
import { EmptyLinkContentSchema as EmptyLinkContentSchema$1, FilledLinkContentSchema as FilledLinkContentSchema$1, LinkContentSchema as LinkContentSchema$1 } from "./content/link.js";
|
|
5
5
|
import { RichTextContentBlockSchema as RichTextContentBlockSchema$1, RichTextContentSchema as RichTextContentSchema$1, RichTextContentSpanSchema as RichTextContentSpanSchema$1 } from "./content/richText.js";
|
|
6
|
+
import { WidgetKeySchema as WidgetKeySchema$1 } from "./common/widgetKey.js";
|
|
7
|
+
import { BooleanModelSchema as BooleanModelSchema$1 } from "./model/boolean.js";
|
|
8
|
+
import { ColorModelSchema as ColorModelSchema$1 } from "./model/color.js";
|
|
9
|
+
import { DateModelSchema as DateModelSchema$1 } from "./model/date.js";
|
|
10
|
+
import { EmbedModelSchema as EmbedModelSchema$1 } from "./model/embed.js";
|
|
11
|
+
import { GeoPointModelSchema as GeoPointModelSchema$1 } from "./model/geopoint.js";
|
|
6
12
|
import { ImageModelSchema as ImageModelSchema$1 } from "./model/image.js";
|
|
13
|
+
import { IntegrationFieldModelSchema as IntegrationFieldModelSchema$1 } from "./model/integrationField.js";
|
|
14
|
+
import { LinkModelSchema as LinkModelSchema$1 } from "./model/link.js";
|
|
15
|
+
import { NumberModelSchema as NumberModelSchema$1 } from "./model/number.js";
|
|
16
|
+
import { RangeModelSchema as RangeModelSchema$1 } from "./model/range.js";
|
|
7
17
|
import { RichTextModelSchema as RichTextModelSchema$1 } from "./model/richText.js";
|
|
18
|
+
import { SelectModelSchema as SelectModelSchema$1 } from "./model/select.js";
|
|
19
|
+
import { SeparatorModelSchema as SeparatorModelSchema$1 } from "./model/separator.js";
|
|
8
20
|
import { TableModelSchema as TableModelSchema$1 } from "./model/table.js";
|
|
9
|
-
import {
|
|
21
|
+
import { TextModelSchema as TextModelSchema$1 } from "./model/text.js";
|
|
22
|
+
import { TimestampModelSchema as TimestampModelSchema$1 } from "./model/timestamp.js";
|
|
23
|
+
import { NestableModelSchema as NestableModelSchema$1 } from "./model/nestable.js";
|
|
24
|
+
import { GroupModelSchema as GroupModelSchema$1, NestedGroupModelSchema as NestedGroupModelSchema$1 } from "./model/group.js";
|
|
10
25
|
import { BooleanContentSchema as BooleanContentSchema$1 } from "./content/boolean.js";
|
|
11
26
|
import { EmptyContentSchema as EmptyContentSchema$1 } from "./content/empty.js";
|
|
12
27
|
import { ColorContentSchema as ColorContentSchema$1, DateContentSchema as DateContentSchema$1, FieldContentSchema as FieldContentSchema$1, NumberContentSchema as NumberContentSchema$1, RangeContentSchema as RangeContentSchema$1, SelectContentSchema as SelectContentSchema$1, TextContentSchema as TextContentSchema$1, TimestampContentSchema as TimestampContentSchema$1 } from "./content/field.js";
|
|
@@ -41,21 +56,6 @@ import { SliceItemLegacyCodec, SlicesLegacyCodec } from "./content/codec/slices.
|
|
|
41
56
|
import { UIDLegacyCodec } from "./content/codec/uid.js";
|
|
42
57
|
import { WidgetLegacyCodec } from "./content/codec/widget.js";
|
|
43
58
|
import { DocumentLegacyCodec } from "./content/codec/document.js";
|
|
44
|
-
import { BooleanModelSchema as BooleanModelSchema$1 } from "./model/boolean.js";
|
|
45
|
-
import { ColorModelSchema as ColorModelSchema$1 } from "./model/color.js";
|
|
46
|
-
import { DateModelSchema as DateModelSchema$1 } from "./model/date.js";
|
|
47
|
-
import { EmbedModelSchema as EmbedModelSchema$1 } from "./model/embed.js";
|
|
48
|
-
import { GeoPointModelSchema as GeoPointModelSchema$1 } from "./model/geopoint.js";
|
|
49
|
-
import { IntegrationFieldModelSchema as IntegrationFieldModelSchema$1 } from "./model/integrationField.js";
|
|
50
|
-
import { LinkModelSchema as LinkModelSchema$1 } from "./model/link.js";
|
|
51
|
-
import { NumberModelSchema as NumberModelSchema$1 } from "./model/number.js";
|
|
52
|
-
import { RangeModelSchema as RangeModelSchema$1 } from "./model/range.js";
|
|
53
|
-
import { SelectModelSchema as SelectModelSchema$1 } from "./model/select.js";
|
|
54
|
-
import { SeparatorModelSchema as SeparatorModelSchema$1 } from "./model/separator.js";
|
|
55
|
-
import { TextModelSchema as TextModelSchema$1 } from "./model/text.js";
|
|
56
|
-
import { TimestampModelSchema as TimestampModelSchema$1 } from "./model/timestamp.js";
|
|
57
|
-
import { NestableModelSchema as NestableModelSchema$1 } from "./model/nestable.js";
|
|
58
|
-
import { GroupModelSchema as GroupModelSchema$1, NestedGroupModelSchema as NestedGroupModelSchema$1 } from "./model/group.js";
|
|
59
59
|
import { CompositeSliceModelSchema as CompositeSliceModelSchema$1, DynamicSliceModelSchema as DynamicSliceModelSchema$1, LegacySliceModelSchema as LegacySliceModelSchema$1, SharedSliceModelSchema as SharedSliceModelSchema$1, SharedSliceModelVariationSchema as SharedSliceModelVariationSchema$1, SharedSliceRefModelSchema as SharedSliceRefModelSchema$1, SliceContentModelSchema as SliceContentModelSchema$1, StaticSliceModelSchema as StaticSliceModelSchema$1 } from "./model/slice.js";
|
|
60
60
|
import { DynamicSlicesModelSchema as DynamicSlicesModelSchema$1, StaticSlicesModelSchema as StaticSlicesModelSchema$1 } from "./model/slices.js";
|
|
61
61
|
import { UIDModelSchema as UIDModelSchema$1 } from "./model/uid.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/model/diff/changes.d.ts
|
|
2
|
+
declare enum DiffOperation {
|
|
3
|
+
Added = "added",
|
|
4
|
+
Removed = "removed",
|
|
5
|
+
Updated = "updated"
|
|
6
|
+
}
|
|
7
|
+
type AddedDiff<A> = {
|
|
8
|
+
op: DiffOperation.Added;
|
|
9
|
+
value: A;
|
|
10
|
+
};
|
|
11
|
+
type RemovedDiff = {
|
|
12
|
+
op: DiffOperation.Removed;
|
|
13
|
+
};
|
|
14
|
+
type UpdatedDiff<A> = {
|
|
15
|
+
op: DiffOperation.Updated;
|
|
16
|
+
value: A;
|
|
17
|
+
};
|
|
18
|
+
type Diff<A, U> = AddedDiff<A> | UpdatedDiff<U> | RemovedDiff;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AddedDiff, Diff, DiffOperation, RemovedDiff, UpdatedDiff };
|
|
21
|
+
//# sourceMappingURL=changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.d.ts","names":[],"sources":["../../../src/model/diff/changes.ts"],"mappings":";aAAY;EACX;EACA;EACA;;KAGW,UAAU;EACrB,IAAI,cAAc;EAClB,OAAO;;KAGI;EACX,IAAI,cAAc;;KAGP,YAAY;EACvB,IAAI,cAAc;EAClB,OAAO;;KAGI,KAAK,GAAG,KAAK,UAAU,KAAK,YAAY,KAAK"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/model/diff/changes.ts
|
|
2
|
+
let DiffOperation = /* @__PURE__ */ function(DiffOperation) {
|
|
3
|
+
DiffOperation["Added"] = "added";
|
|
4
|
+
DiffOperation["Removed"] = "removed";
|
|
5
|
+
DiffOperation["Updated"] = "updated";
|
|
6
|
+
return DiffOperation;
|
|
7
|
+
}({});
|
|
8
|
+
//#endregion
|
|
9
|
+
export { DiffOperation };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.js","names":[],"sources":["../../../src/model/diff/changes.ts"],"sourcesContent":["export enum DiffOperation {\n\tAdded = \"added\",\n\tRemoved = \"removed\",\n\tUpdated = \"updated\",\n}\n\nexport type AddedDiff<A> = {\n\top: DiffOperation.Added\n\tvalue: A\n}\n\nexport type RemovedDiff = {\n\top: DiffOperation.Removed\n}\n\nexport type UpdatedDiff<A> = {\n\top: DiffOperation.Updated\n\tvalue: A\n}\n\nexport type Diff<A, U> = AddedDiff<A> | UpdatedDiff<U> | RemovedDiff\n"],"mappings":";AAAA,IAAY,gBAAL,yBAAA,eAAA;CACN,cAAA,WAAA;CACA,cAAA,aAAA;CACA,cAAA,aAAA;;AACD,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SharedSliceModel } from "../slice.js";
|
|
2
|
+
import { Diff } from "./changes.js";
|
|
3
|
+
import { VariationDiff } from "./variation.js";
|
|
4
|
+
//#region src/model/diff/sharedSlice.d.ts
|
|
5
|
+
type SliceDiffMetadata = Omit<SharedSliceModel, "variations">;
|
|
6
|
+
type SliceDiff = Diff<SharedSliceModel, Partial<SliceDiffMetadata & {
|
|
7
|
+
variations?: Partial<Record<string, VariationDiff>>;
|
|
8
|
+
}>>;
|
|
9
|
+
declare const SliceDiffComparator: {
|
|
10
|
+
compare(sliceA?: SharedSliceModel, sliceB?: SharedSliceModel): SliceDiff | undefined;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { SliceDiff, SliceDiffComparator, SliceDiffMetadata };
|
|
14
|
+
//# sourceMappingURL=sharedSlice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedSlice.d.ts","names":[],"sources":["../../../src/model/diff/sharedSlice.ts"],"mappings":";;;;KAKY,oBAAoB,KAAK;KACzB,YAAY,KACvB,kBACA,QACC;EACC,aAAa,QAAQ,eAAe;;cAmB1B;EACZ,QAAO,SAAU,kBAAgB,SAAW,mBAAmB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "./changes.js";
|
|
2
|
+
import { isNotEmpty, toRecord, zipObjects } from "./utils.js";
|
|
3
|
+
import { VariationDiffComparator } from "./variation.js";
|
|
4
|
+
//#region src/model/diff/sharedSlice.ts
|
|
5
|
+
function compareSliceMeta(sliceA, sliceB) {
|
|
6
|
+
const zippedSlices = zipObjects(sliceA, sliceB);
|
|
7
|
+
return Object.entries(zippedSlices).reduce((acc, [key, value]) => {
|
|
8
|
+
if (key === "variations") return acc;
|
|
9
|
+
if (value?.left === value?.right) return acc;
|
|
10
|
+
return {
|
|
11
|
+
...acc,
|
|
12
|
+
[key]: value?.right
|
|
13
|
+
};
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
const SliceDiffComparator = { compare(sliceA, sliceB) {
|
|
17
|
+
if (!sliceA && sliceB) return {
|
|
18
|
+
op: "added",
|
|
19
|
+
value: sliceB
|
|
20
|
+
};
|
|
21
|
+
if (sliceA && !sliceB) return { op: "removed" };
|
|
22
|
+
const diffMeta = compareSliceMeta(sliceA, sliceB);
|
|
23
|
+
const zippedSlices = zipObjects(sliceA && toRecord(sliceA.variations, (v) => v.id), sliceB && toRecord(sliceB.variations, (v) => v.id));
|
|
24
|
+
const diffVariations = Object.entries(zippedSlices).reduce((acc, [variationId, value]) => {
|
|
25
|
+
if (!value) return acc;
|
|
26
|
+
const vDiff = VariationDiffComparator.compare(value.left, value.right);
|
|
27
|
+
if (!vDiff) return acc;
|
|
28
|
+
return {
|
|
29
|
+
...acc,
|
|
30
|
+
[variationId]: vDiff
|
|
31
|
+
};
|
|
32
|
+
}, {});
|
|
33
|
+
const diffSlice = {
|
|
34
|
+
...diffMeta,
|
|
35
|
+
...isNotEmpty(diffVariations) ? { variations: diffVariations } : {}
|
|
36
|
+
};
|
|
37
|
+
if (isNotEmpty(diffSlice)) return {
|
|
38
|
+
op: "updated",
|
|
39
|
+
value: diffSlice
|
|
40
|
+
};
|
|
41
|
+
} };
|
|
42
|
+
//#endregion
|
|
43
|
+
export { SliceDiffComparator };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=sharedSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedSlice.js","names":[],"sources":["../../../src/model/diff/sharedSlice.ts"],"sourcesContent":["import type { SharedSliceModel, SharedSliceModelVariation } from \"../slice\"\nimport { type Diff, DiffOperation } from \"./changes\"\nimport { isNotEmpty, toRecord, zipObjects } from \"./utils\"\nimport { type VariationDiff, VariationDiffComparator } from \"./variation\"\n\nexport type SliceDiffMetadata = Omit<SharedSliceModel, \"variations\">\nexport type SliceDiff = Diff<\n\tSharedSliceModel,\n\tPartial<\n\t\tSliceDiffMetadata & {\n\t\t\tvariations?: Partial<Record<string, VariationDiff>>\n\t\t}\n\t>\n>\n\nfunction compareSliceMeta(\n\tsliceA?: SharedSliceModel,\n\tsliceB?: SharedSliceModel,\n): Partial<SliceDiffMetadata> {\n\tconst zippedSlices = zipObjects(sliceA, sliceB)\n\n\treturn Object.entries(zippedSlices).reduce((acc, [key, value]) => {\n\t\tif (key === \"variations\") return acc\n\n\t\tif (value?.left === value?.right) return acc\n\t\treturn { ...acc, [key]: value?.right }\n\t}, {})\n}\n\nexport const SliceDiffComparator = {\n\tcompare(sliceA?: SharedSliceModel, sliceB?: SharedSliceModel): SliceDiff | undefined {\n\t\tif (!sliceA && sliceB)\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Added,\n\t\t\t\tvalue: sliceB,\n\t\t\t}\n\t\tif (sliceA && !sliceB)\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Removed,\n\t\t\t}\n\n\t\tconst diffMeta = compareSliceMeta(sliceA, sliceB)\n\n\t\tconst zippedSlices = zipObjects<SharedSliceModelVariation>(\n\t\t\tsliceA && toRecord(sliceA.variations, (v) => v.id),\n\t\t\tsliceB && toRecord(sliceB.variations, (v) => v.id),\n\t\t)\n\n\t\tconst diffVariations = Object.entries(zippedSlices).reduce<\n\t\t\tPartial<Record<string, VariationDiff>>\n\t\t>((acc, [variationId, value]) => {\n\t\t\tif (!value) return acc\n\n\t\t\tconst vDiff = VariationDiffComparator.compare(value.left, value.right)\n\t\t\tif (!vDiff) return acc\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[variationId]: vDiff,\n\t\t\t}\n\t\t}, {})\n\n\t\tconst diffSlice = {\n\t\t\t...diffMeta,\n\t\t\t...(isNotEmpty(diffVariations) ? { variations: diffVariations } : {}),\n\t\t}\n\n\t\tif (isNotEmpty(diffSlice)) {\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Updated,\n\t\t\t\tvalue: diffSlice,\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t},\n}\n"],"mappings":";;;;AAeA,SAAS,iBACR,QACA,QAC6B;CAC7B,MAAM,eAAe,WAAW,QAAQ,MAAM;CAE9C,OAAO,OAAO,QAAQ,YAAY,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;EACjE,IAAI,QAAQ,cAAc,OAAO;EAEjC,IAAI,OAAO,SAAS,OAAO,OAAO,OAAO;EACzC,OAAO;GAAE,GAAG;IAAM,MAAM,OAAO;EAAM;CACtC,GAAG,CAAC,CAAC;AACN;AAEA,MAAa,sBAAsB,EAClC,QAAQ,QAA2B,QAAkD;CACpF,IAAI,CAAC,UAAU,QACd,OAAO;EACN,IAAA;EACA,OAAO;CACR;CACD,IAAI,UAAU,CAAC,QACd,OAAO,EACN,IAAA,UACD;CAED,MAAM,WAAW,iBAAiB,QAAQ,MAAM;CAEhD,MAAM,eAAe,WACpB,UAAU,SAAS,OAAO,aAAa,MAAM,EAAE,EAAE,GACjD,UAAU,SAAS,OAAO,aAAa,MAAM,EAAE,EAAE,CAClD;CAEA,MAAM,iBAAiB,OAAO,QAAQ,YAAY,CAAC,CAAC,QAEjD,KAAK,CAAC,aAAa,WAAW;EAChC,IAAI,CAAC,OAAO,OAAO;EAEnB,MAAM,QAAQ,wBAAwB,QAAQ,MAAM,MAAM,MAAM,KAAK;EACrE,IAAI,CAAC,OAAO,OAAO;EACnB,OAAO;GACN,GAAG;IACF,cAAc;EAChB;CACD,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY;EACjB,GAAG;EACH,GAAI,WAAW,cAAc,IAAI,EAAE,YAAY,eAAe,IAAI,CAAC;CACpE;CAEA,IAAI,WAAW,SAAS,GACvB,OAAO;EACN,IAAA;EACA,OAAO;CACR;AAGF,EACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/model/diff/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Zips two objects together by their keys, creating an object with
|
|
4
|
+
* both left and right values for each key.
|
|
5
|
+
*/
|
|
6
|
+
function zipObjects(objLeft, objRight) {
|
|
7
|
+
return [...new Set(Object.keys(objLeft || {}).concat(Object.keys(objRight || {})))].reduce((acc, key) => {
|
|
8
|
+
const left = objLeft?.[key];
|
|
9
|
+
const right = objRight?.[key];
|
|
10
|
+
return {
|
|
11
|
+
...acc,
|
|
12
|
+
[key]: {
|
|
13
|
+
left,
|
|
14
|
+
right
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the object has at least one key.
|
|
21
|
+
*/
|
|
22
|
+
function isNotEmpty(obj) {
|
|
23
|
+
return Boolean(Object.keys(obj).length);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts an array to a record using the provided key function.
|
|
27
|
+
*/
|
|
28
|
+
function toRecord(arr, key) {
|
|
29
|
+
return arr.reduce((acc, entry) => {
|
|
30
|
+
const k = key(entry);
|
|
31
|
+
return {
|
|
32
|
+
...acc,
|
|
33
|
+
[k]: entry
|
|
34
|
+
};
|
|
35
|
+
}, {});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { isNotEmpty, toRecord, zipObjects };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/model/diff/utils.ts"],"sourcesContent":["/**\n * Zips two objects together by their keys, creating an object with\n * both left and right values for each key.\n */\nexport function zipObjects<A, B = A>(\n\tobjLeft?: Partial<Record<string, A>> | undefined,\n\tobjRight?: Partial<Record<string, B>> | undefined,\n): Partial<Record<string, { left?: A | undefined; right?: B | undefined }>> {\n\tconst allKeys = [...new Set(Object.keys(objLeft || {}).concat(Object.keys(objRight || {})))]\n\n\treturn allKeys.reduce<Record<string, { left?: A | undefined; right?: B | undefined }>>(\n\t\t(acc, key) => {\n\t\t\tconst left = objLeft?.[key]\n\t\t\tconst right = objRight?.[key]\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: { left, right },\n\t\t\t}\n\t\t},\n\t\t{},\n\t)\n}\n\n/**\n * Returns true if the object has at least one key.\n */\nexport function isNotEmpty<A extends object>(obj: A): boolean {\n\treturn Boolean(Object.keys(obj).length)\n}\n\n/**\n * Converts an array to a record using the provided key function.\n */\nexport function toRecord<A extends object>(\n\tarr: ReadonlyArray<A>,\n\tkey: (obj: A) => string,\n): Record<string, A> {\n\treturn arr.reduce<Record<string, A>>((acc, entry) => {\n\t\tconst k = key(entry)\n\t\treturn {\n\t\t\t...acc,\n\t\t\t[k]: entry,\n\t\t}\n\t}, {})\n}\n"],"mappings":";;;;;AAIA,SAAgB,WACf,SACA,UAC2E;CAG3E,OAAO,CAFU,GAAG,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAE7E,CAAC,CAAC,QACb,KAAK,QAAQ;EACb,MAAM,OAAO,UAAU;EACvB,MAAM,QAAQ,WAAW;EACzB,OAAO;GACN,GAAG;IACF,MAAM;IAAE;IAAM;GAAM;EACtB;CACD,GACA,CAAC,CACF;AACD;;;;AAKA,SAAgB,WAA6B,KAAiB;CAC7D,OAAO,QAAQ,OAAO,KAAK,GAAG,CAAC,CAAC,MAAM;AACvC;;;;AAKA,SAAgB,SACf,KACA,KACoB;CACpB,OAAO,IAAI,QAA2B,KAAK,UAAU;EACpD,MAAM,IAAI,IAAI,KAAK;EACnB,OAAO;GACN,GAAG;IACF,IAAI;EACN;CACD,GAAG,CAAC,CAAC;AACN"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SharedSliceModelVariation } from "../slice.js";
|
|
2
|
+
import { Diff } from "./changes.js";
|
|
3
|
+
import { NestableWidgetDiff, SlicePrimaryWidgetDiff } from "./widgets.js";
|
|
4
|
+
//#region src/model/diff/variation.d.ts
|
|
5
|
+
type VariationDiffMetadata = Omit<SharedSliceModelVariation, "primary" | "items">;
|
|
6
|
+
type VariationDiff = Diff<SharedSliceModelVariation, Partial<VariationDiffMetadata> & {
|
|
7
|
+
primary?: Record<string, SlicePrimaryWidgetDiff>;
|
|
8
|
+
items?: Record<string, NestableWidgetDiff>;
|
|
9
|
+
}>;
|
|
10
|
+
declare const VariationDiffComparator: {
|
|
11
|
+
compare(variationA?: SharedSliceModelVariation, variationB?: SharedSliceModelVariation): VariationDiff | undefined;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { VariationDiff, VariationDiffComparator, VariationDiffMetadata };
|
|
15
|
+
//# sourceMappingURL=variation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variation.d.ts","names":[],"sources":["../../../src/model/diff/variation.ts"],"mappings":";;;;KAYY,wBAAwB,KAAK;KAC7B,gBAAgB,KAC3B,2BACA,QAAQ;EACP,UAAU,eAAe;EACzB,QAAQ,eAAe;;cAsGZ;EACZ,QAAO,aACO,2BAAyB,aACzB,4BACX"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import "./changes.js";
|
|
2
|
+
import { isNotEmpty, zipObjects } from "./utils.js";
|
|
3
|
+
import "../group.js";
|
|
4
|
+
//#region src/model/diff/variation.ts
|
|
5
|
+
function compareVariationMeta(variationA, variationB) {
|
|
6
|
+
const zippedVariations = zipObjects(variationA, variationB);
|
|
7
|
+
return Object.entries(zippedVariations).reduce((acc, [key, value]) => {
|
|
8
|
+
if (key === "primary" || key === "items") return acc;
|
|
9
|
+
if (value?.left === value?.right) return acc;
|
|
10
|
+
return {
|
|
11
|
+
...acc,
|
|
12
|
+
[key]: value?.right
|
|
13
|
+
};
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
function compareWidgets(widgetsA, widgetsB) {
|
|
17
|
+
const zippedWidgets = zipObjects(widgetsA, widgetsB);
|
|
18
|
+
const diffWidgets = Object.entries(zippedWidgets).reduce((acc, [widgetKey, widgetValue]) => {
|
|
19
|
+
if (JSON.stringify(widgetValue?.left) === JSON.stringify(widgetValue?.right)) return acc;
|
|
20
|
+
const changes = (() => {
|
|
21
|
+
if (!widgetValue?.left && !widgetValue?.right) return;
|
|
22
|
+
if (widgetValue?.left && !widgetValue.right) return { op: "removed" };
|
|
23
|
+
if (!widgetValue?.left && widgetValue?.right) {
|
|
24
|
+
if (widgetValue.right?.type === "Group") {
|
|
25
|
+
const group = {
|
|
26
|
+
...widgetValue.right,
|
|
27
|
+
config: {
|
|
28
|
+
...widgetValue.right.config,
|
|
29
|
+
fields: {}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
group.config.fields = compareWidgets(void 0, widgetValue.right.config?.fields) || {};
|
|
33
|
+
return {
|
|
34
|
+
op: "added",
|
|
35
|
+
value: group
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
op: "added",
|
|
40
|
+
value: widgetValue.right
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (widgetValue.right?.type === "Group") {
|
|
44
|
+
const group = {
|
|
45
|
+
...widgetValue.right,
|
|
46
|
+
config: {
|
|
47
|
+
...widgetValue.right.config,
|
|
48
|
+
fields: {}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
group.config.fields = compareWidgets(widgetValue.left?.type === "Group" ? widgetValue.left?.config?.fields : void 0, widgetValue.right.config?.fields) || {};
|
|
52
|
+
return {
|
|
53
|
+
op: "updated",
|
|
54
|
+
value: group
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
op: "updated",
|
|
59
|
+
value: widgetValue.right
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
if (!changes) return acc;
|
|
63
|
+
return {
|
|
64
|
+
...acc,
|
|
65
|
+
[widgetKey]: changes
|
|
66
|
+
};
|
|
67
|
+
}, {});
|
|
68
|
+
return isNotEmpty(diffWidgets) ? diffWidgets : void 0;
|
|
69
|
+
}
|
|
70
|
+
const VariationDiffComparator = { compare(variationA, variationB) {
|
|
71
|
+
if (variationA && !variationB) return { op: "removed" };
|
|
72
|
+
if (!variationA && variationB) return {
|
|
73
|
+
op: "added",
|
|
74
|
+
value: variationB
|
|
75
|
+
};
|
|
76
|
+
const diffMeta = compareVariationMeta(variationA, variationB);
|
|
77
|
+
const diffPrimary = compareWidgets(variationA?.primary, variationB?.primary);
|
|
78
|
+
const diffItems = compareWidgets(variationA?.items, variationB?.items);
|
|
79
|
+
const diffVariation = {
|
|
80
|
+
...diffMeta,
|
|
81
|
+
...diffPrimary ? { primary: diffPrimary } : {},
|
|
82
|
+
...diffItems ? { items: diffItems } : {}
|
|
83
|
+
};
|
|
84
|
+
if (isNotEmpty(diffVariation)) return {
|
|
85
|
+
op: "updated",
|
|
86
|
+
value: diffVariation
|
|
87
|
+
};
|
|
88
|
+
} };
|
|
89
|
+
//#endregion
|
|
90
|
+
export { VariationDiffComparator };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=variation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variation.js","names":[],"sources":["../../../src/model/diff/variation.ts"],"sourcesContent":["import type { GroupModel } from \"../group\"\nimport { GroupFieldType } from \"../group\"\nimport type { NestableModel } from \"../nestable\"\nimport type { SharedSliceModelVariation } from \"../slice\"\nimport { type Diff, DiffOperation } from \"./changes\"\nimport { isNotEmpty, zipObjects } from \"./utils\"\nimport type {\n\tGroupWidgetWithFieldsDiff,\n\tNestableWidgetDiff,\n\tSlicePrimaryWidgetDiff,\n} from \"./widgets\"\n\nexport type VariationDiffMetadata = Omit<SharedSliceModelVariation, \"primary\" | \"items\">\nexport type VariationDiff = Diff<\n\tSharedSliceModelVariation,\n\tPartial<VariationDiffMetadata> & {\n\t\tprimary?: Record<string, SlicePrimaryWidgetDiff>\n\t\titems?: Record<string, NestableWidgetDiff>\n\t}\n>\n\nfunction compareVariationMeta(\n\tvariationA?: SharedSliceModelVariation,\n\tvariationB?: SharedSliceModelVariation,\n): Partial<VariationDiffMetadata> {\n\tconst zippedVariations = zipObjects(variationA, variationB)\n\n\treturn Object.entries(zippedVariations).reduce((acc, [key, value]) => {\n\t\tif (key === \"primary\" || key === \"items\") return acc\n\n\t\tif (value?.left === value?.right) return acc\n\t\treturn { ...acc, [key]: value?.right }\n\t}, {})\n}\n\nfunction compareWidgets<TWidget extends NestableModel | GroupModel>(\n\twidgetsA?: { [key: string]: TWidget },\n\twidgetsB?: { [key: string]: TWidget },\n):\n\t| Record<string, TWidget extends GroupModel ? SlicePrimaryWidgetDiff : NestableWidgetDiff>\n\t| undefined {\n\tconst zippedWidgets = zipObjects(widgetsA, widgetsB)\n\n\tconst diffWidgets = Object.entries(zippedWidgets).reduce((acc, [widgetKey, widgetValue]) => {\n\t\tif (JSON.stringify(widgetValue?.left) === JSON.stringify(widgetValue?.right)) return acc\n\n\t\tconst changes = (() => {\n\t\t\tif (!widgetValue?.left && !widgetValue?.right) return\n\n\t\t\tif (widgetValue?.left && !widgetValue.right) {\n\t\t\t\treturn {\n\t\t\t\t\top: DiffOperation.Removed,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!widgetValue?.left && widgetValue?.right) {\n\t\t\t\tif (widgetValue.right?.type === GroupFieldType) {\n\t\t\t\t\tconst group: GroupWidgetWithFieldsDiff = {\n\t\t\t\t\t\t...widgetValue.right,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t...widgetValue.right.config,\n\t\t\t\t\t\t\tfields: {},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t\t// On added groups, this basically marks all fields in the group as added\n\t\t\t\t\tgroup.config.fields = compareWidgets(undefined, widgetValue.right.config?.fields) || {}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\top: DiffOperation.Added,\n\t\t\t\t\t\tvalue: group,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\top: DiffOperation.Added,\n\t\t\t\t\tvalue: widgetValue.right,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (widgetValue.right?.type === GroupFieldType) {\n\t\t\t\tconst group: GroupWidgetWithFieldsDiff = {\n\t\t\t\t\t...widgetValue.right,\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\t...widgetValue.right.config,\n\t\t\t\t\t\tfields: {},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t\t// On updated groups, this also compares the fields inside the group\n\t\t\t\tgroup.config.fields =\n\t\t\t\t\tcompareWidgets(\n\t\t\t\t\t\twidgetValue.left?.type === GroupFieldType\n\t\t\t\t\t\t\t? widgetValue.left?.config?.fields\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\twidgetValue.right.config?.fields,\n\t\t\t\t\t) || {}\n\n\t\t\t\treturn {\n\t\t\t\t\top: DiffOperation.Updated,\n\t\t\t\t\tvalue: group,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Updated,\n\t\t\t\tvalue: widgetValue.right,\n\t\t\t}\n\t\t})()\n\n\t\tif (!changes) return acc\n\n\t\treturn {\n\t\t\t...acc,\n\t\t\t[widgetKey]: changes,\n\t\t}\n\t}, {})\n\n\treturn isNotEmpty(diffWidgets) ? diffWidgets : undefined\n}\n\nexport const VariationDiffComparator = {\n\tcompare(\n\t\tvariationA?: SharedSliceModelVariation,\n\t\tvariationB?: SharedSliceModelVariation,\n\t): VariationDiff | undefined {\n\t\tif (variationA && !variationB)\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Removed,\n\t\t\t}\n\t\tif (!variationA && variationB) {\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Added,\n\t\t\t\tvalue: variationB,\n\t\t\t}\n\t\t}\n\n\t\tconst diffMeta = compareVariationMeta(variationA, variationB)\n\n\t\tconst diffPrimary = compareWidgets(variationA?.primary, variationB?.primary)\n\t\tconst diffItems = compareWidgets(variationA?.items, variationB?.items)\n\n\t\tconst diffVariation = {\n\t\t\t...diffMeta,\n\t\t\t...(diffPrimary ? { primary: diffPrimary } : {}),\n\t\t\t...(diffItems ? { items: diffItems } : {}),\n\t\t}\n\n\t\tif (isNotEmpty(diffVariation)) {\n\t\t\treturn {\n\t\t\t\top: DiffOperation.Updated,\n\t\t\t\tvalue: diffVariation,\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t},\n}\n"],"mappings":";;;;AAqBA,SAAS,qBACR,YACA,YACiC;CACjC,MAAM,mBAAmB,WAAW,YAAY,UAAU;CAE1D,OAAO,OAAO,QAAQ,gBAAgB,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;EACrE,IAAI,QAAQ,aAAa,QAAQ,SAAS,OAAO;EAEjD,IAAI,OAAO,SAAS,OAAO,OAAO,OAAO;EACzC,OAAO;GAAE,GAAG;IAAM,MAAM,OAAO;EAAM;CACtC,GAAG,CAAC,CAAC;AACN;AAEA,SAAS,eACR,UACA,UAGY;CACZ,MAAM,gBAAgB,WAAW,UAAU,QAAQ;CAEnD,MAAM,cAAc,OAAO,QAAQ,aAAa,CAAC,CAAC,QAAQ,KAAK,CAAC,WAAW,iBAAiB;EAC3F,IAAI,KAAK,UAAU,aAAa,IAAI,MAAM,KAAK,UAAU,aAAa,KAAK,GAAG,OAAO;EAErF,MAAM,iBAAiB;GACtB,IAAI,CAAC,aAAa,QAAQ,CAAC,aAAa,OAAO;GAE/C,IAAI,aAAa,QAAQ,CAAC,YAAY,OACrC,OAAO,EACN,IAAA,UACD;GAGD,IAAI,CAAC,aAAa,QAAQ,aAAa,OAAO;IAC7C,IAAI,YAAY,OAAO,SAAA,SAAyB;KAC/C,MAAM,QAAmC;MACxC,GAAG,YAAY;MACf,QAAQ;OACP,GAAG,YAAY,MAAM;OACrB,QAAQ,CAAC;MACV;KACD;KAEA,MAAM,OAAO,SAAS,eAAe,KAAA,GAAW,YAAY,MAAM,QAAQ,MAAM,KAAK,CAAC;KAEtF,OAAO;MACN,IAAA;MACA,OAAO;KACR;IACD;IAEA,OAAO;KACN,IAAA;KACA,OAAO,YAAY;IACpB;GACD;GAEA,IAAI,YAAY,OAAO,SAAA,SAAyB;IAC/C,MAAM,QAAmC;KACxC,GAAG,YAAY;KACf,QAAQ;MACP,GAAG,YAAY,MAAM;MACrB,QAAQ,CAAC;KACV;IACD;IAEA,MAAM,OAAO,SACZ,eACC,YAAY,MAAM,SAAA,UACf,YAAY,MAAM,QAAQ,SAC1B,KAAA,GACH,YAAY,MAAM,QAAQ,MAC3B,KAAK,CAAC;IAEP,OAAO;KACN,IAAA;KACA,OAAO;IACR;GACD;GAEA,OAAO;IACN,IAAA;IACA,OAAO,YAAY;GACpB;EACD,EAAA,CAAG;EAEH,IAAI,CAAC,SAAS,OAAO;EAErB,OAAO;GACN,GAAG;IACF,YAAY;EACd;CACD,GAAG,CAAC,CAAC;CAEL,OAAO,WAAW,WAAW,IAAI,cAAc,KAAA;AAChD;AAEA,MAAa,0BAA0B,EACtC,QACC,YACA,YAC4B;CAC5B,IAAI,cAAc,CAAC,YAClB,OAAO,EACN,IAAA,UACD;CACD,IAAI,CAAC,cAAc,YAClB,OAAO;EACN,IAAA;EACA,OAAO;CACR;CAGD,MAAM,WAAW,qBAAqB,YAAY,UAAU;CAE5D,MAAM,cAAc,eAAe,YAAY,SAAS,YAAY,OAAO;CAC3E,MAAM,YAAY,eAAe,YAAY,OAAO,YAAY,KAAK;CAErE,MAAM,gBAAgB;EACrB,GAAG;EACH,GAAI,cAAc,EAAE,SAAS,YAAY,IAAI,CAAC;EAC9C,GAAI,YAAY,EAAE,OAAO,UAAU,IAAI,CAAC;CACzC;CAEA,IAAI,WAAW,aAAa,GAC3B,OAAO;EACN,IAAA;EACA,OAAO;CACR;AAGF,EACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NestableModel } from "../nestable.js";
|
|
2
|
+
import { GroupModel } from "../group.js";
|
|
3
|
+
import { Diff } from "./changes.js";
|
|
4
|
+
//#region src/model/diff/widgets.d.ts
|
|
5
|
+
type NestableWidgetDiff = Diff<NestableModel, NestableModel>;
|
|
6
|
+
type GroupWidgetWithFieldsDiff = Omit<GroupModel, "config"> & {
|
|
7
|
+
config: Omit<NonNullable<GroupModel["config"]>, "fields"> & {
|
|
8
|
+
fields?: Record<string, GroupWidgetDiff | NestableWidgetDiff>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type GroupWidgetDiff = Diff<GroupWidgetWithFieldsDiff, GroupWidgetWithFieldsDiff>;
|
|
12
|
+
type SlicePrimaryWidgetDiff = NestableWidgetDiff | GroupWidgetDiff;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GroupWidgetDiff, GroupWidgetWithFieldsDiff, NestableWidgetDiff, SlicePrimaryWidgetDiff };
|
|
15
|
+
//# sourceMappingURL=widgets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgets.d.ts","names":[],"sources":["../../../src/model/diff/widgets.ts"],"mappings":";;;;KAIY,qBAAqB,KAAK,eAAe;KAEzC,4BAA4B,KAAK;EAC5C,QAAQ,KAAK,YAAY;IACxB,SAAS,eAAe,kBAAkB;;;KAIhC,kBAAkB,KAAK,2BAA2B;KAElD,yBAAyB,qBAAqB"}
|
package/dist/model/nestable.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ImageModelSchema } from "./image.js";
|
|
2
|
-
import { RichTextModelSchema } from "./richText.js";
|
|
3
|
-
import { TableModelSchema } from "./table.js";
|
|
4
1
|
import { BooleanModelSchema } from "./boolean.js";
|
|
5
2
|
import { ColorModelSchema } from "./color.js";
|
|
6
3
|
import { DateModelSchema } from "./date.js";
|
|
7
4
|
import { EmbedModelSchema } from "./embed.js";
|
|
8
5
|
import { GeoPointModelSchema } from "./geopoint.js";
|
|
6
|
+
import { ImageModelSchema } from "./image.js";
|
|
9
7
|
import { IntegrationFieldModelSchema } from "./integrationField.js";
|
|
10
8
|
import { LinkModelSchema } from "./link.js";
|
|
11
9
|
import { NumberModelSchema } from "./number.js";
|
|
12
10
|
import { RangeModelSchema } from "./range.js";
|
|
11
|
+
import { RichTextModelSchema } from "./richText.js";
|
|
13
12
|
import { SelectModelSchema } from "./select.js";
|
|
14
13
|
import { SeparatorModelSchema } from "./separator.js";
|
|
14
|
+
import { TableModelSchema } from "./table.js";
|
|
15
15
|
import { TextModelSchema } from "./text.js";
|
|
16
16
|
import { TimestampModelSchema } from "./timestamp.js";
|
|
17
17
|
import { z } from "zod/mini";
|
package/dist/zod4.js
CHANGED
|
@@ -3,10 +3,25 @@ import { ImageContentSchema as ImageContentSchema$1, ImageContentViewSchema as I
|
|
|
3
3
|
import { NonEmptyStringSchema as NonEmptyStringSchema$1 } from "./common/nonEmptyString.js";
|
|
4
4
|
import { EmptyLinkContentSchema as EmptyLinkContentSchema$1, FilledLinkContentSchema as FilledLinkContentSchema$1, LinkContentSchema as LinkContentSchema$1 } from "./content/link.js";
|
|
5
5
|
import { RichTextContentBlockSchema as RichTextContentBlockSchema$1, RichTextContentSchema as RichTextContentSchema$1, RichTextContentSpanSchema as RichTextContentSpanSchema$1 } from "./content/richText.js";
|
|
6
|
+
import { WidgetKeySchema as WidgetKeySchema$1 } from "./common/widgetKey.js";
|
|
7
|
+
import { BooleanModelSchema as BooleanModelSchema$1 } from "./model/boolean.js";
|
|
8
|
+
import { ColorModelSchema as ColorModelSchema$1 } from "./model/color.js";
|
|
9
|
+
import { DateModelSchema as DateModelSchema$1 } from "./model/date.js";
|
|
10
|
+
import { EmbedModelSchema as EmbedModelSchema$1 } from "./model/embed.js";
|
|
11
|
+
import { GeoPointModelSchema as GeoPointModelSchema$1 } from "./model/geopoint.js";
|
|
6
12
|
import { ImageModelSchema as ImageModelSchema$1 } from "./model/image.js";
|
|
13
|
+
import { IntegrationFieldModelSchema as IntegrationFieldModelSchema$1 } from "./model/integrationField.js";
|
|
14
|
+
import { LinkModelSchema as LinkModelSchema$1 } from "./model/link.js";
|
|
15
|
+
import { NumberModelSchema as NumberModelSchema$1 } from "./model/number.js";
|
|
16
|
+
import { RangeModelSchema as RangeModelSchema$1 } from "./model/range.js";
|
|
7
17
|
import { RichTextModelSchema as RichTextModelSchema$1 } from "./model/richText.js";
|
|
18
|
+
import { SelectModelSchema as SelectModelSchema$1 } from "./model/select.js";
|
|
19
|
+
import { SeparatorModelSchema as SeparatorModelSchema$1 } from "./model/separator.js";
|
|
8
20
|
import { TableModelSchema as TableModelSchema$1 } from "./model/table.js";
|
|
9
|
-
import {
|
|
21
|
+
import { TextModelSchema as TextModelSchema$1 } from "./model/text.js";
|
|
22
|
+
import { TimestampModelSchema as TimestampModelSchema$1 } from "./model/timestamp.js";
|
|
23
|
+
import { NestableModelSchema as NestableModelSchema$1 } from "./model/nestable.js";
|
|
24
|
+
import { GroupModelSchema as GroupModelSchema$1, NestedGroupModelSchema as NestedGroupModelSchema$1 } from "./model/group.js";
|
|
10
25
|
import { BooleanContentSchema as BooleanContentSchema$1 } from "./content/boolean.js";
|
|
11
26
|
import { EmptyContentSchema as EmptyContentSchema$1 } from "./content/empty.js";
|
|
12
27
|
import { ColorContentSchema as ColorContentSchema$1, DateContentSchema as DateContentSchema$1, FieldContentSchema as FieldContentSchema$1, NumberContentSchema as NumberContentSchema$1, RangeContentSchema as RangeContentSchema$1, SelectContentSchema as SelectContentSchema$1, TextContentSchema as TextContentSchema$1, TimestampContentSchema as TimestampContentSchema$1 } from "./content/field.js";
|
|
@@ -22,21 +37,6 @@ import { CompositeSliceItemContentSchema as CompositeSliceItemContentSchema$1, L
|
|
|
22
37
|
import { UIDContentSchema as UIDContentSchema$1 } from "./content/uid.js";
|
|
23
38
|
import { WidgetContentSchema as WidgetContentSchema$1 } from "./content/widget.js";
|
|
24
39
|
import { DocumentContentSchema as DocumentContentSchema$1 } from "./content/document.js";
|
|
25
|
-
import { BooleanModelSchema as BooleanModelSchema$1 } from "./model/boolean.js";
|
|
26
|
-
import { ColorModelSchema as ColorModelSchema$1 } from "./model/color.js";
|
|
27
|
-
import { DateModelSchema as DateModelSchema$1 } from "./model/date.js";
|
|
28
|
-
import { EmbedModelSchema as EmbedModelSchema$1 } from "./model/embed.js";
|
|
29
|
-
import { GeoPointModelSchema as GeoPointModelSchema$1 } from "./model/geopoint.js";
|
|
30
|
-
import { IntegrationFieldModelSchema as IntegrationFieldModelSchema$1 } from "./model/integrationField.js";
|
|
31
|
-
import { LinkModelSchema as LinkModelSchema$1 } from "./model/link.js";
|
|
32
|
-
import { NumberModelSchema as NumberModelSchema$1 } from "./model/number.js";
|
|
33
|
-
import { RangeModelSchema as RangeModelSchema$1 } from "./model/range.js";
|
|
34
|
-
import { SelectModelSchema as SelectModelSchema$1 } from "./model/select.js";
|
|
35
|
-
import { SeparatorModelSchema as SeparatorModelSchema$1 } from "./model/separator.js";
|
|
36
|
-
import { TextModelSchema as TextModelSchema$1 } from "./model/text.js";
|
|
37
|
-
import { TimestampModelSchema as TimestampModelSchema$1 } from "./model/timestamp.js";
|
|
38
|
-
import { NestableModelSchema as NestableModelSchema$1 } from "./model/nestable.js";
|
|
39
|
-
import { GroupModelSchema as GroupModelSchema$1, NestedGroupModelSchema as NestedGroupModelSchema$1 } from "./model/group.js";
|
|
40
40
|
import { CompositeSliceModelSchema as CompositeSliceModelSchema$1, DynamicSliceModelSchema as DynamicSliceModelSchema$1, LegacySliceModelSchema as LegacySliceModelSchema$1, SharedSliceModelSchema as SharedSliceModelSchema$1, SharedSliceModelVariationSchema as SharedSliceModelVariationSchema$1, SharedSliceRefModelSchema as SharedSliceRefModelSchema$1, SliceContentModelSchema as SliceContentModelSchema$1, StaticSliceModelSchema as StaticSliceModelSchema$1 } from "./model/slice.js";
|
|
41
41
|
import { DynamicSlicesModelSchema as DynamicSlicesModelSchema$1, StaticSlicesModelSchema as StaticSlicesModelSchema$1 } from "./model/slices.js";
|
|
42
42
|
import { UIDModelSchema as UIDModelSchema$1 } from "./model/uid.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/types-internal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0-pr.28.255f9f9",
|
|
4
4
|
"description": "TypeScript types and runtime parsers for Prismic data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
|
-
"node": ">=
|
|
81
|
+
"node": ">=22"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/index.ts
CHANGED
|
@@ -66,6 +66,18 @@ export type {
|
|
|
66
66
|
DynamicCustomTypeModelTab,
|
|
67
67
|
} from "./model/customType"
|
|
68
68
|
export type { DateModel } from "./model/date"
|
|
69
|
+
export type { AddedDiff, RemovedDiff, UpdatedDiff, Diff } from "./model/diff/changes"
|
|
70
|
+
export { DiffOperation } from "./model/diff/changes"
|
|
71
|
+
export type { SliceDiffMetadata, SliceDiff } from "./model/diff/sharedSlice"
|
|
72
|
+
export { SliceDiffComparator } from "./model/diff/sharedSlice"
|
|
73
|
+
export type { VariationDiffMetadata, VariationDiff } from "./model/diff/variation"
|
|
74
|
+
export { VariationDiffComparator } from "./model/diff/variation"
|
|
75
|
+
export type {
|
|
76
|
+
NestableWidgetDiff,
|
|
77
|
+
GroupWidgetWithFieldsDiff,
|
|
78
|
+
GroupWidgetDiff,
|
|
79
|
+
SlicePrimaryWidgetDiff,
|
|
80
|
+
} from "./model/diff/widgets"
|
|
69
81
|
export type { EmbedModel } from "./model/embed"
|
|
70
82
|
export type { GeoPointModel } from "./model/geopoint"
|
|
71
83
|
export type { GroupModel, NestedGroupModel } from "./model/group"
|
|
@@ -4,18 +4,18 @@ export enum DiffOperation {
|
|
|
4
4
|
Updated = "updated",
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type AddedDiff<A> = {
|
|
8
8
|
op: DiffOperation.Added
|
|
9
9
|
value: A
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type RemovedDiff = {
|
|
13
13
|
op: DiffOperation.Removed
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type UpdatedDiff<A> = {
|
|
17
17
|
op: DiffOperation.Updated
|
|
18
18
|
value: A
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export type
|
|
21
|
+
export type Diff<A, U> = AddedDiff<A> | UpdatedDiff<U> | RemovedDiff
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SharedSliceModel, SharedSliceModelVariation } from "../slice"
|
|
2
|
-
import { type
|
|
2
|
+
import { type Diff, DiffOperation } from "./changes"
|
|
3
3
|
import { isNotEmpty, toRecord, zipObjects } from "./utils"
|
|
4
|
-
import { type VariationDiff,
|
|
4
|
+
import { type VariationDiff, VariationDiffComparator } from "./variation"
|
|
5
5
|
|
|
6
|
-
export type
|
|
7
|
-
export type SliceDiff =
|
|
6
|
+
export type SliceDiffMetadata = Omit<SharedSliceModel, "variations">
|
|
7
|
+
export type SliceDiff = Diff<
|
|
8
8
|
SharedSliceModel,
|
|
9
9
|
Partial<
|
|
10
|
-
|
|
10
|
+
SliceDiffMetadata & {
|
|
11
11
|
variations?: Partial<Record<string, VariationDiff>>
|
|
12
12
|
}
|
|
13
13
|
>
|
|
@@ -16,7 +16,7 @@ export type SliceDiff = DiffChange<
|
|
|
16
16
|
function compareSliceMeta(
|
|
17
17
|
sliceA?: SharedSliceModel,
|
|
18
18
|
sliceB?: SharedSliceModel,
|
|
19
|
-
): Partial<
|
|
19
|
+
): Partial<SliceDiffMetadata> {
|
|
20
20
|
const zippedSlices = zipObjects(sliceA, sliceB)
|
|
21
21
|
|
|
22
22
|
return Object.entries(zippedSlices).reduce((acc, [key, value]) => {
|
|
@@ -27,7 +27,7 @@ function compareSliceMeta(
|
|
|
27
27
|
}, {})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const
|
|
30
|
+
export const SliceDiffComparator = {
|
|
31
31
|
compare(sliceA?: SharedSliceModel, sliceB?: SharedSliceModel): SliceDiff | undefined {
|
|
32
32
|
if (!sliceA && sliceB)
|
|
33
33
|
return {
|
|
@@ -51,7 +51,7 @@ export const SliceComparator = {
|
|
|
51
51
|
>((acc, [variationId, value]) => {
|
|
52
52
|
if (!value) return acc
|
|
53
53
|
|
|
54
|
-
const vDiff =
|
|
54
|
+
const vDiff = VariationDiffComparator.compare(value.left, value.right)
|
|
55
55
|
if (!vDiff) return acc
|
|
56
56
|
return {
|
|
57
57
|
...acc,
|
|
@@ -2,7 +2,7 @@ import type { GroupModel } from "../group"
|
|
|
2
2
|
import { GroupFieldType } from "../group"
|
|
3
3
|
import type { NestableModel } from "../nestable"
|
|
4
4
|
import type { SharedSliceModelVariation } from "../slice"
|
|
5
|
-
import { type
|
|
5
|
+
import { type Diff, DiffOperation } from "./changes"
|
|
6
6
|
import { isNotEmpty, zipObjects } from "./utils"
|
|
7
7
|
import type {
|
|
8
8
|
GroupWidgetWithFieldsDiff,
|
|
@@ -10,10 +10,10 @@ import type {
|
|
|
10
10
|
SlicePrimaryWidgetDiff,
|
|
11
11
|
} from "./widgets"
|
|
12
12
|
|
|
13
|
-
export type
|
|
14
|
-
export type VariationDiff =
|
|
13
|
+
export type VariationDiffMetadata = Omit<SharedSliceModelVariation, "primary" | "items">
|
|
14
|
+
export type VariationDiff = Diff<
|
|
15
15
|
SharedSliceModelVariation,
|
|
16
|
-
Partial<
|
|
16
|
+
Partial<VariationDiffMetadata> & {
|
|
17
17
|
primary?: Record<string, SlicePrimaryWidgetDiff>
|
|
18
18
|
items?: Record<string, NestableWidgetDiff>
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ export type VariationDiff = DiffChange<
|
|
|
22
22
|
function compareVariationMeta(
|
|
23
23
|
variationA?: SharedSliceModelVariation,
|
|
24
24
|
variationB?: SharedSliceModelVariation,
|
|
25
|
-
): Partial<
|
|
25
|
+
): Partial<VariationDiffMetadata> {
|
|
26
26
|
const zippedVariations = zipObjects(variationA, variationB)
|
|
27
27
|
|
|
28
28
|
return Object.entries(zippedVariations).reduce((acc, [key, value]) => {
|
|
@@ -117,7 +117,7 @@ function compareWidgets<TWidget extends NestableModel | GroupModel>(
|
|
|
117
117
|
return isNotEmpty(diffWidgets) ? diffWidgets : undefined
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export const
|
|
120
|
+
export const VariationDiffComparator = {
|
|
121
121
|
compare(
|
|
122
122
|
variationA?: SharedSliceModelVariation,
|
|
123
123
|
variationB?: SharedSliceModelVariation,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { GroupModel } from "../group"
|
|
2
2
|
import type { NestableModel } from "../nestable"
|
|
3
|
-
import type {
|
|
3
|
+
import type { Diff } from "./changes"
|
|
4
4
|
|
|
5
|
-
export type NestableWidgetDiff =
|
|
5
|
+
export type NestableWidgetDiff = Diff<NestableModel, NestableModel>
|
|
6
6
|
|
|
7
7
|
export type GroupWidgetWithFieldsDiff = Omit<GroupModel, "config"> & {
|
|
8
8
|
config: Omit<NonNullable<GroupModel["config"]>, "fields"> & {
|
|
@@ -10,6 +10,6 @@ export type GroupWidgetWithFieldsDiff = Omit<GroupModel, "config"> & {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export type GroupWidgetDiff =
|
|
13
|
+
export type GroupWidgetDiff = Diff<GroupWidgetWithFieldsDiff, GroupWidgetWithFieldsDiff>
|
|
14
14
|
|
|
15
15
|
export type SlicePrimaryWidgetDiff = NestableWidgetDiff | GroupWidgetDiff
|