Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _useOne (extension) {
try {
extension.options = extend(
true,
{},
extension.options || {},
extension.name != null ? reporter.options.extensions[camelCase(extension.name)] : {},
extension.name != null ? reporter.options.extensions[extension.name] : {}
)
// we need to check for string "false" to support disabling extension by env or CLI args
// since this option does not coerce by schema validation at this point but later
if (extension.options.enabled === 'false' || extension.options.enabled === '0') {
extension.options.enabled = false
}
if (extension.options.enabled === false) {
if (!extension.name) {
reporter.logger.debug(`Anonymous Extension${extension.directory != null ? ` at ${extension.directory}` : ''} is disabled, skipping`)
nfn.file({file: path.join(rootDirectory, 'jsreport.config.json')})
if (nfn.get('rootDirectory') != null) {
rootDirectory = nfn.get('rootDirectory')
}
if (nfn.get('mode') != null) {
mode = nfn.get('mode')
}
}
}
}
// we pass a copy of defaults to avoid loosing the original
// object values
nfn.defaults({ store: extend(true, {}, this.defaults) })
this.options = nconfInstance.get()
this.options.rootDirectory = rootDirectory
this.options.mode = mode
}
toUpdate.forEach((d) => {
if (opts.transaction) {
d.$transaction = d.$transaction || { active: {} }
d.$transaction.active[opts.transaction.id] = d.$transaction.active[opts.transaction.id] || {}
d.$transaction.active[opts.transaction.id].updatedDoc = omit(extend(true, {}, d, u.$set), '$transaction')
d.$transaction.active[opts.transaction.id].state = 'update'
} else {
Object.assign(d, u.$set || {})
}
})
}
module.exports = (obj, parent) => {
const request = Object.create({}, {
__isJsreportRequest__: {
value: true,
writable: false,
configurable: false,
enumerable: false
}})
request.template = extend(true, {}, obj.template)
if (parent) {
request.context = Object.assign({}, request.context, omit(parent.context, 'logs'))
request.context.isChildRequest = true
request.options = Object.assign({}, request.options, parent.options)
if (parent.data) {
const dataInput = normalizeJSONData(parent.data)
request.data = Object.assign(Array.isArray(dataInput) ? [] : {}, dataInput)
}
}
request.options = extend(true, {}, request.options, obj.options)
request.context = extend(true, {}, request.context, obj.context)
if (obj.data) {
cursor.toArray = () => cursor.all().map((e) => omit(extend(true, {}, e), '$transaction'))
return cursor
function extendDefaults (config) {
return extend(true, renderDefaults, config)
}
set: (obj, prop, value, receiver) => {
let newValue
if (prop === 'options') {
const newData = extend(true, {}, value)
const result = reporter.optionsValidator.validate(extension.name, newData, { rootPrefix: 'options' })
if (!result.valid) {
throw new Error(formatExtensionOptionsError(extension.name, result.fullErrorMessage))
}
newValue = newData
} else {
newValue = value
}
return Reflect.set(obj, prop, newValue, receiver)
}
})
module.exports = function (reporter, definition) {
definition.options = extend(true, { preview: {} }, reporter.options.xlsx, reporter.options.office, definition.options)
if (reporter.options.office) {
Object.assign(definition.options, reporter.options.office)
}
if (definition.options.previewInExcelOnline != null) {
definition.options.preview.enabled = definition.options.previewInExcelOnline
}
if (definition.options.showExcelOnlineWarning != null) {
definition.options.preview.showWarning = definition.options.showExcelOnlineWarning
}
if (definition.options.publicUriForPreview != null) {
definition.options.preview.publicUri = definition.options.publicUriForPreview
}
module.exports = (reporter, definition) => {
if (reporter.options.xlsx) {
reporter.logger.warn('xlsx root configuration property is deprecated. Use office property instead')
}
definition.options = extend(true, { preview: {} }, reporter.options.xlsx, reporter.options.office, definition.options)
reporter.options.xlsx = definition.options
if (definition.options.previewInExcelOnline != null) {
reporter.logger.warn('extensions.xlsx.previewInExcelOnline configuration property is deprecated. Use office.preview.enabled=false instead')
definition.options.preview.enabled = definition.options.previewInExcelOnline
}
if (definition.options.showExcelOnlineWarning != null) {
reporter.logger.warn('extensions.xlsx.showExcelOnlineWarning configuration property is deprecated. Use office.preview.showWarning=false instead')
definition.options.preview.showWarning = definition.options.showExcelOnlineWarning
}
if (definition.options.publicUriForPreview != null) {
reporter.logger.warn('extensions.xlsx.publicUriForPreview configuration property is deprecated. Use office.preview.publicUri=https://... instead')
definition.options.preview.publicUri = definition.options.publicUriForPreview
}
insert (entitySet, doc, opts = {}) {
doc._id = doc._id || uid(16)
const newDoc = extend(true, {}, doc)
if (opts.transaction) {
newDoc.$transaction = {
ownerId: opts.transaction.id,
active: {
[opts.transaction.id]: {
state: 'insert'
}
}
}
}
this.documents[entitySet].push(newDoc)
return doc
},