Repository navigation
Feature/1681 reverse dependency lookup for deploy - #2547
Conversation
Coverage ReportCommit:889e3ccBase: develop@5d57b39 Details (changed files):
|
There was a problem hiding this comment.
Pull request overview
This PR extends the existing --refresh deploy behavior so that refreshing triggered send definitions also works when deploying/updating Content Builder blocks (and other non-email assets) by reverse-looking-up emails that reference those blocks.
Changes:
- Replaces the post-deploy refresh hook to call a new
Asset.refresh()entrypoint instead of refreshing only when the deployed asset is an email. - Adds reverse dependency lookup for blocks via an Asset query (
MUSTCONTAIN) to find emails referencing the updated block, then refreshes related TriggeredSendDefinitions. - Updates/extends the test suite and mock REST/SOAP fixtures to cover the new refresh behavior and request patterns.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/metadataTypes/Asset.js | Implements Asset.refresh() and _findEmailsUsingBlock() and wires refresh into postDeployTasks() |
| @types/lib/metadataTypes/Asset.d.ts | Updates typings to include new helper and refresh() return type |
| @types/lib/metadataTypes/Asset.d.ts.map | Regenerated source map for updated typings |
| test/resourceFactory.js | Extends request-to-fixture mapping to support MUSTCONTAIN query operator in POST body |
| test/type.asset.test.js | Adds test case for deploying a block with refresh: true and validates request count |
| test/type.triggeredSend.test.js | Extends expected refreshed triggered send keys and request count |
| test/type.journey.test.js | Updates expected journey count and request count due to additional mocked interaction |
| test/resources/9999999/triggeredSendDefinition/retrieve-TriggeredSendStatusINdummy,Active-response.xml | Adds an additional TriggeredSendDefinition result to mock “Active” retrieval |
| test/resources/9999999/triggeredSendDefinition/retrieve-CustomerKey=testExistingRefresh_triggeredSend-response.xml | New SOAP fixture for retrieving a specific TriggeredSendDefinition by CustomerKey |
| test/resources/9999999/interaction/v1/interactions/key_testExisting_email_block_refresh/get-response.json | New REST fixture for a specific published interaction containing the triggered send key |
| test/resources/9999999/interaction/v1/interactions/get-response-status=Published.json | Extends published interaction listing to include the new interaction |
| test/resources/9999999/asset/v1/content/assets/query/post-response-contentMUSTCONTAINtestExisting_block_refresh.json | New REST fixture for reverse lookup of emails referencing a block key |
| test/resources/9999999/asset/v1/content/assets/query/post-response-assetType.idIN219,220,221,222,223,224,225,226,227,228,230,232,240,241,242,243,244,245.json | Extends existing asset query fixture to include the new email asset |
| test/resources/9999999/asset/v1/content/assets/334322/patch-response.json | New REST fixture for patching the updated block asset |
| test/mockRoot/deploy/testInstance/testBU/asset/block/testExisting_block_refresh.asset-block-meta.json | Adds mock deploy metadata for the test block asset |
| test/mockRoot/deploy/testInstance/testBU/asset/block/testExisting_block_refresh.asset-block-meta.html | Adds mock deploy HTML content for the test block asset |
|
two things that caught my attention:
|
|
I've created a refresh function specifically for the Asset type. Journey and TriggeredSend already have similar functionality, no changes were necessary. Initially, I considered retrieving published journeys as part of this, but I reverted that approach. I realized that the existing TriggeredSend refresh logic already checks whether a TriggeredSend linked to an email activity is Active. So, the process looks up email keys based on code block keys and then runs refresh on the active TriggeredSends associated with those emails. The logic I've added: Refresh command on asset:
Deploy with refresh: Deploy as usual To find emails referencing a content block, I used the POST I'll refine the condition to something more specific, and add recursion to handle embedded blocks. |
Added recursion to support embedded blocks 😊
|
|
@JoernBerkefeld how do I get rid of this error? I can't see 8.4.0 milestone referenced in the PR |
|
No clue, will have to take another look. But that's not important. If the "required" actions ran successfully we are good. Gimme a few more days for this. I'm working on something BIG right now and will get back to mcdev task afterwards :) |
|
That said, could you open a bug ticket for that error pls? |
Updated warning message to specify that the milestone may be closed or deleted.
…r-deploy # Conflicts: # @types/lib/metadataTypes/Asset.d.ts # @types/lib/metadataTypes/Asset.d.ts.map # lib/metadataTypes/Asset.js # test/resources/9999999/asset/v1/content/assets/query/post-response-assetType.idIN219,220,221,222,223,224,225,226,227,228,230,232,240,241,242,243,244,245.json # test/type.journey.test.js
|
looks like this is finally getting merged @yuliialikhyt |
Broaden Content Builder candidate searches to function names, then verify exact literal keys, IDs and full folder-path names locally. Accept either quote style, whitespace and optional arguments without admitting identifier prefixes or dynamic expressions. Inspect nested views, slots and blocks and fetch full assets only when query content is absent. Preserve recursive traversal and customer-key deduplication. Add seven regression cases and document the literal-only limitation; pagination and refresh contracts are handled separately. Co-authored-by: Cursor <[email protected]>
Request ascending asset IDs and restart shard-limited pagination with the original dependency predicate AND an advancing greater-than ID cursor. Never replace the dependency filter with a cursor-only query that could refresh unrelated emails. Fail explicitly when a shard error has no usable advancing cursor, and rethrow query failures instead of returning partially collected results. Add complete-predicate pagination assertions, unrelated beyond-cursor controls and first-page/partial-result failure regressions. Co-authored-by: Cursor <[email protected]>
Require an explicit asset-key array before caching. An empty selection, missing email legacy IDs or no valid matching triggered sends returns an empty result without falling through to refresh-all semantics. Retain the approved undefined cache arguments. Let discovery and refresh exceptions reach existing command/deploy error handling instead of reporting a successful no-op. Add success, empty-selection, omitted-key, discovery/refresh failure and deploy-semantic regressions. Document that a failed post-deploy refresh does not roll back asset deployment. Co-authored-by: Cursor <[email protected]>
Validate complete dependency OR and cursor AND predicates in the fixture router instead of blindly routing the right operand. Filter nested content and cursor candidates honestly and reject malformed predicates. Exercise real triggered-send discovery, validation and refresh transport for exactly two dependent emails and two JOURNEY sends. Exclude unrelated and inactive controls and assert every pause, publish and restart operation. Add C-to-B-to-A traversal, cycle termination, duplicate candidate and multiply reachable email assertions; strengthen deploy integration to exact SOAP targets. Verification: zero-warning lint and TypeScript checks passed; all 54 test files completed in serial fresh processes with 581 passing and 25 pending. Combined npm test exits zero without a Mocha end event and remains a separately reported cross-suite limitation. Co-authored-by: Cursor <[email protected]>
Pin project Mocha to 11.8.0 for hbenl adapter compatibility and remove the null mochaPath override so the adapter resolves the local package. Initialize normal mock test options before loading deploy fixtures in the explicit asset refresh suite. This keeps logfile transports disabled when the suite runs independently and prevents mock-fs file descriptor 3 from colliding with the adapter IPC channel after filesystem restoration. Assert noLogFile remains enabled. Verified installed hbenl 2.14.4 worker: 606 discovered, 581 passed, 25 skipped, zero failures, finished delivered. Full npm test, lint:fix, lint and TypeScript validation passed. No runtime API changes.
PR details
Introduced refresh option for assets. Added a function to lookup emails that are referencing the block.
Can be run after deploy or separately. Can refresh triggeredSends linked to an email, or if the user runs the function for a code block (asset-other or asset-block), then the function will lookup emails that are using the code block. The function refreshes emails on the business unit it's been invoked on.
Examples:
What changes did you make? (Give an overview)
Further details (optional)
Tested on a couple of different code blocks (htmlblock, buttonblock, freeformblock and other), on a Parent BU and on a child BU. Tested refresh of a shared block.
Retrieve of published journeys was not necessary, the existing functionality of
_refreshTriggeredSendfunction already validates triggeredSend status. Also, journeys with a status Finishing are not accepting new contacts, but could be still sending emails.Checklist