@@ -921,19 +921,21 @@ fn(state => {
921921
922922:::warning Availability
923923
924- Globals are new to CLI version X.X.X and not yet available in Lightning
924+ Globals are new to CLI version 1.13.0 and not yet available in on the platform.
925+ If you've tried Globals and have feedback or want to see it in the app, lets us
926+ know on [ community.openfn.org] ( https://community.openfn.org/ ) ! :::
925927
926- :::
927-
928- Each step in your workflow runs in isolation: state is the only way to share
929- information between steps.
928+ You can re-use functions and constants across steps in a workflow through
929+ Globals.
930930
931- Since CLI vX.X.X, you can declare global variables and functions which can be
932- re-used throughout all steps in your workflow. This is particularly useful for
933- declaring re-usable functions.
931+ Usually, each step in a workflow is "sandboxed" into its own environment, with
932+ adaptor functions in scope and a state object created by the previous step (or
933+ input). But globals allow you to define functions and variables to be exported
934+ across steps.
934935
935- Globals are defined in a special kind of step. Everything you export from this
936- "step" will be made globally available to all other steps.
936+ Globals are defined in a special kind of step at the top level of your
937+ ` workflow.json ` file. Everything you export from this "step" will be made
938+ globally available to all other steps.
937939
938940For example, your globals may look like this:
939941
@@ -969,11 +971,18 @@ fn(state => {
969971});
970972```
971973
974+ Globals are useful when you have common logic that you want to share between
975+ steps in a workflow - like generating or pre-processing data, running validation
976+ or generating ids, or utilities like sort, filter and mapping functions.
977+
978+ ### The Rules of Globals
979+
972980There are some important rules to bear in mind when using globals:
973981
974982- You cannot import other modules inside globals. Globals are not a replacement
975983 for adaptors.
976- - Exported functions are not operations, and cannot be used at the top-level of
984+ - Globals do not have an associated adaptor and so cannot use adaptor functions.
985+ - Exported functions are not Operations, and cannot be used at the top-level of
977986 a job expression (unless you specifically write it that way, see below)
978987- The contents of globals are immutable: you cannot change their values and they
979988 are reset in-between steps. You can of course pass state into a global
@@ -1022,6 +1031,21 @@ export function toKebabCase(str) {
10221031
10231032:::
10241033
1034+ ### CLI Usage
1035+
1036+ Right now, Globals are only available to workflows executed through the CLI.
1037+
1038+ When using a workflow with a ` globals ` key defined, the globals will
1039+ automatically be exported to each step. You don't need to do anything.
1040+
1041+ If you want ro run a single step through the CLI, and that step depends on
1042+ globals, you'll need to pass the ` --globals ` argument with a path to the globals
1043+ file, like this:
1044+
1045+ ``` bash
1046+ openfn job.js -a http --globals ./globals.js
1047+ ```
1048+
10251049## Using Cursors
10261050
10271051Sometimes it is useful to maintain a rolling cursor position on the backend
0 commit comments