feat(core-consent): extend generator with consent template + fix withCapture brand propagation
- Add consent to CORE_PACKAGE_GENERATORS in turbo/generators/config.ts so pnpm turbo gen core-package consent is a valid command (not hand-rollable) - Create turbo/generators/templates/core-package/consent/ mirroring the analytics template shape (AGENTS.md, package.json, tsconfig, turbo, vitest, eslint, src/index.ts scaffolds) - Regenerate packages/core-consent/ from the new template (replaces the previous hand-rolled attempt that violated the generator-first rule) - Add __consentChecked to withCapture PROPAGATED_BRANDS so the brand bubbles through the full withSpan→withCapture wrapper chain to the outermost binding that assertFeatureConformance reads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,19 +5,16 @@ import { attachBrand } from "@repo/core-shared/conformance";
|
||||
export type { ConsentChecked };
|
||||
|
||||
/**
|
||||
* Use-case wrapper applied at DI bind time. The wrapper is a thin closure
|
||||
* that forwards to `fn` unchanged and carries the `__consentChecked` brand.
|
||||
* Use-case wrapper applied at DI bind time. Attaches the `__consentChecked`
|
||||
* brand so the boot-time assertion can verify consent-gated use cases were
|
||||
* bound through the consent-aware path.
|
||||
*
|
||||
* The forward closure keeps the brand on a fresh function so the original
|
||||
* `fn` reference is not mutated — important when the same factory output is
|
||||
* used elsewhere unwrapped (dev-seed paths, tests).
|
||||
*
|
||||
* Composition order (innermost to outermost):
|
||||
* withSpan → withCapture → withAudit → withAnalytics → withConsent → factory(deps)
|
||||
*
|
||||
* The wrapper exists to:
|
||||
* (1) require callers to pass the consent instance at bind time (dep is available)
|
||||
* (2) attach the `__consentChecked` brand so the boot-time assertion can verify
|
||||
* consent-gated use cases were bound through the consent-aware path.
|
||||
*/
|
||||
export function withConsent<Args extends unknown[], R>(
|
||||
consent: IConsent,
|
||||
|
||||
Reference in New Issue
Block a user