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

@objectql/sdk

v1.8.4

Published

Remote HTTP driver for ObjectQL - Universal client for browser, Node.js, and edge runtimes

Downloads

858

Readme

@objectql/sdk

Remote HTTP Driver for ObjectQL - Universal client for browser, Node.js, and edge runtimes

License TypeScript

The @objectql/sdk package provides a type-safe HTTP client for ObjectQL servers. It works seamlessly in browsers, Node.js, Deno, and edge runtimes like Cloudflare Workers.


✨ Features

  • 🌍 Universal Runtime - Works in browsers, Node.js, Deno, and edge environments
  • 📦 Zero Dependencies - Only depends on @objectql/types for type definitions
  • 🔒 Type-Safe - Full TypeScript support with generics
  • 🚀 Modern APIs - Uses native fetch API available in all modern JavaScript runtimes
  • 🎯 RESTful Interface - Clean, predictable API design

📦 Installation

npm install @objectql/sdk @objectql/types

For frontend projects:

# Using npm
npm install @objectql/sdk @objectql/types

# Using yarn
yarn add @objectql/sdk @objectql/types

# Using pnpm
pnpm add @objectql/sdk @objectql/types

🚀 Quick Start

Browser Usage (ES Modules)

<!DOCTYPE html>
<html>
<head>
    <title>ObjectQL SDK Browser Example</title>
</head>
<body>
    <h1>ObjectQL Browser Client</h1>
    <div id="users"></div>

    <script type="module">
        // Option 1: Using unpkg CDN
        import { DataApiClient } from 'https://unpkg.com/@objectql/sdk/dist/index.js';

        // Option 2: Using a bundler (Vite, Webpack, etc.)
        // import { DataApiClient } from '@objectql/sdk';

        const client = new DataApiClient({
            baseUrl: 'http://localhost:3000',
            token: 'your-auth-token' // Optional
        });

        // Fetch and display users
        async function loadUsers() {
            const response = await client.list('users', {
                filter: [['status', '=', 'active']],
                limit: 10
            });

            const usersDiv = document.getElementById('users');
            usersDiv.innerHTML = response.items
                .map(user => `<p>${user.name} - ${user.email}</p>`)
                .join('');
        }

        loadUsers().catch(console.error);
    </script>
</body>
</html>

React / Vue / Angular

import { DataApiClient, MetadataApiClient } from '@objectql/sdk';

// Initialize clients
const dataClient = new DataApiClient({
    baseUrl: process.env.REACT_APP_API_URL || 'http://localhost:3000',
    token: localStorage.getItem('auth_token')
});

const metadataClient = new MetadataApiClient({
    baseUrl: process.env.REACT_APP_API_URL || 'http://localhost:3000'
});

// Use in your components
async function fetchUsers() {
    const response = await dataClient.list('users', {
        filter: [['status', '=', 'active']],
        sort: [['created_at', 'desc']]
    });
    return response.items;
}

Node.js

const { DataApiClient } = require('@objectql/sdk');

const client = new DataApiClient({
    baseUrl: 'http://localhost:3000'
});

async function main() {
    const users = await client.list('users');
    console.log(users.items);
}

main();

📚 API Reference

DataApiClient

Client for CRUD operations on data records.

Constructor

new DataApiClient(config: DataApiClientConfig)

Config Options:

  • baseUrl (string, required) - Base URL of the ObjectQL server
  • token (string, optional) - Authentication token
  • headers (Record<string, string>, optional) - Additional HTTP headers
  • timeout (number, optional) - Request timeout in milliseconds (default: 30000)

Methods

list<T>(objectName: string, params?: DataApiListParams): Promise<DataApiListResponse<T>>

List records with optional filtering, sorting, and pagination.

const users = await client.list('users', {
    filter: [['status', '=', 'active']],
    sort: [['name', 'asc']],
    limit: 20,
    skip: 0,
    fields: ['name', 'email', 'status']
});
get<T>(objectName: string, id: string | number): Promise<DataApiItemResponse<T>>

Get a single record by ID.

const user = await client.get('users', 'user_123');
create<T>(objectName: string, data: DataApiCreateRequest): Promise<DataApiItemResponse<T>>

Create a new record.

const newUser = await client.create('users', {
    name: 'Alice',
    email: '[email protected]',
    status: 'active'
});
createMany<T>(objectName: string, data: DataApiCreateManyRequest): Promise<DataApiListResponse<T>>

Create multiple records at once.

const newUsers = await client.createMany('users', [
    { name: 'Bob', email: '[email protected]' },
    { name: 'Charlie', email: '[email protected]' }
]);
update<T>(objectName: string, id: string | number, data: DataApiUpdateRequest): Promise<DataApiItemResponse<T>>

Update an existing record.

const updated = await client.update('users', 'user_123', {
    status: 'inactive'
});
updateMany(objectName: string, request: DataApiBulkUpdateRequest): Promise<DataApiResponse>

Update multiple records matching filters.

await client.updateMany('users', {
    filters: [['status', '=', 'pending']],
    data: { status: 'active' }
});
delete(objectName: string, id: string | number): Promise<DataApiDeleteResponse>

Delete a record by ID.

