paper_trail_diff 0.2.0 → 0.3.0

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -0
  3. data/QUICKSTART.md +44 -2
  4. data/README.md +179 -14
  5. data/lib/paper_trail_diff/activity_child_candidate_loader.rb +73 -0
  6. data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +261 -45
  7. data/lib/paper_trail_diff/activity_history.rb +136 -0
  8. data/lib/paper_trail_diff/activity_range.rb +28 -12
  9. data/lib/paper_trail_diff/activity_snapshot_delta.rb +64 -0
  10. data/lib/paper_trail_diff/activity_snapshot_sequence.rb +3 -3
  11. data/lib/paper_trail_diff/activity_timeline_builder.rb +54 -45
  12. data/lib/paper_trail_diff/activity_version_collector.rb +14 -17
  13. data/lib/paper_trail_diff/branch_snapshot_refresher.rb +5 -3
  14. data/lib/paper_trail_diff/collection_comparator.rb +155 -0
  15. data/lib/paper_trail_diff/collection_identity_index.rb +53 -0
  16. data/lib/paper_trail_diff/collection_transition.rb +25 -0
  17. data/lib/paper_trail_diff/comparison_batch.rb +151 -0
  18. data/lib/paper_trail_diff/engine.rb +5 -45
  19. data/lib/paper_trail_diff/errors.rb +9 -0
  20. data/lib/paper_trail_diff/historical_snapshot_store.rb +55 -3
  21. data/lib/paper_trail_diff/instrumentation.rb +30 -0
  22. data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +133 -0
  23. data/lib/paper_trail_diff/live_endpoint_provider.rb +48 -0
  24. data/lib/paper_trail_diff/live_graph_collector.rb +52 -0
  25. data/lib/paper_trail_diff/paper_trail_adapter.rb +61 -34
  26. data/lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb +48 -0
  27. data/lib/paper_trail_diff/prepared_edge_loader.rb +54 -17
  28. data/lib/paper_trail_diff/prepared_history.rb +14 -4
  29. data/lib/paper_trail_diff/prepared_history_loader.rb +17 -9
  30. data/lib/paper_trail_diff/prepared_record_index.rb +138 -10
  31. data/lib/paper_trail_diff/snapshot.rb +66 -3
  32. data/lib/paper_trail_diff/support.rb +18 -0
  33. data/lib/paper_trail_diff/time_activity_timeline_builder.rb +111 -0
  34. data/lib/paper_trail_diff/time_range.rb +85 -0
  35. data/lib/paper_trail_diff/time_version_range.rb +53 -0
  36. data/lib/paper_trail_diff/timeline_builder.rb +13 -7
  37. data/lib/paper_trail_diff/timeline_range.rb +72 -0
  38. data/lib/paper_trail_diff/version.rb +1 -1
  39. data/lib/paper_trail_diff/version_association_candidate_scope.rb +73 -0
  40. data/lib/paper_trail_diff.rb +74 -12
  41. data/sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs +40 -0
  42. data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +49 -8
  43. data/sig/generated/paper_trail_diff/activity_history.rbs +79 -0
  44. data/sig/generated/paper_trail_diff/activity_range.rbs +14 -5
  45. data/sig/generated/paper_trail_diff/activity_snapshot_delta.rbs +33 -0
  46. data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +2 -2
  47. data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +15 -10
  48. data/sig/generated/paper_trail_diff/activity_version_collector.rbs +2 -5
  49. data/sig/generated/paper_trail_diff/branch_snapshot_refresher.rbs +2 -2
  50. data/sig/generated/paper_trail_diff/collection_comparator.rbs +59 -0
  51. data/sig/generated/paper_trail_diff/collection_identity_index.rbs +29 -0
  52. data/sig/generated/paper_trail_diff/collection_transition.rbs +18 -0
  53. data/sig/generated/paper_trail_diff/comparison_batch.rbs +65 -0
  54. data/sig/generated/paper_trail_diff/engine.rbs +0 -12
  55. data/sig/generated/paper_trail_diff/errors.rbs +12 -0
  56. data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +22 -2
  57. data/sig/generated/paper_trail_diff/instrumentation.rbs +12 -0
  58. data/sig/generated/paper_trail_diff/live_endpoint_batch_loader.rbs +52 -0
  59. data/sig/generated/paper_trail_diff/live_endpoint_provider.rbs +23 -0
  60. data/sig/generated/paper_trail_diff/live_graph_collector.rbs +27 -0
  61. data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +21 -10
  62. data/sig/generated/paper_trail_diff/preloaded_endpoint_batch_loader.rbs +24 -0
  63. data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +22 -8
  64. data/sig/generated/paper_trail_diff/prepared_history.rbs +6 -0
  65. data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +4 -2
  66. data/sig/generated/paper_trail_diff/prepared_record_index.rbs +61 -6
  67. data/sig/generated/paper_trail_diff/snapshot.rbs +37 -2
  68. data/sig/generated/paper_trail_diff/support.rbs +6 -0
  69. data/sig/generated/paper_trail_diff/time_activity_timeline_builder.rbs +46 -0
  70. data/sig/generated/paper_trail_diff/time_range.rbs +41 -0
  71. data/sig/generated/paper_trail_diff/time_version_range.rbs +27 -0
  72. data/sig/generated/paper_trail_diff/timeline_builder.rbs +6 -5
  73. data/sig/generated/paper_trail_diff/timeline_range.rbs +41 -0
  74. data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +32 -0
  75. data/sig/generated/paper_trail_diff.rbs +16 -8
  76. metadata +38 -4
