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

epson-connect-ts

v0.1.0

Published

TypeScript client for the Epson Connect API — zero dependencies

Downloads

16

Readme

epson-connect-ts

Epson Connect API の TypeScript クライアント。

ランタイム依存ゼロ(Node.js 18+ のネイティブ fetch を使用)。型定義付きで、印刷・スキャンまわりの操作を型安全に扱えます。

Install

npm install epson-connect-ts

Quick Start

import { Client } from "epson-connect-ts";

const client = new Client({
  printerEmail: "[email protected]",
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
});

await client.initialize();

// PDF を印刷
const jobId = await client.printer.print("./invoice.pdf");
console.log(`Job ID: ${jobId}`);

環境変数でも設定できます。

export [email protected]
export EPSON_CONNECT_API_CLIENT_ID=your-client-id
export EPSON_CONNECT_API_CLIENT_SECRET=your-client-secret
const client = new Client(); // 環境変数から自動読み込み
await client.initialize();

Usage

印刷(シンプル)

// デフォルト設定で PDF を印刷
const jobId = await client.printer.print("./report.pdf");

印刷(設定付き)

const jobId = await client.printer.print("./photo.jpg", {
  print_mode: "photo",
  print_setting: {
    media_size: "ms_l",
    media_type: "mt_photopaper",
    print_quality: "high",
    borderless: true,
    color_mode: "color",
  },
});

印刷(ステップごと)

アップロードの進捗表示などが必要な場合は、ステップを分けて実行できます。

const printer = client.printer;

// 1. ジョブ作成
const job = await printer.printSetting({
  print_setting: { copies: 3, two_sided: "long" },
});

// 2. ファイルアップロード
await printer.uploadFile(job.upload_uri, "./doc.pdf", job.settings.print_mode);

// 3. 印刷実行
await printer.executePrint(job.id);

ジョブ管理

// ジョブ状態を確認
const info = await client.printer.jobInfo(jobId);
console.log(info.status); // "pending" | "pending_held" | "printing" | ...

// ジョブをキャンセル(pending / pending_held のみ)
await client.printer.cancelPrint(jobId);

プリンター情報

// プリンター情報
const info = await client.printer.info();

// 対応機能を取得
const caps = await client.printer.capabilities("document");

Webhook 通知

// 通知を有効化
await client.printer.notification("https://your-server.com/webhook");

// 通知を無効化
await client.printer.notification("https://your-server.com/webhook", false);

スキャナー(宛先管理)

const scanner = client.scanner;

// 宛先一覧
const { destinations } = await scanner.list();

// 宛先を追加
const dest = await scanner.add("Office", "[email protected]", "mail");

// 宛先を更新
await scanner.update(dest.id, "Office (updated)");

// 宛先を削除
await scanner.remove(dest.id);

// キャッシュから取得(API リクエストなし)
const cached = await scanner.list(true);

切断

await client.deauthenticate();

Print Settings

print / printSetting にはオプションで設定を渡せます。すべて省略可能で、省略時はデフォルト値が適用されます。

| フィールド | 型 | デフォルト | 選択肢 | |---|---|---|---| | job_name | string | job-xxxxxxxx | 任意(256 文字以内) | | print_mode | PrintMode | document | document photo |

print_setting:

| フィールド | 型 | デフォルト | 選択肢 | |---|---|---|---| | media_size | MediaSize | ms_a4 | ms_a3 ms_a4 ms_a5 ms_a6 ms_b5 ms_tabloid ms_letter ms_legal ms_halfletter ms_kg ms_l ms_2l ms_10x12 ms_8x10 ms_hivision ms_5x8 ms_postcard | | media_type | MediaType | mt_plainpaper | mt_plainpaper mt_photopaper mt_hagaki mt_hagakiphoto mt_hagakiinkjet | | borderless | boolean | false | — | | print_quality | PrintQuality | normal | high normal draft | | source | PaperSource | auto | auto rear front1 front2 front3 front4 | | color_mode | ColorMode | color | color mono | | two_sided | TwoSided | none | none long short | | reverse_order | boolean | false | — | | copies | number | 1 | 1–99 | | collate | boolean | true | — |

Supported File Types

doc docx xls xlsx ppt pptx pdf jpeg jpg bmp gif png tiff

Error Handling

各モジュール別のエラークラスが用意されています。

import {
  ClientError,
  AuthenticationError,
  ApiError,
  PrinterError,
  PrintSettingError,
  ScannerError,
} from "epson-connect-ts";

try {
  await client.printer.print("./file.pdf");
} catch (e) {
  if (e instanceof AuthenticationError) {
    // 認証エラー(トークン失効など)
  } else if (e instanceof PrinterError) {
    // 印刷固有のエラー
  } else if (e instanceof ApiError) {
    // API レスポンスエラー
  }
}

Requirements

  • Node.js >= 18(ネイティブ fetch を使用)
  • Epson Connect API のアカウントとクレデンシャル

License

MIT