Skip to content

Commit d8c7404

Browse files
elucidsoftclaude
andcommitted
feat: initial SDK implementation — full TypeScript SDK for CloudLayer.io API
- 10 conversion methods: urlToPdf, urlToImage, htmlToPdf, htmlToImage, templateToPdf, templateToImage, docxToPdf, docxToHtml, pdfToDocx, mergePdfs - 12 data management methods: jobs, assets, storage, account, status, templates - 2 utility methods: downloadJobResult, waitForJob (5s default, 2s min) - 42 TypeScript interfaces matching legacy v1/v2 API - 7 error classes with status code mapping and request context - HTTP transport with native fetch, retry logic, multipart support - Client-side input validation (URL, timeout, quality, batch, async+storage) - 113 unit tests with 90% coverage (vitest + mocked fetch) - Dual ESM/CJS output via tsup with TypeScript declarations - GitHub Actions CI (Node 18/20/22) and npm publish workflows - Zero runtime dependencies (Node 18.13+ native fetch) Package: @cloudlayerio/sdk v0.1.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3c85407 commit d8c7404

44 files changed

Lines changed: 7551 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [18, 20, 22]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: npm
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Lint
29+
run: npm run lint
30+
31+
- name: Format check
32+
run: npm run format:check
33+
34+
- name: Type check
35+
run: npm run typecheck
36+
37+
- name: Test with coverage
38+
run: npm run test:coverage
39+
40+
- name: Build
41+
run: npm run build
42+
43+
- name: Verify package
44+
run: |
45+
npm pack --dry-run
46+
SIZE=$(npm pack --dry-run 2>&1 | grep "unpacked size" | grep -oP '[\d.]+\s*[kKmM]B' | head -1)
47+
echo "Package unpacked size: $SIZE"

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
registry-url: https://registry.npmjs.org
23+
cache: npm
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build
29+
run: npm run build
30+
31+
- name: Publish
32+
run: npm publish --provenance --access public
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.env
5+
.env.*
6+
*.tgz
7+
.DS_Store

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
## 0.1.0 (Unreleased)
4+
5+
### Added
6+
- Initial SDK release
7+
- Full TypeScript type system matching CloudLayer.io v1/v2 API
8+
- 10 conversion methods: `urlToPdf`, `urlToImage`, `htmlToPdf`, `htmlToImage`, `templateToPdf`, `templateToImage`, `docxToPdf`, `docxToHtml`, `pdfToDocx`, `mergePdfs`
9+
- Data management: `listJobs`, `getJob`, `listAssets`, `getAsset`, `listStorage`, `getStorage`, `addStorage`, `deleteStorage`, `getAccount`, `getStatus`, `listTemplates`, `getTemplate`
10+
- Utility methods: `downloadJobResult`, `waitForJob`
11+
- 7 error classes: `CloudLayerError`, `CloudLayerConfigError`, `CloudLayerApiError`, `CloudLayerAuthError`, `CloudLayerRateLimitError`, `CloudLayerTimeoutError`, `CloudLayerNetworkError`, `CloudLayerValidationError`
12+
- Automatic retries with exponential backoff for data endpoints
13+
- Client-side input validation
14+
- Dual ESM/CJS output with TypeScript declarations

CONTRIBUTING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Contributing to @cloudlayerio/sdk
2+
3+
## Development Setup
4+
5+
```bash
6+
git clone https://github.com/cloudlayerio/cloudlayerio-js.git
7+
cd cloudlayerio-js
8+
npm install
9+
```
10+
11+
## Scripts
12+
13+
| Command | Description |
14+
|---------|-------------|
15+
| `npm run build` | Build ESM + CJS + types |
16+
| `npm run dev` | Build in watch mode |
17+
| `npm test` | Run tests |
18+
| `npm run test:watch` | Run tests in watch mode |
19+
| `npm run test:coverage` | Run tests with coverage |
20+
| `npm run lint` | Lint with Biome |
21+
| `npm run lint:fix` | Auto-fix lint issues |
22+
| `npm run format` | Format with Biome |
23+
| `npm run format:check` | Check formatting |
24+
| `npm run typecheck` | TypeScript type checking |
25+
26+
## Code Style
27+
28+
This project uses [Biome](https://biomejs.dev/) for linting and formatting. Configuration is in `biome.json`.
29+
30+
## Testing
31+
32+
Tests use [Vitest](https://vitest.dev/) with mocked `fetch`. Test files live in `tests/` mirroring the `src/` structure.
33+
34+
```bash
35+
npm test # Run all tests
36+
npm run test:coverage # Run with coverage report
37+
```
38+
39+
## Pull Request Process
40+
41+
1. Fork the repository
42+
2. Create a feature branch (`git checkout -b feature/my-feature`)
43+
3. Make your changes
44+
4. Run all quality checks: `npm run typecheck && npm test && npm run lint && npm run format:check`
45+
5. Commit and push
46+
6. Open a pull request
47+
48+
## Release Process
49+
50+
1. Update version in `package.json`
51+
2. Update `CHANGELOG.md`
52+
3. Commit: `chore: release vX.Y.Z`
53+
4. Create a GitHub Release with tag `vX.Y.Z`
54+
5. CI automatically publishes to npm

0 commit comments

Comments
 (0)