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

@payark/sdk-effect

v0.1.0

Published

Functional, type-safe Effect SDK for the PayArk API.

Downloads

46

Readme

@payark/sdk-effect

A high-performance, functional TypeScript SDK for PayArk, built natively on the Effect ecosystem.

Native Effect · Type-safe · Runtime Validation · Zero Promise overhead


Features

  • Effect-Native: Built directly on @effect/platform/HttpClient. Returns pure Effect types without Promise wrappers.
  • Strict Validation: All API responses are parsed and validated at runtime using @effect/schema, ensuring your data is exactly what you expect.
  • Branded Types: IDs (e.g., PaymentId, ProjectId) are branded for compile-time safety, preventing mix-ups.
  • Structured Errors: Errors are typed as PayArkEffectError, a TaggedError that integrates seamlessly with Effect.catchTag.
  • Tracing Ready: Fully instrumented for observability with Effect's built-in tracing.
  • Zero-Dependency Core: Lightweight and tree-shakeable.

Installation

# bun
bun add @payark/sdk-effect

# npm
npm install @payark/sdk-effect

Note: This package requires effect as a peer dependency.

Quick Start

import { Effect, Console } from "effect";
import { PayArkEffect } from "@payark/sdk-effect";

// 1. Initialize the client
const payark = new PayArkEffect({
  apiKey: "sk_live_...",
  // optional: baseUrl, timeout, etc.
});

// 2. Define your program
const program = Effect.gen(function* (_) {
  // Create a checkout session
  const session = yield* _(
    payark.checkout.create({
      amount: 1000, // NPR 1000
      provider: "esewa",
      returnUrl: "https://your-site.com/success",
    }),
  );

  yield* _(Console.log(`Checkout created: ${session.checkout_url}`));

  // Retrieve payment details later
  const payment = yield* _(
    payark.payments.retrieve(session.id.replace("ch_", "pay_")),
  );

  return payment;
});

// 3. Run safely
const result = await Effect.runPromise(
  program.pipe(
    Effect.catchTag("PayArkEffectError", (err) =>
      Console.error(`Payment failed: ${err.message} (${err.code})`),
    ),
  ),
);

API Reference

Resources

  • payark.checkout: Create hosted payment sessions.
  • payark.payments: List and retrieve payment records.
  • payark.projects: Manage project settings (requires PAT).

Types & Schemas

We export all Zod-like schemas for runtime validation if you need them independently:

import { PaymentSchema } from "@payark/sdk-effect";
import { Schema } from "@effect/schema";

const isPayment = Schema.is(PaymentSchema);

Error Handling

All methods return an Effect<Success, Error, Requirements>. The error channel is strictly typed.

import { PayArkEffectError } from "@payark/sdk-effect";
import { Effect } from "effect";

// ...

program.pipe(
  Effect.catchTag("PayArkEffectError", (error) => {
    // error is fully typed
    console.error(error.statusCode); // 400, 401, etc.
    console.error(error.code); // "authentication_error", "invalid_request_error"
    return Effect.succeed(null);
  }),
  Effect.catchTag("ParseError", (error) => {
    // Handle schema validation errors (e.g. API changed shape)
    console.error("Response validation failed", error);
    return Effect.die(error);
  }),
);

Configuration & Testing

You can interact with the underlying HttpClient by providing layers. This is useful for testing or custom networking requirements.

import { PayArkEffect } from "@payark/sdk-effect";
import { HttpClient } from "@effect/platform";

// The SDK uses the default HttpClient by default, but you can provide your own context.
// (Advanced usage for testing mocking)

License

MIT