<commit_before>var _ = require('lodash');
var azure = require('azure');
var FieldType = require('../Type');
var grappling = require('grappling-hook');
var keystone = require('../../../');
var util = require('util');
var utils = require('keystone-utils');

/**
 * AzureFile FieldType Constructor
 * @extends Field
 * @api public
 */
function azurefile (list, path, options) {
	grappling.mixin(this).allowHooks('pre:upload');

	this._underscoreMethods = ['format', 'uploadFile'];
	this._fixedSize = 'full';

	// TODO: implement filtering, usage disabled for now
	options.nofilter = true;

	// TODO: implement initial form, usage disabled for now
	if (options.initial) {
		throw new Error('Invalid Configuration\n\nAzureFile fields (' + list.key + '.' + path + ') do not currently support being used as initial fields.\n');
	}

	azurefile.super_.call(this, list, path, options);

	// validate azurefile config (has to happen after super_.call)
	if (!this.azurefileconfig) {
		throw new Error('Invalid Configuration\n\n'
			+ 'AzureFile fields (' + list.key + '.' + path + ') require the "azurefile config" option to be set.\n\n'
			+ 'See http://keystonejs.com/docs/configuration/#services-azure for more information.\n');
	}

	// TODO; this is really bad, we shouldn't be overwriting global env!
	process.env.AZURE_STORAGE_ACCOUNT = this.azurefileconfig.account;
	process.env.AZURE_STORAGE_ACCESS_KEY = this.azurefileconfig.key;

	this.azurefileconfig.container = this.azurefileconfig.container || 'keystone';

	var self = this;
	options.filenameFormatter = options.filenameFormatter || function (item, filename) { return filename; };
	options.containerFormatter = options.containerFormatter || function (item, filename) { return self.azurefileconfig.container; };// eslint-disable-line no-unused-vars

	// Could be more pre- hooks, just upload for now
	if (options.pre && options.pre.upload) {
		this.pre('upload', options.pre.upload);
	}

}
util.inherits(azurefile, FieldType);

/**
 * Exposes the custom or keystone s3 config settings
 */
Object.defineProperty(azurefile.prototype, 'azurefileconfig', {
	get: function () {
		return this.options.azurefileconfig || keystone.get('azurefile config');
	},
});

/**
 * Registers the field on the List's Mongoose Schema.
 */
azurefile.prototype.addToSchema = function () {<commit_msg>setting AzureFileType options before calling super_.call()<commit_after>var _ = require('lodash');
var azure = require('azure');
var FieldType = require('../Type');
var grappling = require('grappling-hook');
var keystone = require('../../../');
var util = require('util');
var utils = require('keystone-utils');

/**
 * AzureFile FieldType Constructor
 * @extends Field
 * @api public
 */
function azurefile (list, path, options) {
	grappling.mixin(this).allowHooks('pre:upload');

	this._underscoreMethods = ['format', 'uploadFile'];
	this._fixedSize = 'full';

	// TODO: implement filtering, usage disabled for now
	options.nofilter = true;

	// TODO: implement initial form, usage disabled for now
	if (options.initial) {
		throw new Error('Invalid Configuration\n\nAzureFile fields (' + list.key + '.' + path + ') do not currently support being used as initial fields.\n');
	}

	var self = this;
	options.filenameFormatter = options.filenameFormatter || function (item, filename) { return filename; };
	options.containerFormatter = options.containerFormatter || function (item, filename) { return self.azurefileconfig.container; };// eslint-disable-line no-unused-vars

	azurefile.super_.call(this, list, path, options);

	// validate azurefile config (has to happen after super_.call)
	if (!this.azurefileconfig) {
		throw new Error('Invalid Configuration\n\n'
			+ 'AzureFile fields (' + list.key + '.' + path + ') require the "azurefile config" option to be set.\n\n'
			+ 'See http://keystonejs.com/docs/configuration/#services-azure for more information.\n');
	}

	// TODO; this is really bad, we shouldn't be overwriting global env!
	process.env.AZURE_STORAGE_ACCOUNT = this.azurefileconfig.account;
	process.env.AZURE_STORAGE_ACCESS_KEY = this.azurefileconfig.key;

	this.azurefileconfig.container = this.azurefileconfig.container || 'keystone';

	// Could be more pre- hooks, just upload for now
	if (options.pre && options.pre.upload) {
		this.pre('upload', options.pre.upload);
	}

}
util.inherits(azurefile, FieldType);

/**
 * Exposes the custom or keystone s3 config settings
 */
Object.defineProperty(azurefile.prototype, 'azurefileconfig', {
	get: function () {
		return this.options.azurefileconfig || keystone.get('azurefile config');
	},
});

/**
 * Registers the field on the List's Mongoose Schema.
 */
azurefile.prototype.addToSchema = function () {
{'fraction_non_alphanumeric': 0.14224962789708698, 'fraction_numerical': 0.00042526047203912394, 'mean_word_length': 4.540636042402827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1773484', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1389, 'n_words': 379}