@slicemachine/manager 0.24.15-beta.9 → 0.24.16-alpha.coderabbitai-chat-dniAA6r9GseKm4ouqNyJ8dl.1
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/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_node_modules/execa/index.cjs +2 -2
- package/dist/_node_modules/execa/index.js +2 -2
- package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.cjs.map +1 -0
- package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.js.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.cjs +1 -1
- package/dist/_node_modules/npm-run-path/index.cjs.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.js +1 -1
- package/dist/_node_modules/npm-run-path/index.js.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.cjs +1 -1
- package/dist/_node_modules/onetime/index.cjs.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.js +1 -1
- package/dist/_node_modules/onetime/index.js.map +1 -0
- package/dist/_virtual/index2.cjs +4 -3
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +4 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +3 -4
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +2 -4
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs +113 -38
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.d.ts +197 -75
- package/dist/managers/customTypes/CustomTypesManager.js +113 -38
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/dist/managers/telemetry/types.cjs +4 -6
- package/dist/managers/telemetry/types.cjs.map +1 -1
- package/dist/managers/telemetry/types.d.ts +6 -7
- package/dist/managers/telemetry/types.js +4 -6
- package/dist/managers/telemetry/types.js.map +1 -1
- package/package.json +4 -4
- package/src/managers/customTypes/CustomTypesManager.ts +261 -74
- package/src/managers/telemetry/types.ts +12 -17
- package/dist/_node_modules/execa/_node_modules/npm-run-path/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/npm-run-path/index.js.map +0 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.js.map +0 -1
- package/dist/_node_modules/execa/_node_modules/path-key/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/path-key/index.js.map +0 -1
- /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.cjs +0 -0
- /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.js +0 -0
@@ -37,6 +37,24 @@ 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 PathWithinCustomType = [string] | [string, string];
|
42
|
+
/** `[ct, field]` or `[ct, group, field]` – path WITH Custom Type ID */
|
43
|
+
type PathWithCustomType = [string, string] | [string, string, string];
|
44
|
+
export type SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {
|
45
|
+
updateMeta?: {
|
46
|
+
fieldIdChanged?: {
|
47
|
+
/**
|
48
|
+
* Previous path of the changed field. `[field]` or `[group, field]`
|
49
|
+
*/
|
50
|
+
previousPath: PathWithinCustomType;
|
51
|
+
/**
|
52
|
+
* New path of the changed field. `[field]` or `[group, field]`
|
53
|
+
*/
|
54
|
+
newPath: PathWithinCustomType;
|
55
|
+
};
|
56
|
+
};
|
57
|
+
};
|
40
58
|
type SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {
|
41
59
|
errors: HookError[];
|
42
60
|
};
|
@@ -50,8 +68,8 @@ type CustomTypesMachineManagerUpdateCustomTypeReturnType = {
|
|
50
68
|
errors: (DecodeError | HookError)[];
|
51
69
|
};
|
52
70
|
type CustomTypeFieldIdChangedMeta = {
|
53
|
-
previousPath:
|
54
|
-
newPath:
|
71
|
+
previousPath: PathWithCustomType;
|
72
|
+
newPath: PathWithCustomType;
|
55
73
|
};
|
56
74
|
export declare class CustomTypesManager extends BaseManager {
|
57
75
|
readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType>;
|
@@ -64,7 +82,7 @@ export declare class CustomTypesManager extends BaseManager {
|
|
64
82
|
* property.
|
65
83
|
*/
|
66
84
|
private updateContentRelationships;
|
67
|
-
updateCustomType(args:
|
85
|
+
updateCustomType(args: SliceMachineManagerUpdateCustomTypeArgs): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType>;
|
68
86
|
renameCustomType(args: CustomTypeRenameHookData): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>>;
|
69
87
|
deleteCustomType(args: CustomTypesMachineManagerDeleteCustomTypeArgs): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType>;
|
70
88
|
pushCustomType(args: SliceMachineManagerPushCustomTypeArgs): Promise<void>;
|
@@ -221,18 +239,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
221
239
|
useAsTitle?: boolean | undefined;
|
222
240
|
placeholder?: string | undefined;
|
223
241
|
select?: "media" | "document" | "web" | null | undefined;
|
224
|
-
customtypes?: readonly (string |
|
242
|
+
customtypes?: readonly (string | {
|
225
243
|
id: string;
|
226
|
-
|
227
|
-
fields?: readonly (string | {
|
244
|
+
fields: readonly (string | {
|
228
245
|
id: string;
|
229
|
-
customtypes: readonly (string |
|
246
|
+
customtypes: readonly (string | {
|
230
247
|
id: string;
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
248
|
+
fields: readonly (string | {
|
249
|
+
id: string;
|
250
|
+
fields: readonly string[];
|
251
|
+
})[];
|
252
|
+
})[];
|
253
|
+
} | {
|
254
|
+
id: string;
|
255
|
+
fields: readonly (string | {
|
256
|
+
id: string;
|
257
|
+
customtypes: readonly (string | {
|
258
|
+
id: string;
|
259
|
+
fields: readonly (string | {
|
260
|
+
id: string;
|
261
|
+
fields: readonly string[];
|
262
|
+
})[];
|
263
|
+
})[];
|
264
|
+
})[];
|
265
|
+
})[];
|
266
|
+
})[] | undefined;
|
236
267
|
masks?: readonly string[] | undefined;
|
237
268
|
tags?: readonly string[] | undefined;
|
238
269
|
allowTargetBlank?: boolean | undefined;
|
@@ -407,18 +438,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
407
438
|
useAsTitle?: boolean | undefined;
|
408
439
|
placeholder?: string | undefined;
|
409
440
|
select?: "media" | "document" | "web" | null | undefined;
|
410
|
-
customtypes?: readonly (string |
|
441
|
+
customtypes?: readonly (string | {
|
411
442
|
id: string;
|
412
|
-
|
413
|
-
|
443
|
+
fields: readonly (string | {
|
444
|
+
id: string;
|
445
|
+
customtypes: readonly (string | {
|
446
|
+
id: string;
|
447
|
+
fields: readonly (string | {
|
448
|
+
id: string;
|
449
|
+
fields: readonly string[];
|
450
|
+
})[];
|
451
|
+
})[];
|
452
|
+
} | {
|
414
453
|
id: string;
|
415
|
-
|
454
|
+
fields: readonly (string | {
|
416
455
|
id: string;
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
456
|
+
customtypes: readonly (string | {
|
457
|
+
id: string;
|
458
|
+
fields: readonly (string | {
|
459
|
+
id: string;
|
460
|
+
fields: readonly string[];
|
461
|
+
})[];
|
462
|
+
})[];
|
463
|
+
})[];
|
464
|
+
})[];
|
465
|
+
})[] | undefined;
|
422
466
|
masks?: readonly string[] | undefined;
|
423
467
|
tags?: readonly string[] | undefined;
|
424
468
|
allowTargetBlank?: boolean | undefined;
|
@@ -593,18 +637,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
593
637
|
useAsTitle?: boolean | undefined;
|
594
638
|
placeholder?: string | undefined;
|
595
639
|
select?: "media" | "document" | "web" | null | undefined;
|
596
|
-
customtypes?: readonly (string |
|
640
|
+
customtypes?: readonly (string | {
|
597
641
|
id: string;
|
598
|
-
|
599
|
-
fields?: readonly (string | {
|
642
|
+
fields: readonly (string | {
|
600
643
|
id: string;
|
601
|
-
customtypes: readonly (string |
|
644
|
+
customtypes: readonly (string | {
|
602
645
|
id: string;
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
646
|
+
fields: readonly (string | {
|
647
|
+
id: string;
|
648
|
+
fields: readonly string[];
|
649
|
+
})[];
|
650
|
+
})[];
|
651
|
+
} | {
|
652
|
+
id: string;
|
653
|
+
fields: readonly (string | {
|
654
|
+
id: string;
|
655
|
+
customtypes: readonly (string | {
|
656
|
+
id: string;
|
657
|
+
fields: readonly (string | {
|
658
|
+
id: string;
|
659
|
+
fields: readonly string[];
|
660
|
+
})[];
|
661
|
+
})[];
|
662
|
+
})[];
|
663
|
+
})[];
|
664
|
+
})[] | undefined;
|
608
665
|
masks?: readonly string[] | undefined;
|
609
666
|
tags?: readonly string[] | undefined;
|
610
667
|
allowTargetBlank?: boolean | undefined;
|
@@ -778,18 +835,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
778
835
|
useAsTitle?: boolean | undefined;
|
779
836
|
placeholder?: string | undefined;
|
780
837
|
select?: "media" | "document" | "web" | null | undefined;
|
781
|
-
customtypes?: readonly (string |
|
838
|
+
customtypes?: readonly (string | {
|
782
839
|
id: string;
|
783
|
-
|
784
|
-
|
840
|
+
fields: readonly (string | {
|
841
|
+
id: string;
|
842
|
+
customtypes: readonly (string | {
|
843
|
+
id: string;
|
844
|
+
fields: readonly (string | {
|
845
|
+
id: string;
|
846
|
+
fields: readonly string[];
|
847
|
+
})[];
|
848
|
+
})[];
|
849
|
+
} | {
|
785
850
|
id: string;
|
786
|
-
|
851
|
+
fields: readonly (string | {
|
787
852
|
id: string;
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
853
|
+
customtypes: readonly (string | {
|
854
|
+
id: string;
|
855
|
+
fields: readonly (string | {
|
856
|
+
id: string;
|
857
|
+
fields: readonly string[];
|
858
|
+
})[];
|
859
|
+
})[];
|
860
|
+
})[];
|
861
|
+
})[];
|
862
|
+
})[] | undefined;
|
793
863
|
masks?: readonly string[] | undefined;
|
794
864
|
tags?: readonly string[] | undefined;
|
795
865
|
allowTargetBlank?: boolean | undefined;
|
@@ -979,18 +1049,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
979
1049
|
useAsTitle?: boolean | undefined;
|
980
1050
|
placeholder?: string | undefined;
|
981
1051
|
select?: "media" | "document" | "web" | null | undefined;
|
982
|
-
customtypes?: readonly (string |
|
1052
|
+
customtypes?: readonly (string | {
|
983
1053
|
id: string;
|
984
|
-
|
985
|
-
fields?: readonly (string | {
|
1054
|
+
fields: readonly (string | {
|
986
1055
|
id: string;
|
987
|
-
customtypes: readonly (string |
|
1056
|
+
customtypes: readonly (string | {
|
988
1057
|
id: string;
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
1058
|
+
fields: readonly (string | {
|
1059
|
+
id: string;
|
1060
|
+
fields: readonly string[];
|
1061
|
+
})[];
|
1062
|
+
})[];
|
1063
|
+
} | {
|
1064
|
+
id: string;
|
1065
|
+
fields: readonly (string | {
|
1066
|
+
id: string;
|
1067
|
+
customtypes: readonly (string | {
|
1068
|
+
id: string;
|
1069
|
+
fields: readonly (string | {
|
1070
|
+
id: string;
|
1071
|
+
fields: readonly string[];
|
1072
|
+
})[];
|
1073
|
+
})[];
|
1074
|
+
})[];
|
1075
|
+
})[];
|
1076
|
+
})[] | undefined;
|
994
1077
|
masks?: readonly string[] | undefined;
|
995
1078
|
tags?: readonly string[] | undefined;
|
996
1079
|
allowTargetBlank?: boolean | undefined;
|
@@ -1165,18 +1248,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1165
1248
|
useAsTitle?: boolean | undefined;
|
1166
1249
|
placeholder?: string | undefined;
|
1167
1250
|
select?: "media" | "document" | "web" | null | undefined;
|
1168
|
-
customtypes?: readonly (string |
|
1251
|
+
customtypes?: readonly (string | {
|
1169
1252
|
id: string;
|
1170
|
-
|
1171
|
-
|
1253
|
+
fields: readonly (string | {
|
1254
|
+
id: string;
|
1255
|
+
customtypes: readonly (string | {
|
1256
|
+
id: string;
|
1257
|
+
fields: readonly (string | {
|
1258
|
+
id: string;
|
1259
|
+
fields: readonly string[];
|
1260
|
+
})[];
|
1261
|
+
})[];
|
1262
|
+
} | {
|
1172
1263
|
id: string;
|
1173
|
-
|
1264
|
+
fields: readonly (string | {
|
1174
1265
|
id: string;
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1266
|
+
customtypes: readonly (string | {
|
1267
|
+
id: string;
|
1268
|
+
fields: readonly (string | {
|
1269
|
+
id: string;
|
1270
|
+
fields: readonly string[];
|
1271
|
+
})[];
|
1272
|
+
})[];
|
1273
|
+
})[];
|
1274
|
+
})[];
|
1275
|
+
})[] | undefined;
|
1180
1276
|
masks?: readonly string[] | undefined;
|
1181
1277
|
tags?: readonly string[] | undefined;
|
1182
1278
|
allowTargetBlank?: boolean | undefined;
|
@@ -1351,18 +1447,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1351
1447
|
useAsTitle?: boolean | undefined;
|
1352
1448
|
placeholder?: string | undefined;
|
1353
1449
|
select?: "media" | "document" | "web" | null | undefined;
|
1354
|
-
customtypes?: readonly (string |
|
1450
|
+
customtypes?: readonly (string | {
|
1355
1451
|
id: string;
|
1356
|
-
|
1357
|
-
fields?: readonly (string | {
|
1452
|
+
fields: readonly (string | {
|
1358
1453
|
id: string;
|
1359
|
-
customtypes: readonly (string |
|
1454
|
+
customtypes: readonly (string | {
|
1360
1455
|
id: string;
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1456
|
+
fields: readonly (string | {
|
1457
|
+
id: string;
|
1458
|
+
fields: readonly string[];
|
1459
|
+
})[];
|
1460
|
+
})[];
|
1461
|
+
} | {
|
1462
|
+
id: string;
|
1463
|
+
fields: readonly (string | {
|
1464
|
+
id: string;
|
1465
|
+
customtypes: readonly (string | {
|
1466
|
+
id: string;
|
1467
|
+
fields: readonly (string | {
|
1468
|
+
id: string;
|
1469
|
+
fields: readonly string[];
|
1470
|
+
})[];
|
1471
|
+
})[];
|
1472
|
+
})[];
|
1473
|
+
})[];
|
1474
|
+
})[] | undefined;
|
1366
1475
|
masks?: readonly string[] | undefined;
|
1367
1476
|
tags?: readonly string[] | undefined;
|
1368
1477
|
allowTargetBlank?: boolean | undefined;
|
@@ -1536,18 +1645,31 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1536
1645
|
useAsTitle?: boolean | undefined;
|
1537
1646
|
placeholder?: string | undefined;
|
1538
1647
|
select?: "media" | "document" | "web" | null | undefined;
|
1539
|
-
customtypes?: readonly (string |
|
1648
|
+
customtypes?: readonly (string | {
|
1540
1649
|
id: string;
|
1541
|
-
|
1542
|
-
fields?: readonly (string | {
|
1650
|
+
fields: readonly (string | {
|
1543
1651
|
id: string;
|
1544
|
-
customtypes: readonly (string |
|
1652
|
+
customtypes: readonly (string | {
|
1545
1653
|
id: string;
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1654
|
+
fields: readonly (string | {
|
1655
|
+
id: string;
|
1656
|
+
fields: readonly string[];
|
1657
|
+
})[];
|
1658
|
+
})[];
|
1659
|
+
} | {
|
1660
|
+
id: string;
|
1661
|
+
fields: readonly (string | {
|
1662
|
+
id: string;
|
1663
|
+
customtypes: readonly (string | {
|
1664
|
+
id: string;
|
1665
|
+
fields: readonly (string | {
|
1666
|
+
id: string;
|
1667
|
+
fields: readonly string[];
|
1668
|
+
})[];
|
1669
|
+
})[];
|
1670
|
+
})[];
|
1671
|
+
})[];
|
1672
|
+
})[] | undefined;
|
1551
1673
|
masks?: readonly string[] | undefined;
|
1552
1674
|
tags?: readonly string[] | undefined;
|
1553
1675
|
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;
|
@@ -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
|
}
|