Skip to content

Conversation

@chris-freeman-glean
Copy link
Contributor

What

Follow-up to #96 to fix a couple of post-merge issues:

  • Export hooks modules via package subpath exports (./hooks, ./hooks/*.js, ./hooks/*) so consumers can import XGleanOptions as documented.
  • Make the export changes regeneration-safe via .speakeasy/gen.yaml (typescript.additionalPackageJSON).
  • Harden src/hooks/x-glean.ts by removing the unsafe cast, adding runtime guards, and aligning X_GLEAN_INCLUDE_EXPERIMENTAL semantics to only enable the header when the env var is explicitly true (case-insensitive). Any other non-empty value disables/omits the header; empty/whitespace falls back to constructor options.
  • Update README.md constructor options example to be TS-safe (satisfies SDKOptions & XGleanOptions).
  • Expand unit tests for the new env semantics and runtime-guard behavior.

Why

After #96, TypeScript consumers could no longer pass excludeDeprecatedAfter / includeExperimental as constructor options without excess-property errors, and XGleanOptions was not importable from the published package. Also, env var parsing previously allowed accidental values like X_GLEAN_INCLUDE_EXPERIMENTAL=false to be sent as a header.

Test Plan

  • npx vitest run src/__tests__/x-glean.test.ts
  • npm run lint
  • npm run build
  • Verified import('@gleanwork/api-client/hooks/x-glean-options.js') resolves with the new export map.

Make hooks importable via ./hooks/* exports (regen-safe via .speakeasy/gen.yaml) and align X_GLEAN_INCLUDE_EXPERIMENTAL semantics to only enable on true; update docs and tests.
Add explicit ./hooks and ./hooks/*.js exports (regen-safe) so consumers can import hooks modules with .js specifiers without double-extension resolution issues.
@chris-freeman-glean chris-freeman-glean requested a review from a team as a code owner February 3, 2026 19:09
@chris-freeman-glean chris-freeman-glean merged commit 04fabd8 into main Feb 3, 2026
3 checks passed
@chris-freeman-glean chris-freeman-glean deleted the cfreeman/system-reminder-x-glean-hooks-exports branch February 3, 2026 19:30
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.

2 participants