@uniformdev/transformer 1.1.52 → 1.1.53
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/cli/index.js +138 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +137 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ interface ComponentInstance {
|
|
|
36
36
|
}
|
|
37
37
|
interface CompositionOverrides {
|
|
38
38
|
parameters?: Record<string, ParameterValue>;
|
|
39
|
+
/** Slot patches stored only under _overrides (not duplicated on the main tree instance). */
|
|
40
|
+
slots?: Record<string, ComponentInstance[]>;
|
|
39
41
|
[key: string]: unknown;
|
|
40
42
|
}
|
|
41
43
|
interface CompositionRoot {
|
|
@@ -610,6 +612,7 @@ declare class ParameterRemoverService {
|
|
|
610
612
|
private removeParameterInDirectory;
|
|
611
613
|
private removeParameterFromTree;
|
|
612
614
|
private removeParameterFromOverrides;
|
|
615
|
+
private removeParameterFromOverrideSlotTrees;
|
|
613
616
|
private removeOverridesForMatchingInstances;
|
|
614
617
|
private removeKeysFromMap;
|
|
615
618
|
}
|
|
@@ -644,6 +647,15 @@ declare class FieldRemoverService {
|
|
|
644
647
|
private removeFieldInDirectory;
|
|
645
648
|
private removeFieldFromTree;
|
|
646
649
|
private removeFieldFromOverrides;
|
|
650
|
+
/**
|
|
651
|
+
* Walks every _overrides entry's `slots` trees (if present) and removes parameter keys from
|
|
652
|
+
* matching component instances. Uniform often stores nested slot patches only here.
|
|
653
|
+
*/
|
|
654
|
+
private removeFieldFromOverrideSlotTrees;
|
|
655
|
+
/**
|
|
656
|
+
* Looks up override entries by compound key (ancestor _id chain joined with |) and,
|
|
657
|
+
* for backward compatibility, by instance _id alone when it differs from the compound key.
|
|
658
|
+
*/
|
|
647
659
|
private removeOverridesForMatchingInstances;
|
|
648
660
|
private removeKeysFromMap;
|
|
649
661
|
}
|
package/dist/index.js
CHANGED
|
@@ -2890,6 +2890,9 @@ var ParameterRemoverService = class {
|
|
|
2890
2890
|
strict,
|
|
2891
2891
|
"composition"
|
|
2892
2892
|
);
|
|
2893
|
+
this.logger.info(
|
|
2894
|
+
`Compositions (${compositionsDir}): ${compositionsResult.totalFilesMatched} file(s) matched, ${compositionsResult.validCompositionDocuments} with a composition root.`
|
|
2895
|
+
);
|
|
2893
2896
|
const compositionPatternsResult = await this.removeParameterInDirectory(
|
|
2894
2897
|
fullCompositionPatternsDir,
|
|
2895
2898
|
componentType,
|
|
@@ -2898,6 +2901,9 @@ var ParameterRemoverService = class {
|
|
|
2898
2901
|
strict,
|
|
2899
2902
|
"compositionPattern"
|
|
2900
2903
|
);
|
|
2904
|
+
this.logger.info(
|
|
2905
|
+
`Composition patterns (${compositionPatternsDir}): ${compositionPatternsResult.totalFilesMatched} file(s) matched, ${compositionPatternsResult.validCompositionDocuments} with a composition root.`
|
|
2906
|
+
);
|
|
2901
2907
|
const componentPatternsResult = await this.removeParameterInDirectory(
|
|
2902
2908
|
fullComponentPatternsDir,
|
|
2903
2909
|
componentType,
|
|
@@ -2906,6 +2912,9 @@ var ParameterRemoverService = class {
|
|
|
2906
2912
|
strict,
|
|
2907
2913
|
"componentPattern"
|
|
2908
2914
|
);
|
|
2915
|
+
this.logger.info(
|
|
2916
|
+
`Component patterns (${componentPatternsDir}): ${componentPatternsResult.totalFilesMatched} file(s) matched, ${componentPatternsResult.validCompositionDocuments} with a composition root.`
|
|
2917
|
+
);
|
|
2909
2918
|
const totalFiles = compositionsResult.filesModified + compositionPatternsResult.filesModified + componentPatternsResult.filesModified;
|
|
2910
2919
|
const totalInstances = compositionsResult.instancesUpdated + compositionPatternsResult.instancesUpdated + componentPatternsResult.instancesUpdated;
|
|
2911
2920
|
this.logger.info("");
|
|
@@ -2925,13 +2934,25 @@ var ParameterRemoverService = class {
|
|
|
2925
2934
|
try {
|
|
2926
2935
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
2927
2936
|
} catch {
|
|
2928
|
-
return {
|
|
2937
|
+
return {
|
|
2938
|
+
filesModified: 0,
|
|
2939
|
+
instancesUpdated: 0,
|
|
2940
|
+
totalFilesMatched: 0,
|
|
2941
|
+
validCompositionDocuments: 0
|
|
2942
|
+
};
|
|
2929
2943
|
}
|
|
2944
|
+
const totalFilesMatched = files.length;
|
|
2930
2945
|
if (files.length === 0) {
|
|
2931
|
-
return {
|
|
2946
|
+
return {
|
|
2947
|
+
filesModified: 0,
|
|
2948
|
+
instancesUpdated: 0,
|
|
2949
|
+
totalFilesMatched: 0,
|
|
2950
|
+
validCompositionDocuments: 0
|
|
2951
|
+
};
|
|
2932
2952
|
}
|
|
2933
2953
|
let filesModified = 0;
|
|
2934
2954
|
let instancesUpdated = 0;
|
|
2955
|
+
let validCompositionDocuments = 0;
|
|
2935
2956
|
for (const filePath of files) {
|
|
2936
2957
|
let composition;
|
|
2937
2958
|
try {
|
|
@@ -2942,6 +2963,7 @@ var ParameterRemoverService = class {
|
|
|
2942
2963
|
if (!composition?.composition) {
|
|
2943
2964
|
continue;
|
|
2944
2965
|
}
|
|
2966
|
+
validCompositionDocuments++;
|
|
2945
2967
|
const count = this.removeParameterFromTree(
|
|
2946
2968
|
composition.composition,
|
|
2947
2969
|
componentType,
|
|
@@ -2969,7 +2991,7 @@ var ParameterRemoverService = class {
|
|
|
2969
2991
|
instancesUpdated += totalCount;
|
|
2970
2992
|
}
|
|
2971
2993
|
}
|
|
2972
|
-
return { filesModified, instancesUpdated };
|
|
2994
|
+
return { filesModified, instancesUpdated, totalFilesMatched, validCompositionDocuments };
|
|
2973
2995
|
}
|
|
2974
2996
|
removeParameterFromTree(node, componentType, parameterIds, strict) {
|
|
2975
2997
|
let count = 0;
|
|
@@ -3011,24 +3033,54 @@ var ParameterRemoverService = class {
|
|
|
3011
3033
|
componentType,
|
|
3012
3034
|
parameterIds,
|
|
3013
3035
|
strict,
|
|
3014
|
-
counter
|
|
3036
|
+
counter,
|
|
3037
|
+
[composition.composition._id]
|
|
3015
3038
|
);
|
|
3016
3039
|
count += counter.count;
|
|
3040
|
+
const slotTreeCounter = { count: 0 };
|
|
3041
|
+
this.removeParameterFromOverrideSlotTrees(
|
|
3042
|
+
composition.composition._overrides,
|
|
3043
|
+
componentType,
|
|
3044
|
+
parameterIds,
|
|
3045
|
+
strict,
|
|
3046
|
+
slotTreeCounter
|
|
3047
|
+
);
|
|
3048
|
+
count += slotTreeCounter.count;
|
|
3017
3049
|
return count;
|
|
3018
3050
|
}
|
|
3019
|
-
|
|
3051
|
+
removeParameterFromOverrideSlotTrees(overrides, componentType, parameterIds, strict, counter) {
|
|
3052
|
+
for (const entry of Object.values(overrides)) {
|
|
3053
|
+
const slots = entry.slots;
|
|
3054
|
+
if (!slots) continue;
|
|
3055
|
+
for (const slotInstances of Object.values(slots)) {
|
|
3056
|
+
if (!Array.isArray(slotInstances)) continue;
|
|
3057
|
+
for (const instance of slotInstances) {
|
|
3058
|
+
counter.count += this.removeParameterFromTree(instance, componentType, parameterIds, strict);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict, counter, idPath) {
|
|
3020
3064
|
if (node.slots) {
|
|
3021
3065
|
for (const slotInstances of Object.values(node.slots)) {
|
|
3022
3066
|
if (!Array.isArray(slotInstances)) continue;
|
|
3023
3067
|
for (const instance of slotInstances) {
|
|
3024
3068
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
3025
|
-
const
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3069
|
+
const compoundKey = [...idPath, instance._id].join("|");
|
|
3070
|
+
const keysToTry = compoundKey === instance._id ? [compoundKey] : [compoundKey, instance._id];
|
|
3071
|
+
let removedAny = false;
|
|
3072
|
+
for (const overrideKey of keysToTry) {
|
|
3073
|
+
const instanceOverrides = overrides[overrideKey];
|
|
3074
|
+
if (instanceOverrides?.parameters) {
|
|
3075
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
3076
|
+
if (removed > 0) {
|
|
3077
|
+
removedAny = true;
|
|
3078
|
+
}
|
|
3030
3079
|
}
|
|
3031
3080
|
}
|
|
3081
|
+
if (removedAny) {
|
|
3082
|
+
counter.count++;
|
|
3083
|
+
}
|
|
3032
3084
|
}
|
|
3033
3085
|
this.removeOverridesForMatchingInstances(
|
|
3034
3086
|
instance,
|
|
@@ -3036,7 +3088,8 @@ var ParameterRemoverService = class {
|
|
|
3036
3088
|
componentType,
|
|
3037
3089
|
parameterIds,
|
|
3038
3090
|
strict,
|
|
3039
|
-
counter
|
|
3091
|
+
counter,
|
|
3092
|
+
[...idPath, instance._id ?? ""]
|
|
3040
3093
|
);
|
|
3041
3094
|
}
|
|
3042
3095
|
}
|
|
@@ -3117,6 +3170,9 @@ var FieldRemoverService = class {
|
|
|
3117
3170
|
strict,
|
|
3118
3171
|
"composition"
|
|
3119
3172
|
);
|
|
3173
|
+
this.logger.info(
|
|
3174
|
+
`Compositions (${compositionsDir}): ${compositionsResult.totalFilesMatched} file(s) matched, ${compositionsResult.validCompositionDocuments} with a composition root.`
|
|
3175
|
+
);
|
|
3120
3176
|
const compositionPatternsResult = await this.removeFieldInDirectory(
|
|
3121
3177
|
fullCompositionPatternsDir,
|
|
3122
3178
|
componentType,
|
|
@@ -3125,6 +3181,9 @@ var FieldRemoverService = class {
|
|
|
3125
3181
|
strict,
|
|
3126
3182
|
"compositionPattern"
|
|
3127
3183
|
);
|
|
3184
|
+
this.logger.info(
|
|
3185
|
+
`Composition patterns (${compositionPatternsDir}): ${compositionPatternsResult.totalFilesMatched} file(s) matched, ${compositionPatternsResult.validCompositionDocuments} with a composition root.`
|
|
3186
|
+
);
|
|
3128
3187
|
const componentPatternsResult = await this.removeFieldInDirectory(
|
|
3129
3188
|
fullComponentPatternsDir,
|
|
3130
3189
|
componentType,
|
|
@@ -3133,6 +3192,9 @@ var FieldRemoverService = class {
|
|
|
3133
3192
|
strict,
|
|
3134
3193
|
"componentPattern"
|
|
3135
3194
|
);
|
|
3195
|
+
this.logger.info(
|
|
3196
|
+
`Component patterns (${componentPatternsDir}): ${componentPatternsResult.totalFilesMatched} file(s) matched, ${componentPatternsResult.validCompositionDocuments} with a composition root.`
|
|
3197
|
+
);
|
|
3136
3198
|
const totalFiles = compositionsResult.filesModified + compositionPatternsResult.filesModified + componentPatternsResult.filesModified;
|
|
3137
3199
|
const totalInstances = compositionsResult.instancesUpdated + compositionPatternsResult.instancesUpdated + componentPatternsResult.instancesUpdated;
|
|
3138
3200
|
this.logger.info("");
|
|
@@ -3206,13 +3268,25 @@ var FieldRemoverService = class {
|
|
|
3206
3268
|
try {
|
|
3207
3269
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
3208
3270
|
} catch {
|
|
3209
|
-
return {
|
|
3271
|
+
return {
|
|
3272
|
+
filesModified: 0,
|
|
3273
|
+
instancesUpdated: 0,
|
|
3274
|
+
totalFilesMatched: 0,
|
|
3275
|
+
validCompositionDocuments: 0
|
|
3276
|
+
};
|
|
3210
3277
|
}
|
|
3278
|
+
const totalFilesMatched = files.length;
|
|
3211
3279
|
if (files.length === 0) {
|
|
3212
|
-
return {
|
|
3280
|
+
return {
|
|
3281
|
+
filesModified: 0,
|
|
3282
|
+
instancesUpdated: 0,
|
|
3283
|
+
totalFilesMatched: 0,
|
|
3284
|
+
validCompositionDocuments: 0
|
|
3285
|
+
};
|
|
3213
3286
|
}
|
|
3214
3287
|
let filesModified = 0;
|
|
3215
3288
|
let instancesUpdated = 0;
|
|
3289
|
+
let validCompositionDocuments = 0;
|
|
3216
3290
|
for (const filePath of files) {
|
|
3217
3291
|
let composition;
|
|
3218
3292
|
try {
|
|
@@ -3223,6 +3297,7 @@ var FieldRemoverService = class {
|
|
|
3223
3297
|
if (!composition?.composition) {
|
|
3224
3298
|
continue;
|
|
3225
3299
|
}
|
|
3300
|
+
validCompositionDocuments++;
|
|
3226
3301
|
const treeCount = this.removeFieldFromTree(
|
|
3227
3302
|
composition.composition,
|
|
3228
3303
|
componentType,
|
|
@@ -3250,7 +3325,7 @@ var FieldRemoverService = class {
|
|
|
3250
3325
|
instancesUpdated += totalCount;
|
|
3251
3326
|
}
|
|
3252
3327
|
}
|
|
3253
|
-
return { filesModified, instancesUpdated };
|
|
3328
|
+
return { filesModified, instancesUpdated, totalFilesMatched, validCompositionDocuments };
|
|
3254
3329
|
}
|
|
3255
3330
|
removeFieldFromTree(node, componentType, parameterIds, strict) {
|
|
3256
3331
|
let count = 0;
|
|
@@ -3276,8 +3351,8 @@ var FieldRemoverService = class {
|
|
|
3276
3351
|
}
|
|
3277
3352
|
let count = 0;
|
|
3278
3353
|
if (this.compareIds(composition.composition.type, componentType, strict)) {
|
|
3279
|
-
const
|
|
3280
|
-
const rootOverrides = composition.composition._overrides[
|
|
3354
|
+
const rootId2 = composition.composition._id;
|
|
3355
|
+
const rootOverrides = composition.composition._overrides[rootId2];
|
|
3281
3356
|
if (rootOverrides?.parameters) {
|
|
3282
3357
|
const removed = this.removeKeysFromMap(rootOverrides.parameters, parameterIds, strict);
|
|
3283
3358
|
if (removed > 0) {
|
|
@@ -3285,8 +3360,16 @@ var FieldRemoverService = class {
|
|
|
3285
3360
|
}
|
|
3286
3361
|
}
|
|
3287
3362
|
}
|
|
3363
|
+
const rootId = composition.composition._id;
|
|
3288
3364
|
count += this.removeOverridesForMatchingInstances(
|
|
3289
3365
|
composition.composition,
|
|
3366
|
+
composition.composition._overrides,
|
|
3367
|
+
componentType,
|
|
3368
|
+
parameterIds,
|
|
3369
|
+
strict,
|
|
3370
|
+
[rootId]
|
|
3371
|
+
);
|
|
3372
|
+
count += this.removeFieldFromOverrideSlotTrees(
|
|
3290
3373
|
composition.composition._overrides,
|
|
3291
3374
|
componentType,
|
|
3292
3375
|
parameterIds,
|
|
@@ -3294,27 +3377,58 @@ var FieldRemoverService = class {
|
|
|
3294
3377
|
);
|
|
3295
3378
|
return count;
|
|
3296
3379
|
}
|
|
3297
|
-
|
|
3380
|
+
/**
|
|
3381
|
+
* Walks every _overrides entry's `slots` trees (if present) and removes parameter keys from
|
|
3382
|
+
* matching component instances. Uniform often stores nested slot patches only here.
|
|
3383
|
+
*/
|
|
3384
|
+
removeFieldFromOverrideSlotTrees(overrides, componentType, parameterIds, strict) {
|
|
3385
|
+
let count = 0;
|
|
3386
|
+
for (const entry of Object.values(overrides)) {
|
|
3387
|
+
const slots = entry.slots;
|
|
3388
|
+
if (!slots) continue;
|
|
3389
|
+
for (const slotInstances of Object.values(slots)) {
|
|
3390
|
+
if (!Array.isArray(slotInstances)) continue;
|
|
3391
|
+
for (const instance of slotInstances) {
|
|
3392
|
+
count += this.removeFieldFromTree(instance, componentType, parameterIds, strict);
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
return count;
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Looks up override entries by compound key (ancestor _id chain joined with |) and,
|
|
3400
|
+
* for backward compatibility, by instance _id alone when it differs from the compound key.
|
|
3401
|
+
*/
|
|
3402
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict, idPath) {
|
|
3298
3403
|
let count = 0;
|
|
3299
3404
|
if (node.slots) {
|
|
3300
3405
|
for (const slotInstances of Object.values(node.slots)) {
|
|
3301
3406
|
if (!Array.isArray(slotInstances)) continue;
|
|
3302
3407
|
for (const instance of slotInstances) {
|
|
3303
3408
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
3304
|
-
const
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3409
|
+
const compoundKey = [...idPath, instance._id].join("|");
|
|
3410
|
+
const keysToTry = compoundKey === instance._id ? [compoundKey] : [compoundKey, instance._id];
|
|
3411
|
+
let removedAny = false;
|
|
3412
|
+
for (const overrideKey of keysToTry) {
|
|
3413
|
+
const instanceOverrides = overrides[overrideKey];
|
|
3414
|
+
if (instanceOverrides?.parameters) {
|
|
3415
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
3416
|
+
if (removed > 0) {
|
|
3417
|
+
removedAny = true;
|
|
3418
|
+
}
|
|
3309
3419
|
}
|
|
3310
3420
|
}
|
|
3421
|
+
if (removedAny) {
|
|
3422
|
+
count++;
|
|
3423
|
+
}
|
|
3311
3424
|
}
|
|
3312
3425
|
count += this.removeOverridesForMatchingInstances(
|
|
3313
3426
|
instance,
|
|
3314
3427
|
overrides,
|
|
3315
3428
|
componentType,
|
|
3316
3429
|
parameterIds,
|
|
3317
|
-
strict
|
|
3430
|
+
strict,
|
|
3431
|
+
[...idPath, instance._id ?? ""]
|
|
3318
3432
|
);
|
|
3319
3433
|
}
|
|
3320
3434
|
}
|