@toa.io/core 1.0.0-alpha.254 → 1.0.0-alpha.257

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 ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.0.0-alpha.257](https://github.com/toa-io/toa/compare/v1.0.0-alpha.256...v1.0.0-alpha.257) (2026-08-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **core:** lift tombstone on commit when transition leaves it untouched ([38c0d15](https://github.com/toa-io/toa/commit/38c0d15e946c3e2d559d4b18aecc33e0fda2471a))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/core",
3
- "version": "1.0.0-alpha.254",
3
+ "version": "1.0.0-alpha.257",
4
4
  "description": "Toa Core",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -27,5 +27,5 @@
27
27
  "openspan": "1.0.0-alpha.254",
28
28
  "uuid": "11.1.1"
29
29
  },
30
- "gitHead": "0538900d6604e97d8850fad732bb56fd6be4f208"
30
+ "gitHead": "2db23a4e2ff6740a5f852208a9b896812ec6f819"
31
31
  }
@@ -38,6 +38,7 @@ class Entity {
38
38
  if (error !== null)
39
39
  throw new EntityContractException(error, value)
40
40
 
41
+ this.#revive(value)
41
42
  this.#set(value)
42
43
  }
43
44
 
@@ -69,6 +70,16 @@ class Entity {
69
70
  }
70
71
  }
71
72
 
73
+ // deletion is only expressed as a new _deleted timestamp,
74
+ // so committing over a tombstone without touching it means revival
75
+ #revive (value) {
76
+ if (this.#origin?._deleted == null || value._deleted !== this.#origin._deleted)
77
+ return
78
+
79
+ value._deleted = null
80
+ this.deleted = false
81
+ }
82
+
72
83
  #set (value) {
73
84
  if (!('_trailers' in value))
74
85
  Object.defineProperty(value, '_trailers', {
@@ -16,6 +16,34 @@ describe('argument', () => {
16
16
  })
17
17
  })
18
18
 
19
+ describe('tombstone', () => {
20
+ it('should lift tombstone when transition leaves _deleted untouched', () => {
21
+ const origin = fixtures.state()
22
+ const entity = new Entity(fixtures.schema, origin)
23
+ const state = entity.get()
24
+
25
+ state.foo = 'revived'
26
+ entity.set(state)
27
+
28
+ expect(entity.get()._deleted).toBeNull()
29
+ expect(entity.deleted).toBe(false)
30
+ expect(entity.event().changeset._deleted).toBeNull()
31
+ })
32
+
33
+ it('should keep tombstone written by transition', () => {
34
+ const origin = { ...fixtures.state(), _deleted: null }
35
+ const entity = new Entity(fixtures.schema, origin)
36
+ const state = entity.get()
37
+ const timestamp = Date.now()
38
+
39
+ state._deleted = timestamp
40
+ entity.set(state)
41
+
42
+ expect(entity.get()._deleted).toBe(timestamp)
43
+ expect(entity.deleted).toBe(true)
44
+ })
45
+ })
46
+
19
47
  it('should provide event', () => {
20
48
  const origin = fixtures.state()
21
49
  const entity = new Entity(fixtures.schema, origin)