Repository navigation
feat: universal event-driven cache invalidation - #60
Merged
Merged
Conversation
…t consumer
- Move the HTTP dispatcher and receiver into one /webhooks entrypoint and
rename http() to createWebhookDispatcher().
- Add /consumers with createCacheConsumer() and a shared operation runner.
- Add createNextCacheConsumer(); createCacheInvalidationHandler() now takes
the cache definition directly and composes the shared ingress.
- Receiver supports { secret }, { secret, decode } and { adapter } with
bounded output validation, normalized size limits and adapter timeouts.
- Fix de-duplication treating Uint8Array([1]) and {"0":1} as identical.
…additive excludeFields - cacheInvalidation() accepts webhooks (native dispatcher) or dispatcher. - Per-target model filters (collections/globals) or a functional predicate, validated against the effective configuration; affected models route too. - exclude removes models from every path; one effective configuration now drives hooks, media dependency discovery and routing validation. - excludeFields from global, central, local and media levels are combined. - Remove the public hooks option; the plugin installs every lifecycle hook. - Media: centrally enabled globals are discovered, media:false is supported, explicit disablement and exclusion are no longer overridden, and the media collection slug is no longer hard-coded in locale resolution. - Dispatcher targets accept a synchronous event predicate; a failing predicate is a target failure, not a skip.
- Real-HTTP multi-target and shared-collection routing integration tests. - Next.js production fixture exercises adapter and decoder modes. - Type tests for ingress, consumer and Payload configuration contracts. - Fix a native-path regression: canonicalize events only on identity collisions and mark validated batches only when handing them to a consumer. - Export CacheForbiddenError; update README, AGENTS, SECURITY, PERFORMANCE and add the release changeset.
…ization depth - Native batches are no longer marked as normalized, so a consumer re-validates them under its own maxNormalizedBytes. - Duplicate-identity comparison rejects deeply nested data instead of overflowing the stack. - Move the Payload and Next.js example apps to the 0.5 API.
…apters against official SDKs - Payload logs keep the error class and a short machine code instead of the exception message, and dispatcher failures log codes only. - Add regression tests proving secrets, signatures, bodies and exception messages cannot reach receiver, consumer or Payload logs. - Add reference Contentful and Sanity adapters tested with signatures made by @contentful/node-apps-toolkit and @sanity/webhook (dev dependencies only). - Correct the README examples: Contentful signs the query string and accepts future timestamps, Sanity has no freshness check, and unsigned headers must not provide identity or source.
- Typecheck against augmented Payload types (tsconfig.types-generated.json). - Integration tests: combined plugin/central/local excludeFields, excluded models never emit or appear in affected; Resource Change V1 for non-Payload event types; framework-free consumer in the installed smoke. - Measure plain native batches for a consumer's normalized-size limit instead of copying them, restoring the Next.js handler path to about +9%. - Record the benchmark method and raw samples; add a receiver benchmark. - Document how README examples are classified.
…uting examples - README reorganized (overview, generic producer, webhooks, consumers, CMS examples, security and reliability); architecture diagram corrected; unauthenticated adapter example removed; adapter contract shown as a type. - Neutral custom-JSON decoder example; Sanity adapter works from before() and after() snapshots with an operation-qualified identity; Contentful identity prefers a signed idempotency key. Fixtures and tests updated to match. - Robust shared-collection routing predicate, tested for create, update, move, delete, unpublish and media with real Payload. - AGENTS.md condensed; PERFORMANCE.md leads with current results. - SECURITY.md covers documentation examples; changeset extended.
…der selection - Decode request bodies with ignoreBOM so a leading BOM cannot be hidden from signature verification (Contentful, Sanity examples and fixtures). - Contentful signed-header list is read exactly as the SDK reads it. - Regression tests for BOM tampering (Contentful, Sanity, native receiver). - README: decoder/adapter authentication wording, media vs ordinary opt-in, handler maxNormalizedBytes relationship.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Version 0.5.0 makes
@klnap/cache-invalidationa framework-agnostic, standards-based, multi-target cache invalidation library with first-class Payload CMS and Next.js integrations. The release is carried by.changeset/extensible-webhook-ingestion.md(minor)..,/producers/payload,/webhooks,/consumers,/consumers/next. Source, transport and cache destination are independent and joined only by CloudEvents; module boundaries are enforced by dependency-cruiser.{ secret },{ secret, decode }or{ adapter }. Decoder and adapter output is untrusted: shape-checked, copied as plain data, bounded bymaxEvents,maxNormalizedBytesandadapterTimeoutMs, and validated as CloudEvents.createCacheConsumer()with application-owned executors and directconsume(events); the Next.js handler is now the native consumer behind the shared receiver (createNextCacheConsumer()).webhooksconfiguration,collections: true/globals: true, absoluteexclude, additiveexcludeFields, one effective configuration for hooks, media discovery and routing validation.affected) and functional predicates; a failing predicate is a target failure, not a skip.Intentional breaking changes (pre-1.0)
/dispatchers,/dispatchers/http,/consumers/http→/webhooks;http()→createWebhookDispatcher();{ config: cache.config }→{ cache };DefineCacheInput→CacheConfig; Payloadhooksremoved (setting it throws);excludeFieldslists combine instead of replacing;resolveExcludeFieldsandreadCacheInvalidationExcludeFieldsremoved; Payload requires exactly one ofwebhooks/dispatcher; Payload log lines no longer carry exception messages. The event protocol is unchanged, so 0.4 and 0.5 applications interoperate.Verification (head
dbef5e8)bun run check: pass (435 unit tests, type tests including augmented Payload types, knip, boundaries, publint, attw).src; no source change since.PERFORMANCE.md): native callback 33.5 → 34.2 µs/op, Next.js handler 35.4 → 38.7 µs/op.ignoreBOM, and regression tests show a BOM added after signing is rejected for Contentful, Sanity and the native receiver.Accepted limitations
No hosted Sanity or Contentful delivery was used; the adapters are verified with the official SDKs and signed fixtures, and the README lists the payload assumptions to confirm.