vibeusage 0.3.0 → 0.3.2

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 (127) hide show
  1. package/README.md +19 -11
  2. package/README.zh-CN.md +10 -8
  3. package/node_modules/@insforge/sdk/LICENSE +201 -201
  4. package/node_modules/@insforge/sdk/README.md +326 -259
  5. package/node_modules/@insforge/sdk/dist/index.d.mts +377 -182
  6. package/node_modules/@insforge/sdk/dist/index.d.ts +377 -182
  7. package/node_modules/@insforge/sdk/dist/index.js +1172 -677
  8. package/node_modules/@insforge/sdk/dist/index.js.map +1 -1
  9. package/node_modules/@insforge/sdk/dist/index.mjs +1171 -677
  10. package/node_modules/@insforge/sdk/dist/index.mjs.map +1 -1
  11. package/node_modules/@insforge/sdk/package.json +68 -68
  12. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts +1120 -43
  13. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts.map +1 -1
  14. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js +179 -5
  15. package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js.map +1 -1
  16. package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts +25 -25
  17. package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts.map +1 -1
  18. package/node_modules/@insforge/shared-schemas/dist/ai.schema.js +2 -2
  19. package/node_modules/@insforge/shared-schemas/dist/ai.schema.js.map +1 -1
  20. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts +197 -51
  21. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts.map +1 -1
  22. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js +87 -23
  23. package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js.map +1 -1
  24. package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts +32 -3
  25. package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts.map +1 -1
  26. package/node_modules/@insforge/shared-schemas/dist/auth.schema.js +21 -3
  27. package/node_modules/@insforge/shared-schemas/dist/auth.schema.js.map +1 -1
  28. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts +380 -0
  29. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts.map +1 -1
  30. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js +74 -0
  31. package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js.map +1 -1
  32. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts +13 -13
  33. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js +1 -1
  34. package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js.map +1 -1
  35. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts +735 -0
  36. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts.map +1 -0
  37. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js +209 -0
  38. package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js.map +1 -0
  39. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts +37 -0
  40. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts.map +1 -0
  41. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js +25 -0
  42. package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js.map +1 -0
  43. package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts +5 -1
  44. package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts.map +1 -1
  45. package/node_modules/@insforge/shared-schemas/dist/docs.schema.js +34 -4
  46. package/node_modules/@insforge/shared-schemas/dist/docs.schema.js.map +1 -1
  47. package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js +1 -1
  48. package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js.map +1 -1
  49. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts +186 -6
  50. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts.map +1 -1
  51. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js +21 -2
  52. package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js.map +1 -1
  53. package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts +5 -5
  54. package/node_modules/@insforge/shared-schemas/dist/functions.schema.js +1 -1
  55. package/node_modules/@insforge/shared-schemas/dist/functions.schema.js.map +1 -1
  56. package/node_modules/@insforge/shared-schemas/dist/index.d.ts +24 -18
  57. package/node_modules/@insforge/shared-schemas/dist/index.d.ts.map +1 -1
  58. package/node_modules/@insforge/shared-schemas/dist/index.js +24 -18
  59. package/node_modules/@insforge/shared-schemas/dist/index.js.map +1 -1
  60. package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js +1 -1
  61. package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js.map +1 -1
  62. package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts +43 -0
  63. package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts.map +1 -1
  64. package/node_modules/@insforge/shared-schemas/dist/logs.schema.js +11 -0
  65. package/node_modules/@insforge/shared-schemas/dist/logs.schema.js.map +1 -1
  66. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts +229 -172
  67. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts.map +1 -1
  68. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js +27 -7
  69. package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js.map +1 -1
  70. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts +51 -0
  71. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts.map +1 -0
  72. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js +31 -0
  73. package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js.map +1 -0
  74. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts +31 -0
  75. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts.map +1 -0
  76. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js +12 -0
  77. package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js.map +1 -0
  78. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts +39 -20
  79. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts.map +1 -1
  80. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js +5 -1
  81. package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js.map +1 -1
  82. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts +12 -4
  83. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts.map +1 -1
  84. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js +6 -0
  85. package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js.map +1 -1
  86. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts +287 -0
  87. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts.map +1 -0
  88. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js +81 -0
  89. package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js.map +1 -0
  90. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts +77 -0
  91. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts.map +1 -0
  92. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js +36 -0
  93. package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js.map +1 -0
  94. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts +113 -0
  95. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts.map +1 -0
  96. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js +31 -0
  97. package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js.map +1 -0
  98. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts +31 -0
  99. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts.map +1 -0
  100. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js +13 -0
  101. package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js.map +1 -0
  102. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts +27 -2
  103. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts.map +1 -1
  104. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js +9 -1
  105. package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js.map +1 -1
  106. package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts +17 -0
  107. package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts.map +1 -1
  108. package/node_modules/@insforge/shared-schemas/dist/storage.schema.js +6 -0
  109. package/node_modules/@insforge/shared-schemas/dist/storage.schema.js.map +1 -1
  110. package/node_modules/@insforge/shared-schemas/package.json +2 -1
  111. package/package.json +2 -2
  112. package/src/commands/status.js +22 -5
  113. package/src/commands/sync.js +100 -197
  114. package/src/commands/uninstall.js +0 -11
  115. package/src/lib/diagnostics.js +34 -9
  116. package/src/lib/doctor.js +24 -15
  117. package/src/lib/insforge-client.js +13 -9
  118. package/src/lib/integrations/context.js +0 -6
  119. package/src/lib/integrations/index.js +0 -2
  120. package/src/lib/openclaw-session-plugin.js +48 -138
  121. package/src/lib/openclaw-usage-ledger.js +237 -0
  122. package/src/lib/opencode-sqlite.js +113 -0
  123. package/src/lib/opencode-usage-audit.js +3 -2
  124. package/src/lib/rollout.js +229 -153
  125. package/src/lib/vibeusage-api.js +2 -2
  126. package/src/lib/integrations/openclaw-legacy.js +0 -123
  127. package/src/lib/openclaw-hook.js +0 -420
@@ -1,259 +1,326 @@
1
- # insforge-sdk-js
2
-
3
- [![npm version](https://img.shields.io/npm/v/@insforge/sdk.svg)](https://www.npmjs.com/package/@insforge/sdk)
4
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
-
6
- Official TypeScript/JavaScript SDK for [InsForge](https://github.com/InsForge/InsForge) - A powerful, open-source Backend-as-a-Service (BaaS) platform.
7
-
8
- ## Features
9
-
10
- - **Authentication** - Email/password, OAuth (Google, GitHub), session management
11
- - **Database** - Full PostgreSQL database access with PostgREST
12
- - **Storage** - File upload and management with S3-compatible storage
13
- - **Edge Functions** - Serverless function invocation
14
- - **AI Integration** - Built-in AI capabilities
15
- - **TypeScript** - Full TypeScript support with type definitions
16
- - **Automatic OAuth Handling** - Seamless OAuth callback detection
17
-
18
- ## Installation
19
-
20
- ```bash
21
- npm install @insforge/sdk
22
- ```
23
-
24
- Or with yarn:
25
-
26
- ```bash
27
- yarn add @insforge/sdk
28
- ```
29
-
30
- ## Quick Start
31
-
32
- ### Initialize the Client
33
-
34
- ```javascript
35
- import { createClient } from '@insforge/sdk';
36
-
37
- const insforge = createClient({
38
- baseUrl: 'http://localhost:7130' // Your InsForge backend URL
39
- });
40
- ```
41
-
42
- ### Authentication
43
-
44
- ```javascript
45
- // Sign up a new user
46
- const { data, error } = await insforge.auth.signUp({
47
- email: 'user@example.com',
48
- password: 'securePassword123',
49
- name: 'John Doe' // optional
50
- });
51
-
52
- // Sign in with email/password
53
- const { data, error } = await insforge.auth.signInWithPassword({
54
- email: 'user@example.com',
55
- password: 'securePassword123'
56
- });
57
-
58
- // OAuth authentication (Google, GitHub)
59
- await insforge.auth.signInWithOAuth({
60
- provider: 'google',
61
- redirectTo: 'http://localhost:3000/dashboard'
62
- });
63
-
64
- // Get current user
65
- const { data: user } = await insforge.auth.getCurrentUser();
66
-
67
- // Get any user's profile by ID (public endpoint)
68
- const { data: profile, error } = await insforge.auth.getProfile('user-id-here');
69
-
70
- // Update current user's profile (requires authentication)
71
- const { data: updatedProfile, error } = await insforge.auth.setProfile({
72
- displayName: 'John Doe',
73
- bio: 'Software developer',
74
- avatarUrl: 'https://example.com/avatar.jpg'
75
- });
76
-
77
- // Sign out
78
- await insforge.auth.signOut();
79
- ```
80
-
81
- ### Database Operations
82
-
83
- ```javascript
84
- // Insert data
85
- const { data, error } = await insforge.database
86
- .from('posts')
87
- .insert([
88
- { title: 'My First Post', content: 'Hello World!' }
89
- ]);
90
-
91
- // Query data
92
- const { data, error } = await insforge.database
93
- .from('posts')
94
- .select('*')
95
- .eq('author_id', userId);
96
-
97
- // Update data
98
- const { data, error } = await insforge.database
99
- .from('posts')
100
- .update({ title: 'Updated Title' })
101
- .eq('id', postId);
102
-
103
- // Delete data
104
- const { data, error } = await insforge.database
105
- .from('posts')
106
- .delete()
107
- .eq('id', postId);
108
- ```
109
-
110
- ### File Storage
111
-
112
- ```javascript
113
- // Upload a file
114
- const file = document.querySelector('input[type="file"]').files[0];
115
- const { data, error } = await insforge.storage
116
- .from('avatars')
117
- .upload(file);
118
-
119
- // Download a file
120
- const { data, error } = await insforge.storage
121
- .from('avatars')
122
- .download('user-avatar.png');
123
-
124
- // Delete a file
125
- const { data, error } = await insforge.storage
126
- .from('avatars')
127
- .remove(['user-avatar.png']);
128
-
129
- // List files
130
- const { data, error } = await insforge.storage
131
- .from('avatars')
132
- .list();
133
- ```
134
-
135
- ### Edge Functions
136
-
137
- ```javascript
138
- // Invoke an edge function
139
- const { data, error } = await insforge.functions.invoke('my-function', {
140
- body: { key: 'value' }
141
- });
142
- ```
143
-
144
- ### AI Integration
145
-
146
- ```javascript
147
- // Generate text completion
148
- const { data, error } = await insforge.ai.completion({
149
- model: 'gpt-3.5-turbo',
150
- prompt: 'Write a hello world program'
151
- });
152
-
153
- // Analyze an image
154
- const { data, error } = await insforge.ai.vision({
155
- imageUrl: 'https://example.com/image.jpg',
156
- prompt: 'Describe this image'
157
- });
158
- ```
159
-
160
- ## Documentation
161
-
162
- For complete API reference and advanced usage, see:
163
-
164
- - **[SDK Reference](./SDK-REFERENCE.md)** - Complete API documentation
165
- - **[InsForge Main Repository](https://github.com/InsForge/InsForge)** - Backend platform and setup guides
166
-
167
- ## Configuration
168
-
169
- The SDK supports the following configuration options:
170
-
171
- ```javascript
172
- const insforge = createClient({
173
- baseUrl: 'http://localhost:7130', // Required: Your InsForge backend URL
174
- storageStrategy: 'localStorage' // Optional: 'localStorage' or 'memory' (default: 'localStorage')
175
- });
176
- ```
177
-
178
- ## TypeScript Support
179
-
180
- The SDK is written in TypeScript and provides full type definitions:
181
-
182
- ```typescript
183
- import { createClient, InsForgeClient, User, Session } from '@insforge/sdk';
184
-
185
- const insforge: InsForgeClient = createClient({
186
- baseUrl: 'http://localhost:7130'
187
- });
188
-
189
- // Type-safe API calls
190
- const response: { data: User | null; error: Error | null } =
191
- await insforge.auth.getCurrentUser();
192
- ```
193
-
194
- ## Error Handling
195
-
196
- All SDK methods return a consistent response format:
197
-
198
- ```javascript
199
- const { data, error } = await insforge.auth.signUp({...});
200
-
201
- if (error) {
202
- console.error('Error:', error.message);
203
- console.error('Status:', error.statusCode);
204
- } else {
205
- console.log('Success:', data);
206
- }
207
- ```
208
-
209
- ## Browser Support
210
-
211
- The SDK works in all modern browsers that support:
212
- - ES6+ features
213
- - Fetch API
214
- - LocalStorage (for session management)
215
-
216
- For Node.js environments, ensure you're using Node.js 18 or higher.
217
-
218
- ## Contributing
219
-
220
- We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
221
-
222
- ### Development Setup
223
-
224
- ```bash
225
- # Clone the repository
226
- git clone https://github.com/InsForge/insforge-sdk-js.git
227
- cd insforge-sdk-js
228
-
229
- # Install dependencies
230
- npm install
231
-
232
- # Build the SDK
233
- npm run build
234
-
235
- # Run tests
236
- npm test
237
-
238
- # Run integration tests
239
- npm run test:integration
240
- ```
241
-
242
- ## License
243
-
244
- This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE) file for details.
245
-
246
- ## Community & Support
247
-
248
- - **GitHub Issues**: [Report bugs or request features](https://github.com/InsForge/insforge-sdk-js/issues)
249
- - **Documentation**: [https://docs.insforge.com](https://docs.insforge.com)
250
- - **Main Repository**: [InsForge Backend Platform](https://github.com/InsForge/InsForge)
251
-
252
- ## Related Projects
253
-
254
- - **[InsForge](https://github.com/InsForge/InsForge)** - The main InsForge backend platform
255
- - **[InsForge MCP](https://github.com/InsForge/insforge-mcp)** - Model Context Protocol server for InsForge
256
-
257
- ---
258
-
259
- Built with ❤️ by the InsForge team
1
+ # insforge-sdk-js
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@insforge/sdk.svg)](https://www.npmjs.com/package/@insforge/sdk)
4
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+
6
+ Official TypeScript/JavaScript SDK for [InsForge](https://github.com/InsForge/InsForge) - A powerful, open-source Backend-as-a-Service (BaaS) platform.
7
+
8
+ ## Features
9
+
10
+ - **Authentication** - Email/password, OAuth (Google, GitHub), session management
11
+ - **Database** - Full PostgreSQL database access with PostgREST
12
+ - **Storage** - File upload and management with S3-compatible storage
13
+ - **Edge Functions** - Serverless function invocation
14
+ - **AI Integration** - Built-in AI capabilities
15
+ - **TypeScript** - Full TypeScript support with type definitions
16
+ - **Automatic OAuth Handling** - Seamless OAuth callback detection
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @insforge/sdk
22
+ ```
23
+
24
+ Or with yarn:
25
+
26
+ ```bash
27
+ yarn add @insforge/sdk
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ### Initialize the Client
33
+
34
+ ```javascript
35
+ import { createClient } from '@insforge/sdk';
36
+
37
+ const insforge = createClient({
38
+ baseUrl: 'http://localhost:7130' // Your InsForge backend URL
39
+ });
40
+ ```
41
+
42
+ ### Authentication
43
+
44
+ ```javascript
45
+ // Sign up a new user
46
+ const { data, error } = await insforge.auth.signUp({
47
+ email: 'user@example.com',
48
+ password: 'securePassword123',
49
+ name: 'John Doe', // optional
50
+ redirectTo: 'http://localhost:3000/sign-in' // optional, recommended for link-based verification
51
+ });
52
+
53
+ // Sign in with email/password
54
+ const { data, error } = await insforge.auth.signInWithPassword({
55
+ email: 'user@example.com',
56
+ password: 'securePassword123'
57
+ });
58
+
59
+ // OAuth authentication (built-in or custom provider key)
60
+ await insforge.auth.signInWithOAuth({
61
+ provider: 'google', // e.g. built-in: "google", custom: "auth0-acme"
62
+ redirectTo: 'http://localhost:3000/dashboard'
63
+ });
64
+
65
+ // Get current user (call this during browser app startup)
66
+ const { data: currentUser } = await insforge.auth.getCurrentUser();
67
+
68
+ // Get any user's profile by ID (public endpoint)
69
+ const { data: profile, error } = await insforge.auth.getProfile('user-id-here');
70
+
71
+ // Update current user's profile (requires authentication)
72
+ const { data: updatedProfile, error } = await insforge.auth.setProfile({
73
+ displayName: 'John Doe',
74
+ bio: 'Software developer',
75
+ avatarUrl: 'https://example.com/avatar.jpg'
76
+ });
77
+
78
+ // Sign out
79
+ await insforge.auth.signOut();
80
+ ```
81
+
82
+ ### Email Verification And Password Reset
83
+
84
+ ```javascript
85
+ // Resend a verification email
86
+ await insforge.auth.resendVerificationEmail({
87
+ email: 'user@example.com',
88
+ redirectTo: 'http://localhost:3000/sign-in' // optional, recommended for link-based verification
89
+ });
90
+
91
+ // Verify email with a 6-digit code
92
+ await insforge.auth.verifyEmail({
93
+ email: 'user@example.com',
94
+ otp: '123456'
95
+ });
96
+
97
+ // Send password reset email
98
+ await insforge.auth.sendResetPasswordEmail({
99
+ email: 'user@example.com',
100
+ redirectTo: 'http://localhost:3000/reset-password' // optional, recommended for link-based reset
101
+ });
102
+
103
+ // Code-based reset flow: exchange the code, then reset the password
104
+ const { data: resetToken } = await insforge.auth.exchangeResetPasswordToken({
105
+ email: 'user@example.com',
106
+ code: '123456'
107
+ });
108
+
109
+ if (resetToken) {
110
+ await insforge.auth.resetPassword({
111
+ newPassword: 'newSecurePassword123',
112
+ otp: resetToken.token
113
+ });
114
+ }
115
+ ```
116
+
117
+ For link-based verification and password reset, users click the emailed browser links:
118
+ - `GET /api/auth/email/verify-link`
119
+ - `GET /api/auth/email/reset-password-link`
120
+
121
+ Those backend endpoints validate the token first, then redirect the browser to your `redirectTo` URL.
122
+
123
+ - Verification links redirect with `insforge_status=success|error`, `insforge_type=verify_email`, and optional `insforge_error`
124
+ - Recommended: use your sign-in page as the verification `redirectTo`, then show a confirmation message and ask the user to sign in with email and password
125
+ - Reset links redirect with `token` when ready, plus `insforge_status=ready|error`, `insforge_type=reset_password`, and optional `insforge_error`
126
+
127
+ ### Database Operations
128
+
129
+ ```javascript
130
+ // Insert data
131
+ const { data, error } = await insforge.database
132
+ .from('posts')
133
+ .insert([
134
+ { title: 'My First Post', content: 'Hello World!' }
135
+ ]);
136
+
137
+ // Query data
138
+ const { data, error } = await insforge.database
139
+ .from('posts')
140
+ .select('*')
141
+ .eq('author_id', userId);
142
+
143
+ // Update data
144
+ const { data, error } = await insforge.database
145
+ .from('posts')
146
+ .update({ title: 'Updated Title' })
147
+ .eq('id', postId);
148
+
149
+ // Delete data
150
+ const { data, error } = await insforge.database
151
+ .from('posts')
152
+ .delete()
153
+ .eq('id', postId);
154
+ ```
155
+
156
+ ### File Storage
157
+
158
+ ```javascript
159
+ // Upload a file
160
+ const file = document.querySelector('input[type="file"]').files[0];
161
+ const { data, error } = await insforge.storage
162
+ .from('avatars')
163
+ .upload(file);
164
+
165
+ // Download a file
166
+ const { data, error } = await insforge.storage
167
+ .from('avatars')
168
+ .download('user-avatar.png');
169
+
170
+ // Delete a file
171
+ const { data, error } = await insforge.storage
172
+ .from('avatars')
173
+ .remove(['user-avatar.png']);
174
+
175
+ // List files
176
+ const { data, error } = await insforge.storage
177
+ .from('avatars')
178
+ .list();
179
+ ```
180
+
181
+ ### Edge Functions
182
+
183
+ ```javascript
184
+ // Invoke an edge function
185
+ const { data, error } = await insforge.functions.invoke('my-function', {
186
+ body: { key: 'value' }
187
+ });
188
+ ```
189
+
190
+ ### AI Integration
191
+
192
+ ```javascript
193
+ // Generate text completion
194
+ const { data, error } = await insforge.ai.completion({
195
+ model: 'gpt-3.5-turbo',
196
+ prompt: 'Write a hello world program'
197
+ });
198
+
199
+ // Analyze an image
200
+ const { data, error } = await insforge.ai.vision({
201
+ imageUrl: 'https://example.com/image.jpg',
202
+ prompt: 'Describe this image'
203
+ });
204
+ ```
205
+
206
+ ## Documentation
207
+
208
+ For complete API reference and advanced usage, see:
209
+
210
+ - **[SDK Reference](./SDK-REFERENCE.md)** - Complete API documentation
211
+ - **[InsForge Main Repository](https://github.com/InsForge/InsForge)** - Backend platform and setup guides
212
+
213
+ ## Configuration
214
+
215
+ The SDK supports the following configuration options:
216
+
217
+ ```javascript
218
+ const insforge = createClient({
219
+ baseUrl: 'http://localhost:7130', // Your InsForge backend URL
220
+ anonKey: 'your-anon-key', // Optional
221
+ isServerMode: false // Optional (set true in SSR/server runtime)
222
+ });
223
+ ```
224
+
225
+ ### SSR / Next.js
226
+
227
+ For SSR apps, configure `isServerMode: true`.
228
+ In this mode, auth requests use `client_type=mobile` so auth methods return `refreshToken` in the response body.
229
+ The SDK does not auto-refresh in server mode; your Next.js app should manage refresh token flow.
230
+ In server mode, the SDK does not persist session/user state.
231
+ Read your access token from cookies in Next.js and pass it as `edgeFunctionToken` per request.
232
+ Your app should write/update cookies itself after login/refresh.
233
+
234
+ ```typescript
235
+ import { createClient } from '@insforge/sdk';
236
+ const accessToken = /* read access token from request cookies */ null;
237
+
238
+ const insforge = createClient({
239
+ baseUrl: process.env.INSFORGE_URL!,
240
+ isServerMode: true,
241
+ edgeFunctionToken: accessToken ?? undefined,
242
+ });
243
+ ```
244
+
245
+ ## TypeScript Support
246
+
247
+ The SDK is written in TypeScript and provides full type definitions:
248
+
249
+ ```typescript
250
+ import { createClient, InsForgeClient } from '@insforge/sdk';
251
+
252
+ const insforge: InsForgeClient = createClient({
253
+ baseUrl: 'http://localhost:7130'
254
+ });
255
+
256
+ // Type-safe API calls
257
+ const response =
258
+ await insforge.auth.getCurrentUser();
259
+ ```
260
+
261
+ ## Error Handling
262
+
263
+ All SDK methods return a consistent response format:
264
+
265
+ ```javascript
266
+ const { data, error } = await insforge.auth.signUp({...});
267
+
268
+ if (error) {
269
+ console.error('Error:', error.message);
270
+ console.error('Status:', error.statusCode);
271
+ } else {
272
+ console.log('Success:', data);
273
+ }
274
+ ```
275
+
276
+ ## Browser Support
277
+
278
+ The SDK works in all modern browsers that support:
279
+ - ES6+ features
280
+ - Fetch API
281
+ - Cookies (for refresh token flow)
282
+
283
+ For Node.js environments, ensure you're using Node.js 18 or higher.
284
+
285
+ ## Contributing
286
+
287
+ We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
288
+
289
+ ### Development Setup
290
+
291
+ ```bash
292
+ # Clone the repository
293
+ git clone https://github.com/InsForge/insforge-sdk-js.git
294
+ cd insforge-sdk-js
295
+
296
+ # Install dependencies
297
+ npm install
298
+
299
+ # Build the SDK
300
+ npm run build
301
+
302
+ # Run tests
303
+ npm test
304
+
305
+ # Run integration tests
306
+ npm run test:integration
307
+ ```
308
+
309
+ ## License
310
+
311
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE) file for details.
312
+
313
+ ## Community & Support
314
+
315
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/InsForge/insforge-sdk-js/issues)
316
+ - **Documentation**: [https://docs.insforge.com](https://docs.insforge.com)
317
+ - **Main Repository**: [InsForge Backend Platform](https://github.com/InsForge/InsForge)
318
+
319
+ ## Related Projects
320
+
321
+ - **[InsForge](https://github.com/InsForge/InsForge)** - The main InsForge backend platform
322
+ - **[InsForge MCP](https://github.com/InsForge/insforge-mcp)** - Model Context Protocol server for InsForge
323
+
324
+ ---
325
+
326
+ Built with ❤️ by the InsForge team