Skip to content

Commit

Permalink
Merge pull request #250 from skadefro/master
Browse files Browse the repository at this point in the history
close 1.4.25
  • Loading branch information
skadefro authored Oct 3, 2022
2 parents ca98154 + 4e0a081 commit 442f91a
Show file tree
Hide file tree
Showing 34 changed files with 411 additions and 233 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ crash.log
.nyrc.json
dockerignore
register.js
ee
9 changes: 5 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
"program": "${workspaceRoot}/OpenFlowNodeRED/src/index.ts",
"request": "launch",
"showAsyncStacks": true,
// "runtimeArgs": [
// "--nolazy",
// "--trace-warnings"
// ],
"runtimeArgs": [
"--nolazy",
"--trace-warnings",
"--preserve-symlinks"
],
"trace": true,
"runtimeExecutable": null,
"sourceMaps": true,
Expand Down
1 change: 1 addition & 0 deletions OpenFlow/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ee
54 changes: 52 additions & 2 deletions OpenFlow/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,46 @@ import * as fs from "fs";
import * as path from "path";
import { DatabaseConnection } from "./DatabaseConnection";
// import { Logger } from "./Logger";
import { NoderedUtil } from "@openiap/openflow-api";
import { Base, NoderedUtil, Rights, WellknownIds } from "@openiap/openflow-api";
import { promiseRetry } from "./Logger";
import { Span } from "@opentelemetry/api";

export class dbConfig extends Base {
constructor() {
super();
this._type = "customer";
this.name = "Base configuration";
this.version = "0.0.1";
}
public version: string;
public needsupdate: boolean;
public updatedat: Date;
public async Save(jwt: string, parent: Span): Promise<void> {
if (this.needsupdate = true) {
this.updatedat = new Date(new Date().toISOString());
this.needsupdate = false;
this.version = Config.version;
}
Base.addRight(this, WellknownIds.admins, "admins", [Rights.full_control]);
if (NoderedUtil.IsNullEmpty(this._id)) await Config.db.InsertOne(this, "config", 1, true, jwt, parent);
if (!NoderedUtil.IsNullEmpty(this._id)) await Config.db._UpdateOne(null, this, "config", 1, true, jwt, parent);
}
public compare(version: string): number {
return this.version.localeCompare(version, undefined, { numeric: true, sensitivity: 'base' });
}
public static async Load(jwt: string, parent: Span): Promise<dbConfig> {
var conf: dbConfig = await Config.db.GetOne({ query: { "_type": "config" }, collectionname: "config", jwt }, parent);
if (conf == null) { conf = new dbConfig(); }
conf = Object.assign(new dbConfig(), conf);
conf.needsupdate = false;
if (conf.compare(Config.version) == -1) {
conf.needsupdate = true;
}
return conf;
}
}
export class Config {
public static dbConfig: dbConfig;
public static getversion(): string {
let versionfile: string = path.join(__dirname, "VERSION");
if (!fs.existsSync(versionfile)) versionfile = path.join(__dirname, "..", "VERSION")
Expand Down Expand Up @@ -75,6 +112,7 @@ export class Config {

Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
Config.text_index_name_fields = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names"));

Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
Config.auto_create_user_from_jwt = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));
Expand Down Expand Up @@ -217,9 +255,16 @@ export class Config {
Config.otel_trace_include_query = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false"));
Config.otel_trace_connection_ips = Config.parseBoolean(Config.getEnv("otel_trace_connection_ips", "false"));
Config.otel_trace_mongodb_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_per_users", "false"));
Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false"));
Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_insert_per_users", "false"));
Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false"));
Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false"));

Config.validate_user_form = Config.getEnv("validate_user_form", "");
}
public static load_drom_db(): void {
}
public static unittesting: boolean = false;
public static db: DatabaseConnection = null;
public static license_key: string = Config.getEnv("license_key", "");
Expand Down Expand Up @@ -275,6 +320,7 @@ export class Config {

public static supports_watch: boolean = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
public static ensure_indexes: boolean = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
public static text_index_name_fields: string[] = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names"));

public static auto_create_users: boolean = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
public static auto_create_user_from_jwt: boolean = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));
Expand Down Expand Up @@ -419,7 +465,11 @@ export class Config {
public static otel_trace_include_query: boolean = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false"));
public static otel_trace_connection_ips: boolean = Config.parseBoolean(Config.getEnv("otel_trace_connection_ips", "false"));
public static otel_trace_mongodb_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_per_users", "false"));

public static otel_trace_mongodb_query_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
public static otel_trace_mongodb_aggregate_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false"));
public static otel_trace_mongodb_insert_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_insert_per_users", "false"));
public static otel_trace_mongodb_update_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false"));
public static otel_trace_mongodb_delete_per_users: boolean = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false"));

public static validate_user_form: string = Config.getEnv("validate_user_form", "");

Expand Down
Loading

0 comments on commit 442f91a

Please sign in to comment.