Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@withonevision/omnihive-core

Package Overview
Dependencies
Maintainers
4
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@withonevision/omnihive-core - npm Package Compare versions

Comparing version 6.2.36 to 6.2.37

models/HiveWorkerConfig.d.ts

6

interfaces/IConfigWorker.d.ts

@@ -1,7 +0,7 @@

import { AppSettings } from "../models/AppSettings";
import { ServerConfig } from "../models/ServerConfig";
import { IHiveWorker } from "./IHiveWorker";
export interface IConfigWorker extends IHiveWorker {
get: () => Promise<AppSettings>;
set: (settings: AppSettings) => Promise<boolean>;
get: () => Promise<ServerConfig>;
set: (serverConfig: ServerConfig) => Promise<boolean>;
}
//# sourceMappingURL=IConfigWorker.d.ts.map

@@ -1,14 +0,15 @@

import { HiveWorker } from "../models/HiveWorker";
import { EnvironmentVariable } from "../models/EnvironmentVariable";
import { RegisteredHiveWorker } from "../models/RegisteredHiveWorker";
import { AppSettings } from "../models/AppSettings";
export interface IHiveWorker {
appSettings: AppSettings;
environmentVariables: EnvironmentVariable[];
metadata: any;
name: string;
registeredWorkers: RegisteredHiveWorker[];
checkObjectStructure: <T extends object>(type: {
new (): T;
}, model: any | null) => T;
config: HiveWorker;
checkMetadata: (metadata: any) => void;
getWorker: <T extends IHiveWorker | undefined>(type: string, name?: string) => T | undefined;
init: (hiveWorker: HiveWorker) => Promise<void>;
registeredWorkers: RegisteredHiveWorker[];
init: (name: string, metadata?: any) => Promise<void>;
}
//# sourceMappingURL=IHiveWorker.d.ts.map

@@ -0,12 +1,15 @@

/// <reference types="src/types/globals.omnihive" />
import { EnvironmentVariable } from "./EnvironmentVariable";
import { RegisteredHiveWorker } from "./RegisteredHiveWorker";
import { IHiveWorker } from "../interfaces/IHiveWorker";
import { HiveWorker } from "./HiveWorker";
import { AppSettings } from "./AppSettings";
import { WorkerGetterBase } from "./WorkerGetterBase";
export declare abstract class HiveWorkerBase extends WorkerGetterBase implements IHiveWorker {
constructor();
config: HiveWorker;
appSettings: AppSettings;
init(config: HiveWorker): Promise<void>;
export declare abstract class HiveWorkerBase implements IHiveWorker {
environmentVariables: EnvironmentVariable[];
metadata: any;
name: string;
registeredWorkers: RegisteredHiveWorker[];
init(name: string, metadata?: any): Promise<void>;
checkObjectStructure: <T extends object>(type: new () => T, model: any | null) => T;
checkMetadata: (metadata: any) => void;
getWorker<T extends IHiveWorker | undefined>(type: string, name?: string): T | undefined;
}
//# sourceMappingURL=HiveWorkerBase.d.ts.map

@@ -14,7 +14,8 @@ "use strict";

const ObjectHelper_1 = require("../helpers/ObjectHelper");
const WorkerGetterBase_1 = require("./WorkerGetterBase");
const IsHelper_1 = require("../helpers/IsHelper");
class HiveWorkerBase extends WorkerGetterBase_1.WorkerGetterBase {
const EnvironmentVariableType_1 = require("../enums/EnvironmentVariableType");
class HiveWorkerBase {
constructor() {
super();
this.environmentVariables = [];
this.registeredWorkers = [];
this.checkObjectStructure = (type, model) => {

@@ -25,3 +26,3 @@ const objectData = ObjectHelper_1.ObjectHelper.createStrict(type, model);

if (IsHelper_1.IsHelper.isNullOrUndefined(objectAny[key])) {
throw new Error(`Object key ${key} is null or undefined on hive worker ${this.config.name}`);
throw new Error(`Object key ${key} is null or undefined on hive worker ${this.name}`);
}

@@ -31,13 +32,52 @@ });

};
this.checkMetadata = (metadata) => {
Object.keys(metadata).forEach((metaKey) => {
if (metadata[metaKey].toString().startsWith("${") &&
metadata[metaKey].toString().endsWith("}")) {
let metaValue = metadata[metaKey];
metaValue = metaValue.substr(2, metaValue.length - 3);
const environmentVariable = this.environmentVariables.find((variable) => variable.key === metaValue);
if (IsHelper_1.IsHelper.isNullOrUndefined(environmentVariable)) {
throw new Error(`Metadata key ${metaKey} invalid or not set for worker ${this.name}`);
}
switch (environmentVariable.type) {
case EnvironmentVariableType_1.EnvironmentVariableType.Boolean:
this.metadata[metaKey] = environmentVariable.value === "true";
break;
case EnvironmentVariableType_1.EnvironmentVariableType.Number:
this.metadata[metaKey] = Number(environmentVariable.value);
break;
default:
this.metadata[metaKey] = String(environmentVariable.value);
break;
}
}
});
};
}
init(config) {
init(name, metadata) {
return __awaiter(this, void 0, void 0, function* () {
if (IsHelper_1.IsHelper.isNullOrUndefined(config) || IsHelper_1.IsHelper.isEmptyObject(config)) {
throw new Error("Configuration not specified");
this.name = name;
this.metadata = metadata;
if (!IsHelper_1.IsHelper.isNullOrUndefined(metadata)) {
this.checkMetadata(metadata);
}
this.config = config;
});
}
getWorker(type, name) {
if (!IsHelper_1.IsHelper.isNullOrUndefined(name)) {
const namedWorker = this.registeredWorkers.find((value) => value.name === name && value.type === type);
if (!IsHelper_1.IsHelper.isNullOrUndefined(namedWorker)) {
return namedWorker.instance;
}
return undefined;
}
const anyWorkers = this.registeredWorkers.filter((value) => value.type === type);
if (!IsHelper_1.IsHelper.isNullOrUndefined(anyWorkers) && !IsHelper_1.IsHelper.isEmptyArray(anyWorkers)) {
return anyWorkers[0].instance;
}
return undefined;
}
}
exports.HiveWorkerBase = HiveWorkerBase;
//# sourceMappingURL=HiveWorkerBase.js.map

@@ -0,7 +1,10 @@

import { HiveWorkerType } from "../enums/HiveWorkerType";
import { RegisteredHiveWorkerSection } from "../enums/RegisteredHiveWorkerSection";
import { HiveWorker } from "./HiveWorker";
export declare class RegisteredHiveWorker extends HiveWorker {
export declare class RegisteredHiveWorker {
instance: any;
name: string;
type: HiveWorkerType | string;
metadata: any;
section: RegisteredHiveWorkerSection;
}
//# sourceMappingURL=RegisteredHiveWorker.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegisteredHiveWorker = void 0;
const HiveWorkerType_1 = require("../enums/HiveWorkerType");
const RegisteredHiveWorkerSection_1 = require("../enums/RegisteredHiveWorkerSection");
const HiveWorker_1 = require("./HiveWorker");
class RegisteredHiveWorker extends HiveWorker_1.HiveWorker {
class RegisteredHiveWorker {
constructor() {
super(...arguments);
this.name = "";
this.type = HiveWorkerType_1.HiveWorkerType.User;
this.section = RegisteredHiveWorkerSection_1.RegisteredHiveWorkerSection.User;

@@ -10,0 +11,0 @@ }

{
"name": "@withonevision/omnihive-core",
"version": "6.2.36",
"version": "6.2.37",
"description": "OmniHive Core",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc