The purpose of this note is to help developers to upgrade their agent from v7 to v8. Please read carefully and integrate the following breaking changes to ensure a smooth upgrade.
Please be sure of your agent type and version and pick the right documentation accordingly.
This is the documentation of the forest-express-sequelize and forest-express-mongoose Node.js agents that will soon reach end-of-support.
forest-express-sequelize v9 and forest-express-mongoose v9 are replaced by @forestadmin/agent v1.
Please check your agent type and version and read on or switch to the right documentation.
This is still the latest Ruby on Rails documentation of the forest_liana agent, you’re at the right place, please read on.
This is the documentation of the django-forestadmin Django agent that will soon reach end-of-support.
If you’re using a Django agent, notice that django-forestadmin v1 is replaced by forestadmin-agent-django v1.
As for any dependency upgrade, it's very important to test this upgradein your testing environments. Not doing so could result in your admin panel being unusable.
To upgrade to v8, run the following and then update your project as shown in the Breaking Changes section below.
npm install "forest-express-sequelize@^8.0.0"
npm install "forest-express-mongoose@^8.0.0"
In case of a regression introduced in Production after the upgrade, a rollback to your previous agent is the fastest way to restore your admin panel.
Breaking changes
CORS allowed headers
Every collection calls (CRUD operations) to your agent will now be performed with a new header called Forest-Context-Url . This header contains the current URL of the user performing requests. This can be handy if you need information on the context this user is working on.
If you don't have any restriction on headers within your CORS configuration, nothing needs to be changed, you can move on to the next section.
If you have configured a header whitelist (allowedHeaders in express for instance) in your CORS configuration, you need to add this new header to the whitelist, otherwise browsers won't trigger request anymore due to CORS policy:
Until now, once you had submitted a file for upload, the file name wasn't persisted. We have now made so that it is possible to save and display it.
If you use a regex to parse data before sending it for upload (like we originally suggested in this Woodshop tutorial), there is a breaking change: you need to use the output of the parseDataUri method.
Scopes have been revamped, from a convenient alternative to segments, to a security feature. They are now enforced by the agent (server-side).
This update comes with many breaking changes in the prototype of helpers which are provided to access and modify data.
All occurrences of calls to RecordsGetter, RecordCounter, RecordsExporter, RecordsRemover, RecordCreator, RecordGetter, RecordUpdater, RecordRemover , RecordsCounter, must be updated.
Note that RecordSerializer was not modified, and can be used to serialize and deserialize models.
Before
router.post('/actions/do-something',permissionMiddlewareCreator.smartAction() (req, res) => {const { query } = req;// List helpersnewRecordsGetter(MyModel).getAll(query);newRecordsGetter(MyModel).getIdsFromRequest(req);newRecordCounter(MyModel).count(query);newRecordsExporter(MyModel).streamExport(res, query);newRecordsRemover(MyModel).remove([1,2,3])// Single item helpersnewRecordCreator(MyModel).create({title:'One');newRecordGetter(MyModel).get(37);newRecordUpdater(MyModel).update({title:'Two'},37);newRecordRemover(MyModel).remove(37); });
The values endpoint is no longer supported. Hooks now replaces the values endpoint since they are now available for single, bulk & global smart action types.
1st change:
The Smart action change hook method name is no longer the fieldName. You are now required to declare the hook name as a property inside the field.
The signature of hooks functions has changed. In order to support hooks for global and bulk smart actions, record is no longer sent to the hook. You must change the way you get the record information. This change also prevents unnecessary computation in case you don't need to access the record(s) inside the hooks.