underpost 2.8.844 → 2.8.846

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 (68) hide show
  1. package/README.md +14 -2
  2. package/cli.md +4 -3
  3. package/docker-compose.yml +1 -1
  4. package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
  5. package/package.json +1 -2
  6. package/src/cli/index.js +1 -7
  7. package/src/cli/run.js +7 -0
  8. package/src/client/Default.index.js +1 -1
  9. package/src/client/components/core/Chat.js +1 -1
  10. package/src/client/components/core/CommonJs.js +24 -22
  11. package/src/client/components/core/Content.js +1 -5
  12. package/src/client/components/core/Css.js +68 -4
  13. package/src/client/components/core/CssCore.js +5 -0
  14. package/src/client/components/core/Docs.js +9 -10
  15. package/src/client/components/core/DropDown.js +137 -82
  16. package/src/client/components/core/Modal.js +72 -48
  17. package/src/client/components/core/ObjectLayerEngine.js +638 -0
  18. package/src/client/components/core/Panel.js +156 -32
  19. package/src/client/components/core/PanelForm.js +12 -4
  20. package/src/client/components/core/Router.js +63 -2
  21. package/src/client/components/core/Translate.js +6 -2
  22. package/src/client/components/default/MenuDefault.js +27 -1
  23. package/src/client/public/default/android-chrome-144x144.png +0 -0
  24. package/src/client/public/default/android-chrome-192x192.png +0 -0
  25. package/src/client/public/default/android-chrome-256x256.png +0 -0
  26. package/src/client/public/default/android-chrome-36x36.png +0 -0
  27. package/src/client/public/default/android-chrome-48x48.png +0 -0
  28. package/src/client/public/default/android-chrome-72x72.png +0 -0
  29. package/src/client/public/default/android-chrome-96x96.png +0 -0
  30. package/src/client/public/default/apple-touch-icon-114x114-precomposed.png +0 -0
  31. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  32. package/src/client/public/default/apple-touch-icon-120x120-precomposed.png +0 -0
  33. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  34. package/src/client/public/default/apple-touch-icon-144x144-precomposed.png +0 -0
  35. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  36. package/src/client/public/default/apple-touch-icon-152x152-precomposed.png +0 -0
  37. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  38. package/src/client/public/default/apple-touch-icon-180x180-precomposed.png +0 -0
  39. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  40. package/src/client/public/default/apple-touch-icon-57x57-precomposed.png +0 -0
  41. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  42. package/src/client/public/default/apple-touch-icon-60x60-precomposed.png +0 -0
  43. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  44. package/src/client/public/default/apple-touch-icon-72x72-precomposed.png +0 -0
  45. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  46. package/src/client/public/default/apple-touch-icon-76x76-precomposed.png +0 -0
  47. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  48. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  49. package/src/client/public/default/apple-touch-icon.png +0 -0
  50. package/src/client/public/default/assets/background/dark.jpg +0 -0
  51. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  52. package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
  53. package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
  54. package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
  55. package/src/client/public/default/favicon-16x16.png +0 -0
  56. package/src/client/public/default/favicon-32x32.png +0 -0
  57. package/src/client/public/default/favicon.ico +0 -0
  58. package/src/client/public/default/mstile-144x144.png +0 -0
  59. package/src/client/public/default/mstile-150x150.png +0 -0
  60. package/src/client/public/default/mstile-310x150.png +0 -0
  61. package/src/client/public/default/mstile-310x310.png +0 -0
  62. package/src/client/public/default/mstile-70x70.png +0 -0
  63. package/src/client/public/default/safari-pinned-tab.svg +24 -0
  64. package/src/client/ssr/body/DefaultSplashScreen.js +2 -2
  65. package/src/index.js +1 -1
  66. package/src/server/client-build-docs.js +205 -0
  67. package/src/server/client-build.js +15 -138
  68. package/src/server/conf.js +12 -5
