underpost 3.2.9 → 3.2.10

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 (81) hide show
  1. package/.github/workflows/npmpkg.ci.yml +1 -0
  2. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  3. package/.github/workflows/release.cd.yml +1 -0
  4. package/.vscode/settings.json +10 -5
  5. package/CHANGELOG.md +122 -1
  6. package/CLI-HELP.md +22 -7
  7. package/README.md +37 -8
  8. package/bin/build.js +26 -9
  9. package/bin/deploy.js +20 -21
  10. package/bin/file.js +31 -13
  11. package/bin/index.js +2 -1
  12. package/bin/vs.js +1 -1
  13. package/bump.config.js +26 -0
  14. package/conf.js +20 -4
  15. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
  16. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  17. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  18. package/manifests/deployment/dd-test-development/deployment.yaml +4 -2
  19. package/manifests/kind-config-dev.yaml +8 -0
  20. package/manifests/mongodb/pv-pvc.yaml +44 -8
  21. package/manifests/mongodb/statefulset.yaml +55 -68
  22. package/package.json +27 -12
  23. package/scripts/k3s-node-setup.sh +28 -9
  24. package/src/api/core/core.router.js +19 -14
  25. package/src/api/core/core.service.js +5 -5
  26. package/src/api/default/default.router.js +22 -18
  27. package/src/api/default/default.service.js +5 -5
  28. package/src/api/document/document.router.js +28 -23
  29. package/src/api/document/document.service.js +100 -23
  30. package/src/api/file/file.router.js +19 -13
  31. package/src/api/file/file.service.js +9 -7
  32. package/src/api/test/test.router.js +17 -12
  33. package/src/api/types.js +24 -0
  34. package/src/api/user/guest.service.js +5 -4
  35. package/src/api/user/user.router.js +297 -288
  36. package/src/api/user/user.service.js +100 -35
  37. package/src/cli/baremetal.js +20 -11
  38. package/src/cli/cluster.js +196 -55
  39. package/src/cli/db.js +59 -60
  40. package/src/cli/deploy.js +273 -159
  41. package/src/cli/fs.js +3 -1
  42. package/src/cli/index.js +16 -9
  43. package/src/cli/ipfs.js +4 -6
  44. package/src/cli/kubectl.js +4 -1
  45. package/src/cli/lxd.js +217 -135
  46. package/src/cli/release.js +289 -131
  47. package/src/cli/repository.js +58 -7
  48. package/src/cli/run.js +152 -25
  49. package/src/cli/test.js +9 -3
  50. package/src/client/Default.index.js +9 -3
  51. package/src/client/components/core/Auth.js +4 -0
  52. package/src/client/components/core/PanelForm.js +56 -52
  53. package/src/client/components/core/Worker.js +162 -363
  54. package/src/client/sw/core.sw.js +174 -112
  55. package/src/db/DataBaseProvider.js +120 -20
  56. package/src/db/mongo/MongoBootstrap.js +587 -0
  57. package/src/db/mongo/MongooseDB.js +126 -22
  58. package/src/index.js +1 -1
  59. package/src/runtime/express/Express.js +2 -2
  60. package/src/runtime/wp/Wp.js +8 -5
  61. package/src/server/auth.js +2 -2
  62. package/src/server/client-build-docs.js +1 -1
  63. package/src/server/client-build.js +94 -129
  64. package/src/server/conf.js +20 -65
  65. package/src/server/process.js +180 -19
  66. package/src/server/runtime.js +1 -1
  67. package/src/server/start.js +12 -4
  68. package/src/ws/IoInterface.js +16 -16
  69. package/src/ws/core/channels/core.ws.chat.js +11 -11
  70. package/src/ws/core/channels/core.ws.mailer.js +29 -29
  71. package/src/ws/core/channels/core.ws.stream.js +19 -19
  72. package/src/ws/core/core.ws.connection.js +8 -8
  73. package/src/ws/core/core.ws.server.js +6 -5
  74. package/src/ws/default/channels/default.ws.main.js +10 -10
  75. package/src/ws/default/default.ws.connection.js +4 -4
  76. package/src/ws/default/default.ws.server.js +4 -3
  77. package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
  78. package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
  79. /package/src/client/ssr/{offline → views}/Maintenance.js +0 -0
  80. /package/src/client/ssr/{offline → views}/NoNetworkConnection.js +0 -0
  81. /package/src/client/ssr/{pages → views}/Test.js +0 -0
