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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fc1fe96cf406b3cdb4034d8c0a20b2920b3ea685eaa67a88c59b850bf2971d8
4
- data.tar.gz: cc1830bd09b2eeec06f8d27992a2b18255d6db0277751fd9c7614581f8d9d10b
3
+ metadata.gz: 11848dbfe8a5c20a84dbd8749a4c27459bbf4b94294eecaca3660d26a4a2197b
4
+ data.tar.gz: 1a3b7924ee6b7ecc508b336a53d2be3b985ef45ee7e3d5fb9816fd62bf8a3e6f
5
5
  SHA512:
6
- metadata.gz: 1d558abdcbb507970ff723a3453f35a8a37581c4aad79e605112affbddd23be71bc224a6a1f400fee76ffd7b3655eb408752c800216ab70229e02e62b883a5e8
7
- data.tar.gz: d0be5d9b492aa4a6cf3bc2a46ff5aa2c83da139f069eb377c5799932e158e82ffc0e3122a47e9aca0de9eb2d9c2d4c9b58033dda90047f78f8a2f7eeb7ef209d
6
+ metadata.gz: b1ee51c349fd7953244c8b3b85de258ecdb2114e07d8989d3db878325f95d8fe036b55564030baf64c60d81a10c2e6ea58843bab83f309be82417d3ef16ed8b9
7
+ data.tar.gz: e218b54baeb83f963eec7777eb8af5caf1c7c43ace1cca6deff3161979197d140630f84fe31423604e27515b0f378277694281ff754f6e9ea0884e8b6d6c2234
data/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
- ## [Unreleased]
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
- - Initial release
79
+ ### Added
80
+
81
+ - Initial release: core `acts_as_undoable` macro, `soft_delete!`, `restore!`, cascading deletions, `UndoLog`, and `UndoLogItem`.