object-rewrite
Advanced tools
Comparing version 4.4.1 to 5.0.0
@@ -16,2 +16,3 @@ "use strict"; | ||
Joi.assert(options, Joi.object({ | ||
name: Joi.string(), | ||
target: Joi.string(), | ||
@@ -27,2 +28,3 @@ // target can not be "", use "*" instead | ||
const { | ||
name, | ||
target, | ||
@@ -57,2 +59,3 @@ requires, | ||
self, | ||
name, | ||
prefix, | ||
@@ -78,20 +81,22 @@ targetNormalized: targetAbs.endsWith('.') ? targetAbs.slice(0, -1) : targetAbs, | ||
self.init = (context, logger) => { | ||
if (contextSchema !== undefined && validationCompile(contextSchema, false)(context) === false) { | ||
logger.warn(`Context validation failure\n${JSON.stringify({ | ||
origin: 'object-rewrite', | ||
options | ||
})}`); | ||
return false; | ||
self.meta = { | ||
name, | ||
init: (context, logger) => { | ||
if (contextSchema !== undefined && validationCompile(contextSchema, false)(context) === false) { | ||
logger.warn(`Context validation failure\n${JSON.stringify({ | ||
origin: 'object-rewrite', | ||
options | ||
})}`); | ||
return false; | ||
} | ||
localCache = {}; | ||
localContext = contextSchema instanceof Object && !Array.isArray(contextSchema) ? Object.keys(contextSchema).reduce((p, k) => { | ||
// eslint-disable-next-line no-param-reassign | ||
p[k] = context[k]; | ||
return p; | ||
}, {}) : context; | ||
return init === undefined ? true : wrap(init)(); | ||
} | ||
localCache = {}; | ||
localContext = contextSchema instanceof Object && !Array.isArray(contextSchema) ? Object.keys(contextSchema).reduce((p, k) => { | ||
// eslint-disable-next-line no-param-reassign | ||
p[k] = context[k]; | ||
return p; | ||
}, {}) : context; | ||
return init === undefined ? true : wrap(init)(); | ||
}; | ||
return self; | ||
@@ -98,0 +103,0 @@ }; |
@@ -20,4 +20,12 @@ "use strict"; | ||
assert(Array.isArray(dataStoreFields_) && dataStoreFields_.every(e => typeof e === 'string')); | ||
const pluginNames = {}; | ||
const plugins = Object.entries(pluginMap).reduce((prev, [prefix, ps]) => { | ||
ps.forEach(p => prev.push(p(prefix))); | ||
ps.forEach(p => { | ||
if (p.meta.name in pluginNames && p !== pluginNames[p.meta.name]) { | ||
throw new Error(`Plugin name "${p.meta.name}" not unique`); | ||
} | ||
pluginNames[p.meta.name] = p; | ||
prev.push(p(prefix)); | ||
}); | ||
return prev; | ||
@@ -43,3 +51,4 @@ }, []); | ||
sortMap, | ||
fieldsToRequest | ||
fieldsToRequest, | ||
activePlugins | ||
} = compileMeta(plugins, fields); | ||
@@ -80,2 +89,3 @@ | ||
fieldsToRequest, | ||
activePlugins, | ||
rewrite: (input, context = {}) => { | ||
@@ -82,0 +92,0 @@ const promises = rewriteStart(input, context); |
@@ -12,2 +12,3 @@ "use strict"; | ||
}; | ||
const activePlugins = new Set(); | ||
const inactivePlugins = [...plugins]; | ||
@@ -22,2 +23,3 @@ const requiredFields = new Set(fields); | ||
pluginsByType[plugin.type].push(plugin); | ||
activePlugins.add(plugin.name); | ||
inactivePlugins.splice(j, 1); | ||
@@ -36,4 +38,5 @@ j -= 1; | ||
sortMap: compileTargetMap('SORT', pluginsByType.SORT), | ||
fieldsToRequest: [...requiredFields].filter(e => !injectedFields.has(e)) | ||
fieldsToRequest: [...requiredFields].filter(e => !injectedFields.has(e)), | ||
activePlugins: [...activePlugins] | ||
}; | ||
}; |
@@ -9,3 +9,3 @@ "use strict"; | ||
if (!plugins.has(pl.self)) { | ||
plugins.set(pl.self, pl.self.init(context, logger)); | ||
plugins.set(pl.self, pl.self.meta.init(context, logger)); | ||
} | ||
@@ -12,0 +12,0 @@ |
{ | ||
"name": "object-rewrite", | ||
"version": "4.4.1", | ||
"version": "5.0.0", | ||
"description": "Rewrite Object(s) in place using plugins.", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"object-fields": "2.0.20", | ||
"object-scan": "13.7.1" | ||
"object-scan": "13.8.0" | ||
}, | ||
@@ -20,9 +20,9 @@ "devDependencies": { | ||
"@babel/register": "7.12.10", | ||
"@blackflux/eslint-plugin-rules": "1.3.44", | ||
"@blackflux/robo-config-plugin": "3.10.17", | ||
"@blackflux/eslint-plugin-rules": "1.3.45", | ||
"@blackflux/robo-config-plugin": "4.0.4", | ||
"babel-eslint": "10.1.0", | ||
"babel-preset-latest-node": "5.2.0", | ||
"babel-preset-latest-node": "5.4.0", | ||
"chai": "4.2.0", | ||
"coveralls": "3.1.0", | ||
"eslint": "7.17.0", | ||
"eslint": "7.18.0", | ||
"eslint-config-airbnb-base": "14.2.1", | ||
@@ -36,3 +36,3 @@ "eslint-plugin-import": "2.22.1", | ||
"nyc": "15.1.0", | ||
"semantic-release": "17.3.1" | ||
"semantic-release": "17.3.7" | ||
}, | ||
@@ -39,0 +39,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24496
436
+ Addedobject-scan@13.8.0(transitive)
Updatedobject-scan@13.8.0