@nsshunt/stsdatamanagement 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/databaseutils.js CHANGED
@@ -2,6 +2,7 @@ const prompts = require('prompts');
2
2
  const fs = require('fs');
3
3
  require('colors');
4
4
  let crypto = require('crypto');
5
+ const goptions = require('@nsshunt/stsconfig').$options;
5
6
 
6
7
  const { PGPoolManager } = require('./pgpoolmanager');
7
8
  const { PGAccessLayer } = require('./pgaccesslayer');
@@ -21,10 +22,10 @@ class DatabaseUtils
21
22
  this.#accessLayer = accessLayer;
22
23
  }
23
24
 
24
- #_RegisterRolesAndPermissions = async(blcauth, scriptfolder) => {
25
+ #_RegisterRolesAndPermissions = async(blcauth) => {
25
26
  this.#debug(`Registering Roles and Role Permissions.`.yellow);
26
27
  console.log(`Registering Roles and Role Permissions.`.yellow);
27
- const rolePermissionFile = `${scriptfolder}/role-permission.json`;
28
+ const rolePermissionFile = `${goptions.databasescriptfolder}/role-permission.json`;
28
29
  const rawdata = fs.readFileSync(rolePermissionFile);
29
30
  let rolePermissions = JSON.parse(rawdata);
30
31
  for (const [, rolePermission] of Object.entries(rolePermissions)) {
@@ -39,10 +40,10 @@ class DatabaseUtils
39
40
  return true;
40
41
  }
41
42
 
42
- #_RegisterUsersAndRoles = async(blcauth, scriptfolder) => {
43
+ #_RegisterUsersAndRoles = async(blcauth) => {
43
44
  this.#debug(`Registering Users and Roles.`.yellow);
44
45
  console.log(`Registering Users and Roles.`.yellow);
45
- const roleFile = `${scriptfolder}/user-role.json`;
46
+ const roleFile = `${goptions.databasescriptfolder}/user-role.json`;
46
47
  let rawdata = fs.readFileSync(roleFile);
47
48
  let userroles = JSON.parse(rawdata);
48
49
  for (const [, user] of Object.entries(userroles)) {
@@ -57,10 +58,10 @@ class DatabaseUtils
57
58
  return true;
58
59
  }
59
60
 
60
- #_RegisterApplications = async(blcauth, scriptfolder) => {
61
+ #_RegisterApplications = async(blcauth) => {
61
62
  this.#debug(`Registering Applications.`.yellow);
62
63
  console.log(`Registering Applications.`.yellow);
63
- const roleFile = `${scriptfolder}/applications.json`;
64
+ const roleFile = `${goptions.databasescriptfolder}/applications.json`;
64
65
  let rawdata = fs.readFileSync(roleFile);
65
66
  let applications = JSON.parse(rawdata);
66
67
  for (const [, application] of Object.entries(applications)) {
@@ -77,10 +78,10 @@ class DatabaseUtils
77
78
  return true;
78
79
  }
79
80
 
80
- #_RegisterAPIs = async(blcauth, scriptfolder) => {
81
+ #_RegisterAPIs = async(blcauth) => {
81
82
  this.#debug(`Registering APIs.`.yellow);
82
83
  console.log(`Registering APIs.`.yellow);
83
- const roleFile = `${scriptfolder}/apis.json`;
84
+ const roleFile = `${goptions.databasescriptfolder}/apis.json`;
84
85
  let rawdata = fs.readFileSync(roleFile);
85
86
  let apis = JSON.parse(rawdata);
86
87
  for (const [, api] of Object.entries(apis)) {
@@ -100,9 +101,8 @@ class DatabaseUtils
100
101
  createfreshdatabase = async (options) =>
101
102
  {
102
103
  let fname = 'createfreshdatabase';
103
- const { start, entries, minextradata, maxextradata, scriptfolder } = options;
104
- let builddbscript = `${scriptfolder}/builddb.sql`;
105
- //let builddbscript = goptions.databasescriptfolder + '/builddb.sql'
104
+ const { start, entries, minextradata, maxextradata } = options;
105
+ let builddbscript = `${goptions.databasescriptfolder}/builddb.sql`;
106
106
  this.#debug(`Database Build Script: [${builddbscript}]`.yellow);
107
107
 
108
108
  try
@@ -137,15 +137,15 @@ class DatabaseUtils
137
137
  const blcauth = new BLCAuth(localAccesslayer);
138
138
  let status = true;
139
139
 
140
- status = await this.#_RegisterUsersAndRoles(blcauth, scriptfolder);
140
+ status = await this.#_RegisterUsersAndRoles(blcauth);
141
141
  if (status) {
142
- status = await this.#_RegisterRolesAndPermissions(blcauth, scriptfolder);
142
+ status = await this.#_RegisterRolesAndPermissions(blcauth);
143
143
  }
144
144
  if (status) {
145
- status = await this.#_RegisterApplications(blcauth, scriptfolder);
145
+ status = await this.#_RegisterApplications(blcauth);
146
146
  }
147
147
  if (status) {
148
- status = await this.#_RegisterAPIs(blcauth, scriptfolder);
148
+ status = await this.#_RegisterAPIs(blcauth);
149
149
  }
150
150
 
151
151
  if (status) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsdatamanagement",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "STS Data Management Modules, Utilities and Services",
5
5
  "main": "dbaccess.js",
6
6
  "dependencies": {
package/setupdb.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Use;
2
2
  // DB_HOST=localhost DB_PORT=5432 DB_SCRIPT_FOLDER=./db-scripts DB_PASSWORD=postgres DB_USER=postgres DEBUG=procz* node setupdb.js
3
- // DB_HOST=localhost DB_PORT=5432 DB_PASSWORD=postgres DB_USER=postgres DEBUG=procz* node setupdb.js
4
3
 
5
4
  const { DatabaseUtils } = require('./databaseutils.js');
6
5
 
@@ -10,8 +9,7 @@ module.exports = {
10
9
  start: 0,
11
10
  entries: 10000,
12
11
  minextradata: 0,
13
- maxextradata: 1000,
14
- scriptfolder: './db-scripts'
12
+ maxextradata: 1000
15
13
  });
16
14
  }
17
15
  };