Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow adding metadata to versions #51

Open
frankdugan3 opened this issue Apr 22, 2024 · 1 comment
Open

feat: allow adding metadata to versions #51

frankdugan3 opened this issue Apr 22, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@frankdugan3
Copy link

Is your feature request related to a problem? Please describe.

I have a requirement to add various metadata to each version, e.g. reason_for_change for auditing compliance.

Describe the solution you'd like

Ideally, the DSL of AshPaperTrail would allow specifying metadata arguments to accept from the action to merge into the version.

Describe alternatives you've considered

  • Mixins don't seem capable of handling this as an escape hatch.
  • Storing the metadata directly on the primary resource is a leaky abstraction.

Express the feature either with a change to resource syntax, or with a change to the resource interface

Simple example:

paper_trail do
  metadata [:reason_for_change] # <-- will pull the value from that argument of action
end

It may be important to support more advanced uses, like pulling a nested field from the context and naming the key:

paper_trail do
  metadata [client_ip: ^context([:client, :remote_ip])]
end

Additional context

For implementation, perhaps we could use a special context to store the metadata:

paper_trail: %{reason_for_change: "fix typo"}

which could then be encoded on each version.

@frankdugan3 frankdugan3 added the enhancement New feature or request label Apr 22, 2024
@zachdaniel
Copy link
Contributor

Since paper trail is cross-cutting across multiple actions, we'd probably want to use the latter, so ash_paper_trail would extract anything in the paper_trail_metadata context key or something along those lines.

@zachdaniel zachdaniel added the good first issue Good for newcomers label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants