ravendb
Version:
RavenDB client for Node.js
50 lines • 1.62 kB
JavaScript
import { RavenCommand } from "../../Http/RavenCommand.js";
import { throwError } from "../../Exceptions/index.js";
import { TypeUtil } from "../../Utility/TypeUtil.js";
import { RaftIdGenerator } from "../../Utility/RaftIdGenerator.js";
export class SeedIdentityForCommand extends RavenCommand {
_id;
_value;
_forced;
constructor(id, value, forced) {
super();
if (!id) {
throwError("InvalidArgumentException", "Id cannot be null");
}
this._id = id;
this._value = value;
this._forced = forced;
}
get isReadRequest() {
return false;
}
createRequest(node) {
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.isNullOrUndefined(newSeedValue)) {
this._throwInvalidResponse();
}
this.result = newSeedValue;
return body;
}
getRaftUniqueRequestId() {
return RaftIdGenerator.newId();
}
}
//# sourceMappingURL=SeedIdentityForCommand.js.map