import { createDebugStore } from '../debugStore'; import { cloneDeep, mergeConcatArray } from "oak-domain/lib/utils/lodash"; import commonAspectDict, { registerPorts } from 'oak-common-aspect'; export default class DebugConnector { debugStore; contextBuilder; aspectDict; constructor(storageSchema, contextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, common, importations, exportations) { this.debugStore = createDebugStore(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, common); this.contextBuilder = contextBuilder; this.aspectDict = mergeConcatArray(aspectDict, commonAspectDict); if (importations || exportations) { 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](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(); 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 {}; } getSubscribeRouter() { throw new Error('not available in debugConnector'); return {}; } getSubscribePointRouter() { throw new Error('not available in debugConnector'); return {}; } getSubscribePoint() { 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); } } ;