paper_trail_diff 0.16.0 → 0.17.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +581 -1
- data/README.md +42 -7
- data/docs/architecture.md +7 -5
- data/docs/performance.md +86 -38
- data/docs/reference.md +309 -92
- data/docs/testing.md +240 -32
- data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +2 -16
- data/lib/paper_trail_diff/activity_boundary.rb +55 -34
- data/lib/paper_trail_diff/activity_child_candidate_loader.rb +46 -57
- data/lib/paper_trail_diff/activity_collection_event_applier.rb +3 -13
- data/lib/paper_trail_diff/activity_collection_route_updater.rb +1 -1
- data/lib/paper_trail_diff/activity_event.rb +33 -21
- data/lib/paper_trail_diff/activity_event_record_resolver.rb +16 -116
- data/lib/paper_trail_diff/activity_event_route_finder.rb +29 -29
- data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +2 -7
- data/lib/paper_trail_diff/activity_history.rb +90 -49
- data/lib/paper_trail_diff/activity_range.rb +9 -35
- data/lib/paper_trail_diff/activity_root_snapshot_refresher.rb +74 -40
- data/lib/paper_trail_diff/activity_root_steps.rb +10 -13
- data/lib/paper_trail_diff/activity_scope_filter.rb +77 -0
- data/lib/paper_trail_diff/activity_snapshot_delta.rb +12 -15
- data/lib/paper_trail_diff/activity_snapshot_sequence.rb +37 -15
- data/lib/paper_trail_diff/activity_target_candidate_loader.rb +35 -43
- data/lib/paper_trail_diff/activity_timeline_builder.rb +194 -249
- data/lib/paper_trail_diff/activity_transaction_grouper.rb +3 -1
- data/lib/paper_trail_diff/activity_tree_filter.rb +54 -13
- data/lib/paper_trail_diff/activity_version_collector.rb +72 -138
- data/lib/paper_trail_diff/activity_view.rb +22 -11
- data/lib/paper_trail_diff/analysis.rb +19 -5
- data/lib/paper_trail_diff/analysis_batch.rb +16 -58
- data/lib/paper_trail_diff/approximate_paths.rb +4 -8
- data/lib/paper_trail_diff/association_activity_edge.rb +5 -24
- data/lib/paper_trail_diff/association_activity_selection.rb +10 -18
- data/lib/paper_trail_diff/association_discovery.rb +1 -6
- data/lib/paper_trail_diff/association_key.rb +9 -6
- data/lib/paper_trail_diff/association_traversal.rb +49 -6
- data/lib/paper_trail_diff/batch_boundary_resolver.rb +33 -42
- data/lib/paper_trail_diff/batch_preload.rb +2 -12
- data/lib/paper_trail_diff/batched_root_analyses.rb +72 -0
- data/lib/paper_trail_diff/batched_root_analyzer.rb +16 -14
- data/lib/paper_trail_diff/batched_root_versions.rb +25 -20
- data/lib/paper_trail_diff/branch_snapshot_refresher.rb +27 -31
- data/lib/paper_trail_diff/change_attribution.rb +329 -0
- data/lib/paper_trail_diff/change_row.rb +30 -10
- data/lib/paper_trail_diff/comparison_batch.rb +3 -4
- data/lib/paper_trail_diff/configuration.rb +1 -1
- data/lib/paper_trail_diff/deleted_analysis_batch.rb +22 -37
- data/lib/paper_trail_diff/deleted_root_filter.rb +3 -6
- data/lib/paper_trail_diff/deprecation.rb +4 -43
- data/lib/paper_trail_diff/diagnostics.rb +1 -2
- data/lib/paper_trail_diff/direct_record_state_loader.rb +8 -1
- data/lib/paper_trail_diff/endpoint.rb +78 -44
- data/lib/paper_trail_diff/errors.rb +2 -9
- data/lib/paper_trail_diff/fallback_paths.rb +2 -5
- data/lib/paper_trail_diff/habtm_transaction_owners.rb +5 -3
- data/lib/paper_trail_diff/historical_association_reifier.rb +3 -1
- data/lib/paper_trail_diff/historical_filter.rb +40 -15
- data/lib/paper_trail_diff/historical_snapshot_store.rb +80 -38
- data/lib/paper_trail_diff/instrumentation.rb +0 -8
- data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +11 -7
- data/lib/paper_trail_diff/live_endpoint_provider.rb +7 -23
- data/lib/paper_trail_diff/live_graph_collector.rb +3 -3
- data/lib/paper_trail_diff/nested_comparator.rb +46 -19
- data/lib/paper_trail_diff/net_change.rb +276 -0
- data/lib/paper_trail_diff/own_window.rb +35 -0
- data/lib/paper_trail_diff/paper_trail_adapter.rb +40 -45
- data/lib/paper_trail_diff/prepared_activity_index.rb +197 -45
- data/lib/paper_trail_diff/prepared_child_candidates.rb +58 -0
- data/lib/paper_trail_diff/prepared_edge_loader.rb +43 -107
- data/lib/paper_trail_diff/prepared_history.rb +20 -31
- data/lib/paper_trail_diff/prepared_history_loader.rb +46 -9
- data/lib/paper_trail_diff/prepared_record_index.rb +137 -47
- data/lib/paper_trail_diff/prepared_snapshot_builder.rb +16 -0
- data/lib/paper_trail_diff/prepared_state_association_reader.rb +17 -19
- data/lib/paper_trail_diff/read_snapshot.rb +41 -19
- data/lib/paper_trail_diff/recorded_changes.rb +10 -11
- data/lib/paper_trail_diff/recorded_changes_reader.rb +60 -0
- data/lib/paper_trail_diff/recorded_class.rb +14 -19
- data/lib/paper_trail_diff/recorded_columns.rb +33 -0
- data/lib/paper_trail_diff/root_version_plan.rb +20 -22
- data/lib/paper_trail_diff/root_version_selection.rb +39 -29
- data/lib/paper_trail_diff/scope_condition.rb +7 -17
- data/lib/paper_trail_diff/scope_ranking.rb +16 -22
- data/lib/paper_trail_diff/scoped_analysis.rb +27 -4
- data/lib/paper_trail_diff/scoped_analysis_builder.rb +4 -3
- data/lib/paper_trail_diff/scoped_root_selection.rb +60 -41
- data/lib/paper_trail_diff/snapshot_normalizer.rb +18 -3
- data/lib/paper_trail_diff/stored_json_values.rb +52 -0
- data/lib/paper_trail_diff/stored_time_precision.rb +30 -18
- data/lib/paper_trail_diff/stored_values.rb +20 -0
- data/lib/paper_trail_diff/support.rb +185 -35
- data/lib/paper_trail_diff/time_of_day.rb +39 -0
- data/lib/paper_trail_diff/time_range.rb +37 -20
- data/lib/paper_trail_diff/time_version_range.rb +5 -10
- data/lib/paper_trail_diff/timeline_builder.rb +3 -3
- data/lib/paper_trail_diff/timeline_range.rb +18 -12
- data/lib/paper_trail_diff/timeline_snapshot_provider.rb +1 -1
- data/lib/paper_trail_diff/total_order.rb +55 -0
- data/lib/paper_trail_diff/transaction_cut.rb +192 -91
- data/lib/paper_trail_diff/traversal_preparer.rb +5 -8
- data/lib/paper_trail_diff/value_objects.rb +8 -4
- data/lib/paper_trail_diff/version.rb +1 -1
- data/lib/paper_trail_diff/version_association_candidate_scope.rb +27 -16
- data/lib/paper_trail_diff/version_boundary.rb +37 -21
- data/lib/paper_trail_diff/version_query.rb +25 -25
- data/lib/paper_trail_diff/version_range.rb +12 -16
- data/lib/paper_trail_diff/version_sequence_diagnostics.rb +32 -0
- data/lib/paper_trail_diff/version_table.rb +12 -8
- data/lib/paper_trail_diff.rb +28 -42
- data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +0 -8
- data/sig/generated/paper_trail_diff/activity_boundary.rbs +39 -17
- data/sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs +19 -22
- data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +0 -5
- data/sig/generated/paper_trail_diff/activity_event.rbs +25 -9
- data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +6 -34
- data/sig/generated/paper_trail_diff/activity_event_route_finder.rbs +11 -4
- data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +0 -3
- data/sig/generated/paper_trail_diff/activity_history.rbs +54 -19
- data/sig/generated/paper_trail_diff/activity_range.rbs +6 -20
- data/sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs +36 -2
- data/sig/generated/paper_trail_diff/activity_root_steps.rbs +6 -6
- data/sig/generated/paper_trail_diff/activity_scope_filter.rbs +51 -0
- data/sig/generated/paper_trail_diff/activity_snapshot_delta.rbs +5 -3
- data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +21 -3
- data/sig/generated/paper_trail_diff/activity_target_candidate_loader.rbs +19 -24
- data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +121 -127
- data/sig/generated/paper_trail_diff/activity_tree_filter.rbs +41 -8
- data/sig/generated/paper_trail_diff/activity_version_collector.rbs +42 -35
- data/sig/generated/paper_trail_diff/activity_view.rbs +16 -8
- data/sig/generated/paper_trail_diff/analysis.rbs +15 -6
- data/sig/generated/paper_trail_diff/analysis_batch.rbs +6 -24
- data/sig/generated/paper_trail_diff/association_activity_edge.rbs +0 -13
- data/sig/generated/paper_trail_diff/association_activity_selection.rbs +6 -9
- data/sig/generated/paper_trail_diff/association_discovery.rbs +0 -3
- data/sig/generated/paper_trail_diff/association_key.rbs +5 -0
- data/sig/generated/paper_trail_diff/association_traversal.rbs +26 -2
- data/sig/generated/paper_trail_diff/batch_boundary_resolver.rbs +17 -17
- data/sig/generated/paper_trail_diff/batch_preload.rbs +0 -4
- data/sig/generated/paper_trail_diff/batched_root_analyses.rbs +47 -0
- data/sig/generated/paper_trail_diff/batched_root_analyzer.rbs +9 -8
- data/sig/generated/paper_trail_diff/batched_root_versions.rbs +10 -6
- data/sig/generated/paper_trail_diff/branch_snapshot_refresher.rbs +11 -5
- data/sig/generated/paper_trail_diff/change_attribution.rbs +194 -0
- data/sig/generated/paper_trail_diff/change_row.rbs +22 -7
- data/sig/generated/paper_trail_diff/deleted_analysis_batch.rbs +11 -12
- data/sig/generated/paper_trail_diff/deleted_root_filter.rbs +0 -2
- data/sig/generated/paper_trail_diff/deprecation.rbs +4 -24
- data/sig/generated/paper_trail_diff/direct_record_state_loader.rbs +4 -0
- data/sig/generated/paper_trail_diff/endpoint.rbs +40 -16
- data/sig/generated/paper_trail_diff/errors.rbs +2 -11
- data/sig/generated/paper_trail_diff/habtm_transaction_owners.rbs +2 -1
- data/sig/generated/paper_trail_diff/historical_filter.rbs +20 -9
- data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +40 -10
- data/sig/generated/paper_trail_diff/instrumentation.rbs +0 -3
- data/sig/generated/paper_trail_diff/live_endpoint_batch_loader.rbs +3 -0
- data/sig/generated/paper_trail_diff/live_endpoint_provider.rbs +5 -8
- data/sig/generated/paper_trail_diff/live_graph_collector.rbs +2 -2
- data/sig/generated/paper_trail_diff/nested_comparator.rbs +20 -4
- data/sig/generated/paper_trail_diff/net_change.rbs +168 -0
- data/sig/generated/paper_trail_diff/own_window.rbs +22 -0
- data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +9 -6
- data/sig/generated/paper_trail_diff/prepared_activity_index.rbs +114 -14
- data/sig/generated/paper_trail_diff/prepared_child_candidates.rbs +39 -0
- data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +18 -35
- data/sig/generated/paper_trail_diff/prepared_history.rbs +9 -12
- data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +28 -3
- data/sig/generated/paper_trail_diff/prepared_record_index.rbs +68 -14
- data/sig/generated/paper_trail_diff/prepared_snapshot_builder.rbs +12 -0
- data/sig/generated/paper_trail_diff/prepared_state_association_reader.rbs +6 -7
- data/sig/generated/paper_trail_diff/read_snapshot.rbs +27 -8
- data/sig/generated/paper_trail_diff/recorded_changes.rbs +4 -2
- data/sig/generated/paper_trail_diff/recorded_changes_reader.rbs +41 -0
- data/sig/generated/paper_trail_diff/recorded_class.rbs +7 -6
- data/sig/generated/paper_trail_diff/recorded_columns.rbs +21 -0
- data/sig/generated/paper_trail_diff/root_version_plan.rbs +8 -4
- data/sig/generated/paper_trail_diff/root_version_selection.rbs +27 -13
- data/sig/generated/paper_trail_diff/scope_condition.rbs +0 -2
- data/sig/generated/paper_trail_diff/scope_ranking.rbs +10 -10
- data/sig/generated/paper_trail_diff/scoped_analysis.rbs +19 -0
- data/sig/generated/paper_trail_diff/scoped_analysis_builder.rbs +2 -2
- data/sig/generated/paper_trail_diff/scoped_root_selection.rbs +37 -14
- data/sig/generated/paper_trail_diff/snapshot_normalizer.rbs +7 -0
- data/sig/generated/paper_trail_diff/stored_json_values.rbs +35 -0
- data/sig/generated/paper_trail_diff/stored_time_precision.rbs +19 -5
- data/sig/generated/paper_trail_diff/stored_values.rbs +13 -0
- data/sig/generated/paper_trail_diff/support.rbs +120 -23
- data/sig/generated/paper_trail_diff/time_of_day.rbs +21 -0
- data/sig/generated/paper_trail_diff/time_range.rbs +15 -8
- data/sig/generated/paper_trail_diff/time_version_range.rbs +2 -5
- data/sig/generated/paper_trail_diff/timeline_builder.rbs +2 -2
- data/sig/generated/paper_trail_diff/timeline_range.rbs +12 -7
- data/sig/generated/paper_trail_diff/total_order.rbs +32 -0
- data/sig/generated/paper_trail_diff/transaction_cut.rbs +111 -52
- data/sig/generated/paper_trail_diff/traversal_preparer.rbs +2 -2
- data/sig/generated/paper_trail_diff/value_objects.rbs +5 -1
- data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +10 -9
- data/sig/generated/paper_trail_diff/version_boundary.rbs +15 -8
- data/sig/generated/paper_trail_diff/version_query.rbs +17 -10
- data/sig/generated/paper_trail_diff/version_range.rbs +6 -9
- data/sig/generated/paper_trail_diff/version_sequence_diagnostics.rbs +13 -0
- data/sig/generated/paper_trail_diff/version_table.rbs +3 -0
- data/sig/generated/paper_trail_diff.rbs +16 -16
- metadata +28 -6
- data/lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb +0 -60
- data/sig/generated/paper_trail_diff/preloaded_endpoint_batch_loader.rbs +0 -32
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/prepared_child_candidates.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# The children each owner of a has_many or has_one had from a history's
|
|
5
|
+
# start onward, and has now, read once for each owner across the history
|
|
6
|
+
# (see ActivityChildCandidateLoader). Preparation reads them for the owners
|
|
7
|
+
# it loads, and activity then finds them here.
|
|
8
|
+
class PreparedChildCandidates
|
|
9
|
+
# What one class's association has read: the rows recorded under each
|
|
10
|
+
# owner and its live children's ids, by the owner's id.
|
|
11
|
+
class Read
|
|
12
|
+
attr_reader historical: Hash[String, Array[Array[untyped]]]
|
|
13
|
+
|
|
14
|
+
attr_reader live: Hash[String, Array[untyped]]
|
|
15
|
+
|
|
16
|
+
# : () -> void
|
|
17
|
+
def initialize: () -> void
|
|
18
|
+
|
|
19
|
+
# : (Array[untyped]) -> Array[untyped]
|
|
20
|
+
def unread: (Array[untyped]) -> Array[untyped]
|
|
21
|
+
|
|
22
|
+
# : (Array[untyped], ActivityChildCandidateLoader) -> void
|
|
23
|
+
def add: (Array[untyped], ActivityChildCandidateLoader) -> void
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# : (untyped) -> void
|
|
27
|
+
def initialize: (untyped) -> void
|
|
28
|
+
|
|
29
|
+
# The owners not read yet are read together, with the others the block
|
|
30
|
+
# names, so that owners asked about later need none. Each owner class
|
|
31
|
+
# reads its own, as a polymorphic row can store the class's name.
|
|
32
|
+
# : (untyped, Array[untyped], untyped) ?{ () -> Array[untyped] } -> [Hash[String, Array[Array[untyped]]], Hash[String, Array[untyped]]]
|
|
33
|
+
def call: (untyped, Array[untyped], untyped) ?{ () -> Array[untyped] } -> [ Hash[String, Array[Array[untyped]]], Hash[String, Array[untyped]] ]
|
|
34
|
+
|
|
35
|
+
@read: Hash[Array[untyped], Read]
|
|
36
|
+
|
|
37
|
+
@start_at: untyped
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
4
|
# Loads every historical identity that can participate in one association edge.
|
|
5
5
|
class PreparedEdgeLoader
|
|
6
|
-
#
|
|
7
|
-
|
|
6
|
+
# A history shares `children` with its activity index, which reads the
|
|
7
|
+
# children this finds again.
|
|
8
|
+
# : (PreparedRecordIndex, Array[untyped], ?start_at: untyped, ?children: PreparedChildCandidates) -> void
|
|
9
|
+
def initialize: (PreparedRecordIndex, Array[untyped], ?start_at: untyped, ?children: PreparedChildCandidates) -> void
|
|
8
10
|
|
|
9
11
|
# HABTM alone also returns each root transaction's members.
|
|
10
12
|
# : (untyped, Array[untyped], untyped) -> [Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]?]
|
|
@@ -12,15 +14,21 @@ module PaperTrailDiff
|
|
|
12
14
|
|
|
13
15
|
private
|
|
14
16
|
|
|
15
|
-
@
|
|
17
|
+
@children: PreparedChildCandidates
|
|
16
18
|
|
|
17
|
-
@
|
|
19
|
+
@records: PreparedRecordIndex
|
|
18
20
|
|
|
19
21
|
@transaction_ids: Array[untyped]
|
|
20
22
|
|
|
21
23
|
# : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
|
|
22
24
|
def belongs_to_groups: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
|
|
23
25
|
|
|
26
|
+
# Grouping only decides what to preload, so a type that names no class is
|
|
27
|
+
# left to raise where that state is read.
|
|
28
|
+
# : (untyped, Array[untyped], untyped, String) -> Hash[String, Hash[Symbol, untyped]]
|
|
29
|
+
def polymorphic_groups: (untyped, Array[untyped], untyped, String) -> Hash[String, Hash[Symbol, untyped]]
|
|
30
|
+
|
|
31
|
+
# Each owner's children, recorded or live, each once.
|
|
24
32
|
# : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
|
|
25
33
|
def child_groups: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
|
|
26
34
|
|
|
@@ -29,44 +37,19 @@ module PaperTrailDiff
|
|
|
29
37
|
# : (untyped, untyped) -> [Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]]
|
|
30
38
|
def habtm_groups: (untyped, untyped) -> [ Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]] ]
|
|
31
39
|
|
|
40
|
+
# Each root transaction's members, from its rows grouped by transaction.
|
|
41
|
+
# : (Hash[String, Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
42
|
+
def memberships: (Hash[String, Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
43
|
+
|
|
44
|
+
# Each statement reads up to 500 of the root transactions: SQL Server
|
|
45
|
+
# compiles a long list of ids slowly.
|
|
32
46
|
# : (untyped, untyped) -> Array[untyped]
|
|
33
47
|
def habtm_rows: (untyped, untyped) -> Array[untyped]
|
|
34
48
|
|
|
35
|
-
# : (Array[untyped], untyped) -> Array[untyped]
|
|
36
|
-
def membership_ids: (Array[untyped], untyped) -> Array[untyped]
|
|
37
|
-
|
|
38
|
-
# : (untyped, Array[untyped], untyped, String) -> Hash[String, Array[untyped]]
|
|
39
|
-
def historical_child_ids: (untyped, Array[untyped], untyped, String) -> Hash[String, Array[untyped]]
|
|
40
|
-
|
|
41
|
-
# : (untyped, Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
42
|
-
def typed_child_ids: (untyped, Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
43
|
-
|
|
44
|
-
# : (untyped, Array[untyped], untyped, String) -> untyped
|
|
45
|
-
def historical_child_relation: (untyped, Array[untyped], untyped, String) -> untyped
|
|
46
|
-
|
|
47
|
-
# : (untyped) -> VersionAssociationCandidateScope
|
|
48
|
-
def child_candidate_scope: (untyped) -> VersionAssociationCandidateScope
|
|
49
|
-
|
|
50
|
-
# : (untyped, Array[untyped], untyped, String) -> Hash[String, Array[untyped]]
|
|
51
|
-
def live_child_ids: (untyped, Array[untyped], untyped, String) -> Hash[String, Array[untyped]]
|
|
52
|
-
|
|
53
49
|
# : (Hash[String, Hash[Symbol, untyped]], untyped, untyped) -> void
|
|
54
50
|
def add_identity: (Hash[String, Hash[Symbol, untyped]], untyped, untyped) -> void
|
|
55
51
|
|
|
56
52
|
# : (untyped, Array[untyped], ?owners: Hash[String, Array[untyped]]?) -> Hash[String, Hash[Symbol, untyped]]
|
|
57
53
|
def group_for: (untyped, Array[untyped], ?owners: Hash[String, Array[untyped]]?) -> Hash[String, Hash[Symbol, untyped]]
|
|
58
|
-
|
|
59
|
-
# A set rather than a scan, so that a wide edge stays linear in its width.
|
|
60
|
-
# : (Array[Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
61
|
-
def group_ids_by_owner: (Array[Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
62
|
-
|
|
63
|
-
# : (Hash[String, Array[untyped]], Hash[String, Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
64
|
-
def merge_owners: (Hash[String, Array[untyped]], Hash[String, Array[untyped]]) -> Hash[String, Array[untyped]]
|
|
65
|
-
|
|
66
|
-
# : (untyped) -> String?
|
|
67
|
-
def scalar_foreign_key: (untyped) -> String?
|
|
68
|
-
|
|
69
|
-
# : (untyped) -> Array[String?]
|
|
70
|
-
def parent_types: (untyped) -> Array[String?]
|
|
71
54
|
end
|
|
72
55
|
end
|
|
@@ -5,10 +5,16 @@ module PaperTrailDiff
|
|
|
5
5
|
class PreparedHistory
|
|
6
6
|
attr_reader activity_index: PreparedActivityIndex?
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# The transactions that crossed the history's start, keyed as
|
|
9
|
+
# ActivityTransactionGroups keys a version's; see
|
|
10
|
+
# PreparedHistoryLoader#reload.
|
|
11
|
+
attr_reader opening_transactions: Array[Array[untyped]]
|
|
9
12
|
|
|
10
|
-
# : (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
|
|
11
|
-
def initialize: (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
|
|
13
|
+
# : (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?, ?opening_transactions: Array[Array[untyped]]) -> void
|
|
14
|
+
def initialize: (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?, ?opening_transactions: Array[Array[untyped]]) -> void
|
|
15
|
+
|
|
16
|
+
# : () -> Array[untyped]
|
|
17
|
+
def versions: () -> Array[untyped]
|
|
12
18
|
|
|
13
19
|
# Returns every group the edge now holds.
|
|
14
20
|
# : (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
|
|
@@ -59,12 +65,6 @@ module PaperTrailDiff
|
|
|
59
65
|
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
60
66
|
def direct_records: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
61
67
|
|
|
62
|
-
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
63
|
-
def resolve_belongs_to: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
64
|
-
|
|
65
|
-
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
|
|
66
|
-
def resolve_children: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
|
|
67
|
-
|
|
68
68
|
# : (untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
69
69
|
def belongs_to_records: (untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
70
70
|
|
|
@@ -100,9 +100,6 @@ module PaperTrailDiff
|
|
|
100
100
|
# : (untyped, untyped, untyped) -> bool
|
|
101
101
|
def member_of?: (untyped, untyped, untyped) -> bool
|
|
102
102
|
|
|
103
|
-
# : (untyped) -> String?
|
|
104
|
-
def scalar_foreign_key: (untyped) -> String?
|
|
105
|
-
|
|
106
103
|
# : (untyped, untyped) -> Array[String]
|
|
107
104
|
def owner_types: (untyped, untyped) -> Array[String]
|
|
108
105
|
|
|
@@ -4,8 +4,11 @@ module PaperTrailDiff
|
|
|
4
4
|
# Expands the explicit association tree into a request-scoped PreparedHistory.
|
|
5
5
|
class PreparedHistoryLoader
|
|
6
6
|
# Without `end_at`, the activity range closes on the last root version.
|
|
7
|
-
#
|
|
8
|
-
|
|
7
|
+
# A `window` is a time range; a range of versions starts at the state its
|
|
8
|
+
# first version names. `opening` names the transactions that crossed the
|
|
9
|
+
# window's start when this history is read again from where they began.
|
|
10
|
+
# : (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped], ?window: bool, ?opening: Array[Array[untyped]]) -> void
|
|
11
|
+
def initialize: (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped], ?window: bool, ?opening: Array[Array[untyped]]) -> void
|
|
9
12
|
|
|
10
13
|
# : () -> PreparedHistory
|
|
11
14
|
def call: () -> PreparedHistory
|
|
@@ -16,9 +19,13 @@ module PaperTrailDiff
|
|
|
16
19
|
|
|
17
20
|
@edges: PreparedEdgeLoader
|
|
18
21
|
|
|
22
|
+
@end_at: untyped
|
|
23
|
+
|
|
19
24
|
@history: PreparedHistory
|
|
20
25
|
|
|
21
|
-
@
|
|
26
|
+
@live_records: Array[untyped]
|
|
27
|
+
|
|
28
|
+
@prepared: Hash[untyped, Set[String]]
|
|
22
29
|
|
|
23
30
|
@record: untyped
|
|
24
31
|
|
|
@@ -32,6 +39,24 @@ module PaperTrailDiff
|
|
|
32
39
|
|
|
33
40
|
@tree: AssociationTree
|
|
34
41
|
|
|
42
|
+
@window: bool
|
|
43
|
+
|
|
44
|
+
# A transaction that crosses a window's start and saved a version of the
|
|
45
|
+
# root moves the window's edge back to where it began (see
|
|
46
|
+
# TransactionCut); one that saved only associated records moves nothing.
|
|
47
|
+
# A boundary in such a transaction still reads each record as it stood
|
|
48
|
+
# before the transaction began (see PreparedRecordSeries#boundary_index),
|
|
49
|
+
# and a history read from the window's start holds neither the versions
|
|
50
|
+
# it saved before the start nor the records only those versions name, such
|
|
51
|
+
# as one it destroyed there. Without them the window would start after
|
|
52
|
+
# changes that the window before it left to this one, by ending its step
|
|
53
|
+
# at one of the transaction's events here (see ActivityTreeFilter), and
|
|
54
|
+
# neither would report them. So the history is read again from where the
|
|
55
|
+
# earliest such transaction began; the window's events still start at its
|
|
56
|
+
# start.
|
|
57
|
+
# : (Array[Array[untyped]], untyped) -> PreparedHistory
|
|
58
|
+
def reload: (Array[Array[untyped]], untyped) -> PreparedHistory
|
|
59
|
+
|
|
35
60
|
# : (untyped, Array[untyped], AssociationTree, path: String) -> void
|
|
36
61
|
def load_node: (untyped, Array[untyped], AssociationTree, path: String) -> void
|
|
37
62
|
|
|
@@ -45,9 +45,6 @@ module PaperTrailDiff
|
|
|
45
45
|
|
|
46
46
|
@serializers: Hash[untyped, untyped]
|
|
47
47
|
|
|
48
|
-
# : (Hash[untyped, untyped]) -> Hash[String, untyped]
|
|
49
|
-
def stringify_keys: (Hash[untyped, untyped]) -> Hash[String, untyped]
|
|
50
|
-
|
|
51
48
|
# : (untyped, Hash[String, untyped]) -> untyped
|
|
52
49
|
def reification_class: (untyped, Hash[String, untyped]) -> untyped
|
|
53
50
|
|
|
@@ -62,8 +59,11 @@ module PaperTrailDiff
|
|
|
62
59
|
class PreparedRecordSeries
|
|
63
60
|
attr_reader versions: Array[untyped]
|
|
64
61
|
|
|
65
|
-
#
|
|
66
|
-
|
|
62
|
+
# The live fallback is a state, or a current record whose state is read
|
|
63
|
+
# the first time a read reaches past the last version. Most reads stop at
|
|
64
|
+
# a version, and reading a row's state casts every column it has.
|
|
65
|
+
# : (versions: Array[untyped], live: PreparedRecordState?, ?live_record: untyped, ?state_loader: PreparedVersionStateLoader) -> void
|
|
66
|
+
def initialize: (versions: Array[untyped], live: PreparedRecordState?, ?live_record: untyped, ?state_loader: PreparedVersionStateLoader) -> void
|
|
67
67
|
|
|
68
68
|
# : (untyped) -> untyped
|
|
69
69
|
def record_before: (untyped) -> untyped
|
|
@@ -88,14 +88,14 @@ module PaperTrailDiff
|
|
|
88
88
|
# : () -> Array[PreparedRecordState]
|
|
89
89
|
def states: () -> Array[PreparedRecordState]
|
|
90
90
|
|
|
91
|
-
# The classes the record had at any point, or either side of one version
|
|
91
|
+
# The classes the record had at any point, or either side of one version:
|
|
92
|
+
# a create has no state before it and a destroy none after.
|
|
92
93
|
# : (?untyped) -> Array[untyped]
|
|
93
94
|
def model_classes: (?untyped) -> Array[untyped]
|
|
94
95
|
|
|
95
|
-
# The states
|
|
96
|
-
#
|
|
97
|
-
|
|
98
|
-
def states_around: (untyped) -> Array[PreparedRecordState]
|
|
96
|
+
# The states before `first` and after `last`, where they exist.
|
|
97
|
+
# : (untyped, untyped) -> Array[PreparedRecordState]
|
|
98
|
+
def states_across: (untyped, untyped) -> Array[PreparedRecordState]
|
|
99
99
|
|
|
100
100
|
# : (untyped) -> [PreparedRecordState, PreparedRecordState]?
|
|
101
101
|
def transition: (untyped) -> [ PreparedRecordState, PreparedRecordState ]?
|
|
@@ -104,10 +104,14 @@ module PaperTrailDiff
|
|
|
104
104
|
|
|
105
105
|
@live: PreparedRecordState?
|
|
106
106
|
|
|
107
|
+
@live_record: untyped
|
|
108
|
+
|
|
107
109
|
@state_loader: PreparedVersionStateLoader
|
|
108
110
|
|
|
109
111
|
@states: Hash[untyped, PreparedRecordState?]
|
|
110
112
|
|
|
113
|
+
@times: Array[untyped]
|
|
114
|
+
|
|
111
115
|
@transaction_positions: Hash[untyped, Integer]
|
|
112
116
|
|
|
113
117
|
@version_positions: Hash[String, Integer]
|
|
@@ -115,6 +119,9 @@ module PaperTrailDiff
|
|
|
115
119
|
# : (Integer) -> PreparedRecordState?
|
|
116
120
|
def state_after: (Integer) -> PreparedRecordState?
|
|
117
121
|
|
|
122
|
+
# : () -> PreparedRecordState?
|
|
123
|
+
def live: () -> PreparedRecordState?
|
|
124
|
+
|
|
118
125
|
# A version is eligible when it is at or after the boundary, or shares the
|
|
119
126
|
# boundary's transaction. The first is monotonic over the chronological
|
|
120
127
|
# list and the second is indexed, so neither rescans a long history once
|
|
@@ -123,7 +130,8 @@ module PaperTrailDiff
|
|
|
123
130
|
# "At or after" is decided by the version order rather than the timestamp
|
|
124
131
|
# alone. A version written in the same instant as the boundary but before
|
|
125
132
|
# it already took effect there; reading its pre-change state would put the
|
|
126
|
-
# boundary on the wrong side of a change it follows.
|
|
133
|
+
# boundary on the wrong side of a change it follows. Each time is read
|
|
134
|
+
# once, since every record is placed against every boundary.
|
|
127
135
|
# : (untyped) -> Integer?
|
|
128
136
|
def boundary_index: (untyped) -> Integer?
|
|
129
137
|
|
|
@@ -148,6 +156,12 @@ module PaperTrailDiff
|
|
|
148
156
|
# : (untyped, Array[untyped], Array[untyped]) -> void
|
|
149
157
|
def seed: (untyped, Array[untyped], Array[untyped]) -> void
|
|
150
158
|
|
|
159
|
+
# The transactions the versions held from the start onward belong to that
|
|
160
|
+
# began before it, and where the earliest of them began; see
|
|
161
|
+
# PreparedHistoryLoader. Nothing when none did.
|
|
162
|
+
# : () -> [Array[Array[untyped]], untyped]?
|
|
163
|
+
def opening: () -> [ Array[Array[untyped]], untyped ]?
|
|
164
|
+
|
|
151
165
|
# : (untyped, untyped, untyped) -> untyped
|
|
152
166
|
def record_before: (untyped, untyped, untyped) -> untyped
|
|
153
167
|
|
|
@@ -175,11 +189,16 @@ module PaperTrailDiff
|
|
|
175
189
|
# : (untyped, untyped) -> Array[untyped]
|
|
176
190
|
def versions_for_id: (untyped, untyped) -> Array[untyped]
|
|
177
191
|
|
|
192
|
+
# : () -> Array[untyped]
|
|
193
|
+
def versions: () -> Array[untyped]
|
|
194
|
+
|
|
178
195
|
# : (untyped, untyped, ?untyped) -> Array[untyped]
|
|
179
196
|
def model_classes: (untyped, untyped, ?untyped) -> Array[untyped]
|
|
180
197
|
|
|
181
|
-
#
|
|
182
|
-
|
|
198
|
+
# The attributes before `first` and after `last`, where they exist, typed
|
|
199
|
+
# as a reified record's are.
|
|
200
|
+
# : (untyped, untyped, untyped, untyped) -> Array[Hash[untyped, untyped]]
|
|
201
|
+
def typed_states_across: (untyped, untyped, untyped, untyped) -> Array[Hash[untyped, untyped]]
|
|
183
202
|
|
|
184
203
|
# : (untyped, untyped) -> bool
|
|
185
204
|
def loaded?: (untyped, untyped) -> bool
|
|
@@ -191,6 +210,11 @@ module PaperTrailDiff
|
|
|
191
210
|
# : (PreparedRecordState) -> Hash[untyped, untyped]
|
|
192
211
|
def typed_attributes: (PreparedRecordState) -> Hash[untyped, untyped]
|
|
193
212
|
|
|
213
|
+
# A state completed as a record of its class would hold it, or nil where
|
|
214
|
+
# only instantiating can tell; each state is completed once.
|
|
215
|
+
# : (PreparedRecordState) -> PreparedRecordState?
|
|
216
|
+
def direct_state: (PreparedRecordState) -> PreparedRecordState?
|
|
217
|
+
|
|
194
218
|
# : (untyped, String) -> bool
|
|
195
219
|
def generated_reader?: (untyped, String) -> bool
|
|
196
220
|
|
|
@@ -224,7 +248,8 @@ module PaperTrailDiff
|
|
|
224
248
|
# A PaperTrail version is a pre-change snapshot, so the state at the last
|
|
225
249
|
# selected boundary can only live in the next version after it. One
|
|
226
250
|
# trailing version per identity is retained, rather than every version
|
|
227
|
-
# recorded between the requested range and the present.
|
|
251
|
+
# recorded between the requested range and the present. Each record's
|
|
252
|
+
# versions are read in one statement, which takes 500 records.
|
|
228
253
|
# : (untyped, Array[untyped]) -> Array[untyped]
|
|
229
254
|
def versions_for: (untyped, Array[untyped]) -> Array[untyped]
|
|
230
255
|
|
|
@@ -239,4 +264,33 @@ module PaperTrailDiff
|
|
|
239
264
|
# : (untyped, Array[untyped]) -> Array[untyped]
|
|
240
265
|
def live_records_for: (untyped, Array[untyped]) -> Array[untyped]
|
|
241
266
|
end
|
|
267
|
+
|
|
268
|
+
# Finds the transactions that crossed a history's start: those the versions
|
|
269
|
+
# held from the start onward belong to that also saved versions before it,
|
|
270
|
+
# of any record. One statement per 500 transactions.
|
|
271
|
+
class OpeningTransactions
|
|
272
|
+
# : (Hash[Array[String], PreparedRecordSeries], untyped) -> void
|
|
273
|
+
def initialize: (Hash[Array[String], PreparedRecordSeries], untyped) -> void
|
|
274
|
+
|
|
275
|
+
# Their keys, as ActivityTransactionGroups keys a version's, and when the
|
|
276
|
+
# earliest began; nil when none crossed the start.
|
|
277
|
+
# : () -> [Array[Array[untyped]], untyped]?
|
|
278
|
+
def call: () -> [ Array[Array[untyped]], untyped ]?
|
|
279
|
+
|
|
280
|
+
private
|
|
281
|
+
|
|
282
|
+
# When each of these transactions saved its first version before the
|
|
283
|
+
# start, for those that saved one there.
|
|
284
|
+
# : (untyped, Array[untyped]) -> Array[[untyped, untyped]]
|
|
285
|
+
def earliest: (untyped, Array[untyped]) -> Array[[ untyped, untyped ]]
|
|
286
|
+
|
|
287
|
+
@series: Hash[Array[String], PreparedRecordSeries]
|
|
288
|
+
|
|
289
|
+
@start: untyped
|
|
290
|
+
|
|
291
|
+
# The transactions of the versions held from the start onward, by version
|
|
292
|
+
# class, since each version table numbers its own.
|
|
293
|
+
# : () -> Hash[untyped, Array[untyped]]
|
|
294
|
+
def transactions: () -> Hash[untyped, Array[untyped]]
|
|
295
|
+
end
|
|
242
296
|
end
|
|
@@ -9,6 +9,18 @@ module PaperTrailDiff
|
|
|
9
9
|
# : (untyped, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [bool, RecordSnapshot?]
|
|
10
10
|
def call: (untyped, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [ bool, RecordSnapshot? ]
|
|
11
11
|
|
|
12
|
+
# The state `call` builds a version's snapshot from, or nil when the
|
|
13
|
+
# version stored none or must be reified.
|
|
14
|
+
# : (untyped) -> PreparedRecordState?
|
|
15
|
+
def state: (untyped) -> PreparedRecordState?
|
|
16
|
+
|
|
17
|
+
# The current row of a root, given as its state, with its associations as
|
|
18
|
+
# `boundary` reads them. Its attributes are the record's own, as the record
|
|
19
|
+
# path normalizes them, so its model need not be plain; its members are
|
|
20
|
+
# read as a version's are.
|
|
21
|
+
# : (PreparedRecordState, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [bool, RecordSnapshot?]
|
|
22
|
+
def live: (PreparedRecordState, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [ bool, RecordSnapshot? ]
|
|
23
|
+
|
|
12
24
|
private
|
|
13
25
|
|
|
14
26
|
@loader: DirectRecordStateLoader
|
|
@@ -34,9 +34,6 @@ module PaperTrailDiff
|
|
|
34
34
|
# : (PreparedRecordState, untyped, untyped, bool) -> [bool, Array[PreparedRecordState]]
|
|
35
35
|
def target: (PreparedRecordState, untyped, untyped, bool) -> [ bool, Array[PreparedRecordState] ]
|
|
36
36
|
|
|
37
|
-
# : (PreparedRecordState, untyped) -> untyped
|
|
38
|
-
def target_class: (PreparedRecordState, untyped) -> untyped
|
|
39
|
-
|
|
40
37
|
# The members of each join record the owner had at the boundary, as
|
|
41
38
|
# PreparedHistory#through_records reads them from records. Under
|
|
42
39
|
# `source_type:`, only join records of that type count. A has_many
|
|
@@ -60,14 +57,16 @@ module PaperTrailDiff
|
|
|
60
57
|
# : (PreparedRecordState) -> Array[untyped]
|
|
61
58
|
def identity: (PreparedRecordState) -> Array[untyped]
|
|
62
59
|
|
|
60
|
+
# The scope's condition and the owner's id are read once for all the
|
|
61
|
+
# owner's children, which are read at every boundary.
|
|
63
62
|
# : (PreparedRecordState, untyped, untyped, bool) -> [bool, Array[PreparedRecordState]]
|
|
64
63
|
def children: (PreparedRecordState, untyped, untyped, bool) -> [ bool, Array[PreparedRecordState] ]
|
|
65
64
|
|
|
66
|
-
# : (untyped,
|
|
67
|
-
def ids_for: (untyped,
|
|
65
|
+
# : (untyped, String) -> Array[untyped]
|
|
66
|
+
def ids_for: (untyped, String) -> Array[untyped]
|
|
68
67
|
|
|
69
|
-
# : (PreparedRecordState, PreparedRecordState, untyped,
|
|
70
|
-
def member?: (PreparedRecordState, PreparedRecordState, untyped,
|
|
68
|
+
# : (PreparedRecordState, PreparedRecordState, String, untyped, ScopeCondition) -> bool
|
|
69
|
+
def member?: (PreparedRecordState, PreparedRecordState, String, untyped, ScopeCondition) -> bool
|
|
71
70
|
|
|
72
71
|
# : (PreparedRecordState) -> String
|
|
73
72
|
def owner_id: (PreparedRecordState) -> String
|
|
@@ -8,36 +8,55 @@ module PaperTrailDiff
|
|
|
8
8
|
#
|
|
9
9
|
# PostgreSQL and MySQL (through mysql2 or trilogy), and adapters built on
|
|
10
10
|
# them such as PostGIS, run the read at REPEATABLE READ, which gives every
|
|
11
|
-
# statement of the transaction the same view.
|
|
12
|
-
#
|
|
11
|
+
# statement of the transaction the same view. SQL Server runs it at SNAPSHOT
|
|
12
|
+
# when the database allows that isolation level, which it does only after
|
|
13
|
+
# `ALTER DATABASE ... SET ALLOW_SNAPSHOT_ISOLATION ON`; otherwise SNAPSHOT
|
|
14
|
+
# raises, so it takes none. Other adapters get no snapshot; docs/reference.md
|
|
15
|
+
# lists them under limitations.
|
|
13
16
|
module ReadSnapshot
|
|
14
17
|
# The adapters whose subclasses take a snapshot, by name, since an
|
|
15
18
|
# application loads only the adapters it uses.
|
|
16
19
|
SNAPSHOT_ADAPTERS: untyped
|
|
17
20
|
|
|
21
|
+
SQL_SERVER_ADAPTER: ::String
|
|
22
|
+
|
|
23
|
+
# 1 is ON. The setting can change while the application runs, so it is
|
|
24
|
+
# read for each call; the catalog answers at once.
|
|
25
|
+
SQL_SERVER_SNAPSHOT_STATE: ::String
|
|
26
|
+
|
|
18
27
|
# Yields once. Each connection the values read through gets a snapshot
|
|
19
28
|
# transaction first, unless that connection already has a transaction open:
|
|
20
29
|
# its isolation level belongs to the caller, and this gem cannot change it.
|
|
21
30
|
# A value may be a model class, a relation, a record, or a version. Any
|
|
22
31
|
# other value reads no table and is ignored.
|
|
23
32
|
# : (Array[untyped]) { () -> untyped } -> untyped
|
|
24
|
-
def self
|
|
33
|
+
def self.call: (Array[untyped]) { () -> untyped } -> untyped
|
|
34
|
+
|
|
35
|
+
# The isolation level that gives this connection's statements one view, or
|
|
36
|
+
# nil when it has none.
|
|
37
|
+
# : (untyped) -> Symbol?
|
|
38
|
+
def self.isolation: (untyped) -> Symbol?
|
|
39
|
+
|
|
40
|
+
# : (untyped, Array[String]) -> bool
|
|
41
|
+
def self.adapter?: (untyped, Array[String]) -> bool
|
|
25
42
|
|
|
43
|
+
# Named as a schema query, as Active Record names its own catalog reads.
|
|
26
44
|
# : (untyped) -> bool
|
|
27
|
-
def self
|
|
45
|
+
def self.sql_server_snapshot?: (untyped) -> bool
|
|
28
46
|
|
|
29
47
|
# One class per connection: each read model and its version class, with the
|
|
30
48
|
# repeats through a shared connection dropped. An associated model on
|
|
31
49
|
# another database is not among them, so it is read outside the snapshot.
|
|
32
50
|
# : (Array[untyped]) -> Array[untyped]
|
|
33
|
-
def self
|
|
51
|
+
def self.connection_classes: (Array[untyped]) -> Array[untyped]
|
|
34
52
|
|
|
35
53
|
# The versioned model a value reads from, or nil.
|
|
36
54
|
# : (untyped) -> untyped
|
|
37
|
-
def self
|
|
55
|
+
def self.model_for: (untyped) -> untyped
|
|
38
56
|
|
|
39
|
-
# A version reads the model of its item;
|
|
57
|
+
# A version reads the model of its item; anything else its own class,
|
|
58
|
+
# which is a versioned model only for a record.
|
|
40
59
|
# : (untyped) -> untyped
|
|
41
|
-
def self
|
|
60
|
+
def self.endpoint_model: (untyped) -> untyped
|
|
42
61
|
end
|
|
43
62
|
end
|
|
@@ -41,7 +41,9 @@ module PaperTrailDiff
|
|
|
41
41
|
def recorded?: () -> bool
|
|
42
42
|
|
|
43
43
|
# Primary keys identify the record rather than describe it, as in a diff.
|
|
44
|
-
#
|
|
45
|
-
|
|
44
|
+
# Each side is read as a step's diff reads it (see StoredValues), so a
|
|
45
|
+
# value compares equal to the state the change produced.
|
|
46
|
+
# : (untyped, untyped, Array[String]) -> Hash[String, ValueChange]
|
|
47
|
+
def value_changes: (untyped, untyped, Array[String]) -> Hash[String, ValueChange]
|
|
46
48
|
end
|
|
47
49
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/recorded_changes_reader.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# Decodes what each version recorded at most once per request, and only when
|
|
5
|
+
# a boundary's changes are read. A version many roots share in a batch, such
|
|
6
|
+
# as an author's, is one decode however many steps name it, and a step the
|
|
7
|
+
# caller never reads costs none.
|
|
8
|
+
class RecordedChangesReader
|
|
9
|
+
# : (Array[String]) -> void
|
|
10
|
+
def initialize: (Array[String]) -> void
|
|
11
|
+
|
|
12
|
+
# What `version` recorded, as PaperTrailDiff.recorded_changes returns it.
|
|
13
|
+
# : (untyped) -> Hash[String, ValueChange]?
|
|
14
|
+
def call: (untyped) -> Hash[String, ValueChange]?
|
|
15
|
+
|
|
16
|
+
@changes: Hash[Array[untyped], Hash[String, ValueChange]?]
|
|
17
|
+
|
|
18
|
+
@ignore: Array[String]
|
|
19
|
+
|
|
20
|
+
@lock: Thread::Mutex
|
|
21
|
+
|
|
22
|
+
# One boundary's recorded changes, read when first asked for. It lets go of
|
|
23
|
+
# the version and the reader once read, so a result keeps only what was
|
|
24
|
+
# decoded, and not the decodes of the whole call.
|
|
25
|
+
class Pending
|
|
26
|
+
# : (RecordedChangesReader, untyped) -> void
|
|
27
|
+
def initialize: (RecordedChangesReader, untyped) -> void
|
|
28
|
+
|
|
29
|
+
# : () -> Hash[String, ValueChange]?
|
|
30
|
+
def value: () -> Hash[String, ValueChange]?
|
|
31
|
+
|
|
32
|
+
@lock: Thread::Mutex
|
|
33
|
+
|
|
34
|
+
@reader: RecordedChangesReader?
|
|
35
|
+
|
|
36
|
+
@value: Hash[String, ValueChange]?
|
|
37
|
+
|
|
38
|
+
@version: untyped
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -8,15 +8,16 @@ module PaperTrailDiff
|
|
|
8
8
|
# A version that stored neither stays on the base class.
|
|
9
9
|
module RecordedClass
|
|
10
10
|
# : (untyped) -> untyped
|
|
11
|
-
def self
|
|
11
|
+
def self.for: (untyped) -> untyped
|
|
12
|
+
|
|
13
|
+
# The class a version recorded, or a live record's own class.
|
|
14
|
+
# : (untyped) -> untyped
|
|
15
|
+
def self.of_endpoint: (untyped) -> untyped
|
|
12
16
|
|
|
13
17
|
# : (untyped) -> bool
|
|
14
|
-
def self
|
|
18
|
+
def self.sti_base?: (untyped) -> bool
|
|
15
19
|
|
|
16
20
|
# : (untyped, untyped) -> untyped
|
|
17
|
-
def self
|
|
18
|
-
|
|
19
|
-
# : (StandardError) -> bool
|
|
20
|
-
def self?.subclass_not_found?: (StandardError) -> bool
|
|
21
|
+
def self.stored_type: (untyped, untyped) -> untyped
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/recorded_columns.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# Whether PaperTrail writes a column's changes to `object_changes` whenever
|
|
5
|
+
# a version saves them. Only then does a version that left a column out of
|
|
6
|
+
# its recorded changes show that the column changed without a version.
|
|
7
|
+
#
|
|
8
|
+
# `has_paper_trail ignore:` and `skip:` leave a column out, and `only:`
|
|
9
|
+
# leaves out every column it does not name. Each can also name a column
|
|
10
|
+
# with a condition, read when the version was saved; such a column might
|
|
11
|
+
# have been left out, so it is not counted as recorded either.
|
|
12
|
+
module RecordedColumns
|
|
13
|
+
# : (untyped, String?) -> bool
|
|
14
|
+
def self.recorded?: (untyped, String?) -> bool
|
|
15
|
+
|
|
16
|
+
# PaperTrail keeps each entry as a name, or as a hash of names to
|
|
17
|
+
# conditions, which may be a subclass such as HashWithIndifferentAccess.
|
|
18
|
+
# : (Array[untyped], String?) -> bool
|
|
19
|
+
def self.named?: (Array[untyped], String?) -> bool
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -58,6 +58,11 @@ module PaperTrailDiff
|
|
|
58
58
|
# : () -> RootVersionPlan
|
|
59
59
|
def closing_on_destroy: () -> RootVersionPlan
|
|
60
60
|
|
|
61
|
+
# The same plan reporting only `selected` as mutations, of the versions it
|
|
62
|
+
# holds.
|
|
63
|
+
# : (Array[untyped]) -> RootVersionPlan
|
|
64
|
+
def reporting: (Array[untyped]) -> RootVersionPlan
|
|
65
|
+
|
|
61
66
|
# What the range's final state is read from, which is the live record when
|
|
62
67
|
# the window closes on current state and the last version otherwise.
|
|
63
68
|
# : () -> untyped
|
|
@@ -70,6 +75,9 @@ module PaperTrailDiff
|
|
|
70
75
|
|
|
71
76
|
@mutation_keys: Set[Array[untyped]]
|
|
72
77
|
|
|
78
|
+
# : (**untyped) -> RootVersionPlan
|
|
79
|
+
def copy: (**untyped) -> RootVersionPlan
|
|
80
|
+
|
|
73
81
|
# : () -> Array[untyped]
|
|
74
82
|
def default_mutations: () -> Array[untyped]
|
|
75
83
|
|
|
@@ -78,9 +86,5 @@ module PaperTrailDiff
|
|
|
78
86
|
# mutant:disable
|
|
79
87
|
# : (Array[untyped]) -> Set[Array[untyped]]
|
|
80
88
|
def key_set: (Array[untyped]) -> Set[Array[untyped]]
|
|
81
|
-
|
|
82
|
-
# By class name, so a version still matches after its class is reloaded.
|
|
83
|
-
# : (untyped) -> Array[untyped]
|
|
84
|
-
def key: (untyped) -> Array[untyped]
|
|
85
89
|
end
|
|
86
90
|
end
|