New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@layers/amba-functions

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@layers/amba-functions

The SDK Cloudflare Workers import to build amba functions. Provides defineFunction + a typed ctx (auth, collections, AI, events, storage, email, queue, fan-out, secrets).

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
-100%
Maintainers
3
Weekly downloads
 
Created
Source

@layers/amba-functions

The SDK customer Cloudflare Workers import to build amba functions.

defineFunction wraps your handler with HMAC verification of the incoming dispatched request and constructs a typed ctx object exposing auth, collections, AI, events, storage, email, queue, fan-out, and secrets.

Install

npm install @layers/amba-functions
# or: pnpm add @layers/amba-functions
# or: yarn add @layers/amba-functions

Usage

import { defineFunction } from '@layers/amba-functions';

export default defineFunction(async (req, ctx) => {
  const userId = ctx.auth.assertUser();
  const letters = await ctx.collections.letters.asUser(userId).find();
  return Response.json({ letters });
});

The handler receives the Worker Request and a ctx:

  • ctx.auth — userId / developerId, plus assertUser() / assertDeveloper().
  • ctx.collections.<name> — typed CRUD against your tenant database.
  • ctx.ai.anthropic / ctx.ai.openai / ctx.ai.embeddings — proxied AI calls.
  • ctx.events.track({ name, properties }) — record an engagement event.
  • ctx.storage — upload, delete, presign against your project's R2.
  • ctx.email.send — templated or ad-hoc transactional email.
  • ctx.queue.send — enqueue a background job.
  • ctx.fanOut.forUsersInSegment — invoke a function for every user in a segment.
  • ctx.secrets.get('STRIPE_KEY') — read a Workers Secret bound to this script.

Errors thrown by the SDK are subclasses of AmbaError (AmbaAuthError, AmbaNotFoundError, AmbaValidationError, AmbaRateLimitError, AmbaTenantUnavailableError, AmbaInternalError).

License

MIT

FAQs

Package last updated on 12 May 2026

Related posts