@kaiban/sdk 0.4.0 → 0.4.2
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 +91 -14
- package/dist/cjs/lib/client.js +3 -1
- package/dist/cjs/lib/http/HttpClient.js +5 -1
- package/dist/cjs/lib/http/errors.js +70 -4
- package/dist/cjs/lib/resources/AgentsClient.js +28 -0
- package/dist/cjs/lib/resources/BoardsClient.js +42 -0
- package/dist/cjs/lib/resources/TeamMembersClient.js +102 -0
- package/dist/cjs/types/entities/activities.js +0 -2
- package/dist/esm/lib/client.js +3 -1
- package/dist/esm/lib/http/HttpClient.js +6 -2
- package/dist/esm/lib/http/errors.js +67 -3
- package/dist/esm/lib/resources/AgentsClient.js +28 -0
- package/dist/esm/lib/resources/BoardsClient.js +42 -0
- package/dist/esm/lib/resources/TeamMembersClient.js +98 -0
- package/dist/esm/types/entities/activities.js +0 -2
- package/dist/types/lib/client.d.ts +4 -1
- package/dist/types/lib/http/errors.d.ts +26 -2
- package/dist/types/lib/resources/AgentsClient.d.ts +26 -0
- package/dist/types/lib/resources/BoardsClient.d.ts +34 -1
- package/dist/types/lib/resources/TeamMembersClient.d.ts +89 -0
- package/dist/types/types/entities/activities.d.ts +5 -3
- package/dist/types/types/entities/agent.d.ts +14 -14
- package/dist/types/types/entities/board.d.ts +16 -10
- package/dist/types/types/entities/card.d.ts +22 -13
- package/dist/types/types/entities/external-channel.d.ts +1 -1
- package/dist/types/types/entities/team.d.ts +3 -2
- package/package.json +3 -3
|
@@ -25,6 +25,7 @@ export class ApiError extends Error {
|
|
|
25
25
|
this.name = 'ApiError';
|
|
26
26
|
this.code = shape.code;
|
|
27
27
|
this.details = shape.details;
|
|
28
|
+
this.meta = shape.meta;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
export class BadRequestError extends ApiError {
|
|
@@ -37,6 +38,7 @@ export class ValidationError extends ApiError {
|
|
|
37
38
|
constructor(shape) {
|
|
38
39
|
super(shape);
|
|
39
40
|
this.name = 'ValidationError';
|
|
41
|
+
this.details = shape.details;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
export class UnauthorizedError extends ApiError {
|
|
@@ -75,6 +77,18 @@ export class UnavailableError extends ApiError {
|
|
|
75
77
|
this.name = 'UnavailableError';
|
|
76
78
|
}
|
|
77
79
|
}
|
|
80
|
+
export class BadGatewayError extends ApiError {
|
|
81
|
+
constructor(shape) {
|
|
82
|
+
super(shape);
|
|
83
|
+
this.name = 'BadGatewayError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class GatewayTimeoutError extends ApiError {
|
|
87
|
+
constructor(shape) {
|
|
88
|
+
super(shape);
|
|
89
|
+
this.name = 'GatewayTimeoutError';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
78
92
|
export class ServerError extends ApiError {
|
|
79
93
|
constructor(shape) {
|
|
80
94
|
super(shape);
|
|
@@ -82,8 +96,38 @@ export class ServerError extends ApiError {
|
|
|
82
96
|
}
|
|
83
97
|
}
|
|
84
98
|
// Map HTTP response status and body to human-friendly SDK errors
|
|
99
|
+
// Uses backend error code when available, falls back to HTTP status mapping
|
|
85
100
|
export function mapHttpToSdkError(status, body) {
|
|
86
101
|
const shape = normalizeBody(body);
|
|
102
|
+
// If backend provided an explicit error code, use it to determine error type
|
|
103
|
+
if (shape.code) {
|
|
104
|
+
switch (shape.code) {
|
|
105
|
+
case 'invalid_argument':
|
|
106
|
+
return new BadRequestError(shape);
|
|
107
|
+
case 'unauthenticated':
|
|
108
|
+
return new UnauthorizedError(shape);
|
|
109
|
+
case 'permission_denied':
|
|
110
|
+
return new ForbiddenError(shape);
|
|
111
|
+
case 'not_found':
|
|
112
|
+
return new NotFoundError(shape);
|
|
113
|
+
case 'conflict':
|
|
114
|
+
return new ConflictError(shape);
|
|
115
|
+
case 'validation_error':
|
|
116
|
+
return new ValidationError(shape);
|
|
117
|
+
case 'rate_limit_exceeded':
|
|
118
|
+
return new RateLimitError(shape);
|
|
119
|
+
case 'bad_gateway':
|
|
120
|
+
return new BadGatewayError(shape);
|
|
121
|
+
case 'service_unavailable':
|
|
122
|
+
return new UnavailableError(shape);
|
|
123
|
+
case 'gateway_timeout':
|
|
124
|
+
return new GatewayTimeoutError(shape);
|
|
125
|
+
case 'internal':
|
|
126
|
+
default:
|
|
127
|
+
return new ServerError(shape);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Fallback to HTTP status code mapping if no backend code provided
|
|
87
131
|
switch (status) {
|
|
88
132
|
case 400:
|
|
89
133
|
return new BadRequestError(shape);
|
|
@@ -100,14 +144,20 @@ export function mapHttpToSdkError(status, body) {
|
|
|
100
144
|
case 429:
|
|
101
145
|
return new RateLimitError(shape);
|
|
102
146
|
case 502:
|
|
147
|
+
return new BadGatewayError(shape);
|
|
103
148
|
case 503:
|
|
104
|
-
case 504:
|
|
105
149
|
return new UnavailableError(shape);
|
|
150
|
+
case 504:
|
|
151
|
+
return new GatewayTimeoutError(shape);
|
|
106
152
|
case 500:
|
|
107
153
|
default:
|
|
108
154
|
return new ServerError(shape);
|
|
109
155
|
}
|
|
110
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Normalizes error response body to ApiErrorShape
|
|
159
|
+
* Backend returns: { error: { code, message, details? }, meta: { request_id?, timestamp } }
|
|
160
|
+
*/
|
|
111
161
|
function normalizeBody(body) {
|
|
112
162
|
if (!body)
|
|
113
163
|
return { message: 'Unknown error' };
|
|
@@ -115,12 +165,26 @@ function normalizeBody(body) {
|
|
|
115
165
|
return { message: body };
|
|
116
166
|
if (typeof body === 'object') {
|
|
117
167
|
const anyBody = body;
|
|
118
|
-
|
|
168
|
+
// Backend structure: { error: { code, message, details? }, meta: { request_id?, timestamp } }
|
|
169
|
+
if (anyBody['error'] && typeof anyBody['error'] === 'object') {
|
|
170
|
+
const errorObj = anyBody['error'];
|
|
171
|
+
const meta = anyBody['meta'];
|
|
172
|
+
return {
|
|
173
|
+
code: errorObj['code'],
|
|
174
|
+
message: errorObj['message'] || 'Request failed',
|
|
175
|
+
details: errorObj['details'],
|
|
176
|
+
meta,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// Fallback: try to extract from flat structure (legacy support)
|
|
180
|
+
const code = anyBody['code'] ||
|
|
181
|
+
anyBody['error'];
|
|
119
182
|
const message = anyBody['message'] ||
|
|
120
183
|
anyBody['error_description'] ||
|
|
121
184
|
'Request failed';
|
|
122
185
|
const details = anyBody['details'];
|
|
123
|
-
|
|
186
|
+
const meta = anyBody['meta'];
|
|
187
|
+
return { code, message, details, meta };
|
|
124
188
|
}
|
|
125
189
|
return { message: 'Request failed' };
|
|
126
190
|
}
|
|
@@ -102,6 +102,34 @@ export class AgentsClient {
|
|
|
102
102
|
get(id, options) {
|
|
103
103
|
return this.http.get(`/agent/${encodeURIComponent(id)}`, options);
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Create a new agent
|
|
107
|
+
*
|
|
108
|
+
* @param data - Agent creation data
|
|
109
|
+
* @param options - Optional request configuration
|
|
110
|
+
*
|
|
111
|
+
* @returns The newly created agent object
|
|
112
|
+
*
|
|
113
|
+
* @throws {Error} If creation fails
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const agent = await client.agents.create({
|
|
118
|
+
* name: 'SupportAgent',
|
|
119
|
+
* description: 'Handles support tickets',
|
|
120
|
+
* team_id: 'team_123',
|
|
121
|
+
* owner_id: 'user_123',
|
|
122
|
+
* created_by: 'user_123',
|
|
123
|
+
* type: 'a2a',
|
|
124
|
+
* status: 'active',
|
|
125
|
+
* monthly_budget: 200,
|
|
126
|
+
* examples: []
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
create(data, options) {
|
|
131
|
+
return this.http.post('/agents', data, options);
|
|
132
|
+
}
|
|
105
133
|
/**
|
|
106
134
|
* Update an agent's properties
|
|
107
135
|
*
|
|
@@ -71,4 +71,46 @@ export class BoardsClient {
|
|
|
71
71
|
get(id, options) {
|
|
72
72
|
return this.http.get(`/board/${encodeURIComponent(id)}`, options);
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a new board
|
|
76
|
+
*
|
|
77
|
+
* @param data - Board creation data
|
|
78
|
+
* @param data.name - The board name
|
|
79
|
+
* @param data.team_id - The team this board belongs to
|
|
80
|
+
* @param data.owner_id - The owner of the board
|
|
81
|
+
* @param data.created_by - The user creating the board
|
|
82
|
+
* @param data.description - Board description
|
|
83
|
+
* @param data.agent_ids - Array of agent IDs
|
|
84
|
+
* @param data.member_ids - Array of member IDs
|
|
85
|
+
* @param data.allowed_roles - Array of allowed roles
|
|
86
|
+
* @param data.columns - Array of columns
|
|
87
|
+
* @param options - Optional request configuration
|
|
88
|
+
*
|
|
89
|
+
* @returns The newly created board
|
|
90
|
+
*
|
|
91
|
+
* @throws {Error} If creation fails
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const board = await client.boards.create({
|
|
96
|
+
* name: 'Sales',
|
|
97
|
+
* team_id: 'team_123',
|
|
98
|
+
* owner_id: 'user_123',
|
|
99
|
+
* created_by: 'user_123',
|
|
100
|
+
* description: 'Manage pipeline',
|
|
101
|
+
* columns: []
|
|
102
|
+
* // agent_ids, member_ids, and allowed_roles are optional (default to [])
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
create(data, options) {
|
|
107
|
+
// Default empty arrays for optional fields
|
|
108
|
+
const payload = {
|
|
109
|
+
...data,
|
|
110
|
+
agent_ids: data.agent_ids ?? [],
|
|
111
|
+
member_ids: data.member_ids ?? [],
|
|
112
|
+
allowed_roles: data.allowed_roles ?? [],
|
|
113
|
+
};
|
|
114
|
+
return this.http.post('/boards', payload, options);
|
|
115
|
+
}
|
|
74
116
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for managing team members in the Kaiban platform
|
|
3
|
+
* @category Resources
|
|
4
|
+
*/
|
|
5
|
+
export class TeamMembersClient {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List team members with pagination, filters, and sorting
|
|
11
|
+
*
|
|
12
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
13
|
+
* @param params.limit - Number of items per page (default: 50, max: 100)
|
|
14
|
+
* @param params.after - Cursor to navigate forwards (get items after this cursor)
|
|
15
|
+
* @param params.before - Cursor to navigate backwards (get items before this cursor)
|
|
16
|
+
* @param params.order_by - Fields to sort by (prefix with - for descending order)
|
|
17
|
+
* @param params.filters - Filter parameters to narrow results
|
|
18
|
+
* @param options - Optional request configuration
|
|
19
|
+
*
|
|
20
|
+
* @returns A paginated list of team members
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // List first page of team members
|
|
25
|
+
* const result = await client.teamMembers.list({ limit: 10 });
|
|
26
|
+
* console.log(result.data); // Array of TeamMember objects
|
|
27
|
+
* console.log(result.pagination.next_cursor); // Cursor for next page
|
|
28
|
+
*
|
|
29
|
+
* // Get next page using cursor
|
|
30
|
+
* if (result.pagination.next_cursor) {
|
|
31
|
+
* const nextPage = await client.teamMembers.list({
|
|
32
|
+
* limit: 10,
|
|
33
|
+
* after: result.pagination.next_cursor
|
|
34
|
+
* });
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
list(params, options) {
|
|
39
|
+
return this.http.list('/team-members', params, options);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Iterate through all team members using async generator
|
|
43
|
+
* Automatically handles pagination by following next_cursor
|
|
44
|
+
*
|
|
45
|
+
* @param params - Optional query parameters (excluding after/before cursors)
|
|
46
|
+
* @param params.limit - Number of items per page (used internally for pagination)
|
|
47
|
+
* @param params.order_by - Fields to sort by (prefix with - for descending order)
|
|
48
|
+
* @param params.filters - Filter parameters to narrow results
|
|
49
|
+
* @param options - Optional request configuration
|
|
50
|
+
*
|
|
51
|
+
* @yields Individual TeamMember objects
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Iterate through all team members
|
|
56
|
+
* for await (const member of client.teamMembers.listAll()) {
|
|
57
|
+
* console.log(member.id, member.user_id, member.role);
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // With custom page size and sorting
|
|
61
|
+
* for await (const member of client.teamMembers.listAll({
|
|
62
|
+
* limit: 100,
|
|
63
|
+
* order_by: '-joined_at',
|
|
64
|
+
* filters: { team_id: 'team_123' }
|
|
65
|
+
* })) {
|
|
66
|
+
* console.log(member);
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
async *listAll(params, options) {
|
|
71
|
+
let cursor = undefined;
|
|
72
|
+
do {
|
|
73
|
+
const page = await this.list({ ...(params || {}), after: cursor }, options);
|
|
74
|
+
for (const item of page.data)
|
|
75
|
+
yield item;
|
|
76
|
+
cursor = page.pagination.next_cursor;
|
|
77
|
+
} while (cursor);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get a single team member by ID
|
|
81
|
+
*
|
|
82
|
+
* @param id - The unique identifier of the team member
|
|
83
|
+
* @param options - Optional request configuration
|
|
84
|
+
*
|
|
85
|
+
* @returns The team member object
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} If the team member is not found or request fails
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const member = await client.teamMembers.get('tm-123');
|
|
92
|
+
* console.log(member.user_id, member.role);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
get(id, options) {
|
|
96
|
+
return this.http.get(`/team-member/${encodeURIComponent(id)}`, options);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -21,8 +21,6 @@ export const ActivityType = {
|
|
|
21
21
|
CARD_CLONED: 'card_cloned',
|
|
22
22
|
CARD_COLUMN_CHANGED: 'card_column_changed',
|
|
23
23
|
// A2A task status activities
|
|
24
|
-
// "submitted" | "working" | "input-required" | "completed" | "canceled" | "failed" | "rejected"
|
|
25
|
-
// | "auth-required" | "unknown"
|
|
26
24
|
A2A_TASK_STATUS_SUBMITTED: 'submitted',
|
|
27
25
|
A2A_TASK_STATUS_WORKING: 'working',
|
|
28
26
|
A2A_TASK_STATUS_INPUT_REQUIRED: 'required',
|
|
@@ -6,6 +6,7 @@ import { CardsClient } from './resources/CardsClient';
|
|
|
6
6
|
import { ExternalChannelsClient } from './resources/ExternalChannelsClient';
|
|
7
7
|
import { ModelCost } from './resources/ModelCost';
|
|
8
8
|
import { ResourcesClient } from './resources/ResourcesClient';
|
|
9
|
+
import { TeamMembersClient } from './resources/TeamMembersClient';
|
|
9
10
|
import { TeamsClient } from './resources/TeamsClient';
|
|
10
11
|
/**
|
|
11
12
|
* Main Kaiban SDK client interface providing access to all API resources
|
|
@@ -25,12 +26,14 @@ export interface KaibanClient {
|
|
|
25
26
|
activities: ActivitiesClient;
|
|
26
27
|
/** Client for managing teams */
|
|
27
28
|
teams: TeamsClient;
|
|
29
|
+
/** Client for managing team members */
|
|
30
|
+
teamMembers: TeamMembersClient;
|
|
28
31
|
/** Client for managing boards */
|
|
29
32
|
boards: BoardsClient;
|
|
30
33
|
/** Client for managing resources */
|
|
31
34
|
resources: ResourcesClient;
|
|
32
35
|
/** Client for managing external channels */
|
|
33
|
-
|
|
36
|
+
externalChannels: ExternalChannelsClient;
|
|
34
37
|
/** Client for calculate model usage costs*/
|
|
35
38
|
costs: ModelCost;
|
|
36
39
|
}
|
|
@@ -10,20 +10,38 @@ export declare class TimeoutError extends Error {
|
|
|
10
10
|
export declare class AbortedError extends Error {
|
|
11
11
|
constructor(message?: string);
|
|
12
12
|
}
|
|
13
|
+
export type ApiErrorCode = 'invalid_argument' | 'not_found' | 'internal' | 'validation_error' | 'permission_denied' | 'unauthenticated' | 'conflict' | 'rate_limit_exceeded' | 'bad_gateway' | 'service_unavailable' | 'gateway_timeout';
|
|
14
|
+
export interface ValidationIssue {
|
|
15
|
+
code: string;
|
|
16
|
+
path: Array<string | number>;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
13
19
|
export interface ApiErrorShape {
|
|
14
|
-
code?:
|
|
20
|
+
code?: ApiErrorCode;
|
|
15
21
|
message: string;
|
|
16
22
|
details?: unknown;
|
|
23
|
+
meta?: {
|
|
24
|
+
request_id?: string;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
};
|
|
17
27
|
}
|
|
18
28
|
export declare class ApiError extends Error {
|
|
19
|
-
readonly code?:
|
|
29
|
+
readonly code?: ApiErrorCode;
|
|
20
30
|
readonly details?: unknown;
|
|
31
|
+
readonly meta?: {
|
|
32
|
+
request_id?: string;
|
|
33
|
+
timestamp: string;
|
|
34
|
+
};
|
|
21
35
|
constructor(shape: ApiErrorShape);
|
|
22
36
|
}
|
|
23
37
|
export declare class BadRequestError extends ApiError {
|
|
24
38
|
constructor(shape: ApiErrorShape);
|
|
25
39
|
}
|
|
26
40
|
export declare class ValidationError extends ApiError {
|
|
41
|
+
readonly details?: {
|
|
42
|
+
issues?: ValidationIssue[];
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
27
45
|
constructor(shape: ApiErrorShape);
|
|
28
46
|
}
|
|
29
47
|
export declare class UnauthorizedError extends ApiError {
|
|
@@ -44,6 +62,12 @@ export declare class RateLimitError extends ApiError {
|
|
|
44
62
|
export declare class UnavailableError extends ApiError {
|
|
45
63
|
constructor(shape: ApiErrorShape);
|
|
46
64
|
}
|
|
65
|
+
export declare class BadGatewayError extends ApiError {
|
|
66
|
+
constructor(shape: ApiErrorShape);
|
|
67
|
+
}
|
|
68
|
+
export declare class GatewayTimeoutError extends ApiError {
|
|
69
|
+
constructor(shape: ApiErrorShape);
|
|
70
|
+
}
|
|
47
71
|
export declare class ServerError extends ApiError {
|
|
48
72
|
constructor(shape: ApiErrorShape);
|
|
49
73
|
}
|
|
@@ -93,6 +93,32 @@ export declare class AgentsClient {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
get(id: string, options?: RequestOptions): Promise<Agent>;
|
|
96
|
+
/**
|
|
97
|
+
* Create a new agent
|
|
98
|
+
*
|
|
99
|
+
* @param data - Agent creation data
|
|
100
|
+
* @param options - Optional request configuration
|
|
101
|
+
*
|
|
102
|
+
* @returns The newly created agent object
|
|
103
|
+
*
|
|
104
|
+
* @throws {Error} If creation fails
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const agent = await client.agents.create({
|
|
109
|
+
* name: 'SupportAgent',
|
|
110
|
+
* description: 'Handles support tickets',
|
|
111
|
+
* team_id: 'team_123',
|
|
112
|
+
* owner_id: 'user_123',
|
|
113
|
+
* created_by: 'user_123',
|
|
114
|
+
* type: 'a2a',
|
|
115
|
+
* status: 'active',
|
|
116
|
+
* monthly_budget: 200,
|
|
117
|
+
* examples: []
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
create(data: Omit<Agent, 'id' | 'created_at' | 'updated_at' | 'last_active'>, options?: RequestOptions): Promise<Agent>;
|
|
96
122
|
/**
|
|
97
123
|
* Update an agent's properties
|
|
98
124
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Board } from '../../types/entities';
|
|
1
|
+
import { Board, CreateBoardInput } from '../../types/entities';
|
|
2
2
|
import { ListParams, Paginated } from '../../types/responses';
|
|
3
3
|
import { HttpClient } from '../http/HttpClient';
|
|
4
4
|
import { RequestOptions } from '../http/types';
|
|
@@ -62,4 +62,37 @@ export declare class BoardsClient {
|
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
get(id: string, options?: RequestOptions): Promise<Board>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new board
|
|
67
|
+
*
|
|
68
|
+
* @param data - Board creation data
|
|
69
|
+
* @param data.name - The board name
|
|
70
|
+
* @param data.team_id - The team this board belongs to
|
|
71
|
+
* @param data.owner_id - The owner of the board
|
|
72
|
+
* @param data.created_by - The user creating the board
|
|
73
|
+
* @param data.description - Board description
|
|
74
|
+
* @param data.agent_ids - Array of agent IDs
|
|
75
|
+
* @param data.member_ids - Array of member IDs
|
|
76
|
+
* @param data.allowed_roles - Array of allowed roles
|
|
77
|
+
* @param data.columns - Array of columns
|
|
78
|
+
* @param options - Optional request configuration
|
|
79
|
+
*
|
|
80
|
+
* @returns The newly created board
|
|
81
|
+
*
|
|
82
|
+
* @throws {Error} If creation fails
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const board = await client.boards.create({
|
|
87
|
+
* name: 'Sales',
|
|
88
|
+
* team_id: 'team_123',
|
|
89
|
+
* owner_id: 'user_123',
|
|
90
|
+
* created_by: 'user_123',
|
|
91
|
+
* description: 'Manage pipeline',
|
|
92
|
+
* columns: []
|
|
93
|
+
* // agent_ids, member_ids, and allowed_roles are optional (default to [])
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
create(data: CreateBoardInput, options?: RequestOptions): Promise<Board>;
|
|
65
98
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { TeamMember } from '../../types/entities';
|
|
2
|
+
import { ListParams, Paginated } from '../../types/responses';
|
|
3
|
+
import { HttpClient } from '../http/HttpClient';
|
|
4
|
+
import { RequestOptions } from '../http/types';
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing team members in the Kaiban platform
|
|
7
|
+
* @category Resources
|
|
8
|
+
*/
|
|
9
|
+
export declare class TeamMembersClient {
|
|
10
|
+
private readonly http;
|
|
11
|
+
constructor(http: HttpClient);
|
|
12
|
+
/**
|
|
13
|
+
* List team members with pagination, filters, and sorting
|
|
14
|
+
*
|
|
15
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
16
|
+
* @param params.limit - Number of items per page (default: 50, max: 100)
|
|
17
|
+
* @param params.after - Cursor to navigate forwards (get items after this cursor)
|
|
18
|
+
* @param params.before - Cursor to navigate backwards (get items before this cursor)
|
|
19
|
+
* @param params.order_by - Fields to sort by (prefix with - for descending order)
|
|
20
|
+
* @param params.filters - Filter parameters to narrow results
|
|
21
|
+
* @param options - Optional request configuration
|
|
22
|
+
*
|
|
23
|
+
* @returns A paginated list of team members
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // List first page of team members
|
|
28
|
+
* const result = await client.teamMembers.list({ limit: 10 });
|
|
29
|
+
* console.log(result.data); // Array of TeamMember objects
|
|
30
|
+
* console.log(result.pagination.next_cursor); // Cursor for next page
|
|
31
|
+
*
|
|
32
|
+
* // Get next page using cursor
|
|
33
|
+
* if (result.pagination.next_cursor) {
|
|
34
|
+
* const nextPage = await client.teamMembers.list({
|
|
35
|
+
* limit: 10,
|
|
36
|
+
* after: result.pagination.next_cursor
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
list(params?: ListParams, options?: RequestOptions): Promise<Paginated<TeamMember>>;
|
|
42
|
+
/**
|
|
43
|
+
* Iterate through all team members using async generator
|
|
44
|
+
* Automatically handles pagination by following next_cursor
|
|
45
|
+
*
|
|
46
|
+
* @param params - Optional query parameters (excluding after/before cursors)
|
|
47
|
+
* @param params.limit - Number of items per page (used internally for pagination)
|
|
48
|
+
* @param params.order_by - Fields to sort by (prefix with - for descending order)
|
|
49
|
+
* @param params.filters - Filter parameters to narrow results
|
|
50
|
+
* @param options - Optional request configuration
|
|
51
|
+
*
|
|
52
|
+
* @yields Individual TeamMember objects
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Iterate through all team members
|
|
57
|
+
* for await (const member of client.teamMembers.listAll()) {
|
|
58
|
+
* console.log(member.id, member.user_id, member.role);
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* // With custom page size and sorting
|
|
62
|
+
* for await (const member of client.teamMembers.listAll({
|
|
63
|
+
* limit: 100,
|
|
64
|
+
* order_by: '-joined_at',
|
|
65
|
+
* filters: { team_id: 'team_123' }
|
|
66
|
+
* })) {
|
|
67
|
+
* console.log(member);
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
listAll(params?: Omit<ListParams, 'after' | 'before'>, options?: RequestOptions): AsyncGenerator<TeamMember, void, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Get a single team member by ID
|
|
74
|
+
*
|
|
75
|
+
* @param id - The unique identifier of the team member
|
|
76
|
+
* @param options - Optional request configuration
|
|
77
|
+
*
|
|
78
|
+
* @returns The team member object
|
|
79
|
+
*
|
|
80
|
+
* @throws {Error} If the team member is not found or request fails
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const member = await client.teamMembers.get('tm-123');
|
|
85
|
+
* console.log(member.user_id, member.role);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
get(id: string, options?: RequestOptions): Promise<TeamMember>;
|
|
89
|
+
}
|
|
@@ -68,16 +68,18 @@ export interface ActivityChange {
|
|
|
68
68
|
new_value: unknown;
|
|
69
69
|
}
|
|
70
70
|
export interface Activity {
|
|
71
|
-
id
|
|
71
|
+
id?: string;
|
|
72
72
|
board_id: string;
|
|
73
|
-
team_id: string;
|
|
74
73
|
card_id: string;
|
|
75
74
|
type: (typeof ActivityType)[keyof typeof ActivityType];
|
|
76
75
|
description: string;
|
|
77
76
|
actor: ActivityActor;
|
|
78
77
|
changes?: ActivityChange[];
|
|
78
|
+
created_at?: ISODate;
|
|
79
|
+
created_by_session_id?: string;
|
|
79
80
|
metadata?: Record<string, unknown>;
|
|
80
81
|
user_id?: string;
|
|
81
|
-
|
|
82
|
+
team_id: string;
|
|
83
|
+
marked_for_display?: boolean;
|
|
82
84
|
}
|
|
83
85
|
export type ActivityCreate = Omit<Activity, 'id' | 'created_at'>;
|
|
@@ -16,22 +16,22 @@ export interface AgentExample {
|
|
|
16
16
|
}
|
|
17
17
|
export interface Agent {
|
|
18
18
|
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
description: string;
|
|
21
|
-
team_id: string;
|
|
22
|
-
status: (typeof AgentStatus)[keyof typeof AgentStatus];
|
|
23
|
-
type: (typeof AgentType)[keyof typeof AgentType];
|
|
24
|
-
roles: string[];
|
|
25
|
-
owner_id: string;
|
|
26
19
|
created_by: string;
|
|
27
|
-
|
|
28
|
-
config?: Record<string, unknown>;
|
|
29
|
-
created_at: ISODate;
|
|
30
|
-
updated_at?: ISODate;
|
|
31
|
-
last_active: ISODate;
|
|
20
|
+
description: string;
|
|
32
21
|
examples: AgentExample[];
|
|
33
22
|
integrations?: string[];
|
|
23
|
+
last_active: ISODate;
|
|
24
|
+
monthly_budget: number;
|
|
25
|
+
name: string;
|
|
26
|
+
owner_id: string;
|
|
27
|
+
roles?: string[];
|
|
28
|
+
status: (typeof AgentStatus)[keyof typeof AgentStatus];
|
|
29
|
+
team_id: string;
|
|
30
|
+
type: (typeof AgentType)[keyof typeof AgentType];
|
|
31
|
+
updated_at: ISODate;
|
|
34
32
|
active_cards?: number;
|
|
33
|
+
created_at?: ISODate;
|
|
34
|
+
config?: Record<string, unknown>;
|
|
35
35
|
}
|
|
36
36
|
export declare const AgentFeedbackStatus: {
|
|
37
37
|
readonly UNPROCESSED: "unprocessed";
|
|
@@ -61,10 +61,10 @@ export interface AgentFeedback {
|
|
|
61
61
|
}
|
|
62
62
|
export interface AgentSupervisorFeedback {
|
|
63
63
|
id: string;
|
|
64
|
-
agent_id: string;
|
|
65
|
-
team_id: string;
|
|
66
64
|
activity_id: string;
|
|
65
|
+
team_id: string;
|
|
67
66
|
board_id: string;
|
|
67
|
+
agent_id: string;
|
|
68
68
|
feedback: string;
|
|
69
69
|
created_by: string;
|
|
70
70
|
created_at: ISODate;
|
|
@@ -9,17 +9,23 @@ export interface Column {
|
|
|
9
9
|
}
|
|
10
10
|
export interface Board {
|
|
11
11
|
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
team_id: string;
|
|
15
|
-
owner_id: string;
|
|
16
|
-
created_by: string;
|
|
17
|
-
created_at: ISODate;
|
|
18
12
|
agent_ids: string[];
|
|
13
|
+
created_at: ISODate;
|
|
14
|
+
created_by: string;
|
|
15
|
+
description: string;
|
|
19
16
|
member_ids: string[];
|
|
20
|
-
|
|
17
|
+
name: string;
|
|
18
|
+
owner_id: string;
|
|
19
|
+
team_id: string;
|
|
21
20
|
columns: Column[];
|
|
22
|
-
|
|
23
|
-
dashboard_id?: string | null;
|
|
24
|
-
is_favorite?: boolean;
|
|
21
|
+
allowed_roles: string[];
|
|
25
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Input type for creating a new board
|
|
25
|
+
* Fields agent_ids, member_ids, and allowed_roles are optional and default to []
|
|
26
|
+
*/
|
|
27
|
+
export type CreateBoardInput = Omit<Board, 'id' | 'created_at'> & {
|
|
28
|
+
agent_ids?: string[];
|
|
29
|
+
member_ids?: string[];
|
|
30
|
+
allowed_roles?: string[];
|
|
31
|
+
};
|