@@ -0,0 +1,205 @@
1
+ 'use strict';
2
+
3
+ import fs from 'fs-extra';
4
+ import swaggerAutoGen from 'swagger-autogen';
5
+ import { shellExec } from './process.js';
6
+ import { loggerFactory } from './logger.js';
7
+ import { JSONweb } from './client-formatted.js';
8
+
9
+ /**
10
+ * Builds API documentation using Swagger
11
+ * @param {Object} options - Documentation build options
12
+ * @param {string} options.host - The hostname for the API
13
+ * @param {string} options.path - The base path for the API
14
+ * @param {number} options.port - The port number for the API
15
+ * @param {Object} options.metadata - Metadata for the API documentation
16
+ * @param {Array<string>} options.apis - List of API modules to document
17
+ * @param {string} options.publicClientId - Client ID for the public documentation
18
+ * @param {string} options.rootClientPath - Root path for client files
19
+ * @param {Object} options.packageData - Package.json data
20
+ */
21
+ const buildApiDocs = async ({
22
+ host,
23
+ path,
24
+ port,
25
+ metadata = {},
26
+ apis = [],
27
+ publicClientId,
28
+ rootClientPath,
29
+ packageData,
30
+ }) => {
31
+ const logger = loggerFactory(import.meta);
32
+ const basePath = path === '/' ? `${process.env.BASE_API}` : `/${process.env.BASE_API}`;
33
+
34
+ const doc = {
35
+ info: {
36
+ version: packageData.version,
37
+ title: metadata?.title ? `${metadata.title}` : 'REST API',
38
+ description: metadata?.description ? metadata.description : '',
39
+ },
40
+ servers: [
41
+ {
42
+ url:
43
+ process.env.NODE_ENV === 'development'
44
+ ? `http://localhost:${port}${path}${basePath}`
45
+ : `https://${host}${path}${basePath}`,
46
+ description: `${process.env.NODE_ENV} server`,
47
+ },
48
+ ],
49
+ tags: [
50
+ {
51
+ name: 'user',
52
+ description: 'User API operations',
53
+ },
54
+ ],
55
+ components: {
56
+ schemas: {
57
+ userRequest: {
58
+ username: 'user123',
59
+ password: 'Password123',
60
+ email: 'user@example.com',
61
+ },
62
+ userResponse: {
63
+ status: 'success',
64
+ data: {
65
+ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjY2YzM3N2Y1N2Y5OWU1OTY5YjgxZG...',
66
+ user: {
67
+ _id: '66c377f57f99e5969b81de89',
68
+ email: 'user@example.com',
69
+ emailConfirmed: false,
70
+ username: 'user123',
71
+ role: 'user',
72
+ profileImageId: '66c377f57f99e5969b81de87',
73
+ },
74
+ },
75
+ },
76
+ userUpdateResponse: {
77
+ status: 'success',
78
+ data: {
79
+ _id: '66c377f57f99e5969b81de89',
80
+ email: 'user@example.com',
81
+ emailConfirmed: false,
82
+ username: 'user123222',
83
+ role: 'user',
84
+ profileImageId: '66c377f57f99e5969b81de87',
85
+ },
86
+ },
87
+ userGetResponse: {
88
+ status: 'success',
89
+ data: {
90
+ _id: '66c377f57f99e5969b81de89',
91
+ email: 'user@example.com',
92
+ emailConfirmed: false,
93
+ username: 'user123222',
94
+ role: 'user',
95
+ profileImageId: '66c377f57f99e5969b81de87',
96
+ },
97
+ },
98
+ userLogInRequest: {
99
+ email: 'user@example.com',
100
+ password: 'Password123',
101
+ },
102
+ userBadRequestResponse: {
103
+ status: 'error',
104
+ message: 'Bad request. Please check your inputs, and try again',
105
+ },
106
+ },
107
+ securitySchemes: {
108
+ bearerAuth: {
109
+ type: 'http',
110
+ scheme: 'bearer',
111
+ },
112
+ },
113
+ },
114
+ };
115
+
116
+ logger.warn('build swagger api docs', doc.info);
117
+
118
+ const outputFile = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
119
+ const routes = [];
120
+ for (const api of apis) {
121
+ if (['user'].includes(api)) routes.push(`./src/api/${api}/${api}.router.js`);
122
+ }
123
+
124
+ await swaggerAutoGen({ openapi: '3.0.0' })(outputFile, routes, doc);
125
+ };
126
+
127
+ /**
128
+ * Builds JSDoc documentation
129
+ * @param {Object} options - JSDoc build options
130
+ * @param {string} options.host - The hostname for the documentation
131
+ * @param {string} options.path - The base path for the documentation
132
+ * @param {Object} options.metadata - Metadata for the documentation
133
+ */
134
+ const buildJsDocs = async ({ host, path, metadata = {} }) => {
135
+ const logger = loggerFactory(import.meta);
136
+ const jsDocsConfig = JSON.parse(fs.readFileSync(`./jsdoc.json`, 'utf8'));
137
+
138
+ jsDocsConfig.opts.destination = `./public/${host}${path === '/' ? path : `${path}/`}docs/`;
139
+ jsDocsConfig.opts.theme_opts.title = metadata?.title ? metadata.title : undefined;
140
+ jsDocsConfig.opts.theme_opts.favicon = `./public/${host}${path === '/' ? path : `${path}/favicon.ico`}`;
141
+
142
+ fs.writeFileSync(`./jsdoc.json`, JSON.stringify(jsDocsConfig, null, 4), 'utf8');
143
+ logger.warn('build jsdoc view', jsDocsConfig.opts.destination);
144
+
145
+ shellExec(`npm run docs`, { silent: true });
146
+ };
147
+
148
+ /**
149
+ * Builds test coverage documentation
150
+ * @param {Object} options - Coverage build options
151
+ * @param {string} options.host - The hostname for the coverage
152
+ * @param {string} options.path - The base path for the coverage
153
+ */
154
+ const buildCoverage = async ({ host, path }) => {
155
+ const logger = loggerFactory(import.meta);
156
+ const jsDocsConfig = JSON.parse(fs.readFileSync(`./jsdoc.json`, 'utf8'));
157
+
158
+ if (!fs.existsSync(`./coverage`)) {
159
+ shellExec(`npm test`);
160
+ }
161
+
162
+ const coverageBuildPath = `${jsDocsConfig.opts.destination}/coverage`;
163
+ fs.mkdirSync(coverageBuildPath, { recursive: true });
164
+ fs.copySync(`./coverage`, coverageBuildPath);
165
+
166
+ logger.warn('build coverage', coverageBuildPath);
167
+ };
168
+
169
+ /**
170
+ * Main function to build all documentation
171
+ * @param {Object} options - Documentation build options
172
+ * @param {string} options.host - The hostname
173
+ * @param {string} options.path - The base path
174
+ * @param {number} options.port - The port number
175
+ * @param {Object} options.metadata - Metadata for the documentation
176
+ * @param {Array<string>} options.apis - List of API modules to document
177
+ * @param {string} options.publicClientId - Client ID for the public documentation
178
+ * @param {string} options.rootClientPath - Root path for client files
179
+ * @param {Object} options.packageData - Package.json data
180
+ */
181
+ const buildDocs = async ({
182
+ host,
183
+ path,
184
+ port,
185
+ metadata = {},
186
+ apis = [],
187
+ publicClientId,
188
+ rootClientPath,
189
+ packageData,
190
+ }) => {
191
+ await buildJsDocs({ host, path, metadata });
192
+ await buildCoverage({ host, path });
193
+ await buildApiDocs({
194
+ host,
195
+ path,
196
+ port,
197
+ metadata,
198
+ apis,
199
+ publicClientId,
200
+ rootClientPath,
201
+ packageData,
202
+ });
203
+ };
204
+
205
+ export { buildDocs };
@@ -17,11 +17,11 @@ import dotenv from 'dotenv';
17
17
  import AdmZip from 'adm-zip';
