@toa.io/core 1.0.0-alpha.123 → 1.0.0-alpha.126

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/core",
3
- "version": "1.0.0-alpha.123",
3
+ "version": "1.0.0-alpha.126",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -26,5 +26,5 @@
26
26
  "error-value": "0.3.0",
27
27
  "openspan": "1.0.0-alpha.93"
28
28
  },
29
- "gitHead": "8dfee957c1d79b256363c39565811373de2b0f8b"
29
+ "gitHead": "5d350c594b9ad4e0c5956c5ffcb792306b9004ed"
30
30
  }
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const { Readable } = require('node:stream')
4
3
  const { SystemException } = require('../exceptions')
5
4
 
6
5
  class Contract {
@@ -14,7 +14,7 @@ class Entity {
14
14
 
15
15
  if (typeof argument === 'object') {
16
16
  const object = structuredClone(argument)
17
- this.set(object)
17
+ this.#set(object)
18
18
  this.#origin = argument
19
19
  } else {
20
20
  const id = argument === undefined ? newid() : argument
@@ -60,8 +60,10 @@ class Entity {
60
60
  value: {}
61
61
  })
62
62
 
63
- if (!('_created' in value))
63
+ if (!('_created' in value)) {
64
64
  value._created = Date.now()
65
+ value._updated ??= value._created
66
+ }
65
67
 
66
68
  if (value._deleted !== null)
67
69
  this.deleted = true
@@ -33,8 +33,9 @@ const projection = (projection, properties) => {
33
33
  }
34
34
  }
35
35
 
36
- if (projection.includes('_version') === false)
37
- projection.push('_version')
36
+ for (const property of ['_version', '_created', '_updated', '_deleted'])
37
+ if (!projection.includes(property))
38
+ projection.push(property)
38
39
  }
39
40
 
40
41
  exports.options = options