eventsimple 1.7.1 → 1.7.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 953514829adab38f167e1d3e64ca57121c701b868f18474924ce1252797d3670
4
- data.tar.gz: 02eebc6041d3404c885be084e01f3c1106687c677f9bc3de01853736c4f57590
3
+ metadata.gz: 2c652aa8da9fe1a5144ffa53eb34cbdd94f95804e23f2f9b289d8579156a582a
4
+ data.tar.gz: 7ac131b6e43c185979d748747f1dba89d4384eb778eb4b34b3ed7e1d00295924
5
5
  SHA512:
6
- metadata.gz: 21bc4fe5dd6730a6b08fe397be3e1371c3b6aec61318bdd5ea1fa617889172f8b417d5b3aef1459e0d496ef3db416cb564622319dc6a585f557052043d5f68e5
7
- data.tar.gz: f5acaa45ac8d2ac9e0e10cd9e97e3c686c3cb05a3d3e198b24283848438ae65114503ff081566c7cd150d697c895ca77da4825cee558a8b27704a2ead8b86fbd
6
+ metadata.gz: 21b9892b756841b10e05b69cab76ccc3d761b89d20e75c2554436f775b852e2494590b6295c91dd58c43175188ec5a51f939ba444140d62dc75f31b68d12d782
7
+ data.tar.gz: c378200993bcacc99c7d688a7b199a77e64eaa58961411fe3977d68e78835b7c4ecbc375d9fee05862703ec870116fcfb71f050b343a48f182e83a248ec0b147
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.7.3 - 2025-09-15
10
+ ### Changed
11
+ - Add `skip_deleted` option to `reproject` method
12
+
13
+ ## 1.7.2 - 2025-08-28
14
+ ### Changed
15
+ - Rescue `ActiveRecord::AdapterError` in Entity and Event validation
16
+
9
17
  ## 1.7.1 - 2025-08-22
10
18
  ### Changed
11
19
  - Use `model.unscoped` in Eventsimple UI to show soft-deleted records
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.7.1)
4
+ eventsimple (1.7.3)
5
5
  concurrent-ruby (>= 1.2.3)
6
6
  dry-struct (~> 1.6)
7
7
  dry-types (~> 1.7)
@@ -18,7 +18,7 @@ module Eventsimple
18
18
 
19
19
  raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
20
20
  end
21
- rescue ActiveRecord::NoDatabaseError
21
+ rescue ActiveRecord::AdapterError
22
22
  # skip checks if the database is not yet created
23
23
  end
24
24
 
@@ -66,8 +66,13 @@ module Eventsimple
66
66
  @readonly = was_readonly
67
67
  end
68
68
 
69
- def reproject(at: nil)
69
+ def reproject(at: nil, skip_deleted: false)
70
70
  event_history = at ? events.where('created_at <= ?', at).load : events.load
71
+
72
+ if !skip_deleted && event_history.any?(&:deleted?)
73
+ raise "Cannot reproject: deleted event(s) found in event history"
74
+ end
75
+
71
76
  ignore_props = (DEFAULT_IGNORE_PROPS + ignored_for_projection).map(&:to_s)
72
77
  assign_attributes(self.class.column_defaults.except(*ignore_props))
73
78
 
@@ -16,7 +16,7 @@ module Eventsimple
16
16
  raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
17
17
 
18
18
  end
19
- rescue ActiveRecord::NoDatabaseError
19
+ rescue ActiveRecord::AdapterError
20
20
  # skip checks if the database is not yet created
21
21
  end
22
22
 
@@ -69,6 +69,10 @@ module Eventsimple
69
69
  @skip_apply_check || false
70
70
  end
71
71
 
72
+ def deleted?
73
+ false
74
+ end
75
+
72
76
  # Apply the event to the aggregate passed in. The default behaviour is a no-op
73
77
  def apply(aggregate); end
74
78
 
@@ -149,10 +153,11 @@ module Eventsimple
149
153
  klass_name = "Deleted__#{type_name.demodulize}"
150
154
  return const_get(klass_name) if const_defined?(klass_name)
151
155
 
152
- # NOTE: this should still update the timestamps for the model to prevent
153
- # projection drift (since the original projection will
154
- # have the timestamps applied for the deleted event).
155
- klass = Class.new(self)
156
+ klass = Class.new(self) do
157
+ def deleted?
158
+ true
159
+ end
160
+ end
156
161
 
157
162
  const_set(klass_name, klass)
158
163
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.7.1'
4
+ VERSION = '1.7.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali