@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.
Files changed (197) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +491 -0
  3. package/build/__tests__/integration/setup.integration.d.ts +104 -0
  4. package/build/__tests__/integration/setup.integration.d.ts.map +1 -0
  5. package/build/__tests__/integration/setup.integration.js +233 -0
  6. package/build/__tests__/integration/setup.integration.js.map +1 -0
  7. package/build/__tests__/mock-data/items-mock-data.d.ts +168 -0
  8. package/build/__tests__/mock-data/items-mock-data.d.ts.map +1 -0
  9. package/build/__tests__/mock-data/items-mock-data.js +370 -0
  10. package/build/__tests__/mock-data/items-mock-data.js.map +1 -0
  11. package/build/__tests__/mock-data/notification-mock-data.d.ts +55 -0
  12. package/build/__tests__/mock-data/notification-mock-data.d.ts.map +1 -0
  13. package/build/__tests__/mock-data/notification-mock-data.js +190 -0
  14. package/build/__tests__/mock-data/notification-mock-data.js.map +1 -0
  15. package/build/__tests__/mock-data/project-epic-mock-data.d.ts +45 -0
  16. package/build/__tests__/mock-data/project-epic-mock-data.d.ts.map +1 -0
  17. package/build/__tests__/mock-data/project-epic-mock-data.js +85 -0
  18. package/build/__tests__/mock-data/project-epic-mock-data.js.map +1 -0
  19. package/build/__tests__/mock-data/tasks-mock-data.d.ts +27 -0
  20. package/build/__tests__/mock-data/tasks-mock-data.d.ts.map +1 -0
  21. package/build/__tests__/mock-data/tasks-mock-data.js +104 -0
  22. package/build/__tests__/mock-data/tasks-mock-data.js.map +1 -0
  23. package/build/__tests__/mock-data/utility-mock-data.d.ts +19 -0
  24. package/build/__tests__/mock-data/utility-mock-data.d.ts.map +1 -0
  25. package/build/__tests__/mock-data/utility-mock-data.js +165 -0
  26. package/build/__tests__/mock-data/utility-mock-data.js.map +1 -0
  27. package/build/__tests__/setup.d.ts +8 -0
  28. package/build/__tests__/setup.d.ts.map +1 -0
  29. package/build/__tests__/setup.js +31 -0
  30. package/build/__tests__/setup.js.map +1 -0
  31. package/build/__tests__/utils/test-helpers.d.ts +110 -0
  32. package/build/__tests__/utils/test-helpers.d.ts.map +1 -0
  33. package/build/__tests__/utils/test-helpers.js +222 -0
  34. package/build/__tests__/utils/test-helpers.js.map +1 -0
  35. package/build/api/podio-api-client.d.ts +364 -0
  36. package/build/api/podio-api-client.d.ts.map +1 -0
  37. package/build/api/podio-api-client.js +696 -0
  38. package/build/api/podio-api-client.js.map +1 -0
  39. package/build/cache/app-cache.d.ts +77 -0
  40. package/build/cache/app-cache.d.ts.map +1 -0
  41. package/build/cache/app-cache.js +230 -0
  42. package/build/cache/app-cache.js.map +1 -0
  43. package/build/cache/base-cache-manager.d.ts +149 -0
  44. package/build/cache/base-cache-manager.d.ts.map +1 -0
  45. package/build/cache/base-cache-manager.js +312 -0
  46. package/build/cache/base-cache-manager.js.map +1 -0
  47. package/build/cache/cache-manager.d.ts +230 -0
  48. package/build/cache/cache-manager.d.ts.map +1 -0
  49. package/build/cache/cache-manager.js +362 -0
  50. package/build/cache/cache-manager.js.map +1 -0
  51. package/build/cache/cache-test.d.ts +9 -0
  52. package/build/cache/cache-test.d.ts.map +1 -0
  53. package/build/cache/cache-test.js +169 -0
  54. package/build/cache/cache-test.js.map +1 -0
  55. package/build/cache/index.d.ts +18 -0
  56. package/build/cache/index.d.ts.map +1 -0
  57. package/build/cache/index.js +20 -0
  58. package/build/cache/index.js.map +1 -0
  59. package/build/cache/migration-helper.d.ts +44 -0
  60. package/build/cache/migration-helper.d.ts.map +1 -0
  61. package/build/cache/migration-helper.js +235 -0
  62. package/build/cache/migration-helper.js.map +1 -0
  63. package/build/cache/project-epic-cache.d.ts +108 -0
  64. package/build/cache/project-epic-cache.d.ts.map +1 -0
  65. package/build/cache/project-epic-cache.js +278 -0
  66. package/build/cache/project-epic-cache.js.map +1 -0
  67. package/build/cache/space-members-cache.d.ts +99 -0
  68. package/build/cache/space-members-cache.d.ts.map +1 -0
  69. package/build/cache/space-members-cache.js +305 -0
  70. package/build/cache/space-members-cache.js.map +1 -0
  71. package/build/cache/storage-adapters.d.ts +100 -0
  72. package/build/cache/storage-adapters.d.ts.map +1 -0
  73. package/build/cache/storage-adapters.js +297 -0
  74. package/build/cache/storage-adapters.js.map +1 -0
  75. package/build/errors/api-errors.d.ts +52 -0
  76. package/build/errors/api-errors.d.ts.map +1 -0
  77. package/build/errors/api-errors.js +86 -0
  78. package/build/errors/api-errors.js.map +1 -0
  79. package/build/errors/auth-errors.d.ts +67 -0
  80. package/build/errors/auth-errors.d.ts.map +1 -0
  81. package/build/errors/auth-errors.js +114 -0
  82. package/build/errors/auth-errors.js.map +1 -0
  83. package/build/errors/base.d.ts +102 -0
  84. package/build/errors/base.d.ts.map +1 -0
  85. package/build/errors/base.js +131 -0
  86. package/build/errors/base.js.map +1 -0
  87. package/build/errors/cache-errors.d.ts +53 -0
  88. package/build/errors/cache-errors.d.ts.map +1 -0
  89. package/build/errors/cache-errors.js +83 -0
  90. package/build/errors/cache-errors.js.map +1 -0
  91. package/build/errors/config-errors.d.ts +58 -0
  92. package/build/errors/config-errors.d.ts.map +1 -0
  93. package/build/errors/config-errors.js +96 -0
  94. package/build/errors/config-errors.js.map +1 -0
  95. package/build/errors/index.d.ts +101 -0
  96. package/build/errors/index.d.ts.map +1 -0
  97. package/build/errors/index.js +135 -0
  98. package/build/errors/index.js.map +1 -0
  99. package/build/errors/structure-errors.d.ts +89 -0
  100. package/build/errors/structure-errors.d.ts.map +1 -0
  101. package/build/errors/structure-errors.js +182 -0
  102. package/build/errors/structure-errors.js.map +1 -0
  103. package/build/errors/validation-errors.d.ts +81 -0
  104. package/build/errors/validation-errors.d.ts.map +1 -0
  105. package/build/errors/validation-errors.js +169 -0
  106. package/build/errors/validation-errors.js.map +1 -0
  107. package/build/fields/field-mapper.d.ts +245 -0
  108. package/build/fields/field-mapper.d.ts.map +1 -0
  109. package/build/fields/field-mapper.js +404 -0
  110. package/build/fields/field-mapper.js.map +1 -0
  111. package/build/index.d.ts +550 -0
  112. package/build/index.d.ts.map +1 -0
  113. package/build/index.js +1527 -0
  114. package/build/index.js.map +1 -0
  115. package/build/oauth-helper.d.ts +189 -0
  116. package/build/oauth-helper.d.ts.map +1 -0
  117. package/build/oauth-helper.js +422 -0
  118. package/build/oauth-helper.js.map +1 -0
  119. package/build/services/app-structure-service.d.ts +49 -0
  120. package/build/services/app-structure-service.d.ts.map +1 -0
  121. package/build/services/app-structure-service.js +122 -0
  122. package/build/services/app-structure-service.js.map +1 -0
  123. package/build/services/code-execution-service.d.ts +88 -0
  124. package/build/services/code-execution-service.d.ts.map +1 -0
  125. package/build/services/code-execution-service.js +342 -0
  126. package/build/services/code-execution-service.js.map +1 -0
  127. package/build/services/comment-service.d.ts +66 -0
  128. package/build/services/comment-service.d.ts.map +1 -0
  129. package/build/services/comment-service.js +139 -0
  130. package/build/services/comment-service.js.map +1 -0
  131. package/build/services/index.d.ts +16 -0
  132. package/build/services/index.d.ts.map +1 -0
  133. package/build/services/index.js +15 -0
  134. package/build/services/index.js.map +1 -0
  135. package/build/services/item-service.d.ts +104 -0
  136. package/build/services/item-service.d.ts.map +1 -0
  137. package/build/services/item-service.js +368 -0
  138. package/build/services/item-service.js.map +1 -0
  139. package/build/services/notification-service.d.ts +125 -0
  140. package/build/services/notification-service.d.ts.map +1 -0
  141. package/build/services/notification-service.js +321 -0
  142. package/build/services/notification-service.js.map +1 -0
  143. package/build/services/project-epic-service.d.ts +73 -0
  144. package/build/services/project-epic-service.d.ts.map +1 -0
  145. package/build/services/project-epic-service.js +248 -0
  146. package/build/services/project-epic-service.js.map +1 -0
  147. package/build/services/response-formatter.d.ts +190 -0
  148. package/build/services/response-formatter.d.ts.map +1 -0
  149. package/build/services/response-formatter.js +1221 -0
  150. package/build/services/response-formatter.js.map +1 -0
  151. package/build/services/search-service.d.ts +103 -0
  152. package/build/services/search-service.d.ts.map +1 -0
  153. package/build/services/search-service.js +273 -0
  154. package/build/services/search-service.js.map +1 -0
  155. package/build/services/task-service.d.ts +70 -0
  156. package/build/services/task-service.d.ts.map +1 -0
  157. package/build/services/task-service.js +156 -0
  158. package/build/services/task-service.js.map +1 -0
  159. package/build/tools/index.d.ts +8 -0
  160. package/build/tools/index.d.ts.map +1 -0
  161. package/build/tools/index.js +8 -0
  162. package/build/tools/index.js.map +1 -0
  163. package/build/tools/tool-definitions.d.ts +89 -0
  164. package/build/tools/tool-definitions.d.ts.map +1 -0
  165. package/build/tools/tool-definitions.js +1167 -0
  166. package/build/tools/tool-definitions.js.map +1 -0
  167. package/build/types/api-types.d.ts +106 -0
  168. package/build/types/api-types.d.ts.map +1 -0
  169. package/build/types/api-types.js +11 -0
  170. package/build/types/api-types.js.map +1 -0
  171. package/build/types/cache-types.d.ts +52 -0
  172. package/build/types/cache-types.d.ts.map +1 -0
  173. package/build/types/cache-types.js +12 -0
  174. package/build/types/cache-types.js.map +1 -0
  175. package/build/types/index.d.ts +31 -0
  176. package/build/types/index.d.ts.map +1 -0
  177. package/build/types/index.js +25 -0
  178. package/build/types/index.js.map +1 -0
  179. package/build/types/notification-types.d.ts +154 -0
  180. package/build/types/notification-types.d.ts.map +1 -0
  181. package/build/types/notification-types.js +7 -0
  182. package/build/types/notification-types.js.map +1 -0
  183. package/build/types/podio-types.d.ts +250 -0
  184. package/build/types/podio-types.d.ts.map +1 -0
  185. package/build/types/podio-types.js +11 -0
  186. package/build/types/podio-types.js.map +1 -0
  187. package/build/types/search-types.d.ts +188 -0
  188. package/build/types/search-types.d.ts.map +1 -0
  189. package/build/types/search-types.js +43 -0
  190. package/build/types/search-types.js.map +1 -0
  191. package/build/utils/debug.d.ts +58 -0
  192. package/build/utils/debug.d.ts.map +1 -0
  193. package/build/utils/debug.js +147 -0
  194. package/build/utils/debug.js.map +1 -0
  195. package/examples/claude-config-example.json +13 -0
  196. package/package.json +87 -0
  197. package/scripts/generate-claude-config.js +107 -0
