@cpajs/cpa 0.0.0-stage → 0.0.1-alpha-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +142 -2
- package/dist/client/errors.d.ts +70 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +91 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/index.d.ts +46 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +65 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/resources/config.d.ts +61 -0
- package/dist/client/resources/config.d.ts.map +1 -0
- package/dist/client/resources/config.js +80 -0
- package/dist/client/resources/config.js.map +1 -0
- package/dist/client/resources/credentials.d.ts +64 -0
- package/dist/client/resources/credentials.d.ts.map +1 -0
- package/dist/client/resources/credentials.js +94 -0
- package/dist/client/resources/credentials.js.map +1 -0
- package/dist/client/resources/download.d.ts +8 -0
- package/dist/client/resources/download.d.ts.map +1 -0
- package/dist/client/resources/download.js +17 -0
- package/dist/client/resources/download.js.map +1 -0
- package/dist/client/resources/logs.d.ts +23 -0
- package/dist/client/resources/logs.d.ts.map +1 -0
- package/dist/client/resources/logs.js +37 -0
- package/dist/client/resources/logs.js.map +1 -0
- package/dist/client/resources/oauth.d.ts +43 -0
- package/dist/client/resources/oauth.d.ts.map +1 -0
- package/dist/client/resources/oauth.js +70 -0
- package/dist/client/resources/oauth.js.map +1 -0
- package/dist/client/resources/plugins.d.ts +25 -0
- package/dist/client/resources/plugins.d.ts.map +1 -0
- package/dist/client/resources/plugins.js +47 -0
- package/dist/client/resources/plugins.js.map +1 -0
- package/dist/client/resources/requests.d.ts +14 -0
- package/dist/client/resources/requests.d.ts.map +1 -0
- package/dist/client/resources/requests.js +16 -0
- package/dist/client/resources/requests.js.map +1 -0
- package/dist/client/resources/routing.d.ts +12 -0
- package/dist/client/resources/routing.d.ts.map +1 -0
- package/dist/client/resources/routing.js +20 -0
- package/dist/client/resources/routing.js.map +1 -0
- package/dist/client/resources/server.d.ts +17 -0
- package/dist/client/resources/server.d.ts.map +1 -0
- package/dist/client/resources/server.js +49 -0
- package/dist/client/resources/server.js.map +1 -0
- package/dist/client/resources/usage.d.ts +16 -0
- package/dist/client/resources/usage.d.ts.map +1 -0
- package/dist/client/resources/usage.js +20 -0
- package/dist/client/resources/usage.js.map +1 -0
- package/dist/client/transport.d.ts +60 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/transport.js +170 -0
- package/dist/client/transport.js.map +1 -0
- package/dist/client/types/common.d.ts +38 -0
- package/dist/client/types/common.d.ts.map +1 -0
- package/dist/client/types/common.js +4 -0
- package/dist/client/types/common.js.map +1 -0
- package/dist/client/types/config.d.ts +407 -0
- package/dist/client/types/config.d.ts.map +1 -0
- package/dist/client/types/config.js +9 -0
- package/dist/client/types/config.js.map +1 -0
- package/dist/client/types/credentials.d.ts +240 -0
- package/dist/client/types/credentials.d.ts.map +1 -0
- package/dist/client/types/credentials.js +4 -0
- package/dist/client/types/credentials.js.map +1 -0
- package/dist/client/types/index.d.ts +10 -0
- package/dist/client/types/index.d.ts.map +1 -0
- package/dist/client/types/index.js +2 -0
- package/dist/client/types/index.js.map +1 -0
- package/dist/client/types/oauth.d.ts +89 -0
- package/dist/client/types/oauth.d.ts.map +1 -0
- package/dist/client/types/oauth.js +4 -0
- package/dist/client/types/oauth.js.map +1 -0
- package/dist/client/types/observability.d.ts +111 -0
- package/dist/client/types/observability.d.ts.map +1 -0
- package/dist/client/types/observability.js +4 -0
- package/dist/client/types/observability.js.map +1 -0
- package/dist/client/types/plugins.d.ts +171 -0
- package/dist/client/types/plugins.d.ts.map +1 -0
- package/dist/client/types/plugins.js +4 -0
- package/dist/client/types/plugins.js.map +1 -0
- package/dist/client/types/requests.d.ts +16 -0
- package/dist/client/types/requests.d.ts.map +1 -0
- package/dist/client/types/requests.js +4 -0
- package/dist/client/types/requests.js.map +1 -0
- package/dist/client/types/routing.d.ts +50 -0
- package/dist/client/types/routing.d.ts.map +1 -0
- package/dist/client/types/routing.js +4 -0
- package/dist/client/types/routing.js.map +1 -0
- package/dist/client/types/server.d.ts +15 -0
- package/dist/client/types/server.d.ts.map +1 -0
- package/dist/client/types/server.js +4 -0
- package/dist/client/types/server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/server/binary.d.ts +35 -0
- package/dist/server/binary.d.ts.map +1 -0
- package/dist/server/binary.js +108 -0
- package/dist/server/binary.js.map +1 -0
- package/dist/server/config.d.ts +37 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +103 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/cpa-version.d.ts +12 -0
- package/dist/server/cpa-version.d.ts.map +1 -0
- package/dist/server/cpa-version.js +12 -0
- package/dist/server/cpa-version.js.map +1 -0
- package/dist/server/errors.d.ts +36 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +26 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +208 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/process.d.ts +27 -0
- package/dist/server/process.d.ts.map +1 -0
- package/dist/server/process.js +114 -0
- package/dist/server/process.js.map +1 -0
- package/dist/server/readiness.d.ts +13 -0
- package/dist/server/readiness.d.ts.map +1 -0
- package/dist/server/readiness.js +56 -0
- package/dist/server/readiness.js.map +1 -0
- package/dist/server/redact.d.ts +3 -0
- package/dist/server/redact.d.ts.map +1 -0
- package/dist/server/redact.js +16 -0
- package/dist/server/redact.js.map +1 -0
- package/dist/server/targets.d.ts +48 -0
- package/dist/server/targets.d.ts.map +1 -0
- package/dist/server/targets.js +90 -0
- package/dist/server/targets.js.map +1 -0
- package/dist/server/types.d.ts +87 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/package.json +83 -4
- package/src/client/errors.ts +104 -0
- package/src/client/index.ts +95 -0
- package/src/client/resources/config.ts +124 -0
- package/src/client/resources/credentials.ts +133 -0
- package/src/client/resources/download.ts +21 -0
- package/src/client/resources/logs.ts +46 -0
- package/src/client/resources/oauth.ts +105 -0
- package/src/client/resources/plugins.ts +70 -0
- package/src/client/resources/requests.ts +20 -0
- package/src/client/resources/routing.ts +29 -0
- package/src/client/resources/server.ts +52 -0
- package/src/client/resources/usage.ts +27 -0
- package/src/client/transport.ts +215 -0
- package/src/client/types/common.ts +38 -0
- package/src/client/types/config.ts +248 -0
- package/src/client/types/credentials.ts +195 -0
- package/src/client/types/index.ts +9 -0
- package/src/client/types/oauth.ts +71 -0
- package/src/client/types/observability.ts +93 -0
- package/src/client/types/plugins.ts +136 -0
- package/src/client/types/requests.ts +19 -0
- package/src/client/types/routing.ts +44 -0
- package/src/client/types/server.ts +18 -0
- package/src/index.ts +2 -0
- package/src/server/binary.ts +128 -0
- package/src/server/config.ts +128 -0
- package/src/server/cpa-version.ts +11 -0
- package/src/server/errors.ts +48 -0
- package/src/server/index.ts +236 -0
- package/src/server/process.ts +124 -0
- package/src/server/readiness.ts +58 -0
- package/src/server/redact.ts +14 -0
- package/src/server/targets.ts +133 -0
- package/src/server/types.ts +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 akarachen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,143 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cpajs/cpa
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run the official [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) (CPA) from Node.js or Bun, and
|
|
4
|
+
manage any CPA instance with a hand-written, typed client for its native **v8 management API**.
|
|
5
|
+
|
|
6
|
+
- `@cpajs/cpa/server` locates the bundled binary, writes the config, starts the process, waits until it is ready,
|
|
7
|
+
streams logs and stops it.
|
|
8
|
+
- `@cpajs/cpa/client` is a `fetch`-based client for `/v8/management`, with types derived from the CPA source. It can
|
|
9
|
+
connect to local or remote instances.
|
|
10
|
+
- Prebuilt CPA binaries for 23 platforms come through `optionalDependencies`, so `npm install` is all that is
|
|
11
|
+
needed.
|
|
12
|
+
|
|
13
|
+
Bundled CLIProxyAPI: **v8.0.43**. See [docs/compatibility.md](docs/compatibility.md) for platforms and versions,
|
|
14
|
+
and [docs/api-coverage.md](docs/api-coverage.md) for every route.
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @cpajs/cpa
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Start a server
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { startServer } from '@cpajs/cpa/server';
|
|
24
|
+
|
|
25
|
+
const server = await startServer({
|
|
26
|
+
stateDir: './.cpa', // omit for a temporary directory that is removed on stop
|
|
27
|
+
managementKey: process.env.CPA_MANAGEMENT_KEY,
|
|
28
|
+
config: { // native v8 config, typed as CpaConfig
|
|
29
|
+
access: { 'api-keys': ['sk-my-model-key'] },
|
|
30
|
+
routing: { strategy: 'fill-first' },
|
|
31
|
+
},
|
|
32
|
+
onLog: ({ stream, line }) => console.log(`[cpa ${stream}] ${line}`),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log(server.origin); // http://127.0.0.1:40123 (a free port is picked by default)
|
|
36
|
+
console.log(server.baseUrl); // http://127.0.0.1:40123/v1 for OpenAI-compatible SDKs
|
|
37
|
+
|
|
38
|
+
await server.stop();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `config` and `configPath` are mutually exclusive.
|
|
42
|
+
- `config` is written to `<stateDir>/config.yaml` on every start. Credentials go to `<stateDir>/auths` unless
|
|
43
|
+
`oauth.auth-dir` is set. The server binds `127.0.0.1` unless you pass `host` or set `server.host`.
|
|
44
|
+
- `configPath` hands an existing file to CPA unchanged. CPA may rewrite it, for example to hash
|
|
45
|
+
`management.secret-key`. The file must set a fixed port, because CPA does not report the port it picks.
|
|
46
|
+
- `startServer` resolves only once `/healthz` answers. It rejects with `CpaStartError` on early exit, port
|
|
47
|
+
conflict, timeout (`startupTimeoutMs`, default 30 s) or `signal` abort. In every failure case the process is
|
|
48
|
+
stopped and the temporary directory removed.
|
|
49
|
+
- `stop()` is idempotent: it sends SIGTERM and then SIGKILL after `stopTimeoutMs` (default 10 s). On Windows Node
|
|
50
|
+
can only terminate forcefully. `server.exited` settles however the process ends.
|
|
51
|
+
- `managementKey` is passed through `MANAGEMENT_PASSWORD`, so it never touches disk. Upstream treats that
|
|
52
|
+
variable as also allowing remote management. The key, config secrets and `redact` values are masked in logs and
|
|
53
|
+
errors.
|
|
54
|
+
- `binaryPath` overrides the bundled binary. `args` adds CLI flags, for example `['-local-model']`.
|
|
55
|
+
|
|
56
|
+
## Manage a server
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { createClient, CpaHttpError } from '@cpajs/cpa/client';
|
|
60
|
+
|
|
61
|
+
const client = createClient({
|
|
62
|
+
baseUrl: 'http://127.0.0.1:8317', // a path prefix behind a reverse proxy is kept
|
|
63
|
+
managementKey: process.env.CPA_MANAGEMENT_KEY!,
|
|
64
|
+
timeoutMs: 15_000,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const { data: config, etag } = await client.config.get();
|
|
68
|
+
await client.config.patch({ routing: { strategy: 'round-robin' } }, { ifMatch: etag });
|
|
69
|
+
await client.config.set('routing/retry/request-retry', 2);
|
|
70
|
+
|
|
71
|
+
const { files } = await client.credentials.list();
|
|
72
|
+
await client.credentials.upload({ name: 'codex-me.json', content: credentialJson });
|
|
73
|
+
|
|
74
|
+
const login = await client.oauth.start({ provider: 'claude' });
|
|
75
|
+
console.log('open', login.url);
|
|
76
|
+
await client.oauth.waitForCompletion(login.state);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await client.config.getPath('does/not/exist');
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error instanceof CpaHttpError) console.log(error.status, error.errorCode); // 404 'not_found'
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Group | Routes |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `config` | `/config`, `/config.yaml`, `/config/*path`, with ETag / `If-Match` |
|
|
88
|
+
| `credentials` | list, upload (raw or multipart), delete, models, download, status, fields, refresh, SIWC status |
|
|
89
|
+
| `oauth` | auth URL, status / wait, cancel, callback, Vertex import, SIWC bind |
|
|
90
|
+
| `logs` | main log with cursor, clear, error logs, request logs |
|
|
91
|
+
| `usage` | API-key counters, usage queue (destructive pop) |
|
|
92
|
+
| `routing` | cooldown reset, model definitions |
|
|
93
|
+
| `requests` | server-side `api-call` |
|
|
94
|
+
| `plugins` | list, delete, store, install, quota |
|
|
95
|
+
| `server` | `/healthz`, version headers, latest release |
|
|
96
|
+
|
|
97
|
+
Every method takes `{ signal, timeoutMs, headers }`. Errors:
|
|
98
|
+
|
|
99
|
+
- `CpaHttpError` for a non-2xx response. It carries `status`, the raw `body`, parsed `data`, and `errorCode` /
|
|
100
|
+
`errorMessage`.
|
|
101
|
+
- `CpaNetworkError` when the request fails.
|
|
102
|
+
- `CpaTimeoutError` when the request times out.
|
|
103
|
+
- `CpaAbortError` when your `signal` aborts the request.
|
|
104
|
+
- `CpaResponseError` when a 2xx response has a malformed body.
|
|
105
|
+
|
|
106
|
+
A 207 partial result resolves normally. Use `client.request()` for anything without a typed method.
|
|
107
|
+
|
|
108
|
+
### Model API
|
|
109
|
+
|
|
110
|
+
The management key and model API keys are different things. Model requests go to `server.baseUrl` or
|
|
111
|
+
`client.modelBaseUrl` with a key from `access.api-keys`:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import OpenAI from 'openai';
|
|
115
|
+
const openai = new OpenAI({ baseURL: server.baseUrl, apiKey: 'sk-my-model-key' });
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
pnpm install
|
|
122
|
+
pnpm typecheck && pnpm test # unit tests (mocked fetch + a fake CPA process)
|
|
123
|
+
node scripts/build-binary.ts --target linux-x64-musl
|
|
124
|
+
CPA_BINARY=dist-bin/linux-x64-musl/cli-proxy-api pnpm test:e2e # contract tests against real CPA
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Release tooling, all in `scripts/` and run directly with Node's type stripping:
|
|
128
|
+
|
|
129
|
+
| Script | Purpose |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
| `fetch-source.ts` | Clone the pinned CPA tag and verify the commit. |
|
|
132
|
+
| `build-binary.ts` | Build one or more targets, with the same CGO/plugin split as upstream. |
|
|
133
|
+
| `verify-binary.ts` | Check format, CPU, static linking and the glibc baseline; `--smoke` starts the binary. |
|
|
134
|
+
| `assemble-packages.ts` | Create the `@cpajs/*` platform packages. |
|
|
135
|
+
| `pack.ts` | Produce the tarballs. |
|
|
136
|
+
| `install-test.ts` | Install the tarballs through a local registry with npm, pnpm or bun, and run them. |
|
|
137
|
+
| `trust-publishers.ts` | Configure npm trusted publishing for all packages (run locally after the first publish). |
|
|
138
|
+
|
|
139
|
+
`.github/workflows/release.yml` runs these steps across the whole platform matrix and publishes on `v*` tags through npm trusted publishing (OIDC). Prerelease versions such as `0.0.1-alpha-1` go to a matching dist-tag (`alpha`). `trust-publishers.ts` configures trusted publishing for every package; npm only allows this once a package exists, so the very first release needs a temporary `NPM_TOKEN` secret.
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT. The bundled CLIProxyAPI binaries are MIT licensed by their authors; each platform package ships their LICENSE.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Base class for every error thrown by the client. */
|
|
2
|
+
export declare class CpaClientError extends Error {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly method: string;
|
|
5
|
+
readonly url: string;
|
|
6
|
+
constructor(message: string, request: {
|
|
7
|
+
method: string;
|
|
8
|
+
url: string;
|
|
9
|
+
}, options?: {
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The server answered with a non-2xx status.
|
|
15
|
+
*
|
|
16
|
+
* `body` is the raw response text. `data` is the parsed JSON body when there
|
|
17
|
+
* was one; CPA errors usually look like `{ "error": "<code>", "message"?: "..." }`.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CpaHttpError extends CpaClientError {
|
|
20
|
+
readonly name = "CpaHttpError";
|
|
21
|
+
readonly status: number;
|
|
22
|
+
readonly statusText: string;
|
|
23
|
+
readonly headers: Headers;
|
|
24
|
+
readonly body: string;
|
|
25
|
+
readonly data: unknown;
|
|
26
|
+
constructor(request: {
|
|
27
|
+
method: string;
|
|
28
|
+
url: string;
|
|
29
|
+
}, response: {
|
|
30
|
+
status: number;
|
|
31
|
+
statusText: string;
|
|
32
|
+
headers: Headers;
|
|
33
|
+
}, body: string);
|
|
34
|
+
/** The `error` field of a CPA error body, e.g. `"not_found"` or `"invalid management key"`. */
|
|
35
|
+
get errorCode(): string | undefined;
|
|
36
|
+
/** The `message` field of a CPA error body, when present. */
|
|
37
|
+
get errorMessage(): string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The request could not be sent or the response could not be read. */
|
|
40
|
+
export declare class CpaNetworkError extends CpaClientError {
|
|
41
|
+
readonly name = "CpaNetworkError";
|
|
42
|
+
}
|
|
43
|
+
/** The request exceeded its timeout. */
|
|
44
|
+
export declare class CpaTimeoutError extends CpaClientError {
|
|
45
|
+
readonly name = "CpaTimeoutError";
|
|
46
|
+
readonly timeoutMs: number;
|
|
47
|
+
constructor(request: {
|
|
48
|
+
method: string;
|
|
49
|
+
url: string;
|
|
50
|
+
}, timeoutMs: number, options?: {
|
|
51
|
+
cause?: unknown;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** The caller's AbortSignal was aborted. `cause` is the signal's reason. */
|
|
55
|
+
export declare class CpaAbortError extends CpaClientError {
|
|
56
|
+
readonly name = "CpaAbortError";
|
|
57
|
+
}
|
|
58
|
+
/** A 2xx response body did not match the expected format (e.g. invalid JSON). */
|
|
59
|
+
export declare class CpaResponseError extends CpaClientError {
|
|
60
|
+
readonly name = "CpaResponseError";
|
|
61
|
+
readonly status: number;
|
|
62
|
+
readonly body: string;
|
|
63
|
+
constructor(message: string, request: {
|
|
64
|
+
method: string;
|
|
65
|
+
url: string;
|
|
66
|
+
}, status: number, body: string, options?: {
|
|
67
|
+
cause?: unknown;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0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,SAAQ,cAAc;IACjD,SAAkB,IAAI,qBAAqB;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGrG;CACF;AAED,4EAA4E;AAC5E,qBAAa,aAAc,SAAQ,cAAc;IAC/C,SAAkB,IAAI,mBAAmB;CAC1C;AAED,iFAAiF;AACjF,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,SAAkB,IAAI,sBAAsB;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIjI;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Base class for every error thrown by the client. */
|
|
2
|
+
export class CpaClientError extends Error {
|
|
3
|
+
name = 'CpaClientError';
|
|
4
|
+
method;
|
|
5
|
+
url;
|
|
6
|
+
constructor(message, request, options) {
|
|
7
|
+
super(message, options);
|
|
8
|
+
this.method = request.method;
|
|
9
|
+
this.url = request.url;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The server answered with a non-2xx status.
|
|
14
|
+
*
|
|
15
|
+
* `body` is the raw response text. `data` is the parsed JSON body when there
|
|
16
|
+
* was one; CPA errors usually look like `{ "error": "<code>", "message"?: "..." }`.
|
|
17
|
+
*/
|
|
18
|
+
export class CpaHttpError extends CpaClientError {
|
|
19
|
+
name = 'CpaHttpError';
|
|
20
|
+
status;
|
|
21
|
+
statusText;
|
|
22
|
+
headers;
|
|
23
|
+
body;
|
|
24
|
+
data;
|
|
25
|
+
constructor(request, response, body) {
|
|
26
|
+
const data = parseJsonOrUndefined(body);
|
|
27
|
+
const detail = describeErrorBody(data) ?? (body.trim().slice(0, 200) || response.statusText);
|
|
28
|
+
super(`${request.method} ${request.url} failed with ${response.status}${detail ? `: ${detail}` : ''}`, request);
|
|
29
|
+
this.status = response.status;
|
|
30
|
+
this.statusText = response.statusText;
|
|
31
|
+
this.headers = response.headers;
|
|
32
|
+
this.body = body;
|
|
33
|
+
this.data = data;
|
|
34
|
+
}
|
|
35
|
+
/** The `error` field of a CPA error body, e.g. `"not_found"` or `"invalid management key"`. */
|
|
36
|
+
get errorCode() {
|
|
37
|
+
const value = this.data?.error;
|
|
38
|
+
return typeof value === 'string' ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The `message` field of a CPA error body, when present. */
|
|
41
|
+
get errorMessage() {
|
|
42
|
+
const value = this.data?.message;
|
|
43
|
+
return typeof value === 'string' ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** The request could not be sent or the response could not be read. */
|
|
47
|
+
export class CpaNetworkError extends CpaClientError {
|
|
48
|
+
name = 'CpaNetworkError';
|
|
49
|
+
}
|
|
50
|
+
/** The request exceeded its timeout. */
|
|
51
|
+
export class CpaTimeoutError extends CpaClientError {
|
|
52
|
+
name = 'CpaTimeoutError';
|
|
53
|
+
timeoutMs;
|
|
54
|
+
constructor(request, timeoutMs, options) {
|
|
55
|
+
super(`${request.method} ${request.url} timed out after ${timeoutMs} ms`, request, options);
|
|
56
|
+
this.timeoutMs = timeoutMs;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** The caller's AbortSignal was aborted. `cause` is the signal's reason. */
|
|
60
|
+
export class CpaAbortError extends CpaClientError {
|
|
61
|
+
name = 'CpaAbortError';
|
|
62
|
+
}
|
|
63
|
+
/** A 2xx response body did not match the expected format (e.g. invalid JSON). */
|
|
64
|
+
export class CpaResponseError extends CpaClientError {
|
|
65
|
+
name = 'CpaResponseError';
|
|
66
|
+
status;
|
|
67
|
+
body;
|
|
68
|
+
constructor(message, request, status, body, options) {
|
|
69
|
+
super(message, request, options);
|
|
70
|
+
this.status = status;
|
|
71
|
+
this.body = body;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function parseJsonOrUndefined(text) {
|
|
75
|
+
if (!text)
|
|
76
|
+
return undefined;
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(text);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function describeErrorBody(data) {
|
|
85
|
+
if (typeof data !== 'object' || data === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
const { error, message } = data;
|
|
88
|
+
const parts = [error, message].filter((v) => typeof v === 'string' && v !== '');
|
|
89
|
+
return parts.length ? parts.join(': ') : undefined;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/client/errors.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACrB,IAAI,GAAW,gBAAgB,CAAC;IACzC,MAAM,CAAS;IACf,GAAG,CAAS;IAErB,YAAY,OAAe,EAAE,OAAwC,EAAE,OAA6B;QAClG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACzB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,cAAc;IAC5B,IAAI,GAAG,cAAc,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,OAAO,EAAE,GAAG,IAA8C,CAAC;IAC1E,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7F,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ConfigResource } from './resources/config.ts';
|
|
2
|
+
import { CredentialsResource } from './resources/credentials.ts';
|
|
3
|
+
import { LogsResource } from './resources/logs.ts';
|
|
4
|
+
import { OAuthResource } from './resources/oauth.ts';
|
|
5
|
+
import { PluginsResource } from './resources/plugins.ts';
|
|
6
|
+
import { RequestsResource } from './resources/requests.ts';
|
|
7
|
+
import { RoutingResource } from './resources/routing.ts';
|
|
8
|
+
import { ServerResource } from './resources/server.ts';
|
|
9
|
+
import { UsageResource } from './resources/usage.ts';
|
|
10
|
+
import { type ClientOptions, type RawRequest, type TransportResponse } from './transport.ts';
|
|
11
|
+
export { CpaAbortError, CpaClientError, CpaHttpError, CpaNetworkError, CpaResponseError, CpaTimeoutError, } from './errors.ts';
|
|
12
|
+
export type { ClientOptions, FetchLike, Query, QueryValue, RawRequest, RequestOptions, ResponseType, TransportResponse } from './transport.ts';
|
|
13
|
+
export type { ConfigPath, ConfigWriteOptions, ConfigWriteResult, Versioned } from './resources/config.ts';
|
|
14
|
+
export type { CredentialContent, CredentialFile, CredentialSelector } from './resources/credentials.ts';
|
|
15
|
+
export type { DownloadedFile } from './resources/download.ts';
|
|
16
|
+
export type { WaitForOAuthOptions } from './resources/oauth.ts';
|
|
17
|
+
export { ConfigResource, CredentialsResource, LogsResource, OAuthResource, PluginsResource, RequestsResource, RoutingResource, ServerResource, UsageResource, };
|
|
18
|
+
export type * from './types/index.ts';
|
|
19
|
+
/** Typed client for the CLIProxyAPI v8 management API (`/v8/management`). */
|
|
20
|
+
export declare class CpaClient {
|
|
21
|
+
#private;
|
|
22
|
+
readonly config: ConfigResource;
|
|
23
|
+
readonly credentials: CredentialsResource;
|
|
24
|
+
readonly oauth: OAuthResource;
|
|
25
|
+
readonly logs: LogsResource;
|
|
26
|
+
readonly usage: UsageResource;
|
|
27
|
+
readonly routing: RoutingResource;
|
|
28
|
+
readonly requests: RequestsResource;
|
|
29
|
+
readonly plugins: PluginsResource;
|
|
30
|
+
readonly server: ServerResource;
|
|
31
|
+
constructor(options: ClientOptions);
|
|
32
|
+
/** Server root URL this client talks to. */
|
|
33
|
+
get baseUrl(): URL;
|
|
34
|
+
/**
|
|
35
|
+
* OpenAI-compatible model API base URL (`<baseUrl>/v1`), for existing SDKs.
|
|
36
|
+
* Authenticate those requests with a model API key from `access.api-keys`,
|
|
37
|
+
* not with the management key.
|
|
38
|
+
*/
|
|
39
|
+
get modelBaseUrl(): string;
|
|
40
|
+
/** Escape hatch for routes without a typed method. `path` is relative to `/v8/management`. */
|
|
41
|
+
request<T = unknown>(request: RawRequest): Promise<TransportResponse<T>>;
|
|
42
|
+
}
|
|
43
|
+
export declare function createClient(options: ClientOptions): CpaClient;
|
|
44
|
+
/** `<baseUrl>/v1`, keeping any path prefix. */
|
|
45
|
+
export declare function modelApiBaseUrl(baseUrl: string | URL): string;
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,E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IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,YAAY,OAAO,EAAE,aAAa,EAWjC;IAED,4CAA4C;IAC5C,IAAI,OAAO,IAAI,GAAG,CAEjB;IAED;;;;OAIG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,8FAA8F;IAC9F,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAEvE;CACF;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAE9D;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAM7D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ConfigResource } from './resources/config.js';
|
|
2
|
+
import { CredentialsResource } from './resources/credentials.js';
|
|
3
|
+
import { LogsResource } from './resources/logs.js';
|
|
4
|
+
import { OAuthResource } from './resources/oauth.js';
|
|
5
|
+
import { PluginsResource } from './resources/plugins.js';
|
|
6
|
+
import { RequestsResource } from './resources/requests.js';
|
|
7
|
+
import { RoutingResource } from './resources/routing.js';
|
|
8
|
+
import { ServerResource } from './resources/server.js';
|
|
9
|
+
import { UsageResource } from './resources/usage.js';
|
|
10
|
+
import { Transport } from './transport.js';
|
|
11
|
+
export { CpaAbortError, CpaClientError, CpaHttpError, CpaNetworkError, CpaResponseError, CpaTimeoutError, } from './errors.js';
|
|
12
|
+
export { ConfigResource, CredentialsResource, LogsResource, OAuthResource, PluginsResource, RequestsResource, RoutingResource, ServerResource, UsageResource, };
|
|
13
|
+
/** Typed client for the CLIProxyAPI v8 management API (`/v8/management`). */
|
|
14
|
+
export class CpaClient {
|
|
15
|
+
#transport;
|
|
16
|
+
config;
|
|
17
|
+
credentials;
|
|
18
|
+
oauth;
|
|
19
|
+
logs;
|
|
20
|
+
usage;
|
|
21
|
+
routing;
|
|
22
|
+
requests;
|
|
23
|
+
plugins;
|
|
24
|
+
server;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.#transport = new Transport(options);
|
|
27
|
+
this.config = new ConfigResource(this.#transport);
|
|
28
|
+
this.credentials = new CredentialsResource(this.#transport);
|
|
29
|
+
this.oauth = new OAuthResource(this.#transport);
|
|
30
|
+
this.logs = new LogsResource(this.#transport);
|
|
31
|
+
this.usage = new UsageResource(this.#transport);
|
|
32
|
+
this.routing = new RoutingResource(this.#transport);
|
|
33
|
+
this.requests = new RequestsResource(this.#transport);
|
|
34
|
+
this.plugins = new PluginsResource(this.#transport);
|
|
35
|
+
this.server = new ServerResource(this.#transport);
|
|
36
|
+
}
|
|
37
|
+
/** Server root URL this client talks to. */
|
|
38
|
+
get baseUrl() {
|
|
39
|
+
return this.#transport.baseUrl;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* OpenAI-compatible model API base URL (`<baseUrl>/v1`), for existing SDKs.
|
|
43
|
+
* Authenticate those requests with a model API key from `access.api-keys`,
|
|
44
|
+
* not with the management key.
|
|
45
|
+
*/
|
|
46
|
+
get modelBaseUrl() {
|
|
47
|
+
return modelApiBaseUrl(this.#transport.baseUrl);
|
|
48
|
+
}
|
|
49
|
+
/** Escape hatch for routes without a typed method. `path` is relative to `/v8/management`. */
|
|
50
|
+
request(request) {
|
|
51
|
+
return this.#transport.request(request);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function createClient(options) {
|
|
55
|
+
return new CpaClient(options);
|
|
56
|
+
}
|
|
57
|
+
/** `<baseUrl>/v1`, keeping any path prefix. */
|
|
58
|
+
export function modelApiBaseUrl(baseUrl) {
|
|
59
|
+
const url = new URL(baseUrl);
|
|
60
|
+
url.pathname = `${url.pathname.replace(/\/+$/, '')}/v1`;
|
|
61
|
+
url.search = '';
|
|
62
|
+
url.hash = '';
|
|
63
|
+
return url.toString();
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAA+D,MAAM,gBAAgB,CAAC;AAExG,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,GACd,CAAC;AAGF,6EAA6E;AAC7E,MAAM,OAAO,SAAS;IACX,UAAU,CAAY;IACtB,MAAM,CAAiB;IACvB,WAAW,CAAsB;IACjC,KAAK,CAAgB;IACrB,IAAI,CAAe;IACnB,KAAK,CAAgB;IACrB,OAAO,CAAkB;IACzB,QAAQ,CAAmB;IAC3B,OAAO,CAAkB;I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AAC;AAChC,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,eAAe,CAAC,OAAqB;IACnD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC;IACxD,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;IAChB,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;IACd,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { JsonValue } from '../types/common.ts';
|
|
2
|
+
import type { CpaConfig } from '../types/config.ts';
|
|
3
|
+
import { type RequestOptions, type Transport } from '../transport.ts';
|
|
4
|
+
/** A value together with the ETag of the config file it was read from or written to. */
|
|
5
|
+
export interface Versioned<T> {
|
|
6
|
+
data: T;
|
|
7
|
+
/** Strong ETag of the on-disk file. Pass it as `ifMatch` for optimistic concurrency. */
|
|
8
|
+
etag: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigWriteOptions extends RequestOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Only write if the file still has this ETag (or `*`). A mismatch fails with
|
|
13
|
+
* a 412 `CpaHttpError` (`errorCode === 'precondition_failed'`).
|
|
14
|
+
*
|
|
15
|
+
* Writing a plaintext `management.secret-key` makes CPA rewrite the file
|
|
16
|
+
* with a bcrypt hash a few seconds later, so read again before the next
|
|
17
|
+
* conditional write.
|
|
18
|
+
*/
|
|
19
|
+
ifMatch?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface ConfigWriteResult {
|
|
22
|
+
status: 'ok';
|
|
23
|
+
'config-version': 8;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A config path: `'routing/retry'` or `['routing', 'retry']`. Segments are
|
|
27
|
+
* dash-case YAML keys; list indices are not addressable (lists are replaced whole).
|
|
28
|
+
*/
|
|
29
|
+
export type ConfigPath = string | readonly string[];
|
|
30
|
+
/** `/v8/management/config*`: the native configuration document. */
|
|
31
|
+
export declare class ConfigResource {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(transport: Transport);
|
|
34
|
+
/**
|
|
35
|
+
* The whole config as JSON, migrated to v8 in memory. TURN `username` and
|
|
36
|
+
* `credential` are removed and `auth_index` is added to API keys; writing it
|
|
37
|
+
* back is still safe. Use {@link getYaml} for a lossless copy.
|
|
38
|
+
*/
|
|
39
|
+
get(options?: RequestOptions): Promise<Versioned<CpaConfig>>;
|
|
40
|
+
/** Replaces the whole document. Omitted sections are deleted. */
|
|
41
|
+
replace(config: CpaConfig, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
42
|
+
/**
|
|
43
|
+
* Deep-merges into the document. Objects merge key by key; arrays and
|
|
44
|
+
* scalars replace. `null` is stored as null, it does not delete — use
|
|
45
|
+
* {@link delete} to remove a key.
|
|
46
|
+
*/
|
|
47
|
+
patch(partial: CpaConfig, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
48
|
+
/** The config file as YAML, with comments and without redaction. */
|
|
49
|
+
getYaml(options?: RequestOptions): Promise<Versioned<string>>;
|
|
50
|
+
/** Replaces the whole document with YAML (JSON is accepted too). */
|
|
51
|
+
replaceYaml(yaml: string, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
52
|
+
/** Reads one node, e.g. `getPath('server/port')`. A missing node is a 404 `CpaHttpError`. */
|
|
53
|
+
getPath<T = JsonValue>(path: ConfigPath, options?: RequestOptions): Promise<Versioned<T>>;
|
|
54
|
+
/** Replaces or creates one node. Missing parent objects are created. */
|
|
55
|
+
set(path: ConfigPath, value: JsonValue, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
56
|
+
/** Deep-merges into one node (see {@link patch}). */
|
|
57
|
+
patchPath(path: ConfigPath, value: JsonValue, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
58
|
+
/** Removes one node and any parents left empty. A missing node is a 404 `CpaHttpError`. */
|
|
59
|
+
delete(path: ConfigPath, options?: ConfigWriteOptions): Promise<Versioned<ConfigWriteResult>>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/client/resources/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElF,wFAAwF;AACxF,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC;IACR,wFAAwF;IACxF,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,IAAI,CAAC;IACb,gBAAgB,EAAE,CAAC,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;AAgBpD,mEAAmE;AACnE,qBAAa,cAAc;;IAGzB,YAAY,SAAS,EAAE,SAAS,EAE/B;IAiBD;;;;OAIG;IACH,GAAG,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAE/D;IAED,iEAAiE;IACjE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAElG;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAEjG;IAED,oEAAoE;IACpE,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAEhE;IAED,oEAAoE;IACpE,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAEjG;IAED,6FAA6F;IAC7F,OAAO,CAAC,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAE5F;IAED,wEAAwE;IACxE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAE/G;IAED,qDAAqD;IACrD,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAErH;IAED,2FAA2F;IAC3F,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAEhG;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { encodePath } from '../transport.js';
|
|
2
|
+
function withIfMatch(options) {
|
|
3
|
+
const { ifMatch, ...rest } = options;
|
|
4
|
+
if (ifMatch === undefined)
|
|
5
|
+
return rest;
|
|
6
|
+
const headers = new Headers(rest.headers);
|
|
7
|
+
headers.set('If-Match', ifMatch);
|
|
8
|
+
return { ...rest, headers };
|
|
9
|
+
}
|
|
10
|
+
function nodePath(path) {
|
|
11
|
+
const encoded = encodePath(path, 'config path');
|
|
12
|
+
if (encoded === '')
|
|
13
|
+
throw new TypeError('config path must not be empty; use the whole-document methods instead.');
|
|
14
|
+
return `/config/${encoded}`;
|
|
15
|
+
}
|
|
16
|
+
/** `/v8/management/config*`: the native configuration document. */
|
|
17
|
+
export class ConfigResource {
|
|
18
|
+
#t;
|
|
19
|
+
constructor(transport) {
|
|
20
|
+
this.#t = transport;
|
|
21
|
+
}
|
|
22
|
+
async #read(path, responseType, options) {
|
|
23
|
+
const res = await this.#t.request({ ...options, method: 'GET', path, responseType });
|
|
24
|
+
return { data: res.data, etag: res.headers.get('ETag') ?? undefined };
|
|
25
|
+
}
|
|
26
|
+
async #write(method, path, body, options) {
|
|
27
|
+
const res = await this.#t.request({
|
|
28
|
+
...withIfMatch(options),
|
|
29
|
+
method,
|
|
30
|
+
path,
|
|
31
|
+
...(body === undefined ? {} : 'json' in body ? { json: body.json } : { body: body.yaml, contentType: 'application/yaml' }),
|
|
32
|
+
});
|
|
33
|
+
return { data: res.data, etag: res.headers.get('ETag') ?? undefined };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The whole config as JSON, migrated to v8 in memory. TURN `username` and
|
|
37
|
+
* `credential` are removed and `auth_index` is added to API keys; writing it
|
|
38
|
+
* back is still safe. Use {@link getYaml} for a lossless copy.
|
|
39
|
+
*/
|
|
40
|
+
get(options = {}) {
|
|
41
|
+
return this.#read('/config', 'json', options);
|
|
42
|
+
}
|
|
43
|
+
/** Replaces the whole document. Omitted sections are deleted. */
|
|
44
|
+
replace(config, options = {}) {
|
|
45
|
+
return this.#write('PUT', '/config', { json: config }, options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deep-merges into the document. Objects merge key by key; arrays and
|
|
49
|
+
* scalars replace. `null` is stored as null, it does not delete — use
|
|
50
|
+
* {@link delete} to remove a key.
|
|
51
|
+
*/
|
|
52
|
+
patch(partial, options = {}) {
|
|
53
|
+
return this.#write('PATCH', '/config', { json: partial }, options);
|
|
54
|
+
}
|
|
55
|
+
/** The config file as YAML, with comments and without redaction. */
|
|
56
|
+
getYaml(options = {}) {
|
|
57
|
+
return this.#read('/config.yaml', 'text', options);
|
|
58
|
+
}
|
|
59
|
+
/** Replaces the whole document with YAML (JSON is accepted too). */
|
|
60
|
+
replaceYaml(yaml, options = {}) {
|
|
61
|
+
return this.#write('PUT', '/config.yaml', { yaml }, options);
|
|
62
|
+
}
|
|
63
|
+
/** Reads one node, e.g. `getPath('server/port')`. A missing node is a 404 `CpaHttpError`. */
|
|
64
|
+
getPath(path, options = {}) {
|
|
65
|
+
return this.#read(nodePath(path), 'json', options);
|
|
66
|
+
}
|
|
67
|
+
/** Replaces or creates one node. Missing parent objects are created. */
|
|
68
|
+
set(path, value, options = {}) {
|
|
69
|
+
return this.#write('PUT', nodePath(path), { json: value }, options);
|
|
70
|
+
}
|
|
71
|
+
/** Deep-merges into one node (see {@link patch}). */
|
|
72
|
+
patchPath(path, value, options = {}) {
|
|
73
|
+
return this.#write('PATCH', nodePath(path), { json: value }, options);
|
|
74
|
+
}
|
|
75
|
+
/** Removes one node and any parents left empty. A missing node is a 404 `CpaHttpError`. */
|
|
76
|
+
delete(path, options = {}) {
|
|
77
|
+
return this.#write('DELETE', nodePath(path), undefined, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/client/resources/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAuC,MAAM,iBAAiB,CAAC;AAgClF,SAAS,WAAW,CAAC,OAA2B;IAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACrC,IAAI,OAAO,KAAK,SAAS;QAAE,OA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