Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"mcpServers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {}
},
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"],
"env": {}
},
"gemini-google-search": {
"type": "stdio",
"command": "npx",
"args": ["mcp-gemini-google-search"],
"env": {
"GEMINI_MODEL": "gemini-2.5-flash"
}
},
"gemini-cli": {
"type": "stdio",
"command": "npx",
"args": ["mcp-gemini-cli", "--allow-npx"],
"env": {}
},
"codex": {
"type": "stdio",
"command": "codex",
"args": ["mcp-server"],
"env": {}
},
"kiri": {
"type": "stdio",
"command": "npx",
"args": [
"kiri-mcp-server@latest",
"--repo",
".",
"--db",
".kiri/index.duckdb",
"--watch"
],
"env": {}
},
"next-devtools": {
"type": "stdio",
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"],
"env": {}
}
}
}
75 changes: 75 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# CLAUDE.md

このファイルは、このリポジトリでコードを扱う際にClaude Code (claude.ai/code)にガイダンスを提供します。

## 言語設定

**重要**: ユーザーへの出力は日本語で行い、内部的な思考プロセスは英語で行ってください。

## プロジェクト概要

**@printgraph/js-sdk** は、Printgraph APIのJavaScript/TypeScript向けクライアントライブラリです。テンプレートとパラメータを指定してPDFを生成するシンプルなAPIを提供します。

## コマンド

### ビルド
```bash
npm run build
```
- tsupを使用してCJS/ESMの両方の形式でビルド
- 型定義(.d.ts)とソースマップが生成される
- 出力先: `dist/`

### Lint
```bash
npm run lint
```
- Biomeを使用してコードをチェック
- 対象: `src/`配下のすべてのファイル

### テスト
```bash
npm test
```
- Vitestを使用(現在テストファイルは未実装)

## アーキテクチャ

### ディレクトリ構成
- `src/index.ts` - パッケージのエントリーポイント(型とクラスをエクスポート)
- `src/printgraph.ts` - `Printgraph`クラスの実装(メインクライアント)
- `src/types.ts` - すべての型定義とインターフェース

### 主要コンポーネント

#### Printgraphクラス (`src/printgraph.ts`)
- コンストラクタで認証トークンとオプションのAPIエンドポイントを受け取る
- デフォルトAPI URL: `https://api.printgraph.jp/v1/`
- メソッド:
- `generatePDF(options)` - テンプレートキーとパラメータからPDFを生成し、`ArrayBuffer`として返す

#### 型システム (`src/types.ts`)
- `GeneratePDFOptions` - PDF生成オプション(テンプレートキーとパラメータ)
- PDFサイズ指定は2つの方法:
- `GeneratePDFFormat` - 事前定義されたフォーマット(A4、Letterなど)を使用
- `GeneratePDFSize` - カスタムwidth/heightを指定(`px`, `mm`, `cm`, `in`のサイズ単位をサポート)
- `TemplateParamType` - テンプレートパラメータの許可される型(`string | number | boolean`)

### ビルド設定

#### tsup (`tsup.config.ts`)
- エントリーポイント: `src/index.ts`
- 出力フォーマット: CommonJS (`cjs`) と ESM (`esm`)
- ソースマップ、型定義を生成
- ビルド前に`dist/`をクリーン

#### TypeScript (`tsconfig.json`)
- ターゲット: ES2022
- モジュール形式: NodeNext(ESM/CJS両対応)
- 厳格モード有効
- `noUncheckedIndexedAccess`有効(配列アクセスの安全性向上)

### パッケージ情報
- CommonJSとESMの両方をサポート
- パッケージはpublicとして公開される
- ライセンス: MIT
9 changes: 3 additions & 6 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.3.5/schema.json",
"files": {
"include": ["src/**/*", "tests/**/*"],
"ignore": ["**/node_modules/**"]
},
"organizeImports": {
"enabled": true
"includes": ["**/src/**/*", "**/tests/**/*", "!**/node_modules"]
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"formatter": {
"enabled": true,
"indentStyle": "space"
Expand Down
4 changes: 3 additions & 1 deletion src/printgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class Printgraph {
});

if (!res.ok) {
throw new Error(`Failed to generate PDF\n\tHTTP status: ${res.statusText}(${res.status})`);
throw new Error(
`Failed to generate PDF\n\tHTTP status: ${res.statusText}(${res.status})`,
);
}

return res.arrayBuffer();
Expand Down