@@ -12,29 +12,29 @@ import { IoChannel } from '../../IoInterface.js';
12
12
  * Handles register/unregister messages and cleanup on disconnect.
13
13
  */
14
14
  class CoreWsMailerChannel {
15
- /** @type {Object.<string, Object.<string, { model: { user: Object } }>>} Socket data keyed by `[wsManagementId][socketId]`. */
15
+ /** @type {Object.<string, Object.<string, { model: { user: Object } }>>} Socket data keyed by `[hostKeyContext][socketId]`. */
16
16
  static #data = {};
17
17
 
18
- /** @type {Object.<string, Object.<string, string>>} Reverse index: `[wsManagementId][userId]` → socketId. */
18
+ /** @type {Object.<string, Object.<string, string>>} Reverse index: `[hostKeyContext][userId]` → socketId. */
19
19
  static #userIndex = {};
20
20
 
21
21
  /** @type {IoChannel} */
22
22
  static #io = new IoChannel({
23
23
  channel: 'mailer',
24
- controller(socket, client, payload, wsManagementId) {
24
+ controller(socket, client, payload, hostKeyContext) {
25
25
  switch (payload.status) {
26
26
  case 'register-user':
27
- CoreWsMailerChannel.setUser(wsManagementId, socket.id, payload.user);
27
+ CoreWsMailerChannel.setUser(hostKeyContext, socket.id, payload.user);
28
28
  break;
29
29
  case 'unregister-user':
30
- CoreWsMailerChannel.removeSocket(wsManagementId, socket.id);
30
+ CoreWsMailerChannel.removeSocket(hostKeyContext, socket.id);
31
31
  break;
32
32
  default:
33
33
  break;
34
34
  }
35
35
  },
36
- disconnect(socket, client, reason, wsManagementId) {
37
- CoreWsMailerChannel.removeSocket(wsManagementId, socket.id);
36
+ disconnect(socket, client, reason, hostKeyContext) {
37
+ CoreWsMailerChannel.removeSocket(hostKeyContext, socket.id);
38
38
  },
39
39
  });
40
40
 
@@ -50,66 +50,66 @@ class CoreWsMailerChannel {
50
50
 
51
51
  /**
52
52
  * Initializes state for a server instance.
53
- * @param {string} wsManagementId - Unique server context ID (`${host}${path}`).
53
+ * @param {string} hostKeyContext - Unique server context ID (`${host}${path}`).
54
54
  */
55
- static init(wsManagementId) {
56
- this.#data[wsManagementId] = {};
57
- this.#userIndex[wsManagementId] = {};
55
+ static init(hostKeyContext) {
56
+ this.#data[hostKeyContext] = {};
57
+ this.#userIndex[hostKeyContext] = {};
58
58
  }
59
59
 
60
60
  /**
61
61
  * Registers a socket connection.
62
62
  * @param {import('socket.io').Socket} socket
63
- * @param {string} wsManagementId
63
+ * @param {string} hostKeyContext
64
64
  */
65
- static connection(socket, wsManagementId) {
66
- return this.#io.connection(socket, wsManagementId);
65
+ static connection(socket, hostKeyContext) {
66
+ return this.#io.connection(socket, hostKeyContext);
67
67
  }
68
68
 
69
69
  /**
70
70
  * Handles socket disconnection.
71
71
  * @param {import('socket.io').Socket} socket
72
72
  * @param {string} reason
73
- * @param {string} wsManagementId
73
+ * @param {string} hostKeyContext
74
74
  */
75
- static disconnect(socket, reason, wsManagementId) {
76
- return this.#io.disconnect(socket, reason, wsManagementId);
75
+ static disconnect(socket, reason, hostKeyContext) {
76
+ return this.#io.disconnect(socket, reason, hostKeyContext);
77
77
  }
78
78
 
79
79
  /**
80
80
  * Registers a user↔socket mapping.
81
- * @param {string} wsManagementId
81
+ * @param {string} hostKeyContext
82
82
  * @param {string} socketId
83
83
  * @param {Object} user - User data with `_id` property.
84
84
  */
85
- static setUser(wsManagementId, socketId, user) {
86
- this.#data[wsManagementId][socketId] = { model: { user } };
85
+ static setUser(hostKeyContext, socketId, user) {
86
+ this.#data[hostKeyContext][socketId] = { model: { user } };
87
87
  if (user?._id) {
88
- this.#userIndex[wsManagementId][user._id.toString()] = socketId;
88
+ this.#userIndex[hostKeyContext][user._id.toString()] = socketId;
89
89
  }
90
90
  }
91
91
 
92
92
  /**
93
93
  * Removes a socket entry and its reverse user index.
94
- * @param {string} wsManagementId
94
+ * @param {string} hostKeyContext
95
95
  * @param {string} socketId
96
96
  */
97
- static removeSocket(wsManagementId, socketId) {
98
- const entry = this.#data[wsManagementId]?.[socketId];
97
+ static removeSocket(hostKeyContext, socketId) {
98
+ const entry = this.#data[hostKeyContext]?.[socketId];
99
99
  if (entry?.model?.user?._id) {
100
- delete this.#userIndex[wsManagementId][entry.model.user._id.toString()];
100
+ delete this.#userIndex[hostKeyContext][entry.model.user._id.toString()];
101
101
  }
102
- delete this.#data[wsManagementId]?.[socketId];
102
+ delete this.#data[hostKeyContext]?.[socketId];
103
103
  }
104
104
 
105
105
  /**
106
106
  * Finds the socket ID for a user (O(1) reverse index lookup).
107
- * @param {string} wsManagementId
107
+ * @param {string} hostKeyContext
108
108
  * @param {string} userId - The user `_id`.
109
109
  * @returns {string|undefined} Socket ID, or `undefined` if not connected.
110
110
  */
111
- static getUserWsId(wsManagementId, userId) {
112
- return this.#userIndex[wsManagementId]?.[userId];
111
+ static getUserWsId(hostKeyContext, userId) {
112
+ return this.#userIndex[hostKeyContext]?.[userId];
113
113
  }
114
114
  }
115
115
 
@@ -11,41 +11,41 @@ import { IoChannel } from '../../IoInterface.js';
11
11
  * and broadcast connection/disconnection events to other room members.
12
12
  */
13
13
  class CoreWsStreamChannel {
14
- /** @type {Object.<string, Object.<string, Array>>} Per-socket room/user args keyed by `[wsManagementId][socketId]`. */
14
+ /** @type {Object.<string, Object.<string, Array>>} Per-socket room/user args keyed by `[hostKeyContext][socketId]`. */
15
15
  static #state = {};
16
16
 
17
17
  /** @type {IoChannel} */
18
18
  static #io = new IoChannel({
19
19
  channel: 'stream',
20
20
  stream: true,
21
- controller(socket, client, payload, wsManagementId, args) {
21
+ controller(socket, client, payload, hostKeyContext, args) {
22
22
  const [roomId, userId] = args;
23
23
 
24
24
  // Collect existing users in the room before registering the new one
25
25
  const existingUsers = [];
26
- for (const entry of Object.values(CoreWsStreamChannel.#state[wsManagementId])) {
26
+ for (const entry of Object.values(CoreWsStreamChannel.#state[hostKeyContext])) {
27
27
  if (entry[0] === roomId && entry[1]) existingUsers.push(entry[1]);
28
28
  }
29
29
 
30
- CoreWsStreamChannel.#state[wsManagementId][socket.id] = args;
30
+ CoreWsStreamChannel.#state[hostKeyContext][socket.id] = args;
31
31
  socket.join(roomId);
32
32
  socket.to(roomId).emit('stream-user-connected', userId);
33
33
 
34
34
  // Tell the joining user about everyone already in the room
35
35
  if (existingUsers.length > 0) socket.emit('stream-existing-users', existingUsers);
36
36
  },
37
- connection(socket, client, wsManagementId) {
38
- CoreWsStreamChannel.#state[wsManagementId][socket.id] = [];
37
+ connection(socket, client, hostKeyContext) {
38
+ CoreWsStreamChannel.#state[hostKeyContext][socket.id] = [];
39
39
  },
40
- disconnect(socket, client, reason, wsManagementId) {
41
- const entry = CoreWsStreamChannel.#state[wsManagementId]?.[socket.id];
40
+ disconnect(socket, client, reason, hostKeyContext) {
41
+ const entry = CoreWsStreamChannel.#state[hostKeyContext]?.[socket.id];
42
42
  if (!entry || entry.length === 0) {
43
- if (CoreWsStreamChannel.#state[wsManagementId]) delete CoreWsStreamChannel.#state[wsManagementId][socket.id];
43
+ if (CoreWsStreamChannel.#state[hostKeyContext]) delete CoreWsStreamChannel.#state[hostKeyContext][socket.id];
44
44
  return;
45
45
  }
46
46
  const [roomId, userId] = entry;
47
47
  socket.to(roomId).emit('stream-user-disconnected', userId);
48
- delete CoreWsStreamChannel.#state[wsManagementId][socket.id];
48
+ delete CoreWsStreamChannel.#state[hostKeyContext][socket.id];
49
49
  },
50
50
  });
51
51
 
@@ -61,29 +61,29 @@ class CoreWsStreamChannel {
61
61
 
62
62
  /**
63
63
  * Initializes state for a server instance.
64
- * @param {string} wsManagementId - Unique server context ID (`${host}${path}`).
64
+ * @param {string} hostKeyContext - Unique server context ID (`${host}${path}`).
65
65
  */
66
- static init(wsManagementId) {
67
- this.#state[wsManagementId] = {};
66
+ static init(hostKeyContext) {
67
+ this.#state[hostKeyContext] = {};
68
68
  }
69
69
 
70
70
  /**
71
71
  * Registers a socket connection.
72
72
  * @param {import('socket.io').Socket} socket
73
- * @param {string} wsManagementId
73
+ * @param {string} hostKeyContext
74
74
  */
75
- static connection(socket, wsManagementId) {
76
- return this.#io.connection(socket, wsManagementId);
75
+ static connection(socket, hostKeyContext) {
76
+ return this.#io.connection(socket, hostKeyContext);
77
77
  }
78
78
 
79
79
  /**
80
80
  * Handles socket disconnection.
81
81
  * @param {import('socket.io').Socket} socket
82
82
  * @param {string} reason
83
- * @param {string} wsManagementId
83
+ * @param {string} hostKeyContext
84
84
  */
85
- static disconnect(socket, reason, wsManagementId) {
86
- return this.#io.disconnect(socket, reason, wsManagementId);
85
+ static disconnect(socket, reason, hostKeyContext) {
86
+ return this.#io.disconnect(socket, reason, hostKeyContext);
87
87
  }
88
88
  }
89
89
 
@@ -19,21 +19,21 @@ class CoreWsConnectionHandler {
19
19
  /**
20
20
  * Handles a new WebSocket connection.
21
21
  * @param {import('socket.io').Socket} socket
22
- * @param {string} wsManagementId
22
+ * @param {string} hostKeyContext
23
23
  */
24
- static handle(socket, wsManagementId) {
24
+ static handle(socket, hostKeyContext) {
25
25
  logger.info(`New connection established. Socket ID: ${socket.id}`);
26
26
 
27
- CoreWsChatChannel.connection(socket, wsManagementId);
28
- CoreWsMailerChannel.connection(socket, wsManagementId);
29
- CoreWsStreamChannel.connection(socket, wsManagementId);
27
+ CoreWsChatChannel.connection(socket, hostKeyContext);
28
+ CoreWsMailerChannel.connection(socket, hostKeyContext);
29
+ CoreWsStreamChannel.connection(socket, hostKeyContext);
30
30
 
31
31
  socket.on('disconnect', (reason) => {
32
32
  logger.info(`Connection disconnected. Socket ID: ${socket.id}, reason: ${reason}`);
33
33
 
34
- CoreWsChatChannel.disconnect(socket, reason, wsManagementId);
35
- CoreWsMailerChannel.disconnect(socket, reason, wsManagementId);
36
- CoreWsStreamChannel.disconnect(socket, reason, wsManagementId);
34
+ CoreWsChatChannel.disconnect(socket, reason, hostKeyContext);
35
+ CoreWsMailerChannel.disconnect(socket, reason, hostKeyContext);
36
+ CoreWsStreamChannel.disconnect(socket, reason, hostKeyContext);
37
37
  });
38
38
  }
39
39
  }
@@ -10,6 +10,7 @@ import { CoreWsConnectionHandler } from './core.ws.connection.js';
10
10
  import { CoreWsChatChannel } from './channels/core.ws.chat.js';
11
11
  import { CoreWsMailerChannel } from './channels/core.ws.mailer.js';
12
12
  import { CoreWsStreamChannel } from './channels/core.ws.stream.js';
13
+ import { resolveHostKeyContext } from '../../server/conf.js';
13
14
 
14
15
  /**
15
16
  * @class CoreWsServer
@@ -27,13 +28,13 @@ class CoreWsServer {
27
28
  */
28
29
  static create(httpServer, options) {
29
30
  const { host, path } = options;
30
- const wsManagementId = `${host}${path}`;
31
+ const hostKeyContext = resolveHostKeyContext({ host, path });
31
32
 
32
- CoreWsChatChannel.init(wsManagementId);
33
- CoreWsMailerChannel.init(wsManagementId);
34
- CoreWsStreamChannel.init(wsManagementId);
33
+ CoreWsChatChannel.init(hostKeyContext);
34
+ CoreWsMailerChannel.init(hostKeyContext);
35
+ CoreWsStreamChannel.init(hostKeyContext);
35
36
 
36
- return IoServer.create(httpServer, options, (socket) => CoreWsConnectionHandler.handle(socket, wsManagementId));
37
+ return IoServer.create(httpServer, options, (socket) => CoreWsConnectionHandler.handle(socket, hostKeyContext));
37
38
  }
38
39
  }
39
40
 
@@ -10,7 +10,7 @@ import { IoChannel } from '../../IoInterface.js';
10
10
  * @classdesc Provides a no-op main channel for the default WebSocket server.
11
11
  */
12
12
  class DefaultWsMainChannel {
13
- /** @type {Object.<string, Object>} Per-instance state keyed by wsManagementId. */
13
+ /** @type {Object.<string, Object>} Per-instance state keyed by hostKeyContext. */
14
14
  static #state = {};
15
15
 
16
16
  /** @type {IoChannel} */
@@ -28,29 +28,29 @@ class DefaultWsMainChannel {
28
28
 
29
29
  /**
30
30
  * Initializes state for a server instance.
31
- * @param {string} wsManagementId
31
+ * @param {string} hostKeyContext
32
32
  */
33
- static init(wsManagementId) {
34
- this.#state[wsManagementId] = {};
33
+ static init(hostKeyContext) {
34
+ this.#state[hostKeyContext] = {};
35
35
  }
36
36
 
37
37
  /**
38
38
  * Registers a socket connection.
39
39
  * @param {import('socket.io').Socket} socket
40
- * @param {string} wsManagementId
40
+ * @param {string} hostKeyContext
41
41
  */
42
- static connection(socket, wsManagementId) {
43
- return this.#io.connection(socket, wsManagementId);
42
+ static connection(socket, hostKeyContext) {
43
+ return this.#io.connection(socket, hostKeyContext);
44
44
  }
45
45
 
46
46
  /**
47
47
  * Handles socket disconnection.
48
48
  * @param {import('socket.io').Socket} socket
49
49
  * @param {string} reason
50
- * @param {string} wsManagementId
50
+ * @param {string} hostKeyContext
51
51
  */
52
- static disconnect(socket, reason, wsManagementId) {
53
- return this.#io.disconnect(socket, reason, wsManagementId);
52
+ static disconnect(socket, reason, hostKeyContext) {
53
+ return this.#io.disconnect(socket, reason, hostKeyContext);
54
54
  }
55
55
  }
56
56
 
@@ -17,17 +17,17 @@ class DefaultWsConnectionHandler {
17
17
  /**
18
18
  * Handles a new WebSocket connection.
19
19
  * @param {import('socket.io').Socket} socket
20
- * @param {string} wsManagementId
20
+ * @param {string} hostKeyContext
21
21
  */
22
- static handle(socket, wsManagementId) {
22
+ static handle(socket, hostKeyContext) {
23
23
  logger.info(`DefaultWsConnection ${socket.id}`);
24
24
 
25
- DefaultWsMainChannel.connection(socket, wsManagementId);
25
+ DefaultWsMainChannel.connection(socket, hostKeyContext);
26
26
 
27
27
  socket.on('disconnect', (reason) => {
28
28
  logger.info(`DefaultWsConnection ${socket.id} due to reason: ${reason}`);
29
29
 
30
- DefaultWsMainChannel.disconnect(socket, reason, wsManagementId);
30
+ DefaultWsMainChannel.disconnect(socket, reason, hostKeyContext);
31
31
  });
32
32
  }
33
33
  }
@@ -8,6 +8,7 @@
8
8
  import { IoServer } from '../IoServer.js';
9
9
  import { DefaultWsConnectionHandler } from './default.ws.connection.js';
10
10
  import { DefaultWsMainChannel } from './channels/default.ws.main.js';
11
+ import { resolveHostKeyContext } from '../../server/conf.js';
11
12
 
12
13
  /**
13
14
  * @class DefaultWsServer
@@ -24,11 +25,11 @@ class DefaultWsServer {
24
25
  */
25
26
  static create(httpServer, options) {
26
27
  const { host, path } = options;
27
- const wsManagementId = `${host}${path}`;
28
+ const hostKeyContext = resolveHostKeyContext({ host, path });
28
29
 
29
- DefaultWsMainChannel.init(wsManagementId);
30
+ DefaultWsMainChannel.init(hostKeyContext);
30
31
 
31
- return IoServer.create(httpServer, options, (socket) => DefaultWsConnectionHandler.handle(socket, wsManagementId));
32
+ return IoServer.create(httpServer, options, (socket) => DefaultWsConnectionHandler.handle(socket, hostKeyContext));
32
33
  }
33
34
  }
34
35
 
@@ -1,21 +0,0 @@
1
- SrrComponent = (render = { style: {}, renderStyle: () => '' }, options) =>
2
- html`
3
- <div style="${render.renderStyle('body')}">
4
- <div style="${render.renderStyle('.container')}">
5
- <h1 style="${render.renderStyle('h1')}">{{H1}}</h1>
6
- <p style="${render.renderStyle('p')}">{{P1}}</p>
7
- <p style="${render.renderStyle('p')}">
8
- <a href="{{RECOVER_WEB_URL}}" style="${render.renderStyle('button')}"
9
- ><img
10
- src="http${options.transport.secure ? 's' : ''}://${options.host}${options.path === '/'
11
- ? ''
12
- : options.path}/api/user/recover/{{TOKEN}}"
13
- /><br />{{RECOVER_BTN_LABEL}}</a
14
- >
15
- </p>
16
- </div>
17
- <div style="${render.renderStyle('.footer')}">
18
- <p>{{COMPANY}}</p>
19
- </div>
20
- </div>
21
- `;
@@ -1,17 +0,0 @@
1
- SrrComponent = (render = { style: {}, renderStyle: () => '' }, options) =>
2
- html`
3
- <div style="${render.renderStyle('body')}">
4
- <div style="${render.renderStyle('.container')}">
5
- <h1 style="${render.renderStyle('h1')}">{{H1}}</h1>
6
- <p style="${render.renderStyle('p')}">{{P1}}</p>
7
- <img
8
- src="http${options.transport.secure ? 's' : ''}://${options.host}${options.path === '/'
9
- ? ''
10
- : options.path}/api/user/mailer/{{TOKEN}}"
11
- />
12
- </div>
13
- <div style="${render.renderStyle('.footer')}">
14
- <p>{{COMPANY}}</p>
15
- </div>
16
- </div>
17
- `;
File without changes