Synchronising app instances
Through the app instance export and import functionality Stryke provides a very quick way to create multiple versions of an app for different purposes, clients, data subsets, etc. This can result in multiple app instances that share the same definition (entities, fields, scripts, etc.) while working with different data. In these cases it can be useful to propagate changes of the app's definition to the other related app instances with a single command instead of having to manually replicate the changes.
The "app instance sync" endpoint provides this functionality and is available by calling:
https://app.stryke.io/#/[your app name]/sync
This synchronises fields, entities, and code across app instance that are related. For example development and production instances of the same application. Specifically, the information that is synced includes:
- Entity
- Action
- Script
- Template
This excludes any data stored in the app itself as well as access control definitions.
How to use the Sync endpoint
The sync endpoint works in one of two ways:
- Syncs the definition of a parent app with the selected child app instance
- Updates the definition of an app with an app template JSON document provided in the body to the sync request
Syncing parent and child app instances
Any app instance can be assigned a "parent app instance". When an app has a parent set, its definition can be synced with the definition of its parent by simply calling the sync
endpoint. Below are the steps to follow to set a parent and sync an app instance.
- Set the parent on an app instance using the app instance update endpoint. Example:
{
"parent": {
"id" : "12455351-555d-4721-9b77-dde39f6e2e38"
}
}
- Call the sync endpoint with no request body
https://app.stryke.io/#/[your app name]/sync
Updating the definition of an app from a JSON template
Alternatively, the sync
endpoint can be called on an app that has not parent assigned but passing an app's template in the body of the POST request. An app's template is the JSON document that is generated when exporting an app.
The ability to work with apps' definitions through JSON documents and APIs allows for mature development practices such as tracking changes to the app definition in source control or automating releases through a continuous deployment strategy.
Important Remarks
Behaviour and restrictions
Syncing is performed by name. When two apps are synced: entities, actions, scripts, and templates that have the same name will be updated in the child app instance with the contents on their counterpart in the parent app instance. Entities, actions, scripts and templates that do not exist in the child app instance will be created and the ones that do not exist in the parent will be removed from the child app instance. After the sync operation is finished the definition of the child and parent app instances will be identical.
Syncing changes in entities across apps has the same behaviour and result as manually editing the entities directly. For example, removing a field from an entity in the parent app and then syncing the child app with it, has the same effect as removing that field from the child app directly. Consequently, the same restrictions apply when syncing entity definitions as when editing entities directly. For more details see the section on Restrictions editing fields.
Syncing app instances can affect the app's data
While data is not directly copied or accessed when executing a sync across apps, changing an app's metadata may affect the data contained in that app. For example, if a field is removed from an entity in the parent app and then the app is synced with the child app, all records in the child app will lose that field as it happened in the parent app instance.
Similarly, deleting an entity in the parent app instance will result in that entity being removed, along with all of its data records, when the parent app is synced with the child app instance.