autumn-js 0.0.2 → 0.0.3

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ The MIT License (MIT) Copyright (c) 2023 - present, Recase Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -0,0 +1,110 @@
1
+ # Autumn.js
2
+
3
+ Autumn.js is a comprehensive JavaScript/TypeScript library for interacting with the Autumn pricing platform. This package provides both a server-side SDK for the Autumn API and a Next.js integration package for seamless client-side implementation.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Complete Autumn API SDK
8
+ - ⚡ Next.js Integration
9
+ - 🔒 Type-safe API interactions
10
+ - 🛠️ Easy-to-use hooks and components
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install autumn-js
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ Add your Autumn secret key to your environment variables:
21
+
22
+ ```env
23
+ AUTUMN_SECRET_KEY=your_secret_key_here
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Server-Side SDK
29
+
30
+ For server-side applications (Node.js, Express, etc.), use the SDK like this:
31
+
32
+ ```typescript
33
+ import { Autumn } from 'autumn-js'
34
+
35
+ // Initialize Autumn
36
+ const autumn = new Autumn()
37
+
38
+ // Create a customer
39
+ await autumn.customers.create({
40
+ id: "customer_123",
41
+ name: "John Doe"
42
+ })
43
+
44
+ // Other available operations
45
+ await autumn.products.list()
46
+ await autumn.prices.create(...)
47
+ await autumn.subscriptions.create(...)
48
+ ```
49
+
50
+ ### Next.js Integration
51
+
52
+ For Next.js applications, Autumn.js provides a dedicated integration with helpful hooks and components.
53
+
54
+ 1. First, wrap your application with the `AutumnProvider` in your root layout:
55
+
56
+ ```typescript
57
+ // app/layout.tsx
58
+ import { AutumnProvider } from 'autumn-js/next'
59
+
60
+ export default function RootLayout({
61
+ children,
62
+ }: {
63
+ children: React.ReactNode
64
+ }) {
65
+ return (
66
+ <html>
67
+ <body>
68
+ <AutumnProvider customerId="YOUR_CUSTOMER_ID">
69
+ {children}
70
+ </AutumnProvider>
71
+ </body>
72
+ </html>
73
+ )
74
+ }
75
+ ```
76
+
77
+ 2. Then use the `useAutumn` hook in your components:
78
+
79
+ ```typescript
80
+ import { useAutumn } from 'autumn-js/next'
81
+
82
+ export default function BillingPage() {
83
+ const { customer, attach, openBillingPortal } = useAutumn()
84
+
85
+ return (
86
+ <div>
87
+ <h1>Welcome {customer?.name}</h1>
88
+ <button onClick={() => openBillingPortal()}>
89
+ Manage Billing
90
+ </button>
91
+ <button onClick={() => attach()}>
92
+ Upgrade to Pro
93
+ </button>
94
+ </div>
95
+ )
96
+ }
97
+ ```
98
+
99
+
100
+ ## API Reference
101
+
102
+ For detailed API documentation, visit [docs.useautumn.com](https://docs.useautumn.com)
103
+
104
+ ## Support
105
+
106
+ For support, email hey@useautumn.com!
107
+
108
+ ## License
109
+
110
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "autumn-js",
3
3
  "description": "Autumn JS Library",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -38,11 +38,8 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@clerk/nextjs": "^6.16.0",
41
+ "better-auth": "^1.2.7",
41
42
  "react": "^18.2.0",
42
- "react-dom": "^18.2.0",
43
- "better-auth": "^1.2.7"
44
- },
45
- "dependencies": {
46
- "server-only": "^0.0.1"
43
+ "react-dom": "^18.2.0"
47
44
  }
48
45
  }
package/publish.sh CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/bin/bash
2
2
 
3
- # npm version patch
3
+ # Copy README.md from ../ to ./
4
+ cp ../README.md ./
5
+
6
+ # Copy LICENSE.md from ../ to ./
7
+ cp ../LICENSE.md ./
8
+
9
+ npm version patch
4
10
 
5
11
  npm publish
6
12