@jumoo/usync 17.5.1 → 17.5.2-prerelease.15

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 (39) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +1 -1
  3. package/dist/api/sdk.gen.d.ts +2 -1
  4. package/dist/api/sdk.gen.js +7 -0
  5. package/dist/api/types.gen.d.ts +361 -0
  6. package/dist/api/types.gen.js +13 -0
  7. package/dist/components/index.d.ts +3 -0
  8. package/dist/components/index.js +3 -0
  9. package/dist/components/usync-content-preview.d.ts +27 -0
  10. package/dist/components/usync-content-preview.js +540 -0
  11. package/dist/components/usync-content-type-preview.d.ts +25 -0
  12. package/dist/components/usync-content-type-preview.js +548 -0
  13. package/dist/components/usync-data-type-preview.d.ts +21 -0
  14. package/dist/components/usync-data-type-preview.js +293 -0
  15. package/dist/components/usync-results-view.js +13 -5
  16. package/dist/dialogs/details-modal-element.d.ts +12 -1
  17. package/dist/dialogs/details-modal-element.js +139 -9
  18. package/dist/dialogs/details-modal-token.d.ts +10 -1
  19. package/dist/lang/files/da-dk.d.ts +37 -0
  20. package/dist/lang/files/da-dk.js +37 -0
  21. package/dist/lang/files/de-de.d.ts +37 -0
  22. package/dist/lang/files/de-de.js +37 -0
  23. package/dist/lang/files/en-us.d.ts +37 -0
  24. package/dist/lang/files/en-us.js +37 -0
  25. package/dist/lang/files/es-es.d.ts +37 -0
  26. package/dist/lang/files/es-es.js +37 -0
  27. package/dist/lang/files/fr-fr.d.ts +37 -0
  28. package/dist/lang/files/fr-fr.js +37 -0
  29. package/dist/lang/files/nl-nl.d.ts +37 -0
  30. package/dist/lang/files/nl-nl.js +37 -0
  31. package/dist/repository/SyncAction.respositoy.d.ts +8 -0
  32. package/dist/repository/SyncAction.respositoy.js +6 -0
  33. package/dist/repository/sources/SyncAction.source.d.ts +5 -0
  34. package/dist/repository/sources/SyncAction.source.js +5 -0
  35. package/dist/utils/preview/content-type-diff.d.ts +18 -0
  36. package/dist/utils/preview/content-type-diff.js +72 -0
  37. package/dist/utils/preview/content-type-layout.d.ts +39 -0
  38. package/dist/utils/preview/content-type-layout.js +100 -0
  39. package/package.json +1 -1
@@ -0,0 +1,100 @@
1
+ /** name used for the tab that holds groups which aren't inside a tab */
2
+ export const USYNC_GENERIC_TAB = '';
3
+ /** the ids of the types this one is composed of (or inherits from). */
4
+ export function compositionIds(type) {
5
+ return type.compositions.map((composition) => {
6
+ if ('documentType' in composition)
7
+ return composition.documentType.id;
8
+ if ('mediaType' in composition)
9
+ return composition.mediaType.id;
10
+ return composition.memberType.id;
11
+ });
12
+ }
13
+ /**
14
+ * build the tabs and groups an editor would see, merging in the containers
15
+ * and properties from compositions the way the backoffice does (by name).
16
+ */
17
+ export function buildContentTypeLayout(type, compositions) {
18
+ const tabs = new Map();
19
+ const tabFor = (name, id, sortOrder, inherited) => {
20
+ let tab = tabs.get(name);
21
+ if (!tab) {
22
+ tab = { name, ids: [], inherited, sortOrder, properties: [], groups: [] };
23
+ tabs.set(name, tab);
24
+ }
25
+ if (id)
26
+ tab.ids.push(id);
27
+ tab.inherited && (tab.inherited = inherited);
28
+ return tab;
29
+ };
30
+ const groupFor = (tab, name, id, sortOrder, inherited) => {
31
+ let group = tab.groups.find((g) => g.name === name);
32
+ if (!group) {
33
+ group = { name, ids: [], inherited, sortOrder, properties: [] };
34
+ tab.groups.push(group);
35
+ }
36
+ group.ids.push(id);
37
+ group.inherited && (group.inherited = inherited);
38
+ return group;
39
+ };
40
+ for (const source of contributors(type, compositions)) {
41
+ const inherited = source !== type;
42
+ const containers = new Map(source.containers.map((c) => [c.id, c]));
43
+ // where each container (and so each property) lands in the merged layout.
44
+ const placed = new Map();
45
+ for (const container of [...source.containers].sort(bySortOrder)) {
46
+ if (container.type === 'Tab') {
47
+ placed.set(container.id, tabFor(container.name ?? '', container.id, container.sortOrder, inherited));
48
+ }
49
+ }
50
+ for (const container of [...source.containers].sort(bySortOrder)) {
51
+ if (container.type !== 'Group')
52
+ continue;
53
+ const parent = container.parent ? containers.get(container.parent.id) : undefined;
54
+ const tab = parent
55
+ ? tabFor(parent.name ?? '', undefined, parent.sortOrder, inherited)
56
+ : tabFor(USYNC_GENERIC_TAB, undefined, -1, inherited);
57
+ placed.set(container.id, groupFor(tab, container.name ?? '', container.id, container.sortOrder, inherited));
58
+ }
59
+ for (const property of [...source.properties].sort(bySortOrder)) {
60
+ const target = property.container ? placed.get(property.container.id) : undefined;
61
+ const entry = { property, inheritedFrom: inherited ? source.name : undefined };
62
+ if (target) {
63
+ target.properties.push(entry);
64
+ }
65
+ else {
66
+ tabFor(USYNC_GENERIC_TAB, undefined, -1, inherited).properties.push(entry);
67
+ }
68
+ }
69
+ }
70
+ const result = [...tabs.values()].sort(bySortOrder);
71
+ for (const tab of result) {
72
+ tab.groups.sort(bySortOrder);
73
+ tab.properties.sort((a, b) => a.property.sortOrder - b.property.sortOrder);
74
+ for (const group of tab.groups) {
75
+ group.properties.sort((a, b) => a.property.sortOrder - b.property.sortOrder);
76
+ }
77
+ }
78
+ return result.filter((tab) => tab.properties.length > 0 || tab.groups.length > 0);
79
+ }
80
+ /** the type itself first, then everything it is composed of (depth first, no repeats). */
81
+ function contributors(type, compositions) {
82
+ const seen = new Set();
83
+ const out = [];
84
+ const visit = (current) => {
85
+ if (seen.has(current.id))
86
+ return;
87
+ seen.add(current.id);
88
+ out.push(current);
89
+ for (const id of compositionIds(current)) {
90
+ const composition = compositions.get(id);
91
+ if (composition)
92
+ visit(composition);
93
+ }
94
+ };
95
+ visit(type);
96
+ return out;
97
+ }
98
+ function bySortOrder(a, b) {
99
+ return a.sortOrder - b.sortOrder;
100
+ }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://jumoo.co.uk/uSync",
9
9
  "license": "MPL-2.0",
10
10
  "type": "module",
11
- "version": "17.5.1",
11
+ "version": "17.5.2-prerelease.15",
12
12
  "main": "./dist/usync.js",
13
13
  "types": "./dist/index.d.ts",
14
14
  "module": "./dist/usync.js",