mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-13 11:19:37 +03:00
Allow setting meta information when creating/updating an object using the API #3795
Closed
opened 2026-02-05 07:30:09 +03:00 by OVERLORD
·
3 comments
No Branch/Tag Specified
development
l10n_development
release
v25-12
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
pull-request
Mirrored from GitHub Pull Request
No Label
🔩 API Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#3795
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zedidas on GitHub (May 10, 2023).
API Endpoint or Feature
Add a new API endpoint or modify the existing ones to support setting meta information on shelves, books, chapters, pages, etc. Using this feature should be allowed only to application administrators. As an example, the current /books endpoint could support creating or editing a book while allowing to explicitly set the following:
Additionally, when changing or setting this information, it would be good to be able to set a flag in the request body so that one can set if the "Recent Activity" is updated or not.
Use-Case
There are organizations that are using other knowledge base applications and may be compeled to move to BookStack. Organizations may want to bulk export pages from the source system and import them in BookStack, while maintaining the creation time, creator, modification time, etc.
This would allow for building scripts to replicate the entire existing knowledge base into BookStack, while keeping all the previous meta information in the system. For instance, although I may use the API to create a book with an admin account, in the end, what I need is that the book creator is set to the original creator and to the original creation time that was in the source system (Of course, this assumes that the corresponding users exist also in BookStack).
Our current use case is that we are exploring the possibility to move from another Knowledge Base/Wiki into BookStack and we have 2000+ pages to move. We have been doing some scripting, and we are able to export contents from the source system and map them into BookStack. What we miss is precisely the ability to set the meta information of the imported contents, so that it matches the source system.
Additional context
No response
@ssddanbrown commented on GitHub (May 10, 2023):
In regards to setting an owner, the recently added PUT "content-permissions" API endpoint allows setting of a new owner.
In regards to all other properties, I'm not too sure this is something I'd think would be worth supporting. I would not want to allow editing of these via the API by default, so it'd have to be via a flag or different endpoints, and I'm not sure the added complexity is really worth the, what essentially is, one time demand in this specific use-case.
For some of this (IDs specifically) you could use an intermediary mapping of ids in your migration scripts to map old system IDs to new system IDs as the content is created in the new system.
You also have the option of tags if you just need a record of the metadata after migration.
You also have the option of interacting with the database directly.
You could do most of the import via the APIs, mapping ID changes, then do a late pass on the database, setting IDs and dates as required directly there.
@zedidas commented on GitHub (May 12, 2023):
Hello and thank you for the answer. I really appreciate it!
Good to know it is possible to set the owner through the "content-permissions" API endpoint. I was not aware.
Let me, respetfully, add few more arguments in having the possibility to set meta information through the API (either with the same endpoints or with new ones - I don't have a clear opinion on that).
Using tags:
I understand that the tags will allow to save meta information and legacy information from the source system. We were considering using it for some "unmapable" attributes from the source system. Still, it would be preferable to have the creation and modification dates set on the object in BookStack, instead of having them in tags.
One shot migration
We are looking to do a one shot migration. This means that, after the migration, all the Books and Pages will have the same creation time. Thus, all books will have the same relevance (for instance in the "New Books" section, regardless of it being created 2 years ago or yesterday, in the source system).
Sorting and Recent Activity
Sorting by creation date or by modification date will be meaningless (at least until de object is modified again in BookStack). Likewise, the "Recent Activity" list will not show anything useful.
Keeping IDs from the source system
I understand that this can be done with a map of IDs between the source and the target system. Still this increases a lot any script to sinchronize 2 systems (we need to handle all sorts of references between books, chapters, pages, etc.). The way I see it is if there is no hard rule to force a specific ID in a bookstack object, then the API could support a lazy ID. I mean, if the ID is specified in the API request, then the object is created with that ID. Otherwise, the ID is generated automatically by BookStack upon creation as it is right now (I may be oversimplifying the requirement...).
Achieving synchronization
Having the possibility to set meta information and IDs may allow for use cases where you want to have 2 or more systems synchronized (without having to copy the entire databse). I can imagine situations where it could be usefull to synchronize even 2 BookStack instances. This may be useful for having a staging and a production environment and then move contents from one to another. In this situation, keeping the ID is a must, so that the same content can be correctly matched.
Facilitating the move to BookStack
For organizations considering moving to BookStack, keeping audit on the Enterprise Contents is a must (every content author and metadata must be kept, during whatever retention period). Loosing this information in a possible migration will at least make it harder for and organization to decide to move to BookStack.
Updating information in the database
I appreciate that this is a valid option. Still, changing data in the database directly is always a big risk, especially in organizations, and I would prefer to avoid it.
In conclusion, I understand that my initial requirements can be meet with some compromises and added complexity. Still I think that enhacing this kind of support in the API could be a big deciding factor for organizations thinking on adopting to BookStack. The cost of migration is often the reason why an organization will not switch to another system.
Let me finish with a word of appreciation for what is BookStack right now! It is very good in doing what it is set to do! Congratulations!
Thank you again.
@ssddanbrown commented on GitHub (May 30, 2023):
Thank for the further information. I respect your points and position but none of that really changes my viewpoint on this being worthwhile.
It may seem irregular, but when it comes to assessing additions/changes I lean very much pragmatically to current possible value, and primarily its benefit to existing users. I try to avoid considering any imagined considerations or anything designed to help adoption. Over the last 8 years I've learnt these aren't healthy things to chase since they often have a real upfront impact for an unknown potential benefit. The project is not a VC-startup chasing growth, I am not trying to make the project a market leader, I instead want to ensure a continuously improving yet stable and sustainable platform for the existing users it serves, which in turn usually brings healthier natural growth in itself.
Eh, sure it's not ideal, but it depends on the data and context. Applying it as a one-shot thing upon dates seems pretty safe to me. If you really don't want to touch the database, as an alternative you could add some custom API endpoints using our logical theme system to allowing settings dates or other data.
Can't advise either of these routes for IDs though.
Thank you very much!
Since I don't see this moving forward any further I'm going to close this off, but feel free to still comment for any guidance/info if/where needed.