Skip to content

Commit 752a631

Browse files
committed
Merge remote-tracking branch 'origin/main' into sm/skip-adapter-optimizations
2 parents cb3a219 + 683254a commit 752a631

19 files changed

+1198
-2257
lines changed

CHANGELOG.md

Lines changed: 429 additions & 1545 deletions
Large diffs are not rendered by default.

METADATA_SUPPORT.md

Lines changed: 632 additions & 633 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@salesforce/source-deploy-retrieve",
3-
"version": "12.0.2",
3+
"version": "12.1.4",
44
"description": "JavaScript library to run Salesforce metadata deploys and retrieves",
55
"main": "lib/src/index.js",
66
"author": "Salesforce",
@@ -25,7 +25,7 @@
2525
"node": ">=18.0.0"
2626
},
2727
"dependencies": {
28-
"@salesforce/core": "^8.0.5",
28+
"@salesforce/core": "^8.1.0",
2929
"@salesforce/kit": "^3.1.6",
3030
"@salesforce/ts-types": "^2.0.10",
3131
"fast-levenshtein": "^3.0.0",
@@ -35,7 +35,7 @@
3535
"ignore": "^5.3.1",
3636
"jszip": "^3.10.1",
3737
"mime": "2.6.0",
38-
"minimatch": "^5.1.6",
38+
"minimatch": "^9.0.5",
3939
"proxy-agent": "^6.4.0"
4040
},
4141
"devDependencies": {

src/client/deployMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const shouldWalkContent = (component: SourceComponent): boolean =>
7373
export const createResponses = (component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] =>
7474
responseMessages.flatMap((message): FileResponse[] => {
7575
const state = getState(message);
76-
const base = { fullName: component.fullName, type: component.type.name };
76+
const base = { fullName: component.fullName, type: component.type.name } as const;
7777

7878
if (state === ComponentStatus.Failed) {
7979
return [{ ...base, state, ...parseDeployDiagnostic(component, message) } satisfies FileResponseFailure];

src/client/metadataApiRetrieve.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
AsyncResult,
1717
ComponentStatus,
1818
FileResponse,
19+
FileResponseSuccess,
1920
MetadataApiRetrieveStatus,
2021
MetadataTransferResult,
2122
PackageOptions,
@@ -88,20 +89,20 @@ export class RetrieveResult implements MetadataTransferResult {
8889
// construct successes
8990
for (const retrievedComponent of this.components.getSourceComponents()) {
9091
const { fullName, type, xml } = retrievedComponent;
91-
const baseResponse: FileResponse = {
92+
const baseResponse = {
9293
fullName,
9394
type: type.name,
9495
state: this.localComponents.has(retrievedComponent) ? ComponentStatus.Changed : ComponentStatus.Created,
95-
};
96+
} as const;
9697

9798
if (!type.children || Object.values(type.children.types).some((t) => t.unaddressableWithoutParent)) {
9899
for (const filePath of retrievedComponent.walkContent()) {
99-
this.fileResponses.push(Object.assign({}, baseResponse, { filePath }));
100+
this.fileResponses.push({ ...baseResponse, filePath } satisfies FileResponseSuccess);
100101
}
101102
}
102103

103104
if (xml) {
104-
this.fileResponses.push(Object.assign({}, baseResponse, { filePath: xml }));
105+
this.fileResponses.push({ ...baseResponse, filePath: xml } satisfies FileResponseSuccess);
105106
}
106107
}
107108

src/client/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ type FileResponseBase = {
5555
filePath?: string;
5656
};
5757

58-
export type FileResponseSuccess = {
58+
export type FileResponseSuccess = Required<FileResponseBase> & {
5959
state: Exclude<ComponentStatus, ComponentStatus.Failed>;
60-
} & FileResponseBase;
60+
};
6161

6262
export type FileResponseFailure = {
6363
state: ComponentStatus.Failed;

src/collections/componentSetBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import * as path from 'node:path';
99
import { Logger, Messages, SfError, StateAggregator } from '@salesforce/core';
1010
import fs from 'graceful-fs';
11-
import minimatch from 'minimatch';
11+
import { minimatch } from 'minimatch';
1212
import { MetadataComponent } from '../resolve/types';
1313
import { SourceComponent } from '../resolve/sourceComponent';
1414
import { ComponentSet } from '../collections/componentSet';

src/convert/replacements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { readFile } from 'node:fs/promises';
88
import { Transform, Readable } from 'node:stream';
99
import { sep, posix, join, isAbsolute } from 'node:path';
1010
import { Lifecycle, Messages, SfError, SfProject } from '@salesforce/core';
11-
import minimatch from 'minimatch';
11+
import { minimatch } from 'minimatch';
1212
import { Env } from '@salesforce/kit';
1313
import { ensureString, isString } from '@salesforce/ts-types';
1414
import { SourcePath } from '../common/types';

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ export {
100100
RecompositionStrategy,
101101
TransformerStrategy,
102102
} from './registry';
103+
104+
export { presetMap } from './registry/presets/presetMap';

src/registry/metadataRegistry.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"customfield": "customobject",
1010
"customfieldtranslation": "customobjecttranslation",
1111
"customlabel": "customlabels",
12-
"decisionmatrixdefinitionversion": "decisionmatrixdefinition",
1312
"digitalexperience": "digitalexperiencebundle",
1413
"escalationrule": "escalationrules",
1514
"extdatatranfieldtemplate": "extdatatranobjecttemplate",
@@ -203,7 +202,7 @@
203202
"datacategorygroup": "datacategorygroup",
204203
"datatype": "customdatatype",
205204
"decisionMatrixDefinition": "decisionmatrixdefinition",
206-
"decisionMatrixDefinitionVersion": "decisionmatrixdefinitionversion",
205+
"decisionMatrixVersion": "decisionmatrixdefinitionversion",
207206
"decisionTable": "decisiontable",
208207
"decisionTableDatasetLink": "decisiontabledatasetlink",
209208
"delegateGroup": "delegategroup",
@@ -250,6 +249,7 @@
250249
"explainabilityActionVersion": "explainabilityactionversion",
251250
"explainabilityMsgTemplate": "explainabilitymsgtemplate",
252251
"expressionSetDefinition": "expressionsetdefinition",
252+
"expressionSetVersion": "expressionsetdefinitionversion",
253253
"expressionSetMessageToken": "expressionsetmessagetoken",
254254
"expressionSetObjectAlias": "expressionsetobjectalias",
255255
"extDataTranFieldTemplate": "extdatatranfieldtemplate",
@@ -1765,29 +1765,21 @@
17651765
"suffix": "dwl"
17661766
},
17671767
"decisionmatrixdefinition": {
1768-
"children": {
1769-
"directories": {
1770-
"versions": "decisionmatrixdefinitionversion"
1771-
},
1772-
"suffixes": {
1773-
"decisionMatrixDefinitionVersion": "decisionmatrixdefinitionversion"
1774-
},
1775-
"types": {
1776-
"decisionmatrixdefinitionversion": {
1777-
"directoryName": "versions",
1778-
"id": "decisionmatrixdefinitionversion",
1779-
"name": "DecisionMatrixDefinitionVersion",
1780-
"suffix": "decisionMatrixDefinitionVersion"
1781-
}
1782-
}
1783-
},
17841768
"directoryName": "decisionMatrixDefinition",
17851769
"id": "decisionmatrixdefinition",
17861770
"inFolder": false,
17871771
"name": "DecisionMatrixDefinition",
17881772
"strictDirectoryName": false,
17891773
"suffix": "decisionMatrixDefinition"
17901774
},
1775+
"decisionmatrixdefinitionversion": {
1776+
"directoryName": "decisionMatrixVersion",
1777+
"id": "decisionmatrixdefinitionversion",
1778+
"inFolder": false,
1779+
"name": "DecisionMatrixDefinitionVersion",
1780+
"strictDirectoryName": false,
1781+
"suffix": "decisionMatrixVersion"
1782+
},
17911783
"decisiontable": {
17921784
"directoryName": "decisionTables",
17931785
"id": "decisiontable",
@@ -2237,6 +2229,14 @@
22372229
"strictDirectoryName": false,
22382230
"suffix": "expressionSetDefinition"
22392231
},
2232+
"expressionsetdefinitionversion": {
2233+
"directoryName": "expressionSetVersion",
2234+
"id": "expressionsetdefinitionversion",
2235+
"inFolder": false,
2236+
"name": "ExpressionSetDefinitionVersion",
2237+
"strictDirectoryName": false,
2238+
"suffix": "expressionSetVersion"
2239+
},
22402240
"expressionsetmessagetoken": {
22412241
"directoryName": "expressionSetMessageToken",
22422242
"id": "expressionsetmessagetoken",

src/registry/presets/presetMap.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2023, salesforce.com, 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 { MetadataRegistry } from '../types';
8+
9+
// we have to import all presets explicitly for VSCE's esbuild bundling process
10+
import * as decomposeCustomLabelsBeta from './decomposeCustomLabelsBeta.json';
11+
import * as decomposePermissionSetBeta from './decomposePermissionSetBeta.json';
12+
import * as decomposeSharingRulesBeta from './decomposeSharingRulesBeta.json';
13+
import * as decomposeWorkflowBeta from './decomposeWorkflowBeta.json';
14+
15+
export const presetMap = new Map<string, MetadataRegistry>([
16+
['decomposeCustomLabelsBeta', decomposeCustomLabelsBeta as MetadataRegistry],
17+
['decomposePermissionSetBeta', decomposePermissionSetBeta as MetadataRegistry],
18+
['decomposeSharingRulesBeta', decomposeSharingRulesBeta as MetadataRegistry],
19+
['decomposeWorkflowBeta', decomposeWorkflowBeta as MetadataRegistry],
20+
]);

src/registry/variants.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import * as fs from 'node:fs';
8-
import * as path from 'node:path';
9-
import { Logger, SfProject, SfProjectJson, Lifecycle } from '@salesforce/core';
7+
import { Logger, SfProject, SfProjectJson, Lifecycle, SfError } from '@salesforce/core';
108
import { deepFreeze } from '../utils/collections';
119
import { MetadataRegistry } from './types';
1210
import * as registryData from './metadataRegistry.json';
11+
import { presetMap } from './presets/presetMap';
1312

1413
export type RegistryLoadInput = {
1514
/** The project directory to look at sfdx-project.json file
@@ -76,14 +75,18 @@ const maybeGetProject = (projectDir?: string): SfProjectJson | undefined => {
7675
};
7776

7877
const loadPreset = (preset: string): MetadataRegistry => {
79-
const pathToCheck = path.join(__dirname, 'presets', `${preset}.json`);
80-
81-
try {
82-
const rawPreset = fs.readFileSync(pathToCheck, 'utf-8');
83-
return JSON.parse(rawPreset) as MetadataRegistry;
84-
} catch (e) {
85-
throw new Error(`Failed to load preset ${preset} in ${pathToCheck}`);
78+
const matchedPreset = presetMap.get(preset);
79+
if (matchedPreset) {
80+
return matchedPreset;
8681
}
82+
throw SfError.create({
83+
message: `Failed to load preset "${preset}"`,
84+
name: 'InvalidPreset',
85+
actions: [
86+
`Use a valid preset. Currently available presets are: [${[...presetMap.keys()].join(', ')}]`,
87+
'Updating your CLI may be required to get newer presets',
88+
],
89+
});
8790
};
8891

8992
const emptyRegistry = {

src/resolve/sourceComponent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ export class SourceComponent implements MetadataComponent {
232232
const uniqueElement = this.type.uniqueIdElement;
233233
const matched = uniqueElement ? children.find((c) => getString(c, uniqueElement) === this.name) : undefined;
234234
if (!matched) {
235-
throw new SfError(`Unable to find matching parent xml file for ${this.xml}`);
235+
throw new SfError(
236+
`Invalid XML tags or unable to find matching parent xml file for ${this.type.name} "${this.name}"`
237+
);
236238
}
237239
return matched;
238240
}

src/utils/collections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, salesforce.com, inc.
2+
* Copyright (c) 2024, salesforce.com, inc.
33
* All rights reserved.
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause

test/client/metadataApiDeploy.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { basename, join, sep } from 'node:path';
88
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
99
import chai, { assert, expect } from 'chai';
10-
import { AnyJson, getString } from '@salesforce/ts-types';
10+
import { AnyJson, ensureString, getString } from '@salesforce/ts-types';
1111
import { Lifecycle, Messages, PollingClient, StatusResult } from '@salesforce/core';
1212
import { Duration } from '@salesforce/kit';
1313
import deepEqualInAnyOrder = require('deep-equal-in-any-order');
@@ -548,13 +548,13 @@ describe('MetadataApiDeploy', () => {
548548
fullName,
549549
type: type.name,
550550
state: ComponentStatus.Changed,
551-
filePath: content,
551+
filePath: ensureString(content),
552552
},
553553
{
554554
fullName,
555555
type: type.name,
556556
state: ComponentStatus.Changed,
557-
filePath: xml,
557+
filePath: ensureString(xml),
558558
},
559559
];
560560

@@ -584,13 +584,13 @@ describe('MetadataApiDeploy', () => {
584584
fullName,
585585
type: type.name,
586586
state: ComponentStatus.Created,
587-
filePath: content,
587+
filePath: ensureString(content),
588588
},
589589
{
590590
fullName,
591591
type: type.name,
592592
state: ComponentStatus.Created,
593-
filePath: xml,
593+
filePath: ensureString(xml),
594594
},
595595
];
596596

@@ -620,13 +620,13 @@ describe('MetadataApiDeploy', () => {
620620
fullName,
621621
type: type.name,
622622
state: ComponentStatus.Deleted,
623-
filePath: content,
623+
filePath: ensureString(content),
624624
},
625625
{
626626
fullName,
627627
type: type.name,
628628
state: ComponentStatus.Deleted,
629-
filePath: xml,
629+
filePath: ensureString(xml),
630630
},
631631
];
632632

@@ -695,13 +695,13 @@ describe('MetadataApiDeploy', () => {
695695
fullName,
696696
type: type.name,
697697
state: ComponentStatus.Unchanged,
698-
filePath: content,
698+
filePath: ensureString(content),
699699
},
700700
{
701701
fullName,
702702
type: type.name,
703703
state: ComponentStatus.Unchanged,
704-
filePath: xml,
704+
filePath: ensureString(xml),
705705
},
706706
];
707707

@@ -1031,19 +1031,19 @@ describe('MetadataApiDeploy', () => {
10311031
fullName: DECOMPOSED_CHILD_COMPONENT_1.fullName,
10321032
type: DECOMPOSED_CHILD_COMPONENT_1.type.name,
10331033
state: ComponentStatus.Changed,
1034-
filePath: DECOMPOSED_CHILD_COMPONENT_1.xml,
1034+
filePath: ensureString(DECOMPOSED_CHILD_COMPONENT_1.xml),
10351035
},
10361036
{
10371037
fullName: DECOMPOSED_CHILD_COMPONENT_2.fullName,
10381038
type: DECOMPOSED_CHILD_COMPONENT_2.type.name,
10391039
state: ComponentStatus.Changed,
1040-
filePath: DECOMPOSED_CHILD_COMPONENT_2.xml,
1040+
filePath: ensureString(DECOMPOSED_CHILD_COMPONENT_2.xml),
10411041
},
10421042
{
10431043
fullName: component.fullName,
10441044
type: component.type.name,
10451045
state: ComponentStatus.Changed,
1046-
filePath: component.xml,
1046+
filePath: ensureString(component.xml),
10471047
},
10481048
];
10491049

@@ -1074,13 +1074,13 @@ describe('MetadataApiDeploy', () => {
10741074
fullName: component.fullName,
10751075
type: component.type.name,
10761076
state: ComponentStatus.Deleted,
1077-
filePath: component.content,
1077+
filePath: ensureString(component.content),
10781078
},
10791079
{
10801080
fullName: component.fullName,
10811081
type: component.type.name,
10821082
state: ComponentStatus.Deleted,
1083-
filePath: component.xml,
1083+
filePath: ensureString(component.xml),
10841084
},
10851085
];
10861086

0 commit comments

Comments
 (0)