UNPKG

@configurator/ravendb

Version:
54 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IndexHasChangedCommand = exports.IndexHasChangedOperation = void 0; const Exceptions_1 = require("../../../Exceptions"); const RavenCommand_1 = require("../../../Http/RavenCommand"); const HttpUtil_1 = require("../../../Utility/HttpUtil"); class IndexHasChangedOperation { constructor(definition) { if (!definition) { (0, Exceptions_1.throwError)("InvalidArgumentException", "IndexDefinition cannot be null"); } this._definition = definition; } getCommand(conventions) { return new IndexHasChangedCommand(conventions, this._definition); } get resultType() { return "CommandResult"; } } exports.IndexHasChangedOperation = IndexHasChangedOperation; class IndexHasChangedCommand extends RavenCommand_1.RavenCommand { constructor(conventions, definition) { super(); this._definition = conventions.objectMapper.toObjectLiteral(definition); } get isReadRequest() { return false; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/indexes/has-changed"; const body = this._serializer.serialize(this._definition); const headers = HttpUtil_1.HeadersBuilder.create() .typeAppJson().build(); return { method: "POST", uri, body, headers }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { this._throwInvalidResponse(); } let body = null; const results = await this._defaultPipeline(_ => body = _) .process(bodyStream); this.result = results["changed"]; return body; } } exports.IndexHasChangedCommand = IndexHasChangedCommand; //# sourceMappingURL=IndexHasChangedOperation.js.map