UNPKG

@configurator/ravendb

Version:
45 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SuggestionBuilder = void 0; const SuggestionWithTerm_1 = require("./SuggestionWithTerm"); const SuggestionWithTerms_1 = require("./SuggestionWithTerms"); const Exceptions_1 = require("../../../Exceptions"); const TypeUtil_1 = require("../../../Utility/TypeUtil"); class SuggestionBuilder { withDisplayName(displayName) { this.suggestion.displayField = displayName; return this; } byField(fieldName, termOrTerms) { if (!fieldName) { (0, Exceptions_1.throwError)("InvalidArgumentException", "fieldName cannot be null"); } if (!termOrTerms) { (0, Exceptions_1.throwError)("InvalidArgumentException", "term cannot be null"); } if (TypeUtil_1.TypeUtil.isArray(termOrTerms)) { if (!termOrTerms.length) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Terms cannot be an empty collection"); } this._terms = new SuggestionWithTerms_1.SuggestionWithTerms(fieldName); this._terms.terms = termOrTerms; } else { this._term = new SuggestionWithTerm_1.SuggestionWithTerm(fieldName); this._term.term = termOrTerms; } return this; } withOptions(options) { this.suggestion.options = options; return this; } get suggestion() { if (this._term) { return this._term; } return this._terms; } } exports.SuggestionBuilder = SuggestionBuilder; //# sourceMappingURL=SuggestionBuilder.js.map