motionmcp 2.5.0 → 2.7.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/dist/handlers/CommentHandler.d.ts.map +1 -1
  2. package/dist/handlers/CommentHandler.js +4 -3
  3. package/dist/handlers/CommentHandler.js.map +1 -1
  4. package/dist/handlers/CustomFieldHandler.d.ts.map +1 -1
  5. package/dist/handlers/CustomFieldHandler.js +44 -21
  6. package/dist/handlers/CustomFieldHandler.js.map +1 -1
  7. package/dist/handlers/HandlerFactory.d.ts +0 -5
  8. package/dist/handlers/HandlerFactory.d.ts.map +1 -1
  9. package/dist/handlers/HandlerFactory.js +0 -15
  10. package/dist/handlers/HandlerFactory.js.map +1 -1
  11. package/dist/handlers/ProjectHandler.d.ts.map +1 -1
  12. package/dist/handlers/ProjectHandler.js +2 -1
  13. package/dist/handlers/ProjectHandler.js.map +1 -1
  14. package/dist/handlers/RecurringTaskHandler.d.ts.map +1 -1
  15. package/dist/handlers/RecurringTaskHandler.js +16 -10
  16. package/dist/handlers/RecurringTaskHandler.js.map +1 -1
  17. package/dist/handlers/ScheduleHandler.d.ts +1 -1
  18. package/dist/handlers/ScheduleHandler.d.ts.map +1 -1
  19. package/dist/handlers/ScheduleHandler.js +4 -26
  20. package/dist/handlers/ScheduleHandler.js.map +1 -1
  21. package/dist/handlers/SearchHandler.d.ts +1 -2
  22. package/dist/handlers/SearchHandler.d.ts.map +1 -1
  23. package/dist/handlers/SearchHandler.js +24 -70
  24. package/dist/handlers/SearchHandler.js.map +1 -1
  25. package/dist/handlers/TaskHandler.d.ts +11 -5
  26. package/dist/handlers/TaskHandler.d.ts.map +1 -1
  27. package/dist/handlers/TaskHandler.js +101 -63
  28. package/dist/handlers/TaskHandler.js.map +1 -1
  29. package/dist/handlers/UserHandler.js +6 -6
  30. package/dist/handlers/UserHandler.js.map +1 -1
  31. package/dist/handlers/WorkspaceHandler.d.ts +0 -1
  32. package/dist/handlers/WorkspaceHandler.d.ts.map +1 -1
  33. package/dist/handlers/WorkspaceHandler.js +0 -9
  34. package/dist/handlers/WorkspaceHandler.js.map +1 -1
  35. package/dist/handlers/base/BaseHandler.d.ts +4 -5
  36. package/dist/handlers/base/BaseHandler.d.ts.map +1 -1
  37. package/dist/handlers/base/BaseHandler.js +0 -12
  38. package/dist/handlers/base/BaseHandler.js.map +1 -1
  39. package/dist/handlers/base/HandlerInterface.d.ts +0 -5
  40. package/dist/handlers/base/HandlerInterface.d.ts.map +1 -1
  41. package/dist/handlers/index.d.ts +1 -1
  42. package/dist/handlers/index.d.ts.map +1 -1
  43. package/dist/mcp-server.js +3 -3
  44. package/dist/mcp-server.js.map +1 -1
  45. package/dist/schemas/motion.d.ts +12 -255
  46. package/dist/schemas/motion.d.ts.map +1 -1
  47. package/dist/schemas/motion.js +4 -17
  48. package/dist/schemas/motion.js.map +1 -1
  49. package/dist/services/api/ApiClient.d.ts +22 -0
  50. package/dist/services/api/ApiClient.d.ts.map +1 -0
  51. package/dist/services/api/ApiClient.js +198 -0
  52. package/dist/services/api/ApiClient.js.map +1 -0
  53. package/dist/services/api/CacheManager.d.ts +21 -0
  54. package/dist/services/api/CacheManager.d.ts.map +1 -0
  55. package/dist/services/api/CacheManager.js +25 -0
  56. package/dist/services/api/CacheManager.js.map +1 -0
  57. package/dist/services/api/comments.d.ts +8 -0
  58. package/dist/services/api/comments.d.ts.map +1 -0
  59. package/dist/services/api/comments.js +86 -0
  60. package/dist/services/api/comments.js.map +1 -0
  61. package/dist/services/api/customFields.d.ts +21 -0
  62. package/dist/services/api/customFields.d.ts.map +1 -0
  63. package/dist/services/api/customFields.js +277 -0
  64. package/dist/services/api/customFields.js.map +1 -0
  65. package/dist/services/api/index.d.ts +22 -0
  66. package/dist/services/api/index.d.ts.map +1 -0
  67. package/dist/services/api/index.js +64 -0
  68. package/dist/services/api/index.js.map +1 -0
  69. package/dist/services/api/projects.d.ts +18 -0
  70. package/dist/services/api/projects.d.ts.map +1 -0
  71. package/dist/services/api/projects.js +346 -0
  72. package/dist/services/api/projects.js.map +1 -0
  73. package/dist/services/api/recurringTasks.d.ts +15 -0
  74. package/dist/services/api/recurringTasks.d.ts.map +1 -0
  75. package/dist/services/api/recurringTasks.js +143 -0
  76. package/dist/services/api/recurringTasks.js.map +1 -0
  77. package/dist/services/api/schedules.d.ts +8 -0
  78. package/dist/services/api/schedules.d.ts.map +1 -0
  79. package/dist/services/api/schedules.js +70 -0
  80. package/dist/services/api/schedules.js.map +1 -0
  81. package/dist/services/api/search.d.ts +29 -0
  82. package/dist/services/api/search.d.ts.map +1 -0
  83. package/dist/services/api/search.js +415 -0
  84. package/dist/services/api/search.js.map +1 -0
  85. package/dist/services/api/statuses.d.ts +7 -0
  86. package/dist/services/api/statuses.d.ts.map +1 -0
  87. package/dist/services/api/statuses.js +67 -0
  88. package/dist/services/api/statuses.js.map +1 -0
  89. package/dist/services/api/tasks.d.ts +34 -0
  90. package/dist/services/api/tasks.d.ts.map +1 -0
  91. package/dist/services/api/tasks.js +474 -0
  92. package/dist/services/api/tasks.js.map +1 -0
  93. package/dist/services/api/types.d.ts +54 -0
  94. package/dist/services/api/types.d.ts.map +1 -0
  95. package/dist/services/api/types.js +9 -0
  96. package/dist/services/api/types.js.map +1 -0
  97. package/dist/services/api/users.d.ts +8 -0
  98. package/dist/services/api/users.d.ts.map +1 -0
  99. package/dist/services/api/users.js +93 -0
  100. package/dist/services/api/users.js.map +1 -0
  101. package/dist/services/api/workspaces.d.ts +7 -0
  102. package/dist/services/api/workspaces.d.ts.map +1 -0
  103. package/dist/services/api/workspaces.js +59 -0
  104. package/dist/services/api/workspaces.js.map +1 -0
  105. package/dist/services/motionApi.d.ts +41 -175
  106. package/dist/services/motionApi.d.ts.map +1 -1
  107. package/dist/services/motionApi.js +90 -2015
  108. package/dist/services/motionApi.js.map +1 -1
  109. package/dist/tools/ToolConfigurator.d.ts +1 -7
  110. package/dist/tools/ToolConfigurator.d.ts.map +1 -1
  111. package/dist/tools/ToolConfigurator.js +0 -31
  112. package/dist/tools/ToolConfigurator.js.map +1 -1
  113. package/dist/tools/ToolDefinitions.d.ts.map +1 -1
  114. package/dist/tools/ToolDefinitions.js +60 -82
  115. package/dist/tools/ToolDefinitions.js.map +1 -1
  116. package/dist/tools/ToolRegistry.d.ts +1 -22
  117. package/dist/tools/ToolRegistry.d.ts.map +1 -1
  118. package/dist/tools/ToolRegistry.js +0 -31
  119. package/dist/tools/ToolRegistry.js.map +1 -1
  120. package/dist/types/mcp-tool-args.d.ts +46 -61
  121. package/dist/types/mcp-tool-args.d.ts.map +1 -1
  122. package/dist/types/mcp-tool-args.js +2 -4
  123. package/dist/types/mcp-tool-args.js.map +1 -1
  124. package/dist/types/mcp.d.ts +5 -1
  125. package/dist/types/mcp.d.ts.map +1 -1
  126. package/dist/types/motion.d.ts +40 -20
  127. package/dist/types/motion.d.ts.map +1 -1
  128. package/dist/utils/cache.d.ts +0 -5
  129. package/dist/utils/cache.d.ts.map +1 -1
  130. package/dist/utils/cache.js +0 -8
  131. package/dist/utils/cache.js.map +1 -1
  132. package/dist/utils/constants.d.ts +4 -11
  133. package/dist/utils/constants.d.ts.map +1 -1
  134. package/dist/utils/constants.js +13 -53
  135. package/dist/utils/constants.js.map +1 -1
  136. package/dist/utils/errorHandling.d.ts +0 -12
  137. package/dist/utils/errorHandling.d.ts.map +1 -1
  138. package/dist/utils/errorHandling.js +2 -23
  139. package/dist/utils/errorHandling.js.map +1 -1
  140. package/dist/utils/errors.d.ts +89 -0
  141. package/dist/utils/errors.d.ts.map +1 -0
  142. package/dist/utils/errors.js +276 -0
  143. package/dist/utils/errors.js.map +1 -0
  144. package/dist/utils/frequencyTransform.d.ts +0 -5
  145. package/dist/utils/frequencyTransform.d.ts.map +1 -1
  146. package/dist/utils/frequencyTransform.js +1 -9
  147. package/dist/utils/frequencyTransform.js.map +1 -1
  148. package/dist/utils/index.d.ts +2 -2
  149. package/dist/utils/index.d.ts.map +1 -1
  150. package/dist/utils/index.js +6 -5
  151. package/dist/utils/index.js.map +1 -1
  152. package/dist/utils/pagination.d.ts +61 -0
  153. package/dist/utils/pagination.d.ts.map +1 -0
  154. package/dist/utils/pagination.js +168 -0
  155. package/dist/utils/pagination.js.map +1 -0
  156. package/dist/utils/paginationNew.d.ts +0 -5
  157. package/dist/utils/paginationNew.d.ts.map +1 -1
  158. package/dist/utils/paginationNew.js +5 -9
  159. package/dist/utils/paginationNew.js.map +1 -1
  160. package/dist/utils/parameterUtils.d.ts +15 -10
  161. package/dist/utils/parameterUtils.d.ts.map +1 -1
  162. package/dist/utils/parameterUtils.js +8 -22
  163. package/dist/utils/parameterUtils.js.map +1 -1
  164. package/dist/utils/responseFormatters.d.ts +3 -2
  165. package/dist/utils/responseFormatters.d.ts.map +1 -1
  166. package/dist/utils/responseFormatters.js +67 -24
  167. package/dist/utils/responseFormatters.js.map +1 -1
  168. package/dist/utils/responseWrapper.js +1 -1
  169. package/dist/utils/responseWrapper.js.map +1 -1
  170. package/dist/utils/sanitize.d.ts.map +1 -1
  171. package/dist/utils/sanitize.js +2 -5
  172. package/dist/utils/sanitize.js.map +1 -1
  173. package/dist/utils/serverInstructions.d.ts +2 -0
  174. package/dist/utils/serverInstructions.d.ts.map +1 -0
  175. package/dist/utils/serverInstructions.js +21 -0
  176. package/dist/utils/serverInstructions.js.map +1 -0
  177. package/dist/utils/userFacingErrors.d.ts +0 -8
  178. package/dist/utils/userFacingErrors.d.ts.map +1 -1
  179. package/dist/utils/userFacingErrors.js +0 -19
  180. package/dist/utils/userFacingErrors.js.map +1 -1
  181. package/dist/utils/workspaceResolver.d.ts +5 -1
  182. package/dist/utils/workspaceResolver.d.ts.map +1 -1
  183. package/dist/utils/workspaceResolver.js +46 -25
  184. package/dist/utils/workspaceResolver.js.map +1 -1
  185. package/package.json +6 -2
  186. package/dist/mcp-server-old.d.ts +0 -29
  187. package/dist/mcp-server-old.d.ts.map +0 -1
  188. package/dist/mcp-server-old.js +0 -1304
  189. package/dist/mcp-server-old.js.map +0 -1
  190. package/dist/utils/jsonSchemaToZod.d.ts +0 -33
  191. package/dist/utils/jsonSchemaToZod.d.ts.map +0 -1
  192. package/dist/utils/jsonSchemaToZod.js +0 -110
  193. package/dist/utils/jsonSchemaToZod.js.map +0 -1
  194. package/dist/worker.d.ts +0 -17
  195. package/dist/worker.d.ts.map +0 -1
  196. package/dist/worker.js +0 -61
  197. package/dist/worker.js.map +0 -1
