@praxium/sdk 0.3.48 → 0.3.50
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 +32 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ npm install @praxium/sdk
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
### Locale-Specific Mode
|
|
14
|
+
|
|
13
15
|
```typescript
|
|
14
16
|
import { createPraxiumClient } from '@praxium/sdk'
|
|
15
17
|
|
|
@@ -50,14 +52,42 @@ const label = localizeText(team[0].customFields[0].label, 'nl') // → "Special
|
|
|
50
52
|
const value = localizeText(team[0].customFields[0].value, 'nl') // → "Sport"
|
|
51
53
|
```
|
|
52
54
|
|
|
55
|
+
### Contact Form
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const result = await client.submitContactForm({
|
|
59
|
+
name: 'Jan de Vries',
|
|
60
|
+
email: 'jan@example.nl',
|
|
61
|
+
phone: '+31612345678',
|
|
62
|
+
subject: 'Afspraak maken',
|
|
63
|
+
message: 'Ik wil graag een afspraak maken.',
|
|
64
|
+
})
|
|
65
|
+
// → { success: true, emailStatus: 'sent' }
|
|
66
|
+
```
|
|
67
|
+
|
|
53
68
|
## Next.js Revalidation
|
|
54
69
|
|
|
55
|
-
|
|
70
|
+
When an admin updates data (team, FAQ, opening hours), a webhook triggers cache revalidation on the tenant website. The SDK handles HMAC signature verification and path resolution.
|
|
56
71
|
|
|
57
72
|
```typescript
|
|
58
|
-
|
|
73
|
+
// app/api/revalidate/route.ts
|
|
74
|
+
import { createRevalidationHandler } from '@praxium/sdk/revalidation'
|
|
75
|
+
|
|
76
|
+
export const POST = createRevalidationHandler({
|
|
77
|
+
secret: process.env.PRAXIUM_REVALIDATION_SECRET!,
|
|
78
|
+
pathMap: {
|
|
79
|
+
// entity → locale-prefixed paths to revalidate
|
|
80
|
+
'team': ['/nl/team', '/en/team'],
|
|
81
|
+
'rates': ['/nl/tarieven', '/en/rates'],
|
|
82
|
+
'faq': ['/nl/faq', '/en/faq'],
|
|
83
|
+
'opening-hours': ['/nl', '/en'],
|
|
84
|
+
'all': ['/nl', '/en'],
|
|
85
|
+
},
|
|
86
|
+
})
|
|
59
87
|
```
|
|
60
88
|
|
|
89
|
+
Security: HMAC-SHA256 signature verification, timestamp-based replay protection (5-min window), timing-safe comparison. Requires `next` as peer dependency.
|
|
90
|
+
|
|
61
91
|
## Development
|
|
62
92
|
|
|
63
93
|
```bash
|