UNPKG

ravendb

Version:
67 lines 2.35 kB
import { TypeUtil } from "../../../Utility/TypeUtil.js"; import { throwError } from "../../../Exceptions/index.js"; import { RavenCommand } from "../../../Http/RavenCommand.js"; import { RaftIdGenerator } from "../../../Utility/RaftIdGenerator.js"; export class SetIndexesPriorityOperation { _parameters; constructor(paramsOrIndexName, priority) { if (TypeUtil.isString(paramsOrIndexName)) { const indexName = paramsOrIndexName; if (!indexName) { throwError("InvalidArgumentException", "IndexName cannot be null."); } this._parameters = { indexNames: [indexName], priority }; } else { const parameters = paramsOrIndexName; if (!parameters) { throwError("InvalidArgumentException", "Parameters cannot be null."); } if (!parameters.indexNames || !parameters.indexNames.length) { throwError("InvalidArgumentException", "IndexNames cannot be null or empty."); } this._parameters = parameters; } } getCommand(conventions) { return new SetIndexPriorityCommand(conventions, this._parameters); } get resultType() { return "CommandResult"; } } export class SetIndexPriorityCommand extends RavenCommand { _parameters; constructor(conventions, parameters) { super(); if (!conventions) { throwError("InvalidArgumentException", "Conventions cannot be null"); } if (!parameters) { throwError("InvalidArgumentException", "Parameters cannot be null"); } this._parameters = conventions.objectMapper.toObjectLiteral(parameters); } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/indexes/set-priority"; const body = this._serializer.serialize(this._parameters); const headers = this._headers() .typeAppJson().build(); return { uri, method: "POST", body, headers }; } get isReadRequest() { return false; } getRaftUniqueRequestId() { return RaftIdGenerator.newId(); } } //# sourceMappingURL=SetIndexesPriorityOperation.js.map