@@ -5,27 +5,38 @@ require 'paper_trail'
5
5
 
6
6
  require_relative 'paper_trail_diff/version'
7
7
  require_relative 'paper_trail_diff/support'
8
+ require_relative 'paper_trail_diff/instrumentation'
8
9
  require_relative 'paper_trail_diff/errors'
9
10
  require_relative 'paper_trail_diff/configuration'
10
11
  require_relative 'paper_trail_diff/endpoint'
11
12
  require_relative 'paper_trail_diff/association_traversal'
12
13
  require_relative 'paper_trail_diff/association_discovery'
13
14
  require_relative 'paper_trail_diff/diagnostics'
15
+ require_relative 'paper_trail_diff/collection_identity_index'
16
+ require_relative 'paper_trail_diff/collection_transition'
14
17
  require_relative 'paper_trail_diff/snapshot'
18
+ require_relative 'paper_trail_diff/activity_snapshot_delta'
15
19
  require_relative 'paper_trail_diff/value_objects'
16
20
  require_relative 'paper_trail_diff/traversal_entry'
17
21
  require_relative 'paper_trail_diff/traversal_emitter'
18
22
  require_relative 'paper_trail_diff/snapshot_traversal'
19
23
  require_relative 'paper_trail_diff/association_diff_traversal'
20
24
  require_relative 'paper_trail_diff/traversal'
25
+ require_relative 'paper_trail_diff/collection_comparator'
21
26
  require_relative 'paper_trail_diff/engine'
22
27
  require_relative 'paper_trail_diff/historical_association_reifier'
23
28
  require_relative 'paper_trail_diff/prepared_record_index'
24
29
  require_relative 'paper_trail_diff/prepared_history'
30
+ require_relative 'paper_trail_diff/version_association_candidate_scope'
25
31
  require_relative 'paper_trail_diff/prepared_edge_loader'
26
32
  require_relative 'paper_trail_diff/prepared_history_loader'
27
33
  require_relative 'paper_trail_diff/prepared_association_reifier'
28
34
  require_relative 'paper_trail_diff/live_association_reader'
35
+ require_relative 'paper_trail_diff/live_endpoint_batch_loader'
36
+ require_relative 'paper_trail_diff/preloaded_endpoint_batch_loader'
37
+ require_relative 'paper_trail_diff/live_endpoint_provider'
38
+ require_relative 'paper_trail_diff/live_graph_collector'
39
+ require_relative 'paper_trail_diff/comparison_batch'
29
40
  require_relative 'paper_trail_diff/snapshot_normalizer'
30
41
  require_relative 'paper_trail_diff/historical_snapshot_store'
31
42
  require_relative 'paper_trail_diff/timeline_snapshot_provider'
@@ -36,11 +47,17 @@ require_relative 'paper_trail_diff/activity_boundary'
36
47
  require_relative 'paper_trail_diff/step'
37
48
  require_relative 'paper_trail_diff/analysis'
38
49
  require_relative 'paper_trail_diff/version_range'
50
+ require_relative 'paper_trail_diff/time_range'
51
+ require_relative 'paper_trail_diff/time_version_range'
52
+ require_relative 'paper_trail_diff/timeline_range'
39
53
  require_relative 'paper_trail_diff/timeline_builder'
40
54
  require_relative 'paper_trail_diff/activity_range'
41
55
  require_relative 'paper_trail_diff/activity_event'
56
+ require_relative 'paper_trail_diff/activity_child_candidate_loader'
42
57
  require_relative 'paper_trail_diff/activity_version_collector'
43
58
  require_relative 'paper_trail_diff/activity_snapshot_sequence'
59
+ require_relative 'paper_trail_diff/activity_history'
60
+ require_relative 'paper_trail_diff/time_activity_timeline_builder'
44
61
  require_relative 'paper_trail_diff/activity_timeline_builder'
45
62
  require_relative 'paper_trail_diff/paper_trail_adapter'
46
63
 
