UNPKG

ravendb

Version:
54 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SeedIdentityForCommand = void 0; const RavenCommand_js_1 = require("../../Http/RavenCommand.js"); const index_js_1 = require("../../Exceptions/index.js"); const TypeUtil_js_1 = require("../../Utility/TypeUtil.js"); const RaftIdGenerator_js_1 = require("../../Utility/RaftIdGenerator.js"); class SeedIdentityForCommand extends RavenCommand_js_1.RavenCommand { _id; _value; _forced; constructor(id, value, forced) { super(); if (!id) { (0, index_js_1.throwError)("InvalidArgumentException", "Id cannot be null"); } this._id = id; this._value = value; this._forced = forced; } get isReadRequest() { return false; } createRequest(node) { RavenCommand_js_1.RavenCommand.ensureIsNotNullOrEmpty(this._id, "id"); let uri = node.url + "/databases/" + node.database + "/identity/seed?name=" + encodeURIComponent(this._id) + "&value=" + this._value; if (this._forced) { uri += "&force=true"; } return { method: "POST", uri }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { this._throwInvalidResponse(); } let body = null; const result = await this._defaultPipeline(_ => body = _).process(bodyStream); const newSeedValue = result["newSeedValue"]; if (TypeUtil_js_1.TypeUtil.isNullOrUndefined(newSeedValue)) { this._throwInvalidResponse(); } this.result = newSeedValue; return body; } getRaftUniqueRequestId() { return RaftIdGenerator_js_1.RaftIdGenerator.newId(); } } exports.SeedIdentityForCommand = SeedIdentityForCommand; //# sourceMappingURL=SeedIdentityForCommand.js.map