underpost 2.8.877 → 2.8.881

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 (54) hide show
  1. package/.env.development +35 -3
  2. package/.env.production +40 -3
  3. package/.env.test +35 -3
  4. package/.github/workflows/release.cd.yml +3 -3
  5. package/README.md +48 -36
  6. package/bin/deploy.js +40 -0
  7. package/cli.md +89 -86
  8. package/conf.js +28 -3
  9. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  10. package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
  11. package/package.json +1 -2
  12. package/src/api/document/document.controller.js +66 -0
  13. package/src/api/document/document.model.js +51 -0
  14. package/src/api/document/document.router.js +24 -0
  15. package/src/api/document/document.service.js +125 -0
  16. package/src/api/file/file.controller.js +15 -1
  17. package/src/api/user/user.router.js +4 -3
  18. package/src/cli/deploy.js +1 -1
  19. package/src/cli/index.js +3 -0
  20. package/src/cli/repository.js +2 -2
  21. package/src/cli/run.js +29 -1
  22. package/src/client/Default.index.js +42 -1
  23. package/src/client/components/core/Account.js +8 -1
  24. package/src/client/components/core/AgGrid.js +18 -9
  25. package/src/client/components/core/BtnIcon.js +3 -2
  26. package/src/client/components/core/Content.js +13 -11
  27. package/src/client/components/core/CssCore.js +4 -0
  28. package/src/client/components/core/Docs.js +0 -3
  29. package/src/client/components/core/Input.js +34 -19
  30. package/src/client/components/core/Modal.js +29 -7
  31. package/src/client/components/core/ObjectLayerEngine.js +370 -0
  32. package/src/client/components/core/ObjectLayerEngineModal.js +1 -0
  33. package/src/client/components/core/Panel.js +7 -2
  34. package/src/client/components/core/PanelForm.js +187 -63
  35. package/src/client/components/core/VanillaJs.js +3 -0
  36. package/src/client/components/default/MenuDefault.js +94 -41
  37. package/src/client/components/default/RoutesDefault.js +2 -0
  38. package/src/client/services/default/default.management.js +1 -0
  39. package/src/client/services/document/document.service.js +97 -0
  40. package/src/client/services/file/file.service.js +2 -0
  41. package/src/client/services/user/user.service.js +1 -0
  42. package/src/client/ssr/Render.js +1 -1
  43. package/src/client/ssr/head/DefaultScripts.js +2 -0
  44. package/src/client/ssr/head/Seo.js +1 -0
  45. package/src/index.js +1 -1
  46. package/src/mailer/EmailRender.js +1 -1
  47. package/src/server/auth.js +4 -3
  48. package/src/server/client-build.js +2 -3
  49. package/src/server/client-formatted.js +40 -12
  50. package/src/server/conf.js +42 -3
  51. package/src/server/object-layer.js +196 -0
  52. package/src/server/runtime.js +18 -21
  53. package/src/server/ssr.js +52 -10
  54. package/src/server/valkey.js +89 -1
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Module for managing Valkey
3
+ * @module src/server/valkey.js
4
+ * @namespace Valkey
5
+ */
6
+
1
7
  import Valkey from 'iovalkey';
2
8
  import mongoose from 'mongoose';
3
9
  import { hashPassword } from './auth.js';
@@ -10,11 +16,35 @@ const ValkeyInstances = {};
10
16
  const DummyStores = {}; // in-memory Maps per instance
11
17
  const ValkeyStatus = {}; // 'connected' | 'dummy' | 'error' | undefined
12
18
 
13
- // Backward-compatible overall flag: true if any instance is connected
19
+ /**
20
+ * Checks if any Valkey instance is connected.
21
+ * This is a backward-compatible overall flag.
22
+ * @returns {boolean} True if any instance has a 'connected' status.
23
+ * @memberof Valkey
24
+ */
14
25
  const isValkeyEnable = () => Object.values(ValkeyStatus).some((s) => s === 'connected');
15
26
 
27
+ /**
28
+ * Generates a unique key for a Valkey instance based on its host and path.
29
+ * @param {object} [opts={ host: '', path: '' }] - The instance options.
30
+ * @param {string} [opts.host=''] - The host of the instance.
31
+ * @param {string} [opts.path=''] - The path of the instance.
32
+ * @returns {string} The instance key.
33
+ * @private
34
+ * @memberof Valkey
35
+ */
16
36
  const _instanceKey = (opts = { host: '', path: '' }) => `${opts.host || ''}${opts.path || ''}`;
17
37
 
