@devpad/api 2.1.2 → 2.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 +101 -98
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,149 +1,152 @@
|
|
|
1
1
|
# @devpad/api
|
|
2
2
|
|
|
3
|
-
TypeScript client
|
|
3
|
+
TypeScript API client for [devpad](https://devpad.tools) — project management, task tracking, milestones, goals, and more.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @devpad/api
|
|
9
|
-
# or
|
|
10
|
-
yarn add @devpad/api
|
|
11
|
-
# or
|
|
12
8
|
bun add @devpad/api
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
## Quick
|
|
11
|
+
## Quick start
|
|
16
12
|
|
|
17
13
|
```typescript
|
|
18
|
-
import
|
|
14
|
+
import ApiClient from "@devpad/api";
|
|
19
15
|
|
|
20
|
-
const client = new
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Create a project
|
|
26
|
-
const project = await client.projects.create({
|
|
27
|
-
name: 'My New Project',
|
|
28
|
-
description: 'A project created via API',
|
|
29
|
-
visibility: 'private'
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Create a task
|
|
33
|
-
const task = await client.tasks.create({
|
|
34
|
-
project_id: project.data.project_id,
|
|
35
|
-
title: 'Implement new feature',
|
|
36
|
-
description: 'Add user authentication',
|
|
37
|
-
status: 'pending',
|
|
38
|
-
priority: 'high',
|
|
39
|
-
tags: ['feature', 'auth']
|
|
16
|
+
const client = new ApiClient({
|
|
17
|
+
base_url: "https://devpad.tools/api/v1",
|
|
18
|
+
api_key: "your-api-key",
|
|
40
19
|
});
|
|
41
20
|
```
|
|
42
21
|
|
|
43
|
-
|
|
22
|
+
The constructor also accepts `auth_mode`, `credentials`, `default_headers`, and `custom_fetch`. Auth mode is auto-detected from the `api_key` format.
|
|
44
23
|
|
|
45
|
-
|
|
24
|
+
## Error handling
|
|
46
25
|
|
|
47
|
-
|
|
26
|
+
All methods return `ApiResult<T>` which is `Result<T, ApiResultError>` from `@f0rbit/corpus`. No try/catch needed.
|
|
48
27
|
|
|
49
28
|
```typescript
|
|
50
|
-
|
|
51
|
-
api_key: string; // Required: Your Devpad API key
|
|
52
|
-
base_url?: string; // Optional: API base URL (defaults to localhost:4321/api/v1)
|
|
53
|
-
});
|
|
54
|
-
```
|
|
29
|
+
import ApiClient, { type ApiResult } from "@devpad/api";
|
|
55
30
|
|
|
56
|
-
|
|
31
|
+
const result = await client.projects.list();
|
|
57
32
|
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
if (!result.ok) {
|
|
34
|
+
console.error(result.error.message, result.error.status_code);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
60
37
|
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
const projects = result.value;
|
|
39
|
+
```
|
|
63
40
|
|
|
64
|
-
|
|
65
|
-
Get a project by name.
|
|
41
|
+
The `ok()` and `err()` constructors are re-exported for building your own Results.
|
|
66
42
|
|
|
67
|
-
|
|
68
|
-
Create a new project.
|
|
43
|
+
## API reference
|
|
69
44
|
|
|
70
|
-
|
|
71
|
-
Update an existing project.
|
|
45
|
+
### Projects
|
|
72
46
|
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
```typescript
|
|
48
|
+
client.projects.list()
|
|
49
|
+
client.projects.find(id)
|
|
50
|
+
client.projects.getByName(name)
|
|
51
|
+
client.projects.create(data)
|
|
52
|
+
client.projects.upsert(data)
|
|
53
|
+
client.projects.config.load(id)
|
|
54
|
+
client.projects.config.save(id, config)
|
|
55
|
+
client.projects.history(id)
|
|
56
|
+
client.projects.specification(id)
|
|
57
|
+
client.projects.scan.initiate(name)
|
|
58
|
+
client.projects.scan.updates(id)
|
|
59
|
+
client.projects.map()
|
|
60
|
+
```
|
|
75
61
|
|
|
76
|
-
### Tasks
|
|
62
|
+
### Tasks
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
```typescript
|
|
65
|
+
client.tasks.list(params?) // optional { project_id, tag_id }
|
|
66
|
+
client.tasks.find(id)
|
|
67
|
+
client.tasks.getByProject(id)
|
|
68
|
+
client.tasks.create(data)
|
|
69
|
+
client.tasks.upsert(data)
|
|
70
|
+
client.tasks.delete(id)
|
|
71
|
+
client.tasks.history.get(id)
|
|
72
|
+
```
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
Get a specific task by ID.
|
|
74
|
+
### Milestones
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
```typescript
|
|
77
|
+
client.milestones.list(params?) // optional { project_id }
|
|
78
|
+
client.milestones.find(id)
|
|
79
|
+
client.milestones.getByProject(id)
|
|
80
|
+
client.milestones.create(data)
|
|
81
|
+
client.milestones.update(id, data)
|
|
82
|
+
client.milestones.delete(id)
|
|
83
|
+
client.milestones.goals(id)
|
|
84
|
+
```
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
Create a new task.
|
|
86
|
+
### Goals
|
|
89
87
|
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
```typescript
|
|
89
|
+
client.goals.list()
|
|
90
|
+
client.goals.find(id)
|
|
91
|
+
client.goals.create(data)
|
|
92
|
+
client.goals.update(id, data)
|
|
93
|
+
client.goals.delete(id)
|
|
94
|
+
```
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
Create or update a task (unified endpoint).
|
|
96
|
+
### Tags
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
```typescript
|
|
99
|
+
client.tags.list()
|
|
100
|
+
client.tags.save(tags)
|
|
101
|
+
```
|
|
97
102
|
|
|
98
|
-
|
|
103
|
+
### Auth
|
|
99
104
|
|
|
100
105
|
```typescript
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
TaskCreate,
|
|
109
|
-
TaskUpdate,
|
|
110
|
-
TaskUpsert,
|
|
111
|
-
ApiResponse
|
|
112
|
-
} from '@devpad/api';
|
|
106
|
+
client.auth.keys.list()
|
|
107
|
+
client.auth.keys.create(data)
|
|
108
|
+
client.auth.keys.update(id, data)
|
|
109
|
+
client.auth.keys.delete(id)
|
|
110
|
+
client.auth.user()
|
|
111
|
+
client.auth.login(code)
|
|
112
|
+
client.auth.loginUrl()
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
###
|
|
115
|
+
### User
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
```typescript
|
|
118
|
+
client.user.history()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### GitHub
|
|
118
122
|
|
|
119
123
|
```typescript
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
await client.projects.create({ name: 'Test Project' });
|
|
124
|
-
} catch (error) {
|
|
125
|
-
if (error instanceof AuthenticationError) {
|
|
126
|
-
console.error('Invalid API key');
|
|
127
|
-
} else if (error instanceof ApiError) {
|
|
128
|
-
console.error('API Error:', error.message, error.statusCode);
|
|
129
|
-
} else if (error instanceof NetworkError) {
|
|
130
|
-
console.error('Network Error:', error.message);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
124
|
+
client.github.repos()
|
|
125
|
+
client.github.branches(owner, repo)
|
|
133
126
|
```
|
|
134
127
|
|
|
135
|
-
|
|
128
|
+
Blog and media namespaces also exist but are documented separately.
|
|
136
129
|
|
|
137
|
-
|
|
130
|
+
## Types
|
|
138
131
|
|
|
139
|
-
|
|
132
|
+
```typescript
|
|
133
|
+
import ApiClient, {
|
|
134
|
+
type ApiResult,
|
|
135
|
+
type ApiResultError,
|
|
136
|
+
type AuthMode, // "session" | "key" | "cookie"
|
|
137
|
+
} from "@devpad/api";
|
|
138
|
+
|
|
139
|
+
// Schema types re-exported for convenience
|
|
140
|
+
import type {
|
|
141
|
+
Project,
|
|
142
|
+
TaskWithDetails,
|
|
143
|
+
UpsertProject,
|
|
144
|
+
UpsertTodo,
|
|
145
|
+
} from "@devpad/api";
|
|
146
|
+
```
|
|
140
147
|
|
|
141
|
-
|
|
148
|
+
Result utilities `ok` and `err` are also exported from the main entry point.
|
|
142
149
|
|
|
143
150
|
## License
|
|
144
151
|
|
|
145
152
|
MIT
|
|
146
|
-
|
|
147
|
-
## Support
|
|
148
|
-
|
|
149
|
-
For issues and feature requests, please visit the [GitHub repository](https://github.com/f0rbit/devpad/issues).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devpad/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "f0rbit",
|
|
6
6
|
"url": "https://github.com/f0rbit"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"zod": "^3.22.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@devpad/schema": "^2.1.
|
|
30
|
+
"@devpad/schema": "^2.1.3",
|
|
31
31
|
"@types/node": "^20.11.24",
|
|
32
32
|
"bun-types": "latest",
|
|
33
33
|
"eslint": "^8.57.0",
|