Repository navigation
Conversation
|
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Aparna Goyal <r***@A***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated. |
e8279ce to
8f238d7
Compare
There was a problem hiding this comment.
thanks for putting this together! the resolve/convert side looks solid. I pulled the branch and ran some probes against it. a few things I'd want sorted before merging:
blocking
toSourceFormatignoresmergeWithand always writes tomain/default/d360/.... if the component already lives somewhere else (likeforce-app/d360/..., which is what the tests use), retrieve writes a second copy. the sidecar merge also never runs in that case since it reads the hardcoded path.getD360Destination: if there's nod360segment in the path,trimUntilreturns the absolute path as is. a DLO atmain/default/dataLakeObjects/X.jsonstill resolves, then converts right back onto its own source path. could we either not resolve these or throw a clear error?expandD360ComponentSetbuilds a brand-new set, so it drops destructive changes (they come back as deploys!),apiVersion/sourceApiVersion, and wildcard entries. could it add the peers to the set it's given instead?- deleting a peer-only type is a no-op.
excludeFromManifestalso filters the destructive manifest, so a deletedDataspaceMember/DataModelObjectMappinggives an empty destructiveChanges.xml. tracking then marks it synced, but the org still has it.
design
5. I think the expansion should live in SDR, not the plugin. something like:
- expand in
ComponentSetBuilder.build(), next toresolveDataspaceQualifiedComponents.deploy startanddeploy previewboth go through it, so preview would be accurate - skip members marked for delete
- keep an idempotent version in
ComponentSet.deploy()as a fallback, for deploys with no flags (those get their set from source tracking) and for anything callingdeploy()directly - I'd avoid doing it in
add(), since that would also hit retrieve/delete sets and change the set behind the caller's back - you could find peers by path instead of resolving the whole project:
retrieveWithalready has type + name + dataspace, and the layout is fixed, so just compute the path and checktree.exists. it's cheaper, and a bad file in another package dir can't break the deploy anymore
deletes
6. same root cause as #4, but for edits: deploying just a changed DataModelObjectMapping gives an empty package.xml. should we look up the component that owns it and include that?
7. when a DLO is deleted, does the org clean up its peers? if not, those local files are orphaned and nothing can deploy or delete them
8. just confirming: deleting DataLakeObject:default.myDlo__dll resolves to the shared bare-named local file, right? would project delete source remove it for every dataspace?
9. mergeSidecars keeps a dataspace's old peers if a retrieve returns none for it, so peers deleted in the org never get cleaned up locally
10. if only the .meta.json gets deleted, the payload deploys without it silently. should that error instead?
other
11. nit (non-blocking): calling add() after addWithoutManifestEntry doesn't clear the exclusion
12. the description says 8 types but the diff registers 16, and the last commit's 8 have no tests. could we confirm those all exist in the Metadata API? (MarketSegment vs the existing MarketSegmentDefinition caught my eye)
13. would love to see a retrieve → deploy round-trip test with a non-main/default layout, plus some delete cases
14. could we update HANDBOOK.md too? the new excludeFromManifest property should go in "Breaking Down a Metadata Type Entry", explaining that the type's files still go in the deploy/retrieve payload but it never gets a package.xml entry (constructive or destructive). a short section for the d360 adapter/transformer under Adapters/Transformers would help too
|
@WillieRuemmele Thanks for the thorough review, and for running the probes. I've pushed the fixes as separate commits. Here's where each point stands. Fixed in this push
While testing #11 I also found that requesting both Next: moving the expansion into SDR (#5)Agreed, this is the right home for it. Here's the plan:
Once that's in, the plugin PR isn't needed and we can just bump SDR and Deletes (#4, #6 to #9)
Types (#12)Sorry, the description is out of date: the PR registers 16 types, not 8. I'll update it.
The 8 from the last commit are confirmed against the server. I'm double checking |
|
Thanks for the contribution! Before we can merge this, we need @jamiesampey to sign the Salesforce Inc. Contributor License Agreement. |
7ff595f to
2a9558c
Compare
|
thanks for the updates! path-based peer lookup looks good, and expand is safe to run twice now (verified merge-onto-existing and in-place expand locally). thanks for flagging the delete case, I'd rather not add another option to build() though, every caller should get the same set. could we always expand in build() and make the peer marker stick to the SourceComponent instead of the set? both delete source in PDR and deleteSource in vscode do couple of things still open from before:
|
|
one more, could we add a snapshot project under
that'd lock in the behavior we've been going back and forth on. |
|
a few more after another pass:
|
Add SDR support for Data Cloud dataspace-scoped metadata (CalculatedInsight, DataModelObject). Their on-disk shape differs from every existing type: each component is a pair of generic .json files - a payload <name>.json and a <name>.meta.json sidecar - nested under a d360/dataspace/<dataspace>/<typeDir>/ wrapper, with no -meta.xml. The component fullName is dataspace-scoped (<dataspace>.<name>). - registry: register the two types with dataspaceScoped adapter/transformer strategies and index the `json` suffix so bare .json files resolve as metadata. - resolve: DataspaceScopedSourceAdapter derives the <dataspace>.<name> fullName from the path and folds the .meta.json sidecar into its payload component. - convert: DataspaceScopedMetadataTransformer preserves the full d360/... path in both directions and co-writes the sidecar alongside the payload. - collections: expandDataspaceScopedComponentSet builds the minimal deploy closure from each component's sidecar retrieveWith set.
…package.xml Add DataLakeObject, DataspaceMember, DataModelObjectMapping, SecondaryIndex, DataStreamBundle and DataConnection, and use the plural directory names the Metadata API writes (calculatedInsights, dataModelObjects, ...). Add an excludeFromManifest registry flag and ComponentSet.addWithoutManifestEntry so components that only deploy as part of another one travel as files without their own package.xml entry.
Accept <dataspace>.<name> on deploy for components stored outside any dataspace (e.g. DataLakeObject:default.myDlo__dll, DataStreamBundle:default.myStream), the same name retrieve accepts. The local component is resolved by its bare name, package.xml keeps the requested name, and the retrieveWith closure is limited to that dataspace. Match retrieveWith entries by type and name, so components of different types that share a name are told apart, and honour the dataspace a reference names.
A component outside any dataspace, such as a Data Lake Object, is stored once but can be retrieved through several dataspaces. On retrieve, its payload is overwritten and its .meta.json is merged with the local copy: retrieveWith entries of the dataspaces the retrieve covers are replaced, and those of other dataspaces are kept. On deploy for one dataspace, the closure skips entries that name another dataspace, and the sidecar is sent with retrieveWith trimmed to the requested dataspaces. The local file is left unchanged.
A Data Stream bundle names its Data Lake Object with the dataspace it uses it in, but the DLO is stored outside every dataspace, so its sidecar has none. The closure only matched a peer whose dataspace equalled the one the reference named, so it dropped the DLO and the deploy failed for a missing component. A reference that names a dataspace now also matches a peer stored outside every dataspace.
Adds DataTransform, ActivationTarget, DataAction, DataActionTarget, DataGraph, IdentityResolution, MarketSegment and MarketSegmentActivation to the registry, with the d360 adapter and transformer and strict directory names, matching the existing Data Cloud types.
A manifest entry such as DataLakeObject:default.myDlo__dll matched no local source, because the component is stored once under its bare name. Resolve manifest entries the same way metadata entries already are, so the local component is found and the manifest keeps the requested name.
A Data Cloud file outside a d360 folder used to resolve, then convert back onto its own path. The adapter now rejects it with a clear error. The transformer uses the same layout check, so a dataspace named d360 no longer confuses the path.
The transformer ignored mergeWith and always wrote under main/default, so a component stored anywhere else got a second copy and its sidecar was never merged. It now writes over the component's own files, wherever they are.
A payload whose .meta.json sidecar was deleted used to be sent on its own, and the org then rejected it. The conversion now fails first, naming the missing file and how to restore it.
Calling add() after addWithoutManifestEntry() kept the component out of the manifest. add() now clears that, so the last call decides.
…equested Asking for both myDlo__dll and default.myDlo__dll re-added the local component without a manifest entry, which dropped myDlo__dll from package.xml. A component already in the set is now left as is.
expandD360ComponentSet built a new set, which lost destructive changes, the API versions, and wildcard entries. It now adds the peers to the set it is given and returns that set. Components marked for delete are not walked, and a peer already in the set keeps what the caller asked for it.
The layout under a d360 folder is fixed, so a retrieveWith entry gives the path of each candidate peer. Only those paths are checked now, instead of resolving the whole project to build a lookup index. expandD360ComponentSet takes the set to expand and the registry. A peer is still matched on its sidecar type and name, and its dataspace now comes from its path.
A peer an earlier expansion added has no manifest entry of its own. It is no longer seeded again, since walking a peer outside every dataspace from scratch would pull peers from dataspaces it was not reached in. ComponentSet.isWithoutManifestEntry tells such a component apart.
ComponentSetBuilder.build takes a forDeploy option. With it, the Data Cloud components that deploy together with the requested ones are added while the set is built, so the deploy start and its preview list the same components. Retrieve and delete leave the option off and build the set as before.
A set that was not built for a deploy, such as one from source tracking or from a direct caller, still gets the Data Cloud components that deploy together with the requested ones. A set built for a deploy already has them, and expanding it again adds nothing.
…With The sidecar field that lists the components deployed together with a Data Cloud component is now deploysWith, matching the field the org writes on retrieve.
The type is named for the component it holds. Its files now live under dataStreams.
A custom relationship between two Data Model Objects is retrieved under d360/dataspace/<dataspace>/dataModelObjectRelationships and deployed through the deploysWith of its source Data Model Object. It is never listed in package.xml.
A file in a folder that shares a Data Cloud type's name, such as a test fixture under force-app/test/fixtures/dataConnections, used to throw and stop the whole project from resolving. It is now skipped with a warning, as it is on main, and the rest of the project resolves as before.
A deploysWith entry that named nothing in the component's d360 folder was dropped with only a debug log, so a missing peer, or one in another package directory, silently fell out of the deploy. It now raises a warning that names the component, the peer and the folder searched. Each one is reported once per set, since a deploy can expand the same set again.
Covers each of the 17 registered Data Cloud types: it resolves to its own type under d360/dataspace/<dataspace>/ and under d360/, and only the four types sent with another component are kept out of the manifest.
D360 components can't be deleted through the Metadata API. ComponentSet.deploy now throws D360DeleteError, naming each D360 component marked for delete, before anything is sent to the org. A deploy that deletes only other components goes through as before.
A D360 component outside every dataspace keeps one sidecar for all the dataspaces it was retrieved through. The merge only counted a dataspace as covered when the org returned a peer in it, so a dataspace with no peers left kept its old ones. The merge now reads the package.xml the org returns with the retrieve: - <dataspace>.<name> asked for: that dataspace is covered, even empty. - The bare name asked for: the retrieved sidecar is written as is. - No package.xml, or the component was not asked for: unchanged.
2f89203 to
45c0062
Compare
…eve and delete One Data Lake Object in two dataspaces, each with its own peers, and a shared index. The snapshots show what each deploy sends, how a retrieve for one dataspace is written into the project, and that a delete is refused before anything is sent.
…ntsToDeploy The deploy closure is now a property of the set, so it works however the set was built, including sets built by hand with new ComponentSet() and add(), as source tracking does. getComponentsToDeploy() returns what a deploy sends without changing the set: D360 components with their peers, and a <dataspace>.<name> request under that name with the local file sent for it, listed once. Other members are listed as iterating the set lists them. deploy() and the view share the same closure step, so preview and deploy can't drift apart.
The project holds one Data Lake Object and everything an org retrieve returned with it: its members of the default and custom_ds dataspaces, the data model objects, mappings and relationship in each, and the secondary index they share. The files keep the current sidecar shape. Only the object name was shortened. The tests resolve the project, convert it to a package and back without change, and check that a deploy of the object in each dataspace sends that dataspace's peers while package.xml names only the request.
…rned them The pre-commit formatter rewrote the JSON the org returned, so the package a deploy sends no longer matched the files on disk. Leave those files out of prettier and restore them byte for byte.
… directory A DLO and a data model object that each list the other deploy once each. A peer stored in another package directory isn't pulled in, and the deploy warns that it was left out.
A sidecar that couldn't be parsed was read as having no peers, so the deploy went ahead without them. The deploy now fails, naming the component and the sidecar, and asks to retrieve it again.
A peer that .forceignore excludes was reported as not found. It now gets its own warning that names the ignored file, so leaving a peer out on purpose reads differently from a missing one.
1658749 to
3a5613e
Compare
|
Thanks for the contribution! It looks like @aparnagoy is an internal user so signing the CLA is not required. However, we need to confirm this. |
Add a snapshot project with the D360 files of the d360 project next to an Apex class and a custom object with a field. For a request that names no D360 component, by name or by folder, the deploy set and the package match the same project with its d360 folder removed, and no D360 warning is emitted. Next to a D360 request for one dataspace, the Apex and object files are unchanged. A delete of the Apex class still produces destructiveChangesPost.xml.
The D360 adapter cut the name at the first dot of the file name, so a relationship named ssot__Account__dlm.ssot__Id__c_ssot__Individual__dlm.ssot__FirstName__c resolved as ssot__Account__dlm. Every relationship of an object got the same name, and a deploy by its full name found nothing to send. Only the .json suffix is removed now, so the whole name is kept, inside a dataspace and outside one.
What this does
Adds support for D360 metadata types. They don't fit any existing adapter or transformer, because each component is stored as a pair of JSON files and there's no
-meta.xml:<name>.json<name>.meta.jsoncomponentType,componentName,dataspaceName,deploysWith,dependsOnComponents live under a
d360folder, either in a dataspace or outside one:d360/dataspace/<dataspace>/<typeDir>/<name>.json<dataspace>.<name>d360/<typeDir>/<name>.json<name>The path from
d360down is kept as is in both directions. A file of one of these types outside ad360folder is skipped with a warning, and the rest of the project resolves as before.Nothing in the code is specific to one type. Adding another D360 type is a registry entry, not a code change.
Registered types
package.xmlCalculatedInsightcalculatedInsightsDataModelObjectdataModelObjectsDataLakeObjectdataLakeObjectsDataStreamdataStreamsDataConnectiondataConnectionsDataTransformdataTransformsActivationTargetactivationTargetsDataActiondataActionsDataActionTargetdataActionTargetsDataGraphdataGraphsIdentityResolutionidentityResolutionsMarketSegmentmarketSegmentsMarketSegmentActivationmarketSegmentActivationsDataspaceMemberdataspaceMembersDataModelObjectMappingdataModelObjectMappingsSecondaryIndexsecondaryIndexesDataModelObjectRelationshipdataModelObjectRelationshipsMarketSegmentis the D360 JSON type. It is separate from the existing XMLMarketSegmentDefinition, and the two use different folders and suffixes.How it fits in
d360adapter and transformer, and indexes thejsonsuffix so these files are seen as metadata. The strict folder name picks the type.D360SourceAdapter.meta.jsonsidecar as part of its payload instead of a component of its own.D360MetadataTransformerd360path in both directions and writes the sidecar next to the payload.expandD360ComponentSetdeploysWith.ComponentSetBuilder.buildruns it when called withforDeploy, andComponentSet.deployruns it for sets built any other way. Expanding a set twice adds nothing.resolveDataspaceQualifiedComponents<dataspace>.<name>deploy request to the local file of a component stored outside any dataspace.excludeFromManifestandaddWithoutManifestEntrypackage.xmlentry.Behaviour
Deploy
A component deploys together with the peers in its
deploysWith. Those peers are added to the set as files only, sopackage.xmllists just what was asked for, as on retrieve. The four peer only types are never written to a manifest.The peers are added to the set the deploy was given, so destructive changes,
apiVersion,sourceApiVersionand wildcards are kept. Members marked for delete aren't followed, and a peer already in the set is left as it is.A payload without its
.meta.jsonnow fails with an error that names the missing file. The org rejects it anyway, so this just reports it earlier.When a
deploysWithentry names nothing in the component'sd360folder, the deploy goes on without it and warns, naming the component, the missing peer and the folder searched. Each one is reported once.Deploying for one dataspace
DataLakeObject:default.myDlo__dllworks on retrieve because the org resolves the name. Locally the DLO is stored once asmyDlo__dll. On deploy:myDlo__dll.package.xmlkeepsdefault.myDlo__dll.default, or outside every dataspace, are added.deploysWithnarrowed to those peers. The local file isn't changed.Requesting the bare name follows every dataspace.
Retrieve
A component already in the project is written over its own files, wherever they are. New components go under the default package directory.
A component outside any dataspace can be retrieved through several dataspaces, and each returns its own
deploysWith. The payload is overwritten, and the sidecar is merged with the local one: the new entries replace those of the dataspaces it covers, and the rest are kept. With no local sidecar, the retrieved one is written as is.Matching
deploysWithentriesEach entry is
{ componentType, name, dataspaceName? }. Peers are matched by type and name, since different types can share a name. When an entry names a dataspace, a peer in that dataspace matches, and so does one stored outside every dataspace.dependsOnis informational and isn't used for deploys.Delete
D360 components can't be deleted through the Metadata API. A deploy that would delete one is refused before anything is sent to the org:
destructiveChangesPreordestructiveChangesPostproject delete sourceremoves local files only after the org reports successA component counts as D360 when its registry type uses the
d360adapter. That is exactly the 17 types above, so no existing type is affected.Deploy flow
sequenceDiagram actor User participant CLI as CLI participant SDR as SDR participant Org as Org User->>CLI: sf project deploy start --metadata DataLakeObject:default.myDlo__dll CLI->>SDR: ComponentSetBuilder.build with forDeploy SDR->>SDR: resolve default.myDlo__dll to the local myDlo__dll SDR->>SDR: add deploysWith peers as files only CLI->>SDR: componentSet.deploy SDR->>Org: payloads and sidecars under d360/ Org-->>User: DeployResultChanges in this update
test/fixtures/dataConnections/sample.jsonshould not stop the project from resolvingmainthe same file is simply ignoredD360SourceAdapterchecks the path while resolving. A file with nod360folder above it emitswarning_d360_outside_rootand resolves to nothingd360folder is skipped too. It has to be moved underd360to deploydeploysWithentry that named nothing in the component'sd360folder was dropped with only a debug logwarning_d360_peer_not_found, at most once per set, naming the component, the peer and the folder searchedd360folder. One in another package directory is warned about, not pulled ind360/dataspace/<dataspace>/and underd360/, and only the four peer only types stay out ofpackage.xmlComponentSet.deploy()callsgetD360ComponentsToDeletefirst. Any D360 component indestructiveChangesPreordestructiveChangesPostthrowsD360DeleteErrornaming them, before anything is sent. Local files are keptpackage.xmlthe org returns. A requested dataspace counts as covered even when it returns no peers, and a bare name request takes the org's sidecar as istest/snapshot/sampleProjects/d360has one DLO in two dataspaces, each with its own peers, plus a shared index. It records resolve, convert and back, the package each deploy sends, a retrieve for one dataspace, and the delete refusalComponentSet, so it works however the set was built, including sets from source trackingdeploy()added the peers later, so the two could drift apartComponentSet.getComponentsToDeploy()lists the components as the deploy sends them, without changing the set.deploy()adds the peers from the same lookup, and each<dataspace>.<name>request is listed once, under its name, with its local filebuild()withoutforDeploystill doesn't add the peers, by design, sinceproject delete sourcealso usesbuild()test/snapshot/sampleProjects/d360-orgholds the files an org returned for one DLO retrieved throughdefaultandcustom_ds. The snapshots show the deploy fordefaultsends 10 components and the deploy forcustom_dssends 9deploysWith, and peers in more than one package directoryd360folder, by designD360SidecarError, naming the component and the sidecar, and asks to retrieve the component againdeploysWith, so resolve, convert and retrieve are unchanged.forceignore.forceignoreexcludes the peer, naming the ignored file.forceignorestill wins, so the peer isn't sent. If the org needs it, the org refuses the deploytest/snapshot/sampleProjects/d360-mixedhas the D360 files of thed360project, an Apex class, and a custom object with a field. For the Apex class or the object by name, or theclassesandobjectsfolders, the set and the package match the same project with itsd360folder removed, byte for byte, with no D360 warning. Next to a D360 request for one dataspace, the Apex and object files are unchanged. Deleting the Apex class still givesdestructiveChangesPost.xml. The same packages also match whatmainproducesDelete flow after this change:
sequenceDiagram actor User participant CLI as CLI participant SDR as SDR participant Org as Org User->>CLI: sf project delete source --metadata DataLakeObject:default.myDlo__dll CLI->>SDR: componentSet.deploy with the component marked for delete SDR->>SDR: getD360ComponentsToDelete finds DataLakeObject:default.myDlo__dll SDR-->>CLI: D360DeleteError CLI-->>User: error, local files kept Note over Org: nothing is sentTesting
d360skipped with a warning, a dataspace namedd360,DataModelObjectRelationshipkept apart from the XMLFieldSrcTrgtRelationshipforce-app/d360project to a package and back, writing over existing files, sidecar merge, missing sidecar errorComponentSetaddWithoutManifestEntry, andadd()giving the manifest entry backmain, no D360 warnings, and an Apex delete still deploys. 6 tests.forceignore, and a malformed sidecaryarn buildandyarn testpass: 1485 unit tests and 100 snapshot tests.Round trip against an org, for one DLO in two dataspaces:
DataLakeObject:default.<name>DataLakeObject:custom_ds.<name>defaultpeers and adds 7custom_dspeers, with the shared index listed once. Nodefaultfile changesDataLakeObject:<name><dataspace>.<name>since the DLO is in two dataspaces. No local file changesDataLakeObject:default.<name>DataLakeObject:custom_ds.<name>Next
The expansion now runs inside SDR, so the CLI doesn't call it directly. salesforcecli/plugin-deploy-retrieve#1649 only passes
forDeploy: truetoComponentSetBuilder.build, so the deploy set it reports already holds the peers. Beyond that, the CLI only needs an SDR and@salesforce/source-trackingbump.