Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

@rubriclab/events

Package Overview
Dependencies
Maintainers
4
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rubriclab/events

Source
npmnpm
Version
0.0.33
Version published
Weekly downloads
83
-72.61%
Maintainers
4
Weekly downloads
 
Created
Source

@rubriclab/events

The Actions package aims to provide a powerful and simple way to define actions (which are essentially API primitives) and execute them safely with JSON serializable payloads.

It is part of Rubric's architecture for Generative UI when used with:

  • @rubriclab/actions
  • @rubriclab/blocks
  • @rubriclab/chains
  • @rubriclab/agents

Get Started

Installation

bun add @rubriclab/events

@rubriclab scope packages are not built, they are all raw typescript. If using in a next.js app, make sure to transpile.

// next.config.ts
import type { NextConfig } from  'next' 
export default {
	transpilePackages: ['@rubriclab/events'],
	reactStrictMode: true
} satisfies  NextConfig

If using inside the monorepo (@rubric), simply add {"@rubriclab/events": "*"} to dependencies and then run bun i

Define Event types

export const eventTypes = createEventTypes({
  ping: z.literal('ping'),
})

Create the events server and a route

import { createEventsServer } from '@rubriclab/events/server'
import env from '~/env'
import { eventTypes } from './types'

export const { publish, GET, maxDuration } = createEventsServer({
	eventTypes,
	redisURL: env.UPSTASH_REDIS_URL
})
// app/api/events/route.ts
export { GET, maxDuration } from './server'

Create the events client

import { createEventsClient } from '@rubriclab/events/client'
import { eventTypes } from './types'

export const { useEvents } = createEventsClient({
	url: '/api/events', // The url of the server
	eventTypes
})

Publish an event from the server

await publish({
  channel: '123',
  eventType: 'ping',
  payload: 'ping'
})

Consume it on the client!

useEvents({
		id: '123',
		on: {
			ping: (payload) => {
				console.log('ping', payload)
			}
		}
	})

Commits to main will automatically publish a new version to npm.

FAQs

Package last updated on 05 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts