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

@integratop/retailcrm-bot-api-effect

v1.0.0

Published

RetailCRM Bot API Client based on Effect

Readme

RetailCRM Bot API Effect Client

License: MIT

Клиент для RetailCRM Bot API, построенный на библиотеке Effect для TypeScript. Предоставляет типобезопасный и функциональный интерфейс для работы с RetailCRM Bot API.

Особенности

  • 🚀 Полная типобезопасность - все методы и сущности имеют строгие TypeScript типы
  • Функциональный подход - построен на библиотеке Effect для чистого функционального программирования
  • 📦 Автогенерация - клиент генерируется из OpenAPI схемы RetailCRM
  • 🔧 Гибкая настройка - поддержка кастомные HTTP клиенты и трансформации
  • 🧪 Тестирование - включает end-to-end тесты для некоторых методов API

Установка

npm install @integratop/retailcrm-bot-api-effect
# или
yarn add @integratop/retailcrm-bot-api-effect
# или
pnpm add @integratop/retailcrm-bot-api-effect

Быстрый старт

Конфигурация

import { Config } from "effect";

export const RETAILCRM_BOT_ENDPOINT = Config.url("RETAILCRM_BOT_ENDPOINT");
export const RETAILCRM_BOT_TOKEN = Config.redacted("RETAILCRM_BOT_TOKEN");

Код примера в файле: config.ts.

Настройка HTTP клиента

import { HttpClient, HttpClientRequest } from "@effect/platform";
import { Effect, flow, pipe, Redacted } from "effect";
import { RETAILCRM_BOT_ENDPOINT, RETAILCRM_BOT_TOKEN } from "./config.js";

export const makeHttpClient = Effect.gen(function* () {
  const baseUrl = yield* RETAILCRM_BOT_ENDPOINT;
  const token = yield* RETAILCRM_BOT_TOKEN;
  const apiUrl = new URL("/api/bot/v1", baseUrl);

  return pipe(
    yield* HttpClient.HttpClient,
    HttpClient.mapRequest(
      flow(
        HttpClientRequest.prependUrl(apiUrl.href),
        HttpClientRequest.setHeaders({
          "X-Bot-Token": `${Redacted.value(token)}`,
          "Content-Type": "application/json",
          Accept: "application/json",
        }),
      ),
    ),
  );
});

Полный код примера с повторными попытками и RateLimiter в файле: httpClient.ts.

Настройка Effect Layer

import { NodeHttpClient } from "@effect/platform-node";
import { Layer, Logger, LogLevel } from "effect";

export const testLayer = Layer.mergeAll(
  Logger.minimumLogLevel(LogLevel.All),
  NodeHttpClient.layer,
  Layer.scope,
);

Код примера в файле: layer.ts.

Пример использования

import { make } from "@integratop/retailcrm-bot-api-effect";
import { Effect, pipe } from "effect";
import { makeHttpClient } from "./httpClient.js";
import { testLayer } from "./layer.js";

// Получение списка каналов
async function main() {
  const result = await pipe(
    Effect.gen(function* () {
      // Создание HttpClient
      const httpClient = yield* makeHttpClient;
      // Создание Bot API клиента
      const client = make(httpClient);
      // Запрос списка каналов
      return yield* client.ListChannels();
    }),
    Effect.provide(testLayer),
    Effect.runPromise,
  );

  console.log(result);
}

// Запуск примера
await main();

Код примера в файле: examples.test.ts.

Bot API

Обработка ошибок

Все методы возвращают Effect, который может завершиться с ошибкой типа HttpClientError или ParseError:

pipe(
  client.ListChannels(),
  // Обработка одного типа ошибки
  Effect.catchTag("ParseError", (error) =>
    Effect.logError(`Failed to parse received data: ${error.message}`),
  ),
  // Обработка двух типов ошибок
  Effect.catchTags({
    RequestError: (error) => Effect.logError(`Failed to make request: ${error.message}`),
    ResponseError: (error) => Effect.logError(`Response error: ${error.message}`),
  }),
);

Разработка

Установка зависимостей

pnpm install

Обновление OpenAPI спецификации

Выполняется через обновление версии зависимости: @integratop/retailcrm-bot-api-schema.

Генерация клиента

pnpm src

Полная сборка

pnpm build

Тестирование

pnpm test

Лицензия

MIT License - смотрите файл LICENSE для подробностей.

Версионирование

Проект использует Semantic Versioning.

Безопасность

Если вы обнаружили уязвимость безопасности, пожалуйста, сообщите нам об этом.

Поддержка

Если у вас есть вопросы или предложения, создайте issue в GitHub репозитории.