@joyjit/vikunja-mcp 0.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 (424) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1377 -0
  4. package/dist/auth/AuthManager.d.ts +63 -0
  5. package/dist/auth/AuthManager.d.ts.map +1 -0
  6. package/dist/auth/AuthManager.js +137 -0
  7. package/dist/auth/AuthManager.js.map +1 -0
  8. package/dist/auth/index.d.ts +7 -0
  9. package/dist/auth/index.d.ts.map +1 -0
  10. package/dist/auth/index.js +14 -0
  11. package/dist/auth/index.js.map +1 -0
  12. package/dist/auth/permissions.d.ts +60 -0
  13. package/dist/auth/permissions.d.ts.map +1 -0
  14. package/dist/auth/permissions.js +173 -0
  15. package/dist/auth/permissions.js.map +1 -0
  16. package/dist/client/VikunjaClientFactory.d.ts +32 -0
  17. package/dist/client/VikunjaClientFactory.d.ts.map +1 -0
  18. package/dist/client/VikunjaClientFactory.js +66 -0
  19. package/dist/client/VikunjaClientFactory.js.map +1 -0
  20. package/dist/client.d.ts +57 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/client.js +128 -0
  23. package/dist/client.js.map +1 -0
  24. package/dist/config/ConfigurationManager.d.ts +63 -0
  25. package/dist/config/ConfigurationManager.d.ts.map +1 -0
  26. package/dist/config/ConfigurationManager.js +243 -0
  27. package/dist/config/ConfigurationManager.js.map +1 -0
  28. package/dist/config/index.d.ts +8 -0
  29. package/dist/config/index.d.ts.map +1 -0
  30. package/dist/config/index.js +27 -0
  31. package/dist/config/index.js.map +1 -0
  32. package/dist/config/types.d.ts +434 -0
  33. package/dist/config/types.d.ts.map +1 -0
  34. package/dist/config/types.js +93 -0
  35. package/dist/config/types.js.map +1 -0
  36. package/dist/formatters/BatchImportResponseFormatter.d.ts +89 -0
  37. package/dist/formatters/BatchImportResponseFormatter.d.ts.map +1 -0
  38. package/dist/formatters/BatchImportResponseFormatter.js +125 -0
  39. package/dist/formatters/BatchImportResponseFormatter.js.map +1 -0
  40. package/dist/index.d.ts +20 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +119 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/middleware/direct-middleware.d.ts +9 -0
  45. package/dist/middleware/direct-middleware.d.ts.map +1 -0
  46. package/dist/middleware/direct-middleware.js +49 -0
  47. package/dist/middleware/direct-middleware.js.map +1 -0
  48. package/dist/middleware/index.d.ts +8 -0
  49. package/dist/middleware/index.d.ts.map +1 -0
  50. package/dist/middleware/index.js +21 -0
  51. package/dist/middleware/index.js.map +1 -0
  52. package/dist/middleware/simplified-rate-limit.d.ts +147 -0
  53. package/dist/middleware/simplified-rate-limit.d.ts.map +1 -0
  54. package/dist/middleware/simplified-rate-limit.js +542 -0
  55. package/dist/middleware/simplified-rate-limit.js.map +1 -0
  56. package/dist/parsers/CSVParser.d.ts +36 -0
  57. package/dist/parsers/CSVParser.d.ts.map +1 -0
  58. package/dist/parsers/CSVParser.js +69 -0
  59. package/dist/parsers/CSVParser.js.map +1 -0
  60. package/dist/parsers/InputParserFactory.d.ts +17 -0
  61. package/dist/parsers/InputParserFactory.d.ts.map +1 -0
  62. package/dist/parsers/InputParserFactory.js +137 -0
  63. package/dist/parsers/InputParserFactory.js.map +1 -0
  64. package/dist/parsers/JSONParser.d.ts +74 -0
  65. package/dist/parsers/JSONParser.d.ts.map +1 -0
  66. package/dist/parsers/JSONParser.js +69 -0
  67. package/dist/parsers/JSONParser.js.map +1 -0
  68. package/dist/services/EntityResolver.d.ts +75 -0
  69. package/dist/services/EntityResolver.d.ts.map +1 -0
  70. package/dist/services/EntityResolver.js +176 -0
  71. package/dist/services/EntityResolver.js.map +1 -0
  72. package/dist/services/TaskCreationService.d.ts +96 -0
  73. package/dist/services/TaskCreationService.d.ts.map +1 -0
  74. package/dist/services/TaskCreationService.js +361 -0
  75. package/dist/services/TaskCreationService.js.map +1 -0
  76. package/dist/storage/SimpleFilterStorage.d.ts +110 -0
  77. package/dist/storage/SimpleFilterStorage.d.ts.map +1 -0
  78. package/dist/storage/SimpleFilterStorage.js +358 -0
  79. package/dist/storage/SimpleFilterStorage.js.map +1 -0
  80. package/dist/storage/index.d.ts +59 -0
  81. package/dist/storage/index.d.ts.map +1 -0
  82. package/dist/storage/index.js +117 -0
  83. package/dist/storage/index.js.map +1 -0
  84. package/dist/tools/auth.d.ts +9 -0
  85. package/dist/tools/auth.d.ts.map +1 -0
  86. package/dist/tools/auth.js +80 -0
  87. package/dist/tools/auth.js.map +1 -0
  88. package/dist/tools/batch-import.d.ts +5 -0
  89. package/dist/tools/batch-import.d.ts.map +1 -0
  90. package/dist/tools/batch-import.js +150 -0
  91. package/dist/tools/batch-import.js.map +1 -0
  92. package/dist/tools/export.d.ts +14 -0
  93. package/dist/tools/export.d.ts.map +1 -0
  94. package/dist/tools/export.js +232 -0
  95. package/dist/tools/export.js.map +1 -0
  96. package/dist/tools/filters.d.ts +8 -0
  97. package/dist/tools/filters.d.ts.map +1 -0
  98. package/dist/tools/filters.js +419 -0
  99. package/dist/tools/filters.js.map +1 -0
  100. package/dist/tools/index.d.ts +36 -0
  101. package/dist/tools/index.d.ts.map +1 -0
  102. package/dist/tools/index.js +87 -0
  103. package/dist/tools/index.js.map +1 -0
  104. package/dist/tools/labels.d.ts +9 -0
  105. package/dist/tools/labels.d.ts.map +1 -0
  106. package/dist/tools/labels.js +152 -0
  107. package/dist/tools/labels.js.map +1 -0
  108. package/dist/tools/projects/crud.d.ts +118 -0
  109. package/dist/tools/projects/crud.d.ts.map +1 -0
  110. package/dist/tools/projects/crud.js +389 -0
  111. package/dist/tools/projects/crud.js.map +1 -0
  112. package/dist/tools/projects/hierarchy.d.ts +68 -0
  113. package/dist/tools/projects/hierarchy.d.ts.map +1 -0
  114. package/dist/tools/projects/hierarchy.js +280 -0
  115. package/dist/tools/projects/hierarchy.js.map +1 -0
  116. package/dist/tools/projects/index.d.ts +17 -0
  117. package/dist/tools/projects/index.d.ts.map +1 -0
  118. package/dist/tools/projects/index.js +169 -0
  119. package/dist/tools/projects/index.js.map +1 -0
  120. package/dist/tools/projects/response-formatter.d.ts +46 -0
  121. package/dist/tools/projects/response-formatter.d.ts.map +1 -0
  122. package/dist/tools/projects/response-formatter.js +131 -0
  123. package/dist/tools/projects/response-formatter.js.map +1 -0
  124. package/dist/tools/projects/sharing.d.ts +89 -0
  125. package/dist/tools/projects/sharing.d.ts.map +1 -0
  126. package/dist/tools/projects/sharing.js +272 -0
  127. package/dist/tools/projects/sharing.js.map +1 -0
  128. package/dist/tools/projects/validation.d.ts +39 -0
  129. package/dist/tools/projects/validation.d.ts.map +1 -0
  130. package/dist/tools/projects/validation.js +129 -0
  131. package/dist/tools/projects/validation.js.map +1 -0
  132. package/dist/tools/projects.d.ts +10 -0
  133. package/dist/tools/projects.d.ts.map +1 -0
  134. package/dist/tools/projects.js +42 -0
  135. package/dist/tools/projects.js.map +1 -0
  136. package/dist/tools/task-assignees.d.ts +13 -0
  137. package/dist/tools/task-assignees.d.ts.map +1 -0
  138. package/dist/tools/task-assignees.js +62 -0
  139. package/dist/tools/task-assignees.js.map +1 -0
  140. package/dist/tools/task-bulk.d.ts +13 -0
  141. package/dist/tools/task-bulk.d.ts.map +1 -0
  142. package/dist/tools/task-bulk.js +113 -0
  143. package/dist/tools/task-bulk.js.map +1 -0
  144. package/dist/tools/task-comments.d.ts +13 -0
  145. package/dist/tools/task-comments.d.ts.map +1 -0
  146. package/dist/tools/task-comments.js +53 -0
  147. package/dist/tools/task-comments.js.map +1 -0
  148. package/dist/tools/task-crud.d.ts +13 -0
  149. package/dist/tools/task-crud.d.ts.map +1 -0
  150. package/dist/tools/task-crud.js +163 -0
  151. package/dist/tools/task-crud.js.map +1 -0
  152. package/dist/tools/task-labels.d.ts +13 -0
  153. package/dist/tools/task-labels.d.ts.map +1 -0
  154. package/dist/tools/task-labels.js +62 -0
  155. package/dist/tools/task-labels.js.map +1 -0
  156. package/dist/tools/task-relations.d.ts +13 -0
  157. package/dist/tools/task-relations.d.ts.map +1 -0
  158. package/dist/tools/task-relations.js +72 -0
  159. package/dist/tools/task-relations.js.map +1 -0
  160. package/dist/tools/task-reminders.d.ts +13 -0
  161. package/dist/tools/task-reminders.d.ts.map +1 -0
  162. package/dist/tools/task-reminders.js +63 -0
  163. package/dist/tools/task-reminders.js.map +1 -0
  164. package/dist/tools/tasks/assignees/AssigneeOperationsService.d.ts +31 -0
  165. package/dist/tools/tasks/assignees/AssigneeOperationsService.d.ts.map +1 -0
  166. package/dist/tools/tasks/assignees/AssigneeOperationsService.js +95 -0
  167. package/dist/tools/tasks/assignees/AssigneeOperationsService.js.map +1 -0
  168. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.d.ts +32 -0
  169. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.d.ts.map +1 -0
  170. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.js +84 -0
  171. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.js.map +1 -0
  172. package/dist/tools/tasks/assignees/AssigneeValidationService.d.ts +36 -0
  173. package/dist/tools/tasks/assignees/AssigneeValidationService.d.ts.map +1 -0
  174. package/dist/tools/tasks/assignees/AssigneeValidationService.js +63 -0
  175. package/dist/tools/tasks/assignees/AssigneeValidationService.js.map +1 -0
  176. package/dist/tools/tasks/assignees/index.d.ts +40 -0
  177. package/dist/tools/tasks/assignees/index.d.ts.map +1 -0
  178. package/dist/tools/tasks/assignees/index.js +72 -0
  179. package/dist/tools/tasks/assignees/index.js.map +1 -0
  180. package/dist/tools/tasks/bulk/BulkOperationValidator.d.ts +51 -0
  181. package/dist/tools/tasks/bulk/BulkOperationValidator.d.ts.map +1 -0
  182. package/dist/tools/tasks/bulk/BulkOperationValidator.js +149 -0
  183. package/dist/tools/tasks/bulk/BulkOperationValidator.js.map +1 -0
  184. package/dist/tools/tasks/bulk-operations-simplified.d.ts +39 -0
  185. package/dist/tools/tasks/bulk-operations-simplified.d.ts.map +1 -0
  186. package/dist/tools/tasks/bulk-operations-simplified.js +249 -0
  187. package/dist/tools/tasks/bulk-operations-simplified.js.map +1 -0
  188. package/dist/tools/tasks/bulk-operations.d.ts +8 -0
  189. package/dist/tools/tasks/bulk-operations.d.ts.map +1 -0
  190. package/dist/tools/tasks/bulk-operations.js +14 -0
  191. package/dist/tools/tasks/bulk-operations.js.map +1 -0
  192. package/dist/tools/tasks/comments/CommentOperationsService.d.ts +23 -0
  193. package/dist/tools/tasks/comments/CommentOperationsService.d.ts.map +1 -0
  194. package/dist/tools/tasks/comments/CommentOperationsService.js +37 -0
  195. package/dist/tools/tasks/comments/CommentOperationsService.js.map +1 -0
  196. package/dist/tools/tasks/comments/CommentResponseFormatter.d.ts +29 -0
  197. package/dist/tools/tasks/comments/CommentResponseFormatter.d.ts.map +1 -0
  198. package/dist/tools/tasks/comments/CommentResponseFormatter.js +69 -0
  199. package/dist/tools/tasks/comments/CommentResponseFormatter.js.map +1 -0
  200. package/dist/tools/tasks/comments/CommentValidationService.d.ts +33 -0
  201. package/dist/tools/tasks/comments/CommentValidationService.d.ts.map +1 -0
  202. package/dist/tools/tasks/comments/CommentValidationService.js +50 -0
  203. package/dist/tools/tasks/comments/CommentValidationService.js.map +1 -0
  204. package/dist/tools/tasks/comments/index.d.ts +38 -0
  205. package/dist/tools/tasks/comments/index.d.ts.map +1 -0
  206. package/dist/tools/tasks/comments/index.js +62 -0
  207. package/dist/tools/tasks/comments/index.js.map +1 -0
  208. package/dist/tools/tasks/constants.d.ts +17 -0
  209. package/dist/tools/tasks/constants.d.ts.map +1 -0
  210. package/dist/tools/tasks/constants.js +36 -0
  211. package/dist/tools/tasks/constants.js.map +1 -0
  212. package/dist/tools/tasks/crud/TaskCreationService.d.ts +26 -0
  213. package/dist/tools/tasks/crud/TaskCreationService.d.ts.map +1 -0
  214. package/dist/tools/tasks/crud/TaskCreationService.js +228 -0
  215. package/dist/tools/tasks/crud/TaskCreationService.js.map +1 -0
  216. package/dist/tools/tasks/crud/TaskDeletionService.d.ts +18 -0
  217. package/dist/tools/tasks/crud/TaskDeletionService.d.ts.map +1 -0
  218. package/dist/tools/tasks/crud/TaskDeletionService.js +89 -0
  219. package/dist/tools/tasks/crud/TaskDeletionService.js.map +1 -0
  220. package/dist/tools/tasks/crud/TaskReadService.d.ts +18 -0
  221. package/dist/tools/tasks/crud/TaskReadService.d.ts.map +1 -0
  222. package/dist/tools/tasks/crud/TaskReadService.js +58 -0
  223. package/dist/tools/tasks/crud/TaskReadService.js.map +1 -0
  224. package/dist/tools/tasks/crud/TaskResponseFormatter.d.ts +18 -0
  225. package/dist/tools/tasks/crud/TaskResponseFormatter.d.ts.map +1 -0
  226. package/dist/tools/tasks/crud/TaskResponseFormatter.js +244 -0
  227. package/dist/tools/tasks/crud/TaskResponseFormatter.js.map +1 -0
  228. package/dist/tools/tasks/crud/TaskUpdateService.d.ts +29 -0
  229. package/dist/tools/tasks/crud/TaskUpdateService.d.ts.map +1 -0
  230. package/dist/tools/tasks/crud/TaskUpdateService.js +231 -0
  231. package/dist/tools/tasks/crud/TaskUpdateService.js.map +1 -0
  232. package/dist/tools/tasks/crud/index.d.ts +16 -0
  233. package/dist/tools/tasks/crud/index.d.ts.map +1 -0
  234. package/dist/tools/tasks/crud/index.js +20 -0
  235. package/dist/tools/tasks/crud/index.js.map +1 -0
  236. package/dist/tools/tasks/filtering/FilterExecutor.d.ts +38 -0
  237. package/dist/tools/tasks/filtering/FilterExecutor.d.ts.map +1 -0
  238. package/dist/tools/tasks/filtering/FilterExecutor.js +200 -0
  239. package/dist/tools/tasks/filtering/FilterExecutor.js.map +1 -0
  240. package/dist/tools/tasks/filtering/FilterValidator.d.ts +56 -0
  241. package/dist/tools/tasks/filtering/FilterValidator.d.ts.map +1 -0
  242. package/dist/tools/tasks/filtering/FilterValidator.js +183 -0
  243. package/dist/tools/tasks/filtering/FilterValidator.js.map +1 -0
  244. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.d.ts +75 -0
  245. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.d.ts.map +1 -0
  246. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.js +193 -0
  247. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.js.map +1 -0
  248. package/dist/tools/tasks/filtering/evaluators.d.ts +38 -0
  249. package/dist/tools/tasks/filtering/evaluators.d.ts.map +1 -0
  250. package/dist/tools/tasks/filtering/evaluators.js +200 -0
  251. package/dist/tools/tasks/filtering/evaluators.js.map +1 -0
  252. package/dist/tools/tasks/filtering/index.d.ts +11 -0
  253. package/dist/tools/tasks/filtering/index.d.ts.map +1 -0
  254. package/dist/tools/tasks/filtering/index.js +26 -0
  255. package/dist/tools/tasks/filtering/index.js.map +1 -0
  256. package/dist/tools/tasks/index.d.ts +9 -0
  257. package/dist/tools/tasks/index.d.ts.map +1 -0
  258. package/dist/tools/tasks/index.js +245 -0
  259. package/dist/tools/tasks/index.js.map +1 -0
  260. package/dist/tools/tasks/labels.d.ts +39 -0
  261. package/dist/tools/tasks/labels.d.ts.map +1 -0
  262. package/dist/tools/tasks/labels.js +150 -0
  263. package/dist/tools/tasks/labels.js.map +1 -0
  264. package/dist/tools/tasks/reminders.d.ts +39 -0
  265. package/dist/tools/tasks/reminders.d.ts.map +1 -0
  266. package/dist/tools/tasks/reminders.js +147 -0
  267. package/dist/tools/tasks/reminders.js.map +1 -0
  268. package/dist/tools/tasks/types/filters.d.ts +121 -0
  269. package/dist/tools/tasks/types/filters.d.ts.map +1 -0
  270. package/dist/tools/tasks/types/filters.js +7 -0
  271. package/dist/tools/tasks/types/filters.js.map +1 -0
  272. package/dist/tools/tasks/validation.d.ts +44 -0
  273. package/dist/tools/tasks/validation.d.ts.map +1 -0
  274. package/dist/tools/tasks/validation.js +121 -0
  275. package/dist/tools/tasks/validation.js.map +1 -0
  276. package/dist/tools/tasks-relations.d.ts +24 -0
  277. package/dist/tools/tasks-relations.d.ts.map +1 -0
  278. package/dist/tools/tasks-relations.js +203 -0
  279. package/dist/tools/tasks-relations.js.map +1 -0
  280. package/dist/tools/tasks.d.ts +6 -0
  281. package/dist/tools/tasks.d.ts.map +1 -0
  282. package/dist/tools/tasks.js +10 -0
  283. package/dist/tools/tasks.js.map +1 -0
  284. package/dist/tools/teams.d.ts +9 -0
  285. package/dist/tools/teams.d.ts.map +1 -0
  286. package/dist/tools/teams.js +332 -0
  287. package/dist/tools/teams.js.map +1 -0
  288. package/dist/tools/templates.d.ts +9 -0
  289. package/dist/tools/templates.d.ts.map +1 -0
  290. package/dist/tools/templates.js +356 -0
  291. package/dist/tools/templates.js.map +1 -0
  292. package/dist/tools/users.d.ts +9 -0
  293. package/dist/tools/users.d.ts.map +1 -0
  294. package/dist/tools/users.js +239 -0
  295. package/dist/tools/users.js.map +1 -0
  296. package/dist/tools/webhooks.d.ts +11 -0
  297. package/dist/tools/webhooks.d.ts.map +1 -0
  298. package/dist/tools/webhooks.js +378 -0
  299. package/dist/tools/webhooks.js.map +1 -0
  300. package/dist/transforms/base.d.ts +178 -0
  301. package/dist/transforms/base.d.ts.map +1 -0
  302. package/dist/transforms/base.js +134 -0
  303. package/dist/transforms/base.js.map +1 -0
  304. package/dist/transforms/field-selector.d.ts +27 -0
  305. package/dist/transforms/field-selector.d.ts.map +1 -0
  306. package/dist/transforms/field-selector.js +91 -0
  307. package/dist/transforms/field-selector.js.map +1 -0
  308. package/dist/transforms/task.d.ts +207 -0
  309. package/dist/transforms/task.d.ts.map +1 -0
  310. package/dist/transforms/task.js +259 -0
  311. package/dist/transforms/task.js.map +1 -0
  312. package/dist/types/errors.d.ts +55 -0
  313. package/dist/types/errors.d.ts.map +1 -0
  314. package/dist/types/errors.js +44 -0
  315. package/dist/types/errors.js.map +1 -0
  316. package/dist/types/filters.d.ts +146 -0
  317. package/dist/types/filters.d.ts.map +1 -0
  318. package/dist/types/filters.js +22 -0
  319. package/dist/types/filters.js.map +1 -0
  320. package/dist/types/index.d.ts +151 -0
  321. package/dist/types/index.d.ts.map +1 -0
  322. package/dist/types/index.js +24 -0
  323. package/dist/types/index.js.map +1 -0
  324. package/dist/types/node-vikunja-extended.d.ts +36 -0
  325. package/dist/types/node-vikunja-extended.d.ts.map +1 -0
  326. package/dist/types/node-vikunja-extended.js +25 -0
  327. package/dist/types/node-vikunja-extended.js.map +1 -0
  328. package/dist/types/responses.d.ts +118 -0
  329. package/dist/types/responses.d.ts.map +1 -0
  330. package/dist/types/responses.js +26 -0
  331. package/dist/types/responses.js.map +1 -0
  332. package/dist/types/vikunja.d.ts +315 -0
  333. package/dist/types/vikunja.d.ts.map +1 -0
  334. package/dist/types/vikunja.js +7 -0
  335. package/dist/types/vikunja.js.map +1 -0
  336. package/dist/utils/auth-error-handler.d.ts +23 -0
  337. package/dist/utils/auth-error-handler.d.ts.map +1 -0
  338. package/dist/utils/auth-error-handler.js +162 -0
  339. package/dist/utils/auth-error-handler.js.map +1 -0
  340. package/dist/utils/error-handler.d.ts +38 -0
  341. package/dist/utils/error-handler.d.ts.map +1 -0
  342. package/dist/utils/error-handler.js +288 -0
  343. package/dist/utils/error-handler.js.map +1 -0
  344. package/dist/utils/filtering/ClientSideFilteringStrategy.d.ts +13 -0
  345. package/dist/utils/filtering/ClientSideFilteringStrategy.d.ts.map +1 -0
  346. package/dist/utils/filtering/ClientSideFilteringStrategy.js +63 -0
  347. package/dist/utils/filtering/ClientSideFilteringStrategy.js.map +1 -0
  348. package/dist/utils/filtering/FilteringContext.d.ts +27 -0
  349. package/dist/utils/filtering/FilteringContext.d.ts.map +1 -0
  350. package/dist/utils/filtering/FilteringContext.js +43 -0
  351. package/dist/utils/filtering/FilteringContext.js.map +1 -0
  352. package/dist/utils/filtering/HybridFilteringStrategy.d.ts +15 -0
  353. package/dist/utils/filtering/HybridFilteringStrategy.d.ts.map +1 -0
  354. package/dist/utils/filtering/HybridFilteringStrategy.js +55 -0
  355. package/dist/utils/filtering/HybridFilteringStrategy.js.map +1 -0
  356. package/dist/utils/filtering/ServerSideFilteringStrategy.d.ts +13 -0
  357. package/dist/utils/filtering/ServerSideFilteringStrategy.d.ts.map +1 -0
  358. package/dist/utils/filtering/ServerSideFilteringStrategy.js +64 -0
  359. package/dist/utils/filtering/ServerSideFilteringStrategy.js.map +1 -0
  360. package/dist/utils/filtering/TaskFilteringStrategy.d.ts +19 -0
  361. package/dist/utils/filtering/TaskFilteringStrategy.d.ts.map +1 -0
  362. package/dist/utils/filtering/TaskFilteringStrategy.js +10 -0
  363. package/dist/utils/filtering/TaskFilteringStrategy.js.map +1 -0
  364. package/dist/utils/filtering/index.d.ts +13 -0
  365. package/dist/utils/filtering/index.d.ts.map +1 -0
  366. package/dist/utils/filtering/index.js +20 -0
  367. package/dist/utils/filtering/index.js.map +1 -0
  368. package/dist/utils/filtering/types.d.ts +62 -0
  369. package/dist/utils/filtering/types.d.ts.map +1 -0
  370. package/dist/utils/filtering/types.js +6 -0
  371. package/dist/utils/filtering/types.js.map +1 -0
  372. package/dist/utils/filters.d.ts +97 -0
  373. package/dist/utils/filters.d.ts.map +1 -0
  374. package/dist/utils/filters.js +939 -0
  375. package/dist/utils/filters.js.map +1 -0
  376. package/dist/utils/logger.d.ts +26 -0
  377. package/dist/utils/logger.d.ts.map +1 -0
  378. package/dist/utils/logger.js +83 -0
  379. package/dist/utils/logger.js.map +1 -0
  380. package/dist/utils/memory.d.ts +71 -0
  381. package/dist/utils/memory.d.ts.map +1 -0
  382. package/dist/utils/memory.js +194 -0
  383. package/dist/utils/memory.js.map +1 -0
  384. package/dist/utils/performance/batch-processor.d.ts +77 -0
  385. package/dist/utils/performance/batch-processor.d.ts.map +1 -0
  386. package/dist/utils/performance/batch-processor.js +218 -0
  387. package/dist/utils/performance/batch-processor.js.map +1 -0
  388. package/dist/utils/performance/index.d.ts +42 -0
  389. package/dist/utils/performance/index.d.ts.map +1 -0
  390. package/dist/utils/performance/index.js +49 -0
  391. package/dist/utils/performance/index.js.map +1 -0
  392. package/dist/utils/performance/performance-monitor.d.ts +116 -0
  393. package/dist/utils/performance/performance-monitor.d.ts.map +1 -0
  394. package/dist/utils/performance/performance-monitor.js +307 -0
  395. package/dist/utils/performance/performance-monitor.js.map +1 -0
  396. package/dist/utils/response-factory.d.ts +81 -0
  397. package/dist/utils/response-factory.d.ts.map +1 -0
  398. package/dist/utils/response-factory.js +86 -0
  399. package/dist/utils/response-factory.js.map +1 -0
  400. package/dist/utils/retry.d.ts +146 -0
  401. package/dist/utils/retry.d.ts.map +1 -0
  402. package/dist/utils/retry.js +281 -0
  403. package/dist/utils/retry.js.map +1 -0
  404. package/dist/utils/security.d.ts +70 -0
  405. package/dist/utils/security.d.ts.map +1 -0
  406. package/dist/utils/security.js +358 -0
  407. package/dist/utils/security.js.map +1 -0
  408. package/dist/utils/simple-response.d.ts +75 -0
  409. package/dist/utils/simple-response.d.ts.map +1 -0
  410. package/dist/utils/simple-response.js +208 -0
  411. package/dist/utils/simple-response.js.map +1 -0
  412. package/dist/utils/storage-errors.d.ts +9 -0
  413. package/dist/utils/storage-errors.d.ts.map +1 -0
  414. package/dist/utils/storage-errors.js +20 -0
  415. package/dist/utils/storage-errors.js.map +1 -0
  416. package/dist/utils/unicode-fix.d.ts +19 -0
  417. package/dist/utils/unicode-fix.d.ts.map +1 -0
  418. package/dist/utils/unicode-fix.js +70 -0
  419. package/dist/utils/unicode-fix.js.map +1 -0
  420. package/dist/utils/validation.d.ts +103 -0
  421. package/dist/utils/validation.d.ts.map +1 -0
  422. package/dist/utils/validation.js +729 -0
  423. package/dist/utils/validation.js.map +1 -0
  424. package/package.json +148 -0