18
18
  import * as dir from 'path';
19
19
  import { shellExec } from './process.js';
20
- import swaggerAutoGen from 'swagger-autogen';
21
20
  import { SitemapStream, streamToPromise } from 'sitemap';
22
21
  import { Readable } from 'stream';
23
22
  import { buildIcons, buildTextImg, getBufferPngText } from './client-icons.js';
24
23
  import Underpost from '../index.js';
24
+ import { buildDocs } from './client-build-docs.js';
25
25
 
26
26
  dotenv.config();
27
27
 
@@ -441,27 +441,13 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [] }
441
441
  case 'CyberiaDefaultSplashScreen':
442
442
  case 'NexodevSplashScreen':
443
443
  case 'DefaultSplashScreen':
444
- if (backgroundImage) {
444
+ if (backgroundImage)
445
445
  ssrHeadComponents += SrrComponent({
446
+ ...metadata,
446
447
  backgroundImage: (path === '/' ? path : `${path}/`) + backgroundImage,
447
448
  });
448
- // `data:image/${backgroundImage.split('.').pop()};base64,${fs
449
- // .readFileSync()
450
- // .toString('base64')}`,
451
- break;
452
- } else {
453
- ssrHeadComponents += SrrComponent({ metadata });
454
- break;
455
- const bufferBackgroundImage = await getBufferPngText({
456
- text: ' ',
457
- textColor: metadata?.themeColor ? metadata.themeColor : '#ececec',
458
- size: '100x100',
459
- bgColor: metadata?.themeColor ? metadata.themeColor : '#ececec',
460
- });
461
- ssrHeadComponents += SrrComponent({
462
- backgroundImage: `data:image/png;base64,${bufferBackgroundImage.toString('base64')}`,
463
- });
464
- }
449
+ else ssrHeadComponents += SrrComponent({ metadata });
450
+ break;
465
451
 
466
452
  case 'CyberiaSplashScreenLore': {
467
453
  ssrBodyComponents += SrrComponent({
@@ -557,125 +543,16 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
557
543
  }
558
544
 
559
545
  if (!enableLiveRebuild && !process.argv.includes('l') && !process.argv.includes('deploy') && docsBuild) {
560
- // https://www.pullrequest.com/blog/leveraging-jsdoc-for-better-code-documentation-in-javascript/
561
- // https://jsdoc.app/about-configuring-jsdoc
562
- // https://jsdoc.app/ Block tags
563
-
564
- const jsDocsConfig = JSON.parse(fs.readFileSync(`./jsdoc.json`, 'utf8'));
565
- jsDocsConfig.opts.destination = `./public/${host}${path === '/' ? path : `${path}/`}docs/`;
566
- jsDocsConfig.opts.theme_opts.title = metadata && metadata.title ? metadata.title : undefined;
567
- jsDocsConfig.opts.theme_opts.favicon = `./public/${host}${path === '/' ? path : `${path}/favicon.ico`}`;
568
- fs.writeFileSync(`./jsdoc.json`, JSON.stringify(jsDocsConfig, null, 4), 'utf8');
569
- logger.warn('build jsdoc view', jsDocsConfig.opts.destination);
570
- shellExec(`npm run docs`, { silent: true });
571
-
572
- // coverage
573
- if (!fs.existsSync(`./coverage`)) {
574
- shellExec(`npm test`);
575
- }
576
- const coverageBuildPath = `${jsDocsConfig.opts.destination}/coverage`;
577
- fs.mkdirSync(coverageBuildPath, { recursive: true });
578
- fs.copySync(`./coverage`, coverageBuildPath);
579
-
580
- // https://swagger-autogen.github.io/docs/
581
-
582
- const basePath = path === '/' ? `${process.env.BASE_API}` : `/${process.env.BASE_API}`;
583
-
584
- const doc = {
585
- info: {
586
- version: packageData.version, // by default: '1.0.0'
587
- title: metadata?.title ? `${metadata.title}` : 'REST API', // by default: 'REST API'
588
- description: metadata?.description ? metadata.description : '', // by default: ''
589
- },
590
- servers: [
591
- {
592
- url:
593
- process.env.NODE_ENV === 'development'
594
- ? `http://localhost:${port}${path}${basePath}`
595
- : `https://${host}${path}${basePath}`, // by default: 'http://localhost:3000'
596
- description: `${process.env.NODE_ENV} server`, // by default: ''
597
- },
598
- ],
599
- tags: [
600
- // by default: empty Array
601
- {
602
- name: 'user', // Tag name
603
- description: 'User API operations', // Tag description
604
- },
605
- ],
606
- components: {
607
- schemas: {
608
- userRequest: {
609
- username: 'user123',
610
- password: 'Password123',
611
- email: 'user@example.com',
612
- },
613
- userResponse: {
614
- status: 'success',
615
- data: {
616
- token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjY2YzM3N2Y1N2Y5OWU1OTY5YjgxZG...',
617
- user: {
618
- _id: '66c377f57f99e5969b81de89',
619
- email: 'user@example.com',
620
- emailConfirmed: false,
621
- username: 'user123',
622
- role: 'user',
623
- profileImageId: '66c377f57f99e5969b81de87',
624
- },
625
- },
626
- },
627
- userUpdateResponse: {
628
- status: 'success',
629
- data: {
630
- _id: '66c377f57f99e5969b81de89',
631
- email: 'user@example.com',
632
- emailConfirmed: false,
633
- username: 'user123222',
634
- role: 'user',
635
- profileImageId: '66c377f57f99e5969b81de87',
636
- },
637
- },
638
- userGetResponse: {
639
- status: 'success',
640
- data: {
641
- _id: '66c377f57f99e5969b81de89',
642
- email: 'user@example.com',
643
- emailConfirmed: false,
644
- username: 'user123222',
645
- role: 'user',
646
- profileImageId: '66c377f57f99e5969b81de87',
647
- },
648
- },
649
- userLogInRequest: {
650
- email: 'user@example.com',
651
- password: 'Password123',
652
- },
653
- userBadRequestResponse: {
654
- status: 'error',
655
- message: 'Bad request. Please check your inputs, and try again',
656
- },
657
- },
658
- securitySchemes: {
659
- bearerAuth: {
660
- type: 'http',
661
- scheme: 'bearer',
662
- },
663
- },
664
- },
665
- };
666
-
667
- logger.warn('build swagger api docs', doc.info);
668
-
669
- const outputFile = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
670
- const routes = [];
671
- for (const api of apis) {
672
- if (['user'].includes(api)) routes.push(`./src/api/${api}/${api}.router.js`);
673
- }
674
-
675
- /* NOTE: If you are using the express Router, you must pass in the 'routes' only the
676
- root file where the route starts, such as index.js, app.js, routes.js, etc ... */
677
-
678
- await swaggerAutoGen({ openapi: '3.0.0' })(outputFile, routes, doc);
546
+ await buildDocs({
547
+ host,
548
+ path,
549
+ port,
550
+ metadata,
551
+ apis,
552
+ publicClientId,
553
+ rootClientPath,
554
+ packageData,
555
+ });
679
556
  }
680
557
 
681
558
  if (client) {
@@ -89,12 +89,19 @@ const Config = {
89
89
  };
90
90
 
91
91
  const loadConf = (deployId, envInput, subConf) => {
92
+ if (deployId === 'current') {
93
+ console.log(process.env.DEPLOY_ID);
94
+ return;
95
+ }
92
96
  if (deployId === 'clean') {
93
- shellExec(`git checkout package.json`);
94
- shellExec(`git checkout .env.production`);
95
- shellExec(`git checkout .env.development`);
96
- shellExec(`git checkout .env.test`);
97
- shellExec(`git checkout jsdoc.json`);
97
+ const path = envInput ?? '.';
98
+ fs.removeSync(`${path}/.env`);
99
+ shellExec(`git checkout ${path}/.env.production`);
100
+ shellExec(`git checkout ${path}/.env.development`);
101
+ shellExec(`git checkout ${path}/.env.test`);
102
+ if (fs.existsSync(`${path}/jsdoc.json`)) shellExec(`git checkout ${path}/jsdoc.json`);
103
+ shellExec(`git checkout ${path}/package.json`);
104
+ shellExec(`git checkout ${path}/package-lock.json`);
98
105
  return;
99
106
  }
100
107
  const folder = fs.existsSync(`./engine-private/replica/${deployId}`)