Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,50 @@ confidence quickstart # Launch the interactive setup wizard

### Data Warehouses

| Command | Description |
| ---------------------------------------------------- | -------------------------------------------------- |
| `confidence warehouse validate` | Validate warehouse configuration |
| `confidence warehouse create` | Create a data warehouse connection |
| `confidence warehouse connector create-flag-applied` | Create flag assignment data connector |
| `confidence warehouse connector create-event` | Create event data connector |
| `confidence warehouse assignment-table create` | Create an assignment table for experiment analysis |
| `confidence warehouse crypto-key create` | Create a crypto key (Snowflake) |
| Command | Description |
| ----------------------------------------------------- | -------------------------------------------------- |
| `confidence warehouse list` | List data warehouse connections |
| `confidence warehouse get --name dataWarehouses/<id>` | Get a data warehouse connection |
| `confidence warehouse validate` | Validate warehouse configuration |
| `confidence warehouse create` | Create a data warehouse connection |
| `confidence warehouse connector create-flag-applied` | Create flag assignment data connector |
| `confidence warehouse connector create-event` | Create event data connector |
| `confidence warehouse assignment-table create` | Create an assignment table for experiment analysis |
| `confidence warehouse crypto-key create` | Create a crypto key (Snowflake) |

#### Read warehouse connections

Warehouse reads call the regional Metrics HTTP API directly (no MCP server required):

```bash
confidence warehouse list --page-size 100 --json
confidence warehouse list --page-token '<nextPageToken>' --json
confidence warehouse list --all --profile production --output table
confidence warehouse get --name dataWarehouses/my-warehouse --json
confidence warehouse get --name dataWarehouses/my-warehouse --dry-run
```

`list` fetches one page by default and preserves `dataWarehouses`, `nextPageToken`, and
other response metadata inside the JSON `data` envelope. An omitted `dataWarehouses`
field in an empty protobuf JSON response is normalized to `[]`. `--page-size` must be a
positive integer at most 1000. `--all` follows pagination until exhausted, combines
warehouses in response order, and fails on repeated page tokens rather than looping.
A 1000-page safety limit also prevents endless aggregation if the server keeps
returning unique tokens; use single-page requests for larger listings. It can start
at `--page-token`; response metadata is merged with later pages taking precedence. `get`
requires a qualified `dataWarehouses/<id>` name, not a bare ID or URL, and rejects a
response for a different warehouse.

Both reads honor `--profile`, select EU/US from the authentication token, and support
`--json` / `--output`. `--dry-run` validates inputs and previews the request without
authentication or network access. Invalid inputs, malformed API responses, and API
errors fail with a nonzero exit code; no partial list is printed if pagination fails.
Public warehouse metadata is retained. Configuration output is restricted to known
public proto fields: input-only client secrets, AWS secret access keys, and unknown
configuration fields are omitted in every output format. Crypto key and service
account references remain visible; they are not raw credentials.

Existing warehouse setup, creation, validation, and connector commands are unchanged.

### SDK

Expand Down
51 changes: 51 additions & 0 deletions packages/cli/__tests__/commands/data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import yargs from 'yargs';
import { prepareAuthTokens } from '@spotify-confidence/testing/auth';
import { dataCommand } from '@commands/index.js';

function run(args: string[]) {
let output = '';
const sut = yargs(args).scriptName('confidence').command(dataCommand).help().exitProcess(false);
return sut
.parseAsync(args, (_error: Error | undefined, _argv: unknown, text: string) => {
output = text;
})
.then(() => output);
}

describe('data command group', () => {
it('is registered in the real root help alongside existing commands', () => {
using _auth = prepareAuthTokens('none');
const sut = fileURLToPath(new URL('../../bin/cli.ts', import.meta.url));

const output = execFileSync(process.execPath, ['--import', 'tsx', sut, '--help'], {
encoding: 'utf8',
env: { ...process.env, CONFIDENCE_TELEMETRY: 'false' },
});

expect(output).toContain('confidence data');
expect(output).toContain('confidence warehouse');
expect(output).toContain('confidence flags');
});

it('shows help without authentication or placeholder API subcommands', async () => {
using _auth = prepareAuthTokens('none');
const sut = run;

const output = await sut(['data', '--help']);

expect(output).toContain('confidence data <command>');
expect(output).not.toMatch(/onboard|discover|proposal|workflow/iu);
});

it('shows guidance when invoked without a subcommand', async () => {
const sut = run;
expect(await sut(['data'])).toContain('confidence data --help');
});

it('rejects unimplemented subcommands', async () => {
const sut = run;
expect(await sut(['data', 'invented'])).toContain('Unknown argument: invented');
});
});
Loading
Loading