@@ -0,0 +1,939 @@
1
+ "use strict";
2
+ /**
3
+ * Zod-based filter validation and parsing system
4
+ * Replaces the complex custom tokenizer/parser with secure Zod schemas
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FilterBuilder = exports.SecurityValidator = void 0;
8
+ exports.parseFilterString = parseFilterString;
9
+ exports.validateCondition = validateCondition;
10
+ exports.validateFilterExpression = validateFilterExpression;
11
+ exports.conditionToString = conditionToString;
12
+ exports.groupToString = groupToString;
13
+ exports.expressionToString = expressionToString;
14
+ exports.parseSimpleFilter = parseSimpleFilter;
15
+ exports.applyClientSideFilter = applyClientSideFilter;
16
+ const zod_1 = require("zod");
17
+ /**
18
+ * Security constants
19
+ */
20
+ const MAX_FILTER_LENGTH = 1000;
21
+ const MAX_VALUE_LENGTH = 200;
22
+ const ALLOWED_CHARS = /^[\t\n\r\u0020-\u007D\u00C0-\u017F\u4E00-\u9FFF]*$/;
23
+ /** Fields accepted by the simple single-condition filter helper */
24
+ const SIMPLE_FILTER_FIELDS = new Set([
25
+ 'id', 'title', 'description', 'done', 'priority', 'due_date', 'dueDate',
26
+ 'created', 'updated', 'project_id', 'projectId', 'labels', 'assignees',
27
+ 'percent_done', 'reminder_dates', 'start_date', 'end_date', 'done_at',
28
+ ]);
29
+ /** Operators accepted by the simple single-condition filter helper */
30
+ const SIMPLE_FILTER_OPERATORS = new Set([
31
+ '=', '!=', '>', '>=', '<', '<=', 'like', 'LIKE', 'in', 'not in',
32
+ ]);
33
+ /**
34
+ * Pre-compiled optimized regex patterns for performance and security
35
+ * Using atomic groups, possessive quantifiers, and non-backtracking patterns to prevent ReDoS
36
+ */
37
+ const DATE_PATTERNS = {
38
+ // Combined pattern with atomic groups to prevent backtracking
39
+ QUICK_DATE_CHECK: /^(?:(?:\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?)|now(?:[+-]\d{1,4}[smhdwMy])?|now\/[smhdwMy])$/,
40
+ // Individual optimized patterns for specific validation
41
+ ISO_DATE: /^\d{4}-\d{2}-\d{2}$/,
42
+ ISO_DATETIME: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
43
+ NOW_LITERAL: /^now$/,
44
+ RELATIVE_DATE: /^now([+-]\d{1,4}[smhdwMy])$/,
45
+ PERIOD_DATE: /^now\/([smhdwMy])$/,
46
+ // Fast rejection patterns - optimized for performance
47
+ SECURITY_REJECTION: [
48
+ /\s/, // Any spaces
49
+ /now\+\d+day/, // "day" instead of "d"
50
+ /now\/day/, // "day" instead of "d"
51
+ /\d{4}\/\d{1}\/\d{1}/, // Missing leading zeros in YYYY/M/D
52
+ /\d{1}-\d{2}-\d{4}/, // Wrong order D-MM-YYYY
53
+ /now\+\d+\.\d+[a-z]/, // Decimal numbers
54
+ /now\+\+/, // Double operator
55
+ /now\+-/, // Conflicting operators
56
+ ],
57
+ };
58
+ // Repeated character check for DoS prevention - optimized pattern
59
+ const REPEATED_CHAR_PATTERN = /(.)\1{20,}/;
60
+ /**
61
+ * Zod schemas for validation
62
+ */
63
+ const FilterFieldSchema = zod_1.z.enum([
64
+ 'done', 'priority', 'percentDone', 'dueDate', 'assignees',
65
+ 'labels', 'created', 'updated', 'title', 'description'
66
+ ]);
67
+ const FilterOperatorSchema = zod_1.z.enum([
68
+ '=', '!=', '>', '>=', '<', '<=', 'like', 'LIKE', 'in', 'not in'
69
+ ]);
70
+ const LogicalOperatorSchema = zod_1.z.enum(['&&', '||']);
71
+ const FilterValueSchema = zod_1.z.union([
72
+ zod_1.z.string(),
73
+ zod_1.z.number(),
74
+ zod_1.z.boolean(),
75
+ zod_1.z.array(zod_1.z.string()),
76
+ zod_1.z.array(zod_1.z.number())
77
+ ]);
78
+ const FilterConditionSchema = zod_1.z.object({
79
+ field: FilterFieldSchema,
80
+ operator: FilterOperatorSchema,
81
+ value: FilterValueSchema,
82
+ }).strict();
83
+ const FilterGroupSchema = zod_1.z.object({
84
+ conditions: zod_1.z.array(FilterConditionSchema).min(1, 'Group must contain at least one condition'),
85
+ operator: LogicalOperatorSchema.default('&&'),
86
+ }).strict();
87
+ const FilterExpressionSchema = zod_1.z.object({
88
+ groups: zod_1.z.array(FilterGroupSchema).min(1, 'Expression must contain at least one group'),
89
+ operator: LogicalOperatorSchema.optional(),
90
+ }).strict();
91
+ /**
92
+ * Security validation functions
93
+ */
94
+ exports.SecurityValidator = {
95
+ /**
96
+ * Validates input string contains only allowed characters
97
+ */
98
+ validateAllowedChars(input) {
99
+ return ALLOWED_CHARS.test(input);
100
+ },
101
+ /**
102
+ * Validates filter string length
103
+ */
104
+ validateLength(input) {
105
+ if (input.length > MAX_FILTER_LENGTH) {
106
+ return {
107
+ isValid: false,
108
+ error: `Filter string too long. Maximum length is ${MAX_FILTER_LENGTH} characters, got ${input.length}`
109
+ };
110
+ }
111
+ return { isValid: true };
112
+ },
113
+ /**
114
+ * Validates individual value length and safety
115
+ */
116
+ validateValue(value) {
117
+ if (value.length > MAX_VALUE_LENGTH) {
118
+ return {
119
+ isValid: false,
120
+ error: `Value too long. Maximum length is ${MAX_VALUE_LENGTH} characters`
121
+ };
122
+ }
123
+ return { isValid: true };
124
+ },
125
+ /**
126
+ * Validates filter field names for simple filters
127
+ */
128
+ validateField(field) {
129
+ return SIMPLE_FILTER_FIELDS.has(field);
130
+ },
131
+ /**
132
+ * Validates filter operators for simple filters
133
+ */
134
+ validateOperator(operator) {
135
+ return SIMPLE_FILTER_OPERATORS.has(operator);
136
+ }
137
+ };
138
+ /**
139
+ * Create parse error with context
140
+ */
141
+ function createParseError(message, state, contextLength = 20) {
142
+ const start = Math.max(0, state.position - contextLength);
143
+ const end = Math.min(state.length, state.position + contextLength);
144
+ const prefix = start > 0 ? '...' : '';
145
+ const suffix = end < state.length ? '...' : '';
146
+ const context = state.input.substring(start, end);
147
+ const markerPosition = state.position - start + prefix.length;
148
+ const marker = ' '.repeat(markerPosition) + '^';
149
+ return {
150
+ message,
151
+ position: state.position,
152
+ context: `${prefix}${context}${suffix}\n${marker}`
153
+ };
154
+ }
155
+ /**
156
+ * Skip whitespace in input
157
+ */
158
+ function skipWhitespace(state) {
159
+ while (state.position < state.length && state.input[state.position] !== undefined) {
160
+ const char = state.input[state.position];
161
+ if (char && /\s/.test(char)) {
162
+ state.position++;
163
+ }
164
+ else {
165
+ break;
166
+ }
167
+ }
168
+ }
169
+ /**
170
+ * Parse quoted string value
171
+ */
172
+ function parseQuotedString(state) {
173
+ if (state.position >= state.length || state.input[state.position] !== '"') {
174
+ return null;
175
+ }
176
+ state.position++; // Skip opening quote
177
+ let value = '';
178
+ while (state.position < state.length && state.input[state.position] !== '"') {
179
+ const char = state.input[state.position];
180
+ // Handle escaped quotes
181
+ if (char === '\\' && state.position + 1 < state.length && state.input[state.position + 1] === '"') {
182
+ value += '"';
183
+ state.position += 2;
184
+ }
185
+ else if (char !== undefined) {
186
+ value += char;
187
+ state.position++;
188
+ }
189
+ // Prevent extremely long quoted values
190
+ if (value.length > MAX_VALUE_LENGTH) {
191
+ return null;
192
+ }
193
+ }
194
+ if (state.position >= state.length) {
195
+ return null; // Unclosed quote
196
+ }
197
+ state.position++; // Skip closing quote
198
+ return value;
199
+ }
200
+ /**
201
+ * Parse unquoted value
202
+ */
203
+ function parseUnquotedValue(state) {
204
+ const start = state.position;
205
+ while (state.position < state.length &&
206
+ state.input[state.position] !== undefined) {
207
+ const char = state.input[state.position];
208
+ if (char && /[^\s(),=!<>&|]/.test(char)) {
209
+ state.position++;
210
+ }
211
+ else {
212
+ break;
213
+ }
214
+ }
215
+ if (start === state.position) {
216
+ return null;
217
+ }
218
+ return state.input.substring(start, state.position);
219
+ }
220
+ /**
221
+ * Parse a value (quoted or unquoted)
222
+ */
223
+ function parseValue(state) {
224
+ const quoted = parseQuotedString(state);
225
+ if (quoted !== null) {
226
+ return quoted;
227
+ }
228
+ return parseUnquotedValue(state);
229
+ }
230
+ /**
231
+ * Parse operator token
232
+ */
233
+ function parseOperator(state) {
234
+ const operators = ['>=', '<=', '!=', '>', '<', '=', 'like', 'in', 'not in'];
235
+ for (const op of operators.sort((a, b) => b.length - a.length)) {
236
+ const substr = state.input.substring(state.position, state.position + op.length);
237
+ if (substr.toLowerCase() === op.toLowerCase()) {
238
+ state.position += op.length;
239
+ // Preserve original case
240
+ return substr;
241
+ }
242
+ }
243
+ return null;
244
+ }
245
+ /**
246
+ * Parse field name
247
+ */
248
+ function parseField(state) {
249
+ const fields = ['done', 'priority', 'percentDone', 'dueDate', 'assignees',
250
+ 'labels', 'created', 'updated', 'title', 'description'];
251
+ for (const field of fields) {
252
+ const substr = state.input.substring(state.position, state.position + field.length);
253
+ if (substr === field &&
254
+ (state.position + field.length >= state.length ||
255
+ /[\s=!<>]/.test(state.input[state.position + field.length] || ''))) {
256
+ state.position += field.length;
257
+ return field;
258
+ }
259
+ }
260
+ return null;
261
+ }
262
+ /**
263
+ * Parse logical operator
264
+ */
265
+ function parseLogicalOperator(state) {
266
+ if (state.input.substring(state.position, state.position + 2) === '&&') {
267
+ state.position += 2;
268
+ return '&&';
269
+ }
270
+ if (state.input.substring(state.position, state.position + 2) === '||') {
271
+ state.position += 2;
272
+ return '||';
273
+ }
274
+ return null;
275
+ }
276
+ /**
277
+ * Parse comma-separated values for IN/NOT IN operators
278
+ */
279
+ function parseArrayValues(state) {
280
+ const values = [];
281
+ const firstValue = parseValue(state);
282
+ if (firstValue === null) {
283
+ return null;
284
+ }
285
+ values.push(firstValue);
286
+ while (state.position < state.length) {
287
+ skipWhitespace(state);
288
+ if (state.position >= state.length || state.input[state.position] !== ',') {
289
+ break;
290
+ }
291
+ state.position++; // Skip comma
292
+ skipWhitespace(state);
293
+ const nextValue = parseValue(state);
294
+ if (nextValue === null) {
295
+ return null;
296
+ }
297
+ values.push(nextValue);
298
+ }
299
+ return values;
300
+ }
301
+ /**
302
+ * Convert string value to appropriate type based on field
303
+ */
304
+ function convertValue(value, field, operator) {
305
+ if (operator === 'in' || operator === 'not in') {
306
+ return value.split(',').map(v => v.trim());
307
+ }
308
+ const fieldType = {
309
+ done: 'boolean',
310
+ priority: 'number',
311
+ percentDone: 'number',
312
+ dueDate: 'date',
313
+ assignees: 'array',
314
+ labels: 'array',
315
+ created: 'date',
316
+ updated: 'date',
317
+ title: 'string',
318
+ description: 'string',
319
+ }[field];
320
+ if (fieldType === 'boolean') {
321
+ return value === 'true';
322
+ }
323
+ else if (fieldType === 'number') {
324
+ const num = Number(value);
325
+ if (isNaN(num)) {
326
+ throw new Error(`Invalid number: ${value}`);
327
+ }
328
+ return num;
329
+ }
330
+ return value;
331
+ }
332
+ /**
333
+ * Parse a single condition
334
+ */
335
+ function parseCondition(state) {
336
+ const field = parseField(state);
337
+ if (field === null) {
338
+ return null;
339
+ }
340
+ skipWhitespace(state);
341
+ const operator = parseOperator(state);
342
+ if (operator === null) {
343
+ throw new Error('Expected operator');
344
+ }
345
+ skipWhitespace(state);
346
+ let rawValue;
347
+ if (operator === 'in' || operator === 'not in') {
348
+ const values = parseArrayValues(state);
349
+ if (values === null) {
350
+ throw new Error('Expected value(s) for IN/NOT IN operator');
351
+ }
352
+ rawValue = values.join(',');
353
+ }
354
+ else {
355
+ const value = parseValue(state);
356
+ if (value === null) {
357
+ throw new Error('Expected value');
358
+ }
359
+ rawValue = value;
360
+ }
361
+ try {
362
+ const convertedValue = convertValue(rawValue, field, operator);
363
+ return { field, operator, value: convertedValue };
364
+ }
365
+ catch (error) {
366
+ throw new Error(error instanceof Error ? error.message : 'Invalid value');
367
+ }
368
+ }
369
+ /**
370
+ * Parse a group (conditions optionally in parentheses)
371
+ */
372
+ function parseGroup(state) {
373
+ const conditions = [];
374
+ let operator = '&&';
375
+ let hasParens = false;
376
+ skipWhitespace(state);
377
+ if (state.position < state.length && state.input[state.position] === '(') {
378
+ hasParens = true;
379
+ state.position++; // Skip opening parenthesis
380
+ skipWhitespace(state);
381
+ }
382
+ // Parse first condition
383
+ const firstCondition = parseCondition(state);
384
+ if (firstCondition === null) {
385
+ throw new Error('Expected condition');
386
+ }
387
+ conditions.push(firstCondition);
388
+ skipWhitespace(state);
389
+ // Parse additional conditions with logical operators
390
+ while (state.position < state.length) {
391
+ // Check for closing parenthesis
392
+ if (hasParens && state.position < state.length && state.input[state.position] === ')') {
393
+ state.position++;
394
+ break;
395
+ }
396
+ // Check for logical operator
397
+ const logicalOp = parseLogicalOperator(state);
398
+ if (logicalOp === null) {
399
+ break;
400
+ }
401
+ operator = logicalOp;
402
+ skipWhitespace(state);
403
+ // Parse next condition
404
+ const nextCondition = parseCondition(state);
405
+ if (nextCondition === null) {
406
+ throw new Error('Expected condition after logical operator');
407
+ }
408
+ conditions.push(nextCondition);
409
+ skipWhitespace(state);
410
+ }
411
+ // If we had parentheses but didn't find closing one, it's an error
412
+ if (hasParens && state.position <= state.length && state.input[state.position - 1] !== ')') {
413
+ throw new Error('Expected closing parenthesis');
414
+ }
415
+ return { conditions, operator };
416
+ }
417
+ /**
418
+ * Parse complete filter expression
419
+ */
420
+ function parseExpression(state) {
421
+ const groups = [];
422
+ let groupOperator;
423
+ // Parse first group
424
+ const firstGroup = parseGroup(state);
425
+ groups.push(firstGroup);
426
+ skipWhitespace(state);
427
+ // Parse additional groups with logical operators
428
+ while (state.position < state.length) {
429
+ const logicalOp = parseLogicalOperator(state);
430
+ if (logicalOp === null) {
431
+ break;
432
+ }
433
+ if (!groupOperator) {
434
+ groupOperator = logicalOp;
435
+ }
436
+ skipWhitespace(state);
437
+ const nextGroup = parseGroup(state);
438
+ groups.push(nextGroup);
439
+ skipWhitespace(state);
440
+ }
441
+ const expression = groupOperator
442
+ ? { groups, operator: groupOperator }
443
+ : { groups };
444
+ return expression;
445
+ }
446
+ /**
447
+ * Main filter string parsing function
448
+ * Replaces the complex tokenizer/parser system with Zod validation
449
+ */
450
+ function parseFilterString(filterStr) {
451
+ // Input validation
452
+ if (typeof filterStr !== 'string') {
453
+ return {
454
+ expression: null,
455
+ error: {
456
+ message: 'Filter input must be a string',
457
+ position: 0,
458
+ },
459
+ };
460
+ }
461
+ if (!filterStr || filterStr.trim().length === 0) {
462
+ return {
463
+ expression: null,
464
+ error: {
465
+ message: 'Filter string cannot be empty',
466
+ position: 0,
467
+ },
468
+ };
469
+ }
470
+ // Security validation
471
+ if (!exports.SecurityValidator.validateAllowedChars(filterStr)) {
472
+ return {
473
+ expression: null,
474
+ error: {
475
+ message: 'Filter string contains invalid characters',
476
+ position: 0,
477
+ context: 'Only alphanumeric characters, common punctuation, and international characters are allowed'
478
+ },
479
+ };
480
+ }
481
+ const lengthValidation = exports.SecurityValidator.validateLength(filterStr);
482
+ if (!lengthValidation.isValid) {
483
+ return {
484
+ expression: null,
485
+ error: {
486
+ message: lengthValidation.error || 'Filter string too long',
487
+ position: 0,
488
+ },
489
+ };
490
+ }
491
+ // Parse the filter string
492
+ const state = {
493
+ input: filterStr.trim(),
494
+ position: 0,
495
+ length: filterStr.trim().length
496
+ };
497
+ try {
498
+ const expression = parseExpression(state);
499
+ // Check if we consumed the entire input
500
+ skipWhitespace(state);
501
+ if (state.position < state.length) {
502
+ const remainingChar = state.input[state.position];
503
+ // Handle specific cases that should return "Invalid filter syntax"
504
+ if (remainingChar === '&' || remainingChar === '|' || remainingChar === '!' ||
505
+ remainingChar === '(' || remainingChar === ')') {
506
+ return {
507
+ expression: null,
508
+ error: {
509
+ message: 'Invalid filter syntax',
510
+ position: state.position,
511
+ context: state.input.substring(state.position, Math.min(state.position + 40, state.length))
512
+ }
513
+ };
514
+ }
515
+ return {
516
+ expression: null,
517
+ error: createParseError(`Unexpected token: ${state.input.substring(state.position, Math.min(state.position + 20, state.length))}`, state)
518
+ };
519
+ }
520
+ // Validate with Zod schema
521
+ const validationResult = FilterExpressionSchema.safeParse(expression);
522
+ if (!validationResult.success) {
523
+ return {
524
+ expression: null,
525
+ error: {
526
+ message: 'Invalid filter structure',
527
+ position: 0,
528
+ context: validationResult.error.errors.map(e => e.message).join(', ')
529
+ }
530
+ };
531
+ }
532
+ return { expression: validationResult.data };
533
+ }
534
+ catch (error) {
535
+ const message = error instanceof Error ? error.message : 'Parse error';
536
+ // Handle specific parsing errors that should return "Invalid filter syntax"
537
+ if (message.includes('Expected value') || message.includes('Unclosed quote')) {
538
+ return {
539
+ expression: null,
540
+ error: {
541
+ message: 'Invalid filter syntax',
542
+ position: state.position,
543
+ context: state.input.substring(Math.max(0, state.position - 20), Math.min(state.position + 20, state.length))
544
+ }
545
+ };
546
+ }
547
+ return {
548
+ expression: null,
549
+ error: createParseError(message, state)
550
+ };
551
+ }
552
+ }
553
+ /**
554
+ * Enhanced validation with field type checking and value validation
555
+ */
556
+ function validateFieldTypeAndValue(field, operator, value) {
557
+ const errors = [];
558
+ const fieldType = {
559
+ done: 'boolean',
560
+ priority: 'number',
561
+ percentDone: 'number',
562
+ dueDate: 'date',
563
+ assignees: 'array',
564
+ labels: 'array',
565
+ created: 'date',
566
+ updated: 'date',
567
+ title: 'string',
568
+ description: 'string',
569
+ }[field];
570
+ // Basic field validation
571
+ if (!Object.keys({
572
+ done: 'boolean',
573
+ priority: 'number',
574
+ percentDone: 'number',
575
+ dueDate: 'date',
576
+ assignees: 'array',
577
+ labels: 'array',
578
+ created: 'date',
579
+ updated: 'date',
580
+ title: 'string',
581
+ description: 'string',
582
+ }).includes(field)) {
583
+ return ['Invalid field name'];
584
+ }
585
+ // Operator validation for field types
586
+ if (fieldType === 'boolean' && !['=', '!='].includes(operator)) {
587
+ errors.push(`Invalid operator '${operator}' for boolean field '${field}'. Only = and != are allowed.`);
588
+ }
589
+ if (fieldType === 'array' && !['=', '!=', 'in', 'not in'].includes(operator)) {
590
+ errors.push(`Invalid operator '${operator}' for array field '${field}'. Only =, !=, in, and not in are allowed.`);
591
+ }
592
+ // Value type validation
593
+ if (fieldType === 'boolean') {
594
+ if (typeof value === 'string' && (value === 'true' || value === 'false')) {
595
+ // String boolean values are acceptable
596
+ }
597
+ else if (typeof value !== 'boolean') {
598
+ errors.push(`Field "${field}" requires a boolean value`);
599
+ }
600
+ }
601
+ if (fieldType === 'number' && (typeof value !== 'number' || isNaN(Number(value)))) {
602
+ errors.push(`Field "${field}" requires a numeric value`);
603
+ }
604
+ if (fieldType === 'array' && !Array.isArray(value) && typeof value !== 'string') {
605
+ errors.push(`Field "${field}" requires an array or comma-separated string`);
606
+ }
607
+ // Date validation (optimized for performance and security)
608
+ if (fieldType === 'date' && typeof value === 'string') {
609
+ // Security check: reject extremely long values that could cause DoS
610
+ if (value.length > 50) {
611
+ errors.push(`Field "${field}" requires a valid date value`);
612
+ return errors;
613
+ }
614
+ // Fast security check: prevent repeated characters that could indicate attacks
615
+ if (REPEATED_CHAR_PATTERN.test(value)) {
616
+ errors.push(`Field "${field}" requires a valid date value`);
617
+ return errors;
618
+ }
619
+ // Fast rejection: check against known invalid patterns first (optimized)
620
+ for (const pattern of DATE_PATTERNS.SECURITY_REJECTION) {
621
+ if (pattern.test(value)) {
622
+ errors.push(`Field "${field}" requires a valid date value`);
623
+ return errors;
624
+ }
625
+ }
626
+ // Quick validation: use combined pattern for fast acceptance (prevents backtracking)
627
+ if (!DATE_PATTERNS.QUICK_DATE_CHECK.test(value)) {
628
+ errors.push(`Field "${field}" requires a valid date value`);
629
+ return errors;
630
+ }
631
+ // Specific validation: only run additional checks if needed
632
+ // This minimizes regex operations for common cases
633
+ if (DATE_PATTERNS.ISO_DATE.test(value)) {
634
+ // Validate actual calendar date only for ISO date format
635
+ const dateMatch = value.match(DATE_PATTERNS.ISO_DATE);
636
+ if (dateMatch) {
637
+ const [yearStr, monthStr, dayStr] = dateMatch[0].split('-');
638
+ if (!yearStr || !monthStr || !dayStr) {
639
+ errors.push(`Field "${field}" requires a valid date in YYYY-MM-DD format`);
640
+ return errors;
641
+ }
642
+ const year = parseInt(yearStr, 10);
643
+ const month = parseInt(monthStr, 10);
644
+ const day = parseInt(dayStr, 10);
645
+ const date = new Date(year, month - 1, day);
646
+ // Check if the date is valid (month and day within bounds)
647
+ if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
648
+ errors.push(`Field "${field}" requires a valid date value`);
649
+ return errors;
650
+ }
651
+ }
652
+ }
653
+ // No additional validation needed for other formats - they were validated by QUICK_DATE_CHECK
654
+ }
655
+ return errors;
656
+ }
657
+ /**
658
+ * Validate a filter condition using enhanced validation
659
+ */
660
+ function validateCondition(condition) {
661
+ // Check if condition has valid structure first
662
+ const result = FilterConditionSchema.safeParse(condition);
663
+ if (!result.success) {
664
+ const errors = result.error.errors.map(e => e.message);
665
+ // Convert Zod enum error to more user-friendly message
666
+ if (errors.some(e => e.includes('enum value'))) {
667
+ return ['Invalid field name'];
668
+ }
669
+ return errors;
670
+ }
671
+ const { field, operator, value } = condition;
672
+ // Enhanced field and value validation
673
+ const fieldValidationErrors = validateFieldTypeAndValue(field, operator, value);
674
+ return fieldValidationErrors;
675
+ }
676
+ /**
677
+ * Validate filter expression using Zod
678
+ */
679
+ function validateFilterExpression(expression, config = {}) {
680
+ const errors = [];
681
+ const warnings = [];
682
+ // Zod schema validation
683
+ const schemaResult = FilterExpressionSchema.safeParse(expression);
684
+ if (!schemaResult.success) {
685
+ errors.push(...schemaResult.error.errors.map(e => e.message));
686
+ }
687
+ // Custom validation
688
+ if (Array.isArray(expression.groups)) {
689
+ expression.groups.forEach((group, groupIndex) => {
690
+ if (!group.conditions || group.conditions.length === 0) {
691
+ errors.push(`Group ${groupIndex + 1} must contain at least one condition`);
692
+ }
693
+ group.conditions.forEach((condition, conditionIndex) => {
694
+ const conditionErrors = validateCondition(condition);
695
+ conditionErrors.forEach(errorMessage => {
696
+ errors.push(`Group ${groupIndex + 1}, Condition ${conditionIndex + 1}: ${errorMessage}`);
697
+ });
698
+ });
699
+ });
700
+ // Performance warnings
701
+ const totalConditions = expression.groups.reduce((sum, group) => sum + group.conditions.length, 0);
702
+ const threshold = config.performanceWarningThreshold ?? 10;
703
+ if (totalConditions > threshold) {
704
+ warnings.push(`Complex filters with many conditions (${totalConditions}) may impact performance`);
705
+ }
706
+ }
707
+ const result = {
708
+ valid: errors.length === 0,
709
+ errors,
710
+ };
711
+ if (warnings.length > 0) {
712
+ result.warnings = warnings;
713
+ }
714
+ return result;
715
+ }
716
+ /**
717
+ * Convert condition to string representation
718
+ */
719
+ function conditionToString(condition) {
720
+ const { field, operator, value } = condition;
721
+ let valueStr;
722
+ if (Array.isArray(value)) {
723
+ valueStr = value.join(', ');
724
+ }
725
+ else if (typeof value === 'string' && operator === 'like') {
726
+ valueStr = `"${value}"`;
727
+ }
728
+ else if (typeof value === 'boolean') {
729
+ valueStr = value.toString();
730
+ }
731
+ else {
732
+ valueStr = String(value);
733
+ }
734
+ if (operator === 'in' || operator === 'not in') {
735
+ return `${field} ${operator} ${valueStr}`;
736
+ }
737
+ return `${field} ${operator} ${valueStr}`;
738
+ }
739
+ /**
740
+ * Convert group to string representation
741
+ */
742
+ function groupToString(group) {
743
+ const conditions = group.conditions.map(conditionToString);
744
+ return conditions.length > 1
745
+ ? `(${conditions.join(` ${group.operator} `)})`
746
+ : conditions[0] || '';
747
+ }
748
+ /**
749
+ * Convert expression to string representation
750
+ */
751
+ function expressionToString(expression) {
752
+ const groups = expression.groups.map(groupToString);
753
+ const operator = expression.operator || '&&';
754
+ return groups.join(` ${operator} `);
755
+ }
756
+ /**
757
+ * Filter builder class for fluent construction
758
+ */
759
+ class FilterBuilder {
760
+ expression;
761
+ currentGroup;
762
+ constructor() {
763
+ this.currentGroup = {
764
+ conditions: [],
765
+ operator: '&&',
766
+ };
767
+ this.expression = {
768
+ groups: [this.currentGroup],
769
+ };
770
+ }
771
+ where(field, operator, value) {
772
+ this.currentGroup.conditions.push({
773
+ field,
774
+ operator,
775
+ value: value,
776
+ });
777
+ return this;
778
+ }
779
+ and() {
780
+ this.currentGroup.operator = '&&';
781
+ return this;
782
+ }
783
+ or() {
784
+ this.currentGroup.operator = '||';
785
+ return this;
786
+ }
787
+ group(operator = '&&') {
788
+ this.currentGroup = {
789
+ conditions: [],
790
+ operator,
791
+ };
792
+ this.expression.groups.push(this.currentGroup);
793
+ return this;
794
+ }
795
+ groupOperator(operator) {
796
+ this.expression.operator = operator;
797
+ return this;
798
+ }
799
+ build() {
800
+ this.expression.groups = this.expression.groups.filter((g) => g.conditions.length > 0);
801
+ return this.expression;
802
+ }
803
+ toString() {
804
+ return expressionToString(this.build());
805
+ }
806
+ validate(config) {
807
+ return validateFilterExpression(this.build(), config);
808
+ }
809
+ }
810
+ exports.FilterBuilder = FilterBuilder;
811
+ /**
812
+ * Parse a simple single-condition filter ("field operator value").
813
+ * Returns null when the input is empty, too long, or not a valid simple expression.
814
+ */
815
+ function parseSimpleFilter(filterStr) {
816
+ if (typeof filterStr !== 'string' || filterStr.length === 0 || filterStr.length > 200) {
817
+ return null;
818
+ }
819
+ const match = filterStr.match(/^(\w+)\s*(=|!=|>=|<=|>|<|like|in|not in)\s*(.+)$/i);
820
+ if (!match) {
821
+ return null;
822
+ }
823
+ const field = match[1];
824
+ const operator = match[2];
825
+ const valueStr = match[3];
826
+ if (!field ||
827
+ !operator ||
828
+ !valueStr ||
829
+ !SIMPLE_FILTER_FIELDS.has(field) ||
830
+ !SIMPLE_FILTER_OPERATORS.has(operator)) {
831
+ return null;
832
+ }
833
+ let value;
834
+ try {
835
+ value = JSON.parse(valueStr);
836
+ }
837
+ catch {
838
+ value = valueStr;
839
+ }
840
+ return {
841
+ field,
842
+ operator: operator.toLowerCase() === 'like' ? 'like' : operator,
843
+ value,
844
+ };
845
+ }
846
+ function getTaskPropertyValue(task, field) {
847
+ const value = task[field];
848
+ if (typeof value === 'string' ||
849
+ typeof value === 'number' ||
850
+ typeof value === 'boolean' ||
851
+ value === null ||
852
+ value === undefined) {
853
+ return value;
854
+ }
855
+ if (Array.isArray(value)) {
856
+ if (value.every((item) => typeof item === 'string')) {
857
+ return value;
858
+ }
859
+ if (value.every((item) => typeof item === 'number')) {
860
+ return value;
861
+ }
862
+ }
863
+ return undefined;
864
+ }
865
+ function compareScalarValues(taskValue, filterValue, operator) {
866
+ if (Array.isArray(taskValue)) {
867
+ return false;
868
+ }
869
+ if (typeof taskValue === 'number' && typeof filterValue === 'number') {
870
+ switch (operator) {
871
+ case '>': return taskValue > filterValue;
872
+ case '>=': return taskValue >= filterValue;
873
+ case '<': return taskValue < filterValue;
874
+ case '<=': return taskValue <= filterValue;
875
+ }
876
+ }
877
+ if (typeof taskValue === 'string' && (typeof filterValue === 'string' || typeof filterValue === 'number')) {
878
+ const taskTime = Date.parse(taskValue);
879
+ const filterTime = Date.parse(String(filterValue));
880
+ if (!Number.isNaN(taskTime) && !Number.isNaN(filterTime)) {
881
+ switch (operator) {
882
+ case '>': return taskTime > filterTime;
883
+ case '>=': return taskTime >= filterTime;
884
+ case '<': return taskTime < filterTime;
885
+ case '<=': return taskTime <= filterTime;
886
+ }
887
+ }
888
+ }
889
+ return false;
890
+ }
891
+ /**
892
+ * Apply a simple filter to an in-memory task list.
893
+ */
894
+ function applyClientSideFilter(tasks, filter) {
895
+ if (!filter) {
896
+ return tasks;
897
+ }
898
+ return tasks.filter((task) => {
899
+ const taskValue = getTaskPropertyValue(task, filter.field);
900
+ const filterValue = filter.value;
901
+ switch (filter.operator) {
902
+ case '=':
903
+ return taskValue === filterValue;
904
+ case '!=':
905
+ return taskValue !== filterValue;
906
+ case '>':
907
+ return compareScalarValues(taskValue, filterValue, '>');
908
+ case '>=':
909
+ return compareScalarValues(taskValue, filterValue, '>=');
910
+ case '<':
911
+ return compareScalarValues(taskValue, filterValue, '<');
912
+ case '<=':
913
+ return compareScalarValues(taskValue, filterValue, '<=');
914
+ case 'like':
915
+ return (typeof taskValue === 'string' &&
916
+ typeof filterValue === 'string' &&
917
+ taskValue.toLowerCase().includes(filterValue.toLowerCase()));
918
+ case 'in':
919
+ if (!Array.isArray(filterValue)) {
920
+ return false;
921
+ }
922
+ if (Array.isArray(taskValue)) {
923
+ return filterValue.some((value) => taskValue.includes(value));
924
+ }
925
+ return filterValue.includes(taskValue);
926
+ case 'not in':
927
+ if (!Array.isArray(filterValue)) {
928
+ return true;
929
+ }
930
+ if (Array.isArray(taskValue)) {
931
+ return !filterValue.some((value) => taskValue.includes(value));
932
+ }
933
+ return !filterValue.includes(taskValue);
934
+ default:
935
+ return true;
936
+ }
937
+ });
938
+ }
939
+ //# sourceMappingURL=filters.js.map