@devpad/api 2.1.1 → 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/dist/index.d.ts +8 -1
- package/dist/index.js +12 -6
- 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/dist/index.d.ts
CHANGED
|
@@ -99,7 +99,10 @@ declare class ApiClient {
|
|
|
99
99
|
list: () => Promise<ApiResult<ApiKey[]>>;
|
|
100
100
|
create: (name?: string) => Promise<ApiResult<{
|
|
101
101
|
message: string;
|
|
102
|
-
key:
|
|
102
|
+
key: {
|
|
103
|
+
key: ApiKey;
|
|
104
|
+
raw_key: string;
|
|
105
|
+
};
|
|
103
106
|
}>>;
|
|
104
107
|
revoke: (key_id: string) => Promise<ApiResult<{
|
|
105
108
|
message: string;
|
|
@@ -219,6 +222,7 @@ declare class ApiClient {
|
|
|
219
222
|
description?: string;
|
|
220
223
|
target_time?: string;
|
|
221
224
|
target_version?: string;
|
|
225
|
+
finished_at?: string;
|
|
222
226
|
}) => Promise<ApiResult<Milestone>>;
|
|
223
227
|
/**
|
|
224
228
|
* Update milestone
|
|
@@ -228,6 +232,7 @@ declare class ApiClient {
|
|
|
228
232
|
description?: string;
|
|
229
233
|
target_time?: string;
|
|
230
234
|
target_version?: string;
|
|
235
|
+
finished_at?: string | null;
|
|
231
236
|
}) => Promise<ApiResult<Milestone>>;
|
|
232
237
|
/**
|
|
233
238
|
* Delete milestone (soft delete)
|
|
@@ -261,6 +266,7 @@ declare class ApiClient {
|
|
|
261
266
|
name: string;
|
|
262
267
|
description?: string;
|
|
263
268
|
target_time?: string;
|
|
269
|
+
finished_at?: string;
|
|
264
270
|
}) => Promise<ApiResult<Goal>>;
|
|
265
271
|
/**
|
|
266
272
|
* Update goal
|
|
@@ -269,6 +275,7 @@ declare class ApiClient {
|
|
|
269
275
|
name?: string;
|
|
270
276
|
description?: string;
|
|
271
277
|
target_time?: string;
|
|
278
|
+
finished_at?: string | null;
|
|
272
279
|
}) => Promise<ApiResult<Goal>>;
|
|
273
280
|
/**
|
|
274
281
|
* Delete goal (soft delete)
|
package/dist/index.js
CHANGED
|
@@ -627,7 +627,8 @@ var ApiClient2 = class {
|
|
|
627
627
|
name: data.name ?? milestone.name,
|
|
628
628
|
description: data.description ?? milestone.description,
|
|
629
629
|
target_time: data.target_time ?? milestone.target_time,
|
|
630
|
-
target_version: data.target_version ?? milestone.target_version
|
|
630
|
+
target_version: data.target_version ?? milestone.target_version,
|
|
631
|
+
finished_at: data.finished_at !== void 0 ? data.finished_at : milestone.finished_at
|
|
631
632
|
};
|
|
632
633
|
return this.clients.milestones.patch(`/milestones/${id}`, {
|
|
633
634
|
body: updateData
|
|
@@ -671,7 +672,8 @@ var ApiClient2 = class {
|
|
|
671
672
|
milestone_id: goal.milestone_id,
|
|
672
673
|
name: data.name ?? goal.name,
|
|
673
674
|
description: data.description ?? goal.description,
|
|
674
|
-
target_time: data.target_time ?? goal.target_time
|
|
675
|
+
target_time: data.target_time ?? goal.target_time,
|
|
676
|
+
finished_at: data.finished_at !== void 0 ? data.finished_at : goal.finished_at
|
|
675
677
|
};
|
|
676
678
|
return this.clients.goals.patch(`/goals/${id}`, {
|
|
677
679
|
body: updateData
|
|
@@ -1099,13 +1101,15 @@ var tools = {
|
|
|
1099
1101
|
name: input.name,
|
|
1100
1102
|
description: input.description,
|
|
1101
1103
|
target_time: input.target_time,
|
|
1102
|
-
target_version: input.target_version
|
|
1104
|
+
target_version: input.target_version,
|
|
1105
|
+
finished_at: input.finished_at
|
|
1103
1106
|
}) : await client.milestones.create({
|
|
1104
1107
|
project_id: input.project_id,
|
|
1105
1108
|
name: input.name,
|
|
1106
1109
|
description: input.description,
|
|
1107
1110
|
target_time: input.target_time,
|
|
1108
|
-
target_version: input.target_version
|
|
1111
|
+
target_version: input.target_version,
|
|
1112
|
+
finished_at: input.finished_at
|
|
1109
1113
|
})
|
|
1110
1114
|
)
|
|
1111
1115
|
},
|
|
@@ -1130,12 +1134,14 @@ var tools = {
|
|
|
1130
1134
|
input.id ? await client.goals.update(input.id, {
|
|
1131
1135
|
name: input.name,
|
|
1132
1136
|
description: input.description,
|
|
1133
|
-
target_time: input.target_time
|
|
1137
|
+
target_time: input.target_time,
|
|
1138
|
+
finished_at: input.finished_at
|
|
1134
1139
|
}) : await client.goals.create({
|
|
1135
1140
|
milestone_id: input.milestone_id,
|
|
1136
1141
|
name: input.name,
|
|
1137
1142
|
description: input.description,
|
|
1138
|
-
target_time: input.target_time
|
|
1143
|
+
target_time: input.target_time,
|
|
1144
|
+
finished_at: input.finished_at
|
|
1139
1145
|
})
|
|
1140
1146
|
)
|
|
1141
1147
|
},
|
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",
|