feat: add path-level prerender deploy support to tokowaka-client#1598
feat: add path-level prerender deploy support to tokowaka-client#1598ssilare-adobe wants to merge 4 commits into
Conversation
|
This PR will trigger a minor release when merged. |
…stions in rollbackSuggestions
…isDomainWide checks
| } | ||
|
|
||
| /** Returns true if the suggestion is a path-level prerender suggestion. */ | ||
| function isPathSuggestion(suggestion) { |
There was a problem hiding this comment.
lets use coveredByPattern prop in the schema for the segment related suggestions.
isCoveredByPathPattern should be a generic method that returns true if suggestion.getData()?.coveredByPattern || suggestion.getData()?.isDomainWide
There was a problem hiding this comment.
@nit23uec This checks if the suggestion is a path level suggestion and not if the suggestion is covered by path level suggestion.
What this function checks:
https://adobe.com/products/* -> Path level suggestion -> returns true
If we need to add coveredByPattern, it should come on the suggestions which are covered by pattern like https://adobe.com/products/test rather than on path level suggestion.
| // Validate which suggestions can be rolled back | ||
| // Separate metaconfig-based suggestions (path and domain-wide allowList entries) | ||
| // from per-URL suggestions — each group is rolled back via a different code path. | ||
| const metaconfigSuggestions = suggestions.filter((s) => { |
There was a problem hiding this comment.
nitpick: metaconfig is an impl detail.
lets use patternCoveredSuggestions to filter segment and domain wide suggestions
|
|
||
| try { | ||
| // eslint-disable-next-line no-await-in-loop | ||
| const metaconfig = await this.fetchMetaconfig(baseURL); |
There was a problem hiding this comment.
earlier also, we used to support a domain wide rollback - can you pls make sure we are usig the same code to rollback such suggestions. Pls sync with @dipratap
|
|
||
| targetSuggestions.forEach((suggestion) => { | ||
| const data = suggestion.getData(); | ||
| if (data?.isDomainWide === true) { |
There was a problem hiding this comment.
better to reuse the generic method coveredByPattern proposed above to do any handling of such suggestions.
| if (Array.isArray(allowedRegexPatterns) && allowedRegexPatterns.length > 0) { | ||
| domainWideSuggestions.push({ suggestion, allowedRegexPatterns }); | ||
| } | ||
| } else if (isPathSuggestion(suggestion)) { |
There was a problem hiding this comment.
domainwide and pathbased should be handled exactly on a similar basis. there should be no separate if else required for them.
we did a mistake when we introduced domainWide prop for the /* suggestions - we should have just introduced a generic prop coveredByPattern to cover any regex case.
Context
This is PR 1 of 4 in the end-to-end path-level prerender suggestions feature. It must ship and be consumed by `spacecat-api-service` before path deploy requests can be made.
Feature overview: The prerender audit today generates per-URL and domain-wide suggestions. This feature adds a third tier — path-level suggestions (e.g., `/products/*`) — that group URLs by their first path segment. When a path is deployed, the CDN allow-list is updated with that path pattern (append semantics), and per-URL suggestions under that prefix are marked as covered. See the full design plan for details.
Deployment sequence
What this PR does
Extends
packages/spacecat-shared-tokowaka-clientto handlepathType: truesuggestions in thedeployToEdgeandrollbackSuggestionsmethods.Key changes
deployToEdge— path suggestions use append semantics:data.pathType === trueaspathSuggestions(separate fromdomainWideSuggestionsand per-URLvalidSuggestions)metaconfig.prerender.allowList→ append the new path pattern (deduped viaSet) → write backedgeDeployedtimestamp on the suggestion after successful deploycoveredSuggestionsfor per-URL suggestions whose URL starts with the deployed path prefixrollbackSuggestions— path and domain-wide suggestions use remove-one semantics:pathType: true) and domain-wide (isDomainWide: true) suggestions are classified beforefilterEligibleSuggestions(the prerender mapper'scanDeployrejects them since they have nourlfield)allowedRegexPatterns[0]fromallowList, and writing backallowListis empty after removal, deletes theprerenderkey entirely/*intact when rolling back/products/*)failedSuggestions; other suggestions in the same batch are unaffectedDomain-wide deploy updated (no longer full-replace):
/*into the existingallowListinstead of full-replacing/*from the list via the same remove-one pathConcurrent path deploys (race condition mitigation):
allowListallowListbehaviour summary/*)/products/*)/*into existing list/*, delete key if emptyTest additions (
packages/spacecat-shared-tokowaka-client/test/index.test.js)/products/*whenallowListis empty →['/products/*']/products/*whenallowList: ['/*']→['/*', '/products/*'](domain-wide preserved)allowList/products/*removes only that pattern, leaves/*intactprerenderkey entirely/*into existing list (not full replace)/*coveredSuggestionsreturns matching per-URL suggestions for path deploysprerenderkeyallowListallowedRegexPatternsis missingstatusCode: 500when upload throwsTest plan
npm test -w packages/spacecat-shared-tokowaka-client— all 718 tests pass, 100% line/branch/statement coverage🤖 Generated with Claude Code