@graphql-mesh/string-interpolation 0.5.9-alpha-20250918125912-b91c179ec9b445887a142227d8886304430f63f0 → 0.5.10
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/cjs/interpolator.js +11 -1
- package/esm/interpolator.js +11 -1
- package/package.json +2 -2
package/cjs/interpolator.js
CHANGED
|
@@ -100,7 +100,17 @@ class Interpolator {
|
|
|
100
100
|
applyRule(str, rule, data = {}) {
|
|
101
101
|
const dataToReplace = this.applyData(rule.key, data);
|
|
102
102
|
if (dataToReplace !== undefined) {
|
|
103
|
-
|
|
103
|
+
const modifiedData = this.applyModifiers(rule.modifiers, dataToReplace, data);
|
|
104
|
+
// If the entire string is just the placeholder and the replacement is an object,
|
|
105
|
+
// return the object directly instead of converting to "[object Object]"
|
|
106
|
+
if (str === rule.replace && typeof modifiedData === 'object' && modifiedData !== null) {
|
|
107
|
+
return modifiedData;
|
|
108
|
+
}
|
|
109
|
+
// For objects embedded in a larger string, JSON stringify them
|
|
110
|
+
if (typeof modifiedData === 'object' && modifiedData !== null) {
|
|
111
|
+
return str.replace(rule.replace, JSON.stringify(modifiedData));
|
|
112
|
+
}
|
|
113
|
+
return str.replace(rule.replace, modifiedData);
|
|
104
114
|
}
|
|
105
115
|
else if (rule.alternativeText) {
|
|
106
116
|
return str.replace(rule.replace, this.applyModifiers(rule.modifiers, rule.alternativeText, data));
|
package/esm/interpolator.js
CHANGED
|
@@ -96,7 +96,17 @@ export class Interpolator {
|
|
|
96
96
|
applyRule(str, rule, data = {}) {
|
|
97
97
|
const dataToReplace = this.applyData(rule.key, data);
|
|
98
98
|
if (dataToReplace !== undefined) {
|
|
99
|
-
|
|
99
|
+
const modifiedData = this.applyModifiers(rule.modifiers, dataToReplace, data);
|
|
100
|
+
// If the entire string is just the placeholder and the replacement is an object,
|
|
101
|
+
// return the object directly instead of converting to "[object Object]"
|
|
102
|
+
if (str === rule.replace && typeof modifiedData === 'object' && modifiedData !== null) {
|
|
103
|
+
return modifiedData;
|
|
104
|
+
}
|
|
105
|
+
// For objects embedded in a larger string, JSON stringify them
|
|
106
|
+
if (typeof modifiedData === 'object' && modifiedData !== null) {
|
|
107
|
+
return str.replace(rule.replace, JSON.stringify(modifiedData));
|
|
108
|
+
}
|
|
109
|
+
return str.replace(rule.replace, modifiedData);
|
|
100
110
|
}
|
|
101
111
|
else if (rule.alternativeText) {
|
|
102
112
|
return str.replace(rule.replace, this.applyModifiers(rule.modifiers, rule.alternativeText, data));
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/string-interpolation",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"description": "Dynamic string manipulation",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "*"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"dayjs": "1.11.
|
|
10
|
+
"dayjs": "1.11.19",
|
|
11
11
|
"json-pointer": "0.6.2",
|
|
12
12
|
"lodash.get": "4.4.2",
|
|
13
13
|
"tslib": "^2.4.0"
|