Skip to content

improve building contextDefinition #32

@iamigo

Description

@iamigo

Current behavior:
The transform and connection are built separately, and the contextDefinition from each is added to the existing object in the sgt. Variables are overwritten, but not removed. The only way to delete a context variable is to remove it from the sgt directly.

It works this way for two reasons:

  1. Context variables can be defined in either transform.js or connection.js, and those are built separately, so when building either it can't overwrite the entire contextDefinition object because there could be variables there from the other file.
  2. Context variables can be defined directly in the sgt. If there is a mismatch, there’s no way to tell if it was caused by a variable being deleted in the transform/connection, or added in the sgt.

This behavior is confusing for the user. It would be better if the contextDefinition in the sgt always reflected exactly the combination of the contextDefinition in connection.js and transform.js, so that if you delete a variable it will automatically be deleted in the sgt when next built.

Changes:

  1. Restructure the build process to build the ctxDef atomically. Extract the ctxDef handling in buildConnection and buildTransform into a function that reads from both files, and run that before building either of them.
  2. Disallow adding context vars to the sgt directly. Update docs. Update tests.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions