Skip to content

Commit 4018692

Browse files
karlwaldmanclaude
andcommitted
feat: v0.8.0 — World-class SDK upgrade
Major improvements across the entire SDK: - Route all mutations (POST/PATCH/DELETE) through central request() with retry, timeout, typed errors - Add dual ESM + CJS build (require('oilpriceapi') now works) - Add ValidationError type replacing generic Error in all 20 resource files - Add OILPRICEAPI_KEY env var fallback for API key - Add webhook signature verification (verifyWebhookSignature + WebhooksResource.verifySignature) - Add paginateHistoricalPrices() async generator for memory-efficient iteration - Add ESLint + Prettier config with blocking CI step - Add automated npm publish workflow (GitHub Actions on release) - Add TypeDoc API reference generation (npm run docs) - Fix moduleResolution from "node" to "NodeNext" - Fix diesel getStations() bypass of central request() (was using raw fetch with stale v0.4.0 headers) - Create missing git tags (v0.5.3, v0.6.0, v0.7.0), remove erroneous v1.4.1 Tests: 107 → 201 (webhook verify, pagination, drilling, rig-counts, data-sources, data-quality, storage) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7a908ab commit 4018692

47 files changed

Lines changed: 4359 additions & 1350 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/github-pages.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,24 @@ jobs:
2525
- name: Checkout
2626
uses: actions/checkout@v4
2727

28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: "22"
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Generate API docs
37+
run: npm run docs
38+
2839
- name: Setup Pages
2940
uses: actions/configure-pages@v4
3041

3142
- name: Upload artifact
3243
uses: actions/upload-pages-artifact@v3
3344
with:
34-
path: './docs'
45+
path: "./docs"
3546

3647
- name: Deploy to GitHub Pages
3748
id: deployment

.github/workflows/publish.yml

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

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ on:
77
branches: [main]
88

99
jobs:
10+
lint:
11+
name: Lint & Type Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "22"
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: TypeScript build check
25+
run: npx tsc --noEmit
26+
27+
- name: ESLint
28+
run: npx eslint src/
29+
1030
test:
1131
name: Test (Node ${{ matrix.node-version }})
1232
runs-on: ubuntu-latest

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "all",
4+
"singleQuote": false,
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

PUBLISH_GUIDE.md

