@slicemachine/manager 0.24.16-beta.1 → 0.24.16-beta.11
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/managers/customTypes/CustomTypesManager.cjs +114 -39
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.d.ts +202 -75
- package/dist/managers/customTypes/CustomTypesManager.js +114 -39
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/dist/managers/telemetry/types.cjs +0 -2
- package/dist/managers/telemetry/types.cjs.map +1 -1
- package/dist/managers/telemetry/types.d.ts +1 -8
- package/dist/managers/telemetry/types.js +0 -2
- package/dist/managers/telemetry/types.js.map +1 -1
- package/package.json +4 -4
- package/src/managers/customTypes/CustomTypesManager.ts +254 -71
- package/src/managers/telemetry/types.ts +0 -12
@@ -37,6 +37,27 @@ type SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {
|
|
37
37
|
customTypeID: string;
|
38
38
|
mocksConfig: Record<string, unknown>;
|
39
39
|
};
|
40
|
+
/** `[field]` or `[group, field]` – path **inside** the Custom Type */
|
41
|
+
type PathWithoutCustomType = [string] | [string, string];
|
42
|
+
type SliceMachineManagerUpdateCustomTypeFieldIdChanged = {
|
43
|
+
/**
|
44
|
+
* Previous path of the changed field, excluding the custom type id. Can be
|
45
|
+
* used to identify the field that had an API ID rename (e.g. ["fieldA"] or
|
46
|
+
* ["groupA", "fieldA"])
|
47
|
+
*/
|
48
|
+
previousPath: PathWithoutCustomType;
|
49
|
+
/**
|
50
|
+
* New path of the changed field, excluding the custom type id. Can be used to
|
51
|
+
* identify the field that had an API ID rename (e.g. ["fieldB"] or ["groupA",
|
52
|
+
* "fieldB"])
|
53
|
+
*/
|
54
|
+
newPath: PathWithoutCustomType;
|
55
|
+
};
|
56
|
+
type SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {
|
57
|
+
updateMeta?: {
|
58
|
+
fieldIdChanged?: SliceMachineManagerUpdateCustomTypeFieldIdChanged;
|
59
|
+
};
|
60
|
+
};
|
40
61
|
type SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {
|
41
62
|
errors: HookError[];
|
42
63
|
};
|
@@ -49,9 +70,11 @@ type CustomTypesMachineManagerDeleteCustomTypeReturnType = {
|
|
49
70
|
type CustomTypesMachineManagerUpdateCustomTypeReturnType = {
|
50
71
|
errors: (DecodeError | HookError)[];
|
51
72
|
};
|
73
|
+
/** `[ct, field]` or `[ct, group, field]` – path **with** Custom Type ID */
|
74
|
+
type PathWithCustomType = [string, string] | [string, string, string];
|
52
75
|
type CustomTypeFieldIdChangedMeta = {
|
53
|
-
previousPath:
|
54
|
-
newPath:
|
76
|
+
previousPath: PathWithCustomType;
|
77
|
+
newPath: PathWithCustomType;
|
55
78
|
};
|
56
79
|
export declare class CustomTypesManager extends BaseManager {
|
57
80
|
readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType>;
|
@@ -64,7 +87,7 @@ export declare class CustomTypesManager extends BaseManager {
|
|
64
87
|
* property.
|
65
88
|
*/
|
66
89
|
private updateContentRelationships;
|
67
|
-
updateCustomType(args:
|
90
|
+
updateCustomType(args: SliceMachineManagerUpdateCustomTypeArgs): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType>;
|
68
91
|
renameCustomType(args: CustomTypeRenameHookData): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>>;
|
69
92
|
deleteCustomType(args: CustomTypesMachineManagerDeleteCustomTypeArgs): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType>;
|
70
93
|
pushCustomType(args: SliceMachineManagerPushCustomTypeArgs): Promise<void>;
|
@@ -221,18 +244,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
221
244
|
useAsTitle?: boolean | undefined;
|
222
245
|
placeholder?: string | undefined;
|
223
246
|
select?: "media" | "document" | "web" | null | undefined;
|
224
|
-
customtypes?: readonly (string |
|
247
|
+
customtypes?: readonly (string | {
|
225
248
|
id: string;
|
226
|
-
|
227
|
-
fields?: readonly (string | {
|
249
|
+
fields: readonly (string | {
|
228
250
|
id: string;
|
229
|
-
customtypes: readonly (string |
|
251
|
+
customtypes: readonly (string | {
|
230
252
|
id: string;
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
253
|
+
fields: readonly (string | {
|
254
|
+
id: string;
|
255
|
+
fields: readonly string[];
|
256
|
+
})[];
|
257
|
+
})[];
|
258
|
+
} | {
|
259
|
+
id: string;
|
260
|
+
fields: readonly (string | {
|
261
|
+
id: string;
|
262
|
+
customtypes: readonly (string | {
|
263
|
+
id: string;
|
264
|
+
fields: readonly (string | {
|
265
|
+
id: string;
|
266
|
+
fields: readonly string[];
|
267
|
+
})[];
|
268
|
+
})[];
|
269
|
+
})[];
|
270
|
+
})[];
|
271
|
+
})[] | undefined;
|
236
272
|
masks?: readonly string[] | undefined;
|
237
273
|
tags?: readonly string[] | undefined;
|
238
274
|
allowTargetBlank?: boolean | undefined;
|
@@ -407,18 +443,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
407
443
|
useAsTitle?: boolean | undefined;
|
408
444
|
placeholder?: string | undefined;
|
409
445
|
select?: "media" | "document" | "web" | null | undefined;
|
410
|
-
customtypes?: readonly (string |
|
446
|
+
customtypes?: readonly (string | {
|
411
447
|
id: string;
|
412
|
-
|
413
|
-
fields?: readonly (string | {
|
448
|
+
fields: readonly (string | {
|
414
449
|
id: string;
|
415
|
-
customtypes: readonly (string |
|
450
|
+
customtypes: readonly (string | {
|
416
451
|
id: string;
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
452
|
+
fields: readonly (string | {
|
453
|
+
id: string;
|
454
|
+
fields: readonly string[];
|
455
|
+
})[];
|
456
|
+
})[];
|
457
|
+
} | {
|
458
|
+
id: string;
|
459
|
+
fields: readonly (string | {
|
460
|
+
id: string;
|
461
|
+
customtypes: readonly (string | {
|
462
|
+
id: string;
|
463
|
+
fields: readonly (string | {
|
464
|
+
id: string;
|
465
|
+
fields: readonly string[];
|
466
|
+
})[];
|
467
|
+
})[];
|
468
|
+
})[];
|
469
|
+
})[];
|
470
|
+
})[] | undefined;
|
422
471
|
masks?: readonly string[] | undefined;
|
423
472
|
tags?: readonly string[] | undefined;
|
424
473
|
allowTargetBlank?: boolean | undefined;
|
@@ -593,18 +642,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
593
642
|
useAsTitle?: boolean | undefined;
|
594
643
|
placeholder?: string | undefined;
|
595
644
|
select?: "media" | "document" | "web" | null | undefined;
|
596
|
-
customtypes?: readonly (string |
|
645
|
+
customtypes?: readonly (string | {
|
597
646
|
id: string;
|
598
|
-
|
599
|
-
fields?: readonly (string | {
|
647
|
+
fields: readonly (string | {
|
600
648
|
id: string;
|
601
|
-
customtypes: readonly (string |
|
649
|
+
customtypes: readonly (string | {
|
602
650
|
id: string;
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
651
|
+
fields: readonly (string | {
|
652
|
+
id: string;
|
653
|
+
fields: readonly string[];
|
654
|
+
})[];
|
655
|
+
})[];
|
656
|
+
} | {
|
657
|
+
id: string;
|
658
|
+
fields: readonly (string | {
|
659
|
+
id: string;
|
660
|
+
customtypes: readonly (string | {
|
661
|
+
id: string;
|
662
|
+
fields: readonly (string | {
|
663
|
+
id: string;
|
664
|
+
fields: readonly string[];
|
665
|
+
})[];
|
666
|
+
})[];
|
667
|
+
})[];
|
668
|
+
})[];
|
669
|
+
})[] | undefined;
|
608
670
|
masks?: readonly string[] | undefined;
|
609
671
|
tags?: readonly string[] | undefined;
|
610
672
|
allowTargetBlank?: boolean | undefined;
|
@@ -778,18 +840,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
778
840
|
useAsTitle?: boolean | undefined;
|
779
841
|
placeholder?: string | undefined;
|
780
842
|
select?: "media" | "document" | "web" | null | undefined;
|
781
|
-
customtypes?: readonly (string |
|
843
|
+
customtypes?: readonly (string | {
|
782
844
|
id: string;
|
783
|
-
|
784
|
-
|
845
|
+
fields: readonly (string | {
|
846
|
+
id: string;
|
847
|
+
customtypes: readonly (string | {
|
848
|
+
id: string;
|
849
|
+
fields: readonly (string | {
|
850
|
+
id: string;
|
851
|
+
fields: readonly string[];
|
852
|
+
})[];
|
853
|
+
})[];
|
854
|
+
} | {
|
785
855
|
id: string;
|
786
|
-
|
856
|
+
fields: readonly (string | {
|
787
857
|
id: string;
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
858
|
+
customtypes: readonly (string | {
|
859
|
+
id: string;
|
860
|
+
fields: readonly (string | {
|
861
|
+
id: string;
|
862
|
+
fields: readonly string[];
|
863
|
+
})[];
|
864
|
+
})[];
|
865
|
+
})[];
|
866
|
+
})[];
|
867
|
+
})[] | undefined;
|
793
868
|
masks?: readonly string[] | undefined;
|
794
869
|
tags?: readonly string[] | undefined;
|
795
870
|
allowTargetBlank?: boolean | undefined;
|
@@ -979,18 +1054,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
979
1054
|
useAsTitle?: boolean | undefined;
|
980
1055
|
placeholder?: string | undefined;
|
981
1056
|
select?: "media" | "document" | "web" | null | undefined;
|
982
|
-
customtypes?: readonly (string |
|
1057
|
+
customtypes?: readonly (string | {
|
983
1058
|
id: string;
|
984
|
-
|
985
|
-
|
1059
|
+
fields: readonly (string | {
|
1060
|
+
id: string;
|
1061
|
+
customtypes: readonly (string | {
|
1062
|
+
id: string;
|
1063
|
+
fields: readonly (string | {
|
1064
|
+
id: string;
|
1065
|
+
fields: readonly string[];
|
1066
|
+
})[];
|
1067
|
+
})[];
|
1068
|
+
} | {
|
986
1069
|
id: string;
|
987
|
-
|
1070
|
+
fields: readonly (string | {
|
988
1071
|
id: string;
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
1072
|
+
customtypes: readonly (string | {
|
1073
|
+
id: string;
|
1074
|
+
fields: readonly (string | {
|
1075
|
+
id: string;
|
1076
|
+
fields: readonly string[];
|
1077
|
+
})[];
|
1078
|
+
})[];
|
1079
|
+
})[];
|
1080
|
+
})[];
|
1081
|
+
})[] | undefined;
|
994
1082
|
masks?: readonly string[] | undefined;
|
995
1083
|
tags?: readonly string[] | undefined;
|
996
1084
|
allowTargetBlank?: boolean | undefined;
|
@@ -1165,18 +1253,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1165
1253
|
useAsTitle?: boolean | undefined;
|
1166
1254
|
placeholder?: string | undefined;
|
1167
1255
|
select?: "media" | "document" | "web" | null | undefined;
|
1168
|
-
customtypes?: readonly (string |
|
1256
|
+
customtypes?: readonly (string | {
|
1169
1257
|
id: string;
|
1170
|
-
|
1171
|
-
|
1258
|
+
fields: readonly (string | {
|
1259
|
+
id: string;
|
1260
|
+
customtypes: readonly (string | {
|
1261
|
+
id: string;
|
1262
|
+
fields: readonly (string | {
|
1263
|
+
id: string;
|
1264
|
+
fields: readonly string[];
|
1265
|
+
})[];
|
1266
|
+
})[];
|
1267
|
+
} | {
|
1172
1268
|
id: string;
|
1173
|
-
|
1269
|
+
fields: readonly (string | {
|
1174
1270
|
id: string;
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1271
|
+
customtypes: readonly (string | {
|
1272
|
+
id: string;
|
1273
|
+
fields: readonly (string | {
|
1274
|
+
id: string;
|
1275
|
+
fields: readonly string[];
|
1276
|
+
})[];
|
1277
|
+
})[];
|
1278
|
+
})[];
|
1279
|
+
})[];
|
1280
|
+
})[] | undefined;
|
1180
1281
|
masks?: readonly string[] | undefined;
|
1181
1282
|
tags?: readonly string[] | undefined;
|
1182
1283
|
allowTargetBlank?: boolean | undefined;
|
@@ -1351,18 +1452,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1351
1452
|
useAsTitle?: boolean | undefined;
|
1352
1453
|
placeholder?: string | undefined;
|
1353
1454
|
select?: "media" | "document" | "web" | null | undefined;
|
1354
|
-
customtypes?: readonly (string |
|
1455
|
+
customtypes?: readonly (string | {
|
1355
1456
|
id: string;
|
1356
|
-
|
1357
|
-
fields?: readonly (string | {
|
1457
|
+
fields: readonly (string | {
|
1358
1458
|
id: string;
|
1359
|
-
customtypes: readonly (string |
|
1459
|
+
customtypes: readonly (string | {
|
1360
1460
|
id: string;
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1461
|
+
fields: readonly (string | {
|
1462
|
+
id: string;
|
1463
|
+
fields: readonly string[];
|
1464
|
+
})[];
|
1465
|
+
})[];
|
1466
|
+
} | {
|
1467
|
+
id: string;
|
1468
|
+
fields: readonly (string | {
|
1469
|
+
id: string;
|
1470
|
+
customtypes: readonly (string | {
|
1471
|
+
id: string;
|
1472
|
+
fields: readonly (string | {
|
1473
|
+
id: string;
|
1474
|
+
fields: readonly string[];
|
1475
|
+
})[];
|
1476
|
+
})[];
|
1477
|
+
})[];
|
1478
|
+
})[];
|
1479
|
+
})[] | undefined;
|
1366
1480
|
masks?: readonly string[] | undefined;
|
1367
1481
|
tags?: readonly string[] | undefined;
|
1368
1482
|
allowTargetBlank?: boolean | undefined;
|
@@ -1536,18 +1650,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1536
1650
|
useAsTitle?: boolean | undefined;
|
1537
1651
|
placeholder?: string | undefined;
|
1538
1652
|
select?: "media" | "document" | "web" | null | undefined;
|
1539
|
-
customtypes?: readonly (string |
|
1653
|
+
customtypes?: readonly (string | {
|
1540
1654
|
id: string;
|
1541
|
-
|
1542
|
-
|
1655
|
+
fields: readonly (string | {
|
1656
|
+
id: string;
|
1657
|
+
customtypes: readonly (string | {
|
1658
|
+
id: string;
|
1659
|
+
fields: readonly (string | {
|
1660
|
+
id: string;
|
1661
|
+
fields: readonly string[];
|
1662
|
+
})[];
|
1663
|
+
})[];
|
1664
|
+
} | {
|
1543
1665
|
id: string;
|
1544
|
-
|
1666
|
+
fields: readonly (string | {
|
1545
1667
|
id: string;
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1668
|
+
customtypes: readonly (string | {
|
1669
|
+
id: string;
|
1670
|
+
fields: readonly (string | {
|
1671
|
+
id: string;
|
1672
|
+
fields: readonly string[];
|
1673
|
+
})[];
|
1674
|
+
})[];
|
1675
|
+
})[];
|
1676
|
+
})[];
|
1677
|
+
})[] | undefined;
|
1551
1678
|
masks?: readonly string[] | undefined;
|
1552
1679
|
tags?: readonly string[] | undefined;
|
1553
1680
|
allowTargetBlank?: boolean | undefined;
|
@@ -67,11 +67,11 @@ class CustomTypesManager extends BaseManager {
|
|
67
67
|
*/
|
68
68
|
async updateContentRelationships(args) {
|
69
69
|
assertPluginsInitialized(this.sliceMachinePluginRunner);
|
70
|
-
const { model } = args;
|
71
|
-
|
72
|
-
|
73
|
-
previousPath = [
|
74
|
-
newPath = [
|
70
|
+
const { model, previousPath: previousFieldPath, newPath: newFieldPath } = args;
|
71
|
+
if (previousFieldPath.join(".") !== newFieldPath.join(".")) {
|
72
|
+
const { id: ctId } = model;
|
73
|
+
const previousPath = [ctId, ...previousFieldPath];
|
74
|
+
const newPath = [ctId, ...newFieldPath];
|
75
75
|
const crUpdates = [];
|
76
76
|
const customTypes = await this.readAllCustomTypes();
|
77
77
|
updateCustomTypeContentRelationships({
|
@@ -309,54 +309,113 @@ const InferSliceResponse = z.object({
|
|
309
309
|
langSmithUrl: z.string().url().optional()
|
310
310
|
});
|
311
311
|
function updateCRCustomType(args) {
|
312
|
-
const
|
313
|
-
const
|
314
|
-
if (!
|
315
|
-
throw new Error(
|
312
|
+
const previousPath = getPathIds(args.previousPath);
|
313
|
+
const newPath = getPathIds(args.newPath);
|
314
|
+
if (!previousPath.customTypeId || !newPath.customTypeId) {
|
315
|
+
throw new Error(`Could not find a customtype id in previousPath (${args.previousPath.join(".")}) and/or newPath (${args.newPath.join(".")}), which should not be possible.`);
|
316
316
|
}
|
317
|
-
if (!
|
318
|
-
throw new Error(
|
317
|
+
if (!previousPath.fieldId || !newPath.fieldId) {
|
318
|
+
throw new Error(`Could not find a field id in previousPath (${args.previousPath.join(".")}) and/or newPath (${args.newPath.join(".")}), which should not be possible.`);
|
319
319
|
}
|
320
320
|
const customType = shallowCloneIfObject(args.customType);
|
321
|
-
if (typeof customType === "string"
|
321
|
+
if (typeof customType === "string") {
|
322
322
|
return customType;
|
323
323
|
}
|
324
|
-
const matchedCustomTypeId = customType.id ===
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
324
|
+
const matchedCustomTypeId = customType.id === previousPath.customTypeId;
|
325
|
+
return {
|
326
|
+
...customType,
|
327
|
+
fields: customType.fields.map((fieldArg) => {
|
328
|
+
const customTypeField = shallowCloneIfObject(fieldArg);
|
329
|
+
if (typeof customTypeField === "string") {
|
330
|
+
if (matchedCustomTypeId && customTypeField === previousPath.fieldId && customTypeField !== newPath.fieldId) {
|
331
|
+
return newPath.fieldId;
|
332
|
+
}
|
333
|
+
return customTypeField;
|
330
334
|
}
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
customTypeField
|
335
|
+
if (matchedCustomTypeId && customTypeField.id === previousPath.fieldId && customTypeField.id !== newPath.fieldId) {
|
336
|
+
customTypeField.id = newPath.fieldId;
|
337
|
+
}
|
338
|
+
if ("fields" in customTypeField) {
|
339
|
+
if (!previousPath.groupId && !newPath.groupId && customTypeField.id === previousPath.fieldId && customTypeField.id !== newPath.fieldId) {
|
340
|
+
return newPath.fieldId;
|
341
|
+
}
|
342
|
+
const matchedGroupId = customTypeField.id === previousPath.groupId;
|
343
|
+
if (previousPath.groupId && newPath.groupId && matchedGroupId && customTypeField.id !== newPath.groupId) {
|
344
|
+
customTypeField.id = newPath.groupId;
|
345
|
+
}
|
346
|
+
return {
|
347
|
+
...customTypeField,
|
348
|
+
fields: customTypeField.fields.map((groupFieldArg) => {
|
349
|
+
const groupField = shallowCloneIfObject(groupFieldArg);
|
350
|
+
if (typeof groupField === "string") {
|
351
|
+
if (matchedGroupId && groupField === previousPath.fieldId && groupField !== newPath.fieldId) {
|
352
|
+
return newPath.fieldId;
|
353
|
+
}
|
354
|
+
return groupField;
|
355
|
+
}
|
356
|
+
return {
|
357
|
+
...groupField,
|
358
|
+
fields: updateContentRelationshipFields({
|
359
|
+
customtypes: groupField.customtypes,
|
360
|
+
previousPath,
|
361
|
+
newPath
|
362
|
+
})
|
363
|
+
};
|
364
|
+
})
|
365
|
+
};
|
366
|
+
}
|
367
|
+
return {
|
368
|
+
...customTypeField,
|
369
|
+
customtypes: updateContentRelationshipFields({
|
370
|
+
customtypes: customTypeField.customtypes,
|
371
|
+
previousPath,
|
372
|
+
newPath
|
373
|
+
})
|
374
|
+
};
|
375
|
+
})
|
376
|
+
};
|
377
|
+
}
|
378
|
+
function updateContentRelationshipFields(args) {
|
379
|
+
const { customtypes, previousPath, newPath } = args;
|
380
|
+
return customtypes.map((nestedCtArg) => {
|
381
|
+
const nestedCt = shallowCloneIfObject(nestedCtArg);
|
382
|
+
if (typeof nestedCt === "string" || // Since we are entering a new custom type, if the previous id
|
383
|
+
// doesn't match, we can return early, because it's not the
|
384
|
+
// custom type we are looking for.
|
385
|
+
nestedCt.id !== previousPath.customTypeId) {
|
386
|
+
return nestedCt;
|
335
387
|
}
|
336
388
|
return {
|
337
|
-
...
|
338
|
-
|
339
|
-
const
|
340
|
-
if (typeof
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
return
|
389
|
+
...nestedCt,
|
390
|
+
fields: nestedCt.fields.map((nestedCtFieldArg) => {
|
391
|
+
const nestedCtField = shallowCloneIfObject(nestedCtFieldArg);
|
392
|
+
if (typeof nestedCtField === "string") {
|
393
|
+
if (nestedCtField === previousPath.fieldId && nestedCtField !== newPath.fieldId) {
|
394
|
+
return newPath.fieldId;
|
395
|
+
}
|
396
|
+
return nestedCtField;
|
397
|
+
}
|
398
|
+
if (nestedCtField.id === previousPath.fieldId && nestedCtField.id !== newPath.fieldId) {
|
399
|
+
nestedCtField.id = newPath.fieldId;
|
400
|
+
}
|
401
|
+
if (!previousPath.groupId || !newPath.groupId || nestedCtField.id !== previousPath.groupId) {
|
402
|
+
return nestedCtField;
|
403
|
+
}
|
404
|
+
if (nestedCtField.id !== newPath.groupId) {
|
405
|
+
nestedCtField.id = newPath.groupId;
|
345
406
|
}
|
346
407
|
return {
|
347
|
-
...
|
348
|
-
fields:
|
349
|
-
|
350
|
-
|
351
|
-
return newFieldId;
|
408
|
+
...nestedCtField,
|
409
|
+
fields: nestedCtField.fields.map((nestedCtGroupFieldId) => {
|
410
|
+
if (nestedCtGroupFieldId === previousPath.fieldId && nestedCtGroupFieldId !== newPath.fieldId) {
|
411
|
+
return newPath.fieldId;
|
352
412
|
}
|
353
|
-
return
|
413
|
+
return nestedCtGroupFieldId;
|
354
414
|
})
|
355
415
|
};
|
356
416
|
})
|
357
417
|
};
|
358
418
|
});
|
359
|
-
return { ...customType, fields: newFields };
|
360
419
|
}
|
361
420
|
function updateFieldContentRelationships(args) {
|
362
421
|
var _a, _b;
|
@@ -365,7 +424,7 @@ function updateFieldContentRelationships(args) {
|
|
365
424
|
return field;
|
366
425
|
}
|
367
426
|
const newCustomTypes = field.config.customtypes.map((customType) => {
|
368
|
-
return updateCRCustomType({
|
427
|
+
return updateCRCustomType({ ...updateMeta, customType });
|
369
428
|
});
|
370
429
|
return {
|
371
430
|
...field,
|
@@ -394,7 +453,7 @@ function updateSharedSliceContentRelationships(args) {
|
|
394
453
|
const { models, previousPath, newPath, onUpdate } = args;
|
395
454
|
for (const { model: slice } of models) {
|
396
455
|
const updateSlice = traverseSharedSlice({
|
397
|
-
path: [
|
456
|
+
path: [],
|
398
457
|
slice,
|
399
458
|
onField: ({ field }) => {
|
400
459
|
return updateFieldContentRelationships({
|
@@ -409,6 +468,22 @@ function updateSharedSliceContentRelationships(args) {
|
|
409
468
|
}
|
410
469
|
}
|
411
470
|
}
|
471
|
+
function getPathIds(path) {
|
472
|
+
if (path.length < 2) {
|
473
|
+
throw new Error(`Unexpected path length ${path.length}. Expected at least 2 segments (got: ${path.join(".")}).`);
|
474
|
+
}
|
475
|
+
const [customTypeId, groupOrFieldId, fieldId] = path;
|
476
|
+
return {
|
477
|
+
customTypeId,
|
478
|
+
/**
|
479
|
+
* Id of a changed group. If it's defined, it means that a group or a field
|
480
|
+
* inside a group had its API ID renamed. It's defined when the path has a
|
481
|
+
* third element (e.g. `["customtypeA", "groupA", "fieldA"]`).
|
482
|
+
*/
|
483
|
+
groupId: fieldId ? groupOrFieldId : void 0,
|
484
|
+
fieldId: fieldId || groupOrFieldId
|
485
|
+
};
|
486
|
+
}
|
412
487
|
function isEqualModel(modelA, modelB) {
|
413
488
|
return JSON.stringify(modelA) === JSON.stringify(modelB);
|
414
489
|
}
|