@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/cli/index.js
CHANGED
|
@@ -4977,6 +4977,9 @@ var ParameterRemoverService = class {
|
|
|
4977
4977
|
strict,
|
|
4978
4978
|
"composition"
|
|
4979
4979
|
);
|
|
4980
|
+
this.logger.info(
|
|
4981
|
+
`Compositions (${compositionsDir}): ${compositionsResult.totalFilesMatched} file(s) matched, ${compositionsResult.validCompositionDocuments} with a composition root.`
|
|
4982
|
+
);
|
|
4980
4983
|
const compositionPatternsResult = await this.removeParameterInDirectory(
|
|
4981
4984
|
fullCompositionPatternsDir,
|
|
4982
4985
|
componentType,
|
|
@@ -4985,6 +4988,9 @@ var ParameterRemoverService = class {
|
|
|
4985
4988
|
strict,
|
|
4986
4989
|
"compositionPattern"
|
|
4987
4990
|
);
|
|
4991
|
+
this.logger.info(
|
|
4992
|
+
`Composition patterns (${compositionPatternsDir}): ${compositionPatternsResult.totalFilesMatched} file(s) matched, ${compositionPatternsResult.validCompositionDocuments} with a composition root.`
|
|
4993
|
+
);
|
|
4988
4994
|
const componentPatternsResult = await this.removeParameterInDirectory(
|
|
4989
4995
|
fullComponentPatternsDir,
|
|
4990
4996
|
componentType,
|
|
@@ -4993,6 +4999,9 @@ var ParameterRemoverService = class {
|
|
|
4993
4999
|
strict,
|
|
4994
5000
|
"componentPattern"
|
|
4995
5001
|
);
|
|
5002
|
+
this.logger.info(
|
|
5003
|
+
`Component patterns (${componentPatternsDir}): ${componentPatternsResult.totalFilesMatched} file(s) matched, ${componentPatternsResult.validCompositionDocuments} with a composition root.`
|
|
5004
|
+
);
|
|
4996
5005
|
const totalFiles = compositionsResult.filesModified + compositionPatternsResult.filesModified + componentPatternsResult.filesModified;
|
|
4997
5006
|
const totalInstances = compositionsResult.instancesUpdated + compositionPatternsResult.instancesUpdated + componentPatternsResult.instancesUpdated;
|
|
4998
5007
|
this.logger.info("");
|
|
@@ -5012,13 +5021,25 @@ var ParameterRemoverService = class {
|
|
|
5012
5021
|
try {
|
|
5013
5022
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
5014
5023
|
} catch {
|
|
5015
|
-
return {
|
|
5024
|
+
return {
|
|
5025
|
+
filesModified: 0,
|
|
5026
|
+
instancesUpdated: 0,
|
|
5027
|
+
totalFilesMatched: 0,
|
|
5028
|
+
validCompositionDocuments: 0
|
|
5029
|
+
};
|
|
5016
5030
|
}
|
|
5031
|
+
const totalFilesMatched = files.length;
|
|
5017
5032
|
if (files.length === 0) {
|
|
5018
|
-
return {
|
|
5033
|
+
return {
|
|
5034
|
+
filesModified: 0,
|
|
5035
|
+
instancesUpdated: 0,
|
|
5036
|
+
totalFilesMatched: 0,
|
|
5037
|
+
validCompositionDocuments: 0
|
|
5038
|
+
};
|
|
5019
5039
|
}
|
|
5020
5040
|
let filesModified = 0;
|
|
5021
5041
|
let instancesUpdated = 0;
|
|
5042
|
+
let validCompositionDocuments = 0;
|
|
5022
5043
|
for (const filePath of files) {
|
|
5023
5044
|
let composition;
|
|
5024
5045
|
try {
|
|
@@ -5029,6 +5050,7 @@ var ParameterRemoverService = class {
|
|
|
5029
5050
|
if (!composition?.composition) {
|
|
5030
5051
|
continue;
|
|
5031
5052
|
}
|
|
5053
|
+
validCompositionDocuments++;
|
|
5032
5054
|
const count = this.removeParameterFromTree(
|
|
5033
5055
|
composition.composition,
|
|
5034
5056
|
componentType,
|
|
@@ -5056,7 +5078,7 @@ var ParameterRemoverService = class {
|
|
|
5056
5078
|
instancesUpdated += totalCount;
|
|
5057
5079
|
}
|
|
5058
5080
|
}
|
|
5059
|
-
return { filesModified, instancesUpdated };
|
|
5081
|
+
return { filesModified, instancesUpdated, totalFilesMatched, validCompositionDocuments };
|
|
5060
5082
|
}
|
|
5061
5083
|
removeParameterFromTree(node, componentType, parameterIds, strict) {
|
|
5062
5084
|
let count = 0;
|
|
@@ -5098,24 +5120,54 @@ var ParameterRemoverService = class {
|
|
|
5098
5120
|
componentType,
|
|
5099
5121
|
parameterIds,
|
|
5100
5122
|
strict,
|
|
5101
|
-
counter
|
|
5123
|
+
counter,
|
|
5124
|
+
[composition.composition._id]
|
|
5102
5125
|
);
|
|
5103
5126
|
count += counter.count;
|
|
5127
|
+
const slotTreeCounter = { count: 0 };
|
|
5128
|
+
this.removeParameterFromOverrideSlotTrees(
|
|
5129
|
+
composition.composition._overrides,
|
|
5130
|
+
componentType,
|
|
5131
|
+
parameterIds,
|
|
5132
|
+
strict,
|
|
5133
|
+
slotTreeCounter
|
|
5134
|
+
);
|
|
5135
|
+
count += slotTreeCounter.count;
|
|
5104
5136
|
return count;
|
|
5105
5137
|
}
|
|
5106
|
-
|
|
5138
|
+
removeParameterFromOverrideSlotTrees(overrides, componentType, parameterIds, strict, counter) {
|
|
5139
|
+
for (const entry of Object.values(overrides)) {
|
|
5140
|
+
const slots = entry.slots;
|
|
5141
|
+
if (!slots) continue;
|
|
5142
|
+
for (const slotInstances of Object.values(slots)) {
|
|
5143
|
+
if (!Array.isArray(slotInstances)) continue;
|
|
5144
|
+
for (const instance of slotInstances) {
|
|
5145
|
+
counter.count += this.removeParameterFromTree(instance, componentType, parameterIds, strict);
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict, counter, idPath) {
|
|
5107
5151
|
if (node.slots) {
|
|
5108
5152
|
for (const slotInstances of Object.values(node.slots)) {
|
|
5109
5153
|
if (!Array.isArray(slotInstances)) continue;
|
|
5110
5154
|
for (const instance of slotInstances) {
|
|
5111
5155
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
5112
|
-
const
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5156
|
+
const compoundKey = [...idPath, instance._id].join("|");
|
|
5157
|
+
const keysToTry = compoundKey === instance._id ? [compoundKey] : [compoundKey, instance._id];
|
|
5158
|
+
let removedAny = false;
|
|
5159
|
+
for (const overrideKey of keysToTry) {
|
|
5160
|
+
const instanceOverrides = overrides[overrideKey];
|
|
5161
|
+
if (instanceOverrides?.parameters) {
|
|
5162
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
5163
|
+
if (removed > 0) {
|
|
5164
|
+
removedAny = true;
|
|
5165
|
+
}
|
|
5117
5166
|
}
|
|
5118
5167
|
}
|
|
5168
|
+
if (removedAny) {
|
|
5169
|
+
counter.count++;
|
|
5170
|
+
}
|
|
5119
5171
|
}
|
|
5120
5172
|
this.removeOverridesForMatchingInstances(
|
|
5121
5173
|
instance,
|
|
@@ -5123,7 +5175,8 @@ var ParameterRemoverService = class {
|
|
|
5123
5175
|
componentType,
|
|
5124
5176
|
parameterIds,
|
|
5125
5177
|
strict,
|
|
5126
|
-
counter
|
|
5178
|
+
counter,
|
|
5179
|
+
[...idPath, instance._id ?? ""]
|
|
5127
5180
|
);
|
|
5128
5181
|
}
|
|
5129
5182
|
}
|
|
@@ -5300,6 +5353,9 @@ var FieldRemoverService = class {
|
|
|
5300
5353
|
strict,
|
|
5301
5354
|
"composition"
|
|
5302
5355
|
);
|
|
5356
|
+
this.logger.info(
|
|
5357
|
+
`Compositions (${compositionsDir}): ${compositionsResult.totalFilesMatched} file(s) matched, ${compositionsResult.validCompositionDocuments} with a composition root.`
|
|
5358
|
+
);
|
|
5303
5359
|
const compositionPatternsResult = await this.removeFieldInDirectory(
|
|
5304
5360
|
fullCompositionPatternsDir,
|
|
5305
5361
|
componentType,
|
|
@@ -5308,6 +5364,9 @@ var FieldRemoverService = class {
|
|
|
5308
5364
|
strict,
|
|
5309
5365
|
"compositionPattern"
|
|
5310
5366
|
);
|
|
5367
|
+
this.logger.info(
|
|
5368
|
+
`Composition patterns (${compositionPatternsDir}): ${compositionPatternsResult.totalFilesMatched} file(s) matched, ${compositionPatternsResult.validCompositionDocuments} with a composition root.`
|
|
5369
|
+
);
|
|
5311
5370
|
const componentPatternsResult = await this.removeFieldInDirectory(
|
|
5312
5371
|
fullComponentPatternsDir,
|
|
5313
5372
|
componentType,
|
|
@@ -5316,6 +5375,9 @@ var FieldRemoverService = class {
|
|
|
5316
5375
|
strict,
|
|
5317
5376
|
"componentPattern"
|
|
5318
5377
|
);
|
|
5378
|
+
this.logger.info(
|
|
5379
|
+
`Component patterns (${componentPatternsDir}): ${componentPatternsResult.totalFilesMatched} file(s) matched, ${componentPatternsResult.validCompositionDocuments} with a composition root.`
|
|
5380
|
+
);
|
|
5319
5381
|
const totalFiles = compositionsResult.filesModified + compositionPatternsResult.filesModified + componentPatternsResult.filesModified;
|
|
5320
5382
|
const totalInstances = compositionsResult.instancesUpdated + compositionPatternsResult.instancesUpdated + componentPatternsResult.instancesUpdated;
|
|
5321
5383
|
this.logger.info("");
|
|
@@ -5389,13 +5451,25 @@ var FieldRemoverService = class {
|
|
|
5389
5451
|
try {
|
|
5390
5452
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
5391
5453
|
} catch {
|
|
5392
|
-
return {
|
|
5454
|
+
return {
|
|
5455
|
+
filesModified: 0,
|
|
5456
|
+
instancesUpdated: 0,
|
|
5457
|
+
totalFilesMatched: 0,
|
|
5458
|
+
validCompositionDocuments: 0
|
|
5459
|
+
};
|
|
5393
5460
|
}
|
|
5461
|
+
const totalFilesMatched = files.length;
|
|
5394
5462
|
if (files.length === 0) {
|
|
5395
|
-
return {
|
|
5463
|
+
return {
|
|
5464
|
+
filesModified: 0,
|
|
5465
|
+
instancesUpdated: 0,
|
|
5466
|
+
totalFilesMatched: 0,
|
|
5467
|
+
validCompositionDocuments: 0
|
|
5468
|
+
};
|
|
5396
5469
|
}
|
|
5397
5470
|
let filesModified = 0;
|
|
5398
5471
|
let instancesUpdated = 0;
|
|
5472
|
+
let validCompositionDocuments = 0;
|
|
5399
5473
|
for (const filePath of files) {
|
|
5400
5474
|
let composition;
|
|
5401
5475
|
try {
|
|
@@ -5406,6 +5480,7 @@ var FieldRemoverService = class {
|
|
|
5406
5480
|
if (!composition?.composition) {
|
|
5407
5481
|
continue;
|
|
5408
5482
|
}
|
|
5483
|
+
validCompositionDocuments++;
|
|
5409
5484
|
const treeCount = this.removeFieldFromTree(
|
|
5410
5485
|
composition.composition,
|
|
5411
5486
|
componentType,
|
|
@@ -5433,7 +5508,7 @@ var FieldRemoverService = class {
|
|
|
5433
5508
|
instancesUpdated += totalCount;
|
|
5434
5509
|
}
|
|
5435
5510
|
}
|
|
5436
|
-
return { filesModified, instancesUpdated };
|
|
5511
|
+
return { filesModified, instancesUpdated, totalFilesMatched, validCompositionDocuments };
|
|
5437
5512
|
}
|
|
5438
5513
|
removeFieldFromTree(node, componentType, parameterIds, strict) {
|
|
5439
5514
|
let count = 0;
|
|
@@ -5459,8 +5534,8 @@ var FieldRemoverService = class {
|
|
|
5459
5534
|
}
|
|
5460
5535
|
let count = 0;
|
|
5461
5536
|
if (this.compareIds(composition.composition.type, componentType, strict)) {
|
|
5462
|
-
const
|
|
5463
|
-
const rootOverrides = composition.composition._overrides[
|
|
5537
|
+
const rootId2 = composition.composition._id;
|
|
5538
|
+
const rootOverrides = composition.composition._overrides[rootId2];
|
|
5464
5539
|
if (rootOverrides?.parameters) {
|
|
5465
5540
|
const removed = this.removeKeysFromMap(rootOverrides.parameters, parameterIds, strict);
|
|
5466
5541
|
if (removed > 0) {
|
|
@@ -5468,8 +5543,16 @@ var FieldRemoverService = class {
|
|
|
5468
5543
|
}
|
|
5469
5544
|
}
|
|
5470
5545
|
}
|
|
5546
|
+
const rootId = composition.composition._id;
|
|
5471
5547
|
count += this.removeOverridesForMatchingInstances(
|
|
5472
5548
|
composition.composition,
|
|
5549
|
+
composition.composition._overrides,
|
|
5550
|
+
componentType,
|
|
5551
|
+
parameterIds,
|
|
5552
|
+
strict,
|
|
5553
|
+
[rootId]
|
|
5554
|
+
);
|
|
5555
|
+
count += this.removeFieldFromOverrideSlotTrees(
|
|
5473
5556
|
composition.composition._overrides,
|
|
5474
5557
|
componentType,
|
|
5475
5558
|
parameterIds,
|
|
@@ -5477,27 +5560,58 @@ var FieldRemoverService = class {
|
|
|
5477
5560
|
);
|
|
5478
5561
|
return count;
|
|
5479
5562
|
}
|
|
5480
|
-
|
|
5563
|
+
/**
|
|
5564
|
+
* Walks every _overrides entry's `slots` trees (if present) and removes parameter keys from
|
|
5565
|
+
* matching component instances. Uniform often stores nested slot patches only here.
|
|
5566
|
+
*/
|
|
5567
|
+
removeFieldFromOverrideSlotTrees(overrides, componentType, parameterIds, strict) {
|
|
5568
|
+
let count = 0;
|
|
5569
|
+
for (const entry of Object.values(overrides)) {
|
|
5570
|
+
const slots = entry.slots;
|
|
5571
|
+
if (!slots) continue;
|
|
5572
|
+
for (const slotInstances of Object.values(slots)) {
|
|
5573
|
+
if (!Array.isArray(slotInstances)) continue;
|
|
5574
|
+
for (const instance of slotInstances) {
|
|
5575
|
+
count += this.removeFieldFromTree(instance, componentType, parameterIds, strict);
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
return count;
|
|
5580
|
+
}
|
|
5581
|
+
/**
|
|
5582
|
+
* Looks up override entries by compound key (ancestor _id chain joined with |) and,
|
|
5583
|
+
* for backward compatibility, by instance _id alone when it differs from the compound key.
|
|
5584
|
+
*/
|
|
5585
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict, idPath) {
|
|
5481
5586
|
let count = 0;
|
|
5482
5587
|
if (node.slots) {
|
|
5483
5588
|
for (const slotInstances of Object.values(node.slots)) {
|
|
5484
5589
|
if (!Array.isArray(slotInstances)) continue;
|
|
5485
5590
|
for (const instance of slotInstances) {
|
|
5486
5591
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
5487
|
-
const
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5592
|
+
const compoundKey = [...idPath, instance._id].join("|");
|
|
5593
|
+
const keysToTry = compoundKey === instance._id ? [compoundKey] : [compoundKey, instance._id];
|
|
5594
|
+
let removedAny = false;
|
|
5595
|
+
for (const overrideKey of keysToTry) {
|
|
5596
|
+
const instanceOverrides = overrides[overrideKey];
|
|
5597
|
+
if (instanceOverrides?.parameters) {
|
|
5598
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
5599
|
+
if (removed > 0) {
|
|
5600
|
+
removedAny = true;
|
|
5601
|
+
}
|
|
5492
5602
|
}
|
|
5493
5603
|
}
|
|
5604
|
+
if (removedAny) {
|
|
5605
|
+
count++;
|
|
5606
|
+
}
|
|
5494
5607
|
}
|
|
5495
5608
|
count += this.removeOverridesForMatchingInstances(
|
|
5496
5609
|
instance,
|
|
5497
5610
|
overrides,
|
|
5498
5611
|
componentType,
|
|
5499
5612
|
parameterIds,
|
|
5500
|
-
strict
|
|
5613
|
+
strict,
|
|
5614
|
+
[...idPath, instance._id ?? ""]
|
|
5501
5615
|
);
|
|
5502
5616
|
}
|
|
5503
5617
|
}
|
|
@@ -7773,7 +7887,7 @@ function createClearSlotCommand() {
|
|
|
7773
7887
|
// package.json
|
|
7774
7888
|
var package_default = {
|
|
7775
7889
|
name: "@uniformdev/transformer",
|
|
7776
|
-
version: "1.1.
|
|
7890
|
+
version: "1.1.53",
|
|
7777
7891
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
7778
7892
|
type: "module",
|
|
7779
7893
|
bin: {
|