@solvapay/core 1.0.0-preview.19 → 1.0.0-preview.20

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.
Files changed (2) hide show
  1. package/README.md +75 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,87 @@
1
1
  # @solvapay/core
2
2
 
3
- Shared types, schemas, and errors.
3
+ Shared types, schemas, errors, and utilities used across all SolvaPay SDK packages.
4
+
5
+ This package is **runtime-agnostic** -- it contains no Node.js or browser globals and has `"sideEffects": false`.
4
6
 
5
7
  ## Install
6
8
 
7
9
  ```bash
10
+ npm install @solvapay/core
11
+ # or
12
+ yarn add @solvapay/core
13
+ # or
8
14
  pnpm add @solvapay/core
9
15
  ```
10
16
 
11
- ## Usage
17
+ ## Exports
18
+
19
+ ### `SolvaPayError`
20
+
21
+ Base error class for all SolvaPay SDK errors. Useful for catching SDK-specific errors:
22
+
23
+ ```typescript
24
+ import { SolvaPayError } from '@solvapay/core'
12
25
 
13
- ```ts
14
- import { SolvaPayError, Env } from '@solvapay/core'
26
+ try {
27
+ const config = getSolvaPayConfig()
28
+ } catch (error) {
29
+ if (error instanceof SolvaPayError) {
30
+ console.error('SolvaPay error:', error.message)
31
+ }
32
+ }
15
33
  ```
16
34
 
17
- More: [docs/guides/architecture.md](../../docs/guides/architecture.md)
35
+ ### `SolvaPayConfig`
36
+
37
+ Configuration interface for the SDK:
38
+
39
+ ```typescript
40
+ import type { SolvaPayConfig } from '@solvapay/core'
41
+
42
+ const config: SolvaPayConfig = {
43
+ apiKey: 'sk_live_...',
44
+ apiBaseUrl: 'https://api.solvapay.com', // optional
45
+ }
46
+ ```
47
+
48
+ ### `getSolvaPayConfig()`
49
+
50
+ Validates and returns configuration from environment variables. Reads `SOLVAPAY_SECRET_KEY` and optional `SOLVAPAY_API_BASE_URL`:
51
+
52
+ ```typescript
53
+ import { getSolvaPayConfig } from '@solvapay/core'
54
+
55
+ const config = getSolvaPayConfig()
56
+ // config.apiKey - from SOLVAPAY_SECRET_KEY
57
+ // config.apiBaseUrl - from SOLVAPAY_API_BASE_URL (optional)
58
+ ```
59
+
60
+ Throws `SolvaPayError` if `SOLVAPAY_SECRET_KEY` is not set.
61
+
62
+ ### `Env`
63
+
64
+ Zod schema for validating environment variables:
65
+
66
+ ```typescript
67
+ import { Env } from '@solvapay/core'
68
+
69
+ const result = Env.safeParse(process.env)
70
+ if (!result.success) {
71
+ console.error('Invalid environment:', result.error)
72
+ }
73
+ ```
74
+
75
+ ### `version`
76
+
77
+ The current SDK version string.
78
+
79
+ ## When to Use This Package
80
+
81
+ Most developers don't need to install `@solvapay/core` directly -- it's automatically included as a dependency of `@solvapay/server`, `@solvapay/react`, and other packages. Install it directly only if you need access to the shared types or error classes without pulling in a full SDK package.
82
+
83
+ ## More Information
84
+
85
+ - [Architecture Guide](../../docs/guides/architecture.md) - Package design and boundaries
86
+ - [Server SDK](../server/README.md) - Server-side paywall protection
87
+ - [React SDK](../react/README.md) - Client-side payment components
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/core",
3
- "version": "1.0.0-preview.19",
3
+ "version": "1.0.0-preview.20",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",