114 lines
3.8 KiB
JavaScript
114 lines
3.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const tslib_1 = require("tslib");
|
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
const types_1 = require("oak-domain/lib/types");
|
|
const debugStore_1 = require("../debugStore");
|
|
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
|
const oak_common_aspect_1 = tslib_1.__importStar(require("oak-common-aspect"));
|
|
const i18n_1 = tslib_1.__importDefault(require("oak-domain/lib/data/i18n"));
|
|
class DebugConnector {
|
|
debugStore;
|
|
contextBuilder;
|
|
aspectDict;
|
|
constructor(storageSchema, contextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, common, importations, exportations) {
|
|
(0, assert_1.default)(initialData.i18n);
|
|
initialData.i18n.push(...i18n_1.default);
|
|
this.debugStore = (0, debugStore_1.createDebugStore)(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, common);
|
|
this.contextBuilder = contextBuilder;
|
|
this.aspectDict = (0, lodash_1.mergeConcatArray)(aspectDict, oak_common_aspect_1.default);
|
|
if (importations || exportations) {
|
|
(0, oak_common_aspect_1.registerPorts)(importations || [], exportations || []);
|
|
}
|
|
}
|
|
getRouter() {
|
|
throw new Error('not available in debugConnector');
|
|
return '';
|
|
}
|
|
;
|
|
async callAspect(name, params, context) {
|
|
const str = await context?.toString();
|
|
const contextBackend = this.contextBuilder(this.debugStore);
|
|
await contextBackend.begin();
|
|
if (str) {
|
|
await contextBackend.initialize(JSON.parse(str));
|
|
}
|
|
let { opRecords } = contextBackend;
|
|
let message;
|
|
try {
|
|
const result = await this.aspectDict[name]((0, lodash_1.cloneDeep)(params), contextBackend);
|
|
await contextBackend.refineOpRecords();
|
|
opRecords = contextBackend.opRecords;
|
|
message = contextBackend.getMessage();
|
|
await contextBackend.commit();
|
|
return {
|
|
result,
|
|
opRecords: opRecords,
|
|
message,
|
|
};
|
|
}
|
|
catch (err) {
|
|
await contextBackend.rollback();
|
|
if (err instanceof types_1.OakException) {
|
|
throw err;
|
|
}
|
|
if (err instanceof Error) {
|
|
const exception = await contextBackend.tryDeduceException(err);
|
|
if (exception) {
|
|
throw exception;
|
|
}
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
parseRequest() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
serializeResult() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
serializeException() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
getSocketPath() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
getSocketPointRouter() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
getSocketPoint() {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
;
|
|
getBridgeRouter() {
|
|
throw new Error('not available in debugConnector');
|
|
return '';
|
|
}
|
|
;
|
|
makeBridgeUrl(url) {
|
|
return url;
|
|
}
|
|
getEndpointRouter() {
|
|
return '';
|
|
}
|
|
parseBridgeRequestQuery(urlParams) {
|
|
throw new Error('not available in debugConnector');
|
|
return {};
|
|
}
|
|
async getFullData(keys) {
|
|
return this.debugStore.getCurrentData(keys);
|
|
}
|
|
getCorsHeader() {
|
|
throw new Error('not available in debugConnector');
|
|
return [];
|
|
}
|
|
}
|
|
exports.default = DebugConnector;
|
|
;
|