|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is `@makeplane/plane-node-sdk` — a TypeScript SDK for the Plane API. It uses axios for HTTP, targets Node.js >=20, and is managed with pnpm@10.20.0. |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +pnpm install # Install dependencies |
| 13 | +pnpm build # Compile TS + bundle type definitions |
| 14 | +pnpm dev # Watch mode for development |
| 15 | +pnpm test # Run all tests (Jest) |
| 16 | +pnpm test:unit # Unit tests only |
| 17 | +pnpm test:e2e # E2E tests only |
| 18 | +pnpm test -- --testPathPattern=tests/unit/project # Run a single test file |
| 19 | +pnpm test:coverage # Run with coverage report |
| 20 | +pnpm check:lint # Lint check (ESLint) |
| 21 | +pnpm fix:lint # Auto-fix lint issues |
| 22 | +pnpm check:format # Format check (Prettier, 120 char width) |
| 23 | +pnpm fix:format # Auto-format |
| 24 | +``` |
| 25 | + |
| 26 | +## Testing |
| 27 | + |
| 28 | +Tests live in `tests/unit/` and `tests/e2e/`. Tests require a `.env.test` file (copy from `env.example`) with real workspace/project IDs. Tests run sequentially (`maxWorkers: 1`) to avoid API rate limits. Jest uses `tsconfig.jest.json` via ts-jest. |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +**Entry point**: `src/index.ts` re-exports everything. The main consumer-facing class is `PlaneClient` (`src/client/plane-client.ts`), which instantiates all API resources with shared `Configuration`. |
| 33 | + |
| 34 | +**BaseResource pattern** (`src/api/BaseResource.ts`): Abstract base class providing HTTP methods (get, post, patch, put, httpDelete) via axios. All API resource classes extend it. Handles both `apiKey` (X-Api-Key header) and `accessToken` (Bearer token) auth. Includes optional request/response logging with sensitive data sanitization. |
| 35 | + |
| 36 | +**API resources** (`src/api/`): Each resource class extends BaseResource. Some have sub-resources as separate classes composed by the parent: |
| 37 | +- `WorkItems/` → Comments, Attachments, Activities, Relations, WorkLogs |
| 38 | +- `Customers/` → Properties, Requests |
| 39 | +- `Teamspaces/` → Members, Projects |
| 40 | +- `Initiatives/` → Labels, Projects, Epics |
| 41 | +- `AgentRuns/` → Activities |
| 42 | +- `WorkItemProperties/` → Options, Values |
| 43 | + |
| 44 | +**Models** (`src/models/`): TypeScript interfaces for each entity with separate Create/Update DTOs. Uses `Pick`, `Omit`, and `Partial` for DTO derivation. Notable: `WorkItem` uses a generic expandable fields pattern (`WorkItem<E extends WorkItemExpandableFieldName = never>`). |
| 45 | + |
| 46 | +**Errors** (`src/errors/`): `PlaneError` (base) → `HttpError` (HTTP-specific with status code and response data). |
| 47 | + |
| 48 | +**OAuth**: Standalone `OAuthClient` (`src/client/oauth-client.ts`) handles authorization flows, token exchange, and refresh separately from the main SDK auth. |
| 49 | + |
| 50 | +## Conventions |
| 51 | + |
| 52 | +- All API endpoint URLs must end with `/` |
| 53 | +- Standard resource methods: `list`, `create`, `retrieve`, `update`, `del` |
| 54 | +- Never use "Issue" in names — always use "Work Item" |
| 55 | +- File naming: kebab-case for files, PascalCase for classes, camelCase for methods |
| 56 | +- Avoid `any` types; use proper typing or `unknown` with type guards |
| 57 | +- Build produces `dist/` with compiled JS, declarations, source maps, and a bundled `types.bundle.d.ts` |
0 commit comments