/* Copyright (c) 2020, 2023, The Unified Company. This code is part of Unify. This program is free software; you can redistribute it and/or modify it under the terms of the ESA Software Community License - Strong Copyleft LICENSE, as published by the ESA. See the ESA Software Community License - Strong Copyleft LICENSE, for more details. https://unifyjs.org */ import tools from '../../unify/tools.js'; import querySQL from '../../unify/querySQL.js'; import Console from '../console.js'; import database from '../database.js'; import deepclone from '../../unify/clonedeep.js'; export default class objectController{ __className = "objectController"; __sourcePath = "./framework/server/cachedControllers/objectController.js"; __publicMethods = "callNodeMethod"; async callNodeMethod( object, client, eventName ) { console.log("called method", object.nodeMethodName, eventName); var args = JSON.parse( object.nodeMethodArguments ); object.client = client; var output = object[ eventName ]( args[0], args[1], args[2], args[3], args[4], args[5] ); delete object.client; var out = await output; if( !typeof out ) { return object; } else { //console.log("output", out); return out; } } // Deprecated, Unsafe. add( json, client, eventName ) { /* // todo : this is not save var properties = JSON.parse( json ); var parentObject = tools.getObjectByPath( client.application, properties.parentApplicationPath ); var classObjects = client.classObjects; var object = client.classObjects[ properties.className ]; var objectClone = deepclone( object ); parentObject[ properties.propertyName ] = objectClone; objectClone.parent = parentObject; objectClone.propertyName = properties.propertyName; objectClone.id = properties.id; */ } }