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

circuitstream-aws-utils

v1.0.0

Published

AWS service integrations for electronic component inventory management with DynamoDB, S3, Rekognition, SNS, and Cognito support

Readme

circuitstream-aws-utils

AWS service integrations specifically designed for electronic component inventory management systems.

Features

  • ComponentDatabase: DynamoDB operations for component CRUD with advanced filtering
  • ComponentStorage: S3 file management with presigned URLs for secure uploads
  • ComponentAnalyzer: Rekognition-based AI component identification from images
  • StockAlerts: SNS notifications for low stock warnings
  • CognitoAuth: JWT authentication helpers for API Gateway Lambda functions

Installation

npm install circuitstream-aws-utils

Usage

Component Database Operations

import { ComponentDatabase } from 'circuitstream-aws-utils';

const db = new ComponentDatabase();

// Create a component
const component = await db.createComponent('userId123', {
  name: '1kΩ Resistor',
  componentType: 'resistor',
  quantity: 100,
  partNumber: 'RES-1K-0805',
  manufacturer: 'Yageo',
  minStockLevel: 20
});

// Get user's components with filters
const components = await db.getUserComponents('userId123', {
  type: 'resistor',
  lowStock: true,
  threshold: 50,
  search: '1k'
});

// Update component
const updated = await db.updateComponent('userId123', 'componentId', {
  quantity: 75
});

// Delete component
await db.deleteComponent('userId123', 'componentId');

S3 Storage

import { ComponentStorage } from 'circuitstream-aws-utils';

const storage = new ComponentStorage();

// Upload a file
await storage.uploadFile('images/resistor.jpg', fileBuffer, 'image/jpeg');

// Get presigned URL for upload
const uploadUrl = await storage.getUploadUrl('datasheets/spec.pdf');

// Delete a file
await storage.deleteFile('https://bucket.s3.amazonaws.com/images/old.jpg');

Component Image Analysis

import { ComponentAnalyzer } from 'circuitstream-aws-utils';

const analyzer = new ComponentAnalyzer();

// Analyze component from S3 image
const result = await analyzer.analyzeComponent('uploads/component.jpg');

console.log(result.componentData.type); // 'resistor'
console.log(result.summary); // AI-generated description
console.log(result.componentData.analysis.resistor.estimatedValue); // '1kΩ'

Stock Alerts

import { StockAlerts } from 'circuitstream-aws-utils';

const alerts = new StockAlerts();

// Subscribe user to alerts
await alerts.subscribeUser('[email protected]');

// Send low stock alert
await alerts.sendLowStockAlert(component, '[email protected]');

// Send critical stock alert
await alerts.sendCriticalStockAlert(component, '[email protected]');

Cognito Authentication

import { CognitoAuth } from 'circuitstream-aws-utils';

const auth = new CognitoAuth();

// Extract user from Lambda event
export const handler = async (event) => {
  const { userId, email } = auth.getUserContext(event);
  
  // Create standardized responses
  return auth.createResponse(200, { 
    message: 'Success',
    data: results 
  });
  
  // Or error responses
  return auth.createErrorResponse(400, 'Invalid request');
};

Lambda Function Example

Complete Lambda function using the library:

import { ComponentDatabase, CognitoAuth } from 'circuitstream-aws-utils';

const db = new ComponentDatabase();
const auth = new CognitoAuth();

export const handler = async (event) => {
  try {
    if (event.httpMethod === 'OPTIONS') {
      return auth.createResponse(200, '');
    }

    const { userId } = auth.getUserContext(event);
    const body = JSON.parse(event.body);

    const component = await db.createComponent(userId, body);

    return auth.createResponse(201, {
      message: 'Component created',
      component
    });
  } catch (error) {
    return auth.createErrorResponse(500, error.message);
  }
};

Environment Variables

Required environment variables for Lambda functions:

  • COMPONENTS_TABLE: DynamoDB table name
  • COMPONENTS_BUCKET: S3 bucket name
  • SNS_TOPIC_ARN: SNS topic ARN for alerts

Constants

The library includes useful constants:

import { ComponentTypes, StockThresholds, ResistorColorCodes } from 'circuitstream-aws-utils';

console.log(ComponentTypes.RESISTOR); // 'resistor'
console.log(StockThresholds.LOW); // 20
console.log(ResistorColorCodes.BROWN); // 1

Component Types

Supported component types:

  • resistor
  • capacitor
  • diode
  • transistor
  • integrated_circuit
  • connector
  • inductor
  • sensor
  • led
  • crystal

AWS Permissions

Your Lambda execution role needs these permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "dynamodb:GetItem",
        "dynamodb:PutItem",
        "dynamodb:UpdateItem",
        "dynamodb:DeleteItem",
        "dynamodb:Query"
      ],
      "Resource": "arn:aws:dynamodb:*:*:table/YourComponentsTable"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject"
      ],
      "Resource": "arn:aws:s3:::your-bucket/*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "rekognition:DetectLabels",
        "rekognition:DetectText"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "sns:Publish",
        "sns:Subscribe"
      ],
      "Resource": "arn:aws:sns:*:*:YourStockAlertsTopic"
    }
  ]
}

License

MIT

Author

CircuitStream Team