Allow value to be non-string

Signed-off-by: Taras <tarasm@gmail.com>
This commit is contained in:
Taras
2022-09-15 09:23:07 -04:00
parent b6de0abf85
commit f2f2df9a73
2 changed files with 10 additions and 7 deletions
@@ -396,7 +396,6 @@ describe('PlaceholderProcessor', () => {
const processor = new PlaceholderProcessor({
resolvers: {
merge: async ({ value }) => {
console.log({ value });
if (value instanceof Object) {
return { merged: 'value', ...value };
}
@@ -111,15 +111,19 @@ export class PlaceholderProcessor implements CatalogProcessor {
const resolverValue = data[keys[0]];
const resolver = this.options.resolvers[resolverKey];
if (!resolver || typeof resolverValue !== 'string') {
// If there was no such placeholder resolver or if the value was not a
// string, we err on the side of safety and assume that this is
// something that's best left alone. For example, if the input contains
// JSONSchema, there may be "$ref": "#/definitions/node" nodes in the
// document.
if (!resolver) {
// If there was no such placeholder resolver, we err on the side of safety
// and assume that this is something that's best left alone. For example, if
// the input contains JSONSchema, there may be "$ref": "#/definitions/node"
// nodes in the document.
return [data, false];
}
// if (typeof resolverValue !== 'string') {
// treat it as an argument to resolver function
// TODO: make this recursive, but it should resolve from bottom up
// }
const read = async (url: string): Promise<Buffer> => {
if (this.options.reader.readUrl) {
const response = await this.options.reader.readUrl(url);