hola-server 1.0.10 → 2.0.1

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 (83) hide show
  1. package/README.md +196 -1
  2. package/core/array.js +79 -142
  3. package/core/bash.js +208 -259
  4. package/core/chart.js +26 -16
  5. package/core/cron.js +14 -3
  6. package/core/date.js +15 -44
  7. package/core/encrypt.js +19 -9
  8. package/core/file.js +42 -29
  9. package/core/lhs.js +32 -6
  10. package/core/meta.js +213 -289
  11. package/core/msg.js +20 -7
  12. package/core/number.js +105 -103
  13. package/core/obj.js +15 -12
  14. package/core/random.js +9 -6
  15. package/core/role.js +69 -77
  16. package/core/thread.js +12 -2
  17. package/core/type.js +300 -261
  18. package/core/url.js +20 -12
  19. package/core/validate.js +29 -26
  20. package/db/db.js +297 -227
  21. package/db/entity.js +631 -963
  22. package/db/gridfs.js +120 -166
  23. package/design/add_default_field_attr.md +56 -0
  24. package/http/context.js +22 -8
  25. package/http/cors.js +25 -8
  26. package/http/error.js +27 -9
  27. package/http/express.js +70 -41
  28. package/http/params.js +70 -42
  29. package/http/router.js +51 -40
  30. package/http/session.js +59 -36
  31. package/index.js +85 -9
  32. package/package.json +2 -2
  33. package/router/clone.js +28 -36
  34. package/router/create.js +21 -26
  35. package/router/delete.js +24 -28
  36. package/router/read.js +137 -123
  37. package/router/update.js +38 -56
  38. package/setting.js +22 -6
  39. package/skills/array.md +155 -0
  40. package/skills/bash.md +91 -0
  41. package/skills/chart.md +54 -0
  42. package/skills/code.md +422 -0
  43. package/skills/context.md +177 -0
  44. package/skills/date.md +58 -0
  45. package/skills/express.md +255 -0
  46. package/skills/file.md +60 -0
  47. package/skills/lhs.md +54 -0
  48. package/skills/meta.md +1023 -0
  49. package/skills/msg.md +30 -0
  50. package/skills/number.md +88 -0
  51. package/skills/obj.md +36 -0
  52. package/skills/params.md +206 -0
  53. package/skills/random.md +22 -0
  54. package/skills/role.md +59 -0
  55. package/skills/session.md +281 -0
  56. package/skills/storage.md +743 -0
  57. package/skills/thread.md +22 -0
  58. package/skills/type.md +547 -0
  59. package/skills/url.md +34 -0
  60. package/skills/validate.md +48 -0
  61. package/test/cleanup/close-db.js +5 -0
  62. package/test/core/array.js +226 -0
  63. package/test/core/chart.js +51 -0
  64. package/test/core/file.js +59 -0
  65. package/test/core/lhs.js +44 -0
  66. package/test/core/number.js +167 -12
  67. package/test/core/obj.js +47 -0
  68. package/test/core/random.js +24 -0
  69. package/test/core/thread.js +20 -0
  70. package/test/core/type.js +216 -0
  71. package/test/core/validate.js +67 -0
  72. package/test/db/db-ops.js +99 -0
  73. package/test/db/pipe_test.txt +0 -0
  74. package/test/db/test_case_design.md +528 -0
  75. package/test/db/test_db_class.js +613 -0
  76. package/test/db/test_entity_class.js +414 -0
  77. package/test/db/test_gridfs_class.js +234 -0
  78. package/test/entity/create.js +1 -1
  79. package/test/entity/delete-mixed.js +156 -0
  80. package/test/entity/ref-filter.js +63 -0
  81. package/tool/gen_i18n.js +55 -21
  82. package/test/crud/router.js +0 -99
  83. package/test/router/user.js +0 -17
package/core/validate.js CHANGED
@@ -1,32 +1,35 @@
1
- const is_undefined = function (value) {
2
- return typeof value === 'undefined';
3
- }
1
+ /**
2
+ * @fileoverview Validation utility functions for checking values and required fields.
3
+ * @module core/validate
4
+ */
4
5
 
5
- const has_value = function (value) {
6
- //In short, JavaScript NaN values are the only ones that are not equal to themselves
7
- //value!==value is to check is NaN
8
- if (value === undefined || value === null || value !== value) {
9
- return false
10
- }
11
- if (typeof value == 'undefined') {
12
- return false;
13
- }
14
- if (typeof value === 'string' && value.trim().length === 0) {
15
- return false;
16
- }
6
+ /**
7
+ * Check if a value is undefined.
8
+ * @param {*} value - The value to check.
9
+ * @returns {boolean} True if value is undefined, false otherwise.
10
+ */
11
+ const is_undefined = (value) => typeof value === 'undefined';
12
+
13
+ /**
14
+ * Check if a value exists and is meaningful (not null, undefined, NaN, or empty string).
15
+ * @param {*} value - The value to check.
16
+ * @returns {boolean} True if value has meaningful content, false otherwise.
17
+ */
18
+ const has_value = (value) => {
19
+ // null == undefined, value !== value checks for NaN
20
+ if (value == null || value !== value) return false;
21
+ if (typeof value === 'string' && value.trim().length === 0) return false;
17
22
  return true;
18
23
  };
19
24
 
20
- const validate_required_fields = function (obj, field_names) {
21
- const error_field_names = [];
22
- field_names.forEach(function (field_name) {
23
- const value = obj[field_name];
24
- if (!has_value(value)) {
25
- error_field_names.push(field_name);
26
- }
27
- });
28
-
29
- return error_field_names;
25
+ /**
26
+ * Validate that required fields have values in an object.
27
+ * @param {Object} obj - The object to validate.
28
+ * @param {string[]} field_names - Array of required field names.
29
+ * @returns {string[]} Array of field names that are missing values.
30
+ */
31
+ const validate_required_fields = (obj, field_names) => {
32
+ return field_names.filter((field_name) => !has_value(obj[field_name]));
30
33
  };
31
34
 
32
- module.exports = { is_undefined, has_value, validate_required_fields }
35
+ module.exports = { is_undefined, has_value, validate_required_fields };