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

@odata-effect/odata-effect-promise

v4.0.4

Published

Promise-based OData client for non-Effect environments

Downloads

589

Readme

@odata-effect/odata-effect-promise

Promise bridge for @odata-effect/odata-effect.

The core OData operations and generated services return Effect values. This package gives Promise-based apps a small runtime and a toPromise(runtime) helper so you can use those operations from scripts, Express, Next.js route handlers, tests, and other non-Effect entry points.

Install

For Node.js:

pnpm add @odata-effect/odata-effect @odata-effect/odata-effect-promise [email protected] @effect/[email protected]

The runtime is platform-independent. Node.js examples use @effect/platform-node/NodeHttpClient; Bun or browser apps should provide the matching Effect HTTP client layer.

Create A Runtime

import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { createODataRuntime } from "@odata-effect/odata-effect-promise"

const runtime = createODataRuntime(
  {
    baseUrl: "https://server.example.com",
    servicePath: "/sap/opu/odata/sap/MY_SERVICE/"
  },
  NodeHttpClient.layer
)

baseUrl is the protocol and host. servicePath is the OData service root and should usually end with /.

Always dispose the runtime when your process, request scope, or test is done:

try {
  // run OData operations here
} finally {
  await runtime.dispose()
}

Use Generated Services

This is the most common usage. Generate a client with @odata-effect/odata-effect-generator, then convert generated service Effects to Promises:

import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { createODataRuntime, toPromise } from "@odata-effect/odata-effect-promise"
import { ProductService } from "./generated/index.js"

const runtime = createODataRuntime(
  {
    baseUrl: "https://server.example.com",
    servicePath: "/sap/opu/odata/sap/MY_SERVICE/"
  },
  NodeHttpClient.layer
)

try {
  const products = await ProductService.getAll({ $top: 10 }).pipe(toPromise(runtime))
  const product = await ProductService.getById("123").pipe(toPromise(runtime))
  const created = await ProductService.create({ name: "Notebook" }).pipe(toPromise(runtime))

  console.log({ created, product, products })
} finally {
  await runtime.dispose()
}

Use Core Operations Directly

You can also use the low-level V2 and V4 modules from @odata-effect/odata-effect:

import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { OData, ODataV4 } from "@odata-effect/odata-effect"
import { createODataRuntime, toPromise } from "@odata-effect/odata-effect-promise"
import * as Schema from "effect/Schema"

const Product = Schema.Struct({
  ProductID: Schema.String,
  Name: Schema.String
})

const runtime = createODataRuntime(
  {
    baseUrl: "https://server.example.com",
    servicePath: "/sap/opu/odata/sap/MY_SERVICE/"
  },
  NodeHttpClient.layer
)

try {
  const v2Products = await OData.getCollection("Products", Product, { $top: 10 }).pipe(toPromise(runtime))
  const v4Product = await ODataV4.get("Products(1)", Product).pipe(toPromise(runtime))

  console.log({ v2Products, v4Product })
} finally {
  await runtime.dispose()
}

Handling Errors

toPromise(runtime) rejects when the underlying Effect fails. Use normal try/catch at the Promise boundary:

try {
  const products = await ProductService.getAll().pipe(toPromise(runtime))
  console.log(products)
} catch (error) {
  console.error("OData request failed", error)
}

If you want Effect's Exit value instead of thrown Promise rejections, use runtime.runPromiseExit(effect).

API

| Export | Description | | ------ | ----------- | | createODataRuntime(config, httpClientLayer) | Creates a managed runtime with OData config and an HTTP client layer. | | toPromise(runtime) | Converts an Effect operation into a Promise. Designed for .pipe(toPromise(runtime)). | | ODataRuntime | Runtime interface with runPromise, runPromiseExit, and dispose. |

License

MIT