@@ -53,6 +70,8 @@ require_relative 'paper_trail_diff/paper_trail_adapter'
53
70
  # type association_diffs = Hash[String, association_diff]
54
71
  # type association_snapshots = Hash[String, AssociationSnapshot]
55
72
  # type identity = Array[untyped]
73
+ # type comparison_input = Hash[String | Symbol, untyped]
74
+ # type comparison_results = Hash[identity, Diff]
56
75
  # type ignore_option = Array[String | Symbol] | Hash[String | Symbol, untyped]
57
76
  # type reference_key = :type | :id | "type" | "id"
58
77
  # type traversal_context = :change | :included_state
@@ -73,40 +92,82 @@ module PaperTrailDiff
73
92
 
74
93
  class << self
75
94
  # Compares net state between explicit PaperTrail-version or current-record endpoints.
76
- #: (untyped, untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option) -> Diff
77
- def compare(from_version, to_version, associations: [], ignore: DEFAULT_IGNORED_ATTRIBUTES)
78
- PaperTrailAdapter.new(associations: associations, ignore: ignore).compare(
95
+ #: (untyped, untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool) -> Diff
96
+ def compare(
97
+ from_version,
98
+ to_version,
99
+ associations: [],
100
+ ignore: DEFAULT_IGNORED_ATTRIBUTES,
101
+ reload_live_endpoints: true
102
+ )
103
+ PaperTrailAdapter.new(
104
+ associations: associations,
105
+ ignore: ignore,
106
+ reload_live_endpoints: reload_live_endpoints
107
+ ).compare(
79
108
  from_version,
80
109
  to_version
81
110
  )
82
111
  end
83
112
 
113
+ # Compares many independent endpoint pairs while batching current-record loading.
114
+ #: (Array[comparison_input], ?associations: Array[String | Symbol], ?ignore: ignore_option, ?reload_live_endpoints: bool) -> comparison_results
115
+ def compare_many(
116
+ comparisons,
117
+ associations: [],
118
+ ignore: DEFAULT_IGNORED_ATTRIBUTES,
119
+ reload_live_endpoints: true
120
+ )
121
+ PaperTrailAdapter.new(
122
+ associations: associations,
123
+ ignore: ignore,
124
+ reload_live_endpoints: reload_live_endpoints
125
+ ).compare_many(comparisons)
126
+ end
127
+
84
128
  # Compares every adjacent reconstructed state in an inclusive version range.
85
- #: (untyped, from: untyped, to: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option) -> Array[Step]
86
- def timeline(record, from:, to:, associations: [], ignore: DEFAULT_IGNORED_ATTRIBUTES)
129
+ #: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option) -> Array[Step]
130
+ def timeline( # rubocop:disable Metrics/ParameterLists
131
+ record,
132
+ from: nil,
133
+ to: nil,
134
+ within: nil,
135
+ associations: [],
136
+ ignore: DEFAULT_IGNORED_ATTRIBUTES
137
+ )
87
138
  PaperTrailAdapter.new(associations: associations, ignore: ignore).timeline(
88
139
  record,
89
140
  from: from,
90
- to: to
141
+ to: to,
142
+ within: within
91
143
  )
92
144
  end
93
145
 
94
146
  # Compares adjacent root and selected-descendant activity boundaries.
95
- #: (untyped, from: untyped, to: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option) -> Array[ActivityStep]
96
- def activity_timeline(record, from:, to:, associations: [], ignore: DEFAULT_IGNORED_ATTRIBUTES)
147
+ #: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option) -> Array[ActivityStep]
148
+ def activity_timeline( # rubocop:disable Metrics/ParameterLists
149
+ record,
150
+ from: nil,
151
+ to: nil,
152
+ within: nil,
153
+ associations: [],
154
+ ignore: DEFAULT_IGNORED_ATTRIBUTES
155
+ )
97
156
  PaperTrailAdapter.new(associations: associations, ignore: ignore).activity_timeline(
98
157
  record,
99
158
  from: from,
100
- to: to
159
+ to: to,
160
+ within: within
101
161
  )
102
162
  end
103
163
 
104
164
  # Builds an endpoint diff and root-checkpoint timeline while normalizing each version once.
105
- #: (untyped, from: untyped, to: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool) -> Analysis
165
+ #: (untyped, ?from: untyped, ?to: untyped, ?within: untyped, ?associations: Array[String | Symbol], ?ignore: ignore_option, ?activity: bool) -> Analysis
106
166
  def analyze( # rubocop:disable Metrics/ParameterLists
107
167
  record,
108
- from:,
109
- to:,
168
+ from: nil,
169
+ to: nil,
170
+ within: nil,
110
171
  associations: [],
111
172
  ignore: DEFAULT_IGNORED_ATTRIBUTES,
112
173
  activity: false
@@ -115,6 +176,7 @@ module PaperTrailDiff
115
176
  record,
116
177
  from: from,
117
178
  to: to,
179
+ within: within,
118
180
  activity: activity
119
181
  )
120
182
  end
@@ -0,0 +1,40 @@
1
+ # Generated from lib/paper_trail_diff/activity_child_candidate_loader.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Loads direct-child identities active at or after one activity boundary.
5
+ class ActivityChildCandidateLoader
6
+ # : (untyped, Array[untyped], untyped, ActivityRange) -> void
7
+ def initialize: (untyped, Array[untyped], untyped, ActivityRange) -> void
8
+
9
+ # : () -> Array[untyped]
10
+ def call: () -> Array[untyped]
11
+
12
+ private
13
+
14
+ @parent_class: untyped
15
+
16
+ @parent_ids: Array[untyped]
17
+
18
+ @range: ActivityRange
19
+
20
+ @reflection: untyped
21
+
22
+ # : () -> Array[untyped]
23
+ def historical_ids: () -> Array[untyped]
24
+
25
+ # : (untyped) -> untyped
26
+ def historical_relation: (untyped) -> untyped
27
+
28
+ # : (untyped) -> VersionAssociationCandidateScope
29
+ def candidate_scope: (untyped) -> VersionAssociationCandidateScope
30
+
31
+ # : () -> Array[untyped]
32
+ def current_ids: () -> Array[untyped]
33
+
34
+ # : () -> String
35
+ def child_item_type: () -> String
36
+
37
+ # : () -> Array[String?]
38
+ def parent_types: () -> Array[String?]
39
+ end
40
+ end
@@ -6,8 +6,8 @@ module PaperTrailDiff
6
6
  class ActivityEventSnapshotRefresher
7
7
  RECORD_AFTER_HANDLERS: untyped
8
8
 
9
- # : (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped) -> void
10
- def initialize: (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped) -> void
9
+ # : (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped, ?record_transition: untyped) -> void
10
+ def initialize: (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped, ?record_transition: untyped) -> void
11
11
 
12
12
  # : (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [bool, RecordSnapshot?]
13
13
  def call: (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [ bool, RecordSnapshot? ]
@@ -20,13 +20,30 @@ module PaperTrailDiff
20
20
 
21
21
  @pool: SnapshotPool
22
22
 
23
+ @record_transition: untyped
24
+
23
25
  @traversal: AssociationTraversal
24
26
 
25
27
  # : (Array[Array[untyped]], untyped) -> bool
26
28
  def unsafe_through_membership_event?: (Array[Array[untyped]], untyped) -> bool
27
29
 
28
- # : (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped) -> [bool, RecordSnapshot]
29
- def collection_target_snapshot: (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped) -> [ bool, RecordSnapshot ]
30
+ # : (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
31
+ def unsafe_nested_membership_delta?: (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
32
+
33
+ # : (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [bool, RecordSnapshot]
34
+ def collection_target_snapshot: (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [ bool, RecordSnapshot ]
35
+
36
+ # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, untyped, untyped) -> [untyped, RecordSnapshot?]
37
+ def collection_route_event_state: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, untyped, untyped) -> [ untyped, RecordSnapshot? ]
38
+
39
+ # : (untyped, Array[untyped], SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
40
+ def normalized_collection_event_record: (untyped, Array[untyped], SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
41
+
42
+ # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
43
+ def existing_delta_record: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
44
+
45
+ # : (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
46
+ def nested_delta_owner: (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
30
47
 
31
48
  # : (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
32
49
  def direct_collection_routes: (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
@@ -34,6 +51,18 @@ module PaperTrailDiff
34
51
  # : (RecordSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, ?depth: Integer) -> [RecordSnapshot, bool]
35
52
  def replace_collection_route: (RecordSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, ?depth: Integer) -> [ RecordSnapshot, bool ]
36
53
 
54
+ # : (AssociationSnapshot, untyped, untyped, untyped, RecordSnapshot, RecordSnapshot?) -> RecordSnapshot?
55
+ def collection_event_child: (AssociationSnapshot, untyped, untyped, untyped, RecordSnapshot, RecordSnapshot?) -> RecordSnapshot?
56
+
57
+ # : (AssociationSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, Integer) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]?
58
+ def replace_targeted_collection_parent: (AssociationSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, Integer) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]?
59
+
60
+ # : (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
61
+ def targeted_parent_replacement: (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
62
+
63
+ # : (AssociationSnapshot, untyped, untyped, untyped) -> Integer?
64
+ def nested_owner_position: (AssociationSnapshot, untyped, untyped, untyped) -> Integer?
65
+
37
66
  # : (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [bool, RecordSnapshot?]
38
67
  def belongs_to_target_snapshot: (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [ bool, RecordSnapshot? ]
39
68
 
@@ -77,8 +106,17 @@ module PaperTrailDiff
77
106
  # : (untyped, untyped, untyped) -> untyped
78
107
  def standard_changeset: (untyped, untyped, untyped) -> untyped
79
108
 
80
- # : (untyped, untyped, RecordSnapshot) -> bool
81
- def member_of_owner?: (untyped, untyped, RecordSnapshot) -> bool
109
+ # : (untyped) -> ActivitySnapshotDelta?
110
+ def activity_snapshot_delta: (untyped) -> ActivitySnapshotDelta?
111
+
112
+ # : (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
113
+ def member_of_owner?: (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
114
+
115
+ # : (untyped, untyped, state: Symbol) -> untyped
116
+ def event_attribute: (untyped, untyped, state: Symbol) -> untyped
117
+
118
+ # : (untyped, untyped, state: Symbol) -> untyped
119
+ def relationship_owner_id: (untyped, untyped, state: Symbol) -> untyped
82
120
 
83
121
  # : (untyped, untyped, AssociationTree, String, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
84
122
  def normalize_event_record: (untyped, untyped, AssociationTree, String, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
@@ -86,8 +124,11 @@ module PaperTrailDiff
86
124
  # : (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
87
125
  def historical_reader: (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
88
126
 
89
- # : (Array[RecordSnapshot], untyped, RecordSnapshot?) -> Array[RecordSnapshot]
90
- def replace_collection_record: (Array[RecordSnapshot], untyped, RecordSnapshot?) -> Array[RecordSnapshot]
127
+ # : (AssociationSnapshot, untyped, RecordSnapshot?) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
128
+ def replace_collection_record: (AssociationSnapshot, untyped, RecordSnapshot?) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
129
+
130
+ # : (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
131
+ def replacement_collection_records: (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
91
132
 
92
133
  # : (untyped, RecordSnapshot?) -> String
93
134
  def replacement_type: (untyped, RecordSnapshot?) -> String
@@ -0,0 +1,79 @@
1
+ # Generated from lib/paper_trail_diff/activity_history.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Immutable snapshots and steps produced by one activity-history pass.
5
+ class ActivityHistory
6
+ attr_reader steps: Array[ActivityStep]
7
+
8
+ attr_reader root_snapshots: Hash[Array[untyped], RecordSnapshot?]
9
+
10
+ attr_reader first_snapshot: RecordSnapshot?
11
+
12
+ attr_reader last_snapshot: RecordSnapshot?
13
+
14
+ # : (steps: Array[ActivityStep], root_snapshots: Hash[Array[untyped], RecordSnapshot?], first_snapshot: RecordSnapshot?, last_snapshot: RecordSnapshot?) -> void
15
+ def initialize: (steps: Array[ActivityStep], root_snapshots: Hash[Array[untyped], RecordSnapshot?], first_snapshot: RecordSnapshot?, last_snapshot: RecordSnapshot?) -> void
16
+
17
+ # : () -> ActivityHistory
18
+ def self.empty: () -> ActivityHistory
19
+ end
20
+
21
+ # Builds activity steps while retaining root snapshots for combined analysis.
22
+ class ActivityHistoryBuilder
23
+ # : (Array[untyped], Array[ActivityEvent], untyped, ?current: untyped, ?include_step: untyped) -> void
24
+ def initialize: (Array[untyped], Array[ActivityEvent], untyped, ?current: untyped, ?include_step: untyped) -> void
25
+
26
+ # : () -> ActivityHistory
27
+ def call: () -> ActivityHistory
28
+
29
+ private
30
+
31
+ @current: untyped
32
+
33
+ @events: Array[ActivityEvent]
34
+
35
+ @first_snapshot: RecordSnapshot?
36
+
37
+ @include_step: untyped
38
+
39
+ @previous_boundary: ActivityBoundary?
40
+
41
+ @previous_event: ActivityEvent?
42
+
43
+ @previous_snapshot: RecordSnapshot?
44
+
45
+ @root_snapshots: Hash[Array[untyped], RecordSnapshot?]
46
+
47
+ @root_versions: Array[untyped]
48
+
49
+ @selected_last_snapshot: RecordSnapshot?
50
+
51
+ @snapshotter: untyped
52
+
53
+ @steps: Array[ActivityStep]
54
+
55
+ # : () -> void
56
+ def reset: () -> void
57
+
58
+ # : () -> ActivitySnapshotSequence
59
+ def sequence: () -> ActivitySnapshotSequence
60
+
61
+ # : (ActivityEvent, RecordSnapshot?) -> void
62
+ def consume: (ActivityEvent, RecordSnapshot?) -> void
63
+
64
+ # : (RecordSnapshot?) -> void
65
+ def capture_first: (RecordSnapshot?) -> void
66
+
67
+ # : (ActivityBoundary, RecordSnapshot?) -> void
68
+ def append_step: (ActivityBoundary, RecordSnapshot?) -> void
69
+
70
+ # : () -> bool
71
+ def include_previous_step?: () -> bool
72
+
73
+ # : () -> RecordSnapshot?
74
+ def final_snapshot: () -> RecordSnapshot?
75
+
76
+ # : (untyped) -> Array[untyped]
77
+ def version_key: (untyped) -> Array[untyped]
78
+ end
79
+ end
@@ -3,6 +3,10 @@
3
3
  module PaperTrailDiff
4
4
  # Tests activity versions against a historical-version or wall-clock range end.
5
5
  class ActivityRange
6
+ attr_reader start_time: untyped
7
+
8
+ attr_reader end_time: untyped
9
+
6
10
  # : (untyped, untyped) -> void
7
11
  def initialize: (untyped, untyped) -> void
8
12
 
@@ -14,21 +18,26 @@ module PaperTrailDiff
14
18
  # : (untyped) -> untyped
15
19
  def scope: (untyped) -> untyped
16
20
 
21
+ # : () -> bool
22
+ def current_end?: () -> bool
23
+
17
24
  private
18
25
 
19
26
  @end_boundary: untyped
20
27
 
21
28
  @end_key: Array[untyped]?
22
29
 
23
- @start_key: Array[untyped]
30
+ @start_boundary: untyped
31
+
32
+ @start_key: Array[untyped]?
24
33
 
25
- @start_version: untyped
34
+ @start_time: untyped
26
35
 
27
36
  # : (untyped, Array[untyped]) -> bool
28
- def before_end?: (untyped, Array[untyped]) -> bool
37
+ def after_start?: (untyped, Array[untyped]) -> bool
29
38
 
30
- # : () -> untyped
31
- def end_time: () -> untyped
39
+ # : (untyped, Array[untyped]) -> bool
40
+ def before_end?: (untyped, Array[untyped]) -> bool
32
41
 
33
42
  # : (Array[untyped], Array[untyped]) -> bool
34
43
  def key_before_or_equal?: (Array[untyped], Array[untyped]) -> bool
@@ -0,0 +1,33 @@
1
+ # Generated from lib/paper_trail_diff/activity_snapshot_delta.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Internal scalar transition for one isolated PaperTrail update event.
5
+ class ActivitySnapshotDelta
6
+ # : (before_attributes: Hash[untyped, untyped], after_attributes: Hash[untyped, untyped]) -> void
7
+ def initialize: (before_attributes: Hash[untyped, untyped], after_attributes: Hash[untyped, untyped]) -> void
8
+
9
+ # : (RecordSnapshot) -> RecordSnapshot
10
+ def apply: (RecordSnapshot) -> RecordSnapshot
11
+
12
+ # : (untyped) -> untyped
13
+ def before_value: (untyped) -> untyped
14
+
15
+ # : (untyped) -> untyped
16
+ def after_value: (untyped) -> untyped
17
+
18
+ # : (untyped) -> bool
19
+ def relationship_changed?: (untyped) -> bool
20
+
21
+ private
22
+
23
+ @after_attributes: Hash[String, untyped]
24
+
25
+ @before_attributes: Hash[String, untyped]
26
+
27
+ # : (Hash[untyped, untyped]) -> Hash[String, untyped]
28
+ def normalize_hash: (Hash[untyped, untyped]) -> Hash[String, untyped]
29
+
30
+ # : (untyped) -> Array[untyped]
31
+ def relationship_keys: (untyped) -> Array[untyped]
32
+ end
33
+ end
@@ -6,8 +6,8 @@ module PaperTrailDiff
6
6
  # : (snapshotter: untyped, refresher: untyped, preparer: untyped) -> void
7
7
  def initialize: (snapshotter: untyped, refresher: untyped, preparer: untyped) -> void
8
8
 
9
- # : (untyped, Array[untyped]) -> void
10
- def prepare: (untyped, Array[untyped]) -> void
9
+ # : (untyped, Array[untyped], ?start_at: untyped) -> void
10
+ def prepare: (untyped, Array[untyped], ?start_at: untyped) -> void
11
11
 
12
12
  # : (untyped, untyped) -> RecordSnapshot?
13
13
  def call: (untyped, untyped) -> RecordSnapshot?
@@ -3,8 +3,8 @@
3
3
  module PaperTrailDiff
4
4
  # Compares adjacent root and selected-descendant activity boundaries.
5
5
  class ActivityTimelineBuilder
6
- # : (untyped, from: untyped, to: untyped, tree: AssociationTree, snapshotter: untyped) -> void
7
- def initialize: (untyped, from: untyped, to: untyped, tree: AssociationTree, snapshotter: untyped) -> void
6
+ # : (untyped, range: TimelineRange, tree: AssociationTree, snapshotter: untyped) -> void
7
+ def initialize: (untyped, range: TimelineRange, tree: AssociationTree, snapshotter: untyped) -> void
8
8
 
9
9
  # : () -> Array[ActivityStep]
10
10
  def build: () -> Array[ActivityStep]
@@ -17,6 +17,8 @@ module PaperTrailDiff
17
17
 
18
18
  @from: untyped
19
19
 
20
+ @range: TimelineRange
21
+
20
22
  @record: untyped
21
23
 
22
24
  @snapshotter: untyped
@@ -37,25 +39,28 @@ module PaperTrailDiff
37
39
  # : () -> void
38
40
  def validate_current_range!: () -> void
39
41
 
40
- # : (Array[untyped], ?range_end: untyped) -> Array[ActivityEvent]
41
- def collect_events: (Array[untyped], ?range_end: untyped) -> Array[ActivityEvent]
42
+ # : (Array[untyped], ?range_start: untyped, ?range_end: untyped) -> Array[ActivityEvent]
43
+ def collect_events: (Array[untyped], ?range_start: untyped, ?range_end: untyped) -> Array[ActivityEvent]
42
44
 
43
- # : (Array[untyped]) -> void
44
- def prepare_history: (Array[untyped]) -> void
45
+ # : (Array[untyped], ?start_at: untyped) -> void
46
+ def prepare_history: (Array[untyped], ?start_at: untyped) -> void
45
47
 
46
48
  # : (Array[untyped], Array[ActivityEvent], ?current: untyped, ?final_boundary: ActivityBoundary?, ?final_snapshot: RecordSnapshot?) -> Array[ActivityStep]
47
49
  def build_event_steps: (Array[untyped], Array[ActivityEvent], ?current: untyped, ?final_boundary: ActivityBoundary?, ?final_snapshot: RecordSnapshot?) -> Array[ActivityStep]
48
50
 
49
- # : (Array[untyped], Array[ActivityEvent], ?current: untyped) -> [Array[ActivityStep], Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?]
50
- def event_history: (Array[untyped], Array[ActivityEvent], ?current: untyped) -> [ Array[ActivityStep], Hash[Array[untyped], RecordSnapshot?], RecordSnapshot? ]
51
+ # : (Array[untyped], Array[ActivityEvent], ?current: untyped) -> ActivityHistory
52
+ def event_history: (Array[untyped], Array[ActivityEvent], ?current: untyped) -> ActivityHistory
51
53
 
52
- # : (Array[untyped], Hash[Array[untyped], RecordSnapshot?], Array[ActivityStep]) -> Analysis
53
- def build_analysis: (Array[untyped], Hash[Array[untyped], RecordSnapshot?], Array[ActivityStep]) -> Analysis
54
+ # : (Array[untyped], ActivityHistory) -> Analysis
55
+ def build_analysis: (Array[untyped], ActivityHistory) -> Analysis
54
56
 
55
57
  # : (Array[untyped], Array[RecordSnapshot?]) -> Array[Step]
56
58
  def build_root_steps: (Array[untyped], Array[RecordSnapshot?]) -> Array[Step]
57
59
 
58
60
  # : (untyped) -> Array[untyped]
59
61
  def version_key: (untyped) -> Array[untyped]
62
+
63
+ # : () -> TimeActivityTimelineBuilder
64
+ def time_builder: () -> TimeActivityTimelineBuilder
60
65
  end
61
66
  end
@@ -3,8 +3,8 @@
3
3
  module PaperTrailDiff
4
4
  # Collects root and selected-descendant versions relevant to one root history range.
5
5
  class ActivityVersionCollector
6
- # : (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?range_end: untyped) -> void
7
- def initialize: (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?range_end: untyped) -> void
6
+ # : (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?range_start: untyped, ?range_end: untyped) -> void
7
+ def initialize: (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?range_start: untyped, ?range_end: untyped) -> void
8
8
 
9
9
  # : () -> Array[ActivityEvent]
10
10
  def call: () -> Array[ActivityEvent]
@@ -59,9 +59,6 @@ module PaperTrailDiff
59
59
  # : (untyped, untyped) -> untyped
60
60
  def target_class: (untyped, untyped) -> untyped
61
61
 
62
- # : (untyped) -> Array[String?]
63
- def related_parent_types: (untyped) -> Array[String?]
64
-
65
62
  # : (untyped) -> bool
66
63
  def in_range?: (untyped) -> bool
67
64
 
@@ -3,8 +3,8 @@
3
3
  module PaperTrailDiff
4
4
  # Reconstructs selected root branches and merges them into a prior immutable snapshot.
5
5
  class BranchSnapshotRefresher
6
- # : (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped) -> void
7
- def initialize: (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped) -> void
6
+ # : (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped) -> void
7
+ def initialize: (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped) -> void
8
8
 
9
9
  # : (untyped, untyped, RecordSnapshot?, event: ActivityEvent) -> RecordSnapshot?
10
10
  def advance_root: (untyped, untyped, RecordSnapshot?, event: ActivityEvent) -> RecordSnapshot?
@@ -0,0 +1,59 @@
1
+ # Generated from lib/paper_trail_diff/collection_comparator.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Compares collection snapshots with a low-allocation path for stable membership.
5
+ class CollectionComparator
6
+ # : (AssociationSnapshot, AssociationSnapshot, record_comparer: untyped) -> void
7
+ def initialize: (AssociationSnapshot, AssociationSnapshot, record_comparer: untyped) -> void
8
+
9
+ # : () -> CollectionAssociationDiff
10
+ def call: () -> CollectionAssociationDiff
11
+
12
+ private
13
+
14
+ @from: AssociationSnapshot
15
+
16
+ @record_comparer: untyped
17
+
18
+ @to: AssociationSnapshot
19
+
20
+ # : (CollectionTransition) -> CollectionAssociationDiff
21
+ def transition_difference: (CollectionTransition) -> CollectionAssociationDiff
22
+
23
+ # : (RecordSnapshot?, RecordSnapshot?) -> RecordChange?
24
+ def compare_transition_records: (RecordSnapshot?, RecordSnapshot?) -> RecordChange?
25
+
26
+ # : () -> Array[RecordChange]?
27
+ def aligned_changes: () -> Array[RecordChange]?
28
+
29
+ # : () -> Array[[RecordSnapshot, RecordSnapshot]]?
30
+ def aligned_changed_pairs: () -> Array[[ RecordSnapshot, RecordSnapshot ]]?
31
+
32
+ # : (Array[RecordSnapshot], Array[RecordSnapshot]) -> Array[[RecordSnapshot, RecordSnapshot]]?
33
+ def collect_aligned_pairs: (Array[RecordSnapshot], Array[RecordSnapshot]) -> Array[[ RecordSnapshot, RecordSnapshot ]]?
34
+
35
+ # : () -> CollectionAssociationDiff
36
+ def indexed_difference: () -> CollectionAssociationDiff
37
+
38
+ # : (added: Array[RecordSnapshot], removed: Array[RecordSnapshot], changed: Array[RecordChange]) -> CollectionAssociationDiff
39
+ def difference: (added: Array[RecordSnapshot], removed: Array[RecordSnapshot], changed: Array[RecordChange]) -> CollectionAssociationDiff
40
+
41
+ # : (Hash[identity, RecordSnapshot], Hash[identity, RecordSnapshot]) -> Array[RecordSnapshot]
42
+ def records_missing_from: (Hash[identity, RecordSnapshot], Hash[identity, RecordSnapshot]) -> Array[RecordSnapshot]
43
+
44
+ # : (Hash[identity, RecordSnapshot], Hash[identity, RecordSnapshot]) -> Array[RecordChange]
45
+ def changed_records: (Hash[identity, RecordSnapshot], Hash[identity, RecordSnapshot]) -> Array[RecordChange]
46
+
47
+ # : (Array[RecordSnapshot]) -> Hash[identity, RecordSnapshot]
48
+ def index_records: (Array[RecordSnapshot]) -> Hash[identity, RecordSnapshot]
49
+
50
+ # : (Array[identity]) -> Array[identity]
51
+ def sorted_identities: (Array[identity]) -> Array[identity]
52
+
53
+ # : (identity) -> Array[untyped]
54
+ def sortable_identity: (identity) -> Array[untyped]
55
+
56
+ # : (identity) -> void
57
+ def raise_duplicate_identity!: (identity) -> void
58
+ end
59
+ end
@@ -0,0 +1,29 @@
1
+ # Generated from lib/paper_trail_diff/collection_identity_index.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Immutable positions for one collection membership and ordering.
5
+ class CollectionIdentityIndex
6
+ # : (Array[untyped]) -> void
7
+ def initialize: (Array[untyped]) -> void
8
+
9
+ # : (untyped, untyped) -> Integer?
10
+ def position: (untyped, untyped) -> Integer?
11
+
12
+ # : (untyped) -> Integer?
13
+ def position_for_id: (untyped) -> Integer?
14
+
15
+ private
16
+
17
+ @id_positions: Hash[String, Integer?]
18
+
19
+ @positions: Hash[Array[untyped], Integer]
20
+
21
+ @serialized_positions: Hash[Array[String], Integer]
22
+
23
+ # : (untyped, Integer) -> void
24
+ def register: (untyped, Integer) -> void
25
+
26
+ # : (untyped, Integer) -> void
27
+ def register_id: (untyped, Integer) -> void
28
+ end
29
+ end