npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@trivikr-test/eventbridge-event-types

v0.1.0

Published

Generated, self-contained TypeScript detail types for AWS EventBridge events. Ships .d.ts only; designed to be imported by @types/aws-lambda.

Readme

@trivikr-test/eventbridge-event-types

Generated, self-contained TypeScript types for the detail payloads of AWS EventBridge events, derived from the EventBridge Schema Registry (aws.events).

The package ships .d.ts only and has no dependency on aws-lambda / @types/aws-lambda. That is deliberate: it is designed so that @types/aws-lambda can import it and combine it with its own EventBridgeEvent type, without creating a circular dependency.

What it exports

// One interface per AWS detail payload, e.g.
export interface GlueJobStateChangeDetail {
  /* ... */
}
export interface CloudWatchAlarmStateChangeDetail {
  /* ... */
}

// A map from each `detail-type` string to its detail interface.
export interface EventBridgeDetailMap {
  "CloudWatch Alarm State Change": CloudWatchAlarmStateChangeDetail;
  "Glue Job State Change": GlueJobStateChangeDetail;
  // ...one entry per AWS detail-type
}

// Convenience union of every known detail-type string.
export type EventBridgeDetailType = keyof EventBridgeDetailMap;

There is intentionally no type here that references EventBridgeEvent. That wiring belongs to the consumer (see below), which keeps the dependency direction one-way: @types/aws-lambda -> this package.

How @types/aws-lambda can consume it

1. Declare the dependency

In types/aws-lambda/package.json, add the package to dependencies:

{
  "dependencies": {
    "@trivikr-test/eventbridge-event-types": "^0.1.0",
  },
}

Because this is a declaration-only package that bundles its own .d.ts, no matching @types/... entry is needed.

2. Wire the map into EventBridgeEvent

In types/aws-lambda/trigger/eventbridge.d.ts, import the map and expose typed helpers next to the existing generic EventBridgeEvent:

import { Handler } from "../handler";
import { EventBridgeDetailMap } from "@trivikr-test/eventbridge-event-types";

// Existing generic event (unchanged).
export interface EventBridgeEvent<TDetailType extends string, TDetail> {
  id: string;
  version: string;
  account: string;
  time: string;
  region: string;
  resources: string[];
  source: string;
  "detail-type": TDetailType;
  detail: TDetail;
  "replay-name"?: string;
}

// New: a fully-typed event for a known AWS detail-type.
export type TypedEventBridgeEvent<K extends keyof EventBridgeDetailMap> =
  EventBridgeEvent<K & string, EventBridgeDetailMap[K]>;

// New: a discriminated union over all known AWS events. Narrowing on
// `detail-type` narrows `detail` to the matching payload.
export type KnownEventBridgeEvent<
  K extends keyof EventBridgeDetailMap = keyof EventBridgeDetailMap,
> = { [T in K]: EventBridgeEvent<T & string, EventBridgeDetailMap[T]> }[K];

export type KnownEventBridgeHandler<
  K extends keyof EventBridgeDetailMap = keyof EventBridgeDetailMap,
> = Handler<KnownEventBridgeEvent<K>, void>;

Re-export these from the package index (types/aws-lambda/index.d.ts) the same way the other trigger types are surfaced.

3. End-user experience

Once published, consumers of @types/aws-lambda can get:

import type { KnownEventBridgeEvent, TypedEventBridgeEvent } from "aws-lambda";

// Discriminated union: detail narrows off `detail-type`.
export const handler = (event: KnownEventBridgeEvent) => {
  switch (event["detail-type"]) {
    case "Glue Job State Change":
      event.detail.jobRunId; // typed
      break;
    case "CloudWatch Alarm State Change":
      event.detail.state.value; // typed
      break;
  }
};

// Or pin a handler to a single detail-type:
export const onGlue = (
  event: TypedEventBridgeEvent<"Glue Job State Change">,
) => {
  event.detail.state; // "SUCCEEDED" | "FAILED" | ...
};

The generic EventBridgeEvent<TDetailType, TDetail> continues to work unchanged for custom (non-AWS) events.

Regenerating the types

The committed index.d.ts is generated; do not edit it by hand. See CONTRIBUTING.md for setup and regeneration instructions.

Why a separate package instead of hand-writing in DefinitelyTyped

The detail schemas already exist, machine-readable, in the EventBridge Schema Registry. Generating from them keeps the types in sync with AWS automatically. DefinitelyTyped does not run codegen in CI, so the generated catalog lives here and @types/aws-lambda consumes the published .d.ts.