ravendb
Version:
RavenDB client for Node.js
35 lines • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseJavaScriptIndexCreationTask = void 0;
const AbstractGenericIndexCreationTask_js_1 = require("./AbstractGenericIndexCreationTask.js");
const IndexDefinitionHelper_js_1 = require("./IndexDefinitionHelper.js");
const TypeUtil_js_1 = require("../../Utility/TypeUtil.js");
class BaseJavaScriptIndexCreationTask extends AbstractGenericIndexCreationTask_js_1.AbstractGenericIndexCreationTask {
_registeredEnums = [];
/**
* This extension point to tweak strongly typed index definitions
* @param definition original index definition
* @param origin origin of definition: map or reduce
* @protected
*/
postProcessDefinition(definition, origin) {
if (this._registeredEnums.length) {
for (const transformation of this._registeredEnums) {
const actualValue = transformation.actualValue;
const escapedValue = TypeUtil_js_1.TypeUtil.isNumber(actualValue) ? actualValue.toString() : '"' + actualValue + '"';
definition = definition.replace(transformation.sourceCode, escapedValue);
}
}
return definition;
}
registerEnum(provider) {
const value = provider();
const functionBody = provider.toString();
this._registeredEnums.push({
sourceCode: IndexDefinitionHelper_js_1.IndexDefinitionHelper.extractEnumNotation(functionBody),
actualValue: value
});
}
}
exports.BaseJavaScriptIndexCreationTask = BaseJavaScriptIndexCreationTask;
//# sourceMappingURL=BaseJavaScriptIndexCreationTask.js.map