forest_admin_agent 1.47.0 → 1.48.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32e0f7c27c7dea94a2edc46e7fd3fb938e2ec986d4684fd28d9544eb0b3acc93
|
|
4
|
+
data.tar.gz: ee4246b8d69882a1ab72c72a5ae9208382da9d71e740eba74a109c76492cff5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb1d2f2761640a61484a7943a490d4149b3616eafcab69cbff6a713d4ff842965ccc8f1f44be3fbcea715b5e36230f79480fcfa5cc384302bddce74cd5bc4f46
|
|
7
|
+
data.tar.gz: 23673caf7138deb825471449efca08581aaf4d923b69e18d71238795d773c3a8b59bfcae47ec93ceac278b9e907c3a35f34c26aec6dc9c7733e857ca61b5f63c
|
data/AUDIT_TRAIL.md
CHANGED
|
@@ -340,6 +340,11 @@ the store. A missing `collection` or `recordId` returns **HTTP 400** (`Validatio
|
|
|
340
340
|
|
|
341
341
|
## Smart actions
|
|
342
342
|
|
|
343
|
+
Writes a smart action makes through Forest (`context.collection` or `context.datasource.get_collection(...)`
|
|
344
|
+
`create` / `update` / `delete`) are audited like any other write, under the same `correlationKey` as the
|
|
345
|
+
action: the audit hooks sit on an internal layer below smart actions. Writes that bypass Forest (raw SQL, a
|
|
346
|
+
direct ActiveRecord call, an external API) only show up through the action row below.
|
|
347
|
+
|
|
343
348
|
Running a smart action writes one row per selected record, in the same table:
|
|
344
349
|
|
|
345
350
|
| column | value |
|
|
@@ -43,19 +43,18 @@ module ForestAdminAgent
|
|
|
43
43
|
add_delete_hooks(collection_customizer, target)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# has had its say on.
|
|
46
|
+
# Hooks sit on the internal layer, below smart actions, so writes made from an action's `execute` are
|
|
47
|
+
# audited too. The "after" hooks are prepended: `execute_after` stops at the first exception, so another
|
|
48
|
+
# internal hook raising would otherwise drop the record of a write that already happened.
|
|
50
49
|
def add_create_hooks(collection_customizer, target)
|
|
51
|
-
collection_customizer.
|
|
50
|
+
collection_customizer.add_internal_hook('Before', 'Create') do |context|
|
|
52
51
|
# No record id yet — that is what the column being nullable is for.
|
|
53
52
|
rows = [{ record_id: nil, new_values: pick(context.data, target[:columns]) }]
|
|
54
53
|
|
|
55
54
|
@snapshots.push(context.data, ids: pending_rows(context.caller, 'create', target[:name], rows))
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
collection_customizer.
|
|
57
|
+
collection_customizer.add_internal_hook('After', 'Create', prepend: true) do |context|
|
|
59
58
|
pending = @snapshots.pop_for(context.data)
|
|
60
59
|
next unless pending
|
|
61
60
|
|
|
@@ -66,7 +65,7 @@ module ForestAdminAgent
|
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
def add_update_hooks(collection_customizer, target)
|
|
69
|
-
collection_customizer.
|
|
68
|
+
collection_customizer.add_internal_hook('Before', 'Update') do |context|
|
|
70
69
|
records = @snapshots.take(context, target[:projection])
|
|
71
70
|
@snapshots.push(
|
|
72
71
|
context.filter,
|
|
@@ -83,7 +82,7 @@ module ForestAdminAgent
|
|
|
83
82
|
)
|
|
84
83
|
end
|
|
85
84
|
|
|
86
|
-
collection_customizer.
|
|
85
|
+
collection_customizer.add_internal_hook('After', 'Update', prepend: true) do |context|
|
|
87
86
|
pending = @snapshots.pop_for(context.filter)
|
|
88
87
|
next unless pending
|
|
89
88
|
|
|
@@ -92,7 +91,7 @@ module ForestAdminAgent
|
|
|
92
91
|
end
|
|
93
92
|
|
|
94
93
|
def add_delete_hooks(collection_customizer, target)
|
|
95
|
-
collection_customizer.
|
|
94
|
+
collection_customizer.add_internal_hook('Before', 'Delete') do |context|
|
|
96
95
|
records = @snapshots.take(context, target[:projection])
|
|
97
96
|
@snapshots.push(
|
|
98
97
|
context.filter,
|
|
@@ -107,7 +106,7 @@ module ForestAdminAgent
|
|
|
107
106
|
)
|
|
108
107
|
end
|
|
109
108
|
|
|
110
|
-
collection_customizer.
|
|
109
|
+
collection_customizer.add_internal_hook('After', 'Delete', prepend: true) do |context|
|
|
111
110
|
pending = @snapshots.pop_for(context.filter)
|
|
112
111
|
next unless pending
|
|
113
112
|
|