@cocreate/utils 1.27.0 → 1.27.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.27.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.27.0...v1.27.1) (2023-11-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * meta name typo ([e629a89](https://github.com/CoCreate-app/CoCreate-utils/commit/e629a89c8a3943d9ef8eaa891f41756cd766e6bb))
7
+ * ObjectId use new Date(new Date().toISOString()).getTime() instead of date.now() preventing 24 possible collisions in a day ([89236e5](https://github.com/CoCreate-app/CoCreate-utils/commit/89236e534d958399827f7ad0fa9345bdecc06497))
8
+ * update host ([d234c14](https://github.com/CoCreate-app/CoCreate-utils/commit/d234c1459da3064105ba50cfef9bbdb0fe484cd9))
9
+
1
10
  # [1.27.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.26.2...v1.27.0) (2023-11-03)
2
11
 
3
12
 
@@ -12,8 +12,7 @@ module.exports = {
12
12
  "pathname": "/docs/utils/index.html",
13
13
  "src": "{{./docs/index.html}}",
14
14
  "host": [
15
- "*",
16
- "general.cocreate.app"
15
+ "*"
17
16
  ],
18
17
  "directory": "utils",
19
18
  "content-type": "{{content-type}}",
package/docs/index.html CHANGED
@@ -11,10 +11,10 @@
11
11
  sizes="32x32"
12
12
  href="https://cocreate.app/images/favicon.ico" />
13
13
  <meta
14
- key="description"
14
+ name="description"
15
15
  content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
16
16
  <meta
17
- key="keywords"
17
+ name="keywords"
18
18
  content="helper classes, utility classes, css framework, css library, inline style classes" />
19
19
  <meta name="robots" content="index,follow" />
20
20
  <meta
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/utils",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "utils",
package/src/index.js CHANGED
@@ -59,7 +59,7 @@
59
59
  }
60
60
 
61
61
  // Generate a new custom ObjectId
62
- const timestampHex = Math.floor(Date.now() / 1000).toString(16).padStart(8, '0');
62
+ const timestampHex = Math.floor(new Date(new Date().toISOString()).getTime() / 1000).toString(16).padStart(8, '0');
63
63
  const processIdHex = Math.floor(Math.random() * 0x100000000000).toString(16).padStart(12, '0');
64
64
 
65
65
  counter = (counter + 1) % 10000;
@@ -89,24 +89,19 @@
89
89
 
90
90
  function isValidDate(value) {
91
91
  if (typeof value === 'string' && value.length >= 20 && value.length <= 24) {
92
- const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/i;
93
- if (iso8601Regex.test(value)) {
94
- const dateObject = new Date(value);
95
- dateObject.setUTCHours(dateObject.getUTCHours(), 0, 0, 0);
96
- if (!isNaN(dateObject)) {
97
- return dateObject; // Is a valid date object and now utc
98
- }
92
+ // if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/i.test(value))
93
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([-+]\d{2}:\d{2}|Z)?$/i.test(value)) {
94
+ return true
99
95
  }
100
96
  }
101
97
 
102
- return value; // Is a valid date object adjusted to UTC time
103
-
98
+ return false;
104
99
  }
105
100
 
106
101
  function dotNotationToObject(data, obj = {}) {
107
102
  try {
108
103
  for (const key of Object.keys(data)) {
109
- let value = isValidDate(data[key])
104
+ let value = data[key]
110
105
  let newObject = obj
111
106
  let oldObject = new Object(obj)
112
107
  let keys = key.split('.');
@@ -463,8 +458,10 @@
463
458
  queryValue = queryValue.toLowerCase()
464
459
  }
465
460
 
466
- dataValue = isValidDate(dataValue)
467
- queryValue = isValidDate(queryValue)
461
+ if (isValidDate(dataValue) && isValidDate(queryValue)) {
462
+ dataValue = new Date(dataValue)
463
+ queryValue = new Date(queryValue)
464
+ }
468
465
 
469
466
  switch (query[i].operator) {
470
467
  case '$includes':