active_record-undo 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +78 -2
- data/DOCUMENTATION.md +311 -178
- data/README.md +140 -10
- data/app/controllers/active_record/undo/application_controller.rb +9 -0
- data/app/controllers/active_record/undo/logs_controller/async_handler.rb +50 -0
- data/app/controllers/active_record/undo/logs_controller.rb +32 -3
- data/app/jobs/active_record/undo/restore_job.rb +72 -0
- data/app/jobs/active_record/undo/soft_delete_job.rb +75 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20260920000000_add_status_and_error_message_to_undo_logs.rb +15 -0
- data/lib/active_record/undo/cascade_handler.rb +66 -0
- data/lib/active_record/undo/configuration.rb +2 -1
- data/lib/active_record/undo/model_extension/async_methods.rb +68 -0
- data/lib/active_record/undo/model_extension.rb +7 -4
- data/lib/active_record/undo/status_predicates.rb +39 -0
- data/lib/active_record/undo/undo_log/token_verifier.rb +48 -0
- data/lib/active_record/undo/undo_log.rb +49 -32
- data/lib/active_record/undo/version.rb +1 -1
- data/lib/active_record/undo/view_helpers/status_badge_helper.rb +84 -0
- data/lib/active_record/undo/view_helpers.rb +4 -0
- data/lib/active_record/undo.rb +24 -1
- data/sig/active_record/undo.rbs +50 -1
- metadata +23 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11848dbfe8a5c20a84dbd8749a4c27459bbf4b94294eecaca3660d26a4a2197b
|
|
4
|
+
data.tar.gz: 1a3b7924ee6b7ecc508b336a53d2be3b985ef45ee7e3d5fb9816fd62bf8a3e6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1ee51c349fd7953244c8b3b85de258ecdb2114e07d8989d3db878325f95d8fe036b55564030baf64c60d81a10c2e6ea58843bab83f309be82417d3ef16ed8b9
|
|
7
|
+
data.tar.gz: e218b54baeb83f963eec7777eb8af5caf1c7c43ace1cca6deff3161979197d140630f84fe31423604e27515b0f378277694281ff754f6e9ea0884e8b6d6c2234
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.3.0] - 2026-10-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Asynchronous Cascades & Background Workers**:
|
|
13
|
+
- `record.soft_delete_later!(whodunnit: ..., tenant: ..., queue: ...)`: Marks the root record immediately, creates an audit `UndoLog`, and enqueues `SoftDeleteJob` for background cascading.
|
|
14
|
+
- `record.restore_later!(whodunnit: ..., queue: ...)` and `undo_log.restore_later!(...)`: Schedules bottom-up batch restoration in the background via `RestoreJob`.
|
|
15
|
+
- Configurable `config.base_job` (defaults to `"::ActiveJob::Base"`) allowing custom application worker classes with custom retry and error handling logic.
|
|
16
|
+
- **Persistent State Tracking & Observability**:
|
|
17
|
+
- Migration `AddStatusAndErrorMessageToUndoLogs` adding `status` enum (`pending`, `processing`, `completed`, `failed`), `action` enum (`soft_delete`, `restore`), and persistent `error_message` text column with database indexes.
|
|
18
|
+
- Dedicated status polling HTTP endpoints: `GET /undo/logs/:id/status` and `GET /undo/status/:token`.
|
|
19
|
+
- Asynchronous restore support on HTTP endpoints: `POST /undo/logs/:id/restore` and `POST /undo/restore/:token` via `params: { async: true }` or `X-Undo-Async: true` header, returning `202 Accepted` in JSON and Turbo Stream formats.
|
|
20
|
+
- **Idempotency, Concurrency & Retry Resilience**:
|
|
21
|
+
- Row-level database locking (`with_lock`) in `RestoreJob` and `SoftDeleteJob` to prevent duplicate or concurrent worker runs.
|
|
22
|
+
- Idempotent re-entrancy in `CascadeHandler#soft_delete_associations_batched!` with `associated.reload.soft_deleted?` pre-checks.
|
|
23
|
+
- Safe retry support for failed operations (`UndoLog#restore!` and `UndoLog#restore_later!`).
|
|
24
|
+
- ActiveJob worker exception re-raising after logging failure to allow native queue retries (`retry_on`) and APM/error monitoring alerts (Sentry, Bugsnag).
|
|
25
|
+
- **Execution State Predicates & View Helpers**:
|
|
26
|
+
- Model and UndoLog predicate methods: `soft_delete_status`, `restore_status`, `soft_delete_pending?`, `soft_delete_processing?`, `soft_delete_completed?`, `soft_delete_failed?`, `restore_pending?`, `restore_processing?`, `restore_failed?`.
|
|
27
|
+
- Status badge view helpers: `undo_status_badge(target, action: :auto, **options)`, `soft_delete_status_badge(target, **options)`, and `restore_status_badge(target, **options)`.
|
|
28
|
+
- **Security & Multi-Tenancy**:
|
|
29
|
+
- Strict tenant boundary security enforcement on all async restore endpoints and status check routes.
|
|
30
|
+
- Automatic tenant context propagation to background worker threads during asynchronous restoration.
|
|
31
|
+
|
|
32
|
+
## [0.2.0] - 2026-08-25
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Mountable Rails engine (`ActiveRecord::Undo::Engine`) and RESTful restore endpoints (`POST /undo/logs/:id/restore` and `POST /undo/restore/:token`).
|
|
37
|
+
- Cryptographic signed token verification (`token_verifier`) for tamper-proof direct-link restoration without exposing database IDs.
|
|
38
|
+
- ActionView helpers: `undo_button_to` and `undo_link_to` supporting both log instances and model objects.
|
|
39
|
+
- Open-redirect protection (`SafeRedirect`) preventing open-redirect and protocol-relative phishing attacks.
|
|
40
|
+
- Global engine configuration: `base_controller`, `default_redirect_path`, `token_secret_key`, `token_expires_in`, and `error_handling`.
|
|
41
|
+
|
|
42
|
+
## [0.1.5] - 2026-08-21
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- User attribution (`whodunnit`) and multi-tenant isolation support.
|
|
47
|
+
- Migration `AddTenantAndUserAttributionToUndoLogs` for polymorphic attribution.
|
|
48
|
+
- Ambient thread/fiber context: `ActiveRecord::Undo.whodunnit` and `ActiveRecord::Undo.current_tenant`.
|
|
49
|
+
- Strict tenant verification during restore operations.
|
|
50
|
+
|
|
51
|
+
## [0.1.4] - 2026-08-14
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- Hard purging engine (`ActiveRecord::Undo::Purger`) for cleaning up expired records and audit logs.
|
|
56
|
+
- Background purge job (`ActiveRecord::Undo::PurgeJob`) and `rake active_record_undo:purge_expired` task.
|
|
57
|
+
- Retention period management via `config.retention_period` and model `.expired` scope.
|
|
58
|
+
|
|
59
|
+
## [0.1.3] - 2026-08-11
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- `undoable?` predicate helper on undoable models.
|
|
64
|
+
|
|
65
|
+
## [0.1.2] - 2026-08-09
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- CI and Shields.io status badges to documentation.
|
|
70
|
+
|
|
71
|
+
## [0.1.1] - 2026-08-09
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
- Updated gem publishing GitHub Actions workflow.
|
|
2
76
|
|
|
3
77
|
## [0.1.0] - 2026-08-08
|
|
4
78
|
|
|
5
|
-
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- Initial release: core `acts_as_undoable` macro, `soft_delete!`, `restore!`, cascading deletions, `UndoLog`, and `UndoLogItem`.
|