@salesforce/metadata-core-sdk 1.0.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 (150) hide show
  1. package/LICENSE.txt +27 -0
  2. package/README.md +219 -0
  3. package/dist/index.d.ts +38 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +22 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/sdk/abstractions/core/IPlatformContext.d.ts +45 -0
  8. package/dist/sdk/abstractions/core/IPlatformContext.d.ts.map +1 -0
  9. package/dist/sdk/abstractions/core/IPlatformContext.js +8 -0
  10. package/dist/sdk/abstractions/core/IPlatformContext.js.map +1 -0
  11. package/dist/sdk/abstractions/core/index.d.ts +8 -0
  12. package/dist/sdk/abstractions/core/index.d.ts.map +1 -0
  13. package/dist/sdk/abstractions/core/index.js +8 -0
  14. package/dist/sdk/abstractions/core/index.js.map +1 -0
  15. package/dist/sdk/abstractions/index.d.ts +17 -0
  16. package/dist/sdk/abstractions/index.d.ts.map +1 -0
  17. package/dist/sdk/abstractions/index.js +20 -0
  18. package/dist/sdk/abstractions/index.js.map +1 -0
  19. package/dist/sdk/abstractions/services/IFileSystem.d.ts +114 -0
  20. package/dist/sdk/abstractions/services/IFileSystem.d.ts.map +1 -0
  21. package/dist/sdk/abstractions/services/IFileSystem.js +8 -0
  22. package/dist/sdk/abstractions/services/IFileSystem.js.map +1 -0
  23. package/dist/sdk/abstractions/services/ILogger.d.ts +63 -0
  24. package/dist/sdk/abstractions/services/ILogger.d.ts.map +1 -0
  25. package/dist/sdk/abstractions/services/ILogger.js +18 -0
  26. package/dist/sdk/abstractions/services/ILogger.js.map +1 -0
  27. package/dist/sdk/abstractions/services/ITelemetry.d.ts +159 -0
  28. package/dist/sdk/abstractions/services/ITelemetry.d.ts.map +1 -0
  29. package/dist/sdk/abstractions/services/ITelemetry.js +97 -0
  30. package/dist/sdk/abstractions/services/ITelemetry.js.map +1 -0
  31. package/dist/sdk/abstractions/services/index.d.ts +10 -0
  32. package/dist/sdk/abstractions/services/index.d.ts.map +1 -0
  33. package/dist/sdk/abstractions/services/index.js +10 -0
  34. package/dist/sdk/abstractions/services/index.js.map +1 -0
  35. package/dist/sdk/abstractions/types/FileMetadata.d.ts +15 -0
  36. package/dist/sdk/abstractions/types/FileMetadata.d.ts.map +1 -0
  37. package/dist/sdk/abstractions/types/FileMetadata.js +8 -0
  38. package/dist/sdk/abstractions/types/FileMetadata.js.map +1 -0
  39. package/dist/sdk/abstractions/types/Result.d.ts +15 -0
  40. package/dist/sdk/abstractions/types/Result.d.ts.map +1 -0
  41. package/dist/sdk/abstractions/types/Result.js +8 -0
  42. package/dist/sdk/abstractions/types/Result.js.map +1 -0
  43. package/dist/sdk/abstractions/types/index.d.ts +9 -0
  44. package/dist/sdk/abstractions/types/index.d.ts.map +1 -0
  45. package/dist/sdk/abstractions/types/index.js +9 -0
  46. package/dist/sdk/abstractions/types/index.js.map +1 -0
  47. package/dist/sdk/constants.d.ts +35 -0
  48. package/dist/sdk/constants.d.ts.map +1 -0
  49. package/dist/sdk/constants.js +35 -0
  50. package/dist/sdk/constants.js.map +1 -0
  51. package/dist/sdk/contracts/core/IMetadataParser.d.ts +49 -0
  52. package/dist/sdk/contracts/core/IMetadataParser.d.ts.map +1 -0
  53. package/dist/sdk/contracts/core/IMetadataParser.js +8 -0
  54. package/dist/sdk/contracts/core/IMetadataParser.js.map +1 -0
  55. package/dist/sdk/contracts/core/IVisualizationPlugin.d.ts +65 -0
  56. package/dist/sdk/contracts/core/IVisualizationPlugin.d.ts.map +1 -0
  57. package/dist/sdk/contracts/core/IVisualizationPlugin.js +8 -0
  58. package/dist/sdk/contracts/core/IVisualizationPlugin.js.map +1 -0
  59. package/dist/sdk/contracts/core/index.d.ts +9 -0
  60. package/dist/sdk/contracts/core/index.d.ts.map +1 -0
  61. package/dist/sdk/contracts/core/index.js +9 -0
  62. package/dist/sdk/contracts/core/index.js.map +1 -0
  63. package/dist/sdk/contracts/index.d.ts +9 -0
  64. package/dist/sdk/contracts/index.d.ts.map +1 -0
  65. package/dist/sdk/contracts/index.js +9 -0
  66. package/dist/sdk/contracts/index.js.map +1 -0
  67. package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts +56 -0
  68. package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts.map +1 -0
  69. package/dist/sdk/contracts/types/MetadataPluginInfo.js +8 -0
  70. package/dist/sdk/contracts/types/MetadataPluginInfo.js.map +1 -0
  71. package/dist/sdk/contracts/types/PluginConfig.d.ts +16 -0
  72. package/dist/sdk/contracts/types/PluginConfig.d.ts.map +1 -0
  73. package/dist/sdk/contracts/types/PluginConfig.js +8 -0
  74. package/dist/sdk/contracts/types/PluginConfig.js.map +1 -0
  75. package/dist/sdk/contracts/types/PluginContext.d.ts +22 -0
  76. package/dist/sdk/contracts/types/PluginContext.d.ts.map +1 -0
  77. package/dist/sdk/contracts/types/PluginContext.js +8 -0
  78. package/dist/sdk/contracts/types/PluginContext.js.map +1 -0
  79. package/dist/sdk/contracts/types/PluginError.d.ts +50 -0
  80. package/dist/sdk/contracts/types/PluginError.d.ts.map +1 -0
  81. package/dist/sdk/contracts/types/PluginError.js +31 -0
  82. package/dist/sdk/contracts/types/PluginError.js.map +1 -0
  83. package/dist/sdk/contracts/types/ValidationResult.d.ts +15 -0
  84. package/dist/sdk/contracts/types/ValidationResult.d.ts.map +1 -0
  85. package/dist/sdk/contracts/types/ValidationResult.js +8 -0
  86. package/dist/sdk/contracts/types/ValidationResult.js.map +1 -0
  87. package/dist/sdk/contracts/types/VersionInfo.d.ts +24 -0
  88. package/dist/sdk/contracts/types/VersionInfo.d.ts.map +1 -0
  89. package/dist/sdk/contracts/types/VersionInfo.js +8 -0
  90. package/dist/sdk/contracts/types/VersionInfo.js.map +1 -0
  91. package/dist/sdk/contracts/types/index.d.ts +13 -0
  92. package/dist/sdk/contracts/types/index.d.ts.map +1 -0
  93. package/dist/sdk/contracts/types/index.js +13 -0
  94. package/dist/sdk/contracts/types/index.js.map +1 -0
  95. package/dist/sdk/design-system/index.d.ts +11 -0
  96. package/dist/sdk/design-system/index.d.ts.map +1 -0
  97. package/dist/sdk/design-system/index.js +12 -0
  98. package/dist/sdk/design-system/index.js.map +1 -0
  99. package/dist/sdk/design-system/tokens/colors.d.ts +122 -0
  100. package/dist/sdk/design-system/tokens/colors.d.ts.map +1 -0
  101. package/dist/sdk/design-system/tokens/colors.js +142 -0
  102. package/dist/sdk/design-system/tokens/colors.js.map +1 -0
  103. package/dist/sdk/design-system/tokens/spacing.d.ts +24 -0
  104. package/dist/sdk/design-system/tokens/spacing.d.ts.map +1 -0
  105. package/dist/sdk/design-system/tokens/spacing.js +24 -0
  106. package/dist/sdk/design-system/tokens/spacing.js.map +1 -0
  107. package/dist/sdk/design-system/tokens/typography.d.ts +31 -0
  108. package/dist/sdk/design-system/tokens/typography.d.ts.map +1 -0
  109. package/dist/sdk/design-system/tokens/typography.js +31 -0
  110. package/dist/sdk/design-system/tokens/typography.js.map +1 -0
  111. package/dist/sdk/design-system/utils.d.ts +66 -0
  112. package/dist/sdk/design-system/utils.d.ts.map +1 -0
  113. package/dist/sdk/design-system/utils.js +116 -0
  114. package/dist/sdk/design-system/utils.js.map +1 -0
  115. package/dist/sdk/design-system/vscode-design-system.css +623 -0
  116. package/dist/sdk/utils/errors/ErrorBoundary.d.ts +35 -0
  117. package/dist/sdk/utils/errors/ErrorBoundary.d.ts.map +1 -0
  118. package/dist/sdk/utils/errors/ErrorBoundary.js +65 -0
  119. package/dist/sdk/utils/errors/ErrorBoundary.js.map +1 -0
  120. package/dist/sdk/utils/errors/ErrorBuilder.d.ts +107 -0
  121. package/dist/sdk/utils/errors/ErrorBuilder.d.ts.map +1 -0
  122. package/dist/sdk/utils/errors/ErrorBuilder.js +163 -0
  123. package/dist/sdk/utils/errors/ErrorBuilder.js.map +1 -0
  124. package/dist/sdk/utils/errors/setupHandlers.d.ts +12 -0
  125. package/dist/sdk/utils/errors/setupHandlers.d.ts.map +1 -0
  126. package/dist/sdk/utils/errors/setupHandlers.js +42 -0
  127. package/dist/sdk/utils/errors/setupHandlers.js.map +1 -0
  128. package/dist/sdk/utils/logger.d.ts +41 -0
  129. package/dist/sdk/utils/logger.d.ts.map +1 -0
  130. package/dist/sdk/utils/logger.js +54 -0
  131. package/dist/sdk/utils/logger.js.map +1 -0
  132. package/dist/sdk/utils/test-helpers/architecture-test-utils.d.ts +146 -0
  133. package/dist/sdk/utils/test-helpers/architecture-test-utils.d.ts.map +1 -0
  134. package/dist/sdk/utils/test-helpers/architecture-test-utils.js +286 -0
  135. package/dist/sdk/utils/test-helpers/architecture-test-utils.js.map +1 -0
  136. package/dist/sdk/utils/test-helpers/index.d.ts +8 -0
  137. package/dist/sdk/utils/test-helpers/index.d.ts.map +1 -0
  138. package/dist/sdk/utils/test-helpers/index.js +8 -0
  139. package/dist/sdk/utils/test-helpers/index.js.map +1 -0
  140. package/dist/sdk/utils/xmlParser.d.ts +38 -0
  141. package/dist/sdk/utils/xmlParser.d.ts.map +1 -0
  142. package/dist/sdk/utils/xmlParser.js +79 -0
  143. package/dist/sdk/utils/xmlParser.js.map +1 -0
  144. package/dist/sdk/webviewMessageTypes.d.ts +24 -0
  145. package/dist/sdk/webviewMessageTypes.d.ts.map +1 -0
  146. package/dist/sdk/webviewMessageTypes.js +23 -0
  147. package/dist/sdk/webviewMessageTypes.js.map +1 -0
  148. package/package.json +80 -0
  149. package/src/sdk/utils/test-helpers/architecture-test-utils.ts +365 -0
  150. package/src/sdk/utils/test-helpers/index.ts +20 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import React from 'react';
8
+ import { ErrorCategory } from '../../contracts/types/PluginError.js';
9
+ import { ErrorBuilder } from './ErrorBuilder.js';
10
+ /**
11
+ * Report a React error to the framework (shared logic).
12
+ */
13
+ function reportReactError(error, errorInfo) {
14
+ ErrorBuilder.create()
15
+ .category(ErrorCategory.Rendering)
16
+ .message(error.message)
17
+ .stackTrace(error.stack)
18
+ .context({
19
+ componentStack: errorInfo.componentStack,
20
+ errorName: error.name,
21
+ })
22
+ .send();
23
+ console.error('[ErrorBoundary] Rendering error:', error, errorInfo);
24
+ }
25
+ /**
26
+ * Minimal error fallback; error is already reported to the host via ErrorBuilder.
27
+ */
28
+ function ErrorFallbackUI({ error }) {
29
+ return (React.createElement(React.Fragment, null,
30
+ React.createElement("p", null, "Something went wrong. Check the error panel for details."),
31
+ error && (React.createElement(React.Fragment, null,
32
+ error.message && React.createElement("p", null, error.message),
33
+ error.stack && React.createElement("pre", null, error.stack)))));
34
+ }
35
+ /**
36
+ * Standalone React Error Boundary component
37
+ *
38
+ * This component can be used directly in JSX to wrap sections of your UI.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * <ErrorBoundary>
43
+ * <ObjectDiagram data={data} />
44
+ * </ErrorBoundary>
45
+ * ```
46
+ */
47
+ export class ErrorBoundary extends React.Component {
48
+ constructor(props) {
49
+ super(props);
50
+ this.state = { hasError: false };
51
+ }
52
+ static getDerivedStateFromError(error) {
53
+ return { hasError: true, error };
54
+ }
55
+ componentDidCatch(error, errorInfo) {
56
+ reportReactError(error, errorInfo);
57
+ }
58
+ render() {
59
+ if (this.state.hasError) {
60
+ return React.createElement(ErrorFallbackUI, { error: this.state.error });
61
+ }
62
+ return this.props.children;
63
+ }
64
+ }
65
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../src/sdk/utils/errors/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO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,oBAAC,eAAe,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import type { PluginError } from '../../contracts/types/PluginError.js';
8
+ import { ErrorCategory } from '../../contracts/types/PluginError.js';
9
+ /**
10
+ * Fluent builder for creating structured plugin errors
11
+ *
12
+ * This builder provides a type-safe and intuitive way for plugins to construct
13
+ * error objects that can be reported to the visualization framework.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Build and send an error
18
+ * ErrorBuilder.create()
19
+ * .category(ErrorCategory.Parsing)
20
+ * .message('Failed to parse field definition')
21
+ * .stackTrace(err.stack)
22
+ * .context({ fieldName: 'Account__c' })
23
+ * .send();
24
+ *
25
+ * // Build an error without sending
26
+ * const error = ErrorBuilder.create()
27
+ * .category(ErrorCategory.Validation)
28
+ * .message('Missing required field')
29
+ * .build();
30
+ * ```
31
+ */
32
+ export declare class ErrorBuilder {
33
+ private error;
34
+ /**
35
+ * Create a new ErrorBuilder instance
36
+ *
37
+ * @returns A new ErrorBuilder instance
38
+ */
39
+ static create(): ErrorBuilder;
40
+ /**
41
+ * Set the error category
42
+ *
43
+ * @param category - The category of the error (e.g., PARSING, VALIDATION, RENDERING)
44
+ * @returns This builder instance for chaining
45
+ */
46
+ category(category: ErrorCategory): this;
47
+ /**
48
+ * Set the error message
49
+ *
50
+ * @param message - A human-readable error message (short and descriptive)
51
+ * @returns This builder instance for chaining
52
+ */
53
+ message(message: string): this;
54
+ /**
55
+ * Set the stack trace
56
+ *
57
+ * @param stackTrace - The full stack trace or detailed error information
58
+ * @returns This builder instance for chaining
59
+ */
60
+ stackTrace(stackTrace: string | undefined): this;
61
+ /**
62
+ * Set additional context data
63
+ *
64
+ * @param context - Additional metadata about the error (e.g., field names, file paths)
65
+ * @returns This builder instance for chaining
66
+ */
67
+ context(context: Record<string, any>): this;
68
+ /**
69
+ * Build the error object
70
+ *
71
+ * Validates that all required fields are present and returns the complete error object.
72
+ *
73
+ * @returns The complete PluginError object
74
+ * @throws Error if required fields are missing
75
+ */
76
+ build(): PluginError;
77
+ /**
78
+ * Build and send the error to the framework via postMessage to parent.
79
+ *
80
+ */
81
+ send(): void;
82
+ /**
83
+ * Create an error from a caught exception
84
+ *
85
+ * Convenience method to quickly create an error from a caught exception.
86
+ *
87
+ * @param category - The error category
88
+ * @param error - The caught error or exception
89
+ * @param additionalContext - Optional additional context
90
+ * @returns A new ErrorBuilder instance with error details pre-populated
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * try {
95
+ * // ... some operation
96
+ * } catch (err) {
97
+ * ErrorBuilder.fromError(
98
+ * ErrorCategory.Parsing,
99
+ * err,
100
+ * { filePath: '/path/to/file.xml' }
101
+ * ).send();
102
+ * }
103
+ * ```
104
+ */
105
+ static fromError(category: ErrorCategory, error: unknown, additionalContext?: Record<string, any>): ErrorBuilder;
106
+ }
107
+ //# sourceMappingURL=ErrorBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBuilder.d.ts","sourceRoot":"","sources":["../../../../src/sdk/utils/errors/ErrorBuilder.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA4B;IAEzC;;;;OAIG;IACH,MAAM,CAAC,MAAM,IAAI,YAAY;IAI7B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAKvC;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK9B;;;;;OAKG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKhD;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAK3C;;;;;;;OAOG;IACH,KAAK,IAAI,WAAW;IAYpB;;;OAGG;IACH,IAAI,IAAI,IAAI;IA6BZ;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,SAAS,CACd,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,OAAO,EACd,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACtC,YAAY;CAgBhB"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import { WebviewMessageType } from '../../webviewMessageTypes.js';
8
+ /**
9
+ * Fluent builder for creating structured plugin errors
10
+ *
11
+ * This builder provides a type-safe and intuitive way for plugins to construct
12
+ * error objects that can be reported to the visualization framework.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Build and send an error
17
+ * ErrorBuilder.create()
18
+ * .category(ErrorCategory.Parsing)
19
+ * .message('Failed to parse field definition')
20
+ * .stackTrace(err.stack)
21
+ * .context({ fieldName: 'Account__c' })
22
+ * .send();
23
+ *
24
+ * // Build an error without sending
25
+ * const error = ErrorBuilder.create()
26
+ * .category(ErrorCategory.Validation)
27
+ * .message('Missing required field')
28
+ * .build();
29
+ * ```
30
+ */
31
+ export class ErrorBuilder {
32
+ constructor() {
33
+ this.error = {};
34
+ }
35
+ /**
36
+ * Create a new ErrorBuilder instance
37
+ *
38
+ * @returns A new ErrorBuilder instance
39
+ */
40
+ static create() {
41
+ return new ErrorBuilder();
42
+ }
43
+ /**
44
+ * Set the error category
45
+ *
46
+ * @param category - The category of the error (e.g., PARSING, VALIDATION, RENDERING)
47
+ * @returns This builder instance for chaining
48
+ */
49
+ category(category) {
50
+ this.error.category = category;
51
+ return this;
52
+ }
53
+ /**
54
+ * Set the error message
55
+ *
56
+ * @param message - A human-readable error message (short and descriptive)
57
+ * @returns This builder instance for chaining
58
+ */
59
+ message(message) {
60
+ this.error.message = message;
61
+ return this;
62
+ }
63
+ /**
64
+ * Set the stack trace
65
+ *
66
+ * @param stackTrace - The full stack trace or detailed error information
67
+ * @returns This builder instance for chaining
68
+ */
69
+ stackTrace(stackTrace) {
70
+ this.error.stackTrace = stackTrace;
71
+ return this;
72
+ }
73
+ /**
74
+ * Set additional context data
75
+ *
76
+ * @param context - Additional metadata about the error (e.g., field names, file paths)
77
+ * @returns This builder instance for chaining
78
+ */
79
+ context(context) {
80
+ this.error.context = { ...this.error.context, ...context };
81
+ return this;
82
+ }
83
+ /**
84
+ * Build the error object
85
+ *
86
+ * Validates that all required fields are present and returns the complete error object.
87
+ *
88
+ * @returns The complete PluginError object
89
+ * @throws Error if required fields are missing
90
+ */
91
+ build() {
92
+ // Validation
93
+ if (!this.error.category) {
94
+ throw new Error('ErrorBuilder: category is required');
95
+ }
96
+ if (!this.error.message) {
97
+ throw new Error('ErrorBuilder: message is required');
98
+ }
99
+ return this.error;
100
+ }
101
+ /**
102
+ * Build and send the error to the framework via postMessage to parent.
103
+ *
104
+ */
105
+ send() {
106
+ const error = this.build();
107
+ if (typeof window === 'undefined') {
108
+ console.error('[ErrorBuilder] Unable to send error (not in browser context):', error);
109
+ return;
110
+ }
111
+ const hostChannel = window.__hostChannel;
112
+ if (typeof hostChannel?.postMessage === 'function') {
113
+ hostChannel.postMessage({ type: WebviewMessageType.PLUGIN_ERROR, payload: error });
114
+ return;
115
+ }
116
+ if (window.parent && window.parent !== window) {
117
+ const targetOrigin = typeof window.location !== 'undefined' && window.location.origin
118
+ ? window.location.origin
119
+ : '';
120
+ window.parent.postMessage({ type: WebviewMessageType.PLUGIN_ERROR, payload: error }, targetOrigin);
121
+ return;
122
+ }
123
+ console.error('[ErrorBuilder] Unable to send error (no host channel):', error);
124
+ }
125
+ /**
126
+ * Create an error from a caught exception
127
+ *
128
+ * Convenience method to quickly create an error from a caught exception.
129
+ *
130
+ * @param category - The error category
131
+ * @param error - The caught error or exception
132
+ * @param additionalContext - Optional additional context
133
+ * @returns A new ErrorBuilder instance with error details pre-populated
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * try {
138
+ * // ... some operation
139
+ * } catch (err) {
140
+ * ErrorBuilder.fromError(
141
+ * ErrorCategory.Parsing,
142
+ * err,
143
+ * { filePath: '/path/to/file.xml' }
144
+ * ).send();
145
+ * }
146
+ * ```
147
+ */
148
+ static fromError(category, error, additionalContext) {
149
+ const builder = ErrorBuilder.create().category(category);
150
+ if (error instanceof Error) {
151
+ builder.message(error.message);
152
+ builder.stackTrace(error.stack);
153
+ }
154
+ else {
155
+ builder.message(String(error));
156
+ }
157
+ if (additionalContext) {
158
+ builder.context(additionalContext);
159
+ }
160
+ return builder;
161
+ }
162
+ }
163
+ //# sourceMappingURL=ErrorBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBuilder.js","sourceRoot":"","sources":["../../../../src/sdk/utils/errors/ErrorBuilder.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAIJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,YAAY;IAAzB;QACU,UAAK,GAAyB,EAAE,CAAC;IAuJ3C,CAAC;IArJC;;;;OAIG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,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ce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Setup global error handlers for uncaught errors and unhandled promise rejections
9
+ * Call once at React app start
10
+ */
11
+ export declare function setupErrorHandlers(): void;
12
+ //# sourceMappingURL=setupHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupHandlers.d.ts","sourceRoot":"","sources":["../../../../src/sdk/utils/errors/setupHandlers.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAUJ;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CA0BzC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Setup global error handlers for webview
9
+ * Call once at app start (e.g. first line in main.tsx) to capture uncaught errors and unhandled promise rejections
10
+ */
11
+ import { ErrorBuilder } from './ErrorBuilder.js';
12
+ import { ErrorCategory } from '../../contracts/types/PluginError.js';
13
+ /**
14
+ * Setup global error handlers for uncaught errors and unhandled promise rejections
15
+ * Call once at React app start
16
+ */
17
+ export function setupErrorHandlers() {
18
+ if (typeof window === 'undefined') {
19
+ return;
20
+ }
21
+ window.addEventListener('error', (event) => {
22
+ ErrorBuilder.create()
23
+ .category(ErrorCategory.Runtime)
24
+ .message(event.message || 'An error occurred')
25
+ .stackTrace(event.error?.stack)
26
+ .context({
27
+ lineno: event.lineno,
28
+ colno: event.colno,
29
+ filename: event.filename,
30
+ })
31
+ .send();
32
+ });
33
+ window.addEventListener('unhandledrejection', (event) => {
34
+ const reason = event.reason;
35
+ ErrorBuilder.create()
36
+ .category(ErrorCategory.Runtime)
37
+ .message(reason !== null ? String(reason) : 'Unhandled promise rejection')
38
+ .stackTrace(reason instanceof Error ? reason.stack : undefined)
39
+ .send();
40
+ });
41
+ }
42
+ //# sourceMappingURL=setupHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupHandlers.js","sourceRoot":"","sources":["../../../../src/sdk/utils/errors/setupHandlers.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAiB,EAAE,EAAE;QACrD,YAAY,CAAC,MAAM,EAAE;aAClB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;aAC/B,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,mBAAmB,CAAC;aAC7C,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;aAC9B,OAAO,CAAC;YACP,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;aACD,IAAI,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,KAA4B,EAAE,EAAE;QAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,YAAY,CAAC,MAAM,EAAE;aAClB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;aAC/B,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,6BAA6B,CAAC;aACzE,UAAU,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;aAC9D,IAAI,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Logger utility for plugins
9
+ *
10
+ * Simple console-based logger. Plugins can use this for basic logging,
11
+ * or use the platform logger provided through IPlatformContext.initialize().
12
+ **/
13
+ export declare class Logger {
14
+ private prefix;
15
+ constructor(prefix: string);
16
+ /**
17
+ * Log info message
18
+ */
19
+ info(message: string, ...args: any[]): void;
20
+ /**
21
+ * Log warning message
22
+ */
23
+ warn(message: string, ...args: any[]): void;
24
+ /**
25
+ * Log error message
26
+ */
27
+ error(message: string, ...args: any[]): void;
28
+ /**
29
+ * Log debug message
30
+ */
31
+ debug(message: string, ...args: any[]): void;
32
+ /**
33
+ * Log success message
34
+ */
35
+ success(message: string, ...args: any[]): void;
36
+ /**
37
+ * Create a child logger with extended prefix
38
+ */
39
+ child(suffix: string): Logger;
40
+ }
41
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;IAKI;AAEJ,qBAAa,MAAM;IACL,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAElC;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI5C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI5C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI9C;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAG9B"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Logger utility for plugins
9
+ *
10
+ * Simple console-based logger. Plugins can use this for basic logging,
11
+ * or use the platform logger provided through IPlatformContext.initialize().
12
+ **/
13
+ export class Logger {
14
+ constructor(prefix) {
15
+ this.prefix = prefix;
16
+ }
17
+ /**
18
+ * Log info message
19
+ */
20
+ info(message, ...args) {
21
+ console.log(`[${this.prefix}] ℹ️ ${message}`, ...args);
22
+ }
23
+ /**
24
+ * Log warning message
25
+ */
26
+ warn(message, ...args) {
27
+ console.warn(`[${this.prefix}] ⚠️ ${message}`, ...args);
28
+ }
29
+ /**
30
+ * Log error message
31
+ */
32
+ error(message, ...args) {
33
+ console.error(`[${this.prefix}] ❌ ${message}`, ...args);
34
+ }
35
+ /**
36
+ * Log debug message
37
+ */
38
+ debug(message, ...args) {
39
+ console.debug(`[${this.prefix}] 🔍 ${message}`, ...args);
40
+ }
41
+ /**
42
+ * Log success message
43
+ */
44
+ success(message, ...args) {
45
+ console.log(`[${this.prefix}] ✅ ${message}`, ...args);
46
+ }
47
+ /**
48
+ * Create a child logger with extended prefix
49
+ */
50
+ child(suffix) {
51
+ return new Logger(`${this.prefix}:${suffix}`);
52
+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}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Configuration for a single architecture rule (one "suite" in the test).
9
+ */
10
+ export interface SuiteConfig {
11
+ /** Human-readable description shown in violation messages */
12
+ description: string;
13
+ /** Package names that must not appear in import/require (e.g. 'fs', '@salesforce/foo') */
14
+ bannedPackages?: string[];
15
+ /** String patterns that must not appear in a line (e.g. '../object' for cross-plugin imports) */
16
+ bannedPatterns?: string[];
17
+ /** Glob patterns for paths to skip entirely (e.g. patterns for __tests__ or scripts dirs) */
18
+ excludePatterns: string[];
19
+ /** Exact path substrings for files to skip (temporary allowlist; prefer fixing the code) */
20
+ excludeFiles: string[];
21
+ /** Optional message shown after the violation list (e.g. how to fix) */
22
+ errorMessage?: string;
23
+ }
24
+ /**
25
+ * Full architecture config: a map of suite name -> SuiteConfig.
26
+ * Each suite is run independently and reported separately.
27
+ */
28
+ export interface ArchitectureConfig {
29
+ suites: Record<string, SuiteConfig>;
30
+ }
31
+ /**
32
+ * A single violation: one line in one file that broke a rule.
33
+ */
34
+ export interface Violation {
35
+ /** Path relative to package root */
36
+ file: string;
37
+ /** 1-based line number */
38
+ line: number;
39
+ /** Trimmed line content */
40
+ content: string;
41
+ /** Set when violation is from bannedPackages */
42
+ package?: string;
43
+ /** Set when violation is from bannedPatterns */
44
+ pattern?: string;
45
+ }
46
+ /**
47
+ * Returns true if the file path matches the glob pattern (full path match).
48
+ *
49
+ * The path is normalized to forward slashes. The pattern is converted via globToRegex
50
+ * and anchored at both ends (^...$), so the entire path must match.
51
+ *
52
+ * @param filePath - Path to check (relative or absolute; backslashes normalized)
53
+ * @param pattern - Glob pattern (e.g. pattern for __tests__ dir or one segment wildcard)
54
+ * @returns true if the path matches, false otherwise (or if regex construction fails)
55
+ */
56
+ export declare function matchPattern(filePath: string, pattern: string): boolean;
57
+ /**
58
+ * Returns true if the file should be excluded from architecture checks.
59
+ *
60
+ * A file is excluded if:
61
+ * 1. Its path matches any of the glob patterns in excludePatterns, or
62
+ * 2. Its path includes any of the strings in excludeFiles (substring match).
63
+ *
64
+ * Use excludePatterns for broad rules (e.g. all __tests__); use excludeFiles for
65
+ * a temporary allowlist of specific files until they are refactored.
66
+ *
67
+ * @param relativePath - File path relative to package root
68
+ * @param excludePatterns - Glob patterns (e.g. patterns that match __tests__ or scripts dirs)
69
+ * @param excludeFiles - Path substrings (e.g. 'core/PluginManager.ts')
70
+ */
71
+ export declare function isExcluded(relativePath: string, excludePatterns: string[], excludeFiles: string[]): boolean;
72
+ /**
73
+ * Detects if a line contains an import/require of one of the banned packages.
74
+ *
75
+ * Checks for (with single or double quotes):
76
+ * - ES static: import ... from 'pkg'
77
+ * - CommonJS: require('pkg')
78
+ * - Dynamic: import('pkg') or import('pkg' + ...)
79
+ *
80
+ * Does not parse the AST; uses string inclusion, so avoid banning substrings
81
+ * that could appear in comments or unrelated strings.
82
+ *
83
+ * @param line - One line of source code (will be trimmed)
84
+ * @param bannedPackages - Package names to forbid (e.g. ['fs', 'node:fs'])
85
+ * @returns The matched package name, or null if none
86
+ */
87
+ export declare function checkForBannedImport(line: string, bannedPackages: string[]): string | null;
88
+ /**
89
+ * Detects if a line contains a banned substring pattern (e.g. relative path to another plugin).
90
+ *
91
+ * The pattern is converted to a regex: . and * are escaped, ** becomes .*.
92
+ * So bannedPatterns like '../object' will match lines containing that substring.
93
+ * Used for rules that are not package names (e.g. no cross-plugin relative imports).
94
+ *
95
+ * @param line - One line of source code (will be trimmed)
96
+ * @param bannedPatterns - Literal patterns to forbid (e.g. ['../object', '../flow'])
97
+ * @returns The matched pattern, or null if none
98
+ */
99
+ export declare function checkForBannedPattern(line: string, bannedPatterns: string[]): string | null;
100
+ /**
101
+ * Finds all TypeScript/JavaScript source files under packageRoot.
102
+ *
103
+ * Includes .ts, .js, .tsx, .jsx. Excludes node_modules, dist, out, and build.
104
+ * Returns absolute file paths. Used as the input for validateSuite.
105
+ *
106
+ * @param packageRoot - Directory to scan (e.g. path to src)
107
+ * @returns Absolute paths of matching files
108
+ */
109
+ export declare function scanSourceFiles(packageRoot: string): Promise<string[]>;
110
+ /**
111
+ * Runs one suite against the given file list: applies exclusions, then checks
112
+ * each non-excluded file for banned imports and banned patterns.
113
+ *
114
+ * Files in suite.excludePatterns or suite.excludeFiles are skipped. For each
115
+ * remaining file, every line is checked against bannedPackages (if set) and
116
+ * bannedPatterns (if set). Each hit is recorded as a Violation.
117
+ *
118
+ * @param packageRoot - Root used to compute relative paths in violations
119
+ * @param sourceFiles - Absolute paths (e.g. from scanSourceFiles)
120
+ * @param suiteName - Name of the suite (for reference)
121
+ * @param suite - Rule config (banned lists, exclusions)
122
+ * @returns List of violations for this suite
123
+ */
124
+ export declare function validateSuite(packageRoot: string, sourceFiles: string[], suiteName: string, suite: SuiteConfig): Violation[];
125
+ /**
126
+ * Runs all suites in config: scans packageRoot once, then runs each suite
127
+ * and collects violations per suite name.
128
+ *
129
+ * @param packageRoot - Root directory to scan and relativize paths from
130
+ * @param config - Full architecture config (map of suite name -> SuiteConfig)
131
+ * @returns Map of suite name -> list of violations (empty array if none)
132
+ */
133
+ export declare function validateArchitecture(packageRoot: string, config: ArchitectureConfig): Promise<Record<string, Violation[]>>;
134
+ /**
135
+ * Formats a list of violations into a single string suitable for throwing
136
+ * as an Error message or logging. Includes suite description, file:line,
137
+ * line content, and package/pattern that was violated; appends suite.errorMessage
138
+ * and a hint about excludeFiles.
139
+ *
140
+ * @param suiteName - Name of the suite that failed
141
+ * @param suite - Suite config (description, errorMessage)
142
+ * @param violations - List of violations from validateSuite
143
+ * @returns Multi-line string (no trailing newline)
144
+ */
145
+ export declare function reportViolations(suiteName: string, suite: SuiteConfig, violations: Violation[]): string;
146
+ //# sourceMappingURL=architecture-test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architecture-test-utils.d.ts","sourceRoot":"","sources":["../../../../src/sdk/utils/test-helpers/architecture-test-utils.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAoBJ;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iGAAiG;IACjG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,6FAA6F;IAC7F,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,4FAA4F;IAC5F,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiCD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CASvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAQT;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAA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