Apps are bundled in packages. When a new version of a package is released,
users are going to update the package, and with it all apps in the package.
It may be necessary to apply changes to all instances of those apps,
for example, when an attribute named
foo is to be renamed to
.Update method is for this purpose: to update all affected files.
(All files that are instances of apps of the updated package.)
Let’s assume you are the vendor of the package
example.com, and you have a
gallery app at
example.com/gallery-1. Your app uses a string attribute
that you want to rename to
/gallery-2to hold the new version of the app.
.Updatefile’s link property to
path /gallery-2. (This documents that the
/gallery-2app supersedes the
/gallery-1app. Required to do updates one version at a time.)
.Updatefile’s type to
sjs-4or any interpreter of your choice, and write the code that will do the transformation:
fwill point to the instance being transformed (migrated).
fmay have a longer typeChain to your app. It is guaranteed that the files on the typeChain of
fwill be updated after
fitself. Thus, the typeChain of
bar. (Create a new attribute, remove the old one.)
fto point to
/gallery-2, it will be done automatically. In fact, it may not need to be updated, if there is a longer typeChain. (!)
Updating an entire package runs in a single transaction.
In the above example, never ever remove the file
/gallery-1. It makes sure
that restoring an old version of a website will continue to just work.
.ContentSecurityPolicyrules of a website during an update is not currently supported. Get in touch if you need it implemented. Note that the website owner will have to approve
.ContentSecurityPolicychanges every single time.