@praxium/sdk 0.3.52 → 0.3.61
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/README.md +46 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Official TypeScript SDK for the [Praxium](https://praxium.nl) platform API. Build tenant websites that display practice data (team, services, FAQ, opening hours) with full locale support.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- [Quick Start](#quick-start) — Installation and usage examples
|
|
6
|
+
- [Configuration](#configuration) — Environment variables and tenant routing
|
|
7
|
+
- [Available Methods](#available-methods) — All API endpoints
|
|
8
|
+
- [Error Handling](#error-handling) — Typed error classes
|
|
9
|
+
- [Next.js ISR Revalidation](#nextjs-isr-revalidation) — Webhook-based cache invalidation
|
|
10
|
+
- [Contributing](#contributing) — Development commands
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
6
13
|
|
|
7
14
|
```bash
|
|
8
15
|
npm install @praxium/sdk
|
|
9
16
|
```
|
|
10
17
|
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
18
|
### Locale-Specific Mode
|
|
14
19
|
|
|
15
20
|
Pass a locale to get pre-resolved labels and values in that language:
|
|
@@ -72,6 +77,32 @@ const result = await client.submitContactForm({
|
|
|
72
77
|
// → { success: true, emailStatus: 'sent' }
|
|
73
78
|
```
|
|
74
79
|
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
Your website needs two environment variables to connect to the Praxium platform, plus an optional third for webhook-based cache revalidation:
|
|
83
|
+
|
|
84
|
+
**Required:**
|
|
85
|
+
|
|
86
|
+
| Variable | Purpose | Example |
|
|
87
|
+
|----------|---------|---------|
|
|
88
|
+
| `PRAXIUM_API_URL` | Your tenant's admin portal URL. The SDK sends API requests to this host. | `https://ijfysio.admin.praxium.nl` |
|
|
89
|
+
| `PRAXIUM_API_KEY` | HMAC API key for authentication. Generated in the admin portal under API Profiles. The tenant slug is embedded in the key — no need to configure it separately. | `hmac_v1_ijfysio_default_17..._abc...` |
|
|
90
|
+
|
|
91
|
+
**Optional (only if using ISR revalidation webhooks):**
|
|
92
|
+
|
|
93
|
+
| Variable | Purpose | Example |
|
|
94
|
+
|----------|---------|---------|
|
|
95
|
+
| `PRAXIUM_REVALIDATION_SECRET` | Shared secret for webhook signature verification. Only needed if your website uses ISR and you want the platform to notify your site when data changes (team, FAQ, opening hours). See [Next.js ISR Revalidation](#nextjs-isr-revalidation). | (32+ character random string) |
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# .env.local
|
|
99
|
+
PRAXIUM_API_URL="https://mypractice.admin.praxium.nl"
|
|
100
|
+
PRAXIUM_API_KEY="hmac_v1_mypractice_default_1234567890_abcdef..."
|
|
101
|
+
PRAXIUM_REVALIDATION_SECRET="your-webhook-secret-from-admin-portal" # optional
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> **How tenant routing works:** Each tenant has its own admin subdomain (`{slug}.admin.praxium.nl`). The platform identifies your tenant from both the hostname AND the API key's embedded slug, cross-validating them for security. You don't need to configure the tenant slug separately — it's derived from your API key automatically.
|
|
105
|
+
|
|
75
106
|
## Available Methods
|
|
76
107
|
|
|
77
108
|
| Method | Description |
|
|
@@ -122,28 +153,35 @@ try {
|
|
|
122
153
|
|
|
123
154
|
For websites using Next.js [ISR (Incremental Static Regeneration)](https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration), the SDK provides a webhook handler for on-demand cache revalidation. When an admin updates data (team, FAQ, opening hours), the platform sends an HMAC-signed webhook to your revalidation endpoint. The handler verifies the signature and calls `revalidatePath()` for the affected pages.
|
|
124
155
|
|
|
156
|
+
The `pathMap` is fully customizable — you define which pages to revalidate for each entity based on your website's routing structure:
|
|
157
|
+
|
|
125
158
|
```typescript
|
|
126
159
|
// app/api/revalidate/route.ts
|
|
127
160
|
import { createRevalidationHandler } from '@praxium/sdk/revalidation'
|
|
128
161
|
|
|
129
162
|
export const POST = createRevalidationHandler({
|
|
130
163
|
secret: process.env.PRAXIUM_REVALIDATION_SECRET!,
|
|
164
|
+
// Map platform entities to YOUR website's page paths.
|
|
165
|
+
// These are specific to your project's routing structure —
|
|
166
|
+
// adjust the paths to match your pages.
|
|
131
167
|
pathMap: {
|
|
132
|
-
// entity → locale-prefixed paths to revalidate
|
|
133
168
|
'team': ['/nl/team', '/en/team'],
|
|
134
169
|
'rates': ['/nl/tarieven', '/en/rates'],
|
|
135
170
|
'faq': ['/nl/faq', '/en/faq'],
|
|
136
|
-
'opening-hours': ['/nl', '/en'],
|
|
137
|
-
'all': ['/nl', '/en'],
|
|
171
|
+
'opening-hours': ['/nl', '/en'], // homepage shows opening hours
|
|
172
|
+
'all': ['/nl', '/en'], // full-site revalidation
|
|
138
173
|
},
|
|
139
174
|
})
|
|
140
175
|
```
|
|
141
176
|
|
|
142
|
-
**Prerequisites:**
|
|
177
|
+
**Prerequisites:**
|
|
178
|
+
|
|
179
|
+
1. Register your revalidation endpoint URL in the admin portal (Settings → Webhooks)
|
|
180
|
+
2. Set the `PRAXIUM_REVALIDATION_SECRET` env var to match the webhook secret from the admin portal
|
|
143
181
|
|
|
144
182
|
The handler includes HMAC-SHA256 signature verification, timestamp-based replay protection (5-minute window), and timing-safe comparison. Requires `next` as a peer dependency.
|
|
145
183
|
|
|
146
|
-
##
|
|
184
|
+
## Contributing
|
|
147
185
|
|
|
148
186
|
```bash
|
|
149
187
|
npm run generate # Regenerate client from OpenAPI spec
|