From 02f951aa7d2f7aff4aa783aa82b579b6a28b9418 Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Tue, 20 Sep 2022 20:54:53 +0200 Subject: [PATCH] # 1.3.13 - Fixes: - `cli/runNopeBackend`: Fixing parameter `preventVarifiedNames` no works correctly. # 1.3.14 - Fixes: - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui` - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui` # 1.4.0 - Modified: - asyncified all ui-related services. - Adapted ui-defintion of functions: - `autoGenBySchema` Helper to enable auto generating a configuration - `requiresProviderForRendering` Flag to indicate, that rendering the service configuration requires a provider itself. This for instance is the case, if some needs to be called. - `types/ui/editor/IServiceEditPage.ts`: Asnycify the Calls - `types/ui/editor/render.callbacks.ts`: Asnycify the Calls # 1.4.1 - Modified: - loading all files related to `*.functions.js` - Adapted the following files to implement that behavior: - `getCentralDecoratedContainer` in `lib\decorators\container.ts` -> now provides services as Map - `exportFunctionAsNopeService` in `lib\decorators\functionDecorators.ts` to work with the map. - `loadFunctions` in `lib\loader\loadPackages.ts` to match the interface of `loadPackages` and add the functions to the package-loader. - added the function `addDecoratedElements` in the package-loader and the interface. --- CHANGELOG.md | 28 ++ contribute/VERSION | 2 +- lib/cli/nope.ts | 21 +- lib/cli/repl.ts | 4 +- lib/cli/runNopeBackend.ts | 31 +- lib/decorators/container.ts | 4 +- lib/decorators/functionDecorators.ts | 4 +- lib/helpers/jsonMethods.ts | 15 +- lib/loader/loadPackages.ts | 86 +++-- lib/loader/nopePackageLoader.ts | 82 ++++- lib/types/nope/nopeCommunication.interface.ts | 1 + lib/types/nope/nopeModule.interface.ts | 16 + lib/types/nope/nopePackageLoader.interface.ts | 14 + lib/types/ui/editor/IServiceEditPage.ts | 19 +- lib/types/ui/editor/render.callbacks.ts | 2 +- lib/types/ui/helpers.interface.ts | 1 + lib/types/ui/layout.interface.ts | 13 +- lib/types/ui/render.callbacks.ts | 4 +- lib/ui/helpers.nodejs.ts | 248 ++++++++++++- package-lock.json | 345 ++++++++++++++++-- package.json | 4 +- tsconfig.browser.json | 2 +- 22 files changed, 825 insertions(+), 121 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a2df28..a2dc29e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -232,3 +232,31 @@ Inital commit, which is working with the browser # 1.3.12 - Modified: - `helpers/limit`: added the option `minDelay`. If provided, the calles are ensured to be delayed with this options. If `0` or smaller -> no delay is added. + +# 1.3.13 + - Fixes: + - `cli/runNopeBackend`: Fixing parameter `preventVarifiedNames` no works correctly. + +# 1.3.14 + - Fixes: + - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui` + - `helpers/ui/helpers.nodejs`: Adding the option `upload-ui` + +# 1.4.0 + - Modified: + - asyncified all ui-related services. + - Adapted ui-defintion of functions: + - `autoGenBySchema` Helper to enable auto generating a configuration + - `requiresProviderForRendering` Flag to indicate, that rendering the service configuration requires a provider itself. This for instance is the case, if some needs to be called. + - `types/ui/editor/IServiceEditPage.ts`: Asnycify the Calls + - `types/ui/editor/render.callbacks.ts`: Asnycify the Calls + +# 1.4.1 + - Modified: + - loading all files related to `*.functions.js` + - Adapted the following files to implement that behavior: + - `getCentralDecoratedContainer` in `lib\decorators\container.ts` -> now provides services as Map + - `exportFunctionAsNopeService` in `lib\decorators\functionDecorators.ts` to work with the map. + - `loadFunctions` in `lib\loader\loadPackages.ts` to match the interface of `loadPackages` and add the functions to the package-loader. + - added the function `addDecoratedElements` in the package-loader and the interface. + diff --git a/contribute/VERSION b/contribute/VERSION index ba50e86..13175fd 100644 --- a/contribute/VERSION +++ b/contribute/VERSION @@ -1 +1 @@ -1.3.12 \ No newline at end of file +1.4.1 \ No newline at end of file diff --git a/lib/cli/nope.ts b/lib/cli/nope.ts index 6bde1c1..8a702ad 100644 --- a/lib/cli/nope.ts +++ b/lib/cli/nope.ts @@ -4,13 +4,17 @@ * @desc [description] */ -import { readInwriteUiFileArgs, writeUiFile } from "../ui/helpers.nodejs"; +import { + readInWriteUiFileArgs, + writeUiFile, + main as uploadUi, +} from "../ui/helpers.nodejs"; import { createService } from "./createService"; import { generateDefaultConfig } from "./generateDefaultConfig"; import { generateDefaultPackageConfig } from "./generateDefaultPackageConfig"; import { generateFolderStructure } from "./generateFolderStructure"; import { repl } from "./repl"; -import run from "./runNopeBackend"; +import { main as runMain } from "./runNopeBackend"; /** * Main Function. @@ -27,7 +31,8 @@ export async function main() { | "help" | "service" | "repl" - | "scan-ui"; + | "scan-ui" + | "upload-ui"; params: string[]; } = { mode: (process.argv[2] as any) || "none", @@ -49,6 +54,7 @@ Please select the option you want. Therefore add one of the following options: \x1b[4minit\x1b[0m Initialize a new project. This project is empty. \x1b[4mconf\x1b[0m Trys to update the configuration file. \x1b[4mscan-ui\x1b[0m Scans and extracts the provided uis. + \x1b[4mupload-ui\x1b[0m Uploads the determined ui-file \x1b[4mservice\x1b[0m Generate Helper Files to provide services \x1b[4mrepl\x1b[0m Opens an interactive console. @@ -83,7 +89,8 @@ Have fun using NoPE :) showLog(); break; case "run": - await run([additionalArg]); + additionalArg.help = "Command to run the backend"; + await runMain([additionalArg]); break; case "init": additionalArg.help = "Command to run init"; @@ -105,7 +112,11 @@ Have fun using NoPE :) case "scan-ui": additionalArg.help = "Command to readin the UI-Files and store them in a config"; - await writeUiFile(readInwriteUiFileArgs([additionalArg])); + await writeUiFile(readInWriteUiFileArgs([additionalArg])); + break; + case "upload-ui": + additionalArg.help = "to upload the determined ui-config."; + await uploadUi([additionalArg]); break; } } diff --git a/lib/cli/repl.ts b/lib/cli/repl.ts index 6471653..f931ea9 100644 --- a/lib/cli/repl.ts +++ b/lib/cli/repl.ts @@ -7,7 +7,7 @@ */ import { start } from "repl"; -import run from "./runNopeBackend"; +import main from "./runNopeBackend"; /** * Starts an interactive console with the loaded dispatcher. @@ -20,7 +20,7 @@ export async function repl( defaultValue?: any; }[] = [] ) { - const loader = await run( + const loader = await main( additionalArguments, { // skipLoadingConfig: true diff --git a/lib/cli/runNopeBackend.ts b/lib/cli/runNopeBackend.ts index d39e300..5d67de1 100644 --- a/lib/cli/runNopeBackend.ts +++ b/lib/cli/runNopeBackend.ts @@ -257,7 +257,7 @@ export async function readInArgs( args.logToFile = Array.isArray(args.logToFile); args.forceUsingSelectors = Array.isArray(args.forceUsingSelectors); args.useBaseServices = !Array.isArray(args.useBaseServices); - args.preventVarifiedNames = !Array.isArray(args.preventVarifiedNames); + args.preventVarifiedNames = Array.isArray(args.preventVarifiedNames); return Object.assign(args, forcedArgs); } @@ -403,19 +403,6 @@ export async function runNopeBackend( } } - // If required load all Packages. - if (!args.skipLoadingConfig) { - // Try to load the Modules. - try { - logger.info("loading Functions"); - await loadFunctions(args.file); - } catch (e) { - logger.error("Unable to load the Packages defined in " + args.file); - logger.error("Returning without config. "); - args.skipLoadingConfig = true; - } - } - let loader: INopePackageLoader; try { loader = getPackageLoader( @@ -452,6 +439,14 @@ export async function runNopeBackend( await sleep(args.delay * 1000); } + // If required load all Packages. + try { + logger.info("loading Functions"); + await loadFunctions(loader, args.file, args.delay); + } catch (e) { + logger.error("Unable to load the Functions defined in " + args.file); + } + try { logger.info("loading Packages"); await loadPackages(loader, args.file, args.delay); @@ -473,7 +468,7 @@ export async function runNopeBackend( * * @export */ -export async function run( +export async function main( additionalArguments: { help: string; type: "string" | "number"; @@ -492,9 +487,9 @@ export async function run( return await runNopeBackend(args); } -export default run; - // If requested As Main => Perform the Operation. if (require.main === module) { - run(); + main(); } + +export default main; diff --git a/lib/decorators/container.ts b/lib/decorators/container.ts index 467d921..9278170 100644 --- a/lib/decorators/container.ts +++ b/lib/decorators/container.ts @@ -17,7 +17,7 @@ export type IexportFunctionAsNopeServiceParameters = IFunctionOptions; * @return {NopeLogger} A Returns the Logger {@link NopeLogger} */ export function getCentralDecoratedContainer(): { - methods: Map< + services: Map< string, { uri: string; @@ -29,7 +29,7 @@ export function getCentralDecoratedContainer(): { } { const container = getSingleton("nope.decorated.elements", () => { return { - methods: new Map(), + services: new Map(), classes: new Map(), }; }); diff --git a/lib/decorators/functionDecorators.ts b/lib/decorators/functionDecorators.ts index 6d9ecb0..e98c2fc 100644 --- a/lib/decorators/functionDecorators.ts +++ b/lib/decorators/functionDecorators.ts @@ -28,8 +28,8 @@ export function exportFunctionAsNopeService( options: IexportFunctionAsNopeServiceParameters ) { // Only add the element if it doesnt exists. - if (!CONTAINER.methods.has(options.id)) { - CONTAINER.methods.set(options.id, { + if (!CONTAINER.services.has(options.id)) { + CONTAINER.services.set(options.id, { callback: async (...args) => { return await (func as any)(...args); }, diff --git a/lib/helpers/jsonMethods.ts b/lib/helpers/jsonMethods.ts index fa4f388..33c1b58 100644 --- a/lib/helpers/jsonMethods.ts +++ b/lib/helpers/jsonMethods.ts @@ -26,12 +26,20 @@ export function stringifyWithFunctions(obj, ...args) { // 3) (a, b) => (a + b); // 4) (name, description) => ({name: name, description: description}) // .... + const isAsync = str.startsWith("async "); + + if (isAsync) { + str = str.slice("async ".length); + } if (!str.startsWith("function") && !str.startsWith("(")) { const name = str.slice(0, str.indexOf("=>")); const func = str.slice(str.indexOf("=>(") + 3, str.length - 2); - const adaptedFunc = "function(" + name + "){ return " + func + "; }"; - str = adaptedFunc; + str = "function(" + name + "){ return " + func + "; }"; + } + + if (isAsync) { + return BEGIN_STR + "async " + str + END_STR; } return BEGIN_STR + str + END_STR; @@ -65,7 +73,8 @@ export function parseWithFunctions( try { return eval("(" + _value + ")").bind(scope); } catch (e) { - console.log("FAILED PARSING", value, _value); + console.log("Failed Parsing function", "\n" + _value); + console.error(e); } } return value; diff --git a/lib/loader/loadPackages.ts b/lib/loader/loadPackages.ts index d813544..0a3c20d 100644 --- a/lib/loader/loadPackages.ts +++ b/lib/loader/loadPackages.ts @@ -9,11 +9,18 @@ import { join, resolve } from "path"; import "reflect-metadata"; import { sleep } from "../helpers/async"; import { createFile, listFiles } from "../helpers/fileMethods"; -import { parseWithFunctions, stringifyWithFunctions } from "../index.browser"; +import { determineDifference } from "../helpers/setMethods"; +import { + getCentralDecoratedContainer, + parseWithFunctions, + stringifyWithFunctions, +} from "../index.browser"; import { getNopeLogger } from "../logger/getLogger"; import { IPackageDescription } from "../types/nope/nopePackage.interface"; import { INopePackageLoader } from "../types/nope/nopePackageLoader.interface"; +const logger = getNopeLogger("helper-load-packages"); + export interface IPackageConfig extends Partial> { // File Path of the element. path: string; @@ -46,16 +53,16 @@ export async function listPackages(dir = "./modules") { for (const fileName of await listFiles(dir, ".package.js")) { // Now Try to load a Package, to test whether is is an assembly. try { + logger.info("found ", fileName); + ret.push({ package: (await import(resolve(fileName))) .DESCRIPTION as IPackageDescription, path: fileName, }); } catch (e) { - getNopeLogger("helper-list-packages").error( - "Failed Loading the Package " + fileName - ); - getNopeLogger("helper-list-packages").error(e); + logger.error("Failed Loading the Package " + fileName); + logger.error(e); } } @@ -74,15 +81,15 @@ export async function listFunctions(dir = "./modules") { for (const fileName of await listFiles(dir, ".functions.js")) { // Now Try to load a Package, to test whether is is an assembly. try { + logger.info("found ", fileName); + ret.push({ content: (await import(resolve(fileName))).DESCRIPTION, path: fileName, }); } catch (e) { - getNopeLogger("helper-list-functions").error( - "Failed Loading the functions in file: " + fileName - ); - getNopeLogger("helper-list-functions").error(e); + logger.error("Failed Loading the functions in file: " + fileName); + logger.error(e); } } @@ -154,7 +161,7 @@ export async function loadPackages( await writeDefaultConfig(filename); // Show an Hint - getNopeLogger("helper-load-packages").warn( + logger.warn( "No configuration was present. Created a new config file in " + filename ); @@ -180,10 +187,8 @@ export async function loadPackages( loadedPackage.defaultInstances = item.defaultInstances; packages.push(loadedPackage); } catch (e) { - getNopeLogger("helper-load-packages").error( - "Failed Loading the Package " + item.nameOfPackage - ); - getNopeLogger("helper-load-packages").error(e); + logger.error("Failed Loading the Package " + item.nameOfPackage); + logger.error(e); } } @@ -194,7 +199,7 @@ export async function loadPackages( try { await loader.addPackage(thePackageToLoad); } catch (e) { - getNopeLogger("helper-load-packages").error( + logger.error( 'Failed Add the Package "' + thePackageToLoad.nameOfPackage + '" to the PackageLoader', @@ -204,9 +209,7 @@ export async function loadPackages( } if (delay > 0) { - getNopeLogger("helper-load-packages").info( - `Waiting ${delay} [s] before creating instances.` - ); + logger.info(`Waiting ${delay} [s] before creating instances.`); await sleep(delay * 1000); } @@ -223,7 +226,9 @@ export async function loadPackages( * @return {*} */ export async function loadFunctions( - filename: string = join(resolve(process.cwd()), "config", "assembly.json") + loader: INopePackageLoader, + filename: string = join(resolve(process.cwd()), "config", "settings.json"), + delay = 2 ) { let data: IConfigFile = { functions: [], @@ -238,7 +243,7 @@ export async function loadFunctions( await writeDefaultConfig(filename); // Show an Hint - getNopeLogger("helper-load-packages").warn( + logger.warn( "No configuration was present. Created a new config file in " + filename ); @@ -251,23 +256,46 @@ export async function loadFunctions( } // Define the Return Array. - const functionPackages = new Array(); + const successfull = new Array(); + + // Get the container containing all registered Services and Classes. + const CONTAINER = getCentralDecoratedContainer(); // Scan for the Package-Files // And iterate over them. for (const item of data.functions) { // Now Try to load a Package, to test whether is is an assembly. try { - const loadedFunction = (await import(resolve(item.path))) - .DESCRIPTION as IPackageDescription; - functionPackages.push(loadedFunction); + // Load the Function: + const before = new Set(CONTAINER.services.keys()); + await import(resolve(item.path)); + const after = new Set(CONTAINER.services.keys()); + + const diff = determineDifference(before, after); + if (diff.added.size > 0) { + logger.info( + "loaded services of file", + '"' + item.path + '"', + "found:" + JSON.stringify(Array.from(diff.added), undefined, 4) + ); + } + + // Mark the file as sucessfully loaded. + successfull.push(item.path); } catch (e) { - getNopeLogger("helper-load-packages").error( - "Failed Loading function-file at " + item.path - ); - getNopeLogger("helper-load-packages").error(e); + logger.error("Failed Loading function-file at " + item.path); + logger.error(e); } } - return functionPackages; + await loader.addDecoratedElements({ + consider: ["services"], + }); + + if (delay > 0) { + logger.info(`Waiting ${delay} [s] before creating instances.`); + await sleep(delay * 1000); + } + + return successfull; } diff --git a/lib/loader/nopePackageLoader.ts b/lib/loader/nopePackageLoader.ts index 6602646..5c9cc29 100644 --- a/lib/loader/nopePackageLoader.ts +++ b/lib/loader/nopePackageLoader.ts @@ -5,8 +5,12 @@ */ import { Container, injectable, interfaces } from "inversify"; -import { flatten } from "lodash"; +import { flatten, isArguments } from "lodash"; import "reflect-metadata"; +import { + getCentralDecoratedContainer, + IexportFunctionAsNopeServiceParameters, +} from "../decorators"; import { arraysEqual } from "../helpers/arrayMethods"; import { sleep } from "../helpers/async"; import { RUNNINGINNODE } from "../helpers/runtimeMethods"; @@ -701,6 +705,82 @@ export class NopePackageLoader implements INopePackageLoader { } } + /** + * Function to load all decorated elements with the decorators `exportFunctionAsNopeService` + * + * @param options + */ + async addDecoratedElements( + options: { + addServiceCallback?: ( + options: IexportFunctionAsNopeServiceParameters + ) => Promise; + addClassCallback?: (options: INopeModule) => Promise; + consider?: Array<"services" | "classes">; + } = { + consider: ["services"], + } + ): Promise { + const _this = this; + + // Get the container containing all registered Services and Classes. + const CONTAINER = getCentralDecoratedContainer(); + + // Helper to list the Promises. + const promises = new Array>(); + + if (!Array.isArray(options.consider)) { + options.consider = []; + } + + if (typeof options.addServiceCallback === "function") { + options.consider.push("services"); + } + + if (typeof options.addClassCallback === "function") { + options.consider.push("classes"); + } + + if (options.consider.includes("services")) { + for (const serviceDefintion of CONTAINER.services.values()) { + if (typeof options.addServiceCallback === "function") { + let resolve = null; + // Create a Promise, that will be completed, if + // the function is been added + const promise = new Promise((_resolve) => (resolve = _resolve)); + promises.push(promise); + + // Now we call the function to decide whether the + // service should be added or not. + options + .addServiceCallback(serviceDefintion.options) + .then((decision) => { + if (decision) { + this.dispatcher.rpcManager.registerService( + serviceDefintion.callback, + serviceDefintion.options + ); + } + resolve(null); + }); + } else { + // Just add the Service. + this.dispatcher.rpcManager.registerService( + serviceDefintion.callback, + serviceDefintion.options + ); + } + } + } + + // for (const classDefinition of CONTAINER.classes.values()){ + // this.dispatcher.rpcManager.registerService(classDefinition.,classDefinition.options) + // } + + // Wait for all Promises to be added. + await Promise.all(promises); + } + protected _disposeDefaultInstance: Array<() => Promise> = []; async dispose(): Promise { diff --git a/lib/types/nope/nopeCommunication.interface.ts b/lib/types/nope/nopeCommunication.interface.ts index 2e32418..643685e 100644 --- a/lib/types/nope/nopeCommunication.interface.ts +++ b/lib/types/nope/nopeCommunication.interface.ts @@ -372,6 +372,7 @@ export interface ICallOptions { /** * A User Provided Timeout of the call. After the timeout has been * ellapsed, the task is cancelled with a timeout error. + * The Time is given in **ms** * * @type {number} */ diff --git a/lib/types/nope/nopeModule.interface.ts b/lib/types/nope/nopeModule.interface.ts index 51d7b09..1a09773 100644 --- a/lib/types/nope/nopeModule.interface.ts +++ b/lib/types/nope/nopeModule.interface.ts @@ -298,7 +298,23 @@ export interface IFunctionOptions extends Partial { * The ui definition of the service. */ ui?: { + /** + * Custom function to render the service in the editor + */ serviceConfiguration?: TRenderConfigureServicePage; + /** + * Helper to enable auto generating a configuration + */ + autoGenBySchema?: true; + /** + * Flag to indicate, that rendering the service configuration requires + * a provider itself. This for instance is the case, if some functions + * needs to be called. + */ + requiredProvidersForRendering?: string[]; + /** + * Helper to generate the Pors based on the provided node data. + */ getPorts?: TGetPorts; }; diff --git a/lib/types/nope/nopePackageLoader.interface.ts b/lib/types/nope/nopePackageLoader.interface.ts index 61ba6de..be151bb 100644 --- a/lib/types/nope/nopePackageLoader.interface.ts +++ b/lib/types/nope/nopePackageLoader.interface.ts @@ -1,5 +1,7 @@ import { Container } from "inversify"; +import { IexportFunctionAsNopeServiceParameters } from "../../decorators"; import { INopeDispatcher } from "./nopeDispatcher.interface"; +import { INopeModule } from "./nopeModule.interface"; import { IClassDescriptor, INopeActivationHanlder, @@ -75,4 +77,16 @@ export interface INopePackageLoader { * @memberof INopePackageLoader */ generateInstances(testRequirements?: boolean): Promise; + + /** + * Helper to add the decorated Elements. + * @param options + */ + addDecoratedElements(options?: { + addServiceCallback?: ( + options: IexportFunctionAsNopeServiceParameters + ) => Promise; + addClassCallback?: (options: INopeModule) => Promise; + consider?: Array<"services" | "classes">; + }): Promise; } diff --git a/lib/types/ui/editor/IServiceEditPage.ts b/lib/types/ui/editor/IServiceEditPage.ts index 870ec4e..f20730e 100644 --- a/lib/types/ui/editor/IServiceEditPage.ts +++ b/lib/types/ui/editor/IServiceEditPage.ts @@ -3,7 +3,9 @@ * @email m.karkowski@zema.de */ +import { IRenderData } from "../helpers.interface"; import { TRenderFunctionResult } from "../layout.interface"; +import { PN } from "./INodes"; /** * Type to define the Ports of a UI: @@ -19,27 +21,34 @@ export type TServiceGetPortsReturn = { }[]; }; -export type TGetPorts = (data?: T) => TServiceGetPortsReturn; +/** + * Function, used to define the Ports of a service. + */ +export type TGetPorts = ( + options?: IRenderData & { + input: T; + } & Extension +) => Promise; export interface IServiceEditPage extends TRenderFunctionResult { /** * Function, which must return the current service-data. * * @author M.Karkowski - * @return {boolean} + * @return {Promise} * @memberof IEditPage */ - getData(): T; + getData(): Promise; /** * Function which must return true, if the Entered- * Data is valid. Otherwise the Update will be refused * * @author M.Karkowski - * @return {boolean} + * @return {Promise} * @memberof IEditPage */ - isValid(): boolean; + isValid(): Promise; /** * Element showing the type of the edit panel. diff --git a/lib/types/ui/editor/render.callbacks.ts b/lib/types/ui/editor/render.callbacks.ts index bd565df..46fba3b 100644 --- a/lib/types/ui/editor/render.callbacks.ts +++ b/lib/types/ui/editor/render.callbacks.ts @@ -13,4 +13,4 @@ export type TRenderConfigureServicePage = ( options: IRenderData & { input: T; } & Extension -) => IServiceEditPage; +) => Promise; diff --git a/lib/types/ui/helpers.interface.ts b/lib/types/ui/helpers.interface.ts index 1c9f2bb..82c7473 100644 --- a/lib/types/ui/helpers.interface.ts +++ b/lib/types/ui/helpers.interface.ts @@ -76,6 +76,7 @@ export type TLibraries = { w2confirm: (...args) => any; w2prompt: (...args) => any; w2utils: any; + nopeW2ui: any; }; w2ui: any; diff --git a/lib/types/ui/layout.interface.ts b/lib/types/ui/layout.interface.ts index 152913e..35b0f5c 100644 --- a/lib/types/ui/layout.interface.ts +++ b/lib/types/ui/layout.interface.ts @@ -860,14 +860,14 @@ export interface ILayoutOptions { * * @memberof ILayoutOptions */ - onResized?: (panels: IPossiblePanels) => void; + onResized?: (panels: IPossiblePanels) => Promise; /** * Callback, which will be used to provide the actual Editmode. * * @memberof ILayoutOptions */ - onEditModeChanged?: (editingEnabled: boolean) => void; + onEditModeChanged?: (editingEnabled: boolean) => Promise; /** * Function, which will be called before the Componented is getting destroyed. @@ -875,13 +875,12 @@ export interface ILayoutOptions { * * @memberof ILayoutOptions */ - dispose?: () => void; + dispose?: () => Promise; /** * An addtional Function which will be called before a Callback of the Context-Menu * or Toolbar will be called. * - * @type {IAdaptDataCallback} * @memberof ILayoutOptions */ adaptData: IAdaptDataCallback; @@ -903,7 +902,7 @@ export interface ILayoutOptions { * @author M.Karkowski * @memberof ILayoutOptions */ - onReady?: () => void; + onReady?: () => Promise; /** * Boolean to toggle the FullScreen @@ -952,7 +951,7 @@ export type TRenderFunction< setVisibilityOfPanel: (value: boolean) => void; layout: IBasicLayoutComponent; } -) => O; +) => Promise; /** * Base Component to render a Layout. @@ -1102,7 +1101,7 @@ export interface IBasicLayoutComponent< showOnCreate?: boolean; /** The Panel to show */ panel: ValidPanels; - }): void; + }): Promise; /** * Returns the div of the panel. diff --git a/lib/types/ui/render.callbacks.ts b/lib/types/ui/render.callbacks.ts index 2c1a418..656ba7d 100644 --- a/lib/types/ui/render.callbacks.ts +++ b/lib/types/ui/render.callbacks.ts @@ -26,7 +26,7 @@ export type TRenderInstancePage< /** The Instance to Render. */ input: T & IGenericNopeModule; } & Extension -) => TRenderFunctionResult; +) => Promise; /** UI to define an instance. */ export type TInstanceManagerPage< @@ -49,4 +49,4 @@ export type TInstanceManagerPage< ) => Promise; instances: Array; } & Extension -) => void; +) => Promise; diff --git a/lib/ui/helpers.nodejs.ts b/lib/ui/helpers.nodejs.ts index 1c7e2bb..9d5c8c0 100644 --- a/lib/ui/helpers.nodejs.ts +++ b/lib/ui/helpers.nodejs.ts @@ -14,20 +14,19 @@ import { } from "../index.browser"; import { listFunctions, listPackages } from "../index.nodejs"; import { IUiDefinition } from "../types/ui"; +import { readFile } from "node:fs/promises"; +import { getNopeLogger, replaceAll } from "../index.browser"; +import * as superagent from "superagent"; /** * Helper Function to write a default configuration. - * - * @export - * @param {string} [dir='./modules'] - * @param {string} [filename=join(resolve(process.cwd()), 'config', 'assembly.json')] */ export async function writeUiFile( options: { dir: string; filename: string; } = { - dir: "./modules", + dir: "./dist", filename: join(resolve(process.cwd()), "config", "ui.json"), } ) { @@ -93,7 +92,7 @@ export async function writeUiFile( }); } - for (const [id, data] of CONTAINER.methods.entries()) { + for (const [id, data] of CONTAINER.services.entries()) { if (data.options.ui) { uiFile.functions[id] = { id, @@ -113,7 +112,7 @@ export async function writeUiFile( * @param additionalArguments Arguments added by the nope.cli * @return {*} The Arguments */ -export function readInwriteUiFileArgs( +export function readInWriteUiFileArgs( additionalArguments: { help: string; type: "string" | "number"; @@ -156,3 +155,238 @@ export function readInwriteUiFileArgs( return args; } + +export interface IDataElement { + name: string; + originalName: string; + path: string; + keywords: string; + identifier: string; + additionalOptions: any; + uuid: string; + type: string; + date: string; +} + +export interface UploadArgs { + /** + * File containing the UI-Defintions + */ + file: string; + + /** + * Default uri of the upload server + */ + uri: string; + + /** + * The mode how to handle the ui-file. + */ + mode: "replace" | "merge"; +} + +const VALID_MODES: Array = ["replace", "merge"]; + +export const DEFAULT_SETTINGS: UploadArgs = { + file: "./config/ui.json", + uri: "http://localhost:5001", + mode: "merge", +}; + +/** + * Helper Function to Read-In the Arguments used by the + * cli-tool + * + * @return {*} + */ +export async function readInArgs( + additionalArguments: { + help: string; + type: "string" | "number"; + name: string | string; + defaultValue?: any; + }[] = [], + forcedArgs: Partial = {} +): Promise { + const parser = new ArgumentParser({ + // version: "1.0.0", + add_help: true, + description: "Command Line interface, to upload ui files", + }); + + for (const arg of additionalArguments) { + parser.add_argument(arg.name, { + help: arg.help, + default: arg.defaultValue, + type: arg.type, + }); + } + + parser.add_argument("-f", "--file", { + help: + "File containing containing the package definitions. Defaults to '" + + DEFAULT_SETTINGS.file + + "'", + default: DEFAULT_SETTINGS.file, + type: "str", + dest: "file", + }); + + parser.add_argument("-m", "--mode", { + help: + "The mode, how to handle the ui defintion: " + + // Display all Options: + VALID_MODES.map((item) => { + return '"' + item + '"'; + }).join(", ") + + '. Deaults to "' + + DEFAULT_SETTINGS.mode + + '"', + default: DEFAULT_SETTINGS.mode, + type: "str", + dest: "mode", + }); + + parser.add_argument("-u", "--uri", { + help: "The URI of the Server. Defaults to '" + DEFAULT_SETTINGS.uri + ",", + default: DEFAULT_SETTINGS.uri, + type: "str", + dest: "params", + }); + + const args: UploadArgs = parser.parse_args(); + + return Object.assign(args, forcedArgs); +} + +export async function uploadUi(args: Partial) { + const settingsToUse = Object.assign(DEFAULT_SETTINGS, args); + let localContent: any = {}; + + const logger = getNopeLogger("ui-uploader-cli"); + + try { + // Try to read in the default config file. + logger.info(`Trying to read file ${settingsToUse.file}`); + + localContent = JSON.parse( + await readFile(settingsToUse.file, { + encoding: "utf-8", + }) + ); + } catch (error) { + logger.error("Failed to read File."); + logger.error(error); + } + + if (Object.keys(settingsToUse).length == 0) { + logger.info("No Data contained. Goodbye!"); + + return; + } + + async function getFiles( + query: ( + item: IDataElement, + scope: { [index: string]: any } + ) => boolean = () => true, + scope: { [index: string]: any } = {} + ) { + const params = { + query: stringifyWithFunctions(query), + scope, + }; + + const result: IDataElement[] = ( + await superagent.post(settingsToUse.uri + "/storage/query").send(params) + ).body; + + return result; + } + + async function getContentOfNewestFile() { + // Get all Possible Files + const _files = await getFiles((item, scope) => { + return item.identifier === "ui-definition"; + }); + + let newest: IDataElement = null; + _files.map((item) => { + if (item.date > item.date) { + newest = item; + } else if (newest == null) { + newest = item; + } + }); + + if (newest) { + try { + const _file = replaceAll( + settingsToUse.uri + "/" + newest.path, + "\\", + "/" + ); + return (await superagent.get(_file)).body; + } catch (e) { + logger.error("Failed getting Data"); + logger.error(e); + } + } + return {}; + } + + logger.info( + `Uploading file '${settingsToUse.file}' to '${settingsToUse.uri}'` + ); + + let contentToUpload: any = localContent; + + if (settingsToUse.mode === "merge") { + const currentContent: any = await getContentOfNewestFile(); + contentToUpload.functions = Object.assign( + currentContent.functions, + localContent.functions + ); + contentToUpload.classes = Object.assign( + currentContent.classes, + localContent.classes + ); + } + + const params = { + name: "ui", + keywords: "ui-definition;", + identifier: "ui-definition", + data: contentToUpload, + }; + const result = await superagent + .post(settingsToUse.uri + "/storage/upload-data") + .send(params); + + logger.info("sucessfully uploaded the file."); +} + +/** + * Main Function. + * + * @export + */ +export async function main( + additionalArguments: { + help: string; + type: "string" | "number"; + name: string | string; + defaultValue?: any; + }[] = [], + forcedArgs: Partial = {} +) { + const args = await readInArgs(additionalArguments, forcedArgs); + return await uploadUi(args); +} + +export default uploadUi; + +// If requested As Main => Perform the Operation. +if (require.main === module) { + main(); +} diff --git a/package-lock.json b/package-lock.json index 7dfd85e..eee14e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nope", - "version": "1.2.1", + "version": "1.3.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nope", - "version": "1.2.1", + "version": "1.3.12", "license": "MIT", "dependencies": { "argparse": "^2.0.1", @@ -30,6 +30,7 @@ "rxjs": "^7.5.1", "socket.io": "^4.4.1", "socket.io-client": "^4.4.1", + "superagent": "^8.0.0", "ts-morph": "^13.0.2", "typescript-json-schema": "^0.52.0", "uuid": "^8.3.2", @@ -48,6 +49,7 @@ "@types/plotly.js": "^1.54.22", "@types/socket.io": "^3.0.1", "@types/socket.io-client": "^1.4.36", + "@types/superagent": "^4.1.15", "chai": "^4.3.4", "dts-bundle": "^0.7.3", "dts-bundle-webpack": "^1.0.2", @@ -442,6 +444,12 @@ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" }, + "node_modules/@types/cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", + "dev": true + }, "node_modules/@types/cors": { "version": "2.8.12", "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", @@ -528,6 +536,16 @@ "integrity": "sha512-ZJWjtFBeBy1kRSYpVbeGYTElf6BqPQUkXDlHHD4k/42byCN5Rh027f4yARHCink9sKAkbtGZXEAmR0ZCnc2/Ag==", "dev": true }, + "node_modules/@types/superagent": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.15.tgz", + "integrity": "sha512-mu/N4uvfDN2zVQQ5AYJI/g4qxn2bHB6521t1UuH09ShNWjebTqN0ZFuYK9uYjcgmI0dTQEs+Owi1EO6U0OkOZQ==", + "dev": true, + "dependencies": { + "@types/cookiejar": "*", + "@types/node": "*" + } + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -1056,6 +1074,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "node_modules/asn1.js": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", @@ -1109,6 +1132,11 @@ "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -1535,7 +1563,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -1958,6 +1985,17 @@ "node": ">=0.1.90" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", @@ -2074,6 +2112,11 @@ "node": ">= 0.6" } }, + "node_modules/cookiejar": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + }, "node_modules/copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", @@ -2241,9 +2284,9 @@ } }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { "ms": "2.1.2" }, @@ -2360,6 +2403,14 @@ "node": ">=0.10.0" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -2401,6 +2452,15 @@ "node": ">=0.10.0" } }, + "node_modules/dezalgo": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", + "integrity": "sha512-K7i4zNfT2kgQz3GylDw40ot9GAE47sFZ9EXHFSPP6zONLgH6kWXE0KWJchkbQJLBkRazq4APwZ4OwiFFlT95OQ==", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -3562,6 +3622,11 @@ "integrity": "sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==", "dev": true }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "node_modules/fastest-levenshtein": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz", @@ -3729,6 +3794,44 @@ "node": ">=0.10.0" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formidable": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.0.1.tgz", + "integrity": "sha512-rjTMNbp2BpfQShhFbR3Ruk3qk2y9jKpvMW78nJgx8QKtxjDVrwbZG+wvDOmVbifHyOUOQJXxqEy6r0faRrPzTQ==", + "dependencies": { + "dezalgo": "1.0.3", + "hexoid": "1.0.0", + "once": "1.4.0", + "qs": "6.9.3" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, + "node_modules/formidable/node_modules/qs": { + "version": "6.9.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz", + "integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==", + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/fp-and-or": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/fp-and-or/-/fp-and-or-0.1.3.tgz", @@ -3890,8 +3993,7 @@ "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -3948,7 +4050,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -4166,7 +4267,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -4200,7 +4300,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -4343,6 +4442,14 @@ "readable-stream": "^3.6.0" } }, + "node_modules/hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", + "engines": { + "node": ">=8" + } + }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -6061,6 +6168,14 @@ "node": ">= 8" } }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", @@ -6092,6 +6207,17 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", "dev": true }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/mime-db": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", @@ -14074,7 +14200,6 @@ "version": "1.12.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -14927,6 +15052,20 @@ "node": ">=8" } }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -15520,10 +15659,9 @@ "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -15691,7 +15829,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "dependencies": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -16301,6 +16438,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/superagent": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.0.0.tgz", + "integrity": "sha512-iudipXEel+SzlP9y29UBWGDjB+Zzag+eeA1iLosaR2YHBRr1Q1kC29iBrF2zIVD9fqVbpZnXkN/VJmwFMVyNWg==", + "dependencies": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.3", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^2.0.1", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.10.3", + "readable-stream": "^3.6.0", + "semver": "^7.3.7" + }, + "engines": { + "node": ">=6.4.0 <13 || >=14" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -18591,6 +18749,12 @@ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" }, + "@types/cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", + "dev": true + }, "@types/cors": { "version": "2.8.12", "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", @@ -18676,6 +18840,16 @@ "integrity": "sha512-ZJWjtFBeBy1kRSYpVbeGYTElf6BqPQUkXDlHHD4k/42byCN5Rh027f4yARHCink9sKAkbtGZXEAmR0ZCnc2/Ag==", "dev": true }, + "@types/superagent": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.15.tgz", + "integrity": "sha512-mu/N4uvfDN2zVQQ5AYJI/g4qxn2bHB6521t1UuH09ShNWjebTqN0ZFuYK9uYjcgmI0dTQEs+Owi1EO6U0OkOZQ==", + "dev": true, + "requires": { + "@types/cookiejar": "*", + "@types/node": "*" + } + }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -19107,6 +19281,11 @@ "es-abstract": "^1.19.0" } }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "asn1.js": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", @@ -19156,6 +19335,11 @@ "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -19503,7 +19687,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -19831,6 +20014,14 @@ "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "commander": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", @@ -19927,6 +20118,11 @@ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==" }, + "cookiejar": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", @@ -20080,9 +20276,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { "ms": "2.1.2" } @@ -20167,6 +20363,11 @@ "isobject": "^3.0.1" } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -20199,6 +20400,15 @@ "minimist": "^0.1.0" } }, + "dezalgo": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", + "integrity": "sha512-K7i4zNfT2kgQz3GylDw40ot9GAE47sFZ9EXHFSPP6zONLgH6kWXE0KWJchkbQJLBkRazq4APwZ4OwiFFlT95OQ==", + "requires": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -21138,6 +21348,11 @@ "integrity": "sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==", "dev": true }, + "fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "fastest-levenshtein": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz", @@ -21282,6 +21497,34 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "formidable": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.0.1.tgz", + "integrity": "sha512-rjTMNbp2BpfQShhFbR3Ruk3qk2y9jKpvMW78nJgx8QKtxjDVrwbZG+wvDOmVbifHyOUOQJXxqEy6r0faRrPzTQ==", + "requires": { + "dezalgo": "1.0.3", + "hexoid": "1.0.0", + "once": "1.4.0", + "qs": "6.9.3" + }, + "dependencies": { + "qs": { + "version": "6.9.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz", + "integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==" + } + } + }, "fp-and-or": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/fp-and-or/-/fp-and-or-0.1.3.tgz", @@ -21424,8 +21667,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "functional-red-black-tree": { "version": "1.0.1", @@ -21470,7 +21712,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -21630,7 +21871,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -21654,8 +21894,7 @@ "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" }, "has-tostringtag": { "version": "1.0.0", @@ -21766,6 +22005,11 @@ "readable-stream": "^3.6.0" } }, + "hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==" + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -23092,6 +23336,11 @@ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" + }, "micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", @@ -23119,6 +23368,11 @@ } } }, + "mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==" + }, "mime-db": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", @@ -29065,8 +29319,7 @@ "object-inspect": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true + "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==" }, "object-keys": { "version": "1.1.1", @@ -29745,6 +29998,14 @@ "escape-goat": "^2.0.0" } }, + "qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } + }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -30191,10 +30452,9 @@ "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "requires": { "lru-cache": "^6.0.0" } @@ -30330,7 +30590,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "requires": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -30824,6 +31083,24 @@ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, + "superagent": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.0.0.tgz", + "integrity": "sha512-iudipXEel+SzlP9y29UBWGDjB+Zzag+eeA1iLosaR2YHBRr1Q1kC29iBrF2zIVD9fqVbpZnXkN/VJmwFMVyNWg==", + "requires": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.3", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^2.0.1", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.10.3", + "readable-stream": "^3.6.0", + "semver": "^7.3.7" + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", diff --git a/package.json b/package.json index a3a3a7c..35c4a94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nope", - "version": "1.3.12", + "version": "1.4.1", "description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser", "files": [ "dist-nodejs/**/*", @@ -61,6 +61,7 @@ "rxjs": "^7.5.1", "socket.io": "^4.4.1", "socket.io-client": "^4.4.1", + "superagent": "^8.0.0", "ts-morph": "^13.0.2", "typescript-json-schema": "^0.52.0", "uuid": "^8.3.2", @@ -76,6 +77,7 @@ "@types/plotly.js": "^1.54.22", "@types/socket.io": "^3.0.1", "@types/socket.io-client": "^1.4.36", + "@types/superagent": "^4.1.15", "chai": "^4.3.4", "dts-bundle": "^0.7.3", "dts-bundle-webpack": "^1.0.2", diff --git a/tsconfig.browser.json b/tsconfig.browser.json index e33396e..cb43c89 100644 --- a/tsconfig.browser.json +++ b/tsconfig.browser.json @@ -15,7 +15,7 @@ "noImplicitReturns": true, "outDir": "./dist-browser", "pretty": false, - "removeComments": true, + "removeComments": false, "stripInternal": true, "downlevelIteration": true, "noImplicitAny": false,