@forumviriumhelsinki/podio-mcp 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +491 -0
- package/build/__tests__/integration/setup.integration.d.ts +104 -0
- package/build/__tests__/integration/setup.integration.d.ts.map +1 -0
- package/build/__tests__/integration/setup.integration.js +233 -0
- package/build/__tests__/integration/setup.integration.js.map +1 -0
- package/build/__tests__/mock-data/items-mock-data.d.ts +168 -0
- package/build/__tests__/mock-data/items-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/items-mock-data.js +370 -0
- package/build/__tests__/mock-data/items-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/notification-mock-data.d.ts +55 -0
- package/build/__tests__/mock-data/notification-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/notification-mock-data.js +190 -0
- package/build/__tests__/mock-data/notification-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/project-epic-mock-data.d.ts +45 -0
- package/build/__tests__/mock-data/project-epic-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/project-epic-mock-data.js +85 -0
- package/build/__tests__/mock-data/project-epic-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/tasks-mock-data.d.ts +27 -0
- package/build/__tests__/mock-data/tasks-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/tasks-mock-data.js +104 -0
- package/build/__tests__/mock-data/tasks-mock-data.js.map +1 -0
- package/build/__tests__/mock-data/utility-mock-data.d.ts +19 -0
- package/build/__tests__/mock-data/utility-mock-data.d.ts.map +1 -0
- package/build/__tests__/mock-data/utility-mock-data.js +165 -0
- package/build/__tests__/mock-data/utility-mock-data.js.map +1 -0
- package/build/__tests__/setup.d.ts +8 -0
- package/build/__tests__/setup.d.ts.map +1 -0
- package/build/__tests__/setup.js +31 -0
- package/build/__tests__/setup.js.map +1 -0
- package/build/__tests__/utils/test-helpers.d.ts +110 -0
- package/build/__tests__/utils/test-helpers.d.ts.map +1 -0
- package/build/__tests__/utils/test-helpers.js +222 -0
- package/build/__tests__/utils/test-helpers.js.map +1 -0
- package/build/api/podio-api-client.d.ts +364 -0
- package/build/api/podio-api-client.d.ts.map +1 -0
- package/build/api/podio-api-client.js +696 -0
- package/build/api/podio-api-client.js.map +1 -0
- package/build/cache/app-cache.d.ts +77 -0
- package/build/cache/app-cache.d.ts.map +1 -0
- package/build/cache/app-cache.js +230 -0
- package/build/cache/app-cache.js.map +1 -0
- package/build/cache/base-cache-manager.d.ts +149 -0
- package/build/cache/base-cache-manager.d.ts.map +1 -0
- package/build/cache/base-cache-manager.js +312 -0
- package/build/cache/base-cache-manager.js.map +1 -0
- package/build/cache/cache-manager.d.ts +230 -0
- package/build/cache/cache-manager.d.ts.map +1 -0
- package/build/cache/cache-manager.js +362 -0
- package/build/cache/cache-manager.js.map +1 -0
- package/build/cache/cache-test.d.ts +9 -0
- package/build/cache/cache-test.d.ts.map +1 -0
- package/build/cache/cache-test.js +169 -0
- package/build/cache/cache-test.js.map +1 -0
- package/build/cache/index.d.ts +18 -0
- package/build/cache/index.d.ts.map +1 -0
- package/build/cache/index.js +20 -0
- package/build/cache/index.js.map +1 -0
- package/build/cache/migration-helper.d.ts +44 -0
- package/build/cache/migration-helper.d.ts.map +1 -0
- package/build/cache/migration-helper.js +235 -0
- package/build/cache/migration-helper.js.map +1 -0
- package/build/cache/project-epic-cache.d.ts +108 -0
- package/build/cache/project-epic-cache.d.ts.map +1 -0
- package/build/cache/project-epic-cache.js +278 -0
- package/build/cache/project-epic-cache.js.map +1 -0
- package/build/cache/space-members-cache.d.ts +99 -0
- package/build/cache/space-members-cache.d.ts.map +1 -0
- package/build/cache/space-members-cache.js +305 -0
- package/build/cache/space-members-cache.js.map +1 -0
- package/build/cache/storage-adapters.d.ts +100 -0
- package/build/cache/storage-adapters.d.ts.map +1 -0
- package/build/cache/storage-adapters.js +297 -0
- package/build/cache/storage-adapters.js.map +1 -0
- package/build/errors/api-errors.d.ts +52 -0
- package/build/errors/api-errors.d.ts.map +1 -0
- package/build/errors/api-errors.js +86 -0
- package/build/errors/api-errors.js.map +1 -0
- package/build/errors/auth-errors.d.ts +67 -0
- package/build/errors/auth-errors.d.ts.map +1 -0
- package/build/errors/auth-errors.js +114 -0
- package/build/errors/auth-errors.js.map +1 -0
- package/build/errors/base.d.ts +102 -0
- package/build/errors/base.d.ts.map +1 -0
- package/build/errors/base.js +131 -0
- package/build/errors/base.js.map +1 -0
- package/build/errors/cache-errors.d.ts +53 -0
- package/build/errors/cache-errors.d.ts.map +1 -0
- package/build/errors/cache-errors.js +83 -0
- package/build/errors/cache-errors.js.map +1 -0
- package/build/errors/config-errors.d.ts +58 -0
- package/build/errors/config-errors.d.ts.map +1 -0
- package/build/errors/config-errors.js +96 -0
- package/build/errors/config-errors.js.map +1 -0
- package/build/errors/index.d.ts +101 -0
- package/build/errors/index.d.ts.map +1 -0
- package/build/errors/index.js +135 -0
- package/build/errors/index.js.map +1 -0
- package/build/errors/structure-errors.d.ts +89 -0
- package/build/errors/structure-errors.d.ts.map +1 -0
- package/build/errors/structure-errors.js +182 -0
- package/build/errors/structure-errors.js.map +1 -0
- package/build/errors/validation-errors.d.ts +81 -0
- package/build/errors/validation-errors.d.ts.map +1 -0
- package/build/errors/validation-errors.js +169 -0
- package/build/errors/validation-errors.js.map +1 -0
- package/build/fields/field-mapper.d.ts +245 -0
- package/build/fields/field-mapper.d.ts.map +1 -0
- package/build/fields/field-mapper.js +404 -0
- package/build/fields/field-mapper.js.map +1 -0
- package/build/index.d.ts +550 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1527 -0
- package/build/index.js.map +1 -0
- package/build/oauth-helper.d.ts +189 -0
- package/build/oauth-helper.d.ts.map +1 -0
- package/build/oauth-helper.js +422 -0
- package/build/oauth-helper.js.map +1 -0
- package/build/services/app-structure-service.d.ts +49 -0
- package/build/services/app-structure-service.d.ts.map +1 -0
- package/build/services/app-structure-service.js +122 -0
- package/build/services/app-structure-service.js.map +1 -0
- package/build/services/code-execution-service.d.ts +88 -0
- package/build/services/code-execution-service.d.ts.map +1 -0
- package/build/services/code-execution-service.js +342 -0
- package/build/services/code-execution-service.js.map +1 -0
- package/build/services/comment-service.d.ts +66 -0
- package/build/services/comment-service.d.ts.map +1 -0
- package/build/services/comment-service.js +139 -0
- package/build/services/comment-service.js.map +1 -0
- package/build/services/index.d.ts +16 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +15 -0
- package/build/services/index.js.map +1 -0
- package/build/services/item-service.d.ts +104 -0
- package/build/services/item-service.d.ts.map +1 -0
- package/build/services/item-service.js +368 -0
- package/build/services/item-service.js.map +1 -0
- package/build/services/notification-service.d.ts +125 -0
- package/build/services/notification-service.d.ts.map +1 -0
- package/build/services/notification-service.js +321 -0
- package/build/services/notification-service.js.map +1 -0
- package/build/services/project-epic-service.d.ts +73 -0
- package/build/services/project-epic-service.d.ts.map +1 -0
- package/build/services/project-epic-service.js +248 -0
- package/build/services/project-epic-service.js.map +1 -0
- package/build/services/response-formatter.d.ts +190 -0
- package/build/services/response-formatter.d.ts.map +1 -0
- package/build/services/response-formatter.js +1221 -0
- package/build/services/response-formatter.js.map +1 -0
- package/build/services/search-service.d.ts +103 -0
- package/build/services/search-service.d.ts.map +1 -0
- package/build/services/search-service.js +273 -0
- package/build/services/search-service.js.map +1 -0
- package/build/services/task-service.d.ts +70 -0
- package/build/services/task-service.d.ts.map +1 -0
- package/build/services/task-service.js +156 -0
- package/build/services/task-service.js.map +1 -0
- package/build/tools/index.d.ts +8 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +8 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/tool-definitions.d.ts +89 -0
- package/build/tools/tool-definitions.d.ts.map +1 -0
- package/build/tools/tool-definitions.js +1167 -0
- package/build/tools/tool-definitions.js.map +1 -0
- package/build/types/api-types.d.ts +106 -0
- package/build/types/api-types.d.ts.map +1 -0
- package/build/types/api-types.js +11 -0
- package/build/types/api-types.js.map +1 -0
- package/build/types/cache-types.d.ts +52 -0
- package/build/types/cache-types.d.ts.map +1 -0
- package/build/types/cache-types.js +12 -0
- package/build/types/cache-types.js.map +1 -0
- package/build/types/index.d.ts +31 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +25 -0
- package/build/types/index.js.map +1 -0
- package/build/types/notification-types.d.ts +154 -0
- package/build/types/notification-types.d.ts.map +1 -0
- package/build/types/notification-types.js +7 -0
- package/build/types/notification-types.js.map +1 -0
- package/build/types/podio-types.d.ts +250 -0
- package/build/types/podio-types.d.ts.map +1 -0
- package/build/types/podio-types.js +11 -0
- package/build/types/podio-types.js.map +1 -0
- package/build/types/search-types.d.ts +188 -0
- package/build/types/search-types.d.ts.map +1 -0
- package/build/types/search-types.js +43 -0
- package/build/types/search-types.js.map +1 -0
- package/build/utils/debug.d.ts +58 -0
- package/build/utils/debug.d.ts.map +1 -0
- package/build/utils/debug.js +147 -0
- package/build/utils/debug.js.map +1 -0
- package/examples/claude-config-example.json +13 -0
- package/package.json +87 -0
- package/scripts/generate-claude-config.js +107 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Comprehensive typed error system for the Podio MCP server
|
|
3
|
+
*
|
|
4
|
+
* This module provides a complete set of error classes for proper error handling
|
|
5
|
+
* throughout the Podio MCP server. It replaces generic Error usage with specific,
|
|
6
|
+
* typed error classes that include error codes, HTTP status information, and
|
|
7
|
+
* contextual metadata for better debugging and error handling.
|
|
8
|
+
*
|
|
9
|
+
* @example Basic Usage
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { PodioApiError, PodioAuthError } from './errors/index.js';
|
|
12
|
+
*
|
|
13
|
+
* // API error with response
|
|
14
|
+
* throw PodioApiError.fromResponse(response, 'Custom message');
|
|
15
|
+
*
|
|
16
|
+
* // Authentication error
|
|
17
|
+
* throw PodioAuthError.notInitialized(['PODIO_CLIENT_ID']);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Error Handling
|
|
21
|
+
* ```typescript
|
|
22
|
+
* try {
|
|
23
|
+
* await podioOperation();
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* if (error instanceof PodioApiError) {
|
|
26
|
+
* console.log(`API Error: ${error.code}, Status: ${error.context.statusCode}`);
|
|
27
|
+
* } else if (error instanceof PodioAuthError) {
|
|
28
|
+
* console.log(`Auth Error: ${error.code}`);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
// Export base error classes and types
|
|
34
|
+
export { PodioError, PodioErrorCode, } from './base.js';
|
|
35
|
+
// Export API-related errors
|
|
36
|
+
export { PodioApiError, PodioApiResponseError, } from './api-errors.js';
|
|
37
|
+
// Export authentication-related errors
|
|
38
|
+
export { PodioAuthError } from './auth-errors.js';
|
|
39
|
+
// Export configuration-related errors
|
|
40
|
+
export { PodioConfigError } from './config-errors.js';
|
|
41
|
+
// Export cache-related errors
|
|
42
|
+
export { PodioCacheError } from './cache-errors.js';
|
|
43
|
+
// Export validation-related errors
|
|
44
|
+
export { PodioValidationError } from './validation-errors.js';
|
|
45
|
+
// Export structure-related errors
|
|
46
|
+
export { PodioStructureError } from './structure-errors.js';
|
|
47
|
+
// Import the actual error classes for type guards
|
|
48
|
+
import { PodioError, PodioErrorCode } from './base.js';
|
|
49
|
+
import { PodioApiError } from './api-errors.js';
|
|
50
|
+
import { PodioAuthError } from './auth-errors.js';
|
|
51
|
+
import { PodioConfigError } from './config-errors.js';
|
|
52
|
+
import { PodioCacheError } from './cache-errors.js';
|
|
53
|
+
import { PodioValidationError } from './validation-errors.js';
|
|
54
|
+
import { PodioStructureError } from './structure-errors.js';
|
|
55
|
+
/**
|
|
56
|
+
* Type guard to check if an error is any Podio error
|
|
57
|
+
*/
|
|
58
|
+
export function isPodioError(error) {
|
|
59
|
+
return error instanceof PodioError;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if an error is an API error
|
|
63
|
+
*/
|
|
64
|
+
export function isPodioApiError(error) {
|
|
65
|
+
return error instanceof PodioApiError;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if an error is an authentication error
|
|
69
|
+
*/
|
|
70
|
+
export function isPodioAuthError(error) {
|
|
71
|
+
return error instanceof PodioAuthError;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if an error is a configuration error
|
|
75
|
+
*/
|
|
76
|
+
export function isPodioConfigError(error) {
|
|
77
|
+
return error instanceof PodioConfigError;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if an error is a cache error
|
|
81
|
+
*/
|
|
82
|
+
export function isPodioCacheError(error) {
|
|
83
|
+
return error instanceof PodioCacheError;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Type guard to check if an error is a validation error
|
|
87
|
+
*/
|
|
88
|
+
export function isPodioValidationError(error) {
|
|
89
|
+
return error instanceof PodioValidationError;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Type guard to check if an error is a structure error
|
|
93
|
+
*/
|
|
94
|
+
export function isPodioStructureError(error) {
|
|
95
|
+
return error instanceof PodioStructureError;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Error factory for common error scenarios
|
|
99
|
+
*/
|
|
100
|
+
export class PodioErrorFactory {
|
|
101
|
+
/**
|
|
102
|
+
* Creates appropriate error from HTTP response
|
|
103
|
+
*/
|
|
104
|
+
static fromHttpError(response, message, cause) {
|
|
105
|
+
return PodioApiError.fromResponse(response, message, cause);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates structure not loaded error
|
|
109
|
+
*/
|
|
110
|
+
static structureNotLoaded(operation) {
|
|
111
|
+
return PodioStructureError.notLoaded(operation);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates validation error for required field
|
|
115
|
+
*/
|
|
116
|
+
static requiredField(fieldName, context) {
|
|
117
|
+
return PodioValidationError.requiredField(fieldName, context);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates auth error for uninitialized OAuth
|
|
121
|
+
*/
|
|
122
|
+
static authNotInitialized(missingVars) {
|
|
123
|
+
return PodioAuthError.notInitialized(missingVars);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates API error for failed API call
|
|
127
|
+
*/
|
|
128
|
+
static apiCallFailed(operation, error) {
|
|
129
|
+
const message = `Failed to ${operation}: ${error?.message || 'Unknown error'}`;
|
|
130
|
+
return new PodioApiError(message, PodioErrorCode.API_REQUEST_FAILED, { metadata: { operation } }, error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Re-export the base error for direct access
|
|
134
|
+
export { PodioError as default } from './base.js';
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,sCAAsC;AACtC,OAAO,EACL,UAAU,EACV,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,4BAA4B;AAC5B,OAAO,EACL,aAAa,EACb,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,sCAAsC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,8BAA8B;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,mCAAmC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,kCAAkC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,kDAAkD;AAClD,OAAO,EAAE,UAAU,EAAE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IAC9D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAkB;QAC1C,OAAO,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAiB,EAAE,OAAgB;QACtD,OAAO,oBAAoB,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,WAAsB;QAC9C,OAAO,cAAc,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAiB,EAAE,KAAU;QAChD,MAAM,OAAO,GAAG,aAAa,SAAS,KAAK,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/E,OAAO,IAAI,aAAa,CACtB,OAAO,EACP,cAAc,CAAC,kBAAkB,EACjC,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,EAC3B,KAAK,CACN,CAAC;IACJ,CAAC;CACF;AAED,6CAA6C;AAC7C,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Structure-related error classes for the Podio MCP server
|
|
3
|
+
*
|
|
4
|
+
* This module provides error classes specifically for app structure issues,
|
|
5
|
+
* including missing app structure data, field configuration problems, and
|
|
6
|
+
* workspace structure validation failures.
|
|
7
|
+
*/
|
|
8
|
+
import { PodioError, PodioErrorCode, type ErrorContext } from './base.js';
|
|
9
|
+
/**
|
|
10
|
+
* Base class for all structure-related errors.
|
|
11
|
+
*
|
|
12
|
+
* This error is thrown when there are issues with Podio app structure,
|
|
13
|
+
* field configurations, or workspace structure validation.
|
|
14
|
+
*/
|
|
15
|
+
export declare class PodioStructureError extends PodioError {
|
|
16
|
+
constructor(message: string, code?: PodioErrorCode, context?: ErrorContext, cause?: Error);
|
|
17
|
+
/**
|
|
18
|
+
* Creates an error for when app structure is not loaded.
|
|
19
|
+
*
|
|
20
|
+
* @param operation - The operation that requires loaded structure
|
|
21
|
+
*/
|
|
22
|
+
static notLoaded(operation?: string): PodioStructureError;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an error for when a specific app is not found in the structure.
|
|
25
|
+
*
|
|
26
|
+
* @param appIdentifier - The app identifier (ID, name, or coordinates)
|
|
27
|
+
* @param availableApps - Array of available app identifiers
|
|
28
|
+
*/
|
|
29
|
+
static appNotFound(appIdentifier: string, availableApps?: string[]): PodioStructureError;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an error for when a specific field is not found in app structure.
|
|
32
|
+
*
|
|
33
|
+
* @param fieldIdentifier - The field identifier (ID, name, or external_id)
|
|
34
|
+
* @param appName - Name of the app being searched
|
|
35
|
+
* @param availableFields - Array of available field identifiers
|
|
36
|
+
*/
|
|
37
|
+
static fieldNotFound(fieldIdentifier: string, appName?: string, availableFields?: string[]): PodioStructureError;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an error for field type mismatch.
|
|
40
|
+
*
|
|
41
|
+
* @param fieldIdentifier - The field identifier
|
|
42
|
+
* @param expectedType - The expected field type
|
|
43
|
+
* @param actualType - The actual field type
|
|
44
|
+
*/
|
|
45
|
+
static fieldTypeMismatch(fieldIdentifier: string, expectedType: string, actualType: string): PodioStructureError;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an error for missing required fields.
|
|
48
|
+
*
|
|
49
|
+
* @param missingFields - Array of missing field identifiers
|
|
50
|
+
*/
|
|
51
|
+
static missingFields(missingFields: string[]): PodioStructureError;
|
|
52
|
+
/**
|
|
53
|
+
* Creates an error for invalid app structure configuration.
|
|
54
|
+
*
|
|
55
|
+
* @param issue - Description of the configuration issue
|
|
56
|
+
* @param appName - Name of the app with configuration issues
|
|
57
|
+
* @param details - Additional details about the issue
|
|
58
|
+
*/
|
|
59
|
+
static invalidConfig(issue: string, appName?: string, details?: Record<string, any>): PodioStructureError;
|
|
60
|
+
/**
|
|
61
|
+
* Creates an error for when space information is not found.
|
|
62
|
+
*
|
|
63
|
+
* @param spaceIdentifier - The space identifier
|
|
64
|
+
* @param context - Context about why space is needed
|
|
65
|
+
*/
|
|
66
|
+
static spaceNotFound(spaceIdentifier?: string, context?: string): PodioStructureError;
|
|
67
|
+
/**
|
|
68
|
+
* Creates an error for missing field options.
|
|
69
|
+
*
|
|
70
|
+
* @param fieldName - Name of the field missing options
|
|
71
|
+
* @param fieldType - Type of the field
|
|
72
|
+
*/
|
|
73
|
+
static missingFieldOptions(fieldName: string, fieldType: string): PodioStructureError;
|
|
74
|
+
/**
|
|
75
|
+
* Creates an error for invalid workspace coordinates.
|
|
76
|
+
*
|
|
77
|
+
* @param coordinates - The invalid coordinates provided
|
|
78
|
+
* @param issue - Description of what's wrong with the coordinates
|
|
79
|
+
*/
|
|
80
|
+
static invalidCoordinates(coordinates: Record<string, any>, issue: string): PodioStructureError;
|
|
81
|
+
/**
|
|
82
|
+
* Creates an error for when no valid app ID or coordinates are available.
|
|
83
|
+
*
|
|
84
|
+
* @param itemType - The type of item being fetched
|
|
85
|
+
* @param context - Additional context about the attempted operation
|
|
86
|
+
*/
|
|
87
|
+
static noValidAppReference(itemType: string, context?: string): PodioStructureError;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=structure-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structure-errors.d.ts","sourceRoot":"","sources":["../../src/errors/structure-errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;gBAE/C,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,cAAoD,EAC1D,OAAO,GAAE,YAAiB,EAC1B,KAAK,CA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-0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Structure-related error classes for the Podio MCP server
|
|
3
|
+
*
|
|
4
|
+
* This module provides error classes specifically for app structure issues,
|
|
5
|
+
* including missing app structure data, field configuration problems, and
|
|
6
|
+
* workspace structure validation failures.
|
|
7
|
+
*/
|
|
8
|
+
import { PodioError, PodioErrorCode } from './base.js';
|
|
9
|
+
/**
|
|
10
|
+
* Base class for all structure-related errors.
|
|
11
|
+
*
|
|
12
|
+
* This error is thrown when there are issues with Podio app structure,
|
|
13
|
+
* field configurations, or workspace structure validation.
|
|
14
|
+
*/
|
|
15
|
+
export class PodioStructureError extends PodioError {
|
|
16
|
+
constructor(message, code = PodioErrorCode.STRUCTURE_NOT_LOADED, context = {}, cause) {
|
|
17
|
+
super(message, code, context, cause);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an error for when app structure is not loaded.
|
|
21
|
+
*
|
|
22
|
+
* @param operation - The operation that requires loaded structure
|
|
23
|
+
*/
|
|
24
|
+
static notLoaded(operation) {
|
|
25
|
+
const message = operation
|
|
26
|
+
? `App structure not loaded. Please call get_app_structure first before ${operation}.`
|
|
27
|
+
: 'App structure not loaded. Please call get_app_structure first.';
|
|
28
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_NOT_LOADED, {
|
|
29
|
+
metadata: { operation },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an error for when a specific app is not found in the structure.
|
|
34
|
+
*
|
|
35
|
+
* @param appIdentifier - The app identifier (ID, name, or coordinates)
|
|
36
|
+
* @param availableApps - Array of available app identifiers
|
|
37
|
+
*/
|
|
38
|
+
static appNotFound(appIdentifier, availableApps) {
|
|
39
|
+
const message = `App not found: ${appIdentifier}`;
|
|
40
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_APP_NOT_FOUND, {
|
|
41
|
+
metadata: {
|
|
42
|
+
appIdentifier,
|
|
43
|
+
availableApps,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates an error for when a specific field is not found in app structure.
|
|
49
|
+
*
|
|
50
|
+
* @param fieldIdentifier - The field identifier (ID, name, or external_id)
|
|
51
|
+
* @param appName - Name of the app being searched
|
|
52
|
+
* @param availableFields - Array of available field identifiers
|
|
53
|
+
*/
|
|
54
|
+
static fieldNotFound(fieldIdentifier, appName, availableFields) {
|
|
55
|
+
const message = appName
|
|
56
|
+
? `Field '${fieldIdentifier}' not found in app '${appName}'`
|
|
57
|
+
: `Field '${fieldIdentifier}' not found`;
|
|
58
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_FIELD_NOT_FOUND, {
|
|
59
|
+
metadata: {
|
|
60
|
+
fieldIdentifier,
|
|
61
|
+
appName,
|
|
62
|
+
availableFields,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates an error for field type mismatch.
|
|
68
|
+
*
|
|
69
|
+
* @param fieldIdentifier - The field identifier
|
|
70
|
+
* @param expectedType - The expected field type
|
|
71
|
+
* @param actualType - The actual field type
|
|
72
|
+
*/
|
|
73
|
+
static fieldTypeMismatch(fieldIdentifier, expectedType, actualType) {
|
|
74
|
+
const message = `Field '${fieldIdentifier}' type mismatch: expected '${expectedType}', got '${actualType}'`;
|
|
75
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_FIELD_NOT_FOUND, {
|
|
76
|
+
metadata: {
|
|
77
|
+
fieldIdentifier,
|
|
78
|
+
expectedType,
|
|
79
|
+
actualType,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates an error for missing required fields.
|
|
85
|
+
*
|
|
86
|
+
* @param missingFields - Array of missing field identifiers
|
|
87
|
+
*/
|
|
88
|
+
static missingFields(missingFields) {
|
|
89
|
+
const message = `Missing required fields: ${missingFields.join(', ')}`;
|
|
90
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_FIELD_NOT_FOUND, {
|
|
91
|
+
metadata: {
|
|
92
|
+
missingFields,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates an error for invalid app structure configuration.
|
|
98
|
+
*
|
|
99
|
+
* @param issue - Description of the configuration issue
|
|
100
|
+
* @param appName - Name of the app with configuration issues
|
|
101
|
+
* @param details - Additional details about the issue
|
|
102
|
+
*/
|
|
103
|
+
static invalidConfig(issue, appName, details) {
|
|
104
|
+
const message = appName
|
|
105
|
+
? `Invalid app structure configuration for '${appName}': ${issue}`
|
|
106
|
+
: `Invalid app structure configuration: ${issue}`;
|
|
107
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_INVALID_CONFIG, {
|
|
108
|
+
metadata: {
|
|
109
|
+
issue,
|
|
110
|
+
appName,
|
|
111
|
+
details,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates an error for when space information is not found.
|
|
117
|
+
*
|
|
118
|
+
* @param spaceIdentifier - The space identifier
|
|
119
|
+
* @param context - Context about why space is needed
|
|
120
|
+
*/
|
|
121
|
+
static spaceNotFound(spaceIdentifier, context) {
|
|
122
|
+
const message = spaceIdentifier
|
|
123
|
+
? `Space '${spaceIdentifier}' not found in app structure`
|
|
124
|
+
: 'Space ID not available in app structure. Assignment by name/email requires space context.';
|
|
125
|
+
const contextMsg = context ? ` Context: ${context}` : '';
|
|
126
|
+
const fullMessage = message + contextMsg;
|
|
127
|
+
return new PodioStructureError(fullMessage, PodioErrorCode.STRUCTURE_SPACE_NOT_FOUND, {
|
|
128
|
+
metadata: {
|
|
129
|
+
spaceIdentifier,
|
|
130
|
+
context,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates an error for missing field options.
|
|
136
|
+
*
|
|
137
|
+
* @param fieldName - Name of the field missing options
|
|
138
|
+
* @param fieldType - Type of the field
|
|
139
|
+
*/
|
|
140
|
+
static missingFieldOptions(fieldName, fieldType) {
|
|
141
|
+
const message = `${fieldName} field has no options configured.`;
|
|
142
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_FIELD_NOT_FOUND, {
|
|
143
|
+
metadata: {
|
|
144
|
+
fieldName,
|
|
145
|
+
fieldType,
|
|
146
|
+
issue: 'missing_options',
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates an error for invalid workspace coordinates.
|
|
152
|
+
*
|
|
153
|
+
* @param coordinates - The invalid coordinates provided
|
|
154
|
+
* @param issue - Description of what's wrong with the coordinates
|
|
155
|
+
*/
|
|
156
|
+
static invalidCoordinates(coordinates, issue) {
|
|
157
|
+
const message = `Invalid workspace coordinates: ${issue}`;
|
|
158
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_INVALID_CONFIG, {
|
|
159
|
+
metadata: {
|
|
160
|
+
coordinates,
|
|
161
|
+
issue,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates an error for when no valid app ID or coordinates are available.
|
|
167
|
+
*
|
|
168
|
+
* @param itemType - The type of item being fetched
|
|
169
|
+
* @param context - Additional context about the attempted operation
|
|
170
|
+
*/
|
|
171
|
+
static noValidAppReference(itemType, context) {
|
|
172
|
+
const message = `Failed to fetch ${itemType.toLowerCase()}: No valid app ID or coordinates available`;
|
|
173
|
+
return new PodioStructureError(message, PodioErrorCode.STRUCTURE_INVALID_CONFIG, {
|
|
174
|
+
metadata: {
|
|
175
|
+
itemType,
|
|
176
|
+
context,
|
|
177
|
+
issue: 'no_valid_app_reference',
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=structure-errors.js.map
|
|
@@ -0,0 +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
|
|
3
|
+
*
|
|
4
|
+
* This module provides error classes specifically for data validation failures,
|
|
5
|
+
* including field validation, parameter validation, and format validation.
|
|
6
|
+
*/
|
|
7
|
+
import { PodioError, PodioErrorCode, type ErrorContext } from './base.js';
|
|
8
|
+
/**
|
|
9
|
+
* Base class for all validation-related errors.
|
|
10
|
+
*
|
|
11
|
+
* This error is thrown when data validation fails, including invalid
|
|
12
|
+
* field values, missing required parameters, and format validation issues.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PodioValidationError extends PodioError {
|
|
15
|
+
constructor(message: string, code?: PodioErrorCode, context?: ErrorContext, cause?: Error);
|
|
16
|
+
/**
|
|
17
|
+
* Creates an error for missing required fields.
|
|
18
|
+
*
|
|
19
|
+
* @param fieldName - Name of the required field
|
|
20
|
+
* @param context - Additional context about where the field is required
|
|
21
|
+
*/
|
|
22
|
+
static requiredField(fieldName: string, context?: string): PodioValidationError;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an error for invalid field types.
|
|
25
|
+
*
|
|
26
|
+
* @param fieldName - Name of the field with invalid type
|
|
27
|
+
* @param expectedType - Expected type
|
|
28
|
+
* @param actualType - Actual type received
|
|
29
|
+
* @param value - The invalid value
|
|
30
|
+
*/
|
|
31
|
+
static invalidType(fieldName: string, expectedType: string, actualType: string, value?: any): PodioValidationError;
|
|
32
|
+
/**
|
|
33
|
+
* Creates an error for values outside valid ranges.
|
|
34
|
+
*
|
|
35
|
+
* @param fieldName - Name of the field with out-of-range value
|
|
36
|
+
* @param value - The out-of-range value
|
|
37
|
+
* @param min - Minimum allowed value
|
|
38
|
+
* @param max - Maximum allowed value
|
|
39
|
+
*/
|
|
40
|
+
static outOfRange(fieldName: string, value: number, min?: number, max?: number): PodioValidationError;
|
|
41
|
+
/**
|
|
42
|
+
* Creates an error for invalid format.
|
|
43
|
+
*
|
|
44
|
+
* @param fieldName - Name of the field with invalid format
|
|
45
|
+
* @param value - The value with invalid format
|
|
46
|
+
* @param expectedFormat - Description of expected format
|
|
47
|
+
*/
|
|
48
|
+
static invalidFormat(fieldName: string, value: any, expectedFormat: string): PodioValidationError;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error for when no valid fields are provided for an operation.
|
|
51
|
+
*
|
|
52
|
+
* @param operation - The operation that requires valid fields
|
|
53
|
+
* @param providedFields - Array of field names that were provided
|
|
54
|
+
*/
|
|
55
|
+
static noValidFields(operation: string, providedFields?: string[]): PodioValidationError;
|
|
56
|
+
/**
|
|
57
|
+
* Creates an error for invalid enum values.
|
|
58
|
+
*
|
|
59
|
+
* @param fieldName - Name of the field with invalid enum value
|
|
60
|
+
* @param value - The invalid enum value
|
|
61
|
+
* @param validValues - Array of valid enum values
|
|
62
|
+
*/
|
|
63
|
+
static invalidEnumValue(fieldName: string, value: any, validValues: string[]): PodioValidationError;
|
|
64
|
+
/**
|
|
65
|
+
* Creates an error for resource not found during validation.
|
|
66
|
+
*
|
|
67
|
+
* @param resourceType - Type of resource that wasn't found
|
|
68
|
+
* @param identifier - The identifier used to search for the resource
|
|
69
|
+
* @param searchContext - Additional context about the search
|
|
70
|
+
*/
|
|
71
|
+
static resourceNotFound(resourceType: string, identifier: string, searchContext?: string): PodioValidationError;
|
|
72
|
+
/**
|
|
73
|
+
* Creates an error for invalid field values.
|
|
74
|
+
*
|
|
75
|
+
* @param fieldName - Name of the field with invalid value
|
|
76
|
+
* @param value - The invalid value
|
|
77
|
+
* @param reason - Reason why the value is invalid
|
|
78
|
+
*/
|
|
79
|
+
static invalidFieldValue(fieldName: string, value: any, reason: string): PodioValidationError;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=validation-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-errors.d.ts","sourceRoot":"","sources":["../../src/errors/validation-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1E;;;;;GA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|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Validation-related error classes for the Podio MCP server
|
|
3
|
+
*
|
|
4
|
+
* This module provides error classes specifically for data validation failures,
|
|
5
|
+
* including field validation, parameter validation, and format validation.
|
|
6
|
+
*/
|
|
7
|
+
import { PodioError, PodioErrorCode } from './base.js';
|
|
8
|
+
/**
|
|
9
|
+
* Base class for all validation-related errors.
|
|
10
|
+
*
|
|
11
|
+
* This error is thrown when data validation fails, including invalid
|
|
12
|
+
* field values, missing required parameters, and format validation issues.
|
|
13
|
+
*/
|
|
14
|
+
export class PodioValidationError extends PodioError {
|
|
15
|
+
constructor(message, code = PodioErrorCode.VALIDATION_REQUIRED_FIELD, context = {}, cause) {
|
|
16
|
+
super(message, code, context, cause);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates an error for missing required fields.
|
|
20
|
+
*
|
|
21
|
+
* @param fieldName - Name of the required field
|
|
22
|
+
* @param context - Additional context about where the field is required
|
|
23
|
+
*/
|
|
24
|
+
static requiredField(fieldName, context) {
|
|
25
|
+
const message = context
|
|
26
|
+
? `Required field '${fieldName}' is missing in ${context}`
|
|
27
|
+
: `Required field '${fieldName}' is missing`;
|
|
28
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_REQUIRED_FIELD, {
|
|
29
|
+
metadata: {
|
|
30
|
+
fieldName,
|
|
31
|
+
validationContext: context,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates an error for invalid field types.
|
|
37
|
+
*
|
|
38
|
+
* @param fieldName - Name of the field with invalid type
|
|
39
|
+
* @param expectedType - Expected type
|
|
40
|
+
* @param actualType - Actual type received
|
|
41
|
+
* @param value - The invalid value
|
|
42
|
+
*/
|
|
43
|
+
static invalidType(fieldName, expectedType, actualType, value) {
|
|
44
|
+
const message = `Field '${fieldName}' has invalid type. Expected: ${expectedType}, got: ${actualType}`;
|
|
45
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_INVALID_TYPE, {
|
|
46
|
+
metadata: {
|
|
47
|
+
fieldName,
|
|
48
|
+
expectedType,
|
|
49
|
+
actualType,
|
|
50
|
+
value,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates an error for values outside valid ranges.
|
|
56
|
+
*
|
|
57
|
+
* @param fieldName - Name of the field with out-of-range value
|
|
58
|
+
* @param value - The out-of-range value
|
|
59
|
+
* @param min - Minimum allowed value
|
|
60
|
+
* @param max - Maximum allowed value
|
|
61
|
+
*/
|
|
62
|
+
static outOfRange(fieldName, value, min, max) {
|
|
63
|
+
let rangeDesc = '';
|
|
64
|
+
if (min !== undefined && max !== undefined) {
|
|
65
|
+
rangeDesc = ` (range: ${min}-${max})`;
|
|
66
|
+
}
|
|
67
|
+
else if (min !== undefined) {
|
|
68
|
+
rangeDesc = ` (minimum: ${min})`;
|
|
69
|
+
}
|
|
70
|
+
else if (max !== undefined) {
|
|
71
|
+
rangeDesc = ` (maximum: ${max})`;
|
|
72
|
+
}
|
|
73
|
+
const message = `Field '${fieldName}' value ${value} is out of range${rangeDesc}`;
|
|
74
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_OUT_OF_RANGE, {
|
|
75
|
+
metadata: {
|
|
76
|
+
fieldName,
|
|
77
|
+
value,
|
|
78
|
+
min,
|
|
79
|
+
max,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates an error for invalid format.
|
|
85
|
+
*
|
|
86
|
+
* @param fieldName - Name of the field with invalid format
|
|
87
|
+
* @param value - The value with invalid format
|
|
88
|
+
* @param expectedFormat - Description of expected format
|
|
89
|
+
*/
|
|
90
|
+
static invalidFormat(fieldName, value, expectedFormat) {
|
|
91
|
+
const message = `Field '${fieldName}' has invalid format. Value: ${value}, Expected: ${expectedFormat}`;
|
|
92
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_FORMAT_INVALID, {
|
|
93
|
+
metadata: {
|
|
94
|
+
fieldName,
|
|
95
|
+
value,
|
|
96
|
+
expectedFormat,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates an error for when no valid fields are provided for an operation.
|
|
102
|
+
*
|
|
103
|
+
* @param operation - The operation that requires valid fields
|
|
104
|
+
* @param providedFields - Array of field names that were provided
|
|
105
|
+
*/
|
|
106
|
+
static noValidFields(operation, providedFields) {
|
|
107
|
+
const message = `No valid fields to ${operation} were provided.`;
|
|
108
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_NO_VALID_FIELDS, {
|
|
109
|
+
metadata: {
|
|
110
|
+
operation,
|
|
111
|
+
providedFields,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates an error for invalid enum values.
|
|
117
|
+
*
|
|
118
|
+
* @param fieldName - Name of the field with invalid enum value
|
|
119
|
+
* @param value - The invalid enum value
|
|
120
|
+
* @param validValues - Array of valid enum values
|
|
121
|
+
*/
|
|
122
|
+
static invalidEnumValue(fieldName, value, validValues) {
|
|
123
|
+
const message = `Field '${fieldName}' has invalid value '${value}'. Valid values: ${validValues.join(', ')}`;
|
|
124
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_FORMAT_INVALID, {
|
|
125
|
+
metadata: {
|
|
126
|
+
fieldName,
|
|
127
|
+
value,
|
|
128
|
+
validValues,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates an error for resource not found during validation.
|
|
134
|
+
*
|
|
135
|
+
* @param resourceType - Type of resource that wasn't found
|
|
136
|
+
* @param identifier - The identifier used to search for the resource
|
|
137
|
+
* @param searchContext - Additional context about the search
|
|
138
|
+
*/
|
|
139
|
+
static resourceNotFound(resourceType, identifier, searchContext) {
|
|
140
|
+
const message = searchContext
|
|
141
|
+
? `${resourceType} "${identifier}" not found in ${searchContext}`
|
|
142
|
+
: `${resourceType} "${identifier}" not found`;
|
|
143
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_FORMAT_INVALID, {
|
|
144
|
+
metadata: {
|
|
145
|
+
resourceType,
|
|
146
|
+
identifier,
|
|
147
|
+
searchContext,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Creates an error for invalid field values.
|
|
153
|
+
*
|
|
154
|
+
* @param fieldName - Name of the field with invalid value
|
|
155
|
+
* @param value - The invalid value
|
|
156
|
+
* @param reason - Reason why the value is invalid
|
|
157
|
+
*/
|
|
158
|
+
static invalidFieldValue(fieldName, value, reason) {
|
|
159
|
+
const message = `Field '${fieldName}' has invalid value '${value}': ${reason}`;
|
|
160
|
+
return new PodioValidationError(message, PodioErrorCode.VALIDATION_FORMAT_INVALID, {
|
|
161
|
+
metadata: {
|
|
162
|
+
fieldName,
|
|
163
|
+
value,
|
|
164
|
+
reason,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=validation-errors.js.map
|