@adobe/spacecat-shared-tokowaka-client 1.18.2 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [@adobe/spacecat-shared-tokowaka-client-v1.19.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.18.2...@adobe/spacecat-shared-tokowaka-client-v1.19.0) (2026-06-03)
2
+
3
+ ### Features
4
+
5
+ * **tokowaka-client:** mark path-level suggestions as coveredByDomainWide on domain-wide deploy ([#1648](https://github.com/adobe/spacecat-shared/issues/1648)) ([9cc5992](https://github.com/adobe/spacecat-shared/commit/9cc5992bb98acf9da48a432fedfbec694d30fe23))
6
+
1
7
  ## [@adobe/spacecat-shared-tokowaka-client-v1.18.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.18.1...@adobe/spacecat-shared-tokowaka-client-v1.18.2) (2026-06-02)
2
8
 
3
9
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-tokowaka-client",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Tokowaka Client for SpaceCat - Edge optimization config management",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.js CHANGED
@@ -1532,12 +1532,14 @@ class TokowakaClient {
1532
1532
  if (!isEdgeDeployableSuggestionStatus(s.getStatus())) {
1533
1533
  return false;
1534
1534
  }
1535
- if (isPatternSuggestion(s)) {
1536
- return false;
1537
- }
1538
1535
  if (s.getData()?.edgeDeployed) {
1539
1536
  return false;
1540
1537
  }
1538
+ // Path-level pattern suggestions (not domain-wide) are fully covered by a
1539
+ // domain-wide deployment. Other pattern suggestions (including other DW ones) are not.
1540
+ if (isPatternSuggestion(s)) {
1541
+ return coverageField === 'coveredByDomainWide' && !s.getData()?.isDomainWide;
1542
+ }
1541
1543
  const url = s.getData()?.url;
1542
1544
  return url && matchers.some((match) => match(url));
1543
1545
  });
@@ -3117,6 +3117,55 @@ describe('TokowakaClient', () => {
3117
3117
  expect(coveredData).to.not.have.property('coveredByDomainWide');
3118
3118
  });
3119
3119
 
3120
+ it('cleans up coveredByDomainWide on path-level suggestions when rolling back domain-wide', async () => {
3121
+ const prerenderOpportunity = { getId: () => 'opp-dw', getType: () => 'prerender' };
3122
+ const dwSuggestion = {
3123
+ getId: () => 'dw-1',
3124
+ getData: () => ({
3125
+ isDomainWide: true,
3126
+ allowedRegexPatterns: ['/*'],
3127
+ edgeDeployed: Date.now(),
3128
+ }),
3129
+ setData: sinon.stub(),
3130
+ setUpdatedBy: sinon.stub(),
3131
+ save: sinon.stub().resolves(),
3132
+ };
3133
+ const pathSuggestion = {
3134
+ getId: () => 'path-1',
3135
+ getData: () => ({
3136
+ allowedRegexPatterns: ['/products/*'],
3137
+ coveredByDomainWide: 'dw-1',
3138
+ }),
3139
+ setData: sinon.stub(),
3140
+ setUpdatedBy: sinon.stub(),
3141
+ save: sinon.stub().resolves(),
3142
+ };
3143
+
3144
+ sinon.stub(client, 'fetchMetaconfig').resolves({
3145
+ siteId: 'site-123',
3146
+ prerender: { allowList: ['/*'] },
3147
+ });
3148
+ sinon.stub(client, 'uploadMetaconfig').resolves();
3149
+
3150
+ const result = await client.rollbackSuggestions(
3151
+ mockSite,
3152
+ prerenderOpportunity,
3153
+ [dwSuggestion],
3154
+ { allSuggestions: [dwSuggestion, pathSuggestion], updatedBy: 'test@example.com' },
3155
+ );
3156
+
3157
+ expect(result.succeededSuggestions).to.include(dwSuggestion);
3158
+ expect(pathSuggestion.setData.calledOnce).to.be.true;
3159
+ const pathData = pathSuggestion.setData.firstCall.args[0];
3160
+ expect(pathData).to.not.have.property('coveredByDomainWide');
3161
+ expect(pathData).to.have.property('allowedRegexPatterns');
3162
+ // Verify the cleaned-up path suggestion was actually persisted via saveMany
3163
+ expect(client.dataAccess.Suggestion.saveMany).to.have.been.calledWith(
3164
+ sinon.match((arr) => arr.includes(pathSuggestion)),
3165
+ sinon.match.any,
3166
+ );
3167
+ });
3168
+
3120
3169
  it('cleans up covered suggestions (coveredByPattern) when rolling back a path-level pattern', async () => {
3121
3170
  const prerenderOpportunity = { getId: () => 'opp-p', getType: () => 'prerender' };
3122
3171
  const pathSuggestion = {
@@ -5909,6 +5958,51 @@ describe('TokowakaClient', () => {
5909
5958
  expect(result.coveredSuggestions).to.not.include(dw2);
5910
5959
  });
5911
5960
 
5961
+ it('should mark path-level pattern suggestions as coveredByDomainWide when domain-wide is deployed', async () => {
5962
+ const dw = makeSuggestion('dw1', {
5963
+ isDomainWide: true,
5964
+ allowedRegexPatterns: ['^https://example\\.com/.*'],
5965
+ });
5966
+ const pathLevel = makeSuggestion('path1', {
5967
+ allowedRegexPatterns: ['/products/*'],
5968
+ });
5969
+
5970
+ fetchMetaconfigStub.resolves({ siteId: 'site-123' });
5971
+
5972
+ const result = await client.deployToEdge({
5973
+ site: mockSite,
5974
+ opportunity: mockOpportunity,
5975
+ targetSuggestions: [dw],
5976
+ allSuggestions: [dw, pathLevel],
5977
+ });
5978
+
5979
+ expect(result.coveredSuggestions).to.include(pathLevel);
5980
+ expect(pathLevel.getData()).to.have.property('coveredByDomainWide', 'dw1');
5981
+ });
5982
+
5983
+ it('should not mark already-deployed path-level suggestions as coveredByDomainWide', async () => {
5984
+ const dw = makeSuggestion('dw1', {
5985
+ isDomainWide: true,
5986
+ allowedRegexPatterns: ['^https://example\\.com/.*'],
5987
+ });
5988
+ const pathLevel = makeSuggestion('path1', {
5989
+ allowedRegexPatterns: ['/products/*'],
5990
+ edgeDeployed: Date.now(),
5991
+ });
5992
+
5993
+ fetchMetaconfigStub.resolves({ siteId: 'site-123' });
5994
+
5995
+ const result = await client.deployToEdge({
5996
+ site: mockSite,
5997
+ opportunity: mockOpportunity,
5998
+ targetSuggestions: [dw],
5999
+ allSuggestions: [dw, pathLevel],
6000
+ });
6001
+
6002
+ expect(result.coveredSuggestions).to.not.include(pathLevel);
6003
+ expect(pathLevel.getData()).to.not.have.property('coveredByDomainWide');
6004
+ });
6005
+
5912
6006
  it('should not mark non-NEW suggestions as covered', async () => {
5913
6007
  const dw = makeSuggestion('dw1', {
5914
6008
  isDomainWide: true,