Integreat CLI
A command line interface for Integreat.
Installation
Requires Node.js 22 or later.
Install with npm i great --global
Authentication
Before using most commands, you need to authenticate:
great login
This will open your browser to authenticate with GitHub or Google. The authentication token is stored locally and will be used for subsequent commands.
To log out:
great logout
Commands
Targeting an integration and account
Many commands act on a specific integration, and some on a specific account. They share the same rules for working out which one to use. The commands below note which of these they support.
- Integration — by default the current folder's integration (its
integration.jsonand.great.json). To target another one, value commands take the-i <integration-id-or-key>flag, while others take it as a positional<integration>argument. An explicit integration overrides the folder. - Account — needed only when an integration is addressed by key rather than
id (a key is resolved within an account), or by commands that act on an
account directly. Provide it with the
-a <account-id-or-key>flag. When omitted, it falls back to the current folder's account (from.great.json), then the default account from config (great config set account <id>).
An integration or account passed explicitly that does not exist is an error — commands never silently fall back to the current folder in that case.
Authentication
great login: Log in to Integreat via browser authentication.great logout: Log out and remove stored authentication token.great whoami: Displays your Integreat user.
Account Management
great accountsorgreat accounts list: Display list of accounts (default action).great accounts create <name>: Create a new account.
Integration Management
great integrationsorgreat integrations list: Display list of integrations, with their type and account. Supports-ato filter by account, or-A/--allto list integrations from all accounts, ignoring the integration's account and the default account. Use-t <type>to only list integrations of a given type (integration,library, ortemplate).great integrations create <name>: Create a new integration in Integreat. Requires-a. Returns integration ID to add to localintegration.jsonfor linking with workspace.
Local Workspace
great init [name]: Initialize a new integration workspace locally. Createsintegration.jsonand folder structure without creating anything in Integreat. Ifnameis omitted, one is made from the current directory name. Use-a <account-id-or-key>to link the workspace to an account right away.great clone [integration]: Clone an integration to a new folder.[integration]can be an integration id or key; supports-a. Leave it out to choose from a list of the integrations of all types in the account given with-aor the default account, or from all accounts with-A/--allor when there is no account. Creates a new directory with the integration key (or id), downloads all integration files, and prints the folder it created.great pull: Pull remote changes to the current integration folder. Must be run from a folder with anintegration.jsonfile. Element files that no longer exist in Integreat are deleted, while local-only files are left alone. Elements renamed in Integreat are moved to their new file name. Local changes are kept, as long as they don't conflict with remote changes. Will check for conflicts and abort. Use-f, --forceto overwrite everything with the remote state.great push: Push local changes to Integreat. Must be run from a folder with anintegration.jsonfile; supports-awhen creating a new integration, to create it in the right account. Will check for conflicts and abort. Use-y, --yesto answer yes to all prompts (sets values and detaches edited shadows).great import [template]: Import a template, creating a local shadow file for each of its elements.[template]can be a template id or key; supports-a. Leave it out to choose from a list of the templates in the account given with-a, the integration's account or the default account, or from all accounts with-A/--allor when there is no account. A shadow file is an ordinary element file carrying a$shadow: truemarker; it does not own its content (that lives in the source element) — the link to the source and the template import are recorded in.great.json. Integreat resolves all the imported templates together against the local elements, and the result is applied to the local files. Re-importing a template moves its shadows to the template's new version and removes the elements it no longer has (the nextgreat pushdeletes them in Integreat too). Elements shared by several templates point at what the templates have in common. When templates share a service with different endpoint lists, the lists are merged into a local endpoint list that remembers every template it came from. The import is aborted on conflicts and nothing is written. The only exception is when the conflict is that already imported templates pin a shared element at another version, in which case you are asked whether to move them to the version of the template being imported; answering yes leaves the other templates out of sync until they are re-imported. Use-y, --yesto answer yes to this without being asked. Must be run from a folder with anintegration.jsonfile.great unimport [template]: Remove an imported template.[template]can be a template id or key; supports-a. Leave it out to choose from a list of the templates imported into the integration. Integreat resolves the remaining templates against the local elements, and the result is applied to the local files: elements only this template supplied are removed, shadows other templates also supply are kept with the template dropped from their provenance, and elements Integreat keeps as local elements lose their link to the templates. Nothing is changed in Integreat until you rungreat push.great include [element]: Include a single element from another integration as a shadow file.[element]is an element id, or"<folder>/<key>"(e.g.schemas/entry). With a key,-i, --integrationis required and takes the id or key of the integration to include from. Leave[element]out to choose from a list: first an integration in the account, then one of its elements. With-i, you go straight to the elements of that integration. Use-a, --accountto resolve an integration key or pick the account to list from (defaults to the folder's account, then the account in config). Use-p, --pinned-at <timestamp>to pin the shadow to the source as it stood at that ISO timestamp; omit it to follow the source's latest content. Including a service with an endpoint list, you're asked which endpoints to include with it as shadow elements. Leaving any out makes the endpoint list a local element with only the selected endpoints, detached from its source. Use-e, --endpoints <keys>to give the endpoint keys as a comma-separated list instead (e.g.--endpoints getEntries,setEntry); an unknown key stops the include. When including an element that already exists, you will be asked to override if the include causes a conflict. Use-y, --yesto answer yes to all prompts: all endpoints are included (unless--endpointsis given) and existing elements are replaced without asking.[element]is required with--yes. Undo an include withgreat remove. Must be run from a folder with anintegration.jsonfile.great rename [target] [new-key]: Rename an element.[target]is"<folder>/<key>"(e.g.schemas/entry). Leave it out to choose an element from a list, and leave out[new-key]to be asked for it. This updates the key in Integreat ongreat push. Use this instead of renaming an element file by hand — a plain rename is treated as deleting the old element and creating a new one. Renaming a service also renames its endpoint list, and renaming an endpoint updates every service listing it.great remove [target]: Remove an element file.[target]is"<folder>/<key>"(e.g.schemas/entry). Leave it out to choose from a list of the elements in the project. Removing an endpoint also drops it from every service listing it. Removing a service also removes the endpoints included with it (included shadows no other service lists), so this undoes agreat include. Local and imported endpoints are kept. An endpoint list can't be removed on its own; it goes with its service. Nothing is changed in Integreat until you rungreat push. Use this instead of deleting an element file by hand, which leaves a stale link behind for an element that hasn't been pushed. Must be run from a folder with anintegration.jsonfile.
Deployment & Runtime
great deploy [integration]: Create a version and start the integration. Targets the[integration]argument or the current folder; supports-a. Use-n <name>to specify a custom version name. Only real integrations are started;libraryandtemplateintegrations get a new version but are not started.great start: Start an existing integration with its current active version, without creating a new version. Targets-i <id or key>or the current folder; supports-a.great stop: Stop a running integration. Targets-i <id or key>or the current folder; supports-a.great run [integration]: Run a job or flow interactively. Targets the[integration]argument or the current folder; supports-a.great status [integration]: Show integration status, type and active version. Targets the[integration]argument or the current folder; supports-a. When run without an argument inside an integration folder, it also lists differences betwen the local files and the remote integration.great repl [integration]: Start a Node.js REPL session with access to integration dispatch functions. Targets the[integration]argument or the current folder; supports-a. Usehelp()in the REPL to see available functions.
Value Management
Value commands read the latest values (the draft, when there is one, otherwise
the active version), so they show what you're working on. Values are normally
part of a version and take effect on the next great deploy. A value whose file
has "isDynamic": true next to "type" is used by the running integration
right away, outside of versions: setting or clearing it reloads the integration
when it is running.
great valuesorgreat values list: List all value elements in an integration. Supports-iand-a.great values get [element]: Get the value of a value element. The[element]can be either an element ID or key (a key needs integration context). Leave it out to choose from the values in the integration. Supports-iand-a.great values set [element] [value]: Set the value of a value element. The[element]can be either an element ID or key (a key needs integration context). Leave it out to choose from the values in the integration. Leave out[value]to be asked for it. Supports-iand-a. The value will be automatically cast to the appropriate type (string, number, boolean, date, or secret) based on the element's type definition. When giving a value as an argument and it starts with a dash (e.g. a PEM key like-----BEGIN PRIVATE KEY-----), put a bare--before it so it isn't parsed as an option:great values set <element> -- '-----BEGIN ...'. Usequoting if you need\nsequences turned into real newlines. When asked for a value you may paste a multiline text or press ctrl+o to enter your editor to edit it.great values unset [element]: Clear the value of a value element, so it may fall back to an inherited value from a source element when present. The[element]can be either an element ID or key (a key needs integration context). Leave it out to choose from the values in the integration. Supports-iand-a.
Environments
great envorgreat env list: List configured environments. The built-inprodenvironment is always present, and the active one is marked.great env set <name> --api-url <url> --app-url <url>: Add or update a named environment. The nameprodis reserved.great env use [name]: Switch the active environment. Useprodto reset to the default. Leave out[name]to choose from a list, with the active environment selected. Logins are remembered per environment, so you can switch back and forth without logging in again (until the token expires).great env remove <name>: Remove a named environment.
Utilities
great explode <file>: Convert legacy integration JSON to new file structure. Specify the path to a legacy JSON file as the first argument.great implode [folder]: Combine integration file structure into a single legacy JSON file. Specify the path to an integration folder as the first argument (defaults to current directory). Endpoint keys on services are resolved back to inline endpoint definitions. Note: value elements will have empty values in the output.great migrate: Migrate an existing workspace to the newest layout. Run it from the integration folder; it is safe to re-run. It does two things:- Moves sync bookkeeping stored inline as
__id/__key/__timestampprops (the old layout) to a.great.jsonfile (see Workspace files below). - Extracts inline endpoint definitions on services to
endpoints/files, leaving the endpoint keys on the service (see Services and endpoints below). Each key is the endpoint'sid, orendpoint<N>by position, and is prefixed with the service key and a dash, unless--no-prefixis given. Keys are kept within 50 chars and made unique with a number suffix if needed. Rungreat pushafterwards to create the endpoints in Integreat.
- Moves sync bookkeeping stored inline as
great now: Prints the current Unix timestamp. The-cflag will copy it to your clipboard.
Exit codes
Errors are written to stderr, and the commands exit with a code scripts can rely
on, e.g. great push && great start:
| Code | Meaning |
|---|---|
| 0 | Success, including when there is nothing to do (e.g. already stopped) |
| 1 | An error, including when only part of the work was done |
| 2 | Cancelled by the user (Ctrl+C, or answering no to abort) |
| 4 | Authentication required (not logged in, or the token was rejected) |
Errors inside a great repl session don't affect the exit code.
Workspace files
An integration folder contains:
integration.jsonat the folder root. This holds the integration's own configuration: itsname,description,type, andflags. The integration's key is the folder name, so renaming its folder to change the key (not yet implemented).- Per-type folders (
schemas/,services/,endpoints/,auths/,mutations/,dictionaries/,jobs/,values/,flows/,retryRules/) with one JSON file per element. These hold only configuration. Keys come from names, not stored fields: an element's key is its file name without the extension (e.g.schemas/entry.jsonhas keyentry). Rename an element withgreat rename(a plain file rename is treated as delete + recreate), and remove one withgreat remove. .great.jsonat the folder root. This holds the sync bookkeeping that links local files to their remote counterparts — the integration and element ids, the owning account, the last-synced timestamps and content hashes. It is managed bygreat pullandgreat push— commit it to git, and do not edit it by hand. Deleting it "forgets" all remote links, so the nextgreat pushrecreates the remote elements; this is the clean way to regenerate a folder against a new environment.
Services and endpoints
A service is one file in services/, and each of its endpoints is a file of its
own in endpoints/. The service refers to the endpoints it uses by key:
// services/crm.json
{
"name": "CRM",
"transporter": "http",
"endpoints": ["crm-getEntries", "crm-setEntry"],
}
// endpoints/crm-getEntries.json
{
"name": "Get entries",
"match": { "action": "GET", "type": "entry" },
"options": { "uri": "/entries" },
}
The order matters, as Integreat composes the endpoints in the order they are listed. Endpoints have a folder of their own because several services may list the same one, and their keys must be unique across the whole integration, so prefixing them with the service key is a good convention.
In Integreat the service consists of three element types: the service, one
element per endpoint, and an endpoint list of ordered endpoint keys, tied to
its service by having the same key. The endpoints array is that list, so one
file gives you two elements in Integreat. The $shadow marker in this file says
which of the two elements are shadows: true for both, "service" or
"endpoints" for one of them.
Integreat still accepts an older "monolitic" endpoints format, where the
endpoints are included directly in the endpoints array. This can't be mixed, so
run great migrate to extract the inline endpoints to their own files before
adding more endpoints.
Typical Workflow
For new integrations:
- Initialize local workspace:
great init "My Integration" - Create element files (schemas, services, etc.) in their respective folders
- Push local files to Integreat:
great push - Deploy:
great deploy -n "First version"
For existing integrations:
- Clone to local:
great clone [integration-id-or-key] - Make local changes to element files
- Push changes:
great push - Deploy:
great deploy -n "New version"
Setting values:
- From integration directory:
great value set apiKey "my-secret-value" - With integration flag:
great value set apiKey "my-secret" -i my-integration - By element ID:
great value set val-123 "my-value"
Development and testing
To run against a non-prod setup (QA, local, etc.), configure a named environment once and switch to it:
great env set local --api-url http://localhost:3001 --app-url http://localhost:3000
great env use local
great login
Switch back to prod with great env use prod.
Environments
- __INLINE_CODE_135__ or __INLINE_CODE_136__: List configured environments. The built-in __INLINE_CODE_137__ environment is always present, and the active one is marked.
- __INLINE_CODE_138__: Add or update a named environment. The name __INLINE_CODE_139__ is reserved.
- __INLINE_CODE_140__: Switch the active environment. Use __INLINE_CODE_141__ to reset to the default. Leave out __INLINE_CODE_142__ to choose from a list, with the active environment selected. Logins are remembered per environment, so you can switch back and forth without logging in again (until the token expires).
- __INLINE_CODE_143__: Remove a named environment.
Utilities
- __INLINE_CODE_144__: Convert legacy integration JSON to new file structure. Specify the path to a legacy JSON file as the first argument.
- __INLINE_CODE_145__: Combine integration file structure into a single legacy JSON file. Specify the path to an integration folder as the first argument (defaults to current directory). Endpoint keys on services are resolved back to inline endpoint definitions. Note: value elements will have empty values in the output.
- __INLINE_CODE_146__: Migrate an existing workspace to the newest layout. Run it
from the integration folder; it is safe to re-run. It does two things:
- Moves sync bookkeeping stored inline as __INLINE_CODE_147__/__INLINE_CODE_148__/__INLINE_CODE_149__ props (the old layout) to a __INLINE_CODE_150__ file (see Workspace files below).
- Extracts inline endpoint definitions on services to __INLINE_CODE_151__ files, leaving the endpoint keys on the service (see Services and endpoints below). Each key is the endpoint's __INLINE_CODE_152__, or __INLINE_CODE_153__ by position, and is prefixed with the service key and a dash, unless __INLINE_CODE_154__ is given. Keys are kept within 50 chars and made unique with a number suffix if needed. Run __INLINE_CODE_155__ afterwards to create the endpoints in Integreat.
- __INLINE_CODE_156__: Prints the current Unix timestamp. The __INLINE_CODE_157__ flag will copy it to your clipboard.
Exit codes
Errors are written to stderr, and the commands exit with a code scripts can rely on, e.g. __INLINE_CODE_158__:
| Code | Meaning |
|---|---|
| 0 | Success, including when there is nothing to do (e.g. already stopped) |
| 1 | An error, including when only part of the work was done |
| 2 | Cancelled by the user (Ctrl+C, or answering no to abort) |
| 4 | Authentication required (not logged in, or the token was rejected) |
Errors inside a __INLINE_CODE_159__ session don't affect the exit code.
Workspace files
An integration folder contains:
- __INLINE_CODE_160__ at the folder root. This holds the integration's own configuration: its __INLINE_CODE_161__, __INLINE_CODE_162__, __INLINE_CODE_163__, and __INLINE_CODE_164__. The integration's key is the folder name, so renaming its folder to change the key (not yet implemented).
- Per-type folders (__INLINE_CODE_165__, __INLINE_CODE_166__, __INLINE_CODE_167__, __INLINE_CODE_168__, __INLINE_CODE_169__, __INLINE_CODE_170__, __INLINE_CODE_171__, __INLINE_CODE_172__, __INLINE_CODE_173__, __INLINE_CODE_174__) with one JSON file per element. These hold only configuration. Keys come from names, not stored fields: an element's key is its file name without the extension (e.g. __INLINE_CODE_175__ has key __INLINE_CODE_176__). Rename an element with __INLINE_CODE_177__ (a plain file rename is treated as delete + recreate), and remove one with __INLINE_CODE_178__.
- __INLINE_CODE_179__ at the folder root. This holds the sync bookkeeping that links local files to their remote counterparts — the integration and element ids, the owning account, the last-synced timestamps and content hashes. It is managed by __INLINE_CODE_180__ and __INLINE_CODE_181__ — commit it to git, and do not edit it by hand. Deleting it "forgets" all remote links, so the next __INLINE_CODE_182__ recreates the remote elements; this is the clean way to regenerate a folder against a new environment.
Services and endpoints
A service is one file in __INLINE_CODE_183__, and each of its endpoints is a file of its own in __INLINE_CODE_184__. The service refers to the endpoints it uses by key:
// services/crm.json
{
"name": "CRM",
"transporter": "http",
"endpoints": ["crm-getEntries", "crm-setEntry"],
}
// endpoints/crm-getEntries.json
{
"name": "Get entries",
"match": { "action": "GET", "type": "entry" },
"options": { "uri": "/entries" },
}
The order matters, as Integreat composes the endpoints in the order they are listed. Endpoints have a folder of their own because several services may list the same one, and their keys must be unique across the whole integration, so prefixing them with the service key is a good convention.
In Integreat the service consists of three element types: the service, one element per endpoint, and an endpoint list of ordered endpoint keys, tied to its service by having the same key. The __INLINE_CODE_185__ array is that list, so one file gives you two elements in Integreat. The __INLINE_CODE_186__ marker in this file says which of the two elements are shadows: __INLINE_CODE_187__ for both, __INLINE_CODE_188__ or __INLINE_CODE_189__ for one of them.
Integreat still accepts an older "monolitic" endpoints format, where the endpoints are included directly in the endpoints array. This can't be mixed, so run __INLINE_CODE_190__ to extract the inline endpoints to their own files before adding more endpoints.
Typical Workflow
For new integrations:
- Initialize local workspace: __INLINE_CODE_191__
- Create element files (schemas, services, etc.) in their respective folders
- Push local files to Integreat: __INLINE_CODE_192__
- Deploy: __INLINE_CODE_193__
For existing integrations:
- Clone to local: __INLINE_CODE_194__
- Make local changes to element files
- Push changes: __INLINE_CODE_195__
- Deploy: __INLINE_CODE_196__
Setting values:
- From integration directory: __INLINE_CODE_197__
- With integration flag: __INLINE_CODE_198__
- By element ID: __INLINE_CODE_199__
Development and testing
To run against a non-prod setup (QA, local, etc.), configure a named environment once and switch to it:
great env set local --api-url http://localhost:3001 --app-url http://localhost:3000
great env use local
great login
Switch back to prod with __INLINE_CODE_200__.