@cavsnode/cavs-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/index.cjs +1186 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +735 -0
- package/dist/index.d.ts +735 -0
- package/dist/index.js +1139 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @cavsnode/cavs-sdk
|
|
2
|
+
|
|
3
|
+
Official **TypeScript / JavaScript SDK** for [CAVS Hub](https://github.com/orelvis15/cavs-hub) — the
|
|
4
|
+
deduplicating, content-addressed artifact store for AI, CI/CD and game pipelines.
|
|
5
|
+
|
|
6
|
+
It talks to the same canonical `/api/v1` API the CLI uses (see
|
|
7
|
+
[`../CONTRACT.md`](../CONTRACT.md)). Uploads and downloads **stream** — files are
|
|
8
|
+
never read whole into memory — and every download is verified (`sha256 === oid`).
|
|
9
|
+
|
|
10
|
+
- Node **18+** (uses the global `fetch`, Web Streams and `node:crypto`).
|
|
11
|
+
- Ships ESM + CJS with type declarations.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @cavsnode/cavs-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Authentication
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
export CAVS_TOKEN=cavs_sk_... # a service-account key from the dashboard
|
|
23
|
+
export CAVS_API=https://api.cavs.dev # or your self-hosted Hub
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Tokens are never printed in logs or errors. See [`../CONTRACT.md`](../CONTRACT.md) §2.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { CAVS } from "@cavsnode/cavs-sdk";
|
|
32
|
+
|
|
33
|
+
const client = CAVS.fromEnv();
|
|
34
|
+
|
|
35
|
+
const artifact = await client.artifacts.upload({
|
|
36
|
+
path: "./model",
|
|
37
|
+
project: "vision-models",
|
|
38
|
+
name: "resnet50",
|
|
39
|
+
kind: "model",
|
|
40
|
+
version: "1.4.0",
|
|
41
|
+
metadata: { framework: "pytorch", accuracy: 0.942 },
|
|
42
|
+
onProgress: (e) => process.stdout.write(`\r${e.phase} ${e.path} ${e.loaded}/${e.total}`),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log(artifact.reference); // cavs://…/model/resnet50:1.4.0
|
|
46
|
+
console.log(artifact.deduplicationRatio); // e.g. 0.6
|
|
47
|
+
|
|
48
|
+
await client.artifacts.download(artifact.reference, { dest: "./restored" });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## What's included
|
|
52
|
+
|
|
53
|
+
- `client.artifacts` — `upload`, `download`, `get`, `versions`, `list`
|
|
54
|
+
- `client.runs` — create/update pipeline runs and record lineage
|
|
55
|
+
- `client.lineage`, `client.snapshots`, `client.releases`, `client.usage`
|
|
56
|
+
- `client.serviceAccounts` — manage service accounts and API keys
|
|
57
|
+
- Typed errors: `CAVSError`, `AuthenticationError`, `AuthorizationError`,
|
|
58
|
+
`NotFoundError`, `ConflictError`, `RateLimitError`, `QuotaExceededError`,
|
|
59
|
+
`ChecksumError`, `UploadError`, `DownloadError`, `TemporaryServiceError`
|
|
60
|
+
- `uri.parse` / `uri.format` for `cavs://` references
|
|
61
|
+
|
|
62
|
+
## Retries, timeouts and cancellation
|
|
63
|
+
|
|
64
|
+
Requests retry up to 4 times on `429`/`5xx`/network errors with exponential
|
|
65
|
+
backoff, honouring `Retry-After`. Pass an `AbortSignal` to cancel any call:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const ac = new AbortController();
|
|
69
|
+
const p = client.artifacts.upload({ /* … */, signal: ac.signal });
|
|
70
|
+
ac.abort();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm ci
|
|
77
|
+
npm run lint && npm run typecheck && npm test # vitest, coverage gate ≥90%
|
|
78
|
+
npm run build # tsup → dist/ (ESM + CJS + d.ts)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See [`../CONTRIBUTING.md`](../CONTRIBUTING.md) and [`../docs/typescript.md`](../docs/typescript.md).
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache 2.0 — see [`../LICENSE`](../LICENSE).
|