zet-lib 1.5.14 → 1.5.16

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/lib/Mail.js CHANGED
@@ -6,6 +6,10 @@ const io = require('./io')
6
6
  const moment = require('moment')
7
7
  const config = require('dotenv').config()
8
8
 
9
+ if (typeof global.dirRoot === 'undefined') {
10
+ global.dirRoot = Util.dirRoot;
11
+ }
12
+
9
13
  const MAIL = {}
10
14
  //process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
11
15
 
package/lib/Util.js CHANGED
@@ -7,6 +7,42 @@ const sha256 = require("js-sha256");
7
7
 
8
8
  const Util = {};
9
9
 
10
+
11
+ // Global directory root - automatically detect application root
12
+ Util.dirRoot = (() => {
13
+ // Start from the zet-lib directory and navigate up to find the main application root
14
+ let currentDir = __dirname; // This is zet-lib/lib/
15
+
16
+ // Navigate up 3 levels: lib/ -> zet-lib/ -> node_modules/ -> fins_node/
17
+ currentDir = path.dirname(currentDir); // zet-lib/
18
+ currentDir = path.dirname(currentDir); // node_modules/
19
+ currentDir = path.dirname(currentDir); // fins_node/ (main app root)
20
+
21
+ // Verify this is the correct application root
22
+ const hasPackageJson = fs.existsSync(path.join(currentDir, 'package.json'));
23
+ const hasAppJs = fs.existsSync(path.join(currentDir, 'app.js'));
24
+
25
+ if (hasPackageJson && hasAppJs) {
26
+ return currentDir;
27
+ }
28
+
29
+ // Fallback: try to find the app root by looking for typical Node.js app files
30
+ let searchDir = currentDir;
31
+ while (searchDir !== path.dirname(searchDir)) {
32
+ const hasPackageJson = fs.existsSync(path.join(searchDir, 'package.json'));
33
+ const hasAppJs = fs.existsSync(path.join(searchDir, 'app.js'));
34
+
35
+ if (hasPackageJson && hasAppJs) {
36
+ return searchDir;
37
+ }
38
+
39
+ searchDir = path.dirname(searchDir);
40
+ }
41
+
42
+ // Final fallback to the calculated directory
43
+ return currentDir;
44
+ })();
45
+
10
46
  // Constants
11
47
  Util.tab = "\t";
12
48
  Util.NEW_LINE = "\n";
@@ -34,7 +70,7 @@ Util.excelSequence = function () {
34
70
  const arr = [...abjads];
35
71
  let num = 26;
36
72
 
37
- for (let char = 0; char < 13; char++) {
73
+ for (let char = 0; char < 26; char++) {
38
74
  for (let idx = 0; idx < 26; idx++) {
39
75
  arr[num++] = abjads[char] + abjads[idx];
40
76
  }
package/lib/zAppRouter.js CHANGED
@@ -29,6 +29,10 @@ const fetch = require("isomorphic-fetch");
29
29
  const JSZip = require("jszip");
30
30
  const zDropbox = require("./zDropbox");
31
31
 
32
+ if (typeof global.dirRoot === 'undefined') {
33
+ global.dirRoot = Util.dirRoot;
34
+ }
35
+
32
36
  /*
33
37
  ajax Post
34
38
  */
package/lib/zDropbox.js CHANGED
@@ -3,6 +3,10 @@ const { Dropbox } = require("dropbox");
3
3
  const fetch = require("isomorphic-fetch");
4
4
  const Util = require("./Util");
5
5
 
6
+ if (typeof global.dirRoot === 'undefined') {
7
+ global.dirRoot = Util.dirRoot;
8
+ }
9
+
6
10
  const zDropbox = {};
7
11
 
8
12
  let dbx = new Dropbox({
@@ -16,6 +16,10 @@ const ejs = require("ejs");
16
16
  var app = express();
17
17
  const path = require("path");
18
18
 
19
+ if (typeof global.dirRoot === 'undefined') {
20
+ global.dirRoot = Util.dirRoot;
21
+ }
22
+
19
23
  const nots = [
20
24
  "index",
21
25
  "uploads",
@@ -12,6 +12,9 @@ const moduleLib = require('./moduleLib');
12
12
  const config = require('dotenv').config();
13
13
  const ejs = require('ejs');
14
14
 
15
+ if (typeof global.dirRoot === 'undefined') {
16
+ global.dirRoot = Util.dirRoot;
17
+ }
15
18
  /*
16
19
  icons list for tabler and set to /public/js
17
20
  */
package/lib/zPage.js CHANGED
@@ -12,6 +12,9 @@ const connection = require('./connection');
12
12
  const Util = require('./Util');
13
13
  const myCache = require('./cache');
14
14
 
15
+ if (typeof global.dirRoot === 'undefined') {
16
+ global.dirRoot = Util.dirRoot;
17
+ }
15
18
  const zpage = {};
16
19
 
17
20
  zpage.build = async (req, res) => {
package/lib/zReport.js CHANGED
@@ -14,6 +14,9 @@ const config = require('dotenv').config()
14
14
  const zReport = {}
15
15
  const myCache = require('./cache')
16
16
 
17
+ if (typeof global.dirRoot === 'undefined') {
18
+ global.dirRoot = Util.dirRoot;
19
+ }
17
20
  /*
18
21
  Custom Reports
19
22
  Report Generator
package/lib/zRoute.js CHANGED
@@ -24,6 +24,9 @@ const readXlsxFile = require("read-excel-file/node");
24
24
  //const { Dropbox } = require("dropbox");
25
25
  const zDropbox = require("./zDropbox");
26
26
 
27
+ if (typeof global.dirRoot === 'undefined') {
28
+ global.dirRoot = Util.dirRoot;
29
+ }
27
30
  const zRoute = {};
28
31
 
29
32
  zRoute.tableHasNoCompanyId = ["zcompany", "zrole", "zgrid"];
@@ -11,6 +11,10 @@ const Model = require('./Model')
11
11
  const ejs = require('ejs')
12
12
  const pm2 = require("pm2");
13
13
 
14
+ if (typeof global.dirRoot === 'undefined') {
15
+ global.dirRoot = Util.dirRoot;
16
+ }
17
+
14
18
  router.get('/', csrfProtection, async (req, res) => {
15
19
  const nots = ['index', 'uploads', 'js', 'css', 'log', 'generator', 'zmenu', 'zgenerator', 'zfields', 'zrole', 'zfunction', 'zgrid', 'zgrid_default', 'zpage', 'zlayout', 'zerror', 'zuser_company']
16
20
  let table = req.query.table || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"