@artemis-studio/client 2026.10.4

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 ADDED
@@ -0,0 +1,21 @@
1
+ # @artemis-studio/client
2
+
3
+ A typed client for the [Artemis Studio](https://github.com/sudoitir/artemis-studio) API. Its types are
4
+ generated from the OpenAPI document of the same release, so version `2026.9.3` of the client describes
5
+ Studio `2026.09.3`.
6
+
7
+ ```ts
8
+ import { createStudioClient, ProblemError } from '@artemis-studio/client';
9
+
10
+ const studio = createStudioClient({ baseUrl: 'https://studio.example.com', token: process.env.STUDIO_TOKEN! });
11
+
12
+ try {
13
+ const { data } = await studio.GET('/api/v1/clusters');
14
+ } catch (error) {
15
+ // Every non-2xx answer is an RFC 9457 problem; `type` is a stable URI.
16
+ if (error instanceof ProblemError) console.error(error.status, error.type, error.message);
17
+ }
18
+ ```
19
+
20
+ Requests are made with [openapi-fetch](https://openapi-ts.dev/openapi-fetch/), so its options and
21
+ middleware apply.
package/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { type Client } from 'openapi-fetch';
2
+ import type { paths } from './schema.js';
3
+ export type { components, operations, paths } from './schema.js';
4
+ /** An RFC 9457 `application/problem+json` answer. `type` is one of Studio's stable problem URIs. */
5
+ export declare class ProblemError extends Error {
6
+ readonly status: number;
7
+ readonly type: string;
8
+ readonly title: string;
9
+ /** The whole body: a problem may carry more members (field errors, a limit) than these. */
10
+ readonly problem: Record<string, unknown>;
11
+ constructor(status: number, problem: Record<string, unknown>);
12
+ }
13
+ export interface StudioClientOptions {
14
+ /** Where Studio is served, for example `https://studio.example.com`. */
15
+ baseUrl: string;
16
+ /** An API token; sent as `Authorization: Bearer <token>`. */
17
+ token: string;
18
+ /** A replacement for the global `fetch`, for a proxy or a test. */
19
+ fetch?: (request: Request) => Promise<Response>;
20
+ }
21
+ /** A typed client for the Studio API: `client.GET('/api/v1/clusters')`, and so on. */
22
+ export declare function createStudioClient({ baseUrl, token, fetch }: StudioClientOptions): Client<paths>;
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import createClient, {} from 'openapi-fetch';
2
+ /** An RFC 9457 `application/problem+json` answer. `type` is one of Studio's stable problem URIs. */
3
+ export class ProblemError extends Error {
4
+ status;
5
+ type;
6
+ title;
7
+ /** The whole body: a problem may carry more members (field errors, a limit) than these. */
8
+ problem;
9
+ constructor(status, problem) {
10
+ super(problem.detail ?? problem.title ?? `Request failed (${status})`);
11
+ this.name = 'ProblemError';
12
+ this.status = status;
13
+ this.type = problem.type ?? 'about:blank';
14
+ this.title = problem.title ?? 'Error';
15
+ this.problem = problem;
16
+ }
17
+ }
18
+ /** Sends the token, and turns every non-2xx `problem+json` answer into a thrown {@link ProblemError}. */
19
+ const studio = (token) => ({
20
+ onRequest({ request }) {
21
+ request.headers.set('Authorization', `Bearer ${token}`);
22
+ return request;
23
+ },
24
+ async onResponse({ response }) {
25
+ if (response.ok || !response.headers.get('content-type')?.includes('application/problem+json'))
26
+ return undefined;
27
+ throw new ProblemError(response.status, (await response.json()));
28
+ },
29
+ });
30
+ /** A typed client for the Studio API: `client.GET('/api/v1/clusters')`, and so on. */
31
+ export function createStudioClient({ baseUrl, token, fetch }) {
32
+ const client = createClient({ baseUrl, fetch });
33
+ client.use(studio(token));
34
+ return client;
35
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@artemis-studio/client",
3
+ "version": "2026.10.4",
4
+ "description": "A typed TypeScript client for the Artemis Studio API, generated from its OpenAPI document.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/sudoitir/artemis-studio.git",
9
+ "directory": "web/packages/client"
10
+ },
11
+ "homepage": "https://sudoitir.github.io/artemis-studio/",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "schema.d.ts",
23
+ "README.md"
24
+ ],
25
+ "sideEffects": false,
26
+ "dependencies": {
27
+ "openapi-fetch": "0.17.0"
28
+ }
29
+ }