@forumviriumhelsinki/podio-mcp 2.3.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/LICENSE +21 -0
- package/README.md +491 -0
- package/build/__tests__/integration/setup.integration.d.ts +104 -0
- package/build/__tests__/integration/setup.integration.d.ts.map +1 -0
- package/build/__tests__/integration/setup.integration.js +233 -0
- package/build/__tests__/integration/setup.integration.js.map +1 -0
- package/build/__tests__/mock-data/items-mock-data.d.ts +168 -0
- package/build/__tests__/mock-data/items-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/items-mock-data.js +370 -0
- package/build/__tests__/mock-data/items-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/notification-mock-data.d.ts +55 -0
- package/build/__tests__/mock-data/notification-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/notification-mock-data.js +190 -0
- package/build/__tests__/mock-data/notification-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/project-epic-mock-data.d.ts +45 -0
- package/build/__tests__/mock-data/project-epic-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/project-epic-mock-data.js +85 -0
- package/build/__tests__/mock-data/project-epic-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/tasks-mock-data.d.ts +27 -0
- package/build/__tests__/mock-data/tasks-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/tasks-mock-data.js +104 -0
- package/build/__tests__/mock-data/tasks-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/utility-mock-data.d.ts +19 -0
- package/build/__tests__/mock-data/utility-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/utility-mock-data.js +165 -0
- package/build/__tests__/mock-data/utility-mock-data.js.map +1 -0
- package/build/__tests__/setup.d.ts +8 -0
- package/build/__tests__/setup.d.ts.map +1 -0
- package/build/__tests__/setup.js +31 -0
- package/build/__tests__/setup.js.map +1 -0
- package/build/__tests__/utils/test-helpers.d.ts +110 -0
- package/build/__tests__/utils/test-helpers.d.ts.map +1 -0
- package/build/__tests__/utils/test-helpers.js +222 -0
- package/build/__tests__/utils/test-helpers.js.map +1 -0
- package/build/api/podio-api-client.d.ts +364 -0
- package/build/api/podio-api-client.d.ts.map +1 -0
- package/build/api/podio-api-client.js +696 -0
- package/build/api/podio-api-client.js.map +1 -0
- package/build/cache/app-cache.d.ts +77 -0
- package/build/cache/app-cache.d.ts.map +1 -0
- package/build/cache/app-cache.js +230 -0
- package/build/cache/app-cache.js.map +1 -0
- package/build/cache/base-cache-manager.d.ts +149 -0
- package/build/cache/base-cache-manager.d.ts.map +1 -0
- package/build/cache/base-cache-manager.js +312 -0
- package/build/cache/base-cache-manager.js.map +1 -0
- package/build/cache/cache-manager.d.ts +230 -0
- package/build/cache/cache-manager.d.ts.map +1 -0
- package/build/cache/cache-manager.js +362 -0
- package/build/cache/cache-manager.js.map +1 -0
- package/build/cache/cache-test.d.ts +9 -0
- package/build/cache/cache-test.d.ts.map +1 -0
- package/build/cache/cache-test.js +169 -0
- package/build/cache/cache-test.js.map +1 -0
- package/build/cache/index.d.ts +18 -0
- package/build/cache/index.d.ts.map +1 -0
- package/build/cache/index.js +20 -0
- package/build/cache/index.js.map +1 -0
- package/build/cache/migration-helper.d.ts +44 -0
- package/build/cache/migration-helper.d.ts.map +1 -0
- package/build/cache/migration-helper.js +235 -0
- package/build/cache/migration-helper.js.map +1 -0
- package/build/cache/project-epic-cache.d.ts +108 -0
- package/build/cache/project-epic-cache.d.ts.map +1 -0
- package/build/cache/project-epic-cache.js +278 -0
- package/build/cache/project-epic-cache.js.map +1 -0
- package/build/cache/space-members-cache.d.ts +99 -0
- package/build/cache/space-members-cache.d.ts.map +1 -0
- package/build/cache/space-members-cache.js +305 -0
- package/build/cache/space-members-cache.js.map +1 -0
- package/build/cache/storage-adapters.d.ts +100 -0
- package/build/cache/storage-adapters.d.ts.map +1 -0
- package/build/cache/storage-adapters.js +297 -0
- package/build/cache/storage-adapters.js.map +1 -0
- package/build/errors/api-errors.d.ts +52 -0
- package/build/errors/api-errors.d.ts.map +1 -0
- package/build/errors/api-errors.js +86 -0
- package/build/errors/api-errors.js.map +1 -0
- package/build/errors/auth-errors.d.ts +67 -0
- package/build/errors/auth-errors.d.ts.map +1 -0
- package/build/errors/auth-errors.js +114 -0
- package/build/errors/auth-errors.js.map +1 -0
- package/build/errors/base.d.ts +102 -0
- package/build/errors/base.d.ts.map +1 -0
- package/build/errors/base.js +131 -0
- package/build/errors/base.js.map +1 -0
- package/build/errors/cache-errors.d.ts +53 -0
- package/build/errors/cache-errors.d.ts.map +1 -0
- package/build/errors/cache-errors.js +83 -0
- package/build/errors/cache-errors.js.map +1 -0
- package/build/errors/config-errors.d.ts +58 -0
- package/build/errors/config-errors.d.ts.map +1 -0
- package/build/errors/config-errors.js +96 -0
- package/build/errors/config-errors.js.map +1 -0
- package/build/errors/index.d.ts +101 -0
- package/build/errors/index.d.ts.map +1 -0
- package/build/errors/index.js +135 -0
- package/build/errors/index.js.map +1 -0
- package/build/errors/structure-errors.d.ts +89 -0
- package/build/errors/structure-errors.d.ts.map +1 -0
- package/build/errors/structure-errors.js +182 -0
- package/build/errors/structure-errors.js.map +1 -0
- package/build/errors/validation-errors.d.ts +81 -0
- package/build/errors/validation-errors.d.ts.map +1 -0
- package/build/errors/validation-errors.js +169 -0
- package/build/errors/validation-errors.js.map +1 -0
- package/build/fields/field-mapper.d.ts +245 -0
- package/build/fields/field-mapper.d.ts.map +1 -0
- package/build/fields/field-mapper.js +404 -0
- package/build/fields/field-mapper.js.map +1 -0
- package/build/index.d.ts +550 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1527 -0
- package/build/index.js.map +1 -0
- package/build/oauth-helper.d.ts +189 -0
- package/build/oauth-helper.d.ts.map +1 -0
- package/build/oauth-helper.js +422 -0
- package/build/oauth-helper.js.map +1 -0
- package/build/services/app-structure-service.d.ts +49 -0
- package/build/services/app-structure-service.d.ts.map +1 -0
- package/build/services/app-structure-service.js +122 -0
- package/build/services/app-structure-service.js.map +1 -0
- package/build/services/code-execution-service.d.ts +88 -0
- package/build/services/code-execution-service.d.ts.map +1 -0
- package/build/services/code-execution-service.js +342 -0
- package/build/services/code-execution-service.js.map +1 -0
- package/build/services/comment-service.d.ts +66 -0
- package/build/services/comment-service.d.ts.map +1 -0
- package/build/services/comment-service.js +139 -0
- package/build/services/comment-service.js.map +1 -0
- package/build/services/index.d.ts +16 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +15 -0
- package/build/services/index.js.map +1 -0
- package/build/services/item-service.d.ts +104 -0
- package/build/services/item-service.d.ts.map +1 -0
- package/build/services/item-service.js +368 -0
- package/build/services/item-service.js.map +1 -0
- package/build/services/notification-service.d.ts +125 -0
- package/build/services/notification-service.d.ts.map +1 -0
- package/build/services/notification-service.js +321 -0
- package/build/services/notification-service.js.map +1 -0
- package/build/services/project-epic-service.d.ts +73 -0
- package/build/services/project-epic-service.d.ts.map +1 -0
- package/build/services/project-epic-service.js +248 -0
- package/build/services/project-epic-service.js.map +1 -0
- package/build/services/response-formatter.d.ts +190 -0
- package/build/services/response-formatter.d.ts.map +1 -0
- package/build/services/response-formatter.js +1221 -0
- package/build/services/response-formatter.js.map +1 -0
- package/build/services/search-service.d.ts +103 -0
- package/build/services/search-service.d.ts.map +1 -0
- package/build/services/search-service.js +273 -0
- package/build/services/search-service.js.map +1 -0
- package/build/services/task-service.d.ts +70 -0
- package/build/services/task-service.d.ts.map +1 -0
- package/build/services/task-service.js +156 -0
- package/build/services/task-service.js.map +1 -0
- package/build/tools/index.d.ts +8 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +8 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/tool-definitions.d.ts +89 -0
- package/build/tools/tool-definitions.d.ts.map +1 -0
- package/build/tools/tool-definitions.js +1167 -0
- package/build/tools/tool-definitions.js.map +1 -0
- package/build/types/api-types.d.ts +106 -0
- package/build/types/api-types.d.ts.map +1 -0
- package/build/types/api-types.js +11 -0
- package/build/types/api-types.js.map +1 -0
- package/build/types/cache-types.d.ts +52 -0
- package/build/types/cache-types.d.ts.map +1 -0
- package/build/types/cache-types.js +12 -0
- package/build/types/cache-types.js.map +1 -0
- package/build/types/index.d.ts +31 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +25 -0
- package/build/types/index.js.map +1 -0
- package/build/types/notification-types.d.ts +154 -0
- package/build/types/notification-types.d.ts.map +1 -0
- package/build/types/notification-types.js +7 -0
- package/build/types/notification-types.js.map +1 -0
- package/build/types/podio-types.d.ts +250 -0
- package/build/types/podio-types.d.ts.map +1 -0
- package/build/types/podio-types.js +11 -0
- package/build/types/podio-types.js.map +1 -0
- package/build/types/search-types.d.ts +188 -0
- package/build/types/search-types.d.ts.map +1 -0
- package/build/types/search-types.js +43 -0
- package/build/types/search-types.js.map +1 -0
- package/build/utils/debug.d.ts +58 -0
- package/build/utils/debug.d.ts.map +1 -0
- package/build/utils/debug.js +147 -0
- package/build/utils/debug.js.map +1 -0
- package/examples/claude-config-example.json +13 -0
- package/package.json +87 -0
- package/scripts/generate-claude-config.js +107 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PodioApiClient class for centralized Podio API communication
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized, type-safe client for all Podio API operations,
|
|
5
|
+
* eliminating repeated fetch + auth + error handling patterns throughout the codebase.
|
|
6
|
+
*
|
|
7
|
+
* @module PodioApiClient
|
|
8
|
+
*/
|
|
9
|
+
import { PodioApiError, PodioAuthError } from '../errors/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* PodioApiClient provides centralized API communication for all Podio operations.
|
|
12
|
+
*
|
|
13
|
+
* This class eliminates the repeated fetch + OAuth2 + error handling patterns
|
|
14
|
+
* by providing a consistent, type-safe interface for all API calls.
|
|
15
|
+
*
|
|
16
|
+
* Features:
|
|
17
|
+
* - Automatic OAuth2 authentication
|
|
18
|
+
* - Consistent error handling and retry logic
|
|
19
|
+
* - Request/response logging
|
|
20
|
+
* - Type-safe response handling
|
|
21
|
+
* - Rate limiting and timeout management
|
|
22
|
+
*
|
|
23
|
+
* @example Basic API calls
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const client = new PodioApiClient(oauthHelper);
|
|
26
|
+
*
|
|
27
|
+
* // GET request
|
|
28
|
+
* const items = await client.get<PodioItem[]>('/item/app/12345/filter/');
|
|
29
|
+
*
|
|
30
|
+
* // POST request
|
|
31
|
+
* const newItem = await client.post<PodioItem>('/item/app/12345/', {
|
|
32
|
+
* fields: { title: 'New Task' }
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export class PodioApiClient {
|
|
37
|
+
/** Base URL for all Podio API endpoints */
|
|
38
|
+
baseUrl = 'https://api.podio.com';
|
|
39
|
+
/** OAuth helper for authentication */
|
|
40
|
+
oauthHelper;
|
|
41
|
+
/** Default request timeout in milliseconds */
|
|
42
|
+
defaultTimeout = 30000;
|
|
43
|
+
/** Default number of retries */
|
|
44
|
+
defaultRetries = 2;
|
|
45
|
+
constructor(oauthHelper) {
|
|
46
|
+
if (!oauthHelper) {
|
|
47
|
+
throw PodioAuthError.notInitialized(['OAuth helper']);
|
|
48
|
+
}
|
|
49
|
+
this.oauthHelper = oauthHelper;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Make a GET request to the Podio API
|
|
53
|
+
*
|
|
54
|
+
* @param endpoint - API endpoint path (without base URL)
|
|
55
|
+
* @param config - Request configuration
|
|
56
|
+
* @returns Promise resolving to the API response
|
|
57
|
+
*/
|
|
58
|
+
async get(endpoint, config = {}) {
|
|
59
|
+
return this.request(endpoint, { ...config, method: 'GET' });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Make a POST request to the Podio API
|
|
63
|
+
*
|
|
64
|
+
* @param endpoint - API endpoint path (without base URL)
|
|
65
|
+
* @param body - Request body data
|
|
66
|
+
* @param config - Request configuration
|
|
67
|
+
* @returns Promise resolving to the API response
|
|
68
|
+
*/
|
|
69
|
+
async post(endpoint, body, config = {}) {
|
|
70
|
+
return this.request(endpoint, { ...config, method: 'POST', body });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Make a PUT request to the Podio API
|
|
74
|
+
*
|
|
75
|
+
* @param endpoint - API endpoint path (without base URL)
|
|
76
|
+
* @param body - Request body data
|
|
77
|
+
* @param config - Request configuration
|
|
78
|
+
* @returns Promise resolving to the API response
|
|
79
|
+
*/
|
|
80
|
+
async put(endpoint, body, config = {}) {
|
|
81
|
+
return this.request(endpoint, { ...config, method: 'PUT', body });
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Make a DELETE request to the Podio API
|
|
85
|
+
*
|
|
86
|
+
* @param endpoint - API endpoint path (without base URL)
|
|
87
|
+
* @param config - Request configuration
|
|
88
|
+
* @returns Promise resolving to the API response
|
|
89
|
+
*/
|
|
90
|
+
async delete(endpoint, config = {}) {
|
|
91
|
+
return this.request(endpoint, { ...config, method: 'DELETE' });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Core request method with automatic auth, retry, and error handling
|
|
95
|
+
*
|
|
96
|
+
* @param endpoint - API endpoint path (without base URL)
|
|
97
|
+
* @param config - Request configuration
|
|
98
|
+
* @returns Promise resolving to the API response
|
|
99
|
+
* @throws PodioApiError for API failures
|
|
100
|
+
* @throws PodioAuthError for authentication issues
|
|
101
|
+
*/
|
|
102
|
+
async request(endpoint, config = {}) {
|
|
103
|
+
const { method = 'GET', headers = {}, body, timeout = this.defaultTimeout, retries = this.defaultRetries, includeAuth = true, } = config;
|
|
104
|
+
// Build full URL
|
|
105
|
+
const url = endpoint.startsWith('http') ? endpoint : `${this.baseUrl}${endpoint}`;
|
|
106
|
+
// Prepare headers
|
|
107
|
+
const requestHeaders = {
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
...headers,
|
|
110
|
+
};
|
|
111
|
+
// Add authentication if required
|
|
112
|
+
if (includeAuth) {
|
|
113
|
+
try {
|
|
114
|
+
const accessToken = await this.oauthHelper.getValidToken();
|
|
115
|
+
requestHeaders['Authorization'] = `OAuth2 ${accessToken}`;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw PodioAuthError.tokenFailure(error instanceof Error ? error.message : 'Unknown auth error');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Prepare request options
|
|
122
|
+
const requestOptions = {
|
|
123
|
+
method,
|
|
124
|
+
headers: requestHeaders,
|
|
125
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
126
|
+
};
|
|
127
|
+
// Execute request with retries
|
|
128
|
+
let lastError = null;
|
|
129
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
130
|
+
try {
|
|
131
|
+
console.error(`API ${method} ${endpoint} (attempt ${attempt + 1}/${retries + 1})`);
|
|
132
|
+
// Create abort controller for timeout
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
135
|
+
const response = await fetch(url, {
|
|
136
|
+
...requestOptions,
|
|
137
|
+
signal: controller.signal,
|
|
138
|
+
});
|
|
139
|
+
clearTimeout(timeoutId);
|
|
140
|
+
// Handle successful responses
|
|
141
|
+
if (response.ok) {
|
|
142
|
+
const responseData = await this.parseResponse(response);
|
|
143
|
+
return {
|
|
144
|
+
data: responseData,
|
|
145
|
+
status: response.status,
|
|
146
|
+
headers: response.headers,
|
|
147
|
+
success: true,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Handle error responses
|
|
151
|
+
const errorData = await this.parseErrorResponse(response);
|
|
152
|
+
const apiError = PodioApiError.fromResponse(response, `API request failed: ${method} ${endpoint}`, errorData);
|
|
153
|
+
// Don't retry on certain status codes
|
|
154
|
+
if (response.status === 401 || response.status === 403 || response.status === 404) {
|
|
155
|
+
throw apiError;
|
|
156
|
+
}
|
|
157
|
+
lastError = apiError;
|
|
158
|
+
// Wait before retry (exponential backoff)
|
|
159
|
+
if (attempt < retries) {
|
|
160
|
+
await this.delay(2 ** attempt * 1000);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
// Handle network errors and timeouts
|
|
165
|
+
if (error instanceof Error) {
|
|
166
|
+
if (error.name === 'AbortError') {
|
|
167
|
+
lastError = PodioApiError.timeout(endpoint, timeout.toString());
|
|
168
|
+
}
|
|
169
|
+
else if (error instanceof PodioApiError) {
|
|
170
|
+
lastError = error;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
lastError = PodioApiError.networkError(endpoint, error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
lastError = PodioApiError.networkError(endpoint, new Error('Unknown network error'));
|
|
178
|
+
}
|
|
179
|
+
// Don't retry on certain error types
|
|
180
|
+
if (lastError instanceof PodioApiError && lastError.code >= 2000 && lastError.code < 3000) {
|
|
181
|
+
throw lastError;
|
|
182
|
+
}
|
|
183
|
+
// Wait before retry
|
|
184
|
+
if (attempt < retries) {
|
|
185
|
+
await this.delay(2 ** attempt * 1000);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// All retries failed
|
|
190
|
+
throw lastError || PodioApiError.networkError(endpoint, new Error('All retry attempts failed'));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Parse successful API response
|
|
194
|
+
*
|
|
195
|
+
* @param response - Fetch response object
|
|
196
|
+
* @returns Parsed response data
|
|
197
|
+
*/
|
|
198
|
+
async parseResponse(response) {
|
|
199
|
+
const contentType = response.headers.get('content-type');
|
|
200
|
+
if (contentType && contentType.includes('application/json')) {
|
|
201
|
+
return (await response.json());
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return (await response.text());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Parse error response for detailed error information
|
|
209
|
+
*
|
|
210
|
+
* @param response - Fetch response object
|
|
211
|
+
* @returns Error data object
|
|
212
|
+
*/
|
|
213
|
+
async parseErrorResponse(response) {
|
|
214
|
+
try {
|
|
215
|
+
const contentType = response.headers.get('content-type');
|
|
216
|
+
if (contentType && contentType.includes('application/json')) {
|
|
217
|
+
return await response.json();
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return { message: await response.text() };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
return { message: response.statusText };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Delay execution for specified milliseconds
|
|
229
|
+
*
|
|
230
|
+
* @param ms - Milliseconds to delay
|
|
231
|
+
*/
|
|
232
|
+
delay(ms) {
|
|
233
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
234
|
+
}
|
|
235
|
+
// Convenience methods for common Podio API patterns
|
|
236
|
+
/**
|
|
237
|
+
* Get app structure by app ID
|
|
238
|
+
*
|
|
239
|
+
* @param appId - Podio app ID
|
|
240
|
+
* @returns App structure data
|
|
241
|
+
*/
|
|
242
|
+
async getAppStructure(appId) {
|
|
243
|
+
const response = await this.get(`/app/${appId}`);
|
|
244
|
+
return response.data;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Filter items in an app
|
|
248
|
+
*
|
|
249
|
+
* @param appId - Podio app ID
|
|
250
|
+
* @param filters - Filter criteria
|
|
251
|
+
* @param limit - Maximum number of items to return
|
|
252
|
+
* @returns Filtered items
|
|
253
|
+
*/
|
|
254
|
+
async filterItems(appId, filters = {}, limit = 20) {
|
|
255
|
+
const response = await this.post(`/item/app/${appId}/filter/`, {
|
|
256
|
+
filters: Object.keys(filters).length > 0 ? filters : undefined,
|
|
257
|
+
limit,
|
|
258
|
+
});
|
|
259
|
+
return response.data;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Create a new item in an app
|
|
263
|
+
*
|
|
264
|
+
* @param appId - Podio app ID
|
|
265
|
+
* @param fields - Item field data
|
|
266
|
+
* @returns Created item
|
|
267
|
+
*/
|
|
268
|
+
async createItem(appId, fields) {
|
|
269
|
+
const response = await this.post(`/item/app/${appId}/`, { fields });
|
|
270
|
+
return response.data;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Update an existing item
|
|
274
|
+
*
|
|
275
|
+
* @param itemId - Podio item ID
|
|
276
|
+
* @param fields - Updated field data
|
|
277
|
+
* @returns Updated item
|
|
278
|
+
*/
|
|
279
|
+
async updateItem(itemId, fields) {
|
|
280
|
+
const response = await this.put(`/item/${itemId}`, { fields });
|
|
281
|
+
return response.data;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Delete an item
|
|
285
|
+
*
|
|
286
|
+
* @param itemId - Podio item ID
|
|
287
|
+
*/
|
|
288
|
+
async deleteItem(itemId) {
|
|
289
|
+
await this.delete(`/item/${itemId}`);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Get item details by ID
|
|
293
|
+
*
|
|
294
|
+
* @param itemId - Podio item ID
|
|
295
|
+
* @returns Item details
|
|
296
|
+
*/
|
|
297
|
+
async getItem(itemId) {
|
|
298
|
+
const response = await this.get(`/item/${itemId}`);
|
|
299
|
+
return response.data;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get item details by app-specific item ID
|
|
303
|
+
*
|
|
304
|
+
* @param appId - App ID containing the item
|
|
305
|
+
* @param appItemId - App-specific item ID (ticket/item number)
|
|
306
|
+
* @returns Item details
|
|
307
|
+
*/
|
|
308
|
+
async getItemByAppItemId(appId, appItemId) {
|
|
309
|
+
const response = await this.get(`/app/${appId}/item/${appItemId}`);
|
|
310
|
+
return response.data;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Get tasks for a space
|
|
314
|
+
*
|
|
315
|
+
* @param spaceId - Podio space ID
|
|
316
|
+
* @param filters - Task filters
|
|
317
|
+
* @returns Task list
|
|
318
|
+
*/
|
|
319
|
+
async getTasks(spaceId, filters = {}) {
|
|
320
|
+
const response = await this.get(`/task/space/${spaceId}/`, { headers: filters });
|
|
321
|
+
return response.data;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Create a new task
|
|
325
|
+
*
|
|
326
|
+
* @param taskData - Task creation data
|
|
327
|
+
* @returns Created task
|
|
328
|
+
*/
|
|
329
|
+
async createTask(taskData) {
|
|
330
|
+
const response = await this.post('/task/', taskData);
|
|
331
|
+
return response.data;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Update a task
|
|
335
|
+
*
|
|
336
|
+
* @param taskId - Task ID
|
|
337
|
+
* @param taskData - Updated task data
|
|
338
|
+
* @returns Updated task
|
|
339
|
+
*/
|
|
340
|
+
async updateTask(taskId, taskData) {
|
|
341
|
+
const response = await this.put(`/task/${taskId}`, taskData);
|
|
342
|
+
return response.data;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Delete a task
|
|
346
|
+
*
|
|
347
|
+
* @param taskId - Task ID
|
|
348
|
+
*/
|
|
349
|
+
async deleteTask(taskId) {
|
|
350
|
+
await this.delete(`/task/${taskId}`);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Get space members
|
|
354
|
+
*
|
|
355
|
+
* @param spaceId - Podio space ID
|
|
356
|
+
* @returns Space members
|
|
357
|
+
*/
|
|
358
|
+
async getSpaceMembers(spaceId) {
|
|
359
|
+
const response = await this.get(`/space/${spaceId}/member/v2/`);
|
|
360
|
+
return response.data;
|
|
361
|
+
}
|
|
362
|
+
// ===================
|
|
363
|
+
// NOTIFICATION METHODS
|
|
364
|
+
// ===================
|
|
365
|
+
/**
|
|
366
|
+
* Get notifications for the current user
|
|
367
|
+
*
|
|
368
|
+
* @param filters - Optional filters for notifications
|
|
369
|
+
* @returns List of notifications
|
|
370
|
+
*/
|
|
371
|
+
async getNotifications(filters = {}) {
|
|
372
|
+
const params = new URLSearchParams();
|
|
373
|
+
if (filters.limit)
|
|
374
|
+
params.append('limit', filters.limit.toString());
|
|
375
|
+
if (filters.offset)
|
|
376
|
+
params.append('offset', filters.offset.toString());
|
|
377
|
+
if (filters.viewed !== undefined)
|
|
378
|
+
params.append('viewed', filters.viewed.toString());
|
|
379
|
+
if (filters.status)
|
|
380
|
+
params.append('status', filters.status);
|
|
381
|
+
if (filters.type)
|
|
382
|
+
params.append('type', filters.type);
|
|
383
|
+
if (filters.created_from)
|
|
384
|
+
params.append('created_from', filters.created_from);
|
|
385
|
+
if (filters.created_to)
|
|
386
|
+
params.append('created_to', filters.created_to);
|
|
387
|
+
if (filters.space_id)
|
|
388
|
+
params.append('space_id', filters.space_id.toString());
|
|
389
|
+
if (filters.app_id)
|
|
390
|
+
params.append('app_id', filters.app_id.toString());
|
|
391
|
+
const endpoint = `/notification/${params.toString() ? `?${params.toString()}` : ''}`;
|
|
392
|
+
const response = await this.get(endpoint);
|
|
393
|
+
return {
|
|
394
|
+
notifications: response.data,
|
|
395
|
+
total: response.headers.get('X-Total-Count')
|
|
396
|
+
? parseInt(response.headers.get('X-Total-Count'))
|
|
397
|
+
: undefined,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Get a specific notification by ID
|
|
402
|
+
*
|
|
403
|
+
* @param notificationId - Notification ID
|
|
404
|
+
* @returns Notification details
|
|
405
|
+
*/
|
|
406
|
+
async getNotification(notificationId) {
|
|
407
|
+
const response = await this.get(`/notification/${notificationId}`);
|
|
408
|
+
return response.data;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get inbox new count (number of unread notifications)
|
|
412
|
+
*
|
|
413
|
+
* @returns Inbox count information
|
|
414
|
+
*/
|
|
415
|
+
async getInboxNewCount() {
|
|
416
|
+
const response = await this.get('/notification/inbox/new/count');
|
|
417
|
+
return response.data;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Get notification settings for the current user
|
|
421
|
+
*
|
|
422
|
+
* @returns Notification settings
|
|
423
|
+
*/
|
|
424
|
+
async getNotificationSettings() {
|
|
425
|
+
const response = await this.get('/notification/settings');
|
|
426
|
+
return response.data;
|
|
427
|
+
}
|
|
428
|
+
// =====================
|
|
429
|
+
// SEARCH METHODS
|
|
430
|
+
// =====================
|
|
431
|
+
/**
|
|
432
|
+
* Perform a global search across all accessible Podio content
|
|
433
|
+
*
|
|
434
|
+
* @param filters - Search filters and parameters
|
|
435
|
+
* @returns Search results
|
|
436
|
+
*/
|
|
437
|
+
async searchGlobal(filters) {
|
|
438
|
+
const params = new URLSearchParams();
|
|
439
|
+
params.append('query', filters.query);
|
|
440
|
+
if (filters.type) {
|
|
441
|
+
const types = Array.isArray(filters.type) ? filters.type : [filters.type];
|
|
442
|
+
types.forEach((type) => params.append('type', type));
|
|
443
|
+
}
|
|
444
|
+
if (filters.limit)
|
|
445
|
+
params.append('limit', filters.limit.toString());
|
|
446
|
+
if (filters.offset)
|
|
447
|
+
params.append('offset', filters.offset.toString());
|
|
448
|
+
if (filters.created_from)
|
|
449
|
+
params.append('created_from', filters.created_from);
|
|
450
|
+
if (filters.created_to)
|
|
451
|
+
params.append('created_to', filters.created_to);
|
|
452
|
+
if (filters.fields) {
|
|
453
|
+
filters.fields.forEach((field) => params.append('fields', field));
|
|
454
|
+
}
|
|
455
|
+
const response = await this.get(`/search/v2/?${params.toString()}`);
|
|
456
|
+
return this.transformSearchResponse(response.data, 'global', filters);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Search within a specific space
|
|
460
|
+
*
|
|
461
|
+
* @param spaceId - Space ID to search in
|
|
462
|
+
* @param filters - Search filters and parameters
|
|
463
|
+
* @returns Search results
|
|
464
|
+
*/
|
|
465
|
+
async searchInSpace(spaceId, filters) {
|
|
466
|
+
const params = new URLSearchParams();
|
|
467
|
+
params.append('query', filters.query);
|
|
468
|
+
if (filters.type) {
|
|
469
|
+
const types = Array.isArray(filters.type) ? filters.type : [filters.type];
|
|
470
|
+
types.forEach((type) => params.append('type', type));
|
|
471
|
+
}
|
|
472
|
+
if (filters.limit)
|
|
473
|
+
params.append('limit', filters.limit.toString());
|
|
474
|
+
if (filters.offset)
|
|
475
|
+
params.append('offset', filters.offset.toString());
|
|
476
|
+
if (filters.created_from)
|
|
477
|
+
params.append('created_from', filters.created_from);
|
|
478
|
+
if (filters.created_to)
|
|
479
|
+
params.append('created_to', filters.created_to);
|
|
480
|
+
if (filters.fields) {
|
|
481
|
+
filters.fields.forEach((field) => params.append('fields', field));
|
|
482
|
+
}
|
|
483
|
+
const response = await this.get(`/search/space/${spaceId}/v2/?${params.toString()}`);
|
|
484
|
+
return this.transformSearchResponse(response.data, 'space', filters);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Search within a specific app
|
|
488
|
+
*
|
|
489
|
+
* @param appId - App ID to search in
|
|
490
|
+
* @param filters - Search filters and parameters
|
|
491
|
+
* @returns Search results
|
|
492
|
+
*/
|
|
493
|
+
async searchInApp(appId, filters) {
|
|
494
|
+
const params = new URLSearchParams();
|
|
495
|
+
params.append('query', filters.query);
|
|
496
|
+
if (filters.type) {
|
|
497
|
+
const types = Array.isArray(filters.type) ? filters.type : [filters.type];
|
|
498
|
+
types.forEach((type) => params.append('type', type));
|
|
499
|
+
}
|
|
500
|
+
if (filters.limit)
|
|
501
|
+
params.append('limit', filters.limit.toString());
|
|
502
|
+
if (filters.offset)
|
|
503
|
+
params.append('offset', filters.offset.toString());
|
|
504
|
+
if (filters.created_from)
|
|
505
|
+
params.append('created_from', filters.created_from);
|
|
506
|
+
if (filters.created_to)
|
|
507
|
+
params.append('created_to', filters.created_to);
|
|
508
|
+
if (filters.fields) {
|
|
509
|
+
filters.fields.forEach((field) => params.append('fields', field));
|
|
510
|
+
}
|
|
511
|
+
const response = await this.get(`/search/app/${appId}/v2/?${params.toString()}`);
|
|
512
|
+
return this.transformSearchResponse(response.data, 'app', filters);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Search within a specific organization
|
|
516
|
+
*
|
|
517
|
+
* @param orgId - Organization ID to search in
|
|
518
|
+
* @param filters - Search filters and parameters
|
|
519
|
+
* @returns Search results
|
|
520
|
+
*/
|
|
521
|
+
async searchInOrganization(orgId, filters) {
|
|
522
|
+
const params = new URLSearchParams();
|
|
523
|
+
params.append('query', filters.query);
|
|
524
|
+
if (filters.type) {
|
|
525
|
+
const types = Array.isArray(filters.type) ? filters.type : [filters.type];
|
|
526
|
+
types.forEach((type) => params.append('type', type));
|
|
527
|
+
}
|
|
528
|
+
if (filters.limit)
|
|
529
|
+
params.append('limit', filters.limit.toString());
|
|
530
|
+
if (filters.offset)
|
|
531
|
+
params.append('offset', filters.offset.toString());
|
|
532
|
+
if (filters.created_from)
|
|
533
|
+
params.append('created_from', filters.created_from);
|
|
534
|
+
if (filters.created_to)
|
|
535
|
+
params.append('created_to', filters.created_to);
|
|
536
|
+
if (filters.fields) {
|
|
537
|
+
filters.fields.forEach((field) => params.append('fields', field));
|
|
538
|
+
}
|
|
539
|
+
const response = await this.get(`/search/org/${orgId}/v2/?${params.toString()}`);
|
|
540
|
+
return this.transformSearchResponse(response.data, 'organization', filters);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Transform raw Podio search API response to our standardized format
|
|
544
|
+
*
|
|
545
|
+
* @private
|
|
546
|
+
* @param rawResponse - Raw response from Podio API
|
|
547
|
+
* @param scope - Search scope used
|
|
548
|
+
* @param filters - Original search filters
|
|
549
|
+
* @returns Standardized search response
|
|
550
|
+
*/
|
|
551
|
+
transformSearchResponse(rawResponse, scope, filters) {
|
|
552
|
+
const results = (rawResponse.results || []).map((result) => ({
|
|
553
|
+
id: result.id,
|
|
554
|
+
type: result.type,
|
|
555
|
+
title: result.title || result.name || 'Untitled',
|
|
556
|
+
description: result.description || result.text || '',
|
|
557
|
+
link: result.link,
|
|
558
|
+
app: result.app
|
|
559
|
+
? {
|
|
560
|
+
id: result.app.app_id,
|
|
561
|
+
name: result.app.config?.name || 'Unknown App',
|
|
562
|
+
space_id: result.app.space_id,
|
|
563
|
+
space_name: result.app.space?.name || 'Unknown Space',
|
|
564
|
+
}
|
|
565
|
+
: undefined,
|
|
566
|
+
space: result.space
|
|
567
|
+
? {
|
|
568
|
+
id: result.space.space_id,
|
|
569
|
+
name: result.space.name,
|
|
570
|
+
org_id: result.space.org_id,
|
|
571
|
+
org_name: result.space.org?.name || 'Unknown Organization',
|
|
572
|
+
}
|
|
573
|
+
: undefined,
|
|
574
|
+
user: result.user
|
|
575
|
+
? {
|
|
576
|
+
id: result.user.user_id,
|
|
577
|
+
name: result.user.name,
|
|
578
|
+
mail: result.user.mail,
|
|
579
|
+
avatar: result.user.image?.link,
|
|
580
|
+
}
|
|
581
|
+
: undefined,
|
|
582
|
+
file: result.file
|
|
583
|
+
? {
|
|
584
|
+
id: result.file.file_id,
|
|
585
|
+
name: result.file.name,
|
|
586
|
+
mimetype: result.file.mimetype,
|
|
587
|
+
size: result.file.size,
|
|
588
|
+
}
|
|
589
|
+
: undefined,
|
|
590
|
+
created_on: result.created_on,
|
|
591
|
+
last_event_on: result.last_event_on,
|
|
592
|
+
score: result.score,
|
|
593
|
+
highlights: result.highlights || [],
|
|
594
|
+
}));
|
|
595
|
+
return {
|
|
596
|
+
results,
|
|
597
|
+
total: rawResponse.total || results.length,
|
|
598
|
+
count: results.length,
|
|
599
|
+
offset: filters.offset || 0,
|
|
600
|
+
query: filters.query,
|
|
601
|
+
scope: scope,
|
|
602
|
+
filters,
|
|
603
|
+
search_time: rawResponse.search_time,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
// ===================
|
|
607
|
+
// COMMENT METHODS
|
|
608
|
+
// ===================
|
|
609
|
+
/**
|
|
610
|
+
* Get all comments for a specific item
|
|
611
|
+
*
|
|
612
|
+
* @param itemId - Podio item ID
|
|
613
|
+
* @returns List of comments on the item
|
|
614
|
+
*/
|
|
615
|
+
async getItemComments(itemId) {
|
|
616
|
+
const response = await this.get(`/comment/item/${itemId}/`);
|
|
617
|
+
return response.data;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Create a new comment on an item
|
|
621
|
+
*
|
|
622
|
+
* @param itemId - Podio item ID
|
|
623
|
+
* @param text - Comment text content
|
|
624
|
+
* @returns Created comment
|
|
625
|
+
*/
|
|
626
|
+
async createItemComment(itemId, text) {
|
|
627
|
+
const response = await this.post(`/comment/item/${itemId}/`, { value: text });
|
|
628
|
+
return response.data;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Get a specific comment by ID
|
|
632
|
+
*
|
|
633
|
+
* @param commentId - Comment ID
|
|
634
|
+
* @returns Comment details
|
|
635
|
+
*/
|
|
636
|
+
async getComment(commentId) {
|
|
637
|
+
const response = await this.get(`/comment/${commentId}`);
|
|
638
|
+
return response.data;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Update an existing comment
|
|
642
|
+
*
|
|
643
|
+
* @param commentId - Comment ID
|
|
644
|
+
* @param text - Updated comment text
|
|
645
|
+
* @returns Updated comment
|
|
646
|
+
*/
|
|
647
|
+
async updateComment(commentId, text) {
|
|
648
|
+
const response = await this.put(`/comment/${commentId}`, { text });
|
|
649
|
+
return response.data;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Delete a comment
|
|
653
|
+
*
|
|
654
|
+
* @param commentId - Comment ID
|
|
655
|
+
*/
|
|
656
|
+
async deleteComment(commentId) {
|
|
657
|
+
await this.delete(`/comment/${commentId}`);
|
|
658
|
+
}
|
|
659
|
+
// ===================
|
|
660
|
+
// ITEM ACTIVITY METHODS
|
|
661
|
+
// ===================
|
|
662
|
+
/**
|
|
663
|
+
* Get all revisions/activity for a specific item
|
|
664
|
+
*
|
|
665
|
+
* @param itemId - Podio item ID
|
|
666
|
+
* @returns List of item revisions showing activity history
|
|
667
|
+
*/
|
|
668
|
+
async getItemRevisions(itemId) {
|
|
669
|
+
const response = await this.get(`/item/${itemId}/revision/`);
|
|
670
|
+
return response.data;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Get details of a specific item revision
|
|
674
|
+
*
|
|
675
|
+
* @param itemId - Podio item ID
|
|
676
|
+
* @param revisionId - Revision ID
|
|
677
|
+
* @returns Specific revision details
|
|
678
|
+
*/
|
|
679
|
+
async getItemRevision(itemId, revisionId) {
|
|
680
|
+
const response = await this.get(`/item/${itemId}/revision/${revisionId}`);
|
|
681
|
+
return response.data;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Get the difference between two item revisions
|
|
685
|
+
*
|
|
686
|
+
* @param itemId - Podio item ID
|
|
687
|
+
* @param fromRevision - Starting revision number
|
|
688
|
+
* @param toRevision - Ending revision number
|
|
689
|
+
* @returns Difference between the two revisions
|
|
690
|
+
*/
|
|
691
|
+
async getItemRevisionDiff(itemId, fromRevision, toRevision) {
|
|
692
|
+
const response = await this.get(`/item/${itemId}/revision/${fromRevision}/${toRevision}`);
|
|
693
|
+
return response.data;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
//# sourceMappingURL=podio-api-client.js.map
|