Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (typeName, options, store) {
this.typeName = typeName
this.options = options || {}
this._store = store
this._transformers = store._transformers
this._events = new EventEmitter()
this._collection = new Collection(typeName, {
indices: ['id', 'path', 'internal.typeName'],
unique: ['id', 'path'],
disableMeta: true
})
this._refs = mapValues(options.refs, (ref, key) => ({
typeName: ref.typeName || options.typeName,
fieldName: key
}))
this._mimeTypes = {}
this._fields = options.fields || {}
this._dateField = options.dateField || 'date'
this._defaultSortBy = this._dateField
this._defaultSortOrder = 'DESC'
createPage: new SyncWaterfallHook(['options']),
pageContext: new SyncWaterfallHook(['context', 'data'])
}
this._componentCache = new LRU({ max: 100 })
this._queryCache = new LRU({ max: 100 })
this._watched = new Map()
this._watcher = null
this._routes = new Collection('routes', {
indices: ['id'],
unique: ['id', 'path', 'internal.priority'],
disableMeta: true
})
this._pages = new Collection('pages', {
indices: ['id'],
unique: ['id', 'path'],
disableMeta: true
})
if (isDev) {
this._watcher = new FSWatcher({
disableGlobbing: true
})
initWatcher(app, this)
}
}
constructor (app) {
this.app = app
this.collections = {}
this.nodeIndex = new NodeIndex(app)
this._events = new EventEmitter()
this.lastUpdate = null
this.setUpdateTime()
autoBind(this)
this.metadata = new Loki.Collection('core/metadata', {
unique: ['key'],
autoupdate: true
})
this.hooks = {
addCollection: new SyncWaterfallHook(['options']),
addNode: new SyncBailWaterfallHook(['options', 'collection'])
}
this.hooks.addNode.tap('TransformNodeContent', require('./transformNodeContent'))
this.hooks.addNode.tap('ProcessNodeFields', require('./processNodeFields'))
}
constructor (app) {
this.app = app
this.hooks = {
addEntry: new SyncWaterfallHook(['entry', 'node', 'collection'])
}
this.hooks.addEntry.tap('BelongsToProcessor', require('./processNodeReferences'))
this.index = new Collection('NodeIndex', {
indices: ['typeName', 'id'],
unique: ['uid'],
disableMeta: true
})
}
constructor (app) {
this.app = app
this.hooks = {
parseComponent: new HookMap(() => new SyncBailHook(['source', 'resource'])),
createRoute: new SyncWaterfallHook(['options']),
createPage: new SyncWaterfallHook(['options']),
pageContext: new SyncWaterfallHook(['context', 'data'])
}
this._componentCache = new LRU({ max: 100 })
this._queryCache = new LRU({ max: 100 })
this._watched = new Map()
this._watcher = null
this._routes = new Collection('routes', {
indices: ['id'],
unique: ['id', 'path', 'internal.priority'],
disableMeta: true
})
this._pages = new Collection('pages', {
indices: ['id'],
unique: ['id', 'path'],
disableMeta: true
})
if (isDev) {
this._watcher = new FSWatcher({
disableGlobbing: true
})