Skip to content

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 09 Jul 19:12
22786d2

Minor Changes

  • 76025f4: Simplification + declarative-response pass: internals consolidated, the authoring surface extended (source-scoped defineEvent), and the HTTP reply repositioned to the invocation layer as a self-describing declaration (breaking, pre-adoption).

    • Removed dead export NotImplementedError (root and /core). It was a Phase-0 scaffolding relic: no runtime code path ever threw it, so nothing could ever catch it. Migration: delete any import of it — there is no replacement because there was no behavior.
    • The three Hasura sources (hasuraEvent, hasuraCron, hasuraAction) now share one callableSource assembly helper instead of three copy-pasted factory blocks; their runtime shape (callable + attached authoring helpers + plugin name) is pinned by new tests.
    • handle() and dryRun() share one intake pipeline (extract → normalize → augment), and the response seams share one error-mapping path — the invocation lifecycle now reads in one place.
    • Consolidated six copies of the crypto.randomUUID fallback and two copies of isJobDefinition into single internal helpers; the two Netlify v2 platforms share the Web-Response rejection formatter.
    • webhook factory now carries the typed authoring helpers (additive): webhook.detector<TBody>(fn) / webhook.prepare<TBody>(fn) work on the bare factory value (uniform with the Hasura family), so an event module can type ctx.body without constructing the vendor-configured source that lives in the entry file. New WebhookAuthoring interface; runtime behavior unchanged (identity wrappers).
    • Source-scoped defineEvent (additive): every source now carries a typed module builder — hasuraEvent.defineEvent<Row>({ … }), webhook.defineEvent<Body>({ … }), hasuraAction.defineEvent<Input>({ … }), hasuraCron.defineEvent<Payload>({ … }). The one type parameter on the outer call types every inline (ctx) => … seam (detector, prepare) with the source's enriched context, so detectors can be authored inline with no per-seam wrapper. At runtime it is core defineEvent (name branding only). New core type SourceEventModule (type-only). The generic root defineEvent is unchanged and remains the full-inference path (ctx.prepared from prepare, D32).
    • BREAKING (pre-adoption): the HTTP reply moved to the invocation layer — kit.handler({ before, after }) (ADR-026, re-amended). A module never declares an HTTP reply: modules own detection + jobs; one invocation has ONE wire reply and the handler declares it. after takes one of two self-naming modes: { body } (a constant — data, not code, so it provably cannot wait on or be changed by the work) or { fromResults: (result) => body } (arbitrary business logic over the PRESCRIBED typed rollup the runtime builds — InvocationResult with every detector's EventOutcome and every job's JobExecution; throw ClientError/ActionError for the error mapping). Optional status/headers (ResponseWire — the web-standard ResponseInit fields as data) ride beside the mode; platform adapters map everything (new Response(body, init) on v2, { statusCode, headers, body } on classic/Lambda). after is skipped on a framework error (the 500 retry contract) and never clobbers a pre-dispatch client rejection (webhook rejectUnverified). { fromResults } is rejected under a background/202 platform — "202 first, then work" is a PLATFORM choice (netlifyBackgroundPlatform), not an after mode. The earlier per-module resolve/respond/response fields are all removed (registering them throws with the migration pointer); an action/webhook's work runs as JOBS and the reply is composed from their outputs. KitEventDescription.response/FlowResponseKind are removed from describe()/flow output (events no longer have response kinds); the expectFlow(...).respondsWith(...) testing assertion is removed with them. New core types HandlerResponse/ResponseBody/ResponseWire.
    • registerEvent/registerEvents now accept EventModule<any, any, any> (type-level widening): a source-typed module registers without a variance cast under strict compiler flags (e.g. exactOptionalPropertyTypes). Runtime unchanged.
    • docs/guide.html: documented kit.dryRun() and the Hasura sources' factory/config form (inbound token discovery) in the API reference; replaced the webhook walkthrough with a real Stripe payment_intent.succeeded example (now authored with webhook.defineEvent<StripePaymentEvent> and the reply declared at kit.handler({ after: { body } })) and the hmacVerify preset (the previous example called .detector on the bare factory — which didn't exist before this change — and showed retry semantics that don't match Stripe's redeliver-on-any-non-2xx contract).