durable-functions
Version:
Durable Functions library for Node.js Azure Functions
69 lines • 4.03 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEntityFunction = exports.createOrchestrator = exports.DummyEntityContext = exports.DurableOrchestrationInput = exports.DummyOrchestrationContext = void 0;
const functions_1 = require("@azure/functions");
const ReplaySchema_1 = require("../orchestrations/ReplaySchema");
const uuid_1 = require("uuid");
const Entity_1 = require("../entities/Entity");
const HistoryEventOptions_1 = require("../history/HistoryEventOptions");
const OrchestratorStartedEvent_1 = require("../history/OrchestratorStartedEvent");
const DurableOrchestrationBindingInfo_1 = require("../orchestrations/DurableOrchestrationBindingInfo");
const Orchestrator_1 = require("../orchestrations/Orchestrator");
class DummyOrchestrationContext extends functions_1.InvocationContext {
constructor(functionName = "dummyContextFunctionName", invocationId = (0, uuid_1.v1)(), logHandler = (_level, ...args) => console.log(...args)) {
const invocationContextInit = {
functionName,
invocationId,
logHandler,
};
super(invocationContextInit);
this.df = undefined;
}
}
exports.DummyOrchestrationContext = DummyOrchestrationContext;
class DurableOrchestrationInput extends DurableOrchestrationBindingInfo_1.DurableOrchestrationBindingInfo {
constructor(instanceId = "", history = undefined, input = undefined, longRunningTimerIntervalDuration = "3.00:00:00", maximumShortTimerDuration = "6.00:00:00", defaultHttpAsyncRequestSleepTimeMillseconds = 30000, schemaVersion = ReplaySchema_1.ReplaySchema.V1, isReplaying = false, parentInstanceId = "") {
if (history === undefined) {
const opts = new HistoryEventOptions_1.HistoryEventOptions(0, new Date());
history = [new OrchestratorStartedEvent_1.OrchestratorStartedEvent(opts)];
}
super(history, input, instanceId, isReplaying, parentInstanceId, maximumShortTimerDuration, longRunningTimerIntervalDuration, defaultHttpAsyncRequestSleepTimeMillseconds, schemaVersion);
}
}
exports.DurableOrchestrationInput = DurableOrchestrationInput;
class DummyEntityContext extends functions_1.InvocationContext {
constructor(functionName = "dummyContextFunctionName", invocationId = (0, uuid_1.v1)(), logHandler = (_level, ...args) => console.log(...args)) {
const invocationContextInit = {
functionName,
invocationId,
logHandler,
};
super(invocationContextInit);
this.df = undefined;
}
}
exports.DummyEntityContext = DummyEntityContext;
function createOrchestrator(fn) {
const listener = new Orchestrator_1.Orchestrator(fn).listen();
return (orchestrationTrigger, context) => __awaiter(this, void 0, void 0, function* () {
return yield listener(orchestrationTrigger, context);
});
}
exports.createOrchestrator = createOrchestrator;
function createEntityFunction(fn) {
const listener = new Entity_1.Entity(fn).listen();
return (entityTrigger, context) => __awaiter(this, void 0, void 0, function* () {
return yield listener(entityTrigger, context);
});
}
exports.createEntityFunction = createEntityFunction;
//# sourceMappingURL=testingUtils.js.map
;