0.0.16 • Published 8 months ago

@unthread-io/node v0.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

unthread-node-client

npm

Unthread API Client for Node

Install

With npm:

npm install @unthread-io/node

Usage

This package uses ES modules. Import and use the client as follows:

import { UnthreadClient } from "@unthread-io/node";

const unthreadClient = new UnthreadClient({
  apiKey: "your-api-key-here",
  baseUrl: "https://api.unthread.io/api" // Optional, this is the default
});

Automations

The client provides access to Automations functionality through two main components: Stores and Functions.

Stores

Stores allow you to manage key-value data storage:

// Get a store
const store = await unthreadClient.automations.stores.get("storeName");

// List all stores
const stores = await unthreadClient.automations.stores.list();

// Use transactions
const transaction = await unthreadClient.automations.stores.transaction("storeName");
await transaction.setValue("key", "value");
await transaction.commit();

// Direct operations
await unthreadClient.automations.stores.setValue("storeName", "key", "value");
const value = await unthreadClient.automations.stores.getValue("storeName", "key");
await unthreadClient.automations.stores.deleteValue("storeName", "key");

Functions

Functions allow you to manage and deploy automation code:

// Upsert a draft version
const draft = await unthreadClient.automations.functions.upsertDraftVersion({
  code: "your function code here"
});

// Activate a version
await unthreadClient.automations.functions.activateVersion(draft.version);

// Deploy a new version (upsert and activate in one step)
const deployed = await unthreadClient.automations.functions.deployNewVersion({
  code: "your function code here"
});

Error Handling

The client provides custom error classes for different types of API errors:

  • UnthreadApiError: Base class for API errors
  • AuthorizationError: For 401 and 403 errors
  • NotFoundError: For resource not found errors
  • ConflictError: For transaction conflicts
  • AlreadyCommittedError: For attempting operations on already committed transactions

License

This project is licensed under the MIT License. See the LICENSE file for details.

0.0.14

8 months ago

0.0.15

8 months ago

0.0.16

8 months ago

0.0.10

11 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago