@fluidgrids/cli 0.0.0-stage → 2026.1028.1
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.
- package/LICENSE +9 -0
- package/README.md +219 -2
- package/dist/auth/device-login.d.ts +31 -0
- package/dist/auth/device-login.d.ts.map +1 -0
- package/dist/auth/device-login.js +75 -0
- package/dist/auth/device-login.js.map +1 -0
- package/dist/auth/token-auth.d.ts +49 -0
- package/dist/auth/token-auth.d.ts.map +1 -0
- package/dist/auth/token-auth.js +279 -0
- package/dist/auth/token-auth.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/code-first/api.d.ts +170 -0
- package/dist/code-first/api.d.ts.map +1 -0
- package/dist/code-first/api.js +166 -0
- package/dist/code-first/api.js.map +1 -0
- package/dist/code-first/commands/codegen.d.ts +20 -0
- package/dist/code-first/commands/codegen.d.ts.map +1 -0
- package/dist/code-first/commands/codegen.js +50 -0
- package/dist/code-first/commands/codegen.js.map +1 -0
- package/dist/code-first/commands/diff.d.ts +28 -0
- package/dist/code-first/commands/diff.d.ts.map +1 -0
- package/dist/code-first/commands/diff.js +73 -0
- package/dist/code-first/commands/diff.js.map +1 -0
- package/dist/code-first/commands/import.d.ts +40 -0
- package/dist/code-first/commands/import.d.ts.map +1 -0
- package/dist/code-first/commands/import.js +235 -0
- package/dist/code-first/commands/import.js.map +1 -0
- package/dist/code-first/commands/init.d.ts +33 -0
- package/dist/code-first/commands/init.d.ts.map +1 -0
- package/dist/code-first/commands/init.js +177 -0
- package/dist/code-first/commands/init.js.map +1 -0
- package/dist/code-first/commands/interface.d.ts +12 -0
- package/dist/code-first/commands/interface.d.ts.map +1 -0
- package/dist/code-first/commands/interface.js +21 -0
- package/dist/code-first/commands/interface.js.map +1 -0
- package/dist/code-first/commands/pull.d.ts +63 -0
- package/dist/code-first/commands/pull.d.ts.map +1 -0
- package/dist/code-first/commands/pull.js +266 -0
- package/dist/code-first/commands/pull.js.map +1 -0
- package/dist/code-first/commands/push.d.ts +51 -0
- package/dist/code-first/commands/push.d.ts.map +1 -0
- package/dist/code-first/commands/push.js +217 -0
- package/dist/code-first/commands/push.js.map +1 -0
- package/dist/code-first/commands/validate.d.ts +34 -0
- package/dist/code-first/commands/validate.d.ts.map +1 -0
- package/dist/code-first/commands/validate.js +115 -0
- package/dist/code-first/commands/validate.js.map +1 -0
- package/dist/code-first/connections.d.ts +55 -0
- package/dist/code-first/connections.d.ts.map +1 -0
- package/dist/code-first/connections.js +180 -0
- package/dist/code-first/connections.js.map +1 -0
- package/dist/code-first/index.d.ts +14 -0
- package/dist/code-first/index.d.ts.map +1 -0
- package/dist/code-first/index.js +31 -0
- package/dist/code-first/index.js.map +1 -0
- package/dist/code-first/lowering.d.ts +42 -0
- package/dist/code-first/lowering.d.ts.map +1 -0
- package/dist/code-first/lowering.js +128 -0
- package/dist/code-first/lowering.js.map +1 -0
- package/dist/code-first/operations.d.ts +57 -0
- package/dist/code-first/operations.d.ts.map +1 -0
- package/dist/code-first/operations.js +167 -0
- package/dist/code-first/operations.js.map +1 -0
- package/dist/code-first/project.d.ts +114 -0
- package/dist/code-first/project.d.ts.map +1 -0
- package/dist/code-first/project.js +279 -0
- package/dist/code-first/project.js.map +1 -0
- package/dist/code-first/python.d.ts +70 -0
- package/dist/code-first/python.d.ts.map +1 -0
- package/dist/code-first/python.js +219 -0
- package/dist/code-first/python.js.map +1 -0
- package/dist/code-first/register.d.ts +21 -0
- package/dist/code-first/register.d.ts.map +1 -0
- package/dist/code-first/register.js +126 -0
- package/dist/code-first/register.js.map +1 -0
- package/dist/code-first/remote.d.ts +58 -0
- package/dist/code-first/remote.d.ts.map +1 -0
- package/dist/code-first/remote.js +120 -0
- package/dist/code-first/remote.js.map +1 -0
- package/dist/code-first/shared.d.ts +39 -0
- package/dist/code-first/shared.d.ts.map +1 -0
- package/dist/code-first/shared.js +57 -0
- package/dist/code-first/shared.js.map +1 -0
- package/dist/modules.d.ts +15 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +61 -0
- package/dist/modules.js.map +1 -0
- package/dist/product-defaults.d.ts +11 -0
- package/dist/product-defaults.d.ts.map +1 -0
- package/dist/product-defaults.js +25 -0
- package/dist/product-defaults.js.map +1 -0
- package/dist/program.d.ts +20 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +43 -0
- package/dist/program.js.map +1 -0
- package/package.json +100 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright (c) 2025 Algoshred Technologies Private Limited.
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software, via any medium, is strictly prohibited without the express written permission of the copyright holders.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
|
9
|
+
For licensing inquiries, please contact: legal@algoshred.com
|
package/README.md
CHANGED
|
@@ -1,3 +1,220 @@
|
|
|
1
|
-
#
|
|
1
|
+
# fluidgrids-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The FluidGrids command line: manage workflows, trigger and watch runs, and work
|
|
4
|
+
with credentials, webhooks and scheduled jobs from a terminal or a CI job.
|
|
5
|
+
|
|
6
|
+
It is a **thin shell over [`@burdenoff/cli-sdk`](https://www.npmjs.com/package/@burdenoff/cli-sdk)**,
|
|
7
|
+
like the VibeControls CLI. The FluidGrids commands live in the shared
|
|
8
|
+
`fluidgrids` module, and the shell also mounts the shared platform modules
|
|
9
|
+
(workspaces, organizations, tags, files, billing, notifications, support, store,
|
|
10
|
+
integrations, devportal and more). The code-first workflow commands (`init`,
|
|
11
|
+
`codegen`, `pull`, `push`, `diff`, `validate`, `import`, `interface`) live in
|
|
12
|
+
this repo under `src/code-first/`, because they depend on
|
|
13
|
+
[`@fluidgrids/workflows`](https://www.npmjs.com/package/@fluidgrids/workflows),
|
|
14
|
+
which the other product CLIs built on cli-sdk should not pull in.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @fluidgrids/cli
|
|
20
|
+
fluidgrids --version
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
From source:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/algoshred/fluidgrids-cli.git
|
|
27
|
+
cd fluidgrids-cli
|
|
28
|
+
bun install
|
|
29
|
+
bun run build
|
|
30
|
+
node dist/cli.js --version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Sign in
|
|
34
|
+
|
|
35
|
+
The CLI uses the OAuth 2.0 device-code flow with the first-party
|
|
36
|
+
`burdenoff_cli_fluidgrids` client. It never asks for your password.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
fluidgrids auth login # prints a URL and a code; approve it in a browser
|
|
40
|
+
fluidgrids workspace list
|
|
41
|
+
fluidgrids workspace set <id> # issues the workspace token workspace commands need
|
|
42
|
+
fluidgrids auth status
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For automation, sign in as an app with `fluidgrids auth login --client-credentials`.
|
|
46
|
+
|
|
47
|
+
### Token mode (CI and the doctor)
|
|
48
|
+
|
|
49
|
+
When `FLUIDGRIDS_TOKEN` (or `--token <token>`) is set, the CLI uses that platform
|
|
50
|
+
access token for the run and never reads or writes the stored login. Prefer the
|
|
51
|
+
variable: a `--token` value is visible in the process list.
|
|
52
|
+
|
|
53
|
+
| Variable | Purpose |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `FLUIDGRIDS_TOKEN` | Platform access token |
|
|
56
|
+
| `FLUIDGRIDS_WORKSPACE_TOKEN` | Workspace token to use as is, or |
|
|
57
|
+
| `FLUIDGRIDS_WORKSPACE_ID` | Workspace to issue a workspace token for (in memory, re-issued before it expires) |
|
|
58
|
+
| `FLUIDGRIDS_ORG_ID` | Organization, sent as `x-org-id` (optional; the platform derives it from the workspace) |
|
|
59
|
+
| `FLUIDGRIDS_CF_ACCESS_CLIENT_ID` / `_SECRET` | Cloudflare Access service-token headers, which the alpha gateways need |
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
FLUIDGRIDS_TOKEN=… FLUIDGRIDS_WORKSPACE_ID=… fluidgrids diff --exit-code
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Queries are retried up to three times on network and 5xx errors. Mutations are
|
|
66
|
+
sent once: after a server error the CLI cannot tell whether a version was
|
|
67
|
+
created, and a retry could create it twice. With only
|
|
68
|
+
`FLUIDGRIDS_WORKSPACE_TOKEN`, the CLI does not know which workspace the token is
|
|
69
|
+
for, so set `FLUIDGRIDS_WORKSPACE_ID` as well to keep the project workspace check.
|
|
70
|
+
|
|
71
|
+
## Workflows and runs
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
fluidgrids workflows list --status ACTIVE
|
|
75
|
+
fluidgrids workflows get <definitionId>
|
|
76
|
+
fluidgrids workflows get --key <workflowKey> --wf-version <version>
|
|
77
|
+
fluidgrids workflows versions <workflowKey>
|
|
78
|
+
fluidgrids workflows create workflow.json # CreateWorkflowDefinitionInput
|
|
79
|
+
fluidgrids workflows publish|activate|deactivate|archive <definitionId>
|
|
80
|
+
fluidgrids workflows duplicate <workflowKey> <version> --new-key <key>
|
|
81
|
+
fluidgrids workflows import template.json # ImportWorkflowTemplateInput
|
|
82
|
+
fluidgrids workflows delete <workflowKey> [--wf-version <v>] --force
|
|
83
|
+
|
|
84
|
+
fluidgrids workflows trigger <workflowKey> --wf-version <version> --trigger-node <nodeId> \
|
|
85
|
+
--input '{"amount":42}'
|
|
86
|
+
fluidgrids runs list --workflow-key <workflowKey> --status FAILED
|
|
87
|
+
fluidgrids runs list --workflow-id <definitionId> # exact definition, scans all pages
|
|
88
|
+
fluidgrids runs wait <runId> --timeout 600000
|
|
89
|
+
fluidgrids runs logs <runId> --level WARN --page-info
|
|
90
|
+
fluidgrids runs resume <runId> --payload '{"approved":true}'
|
|
91
|
+
fluidgrids runs retry-node <runId> <graphNodeId>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Code-first workflows
|
|
95
|
+
|
|
96
|
+
Workflows can be kept as TypeScript or Python in a project (spec
|
|
97
|
+
`fluidgrids-specs/product/specs/code-first`, Phase A). Tier-1 code *constructs*
|
|
98
|
+
a canvas workflow: the canvas and the code are two views of one definition, and
|
|
99
|
+
the CLI lifts and lowers between them with `@fluidgrids/workflows`.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
my-automations/
|
|
103
|
+
fluidgrids.config.json language, workspace, default task queue, Python interpreter
|
|
104
|
+
package.json (TypeScript) @fluidgrids/workflows, @fluidgrids/cli
|
|
105
|
+
pyproject.toml (Python) fluidgrids-workflows
|
|
106
|
+
.fluidgrids/nodes.ts|py typed node clients (fluidgrids codegen; commit it)
|
|
107
|
+
workflows/<key>.ts|py tier-1 source, with <key>.layout.json (and <key>.pinned.json)
|
|
108
|
+
workflows/<key>.json a workflow kept as the JSON export envelope
|
|
109
|
+
activities/ code workflows import
|
|
110
|
+
lock.json registry snapshot, node versions, SDK version, pulled versions
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
fluidgrids init --lang ts # scaffold; signs in (device code) when signed out at a terminal
|
|
115
|
+
fluidgrids codegen # .fluidgrids/nodes.ts from the workspace's node registry
|
|
116
|
+
fluidgrids pull lead-enrichment # workflows/lead-enrichment.ts + layout sidecar
|
|
117
|
+
fluidgrids pull --as py # every tracked workflow as Python (`--format py` works too)
|
|
118
|
+
fluidgrids pull --check # print the fidelity report; exit 1 when an export is lossy
|
|
119
|
+
fluidgrids validate --strict # IR v2 rules plus the strict rules (add --remote for the service)
|
|
120
|
+
fluidgrids diff --against active # IR diff of the local workflows against a stored version
|
|
121
|
+
fluidgrids push --dry-run # what would change
|
|
122
|
+
fluidgrids push -m "Route big leads" # a new version per changed workflow, with workflowVersionDiff
|
|
123
|
+
fluidgrids import workflows/new-flow.ts # a NEW workflow through the service's import (it lowers the TypeScript)
|
|
124
|
+
fluidgrids interface lead-enrichment # the typed interface of the ACTIVE (else newest) version
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- **Fidelity** is computed by lowering the lifted code and comparing `irHash`,
|
|
128
|
+
never by heuristics. `--server` on `pull` asks the service to render instead.
|
|
129
|
+
- **Push** lowers the whole project locally once, validates every workflow, and
|
|
130
|
+
creates a version only for workflows whose `irHash` changed
|
|
131
|
+
(`createWorkflowVersion`; a key new to the workspace goes through
|
|
132
|
+
`importWorkflow` as a DRAFT). Stored pinned TEST data is kept when the code has none.
|
|
133
|
+
When a workflow got a newer version in the workspace after it was pulled (a
|
|
134
|
+
canvas edit, another push), `push` refuses rather than silently revert it:
|
|
135
|
+
pull again and re-apply the edit, or pass `--force`.
|
|
136
|
+
- **Workspace.** `init --workspace <id>` records the workspace in
|
|
137
|
+
`fluidgrids.config.json`. While it is recorded, `pull`, `push`, `diff`,
|
|
138
|
+
`validate`, `codegen` and `import` refuse to run against another workspace
|
|
139
|
+
(switch with `fluidgrids workspace set <id>` or `FLUIDGRIDS_WORKSPACE_ID`).
|
|
140
|
+
Without `workspaceId` the project works with whichever workspace is selected.
|
|
141
|
+
- **Connections** are written by name in code. Names resolve against the
|
|
142
|
+
workspace's connections at push time; a name that does not resolve stops the
|
|
143
|
+
push before anything is written, with what to do about it. Only the
|
|
144
|
+
connections a workflow uses are sent to the service (`pull --server`,
|
|
145
|
+
`import` of TypeScript).
|
|
146
|
+
- **Python** projects need Python 3.11+ with the `fluidgrids-workflows` package.
|
|
147
|
+
`pull` and `codegen` write `.py` without it; `push`, `diff`, `validate` and
|
|
148
|
+
`import` run `python -m fluidgrids_workflows lower` and stop with an install
|
|
149
|
+
hint when the package is missing. The interpreter is `FLUIDGRIDS_PYTHON`, then
|
|
150
|
+
`"python"` in `fluidgrids.config.json`, then `.venv/`, then `python3`.
|
|
151
|
+
- The workspace needs the `fluidgrids.code-first` feature for the code-first
|
|
152
|
+
service operations (`exportWorkflow` as code, `importWorkflow` from source,
|
|
153
|
+
`validateWorkflowDefinition`, `workflowInterface`, and saving a definition
|
|
154
|
+
that uses IR version 2 fields such as `authoring`).
|
|
155
|
+
|
|
156
|
+
## Credentials, webhooks, scheduled jobs
|
|
157
|
+
|
|
158
|
+
A credential is an integration connection. Creating one is a two-step flow:
|
|
159
|
+
create the connection, then attach the secret. Secrets come from a hidden prompt
|
|
160
|
+
or from the *name* of an environment variable, never from a flag value.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
fluidgrids credentials types --search stripe
|
|
164
|
+
fluidgrids credentials create connection.json # CreateConnectionInput (no secrets)
|
|
165
|
+
fluidgrids credentials auth-api-key <connectionId> --api-key-env PROVIDER_KEY
|
|
166
|
+
fluidgrids credentials auth-basic <connectionId> <username> --password-env PROVIDER_PASSWORD
|
|
167
|
+
fluidgrids credentials test <connectionId>
|
|
168
|
+
|
|
169
|
+
fluidgrids webhooks list --workflow-key <workflowKey>
|
|
170
|
+
fluidgrids webhooks activate|deactivate <id>
|
|
171
|
+
fluidgrids scheduled-jobs list --enabled
|
|
172
|
+
fluidgrids scheduled-jobs pause|resume <jobId>
|
|
173
|
+
|
|
174
|
+
fluidgrids dashboard summary
|
|
175
|
+
fluidgrids dashboard usage --start 2026-10-01 --end 2026-10-21
|
|
176
|
+
fluidgrids search query invoice --type workflow
|
|
177
|
+
fluidgrids admin system-info
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Destructive commands ask for confirmation; pass `--force` in scripts.
|
|
181
|
+
Every data command takes `-f, --format json|table|yaml` (JSON when not on a terminal).
|
|
182
|
+
|
|
183
|
+
## Configuration
|
|
184
|
+
|
|
185
|
+
State lives in `~/.config/fluidgrids-cli/` (`auth.json` is written `0600`).
|
|
186
|
+
Defaults point at production. Overrides:
|
|
187
|
+
|
|
188
|
+
| Variable | Purpose |
|
|
189
|
+
|---|---|
|
|
190
|
+
| `FLUIDGRIDS_WORKSPACE_ENDPOINT` | Workspace gateway (default `https://graphqlworkspaces.burdenoff.com/workspaces/graphql`) |
|
|
191
|
+
| `FLUIDGRIDS_GLOBAL_ENDPOINT` | Global gateway (default `https://graphql.burdenoff.com/global/graphql`) |
|
|
192
|
+
| `FLUIDGRIDS_OIDC_ISSUER` | Device-code issuer (set `https://alphagraphql.burdenoff.com/global` for alpha) |
|
|
193
|
+
| `FLUIDGRIDS_CLIENT_ID` | OAuth client (default `burdenoff_cli_fluidgrids`) |
|
|
194
|
+
| `FLUIDGRIDS_ORIGIN` | Product Origin for a custom or local gateway |
|
|
195
|
+
|
|
196
|
+
The workflow service is product-scoped: the gateway works out the product from
|
|
197
|
+
the request `Origin`. The CLI sends `https://app.fluidgrids.ai` to the production
|
|
198
|
+
gateway and `https://alphaapp.fluidgrids.ai` to the alpha gateway automatically.
|
|
199
|
+
|
|
200
|
+
## Development
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
bun install
|
|
204
|
+
bun run dev -- --help
|
|
205
|
+
bun run test
|
|
206
|
+
bun run sanity # format:check + lint + type-check + test + build
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Changes to the shared command behaviour belong in `cli-sdk`
|
|
210
|
+
(`src/modules/fluidgrids/`). This repo picks modules and product defaults, and
|
|
211
|
+
holds the code-first commands (`src/code-first/`) and token mode (`src/auth/`).
|
|
212
|
+
|
|
213
|
+
The code-first GraphQL documents are validated against the vendored supergraph
|
|
214
|
+
`schema/wspace.graphql` (`bun run schema:pull` refreshes it) and, until the
|
|
215
|
+
code-first service release is on the Hive CDN, against
|
|
216
|
+
`schema/code-first.pending.graphql`.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
PROPRIETARY License - Copyright (c) 2023 Algoshred Technologies Private Limited
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OAuth2 device-code login that `fluidgrids init` runs when the CLI is not
|
|
3
|
+
* signed in (spec 07 §7). It is the same flow as `fluidgrids auth login`, built
|
|
4
|
+
* from the `@burdenoff/cli-sdk/core` primitives, with one difference: it never
|
|
5
|
+
* prompts. The workspace comes from `--workspace`, or is the caller's only
|
|
6
|
+
* workspace; with several and none named, the platform login is stored and
|
|
7
|
+
* `fluidgrids workspace set <id>` picks one.
|
|
8
|
+
*/
|
|
9
|
+
import { fetchWorkspaces, issueWorkspaceToken, openBrowser, pollForToken, startDeviceCodeFlow, type CLIContext } from '@burdenoff/cli-sdk/core';
|
|
10
|
+
/** The device-code primitives; tests substitute them. */
|
|
11
|
+
export interface DeviceLoginDeps {
|
|
12
|
+
startDeviceCodeFlow: typeof startDeviceCodeFlow;
|
|
13
|
+
pollForToken: typeof pollForToken;
|
|
14
|
+
fetchWorkspaces: typeof fetchWorkspaces;
|
|
15
|
+
issueWorkspaceToken: typeof issueWorkspaceToken;
|
|
16
|
+
openBrowser: typeof openBrowser;
|
|
17
|
+
}
|
|
18
|
+
export declare const defaultDeviceLoginDeps: DeviceLoginDeps;
|
|
19
|
+
export interface DeviceLoginResult {
|
|
20
|
+
/** The selected workspace, or null when the caller has to pick one. */
|
|
21
|
+
workspaceId: string | null;
|
|
22
|
+
/** Workspaces to choose from when none was selected. */
|
|
23
|
+
choices: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export declare function deviceCodeLogin(ctx: CLIContext, options?: {
|
|
29
|
+
workspaceId?: string;
|
|
30
|
+
}, deps?: DeviceLoginDeps): Promise<DeviceLoginResult>;
|
|
31
|
+
//# sourceMappingURL=device-login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-login.d.ts","sourceRoot":"","sources":["../../src/auth/device-login.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,KAAK,UAAU,EAEhB,MAAM,yBAAyB,CAAC;AAEjC,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;IAChD,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;IAChD,WAAW,EAAE,OAAO,WAAW,CAAC;CACjC;AAED,eAAO,MAAM,sBAAsB,EAAE,eAMpC,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wDAAwD;IACxD,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9C;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,EACtC,IAAI,GAAE,eAAwC,GAC7C,OAAO,CAAC,iBAAiB,CAAC,CAkE5B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OAuth2 device-code login that `fluidgrids init` runs when the CLI is not
|
|
3
|
+
* signed in (spec 07 §7). It is the same flow as `fluidgrids auth login`, built
|
|
4
|
+
* from the `@burdenoff/cli-sdk/core` primitives, with one difference: it never
|
|
5
|
+
* prompts. The workspace comes from `--workspace`, or is the caller's only
|
|
6
|
+
* workspace; with several and none named, the platform login is stored and
|
|
7
|
+
* `fluidgrids workspace set <id>` picks one.
|
|
8
|
+
*/
|
|
9
|
+
import { fetchWorkspaces, issueWorkspaceToken, openBrowser, pollForToken, startDeviceCodeFlow, CliUserError, } from '@burdenoff/cli-sdk/core';
|
|
10
|
+
export const defaultDeviceLoginDeps = {
|
|
11
|
+
startDeviceCodeFlow,
|
|
12
|
+
pollForToken,
|
|
13
|
+
fetchWorkspaces,
|
|
14
|
+
issueWorkspaceToken,
|
|
15
|
+
openBrowser,
|
|
16
|
+
};
|
|
17
|
+
export async function deviceCodeLogin(ctx, options = {}, deps = defaultDeviceLoginDeps) {
|
|
18
|
+
const config = ctx.config.read();
|
|
19
|
+
const oidc = ctx.config.resolveOIDC();
|
|
20
|
+
const { output } = ctx;
|
|
21
|
+
output.printInfo('Starting device code authentication...');
|
|
22
|
+
const flow = await deps.startDeviceCodeFlow(oidc);
|
|
23
|
+
console.log('');
|
|
24
|
+
console.log(` Open: ${flow.verificationUri}`);
|
|
25
|
+
console.log(` Code: ${flow.userCode}`);
|
|
26
|
+
console.log('');
|
|
27
|
+
if (!(await deps.openBrowser(flow.verificationUriComplete ?? flow.verificationUri))) {
|
|
28
|
+
output.printWarning('Could not open a browser; open the URL above.');
|
|
29
|
+
}
|
|
30
|
+
output.printInfo('Waiting for authorization...');
|
|
31
|
+
const token = await deps.pollForToken(flow.deviceCode, flow.interval, oidc);
|
|
32
|
+
const platform = {
|
|
33
|
+
accessToken: token.accessToken,
|
|
34
|
+
refreshToken: token.refreshToken,
|
|
35
|
+
expiresAt: Date.now() + token.expiresIn * 1000,
|
|
36
|
+
authMethod: 'device_code',
|
|
37
|
+
};
|
|
38
|
+
const workspaces = await deps.fetchWorkspaces(config.globalEndpoint, token.accessToken);
|
|
39
|
+
const selected = options.workspaceId
|
|
40
|
+
? workspaces.find((workspace) => workspace.id === options.workspaceId)
|
|
41
|
+
: workspaces.length === 1
|
|
42
|
+
? workspaces[0]
|
|
43
|
+
: undefined;
|
|
44
|
+
if (options.workspaceId && !selected) {
|
|
45
|
+
ctx.auth.write(platform);
|
|
46
|
+
ctx.gql.reset();
|
|
47
|
+
throw new CliUserError(`You are not a member of workspace ${options.workspaceId}.`, {
|
|
48
|
+
hint: workspaces.length > 0
|
|
49
|
+
? `Your workspaces: ${workspaces.map((workspace) => `${workspace.name} (${workspace.id})`).join(', ')}`
|
|
50
|
+
: 'Your account has no workspaces yet.',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (!selected) {
|
|
54
|
+
ctx.auth.write(platform);
|
|
55
|
+
ctx.gql.reset();
|
|
56
|
+
output.printSuccess('Authentication successful');
|
|
57
|
+
return {
|
|
58
|
+
workspaceId: null,
|
|
59
|
+
choices: workspaces.map((workspace) => ({ id: workspace.id, name: workspace.name })),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const issued = await deps.issueWorkspaceToken(config.workspaceEndpoint, token.accessToken, selected.id, selected.organizationId);
|
|
63
|
+
const workspaceTokenExpiresAt = Date.parse(issued.expiresAt);
|
|
64
|
+
ctx.auth.write({
|
|
65
|
+
...platform,
|
|
66
|
+
workspaceToken: issued.token,
|
|
67
|
+
...(Number.isFinite(workspaceTokenExpiresAt) ? { workspaceTokenExpiresAt } : {}),
|
|
68
|
+
workspaceId: selected.id,
|
|
69
|
+
organizationId: selected.organizationId,
|
|
70
|
+
});
|
|
71
|
+
ctx.gql.reset();
|
|
72
|
+
output.printSuccess(`Authentication successful; using workspace ${selected.name}`);
|
|
73
|
+
return { workspaceId: selected.id, choices: [] };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=device-login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-login.js","sourceRoot":"","sources":["../../src/auth/device-login.ts"],"names":[],"mappings":"AAAA;;;;;;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RIDS_TOKEN` (or `--token <token>`) is set, the CLI uses that
|
|
5
|
+
* platform access token instead of the stored device-code login, and never
|
|
6
|
+
* writes a token to disk. The workspace token comes from
|
|
7
|
+
* `FLUIDGRIDS_WORKSPACE_TOKEN`, or is issued in memory for
|
|
8
|
+
* `FLUIDGRIDS_WORKSPACE_ID` (and re-issued shortly before it expires).
|
|
9
|
+
* `FLUIDGRIDS_ORG_ID` is optional: the platform derives the organization from
|
|
10
|
+
* the workspace, and the CLI sends it as `x-org-id` when it is set. `FLUIDGRIDS_CF_ACCESS_CLIENT_ID` / `_SECRET` add Cloudflare
|
|
11
|
+
* Access service-token headers, which alpha gateways require.
|
|
12
|
+
*
|
|
13
|
+
* Prefer the environment variable: a `--token` value is visible in the
|
|
14
|
+
* process list.
|
|
15
|
+
*/
|
|
16
|
+
import { type RequestDocument } from 'graphql-request';
|
|
17
|
+
import { type AuthStore, type CLIContext, type ConfigStore, type GqlClients } from '@burdenoff/cli-sdk/core';
|
|
18
|
+
export declare const TOKEN_FLAG = "--token";
|
|
19
|
+
export interface TokenAuthSettings {
|
|
20
|
+
accessToken: string;
|
|
21
|
+
workspaceToken?: string;
|
|
22
|
+
workspaceId?: string;
|
|
23
|
+
organizationId?: string;
|
|
24
|
+
cfAccess?: {
|
|
25
|
+
clientId: string;
|
|
26
|
+
clientSecret: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The `--token` value from argv, if given; `undefined` when the flag is absent. */
|
|
30
|
+
export declare function tokenFromArgv(argv: readonly string[]): string | undefined;
|
|
31
|
+
/** Token mode settings, or null for the normal stored login. */
|
|
32
|
+
export declare function readTokenAuthSettings(argv: readonly string[], env: Readonly<Record<string, string | undefined>>, prefix?: string): TokenAuthSettings | null;
|
|
33
|
+
/** The `exp` claim of a JWT in milliseconds, when the token is a readable JWT. */
|
|
34
|
+
export declare function jwtExpiry(token: string): number | undefined;
|
|
35
|
+
/** An in-memory AuthStore over the injected tokens; `write` never touches the disk. */
|
|
36
|
+
export declare function createTokenAuthStore(settings: TokenAuthSettings): AuthStore;
|
|
37
|
+
/**
|
|
38
|
+
* True when the document holds a mutation. A server error after a mutation
|
|
39
|
+
* does not say whether it was applied, so retrying it could, for example,
|
|
40
|
+
* create a workflow version twice. A document that does not parse is left to
|
|
41
|
+
* the server to refuse.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isMutation(document: RequestDocument): boolean;
|
|
44
|
+
export declare const ISSUE_WORKSPACE_TOKEN = "\n mutation FluidgridsTokenModeIssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {\n issueWorkspaceToken(input: $input) {\n success token expiresAt\n error { code message }\n }\n }\n";
|
|
45
|
+
/** GraphQL clients for token mode: static tokens, Cloudflare Access headers, no refresh. */
|
|
46
|
+
export declare function createTokenGqlClients(config: ConfigStore, auth: AuthStore, settings: TokenAuthSettings): GqlClients;
|
|
47
|
+
/** The context with token-mode auth and clients in place of the stored login. */
|
|
48
|
+
export declare function applyTokenAuth(ctx: CLIContext, settings: TokenAuthSettings): CLIContext;
|
|
49
|
+
//# sourceMappingURL=token-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-auth.d.ts","sourceRoot":"","sources":["../../src/auth/token-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAiB,KAAK,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EAEhB,KAAK,UAAU,EAEhB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,UAAU,YAAY,CAAC;AAEpC,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE;QAAE,QAAQ,E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