@spike-forms/sdk 0.2.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/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @spike-forms/sdk
2
+
3
+ TypeScript SDK for the Spike Forms API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @spike-forms/sdk
9
+ # or
10
+ pnpm add @spike-forms/sdk
11
+ # or
12
+ yarn add @spike-forms/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { SpikeClient } from '@spike-forms/sdk';
19
+
20
+ // Initialize the client with your API key
21
+ const client = new SpikeClient({
22
+ apiKey: 'sk_your_api_key_here',
23
+ });
24
+
25
+ // List all forms
26
+ const forms = await client.forms.list();
27
+
28
+ // Create a new form
29
+ const form = await client.forms.create({
30
+ name: 'Contact Form',
31
+ });
32
+
33
+ // Get form submissions
34
+ const submissions = await client.submissions.list(form.id);
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ ```typescript
40
+ const client = new SpikeClient({
41
+ apiKey: 'sk_your_api_key_here',
42
+ baseUrl: 'https://spike.ac', // Optional, defaults to https://spike.ac
43
+ timeout: 30000, // Optional, defaults to 30000ms
44
+ });
45
+ ```
46
+
47
+ ## Resources
48
+
49
+ The SDK provides access to the following resources:
50
+
51
+ - `client.forms` - Manage forms
52
+ - `client.submissions` - Manage form submissions
53
+ - `client.rules` - Manage form rules
54
+ - `client.projects` - Manage projects
55
+ - `client.teams` - Manage teams and members
56
+ - `client.user` - Manage user profile and settings
57
+ - `client.billing` - Manage billing and subscriptions
58
+ - `client.files` - Manage uploaded files
59
+
60
+ ## Error Handling
61
+
62
+ The SDK throws specific error types for different error conditions:
63
+
64
+ ```typescript
65
+ import {
66
+ SpikeError,
67
+ AuthenticationError,
68
+ NotFoundError,
69
+ RateLimitError,
70
+ ValidationError,
71
+ NetworkError,
72
+ } from '@spike-forms/sdk';
73
+
74
+ try {
75
+ await client.forms.get('non-existent-id');
76
+ } catch (error) {
77
+ if (error instanceof NotFoundError) {
78
+ console.log('Form not found');
79
+ } else if (error instanceof AuthenticationError) {
80
+ console.log('Invalid API key');
81
+ } else if (error instanceof RateLimitError) {
82
+ console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
83
+ }
84
+ }
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT