Skip to content

Conversation

@dipratap
Copy link
Contributor

@dipratap dipratap commented Oct 14, 2025

Introduces a new API for deploying LLMO Opportunity suggestions on Edge (Project Tokowaka).
Implementation details are captured in https://wiki.corp.adobe.com/display/AEMSites/Tokowaka+-+Spacecat+Integration and https://wiki.corp.adobe.com/display/AEMSites/Tokowaka+Spacecat+Integration+-+Implementation+Internals.

Briefly, the API first fetches LLMO opportunity - Empty Headings for first iteration, generates a json patch config, uploads on S3, and invalidates the Tokowaka Cloudfront CDN cache.
The API is expected to be called from LLMO UI when the user clicks on deploy suggestion button.

@github-actions
Copy link

This PR will trigger a patch release when merged.

@dipratap dipratap changed the title fix: add tokowaka client [wip] fix: add tokowaka client Oct 23, 2025
@dipratap dipratap requested a review from nit23uec October 23, 2025 07:00
const response = await this.client.send(command);
const invalidation = response.Invalidation;

this.log.info(`CloudFront cache invalidation initiated: ${invalidation.Id}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets also log the time to invalidate the cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @private
*/
#initializeClient() {
/* c8 ignore start */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use nock to. mock the cdn requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used aws-sdk-client-mock, nock faces some issues with aws clients.

import { S3Client } from '@aws-sdk/client-s3';

export interface TokawakaPatch {
op: 'replace' | 'add' | 'prerender';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace
appendChild
insertBefore
insertAfter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


export interface TokawakaPatch {
op: 'replace' | 'add' | 'prerender';
selector?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selector is mandatory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated index.d.ts

selector?: string;
value?: string;
attribute?: string;
element?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated index.d.ts

/**
* Akamai CDN client implementation
*/
export class AkamaiCdnClient extends BaseCdnClient {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove AkamaiCdnClient. its not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated index.d.ts

return s3Path;
} catch (error) {
this.log.error(`Failed to upload Tokowaka config to S3: ${error.message}`, error);
throw this.#createError(`S3 upload failed: ${error.message}`, HTTP_INTERNAL_SERVER_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for displaying error in UI, we should not highlight internal impl details like S3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is not going to the UI, in case of unexpected errors - UI will get "Deployment failed - Internal Server Error"

this.log.info(`CDN cache invalidation completed: ${JSON.stringify(result)}`);
return result;
} catch (error) {
this.log.error(`Failed to invalidate CDN cache: ${error.message}`, error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tokowaka CDN cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated log

const newConfig = this.generateConfig(site, opportunity, eligibleSuggestions);

if (Object.keys(newConfig.tokowakaOptimizations).length === 0) {
this.log.warn('');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty warn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@nit23uec nit23uec merged commit 7af58b0 into main Oct 29, 2025
8 of 9 checks passed
@nit23uec nit23uec deleted the tokowaka-json branch October 29, 2025 15:33
solaris007 pushed a commit that referenced this pull request Oct 29, 2025
@solaris007
Copy link
Member

🎉 This PR is included in version @adobe/spacecat-shared-data-access-v2.76.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

solaris007 pushed a commit that referenced this pull request Oct 30, 2025
# @adobe/spacecat-shared-tokowaka-client-v1.0.0 (2025-10-30)

### Bug Fixes

* add releaserc to tokowaka client ([#1071](#1071)) ([e49f02c](e49f02c))
* update publish config for tokowaka client ([#1070](#1070)) ([066d5a1](066d5a1))

### Features

* add tokowaka client ([#1025](#1025)) ([7af58b0](7af58b0))
@solaris007
Copy link
Member

🎉 This PR is included in version @adobe/spacecat-shared-tokowaka-client-v1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants