configorama 0.6.16 → 0.6.18
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/package.json +1 -1
- package/src/index.js +14 -0
- package/src/main.js +13 -7
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -42,6 +42,20 @@ module.exports = async (configPathOrObject, settings = {}) => {
|
|
|
42
42
|
instance.variableTypes
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
+
// Collect custom metadata from variable sources that have collectMetadata
|
|
46
|
+
if (settings.variableSources && Array.isArray(settings.variableSources)) {
|
|
47
|
+
for (const source of settings.variableSources) {
|
|
48
|
+
if (typeof source.collectMetadata === 'function') {
|
|
49
|
+
const customData = source.collectMetadata()
|
|
50
|
+
if (customData !== undefined && customData !== null) {
|
|
51
|
+
// Use source.metadataKey if specified, otherwise default to `${type}References`
|
|
52
|
+
const metadataKey = source.metadataKey || `${source.type}References`
|
|
53
|
+
enrichedMetadata[metadataKey] = customData
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
return {
|
|
46
60
|
variableSyntax: instance.variableSyntax,
|
|
47
61
|
variableTypes: instance.variableTypes,
|
package/src/main.js
CHANGED
|
@@ -2566,7 +2566,6 @@ Missing Value ${missingValue} - ${matchedString}
|
|
|
2566
2566
|
|
|
2567
2567
|
// console.log('variableValues', variableValues)
|
|
2568
2568
|
return Promise.all(variableValues).then((values) => {
|
|
2569
|
-
let deepPropertyStr = propertyString
|
|
2570
2569
|
let deepProperties = 0
|
|
2571
2570
|
// console.log('overwrite values', valuesToUse)
|
|
2572
2571
|
// Extract actual values from metadata objects
|
|
@@ -2576,6 +2575,10 @@ Missing Value ${missingValue} - ${matchedString}
|
|
|
2576
2575
|
}
|
|
2577
2576
|
return value
|
|
2578
2577
|
})
|
|
2578
|
+
|
|
2579
|
+
// Build deep variable parts for reconstruction
|
|
2580
|
+
const deepVariableParts = variableStrings.slice()
|
|
2581
|
+
|
|
2579
2582
|
extractedValues.forEach((value, index) => {
|
|
2580
2583
|
// console.log('───────────────────────────────> value', value)
|
|
2581
2584
|
if (isString(value) && value.match(this.variableSyntax)) {
|
|
@@ -2585,14 +2588,17 @@ Missing Value ${missingValue} - ${matchedString}
|
|
|
2585
2588
|
// console.log('deepVariable', deepVariable)
|
|
2586
2589
|
const newValue = cleanVariable(deepVariable, this.variableSyntax, true, `overwrite ${this.callCount}`)
|
|
2587
2590
|
// console.log(`overwrite newValue ${variableStrings[index]}`, newValue)
|
|
2588
|
-
//
|
|
2589
|
-
|
|
2590
|
-
// console.log('deepPropertyString', deepPropertyStr)
|
|
2591
|
+
// Store the deep ref for this part
|
|
2592
|
+
deepVariableParts[index] = newValue
|
|
2591
2593
|
}
|
|
2592
2594
|
})
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2595
|
+
|
|
2596
|
+
if (deepProperties > 0) {
|
|
2597
|
+
// Reconstruct a minimal variable string with deep refs, not the full outer string
|
|
2598
|
+
const reconstructed = '${' + deepVariableParts.join(', ') + '}'
|
|
2599
|
+
return Promise.resolve(reconstructed)
|
|
2600
|
+
}
|
|
2601
|
+
return Promise.resolve(extractedValues.find(isValidValue)) // resolve first valid value, else undefined
|
|
2596
2602
|
})
|
|
2597
2603
|
}
|
|
2598
2604
|
|