UNPKG

@configurator/ravendb

Version:
65 lines 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetIndexCommand = exports.GetIndexOperation = void 0; const IndexDefinition_1 = require("../../Indexes/IndexDefinition"); const Exceptions_1 = require("../../../Exceptions"); const RavenCommand_1 = require("../../../Http/RavenCommand"); class GetIndexOperation { constructor(indexName) { if (!indexName) { (0, Exceptions_1.throwError)("InvalidArgumentException", "IndexName cannot be null."); } this._indexName = indexName; } getCommand(conventions) { return new GetIndexCommand(this._indexName, conventions); } get resultType() { return "CommandResult"; } } exports.GetIndexOperation = GetIndexOperation; class GetIndexCommand extends RavenCommand_1.RavenCommand { constructor(indexName, conventions) { super(); if (!indexName) { (0, Exceptions_1.throwError)("InvalidArgumentException", "IndexName cannot be null."); } this._indexName = indexName; this._conventions = conventions; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/indexes?name=" + encodeURIComponent(this._indexName); return { uri }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { return; } let body = null; const result = await this._pipeline() .collectBody(b => body = b) .parseJsonSync() .objectKeysTransform({ defaultTransform: "camel", ignorePaths: [/fields\.[^.]+$/i] }) .process(bodyStream); const indexDefTypeInfo = { nestedTypes: { "results[]": "IndexDefinition", "results[].maps": "Set" }, }; const knownTypes = new Map([[IndexDefinition_1.IndexDefinition.name, IndexDefinition_1.IndexDefinition]]); const allResults = this._reviveResultTypes(result, this._conventions, indexDefTypeInfo, knownTypes); this.result = allResults["results"][0] || null; return body; } get isReadRequest() { return true; } } exports.GetIndexCommand = GetIndexCommand; //# sourceMappingURL=GetIndexOperation.js.map