await client.delete('users', 'user_123');
deleteMany(objectName: string, request: DataApiBulkDeleteRequest): Promise<DataApiDeleteResponse>

Delete multiple records matching filters.

await client.deleteMany('users', {
    filters: [['created_at', '<', '2023-01-01']]
});
count(objectName: string, filters?: FilterExpression): Promise<DataApiCountResponse>

Count records matching filters.

const result = await client.count('users', [['status', '=', 'active']]);
console.log(result.count);

MetadataApiClient

Client for reading object schemas and metadata.

Constructor

new MetadataApiClient(config: MetadataApiClientConfig)

Methods

listObjects(): Promise<MetadataApiObjectListResponse>

List all available objects.

const objects = await metadataClient.listObjects();
getObject(objectName: string): Promise<MetadataApiObjectDetailResponse>

Get detailed schema for an object.

const userSchema = await metadataClient.getObject('users');
console.log(userSchema.fields);
getField(objectName: string, fieldName: string): Promise<FieldMetadataResponse>

Get metadata for a specific field.

const emailField = await metadataClient.getField('users', 'email');
listActions(objectName: string): Promise<MetadataApiActionsResponse>

List actions available for an object.

const actions = await metadataClient.listActions('users');

🌐 Browser Compatibility

The SDK uses modern JavaScript APIs available in all current browsers:

  • fetch API - Available in all modern browsers
  • Promises/async-await - ES2017+
  • AbortSignal.timeout() - Chrome 103+, Firefox 100+, Safari 16.4+

Automatic Polyfill

The SDK automatically includes a polyfill for AbortSignal.timeout() that activates when running in older browsers. You don't need to add any polyfills manually - the SDK works universally out of the box!

The polyfill is lightweight and only adds the missing functionality when needed, ensuring compatibility with:

  • Chrome 90+
  • Firefox 90+
  • Safari 15+
  • Edge 90+

For even older browsers, you may need to add polyfills for:

  • fetch API (via whatwg-fetch)
  • AbortController (via abort-controller package)

🔧 Advanced Usage

Custom Headers

const client = new DataApiClient({
    baseUrl: 'http://localhost:3000',
    headers: {
        'X-Custom-Header': 'value',
        'X-Request-ID': crypto.randomUUID()
    }
});

Dynamic Token Updates

class AuthenticatedClient {
    private client: DataApiClient;

    constructor(baseUrl: string) {
        this.client = new DataApiClient({ baseUrl });
    }

    setToken(token: string) {
        this.client = new DataApiClient({
            baseUrl: this.client['baseUrl'],
            token
        });
    }

    async fetchData() {
        return this.client.list('users');
    }
}

Error Handling

import { ObjectQLError, ApiErrorCode } from '@objectql/types';

try {
    await client.create('users', { email: 'invalid' });
} catch (error) {
    if (error instanceof ObjectQLError) {
        console.error('ObjectQL Error:', error.code, error.message);
        
        if (error.code === ApiErrorCode.VALIDATION_ERROR) {
            console.log('Validation failed:', error.details);
        }
    }
}

📖 Examples

React Hook

import { useState, useEffect } from 'react';
import { DataApiClient } from '@objectql/sdk';

const client = new DataApiClient({
    baseUrl: process.env.REACT_APP_API_URL
});

export function useObjectData<T>(objectName: string, params?: any) {
    const [data, setData] = useState<T[]>([]);
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState<Error | null>(null);

    useEffect(() => {
        async function fetchData() {
            try {
                setLoading(true);
                const response = await client.list<T>(objectName, params);
                setData(response.items || []);
            } catch (err) {
                setError(err as Error);
            } finally {
                setLoading(false);
            }
        }

        fetchData();
    }, [objectName, JSON.stringify(params)]);

    return { data, loading, error };
}

Vue Composable

import { ref, watchEffect } from 'vue';
import { DataApiClient } from '@objectql/sdk';

const client = new DataApiClient({
    baseUrl: import.meta.env.VITE_API_URL
});

export function useObjectData<T>(objectName: string, params?: any) {
    const data = ref<T[]>([]);
    const loading = ref(true);
    const error = ref<Error | null>(null);

    watchEffect(async () => {
        try {
            loading.value = true;
            const response = await client.list<T>(objectName, params);
            data.value = response.items || [];
        } catch (err) {
            error.value = err as Error;
        } finally {
            loading.value = false;
        }
    });

    return { data, loading, error };
}

🏗️ Architecture

The SDK is designed with the ObjectQL "Trinity" architecture:

  1. @objectql/types (The Contract) - Pure TypeScript interfaces
  2. @objectql/sdk (The Client) - HTTP communication layer
  3. ObjectQL Server (The Backend) - Data processing and storage
┌─────────────────┐
│   Frontend      │
│  (Browser/App)  │
│                 │
│  @objectql/sdk  │
└────────┬────────┘
         │ HTTP/REST
         │
┌────────▼────────┐
│ ObjectQL Server │
│                 │
│  @objectql/core │
└────────┬────────┘
         │
    ┌────┴────┐
    │ SQL/Mongo│
    └─────────┘

📄 License

MIT License - see LICENSE file for details.


🔗 Related Packages


🤝 Contributing

We welcome contributions! Please see the main repository README for guidelines.


📚 Documentation

For complete documentation, visit: