@underpostnet/underpost 2.8.1 → 2.8.5

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.
Files changed (105) hide show
  1. package/.dockerignore +1 -0
  2. package/.github/workflows/ghpkg.yml +20 -50
  3. package/.github/workflows/npmpkg.yml +67 -0
  4. package/.github/workflows/publish.yml +5 -5
  5. package/.github/workflows/pwa-microservices-template.page.yml +13 -5
  6. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  7. package/.vscode/extensions.json +17 -71
  8. package/.vscode/settings.json +14 -3
  9. package/AUTHORS.md +16 -5
  10. package/CHANGELOG.md +79 -3
  11. package/Dockerfile +24 -66
  12. package/README.md +1 -28
  13. package/bin/build.js +161 -0
  14. package/bin/db.js +2 -24
  15. package/bin/deploy.js +111 -82
  16. package/bin/file.js +59 -16
  17. package/bin/index.js +168 -58
  18. package/bin/ssl.js +19 -11
  19. package/bin/util.js +9 -97
  20. package/bin/vs.js +25 -2
  21. package/conf.js +31 -138
  22. package/docker-compose.yml +1 -1
  23. package/manifests/core/kustomization.yaml +11 -0
  24. package/manifests/core/underpost-engine-backup-access.yaml +16 -0
  25. package/manifests/core/underpost-engine-backup-pv-pvc.yaml +22 -0
  26. package/manifests/core/underpost-engine-headless-service.yaml +10 -0
  27. package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +40 -0
  28. package/manifests/core/underpost-engine-mongodb-configmap.yaml +26 -0
  29. package/manifests/core/underpost-engine-pv-pvc.yaml +23 -0
  30. package/manifests/core/underpost-engine-statefulset.yaml +91 -0
  31. package/manifests/deployment/mongo-express/deployment.yaml +60 -0
  32. package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
  33. package/manifests/kind-config.yaml +12 -0
  34. package/manifests/letsencrypt-prod.yaml +15 -0
  35. package/manifests/mariadb/config.yaml +10 -0
  36. package/manifests/mariadb/kustomization.yaml +9 -0
  37. package/manifests/mariadb/pv.yaml +12 -0
  38. package/manifests/mariadb/pvc.yaml +10 -0
  39. package/manifests/mariadb/secret.yaml +8 -0
  40. package/manifests/mariadb/service.yaml +10 -0
  41. package/manifests/mariadb/statefulset.yaml +55 -0
  42. package/manifests/mongodb/backup-access.yaml +16 -0
  43. package/manifests/mongodb/backup-cronjob.yaml +42 -0
  44. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  45. package/manifests/mongodb/configmap.yaml +26 -0
  46. package/manifests/mongodb/headless-service.yaml +10 -0
  47. package/manifests/mongodb/kustomization.yaml +11 -0
  48. package/manifests/mongodb/pv-pvc.yaml +23 -0
  49. package/manifests/mongodb/statefulset.yaml +125 -0
  50. package/manifests/valkey/kustomization.yaml +7 -0
  51. package/manifests/valkey/service.yaml +17 -0
  52. package/manifests/valkey/statefulset.yaml +39 -0
  53. package/manifests/valkey/underpost-engine-valkey-service.yaml +17 -0
  54. package/manifests/valkey/underpost-engine-valkey-statefulset.yaml +39 -0
  55. package/package.json +26 -31
  56. package/src/api/core/core.service.js +1 -1
  57. package/src/api/user/user.model.js +16 -3
  58. package/src/api/user/user.service.js +1 -1
  59. package/src/cli/cluster.js +154 -0
  60. package/src/cli/cron.js +90 -0
  61. package/src/cli/db.js +148 -0
  62. package/src/cli/deploy.js +277 -0
  63. package/src/cli/env.js +52 -0
  64. package/src/cli/image.js +125 -0
  65. package/src/cli/repository.js +104 -0
  66. package/src/cli/script.js +29 -0
  67. package/src/cli/secrets.js +37 -0
  68. package/src/cli/test.js +83 -0
  69. package/src/client/components/core/Auth.js +22 -4
  70. package/src/client/components/core/CalendarCore.js +115 -49
  71. package/src/client/components/core/CommonJs.js +231 -19
  72. package/src/client/components/core/Css.js +1 -0
  73. package/src/client/components/core/CssCore.js +6 -0
  74. package/src/client/components/core/DropDown.js +5 -1
  75. package/src/client/components/core/Input.js +18 -4
  76. package/src/client/components/core/Modal.js +10 -6
  77. package/src/client/components/core/Panel.js +84 -25
  78. package/src/client/components/core/PanelForm.js +4 -18
  79. package/src/client/components/core/Scroll.js +1 -0
  80. package/src/client/components/core/Translate.js +47 -9
  81. package/src/client/components/core/Validator.js +9 -1
  82. package/src/client/components/core/VanillaJs.js +0 -9
  83. package/src/client/components/core/Worker.js +34 -31
  84. package/src/client/services/default/default.management.js +4 -2
  85. package/src/client/ssr/body/CacheControl.js +2 -2
  86. package/src/db/mongo/MongooseDB.js +13 -1
  87. package/src/index.js +77 -19
  88. package/src/runtime/lampp/Lampp.js +1 -13
  89. package/src/runtime/xampp/Xampp.js +0 -13
  90. package/src/server/auth.js +3 -3
  91. package/src/server/backup.js +49 -93
  92. package/src/server/client-build.js +4 -23
  93. package/src/server/client-formatted.js +5 -3
  94. package/src/server/conf.js +193 -45
  95. package/src/server/dns.js +49 -67
  96. package/src/server/logger.js +15 -10
  97. package/src/server/network.js +17 -43
  98. package/src/server/process.js +25 -2
  99. package/src/server/proxy.js +4 -26
  100. package/src/server/runtime.js +14 -29
  101. package/src/server/ssl.js +1 -1
  102. package/src/server/valkey.js +2 -0
  103. package/src/dns.js +0 -22
  104. package/src/server/prompt-optimizer.js +0 -28
  105. package/startup.js +0 -11
