@wirecat/cli-base 0.132.0 → 1.0.0-rc.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/CHANGELOG.md +120 -0
- package/README.md +7 -1
- package/dist/batch.d.ts +1 -0
- package/dist/batch.js +1 -0
- package/dist/codegen/graphql-fake.d.ts +1 -1
- package/dist/codegen/graphql-fake.js +1 -1
- package/dist/codegen/graphql.d.ts +1 -12
- package/dist/codegen/graphql.js +0 -44
- package/dist/codegen/index.d.ts +4 -3
- package/dist/codegen/index.js +2 -1
- package/dist/codegen/manifest.js +2 -2
- package/dist/codegen/model.d.ts +4 -1
- package/dist/codegen/pipeline.d.ts +5 -5
- package/dist/codegen/runtime.d.ts +9 -2
- package/dist/codegen/runtime.js +7 -1
- package/dist/codegen/selection.d.ts +13 -0
- package/dist/codegen/selection.js +44 -0
- package/dist/codegen/wp-json.d.ts +2 -2
- package/dist/commands/document.d.ts +3 -0
- package/dist/commands/document.js +3 -0
- package/dist/commands/page.d.ts +14 -2
- package/dist/commands/page.js +3 -0
- package/dist/completion/index.d.ts +5 -1
- package/dist/completion/index.js +5 -1
- package/dist/credentials.d.ts +2 -0
- package/dist/credentials.js +2 -0
- package/dist/dev/api-report.d.ts +24 -0
- package/dist/dev/api-report.js +345 -0
- package/dist/dev/main.js +9 -19
- package/dist/dev/next-version.d.ts +5 -1
- package/dist/dev/next-version.js +30 -2
- package/dist/dev/result-shape.d.ts +4 -0
- package/dist/dev/result-shape.js +4 -4
- package/dist/dev/wcat-lint.d.ts +4 -1
- package/dist/dev/wcat-lint.js +9 -2
- package/dist/executable.d.ts +2 -0
- package/dist/executable.js +2 -0
- package/dist/http/fetch.d.ts +1 -0
- package/dist/http/fetch.js +1 -0
- package/dist/http/hosts.d.ts +11 -2
- package/dist/http/hosts.js +11 -2
- package/dist/http/index.d.ts +10 -2
- package/dist/http/index.js +10 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/logging.d.ts +3 -0
- package/dist/logging.js +3 -0
- package/dist/mcp/index.d.ts +17 -3
- package/dist/mcp/index.js +12 -2
- package/dist/output-buffer.d.ts +3 -0
- package/dist/output-buffer.js +1 -0
- package/dist/query/dates.d.ts +6 -1
- package/dist/query/dates.js +6 -1
- package/dist/query/help.d.ts +1 -0
- package/dist/query/help.js +1 -0
- package/dist/query/registry.d.ts +6 -1
- package/dist/query/registry.js +6 -1
- package/dist/query/types.d.ts +1 -0
- package/dist/query/types.js +1 -0
- package/dist/release/fold.d.ts +5 -0
- package/dist/release/fold.js +10 -1
- package/dist/release/fragments.d.ts +5 -2
- package/dist/release/fragments.js +18 -15
- package/dist/release/level.js +17 -11
- package/dist/skill/index.d.ts +34 -5
- package/dist/skill/index.js +21 -3
- package/dist/standards/audit.d.ts +15 -1
- package/dist/standards/audit.js +12 -1
- package/dist/standards/effects.d.ts +2 -0
- package/dist/standards/effects.js +1 -0
- package/dist/standards/errors.d.ts +2 -0
- package/dist/standards/errors.js +2 -0
- package/dist/standards/fields.d.ts +3 -0
- package/dist/standards/fields.js +2 -0
- package/dist/standards/identifiers.d.ts +7 -1
- package/dist/standards/identifiers.js +6 -1
- package/dist/standards/lint.d.ts +48 -8
- package/dist/standards/lint.js +45 -8
- package/dist/standards/log.d.ts +15 -3
- package/dist/standards/log.js +15 -3
- package/dist/standards/monthly.d.ts +2 -0
- package/dist/standards/monthly.js +2 -0
- package/dist/standards/output.d.ts +8 -1
- package/dist/standards/output.js +7 -1
- package/dist/standards/registry.d.ts +6 -1
- package/dist/standards/registry.js +6 -1
- package/dist/standards/steps.d.ts +5 -1
- package/dist/standards/steps.js +5 -1
- package/dist/standards/vocabulary.d.ts +5 -1
- package/dist/standards/vocabulary.js +6 -1
- package/dist/testing/index.d.ts +1 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/sandbox.js +23 -4
- package/dist/update/index.d.ts +25 -4
- package/dist/update/index.js +24 -4
- package/dist/wcat/manifest.d.ts +11 -1
- package/dist/wcat/manifest.js +10 -1
- package/docs/standards/accounts.md +5 -4
- package/docs/standards/commands.md +5 -4
- package/docs/standards/docs.md +5 -2
- package/docs/standards/releases.md +37 -9
- package/docs/standards/security.md +3 -2
- package/docs/standards/toolchain.md +1 -1
- package/package.json +23 -5
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,126 @@ Versions before 0.8.0 are in the [git tags](https://github.com/WireCatLabs/cli-b
|
|
|
8
8
|
Every entry says what changed as a caller sees it, why, and what to watch for — the rules are
|
|
9
9
|
[`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog).
|
|
10
10
|
|
|
11
|
+
## 1.0.0-rc.1 — 25.11.2026
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`sprints` is a noun of the vocabulary:** a tracker team's time-boxed runs of work, such as Linear's cycles and
|
|
16
|
+
Jira's sprints. cli-core's tracker copies them and mounts `sprints list`, which the command lint refused as an
|
|
17
|
+
unknown resource.
|
|
18
|
+
- **`/codegen/runtime` exports `Binding`, `HttpBinding`, `RpcBinding` and `Confidence`.** A CLI that reads an
|
|
19
|
+
operation's binding or how far it is trusted no longer imports the experimental `/codegen` for the type.
|
|
20
|
+
|
|
21
|
+
### Changed — experimental
|
|
22
|
+
|
|
23
|
+
- **The generated manifest and definitions import their types from `@wirecat/cli-base/codegen/runtime`** when
|
|
24
|
+
`coreImport` is not given, not from `/codegen`. Every type they name is there, and `/codegen/runtime` is part of
|
|
25
|
+
the stable API, so a CLI no longer passes `coreImport` by hand. Regenerating changes that one import line.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- **WC-ACCT-12 no longer lists zm as a known gap:** zm 0.81.0 has `session list`, so it has all four session
|
|
30
|
+
commands, as most CLIs that sign in now do. The tg, max and wa gap now names cli-core's `messengerSessionCommands`,
|
|
31
|
+
which gives them the two commands they lack, and the drive gap says that its next release adds `session status`.
|
|
32
|
+
- **`bin/release` collects the `changes/` fragments and never renames a published section.** When npm already had
|
|
33
|
+
the version in `package.json` and only fragments had merged, it renamed that version's heading (`## 0.131.0` to
|
|
34
|
+
`## 0.132.0`), moved the published entries under the new number and left the fragments out (#706). Now a published
|
|
35
|
+
section keeps its heading: the new version takes the Unreleased section, or a new section the fragments fill, and
|
|
36
|
+
the release stops when there is neither. The fragments are collected into the version's section, which may raise
|
|
37
|
+
it to the level they need (an Added is a minor), as the CLIs' `bin/release` does. See
|
|
38
|
+
[RELEASING.md](docs/dev/RELEASING.md).
|
|
39
|
+
- **The shared Start release workflow agrees with `bin/release` on the `changes/` fragments.** When npm already had
|
|
40
|
+
the version in `package.json` and every entry was in `changes/` fragments, `release-start.yml` failed with
|
|
41
|
+
`CHANGELOG.md has no "## Unreleased" to raise …`. Now the new version gets a new section the fragments fill, and
|
|
42
|
+
the run stops only when there are no fragments and the Unreleased section is missing or empty. A
|
|
43
|
+
published `x.0.0` is followed by its next patch, raised only when the entries need more, so `1.0.0` with a fix
|
|
44
|
+
gives `1.0.1` instead of stopping at a major. Every file is checked before any is written, and `after-raise` runs
|
|
45
|
+
once, with the version that ships. The workflow needs cli-dev from cli-base 0.98.0 or later (#714).
|
|
46
|
+
- **On Linux the test sandbox starts in the runtime folder (`$XDG_RUNTIME_DIR`), which is in memory.** Every commit of
|
|
47
|
+
a store waits for `fsync`, and on a disk other jobs keep busy a CRM sync in a test took 14 s instead of 1.5 s, past
|
|
48
|
+
the 15 s test timeout, so a CLI's local release check failed three times in a row. With no runtime folder to write
|
|
49
|
+
to, the sandbox starts in the temporary folder as before.
|
|
50
|
+
|
|
51
|
+
## 1.0.0-rc.0 — 23.11.2026
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **Two changelog headings for libraries on their way to 1.0: "Changed — experimental" and "Deprecated".** Both need
|
|
56
|
+
a minor release. "Changed — may break callers" and "Removed" stay for the stable API and, from 1.0.0 on, need a
|
|
57
|
+
major. See [WC-REL-7](docs/standards/releases.md).
|
|
58
|
+
- **`bin/release --major`.** A version that raises the major over npm's latest now stops unless this flag is given.
|
|
59
|
+
- **`wirecat.stable` in `package.json` lists the stable entry points.** Semver covers them from 1.0.0 on. An entry
|
|
60
|
+
point not in the list is experimental as a whole, and so is a name tagged `@experimental` inside a stable one. The
|
|
61
|
+
list: `.`, `/http`, `/commands`, `/completion`, `/update`, `/codegen/runtime`, `/skill`, `/mcp`, `/query`,
|
|
62
|
+
`/standards`, `/standards/tables` (only the vocabulary), `/wcat/start` and `/wcat/manifest`. The
|
|
63
|
+
[README](README.md#install) says what that means for a caller. Inside them, 105 names are tagged `@experimental`:
|
|
64
|
+
names cli-core does not use and at most one other package imports, and the generated docs text (`commandsPage`,
|
|
65
|
+
`withVersion`, `skillFiles`). Among them: the lint and audit tables, the update check's internals (`mayNotify`,
|
|
66
|
+
`readUpdateState`), the Hermes skill helpers, `parseRetryAfter` and `createOutputBuffer`. An editor shows the tag on
|
|
67
|
+
hover.
|
|
68
|
+
- **`/codegen/runtime` also exports what a CLI reads the generated manifest with**: the types `ManifestOperation`,
|
|
69
|
+
`SchemaNode`, `ApiServer`, `SecurityScheme`, `SecurityRequirement`, `OAuthFlow`, `Pagination`, `PageParameter`,
|
|
70
|
+
`GraphqlBinding`, `OperationPermission`, `Effect`, `Selection` and `SignInPlace`, and `identifier`,
|
|
71
|
+
`graphqlDocument`, `parseSelection`, `signInPlace` and `signInRequirements`. They are stable there;
|
|
72
|
+
`/codegen`, which still exports them too, is experimental. Watch for: import them from `/codegen/runtime` in code
|
|
73
|
+
that runs, so a change to the generator cannot reach it.
|
|
74
|
+
- **`@wirecat/cli-base/package.json` can be imported or resolved.** `exports` blocked it, and some tools read it.
|
|
75
|
+
- **`cli-dev api-report`: the stable API as a committed text file.** A package lists its stable entry points in
|
|
76
|
+
`package.json` (`"wirecat": { "stable": [".", "./http"] }`), and the command writes `api/<entry>.api.txt` from the
|
|
77
|
+
built `.d.ts`, one line per declaration line, without the names whose TSDoc says `@experimental`. `--check` fails
|
|
78
|
+
when the committed report differs from the build. The shared `node-ci.yml` runs the check for every package that
|
|
79
|
+
lists `wirecat.stable` and skips the others. See [WC-REL-7](docs/standards/releases.md).
|
|
80
|
+
- **The changelog guard reads the API report.** A pull request that removes or changes a stable line needs an entry
|
|
81
|
+
under "Changed — may break callers" or "Removed", and one that only adds lines needs "Added". From 1.0.0 on, an
|
|
82
|
+
entry under either break heading also needs the `major` label. Watch for: a caller's own `changelog-guard.yml`
|
|
83
|
+
needs `labeled` and `unlabeled` in its `pull_request` types for a new label to re-run the guard.
|
|
84
|
+
- **`release-start.yml` collects the `changes/` fragments and takes the level they need**, as `bin/release` does, and
|
|
85
|
+
stops a version that raises the major unless the release starts with the new `major: true` input.
|
|
86
|
+
|
|
87
|
+
### Changed — may break callers
|
|
88
|
+
|
|
89
|
+
- **`cli-dev lint` no longer warns about a short `"bin"` name beside a `wcat-<name>` that runs the same file**, the
|
|
90
|
+
pair the template writes (`ydisk` and `wcat-ydisk`). A short name alone, or one that runs another file, still warns.
|
|
91
|
+
Watch for: an override in `lint/overrides.json` for such a pair is now stale, and `cli-dev lint` fails until it is
|
|
92
|
+
removed. asterisk-cli (`pbx`), beeline-cli and gcal-cli carry one; delete that entry when bumping cli-base. See
|
|
93
|
+
[WC-CMD-29](docs/standards/commands.md).
|
|
94
|
+
- **The version-level check reads 1.0.0 rules.** From 1.0.0 on, a stable break needs a major, an experimental change
|
|
95
|
+
a minor. A release candidate (`1.0.0-rc.1`) counts as its plain version and is never read as the release below.
|
|
96
|
+
- **The optional peers `commander` and `vitest` are now `^15.0.0` and `^5.0.0`** instead of open ranges: `./commands`
|
|
97
|
+
and `./skill` use commander internals that a new major may change.
|
|
98
|
+
- **`engines.node` is `^22.16.0 || >=24`**, as in cli-core and every CLI, instead of `>=22`. Node 22.0 to 22.15 and
|
|
99
|
+
Node 23 were never tested. See [WC-TOOL-6](docs/standards/toolchain.md).
|
|
100
|
+
|
|
101
|
+
### Changed — experimental
|
|
102
|
+
|
|
103
|
+
- **`/testing` no longer exports `brokenKeyring` and `captureStreams`.** Nothing imported them from there; import
|
|
104
|
+
them from the root, which keeps them stable. `memoryKeyring` stays in both.
|
|
105
|
+
- **Two `/codegen` names that clashed with names elsewhere are renamed.** `WriteOptions` (the options of
|
|
106
|
+
`writeArtifacts`) is `CodegenWriteOptions`, since the root's `WriteOptions` is the credential write. `Override`
|
|
107
|
+
is `ModelOverride`, since `/standards/tables` has a lint `Override`. An editor's auto-import picked the wrong one.
|
|
108
|
+
|
|
109
|
+
### Deprecated
|
|
110
|
+
|
|
111
|
+
- **`Override` from `/codegen`**, now an alias of `ModelOverride`. cli-template's kit and the scripts of max-cli,
|
|
112
|
+
tg-cli and wordpress-cli use it. It goes in the next major.
|
|
113
|
+
|
|
114
|
+
### Fixed
|
|
115
|
+
|
|
116
|
+
- **WC-SECR-26 no longer lists ydisk's docs as a known gap:** they say where the owner revokes the Yandex token
|
|
117
|
+
(Yandex ID's Data access), and the rule's example now shows `session end`'s help saying it.
|
|
118
|
+
- **`next-version` keeps a taken major a major**: with 2.0.0 on npm, `2.0.0` gives `3.0.0`, not `2.1.0`.
|
|
119
|
+
- **A pre-release is published under npm's `next` tag**, from `bin/release` and from the release workflow. npm refuses
|
|
120
|
+
a pre-release without a tag, and `latest` must stay a release.
|
|
121
|
+
- **A release that collects `changes/` fragments or folds Unreleased no longer leaves a blank line between entries.**
|
|
122
|
+
A blank line inside a fragment, or a `###` heading that appears twice in the dated section, used to split the list
|
|
123
|
+
in two (ydisk 0.3.0's Fixed) or leave two blank lines in a row. Each heading now gets one list, with one blank line
|
|
124
|
+
around the heading. A blank line inside an entry, before its indented second paragraph, stays.
|
|
125
|
+
|
|
126
|
+
### Removed
|
|
127
|
+
|
|
128
|
+
- **`abortError` and `retryOf` from the root export.** No package imports them; `realSleep` and the error record
|
|
129
|
+
still use them inside.
|
|
130
|
+
|
|
11
131
|
## 0.132.0 — 23.11.2026
|
|
12
132
|
|
|
13
133
|
### Added
|
package/README.md
CHANGED
|
@@ -35,9 +35,15 @@ it alone.
|
|
|
35
35
|
npm install @wirecat/cli-base
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
It is ESM only, for Node 22 and later, and runs on Bun. `import` it (`require()` works
|
|
38
|
+
It is ESM only, for Node 22.16 and later (not 23), and runs on Bun. `import` it (`require()` works). Add
|
|
39
39
|
`commander` if you use `/skill`, and `vitest` if you use `/testing/setup`.
|
|
40
40
|
|
|
41
|
+
**What semver covers.** The entry points listed under `wirecat.stable` in `package.json` are the stable API: from
|
|
42
|
+
1.0.0 on, a break there waits for a major and is deprecated first. A name inside one of them that carries the TSDoc
|
|
43
|
+
tag `@experimental` is not covered, and neither is any entry point missing from the list (`/codegen`, `/release`,
|
|
44
|
+
`/testing`, `/testing/setup`, `/wcat`, the config files) or the `cli-dev` commands. Those may change in a minor,
|
|
45
|
+
under the changelog heading "Changed — experimental" ([WC-REL-7](docs/standards/releases.md)).
|
|
46
|
+
|
|
41
47
|
[API reference](docs/REFERENCE.md) · [Architecture](docs/dev/ARCHITECTURE.md) · [Shared tooling](docs/TOOLING.md) ·
|
|
42
48
|
[Standards handbook](docs/standards/README.md) · [Changelog](CHANGELOG.md) · [wirecat.dev](https://wirecat.dev)
|
|
43
49
|
|
package/dist/batch.d.ts
CHANGED
|
@@ -56,4 +56,5 @@ export declare const runBatch: (requests: readonly PreparedBatchRequest[], optio
|
|
|
56
56
|
failureContext?: FailureContext;
|
|
57
57
|
fields?: readonly string[];
|
|
58
58
|
}) => Promise<BatchReport>;
|
|
59
|
+
/** @experimental */
|
|
59
60
|
export declare const projectBatchAnswers: (report: BatchReport, fields: readonly string[]) => BatchReport;
|
package/dist/batch.js
CHANGED
|
@@ -164,6 +164,7 @@ export const runBatch = async (requests, options = {}) => {
|
|
|
164
164
|
output_limited: outputLimited,
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
|
+
/** @experimental */
|
|
167
168
|
export const projectBatchAnswers = (report, fields) => ({
|
|
168
169
|
...report,
|
|
169
170
|
items: report.items.map((result) => result.status === "ok" ? { ...result, answer: projectFields(result.answer, fields) } : result),
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* field the type lacks, variables that break their schema and a missing sign-in, and answers `data.<field>` within
|
|
5
5
|
* the selection. A test writes only its scenarios; one that answers outside the schema or the selection throws.
|
|
6
6
|
*/
|
|
7
|
-
import { type Selection } from "./graphql.js";
|
|
8
7
|
import type { ManifestOperation } from "./manifest.js";
|
|
9
8
|
import type { SchemaNode } from "./model.js";
|
|
9
|
+
import { type Selection } from "./selection.js";
|
|
10
10
|
type Definitions = Readonly<Record<string, SchemaNode>>;
|
|
11
11
|
export interface GraphqlFakeCall {
|
|
12
12
|
/** The matched operation's id; absent when the request matched none. */
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* the selection. A test writes only its scenarios; one that answers outside the schema or the selection throws.
|
|
6
6
|
*/
|
|
7
7
|
import { sampleOf, schemaProblems } from "./fake.js";
|
|
8
|
-
import { graphqlDocument, parseSelection } from "./graphql.js";
|
|
9
8
|
import { identifier } from "./names.js";
|
|
9
|
+
import { graphqlDocument, parseSelection } from "./selection.js";
|
|
10
10
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
11
|
/** What a selection walks into, through references, lists and a nullable wrapper: an object, a union or a leaf. */
|
|
12
12
|
const shapeOf = (node, definitions, depth = 0) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiModel,
|
|
1
|
+
import type { ApiModel, SchemaNode } from "./model.js";
|
|
2
2
|
export interface GraphqlOptions {
|
|
3
3
|
/** The endpoint every operation is sent to: `https://api.linear.app/graphql`. */
|
|
4
4
|
url: string;
|
|
@@ -16,17 +16,6 @@ export interface GraphqlOptions {
|
|
|
16
16
|
sourceRevision?: string;
|
|
17
17
|
}
|
|
18
18
|
export declare const GRAPHQL_DELETE_REASON = "a mutation whose name ends in Delete or Archive deletes";
|
|
19
|
-
/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
|
|
20
|
-
export declare const graphqlDocument: (binding: GraphqlBinding, selection?: string) => string;
|
|
21
|
-
/** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */
|
|
22
|
-
export interface Selection {
|
|
23
|
-
readonly [field: string]: Selection | true;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
|
|
27
|
-
* throws, since nothing here can check one.
|
|
28
|
-
*/
|
|
29
|
-
export declare const parseSelection: (text: string) => Selection;
|
|
30
19
|
export declare const adaptGraphql: (introspection: unknown, options: GraphqlOptions) => ApiModel;
|
|
31
20
|
/** The standard introspection query, deep enough for `[[Type!]!]!`. */
|
|
32
21
|
export declare const INTROSPECTION_QUERY = "query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind name description\n fields(includeDeprecated: true) { name description isDeprecated args { ...InputValue } type { ...TypeRef } }\n inputFields { ...InputValue }\n enumValues(includeDeprecated: true) { name }\n possibleTypes { name }\n }\n }\n}\nfragment InputValue on __InputValue { name description defaultValue type { ...TypeRef } }\nfragment TypeRef on __Type {\n kind name\n ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } }\n}";
|
package/dist/codegen/graphql.js
CHANGED
|
@@ -30,50 +30,6 @@ const typeText = (ref) => ref.kind === "NON_NULL" && ref.ofType
|
|
|
30
30
|
? `[${typeText(ref.ofType)}]`
|
|
31
31
|
: String(ref.name);
|
|
32
32
|
const named = (ref) => (ref.ofType ? named(ref.ofType) : String(ref.name));
|
|
33
|
-
/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
|
|
34
|
-
export const graphqlDocument = (binding, selection = binding.selection) => {
|
|
35
|
-
const variables = Object.entries(binding.variables);
|
|
36
|
-
const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
|
|
37
|
-
const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
|
|
38
|
-
const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
|
|
39
|
-
return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
|
|
43
|
-
* throws, since nothing here can check one.
|
|
44
|
-
*/
|
|
45
|
-
export const parseSelection = (text) => {
|
|
46
|
-
const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [];
|
|
47
|
-
let at = 0;
|
|
48
|
-
const level = (nested) => {
|
|
49
|
-
const fields = {};
|
|
50
|
-
while (at < tokens.length) {
|
|
51
|
-
const token = tokens[at];
|
|
52
|
-
if (token === "}") {
|
|
53
|
-
if (!nested)
|
|
54
|
-
throw new Error(`selection "${text}": an unmatched }`);
|
|
55
|
-
at += 1;
|
|
56
|
-
return fields;
|
|
57
|
-
}
|
|
58
|
-
if (!/^[_A-Za-z]/.test(token))
|
|
59
|
-
throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`);
|
|
60
|
-
at += 1;
|
|
61
|
-
if (tokens[at] === "{") {
|
|
62
|
-
at += 1;
|
|
63
|
-
const inner = level(true);
|
|
64
|
-
if (Object.keys(inner).length === 0)
|
|
65
|
-
throw new Error(`selection "${text}": ${token} selects nothing`);
|
|
66
|
-
fields[token] = inner;
|
|
67
|
-
}
|
|
68
|
-
else
|
|
69
|
-
fields[token] = true;
|
|
70
|
-
}
|
|
71
|
-
if (nested)
|
|
72
|
-
throw new Error(`selection "${text}": a { is not closed`);
|
|
73
|
-
return fields;
|
|
74
|
-
};
|
|
75
|
-
return level(false);
|
|
76
|
-
};
|
|
77
33
|
const schemaOf = (raw) => {
|
|
78
34
|
const root = object(raw) && object(raw.data) ? raw.data : raw;
|
|
79
35
|
if (!object(root) || !object(root.__schema))
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -10,18 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { adaptDiscovery, type DiscoveryMetadata, type DiscoveryOptions, type DiscoveryProvenance, type DiscoveryResult, type DiscoveryService, readDiscovery, type SyncDiscoveryOptions, syncDiscovery, } from "./discovery.js";
|
|
12
12
|
export { type FakeAnswer, type FakeApi, type FakeApiOptions, type FakeCall, fakeApi, sampleOf, schemaProblems, } from "./fake.js";
|
|
13
|
-
export { adaptGraphql, GRAPHQL_DELETE_REASON, type GraphqlOptions, type GraphqlProvenance,
|
|
13
|
+
export { adaptGraphql, GRAPHQL_DELETE_REASON, type GraphqlOptions, type GraphqlProvenance, INTROSPECTION_QUERY, readGraphql, syncGraphql, } from "./graphql.js";
|
|
14
14
|
export { type GraphqlFake, type GraphqlFakeAnswer, type GraphqlFakeCall, type GraphqlFakeOptions, graphqlFake, selectionProblems, } from "./graphql-fake.js";
|
|
15
15
|
export { requestSchema } from "./json-schema.js";
|
|
16
16
|
export { type CoverageOptions, coverageGenerator, definitionsGenerator, examplesGenerator, type ManifestOperation, manifestGenerator, } from "./manifest.js";
|
|
17
17
|
export { type MergedSource, type MergeOptions, type MergeReport, mergeOpenApi, type SpecSource } from "./merge.js";
|
|
18
|
-
export type { ApiBody, ApiModel, ApiOperation, ApiParameter, ApiSchema, ApiServer, Binding, CodeGenerator, Confidence, Discriminator, Effect, GeneratedArtifact, GraphqlBinding, HttpBinding, HttpMethod, OAuthFlow, OperationPermission, Override, PageParameter, Pagination, RpcBinding, SchemaNode, SecurityRequirement, SecurityScheme, SourceInfo, SourceReference, } from "./model.js";
|
|
18
|
+
export type { ApiBody, ApiModel, ApiOperation, ApiParameter, ApiSchema, ApiServer, Binding, CodeGenerator, Confidence, Discriminator, Effect, GeneratedArtifact, GraphqlBinding, HttpBinding, HttpMethod, ModelOverride, OAuthFlow, OperationPermission, Override, PageParameter, Pagination, RpcBinding, SchemaNode, SecurityRequirement, SecurityScheme, SourceInfo, SourceReference, } from "./model.js";
|
|
19
19
|
export { apiCommandPath, bindingLabel, identifier, kebab } from "./names.js";
|
|
20
20
|
export { adaptOpenApi, OpenApiError } from "./openapi.js";
|
|
21
21
|
export { detectPagination } from "./pagination.js";
|
|
22
22
|
export { type PatchedSpec, type PatchSpecOptions, patchSpec, type SpecPatch } from "./patch.js";
|
|
23
|
-
export { type AuthOverride, applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, type CommandNames, type GenerateOptions, generate, type PermissionRule, READING_POST_REASON, validateModel,
|
|
23
|
+
export { type AuthOverride, applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, type CodegenWriteOptions, type CommandNames, type GenerateOptions, generate, type PermissionRule, READING_POST_REASON, validateModel, writeArtifacts, } from "./pipeline.js";
|
|
24
24
|
export { type PostmanOptions, type PostmanResult, postmanToOpenApi } from "./postman.js";
|
|
25
|
+
export { graphqlDocument, parseSelection, type Selection } from "./selection.js";
|
|
25
26
|
export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js";
|
|
26
27
|
export { API_SKILL_GROUPS, API_SKILL_INDEX, type ApiSkillOptions, apiSkillFiles } from "./skill.js";
|
|
27
28
|
export { upgradeToOpenApi3 } from "./swagger.js";
|
package/dist/codegen/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { adaptDiscovery, readDiscovery, syncDiscovery, } from "./discovery.js";
|
|
12
12
|
export { fakeApi, sampleOf, schemaProblems, } from "./fake.js";
|
|
13
|
-
export { adaptGraphql, GRAPHQL_DELETE_REASON,
|
|
13
|
+
export { adaptGraphql, GRAPHQL_DELETE_REASON, INTROSPECTION_QUERY, readGraphql, syncGraphql, } from "./graphql.js";
|
|
14
14
|
export { graphqlFake, selectionProblems, } from "./graphql-fake.js";
|
|
15
15
|
export { requestSchema } from "./json-schema.js";
|
|
16
16
|
export { coverageGenerator, definitionsGenerator, examplesGenerator, manifestGenerator, } from "./manifest.js";
|
|
@@ -21,6 +21,7 @@ export { detectPagination } from "./pagination.js";
|
|
|
21
21
|
export { patchSpec } from "./patch.js";
|
|
22
22
|
export { applyNames, applyOverrides, applyPagination, applyPermissionRule, CodegenError, generate, READING_POST_REASON, validateModel, writeArtifacts, } from "./pipeline.js";
|
|
23
23
|
export { postmanToOpenApi } from "./postman.js";
|
|
24
|
+
export { graphqlDocument, parseSelection } from "./selection.js";
|
|
24
25
|
export { signInPlace, signInRequirements } from "./sign-in.js";
|
|
25
26
|
export { API_SKILL_GROUPS, API_SKILL_INDEX, apiSkillFiles } from "./skill.js";
|
|
26
27
|
export { upgradeToOpenApi3 } from "./swagger.js";
|
package/dist/codegen/manifest.js
CHANGED
|
@@ -44,7 +44,7 @@ export const manifestGenerator = (options) => (model) => {
|
|
|
44
44
|
].filter(([, , , value]) => value !== undefined);
|
|
45
45
|
const types = ["ManifestOperation", ...extras.map(([, type]) => type)].sort();
|
|
46
46
|
const content = [
|
|
47
|
-
`import type { ${types.join(", ")} } from "${options.coreImport ?? "@wirecat/cli-base/codegen"}"`,
|
|
47
|
+
`import type { ${types.join(", ")} } from "${options.coreImport ?? "@wirecat/cli-base/codegen/runtime"}"`,
|
|
48
48
|
"",
|
|
49
49
|
`export const operations: readonly ManifestOperation[] = ${JSON.stringify(operations, null, 2)}`,
|
|
50
50
|
...extras.flatMap(([name, , type, value]) => [
|
|
@@ -61,7 +61,7 @@ export const definitionsGenerator = (options) => (model) => {
|
|
|
61
61
|
return [
|
|
62
62
|
{
|
|
63
63
|
path: options.path,
|
|
64
|
-
content: `import type { SchemaNode } from "${options.coreImport ?? "@wirecat/cli-base/codegen"}"\n\nexport const definitions: Readonly<Record<string, SchemaNode>> = ${JSON.stringify(definitions, null, 2)}\n`,
|
|
64
|
+
content: `import type { SchemaNode } from "${options.coreImport ?? "@wirecat/cli-base/codegen/runtime"}"\n\nexport const definitions: Readonly<Record<string, SchemaNode>> = ${JSON.stringify(definitions, null, 2)}\n`,
|
|
65
65
|
},
|
|
66
66
|
];
|
|
67
67
|
};
|
package/dist/codegen/model.d.ts
CHANGED
|
@@ -263,13 +263,16 @@ export interface ApiModel {
|
|
|
263
263
|
/** Set when `generate`'s `auth` replaced the source's sign-in: its reason, for the coverage page. */
|
|
264
264
|
securityReason?: string;
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
/** A correction to one operation of the model, keyed by its id in `generate`'s `overrides`. */
|
|
267
|
+
export interface ModelOverride {
|
|
267
268
|
effect?: Effect;
|
|
268
269
|
/** How the operation pages, where detection misses or misreads it; `null` says it does not page. */
|
|
269
270
|
pagination?: Pagination | null;
|
|
270
271
|
/** Required: an override nobody can explain is one nobody dares remove. */
|
|
271
272
|
reason: string;
|
|
272
273
|
}
|
|
274
|
+
/** @deprecated Use `ModelOverride`; the old name clashed with the lint `Override` of `/standards/tables`. */
|
|
275
|
+
export type Override = ModelOverride;
|
|
273
276
|
export interface GeneratedArtifact {
|
|
274
277
|
path: string;
|
|
275
278
|
content: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiModel, ApiOperation, CodeGenerator, GeneratedArtifact,
|
|
1
|
+
import type { ApiModel, ApiOperation, CodeGenerator, GeneratedArtifact, ModelOverride, Pagination, SecurityRequirement, SecurityScheme } from "./model.js";
|
|
2
2
|
export declare class CodegenError extends Error {
|
|
3
3
|
readonly problems: readonly string[];
|
|
4
4
|
constructor(problems: readonly string[]);
|
|
@@ -28,7 +28,7 @@ export declare const applyPagination: (model: ApiModel, overrides: Readonly<Reco
|
|
|
28
28
|
pagination?: Pagination | null;
|
|
29
29
|
reason: string;
|
|
30
30
|
}>>, detect: boolean) => ApiModel;
|
|
31
|
-
export declare const applyOverrides: (model: ApiModel, overrides: Readonly<Record<string,
|
|
31
|
+
export declare const applyOverrides: (model: ApiModel, overrides: Readonly<Record<string, ModelOverride>>) => ApiModel;
|
|
32
32
|
/**
|
|
33
33
|
* Which calls the CLI's own permission keys guard, so denying `files.delete` also holds over the raw `api` group:
|
|
34
34
|
* `<group>.delete` for every destructive operation and for every flag in `deletingFlags` an operation takes (cli-core
|
|
@@ -80,7 +80,7 @@ export interface AuthOverride {
|
|
|
80
80
|
/** Everything that would otherwise make an operation vanish or turn into a guess. */
|
|
81
81
|
export declare const validateModel: (model: ApiModel) => void;
|
|
82
82
|
export interface GenerateOptions {
|
|
83
|
-
overrides?: Readonly<Record<string,
|
|
83
|
+
overrides?: Readonly<Record<string, ModelOverride>>;
|
|
84
84
|
/** Treat a POST to a `…/search` or `…/query` path as a read; an override still wins. */
|
|
85
85
|
readingPosts?: boolean;
|
|
86
86
|
/** Detect how each read pages; an override's `pagination` wins either way. */
|
|
@@ -92,7 +92,7 @@ export interface GenerateOptions {
|
|
|
92
92
|
banner: readonly string[];
|
|
93
93
|
}
|
|
94
94
|
export declare const generate: (model: ApiModel, generators: readonly CodeGenerator[], options: GenerateOptions) => GeneratedArtifact[];
|
|
95
|
-
export interface
|
|
95
|
+
export interface CodegenWriteOptions {
|
|
96
96
|
root: string;
|
|
97
97
|
/** Compare only: report what is out of date and write nothing. */
|
|
98
98
|
check?: boolean;
|
|
@@ -105,4 +105,4 @@ export interface WriteOptions {
|
|
|
105
105
|
owns?: readonly string[];
|
|
106
106
|
}
|
|
107
107
|
/** Paths whose committed content differs from what was generated — written, or with `check`, only reported. */
|
|
108
|
-
export declare const writeArtifacts: (artifacts: readonly GeneratedArtifact[], options:
|
|
108
|
+
export declare const writeArtifacts: (artifacts: readonly GeneratedArtifact[], options: CodegenWriteOptions) => string[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What generated Valibot schemas call at run time. Kept apart from the generator so a CLI loads
|
|
3
|
-
* these few functions, not the code that writes code.
|
|
3
|
+
* these few functions, not the code that writes code. Also the stable part of the model a CLI reads the generated
|
|
4
|
+
* manifest with (the operation and schema types, `identifier`, the sign-in and GraphQL helpers):
|
|
5
|
+
* `/codegen` itself is experimental.
|
|
4
6
|
*
|
|
5
7
|
* Numbers arrive from a lossless JSON parser (`lossless-json` or anything shaped like its
|
|
6
8
|
* `LosslessNumber`), because a 64-bit id read as a JS number is silently a different id.
|
|
@@ -10,6 +12,7 @@ interface LosslessLike {
|
|
|
10
12
|
isLosslessNumber: true;
|
|
11
13
|
value: string;
|
|
12
14
|
}
|
|
15
|
+
/** @experimental */
|
|
13
16
|
export declare const isLossless: (input: unknown) => input is LosslessLike;
|
|
14
17
|
interface Range {
|
|
15
18
|
minimum?: number;
|
|
@@ -21,4 +24,8 @@ export declare const int64: (range?: Range) => v.SchemaWithPipe<readonly [v.Cust
|
|
|
21
24
|
export declare const integer: (range?: Range) => v.SchemaWithPipe<readonly [v.CustomSchema<number | bigint | LosslessLike, v.ErrorMessage<v.CustomIssue> | undefined>, v.TransformAction<number | bigint | LosslessLike, number>, v.CheckAction<number, "integer out of range">]>;
|
|
22
25
|
export declare const number: (range?: Range) => v.SchemaWithPipe<readonly [v.CustomSchema<number | LosslessLike, v.ErrorMessage<v.CustomIssue> | undefined>, v.TransformAction<number | LosslessLike, number>, v.CheckAction<number, "number out of range">]>;
|
|
23
26
|
export declare const unique: (items: readonly unknown[]) => boolean;
|
|
24
|
-
export {};
|
|
27
|
+
export type { ManifestOperation } from "./manifest.js";
|
|
28
|
+
export type { ApiServer, Binding, Confidence, Effect, GraphqlBinding, HttpBinding, OAuthFlow, OperationPermission, PageParameter, Pagination, RpcBinding, SchemaNode, SecurityRequirement, SecurityScheme, } from "./model.js";
|
|
29
|
+
export { identifier } from "./names.js";
|
|
30
|
+
export { graphqlDocument, parseSelection, type Selection } from "./selection.js";
|
|
31
|
+
export { type SignInPlace, signInPlace, signInRequirements } from "./sign-in.js";
|
package/dist/codegen/runtime.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What generated Valibot schemas call at run time. Kept apart from the generator so a CLI loads
|
|
3
|
-
* these few functions, not the code that writes code.
|
|
3
|
+
* these few functions, not the code that writes code. Also the stable part of the model a CLI reads the generated
|
|
4
|
+
* manifest with (the operation and schema types, `identifier`, the sign-in and GraphQL helpers):
|
|
5
|
+
* `/codegen` itself is experimental.
|
|
4
6
|
*
|
|
5
7
|
* Numbers arrive from a lossless JSON parser (`lossless-json` or anything shaped like its
|
|
6
8
|
* `LosslessNumber`), because a 64-bit id read as a JS number is silently a different id.
|
|
7
9
|
*/
|
|
8
10
|
import * as v from "valibot";
|
|
11
|
+
/** @experimental */
|
|
9
12
|
export const isLossless = (input) => typeof input === "object" &&
|
|
10
13
|
input !== null &&
|
|
11
14
|
input.isLosslessNumber === true &&
|
|
@@ -35,3 +38,6 @@ export const integer = (range = {}) => v.pipe(v.custom((input) => {
|
|
|
35
38
|
}, "expected an integer within ±2^53"), v.transform((input) => Number(digitsOf(input))), v.check((value) => inRange(value, range), "integer out of range"));
|
|
36
39
|
export const number = (range = {}) => v.pipe(v.custom((input) => (isLossless(input) ? Number.isFinite(Number(input.value)) : Number.isFinite(input)), "expected a number"), v.transform((input) => (isLossless(input) ? Number(input.value) : input)), v.check((value) => inRange(value, range), "number out of range"));
|
|
37
40
|
export const unique = (items) => new Set(items.map((item) => JSON.stringify(item))).size === items.length;
|
|
41
|
+
export { identifier } from "./names.js";
|
|
42
|
+
export { graphqlDocument, parseSelection } from "./selection.js";
|
|
43
|
+
export { signInPlace, signInRequirements } from "./sign-in.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The two GraphQL helpers a CLI calls at run time, apart from the adapter so they load no codegen code. */
|
|
2
|
+
import type { GraphqlBinding } from "./model.js";
|
|
3
|
+
/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
|
|
4
|
+
export declare const graphqlDocument: (binding: GraphqlBinding, selection?: string) => string;
|
|
5
|
+
/** A selection as a tree: a field's name → its own selection, or `true` for a leaf. */
|
|
6
|
+
export interface Selection {
|
|
7
|
+
readonly [field: string]: Selection | true;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
|
|
11
|
+
* throws, since nothing here can check one.
|
|
12
|
+
*/
|
|
13
|
+
export declare const parseSelection: (text: string) => Selection;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Builds the one document an operation sends: every variable declared and passed, the selection inside. */
|
|
2
|
+
export const graphqlDocument = (binding, selection = binding.selection) => {
|
|
3
|
+
const variables = Object.entries(binding.variables);
|
|
4
|
+
const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
|
|
5
|
+
const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
|
|
6
|
+
const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
|
|
7
|
+
return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* `id title state { id type }` → its tree. Only names and braces: an argument, an alias, a fragment or a directive
|
|
11
|
+
* throws, since nothing here can check one.
|
|
12
|
+
*/
|
|
13
|
+
export const parseSelection = (text) => {
|
|
14
|
+
const tokens = text.match(/[_A-Za-z][_0-9A-Za-z]*|[{}]|\S/g) ?? [];
|
|
15
|
+
let at = 0;
|
|
16
|
+
const level = (nested) => {
|
|
17
|
+
const fields = {};
|
|
18
|
+
while (at < tokens.length) {
|
|
19
|
+
const token = tokens[at];
|
|
20
|
+
if (token === "}") {
|
|
21
|
+
if (!nested)
|
|
22
|
+
throw new Error(`selection "${text}": an unmatched }`);
|
|
23
|
+
at += 1;
|
|
24
|
+
return fields;
|
|
25
|
+
}
|
|
26
|
+
if (!/^[_A-Za-z]/.test(token))
|
|
27
|
+
throw new Error(`selection "${text}": "${token}" — only field names and braces are supported`);
|
|
28
|
+
at += 1;
|
|
29
|
+
if (tokens[at] === "{") {
|
|
30
|
+
at += 1;
|
|
31
|
+
const inner = level(true);
|
|
32
|
+
if (Object.keys(inner).length === 0)
|
|
33
|
+
throw new Error(`selection "${text}": ${token} selects nothing`);
|
|
34
|
+
fields[token] = inner;
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
fields[token] = true;
|
|
38
|
+
}
|
|
39
|
+
if (nested)
|
|
40
|
+
throw new Error(`selection "${text}": a { is not closed`);
|
|
41
|
+
return fields;
|
|
42
|
+
};
|
|
43
|
+
return level(false);
|
|
44
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModelOverride } from "./model.js";
|
|
2
2
|
type Json = Record<string, unknown>;
|
|
3
3
|
export interface WpJsonOptions {
|
|
4
4
|
/** The namespaces the CLI offers, as `wp/v2`; every other route is left out and listed in `omissions`. */
|
|
@@ -17,7 +17,7 @@ export interface WpJsonResult {
|
|
|
17
17
|
* For `generate`'s `overrides`: how each collection read pages. WordPress answers the list itself, counts pages from
|
|
18
18
|
* 1 and gives their number in `X-WP-TotalPages`; a page past it is an error, not an empty list.
|
|
19
19
|
*/
|
|
20
|
-
overrides: Record<string,
|
|
20
|
+
overrides: Record<string, ModelOverride>;
|
|
21
21
|
/** What the document leaves out, one line each, for a reviewer. */
|
|
22
22
|
omissions: string[];
|
|
23
23
|
}
|
|
@@ -4,6 +4,8 @@ import { type CommandInfo, type OptionInfo } from "./registry.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* What `<cli> commands --json` prints, in every CLI on cli-base. `scope` and `inherited_options` are
|
|
6
6
|
* there only when one command path was asked for. Nothing else at the top: `cli-dev lint` refuses it.
|
|
7
|
+
*
|
|
8
|
+
* @experimental
|
|
7
9
|
*/
|
|
8
10
|
export declare const commandsDocumentSchema: v.StrictObjectSchema<{
|
|
9
11
|
readonly cli: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
|
|
@@ -56,6 +58,7 @@ export interface CommandsDocument {
|
|
|
56
58
|
commands: CommandInfo[];
|
|
57
59
|
exit_codes: Record<string, number>;
|
|
58
60
|
}
|
|
61
|
+
/** @experimental */
|
|
59
62
|
export declare const commandsDocumentJsonSchema: () => import("@valibot/to-json-schema").JsonSchema;
|
|
60
63
|
export declare const parseCommandsDocument: (value: unknown) => {
|
|
61
64
|
document: CommandsDocument;
|
|
@@ -67,6 +67,8 @@ const commandInfoSchema = v.object({
|
|
|
67
67
|
/**
|
|
68
68
|
* What `<cli> commands --json` prints, in every CLI on cli-base. `scope` and `inherited_options` are
|
|
69
69
|
* there only when one command path was asked for. Nothing else at the top: `cli-dev lint` refuses it.
|
|
70
|
+
*
|
|
71
|
+
* @experimental
|
|
70
72
|
*/
|
|
71
73
|
export const commandsDocumentSchema = v.strictObject({
|
|
72
74
|
cli: v.pipe(v.string(), v.nonEmpty()),
|
|
@@ -80,6 +82,7 @@ export const commandsDocumentSchema = v.strictObject({
|
|
|
80
82
|
commands: v.array(commandInfoSchema),
|
|
81
83
|
exit_codes: v.record(v.string(), v.pipe(v.number(), v.integer())),
|
|
82
84
|
});
|
|
85
|
+
/** @experimental */
|
|
83
86
|
export const commandsDocumentJsonSchema = () => jsonSchemaOf(commandsDocumentSchema, { command: commandInfoSchema });
|
|
84
87
|
export const parseCommandsDocument = (value) => {
|
|
85
88
|
const parsed = v.safeParse(commandsDocumentSchema, value);
|
package/dist/commands/page.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { CommandInfo, OptionInfo } from "./registry.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The labels of the tables; the same for every CLI writing in one language.
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
3
7
|
export type CommandsPageLabels = {
|
|
4
8
|
option: string;
|
|
5
9
|
does: string;
|
|
@@ -20,6 +24,7 @@ export type CommandsPageLabels = {
|
|
|
20
24
|
/** Under a command that only reads from such a service. */
|
|
21
25
|
readsOutside?: string;
|
|
22
26
|
};
|
|
27
|
+
/** @experimental */
|
|
23
28
|
export declare const COMMANDS_PAGE_LABELS: {
|
|
24
29
|
readonly en: {
|
|
25
30
|
readonly option: "Option";
|
|
@@ -54,7 +59,11 @@ export declare const COMMANDS_PAGE_LABELS: {
|
|
|
54
59
|
readonly readsOutside: "**Читает из внешнего сервиса.**";
|
|
55
60
|
};
|
|
56
61
|
};
|
|
57
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* The CLI's own words: everything on the page that is not read out of the program.
|
|
64
|
+
*
|
|
65
|
+
* @experimental
|
|
66
|
+
*/
|
|
58
67
|
export type CommandsPageText = {
|
|
59
68
|
/** The first line, an HTML comment saying the page is generated and by what. */
|
|
60
69
|
banner: string;
|
|
@@ -72,6 +81,7 @@ export type CommandsPageText = {
|
|
|
72
81
|
/** Markdown after the exit codes; may be empty. */
|
|
73
82
|
outro: string;
|
|
74
83
|
};
|
|
84
|
+
/** @experimental */
|
|
75
85
|
export type CommandsPage = {
|
|
76
86
|
cli: string;
|
|
77
87
|
commands: readonly CommandInfo[];
|
|
@@ -85,5 +95,7 @@ export type CommandsPage = {
|
|
|
85
95
|
* The whole `docs/commands.md`: every command at any depth, every option and argument, the exit
|
|
86
96
|
* codes. Descriptions are quoted as `--help` prints them, untranslated — a translation here would
|
|
87
97
|
* give the sentence a second home, and the one on screen is the one that gets corrected.
|
|
98
|
+
*
|
|
99
|
+
* @experimental
|
|
88
100
|
*/
|
|
89
101
|
export declare const commandsPage: ({ cli, commands, options, labels, text, details }: CommandsPage) => string;
|
package/dist/commands/page.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EXIT_CODES } from "../exit-codes.js";
|
|
2
|
+
/** @experimental */
|
|
2
3
|
export const COMMANDS_PAGE_LABELS = {
|
|
3
4
|
en: {
|
|
4
5
|
option: "Option",
|
|
@@ -43,6 +44,8 @@ const sentence = (text) => {
|
|
|
43
44
|
* The whole `docs/commands.md`: every command at any depth, every option and argument, the exit
|
|
44
45
|
* codes. Descriptions are quoted as `--help` prints them, untranslated — a translation here would
|
|
45
46
|
* give the sentence a second home, and the one on screen is the one that gets corrected.
|
|
47
|
+
*
|
|
48
|
+
* @experimental
|
|
46
49
|
*/
|
|
47
50
|
export const commandsPage = ({ cli, commands, options, labels, text, details }) => {
|
|
48
51
|
// What a value may be and what it is when left out: Commander keeps both out of the description.
|
|
@@ -29,7 +29,11 @@ export interface CompletionRequest {
|
|
|
29
29
|
words: readonly string[];
|
|
30
30
|
sources?: CompletionSources;
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Tells the shell not to fall back to file names when nothing matched.
|
|
34
|
+
*
|
|
35
|
+
* @experimental
|
|
36
|
+
*/
|
|
33
37
|
export declare const NO_FILE_COMPLETION = 4;
|
|
34
38
|
export declare const suggest: ({ commands, globalOptions, words, sources }: CompletionRequest) => Suggestion[];
|
|
35
39
|
/** The answer in the form the shell script reads. */
|
package/dist/completion/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Tells the shell not to fall back to file names when nothing matched.
|
|
3
|
+
*
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
2
6
|
export const NO_FILE_COMPLETION = 4;
|
|
3
7
|
export const suggest = ({ commands, globalOptions = [], words, sources = {} }) => {
|
|
4
8
|
const typed = words.at(-1) ?? "";
|