snoutdata 0.0.1 → 0.1.0
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/README.md +147 -10
- package/dist/snoutdata.mjs +2815 -0
- package/package.json +46 -20
- package/LICENSE +0 -21
- package/index.js +0 -6
package/README.md
CHANGED
|
@@ -1,21 +1,158 @@
|
|
|
1
1
|
# snoutdata
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Hosted Postgres from a terminal, or from an agent. One bundled file with no dependencies, so
|
|
4
|
+
`npx snoutdata` is a download rather than an install. Needs Node 20 or newer.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
```bash
|
|
7
|
+
npx snoutdata init --env
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
An empty folder becomes a folder with a working database: a project is created, the command
|
|
11
|
+
waits until it is actually serving, writes `.snoutdata/project.json`, and puts `DATABASE_URL`
|
|
12
|
+
in `.env`. It is idempotent, so running it twice gives you the same project, not two.
|
|
13
|
+
|
|
14
|
+
Driven end to end holding nothing but an access token (no browser, no session, no human) in
|
|
15
|
+
21 seconds, with a `DATABASE_URL` that connected on the first try.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## For an agent
|
|
20
|
+
|
|
21
|
+
This CLI is built to be driven by a program. The contract, which every command holds:
|
|
22
|
+
|
|
23
|
+
| | |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `--json` | Accepted everywhere. **Exactly one JSON value on stdout and nothing else**, so a pipe into `jq` needs no filtering. Progress, warnings and prompts go to stderr. |
|
|
26
|
+
| Failures are structured | In `--json` mode a failure is `{"ok":false,"code":"...","error":"..."}` on stdout. Including a bad flag, a bad command, and a bad credential. |
|
|
27
|
+
| No prompts | Nothing asks a question when stdin is not a terminal, or under `--json`, or in CI. A command that would have to ask says which flag to pass and exits 2 immediately, rather than blocking on a question nobody will answer. |
|
|
28
|
+
| Unknown flags are errors | Never ignored. A typo that quietly does something else is worse than a stop. |
|
|
29
|
+
| Typed exit codes | The code says what kind of problem it was, so a caller can decide whether to retry, re-authenticate, or give up. |
|
|
30
|
+
|
|
31
|
+
### Exit codes
|
|
32
|
+
|
|
33
|
+
| Code | Meaning | What a caller should do |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `0` | Fine | Continue. |
|
|
36
|
+
| `1` | The operation failed | Read the error. |
|
|
37
|
+
| `2` | The command was wrong | Fix the call. Do not retry. |
|
|
38
|
+
| `3` | The credential is no good | Never signed in, expired, or revoked. The message says which. |
|
|
39
|
+
| `4` | Not ready yet | Retry. |
|
|
40
|
+
| `5` | Forbidden | Do not retry. |
|
|
41
|
+
| `6` | Not found | Do not retry. |
|
|
42
|
+
| `7` | Conflict | |
|
|
43
|
+
| `8` | Over a quota | The plan's limit. Do not retry. |
|
|
44
|
+
| `9` | Network | Retry. |
|
|
45
|
+
| `10` | Timed out | Retry, or raise `--timeout`. |
|
|
46
|
+
|
|
47
|
+
### Credentials, without a browser
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
export SNOUTDATA_ACCESS_TOKEN=sdt_... # made once by a person: snoutdata tokens create
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`SNOUTDATA_ACCESS_TOKEN` outranks everything and never expires, which is what CI and an agent
|
|
54
|
+
should use: a script's behaviour should not depend on who happens to be logged in on the machine
|
|
55
|
+
it runs on. Failing that, `~/.snoutdata/auth.json` (written by `snoutdata login`, mode 0600),
|
|
56
|
+
whose session lasts an hour.
|
|
57
|
+
|
|
58
|
+
The token is exchanged for a short-lived session by the control plane, so row-level security is
|
|
59
|
+
still the only thing deciding what it can see.
|
|
60
|
+
|
|
61
|
+
### As an MCP server
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
snoutdata mcp
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Serves the operations below as tools over stdio, so an agent configures one server instead of
|
|
68
|
+
being handed a connection string. Anything destructive is off unless you pass `--allow-delete`,
|
|
69
|
+
and it is present-but-refusing rather than absent, so an agent can tell you what to turn on
|
|
70
|
+
instead of inventing something else.
|
|
71
|
+
|
|
72
|
+
If the SnoutData desktop app is running on the same machine, its own database tools are borrowed
|
|
73
|
+
onto the same endpoint under an `app_` prefix, so one configured server covers both the cloud and
|
|
74
|
+
the databases already set up locally. `SNOUTDATA_NO_DESKTOP=1` opts out.
|
|
75
|
+
|
|
76
|
+
---
|
|
6
77
|
|
|
7
|
-
|
|
8
|
-
|
|
78
|
+
## Commands
|
|
79
|
+
|
|
80
|
+
**Setup**
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
snoutdata init [--name X] [--env] # a database for this folder, linked and ready
|
|
84
|
+
snoutdata link --ref R # point this folder at an existing project
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Auth**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
snoutdata login # through a browser
|
|
91
|
+
snoutdata login --device # print a code to type into a browser anywhere
|
|
92
|
+
snoutdata login --no-browser # print the URL instead of opening one
|
|
93
|
+
snoutdata logout
|
|
94
|
+
snoutdata whoami
|
|
95
|
+
snoutdata tokens create --name ci [--expires DAYS]
|
|
96
|
+
snoutdata tokens list
|
|
97
|
+
snoutdata tokens revoke <id|sdt_prefix>
|
|
9
98
|
```
|
|
10
99
|
|
|
11
|
-
|
|
100
|
+
**Projects**
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
snoutdata projects list
|
|
104
|
+
snoutdata projects create --name X [--region R] [--no-wait]
|
|
105
|
+
snoutdata projects pause|resume|delete [--ref R]
|
|
106
|
+
snoutdata usage [--ref R] [--days 30] [--history]
|
|
107
|
+
snoutdata teams
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Database**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
snoutdata db url [--ref R] # a connection string
|
|
114
|
+
snoutdata db psql [--ref R] [-- ...] # opens psql, no password typed
|
|
115
|
+
snoutdata db reset-password [--ref R]
|
|
116
|
+
snoutdata db export [--ref R] [--out FILE] # take a dump and download it
|
|
117
|
+
snoutdata db push [--dir migrations] [--dry-run] # run the .sql files, once each
|
|
118
|
+
snoutdata db restore --file DUMP [--force]
|
|
119
|
+
```
|
|
12
120
|
|
|
13
|
-
|
|
14
|
-
import snoutdata from "snoutdata";
|
|
121
|
+
**Agents**
|
|
15
122
|
|
|
16
|
-
|
|
123
|
+
```bash
|
|
124
|
+
snoutdata mcp [--allow-delete]
|
|
17
125
|
```
|
|
18
126
|
|
|
19
|
-
|
|
127
|
+
Every command takes `--json`, `--quiet` and `--help`, and anything that waits takes
|
|
128
|
+
`--timeout SECONDS`. `snoutdata --help --json` returns the whole command surface as JSON.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Where things come from
|
|
133
|
+
|
|
134
|
+
**A project**, in order: `--ref`, then `SNOUTDATA_PROJECT`, then `.snoutdata/project.json` in
|
|
135
|
+
this folder or a parent.
|
|
136
|
+
|
|
137
|
+
**A token**, in order: `SNOUTDATA_ACCESS_TOKEN`, then `~/.snoutdata/auth.json`.
|
|
138
|
+
|
|
139
|
+
**Sign-in, when there is no credential and a person is present**, in order: the SnoutData
|
|
140
|
+
desktop app if it is running here and willing, then a browser, then a pairing code for a
|
|
141
|
+
terminal that has no browser at all. With no person present (not a terminal, `--json`, CI, or
|
|
142
|
+
`SNOUTDATA_NO_INTERACTIVE`) nothing is asked and it exits 3 at once.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
- Everything an agent needs, on one page: <https://docs.snoutdata.com/cloud/agent>
|
|
149
|
+
- Full CLI reference: <https://docs.snoutdata.com/cloud/cli>
|
|
150
|
+
- Getting started: <https://docs.snoutdata.com/cloud/getting-started>
|
|
151
|
+
- Plans and limits: <https://docs.snoutdata.com/cloud/limits>
|
|
152
|
+
|
|
153
|
+
SnoutData Cloud is hosted Postgres that costs nothing when idle: a database pauses when nobody
|
|
154
|
+
is using it and wakes on the next connection, while the client waits.
|
|
155
|
+
|
|
156
|
+
---
|
|
20
157
|
|
|
21
|
-
|
|
158
|
+
© SnoutData. See <https://snoutdata.com/terms>.
|