Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into wr/invalidXmlMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 28, 2024
2 parents c7b21ff + da47439 commit 020a111
Show file tree
Hide file tree
Showing 10 changed files with 479 additions and 1,612 deletions.
1,978 changes: 422 additions & 1,556 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/source-deploy-retrieve",
"version": "12.0.2",
"version": "12.1.1",
"description": "JavaScript library to run Salesforce metadata deploys and retrieves",
"main": "lib/src/index.js",
"author": "Salesforce",
Expand Down Expand Up @@ -39,7 +39,7 @@
"proxy-agent": "^6.4.0"
},
"devDependencies": {
"@jsforce/jsforce-node": "^3.2.0",
"@jsforce/jsforce-node": "^3.2.1",
"@salesforce/cli-plugins-testkit": "^5.3.16",
"@salesforce/dev-scripts": "^10.2.2",
"@types/deep-equal-in-any-order": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/client/deployMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const shouldWalkContent = (component: SourceComponent): boolean =>
export const createResponses = (component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] =>
responseMessages.flatMap((message): FileResponse[] => {
const state = getState(message);
const base = { fullName: component.fullName, type: component.type.name };
const base = { fullName: component.fullName, type: component.type.name } as const;

if (state === ComponentStatus.Failed) {
return [{ ...base, state, ...parseDeployDiagnostic(component, message) } satisfies FileResponseFailure];
Expand Down
9 changes: 5 additions & 4 deletions src/client/metadataApiRetrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
AsyncResult,
ComponentStatus,
FileResponse,
FileResponseSuccess,
MetadataApiRetrieveStatus,
MetadataTransferResult,
PackageOptions,
Expand Down Expand Up @@ -88,20 +89,20 @@ export class RetrieveResult implements MetadataTransferResult {
// construct successes
for (const retrievedComponent of this.components.getSourceComponents()) {
const { fullName, type, xml } = retrievedComponent;
const baseResponse: FileResponse = {
const baseResponse = {
fullName,
type: type.name,
state: this.localComponents.has(retrievedComponent) ? ComponentStatus.Changed : ComponentStatus.Created,
};
} as const;

if (!type.children || Object.values(type.children.types).some((t) => t.unaddressableWithoutParent)) {
for (const filePath of retrievedComponent.walkContent()) {
this.fileResponses.push(Object.assign({}, baseResponse, { filePath }));
this.fileResponses.push({ ...baseResponse, filePath } satisfies FileResponseSuccess);
}
}

if (xml) {
this.fileResponses.push(Object.assign({}, baseResponse, { filePath: xml }));
this.fileResponses.push({ ...baseResponse, filePath: xml } satisfies FileResponseSuccess);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ type FileResponseBase = {
filePath?: string;
};

export type FileResponseSuccess = {
export type FileResponseSuccess = Required<FileResponseBase> & {
state: Exclude<ComponentStatus, ComponentStatus.Failed>;
} & FileResponseBase;
};

export type FileResponseFailure = {
state: ComponentStatus.Failed;
Expand Down
36 changes: 18 additions & 18 deletions src/registry/metadataRegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"customfield": "customobject",
"customfieldtranslation": "customobjecttranslation",
"customlabel": "customlabels",
"decisionmatrixdefinitionversion": "decisionmatrixdefinition",
"digitalexperience": "digitalexperiencebundle",
"escalationrule": "escalationrules",
"extdatatranfieldtemplate": "extdatatranobjecttemplate",
Expand Down Expand Up @@ -203,7 +202,7 @@
"datacategorygroup": "datacategorygroup",
"datatype": "customdatatype",
"decisionMatrixDefinition": "decisionmatrixdefinition",
"decisionMatrixDefinitionVersion": "decisionmatrixdefinitionversion",
"decisionMatrixVersion": "decisionmatrixdefinitionversion",
"decisionTable": "decisiontable",
"decisionTableDatasetLink": "decisiontabledatasetlink",
"delegateGroup": "delegategroup",
Expand Down Expand Up @@ -250,6 +249,7 @@
"explainabilityActionVersion": "explainabilityactionversion",
"explainabilityMsgTemplate": "explainabilitymsgtemplate",
"expressionSetDefinition": "expressionsetdefinition",
"expressionSetVersion": "expressionsetdefinitionversion",
"expressionSetMessageToken": "expressionsetmessagetoken",
"expressionSetObjectAlias": "expressionsetobjectalias",
"extDataTranFieldTemplate": "extdatatranfieldtemplate",
Expand Down Expand Up @@ -1765,29 +1765,21 @@
"suffix": "dwl"
},
"decisionmatrixdefinition": {
"children": {
"directories": {
"versions": "decisionmatrixdefinitionversion"
},
"suffixes": {
"decisionMatrixDefinitionVersion": "decisionmatrixdefinitionversion"
},
"types": {
"decisionmatrixdefinitionversion": {
"directoryName": "versions",
"id": "decisionmatrixdefinitionversion",
"name": "DecisionMatrixDefinitionVersion",
"suffix": "decisionMatrixDefinitionVersion"
}
}
},
"directoryName": "decisionMatrixDefinition",
"id": "decisionmatrixdefinition",
"inFolder": false,
"name": "DecisionMatrixDefinition",
"strictDirectoryName": false,
"suffix": "decisionMatrixDefinition"
},
"decisionmatrixdefinitionversion": {
"directoryName": "decisionMatrixVersion",
"id": "decisionmatrixdefinitionversion",
"inFolder": false,
"name": "DecisionMatrixDefinitionVersion",
"strictDirectoryName": false,
"suffix": "decisionMatrixVersion"
},
"decisiontable": {
"directoryName": "decisionTables",
"id": "decisiontable",
Expand Down Expand Up @@ -2237,6 +2229,14 @@
"strictDirectoryName": false,
"suffix": "expressionSetDefinition"
},
"expressionsetdefinitionversion": {
"directoryName": "expressionSetVersion",
"id": "expressionsetdefinitionversion",
"inFolder": false,
"name": "ExpressionSetDefinitionVersion",
"strictDirectoryName": false,
"suffix": "expressionSetVersion"
},
"expressionsetmessagetoken": {
"directoryName": "expressionSetMessageToken",
"id": "expressionsetmessagetoken",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/collections.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
Expand Down
28 changes: 14 additions & 14 deletions test/client/metadataApiDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { basename, join, sep } from 'node:path';
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
import chai, { assert, expect } from 'chai';
import { AnyJson, getString } from '@salesforce/ts-types';
import { AnyJson, ensureString, getString } from '@salesforce/ts-types';
import { Lifecycle, Messages, PollingClient, StatusResult } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import deepEqualInAnyOrder = require('deep-equal-in-any-order');
Expand Down Expand Up @@ -548,13 +548,13 @@ describe('MetadataApiDeploy', () => {
fullName,
type: type.name,
state: ComponentStatus.Changed,
filePath: content,
filePath: ensureString(content),
},
{
fullName,
type: type.name,
state: ComponentStatus.Changed,
filePath: xml,
filePath: ensureString(xml),
},
];

Expand Down Expand Up @@ -584,13 +584,13 @@ describe('MetadataApiDeploy', () => {
fullName,
type: type.name,
state: ComponentStatus.Created,
filePath: content,
filePath: ensureString(content),
},
{
fullName,
type: type.name,
state: ComponentStatus.Created,
filePath: xml,
filePath: ensureString(xml),
},
];

Expand Down Expand Up @@ -620,13 +620,13 @@ describe('MetadataApiDeploy', () => {
fullName,
type: type.name,
state: ComponentStatus.Deleted,
filePath: content,
filePath: ensureString(content),
},
{
fullName,
type: type.name,
state: ComponentStatus.Deleted,
filePath: xml,
filePath: ensureString(xml),
},
];

Expand Down Expand Up @@ -695,13 +695,13 @@ describe('MetadataApiDeploy', () => {
fullName,
type: type.name,
state: ComponentStatus.Unchanged,
filePath: content,
filePath: ensureString(content),
},
{
fullName,
type: type.name,
state: ComponentStatus.Unchanged,
filePath: xml,
filePath: ensureString(xml),
},
];

Expand Down Expand Up @@ -1031,19 +1031,19 @@ describe('MetadataApiDeploy', () => {
fullName: DECOMPOSED_CHILD_COMPONENT_1.fullName,
type: DECOMPOSED_CHILD_COMPONENT_1.type.name,
state: ComponentStatus.Changed,
filePath: DECOMPOSED_CHILD_COMPONENT_1.xml,
filePath: ensureString(DECOMPOSED_CHILD_COMPONENT_1.xml),
},
{
fullName: DECOMPOSED_CHILD_COMPONENT_2.fullName,
type: DECOMPOSED_CHILD_COMPONENT_2.type.name,
state: ComponentStatus.Changed,
filePath: DECOMPOSED_CHILD_COMPONENT_2.xml,
filePath: ensureString(DECOMPOSED_CHILD_COMPONENT_2.xml),
},
{
fullName: component.fullName,
type: component.type.name,
state: ComponentStatus.Changed,
filePath: component.xml,
filePath: ensureString(component.xml),
},
];

Expand Down Expand Up @@ -1074,13 +1074,13 @@ describe('MetadataApiDeploy', () => {
fullName: component.fullName,
type: component.type.name,
state: ComponentStatus.Deleted,
filePath: component.content,
filePath: ensureString(component.content),
},
{
fullName: component.fullName,
type: component.type.name,
state: ComponentStatus.Deleted,
filePath: component.xml,
filePath: ensureString(component.xml),
},
];

Expand Down
26 changes: 13 additions & 13 deletions test/client/metadataApiRetrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { assert, expect } from 'chai';
import chai = require('chai');
import deepEqualInAnyOrder = require('deep-equal-in-any-order');
import { SinonStub } from 'sinon';
import { getString } from '@salesforce/ts-types';
import { ensureString, getString } from '@salesforce/ts-types';
import fs from 'graceful-fs';
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
import {
Expand Down Expand Up @@ -549,14 +549,14 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
const result = new RetrieveResult(apiStatus as MetadataApiRetrieveStatus, retrievedSet, retrievedSet);

const responses = result.getFileResponses();
const baseResponse: FileResponse = {
const baseResponse = {
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
};
} as const;
const expected: FileResponse[] = [
Object.assign({}, baseResponse, { filePath: component.content }),
Object.assign({}, baseResponse, { filePath: component.xml }),
{ ...baseResponse, filePath: ensureString(component.content) },
{ ...baseResponse, filePath: ensureString(component.xml) },
];

expect(responses).to.deep.equal(expected);
Expand All @@ -572,20 +572,20 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
const result = new RetrieveResult(apiStatus as MetadataApiRetrieveStatus, retrievedSet, localSet);

const responses = result.getFileResponses();
const baseResponse: FileResponse = {
const baseResponse = {
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
};
} as const;
// Since the DECOMPOSED_COMPONENT was in the retrieved ComponentSet but
// not the local source ComponentSet it should have a state of 'Created'
// rather than 'Changed'.
const expected: FileResponse[] = [
Object.assign({}, baseResponse, { filePath: component.content }),
Object.assign({}, baseResponse, { filePath: component.xml }),
{ ...baseResponse, filePath: ensureString(component.content) },
{ ...baseResponse, filePath: ensureString(component.xml) },
{
fullName: DECOMPOSED_COMPONENT.fullName,
filePath: DECOMPOSED_COMPONENT.xml,
filePath: ensureString(DECOMPOSED_COMPONENT.xml),
state: ComponentStatus.Created,
type: DECOMPOSED_COMPONENT.type.name,
},
Expand Down Expand Up @@ -646,7 +646,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: successComponent.fullName,
type: successComponent.type.name,
filePath: successComponent.xml,
filePath: ensureString(successComponent.xml),
},
];

Expand Down Expand Up @@ -695,7 +695,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
filePath: component.xml,
filePath: ensureString(component.xml),
},
];

Expand All @@ -721,7 +721,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
filePath: component.content,
filePath: ensureString(component.content),
},
];

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
"@jridgewell/resolve-uri" "3.1.0"
"@jridgewell/sourcemap-codec" "1.4.14"

"@jsforce/jsforce-node@^3.2.0", "@jsforce/jsforce-node@^3.2.1":
"@jsforce/jsforce-node@^3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.2.1.tgz#00fab05919e0cbe91ae4d873377e56cfbc087b98"
integrity sha512-hjmZQbYVikm6ATmaErOp5NaKR2VofNZsrcGGHrdbGA+bAgpfg/+MA/HzRTb8BvYyPDq3RRc5A8Yk8gx9Vtcrxg==
Expand Down

2 comments on commit 020a111

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 020a111 Previous: fba1a7c Ratio
eda-componentSetCreate-linux 178 ms 191 ms 0.93
eda-sourceToMdapi-linux 1982 ms 2015 ms 0.98
eda-sourceToZip-linux 1821 ms 1843 ms 0.99
eda-mdapiToSource-linux 2846 ms 2840 ms 1.00
lotsOfClasses-componentSetCreate-linux 362 ms 402 ms 0.90
lotsOfClasses-sourceToMdapi-linux 3759 ms 3734 ms 1.01
lotsOfClasses-sourceToZip-linux 3134 ms 3243 ms 0.97
lotsOfClasses-mdapiToSource-linux 3509 ms 3534 ms 0.99
lotsOfClassesOneDir-componentSetCreate-linux 625 ms 616 ms 1.01
lotsOfClassesOneDir-sourceToMdapi-linux 6478 ms 6613 ms 0.98
lotsOfClassesOneDir-sourceToZip-linux 5565 ms 5662 ms 0.98
lotsOfClassesOneDir-mdapiToSource-linux 6324 ms 6509 ms 0.97

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 020a111 Previous: fba1a7c Ratio
eda-componentSetCreate-win32 418 ms 377 ms 1.11
eda-sourceToMdapi-win32 3722 ms 3458 ms 1.08
eda-sourceToZip-win32 2858 ms 2693 ms 1.06
eda-mdapiToSource-win32 5953 ms 5575 ms 1.07
lotsOfClasses-componentSetCreate-win32 895 ms 831 ms 1.08
lotsOfClasses-sourceToMdapi-win32 7411 ms 7371 ms 1.01
lotsOfClasses-sourceToZip-win32 4677 ms 4753 ms 0.98
lotsOfClasses-mdapiToSource-win32 7357 ms 7597 ms 0.97
lotsOfClassesOneDir-componentSetCreate-win32 1479 ms 1476 ms 1.00
lotsOfClassesOneDir-sourceToMdapi-win32 13332 ms 13245 ms 1.01
lotsOfClassesOneDir-sourceToZip-win32 8569 ms 8752 ms 0.98
lotsOfClassesOneDir-mdapiToSource-win32 13454 ms 13501 ms 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.