@empathyco/x-adapter 8.0.0-alpha.32 → 8.0.0-alpha.34
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.
|
@@ -96,7 +96,7 @@ function interpolate(string, parameters) {
|
|
|
96
96
|
/* As the replacer function has a very dynamic signature, it is typed as a function with
|
|
97
97
|
* `any` arguments. This makes it impossible for TS to infer the correct `string`
|
|
98
98
|
* type that we are using as default values here. */
|
|
99
|
-
return value
|
|
99
|
+
return value ? `${String(head)}${String(value)}${String(tail)}` : '';
|
|
100
100
|
}));
|
|
101
101
|
}
|
|
102
102
|
exports.interpolate = interpolate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../../../src/utils/interpolate.ts"],"names":[],"mappings":";;;AAAA,gDAA0D;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,UAAU,YAAY,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,SAAgB,WAAW,CAAC,MAAc,EAAE,UAAmC;IAC7E,OAAO,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,iBAAyB,EAAE,EAAE,CAC7E,iBAAiB,CAAC,OAAO,CACvB,wBAAwB,EACxB,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,QAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,IAAA,8BAAoB,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzD;;4DAEoD;QACpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../../../src/utils/interpolate.ts"],"names":[],"mappings":";;;AAAA,gDAA0D;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,UAAU,YAAY,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,SAAgB,WAAW,CAAC,MAAc,EAAE,UAAmC;IAC7E,OAAO,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,iBAAyB,EAAE,EAAE,CAC7E,iBAAiB,CAAC,OAAO,CACvB,wBAAwB,EACxB,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,QAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,IAAA,8BAAoB,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzD;;4DAEoD;QACpD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,CAAC,CACF,CACF,CAAC;AACJ,CAAC;AAbD,kCAaC","sourcesContent":["import { getSafePropertyChain } from '@empathyco/x-utils';\n\n/**\n * Syntax to detect and extract string parameters. A string parameter contains a property name\n * with an optional header or tail to concatenate wrapped in curly braces (`{}`).\n * The different parts of a string parameter are explained in {@link STRING_PARAMETER_CONTENT}.\n *\n * @example Different string parameters\n * ```js\n * \"\\{env\\}\" // No optional head or tail.\n * \"\\{(.)env\\}\" // Optional `.` head.\n * \"\\{env(-api)\\}\" // Optional `-api` tail.\n * \"\\{(api-)env(.)\\}\" // Optional `api-` head and `.` tail.\n * ```\n * @internal\n */\nconst STRING_PARAMETERS = /{([^}]+)}/g;\n\n/**\n * Shape of the optional head and tail parts of the {@link STRING_PARAMETER_CONTENT} regex.\n * This can be anything wrapped into parentheses.\n *\n * @internal\n */\nconst HEAD_OR_TAIL = '(?:\\\\((.+)\\\\))?';\n/**\n * Syntax of a single string parameter. A string parameter shape is composed by\n * the name of the property that should be replaced. This property name can be preceded\n * or followed by an optional string to prepend or to append to the property value\n * in case it is defined.\n *\n * @example Valid string parameters content\n * ```js\n * \"env\" // No optional head or tail to concatenate.\n * \"(.)env\" // The `.` character will be prepended as long as the `env` property is defined.\n * \"env(-api)\" // The `-api` string will be appended as long as the `env` property is defined.\n * \"(api-)env(.)\" // The `api-` string and the `.` character will be added as long as\n * // the `env` property is defined.\n * ```\n * @internal\n */\nconst STRING_PARAMETER_CONTENT = new RegExp(`^${HEAD_OR_TAIL}([^(]+)${HEAD_OR_TAIL}$`, 'g');\n\n/**\n * Interpolates different parameters into a string.\n * The provided string can set the parameters to replace wrapping a parameter name in curly\n * braces. This will then be replaced by the parameter value as long as it is defined. If it\n * is not provided, the parameter name will just be removed from the final string.\n *\n * @param string - The string to interpolate different parameters in.\n * @param parameters - Value of the different parameters to interpolate.\n * @returns The interpolated string.\n * @example Different usages of the interpolate function.\n * ```js\n * interpolate('https://{env}.empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://live.empathy.co/demo'\n *\n * interpolate('https://{(api-)env}.empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api-live.empathy.co/demo'\n *\n * interpolate('https://api.{env(.)}empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api.live.empathy.co/demo'\n *\n * interpolate('https://{(api-)env(.)}empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api-live.empathy.co/demo'\n *\n * interpolate('https://{env}.empathy.co/{instance}', {\n * env: 'live'\n * }) // 'https://live.empathy.co/'\n *\n * interpolate('https://search{(api-)env}.empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://search.empathy.co/demo'\n *\n * interpolate('https://api.{env(.)}empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://api.empathy.co/demo'\n *\n * interpolate('https://search.{(api-)env(.)}empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://search.empathy.co/demo'\n * ```\n * @public\n */\nexport function interpolate(string: string, parameters: Record<string, unknown>): string {\n return string.replace(STRING_PARAMETERS, (_match, propertyToReplace: string) =>\n propertyToReplace.replace(\n STRING_PARAMETER_CONTENT,\n (_match, head = '', property: string, tail = '') => {\n const value = getSafePropertyChain(parameters, property);\n /* As the replacer function has a very dynamic signature, it is typed as a function with\n * `any` arguments. This makes it impossible for TS to infer the correct `string`\n * type that we are using as default values here. */\n return value ? `${String(head)}${String(value)}${String(tail)}` : '';\n }\n )\n );\n}\n"]}
|
|
@@ -93,7 +93,7 @@ export function interpolate(string, parameters) {
|
|
|
93
93
|
/* As the replacer function has a very dynamic signature, it is typed as a function with
|
|
94
94
|
* `any` arguments. This makes it impossible for TS to infer the correct `string`
|
|
95
95
|
* type that we are using as default values here. */
|
|
96
|
-
return value
|
|
96
|
+
return value ? `${String(head)}${String(value)}${String(tail)}` : '';
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
99
|
//# sourceMappingURL=interpolate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../../../src/utils/interpolate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC;;;;;;;;;;;;;;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,QAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzD;;4DAEoD;QACpD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,CAAC,CACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { getSafePropertyChain } from '@empathyco/x-utils';\n\n/**\n * Syntax to detect and extract string parameters. A string parameter contains a property name\n * with an optional header or tail to concatenate wrapped in curly braces (`{}`).\n * The different parts of a string parameter are explained in {@link STRING_PARAMETER_CONTENT}.\n *\n * @example Different string parameters\n * ```js\n * \"\\{env\\}\" // No optional head or tail.\n * \"\\{(.)env\\}\" // Optional `.` head.\n * \"\\{env(-api)\\}\" // Optional `-api` tail.\n * \"\\{(api-)env(.)\\}\" // Optional `api-` head and `.` tail.\n * ```\n * @internal\n */\nconst STRING_PARAMETERS = /{([^}]+)}/g;\n\n/**\n * Shape of the optional head and tail parts of the {@link STRING_PARAMETER_CONTENT} regex.\n * This can be anything wrapped into parentheses.\n *\n * @internal\n */\nconst HEAD_OR_TAIL = '(?:\\\\((.+)\\\\))?';\n/**\n * Syntax of a single string parameter. A string parameter shape is composed by\n * the name of the property that should be replaced. This property name can be preceded\n * or followed by an optional string to prepend or to append to the property value\n * in case it is defined.\n *\n * @example Valid string parameters content\n * ```js\n * \"env\" // No optional head or tail to concatenate.\n * \"(.)env\" // The `.` character will be prepended as long as the `env` property is defined.\n * \"env(-api)\" // The `-api` string will be appended as long as the `env` property is defined.\n * \"(api-)env(.)\" // The `api-` string and the `.` character will be added as long as\n * // the `env` property is defined.\n * ```\n * @internal\n */\nconst STRING_PARAMETER_CONTENT = new RegExp(`^${HEAD_OR_TAIL}([^(]+)${HEAD_OR_TAIL}$`, 'g');\n\n/**\n * Interpolates different parameters into a string.\n * The provided string can set the parameters to replace wrapping a parameter name in curly\n * braces. This will then be replaced by the parameter value as long as it is defined. If it\n * is not provided, the parameter name will just be removed from the final string.\n *\n * @param string - The string to interpolate different parameters in.\n * @param parameters - Value of the different parameters to interpolate.\n * @returns The interpolated string.\n * @example Different usages of the interpolate function.\n * ```js\n * interpolate('https://{env}.empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://live.empathy.co/demo'\n *\n * interpolate('https://{(api-)env}.empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api-live.empathy.co/demo'\n *\n * interpolate('https://api.{env(.)}empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api.live.empathy.co/demo'\n *\n * interpolate('https://{(api-)env(.)}empathy.co/{instance}', {\n * env: 'live',\n * instance: 'demo'\n * }) // 'https://api-live.empathy.co/demo'\n *\n * interpolate('https://{env}.empathy.co/{instance}', {\n * env: 'live'\n * }) // 'https://live.empathy.co/'\n *\n * interpolate('https://search{(api-)env}.empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://search.empathy.co/demo'\n *\n * interpolate('https://api.{env(.)}empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://api.empathy.co/demo'\n *\n * interpolate('https://search.{(api-)env(.)}empathy.co/{instance}', {\n * instance: 'demo'\n * }) // 'https://search.empathy.co/demo'\n * ```\n * @public\n */\nexport function interpolate(string: string, parameters: Record<string, unknown>): string {\n return string.replace(STRING_PARAMETERS, (_match, propertyToReplace: string) =>\n propertyToReplace.replace(\n STRING_PARAMETER_CONTENT,\n (_match, head = '', property: string, tail = '') => {\n const value = getSafePropertyChain(parameters, property);\n /* As the replacer function has a very dynamic signature, it is typed as a function with\n * `any` arguments. This makes it impossible for TS to infer the correct `string`\n * type that we are using as default values here. */\n return value ? `${String(head)}${String(value)}${String(tail)}` : '';\n }\n )\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-adapter",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.34",
|
|
4
4
|
"description": "A utils library to create a client for any API",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"prepublishOnly": "pnpm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@empathyco/x-deep-merge": "^2.0.0-alpha.
|
|
41
|
-
"@empathyco/x-utils": "^1.0.0-alpha.
|
|
40
|
+
"@empathyco/x-deep-merge": "^2.0.0-alpha.3",
|
|
41
|
+
"@empathyco/x-utils": "^1.0.0-alpha.23",
|
|
42
42
|
"tslib": "~2.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "bcf6d3e516bd903c85c47423926bc477dec852c6"
|
|
56
56
|
}
|