-
Notifications
You must be signed in to change notification settings - Fork 45
Feature/1681 reverse dependency lookup for deploy #2547
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
base: develop
Are you sure you want to change the base?
Changes from 10 commits
3c33340
ed0d0c6
d45541e
950dd17
f8cef1e
5c4c116
3f4c28f
5b18ab6
555fe6a
91f320f
0e10944
3cf3e1c
3998ace
37e5c9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -848,21 +848,103 @@ class Asset extends MetadataType { | |||||||||||||||||||||||||||||||||||||||||||||
| if (Util.OPTIONS.refresh) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (createdUpdated.updated) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // only run this if assets were updated. for created assets we do not expect | ||||||||||||||||||||||||||||||||||||||||||||||
| await this._refreshTriggeredSend(metadata); | ||||||||||||||||||||||||||||||||||||||||||||||
| await this.refresh(Object.keys(metadata)); | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| Util.logger.warn( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'You set the --refresh flag but no updated assets found. Skipping refresh of triggeredSendDefinitions.' | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * helper for {@link Asset}. finds active emails that reference the updated block | ||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||
| * @private | ||||||||||||||||||||||||||||||||||||||||||||||
| * @param {string[]} keys metadata keys | ||||||||||||||||||||||||||||||||||||||||||||||
| * @returns {Promise.<object[]>} - array of assets | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| static async _findEmailsUsingBlock(keys) { | ||||||||||||||||||||||||||||||||||||||||||||||
| const uri = '/asset/v1/content/assets/query'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const emailCondition = { | ||||||||||||||||||||||||||||||||||||||||||||||
| property: 'assetType.name', | ||||||||||||||||||||||||||||||||||||||||||||||
| simpleOperator: 'in', | ||||||||||||||||||||||||||||||||||||||||||||||
| value: this.definition.extendedSubTypes.message, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Build metadata keys condition | ||||||||||||||||||||||||||||||||||||||||||||||
| // @ts-ignore | ||||||||||||||||||||||||||||||||||||||||||||||
| const metadataCondition = keys.reduce((acc, key, index) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const condition = { | ||||||||||||||||||||||||||||||||||||||||||||||
| property: 'content', | ||||||||||||||||||||||||||||||||||||||||||||||
| simpleOperator: 'mustContain', | ||||||||||||||||||||||||||||||||||||||||||||||
| value: key, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (index === 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return condition; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||
| leftOperand: acc, | ||||||||||||||||||||||||||||||||||||||||||||||
| logicalOperator: 'OR', | ||||||||||||||||||||||||||||||||||||||||||||||
| rightOperand: condition, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||
| const query = { | ||||||||||||||||||||||||||||||||||||||||||||||
| leftOperand: emailCondition, | ||||||||||||||||||||||||||||||||||||||||||||||
| logicalOperator: 'AND', | ||||||||||||||||||||||||||||||||||||||||||||||
| rightOperand: metadataCondition, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
| /** @type {AssetRequestParams} */ | ||||||||||||||||||||||||||||||||||||||||||||||
| const payload = { | ||||||||||||||||||||||||||||||||||||||||||||||
| page: { | ||||||||||||||||||||||||||||||||||||||||||||||
| page: 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| pageSize: 50, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| // @ts-ignore | ||||||||||||||||||||||||||||||||||||||||||||||
| query: query, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
| let items = []; | ||||||||||||||||||||||||||||||||||||||||||||||
| let moreResults; | ||||||||||||||||||||||||||||||||||||||||||||||
| let lastPage = 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||||||||||||||||
| payload.page.page = lastPage + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.client.rest.post(uri, payload); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (response?.items?.length) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // sometimes the api will return a payload without items | ||||||||||||||||||||||||||||||||||||||||||||||
| // --> ensure we only add proper items-arrays here | ||||||||||||||||||||||||||||||||||||||||||||||
| items = items.concat(response.items); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| // check if any more records | ||||||||||||||||||||||||||||||||||||||||||||||
| if (response?.message?.includes('all shards failed')) { | ||||||||||||||||||||||||||||||||||||||||||||||
| payload.query = { | ||||||||||||||||||||||||||||||||||||||||||||||
| property: 'id', | ||||||||||||||||||||||||||||||||||||||||||||||
| simpleOperator: 'greaterThan', | ||||||||||||||||||||||||||||||||||||||||||||||
| value: items.at(-1).id, | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
| lastPage = 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| moreResults = true; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+931
to
+937
|
||||||||||||||||||||||||||||||||||||||||||||||
| payload.query = { | |
| property: 'id', | |
| simpleOperator: 'greaterThan', | |
| value: items.at(-1).id, | |
| }; | |
| lastPage = 0; | |
| moreResults = true; | |
| if (!items.length) { | |
| // cannot apply greaterThan pagination without at least one item | |
| Util.logger.warn( | |
| 'Asset._findEmailsUsingBlock: received "all shards failed" response without any items; stopping pagination.' | |
| ); | |
| moreResults = false; | |
| } else { | |
| payload.query = { | |
| property: 'id', | |
| simpleOperator: 'greaterThan', | |
| value: items.at(-1).id, | |
| }; | |
| lastPage = 0; | |
| moreResults = true; | |
| } |
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh() declares keyArr as optional in the JSDoc/typings, but the implementation does for (const key of keyArr) which will throw if keyArr is undefined (e.g., if a caller invokes refresh without keys). Either make the parameter required everywhere (update docs/types) or add a default/guard (treat missing keys as an empty list or throw a clear error).
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh() passes toPublish (an array) into _refreshTriggeredSend(), but _refreshTriggeredSend() expects a MetadataTypeMap keyed by customerKey and iterates Object.keys(metadata) to access items. With an array, keys become "0", "1", ... which is brittle and can break if callers ever pass a non-array iterable. Consider normalizing toPublish into an object keyed by customerKey (and ideally de-dupe) before calling _refreshTriggeredSend(), or update _refreshTriggeredSend() to explicitly accept an array and iterate items directly.
| return toPublish.length ? await this._refreshTriggeredSend(toPublish) : []; | |
| const toPublishMap = | |
| toPublish.length > 0 | |
| ? toPublish.reduce( | |
| /** | |
| * @param {MetadataTypeMap} acc | |
| * @param {MetadataTypeItem} item | |
| * @returns {MetadataTypeMap} | |
| */ | |
| (acc, item) => { | |
| if (item && item.customerKey) { | |
| acc[item.customerKey] = item; | |
| } | |
| return acc; | |
| }, | |
| /** @type {MetadataTypeMap} */ ({}) | |
| ) | |
| : /** @type {MetadataTypeMap} */ ({}); | |
| return Object.keys(toPublishMap).length | |
| ? await this._refreshTriggeredSend(toPublishMap) | |
| : []; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <table | ||
| cellpadding="0" | ||
| cellspacing="0" | ||
| width="100%" | ||
| role="presentation" | ||
| style="min-width: 100%; " | ||
| class="stylingblock-content-wrapper" | ||
| > | ||
| <tr> | ||
| <td class="stylingblock-content-wrapper camarker-inner"> | ||
| <h1>Test Block</h1> | ||
| <div>This is a test block</div> | ||
| </td> | ||
| </tr> | ||
| </table> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "id": 334322, | ||
| "customerKey": "testExisting_block_refresh", | ||
| "objectID": "baf8348d-61d5-451f-948a-28045e41e50c", | ||
| "assetType": { | ||
| "id": 220, | ||
| "name": "codesnippetblock", | ||
| "displayName": "Code Snippet Block" | ||
| }, | ||
| "name": "testExisting_block_refresh", | ||
| "createdDate": "2025-10-24T12:19:21.2-06:00", | ||
| "createdBy": { | ||
| "id": 724496218, | ||
| "email": "test@test.com", | ||
| "name": "Yuliia Likhytska", | ||
| "userId": "724496218" | ||
| }, | ||
| "modifiedDate": "2026-03-15T11:37:51.38-06:00", | ||
| "modifiedBy": { | ||
| "id": 724496218, | ||
| "email": "test@test.com", | ||
| "name": "Yuliia Likhytska", | ||
| "userId": "724496218" | ||
| }, | ||
| "category": { | ||
| "id": 370568 | ||
| }, | ||
| "modelVersion": 2, | ||
| "r__folder_Path": "Content Builder" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.