feat: allow custom storage strategies via lifecycle hooks and custom readers#1528
Open
EmaSchiavoni wants to merge 5 commits intoThinkmill:mainfrom
Open
feat: allow custom storage strategies via lifecycle hooks and custom readers#1528EmaSchiavoni wants to merge 5 commits intoThinkmill:mainfrom
EmaSchiavoni wants to merge 5 commits intoThinkmill:mainfrom
Conversation
…leton configs to enable callback hooks. These callback hooks allow devs to perform actions on saving or deleting, even letting you decide whether to proceed with saving or deleting, respectively, through the function call received as an argument.
…gletons doc pages
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While Keystatic's internal persistence (local/GitHub) is excellent for most use cases, there are times when a project requires a specific collection to be managed externally due to custom business logic. Instead of forcing developers to leave the Keystatic ecosystem for these exceptions, this pull request introduces two complementary features that, together, allow for seamless integration into the same unified workflow:
beforeSave,beforeDelete): New callbacks for collections and singletons. They provide full control over the persistence flow by receiving asave/deletefunction as an argument. This allows for side effects (logging, external sync) or complete overrides of the default behavior.readerproperty in the config that allows developers to define how data is fetched.I know these could be two separate features, but I'm intentionally submitting them in a single PR because together they form a coherent extensibility tool: The hooks allow a "true" return value to indicate a successful operation even if Keystatic's internal save function wasn't called (for example, when saving to an external API). Without the custom reader, this would result in an inconsistent UI state where data is saved externally, but Keystatic can't retrieve it