ravendb
Version:
RavenDB client for Node.js
69 lines • 2.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetIndexCommand = exports.GetIndexOperation = void 0;
const IndexDefinition_js_1 = require("../../Indexes/IndexDefinition.js");
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const ObjectUtil_js_1 = require("../../../Utility/ObjectUtil.js");
class GetIndexOperation {
_indexName;
constructor(indexName) {
if (!indexName) {
(0, index_js_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_js_1.RavenCommand {
_indexName;
_conventions;
constructor(indexName, conventions) {
super();
if (!indexName) {
(0, index_js_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: ObjectUtil_js_1.ObjectUtil.camel,
ignorePaths: [/fields\.[^.]+$/i, /configuration\./i]
})
.process(bodyStream);
const indexDefTypeInfo = {
nestedTypes: {
"results[]": "IndexDefinition",
"results[].maps": "Set"
},
};
const knownTypes = new Map([[IndexDefinition_js_1.IndexDefinition.name, IndexDefinition_js_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