@@ -0,0 +1,297 @@
1
+ /**
2
+ * @fileoverview Storage adapter implementations for different cache backends
3
+ *
4
+ * This module provides concrete implementations of the StorageAdapter interface
5
+ * for both in-memory and persistent file-based storage. These adapters can be
6
+ * plugged into the BaseCacheManager for different caching strategies.
7
+ */
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ import { PodioCacheError } from '../errors/index.js';
11
+ /**
12
+ * In-memory storage adapter for fast, temporary caching
13
+ *
14
+ * This adapter stores data in a JavaScript Map for maximum performance.
15
+ * Data is lost when the process restarts, making it ideal for frequently
16
+ * accessed, short-lived cache data like user sessions and API responses.
17
+ */
18
+ export class MemoryStorageAdapter {
19
+ cache = new Map();
20
+ async get(key) {
21
+ const entry = this.cache.get(key);
22
+ return entry || null;
23
+ }
24
+ async set(key, entry) {
25
+ this.cache.set(key, entry);
26
+ }
27
+ async delete(key) {
28
+ this.cache.delete(key);
29
+ }
30
+ async clear() {
31
+ this.cache.clear();
32
+ }
33
+ async keys() {
34
+ return Array.from(this.cache.keys());
35
+ }
36
+ async has(key) {
37
+ return this.cache.has(key);
38
+ }
39
+ async size() {
40
+ return this.cache.size;
41
+ }
42
+ }
43
+ /**
44
+ * File-based storage adapter for persistent caching
45
+ *
46
+ * This adapter stores cache entries as individual JSON files on disk.
47
+ * Data persists across process restarts, making it ideal for app structures,
48
+ * configuration data, and other long-lived cache entries.
49
+ */
50
+ export class FileStorageAdapter {
51
+ config;
52
+ constructor(config) {
53
+ this.config = {
54
+ extension: '.json',
55
+ prettyPrint: false,
56
+ encoding: 'utf-8',
57
+ ...config,
58
+ };
59
+ // Ensure cache directory exists
60
+ this.ensureCacheDir();
61
+ }
62
+ async get(key) {
63
+ const filePath = this.getFilePath(key);
64
+ try {
65
+ if (!fs.existsSync(filePath)) {
66
+ return null;
67
+ }
68
+ const content = await fs.promises.readFile(filePath, this.config.encoding);
69
+ const entry = JSON.parse(content);
70
+ // Basic validation of entry structure
71
+ if (!this.isValidEntry(entry)) {
72
+ throw PodioCacheError.corrupted(key, 'Invalid cache entry structure');
73
+ }
74
+ return entry;
75
+ }
76
+ catch (error) {
77
+ if (error instanceof PodioCacheError) {
78
+ throw error;
79
+ }
80
+ throw PodioCacheError.serializationFailed(key, 'deserialize', error);
81
+ }
82
+ }
83
+ async set(key, entry) {
84
+ const filePath = this.getFilePath(key);
85
+ try {
86
+ const content = this.config.prettyPrint
87
+ ? JSON.stringify(entry, null, 2)
88
+ : JSON.stringify(entry);
89
+ await fs.promises.writeFile(filePath, content, this.config.encoding);
90
+ }
91
+ catch (error) {
92
+ throw PodioCacheError.serializationFailed(key, 'serialize', error);
93
+ }
94
+ }
95
+ async delete(key) {
96
+ const filePath = this.getFilePath(key);
97
+ try {
98
+ if (fs.existsSync(filePath)) {
99
+ await fs.promises.unlink(filePath);
100
+ }
101
+ }
102
+ catch (error) {
103
+ throw PodioCacheError.invalidationFailed(key, error);
104
+ }
105
+ }
106
+ async clear() {
107
+ try {
108
+ const files = await this.getCacheFiles();
109
+ await Promise.all(files.map((file) => fs.promises.unlink(file)));
110
+ }
111
+ catch (error) {
112
+ throw PodioCacheError.invalidationFailed('all files', error);
113
+ }
114
+ }
115
+ async keys() {
116
+ try {
117
+ const files = await this.getCacheFiles();
118
+ return files.map((file) => {
119
+ const basename = path.basename(file, this.config.extension);
120
+ return decodeURIComponent(basename);
121
+ });
122
+ }
123
+ catch (error) {
124
+ throw PodioCacheError.readFailed('keys', error);
125
+ }
126
+ }
127
+ async has(key) {
128
+ const filePath = this.getFilePath(key);
129
+ return fs.existsSync(filePath);
130
+ }
131
+ async size() {
132
+ try {
133
+ const files = await this.getCacheFiles();
134
+ return files.length;
135
+ }
136
+ catch (error) {
137
+ return 0; // Return 0 if directory doesn't exist or other error
138
+ }
139
+ }
140
+ /**
141
+ * Get total disk space used by cache files in bytes
142
+ */
143
+ async getDiskUsage() {
144
+ try {
145
+ const files = await this.getCacheFiles();
146
+ let totalSize = 0;
147
+ for (const file of files) {
148
+ const stats = await fs.promises.stat(file);
149
+ totalSize += stats.size;
150
+ }
151
+ return totalSize;
152
+ }
153
+ catch (error) {
154
+ return 0;
155
+ }
156
+ }
157
+ /**
158
+ * Clean up corrupted or invalid cache files
159
+ */
160
+ async cleanupCorrupted() {
161
+ let cleanedCount = 0;
162
+ try {
163
+ const files = await this.getCacheFiles();
164
+ for (const file of files) {
165
+ try {
166
+ const content = await fs.promises.readFile(file, this.config.encoding);
167
+ const entry = JSON.parse(content);
168
+ if (!this.isValidEntry(entry)) {
169
+ await fs.promises.unlink(file);
170
+ cleanedCount++;
171
+ }
172
+ }
173
+ catch (error) {
174
+ // File is corrupted, remove it
175
+ await fs.promises.unlink(file);
176
+ cleanedCount++;
177
+ }
178
+ }
179
+ }
180
+ catch (error) {
181
+ // Ignore errors during cleanup
182
+ }
183
+ return cleanedCount;
184
+ }
185
+ // Private helper methods
186
+ ensureCacheDir() {
187
+ try {
188
+ if (!fs.existsSync(this.config.cacheDir)) {
189
+ fs.mkdirSync(this.config.cacheDir, { recursive: true });
190
+ }
191
+ }
192
+ catch (error) {
193
+ throw PodioCacheError.writeFailed(this.config.cacheDir, new Error(`Failed to create cache directory: ${error}`));
194
+ }
195
+ }
196
+ getFilePath(key) {
197
+ // Encode key to handle special characters safely
198
+ const encodedKey = encodeURIComponent(key);
199
+ return path.join(this.config.cacheDir, `${encodedKey}${this.config.extension}`);
200
+ }
201
+ async getCacheFiles() {
202
+ const files = await fs.promises.readdir(this.config.cacheDir);
203
+ return files
204
+ .filter((file) => file.endsWith(this.config.extension))
205
+ .map((file) => path.join(this.config.cacheDir, file));
206
+ }
207
+ isValidEntry(entry) {
208
+ return (entry &&
209
+ typeof entry === 'object' &&
210
+ 'data' in entry &&
211
+ 'timestamp' in entry &&
212
+ 'ttl' in entry &&
213
+ typeof entry.timestamp === 'number' &&
214
+ typeof entry.ttl === 'number');
215
+ }
216
+ }
217
+ /**
218
+ * Hybrid storage adapter that combines memory and file storage
219
+ *
220
+ * This adapter uses memory storage for fast access and file storage for persistence.
221
+ * It provides the performance benefits of memory caching with the durability of
222
+ * file-based storage. Ideal for app structures and other data that needs both
223
+ * speed and persistence.
224
+ */
225
+ export class HybridStorageAdapter {
226
+ memoryAdapter;
227
+ fileAdapter;
228
+ constructor(fileConfig) {
229
+ this.memoryAdapter = new MemoryStorageAdapter();
230
+ this.fileAdapter = new FileStorageAdapter(fileConfig);
231
+ }
232
+ async get(key) {
233
+ // Try memory first for speed
234
+ let entry = await this.memoryAdapter.get(key);
235
+ if (!entry) {
236
+ // Fall back to file storage
237
+ entry = await this.fileAdapter.get(key);
238
+ if (entry) {
239
+ // Cache in memory for future access
240
+ await this.memoryAdapter.set(key, entry);
241
+ }
242
+ }
243
+ return entry;
244
+ }
245
+ async set(key, entry) {
246
+ // Write to both storage backends
247
+ await Promise.all([this.memoryAdapter.set(key, entry), this.fileAdapter.set(key, entry)]);
248
+ }
249
+ async delete(key) {
250
+ // Remove from both storage backends
251
+ await Promise.all([this.memoryAdapter.delete(key), this.fileAdapter.delete(key)]);
252
+ }
253
+ async clear() {
254
+ // Clear both storage backends
255
+ await Promise.all([this.memoryAdapter.clear(), this.fileAdapter.clear()]);
256
+ }
257
+ async keys() {
258
+ // Use file storage as source of truth for keys
259
+ const fileKeys = await this.fileAdapter.keys();
260
+ return fileKeys;
261
+ }
262
+ async has(key) {
263
+ // Check memory first, then file
264
+ const inMemory = await this.memoryAdapter.has(key);
265
+ if (inMemory)
266
+ return true;
267
+ return await this.fileAdapter.has(key);
268
+ }
269
+ async size() {
270
+ // Use file storage as source of truth for size
271
+ return await this.fileAdapter.size();
272
+ }
273
+ /**
274
+ * Sync memory cache with file storage
275
+ *
276
+ * Loads all file entries into memory for maximum performance.
277
+ * Useful during startup or after memory cache is cleared.
278
+ */
279
+ async syncMemoryFromDisk() {
280
+ const keys = await this.fileAdapter.keys();
281
+ for (const key of keys) {
282
+ const entry = await this.fileAdapter.get(key);
283
+ if (entry) {
284
+ await this.memoryAdapter.set(key, entry);
285
+ }
286
+ }
287
+ }
288
+ /**
289
+ * Get memory cache hit ratio for monitoring
290
+ */
291
+ async getMemoryHitRatio() {
292
+ const memorySize = await this.memoryAdapter.size();
293
+ const totalSize = await this.fileAdapter.size();
294
+ return totalSize > 0 ? memorySize / totalSize : 0;
295
+ }
296
+ }
297
+ //# sourceMappingURL=storage-adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-adapters.js","sourceRoot":"","sources":["../../src/cache/storage-adapters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACvB,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEjD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,KAAK,IAAI,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAoB;QACzC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,IAA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,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @fileoverview API-related error classes for the Podio MCP server
3
+ *
4
+ * This module provides error classes specifically for API request failures,
5
+ * network issues, and HTTP-related problems when communicating with the Podio API.
6
+ */
7
+ import { PodioError, PodioErrorCode, type ErrorContext } from './base.js';
8
+ /**
9
+ * Base class for all Podio API-related errors.
10
+ *
11
+ * This error is thrown when API requests to Podio fail due to network issues,
12
+ * invalid responses, or server errors.
13
+ */
14
+ export declare class PodioApiError extends PodioError {
15
+ constructor(message: string, code?: PodioErrorCode, context?: ErrorContext, cause?: Error);
16
+ /**
17
+ * Creates a PodioApiError from an HTTP response.
18
+ *
19
+ * @param response - The failed HTTP response
20
+ * @param message - Optional custom message
21
+ * @param cause - Original error that caused the API failure
22
+ */
23
+ static fromResponse(response: Response, message?: string, cause?: Error): PodioApiError;
24
+ /**
25
+ * Creates a PodioApiError for network-related failures.
26
+ *
27
+ * @param message - Error message
28
+ * @param cause - Network error that caused the failure
29
+ */
30
+ static networkError(message: string, cause?: Error): PodioApiError;
31
+ /**
32
+ * Creates a PodioApiError for request timeout.
33
+ *
34
+ * @param message - Error message
35
+ * @param url - The URL that timed out
36
+ */
37
+ static timeout(message: string, url?: string): PodioApiError;
38
+ }
39
+ /**
40
+ * Error thrown when an API response has invalid or unexpected structure.
41
+ */
42
+ export declare class PodioApiResponseError extends PodioApiError {
43
+ constructor(message: string, context?: ErrorContext, cause?: Error);
44
+ /**
45
+ * Creates an error for unexpected API response structure.
46
+ *
47
+ * @param expectedStructure - Description of expected structure
48
+ * @param actualResponse - The actual response received
49
+ */
50
+ static unexpectedStructure(expectedStructure: string, actualResponse?: any): PodioApiResponseError;
51
+ }
52
+ //# sourceMappingURL=api-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-errors.d.ts","sourceRoot":"","sources":["../../src/errors/api-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,UAAU;gBAEzC,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,cAAkD,EACxD,OAAO,GAAE,YAAiB,EAC1B,KAAK,CAAC,EAAE,KAAK;IAKf;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,aAAa;IAmBvF;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,aAAa;IAIlE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,aAAa;CAI7D;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAAE,KAAK,CAAC,EAAE,KAAK;IAItE;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CACxB,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,GAAG,GACnB,qBAAqB;CAUzB"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @fileoverview API-related error classes for the Podio MCP server
3
+ *
4
+ * This module provides error classes specifically for API request failures,
5
+ * network issues, and HTTP-related problems when communicating with the Podio API.
6
+ */
7
+ import { PodioError, PodioErrorCode } from './base.js';
8
+ /**
9
+ * Base class for all Podio API-related errors.
10
+ *
11
+ * This error is thrown when API requests to Podio fail due to network issues,
12
+ * invalid responses, or server errors.
13
+ */
14
+ export class PodioApiError extends PodioError {
15
+ constructor(message, code = PodioErrorCode.API_REQUEST_FAILED, context = {}, cause) {
16
+ super(message, code, context, cause);
17
+ }
18
+ /**
19
+ * Creates a PodioApiError from an HTTP response.
20
+ *
21
+ * @param response - The failed HTTP response
22
+ * @param message - Optional custom message
23
+ * @param cause - Original error that caused the API failure
24
+ */
25
+ static fromResponse(response, message, cause) {
26
+ const defaultMessage = `API request failed: ${response.status} ${response.statusText}`;
27
+ const context = {
28
+ statusCode: response.status,
29
+ statusText: response.statusText,
30
+ url: response.url,
31
+ };
32
+ // Determine specific error code based on status
33
+ let code = PodioErrorCode.API_REQUEST_FAILED;
34
+ if (response.status === 408 || response.status === 504) {
35
+ code = PodioErrorCode.API_TIMEOUT;
36
+ }
37
+ else if (response.status >= 400 && response.status < 500) {
38
+ code = PodioErrorCode.API_RESPONSE_INVALID;
39
+ }
40
+ return new PodioApiError(message || defaultMessage, code, context, cause);
41
+ }
42
+ /**
43
+ * Creates a PodioApiError for network-related failures.
44
+ *
45
+ * @param message - Error message
46
+ * @param cause - Network error that caused the failure
47
+ */
48
+ static networkError(message, cause) {
49
+ return new PodioApiError(message, PodioErrorCode.API_NETWORK_ERROR, {}, cause);
50
+ }
51
+ /**
52
+ * Creates a PodioApiError for request timeout.
53
+ *
54
+ * @param message - Error message
55
+ * @param url - The URL that timed out
56
+ */
57
+ static timeout(message, url) {
58
+ const context = url ? { url } : {};
59
+ return new PodioApiError(message, PodioErrorCode.API_TIMEOUT, context);
60
+ }
61
+ }
62
+ /**
63
+ * Error thrown when an API response has invalid or unexpected structure.
64
+ */
65
+ export class PodioApiResponseError extends PodioApiError {
66
+ constructor(message, context = {}, cause) {
67
+ super(message, PodioErrorCode.API_RESPONSE_INVALID, context, cause);
68
+ }
69
+ /**
70
+ * Creates an error for unexpected API response structure.
71
+ *
72
+ * @param expectedStructure - Description of expected structure
73
+ * @param actualResponse - The actual response received
74
+ */
75
+ static unexpectedStructure(expectedStructure, actualResponse) {
76
+ const message = `Unexpected API response structure. Expected: ${expectedStructure}`;
77
+ const context = {
78
+ metadata: {
79
+ expectedStructure,
80
+ actualResponse: actualResponse ? JSON.stringify(actualResponse) : undefined,
81
+ },
82
+ };
83
+ return new PodioApiResponseError(message, context);
84
+ }
85
+ }
86
+ //# sourceMappingURL=api-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-errors.js","sourceRoot":"","sources":["../../src/errors/api-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAqB,MAAM,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IAC3C,YACE,OAAe,EACf,OAAuB,cAAc,CAAC,kBAAkB,EACxD,UAAwB,EAAE,EAC1B,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,QAAkB,EAAE,OAAgB,EAAE,KAAa;QACrE,MAAM,cAAc,GAAG,uBAAuB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvF,MAAM,OAAO,GAAiB;YAC5B,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,GAAG,EAAE,QAAQ,CAAC,GAAG;SAClB,CAAC;QAEF,gDAAgD;QAChD,IAAI,IAAI,GAAG,cAAc,CAAC,kBAAkB,CAAC;QAC7C,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvD,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC;QACpC,CAAC;aAAM,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC3D,IAAI,GAAG,cAAc,CAAC,oBAAoB,CAAC;QAC7C,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,OAAO,IAAI,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAe,EAAE,KAAa;QAChD,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,iBAAiB,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,GAAY;QAC1C,MAAM,OAAO,GAAiB,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,OAAe,EAAE,UAAwB,EAAE,EAAE,KAAa;QACpE,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,oBAAoB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CACxB,iBAAyB,EACzB,cAAoB;QAEpB,MAAM,OAAO,GAAG,gDAAgD,iBAAiB,EAAE,CAAC;QACpF,MAAM,OAAO,GAAiB;YAC5B,QAAQ,EAAE;gBACR,iBAAiB;gBACjB,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;aAC5E;SACF,CAAC;QACF,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;CACF"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @fileoverview Authentication-related error classes for the Podio MCP server
3
+ *
4
+ * This module provides error classes specifically for OAuth authentication failures,
5
+ * token management issues, and authorization problems.
6
+ */
7
+ import { PodioError, PodioErrorCode, type ErrorContext } from './base.js';
8
+ /**
9
+ * Base class for all authentication-related errors.
10
+ *
11
+ * This error is thrown when authentication with Podio fails, including
12
+ * OAuth flow issues, token problems, and credential validation failures.
13
+ */
14
+ export declare class PodioAuthError extends PodioError {
15
+ constructor(message: string, code?: PodioErrorCode, context?: ErrorContext, cause?: Error);
16
+ /**
17
+ * Creates an error for OAuth initialization failure.
18
+ *
19
+ * @param missingVars - Array of missing environment variables
20
+ */
21
+ static notInitialized(missingVars?: string[]): PodioAuthError;
22
+ /**
23
+ * Creates an error for OAuth flow failures.
24
+ *
25
+ * @param step - The OAuth step that failed (e.g., 'authorization', 'token_exchange')
26
+ * @param message - Error message
27
+ * @param cause - Original error
28
+ */
29
+ static oauthFailed(step: string, message: string, cause?: Error): PodioAuthError;
30
+ /**
31
+ * Creates an error for token refresh failures.
32
+ *
33
+ * @param statusCode - HTTP status code from refresh attempt
34
+ * @param statusText - HTTP status text from refresh attempt
35
+ * @param cause - Original error
36
+ */
37
+ static refreshFailed(statusCode?: number, statusText?: string, cause?: Error): PodioAuthError;
38
+ /**
39
+ * Creates an error for expired tokens.
40
+ *
41
+ * @param tokenType - Type of token that expired (e.g., 'access', 'refresh')
42
+ */
43
+ static tokenExpired(tokenType?: string): PodioAuthError;
44
+ /**
45
+ * Creates an error for invalid tokens.
46
+ *
47
+ * @param reason - Reason why the token is invalid
48
+ */
49
+ static tokenInvalid(reason?: string): PodioAuthError;
50
+ /**
51
+ * Creates an error for authorization code exchange failures.
52
+ *
53
+ * @param statusCode - HTTP status code from exchange attempt
54
+ * @param errorText - Error text from the response
55
+ * @param cause - Original error
56
+ */
57
+ static codeExchangeFailed(statusCode: number, errorText: string, cause?: Error): PodioAuthError;
58
+ /**
59
+ * Creates an error for general token failures.
60
+ *
61
+ * Enhanced to provide clear guidance for port conflict issues.
62
+ *
63
+ * @param message - Error message
64
+ */
65
+ static tokenFailure(message: string): PodioAuthError;
66
+ }
67
+ //# sourceMappingURL=auth-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-errors.d.ts","sourceRoot":"","sources":["../../src/errors/auth-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,UAAU;gBAE1C,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,cAAwD,EAC9D,OAAO,GAAE,YAAiB,EAC1B,KAAK,CAAC,EAAE,KAAK;IAKf;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,WAAW,GAAE,MAAM,EAAO,GAAG,cAAc;IAWjE;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,cAAc;IAShF;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,cAAc;IAa7F;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,GAAE,MAAiB,GAAG,cAAc;IAQjE;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc;IAMpD;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,cAAc;IAiB/F;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc;CAgBrD"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @fileoverview Authentication-related error classes for the Podio MCP server
3
+ *
4
+ * This module provides error classes specifically for OAuth authentication failures,
5
+ * token management issues, and authorization problems.
6
+ */
7
+ import { PodioError, PodioErrorCode } from './base.js';
8
+ /**
9
+ * Base class for all authentication-related errors.
10
+ *
11
+ * This error is thrown when authentication with Podio fails, including
12
+ * OAuth flow issues, token problems, and credential validation failures.
13
+ */
14
+ export class PodioAuthError extends PodioError {
15
+ constructor(message, code = PodioErrorCode.AUTH_INVALID_CREDENTIALS, context = {}, cause) {
16
+ super(message, code, context, cause);
17
+ }
18
+ /**
19
+ * Creates an error for OAuth initialization failure.
20
+ *
21
+ * @param missingVars - Array of missing environment variables
22
+ */
23
+ static notInitialized(missingVars = []) {
24
+ const message = missingVars.length > 0
25
+ ? `OAuth helper not initialized. Missing environment variables: ${missingVars.join(', ')}`
26
+ : 'OAuth helper not initialized. Please check your environment variables (PODIO_CLIENT_ID, PODIO_CLIENT_SECRET, PODIO_REDIRECT_URI).';
27
+ return new PodioAuthError(message, PodioErrorCode.AUTH_NOT_INITIALIZED, {
28
+ metadata: { missingVars },
29
+ });
30
+ }
31
+ /**
32
+ * Creates an error for OAuth flow failures.
33
+ *
34
+ * @param step - The OAuth step that failed (e.g., 'authorization', 'token_exchange')
35
+ * @param message - Error message
36
+ * @param cause - Original error
37
+ */
38
+ static oauthFailed(step, message, cause) {
39
+ return new PodioAuthError(`OAuth ${step} failed: ${message}`, PodioErrorCode.AUTH_OAUTH_FAILED, { metadata: { oauthStep: step } }, cause);
40
+ }
41
+ /**
42
+ * Creates an error for token refresh failures.
43
+ *
44
+ * @param statusCode - HTTP status code from refresh attempt
45
+ * @param statusText - HTTP status text from refresh attempt
46
+ * @param cause - Original error
47
+ */
48
+ static refreshFailed(statusCode, statusText, cause) {
49
+ const message = statusCode && statusText
50
+ ? `Failed to refresh token: ${statusCode} ${statusText}`
51
+ : 'Failed to refresh token';
52
+ const context = {};
53
+ if (statusCode)
54
+ context.statusCode = statusCode;
55
+ if (statusText)
56
+ context.statusText = statusText;
57
+ return new PodioAuthError(message, PodioErrorCode.AUTH_REFRESH_FAILED, context, cause);
58
+ }
59
+ /**
60
+ * Creates an error for expired tokens.
61
+ *
62
+ * @param tokenType - Type of token that expired (e.g., 'access', 'refresh')
63
+ */
64
+ static tokenExpired(tokenType = 'access') {
65
+ return new PodioAuthError(`${tokenType.charAt(0).toUpperCase() + tokenType.slice(1)} token has expired`, PodioErrorCode.AUTH_TOKEN_EXPIRED, { metadata: { tokenType } });
66
+ }
67
+ /**
68
+ * Creates an error for invalid tokens.
69
+ *
70
+ * @param reason - Reason why the token is invalid
71
+ */
72
+ static tokenInvalid(reason) {
73
+ const message = reason ? `Token is invalid: ${reason}` : 'Token is invalid';
74
+ return new PodioAuthError(message, PodioErrorCode.AUTH_TOKEN_INVALID, { metadata: { reason } });
75
+ }
76
+ /**
77
+ * Creates an error for authorization code exchange failures.
78
+ *
79
+ * @param statusCode - HTTP status code from exchange attempt
80
+ * @param errorText - Error text from the response
81
+ * @param cause - Original error
82
+ */
83
+ static codeExchangeFailed(statusCode, errorText, cause) {
84
+ const message = `Failed to exchange code for token: ${statusCode} ${errorText}`;
85
+ return new PodioAuthError(message, PodioErrorCode.AUTH_OAUTH_FAILED, {
86
+ statusCode,
87
+ metadata: {
88
+ oauthStep: 'code_exchange',
89
+ errorDetails: errorText,
90
+ },
91
+ }, cause);
92
+ }
93
+ /**
94
+ * Creates an error for general token failures.
95
+ *
96
+ * Enhanced to provide clear guidance for port conflict issues.
97
+ *
98
+ * @param message - Error message
99
+ */
100
+ static tokenFailure(message) {
101
+ // Check if this is a port conflict error and enhance the message
102
+ if (message.includes('EADDRINUSE') || message.includes('address already in use')) {
103
+ const enhancedMessage = `Port conflict detected - OAuth callback server cannot start. ` +
104
+ `The requested port (likely 8080) is already in use by another service. ` +
105
+ `SOLUTION: Please stop the conflicting service or wait for the podio-mcp server to automatically try alternative ports. ` +
106
+ `The server will attempt ports: 8080, 8090, 8100, 8888, 9090 in sequence.`;
107
+ return new PodioAuthError(enhancedMessage, PodioErrorCode.AUTH_TOKEN_INVALID, {
108
+ metadata: { originalMessage: message, portConflict: true },
109
+ });
110
+ }
111
+ return new PodioAuthError(`Token failure: ${message}`, PodioErrorCode.AUTH_TOKEN_INVALID);
112
+ }
113
+ }
114
+ //# sourceMappingURL=auth-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-errors.js","sourceRoot":"","sources":["../../src/errors/auth-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAqB,MAAM,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,YACE,OAAe,EACf,OAAuB,cAAc,CAAC,wBAAwB,EAC9D,UAAwB,EAAE,EAC1B,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,cAAwB,EAAE;QAC9C,MAAM,OAAO,GACX,WAAW,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC,gEAAgE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC1F,CAAC,CAAC,mIAAmI,CAAC;QAE1I,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,oBAAoB,EAAE;YACtE,QAAQ,EAAE,EAAE,WAAW,EAAE;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,OAAe,EAAE,KAAa;QAC7D,OAAO,IAAI,cAAc,CACvB,SAAS,IAAI,YAAY,OAAO,EAAE,EAClC,cAAc,CAAC,iBAAiB,EAChC,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EACjC,KAAK,CACN,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,UAAmB,EAAE,UAAmB,EAAE,KAAa;QAC1E,MAAM,OAAO,GACX,UAAU,IAAI,UAAU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