Lines changed: 62 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,62 @@
1-
# Publishing Guide: Node.js SDK v0.5.0
2-
3-
## Pre-Publishing Checklist
4-
5-
✅ Version bumped to 0.5.0 in package.json
6-
✅ CHANGELOG.md updated with v0.5.0 release notes
7-
✅ README.md updated with alerts examples
8-
✅ All tests passing (43/43)
9-
✅ TypeScript compilation successful
10-
✅ Code committed and pushed to GitHub
11-
12-
## Publishing to npm
13-
14-
### Step 1: Verify npm Authentication
15-
16-
```bash
17-
npm whoami
18-
# Should show: oilpriceapi (or your npm username)
19-
```
20-
21-
If not logged in:
22-
```bash
23-
npm login
24-
```
25-
26-
### Step 2: Run Final Checks
27-
28-
```bash
29-
# Ensure clean working directory
30-
git status
31-
32-
# Run tests one more time
33-
npm test
34-
35-
# Build production bundle
36-
npm run build
37-
38-
# Check what will be published
39-
npm pack --dry-run
40-
```
41-
42-
### Step 3: Publish to npm
43-
44-
```bash
45-
# Publish to npm registry
46-
npm publish
47-
48-
# Expected output:
49-
# + oilpriceapi@0.5.0
50-
```
51-
52-
### Step 4: Verify Publication
53-
54-
```bash
55-
# Check npm registry
56-
npm view oilpriceapi
57-
58-
# Install in test project
59-
mkdir /tmp/test-npm-install
60-
cd /tmp/test-npm-install
61-
npm init -y
62-
npm install oilpriceapi@0.5.0
63-
64-
# Verify version
65-
npm list oilpriceapi
66-
```
67-
68-
### Step 5: Tag Release on GitHub
69-
70-
```bash
71-
git tag -a v0.5.0 -m "Release v0.5.0: Price Alerts Support"
72-
git push origin v0.5.0
73-
```
74-
75-
### Step 6: Create GitHub Release
76-
77-
Go to: https://github.com/OilpriceAPI/oilpriceapi-node/releases/new
78-
79-
- Tag: v0.5.0
80-
- Title: v0.5.0 - Price Alerts Support
81-
- Description: Copy from CHANGELOG.md v0.5.0 section
82-
- Attach: None needed (published to npm)
83-
84-
## Post-Publishing
85-
86-
### Update Documentation Website
87-
88-
```bash
89-
# If you have a docs deployment script
90-
npm run deploy:docs
91-
```
92-
93-
### Announce Release
94-
95-
1. **Twitter/X**:
96-
```
97-
🚀 OilPriceAPI Node.js SDK v0.5.0 is now live!
98-
99-
New: Price Alerts 🔔
100-
• Monitor commodity prices 24/7
101-
• Webhook notifications
102-
• 5 comparison operators
103-
• Alert cooldown periods
104-
105-
npm install oilpriceapi@0.5.0
106-
107-
Docs: https://docs.oilpriceapi.com/sdk/nodejs
108-
```
109-
110-
2. **Reddit** (r/node, r/javascript):
111-
- Title: "OilPriceAPI Node.js SDK v0.5.0: Price Alerts Feature"
112-
- Link to GitHub release
113-
114-
3. **Email to Users**:
115-
- Subject: "New Feature: Price Alerts Now Available"
116-
- Highlight webhook notifications and automation
117-
118-
## Troubleshooting
119-
120-
### "You do not have permission to publish"
121-
- Verify npm account has publish rights to @oilpriceapi scope
122-
- Check npm organization membership
123-
124-
### "Version already published"
125-
- Version 0.5.0 already exists on npm
126-
- Bump to 0.5.1 if you need to republish
127-
128-
### "Invalid package.json"
129-
- Run `npm pack --dry-run` to check package contents
130-
- Verify all required fields present
131-
132-
## Quick Publish Command
133-
134-
```bash
135-
# One-liner (use with caution)
136-
npm test && npm run build && npm publish && git tag -a v0.5.0 -m "Release v0.5.0" && git push origin v0.5.0
137-
```
138-
139-
## Rollback (If Needed)
140-
141-
```bash
142-
# Deprecate version (don't unpublish)
143-
npm deprecate oilpriceapi@0.5.0 "This version has issues, use 0.5.1"
144-
145-
# Publish fixed version
146-
npm version patch # Bumps to 0.5.1
147-
npm publish
148-
```
149-
150-
## Success Indicators
151-
152-
✅ Package appears on npm: https://www.npmjs.com/package/oilpriceapi
153-
✅ Version 0.5.0 listed in versions tab
154-
`npm install oilpriceapi@0.5.0` works globally
155-
✅ GitHub release created
156-
✅ Git tag pushed
157-
✅ Downloads counter incrementing
158-
159-
---
160-
161-
**Ready to publish!** 🚀
162-
163-
Run: `npm publish`
1+
# Publishing Guide: Node.js SDK
2+
3+
## Automated Publishing (Recommended)
4+
5+
Publishing is now automated via GitHub Actions. Simply:
6+
7+
1. Update version in `package.json` and `src/version.ts`
8+
2. Update `CHANGELOG.md`
9+
3. Commit and push to `main`
10+
4. Create a GitHub Release with the version tag
11+
12+
The `.github/workflows/publish.yml` workflow will:
13+
14+
- Run tests
15+
- Build ESM + CJS
16+
- Publish to npm with provenance
17+
18+
## Manual Publishing
19+
20+
### Pre-Publishing Checklist
21+
22+
- [ ] Version bumped in `package.json` and `src/version.ts`
23+
- [ ] CHANGELOG.md updated
24+
- [ ] All tests passing (185+)
25+
- [ ] TypeScript compilation successful
26+
- [ ] ESLint passes (`npm run lint`)
27+
28+
### Steps
29+
30+
```bash
31+
# 1. Verify clean state
32+
git status
33+
npm test
34+
npm run lint
35+
npm run build
36+
37+
# 2. Check package contents
38+
npm pack --dry-run
39+
40+
# 3. Publish
41+
npm publish
42+
43+
# 4. Tag and push
44+
git tag -a vX.Y.Z -m "Release vX.Y.Z"
45+
git push origin vX.Y.Z
46+
47+
# 5. Create GitHub Release at:
48+
# https://github.com/OilpriceAPI/oilpriceapi-node/releases/new
49+
```
50+
51+
### Verify
52+
53+
```bash
54+
npm view oilpriceapi versions
55+
npm install oilpriceapi@latest
56+
```
57+
58+
## Rollback
59+
60+
```bash
61+
npm deprecate oilpriceapi@X.Y.Z "Use X.Y.Z+1 instead"
62+
```

eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import tseslint from "typescript-eslint";
2+
3+
export default tseslint.config(
4+
{
5+
ignores: ["dist/", "node_modules/", "tests/", "examples/", "docs/"],
6+
},
7+
...tseslint.configs.recommended,
8+
{
9+
rules: {
10+
"@typescript-eslint/no-explicit-any": "warn",
11+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
12+
},
13+
},
14+
);

0 commit comments

Comments
 (0)