From 6e61f28d7833f54bc65b98a7f9312c4f7f243db8 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 4 Jun 2025 13:59:15 +0700 Subject: [PATCH 1/6] [wip] initial inclusion of ABClassManager and loading of local dev plugins --- ABFactoryCore.js | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/ABFactoryCore.js b/ABFactoryCore.js index 8e358ebb..8e230f23 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -8,6 +8,8 @@ // const _ = require("lodash"); // const uuidv4 = require("uuid"); +const ABClassManager = require("../platform/ABClassManager"); + const ABApplication = require("../platform/ABApplication"); const ABApplicationMobile = require("../platform/ABApplicationMobile"); const ABDefinition = require("../platform/ABDefinition"); @@ -97,6 +99,9 @@ class ABFactory extends EventEmitter { this._allDatacollections = []; // {array} of all the ABDataCollection(s) in our site. + this.ClassManager = ABClassManager; + // {ClassManager} the single source for our Class Libraries. + // // Class References // @@ -275,6 +280,10 @@ class ABFactory extends EventEmitter { } init() { + // BEFORE Definitions are loaded, + // make sure any local Plugins are loaded. + this.ClassManager.registerLocalPlugins(this.pluginAPI()); + let allDefinitions = Object.keys(this._definitions).map( (k) => this._definitions[k] ); @@ -679,13 +688,20 @@ class ABFactory extends EventEmitter { objectNew(values) { var newObj = null; - if (values.isExternal == true) + if (values.plugin_key) { + // If this is from a plugin, create it from ClassManager + newObj = this.ClassManager.createObject( + values.plugin_key, + values, + this + ); + } else if (values.isExternal == true) newObj = new ABObjectExternal(values, this); else if (values.isImported == true) newObj = new ABObjectImport(values, this); - else if (values.isNetsuite == true) + else if (values.isNetsuite == true) { newObj = new ABObjectApiNetsuite(values, this); - else if (values.isAPI == true) newObj = new ABObjectApi(values, this); + } else if (values.isAPI == true) newObj = new ABObjectApi(values, this); else newObj = new ABObject(values, this); /* @@ -743,6 +759,20 @@ class ABFactory extends EventEmitter { return this.objectByID("db5b3b26-5300-4c92-bc73-8ce4f4696992"); } + // + // Plugin + // + pluginAPI() { + let api = this.ClassManager.getPluginAPI(); + api.AB = this; + api.platform = this.platform ?? "service"; + return api; + } + + pluginRegister(plugin) { + plugin(this.pluginAPI()); + } + // // Hints // From 397b88df7b003a65835686bfcded07ded63a6e91 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Mon, 3 Nov 2025 16:24:55 +0700 Subject: [PATCH 2/6] [wip] ABFactoryCore now passes plugin registration to ABClassManager --- ABFactoryCore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ABFactoryCore.js b/ABFactoryCore.js index 8e230f23..494e26c5 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -770,7 +770,8 @@ class ABFactory extends EventEmitter { } pluginRegister(plugin) { - plugin(this.pluginAPI()); + let pluginClass = plugin(this.pluginAPI()); + this.ClassManager.pluginRegister(pluginClass); } // From 715cf85e9d9f6f5744fd78bb266d8548a98b7de3 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Mon, 3 Nov 2025 16:25:45 +0700 Subject: [PATCH 3/6] [wip] define an ABObject for working with the plugin table. --- ABFactoryCore.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ABFactoryCore.js b/ABFactoryCore.js index 494e26c5..9940fbdd 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -723,6 +723,10 @@ class ABFactory extends EventEmitter { return this.objectByID("d84cd351-d96c-490f-9afb-2a0b880ca0ec"); } + objectPlugin() { + return this.objectByID("1587f5ba-f5e2-4e1f-b4b9-6472d20487e8"); + } + objectProcessDefinition() { return this.objectByID("af91fc75-fb73-4d71-af14-e22832eb5915"); } From bb54bd0ff3d9d86026cac08a95e70b59156822b2 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Sat, 8 Nov 2025 14:11:05 +0700 Subject: [PATCH 4/6] [wip] include system objects for SitePlugins and SitePluginLinks --- ABFactoryCore.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ABFactoryCore.js b/ABFactoryCore.js index 9940fbdd..63771439 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -724,7 +724,11 @@ class ABFactory extends EventEmitter { } objectPlugin() { - return this.objectByID("1587f5ba-f5e2-4e1f-b4b9-6472d20487e8"); + return this.objectByID("8a20528a-e472-4e80-911a-b14285425caf"); + } + + objectPluginLinks() { + return this.objectByID("7ff322ff-3434-4611-9fd1-4d2996414c1a"); } objectProcessDefinition() { From 3c69b2abdf2d213d91c1217a8958c0b9a68210b2 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Sat, 8 Nov 2025 17:34:22 +0700 Subject: [PATCH 5/6] [wip] include ABFormUrl --- ABViewManagerCore.js | 5 +++-- views/ABViewCore.js | 4 ++-- views/ABViewFormCore.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ABViewManagerCore.js b/ABViewManagerCore.js index d8b357f0..f2f324ba 100644 --- a/ABViewManagerCore.js +++ b/ABViewManagerCore.js @@ -71,6 +71,7 @@ var AllViews = [ require("../platform/views/ABViewFormSelectSingle"), require("../platform/views/ABViewFormTextbox"), require("../platform/views/ABViewFormTree"), + require("../platform/views/ABViewFormURL"), ]; /* @@ -120,8 +121,8 @@ module.exports = class ABViewManagerCore { if (!isPlugin(values.key)) { console.error( "!! View[" + - values.key + - "] not yet defined. Have an ABView instead:" + values.key + + "] not yet defined. Have an ABView instead:" ); } return new Views["view"](values, application, parent); diff --git a/views/ABViewCore.js b/views/ABViewCore.js index 5c4bd866..f6e082c0 100644 --- a/views/ABViewCore.js +++ b/views/ABViewCore.js @@ -352,11 +352,11 @@ module.exports = class ABViewCore extends ABMLClass { var form = null; var curr = this; - while (curr.key != "form" && !curr.isRoot() && curr.parent) { + while (!curr.isForm && !curr.isRoot() && curr.parent) { curr = curr.parent; } - if (curr.key == "form") { + if (curr.isForm) { form = curr; } diff --git a/views/ABViewFormCore.js b/views/ABViewFormCore.js index 73afd9d9..be6dfd89 100644 --- a/views/ABViewFormCore.js +++ b/views/ABViewFormCore.js @@ -56,6 +56,7 @@ const ABViewFormPropertyComponentDefaults = { module.exports = class ABViewFormCore extends ABViewContainer { constructor(values, application, parent, defaultValues) { super(values, application, parent, defaultValues || ABViewFormDefaults); + this.isForm = true; } static common() { From e82c0b9da5fb097f1327327de3737dc594fdd4b4 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Tue, 11 Nov 2025 00:47:51 +0700 Subject: [PATCH 6/6] [wip] support plugin fn() returning more than 1 object --- ABFactoryCore.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ABFactoryCore.js b/ABFactoryCore.js index 63771439..cb986e98 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -779,7 +779,13 @@ class ABFactory extends EventEmitter { pluginRegister(plugin) { let pluginClass = plugin(this.pluginAPI()); - this.ClassManager.pluginRegister(pluginClass); + if (Array.isArray(pluginClass)) { + pluginClass.forEach((p) => { + this.ClassManager.pluginRegister(p); + }); + } else { + this.ClassManager.pluginRegister(pluginClass); + } } //