@@ -3,10 +3,8 @@
3
3
  * Shared constants and error codes for Motion MCP Server utilities
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VALID_PRIORITIES = exports.NULL_UNDEFINED_POLICY = exports.LOG_LEVELS = exports.LIMITS = exports.CACHE_TTL = exports.API_CONFIG = exports.RETRY_CONFIG = exports.DEFAULTS = exports.MCP_RESPONSE_TYPES = exports.WORKSPACE_TYPES = exports.ERROR_CODES = void 0;
7
- exports.convertUndefinedToNull = convertUndefinedToNull;
6
+ exports.VALID_PRIORITIES = exports.LOG_LEVELS = exports.LIMITS = exports.CACHE_TTL = exports.API_CONFIG = exports.RETRY_CONFIG = exports.DEFAULTS = exports.MCP_RESPONSE_TYPES = exports.WORKSPACE_TYPES = exports.ERROR_CODES = void 0;
8
7
  exports.createMinimalPayload = createMinimalPayload;
9
- exports.convertNullToUndefined = convertNullToUndefined;
10
8
  exports.isValidPriority = isValidPriority;
11
9
  exports.parseFilterDate = parseFilterDate;
12
10
  // Error codes for different types of failures
@@ -15,11 +13,16 @@ exports.ERROR_CODES = {
15
13
  WORKSPACE_NOT_FOUND: 'WORKSPACE_NOT_FOUND',
16
14
  WORKSPACE_ACCESS_DENIED: 'WORKSPACE_ACCESS_DENIED',
17
15
  NO_DEFAULT_WORKSPACE: 'NO_DEFAULT_WORKSPACE',
16
+ // Auth/access errors
17
+ AUTH_FAILED: 'AUTH_FAILED', // 401 – invalid or missing credentials
18
+ ACCESS_DENIED: 'ACCESS_DENIED', // 403 – valid credentials, insufficient permissions
18
19
  // Validation errors
19
20
  INVALID_PARAMETERS: 'INVALID_PARAMETERS',
20
21
  MISSING_REQUIRED_PARAM: 'MISSING_REQUIRED_PARAM',
21
22
  INVALID_PRIORITY: 'INVALID_PRIORITY',
22
23
  INVALID_DATE_FORMAT: 'INVALID_DATE_FORMAT',
24
+ // Resource errors
25
+ RESOURCE_NOT_FOUND: 'RESOURCE_NOT_FOUND',
23
26
  // API related errors
24
27
  MOTION_API_ERROR: 'MOTION_API_ERROR',
25
28
  NETWORK_ERROR: 'NETWORK_ERROR',
@@ -43,15 +46,6 @@ exports.MCP_RESPONSE_TYPES = {
43
46
  exports.DEFAULTS = {
44
47
  WORKSPACE_FALLBACK_TO_DEFAULT: true,
45
48
  WORKSPACE_VALIDATE_ACCESS: false,
46
- WORKSPACE_USE_CACHE: true,
47
- // Search defaults
48
- SEARCH_LIMIT: 40,
49
- SEARCH_SCOPE: 'both',
50
- // Suggestion defaults
51
- MAX_SUGGESTIONS: 5,
52
- // Workload analysis defaults
53
- TIMEFRAME: 'this_week',
54
- INCLUDE_PROJECTS: true
55
49
  };
56
50
  // Retry configuration
57
51
  exports.RETRY_CONFIG = {
@@ -74,7 +68,8 @@ exports.CACHE_TTL = {
74
68
  COMMENTS: 60, // 1 minute
75
69
  CUSTOM_FIELDS: 600, // 10 minutes
76
70
  RECURRING_TASKS: 300, // 5 minutes (same as projects)
77
- SCHEDULES: 300 // 5 minutes (schedule data changes frequently)
71
+ SCHEDULES: 300, // 5 minutes (schedule data changes frequently)
72
+ STATUSES: 600 // 10 minutes (same as workspaces)
78
73
  };
79
74
  // Content limits and validation
80
75
  exports.LIMITS = {
@@ -96,29 +91,6 @@ exports.LOG_LEVELS = {
96
91
  WARN: 'warn',
97
92
  ERROR: 'error'
98
93
  };
99
- // Null vs Undefined Policy
100
- exports.NULL_UNDEFINED_POLICY = {
101
- // Use undefined for:
102
- // - Optional parameters that weren't provided
103
- // - Missing object properties
104
- // - Function returns when item not found
105
- // - Uninitialized values
106
- // Use null for:
107
- // - Explicit absence of value from API
108
- // - Database null values
109
- // - Cleared/reset state (e.g., cache reset)
110
- // - Values that need to be explicitly sent as null to external APIs
111
- };
112
- // Helper to convert undefined to null for API compatibility
113
- function convertUndefinedToNull(obj) {
114
- const result = { ...obj };
115
- for (const key in result) {
116
- if (result[key] === undefined) {
117
- result[key] = null;
118
- }
119
- }
120
- return result;
121
- }
122
94
  /**
123
95
  * Creates a minimal payload by removing null, undefined, and empty values
124
96
  * This prevents API validation errors from unexpected fields
@@ -129,32 +101,20 @@ function createMinimalPayload(obj) {
129
101
  const result = {};
130
102
  for (const key in obj) {
131
103
  const value = obj[key];
132
- // Skip null, undefined, empty strings, and empty arrays
133
- if (value === null || value === undefined || value === '') {
134
- continue;
135
- }
136
- // Skip empty arrays
137
- if (Array.isArray(value) && value.length === 0) {
104
+ // Skip undefined and empty strings only.
105
+ // Preserve null (API may distinguish absent vs null, e.g., autoScheduled: null).
106
+ // Preserve empty arrays (e.g., labels: [] to clear all labels).
107
+ if (value === undefined || value === '') {
138
108
  continue;
139
109
  }
140
110
  // Skip empty objects (but preserve objects with properties)
141
- if (typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0) {
111
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && Object.keys(value).length === 0) {
142
112
  continue;
143
113
  }
144
114
  result[key] = value;
145
115
  }
146
116
  return result;
147
117
  }
148
- // Helper to convert null to undefined for internal consistency
149
- function convertNullToUndefined(obj) {
150
- const result = { ...obj };
151
- for (const key in result) {
152
- if (result[key] === null) {
153
- delete result[key]; // This makes it undefined
154
- }
155
- }
156
- return result;
157
- }
158
118
  // Valid priority levels for Motion tasks
159
119
  exports.VALID_PRIORITIES = ['ASAP', 'HIGH', 'MEDIUM', 'LOW'];
160
120
  // Helper to validate priority values
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAiIH,wDAQC;AAQD,oDAyB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AE,CAAC;IACzB,MAAM,eAAe,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAEvD,QAAQ,eAAe,EAAE,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QAC5C,KAAK,UAAU;YACb,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YACjC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;YACtC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QAC/C,KAAK,WAAW;YACd,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAClC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;YACvC,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;IAClD,CAAC;IAED,6BAA6B;IAC7B,MAAM,WAAW,GAAG,qBAAqB,CAAC;IAC1C,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YACjC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -9,14 +9,6 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
9
9
  interface ErrorContext {
10
10
  [key: string]: any;
11
11
  }
12
- /**
13
- * Base error class for Motion API related errors
14
- */
15
- export declare class MotionApiError extends Error {
16
- readonly code: ErrorCode;
17
- readonly context: ErrorContext;
18
- constructor(message: string, code?: ErrorCode, context?: ErrorContext);
19
- }
20
12
  /**
21
13
  * Error class for parameter validation failures
22
14
  */
@@ -57,9 +49,5 @@ export declare function formatMcpError(error: Error | unknown, additionalContext
57
49
  * Format a success response for MCP protocol
58
50
  */
59
51
  export declare function formatMcpSuccess(text: string): CallToolResult;
60
- /**
61
- * Create a standardized error response with context
62
- */
63
- export declare function createErrorResponse(message: string, code?: ErrorCode, context?: ErrorContext): CallToolResult;
64
52
  export {};
65
53
  //# sourceMappingURL=errorHandling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmC,SAAS,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,UAAU,YAAY;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAAwC,EAAE,OAAO,GAAE,YAAiB;CAMxG;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW,EAAE,OAAO,GAAE,YAAiB;CAOzF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,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E,OAAO,GAAE,YAAiB;CAOzF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAA2C,EAAE,OAAO,GAAE,YAAiB;CAM3G;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAKhG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAoB5G;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,EAAE,iBAAiB,GAAE,YAAiB,GAAG,cAAc,CAsB3G;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAS7D"}
@@ -6,25 +6,12 @@
6
6
  * formatting to ensure consistent error handling across all handlers.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.WorkspaceError = exports.ValidationError = exports.MotionApiError = void 0;
9
+ exports.WorkspaceError = exports.ValidationError = void 0;
10
10
  exports.isCodedError = isCodedError;
11
11
  exports.extractErrorInfo = extractErrorInfo;
12
12
  exports.formatMcpError = formatMcpError;
13
13
  exports.formatMcpSuccess = formatMcpSuccess;
14
- exports.createErrorResponse = createErrorResponse;
15
14
  const constants_1 = require("./constants");
16
- /**
17
- * Base error class for Motion API related errors
18
- */
19
- class MotionApiError extends Error {
20
- constructor(message, code = constants_1.ERROR_CODES.MOTION_API_ERROR, context = {}) {
21
- super(message);
22
- this.name = 'MotionApiError';
23
- this.code = code;
24
- this.context = context;
25
- }
26
- }
27
- exports.MotionApiError = MotionApiError;
28
15
  /**
29
16
  * Error class for parameter validation failures
30
17
  */
@@ -54,8 +41,7 @@ exports.WorkspaceError = WorkspaceError;
54
41
  * Type guard to check if an error has an error code
55
42
  */
56
43
  function isCodedError(error) {
57
- return (error instanceof MotionApiError ||
58
- error instanceof ValidationError ||
44
+ return (error instanceof ValidationError ||
59
45
  error instanceof WorkspaceError);
60
46
  }
61
47
  /**
@@ -118,11 +104,4 @@ function formatMcpSuccess(text) {
118
104
  ]
119
105
  };
120
106
  }
121
- /**
122
- * Create a standardized error response with context
123
- */
124
- function createErrorResponse(message, code = constants_1.ERROR_CODES.INTERNAL_ERROR, context = {}) {
125
- const error = new MotionApiError(message, code, context);
126
- return formatMcpError(error, context);
127
- }
128
107
  //# sourceMappingURL=errorHandling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../src/utils/errorHandling.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA2DH,oCAMC;AAKD,4CAoBC;AAKD,wCAsBC;AAKD,4CASC;AAKD,kDAOC;AA7ID,2CAAyE;AAOzE;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IAIvC,YAAY,OAAe,EAAE,OAAkB,uBAAW,CAAC,gBAAgB,EAAE,UAAwB,EAAE;QACrG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,wCAUC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAKxC,YAAY,OAAe,EAAE,YAA2B,IAAI,EAAE,UAAwB,EAAE;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC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AAW,CAAC,cAAc;QAChC,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAsB,EAAE,oBAAkC,EAAE;IACzF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,OAAO,IAAI,2BAA2B,CAAC;IAC5D,MAAM,YAAY,GAAiB,EAAE,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAExE,2CAA2C;IAC3C,IAAI,KAAK,YAAY,eAAe,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACxD,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3C,CAAC;IAED,sBAAsB;IACtB,MAAM,SAAS,GAAG,UAAU,IAAI,MAAM,YAAY,EAAE,CAAC;IAErD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,8BAAkB,CAAC,IAAI;gBAC7B,IAAI,EAAE,SAAS;aAChB;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,8BAAkB,CAAC,IAAI;gBAC7B,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Error Utilities - Custom error classes, type guards, and MCP response formatters
3
+ *
4
+ * Consolidates the full error pipeline: error classes (ValidationError, WorkspaceError,
5
+ * UserFacingError), type guards, MCP response formatting, and user-facing error factories.
6
+ */
7
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
8
+ import { ErrorCode, LogLevel } from './constants';
9
+ interface ErrorContext {
10
+ [key: string]: any;
11
+ }
12
+ /**
13
+ * Error class for parameter validation failures
14
+ */
15
+ export declare class ValidationError extends Error {
16
+ readonly code: ErrorCode;
17
+ readonly parameter: string | null;
18
+ readonly context: ErrorContext;
19
+ constructor(message: string, parameter?: string | null, context?: ErrorContext);
20
+ }
21
+ /**
22
+ * Error class for workspace-specific issues
23
+ */
24
+ export declare class WorkspaceError extends Error {
25
+ readonly code: ErrorCode;
26
+ readonly context: ErrorContext;
27
+ constructor(message: string, code?: ErrorCode, context?: ErrorContext);
28
+ }
29
+ /**
30
+ * Error context for categorizing API errors
31
+ */
32
+ interface ApiErrorContext {
33
+ action: string;
34
+ resourceType?: 'task' | 'project' | 'workspace' | 'user' | 'comment' | 'custom field' | 'recurring task' | 'schedule' | 'status';
35
+ resourceId?: string;
36
+ resourceName?: string;
37
+ }
38
+ /**
39
+ * Error class that contains both user-friendly and technical messages
40
+ */
41
+ export declare class UserFacingError extends Error {
42
+ readonly code: ErrorCode;
43
+ readonly userMessage: string;
44
+ readonly technicalMessage: string;
45
+ readonly originalError?: Error;
46
+ readonly statusCode?: number;
47
+ readonly context: Record<string, unknown>;
48
+ constructor(userMessage: string, technicalMessage: string, originalError?: Error, context?: Record<string, unknown>,
49
+ /**
50
+ * Optional HTTP status code. When provided, overrides any status code that
51
+ * would otherwise be extracted from originalError. Use only when the caller
52
+ * has already extracted and validated the status (e.g. createUserFacingError).
53
+ */
54
+ statusCode?: number);
55
+ /**
56
+ * Log this error with full details
57
+ */
58
+ log(level?: LogLevel): void;
59
+ }
60
+ /**
61
+ * Type guard to check if an error has an error code
62
+ */
63
+ export declare function isCodedError(error: unknown): error is ValidationError | WorkspaceError | UserFacingError;
64
+ /**
65
+ * Extract error information from any error type
66
+ */
67
+ export declare function extractErrorInfo(error: unknown): {
68
+ message: string;
69
+ code: ErrorCode;
70
+ context: ErrorContext;
71
+ };
72
+ /**
73
+ * Format an error for MCP protocol response
74
+ */
75
+ export declare function formatMcpError(error: Error | unknown): CallToolResult;
76
+ /**
77
+ * Format a success response for MCP protocol
78
+ */
79
+ export declare function formatMcpSuccess(text: string): CallToolResult;
80
+ /**
81
+ * Creates a user-facing error with both user-friendly and technical messages
82
+ */
83
+ export declare function createUserFacingError(error: unknown, context: ApiErrorContext): UserFacingError;
84
+ /**
85
+ * Helper to create error context
86
+ */
87
+ export declare function createErrorContext(action: string, resourceType?: ApiErrorContext['resourceType'], resourceId?: string, resourceName?: string): ApiErrorContext;
88
+ export {};
89
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAmC,SAAS,EAAc,QAAQ,EAAE,MAAM,aAAa,CAAC;AAO/F,UAAU,YAAY;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAID;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW,EAAE,OAAO,GAAE,YAAiB;CAOzF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAA2C,EAAE,OAAO,GAAE,YAAiB;CAM3G;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,gBAAgB,GAAG,UAAU,GAAG,QAAQ,CAAC;IACjI,UAAU,CAAC,EAAE,MAAM,CAA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,CAAC,EAAE,eAAe,CAAC,cAAc,CAAC,EAC9C,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe,CAOjB"}
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+ /**
3
+ * Error Utilities - Custom error classes, type guards, and MCP response formatters
4
+ *
5
+ * Consolidates the full error pipeline: error classes (ValidationError, WorkspaceError,
6
+ * UserFacingError), type guards, MCP response formatting, and user-facing error factories.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.UserFacingError = exports.WorkspaceError = exports.ValidationError = void 0;
10
+ exports.isCodedError = isCodedError;
11
+ exports.extractErrorInfo = extractErrorInfo;
12
+ exports.formatMcpError = formatMcpError;
13
+ exports.formatMcpSuccess = formatMcpSuccess;
14
+ exports.createUserFacingError = createUserFacingError;
15
+ exports.createErrorContext = createErrorContext;
16
+ const axios_1 = require("axios");
17
+ const constants_1 = require("./constants");
18
+ const logger_1 = require("./logger");
19
+ // ─── Error Classes ──────────────────────────────────────────────────────────
20
+ /**
21
+ * Error class for parameter validation failures
22
+ */
23
+ class ValidationError extends Error {
24
+ constructor(message, parameter = null, context = {}) {
25
+ super(message);
26
+ this.name = 'ValidationError';
27
+ this.code = constants_1.ERROR_CODES.INVALID_PARAMETERS;
28
+ this.parameter = parameter;
29
+ this.context = context;
30
+ }
31
+ }
32
+ exports.ValidationError = ValidationError;
33
+ /**
34
+ * Error class for workspace-specific issues
35
+ */
36
+ class WorkspaceError extends Error {
37
+ constructor(message, code = constants_1.ERROR_CODES.WORKSPACE_NOT_FOUND, context = {}) {
38
+ super(message);
39
+ this.name = 'WorkspaceError';
40
+ this.code = code;
41
+ this.context = context;
42
+ }
43
+ }
44
+ exports.WorkspaceError = WorkspaceError;
45
+ /**
46
+ * Maps HTTP status codes to ErrorCode values
47
+ */
48
+ function httpStatusToErrorCode(statusCode) {
49
+ if (!statusCode)
50
+ return constants_1.ERROR_CODES.INTERNAL_ERROR;
51
+ if (statusCode === 401)
52
+ return constants_1.ERROR_CODES.AUTH_FAILED;
53
+ if (statusCode === 403)
54
+ return constants_1.ERROR_CODES.ACCESS_DENIED;
55
+ if (statusCode === 404)
56
+ return constants_1.ERROR_CODES.RESOURCE_NOT_FOUND;
57
+ if (statusCode === 400 || statusCode === 422)
58
+ return constants_1.ERROR_CODES.INVALID_PARAMETERS;
59
+ if (statusCode === 429)
60
+ return constants_1.ERROR_CODES.RATE_LIMIT_EXCEEDED;
61
+ if (statusCode >= 500)
62
+ return constants_1.ERROR_CODES.MOTION_API_ERROR;
63
+ return constants_1.ERROR_CODES.INTERNAL_ERROR;
64
+ }
65
+ /**
66
+ * Error class that contains both user-friendly and technical messages
67
+ */
68
+ class UserFacingError extends Error {
69
+ constructor(userMessage, technicalMessage, originalError, context,
70
+ /**
71
+ * Optional HTTP status code. When provided, overrides any status code that
72
+ * would otherwise be extracted from originalError. Use only when the caller
73
+ * has already extracted and validated the status (e.g. createUserFacingError).
74
+ */
75
+ statusCode) {
76
+ super(userMessage);
77
+ this.name = 'UserFacingError';
78
+ this.userMessage = userMessage;
79
+ this.technicalMessage = technicalMessage;
80
+ this.originalError = originalError;
81
+ this.context = context ?? {};
82
+ // Use explicit statusCode if provided, otherwise extract from axios errors
83
+ if (statusCode !== undefined) {
84
+ this.statusCode = statusCode;
85
+ }
86
+ else if (originalError && (0, axios_1.isAxiosError)(originalError)) {
87
+ this.statusCode = originalError.response?.status;
88
+ }
89
+ this.code = httpStatusToErrorCode(this.statusCode);
90
+ // Maintain proper stack trace
91
+ if (Error.captureStackTrace) {
92
+ Error.captureStackTrace(this, UserFacingError);
93
+ }
94
+ }
95
+ /**
96
+ * Log this error with full details
97
+ */
98
+ log(level = constants_1.LOG_LEVELS.ERROR) {
99
+ (0, logger_1.mcpLog)(level, this.userMessage, {
100
+ technicalMessage: this.technicalMessage,
101
+ statusCode: this.statusCode,
102
+ originalError: this.originalError?.message,
103
+ context: this.context
104
+ });
105
+ }
106
+ }
107
+ exports.UserFacingError = UserFacingError;
108
+ // ─── Type Guards and Extractors ─────────────────────────────────────────────
109
+ /**
110
+ * Type guard to check if an error has an error code
111
+ */
112
+ function isCodedError(error) {
113
+ return (error instanceof ValidationError ||
114
+ error instanceof WorkspaceError ||
115
+ error instanceof UserFacingError);
116
+ }
117
+ /**
118
+ * Extract error information from any error type
119
+ */
120
+ function extractErrorInfo(error) {
121
+ if (error instanceof Error) {
122
+ if (isCodedError(error)) {
123
+ return {
124
+ message: error.message,
125
+ code: error.code,
126
+ context: error.context
127
+ };
128
+ }
129
+ return {
130
+ message: error.message,
131
+ code: constants_1.ERROR_CODES.INTERNAL_ERROR,
132
+ context: {}
133
+ };
134
+ }
135
+ return {
136
+ message: String(error),
137
+ code: constants_1.ERROR_CODES.INTERNAL_ERROR,
138
+ context: {}
139
+ };
140
+ }
141
+ // ─── MCP Response Formatters ────────────────────────────────────────────────
142
+ /**
143
+ * Format an error for MCP protocol response
144
+ */
145
+ function formatMcpError(error) {
146
+ // For UserFacingError, message is the user-friendly text (not technicalMessage)
147
+ const { message, code } = extractErrorInfo(error);
148
+ const errorMessage = message || 'An unknown error occurred';
149
+ const errorText = `Error [${code}]: ${errorMessage}`;
150
+ return {
151
+ content: [
152
+ {
153
+ type: constants_1.MCP_RESPONSE_TYPES.TEXT,
154
+ text: errorText
155
+ }
156
+ ],
157
+ isError: true
158
+ };
159
+ }
160
+ /**
161
+ * Format a success response for MCP protocol
162
+ */
163
+ function formatMcpSuccess(text) {
164
+ return {
165
+ content: [
166
+ {
167
+ type: constants_1.MCP_RESPONSE_TYPES.TEXT,
168
+ text
169
+ }
170
+ ]
171
+ };
172
+ }
173
+ // ─── User-Facing Error Factories ────────────────────────────────────────────
174
+ /**
175
+ * Maps HTTP status codes to user-friendly messages
176
+ */
177
+ const STATUS_CODE_MESSAGES = {
178
+ 400: 'The request was invalid. Please check your input and try again.',
179
+ 401: 'Authentication failed. Please check your API key configuration.',
180
+ 403: 'You don\'t have permission to perform this action.',
181
+ 404: 'The requested resource was not found.',
182
+ 409: 'This action conflicts with the current state. The resource may have been modified.',
183
+ 422: 'The data provided cannot be processed. Please check the format and try again.',
184
+ 429: 'Too many requests. Please wait a moment and try again.',
185
+ 500: 'Motion server encountered an error. Please try again later.',
186
+ 502: 'Unable to connect to Motion servers. Please check your internet connection.',
187
+ 503: 'Motion service is temporarily unavailable. Please try again in a few moments.',
188
+ 504: 'Request timed out. Please try again.'
189
+ };
190
+ /**
191
+ * Maps action types to user-friendly action descriptions
192
+ */
193
+ const ACTION_DESCRIPTIONS = {
194
+ 'fetch': 'load',
195
+ 'create': 'create',
196
+ 'update': 'update',
197
+ 'delete': 'delete',
198
+ 'move': 'move',
199
+ 'unassign': 'unassign',
200
+ 'search': 'search for',
201
+ 'resolve': 'find',
202
+ 'list': 'retrieve'
203
+ };
204
+ /**
205
+ * Builds a user-friendly message based on context and status
206
+ */
207
+ function buildUserMessage(context, statusCode, apiMessage) {
208
+ const action = ACTION_DESCRIPTIONS[context.action] || context.action;
209
+ const resource = context.resourceType || 'resource';
210
+ const resourceInfo = context.resourceName
211
+ ? ` "${context.resourceName}"`
212
+ : context.resourceId
213
+ ? ` (ID: ${context.resourceId})`
214
+ : '';
215
+ // Check for specific status code messages
216
+ if (statusCode && STATUS_CODE_MESSAGES[statusCode]) {
217
+ // For auth errors, lead with permission context
218
+ if (statusCode === 401 || statusCode === 403) {
219
+ return `${STATUS_CODE_MESSAGES[statusCode]} Unable to ${action} ${resource}${resourceInfo}.`;
220
+ }
221
+ return `Unable to ${action} ${resource}${resourceInfo}. ${STATUS_CODE_MESSAGES[statusCode]}`;
222
+ }
223
+ // Check for common error patterns in API messages
224
+ if (apiMessage) {
225
+ // Network/connection errors
226
+ if (apiMessage.toLowerCase().includes('network') ||
227
+ apiMessage.toLowerCase().includes('connection')) {
228
+ return `Unable to ${action} ${resource}${resourceInfo}. Please check your internet connection and try again.`;
229
+ }
230
+ // Validation errors
231
+ if (apiMessage.toLowerCase().includes('validation') ||
232
+ apiMessage.toLowerCase().includes('invalid')) {
233
+ return `Unable to ${action} ${resource}${resourceInfo}. ${apiMessage}`;
234
+ }
235
+ }
236
+ // Generic message
237
+ return `Unable to ${action} ${resource}${resourceInfo}. Please try again or contact support if the problem persists.`;
238
+ }
239
+ /**
240
+ * Creates a user-facing error with both user-friendly and technical messages
241
+ */
242
+ function createUserFacingError(error, context) {
243
+ // Get technical message
244
+ const technicalMessage = error instanceof Error ? error.message : String(error);
245
+ // Extract status code
246
+ let statusCode;
247
+ let apiMessage;
248
+ if ((0, axios_1.isAxiosError)(error)) {
249
+ statusCode = error.response?.status;
250
+ apiMessage = error.response?.data?.message;
251
+ }
252
+ // Build user-friendly message
253
+ const userMessage = buildUserMessage(context, statusCode, apiMessage);
254
+ // Create the error
255
+ const userError = new UserFacingError(userMessage, technicalMessage, error instanceof Error ? error : undefined, {
256
+ action: context.action,
257
+ resourceType: context.resourceType,
258
+ resourceId: context.resourceId,
259
+ resourceName: context.resourceName
260
+ }, statusCode);
261
+ // Log the error
262
+ userError.log();
263
+ return userError;
264
+ }
265
+ /**
266
+ * Helper to create error context
267
+ */
268
+ function createErrorContext(action, resourceType, resourceId, resourceName) {
269
+ return {
270
+ action,
271
+ resourceType,
272
+ resourceId,
273
+ resourceName
274
+ };
275
+ }
276
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAuIH,oCAMC;AAKD,4CAoBC;AAOD,wCAeC;AAKD,4CASC;AAmFD,sDAqCC;AAKD,gDAYC;AAjVD,iCAAqC;AAErC,2CAA+F;AAC/F,qCAAkC;AAUlC,+EAA+E;AAE/E;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAKxC,YAAY,OAAe,EAAE,YAA2B,IAAI,EAAE,UAAwB,EAAE;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CA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AC9B,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEtE,mBAAmB;IACnB,MAAM,SAAS,GAAG,IAAI,eAAe,CACnC,WAAW,EACX,gBAAgB,EAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAC1C;QACE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,EACD,UAAU,CACX,CAAC;IAEF,gBAAgB;IAChB,SAAS,CAAC,GAAG,EAAE,CAAC;IAEhB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAChC,MAAc,EACd,YAA8C,EAC9C,UAAmB,EACnB,YAAqB;IAErB,OAAO;QACL,MAAM;QACN,YAAY;QACZ,UAAU;QACV,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -33,9 +33,4 @@ export interface FrequencyValidationResult {
33
33
  * @returns Validation result with detailed reason if invalid
34
34
  */
35
35
  export declare function validateFrequencyObject(frequency: FrequencyObject): FrequencyValidationResult;
36
- /**
37
- * Legacy boolean validation function for backward compatibility
38
- * @deprecated Use validateFrequencyObject instead for detailed error information
39
- */
40
- export declare function isValidFrequencyObject(frequency: FrequencyObject): boolean;
41
36
  //# sourceMappingURL=frequencyTransform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frequencyTransform.d.ts","sourceRoot":"","sources":["../../src/utils/frequencyTransform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgBlD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAyChF;AAqLD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,eAAe,GAAG,yBAAyB,CAiG7F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAE1E"}
1
+ {"version":3,"file":"frequencyTransform.d.ts","sourceRoot":"","sources":["../../src/utils/frequencyTransform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgBlD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAyChF;AAqLD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,eAAe,GAAG,yBAAyB,CAiG7F"}