@solti/sdk 0.0.0-stage → 0.1.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/README.md +97 -2
- package/dist/client.d.ts +45 -0
- package/dist/client.js +105 -0
- package/dist/errors.d.ts +73 -0
- package/dist/errors.js +101 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +19 -0
- package/dist/resources/connections.d.ts +66 -0
- package/dist/resources/connections.js +43 -0
- package/dist/resources/cronjobs.d.ts +50 -0
- package/dist/resources/cronjobs.js +71 -0
- package/dist/resources/jobs.d.ts +154 -0
- package/dist/resources/jobs.js +172 -0
- package/dist/resources/keys.d.ts +35 -0
- package/dist/resources/keys.js +41 -0
- package/dist/resources/shared.d.ts +34 -0
- package/dist/resources/shared.js +23 -0
- package/package.json +30 -4
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solti/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Solti Platform TypeScript SDK — submit and orchestrate workloads, manage
|
|
4
|
+
connections and cronjobs from Node.js backends, serverless endpoints, and
|
|
5
|
+
orchestrators, without managing infrastructure.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @solti/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @solti/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js >= 20 (native `fetch`).
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { SoltiClient } from "@solti/sdk";
|
|
21
|
+
|
|
22
|
+
// apiKey falls back to the SOLTI_API_KEY environment variable.
|
|
23
|
+
// The project is selected via the X-Solti-Project-Id header — the SDK always
|
|
24
|
+
// targets the global API host (per-project wildcard hosts are not deployed).
|
|
25
|
+
const client = new SoltiClient({
|
|
26
|
+
apiKey: process.env.SOLTI_API_KEY,
|
|
27
|
+
projectId: "<project-id>",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const job = await client.jobs.create({
|
|
31
|
+
namePrefix: "postgres-cleanup-",
|
|
32
|
+
image: "postgres:18-alpine",
|
|
33
|
+
command: ["psql"],
|
|
34
|
+
args: ["-c", "VACUUM ANALYZE;"],
|
|
35
|
+
resources: { cpu: 2, memory: "4Gi" },
|
|
36
|
+
labels: { environment: "production" },
|
|
37
|
+
tags: ["maintenance"],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log(`Job submitted: ${job.id} (${job.status})`);
|
|
41
|
+
|
|
42
|
+
const finalJob = await job.waitUntilComplete({
|
|
43
|
+
timeoutMs: 600_000,
|
|
44
|
+
onProgress: (status) => console.log(`Status: ${status}`),
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Error handling
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import {
|
|
52
|
+
WorkloadFailedError,
|
|
53
|
+
TimeoutError,
|
|
54
|
+
RateLimitError,
|
|
55
|
+
AuthenticationError,
|
|
56
|
+
PermissionDeniedError,
|
|
57
|
+
ValidationError,
|
|
58
|
+
} from "@solti/sdk";
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
await job.waitUntilComplete({ timeoutMs: 600_000 });
|
|
62
|
+
} catch (e) {
|
|
63
|
+
if (e instanceof WorkloadFailedError) {
|
|
64
|
+
console.error(`Workload failed: exit ${e.exitCode}\n${e.errorSummary}`);
|
|
65
|
+
} else if (e instanceof TimeoutError) {
|
|
66
|
+
await client.jobs.cancel(job.id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Error mapping per the client tools spec:
|
|
72
|
+
|
|
73
|
+
| Error | Condition |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `AuthenticationError` | HTTP 401 — invalid or expired API key (Zitadel PAT) |
|
|
76
|
+
| `PermissionDeniedError` | HTTP 403 — key role too weak (e.g. `viewer` on a write) |
|
|
77
|
+
| `ValidationError` | HTTP 422 — invalid payload configuration |
|
|
78
|
+
| `RateLimitError` | HTTP 429 — exposes `retryAfter` and the `X-RateLimit-*` headers |
|
|
79
|
+
| `WorkloadFailedError` | Terminal `failed` state during `waitUntilComplete` (`exitCode`, `errorSummary`, OOM flag) |
|
|
80
|
+
| `TimeoutError` | Client-side wait timeout exceeded |
|
|
81
|
+
|
|
82
|
+
Idempotent reads (GET) are auto-retried on 429 honoring `Retry-After`
|
|
83
|
+
(capped at 30s, at most 2 retries); mutations surface `RateLimitError`.
|
|
84
|
+
|
|
85
|
+
## Resources
|
|
86
|
+
|
|
87
|
+
- `client.jobs` — `create`, `get`, `list`, `cancel`, `waitUntilComplete`
|
|
88
|
+
- `client.connections` — `create`, `get`, `list`, `delete`
|
|
89
|
+
- `client.cronjobs` — `create`, `get`, `list`, `patch`/`update`, `delete` (by UUID `id` or unique `name`)
|
|
90
|
+
- `client.keys` — `create`, `list`, `delete` (admin only)
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
| Option | Default | Description |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `apiKey` | `SOLTI_API_KEY` env | Zitadel-managed PAT |
|
|
97
|
+
| `apiUrl` | `https://api.solti.run/1` (`SOLTI_API_URL_GLOBAL` env overrides) | API base URL (use `https://preview.api.solti.run/1` for preview) |
|
|
98
|
+
| `projectId` | — | Sent as `X-Solti-Project-Id` |
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solti SDK client — host strategy, auth, and error mapping.
|
|
3
|
+
*
|
|
4
|
+
* Host strategy (Change 015 WS2): per-project wildcard hosts
|
|
5
|
+
* (`<project-id>.api.solti.run`) are NOT deployed. The SDK always targets the
|
|
6
|
+
* global host and selects the project via the `X-Solti-Project-Id` header —
|
|
7
|
+
* exactly the deployed mechanism of ../solti-cli/src/api/client.ts.
|
|
8
|
+
*
|
|
9
|
+
* Auth: `X-Solti-API-Key` header, from the explicit `apiKey` option or the
|
|
10
|
+
* `SOLTI_API_KEY` environment variable.
|
|
11
|
+
*/
|
|
12
|
+
import { ConnectionsResource } from "./resources/connections.js";
|
|
13
|
+
import { CronjobsResource } from "./resources/cronjobs.js";
|
|
14
|
+
import { JobsResource } from "./resources/jobs.js";
|
|
15
|
+
import { KeysResource } from "./resources/keys.js";
|
|
16
|
+
/** Global API host — same default as the CLI (`SOLTI_API_URL_GLOBAL` override supported). */
|
|
17
|
+
export declare const GLOBAL_API_URL: string;
|
|
18
|
+
export interface SoltiClientOptions {
|
|
19
|
+
/** Zitadel-managed PAT. Falls back to the `SOLTI_API_KEY` environment variable. */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
/** API base URL including the `/1` version segment. Defaults to the global host. */
|
|
22
|
+
apiUrl?: string;
|
|
23
|
+
/** Project selection — sent as the `X-Solti-Project-Id` header (no per-project hostnames). */
|
|
24
|
+
projectId?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare class SoltiClient {
|
|
27
|
+
readonly apiKey: string;
|
|
28
|
+
readonly apiUrl: string;
|
|
29
|
+
readonly projectId?: string;
|
|
30
|
+
/** Jobs lifecycle: create / get / list / cancel / waitUntilComplete. */
|
|
31
|
+
readonly jobs: JobsResource;
|
|
32
|
+
/** Connections CRUD. */
|
|
33
|
+
readonly connections: ConnectionsResource;
|
|
34
|
+
/** Cronjobs management (addressable by UUID `id` or unique `name`). */
|
|
35
|
+
readonly cronjobs: CronjobsResource;
|
|
36
|
+
/** API keys (admin-only endpoints). */
|
|
37
|
+
readonly keys: KeysResource;
|
|
38
|
+
constructor(options?: SoltiClientOptions);
|
|
39
|
+
/** Performs an API request. `path` is relative to the `/1` base (e.g. `jobs`). */
|
|
40
|
+
request(path: string, options?: {
|
|
41
|
+
method?: string;
|
|
42
|
+
body?: unknown;
|
|
43
|
+
query?: Record<string, string | number | undefined>;
|
|
44
|
+
}): Promise<unknown>;
|
|
45
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solti SDK client — host strategy, auth, and error mapping.
|
|
3
|
+
*
|
|
4
|
+
* Host strategy (Change 015 WS2): per-project wildcard hosts
|
|
5
|
+
* (`<project-id>.api.solti.run`) are NOT deployed. The SDK always targets the
|
|
6
|
+
* global host and selects the project via the `X-Solti-Project-Id` header —
|
|
7
|
+
* exactly the deployed mechanism of ../solti-cli/src/api/client.ts.
|
|
8
|
+
*
|
|
9
|
+
* Auth: `X-Solti-API-Key` header, from the explicit `apiKey` option or the
|
|
10
|
+
* `SOLTI_API_KEY` environment variable.
|
|
11
|
+
*/
|
|
12
|
+
import { AuthenticationError, PermissionDeniedError, RateLimitError, SoltiApiError, ValidationError } from "./errors.js";
|
|
13
|
+
import { ConnectionsResource } from "./resources/connections.js";
|
|
14
|
+
import { CronjobsResource } from "./resources/cronjobs.js";
|
|
15
|
+
import { JobsResource } from "./resources/jobs.js";
|
|
16
|
+
import { KeysResource } from "./resources/keys.js";
|
|
17
|
+
/** Global API host — same default as the CLI (`SOLTI_API_URL_GLOBAL` override supported). */
|
|
18
|
+
export const GLOBAL_API_URL = process.env.SOLTI_API_URL_GLOBAL ?? "https://api.solti.run/1";
|
|
19
|
+
export class SoltiClient {
|
|
20
|
+
apiKey;
|
|
21
|
+
apiUrl;
|
|
22
|
+
projectId;
|
|
23
|
+
/** Jobs lifecycle: create / get / list / cancel / waitUntilComplete. */
|
|
24
|
+
jobs;
|
|
25
|
+
/** Connections CRUD. */
|
|
26
|
+
connections;
|
|
27
|
+
/** Cronjobs management (addressable by UUID `id` or unique `name`). */
|
|
28
|
+
cronjobs;
|
|
29
|
+
/** API keys (admin-only endpoints). */
|
|
30
|
+
keys;
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
const apiKey = options.apiKey ?? process.env.SOLTI_API_KEY;
|
|
33
|
+
if (apiKey === undefined || apiKey === "") {
|
|
34
|
+
throw new Error("No API key provided. Pass `apiKey` or set the SOLTI_API_KEY environment variable.");
|
|
35
|
+
}
|
|
36
|
+
this.apiKey = apiKey;
|
|
37
|
+
this.apiUrl = (options.apiUrl ?? GLOBAL_API_URL).replace(/\/+$/, "");
|
|
38
|
+
this.projectId = options.projectId === "" ? undefined : options.projectId;
|
|
39
|
+
this.jobs = new JobsResource(this);
|
|
40
|
+
this.connections = new ConnectionsResource(this);
|
|
41
|
+
this.cronjobs = new CronjobsResource(this);
|
|
42
|
+
this.keys = new KeysResource(this);
|
|
43
|
+
}
|
|
44
|
+
/** Performs an API request. `path` is relative to the `/1` base (e.g. `jobs`). */
|
|
45
|
+
async request(path, options = {}) {
|
|
46
|
+
const method = options.method ?? "GET";
|
|
47
|
+
const headers = { "X-Solti-API-Key": this.apiKey };
|
|
48
|
+
if (options.body !== undefined)
|
|
49
|
+
headers["Content-Type"] = "application/json";
|
|
50
|
+
if (this.projectId !== undefined)
|
|
51
|
+
headers["X-Solti-Project-Id"] = this.projectId;
|
|
52
|
+
let url = `${this.apiUrl}/${path.replace(/^\//, "")}`;
|
|
53
|
+
const query = options.query ?? {};
|
|
54
|
+
const params = new URLSearchParams();
|
|
55
|
+
for (const [key, value] of Object.entries(query)) {
|
|
56
|
+
if (value !== undefined && value !== "")
|
|
57
|
+
params.set(key, String(value));
|
|
58
|
+
}
|
|
59
|
+
const queryString = params.toString();
|
|
60
|
+
if (queryString !== "")
|
|
61
|
+
url += `?${queryString}`;
|
|
62
|
+
const isIdempotentRead = method === "GET";
|
|
63
|
+
let attempts = 0;
|
|
64
|
+
let retryAfterMs = 0;
|
|
65
|
+
// Rate-limit friendly behavior (api spec §5): auto-retry idempotent reads
|
|
66
|
+
// honoring `Retry-After` (capped at 30s), generalized from
|
|
67
|
+
// ../solti-cli/src/api/client.ts. Mutations surface `RateLimitError`.
|
|
68
|
+
for (;;) {
|
|
69
|
+
if (retryAfterMs > 0) {
|
|
70
|
+
await new Promise((resolve) => setTimeout(resolve, retryAfterMs));
|
|
71
|
+
}
|
|
72
|
+
attempts += 1;
|
|
73
|
+
const response = await fetch(url, {
|
|
74
|
+
method,
|
|
75
|
+
headers,
|
|
76
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
77
|
+
});
|
|
78
|
+
if (response.status === 429 && isIdempotentRead && attempts <= 2) {
|
|
79
|
+
const retryAfter = Number(response.headers.get("Retry-After") ?? "5");
|
|
80
|
+
retryAfterMs = Math.min(Number.isFinite(retryAfter) ? retryAfter * 1000 : 5000, 30_000);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const text = await response.text();
|
|
84
|
+
let payload = null;
|
|
85
|
+
try {
|
|
86
|
+
payload = text === "" ? null : JSON.parse(text);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
payload = text;
|
|
90
|
+
}
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
if (response.status === 401)
|
|
93
|
+
throw new AuthenticationError(response.status, payload);
|
|
94
|
+
if (response.status === 403)
|
|
95
|
+
throw new PermissionDeniedError(response.status, payload);
|
|
96
|
+
if (response.status === 422)
|
|
97
|
+
throw new ValidationError(response.status, payload);
|
|
98
|
+
if (response.status === 429)
|
|
99
|
+
throw new RateLimitError(response.status, payload, response.headers);
|
|
100
|
+
throw new SoltiApiError(response.status, payload);
|
|
101
|
+
}
|
|
102
|
+
return payload;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error mapping per constitution/tools/sdk.md §5.
|
|
3
|
+
*
|
|
4
|
+
* Every HTTP error surfaces as a `SoltiApiError` subclass (or `SoltiApiError`
|
|
5
|
+
* itself for statuses without a dedicated type). `RateLimitError` carries the
|
|
6
|
+
* server-provided `retry_after` (seconds) and the `X-RateLimit-*` headers.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SoltiApiError extends Error {
|
|
9
|
+
/** HTTP status code of the failed response. */
|
|
10
|
+
readonly status: number;
|
|
11
|
+
/** Parsed response body (JSON object when parseable, raw text otherwise). */
|
|
12
|
+
readonly payload: unknown;
|
|
13
|
+
constructor(status: number, payload: unknown, message?: string);
|
|
14
|
+
}
|
|
15
|
+
/** 401 — the API key (Zitadel PAT) is invalid or has expired. */
|
|
16
|
+
export declare class AuthenticationError extends SoltiApiError {
|
|
17
|
+
constructor(status: number, payload: unknown);
|
|
18
|
+
}
|
|
19
|
+
/** 403 — the key's role is not allowed to perform this operation (e.g. `viewer` on a write). */
|
|
20
|
+
export declare class PermissionDeniedError extends SoltiApiError {
|
|
21
|
+
constructor(status: number, payload: unknown);
|
|
22
|
+
}
|
|
23
|
+
/** 422 — the payload contains invalid configuration (e.g. invalid cron expression, malformed volume). */
|
|
24
|
+
export declare class ValidationError extends SoltiApiError {
|
|
25
|
+
constructor(status: number, payload: unknown);
|
|
26
|
+
}
|
|
27
|
+
/** 429 — rate limit exceeded. Idempotent reads are auto-retried by the client; mutations surface this error. */
|
|
28
|
+
export declare class RateLimitError extends SoltiApiError {
|
|
29
|
+
/** Server-provided `Retry-After` in seconds (defaults to 5 when absent). */
|
|
30
|
+
readonly retryAfter: number;
|
|
31
|
+
/** `X-RateLimit-Limit` header value, when present. */
|
|
32
|
+
readonly limit?: number;
|
|
33
|
+
/** `X-RateLimit-Remaining` header value, when present. */
|
|
34
|
+
readonly remaining?: number;
|
|
35
|
+
/** `X-RateLimit-Reset` header value (unix epoch seconds), when present. */
|
|
36
|
+
readonly reset?: number;
|
|
37
|
+
constructor(status: number, payload: unknown, headers: Headers);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Raised by `waitUntilComplete` when the job reaches a terminal `failed`
|
|
41
|
+
* state (non-zero container exit, execution error, or OOM).
|
|
42
|
+
*/
|
|
43
|
+
export declare class WorkloadFailedError extends Error {
|
|
44
|
+
readonly status: number;
|
|
45
|
+
readonly payload: unknown;
|
|
46
|
+
/** Container exit code, when the Task Manager reported one. */
|
|
47
|
+
readonly exitCode?: number;
|
|
48
|
+
/** Logged error summary, when present. */
|
|
49
|
+
readonly errorSummary?: string;
|
|
50
|
+
/** True when the container was killed by the OOM killer. */
|
|
51
|
+
readonly oom?: boolean;
|
|
52
|
+
/** Final job state at failure time. */
|
|
53
|
+
readonly job?: JobSnapshot;
|
|
54
|
+
constructor(options: {
|
|
55
|
+
exitCode?: number;
|
|
56
|
+
errorSummary?: string;
|
|
57
|
+
oom?: boolean;
|
|
58
|
+
job?: JobSnapshot;
|
|
59
|
+
status?: number;
|
|
60
|
+
payload?: unknown;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Minimal snapshot of the failed job attached to {@link WorkloadFailedError}. */
|
|
64
|
+
export interface JobSnapshot {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
status: string;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
/** Raised by `waitUntilComplete` when the client-side wait timeout is exceeded. */
|
|
71
|
+
export declare class TimeoutError extends Error {
|
|
72
|
+
constructor(message?: string);
|
|
73
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error mapping per constitution/tools/sdk.md §5.
|
|
3
|
+
*
|
|
4
|
+
* Every HTTP error surfaces as a `SoltiApiError` subclass (or `SoltiApiError`
|
|
5
|
+
* itself for statuses without a dedicated type). `RateLimitError` carries the
|
|
6
|
+
* server-provided `retry_after` (seconds) and the `X-RateLimit-*` headers.
|
|
7
|
+
*/
|
|
8
|
+
export class SoltiApiError extends Error {
|
|
9
|
+
/** HTTP status code of the failed response. */
|
|
10
|
+
status;
|
|
11
|
+
/** Parsed response body (JSON object when parseable, raw text otherwise). */
|
|
12
|
+
payload;
|
|
13
|
+
constructor(status, payload, message) {
|
|
14
|
+
super(message ?? `Solti API error (HTTP ${status})`);
|
|
15
|
+
this.name = "SoltiApiError";
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.payload = payload;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** 401 — the API key (Zitadel PAT) is invalid or has expired. */
|
|
21
|
+
export class AuthenticationError extends SoltiApiError {
|
|
22
|
+
constructor(status, payload) {
|
|
23
|
+
super(status, payload, "Authentication failed: the API key is invalid or has expired.");
|
|
24
|
+
this.name = "AuthenticationError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** 403 — the key's role is not allowed to perform this operation (e.g. `viewer` on a write). */
|
|
28
|
+
export class PermissionDeniedError extends SoltiApiError {
|
|
29
|
+
constructor(status, payload) {
|
|
30
|
+
super(status, payload, "Permission denied: this API key's role does not permit this operation.");
|
|
31
|
+
this.name = "PermissionDeniedError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** 422 — the payload contains invalid configuration (e.g. invalid cron expression, malformed volume). */
|
|
35
|
+
export class ValidationError extends SoltiApiError {
|
|
36
|
+
constructor(status, payload) {
|
|
37
|
+
super(status, payload, "Validation failed: the request payload contains invalid configuration.");
|
|
38
|
+
this.name = "ValidationError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** 429 — rate limit exceeded. Idempotent reads are auto-retried by the client; mutations surface this error. */
|
|
42
|
+
export class RateLimitError extends SoltiApiError {
|
|
43
|
+
/** Server-provided `Retry-After` in seconds (defaults to 5 when absent). */
|
|
44
|
+
retryAfter;
|
|
45
|
+
/** `X-RateLimit-Limit` header value, when present. */
|
|
46
|
+
limit;
|
|
47
|
+
/** `X-RateLimit-Remaining` header value, when present. */
|
|
48
|
+
remaining;
|
|
49
|
+
/** `X-RateLimit-Reset` header value (unix epoch seconds), when present. */
|
|
50
|
+
reset;
|
|
51
|
+
constructor(status, payload, headers) {
|
|
52
|
+
super(status, payload, "Rate limit exceeded.");
|
|
53
|
+
this.name = "RateLimitError";
|
|
54
|
+
const retryAfter = Number(headers.get("Retry-After") ?? "5");
|
|
55
|
+
this.retryAfter = Number.isFinite(retryAfter) ? retryAfter : 5;
|
|
56
|
+
const limit = Number(headers.get("X-RateLimit-Limit"));
|
|
57
|
+
if (Number.isFinite(limit))
|
|
58
|
+
this.limit = limit;
|
|
59
|
+
const remaining = Number(headers.get("X-RateLimit-Remaining"));
|
|
60
|
+
if (Number.isFinite(remaining))
|
|
61
|
+
this.remaining = remaining;
|
|
62
|
+
const reset = Number(headers.get("X-RateLimit-Reset"));
|
|
63
|
+
if (Number.isFinite(reset))
|
|
64
|
+
this.reset = reset;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Raised by `waitUntilComplete` when the job reaches a terminal `failed`
|
|
69
|
+
* state (non-zero container exit, execution error, or OOM).
|
|
70
|
+
*/
|
|
71
|
+
export class WorkloadFailedError extends Error {
|
|
72
|
+
status;
|
|
73
|
+
payload;
|
|
74
|
+
/** Container exit code, when the Task Manager reported one. */
|
|
75
|
+
exitCode;
|
|
76
|
+
/** Logged error summary, when present. */
|
|
77
|
+
errorSummary;
|
|
78
|
+
/** True when the container was killed by the OOM killer. */
|
|
79
|
+
oom;
|
|
80
|
+
/** Final job state at failure time. */
|
|
81
|
+
job;
|
|
82
|
+
constructor(options) {
|
|
83
|
+
const code = options.exitCode !== undefined ? ` (exit code ${options.exitCode})` : "";
|
|
84
|
+
const oomSuffix = options.oom === true ? " — container was OOM-killed" : "";
|
|
85
|
+
super(`Workload failed${code}${oomSuffix}${options.errorSummary !== undefined ? `: ${options.errorSummary}` : ""}`);
|
|
86
|
+
this.name = "WorkloadFailedError";
|
|
87
|
+
this.exitCode = options.exitCode;
|
|
88
|
+
this.errorSummary = options.errorSummary;
|
|
89
|
+
this.oom = options.oom;
|
|
90
|
+
this.job = options.job;
|
|
91
|
+
this.status = options.status ?? 0;
|
|
92
|
+
this.payload = options.payload ?? null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Raised by `waitUntilComplete` when the client-side wait timeout is exceeded. */
|
|
96
|
+
export class TimeoutError extends Error {
|
|
97
|
+
constructor(message = "Workload did not complete before the client-side timeout.") {
|
|
98
|
+
super(message);
|
|
99
|
+
this.name = "TimeoutError";
|
|
100
|
+
}
|
|
101
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @solti/sdk — Solti Platform TypeScript SDK.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { SoltiClient } from "@solti/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const client = new SoltiClient({ apiKey: process.env.SOLTI_API_KEY, projectId: "<project-id>" });
|
|
9
|
+
* const job = await client.jobs.create({ image: "alpine:latest", command: ["echo", "hi"] });
|
|
10
|
+
* const finalJob = await job.waitUntilComplete({ timeoutMs: 600_000 });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { SoltiClient, GLOBAL_API_URL, type SoltiClientOptions } from "./client.js";
|
|
14
|
+
export { SoltiApiError, AuthenticationError, PermissionDeniedError, ValidationError, RateLimitError, WorkloadFailedError, TimeoutError, type JobSnapshot, } from "./errors.js";
|
|
15
|
+
export type { VolumeMount, JobResources, GpuRequest, JobDefinition, CreateJobRequest, JobListFilters, JobData, WaitUntilCompleteOptions, } from "./resources/jobs.js";
|
|
16
|
+
export { Job, JobsResource, DEFAULT_POLL_INTERVAL_MS } from "./resources/jobs.js";
|
|
17
|
+
export type { Connection, ConnectionCreateRequest, ConnectionCredentials, AwsCredentials, GcpCredentials, AzureCredentials, R2Credentials, GithubCredentials, } from "./resources/connections.js";
|
|
18
|
+
export { ConnectionsResource } from "./resources/connections.js";
|
|
19
|
+
export type { Cronjob, CreateCronjobRequest, PatchCronjobRequest } from "./resources/cronjobs.js";
|
|
20
|
+
export { CronjobsResource } from "./resources/cronjobs.js";
|
|
21
|
+
export type { Key, CreateKeyRequest, CreateKeyResponse } from "./resources/keys.js";
|
|
22
|
+
export { KeysResource } from "./resources/keys.js";
|
|
23
|
+
export { TERMINAL_STATUSES } from "./resources/shared.js";
|
|
24
|
+
export type { WorkloadStatus, TerminalStatus, VmStatus, CloudProvider, ConnectionType, KeyRole, MacroRegion, } from "./resources/shared.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @solti/sdk — Solti Platform TypeScript SDK.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { SoltiClient } from "@solti/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const client = new SoltiClient({ apiKey: process.env.SOLTI_API_KEY, projectId: "<project-id>" });
|
|
9
|
+
* const job = await client.jobs.create({ image: "alpine:latest", command: ["echo", "hi"] });
|
|
10
|
+
* const finalJob = await job.waitUntilComplete({ timeoutMs: 600_000 });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { SoltiClient, GLOBAL_API_URL } from "./client.js";
|
|
14
|
+
export { SoltiApiError, AuthenticationError, PermissionDeniedError, ValidationError, RateLimitError, WorkloadFailedError, TimeoutError, } from "./errors.js";
|
|
15
|
+
export { Job, JobsResource, DEFAULT_POLL_INTERVAL_MS } from "./resources/jobs.js";
|
|
16
|
+
export { ConnectionsResource } from "./resources/connections.js";
|
|
17
|
+
export { CronjobsResource } from "./resources/cronjobs.js";
|
|
18
|
+
export { KeysResource } from "./resources/keys.js";
|
|
19
|
+
export { TERMINAL_STATUSES } from "./resources/shared.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connections resource — CRUD for cloud/storage credential integrations
|
|
3
|
+
* (api spec §3.1). Credentials are write-only: the API stores them encrypted
|
|
4
|
+
* and redacts them on read.
|
|
5
|
+
*
|
|
6
|
+
* Wire payload follows ../solti-cli/src/commands/connection.ts: credential
|
|
7
|
+
* fields are sent flat at the top level (`access_key_id`, `access_token`, …).
|
|
8
|
+
* The SDK accepts them nested under `credentials` and flattens for the wire.
|
|
9
|
+
*/
|
|
10
|
+
import type { SoltiClient } from "../client.js";
|
|
11
|
+
import { type ConnectionType } from "./shared.js";
|
|
12
|
+
/** `type: "aws"` credential fields (cli wire format). */
|
|
13
|
+
export interface AwsCredentials {
|
|
14
|
+
access_key_id: string;
|
|
15
|
+
secret_access_key: string;
|
|
16
|
+
region?: string;
|
|
17
|
+
}
|
|
18
|
+
/** `type: "gcp"` credential fields (cli wire format). */
|
|
19
|
+
export interface GcpCredentials {
|
|
20
|
+
gcp_project_id: string;
|
|
21
|
+
/** Service-account key JSON (stringified) or omitted for ADC-style creds. */
|
|
22
|
+
keyfile_json?: string;
|
|
23
|
+
}
|
|
24
|
+
/** `type: "azure"` credential fields (cli wire format). */
|
|
25
|
+
export interface AzureCredentials {
|
|
26
|
+
client_id: string;
|
|
27
|
+
client_secret: string;
|
|
28
|
+
subscription_id: string;
|
|
29
|
+
tenant_id: string;
|
|
30
|
+
}
|
|
31
|
+
/** `type: "r2"` (Cloudflare R2) credential fields (cli wire format). */
|
|
32
|
+
export interface R2Credentials {
|
|
33
|
+
account_id: string;
|
|
34
|
+
access_key_id: string;
|
|
35
|
+
secret_access_key: string;
|
|
36
|
+
}
|
|
37
|
+
/** `type: "github"` credential fields (cli wire format). */
|
|
38
|
+
export interface GithubCredentials {
|
|
39
|
+
access_token: string;
|
|
40
|
+
}
|
|
41
|
+
/** Provider-specific credentials, flattened into the wire payload (cli convention). */
|
|
42
|
+
export type ConnectionCredentials = AwsCredentials | GcpCredentials | AzureCredentials | R2Credentials | GithubCredentials;
|
|
43
|
+
/** A stored connection (credentials are redacted by the API on read). */
|
|
44
|
+
export interface Connection {
|
|
45
|
+
name: string;
|
|
46
|
+
type: ConnectionType;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
/** Remaining provider-specific fields (credentials are redacted by the API). */
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
export interface ConnectionCreateRequest {
|
|
52
|
+
name: string;
|
|
53
|
+
type: ConnectionType;
|
|
54
|
+
/** Provider credential fields, flattened into the wire payload (CLI convention). */
|
|
55
|
+
credentials?: ConnectionCredentials;
|
|
56
|
+
/** Flat credential fields are also accepted directly (CLI convention). */
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
export declare class ConnectionsResource {
|
|
60
|
+
private readonly client;
|
|
61
|
+
constructor(client: SoltiClient);
|
|
62
|
+
create(request: ConnectionCreateRequest): Promise<Connection>;
|
|
63
|
+
get(name: string): Promise<Connection>;
|
|
64
|
+
list(): Promise<Connection[]>;
|
|
65
|
+
delete(name: string): Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connections resource — CRUD for cloud/storage credential integrations
|
|
3
|
+
* (api spec §3.1). Credentials are write-only: the API stores them encrypted
|
|
4
|
+
* and redacts them on read.
|
|
5
|
+
*
|
|
6
|
+
* Wire payload follows ../solti-cli/src/commands/connection.ts: credential
|
|
7
|
+
* fields are sent flat at the top level (`access_key_id`, `access_token`, …).
|
|
8
|
+
* The SDK accepts them nested under `credentials` and flattens for the wire.
|
|
9
|
+
*/
|
|
10
|
+
import { rawUnion, rawString } from "./shared.js";
|
|
11
|
+
function mapConnection(raw) {
|
|
12
|
+
const { created_at: createdAt, ...rest } = raw;
|
|
13
|
+
return {
|
|
14
|
+
...rest,
|
|
15
|
+
name: rawString(raw, "name") ?? "",
|
|
16
|
+
type: rawUnion(raw, "type") ?? "",
|
|
17
|
+
createdAt: createdAt,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export class ConnectionsResource {
|
|
21
|
+
client;
|
|
22
|
+
constructor(client) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
}
|
|
25
|
+
async create(request) {
|
|
26
|
+
const { credentials, ...flat } = request;
|
|
27
|
+
const body = { ...flat, ...credentials };
|
|
28
|
+
const raw = (await this.client.request("connections", { method: "POST", body }));
|
|
29
|
+
return mapConnection(raw);
|
|
30
|
+
}
|
|
31
|
+
async get(name) {
|
|
32
|
+
const raw = (await this.client.request(`connections/${encodeURIComponent(name)}`));
|
|
33
|
+
return mapConnection(raw);
|
|
34
|
+
}
|
|
35
|
+
async list() {
|
|
36
|
+
const data = (await this.client.request("connections"));
|
|
37
|
+
const items = Array.isArray(data) ? data : (data.connections ?? []);
|
|
38
|
+
return items.map(mapConnection);
|
|
39
|
+
}
|
|
40
|
+
async delete(name) {
|
|
41
|
+
await this.client.request(`connections/${encodeURIComponent(name)}`, { method: "DELETE" });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cronjobs resource — periodic task definitions with UTC crontab schedules
|
|
3
|
+
* and a strict `jobDefinition` template (api spec §3.3).
|
|
4
|
+
*
|
|
5
|
+
* All methods accept either the cronjob's unique UUID (`id`) or its unique
|
|
6
|
+
* `name`. The create payload must not contain a fixed `name` inside
|
|
7
|
+
* `jobDefinition` — each trigger spawns `<cronjob-name>-<UTC timestamp>`.
|
|
8
|
+
*/
|
|
9
|
+
import type { SoltiClient } from "../client.js";
|
|
10
|
+
import type { JobDefinition } from "./jobs.js";
|
|
11
|
+
export interface Cronjob {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
/** UTC crontab expression. */
|
|
15
|
+
cronSpec: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
lastTriggeredAt?: string;
|
|
18
|
+
/** Job template spawned on each trigger (a job definition without `name`). */
|
|
19
|
+
jobDefinition?: JobDefinition;
|
|
20
|
+
createdAt?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface CreateCronjobRequest {
|
|
24
|
+
name: string;
|
|
25
|
+
/** UTC crontab expression (e.g. `"0 2 * * *"`). */
|
|
26
|
+
cronSpec: string;
|
|
27
|
+
/** Default true. */
|
|
28
|
+
isActive?: boolean;
|
|
29
|
+
/** Strict job template (a {@link JobDefinition}) — must not contain `name`. */
|
|
30
|
+
jobDefinition: JobDefinition;
|
|
31
|
+
}
|
|
32
|
+
export interface PatchCronjobRequest {
|
|
33
|
+
cronSpec?: string;
|
|
34
|
+
isActive?: boolean;
|
|
35
|
+
jobDefinition?: JobDefinition;
|
|
36
|
+
}
|
|
37
|
+
export declare class CronjobsResource {
|
|
38
|
+
private readonly client;
|
|
39
|
+
constructor(client: SoltiClient);
|
|
40
|
+
create(request: CreateCronjobRequest): Promise<Cronjob>;
|
|
41
|
+
/** Accepts either the cronjob's unique UUID or its unique name. */
|
|
42
|
+
get(idOrName: string): Promise<Cronjob>;
|
|
43
|
+
list(): Promise<Cronjob[]>;
|
|
44
|
+
/** Updates schedule / active flag / job template without recreating the resource. */
|
|
45
|
+
patch(idOrName: string, request: PatchCronjobRequest): Promise<Cronjob>;
|
|
46
|
+
/** Alias for {@link CronjobsResource.patch} (sdk.md §2 `.update`). */
|
|
47
|
+
update(idOrName: string, request: PatchCronjobRequest): Promise<Cronjob>;
|
|
48
|
+
/** Accepts either the cronjob's unique UUID or its unique name. */
|
|
49
|
+
delete(idOrName: string): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cronjobs resource — periodic task definitions with UTC crontab schedules
|
|
3
|
+
* and a strict `jobDefinition` template (api spec §3.3).
|
|
4
|
+
*
|
|
5
|
+
* All methods accept either the cronjob's unique UUID (`id`) or its unique
|
|
6
|
+
* `name`. The create payload must not contain a fixed `name` inside
|
|
7
|
+
* `jobDefinition` — each trigger spawns `<cronjob-name>-<UTC timestamp>`.
|
|
8
|
+
*/
|
|
9
|
+
import { rawString } from "./shared.js";
|
|
10
|
+
function mapCronjob(raw) {
|
|
11
|
+
const { cron_spec: cronSpec, is_active: isActive, last_triggered_at: lastTriggeredAt, created_at: createdAt, ...rest } = raw;
|
|
12
|
+
return {
|
|
13
|
+
...rest,
|
|
14
|
+
id: rawString(raw, "id") ?? "",
|
|
15
|
+
name: rawString(raw, "name") ?? "",
|
|
16
|
+
cronSpec: typeof cronSpec === "string" ? cronSpec : "",
|
|
17
|
+
isActive: isActive === true,
|
|
18
|
+
lastTriggeredAt: lastTriggeredAt,
|
|
19
|
+
jobDefinition: raw.job_definition,
|
|
20
|
+
createdAt: createdAt,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export class CronjobsResource {
|
|
24
|
+
client;
|
|
25
|
+
constructor(client) {
|
|
26
|
+
this.client = client;
|
|
27
|
+
}
|
|
28
|
+
async create(request) {
|
|
29
|
+
const body = {
|
|
30
|
+
name: request.name,
|
|
31
|
+
cron_spec: request.cronSpec,
|
|
32
|
+
is_active: request.isActive ?? true,
|
|
33
|
+
job_definition: request.jobDefinition,
|
|
34
|
+
};
|
|
35
|
+
const raw = (await this.client.request("cronjobs", { method: "POST", body }));
|
|
36
|
+
return mapCronjob(raw);
|
|
37
|
+
}
|
|
38
|
+
/** Accepts either the cronjob's unique UUID or its unique name. */
|
|
39
|
+
async get(idOrName) {
|
|
40
|
+
const raw = (await this.client.request(`cronjobs/${encodeURIComponent(idOrName)}`));
|
|
41
|
+
return mapCronjob(raw);
|
|
42
|
+
}
|
|
43
|
+
async list() {
|
|
44
|
+
const data = (await this.client.request("cronjobs"));
|
|
45
|
+
const items = Array.isArray(data) ? data : (data.cronjobs ?? []);
|
|
46
|
+
return items.map(mapCronjob);
|
|
47
|
+
}
|
|
48
|
+
/** Updates schedule / active flag / job template without recreating the resource. */
|
|
49
|
+
async patch(idOrName, request) {
|
|
50
|
+
const body = {};
|
|
51
|
+
if (request.cronSpec !== undefined)
|
|
52
|
+
body.cron_spec = request.cronSpec;
|
|
53
|
+
if (request.isActive !== undefined)
|
|
54
|
+
body.is_active = request.isActive;
|
|
55
|
+
if (request.jobDefinition !== undefined)
|
|
56
|
+
body.job_definition = request.jobDefinition;
|
|
57
|
+
const raw = (await this.client.request(`cronjobs/${encodeURIComponent(idOrName)}`, {
|
|
58
|
+
method: "PATCH",
|
|
59
|
+
body,
|
|
60
|
+
}));
|
|
61
|
+
return mapCronjob(raw);
|
|
62
|
+
}
|
|
63
|
+
/** Alias for {@link CronjobsResource.patch} (sdk.md §2 `.update`). */
|
|
64
|
+
async update(idOrName, request) {
|
|
65
|
+
return this.patch(idOrName, request);
|
|
66
|
+
}
|
|
67
|
+
/** Accepts either the cronjob's unique UUID or its unique name. */
|
|
68
|
+
async delete(idOrName) {
|
|
69
|
+
await this.client.request(`cronjobs/${encodeURIComponent(idOrName)}`, { method: "DELETE" });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jobs resource — submit, inspect, list, cancel workloads, and block on
|
|
3
|
+
* completion with `waitUntilComplete` (sdk.md §4.1).
|
|
4
|
+
*
|
|
5
|
+
* Request payloads use camelCase wire keys (`namePrefix`, `maxRetries`,
|
|
6
|
+
* `mountPath` — api spec §3.0); responses are snake_case and are mapped to
|
|
7
|
+
* camelCase SDK types (`vmStatus`, `estimatedCost`, `exitCode`).
|
|
8
|
+
*/
|
|
9
|
+
import type { SoltiClient } from "../client.js";
|
|
10
|
+
import { type CloudProvider, type RawRecord, type VmStatus, type WorkloadStatus } from "./shared.js";
|
|
11
|
+
/** Default client-side polling interval (sdk.md §3.1: 10s). */
|
|
12
|
+
export declare const DEFAULT_POLL_INTERVAL_MS = 10000;
|
|
13
|
+
/** A storage volume mount, keyed by volume name in the `volumes` map. */
|
|
14
|
+
export interface VolumeMount {
|
|
15
|
+
/** Required: source bucket. */
|
|
16
|
+
bucket: string;
|
|
17
|
+
/** Required: in-container mount path. */
|
|
18
|
+
mountPath: string;
|
|
19
|
+
/** Optional: connection name (defaults to the first connection with bucket access). */
|
|
20
|
+
connection?: string;
|
|
21
|
+
/** Optional: bucket prefix (defaults to the bucket root). */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Nested GPU request (api spec §3.2 `resources.gpu` long form). Hard
|
|
26
|
+
* constraints are never silently relaxed: unsatisfiable requests fail at
|
|
27
|
+
* scheduling with an explicit configuration error.
|
|
28
|
+
*/
|
|
29
|
+
export interface GpuRequest {
|
|
30
|
+
/** Minimum aggregate GPU VRAM (e.g. `"24Gi"`); required unless `model` is given. */
|
|
31
|
+
vram?: string;
|
|
32
|
+
/** Hard constraint on GPU model (e.g. `"A100"`); matched case-insensitively. */
|
|
33
|
+
model?: string;
|
|
34
|
+
/** Hard constraint on the minimum number of physical GPUs (requires `model`). */
|
|
35
|
+
count?: number;
|
|
36
|
+
}
|
|
37
|
+
/** Compute resources; `gpu` is the VRAM shorthand or a nested {@link GpuRequest}. */
|
|
38
|
+
export interface JobResources {
|
|
39
|
+
cpu?: number;
|
|
40
|
+
memory?: string;
|
|
41
|
+
gpu?: string | GpuRequest;
|
|
42
|
+
}
|
|
43
|
+
export interface CreateJobRequest {
|
|
44
|
+
/** Optional unique job name (unique per project). */
|
|
45
|
+
name?: string;
|
|
46
|
+
/** Optional prefix — auto-generates a unique `<prefix>-<random_suffix>` name. */
|
|
47
|
+
namePrefix?: string;
|
|
48
|
+
image: string;
|
|
49
|
+
command?: string[];
|
|
50
|
+
args?: string[];
|
|
51
|
+
env?: Record<string, string>;
|
|
52
|
+
/** Map keyed by volume name. */
|
|
53
|
+
volumes?: Record<string, VolumeMount>;
|
|
54
|
+
resources?: JobResources;
|
|
55
|
+
/** Optional provider constraints (e.g. `["aws", "gcp"]`). */
|
|
56
|
+
cloud?: CloudProvider | CloudProvider[];
|
|
57
|
+
/** Optional specific region(s) or macro-region. */
|
|
58
|
+
region?: string | string[];
|
|
59
|
+
/** Container retries inside the VM. */
|
|
60
|
+
maxRetries?: number;
|
|
61
|
+
labels?: Record<string, string>;
|
|
62
|
+
tags?: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Cronjob job template — a standard job definition without `name` (api spec
|
|
65
|
+
* §3.3: each trigger spawns `<cronjob-name>-<UTC timestamp>`). */
|
|
66
|
+
export type JobDefinition = Omit<CreateJobRequest, "name" | "namePrefix">;
|
|
67
|
+
export interface JobListFilters {
|
|
68
|
+
status?: WorkloadStatus;
|
|
69
|
+
/** Tag filter (single value). */
|
|
70
|
+
tag?: string;
|
|
71
|
+
/** Label filter in the `key:value` form. */
|
|
72
|
+
label?: string;
|
|
73
|
+
/** Page size (default 50, max 200). */
|
|
74
|
+
limit?: number;
|
|
75
|
+
offset?: number;
|
|
76
|
+
}
|
|
77
|
+
/** Mapped job state (camelCase view of the snake_case API response). */
|
|
78
|
+
export interface JobData {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
status: WorkloadStatus;
|
|
82
|
+
image?: string;
|
|
83
|
+
vmStatus?: VmStatus;
|
|
84
|
+
estimatedCost?: number;
|
|
85
|
+
actualCost?: number;
|
|
86
|
+
retryCount?: number;
|
|
87
|
+
maxRetries?: number;
|
|
88
|
+
errorSummary?: string;
|
|
89
|
+
exitCode?: number;
|
|
90
|
+
/** OOM flag reported by the Task Manager. */
|
|
91
|
+
oom?: boolean;
|
|
92
|
+
/** OOM-killed flag (alternate wire key for the same signal). */
|
|
93
|
+
oomKilled?: boolean;
|
|
94
|
+
labels?: Record<string, string>;
|
|
95
|
+
tags?: string[];
|
|
96
|
+
createdAt?: string;
|
|
97
|
+
startedAt?: string;
|
|
98
|
+
finishedAt?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface WaitUntilCompleteOptions {
|
|
101
|
+
/** Client-side wait timeout; a `TimeoutError` is thrown when exceeded. */
|
|
102
|
+
timeoutMs?: number;
|
|
103
|
+
/** Polling interval. Default 10s. */
|
|
104
|
+
pollIntervalMs?: number;
|
|
105
|
+
/** Invoked whenever the reported status changes. */
|
|
106
|
+
onProgress?: (status: WorkloadStatus) => void;
|
|
107
|
+
/** Best-effort `jobs.cancel` when the timeout fires. Default false. */
|
|
108
|
+
cancelOnTimeout?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export declare function mapJob(raw: RawRecord): JobData;
|
|
111
|
+
/** A submitted/fetched job; carries `waitUntilComplete` for lifecycle control. */
|
|
112
|
+
export declare class Job implements JobData {
|
|
113
|
+
private readonly client;
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly status: WorkloadStatus;
|
|
117
|
+
readonly image?: string;
|
|
118
|
+
readonly vmStatus?: VmStatus;
|
|
119
|
+
readonly estimatedCost?: number;
|
|
120
|
+
readonly actualCost?: number;
|
|
121
|
+
readonly retryCount?: number;
|
|
122
|
+
readonly maxRetries?: number;
|
|
123
|
+
readonly errorSummary?: string;
|
|
124
|
+
readonly exitCode?: number;
|
|
125
|
+
readonly oom?: boolean;
|
|
126
|
+
readonly oomKilled?: boolean;
|
|
127
|
+
readonly labels?: Record<string, string>;
|
|
128
|
+
readonly tags?: string[];
|
|
129
|
+
readonly createdAt?: string;
|
|
130
|
+
readonly startedAt?: string;
|
|
131
|
+
readonly finishedAt?: string;
|
|
132
|
+
constructor(data: JobData, client: SoltiClient);
|
|
133
|
+
/**
|
|
134
|
+
* Polls until the job reaches a terminal state (default interval 10s).
|
|
135
|
+
* Throws `WorkloadFailedError` on a terminal `failed` state (non-zero exit,
|
|
136
|
+
* execution error, or OOM) and `TimeoutError` when `timeoutMs` is exceeded
|
|
137
|
+
* (optionally cancelling the job first via `cancelOnTimeout`).
|
|
138
|
+
*/
|
|
139
|
+
waitUntilComplete(options?: WaitUntilCompleteOptions): Promise<Job>;
|
|
140
|
+
}
|
|
141
|
+
/** Shared polling loop used by `Job.waitUntilComplete` and `jobs.waitUntilComplete`. */
|
|
142
|
+
export declare function waitUntilComplete(client: SoltiClient, idOrName: string, options?: WaitUntilCompleteOptions): Promise<Job>;
|
|
143
|
+
export declare class JobsResource {
|
|
144
|
+
private readonly client;
|
|
145
|
+
constructor(client: SoltiClient);
|
|
146
|
+
create(request: CreateJobRequest): Promise<Job>;
|
|
147
|
+
/** Accepts either the job's unique UUID or its unique name. */
|
|
148
|
+
get(idOrName: string): Promise<Job>;
|
|
149
|
+
list(filters?: JobListFilters): Promise<Job[]>;
|
|
150
|
+
/** Cancels a running, booting, or queued job (by UUID or name). */
|
|
151
|
+
cancel(idOrName: string): Promise<void>;
|
|
152
|
+
/** Polls `jobs.get` until the job reaches a terminal state. See {@link Job.waitUntilComplete}. */
|
|
153
|
+
waitUntilComplete(idOrName: string, options?: WaitUntilCompleteOptions): Promise<Job>;
|
|
154
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jobs resource — submit, inspect, list, cancel workloads, and block on
|
|
3
|
+
* completion with `waitUntilComplete` (sdk.md §4.1).
|
|
4
|
+
*
|
|
5
|
+
* Request payloads use camelCase wire keys (`namePrefix`, `maxRetries`,
|
|
6
|
+
* `mountPath` — api spec §3.0); responses are snake_case and are mapped to
|
|
7
|
+
* camelCase SDK types (`vmStatus`, `estimatedCost`, `exitCode`).
|
|
8
|
+
*/
|
|
9
|
+
import { TimeoutError, WorkloadFailedError } from "../errors.js";
|
|
10
|
+
import { TERMINAL_STATUSES, rawBoolean, rawNumber, rawString, rawUnion, } from "./shared.js";
|
|
11
|
+
/** Default client-side polling interval (sdk.md §3.1: 10s). */
|
|
12
|
+
export const DEFAULT_POLL_INTERVAL_MS = 10_000;
|
|
13
|
+
export function mapJob(raw) {
|
|
14
|
+
return {
|
|
15
|
+
id: rawString(raw, "id") ?? rawString(raw, "job_id") ?? "",
|
|
16
|
+
name: rawString(raw, "name") ?? "",
|
|
17
|
+
status: rawUnion(raw, "status") ?? "",
|
|
18
|
+
image: rawString(raw, "image"),
|
|
19
|
+
vmStatus: rawUnion(raw, "vm_status"),
|
|
20
|
+
estimatedCost: rawNumber(raw, "estimated_cost"),
|
|
21
|
+
actualCost: rawNumber(raw, "actual_cost"),
|
|
22
|
+
retryCount: rawNumber(raw, "retry_count"),
|
|
23
|
+
maxRetries: rawNumber(raw, "max_retries"),
|
|
24
|
+
errorSummary: rawString(raw, "error_summary"),
|
|
25
|
+
exitCode: rawNumber(raw, "exit_code"),
|
|
26
|
+
oom: rawBoolean(raw, "oom"),
|
|
27
|
+
oomKilled: rawBoolean(raw, "oom_killed"),
|
|
28
|
+
labels: raw.labels,
|
|
29
|
+
tags: raw.tags,
|
|
30
|
+
createdAt: rawString(raw, "created_at"),
|
|
31
|
+
startedAt: rawString(raw, "started_at"),
|
|
32
|
+
finishedAt: rawString(raw, "finished_at"),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A submitted/fetched job; carries `waitUntilComplete` for lifecycle control. */
|
|
36
|
+
export class Job {
|
|
37
|
+
client;
|
|
38
|
+
id;
|
|
39
|
+
name;
|
|
40
|
+
status;
|
|
41
|
+
image;
|
|
42
|
+
vmStatus;
|
|
43
|
+
estimatedCost;
|
|
44
|
+
actualCost;
|
|
45
|
+
retryCount;
|
|
46
|
+
maxRetries;
|
|
47
|
+
errorSummary;
|
|
48
|
+
exitCode;
|
|
49
|
+
oom;
|
|
50
|
+
oomKilled;
|
|
51
|
+
labels;
|
|
52
|
+
tags;
|
|
53
|
+
createdAt;
|
|
54
|
+
startedAt;
|
|
55
|
+
finishedAt;
|
|
56
|
+
constructor(data, client) {
|
|
57
|
+
this.client = client;
|
|
58
|
+
this.id = data.id;
|
|
59
|
+
this.name = data.name;
|
|
60
|
+
this.status = data.status;
|
|
61
|
+
this.image = data.image;
|
|
62
|
+
this.vmStatus = data.vmStatus;
|
|
63
|
+
this.estimatedCost = data.estimatedCost;
|
|
64
|
+
this.actualCost = data.actualCost;
|
|
65
|
+
this.retryCount = data.retryCount;
|
|
66
|
+
this.maxRetries = data.maxRetries;
|
|
67
|
+
this.errorSummary = data.errorSummary;
|
|
68
|
+
this.exitCode = data.exitCode;
|
|
69
|
+
this.oom = data.oom;
|
|
70
|
+
this.oomKilled = data.oomKilled;
|
|
71
|
+
this.labels = data.labels;
|
|
72
|
+
this.tags = data.tags;
|
|
73
|
+
this.createdAt = data.createdAt;
|
|
74
|
+
this.startedAt = data.startedAt;
|
|
75
|
+
this.finishedAt = data.finishedAt;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Polls until the job reaches a terminal state (default interval 10s).
|
|
79
|
+
* Throws `WorkloadFailedError` on a terminal `failed` state (non-zero exit,
|
|
80
|
+
* execution error, or OOM) and `TimeoutError` when `timeoutMs` is exceeded
|
|
81
|
+
* (optionally cancelling the job first via `cancelOnTimeout`).
|
|
82
|
+
*/
|
|
83
|
+
async waitUntilComplete(options = {}) {
|
|
84
|
+
return waitUntilComplete(this.client, this.id, options);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Shared polling loop used by `Job.waitUntilComplete` and `jobs.waitUntilComplete`. */
|
|
88
|
+
export async function waitUntilComplete(client, idOrName, options = {}) {
|
|
89
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
90
|
+
const deadline = options.timeoutMs !== undefined ? Date.now() + options.timeoutMs : undefined;
|
|
91
|
+
let lastStatus;
|
|
92
|
+
for (;;) {
|
|
93
|
+
const job = await client.jobs.get(idOrName);
|
|
94
|
+
if (job.status !== lastStatus) {
|
|
95
|
+
options.onProgress?.(job.status);
|
|
96
|
+
lastStatus = job.status;
|
|
97
|
+
}
|
|
98
|
+
if (TERMINAL_STATUSES.includes(job.status)) {
|
|
99
|
+
if (job.status === "failed") {
|
|
100
|
+
throw new WorkloadFailedError({
|
|
101
|
+
exitCode: job.exitCode,
|
|
102
|
+
errorSummary: job.errorSummary,
|
|
103
|
+
oom: job.oom === true || job.oomKilled === true ? true : undefined,
|
|
104
|
+
job: {
|
|
105
|
+
id: job.id,
|
|
106
|
+
name: job.name,
|
|
107
|
+
status: job.status,
|
|
108
|
+
exitCode: job.exitCode,
|
|
109
|
+
errorSummary: job.errorSummary,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return job;
|
|
114
|
+
}
|
|
115
|
+
if (deadline !== undefined) {
|
|
116
|
+
const remaining = deadline - Date.now();
|
|
117
|
+
if (remaining <= 0) {
|
|
118
|
+
if (options.cancelOnTimeout === true) {
|
|
119
|
+
// Best-effort: the TimeoutError is the primary outcome; a failing
|
|
120
|
+
// cancel (e.g. job completed between polls) must not mask it.
|
|
121
|
+
try {
|
|
122
|
+
await client.jobs.cancel(idOrName);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// ignored deliberately
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
throw new TimeoutError(`Job ${idOrName} did not complete within the client-side timeout (${options.timeoutMs}ms).`);
|
|
129
|
+
}
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(pollIntervalMs, remaining)));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export class JobsResource {
|
|
138
|
+
client;
|
|
139
|
+
constructor(client) {
|
|
140
|
+
this.client = client;
|
|
141
|
+
}
|
|
142
|
+
async create(request) {
|
|
143
|
+
const raw = (await this.client.request("jobs", { method: "POST", body: request }));
|
|
144
|
+
return new Job(mapJob(raw), this.client);
|
|
145
|
+
}
|
|
146
|
+
/** Accepts either the job's unique UUID or its unique name. */
|
|
147
|
+
async get(idOrName) {
|
|
148
|
+
const raw = (await this.client.request(`jobs/${encodeURIComponent(idOrName)}`));
|
|
149
|
+
return new Job(mapJob(raw), this.client);
|
|
150
|
+
}
|
|
151
|
+
async list(filters = {}) {
|
|
152
|
+
const data = (await this.client.request("jobs", {
|
|
153
|
+
query: {
|
|
154
|
+
status: filters.status,
|
|
155
|
+
tag: filters.tag,
|
|
156
|
+
label: filters.label,
|
|
157
|
+
limit: filters.limit,
|
|
158
|
+
offset: filters.offset,
|
|
159
|
+
},
|
|
160
|
+
}));
|
|
161
|
+
const items = Array.isArray(data) ? data : (data.jobs ?? []);
|
|
162
|
+
return items.map((raw) => new Job(mapJob(raw), this.client));
|
|
163
|
+
}
|
|
164
|
+
/** Cancels a running, booting, or queued job (by UUID or name). */
|
|
165
|
+
async cancel(idOrName) {
|
|
166
|
+
await this.client.request(`jobs/${encodeURIComponent(idOrName)}/cancel`, { method: "POST" });
|
|
167
|
+
}
|
|
168
|
+
/** Polls `jobs.get` until the job reaches a terminal state. See {@link Job.waitUntilComplete}. */
|
|
169
|
+
async waitUntilComplete(idOrName, options = {}) {
|
|
170
|
+
return waitUntilComplete(this.client, idOrName, options);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys resource — API key management (admin-only; api spec §3.4). Proxies
|
|
3
|
+
* Zitadel machine users / PATs. The clear-text token is returned exactly once
|
|
4
|
+
* at creation.
|
|
5
|
+
*/
|
|
6
|
+
import type { SoltiClient } from "../client.js";
|
|
7
|
+
import { type KeyRole } from "./shared.js";
|
|
8
|
+
export interface Key {
|
|
9
|
+
name: string;
|
|
10
|
+
role?: KeyRole;
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateKeyRequest {
|
|
15
|
+
name: string;
|
|
16
|
+
/** Role assigned to the machine user (`admin` | `developer` | `viewer`). */
|
|
17
|
+
role: KeyRole;
|
|
18
|
+
/** Optional expiry (ISO 8601). */
|
|
19
|
+
expiresAt?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateKeyResponse {
|
|
22
|
+
name: string;
|
|
23
|
+
/** Clear-text PAT, shown only once. */
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
/** Alternate wire key for the same token. */
|
|
26
|
+
token?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class KeysResource {
|
|
29
|
+
private readonly client;
|
|
30
|
+
constructor(client: SoltiClient);
|
|
31
|
+
create(request: CreateKeyRequest): Promise<CreateKeyResponse>;
|
|
32
|
+
list(): Promise<Key[]>;
|
|
33
|
+
/** Accepts either the key UUID or the key name. */
|
|
34
|
+
delete(idOrName: string): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys resource — API key management (admin-only; api spec §3.4). Proxies
|
|
3
|
+
* Zitadel machine users / PATs. The clear-text token is returned exactly once
|
|
4
|
+
* at creation.
|
|
5
|
+
*/
|
|
6
|
+
import { rawUnion, rawString } from "./shared.js";
|
|
7
|
+
function mapKey(raw) {
|
|
8
|
+
const { created_at: createdAt, ...rest } = raw;
|
|
9
|
+
return {
|
|
10
|
+
...rest,
|
|
11
|
+
name: rawString(raw, "name") ?? "",
|
|
12
|
+
role: rawUnion(raw, "role"),
|
|
13
|
+
createdAt: createdAt,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export class KeysResource {
|
|
17
|
+
client;
|
|
18
|
+
constructor(client) {
|
|
19
|
+
this.client = client;
|
|
20
|
+
}
|
|
21
|
+
async create(request) {
|
|
22
|
+
const body = { name: request.name, role: request.role };
|
|
23
|
+
if (request.expiresAt !== undefined)
|
|
24
|
+
body.expires_at = request.expiresAt;
|
|
25
|
+
const raw = (await this.client.request("keys", { method: "POST", body }));
|
|
26
|
+
return {
|
|
27
|
+
name: rawString(raw, "name") ?? "",
|
|
28
|
+
apiKey: rawString(raw, "api_key"),
|
|
29
|
+
token: rawString(raw, "token"),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async list() {
|
|
33
|
+
const data = (await this.client.request("keys"));
|
|
34
|
+
const items = Array.isArray(data) ? data : (data.keys ?? []);
|
|
35
|
+
return items.map(mapKey);
|
|
36
|
+
}
|
|
37
|
+
/** Accepts either the key UUID or the key name. */
|
|
38
|
+
async delete(idOrName) {
|
|
39
|
+
await this.client.request(`keys/${encodeURIComponent(idOrName)}`, { method: "DELETE" });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resource types — deep typing: nested interfaces plus string-union
|
|
3
|
+
* types for every finite value set (api spec §3, scheduler spec lifecycles).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Well-known workload statuses reported by the Task Manager / scheduler
|
|
7
|
+
* (scheduler spec — `queued` → `booting` → `running` → terminal).
|
|
8
|
+
*/
|
|
9
|
+
export type WorkloadStatus = "queued" | "booting" | "running" | "succeeded" | "failed" | "cancelled";
|
|
10
|
+
/** Statuses from which no further transitions occur. */
|
|
11
|
+
export type TerminalStatus = "succeeded" | "failed" | "cancelled";
|
|
12
|
+
/**
|
|
13
|
+
* Infrastructure lifecycle (`vm_status`) — strictly monotonic (scheduler
|
|
14
|
+
* spec): `nonassigned` → `provisioning` → `provisioned` → `terminating` →
|
|
15
|
+
* `terminated`; `error` is reachable only from pre-`terminating` states.
|
|
16
|
+
*/
|
|
17
|
+
export type VmStatus = "nonassigned" | "provisioning" | "provisioned" | "terminating" | "terminated" | "error";
|
|
18
|
+
/** Cloud providers accepted by job routing and connections (api spec §3.2). */
|
|
19
|
+
export type CloudProvider = "aws" | "gcp" | "azure";
|
|
20
|
+
/** Connection integration types (cli `solti connection create --type`). */
|
|
21
|
+
export type ConnectionType = "aws" | "gcp" | "azure" | "r2" | "github";
|
|
22
|
+
/** Key roles (api `keys/models.py`: `Role = Literal["admin", "developer", "viewer"]`). */
|
|
23
|
+
export type KeyRole = "admin" | "developer" | "viewer";
|
|
24
|
+
/** Macro-regions accepted as `region` routing constraints (api spec §3.2). */
|
|
25
|
+
export type MacroRegion = "americas" | "europe" | "apac" | "africa" | "middle-east";
|
|
26
|
+
/** Statuses from which no further transitions occur (typed constant). */
|
|
27
|
+
export declare const TERMINAL_STATUSES: readonly TerminalStatus[];
|
|
28
|
+
/** Raw API responses are snake_case; helpers below map to camelCase SDK types. */
|
|
29
|
+
export type RawRecord = Record<string, unknown>;
|
|
30
|
+
export declare function rawString(raw: RawRecord, key: string): string | undefined;
|
|
31
|
+
export declare function rawNumber(raw: RawRecord, key: string): number | undefined;
|
|
32
|
+
export declare function rawBoolean(raw: RawRecord, key: string): boolean | undefined;
|
|
33
|
+
/** Narrows an unknown raw value to a string-union type (wire values are exact). */
|
|
34
|
+
export declare function rawUnion<T extends string>(raw: RawRecord, key: string): T | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resource types — deep typing: nested interfaces plus string-union
|
|
3
|
+
* types for every finite value set (api spec §3, scheduler spec lifecycles).
|
|
4
|
+
*/
|
|
5
|
+
/** Statuses from which no further transitions occur (typed constant). */
|
|
6
|
+
export const TERMINAL_STATUSES = ["succeeded", "failed", "cancelled"];
|
|
7
|
+
export function rawString(raw, key) {
|
|
8
|
+
const value = raw[key];
|
|
9
|
+
return typeof value === "string" ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function rawNumber(raw, key) {
|
|
12
|
+
const value = raw[key];
|
|
13
|
+
return typeof value === "number" ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
export function rawBoolean(raw, key) {
|
|
16
|
+
const value = raw[key];
|
|
17
|
+
return typeof value === "boolean" ? value : undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Narrows an unknown raw value to a string-union type (wire values are exact). */
|
|
20
|
+
export function rawUnion(raw, key) {
|
|
21
|
+
const value = raw[key];
|
|
22
|
+
return typeof value === "string" ? value : undefined;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solti/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Solti Platform TypeScript SDK — submit and orchestrate workloads, manage connections and cronjobs without managing infrastructure.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.10.1",
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"vitest": "^3.2.4"
|
|
31
|
+
}
|
|
32
|
+
}
|