flowbase-cli 0.1.5__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowbase-cli
3
+ Version: 0.1.7
4
+ Summary: Command line client for the FlowBase OpenAPI
5
+ Author: DeepFlowAI
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+
10
+ # FlowBase CLI
11
+
12
+ `flowbase` is the official command line client for the FlowBase OpenAPI. It manages apps, objects, fields, views, custom pages, workflows, dashboards, business records, roles, and configuration versions across the three FlowBase environments.
13
+
14
+ ## 1. Install and connect
15
+
16
+ ```bash
17
+ python -m pip install ./packages/flowbase-cli
18
+ ```
19
+
20
+ Connect to an environment by its site Base URL and a FlowBase API key:
21
+
22
+ ```bash
23
+ export FLOWBASE_HOST=https://flowbase-test-a.deepflowagent.com
24
+ export FLOWBASE_API_KEY=fbk_xxx
25
+ ```
26
+
27
+ | Setting | Source |
28
+ | --- | --- |
29
+ | Host | `--host` > `FLOWBASE_HOST` > `http://flowbase.localhost:5001` |
30
+ | API key | `--api-key` > `FLOWBASE_API_KEY` |
31
+
32
+ The CLI appends `/api/openapi/v1` automatically and sends `Authorization: Bearer <key>` plus an `X-FlowBase-Channel: cli` header. It never stores keys on disk and never prints the full key in errors.
33
+
34
+ ## 2. Environments
35
+
36
+ FlowBase has three environments, selected only by the Host — never by a query, body, or extra header:
37
+
38
+ | Environment | Host |
39
+ | --- | --- |
40
+ | Production | `https://flowbase.deepflowagent.com` |
41
+ | Test A | `https://flowbase-test-a.deepflowagent.com` |
42
+ | Test B | `https://flowbase-test-b.deepflowagent.com` |
43
+
44
+ Most commands run on every Host; `roles` is production-only and `changes commit/release` is test-only.
45
+
46
+ ## 3. Mental model
47
+
48
+ ### 3.1 Metadata vs records
49
+
50
+ - **Metadata** (`metadata` scope): apps, objects, fields, views, pages, workflows, dashboards, roles, versions.
51
+ - **Business records** (`records` scope): rows inside an object.
52
+
53
+ Metadata changes are **drafts** against the current environment's configuration repository. They do not affect the running front-end until they are committed and released.
54
+
55
+ ### 3.2 Draft → commit → release
56
+
57
+ ```text
58
+ metadata write commands → draft in the current environment
59
+ changes commit → snapshot draft into a new version (test env)
60
+ changes release → publish the current test version to production
61
+ changes direct-release → production hotfix: preflight + confirmation, then publish drafts
62
+ ```
63
+
64
+ Most update commands accept an optional `baseRevision` to guard against concurrent edits; the server returns `409` if the draft moved since your last read.
65
+
66
+ ### 3.3 Scope and confirmation
67
+
68
+ Each operation is in `metadata:read`, `metadata:write`, `records:read`, or `records:write`. Destructive commands (`delete`, `restore`, `set-enabled`, version operations) ask for confirmation in a terminal; in automation you must pass `--yes`.
69
+
70
+ ## 4. Command groups
71
+
72
+ ```text
73
+ flowbase
74
+ ├── docs list | show | example | operations Offline endpoint catalog
75
+ ├── apps list | get | create | update | set-enabled | delete
76
+ │ add-objects | remove-object | set-group | reorder-objects
77
+ │ add-dashboards | remove-dashboard | set-dashboard-group | reorder-members
78
+ ├── groups create | reorder | update | delete App groups (under an app)
79
+ ├── objects list | get | create | update | delete | restore
80
+ ├── fields create | update | delete | restore Fields under an object
81
+ ├── views list | create | update | reorder | set-enabled | delete
82
+ ├── workflows list | get | create | update | reorder | set-enabled | delete | executions
83
+ ├── pages list | options | get | create | update | set-default | delete | restore
84
+ ├── dashboards list | get | create | update | copy | delete
85
+ ├── changes commit | release | direct-release
86
+ ├── versions list | show | releases Read-only history
87
+ ├── environments restart Destructive test-env reset
88
+ ├── records list | get | create | update | delete | upload-attachment | download-attachment
89
+ └── roles list | options | get | create | update | delete (production only)
90
+ ```
91
+
92
+ Global flags: `--host`, `--api-key`, `--pretty`/`--no-pretty`, `--raw`.
93
+
94
+ ## 5. Discovering request bodies
95
+
96
+ JSON writes accept `--json` or `--json-file`. The CLI is self-describing:
97
+
98
+ ```bash
99
+ flowbase docs list # endpoints + hasRequestBody/requiresConfirmation flags
100
+ flowbase docs show dashboards.update # metadata + representative request body
101
+ flowbase docs example dashboards.update --output dashboard.json
102
+ flowbase dashboards update dsh_xxx --json-file dashboard.json
103
+ ```
104
+
105
+ `flowbase docs example <key>` prints a representative body template for that endpoint so you can edit it instead of writing from scratch.
106
+
107
+ ### Closed-domain catalogs
108
+
109
+ Complex bodies reference closed sets that are not guessable from examples. Query them offline:
110
+
111
+ ```bash
112
+ flowbase docs catalogs # list available catalogs
113
+ flowbase docs catalogs field-types # field type names + allowed constraints
114
+ flowbase docs catalogs workflow-nodes # node types with in/out edge rules
115
+ flowbase docs catalogs permissions # function permission points + data scopes
116
+ flowbase docs catalogs dashboard-filters # filter types + date-range presets
117
+ flowbase docs catalogs id-prefixes # resource ID prefix meanings
118
+ flowbase docs catalogs icons # icon guidance + examples
119
+ ```
120
+
121
+ ### The read → modify → write loop
122
+
123
+ Most `update` commands replace a **full snapshot** and accept an optional `baseRevision` for optimistic locking. The safe pattern is:
124
+
125
+ ```bash
126
+ flowbase dashboards get dsh_xxx > current.json # authoritative snapshot
127
+ # edit current.json: change fields, keep filters/components, use draftRevision as baseRevision
128
+ flowbase dashboards update dsh_xxx --json-file current.json
129
+ ```
130
+
131
+ Do not compose update bodies from scratch when an existing resource exists — `get` returns the server-valid shape, including `baseRevision`.
132
+
133
+ ## 6. Recipes
134
+
135
+ ### 6.1 Create an object with a field and a record
136
+
137
+ ```bash
138
+ flowbase objects create --label Customer --key customer --description "Customer records"
139
+ flowbase fields create obj_xxx --json '{"label":"Name","key":"name","description":"Customer name","type":"text.singleLine","permission":"required"}'
140
+ flowbase records create obj_xxx --json '{"values":{"name":"Acme Corp"}}'
141
+ ```
142
+
143
+ Record `values` keys are **field keys** (`name`), not internal IDs (`fld_...`). IDs are `obj_`/`fld_`/`dsh_`/`wfl_`/`pag_`-prefixed; see `docs catalogs id-prefixes`.
144
+
145
+ ### 6.2 Edit and publish configuration on a test environment
146
+
147
+ ```bash
148
+ export FLOWBASE_HOST=https://flowbase-test-a.deepflowagent.com
149
+
150
+ flowbase dashboards create --label "Sales board" --key sales_board
151
+ flowbase docs example dashboards.update --output dashboard.json # fill filters/components
152
+ flowbase dashboards update dsh_xxx --json-file dashboard.json
153
+ flowbase apps add-dashboards app_xxx dsh_xxx
154
+ flowbase apps reorder-members app_xxx --json '{"items":[{"type":"object","id":"obj_xxx"},{"type":"dashboard","id":"dsh_xxx"}]}'
155
+ flowbase changes commit --message "Add sales dashboard" --yes
156
+ flowbase changes release --message "Ship sales dashboard" --yes
157
+ ```
158
+
159
+ Dashboard component code runs server-side in a sandbox and returns ECharts config / metric / table / markdown. Components and filters are validated on save; runtime results are only visible in the web UI, not through this CLI.
160
+
161
+ ### 6.3 Production hotfix
162
+
163
+ ```bash
164
+ export FLOWBASE_HOST=https://flowbase.deepflowagent.com
165
+ flowbase changes direct-release --message "Fix customer field" --yes
166
+ ```
167
+
168
+ `direct-release` always runs a server-side preflight, prints the current version, diff summary, checks and risk, and binds a one-time confirmation token. `--yes` accepts that reviewed result; it never skips validation.
169
+
170
+ ### 6.4 Workflows and pages
171
+
172
+ A workflow graph must satisfy structural rules: exactly one `trigger` node, at least one `end` node, a DAG, and valid per-type edges. See `docs catalogs workflow-nodes` before composing `nodes`/`edges`.
173
+
174
+ ```bash
175
+ flowbase docs catalogs workflow-nodes
176
+ flowbase workflows create obj_xxx --json '{"label":"Set owner","enabled":true,"trigger":{"event":"create","match":"all","conditions":[]},"nodes":[],"edges":[]}'
177
+ flowbase workflows update obj_xxx wfl_xxx --json-file workflow.json
178
+ flowbase workflows executions obj_xxx wfl_xxx --result failure
179
+
180
+ flowbase docs example pages.create --output page.json # authoritative layout template
181
+ flowbase pages create --json-file page.json
182
+ flowbase pages set-default pag_xxx --base-revision 4 --yes
183
+ ```
184
+
185
+ ### 6.5 Records and attachments
186
+
187
+ ```bash
188
+ flowbase records list obj_xxx --page 1
189
+ flowbase records get obj_xxx rec_xxx
190
+ flowbase records upload-attachment obj_xxx fld_xxx ./contract.pdf
191
+ flowbase records update obj_xxx rec_xxx --json '{"values":{"fld_contract":["att_xxx"]}}'
192
+ flowbase records download-attachment obj_xxx rec_xxx att_xxx --output ./contract.pdf
193
+ ```
194
+
195
+ ### 6.6 Roles (production only)
196
+
197
+ ```bash
198
+ export FLOWBASE_HOST=https://flowbase.deepflowagent.com
199
+ flowbase docs catalogs permissions # function points + data scopes
200
+ flowbase roles options # apps and objects available for grants
201
+ flowbase roles create --json-file role.json
202
+ flowbase roles update rol_xxx --json-file role.json
203
+ ```
204
+
205
+ ## 7. Output and errors
206
+
207
+ - Success: JSON on stdout, exit code `0`. Use `--no-pretty` for compact JSON or `--raw` for the raw body.
208
+ - Failures (missing key, invalid JSON, HTTP 4xx/5xx, network errors, cancelled confirmation) go to stderr with a clear message and exit code `1`.
209
+ - `flowbase --help` lists every command; `flowbase <group> --help` and `flowbase <group> <action> --help` show flags and, for JSON commands, an inline body example.
210
+
211
+ ### Error matrix
212
+
213
+ | Scenario | HTTP / CLI behavior |
214
+ | --- | --- |
215
+ | Missing or invalid API key | 401; stderr tells you to set `FLOWBASE_API_KEY` or `--api-key` |
216
+ | Environment not enabled | 403; request is rejected before business logic |
217
+ | Missing draft revision / concurrent edit | 409; re-read with `get` and retry with the new `baseRevision` |
218
+ | Invalid request field or business rule | 400 / 422; `detail` explains the reason |
219
+ | Resource not found | 404 |
220
+ | Destructive command without `--yes` in automation | CLI refuses before any network call |
@@ -0,0 +1,211 @@
1
+ # FlowBase CLI
2
+
3
+ `flowbase` is the official command line client for the FlowBase OpenAPI. It manages apps, objects, fields, views, custom pages, workflows, dashboards, business records, roles, and configuration versions across the three FlowBase environments.
4
+
5
+ ## 1. Install and connect
6
+
7
+ ```bash
8
+ python -m pip install ./packages/flowbase-cli
9
+ ```
10
+
11
+ Connect to an environment by its site Base URL and a FlowBase API key:
12
+
13
+ ```bash
14
+ export FLOWBASE_HOST=https://flowbase-test-a.deepflowagent.com
15
+ export FLOWBASE_API_KEY=fbk_xxx
16
+ ```
17
+
18
+ | Setting | Source |
19
+ | --- | --- |
20
+ | Host | `--host` > `FLOWBASE_HOST` > `http://flowbase.localhost:5001` |
21
+ | API key | `--api-key` > `FLOWBASE_API_KEY` |
22
+
23
+ The CLI appends `/api/openapi/v1` automatically and sends `Authorization: Bearer <key>` plus an `X-FlowBase-Channel: cli` header. It never stores keys on disk and never prints the full key in errors.
24
+
25
+ ## 2. Environments
26
+
27
+ FlowBase has three environments, selected only by the Host — never by a query, body, or extra header:
28
+
29
+ | Environment | Host |
30
+ | --- | --- |
31
+ | Production | `https://flowbase.deepflowagent.com` |
32
+ | Test A | `https://flowbase-test-a.deepflowagent.com` |
33
+ | Test B | `https://flowbase-test-b.deepflowagent.com` |
34
+
35
+ Most commands run on every Host; `roles` is production-only and `changes commit/release` is test-only.
36
+
37
+ ## 3. Mental model
38
+
39
+ ### 3.1 Metadata vs records
40
+
41
+ - **Metadata** (`metadata` scope): apps, objects, fields, views, pages, workflows, dashboards, roles, versions.
42
+ - **Business records** (`records` scope): rows inside an object.
43
+
44
+ Metadata changes are **drafts** against the current environment's configuration repository. They do not affect the running front-end until they are committed and released.
45
+
46
+ ### 3.2 Draft → commit → release
47
+
48
+ ```text
49
+ metadata write commands → draft in the current environment
50
+ changes commit → snapshot draft into a new version (test env)
51
+ changes release → publish the current test version to production
52
+ changes direct-release → production hotfix: preflight + confirmation, then publish drafts
53
+ ```
54
+
55
+ Most update commands accept an optional `baseRevision` to guard against concurrent edits; the server returns `409` if the draft moved since your last read.
56
+
57
+ ### 3.3 Scope and confirmation
58
+
59
+ Each operation is in `metadata:read`, `metadata:write`, `records:read`, or `records:write`. Destructive commands (`delete`, `restore`, `set-enabled`, version operations) ask for confirmation in a terminal; in automation you must pass `--yes`.
60
+
61
+ ## 4. Command groups
62
+
63
+ ```text
64
+ flowbase
65
+ ├── docs list | show | example | operations Offline endpoint catalog
66
+ ├── apps list | get | create | update | set-enabled | delete
67
+ │ add-objects | remove-object | set-group | reorder-objects
68
+ │ add-dashboards | remove-dashboard | set-dashboard-group | reorder-members
69
+ ├── groups create | reorder | update | delete App groups (under an app)
70
+ ├── objects list | get | create | update | delete | restore
71
+ ├── fields create | update | delete | restore Fields under an object
72
+ ├── views list | create | update | reorder | set-enabled | delete
73
+ ├── workflows list | get | create | update | reorder | set-enabled | delete | executions
74
+ ├── pages list | options | get | create | update | set-default | delete | restore
75
+ ├── dashboards list | get | create | update | copy | delete
76
+ ├── changes commit | release | direct-release
77
+ ├── versions list | show | releases Read-only history
78
+ ├── environments restart Destructive test-env reset
79
+ ├── records list | get | create | update | delete | upload-attachment | download-attachment
80
+ └── roles list | options | get | create | update | delete (production only)
81
+ ```
82
+
83
+ Global flags: `--host`, `--api-key`, `--pretty`/`--no-pretty`, `--raw`.
84
+
85
+ ## 5. Discovering request bodies
86
+
87
+ JSON writes accept `--json` or `--json-file`. The CLI is self-describing:
88
+
89
+ ```bash
90
+ flowbase docs list # endpoints + hasRequestBody/requiresConfirmation flags
91
+ flowbase docs show dashboards.update # metadata + representative request body
92
+ flowbase docs example dashboards.update --output dashboard.json
93
+ flowbase dashboards update dsh_xxx --json-file dashboard.json
94
+ ```
95
+
96
+ `flowbase docs example <key>` prints a representative body template for that endpoint so you can edit it instead of writing from scratch.
97
+
98
+ ### Closed-domain catalogs
99
+
100
+ Complex bodies reference closed sets that are not guessable from examples. Query them offline:
101
+
102
+ ```bash
103
+ flowbase docs catalogs # list available catalogs
104
+ flowbase docs catalogs field-types # field type names + allowed constraints
105
+ flowbase docs catalogs workflow-nodes # node types with in/out edge rules
106
+ flowbase docs catalogs permissions # function permission points + data scopes
107
+ flowbase docs catalogs dashboard-filters # filter types + date-range presets
108
+ flowbase docs catalogs id-prefixes # resource ID prefix meanings
109
+ flowbase docs catalogs icons # icon guidance + examples
110
+ ```
111
+
112
+ ### The read → modify → write loop
113
+
114
+ Most `update` commands replace a **full snapshot** and accept an optional `baseRevision` for optimistic locking. The safe pattern is:
115
+
116
+ ```bash
117
+ flowbase dashboards get dsh_xxx > current.json # authoritative snapshot
118
+ # edit current.json: change fields, keep filters/components, use draftRevision as baseRevision
119
+ flowbase dashboards update dsh_xxx --json-file current.json
120
+ ```
121
+
122
+ Do not compose update bodies from scratch when an existing resource exists — `get` returns the server-valid shape, including `baseRevision`.
123
+
124
+ ## 6. Recipes
125
+
126
+ ### 6.1 Create an object with a field and a record
127
+
128
+ ```bash
129
+ flowbase objects create --label Customer --key customer --description "Customer records"
130
+ flowbase fields create obj_xxx --json '{"label":"Name","key":"name","description":"Customer name","type":"text.singleLine","permission":"required"}'
131
+ flowbase records create obj_xxx --json '{"values":{"name":"Acme Corp"}}'
132
+ ```
133
+
134
+ Record `values` keys are **field keys** (`name`), not internal IDs (`fld_...`). IDs are `obj_`/`fld_`/`dsh_`/`wfl_`/`pag_`-prefixed; see `docs catalogs id-prefixes`.
135
+
136
+ ### 6.2 Edit and publish configuration on a test environment
137
+
138
+ ```bash
139
+ export FLOWBASE_HOST=https://flowbase-test-a.deepflowagent.com
140
+
141
+ flowbase dashboards create --label "Sales board" --key sales_board
142
+ flowbase docs example dashboards.update --output dashboard.json # fill filters/components
143
+ flowbase dashboards update dsh_xxx --json-file dashboard.json
144
+ flowbase apps add-dashboards app_xxx dsh_xxx
145
+ flowbase apps reorder-members app_xxx --json '{"items":[{"type":"object","id":"obj_xxx"},{"type":"dashboard","id":"dsh_xxx"}]}'
146
+ flowbase changes commit --message "Add sales dashboard" --yes
147
+ flowbase changes release --message "Ship sales dashboard" --yes
148
+ ```
149
+
150
+ Dashboard component code runs server-side in a sandbox and returns ECharts config / metric / table / markdown. Components and filters are validated on save; runtime results are only visible in the web UI, not through this CLI.
151
+
152
+ ### 6.3 Production hotfix
153
+
154
+ ```bash
155
+ export FLOWBASE_HOST=https://flowbase.deepflowagent.com
156
+ flowbase changes direct-release --message "Fix customer field" --yes
157
+ ```
158
+
159
+ `direct-release` always runs a server-side preflight, prints the current version, diff summary, checks and risk, and binds a one-time confirmation token. `--yes` accepts that reviewed result; it never skips validation.
160
+
161
+ ### 6.4 Workflows and pages
162
+
163
+ A workflow graph must satisfy structural rules: exactly one `trigger` node, at least one `end` node, a DAG, and valid per-type edges. See `docs catalogs workflow-nodes` before composing `nodes`/`edges`.
164
+
165
+ ```bash
166
+ flowbase docs catalogs workflow-nodes
167
+ flowbase workflows create obj_xxx --json '{"label":"Set owner","enabled":true,"trigger":{"event":"create","match":"all","conditions":[]},"nodes":[],"edges":[]}'
168
+ flowbase workflows update obj_xxx wfl_xxx --json-file workflow.json
169
+ flowbase workflows executions obj_xxx wfl_xxx --result failure
170
+
171
+ flowbase docs example pages.create --output page.json # authoritative layout template
172
+ flowbase pages create --json-file page.json
173
+ flowbase pages set-default pag_xxx --base-revision 4 --yes
174
+ ```
175
+
176
+ ### 6.5 Records and attachments
177
+
178
+ ```bash
179
+ flowbase records list obj_xxx --page 1
180
+ flowbase records get obj_xxx rec_xxx
181
+ flowbase records upload-attachment obj_xxx fld_xxx ./contract.pdf
182
+ flowbase records update obj_xxx rec_xxx --json '{"values":{"fld_contract":["att_xxx"]}}'
183
+ flowbase records download-attachment obj_xxx rec_xxx att_xxx --output ./contract.pdf
184
+ ```
185
+
186
+ ### 6.6 Roles (production only)
187
+
188
+ ```bash
189
+ export FLOWBASE_HOST=https://flowbase.deepflowagent.com
190
+ flowbase docs catalogs permissions # function points + data scopes
191
+ flowbase roles options # apps and objects available for grants
192
+ flowbase roles create --json-file role.json
193
+ flowbase roles update rol_xxx --json-file role.json
194
+ ```
195
+
196
+ ## 7. Output and errors
197
+
198
+ - Success: JSON on stdout, exit code `0`. Use `--no-pretty` for compact JSON or `--raw` for the raw body.
199
+ - Failures (missing key, invalid JSON, HTTP 4xx/5xx, network errors, cancelled confirmation) go to stderr with a clear message and exit code `1`.
200
+ - `flowbase --help` lists every command; `flowbase <group> --help` and `flowbase <group> <action> --help` show flags and, for JSON commands, an inline body example.
201
+
202
+ ### Error matrix
203
+
204
+ | Scenario | HTTP / CLI behavior |
205
+ | --- | --- |
206
+ | Missing or invalid API key | 401; stderr tells you to set `FLOWBASE_API_KEY` or `--api-key` |
207
+ | Environment not enabled | 403; request is rejected before business logic |
208
+ | Missing draft revision / concurrent edit | 409; re-read with `get` and retry with the new `baseRevision` |
209
+ | Invalid request field or business rule | 400 / 422; `detail` explains the reason |
210
+ | Resource not found | 404 |
211
+ | Destructive command without `--yes` in automation | CLI refuses before any network call |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "flowbase-cli"
7
- version = "0.1.5"
7
+ version = "0.1.7"
8
8
  description = "Command line client for the FlowBase OpenAPI"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """FlowBase OpenAPI CLI."""
2
2
 
3
- __version__ = "0.1.5"
3
+ __version__ = "0.1.7"