Skip to content

fix: adds support for nested InFolder metadata types #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 23, 2021

Conversation

shetzel
Copy link
Contributor

@shetzel shetzel commented Sep 22, 2021

What does this PR do?

Properly resolves nested InFolder metadata types and their respective folder container types.
Report, ReportFolder, Document, DocumentFolder, Dashboard, DashboardFolder, EmailTemplate, EmailFolder

What issues does this PR fix or reference?

@W-9739746@
forcedotcom/cli#1173
forcedotcom/cli#1112

Functionality Before

nested InFolder types failed to convert, deploy and retrieve

Functionality After

successful convert, deploy, retrieve

Testing Notes:
Convert, deploy and retrieve the metadata types listed above as well as Territory2, Territory2Model, Territory2Rule, Territory2Type

@shetzel shetzel requested review from a team as code owners September 22, 2021 16:00
public getFolderContentTypes(): MetadataType[] {
if (!this.folderContentTypes) {
this.folderContentTypes = [];
for (const type of Object.values(this.registry.types)) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this is why the registry has so many other properties? To avoid the perf hit of iterating over every type just to find some that have a property defined? Would it make sense to add a folderContentTypes property to the registry and just access it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By "so many other properties" are you referring to the indexes like suffixes, strictDirectoryNames, and childTypes? If so, yeah that's for better perf. There are only 4 folderContentTypes so I don't think it's worth indexing them. Building the array once makes sense to me though. I think RegistryAccess could use more memoization logic like this.

Copy link
Member

Choose a reason for hiding this comment

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

yeah exactly. I'd prefer not to iterate over the whole registry to find four entries, multiple times... but we could do this optimization later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only done once, not multiple times.

"folderType": "territory2model"
},
"territory2": {
"id": "territory2",
"name": "Territory2",
"suffix": "territory2",
"directoryName": "territories",
"inFolder": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding these back since they are returned by a describemetadata call, and that's what we should be using as the source of truth for type definitions.

Copy link
Contributor

Choose a reason for hiding this comment

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

source of untruth

if (!this.strictFolderTypes) {
this.strictFolderTypes = Object.values(this.registry.strictDirectoryNames).map(
(typeId) => this.registry.types[typeId]
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only need to do this once. The registry data can't change once RegistryAccess is created.

"folderType": "territory2model"
},
"territory2": {
"id": "territory2",
"name": "Territory2",
"suffix": "territory2",
"directoryName": "territories",
"inFolder": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

source of untruth


const isInFolderType = type.inFolder;
const isNestedInFolder =
!fullName.includes('/') || members.some((m) => m.includes(`${fullName}/`));
Copy link
Contributor

Choose a reason for hiding this comment

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

can windows users put \ or \\ in their manifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's valid. It's not a file path, which would be OS specific. It's the server-assigned API name.

@mshanemc mshanemc merged commit b2b90a7 into main Sep 23, 2021
@mshanemc mshanemc deleted the sh/nested-inFolder-types-support branch September 23, 2021 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants