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

sdk-core-machin

v1.0.1

Published

Machin SDK Core - Domain logic and use cases (adapter-agnostic)

Downloads

190

Readme

@machin/sdk-core

Core SDK for Machin mobile application. This package contains the domain logic, entities, and use cases without any adapter implementation.

Architecture

This SDK follows Clean Architecture principles:

  • Domain Layer: Entities and repository interfaces (contracts)
  • Application Layer: Use cases that orchestrate business logic

The actual implementation of repositories (adapters) is provided by separate packages:

  • @machin/sdk-supabase - Supabase backend adapter
  • @machin/sdk-http - HTTP/REST API adapter
  • Or create your own custom adapter!

Installation

npm install @machin/sdk-core
# Also install an adapter (example with Supabase)
npm install @machin/sdk-supabase

Usage

1. Initialize the SDK with an adapter

import { MachinSDK } from '@machin/sdk-core';
import { AuthSupabaseAdapter } from '@machin/sdk-supabase';

// Initialize once in your app
const sdk = MachinSDK.init({
  auth: new AuthSupabaseAdapter(
    'https://your-project.supabase.co',
    'your-anon-key'
  )
});

2. Use the SDK

// Sign in
const result = await sdk.auth.sign_in('[email protected]', 'password');

if (result.error) {
  console.error('Login failed:', result.error.message);
} else {
  console.log('User:', result.data.user);
}

// Sign out
await sdk.auth.sign_out();

// Password recovery
await sdk.auth.recovery_password('[email protected]');

3. Get instance anywhere in your app

import { MachinSDK } from '@machin/sdk-core';

const sdk = MachinSDK.getInstance();
await sdk.auth.sign_out();

Creating a Custom Adapter

You can create your own adapter for any backend by implementing the repository interfaces:

import { AuthRepository, AuthResponse, User } from '@machin/sdk-core';
import axios from 'axios';

export class AuthCustomAdapter implements AuthRepository {
  private apiUrl: string;

  constructor(apiUrl: string) {
    this.apiUrl = apiUrl;
  }

  async sign_in(email: string, password: string): Promise<AuthResponse> {
    try {
      const response = await axios.post(`${this.apiUrl}/auth/login`, {
        email,
        password
      });
      
      const user = User.fromDTO(response.data.user);
      
      return {
        data: { user },
        error: null
      };
    } catch (error: any) {
      return {
        data: { user: null },
        error: {
          status: error.response?.status || 500,
          code: error.code || 'UNKNOWN_ERROR',
          message: error.message
        }
      };
    }
  }

  async sign_up(email: string, password: string): Promise<AuthResponse> {
    // Implementation...
  }

  async sign_out(): Promise<void> {
    // Implementation...
  }

  async recovery_password(email: string): Promise<{}> {
    // Implementation...
  }

  async update_password(password: string): Promise<{}> {
    // Implementation...
  }
}

// Use it
const sdk = MachinSDK.init({
  auth: new AuthCustomAdapter('https://my-api.com')
});

API Reference

MachinSDK

Static Methods

  • MachinSDK.init(config: MachinSDKConfig): MachinSDK - Initialize the SDK with adapters
  • MachinSDK.getInstance(): MachinSDK - Get the current SDK instance
  • MachinSDK.reset(): void - Reset the SDK (useful for testing)

Instance Properties

  • sdk.auth: AuthUseCase - Authentication use case

AuthUseCase

  • sign_up(email: string, password: string): Promise<AuthResponse>
  • sign_in(email: string, password: string): Promise<AuthResponse>
  • sign_out(): Promise<void>
  • recovery_password(email: string): Promise<{}>
  • update_password(password: string): Promise<{}>

Types

interface AuthResponse {
  data: {
    user: User | null;
  };
  error: AuthError | null;
}

interface AuthError {
  status: number;
  code: string | {};
  message: string;
}

class User {
  id: string;
  email: string;
  emailVerified: boolean;
  role: string;
  lastSignInAt: Date | null;
}

Available Adapters

Philosophy

This SDK is designed to be adapter-agnostic. The core package only defines:

  • What operations are available (interfaces)
  • The business logic (use cases)
  • The data structures (entities)

The how (implementation details) is delegated to adapter packages, giving you:

  • ✅ Flexibility to switch backends without changing your code
  • ✅ Easy testing with mock adapters
  • ✅ No vendor lock-in
  • ✅ Small bundle size (only install what you need)

License

MIT © David Luna