This commit is contained in:
Martin Karkowski 2021-08-30 12:42:33 +02:00
commit 227f5a0ac0
27 changed files with 685 additions and 271 deletions

View File

@ -2,7 +2,7 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:30:10
* @modify date 2021-08-04 15:44:45
* @modify date 2021-08-27 20:10:12
* @desc [description]
*/
export {
@ -15,6 +15,7 @@ export {
ICommunicationInterface,
ICommunicationMirror,
IEmitter,
IExecutingTaskMsg,
IExternalEventMsg,
IInstanceCreationMsg,
IInstanceDescriptionMsg,
@ -22,15 +23,20 @@ export {
IRequestOfService,
IRequestTaskMsg,
IResponseTaskMsg,
IRpcUnregisterMsg,
ITaskCancelationMsg,
ValidEventTypesOfMirror
} from "../types/nope/nopeCommunication.interface";
export {
ENopeDispatcherStatus,
IDispatcherInfo,
INopeDispatcher, INopeDispatcherOptions
INopeDispatcher,
INopeDispatcherOptions,
ValidSelectorFunction
} from "../types/nope/nopeDispatcher.interface";
export { Bridge } from "./bridge";
export { getLayer, validLayers } from "./getLayer";
export * as Layers from "./layers/index.browser";
export * as Mirrors from "./mirrors/index.browser";
export { Layers, Mirrors };
import * as Layers from "./layers/index.browser";
import * as Mirrors from "./mirrors/index.browser";

View File

@ -2,10 +2,9 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:30:10
* @modify date 2021-08-04 15:45:57
* @modify date 2021-08-04 15:44:45
* @desc [description]
*/
export {
IAvailableInstanceGeneratorsMsg,
IAvailableInstancesMsg,
@ -16,19 +15,28 @@ export {
ICommunicationInterface,
ICommunicationMirror,
IEmitter,
IExecutingTaskMsg,
IExternalEventMsg,
IInstanceCreationMsg,
IInstanceDescriptionMsg,
IInstanceRemovalMsg,
INopeDispatcherOptions,
IRequestOfService,
IRequestTaskMsg,
IResponseTaskMsg,
IRpcUnregisterMsg,
ITaskCancelationMsg,
ValidEventTypesOfMirror
} from "../types/nope/nopeCommunication.interface";
export {
ENopeDispatcherStatus,
IDispatcherInfo,
INopeDispatcher,
INopeDispatcherOptions,
ValidSelectorFunction
} from "../types/nope/nopeDispatcher.interface";
export { Bridge } from "./bridge";
export { getLayer, validLayers } from "./getLayer";
export * as Layers from "./layers/index.nodejs";
export * as Mirrors from "./mirrors/index.nodejs";
export { Layers, Mirrors };
import * as Layers from "./layers/index.nodejs";
import * as Mirrors from "./mirrors/index.nodejs";

View File

@ -8,8 +8,7 @@
export {
AmqpInterface,
AmqpLayer,
QueuePublishOptions as AmqpQueuePublishOptions,
QueueSubscribeOptions as AmqpQueueSubscribeOptions,
SubscriptionOptions as AmqpSubscriptionOptions
QueuePublishOptions as IAmqpQueuePublishOptions,
QueueSubscribeOptions as IAmqpQueueSubscribeOptions,
SubscriptionOptions as IAmqpSubscriptionOptions
} from "./amqpLayer";

View File

@ -2,15 +2,9 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:31:05
* @modify date 2021-08-04 15:31:05
* @modify date 2021-08-27 20:11:27
* @desc [description]
*/
export {
AmqpInterface,
AmqpLayer,
QueuePublishOptions as AmqpQueuePublishOptions,
QueueSubscribeOptions as AmqpQueueSubscribeOptions,
SubscriptionOptions as AmqpSubscriptionOptions
} from "./amqpLayer";
export { MQTTLayer } from "./mqttLayer";
export * from "./index.browser";
export { MQTTLayer } from "./mqttLayer";

View File

@ -2,9 +2,9 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:33:37
* @modify date 2021-08-04 15:33:37
* @modify date 2021-08-27 20:10:42
* @desc [description]
*/
export { EventMirror } from "./eventMirror";
export { IoSocketMirrorClient } from "./ioSocketMirrorClient";

View File

@ -2,9 +2,9 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:33:37
* @modify date 2021-08-04 15:33:37
* @modify date 2021-08-27 20:10:48
* @desc [description]
*/
export { EventMirror } from "./eventMirror";
export { IoSocketMirrorClient } from "./ioSocketMirrorClient";

10
lib/decorators/index.ts Normal file
View File

@ -0,0 +1,10 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 19:47:47
* @modify date 2021-08-27 19:47:47
* @desc [description]
*/
export { exportFunctionToDispatcher, IExportFunctionToDispatcherParameters } from "./dispatcherDecorators";
export { exportMethod, exportProperty } from "./moduleDecorators";

16
lib/dispatcher/index.ts Normal file
View File

@ -0,0 +1,16 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 19:49:25
* @modify date 2021-08-27 19:49:25
* @desc [description]
*/
export {
exportFunctionToDispatcher,
exportMethod,
exportProperty,
IExportFunctionToDispatcherParameters
} from "../decorators/index";
export { getDispatcher } from "./getDispatcher";
export { getLinkedDispatcher } from "./getLinkedDispatcher";

File diff suppressed because it is too large Load Diff

20
lib/helpers/async.ts Normal file
View File

@ -0,0 +1,20 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 21:16:23
* @modify date 2021-08-27 21:16:23
* @desc [description]
*/
import { promisify } from "util";
export const sleep = promisify(setTimeout);
/**
* Tests if a Function is async or not.
* @param func
* @returns
*/
export function isAsyncFunction(func: (...args) => any): boolean {
return func.constructor.name === "AsyncFunction";
}

View File

@ -0,0 +1,34 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 19:50:23
* @modify date 2021-08-27 19:50:23
* @desc [description]
*/
import * as arrays from "./arrayMethods";
import * as async from "./async";
import * as files from "./fileMethods";
import * as ids from "./idMethods";
import * as json from "./jsonMethods";
import * as schema from "./jsonSchemaMethods";
import * as lazy from "./lazyMethods";
import * as objects from "./objectMethods";
import * as runtime from "./runtimeMethods";
import * as sets from "./setMethods";
import * as singletons from "./singletonMethod";
import * as strings from "./singletonMethod";
export {
async,
arrays,
ids,
json,
lazy,
objects,
sets,
schema,
singletons,
strings,
runtime,
files
};

View File

@ -0,0 +1,11 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 19:50:23
* @modify date 2021-08-27 19:50:23
* @desc [description]
*/
export * from "./index.browser";
export { files };
import * as files from "./fileMethods";

View File

@ -2,9 +2,30 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:46:01
* @modify date 2021-08-04 15:46:01
* @modify date 2021-08-27 20:23:38
* @desc [description]
*/
export * as communcation from "./communication/index.browser";
import "reflect-metadata";
import * as communcation from "./communication/index.browser";
import * as dispatcher from "./dispatcher/index";
import * as helpers from "./helpers/index.browser";
import * as loader from "./loader/index.browser";
import * as logger from "./logger/index.browser";
import * as modules from "./module/index";
import * as observables from "./observables/index";
import * as promises from "./promise/index";
import * as types from "./types/index";
export * from "./logger/index.browser";
export {
communcation,
dispatcher,
helpers,
loader,
logger,
types,
modules,
observables,
promises
};

View File

@ -2,10 +2,34 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-04 15:46:01
* @modify date 2021-08-04 15:47:56
* @modify date 2021-08-27 20:23:34
* @desc [description]
*/
export { readInArgs as readInRunArgs, runNopeBackend } from "./cli/runNopeBackend";
export * as communcation from "./communication/index.nodejs";
import "reflect-metadata";
import * as communcation from "./communication/index.nodejs";
import * as dispatcher from "./dispatcher/index";
import * as helpers from "./helpers/index.nodejs";
import * as loader from "./loader/index.nodejs";
import * as logger from "./logger/index.nodejs";
import * as modules from "./module/index";
import * as observables from "./observables/index";
import * as promises from "./promise/index";
import * as types from "./types/index";
export {
readInArgs as readInRunNopeBackendArgs,
runNopeBackend
} from "./cli/runNopeBackend";
export * from "./logger/index.nodejs";
export {
communcation,
dispatcher,
helpers,
loader,
logger,
types,
modules,
observables,
promises
};

View File

@ -0,0 +1,11 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:19:51
* @modify date 2021-08-27 20:19:51
* @desc [description]
*/
export { generateNopeBasicPackage } from "./generateNopeBasicPackage";
export { getPackageLoader } from "./getPackageLoader";
export { NopePackageLoader } from "./nopePackageLoader";

View File

@ -0,0 +1,18 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:19:51
* @modify date 2021-08-27 20:19:51
* @desc [description]
*/
export * from "./index.browser";
export {
IConfigFile,
IPackageConfig,
listFunctions,
listPackages,
loadFunctions,
loadPackages,
writeDefaultConfig
} from "./loadPackages";

View File

@ -0,0 +1,11 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 19:57:08
* @modify date 2021-08-27 19:57:08
* @desc [description]
*/
export { getCentralNopeLogger, getNopeLogger } from "./getLogger";
export { LoggerLevels } from "./nopeLogger";
export { setGlobalLoggerLevel } from "./setGlobalLoggerLevel";

View File

@ -0,0 +1,10 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:19:05
* @modify date 2021-08-27 20:19:05
* @desc [description]
*/
export { generateLogfilePath, useLogFile } from "./fileLogging";
export * from "./index.browser";

13
lib/module/index.ts Normal file
View File

@ -0,0 +1,13 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:28:44
* @modify date 2021-08-27 20:28:44
* @desc [description]
*/
export * from "../types/nope/nopeModule.interface";
export { NopeBaseModule } from "./BaseModule";
export { InjectableNopeBaseModule } from "./BaseModule.injectable";
export { NopeGenericModule } from "./GenericModule";
export { InjectableNopeGenericModule } from "./GenericModule.injectable";

11
lib/observables/index.ts Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:29:38
* @modify date 2021-08-27 20:29:38
* @desc [description]
*/
export * from "../types/nope/nopeObservable.interface";
export { NopeObservable } from "./nopeObservable";
export { InjectableNopeObservable } from "./nopeObservable.injectable";

View File

@ -30,7 +30,8 @@ import {
* - enables performing a subscription with synced call or a immediate call.
*/
export class NopeObservable<T, S = T, G = T>
implements INopeObservable<T, S, G> {
implements INopeObservable<T, S, G>
{
public observable: BehaviorSubject<G> = new BehaviorSubject<G>(undefined);
public readonly id: string = generateId();
@ -87,7 +88,7 @@ export class NopeObservable<T, S = T, G = T>
this._value = adapted.data;
} else {
// Adapt the Value if required.
this._value = (value as any) as T;
this._value = value as any as T;
}
const valueToPublish = this.getContent();
@ -205,7 +206,7 @@ export class NopeObservable<T, S = T, G = T>
*/
public getContent(): G | null {
if (this.getter !== null) return this.getter(this._value);
return (this._value as any) as G;
return this._value as any as G;
}
/**
@ -311,7 +312,7 @@ export class NopeObservable<T, S = T, G = T>
pipe?: IPipe<T | G, K>;
} = {}
): Subscription {
let observable: Observable<K> = (this as any) as Observable<K>;
let observable: Observable<K> = this as any as Observable<K>;
if (options.pipe) {
observable = options.pipe(options.scope, this.observable);
@ -357,7 +358,8 @@ export class NopeObservable<T, S = T, G = T>
* @param options Additional Options for the Wait Function.
*/
public waitFor(
testCallback: IwaitForCallback<G>,
testCallback: IwaitForCallback<G> = (value) =>
(value as any as boolean) == true,
options: INopeWaitForOpitions = { testCurrent: true }
): Promise<G> {
const _this = this;

9
lib/promise/index.ts Normal file
View File

@ -0,0 +1,9 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:31:04
* @modify date 2021-08-27 20:31:04
* @desc [description]
*/
export * from "../types/nope/nopePromise.interface";
export { NopePromise } from "./nopePromise";

View File

@ -1,6 +1,14 @@
export const DISPATCHER_INSTANCE = Symbol('nope.dispatcher.instance');
export const DISPATCHER_OPTIONS = Symbol('nope.dispatcher.options');
export const OBSERVABLE_FACTORY = Symbol('nope.observable.factory');
export const OBSERVABLE_INSTANCE = Symbol('nope.observable.instance');
export const COMMUNICATION_LAYER = Symbol('nope.communication.layer');
export const LOADER = Symbol('nope.package.loader');
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:31:42
* @modify date 2021-08-27 20:31:42
* @desc [description]
*/
export const DISPATCHER_INSTANCE = Symbol("nope.dispatcher.instance");
export const DISPATCHER_OPTIONS = Symbol("nope.dispatcher.options");
export const OBSERVABLE_FACTORY = Symbol("nope.observable.factory");
export const OBSERVABLE_INSTANCE = Symbol("nope.observable.instance");
export const COMMUNICATION_LAYER = Symbol("nope.communication.layer");
export const LOADER = Symbol("nope.package.loader");

11
lib/types/index.ts Normal file
View File

@ -0,0 +1,11 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:24:15
* @modify date 2021-08-27 20:24:15
* @desc [description]
*/
import * as nope from "./nope/index";
export * from "./IJSONSchema";
export { nope };

17
lib/types/nope/index.ts Normal file
View File

@ -0,0 +1,17 @@
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2021-08-27 20:24:15
* @modify date 2021-08-27 20:24:15
* @desc [description]
*/
export * from "./nopeCommunication.interface";
export * from "./nopeDescriptor.interface";
export * from "./nopeDispatcher.interface";
export * from "./nopeModule.interface";
export * from "./nopeObservable.interface";
export * from "./nopePackage.interface";
export * from "./nopePackageLoader.interface";
export * from "./nopePromise.interface";
export * from "./remoteInstance.interface";

View File

@ -205,7 +205,7 @@ export interface INopeObservable<T, S = T, G = T> {
* @param options Additional Options for the Wait Function.
*/
waitFor(
testCallback: IwaitForCallback<G>,
testCallback?: IwaitForCallback<G>,
options?: INopeWaitForOpitions
): Promise<G>;

View File

@ -18,11 +18,10 @@
"rootDir": "./",
"stripInternal": true,
"downlevelIteration": true,
"noImplicitAny": false
"noImplicitAny": false,
"declaration": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"lib",
"open-api",
"src",