Skip to content

Conversation

@kmaschi
Copy link
Member

@kmaschi kmaschi commented Jun 3, 2025

This PR includes features and fixes for the plugin-hooks repository.

  • Migration of project from JS to TS.
    • Includes developer tooling, actions, linting, and test coverage.
    • Builds CJS and ESM for NPM use cases.
  • Adds afterAll hook
  • Adds beforeSource/afterSource hooks

Description

Current state of this project is in JS with very minimal/non-existent test coverage. Moving forward we would like to have confidence in changes through test coverage. The move to TypeScript will improve developer experience working within the package and provide useful typings that can be used by users creating hooks.

BeforeSource hook executes once before the fetch to a named source. It has access to the request allowing users to perform actions such as modifying request headers.

AfterSource hook executes once after the fetch to a named source. It has access to the response allowing users to perform actions such as modifying response headers.

AfterAll hook executes once before the final response is sent to the client.

Related Issue

CEXT-1441

Motivation and Context

Goals of better developer and user experience.

  • Better developer experience in TypeScript.
  • Test coverage
  • Prettier/linting for code quality/consistency.
  • Typings for developers.

How Has This Been Tested?

  • Changes lint, test, and build successful in GitHub Actions
  • Published an alpha to NPM 0.3.5-alpha.4

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@kmaschi
Copy link
Member Author

kmaschi commented Jun 3, 2025

Created as epic to test NPM publish.

@kmaschi kmaschi marked this pull request as ready for review June 3, 2025 14:22
@dani97 dani97 force-pushed the epic/ts-migration branch from dc31d32 to 451949c Compare June 24, 2025 14:07
amolina-adobe
amolina-adobe previously approved these changes Jul 31, 2025
Kristopher Maschi and others added 7 commits July 31, 2025 18:15
kmaschi and others added 8 commits August 3, 2025 12:26
…ferently.

- Updated types to make clear the properties available to each hook handler.
- Handled stacked beforeAll/afterAll hooks ensuring both local and remove functions can work with serialized payload.
- Handled stacked beforeAll/afterAll hooks ensuring handlers can work with serialized response data.
- Updated tests.
amolina-adobe
amolina-adobe previously approved these changes Aug 5, 2025
brasewel
brasewel previously approved these changes Aug 6, 2025
Updating readme. Excluding examples
@brasewel brasewel dismissed stale reviews from amolina-adobe and themself via 0e2c9c5 August 6, 2025 14:30
@kmaschi kmaschi merged commit c66db1c into develop Aug 6, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants