revenuecat-api 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +2 -5
- package/.github/workflows/publish.yml +60 -8
- package/CHANGELOG.md +28 -0
- package/README.md +4 -27
- package/dist/__generated/revenuecat-api-v2.d.ts +5278 -1897
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/eslint.config.mjs +7 -7
- package/package.json +21 -20
- package/pnpm-workspace.yaml +2 -0
- package/scripts/generate_openapi_client.sh +0 -0
- package/test/createRevenueCatClient.test.ts +100 -0
- package/tsconfig.json +15 -109
- package/dist/rateLimitMiddleware.d.ts +0 -3
- package/dist/rateLimitMiddleware.d.ts.map +0 -1
- package/dist/rateLimitMiddleware.js +0 -160
- package/test/rateLimitMiddleware.test.ts +0 -609
package/.github/workflows/ci.yml
CHANGED
|
@@ -9,19 +9,16 @@ on:
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
node-version: [20]
|
|
15
12
|
steps:
|
|
16
13
|
- uses: actions/checkout@v4
|
|
17
14
|
|
|
18
15
|
- name: Install pnpm
|
|
19
16
|
uses: pnpm/action-setup@v4
|
|
20
17
|
|
|
21
|
-
- name: Use Node.js
|
|
18
|
+
- name: Use Node.js
|
|
22
19
|
uses: actions/setup-node@v4
|
|
23
20
|
with:
|
|
24
|
-
node-version:
|
|
21
|
+
node-version: "24"
|
|
25
22
|
cache: "pnpm"
|
|
26
23
|
|
|
27
24
|
- name: Install dependencies
|
|
@@ -3,11 +3,61 @@
|
|
|
3
3
|
name: Publish to npm
|
|
4
4
|
|
|
5
5
|
on:
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write # Required for npm OIDC trusted publishing
|
|
11
|
+
contents: read
|
|
8
12
|
|
|
9
13
|
jobs:
|
|
14
|
+
check-version:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
outputs:
|
|
17
|
+
should_publish: ${{ steps.check.outputs.should_publish }}
|
|
18
|
+
version: ${{ steps.check.outputs.version }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Read package version
|
|
23
|
+
id: versions
|
|
24
|
+
run: |
|
|
25
|
+
echo "name=$(node -p "require('./package.json').name")" >> "$GITHUB_OUTPUT"
|
|
26
|
+
echo "new=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
|
|
27
|
+
|
|
28
|
+
- name: Look up latest published version
|
|
29
|
+
id: npm
|
|
30
|
+
run: |
|
|
31
|
+
if PUBLISHED=$(npm view "${{ steps.versions.outputs.name }}" version 2>/dev/null); then
|
|
32
|
+
echo "published=$PUBLISHED" >> "$GITHUB_OUTPUT"
|
|
33
|
+
else
|
|
34
|
+
echo "Package not yet on npm; treating published version as 0.0.0"
|
|
35
|
+
echo "published=0.0.0" >> "$GITHUB_OUTPUT"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
- name: Compare versions
|
|
39
|
+
id: semver
|
|
40
|
+
uses: mage-os/github-actions/semver-compare@v1.7.3
|
|
41
|
+
with:
|
|
42
|
+
version: ${{ steps.versions.outputs.new }}
|
|
43
|
+
compare_against: ${{ steps.npm.outputs.published }}
|
|
44
|
+
|
|
45
|
+
- name: Check for version bump
|
|
46
|
+
id: check
|
|
47
|
+
run: |
|
|
48
|
+
echo "Published version: ${{ steps.npm.outputs.published }}"
|
|
49
|
+
echo "Package version: ${{ steps.versions.outputs.new }}"
|
|
50
|
+
|
|
51
|
+
if [ "${{ steps.semver.outputs.result }}" = "1" ]; then
|
|
52
|
+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
|
53
|
+
echo "version=${{ steps.versions.outputs.new }}" >> "$GITHUB_OUTPUT"
|
|
54
|
+
else
|
|
55
|
+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
|
|
56
|
+
fi
|
|
57
|
+
|
|
10
58
|
publish:
|
|
59
|
+
needs: check-version
|
|
60
|
+
if: needs.check-version.outputs.should_publish == 'true'
|
|
11
61
|
runs-on: ubuntu-latest
|
|
12
62
|
steps:
|
|
13
63
|
- uses: actions/checkout@v4
|
|
@@ -18,17 +68,19 @@ jobs:
|
|
|
18
68
|
- name: Setup Node.js
|
|
19
69
|
uses: actions/setup-node@v4
|
|
20
70
|
with:
|
|
21
|
-
node-version: "
|
|
71
|
+
node-version: "24"
|
|
22
72
|
registry-url: "https://registry.npmjs.org"
|
|
23
73
|
cache: "pnpm"
|
|
24
74
|
|
|
75
|
+
- name: Update npm
|
|
76
|
+
run: npm install -g npm@latest
|
|
77
|
+
|
|
25
78
|
- name: Install dependencies
|
|
26
79
|
run: pnpm install
|
|
27
80
|
|
|
28
|
-
- name:
|
|
29
|
-
run: pnpm
|
|
30
|
-
env:
|
|
31
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
81
|
+
- name: Run tests
|
|
82
|
+
run: pnpm test
|
|
32
83
|
|
|
33
84
|
- name: Publish to npm
|
|
34
|
-
|
|
85
|
+
# pnpm publish does not support OIDC trusted publishing (pnpm v11+); npm CLI does.
|
|
86
|
+
run: npm publish --access public
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## 2.0.0
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Removed built-in rate limiting. The `automaticRateLimit` client option and `createRateLimitMiddleware` middleware have been removed. Handle `429` responses and `Retry-After` headers in your application if needed (see [RevenueCat rate limit docs](https://www.revenuecat.com/docs/api-v2#tag/Rate-Limit)).
|
|
10
|
+
- `CreateRevenueCatClientOptions` is now an alias for `openapi-fetch`'s `ClientOptions` (no library-specific options remain).
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Regenerated types from the latest RevenueCat OpenAPI spec, including new endpoints for:
|
|
15
|
+
- Audit logs
|
|
16
|
+
- Collaborators
|
|
17
|
+
- Virtual currencies
|
|
18
|
+
- Webhook integrations
|
|
19
|
+
- Media assets
|
|
20
|
+
- Charts & metrics
|
|
21
|
+
- Customer actions (grant/revoke entitlement, assign offering, restore purchase)
|
|
22
|
+
- Archive/unarchive actions for entitlements, offerings, products, and virtual currencies
|
|
23
|
+
- Subscription extend action
|
|
24
|
+
- Revenue metrics
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Updated `openapi-fetch` from `^0.15.0` to `^0.17.0`.
|
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@ This package provides a lightweight, fully-typed client for interacting with the
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- **Type Safety**: Full TypeScript support with generated types from the official OpenAPI spec
|
|
12
|
-
- **Automatic Rate Limiting**: Built-in rate limiting that respects RevenueCat's `Retry-After` headers
|
|
13
12
|
- **Isomorphic**: Works in both server-side (Node.js, Deno) and browser environments
|
|
14
13
|
- **Lightweight**: Minimal bundle size using modern fetch-based architecture
|
|
15
14
|
- **Queue Management**: Intelligent request queuing to handle rate limits gracefully
|
|
@@ -28,10 +27,10 @@ npm install revenuecat-api
|
|
|
28
27
|
## Quick Start
|
|
29
28
|
|
|
30
29
|
```typescript
|
|
31
|
-
import { createRevenueCatClient } from
|
|
30
|
+
import { createRevenueCatClient } from "revenuecat-api";
|
|
32
31
|
|
|
33
32
|
// Create a client with your RevenueCat API key
|
|
34
|
-
const client = createRevenueCatClient(
|
|
33
|
+
const client = createRevenueCatClient("your-api-key-here");
|
|
35
34
|
|
|
36
35
|
// Example: Fetch subscription information
|
|
37
36
|
// (Note all API endpoint strings are type-safe and discoverable via IntelliSense!)
|
|
@@ -51,31 +50,10 @@ const { data, error } = await client[
|
|
|
51
50
|
if (error) {
|
|
52
51
|
console.error(`Error of type ${error.type}:`, error.message);
|
|
53
52
|
} else {
|
|
54
|
-
console.log(
|
|
53
|
+
console.log("Subscription data:", data);
|
|
55
54
|
}
|
|
56
55
|
```
|
|
57
56
|
|
|
58
|
-
## Rate Limiting
|
|
59
|
-
|
|
60
|
-
The client can optionally handle RevenueCat's rate limiting by:
|
|
61
|
-
|
|
62
|
-
- Respecting `Retry-After` headers from 429 responses
|
|
63
|
-
- Queuing requests when rate limits are hit
|
|
64
|
-
- Automatically retrying failed requests (up to 3 times by default)
|
|
65
|
-
- Managing per-endpoint rate limit states
|
|
66
|
-
|
|
67
|
-
_Note that automatic rate limiting functionality is still in early development stages and may not be production ready_
|
|
68
|
-
|
|
69
|
-
You can opt into automatic rate limiting if desired:
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
const client = createRevenueCatClient('your-api-key', {
|
|
73
|
-
automaticRateLimit: true
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
For more details on RevenueCat's rate limiting, see the [official documentation](https://www.revenuecat.com/docs/api-v2#tag/Rate-Limit).
|
|
78
|
-
|
|
79
57
|
## API Reference
|
|
80
58
|
|
|
81
59
|
### `createRevenueCatClient(accessToken, options?)`
|
|
@@ -89,7 +67,6 @@ Creates a new RevenueCat API client instance.
|
|
|
89
67
|
|
|
90
68
|
**Options:**
|
|
91
69
|
|
|
92
|
-
- `automaticRateLimit` (boolean, default: true): Enable/disable automatic rate limiting
|
|
93
70
|
- `baseUrl` (string, default: `"https://api.revenuecat.com/v2"`): API base URL
|
|
94
71
|
- All other [options from `openapi-fetch`](https://openapi-ts.dev/openapi-fetch/api#createclient) are supported
|
|
95
72
|
|
|
@@ -165,7 +142,7 @@ if (error) {
|
|
|
165
142
|
|
|
166
143
|
### Prerequisites
|
|
167
144
|
|
|
168
|
-
- Node.js
|
|
145
|
+
- Node.js 24+
|
|
169
146
|
- pnpm (recommended) or npm
|
|
170
147
|
|
|
171
148
|
### Setup
|