Packs proposal

Version 1.1
Created 2023/06/07 - Michael P. Dubner (https://github.com/pyhedgehog)
Modified 2023/07/14 - Michael P. Dubner (https://github.com/pyhedgehog)

Abstract

This SIP (Saltcorn Improvement Proposal) has goal to make packs more developer-friendly format.

Motivation

Packs pros

Features that should be keept:

  1. Pack has simple representation that can be constructed manually/programmatically.
  2. Pack has text representation that can be stored in VCS.
  3. Snapshots are packs.
  4. On pack re-import existing triggers are overrided.

Packs cons

Defects that should be fixed:

  1. Packs can be imported only once (#1507)
    1. Existing table cause pack import to fail.
    2. Existing view/page silently ignored.
  2. Packs export can't be easily repeated (#1505)
  3. Packs are not self-consistent.
    1. Custom events not included (#1806)
    2. Important parts of config is not included: menu, log settings, tags.
  4. Packs imported from cli (saltcorn install-pack -f ...) require saltcorn restart.

Proposal

  1. Update existing views, pages (and maybe library items) like triggers.
  2. Add ability to define default value for required column in pack.
  3. Update existing table definition if posiible fail otherwise.
  4. Add "create pack" to tag interface. This will simplify re-export.
  5. Send reload signal from cli install-pack command to server (i.e. SIGHUP which should be handled beforehand).

Format changes

  1. Add format version field ("format": 1) while absence of this field implies format=0, i.e. old format.
  2. Add version field ("version": "1.0" by default).
  3. Add custom_events field as list of {"name":"...","hasChannel":false}.

Import changes

  1. Update (aka replace) existing views, pages (and maybe library items) like triggers.
  2. Update existing table definition if posiible fail (and rollback) whole pack import otherwise.

Interface changes

  1. Add ability to define default value for required column in pack.
  2. Change pack export interface as a whole:
    1. Add versioning
    2. Add pack re-export
    3. Make pack installed on export (including version bump)
    4. Add "create pack" to tag interface. This will simplify re-export with version increment.

Misc changes

  1. Send reload signal from cli install-pack command to server (i.e. SIGHUP which should be handled beforehand).