ravendb
Version:
RavenDB client for Node.js
150 lines • 5.33 kB
JavaScript
import { TypeUtil } from "../../Utility/TypeUtil.js";
import { RavenCommand } from "../../Http/RavenCommand.js";
import { throwError } from "../../Exceptions/index.js";
import { RavenEtlConfiguration } from "./Etl/RavenEtlConfiguration.js";
import { SqlEtlConfiguration } from "./Etl/Sql/SqlEtlConfiguration.js";
import { OlapEtlConfiguration } from "./Etl/Olap/OlapEtlConfiguration.js";
import { ElasticSearchEtlConfiguration } from "./Etl/ElasticSearch/ElasticSearchEtlConfiguration.js";
import { QueueEtlConfiguration } from "./Etl/Queue/QueueEtlConfiguration.js";
import { Transformation } from "./Etl/Transformation.js";
export class GetOngoingTaskInfoOperation {
_taskName;
_taskId;
_type;
constructor(taskIdOrName, type) {
if (TypeUtil.isString(taskIdOrName)) {
this._taskName = taskIdOrName;
}
else {
this._taskId = taskIdOrName;
}
this._type = type;
if (type === "PullReplicationAsHub") {
throwError("InvalidArgumentException", "PullReplicationAsHub type is not supported. " +
"Please use GetPullReplicationTasksInfoOperation instead.");
}
}
get resultType() {
return "CommandResult";
}
getCommand(conventions) {
return new GetOngoingTaskInfoCommand(this._taskName || this._taskId, this._type, conventions);
}
}
class GetOngoingTaskInfoCommand extends RavenCommand {
_taskName;
_taskId;
_type;
_conventions;
constructor(taskIdOrName, type, documentConventions) {
super();
if (TypeUtil.isString(taskIdOrName)) {
this._taskName = taskIdOrName;
}
else {
this._taskId = taskIdOrName;
}
this._type = type;
this._conventions = documentConventions;
}
createRequest(node) {
const uri = this._taskName
? node.url + "/databases/" + node.database + "/task?taskName=" + encodeURIComponent(this._taskName) + "&type=" + this._type
: node.url + "/databases/" + node.database + "/task?key=" + this._taskId + "&type=" + this._type;
return {
uri,
method: "GET"
};
}
async setResponseAsync(bodyStream, fromCache) {
let body = null;
const results = await this._defaultPipeline(_ => body = _)
.process(bodyStream);
let nestedTypes = {};
switch (this._type) {
case "Replication": {
// nothing to do
break;
}
case "RavenEtl": {
nestedTypes = {
configuration: "RavenEtlConfiguration",
"configuration.transforms": "Transformation"
};
break;
}
case "SqlEtl": {
nestedTypes = {
configuration: "SqlEtlConfiguration",
"configuration.transforms": "Transformation"
};
break;
}
case "Subscription": {
nestedTypes = {
lastBatchAckTime: "date",
lastClientConnectionTime: "date"
};
break;
}
case "OlapEtl": {
nestedTypes = {
configuration: "OlapEtlConfiguration",
"configuration.transforms": "Transformation"
};
break;
}
case "ElasticSearchEtl": {
nestedTypes = {
configuration: "ElasticSearchEtlConfiguration",
"configuration.transforms": "Transformation"
};
break;
}
case "QueueEtl": {
nestedTypes = {
configuration: "QueueEtlConfiguration",
"configuration.transforms": "Transformation"
};
break;
}
case "PullReplicationAsSink": {
break;
}
case "PullReplicationAsHub": {
break;
}
case "QueueSink": {
break;
}
case "Backup": {
nestedTypes = {
lastFullBackup: "date",
delayUntil: "date",
originalBackupTime: "date",
lastIncrementalBackup: "date",
"onGoingBackup.startTime": "date",
"nextBackup.dateTime": "date",
"nextBackup.originalBackupTime": "date",
};
break;
}
}
this.result = this._reviveResultTypes(results, this._conventions, {
nestedTypes
}, knownTypes);
return body;
}
get isReadRequest() {
return false;
}
}
const knownTypes = new Map([
[RavenEtlConfiguration.name, RavenEtlConfiguration],
[SqlEtlConfiguration.name, SqlEtlConfiguration],
[OlapEtlConfiguration.name, OlapEtlConfiguration],
[ElasticSearchEtlConfiguration.name, ElasticSearchEtlConfiguration],
[QueueEtlConfiguration.name, QueueEtlConfiguration],
[Transformation.name, Transformation],
]);
//# sourceMappingURL=GetOngoingTaskInfoOperation.js.map