<commit_before>(function($) {

	var baseUrl = '/api';

	function config(callback) {
		var c = {
			baseUrl : function(url) {
				baseUrl = url;
			}
		};

		callback(c);
	}

	function defaultAjax(type, options) {
		var request = $.ajax({
			type : type,
			url : baseUrl + options.url,
			data : options.data,
			async : options.async,
			contentType : 'application/json;charset=UTF-8',
			dataType : 'json'
		});

		return request;
	}

	function extractId(object) {
		if (object.id) {
			return object.id;
		}
		throw 'use yawp(id) if your endpoint does not have a @Id field called id';
	}

	function query(options) {
		var q = {};

		function where(data) {
			q.where = data;
			return this;
		}

		function order(data) {
			q.order = data;
			return this;
		}

		function sort(data) {
			q.sort = data;
			return this;
		}

		function limit(data) {
			q.limit = data;
			return this;
		}

		function addQueryParameter(key, value) {
			var _options = options();
			if (!_options.data) {
				_options.data = {};
			}
			_options.data[key] = value;
		}

		function transform(t) {
			addQueryParameter('t', t);
			return this;
		}

		function fetch(callback) {
			return defaultAjax('GET', options()).done(callback);
		}

		function list(callback) {
			if (Object.keys(q).length > 0) {
				addQueryParameter('q', JSON.stringify(q));
			}

			return defaultAjax('GET', options()).done(callback);
		}

		function first(callback) {
			limit(1);

			return list(function(objects) {
				var object = objects.length == 0 ? null : objects[0];
				if (callback) {
					callback(object);
				}
			});
		}

		function only(callback) {
			return list(function(objects) {
				if (objects.length != 1) {
					throw 'called only but got ' + objects.length + ' results';
				}
				if (callback) {
					callback(objects[0]);
				}
			});
		}

		return {
			transform : transform,
			where : where,
			order : order,
			sort : sort,
			limit : limit,
			fetch : fetch,
			list : list,
			first : first,
			only : only
		};
	}

	function repository(options) {
		function create(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('POST', options());
		}

		function update(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('PUT', options());
		}

		function destroy(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('DELETE', options());
		}

		return {
			create : create,
			update : update,
			destroy : destroy
		};
	}

	function actions(options) {
		function actionOptions(action) {
			options().url += '/' + action;
			return options();
		}

		function get(action) {
			return defaultAjax('GET', actionOptions(action));
		}

		function put(action) {
			return defaultAjax('PUT', actionOptions(action));
		}

		function post(action) {
			return defaultAjax('POST', actionOptions(action));
		}

		function _delete(action) {
			return defaultAjax('DELETE', actionOptions(action));
		}

		return {
			get : get,
			put : put,
			post : post,
			_delete : _delete
		};
	}

	function yawp(baseArg) {
		function normalize(arg) {
			if (!arg) {
				return '';
			}
			if (arg instanceof Object) {
				return extractId(arg);
			}
			return arg;
		}

		var base = normalize(baseArg);

		var globalOptions = {
			url : base
		}

		function options() {
			return globalOptions;
		}

		function from(parentBaseArg) {
			var parentBase = normalize(parentBaseArg);
			return yawp(parentBase + base);
		}

		return $.extend({
			from : from
		}, query(options), repository(options), actions(options));
	}

	function update(object) {
		var id = extractId(object);
		return yawp(id).update(object);
	}

	function destroy(object) {
		var id = extractId(object);
		return yawp(id).destroy(object);
	}

	var api = {
		config : config,
		update : update,
		destroy : destroy
	};<commit_msg>transform on create/update<commit_after>(function($) {

	var baseUrl = '/api';

	function config(callback) {
		var c = {
			baseUrl : function(url) {
				baseUrl = url;
			}
		};

		callback(c);
	}

	function defaultAjax(type, options) {
		var request = $.ajax({
			type : type,
			url : baseUrl + options.url,
			data : options.data,
			async : options.async,
			contentType : 'application/json;charset=UTF-8',
			dataType : 'json'
		});

		return request;
	}

	function extractId(object) {
		if (object.id) {
			return object.id;
		}
		throw 'use yawp(id) if your endpoint does not have a @Id field called id';
	}

	function query(options) {
		var q = {};

		function where(data) {
			q.where = data;
			return this;
		}

		function order(data) {
			q.order = data;
			return this;
		}

		function sort(data) {
			q.sort = data;
			return this;
		}

		function limit(data) {
			q.limit = data;
			return this;
		}

		function addQueryParameter(key, value) {
			var _options = options();
			if (!_options.data) {
				_options.data = {};
			}
			_options.data[key] = value;
		}

		function transform(t) {
			addQueryParameter('t', t);
			return this;
		}

		function fetch(callback) {
			return defaultAjax('GET', options()).done(callback);
		}

		function list(callback) {
			if (Object.keys(q).length > 0) {
				addQueryParameter('q', JSON.stringify(q));
			}

			return defaultAjax('GET', options()).done(callback);
		}

		function first(callback) {
			limit(1);

			return list(function(objects) {
				var object = objects.length == 0 ? null : objects[0];
				if (callback) {
					callback(object);
				}
			});
		}

		function only(callback) {
			return list(function(objects) {
				if (objects.length != 1) {
					throw 'called only but got ' + objects.length + ' results';
				}
				if (callback) {
					callback(objects[0]);
				}
			});
		}

		return {
			transform : transform,
			where : where,
			order : order,
			sort : sort,
			limit : limit,
			fetch : fetch,
			list : list,
			first : first,
			only : only
		};
	}

	function repository(options) {
		function create(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('POST', options());
		}

		function update(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('PUT', options());
		}

		function destroy(object) {
			options().data = JSON.stringify(object);
			return defaultAjax('DELETE', options());
		}

		return {
			create : create,
			update : update,
			destroy : destroy
		};
	}

	function actions(options) {
		function actionOptions(action) {
			options().url += '/' + action;
			return options();
		}

		function get(action) {
			return defaultAjax('GET', actionOptions(action));
		}

		function put(action) {
			return defaultAjax('PUT', actionOptions(action));
		}

		function post(action) {
			return defaultAjax('POST', actionOptions(action));
		}

		function _delete(action) {
			return defaultAjax('DELETE', actionOptions(action));
		}

		return {
			get : get,
			put : put,
			post : post,
			_delete : _delete
		};
	}

	function yawp(baseArg) {
		function normalize(arg) {
			if (!arg) {
				return '';
			}
			if (arg instanceof Object) {
				return extractId(arg);
			}
			return arg;
		}

		var globalOptions = {
			url : normalize(baseArg)
		// query : {}
		}

		function options() {
			return globalOptions;
		}

		function addQueryParameter(key, value) {
			if (!globalOptions[key]) {
				globalOptions[key] = value;
			}
		}

		function from(parentBaseArg) {
			var parentBase = normalize(parentBaseArg);
			options().url = parentBase + options().url;
			return this;
		}

		return $.extend({
			from : from
		}, query(options), repository(options), actions(options));
	}

	function update(object) {
		var id = extractId(object);
		return yawp(id).update(object);
	}

	function destroy(object) {
		var id = extractId(object);
		return yawp(id).destroy(object);
	}

	var api = {
		config : config,
		update : update,
		destroy : destroy
	};
{'fraction_non_alphanumeric': 0.1435884310212439, 'fraction_numerical': 0.0017916560020476069, 'mean_word_length': 2.967005076142132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1045825', 'n_tokens_mistral': 3178, 'n_tokens_neox': 2558, 'n_words': 597}