-
Couldn't load subscription status.
- Fork 14
fix: add tokowaka client #1025
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: main
Are you sure you want to change the base?
fix: add tokowaka client #1025
Conversation
|
This PR will trigger a patch release when merged. |
| const response = await this.client.send(command); | ||
| const invalidation = response.Invalidation; | ||
|
|
||
| this.log.info(`CloudFront cache invalidation initiated: ${invalidation.Id}`); |
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.
lets also log the time to invalidate the cache
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.
done
| * @private | ||
| */ | ||
| #initializeClient() { | ||
| /* c8 ignore start */ |
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.
lets use nock to. mock the cdn requests.
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.
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'; |
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.
replace
appendChild
insertBefore
insertAfter
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.
done
|
|
||
| export interface TokawakaPatch { | ||
| op: 'replace' | 'add' | 'prerender'; | ||
| selector?: string; |
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.
selector is mandatory
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.
Updated index.d.ts
| selector?: string; | ||
| value?: string; | ||
| attribute?: string; | ||
| element?: string; |
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.
element is not required.
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.
Updated index.d.ts
| /** | ||
| * Akamai CDN client implementation | ||
| */ | ||
| export class AkamaiCdnClient extends BaseCdnClient { |
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.
lets remove AkamaiCdnClient. its not required.
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.
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); |
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.
for displaying error in UI, we should not highlight internal impl details like S3.
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.
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); |
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.
Tokowaka CDN cache
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.
updated log
| const newConfig = this.generateConfig(site, opportunity, eligibleSuggestions); | ||
|
|
||
| if (Object.keys(newConfig.tokowakaOptimizations).length === 0) { | ||
| this.log.warn(''); |
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.
empty warn?
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.
fixed
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.