@hasna/configs-sdk 0.1.1 → 0.1.3
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 +84 -0
- package/dist/index.js +12 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @hasna/configs-sdk
|
|
2
|
+
|
|
3
|
+
Zero-dependency TypeScript client for the `@hasna/configs` REST API. Works in Node, Bun, Deno, and browser.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @hasna/configs-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ConfigsClient } from "@hasna/configs-sdk";
|
|
15
|
+
|
|
16
|
+
const client = new ConfigsClient({ baseUrl: "http://localhost:3457" });
|
|
17
|
+
// Or: reads CONFIGS_URL env var
|
|
18
|
+
const client = ConfigsClient.fromEnv?.() ?? new ConfigsClient();
|
|
19
|
+
|
|
20
|
+
// Get status (drift detection, template count)
|
|
21
|
+
const status = await client.getStatus();
|
|
22
|
+
console.log(`${status.total} configs, ${status.drifted} drifted`);
|
|
23
|
+
|
|
24
|
+
// List configs
|
|
25
|
+
const rules = await client.listConfigs({ category: "rules" });
|
|
26
|
+
|
|
27
|
+
// Get a specific config
|
|
28
|
+
const claudeMd = await client.getConfig("claude-claude-md");
|
|
29
|
+
|
|
30
|
+
// Sync from disk
|
|
31
|
+
const result = await client.syncKnown({ agent: "claude" });
|
|
32
|
+
|
|
33
|
+
// Apply a config to disk
|
|
34
|
+
await client.applyConfig("claude-claude-md");
|
|
35
|
+
|
|
36
|
+
// Profiles
|
|
37
|
+
const profile = await client.createProfile("my-setup");
|
|
38
|
+
await client.applyProfile("my-setup");
|
|
39
|
+
|
|
40
|
+
// Snapshots
|
|
41
|
+
const snaps = await client.getSnapshots("claude-claude-md");
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## All Methods (21)
|
|
45
|
+
|
|
46
|
+
| Method | Description |
|
|
47
|
+
|--------|-------------|
|
|
48
|
+
| `listConfigs(filter?)` | List configs with optional category/agent/kind/search filter |
|
|
49
|
+
| `getConfig(idOrSlug)` | Get full config including content |
|
|
50
|
+
| `createConfig(input)` | Create a new config |
|
|
51
|
+
| `updateConfig(id, input)` | Update config content/metadata |
|
|
52
|
+
| `deleteConfig(id)` | Delete a config |
|
|
53
|
+
| `applyConfig(id, dryRun?)` | Write config to its target_path on disk |
|
|
54
|
+
| `syncDirectory(dir, direction?, dryRun?)` | Sync a directory with the DB |
|
|
55
|
+
| `syncKnown(opts?)` | Sync known config files from disk |
|
|
56
|
+
| `getStatus()` | Health check: total, drifted, templates, DB path |
|
|
57
|
+
| `getStats()` | Counts by category |
|
|
58
|
+
| `listProfiles()` | List all profiles |
|
|
59
|
+
| `getProfile(id)` | Get profile with its configs |
|
|
60
|
+
| `createProfile(name, desc?)` | Create a profile |
|
|
61
|
+
| `updateProfile(id, input)` | Update profile name/description |
|
|
62
|
+
| `deleteProfile(id)` | Delete a profile |
|
|
63
|
+
| `applyProfile(id, dryRun?)` | Apply all configs in a profile to disk |
|
|
64
|
+
| `listMachines()` | List machines where configs were applied |
|
|
65
|
+
| `registerMachine(hostname?, os?)` | Register a machine |
|
|
66
|
+
| `createSnapshot(configId)` | Create a version snapshot |
|
|
67
|
+
| `getSnapshots(configId)` | List snapshots for a config |
|
|
68
|
+
| `health()` | Health check |
|
|
69
|
+
|
|
70
|
+
## Environment Variables
|
|
71
|
+
|
|
72
|
+
- `CONFIGS_URL` — base URL for the configs REST API (default: `http://localhost:3457`)
|
|
73
|
+
|
|
74
|
+
## Part of the @hasna ecosystem
|
|
75
|
+
|
|
76
|
+
- [`@hasna/configs`](https://npm.im/@hasna/configs) — CLI + MCP + REST server
|
|
77
|
+
- [`@hasna/todos`](https://npm.im/@hasna/todos) — task management
|
|
78
|
+
- [`@hasna/mementos`](https://npm.im/@hasna/mementos) — persistent memory
|
|
79
|
+
- [`@hasna/sessions`](https://npm.im/@hasna/sessions) — session search
|
|
80
|
+
- [`@hasna/attachments`](https://npm.im/@hasna/attachments) — file transfer
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Apache-2.0
|
package/dist/index.js
CHANGED
|
@@ -58,12 +58,24 @@ class ConfigsClient {
|
|
|
58
58
|
async getProfile(idOrSlug) {
|
|
59
59
|
return this.req("GET", `/api/profiles/${idOrSlug}`);
|
|
60
60
|
}
|
|
61
|
+
async createProfile(name, description) {
|
|
62
|
+
return this.req("POST", "/api/profiles", { name, description });
|
|
63
|
+
}
|
|
64
|
+
async updateProfile(idOrSlug, input) {
|
|
65
|
+
return this.req("PUT", `/api/profiles/${idOrSlug}`, input);
|
|
66
|
+
}
|
|
67
|
+
async deleteProfile(idOrSlug) {
|
|
68
|
+
await this.req("DELETE", `/api/profiles/${idOrSlug}`);
|
|
69
|
+
}
|
|
61
70
|
async applyProfile(idOrSlug, dryRun = false) {
|
|
62
71
|
return this.req("POST", `/api/profiles/${idOrSlug}/apply`, { dry_run: dryRun });
|
|
63
72
|
}
|
|
64
73
|
async listMachines() {
|
|
65
74
|
return this.req("GET", "/api/machines");
|
|
66
75
|
}
|
|
76
|
+
async registerMachine(hostname, os) {
|
|
77
|
+
return this.req("POST", "/api/machines", { hostname, os });
|
|
78
|
+
}
|
|
67
79
|
async getStats() {
|
|
68
80
|
return this.req("GET", "/api/stats");
|
|
69
81
|
}
|