@forumulate/cli 0.5.0 → 0.8.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 +116 -5
- package/dist/api/args.d.ts +21 -0
- package/dist/api/args.d.ts.map +1 -0
- package/dist/api/args.js +81 -0
- package/dist/api/args.js.map +1 -0
- package/dist/api/command.d.ts +17 -0
- package/dist/api/command.d.ts.map +1 -0
- package/dist/api/command.js +182 -0
- package/dist/api/command.js.map +1 -0
- package/dist/api/describe.d.ts +5 -0
- package/dist/api/describe.d.ts.map +1 -0
- package/dist/api/describe.js +121 -0
- package/dist/api/describe.js.map +1 -0
- package/dist/api/http.d.ts +81 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +183 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/operations.json +1 -0
- package/dist/api/output.d.ts +35 -0
- package/dist/api/output.d.ts.map +1 -0
- package/dist/api/output.js +176 -0
- package/dist/api/output.js.map +1 -0
- package/dist/api/request.d.ts +37 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +230 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/send.d.ts +35 -0
- package/dist/api/send.d.ts.map +1 -0
- package/dist/api/send.js +85 -0
- package/dist/api/send.js.map +1 -0
- package/dist/api/spec.d.ts +96 -0
- package/dist/api/spec.d.ts.map +1 -0
- package/dist/api/spec.js +126 -0
- package/dist/api/spec.js.map +1 -0
- package/dist/commands/completion.d.ts +12 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +153 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +144 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +35 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +59 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/groups-api.d.ts +11 -0
- package/dist/commands/groups-api.d.ts.map +1 -0
- package/dist/commands/groups-api.js +140 -0
- package/dist/commands/groups-api.js.map +1 -0
- package/dist/commands/groups-community.d.ts +15 -0
- package/dist/commands/groups-community.d.ts.map +1 -0
- package/dist/commands/groups-community.js +344 -0
- package/dist/commands/groups-community.js.map +1 -0
- package/dist/commands/groups-content.d.ts +10 -0
- package/dist/commands/groups-content.d.ts.map +1 -0
- package/dist/commands/groups-content.js +331 -0
- package/dist/commands/groups-content.js.map +1 -0
- package/dist/commands/groups-docs.d.ts +12 -0
- package/dist/commands/groups-docs.d.ts.map +1 -0
- package/dist/commands/groups-docs.js +414 -0
- package/dist/commands/groups-docs.js.map +1 -0
- package/dist/commands/groups-org.d.ts +10 -0
- package/dist/commands/groups-org.d.ts.map +1 -0
- package/dist/commands/groups-org.js +405 -0
- package/dist/commands/groups-org.js.map +1 -0
- package/dist/commands/groups-site.d.ts +3 -0
- package/dist/commands/groups-site.d.ts.map +1 -0
- package/dist/commands/groups-site.js +230 -0
- package/dist/commands/groups-site.js.map +1 -0
- package/dist/commands/groups-spaces.d.ts +3 -0
- package/dist/commands/groups-spaces.d.ts.map +1 -0
- package/dist/commands/groups-spaces.js +273 -0
- package/dist/commands/groups-spaces.js.map +1 -0
- package/dist/commands/groups-types.d.ts +3 -0
- package/dist/commands/groups-types.d.ts.map +1 -0
- package/dist/commands/groups-types.js +251 -0
- package/dist/commands/groups-types.js.map +1 -0
- package/dist/commands/groups.d.ts +4 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +71 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +118 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/resource.d.ts +86 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +314 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/content/library.d.ts +1 -0
- package/dist/content/library.d.ts.map +1 -1
- package/dist/content/library.js +1 -0
- package/dist/content/library.js.map +1 -1
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +142 -0
- package/dist/help.js.map +1 -0
- package/dist/run.d.ts +16 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +51 -91
- package/dist/run.js.map +1 -1
- package/dist/translations/command.d.ts +36 -0
- package/dist/translations/command.d.ts.map +1 -0
- package/dist/translations/command.js +411 -0
- package/dist/translations/command.js.map +1 -0
- package/dist/translations/extras.d.ts +29 -0
- package/dist/translations/extras.d.ts.map +1 -0
- package/dist/translations/extras.js +123 -0
- package/dist/translations/extras.js.map +1 -0
- package/dist/translations/files.d.ts +22 -0
- package/dist/translations/files.d.ts.map +1 -0
- package/dist/translations/files.js +75 -0
- package/dist/translations/files.js.map +1 -0
- package/dist/translations/sync.d.ts +89 -0
- package/dist/translations/sync.d.ts.map +1 -0
- package/dist/translations/sync.js +215 -0
- package/dist/translations/sync.js.map +1 -0
- package/dist/translations/target.d.ts +33 -0
- package/dist/translations/target.d.ts.map +1 -0
- package/dist/translations/target.js +54 -0
- package/dist/translations/target.js.map +1 -0
- package/dist/translations/xliff.d.ts +29 -0
- package/dist/translations/xliff.d.ts.map +1 -0
- package/dist/translations/xliff.js +62 -0
- package/dist/translations/xliff.js.map +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -34,11 +34,107 @@ The SDK (`ForumulateClient.fromEnv()`) and the MCP server ([`@forumulate/mcp`](h
|
|
|
34
34
|
## Quickstart
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
|
-
forumulate
|
|
38
|
-
forumulate
|
|
39
|
-
forumulate
|
|
37
|
+
forumulate config set org acme # the default for every --org
|
|
38
|
+
forumulate orgs list # id slug name
|
|
39
|
+
forumulate spaces list # the spaces in acme
|
|
40
|
+
forumulate items list --space docs # what is in a space, and where its content lives
|
|
41
|
+
forumulate api list --search webhook # every API operation, by summary
|
|
40
42
|
```
|
|
41
43
|
|
|
44
|
+
## Resource commands
|
|
45
|
+
|
|
46
|
+
Every group takes the same verbs (`list`, `get`, `create`, `update`, `delete`, and `publish` where a thing has a draft), the same scope flags (`--org`, `--space`, `--library`, each an id or a slug), and `--json` for the API's answer untouched. `forumulate <group> --help` lists a group's verbs and the operation each one calls.
|
|
47
|
+
|
|
48
|
+
| Group | Verbs |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `orgs list\|get\|create\|update\|delete`, `orgs deepl status\|set\|clear`, `orgs strings list\|set\|remove` | Your organizations, their DeepL key, and their own wording for interface strings. |
|
|
51
|
+
| `members list\|update\|remove\|sign-out\|reassign` | People in an org. |
|
|
52
|
+
| `invites list\|create\|bulk\|revoke\|pending\|accept\|redeem\|join`, `invites links list\|create\|revoke` | Invitations you send (one, many, or a shareable link) and the ones waiting for you. |
|
|
53
|
+
| `groups …`, `roles …`, `service-accounts` / `bots` `… tokens list\|create\|revoke` | Groups and join requests, custom roles, and non-human members with their tokens. |
|
|
54
|
+
| `tokens` / `pats` `list\|scopes\|create\|rotate\|rename\|revoke` | Your personal access tokens, by id or by name. |
|
|
55
|
+
| `webhooks list\|events\|create\|update\|delete\|test\|rotate-secret\|deliveries\|replay` | Endpoints, their deliveries, and replays. |
|
|
56
|
+
| `extensions …`, `audit list\|actions\|export` | Installed extensions and the marketplace; the audit log (export as CSV). |
|
|
57
|
+
| `spaces list\|overview\|get\|create\|update\|delete\|restore\|purge\|duplicate\|move\|rename\|access\|preview`, `spaces slugs list\|forget` | Spaces in an org: slugs, moves, copies and the trash. |
|
|
58
|
+
| `snapshots list\|create\|restore\|delete`, `shape get\|set\|patch\|preset\|kinds …` | Space snapshots, and a space's shape override. |
|
|
59
|
+
| `items` / `pages` `list\|get\|content\|create\|update\|write\|section\|fields\|chunks\|verify\|publish\|delete` | Any piece in a space. `--file page.md` fills the body; front matter sets `title` and `slug`. |
|
|
60
|
+
| `docs list\|get\|save\|publish\|unpublish\|history\|diff\|rollback\|move\|duplicate\|…`, `docs schedule get\|set\|cancel`, `docs checkpoints …`, `docs trash …`, `docs import zip\|docx\|url\|files`, `docs locales …`, `docs search` | A docs space's pages: drafts, revisions, scheduled publishing, rollback, the trash, imports and languages. |
|
|
61
|
+
| `collections …`, `versions list\|create\|update\|default\|delete\|settings\|configure` | Collections and their page order; docs versions. |
|
|
62
|
+
| `change-requests` / `crs` `list\|open\|review\|approve\|merge\|close\|rebase\|comment\|…`, `crs reviewers …`, `crs rules get\|set` | Proposed docs changes, review and merge rules. |
|
|
63
|
+
| `openapi list\|register\|resync\|lint\|import\|generate\|…`, `openapi sdk languages\|get\|download` | OpenAPI specs behind reference pages, and the SDKs generated from them. |
|
|
64
|
+
| `sdks packages\|register\|publish\|publishes`, `sdks registries list\|set\|test\|remove` | Publishing those SDKs to package registries. |
|
|
65
|
+
| `blog`, `forum`, `changelog` `list\|get\|create\|update\|publish\|delete\|…` | Articles, topics and releases; scheduling, pinning, settings, flags, polls, replies. `create --file post.md --publish`. |
|
|
66
|
+
| `blog` / `forum` / `changelog` / `status` `translations list\|get\|put\|remove\|auto` | One piece's translations at its own door. `translations` (below) is the whole-space workflow. |
|
|
67
|
+
| `roadmap board\|get\|submit\|update\|status\|vote\|comment\|merge\|proxy-votes …` | A roadmap space. |
|
|
68
|
+
| `status board`, `status incidents …`, `status components …`, `status channels …`, `status groups get\|set` | A status space: incidents, components, where they are announced. |
|
|
69
|
+
| `events …`, `course outline\|enrol\|complete`, `careers …`, `forms …` | Events and RSVPs, course progress, job applications, forms and submissions (CSV export). |
|
|
70
|
+
| `libraries list\|get\|create\|update\|delete`, `libraries members\|locales\|model\|keys …` | Headless CMS libraries: grants, languages, the model, delivery keys. |
|
|
71
|
+
| `entries list\|types\|get\|create\|update\|fields\|patch\|publish\|bulk\|trash\|restore\|lock …\|locale get\|set` | A library's entries. |
|
|
72
|
+
| `media …`, `releases list\|create\|add\|schedule\|publish\|rollback\|…`, `environments` / `envs list\|fork\|compare\|promote` | Library media, content releases, and sandbox environments. |
|
|
73
|
+
| `domains list\|add\|setup\|verify\|activate\|www\|allow-ips\|redirect\|remove\|…`, `assets list\|all\|upload\|download\|delete` | Custom domains on a space (by id or hostname), and its uploaded files. |
|
|
74
|
+
| `theme get\|set\|patch\|export\|import`, `theme draft get\|set\|patch\|apply\|discard\|publish` | A space's theme: kept in git with `export`/`import`, staged as a draft, then published. |
|
|
75
|
+
| `sites …`, `sites domains …`, `sites theme export\|import`, `sites draft …` | Sites: several spaces under one domain and theme. |
|
|
76
|
+
| `github status\|connect\|import\|export\|pull-request` | Sync a docs space with a repository. |
|
|
77
|
+
| `reader page\|markdown\|pdf\|version`, `reader blog index\|article\|rss\|json-feed\|…` | What a reader is served, as the public API answers it (`--out` for a PDF or feed). |
|
|
78
|
+
| `space-types list\|get\|presets\|slots` | What each kind of space is. |
|
|
79
|
+
| `search <query…>`, `search semantic\|recent\|tags\|tag\|gaps\|reindex` | Unified search across docs, forum and blog, and the searches that found nothing. |
|
|
80
|
+
|
|
81
|
+
Flags are derived from the API itself: every query parameter of the operation (`--limit`, `--state`) and every top-level body field (`--name`, `--visibility`) is a flag, and `--data`/`--field` work as they do under `forumulate api`. A Markdown file with front matter fills an item, post, topic or release: `title` and `slug` come from the front matter unless you pass them.
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
forumulate spaces create Guides --slug guides --type DOCS --visibility PUBLIC
|
|
85
|
+
forumulate items create --space guides --file getting-started.md --publish
|
|
86
|
+
forumulate webhooks create https://hooks.example.com/f --events page.published,post.created
|
|
87
|
+
forumulate webhooks deliveries <webhookId> && forumulate webhooks replay <webhookId> <deliveryId>
|
|
88
|
+
forumulate tokens rotate ci-deploy --graceMinutes 60
|
|
89
|
+
forumulate status incidents create "API latency" --space status --severity minor
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`delete`, `remove` and `revoke` ask first; `--yes` skips the question, and with no terminal (CI) `--yes` is required. `--dry-run` prints the request instead of sending it. A command whose answer is a file (an SDK archive, a PDF, a CSV export) writes it to `--out <file>`, and one that uploads (`assets upload`, `media upload`, `docs import zip`) takes the local path as its argument.
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
forumulate docs schedule set <pageId> 2026-11-01T09:00:00Z --space guides
|
|
96
|
+
forumulate docs rollback <pageId> <revisionId> --mode draft --space guides
|
|
97
|
+
forumulate crs open "Rate limits rewrite" --space guides && forumulate crs merge <crId> --space guides
|
|
98
|
+
forumulate openapi resync <specId> --space reference --background true
|
|
99
|
+
forumulate releases create "Spring launch" && forumulate releases schedule <releaseId> 2026-03-01T08:00:00Z
|
|
100
|
+
forumulate theme export --space docs --json > theme.json && forumulate theme import --space docs --data @theme.json
|
|
101
|
+
forumulate blog translations auto <postId> es --space blog
|
|
102
|
+
forumulate audit export --from 2026-10-01 --out audit.csv
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## `forumulate api`: every operation
|
|
106
|
+
|
|
107
|
+
The resource commands cover the daily work. `forumulate api` covers the rest — every operation in the API, from a copy of the OpenAPI document bundled with the CLI.
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
forumulate api list --tag Webhook # operationId, method, path, summary
|
|
111
|
+
forumulate api describe Space_create # parameters as flags, the body as fields
|
|
112
|
+
forumulate api Space_list acme --limit 20 # path params positionally…
|
|
113
|
+
forumulate api Space_get --orgId acme --spaceId <id> # …or by name (--org-id works too)
|
|
114
|
+
forumulate api GET /orgs/{orgId}/members --paginate --json
|
|
115
|
+
forumulate api POST /orgs/acme/spaces --data @space.json
|
|
116
|
+
cat body.json | forumulate api Item_putContent acme <spaceId> <itemId> --data -
|
|
117
|
+
forumulate api Space_update acme <spaceId> --field settings.overview="Start here"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- **Parameters**: `--<name> value` for path, query and header parameters; a repeated flag is joined with commas (how every array parameter here is spelled). Path parameters may be positional, in path order; `orgId` defaults to `--org`, `FORUMULATE_ORG`, then `forumulate config`. `-p name=value` sets one whose name collides with a CLI flag.
|
|
121
|
+
- **Body**: `--data '{…}'`, `--data @file.json` or `--data -` (stdin), then `--field a.b=value` (typed by the body schema; `a:=<json>` for raw JSON), then any `--<field>` the body declares. Multipart operations take `--form name=value` and `--form file=@path`.
|
|
122
|
+
- **Output**: a list prints as a table with a footer saying whether there is more (`--cursor <next>`), a single resource as `key value` lines; `--json` prints the body as received; `--paginate` follows `page.nextCursor` to the end and prints one merged list; `--columns a,b` picks table columns; `-i` adds the status and headers.
|
|
123
|
+
- **Transport**: `Forumulate-Version: 2026-12-01` on every request (`--api-version` or `forumulate config set api-version` to pin another), an `Idempotency-Key` on every write that declares one (the same key on a retry), and retries for a 429 (honouring `Retry-After`) and for a 502/503/504 on a request that is safe to repeat.
|
|
124
|
+
- **Exit status** is 0 on a 2xx and 1 on anything else, including a usage error, so it works in a pipeline.
|
|
125
|
+
|
|
126
|
+
A route newer than your copy of the CLI still works as `forumulate api <METHOD> <path>`; it is sent as written.
|
|
127
|
+
|
|
128
|
+
## Configuration and completion
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
forumulate config set org acme # also: space, library, api-version
|
|
132
|
+
forumulate config list # value and where it came from
|
|
133
|
+
eval "$(forumulate completion zsh)" # or bash; fish: forumulate completion fish > ~/.config/fish/completions/forumulate.fish
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
A flag beats the environment (`FORUMULATE_ORG`, `FORUMULATE_SPACE`, `FORUMULATE_LIBRARY`, `FORUMULATE_API_VERSION`), and the environment beats `~/.config/forumulate/config.json`. Completion covers commands, verbs, operationIds and each operation's flags.
|
|
137
|
+
|
|
42
138
|
## Common tasks
|
|
43
139
|
|
|
44
140
|
**1. Publish a folder of Markdown (docs-as-code).** One folder per collection, nested folders as parent pages, front matter for title, slug, description, icon, tags, order and any other page field, images uploaded, links rewritten. Blog and changelog folders become posts. Re-runs change only what changed; `--prune` removes what the folder no longer has; the space is read back afterwards. An optional `forumulate.yaml` sets the space's settings and theme, the site, an OpenAPI reference and status monitors. See [Publish a folder of Markdown from git](https://forumulate.com/guides/publish-from-git) and `examples/publish-docs.yml` for GitHub Actions.
|
|
@@ -58,7 +154,7 @@ forumulate publish acme <spaceId> <pageId>
|
|
|
58
154
|
**3. Search docs, forum and blog together.**
|
|
59
155
|
|
|
60
156
|
```sh
|
|
61
|
-
forumulate search acme rate limits
|
|
157
|
+
forumulate search rate limits --org acme # or, older form: forumulate search acme rate limits
|
|
62
158
|
```
|
|
63
159
|
|
|
64
160
|
**4. Snapshot a space before a big change.**
|
|
@@ -74,7 +170,19 @@ forumulate domains acme <spaceId> # each domain and its
|
|
|
74
170
|
forumulate domains verify acme <spaceId> docs.acme.dev # re-check, and print the DNS still missing
|
|
75
171
|
```
|
|
76
172
|
|
|
77
|
-
|
|
173
|
+
**6. Manage translations.** Use `forumulate translations`, or its alias `forumulate i18n`. It covers every translation capability: a space's or library's languages, coverage, a file round trip, machine translation with your own key, chrome labels, interface overrides, names and the switcher. See [Translations everywhere](https://forumulate.com/guides/translations-everywhere).
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
forumulate translations locales set es=Español fr --space docs # declare exactly these
|
|
177
|
+
forumulate translations status --space docs --fail-on missing,outdated # CI gate (exit 1)
|
|
178
|
+
forumulate translations pull --space docs --include-missing # translations/<locale>/<slug>.md
|
|
179
|
+
forumulate translations push --space docs --dry-run # the diff; drop --dry-run to apply
|
|
180
|
+
forumulate translations auto --space docs --locale es # your DeepL key; missing + outdated
|
|
181
|
+
forumulate translations labels pull --space docs --format xliff # for your TMS
|
|
182
|
+
forumulate translations overrides push overrides.json --prune
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Add `--json` to any command for raw JSON, `--version` for the version, and `forumulate help` for the full list. Every command exits non-zero on failure, so it works in a pipeline. The older positional forms — `spaces <orgId>`, `items <orgId> <spaceId>`, `search <orgId> <query…>`, `domains [verify] <orgId> <spaceId>` — still work and print exactly what they did.
|
|
78
186
|
|
|
79
187
|
### In CI
|
|
80
188
|
|
|
@@ -83,6 +191,9 @@ Add `--json` to any command for raw JSON, `--version` for the version, and `foru
|
|
|
83
191
|
- run: npx -y @forumulate/cli publish acme ${{ vars.DOCS_SPACE_ID }} ./docs
|
|
84
192
|
env:
|
|
85
193
|
FORUMULATE_TOKEN: ${{ secrets.FORUMULATE_TOKEN }}
|
|
194
|
+
- run: npx -y @forumulate/cli translations status --org acme --space docs --fail-on missing,outdated
|
|
195
|
+
env:
|
|
196
|
+
FORUMULATE_TOKEN: ${{ secrets.FORUMULATE_TOKEN }}
|
|
86
197
|
```
|
|
87
198
|
|
|
88
199
|
## `forumulate conformance`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument parsing for `forumulate api` and the resource commands.
|
|
3
|
+
*
|
|
4
|
+
* The older commands parse against a fixed list of value flags. These cannot:
|
|
5
|
+
* `forumulate api` takes a flag per API parameter, and there are a thousand of
|
|
6
|
+
* them. So the rule is inverted — every `--flag` takes the next token as its
|
|
7
|
+
* value unless it is a known switch, the next token is itself a flag, or the
|
|
8
|
+
* flag is written `--flag=value`. `--no-x` is `x=false`.
|
|
9
|
+
*/
|
|
10
|
+
export interface Parsed {
|
|
11
|
+
positionals: string[];
|
|
12
|
+
/** Every value given for a flag, in order (a flag may repeat). */
|
|
13
|
+
flags: Map<string, string[]>;
|
|
14
|
+
}
|
|
15
|
+
/** Flags that never take a value. */
|
|
16
|
+
export declare const SWITCHES: Set<string>;
|
|
17
|
+
export declare function parseArgs(argv: string[], switches?: Set<string>): Parsed;
|
|
18
|
+
export declare const flag: (p: Parsed, name: string) => string | undefined;
|
|
19
|
+
export declare const has: (p: Parsed, name: string) => boolean;
|
|
20
|
+
export declare const all: (p: Parsed, name: string) => string[];
|
|
21
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/api/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kEAAkE;IAClE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9B;AAED,qCAAqC;AACrC,eAAO,MAAM,QAAQ,aAanB,CAAC;AAYH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,GAAG,CAAC,MAAM,CAAY,GAAG,MAAM,CAsClF;AAED,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAAsC,CAAC;AAC/F,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,KAAG,OAG7C,CAAC;AACF,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,EAA6B,CAAC"}
|
package/dist/api/args.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.all = exports.has = exports.flag = exports.SWITCHES = void 0;
|
|
4
|
+
exports.parseArgs = parseArgs;
|
|
5
|
+
/** Flags that never take a value. */
|
|
6
|
+
exports.SWITCHES = new Set([
|
|
7
|
+
'json',
|
|
8
|
+
'paginate',
|
|
9
|
+
'yes',
|
|
10
|
+
'y',
|
|
11
|
+
'help',
|
|
12
|
+
'h',
|
|
13
|
+
'dry-run',
|
|
14
|
+
'verbose',
|
|
15
|
+
'include-headers',
|
|
16
|
+
'publish',
|
|
17
|
+
'all',
|
|
18
|
+
'force',
|
|
19
|
+
]);
|
|
20
|
+
const SHORT = {
|
|
21
|
+
f: 'field',
|
|
22
|
+
H: 'header',
|
|
23
|
+
d: 'data',
|
|
24
|
+
p: 'param',
|
|
25
|
+
y: 'yes',
|
|
26
|
+
h: 'help',
|
|
27
|
+
i: 'include-headers',
|
|
28
|
+
};
|
|
29
|
+
function parseArgs(argv, switches = exports.SWITCHES) {
|
|
30
|
+
const positionals = [];
|
|
31
|
+
const flags = new Map();
|
|
32
|
+
const add = (k, v) => flags.set(k, [...(flags.get(k) ?? []), v]);
|
|
33
|
+
for (let i = 0; i < argv.length; i++) {
|
|
34
|
+
const a = argv[i];
|
|
35
|
+
if (a === '--') {
|
|
36
|
+
positionals.push(...argv.slice(i + 1));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
let name;
|
|
40
|
+
if (a.startsWith('--') && a.length > 2)
|
|
41
|
+
name = a.slice(2);
|
|
42
|
+
else if (/^-[a-zA-Z]$/.test(a))
|
|
43
|
+
name = SHORT[a.slice(1)] ?? a.slice(1);
|
|
44
|
+
if (name === undefined) {
|
|
45
|
+
positionals.push(a);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const eq = name.indexOf('=');
|
|
49
|
+
if (eq > 0) {
|
|
50
|
+
add(name.slice(0, eq), name.slice(eq + 1));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (switches.has(name)) {
|
|
54
|
+
add(name, 'true');
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (name.startsWith('no-')) {
|
|
58
|
+
add(name.slice(3), 'false');
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const next = argv[i + 1];
|
|
62
|
+
// `--data -` is stdin, so a lone dash is a value, not a flag.
|
|
63
|
+
if (next !== undefined && (next === '-' || !next.startsWith('-') || /^-\d/.test(next))) {
|
|
64
|
+
add(name, next);
|
|
65
|
+
i++;
|
|
66
|
+
}
|
|
67
|
+
else
|
|
68
|
+
add(name, 'true');
|
|
69
|
+
}
|
|
70
|
+
return { positionals, flags };
|
|
71
|
+
}
|
|
72
|
+
const flag = (p, name) => p.flags.get(name)?.at(-1);
|
|
73
|
+
exports.flag = flag;
|
|
74
|
+
const has = (p, name) => {
|
|
75
|
+
const v = (0, exports.flag)(p, name);
|
|
76
|
+
return v !== undefined && v !== 'false';
|
|
77
|
+
};
|
|
78
|
+
exports.has = has;
|
|
79
|
+
const all = (p, name) => p.flags.get(name) ?? [];
|
|
80
|
+
exports.all = all;
|
|
81
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/api/args.ts"],"names":[],"mappings":";;;AAyCA,8BAsCC;AAhED,qCAAqC;AACxB,QAAA,QAAQ,GAAG,IAAI,GAAG,CAAC;IAC9B,MAAM;IACN,UAAU;IACV,KAAK;IACL,GAAG;IACH,MAAM;IACN,GAAG;IACH,SAAS;IACT,SAAS;IACT,iBAAiB;IACjB,SAAS;IACT,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,KAAK,GAA2B;IACpC,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,iBAAiB;CACrB,CAAC;AAEF,SAAgB,SAAS,CAAC,IAAc,EAAE,WAAwB,gBAAQ;IACxE,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC1C,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACnB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACf,WA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AI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACvF,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAChB,CAAC,EAAE,CAAC;QACN,CAAC;;YAAM,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC;AAEM,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,IAAY,EAAsB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAAlF,QAAA,IAAI,QAA8E;AACxF,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,IAAY,EAAW,EAAE;IACtD,MAAM,CAAC,GAAG,IAAA,YAAI,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACxB,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,OAAO,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,GAAG,OAGd;AACK,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,IAAY,EAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAArE,QAAA,GAAG,OAAkE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommandDeps } from '../commands/context';
|
|
2
|
+
/**
|
|
3
|
+
* `forumulate api` — every operation in the API, from the bundled spec.
|
|
4
|
+
*
|
|
5
|
+
* forumulate api list [--tag Space] [--search webhook]
|
|
6
|
+
* forumulate api describe Space_create
|
|
7
|
+
* forumulate api Space_list acme --limit 20
|
|
8
|
+
* forumulate api GET /orgs/{orgId}/spaces acme --paginate
|
|
9
|
+
* forumulate api POST /orgs/acme/spaces --data @space.json
|
|
10
|
+
*
|
|
11
|
+
* The resource commands (`spaces`, `webhooks`, …) cover what people do daily;
|
|
12
|
+
* this covers everything else, so a route that ships today is callable today
|
|
13
|
+
* with no CLI release — `operations.test.ts` walks the spec to keep it so.
|
|
14
|
+
*/
|
|
15
|
+
export declare const API_HELP = "forumulate api \u2014 call any operation in the Forumulate API\n\nUsage:\n forumulate api list [--tag <tag>] [--search <words>] [--method GET]\n forumulate api describe <operationId | METHOD path> [--json]\n forumulate api <operationId> [path params\u2026] [flags]\n forumulate api <METHOD> <path> [path params\u2026] [flags]\n\nParameters:\n --<name> <value> a path, query or header parameter (--orgId, --org-id)\n -p, --param name=value the same, for a name that collides with a flag below\n path params may also be given positionally, in path order; orgId defaults\n to --org / FORUMULATE_ORG / `forumulate config set org \u2026`\n\nBody:\n -d, --data '{\u2026}' | @file.json | - JSON body (- reads stdin)\n -f, --field a.b=value one field, typed by the body schema (a:=<json> raw)\n --<field> <value> a top-level body field the operation declares\n --form name=value | name=@file multipart operations (uploads)\n\nOutput and transport:\n --json the response body, untouched\n --paginate follow page.nextCursor to the end (one merged list)\n --max-pages <n> stop after n pages (default 1000)\n --columns a,b,c table columns for a list answer\n -i, --include-headers print the status line and response headers\n -H, --header 'Name: v' an extra request header\n --api-version <date> Forumulate-Version to send (default 2026-12-01)\n --idempotency-key <k> instead of the generated one\n --dry-run print the request, send nothing\n\nExit status is 0 on a 2xx and 1 otherwise (usage errors included).";
|
|
16
|
+
export declare function runApi(argv: string[], deps: CommandDeps): Promise<number>;
|
|
17
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/api/command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,+kDA+B8C,CAAC;AAIpE,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC/E"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_HELP = void 0;
|
|
4
|
+
exports.runApi = runApi;
|
|
5
|
+
const args_1 = require("./args");
|
|
6
|
+
const describe_1 = require("./describe");
|
|
7
|
+
const output_1 = require("./output");
|
|
8
|
+
const send_1 = require("./send");
|
|
9
|
+
const spec_1 = require("./spec");
|
|
10
|
+
const request_1 = require("./request");
|
|
11
|
+
/**
|
|
12
|
+
* `forumulate api` — every operation in the API, from the bundled spec.
|
|
13
|
+
*
|
|
14
|
+
* forumulate api list [--tag Space] [--search webhook]
|
|
15
|
+
* forumulate api describe Space_create
|
|
16
|
+
* forumulate api Space_list acme --limit 20
|
|
17
|
+
* forumulate api GET /orgs/{orgId}/spaces acme --paginate
|
|
18
|
+
* forumulate api POST /orgs/acme/spaces --data @space.json
|
|
19
|
+
*
|
|
20
|
+
* The resource commands (`spaces`, `webhooks`, …) cover what people do daily;
|
|
21
|
+
* this covers everything else, so a route that ships today is callable today
|
|
22
|
+
* with no CLI release — `operations.test.ts` walks the spec to keep it so.
|
|
23
|
+
*/
|
|
24
|
+
exports.API_HELP = `forumulate api — call any operation in the Forumulate API
|
|
25
|
+
|
|
26
|
+
Usage:
|
|
27
|
+
forumulate api list [--tag <tag>] [--search <words>] [--method GET]
|
|
28
|
+
forumulate api describe <operationId | METHOD path> [--json]
|
|
29
|
+
forumulate api <operationId> [path params…] [flags]
|
|
30
|
+
forumulate api <METHOD> <path> [path params…] [flags]
|
|
31
|
+
|
|
32
|
+
Parameters:
|
|
33
|
+
--<name> <value> a path, query or header parameter (--orgId, --org-id)
|
|
34
|
+
-p, --param name=value the same, for a name that collides with a flag below
|
|
35
|
+
path params may also be given positionally, in path order; orgId defaults
|
|
36
|
+
to --org / FORUMULATE_ORG / \`forumulate config set org …\`
|
|
37
|
+
|
|
38
|
+
Body:
|
|
39
|
+
-d, --data '{…}' | @file.json | - JSON body (- reads stdin)
|
|
40
|
+
-f, --field a.b=value one field, typed by the body schema (a:=<json> raw)
|
|
41
|
+
--<field> <value> a top-level body field the operation declares
|
|
42
|
+
--form name=value | name=@file multipart operations (uploads)
|
|
43
|
+
|
|
44
|
+
Output and transport:
|
|
45
|
+
--json the response body, untouched
|
|
46
|
+
--paginate follow page.nextCursor to the end (one merged list)
|
|
47
|
+
--max-pages <n> stop after n pages (default 1000)
|
|
48
|
+
--columns a,b,c table columns for a list answer
|
|
49
|
+
-i, --include-headers print the status line and response headers
|
|
50
|
+
-H, --header 'Name: v' an extra request header
|
|
51
|
+
--api-version <date> Forumulate-Version to send (default 2026-12-01)
|
|
52
|
+
--idempotency-key <k> instead of the generated one
|
|
53
|
+
--dry-run print the request, send nothing
|
|
54
|
+
|
|
55
|
+
Exit status is 0 on a 2xx and 1 otherwise (usage errors included).`;
|
|
56
|
+
const API_SWITCHES = new Set(['json', 'paginate', 'include-headers', 'dry-run', 'help', 'verbose']);
|
|
57
|
+
async function runApi(argv, deps) {
|
|
58
|
+
const parsed = (0, args_1.parseArgs)(argv, API_SWITCHES);
|
|
59
|
+
const [first, ...rest] = parsed.positionals;
|
|
60
|
+
const json = (0, args_1.has)(parsed, 'json');
|
|
61
|
+
if (!first || first === 'help' || ((0, args_1.has)(parsed, 'help') && first !== 'describe')) {
|
|
62
|
+
deps.out(exports.API_HELP);
|
|
63
|
+
return first || (0, args_1.has)(parsed, 'help') ? 0 : 1;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
if (first === 'list' || first === 'ls')
|
|
67
|
+
return list(parsed, rest, deps, json);
|
|
68
|
+
if (first === 'describe') {
|
|
69
|
+
const target = resolveOp(rest);
|
|
70
|
+
if (!target)
|
|
71
|
+
return usage(deps, 'api describe <operationId | METHOD path>', rest.join(' '));
|
|
72
|
+
if (json)
|
|
73
|
+
deps.out(JSON.stringify({ ...target.op, b: undefined, body: target.op.b ? (0, describe_1.expand)(target.op.b) : undefined }, null, 2));
|
|
74
|
+
else
|
|
75
|
+
for (const l of (0, describe_1.describe)(target.op))
|
|
76
|
+
deps.out(l);
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
return await invoke(parsed, deps, json);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (e instanceof request_1.UsageError) {
|
|
83
|
+
deps.err(`Usage: ${e.message}`);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function usage(deps, form, got) {
|
|
90
|
+
if (got)
|
|
91
|
+
deps.err(`No operation matches "${got}". Try: forumulate api list --search <words>`);
|
|
92
|
+
deps.err(`Usage: forumulate ${form}`);
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
/** `Space_list` or `GET /orgs/{orgId}/spaces` or `GET /orgs/acme/spaces`. */
|
|
96
|
+
function resolveOp(words) {
|
|
97
|
+
const [a, b] = words;
|
|
98
|
+
if (!a)
|
|
99
|
+
return undefined;
|
|
100
|
+
if ((0, spec_1.isMethod)(a) && b?.startsWith('/')) {
|
|
101
|
+
const hit = (0, spec_1.findByPath)(a, b);
|
|
102
|
+
return hit && { ...hit, used: 2 };
|
|
103
|
+
}
|
|
104
|
+
const op = (0, spec_1.findById)(a);
|
|
105
|
+
return op && { op, values: {}, used: 1 };
|
|
106
|
+
}
|
|
107
|
+
function list(parsed, rest, deps, json) {
|
|
108
|
+
const ops = (0, spec_1.filterOps)({
|
|
109
|
+
tag: (0, args_1.flag)(parsed, 'tag'),
|
|
110
|
+
search: [(0, args_1.flag)(parsed, 'search'), ...rest].filter(Boolean).join(' ') || undefined,
|
|
111
|
+
method: (0, args_1.flag)(parsed, 'method'),
|
|
112
|
+
});
|
|
113
|
+
if (json) {
|
|
114
|
+
deps.out(JSON.stringify(ops.map((o) => ({ operationId: o.id, method: o.m, path: o.p, summary: o.s, tags: o.t })), null, 2));
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
if (ops.length === 0) {
|
|
118
|
+
deps.err('No operations match.');
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
for (const l of (0, output_1.table)(ops.map((o) => ({ operationId: o.id, method: o.m, path: o.p, summary: o.s ?? '' })), ['operationId', 'method', 'path', 'summary']))
|
|
122
|
+
deps.out(l);
|
|
123
|
+
deps.out(`-- ${ops.length} of ${(0, spec_1.loadIndex)().ops.length} operations`);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
async function invoke(parsed, deps, json) {
|
|
127
|
+
const words = parsed.positionals;
|
|
128
|
+
const target = resolveOp(words);
|
|
129
|
+
const src = {
|
|
130
|
+
readFile: deps.readFile,
|
|
131
|
+
readStdin: deps.readStdin,
|
|
132
|
+
defaultOrg: (0, args_1.flag)(parsed, 'org') ?? deps.defaultOrg,
|
|
133
|
+
};
|
|
134
|
+
let request;
|
|
135
|
+
let op;
|
|
136
|
+
if (target) {
|
|
137
|
+
op = target.op;
|
|
138
|
+
({ request } = await (0, request_1.planRequest)(op, parsed, words.slice(target.used), src, target.values));
|
|
139
|
+
}
|
|
140
|
+
else if ((0, spec_1.isMethod)(words[0]) && words[1]?.startsWith('/')) {
|
|
141
|
+
// A path the bundled spec does not know (a route newer than this CLI):
|
|
142
|
+
// send it as written, unknown flags as query parameters.
|
|
143
|
+
const query = {};
|
|
144
|
+
for (const [k, v] of parsed.flags)
|
|
145
|
+
if (!request_1.API_FLAGS.has(k))
|
|
146
|
+
query[k] = v.join(',');
|
|
147
|
+
const fake = {
|
|
148
|
+
id: `${words[0].toUpperCase()} ${words[1]}`,
|
|
149
|
+
m: words[0].toUpperCase(),
|
|
150
|
+
p: words[1].split('?')[0],
|
|
151
|
+
b: {},
|
|
152
|
+
};
|
|
153
|
+
const withQuery = {
|
|
154
|
+
...parsed,
|
|
155
|
+
flags: new Map([...parsed.flags].filter(([k]) => request_1.API_FLAGS.has(k))),
|
|
156
|
+
};
|
|
157
|
+
({ request } = await (0, request_1.planRequest)(fake, withQuery, words.slice(2), src));
|
|
158
|
+
request.query = {
|
|
159
|
+
...Object.fromEntries(new URLSearchParams(words[1].split('?')[1] ?? '')),
|
|
160
|
+
...query,
|
|
161
|
+
};
|
|
162
|
+
deps.err(`note: ${request.method} ${fake.p} is not in this CLI's bundled spec; sending it as written.`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return usage(deps, 'api <operationId | METHOD path> [flags]', words.join(' '));
|
|
166
|
+
}
|
|
167
|
+
const http = deps.http;
|
|
168
|
+
if ((0, args_1.has)(parsed, 'dry-run') && !op?.q?.some((p) => p.n === 'dryRun')) {
|
|
169
|
+
(0, send_1.printRequest)(http, request, deps);
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
await (0, send_1.sendAndPrint)(http, request, {
|
|
173
|
+
json,
|
|
174
|
+
paginate: (0, args_1.has)(parsed, 'paginate'),
|
|
175
|
+
maxPages: Number((0, args_1.flag)(parsed, 'max-pages') ?? 1000),
|
|
176
|
+
columns: columns(parsed),
|
|
177
|
+
includeHeaders: (0, args_1.has)(parsed, 'include-headers'),
|
|
178
|
+
}, deps);
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
const columns = (p) => (0, args_1.flag)(p, 'columns')?.split(',').filter(Boolean);
|
|
182
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/api/command.ts"],"names":[],"mappings":";;;AAyDA,wBAgCC;AAzFD,iCAA2D;AAC3D,yCAA8C;AAE9C,qCAAiC;AACjC,iCAAoD;AACpD,iCAA8F;AAC9F,uCAAoF;AAGpF;;;;;;;;;;;;GAYG;AACU,QAAA,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;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@@
|
|
|
1
|
+
import { type Operation, type SchemaNode } from './spec';
|
|
2
|
+
export declare function describe(op: Operation): string[];
|
|
3
|
+
/** The body schema as JSON, refs expanded a few levels — `describe --json`. */
|
|
4
|
+
export declare function expand(node: SchemaNode | undefined, depth?: number): unknown;
|
|
5
|
+
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/api/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAyD5F,wBAAgB,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CA0BhD;AAED,+EAA+E;AAC/E,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,SAAI,GAAG,OAAO,CAmBvE"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describe = describe;
|
|
4
|
+
exports.expand = expand;
|
|
5
|
+
const spec_1 = require("./spec");
|
|
6
|
+
/**
|
|
7
|
+
* `forumulate api describe <operationId>`: what to pass, in the CLI's own terms.
|
|
8
|
+
*
|
|
9
|
+
* Each parameter is printed as the flag that sets it, and the body as an
|
|
10
|
+
* indented field list with types, required marks and enums — enough to write
|
|
11
|
+
* `--field` flags or a `--data` file without opening the reference.
|
|
12
|
+
*/
|
|
13
|
+
/** An enum of 40 event names is a paragraph, not a type: show a few and say how many. */
|
|
14
|
+
function enumText(values) {
|
|
15
|
+
const shown = values
|
|
16
|
+
.slice(0, 8)
|
|
17
|
+
.map((v) => JSON.stringify(v))
|
|
18
|
+
.join('|');
|
|
19
|
+
return values.length > 8
|
|
20
|
+
? `${shown}|… (${values.length} values; describe --json lists all)`
|
|
21
|
+
: shown;
|
|
22
|
+
}
|
|
23
|
+
function typeOf(node, depth = 0) {
|
|
24
|
+
const n = (0, spec_1.resolveRef)(node);
|
|
25
|
+
if (!n)
|
|
26
|
+
return 'any';
|
|
27
|
+
if (n.c !== undefined)
|
|
28
|
+
return JSON.stringify(n.c);
|
|
29
|
+
if (n.e)
|
|
30
|
+
return enumText(n.e);
|
|
31
|
+
if (n.any)
|
|
32
|
+
return [...new Set(n.any.map((v) => typeOf(v, depth + 1)))].join(' | ');
|
|
33
|
+
if (n.t === 'array')
|
|
34
|
+
return `${typeOf(n.i, depth + 1)}[]`;
|
|
35
|
+
return (n.t ?? (n.p ? 'object' : 'any')) + (n.n ? '?' : '');
|
|
36
|
+
}
|
|
37
|
+
function fields(node, indent, depth, out) {
|
|
38
|
+
const n = (0, spec_1.resolveRef)(node);
|
|
39
|
+
if (!n || depth > 3)
|
|
40
|
+
return;
|
|
41
|
+
if (n.any) {
|
|
42
|
+
const objects = n.any.map((v) => (0, spec_1.resolveRef)(v)).filter((v) => v?.p);
|
|
43
|
+
if (objects.length > 1) {
|
|
44
|
+
objects.forEach((v, i) => {
|
|
45
|
+
out.push(`${indent}one of (${i + 1}/${objects.length})${v.d ? ` — ${v.d}` : ''}`);
|
|
46
|
+
fields(v, `${indent} `, depth + 1, out);
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (objects.length === 1)
|
|
51
|
+
return fields(objects[0], indent, depth, out);
|
|
52
|
+
}
|
|
53
|
+
for (const part of n.all ?? [])
|
|
54
|
+
fields(part, indent, depth + 1, out);
|
|
55
|
+
const required = new Set(n.r ?? []);
|
|
56
|
+
for (const [k, v] of Object.entries(n.p ?? {})) {
|
|
57
|
+
const child = (0, spec_1.resolveRef)(v);
|
|
58
|
+
out.push(`${indent}${k}${required.has(k) ? '*' : ''} ${typeOf(v)}${child?.d ? ` — ${child.d}` : ''}`);
|
|
59
|
+
const inner = child?.t === 'array' ? (0, spec_1.resolveRef)(child.i) : child;
|
|
60
|
+
if (inner?.p && depth < 2)
|
|
61
|
+
fields(inner, `${indent} `, depth + 1, out);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function describe(op) {
|
|
65
|
+
const out = [`${op.id} ${op.m} ${op.p}${op.dep ? ' (deprecated)' : ''}`];
|
|
66
|
+
if (op.s)
|
|
67
|
+
out.push(` ${op.s}`);
|
|
68
|
+
if (op.t?.length)
|
|
69
|
+
out.push(` tags: ${op.t.join(', ')}`);
|
|
70
|
+
const params = op.q ?? [];
|
|
71
|
+
const path = (0, spec_1.pathParams)(op);
|
|
72
|
+
out.push('', 'Usage:', ` forumulate api ${op.id}${path.map((p) => ` <${p}>`).join('')} [flags]`);
|
|
73
|
+
if (params.length) {
|
|
74
|
+
out.push('', 'Parameters:');
|
|
75
|
+
for (const p of params) {
|
|
76
|
+
const t = p.e ? enumText(p.e) : (p.t ?? 'string');
|
|
77
|
+
out.push(` --${p.n}${p.r ? '*' : ''} ${p.in} ${t}${p.d ? ` — ${p.d}` : ''}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (op.b) {
|
|
81
|
+
out.push('', `Body (${op.mp ? 'multipart/form-data: --form name=value | name=@file' : 'JSON: --data, --field, or --<field>'})${op.br ? ', required' : ''}:`);
|
|
82
|
+
fields(op.b, ' ', 0, out);
|
|
83
|
+
}
|
|
84
|
+
if (op.ik)
|
|
85
|
+
out.push('', 'Sends an Idempotency-Key (override with --idempotency-key).');
|
|
86
|
+
if (params.some((p) => p.n === 'cursor'))
|
|
87
|
+
out.push('Paged: --paginate follows page.nextCursor to the end.');
|
|
88
|
+
out.push('', '* required');
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
/** The body schema as JSON, refs expanded a few levels — `describe --json`. */
|
|
92
|
+
function expand(node, depth = 0) {
|
|
93
|
+
const n = (0, spec_1.resolveRef)(node, (0, spec_1.loadIndex)());
|
|
94
|
+
if (!n)
|
|
95
|
+
return {};
|
|
96
|
+
if (depth > 6)
|
|
97
|
+
return { type: n.t ?? 'object' };
|
|
98
|
+
const out = {};
|
|
99
|
+
if (n.t)
|
|
100
|
+
out.type = n.t;
|
|
101
|
+
if (n.d)
|
|
102
|
+
out.description = n.d;
|
|
103
|
+
if (n.e)
|
|
104
|
+
out.enum = n.e;
|
|
105
|
+
if (n.c !== undefined)
|
|
106
|
+
out.const = n.c;
|
|
107
|
+
if (n.n)
|
|
108
|
+
out.nullable = true;
|
|
109
|
+
if (n.r)
|
|
110
|
+
out.required = n.r;
|
|
111
|
+
if (n.p)
|
|
112
|
+
out.properties = Object.fromEntries(Object.entries(n.p).map(([k, v]) => [k, expand(v, depth + 1)]));
|
|
113
|
+
if (n.i)
|
|
114
|
+
out.items = expand(n.i, depth + 1);
|
|
115
|
+
if (n.any)
|
|
116
|
+
out.anyOf = n.any.map((v) => expand(v, depth + 1));
|
|
117
|
+
if (n.all)
|
|
118
|
+
out.allOf = n.all.map((v) => expand(v, depth + 1));
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/api/describe.ts"],"names":[],"mappings":";;AAyDA,4BA0BC;AAGD,wBAmBC;AAzGD,iCAA4F;AAE5F;;;;;;GAMG;AAEH,yFAAyF;AACzF,SAAS,QAAQ,CAAC,MAAiB;IACjC,MAAM,KAAK,GAAG,MAAM;SACjB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC7B,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC;QACtB,CAAC,CAAC,GAAG,KAAK,OAAO,MAAM,CAAC,MAAM,qCAAqC;QACnE,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED,SAAS,MAAM,CAAC,IAA4B,EAAE,KAAK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