package/src/cli/env.js ADDED
@@ -0,0 +1,52 @@
1
+ import { getNpmRootPath, writeEnv } from '../server/conf.js';
2
+ import fs from 'fs-extra';
3
+ import { loggerFactory } from '../server/logger.js';
4
+ import dotenv from 'dotenv';
5
+
6
+ dotenv.config();
7
+
8
+ const logger = loggerFactory(import.meta);
9
+
10
+ class UnderpostRootEnv {
11
+ static API = {
12
+ set(key, value) {
13
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
14
+ const envPath = `${exeRootPath}/.env`;
15
+ let env = {};
16
+ if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
17
+ env[key] = value;
18
+ writeEnv(envPath, env);
19
+ },
20
+ delete(key) {
21
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
22
+ const envPath = `${exeRootPath}/.env`;
23
+ let env = {};
24
+ if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
25
+ delete env[key];
26
+ writeEnv(envPath, env);
27
+ },
28
+ get(key) {
29
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
30
+ const envPath = `${exeRootPath}/.env`;
31
+ if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
32
+ const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
33
+ logger.info('underpost root', { [key]: env[key] });
34
+ return env[key];
35
+ },
36
+ list() {
37
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
38
+ const envPath = `${exeRootPath}/.env`;
39
+ if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
40
+ const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
41
+ logger.info('underpost root', env);
42
+ return env;
43
+ },
44
+ clean() {
45
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
46
+ const envPath = `${exeRootPath}/.env`;
47
+ fs.removeSync(envPath);
48
+ },
49
+ };
50
+ }
51
+
52
+ export default UnderpostRootEnv;
@@ -0,0 +1,125 @@
1
+ import fs from 'fs-extra';
2
+ import Underpost from '../index.js';
3
+ import { shellExec } from '../server/process.js';
4
+ import dotenv from 'dotenv';
5
+ import { getNpmRootPath } from '../server/conf.js';
6
+ import { timer } from '../client/components/core/CommonJs.js';
7
+
8
+ dotenv.config();
9
+
10
+ class UnderpostImage {
11
+ static API = {
12
+ dockerfile: {
13
+ pullBaseImages() {
14
+ shellExec(`sudo podman pull docker.io/library/debian:buster`);
15
+ },
16
+ build(deployId = 'default', env = 'development', path = '.', options = { imageArchive: false }) {
17
+ const imgName = `${deployId}-${env}:${Underpost.version}`;
18
+ const podManImg = `localhost/${imgName}`;
19
+ const imagesStoragePath = `./images`;
20
+ const tarFile = `${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
21
+
22
+ let secrets = ' ';
23
+ let secretDockerInput = '';
24
+
25
+ const envObj = dotenv.parse(fs.readFileSync(`${getNpmRootPath()}/underpost/.env`, 'utf8'));
26
+
27
+ for (const key of Object.keys(envObj)) {
28
+ continue;
29
+ secrets += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
30
+ secretDockerInput += ` --secret id=${key},env=${key} \ `;
31
+ }
32
+ // --rm --no-cache
33
+ if (options.imageArchive !== true) {
34
+ fs.copyFile(`${getNpmRootPath()}/underpost/.env`, `${path}/.env.underpost`);
35
+ shellExec(
36
+ `cd ${path}${secrets}&& sudo podman build -f ./Dockerfile -t ${imgName} --pull=never --cap-add=CAP_AUDIT_WRITE${secretDockerInput}`,
37
+ );
38
+ fs.removeSync(`${path}/.env.underpost`);
39
+ shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
40
+ }
41
+ shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
42
+ },
43
+ async script(deployId = 'default', env = 'development', options = { run: false }) {
44
+ switch (deployId) {
45
+ case 'dd-lampp':
46
+ {
47
+ const lamppPublicPath = '/xampp/htdocs/online';
48
+ shellExec(`sudo mkdir -p ${lamppPublicPath}`);
49
+
50
+ {
51
+ shellExec(
52
+ `cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_0}`,
53
+ );
54
+
55
+ shellExec(`cd ${lamppPublicPath} && sudo ${process.env.DD_LAMPP_SCRIPT_0}`);
56
+
57
+ shellExec(
58
+ `sudo sed -i -e "s@define( 'DB_HOST', 'localhost' );@define( 'DB_HOST', '${process.env.MARIADB_HOST}' );@g" ${lamppPublicPath}/${process.env.DD_LAMPP_REPO_0_FOLDER}/wp-config.php`,
59
+ );
60
+ }
61
+ {
62
+ shellExec(
63
+ `cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_1}`,
64
+ );
65
+ }
66
+ }
67
+ break;
68
+
69
+ default:
70
+ {
71
+ {
72
+ const originPath = `./src/db/mongo/MongooseDB.js`;
73
+ fs.writeFileSync(
74
+ originPath,
75
+ fs.readFileSync(originPath, 'utf8').replaceAll(
76
+ `connect: async (host, name) => {`,
77
+ `connect: async (host, name) => {
78
+ host = 'mongodb://mongodb-0.mongodb-service:27017';
79
+ `,
80
+ ),
81
+ 'utf8',
82
+ );
83
+ }
84
+
85
+ {
86
+ const originPath = `./src/server/valkey.js`;
87
+ fs.writeFileSync(
88
+ originPath,
89
+ fs.readFileSync(originPath, 'utf8').replaceAll(
90
+ ` // port: 6379,
91
+ // host: 'service-valkey.default.svc.cluster.local',`,
92
+ ` port: 6379,
93
+ host: 'service-valkey.default.svc.cluster.local',`,
94
+ ),
95
+ 'utf8',
96
+ );
97
+ }
98
+ }
99
+ break;
100
+ }
101
+ shellExec(`node bin/deploy conf ${deployId} ${env}`);
102
+ shellExec(`node bin/deploy build-full-client ${deployId}`);
103
+ if (options.run === true) {
104
+ const runCmd = env === 'production' ? 'prod-img' : 'dev-img';
105
+ if (fs.existsSync(`./engine-private/replica`)) {
106
+ const replicas = await fs.readdir(`./engine-private/replica`);
107
+ for (const replica of replicas) {
108
+ shellExec(`node bin/deploy conf ${replica} ${env}`);
109
+ shellExec(`npm run ${runCmd} ${replica} deploy`, { async: true });
110
+ fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
111
+ const monitor = async () => {
112
+ await timer(1000);
113
+ if (fs.existsSync(`./tmp/await-deploy`)) return await monitor();
114
+ };
115
+ await monitor();
116
+ }
117
+ shellExec(`node bin/deploy conf ${deployId} ${env}`);
118
+ }
119
+ shellExec(`npm run ${runCmd} ${deployId} deploy`);
120
+ }
121
+ },
122
+ },
123
+ };
124
+ }
125
+ export default UnderpostImage;
@@ -0,0 +1,104 @@
1
+ import { commitData } from '../client/components/core/CommonJs.js';
2
+ import dotenv from 'dotenv';
3
+ import { pbcopy, shellExec } from '../server/process.js';
4
+ import { actionInitLog, loggerFactory } from '../server/logger.js';
5
+ import fs from 'fs-extra';
6
+ import { getNpmRootPath } from '../server/conf.js';
7
+ import { listenPortController, listenServerFactory } from '../server/network.js';
8
+
9
+ dotenv.config();
10
+
11
+ const logger = loggerFactory(import.meta);
12
+
13
+ class UnderpostRepository {
14
+ static API = {
15
+ clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false }) {
16
+ const repoName = gitUri.split('/').pop();
17
+ if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
18
+ shellExec(
19
+ `git clone ${options?.bare === true ? ` --bare ` : ''}https://${
20
+ process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
21
+ }github.com/${gitUri}.git`,
22
+ {
23
+ disableLog: true,
24
+ },
25
+ );
26
+ },
27
+ pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') {
28
+ shellExec(
29
+ `cd ${repoPath} && git pull https://${
30
+ process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
31
+ }github.com/${gitUri}.git`,
32
+ {
33
+ disableLog: true,
34
+ },
35
+ );
36
+ },
37
+ commit(
38
+ repoPath = './',
39
+ commitType = 'feat',
40
+ subModule = '',
41
+ message = '',
42
+ options = {
43
+ copy: false,
44
+ info: false,
45
+ empty: false,
46
+ },
47
+ ) {
48
+ if (commitType === 'reset') {
49
+ shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
50
+ return;
51
+ }
52
+ if (options.info) return logger.info('', commitData);
53
+ const _message = `${commitType}${subModule ? `(${subModule})` : ''}${process.argv.includes('!') ? '!' : ''}: ${
54
+ commitData[commitType].emoji
55
+ } ${message ? message : commitData[commitType].description}`;
56
+ if (options.copy) return pbcopy(_message);
57
+ shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
58
+ },
59
+
60
+ push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false }) {
61
+ shellExec(
62
+ `cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git${
63
+ options?.f === true ? ' --force' : ''
64
+ }`,
65
+ {
66
+ disableLog: true,
67
+ },
68
+ );
69
+ logger.info(
70
+ 'commit url',
71
+ `http://github.com/${gitUri}/commit/${shellExec(`cd ${repoPath} && git rev-parse --verify HEAD`, {
72
+ stdout: true,
73
+ }).trim()}`,
74
+ );
75
+ },
76
+
77
+ new(repositoryName) {
78
+ return new Promise(async (resolve, reject) => {
79
+ try {
80
+ await logger.setUpInfo();
81
+ if (repositoryName === 'service') return resolve(await listenPortController(listenServerFactory(), ':'));
82
+ else actionInitLog();
83
+ const exeRootPath = `${getNpmRootPath()}/underpost`;
84
+ const destFolder = `./${repositoryName}`;
85
+ logger.info('Note: This process may take several minutes to complete');
86
+ logger.info('build app', { destFolder });
87
+ if (fs.existsSync(destFolder)) fs.removeSync(destFolder);
88
+ fs.mkdirSync(destFolder, { recursive: true });
89
+ fs.copySync(exeRootPath, destFolder);
90
+ fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${exeRootPath}/.dockerignore`, 'utf8'), 'utf8');
91
+ shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
92
+ shellExec(`cd ${destFolder} && npm run build`);
93
+ shellExec(`cd ${destFolder} && npm run dev`);
94
+ return resolve();
95
+ } catch (error) {
96
+ logger.error(error, error.stack);
97
+ return reject(error.message);
98
+ }
99
+ });
100
+ },
101
+ };
102
+ }
103
+
104
+ export default UnderpostRepository;
@@ -0,0 +1,29 @@
1
+ import { getNpmRootPath } from '../server/conf.js';
2
+ import { loggerFactory } from '../server/logger.js';
3
+ import { shellExec } from '../server/process.js';
4
+ import fs from 'fs-extra';
5
+
6
+ const logger = loggerFactory(import.meta);
7
+
8
+ class UnderpostScript {
9
+ static API = {
10
+ set(key, value) {
11
+ const npmRoot = `${getNpmRootPath()}/underpost`;
12
+ const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
13
+ packageJson.scripts[key] = value;
14
+ fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
15
+ },
16
+ run(key) {
17
+ const npmRoot = `${getNpmRootPath()}/underpost`;
18
+ shellExec(`cd ${npmRoot} && npm run ${key}`);
19
+ },
20
+ get(key) {
21
+ const npmRoot = `${getNpmRootPath()}/underpost`;
22
+ const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
23
+ logger.info('[get] ' + key, packageJson.scripts[key]);
24
+ return packageJson.scripts[key];
25
+ },
26
+ };
27
+ }
28
+
29
+ export default UnderpostScript;
@@ -0,0 +1,37 @@
1
+ import dotenv from 'dotenv';
2
+ import { shellExec } from '../server/process.js';
3
+ import fs from 'fs-extra';
4
+ import UnderpostRootEnv from './env.js';
5
+
6
+ class UnderpostSecret {
7
+ static API = {
8
+ docker: {
9
+ init() {
10
+ shellExec(`docker swarm init`);
11
+ },
12
+ createFromEnvFile(envPath) {
13
+ const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
14
+ for (const key of Object.keys(envObj)) {
15
+ UnderpostSecret.API.docker.set(key, envObj[key]);
16
+ }
17
+ },
18
+ set(key, value) {
19
+ shellExec(`docker secret rm ${key}`);
20
+ shellExec(`echo "${value}" | docker secret create ${key} -`);
21
+ },
22
+ list() {
23
+ shellExec(`docker secret ls`);
24
+ },
25
+ },
26
+ underpost: {
27
+ createFromEnvFile(envPath) {
28
+ const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
29
+ for (const key of Object.keys(envObj)) {
30
+ UnderpostRootEnv.API.set(key, envObj[key]);
31
+ }
32
+ },
33
+ },
34
+ };
35
+ }
36
+
37
+ export default UnderpostSecret;
@@ -0,0 +1,83 @@
1
+ import { MariaDB } from '../db/mariadb/MariaDB.js';
2
+ import { getNpmRootPath } from '../server/conf.js';
3
+ import { actionInitLog, loggerFactory, setUpInfo } from '../server/logger.js';
4
+ import { pbcopy, shellExec } from '../server/process.js';
5
+ import UnderpostDeploy from './deploy.js';
6
+
7
+ const logger = loggerFactory(import.meta);
8
+
9
+ class UnderpostTest {
10
+ static API = {
11
+ /**
12
+ * Logs information about the current process environment to the console.
13
+ *
14
+ * This function is used to log details about
15
+ * the execution context, such as command-line arguments,
16
+ * environment variables, the process's administrative privileges,
17
+ * and the maximum available heap space size.
18
+ *
19
+ * @static
20
+ * @method setUpInfo
21
+ * @returns {Promise<void>}
22
+ * @memberof Underpost
23
+ */
24
+ async setUpInfo() {
25
+ return await setUpInfo(logger);
26
+ },
27
+ run() {
28
+ actionInitLog();
29
+ shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
30
+ },
31
+ async callback(deployList = '', options = { insideContainer: false, sh: false, logs: false }) {
32
+ if (options.sh === true || options.logs === true) {
33
+ const [pod] = UnderpostDeploy.API.getPods(deployList);
34
+ if (pod) {
35
+ if (options.sh) return pbcopy(`sudo kubectl exec -it ${pod.NAME} -- sh`);
36
+ if (options.logs) return shellExec(`sudo kubectl logs -f ${pod.NAME}`);
37
+ }
38
+ return logger.warn(`Couldn't find pods in deployment`, deployList);
39
+ }
40
+ if (deployList) {
41
+ for (const _deployId of deployList.split(',')) {
42
+ const deployId = _deployId.trim();
43
+ if (!deployId) continue;
44
+ if (options.insideContainer === true)
45
+ switch (deployId) {
46
+ case 'dd-lampp':
47
+ {
48
+ const { MARIADB_HOST, MARIADB_USER, MARIADB_PASSWORD, DD_LAMPP_TEST_DB_0 } = process.env;
49
+
50
+ await MariaDB.query({
51
+ host: MARIADB_HOST,
52
+ user: MARIADB_USER,
53
+ password: MARIADB_PASSWORD,
54
+ query: `SHOW TABLES FROM ${DD_LAMPP_TEST_DB_0}`,
55
+ });
56
+ }
57
+ break;
58
+
59
+ default:
60
+ {
61
+ shellExec('npm run test');
62
+ }
63
+
64
+ break;
65
+ }
66
+ else {
67
+ const pods = UnderpostDeploy.API.getPods(deployId);
68
+ if (pods.length > 0)
69
+ for (const deployData of pods) {
70
+ const { NAME } = deployData;
71
+ shellExec(
72
+ `sudo kubectl exec -i ${NAME} -- sh -c "cd /home/dd/engine && underpost test ${deployId} --inside-container"`,
73
+ );
74
+ }
75
+ else logger.warn(`Couldn't find pods in deployment`, { deployId });
76
+ }
77
+ }
78
+ } else return UnderpostTest.API.run();
79
+ },
80
+ };
81
+ }
82
+
83
+ export default UnderpostTest;
@@ -3,7 +3,10 @@ import { Account } from './Account.js';
3
3
  import { loggerFactory } from './Logger.js';
4
4
  import { LogIn } from './LogIn.js';
5
5
  import { LogOut } from './LogOut.js';
6
+ import { NotificationManager } from './NotificationManager.js';
6
7
  import { SignUp } from './SignUp.js';
8
+ import { Translate } from './Translate.js';
9
+ import { s } from './VanillaJs.js';
7
10
 
8
11
  const logger = loggerFactory(import.meta);
9
12
 
@@ -65,6 +68,7 @@ const Auth = {
65
68
  const _result = await UserService.get({ id: 'auth' });
66
69
  return {
67
70
  status: _result.status,
71
+ message: _result.message,
68
72
  data: {
69
73
  user: _result.data,
70
74
  },
@@ -77,6 +81,15 @@ const Auth = {
77
81
  await Account.updateForm(data.user);
78
82
  return { user: data.user };
79
83
  }
84
+ if (message && message.match('expired'))
85
+ setTimeout(() => {
86
+ s(`.main-btn-log-in`).click();
87
+ NotificationManager.Push({
88
+ html: Translate.Render(`expired-session`),
89
+ status: 'warning',
90
+ });
91
+ });
92
+ return await Auth.sessionOut();
80
93
  }
81
94
 
82
95
  // anon guest session
@@ -92,20 +105,25 @@ const Auth = {
92
105
 
93
106
  this.setGuestToken(guestToken);
94
107
  let { data, status, message } = await UserService.get({ id: 'auth' });
95
- if (status === 'error') throw new Error(message);
108
+ if (status === 'error') {
109
+ if (message && message.match('expired')) {
110
+ localStorage.removeItem('jwt.g');
111
+ return await Auth.sessionOut();
112
+ } else throw new Error(message);
113
+ }
96
114
  await Account.updateForm(data);
97
115
  return { user: data };
98
116
  } catch (error) {
99
117
  logger.error(error);
100
- localStorage.removeItem('jwt');
101
- localStorage.removeItem('jwt.g');
102
118
  return { user: UserMock.default };
103
119
  }
104
120
  },
105
121
  sessionOut: async function () {
106
122
  this.deleteToken();
107
123
  localStorage.removeItem('jwt');
108
- await LogOut.Trigger(await this.sessionIn());
124
+ const result = await this.sessionIn();
125
+ await LogOut.Trigger(result);
126
+ return result;
109
127
  },
110
128
  };
111
129