38
+ /**
39
+ * Creates and manages a connection to a Valkey server for a given instance.
40
+ * It sets up a client, attaches event listeners for connection status, and implements a fallback to an in-memory dummy store if the connection fails.
41
+ * @param {object} [instance={ host: '', path: '' }] - The instance identifier.
42
+ * @param {string} [instance.host=''] - The host of the instance.
43
+ * @param {string} [instance.path=''] - The path of the instance.
44
+ * @param {object} [valkeyServerConnectionOptions={ host: '', path: '' }] - Connection options for the iovalkey client.
45
+ * @returns {Promise<Valkey|undefined>} A promise that resolves to the Valkey client instance, or undefined if creation fails.
46
+ * @memberof Valkey
47
+ */
18
48
  const createValkeyConnection = async (
19
49
  instance = { host: '', path: '' },
20
50
  valkeyServerConnectionOptions = { host: '', path: '' },
@@ -72,6 +102,14 @@ const createValkeyConnection = async (
72
102
  return ValkeyInstances[key];
73
103
  };
74
104
 
105
+ /**
106
+ * Factory function to create a Data Transfer Object (DTO) from a payload.
107
+ * It filters the payload to include only the keys specified in the `select` object.
108
+ * @param {object} payload - The source object.
109
+ * @param {object} select - An object where keys are field names and values are 1 to include them.
110
+ * @returns {object} A new object containing only the selected fields from the payload.
111
+ * @memberof Valkey
112
+ */
75
113
  const selectDtoFactory = (payload, select) => {
76
114
  const result = {};
77
115
  for (const key of Object.keys(select)) {
@@ -80,6 +118,12 @@ const selectDtoFactory = (payload, select) => {
80
118
  return result;
81
119
  };
82
120
 
121
+ /**
122
+ * Factory function to create a new Valkey client instance.
123
+ * @param {object} options - Connection options for the iovalkey client.
124
+ * @returns {Promise<Valkey>} A promise that resolves to a new Valkey client.
125
+ * @memberof Valkey
126
+ */
83
127
  const valkeyClientFactory = async (options) => {
84
128
  const valkey = new Valkey({
85
129
  port: options?.port ? options.port : undefined,
@@ -103,6 +147,15 @@ const valkeyClientFactory = async (options) => {
103
147
  return valkey;
104
148
  };
105
149
 
150
+ /**
151
+ * Retrieves an object from Valkey by key for a specific instance.
152
+ * If the Valkey client is not connected or an error occurs, it falls back to the dummy in-memory store.
153
+ * It automatically parses JSON strings.
154
+ * @param {object} [options={ host: '', path: '' }] - The instance identifier.
155
+ * @param {string} [key=''] - The key of the object to retrieve.
156
+ * @returns {Promise<object|string|null>} A promise that resolves to the retrieved object, string, or null if not found.
157
+ * @memberof Valkey
158
+ */
106
159
  const getValkeyObject = async (options = { host: '', path: '' }, key = '') => {
107
160
  const k = _instanceKey(options);
108
161
  const status = ValkeyStatus[k];
@@ -124,6 +177,16 @@ const getValkeyObject = async (options = { host: '', path: '' }, key = '') => {
124
177
  return DummyStores[k]?.get(key) ?? null;
125
178
  };
126
179
 
180
+ /**
181
+ * Sets an object or string in Valkey for a specific instance.
182
+ * If the Valkey client is not connected, it writes to the in-memory dummy store instead.
183
+ * Objects are automatically stringified.
184
+ * @param {object} [options={ host: '', path: '' }] - The instance identifier.
185
+ * @param {string} [key=''] - The key under which to store the payload.
186
+ * @param {object|string} [payload={}] - The data to store.
187
+ * @returns {Promise<string>} A promise that resolves to 'OK' on success.
188
+ * @memberof Valkey
189
+ */
127
190
  const setValkeyObject = async (options = { host: '', path: '' }, key = '', payload = {}) => {
128
191
  const k = _instanceKey(options);
129
192
  const isString = typeof payload === 'string';
@@ -141,6 +204,16 @@ const setValkeyObject = async (options = { host: '', path: '' }, key = '', paylo
141
204
  return 'OK';
142
205
  };
143
206
 
207
+ /**
208
+ * Updates an existing object in Valkey by merging it with a new payload.
209
+ * It retrieves the current object, merges it with the new payload, and sets the updated object back.
210
+ * It also updates the `updatedAt` timestamp.
211
+ * @param {object} [options={ host: '', path: '' }] - The instance identifier.
212
+ * @param {string} [key=''] - The key of the object to update.
213
+ * @param {object} [payload={}] - The new data to merge into the object.
214
+ * @returns {Promise<string>} A promise that resolves to the result of the set operation.
215
+ * @memberof Valkey
216
+ */
144
217
  const updateValkeyObject = async (options = { host: '', path: '' }, key = '', payload = {}) => {
145
218
  let base = await getValkeyObject(options, key);
146
219
  if (typeof base !== 'object' || base === null) base = {};
@@ -148,6 +221,17 @@ const updateValkeyObject = async (options = { host: '', path: '' }, key = '', pa
148
221
  return await setValkeyObject(options, key, { ...base, ...payload });
149
222
  };
150
223
 
224
+ /**
225
+ * Factory function to create a new object based on a model schema.
226
+ * It generates a new object with default properties like `_id`, `createdAt`, and `updatedAt`,
227
+ * and model-specific properties.
228
+ * @param {object} [options={ host: 'localhost', path: '', object: {} }] - Options for object creation.
229
+ * @param {string} [options.host='localhost'] - The host context for the object.
230
+ * @param {object} [options.object={}] - An initial object to extend.
231
+ * @param {string} [model=''] - The name of the model schema to use (e.g., 'user').
232
+ * @returns {Promise<object>} A promise that resolves to the newly created object.
233
+ * @memberof Valkey
234
+ */
151
235
  const valkeyObjectFactory = async (options = { host: 'localhost', path: '', object: {} }, model = '') => {
152
236
  const idoDate = new Date().toISOString();
153
237
  options.object = options.object || {};
@@ -181,6 +265,10 @@ const valkeyObjectFactory = async (options = { host: 'localhost', path: '', obje
181
265
  }
182
266
  };
183
267
 
268
+ /**
269
+ * A collection of Valkey-related API functions.
270
+ * @type {object}
271
+ */
184
272
  const ValkeyAPI = {
185
273
  valkeyClientFactory,
186
274
  selectDtoFactory,