@salesforce/metadata-enrichment 0.0.3 → 0.0.5
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/lib/enrichment/constants/api.d.ts +5 -1
- package/lib/enrichment/constants/api.js +10 -1
- package/lib/enrichment/constants/api.js.map +1 -1
- package/lib/enrichment/constants/component.d.ts +9 -0
- package/lib/enrichment/constants/component.js +28 -0
- package/lib/enrichment/constants/component.js.map +1 -0
- package/lib/enrichment/constants/index.d.ts +3 -2
- package/lib/enrichment/constants/index.js +3 -2
- package/lib/enrichment/constants/index.js.map +1 -1
- package/lib/enrichment/constants/mimeTypes.d.ts +1 -1
- package/lib/enrichment/constants/mimeTypes.js +1 -1
- package/lib/enrichment/constants/mimeTypes.js.map +1 -1
- package/lib/enrichment/enrichmentHandler.d.ts +4 -2
- package/lib/enrichment/enrichmentHandler.js +20 -18
- package/lib/enrichment/enrichmentHandler.js.map +1 -1
- package/lib/enrichment/enrichmentMetrics.d.ts +6 -0
- package/lib/enrichment/enrichmentMetrics.js +9 -0
- package/lib/enrichment/enrichmentMetrics.js.map +1 -1
- package/lib/enrichment/enrichmentRecords.d.ts +16 -0
- package/lib/enrichment/enrichmentRecords.js +117 -0
- package/lib/enrichment/enrichmentRecords.js.map +1 -0
- package/lib/enrichment/index.d.ts +5 -3
- package/lib/enrichment/index.js +3 -1
- package/lib/enrichment/index.js.map +1 -1
- package/lib/enrichment/types/index.d.ts +1 -1
- package/lib/enrichment/types/requestTypes.d.ts +1 -1
- package/lib/enrichment/types/responseTypes.d.ts +2 -1
- package/lib/enrichment/validators/index.d.ts +1 -0
- package/lib/enrichment/validators/index.js +17 -0
- package/lib/enrichment/validators/index.js.map +1 -0
- package/lib/enrichment/validators/lwcComponentValidator.d.ts +8 -0
- package/lib/enrichment/validators/lwcComponentValidator.js +26 -0
- package/lib/enrichment/validators/lwcComponentValidator.js.map +1 -0
- package/lib/files/fileProcessor.d.ts +15 -1
- package/lib/files/fileProcessor.js +26 -6
- package/lib/files/fileProcessor.js.map +1 -1
- package/lib/files/index.d.ts +1 -0
- package/lib/files/index.js +1 -0
- package/lib/files/index.js.map +1 -1
- package/lib/files/lwcProcessor.d.ts +10 -7
- package/lib/files/lwcProcessor.js +26 -22
- package/lib/files/lwcProcessor.js.map +1 -1
- package/lib/files/sourceComponentProcessor.d.ts +24 -0
- package/lib/files/sourceComponentProcessor.js +136 -0
- package/lib/files/sourceComponentProcessor.js.map +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/messages/errors.md +31 -0
- package/package.json +1 -1
- package/messages/enrichment.md +0 -15
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const API_ENDPOINT_ENRICHMENT = "/services/data/v66.0/metadata-intelligence/enrichments/on-demand";
|
|
2
2
|
export declare const ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER = "X-Chatter-Entity-Encoding";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const METADATA_TYPE_GENERIC = "Generic";
|
|
4
|
+
export declare const METADATA_TYPE_LWC = "Lwc";
|
|
5
|
+
export declare const METADATA_TYPE_APEX_CLASS = "ApexClass";
|
|
6
|
+
export declare const METADATA_TYPE_FLEXIPAGE = "Flexipage";
|
|
7
|
+
export declare const MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE: Record<string, string>;
|
|
@@ -15,5 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export const API_ENDPOINT_ENRICHMENT = '/services/data/v66.0/metadata-intelligence/enrichments/on-demand';
|
|
17
17
|
export const ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER = 'X-Chatter-Entity-Encoding';
|
|
18
|
-
export const
|
|
18
|
+
export const METADATA_TYPE_GENERIC = 'Generic';
|
|
19
|
+
export const METADATA_TYPE_LWC = 'Lwc';
|
|
20
|
+
export const METADATA_TYPE_APEX_CLASS = 'ApexClass';
|
|
21
|
+
export const METADATA_TYPE_FLEXIPAGE = 'Flexipage';
|
|
22
|
+
export const MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE = {
|
|
23
|
+
ApexClass: METADATA_TYPE_APEX_CLASS,
|
|
24
|
+
Flexipage: METADATA_TYPE_FLEXIPAGE,
|
|
25
|
+
LightningComponentBundle: METADATA_TYPE_LWC,
|
|
26
|
+
Generic: METADATA_TYPE_GENERIC,
|
|
27
|
+
};
|
|
19
28
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/enrichment/constants/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kEAAkE,CAAC;AAE1G,MAAM,CAAC,MAAM,yCAAyC,GAAG,2BAA2B,CAAC;AAErF,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/enrichment/constants/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kEAAkE,CAAC;AAE1G,MAAM,CAAC,MAAM,yCAAyC,GAAG,2BAA2B,CAAC;AAErF,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC;AACnD,MAAM,CAAC,MAAM,0CAA0C,GAA2B;IAC9E,SAAS,EAAE,wBAAwB;IACnC,SAAS,EAAE,uBAAuB;IAClC,wBAAwB,EAAE,iBAAiB;IAC3C,OAAO,EAAE,qBAAqB;CACjC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
export declare const LWC_METADATA_TYPE_NAME = "LightningComponentBundle";
|
|
3
|
+
export declare const SUPPORTED_COMPONENT_TYPES: ReadonlySet<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Maps component type names to a validator function that determines if the component
|
|
6
|
+
* meets the requirements for enrichment processing.
|
|
7
|
+
* Returns true if the component is valid, false if it should be skipped.
|
|
8
|
+
*/
|
|
9
|
+
export declare const COMPONENT_TYPE_VALIDATORS: ReadonlyMap<string, (component: SourceComponent) => boolean>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { LwcComponentValidator } from '../validators/index.js';
|
|
17
|
+
export const LWC_METADATA_TYPE_NAME = 'LightningComponentBundle';
|
|
18
|
+
export const SUPPORTED_COMPONENT_TYPES = new Set([LWC_METADATA_TYPE_NAME]);
|
|
19
|
+
/**
|
|
20
|
+
* Maps component type names to a validator function that determines if the component
|
|
21
|
+
* meets the requirements for enrichment processing.
|
|
22
|
+
* Returns true if the component is valid, false if it should be skipped.
|
|
23
|
+
*/
|
|
24
|
+
export const COMPONENT_TYPE_VALIDATORS = new Map([
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
26
|
+
[LWC_METADATA_TYPE_NAME, LwcComponentValidator.validate],
|
|
27
|
+
]);
|
|
28
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/enrichment/constants/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEjE,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAiE,IAAI,GAAG,CAAC;IAC7G,6DAA6D;IAC7D,CAAC,sBAAsB,EAAE,qBAAqB,CAAC,QAAQ,CAAC;CACzD,CAAC,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER,
|
|
2
|
-
export {
|
|
1
|
+
export { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER, MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE, METADATA_TYPE_GENERIC, METADATA_TYPE_LWC, } from './api.js';
|
|
2
|
+
export { COMPONENT_TYPE_VALIDATORS, LWC_METADATA_TYPE_NAME, SUPPORTED_COMPONENT_TYPES } from './component.js';
|
|
3
|
+
export { SUPPORTED_MIME_TYPES } from './mimeTypes.js';
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER,
|
|
17
|
-
export {
|
|
16
|
+
export { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER, MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE, METADATA_TYPE_GENERIC, METADATA_TYPE_LWC, } from './api.js';
|
|
17
|
+
export { COMPONENT_TYPE_VALIDATORS, LWC_METADATA_TYPE_NAME, SUPPORTED_COMPONENT_TYPES } from './component.js';
|
|
18
|
+
export { SUPPORTED_MIME_TYPES } from './mimeTypes.js';
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enrichment/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,uBAAuB,EACvB,yCAAyC,EACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enrichment/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,uBAAuB,EACvB,yCAAyC,EACzC,0CAA0C,EAC1C,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const SUPPORTED_MIME_TYPES: Record<string, string>;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const SUPPORTED_MIME_TYPES = {
|
|
17
17
|
'.js': 'application/javascript',
|
|
18
18
|
'.html': 'text/html',
|
|
19
19
|
'.css': 'text/css',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mimeTypes.js","sourceRoot":"","sources":["../../../src/enrichment/constants/mimeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"mimeTypes.js","sourceRoot":"","sources":["../../../src/enrichment/constants/mimeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,KAAK,EAAE,wBAAwB;IAC/B,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,eAAe;CACxB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Connection } from '@salesforce/core';
|
|
2
2
|
import type { MetadataType, SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
3
|
-
import type { EnrichmentRequestBody,
|
|
3
|
+
import type { EnrichmentRequestBody, EnrichMetadataResponse } from './types/index.js';
|
|
4
4
|
export declare enum EnrichmentStatus {
|
|
5
5
|
NOT_PROCESSED = "NOT_PROCESSED",
|
|
6
6
|
SUCCESS = "SUCCESS",
|
|
@@ -11,7 +11,7 @@ export type EnrichmentRequestRecord = {
|
|
|
11
11
|
componentName: string;
|
|
12
12
|
componentType: MetadataType;
|
|
13
13
|
requestBody: EnrichmentRequestBody | null;
|
|
14
|
-
response:
|
|
14
|
+
response: EnrichMetadataResponse | null;
|
|
15
15
|
message: string | null;
|
|
16
16
|
status: EnrichmentStatus;
|
|
17
17
|
};
|
|
@@ -19,6 +19,8 @@ export declare function getMimeTypeFromExtension(filePath: string): string;
|
|
|
19
19
|
export declare class EnrichmentHandler {
|
|
20
20
|
/**
|
|
21
21
|
* Processes and sends metadata enrichment requests for the input source components in the project.
|
|
22
|
+
* Automatically determines the metadata type for enrichment requests based on the source component.
|
|
23
|
+
* Supported component types are defined in SUPPORTED_COMPONENT_TYPES. All other component types are skipped.
|
|
22
24
|
*
|
|
23
25
|
* @param connection Salesforce connection instance
|
|
24
26
|
* @param sourceComponents Array of source components to enrich
|
|
@@ -17,9 +17,9 @@ import { basename, extname } from 'node:path';
|
|
|
17
17
|
import { SfError } from '@salesforce/core';
|
|
18
18
|
import { Messages } from '@salesforce/core/messages';
|
|
19
19
|
import { FileProcessor } from '../files/index.js';
|
|
20
|
-
import { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER,
|
|
20
|
+
import { API_ENDPOINT_ENRICHMENT, ENRICHMENT_REQUEST_ENTITY_ENCODING_HEADER, SUPPORTED_MIME_TYPES, MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE, METADATA_TYPE_GENERIC, SUPPORTED_COMPONENT_TYPES, } from './constants/index.js';
|
|
21
21
|
Messages.importMessagesDirectory(import.meta.dirname);
|
|
22
|
-
const messages = Messages.loadMessages('@salesforce/metadata-enrichment', '
|
|
22
|
+
const messages = Messages.loadMessages('@salesforce/metadata-enrichment', 'errors');
|
|
23
23
|
export var EnrichmentStatus;
|
|
24
24
|
(function (EnrichmentStatus) {
|
|
25
25
|
EnrichmentStatus["NOT_PROCESSED"] = "NOT_PROCESSED";
|
|
@@ -29,32 +29,33 @@ export var EnrichmentStatus;
|
|
|
29
29
|
})(EnrichmentStatus || (EnrichmentStatus = {}));
|
|
30
30
|
export function getMimeTypeFromExtension(filePath) {
|
|
31
31
|
const ext = extname(filePath).toLowerCase();
|
|
32
|
-
return
|
|
32
|
+
return SUPPORTED_MIME_TYPES[ext] || 'application/octet-stream';
|
|
33
33
|
}
|
|
34
34
|
export class EnrichmentHandler {
|
|
35
35
|
/**
|
|
36
36
|
* Processes and sends metadata enrichment requests for the input source components in the project.
|
|
37
|
+
* Automatically determines the metadata type for enrichment requests based on the source component.
|
|
38
|
+
* Supported component types are defined in SUPPORTED_COMPONENT_TYPES. All other component types are skipped.
|
|
37
39
|
*
|
|
38
40
|
* @param connection Salesforce connection instance
|
|
39
41
|
* @param sourceComponents Array of source components to enrich
|
|
40
42
|
* @returns Promise resolving to enrichment request records
|
|
41
43
|
*/
|
|
42
44
|
static async enrich(connection, sourceComponents) {
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const nonLwcComponents = [];
|
|
45
|
+
const supportedComponents = [];
|
|
46
|
+
const unsupportedComponents = [];
|
|
46
47
|
for (const component of sourceComponents) {
|
|
47
|
-
if (component.type?.name
|
|
48
|
-
|
|
48
|
+
if (SUPPORTED_COMPONENT_TYPES.has(component.type?.name ?? '')) {
|
|
49
|
+
supportedComponents.push(component);
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
|
-
|
|
52
|
+
unsupportedComponents.push(component);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const enrichmentResults = await EnrichmentHandler.sendEnrichmentRequests(connection,
|
|
57
|
-
return [...enrichmentResults, ...
|
|
55
|
+
const supportedRecords = await EnrichmentHandler.createEnrichmentRequestRecords(supportedComponents);
|
|
56
|
+
const unsupportedRecords = await EnrichmentHandler.createEnrichmentRequestRecords(unsupportedComponents, EnrichmentStatus.SKIPPED, messages.getMessage('errors.unsupported.type.default'));
|
|
57
|
+
const enrichmentResults = await EnrichmentHandler.sendEnrichmentRequests(connection, supportedRecords);
|
|
58
|
+
return [...enrichmentResults, ...unsupportedRecords];
|
|
58
59
|
}
|
|
59
60
|
static async createEnrichmentRequestRecord(component, status, message) {
|
|
60
61
|
const componentName = component.fullName ?? component.name;
|
|
@@ -65,12 +66,13 @@ export class EnrichmentHandler {
|
|
|
65
66
|
componentType: component.type ?? null,
|
|
66
67
|
requestBody: null,
|
|
67
68
|
response: null,
|
|
68
|
-
message: messages.getMessage('
|
|
69
|
+
message: messages.getMessage('errors.file.read.failed', [componentName]),
|
|
69
70
|
status: EnrichmentStatus.SKIPPED,
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
const contentBundle = EnrichmentHandler.createContentBundle(componentName, files);
|
|
73
|
-
const
|
|
74
|
+
const metadataType = MAP_SOURCE_COMPONENT_TYPE_TO_METADATA_TYPE[component.type?.name ?? ''] ?? METADATA_TYPE_GENERIC;
|
|
75
|
+
const requestBody = EnrichmentHandler.createEnrichmentRequestBody(contentBundle, metadataType);
|
|
74
76
|
return {
|
|
75
77
|
componentName,
|
|
76
78
|
componentType: component.type ?? null,
|
|
@@ -110,10 +112,10 @@ export class EnrichmentHandler {
|
|
|
110
112
|
files: contentBundleFiles,
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
|
-
static createEnrichmentRequestBody(contentBundle) {
|
|
115
|
+
static createEnrichmentRequestBody(contentBundle, metadataType = METADATA_TYPE_GENERIC) {
|
|
114
116
|
return {
|
|
115
117
|
contentBundles: [contentBundle],
|
|
116
|
-
metadataType
|
|
118
|
+
metadataType,
|
|
117
119
|
maxTokens: 50,
|
|
118
120
|
};
|
|
119
121
|
}
|
|
@@ -132,7 +134,7 @@ export class EnrichmentHandler {
|
|
|
132
134
|
}
|
|
133
135
|
catch (error) {
|
|
134
136
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
135
|
-
throw new SfError(messages.getMessage('
|
|
137
|
+
throw new SfError(messages.getMessage('errors.enrichment.request', [record.componentName, errorMessage]));
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
static async sendEnrichmentRequests(connection, records) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrichmentHandler.js","sourceRoot":"","sources":["../../src/enrichment/enrichmentHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACL,uBAAuB,EACvB,yCAAyC,EACzC,
|
|
1
|
+
{"version":3,"file":"enrichmentHandler.js","sourceRoot":"","sources":["../../src/enrichment/enrichmentHandler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;IAEO,MAAM,CAAC,KAAK,CAAC,sBAAsB,CACzC,UAAsB,EACtB,OAAkC;QAElC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAE7G,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAEjE,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC1C,+EAA+E;YAC/E,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,OAAO,MAAM,CAAC,KAAK,CAAC;YACtB,CAAC;YACD,+DAA+D;YAC/D,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACpG,OAAO;gBACL,GAAG,OAAO,CAAC,KAAK,CAAC;gBACjB,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,YAAY;gBACrB,MAAM,EAAE,gBAAgB,CAAC,IAAI;aAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ComponentEnrichmentStatus } from '../common/types.js';
|
|
2
2
|
import type { EnrichmentRequestRecord } from './enrichmentHandler.js';
|
|
3
|
+
/**
|
|
4
|
+
* A metrics data object for storing the final enrichment results.
|
|
5
|
+
* This includes components that were successfully enriched, failed, or skipped.
|
|
6
|
+
* This metrics object can be used to generate the final console or json output.
|
|
7
|
+
*/
|
|
3
8
|
export declare class EnrichmentMetrics {
|
|
4
9
|
success: {
|
|
5
10
|
count: number;
|
|
@@ -14,6 +19,7 @@ export declare class EnrichmentMetrics {
|
|
|
14
19
|
components: ComponentEnrichmentStatus[];
|
|
15
20
|
};
|
|
16
21
|
total: number;
|
|
22
|
+
requestId?: string;
|
|
17
23
|
constructor();
|
|
18
24
|
static createEnrichmentMetrics(enrichmentResults: EnrichmentRequestRecord[]): EnrichmentMetrics;
|
|
19
25
|
addSuccessComponent(component: ComponentEnrichmentStatus): void;
|
|
@@ -14,11 +14,17 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { EnrichmentStatus } from './enrichmentHandler.js';
|
|
17
|
+
/**
|
|
18
|
+
* A metrics data object for storing the final enrichment results.
|
|
19
|
+
* This includes components that were successfully enriched, failed, or skipped.
|
|
20
|
+
* This metrics object can be used to generate the final console or json output.
|
|
21
|
+
*/
|
|
17
22
|
export class EnrichmentMetrics {
|
|
18
23
|
success;
|
|
19
24
|
fail;
|
|
20
25
|
skipped;
|
|
21
26
|
total;
|
|
27
|
+
requestId;
|
|
22
28
|
constructor() {
|
|
23
29
|
this.success = {
|
|
24
30
|
count: 0,
|
|
@@ -37,6 +43,9 @@ export class EnrichmentMetrics {
|
|
|
37
43
|
static createEnrichmentMetrics(enrichmentResults) {
|
|
38
44
|
const metrics = new EnrichmentMetrics();
|
|
39
45
|
for (const record of enrichmentResults) {
|
|
46
|
+
if (record.response?.metadata?.requestId) {
|
|
47
|
+
metrics.requestId = record.response.metadata.requestId;
|
|
48
|
+
}
|
|
40
49
|
const componentName = record.componentName;
|
|
41
50
|
let typeName = '';
|
|
42
51
|
if (record.componentType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrichmentMetrics.js","sourceRoot":"","sources":["../../src/enrichment/enrichmentMetrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,OAAO,iBAAiB;IACrB,OAAO,CAGZ;IACK,IAAI,CAGT;IACK,OAAO,CAGZ;IACK,KAAK,CAAS;
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,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
import type { MetadataTypeAndName } from '../common/types.js';
|
|
3
|
+
import type { EnrichmentRequestRecord } from './enrichmentHandler.js';
|
|
4
|
+
import { EnrichmentStatus } from './enrichmentHandler.js';
|
|
5
|
+
/**
|
|
6
|
+
* An all-in-one data object used for tracking the enrichment process storing the components,
|
|
7
|
+
* their enrichment request and responses, and their enrichment results.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EnrichmentRecords {
|
|
10
|
+
readonly recordSet: Set<EnrichmentRequestRecord>;
|
|
11
|
+
constructor(projectSourceComponents: SourceComponent[]);
|
|
12
|
+
addSkippedComponents(componentsToSkip: Set<MetadataTypeAndName>): void;
|
|
13
|
+
updateWithStatus(componentsToUpdate: Set<MetadataTypeAndName>, status: EnrichmentStatus): void;
|
|
14
|
+
updateWithResults(results: EnrichmentRequestRecord[]): void;
|
|
15
|
+
generateSkipReasons(componentsToSkip: Set<MetadataTypeAndName>, projectSourceComponents: SourceComponent[]): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Messages } from '@salesforce/core/messages';
|
|
2
|
+
import { EnrichmentStatus } from './enrichmentHandler.js';
|
|
3
|
+
import { COMPONENT_TYPE_VALIDATORS, SUPPORTED_COMPONENT_TYPES } from './constants/component.js';
|
|
4
|
+
Messages.importMessagesDirectory(import.meta.dirname);
|
|
5
|
+
const messages = Messages.loadMessages('@salesforce/metadata-enrichment', 'errors');
|
|
6
|
+
const DEFAULT_REQUEST_BODY = {
|
|
7
|
+
contentBundles: [],
|
|
8
|
+
metadataType: 'Generic',
|
|
9
|
+
maxTokens: 50,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An all-in-one data object used for tracking the enrichment process storing the components,
|
|
13
|
+
* their enrichment request and responses, and their enrichment results.
|
|
14
|
+
*/
|
|
15
|
+
export class EnrichmentRecords {
|
|
16
|
+
recordSet;
|
|
17
|
+
constructor(projectSourceComponents) {
|
|
18
|
+
this.recordSet = new Set();
|
|
19
|
+
// Create initial records for all provided source components with default request body
|
|
20
|
+
for (const component of projectSourceComponents) {
|
|
21
|
+
const componentName = component.fullName ?? component.name;
|
|
22
|
+
if (componentName && component.type) {
|
|
23
|
+
this.recordSet.add({
|
|
24
|
+
componentName,
|
|
25
|
+
componentType: component.type,
|
|
26
|
+
requestBody: DEFAULT_REQUEST_BODY,
|
|
27
|
+
response: null,
|
|
28
|
+
message: null,
|
|
29
|
+
status: EnrichmentStatus.NOT_PROCESSED,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
addSkippedComponents(componentsToSkip) {
|
|
35
|
+
for (const component of componentsToSkip) {
|
|
36
|
+
if (!component.componentName)
|
|
37
|
+
continue;
|
|
38
|
+
// Check if record already exists
|
|
39
|
+
const existingRecord = Array.from(this.recordSet).find((r) => r.componentName === component.componentName);
|
|
40
|
+
if (existingRecord)
|
|
41
|
+
continue;
|
|
42
|
+
// Create a new record for the skipped component
|
|
43
|
+
this.recordSet.add({
|
|
44
|
+
componentName: component.componentName,
|
|
45
|
+
componentType: { name: component.typeName },
|
|
46
|
+
requestBody: DEFAULT_REQUEST_BODY,
|
|
47
|
+
response: null,
|
|
48
|
+
message: null,
|
|
49
|
+
status: EnrichmentStatus.SKIPPED,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
updateWithStatus(componentsToUpdate, status) {
|
|
54
|
+
const componentsToUpdateMap = new Map();
|
|
55
|
+
for (const component of componentsToUpdate) {
|
|
56
|
+
if (component.componentName) {
|
|
57
|
+
componentsToUpdateMap.set(component.componentName, component);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const record of this.recordSet) {
|
|
61
|
+
const componentToUpdate = componentsToUpdateMap.get(record.componentName);
|
|
62
|
+
if (componentToUpdate) {
|
|
63
|
+
record.status = status;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
updateWithResults(results) {
|
|
68
|
+
const resultsMap = new Map(results.map((r) => [r.componentName, r]));
|
|
69
|
+
for (const record of this.recordSet) {
|
|
70
|
+
const processedResult = resultsMap.get(record.componentName);
|
|
71
|
+
if (processedResult) {
|
|
72
|
+
record.requestBody = processedResult.requestBody;
|
|
73
|
+
record.response = processedResult.response;
|
|
74
|
+
if (record.status !== EnrichmentStatus.SKIPPED) {
|
|
75
|
+
record.status = processedResult.response ? EnrichmentStatus.SUCCESS : EnrichmentStatus.FAIL;
|
|
76
|
+
}
|
|
77
|
+
record.message = processedResult.message;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
generateSkipReasons(componentsToSkip, projectSourceComponents) {
|
|
82
|
+
const sourceComponentMap = new Map();
|
|
83
|
+
for (const component of projectSourceComponents) {
|
|
84
|
+
const componentName = component.fullName ?? component.name;
|
|
85
|
+
if (componentName) {
|
|
86
|
+
sourceComponentMap.set(componentName, component);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const skip of componentsToSkip) {
|
|
90
|
+
if (!skip.componentName)
|
|
91
|
+
continue;
|
|
92
|
+
const record = Array.from(this.recordSet).find((r) => r.componentName === skip.componentName);
|
|
93
|
+
if (!record || record.status !== EnrichmentStatus.SKIPPED || record.message)
|
|
94
|
+
continue;
|
|
95
|
+
const sourceComponent = sourceComponentMap.get(skip.componentName);
|
|
96
|
+
const componentTypeName = sourceComponent?.type?.name ?? '';
|
|
97
|
+
let message;
|
|
98
|
+
if (!sourceComponent) {
|
|
99
|
+
message = messages.getMessage('errors.component.not.found');
|
|
100
|
+
}
|
|
101
|
+
else if (!SUPPORTED_COMPONENT_TYPES.has(componentTypeName)) {
|
|
102
|
+
message = messages.getMessage('errors.unsupported.type', [componentTypeName]);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const validator = COMPONENT_TYPE_VALIDATORS.get(componentTypeName);
|
|
106
|
+
if (validator && !validator(sourceComponent)) {
|
|
107
|
+
message = messages.getMessage('errors.component.configuration.not.found');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
message = messages.getMessage('errors.unknown');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
record.message = message;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=enrichmentRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichmentRecords.js","sourceRoot":"","sources":["../../src/enrichment/enrichmentRecords.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAEhG,QAAQ,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtD,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,iCAAiC,EAAE,QAAQ,CAAC,CAAC;AAEpF,MAAM,oBAAoB,GAA2C;IACjE,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,SAAS;IACvB,SAAS,EAAE,EAAE;CAChB,CAAA;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACZ,SAAS,CAA+B;IAExD,YAAmB,uBAA0C;QAC3D,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAEpD,sFAAsF;QACtF,KAAK,MAAM,SAAS,IAAI,uBAAuB,EAAE,CAAC;YAChD,MAAM,aAAa,GAAG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,CAAC;oBAC7C,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,0CAA0C,CAAC,CAAC;gBAC5E,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;YAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export type { EnrichmentRequestRecord } from './enrichmentHandler.js';
|
|
2
|
+
export type { ContentBundleFile, ContentBundle, EnrichmentRequestBody, EnrichmentMetadata, EnrichmentResult, EnrichMetadataResponse, } from './types/index.js';
|
|
3
|
+
export { API_ENDPOINT_ENRICHMENT, SUPPORTED_MIME_TYPES } from './constants/index.js';
|
|
1
4
|
export { getMimeTypeFromExtension, EnrichmentHandler, EnrichmentStatus } from './enrichmentHandler.js';
|
|
2
|
-
export {
|
|
5
|
+
export { EnrichmentRecords } from './enrichmentRecords.js';
|
|
3
6
|
export { EnrichmentMetrics } from './enrichmentMetrics.js';
|
|
4
|
-
export
|
|
5
|
-
export type { ContentBundleFile, ContentBundle, EnrichmentRequestBody, EnrichmentMetadata, EnrichmentResult, EnrichMetadataResult, } from './types/index.js';
|
|
7
|
+
export { LwcComponentValidator } from './validators/index.js';
|
package/lib/enrichment/index.js
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { API_ENDPOINT_ENRICHMENT, SUPPORTED_MIME_TYPES } from './constants/index.js';
|
|
16
17
|
export { getMimeTypeFromExtension, EnrichmentHandler, EnrichmentStatus } from './enrichmentHandler.js';
|
|
17
|
-
export {
|
|
18
|
+
export { EnrichmentRecords } from './enrichmentRecords.js';
|
|
18
19
|
export { EnrichmentMetrics } from './enrichmentMetrics.js';
|
|
20
|
+
export { LwcComponentValidator } from './validators/index.js';
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enrichment/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enrichment/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAErF,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { ContentBundleFile, ContentBundle, EnrichmentRequestBody, } from './requestTypes.js';
|
|
2
|
-
export type { EnrichmentMetadata, EnrichmentResult,
|
|
2
|
+
export type { EnrichmentMetadata, EnrichmentResult, EnrichMetadataResponse, } from './responseTypes.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type EnrichmentMetadata = {
|
|
2
2
|
durationMs: number;
|
|
3
3
|
failureCount: number;
|
|
4
|
+
requestId?: string;
|
|
4
5
|
successCount: number;
|
|
5
6
|
timestamp: string;
|
|
6
7
|
};
|
|
@@ -12,7 +13,7 @@ export type EnrichmentResult = {
|
|
|
12
13
|
description: string;
|
|
13
14
|
descriptionScore: number;
|
|
14
15
|
};
|
|
15
|
-
export type
|
|
16
|
+
export type EnrichMetadataResponse = {
|
|
16
17
|
metadata: EnrichmentMetadata;
|
|
17
18
|
results: EnrichmentResult[];
|
|
18
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LwcComponentValidator } from './lwcComponentValidator.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export { LwcComponentValidator } from './lwcComponentValidator.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enrichment/validators/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
/**
|
|
3
|
+
* Validator for LWC - "LightningComponentBundle" source components processing
|
|
4
|
+
* Validates that a corresponding metadata XML file exists
|
|
5
|
+
*/
|
|
6
|
+
export declare class LwcComponentValidator {
|
|
7
|
+
static validate(this: void, component: SourceComponent): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Validator for LWC - "LightningComponentBundle" source components processing
|
|
18
|
+
* Validates that a corresponding metadata XML file exists
|
|
19
|
+
*/
|
|
20
|
+
export class LwcComponentValidator {
|
|
21
|
+
static validate(component) {
|
|
22
|
+
const hasMetadataFile = (component.xml !== undefined);
|
|
23
|
+
return hasMetadataFile;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=lwcComponentValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lwcComponentValidator.js","sourceRoot":"","sources":["../../../src/enrichment/validators/lwcComponentValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACzB,MAAM,CAAC,QAAQ,CAAa,SAA0B;QAC3D,MAAM,eAAe,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;QACtD,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -6,8 +6,22 @@ export type FileReadResult = {
|
|
|
6
6
|
fileContents: string;
|
|
7
7
|
mimeType: string;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Contract for all component-type-specific processors.
|
|
11
|
+
* To add support for a new component type, implement this interface and register
|
|
12
|
+
* the processor in COMPONENT_TYPE_PROCESSOR_MAP below.
|
|
13
|
+
*/
|
|
14
|
+
export type ComponentTypeProcessor = {
|
|
15
|
+
updateMetadata(components: SourceComponent[], enrichmentRecords: Set<EnrichmentRequestRecord>): Promise<Set<EnrichmentRequestRecord>>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A main entryway for processing file operations for metadata files.
|
|
19
|
+
* This includes reading and writing component files.
|
|
20
|
+
* Supported component types are defined in SUPPORTED_COMPONENT_TYPES and each maps
|
|
21
|
+
* to a dedicated processor in COMPONENT_TYPE_PROCESSOR_MAP.
|
|
22
|
+
*/
|
|
9
23
|
export declare class FileProcessor {
|
|
10
|
-
static
|
|
24
|
+
static updateMetadata(componentsToProcess: SourceComponent[], enrichmentRecords: Set<EnrichmentRequestRecord>): Promise<Set<EnrichmentRequestRecord>>;
|
|
11
25
|
static readComponentFile(componentName: string, filePath: string): Promise<FileReadResult | null>;
|
|
12
26
|
static readComponentFiles(component: SourceComponent): Promise<FileReadResult[]>;
|
|
13
27
|
private static groupComponentsByType;
|
|
@@ -15,16 +15,36 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { readFile } from 'node:fs/promises';
|
|
17
17
|
import { getMimeTypeFromExtension } from '../enrichment/enrichmentHandler.js';
|
|
18
|
+
import { LWC_METADATA_TYPE_NAME, SUPPORTED_COMPONENT_TYPES } from '../enrichment/constants/component.js';
|
|
18
19
|
import { LwcProcessor } from './lwcProcessor.js';
|
|
20
|
+
/**
|
|
21
|
+
* Maps each supported component type to its corresponding processor.
|
|
22
|
+
* Add new entries here when introducing support for additional component types.
|
|
23
|
+
*/
|
|
24
|
+
const COMPONENT_TYPE_PROCESSOR_MAP = new Map([
|
|
25
|
+
[LWC_METADATA_TYPE_NAME, new LwcProcessor()],
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* A main entryway for processing file operations for metadata files.
|
|
29
|
+
* This includes reading and writing component files.
|
|
30
|
+
* Supported component types are defined in SUPPORTED_COMPONENT_TYPES and each maps
|
|
31
|
+
* to a dedicated processor in COMPONENT_TYPE_PROCESSOR_MAP.
|
|
32
|
+
*/
|
|
19
33
|
export class FileProcessor {
|
|
20
|
-
static async
|
|
34
|
+
static async updateMetadata(componentsToProcess, enrichmentRecords) {
|
|
21
35
|
const componentsByType = FileProcessor.groupComponentsByType(componentsToProcess);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
for (const [componentType, components] of componentsByType) {
|
|
37
|
+
if (!SUPPORTED_COMPONENT_TYPES.has(componentType)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const processor = COMPONENT_TYPE_PROCESSOR_MAP.get(componentType);
|
|
41
|
+
if (!processor) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line no-await-in-loop
|
|
45
|
+
enrichmentRecords = await processor.updateMetadata(components, enrichmentRecords);
|
|
26
46
|
}
|
|
27
|
-
return
|
|
47
|
+
return enrichmentRecords;
|
|
28
48
|
}
|
|
29
49
|
static async readComponentFile(componentName, filePath) {
|
|
30
50
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileProcessor.js","sourceRoot":"","sources":["../../src/files/fileProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"fileProcessor.js","sourceRoot":"","sources":["../../src/files/fileProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACzG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAqBjD;;;GAGG;AACH,MAAM,4BAA4B,G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Aa,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,MAAM,gBAAgB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE/G,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACxD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAA4B,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IACnF,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,UAA6B;QAChE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAC9D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC;YAC5D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;YAC/D,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF"}
|
package/lib/files/index.d.ts
CHANGED
package/lib/files/index.js
CHANGED
|
@@ -13,5 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { SourceComponentProcessor } from './sourceComponentProcessor.js';
|
|
16
17
|
export { FileProcessor } from './fileProcessor.js';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/lib/files/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
2
2
|
import type { EnrichmentRequestRecord } from '../enrichment/enrichmentHandler.js';
|
|
3
3
|
import type { EnrichmentResult } from '../enrichment/types/index.js';
|
|
4
|
-
import type { FileReadResult } from './fileProcessor.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import type { ComponentTypeProcessor, FileReadResult } from './fileProcessor.js';
|
|
5
|
+
/**
|
|
6
|
+
* A LWC specific processor for reading and updating LWC metadata files.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LwcProcessor implements ComponentTypeProcessor {
|
|
9
|
+
updateMetadata(lightningComponentBundles: SourceComponent[], enrichmentRecords: Set<EnrichmentRequestRecord>): Promise<Set<EnrichmentRequestRecord>>;
|
|
10
|
+
readComponentFiles(sourceComponents: SourceComponent[]): Promise<FileReadResult[]>;
|
|
11
|
+
updateMetaXml(xmlContent: string, result: EnrichmentResult): string;
|
|
12
|
+
isMetaXmlFile(filePath: string): boolean;
|
|
13
|
+
private isSkipUpliftEnabled;
|
|
11
14
|
}
|
|
@@ -21,24 +21,16 @@ import { XMLParser, XMLBuilder } from 'fast-xml-parser';
|
|
|
21
21
|
import { EnrichmentStatus } from '../enrichment/enrichmentHandler.js';
|
|
22
22
|
import { FileProcessor } from './fileProcessor.js';
|
|
23
23
|
Messages.importMessagesDirectory(import.meta.dirname);
|
|
24
|
-
const messages = Messages.loadMessages('@salesforce/metadata-enrichment', '
|
|
24
|
+
const messages = Messages.loadMessages('@salesforce/metadata-enrichment', 'errors');
|
|
25
|
+
/**
|
|
26
|
+
* A LWC specific processor for reading and updating LWC metadata files.
|
|
27
|
+
*/
|
|
28
|
+
/* eslint-disable class-methods-use-this */
|
|
25
29
|
export class LwcProcessor {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
for (const component of sourceComponents) {
|
|
29
|
-
const componentName = component.fullName ?? component.name;
|
|
30
|
-
if (!componentName || !component.xml) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
fileReadPromises.push(FileProcessor.readComponentFile(componentName, component.xml));
|
|
34
|
-
}
|
|
35
|
-
const fileResults = await Promise.all(fileReadPromises);
|
|
36
|
-
return fileResults.filter((result) => result !== null);
|
|
37
|
-
}
|
|
38
|
-
static async updateMetadataFiles(lightningComponentBundles, enrichmentRecords) {
|
|
39
|
-
const fileContents = await LwcProcessor.readComponentFiles(lightningComponentBundles);
|
|
30
|
+
async updateMetadata(lightningComponentBundles, enrichmentRecords) {
|
|
31
|
+
const fileContents = await this.readComponentFiles(lightningComponentBundles);
|
|
40
32
|
for (const file of fileContents) {
|
|
41
|
-
if (!
|
|
33
|
+
if (!this.isMetaXmlFile(file.filePath)) {
|
|
42
34
|
continue;
|
|
43
35
|
}
|
|
44
36
|
let enrichmentRecord;
|
|
@@ -56,13 +48,13 @@ export class LwcProcessor {
|
|
|
56
48
|
continue;
|
|
57
49
|
}
|
|
58
50
|
// Check if skipUplift is enabled before processing
|
|
59
|
-
if (
|
|
51
|
+
if (this.isSkipUpliftEnabled(file.fileContents)) {
|
|
60
52
|
enrichmentRecord.message = 'skipUplift is set to true';
|
|
61
53
|
enrichmentRecord.status = EnrichmentStatus.SKIPPED;
|
|
62
54
|
continue;
|
|
63
55
|
}
|
|
64
56
|
try {
|
|
65
|
-
const updatedXml =
|
|
57
|
+
const updatedXml = this.updateMetaXml(file.fileContents, enrichmentResult);
|
|
66
58
|
// eslint-disable-next-line no-await-in-loop
|
|
67
59
|
await writeFile(file.filePath, updatedXml, 'utf-8');
|
|
68
60
|
}
|
|
@@ -73,7 +65,19 @@ export class LwcProcessor {
|
|
|
73
65
|
}
|
|
74
66
|
return enrichmentRecords;
|
|
75
67
|
}
|
|
76
|
-
|
|
68
|
+
async readComponentFiles(sourceComponents) {
|
|
69
|
+
const fileReadPromises = [];
|
|
70
|
+
for (const component of sourceComponents) {
|
|
71
|
+
const componentName = component.fullName ?? component.name;
|
|
72
|
+
if (!componentName || !component.xml) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
fileReadPromises.push(FileProcessor.readComponentFile(componentName, component.xml));
|
|
76
|
+
}
|
|
77
|
+
const fileResults = await Promise.all(fileReadPromises);
|
|
78
|
+
return fileResults.filter((result) => result !== null);
|
|
79
|
+
}
|
|
80
|
+
updateMetaXml(xmlContent, result) {
|
|
77
81
|
const parser = new XMLParser({
|
|
78
82
|
htmlEntities: true,
|
|
79
83
|
ignoreAttributes: false,
|
|
@@ -99,14 +103,14 @@ export class LwcProcessor {
|
|
|
99
103
|
return builtXml.trim().replace(/\n{3,}/g, '\n\n');
|
|
100
104
|
}
|
|
101
105
|
catch (error) {
|
|
102
|
-
throw new SfError(messages.getMessage('
|
|
106
|
+
throw new SfError(messages.getMessage('errors.parsing.xml', [error instanceof Error ? error.message : String(error)]));
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
|
-
|
|
109
|
+
isMetaXmlFile(filePath) {
|
|
106
110
|
const fileName = basename(filePath);
|
|
107
111
|
return fileName.endsWith('.js-meta.xml');
|
|
108
112
|
}
|
|
109
|
-
|
|
113
|
+
isSkipUpliftEnabled(xmlContent) {
|
|
110
114
|
try {
|
|
111
115
|
const parser = new XMLParser({ ignoreAttributes: false, preserveOrder: false, trimValues: true });
|
|
112
116
|
const xmlObj = parser.parse(xmlContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lwcProcessor.js","sourceRoot":"","sources":["../../src/files/lwcProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAQ,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtD,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,iCAAiC,EAAE,
|
|
1
|
+
{"version":3,"file":"lwcProcessor.js","sourceRoot":"","sources":["../../src/files/lwcProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAQ,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAA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CAAC;YAEF,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,EAAE,EAAE,EAAE,UAAU,CAAC;YACnE,OAAO,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SourceComponent } from '@salesforce/source-deploy-retrieve';
|
|
2
|
+
import type { MetadataTypeAndName } from '../common/types.js';
|
|
3
|
+
export declare class SourceComponentProcessor {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Determine the components to SKIP based on the source components and the metadata entries.
|
|
7
|
+
* This includes:
|
|
8
|
+
* - Input components that do not exist in the source project
|
|
9
|
+
* - Components of unsupported types (not in SUPPORTED_COMPONENT_TYPES)
|
|
10
|
+
* - Components that fail type-specific validation (e.g., missing metadata configuration file)
|
|
11
|
+
*
|
|
12
|
+
* @param sourceComponents
|
|
13
|
+
* @param metadataEntries
|
|
14
|
+
* @param projectDir
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
static getComponentsToSkip(sourceComponents: SourceComponent[], metadataEntries: string[], projectDir?: string): Set<MetadataTypeAndName>;
|
|
18
|
+
private static filterComponents;
|
|
19
|
+
private static diffRequestedComponents;
|
|
20
|
+
private static parseRequestedComponents;
|
|
21
|
+
private static getExistingSourceComponentNames;
|
|
22
|
+
private static createSourceComponentMap;
|
|
23
|
+
private static parseMetadataEntry;
|
|
24
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
|
|
17
|
+
import { COMPONENT_TYPE_VALIDATORS, SUPPORTED_COMPONENT_TYPES } from '../enrichment/constants/component.js';
|
|
18
|
+
export class SourceComponentProcessor {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* Determine the components to SKIP based on the source components and the metadata entries.
|
|
22
|
+
* This includes:
|
|
23
|
+
* - Input components that do not exist in the source project
|
|
24
|
+
* - Components of unsupported types (not in SUPPORTED_COMPONENT_TYPES)
|
|
25
|
+
* - Components that fail type-specific validation (e.g., missing metadata configuration file)
|
|
26
|
+
*
|
|
27
|
+
* @param sourceComponents
|
|
28
|
+
* @param metadataEntries
|
|
29
|
+
* @param projectDir
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
static getComponentsToSkip(sourceComponents, metadataEntries, projectDir) {
|
|
33
|
+
const requestedComponents = SourceComponentProcessor.parseRequestedComponents(metadataEntries, projectDir);
|
|
34
|
+
const missingComponents = SourceComponentProcessor.diffRequestedComponents(sourceComponents, requestedComponents);
|
|
35
|
+
const filteredComponents = SourceComponentProcessor.filterComponents(sourceComponents, requestedComponents);
|
|
36
|
+
return new Set([...missingComponents, ...filteredComponents]);
|
|
37
|
+
}
|
|
38
|
+
static filterComponents(sourceComponents, requestedComponents) {
|
|
39
|
+
const sourceComponentMap = SourceComponentProcessor.createSourceComponentMap(sourceComponents);
|
|
40
|
+
const filteredComponents = new Set();
|
|
41
|
+
for (const requestedComponent of requestedComponents) {
|
|
42
|
+
if (!requestedComponent?.componentName)
|
|
43
|
+
continue;
|
|
44
|
+
const sourceComponent = sourceComponentMap.get(requestedComponent.componentName);
|
|
45
|
+
if (!sourceComponent)
|
|
46
|
+
continue;
|
|
47
|
+
const typeName = sourceComponent.type?.name ?? '';
|
|
48
|
+
// Filter out unsupported component types
|
|
49
|
+
if (!SUPPORTED_COMPONENT_TYPES.has(typeName)) {
|
|
50
|
+
filteredComponents.add({
|
|
51
|
+
typeName: sourceComponent.type.name,
|
|
52
|
+
componentName: requestedComponent.componentName,
|
|
53
|
+
});
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Run type-specific validation
|
|
57
|
+
const validator = COMPONENT_TYPE_VALIDATORS.get(typeName);
|
|
58
|
+
if (validator && !validator(sourceComponent)) {
|
|
59
|
+
filteredComponents.add({
|
|
60
|
+
typeName: sourceComponent.type.name,
|
|
61
|
+
componentName: requestedComponent.componentName,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return filteredComponents;
|
|
66
|
+
}
|
|
67
|
+
static diffRequestedComponents(sourceComponents, requestedComponents) {
|
|
68
|
+
const existingSourceComponentNames = SourceComponentProcessor.getExistingSourceComponentNames(sourceComponents);
|
|
69
|
+
const missingComponents = new Set();
|
|
70
|
+
for (const requestedComponent of requestedComponents) {
|
|
71
|
+
if (requestedComponent.componentName && !existingSourceComponentNames.has(requestedComponent.componentName)) {
|
|
72
|
+
missingComponents.add(requestedComponent);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return missingComponents;
|
|
76
|
+
}
|
|
77
|
+
static parseRequestedComponents(metadataEntries, projectDir) {
|
|
78
|
+
const requestedComponents = new Set();
|
|
79
|
+
for (const entry of metadataEntries) {
|
|
80
|
+
const parsed = SourceComponentProcessor.parseMetadataEntry(entry, projectDir);
|
|
81
|
+
if (!parsed) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Ignore wildcarded component names
|
|
85
|
+
if (parsed.componentName?.includes('*')) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
requestedComponents.add(parsed);
|
|
89
|
+
}
|
|
90
|
+
return requestedComponents;
|
|
91
|
+
}
|
|
92
|
+
static getExistingSourceComponentNames(sourceComponents) {
|
|
93
|
+
const existingSourceComponentNames = new Set();
|
|
94
|
+
for (const component of sourceComponents) {
|
|
95
|
+
const componentName = component.fullName ?? component.name;
|
|
96
|
+
if (componentName) {
|
|
97
|
+
existingSourceComponentNames.add(componentName);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return existingSourceComponentNames;
|
|
101
|
+
}
|
|
102
|
+
static createSourceComponentMap(sourceComponents) {
|
|
103
|
+
const componentMap = new Map();
|
|
104
|
+
for (const component of sourceComponents) {
|
|
105
|
+
const componentName = component.fullName ?? component.name;
|
|
106
|
+
if (componentName) {
|
|
107
|
+
componentMap.set(componentName, component);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return componentMap;
|
|
111
|
+
}
|
|
112
|
+
static parseMetadataEntry(rawEntry, projectDir) {
|
|
113
|
+
try {
|
|
114
|
+
const registry = new RegistryAccess(undefined, projectDir);
|
|
115
|
+
// Split on the first colon, and then join the rest back together to support names that include colons
|
|
116
|
+
const [typeName, ...nameParts] = rawEntry.split(':');
|
|
117
|
+
const type = registry.getTypeByName(typeName.trim());
|
|
118
|
+
if (!type) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const metadataName = nameParts.length > 0 ? nameParts.join(':').trim() : '*';
|
|
122
|
+
// Return null for wildcards since componentName is required
|
|
123
|
+
if (metadataName === '*') {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
typeName: type.name,
|
|
128
|
+
componentName: metadataName,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=sourceComponentProcessor.js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;YAC3D,sGAAsG;YACtG,MAAM,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7E,4DAA4D;YAC5D,IAAI,YAAY,KAAK,GAAG,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,aAAa,EAAE,YAAY;aAC5B,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { FileProcessor } from './files/index.js';
|
|
1
|
+
export { SourceComponentProcessor, FileProcessor } from './files/index.js';
|
|
2
2
|
export type { FileReadResult } from './files/index.js';
|
|
3
|
-
export { getMimeTypeFromExtension, EnrichmentHandler,
|
|
4
|
-
export type { ContentBundleFile, ContentBundle, EnrichmentRequestBody, EnrichmentMetadata, EnrichmentResult,
|
|
3
|
+
export { getMimeTypeFromExtension, API_ENDPOINT_ENRICHMENT, SUPPORTED_MIME_TYPES, EnrichmentHandler, EnrichmentMetrics, EnrichmentRecords, EnrichmentStatus, LwcComponentValidator, } from './enrichment/index.js';
|
|
4
|
+
export type { ContentBundleFile, ContentBundle, EnrichmentRequestBody, EnrichmentMetadata, EnrichmentResult, EnrichMetadataResponse, EnrichmentRequestRecord, } from './enrichment/index.js';
|
|
5
5
|
export type { ComponentEnrichmentStatus, MetadataTypeAndName } from './common/index.js';
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { FileProcessor } from './files/index.js';
|
|
17
|
-
export { getMimeTypeFromExtension, EnrichmentHandler,
|
|
16
|
+
export { SourceComponentProcessor, FileProcessor } from './files/index.js';
|
|
17
|
+
export { getMimeTypeFromExtension, API_ENDPOINT_ENRICHMENT, SUPPORTED_MIME_TYPES, EnrichmentHandler, EnrichmentMetrics, EnrichmentRecords, EnrichmentStatus, LwcComponentValidator, } from './enrichment/index.js';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG3E,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# errors.component.not.found
|
|
2
|
+
|
|
3
|
+
Component not found in project.
|
|
4
|
+
|
|
5
|
+
# errors.unsupported.type.default
|
|
6
|
+
|
|
7
|
+
This component type is not currently supported for enrichment.
|
|
8
|
+
|
|
9
|
+
# errors.unsupported.type
|
|
10
|
+
|
|
11
|
+
Component type '%s' is not currently supported for enrichment.
|
|
12
|
+
|
|
13
|
+
# errors.component.configuration.not.found
|
|
14
|
+
|
|
15
|
+
The component's metadata configuration file doesn't exist.
|
|
16
|
+
|
|
17
|
+
# errors.enrichment.request
|
|
18
|
+
|
|
19
|
+
Error sending request for component %s %s.
|
|
20
|
+
|
|
21
|
+
# errors.unknown
|
|
22
|
+
|
|
23
|
+
An unknown error occurred.
|
|
24
|
+
|
|
25
|
+
# errors.parsing.xml
|
|
26
|
+
|
|
27
|
+
Failed to parse XML: %s.
|
|
28
|
+
|
|
29
|
+
# errors.file.read.failed
|
|
30
|
+
|
|
31
|
+
Failed to read file for component %s.
|
package/package.json
CHANGED
package/messages/enrichment.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# error.enrichment.request
|
|
2
|
-
|
|
3
|
-
Error sending request for component %s %s.
|
|
4
|
-
|
|
5
|
-
# error.parsing.xml
|
|
6
|
-
|
|
7
|
-
Failed to parse XML: %s.
|
|
8
|
-
|
|
9
|
-
# error.file.read.failed
|
|
10
|
-
|
|
11
|
-
Failed to read file for component %s.
|
|
12
|
-
|
|
13
|
-
# error.enrich.lwc.only
|
|
14
|
-
|
|
15
|
-
Enrichment currently supports only Lightning Web Components, represented by the LightningComponentBundle metadata type.
|